"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8648],{75429:(J,P,t)=>{t.d(P,{x:()=>v});var r=t(27702),o=t(18771),e=t(92071);function v(u){const g=(0,o.useDispatch)(),p=(0,r.useRef)(u);p.current=u,(0,r.useEffect)(()=>()=>{g((0,e.e)({cleanupAction:p.current}))},[g])}},18555:(J,P,t)=>{t.d(P,{Z:()=>e});var r=t(27702);const e=({shouldWrap:v,children:u,wrap:g})=>v?r.cloneElement(g(u)):u},69798:(J,P,t)=>{t.r(P),t.d(P,{default:()=>yn,findRoutesMatchingFilters:()=>bt});var r=t(42844),o=t(89949),e=t(27702),v=t(26811),u=t(23852),g=t(66310),p=t(15372),B=t(54281),C=t(4432),x=t(52419),R=t(63439),w=t(37647),V=t(89033),D=t(18771),$=t(75429),z=t(52646),Y=t(98164),ie=t(81324),ve=t(80118),N=t(66670),fe=t(3613),ce=t(9848),le=t(67437),ye=t(91368),f=t(29891),j=t(89439),L=t(97529),ne=t(47702),_=t(2082),S=t(39036),se=t(45986);const Ke=({children:n})=>{const a=(0,g.wW)(Pt);return e.createElement("div",{className:a.container},n)},Pt=n=>({container:(0,r.css)`
      background-color: ${n.colors.background.secondary};
      color: ${n.colors.text.secondary};
      padding: ${n.spacing(4)};
      text-align: center;
    `}),ot=({buttonIcon:n,buttonLabel:a,buttonSize:l="lg",buttonVariant:i="primary",onButtonClick:d,text:c,href:s,showButton:E=!0})=>{const m=(0,g.wW)(Ot),h={className:m.button,icon:n,size:l,variant:i};return e.createElement(Ke,null,e.createElement(e.Fragment,null,e.createElement("p",{className:m.text},c),E&&(s?e.createElement(N.Qj,{href:s,type:"button",...h},a):e.createElement(N.zx,{onClick:d,type:"button",...h},a))))},Ot=n=>({container:(0,r.css)`
      background-color: ${n.colors.background.secondary};
      color: ${n.colors.text.secondary};
      padding: ${n.spacing(4)};
      text-align: center;
    `,text:(0,r.css)`
      margin-bottom: ${n.spacing(2)};
    `,button:(0,r.css)`
      margin: ${n.spacing(2,0,1)};
    `});var lt=t(18629),st=t(67045),Tt=t(86342);const Dt=({alertManagerSourceName:n,muteTimingNames:a,hideActions:l})=>{const i=(0,g.wW)(xt),d=(0,f.I0)(),c=(0,_.Ko)(n),{currentData:s}=(0,L.W)(n,{refetchOnFocus:!0,refetchOnReconnect:!0}),E=s?.alertmanager_config,[m,h]=(0,e.useState)(""),M=(0,e.useMemo)(()=>{const Q=E?.mute_time_intervals??[],F=E?.muteTimeProvenances??{};return Q.filter(({name:G})=>a?a.includes(G):!0).map(G=>({id:G.name,data:{...G,provenance:F[G.name]}}))},[E?.mute_time_intervals,E?.muteTimeProvenances,a]),b=It(n,l,h);return e.createElement("div",{className:i.container},e.createElement(u.K,{direction:"row",alignItems:"center"},e.createElement("span",null,"Enter specific time intervals when not to send notifications or freeze notifications for recurring periods of time."),e.createElement(st.L,null),!l&&M.length>0&&e.createElement(j.q,{actions:[c.create]},e.createElement(N.Qj,{className:i.addMuteButton,icon:"plus",variant:"primary",href:(0,S.eQ)("alerting/routes/mute-timing/new",n)},"Add mute timing"))),M.length>0?e.createElement(se.t,{items:M,cols:b}):l?e.createElement(ot,{text:"No mute timings configured",buttonLabel:"",showButton:!1}):e.createElement(ot,{text:"You haven't created any mute timings yet",buttonLabel:"Add mute timing",buttonIcon:"plus",buttonSize:"lg",href:(0,S.eQ)("alerting/routes/mute-timing/new",n),showButton:ye.contextSrv.hasPermission(c.create)}),!l&&e.createElement(fe.s,{isOpen:!!m,title:"Delete mute timing",body:`Are you sure you would like to delete "${m}"`,confirmText:"Delete",onConfirm:()=>{d((0,ne.r0)(n,m)),h("")},onDismiss:()=>h("")}))};function It(n,a=!1,l){const i=(0,_.Ko)(n),d=ye.contextSrv.hasPermission(i.update),c=ye.contextSrv.hasPermission(i.delete),s=!a&&(d||c);return(0,e.useMemo)(()=>{const E=[{id:"name",label:"Name",renderCell:function({data:h}){return e.createElement(e.Fragment,null,h.name," ",h.provenance&&e.createElement(lt.C0,null))},size:"250px"},{id:"timeRange",label:"Time range",renderCell:({data:m})=>(0,Tt.Nx)(m)}];return s&&E.push({id:"actions",label:"Actions",renderCell:function({data:h}){return h.provenance?e.createElement("div",null,e.createElement(ce.r,{href:(0,S.eQ)("/alerting/routes/mute-timing/edit",n,{muteName:h.name})},e.createElement(le.h,{name:"file-alt",tooltip:"View mute timing"}))):e.createElement("div",null,e.createElement(j.q,{actions:[i.update]},e.createElement(ce.r,{href:(0,S.eQ)("/alerting/routes/mute-timing/edit",n,{muteName:h.name})},e.createElement(le.h,{name:"edit",tooltip:"Edit mute timing"}))),e.createElement(j.q,{actions:[i.delete]},e.createElement(le.h,{name:"trash-alt",tooltip:"Delete mute timing",onClick:()=>l(h.name)})))},size:"100px"}),E},[n,l,s,i])}const xt=n=>({container:(0,r.css)`
    display: flex;
    flex-flow: column nowrap;
  `,addMuteButton:(0,r.css)`
    margin-bottom: ${n.spacing(2)};
    align-self: flex-end;
  `});var xe=t(9908),ee=t(13741),Se=t(73453),St=t(62108),Re=t(62862),Rt=t(9853),it=t(74023),Wt=t(6772),We=t.n(Wt),he=t(25357);const Gt=({active:n=0,suppressed:a=0,unprocessed:l=0})=>{const i=[],d=n+a+l;return n&&i.push(e.createElement(he.C,{color:"red",key:"firing",text:`${n} firing`})),a&&i.push(e.createElement(he.C,{color:"blue",key:"suppressed",text:`${a} suppressed`})),l&&i.push(e.createElement(he.C,{color:"orange",key:"unprocessed",text:`${l} unprocessed`})),i.length>1&&i.unshift(e.createElement(e.Fragment,{key:"total"},d," ",We()("instance",d))),!!i.length?e.createElement(u.K,{gap:.5},i):null};var ct=t(23839),K=t(22209),ge=t(16310),pe=t(28580),Bt=t(41640),W=t(26630),Ve=t(1128),Ge=t(51453),be=t(42439);function $t(){const n=(0,g.wW)(mt);return e.createElement("div",null,"Prometheus duration format consist of a number followed by a time unit.",e.createElement("br",null),"Different units can be combined for more granularity.",e.createElement("hr",null),e.createElement("div",{className:n.list},e.createElement("div",{className:n.header},e.createElement("div",null,"Symbol"),e.createElement("div",null,"Time unit"),e.createElement("div",null,"Example")),e.createElement(Ae,{unit:be.t.seconds,name:"seconds",example:"20s"}),e.createElement(Ae,{unit:be.t.minutes,name:"minutes",example:"10m"}),e.createElement(Ae,{unit:be.t.hours,name:"hours",example:"4h"}),e.createElement(Ae,{unit:be.t.days,name:"days",example:"3d"}),e.createElement(Ae,{unit:be.t.weeks,name:"weeks",example:"2w"}),e.createElement("div",{className:n.examples},e.createElement("div",null,"Multiple units combined"),e.createElement("code",null,"1m30s, 2h30m20s, 1w2d"))))}function Ae({unit:n,name:a,example:l}){const i=(0,g.wW)(mt);return e.createElement(e.Fragment,null,e.createElement("div",{className:i.unit},n),e.createElement("div",null,a),e.createElement("code",null,l))}const mt=n=>({unit:(0,r.css)`
    font-weight: ${n.typography.fontWeightBold};
  `,list:(0,r.css)`
    display: grid;
    grid-template-columns: max-content 1fr 2fr;
    gap: ${n.spacing(1,3)};
  `,header:(0,r.css)`
    display: contents;
    font-weight: ${n.typography.fontWeightBold};
  `,examples:(0,r.css)`
    display: contents;
    & > div {
      grid-column: 1 / span 2;
    }
  `}),me=e.forwardRef((n,a)=>e.createElement(Ve.I,{suffix:e.createElement(Ge.z,{content:e.createElement($t,null),disabled:!1},e.createElement(Se.J,{name:"info-circle",size:"lg"})),...n,ref:a}));me.displayName="PromDurationInput";const ut=n=>({container:(0,r.css)`
      align-items: center;
      display: flex;
      flex-flow: row nowrap;

      & > * + * {
        margin-left: ${n.spacing(1)};
      }
    `,input:(0,r.css)`
      flex: 1;
    `,promDurationInput:(0,r.css)`
      max-width: ${n.spacing(32)};
    `,timingFormContainer:(0,r.css)`
      padding: ${n.spacing(1)};
    `,linkText:(0,r.css)`
      text-decoration: underline;
    `,collapse:(0,r.css)`
      border: none;
      background: none;
      color: ${n.colors.text.primary};
    `}),Ce={group_wait:"30s",group_interval:"5m",repeat_interval:"4h"},Nt=({actionButtons:n,alertManagerSourceName:a,onSubmit:l,receivers:i,route:d})=>{const c=(0,g.wW)(ut),[s,E]=(0,e.useState)(!1),[m,h]=(0,e.useState)((0,W.eh)(d.group_by)),M=(0,W.ZS)(d);return e.createElement(ct.l,{defaultValues:{...M,overrideTimings:!0,overrideGrouping:!0},onSubmit:l},({register:b,control:Q,errors:F,setValue:G,getValues:y})=>e.createElement(e.Fragment,null,e.createElement(K.g,{label:"Default contact point",invalid:!!F.receiver,error:F.receiver?.message},e.createElement(e.Fragment,null,e.createElement("div",{className:c.container,"data-testid":"am-receiver-select"},e.createElement(ge.g,{render:({field:{onChange:O,ref:U,...X}})=>e.createElement(pe.Ph,{"aria-label":"Default contact point",...X,className:c.input,onChange:H=>O((0,W.mJ)(H)),options:i}),control:Q,name:"receiver",rules:{required:{value:!0,message:"Required."}}}),e.createElement("span",null,"or"),e.createElement(ce.r,{className:c.linkText,href:(0,S.eQ)("/alerting/notifications/receivers/new",a)},"Create a contact point")))),e.createElement(K.g,{label:"Group by",description:"Group alerts when you receive a notification based on labels.","data-testid":"am-group-select"},e.createElement(ge.g,{render:({field:{onChange:O,ref:U,...X}})=>e.createElement(pe.NU,{"aria-label":"Group by",...X,allowCustomValue:!0,className:c.input,onCreateOption:H=>{h(I=>[...I,(0,W.T0)(H)]),G("groupBy",[...X.value,H])},onChange:H=>O((0,W.bi)(H)),options:[...W.dO,...m]}),control:Q,name:"groupBy"})),e.createElement(Bt.U,{collapsible:!0,className:c.collapse,isOpen:s,label:"Timing options",onToggle:E},e.createElement("div",{className:c.timingFormContainer},e.createElement(K.g,{label:"Group wait",description:"The waiting time until the initial notification is sent for a new group created by an incoming alert. Default 30 seconds.",invalid:!!F.groupWaitValue,error:F.groupWaitValue?.message,"data-testid":"am-group-wait"},e.createElement(me,{...b("groupWaitValue",{validate:W.Oy}),placeholder:Ce.group_wait,className:c.promDurationInput,"aria-label":"Group wait"})),e.createElement(K.g,{label:"Group interval",description:"The waiting time to send a batch of new alerts for that group after the first notification was sent. Default 5 minutes.",invalid:!!F.groupIntervalValue,error:F.groupIntervalValue?.message,"data-testid":"am-group-interval"},e.createElement(me,{...b("groupIntervalValue",{validate:W.Oy}),placeholder:Ce.group_interval,className:c.promDurationInput,"aria-label":"Group interval"})),e.createElement(K.g,{label:"Repeat interval",description:"The waiting time to resend an alert after they have successfully been sent. Default 4 hours.",invalid:!!F.repeatIntervalValue,error:F.repeatIntervalValue?.message,"data-testid":"am-repeat-interval"},e.createElement(me,{...b("repeatIntervalValue",{validate:O=>{const U=y("groupIntervalValue");return(0,W.eP)(O,U)}}),placeholder:Ce.repeat_interval,className:c.promDurationInput,"aria-label":"Repeat interval"})))),e.createElement("div",{className:c.container},n)))};var Ft=t(56948),ze=t(42074),Ut=t(59904),dt=t(1469),gt=t(76658);function wt(){const{selectedAlertmanager:n}=(0,dt.Z)(),{currentData:a}=(0,L.W)(n),l=a?.alertmanager_config;return(0,e.useMemo)(()=>l?.mute_time_intervals?.map(d=>({value:d.name,label:d.name,description:d.time_intervals.map(c=>(0,gt.uK)(c)).join(", AND ")}))??[],[l])}var Lt=t(62401);const pt=({actionButtons:n,receivers:a,route:l,onSubmit:i,defaults:d})=>{const c=(0,g.wW)(Vt),s=(0,g.wW)(ut),[E,m]=(0,e.useState)((0,W.eh)(l?.group_by)),h=wt(),M=[{name:"",operator:Re._M.equal,value:""}],b=a.sort(Kt),Q={...(0,W.ZS)(l),...d},F={...Q,object_matchers:l?Q.object_matchers:M};return e.createElement(ct.l,{defaultValues:F,onSubmit:i,maxWidth:"none"},({control:G,register:y,errors:O,setValue:U,watch:X,getValues:H})=>e.createElement(e.Fragment,null,e.createElement("input",{type:"hidden",...y("id")}),e.createElement(Ft.F,{name:"object_matchers",control:G},({fields:I,append:Z,remove:k})=>e.createElement(e.Fragment,null,e.createElement(u.K,{direction:"column",alignItems:"flex-start"},e.createElement("div",null,"Matching labels"),I.length===0&&e.createElement(he.C,{color:"orange",className:c.noMatchersWarning,icon:"exclamation-triangle",text:"If no matchers are specified, this notification policy will handle all alert instances."}),I.length>0&&e.createElement("div",{className:c.matchersContainer},I.map((T,A)=>e.createElement(u.K,{direction:"row",key:T.id,alignItems:"center"},e.createElement(K.g,{label:"Label",invalid:!!O.object_matchers?.[A]?.name,error:O.object_matchers?.[A]?.name?.message},e.createElement(Ve.I,{...y(`object_matchers.${A}.name`,{required:"Field is required"}),defaultValue:T.name,placeholder:"label",autoFocus:!0})),e.createElement(K.g,{label:"Operator"},e.createElement(ge.g,{render:({field:{onChange:re,ref:ue,...de}})=>e.createElement(pe.Ph,{...de,className:c.matchersOperator,onChange:Oe=>re(Oe?.value),options:gt.tA,"aria-label":"Operator"}),defaultValue:T.operator,control:G,name:`object_matchers.${A}.operator`,rules:{required:{value:!0,message:"Required."}}})),e.createElement(K.g,{label:"Value",invalid:!!O.object_matchers?.[A]?.value,error:O.object_matchers?.[A]?.value?.message},e.createElement(Ve.I,{...y(`object_matchers.${A}.value`,{required:"Field is required"}),defaultValue:T.value,placeholder:"value"})),e.createElement(le.h,{tooltip:"Remove matcher",name:"trash-alt",onClick:()=>k(A)},"Remove")))),e.createElement(N.zx,{className:c.addMatcherBtn,icon:"plus",onClick:()=>Z(W.fx),variant:"secondary",type:"button"},"Add matcher")))),e.createElement(K.g,{label:"Contact point"},e.createElement(ge.g,{render:({field:{onChange:I,ref:Z,...k}})=>e.createElement(pe.Ph,{"aria-label":"Contact point",...k,className:s.input,onChange:T=>I((0,W.mJ)(T)),options:b,isClearable:!0}),control:G,name:"receiver"})),e.createElement(K.g,{label:"Continue matching subsequent sibling nodes"},e.createElement(ze.r,{id:"continue-toggle",...y("continue")})),e.createElement(K.g,{label:"Override grouping"},e.createElement(ze.r,{id:"override-grouping-toggle",...y("overrideGrouping")})),X().overrideGrouping&&e.createElement(K.g,{label:"Group by",description:"Group alerts when you receive a notification based on labels. If empty it will be inherited from the parent policy."},e.createElement(ge.g,{rules:{validate:I=>!I||I.length===0?"At least one group by option is required.":!0},render:({field:{onChange:I,ref:Z,...k},fieldState:{error:T}})=>e.createElement(e.Fragment,null,e.createElement(pe.NU,{"aria-label":"Group by",...k,invalid:!!T,allowCustomValue:!0,className:s.input,onCreateOption:A=>{m(re=>[...re,(0,W.T0)(A)]),U("groupBy",[...k.value,A])},onChange:A=>I((0,W.bi)(A)),options:[...W.dO,...E]}),T&&e.createElement(Ut.S,null,T.message)),control:G,name:"groupBy"})),e.createElement(K.g,{label:"Override general timings"},e.createElement(ze.r,{id:"override-timings-toggle",...y("overrideTimings")})),X().overrideTimings&&e.createElement(e.Fragment,null,e.createElement(K.g,{label:"Group wait",description:"The waiting time until the initial notification is sent for a new group created by an incoming alert. If empty it will be inherited from the parent policy.",invalid:!!O.groupWaitValue,error:O.groupWaitValue?.message},e.createElement(me,{...y("groupWaitValue",{validate:W.Oy}),"aria-label":"Group wait value",className:s.promDurationInput})),e.createElement(K.g,{label:"Group interval",description:"The waiting time to send a batch of new alerts for that group after the first notification was sent. If empty it will be inherited from the parent policy.",invalid:!!O.groupIntervalValue,error:O.groupIntervalValue?.message},e.createElement(me,{...y("groupIntervalValue",{validate:W.Oy}),"aria-label":"Group interval value",className:s.promDurationInput})),e.createElement(K.g,{label:"Repeat interval",description:"The waiting time to resend an alert after they have successfully been sent.",invalid:!!O.repeatIntervalValue,error:O.repeatIntervalValue?.message},e.createElement(me,{...y("repeatIntervalValue",{validate:I=>{const Z=H("groupIntervalValue");return(0,W.eP)(I,Z)}}),"aria-label":"Repeat interval value",className:s.promDurationInput}))),e.createElement(K.g,{label:"Mute timings","data-testid":"am-mute-timing-select",description:"Add mute timing to policy",invalid:!!O.muteTimeIntervals},e.createElement(ge.g,{render:({field:{onChange:I,ref:Z,...k}})=>e.createElement(pe.NU,{"aria-label":"Mute timings",...k,className:s.input,onChange:T=>I((0,W.bi)(T)),options:h}),control:G,name:"muteTimeIntervals"})),n))};function Kt(n){return n.grafanaAppReceiverType===Lt.W.OnCall?-1:0}const Vt=n=>{const a=n.spacing(3.5);return{addMatcherBtn:(0,r.css)`
      margin-bottom: ${a};
    `,matchersContainer:(0,r.css)`
      background-color: ${n.colors.background.secondary};
      padding: ${n.spacing(1.5)} ${n.spacing(2)};
      padding-bottom: 0;
      width: fit-content;
    `,matchersOperator:(0,r.css)`
      min-width: 120px;
    `,noMatchersWarning:(0,r.css)`
      padding: ${n.spacing(1)} ${n.spacing(2)};
    `}};var Et=t(54915);const zt=(n=[],a,l)=>{const[i,d]=(0,e.useState)(!1),[c,s]=(0,e.useState)(),E=(0,it.Kt)(n),m=(0,e.useCallback)(()=>{s(void 0),d(!1)},[]),h=(0,e.useCallback)(b=>{s(b),d(!0)},[]);return[(0,e.useMemo)(()=>l?e.createElement(je,{isOpen:i}):e.createElement(ee.u,{isOpen:i,onDismiss:m,closeOnBackdropClick:!0,closeOnEscape:!0,title:"Add notification policy"},e.createElement(pt,{receivers:E,defaults:{groupBy:c?.group_by},onSubmit:b=>c&&a(b,c),actionButtons:e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:m,fill:"outline"},"Cancel"),e.createElement(N.zx,{type:"submit"},"Save policy"))})),[E,a,m,l,c,i]),h,m]},jt=(n,a,l,i)=>{const[d,c]=(0,e.useState)(!1),[s,E]=(0,e.useState)(!1),[m,h]=(0,e.useState)(),M=(0,it.Kt)(a),b=(0,e.useCallback)(()=>{h(void 0),c(!1)},[]),Q=(0,e.useCallback)((G,y)=>{E(y??!1),h(G),c(!0)},[]);return[(0,e.useMemo)(()=>i?e.createElement(je,{isOpen:d}):e.createElement(ee.u,{isOpen:d,onDismiss:b,closeOnBackdropClick:!0,closeOnEscape:!0,title:"Edit notification policy"},s&&m&&e.createElement(Nt,{alertManagerSourceName:n,onSubmit:l,receivers:M,route:m,actionButtons:e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:b,fill:"outline"},"Cancel"),e.createElement(N.zx,{type:"submit"},"Update default policy"))}),!s&&e.createElement(pt,{receivers:M,route:m,onSubmit:l,actionButtons:e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:b,fill:"outline"},"Cancel"),e.createElement(N.zx,{type:"submit"},"Update policy"))})),[M,n,b,l,s,i,m,d]),Q,b]},Qt=(n,a)=>{const[l,i]=(0,e.useState)(!1),[d,c]=(0,e.useState)(),s=(0,e.useCallback)(()=>{c(void 0),i(!1)},[c]),E=(0,e.useCallback)(M=>{c(M),i(!0)},[]),m=(0,e.useCallback)(()=>{d&&n(d)},[n,d]);return[(0,e.useMemo)(()=>a?e.createElement(je,{isOpen:l}):e.createElement(ee.u,{isOpen:l,onDismiss:s,closeOnBackdropClick:!0,closeOnEscape:!0,title:"Delete notification policy"},e.createElement("p",null,"Deleting this notification policy will permanently remove it."),e.createElement("p",null,"Are you sure you want to delete this policy?"),e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"destructive",onClick:m},"Yes, delete policy"),e.createElement(N.zx,{type:"button",variant:"secondary",onClick:s},"Cancel"))),[s,m,a,l]),E,s]},Zt=()=>{const[n,a]=(0,e.useState)(!1),[l,i]=(0,e.useState)([]),[d,c]=(0,e.useState)([]),s=(0,e.useCallback)(()=>{a(!1),i([]),c([])},[]),E=(0,e.useCallback)((M,b)=>{i(M),b&&c(b),a(!0)},[]),m=(0,e.useMemo)(()=>{const M=l.flatMap(b=>b.alerts);return(0,o.groupBy)(M,b=>b.status.state)},[l]);return[(0,e.useMemo)(()=>e.createElement(ee.u,{isOpen:n,onDismiss:s,closeOnBackdropClick:!0,closeOnEscape:!0,title:e.createElement(u.K,{direction:"row",alignItems:"center",gap:1,flexGrow:1},e.createElement(u.K,{direction:"row",alignItems:"center",gap:.5},e.createElement(Se.J,{name:"x"})," Matchers"),e.createElement(Et.g,{matchers:d}))},e.createElement(u.K,{direction:"column"},e.createElement(Gt,{active:m[Re.Z9.Active]?.length,suppressed:m[Re.Z9.Suppressed]?.length,unprocessed:m[Re.Z9.Unprocessed]?.length}),e.createElement("div",null,l.map((M,b)=>e.createElement(Rt.y,{key:b,alertManagerSourceName:"",group:M})))),e.createElement(ee.u.ButtonRow,null,e.createElement(N.zx,{type:"button",variant:"secondary",onClick:s},"Cancel"))),[l,s,m,d,n]),E,s]},je=({isOpen:n})=>e.createElement(ee.u,{isOpen:n,onDismiss:()=>{},closeOnBackdropClick:!1,closeOnEscape:!1,title:e.createElement(u.K,{direction:"row",alignItems:"center",gap:.5},"Updating... ",e.createElement(St.$,{inline:!0}))},"Please wait while we update your notification policies.");var Be=t(85014),Ht=t(80434),Me=t(89746),Pe=t(80011),Jt=t(64714),vt=t(21323),Qe=t(66574),Ze=t(18555),Yt=t(309),Xt=t(14917),ft=t(22513),yt=t(32925),kt=t(95984),qt=t(59597),He=t(79374),ae=t(218),q=t(92273);const ht=({receivers:n=[],contactPointsState:a,readOnly:l=!1,provisioned:i=!1,alertGroups:d=[],alertManagerSourceName:c,currentRoute:s,routeTree:E,inheritedProperties:m,routesMatchingFilters:h=[],matchingInstancesPreview:M={enabled:!1},onEditPolicy:b,onAddPolicy:Q,onDeletePolicy:F,onShowAlertInstances:G})=>{const y=(0,g.wW)($e),O=s===E,U=(0,_.Ko)(c),X=Qe.Vt.hasPermission(U.update),H=Qe.Vt.hasPermission(U.delete),I=Qe.Vt.hasAccess(U.provisioning.read,(0,Yt.RN)()),Z=s.receiver,k=s.continue??!1,T=s.group_by,A=s.mute_time_intervals??[],re={group_wait:s.group_wait,group_interval:s.group_interval,repeat_interval:s.repeat_interval},ue=(0,yt.QO)(s),de=!!(ue&&ue.length),Oe=!!A.length,Xe=h.some(te=>te.id===s.id),Te=[],ke=!de&&!O&&!k,qe=Z??m?.receiver??"";(a?sn(qe,a):[]).forEach(te=>{Te.push(te)});const Fe=m&&Object.keys(m).length>0,_e=s.routes??[],et=Fe&&m.group_by,Ue=(0,o.isArray)(T)&&T[0]==="...",tt=!Ue&&(0,o.isArray)(T)&&T.length>0,nt=O&&(0,o.isArray)(T)&&T.length===0,at=X,we=H&&!O,Ee=M?.groupsMap?.get(s.id),Le=Ee?(0,o.sumBy)(Ee,te=>te.alerts.length):void 0,De=c===ft.GC&&O&&I;return e.createElement(u.K,{direction:"column",gap:1.5},e.createElement("div",{className:y.policyWrapper(Xe),"data-testid":O?"am-root-route-container":"am-route-container"},k&&e.createElement(en,null),ke&&e.createElement(tn,null),e.createElement("div",{className:y.policyItemWrapper},e.createElement(u.K,{direction:"column",gap:1},e.createElement("div",null,e.createElement(u.K,{direction:"row",alignItems:"center",gap:1},O?e.createElement(nn,null):de?e.createElement(Et.g,{matchers:ue??[]}):e.createElement("span",{className:y.metadata},"No matchers"),e.createElement(st.L,null),Te.length>0&&e.createElement(_t,{errors:Te}),i&&e.createElement(lt.C0,null),l&&!De?null:e.createElement(u.K,{direction:"row",gap:.5},!l&&e.createElement(Ze.Z,{shouldWrap:i,wrap:Je},e.createElement(N.zx,{variant:"secondary",icon:"plus",size:"sm",onClick:()=>Q(s),disabled:i,type:"button"},"New nested policy")),e.createElement(Ht.L,{overlay:e.createElement(Me.v,null,!l&&e.createElement(Ze.Z,{shouldWrap:i,wrap:Je},e.createElement(Me.v.Item,{icon:"edit",disabled:!at||i,label:"Edit",onClick:()=>b(s,O)})),De&&e.createElement(Me.v.Item,{icon:"download-alt",label:"Export",url:(0,qt.u)("/api/v1/provisioning/policies/export",{download:"true",format:"yaml"}),target:"_blank"}),!l&&we&&e.createElement(e.Fragment,null,e.createElement(Me.v.Divider,null),e.createElement(Ze.Z,{shouldWrap:i,wrap:Je},e.createElement(Me.v.Item,{destructive:!0,icon:"trash-alt",disabled:!we||i,label:"Delete",onClick:()=>F(s)}))))},e.createElement(N.zx,{icon:"ellipsis-h",variant:"secondary",size:"sm",type:"button","aria-label":"more-actions","data-testid":"more-actions"}))))),e.createElement("div",{className:y.metadataRow},e.createElement(u.K,{direction:"row",alignItems:"center",gap:1},M.enabled&&e.createElement(ae.g,{icon:"layers-alt",onClick:()=>{Ee&&G(Ee,ue)},"data-testid":"matching-instances"},e.createElement(q.c,null,Le??"-"),e.createElement("span",null,We()("instance",Le))),Z&&e.createElement(ae.g,{icon:"at","data-testid":"contact-point"},e.createElement("span",null,"Delivered to"),e.createElement(ln,{alertManagerSourceName:c,receivers:n,contactPoint:Z})),!et&&e.createElement(e.Fragment,null,tt&&e.createElement(ae.g,{icon:"layer-group","data-testid":"grouping"},e.createElement("span",null,"Grouped by"),e.createElement(q.c,null,T.join(", "))),nt&&e.createElement(ae.g,{icon:"layer-group"},e.createElement("span",null,"Single group")),Ue&&e.createElement(ae.g,{icon:"layer-group"},e.createElement("span",null,"Not grouping"))),Oe&&e.createElement(ae.g,{icon:"calendar-slash","data-testid":"mute-timings"},e.createElement("span",null,"Muted when"),e.createElement(rn,{timings:A,alertManagerSourceName:c})),re&&Object.values(re).some(Boolean)&&e.createElement(on,{timingOptions:re}),Fe&&e.createElement(e.Fragment,null,e.createElement(ae.g,{icon:"corner-down-right-alt","data-testid":"inherited-properties"},e.createElement("span",null,"Inherited"),e.createElement(an,{properties:m})))))))),e.createElement("div",{className:y.childPolicies},_e.map(te=>{const rt=(0,kt.$2)(s,te,m);return e.createElement(ht,{key:(0,o.uniqueId)(),routeTree:E,currentRoute:te,receivers:n,contactPointsState:a,readOnly:l||i,inheritedProperties:rt,onAddPolicy:Q,onEditPolicy:b,onDeletePolicy:F,onShowAlertInstances:G,alertManagerSourceName:c,alertGroups:d,routesMatchingFilters:h,matchingInstancesPreview:M})})))},Je=n=>e.createElement(Pe.u,{content:"Provisioned items cannot be edited in the UI",placement:"top"},e.createElement("span",null,n)),_t=({errors:n})=>e.createElement(Ge.z,{arrow:!0,placement:"top",content:e.createElement(u.K,{direction:"column",gap:.5},n.map(a=>e.createElement(e.Fragment,{key:(0,o.uniqueId)()},a)))},e.createElement("span",null,e.createElement(he.C,{icon:"exclamation-circle",color:"red",text:We()("error",n.length,!0)}))),en=()=>{const n=(0,g.wW)($e);return e.createElement(Pe.u,{placement:"top",content:"This route will continue matching other policies"},e.createElement("div",{className:n.gutterIcon,"data-testid":"continue-matching"},e.createElement(Se.J,{name:"arrow-down"})))},tn=()=>{const n=(0,g.wW)($e);return e.createElement(Pe.u,{placement:"top",content:"This policy matches all labels"},e.createElement("div",{className:n.gutterIcon,"data-testid":"matches-all"},e.createElement(Se.J,{name:"exclamation-triangle"})))},nn=()=>{const n=(0,g.wW)($e);return e.createElement(e.Fragment,null,e.createElement("strong",null,"Default policy"),e.createElement("span",{className:n.metadata},"All alert instances will be handled by the default policy if no other matching policies are found."))},an=({properties:n})=>e.createElement(Ge.z,{arrow:!0,placement:"top",content:e.createElement(u.K,{direction:"row",gap:.5},Object.entries(n).map(([a,l])=>e.createElement(He._,{key:a,label:cn(a),value:e.createElement(q.c,null,mn(a,l))})))},e.createElement("div",null,e.createElement(q.c,null,We()("property",Object.keys(n).length,!0)))),rn=({timings:n,alertManagerSourceName:a})=>e.createElement("div",null,e.createElement(q.c,null,n.map(l=>e.createElement(Be.Link,{key:l,to:(0,S.ET)(l,a)},l)))),on=({timingOptions:n})=>{const a=n.group_wait??Ce.group_wait,l=n.group_interval??Ce.group_interval;return e.createElement(ae.g,{icon:"hourglass","data-testid":"timing-options"},e.createElement("span",null,"Wait"),e.createElement(Pe.u,{placement:"top",content:"How long to initially wait to send a notification for a group of alert instances."},e.createElement("span",null,e.createElement(q.c,null,a)," ",e.createElement("span",null,"to group instances"),",")),e.createElement(Pe.u,{placement:"top",content:"How long to wait before sending a notification about new alerts that are added to a group of alerts for which an initial notification has already been sent."},e.createElement("span",null,e.createElement(q.c,null,l)," ",e.createElement("span",null,"before sending updates"))))},ln=({alertManagerSourceName:n,contactPoint:a,receivers:l})=>{const i=l.find(s=>s.name===a);if(!i)return e.createElement(Be.Link,{to:(0,S.GV)(a,n)},e.createElement(q.c,null,a));if(!i.grafana_managed_receiver_configs)return e.createElement(Be.Link,{to:(0,S.GV)(a,n)},e.createElement(q.c,null,a));const c=(0,o.groupBy)(i.grafana_managed_receiver_configs,s=>s.type);return e.createElement(Ge.z,{arrow:!0,placement:"top",header:e.createElement(ae.g,{icon:"at"},e.createElement("div",null,"Contact Point"),e.createElement(q.c,null,a)),key:(0,o.uniqueId)(),content:e.createElement(u.K,{direction:"row",gap:.5},Object.entries(c).map(([s,E])=>e.createElement(He._,{key:(0,o.uniqueId)(),label:E.length>1?E.length:void 0,icon:Xt.y[s],value:(0,o.upperFirst)(s)})))},e.createElement(Be.Link,{to:(0,S.GV)(a,n)},e.createElement(q.c,null,a)))};function sn(n,a){return Object.entries(a[n]?.notifiers??[]).reduce((d=[],[c,s])=>{const E=s.filter(m=>m.lastNotifyAttemptError).map(m=>e.createElement(He._,{icon:"at",key:(0,o.uniqueId)(),label:`Contact Point \u203A ${m.name}`,value:m.lastNotifyAttemptError}));return d.concat(E)},[])}const cn=n=>{switch(n){case"receiver":return"Contact Point";case"group_by":return"Group by";case"group_interval":return"Group interval";case"group_wait":return"Group wait";case"mute_time_intervals":return"Mute timings";case"repeat_interval":return"Repeat interval";default:return n}},mn=(n,a)=>{const l=n==="group_by"&&Array.isArray(a)&&a[0]==="...",i=n==="group_by"&&Array.isArray(a)&&a.length===0;return l?e.createElement(vt.x,{variant:"bodySmall",color:"secondary"},"Not grouping"):i?e.createElement(vt.x,{variant:"bodySmall",color:"secondary"},"Single group"):Array.isArray(a)?a.join(", "):a},$e=n=>({matcher:a=>{const{color:l,borderColor:i}=(0,Jt.Bx)(a);return{wrapper:(0,r.css)`
        color: #fff;
        background: ${l};
        padding: ${n.spacing(.33)} ${n.spacing(.66)};
        font-size: ${n.typography.bodySmall.fontSize};

        border: solid 1px ${i};
        border-radius: ${n.shape.borderRadius(1)};
      `}},childPolicies:(0,r.css)`
    margin-left: ${n.spacing(4)};
    position: relative;

    &:before {
      content: '';
      position: absolute;
      height: calc(100% - 10px);

      border-left: solid 1px ${n.colors.border.weak};

      margin-top: 0;
      margin-left: -20px;
    }
  `,policyItemWrapper:(0,r.css)`
    padding: ${n.spacing(1.5)};
  `,metadataRow:(0,r.css)`
    background: ${n.colors.background.secondary};

    border-bottom-left-radius: ${n.shape.borderRadius(2)};
    border-bottom-right-radius: ${n.shape.borderRadius(2)};
  `,policyWrapper:(a=!1)=>(0,r.css)`
    flex: 1;
    position: relative;
    background: ${n.colors.background.secondary};

    border-radius: ${n.shape.borderRadius(1)};
    border: solid 1px ${n.colors.border.weak};

    ${a&&(0,r.css)`
      border-color: ${n.colors.primary.border};
    `}
  `,metadata:(0,r.css)`
    color: ${n.colors.text.secondary};

    font-size: ${n.typography.bodySmall.fontSize};
    font-weight: ${n.typography.bodySmall.fontWeight};
  `,break:(0,r.css)`
    width: 100%;
    height: 0;
    margin-bottom: ${n.spacing(2)};
  `,gutterIcon:(0,r.css)`
    position: absolute;

    top: 0;
    transform: translateY(50%);
    left: -${n.spacing(4)};

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

    width: 25px;
    height: 25px;
    text-align: center;

    border: solid 1px ${n.colors.border.weak};
    border-radius: ${n.shape.borderRadius(1)};

    padding: 0;
  `});var un=t(36546),dn=t(84369),Ye=t(68228),gn=(n=>(n.NotificationPolicies="notification_policies",n.MuteTimings="mute_timings",n))(gn||{});const pn=()=>{const n=(0,D.useDispatch)(),a=(0,g.wW)(En),{useGetAlertmanagerAlertGroupsQuery:l}=z.alertmanagerApi,[i,d]=(0,V.K)(),{tab:c}=vn(i),[s,E]=(0,e.useState)(c),[m,h]=(0,e.useState)(!1),[M,b]=(0,e.useState)(),[Q,F]=(0,e.useState)([]),{getRouteGroupsMap:G}=(0,un.N)(),{selectedAlertmanager:y}=(0,dt.Z)(),O=(0,Y.V)(y??""),{currentData:U,isLoading:X,error:H}=(0,L.W)(y,{refetchOnFocus:!0,refetchOnReconnect:!0}),I=U?.alertmanager_config,{currentData:Z,refetch:k}=l({amSourceName:y??""},{skip:!y}),T=I?.receivers??[],A=(0,e.useMemo)(()=>{if(I?.route)return(0,W.br)(I.route)},[I?.route]),[{value:re,error:ue},de]=(0,v.Z)(G,[G]);(0,e.useEffect)(()=>{A&&Z&&de(A,Z)},[A,Z,de]);const Oe=(0,e.useMemo)(()=>A?bt(A,{contactPointFilter:M,labelMatchersFilter:Q}):[],[M,Q,A]),Xe=!!I?.route?.provenance;function Te(oe){if(!A)return;const Ie=(0,Ye.SF)(y??"",oe,A);Ne(Ie)}function ke(oe){if(!A)return;const Ie=(0,Ye.wB)(oe,A);Ne(Ie)}function qe(oe,Ie){if(!A)return;const Mn=(0,Ye._P)(y??"",oe,Ie,A);Ne(Mn)}function Ne(oe){U&&(h(!0),n((0,ne.mM)({newConfig:{...U,alertmanager_config:{...U.alertmanager_config,route:oe}},oldConfig:U,alertManagerSourceName:y,successMessage:"Updated notification policies",refetch:!0})).unwrap().then(()=>{y&&k(),nt(),et(),Ee()}).finally(()=>{h(!1)}))}const[Fe,_e,et]=zt(T,qe,m),[Ue,tt,nt]=jt(y??"",T,Te,m),[at,we,Ee]=Qt(ke,m),[Le,At]=Zt();if((0,$.x)(oe=>oe.unifiedAlerting.saveAMConfig=dn.oq),!y)return null;const De=(0,ft.RY)(y),te=De,rt=De,hn=U?.alertmanager_config.mute_time_intervals?.length??0,bn=U&&!H&&!X,An=!U&&X,Cn=H&&!X,Ct=s==="mute_timings",Mt=s==="notification_policies";return e.createElement(e.Fragment,null,e.createElement(p.J,null,e.createElement(B.O,{label:"Notification Policies",active:Mt,onChangeTab:()=>{E("notification_policies"),d({tab:"notification_policies"})}}),e.createElement(B.O,{label:"Mute Timings",active:Ct,counter:hn,onChangeTab:()=>{E("mute_timings"),d({tab:"mute_timings"})}})),e.createElement(C.I,{className:a.tabContent},An&&e.createElement(x.u,{text:"Loading Alertmanager config..."}),Cn&&e.createElement(R.b,{severity:"error",title:"Error loading Alertmanager config"},H.message||"Unknown error."),bn&&e.createElement(e.Fragment,null,Mt&&e.createElement(e.Fragment,null,e.createElement(ve.u,{currentAlertmanager:y}),e.createElement(u.K,{direction:"column",gap:1},A&&e.createElement(xe.B0,{receivers:T,onChangeMatchers:F,onChangeReceiver:b}),A&&e.createElement(ht,{receivers:T,routeTree:A,currentRoute:A,alertGroups:Z??[],contactPointsState:O.receivers,readOnly:te,provisioned:Xe,alertManagerSourceName:y,onAddPolicy:_e,onEditPolicy:tt,onDeletePolicy:we,onShowAlertInstances:At,routesMatchingFilters:Oe,matchingInstancesPreview:{groupsMap:re,enabled:!ue}})),Fe,Ue,at,Le),Ct&&e.createElement(Dt,{alertManagerSourceName:y,hideActions:rt}))))},bt=(n,a)=>{const{contactPointFilter:l,labelMatchersFilter:i=[]}=a;let d=[];const c=(0,xe.tK)(n),s=l?(0,xe.Iw)(c,m=>m.receiver===l):void 0;s&&d.push(s);const E=i.length?(0,xe.Iw)(c,m=>{const h=(0,yt.QO)(m);return i.every(M=>h.some(b=>(0,o.isEqual)(M,b)))}):void 0;return E&&d.push(E),(0,o.intersectionBy)(...d,"id")},En=n=>({tabContent:(0,r.css)`
    margin-top: ${n.spacing(2)};
  `});function vn(n){let a="notification_policies";return n.tab==="notification_policies"&&(a="notification_policies"),n.tab==="mute_timings"&&(a="mute_timings"),{tab:a}}const fn=()=>e.createElement(ie.O,{pageId:"am-routes",accessType:"notification"},e.createElement(pn,null)),yn=(0,w.Pf)(fn,{style:"page"})},98164:(J,P,t)=>{t.d(P,{V:()=>u});var r=t(33555),o=t(16881),e=t(8014);const v=o.C.injectEndpoints({endpoints:g=>({contactPointsState:g.query({queryFn:async({amSourceName:p})=>{try{return{data:await(0,e.QE)(p)}}catch(B){return{error:B}}}})})}),u=g=>{const p={receivers:{},errorCount:0},{currentData:B}=v.useContactPointsStateQuery({amSourceName:g??""},{skip:!g,pollingInterval:r.m4});return B??p}},43491:(J,P,t)=>{t.d(P,{F:()=>u});var r=t(42844),o=t(27702),e=t(66310),v=t(45986);const u=({renderExpandedContent:p,...B})=>{const C=(0,e.wW)(g);return o.createElement(v.t,{renderExpandedContent:p?(x,R,w)=>o.createElement(o.Fragment,null,R!==w.length-1&&o.createElement("div",{className:(0,r.cx)(C.contentGuideline,C.guideline)}),p(x,R,w)):void 0,renderPrefixHeader:()=>o.createElement("div",{className:C.relative},o.createElement("div",{className:(0,r.cx)(C.headerGuideline,C.guideline)})),renderPrefixCell:(x,R,w)=>o.createElement("div",{className:C.relative},o.createElement("div",{className:(0,r.cx)(C.topGuideline,C.guideline)}),R!==w.length-1&&o.createElement("div",{className:(0,r.cx)(C.bottomGuideline,C.guideline)})),...B})},g=p=>({relative:(0,r.css)`
    position: relative;
    height: 100%;
  `,guideline:(0,r.css)`
    left: -19px;
    border-left: 1px solid ${p.colors.border.weak};
    position: absolute;

    ${p.breakpoints.down("md")} {
      display: none;
    }
  `,topGuideline:(0,r.css)`
    width: 18px;
    border-bottom: 1px solid ${p.colors.border.medium};
    top: 0;
    bottom: 50%;
  `,bottomGuideline:(0,r.css)`
    top: 50%;
    bottom: 0;
  `,contentGuideline:(0,r.css)`
    top: 0;
    bottom: 0;
    left: -49px !important;
  `,headerGuideline:(0,r.css)`
    top: -17px;
    bottom: 0;
  `})},80118:(J,P,t)=>{t.d(P,{u:()=>B});var r=t(42844),o=t(27702),e=t(66310),v=t(63439),u=t(62862),g=t(52646),p=t(22513);function B({currentAlertmanager:x}){const R=(0,e.wW)(C),{useGetAlertmanagerChoiceStatusQuery:w}=g.alertmanagerApi,{currentData:V}=w(),D=x===p.GC;if(!(V?.alertmanagersChoice&&[u.TE.External,u.TE.All].includes(V?.alertmanagersChoice))||!D)return null;const z=V.numExternalAlertmanagers>0;return V.alertmanagersChoice===u.TE.External?o.createElement(v.b,{title:"Grafana alerts are not delivered to Grafana Alertmanager"},"Grafana is configured to send alerts to external Alertmanagers only. Changing Grafana Alertmanager configuration will not affect delivery of your alerts.",o.createElement("div",{className:R.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):V.alertmanagersChoice===u.TE.All&&z?o.createElement(v.b,{title:"You have additional Alertmanagers to configure",severity:"warning"},"Ensure you make configuration changes in the correct Alertmanagers; both internal and external. Changing one will not affect the others.",o.createElement("div",{className:R.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):null}const C=x=>({adminHint:(0,r.css)`
    font-size: ${x.typography.bodySmall.fontSize};
    font-weight: ${x.typography.bodySmall.fontWeight};
  `})},18629:(J,P,t)=>{t.d(P,{C0:()=>g,Uv:()=>v,Xq:()=>u});var r=t(27702),o=t(63439),e=t(25357),v=(p=>(p.ContactPoint="contact point",p.Template="template",p.MuteTiming="mute timing",p.AlertRule="alert rule",p.RootNotificationPolicy="root notification policy",p))(v||{});const u=({resource:p})=>r.createElement(o.b,{title:`This ${p} cannot be edited through the UI`,severity:"info"},"This ",p," has been provisioned, that means it was created by config. Please contact your server admin to update this ",p,"."),g=()=>r.createElement(e.C,{text:"Provisioned",color:"purple"})},92273:(J,P,t)=>{t.d(P,{c:()=>e});var r=t(27702),o=t(66310);const e=({children:v})=>{const u=(0,o.l4)();return r.createElement("strong",{style:{color:u.colors.text.primary}},v)}},9853:(J,P,t)=>{t.d(P,{y:()=>le});var r=t(42844),o=t(27702),e=t(66310),v=t(62862),u=t(8254),g=t(10759),p=t(32082),B=t(43491),C=t(22201),x=t(66670),R=t(91368),w=t(18771),V=t(2082),D=t(22513),$=t(39036),z=t(73104),Y=t(89439);const ie=({alert:f,alertManagerSourceName:j})=>{const L=(0,e.wW)(ve),ne=(0,V.QX)(j),S=(0,D.HY)(j)?R.contextSrv.hasPermission(w.AccessControlAction.AlertingRuleRead):!0;return o.createElement(o.Fragment,null,o.createElement("div",{className:L.actionsRow},o.createElement(Y.q,{actions:[ne.update,ne.create],fallback:R.contextSrv.isEditor},f.status.state===v.Z9.Suppressed&&o.createElement(x.Qj,{href:`${(0,$.eQ)("/alerting/silences",j)}&silenceIds=${f.status.silencedBy.join(",")}`,className:L.button,icon:"bell",size:"sm"},"Manage silences"),f.status.state===v.Z9.Active&&o.createElement(x.Qj,{href:(0,$.VN)(j,f.labels),className:L.button,icon:"bell-slash",size:"sm"},"Silence")),S&&f.generatorURL&&o.createElement(x.Qj,{className:L.button,href:f.generatorURL,icon:"chart-line",size:"sm"},"See source")),Object.entries(f.annotations).map(([se,Ke])=>o.createElement(z.a,{key:se,annotationKey:se,value:Ke})),o.createElement("div",{className:L.receivers},"Receivers:"," ",f.receivers.map(({name:se})=>se).filter(se=>!!se).join(", ")))},ve=f=>({button:(0,r.css)`
    & + & {
      margin-left: ${f.spacing(1)};
    }
  `,actionsRow:(0,r.css)`
    padding: ${f.spacing(2,0)} !important;
    border-bottom: 1px solid ${f.colors.border.medium};
  `,receivers:(0,r.css)`
    padding: ${f.spacing(1,0)};
  `}),N=({alerts:f,alertManagerSourceName:j})=>{const L=(0,e.wW)(fe),ne=(0,o.useMemo)(()=>[{id:"state",label:"State",renderCell:({data:S})=>o.createElement(o.Fragment,null,o.createElement(C.G,{state:S.status.state}),o.createElement("span",{className:L.duration},"for"," ",(0,p.vT)({start:new Date(S.startsAt),end:new Date(S.endsAt)}))),size:"220px"},{id:"labels",label:"Labels",renderCell:({data:{labels:S}})=>o.createElement(u.s,{labels:S,size:"sm"}),size:1}],[L]),_=(0,o.useMemo)(()=>f.map(S=>({id:S.fingerprint,data:S})),[f]);return o.createElement("div",{className:L.tableWrapper,"data-testid":"alert-group-table"},o.createElement(B.F,{cols:ne,items:_,isExpandable:!0,renderExpandedContent:({data:S})=>o.createElement(ie,{alert:S,alertManagerSourceName:j})}))},fe=f=>({tableWrapper:(0,r.css)`
    margin-top: ${f.spacing(3)};
    ${f.breakpoints.up("md")} {
      margin-left: ${f.spacing(4.5)};
    }
  `,duration:(0,r.css)`
    margin-left: ${f.spacing(1)};
    font-size: ${f.typography.bodySmall.fontSize};
  `});var ce=t(33273);const le=({alertManagerSourceName:f,group:j})=>{const[L,ne]=(0,o.useState)(!0),_=(0,e.wW)(ye);return o.createElement("div",{className:_.wrapper},o.createElement("div",{className:_.header},o.createElement("div",{className:_.group,"data-testid":"alert-group"},o.createElement(g.U,{size:"sm",isCollapsed:L,onToggle:()=>ne(!L),"data-testid":"alert-group-collapse-toggle"}),Object.keys(j.labels).length?o.createElement(u.s,{labels:j.labels,size:"sm"}):o.createElement("span",null,"No grouping")),o.createElement(ce.Z,{group:j})),!L&&o.createElement(N,{alertManagerSourceName:f,alerts:j.alerts}))},ye=f=>({wrapper:(0,r.css)`
    & + & {
      margin-top: ${f.spacing(2)};
    }
  `,header:(0,r.css)`
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: ${f.spacing(1,1,1,0)};
    background-color: ${f.colors.background.secondary};
    width: 100%;
  `,group:(0,r.css)`
    display: flex;
    flex-direction: row;
    align-items: center;
  `,summary:(0,r.css)``,spanElement:(0,r.css)`
    margin-left: ${f.spacing(.5)};
  `,[v.Z9.Active]:(0,r.css)`
    color: ${f.colors.error.main};
  `,[v.Z9.Suppressed]:(0,r.css)`
    color: ${f.colors.primary.main};
  `,[v.Z9.Unprocessed]:(0,r.css)`
    color: ${f.colors.secondary.main};
  `})},86342:(J,P,t)=>{t.d(P,{Nx:()=>B,kO:()=>p,ot:()=>g});var r=t(79913),o=t.n(r),e=t(27702),v=t(76658);const u=/^((([01][0-9])|(2[0-3])):[0-5][0-9])$|(^24:00$)/,g=C=>C?u.test(C):!0,p=(C,x)=>{if(!C&&!x)return!0;if(!C&&x||C&&!x)return!1;const R="HH:mm",w=o()().startOf("day").add(C,R),V=o()().startOf("day").add(x,R);return!!(C&&x&&w.isBefore(V)||C&&x&&V.isAfter(w))};function B(C){return C.time_intervals.map((R,w)=>{const{times:V,weekdays:D,days_of_month:$,months:z,years:Y,location:ie}=R,ve=(0,v.u6)(V,ie),N=(0,v.v7)(D),fe=(0,v.J8)($),ce=(0,v.m8)(z),le=(0,v.qw)(Y);return e.createElement(e.Fragment,{key:JSON.stringify(R)+w},`${ve} ${N}`,e.createElement("br",null),[fe,ce,le].join(" | "),e.createElement("br",null))})}},74023:(J,P,t)=>{t.d(P,{Kt:()=>w,HU:()=>V});var r=t(78209),o=t(73289),e=t(16881);const v=e.C.injectEndpoints({endpoints:D=>({getOnCallIntegrations:D.query({queryFn:async()=>({data:await u()})})})});async function u(){try{return(await(0,r.n)((0,o.i)().fetch({url:"/api/plugin-proxy/grafana-oncall-app/api/internal/v1/alert_receive_channels/",showErrorAlert:!1,showSuccessAlert:!1}))).data.map($=>$.integration_url)}catch{return[]}}const{useGetOnCallIntegrationsQuery:g}=v;var p=t(76393),B=t(62401);const C=(D,$)=>$.includes(D),x=(D,$)=>{if(!D.grafana_managed_receiver_configs)return!1;const z=D.grafana_managed_receiver_configs.length===1,Y=C(D.grafana_managed_receiver_configs[0]?.settings?.url??"",$);return z&&Y},R=()=>{const{installed:D}=(0,p.n)(B.W.OnCall),{data:$}=g(void 0,{skip:!D});return Y=>{if(D&&x(Y,$??[]))return B.W.OnCall}},w=D=>{const $=R(),z=Y=>({label:Y.name,value:Y.name,grafanaAppReceiverType:$(Y)});return D.map(z)},V=D=>{const $=R();return D.map(z=>({...z,grafanaAppReceiverType:$(z)}))}},22201:(J,P,t)=>{t.d(P,{G:()=>u});var r=t(27702),o=t(62862),e=t(6949);const v={[o.Z9.Active]:"bad",[o.Z9.Unprocessed]:"neutral",[o.Z9.Suppressed]:"info"},u=({state:g})=>r.createElement(e.i,{state:v[g]},g)},79003:(J,P,t)=>{t.d(P,{j:()=>v});var r=t(27702),o=t(7662),e=t(26129);function v(){const{search:u}=(0,o.TH)(),g=(0,r.useMemo)(()=>new URLSearchParams(u),[u]),p=(0,r.useCallback)((B,C)=>{e.E1.partial(B,C)},[]);return[g,p]}},14917:(J,P,t)=>{t.d(P,{y:()=>r});const r={discord:"discord",email:"envelope",googlechat:"google-hangouts-alt",hipchat:"hipchat",line:"line",pagerduty:"pagerduty",slack:"slack",teams:"microsoft",telegram:"telegram-alt"}}}]);

//# sourceMappingURL=AlertAmRoutes.0ef23b172f3327b71f6a.js.map