/*! 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([[17],{113:function(e,t,n){"use strict";n.d(t,"f",(function(){return i})),n.d(t,"e",(function(){return s})),n.d(t,"c",(function(){return r})),n.d(t,"b",(function(){return l})),n.d(t,"a",(function(){return o})),n.d(t,"d",(function(){return a}));const i=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.show},s=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.save},r=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.execute},l=e=>{var t;return null==e||null===(t=e.actions)||void 0===t?void 0:t.delete};function o(e,t){var n,i;return null!==(n=null==t||null===(i=t.authorizedConsumers[e])||void 0===i?void 0:i.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}},121:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(3);const s={label:i.i18n.translate("xpack.triggersActionsUI.technicalPreviewBadgeLabel",{defaultMessage:"Technical preview"}),tooltipContent:i.i18n.translate("xpack.triggersActionsUI.technicalPreviewBadgeDescription",{defaultMessage:"This functionality is in technical preview and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but features in technical preview are not subject to the support SLA of official GA features."})}},152:function(e,t,n){"use strict";n.d(t,"a",(function(){return T}));var i=n(1),s=n.n(i),r=n(9),l=n(15),o=n(2),a=n(25),c=n(52),u=n(113),d=n(29),b=n(62),j=n(37),p=n(3),g=n(0);const{emptyField:m}=b.fieldValidators,f={label:"Connector name",validations:[{validator:m(p.i18n.translate("xpack.triggersActionsUI.sections.actionConnectorForm.error.requiredNameText",{defaultMessage:"Name is required."}))}]},h=({canSave:e})=>Object(g.jsx)(s.a.Fragment,null,Object(g.jsx)(l.UseField,{path:"id",component:j.HiddenField}),Object(g.jsx)(l.UseField,{path:"actionTypeId",component:j.HiddenField}),Object(g.jsx)(l.UseField,{path:"isDeprecated",component:j.HiddenField}),Object(g.jsx)(l.UseField,{path:"name",config:f,component:j.Field,componentProps:{euiFieldProps:{readOnly:!e,"data-test-subj":"nameInput",fullWidth:!0}}})),v=Object(i.memo)(h),O=({actionTypeModel:e,isEdit:t,registerPreSubmitValidator:n})=>{var r;const{application:{capabilities:l}}=Object(d.b)().services,b=Object(u.e)(l),j=null!==(r=null==e?void 0:e.actionConnectorFields)&&void 0!==r?r:null;return Object(g.jsx)(s.a.Fragment,null,Object(g.jsx)(v,{canSave:b}),Object(g.jsx)(o.EuiSpacer,{size:"m"}),null!==j?Object(g.jsx)(s.a.Fragment,null,Object(g.jsx)(o.EuiTitle,{size:"xxs","data-test-subj":"connector-settings-label"},Object(g.jsx)("h4",null,Object(g.jsx)(a.FormattedMessage,{id:"xpack.triggersActionsUI.sections.actionConnectorForm.connectorSettingsLabel",defaultMessage:"Connector settings"}))),Object(g.jsx)(o.EuiSpacer,{size:"s"}),Object(g.jsx)(o.EuiErrorBoundary,null,Object(g.jsx)(i.Suspense,{fallback:Object(g.jsx)(c.a,null,Object(g.jsx)(a.FormattedMessage,{id:"xpack.triggersActionsUI.sections.actionConnectorForm.loadingConnectorSettingsDescription",defaultMessage:"Loading connector settings…"}))},Object(g.jsx)(j,{readOnly:!b,isEdit:t,registerPreSubmitValidator:n})))):null)},F=Object(i.memo)(O),x=({title:e,dataTestSubj:t})=>Object(g.jsx)(s.a.Fragment,null,Object(g.jsx)(o.EuiSpacer,{size:"s"}),Object(g.jsx)(o.EuiCallOut,{size:"s",iconType:"iInCircle","data-test-subj":t,title:e}),Object(g.jsx)(o.EuiSpacer,{size:"m"})),y=e=>null!=e||!y(e),S=({isEdit:e,isMissingSecrets:t})=>{const[n]=Object(l.useFormData)(),{getFields:i}=Object(l.useFormContext)(),s=i(),r=(o=s,Object.keys(o).filter((e=>e.includes("secrets"))).reduce(((e,t)=>({...e,[t]:o[t]})),{}));var o;const a=Object.keys(r).length,c=(e=>{if(0===e.length)return"";if(1===e.length)return`${e[0]}`;if(2===e.length)return e.join(" and ");const t=e[e.length-1];return`${e.slice(0,-1).join(", ")}, and ${t}`})((e=>Object.keys(e).map((t=>e[t].label)).filter(y))(r));return 0===Object.keys(r).length?null:t?Object(g.jsx)(x,{title:p.i18n.translate("xpack.triggersActionsUI.components.builtinActionTypes.missingSecretsValuesLabel",{values:{secretFieldsLabel:c,encryptedFieldsLength:a},defaultMessage:"Sensitive information is not imported. Please enter value{encryptedFieldsLength, plural, one {} other {s}} for the following field{encryptedFieldsLength, plural, one {} other {s}} {secretFieldsLabel}."}),dataTestSubj:"missing-secrets-callout"}):e?e?Object(g.jsx)(x,{title:p.i18n.translate("xpack.triggersActionsUI.components.simpleConnectorForm.secrets.reenterValuesMessage",{values:{secretFieldsLabel:c,encryptedFieldsLength:a},defaultMessage:"Value{encryptedFieldsLength, plural, one {} other {s}} {secretFieldsLabel} {encryptedFieldsLength, plural, one {is} other {are}} encrypted. Please reenter value{encryptedFieldsLength, plural, one {} other {s}} for {encryptedFieldsLength, plural, one {this} other {these}} field{encryptedFieldsLength, plural, one {} other {s}}."}),dataTestSubj:"edit-connector-secrets-callout"}):null:Object(g.jsx)(x,{title:p.i18n.translate("xpack.triggersActionsUI.components.simpleConnectorForm.secrets.reenterValuesLabel",{values:{secretFieldsLabel:c,encryptedFieldsLength:a},defaultMessage:"Remember your {secretFieldsLabel} {encryptedFieldsLength, plural, one {value} other {values}}. You must reenter {encryptedFieldsLength, plural, one {it} other {them}} each time you edit the connector."}),dataTestSubj:"create-connector-secrets-callout"})},L=Object(i.memo)(S),k=e=>{var t,n;if(".webhook"!==e.actionTypeId&&".cases-webhook"!==e.actionTypeId)return e;const i=e,s=Object.entries(null!==(t=null==i||null===(n=i.config)||void 0===n?void 0:n.headers)&&void 0!==t?t:{}).map((([e,t])=>({key:e,value:t})));return{...e,config:{...e.config,headers:Object(r.isEmpty)(s)?void 0:s}}},E=e=>{var t,n;if(".webhook"!==e.actionTypeId&&".cases-webhook"!==e.actionTypeId)return e;const i=(null!==(t=null==e||null===(n=e.config)||void 0===n?void 0:n.headers)&&void 0!==t?t:[]).reduce(((e,t)=>({...e,[t.key]:t.value})),{});return{...e,config:{...e.config,headers:Object(r.isEmpty)(i)?null:i}}},M=({actionTypeModel:e,connector:t,isEdit:n,onChange:s,onFormModifiedChange:r,setResetForm:a})=>{const{form:c}=Object(l.useForm)({defaultValue:t,serializer:E,deserializer:k}),{submit:u,isValid:d,isSubmitted:b,isSubmitting:j,reset:p}=c,[m,f]=Object(i.useState)(null),h=Object(i.useCallback)((e=>{f((()=>e))}),[]),v=Object(l.useFormIsModified)({form:c,discard:["__internal__"]});return Object(i.useEffect)((()=>{s&&s({isValid:d,isSubmitted:b,isSubmitting:j,submit:u,preSubmitValidator:m})}),[s,d,b,j,u,m]),Object(i.useEffect)((()=>{r&&r(v)}),[v,r]),Object(i.useEffect)((()=>{a&&a(p)}),[p]),Object(g.jsx)(l.Form,{form:c},Object(g.jsx)(F,{actionTypeModel:e,isEdit:n,registerPreSubmitValidator:h}),Object(g.jsx)(o.EuiSpacer,{size:"m"}),Object(g.jsx)(L,{isEdit:n,isMissingSecrets:t.isMissingSecrets}))},T=s.a.memo(M)}}]);