/*! 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([[45],{123:function(e,t,o){"use strict";o.d(t,"a",(function(){return r})),o(1);var s=o(3),l=o(2),n=o(0);const r=({children:e,onClose:t})=>Object(n.jsx)(l.EuiPopoverTitle,null,Object(n.jsx)(l.EuiFlexGroup,{alignItems:"center",gutterSize:"s"},Object(n.jsx)(l.EuiFlexItem,null,e),Object(n.jsx)(l.EuiFlexItem,{grow:!1},Object(n.jsx)(l.EuiButtonIcon,{iconType:"cross",color:"danger","aria-label":s.i18n.translate("xpack.triggersActionsUI.common.expressionItems.components.closablePopoverTitle.closeLabel",{defaultMessage:"Close"}),onClick:()=>t()}))))},311:function(e,t,o){"use strict";o.r(t),o.d(t,"ThresholdExpression",(function(){return d})),o.d(t,"default",(function(){return d}));var s=o(1),l=o.n(s),n=o(3),r=o(2),i=o(9),a=o(12),u=o(123),c=o(0);const d=({thresholdComparator:e,errors:t,onChangeSelectedThresholdComparator:o,onChangeSelectedThreshold:d,customComparators:h,display:j="inline",threshold:b=[],popupPosition:p})=>{const x=null!=h?h:a.builtInComparators,[g,m]=Object(s.useState)(!1),[v,O]=Object(s.useState)(e),[E,I]=Object(s.useState)(x[e].requiredValues),f=n.i18n.translate("xpack.triggersActionsUI.common.expressionItems.threshold.andLabel",{defaultMessage:"AND"});return Object(s.useEffect)((()=>{if(x[v].requiredValues!==E){const e=b.slice(0,x[v].requiredValues);d(e),I(x[v].requiredValues)}}),[v]),Object(c.jsx)(r.EuiPopover,{button:Object(c.jsx)(r.EuiExpression,{"data-test-subj":"thresholdPopover",description:x[v].text,value:(b||[]).slice(0,E).join(` ${f} `),isActive:Boolean(g||t.threshold0&&t.threshold0.length||t.threshold1&&t.threshold1.length),onClick:()=>{m(!0)},display:"inline"===j?"inline":"columns",isInvalid:!!(t.threshold0&&t.threshold0.length||(t.threshold1&&t.threshold1.length)>0)}),isOpen:g,closePopover:()=>{m(!1)},ownFocus:!0,display:"fullWidth"===j?"block":"inline-block",anchorPosition:null!=p?p:"downLeft",repositionOnScroll:!0},Object(c.jsx)("div",null,Object(c.jsx)(u.a,{onClose:()=>m(!1)},Object(c.jsx)(l.a.Fragment,null,x[v].text)),Object(c.jsx)(r.EuiFlexGroup,null,Object(c.jsx)(r.EuiFlexItem,{grow:!1},Object(c.jsx)(r.EuiSelect,{"data-test-subj":"comparatorOptionsComboBox",value:v,onChange:e=>{O(e.target.value),o(e.target.value)},options:Object.values(x).map((({text:e,value:t})=>({text:e,value:t})))})),Array.from(Array(E)).map(((e,o)=>{var l,n;return Object(c.jsx)(s.Fragment,{key:`threshold${o}`},o>0?Object(c.jsx)(r.EuiFlexItem,{grow:!1,className:"watcherThresholdWatchInBetweenComparatorText"},Object(c.jsx)(r.EuiText,null,f)):null,Object(c.jsx)(r.EuiFlexItem,{grow:!1},Object(c.jsx)(r.EuiFormRow,{isInvalid:(null===(l=t[`threshold${o}`])||void 0===l?void 0:l.length)>0||Object(i.isNil)(b[o]),error:t[`threshold${o}`]},Object(c.jsx)(r.EuiFieldNumber,{"data-test-subj":"alertThresholdInput",min:0,value:b&&void 0!==b[o]?b[o]:"",isInvalid:(null===(n=t[`threshold${o}`])||void 0===n?void 0:n.length)>0||Object(i.isNil)(b[o]),onChange:e=>{const{value:t}=e.target,s=""!==t?parseFloat(t):void 0,l=[...b];void 0!==s?l[o]=s:delete l[o],d(l)}}))))})))))}}}]);