"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3511],{40715:(ae,B,a)=>{a.d(B,{o:()=>E});var s=a(96540),e=a(80348),g=a(97007);function E(I){const D=(0,e.useDispatch)(),N=(0,s.useRef)(I);N.current=I,(0,s.useEffect)(()=>()=>{D((0,g.N)({cleanupAction:N.current}))},[D])}},31987:(ae,B,a)=>{a.r(B),a.d(B,{CreateAlertButton:()=>mt,default:()=>fa});var s=a(32196),e=a(96540),g=a(24180),E=a(41053),I=a(10940),D=a(76885),N=a(66602),C=a(40845),S=a(55852),L=a(83277),P=a(80348),v=a(25027),U=a(33450),M=a(67061),ve=a(76442),J=a(7521),Q=a(41520);const le=()=>{const{canCreateGrafanaRules:t,canCreateCloudRules:n}=(0,Q.V)(),r=(0,C.of)(de);return t||n?e.createElement("div",null,e.createElement("p",null,"You haven't created any alert rules yet"),e.createElement(M.B,{gap:1},e.createElement("div",{className:r.newRuleCard},e.createElement(J.A,{title:"",buttonIcon:"bell",buttonLink:"alerting/new/alerting",buttonTitle:"New alert rule",proTip:"you can also create alert rules from existing panels and queries.",proTipLink:"https://grafana.com/docs/",proTipLinkTitle:"Learn more",proTipTarget:"_blank",onClick:()=>(0,v.fH)(v.le.alertRuleFromScratch)})),e.createElement("div",{className:r.newRuleCard},e.createElement(J.A,{title:"",buttonIcon:"plus",buttonLink:"alerting/new/recording",buttonTitle:"New recording rule",onClick:()=>(0,v.fH)(v.le.recordingRuleFromScratch)})))):e.createElement(ve.c,{message:"No rules exist yet.",callToActionElement:e.createElement("div",null)})},de=t=>({newRuleCard:(0,s.css)`
    width: calc(50% - ${t.spacing(1)});

    > div {
      height: 100%;
    }
  `});var se=a(11536),ne=a(55127),ge=a.n(ne),Re=a(78685),K=a(42418),ee=a(56034),X=a(61410),O=a(57220),Z=a(56361),H=a(23662);function he(){const[t,n]=(0,e.useState)(!1),[r,o]=(0,Re.A)("grafana.unifiedalerting.hideErrors",!1),l=(0,X.$)(d=>d.dataSources),c=(0,X.$)(d=>d.promRules),u=(0,X.$)(d=>d.rulerRules),i=(0,C.of)(Se),m=(0,e.useMemo)(()=>{const[d,p,W]=[l,c,u].map(R=>(0,O.qi)().reduce((h,$)=>{const k=R[$.name]?.error;return R[$.name]&&k&&!(0,H.$7)(R[$.name])?[...h,{dataSource:$,error:k}]:h},[])),y=c[O.hY]?.error,A=u[O.hY]?.error,x=[];return y&&x.push(e.createElement(e.Fragment,null,"Failed to load Grafana rules state: ",y.message||"Unknown error.")),A&&x.push(e.createElement(e.Fragment,null,"Failed to load Grafana rules config: ",A.message||"Unknown error.")),d.forEach(({dataSource:R,error:h})=>{x.push(e.createElement(e.Fragment,null,"Failed to load the data source configuration for"," ",e.createElement("a",{href:(0,Z.GD)(R.uid),className:i.dsLink},R.name),": ",h.message||"Unknown error."))}),p.forEach(({dataSource:R,error:h})=>x.push(e.createElement(e.Fragment,null,"Failed to load rules state from"," ",e.createElement("a",{href:(0,Z.GD)(R.uid),className:i.dsLink},R.name),": ",h.message||"Unknown error."))),W.forEach(({dataSource:R,error:h})=>x.push(e.createElement(e.Fragment,null,"Failed to load rules config from"," ",e.createElement("a",{href:(0,Z.GD)(R.uid),className:i.dsLink},R.name),": ",h.message||"Unknown error."))),x},[l,c,u,i.dsLink]);return e.createElement(e.Fragment,null,!!m.length&&r&&e.createElement(ue,{count:m.length,onClick:()=>o(d=>!d)}),!!m.length&&!r&&e.createElement(K.F,{"data-testid":"cloud-rulessource-errors",title:"Errors loading rules",severity:"error",onRemove:()=>o(!0)},t&&m.map((d,p)=>e.createElement("div",{key:p},d)),!t&&e.createElement(e.Fragment,null,e.createElement("div",null,m[0]),m.length>=2&&e.createElement(S.$n,{className:i.moreButton,fill:"text",icon:"angle-right",size:"sm",onClick:()=>n(!0)},m.length-1," more ",ge()("error",m.length-1)))))}const ue=({count:t,onClick:n})=>{const r=(0,C.of)(Se);return e.createElement("div",{className:r.floatRight},e.createElement(ee.m,{content:"Show all errors",placement:"bottom"},e.createElement(S.$n,{fill:"text",variant:"destructive",icon:"exclamation-triangle",onClick:n},t>1?e.createElement(e.Fragment,null,t," errors"):e.createElement(e.Fragment,null,"1 error"))))},Se=t=>({moreButton:(0,s.css)`
    padding: 0;
  `,floatRight:(0,s.css)`
    display: flex;
    justify-content: flex-end;
  `,dsLink:(0,s.css)`
    font-weight: ${t.typography.fontWeightBold};
  `});var te=a(19073),je=a(64853),Ce=a(39558),Te=a(62930),Ye=a(19384),Ve=a(15054),we=a(98439),Je=a(22620),Pe=a(88467),Qe=a(66864),Ee=a(14578),Ne=a(39938),dt=a(96374),gt=a(11167),Et=a(83903),Me=a(23770),Xe=a(64047),Ze=a(82437),Le=a(79938),be=a(16293),Fe=a(76648),Be=a(84029);function pt({folder:t,onClose:n}){const[r,o]=(0,e.useState)("yaml");return e.createElement(Fe.m,{title:`Export ${t.title} rules`,activeTab:r,onTabChange:o,onClose:n,formatProviders:Object.values(Be.sl)},e.createElement(ft,{folder:t,exportFormat:r,onClose:n}))}function ft({folder:t,exportFormat:n,onClose:r}){const{currentData:o="",isFetching:l}=Le.hK.endpoints.exportRules.useQuery({folderUid:t.uid,format:n});if(l)return e.createElement(Ce._,{text:"Loading...."});const c=`${t.title}-${t.uid}`;return e.createElement(be.J,{format:n,textDefinition:o,downloadFileName:c,onClose:r})}function vt({folderUid:t,groupName:n,onClose:r}){const[o,l]=(0,e.useState)("yaml");return e.createElement(Fe.m,{title:`Export ${n} rules`,activeTab:o,onTabChange:l,onClose:r,formatProviders:Object.values(Be.sl)},e.createElement(ht,{folderUid:t,groupName:n,exportFormat:o,onClose:r}))}function ht({folderUid:t,groupName:n,exportFormat:r,onClose:o}){const{currentData:l="",isFetching:c}=Le.hK.endpoints.exportRules.useQuery({folderUid:t,group:n,format:r});return c?e.createElement(Ce._,{text:"Loading...."}):e.createElement(be.J,{format:r,textDefinition:l,downloadFileName:n,onClose:o})}var ke=a(99106),oe=a(72275),yt=a(46479),Rt=a(46942),qe=a.n(Rt),ye=a(2543),$e=a(75494),Ct=a(37390),xt=a(99140),Dt=a(18461),St=a(30423);const Pt=t=>{const{group:n,namespace:r,onClose:o,folderUid:l}=t,[c,u]=(0,e.useState)(!1),[i,m]=(0,e.useState)(n.rules),d=(0,C.of)(Ue),p=(0,e.useCallback)(y=>{if(!y.destination||y.destination.index===y.source.index)return;const x=It(i,y.source.index,y.destination.index);m(x);const R=(0,O.EV)(r.rulesSource),h=(0,ye.compact)(x.map($=>$.rulerRule));u(!0),(0,xt.JD)((0,Me.DN)({namespaceName:r.name,groupName:n.name,rulesSourceName:R,newRules:h,folderUid:l||r.name})).unwrap().finally(()=>{u(!1)})},[n.name,r.name,r.rulesSource,i,l]),W=i.map(y=>({...y,uid:String((0,Dt.Ns)(y.rulerRule))}));return e.createElement(Ct.a,{className:d.modal,isOpen:!0,title:e.createElement(Mt,{namespace:r,group:n}),onDismiss:o,onClickBackdrop:o},e.createElement($e.JY,{onDragEnd:p},e.createElement($e.gL,{droppableId:"alert-list",mode:"standard",renderClone:(y,A,x)=>e.createElement(_e,{provided:y,rule:W[x.source.index],isClone:!0})},y=>e.createElement("div",{ref:y.innerRef,className:qe()(d.listContainer,c&&d.disabled),...y.droppableProps},W.map((A,x)=>e.createElement($e.sx,{key:A.uid,draggableId:A.uid,index:x,isDragDisabled:c},R=>e.createElement(_e,{key:A.uid,provided:R,rule:A}))),y.placeholder))))},_e=({provided:t,rule:n,isClone:r=!1,isDragging:o=!1})=>{const l=(0,C.of)(Ue);return e.createElement("div",{className:qe()(l.listItem,r&&"isClone",o&&"isDragging"),ref:t.innerRef,...t.draggableProps,...t.dragHandleProps},(0,H.Z8)(n.promRule)&&e.createElement(St.C,{state:n.promRule.state}),(0,H.KB)(n.promRule)&&e.createElement(Ne.E,{text:"Recording",color:"blue"}),e.createElement("div",{className:l.listItemName},n.name),e.createElement(Ee.I,{name:"draggabledots"}))},Mt=({namespace:t,group:n})=>{const r=(0,C.of)(Ue);return e.createElement("div",{className:r.header},e.createElement(Ee.I,{name:"folder"}),(0,O.Eb)(t.rulesSource)&&e.createElement(ee.m,{content:t.rulesSource.name,placement:"top"},e.createElement("img",{alt:t.rulesSource.meta.name,className:r.dataSourceIcon,src:t.rulesSource.meta.info.logos.small})),e.createElement("span",null,t.name),e.createElement(Ee.I,{name:"angle-right"}),e.createElement("span",null,n.name))},Ue=t=>({modal:(0,s.css)`
    max-width: 640px;
    max-height: 80%;
    overflow: hidden;
  `,listItem:(0,s.css)`
    display: flex;
    flex-direction: row;
    align-items: center;

    gap: ${t.spacing()};

    background: ${t.colors.background.primary};
    color: ${t.colors.text.secondary};

    border-bottom: solid 1px ${t.colors.border.medium};
    padding: ${t.spacing(1)} ${t.spacing(2)};

    &:last-child {
      border-bottom: none;
    }

    &.isClone {
      border: solid 1px ${t.colors.primary.shade};
    }
  `,listContainer:(0,s.css)`
    user-select: none;
    border: solid 1px ${t.colors.border.medium};
  `,disabled:(0,s.css)`
    opacity: 0.5;
    pointer-events: none;
  `,listItemName:(0,s.css)`
    flex: 1;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  `,header:(0,s.css)`
    display: flex;
    align-items: center;

    gap: ${t.spacing(1)};
  `,dataSourceIcon:(0,s.css)`
    width: ${t.spacing(2)};
    height: ${t.spacing(2)};
  `});function It(t,n,r){const o=Array.from(t),[l]=o.splice(n,1);return o.splice(r,0,l),o}var et=a(92467),tt=a(82422);const We=e.memo(({group:t,namespace:n,expandAll:r,viewMode:o})=>{const{rulesSource:l}=n,c=(0,P.useDispatch)(),u=(0,C.of)(Ot),[i,m]=(0,e.useState)(!1),[d,p]=(0,e.useState)(!1),[W,y]=(0,e.useState)(!1),[A,x]=(0,e.useState)(void 0),[R,h]=(0,e.useState)(!r),{canEditRules:$}=(0,Q.V)();(0,e.useEffect)(()=>{h(!r)},[r]);const{hasRuler:k,rulerRulesLoaded:b}=(0,Et.y)(),F=t.rules[0]?.rulerRule,G=F&&(0,H.lT)(F)&&F.grafana_alert.namespace_uid||void 0,{folder:T}=(0,gt.a)(G),Y=k(l)&&b(l)&&!t.rules.find(q=>!!q.rulerRule),z=(0,H.YN)(t),ie=t.rules.some(q=>(0,H.lT)(q.rulerRule)&&q.rulerRule.grafana_alert.provenance),re=o==="list",V=o==="grouped",f=()=>{c((0,Me.g6)(n,t)),p(!1)},w=[];if(Y)w.push(e.createElement(Qe.Gy,{key:"is-deleting"},e.createElement(Te.y,null),"deleting"));else if(l===O.hY){if(G){const q=(0,Z.NH)(G);T?.canSave&&(V&&!ie&&(w.push(e.createElement(oe.M,{"aria-label":"edit rule group","data-testid":"edit-group",key:"edit",icon:"pen",tooltip:"edit rule group",onClick:()=>m(!0)})),w.push(e.createElement(oe.M,{"aria-label":"re-order rules","data-testid":"reorder-group",key:"reorder",icon:"exchange-alt",tooltip:"reorder rules",className:u.rotate90,onClick:()=>y(!0)}))),re&&(w.push(e.createElement(oe.M,{"aria-label":"go to folder",key:"goto",icon:"folder-open",tooltip:"go to folder",to:q,target:"__blank"})),T?.canAdmin&&w.push(e.createElement(oe.M,{"aria-label":"manage permissions",key:"manage-perms",icon:"lock",tooltip:"manage permissions",to:q+"/permissions",target:"__blank"})))),T&&(re?w.push(e.createElement(oe.M,{"aria-label":"export rule folder","data-testid":"export-folder",key:"export-folder",icon:"download-alt",tooltip:"Export rules folder",onClick:()=>x("folder")})):V&&w.push(e.createElement(oe.M,{"aria-label":"export rule group","data-testid":"export-group",key:"export-group",icon:"download-alt",tooltip:"Export rule group",onClick:()=>x("group")})))}}else $(l.name)&&k(l)&&(z||(w.push(e.createElement(oe.M,{"aria-label":"edit rule group","data-testid":"edit-group",key:"edit",icon:"pen",tooltip:"edit rule group",onClick:()=>m(!0)})),w.push(e.createElement(oe.M,{"aria-label":"re-order rules","data-testid":"reorder-group",key:"reorder",icon:"exchange-alt",tooltip:"re-order rules",className:u.rotate90,onClick:()=>y(!0)}))),w.push(e.createElement(oe.M,{"aria-label":"delete rule group","data-testid":"delete-group",key:"delete-group",icon:"trash-alt",tooltip:"delete rule group",onClick:()=>p(!0)})));const fe=re?e.createElement(Ze.c,{namespace:(0,ke.EL)(n).name}):e.createElement(Ze.c,{namespace:(0,ke.EL)(n).name,group:t.name}),me=(q=!1)=>{q||(0,v.fH)(v.le.leavingRuleGroupEdit),m(!1)};return e.createElement("div",{className:u.wrapper,"data-testid":"rule-group"},e.createElement("div",{className:u.header,"data-testid":"rule-group-header"},e.createElement(Xe.e,{size:"sm",className:u.collapseToggle,isCollapsed:R,onToggle:h,"data-testid":"group-collapse-toggle"}),e.createElement(Ee.I,{name:R?"folder":"folder-open"}),(0,O.Eb)(l)&&e.createElement(ee.m,{content:l.name,placement:"top"},e.createElement("img",{alt:l.meta.name,className:u.dataSourceIcon,src:l.meta.info.logos.small})),e.createElement("div",{className:u.groupName,onClick:()=>h(!R)},z&&e.createElement(Ne.E,{color:"purple",text:"Federated"})," ",fe),e.createElement("div",{className:u.spacer}),e.createElement("div",{className:u.headerStats},e.createElement(et.j7,{group:t})),ie&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.actionsSeparator},"|"),e.createElement("div",{className:u.actionIcons},e.createElement(Ne.E,{color:"purple",text:"Provisioned"}))),!!w.length&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.actionsSeparator},"|"),e.createElement("div",{className:u.actionIcons},e.createElement(M.B,{gap:.5},w)))),!R&&e.createElement(tt.s,{showSummaryColumn:!0,className:u.rulesTable,showGuidelines:!0,showNextEvaluationColumn:!!t.interval,rules:t.rules}),i&&e.createElement(yt.u5,{namespace:n,group:t,onClose:()=>me(),folderUrl:T?.canEdit?(0,Z.qN)(T.uid):void 0,folderUid:G}),W&&e.createElement(Pt,{group:t,folderUid:G,namespace:n,onClose:()=>y(!1)}),e.createElement(dt.u,{isOpen:d,title:"Delete group",body:e.createElement("div",null,e.createElement("p",null,'Deleting "',e.createElement("strong",null,t.name),'" will permanently remove the group and'," ",t.rules.length," alert ",ge()("rule",t.rules.length)," belonging to it."),e.createElement("p",null,"Are you sure you want to delete this group?")),onConfirm:f,onDismiss:()=>p(!1),confirmText:"Delete"}),T&&A==="folder"&&e.createElement(pt,{folder:T,onClose:()=>x(void 0)}),T&&A==="group"&&e.createElement(vt,{folderUid:T.uid,groupName:t.name,onClose:()=>x(void 0)}))});We.displayName="RulesGroup";const Ot=t=>({wrapper:(0,s.css)``,header:(0,s.css)`
      display: flex;
      flex-direction: row;
      align-items: center;
      padding: ${t.spacing(1)} ${t.spacing(1)} ${t.spacing(1)} 0;
      flex-wrap: nowrap;
      border-bottom: 1px solid ${t.colors.border.weak};

      &:hover {
        background-color: ${t.components.table.rowHoverBackground};
      }
    `,headerStats:(0,s.css)`
      flex-shrink: 0;

      span {
        vertical-align: middle;
      }

      ${t.breakpoints.down("sm")} {
        order: 2;
        width: 100%;
        padding-left: ${t.spacing(1)};
      }
    `,groupName:(0,s.css)`
      margin-left: ${t.spacing(1)};
      margin-bottom: 0;
      cursor: pointer;

      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    `,spacer:(0,s.css)`
      flex: 1;
    `,collapseToggle:(0,s.css)`
      background: none;
      border: none;
      margin-top: -${t.spacing(1)};
      margin-bottom: -${t.spacing(1)};

      svg {
        margin-bottom: 0;
      }
    `,dataSourceIcon:(0,s.css)`
      width: ${t.spacing(2)};
      height: ${t.spacing(2)};
      margin-left: ${t.spacing(2)};
    `,dataSourceOrigin:(0,s.css)`
      margin-right: 1em;
      color: ${t.colors.text.disabled};
    `,actionsSeparator:(0,s.css)`
      margin: 0 ${t.spacing(2)};
    `,actionIcons:(0,s.css)`
      width: 80px;
      align-items: center;

      flex-shrink: 0;
    `,rulesTable:(0,s.css)`
      margin: ${t.spacing(2,0)};
    `,rotate90:(0,s.css)`
      transform: rotate(90deg);
    `});function at(t){return(0,e.useMemo)(()=>t.flatMap(n=>n.groups.map(r=>({namespace:n,group:r}))),[t])}const At=({namespaces:t,expandAll:n})=>{const r=(0,C.of)(Tt),o=(0,X.$)(h=>h.dataSources),l=(0,X.$)(h=>h.promRules),c=(0,e.useMemo)(O.qi,[]),u=at(t),i=(0,e.useMemo)(()=>c.filter(h=>(0,Pe.ML)(l[h.name])||(0,Pe.ML)(o[h.name])),[l,o,c]),m=c.some(h=>!!l[h.name]?.result?.length),d=c.length>0,p=i.length>0,W=t.length>0,{numberOfPages:y,onPageChange:A,page:x,pageItems:R}=(0,we.W)(u,1,Ve.FG);return e.createElement("section",{className:r.wrapper},e.createElement("div",{className:r.sectionHeader},e.createElement("div",{className:r.headerRow},e.createElement("h5",null,"Mimir / Cortex / Loki"),i.length?e.createElement(Ce._,{className:r.loader,text:`Loading rules from ${i.length} ${ge()("source",i.length)}`}):e.createElement("div",null),e.createElement(Nt,null))),R.map(({group:h,namespace:$})=>e.createElement(We,{group:h,key:`${(0,O.v0)($.rulesSource)}-${$.name}-${h.name}`,namespace:$,expandAll:n,viewMode:"grouped"})),!d&&e.createElement("p",null,"There are no Prometheus or Loki data sources configured."),d&&!p&&!W&&e.createElement("p",null,"No rules found."),!m&&p&&e.createElement(Te.y,{size:"xl",className:r.spinner}),e.createElement(Ye.d,{className:r.pagination,currentPage:x,numberOfPages:y,onNavigate:A,hideWhenSinglePage:!0}))},Tt=t=>({loader:(0,s.css)`
    margin-bottom: 0;
  `,sectionHeader:(0,s.css)`
    display: flex;
    justify-content: space-between;
  `,wrapper:(0,s.css)`
    margin-bottom: ${t.spacing(4)};
  `,spinner:(0,s.css)`
    text-align: center;
    padding: ${t.spacing(2)};
  `,pagination:(0,Je.H)(t),headerRow:(0,s.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",marginBottom:t.spacing(1)})});function Nt(){const[t,n]=(0,te.Ej)(te.RY.CreateExternalAlertRule),r=(0,g.zy)();return t&&n?e.createElement(S.z9,{key:"new-recording-rule",href:D.kM.renderUrl("alerting/new/recording",{returnTo:r.pathname+r.search}),icon:"plus",variant:"secondary"},"New recording rule"):null}var Lt=a(42941),xe=a(9518);function bt({onClose:t}){const[n,r]=(0,e.useState)("yaml");return e.createElement(Fe.m,{activeTab:n,onTabChange:r,onClose:t,formatProviders:Object.values(Be.sl)},e.createElement(Ft,{exportFormat:n,onClose:t}))}function Ft({exportFormat:t,onClose:n}){const{currentData:r="",isFetching:o}=Le.hK.endpoints.exportRules.useQuery({format:t}),l=`alert-rules-${new Date().getTime()}`;return o?e.createElement(Ce._,{text:"Loading...."}):e.createElement(be.J,{format:t,textDefinition:r,downloadFileName:l,onClose:n})}const Bt=({namespaces:t,expandAll:n})=>{const r=(0,C.of)($t),[o]=(0,L.s)(),{prom:l,ruler:c}=(0,X.$)(G=>({prom:G.promRules[O.hY]||Pe.jA,ruler:G.rulerRules[O.hY]||Pe.jA})),u=l.loading||c.loading,i=!!l.result||!!c.result,m=o.view==="list",d=m?(0,xe.Jr)(t):t,p=at(d),{numberOfPages:W,onPageChange:y,page:A,pageItems:x}=(0,we.W)(p,1,Ve.FG),[R,h]=(0,te.Ej)(te.RY.ExportGrafanaManagedRules),$=R&&h,[k,b]=(0,Lt.A)(!1),F=t.length>0;return e.createElement("section",{className:r.wrapper},e.createElement("div",{className:r.sectionHeader},e.createElement("div",{className:r.headerRow},e.createElement("h5",null,"Grafana"),u?e.createElement(Ce._,{className:r.loader,text:"Loading..."}):e.createElement("div",null),F&&$&&e.createElement(S.$n,{"aria-label":"export all grafana rules","data-testid":"export-all-grafana-rules",icon:"download-alt",tooltip:"Export all Grafana-managed rules",onClick:b,variant:"secondary"},"Export rules"))),x.map(({group:G,namespace:T})=>e.createElement(We,{group:G,key:`${T.name}-${G.name}`,namespace:T,expandAll:n,viewMode:m?"list":"grouped"})),i&&d?.length===0&&e.createElement("p",null,"No rules found."),!i&&u&&e.createElement(Te.y,{size:"xl",className:r.spinner}),e.createElement(Ye.d,{className:r.pagination,currentPage:A,numberOfPages:W,onNavigate:y,hideWhenSinglePage:!0}),$&&k&&e.createElement(bt,{onClose:b}))},$t=t=>({loader:(0,s.css)`
    margin-bottom: 0;
  `,sectionHeader:(0,s.css)`
    display: flex;
    justify-content: space-between;
    margin-bottom: ${t.spacing(1)};
  `,wrapper:(0,s.css)`
    margin-bottom: ${t.spacing(4)};
  `,spinner:(0,s.css)`
    text-align: center;
    padding: ${t.spacing(2)};
  `,pagination:(0,Je.H)(t),headerRow:(0,s.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",flexDirection:"row"})}),Ut=({namespaces:t,expandAll:n})=>{const[r,o]=(0,e.useMemo)(()=>{const l=t.map(c=>({...c,groups:c.groups.sort((u,i)=>u.name.localeCompare(i.name))})).sort((c,u)=>c.name.localeCompare(u.name));return[l.filter(c=>(0,O.z2)(c.rulesSource)),l.filter(c=>(0,O.Eb)(c.rulesSource))]},[t]);return(0,e.useEffect)(()=>{(0,v.fH)(v.le.loadedList)},[]),e.createElement(e.Fragment,null,e.createElement(je._,{actions:[te.RY.ViewAlertRule]},e.createElement(Bt,{namespaces:r,expandAll:n})),e.createElement(je._,{actions:[te.RY.ViewExternalAlertRule]},e.createElement(At,{namespaces:o,expandAll:n})))};var j=a(94822);const Ke=({rules:t,state:n,defaultCollapsed:r=!1})=>{const[o,l]=(0,e.useState)(r),c=(0,C.of)(Wt);return e.createElement(e.Fragment,null,e.createElement("h4",{className:c.header},e.createElement(Xe.e,{className:c.collapseToggle,size:"xxl",isCollapsed:o,onToggle:()=>l(!o)}),(0,H.XI)(n)," (",t.length,")"),!o&&e.createElement(tt.s,{className:c.rulesTable,rules:t,showGroupColumn:!0}))},Wt=t=>({collapseToggle:(0,s.css)`
    vertical-align: middle;
  `,header:(0,s.css)`
    margin-top: ${t.spacing(2)};
  `,rulesTable:(0,s.css)`
    margin-top: ${t.spacing(3)};
  `}),Kt=({namespaces:t})=>{const n=(0,Z.Ht)((0,L.s)()[0]),r=(0,e.useMemo)(()=>{const o={[j.cF.Firing]:[],[j.cF.Inactive]:[],[j.cF.Pending]:[]};return t.forEach(l=>l.groups.forEach(c=>c.rules.forEach(u=>{u.promRule&&(0,H.Z8)(u.promRule)&&o[u.promRule.state].push(u)}))),Object.values(o).forEach(l=>l.sort((c,u)=>c.name.localeCompare(u.name))),o},[t]);return e.createElement(e.Fragment,null,(!n.alertState||n.alertState===j.cF.Firing)&&e.createElement(Ke,{state:j.cF.Firing,rules:r[j.cF.Firing]}),(!n.alertState||n.alertState===j.cF.Pending)&&e.createElement(Ke,{state:j.cF.Pending,rules:r[j.cF.Pending]}),(!n.alertState||n.alertState===j.cF.Inactive)&&e.createElement(Ke,{defaultCollapsed:n.alertState!==j.cF.Inactive,state:j.cF.Inactive,rules:r[j.cF.Inactive]}))};var Gt=a(49785),Ge=a(88575),pe=a(60029),Ie=a(94354),zt=a(10354),Ht=a(59429),jt=a(53076),Yt=a(1932),nt=a(19347),De=a(28475),Oe=a(98164),rt=a(55740),Vt=a(32642),wt=a(39964);const Jt=25,ze=1/0;function lt(){const[t,n]=(0,wt.l)(),r=t.get("search")??"",o=(0,e.useMemo)(()=>(0,De.XY)(r),[r]),l=(0,e.useMemo)(()=>Object.values(o).some(i=>!(0,ye.isEmpty)(i)),[o]),c=(0,e.useCallback)(i=>{const m=(0,De.kL)(r,i);n({search:m})},[r,n]),u=(0,e.useCallback)(i=>{n({search:i})},[n]);return(0,e.useEffect)(()=>{const i={dataSource:t.get("dataSource")??void 0,alertState:t.get("alertState")??void 0,ruleType:t.get("ruleType")??void 0,labels:(0,Oe.J$)(t.get("queryString")??"").map(Oe.MU)};Object.values(i).some(d=>!(0,ye.isEmpty)(d))&&(n({dataSource:void 0,alertState:void 0,ruleType:void 0,queryString:void 0}),c((0,Yt.jM)(o,d=>{if(d.dataSourceNames??=i.dataSource?[i.dataSource]:[],i.alertState&&(0,j.Si)(i.alertState)&&(d.ruleState??=i.alertState),i.ruleType&&(0,H.nf)(i.ruleType)&&(d.ruleType??=i.ruleType),d.labels.length===0&&i.labels.length>0){const p=i.labels.map(({name:W,operator:y,value:A})=>`${W}${y}${A}`);d.labels.push(...p)}})))},[t,c,o,n]),{filterState:o,hasActiveFilters:l,searchQuery:r,setSearchQuery:u,updateFilters:c}}const Qt=(t,n)=>(0,e.useMemo)(()=>{const r=Xt(t,n);return r.forEach(o=>{o.groups.forEach(l=>{l.rules.forEach(c=>{(0,H.Z8)(c.promRule)&&(c.instanceTotals=(0,xe.Ug)(c.promRule),c.filteredInstanceTotals=(0,xe.NW)(c.promRule))}),l.totals=(0,xe.Tj)({rules:l.rules.map(c=>c.promRule).filter(c=>!!c)})})}),r},[t,n]),Xt=(t,n={dataSourceNames:[],labels:[],freeFormWords:[]})=>{let r=t;const o=n.dataSourceNames;o.length&&(r=r.filter(({rulesSource:c})=>(0,O.Eb)(c)?o.includes(c.name):!0));const l=n.namespace;if(l){const c=r.map(p=>p.name),u=Ae(l),[i,m,d]=u.search(c,l,He(l),ze);m&&d?r=d.map(p=>r[m.idx[p]]):i&&(r=i.map(p=>r[p]))}return r.reduce(Zt(n),[])},Zt=t=>(n,r)=>{const o=t.groupName;let l=r.groups;if(o){const c=l.map(p=>p.name),u=Ae(o),[i,m,d]=u.search(c,o,He(o),ze);m&&d?l=d.map(p=>l[m.idx[p]]):i&&(l=i.map(p=>l[p]))}return l=l.reduce(kt(t),[]),l.length&&n.push({...r,groups:l}),n},kt=t=>{const n=t.ruleName??t.freeFormWords.join(" ");return(r,o)=>{let l=o.rules;if(n){const c=l.map(p=>p.name),u=Ae(n),[i,m,d]=u.search(c,n,He(n),ze);m&&d?l=d.map(p=>l[m.idx[p]]):i&&(l=i.map(p=>l[p]))}return l=l.filter(c=>{const u=c.promRule,i=(0,ye.chain)(t).pick(["ruleType","dataSourceNames","ruleHealth","labels","ruleState","dashboardUid"]).omitBy(ye.isEmpty).mapValues(()=>!1).value();if("ruleType"in i&&t.ruleType===u?.type&&(i.ruleType=!0),"dataSourceNames"in i&&((0,H.lT)(c.rulerRule)?_t(c.rulerRule,t)&&(i.dataSourceNames=!0):i.dataSourceNames=!0),"ruleHealth"in t&&u){const m=(0,H.f6)(u.health);t.ruleHealth===m&&(i.ruleHealth=!0)}if("labels"in i){const m=(0,ye.compact)(t.labels.map(qt)),d=m.length>0&&(0,Oe.Av)(c.labels,m),p=m.length>0&&u&&u.type===j.JS.Alerting&&u.alerts&&u.alerts.some(W=>(0,Oe.Av)(W.labels,m));(d||p)&&(i.labels=!0)}if("ruleState"in i){const m=c.promRule;m&&(0,H.Z8)(m)&&m.state===t.ruleState&&(i.ruleState=!0)}return"dashboardUid"in i&&c.annotations[rt.YH.dashboardUID]===t.dashboardUid&&(i.dashboardUid=!0),Object.values(i).every(m=>m===!0)}),l.length&&r.push({...o,rules:l}),r}};function He(t){return Ae(t).split(t).length<5?4:0}function qt(t){try{return(0,Vt.qR)(t)}catch{return{name:t,value:"",isRegex:!0,isEqual:!0}}}function Ae(t){const n=t.length>Jt;return new jt.A({intraMode:n?0:1,interSplit:"\\s+"})}const _t=(t,n)=>n.dataSourceNames?.length?!!t.grafana_alert.data.find(r=>{if(!r.datasourceUid)return!1;const o=(0,nt.l)().getInstanceSettings(r.datasourceUid);return o?.name&&n?.dataSourceNames?.includes(o.name)}):!0;var ea=a(35108),ta=a(22391),aa=a(51527),st=a(13544),ot=a(26657),na=a(88323),ra=a(98624);const la=t=>{const n=(0,nt.l)(),[r,o]=(0,e.useState)(),l=(b,F)=>{if(F.action==="clear"&&t.onClear){t.onClear();return}const G=b[b.length-1];let T,Y;F.action==="pop-value"||F.action==="remove-value"?(T=F.removedValue?.value,Y="remove"):(T=G.value,Y="add");const z=n.getInstanceSettings(T);z&&(t.onChange(z,Y),o({error:void 0}))},c=()=>{const{current:b,hideTextValue:F,noDefault:G}=t;if(!(!b&&G))return b?.map(T=>{const Y=n.getInstanceSettings(T);if(Y)return{label:Y.name.slice(0,37),value:Y.name,imgUrl:Y.meta.info.logos.small,hideText:F,meta:Y.meta};const z=(0,ta.Iz)(T);return z===ot.dR.uid||z===ot.dR.name?{label:z,value:z,hideText:F}:{label:(z??"no name")+" - not found",value:z??void 0,imgUrl:"",hideText:F}})},u=()=>{const{alerting:b,tracing:F,metrics:G,mixed:T,dashboard:Y,variables:z,annotations:ie,pluginId:re,type:V,filter:f,logs:w}=t,fe=n.getList({alerting:b,tracing:F,metrics:G,logs:w,dashboard:Y,mixed:T,variables:z,annotations:ie,pluginId:re,filter:f,type:V}),me=fe.filter(O.hP).map(_=>({value:_.name,label:`${_.name}${_.isDefault?" (default)":""}`,imgUrl:_.meta.info.logos.small,meta:_.meta})),q=fe.filter(_=>!(0,O.hP)(_)).map(_=>({value:_.name,label:`${_.name}${_.isDefault?" (default)":""}`,imgUrl:_.meta.info.logos.small,meta:_.meta}));return[{label:"Data sources with configured alert rules",options:me,expanded:!0},{label:"Other data sources",options:q,expanded:!0}]},{autoFocus:i,onBlur:m,onClear:d,openMenuOnFocus:p,placeholder:W,width:y,inputId:A,disabled:x=!1,isLoading:R=!1}=t,h=u(),$=c(),k=typeof d=="function";return e.createElement("div",{"data-testid":st.Tp.components.DataSourcePicker.container},e.createElement(na.KF,{isLoading:R,disabled:x,"data-testid":st.Tp.components.DataSourcePicker.inputV2,inputId:A||"data-source-picker",className:"ds-picker select-container",isClearable:k,backspaceRemovesValue:!0,onChange:l,options:h,autoFocus:i,onBlur:m,width:y,openMenuOnFocus:p,maxMenuHeight:500,placeholder:W,noOptionsMessage:"No datasources found",value:$??[],invalid:!!r?.error||!!t.invalid,getOptionLabel:b=>b.meta&&(0,aa.x)(b.meta.signature)&&b!==$?e.createElement(Qe.Gy,{align:"center",justify:"space-between",height:"auto"},e.createElement("span",null,b.label)," ",e.createElement(ra.B,{status:b.meta.signature})):b.label||""}))},ct=[{icon:"folder",label:"Grouped",value:"grouped"},{icon:"list-ul",label:"List",value:"list"},{icon:"heart-rate",label:"State",value:"state"}],sa=[{label:"Alert ",value:j.JS.Alerting},{label:"Recording ",value:j.JS.Recording}],oa=[{label:"Ok",value:De.Jc.Ok},{label:"No Data",value:De.Jc.NoData},{label:"Error",value:De.Jc.Error}],ca=Object.entries(j.cF).map(([t,n])=>({label:(0,H.XI)(n),value:n})),ia=({onFilterCleared:t=()=>{}})=>{const n=(0,C.of)(ua),[r,o]=(0,L.s)(),{filterState:l,hasActiveFilters:c,searchQuery:u,setSearchQuery:i,updateFilters:m}=lt(),[d,p]=(0,e.useState)(Math.floor(Math.random()*100)),W=`dataSource-${d}`,y=`queryString-${d}`,A=(0,e.useRef)(null),{handleSubmit:x,register:R,setValue:h}=(0,Gt.mN)({defaultValues:{searchQuery:u}}),{ref:$,...k}=R("searchQuery");(0,e.useEffect)(()=>{h("searchQuery",u)},[u,h]);const b=(f,w)=>{const fe=w==="add"?[...l.dataSourceNames].concat([f.name]):l.dataSourceNames.filter(me=>me!==f.name);m({...l,dataSourceNames:fe}),p(me=>me+1)},F=f=>{m({...l,dashboardUid:f})},G=()=>{m({...l,dataSourceNames:[]}),p(f=>f+1)},T=f=>{(0,v.fH)(v.le.clickingAlertStateFilters),m({...l,ruleState:f})},Y=f=>{o({view:f})},z=f=>{m({...l,ruleType:f})},ie=f=>{m({...l,ruleHealth:f})},re=()=>{i(void 0),t(),setTimeout(()=>p(d+1),100)},V=e.createElement(Ee.I,{name:"search"});return e.createElement("div",{className:n.container},e.createElement(M.B,{direction:"column",gap:1},e.createElement(M.B,{direction:"row",gap:1,wrap:"wrap"},e.createElement(Ge.D,{className:n.dsPickerContainer,label:e.createElement(pe.J,{htmlFor:"data-source-picker"},e.createElement(M.B,{gap:.5},e.createElement("span",null,"Search by data sources"),e.createElement(ee.m,{content:e.createElement("div",null,e.createElement("p",null,"Data sources containing configured alert rules are Mimir or Loki data sources where alert rules are stored and evaluated in the data source itself."),e.createElement("p",null,"In these data sources, you can select Manage alerts via Alerting UI to be able to manage these alert rules in the Grafana UI as well as in the data source where they were configured."))},e.createElement(Ee.I,{id:"data-source-picker-inline-help",name:"info-circle",size:"sm"}))))},e.createElement(la,{key:W,alerting:!0,noDefault:!0,placeholder:"All data sources",current:l.dataSourceNames,onChange:b,onClear:G})),e.createElement(Ge.D,{className:n.dashboardPickerContainer,label:e.createElement(pe.J,{htmlFor:"filters-dashboard-picker"},"Dashboard")},e.createElement(Ht.b,{inputId:"filters-dashboard-picker",key:l.dashboardUid?"dashboard-defined":"dashboard-not-defined",value:l.dashboardUid,onChange:f=>F(f?.uid),isClearable:!0,cacheOptions:!0})),e.createElement("div",null,e.createElement(pe.J,null,"State"),e.createElement(Ie.z,{options:ca,value:l.ruleState,onChange:T})),e.createElement("div",null,e.createElement(pe.J,null,"Rule type"),e.createElement(Ie.z,{options:sa,value:l.ruleType,onChange:z})),e.createElement("div",null,e.createElement(pe.J,null,"Health"),e.createElement(Ie.z,{options:oa,value:l.ruleHealth,onChange:ie}))),e.createElement(M.B,{direction:"column",gap:1},e.createElement(M.B,{direction:"row",gap:1},e.createElement("form",{className:n.searchInput,onSubmit:x(f=>{i(f.searchQuery),A.current?.blur()})},e.createElement(Ge.D,{label:e.createElement(pe.J,{htmlFor:"rulesSearchInput"},e.createElement(M.B,{gap:.5},e.createElement("span",null,"Search"),e.createElement(ea.j,{content:e.createElement(ma,null)},e.createElement(Ee.I,{name:"info-circle",size:"sm",tabIndex:0}))))},e.createElement(zt.p,{id:"rulesSearchInput",key:y,prefix:V,ref:f=>{$(f),A.current=f},...k,placeholder:"Search","data-testid":"search-query-input"})),e.createElement("input",{type:"submit",hidden:!0})),e.createElement("div",null,e.createElement(pe.J,null,"View as"),e.createElement(Ie.z,{options:ct,value:String(r.view??ct[0].value),onChange:Y}))),c&&e.createElement("div",null,e.createElement(S.$n,{fullWidth:!1,icon:"times",variant:"secondary",onClick:re},"Clear filters")))))},ua=t=>({container:(0,s.css)({marginBottom:t.spacing(1)}),dsPickerContainer:(0,s.css)({width:t.spacing(60),flexGrow:0,margin:0}),dashboardPickerContainer:(0,s.css)({minWidth:t.spacing(50)}),searchInput:(0,s.css)({flex:1,margin:0})});function ma(){const t=(0,C.of)(it);return e.createElement("div",null,e.createElement("div",null,"Search syntax allows to query alert rules by the parameters defined below."),e.createElement("hr",null),e.createElement("div",{className:t.grid},e.createElement("div",null,"Filter type"),e.createElement("div",null,"Expression"),e.createElement(ce,{title:"Datasources",expr:"datasource:mimir datasource:prometheus"}),e.createElement(ce,{title:"Folder/Namespace",expr:"namespace:global"}),e.createElement(ce,{title:"Group",expr:"group:cpu-usage"}),e.createElement(ce,{title:"Rule",expr:'rule:"cpu 80%"'}),e.createElement(ce,{title:"Labels",expr:"label:team=A label:cluster=a1"}),e.createElement(ce,{title:"State",expr:"state:firing|normal|pending"}),e.createElement(ce,{title:"Type",expr:"type:alerting|recording"}),e.createElement(ce,{title:"Health",expr:"health:ok|nodata|error"}),e.createElement(ce,{title:"Dashboard UID",expr:"dashboard:eadde4c7-54e6-4964-85c0-484ab852fd04"})))}function ce({title:t,expr:n}){const r=(0,C.of)(it);return e.createElement(e.Fragment,null,e.createElement("div",null,t),e.createElement("code",{className:r.code},n))}const it=t=>({grid:(0,s.css)({display:"grid",gridTemplateColumns:"max-content auto",gap:t.spacing(1),alignItems:"center"}),code:(0,s.css)({display:"block",textAlign:"center"})}),da=ia,ut={groups:Ut,state:Kt},ga=se.Ys+1,Ea=(0,N.Xc)(()=>{const t=(0,P.useDispatch)(),n=(0,C.of)(pa),r=(0,e.useMemo)(O.gR,[]),[o,l]=(0,e.useState)(!1),c=(0,e.useCallback)(()=>l(!1),[]),[u]=(0,L.s)(),{filterState:i,hasActiveFilters:m}=lt(),d=ut[u.view]?u.view:"groups",p=ut[d],W=(0,X.$)(V=>V.promRules),y=(0,X.$)(V=>V.rulerRules),A=r.some(V=>W[V]?.loading||y[V]?.loading),x=Object.entries(W),R=Object.entries(y),h=x.every(([V,f])=>f.dispatched&&(f?.result!==void 0||f?.error!==void 0)),$=R.every(([V,f])=>f.dispatched&&(f?.result!==void 0||f?.error!==void 0)),k=x.every(([V,f])=>f.dispatched&&f?.result?.length===0),b=R.every(([V,f])=>Object.entries(f?.result??{}).every(([me,q])=>q?.length===0)&&f.dispatched),F=m?void 0:ga,[G,T]=(0,E.A)(async()=>{A||await t((0,Me.yo)(!1,{limitAlerts:F}))},[A,F,t]);(0,e.useEffect)(()=>{(0,v.Sq)().catch(()=>{})},[]),(0,e.useEffect)(()=>{t((0,Me.yo)(!1,{limitAlerts:F}))},[t,F]),(0,I.A)(T,rt.HH);const Y=h&&k&&x.length>0&&b&&$,z=!Y,ie=(0,xe.dy)(),re=Qt(ie,i);return e.createElement(U.d,{navId:"alert-list",isLoading:!1,actions:z&&e.createElement(mt,null)},e.createElement(he,null),e.createElement(da,{onFilterCleared:c}),z&&e.createElement(e.Fragment,null,e.createElement("div",{className:n.break}),e.createElement("div",{className:n.buttonsContainer},e.createElement("div",{className:n.statsContainer},d==="groups"&&m&&e.createElement(S.$n,{className:n.expandAllButton,icon:o?"angle-double-up":"angle-double-down",variant:"secondary",onClick:()=>l(!o)},o?"Collapse all":"Expand all"),e.createElement(et.M_,{namespaces:re})))),Y&&e.createElement(le,null),z&&e.createElement(p,{expandAll:o,namespaces:re}))},{style:"page"}),pa=t=>({break:(0,s.css)`
    width: 100%;
    height: 0;
    margin-bottom: ${t.spacing(2)};
    border-bottom: solid 1px ${t.colors.border.medium};
  `,buttonsContainer:(0,s.css)`
    margin-bottom: ${t.spacing(2)};
    display: flex;
    justify-content: space-between;
  `,statsContainer:(0,s.css)`
    display: flex;
    flex-direction: row;
    align-items: center;
  `,expandAllButton:(0,s.css)`
    margin-right: ${t.spacing(1)};
  `}),fa=Ea;function mt(){const[t,n]=(0,te.Ej)(te.RY.CreateAlertRule),[r,o]=(0,te.Ej)(te.RY.CreateExternalAlertRule),l=(0,g.zy)();return t&&n||r&&o?e.createElement(S.z9,{href:D.kM.renderUrl("alerting/new/alerting",{returnTo:l.pathname+l.search}),icon:"plus",onClick:()=>(0,v.fH)(v.le.alertRuleFromScratch)},"New alert rule"):null}},64853:(ae,B,a)=>{a.d(B,{_:()=>I});var s=a(2543),e=a.n(s),g=a(96540),E=a(19073);const I=({actions:P,children:v})=>{const U=(0,s.filter)(P,S),M=(0,s.filter)(P,L);return U.length?g.createElement(D,{actions:U},v):M.length?g.createElement(N,{actions:M},v):null},D=({actions:P,children:v})=>{const U=(0,E.iI)();return C(U,P)?g.createElement(g.Fragment,null,v):null},N=({actions:P,children:v})=>{const U=(0,E.e2)();return C(U,P)?g.createElement(g.Fragment,null,v):null};function C(P,v){return(0,s.chain)(P).pick(v).values().value().some(([U,M])=>M===!0)}function S(P){return Object.values(E.QI).includes(P)}function L(P){return Object.values(E.RY).includes(P)}},16293:(ae,B,a)=>{a.d(B,{J:()=>U});var s=a(32196),e=a(4213),g=a.n(e),E=a(96540),I=a(70713),D=a(40845),N=a(32372),C=a(55852),S=a(10534),L=a(72109),P=a(42418),v=a(84029);function U({format:J,textDefinition:Q,downloadFileName:le,onClose:de}){const se=(0,D.of)(M),ne=v.sl[J],ge=(0,E.useCallback)(()=>{const K=new Blob([Q],{type:`application/${J};charset=utf-8`});g()(K,`${le}.${J}`)},[Q,le,J]),Re=(0,E.useMemo)(()=>ne.formatter?ne.formatter(Q):Q,[ne,Q]);return E.createElement("div",{className:se.container},E.createElement(ve,{exportProvider:ne}),E.createElement("div",{className:se.content},E.createElement(I.Ay,{disableWidth:!0},({height:K})=>E.createElement(N.B,{width:"100%",height:K,language:J,value:Re,monacoOptions:{minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:!0}}))),E.createElement("div",{className:se.actions},E.createElement(C.$n,{variant:"secondary",onClick:de},"Cancel"),E.createElement(S.b,{icon:"copy",getText:()=>Q},"Copy code"),E.createElement(C.$n,{icon:"download-alt",onClick:ge},"Download")))}const M=J=>({container:(0,s.css)`
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: ${J.spacing(2)};
  `,content:(0,s.css)`
    flex: 1 1 100%;
  `,actions:(0,s.css)`
    flex: 0;
    justify-content: flex-end;
    display: flex;
    gap: ${J.spacing(1)};
  `});function ve({exportProvider:J}){const{name:Q,type:le}=J,de={file:{title:"File-provisioning format",component:E.createElement(E.Fragment,null,Q," format is only valid for File Provisioning."," ",E.createElement(L.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/",external:!0},"Read more in the docs."))},api:{title:"API-provisioning format",component:E.createElement(E.Fragment,null,Q," format is only valid for API Provisioning."," ",E.createElement(L.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/http-api-provisioning/",external:!0},"Read more in the docs."))},terraform:{title:"Terraform-provisioning format",component:E.createElement(E.Fragment,null,Q," format is only valid for Terraform Provisioning."," ",E.createElement(L.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/terraform-provisioning/",external:!0},"Read more in the docs."))}},{title:se,component:ne}=de[le];return E.createElement(P.F,{title:se,severity:"info",bottomSpacing:0,topSpacing:0},ne)}},76648:(ae,B,a)=>{a.d(B,{m:()=>E});var s=a(96540),e=a(87978),g=a(73716);function E({activeTab:I,onTabChange:D,children:N,onClose:C,formatProviders:S,title:L="Export"}){const P=Object.values(S).map(v=>({label:v.name,value:v.exportFormat}));return s.createElement(e._,{title:L,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:s.createElement(g.sb,{tabs:P,setActiveTab:D,activeTab:I}),onClose:C,size:"md"},N)}},84029:(ae,B,a)=>{a.d(B,{sl:()=>E});const s={name:"JSON",exportFormat:"json",type:"file",formatter:D=>{try{return JSON.stringify(JSON.parse(D),null,4)}catch{return D}}},e={name:"YAML",exportFormat:"yaml",type:"file"},g={name:"Terraform (HCL)",exportFormat:"hcl",type:"terraform"},E={[s.exportFormat]:s,[e.exportFormat]:e,[g.exportFormat]:g},I=[s,e]},64100:(ae,B,a)=>{a.d(B,{G:()=>C});var s=a(32196),e=a(96540),g=a(40845),E=a(60782),I=a(67061),D=a(14578),N=a(94753);function C({contentText:L,externalLink:P,linkText:v,title:U}){const M=(0,g.of)(S);return e.createElement(E.G,{content:e.createElement("div",{className:M.mutedText},L),title:e.createElement(I.B,{gap:1,direction:"row"},e.createElement(D.I,{name:"question-circle"}),U),footer:P?e.createElement("a",{href:P,target:"_blank",rel:"noreferrer"},e.createElement(I.B,{direction:"row",gap:.5,alignItems:"center"},e.createElement(N.E,{color:"link"},v," ",e.createElement(D.I,{size:"sm",name:"external-link-alt"})))):void 0,closeButton:!0,placement:"bottom-start"},e.createElement("div",{className:M.helpInfo},e.createElement(I.B,{direction:"row",alignItems:"center",gap:.5},e.createElement(D.I,{name:"question-circle",size:"sm"}),e.createElement(N.E,{variant:"bodySmall",color:"primary"},"Need help?"))))}const S=L=>({mutedText:(0,s.css)`
    color: ${L.colors.text.secondary};
    font-size: ${L.typography.size.sm};
  `,helpInfo:(0,s.css)`
    cursor: pointer;
    text-decoration: underline;
  `})},271:(ae,B,a)=>{a.d(B,{P:()=>N});var s=a(32196),e=a(96540),g=a(40845),E=a(84167),I=a(94753),D=a(67061);const N=({title:S,stepNo:L,children:P,fullWidth:v=!1,description:U})=>{const M=(0,g.of)(C);return e.createElement("div",{className:M.parent},e.createElement(E.n,{className:(0,s.cx)(v&&M.fullWidth),label:e.createElement(I.E,{variant:"h3"},L,". ",S)},e.createElement(D.B,{direction:"column"},U&&e.createElement("div",{className:M.description},U),P)))},C=S=>({parent:(0,s.css)`
    display: flex;
    flex-direction: row;
    max-width: ${S.breakpoints.values.xl}px;
    border: solid 1px ${S.colors.border.weak};
    border-radius: ${S.shape.radius.default};
    padding: ${S.spacing(2)} ${S.spacing(3)};
  `,description:(0,s.css)`
    margin-top: -${S.spacing(2)};
  `,fullWidth:(0,s.css)`
    width: 100%;
  `})},73716:(ae,B,a)=>{a.d(B,{G_:()=>Q,sb:()=>le});var s=a(32196),e=a(20382),g=a(96540),E=a(49785),I=a(70713),D=a(40845),N=a(87978),C=a(63021),S=a(40675),L=a(55852),P=a(56034),v=a(14578),U=a(32372),M=a(63066),ve=a(23662);const J=[{label:"Yaml",value:"yaml"}],Q=({onClose:K})=>{const[ee,X]=(0,g.useState)("yaml"),{setValue:O}=(0,E.xW)(),Z=(0,D.of)(Re),H=he=>{for(const ue in he)O(ue,he[ue]);K()};return g.createElement(N._,{title:"Inspect Alert rule",subtitle:g.createElement("div",{className:Z.subtitle},g.createElement(le,{tabs:J,setActiveTab:X,activeTab:ee})),onClose:K},ee==="yaml"&&g.createElement(de,{onSubmit:H}))};function le({tabs:K,activeTab:ee,setActiveTab:X}){return g.createElement(C.U,null,K.map((O,Z)=>g.createElement(S.o,{key:`${O.value}-${Z}`,label:O.label,value:O.value,onChangeTab:()=>X(O.value),active:ee===O.value})))}const de=({onSubmit:K})=>{const ee=(0,D.of)(ge),{getValues:X}=(0,E.xW)(),O=(0,M.l1)(X()),[Z,H]=(0,g.useState)((0,e.Bh)(O)),he=()=>{const ue=(0,e.Hh)(Z),Se=X(),te=ne(ue);K({...Se,...te})};return g.createElement(g.Fragment,null,g.createElement("div",{className:ee.applyButton},g.createElement(L.$n,{type:"button",onClick:he},"Apply"),g.createElement(P.m,{content:g.createElement(se,null),theme:"info",placement:"left-start",interactive:!0},g.createElement(v.I,{name:"exclamation-triangle",size:"xl"}))),g.createElement("div",{className:ee.content},g.createElement(I.Ay,{disableWidth:!0},({height:ue})=>g.createElement(U.B,{width:"100%",height:ue,language:"yaml",value:Z,onBlur:H,monacoOptions:{minimap:{enabled:!1}}}))))};function se(){return g.createElement("div",null,"The YAML content in the editor only contains alert rule configuration ",g.createElement("br",null),"To configure Prometheus, you need to provide the rest of the"," ",g.createElement("a",{href:"https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/",target:"_blank",rel:"noreferrer"},"configuration file content."))}function ne(K){return(0,ve.$y)(K)?(0,M.Qk)(K):(0,ve.i7)(K)?(0,M.XI)(K):{}}const ge=K=>({content:(0,s.css)`
    flex-grow: 1;
    height: 100%;
    padding-bottom: 16px;
    margin-bottom: ${K.spacing(2)};
  `,applyButton:(0,s.css)`
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-grow: 0;
    margin-bottom: ${K.spacing(2)};
  `}),Re=()=>({subtitle:(0,s.css)`
    display: flex;
    align-items: center;
    justify-content: space-between;
  `})},72275:(ae,B,a)=>{a.d(B,{M:()=>E});var s=a(96540),e=a(56034),g=a(55852);const E=({tooltip:I,icon:D,to:N,target:C,onClick:S,className:L,tooltipPlacement:P="top",...v})=>{const U=typeof I=="string"?I:void 0;return s.createElement(e.m,{content:I,placement:P},N?s.createElement(g.z9,{variant:"secondary",fill:"text",icon:D,href:N,size:"sm",target:C,...v,"aria-label":U}):s.createElement(g.$n,{className:L,variant:"secondary",fill:"text",size:"sm",icon:D,type:"button",onClick:S,...v,"aria-label":U}))}},10940:(ae,B,a)=>{a.d(B,{A:()=>g});var s=a(96540),e=function(E,I){var D=(0,s.useRef)(function(){});(0,s.useEffect)(function(){D.current=E}),(0,s.useEffect)(function(){if(I!==null){var N=setInterval(function(){return D.current()},I||0);return function(){return clearInterval(N)}}},[I])};const g=e}}]);

//# sourceMappingURL=AlertRuleListIndex.f0b17a6119cc5ea575ed.js.map