/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.triggersActionsUi_bundle_jsonpfunction=window.triggersActionsUi_bundle_jsonpfunction||[]).push([[40],{155:function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));const n="/internal/rac/alerts"},315:function(t,e,r){"use strict";r.r(e),r.d(e,"AlertSummaryWidget",(function(){return c})),r.d(e,"default",(function(){return c}));var n=r(1),i=r(155),a=r(29);var o=r(67),l=r(0);const c=({chartProps:t,featureIds:e,filter:r,fullSize:c,onClick:u=(()=>{}),timeRange:s,hideChart:d})=>{const{alertSummary:{activeAlertCount:v,activeAlerts:f,recoveredAlertCount:A},isLoading:C,error:g}=function({featureIds:t,timeRange:e,filter:r}){const{http:o}=Object(a.b)().services,[l,c]=Object(n.useState)({isLoading:!0,alertSummary:{activeAlertCount:0,activeAlerts:[],recoveredAlertCount:0}}),u=Object(n.useRef)(!1),s=Object(n.useRef)(new AbortController),d=Object(n.useCallback)((async()=>{if(t){u.current=!1,s.current.abort(),s.current=new AbortController;try{const{activeAlertCount:n,activeAlerts:a,recoveredAlertCount:l}=await async function({featureIds:t,filter:e,http:r,signal:n,timeRange:{utcFrom:a,utcTo:o,fixedInterval:l}}){var c,u,s;const d=await r.post(`${i.a}/_alert_summary`,{signal:n,body:JSON.stringify({fixed_interval:l,gte:a,lte:o,featureIds:t,filter:[e]})});return{activeAlertCount:null!==(c=null==d?void 0:d.activeAlertCount)&&void 0!==c?c:0,activeAlerts:null!==(u=null==d?void 0:d.activeAlerts)&&void 0!==u?u:[],recoveredAlertCount:null!==(s=null==d?void 0:d.recoveredAlertCount)&&void 0!==s?s:0}}({featureIds:t,filter:r,http:o,signal:s.current.signal,timeRange:e});u.current||c((()=>({alertSummary:{activeAlertCount:n,activeAlerts:a,recoveredAlertCount:l},isLoading:!1})))}catch(t){u.current||"AbortError"!==t.name&&c((e=>({...e,isLoading:!1,error:t.message})))}}}),[t,r,o,e]);return Object(n.useEffect)((()=>{d()}),[d]),l}({featureIds:e,filter:r,timeRange:s});return C?Object(l.jsx)(o.d,{fullSize:c,isLoadingWithoutChart:d}):g?Object(l.jsx)(o.b,null):c?v||A?Object(l.jsx)(o.c,{activeAlertCount:v,activeAlerts:f,chartProps:t,dateFormat:s.dateFormat,recoveredAlertCount:A,hideChart:d}):null:Object(l.jsx)(o.a,{activeAlertCount:v,activeAlerts:f,chartProps:t,onClick:u,recoveredAlertCount:A,timeRangeTitle:s.title})}}}]);