"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6411],{69533:(R,h,t)=>{t.d(h,{V:()=>M});var l=t(63483),r=t(20584),n=t(32490);const u=r.C.injectEndpoints({endpoints:E=>({contactPointsState:E.query({queryFn:async({amSourceName:f})=>{try{return{data:await(0,n.QE)(f)}}catch(s){return{error:s}}}})})}),M=E=>{const f={receivers:{},errorCount:0},{currentData:s}=u.useContactPointsStateQuery({amSourceName:E??""},{skip:!E,pollingInterval:l.m4});return s??f}},81456:(R,h,t)=>{t.d(h,{q:()=>M});var l=t(86832),r=t.n(l),n=t(39953),u=t(18314);const M=({actions:_,children:d})=>{const o=(0,l.filter)(_,x),e=(0,l.filter)(_,O);return o.length?n.createElement(E,{actions:o},d):e.length?n.createElement(f,{actions:e},d):null},E=({actions:_,children:d})=>{const o=(0,u.Mz)();return s(o,_)?n.createElement(n.Fragment,null,d):null},f=({actions:_,children:d})=>{const o=(0,u.cI)();return s(o,_)?n.createElement(n.Fragment,null,d):null};function s(_,d){return(0,l.chain)(_).pick(d).values().value().some(([o,e])=>e===!0)}function x(_){return Object.values(u.oI).includes(_)}function O(_){return Object.values(u.hB).includes(_)}},91753:(R,h,t)=>{t.d(h,{u:()=>_});var l=t(41407),r=t(22160),n=t.n(r),u=t(39953),M=t(19977),E=t(82803),f=t(84541),s=t(4919),x=t(36210),O=t(15898);function _({format:o,textDefinition:e,downloadFileName:a,onClose:c}){const i=(0,E.wW)(d),m=(0,u.useCallback)(()=>{const v=new Blob([e],{type:`application/${o};charset=utf-8`});n()(v,`${a}.${o}`),c()},[e,a,o,c]),P=(0,u.useMemo)(()=>{const v=O.uN[o];return v.formatter?v.formatter(e):e},[o,e]);return u.createElement("div",{className:i.container},u.createElement("div",{className:i.content},u.createElement(M.Z,{disableWidth:!0},({height:v})=>u.createElement(f.p,{width:"100%",height:v,language:o,value:P,monacoOptions:{minimap:{enabled:!1},lineNumbers:"on",readOnly:!0}}))),u.createElement("div",{className:i.actions},u.createElement(s.zx,{variant:"secondary",onClick:c},"Cancel"),u.createElement(x.m,{icon:"copy",getText:()=>e},"Copy code"),u.createElement(s.zx,{icon:"download-alt",onClick:m},"Download")))}const d=o=>({container:(0,l.css)`
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: ${o.spacing(2)};
  `,content:(0,l.css)`
    flex: 1 1 100%;
  `,actions:(0,l.css)`
    flex: 0;
    justify-content: flex-end;
    display: flex;
    gap: ${o.spacing(1)};
  `})},42527:(R,h,t)=>{t.d(h,{i:()=>u});var l=t(39953),r=t(87722),n=t(89525);function u({activeTab:M,onTabChange:E,children:f,onClose:s,formatProviders:x,title:O="Export"}){const _=Object.values(x).map(d=>({label:d.name,value:d.exportFormat}));return l.createElement(r.d,{title:O,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:l.createElement(n.mg,{tabs:_,setActiveTab:E,activeTab:M}),onClose:s,size:"md"},f)}},15898:(R,h,t)=>{t.d(h,{uN:()=>u});const l={name:"JSON",exportFormat:"json",formatter:E=>{try{return JSON.stringify(JSON.parse(E),null,4)}catch{return E}}},r={name:"YAML",exportFormat:"yaml"},n={name:"Terraform (HCL)",exportFormat:"hcl"},u={[l.exportFormat]:l,[r.exportFormat]:r,[n.exportFormat]:n},M=[l,r]},89525:(R,h,t)=>{t.d(h,{CU:()=>i,mg:()=>m});var l=t(41407),r=t(48532),n=t(39953),u=t(14058),M=t(19977),E=t(82803),f=t(87722),s=t(22784),x=t(77804),O=t(4919),_=t(69865),d=t(12190),o=t(84541),e=t(90839),a=t(15032);const c=[{label:"Yaml",value:"yaml"}],i=({onClose:p})=>{const[D,y]=(0,n.useState)("yaml"),{setValue:C}=(0,u.Gc)(),T=(0,E.wW)(U),W=S=>{for(const I in S)C(I,S[I]);p()};return n.createElement(f.d,{title:"Inspect Alert rule",subtitle:n.createElement("div",{className:T.subtitle},n.createElement(m,{tabs:c,setActiveTab:y,activeTab:D})),onClose:p},D==="yaml"&&n.createElement(P,{onSubmit:W}))};function m({tabs:p,activeTab:D,setActiveTab:y}){return n.createElement(s.J,null,p.map((C,T)=>n.createElement(x.O,{key:`${C.value}-${T}`,label:C.label,value:C.value,onChangeTab:()=>y(C.value),active:D===C.value})))}const P=({onSubmit:p})=>{const D=(0,E.wW)(A),{getValues:y}=(0,u.Gc)(),C=(0,e.yh)(y()),[T,W]=(0,n.useState)((0,r.$w)(C)),S=()=>{const I=(0,r.zD)(T),B=y(),L=g(I);p({...B,...L})};return n.createElement(n.Fragment,null,n.createElement("div",{className:D.applyButton},n.createElement(O.zx,{type:"button",onClick:S},"Apply"),n.createElement(_.u,{content:n.createElement(v,null),theme:"info",placement:"left-start",interactive:!0},n.createElement(d.J,{name:"exclamation-triangle",size:"xl"}))),n.createElement("div",{className:D.content},n.createElement(M.Z,{disableWidth:!0},({height:I})=>n.createElement(o.p,{width:"100%",height:I,language:"yaml",value:T,onBlur:W,monacoOptions:{minimap:{enabled:!1}}}))))};function v(){return n.createElement("div",null,"The YAML content in the editor only contains alert rule configuration ",n.createElement("br",null),"To configure Prometheus, you need to provide the rest of the"," ",n.createElement("a",{href:"https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/",target:"_blank",rel:"noreferrer"},"configuration file content."))}function g(p){return(0,a.cG)(p)?(0,e.WL)(p):(0,a.yF)(p)?(0,e.lN)(p):{}}const A=p=>({content:(0,l.css)`
    flex-grow: 1;
    height: 100%;
    padding-bottom: 16px;
    margin-bottom: ${p.spacing(2)};
  `,applyButton:(0,l.css)`
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-grow: 0;
    margin-bottom: ${p.spacing(2)};
  `}),U=()=>({subtitle:(0,l.css)`
    display: flex;
    align-items: center;
    justify-content: space-between;
  `})},18314:(R,h,t)=>{t.d(h,{Mz:()=>O,RA:()=>_,cI:()=>x,hB:()=>f,o2:()=>d,oI:()=>E,xC:()=>o});var l=t(39953),r=t(97125),n=t(57721),u=t(328),M=t(60703),E=(e=>(e.ViewExternalConfiguration="view-external-configuration",e.UpdateExternalConfiguration="update-external-configuration",e.CreateContactPoint="create-contact-point",e.ViewContactPoint="view-contact-point",e.UpdateContactPoint="edit-contact-points",e.DeleteContactPoint="delete-contact-point",e.ExportContactPoint="export-contact-point",e.CreateNotificationTemplate="create-notification-template",e.ViewNotificationTemplate="view-notification-template",e.UpdateNotificationTemplate="edit-notification-template",e.DeleteNotificationTemplate="delete-notification-template",e.DecryptSecrets="decrypt-secrets",e.CreateNotificationPolicy="create-notification-policy",e.ViewNotificationPolicyTree="view-notification-policy-tree",e.UpdateNotificationPolicyTree="update-notification-policy-tree",e.DeleteNotificationPolicy="delete-notification-policy",e.ExportNotificationPolicies="export-notification-policies",e.CreateSilence="create-silence",e.ViewSilence="view-silence",e.UpdateSilence="update-silence",e.ViewMuteTiming="view-mute-timing",e.CreateMuteTiming="create-mute-timing",e.UpdateMuteTiming="update-mute-timing",e.DeleteMuteTiming="delete-mute-timing",e))(E||{}),f=(e=>(e.CreateAlertRule="create-alert-rule",e.ViewAlertRule="view-alert-rule",e.UpdateAlertRule="update-alert-rule",e.DeleteAlertRule="delete-alert-rule",e.CreateExternalAlertRule="create-external-alert-rule",e.ViewExternalAlertRule="view-external-alert-rule",e.UpdateExternalAlertRule="update-external-alert-rule",e.DeleteExternalAlertRule="delete-external-alert-rule",e))(f||{});const s=!0;function x(){return{["create-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleCreate)],["view-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleRead)],["update-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleUpdate)],["delete-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleDelete)],["create-external-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleExternalWrite)],["view-external-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleExternalRead)],["update-external-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleExternalWrite)],["delete-external-alert-rule"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingRuleExternalWrite)]}}function O(){const{selectedAlertmanager:e,hasConfigurationAPI:a,isGrafanaAlertmanager:c}=(0,u.ZA)(),i=(0,M.Ko)(e),m=(0,M.QX)(e);return{["view-external-configuration"]:[s,r.contextSrv.hasPermission(n.AccessControlAction.AlertingNotificationsExternalRead)],["update-external-configuration"]:[a,r.contextSrv.hasPermission(n.AccessControlAction.AlertingNotificationsExternalWrite)],["create-contact-point"]:[a,r.contextSrv.hasPermission(i.create)],["view-contact-point"]:[s,r.contextSrv.hasPermission(i.read)],["edit-contact-points"]:[a,r.contextSrv.hasPermission(i.update)],["delete-contact-point"]:[a,r.contextSrv.hasPermission(i.delete)],["export-contact-point"]:[c,r.contextSrv.hasPermission(i.provisioning.read)||r.contextSrv.hasPermission(i.provisioning.readSecrets)],["create-notification-template"]:[a,r.contextSrv.hasPermission(i.create)],["view-notification-template"]:[s,r.contextSrv.hasPermission(i.read)],["edit-notification-template"]:[a,r.contextSrv.hasPermission(i.update)],["delete-notification-template"]:[a,r.contextSrv.hasPermission(i.delete)],["create-notification-policy"]:[a,r.contextSrv.hasPermission(i.create)],["view-notification-policy-tree"]:[s,r.contextSrv.hasPermission(i.read)],["update-notification-policy-tree"]:[a,r.contextSrv.hasPermission(i.update)],["delete-notification-policy"]:[a,r.contextSrv.hasPermission(i.delete)],["export-notification-policies"]:[c,r.contextSrv.hasPermission(i.provisioning.read)||r.contextSrv.hasPermission(i.provisioning.readSecrets)],["decrypt-secrets"]:[c,r.contextSrv.hasPermission(i.provisioning.readSecrets)],["create-silence"]:[a,r.contextSrv.hasPermission(m.create)],["view-silence"]:[s,r.contextSrv.hasPermission(m.read)],["update-silence"]:[a,r.contextSrv.hasPermission(m.update)],["create-mute-timing"]:[a,r.contextSrv.hasPermission(i.create)],["view-mute-timing"]:[s,r.contextSrv.hasPermission(i.read)],["update-mute-timing"]:[a,r.contextSrv.hasPermission(i.update)],["delete-mute-timing"]:[a,r.contextSrv.hasPermission(i.delete)]}}function _(e){const a=O();return(0,l.useMemo)(()=>a[e],[a,e])}function d(e){const a=O();return(0,l.useMemo)(()=>e.map(c=>a[c]),[a,e])}function o(e){const a=x();return(0,l.useMemo)(()=>a[e],[a,e])}},62393:(R,h,t)=>{t.d(h,{$2:()=>_,tK:()=>d,w2:()=>x});var l=t(86832),r=t.n(l),n=t(47858),u=t(75404);const M={[n._M.equal]:(o,e)=>o===e,[n._M.notEqual]:(o,e)=>o!==e,[n._M.regex]:(o,e)=>!!o.match(new RegExp(e)),[n._M.notRegex]:(o,e)=>!o.match(new RegExp(e))};function E(o,e){const[a,c]=e,[i,m,P]=o;if(a!==i)return!1;const v=M[m];if(!v)throw new Error(`no such operator: ${m}`);return v(c,P)}function f(o,e){const a=new Map,c=new Map(e.map(m=>[m,{match:!1,matchers:[]}]));return{matches:o.every(m=>{const P=e.filter(v=>E(m,v));return P.forEach(v=>{const g=c.get(v);g&&(g.match=!0,g.matchers.push(m))}),P.length===0?!1:(a.set(m,P),P.length>0)}),details:a,labelsMatch:c}}function s(o,e){let a=[];const c=f(o.object_matchers??[],e);if(!c.matches)return[];if(o.routes)for(let i=0;i<o.routes.length;i++){let m=o.routes[i],P=s(m,e);if(a=a.concat(P),P.length&&!m.continue)break}return a.length===0&&a.push({route:o,details:c.details,labelsMatch:c.labelsMatch}),a}function x(o){function e(c){c.object_matchers=(0,u.QO)(c),delete c.matchers,delete c.match,delete c.match_re,c.routes?.forEach(e)}const a=structuredClone(o);return e(a),a}function O(o,e,a){const c=[];return a.reduce((i,m)=>{const P=m.alerts.filter(v=>{const g=Object.entries(v.labels);return s(o,g).some(A=>A.route===e)});return P.length&&i.push({...m,alerts:P}),i},c)}function _(o,e,a){const c=(0,l.merge)({},o,a),i=(0,l.pick)(c,["receiver","group_by","group_wait","group_interval","repeat_interval","mute_time_intervals"]);return(0,l.reduce)(i,(P={},v,g)=>{const A=v!==void 0,U=A&&e[g]===void 0,p=A&&e[g]==="",D=g==="group_by"&&A&&(0,l.isArray)(e[g])&&e[g]?.length===0;return(U||p||D)&&(P[g]=v),P},{})}function d(o){return{...o,routes:o.routes?.map(e=>{const a=_(o,e);return d({...e,...a})})}}}}]);

//# sourceMappingURL=6411.a332a0a0f64f37d3e65c.js.map