/*! 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([[15,37,55],{112:function(e,t,n){"use strict";function r(e){return e}function u(e){throw new Error("Called `absurd` function which should be uncallable")}Object.defineProperty(t,"__esModule",{value:!0}),t.bindTo_=t.bind_=t.hole=t.pipe=t.untupled=t.tupled=t.absurd=t.decrement=t.increment=t.tuple=t.flow=t.flip=t.constVoid=t.constUndefined=t.constNull=t.constFalse=t.constTrue=t.constant=t.not=t.unsafeCoerce=t.identity=void 0,t.identity=r,t.unsafeCoerce=r,t.not=function(e){return function(t){return!e(t)}},t.constant=function(e){return function(){return e}},t.constTrue=function(){return!0},t.constFalse=function(){return!1},t.constNull=function(){return null},t.constUndefined=function(){},t.constVoid=function(){},t.flip=function(e){return function(t,n){return e(n,t)}},t.flow=function(e,t,n,r,u,i,c,o,a){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return u(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return i(u(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return c(i(u(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return o(c(i(u(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return a(o(c(i(u(r(n(t(e.apply(this,arguments)))))))))}}},t.tuple=function(){for(var e=[],t=0;t{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.show},u=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.save},i=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.execute},c=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.delete};function o(e,t){var n,r;return null!==(n=null==t||null===(r=t.authorizedConsumers[e])||void 0===r?void 0:r.all)&&void 0!==n&&n}const a=e=>{var t,n;return null==e||null===(t=e.management)||void 0===t||null===(n=t.security)||void 0===n?void 0:n.api_keys}},115:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pipeable=t.pipe=void 0;var r=n(112);t.pipe=r.pipe;t.pipeable=function(e){var t={};return function(e){return"function"==typeof e.map}(e)&&(t.map=function(t){return function(n){return e.map(n,t)}}),function(e){return"function"==typeof e.contramap}(e)&&(t.contramap=function(t){return function(n){return e.contramap(n,t)}}),function(e){return"function"==typeof e.mapWithIndex}(e)&&(t.mapWithIndex=function(t){return function(n){return e.mapWithIndex(n,t)}}),function(e){return"function"==typeof e.ap}(e)&&(t.ap=function(t){return function(n){return e.ap(n,t)}},t.apFirst=function(t){return function(n){return e.ap(e.map(n,(function(e){return function(){return e}})),t)}},t.apSecond=function(t){return function(n){return e.ap(e.map(n,(function(){return function(e){return e}})),t)}}),function(e){return"function"==typeof e.chain}(e)&&(t.chain=function(t){return function(n){return e.chain(n,t)}},t.chainFirst=function(t){return function(n){return e.chain(n,(function(n){return e.map(t(n),(function(){return n}))}))}},t.flatten=function(t){return e.chain(t,r.identity)}),function(e){return"function"==typeof e.bimap}(e)&&(t.bimap=function(t,n){return function(r){return e.bimap(r,t,n)}},t.mapLeft=function(t){return function(n){return e.mapLeft(n,t)}}),function(e){return"function"==typeof e.extend}(e)&&(t.extend=function(t){return function(n){return e.extend(n,t)}},t.duplicate=function(t){return e.extend(t,r.identity)}),function(e){return"function"==typeof e.reduce}(e)&&(t.reduce=function(t,n){return function(r){return e.reduce(r,t,n)}},t.foldMap=function(t){var n=e.foldMap(t);return function(e){return function(t){return n(t,e)}}},t.reduceRight=function(t,n){return function(r){return e.reduceRight(r,t,n)}}),function(e){return"function"==typeof e.reduceWithIndex}(e)&&(t.reduceWithIndex=function(t,n){return function(r){return e.reduceWithIndex(r,t,n)}},t.foldMapWithIndex=function(t){var n=e.foldMapWithIndex(t);return function(e){return function(t){return n(t,e)}}},t.reduceRightWithIndex=function(t,n){return function(r){return e.reduceRightWithIndex(r,t,n)}}),function(e){return"function"==typeof e.alt}(e)&&(t.alt=function(t){return function(n){return e.alt(n,t)}}),function(e){return"function"==typeof e.compact}(e)&&(t.compact=e.compact,t.separate=e.separate),function(e){return"function"==typeof e.filter}(e)&&(t.filter=function(t){return function(n){return e.filter(n,t)}},t.filterMap=function(t){return function(n){return e.filterMap(n,t)}},t.partition=function(t){return function(n){return e.partition(n,t)}},t.partitionMap=function(t){return function(n){return e.partitionMap(n,t)}}),function(e){return"function"==typeof e.filterWithIndex}(e)&&(t.filterWithIndex=function(t){return function(n){return e.filterWithIndex(n,t)}},t.filterMapWithIndex=function(t){return function(n){return e.filterMapWithIndex(n,t)}},t.partitionWithIndex=function(t){return function(n){return e.partitionWithIndex(n,t)}},t.partitionMapWithIndex=function(t){return function(n){return e.partitionMapWithIndex(n,t)}}),function(e){return"function"==typeof e.promap}(e)&&(t.promap=function(t,n){return function(r){return e.promap(r,t,n)}}),function(e){return"function"==typeof e.compose}(e)&&(t.compose=function(t){return function(n){return e.compose(n,t)}}),function(e){return"function"==typeof e.throwError}(e)&&(t.fromOption=function(t){return function(n){return"None"===n._tag?e.throwError(t()):e.of(n.value)}},t.fromEither=function(t){return"Left"===t._tag?e.throwError(t.left):e.of(t.right)},t.fromPredicate=function(t,n){return function(r){return t(r)?e.of(r):e.throwError(n(r))}},t.filterOrElse=function(t,n){return function(r){return e.chain(r,(function(r){return t(r)?e.of(r):e.throwError(n(r))}))}}),t}},122:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(5);const u=({decryption_health:e,execution_health:t,read_health:n,...r})=>({decryptionHealth:e,executionHealth:t,readHealth:n,...r}),i=({is_sufficiently_secure:e,has_permanent_encryption_key:t,alerting_framework_health:n,...r})=>({isSufficientlySecure:e,hasPermanentEncryptionKey:t,alertingFrameworkHealth:n,...r});async function c({http:e}){const t=await e.get(`${r.b}/_health`),n=u(t.alerting_framework_health);return{...i(t),alertingFrameworkHealth:n}}},127:function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var r=n(26);async function u({http:e}){return await e.get(`${r.a}/_config`)}},156:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(9),u=n(3);const i=e=>({isEnabled:!1,message:u.i18n.translate("xpack.triggersActionsUI.checkRuleTypeEnabled.ruleTypeDisabledByLicenseMessage",{defaultMessage:"This rule type requires a {minimumLicenseRequired} license.",values:{minimumLicenseRequired:Object(r.upperFirst)(e.minimumLicenseRequired)}})});function c(e){return!1===(null==e?void 0:e.enabledInLicense)?i(e):{isEnabled:!0}}},74:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return M}));var r=n(1),u=n.n(r),i=n(25),c=n(2),o=n(3),a=n(9),s=n(17),l=n(164),f=n(157),d=n(136),p=n(5),m=n(32);const h=({ruleTypeId:e,actions:t,...n})=>({...n,rule_type_id:e,actions:t.map((({group:e,id:t,params:n,frequency:r,alertsFilter:u})=>({group:e,id:t,params:n,frequency:{notify_when:r.notifyWhen,throttle:r.throttle,summary:r.summary},alerts_filter:u})))});var y=n(51),b=n(140),j=n(0);const g=({onConfirm:e,onCancel:t})=>Object(j.jsx)(c.EuiConfirmModal,{title:o.i18n.translate("xpack.triggersActionsUI.sections.confirmRuleSave.confirmRuleSaveTitle",{defaultMessage:"Save rule with no actions?"}),onCancel:t,onConfirm:e,confirmButtonText:o.i18n.translate("xpack.triggersActionsUI.sections.confirmRuleSave.confirmRuleSaveConfirmButtonText",{defaultMessage:"Save rule"}),cancelButtonText:o.i18n.translate("xpack.triggersActionsUI.sections.confirmRuleSave.confirmRuleSaveCancelButtonText",{defaultMessage:"Cancel"}),defaultFocusedButton:"confirm","data-test-subj":"confirmRuleSaveModal"},Object(j.jsx)("p",null,Object(j.jsx)(i.FormattedMessage,{id:"xpack.triggersActionsUI.sections.confirmRuleSave.confirmRuleSaveWithoutActionsMessage",defaultMessage:"You can add an action at anytime."})));var v=n(158),x=n(113),O=n(124);const I=({isSaving:e,onSave:t,onCancel:n,isFormLoading:r})=>{const{loadingHealthCheck:a}=Object(O.b)();return Object(j.jsx)(c.EuiFlyoutFooter,null,Object(j.jsx)(c.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(j.jsx)(c.EuiFlexItem,{grow:!1},Object(j.jsx)(c.EuiButtonEmpty,{"data-test-subj":"cancelSaveRuleButton",onClick:n},o.i18n.translate("xpack.triggersActionsUI.sections.ruleAddFooter.cancelButtonLabel",{defaultMessage:"Cancel"}))),r?Object(j.jsx)(c.EuiFlexItem,{grow:!1},Object(j.jsx)(c.EuiSpacer,{size:"s"}),Object(j.jsx)(c.EuiLoadingSpinner,{size:"l"})):Object(j.jsx)(u.a.Fragment,null),Object(j.jsx)(c.EuiFlexItem,{grow:!1},Object(j.jsx)(c.EuiButton,{fill:!0,color:"success","data-test-subj":"saveRuleButton",type:"submit",iconType:"check",isDisabled:a,isLoading:e,onClick:t},Object(j.jsx)(i.FormattedMessage,{id:"xpack.triggersActionsUI.sections.ruleAddFooter.saveButtonLabel",defaultMessage:"Save"})))))};var E=n(29),S=n(159),w=n(54),T=n(127),C=n(178);const M=({consumer:e,ruleTypeRegistry:t,actionTypeRegistry:n,onClose:u,canChangeTrigger:M,ruleTypeId:_,initialValues:F,reloadRules:R,onSave:k,hideInterval:A,metadata:W,filteredRuleTypes:B,...L})=>{var U;const N=null!=k?k:R,[D,H]=Object(r.useState)(W),P=Object(r.useCallback)((e=>H(e)),[]),q=Object(r.useMemo)((()=>({params:{},consumer:e,ruleTypeId:_,schedule:{interval:p.e},actions:[],tags:[],...F||{}})),[_,e,F]),[{rule:z},V]=Object(r.useReducer)(d.a,{rule:q}),[$,G]=Object(r.useState)({isUsingSecurity:!1}),[J,K]=Object(r.useState)({}),[Y,Q]=Object(r.useState)(!1),[X,Z]=Object(r.useState)(!1),[ee,te]=Object(r.useState)(!1),[ne,re]=Object(r.useState)(L.ruleTypeIndex),[ue,ie]=Object(r.useState)(!1),ce=(e,t)=>{V({command:{type:"setProperty"},payload:{key:e,value:t}})},{http:oe,notifications:{toasts:ae},application:{capabilities:se}}=Object(E.b)().services,le=Object(x.f)(se);Object(r.useEffect)((()=>{(async()=>{G(await Object(T.a)({http:oe}))})()}),[oe]),Object(r.useEffect)((()=>{_&&ce("ruleTypeId",_)}),[_]),Object(r.useEffect)((()=>{L.ruleTypeIndex||(async()=>{const e=await Object(y.a)({http:oe}),t=new Map;for(const n of e)t.set(n.id,n);re(t)})()}),[L.ruleTypeIndex,oe]),Object(r.useEffect)((()=>{Object(a.isEmpty)(z.params)&&!Object(a.isEmpty)(J)?K({}):Object(a.isEmpty)(J)&&K(z.params)}),[z.params,J]);const[fe,de]=Object(r.useState)([]),[pe,me]=Object(r.useState)(!1);Object(r.useEffect)((()=>{(async()=>{me(!0);const e=await Object(f.a)(z.actions,n);me(!1),de([...e])})()}),[z.actions,n]),Object(r.useEffect)((()=>{var e;!$.minimumScheduleInterval||null!=F&&null!==(e=F.schedule)&&void 0!==e&&e.interval||ce("schedule",{interval:Object(C.a)($.minimumScheduleInterval.value)})}),[$.minimumScheduleInterval,F]),Object(r.useEffect)((()=>{if(z.ruleTypeId&&ne){const e=ne.get(z.ruleTypeId);null!=e&&e.defaultScheduleInterval&&!ue&&ce("schedule",{interval:e.defaultScheduleInterval})}}),[z.ruleTypeId,ne,z.schedule.interval,ue]),Object(r.useEffect)((()=>{z.schedule.interval===p.e||ue||ie(!0)}),[z.schedule.interval,ue]);const he=()=>{Object(S.a)(z,q,!1)||Object(S.b)(z.params,J)?te(!0):u(s.m.CANCELED,D)},ye=async()=>{const e=await async function(){try{const e=await async function({http:e,rule:t}){const n=await e.post(`${p.b}/rule`,{body:JSON.stringify(h(t))});return Object(m.b)(n)}({http:oe,rule:z});return ae.addSuccess(o.i18n.translate("xpack.triggersActionsUI.sections.ruleAdd.saveSuccessNotificationText",{defaultMessage:'Created rule "{ruleName}"',values:{ruleName:e.name}})),e}catch(n){var e,t;ae.addDanger(null!==(e=null===(t=n.body)||void 0===t?void 0:t.message)&&void 0!==e?e:o.i18n.translate("xpack.triggersActionsUI.sections.ruleAdd.saveErrorNotificationText",{defaultMessage:"Cannot create rule."}))}}();Q(!1),e&&(u(s.m.SAVED,D),N&&N(D))},be=z.ruleTypeId?t.get(z.ruleTypeId):null,{ruleBaseErrors:je,ruleErrors:ge,ruleParamsErrors:ve}=Object(r.useMemo)((()=>Object(f.b)(z,be,$)),[z,be,$]),xe=le&&0===(null===(U=z.actions)||void 0===U?void 0:U.length);return Object(j.jsx)(c.EuiPortal,null,Object(j.jsx)(c.EuiFlyout,{onClose:he,"aria-labelledby":"flyoutRuleAddTitle",size:"m",maxWidth:620,ownFocus:!0},Object(j.jsx)(c.EuiFlyoutHeader,{hasBorder:!0},Object(j.jsx)(c.EuiTitle,{size:"s","data-test-subj":"addRuleFlyoutTitle"},Object(j.jsx)("h3",{id:"flyoutTitle"},Object(j.jsx)(i.FormattedMessage,{defaultMessage:"Create rule",id:"xpack.triggersActionsUI.sections.ruleAdd.flyoutTitle"})))),Object(j.jsx)(O.a,null,Object(j.jsx)(b.a,{inFlyout:!0,waitForCheck:!0},Object(j.jsx)(c.EuiFlyoutBody,null,Object(j.jsx)(l.a,{rule:z,config:$,dispatch:V,errors:ge,canChangeTrigger:M,operation:o.i18n.translate("xpack.triggersActionsUI.sections.ruleAdd.operationName",{defaultMessage:"create"}),actionTypeRegistry:n,ruleTypeRegistry:t,metadata:D,filteredRuleTypes:B,hideInterval:A,onChangeMetaData:P})),Object(j.jsx)(I,{isSaving:Y,isFormLoading:pe,onSave:async()=>{if(Q(!0),pe||!Object(f.c)(z,ge,fe))return e=Object(w.a)(z,ve,je,fe),V({command:{type:"setRule"},payload:{key:"rule",value:e}}),void Q(!1);var e;xe?Z(!0):await ye()},onCancel:he}))),X&&Object(j.jsx)(g,{onConfirm:async()=>{Z(!1),await ye()},onCancel:()=>{Q(!1),Z(!1)}}),ee&&Object(j.jsx)(v.a,{onConfirm:()=>{te(!1),u(s.m.CANCELED,D)},onCancel:()=>{te(!1)}})))}}}]);