"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4312],{43730(J,M,e){e.d(M,{E3:()=>f,vj:()=>h});const t=`{{ define "__subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ if gt (.Alerts.Resolved | len) 0 }}, RESOLVED:{{ .Alerts.Resolved | len }}{{ end }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }}

{{ define "__text_values_list" }}{{ if len .Values }}{{ $first := true }}{{ range $refID, $value := .Values -}}
{{ if $first }}{{ $first = false }}{{ else }}, {{ end }}{{ $refID }}={{ $value }}{{ end -}}
{{ else }}[no value]{{ end }}{{ end }}

{{ define "__text_alert_list" }}{{ range . }}
Value: {{ template "__text_values_list" . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}{{ if gt (len .GeneratorURL) 0 }}Source: {{ .GeneratorURL }}
{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: {{ .SilenceURL }}
{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: {{ .DashboardURL }}
{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: {{ .PanelURL }}
{{ end }}{{ end }}{{ end }}

{{ define "default.title" }}{{ template "__subject" . }}{{ end }}

{{ define "default.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing**
{{ template "__text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }}

{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved**
{{ template "__text_alert_list" .Alerts.Resolved }}{{ end }}{{ end }}

{{ define "__teams_text_alert_list" }}{{ range . }}
Value: {{ template "__text_values_list" . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
{{ if gt (len .GeneratorURL) 0 }}Source: [{{ .GeneratorURL }}]({{ .GeneratorURL }})

{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: [{{ .SilenceURL }}]({{ .SilenceURL }})

{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: [{{ .DashboardURL }}]({{ .DashboardURL }})

{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: [{{ .PanelURL }}]({{ .PanelURL }})

{{ end }}
{{ end }}{{ end }}

{{ define "teams.default.message" }}{{ if gt (len .Alerts.Firing) 0 }}**Firing**
{{ template "__teams_text_alert_list" .Alerts.Firing }}{{ if gt (len .Alerts.Resolved) 0 }}

{{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}**Resolved**
{{ template "__teams_text_alert_list" .Alerts.Resolved }}{{ end }}{{ end }}`;var u=e(87988),o=e(5709);const N=["TemplateGroup"],s=o.H.enhanceEndpoints({addTagTypes:N}).injectEndpoints({endpoints:p=>({listNamespacedTemplateGroup:p.query({query:a=>({url:`/apis/notifications.alerting.grafana.app/v0alpha1/namespaces/${a.namespace}/templategroups`,params:{pretty:a.pretty,allowWatchBookmarks:a.allowWatchBookmarks,continue:a.continue,fieldSelector:a.fieldSelector,labelSelector:a.labelSelector,limit:a.limit,resourceVersion:a.resourceVersion,resourceVersionMatch:a.resourceVersionMatch,sendInitialEvents:a.sendInitialEvents,timeoutSeconds:a.timeoutSeconds,watch:a.watch}}),providesTags:["TemplateGroup"]}),createNamespacedTemplateGroup:p.mutation({query:a=>({url:`/apis/notifications.alerting.grafana.app/v0alpha1/namespaces/${a.namespace}/templategroups`,method:"POST",body:a.comGithubGrafanaGrafanaPkgApisAlertingNotificationsV0Alpha1TemplateGroup,params:{pretty:a.pretty,dryRun:a.dryRun,fieldManager:a.fieldManager,fieldValidation:a.fieldValidation}}),invalidatesTags:["TemplateGroup"]}),readNamespacedTemplateGroup:p.query({query:a=>({url:`/apis/notifications.alerting.grafana.app/v0alpha1/namespaces/${a.namespace}/templategroups/${a.name}`,params:{pretty:a.pretty}}),providesTags:["TemplateGroup"]}),replaceNamespacedTemplateGroup:p.mutation({query:a=>({url:`/apis/notifications.alerting.grafana.app/v0alpha1/namespaces/${a.namespace}/templategroups/${a.name}`,method:"PUT",body:a.comGithubGrafanaGrafanaPkgApisAlertingNotificationsV0Alpha1TemplateGroup,params:{pretty:a.pretty,dryRun:a.dryRun,fieldManager:a.fieldManager,fieldValidation:a.fieldValidation}}),invalidatesTags:["TemplateGroup"]}),deleteNamespacedTemplateGroup:p.mutation({query:a=>({url:`/apis/notifications.alerting.grafana.app/v0alpha1/namespaces/${a.namespace}/templategroups/${a.name}`,method:"DELETE",body:a.ioK8SApimachineryPkgApisMetaV1DeleteOptions,params:{pretty:a.pretty,dryRun:a.dryRun,gracePeriodSeconds:a.gracePeriodSeconds,orphanDependents:a.orphanDependents,propagationPolicy:a.propagationPolicy}}),invalidatesTags:["TemplateGroup"]})}),overrideExisting:!1}),d="/api/alertmanager/grafana/config/api/v1/templates/test";s.enhanceEndpoints({endpoints:{readNamespacedTemplateGroup:p=>{const a={hideErrorMessage:!0};p.extraOptions=a}}});const f=s.injectEndpoints({endpoints:p=>({previewTemplate:p.mutation({query:({template:a,alerts:y,name:K})=>({url:d,data:{template:a,alerts:y,name:K},method:"POST"})}),getDefaultTemplates:p.query({queryFn:async()=>({data:(0,u.D)(t)})})})}),{usePreviewTemplateMutation:h}=f},12266(J,M,e){e.d(M,{e:()=>o});var t=e(74848),u=e(45861);const o=({isCollapsed:N,onToggle:s,idControlled:d,className:f,text:h,size:p="xl",...a})=>(0,t.jsx)(u.$n,{type:"button",fill:"text",variant:"secondary","aria-expanded":!N,"aria-controls":d,className:f,icon:N?"angle-right":"angle-down",onClick:()=>s(!N),...a,children:h})},46787(J,M,e){e.r(M),e.d(M,{ActiveTab:()=>tt,ContactPointsPageContents:()=>rt,default:()=>Et});var t=e(74848),u=e(96540),o=e(92745),N=e(6975),s=e(50201),d=e(45861),f=e(41654),h=e(34999),p=e(66404),a=e(54314),y=e(60208),K=e(13941),m=e(34213),w=e(73427),H=e(56476),B=e(77256),D=e(11257),n=e(16692),l=e(74048),g=e(20962),r=e(5358),j=e(52161),S=e(88547),W=e(36826),$=e(58750),Y=e(24961),Q=e(25992),X=e(63142),c=e(71599),T=e(45967),O=e(99887),E=e(64762),A=e(16194),V=e(24898),L=e(27911),x=e(12266),k=e(40165),at=e(1972),Z=e(40403),_=e(71774),ct=e(1332);const dt=({alertManagerName:i,templates:b})=>{const P=(0,E._2)(),[I]=(0,Z._3)({alertmanager:i}),R=(0,X.of)(L.L),[v,U]=(0,u.useState)(),G=async()=>{if(v)try{await I.execute({uid:v.uid}),P.success("Template deleted",`Template ${v.title} has been deleted`)}catch(C){P.error("Error deleting template",`Error deleting template ${v.title}`);const F=C instanceof Error?C:new Error((0,B.JZ)(C));(0,Q.vV)(F)}U(void 0)};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("table",{className:R.table,"data-testid":"templates-table",children:[(0,t.jsxs)("colgroup",{children:[(0,t.jsx)("col",{className:R.colExpand}),(0,t.jsx)("col",{}),(0,t.jsx)("col",{})]}),(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{}),(0,t.jsx)("th",{children:(0,t.jsx)(o.x6,{i18nKey:"alerting.templates-table.template-group",children:"Template group"})}),(0,t.jsx)(V._,{actions:[n.QI.CreateNotificationTemplate,n.QI.UpdateNotificationTemplate,n.QI.DeleteNotificationTemplate],children:(0,t.jsx)("th",{children:(0,t.jsx)(o.x6,{i18nKey:"alerting.templates-table.actions",children:"Actions"})})})]})}),(0,t.jsxs)("tbody",{children:[!b.length&&(0,t.jsx)("tr",{className:R.evenRow,children:(0,t.jsx)("td",{colSpan:3,children:(0,t.jsx)(o.x6,{i18nKey:"alerting.templates-table.no-templates-defined",children:"No templates defined."})})}),b.map((C,F)=>(0,t.jsx)(pt,{notificationTemplate:C,idx:F,alertManagerName:i,onDeleteClick:U},C.uid))]})]}),!!v&&(0,t.jsx)(c.u,{isOpen:!0,title:(0,o.t)("alerting.templates-table.title-delete-template-group","Delete template group"),body:(0,o.t)("alerting.templates-table.body-delete-template-group",'Are you sure you want to delete template group "{{template}}"?',{template:v.title}),confirmText:(0,o.t)("alerting.templates-table.confirmText-yes-delete","Yes, delete"),onConfirm:G,onDismiss:()=>U(void 0)})]})};function pt({notificationTemplate:i,idx:b,alertManagerName:P,onDeleteClick:I}){const R=(0,X.of)(L.L),v=P===j.hY,[U,G]=(0,u.useState)(!1),{isProvisioned:C}=(0,Z.OA)(i),{uid:F,title:z,content:q,missing:et}=i,nt=(0,o.t)("alerting.templates.misconfigured-badge-text","Misconfigured");return(0,t.jsxs)(u.Fragment,{children:[(0,t.jsxs)("tr",{className:b%2===0?R.evenRow:void 0,children:[(0,t.jsx)("td",{children:(0,t.jsx)(x.e,{isCollapsed:!U,onToggle:()=>G(!U)})}),(0,t.jsxs)("td",{children:[z," ",C&&(0,t.jsx)(at.rS,{})," ",et&&!v&&(0,t.jsx)(T.m,{content:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.x6,{i18nKey:"alerting.templates.misconfigured-warning",children:"This template is misconfigured."}),(0,t.jsx)("br",{}),(0,t.jsxs)(o.x6,{i18nKey:"alerting.templates.misconfigured-warning-details",children:["Templates must be defined in both the"," ",(0,t.jsx)(A.X,{content:(0,o.t)("alerting.template-row.content-templatefiles","template_files")})," and"," ",(0,t.jsx)(A.X,{content:(0,o.t)("alerting.template-row.content-templates","templates")})," sections of your alertmanager configuration."]})]}),children:(0,t.jsx)("span",{children:(0,t.jsx)(O.E,{text:nt,color:"orange"})})})]}),(0,t.jsxs)("td",{className:R.actionsCell,children:[C&&(0,t.jsx)(_.M,{to:(0,B.nL)(`/alerting/notifications/templates/${encodeURIComponent(F)}/edit`,P),tooltip:(0,o.t)("alerting.template-row.tooltip-view-template","view template"),icon:"file-alt"}),!C&&(0,t.jsx)(V._,{actions:[n.QI.UpdateNotificationTemplate],children:(0,t.jsx)(_.M,{to:(0,B.nL)(`/alerting/notifications/templates/${encodeURIComponent(F)}/edit`,P),tooltip:(0,o.t)("alerting.template-row.tooltip-edit-template-group","Edit template group"),icon:"pen"})}),(0,t.jsx)(V._,{actions:[n.QI.CreateNotificationTemplate],children:(0,t.jsx)(_.M,{to:(0,B.nL)(`/alerting/notifications/templates/${encodeURIComponent(F)}/duplicate`,P),tooltip:(0,o.t)("alerting.template-row.tooltip-copy-template-group","Copy template group"),icon:"copy"})}),!C&&(0,t.jsx)(V._,{actions:[n.QI.DeleteNotificationTemplate],children:(0,t.jsx)(_.M,{onClick:()=>I(i),tooltip:(0,o.t)("alerting.template-row.tooltip-delete-template-group","Delete template group"),icon:"trash-alt"})})]})]}),U&&(0,t.jsxs)("tr",{className:b%2===0?R.evenRow:void 0,children:[(0,t.jsx)("td",{}),(0,t.jsx)("td",{colSpan:2,children:(0,t.jsx)(k.X,{label:"",horizontal:!0,children:(0,t.jsx)(ct.K,{width:"auto",height:"auto",autoHeight:!0,value:q,showLineNumbers:!1,monacoOptions:{readOnly:!0,scrollBeyondLastLine:!1}})})})]})]},F)}const mt=()=>{const{selectedAlertmanager:i}=(0,r.VI)(),{data:b,isLoading:P,error:I}=(0,Z.cC)({alertmanager:i??""});return I?(0,t.jsx)(h.F,{title:(0,o.t)("alerting.notification-templates.title-failed-to-fetch-notification-templates","Failed to fetch notification templates"),children:(0,B.JZ)(I)}):P?(0,t.jsx)(N._,{text:(0,o.t)("alerting.notification-templates.text-loading-notification-templates","Loading notification templates")}):b?(0,t.jsx)(dt,{alertManagerName:i,templates:b}):null};var gt=e(22803),ut=e(40996),ft=e(37386),ht=e(63527),xt=e(30703);const bt=()=>{const i=(0,X.of)(vt),[b,P]=(0,g.l)(),I=b.get("search")??"",[R,v]=(0,u.useState)(I),[U,G]=(0,ut.A)(()=>{P({search:R},!0)},300,[P,R]),C=(0,u.useCallback)(()=>{G(),v(""),P({search:""},!0)},[G,P]),F=!!I;return(0,t.jsxs)(f.B,{direction:"row",alignItems:"end",gap:.5,children:[(0,t.jsx)(ft.D,{className:i.noBottom,label:(0,o.t)("alerting.contact-points-filter.label-search-by-name-or-type","Search by name or type"),children:(0,t.jsx)(ht.p,{"aria-label":(0,o.t)("alerting.contact-points-filter.aria-label-search-contact-points","search contact points"),placeholder:(0,o.t)("alerting.contact-points-filter.placeholder-search","Search"),width:46,prefix:(0,t.jsx)(xt.I,{name:"search"}),onChange:z=>{v(z.currentTarget.value)},value:R})}),(0,t.jsx)(d.$n,{variant:"secondary",icon:"times",onClick:()=>C(),disabled:!F,"aria-label":(0,o.t)("alerting.contact-points-filter.aria-label-clear","clear"),children:(0,t.jsx)(o.x6,{i18nKey:"alerting.contact-points-filter.clear",children:"Clear"})})]})},vt=()=>({noBottom:(0,gt.css)({marginBottom:0})}),Tt=({alertManagerName:i})=>{const b=(0,j.AL)(i);return(0,t.jsx)(V._,{actions:[n.QI.UpdateExternalConfiguration],children:(0,t.jsxs)(h.F,{severity:"info",title:(0,o.t)("alerting.global-config-alert.title-global-config-for-contact-points","Global config for contact points"),children:[(0,t.jsx)("p",{children:(0,t.jsx)(o.x6,{i18nKey:"alerting.global-config-alert.body",children:"For each external Alertmanager you can define global settings, like server addresses, usernames and password, for all the supported contact points."})}),(0,t.jsx)(d.z9,{href:(0,B.nL)("alerting/notifications/global-config",i),variant:"secondary",children:b?(0,o.t)("alerting.global-config-alert.view-global-config","View global config"):(0,o.t)("alerting.global-config-alert.edit-global-config","Edit global config")})]})})};var ot=e(97507),At=e(84139),Ct=e(2543),yt=e(3887);const it=new At.A({intraMode:1,intraIns:1,intraSub:1,intraDel:1,intraTrn:1}),jt=(i,b)=>{const P=(0,u.useMemo)(()=>i.map(G=>G.name),[i]),I=(0,u.useMemo)(()=>i.map(G=>G.grafana_managed_receiver_configs.map(C=>C[yt.MX].name).join(" ")),[i]);if(!b)return i;const R=it.filter(P,b)??[],v=it.filter(I,b)??[],U=[...R,...v];return(0,Ct.uniq)(U).map(G=>i[G])??[]};var st=e(8307),tt=(i=>(i.ContactPoints="contact_points",i.NotificationTemplates="templates",i))(tt||{});const lt=10,Pt=()=>{const{selectedAlertmanager:i}=(0,r.VI)(),[b]=(0,g.l)(),P=!(0,H.dM)(i),I=w.TP.hasPermission(D.w.AlertingNotificationsRead),{isLoading:R,error:v,contactPoints:U}=(0,ot.dK)({alertmanager:i,fetchPolicies:P,fetchStatuses:I}),[G,C]=(0,n.L7)(n.QI.CreateContactPoint),[F,z]=(0,n.L7)(n.QI.ExportContactPoint),[q,et]=(0,st.G)(),nt=b.get("search");if(R)return(0,t.jsx)(N._,{text:(0,o.t)("alerting.contact-points-tab.text-loading","Loading...")});const It=i===j.hY;return U.length===0?(0,t.jsx)(s.p,{variant:C?"call-to-action":"not-found",button:C&&(0,t.jsx)(d.z9,{href:(0,B.nL)("/alerting/notifications/receivers/new",i),icon:"plus",size:"lg",children:(0,t.jsx)(o.x6,{i18nKey:"alerting.contact-points.create",children:"Create contact point"})}),message:(0,o.t)("alerting.contact-points.empty-state.title","You don't have any contact points yet")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(f.B,{direction:"row",alignItems:"end",justifyContent:"space-between",children:[(0,t.jsx)(bt,{}),(0,t.jsxs)(f.B,{direction:"row",gap:1,children:[G&&(0,t.jsx)(d.z9,{icon:"plus","aria-label":(0,o.t)("alerting.contact-points-tab.aria-label-add-contact-point","add contact point"),variant:"primary",href:"/alerting/notifications/receivers/new",disabled:!C,children:(0,t.jsx)(o.x6,{i18nKey:"alerting.contact-points.create",children:"Create contact point"})}),F&&(0,t.jsx)(d.$n,{icon:"download-alt",variant:"secondary","aria-label":(0,o.t)("alerting.contact-points-tab.aria-label-export-all","export all"),disabled:!z,onClick:()=>et(st.B),children:(0,t.jsx)(o.x6,{i18nKey:"alerting.contact-points-tab.export-all",children:"Export all"})})]})]}),v?(0,t.jsx)(h.F,{title:(0,o.t)("alerting.contact-points-tab.title-failed-to-fetch-contact-points","Failed to fetch contact points"),children:(0,B.JZ)(v)}):(0,t.jsx)(Rt,{contactPoints:U,search:nt,pageSize:lt}),!It&&(0,t.jsx)(Tt,{alertManagerName:i}),q]})},St=()=>{const[i,b]=(0,n.L7)(n.QI.CreateNotificationTemplate);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(f.B,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[(0,t.jsx)(p.E,{variant:"body",color:"secondary",children:(0,t.jsx)(o.x6,{i18nKey:"alerting.notification-templates-tab.create-notification-templates-customize-notifications",children:"Create notification templates to customize your notifications."})}),i&&(0,t.jsx)(d.z9,{icon:"plus",variant:"primary",href:"/alerting/notifications/templates/new",disabled:!b,children:(0,t.jsx)(o.x6,{i18nKey:"alerting.notification-templates-tab.add-notification-template-group",children:"Add notification template group"})})]}),(0,t.jsx)(mt,{})]})},Lt=i=>{const[b,P]=(0,g.l)();return[(0,u.useMemo)(()=>{const v=b.get("tab");return!v||!Object.values(tt).map(String).includes(v)?i:v||i},[i,b]),v=>P({tab:v})]},rt=()=>{const{selectedAlertmanager:i}=(0,r.VI)(),[,b]=(0,n.L7)(n.QI.ViewContactPoint),[,P]=(0,n.L7)(n.QI.CreateContactPoint),[,I]=(0,n.L7)(n.QI.ViewNotificationTemplate),R=b||P,v=[R&&"contact_points",I&&"templates"].filter(q=>!!q)[0],[U,G]=Lt(v),{contactPoints:C}=(0,ot.dK)({alertmanager:i}),F=U==="contact_points",z=U==="templates";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)($.M,{currentAlertmanager:i}),(0,t.jsxs)(f.B,{direction:"column",children:[(0,t.jsxs)(a.U,{children:[R&&(0,t.jsx)(y.o,{label:(0,o.t)("alerting.contact-points-page-contents.label-contact-points","Contact Points"),active:F,counter:C.length,onChangeTab:()=>G("contact_points")}),I&&(0,t.jsx)(y.o,{label:(0,o.t)("alerting.contact-points-page-contents.label-notification-templates","Notification Templates"),active:z,onChangeTab:()=>G("templates")})]}),(0,t.jsx)(K.J,{children:(0,t.jsxs)(f.B,{direction:"column",children:[F&&(0,t.jsx)(Pt,{}),z&&(0,t.jsx)(St,{})]})})]})]})},Rt=({contactPoints:i,search:b,pageSize:P=lt})=>{const I=jt(i,b),{page:R,pageItems:v,numberOfPages:U,onPageChange:G}=(0,l.W)(I,1,P);if(v.length===0){const C=(0,o.t)("alerting.contact-points.no-contact-points-found","No contact points found");return(0,t.jsx)(s.p,{variant:"not-found",message:C})}return(0,t.jsxs)(t.Fragment,{children:[v.map((C,F)=>{const z=`${C.name}-${F}`;return(0,t.jsx)(Y.z8,{contactPoint:C},z)}),(0,t.jsx)(m.d,{currentPage:R,numberOfPages:U,onNavigate:G,hideWhenSinglePage:!0})]})};function Dt(){return(0,t.jsx)(W.y,{navId:"receivers",accessType:"notification",children:(0,t.jsx)(rt,{})})}const Et=(0,S.S)(Dt)},40403(J,M,e){e.d(M,{A1:()=>$,J2:()=>j,OA:()=>X,_3:()=>Y,cC:()=>n,lx:()=>Q,xW:()=>W});var t=e(96540),u=e(85618),o=e(91984),N=e(43730),s=e(80218),d=e(43100),f=e(55614),h=e(22628),p=e(56476),a=e(42801);const{useGetAlertmanagerConfigurationQuery:y,useLazyGetAlertmanagerConfigurationQuery:K}=o.m,{useListNamespacedTemplateGroupQuery:m,useLazyReadNamespacedTemplateGroupQuery:w,useCreateNamespacedTemplateGroupMutation:H,useReplaceNamespacedTemplateGroupMutation:B,useDeleteNamespacedTemplateGroupMutation:D}=N.E3;function n({alertmanager:c}){const T=(0,p.dM)(c),O=m({namespace:(0,u.Ge)()},{skip:!T,selectFromResult:A=>({...A,data:A.data?l(A.data):void 0,currentData:A.currentData?l(A.currentData):void 0})}),E=y(c,{skip:T,selectFromResult:A=>({...A,data:A.data?r(A.data):void 0,currentData:A.currentData?r(A.currentData):void 0})});return T?O:E}function l(c){return c.items.map(T=>g(T))}function g(c){const T=(0,p.gw)(c,h.T.Provenance)??h.rh;return{uid:c.metadata.name??c.spec.title,title:c.spec.title,content:c.spec.content,provenance:T}}function r(c){const{alertmanager_config:T}=c,{templates:O=[]}=T;return Object.entries(c.template_files).map(([E,A])=>({uid:E,title:E,content:A,provenance:(c.template_file_provenances??{})[E]||h.rh,missing:!O.includes(E)}))}function j({alertmanager:c,uid:T}){const[O,E]=K({selectFromResult:x=>({...x,data:x.data?S(x.data,T):void 0,currentData:x.currentData?S(x.currentData,T):void 0})}),[A,V]=w({selectFromResult:x=>({...x,data:x.data?g(x.data):void 0,currentData:x.currentData?g(x.currentData):void 0})}),L=(0,p.dM)(c);return(0,t.useEffect)(()=>{L?A({namespace:(0,u.Ge)(),name:T}):O(c)},[c,T,L,O,A]),L?V:E}function S(c,T){return r(c).find(E=>E.title===T)}function W({alertmanager:c}){const[T]=H(),[O]=(0,d.d)(),E=(0,p.dM)(c),A=(0,s.Yb)(({templateValues:L})=>{const x=(0,f.FB)({template:L});return O(x)}),V=(0,s.Yb)(({templateValues:L})=>{const x=(0,a.o)(L.title,L.content);return T({namespace:(0,u.Ge)(),comGithubGrafanaGrafanaPkgApisAlertingNotificationsV0Alpha1TemplateGroup:{spec:{title:L.title,content:x},metadata:{}}}).unwrap()});return E?V:A}function $({alertmanager:c}){const[T]=B(),[O]=(0,d.d)(),E=(0,p.dM)(c),A=(0,s.Yb)(({template:L,patch:x})=>{const k=(0,f.jS)({name:L.title,template:x});return O(k)}),V=(0,s.Yb)(({template:L,patch:x})=>{const k=(0,a.o)(x.title,x.content);return T({namespace:(0,u.Ge)(),name:L.uid,comGithubGrafanaGrafanaPkgApisAlertingNotificationsV0Alpha1TemplateGroup:{spec:{title:x.title,content:k},metadata:{name:L.uid}}}).unwrap()});return E?V:A}function Y({alertmanager:c}){const[T]=D(),[O]=(0,d.d)(),E=(0,s.Yb)(async({uid:L})=>{const x=(0,f.JI)({name:L});return O(x)}),A=(0,s.Yb)(({uid:L})=>T({namespace:(0,u.Ge)(),name:L,ioK8SApimachineryPkgApisMetaV1DeleteOptions:{}}).unwrap());return(0,p.dM)(c)?A:E}function Q({alertmanager:c,originalTemplate:T}){const{useLazyGetAlertmanagerConfigurationQuery:O}=o.m,[E]=O();return{titleIsUnique:async V=>{if((0,p.dM)(c)||T?.title===V)return!0;const x=await E(c).unwrap();return r(x).some(Z=>Z.title===V)?"Another template with this name already exists":!0}}}function X(c){return c?{isProvisioned:!!c.provenance&&c.provenance!==h.rh}:{isProvisioned:!1}}},1332(J,M,e){e.d(M,{K:()=>D});var t=e(74848),u=e(96540),o=e(50992),N=e(2543),s=e(56652);function d(n){const l=n.languages.CompletionItemKind.Function;return[{label:s.AlertmanagerTemplateFunction.toUpper,detail:"function(s string)",kind:l},{label:s.AlertmanagerTemplateFunction.toLower,detail:"function(s string)",kind:l},{label:s.AlertmanagerTemplateFunction.title,documentation:"Capitalizes the first letter of each word",detail:"function(s string)",kind:l},{label:s.AlertmanagerTemplateFunction.join,documentation:{value:"Joins an array of strings using the separator provided."},detail:"function(separator string, s []string)",kind:l},{label:s.AlertmanagerTemplateFunction.match,detail:"function",kind:l},{label:s.AlertmanagerTemplateFunction.safeHtml,detail:"function(pattern, repl, text)",kind:l},{label:s.AlertmanagerTemplateFunction.reReplaceAll,detail:"function(pattern, repl, text)",kind:l},{label:s.AlertmanagerTemplateFunction.stringSlice,detail:"function(s ...string)",kind:l}]}function f(n){const l=n.languages.CompletionItemKind.Function;return Object.values(s.GomplateFunctions).flatMap(g=>g.map(r=>({label:r.keyword,detail:r.usage,documentation:`${r.definition}

${r.example}`,kind:l})))}var h=e(32443);function p(n){const l={triggerCharacters:["."],provideCompletionItems(g,r,j){const S=g.getWordUntilPosition(r),W={startLineNumber:r.lineNumber,endLineNumber:r.lineNumber,startColumn:S.startColumn,endColumn:S.endColumn},$=new y(n,W);if(!a(g,r))return $.getSnippetsSuggestions();if(j.triggerKind===n.languages.CompletionTriggerKind.Invoke&&!j.triggerCharacter)return $.getFunctionsSuggestions();const Q=g.getWordUntilPosition({lineNumber:r.lineNumber,column:r.column-1});return $.getTemplateDataSuggestions(Q.word)}};return n.languages.registerCompletionItemProvider("go-template",l)}function a(n,l){return n.findMatches("\\{\\{(?:.|\\n)+?\\}\\}",n.getFullModelRange(),!0,!1,null,!1).some(j=>j.range.containsPosition({lineNumber:l.lineNumber,column:l.column+1}))}class y{constructor(l,g){this.monaco=l,this.range=g,this.getSnippetsSuggestions=()=>this.getCompletionsFromDefinitions((0,h.Mq)(this.monaco)),this.getFunctionsSuggestions=()=>this.getCompletionsFromDefinitions(d(this.monaco),f(this.monaco)),this.getTemplateDataSuggestions=r=>{switch(r){case"":return this.getCompletionsFromDefinitions((0,h.Xt)(this.monaco),(0,h.So)(this.monaco));case"Alerts":return this.getCompletionsFromDefinitions((0,h.J2)(this.monaco));case"GroupLabels":case"CommonLabels":case"CommonAnnotations":case"Labels":case"Annotations":return this.getCompletionsFromDefinitions((0,h.KS)(this.monaco));default:return{suggestions:[]}}},this.getCompletionsFromDefinitions=(...r)=>({suggestions:(0,N.concat)(...r).map(S=>K(S,this.range))})}}function K({label:n,detail:l,documentation:g,kind:r,insertText:j},S){const W=typeof n=="string"?n:n.label,$=typeof n=="string"?{label:n,description:l}:{...n};return $.description??=l,{label:$,kind:r,insertText:j??W,range:S,documentation:g,detail:l}}const m="go-template",H={id:m,extensions:[],aliases:[],mimetypes:[],loader:()=>Promise.resolve().then(e.bind(e,56652))},B=(n,l)=>{const{id:g,loader:r}=l;n.languages.getLanguages().find(S=>S.id===g)||(n.languages.register({id:g}),r().then(S=>{n.languages.setMonarchTokensProvider(g,S.language),n.languages.setLanguageConfiguration(g,S.conf)}))},D=n=>{const l=!!n.autoHeight,g=(0,u.useRef)(null),r=j=>{if(l){const S=j.getContentHeight();try{j.layout({height:S,width:NaN})}catch{}}};return(0,u.useEffect)(()=>()=>{g.current?.dispose()},[]),(0,t.jsx)(o.B,{showLineNumbers:!0,showMiniMap:!1,...n,monacoOptions:{scrollBeyondLastLine:!1},onEditorDidMount:r,onBeforeEditorMount:j=>{B(j,H),g.current=p(j)},language:m})}},32443(J,M,e){e.d(M,{So:()=>K,J2:()=>m,Xt:()=>y,KS:()=>w,Mq:()=>B,L:()=>H});var t=e(92745);const u=`
{{ range .Alerts }}
  Status: {{ .Status }}
  Starts at: {{ .StartsAt }}
{{ end }}
`,o=`
[{{.Status}}] {{ .Labels.alertname }}

Labels:
{{ range .Labels.SortedPairs }}
  {{ .Name }}: {{ .Value }}
{{ end }}

{{ if gt (len .Annotations) 0 }}
Annotations:
{{ range .Annotations.SortedPairs }}
  {{ .Name }}: {{ .Value }}
{{ end }}
{{ end }}

{{ if gt (len .SilenceURL ) 0 }}
  Silence alert: {{ .SilenceURL }}
{{ end }}
{{ if gt (len .DashboardURL ) 0 }}
  Go to dashboard: {{ .DashboardURL }}
{{ end }}
`,N=`
{{ coll.Dict
  "receiver" .Receiver
  "status" .Status
  "alerts" ( len .Alerts )
| data.ToJSONPretty " " }}
`,s=a("GroupLabels.SortedPairs"),d=a("CommonLabels.SortedPairs"),f=a("CommonAnnotations.SortedPairs"),h=a("Labels.SortedPairs"),p=a("Annotations.SortedPairs");function a(D){return`
{{ range .${D} }}
  {{ .Name }} = {{ .Value }}
{{ end }}`}function y(D){const n=D.languages.CompletionItemKind.Field;return[{label:"Alerts",kind:n,detail:"Alert[]",documentation:{value:(0,t.t)("alerting.get-global-suggestions.value.an-array-containing-all-alerts","An Array containing all alerts")}},{label:"Receiver",kind:n,detail:"string"},{label:"Status",kind:n,detail:"string"},{label:"GroupLabels",kind:n,detail:"[]KeyValue"},{label:"CommonLabels",kind:n,detail:"[]KeyValue"},{label:"CommonAnnotations",kind:n,detail:"[]KeyValue"},{label:"ExternalURL",kind:n,detail:"string"},{label:"GroupKey",kind:n,detail:"string"},{label:"TruncatedAlerts",kind:n,detail:"integer"}]}function K(D){const n=D.languages.CompletionItemKind.Field;return[{label:{label:"Status",detail:"(Alert)",description:"string"},kind:n,detail:"string",documentation:{value:(0,t.t)("alerting.get-alert-suggestions.value.status-alert-firing-resolved","Status of the alert. It can be `firing` or `resolved`")}},{label:{label:"Labels",detail:"(Alert)"},kind:n,detail:"[]KeyValue",documentation:{value:(0,t.t)("alerting.get-alert-suggestions.value.labels-attached-alert","A set of labels attached to the alert.")}},{label:{label:"Annotations",detail:"(Alert)"},kind:n,detail:"[]KeyValue",documentation:(0,t.t)("alerting.get-alert-suggestions.documentation.annotations-attached-alert","A set of annotations attached to the alert.")},{label:{label:"StartsAt",detail:"(Alert)"},kind:n,detail:"time.Time",documentation:(0,t.t)("alerting.get-alert-suggestions.documentation.time-the-alert-started-firing","Time the alert started firing.")},{label:{label:"EndsAt",detail:"(Alert)"},kind:n,detail:"time.Time",documentation:"Only set if the end time of an alert is known. Otherwise set to a configurable timeout period from the time since the last alert was received."},{label:{label:"GeneratorURL",detail:"(Alert)"},kind:n,detail:"string",documentation:(0,t.t)("alerting.get-alert-suggestions.documentation.grafana-external-alertmanager","Back link to Grafana or external Alertmanager.")},{label:{label:"SilenceURL",detail:"(Alert)"},kind:n,detail:"string",documentation:"Link to Grafana silence for with labels for this alert pre-filled. Only for Grafana managed alerts."},{label:{label:"DashboardURL",detail:"(Alert)"},kind:n,detail:"string",documentation:"Link to Grafana dashboard, if alert rule belongs to one. Only for Grafana managed alerts."},{label:{label:"PanelURL",detail:"(Alert)"},kind:n,detail:"string",documentation:"Link to Grafana dashboard panel, if alert rule belongs to one. Only for Grafana managed alerts."},{label:{label:"Fingerprint",detail:"(Alert)"},kind:n,detail:"string",documentation:(0,t.t)("alerting.get-alert-suggestions.documentation.fingerprint-identify-alert","Fingerprint that can be used to identify the alert.")},{label:{label:"ValueString",detail:"(Alert)"},kind:n,detail:"string",documentation:"String that contains labels and values of each reduced expression in the alert."},{label:{label:"OrgID",detail:"(Alert)"},kind:n,detail:"integer",documentation:(0,t.t)("alerting.get-alert-suggestions.documentation.organization-alert","The ID of the organization that owns the alert.")}]}function m(D){const n=D.languages.CompletionItemKind.Field;return[{label:"Firing",kind:n,detail:"Alert[]"},{label:"Resolved",kind:n,detail:"Alert[]"}]}function w(D){const n=D.languages.CompletionItemKind.Field;return[{label:"SortedPairs",kind:n,detail:"[]KeyValue"},{label:"Names",kind:n,detail:"[]string"},{label:"Values",kind:n,detail:"[]string"},{label:"Remove",detail:"KeyValue[] function(keys []string)",kind:D.languages.CompletionItemKind.Method}]}const H={alerts:{label:"alertsloop",description:"Renders a loop through alerts",snippet:u},alertDetails:{label:"alertdetails",description:"Renders all information available about the alert",snippet:o},groupLabels:{label:"grouplabelsloop",description:"Renders a loop through group labels",snippet:s},commonLabels:{label:"commonlabelsloop",description:"Renders a loop through common labels",snippet:d},commonAnnotations:{label:"commonannotationsloop",description:"Renders a loop through common annotations",snippet:f},labels:{label:"labelsloop",description:"Renders a loop through labels",snippet:h},annotations:{label:"annotationsloop",description:"Renders a loop through annotations",snippet:p},json:{label:"json",description:"Renders a JSON object",snippet:N}};function B(D){const n=D.languages.CompletionItemKind.Snippet,l=D.languages.CompletionItemInsertTextRule.InsertAsSnippet,{alerts:g,alertDetails:r,groupLabels:j,commonLabels:S,commonAnnotations:W,labels:$,annotations:Y,json:Q}=H;return[{label:g.label,documentation:g.description,kind:n,insertText:g.snippet,insertTextRules:l},{label:{label:r.label,detail:"(Alert)"},documentation:r.description,kind:n,insertText:r.snippet,insertTextRules:l},{label:j.label,documentation:j.description,kind:n,insertText:j.snippet,insertTextRules:l},{label:S.label,documentation:S.description,kind:n,insertText:S.snippet,insertTextRules:l},{label:W.label,documentation:W.description,kind:n,insertText:W.snippet,insertTextRules:l},{label:{label:$.label,detail:"(Alert)"},documentation:$.description,kind:n,insertText:$.snippet,insertTextRules:l},{label:{label:Y.label,detail:"(Alert)"},documentation:Y.description,kind:n,insertText:Y.snippet,insertTextRules:l},{label:Q.label,documentation:Q.description,kind:n,insertText:Q.snippet,insertTextRules:D.languages.CompletionItemInsertTextRule.KeepWhitespace}]}},87988(J,M,e){e.d(M,{D:()=>t,G7:()=>N,Jl:()=>u,gY:()=>o});function t(s){const d={},f=[],h=/{{-?\s*(define|end|if|range|else|with|template|block)\b(.*?)-?}}/gs;let p,a=0;for(;(p=h.exec(s))!==null;){const[,y,K]=p;if(a=p.index,y==="define"){const m=K?.match(/"([^"]+)"/);m&&f.push({type:"define",startIndex:a,name:m[1]})}else if(y==="end"){let m=f.pop();for(;m&&m.type!=="define"&&m.type!=="if"&&m.type!=="range"&&m.type!=="with"&&m.type!=="block";)m=f.pop();if(m){const w=h.lastIndex;m.type==="define"&&!m.name?.startsWith("__")&&(d[m.name]={name:m.name,content:s.slice(m.startIndex,w)})}}else(y==="if"||y==="range"||y==="else"||y==="with"||y==="block")&&f.push({type:y,startIndex:a})}for(const y of Object.values(d)){const K=/{{ template "([^"]+)" }}/g;let m;for(;(m=K.exec(y.content))!==null;){const w=m[1];d[w]?.content&&(y.content+=`
`+d[w]?.content,delete d[w])}}return Object.values(d)}function u(s){return`{{ template "${s}" . }}`}function o(s){const d=s.match(/\{\{\s*template\s*"(.*)"\s*\.\s*\}\}/);return d?d[1]:""}function N(s){const d=/\{\{\s*template\s*".*?"\s*\.\s*\}\}/g;if(s.match(d)?.length!==1)return!1;const h=s.split(d);for(const p of h)if(p.trim()!=="")return!1;return!0}},71774(J,M,e){e.d(M,{M:()=>N});var t=e(74848),u=e(45967),o=e(45861);const N=({tooltip:s,icon:d,to:f,target:h,onClick:p,className:a,tooltipPlacement:y="top",...K})=>{const m=typeof s=="string"?s:void 0;return(0,t.jsx)(u.m,{content:s,placement:y,children:f?(0,t.jsx)(o.z9,{variant:"secondary",fill:"text",icon:d,href:f,size:"sm",target:h,...K,"aria-label":m}):(0,t.jsx)(o.$n,{className:a,variant:"secondary",fill:"text",size:"sm",icon:d,type:"button",onClick:p,...K,"aria-label":m})})}},27911(J,M,e){e.d(M,{L:()=>u});var t=e(22803);const u=o=>({table:(0,t.css)({width:"100%",borderRadius:o.shape.radius.default,border:`solid 1px ${o.colors.border.weak}`,backgroundColor:o.colors.background.secondary,th:{padding:o.spacing(1)},td:{padding:`0 ${o.spacing(1)}`},tr:{height:"38px"}}),evenRow:(0,t.css)({backgroundColor:o.colors.background.primary}),colExpand:(0,t.css)({width:"36px"}),nameCell:(0,t.css)({gap:o.spacing(1)}),actionsCell:(0,t.css)({textAlign:"right",width:"1%",whiteSpace:"nowrap","& > * + *":{marginLeft:o.spacing(.5)}})})}}]);

//# sourceMappingURL=ContactPoints.04767418ac617d16fd07.js.map