@planningcenter/core-automations 1.9.1 → 1.9.2-qa-348.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core-automations.esm.js +1 -1
- package/dist/cjs/core-automations.esm.js.map +1 -1
- package/dist/cjs/core-automations.js +1 -1
- package/dist/cjs/core-automations.js.map +1 -1
- package/dist/cjs/core-automations.modern.mjs +1 -1
- package/dist/cjs/core-automations.modern.mjs.map +1 -1
- package/dist/cjs/core-automations.umd.js +1 -1
- package/dist/cjs/core-automations.umd.js.map +1 -1
- package/dist/types/src/utils/utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("react/jsx-runtime"),t=require("@planningcenter/api-client"),n=require("@planningcenter/tapestry-react"),a=require("react"),i=require("lodash"),o=require("moment"),s=require("@planningcenter/sweetalert2"),r=require("sweetalert2/dist/sweetalert2"),l=require("@planningcenter/icons/paths/church-center"),c=require("@planningcenter/icons/paths/logomark"),d=require("@planningcenter/icons/paths/services"),u=require("react-dom");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function m(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var h=/*#__PURE__*/p(a),g=/*#__PURE__*/p(o),w=/*#__PURE__*/p(r),f=/*#__PURE__*/m(l),x=/*#__PURE__*/m(c),b=/*#__PURE__*/m(d);const v=()=>e.jsxs("svg",{id:"automations_blank","data-name":"Automations Blank",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 111.112 84.832",className:"symbol",children:[e.jsx("title",{children:"people-automations"}),e.jsx("g",{opacity:"0.6",children:e.jsx("path",{d:"M107.784,46.051A57.416,57.416,0,0,1,85.26,75.058c-9.7,6.247-20.045,7.792-31.912,5.185-11.74-2.638-23.339-8-32.92-13.088-9.51-5.342-17-10.236-18.863-17.925C-.26,41.753,3.737,31.4,13.347,21.194,22.85,11.162,37.968,1.853,55.948.321,73.8-1.476,90.2,4.478,99.608,13.164,109.257,21.9,111.921,33.784,107.784,46.051Z",fill:"#e1f0f9"})}),e.jsxs("g",{opacity:"0.2",children:[e.jsx("path",{d:"M63.086,84.317A43.515,43.515,0,0,1,42.87,79C34.056,74.379,24.712,67.422,14.3,57.728,6.616,50.227.284,43.348.489,35c.13-5.851,3.789-12.312,10.3-18.189l.951,1.054c-6.222,5.613-9.715,11.71-9.837,17.169C1.717,42.811,7.85,49.448,15.278,56.7c10.307,9.6,19.551,16.481,28.248,21.039,9.043,4.684,17.715,6.156,26.513,4.5l.262,1.4A38.914,38.914,0,0,1,63.086,84.317Z",fill:"#bac7d3"}),e.jsx("path",{d:"M81.105,80.147l-.587-1.292a56.6,56.6,0,0,0,23.515-19.828l1.183.786A58.03,58.03,0,0,1,81.105,80.147Z",fill:"#bac7d3"}),e.jsx("path",{d:"M110.025,49.27l-1.374-.356a28.351,28.351,0,0,0-4.014-22.991C97.189,14.135,82.488,5.177,66.267,2.538A66.6,66.6,0,0,0,25.738,8.55l-.622-1.275a68,68,0,0,1,41.39-6.136c16.6,2.7,31.672,11.905,39.327,24.019A29.732,29.732,0,0,1,110.025,49.27Z",fill:"#bac7d3"})]}),e.jsx("path",{d:"M81,27.269v31.8a2.685,2.685,0,0,1-2.685,2.685H44.564a2.685,2.685,0,0,1-2.685-2.685V15.425a2.685,2.685,0,0,1,2.685-2.685h21.91a2.681,2.681,0,0,1,1.9.786L80.217,25.371A2.685,2.685,0,0,1,81,27.269Z",fill:"#fff"}),e.jsx("path",{d:"M68.479,13.633v9.8a2.035,2.035,0,0,0,2.035,2.034h9.877Z",fill:"#c9d8e2"}),e.jsx("rect",{x:"51.214",y:"41.285",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"48.434",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"34.136",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"11.771",y:"44.005",width:"50.915",height:"6.664",transform:"translate(-22.93 44.557) rotate(-49.171)",fill:"#454942"}),e.jsx("path",{d:"M56.283,30.38l-7.557,8.745a5.968,5.968,0,0,0-2.005-2.734,6.292,6.292,0,0,0-3.036-1.624l7.555-8.743a6.275,6.275,0,0,1,3.038,1.624A5.959,5.959,0,0,1,56.283,30.38Z",fill:"#fcc846"}),e.jsx("path",{d:"M58.088,28.29l-7.556,8.745a5.968,5.968,0,0,0-2-2.734,6.3,6.3,0,0,0-3.036-1.624l7.555-8.743a6.274,6.274,0,0,1,3.037,1.624A5.959,5.959,0,0,1,58.088,28.29Z",fill:"#48a5e5"}),e.jsx("path",{d:"M58.724,10.432l1.17,2.7a2.129,2.129,0,0,0,1.4,1.207l2.843.765a.73.73,0,0,1,.1,1.375l-2.7,1.17a2.125,2.125,0,0,0-1.207,1.4L59.56,21.89a.73.73,0,0,1-1.374.1l-1.17-2.7a2.125,2.125,0,0,0-1.4-1.206l-2.843-.766a.73.73,0,0,1-.1-1.374l2.7-1.17a2.121,2.121,0,0,0,1.206-1.4l.766-2.844A.73.73,0,0,1,58.724,10.432Z",fill:"#fcc846"}),e.jsx("path",{d:"M44.544,19.294l1.024.868a.968.968,0,0,0,.814.21l1.316-.261a.333.333,0,0,1,.319.541l-.868,1.024a.968.968,0,0,0-.21.814l.261,1.316a.333.333,0,0,1-.541.319l-1.024-.868a.968.968,0,0,0-.814-.21l-1.316.261a.333.333,0,0,1-.319-.541l.868-1.024a.967.967,0,0,0,.21-.814L44,19.613A.333.333,0,0,1,44.544,19.294Z",fill:"#fcc846"}),e.jsx("path",{d:"M64.223,25.729l.869,2.005a1.575,1.575,0,0,0,1.036.895l2.109.568a.542.542,0,0,1,.075,1.02l-2,.868a1.576,1.576,0,0,0-.9,1.036l-.568,2.11a.541.541,0,0,1-1.019.074L62.955,32.3a1.572,1.572,0,0,0-1.036-.895l-2.109-.568a.542.542,0,0,1-.075-1.02l2.005-.868a1.572,1.572,0,0,0,.895-1.036L63.2,25.8A.541.541,0,0,1,64.223,25.729Z",fill:"#fcc846"})]}),j=/*#__PURE__*/a.createContext({dateFormat:null,olsonTimeZone:null,twentyFourHourTime:null});w.default.mixin(s.standardAlertOptions),w.default.mixin(s.successAlertOptions);const y=w.default.mixin(s.errorAlertOptions),k=w.default.mixin(s.standardConfirmOptions),C=w.default.mixin(s.destroyConfirmOptions),S=w.default.mixin(s.createConfirmOptions),z={churchCenter:f,logomark:x,services:b},_={givingBrand31:"hsl(36, 100%, 31%)",neutral12:"hsl(0, 0%, 12%)",neutral24:"hsl(0, 0%, 24%)",neutral45:"hsl(0, 0%, 45%)",neutral62:"hsl(0, 0%, 62%)",neutral68:"hsl(0, 0%, 68%)",neutral88:"hsl(0, 0%, 88%)",neutral98:"hsl(0, 0%, 98%)",statusCreate23:"hsl(86, 91%, 23%)",statusCreate27:"hsl(86, 91%, 27%)",statusCreate35:"hsl(86, 91%, 35%)",statusDelete43:"hsl(9, 61%, 43%)",statusDelete47:"hsl(8, 60%, 47%)",statusWarning49:"hsl(42, 84%, 49%)",statusWarning63:"hsl(42, 84%, 63%)",statusWarning94:"hsl(42, 87%, 94%)"},P=function(e){try{return Promise.all(e.map(function(e){try{const t=function(){if(function(e){return["AddToWorkflowOperationDefinition","CustomFieldBooleanOperationDefinition","CustomFieldCheckboxesOperationDefinition","CustomFieldDateOperationDefinition","CustomFieldNumberOperationDefinition","CustomFieldSelectOperationDefinition","CustomFieldStringOperationDefinition","CustomFieldTextOperationDefinition"].includes(e.operationDefinitionClassName)}(e))return Promise.resolve(function(e){try{function t(){return n||e.description}let n="";const a=function(){if("AddToWorkflowOperationDefinition"===e.operationDefinitionClassName)return Promise.resolve(function(e){try{return Promise.resolve(O.get({data:{fields:{Workflow:"name,archived_at"},filter:"archived,active",where:{id:e}},url:"workflows"}).catch(()=>[{data:{name:""}}])).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(e.operationParams.workflowId)).then(function(t){const a=t[0];if(a?.name){let t;t=a.archivedAt?`[archived] ${a.name}`:a.name,n=e.description.replace("[Hidden Workflow]",t)}});{const t=e.operationParams.definitionIdentifier.match(/(\d+)_field_definition/)[1];return Promise.resolve(function(e){try{return Promise.resolve(O.get({data:{fields:{FieldDefinition:"name,data_type,field_options",FieldOption:"value"},include:"field_options"},url:`field_definitions/${e}`}).catch(()=>({data:{name:""}}))).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(t)).then(function(t){t.name&&(n=e.description.replace("[Hidden Custom Field]",t.name),n+=e.operationParams.values||"checkboxes"!==t.dataType?` (${function(e,t){switch(t.dataType){case"checkboxes":return Object.entries(e.operationParams.values).map(([e,n])=>{const a=t.fieldOptions.find(t=>t.id===parseInt(e,10))?.value||"[Hidden value]";return`${T(n)} ${a}`}).join(", ");case"select":return e.operationParams.value?t.fieldOptions.find(t=>t.id===parseInt(e.operationParams.value.toString(),10))?.value||"[Hidden value]":"Unanswered";case"boolean":switch(e.operationParams.value){case"true":return"Yes";case"false":return"No";default:return"Unanswered"}default:return e.operationParams.value??"Unanswered"}}(e,t)})`:"")})}}();return Promise.resolve(a&&a.then?a.then(t):t())}catch(i){return Promise.reject(i)}}(e)).then(function(t){e.description=t})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function T(e){return e.charAt(0).toUpperCase()+e.slice(1)}const O=new t.Client({app:"people",version:"2022-07-14"});function A(e){return e.listClass?`${e.id}_${e.listClass}`:"PersonSearch"===e.kind?`${e.id}_PersonSearch`:null}function I(e){if(e.definitionClass.match(/^CustomField\w+OperationDefinition$/))return"Update [Hidden Custom Field]"}function F(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $({field:e,loadedLists:t}){if(e.list)return e.list;if(A(e))return t[A(e)];throw new Error(`Don't know how to get list for ${JSON.stringify(e)}`)}function V(e,t){return e.filter(e=>{if(Object.prototype.hasOwnProperty.call(e,"renderIf")){const n=e.renderIf,a=Object.keys(n)[0];return i.isBoolean(n)?n:n[a]===t[a]}return!0})}function L({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n,description:a}){if("AddToWorkflowOperationDefinition"===e.definitionClass){const e=n.workflow_id_WorkflowsList,i=e&&e.find(e=>e.value.toString()===t.workflow_id)?.description;return a.replace(i,"[Hidden Workflow]")}return e.definitionClass.match(/^CustomField\w+OperationDefinition$/)?"":a}({description:e.definitionFields.map(e=>{if(!F(t,e.id))return null;const a=t[e.id];let i;switch(e.kind){case"Select":case"SelectSearch":case"PersonSearch":case"RadioButtons":return i=$({field:e,loadedLists:n}),i&&i.find(e=>e.value.toString()===a)?.description;case"Checkbox":return a&&e.label;case"Checkboxes":return i=$({field:e,loadedLists:n}),i.filter(e=>F(a,e.value)).map(e=>`${T(a[e.value])} ${e.description}`).join(", ");case"NumberField":case"TextField":case"TextArea":case"DateField":return a;default:throw new Error(`Don't know how to build value for field with kind ${e.kind}`)}}).filter(e=>e).join(", "),loadedLists:n,selectedDefinition:e,selectedFieldOptions:t})}function B(e){return e.replace(/%m/,"MM").replace(/%d/,"DD").replace(/%Y/,"YYYY").replace(/%y/,"YY")}function D(e,t){const n=g.default(e,"YYYY-MM-DD");if(!n.isValid())return"";const a=B(t);return n.format(a)}function H(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function W(e){return e.replace(/s$/,"")}function R(e){const t=e.split("/");return{appName:t[0],resourceId:t[t.length-1],resourcePath:t.slice(2,-1).join("/"),resourceType:t[t.length-2]}}const M=function(e){try{const t=e.data.map(e=>X(e));return Promise.resolve(function(n,a){try{var i=Promise.resolve(E(t)).then(function(t){return{events:e,people:t}})}catch(e){return a()}return i&&i.then?i.then(void 0,a):i}(0,function(){return{events:e,people:[]}}))}catch(e){return Promise.reject(e)}},E=function(e){try{return Promise.resolve(Y.get({data:{fields:{Person:"id,name"},where:{id:e.join(",")}},url:"people"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},N=function(e,t,n){try{return Promise.resolve(q.get({data:{_e:e,fields:{Delivery:"status,response_body,created_at",Event:"id,created_at,last_delivery,payload,status,uuid,person"},include:"last_delivery",order:"-created_at",...n},url:`automation_subscriptions/${t}/events`}))}catch(e){return Promise.reject(e)}},q=new t.Client({app:"webhooks",version:"2022-10-20"}),Y=new t.Client({app:"people",version:"2022-07-14"}),U={delivered:{label:"Success",value:["delivered"]},failed:{label:"Failed",value:["failed","duplicated"]},ignored:{label:"Ignored",value:["ignored_duplicated","ignored_failed","ignored_skipped"]},pending:{label:"Pending",value:["pending"]},skipped:{label:"Paused",value:["skipped"]}};function Z({events:e,people:t}){const n=e.data.reduce((e,n)=>{const a=X(n),i=t.find(e=>a.toString()===e.id.toString());return e.push(i?{...n,person:{id:i.id,name:i.name}}:{...n,person:{id:a,name:"[Hidden]"}}),e},[]);return{...e,data:n}}function X(e){return e.personId}function Q({automation:t,triggerResource:i,filterWhere:o,onEventsStatusChange:s}){const{events:r,loading:l,paginationProps:c,refresh:d,params:u,setParams:p}=function(e,t,n){const[i,o]=a.useState(),[s,r]=a.useState(!1),[l,c]=a.useState({}),[d,u]=a.useState(n?{where:{status:n}}:{}),[p,m]=a.useState(),{offset:h,paginationProps:g,resetOffset:w}=function(e,t){const[n,i]=a.useState(0);return{offset:n,paginationProps:{currentPage:Math.floor(n/50)+1,onPageChange:function(e){i(50*(e-1))},totalPages:Math.ceil(t/50)},resetOffset:a.useCallback(()=>{i(0)},[])}}(0,p?.totalCount);a.useEffect(()=>{s||l[h]||(r(!0),N(t,e,{offset:h,per_page:50,...d}).then(M).then(Z).then(e=>{c(t=>({...t,[h]:e.data})),m(e.meta),r(!1)}).catch(x))},[e,t,s,d,h,l]);const f=a.useCallback(()=>{c({}),m(void 0),w()},[w]);function x(e){o(()=>{throw e})}return a.useEffect(()=>{f()},[f,d]),{events:l[h]||[],loading:s,paginationProps:g,params:d,refresh:f,setParams:u}}(t.id,i,o),{dateFormat:m,olsonTimeZone:h,twentyFourHourTime:w}=a.useContext(j),f=u.where&&Object.keys(u.where).length>0,x=function(e){const t=g.default(e,"YYYY-MM-DD");return g.default().diff(t,"days")}(t.createdAt)<=32,b=D(t.createdAt,m),y=x?`Automation history started on ${b}`:"Automation history is saved for 32 days",k=[{cell:t=>e.jsx(K,{status:t.status}),css:{padding:"8px 12px"},header:"Status"},{cell:e=>g.default(e.createdAt).utcOffset(h).format(function({dateFormat:e,twentyFourHourTime:t}){return`${B(e)} ${t?"HH:mm":"h:mm A"}`}({dateFormat:m,twentyFourHourTime:w})),header:"Date and time"},{cell:t=>e.jsx(n.Link,{to:`/people/AC${t.person.id}`,children:t.person.name}),css:{maxWidth:"33%"},header:"Profile"},{cell:t=>e.jsx(ee,{event:t}),css:{flex:1},header:"Message"},{cell:n=>![...U.delivered.value,...U.pending.value].includes(n.status)&&e.jsxs(e.Fragment,{children:[e.jsx(G,{automationId:t.id,event:n,triggerResource:i,onEventsStatusChange:s}),![...U.ignored.value].includes(n.status)&&e.jsx(J,{automationId:t.id,event:n,triggerResource:i,refreshHistory:d,onEventsStatusChange:s})]}),css:{textAlign:"right"},header:"",minWidth:"84px"}];return e.jsxs(n.StackView,{spacing:4,children:[e.jsxs(n.StackView,{spacing:.5,children:[e.jsx(n.Heading,{level:3,size:"16px",color:_.neutral45,weight:500,children:t.description}),e.jsx(n.Text,{color:_.neutral45,size:5,italic:!0,children:y})]}),e.jsxs(n.StackView,{spacing:2,children:[e.jsx(n.Box,{minHeight:7,children:!l&&(r.length||f)&&e.jsxs(n.StackView,{alignItems:"end",axis:"horizontal",distribution:"space-between",spacing:1,children:[e.jsxs(n.StackView,{width:"max-content",children:[e.jsx(n.Input.InputLabel,{fontWeight:500,color:_.neutral24,controls:"select-status",children:"Filter by status"}),e.jsxs(n.Select,{id:"select-status",emptyValue:null,onChange:({selectedValue:e})=>{p({where:e?{status:e}:null})},title:"Status",value:u.where?.status,children:[e.jsx(n.Select.Option,{value:null,children:"All"}),Object.values(U).map(t=>e.jsx(n.Select.Option,{value:t.value.join(","),children:t.label},t.value))]})]}),e.jsx(n.Button,{iconLeft:{name:"general.refresh"},onClick:d,theme:"primary",variant:"outline",width:12,children:"Refresh"})]})}),e.jsx(n.Box,{maxHeight:"70vh",minHeight:36,overflow:"auto",children:e.jsx(n.DataTable,{columns:k,data:r,empty:e.jsxs(n.StackView,{alignment:"center",distribution:"center",minHeight:20,maxWidth:45,spacing:1,marginTop:f?-4:-8,marginBottom:f?4:void 0,children:[e.jsx(n.Box,{css:{svg:{height:15,width:20}},children:e.jsx(v,{})}),e.jsx(n.Heading,{color:_.neutral12,fontWeight:500,level:4,size:2,children:"No history found"}),e.jsxs(n.Text,{fontSize:"16px",textAlign:"center",children:["No events ",f&&"matching your filters"," were triggered for this automation"," ",x?`since ${b}.`:"in the last 32 days."]}),f&&e.jsx(n.Button,{marginTop:1,onClick:()=>p({}),theme:"primary",title:"Clear filters",variant:"outline"})]}),loading:l,loadingTitle:"Loading automation history...",variant:{bodyCell:{alignItems:"start",fontSize:"13px",lineHeight:"20px",padding:"10px 12px"},bodyRow:({rowData:e})=>({backgroundColor:[...U.ignored.value].includes(e.status)?_.neutral98:void 0,minHeight:"36px"}),headerCell:{padding:"8px 12px"},headerRow:{minHeight:"36px"}},...c})})]})]})}function G({automationId:t,event:i,triggerResource:o,onEventsStatusChange:s}){const[r,l]=a.useState(i.status),c=U.pending.value.includes(r)?"Sending":U.delivered.value.includes(r)?"Sent":U.skipped.value.includes(r)?"Run now":"Retry",d=U.delivered.value.includes(r)?{color:_.statusCreate27,name:"general.check"}:void 0;return e.jsx(n.Button,{title:c,onClick:function(){l(U.pending.value.join(",")),q.post({data:{_e:o,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${i.id}/redeliver`}).then(e=>{l(U.delivered.value.join(",")),s(e.meta.eventsStatus)}).catch(()=>{l(U.failed.value.join(",")),y.fire({text:"There was a problem retrying this automation. Please try again in a few moments.",title:"Uh oh!"})})},iconLeft:d,disabled:r!==i.status,variant:"naked",color:U.delivered.value.includes(r)?_.statusCreate27:U.pending.value.includes(r)?_.neutral68:"linkForeground",theme:"primary",size:"xs"})}function J({automationId:t,event:a,triggerResource:i,refreshHistory:o,onEventsStatusChange:s}){return e.jsx(n.Button,{title:"Ignore",onClick:function(){q.post({data:{_e:i,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${a.id}/ignore`}).then(e=>{s(e.meta.eventsStatus)}).then(()=>o()).catch(()=>{y.fire({text:"There was a problem ignoring this event. Please try again in a few moments.",title:"Uh oh!"})})},variant:"naked",color:"linkForeground",theme:"primary",size:"xs"})}function K({status:t}){const a=U.pending.value.includes(t)?{border:_.neutral62,text:_.neutral24}:U.delivered.value.includes(t)?{border:_.statusCreate35,text:_.statusCreate23}:U.skipped.value.includes(t)?{border:_.statusWarning63,text:_.givingBrand31}:U.ignored.value.includes(t)?{border:_.neutral68,text:_.neutral45}:{border:_.statusDelete47,text:_.statusDelete43},i=U.pending.value.includes(t)?"general.clock":U.skipped.value.includes(t)?"services.pause":U.delivered.value.includes(t)?"general.checkCircle":U.ignored.value.includes(t)?"general.inactive":"general.exclamationTriangle",o=U.failed.value.includes(t)?U.failed.label:U.ignored.value.includes(t)?U.ignored.label:U[t].label;return e.jsx(n.Badge,{color:{background:"transparent",foreground:a.text},css:{paddingLeft:3.5,paddingRight:1.5},fontSize:"12px",radius:"pill",renderLeft:e.jsx(n.Icon,{name:i,color:a.border,marginLeft:1}),size:"sm",stroke:a.border,strokeAlign:"inside",strokeWeight:1,title:o})}function ee({event:t}){const{status:a,lastDelivery:i}=t,o=function(t,a){let i=null;switch(t){case"skipped":case"ignored_skipped":i="Automation was paused and did not run on this profile";break;case"failed":case"duplicated":case"ignored_failed":case"ignored_duplicated":i=function(t,a){const i={403:"Owner doesn't have permission to perform this action.",404:"Owner lacks access to target product or resource doesn't exist.",422:"The automation action failed to run",default:"An error occurred",duplicated_event:"Didn't run because the same action had already been performed less than 60 seconds ago",failed_without_deliveries:"Didn't run because the owner doesn't have permissions in this product."};return e.jsx(n.StackView,{flex:1,whiteSpace:"normal",children:t?e.jsx(te,{details:function(e){if(!e?.responseBody)return null;let t;try{t=JSON.parse(e.responseBody)}catch{t={errors:["Server Error"]}}return function(e){return e?.errors?e.errors.map(e=>"string"==typeof e&&e.match(/Archived profiles/)?e.replace(/Archived profiles/,"Archived profiles."):e):[]}(t).join(", ")||t?.message}(t),status:t.status,children:i[t.status]||i.default}):["duplicated","ignored_duplicated"].includes(a)?i.duplicated_event:i.failed_without_deliveries})}(a,t)}return i}(a,i);return o?e.jsx(n.Box,{fontSize:"13px",fontStyle:"italic",lineHeight:"16px",maxWidth:"100%",paddingTop:"1px",whiteSpace:"normal",children:o}):null}function te({children:t,details:i,status:o}){const[s,r]=a.useState(!1);return e.jsxs(n.StackView,{spacing:1,children:[e.jsxs(n.Box,{children:[t," ",i&&e.jsx(n.Button,{inline:!0,onClick:function(){r(e=>!e)},size:"xs",theme:"primary",variant:"naked",fontStyle:"normal",children:"Details"})]}),s?e.jsx(n.Box,{padding:1,background:_.neutral98,children:e.jsxs(n.Text,{fontFamily:"monospace",fontSize:"11px",lineHeight:"1.2",children:[o&&`${o}: `,i]})}):null]})}class ne extends h.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs(n.Alert,{type:"error",marginVertical:1,children:["The application hit an unexpected error. If this persists after a few minutes, please let us know so we can get it fixed for you."," ",e.jsx("a",{style:{whiteSpace:"nowrap"},onClick:()=>window.Helpdesk.load(),children:"Contact support"})]}):this.props.children}}var ae=t=>e.jsx(ne,{children:e.jsx(Q,{...t})});function ie({onClick:t}){return e.jsx(n.Button,{as:"button",height:2,icon:{color:_.neutral62,name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function oe({children:t,onRequestClose:a,open:i,theme:o}){/*#__PURE__*/return u.createPortal(e.jsx(n.ThemeProvider,{theme:o,children:e.jsxs(n.Modal,{open:i,onRequestClose:a,maxWidth:120,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:4,paddingBottom:3,radius:8,children:[e.jsxs(n.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(n.Heading,{level:2,color:_.neutral12,fontWeight:500,fontSize:"25px",lineHeight:"1.4",children:"Automation history"}),e.jsx(ie,{onClick:a})]}),t]})}),document.body)}const se=function(e){try{return Promise.resolve(le.get({data:{fields:{Person:"avatar"}},url:"me"})).then(function({data:{avatar:t}}){return{avatar:t,subscription:e}})}catch(e){return Promise.reject(e)}},re=new t.Client({app:"webhooks",version:"2022-10-20"}),le=new t.Client({app:"people"}),ce=/*#__PURE__*/a.createContext(null);function de({onDelete:t,theme:n,openHistoryNow:a=!1,...i}){return e.jsxs(he,{theme:n,...i,children:[e.jsxs(ge,{children:[e.jsx(fe,{}),e.jsx(we,{onDelete:t,openHistoryNow:a})]}),e.jsx(ve,{}),e.jsx(be,{})]})}function ue(t){return e.jsxs(he,{automation:t.automation,children:[e.jsxs(ge,{children:[e.jsx(fe,{}),e.jsx(me,{})]}),e.jsx(pe,{}),e.jsx(xe,{})]})}function pe(){const{automation:t}=a.useContext(ce),o=t.triggerEventDescription,{name:s,description:r}=ye(t.description);return e.jsxs(n.StackView,{paddingVertical:2,flex:1,opacity:t.active?void 0:.5,children:[e.jsx(n.Heading,{level:3,size:"21px",weight:600,marginBottom:.5,truncate:!0,children:s}),e.jsxs(n.StackView,{spacing:.75,children:[e.jsxs(n.Text,{size:4,color:_.neutral24,lineHeight:"1.2",children:[o,", then ",i.lowerFirst(s)," ",je(t)]}),e.jsx(n.Text,{size:5,color:_.neutral45,lineHeight:"1.2",children:i.truncate(ke(r),{length:160,separator:" "})})]})]})}function me(){const{automation:t}=a.useContext(ce);return e.jsx(n.Button,{external:!0,iconLeft:{name:"general.newWindow"},variant:"naked",size:"sm",to:t.triggerAdminUrl,disabled:!t.canManage,tooltip:t.canManage?void 0:"You do not have access to this resource",color:_.neutral45,hover:{backgroundColor:"highlight",color:_.neutral45},children:"Manage"})}function he({automation:t,children:i,theme:o,...s}){const[r,l]=a.useState(t);return e.jsx(ce.Provider,{value:{automation:r,theme:o,updateAutomation:l,...s},children:e.jsx(n.Card,{radius:4,padding:2,children:i})})}function ge({children:t}){const{automation:i}=a.useContext(ce);return e.jsx(n.StackView,{axis:"horizontal",alignment:"center",padding:0,distribution:"space-between",opacity:i.active?void 0:.5,children:t})}function we({onDelete:t,openHistoryNow:i=!1}){const{automation:o,currentPersonCanCreate:s,currentPersonId:r,trigger:l,theme:c,updateAutomation:d}=a.useContext(ce),[u,p]=a.useState(i),m=o.active,{name:h}=ye(o.description);return e.jsxs(e.Fragment,{children:[e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsxs(n.Dropdown,{icon:{color:_.neutral24,name:"churchCenter.threeDots"},iconRight:!1,title:"Actions",variant:"naked",size:"md",children:[e.jsx(n.Dropdown.Item,{onSelect:()=>{p(!0)},children:"History"}),s&&e.jsx(n.Dropdown.Item,o.createdById===r?{disabled:!0,children:e.jsx(n.Tooltip,{placement:"left",openDelay:250,title:"This automation is already assigned to you.",children:e.jsx(n.Text,{children:"Reassign to me..."})})}:{onSelect:function(){k.fire({text:"This automation will run with your permission levels. Other administrators who can see this automation can grant it their permissions by reassigning it to themselves.",title:"Reassign automation?"}).then(({isConfirmed:e})=>{e&&re.post({data:{_e:l.resource,data:{attributes:{}}},url:`/automation_subscriptions/${o.id}/self_assign`}).then(({data:e})=>se(e)).then(({subscription:e,avatar:t})=>{d(n=>({...n,createdBy:{...n.createdBy,avatarUrl:t},createdById:e.createdById,createdByName:e.createdByName}))}).catch(()=>y.fire({text:"There was a problem updating this automation. Please try again in a few moments.",title:"Uh oh!"}))})},children:"Reassign to me..."}),e.jsx(n.Dropdown.Item,{onSelect:function(){C.fire({confirmButtonText:"Yes, delete automation",text:`Are you sure you want to delete the "${h}" automation? This cannot be undone.`,title:"Delete this automation?"}).then(({isConfirmed:e})=>{e&&t(o.id)})},children:"Delete..."})]}),e.jsx(n.Button,{as:"button",theme:!1,position:"relative",backgroundColor:m?_.statusCreate35:_.neutral62,radius:"pill",width:3.5,height:2,onClick:function(){re.patch({data:{_e:l.resource,data:{attributes:{active:!m}}},url:`/automation_subscriptions/${o.id}`}).then(e=>{d(t=>({...t,active:e.data.active}))}).catch(()=>y.fire({text:`There was a problem ${m?"pausing":"unpausing"} this automation. Please try again in a few moments.`,title:"Uh oh!"}))},tooltip:m?"Pause automation":"Enable automation",children:e.jsx(n.Box,{position:"absolute",pointerEvents:"none",top:.25,left:.25,width:1.5,height:1.5,background:"#fff",radius:"circle",transition:"0.1s",transform:`translateX(${m?"100%":"0%"})`})})]}),e.jsx(oe,{open:u,onRequestClose:()=>p(!1),theme:c,children:e.jsx(ae,{automation:o,triggerResource:l.resource,onEventsStatusChange:function(e){d(t=>({...t,eventsStatus:e}))}})})]})}function fe(){const{automation:t}=a.useContext(ce),o=t.name.split(".")[0];return e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.5,children:[e.jsx(n.Icon,{name:`logomark.${i.camelCase(o)}`,size:2,color:o.toLowerCase()}),e.jsx(n.Icon,{name:"general.rightArrow",size:1.5}),e.jsx(n.Icon,{name:`logomark.${i.camelCase(t.operationAppName)}`,size:2,color:t.operationAppName.toLowerCase()})]})}function xe(){const{automation:t}=a.useContext(ce),{dateFormat:i}=a.useContext(j),o=`${t.createdByName} ${t.createdBy?.id?"":"(deleted profile)"}`,s=t.active?void 0:.5;return e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{marginHorizontal:-2}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:1,opacity:s,children:[e.jsxs(n.Text,{size:6,color:_.neutral62,whiteSpace:"nowrap",children:["Updated ",D(t.createdAt,i)]}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.5,maxWidth:"calc(100% - 136px)",children:[t.createdBy?.avatarUrl&&e.jsx(n.Avatar,{width:2,height:2,basis:2,source:t.createdBy.avatarUrl},o),e.jsx(n.Text,{size:5,truncate:!0,children:o})]})]})]})}function be(){const{dateFormat:t}=a.useContext(j),{automation:i,trigger:o,theme:s,updateAutomation:r}=a.useContext(ce),l=`${i.createdByName} ${i.createdBy?.id?"":"(deleted profile)"}`,c=i.active?void 0:.5,d={color:_.neutral45,fontSize:6,fontWeight:400,paddingHorizontal:1,radius:"pill",size:"xs",variant:"naked"},[u,p]=a.useState({filter:null,historyVisible:!1});return e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{marginHorizontal:-2}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:1,opacity:c,children:[e.jsxs(n.Text,{size:6,color:_.neutral62,whiteSpace:"nowrap",children:["Updated ",D(i.createdAt,t)]}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.25,children:[!!i.eventsStatus?.skipped&&e.jsxs(n.Button,{...d,"aria-label":`${i.eventsStatus.skipped} skipped`,onClick:function(){p({filter:"skipped",historyVisible:!0})},tooltip:`${i.eventsStatus.skipped?.toLocaleString()} skipped events`,children:[e.jsx(n.Box,{backgroundColor:_.statusWarning63,marginRight:.5,radius:"circle",height:"10px",width:"10px",padding:"2px",children:e.jsx(n.Icon,{name:"services.pause",size:"6px",title:"Skipped",color:"white"})}),`${i.eventsStatus.skipped?.toLocaleString()}`]}),!!i.eventsStatus?.failed&&e.jsx(n.Button,{...d,"aria-label":`${i.eventsStatus.failed} failed`,iconLeft:{color:_.statusDelete43,marginRight:.5,name:"general.exclamationTriangle",size:"10px",title:"Failed"},onClick:function(){p({filter:"failed,duplicated",historyVisible:!0})},title:`${i.eventsStatus.failed?.toLocaleString()}`,tooltip:`${i.eventsStatus.failed?.toLocaleString()} failed events`})]}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",distribution:"end",flex:1,spacing:.5,marginLeft:"auto",children:[i.createdBy?.avatarUrl&&e.jsx(n.Avatar,{width:2,height:2,basis:2,source:i.createdBy.avatarUrl},l),e.jsx(n.Text,{size:5,truncate:!0,children:l})]})]}),e.jsx(oe,{open:u.historyVisible,onRequestClose:()=>p({filter:null,historyVisible:!1}),theme:s,children:e.jsx(ae,{automation:i,triggerResource:o.resource,filterWhere:u.filter,onEventsStatusChange:function(e){r(t=>({...t,eventsStatus:e}))}})})]})}function ve(){const{automation:t,trigger:o}=a.useContext(ce),{name:s,description:r}=ye(t.description),l=t.active?void 0:.5,c=["When a person",i.lowerFirst(o.event.description)+",","then",i.lowerFirst(s),je(t)].join(" ");return e.jsxs(n.StackView,{paddingVertical:2,flex:1,opacity:l,children:[e.jsx(n.Heading,{level:3,size:"21px",weight:600,marginBottom:.5,truncate:!0,children:s}),e.jsxs(n.StackView,{spacing:.75,children:[e.jsx(n.Text,{size:4,color:_.neutral24,lineHeight:"1.2",children:c}),e.jsx(n.Text,{size:5,color:_.neutral45,lineHeight:"1.2",children:i.truncate(ke(r),{length:160,separator:" "})})]})]})}function je(e){return e?.triggerParams?.useTriggerPersonOverride?"(also applies to joint donor)":""}function ye(e){const t=/^(.+?)\(([^()]*?)\)$/.exec(e);return t?{description:t[2],name:t[1].trim()}:{name:e}}function ke(e){return e?.startsWith("[archived]")?e.replace("[archived]","(Archived)"):e}const Ce=function(){try{return Promise.resolve(_e.get({data:{fields:{App:["name"],PersonApp:["app","allow_pco_login"]},include:["app"]},url:"/me/person_apps"}).then(({data:e})=>e.filter(e=>e.allowPcoLogin).map(e=>e.app.name.toLowerCase())))}catch(e){return Promise.reject(e)}},Se=function(e){try{const t=i.compact(i.uniq(e.map(e=>e.createdById)));return Promise.resolve(function(n,a){try{var i=Promise.resolve(_e.get({data:{fields:{Person:"avatar"},where:{id:t.join(",")}},url:"people"})).then(function({data:t}){return{profiles:t,subscriptions:e}})}catch(e){return a()}return i&&i.then?i.then(void 0,a):i}(0,function(){return{profiles:[],subscriptions:e}}))}catch(e){return Promise.reject(e)}},ze=new t.Client({app:"webhooks",version:"2022-10-20"}),_e=new t.Client({app:"people"});function Pe({profiles:e,subscriptions:t}){return t.map(t=>{const n=e.find(e=>e.id===t.createdById);return{...t,createdBy:{...t.createdBy,avatarUrl:n?.avatar}}})}const Te=function(e){try{const t={people:["forms","lists"],registrations:["events"],services:["teams"]},n=["giving"],a=e.reduce((e,t)=>{const n=t.triggerResource.replace(/signup/,"event"),{appName:a,resourceType:i,resourcePath:o,resourceId:s}=R(n);return e[a]||(e[a]={}),e[a][i]||(e[a][i]={}),e[a][i].resoucePath||(e[a][i].resourcePath=o),e[a][i].ids||(e[a][i].ids=[]),e[a][i].ids.push(s),e},{}),i=Object.keys(a).flatMap(e=>Object.entries(a[e]).flatMap(([a,i])=>(n.includes(e)?$e:t[e]?.includes(a)?Ie:Fe)({appName:e,ids:i.ids,resourcePath:i.resourcePath,resourceType:a})));return Promise.resolve(Promise.allSettled(i)).then(function(t){return{automations:e,triggerResources:(n=t,n.reduce((e,t)=>("fulfilled"===t.status&&(e=e.concat(t.value)),e),[]).flatMap(e=>e.data))};var n})}catch(e){return Promise.reject(e)}},Oe=function(e){try{return Promise.resolve(Ae.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,trigger_resource,trigger_params",Person:"name"},include:"created_by"},url:"incoming_automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},Ae=new t.Client({app:"webhooks",version:"2022-10-20"});function Ie({appName:e,resourcePath:t,resourceType:n,ids:a}){return Ve({appName:e,params:{where:{id:a.join(",")}},path:t,resourceType:n})}function Fe({appName:e,resourcePath:t,resourceType:n,ids:a}){return a.map(a=>Ve({appName:e,path:`${t}/${a}`,resourceType:n}))}function $e(e){return new Promise((e,t)=>{t()})}function Ve({appName:e,path:n,resourceType:a,params:o={}}){const s=new t.Client({app:e}),r=i.upperFirst(W(a));return s.get({data:{fields:{[r]:["name","name_or_description"]},...o},url:n})}function Le({encryptedParam:t,trigger:o}){const[s,r]=a.useState(!0),[l,c]=a.useState();a.useEffect(()=>{Ce().then(e=>{Oe(t).then(Se).then(Pe).then(P).then(Te).then(({automations:t,triggerResources:n})=>function({automations:e,triggerResources:t,operationApps:n}){return e.map(e=>{const{appName:a,resourceType:o,resourceId:s}=R(e.triggerResource);if("giving"===a)return e.triggerEventDescription=function(e){switch(e.name.replace("giving.v2.events.","")){case"donation.payment_successful":return"When a person gives";case"profile.first_donated_automation":return"When a person gives for the first time";case"recurring_donation.setup_successful":return"When a person sets up a recurring donation";default:return null}}(e),e.canManage=n.find(e=>"giving"===e),e;const r=t.find(e=>e.id.toString()==s.toString()),l=r?r.name||r.nameOrDescription:`[Hidden ${i.upperFirst(W(o))}]`;return e.triggerEventDescription=function(e,t){const n=function(e){switch(e.replace("v2.events.","")){case"groups.membership.created":return"joins";case"groups.membership.destroyed":return"leaves";case"people.list_result.created":case"services.team_person.created":return"is added to";case"people.list_result.destroyed":case"services.team_person.destroyed":return"is removed from";case"people.form_submission.created":return"submits";case"registrations.attendee.created":return"is registered as a new attendee for";case"registrations.attendee.cancelled":return"is canceled as an attendee for";case"registrations.registration.created":return"is the registration contact on a new registration for";case"registrations.registration.cancelled":return"is the registration contact on a canceled registration for";default:return null}}(e.name),{resourceType:a}=R(e.triggerResource);if(!n){const e=i.truncate(t,{length:160,separator:" "});return`When the automation is triggered from ${W(a)} "${e}"`}return`When a person ${n} ${W(a)} "${t}"`}(e,l),e.canManage=!!r,e})}({automations:t,operationApps:e,triggerResources:n})).then(c).then(()=>r(!1))})},[t]);const d=!s&&0===l.length;return e.jsxs(e.Fragment,{children:[e.jsx(n.Box,{borderBottom:`1px solid ${_.neutral88}`,marginBottom:2,marginHorizontal:-3,marginTop:o?12:0,paddingHorizontal:3,paddingVertical:2,children:e.jsx(n.Heading,{color:_.neutral12,level:2,size:"18px",children:s?"Incoming automations":H(l.length,"incoming automation")})}),d?e.jsx(n.Text,{color:_.neutral45,marginVertical:3,children:"Automations that perform actions on this resource will be listed here."}):s?e.jsx(n.Summary,{image:e.jsx(n.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading incoming automations..."}):e.jsx(n.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:l.map(t=>e.jsx(ue,{automation:t},t.id))})]})}function Be(e){return`OPERATION_${e.definitionClass}${e.definitionIdentifier||""}`}function De(e){return`SECTION_${e}`}function He(t){return t.map(({label:t,value:a})=>e.jsx(n.Select.Option,{value:a,children:t},a))}function We(t){const a=i.groupBy(t,"group");return Object.keys(a).sort().map(t=>"null"===t?He(a[t]):e.jsx(n.Select.OptionGroup,{title:t,children:He(a[t])},t))}const Re=({selectedOperation:t,onOperationDefinitionChange:a,operationDefinitions:o})=>{const s=t?.section,r=o.map(e=>({...e,id:Be(e)})),l=r.filter(e=>null===e.section),c=i.uniqBy(o,"section").filter(e=>!!e.section).map(e=>({group:e.sectionGroup,label:e.section,value:De(e.section)})),d=s?r.filter(e=>e.section===s):[];function u({selectedValue:e}){switch(function(e){if(e.startsWith("SECTION"))return"section";if(e.startsWith("OPERATION"))return"operation";if(e)throw new Error(`Unexpected value: ${e}`);return null}(e)){case"section":a(o.find(t=>De(t.section)===e));break;case"operation":a(o.find(t=>Be(t)===e));break;case null:a(null)}}function p(e){return We(e.map(e=>({group:e.group,label:e.description,value:e.id})))}return e.jsxs(n.StackView,{spacing:1,children:[e.jsxs(n.Select,{emptyValue:"Select an action",id:"select-action",onChange:u,size:"lg","data-testid":"operation-select",children:[p(l),We(c)]}),d.length>0&&e.jsx(n.Select,{defaultValue:d[0].id,onChange:u,size:"lg",children:p(d)})]})},Me=({canAccessPeople:t,field:o,onChange:s,value:r,selectedFieldOptions:l,loadListForField:c,loadedLists:d,loadingLists:u})=>{const p=function(e){const[t,n]=a.useState(e);return a.useEffect(()=>{const a=e();i.isEqual(a,t)||n(a)},[e,t]),t}(()=>function({field:e,selectedFieldOptions:t}){return(e.dependsOn||[]).reduce((e,n)=>(Object.prototype.hasOwnProperty.call(t,n)&&(e[i.camelCase(n)]=t[n]),e),{})}({field:o,selectedFieldOptions:l}));a.useEffect(()=>{o.listClass&&c({dependencies:p,field:o})},[o,p,c]);const m=o.list||d[A(o)]||[],h=m.filter(e=>!e.automationNotAllowed),g=o.listClass&&u[A(o)];return e.jsxs(n.StackView,{marginBottom:2,spacing:.5,children:[e.jsxs(n.Input.InputLabel,{color:_.neutral12,fontSize:"14px",fontWeight:500,controls:o.id,children:[o.description,o.info&&e.jsx(n.HelperDrawer.Toggle,{drawerId:`${o.id}_help`,marginLeft:1})]}),e.jsx(n.Box,{children:g?e.jsx(Ke,{}):function(){switch(o.kind){case"Select":return e.jsx(Ee,{fieldId:o.id,listOptions:h,onChange:s,value:r});case"SelectSearch":return e.jsx(Ne,{fieldId:o.id,listOptions:h,onChange:s,value:r});case"Checkbox":return e.jsx(Ye,{field:o,value:r,onChange:s});case"TextArea":return e.jsx(Ue,{field:o,onChange:s,value:r});case"DateField":return e.jsx(Ze,{field:o,onChange:s,value:r});case"Checkboxes":return e.jsx(Xe,{fieldId:o.id,options:h,onChange:s});case"NumberField":return e.jsx(Qe,{field:o,onChange:s,value:r});case"PersonSearch":return e.jsx(qe,{canAccessPeople:t,field:o,onChange:s,listOptions:m,isLoading:u[A(o)],loadListForField:c,value:r});case"TextField":return e.jsx(Ge,{field:o,onChange:s,value:r});case"RadioButtons":return e.jsx(Je,{field:o,options:m,onChange:s,value:r});default:return console.warn(`Unknown field kind "${o.kind}"`),null}}()}),o.info&&e.jsx(n.HelperDrawer,{id:`${o.id}_help`,marginTop:.5,children:e.jsx(n.Box,{dangerouslySetInnerHTML:{__html:o.info}})})]})},Ee=({fieldId:t,listOptions:a,onChange:o,value:s})=>{const r=a?.find(e=>"no-option"===e.value),l=i.groupBy(a,"group"),c=Object.keys(l).sort(),d=()=>c.map(t=>"null"===t||"undefined"===t?u(l[t]):e.jsx(n.Select.OptionGroup,{title:t,children:u(l[t])},t)),u=t=>t.map(t=>e.jsx(n.Select.Option,{value:t.value.toString(),disabled:t.disabled,children:t.description},t.value));return e.jsx(n.Select,{id:t,onChange:({selectedValue:e})=>{o({fieldId:t,value:e})},disabled:d().length<1,emptyValue:0===d().length?"No options available":r?.description||"Select a value",size:"lg",value:s||r?.value||null,placement:"bottom-start",children:d()})},Ne=({fieldId:t,listOptions:o,onChange:s,value:r})=>{const l=o.find(e=>e.value?.toString()===r),c=l?.description||"",[d,u]=a.useState(""),[p,m]=a.useState(c),[h,g]=a.useState(!1),[w,f]=a.useState(!1);c!==d&&(u(c),m(c),g(!1));let x=i.sortBy(i.uniqBy(o,"value"),"group");if(h){const e=p.toLowerCase();x=x.filter(t=>`${t.description} ${t.group}`.toLowerCase().includes(e))}return e.jsx(n.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},css:{"[role='combobox']":{cursor:o.length>0?"pointer":"not-allowed"}},cursor:"pointer",disabled:0===o.length,onBlur:()=>{f(!1),m(c)},onChange:e=>{m(e.target.value),g(!0),f(!0)},onClear:w?()=>{m(""),g(!1)}:void 0,onFocus:e=>e.target.select(),onSelect:e=>{(e=>{s({fieldId:t,value:e})})(e.value),m(e.description),g(!1),f(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:o.length>0?"Select an option":"No options available",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:e.jsx(n.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(n.Icon,{name:"general.downCaret"}),size:"lg",value:p,children:o.length>0&&e.jsx(e.Fragment,{children:x.length>0?x.map((t,a)=>{const i=t.value.toString()===r;return e.jsxs(n.Combobox.Item,{"aria-label":t.description,disabled:t.disabled,index:a,paddingLeft:4.25,renderLeft:e.jsx(n.Icon,{marginLeft:-.5,name:i?"general.check":"",size:"sm"}),role:"option",spacing:1,value:{description:t.description,value:t.value.toString()},children:[e.jsx(n.Text,{truncate:!0,children:e.jsx(n.Highlight,{text:t.description,query:p})}),t.group&&e.jsx(n.Badge,{title:e.jsx(n.Highlight,{text:t.group,query:p}),size:"sm",marginLeft:"auto"})]},t.value)}):e.jsx(n.Menu.Item,{children:e.jsxs(n.Text,{children:['No results for "',p,'"']})})})})},qe=({canAccessPeople:t,field:o,isLoading:s,listOptions:r,loadListForField:l,onChange:c,value:d})=>{const u=a.useCallback(e=>{l({dependencies:{query:e},field:o})},[l]),p=a.useMemo(()=>i.debounce(u,300),[u]),m=a.useCallback(e=>{t&&(e.trim().length>0?p(e):p.cancel())},[p]),h=a.useMemo(()=>({description:"Myself",value:"self"}),[]),g=a.useMemo(()=>t?r:[h],[h,r]).find(e=>e.value===d),w=g?.description||"",[f,x]=a.useState(w),[b,v]=a.useState(!1);function j(e){x(e),m(e),0===e.trim().length&&y(null)}const y=e=>{c({fieldId:o.id,value:e})};return e.jsx(n.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},cursor:"pointer",onBlur:()=>{v(!1),j(w)},onChange:e=>{j(e.target.value),v(!0)},onClear:b?()=>{j("")}:void 0,onFocus:e=>e.target.select(),onSelect:e=>{y(e.value),j(e.description),v(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:"Search",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:g&&g.meta?.avatar?e.jsx(n.Avatar,{size:"sm",source:g.meta.avatar}):e.jsx(n.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(n.Icon,{name:"general.downCaret"}),size:"lg",value:f,children:t?f.trim().length>0?r.length>0?r.map((t,a)=>e.jsx(n.Combobox.Item,{"aria-label":t.description,index:a,paddingLeft:4.25,renderLeft:e.jsx(n.Avatar,{marginLeft:-.5,source:t.meta.avatar,size:"sm"}),role:"option",spacing:1,value:t,children:e.jsx(n.Text,{truncate:!0,children:e.jsx(n.Highlight,{text:t.description,query:f})})},t.value)):e.jsx(n.Combobox.Item,s?{children:e.jsx(n.Text,{children:"Loading..."})}:{children:e.jsx(n.Text,{children:"No results"})}):e.jsx(n.Combobox.Item,{children:e.jsx(n.Text,{children:"Type to search"})}):e.jsx(n.Combobox.Item,{value:h,index:0,role:"option",children:e.jsx(n.Text,{children:h.description})})})},Ye=({field:t,value:a,onChange:i})=>e.jsx(n.Checkbox,{disabled:t.disabled,label:t.label,checked:a||!1,onChange:e=>{i({fieldId:t.id,value:e.target.checked})}}),Ue=({field:t,value:a,onChange:i})=>e.jsx(n.Box,{children:e.jsx(n.TextArea,{value:a,placeholder:t.placeholder,onChange:e=>{i({fieldId:t.id,value:e.target.value})},size:"lg"})}),Ze=({field:t,value:i,onChange:o})=>{const{dateFormat:s}=a.useContext(j),[r,l]=a.useState(!1),c=t.customValue||"Date automation runs",d=s.replace(/%m/,"M").replace(/%d/,"d").replace(/%Y/,"y").replace(/%y/,"yy"),[u,p]=a.useState(g.default(i).toDate());return e.jsxs(n.StackView,{axis:"horizontal",children:[e.jsxs(n.Select,{onChange:({selectedValue:e})=>{e===c?(l(!1),o({fieldId:t.id,value:c})):"specific-date"===e?(o({fieldId:t.id,value:null}),l(!0)):(l(!1),o({fieldId:t.id,value:null}))},size:"lg",placement:"bottom-start",children:[e.jsx(n.Select.Option,{value:c,children:c}),e.jsx(n.Select.Option,{value:"specific-date",children:"A specific date"}),e.jsx(n.Select.Option,{value:"unanswered",children:"Unanswered"})]}),r&&e.jsx(n.Box,{children:e.jsx(n.DateField,{defaultOpen:!0,formatValue:d,marginLeft:1,onChange:e=>{o({fieldId:t.id,value:D(e,s)}),p(e)},size:"lg",value:u})})]})},Xe=({fieldId:t,options:i,onChange:o})=>{const[s,r]=a.useState({});return e.jsx(n.StackView,{spacing:1,children:i.map(a=>e.jsxs(n.Box,{children:[e.jsx(n.Input.InputLabel,{controls:`checkboxes_${t}_${a.value}`,children:a.description||a.value}),e.jsxs(n.Select,{id:`checkboxes_${t}_${a.value}`,onChange:({selectedValue:e})=>((e,n)=>{const a={...s};a[n]=e,r(a),o({fieldId:t,value:a})})(e,a.value),size:"lg",emptyValue:"Don't change",children:[e.jsx(n.Select.Option,{value:"check",children:"Check"}),e.jsx(n.Select.Option,{value:"uncheck",children:"Uncheck"})]})]},a.value))})},Qe=({field:t,onChange:i,value:o})=>{const s=t.minValue>=0?t.minValue:1,r=t.maxValue>=1&&t.maxValue<=365?t.maxValue:365,[l,c]=a.useState(Number(t.defaultValue)||1);return a.useEffect(()=>{i({fieldId:t.id,value:t.defaultValue||1})},[t]),e.jsxs(n.StackView,{children:[e.jsx(n.Input.InputBox,{children:e.jsx(n.NumberField,{onChange:e=>{const n=Number(e)||0;c(n),i({fieldId:t.id,value:Math.min(Math.max(n,s),r)})},placeholder:t.placeholder,size:"lg",value:o,min:s,max:r,hasControls:!0})}),l>r&&e.jsx(n.Alert,{type:"error",paddingHorizontal:1,paddingVertical:.5,display:"inline-block",marginTop:1.5,children:e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsx(n.Icon,{name:"general.exclamationTriangle",size:"sm",color:"delete45"}),e.jsxs(n.Text,{size:4,children:["Value cannot exceed ",r,"."]})]})})]})},Ge=({field:t,value:a,onChange:i})=>e.jsx(n.Box,{children:e.jsx(n.Input,{size:"lg",value:a,id:t.id,placeholder:t.placeholder,onChange:e=>{i({fieldId:t.id,value:e.target.value})}})}),Je=({field:t,options:a,onChange:i,value:o})=>{const s=e=>{i({fieldId:t.id,value:e.target.value})};return e.jsx(n.StackView,{marginTop:1,spacing:.5,children:a.map(t=>e.jsx(n.Radio,{checked:o===t.value,label:t.description||t.value,onChange:s,size:"md",value:t.value},t.value))})},Ke=()=>e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,paddingHorizontal:1.75,paddingVertical:1,radius:4,border:`1px solid ${_.neutral88}`,children:[e.jsx(n.Spinner,{size:"xs"}),e.jsx(n.Text,{fontSize:16,lineHeight:2.75,children:"Loading"})]}),et=({canAccessPeople:t,definitionFields:n,onChange:i,selectedFieldOptions:o,loadListForField:s,loadedLists:r,loadingLists:l})=>{a.useEffect(()=>{const e=n.reduce((e,t)=>(Object.prototype.hasOwnProperty.call(t,"defaultValue")?e[t.id]=t.defaultValue:"DateField"===t.kind&&(e[t.id]=t.customValue||"Date automation runs"),e),{});i(e)},[n,i]);const c=V(n,o),d=({fieldId:e,value:t})=>{const a={...o},s=n.filter(e=>e.dependsOn);s.map(t=>{if(t.dependsOn.includes(e)){const e=s.find(e=>e.dependsOn.includes(t.id));e&&delete a[e.id],delete a[t.id],void 0!==t.defaultValue&&void 0===a[t.id]&&(a[t.id]=t.defaultValue)}}),"no-option"===t?delete a[e]:a[e]=t,i({...a})};return n.length?e.jsx("div",{children:c.map(n=>e.jsx(Me,{canAccessPeople:t,field:n,onChange:d,value:o[n.id],selectedFieldOptions:o,loadListForField:s,loadedLists:r,loadingLists:l},n.id))}):null},tt=function(e){try{return Promise.resolve(ot.get({data:{fields:{OperationDefinition:"definition_class,definition_fields,definition_identifier,description,group,section,section_group,footer_message"},filter:"automation_allowed"},url:`/operation_apps/${e}/operation_definitions`}).then(({data:e})=>e))}catch(e){return Promise.reject(e)}},nt=function(){try{return Promise.resolve(ot.get({data:{fields:{OperationApp:"name"}},url:"/operation_apps"}).then(({data:e})=>e.map(e=>e.name)))}catch(e){return Promise.reject(e)}},at=function(){try{return Promise.resolve(it.get({data:{fields:{Topbar:"apps"}},url:"/me/topbar"}).then(({data:e})=>e.apps.map(e=>e.name)))}catch(e){return Promise.reject(e)}},it=new t.Client({app:"people",env:window.railsEnv,version:"LATEST"}),ot=new t.Client({app:"webhooks",env:window.railsEnv,version:"LATEST"}),st={css:{borderRadius:4},paddingHorizontal:1.75,paddingVertical:1.25,type:"error"},rt=({afterCreateOptions:t,blankStateLink:o,debugMode:s=!1,defaultApp:r,description:l,onRequestClose:c,trigger:d})=>{const[u,p]=a.useState(d.events[0]),[m,h]=a.useState({}),[g,w]=a.useState(r),[f,x]=a.useState([]),[b,v]=a.useState([]),[j,y]=a.useState(!0),[k,C]=a.useState(),[z,P]=a.useState({}),[T,O]=a.useState({}),[F,$]=a.useState({}),[V,B]=a.useState(!1),[D,H]=a.useState({}),[W,R]=a.useState(!1),[M,E]=a.useState({}),N=a.useRef(null),q=a.useMemo(()=>f.map(e=>e.id).includes("people"),[f]),Y=k?.definitionIdentifier,U="danger"===k?.footerMessage?.kind,Z=a.useCallback(({field:e,dependencies:t})=>{$(t=>({...t,[A(e)]:!0})),function({app:e,field:t,definitionIdentifier:n,dependencies:a}){try{return"PersonSearch"===t.kind?Promise.resolve(it.get({data:{fields:{Person:"avatar,name"},where:{search_name_or_email:a.query,status:"active"}},url:"/people"})).then(function({data:e}){return e.map(e=>({description:e.name,meta:{avatar:e.avatar},value:e.id.toString()}))}):Promise.resolve(ot.get({data:{...a,definitionIdentifier:n,fields:{OperationDefinitionList:"values"}},url:`/operation_apps/${e}/operation_definition_lists/${t.listClass}`})).then(function({data:e}){return e.values})}catch(e){return Promise.reject(e)}}({app:g,definitionIdentifier:Y,dependencies:t,field:e}).then(t=>{O(n=>({...n,[A(e)]:t})),$(t=>({...t,[A(e)]:!1}))}).catch(e=>H({selected_definition:e}))},[g,Y]);a.useEffect(()=>{H({}),function(){try{return Promise.resolve(Promise.all([at(),nt()])).then(function([e,t]){return e.filter(e=>t.includes(e)).sort().map(e=>({id:e.toLowerCase(),name:e}))})}catch(e){return Promise.reject(e)}}().then(e=>{x(e);const t=e.find(e=>e.id===r)?r:e[0].id;w(t),tt(t).then(e=>{N.current||(v(e),y(!1))}).catch(e=>H({definitions:e}))})},[r]),a.useEffect(()=>{H({})},[z]);const X=i.cloneDeep("conditions"in u?u.conditions:d.conditions);for(const e in m)i.set(X,e,m[e]);const Q="dynamicConditions"in u?u.dynamicConditions:d.dynamicConditions;function G(){const e=function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return{description:L({loadedLists:n||{},selectedDefinition:e,selectedFieldOptions:t}),name:(a=e,I(a)||a.description)};var a}({loadedLists:T,selectedDefinition:k,selectedFieldOptions:z});let t=e.name;return e.description&&(t+=` (${e.description})`),t}function J(e){B(!0),ot.post({data:e,url:"/me/automation_subscriptions"}).then(()=>{t?.onConfirm&&W?(c(),t.onConfirm({...e})):window.location.reload()}).catch(e=>{B(!1),e.errors?H({automation:e.errors}):alert("something even worse happened!")})}return e.jsxs(n.StackView,{paddingTop:4,spacing:2,children:[l&&e.jsx(n.Box,{children:e.jsxs(n.Text,{style:{color:_.neutral24,fontSize:16,lineHeight:1.65,marginBottom:16},children:[l," ",e.jsx(n.Link,{external:!0,to:o,children:"Learn more"})]})}),D.automation&&e.jsx(n.Alert,{...st,children:e.jsx(n.Text,{children:"There was an error creating your automation. Please change your selections and try again or contact support if the problem persists."})}),e.jsxs(n.StackView,{spacing:1,children:[e.jsx(n.Input.InputLabel,{color:_.neutral12,controls:"select-trigger-event",fontSize:"16px",fontWeight:600,children:"When a person..."}),e.jsx(n.Select,{id:"select-trigger-event",onChange:({selectedValue:e})=>(e=>{p(e),h({})})(e),size:"lg",value:u,children:d.events.map((t,a)=>e.jsx(n.Select.Option,{value:t,children:t.description},`${t.name}_${a}`))}),Q?.length>0&&e.jsx(et,{canAccessPeople:q,definitionFields:Q,selectedFieldOptions:m,onChange:h,loadedLists:{},loadingLists:{},loadListForField:()=>null})]}),e.jsxs(n.StackView,{spacing:1,children:[f.length>0?e.jsx(pt,{selectedApp:g,operationApps:f,onOperationAppChange:e=>{w(e),y(!0),v([]),N.current=e,C(null),P({}),H({}),tt(e).then(v).then(()=>y(!1)).catch(e=>H({definitions:e}))}}):e.jsxs(n.StackView,{spacing:1,children:[e.jsx(n.Text,{color:_.neutral12,fontSize:"16px",fontWeight:600,children:"Then perform an action in..."}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,paddingHorizontal:1.75,paddingVertical:1,radius:4,border:`1px solid ${_.neutral88}`,children:[e.jsx(n.Spinner,{size:"xs"}),e.jsx(n.Text,{fontSize:16,lineHeight:2.75,children:"Loading"})]})]}),D.definitions?e.jsx(n.Alert,{marginTop:1,...st,children:e.jsx(n.Text,{children:"There was a problem looking up automations. Please contact support if the problem persists."})}):j?e.jsx(mt,{}):e.jsx(Re,{selectedOperation:k,operationDefinitions:b,onOperationDefinitionChange:e=>{C(e),H({}),P({})}})]}),k&&(D.selected_definition?e.jsx(n.Alert,{...st,children:e.jsx(n.Text,{children:"There was a problem looking up automation options. Please contact support if the problem persists."})}):e.jsxs(e.Fragment,{children:[e.jsx(et,{canAccessPeople:q,definitionFields:k.definitionFields||[],onChange:P,selectedFieldOptions:z,loadedLists:T,loadListForField:Z,loadingLists:F}),t?.label&&e.jsx(n.Checkbox,{disabled:V||lt(k,z),label:t.label,checked:W,onChange:()=>R(!W)}),u?.triggerParams?.map((t,a)=>e.jsx(n.Checkbox,{label:t.description,checked:M&&M[t.key]||t.defaultValue,onChange:e=>{E(n=>({...n,[`${t.key}`]:e.target.checked}))}},`${t.key}_${a}`)),U&&e.jsx(n.Alert,{...st,children:e.jsxs(n.StackView,{axis:"horizontal",spacing:1.5,children:[e.jsx(n.Icon,{size:3,name:"general.exclamationTriangle",color:"error"}),e.jsx(n.Text,{dangerouslySetInnerHTML:{__html:k.footerMessage?.html}})]})})]})),s&&e.jsx("pre",{children:JSON.stringify({description:k&&G(),loadedLists:T,selectedDefinition:k,selectedFieldOptions:z,triggerConditions:X},null,4)}),e.jsxs(n.StackView,{alignment:"center",axis:"horizontal",borderTop:`1px solid ${_.neutral88}`,distribution:"end",marginTop:2,marginHorizontal:-4,paddingHorizontal:4,paddingTop:3,spacing:2,children:[e.jsx(n.Button,{color:_.neutral12,"data-modal-close":!0,fontWeight:400,onClick:c,size:"md",title:"Cancel",variant:"naked"}),e.jsx(n.Button,{disabled:V||U||lt(k,z),onClick:function(){if(V)return;const e={...z};k.definitionIdentifier&&(e.definition_identifier=k.definitionIdentifier);const n={_e:d.resource,data:{attributes:{description:G(),name:u.name,operation_app_name:g,operation_definition_class_name:k.definitionClass,operation_params:e,trigger_conditions:X,trigger_params:M},type:"AutomationSubscription"}};W?S.fire({cancelButtonText:"Cancel",confirmButtonText:"Yes, perform action",text:"This will happen immediately after creating your new automation. Are you sure?",title:`${t.label}?`}).then(e=>{e.value?J(n):(B(!1),R(!1))}):J(n)},size:"md",theme:"primary",title:ut(k,z),variant:"fill","data-testid":"create-automation"})]})]})};function lt(e,t){if(e){const n=V(e.definitionFields,t),a=n.filter(e=>e.required),i=n.filter(e=>ct(e));return!a.every(e=>dt(e,t))||!i.every(e=>dt(e,t))}return!0}function ct(e){return"Select"===e.kind||"SelectSearch"===e.kind}function dt(e,t){return ct(e)?t.hasOwnProperty(e.id):t.hasOwnProperty(e.id)&&t[e.id]&&""!==t[e.id].toString().trim()}function ut(e,t){const n=function(e,t){if(!e?.definitionFields)return;const n=V(e.definitionFields,t);for(const e of n)if(e.required&&!dt(e,t))return e.description}(e,t);return e?n?`Select a${n.charAt(0).match(/[aeiou]/i)?"n":""} ${n.toLowerCase()}`:"Create automation":"Select an action"}const pt=({onOperationAppChange:t,operationApps:a,selectedApp:i})=>e.jsxs(n.StackView,{spacing:1,children:[e.jsx(n.Input.InputLabel,{color:_.neutral12,controls:"select-product",fontSize:"16px",fontWeight:600,children:"Then perform an action in..."}),e.jsx(n.Select,{autoFocus:!0,id:"select-product",onChange:({selectedValue:e})=>{t(e)},size:"lg",value:i,children:a.map(t=>e.jsx(n.Select.Option,{value:t.id,children:t.name},t.id))})]}),mt=()=>e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,paddingHorizontal:1.75,paddingVertical:1,radius:4,border:`1px solid ${_.neutral88}`,children:[e.jsx(n.Spinner,{size:"xs"}),e.jsx(n.Text,{fontSize:16,lineHeight:2.75,children:"Loading"})]});function ht({onClick:t}){return e.jsx(n.Button,{as:"button",height:2,icon:{color:_.neutral62,name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function gt({children:t,onRequestClose:a,open:i,theme:o}){/*#__PURE__*/return u.createPortal(e.jsxs(n.ThemeProvider,{theme:o,children:[e.jsxs(n.Modal,{open:i,onRequestClose:a,maxWidth:75,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:4,paddingBottom:3,radius:8,zIndex:10009,children:[e.jsxs(n.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(n.Heading,{level:2,color:_.neutral12,fontWeight:500,fontSize:"25px",lineHeight:"1.4",children:"Create automation"}),e.jsx(ht,{onClick:a})]}),t]}),e.jsx("style",{children:"\n .swal2-container.swal2-backdrop-show { z-index: 10001 }\n "})]}),document.body)}const wt=new t.Client({app:"webhooks",version:"2022-10-20"});function ft({afterCreateOptions:t,automations:i,blankStateLink:o,canCreate:s,defaultApp:r,description:l,hasActiveAutomations:c,loading:d,onPauseAutomations:u,theme:p,trigger:m}){const[h,g]=a.useState(!1),w={size:"md",theme:"primary"},f=s&&!c;return e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",backgroundColor:f?_.statusWarning94:void 0,borderBottom:f?void 0:`1px solid ${_.neutral88}`,"data-testid":"automations-header",distribution:"space-between",marginHorizontal:-3,marginBottom:2,marginTop:-3,paddingHorizontal:3,paddingVertical:2,spacing:2,wrap:!0,zIndex:2,children:[s&&!c?e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",marginHorizontal:1,spacing:1,children:[e.jsx(n.Icon,{size:2,color:_.statusWarning49,name:"general.exclamationTriangle"}),e.jsx(n.Heading,{color:_.neutral12,level:2,size:"18px",children:"Automations are currently paused"})]}):e.jsx(n.Heading,{color:_.neutral12,level:2,size:"18px",children:d?"Active automations":H(i.length,"active automation")}),s&&(c?e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[i.length>0&&e.jsx(n.Button,{onClick:u,...w,variant:"outline",children:"Pause automations"}),e.jsx(n.Button,{...w,variant:"fill",onClick:()=>g(!0),children:"Create automation"}),e.jsx(gt,{open:h,onRequestClose:()=>g(!1),theme:p,children:e.jsx(rt,{description:l,blankStateLink:o,defaultApp:r,trigger:m,onRequestClose:()=>g(!1),afterCreateOptions:t})})]}):e.jsx(n.Box,{children:e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[e.jsx(n.Button,{...w,backgroundColor:"success",hover:{backgroundColor:"success-dark"},active:{backgroundColor:"success-darker"},onClick:u,children:"Enable automations"}),e.jsx(n.Button,{...w,disabled:!0,tooltip:{title:"Automations must be enabled to create new ones"},children:"Create automation"})]})}))]})}exports.Automations=function({afterCreateOptions:t,blankStateDescription:i,blankStateLink:o="https://pcopeople.zendesk.com/hc/en-us/articles/217582148-Automations",currentPersonId:s,currentPersonCanCreate:r,defaultApp:l,incomingAutomationsParam:c,theme:d,trigger:u,currentOrganization:p,permissionDeniedReason:m="You need permissions of Editor or above to add an automation."}){a.useEffect(()=>{if(!u)return f(!1);(function(e){try{return Promise.resolve(ze.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,events_status,trigger_params",Person:"name"},include:"created_by"},url:"automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}})(u.resource).then(Se).then(Pe).then(P).then(g).then(()=>f(!1))},[u?.resource]);const[h,g]=a.useState([]),[w,f]=a.useState(!0),[x,b]=a.useState(!1),{dateFormat:k,twentyFourHourTime:C,olsonTimeZone:S}=p,T=new URLSearchParams(window.location.search).get("automation_id"),O={...d,icons:{...z}};a.useEffect(()=>{document.body.toggleAttribute("data-loading-automations",w)},[w]);const A=!h.length||h.some(e=>e.active);function I(e){wt.delete({data:{_e:u.resource},url:`/automation_subscriptions/${e}`}).then(()=>g(h.filter(t=>t.id!==e))).catch(()=>y.fire({text:"There was a problem deleting this automation. Please try again in a few moments.",title:"Uh oh!"}))}const F={color:_.neutral24,level:2,size:"25px",weight:700},$={color:_.neutral45,lineHeight:3,size:3};return e.jsxs(n.ThemeProvider,{theme:O,children:[e.jsxs(j.Provider,{value:{dateFormat:k,olsonTimeZone:S,twentyFourHourTime:C},children:[u&&e.jsx(ft,{automations:h,blankStateLink:o,canCreate:r,loading:w,defaultApp:l,description:i,theme:O,trigger:u,hasActiveAutomations:A,onPauseAutomations:function(){wt.post({data:{data:{attributes:{_e:u.resource,active:!A}}},url:"/pause_automations"}).then(()=>{window.location.reload()})},afterCreateOptions:t}),w?e.jsx(n.Summary,{image:e.jsx(n.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading automations..."}):u?e.jsx(n.Box,{"data-testid":"automations-section",children:h?.length>0?e.jsx(n.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:h.map(t=>{return e.jsx(de,{automation:t,onDelete:I,theme:O,openHistoryNow:t.id===Number(T),trigger:{event:(n=t,u.events.find(e=>e.name===n.name)),resource:u.resource},currentPersonId:s,currentPersonCanCreate:r},t.id);var n})}):e.jsxs(n.StackView,{margin:6,spacing:2,alignment:"center",mediaQueries:{lg:{axis:"horizontal",distribution:"center",spacing:6}},children:[e.jsx(n.Box,{css:{".symbol":{height:"100%",width:"100%"}},maxWidth:24,mediaQueries:{lg:{maxWidth:40}},children:e.jsx(v,{})}),e.jsx(n.StackView,{alignment:"center",spacing:1,maxWidth:45,mediaQueries:{lg:{alignment:"start",textAlign:"left"}},textAlign:"center",children:e.jsxs(e.Fragment,r?{children:[e.jsx(n.Heading,{...F,children:"Add an automation"}),e.jsx(n.StackView,{alignment:"center",marginBottom:1,mediaQueries:{lg:{alignment:"start"}},spacing:1,children:e.jsxs(n.Text,{...$,children:[i," ",e.jsx(n.Link,{inline:!0,external:!0,to:o,children:"Learn more"}),"."]})}),e.jsx(n.Button,{as:"button",theme:"primary",variant:"fill",onClick:()=>b(!0),children:"Create automation"}),e.jsx(gt,{open:x,onRequestClose:()=>b(!1),theme:O,children:e.jsx(rt,{defaultApp:l,description:i,blankStateLink:o,onRequestClose:()=>b(!1),trigger:u,afterCreateOptions:t})})]}:{children:[e.jsx(n.Heading,{...F,children:"Automations"}),e.jsx(n.Text,{...$,children:m})]})})]})}):e.jsx(e.Fragment,{}),c&&e.jsx(Le,{encryptedParam:c,trigger:u})]}),e.jsx("style",{children:'.swal2-popup.swal2-toast{align-items:stretch;background:#fff;box-shadow:0 0 .625em #d9d9d9;flex-direction:column;overflow-y:hidden;padding:1.25em;width:auto}.swal2-popup.swal2-toast .swal2-header{flex-direction:row;padding:0}.swal2-popup.swal2-toast .swal2-title{flex-grow:1;font-size:1em;justify-content:flex-start;margin:0 .625em}.swal2-popup.swal2-toast .swal2-loading{justify-content:center}.swal2-popup.swal2-toast .swal2-input{font-size:1em;height:2em;margin:.3125em auto}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em}.swal2-popup.swal2-toast .swal2-footer{font-size:.8em;margin:.5em 0 0;padding:.5em 0 0}.swal2-popup.swal2-toast .swal2-close{height:.8em;line-height:.8;position:static;width:.8em}.swal2-popup.swal2-toast .swal2-content{font-size:1em;justify-content:flex-start;margin:0 .625em;padding:0;text-align:initial}.swal2-popup.swal2-toast .swal2-html-container{padding:.625em 0 0}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0}.swal2-popup.swal2-toast .swal2-icon{height:2em;margin:0 .5em 0 0;min-width:2em;width:2em}.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{align-items:center;display:flex;font-size:1.8em;font-weight:700}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{font-size:.25em}}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{height:2em;width:2em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-popup.swal2-toast .swal2-actions{align-self:stretch;flex:1;flex-basis:auto!important;height:2.2em;height:auto;margin:.3125em .3125em 0;padding:0;width:auto}.swal2-popup.swal2-toast .swal2-styled{font-size:1em;margin:.125em .3125em;padding:.3125em .625em}.swal2-popup.swal2-toast .swal2-styled:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px rgba(100,150,200,.5)}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{border-radius:50%;height:3em;position:absolute;transform:rotate(45deg);width:1.6em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:4em 0 0 4em;left:-.5em;top:-.8em;transform:rotate(-45deg);transform-origin:2em 2em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 4em 4em 0;left:.9375em;top:-.25em;transform-origin:0 1.5em}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{height:2em;width:2em}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{height:2.6875em;left:.4375em;top:0;width:.4375em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{left:.1875em;top:1.125em;width:.75em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{right:.1875em;top:.9375em;width:1.375em}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}.swal2-popup.swal2-toast.swal2-show{animation:swal2-toast-show .5s}.swal2-popup.swal2-toast.swal2-hide{animation:swal2-toast-hide .1s forwards}.swal2-container{-webkit-overflow-scrolling:touch;align-items:center;bottom:0;display:flex;flex-direction:row;justify-content:center;left:0;overflow-x:hidden;padding:16px;position:fixed;right:0;top:0;transition:background-color .1s;z-index:1060}.swal2-container.swal2-backdrop-show,.swal2-container.swal2-noanimation{background:rgba(0,0,0,.4)}.swal2-container.swal2-backdrop-hide{background:transparent!important}.swal2-container.swal2-top{align-items:flex-start}.swal2-container.swal2-top-left,.swal2-container.swal2-top-start{align-items:flex-start;justify-content:flex-start}.swal2-container.swal2-top-end,.swal2-container.swal2-top-right{align-items:flex-start;justify-content:flex-end}.swal2-container.swal2-center{align-items:center}.swal2-container.swal2-center-left,.swal2-container.swal2-center-start{align-items:center;justify-content:flex-start}.swal2-container.swal2-center-end,.swal2-container.swal2-center-right{align-items:center;justify-content:flex-end}.swal2-container.swal2-bottom{align-items:flex-end}.swal2-container.swal2-bottom-left,.swal2-container.swal2-bottom-start{align-items:flex-end;justify-content:flex-start}.swal2-container.swal2-bottom-end,.swal2-container.swal2-bottom-right{align-items:flex-end;justify-content:flex-end}.swal2-container.swal2-bottom-end>:first-child,.swal2-container.swal2-bottom-left>:first-child,.swal2-container.swal2-bottom-right>:first-child,.swal2-container.swal2-bottom-start>:first-child,.swal2-container.swal2-bottom>:first-child{margin-top:auto}.swal2-container.swal2-grow-fullscreen>.swal2-modal{align-self:stretch;display:flex!important;flex:1;justify-content:center}.swal2-container.swal2-grow-row>.swal2-modal{align-content:center;display:flex!important;flex:1;justify-content:center}.swal2-container.swal2-grow-column{flex:1;flex-direction:column}.swal2-container.swal2-grow-column.swal2-bottom,.swal2-container.swal2-grow-column.swal2-center,.swal2-container.swal2-grow-column.swal2-top{align-items:center}.swal2-container.swal2-grow-column.swal2-bottom-left,.swal2-container.swal2-grow-column.swal2-bottom-start,.swal2-container.swal2-grow-column.swal2-center-left,.swal2-container.swal2-grow-column.swal2-center-start,.swal2-container.swal2-grow-column.swal2-top-left,.swal2-container.swal2-grow-column.swal2-top-start{align-items:flex-start}.swal2-container.swal2-grow-column.swal2-bottom-end,.swal2-container.swal2-grow-column.swal2-bottom-right,.swal2-container.swal2-grow-column.swal2-center-end,.swal2-container.swal2-grow-column.swal2-center-right,.swal2-container.swal2-grow-column.swal2-top-end,.swal2-container.swal2-grow-column.swal2-top-right{align-items:flex-end}.swal2-container.swal2-grow-column>.swal2-modal{align-content:center;display:flex!important;flex:1;justify-content:center}.swal2-container.swal2-no-transition{transition:none!important}.swal2-container:not(.swal2-top):not(.swal2-top-start):not(.swal2-top-end):not(.swal2-top-left):not(.swal2-top-right):not(.swal2-center-start):not(.swal2-center-end):not(.swal2-center-left):not(.swal2-center-right):not(.swal2-bottom):not(.swal2-bottom-start):not(.swal2-bottom-end):not(.swal2-bottom-left):not(.swal2-bottom-right):not(.swal2-grow-fullscreen)>.swal2-modal{margin:auto}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.swal2-container .swal2-modal{margin:0!important}}.swal2-popup{background:#fff;border:none;border-radius:5px;box-sizing:border-box;display:none;flex-direction:column;font-family:inherit;font-size:1rem;justify-content:center;max-width:100%;padding:24px 24px 20px;position:relative;width:512px}.swal2-popup:focus{outline:none}.swal2-popup.swal2-loading{overflow-y:hidden}.swal2-header{align-items:center;display:flex;flex-direction:column;padding:0 1.8em}.swal2-title{word-wrap:break-word;color:#595959;font-size:25px;font-weight:600;margin:0 0 18px;max-width:100%;padding:0;position:relative;text-align:center;text-transform:none}.swal2-actions{align-items:center;box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:center;margin:40px auto 0;padding:12px 0 0;width:100%;z-index:1}.swal2-actions:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}.swal2-actions:not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1))}.swal2-actions:not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0,0,0,.2),rgba(0,0,0,.2))}.swal2-loader{align-items:center;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-color:#2778c4 transparent;border-radius:100%;border-style:solid;border-width:.25em;display:none;height:2.2em;justify-content:center;margin:0 1.875em;width:2.2em}.swal2-styled{box-shadow:none;font-weight:400;margin:4px;padding:8px 24px}.swal2-styled:not([disabled]){cursor:pointer}.swal2-styled.swal2-confirm{background:initial;background-color:#1f93ff;border:0;border-radius:3px;color:#fff;font-size:16px}.swal2-styled.swal2-deny{background:initial;background-color:#e75146;border:0;border-radius:3px;color:#fff;font-size:16px}.swal2-styled.swal2-cancel{background:initial;background-color:transparent;border:0;border-radius:3px;color:#848484;font-size:16px}.swal2-styled:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5);outline:none}.swal2-styled::-moz-focus-inner{border:0}.swal2-footer{border-top:1px solid #eee;color:#545454;font-size:1em;justify-content:center;margin:1.25em 0 0;padding:1em 0 0}.swal2-timer-progress-bar-container{border-bottom-left-radius:5px;border-bottom-right-radius:5px;bottom:0;height:.25em;left:0;overflow:hidden;position:absolute;right:0}.swal2-timer-progress-bar{background:rgba(0,0,0,.2);height:.25em;width:100%}.swal2-image{margin:24px auto 26px;max-width:100%}.swal2-close{align-items:center;background:transparent;border:none;border-radius:5px;color:#ccc;cursor:pointer;font-family:serif;font-size:2.5em;height:1.2em;justify-content:center;line-height:1.2;overflow:hidden;padding:0;position:absolute;right:0;top:0;transition:color .1s ease-out;width:1.2em;z-index:2}.swal2-close:hover{background:transparent;color:#f27474;transform:none}.swal2-close:focus{box-shadow:inset 0 0 0 3px rgba(100,150,200,.5);outline:none}.swal2-close::-moz-focus-inner{border:0}.swal2-content{word-wrap:break-word;color:#848484;font-size:16px;font-weight:400;justify-content:center;line-height:1.4em;margin:-5px 0;padding:0 1.6em;text-align:center;z-index:1}.swal2-checkbox,.swal2-file,.swal2-input,.swal2-radio,.swal2-select,.swal2-textarea{margin:1em auto}.swal2-file,.swal2-input,.swal2-textarea{background:inherit;border:1px solid #d9d9d9;border-radius:.1875em;box-shadow:inset 0 1px 1px rgba(0,0,0,.06);box-sizing:border-box;color:inherit;font-size:1.125em;transition:border-color .3s,box-shadow .3s;width:100%}.swal2-file.swal2-inputerror,.swal2-input.swal2-inputerror,.swal2-textarea.swal2-inputerror{border-color:#f27474!important;box-shadow:0 0 2px #f27474!important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{border:1px solid #b4dbed;box-shadow:0 0 0 3px rgba(100,150,200,.5);outline:none}.swal2-file::-moz-placeholder,.swal2-input::-moz-placeholder,.swal2-textarea::-moz-placeholder{color:#ccc}.swal2-file::placeholder,.swal2-input::placeholder,.swal2-textarea::placeholder{color:#ccc}.swal2-range{background:#fff;margin:1em auto}.swal2-range input{width:80%}.swal2-range output{color:inherit;font-weight:600;text-align:center;width:20%}.swal2-range input,.swal2-range output{font-size:1.125em;height:2.625em;line-height:2.625em;padding:0}.swal2-input{height:2.625em;padding:0 .75em}.swal2-input[type=number]{max-width:10em}.swal2-file{background:inherit;font-size:1.125em}.swal2-textarea{height:6.75em;padding:.75em}.swal2-select{background:inherit;color:inherit;font-size:1.125em;max-width:100%;min-width:50%;padding:.375em .625em}.swal2-checkbox,.swal2-radio{align-items:center;background:#fff;color:inherit;justify-content:center}.swal2-checkbox label,.swal2-radio label{font-size:1.125em;margin:0 .6em}.swal2-checkbox input,.swal2-radio input{flex-shrink:0;margin:0 .4em}.swal2-input-label{display:flex;justify-content:center;margin:1em auto}.swal2-validation-message{align-items:center;background:#f0f0f0;color:#666;font-size:1em;font-weight:300;justify-content:center;margin:0 -2.7em;overflow:hidden;padding:.625em}.swal2-validation-message:before{background-color:#f27474;border-radius:50%;color:#fff;content:"!";display:inline-block;font-weight:600;height:1.5em;line-height:1.5em;margin:0 .625em;min-width:1.5em;text-align:center;width:1.5em}.swal2-icon{border:.25em solid #000;border-radius:50%;box-sizing:content-box;cursor:default;font-family:inherit;height:5em;justify-content:center;line-height:5em;margin:24px auto 32px;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:5em}.swal2-icon .swal2-icon-content{align-items:center;display:flex;font-size:3.75em}.swal2-icon.swal2-error{border-color:#f27474;color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{flex-grow:1;position:relative}.swal2-icon.swal2-error [class^=swal2-x-mark-line]{background-color:#f27474;border-radius:.125em;display:block;height:.3125em;position:absolute;top:2.3125em;width:2.9375em}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}.swal2-icon.swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}.swal2-icon.swal2-warning{border-color:#facea8;color:#f8bb86}.swal2-icon.swal2-info{border-color:#9de0f6;color:#3fc3ee}.swal2-icon.swal2-question{border-color:#c9dae1;color:#87adbd}.swal2-icon.swal2-success{border-color:#a5dc86;color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{border-radius:50%;height:7.5em;position:absolute;transform:rotate(45deg);width:3.75em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:7.5em 0 0 7.5em;left:-2.0635em;top:-.4375em;transform:rotate(-45deg);transform-origin:3.75em 3.75em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 7.5em 7.5em 0;left:1.875em;top:-.6875em;transform:rotate(-45deg);transform-origin:0 3.75em}.swal2-icon.swal2-success .swal2-success-ring{border:.25em solid hsla(98,55%,69%,.3);border-radius:50%;box-sizing:content-box;height:100%;left:-.25em;position:absolute;top:-.25em;width:100%;z-index:2}.swal2-icon.swal2-success .swal2-success-fix{height:5.625em;left:1.625em;position:absolute;top:.5em;transform:rotate(-45deg);width:.4375em;z-index:1}.swal2-icon.swal2-success [class^=swal2-success-line]{background-color:#a5dc86;border-radius:.125em;display:block;height:.3125em;position:absolute;z-index:2}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{left:.8125em;top:2.875em;transform:rotate(45deg);width:1.5625em}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{right:.5em;top:2.375em;transform:rotate(-45deg);width:2.9375em}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}.swal2-progress-steps{align-items:center;background:inherit;flex-wrap:wrap;font-weight:600;margin:0 0 1.25em;max-width:100%;padding:0}.swal2-progress-steps li{display:inline-block;position:relative}.swal2-progress-steps .swal2-progress-step{background:#2778c4;border-radius:2em;color:#fff;flex-shrink:0;height:2em;line-height:2em;text-align:center;width:2em;z-index:20}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:#add8e6;color:#fff}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:#add8e6}.swal2-progress-steps .swal2-progress-step-line{background:#2778c4;flex-shrink:0;height:.4em;margin:0 -1px;width:2.5em;z-index:10}[class^=swal2]{-webkit-tap-highlight-color:transparent}.swal2-hide,.swal2-show{animation:none}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{height:50px;overflow:scroll;position:absolute;top:-9999px;width:50px}.swal2-rtl .swal2-close{left:0;right:auto}.swal2-rtl .swal2-timer-progress-bar{left:auto;right:0}@supports (-ms-accelerator:true){.swal2-range input{width:100%!important}.swal2-range output{display:none}}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.swal2-range input{width:100%!important}.swal2-range output{display:none}}@keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotate(2deg)}33%{transform:translateY(0) rotate(-2deg)}66%{transform:translateY(.3125em) rotate(2deg)}to{transform:translateY(0) rotate(0deg)}}@keyframes swal2-toast-hide{to{opacity:0;transform:rotate(1deg)}}@keyframes swal2-toast-animate-success-line-tip{0%{left:.0625em;top:.5625em;width:0}54%{left:.125em;top:.125em;width:0}70%{left:-.25em;top:.625em;width:1.625em}84%{left:.75em;top:1.0625em;width:.5em}to{left:.1875em;top:1.125em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{right:1.375em;top:1.625em;width:0}65%{right:.9375em;top:1.25em;width:0}84%{right:0;top:.9375em;width:1.125em}to{right:.1875em;top:.9375em;width:1.375em}}@keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}to{transform:scale(1)}}@keyframes swal2-hide{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.5)}}@keyframes swal2-animate-success-line-tip{0%{left:.0625em;top:1.1875em;width:0}54%{left:.125em;top:1.0625em;width:0}70%{left:-.375em;top:2.1875em;width:3.125em}84%{left:1.3125em;top:3em;width:1.0625em}to{left:.8125em;top:2.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{right:2.875em;top:3.375em;width:0}65%{right:2.875em;top:3.375em;width:0}84%{right:0;top:2.1875em;width:3.4375em}to{right:.5em;top:2.375em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}to{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;opacity:0;transform:scale(.4)}50%{margin-top:1.625em;opacity:0;transform:scale(.4)}80%{margin-top:-.375em;transform:scale(1.15)}to{margin-top:0;opacity:1;transform:scale(1)}}@keyframes swal2-animate-error-icon{0%{opacity:0;transform:rotateX(100deg)}to{opacity:1;transform:rotateX(0deg)}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;bottom:auto;left:auto;max-width:calc(100% - 32px);right:auto;top:auto}body.swal2-no-backdrop .swal2-container>.swal2-modal{box-shadow:0 0 10px rgba(0,0,0,.4)}body.swal2-no-backdrop .swal2-container.swal2-top{left:50%;top:0;transform:translateX(-50%)}body.swal2-no-backdrop .swal2-container.swal2-top-left,body.swal2-no-backdrop .swal2-container.swal2-top-start{left:0;top:0}body.swal2-no-backdrop .swal2-container.swal2-top-end,body.swal2-no-backdrop .swal2-container.swal2-top-right{right:0;top:0}body.swal2-no-backdrop .swal2-container.swal2-center{left:50%;top:50%;transform:translate(-50%,-50%)}body.swal2-no-backdrop .swal2-container.swal2-center-left,body.swal2-no-backdrop .swal2-container.swal2-center-start{left:0;top:50%;transform:translateY(-50%)}body.swal2-no-backdrop .swal2-container.swal2-center-end,body.swal2-no-backdrop .swal2-container.swal2-center-right{right:0;top:50%;transform:translateY(-50%)}body.swal2-no-backdrop .swal2-container.swal2-bottom{bottom:0;left:50%;transform:translateX(-50%)}body.swal2-no-backdrop .swal2-container.swal2-bottom-left,body.swal2-no-backdrop .swal2-container.swal2-bottom-start{bottom:0;left:0}body.swal2-no-backdrop .swal2-container.swal2-bottom-end,body.swal2-no-backdrop .swal2-container.swal2-bottom-right{bottom:0;right:0}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static!important}}body.swal2-toast-shown .swal2-container{background-color:transparent}body.swal2-toast-shown .swal2-container.swal2-top{bottom:auto;left:50%;right:auto;top:0;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{bottom:auto;left:auto;right:0;top:0}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{bottom:auto;left:0;right:auto;top:0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{bottom:auto;left:0;right:auto;top:50%;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{bottom:auto;left:50%;right:auto;top:50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{bottom:auto;left:auto;right:0;top:50%;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{bottom:0;left:0;right:auto;top:auto}body.swal2-toast-shown .swal2-container.swal2-bottom{bottom:0;left:50%;right:auto;top:auto;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{bottom:0;left:auto;right:0;top:auto}.swal2-actions{border-top:1px solid #e0e0e0}'})]})};
|
|
1
|
+
var e=require("react/jsx-runtime"),t=require("@planningcenter/api-client"),n=require("@planningcenter/tapestry-react"),a=require("react"),i=require("lodash"),o=require("moment"),s=require("@planningcenter/sweetalert2"),r=require("sweetalert2/dist/sweetalert2"),l=require("@planningcenter/icons/paths/church-center"),c=require("@planningcenter/icons/paths/logomark"),d=require("@planningcenter/icons/paths/services"),u=require("react-dom");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function m(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,t}var h=/*#__PURE__*/p(a),g=/*#__PURE__*/p(o),w=/*#__PURE__*/p(r),f=/*#__PURE__*/m(l),x=/*#__PURE__*/m(c),b=/*#__PURE__*/m(d);const v=()=>e.jsxs("svg",{id:"automations_blank","data-name":"Automations Blank",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 111.112 84.832",className:"symbol",children:[e.jsx("title",{children:"people-automations"}),e.jsx("g",{opacity:"0.6",children:e.jsx("path",{d:"M107.784,46.051A57.416,57.416,0,0,1,85.26,75.058c-9.7,6.247-20.045,7.792-31.912,5.185-11.74-2.638-23.339-8-32.92-13.088-9.51-5.342-17-10.236-18.863-17.925C-.26,41.753,3.737,31.4,13.347,21.194,22.85,11.162,37.968,1.853,55.948.321,73.8-1.476,90.2,4.478,99.608,13.164,109.257,21.9,111.921,33.784,107.784,46.051Z",fill:"#e1f0f9"})}),e.jsxs("g",{opacity:"0.2",children:[e.jsx("path",{d:"M63.086,84.317A43.515,43.515,0,0,1,42.87,79C34.056,74.379,24.712,67.422,14.3,57.728,6.616,50.227.284,43.348.489,35c.13-5.851,3.789-12.312,10.3-18.189l.951,1.054c-6.222,5.613-9.715,11.71-9.837,17.169C1.717,42.811,7.85,49.448,15.278,56.7c10.307,9.6,19.551,16.481,28.248,21.039,9.043,4.684,17.715,6.156,26.513,4.5l.262,1.4A38.914,38.914,0,0,1,63.086,84.317Z",fill:"#bac7d3"}),e.jsx("path",{d:"M81.105,80.147l-.587-1.292a56.6,56.6,0,0,0,23.515-19.828l1.183.786A58.03,58.03,0,0,1,81.105,80.147Z",fill:"#bac7d3"}),e.jsx("path",{d:"M110.025,49.27l-1.374-.356a28.351,28.351,0,0,0-4.014-22.991C97.189,14.135,82.488,5.177,66.267,2.538A66.6,66.6,0,0,0,25.738,8.55l-.622-1.275a68,68,0,0,1,41.39-6.136c16.6,2.7,31.672,11.905,39.327,24.019A29.732,29.732,0,0,1,110.025,49.27Z",fill:"#bac7d3"})]}),e.jsx("path",{d:"M81,27.269v31.8a2.685,2.685,0,0,1-2.685,2.685H44.564a2.685,2.685,0,0,1-2.685-2.685V15.425a2.685,2.685,0,0,1,2.685-2.685h21.91a2.681,2.681,0,0,1,1.9.786L80.217,25.371A2.685,2.685,0,0,1,81,27.269Z",fill:"#fff"}),e.jsx("path",{d:"M68.479,13.633v9.8a2.035,2.035,0,0,0,2.035,2.034h9.877Z",fill:"#c9d8e2"}),e.jsx("rect",{x:"51.214",y:"41.285",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"48.434",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"51.214",y:"34.136",width:"20.221",height:"2.791",rx:"1.395",ry:"1.395",fill:"#dae5ed"}),e.jsx("rect",{x:"11.771",y:"44.005",width:"50.915",height:"6.664",transform:"translate(-22.93 44.557) rotate(-49.171)",fill:"#454942"}),e.jsx("path",{d:"M56.283,30.38l-7.557,8.745a5.968,5.968,0,0,0-2.005-2.734,6.292,6.292,0,0,0-3.036-1.624l7.555-8.743a6.275,6.275,0,0,1,3.038,1.624A5.959,5.959,0,0,1,56.283,30.38Z",fill:"#fcc846"}),e.jsx("path",{d:"M58.088,28.29l-7.556,8.745a5.968,5.968,0,0,0-2-2.734,6.3,6.3,0,0,0-3.036-1.624l7.555-8.743a6.274,6.274,0,0,1,3.037,1.624A5.959,5.959,0,0,1,58.088,28.29Z",fill:"#48a5e5"}),e.jsx("path",{d:"M58.724,10.432l1.17,2.7a2.129,2.129,0,0,0,1.4,1.207l2.843.765a.73.73,0,0,1,.1,1.375l-2.7,1.17a2.125,2.125,0,0,0-1.207,1.4L59.56,21.89a.73.73,0,0,1-1.374.1l-1.17-2.7a2.125,2.125,0,0,0-1.4-1.206l-2.843-.766a.73.73,0,0,1-.1-1.374l2.7-1.17a2.121,2.121,0,0,0,1.206-1.4l.766-2.844A.73.73,0,0,1,58.724,10.432Z",fill:"#fcc846"}),e.jsx("path",{d:"M44.544,19.294l1.024.868a.968.968,0,0,0,.814.21l1.316-.261a.333.333,0,0,1,.319.541l-.868,1.024a.968.968,0,0,0-.21.814l.261,1.316a.333.333,0,0,1-.541.319l-1.024-.868a.968.968,0,0,0-.814-.21l-1.316.261a.333.333,0,0,1-.319-.541l.868-1.024a.967.967,0,0,0,.21-.814L44,19.613A.333.333,0,0,1,44.544,19.294Z",fill:"#fcc846"}),e.jsx("path",{d:"M64.223,25.729l.869,2.005a1.575,1.575,0,0,0,1.036.895l2.109.568a.542.542,0,0,1,.075,1.02l-2,.868a1.576,1.576,0,0,0-.9,1.036l-.568,2.11a.541.541,0,0,1-1.019.074L62.955,32.3a1.572,1.572,0,0,0-1.036-.895l-2.109-.568a.542.542,0,0,1-.075-1.02l2.005-.868a1.572,1.572,0,0,0,.895-1.036L63.2,25.8A.541.541,0,0,1,64.223,25.729Z",fill:"#fcc846"})]}),j=/*#__PURE__*/a.createContext({dateFormat:null,olsonTimeZone:null,twentyFourHourTime:null});w.default.mixin(s.standardAlertOptions),w.default.mixin(s.successAlertOptions);const y=w.default.mixin(s.errorAlertOptions),k=w.default.mixin(s.standardConfirmOptions),C=w.default.mixin(s.destroyConfirmOptions),S=w.default.mixin(s.createConfirmOptions),z={churchCenter:f,logomark:x,services:b},_={givingBrand31:"hsl(36, 100%, 31%)",neutral12:"hsl(0, 0%, 12%)",neutral24:"hsl(0, 0%, 24%)",neutral45:"hsl(0, 0%, 45%)",neutral62:"hsl(0, 0%, 62%)",neutral68:"hsl(0, 0%, 68%)",neutral88:"hsl(0, 0%, 88%)",neutral98:"hsl(0, 0%, 98%)",statusCreate23:"hsl(86, 91%, 23%)",statusCreate27:"hsl(86, 91%, 27%)",statusCreate35:"hsl(86, 91%, 35%)",statusDelete43:"hsl(9, 61%, 43%)",statusDelete47:"hsl(8, 60%, 47%)",statusWarning49:"hsl(42, 84%, 49%)",statusWarning63:"hsl(42, 84%, 63%)",statusWarning94:"hsl(42, 87%, 94%)"},P=function(e){try{return Promise.all(e.map(function(e){try{const t=function(){if(function(e){return["AddToWorkflowOperationDefinition","CustomFieldBooleanOperationDefinition","CustomFieldCheckboxesOperationDefinition","CustomFieldDateOperationDefinition","CustomFieldNumberOperationDefinition","CustomFieldSelectOperationDefinition","CustomFieldStringOperationDefinition","CustomFieldTextOperationDefinition"].includes(e.operationDefinitionClassName)}(e))return Promise.resolve(function(e){try{function t(){return n||e.description}let n="";const a=function(){if("AddToWorkflowOperationDefinition"===e.operationDefinitionClassName)return Promise.resolve(function(e){try{return Promise.resolve(O.get({data:{fields:{Workflow:"name,archived_at"},where:{id:e}},url:"workflows"}).catch(()=>[{data:{name:""}}])).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(e.operationParams.workflowId)).then(function(t){const a=t[0];if(a?.name){let t;t=a.archivedAt?`[archived] ${a.name}`:a.name,n=e.description.replace("[Hidden Workflow]",t)}});{const t=e.operationParams.definitionIdentifier.match(/(\d+)_field_definition/)[1];return Promise.resolve(function(e){try{return Promise.resolve(O.get({data:{fields:{FieldDefinition:"name,data_type,field_options",FieldOption:"value"},include:"field_options"},url:`field_definitions/${e}`}).catch(()=>({data:{name:""}}))).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}}(t)).then(function(t){t.name&&(n=e.description.replace("[Hidden Custom Field]",t.name),n+=e.operationParams.values||"checkboxes"!==t.dataType?` (${function(e,t){switch(t.dataType){case"checkboxes":return Object.entries(e.operationParams.values).map(([e,n])=>{const a=t.fieldOptions.find(t=>t.id===parseInt(e,10))?.value||"[Hidden value]";return`${T(n)} ${a}`}).join(", ");case"select":return e.operationParams.value?t.fieldOptions.find(t=>t.id===parseInt(e.operationParams.value.toString(),10))?.value||"[Hidden value]":"Unanswered";case"boolean":switch(e.operationParams.value){case"true":return"Yes";case"false":return"No";default:return"Unanswered"}default:return e.operationParams.value??"Unanswered"}}(e,t)})`:"")})}}();return Promise.resolve(a&&a.then?a.then(t):t())}catch(i){return Promise.reject(i)}}(e)).then(function(t){e.description=t})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function T(e){return e.charAt(0).toUpperCase()+e.slice(1)}const O=new t.Client({app:"people",version:"2022-07-14"});function A(e){return e.listClass?`${e.id}_${e.listClass}`:"PersonSearch"===e.kind?`${e.id}_PersonSearch`:null}function I(e){if(e.definitionClass.match(/^CustomField\w+OperationDefinition$/))return"Update [Hidden Custom Field]"}function F(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $({field:e,loadedLists:t}){if(e.list)return e.list;if(A(e))return t[A(e)];throw new Error(`Don't know how to get list for ${JSON.stringify(e)}`)}function V(e,t){return e.filter(e=>{if(Object.prototype.hasOwnProperty.call(e,"renderIf")){const n=e.renderIf,a=Object.keys(n)[0];return i.isBoolean(n)?n:n[a]===t[a]}return!0})}function L({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n,description:a}){if("AddToWorkflowOperationDefinition"===e.definitionClass){const e=n.workflow_id_WorkflowsList,i=e&&e.find(e=>e.value.toString()===t.workflow_id)?.description;return a.replace(i,"[Hidden Workflow]")}return e.definitionClass.match(/^CustomField\w+OperationDefinition$/)?"":a}({description:e.definitionFields.map(e=>{if(!F(t,e.id))return null;const a=t[e.id];let i;switch(e.kind){case"Select":case"SelectSearch":case"PersonSearch":case"RadioButtons":return i=$({field:e,loadedLists:n}),i&&i.find(e=>e.value.toString()===a)?.description;case"Checkbox":return a&&e.label;case"Checkboxes":return i=$({field:e,loadedLists:n}),i.filter(e=>F(a,e.value)).map(e=>`${T(a[e.value])} ${e.description}`).join(", ");case"NumberField":case"TextField":case"TextArea":case"DateField":return a;default:throw new Error(`Don't know how to build value for field with kind ${e.kind}`)}}).filter(e=>e).join(", "),loadedLists:n,selectedDefinition:e,selectedFieldOptions:t})}function B(e){return e.replace(/%m/,"MM").replace(/%d/,"DD").replace(/%Y/,"YYYY").replace(/%y/,"YY")}function D(e,t){const n=g.default(e,"YYYY-MM-DD");if(!n.isValid())return"";const a=B(t);return n.format(a)}function H(e,t){return 1===e?`1 ${t}`:`${e} ${t}s`}function W(e){return e.replace(/s$/,"")}function R(e){const t=e.split("/");return{appName:t[0],resourceId:t[t.length-1],resourcePath:t.slice(2,-1).join("/"),resourceType:t[t.length-2]}}const M=function(e){try{const t=e.data.map(e=>X(e));return Promise.resolve(function(n,a){try{var i=Promise.resolve(E(t)).then(function(t){return{events:e,people:t}})}catch(e){return a()}return i&&i.then?i.then(void 0,a):i}(0,function(){return{events:e,people:[]}}))}catch(e){return Promise.reject(e)}},E=function(e){try{return Promise.resolve(Y.get({data:{fields:{Person:"id,name"},where:{id:e.join(",")}},url:"people"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},N=function(e,t,n){try{return Promise.resolve(q.get({data:{_e:e,fields:{Delivery:"status,response_body,created_at",Event:"id,created_at,last_delivery,payload,status,uuid,person"},include:"last_delivery",order:"-created_at",...n},url:`automation_subscriptions/${t}/events`}))}catch(e){return Promise.reject(e)}},q=new t.Client({app:"webhooks",version:"2022-10-20"}),Y=new t.Client({app:"people",version:"2022-07-14"}),U={delivered:{label:"Success",value:["delivered"]},failed:{label:"Failed",value:["failed","duplicated"]},ignored:{label:"Ignored",value:["ignored_duplicated","ignored_failed","ignored_skipped"]},pending:{label:"Pending",value:["pending"]},skipped:{label:"Paused",value:["skipped"]}};function Z({events:e,people:t}){const n=e.data.reduce((e,n)=>{const a=X(n),i=t.find(e=>a.toString()===e.id.toString());return e.push(i?{...n,person:{id:i.id,name:i.name}}:{...n,person:{id:a,name:"[Hidden]"}}),e},[]);return{...e,data:n}}function X(e){return e.personId}function Q({automation:t,triggerResource:i,filterWhere:o,onEventsStatusChange:s}){const{events:r,loading:l,paginationProps:c,refresh:d,params:u,setParams:p}=function(e,t,n){const[i,o]=a.useState(),[s,r]=a.useState(!1),[l,c]=a.useState({}),[d,u]=a.useState(n?{where:{status:n}}:{}),[p,m]=a.useState(),{offset:h,paginationProps:g,resetOffset:w}=function(e,t){const[n,i]=a.useState(0);return{offset:n,paginationProps:{currentPage:Math.floor(n/50)+1,onPageChange:function(e){i(50*(e-1))},totalPages:Math.ceil(t/50)},resetOffset:a.useCallback(()=>{i(0)},[])}}(0,p?.totalCount);a.useEffect(()=>{s||l[h]||(r(!0),N(t,e,{offset:h,per_page:50,...d}).then(M).then(Z).then(e=>{c(t=>({...t,[h]:e.data})),m(e.meta),r(!1)}).catch(x))},[e,t,s,d,h,l]);const f=a.useCallback(()=>{c({}),m(void 0),w()},[w]);function x(e){o(()=>{throw e})}return a.useEffect(()=>{f()},[f,d]),{events:l[h]||[],loading:s,paginationProps:g,params:d,refresh:f,setParams:u}}(t.id,i,o),{dateFormat:m,olsonTimeZone:h,twentyFourHourTime:w}=a.useContext(j),f=u.where&&Object.keys(u.where).length>0,x=function(e){const t=g.default(e,"YYYY-MM-DD");return g.default().diff(t,"days")}(t.createdAt)<=32,b=D(t.createdAt,m),y=x?`Automation history started on ${b}`:"Automation history is saved for 32 days",k=[{cell:t=>e.jsx(K,{status:t.status}),css:{padding:"8px 12px"},header:"Status"},{cell:e=>g.default(e.createdAt).utcOffset(h).format(function({dateFormat:e,twentyFourHourTime:t}){return`${B(e)} ${t?"HH:mm":"h:mm A"}`}({dateFormat:m,twentyFourHourTime:w})),header:"Date and time"},{cell:t=>e.jsx(n.Link,{to:`/people/AC${t.person.id}`,children:t.person.name}),css:{maxWidth:"33%"},header:"Profile"},{cell:t=>e.jsx(ee,{event:t}),css:{flex:1},header:"Message"},{cell:n=>![...U.delivered.value,...U.pending.value].includes(n.status)&&e.jsxs(e.Fragment,{children:[e.jsx(G,{automationId:t.id,event:n,triggerResource:i,onEventsStatusChange:s}),![...U.ignored.value].includes(n.status)&&e.jsx(J,{automationId:t.id,event:n,triggerResource:i,refreshHistory:d,onEventsStatusChange:s})]}),css:{textAlign:"right"},header:"",minWidth:"84px"}];return e.jsxs(n.StackView,{spacing:4,children:[e.jsxs(n.StackView,{spacing:.5,children:[e.jsx(n.Heading,{level:3,size:"16px",color:_.neutral45,weight:500,children:t.description}),e.jsx(n.Text,{color:_.neutral45,size:5,italic:!0,children:y})]}),e.jsxs(n.StackView,{spacing:2,children:[e.jsx(n.Box,{minHeight:7,children:!l&&(r.length||f)&&e.jsxs(n.StackView,{alignItems:"end",axis:"horizontal",distribution:"space-between",spacing:1,children:[e.jsxs(n.StackView,{width:"max-content",children:[e.jsx(n.Input.InputLabel,{fontWeight:500,color:_.neutral24,controls:"select-status",children:"Filter by status"}),e.jsxs(n.Select,{id:"select-status",emptyValue:null,onChange:({selectedValue:e})=>{p({where:e?{status:e}:null})},title:"Status",value:u.where?.status,children:[e.jsx(n.Select.Option,{value:null,children:"All"}),Object.values(U).map(t=>e.jsx(n.Select.Option,{value:t.value.join(","),children:t.label},t.value))]})]}),e.jsx(n.Button,{iconLeft:{name:"general.refresh"},onClick:d,theme:"primary",variant:"outline",width:12,children:"Refresh"})]})}),e.jsx(n.Box,{maxHeight:"70vh",minHeight:36,overflow:"auto",children:e.jsx(n.DataTable,{columns:k,data:r,empty:e.jsxs(n.StackView,{alignment:"center",distribution:"center",minHeight:20,maxWidth:45,spacing:1,marginTop:f?-4:-8,marginBottom:f?4:void 0,children:[e.jsx(n.Box,{css:{svg:{height:15,width:20}},children:e.jsx(v,{})}),e.jsx(n.Heading,{color:_.neutral12,fontWeight:500,level:4,size:2,children:"No history found"}),e.jsxs(n.Text,{fontSize:"16px",textAlign:"center",children:["No events ",f&&"matching your filters"," were triggered for this automation"," ",x?`since ${b}.`:"in the last 32 days."]}),f&&e.jsx(n.Button,{marginTop:1,onClick:()=>p({}),theme:"primary",title:"Clear filters",variant:"outline"})]}),loading:l,loadingTitle:"Loading automation history...",variant:{bodyCell:{alignItems:"start",fontSize:"13px",lineHeight:"20px",padding:"10px 12px"},bodyRow:({rowData:e})=>({backgroundColor:[...U.ignored.value].includes(e.status)?_.neutral98:void 0,minHeight:"36px"}),headerCell:{padding:"8px 12px"},headerRow:{minHeight:"36px"}},...c})})]})]})}function G({automationId:t,event:i,triggerResource:o,onEventsStatusChange:s}){const[r,l]=a.useState(i.status),c=U.pending.value.includes(r)?"Sending":U.delivered.value.includes(r)?"Sent":U.skipped.value.includes(r)?"Run now":"Retry",d=U.delivered.value.includes(r)?{color:_.statusCreate27,name:"general.check"}:void 0;return e.jsx(n.Button,{title:c,onClick:function(){l(U.pending.value.join(",")),q.post({data:{_e:o,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${i.id}/redeliver`}).then(e=>{l(U.delivered.value.join(",")),s(e.meta.eventsStatus)}).catch(()=>{l(U.failed.value.join(",")),y.fire({text:"There was a problem retrying this automation. Please try again in a few moments.",title:"Uh oh!"})})},iconLeft:d,disabled:r!==i.status,variant:"naked",color:U.delivered.value.includes(r)?_.statusCreate27:U.pending.value.includes(r)?_.neutral68:"linkForeground",theme:"primary",size:"xs"})}function J({automationId:t,event:a,triggerResource:i,refreshHistory:o,onEventsStatusChange:s}){return e.jsx(n.Button,{title:"Ignore",onClick:function(){q.post({data:{_e:i,data:{attributes:{}}},url:`/automation_subscriptions/${t}/events/${a.id}/ignore`}).then(e=>{s(e.meta.eventsStatus)}).then(()=>o()).catch(()=>{y.fire({text:"There was a problem ignoring this event. Please try again in a few moments.",title:"Uh oh!"})})},variant:"naked",color:"linkForeground",theme:"primary",size:"xs"})}function K({status:t}){const a=U.pending.value.includes(t)?{border:_.neutral62,text:_.neutral24}:U.delivered.value.includes(t)?{border:_.statusCreate35,text:_.statusCreate23}:U.skipped.value.includes(t)?{border:_.statusWarning63,text:_.givingBrand31}:U.ignored.value.includes(t)?{border:_.neutral68,text:_.neutral45}:{border:_.statusDelete47,text:_.statusDelete43},i=U.pending.value.includes(t)?"general.clock":U.skipped.value.includes(t)?"services.pause":U.delivered.value.includes(t)?"general.checkCircle":U.ignored.value.includes(t)?"general.inactive":"general.exclamationTriangle",o=U.failed.value.includes(t)?U.failed.label:U.ignored.value.includes(t)?U.ignored.label:U[t].label;return e.jsx(n.Badge,{color:{background:"transparent",foreground:a.text},css:{paddingLeft:3.5,paddingRight:1.5},fontSize:"12px",radius:"pill",renderLeft:e.jsx(n.Icon,{name:i,color:a.border,marginLeft:1}),size:"sm",stroke:a.border,strokeAlign:"inside",strokeWeight:1,title:o})}function ee({event:t}){const{status:a,lastDelivery:i}=t,o=function(t,a){let i=null;switch(t){case"skipped":case"ignored_skipped":i="Automation was paused and did not run on this profile";break;case"failed":case"duplicated":case"ignored_failed":case"ignored_duplicated":i=function(t,a){const i={403:"Owner doesn't have permission to perform this action.",404:"Owner lacks access to target product or resource doesn't exist.",422:"The automation action failed to run",default:"An error occurred",duplicated_event:"Didn't run because the same action had already been performed less than 60 seconds ago",failed_without_deliveries:"Didn't run because the owner doesn't have permissions in this product."};return e.jsx(n.StackView,{flex:1,whiteSpace:"normal",children:t?e.jsx(te,{details:function(e){if(!e?.responseBody)return null;let t;try{t=JSON.parse(e.responseBody)}catch{t={errors:["Server Error"]}}return function(e){return e?.errors?e.errors.map(e=>"string"==typeof e&&e.match(/Archived profiles/)?e.replace(/Archived profiles/,"Archived profiles."):e):[]}(t).join(", ")||t?.message}(t),status:t.status,children:i[t.status]||i.default}):["duplicated","ignored_duplicated"].includes(a)?i.duplicated_event:i.failed_without_deliveries})}(a,t)}return i}(a,i);return o?e.jsx(n.Box,{fontSize:"13px",fontStyle:"italic",lineHeight:"16px",maxWidth:"100%",paddingTop:"1px",whiteSpace:"normal",children:o}):null}function te({children:t,details:i,status:o}){const[s,r]=a.useState(!1);return e.jsxs(n.StackView,{spacing:1,children:[e.jsxs(n.Box,{children:[t," ",i&&e.jsx(n.Button,{inline:!0,onClick:function(){r(e=>!e)},size:"xs",theme:"primary",variant:"naked",fontStyle:"normal",children:"Details"})]}),s?e.jsx(n.Box,{padding:1,background:_.neutral98,children:e.jsxs(n.Text,{fontFamily:"monospace",fontSize:"11px",lineHeight:"1.2",children:[o&&`${o}: `,i]})}):null]})}class ne extends h.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs(n.Alert,{type:"error",marginVertical:1,children:["The application hit an unexpected error. If this persists after a few minutes, please let us know so we can get it fixed for you."," ",e.jsx("a",{style:{whiteSpace:"nowrap"},onClick:()=>window.Helpdesk.load(),children:"Contact support"})]}):this.props.children}}var ae=t=>e.jsx(ne,{children:e.jsx(Q,{...t})});function ie({onClick:t}){return e.jsx(n.Button,{as:"button",height:2,icon:{color:_.neutral62,name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function oe({children:t,onRequestClose:a,open:i,theme:o}){/*#__PURE__*/return u.createPortal(e.jsx(n.ThemeProvider,{theme:o,children:e.jsxs(n.Modal,{open:i,onRequestClose:a,maxWidth:120,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:4,paddingBottom:3,radius:8,children:[e.jsxs(n.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(n.Heading,{level:2,color:_.neutral12,fontWeight:500,fontSize:"25px",lineHeight:"1.4",children:"Automation history"}),e.jsx(ie,{onClick:a})]}),t]})}),document.body)}const se=function(e){try{return Promise.resolve(le.get({data:{fields:{Person:"avatar"}},url:"me"})).then(function({data:{avatar:t}}){return{avatar:t,subscription:e}})}catch(e){return Promise.reject(e)}},re=new t.Client({app:"webhooks",version:"2022-10-20"}),le=new t.Client({app:"people"}),ce=/*#__PURE__*/a.createContext(null);function de({onDelete:t,theme:n,openHistoryNow:a=!1,...i}){return e.jsxs(he,{theme:n,...i,children:[e.jsxs(ge,{children:[e.jsx(fe,{}),e.jsx(we,{onDelete:t,openHistoryNow:a})]}),e.jsx(ve,{}),e.jsx(be,{})]})}function ue(t){return e.jsxs(he,{automation:t.automation,children:[e.jsxs(ge,{children:[e.jsx(fe,{}),e.jsx(me,{})]}),e.jsx(pe,{}),e.jsx(xe,{})]})}function pe(){const{automation:t}=a.useContext(ce),o=t.triggerEventDescription,{name:s,description:r}=ye(t.description);return e.jsxs(n.StackView,{paddingVertical:2,flex:1,opacity:t.active?void 0:.5,children:[e.jsx(n.Heading,{level:3,size:"21px",weight:600,marginBottom:.5,truncate:!0,children:s}),e.jsxs(n.StackView,{spacing:.75,children:[e.jsxs(n.Text,{size:4,color:_.neutral24,lineHeight:"1.2",children:[o,", then ",i.lowerFirst(s)," ",je(t)]}),e.jsx(n.Text,{size:5,color:_.neutral45,lineHeight:"1.2",children:i.truncate(ke(r),{length:160,separator:" "})})]})]})}function me(){const{automation:t}=a.useContext(ce);return e.jsx(n.Button,{external:!0,iconLeft:{name:"general.newWindow"},variant:"naked",size:"sm",to:t.triggerAdminUrl,disabled:!t.canManage,tooltip:t.canManage?void 0:"You do not have access to this resource",color:_.neutral45,hover:{backgroundColor:"highlight",color:_.neutral45},children:"Manage"})}function he({automation:t,children:i,theme:o,...s}){const[r,l]=a.useState(t);return e.jsx(ce.Provider,{value:{automation:r,theme:o,updateAutomation:l,...s},children:e.jsx(n.Card,{radius:4,padding:2,children:i})})}function ge({children:t}){const{automation:i}=a.useContext(ce);return e.jsx(n.StackView,{axis:"horizontal",alignment:"center",padding:0,distribution:"space-between",opacity:i.active?void 0:.5,children:t})}function we({onDelete:t,openHistoryNow:i=!1}){const{automation:o,currentPersonCanCreate:s,currentPersonId:r,trigger:l,theme:c,updateAutomation:d}=a.useContext(ce),[u,p]=a.useState(i),m=o.active,{name:h}=ye(o.description);return e.jsxs(e.Fragment,{children:[e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsxs(n.Dropdown,{icon:{color:_.neutral24,name:"churchCenter.threeDots"},iconRight:!1,title:"Actions",variant:"naked",size:"md",children:[e.jsx(n.Dropdown.Item,{onSelect:()=>{p(!0)},children:"History"}),s&&e.jsx(n.Dropdown.Item,o.createdById===r?{disabled:!0,children:e.jsx(n.Tooltip,{placement:"left",openDelay:250,title:"This automation is already assigned to you.",children:e.jsx(n.Text,{children:"Reassign to me..."})})}:{onSelect:function(){k.fire({text:"This automation will run with your permission levels. Other administrators who can see this automation can grant it their permissions by reassigning it to themselves.",title:"Reassign automation?"}).then(({isConfirmed:e})=>{e&&re.post({data:{_e:l.resource,data:{attributes:{}}},url:`/automation_subscriptions/${o.id}/self_assign`}).then(({data:e})=>se(e)).then(({subscription:e,avatar:t})=>{d(n=>({...n,createdBy:{...n.createdBy,avatarUrl:t},createdById:e.createdById,createdByName:e.createdByName}))}).catch(()=>y.fire({text:"There was a problem updating this automation. Please try again in a few moments.",title:"Uh oh!"}))})},children:"Reassign to me..."}),e.jsx(n.Dropdown.Item,{onSelect:function(){C.fire({confirmButtonText:"Yes, delete automation",text:`Are you sure you want to delete the "${h}" automation? This cannot be undone.`,title:"Delete this automation?"}).then(({isConfirmed:e})=>{e&&t(o.id)})},children:"Delete..."})]}),e.jsx(n.Button,{as:"button",theme:!1,position:"relative",backgroundColor:m?_.statusCreate35:_.neutral62,radius:"pill",width:3.5,height:2,onClick:function(){re.patch({data:{_e:l.resource,data:{attributes:{active:!m}}},url:`/automation_subscriptions/${o.id}`}).then(e=>{d(t=>({...t,active:e.data.active}))}).catch(()=>y.fire({text:`There was a problem ${m?"pausing":"unpausing"} this automation. Please try again in a few moments.`,title:"Uh oh!"}))},tooltip:m?"Pause automation":"Enable automation",children:e.jsx(n.Box,{position:"absolute",pointerEvents:"none",top:.25,left:.25,width:1.5,height:1.5,background:"#fff",radius:"circle",transition:"0.1s",transform:`translateX(${m?"100%":"0%"})`})})]}),e.jsx(oe,{open:u,onRequestClose:()=>p(!1),theme:c,children:e.jsx(ae,{automation:o,triggerResource:l.resource,onEventsStatusChange:function(e){d(t=>({...t,eventsStatus:e}))}})})]})}function fe(){const{automation:t}=a.useContext(ce),o=t.name.split(".")[0];return e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.5,children:[e.jsx(n.Icon,{name:`logomark.${i.camelCase(o)}`,size:2,color:o.toLowerCase()}),e.jsx(n.Icon,{name:"general.rightArrow",size:1.5}),e.jsx(n.Icon,{name:`logomark.${i.camelCase(t.operationAppName)}`,size:2,color:t.operationAppName.toLowerCase()})]})}function xe(){const{automation:t}=a.useContext(ce),{dateFormat:i}=a.useContext(j),o=`${t.createdByName} ${t.createdBy?.id?"":"(deleted profile)"}`,s=t.active?void 0:.5;return e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{marginHorizontal:-2}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:1,opacity:s,children:[e.jsxs(n.Text,{size:6,color:_.neutral62,whiteSpace:"nowrap",children:["Updated ",D(t.createdAt,i)]}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.5,maxWidth:"calc(100% - 136px)",children:[t.createdBy?.avatarUrl&&e.jsx(n.Avatar,{width:2,height:2,basis:2,source:t.createdBy.avatarUrl},o),e.jsx(n.Text,{size:5,truncate:!0,children:o})]})]})]})}function be(){const{dateFormat:t}=a.useContext(j),{automation:i,trigger:o,theme:s,updateAutomation:r}=a.useContext(ce),l=`${i.createdByName} ${i.createdBy?.id?"":"(deleted profile)"}`,c=i.active?void 0:.5,d={color:_.neutral45,fontSize:6,fontWeight:400,paddingHorizontal:1,radius:"pill",size:"xs",variant:"naked"},[u,p]=a.useState({filter:null,historyVisible:!1});return e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{marginHorizontal:-2}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",distribution:"space-between",paddingTop:1.75,spacing:1,opacity:c,children:[e.jsxs(n.Text,{size:6,color:_.neutral62,whiteSpace:"nowrap",children:["Updated ",D(i.createdAt,t)]}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.25,children:[!!i.eventsStatus?.skipped&&e.jsxs(n.Button,{...d,"aria-label":`${i.eventsStatus.skipped} skipped`,onClick:function(){p({filter:"skipped",historyVisible:!0})},tooltip:`${i.eventsStatus.skipped?.toLocaleString()} skipped events`,children:[e.jsx(n.Box,{backgroundColor:_.statusWarning63,marginRight:.5,radius:"circle",height:"10px",width:"10px",padding:"2px",children:e.jsx(n.Icon,{name:"services.pause",size:"6px",title:"Skipped",color:"white"})}),`${i.eventsStatus.skipped?.toLocaleString()}`]}),!!i.eventsStatus?.failed&&e.jsx(n.Button,{...d,"aria-label":`${i.eventsStatus.failed} failed`,iconLeft:{color:_.statusDelete43,marginRight:.5,name:"general.exclamationTriangle",size:"10px",title:"Failed"},onClick:function(){p({filter:"failed,duplicated",historyVisible:!0})},title:`${i.eventsStatus.failed?.toLocaleString()}`,tooltip:`${i.eventsStatus.failed?.toLocaleString()} failed events`})]}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",distribution:"end",flex:1,spacing:.5,marginLeft:"auto",children:[i.createdBy?.avatarUrl&&e.jsx(n.Avatar,{width:2,height:2,basis:2,source:i.createdBy.avatarUrl},l),e.jsx(n.Text,{size:5,truncate:!0,children:l})]})]}),e.jsx(oe,{open:u.historyVisible,onRequestClose:()=>p({filter:null,historyVisible:!1}),theme:s,children:e.jsx(ae,{automation:i,triggerResource:o.resource,filterWhere:u.filter,onEventsStatusChange:function(e){r(t=>({...t,eventsStatus:e}))}})})]})}function ve(){const{automation:t,trigger:o}=a.useContext(ce),{name:s,description:r}=ye(t.description),l=t.active?void 0:.5,c=["When a person",i.lowerFirst(o.event.description)+",","then",i.lowerFirst(s),je(t)].join(" ");return e.jsxs(n.StackView,{paddingVertical:2,flex:1,opacity:l,children:[e.jsx(n.Heading,{level:3,size:"21px",weight:600,marginBottom:.5,truncate:!0,children:s}),e.jsxs(n.StackView,{spacing:.75,children:[e.jsx(n.Text,{size:4,color:_.neutral24,lineHeight:"1.2",children:c}),e.jsx(n.Text,{size:5,color:_.neutral45,lineHeight:"1.2",children:i.truncate(ke(r),{length:160,separator:" "})})]})]})}function je(e){return e?.triggerParams?.useTriggerPersonOverride?"(also applies to joint donor)":""}function ye(e){const t=/^(.+?)\(([^()]*?)\)$/.exec(e);return t?{description:t[2],name:t[1].trim()}:{name:e}}function ke(e){return e?.startsWith("[archived]")?e.replace("[archived]","[Archived]"):e}const Ce=function(){try{return Promise.resolve(_e.get({data:{fields:{App:["name"],PersonApp:["app","allow_pco_login"]},include:["app"]},url:"/me/person_apps"}).then(({data:e})=>e.filter(e=>e.allowPcoLogin).map(e=>e.app.name.toLowerCase())))}catch(e){return Promise.reject(e)}},Se=function(e){try{const t=i.compact(i.uniq(e.map(e=>e.createdById)));return Promise.resolve(function(n,a){try{var i=Promise.resolve(_e.get({data:{fields:{Person:"avatar"},where:{id:t.join(",")}},url:"people"})).then(function({data:t}){return{profiles:t,subscriptions:e}})}catch(e){return a()}return i&&i.then?i.then(void 0,a):i}(0,function(){return{profiles:[],subscriptions:e}}))}catch(e){return Promise.reject(e)}},ze=new t.Client({app:"webhooks",version:"2022-10-20"}),_e=new t.Client({app:"people"});function Pe({profiles:e,subscriptions:t}){return t.map(t=>{const n=e.find(e=>e.id===t.createdById);return{...t,createdBy:{...t.createdBy,avatarUrl:n?.avatar}}})}const Te=function(e){try{const t={people:["forms","lists"],registrations:["events"],services:["teams"]},n=["giving"],a=e.reduce((e,t)=>{const n=t.triggerResource.replace(/signup/,"event"),{appName:a,resourceType:i,resourcePath:o,resourceId:s}=R(n);return e[a]||(e[a]={}),e[a][i]||(e[a][i]={}),e[a][i].resoucePath||(e[a][i].resourcePath=o),e[a][i].ids||(e[a][i].ids=[]),e[a][i].ids.push(s),e},{}),i=Object.keys(a).flatMap(e=>Object.entries(a[e]).flatMap(([a,i])=>(n.includes(e)?$e:t[e]?.includes(a)?Ie:Fe)({appName:e,ids:i.ids,resourcePath:i.resourcePath,resourceType:a})));return Promise.resolve(Promise.allSettled(i)).then(function(t){return{automations:e,triggerResources:(n=t,n.reduce((e,t)=>("fulfilled"===t.status&&(e=e.concat(t.value)),e),[]).flatMap(e=>e.data))};var n})}catch(e){return Promise.reject(e)}},Oe=function(e){try{return Promise.resolve(Ae.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,trigger_resource,trigger_params",Person:"name"},include:"created_by"},url:"incoming_automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}},Ae=new t.Client({app:"webhooks",version:"2022-10-20"});function Ie({appName:e,resourcePath:t,resourceType:n,ids:a}){return Ve({appName:e,params:{where:{id:a.join(",")}},path:t,resourceType:n})}function Fe({appName:e,resourcePath:t,resourceType:n,ids:a}){return a.map(a=>Ve({appName:e,path:`${t}/${a}`,resourceType:n}))}function $e(e){return new Promise((e,t)=>{t()})}function Ve({appName:e,path:n,resourceType:a,params:o={}}){const s=new t.Client({app:e}),r=i.upperFirst(W(a));return s.get({data:{fields:{[r]:["name","name_or_description"]},...o},url:n})}function Le({encryptedParam:t,trigger:o}){const[s,r]=a.useState(!0),[l,c]=a.useState();a.useEffect(()=>{Ce().then(e=>{Oe(t).then(Se).then(Pe).then(P).then(Te).then(({automations:t,triggerResources:n})=>function({automations:e,triggerResources:t,operationApps:n}){return e.map(e=>{const{appName:a,resourceType:o,resourceId:s}=R(e.triggerResource);if("giving"===a)return e.triggerEventDescription=function(e){switch(e.name.replace("giving.v2.events.","")){case"donation.payment_successful":return"When a person gives";case"profile.first_donated_automation":return"When a person gives for the first time";case"recurring_donation.setup_successful":return"When a person sets up a recurring donation";default:return null}}(e),e.canManage=n.find(e=>"giving"===e),e;const r=t.find(e=>e.id.toString()==s.toString()),l=r?r.name||r.nameOrDescription:`[Hidden ${i.upperFirst(W(o))}]`;return e.triggerEventDescription=function(e,t){const n=function(e){switch(e.replace("v2.events.","")){case"groups.membership.created":return"joins";case"groups.membership.destroyed":return"leaves";case"people.list_result.created":case"services.team_person.created":return"is added to";case"people.list_result.destroyed":case"services.team_person.destroyed":return"is removed from";case"people.form_submission.created":return"submits";case"registrations.attendee.created":return"is registered as a new attendee for";case"registrations.attendee.cancelled":return"is canceled as an attendee for";case"registrations.registration.created":return"is the registration contact on a new registration for";case"registrations.registration.cancelled":return"is the registration contact on a canceled registration for";default:return null}}(e.name),{resourceType:a}=R(e.triggerResource);if(!n){const e=i.truncate(t,{length:160,separator:" "});return`When the automation is triggered from ${W(a)} "${e}"`}return`When a person ${n} ${W(a)} "${t}"`}(e,l),e.canManage=!!r,e})}({automations:t,operationApps:e,triggerResources:n})).then(c).then(()=>r(!1))})},[t]);const d=!s&&0===l.length;return e.jsxs(e.Fragment,{children:[e.jsx(n.Box,{borderBottom:`1px solid ${_.neutral88}`,marginBottom:2,marginHorizontal:-3,marginTop:o?12:0,paddingHorizontal:3,paddingVertical:2,children:e.jsx(n.Heading,{color:_.neutral12,level:2,size:"18px",children:s?"Incoming automations":H(l.length,"incoming automation")})}),d?e.jsx(n.Text,{color:_.neutral45,marginVertical:3,children:"Automations that perform actions on this resource will be listed here."}):s?e.jsx(n.Summary,{image:e.jsx(n.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading incoming automations..."}):e.jsx(n.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:l.map(t=>e.jsx(ue,{automation:t},t.id))})]})}function Be(e){return`OPERATION_${e.definitionClass}${e.definitionIdentifier||""}`}function De(e){return`SECTION_${e}`}function He(t){return t.map(({label:t,value:a})=>e.jsx(n.Select.Option,{value:a,children:t},a))}function We(t){const a=i.groupBy(t,"group");return Object.keys(a).sort().map(t=>"null"===t?He(a[t]):e.jsx(n.Select.OptionGroup,{title:t,children:He(a[t])},t))}const Re=({selectedOperation:t,onOperationDefinitionChange:a,operationDefinitions:o})=>{const s=t?.section,r=o.map(e=>({...e,id:Be(e)})),l=r.filter(e=>null===e.section),c=i.uniqBy(o,"section").filter(e=>!!e.section).map(e=>({group:e.sectionGroup,label:e.section,value:De(e.section)})),d=s?r.filter(e=>e.section===s):[];function u({selectedValue:e}){switch(function(e){if(e.startsWith("SECTION"))return"section";if(e.startsWith("OPERATION"))return"operation";if(e)throw new Error(`Unexpected value: ${e}`);return null}(e)){case"section":a(o.find(t=>De(t.section)===e));break;case"operation":a(o.find(t=>Be(t)===e));break;case null:a(null)}}function p(e){return We(e.map(e=>({group:e.group,label:e.description,value:e.id})))}return e.jsxs(n.StackView,{spacing:1,children:[e.jsxs(n.Select,{emptyValue:"Select an action",id:"select-action",onChange:u,size:"lg","data-testid":"operation-select",children:[p(l),We(c)]}),d.length>0&&e.jsx(n.Select,{defaultValue:d[0].id,onChange:u,size:"lg",children:p(d)})]})},Me=({canAccessPeople:t,field:o,onChange:s,value:r,selectedFieldOptions:l,loadListForField:c,loadedLists:d,loadingLists:u})=>{const p=function(e){const[t,n]=a.useState(e);return a.useEffect(()=>{const a=e();i.isEqual(a,t)||n(a)},[e,t]),t}(()=>function({field:e,selectedFieldOptions:t}){return(e.dependsOn||[]).reduce((e,n)=>(Object.prototype.hasOwnProperty.call(t,n)&&(e[i.camelCase(n)]=t[n]),e),{})}({field:o,selectedFieldOptions:l}));a.useEffect(()=>{o.listClass&&c({dependencies:p,field:o})},[o,p,c]);const m=o.list||d[A(o)]||[],h=m.filter(e=>!e.automationNotAllowed),g=o.listClass&&u[A(o)];return e.jsxs(n.StackView,{marginBottom:2,spacing:.5,children:[e.jsxs(n.Input.InputLabel,{color:_.neutral12,fontSize:"14px",fontWeight:500,controls:o.id,children:[o.description,o.info&&e.jsx(n.HelperDrawer.Toggle,{drawerId:`${o.id}_help`,marginLeft:1})]}),e.jsx(n.Box,{children:g?e.jsx(Ke,{}):function(){switch(o.kind){case"Select":return e.jsx(Ee,{fieldId:o.id,listOptions:h,onChange:s,value:r});case"SelectSearch":return e.jsx(Ne,{fieldId:o.id,listOptions:h,onChange:s,value:r});case"Checkbox":return e.jsx(Ye,{field:o,value:r,onChange:s});case"TextArea":return e.jsx(Ue,{field:o,onChange:s,value:r});case"DateField":return e.jsx(Ze,{field:o,onChange:s,value:r});case"Checkboxes":return e.jsx(Xe,{fieldId:o.id,options:h,onChange:s});case"NumberField":return e.jsx(Qe,{field:o,onChange:s,value:r});case"PersonSearch":return e.jsx(qe,{canAccessPeople:t,field:o,onChange:s,listOptions:m,isLoading:u[A(o)],loadListForField:c,value:r});case"TextField":return e.jsx(Ge,{field:o,onChange:s,value:r});case"RadioButtons":return e.jsx(Je,{field:o,options:m,onChange:s,value:r});default:return console.warn(`Unknown field kind "${o.kind}"`),null}}()}),o.info&&e.jsx(n.HelperDrawer,{id:`${o.id}_help`,marginTop:.5,children:e.jsx(n.Box,{dangerouslySetInnerHTML:{__html:o.info}})})]})},Ee=({fieldId:t,listOptions:a,onChange:o,value:s})=>{const r=a?.find(e=>"no-option"===e.value),l=i.groupBy(a,"group"),c=Object.keys(l).sort(),d=()=>c.map(t=>"null"===t||"undefined"===t?u(l[t]):e.jsx(n.Select.OptionGroup,{title:t,children:u(l[t])},t)),u=t=>t.map(t=>e.jsx(n.Select.Option,{value:t.value.toString(),disabled:t.disabled,children:t.description},t.value));return e.jsx(n.Select,{id:t,onChange:({selectedValue:e})=>{o({fieldId:t,value:e})},disabled:d().length<1,emptyValue:0===d().length?"No options available":r?.description||"Select a value",size:"lg",value:s||r?.value||null,placement:"bottom-start",children:d()})},Ne=({fieldId:t,listOptions:o,onChange:s,value:r})=>{const l=o.find(e=>e.value?.toString()===r),c=l?.description||"",[d,u]=a.useState(""),[p,m]=a.useState(c),[h,g]=a.useState(!1),[w,f]=a.useState(!1);c!==d&&(u(c),m(c),g(!1));let x=i.sortBy(i.uniqBy(o,"value"),"group");if(h){const e=p.toLowerCase();x=x.filter(t=>`${t.description} ${t.group}`.toLowerCase().includes(e))}return e.jsx(n.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},css:{"[role='combobox']":{cursor:o.length>0?"pointer":"not-allowed"}},cursor:"pointer",disabled:0===o.length,onBlur:()=>{f(!1),m(c)},onChange:e=>{m(e.target.value),g(!0),f(!0)},onClear:w?()=>{m(""),g(!1)}:void 0,onFocus:e=>e.target.select(),onSelect:e=>{(e=>{s({fieldId:t,value:e})})(e.value),m(e.description),g(!1),f(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:o.length>0?"Select an option":"No options available",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:e.jsx(n.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(n.Icon,{name:"general.downCaret"}),size:"lg",value:p,children:o.length>0&&e.jsx(e.Fragment,{children:x.length>0?x.map((t,a)=>{const i=t.value.toString()===r;return e.jsxs(n.Combobox.Item,{"aria-label":t.description,disabled:t.disabled,index:a,paddingLeft:4.25,renderLeft:e.jsx(n.Icon,{marginLeft:-.5,name:i?"general.check":"",size:"sm"}),role:"option",spacing:1,value:{description:t.description,value:t.value.toString()},children:[e.jsx(n.Text,{truncate:!0,children:e.jsx(n.Highlight,{text:t.description,query:p})}),t.group&&e.jsx(n.Badge,{title:e.jsx(n.Highlight,{text:t.group,query:p}),size:"sm",marginLeft:"auto"})]},t.value)}):e.jsx(n.Menu.Item,{children:e.jsxs(n.Text,{children:['No results for "',p,'"']})})})})},qe=({canAccessPeople:t,field:o,isLoading:s,listOptions:r,loadListForField:l,onChange:c,value:d})=>{const u=a.useCallback(e=>{l({dependencies:{query:e},field:o})},[l]),p=a.useMemo(()=>i.debounce(u,300),[u]),m=a.useCallback(e=>{t&&(e.trim().length>0?p(e):p.cancel())},[p]),h=a.useMemo(()=>({description:"Myself",value:"self"}),[]),g=a.useMemo(()=>t?r:[h],[h,r]).find(e=>e.value===d),w=g?.description||"",[f,x]=a.useState(w),[b,v]=a.useState(!1);function j(e){x(e),m(e),0===e.trim().length&&y(null)}const y=e=>{c({fieldId:o.id,value:e})};return e.jsx(n.Combobox.Popover,{closeOnSelect:!0,closeButton:{icon:{size:"md"}},cursor:"pointer",onBlur:()=>{v(!1),j(w)},onChange:e=>{j(e.target.value),v(!0)},onClear:b?()=>{j("")}:void 0,onFocus:e=>e.target.select(),onSelect:e=>{y(e.value),j(e.description),v(!1)},openOnFocus:!0,paddingLeft:4.5,placeholder:"Search",placement:"bottom-start",popoverProps:{matchWidths:"minimum"},renderLeft:g&&g.meta?.avatar?e.jsx(n.Avatar,{size:"sm",source:g.meta.avatar}):e.jsx(n.Icon,{name:"general.search",size:"md"}),renderRight:e.jsx(n.Icon,{name:"general.downCaret"}),size:"lg",value:f,children:t?f.trim().length>0?r.length>0?r.map((t,a)=>e.jsx(n.Combobox.Item,{"aria-label":t.description,index:a,paddingLeft:4.25,renderLeft:e.jsx(n.Avatar,{marginLeft:-.5,source:t.meta.avatar,size:"sm"}),role:"option",spacing:1,value:t,children:e.jsx(n.Text,{truncate:!0,children:e.jsx(n.Highlight,{text:t.description,query:f})})},t.value)):e.jsx(n.Combobox.Item,s?{children:e.jsx(n.Text,{children:"Loading..."})}:{children:e.jsx(n.Text,{children:"No results"})}):e.jsx(n.Combobox.Item,{children:e.jsx(n.Text,{children:"Type to search"})}):e.jsx(n.Combobox.Item,{value:h,index:0,role:"option",children:e.jsx(n.Text,{children:h.description})})})},Ye=({field:t,value:a,onChange:i})=>e.jsx(n.Checkbox,{disabled:t.disabled,label:t.label,checked:a||!1,onChange:e=>{i({fieldId:t.id,value:e.target.checked})}}),Ue=({field:t,value:a,onChange:i})=>e.jsx(n.Box,{children:e.jsx(n.TextArea,{value:a,placeholder:t.placeholder,onChange:e=>{i({fieldId:t.id,value:e.target.value})},size:"lg"})}),Ze=({field:t,value:i,onChange:o})=>{const{dateFormat:s}=a.useContext(j),[r,l]=a.useState(!1),c=t.customValue||"Date automation runs",d=s.replace(/%m/,"M").replace(/%d/,"d").replace(/%Y/,"y").replace(/%y/,"yy"),[u,p]=a.useState(g.default(i).toDate());return e.jsxs(n.StackView,{axis:"horizontal",children:[e.jsxs(n.Select,{onChange:({selectedValue:e})=>{e===c?(l(!1),o({fieldId:t.id,value:c})):"specific-date"===e?(o({fieldId:t.id,value:null}),l(!0)):(l(!1),o({fieldId:t.id,value:null}))},size:"lg",placement:"bottom-start",children:[e.jsx(n.Select.Option,{value:c,children:c}),e.jsx(n.Select.Option,{value:"specific-date",children:"A specific date"}),e.jsx(n.Select.Option,{value:"unanswered",children:"Unanswered"})]}),r&&e.jsx(n.Box,{children:e.jsx(n.DateField,{defaultOpen:!0,formatValue:d,marginLeft:1,onChange:e=>{o({fieldId:t.id,value:D(e,s)}),p(e)},size:"lg",value:u})})]})},Xe=({fieldId:t,options:i,onChange:o})=>{const[s,r]=a.useState({});return e.jsx(n.StackView,{spacing:1,children:i.map(a=>e.jsxs(n.Box,{children:[e.jsx(n.Input.InputLabel,{controls:`checkboxes_${t}_${a.value}`,children:a.description||a.value}),e.jsxs(n.Select,{id:`checkboxes_${t}_${a.value}`,onChange:({selectedValue:e})=>((e,n)=>{const a={...s};a[n]=e,r(a),o({fieldId:t,value:a})})(e,a.value),size:"lg",emptyValue:"Don't change",children:[e.jsx(n.Select.Option,{value:"check",children:"Check"}),e.jsx(n.Select.Option,{value:"uncheck",children:"Uncheck"})]})]},a.value))})},Qe=({field:t,onChange:i,value:o})=>{const s=t.minValue>=0?t.minValue:1,r=t.maxValue>=1&&t.maxValue<=365?t.maxValue:365,[l,c]=a.useState(Number(t.defaultValue)||1);return a.useEffect(()=>{i({fieldId:t.id,value:t.defaultValue||1})},[t]),e.jsxs(n.StackView,{children:[e.jsx(n.Input.InputBox,{children:e.jsx(n.NumberField,{onChange:e=>{const n=Number(e)||0;c(n),i({fieldId:t.id,value:Math.min(Math.max(n,s),r)})},placeholder:t.placeholder,size:"lg",value:o,min:s,max:r,hasControls:!0})}),l>r&&e.jsx(n.Alert,{type:"error",paddingHorizontal:1,paddingVertical:.5,display:"inline-block",marginTop:1.5,children:e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:.75,children:[e.jsx(n.Icon,{name:"general.exclamationTriangle",size:"sm",color:"delete45"}),e.jsxs(n.Text,{size:4,children:["Value cannot exceed ",r,"."]})]})})]})},Ge=({field:t,value:a,onChange:i})=>e.jsx(n.Box,{children:e.jsx(n.Input,{size:"lg",value:a,id:t.id,placeholder:t.placeholder,onChange:e=>{i({fieldId:t.id,value:e.target.value})}})}),Je=({field:t,options:a,onChange:i,value:o})=>{const s=e=>{i({fieldId:t.id,value:e.target.value})};return e.jsx(n.StackView,{marginTop:1,spacing:.5,children:a.map(t=>e.jsx(n.Radio,{checked:o===t.value,label:t.description||t.value,onChange:s,size:"md",value:t.value},t.value))})},Ke=()=>e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,paddingHorizontal:1.75,paddingVertical:1,radius:4,border:`1px solid ${_.neutral88}`,children:[e.jsx(n.Spinner,{size:"xs"}),e.jsx(n.Text,{fontSize:16,lineHeight:2.75,children:"Loading"})]}),et=({canAccessPeople:t,definitionFields:n,onChange:i,selectedFieldOptions:o,loadListForField:s,loadedLists:r,loadingLists:l})=>{a.useEffect(()=>{const e=n.reduce((e,t)=>(Object.prototype.hasOwnProperty.call(t,"defaultValue")?e[t.id]=t.defaultValue:"DateField"===t.kind&&(e[t.id]=t.customValue||"Date automation runs"),e),{});i(e)},[n,i]);const c=V(n,o),d=({fieldId:e,value:t})=>{const a={...o},s=n.filter(e=>e.dependsOn);s.map(t=>{if(t.dependsOn.includes(e)){const e=s.find(e=>e.dependsOn.includes(t.id));e&&delete a[e.id],delete a[t.id],void 0!==t.defaultValue&&void 0===a[t.id]&&(a[t.id]=t.defaultValue)}}),"no-option"===t?delete a[e]:a[e]=t,i({...a})};return n.length?e.jsx("div",{children:c.map(n=>e.jsx(Me,{canAccessPeople:t,field:n,onChange:d,value:o[n.id],selectedFieldOptions:o,loadListForField:s,loadedLists:r,loadingLists:l},n.id))}):null},tt=function(e){try{return Promise.resolve(ot.get({data:{fields:{OperationDefinition:"definition_class,definition_fields,definition_identifier,description,group,section,section_group,footer_message"},filter:"automation_allowed"},url:`/operation_apps/${e}/operation_definitions`}).then(({data:e})=>e))}catch(e){return Promise.reject(e)}},nt=function(){try{return Promise.resolve(ot.get({data:{fields:{OperationApp:"name"}},url:"/operation_apps"}).then(({data:e})=>e.map(e=>e.name)))}catch(e){return Promise.reject(e)}},at=function(){try{return Promise.resolve(it.get({data:{fields:{Topbar:"apps"}},url:"/me/topbar"}).then(({data:e})=>e.apps.map(e=>e.name)))}catch(e){return Promise.reject(e)}},it=new t.Client({app:"people",env:window.railsEnv,version:"LATEST"}),ot=new t.Client({app:"webhooks",env:window.railsEnv,version:"LATEST"}),st={css:{borderRadius:4},paddingHorizontal:1.75,paddingVertical:1.25,type:"error"},rt=({afterCreateOptions:t,blankStateLink:o,debugMode:s=!1,defaultApp:r,description:l,onRequestClose:c,trigger:d})=>{const[u,p]=a.useState(d.events[0]),[m,h]=a.useState({}),[g,w]=a.useState(r),[f,x]=a.useState([]),[b,v]=a.useState([]),[j,y]=a.useState(!0),[k,C]=a.useState(),[z,P]=a.useState({}),[T,O]=a.useState({}),[F,$]=a.useState({}),[V,B]=a.useState(!1),[D,H]=a.useState({}),[W,R]=a.useState(!1),[M,E]=a.useState({}),N=a.useRef(null),q=a.useMemo(()=>f.map(e=>e.id).includes("people"),[f]),Y=k?.definitionIdentifier,U="danger"===k?.footerMessage?.kind,Z=a.useCallback(({field:e,dependencies:t})=>{$(t=>({...t,[A(e)]:!0})),function({app:e,field:t,definitionIdentifier:n,dependencies:a}){try{return"PersonSearch"===t.kind?Promise.resolve(it.get({data:{fields:{Person:"avatar,name"},where:{search_name_or_email:a.query,status:"active"}},url:"/people"})).then(function({data:e}){return e.map(e=>({description:e.name,meta:{avatar:e.avatar},value:e.id.toString()}))}):Promise.resolve(ot.get({data:{...a,definitionIdentifier:n,fields:{OperationDefinitionList:"values"}},url:`/operation_apps/${e}/operation_definition_lists/${t.listClass}`})).then(function({data:e}){return e.values})}catch(e){return Promise.reject(e)}}({app:g,definitionIdentifier:Y,dependencies:t,field:e}).then(t=>{O(n=>({...n,[A(e)]:t})),$(t=>({...t,[A(e)]:!1}))}).catch(e=>H({selected_definition:e}))},[g,Y]);a.useEffect(()=>{H({}),function(){try{return Promise.resolve(Promise.all([at(),nt()])).then(function([e,t]){return e.filter(e=>t.includes(e)).sort().map(e=>({id:e.toLowerCase(),name:e}))})}catch(e){return Promise.reject(e)}}().then(e=>{x(e);const t=e.find(e=>e.id===r)?r:e[0].id;w(t),tt(t).then(e=>{N.current||(v(e),y(!1))}).catch(e=>H({definitions:e}))})},[r]),a.useEffect(()=>{H({})},[z]);const X=i.cloneDeep("conditions"in u?u.conditions:d.conditions);for(const e in m)i.set(X,e,m[e]);const Q="dynamicConditions"in u?u.dynamicConditions:d.dynamicConditions;function G(){const e=function({selectedDefinition:e,selectedFieldOptions:t,loadedLists:n}){return{description:L({loadedLists:n||{},selectedDefinition:e,selectedFieldOptions:t}),name:(a=e,I(a)||a.description)};var a}({loadedLists:T,selectedDefinition:k,selectedFieldOptions:z});let t=e.name;return e.description&&(t+=` (${e.description})`),t}function J(e){B(!0),ot.post({data:e,url:"/me/automation_subscriptions"}).then(()=>{t?.onConfirm&&W?(c(),t.onConfirm({...e})):window.location.reload()}).catch(e=>{B(!1),e.errors?H({automation:e.errors}):alert("something even worse happened!")})}return e.jsxs(n.StackView,{paddingTop:4,spacing:2,children:[l&&e.jsx(n.Box,{children:e.jsxs(n.Text,{style:{color:_.neutral24,fontSize:16,lineHeight:1.65,marginBottom:16},children:[l," ",e.jsx(n.Link,{external:!0,to:o,children:"Learn more"})]})}),D.automation&&e.jsx(n.Alert,{...st,children:e.jsx(n.Text,{children:"There was an error creating your automation. Please change your selections and try again or contact support if the problem persists."})}),e.jsxs(n.StackView,{spacing:1,children:[e.jsx(n.Input.InputLabel,{color:_.neutral12,controls:"select-trigger-event",fontSize:"16px",fontWeight:600,children:"When a person..."}),e.jsx(n.Select,{id:"select-trigger-event",onChange:({selectedValue:e})=>(e=>{p(e),h({})})(e),size:"lg",value:u,children:d.events.map((t,a)=>e.jsx(n.Select.Option,{value:t,children:t.description},`${t.name}_${a}`))}),Q?.length>0&&e.jsx(et,{canAccessPeople:q,definitionFields:Q,selectedFieldOptions:m,onChange:h,loadedLists:{},loadingLists:{},loadListForField:()=>null})]}),e.jsxs(n.StackView,{spacing:1,children:[f.length>0?e.jsx(pt,{selectedApp:g,operationApps:f,onOperationAppChange:e=>{w(e),y(!0),v([]),N.current=e,C(null),P({}),H({}),tt(e).then(v).then(()=>y(!1)).catch(e=>H({definitions:e}))}}):e.jsxs(n.StackView,{spacing:1,children:[e.jsx(n.Text,{color:_.neutral12,fontSize:"16px",fontWeight:600,children:"Then perform an action in..."}),e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,paddingHorizontal:1.75,paddingVertical:1,radius:4,border:`1px solid ${_.neutral88}`,children:[e.jsx(n.Spinner,{size:"xs"}),e.jsx(n.Text,{fontSize:16,lineHeight:2.75,children:"Loading"})]})]}),D.definitions?e.jsx(n.Alert,{marginTop:1,...st,children:e.jsx(n.Text,{children:"There was a problem looking up automations. Please contact support if the problem persists."})}):j?e.jsx(mt,{}):e.jsx(Re,{selectedOperation:k,operationDefinitions:b,onOperationDefinitionChange:e=>{C(e),H({}),P({})}})]}),k&&(D.selected_definition?e.jsx(n.Alert,{...st,children:e.jsx(n.Text,{children:"There was a problem looking up automation options. Please contact support if the problem persists."})}):e.jsxs(e.Fragment,{children:[e.jsx(et,{canAccessPeople:q,definitionFields:k.definitionFields||[],onChange:P,selectedFieldOptions:z,loadedLists:T,loadListForField:Z,loadingLists:F}),t?.label&&e.jsx(n.Checkbox,{disabled:V||lt(k,z),label:t.label,checked:W,onChange:()=>R(!W)}),u?.triggerParams?.map((t,a)=>e.jsx(n.Checkbox,{label:t.description,checked:M&&M[t.key]||t.defaultValue,onChange:e=>{E(n=>({...n,[`${t.key}`]:e.target.checked}))}},`${t.key}_${a}`)),U&&e.jsx(n.Alert,{...st,children:e.jsxs(n.StackView,{axis:"horizontal",spacing:1.5,children:[e.jsx(n.Icon,{size:3,name:"general.exclamationTriangle",color:"error"}),e.jsx(n.Text,{dangerouslySetInnerHTML:{__html:k.footerMessage?.html}})]})})]})),s&&e.jsx("pre",{children:JSON.stringify({description:k&&G(),loadedLists:T,selectedDefinition:k,selectedFieldOptions:z,triggerConditions:X},null,4)}),e.jsxs(n.StackView,{alignment:"center",axis:"horizontal",borderTop:`1px solid ${_.neutral88}`,distribution:"end",marginTop:2,marginHorizontal:-4,paddingHorizontal:4,paddingTop:3,spacing:2,children:[e.jsx(n.Button,{color:_.neutral12,"data-modal-close":!0,fontWeight:400,onClick:c,size:"md",title:"Cancel",variant:"naked"}),e.jsx(n.Button,{disabled:V||U||lt(k,z),onClick:function(){if(V)return;const e={...z};k.definitionIdentifier&&(e.definition_identifier=k.definitionIdentifier);const n={_e:d.resource,data:{attributes:{description:G(),name:u.name,operation_app_name:g,operation_definition_class_name:k.definitionClass,operation_params:e,trigger_conditions:X,trigger_params:M},type:"AutomationSubscription"}};W?S.fire({cancelButtonText:"Cancel",confirmButtonText:"Yes, perform action",text:"This will happen immediately after creating your new automation. Are you sure?",title:`${t.label}?`}).then(e=>{e.value?J(n):(B(!1),R(!1))}):J(n)},size:"md",theme:"primary",title:ut(k,z),variant:"fill","data-testid":"create-automation"})]})]})};function lt(e,t){if(e){const n=V(e.definitionFields,t),a=n.filter(e=>e.required),i=n.filter(e=>ct(e));return!a.every(e=>dt(e,t))||!i.every(e=>dt(e,t))}return!0}function ct(e){return"Select"===e.kind||"SelectSearch"===e.kind}function dt(e,t){return ct(e)?t.hasOwnProperty(e.id):t.hasOwnProperty(e.id)&&t[e.id]&&""!==t[e.id].toString().trim()}function ut(e,t){const n=function(e,t){if(!e?.definitionFields)return;const n=V(e.definitionFields,t);for(const e of n)if(e.required&&!dt(e,t))return e.description}(e,t);return e?n?`Select a${n.charAt(0).match(/[aeiou]/i)?"n":""} ${n.toLowerCase()}`:"Create automation":"Select an action"}const pt=({onOperationAppChange:t,operationApps:a,selectedApp:i})=>e.jsxs(n.StackView,{spacing:1,children:[e.jsx(n.Input.InputLabel,{color:_.neutral12,controls:"select-product",fontSize:"16px",fontWeight:600,children:"Then perform an action in..."}),e.jsx(n.Select,{autoFocus:!0,id:"select-product",onChange:({selectedValue:e})=>{t(e)},size:"lg",value:i,children:a.map(t=>e.jsx(n.Select.Option,{value:t.id,children:t.name},t.id))})]}),mt=()=>e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,paddingHorizontal:1.75,paddingVertical:1,radius:4,border:`1px solid ${_.neutral88}`,children:[e.jsx(n.Spinner,{size:"xs"}),e.jsx(n.Text,{fontSize:16,lineHeight:2.75,children:"Loading"})]});function ht({onClick:t}){return e.jsx(n.Button,{as:"button",height:2,icon:{color:_.neutral62,name:"general.x"},onClick:t,size:"sm",title:"Close",variant:"naked"})}function gt({children:t,onRequestClose:a,open:i,theme:o}){/*#__PURE__*/return u.createPortal(e.jsxs(n.ThemeProvider,{theme:o,children:[e.jsxs(n.Modal,{open:i,onRequestClose:a,maxWidth:75,boxShadow:"0 0 20px rgba(0, 0, 0, 0.15)",padding:4,paddingBottom:3,radius:8,zIndex:10009,children:[e.jsxs(n.StackView,{axis:"horizontal",distribution:"space-between",alignment:"center",children:[e.jsx(n.Heading,{level:2,color:_.neutral12,fontWeight:500,fontSize:"25px",lineHeight:"1.4",children:"Create automation"}),e.jsx(ht,{onClick:a})]}),t]}),e.jsx("style",{children:"\n .swal2-container.swal2-backdrop-show { z-index: 10001 }\n "})]}),document.body)}const wt=new t.Client({app:"webhooks",version:"2022-10-20"});function ft({afterCreateOptions:t,automations:i,blankStateLink:o,canCreate:s,defaultApp:r,description:l,hasActiveAutomations:c,loading:d,onPauseAutomations:u,theme:p,trigger:m}){const[h,g]=a.useState(!1),w={size:"md",theme:"primary"},f=s&&!c;return e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",backgroundColor:f?_.statusWarning94:void 0,borderBottom:f?void 0:`1px solid ${_.neutral88}`,"data-testid":"automations-header",distribution:"space-between",marginHorizontal:-3,marginBottom:2,marginTop:-3,paddingHorizontal:3,paddingVertical:2,spacing:2,wrap:!0,zIndex:2,children:[s&&!c?e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",marginHorizontal:1,spacing:1,children:[e.jsx(n.Icon,{size:2,color:_.statusWarning49,name:"general.exclamationTriangle"}),e.jsx(n.Heading,{color:_.neutral12,level:2,size:"18px",children:"Automations are currently paused"})]}):e.jsx(n.Heading,{color:_.neutral12,level:2,size:"18px",children:d?"Active automations":H(i.length,"active automation")}),s&&(c?e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[i.length>0&&e.jsx(n.Button,{onClick:u,...w,variant:"outline",children:"Pause automations"}),e.jsx(n.Button,{...w,variant:"fill",onClick:()=>g(!0),children:"Create automation"}),e.jsx(gt,{open:h,onRequestClose:()=>g(!1),theme:p,children:e.jsx(rt,{description:l,blankStateLink:o,defaultApp:r,trigger:m,onRequestClose:()=>g(!1),afterCreateOptions:t})})]}):e.jsx(n.Box,{children:e.jsxs(n.StackView,{axis:"horizontal",alignment:"center",spacing:1,children:[e.jsx(n.Button,{...w,backgroundColor:"success",hover:{backgroundColor:"success-dark"},active:{backgroundColor:"success-darker"},onClick:u,children:"Enable automations"}),e.jsx(n.Button,{...w,disabled:!0,tooltip:{title:"Automations must be enabled to create new ones"},children:"Create automation"})]})}))]})}exports.Automations=function({afterCreateOptions:t,blankStateDescription:i,blankStateLink:o="https://pcopeople.zendesk.com/hc/en-us/articles/217582148-Automations",currentPersonId:s,currentPersonCanCreate:r,defaultApp:l,incomingAutomationsParam:c,theme:d,trigger:u,currentOrganization:p,permissionDeniedReason:m="You need permissions of Editor or above to add an automation."}){a.useEffect(()=>{if(!u)return f(!1);(function(e){try{return Promise.resolve(ze.get({data:{_e:e,fields:{AutomationSubscription:"id,description,created_at,created_by,operation_app_name,operation_definition_class_name,operation_params,active,created_by_name,name,trigger_admin_url,events_status,trigger_params",Person:"name"},include:"created_by"},url:"automation_subscriptions"})).then(function({data:e}){return e})}catch(e){return Promise.reject(e)}})(u.resource).then(Se).then(Pe).then(P).then(g).then(()=>f(!1))},[u?.resource]);const[h,g]=a.useState([]),[w,f]=a.useState(!0),[x,b]=a.useState(!1),{dateFormat:k,twentyFourHourTime:C,olsonTimeZone:S}=p,T=new URLSearchParams(window.location.search).get("automation_id"),O={...d,icons:{...z}};a.useEffect(()=>{document.body.toggleAttribute("data-loading-automations",w)},[w]);const A=!h.length||h.some(e=>e.active);function I(e){wt.delete({data:{_e:u.resource},url:`/automation_subscriptions/${e}`}).then(()=>g(h.filter(t=>t.id!==e))).catch(()=>y.fire({text:"There was a problem deleting this automation. Please try again in a few moments.",title:"Uh oh!"}))}const F={color:_.neutral24,level:2,size:"25px",weight:700},$={color:_.neutral45,lineHeight:3,size:3};return e.jsxs(n.ThemeProvider,{theme:O,children:[e.jsxs(j.Provider,{value:{dateFormat:k,olsonTimeZone:S,twentyFourHourTime:C},children:[u&&e.jsx(ft,{automations:h,blankStateLink:o,canCreate:r,loading:w,defaultApp:l,description:i,theme:O,trigger:u,hasActiveAutomations:A,onPauseAutomations:function(){wt.post({data:{data:{attributes:{_e:u.resource,active:!A}}},url:"/pause_automations"}).then(()=>{window.location.reload()})},afterCreateOptions:t}),w?e.jsx(n.Summary,{image:e.jsx(n.Spinner,{size:"xl"}),paddingVertical:10,title:"Loading automations..."}):u?e.jsx(n.Box,{"data-testid":"automations-section",children:h?.length>0?e.jsx(n.TileView,{spacing:3,marginVertical:3,minCellWidth:45,children:h.map(t=>{return e.jsx(de,{automation:t,onDelete:I,theme:O,openHistoryNow:t.id===Number(T),trigger:{event:(n=t,u.events.find(e=>e.name===n.name)),resource:u.resource},currentPersonId:s,currentPersonCanCreate:r},t.id);var n})}):e.jsxs(n.StackView,{margin:6,spacing:2,alignment:"center",mediaQueries:{lg:{axis:"horizontal",distribution:"center",spacing:6}},children:[e.jsx(n.Box,{css:{".symbol":{height:"100%",width:"100%"}},maxWidth:24,mediaQueries:{lg:{maxWidth:40}},children:e.jsx(v,{})}),e.jsx(n.StackView,{alignment:"center",spacing:1,maxWidth:45,mediaQueries:{lg:{alignment:"start",textAlign:"left"}},textAlign:"center",children:e.jsxs(e.Fragment,r?{children:[e.jsx(n.Heading,{...F,children:"Add an automation"}),e.jsx(n.StackView,{alignment:"center",marginBottom:1,mediaQueries:{lg:{alignment:"start"}},spacing:1,children:e.jsxs(n.Text,{...$,children:[i," ",e.jsx(n.Link,{inline:!0,external:!0,to:o,children:"Learn more"}),"."]})}),e.jsx(n.Button,{as:"button",theme:"primary",variant:"fill",onClick:()=>b(!0),children:"Create automation"}),e.jsx(gt,{open:x,onRequestClose:()=>b(!1),theme:O,children:e.jsx(rt,{defaultApp:l,description:i,blankStateLink:o,onRequestClose:()=>b(!1),trigger:u,afterCreateOptions:t})})]}:{children:[e.jsx(n.Heading,{...F,children:"Automations"}),e.jsx(n.Text,{...$,children:m})]})})]})}):e.jsx(e.Fragment,{}),c&&e.jsx(Le,{encryptedParam:c,trigger:u})]}),e.jsx("style",{children:'.swal2-popup.swal2-toast{align-items:stretch;background:#fff;box-shadow:0 0 .625em #d9d9d9;flex-direction:column;overflow-y:hidden;padding:1.25em;width:auto}.swal2-popup.swal2-toast .swal2-header{flex-direction:row;padding:0}.swal2-popup.swal2-toast .swal2-title{flex-grow:1;font-size:1em;justify-content:flex-start;margin:0 .625em}.swal2-popup.swal2-toast .swal2-loading{justify-content:center}.swal2-popup.swal2-toast .swal2-input{font-size:1em;height:2em;margin:.3125em auto}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em}.swal2-popup.swal2-toast .swal2-footer{font-size:.8em;margin:.5em 0 0;padding:.5em 0 0}.swal2-popup.swal2-toast .swal2-close{height:.8em;line-height:.8;position:static;width:.8em}.swal2-popup.swal2-toast .swal2-content{font-size:1em;justify-content:flex-start;margin:0 .625em;padding:0;text-align:initial}.swal2-popup.swal2-toast .swal2-html-container{padding:.625em 0 0}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0}.swal2-popup.swal2-toast .swal2-icon{height:2em;margin:0 .5em 0 0;min-width:2em;width:2em}.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{align-items:center;display:flex;font-size:1.8em;font-weight:700}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{font-size:.25em}}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{height:2em;width:2em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-popup.swal2-toast .swal2-actions{align-self:stretch;flex:1;flex-basis:auto!important;height:2.2em;height:auto;margin:.3125em .3125em 0;padding:0;width:auto}.swal2-popup.swal2-toast .swal2-styled{font-size:1em;margin:.125em .3125em;padding:.3125em .625em}.swal2-popup.swal2-toast .swal2-styled:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px rgba(100,150,200,.5)}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{border-radius:50%;height:3em;position:absolute;transform:rotate(45deg);width:1.6em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:4em 0 0 4em;left:-.5em;top:-.8em;transform:rotate(-45deg);transform-origin:2em 2em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 4em 4em 0;left:.9375em;top:-.25em;transform-origin:0 1.5em}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{height:2em;width:2em}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{height:2.6875em;left:.4375em;top:0;width:.4375em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{left:.1875em;top:1.125em;width:.75em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{right:.1875em;top:.9375em;width:1.375em}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}.swal2-popup.swal2-toast.swal2-show{animation:swal2-toast-show .5s}.swal2-popup.swal2-toast.swal2-hide{animation:swal2-toast-hide .1s forwards}.swal2-container{-webkit-overflow-scrolling:touch;align-items:center;bottom:0;display:flex;flex-direction:row;justify-content:center;left:0;overflow-x:hidden;padding:16px;position:fixed;right:0;top:0;transition:background-color .1s;z-index:1060}.swal2-container.swal2-backdrop-show,.swal2-container.swal2-noanimation{background:rgba(0,0,0,.4)}.swal2-container.swal2-backdrop-hide{background:transparent!important}.swal2-container.swal2-top{align-items:flex-start}.swal2-container.swal2-top-left,.swal2-container.swal2-top-start{align-items:flex-start;justify-content:flex-start}.swal2-container.swal2-top-end,.swal2-container.swal2-top-right{align-items:flex-start;justify-content:flex-end}.swal2-container.swal2-center{align-items:center}.swal2-container.swal2-center-left,.swal2-container.swal2-center-start{align-items:center;justify-content:flex-start}.swal2-container.swal2-center-end,.swal2-container.swal2-center-right{align-items:center;justify-content:flex-end}.swal2-container.swal2-bottom{align-items:flex-end}.swal2-container.swal2-bottom-left,.swal2-container.swal2-bottom-start{align-items:flex-end;justify-content:flex-start}.swal2-container.swal2-bottom-end,.swal2-container.swal2-bottom-right{align-items:flex-end;justify-content:flex-end}.swal2-container.swal2-bottom-end>:first-child,.swal2-container.swal2-bottom-left>:first-child,.swal2-container.swal2-bottom-right>:first-child,.swal2-container.swal2-bottom-start>:first-child,.swal2-container.swal2-bottom>:first-child{margin-top:auto}.swal2-container.swal2-grow-fullscreen>.swal2-modal{align-self:stretch;display:flex!important;flex:1;justify-content:center}.swal2-container.swal2-grow-row>.swal2-modal{align-content:center;display:flex!important;flex:1;justify-content:center}.swal2-container.swal2-grow-column{flex:1;flex-direction:column}.swal2-container.swal2-grow-column.swal2-bottom,.swal2-container.swal2-grow-column.swal2-center,.swal2-container.swal2-grow-column.swal2-top{align-items:center}.swal2-container.swal2-grow-column.swal2-bottom-left,.swal2-container.swal2-grow-column.swal2-bottom-start,.swal2-container.swal2-grow-column.swal2-center-left,.swal2-container.swal2-grow-column.swal2-center-start,.swal2-container.swal2-grow-column.swal2-top-left,.swal2-container.swal2-grow-column.swal2-top-start{align-items:flex-start}.swal2-container.swal2-grow-column.swal2-bottom-end,.swal2-container.swal2-grow-column.swal2-bottom-right,.swal2-container.swal2-grow-column.swal2-center-end,.swal2-container.swal2-grow-column.swal2-center-right,.swal2-container.swal2-grow-column.swal2-top-end,.swal2-container.swal2-grow-column.swal2-top-right{align-items:flex-end}.swal2-container.swal2-grow-column>.swal2-modal{align-content:center;display:flex!important;flex:1;justify-content:center}.swal2-container.swal2-no-transition{transition:none!important}.swal2-container:not(.swal2-top):not(.swal2-top-start):not(.swal2-top-end):not(.swal2-top-left):not(.swal2-top-right):not(.swal2-center-start):not(.swal2-center-end):not(.swal2-center-left):not(.swal2-center-right):not(.swal2-bottom):not(.swal2-bottom-start):not(.swal2-bottom-end):not(.swal2-bottom-left):not(.swal2-bottom-right):not(.swal2-grow-fullscreen)>.swal2-modal{margin:auto}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.swal2-container .swal2-modal{margin:0!important}}.swal2-popup{background:#fff;border:none;border-radius:5px;box-sizing:border-box;display:none;flex-direction:column;font-family:inherit;font-size:1rem;justify-content:center;max-width:100%;padding:24px 24px 20px;position:relative;width:512px}.swal2-popup:focus{outline:none}.swal2-popup.swal2-loading{overflow-y:hidden}.swal2-header{align-items:center;display:flex;flex-direction:column;padding:0 1.8em}.swal2-title{word-wrap:break-word;color:#595959;font-size:25px;font-weight:600;margin:0 0 18px;max-width:100%;padding:0;position:relative;text-align:center;text-transform:none}.swal2-actions{align-items:center;box-sizing:border-box;display:flex;flex-wrap:wrap;justify-content:center;margin:40px auto 0;padding:12px 0 0;width:100%;z-index:1}.swal2-actions:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}.swal2-actions:not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1))}.swal2-actions:not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0,0,0,.2),rgba(0,0,0,.2))}.swal2-loader{align-items:center;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-color:#2778c4 transparent;border-radius:100%;border-style:solid;border-width:.25em;display:none;height:2.2em;justify-content:center;margin:0 1.875em;width:2.2em}.swal2-styled{box-shadow:none;font-weight:400;margin:4px;padding:8px 24px}.swal2-styled:not([disabled]){cursor:pointer}.swal2-styled.swal2-confirm{background:initial;background-color:#1f93ff;border:0;border-radius:3px;color:#fff;font-size:16px}.swal2-styled.swal2-deny{background:initial;background-color:#e75146;border:0;border-radius:3px;color:#fff;font-size:16px}.swal2-styled.swal2-cancel{background:initial;background-color:transparent;border:0;border-radius:3px;color:#848484;font-size:16px}.swal2-styled:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5);outline:none}.swal2-styled::-moz-focus-inner{border:0}.swal2-footer{border-top:1px solid #eee;color:#545454;font-size:1em;justify-content:center;margin:1.25em 0 0;padding:1em 0 0}.swal2-timer-progress-bar-container{border-bottom-left-radius:5px;border-bottom-right-radius:5px;bottom:0;height:.25em;left:0;overflow:hidden;position:absolute;right:0}.swal2-timer-progress-bar{background:rgba(0,0,0,.2);height:.25em;width:100%}.swal2-image{margin:24px auto 26px;max-width:100%}.swal2-close{align-items:center;background:transparent;border:none;border-radius:5px;color:#ccc;cursor:pointer;font-family:serif;font-size:2.5em;height:1.2em;justify-content:center;line-height:1.2;overflow:hidden;padding:0;position:absolute;right:0;top:0;transition:color .1s ease-out;width:1.2em;z-index:2}.swal2-close:hover{background:transparent;color:#f27474;transform:none}.swal2-close:focus{box-shadow:inset 0 0 0 3px rgba(100,150,200,.5);outline:none}.swal2-close::-moz-focus-inner{border:0}.swal2-content{word-wrap:break-word;color:#848484;font-size:16px;font-weight:400;justify-content:center;line-height:1.4em;margin:-5px 0;padding:0 1.6em;text-align:center;z-index:1}.swal2-checkbox,.swal2-file,.swal2-input,.swal2-radio,.swal2-select,.swal2-textarea{margin:1em auto}.swal2-file,.swal2-input,.swal2-textarea{background:inherit;border:1px solid #d9d9d9;border-radius:.1875em;box-shadow:inset 0 1px 1px rgba(0,0,0,.06);box-sizing:border-box;color:inherit;font-size:1.125em;transition:border-color .3s,box-shadow .3s;width:100%}.swal2-file.swal2-inputerror,.swal2-input.swal2-inputerror,.swal2-textarea.swal2-inputerror{border-color:#f27474!important;box-shadow:0 0 2px #f27474!important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{border:1px solid #b4dbed;box-shadow:0 0 0 3px rgba(100,150,200,.5);outline:none}.swal2-file::-moz-placeholder,.swal2-input::-moz-placeholder,.swal2-textarea::-moz-placeholder{color:#ccc}.swal2-file::placeholder,.swal2-input::placeholder,.swal2-textarea::placeholder{color:#ccc}.swal2-range{background:#fff;margin:1em auto}.swal2-range input{width:80%}.swal2-range output{color:inherit;font-weight:600;text-align:center;width:20%}.swal2-range input,.swal2-range output{font-size:1.125em;height:2.625em;line-height:2.625em;padding:0}.swal2-input{height:2.625em;padding:0 .75em}.swal2-input[type=number]{max-width:10em}.swal2-file{background:inherit;font-size:1.125em}.swal2-textarea{height:6.75em;padding:.75em}.swal2-select{background:inherit;color:inherit;font-size:1.125em;max-width:100%;min-width:50%;padding:.375em .625em}.swal2-checkbox,.swal2-radio{align-items:center;background:#fff;color:inherit;justify-content:center}.swal2-checkbox label,.swal2-radio label{font-size:1.125em;margin:0 .6em}.swal2-checkbox input,.swal2-radio input{flex-shrink:0;margin:0 .4em}.swal2-input-label{display:flex;justify-content:center;margin:1em auto}.swal2-validation-message{align-items:center;background:#f0f0f0;color:#666;font-size:1em;font-weight:300;justify-content:center;margin:0 -2.7em;overflow:hidden;padding:.625em}.swal2-validation-message:before{background-color:#f27474;border-radius:50%;color:#fff;content:"!";display:inline-block;font-weight:600;height:1.5em;line-height:1.5em;margin:0 .625em;min-width:1.5em;text-align:center;width:1.5em}.swal2-icon{border:.25em solid #000;border-radius:50%;box-sizing:content-box;cursor:default;font-family:inherit;height:5em;justify-content:center;line-height:5em;margin:24px auto 32px;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:5em}.swal2-icon .swal2-icon-content{align-items:center;display:flex;font-size:3.75em}.swal2-icon.swal2-error{border-color:#f27474;color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{flex-grow:1;position:relative}.swal2-icon.swal2-error [class^=swal2-x-mark-line]{background-color:#f27474;border-radius:.125em;display:block;height:.3125em;position:absolute;top:2.3125em;width:2.9375em}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}.swal2-icon.swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}.swal2-icon.swal2-warning{border-color:#facea8;color:#f8bb86}.swal2-icon.swal2-info{border-color:#9de0f6;color:#3fc3ee}.swal2-icon.swal2-question{border-color:#c9dae1;color:#87adbd}.swal2-icon.swal2-success{border-color:#a5dc86;color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{border-radius:50%;height:7.5em;position:absolute;transform:rotate(45deg);width:3.75em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:7.5em 0 0 7.5em;left:-2.0635em;top:-.4375em;transform:rotate(-45deg);transform-origin:3.75em 3.75em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 7.5em 7.5em 0;left:1.875em;top:-.6875em;transform:rotate(-45deg);transform-origin:0 3.75em}.swal2-icon.swal2-success .swal2-success-ring{border:.25em solid hsla(98,55%,69%,.3);border-radius:50%;box-sizing:content-box;height:100%;left:-.25em;position:absolute;top:-.25em;width:100%;z-index:2}.swal2-icon.swal2-success .swal2-success-fix{height:5.625em;left:1.625em;position:absolute;top:.5em;transform:rotate(-45deg);width:.4375em;z-index:1}.swal2-icon.swal2-success [class^=swal2-success-line]{background-color:#a5dc86;border-radius:.125em;display:block;height:.3125em;position:absolute;z-index:2}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{left:.8125em;top:2.875em;transform:rotate(45deg);width:1.5625em}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{right:.5em;top:2.375em;transform:rotate(-45deg);width:2.9375em}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}.swal2-progress-steps{align-items:center;background:inherit;flex-wrap:wrap;font-weight:600;margin:0 0 1.25em;max-width:100%;padding:0}.swal2-progress-steps li{display:inline-block;position:relative}.swal2-progress-steps .swal2-progress-step{background:#2778c4;border-radius:2em;color:#fff;flex-shrink:0;height:2em;line-height:2em;text-align:center;width:2em;z-index:20}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:#add8e6;color:#fff}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:#add8e6}.swal2-progress-steps .swal2-progress-step-line{background:#2778c4;flex-shrink:0;height:.4em;margin:0 -1px;width:2.5em;z-index:10}[class^=swal2]{-webkit-tap-highlight-color:transparent}.swal2-hide,.swal2-show{animation:none}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{height:50px;overflow:scroll;position:absolute;top:-9999px;width:50px}.swal2-rtl .swal2-close{left:0;right:auto}.swal2-rtl .swal2-timer-progress-bar{left:auto;right:0}@supports (-ms-accelerator:true){.swal2-range input{width:100%!important}.swal2-range output{display:none}}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.swal2-range input{width:100%!important}.swal2-range output{display:none}}@keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotate(2deg)}33%{transform:translateY(0) rotate(-2deg)}66%{transform:translateY(.3125em) rotate(2deg)}to{transform:translateY(0) rotate(0deg)}}@keyframes swal2-toast-hide{to{opacity:0;transform:rotate(1deg)}}@keyframes swal2-toast-animate-success-line-tip{0%{left:.0625em;top:.5625em;width:0}54%{left:.125em;top:.125em;width:0}70%{left:-.25em;top:.625em;width:1.625em}84%{left:.75em;top:1.0625em;width:.5em}to{left:.1875em;top:1.125em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{right:1.375em;top:1.625em;width:0}65%{right:.9375em;top:1.25em;width:0}84%{right:0;top:.9375em;width:1.125em}to{right:.1875em;top:.9375em;width:1.375em}}@keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}to{transform:scale(1)}}@keyframes swal2-hide{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.5)}}@keyframes swal2-animate-success-line-tip{0%{left:.0625em;top:1.1875em;width:0}54%{left:.125em;top:1.0625em;width:0}70%{left:-.375em;top:2.1875em;width:3.125em}84%{left:1.3125em;top:3em;width:1.0625em}to{left:.8125em;top:2.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{right:2.875em;top:3.375em;width:0}65%{right:2.875em;top:3.375em;width:0}84%{right:0;top:2.1875em;width:3.4375em}to{right:.5em;top:2.375em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}to{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;opacity:0;transform:scale(.4)}50%{margin-top:1.625em;opacity:0;transform:scale(.4)}80%{margin-top:-.375em;transform:scale(1.15)}to{margin-top:0;opacity:1;transform:scale(1)}}@keyframes swal2-animate-error-icon{0%{opacity:0;transform:rotateX(100deg)}to{opacity:1;transform:rotateX(0deg)}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;bottom:auto;left:auto;max-width:calc(100% - 32px);right:auto;top:auto}body.swal2-no-backdrop .swal2-container>.swal2-modal{box-shadow:0 0 10px rgba(0,0,0,.4)}body.swal2-no-backdrop .swal2-container.swal2-top{left:50%;top:0;transform:translateX(-50%)}body.swal2-no-backdrop .swal2-container.swal2-top-left,body.swal2-no-backdrop .swal2-container.swal2-top-start{left:0;top:0}body.swal2-no-backdrop .swal2-container.swal2-top-end,body.swal2-no-backdrop .swal2-container.swal2-top-right{right:0;top:0}body.swal2-no-backdrop .swal2-container.swal2-center{left:50%;top:50%;transform:translate(-50%,-50%)}body.swal2-no-backdrop .swal2-container.swal2-center-left,body.swal2-no-backdrop .swal2-container.swal2-center-start{left:0;top:50%;transform:translateY(-50%)}body.swal2-no-backdrop .swal2-container.swal2-center-end,body.swal2-no-backdrop .swal2-container.swal2-center-right{right:0;top:50%;transform:translateY(-50%)}body.swal2-no-backdrop .swal2-container.swal2-bottom{bottom:0;left:50%;transform:translateX(-50%)}body.swal2-no-backdrop .swal2-container.swal2-bottom-left,body.swal2-no-backdrop .swal2-container.swal2-bottom-start{bottom:0;left:0}body.swal2-no-backdrop .swal2-container.swal2-bottom-end,body.swal2-no-backdrop .swal2-container.swal2-bottom-right{bottom:0;right:0}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static!important}}body.swal2-toast-shown .swal2-container{background-color:transparent}body.swal2-toast-shown .swal2-container.swal2-top{bottom:auto;left:50%;right:auto;top:0;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{bottom:auto;left:auto;right:0;top:0}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{bottom:auto;left:0;right:auto;top:0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{bottom:auto;left:0;right:auto;top:50%;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{bottom:auto;left:50%;right:auto;top:50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{bottom:auto;left:auto;right:0;top:50%;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{bottom:0;left:0;right:auto;top:auto}body.swal2-toast-shown .swal2-container.swal2-bottom{bottom:0;left:50%;right:auto;top:auto;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{bottom:0;left:auto;right:0;top:auto}.swal2-actions{border-top:1px solid #e0e0e0}'})]})};
|
|
2
2
|
//# sourceMappingURL=core-automations.js.map
|