@boltic/swirl 1.0.2-sit.89 → 1.0.2-sit.90

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/swirl.umd.js CHANGED
@@ -684,7 +684,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
684
684
  `),we>0&&Et(Dt)&&(nt+=`
685
685
  `)}),nt},He=function(Ge,nt){Be(nt),Re.current=!0;var Et=_e.selection;if(!Et){var yt=Fe(nt);it.current=!1,Ge?.(yt);return}try{var Dt=Le.node(_e,Et),we=Dt[0],Qe=Dt[1];if(!Zi.isElement(we)&&"text"in we)for(var Je=we.text,De=Array.from(Je.matchAll(qe)),at=De.length-1;at>=0;at--){var Ot=De[at],Zt=Ot[1].trim();if(Zt){var ur=Ot.index,Br=ur+Ot[0].length,hn={type:"chip",suggestion:{id:Date.now()+Math.random(),activityNumber:1,label:Zt,value:Zt,icon:C.createElement(zr,{src:"ic_function",width:20,height:20,sx:{path:{fill:Ye.palette.primary.main}}})},children:[{text:""}]};Ut.delete(_e,{at:{anchor:{path:Qe,offset:ur},focus:{path:Qe,offset:Br}}}),Ut.insertNodes(_e,hn,{at:{path:Qe,offset:ur}}),Ut.move(_e)}}}catch{}var sn=Fe(nt);it.current=!1,Ge?.(sn),Y?.({field:o,value:sn,fieldData:t})},dt=C.useCallback(function(Ke){ge(function(Zt){var ur=Zt.filter(function(Br){return Br.id!==Ke});return J?.(ur),ur});var Ge=Array.from(Le.nodes(_e,{at:[],match:function(ur){var Br;return Zi.isElement(ur)&&ur.type==="chip"&&((Br=ur.suggestion)===null||Br===void 0?void 0:Br.id)===Ke}}))[0];if(Ge){var nt=Ge[1],Et=ht.parent(nt),yt=nt[nt.length-1],Dt=Le.node(_e,Et),we=Dt[0],Qe=null,Je=0;if(yt>0){var De=we?.children[yt-1];Zi.isElement(De)||(Qe=[].concat(Et,[yt-1]),Je=De.text.length)}Qe||(Ut.insertNodes(_e,{text:""},{at:[].concat(Et,[yt])}),Qe=[].concat(Et,[yt]),Je=0),Ut.removeNodes(_e,{at:nt});try{var at={path:Qe,offset:Je},Ot={anchor:at,focus:at};Ut.select(_e,Ot),ir.focus(_e)}catch{}}},[_e,J]),Tt=C.useCallback(function(Ke){Ke.key==="Enter"&&M==="xs"&&Ke.preventDefault()},[M]),Ie=C.useCallback(function(Ke){var Ge={type:"chip",suggestion:Ke,children:[{text:""}]};Ut.insertNodes(_e,Ge),Ut.move(_e);var nt=_e.selection;if(nt){var Et=Le.node(_e,nt),yt=Et[0];Zi.isElement(yt)&&yt.type==="chip"&&Ut.insertNodes(_e,{text:""})}},[_e]),lt=function(Ge){var nt=[].concat(xe,[Ge]);ge(nt),J?.(nt),Ie(Ge)},ct=C.useCallback(function(Ke){Ke.preventDefault();var Ge=Ke.clipboardData.getData("text/plain"),nt=Ge;M==="xs"&&(nt=Ge.replace(/\r?\n/g," "));try{var Et=JSON.parse(Ge);typeof Et=="object"&&Et!==null&&"type"in Et&&"props"in Et||_e.insertText(nt)}catch{_e.insertText(nt)}},[_e,M]),rt=C.useCallback(function(Ke){Ke.preventDefault();var Ge=_e.getFragment(),nt="",Et=function(we){return!Zi.isElement(we)||we.type!=="paragraph"?!1:we.children.every(function(Qe){if("text"in Qe){var Je=Qe.text||"";return Je===""||Je.trim()===""||Je==="\uFEFF"||Je==="​"||/^[\s\n\r]*$/.test(Je)}return!1})},yt=function(we){if(Zi.isElement(we)){if(we.type==="chip"){var Qe;return"{{"+(we==null||(Qe=we.suggestion)===null||Qe===void 0?void 0:Qe.label)+"}}"}else if(we.children){var Je="";return we.children.forEach(function(De){Je+=yt(De)}),Je}}else if("text"in we)return we.text;return""};Ge.forEach(function(Dt,we){var Qe=yt(Dt);nt+=Qe,we<Ge.length-1&&(nt+=`
686
686
  `),we>0&&Et(Dt)&&(nt+=`
687
- `)}),Ke.clipboardData.setData("text/plain",nt)},[_e]),kt=C.useCallback(function(){te(!0)},[te]),Gt=C.useCallback(function(){te(!1)},[te]),St=C.useCallback(function(Ke){var Ge=Ke.element,nt=!1;if(Ge.type==="chip"&&_e.selection)try{var Et=ir.findPath(_e,Ge),yt=_e.selection;if(yt&&!Yt.isCollapsed(yt)){var Dt=Yt.edges(yt),we=Dt[0],Qe=Dt[1],Je={path:Et,offset:0};nt=ht.compare(Je.path,we.path)>=0&&ht.compare(Je.path,Qe.path)<=0}}catch{nt=!1}switch(Ge.type){case"chip":return C.createElement(got,Object.assign({},Ke,{suggestion:Ge.suggestion,onDelete:function(){return!Q&&!T&&!_&&dt(Ge.suggestion.id)},isSelected:nt}));case"paragraph":return C.createElement(Oot,Object.assign({},Ke,{size:M}));default:return C.createElement(Eot,Object.assign({},Ke,{size:M}))}},[dt,M,_e]),je=C.useCallback(function(){try{var Ke=_e.children[0],Ge=_e.children.length===1&&Zi.isElement(Ke)&&Ke.children.length===1&&"text"in Ke.children[0]&&Ke.children[0].text==="";return Ge?"100%":"auto"}catch{return"auto"}},[_e]);return C.createElement(E.FormControl,{className:"meta-form-control "+u,sx:{width:"100%",maxWidth:"100%",position:"relative"},fullWidth:!0,key:o,ref:et},(f||H)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:X},C.createElement(Qo,{className:"meta-select-label",required:P,description:O,label:f}),C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:4,color:"neutral.80"},H)),C.createElement(E.Paper,{elevation:0,sx:ar(ar(ar(ar(ar({border:"1px solid "+(he&&$e?dn.error.main:dn.neutral.outlined.border),":hover":{borderColor:dn.text.primary}},Z&&{border:"1px solid "+Ye.palette.primary.main,":hover":{borderColor:Q||T||_?dn.text.secondary:Ye.palette.primary.main}}),{},{display:"flex"},(Q||T||_)&&st&&{opacity:.4}),(Q||T||_)&&{cursor:"not-allowed"}),{},{justifyContent:"center",gap:"1rem"},fot[M]),M!=="xs"&&D&&{resize:"vertical",overflowY:"auto",position:"relative","&::after":{content:'""',display:"block",position:"absolute",width:"18px",height:"18px",bottom:"2px",right:"2px",cursor:"nwse-resize",backgroundImage:"linear-gradient(135deg, transparent 0px, transparent 3px, "+Ye.palette.grey[500]+" 3px, "+Ye.palette.grey[500]+" 4px,)",pointerEvents:"none"}})},C.createElement(E.Box,{sx:ar(ar(ar(ar({flex:1,overflow:"auto"},M==="xs"&&{overflowX:"auto",overflowY:"hidden","-ms-overflow-style":"none","scrollbar-width":"none"}),D&&M!=="xs"?{height:"100%"}:{maxHeight:pot[M]}),{},{"&::-webkit-scrollbar":{display:"none"},'& [data-slate-node="text"]':{minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative",marginRight:"6px",width:je}},M==="xs"&&{"&::-webkit-scrollbar":{display:"none"},'& [data-testid="paragraph-element"]::-webkit-scrollbar':{display:"none"}}),{},{'& [data-slate-node="text"]:empty::before, & [data-slate-zero-width="n"]::before':{content:'""',display:"inline-block",minWidth:"1px",minHeight:"16px",position:"relative"},'& [data-slate-placeholder="true"] [data-slate-node="text"]:empty::before, & [data-slate-placeholder="true"] [data-slate-zero-width="n"]::before':{display:"none !important"},'& [data-testid="paragraph-element"]':{marginBottom:M==="xs"?"0":"1px"},'& [data-testid="paragraph-element"]:not(:last-child)':{marginBottom:M==="xs"?"0":"2px"}})},C.createElement(ws,{name:o,control:U,rules:vt($)?{}:ar(ar({},$),{},{validate:function(Ge){return/^\s*$/.test(Ge)&&P?"Field cannot consist solely of spaces. Please include some characters.":Ge&&h==="url"?vx(Ge)?!0:"Enter a valid URL":Ge&&h==="email"?Tx(Ge)?!0:"Enter a valid email":!0}}),render:function(Ge){var nt=Ge.field,Et=nt.onChange,yt=el(nt,Aot);return C.createElement(H7,Object.assign({editor:_e,initialValue:Te,onChange:function(we){return He(Et,we)}},yt),C.createElement(j7,Object.assign({id:ae,renderElement:St,onKeyDown:Tt,onPaste:ct,onClick:function(we){return!Q&&!T&&!_&&oe(we.currentTarget)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",onCopy:rt,"data-testid":"suggestion-input-"+o,placeholder:b,readOnly:Q||T||_,style:ar({outline:"none",wordWrap:M==="xs"?"normal":"break-word",whiteSpace:M==="xs"?"pre":"pre-wrap",overflowWrap:M==="xs"?"normal":"break-word",fontWeight:500,fontSize:14,lineHeight:"20px",fontFamily:"Inter"},T&&{opacity:.45}),onFocus:kt,onBlur:Gt},ue)))}})),V&&!Q&&!T&&C.createElement(E.IconButton,{size:"small",onClick:function(Ge){return oe(function(nt){return nt?null:Ge.currentTarget})},"data-testid":"add-suggestion-btn",title:"Click to add dynamic values",sx:ar({height:"1rem",width:"1rem",alignItems:"center",justifyContent:"center",padding:"0.5rem",border:"1px solid "+dn.neutral.outlined.border,borderRadius:"0.25rem"},M==="xs"&&{":hover":{backgroundColor:"transparent"}})},C.createElement(zr,{src:"ic_plus",width:16,height:16}))),C.createElement(E.Stack,null,he&&$e&&C.createElement(E.FormHelperText,{component:"span",error:!0,dangerouslySetInnerHTML:{__html:xo($e)}})),C.createElement(qte,{anchorEl:ve,setAnchorEl:oe,handleSuggestionClick:lt,suggestionsData:z,ref:et,handleCustom:ne,isLoading:le}))},got=function(t){var r=t.attributes,n=t.children,i=t.suggestion,o=t.onDelete,s=t.isSelected,a=function(u){u.stopPropagation(),u.preventDefault(),o()};return C.createElement("span",Object.assign({},r,{contentEditable:!1,"data-testid":i?.label+"-chip",style:{display:"inline",marginRight:4}}),C.createElement(dot,{suggestion:i,onDelete:a,isSelected:s}),n)},Eot=function(t){var r=t.attributes,n=t.children,i=t.size;return C.createElement("span",Object.assign({},r,{"data-testid":"default-element",style:ar({minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative"},i==="xs"&&{flexWrap:"nowrap",gap:"2px 0"})}),n)},Oot=function(t){var r=t.attributes,n=t.children,i=t.size;return C.createElement("div",Object.assign({},r,{"data-testid":"paragraph-element",style:ar(ar({margin:0,padding:0},i!=="xs"&&{display:"flex",flexWrap:"wrap"}),{},{gap:i==="xs"?"4px":"4px 0px",alignItems:"center",minHeight:"20px",position:"relative"},i==="xs"&&{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none"})}),n)},yot=function(t){var r=t.name,n=t.control,i=t.meta,o=t.onFocus,s=t.handleChange,a=t.validationRules,l=t.viewOnly,u=l===void 0?!1:l,c=t.MCP_INTEGRATION_FORM,f=i||{},p=f.displayName,h=p===void 0?"":p,A=f.value,g=A===void 0?!1:A,m=f.description,O=m===void 0?"":m,y=f.error,T=y===void 0?{}:y,v=f.readOnly,_=v===void 0?!1:v,x=f.isDisabled,b=x===void 0?!1:x,w=f.validation,R=w===void 0?{}:w,I=R.disabled,P=I===void 0?!1:I,k=R.required,N=k===void 0?!1:k,L=f.htmlProps,M=L===void 0?{}:L,B=f.htmlProps,H=B===void 0?{}:B,j=H.allowDynamic,X=j===void 0?!1:j,F=xo(O),V=C.useState(!1),G=V[0],D=V[1];C.useEffect(function(){typeof g=="string"&&g==="true"?D(!0):typeof g=="boolean"&&D(g)},[]);var $=function(q){o(q,r)};return C.createElement(E.FormControl,{fullWidth:!0,error:T!=null&&T.hasError?!0:void 0,sx:{marginTop:"8px"}},C.createElement(ws,{name:r,control:n,rules:a,defaultValue:G,render:function(q){var z=q.field,W=q.fieldState,Q=W===void 0?{}:W,Y=Q.error;return C.createElement(E.Stack,{spacing:"0.25rem"},C.createElement(E.Stack,{sx:{width:"100%",flexDirection:"row",alignItems:"center",justifyContent:X?"flex-end":"space-between"}},!X&&h&&C.createElement(Qo,{required:N,label:h,description:F}),C.createElement(E.FormControlLabel,Object.assign({disabled:P,label:c?"":z.value?"On":"Off",labelPlacement:"start",control:C.createElement(E.Switch,Object.assign({},z,{onFocus:$,onChange:function(ee){var le=ee.target.checked;(!u||r==="advanced_options")&&(z.onChange(le),s({field:r,value:z.value,fieldData:t}))},onBlur:z.onBlur,value:z.value,checked:z.value,name:r,readOnly:_,disabled:b||u&&r!=="advanced_options","data-testid":"ripple-switch-"+r}))},M,{htmlFor:r}))),Y?.message&&C.createElement(E.FormHelperText,{error:!!(Y!=null&&Y.message)},Y?.message))}}))},ire=C.createContext({fieldControlStates:{},setFieldControlState:function(){},getFieldControlState:function(){return""},transformFormData:function(t,r){return r}}),vot=function(t){var r=t.children,n=C.useState({}),i=n[0],o=n[1],s=function(c,f){o(function(p){var h;return ar(ar({},p),{},(h={},h[c]=f,h))})},a=function(c){return i[c]||""},l=function(c,f){if(!c||!f)return f;var p=ar({},f);return c.forEach(function(h){var A,g,m,O,y=h.name,T=f[y],v=a(y);if(T?p[y]=T:(!v||v==="")&&!T?p[y]="BOLTIC_AI":["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(v)&&(p[y]=v),(h==null||(A=h.meta)===null||A===void 0?void 0:A.displayType)==="array"&&Array.isArray(T)&&(g=h.meta)!==null&&g!==void 0&&g.children)p[y]=T.map(function(x){var b;return l((b=h.meta)===null||b===void 0?void 0:b.children,x)});else if((h==null||(m=h.meta)===null||m===void 0?void 0:m.displayType)==="object"&&typeof T=="object"&&T!==null&&(O=h.meta)!==null&&O!==void 0&&O.children){var _;p[y]=l((_=h.meta)===null||_===void 0?void 0:_.children,T)}}),p};return C.createElement(ire.Provider,{value:{fieldControlStates:i,setFieldControlState:s,getFieldControlState:a,transformFormData:l}},r)},ore=function(){return C.useContext(ire)},Tot=function(t){return function(n){var i,o,s,a,l=n.MCP_INTEGRATION_FORM,u=l===void 0?!1:l,c=n.name,f=c===void 0?"":c,p=n.MCP_EXCLUDED_FIELDS,h=p===void 0?[]:p,A=n.field,g=A===void 0?{}:A,m=n.handleChange,O=n.meta,y=O===void 0?{}:O,T=y.displayName,v=T===void 0?"":T,_=y.description,x=_===void 0?"":_,b=y.htmlProps,w=b===void 0?{}:b,R=rs(),I=R.setValue,P=w.showInfoIcon,k=P===void 0?!1:P,N=w.rightLabel,L=N===void 0?"":N,M=w.rightLabelAlignment,B=M===void 0?"center":M,H=w.showAddNew,j=H===void 0?!1:H,X=xo(x),F=rs(),V=(i=F.getValues)===null||i===void 0?void 0:i.call(F,f),G=ore(),D=G.setFieldControlState,$=C.useState(u?"BOLTIC_AI":"specific"),U=$[0],q=$[1];C.useEffect(function(){if(u){var Q="BOLTIC_AI";["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(V)?Q=V:V&&V!==""&&(Q="specific"),q(Q),D(f,Q)}},[]);var z=function(Y){var J=Y.target.value;q(J),D(f,J),["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(J)?(I(f,J),m?.({field:f,value:J,fieldData:n})):(I(f,""),m?.({field:f,value:"",fieldData:n}))},W=ar(ar({},n.meta),{},{htmlProps:ar(ar({},n==null||(o=n.meta)===null||o===void 0?void 0:o.htmlProps),{},{rightLabel:"",showInfoIcon:!1}),validation:{infoDetail:{infoMsg:""}},displayName:""});return u&&!h.includes(f)&&!["array","object","section"].includes(f)&&!g.hidden&&!f.includes("toolParamsMcp")?C.createElement(E.Stack,{spacing:j||L?0:"0.5rem"},C.createElement(E.FormControl,{fullWidth:!0},(v||L||k)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:B},C.createElement(Qo,{required:n==null||(s=n.meta)===null||s===void 0||(a=s.validation)===null||a===void 0?void 0:a.required,label:v,description:X}),L&&C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:"0.25rem",color:"neutral.80"},L)),C.createElement(E.Select,{value:U,onChange:z,label:"Field Value Control"},C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI"},"Have AI generate a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE"},"Do not include a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"specific"},"Set a specific value for this field"))),U==="specific"&&C.createElement(t,Object.assign({},n,{meta:ar({},W)}))):C.createElement(t,Object.assign({},n))}},oi={ACCORDION:"accordion",DIVIDER:"divider",SECTION:"section",TEXT:"text",SELECT:"select",RADIO:"radio",CHECKBOX:"checkbox",EMAIL:"email",NUMBER:"number",PASSWORD:"password",AUTOCOMPLETE:"autocomplete",FILE:"file",CODE:"code",BUTTON:"button",HIDDEN:"hidden",MULTITEXT:"multitext",TEXTAREA:"textarea",MULTISELECT:"multiselect",TOGGLE:"toggle",RADIOBUTTON:"radiobutton",ARRAY:"array",OBJECT:"object",PHONE:"phone",URL:"url",DATE:"date",TIME:"time",DATETIME:"datetime",KEYVALUE:"keyvalue",SLIDER:"slider"},Sot=function(t){var r,n=t.hidden,i=n===void 0?!0:n,o=t.meta,s=o===void 0?{}:o,a=s.displayType,l=a===void 0?"":a,u=s.displayName,c=u===void 0?"":u,f=s.htmlProps,p=f===void 0?{}:f,h=p.allowDynamic,A=h===void 0?!1:h,g=p.showInfoIcon,m=g===void 0?!1:g,O=p.rightLabel,y=O===void 0?"":O,T=p.size,v=T===void 0?"":T,_=p.overrideDynamicSupport,x=_===void 0?!1:_,b=s.validation,w=b===void 0?{}:b,R=w.infoDetail,I=R===void 0?{}:R,P=I.infoMsg,k=P===void 0?"":P,N=s.validation,L=N===void 0?{}:N,M=s.description,B=M===void 0?"":M,H=s.readOnly,j=H===void 0?!1:H,X=t.suggestions,F=X===void 0?{}:X,V=t.viewOnly,G=V===void 0?!1:V,D=F&&Object?.keys(F),$=["email","password","url","number","code","text","textarea"],U=(A||$.includes(l))&&D?.length>0,q=!["object"].includes(l),z=ar(ar({},t.meta),{},{htmlProps:ar(ar({},t==null||(r=t.meta)===null||r===void 0?void 0:r.htmlProps),{},{rightLabel:U&&q?"":y,showInfoIcon:U&&q?!1:m}),validation:ar(ar({},L),{},{infoDetail:{infoMsg:U&&q?"":k}}),displayName:U&&q?"":c}),W=rs(),Q=W.getValues,Y=W.setValue,J=W.watch,ee=C.useState("static"),le=ee[0],ne=ee[1],ue=C.useRef(null),Oe=function(dt,Tt){if(Tt==="static"){var Ie;Y(t.name,(t==null||(Ie=t.meta)===null||Ie===void 0?void 0:Ie.value)||"")}else{var lt;Y(t.name,String((t==null||(lt=t.meta)===null||lt===void 0?void 0:lt.value)||""))}ne(Tt)};C.useEffect(function(){var He=Q(t.name);typeof He=="string"&&He.startsWith("{{")?ne("dynamic"):ne("static")},[]);var ve=J(t.name),oe=(A&&!["text","textarea"].includes(l)||["email","password","url","number"].includes(l))&&!["file","code"].includes(l)&&!x&&!G&&!j&&D.length>0,ae=function(dt,Tt){var Ie,lt;return Tt===void 0&&(Tt="xs"),C.createElement(E.Stack,{className:"dynamic-wrapper"},C.createElement(E.FormControl,{fullWidth:!0,ref:ue},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&D?.length>0&&C.createElement(E.Stack,{alignItems:"flex-end",justifyContent:"space-between",direction:"row",pb:oe?"4px":0},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&D?.length>0&&C.createElement(Qo,{className:"meta-select-label",required:t==null||(Ie=t.meta)===null||Ie===void 0||(lt=Ie.validation)===null||lt===void 0?void 0:lt.required,label:c,description:B||k}),oe&&C.createElement(E.Tabs,{value:le,onChange:Oe,"aria-label":"select type",TabIndicatorProps:{sx:{display:"none"}}},rit.map(function(ct,rt){return C.createElement(E.Tab,{key:rt,label:ct.label,value:ct.value})}))),(le==="dynamic"&&l!==oi.CODE||["text","textarea"].includes(l))&&!x&&l!=="file"&&D&&D.length>0&&C.createElement(E.Stack,null,C.createElement(mot,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:ar(ar({},t.meta),{},{displayName:"",htmlProps:ar(ar({},t.meta.htmlProps),{},{showSuggestions:!0,size:Tt,rightLabel:""}),validation:L}),validationRules:ve!=null&&ve.includes("{")?{}:t?.validationRules}))),(le!=="dynamic"||l===oi.CODE)&&(!["text","textarea"].includes(l)||["text","textarea"].includes(l)&&vt(F)||x)&&dt))};if(i||l==="hidden")return null;var re=function(dt,Tt,Ie){return C.createElement(Xit,Object.assign({},t,{type:dt,htmlProps:Tt,textFieldProps:Ie,meta:z}))},Z=function(){var dt,Tt,Ie=(dt=t==null||(Tt=t.validation)===null||Tt===void 0?void 0:Tt.max)!=null?dt:"",lt=Ie?{maxLength:Ie}:void 0;return re("text",lt)},te=function(){var dt={type:"password"};return re("password",dt)},se=function(){return re("email")},he=function(){return re("number")},pe=function(){return re("url")},de=function(){var dt,Tt,Ie=t.meta.htmlProps,lt={multiline:!0,minRows:(dt=Ie?.minRows)!=null?dt:2,maxRows:(Tt=Ie?.maxRows)!=null?Tt:2};return re("text",{},lt)},xe=function(){return C.createElement(oot,Object.assign({},t,{meta:z}))},ge=function(){return C.createElement(cit,Object.assign({},t,{meta:z}))},Ee=function(){return C.createElement(lot,Object.assign({},t,{meta:z}))},ke=function(){return C.createElement(Jit,Object.assign({},t,{meta:z}))},We=function(){return C.createElement(uit,Object.assign({},t))},$e=function(){return C.createElement(Wit,Object.assign({},t))},et=function(){return C.createElement($it,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:ar(ar({},t.meta),{},{htmlProps:ar(ar({},t.meta.htmlProps),{},{showSuggestions:!0})})}))},st=function(){return C.createElement(Qit,Object.assign({},t))},it=function(){return C.createElement(sot,Object.assign({},t))},Re=function(){return C.createElement(Hit,Object.assign({},t))},qe=function(){return C.createElement(yot,Object.assign({},t))},Ye=function(){return C.createElement(iot,Object.assign({},t,{meta:z}))},Se=function(){return C.createElement(Yit,Object.assign({},t,{meta:z}))},_e=function(){return C.createElement(Uit,Object.assign({},t,{meta:z}))},be=function(){return C.createElement(not,Object.assign({},t,{meta:z}))},K=function(){return C.createElement(ait,Object.assign({},t,{meta:z}))},ce=function(){return C.createElement(eot,Object.assign({},t,{meta:z}))},Te=function(){return C.createElement(qit,Object.assign({},t,{meta:z}))},Be=function(){return C.createElement(cot,Object.assign({},t,{meta:z}))},Fe=function(){return C.createElement(Ynt,Object.assign({},t,{meta:z}))};switch(l){case oi.TEXT:return ae(Z());case oi.PASSWORD:return ae(te());case oi.EMAIL:return ae(se());case oi.NUMBER:return ae(he());case oi.URL:return ae(pe());case oi.RADIO:return ae(xe());case oi.RADIOBUTTON:return ae(Ye());case oi.CHECKBOX:return ae(ge());case oi.CODE:return ae(et(),v||"md");case oi.TEXTAREA:return ae(de(),v||"sm");case oi.SELECT:case oi.AUTOCOMPLETE:return ae(Ee());case oi.MULTISELECT:return ae(ke());case oi.BUTTON:return ae(We());case oi.TOGGLE:return ae(qe());case oi.MULTITEXT:return ae(Se());case oi.HIDDEN:return st();case oi.FILE:return ae($e());case oi.SECTION:return ae(it());case oi.DIVIDER:return ae(Re());case oi.PHONE:return ae(be());case oi.DATE:return ae(_e());case oi.TIME:return ae(_e());case oi.DATETIME:return ae(_e());case oi.ARRAY:return ae(K(),v||"md");case oi.OBJECT:return ae(ce(),v||"md");case oi.KEYVALUE:return ae(Te(),v||"md");case oi.SLIDER:return ae(Be());case oi.ACCORDION:return ae(Fe());default:return C.createElement(E.Box,null,"Display Type: ",l," is not supported!")}},e0=Tot(C.memo(Sot)),xot=function(t,r){var n=C.useState(t),i=n[0],o=n[1],s=C.useCallback(function(a){return a?.map(function(l){var u,c=l?.meta||{},f=c.dependencies;if(f){var p=f.logic,h=p===void 0?"AND":p,A=f.conditions,g=A===void 0?[]:A,m=h==="AND";g.forEach(function(y){var T,v=y.operator,_=y.field,x=y.value,b=!1,w=Jnt(r,_)||(l==null||(T=l.meta)===null||T===void 0?void 0:T.value);switch(v){case"EQUALS":b=w===x;break;case"NOT_EQUALS":b=w!==x;break;case"GREATER_THAN":b=w>x;break;case"LESS_THAN":b=w<x;break;case"GREATER_THAN_OR_EQUALS":b=w>=x;break;case"LESS_THAN_OR_EQUALS":b=w<=x;break;case"CONTAINS":b=Array.isArray(w)?w.includes(x):w?.toString().includes(x);break;case"NOT_CONTAINS":b=Array.isArray(w)?!w.includes(x):!(w!=null&&w.toString().includes(x));break;case"STARTS_WITH":b=w?.toString().startsWith(x);break;case"ENDS_WITH":b=w?.toString().endsWith(x);break;case"REGEX":b=new RegExp(x).test(w?.toString());break;case"NOT_REGEX":b=!new RegExp(x).test(w?.toString());break;case"EMPTY":b=!w;break;case"NOT_EMPTY":b=!!w;break}m=h==="AND"?m&&b:m||b}),l.hidden=!m}if(["array","object","section"].includes(l==null||(u=l.meta)===null||u===void 0?void 0:u.displayType)){var O;l!=null&&(O=l.meta)!==null&&O!==void 0&&O.children&&(l.meta.children=s(l?.meta.children||[]))}return l})},[r]);return C.useEffect(function(){o(s(t))},[t,r,s]),i},bot=function(t){var r=t.reduce(function(n,i){return n[i.key]=i.value,n},{});return r},xx=function(t,r){return t.forEach(function(n){var i,o;if(["object","array","section"].includes((i=n.meta)===null||i===void 0?void 0:i.displayType))if(["configure","setup"].includes(n?.name)){var s;xx((s=n.meta)===null||s===void 0?void 0:s.children,r)}else{var a=r[n.name];if(a){var l;xx((l=n.meta)===null||l===void 0?void 0:l.children,a)}}else((o=n.meta)===null||o===void 0?void 0:o.displayType)==="keyvalue"&&Array.isArray(r[n.name])&&(r[n.name]=bot(r[n.name]))}),r},Cot=C.forwardRef(function(e,t){var r=e.name,n=e.schema,i=n===void 0?[]:n,o=e.form,s=o===void 0?{}:o,a=e.suggestions,l=e.onChange,u=e.onSubmit,c=e.onFocus,f=e.onCustom,p=e.buttonSchema,h=e.loading,A=e.onCancel,g=e.sx,m=e.isLoading,O=m===void 0?!1:m,y=e.useDefaultButtons,T=y===void 0?!0:y,v=e.viewOnly,_=v===void 0?!1:v,x=e.MCP_INTEGRATION_FORM,b=x===void 0?!1:x,w=e.MCP_EXCLUDED_FIELDS,R=w===void 0?[]:w,I=ar({},s),P=ore(),k=P.transformFormData,N=C.useMemo(function(){var Y;return(Y=_E(i,I))!=null?Y:{}},[i,I]),L=qJe({values:N,mode:"all"}),M=Aee({control:L.control,defaultValue:N}),B=C.useState(i),H=B[0],j=B[1],X=C.useMemo(function(){return i},[i,r]),F=C.useMemo(function(){return M},[M,r]),V=JA(i),G=xot(X,F);C.useEffect(function(){j(G)},[G,r]);var D=C.useCallback(function(Y){c&&c(Y)},[c]),$=C.useCallback(function(){A&&A()},[A]),U=C.useCallback(function(Y){if(l){var J=L.getValues(),ee=L.getValues(Y.field),le=ar(ar({},Y),{},{value:ee});l(le,J)}},[l,L,M]),q=C.useCallback(function(Y){return Y===void 0&&(Y=""),function(J){var ee=xx(i,J);if(b&&(ee=k(i,ee)),u){var le=xx(i,J);u(le,Y)}}},[u,i,k,b]),z=C.useCallback(function(Y,J,ee){if(J===void 0&&(J={}),ee===void 0&&(ee=""),f){var le=L.getValues();f(Y,ar(ar({},le),J),ee)}},[f,M]),W=C.useCallback(function(){try{return Promise.resolve(L.trigger()).then(function(Y){return!!Y})}catch(Y){return Promise.reject(Y)}},[L,H]);C.useImperativeHandle(t,function(){return{handleSubmit:function(J){var ee;J===void 0&&(J=""),(ee=L.handleSubmit(q(J)))===null||ee===void 0||ee()},getValues:L.getValues,isValidated:function(){try{return Promise.resolve(W())}catch(Y){return Promise.reject(Y)}}}});var Q=C.useRef(!1);return C.useEffect(function(){if(!(Q.current||!l)){Q.current=!0;var Y=function(le){le===void 0&&(le=[]);var ne=[];return le.forEach(function(ue){var Oe,ve,oe=ue==null||(Oe=ue.meta)===null||Oe===void 0?void 0:Oe.children;oe&&Array.isArray(oe)?ne.push.apply(ne,Y(oe)):(ue==null||(ve=ue.meta)===null||ve===void 0?void 0:ve.displayType)==="hidden"&&ne.push(ue)}),ne},J=Y(i);J.forEach(function(ee){U({field:ee.name,fieldData:ee})})}},[i,l,U]),C.createElement(kJe,Object.assign({},L),C.createElement("form",{key:r,name:"ripple-form",className:"ripple-form",noValidate:!0,style:ar({display:"flex",flexDirection:"column",height:"100%"},g)},C.createElement(E.Stack,{gap:1,alignItems:"center",sx:{overflowY:"auto",flexGrow:1},className:"ripple-form-container",width:"100%"},H&&H.length>0&&H.map(function(Y,J){var ee,le;return C.createElement(E.Stack,{width:"100%",key:Y?.name+"::"+J+"::"+r,sx:{display:(Y==null||(ee=Y.meta)===null||ee===void 0?void 0:ee.displayType)==="hidden"||Y?.hidden===!0?"none":"flex"}},C.createElement(Qnt,{fieldName:Y?.name},C.createElement(e0,Object.assign({},Y,{isLoading:O,field:Y,hidden:Y?.hidden||!1,control:L.control,handleChange:U,onFocus:D,handleCustom:z,viewOnly:_,validationRules:["object","array","keyvalue"].includes(Y==null||(le=Y.meta)===null||le===void 0?void 0:le.displayType)?V:V[Y?.name],suggestions:a,MCP_INTEGRATION_FORM:b,MCP_EXCLUDED_FIELDS:R}))))}),C.createElement(E.Stack,{width:"100%",alignItems:"center"},O&&C.createElement(E.CircularProgress,null))),T&&C.createElement(znt,{buttonSchema:p,onSubmit:function(J){return L.handleSubmit(q(J))()},onReset:function(){return L.reset()},onCancel:$,loading:h||O,style:{flexShrink:0}})))}),bx=C.forwardRef(function(e,t){var r=C.useRef(null);return C.useImperativeHandle(t,function(){var n;return{handleSubmit:function(o){var s,a;o===void 0&&(o=""),r==null||(s=r.current)===null||s===void 0||(a=s.handleSubmit)===null||a===void 0||a.call(s,o)},isValidated:r==null||(n=r.current)===null||n===void 0?void 0:n.isValidated}}),C.createElement(vot,null,C.createElement(Cot,Object.assign({},e,{ref:r})))});const _ot=(e,t,r)=>{const n=[Kr.WORKFLOW_EXECUTION_COMPLETED,Kr.ACTIVITY_TASK_COMPLETED],i=[Kr.ACTIVITY_TASK_FAILED,Kr.ACTIVITY_TASK_TIMED_OUT,Kr.WORKFLOW_EXECUTION_FAILED,Kr.WORKFLOW_EXECUTION_TIMED_OUT,Kr.WORKFLOW_EXECUTION_TERMINATED,Kr.WORKFLOW_EXECUTION_CANCELED,Kr.WORKFLOW_TASK_TIMED_OUT];{if(n.includes(e))return r.palette.success.main;if(i.includes(e))return r.palette.error.main}},DE=e=>{const t=[Kr.WORKFLOW_EXECUTION_COMPLETED,Kr.WORKFLOW_EXECUTION_FAILED,Kr.WORKFLOW_EXECUTION_TIMED_OUT,Kr.WORKFLOW_EXECUTION_TERMINATED,Kr.WORKFLOW_EXECUTION_CANCELED,Kr.WORKFLOW_EXECUTION_TERMINATED,Kr.WORKFLOW_TASK_FAILED,Kr.WORKFLOW_TASK_TIMED_OUT];return e?e.some(r=>t.includes(r.eventType)):[]};function wot(e){const t=e.eventType.replace(/_/g," ").replace("EVENT TYPE","").replace(/\w\S*/g,r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).trim();if(e.eventType===Kr.ACTIVITY_TASK_SCHEDULED&&e.activityTaskScheduledEventAttributes){const r=e.activityTaskScheduledEventAttributes?.input?.payloads?.[0]?.data?.name;return r?`${t}: ${r}`:t}return t}function Iot(e){if(e==null||typeof e!="object"||Array.isArray(e))return e;const{isBranch:t,branchToExecute:r,...n}=e;return n}const Cx=e=>{if(!(typeof e=="string"||e instanceof String))return;const t=e.match(/\{\{([^{}]+)\}\}/);if(t)return t[1].trim()},Dot=(e,t)=>new Promise((r,n)=>{const i=t.split(".");let o=e;for(const[s,a]of i.entries())if(a.includes("[")){let l,u;if(!a.includes("]"))throw l=a.split("["),u=l[0],n(`Invalid Syntax while using ${u}`),new Error(`Invalid Syntax while using ${u}`);l=a.split("["),u=l[0];const c=parseInt(l[1].replace("]",""));if(!Array.isArray(o[u]))throw n(`${u} should be an array, found ${typeof o[u]}`),new Error(`${u} should be an array, found ${typeof o[u]}`);if(isNaN(c)||c<0)throw n(`Invalid array index for ${a}`),new Error(`Invalid array index for ${a}`);if(c>=o[u].length)throw n(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`),new Error(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`);o=o[u][c]}else if(a==="uuid4()")o=y5();else if(o=o[a],o&&s<i.length-1&&Array.isArray(o)){if(i.includes("length")&&i[i.length-1]==="length")continue;throw n(`Invalid Syntax, Use ${a}[${s}]`),new Error(`Invalid Syntax, Use ${a}[${s}]`)}r(o)}),Rot=async(e,t)=>{if(typeof e!="string")return e;const r=/{{([^{}]*)}}/g,n=[];let i;for(;(i=r.exec(e))!==null;)n.push(i);for(const o of n){const s=o[1],a=await Dot(t,s),l=a!==void 0?typeof a=="object"?JSON.stringify(a):a.toString():"";e=e.replace(o[0],l)}return e},B8=async(e,t)=>{const r=Array.isArray(e)?[]:{};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const i=e[n];typeof i=="object"&&i!==null?r[n]=await B8(i,t):typeof i=="string"?r[n]=await Rot(i,t):r[n]=i}return r},j8=[{name:"activity_name",meta:{displayName:"Custom Name",displayType:"hidden",placeholder:"Enter the custom name",validation:{required:!0},value:""}},{name:"integration_slug",meta:{displayName:"Integration Slug",displayType:"hidden",placeholder:"Enter the integration slug",validation:{required:!0},value:""}}],Pot=[{name:"advanced_options",meta:{displayName:"Advanced Options",displayType:"accordion",htmlProps:{headerVariant:"smSemiBold"},children:[{name:"continue_on_failure",meta:{displayName:"Continue on Failure",displayType:"toggle",description:"When enabled, a failure handle appears on this node. If this node fails, workflow continues through the failure path. If disabled and this node fails, the entire workflow stops.",value:!1,readOnly:!1}},{name:"retry_config",meta:{displayType:"object",children:[{name:"maximum_attempts",meta:{displayName:"Maximum Number of Attempts",displayType:"number",placeholder:"Enter the maximum number of tries",description:"The maximum number of times to try the activity, including the first attempt. If set to 3, the activity will run at most 3 times.",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:1,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"backoff_coefficient",meta:{displayName:"Retry Backoff Rate",displayType:"number",placeholder:"Enter the wait time between tries",description:"Constants factor by which the time delay between the retry attempts increase after the each failure",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:2,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"initial_interval",meta:{displayName:"Wait Time Before First Retry (seconds)",displayType:"number",placeholder:"Enter the initial wait time",description:"The time to wait before the first retry after a failure. For example, if set to 5 seconds, the first retry will occur 5 seconds after the failure.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e3,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_interval",meta:{displayName:"Maximum Wait Between Retries (seconds)",displayType:"number",placeholder:"Enter the maximum wait time",description:"The longest time to wait between retries, regardless of backoff. Prevents the delay from growing indefinitely.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e5,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_timeout",meta:{displayName:"Maximum Activity Completion Timeout in (m/s)",displayType:"number",placeholder:"Enter the maximum timeout",description:"Maximum time to wait for the Activity to complete",validation:{required:!0},value:6e4,htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"secret",operator:"NOT_EMPTY"},{field:"resource",operator:"NOT_EMPTY"},{field:"operation",operator:"NOT_EMPTY"}]}}}],_x=async(e,t)=>{const{url:r,method:n,body:i}=e,o=n,s=i&&await B8({body:i},{parameters:t}),a={};s&&(o==="post"||o==="put"||o==="patch")&&(a.data=s.body);const{data:l}=await Qt[o](r,a);return l},Not=async(e,t,r,n,i,o)=>{const{integration_id:s,resource:a,operation:l,integration_slug:u}=e,c=[];if(!s&&!u)throw new Error("integration_slug or integration_id is required in payload");const p=[r,"v1.0",n,"integrations",u||s],h=Xt(...p,"configuration"),{data:A}=await Qt.get(h),g=A.data.content.parameters;if(c.push(...g),a&&p.push("resource",a),!vt(a)){const m=Xt(...p),{data:O}=await Qt.get(m);if(!O.data.content.parameters)throw new Error("No integration schema data found");c.push(...O.data.content.parameters)}if(!vt(a)&&!vt(l)){l&&p.push("operation",l);const m=Xt(...p),{data:O}=await Qt.get(m),y=O?.data?.content;if(!y)throw new Error("No Operation schema found");if(y?.config){const{method:T,urlType:v,body:_,condition:x}=y.config;if(x){const b=Cx(x);if(b){const w=b.split(".")[1];if(t?.[w]){let{url:R}=y.config;R=Xt(r,"v1.0",n,R);const I={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},P=Object.assign({},{url:R,method:T,urlType:v,body:I}),k=await _x(P,t);c.push(...y.parameters,...k)}else c.push(...y.parameters)}}else{let{url:b}=y.config;b=Xt(r,"v1.0",n,b);const w={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},R=Object.assign({},{url:b,method:T,urlType:v,body:w}),I=await _x(R,t);c.push(...y.parameters,...I)}}else c.push(...y.parameters)}return i||o?c.push(...j8):c.push(...j8,...Pot),c},Lot=async(e,t,r,n)=>{const{integration_id:i,resource:o="webhook",operation:s,integration_slug:a}=e,l=[];let u;if(!i&&!a)throw new Error("integration_slug or integration_id is required in payload");const f=[r,"v1.0",n,"integrations",a||i];if(o&&o==="webhook"){f.push("webhook");const p=Xt(...f),{data:h}=await Qt.get(p);if(u=h.data.content,!u)throw new Error("No integration schema data found");l.push(...u.parameters)}if(!vt(o)&&!vt(s)){if(u?.config){const{method:h,urlType:A,body:g,condition:m}=u.config;if(m){const O=Cx(m);if(O){const y=O.split(".")[1];if(t?.[y]){let{url:T}=u.config;T=Xt(r,"v1.0",n,T);const v={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},_=Object.assign({},{url:T,method:h,urlType:A,body:v}),x=await _x(_,t);l.push(...u.parameters,...x)}else l.push(...u.parameters)}}else{let{url:O}=u.config;O=Xt(r,"v1.0",n,O);const y={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},T=Object.assign({},{url:O,method:h,urlType:A,body:y}),v=await _x(T,t);l.push(...u.parameters,...v)}}const p=u[s]?.parameters;l.push(...p)}return l.push(...j8),{data:l,polling_interval:u?.polling_interval}},wx=({formData:e,isLoop:t=!1,selectedNode:r,INTEGRATION_DATA:n,SET_INTEGRATION_DATA:i,onClose:o,openIntegrationDrawer:s,handleRunActivity:a,handleCompleteSetup:l,setPollingInterval:u,onSubmit:c,source:f="",MCP_INTEGRATION_FORM:p=!1})=>{const[h,A]=C.useState([]),[g,m]=C.useState({}),[O,y]=C.useState(!1),[T,v]=C.useState({headers:{},query:"",variables:{}}),_=C.useRef(!1),x=C.useRef(null),b=pt.useDispatch(),[w,R]=C.useState(!1),{WORKFLOW_URLS:I,ENTITY_ID:P=""}=Ii(),{VORTEX_MAIN_URL:k,TESSERACT_MAIN_URL:N,FRONTEND_URL:L}=I,M=r?.data?.type,B=r?.data?.properties?.activity_name,H=r?.data?.properties?.activity_id,j=r?.data?.properties?.integration_slug,X=ne=>{if(!ne)return{};if(typeof ne=="string")try{const ue=JSON.parse(ne);return typeof ue=="object"&&ue!==null?ue:{}}catch{return{}}return typeof ne=="object"?ne:{}},F=(ne,ue)=>{m(Oe=>{const ve={...Oe,[ne]:ue};return Oe?.properties&&typeof Oe.properties=="object"&&(ve.properties={...Oe.properties,[ne]:ue}),ve})},V=()=>{y(!1),v({headers:{},query:"",variables:{}})},G=ne=>{F("query",ne),v(ue=>({...ue,query:ne}))},D=ne=>{v(ve=>({...ve,variables:ne}));const Oe=typeof g?.variables=="string"&&typeof ne!="string"?JSON.stringify(ne,null,2):ne;F("variables",Oe),V()},$=()=>O?d.jsx(Io,{open:O,handleClose:V,title:"GraphQL Inspector",subtitle:"Explore the GraphQL schema and build queries by selecting fields",icon:d.jsx(Ue,{src:"ic_schema"}),sx:{".MuiDialogContent-root":{padding:"16px 24px !important"}},content:d.jsx(YJ,{form:g,headers:X4(T.headers||{}),currentQuery:T.query||"",onQueryUpdate:G,onVariablesUpdate:D})}):null,U=async ne=>{if(x.current!==ne){x.current=ne;try{const ue=Xt(N,`/v1/integrations/${ne}/validate-token`),Oe=await Qt.get(ue),{data:ve}=Oe.data;if(ve){const{is_revoked:oe}=ve;if(_.current!==oe&&(_.current=oe,h.length>0)){const ae=h.map(re=>re.name==="secret"?{...re,meta:{...re.meta,htmlProps:{...re.meta.htmlProps,showReconnect:oe}}}:re);A(ae)}}}catch(ue){sr(ue,b)}}},q=async()=>{if(g.secret)if(s)s({_id:g.secret},"edit");else{const ne=`${L}/accounts/${P}/integrations/destination/new-destination/${g.secret}/edit`;window.open(ne)}},z=async({resource:ne,operation:ue,currentFormData:Oe={},schema:ve=[]})=>{try{let oe=ve;if(M!==Ze.SERVERLESS){R(!0);const Z={...j&&{integration_slug:j},...H&&{integration_id:H},...ue&&{operation:ue},...ne&&{resource:ne}};let te={};if(vt(Oe)?te=vt(g)?e.properties:g:te=Oe,M===Ze.CLOUD_TRIGGER){const{data:se,polling_interval:he}=await Lot(Z,te,k,P);oe=se,u&&u?.(he)}else oe=await Not(Z,te,k,P,t,p)}let ae=oe;const re=async(Z,te=[])=>{if(f?.includes("commerce_")&&M===Ze.PLATFORM_FDK_ACTIVITY){const se=f?.split("_"),he=se&&se.length>1?se[1]:null,pe=se&&se.length>2?se.slice(2).join("_"):he;ae=ae?.map(de=>de.name==="secret"?(delete de.meta.config,{...de,meta:{...de.meta,options:[{value:f,label:pe}],value:f,isDisabled:!0,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}):de)}for(const se of Z){if((se?.meta?.displayType==="select"||se?.meta?.displayType==="autocomplete"||se?.meta?.displayType==="multiselect")&&se?.meta?.config?.url){const{method:he,labelKey:pe,valueKey:de,urlType:xe,body:ge,condition:Ee}=se.meta.config;let{url:ke}=se.meta.config;xe==="secret"?ke=Xt(N,"v1/integrations/entity",ke):xe==="options"&&(ke=Xt(k,"v1.0",P,ke));const We={...ge,...H&&{integration_id:H},...j&&{integration_slug:j}},$e=Object.assign({},{url:ke,method:he,labelKey:pe,valueKey:de,body:We});if(Ee){const et=Cx(Ee);if(et){const st=et.split(".")[1];(g[st]||e?.properties?.[st])&&(ae=await Q(se.name,$e,ae,[...te,se.name]))}}else ae=await Q(se.name,$e,ae,[...te,se.name])}se?.meta?.children&&se?.meta?.children?.length>0&&await re(se?.meta?.children,[...te,se.name])}};await re(ae),_.current&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&(ae=ae.map(Z=>(Z.name==="secret"&&(Z.meta.htmlProps={...Z.meta.htmlProps,showReconnect:_.current}),Z))),A(ae)}catch(oe){sr(oe,b)}finally{R(!1)}},W=async()=>{const ne=Xt(k,"v1.0",P,"integrations",j,"configuration"),ue={advanced_options:!0};Qt.get(ne,{params:ue}).then(async({data:Oe})=>{if(t){const ve=Oe.data.content.parameters.filter(oe=>!["advanced_options","maximum_attempts","backoff_coefficient","initial_interval","maximum_interval","maximum_timeout"].includes(oe.name));await z({schema:ve})}else await z({schema:Oe.data.content.parameters})})},Q=async(ne,ue,Oe,ve=[])=>{R(!0);try{const{url:oe,method:ae,labelKey:re,valueKey:Z,body:te}=ue,se=ae,he=te&&await B8({body:te},{parameters:vt(g)?e.properties:g}),pe={};he&&(se==="post"||se==="put"||se==="patch")&&(pe.data=he.body);const de=await Qt[se](oe,pe),ge=(ne==="secret"?de.data.data:de.data)?.map(ke=>({value:ke[Z],label:ke[re]}));let Ee=[];if(ve?.length===0)Ee=Oe?.map(ke=>ke.name===ne?{...ke,meta:{...ke.meta,options:ge}}:ke);else{Ee=Oe;const ke=(We,$e,et,st=0)=>{We.forEach(it=>{it.name===$e[st]&&(st===$e.length-1?it.meta={...it.meta,options:et}:it?.meta?.children&&it?.meta?.children?.length>0&&ke(it?.meta?.children,$e,et,st+1))})};ve?.length>0&&ke(Ee,ve,ge)}return Ee}catch(oe){return sr(oe,b),Oe}finally{R(!1)}};return C.useEffect(()=>{if(x.current=null,_.current=!1,M===Ze.SERVERLESS)W();else{async function ne(){r&&(A([]),await z({}))}ne()}},[r.id,B,H,j]),C.useEffect(()=>{async function ne(){if(n?._id&&n?.meta?.entity===B.toUpperCase()){n?.meta?.auth_status==="ACTIVE"&&(_.current=!1),M===Ze.SERVERLESS?await z({schema:h}):await z({});const ue={maximum_attempts:1,backoff_coefficient:2,initial_interval:1e3,maximum_interval:1e5},Oe={...g?.activity_id&&{activity_id:g.activity_id},...j&&{integration_slug:j},...g?.activity_name&&{activity_name:g.activity_name},...M!==Ze.CLOUD_TRIGGER?{maximum_timeout:6e4,retry_config:ue}:{}};m({...Oe,secret:n._id})}}ne()},[n]),C.useEffect(()=>{const ne=async()=>{const{secret:ue,resource:Oe,operation:ve}=e.properties;if(M===Ze.SERVERLESS)vt(ue)||await z({schema:h});else if(e?.properties||!vt(ue)){if(M===Ze.SERVERLESS&&!vt(ue))await z(h);else if(vt(Oe)||await z({resource:Oe}),!vt(ve)){const[oe,ae]=ve.split(".");await z({resource:oe,operation:ae})}}};vt(e.properties)||(m(e.properties),e.properties.secret&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&U(e.properties.secret),ne())},[e]),C.useEffect(()=>{if(p&&h.length>0){const ne=(ue,Oe="")=>{const ve={...g};ue.forEach(oe=>{const ae=oe.name,re=Oe?`${Oe}.${ae}`:ae;if(of.includes(ae)||of.some(te=>re.includes(te)))return;g[ae]||(oe.meta?.displayType==="array"?ve[ae]=["BOLTIC_AI"]:oe.meta?.displayType!=="object"&&(ve[ae]="BOLTIC_AI"));const Z=[];h.forEach(te=>{te.meta?.displayType!=="hidden"&&!of.includes(te.name)&&!of.some(se=>te.name.includes(se))&&Z.push({key:te.name,...te.meta?.displayType==="array"&&{name:te.meta?.name||te.name},description:te.meta?.description||"",type:te.meta?.displayType||"",value:ve[te.name]||null,required:te?.validation?.required||!1})}),ve.payload=Z,oe?.meta?.children&&oe?.meta?.children?.length>0&&ne(oe.meta.children,re)}),m(ve)};ne(h)}},[p,h]),{form:g,formSchema:h,loading:w,handleFocus:async ne=>{let ue=h;const{fieldData:Oe}=ne;if((Oe?.meta?.displayType==="select"||Oe?.meta?.displayType==="autocomplete"||Oe?.meta?.displayType==="multiselect")&&Oe?.meta?.config?.url){const{method:ve,labelKey:oe,valueKey:ae,urlType:re,body:Z,condition:te}=Oe.meta.config;let{url:se}=Oe.meta.config;re==="secret"?se=Xt(N,"v1/integrations/entity",se):re==="options"&&(se=Xt(k,"v1.0",P,se));const he={...Z,...H&&{integration_id:H},...j&&{integration_slug:j}},pe=Object.assign({},{url:se,method:ve,labelKey:oe,valueKey:ae,body:he});if(R(!0),te){const de=Cx(te);if(de){const xe=de.split(".")[1];(g[xe]||e?.properties?.[xe])&&(ue=await Q(Oe.name,pe,ue))}}else ue=await Q(Oe.name,pe,ue);R(!1),_.current&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&(ue=ue.map(de=>de.name==="secret"?{...de,meta:{...de.meta,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}:de))}A(ue)},handleChange:async(ne,ue)=>{if(M===Ze.SERVERLESS){m(ue);return}const{field:Oe,value:ve,fieldData:oe={}}=ne,ae={...ue,[Oe]:ve};if(Oe==="secret")m(ae),ve&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&U(ve);else if(Oe==="resource")m(ae),await z({resource:ve});else if(Oe==="operation"){const[re,Z]=ve.split(".");m(ae),await z({resource:re,operation:Z})}else if(oe?.meta?.loadDynamicParameters){const[re,Z]=g.operation.split(".");m({...ue,[Oe]:ve}),await z({resource:re,operation:Z,currentFormData:{...ue,[Oe]:ve}})}else m(ue)},handleCustom:(ne,ue,Oe="")=>{if(Oe==="run_activity"){a?.(ue?.canvasNodeId);return}else if(Oe==="configure_activity"){l?.(ue?.canvasNodeId);return}if(m(ue),ne.type==="add-new"){R(!0);let ve=B;const oe=h.find(Z=>Z.name==="secret"&&Z.meta.config);if(oe){const{url:Z}=oe.meta.config;ve=Z.split("?")[0].replace("/","")}const ae={current_page:1,page_size:1,entity:ve.toUpperCase(),state:r.activity_data.status},re=Xt(N,"/v1/catalog");Qt.get(re,{params:ae}).then(Z=>{if(s){s(Z.data.data[0],"create");return}const te=`${L}/accounts/${P}/integrations/destination/new-destination/${Z.data.data[0]._id}/create?integration_id=${H}&integration_slug=${j}`;window.open(te)}).catch(Z=>{sr(Z,b)}).finally(()=>{R(!1)})}else if(ne.type==="complete-step")R(!0),b({type:f4,payload:[ne.data?.id]}),b({type:wb,payload:"focused"}),R(!1);else if(ne.type==="add-sample-data"){R(!0);const{data:ve}=ne;ve.name==="global_variables"?b({type:h4,payload:ve.data}):ve.name==="payload"?b({type:md,payload:{id:ve?.id,data:ve.data,loading:!1}}):b({type:md,payload:{id:ve.id,data:{result:ve.data,events:[]},loading:!1}}),R(!1)}else if(ne.type==="reconnect"&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY))q();else if(ne.type==="graphql-inspector"){const oe=!!ue?.properties&&typeof ue.properties=="object"&&!Array.isArray(ue.properties)?ue.properties:ue,ae=oe?.query,re=oe?.headers,Z=X(oe?.variables);v({headers:re||{},query:typeof ae=="string"?ae:ae?JSON.stringify(ae,null,2):"",variables:Z}),y(!0)}},setForm:m,handleCancel:()=>{o?.(),m({}),A([]),i(null)},setFormSchema:A,GraphQLInspectorModal:$}},Ix=e=>{if(!e||e.length===0)return!1;const t=e.some(n=>["secret","resource","operation"].includes(n.name)),r=e.some(n=>!["secret","resource","operation"].includes(n.name));return t&&r},Dx=(e,t)=>{const r=t?.secret&&!vt(t.secret),n=e.filter(u=>u.name==="operation"?r||!r&&t?.resource:["secret","resource"].includes(u.name)),i=e.filter(u=>!["secret","resource","operation"].includes(u.name)),o=[{name:"setup",meta:{className:"setup-section",displayType:"section",displayName:"Setup",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:n}}],s=i.length>0,a=t?.resource&&!vt(t.resource),l=t?.operation&&!vt(t.operation);return s&&a&&l&&(o.push({meta:{displayType:"divider",htmlProps:{my:"1rem"}}}),o.push({name:"configure",meta:{className:"configure-section",displayType:"section",displayName:"Configure",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:i}})),o},kot=C.forwardRef((e,t)=>{const{formData:r,selectedNode:n,type:i,activity_id:o,initialState:s,isLoop:a=!1,cloudRef:l,suggestionsData:u,SET_INTEGRATION_DATA:c,INTEGRATION_DATA:f,openIntegrationDrawer:p,isLoading:h=!1,onSubmit:A,onClose:g}=e,{loopSuggestionsData:m={}}=pt.useSelector(M=>M.loopActivity),{viewOnly:O}=pt.useSelector(M=>M.canvas),{form:y,formSchema:T,loading:v,handleFocus:_,handleChange:x,handleCustom:b,setForm:w,handleCancel:R,setFormSchema:I,GraphQLInspectorModal:P}=wx({formData:r,selectedNode:n,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:c,onClose:g,openIntegrationDrawer:p,onSubmit:A});C.useImperativeHandle(t,()=>({getData:()=>y,validateForm:()=>!0,resetFormData:()=>{w({}),I([])}}),[y]);const k=(M,B="")=>{if(!a){const H={type:i,name:n.data.name,activity_id:o,properties:{...s.properties,...M}};e.onSubmit?.(H,B)}},L=Ix(T)?Dx(T,y):T;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:l,name:`${n.data.name}-integration-form`,schema:L,form:y,onChange:x,onSubmit:k,isLoading:v||h,onFocus:_,onCustom:b,onCancel:R,useDefaultButtons:!1,suggestions:a?m:u,viewOnly:O}),d.jsx(P,{})]})}),sre=Xi(kot),Fot=({url:e})=>{const t=E.useTheme(),r=pt.useDispatch(),[n,i]=C.useState(!1);C.useEffect(()=>{n&&setTimeout(()=>{i(!1)},2e3)},[n]);const o=()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),r({type:Xr,payload:{open:!0,title:"Copied to clipboard",type:"success"}})}).catch(()=>{r({type:Xr,payload:{open:!0,title:"Failed to copy",type:"error"}})})};return d.jsx(E.Grid,{item:!0,xs:12,children:d.jsxs(E.Stack,{direction:"row",alignItems:"center",spacing:2,sx:{border:s=>`1px solid ${s.palette.grey[200]}`,borderRadius:1,p:2,background:t.palette.neutral.soft.bg,position:"relative",userSelect:"none"},children:[d.jsx(E.Typography,{sx:{color:t.palette.primary.main,px:1,py:.5,borderRadius:"4px",border:"1px solid"},children:"POST"}),d.jsx(E.Tooltip,{title:e,arrow:!0,children:d.jsx(E.Typography,{sx:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-all",maxWidth:"80%"},children:e})}),d.jsx(E.Tooltip,{title:"Copy to clipboard",placement:"top",arrow:!0,children:d.jsx(E.IconButton,{"data-testid":"button-copy-webhook-url",onClick:o,sx:{position:"absolute",right:"6px",top:"6px"},children:d.jsx(Ue,{src:"ic_copy",width:15,height:15,sx:{path:{fill:t.palette.common.black}}})})})]})})},Mot=C.forwardRef((e,t)=>{const r=pt.useDispatch(),n=E.useTheme(),{type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,VORTEX_MAIN_URL:a,FRONTEND_URL:l,WORKFLOW_URLS:u,INTEGRATION_DATA:c,viewOnly:f=!1,openIntegrationDrawer:p}=e,[h,A]=C.useState([]),[g,m]=C.useState(!1),[O,y]=C.useState([]),[T,v]=C.useState([]),[_,x]=C.useState(!1),[b,w]=C.useState(!1),[R,I]=C.useState(!1),{control:P,watch:k,setValue:N,trigger:L}=Rr(),M=k("properties.slack_auth_id"),B=k("properties"),[H,j]=C.useState(!1),[X,F]=C.useState(""),V=()=>{m(!0);const J={page_size:999,current_page:1,type:"BOTH"},ee=Xt(o,"/v1/integrations/entity/SLACK_V2");Qt.get(ee,{params:J}).then(({data:le})=>{const ne=io(le.data,["integration_meta"]);A(ne)}).catch(le=>{sr(le,r)}).finally(()=>{m(!1)})},G=Xt(a,`/v1.0/${s}`,"/implementations/choices"),D=async({slackAuthId:J,inputFieldId:ee,fieldsToFill:le,type:ne,refresh:ue=!1})=>{const Oe=`${G}${ue?"?refresh=true":""}`;return Qt.post(Oe,{data:{secret:J,input_field_id:ee,selected_api:"slackAPI",fields_to_fill:le,operation:"get",...ne&&{type:ne}}})},$=async(J,ee=!1)=>{I(!ee),ee&&j(!0);const{event:le}=B;let ne;["public_channel_message","public_channel_message_mention"].includes(le)?ne="public_channel":["private_channel_message","private_channel_message_mention"].includes(le)&&(ne="private_channel");try{const ue=await D({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Nf,type:ne,refresh:ee});y(ue.data)}catch(ue){y([]),sr(ue,r)}finally{I(!1),j(!1)}},U=async(J,ee=!1)=>{I(!ee),ee&&j(!0);try{const[le,ne]=await Promise.all([D({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Nf,type:"public_channel",refresh:ee}),D({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Nf,type:"private_channel",refresh:ee})]);y([...le.data,...ne.data])}catch(le){y([]),sr(le,r)}finally{I(!1),j(!1)}},q=async(J,ee=!1)=>{x(!ee),ee&&w(!0);try{const le=await D({slackAuthId:J,inputFieldId:"user",fieldsToFill:ck,refresh:ee});v(le.data)}catch(le){sr(le,r)}finally{x(!1),w(!1)}},z=async J=>{const{slack_auth_id:ee,event:le}=B;if(!ee||!le)return;const ne=["public_channel_message","private_channel_message"].includes(le),ue=["public_channel_message_mention","private_channel_message_mention"].includes(le);J==="channel"?ne||ue?await $(ee,!0):le==="app_mention"&&await U(ee,!0):J==="user"&&ue&&await q(ee,!0)};C.useEffect(()=>{(M===""||M===null||M===void 0)&&(N("properties.event",""),N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),y([]),v([]))},[M,N]),C.useEffect(()=>{B.event&&B.event!==null&&!vt(B)&&(N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),v([]),y([]))},[B.event,N]),C.useEffect(()=>{const{slack_auth_id:J,event:ee}=B;!vt(J)&&!vt(ee)&&(["public_channel_message","private_channel_message"].includes(ee)?$(J):ee==="app_mention"?U(J):["public_channel_message_mention","private_channel_message_mention"].includes(ee)&&($(J),q(J)))},[B.slack_auth_id,B.event]),C.useEffect(()=>{B.listen_workspace&&N("properties.channel","")},[B.listen_workspace,N]),C.useEffect(()=>{V()},[]),C.useEffect(()=>{try{const ee=window.location.pathname.split("/"),le=ee.findIndex(ue=>ue==="version");let ne="";if(le>-1&&le<ee.length-1)ne=ee[le+1];else{const ue=["draft","published","scheduled"],Oe=ee.findIndex(ve=>ue.includes(ve));ne=Oe>-1?ee[Oe+1]:""}u?.VORTEX_WEBHOOK_URL&&s&&ne&&F(Xt(u.VORTEX_WEBHOOK_URL,`/v1.0/${s}`,"workflows/execute/",ne))}catch{}},[u,s]),C.useEffect(()=>{c?._id&&c?.meta?.entity==="SLACK_V2"&&(V(),N("properties.slack_auth_id",c._id,{shouldValidate:!0}))},[c]);const W=h.find(J=>J.id===B.slack_auth_id),Q=W?.integration_meta?.type==="oauth2",Y=W?.integration_meta?.bot_name;return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.slack_auth_id",control:P,meta:{options:Tn(h),displayProps:{loading:g},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:l,ENTITY_ID:s,openIntegrationDrawer:p,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack Account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${u.GYRATE_MAIN_URL}/integrations/Triggers/slack" target="_blank" rel="noopener noreferrer" style="color: ${n.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},viewOnly:f,id:i,handleChange:()=>{}})})})}),B.slack_auth_id&&d.jsx(E.Divider,{}),B.slack_auth_id&&d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(B.slack_auth_id)&&h.length>0&&(!(h.find(le=>le.id===B.slack_auth_id)?.integration_meta?.type==="oauth2")&&X?d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{container:!0,gap:1,children:d.jsx(Fot,{url:X})}),d.jsx(Ul,{message:'Copy the webhook URL above and paste it into the "Request URL" field on the Event Subscriptions page in your Slack app settings. This enables Slack to send events to your workflow.'})]}):null),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{name:"properties.event",control:P,meta:{options:Hue,displayName:"Operation",searchFieldPlaceholder:"Search operation",description:"This is what starts the Workflow",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},required:!0,viewOnly:f,handleChange:()=>{}})}),B.event==="app_mention"&&!Q&&Y&&d.jsx(Ul,{variant:"info",message:`To trigger workflows, mention your bot using @${Y} in any Slack channel where the bot is invited.`}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(gn,{label:"Watch Whole Workspace",description:co("If enabled, triggers across the entire workspace; channel selection is not required."),sx:{fontSize:14,fontWeight:400,color:n.palette.text.primary}}),d.jsx(hr,{name:"properties.listen_workspace",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(d.Fragment,{children:[!B?.listen_workspace&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!B?.listen_workspace,name:"properties.channel",control:P,meta:{options:Tn(O),displayName:"Select Channel",displayProps:{loading:R,refreshing:H},value:"",searchFieldPlaceholder:"Search",description:"Only channels your bot is a member of will appear in this list.",placeholder:"Select Channel"},validationRules:{...B?.listen_workspace?{}:{required:"Channel is required"}},viewOnly:f,id:"channel",refreshOptions:()=>z("channel"),refreshTooltip:"Refresh Channels"})}),["public_channel_message_mention","private_channel_message_mention"].includes(B.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{name:"properties.username",control:P,meta:{options:Tn((T||[]).map(J=>{let ee="";return J.real_name&&J.name?ee=`${J.real_name} (${J.name})`:ee=J.real_name||J.name||"",{id:J.id,name:ee}})),displayProps:{loading:_,refreshing:b},displayName:"Select User",value:"",searchFieldPlaceholder:"Search User",placeholder:"Select User",description:"Triggers the workflow when this user is mentioned. Specify either a Username, a Highlight Word, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.word");return!J&&(!ee||ee.trim()==="")?"Either User selection or Highlight Word is required":!0}},viewOnly:f,id:"user",virtualized:!0,refreshOptions:()=>z("user"),refreshTooltip:"Refresh Users",handleChange:()=>{L("properties.word")}})}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Mr,{name:"properties.word",control:P,viewOnly:f,meta:{displayName:"Highlight Word",placeholder:"Enter text...",description:"Triggers the workflow when this word is mentioned (case-insensitive). Specify either a Highlight Word, a Username, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.username"),le=J;return(!le||le.trim()==="")&&!ee?"Either Highlight Word or User selection is required":!0}},handleChange:()=>{L("properties.username")}})})]}),d.jsx(Ul,{message:`Invite ${Q?"the Boltic app":"your bot"} to your Slack channel to receive events. In the channel, type: /invite @${Q?"Boltic":Y||"your-app-name"}`}),B?.event!=="app_mention"&&d.jsxs(d.Fragment,{children:[d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(gn,{label:"Listen for Bot Messages",description:co("If no, only messages sent by users will trigger the Workflow. If yes, messages sent by users and slackbots will trigger the Workflow."),sx:{fontSize:14,fontWeight:400,color:n.palette.text.primary}}),d.jsx(hr,{name:"properties.listen_for_bot_message",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),B?.listen_for_bot_message&&d.jsx(Ul,{textColor:n.palette.text.tertiary,variant:"warning",message:"Avoid infinite loops! If your workflow posts messages to the same channel that triggers it, and 'Listen for Bot Messages' is enabled, it will create an endless loop. Consider disabling bot message listening or posting to a different channel."})]})]})]})})]})}),are=({field:e,items:t,type:r,nodeId:n,viewOnly:i=!1,eventType:o,handleArrayItemDelete:s,validationRules:a={},isLoop:l})=>{const u=E.useTheme(),{control:c,formState:{errors:f}}=Rr(),p=C.useMemo(()=>t?.map((h,A)=>`${n}-${e}-${Date.now()}-${A}`),[n,e,t?.length]);return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{py:1},alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:11,children:d.jsx(hr,{name:`properties.${o}.${e}.${A}`,control:c,rules:a,render:({field:g})=>d.jsx(fo,{...g,id:n,fullWidth:!0,required:e==="emails",name:"email",viewOnly:i,label:"Email",isLoop:l,errorMsg:f.properties?.[o]?.[e]?.[A]?.message,showSuggestions:!0,helperText:In(r,e),editorId:`${r}-${e}-${A}`,__withFieldValueControlApplied:!0})})}),d.jsx(E.Grid,{item:!0,xs:1,sx:{display:"flex",justifyContent:"center",alignSelf:"flex-end",paddingBottom:"2px"},children:e==="emails"&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-email-button",sx:{p:.75,width:28,height:28,"& path":{fill:u.palette.neutral.solid.bg},"&:hover path":{fill:u.palette.error[60]},"&:hover":{backgroundColor:"transparent"}},disabled:i,onClick:()=>s(e,A),children:d.jsx(Ue,{src:"ic_delete",width:20,height:20})})})]},p[A]))})},Bot=e=>{const{field:t,eventType:r,viewOnly:n=!1}=e,i=`properties.${r}.${t}`,{watch:o,setValue:s,unregister:a}=Rr(),{setFieldControlState:l}=aa(),u=o(i),[c,f]=C.useState("BOLTIC_AI"),p=C.useRef([]);C.useEffect(()=>{u==="BOLTIC_AI"||u==="BOLTIC_AI_IGNORE"?f(u):Array.isArray(u)&&f("specific")},[u]);const h=A=>{const g=A.target.value;if(f(g),l(i,g),g==="specific"){const m=Array.isArray(u)&&u.length>0?u:p.current.length>0?p.current:[""];s(i,m)}else Array.isArray(u)&&(p.current=u,u.forEach((m,O)=>{a?.(`${i}.${O}`)}),a?.(i)),s(i,g)};return d.jsxs(E.Stack,{spacing:1.5,children:[d.jsx(E.FormControl,{fullWidth:!0,disabled:n,children:d.jsxs(E.Select,{value:c,onChange:h,children:[d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI",children:"Have AI generate a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE",children:"Do not include a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"specific",children:"Set a specific value for this field"})]})}),c==="specific"&&d.jsx(are,{...e})]})},jot=e=>{const{MCP_INTEGRATION_FORM:t}=aa();return t?d.jsx(Bot,{...e}):d.jsx(are,{...e})},lre=C.forwardRef(({property:e,viewOnly:t=!1,value:r,onChange:n},i)=>{const o=E.useTheme(),s=a=>{switch(a){case"add_workflow_link":return"Include Boltic Link at the end of the message";case"pause_workflow":return"Pause the Workflow, once this activity has completed its execution";default:return""}};return d.jsx(E.Grid,{item:!0,xs:12,ref:i,children:d.jsx(E.FormControlLabel,{label:s(e),sx:{display:"block",mr:0,"& .MuiFormControlLabel-label":{fontSize:a=>a.typography.xsNormal.fontSize,color:a=>a.typography.allVariants.color}},control:d.jsx(E.Checkbox,{sx:{p:0,"& .MuiSvgIcon-root":{fontSize:16}},icon:d.jsx(Ue,{src:"ic_unchecked",width:16,height:16,sx:{path:{fill:o.palette.common.white}}}),checkedIcon:d.jsx(Ue,{src:"ic_checked",width:16,height:16}),disabled:t,checked:r,onChange:n})})})}),$ot=Xi(({label:e,type:t,eventKey:r,required:n=!1,showExpandOption:i=!0,errorMsg:o="",suggestionsData:s,isLoop:a,viewOnly:l=!1,value:u,onChange:c})=>{const{loopSuggestionsData:f={}}=pt.useSelector(p=>p.loopActivity);return d.jsxs(E.Box,{children:[d.jsxs(E.Grid,{sx:{...mi},children:[d.jsx(gn,{required:n,label:e,description:co(In(t,"body"))}),d.jsx(E.Typography,{variant:"xsBold",children:d.jsx(E.Link,{href:"https://api.slack.com/block-kit",target:"_blank",rel:"noopener noreferrer",underline:"none",color:p=>p.palette.primary.main,children:"How to use Slack Block Builder?"})})]}),d.jsx($i,{size:"md",language:"json",showSuggestions:!0,viewOnly:l,value:u,handleChange:p=>c(p),id:`${t}-${r}-body`,suggestionsData:a?f:s,showExpandOption:i}),!!o&&d.jsx(E.FormHelperText,{error:!0,children:o})]})},""),Uot=C.forwardRef((e,t)=>{const r=pt.useDispatch(),n=E.useTheme(),{control:i,setValue:o,watch:s,clearErrors:a,formState:{errors:l}}=Rr(),u=s("properties");hA(s,o);const{VORTEX_MAIN_URL:c,ENTITY_ID:f,TESSERACT_MAIN_URL:p,FRONTEND_URL:h,WORKFLOW_URLS:A,type:g,id:m,isLoop:O=!1,INTEGRATION_DATA:y,viewOnly:T=!1,openIntegrationDrawer:v}=e,[_,x]=C.useState([]),[b,w]=C.useState(!1),[R,I]=C.useState(!1),[P,k]=C.useState(!1),[N,L]=C.useState([]),[M,B]=C.useState([]),[H,j]=C.useState("Query Params"),[X,F]=C.useState(!1),[V,G]=C.useState(!1),[D,$]=C.useState(!1),U=D?Bb:Bb.filter(oe=>oe.value),q=async()=>{w(!0);const oe={page_size:999,current_page:1,type:"BOTH"},ae=Xt(p,"/v1/integrations/entity/SLACK_V2");Qt.get(ae,{params:oe}).then(({data:re})=>{const Z=io(re.data,["integration_meta"]);x(Z)}).catch(re=>{sr(re,r)}).finally(()=>{w(!1)})},z=async(oe,ae,re=!1)=>{I(!0);let Z=Xt(c,`/v1.0/${f}`,"/implementations/choices");re&&(Z+="?refresh=true");try{const te=await Qt.post(Z,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Nf,operation:"get",type:ae===Yo.SEND_PUBLIC_CHANNEL_MESSAGE?"public_channel":"private_channel"}});L(Tn(te.data))}catch(te){L([]),sr(te,r)}finally{I(!1)}},W=async(oe,ae=!1)=>{I(!0);let re=Xt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(re+="?refresh=true");try{const[Z,te]=await Promise.all([Qt.post(re,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Nf,operation:"get",type:"public_channel"}}),Qt.post(re,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Nf,operation:"get",type:"private_channel"}})]),se=[...Z.data,...te.data];L(Tn(se))}catch(Z){sr(Z,r)}finally{I(!1)}},Q=async(oe,ae=!1)=>{k(!0);let re=Xt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(re+="?refresh=true");try{const Z=await Qt.post(re,{data:{secret:oe,input_field_id:"user",selected_api:"slackAPI",fields_to_fill:ck,operation:"get"}});B(Z.data.map(te=>({title:te.real_name?`${te.real_name} (${te.name})`:te.name,value:te.id})))}catch(Z){sr(Z,r)}finally{k(!1)}},Y=(oe,ae)=>{const re=u[u.event][oe].filter((Z,te)=>te!==ae);o("properties",{...u,[u.event]:{...u[u.event],[oe]:re}})},J=(oe,ae)=>{o("properties",{...u,[u.event]:{...u[u.event],[oe]:[...u[u.event][oe],ae]}})},ee=oe=>{o(`properties.${u.event}.${oe}`,null)},le=oe=>Ice[oe],ne=async(oe,ae,re="",Z=!1)=>{vt(oe)||vt(ae)||(re==="Channel"?F(!0):re==="Users"&&G(!0),!vt(oe)&&!vt(ae)&&[Yo.SEND_PUBLIC_CHANNEL_MESSAGE,Yo.SEND_PRIVATE_CHANNEL_MESSAGE].includes(ae)?await z(oe,ae,Z):ae===Yo.SEND_USER_MESSAGE?await Q(oe,Z):ae===Yo.SET_CHANNEL_TOPIC?await W(oe,Z):ae===Yo.INVITE_USERS&&(re==="Channel"?await W(oe,Z):re==="Users"?await Q(oe,Z):(!re||re==="")&&await Promise.all([Q(oe,Z),W(oe,Z)])),re==="Channel"?F(!1):re==="Users"&&G(!1))},ue=oe=>{const{slack_auth_id:ae,event:re}=u;ne(ae,re,oe,!0)};C.useEffect(()=>{vt(u)||(u.event===Yo.SEND_PRIVATE_CHANNEL_MESSAGE&&u?.send_private_channel_message?.attachment&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[u.send_private_channel_message.attachment]),u.event===Yo.SEND_PRIVATE_CHANNEL_MESSAGE&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[]),u.event===Yo.SEND_PUBLIC_CHANNEL_MESSAGE&&u?.send_public_channel_message?.attachment&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[u.send_public_channel_message.attachment]),u.event===Yo.SEND_PUBLIC_CHANNEL_MESSAGE&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[]),q())},[]),C.useEffect(()=>{y?._id&&y?.meta?.entity==="SLACK_V2"&&(q(),o("properties.slack_auth_id",y._id,{shouldValidate:!0}))},[y]),C.useEffect(()=>{if(_.length>0&&u?.slack_auth_id){const oe=_.find(ae=>ae.id===u.slack_auth_id);$(oe?.integration_meta?.type==="oauth2")}else $(!1)},[_,u?.slack_auth_id]),C.useEffect(()=>{const{slack_auth_id:oe,event:ae}=u;ne(oe,ae)},[u.event,u.slack_auth_id]);const Oe=u[u.event]?.attachments==="BOLTIC_AI_IGNORE"||u[u.event]?.attachments==="BOLTIC_AI",ve=u[u.event]?.emails==="BOLTIC_AI_IGNORE"||u[u.event]?.emails==="BOLTIC_AI";return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.slack_auth_id",control:i,meta:{options:Tn(_),displayProps:{loading:b},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:p,FRONTEND_URL:h,ENTITY_ID:f,openIntegrationDrawer:v,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${A?.GYRATE_MAIN_URL}/integrations/Communication/slack" target="_blank" rel="noopener noreferrer" style="color: ${n.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},handleChange:({field:oe,value:ae})=>{vt(ae)&&(L([]),B([])),vt(ae)?o("properties.event",""):o(oe,ae)},viewOnly:T,id:"slack_auth_id"})}),u.slack_auth_id&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.event",control:i,meta:{options:Vue,displayProps:{loading:b},displayName:"Operation",description:"This is performed when the Workflow runs.",searchFieldPlaceholder:"Search operation",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},handleChange:({value:oe})=>{o("properties",{...u,[oe]:le(oe),event:oe}),L([]),B([])},viewOnly:T})})]})}),u.slack_auth_id&&u.event&&d.jsx(E.Divider,{}),u.slack_auth_id&&u.event&&d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(u.slack_auth_id)&&d.jsxs(d.Fragment,{children:[u.event===Yo.CUSTOM&&d.jsx(d.Fragment,{children:d.jsx(Tl,{id:m,type:g,isLoop:O,viewOnly:T,customSelectedTab:H,setCustomSelectedTab:j})}),_ce.includes(u.event)&&d.jsx(Mr,{required:!0,id:m,name:`properties.${u.event}.channel_name`,control:i,meta:{displayName:"Channel Name",description:"Name for the channel to be created. Channel names are normalized by converting to lowercase, replacing any non-allowed characters with hyphens or underscore, and truncating to 80 characters.",placeholder:"Enter channel name"},validationRules:{required:"Chanel name is required"},viewOnly:T,editorId:`${g}-slack-channel_name`,showSuggestions:!0,isLoop:O},u.event),bce.includes(u.event)&&d.jsx(lf,{required:!0,name:`properties.${u.event}.channel_id`,id:m,control:i,isLoading:R,type:g,label:"Channel",viewOnly:T,isLoop:O,virtualized:!0,helperTextForDropdown:D?"channel_id":"channel_id_for_bot",helperTextForTextField:"dynamic_channel_id",isMultiple:!1,data:N,value:u[u.event]?.channel_id,onTabChange:()=>{ee("channel_id")},eventName:u.event,fieldName:"channel_id",refreshData:ue,refreshing:X,willRefresh:!0,refreshTooltip:"Refresh Channels"},u.event),u.event===Yo.SEND_PRIVATE_CHANNEL_MESSAGE&&d.jsx(Ul,{message:`To send a message to a private channel, please invite ${D?"the Boltic app":"your bot"} to the channel.`}),[Yo.SET_CHANNEL_TOPIC].includes(u.event)&&d.jsx(Mr,{required:!0,id:m,name:`properties.${u.event}.topic`,control:i,meta:{displayName:"Topic",description:"Topic to be set for the Slack channel",placeholder:"Enter topic"},validationRules:{required:"Topic is required"},viewOnly:T,editorId:`${g}-slack-topic`,showSuggestions:!0,isLoop:O}),wce.includes(u.event)&&d.jsx(lf,{name:`properties.${u.event}.user_id`,control:i,required:!0,isMultiple:!0,viewOnly:T,isLoading:P,id:m,type:g,isLoop:O,label:"Users",helperTextForTextField:"user_id",virtualized:!0,helperTextForDropdown:u.event===Yo.SEND_USER_MESSAGE?"user_ids_message":"user_ids_invite",data:M,value:u[u.event]?.user_id,onTabChange:()=>{ee("user_id")},eventName:u.event,fieldName:"user_id",refreshData:ue,refreshing:V,willRefresh:!0,refreshTooltip:"Refresh Users",handleChange:oe=>{const{field:ae,value:re}=oe;o(ae,re,{shouldValidate:!0})}}),Cce.includes(u.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:`properties.${u.event}.body_type`,control:i,validationRules:{required:"Message Body type is required"},meta:{options:Due,displayName:"Message Body Type",description:In(g,"body_type"),searchFieldPlaceholder:"Search",placeholder:"Select Message Body Type"},viewOnly:T,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae===y0.BLOCKS?ik:"",blocks:ae===y0.BLOCKS?[]:u[u.event].blocks}),a(`properties.${u.event}.body`)}})}),d.jsxs(E.Grid,{item:!0,xs:12,children:[u[u.event]?.body_type==="text"&&d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Mr,{required:!0,id:m,multiline:!0,name:`properties.${u.event}.body`,control:i,meta:{displayName:"Message Body",description:"Specify text / Define Slack Blocks of the message to send",placeholder:"Type or add suggestion"},validationRules:{required:"Message Body is required"},viewOnly:T,editorId:`${g}-slack-body`,showSuggestions:!0,isLoop:O,size:"md"})}),d.jsx(E.Grid,{item:!0,xs:12,children:u.event!==Yo.SEND_USER_MESSAGE&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Stack,{width:"100%",direction:"row",alignItems:"center",justifyContent:"space-between",sx:{"& > .MuiStack-root > .MuiStack-root":{pb:0}},children:[d.jsx(gn,{label:"Attachments",description:"The total attachments size limit is 1GB. The maximum number of attachments is 5."}),!Oe&&d.jsx(E.IconButton,{disabled:u[u.event].attachments?.length>=5,onClick:()=>J("attachments",""),sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:n.palette.primary.main}}})})]}),d.jsx(nN,{nodeId:m,type:g,isLoop:O,field:`properties.${u.event}.attachments`})]},u.event)})]}),u[u.event]?.body_type===y0.BLOCKS&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,sx:{marginBottom:"0.5rem"},children:d.jsx(qt,{required:!0,name:`properties.${u.event}.block_type`,control:i,meta:{options:Dce,displayName:"Slack Block Type",searchFieldPlaceholder:"Search Block Type",placeholder:"Select Block Type",description:In(g,"block_type")},disabled:T,validationRules:{required:"Slack Block Type is required"},handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae==="message"?ik:Tce,blocks:[]})},viewOnly:T,id:g})}),d.jsx(hr,{name:`properties.${u.event}.body`,control:i,render:({field:oe})=>d.jsx($ot,{...oe,id:m,label:"Slack Blocks",viewOnly:T,type:g,isLoop:O,eventKey:u.event,required:!0,showExpandOption:!0,errorMsg:l.properties?.[u.event]?.body?.message})})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:`properties.${u.event}.send_as_bot`,control:i,meta:{options:U,displayName:"Send as Bot",description:In(g,"send_as_bot"),placeholder:"Select Send as Bot",showSearch:!1},viewOnly:T,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],send_as_bot:ae,bot_name:"",bot_icon:""})}})}),u?.[u.event]?.send_as_bot&&d.jsxs(d.Fragment,{children:[d.jsx(Mr,{id:m,name:`properties.${u.event}.bot_name`,control:i,meta:{displayName:"Bot Name",description:"Specify the bot name which appears as a bold username above the message inside Slack. Defaults to Boltic.",placeholder:"Enter bot name"},viewOnly:T,editorId:`${g}-slack-bot_name`,showSuggestions:!0,isLoop:O}),d.jsx(Mr,{id:m,name:`properties.${u.event}.bot_icon`,control:i,meta:{displayName:"Bot Icon",description:"Either an image url or an emoji available to your team (surrounded by :). For example, https://site.com/icon_256.png or :robot_face:",placeholder:"Enter bot icon"},viewOnly:T,editorId:`${g}-slack-bot_icon`,showSuggestions:!0,isLoop:O})]}),d.jsx(Mr,{id:m,name:`properties.${u.event}.thread_ts`,control:i,meta:{displayName:"Thread Id",description:"If you want this to be part of a thread, you'll need the timestamp (Ts) of the parent message. For example: 1345232312616.1231232",placeholder:"Enter thread id"},viewOnly:T,editorId:`${g}-slack-thread_ts`,showSuggestions:!0,isLoop:O}),u[u.event]?.thread_ts&&u[u.event]?.thread_ts!==""&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:`properties.${u.event}.send_with_thread`,control:i,meta:{options:Bb,displayName:"Send Channel Message?",description:In(g,"send_with_thread"),placeholder:"Select Send Channel Message",showSearch:!1},viewOnly:T,id:g})}),d.jsx(hr,{name:`properties.${u.event}.add_workflow_link`,control:i,render:({field:oe})=>d.jsx(lre,{...oe,viewOnly:T,property:"add_workflow_link",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.body_type===y0.BLOCKS&&u?.[u.event].body!==""&&["message",void 0].includes(u?.[u.event]?.block_type)&&d.jsxs(d.Fragment,{children:[d.jsx(hr,{name:`properties.${u.event}.pause_workflow`,control:i,render:({field:oe})=>d.jsx(lre,{...oe,viewOnly:T,property:"pause_workflow",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.pause_workflow&&d.jsx(Ul,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),u?.[u.event]?.pause_workflow&&d.jsx(Ul,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),[Yo.FIND_BY_EMAIL].includes(u.event)&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Box,{sx:{display:"flex",alignItems:"center"},children:[d.jsx(E.FormControl,{fullWidth:!0,children:d.jsx(gn,{label:"Add Emails below"})}),!ve&&d.jsx(E.IconButton,{onClick:()=>J("emails",""),disabled:T,sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:n.palette.primary.main}}})})]}),d.jsx(jot,{eventType:u.event,handleArrayItemDelete:Y,nodeId:m,type:g,viewOnly:T,field:"emails",items:u[u.event].emails,isLoop:O,validationRules:{required:"Email is required"}})]})]}),!O&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Ui,{viewOnly:T,type:g})})]})})]})}),Hot=C.forwardRef((e,t)=>{const{viewOnly:r=!1}=e,{control:n,formState:{errors:i}}=Rr();return d.jsx(En,{children:d.jsx(hr,{name:"properties.timeout",control:n,rules:{required:"Timeout is required",min:{value:1,message:"Timeout must be greater than or equal to 1"},max:{value:2160*60*60*1e3,message:"Timeout must be less than or equal to 90 days (7,776,000 seconds)"}},render:({field:o})=>d.jsx(fo,{...o,label:"Timeout(seconds)",viewOnly:r,fullWidth:!0,type:"number",id:"timeout",required:!0,errorMsg:i.properties?.timeout.message,value:o.value/1e3||"",onChange:s=>o.onChange(Number(s.target.value)*1e3),inputProps:{step:1,min:1,max:2160*60*60*1e3},helperText:"The time to wait before starting the next Activity Execution"})})})}),Vot=({field:e,items:t,type:r,nodeId:n,requiredValue:i,autoFocus:o,hideLabel:s,placeholder:a="",viewOnly:l=!1,name:u,handleArrayItemDelete:c})=>{const f=E.useTheme(),{control:p}=Rr();return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{mb:1},alignItems:"flex-start",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:2.4,children:d.jsx(qt,{required:!0,name:`${u}.${A}.caseType`,control:p,meta:{options:Yue,displayName:s?"":"Type",searchFieldPlaceholder:"Search type",description:In(r,"from_type"),placeholder:s?"":"Select Type"},validationRules:{required:"Type is required"},viewOnly:l,id:r})}),d.jsx(E.Grid,{item:!0,xs:8.2,children:d.jsx(Mr,{meta:{displayName:!s&&"Case",placeholder:`${a} ${A+1}`},name:`${u}.${A}.caseValue`,control:p,validationRules:{required:"Case value is required"},autoFocus:o,id:n,required:i,viewOnly:l,showSuggestions:!0,helperText:In(r,e),editorId:`${r}-${e}-${A}`})}),d.jsx(E.Grid,{item:!0,xs:1,children:i&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-switch-button",sx:{width:28,height:28,position:"relative",top:24,"&:hover":{backgroundColor:"transparent","& path":{fill:f.palette.error[60]}}},onClick:()=>{c(e,A)},disabled:l,children:d.jsx(Ue,{src:"ic_delete",sx:{"& path":{fill:f.palette.neutral.solid.bg}},width:20,height:20})})})]},`switch-array-${A}`))})},Got=C.forwardRef((e,t)=>{const{type:r,id:n,isLoop:i,viewOnly:o=!1}=e,{control:s,setValue:a,watch:l,formState:{errors:u}}=Rr(),c=l("properties"),f=l("properties.next_counter"),p=l("properties.cases"),h=m=>{const O=l(`properties.${m}`);a("properties.next_counter",f+1),a(`properties.${m}`,[...O,{caseKey:`case${f+1}Handle`,caseValue:"",caseType:"string"}])},A=(m,O)=>{const y=l(`properties.${m}`).filter((T,v)=>v!==O);a(`properties.${m}`,y)},g=m=>/^.*\{\{[^{}]+\}\}.*$/.test(m);return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(hr,{name:"properties.condition",control:s,rules:{required:"Condition is required",validate:m=>g(m)?!0:"Invalid condition. Dynamic placeholders {{ }} are required."},render:({field:m})=>d.jsx(fo,{...m,id:n,viewOnly:o,showSuggestions:!0,label:"Condition",name:"condition",editorId:`${r}-condition`,placeholder:"Enter a condition",fullWidth:!0,isLoop:i,required:!0,errorMsg:u.properties?.condition?.message,helperText:In(r,"condition")})})})})}),c.condition&&g(c.condition)&&d.jsx(E.Divider,{}),c.condition&&g(c.condition)&&d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsxs(E.Grid,{item:!0,xs:12,pb:1,children:[d.jsx(gn,{label:"Cases"}),d.jsx(Vot,{placeholder:"Case",nodeId:n,viewOnly:o,type:r,field:"cases",requiredValue:!0,isLoop:i,items:p.filter(m=>m.caseValue!=="default"),name:"properties.cases",handleArrayItemDelete:A},p.length),d.jsxs(E.Button,{variant:"text",disabled:o,onClick:()=>h("cases"),sx:{color:m=>m.palette.primary[60],mt:1,"&:hover":{backgroundColor:"transparent",color:m=>m.palette.primary[50],"& .MuiTypography-root":{color:m=>m.palette.primary[50]},"& svg path":{fill:m=>m.palette.primary[50]}}},disableFocusRipple:!0,disableTouchRipple:!0,disableRipple:!0,disableElevation:!0,children:[d.jsx(Ue,{src:"ic_plus",sx:{fontSize:"18px",marginRight:"5px",path:{fill:"currentColor"}}}),d.jsx(E.Typography,{variant:"smNormal",sx:{alignItems:"center"},children:"Add"})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Ui,{viewOnly:o,type:r})})]})})]})}),Wot=C.forwardRef((e,t)=>{const{type:r,VORTEX_MAIN_URL:n,ENTITY_ID:i,suggestionsData:o,isLoop:s=!1,viewOnly:a=!1}=e,{loopSuggestionsData:l={}}=pt.useSelector(f=>f.loopActivity),{control:u,formState:{errors:c}}=Rr();return d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(hr,{name:"properties.template",control:u,rules:{required:"Template is required"},render:({field:f})=>d.jsx($i,{...f,label:"Template",suggestionLabel:"Template",id:`${r}-template`,size:"xl",viewOnly:a,activityType:r,VORTEX_MAIN_URL:n,ENTITY_ID:i,language:"html",helperText:d.jsxs(E.Box,{children:["Create dynamic web templates easily using Nunjucks, a powerful JavaScript templating engine.see",d.jsx(E.Link,{href:"https://mozilla.github.io/nunjucks/",target:"_blank",children:" Nunjucks Docs"})]}),error:!!c.properties?.template?.message,errorMsg:c.properties?.template?.message,handleChange:p=>f.onChange(p),required:!0,showSuggestions:!0,suggestionsData:s?l:o,showExpandOption:!0})})}),!s&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Ui,{viewOnly:a,type:r})})]})})}),Qot=Xi(Wot),zot=C.forwardRef((e,t)=>{const r=pt.useDispatch(),{id:n,type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,FRONTEND_URL:a,INTEGRATION_DATA:l,viewOnly:u=!1,openIntegrationDrawer:c}=e,[f,p]=C.useState([]),[h,A]=C.useState(!1),{control:g,resetField:m,watch:O,setValue:y}=Rr(),T=O("properties.auth_type"),v=()=>{A(!0);const _={page_size:999,current_page:1,type:"SOURCE"},x=Xt(o,"/v1/integrations/entity/AUTHENTICATION");Qt.get(x,{params:_}).then(({data:b})=>{const w=io(b.data,["integration_meta"]),R=yT(w);p(vT(R))}).catch(b=>{sr(b,r)}).finally(()=>{A(!1)})};return C.useEffect(()=>{l?._id&&l?.meta?.entity==="AUTHENTICATION"&&(v(),y("properties.auth_id",l._id,{shouldValidate:!0}))},[l]),C.useEffect(()=>{!vt(T)&&T!==Ml.NONE?v():m("properties.auth_id")},[T]),d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.auth_type",control:g,meta:{options:e1,displayName:"Authentication Type",searchFieldPlaceholder:"Search authentication type",description:"Select Authentication Type (Basic Auth, Header Auth or None)",placeholder:"Select Authentication type"},validationRules:{required:"Auth type is required"},viewOnly:u,id:i})}),T&&T!==Ml.NONE&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.auth_id",control:g,meta:{options:Tn(f),displayProps:{loading:h},displayName:"Authentication",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:a,ENTITY_ID:s,openIntegrationDrawer:c,addNewButtonText:"Add new",searchFieldPlaceholder:"Search authentication",authType:"AUTHENTICATION",description:"Select Authentication you have saved in the Secrets. You can also create a new Secret using Add new button. Your credentials are encrypted & can be removed at any time.",placeholder:"Select Authentication"},validationRules:{required:"Authentication is required"},viewOnly:u,id:i,groupBy:"integration_meta.auth_type"})})]})}),d.jsx(E.Divider,{}),d.jsx(En,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Yu,{name:"properties.test_payload",label:"Test Trigger Payload",viewOnly:u,required:!0,id:n,validationRules:{required:"Value is required"},fullScreen:!0,showSuggestions:!0,excludePayloadSuggestions:!0})})})})]})}),Xot=Object.freeze(Object.defineProperty({__proto__:null,CopilotWebhook:l7e,FyndAIPIM:iq,FyndCommerceB2B:lN,FyndEngage:cN,FyndKonnect:fN,FyndTMS:oq,apiActivity:tBe,askAgent:lBe,bolticStorageActivity:cBe,bolticTableActivity:XBe,boltic_storage:uBe,boltic_table:dBe,browserbase:YBe,calendly:KBe,converterActivity:a7e,emailActivity:f7e,executeChildWorkflow:h7e,fp_webhook:S7e,functionActivity:b7e,gmailActivity:B7e,gmail_trigger:F7e,googleCalendarActivity:WZe,googleMeet:QZe,googleSheetsReadActivity:zZe,googleSheetsWriteActivity:XZe,gpt:YZe,graphql:KZe,http:ZZe,ifActivity:oJe,logConsole:lJe,loop:dJe,mapper:pJe,mcp:OJe,monitor:vJe,parallel:TJe,response:xJe,schedule:PJe,serverless:sre,slackActivity:Uot,slack_trigger:Mot,sleep:Hot,switchActivity:Got,template:Qot,webhook:zot},Symbol.toStringTag,{value:"Module"})),qot=C.forwardRef((e,t)=>{const{type:r,formData:n,selectedNode:i,onClose:o,isLoop:s=!1,cloudRef:a,suggestionsData:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleRunActivity:h,handleCompleteSetup:A,MCP_INTEGRATION_FORM:g=!1,onSubmit:m}=e,{viewOnly:O}=pt.useSelector(H=>H.canvas),{loopSuggestionsData:y={}}=pt.useSelector(H=>H.loopActivity),{form:T,formSchema:v,loading:_,handleFocus:x,handleChange:b,handleCustom:w,setForm:R,handleCancel:I,setFormSchema:P,GraphQLInspectorModal:k}=wx({formData:n,isLoop:s,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:o,handleRunActivity:h,handleCompleteSetup:A,openIntegrationDrawer:u,onSubmit:m,MCP_INTEGRATION_FORM:g}),N=()=>{},L=(H,j="")=>{if(!s){const X={type:r,name:i.data.name,properties:H};e.onSubmit?.(X,j)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:T,type:r}),validateForm:()=>!0,resetFormData:()=>{R({}),P([])}}),[T]);const B=Ix(v)?Dx(v,T):v;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:a,name:`${i.id}-db-form`,schema:g?v:B,onSubmit:L,onChange:b,onFocus:x,onReset:N,onCancel:I,onCustom:w,form:T,isLoading:_||p,suggestions:s||g?y:l,useDefaultButtons:!1,viewOnly:O,MCP_INTEGRATION_FORM:g,MCP_EXCLUDED_FIELDS:of}),d.jsx(k,{})]})}),Yot=Xi(qot),Kot=C.forwardRef(({type:e,formData:t,onSubmit:r,selectedNode:n,onClose:i,cloudRef:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,isLoading:u=!1,setPollingInterval:c},f)=>{const{viewOnly:p}=pt.useSelector(k=>k.canvas),{form:h,formSchema:A,loading:g,handleFocus:m,handleChange:O,handleCustom:y,setForm:T,handleCancel:v,setFormSchema:_,GraphQLInspectorModal:x}=wx({formData:t,selectedNode:n,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,onClose:i,openIntegrationDrawer:s,onSubmit:r,setPollingInterval:c});C.useImperativeHandle(f,()=>({getData:()=>({name:n.data.properties.activity_name,properties:h,type:e}),validateForm:()=>!0,resetFormData:()=>{T({}),_([])}}),[h]);const b=(k,N="")=>{const L=k,M={type:e,name:n.data.name,properties:{...L}};r?.(M,N)},w=()=>{},I=Ix(A)?Dx(A,h):A,P=h;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:o,name:`${n.data.name}-trigger-integration-form`,schema:I,onSubmit:b,onChange:O,onFocus:m,onReset:w,onCancel:v,onCustom:y,form:P,isLoading:g||u,useDefaultButtons:!1,viewOnly:p}),d.jsx(x,{})]})}),Zot=C.forwardRef((e,t)=>{const{type:r,formData:n,selectedNode:i,isLoop:o=!1,cloudRef:s,suggestionsData:a,onClose:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleCompleteSetup:h,handleRunActivity:A,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O=!1}=e,{viewOnly:y}=pt.useSelector(j=>j.canvas),{loopSuggestionsData:T={}}=pt.useSelector(j=>j.loopActivity),{form:v,formSchema:_,loading:x,handleFocus:b,handleChange:w,handleCustom:R,setForm:I,handleCancel:P,setFormSchema:k,GraphQLInspectorModal:N}=wx({formData:n,isLoop:o,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:l,handleRunActivity:A,handleCompleteSetup:h,openIntegrationDrawer:u,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O}),L=()=>{},M=(j,X="")=>{if(O&&I(j),!o){const F={type:r,name:i.data.name,properties:j};e.onSubmit?.(F,X)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:v,type:r}),validateForm:()=>!0,resetFormData:()=>{I({}),k([])}}),[v]);const H=Ix(_)?Dx(_,v):_;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:s,name:`${i.id}-integration-form`,schema:O?_:H,onSubmit:M,onChange:w,onFocus:b,onReset:L,onCancel:P,viewOnly:y,onCustom:R,form:v,isLoading:x||p,useDefaultButtons:!1,suggestions:o||O?T:a,MCP_INTEGRATION_FORM:O,MCP_EXCLUDED_FIELDS:of}),d.jsx(N,{})]})}),Jot=Xi(Zot),est={"blt-int.fynd-aipim":iq,"blt-int.fynd-konnect":fN,"blt-int.konnect":fN,"blt-int.fynd-engage":cN,"blt-int.engage":cN,"blt-int.fynd-commerce-b2b":lN,"blt-int.commerce-b2b":lN,"blt-int.fynd-tms":oq},ure=C.forwardRef((e,t)=>{const{type:r,selectedNode:n,formData:i,initialState:o,onSubmit:s,onClose:a,openIntegrationDrawer:l,ENTITY_ID:u,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isExecutionLoading:A=!1,isLoop:g=!1,viewOnly:m,actionRef:O,activityDataRef:y,handleRunActivity:T,handleCompleteSetup:v,setPollingInterval:_,methods:x,activityName:b,MCP_INTEGRATION_FORM:w=!1}=e,{VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,ATHENA_MAIN_URL:H,NEO_MAIN_URL:j,TRINITY_MAIN_DOMAIN:X}=c||{},F=D=>{let $=D;n.data.type===Ze.LOOP&&($=y.current?.getData());const U=zb($),q=U?.integration_slug||n?.data?.properties?.integration_slug;s({...n.data,type:n.data.type,name:b||n.data.name,properties:{...U,...q?{integration_slug:q}:{}},id:n.id})},V=n?.data?.properties?.integration_slug,G=V?est[V]:void 0;if(G)return g?d.jsx(G,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w}):d.jsx("form",{autoComplete:"off",style:{height:"100%"},onSubmit:x.handleSubmit(F),children:d.jsx(G,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w,NEO_MAIN_URL:j,TRINITY_MAIN_DOMAIN:X})});switch(r){case"CloudTrigger":return d.jsx(Kot,{id:n.id,ref:y,cloudRef:O,formData:i,onSubmit:s,initialState:o,isLoading:A,type:r,selectedNode:n,VORTEX_MAIN_URL:R,openIntegrationDrawer:l,ENTITY_ID:u,TESSERACT_MAIN_URL:P,onClose:a,FRONTEND_URL:k,SERVERLESS_URL:I,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,setPollingInterval:_});case"platformFdkActivity":case"applicationFdkActivity":case"customActivity":return d.jsx(Jot,{id:n.id,ref:y,cloudRef:O,formData:i,handleRunActivity:T,initialState:o,handleCompleteSetup:v,isLoading:A,onSubmit:s,openIntegrationDrawer:l,type:r,FRONTEND_URL:k,selectedNode:n,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"CloudDatabase":return d.jsx(Yot,{id:n.id,ref:y,cloudRef:O,formData:i,initialState:o,handleRunActivity:T,handleCompleteSetup:v,onSubmit:s,openIntegrationDrawer:l,type:r,FRONTEND_URL:k,isLoading:A,selectedNode:n,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"serverless":return d.jsx(sre,{id:n.id,ref:y,handleRunActivity:T,handleCompleteSetup:v,cloudRef:O,formData:i,isLoading:A,onSubmit:s,type:r,openIntegrationDrawer:l,FRONTEND_URL:k,initialState:o,selectedNode:n,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,activity_id:n.data.activity_id,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,...g?{useDefaultButtons:!1}:{}});default:{const $={...Xot}[r];return $?(w&&C.useImperativeHandle(O,()=>({getData:()=>({name:n.data.properties.activity_name,properties:i,type:r}),validateForm:()=>!0,handleSubmit:async()=>{const U=await x?.trigger();if(U){let q=x?.getValues();q=u1(q,of),F(q)}return U},isValidated:x?.formState?.isValid}),[i,r,n.data.properties.activity_name,x]),g?d.jsx($,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w}):d.jsx("form",{autoComplete:"off",style:{height:"100%"},onSubmit:x.handleSubmit(F),children:d.jsx($,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w,NEO_MAIN_URL:j,TRINITY_MAIN_DOMAIN:X})})):null}}}),cre=({onSubmit:e,selectedNode:t,onClose:r,initialState:n,drawerWidth:i,setSelectedNode:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,openDocs:u,setOpenDocs:c,source:f,actionRef:p,MCP_INTEGRATION_FORM:h=!1})=>{const A=E.useTheme(),g=pt.useDispatch(),m=Rt.useNodes(),{setNodes:O,getNode:y,getEdges:T}=Rt.useReactFlow(),v=p||C.useRef(null),_=C.useRef(null),x=C.useMemo(()=>_o(),[]),{activities:b,triggers:w,reserved_keywords:R,activity_names:I}=pt.useSelector(Ge=>Ge.activities),{canvasWorkflow:P,activityExecutionData:k,viewOnly:N=!1,triggerNodeTest:L}=pt.useSelector(Ge=>Ge.canvas),M=ui(b?.data?.data,w?.data?.data,t.data,"slug"),{ENTITY_ID:B,WORKFLOW_URLS:H,openAddonModal:j,currentSubscription:X}=Ii(),{workflow:F}=pt.useSelector(Ge=>Ge.workflows),V=f||F?.source||"",G=n1(t,V),D=rw({defaultValues:G,mode:"onChange"}),$=C.useRef(null),{analytics:U={}}=Ii(),[q,z]=C.useState(!1),[W,Q]=C.useState([]),[Y,J]=C.useState(!1),ee=C.useRef(null),{data:le}=m.find(Ge=>Ge.id===t?.id)||{},{blt_node_states:ne}=le||{},{test:ue="",setup_and_configure:Oe="",node:ve=""}=ne||{},[oe,ae]=C.useState(0),[re,Z]=C.useState([{label:"Setup & Configure",state:"default"},{label:"Test",state:""}]),{initialNodes:te=[]}=pt.useSelector(Ge=>Ge.workflows),se=C.useMemo(()=>{try{return!Rf.includes(t?.data?.type)}catch{return!0}},[t?.data?.type]);C.useEffect(()=>{const Ge=[{label:"Setup & Configure",state:"default"}];Z(se?[...Ge,{label:"Test",state:""}]:Ge),ae(0)},[se]),C.useEffect(()=>()=>{$.current&&clearTimeout($.current)},[]);const he=Ge=>{Z(nt=>nt.map((Et,yt)=>{const we=["setup_and_configure","test"][yt];return Ge[we]?{...Et,state:I6e(Ge[we])}:Et}))};C.useEffect(()=>{(Oe||ue||ve)&&he({setup_and_configure:Oe||"default",test:ue||"",node:ve||""})},[Oe,ue,ve]);const pe=C.useRef(!1),de=C.useRef(null);C.useEffect(()=>{if(t?.id)if(L?.nodeId===t.id){ae(1);const Ge=`${L.nodeId}-${L.runWithPrevious}`;if(de.current===Ge){g({type:Nb});return}de.current=Ge,Te(L.runWithPrevious),g({type:Nb}),pe.current=!0}else de.current=null,pe.current?pe.current=!1:ae(ve==="completed"&&se?1:0)},[t?.id,L?.nodeId,L?.runWithPrevious,ve,se]);const{VORTEX_MAIN_URL:xe}=H,[ge,Ee]=C.useState(!1),[ke,We]=C.useState(t?.data?.name||""),[$e,et]=C.useState(null),st=bn(x),it=bn(Dr.VERSION),[Re,qe]=C.useState(null),Ye=async Ge=>await dce(Ge.trim(),t.data.name,R,I)||null,Se=C.useRef(Da(Ge=>{g({type:Xr,payload:{open:!0,title:Ge,type:"error",width:"30rem",duration:3e3}})},300)).current,_e=async Ge=>{We(Ge);const nt=await Ye(Ge.trim());if(nt){et(nt),Se(nt);return}const Et=t.data.name;let yt=Mo(I);if(yt.includes(Et)){const Dt=yt.findIndex(we=>we===Et);yt=[...yt.slice(0,Dt),Ge.trim(),...yt.slice(Dt+1)]}else yt=[...yt,Ge.trim()];g({type:wi.SET_ACTIVITY_NAMES,payload:yt}),O(Dt=>{const Qe=JSON.stringify(Dt).replace(new RegExp(`{{${Et}`,"g"),`{{${Ge.trim()}`).replace(new RegExp(`result.${Et}`,"g"),`result.${Ge.trim()}`);return JSON.parse(Qe)}),et(null),K(Ge.trim())},be=()=>{["error","completed"].includes(ue)||x===jn.DRAFT&&Ra(O,t,{}),r(),c?.(!1)},K=Ge=>{const nt=_.current?.getData()||D.getValues();o(Et=>Et?{...Et,data:{...Et.data,name:Ge,properties:{...nt?.properties}}}:null),O(Et=>Et.map(yt=>yt.id===t.id?{...yt,data:{...yt.data,name:Ge}}:{...yt}))},ce=async(Ge,nt,Et)=>{const yt=[...Array.isArray(m)?m:[]],Dt={nodes:nt?[Oc({...Ge})]:[Oc({...t,data:Ge})],result:K0(P,m,k,Ge?.id||t?.id,T())};z(!0);const we=it||st;J(!0);const{success:Qe,isError:Je,data:De}=await Y0(nt?Ge:t,g,xe,B,yt,m,Dt,$,U,we,j,X,Et,void 0,void 0,Et?T():void 0);if(Qe&&!Je)return St(),z(!1),Qe;if(Je&&(setTimeout(()=>{St()},500),De)){delete De.singleRunFailure,Ra(O,t,{test:"error",node:"failed",setup_and_configure:"completed"});const at=Object.keys(De);at&&at.length>0&&at.forEach(Ot=>{ZO(De[Ot]).forEach(ur=>{g({type:Xr,payload:{open:!0,title:typeof ur!="string"?JSON.stringify(ur):ur,type:"error",width:"30rem",duration:3e3}})})})}return z(!1),!1},Te=async Ge=>{const nt=await Ye(ke.trim()),Et=gd(t.data);if(nt&&Et!==xt.TRIGGER){Se(nt);return}const yt=m.find(we=>we.id===t.id);let Dt=!0;Dt=await ce({...yt,outgoingPorts:[Ze.IF,Ze.SWITCH].includes(t.data.type)?t?.outgoingPorts||yt?.outgoingPorts||[]:[]},!0,Ge),Dt&&(Ra(O,t,{test:"completed",node:"completed"}),z(!1))},Be=async(Ge,nt,Et=!1)=>{Ge.preventDefault();const yt=await Ye(ke.trim()),Dt=gd(t.data);if(yt&&Dt!==xt.TRIGGER){Se(yt);return}if(Dt===xt.TRIGGER||vt($e)){const we=await D.trigger();let Qe;if(t?.data?.type===Ze.LOOP&&_.current&&(Qe=await _.current?.validateForm()),we&&(t?.data?.type!==Ze.LOOP||Qe!==!1)||Et){const Je=m?.find(at=>at.id===t.id)?.data?.properties;let De=D.watch();if(t.data.type===Ze.LOOP&&_.current&&(De=_.current.getData()),Od.includes(t.data.type)&&(De={...De,properties:{...typeof De.properties=="object"&&De.properties?De.properties:{},...typeof Je=="object"&&Je?Je:{}}}),nt==="skip_test"){const at=zb(De),Ot=M||at?.integration_slug||t?.data?.properties?.integration_slug;e({...t.data,type:t.data.type,name:ke||t.data.name,properties:{...at,...Ot?{integration_slug:Ot}:{}},id:t.id},nt)}if(nt==="save"){l(null),ae(0),Z(at=>at.map(Ot=>({...Ot,state:"default"}))),g({type:Ad,payload:null}),r();return}se&&(ae(1),Z(at=>at.map(Ot=>({...Ot,state:Ot.state===""?"default":Ot.state}))))}}};C.useEffect(()=>{if(h)return;const Ge=m.find(nt=>nt.id===t?.id);(!Ge||Ge?.type===xt.PLACEHOLDER)&&o(null)},[m,o,t?.id,h]),C.useEffect(()=>{if(Ee(!1),t?.id){const nt=m.find(Dt=>Dt.id===t?.id)||t;if(!nt?.data)return;const Et=Vb(nt.data);if(ee.current===Et)return;ee.current=Et;const yt=n1(nt,V);D.reset(yt,{keepDefaultValues:!1,keepErrors:!1,keepDirty:!1,keepIsSubmitted:!1,keepTouched:!1,keepIsValid:!1,keepSubmitCount:!1}),We(yt.name)}else ee.current=null},[t?.id,m,D,V]);const Fe=ui(b?.data?.data,w?.data?.data,t.data),He=ui(b?.data?.data,w?.data?.data,t.data,"meta"),dt=C.useMemo(()=>{const Ge=m.find(nt=>nt.id===t?.id);return Ge?{...Ge.data}:{...t.data}},[t?.id,m]);C.useEffect(()=>()=>{l(null)},[]),C.useEffect(()=>{h||t&&(y(t.id)||o(null))},[m,h]);const Tt=ui(b?.data?.data,w?.data?.data,t.data,"status"),Ie=!!ui(b?.data?.data,w?.data?.data,t.data,"pro"),lt=async(Ge,nt="")=>{const Et=await Ye(ke.trim()),yt=gd(t.data);if(Et&&yt!==xt.TRIGGER){Se(Et);return}if(nt===""){e({...Ge,name:ge?ke:t.data.name,id:t.id},nt);return}if(yt===xt.TRIGGER||vt($e)){let Dt=!0;if(nt==="skip_test")try{const we=te?.find(Qe=>Qe?.id===t?.id);Vb(we?.data)!==Vb(Ge)&&g({type:md,payload:{type:"replace",data:{...k,[t?.id]:{}}}})}catch{}nt==="test_and_save"&&(Dt=await ce(Ge,!1)),Dt&&e({...Ge,name:ge?ke:t.data.name,id:t.id},nt)}se&&(ae(1),Z(Dt=>Dt.map((we,Qe)=>Qe===0?{...we,state:"completed"}:{...we,state:["error","completed"].includes(ue)?ue:"default"})))},ct=Ge=>{g({type:Au,payload:{id:Ge}})},rt=async Ge=>{const nt=m?.find(Et=>Et?.id===Ge);await ce(nt,!0)},kt=()=>{ae(0),c?.(!1),r(),Z(Ge=>Ge.map((nt,Et)=>Et===0?{...nt,state:"default"}:{...nt,state:"default"}))},Gt=async(Ge,nt)=>{const Et=Xt(xe,`/v1.0/${B}/`,`workflows/${Ge}/integrations/${nt}/executions`);return await Qt.get(Et)},St=async()=>{J(!0);const Ge=it||st;try{if(t?.data?.type!=="webhook"&&Ge){const{data:nt}=await Gt(Ge,t.data.properties.integration_slug&&t.id?`${t.data.properties.integration_slug}_${t.id}`:t.id);Q(nt.data)}}catch(nt){sr(nt,g)}finally{J(!1)}},je=C.useMemo(()=>d.jsx(ure,{type:t.data.type,selectedNode:t,formData:dt,initialState:n,onSubmit:lt,onClose:kt,openIntegrationDrawer:s,ENTITY_ID:B,WORKFLOW_URLS:H,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,source:f,isExecutionLoading:q,actionRef:v,activityDataRef:_,handleRunActivity:rt,handleCompleteSetup:ct,setPollingInterval:qe,methods:D,activityName:ke,viewOnly:N,MCP_INTEGRATION_FORM:h},t?.id),[t?.id,t.data.type,dt,n,lt,kt,s,B,H,a,l,f,q,v,_,rt,ct,qe,D,ke,N]),Ke=C.useMemo(()=>d.jsx(w6e,{activityExecutionList:W,setActivityExecutionList:Q,ENTITY_ID:B,VORTEX_MAIN_URL:xe,selectedNode:t,loading:Y,fetchActivityExecutions:St,viewOnly:N}),[W,Q,B,xe,t,Y,St,N]);return d.jsx(iye,{MCP_INTEGRATION_FORM:h,MCP_EXCLUDED_FIELDS:of,children:d.jsx(KM,{...D,children:d.jsxs(E.Stack,{position:h?"relative":"absolute",top:0,right:0,sx:{height:"100%",width:"100%",...h?{border:`1px solid ${A.palette.grey[300]}`,borderRadius:2}:{borderLeft:`1px solid ${A.palette.grey[300]}`,borderRight:u?`1px solid ${A.palette.grey[300]}`:0},zIndex:A.zIndex.drawer+2},children:[!h&&d.jsxs(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:0,zIndex:1,py:1.5,px:2,height:48},children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1.5,children:[Fe?d.jsx("img",{src:Fe,alt:t.data.name,width:30,height:30,style:{border:`1px solid ${A.palette.grey[300]}`,borderRadius:"4px",padding:"2px",width:32,height:32}}):d.jsx(E.Avatar,{variant:"square",sx:{width:32,height:32,p:2},children:t.data.name.slice(0,2).toUpperCase()}),d.jsx(vX,{value:t?.data.name,onSave:_e,minWidth:64,maxWidth:240,isEditing:ge,setIsEditing:Ge=>{Ee(Ge),Ge&&et(null)},disabled:N||t.type===xt.TRIGGER,maxLength:50,error:$e,variant:"mdSemiBold",textSx:{color:A.palette.text.primary,maxWidth:240,lineHeight:"32px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},inputSx:{height:"100%",fontSize:"1.5rem",".MuiInputBase-input":{py:"5px",px:1,fontSize:"16px",fontWeight:600},"& .MuiFormHelperText-root.Mui-error":{width:"max-content"},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"auto"}},autoResize:!0,enableDoubleClick:!0,showEditIcon:!N&&t.type!==xt.TRIGGER}),t?.type===xt.TRIGGER&&He?.trigger_type===zO.SCHEDULED&&(He?.polling_interval||Re)&&d.jsx(E.Tooltip,{arrow:!0,title:`The trigger checks for new data every ${He?.polling_interval||Re} minutes.`,children:d.jsxs(E.Box,{display:"flex",alignItems:"center",borderRadius:1,ml:1,px:.5,sx:{border:`1px solid ${A.palette.grey.outlined.border}`},children:[d.jsx(Ue,{src:"ic_schedule",sx:{cursor:"pointer",mr:.5,width:18}}),d.jsxs(E.Typography,{variant:"xsMedium",sx:{fontStyle:"normal",lineHeight:"24px"},children:[He?.polling_interval||Re," mins"]})]})})]}),d.jsxs(E.Stack,{alignItems:"center",gap:1.5,flexDirection:"row",children:[Tt===qp.DRAFT&&d.jsx(E.Stack,{direction:"row",alignItems:"center",sx:{padding:"2px 8px",borderRadius:6,background:Ge=>Ge.palette.grey[200]},children:d.jsx(E.Typography,{variant:"xsNormal",sx:{textTransform:"capitalize"},children:Tt})}),Ie&&d.jsx(sf,{}),d.jsxs(E.Button,{onClick:()=>c?.(!u),variant:"outlined",sx:{px:"8px !important",py:"2px !important",borderRadius:"6px","&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${u?A.palette.primary.main:A.palette.neutral.outlined.border}`,"& path":{fill:u?A.palette.primary.main:A.palette.neutral.solid.bg}},"&:hover":{"& .MuiTypography-root":{color:A.palette.primary.main},"& path":{fill:A.palette.primary.main},"&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${A.palette.primary.main}`,"& path":{fill:A.palette.primary.main}}}},children:[d.jsx(Ue,{src:"ic_document"}),d.jsx(E.Typography,{variant:"smSemiBold",sx:{pl:.5,color:u?A.palette.primary.main:A.palette.neutral.plain},children:"Docs"})]}),d.jsx(E.IconButton,{onClick:be,sx:Ni(A),children:d.jsx(Ue,{width:24,height:24,src:"ic_close"})})]})]}),!h&&d.jsx(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:48,zIndex:1,py:1,px:2,height:48,backgroundColor:A.palette.white.smoke},children:d.jsx(B0e,{steps:re,activeStep:oe,setActiveStep:ae})}),d.jsxs(E.Stack,{gap:"12px",sx:{overflowY:"auto",p:2,height:h?"calc(100% - 10px)":"calc(100% - 152px)","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:A.palette.grey[300],borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:A.palette.grey[400]}},children:[(oe===0||h)&&je,oe===1&&!h&&Ke]}),!h&&d.jsx(L0e,{isExecutionLoading:q,selectedNodeType:t.data.type,onClose:kt,validateAndSubmit:Be,activityExecutionList:W,isViewOnly:N,drawerWidth:i,selectedNode:t,activeStep:oe,ref:v,setNodes:O,testActivity:Te,MCP_INTEGRATION_FORM:h})]})})})},tst=C.memo(e=>{const t=E.useTheme(),r=Rt.useNodes(),n=Rt.useEdges(),{setNodes:i,setEdges:o}=Rt.useReactFlow(),{canvasWorkflow:s}=pt.useSelector(O=>O.canvas),a=s?.meta?.isHorizontal??!0,{fromX:l,fromY:u,toX:c,toY:f,fromNode:p,sourcePosition:h,targetPosition:A}=e;if([l,u,c,f].some(O=>typeof O!="number"||Number.isNaN(O)))return null;C.useEffect(()=>{const{id:O}=p,y=n.filter(T=>T.source===O&&T.type===Hr.PLACEHOLDER);if(y.length>0){let T=null,v=1/0;if(y.forEach(_=>{const x=r.find(b=>b.id===_.target);if(x){const b=x.position.y+(x.height||51)/2,w=Math.abs(b-u);w<v&&(v=w,T=_)}}),T&&v<30){const _=T.target,x=n.filter(R=>R.id!==T.id);o(x);const b=r.find(R=>R.id===O),w=r.filter(R=>R.id!==_);if(b){b.outgoingPorts=(b.outgoingPorts||[]).filter(I=>I.id!==_);const R=w.filter(I=>I.id!==O);i([...R,b])}else i(w)}}},[]);const[m]=Rt.getBezierPath({sourceX:a?c:l,sourceY:a?f:u,sourcePosition:a?A:h,targetX:a?l:c,targetY:a?u:f,targetPosition:a?h:A});return d.jsx("path",{fill:"none",stroke:t.palette.primary.main,strokeWidth:1.5,className:"animated",d:m})}),dre=e=>String(e??"").trim(),rst=e=>String(e??"").split(",").map(t=>dre(t)).filter(Boolean),RE=(e,t)=>{const r=dre(e),n=rst(t);return!r||n.length===0?!1:n.includes(r)},Rx=({edgeCenterX:e,edgeCenterY:t,onClick:r,isSelected:n=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-delete-button ${n?"selected":""}`,onClick:r,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-delete-square",children:d.jsx("div",{className:"react-flow__edge-delete-square-inner"})}),d.jsx("g",{transform:`translate(${e-8}, ${t-8})`,className:"react-flow__edge-delete-icon",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",children:d.jsx("path",{fill:i.palette.error.main,d:"M11.667 2.5C11.903 2.50007 12.1011 2.57961 12.2607 2.73926C12.4204 2.89891 12.4999 3.09704 12.5 3.33301H15.833C16.0691 3.33301 16.267 3.41352 16.4268 3.57324C16.5865 3.73296 16.667 3.93088 16.667 4.16699C16.6669 4.40296 16.5864 4.60109 16.4268 4.76074C16.2671 4.92025 16.069 5 15.833 5V15.833C15.833 16.2913 15.6701 16.6844 15.3438 17.0107C15.0175 17.3369 14.6251 17.4999 14.167 17.5H5.83301C5.37489 17.4999 4.98253 17.3369 4.65625 17.0107C4.32986 16.6844 4.16699 16.2913 4.16699 15.833V5C3.93104 5 3.73291 4.92025 3.57324 4.76074C3.41359 4.60109 3.33308 4.40296 3.33301 4.16699C3.33301 3.93088 3.41352 3.73296 3.57324 3.57324C3.73296 3.41352 3.93088 3.33301 4.16699 3.33301H7.5C7.50007 3.09704 7.57961 2.89891 7.73926 2.73926C7.89891 2.57961 8.09704 2.50007 8.33301 2.5H11.667ZM5.83301 15.833H14.167V5H5.83301V15.833ZM8.33301 6.66699C8.56904 6.66699 8.76706 6.74664 8.92676 6.90625C9.08648 7.06597 9.16699 7.26389 9.16699 7.5V13.333C9.16699 13.5691 9.08648 13.767 8.92676 13.9268C8.76704 14.0865 8.56912 14.167 8.33301 14.167C8.09704 14.1669 7.89891 14.0864 7.73926 13.9268C7.57975 13.7671 7.5 13.569 7.5 13.333V7.5C7.5 7.26397 7.57964 7.06594 7.73926 6.90625C7.89891 6.7466 8.09704 6.66707 8.33301 6.66699ZM11.667 6.66699C11.903 6.66707 12.1011 6.7466 12.2607 6.90625C12.4204 7.06594 12.5 7.26397 12.5 7.5V13.333C12.5 13.569 12.4202 13.7671 12.2607 13.9268C12.1011 14.0864 11.903 14.1669 11.667 14.167C11.4309 14.167 11.233 14.0865 11.0732 13.9268C10.9135 13.767 10.833 13.5691 10.833 13.333V7.5C10.833 7.26389 10.9135 7.06597 11.0732 6.90625C11.2329 6.74664 11.431 6.66699 11.667 6.66699Z"})})})]})},Px=({edgeCenterX:e,edgeCenterY:t,onClick:r,isSelected:n=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-add-button ${n?"selected":""}`,onClick:r,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-add-square",children:d.jsx("div",{className:"react-flow__edge-add-square-inner"})}),d.jsx("g",{transform:`translate(${e-12}, ${t-12})`,className:"react-flow__edge-add-icon",children:d.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",fill:"white"}),d.jsx("rect",{className:"add-button-border",x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",stroke:i.palette.neutral?.outlined?.border,fill:"none"}),d.jsx("path",{className:"add-button-icon",fillRule:"evenodd",clipRule:"evenodd",d:"M11.333 14.6663V12.6663H9.33301C9.14412 12.6663 8.98579 12.6025 8.85801 12.4747C8.73023 12.3469 8.66634 12.1886 8.66634 11.9997C8.66634 11.8108 8.73023 11.6525 8.85801 11.5247C8.98579 11.3969 9.14412 11.333 9.33301 11.333H11.333V9.33301C11.333 9.14412 11.3969 8.98579 11.5247 8.85801C11.6525 8.73023 11.8108 8.66634 11.9997 8.66634C12.1886 8.66634 12.3469 8.73023 12.4747 8.85801C12.6025 8.98579 12.6663 9.14412 12.6663 9.33301V11.333H14.6663C14.8552 11.333 15.0136 11.3969 15.1413 11.5247C15.2691 11.6525 15.333 11.8108 15.333 11.9997C15.333 12.1886 15.2691 12.3469 15.1413 12.4747C15.0136 12.6025 14.8552 12.6663 14.6663 12.6663H12.6663V14.6663C12.6663 14.8552 12.6025 15.0136 12.4747 15.1413C12.3469 15.2691 12.1886 15.333 11.9997 15.333C11.8108 15.333 11.6525 15.2691 11.5247 15.1413C11.3969 15.0136 11.333 14.8552 11.333 14.6663ZM9.39967 18.1413C10.2108 18.4913 11.0775 18.6663 11.9997 18.6663C12.9219 18.6663 13.7886 18.4913 14.5997 18.1413C15.4108 17.7913 16.1163 17.3163 16.7163 16.7163C17.3163 16.1163 17.7913 15.4108 18.1413 14.5997C18.4913 13.7886 18.6663 12.9219 18.6663 11.9997C18.6663 11.0775 18.4913 10.2108 18.1413 9.39967C17.7913 8.58856 17.3163 7.88301 16.7163 7.28301C16.1163 6.68301 15.4108 6.20801 14.5997 5.85801C13.7886 5.50801 12.9219 5.33301 11.9997 5.33301C11.0775 5.33301 10.2108 5.50801 9.39967 5.85801C8.58856 6.20801 7.88301 6.68301 7.28301 7.28301C6.68301 7.88301 6.20801 8.58856 5.85801 9.39967C5.50801 10.2108 5.33301 11.0775 5.33301 11.9997C5.33301 12.9219 5.50801 13.7886 5.85801 14.5997C6.20801 15.4108 6.68301 16.1163 7.28301 16.7163C7.88301 17.3163 8.58856 17.7913 9.39967 18.1413ZM15.783 15.783C14.7497 16.8163 13.4886 17.333 11.9997 17.333C10.5108 17.333 9.24967 16.8163 8.21634 15.783C7.18301 14.7497 6.66634 13.4886 6.66634 11.9997C6.66634 10.5108 7.18301 9.24967 8.21634 8.21634C9.24967 7.18301 10.5108 6.66634 11.9997 6.66634C13.4886 6.66634 14.7497 7.18301 15.783 8.21634C16.8163 9.24967 17.333 10.5108 17.333 11.9997C17.333 13.4886 16.8163 14.7497 15.783 15.783Z",fill:i.palette.neutral?.solid?.bg})]})})]})},nst=e=>{const t=E.useTheme(),{canvasWorkflow:r}=pt.useSelector(z=>z.canvas),{ENTITY_ID:n,allowedAccount:i}=Ii(),o=RE(n,i),s=r?.meta?.isHorizontal??!0,{id:a,sourceX:l,sourceY:u,targetX:c,targetY:f,sourcePosition:p,targetPosition:h,style:A={stroke:t.palette.neutral.main},markerEnd:g,source:m,target:O,sourceHandle:y,targetHandle:T}=e;if([l,u,c,f].some(z=>typeof z!="number"||Number.isNaN(z))||!p||!h)return null;const v=Rt.useEdges(),_=Rt.useNodes(),{deleteElements:x}=Rt.useReactFlow(),b=pt.useDispatch(),{viewOnly:w}=pt.useSelector(z=>z.canvas),R=v.find(z=>z.id===a),I=R?.data?.isStraight===!0,P=()=>Rt.getBezierPath({sourceX:l,sourceY:u,sourcePosition:p,targetX:c,targetY:f,targetPosition:h,curvature:.25});let k,N,L;I&&s?Math.abs(u-f)<2?(k=`M ${l},${u} L ${c},${u}`,N=(l+c)/2,L=u):(k=`M ${l},${u} L ${c},${u} L ${c},${f}`,N=(l+c)/2,L=(u+f)/2):[k,N,L]=P();const M=c-l,B=f-u,H=Math.sqrt(M*M+B*B),j=M/H,X=B/H,F=20,V=z=>{z.stopPropagation(),a&&x({nodes:[{id:R.target}],edges:[{id:a}]})},G=z=>{if(z.stopPropagation(),!w){b({type:Zp,payload:{x:z.clientX,y:z.clientY}}),b({type:w0,payload:!1});const W=`placeholder_${Math.trunc(Math.random()*1e9)}`;if(b({type:C0,payload:{id:W,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:T}}),!o){b({type:ss,payload:{type:"activities",active:!0,nodeId:W,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:T}}),b({type:ea,payload:!0});return}b({type:ea,payload:!1}),b({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),b({type:Ns,payload:"prompt"}),b({type:_0,payload:!0})}},D=_.find(z=>z.id===O),$=v.some(z=>z.source===O&&z.id!==a),U=D?.data?.outgoingPorts,q=$||Array.isArray(U)&&U.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:V,id:`${a}-interaction`,className:w?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:k,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:V,id:a,style:{...A},className:w?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:k,markerEnd:g}),!w&&d.jsx(d.Fragment,{children:s?d.jsxs(d.Fragment,{children:[q&&d.jsx(Px,{edgeCenterX:N-F*j,edgeCenterY:L-F*X,onClick:G}),d.jsx(Rx,{edgeCenterX:q?N+F*j:N,edgeCenterY:q?L+F*X:L,onClick:V})]}):d.jsxs(d.Fragment,{children:[q&&d.jsx(Px,{edgeCenterX:N-F*j,edgeCenterY:L-F*X,onClick:G}),d.jsx(Rx,{edgeCenterX:q?N+F*j:N,edgeCenterY:q?L+F*X:L,onClick:V})]})})]})},ist=e=>{const t=E.useTheme(),{id:r,sourceX:n,sourceY:i,targetX:o,targetY:s,sourcePosition:a,targetPosition:l,style:u={stroke:t.palette.neutral.main},markerEnd:c,source:f,target:p,sourceHandle:h,targetHandle:A}=e,{deleteElements:g}=Rt.useReactFlow(),m=pt.useDispatch(),{ENTITY_ID:O,allowedAccount:y}=Ii(),T=RE(O,y),v=Rt.useNodes(),_=Rt.useEdges(),{viewOnly:x,canvasWorkflow:b,activitiesPopover:w}=pt.useSelector(q=>q.canvas),R=b?.meta?.isHorizontal??!0,I=w?.edgeId===r&&w?.active;if([n,i,o,s].some(q=>typeof q!="number"||Number.isNaN(q))||!a||!l)return null;const[P,k,N]=Rt.getBezierPath({sourceX:n,sourceY:i,sourcePosition:a,targetX:o,targetY:s,targetPosition:l,curvature:.25}),L=o-n,M=s-i,B=Math.sqrt(L*L+M*M),H=L/B,j=M/B,X=20,F=q=>{q.stopPropagation(),r&&!x&&g({edges:[{id:r}]})},V=q=>{if(q.stopPropagation(),!x){const z=q.currentTarget?.getBoundingClientRect?.(),W=z&&Number.isFinite(z.left)&&Number.isFinite(z.top)?{x:z.left+z.width/2,y:z.top+z.height/2}:{x:q.clientX,y:q.clientY};m({type:Zp,payload:W}),m({type:w0,payload:!1});const Q=`ai_prompt_${Math.trunc(Math.random()*1e9)}`,Y={id:r,source:f,target:p,sourceHandle:h,targetHandle:A,type:Hr.SMOOTH,markerEnd:c,style:u};if(m({type:C0,payload:{id:Q,edgeId:r,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A,originalEdge:Y}}),!T){m({type:ss,payload:{type:"activities",active:!0,nodeId:Q,edgeId:r,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A}}),m({type:ea,payload:!0});return}m({type:ea,payload:!1}),m({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),m({type:Ns,payload:"prompt"}),m({type:_0,payload:!0})}},G=v.find(q=>q.id===p),D=_.some(q=>q.source===p&&q.id!==r),$=G?.data?.outgoingPorts,U=D||Array.isArray($)&&$.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:F,id:`${r}-interaction`,className:x?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:P,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:F,id:r,style:{...u},className:x?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:P,markerEnd:c}),!x&&d.jsx(d.Fragment,{children:R?d.jsxs(d.Fragment,{children:[U&&d.jsx(Px,{edgeCenterX:k-X*H,edgeCenterY:N-X*j,onClick:V,isSelected:I}),d.jsx(Rx,{edgeCenterX:U?k+X*H:k,edgeCenterY:U?N+X*j:N,onClick:F,isSelected:I})]}):d.jsxs(d.Fragment,{children:[U&&d.jsx(Px,{edgeCenterX:k-X*H,edgeCenterY:N-X*j,onClick:V,isSelected:I}),d.jsx(Rx,{edgeCenterX:U?k+X*H:k,edgeCenterY:U?N+X*j:N,onClick:F,isSelected:I})]})})]})},PE=e=>e.canvas,fre=e=>e.activities,pre=sl.createSelector([PE],e=>e.canvasWorkflow);sl.createSelector([pre],e=>e?.meta?.isHorizontal??!0);const ost=sl.createSelector([PE],e=>e.activityExecutionData),sst=sl.createSelector([PE],e=>e.selectedActivityId),ast=sl.createSelector([PE],e=>e.viewOnly);sl.createSelector([PE],e=>e.nodesToFocus);const lst=sl.createSelector([fre],e=>e.activities?.data?.data||[]),ust=sl.createSelector([fre],e=>e.triggers?.data?.data||[]),NE=sl.createSelector([lst,ust],(e,t)=>({activities:e,triggers:t})),cst=sl.createSelector([ost,(e,t)=>t],(e,t)=>e?.[t]?.loading??!1),dst=sl.createSelector([pre,ast,sst],(e,t,r)=>({isHorizontal:e?.meta?.isHorizontal??!0,viewOnly:t,selectedActivityId:r})),Nx=()=>{const e=E.useTheme();return d.jsx(E.Box,{className:"warning",sx:{background:e.palette.neutral.plain,color:e.palette.common.white,p:"2px 5px",margin:"14px 0px 0px",borderRadius:1.5,position:"relative",top:10},children:d.jsx(E.Typography,{variant:"smSemiBold",sx:{display:"block",width:200,fontFamily:"Inter"},children:"An activity can not be connected to more than one other activity"})})},vf=({type:e,position:t,id:r,isConnectable:n,className:i,isValidConnection:o,style:s,onClick:a})=>{const l=E.useTheme(),{viewOnly:u}=pt.useSelector(c=>c.canvas);return d.jsx(Rt.Handle,{onClick:u?void 0:a,type:e,position:t,id:r,isConnectable:n,isValidConnection:o,className:u?i+" viewModeCursor":i,style:{...s,backgroundColor:l.palette.common.white,cursor:u?"not-allowed":"pointer"},children:!u&&d.jsx(E.Box,{className:"handle_icon",sx:{bgcolor:l.palette.common.white,borderRadius:"50%"},children:d.jsx(Ue,{src:"ic_add_circle_outlined",width:"100%",height:"100%",sx:{path:{fill:l.palette.primary.main}}})})})};function fst(e=!1){const t=pt.useDispatch(),{getNodes:r,getEdges:n}=Rt.useReactFlow(),i=r(),o=n(),s=C.useRef({x:0,y:0}),{activity_names:a}=pt.useSelector(m=>m.activities),{setNodes:l,screenToFlowPosition:u}=Rt.useReactFlow(),[c,f]=C.useState([]),p=C.useCallback((m=u({x:s.current.x,y:s.current.y}))=>{const O=i.filter(v=>v.id===m);let y=[...i];const T=O.map(v=>{const _=Math.trunc(Math.random()*20),x=v.position.x+80+_,b=v.position.y+100+_,w=v?.data?.name||v?.data?.type||"node",I=Na(w,y),P=l1(null,v.data,null,I,y,null,"",[],{x,y:b});return v.activity_data&&(P.activity_data={...v.activity_data}),t({type:wi.SET_ACTIVITY_NAMES,payload:[...a,P.data.name]}),y=[...y,P],P});l([...i.map(v=>({...v,selected:!1})),...T])},[i,l,u]),h=C.useCallback(()=>{const m=i.filter(T=>T.selected);if(m.find(T=>T.type===xt.TRIGGER)){t({type:Xr,payload:{open:!0,title:"Trigger can't be copy",type:"error"}});return}let O=[...i];const y=m.map(T=>{const v=Math.trunc(Math.random()*20),_=T.data.name.split("_")[0],x=jb(_,O),b=T.position.x+60+v,w=T.position.y+60+v,R=Na(T?.data?.name||T?.data?.type||"node",O),I={...T,id:R,position:{x:b,y:w},data:{name:x,properties:T.data.properties,type:T.data.type},incomingPorts:[],outgoingPorts:[]};return O=[...O,{...I}],I});f(y),y.length===0?t({type:Xr,payload:{open:!0,title:"Please select a node to copy",type:"error"}}):t({type:Xr,payload:{open:!0,title:"Activity copied successfully",type:"success"}})},[i,o]),A=C.useCallback(({x:m,y:O}=u({x:s.current.x,y:s.current.y}))=>{const y=Math.min(...c.map(_=>_.position.x)),T=Math.min(...c.map(_=>_.position.y)),v=c.map(_=>{const x=_.id,b=m+(_.position.x-y),w=O+(_.position.y-T);return{..._,id:x,position:{x:b,y:w}}});l([...i.map(_=>({..._,selected:!1})),...v])},[c,u,l]),g=i.find(m=>m?.selected);return hre(e&&g?["Meta+c","Ctrl+c"]:[],h),hre(e&&g?["Meta+v","Ctrl+v"]:[],A),{copy:h,clone:p,paste:A,bufferedNodes:c}}function hre(e,t){const[r,n]=C.useState(!1),i=Rt.useKeyPress(e);C.useEffect(()=>{i&&!r?(t(),n(!0)):n(i)},[i,r,t])}const LE=({name:e,id:t,isTriggerNode:r,nodeData:n,handleDeleteNode:i,proIntegration:o=!1,onRunWithPrevious:s})=>{const a=E.useTheme(),l=pt.useDispatch(),{viewOnly:u}=pt.useSelector(j=>j.canvas),{workflow:c}=pt.useSelector(j=>j.workflows),{activities:f,triggers:p}=pt.useSelector(j=>j.activities),A=new URLSearchParams(typeof window<"u"?window.location.search:"").get("source")?.toLowerCase()||c?.source,g=r&&A?.includes("commerce_"),{clone:m}=fst(),O=ui(f?.data?.data,p?.data?.data,n),y=n?.properties?.integration_slug||"",T=n?.type,v=!r&&!Rf.includes(T),_=n?.blt_node_states||{},x=_.setup_and_configure||"default",b=_.node||"default",w=v&&x!=="completed"&&b!=="completed",R=Rt.useEdges(),I=C.useMemo(()=>R.some(j=>j.target===t&&j.type!==Hr.PLACEHOLDER),[R,t]),P=C.useCallback(()=>{o||w||(l({type:Au,payload:{id:t}}),l({type:Df,payload:!0}),l({type:Pb,payload:{nodeId:t,runWithPrevious:!1}}))},[t,o,w,l]),k=C.useCallback(()=>{o||w||!I||(s?s(t):(l({type:Au,payload:{id:t}}),l({type:Df,payload:!0}),l({type:Pb,payload:{nodeId:t,runWithPrevious:!0}})))},[t,o,w,I,l,s]),N=C.useCallback(()=>{o||m(t)},[t,o,m]),L=C.useCallback(()=>{i([{id:t,name:e,icon:O,integration_slug:y}])},[t,e,O,y,i]),M=C.useCallback(()=>{l({type:Df,payload:!1}),l({type:ss,payload:{type:"triggers",active:!0,nodeId:t}})},[t,l]);if(u)return null;const B={"&.Mui-disabled":{opacity:1}},H=a.palette.primary.disabled??a.palette.grey?.normal;return d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:.5,onClick:j=>j.stopPropagation(),children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",sx:{backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)",p:.25},children:[r&&d.jsx(E.Tooltip,{arrow:!0,title:"Switch Trigger",placement:"top",children:d.jsx(E.IconButton,{onClick:M,sx:{p:.5,width:28,height:28,...Ni(a)},"data-testid":"node-action-switch-trigger",children:d.jsx(Ue,{src:"ic_swap",width:20,height:20,sx:{path:{fill:a.palette.neutral.solid.bg||"#656A70"}}})})}),v&&d.jsxs(d.Fragment,{children:[d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to Test Node":"Test Node",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:P,disabled:w,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run",children:d.jsx(Ue,{src:"ic_play",width:20,height:20,sx:{path:{fill:w?H:a.palette.primary.main}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to run":I?"Run with previous":"No previous node attached",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:k,disabled:w||!I,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run-with-previous",children:d.jsx(Ue,{src:"ic_autoplay",width:20,height:20,sx:{path:{fill:w||!I?H:a.palette.primary.main}}})})})})]}),!r&&d.jsx(E.Tooltip,{arrow:!0,title:"Duplicate",placement:"top",children:d.jsx(E.IconButton,{onClick:N,disabled:o,sx:{p:.5,width:28,height:28,...Ni(a),...B},"data-testid":"node-action-duplicate",children:d.jsx(Ue,{src:"ic_copy",width:20,height:20,sx:{path:{fill:o?a.palette.text?.tertiary??a.palette.neutral?.solid?.bg:a.palette.neutral.solid.bg}}})})})]}),d.jsx(E.Tooltip,{arrow:!0,title:"Delete",placement:"top",children:d.jsx(E.IconButton,{onClick:L,disabled:g,sx:{p:.5,width:28,height:28,backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)","&:hover":{backgroundColor:a.palette.common.white,"& .inline-svg path":{fill:`${a.palette.error.main} !important`}}},"data-testid":"node-action-delete",children:d.jsx(Ue,{src:"ic_new_delete",width:20,height:20,sx:{path:{fill:a.palette.error.main||"#C41C1C"}}})})})]})},pst=250,kE=({children:e,id:t,nodeData:r,focused:n,sx:i={},actionBar:o})=>{const s=Rt.useNodes(),[a,l]=C.useState(!1),u=C.useRef(null),c=()=>{u.current&&(clearTimeout(u.current),u.current=null)},f=()=>{c(),u.current=setTimeout(()=>l(!1),pst)},p=()=>{c(),l(!0)};C.useEffect(()=>()=>c(),[]);const{setNodes:h}=Rt.useReactFlow(),{nodesToFocus:A}=pt.useSelector(b=>b.canvas),g=pt.useDispatch(),m=A.nodes.includes(t),[O,y]=C.useState(r?.activity_comment?.body||""),T=A.type;C.useEffect(()=>{y(r?.activity_comment?.body||"")},[r?.activity_comment?.body]);const v=C.useMemo(()=>Da(w=>{const R=s.map(I=>I.id===t?{...I,data:{...I.data,activity_comment:{...I.data.activity_comment,body:w,visible:w.trim()!==""}}}:I);h(R)},300),[s,t,g]);C.useEffect(()=>()=>{v.cancel()},[v]);const _=b=>{let w=b.target.value;w.length>299&&(w=w.substring(0,299)),y(w),v(w)},x=C.useMemo(()=>m&&A.show||n?{border:b=>`1px solid ${T==="focused"||n?b.palette.primary.main:b.palette.error.main}`,...i}:{border:b=>`1px solid ${b.palette.neutral.outlined.border}`,...i},[m,n,T,A.show,i]);return d.jsxs(E.Box,{className:"nodeContainer",position:"relative",sx:x,onMouseEnter:p,onMouseLeave:f,children:[o&&a&&d.jsx(E.Box,{"data-node-action-bar":!0,onMouseEnter:p,onMouseLeave:f,sx:{position:"absolute",bottom:"100%",left:0,right:0,display:"flex",justifyContent:"flex-end",mb:.75,zIndex:10,pointerEvents:"auto"},children:o}),d.jsxs(E.Box,{sx:{display:"flex",flexDirection:"column",flex:1},children:[e,r?.activity_comment?.visible&&d.jsx(E.Box,{position:"absolute",top:"100%",zIndex:1,width:"100%",height:"auto",mt:.75,mx:0,sx:{userSelect:"all",pointerEvents:"auto"},children:d.jsx(E.TextField,{fullWidth:!0,multiline:!0,variant:"outlined",value:O,placeholder:"Add a comment",autoFocus:O.trim()==="",sx:{width:"100%",background:b=>b.palette.white.ivory,borderRadius:"8px","&:hover":{".MuiInputBase-root":{"&:hover":{".MuiOutlinedInput-notchedOutline":{borderColor:b=>b.palette.primary.main}},boxShadow:b=>`0 0 8px ${b.palette.primary.main}`}},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"32px",padding:"10px 4px"}},onChange:_,onBlur:b=>{if(O.trim()===""){if(b.relatedTarget?.tagName==="BUTTON")return;const w=s.map(R=>R.id===t?{...R,data:{...R.data,activity_comment:{...R.data.activity_comment,visible:!1}}}:R);h(w)}}})})]})]},t)},hst=(e,t)=>{try{const r=e.replace(/properties\.([a-zA-Z_]\w*)/g,(i,o)=>{const s=t[o];return s!=null&&s!==""?s.toString():"undefined"});if(r.includes("undefined")||!/^[\d+\-*/().\s]+$/.test(r))return null;const n=new Function(`return ${r}`)();return typeof n=="number"&&!isNaN(n)?n:null}catch{return null}},Ast=(e,t,r)=>{if(!e)return{result:e,allReplaced:!1};let n=!0;return{result:e.replace(/\{\{([^}]+)\}\}/g,(o,s)=>{if(/[+\-*/()]/.test(s)){const a=hst(s,t);return a!==null?a.toString():(n=!1,o)}else{const l=s.replace(/^properties\??\./,"").replace(/\?/g,"").split(".");let u=t;for(const c of l)if(u&&typeof u=="object"&&c in u)u=u[c];else{u=void 0;break}if(u!=null&&u!==""){if(Array.isArray(u)&&u.length>0)return u.join(", ");if(Array.isArray(u)&&u.length===0)return n=!1,o;let c=r;for(const f of l)if(c&&typeof c=="object"&&f in c)c=c[f];else{c=void 0;break}return c&&typeof c=="object"&&u in c?c[u]:typeof u=="string"?$8(u):u}else return n=!1,o}}),allReplaced:n}},$8=e=>{if(!e)return"";const[t,...r]=e.split("."),n=r.length>0?r.join("."):"",i=(a,l=!1)=>{if(!a)return"";const u=a.replace(/[_\-\.]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g,"$1 $2").replace(/\s+/g," ").trim();return l?u.replace(/\b\w/g,c=>c.toUpperCase()):u.charAt(0).toUpperCase()+u.slice(1)},o=i(t),s=i(n);return s?`${s} [${o}]`:o},mst=e=>{const t=ece();if(Od.includes(e.data?.type))return e.data.properties?.operation?$8(e.data.properties.operation):"Select an operation";if(e.data?.type in t){const r=e.data.properties,n=t[e.data.type];let i={},o="";if(e.type===xt.TRIGGER?(i=n.trigger,o=n?.trigger?.manual_type):(i=n.integration,o=n?.integration?.manual_type),e.data?.type===Ze.SCHEDULE){const l=r?.spec;if(l){if(l.calendars&&l.calendars.length>0)return"Calendar Schedule";if(l.cron_expressions&&l.cron_expressions.length>0)return"Cron Schedule";if(l.intervals&&l.intervals.length>0)return"Interval Schedule"}return"Configure Schedule"}const s=Object.keys(i)[0],a=r?.[s];if(o){const{result:l,allReplaced:u}=Ast(o,r,i);return u?l:i.default}if(!a||typeof a=="object"&&vt(a))return i.default;if(i[s]){if(Array.isArray(a))return a.map(l=>i[s]?.[typeof l=="object"?l?.value?.toLowerCase():l?.toLowerCase()]).join(", ");if(e.data?.type===Ze.BOLTIC_TABLE_ACTIVITY){if(a==="sql_query"||r?.query)return"SQL Query";if(a==="custom_event"||a&&!i[s]?.[a])return $8(a)}return xb.includes(e.data?.type)&&(a==="custom"||e.data?.type===Ze.GOOGLE_SHEETS_WRITE&&s==="mode"&&r?.operation==="custom")?"Custom API":i[s]?.[a]}return a}return""},Are=e=>{switch(e?.node){case"not-configured-yet":return"ic_warning_circle";case"skipped":return"ic_skipped";case"failed":return"ic_error";case"completed":return"ic_success_small";default:return""}},gst=({nodeData:e})=>{const t=E.useTheme(),r=mst(e);return d.jsxs(E.Stack,{direction:"row",width:"100%",alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Tooltip,{title:r,arrow:!0,placement:"top",children:d.jsx(E.Typography,{variant:"smNormal",color:t.palette.text.tertiary,sx:{maxWidth:200,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r})}),!vt(Are(e.data?.blt_node_states))&&d.jsx(E.Stack,{direction:"row",sx:{cursor:"pointer",flexShrink:0},children:d.jsx(E.Tooltip,{arrow:!0,title:Ps(e.data?.blt_node_states?.node),children:d.jsx(Ue,{width:20,height:20,src:Are(e.data?.blt_node_states)})})})]})},FE=({id:e,nodeData:t,iconSrc:r,title:n,children:i,isTriggerNode:o,meta:s=null,proIntegration:a=!1,pro:l=!1})=>{const u=pt.useDispatch(),c=E.useTheme(),{setNodes:f,getNodes:p}=Rt.useReactFlow(),{activitiesPopover:h}=pt.useSelector(m=>m.canvas),A=C.useMemo(()=>r?oh(r,"t.resize(h:24,w:24)"):"",[r]),g=m=>{u({type:Au,payload:{id:m}})};return d.jsxs(E.Stack,{alignItems:"center",p:1.5,gap:1,onClick:m=>{m.stopPropagation(),!a&&(h.nodeId===t.id?u({type:ss,payload:{type:"",active:!1,nodeId:null}}):g(t.id))},sx:{cursor:a?"not-allowed":"pointer"},children:[d.jsxs(E.Stack,{direction:"row",overflow:a?"visible":"hidden",alignItems:"center",width:"100%",justifyContent:"space-between",flex:1,children:[d.jsx(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",flex:1,minWidth:0,display:"flex",alignItems:"center"},children:d.jsxs(E.Stack,{direction:"row",gap:1,alignItems:"center",flex:1,minWidth:0,overflow:"visible",children:[d.jsx(E.Stack,{sx:{...Qi},width:24,height:24,children:r?d.jsx("img",{src:A,alt:n,width:24,height:24,decoding:"async",style:{width:24,height:24,objectFit:"contain",display:"block"}}):d.jsx(E.Box,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.palette.grey.A400}`,borderRadius:1,background:c.palette.grey.A400,padding:.5,color:c.palette.common.white},children:n.slice(0,2).toUpperCase()})}),d.jsx(E.Tooltip,{arrow:!0,title:n,placement:"top",children:d.jsx(E.Typography,{sx:{maxWidth:148,...hu,lineHeight:"142%"},variant:"smSemiBold",color:c.palette.text.primary,children:n})}),l&&d.jsx(E.Box,{flexShrink:0,children:d.jsx(sf,{})})]})}),d.jsxs(E.Stack,{alignItems:"center",gap:1,flexShrink:0,justifyContent:"self-end",direction:"row",children:[d.jsxs(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",display:"flex",alignItems:"center",gap:1},children:[o&&(t.data.type===Ze.GMAIL_TRIGGER||s?.trigger_type===zO.SCHEDULED)&&d.jsx(E.Tooltip,{arrow:!0,title:"The trigger will check for new data in intervals.",children:d.jsx(E.Box,{display:"flex",alignItems:"center",children:d.jsx(E.IconButton,{sx:{p:0},children:d.jsx(Ue,{src:"ic_schedule",width:16,height:16,sx:{cursor:"pointer",path:{fill:c.palette.neutral.solid.bg}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:"Toggle Comment",children:d.jsx(E.IconButton,{onClick:m=>{if(a)return;m.stopPropagation(),m.preventDefault();const O=p().map(y=>y.id===e?{...y,data:{...y.data,activity_comment:{...y.data?.activity_comment,visible:!y.data?.activity_comment?.visible}}}:y);f(O)},sx:{p:0,...Ni(c)},children:d.jsx(Ue,{src:"ic_comment",width:16,height:16})})})]}),d.jsx(E.Box,{sx:{position:"relative",zIndex:1,opacity:1,flexShrink:0},children:i})]})]}),d.jsxs(E.Box,{sx:{width:"100%",opacity:a?.5:1,filter:a?"grayscale(1)":"none"},children:[d.jsx(E.Divider,{sx:{width:"100%"}}),d.jsx(E.Box,{sx:{pt:1},children:d.jsx(gst,{nodeData:t})})]})]})},Est=C.memo(e=>{const t=Rt.useNodes(),r=Rt.useEdges(),n=E.useTheme(),{canvasWorkflow:i,activityExecutionData:o,viewOnly:s,selectedActivityId:a}=pt.useSelector(H=>H.canvas),l=i?.meta?.isHorizontal??!0,u=Rt.useUpdateNodeInternals(),{setNodes:c}=Rt.useReactFlow(),{id:f,data:p,onHandleClick:h,handleDeleteNode:A,selected:g,pro_integration:m,onRunWithPrevious:O}=e,y=t.find(H=>H.id===a),{activities:T,triggers:v}=pt.useSelector(NE),_=Array.isArray(T)?T:[],x=Array.isArray(v)?v:[],b=ui(_,x,p,"pro"),w=!!b&&b!=="",R=w&&m===!1,I=o?.[p.name]?.loading??!1;let P=Array.isArray(p.properties?.branches)?p.properties.branches:[];(p.type===Ze.API||p.type===Ze.GRAPHQL)&&p.properties?.continue_on_failure===!1&&(P=P.filter(H=>H.ref==="success")),C.useEffect(()=>{u(f)},[f,P.length,p.properties?.continue_on_failure]),C.useEffect(()=>{c(H=>H.map(j=>{if(j.id===f){const X=R;if(j.draggable!==!X||j.selectable!==!X||j.connectable!==!X)return{...j,draggable:!X,selectable:!X,connectable:!X}}return j}))},[R,f,c]);const k=P.length+1,N=Math.max(k*16,84),L=H=>{const j=k-1,X=j*8,F=(j-1)*8,V=X+F,D=(N-V+4)/2+H*16,$=l?D:84;return isNaN($)?84:$},M=H=>{const j=k,X=k>4?260+32*(k-4):260,F=l?255:(H+1)*(X/j);return isNaN(F)?l?254:253:F},B=(H,j,X)=>{const F=p.type===Ze.API||p.type===Ze.GRAPHQL;return H===0?F?"success":"if":H===j-1?F?"failure":"else":X[H]?.ref||`branch_${H}`};return d.jsxs(E.Box,{position:"relative",className:"nowheel",onClick:H=>{if(R){H.stopPropagation();return}},sx:{cursor:R?"not-allowed":"default",pointerEvents:"auto",width:"100%",height:"100%"},children:[d.jsx(Rt.Handle,{type:"target",position:l?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:l?"50%":0,left:l?1:"50%",background:n.palette.common.white,border:`1px solid ${n.palette.neutral.main}`,opacity:R?.5:1},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:f,focused:y?.id===f||g,nodeData:e.data,actionBar:d.jsx(LE,{name:p.name,id:f,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:R,onRunWithPrevious:O}),sx:l?{height:N,minHeight:84,width:260}:{width:k>4?260+32*(k-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:f,nodeData:e,iconSrc:ui(_,x,p),title:p.name,running:I,proIntegration:R,pro:w})}),P.map((H,j)=>{const X=B(j,P.length,P),F=X==="failure"||X==="else";return d.jsx(vf,{type:"source",position:l?Rt.Position.Right:Rt.Position.Bottom,id:X,className:"sourceHandleStyle",style:{position:"absolute",top:L(j),left:M(j),transform:"translateY(-50%)",border:`1px solid ${F?n.palette.error[50]:n.palette.neutral.main}`,opacity:R?.5:1},isConnectable:!R,onClick:()=>{!s&&!R&&h(X,t,r,{top:l?L(j)-25.5:L(j)+48,left:l?M(j)+48:M(j)-25.5+3.5})},isValidConnection:V=>{const G=t.find(W=>V.source===W.id);if(!G||V.source===V.target||Ed(V.source,V.target,r))return!1;const $=r.filter(W=>W.type!==Hr.PLACEHOLDER);return!($.some(W=>G.id===W.source&&V.sourceHandle===W.sourceHandle)||$.some(W=>W.target===V.target&&W.source===V.source)||$.some(W=>W.target===V.target&&W.source!==V.source))}},`condition-branch-${j}`)})]})}),Ost=C.memo(e=>{const t=Rt.useNodes(),r=Rt.useEdges(),n=E.useTheme(),{isHorizontal:i,viewOnly:o,selectedActivityId:s}=pt.useSelector(dst),{activities:a,triggers:l}=pt.useSelector(NE),u=pt.useSelector(B=>cst(B,e.data.name)),c=Array.isArray(a)?a:[],f=Array.isArray(l)?l:[],p=Rt.useUpdateNodeInternals(),{id:h,data:A,selected:g,onHandleClick:m,handleDeleteNode:O,pro_integration:y,onRunWithPrevious:T}=e,v=ui(c,f,A,"pro"),_=!!v&&v!=="",x=_&&y===!1;C.useEffect(()=>{p(e.id)},[e.id,e.data?.properties?.continue_on_failure]);const b=C.useMemo(()=>t.find(B=>B.id===s),[t,s]),R=(Array.isArray(A?.properties?.branches)?A.properties.branches:[]).length+1,I=Math.max(R*16,84),N=(e.data.properties?.continue_on_failure===!0?2:1)+1,L=B=>{const H=N-1,j=H*8,X=(H-1)*8,F=j+X,G=(I-F+4)/2+B*16,D=i?G:86;return isNaN(D)?86:D},M=B=>{const j=i?255:(B+1)*(260/N);return isNaN(j)?255:j};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:x?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:i?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:o?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:i?"50%":0,left:i?1:"50%",background:n.palette.common.white,border:`1px solid ${n.palette.neutral.main}`},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:h,focused:b?.id===h||g,nodeData:e.data,actionBar:d.jsx(LE,{name:A.name,id:h,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:O,proIntegration:x,onRunWithPrevious:T}),sx:i?{height:I,minHeight:84,width:260}:{width:R>4?260+32*(R-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:h,nodeData:e,iconSrc:ui(c,f,A),title:A.name,running:u,proIntegration:x,pro:_})}),e.data.type!==Ze.RESPONSE&&d.jsx(vf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",onClick:()=>{!o&&!x&&m("outHandle",t,r,{top:i?L(0)-25.5:L(0)+48,left:i?M(0)+48:M(0)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:L(0),left:M(0),transform:"translateY(-50%)",border:`1px solid ${n.palette.neutral.main}`,opacity:x?.5:1},isValidConnection:B=>{const H=t.find(V=>B.source===V.id);if(B.source===B.target||Ed(B.source,B.target,r))return!1;const X=(H.outgoingPorts||[]).some(V=>!V.ref||V.ref!=="failure");return!r.some(V=>V.target===B.target&&V.type!==Hr.PLACEHOLDER)&&!X}}),e.data.properties?.continue_on_failure===!0&&d.jsx(vf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"failureHandle",onClick:()=>{!o&&!x&&m("failureHandle",t,r,{top:i?L(1)-25.5:L(1)+48,left:i?M(1)+48:M(1)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle failureHandle",style:{position:"absolute",top:L(1),left:M(1),transform:"translateY(-50%)",border:`1px solid ${n.palette.error.main}`,background:n.palette.error.light,opacity:x?.5:1},isValidConnection:B=>{if(!t.find(D=>B.source===D.id)||B.source===B.target||Ed(B.source,B.target,r))return!1;const X=r.filter(D=>D.type!==Hr.PLACEHOLDER);return!(X.some(D=>D.source===B.source&&D.target===B.target&&D.sourceHandle==="failureHandle")||X.some(D=>D.target===B.target&&D.source===B.source)||X.some(D=>D.target===B.target&&D.source!==B.source))}})]})}),yst=C.memo(e=>{const t=Rt.useNodes(),r=Rt.useEdges(),n=E.useTheme(),{activityExecutionData:i,canvasWorkflow:o,viewOnly:s,selectedActivityId:a}=pt.useSelector(B=>B.canvas),l=t.find(B=>B.id===a),u=Rt.useUpdateNodeInternals(),{id:c,data:f,selected:p,onHandleClick:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,{activities:O,triggers:y}=pt.useSelector(NE),T=Array.isArray(O)?O:[],v=Array.isArray(y)?y:[],_=ui(T,v,f,"pro"),x=!!_&&_!=="",b=x&&g===!1,w=o?.meta?.isHorizontal??!0,R=f.properties?.no_of_parallel_threads||0;C.useEffect(()=>{u(c)},[c,R]);const I=i?.[f.name]?.loading??!1,P=B=>`parallel_${B}`,k=R+1,N=Math.max(k*16,84),L=B=>{const H=k-1,j=H*8,X=(H-1)*8,F=j+X,G=(N-F+4)/2+B*16,D=w?G:86;return isNaN(D)?86:D},M=B=>{const H=R+1,j=R>5?260+32*(R-4):260,X=w?255:(B+1)*(j/H);return isNaN(X)?255:X};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:b?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:w?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!b,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:w?"50%":0,left:w?1:"50%",background:n.palette.common.white,border:`1px solid ${n.palette.neutral.main}`,opacity:b?.5:1},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:c,focused:l?.id===c||p,nodeData:e.data,actionBar:d.jsx(LE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:b,onRunWithPrevious:m}),sx:w?{height:`${N}px`,minHeight:84,width:260}:{width:R>5?260+32*(R-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:c,nodeData:e,iconSrc:ui(T,v,f),title:f.name,running:I,proIntegration:b,pro:x})}),[...Array(R)].map((B,H)=>d.jsx(vf,{type:"source",position:w?Rt.Position.Right:Rt.Position.Bottom,id:P(H),isConnectable:!0,className:"sourceHandleStyle",style:{top:L(H),left:M(H),transform:"translateY(-50%)",border:`1px solid ${n.palette.neutral.main}`,opacity:b?.5:1},isValidConnection:j=>{const X=t.find(U=>j.source===U.id);if(!X||j.source===j.target||Ed(j.source,j.target,r))return!1;const V=r.filter(U=>U.type!==Hr.PLACEHOLDER);return!(V.some(U=>X.id===U.source&&j.sourceHandle===U.sourceHandle)||V.some(U=>U.target===j.target&&U.source===j.source)||V.some(U=>U.target===j.target&&U.source!==j.source))},onClick:()=>{!s&&!b&&h(P(H),t,r,{top:w?L(H)-25.5:L(H)+48,left:w?M(H)+48:M(H)-25.5+3.5})}},`parallel-thread-${H}`))]})}),mre=({id:e,overlayProps:t,allowDrag:r=!1,hideTargetHandle:n=!1})=>{const i=E.useTheme(),o=Rt.useUpdateNodeInternals(),{canvasWorkflow:s}=pt.useSelector(l=>l.canvas),a=s?.meta?.isHorizontal??!0;return C.useEffect(()=>{e&&o(e)},[e,o]),d.jsxs("div",{style:{pointerEvents:"auto"},children:[!n&&d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:a?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:"targetHandleStyle",style:{top:a?"50%":0,left:a?0:"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}}),d.jsx(Gde,{open:!0,variant:"inline",draggable:!1,...t}),d.jsx(Rt.Handle,{type:"source",id:"outHandle",position:a?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!1,className:"sourceHandleStyle",style:{top:a?"50%":"100%",left:a?"100%":"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}})]})},vst=e=>{const{handle:t,tooltip:r,toggleListing:n,id:i}=e,o=E.useTheme(),{selectedPlaceholderId:s}=pt.useSelector(a=>a.canvas);return d.jsx(E.Box,{className:"nowheel",sx:{position:"relative",width:51,...s===i&&{"& .MuiButtonBase-root.MuiButton-root":{borderColor:o.palette.primary.main}}},children:d.jsx(E.Tooltip,{arrow:!0,title:r,disableInteractive:!0,children:d.jsxs("span",{children:[d.jsx(E.Button,{sx:{minWidth:50,width:51,height:51,border:`1px solid ${o.palette.grey.outlined.border}`,backgroundColor:o.palette.common.white,"& svg":{width:20,height:20},"&:hover":{backgroundColor:o.palette.common.white,transform:"none"}},onClick:n,children:d.jsx(Ue,{width:24,height:24,src:"ic_add_circle_outlined",sx:{path:{fill:o.palette.primary.main}}})}),t]})})})},Tst=e=>{const{handle:t,toggleListing:r,id:n}=e,i=E.useTheme(),{selectedPlaceholderId:o}=pt.useSelector(s=>s.canvas);return d.jsx(E.Box,{className:"nowheel",children:d.jsxs(E.Stack,{p:1.5,alignItems:"flex-start",border:`1px dashed ${i.palette.neutral.solid.bg}`,borderRadius:2,onClick:r,sx:{backgroundColor:i.palette.common.white,width:260,height:84,...o===n&&{borderColor:i.palette.primary.main}},children:[d.jsxs(E.Stack,{gap:1,width:"100%",children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1,children:[d.jsx(Ue,{src:"ic_spark",width:24,height:24,sx:{path:{fill:i.palette.primary.main}}}),d.jsx(E.Stack,{direction:"row",gap:.5,children:d.jsx(E.Typography,{variant:"smMedium",lineHeight:1,children:"Choose trigger"})})]}),d.jsx(E.Divider,{}),d.jsx(E.Typography,{variant:"smNormal",color:i.palette.text.tertiary,children:"Select an event"})]}),t]})})},Sst=({id:e,data:t,onHandleClick:r})=>{const{isTriggerPlaceholder:n}=t,i=E.useTheme(),o=Rt.useNodes(),s=Rt.useEdges(),{ENTITY_ID:a,allowedAccount:l}=Ii(),u=pt.useDispatch(),{activitiesPopover:c,viewOnly:f,canvasWorkflow:p,selectedActivityId:h}=pt.useSelector(O=>O.canvas),A=RE(a,l),g=p?.meta?.isHorizontal??!0,m=O=>{if(f)return;if(h&&u({type:Ad,payload:null}),u({type:C0,payload:e}),c?.active&&u({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),n&&!A){u({type:ss,payload:{type:"triggers",active:!0,nodeId:e,edgeId:null}}),u({type:ea,payload:!0});return}if(!A){u({type:ss,payload:{type:"activities",active:!0,nodeId:e,edgeId:null}}),u({type:ea,payload:!0});return}const y=O?.currentTarget?.getBoundingClientRect?.()??O?.target?.getBoundingClientRect?.();y&&Number.isFinite(y.left)&&Number.isFinite(y.top)?u({type:Zp,payload:{x:y.left+y.width/2,y:y.top+y.height/2}}):O?.clientX&&O?.clientY&&u({type:Zp,payload:{x:O.clientX,y:O.clientY}}),u({type:w0,payload:!1}),u({type:Ns,payload:"prompt"}),u({type:_0,payload:!0})};return n?d.jsx(Tst,{id:e,handle:d.jsx(vf,{type:"source",id:"outHandle",position:g?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!0,className:"sourceHandleStyle",style:{...g?{top:45,left:255,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${i.palette.neutral.main}`},isValidConnection:O=>{if(!o.find(b=>O.source===b.id)||O.source===O.target||Ed(O.source,O.target,s))return!1;const v=s.filter(b=>b.type!==Hr.PLACEHOLDER);return!(v.some(b=>b.target===O.target&&b.source!==O.source)||v.some(b=>b.source===O.source))},onClick:O=>{O.stopPropagation(),!f&&r("outHandle",o,s,{top:g?42-25.5+2:132,left:g?308:130-25.5})}}),toggleListing:m}):d.jsx(vst,{id:e,handle:d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:g?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:f?"viewModeCursor":"",style:{position:"absolute",background:"transparent",border:"none",left:g?0:"50%",top:g?"50%":0,transform:g?"translateY(-50%)":"translateX(-50%)"}}),tooltip:"Click here to add action",toggleListing:m})},xst=C.memo(e=>{const{canvasWorkflow:t,activityExecutionData:r,viewOnly:n,selectedActivityId:i}=pt.useSelector(L=>L.canvas),o=t?.meta?.isHorizontal??!0,s=Rt.useNodes(),a=Rt.useEdges(),l=E.useTheme(),u=Rt.useUpdateNodeInternals(),{id:c,data:f,onHandleClick:p,selected:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,O=s.find(L=>L.id===i),y=(f.properties?.cases?.length||0)+1;C.useEffect(()=>{u(c)},[c,f.properties?.cases?.length,u]);const T=r?.[f.name]?.loading??!1,{activities:v,triggers:_}=pt.useSelector(NE),x=Array.isArray(v)?v:[],b=Array.isArray(_)?_:[],w=ui(x,b,f,"pro"),R=!!w&&w!=="",I=R&&g===!1,P=Math.max(y*16,84),k=L=>o?y===1?P/2:P/(y+1)*(L+1):84,N=L=>{const M=y+1,B=y>4?260+32*(y-5):260;return o?o?254:253:(L+1)*(B/M)};return d.jsxs(E.Stack,{direction:o?"row":"column",alignItems:"center",position:"relative",className:"nowheel",sx:{cursor:I?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:o?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:n?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:o?"50%":0,left:o?1:"50%",background:l.palette.common.white,border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:c,focused:O?.id===c||h,nodeData:e.data,actionBar:d.jsx(LE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:I,onRunWithPrevious:m}),sx:o?{height:`${P}px`,minHeight:84,width:260}:{width:y>4?260+32*(y-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:c,nodeData:e,running:T,iconSrc:ui(x,b,f),title:f.name,proIntegration:I,pro:R})}),d.jsxs(E.Stack,{gap:o?.5:2,direction:o?"column":"row",children:[(f.properties?.cases||[]).map((L,M)=>{const B=k(M),H=N(M);return d.jsx(vf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:`${L.caseKey}`,isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${B}px`,left:`${H}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},onClick:()=>{if(!n&&!I&&p){const j=k(M),X=N(M);p(L.caseKey,s,a,{top:o?j-25.5:j+48,left:o?X+48:X-25.5+3.5})}},isValidConnection:j=>{const X=s.find(U=>j.source===U.id);if(!X||j.source===j.target||Ed(j.source,j.target,a))return!1;const V=a.filter(U=>U.type!==Hr.PLACEHOLDER);return!(V.some(U=>X.id===U.source&&j.sourceHandle===U.sourceHandle)||V.some(U=>U.target===j.target&&U.source===j.source)||V.some(U=>U.target===j.target&&U.source!==j.source))}},`${L.caseKey}-${M}`)}),d.jsx(vf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:"defaultHandle",isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${k(f.properties?.cases?.length||0)}px`,left:`${N(f.properties?.cases?.length||0)}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.error[50]}`,opacity:I?.5:1},onClick:()=>{if(!n&&!I&&p){const L=f.properties?.cases?.length||0,M=k(L),B=N(L);p("defaultHandle",s,a,{top:o?M-25.5:M+48,left:o?B+48:B-25.5+3.5})}},isValidConnection:L=>{const M=s.find(V=>L.source===V.id);if(!M||L.source===L.target||Ed(L.source,L.target,a))return!1;const H=a.filter(V=>V.type!==Hr.PLACEHOLDER);return!(H.some(V=>M.id===V.source&&L.sourceHandle===V.sourceHandle)||H.some(V=>V.target===L.target&&V.source===L.source)||H.some(V=>V.target===L.target&&V.source!==L.source))}},"defaultHandle")]})]})}),bst=C.memo(e=>{const{id:t,data:r,selected:n,onHandleClick:i,VORTEX_MAIN_URL:o,ENTITY_ID:s,handleDeleteNode:a,currentSubscription:l,pro_integration:u}=e,c=bn(Dr.VERSION),f=_o(),p=bn(f),h=pt.useDispatch(),A=E.useTheme(),{analytics:g}=Ii(),m=Rt.useNodes(),O=Rt.useEdges(),{workflow:y}=pt.useSelector(U=>U.workflows),{canvasWorkflow:T,activityExecutionData:v,viewOnly:_,showDebugLogs:x,selectedActivityId:b}=pt.useSelector(U=>U.canvas),w=m.find(U=>U.id===b),R=T?.meta?.isHorizontal??!0,I=m?.find(U=>U?.type===xt.TRIGGER),{activities:P,triggers:k}=pt.useSelector(NE),N=Array.isArray(P)?P:[],L=Array.isArray(k)?k:[],M=ui(N,L,r,"pro"),B=!!M&&M!=="",H=B&&u===!1,[j,X]=C.useState(!1),F=v?.[r.name]?.loading??!1,V=I?.data?.type,D=(Array.isArray(r?.properties?.branches)?r.properties.branches:[]).length+1,$=Math.max(D*16,84);return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:H?"not-allowed":"default",pointerEvents:"auto"},children:[p&&I&&V!==Ze.HTTP&&d.jsx(E.Tooltip,{arrow:!0,title:l?.workflowExecution?.remaining<=0?"You cannot execute this workflow as you have reached execution limit.":l[0]?.status==="EXPIRED"?"You cannot execute this workflow as your subscription has expired.":l[0]?.status==="CANCELLED"?"You cannot execute this workflow as your subscription has been cancelled.":"Run Workflow",children:d.jsx(E.Box,{sx:{display:"inline-flex",position:"absolute",top:28,left:-44},children:d.jsx(E.IconButton,{color:"primary",sx:{width:32,height:32,color:U=>U.palette.primary.main,opacity:l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED"?.3:1,cursor:"pointer",backgroundColor:A.palette.common.white,border:`1px solid ${b||j?A.palette.neutral.outlined.border:A.palette.primary.main}`,"&:hover":{backgroundColor:A.palette.common.white}},onClick:async()=>{if(I)if(I0(I,m)){const q=vt(c)?p:c;X(!0),await W6(y,q,[I],h,o,s,c,p,x,g),X(!1)}else h({type:Xr,payload:{open:!0,title:"Please complete all activities configurations to execute this workflow",type:"error"}})},disabled:!!b||j||l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED",children:j?d.jsx(E.CircularProgress,{sx:{color:A.palette.grey.normal},size:16}):d.jsx(Ue,{src:"ic_run",sx:{path:{fill:b?"currentColor":A.palette.primary.main}}})})})}),d.jsx(kE,{focused:w?.id===t||n,id:t,nodeData:e.data,actionBar:d.jsx(LE,{name:r.name,id:t,isTriggerNode:!0,nodeData:e.data,handleDeleteNode:a,proIntegration:H}),sx:R?{height:$,minHeight:84,width:260}:{width:D>4?260+32*(D-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:t,nodeData:e,iconSrc:ui(N,L,r),title:r.name,running:F,isTriggerNode:!0,meta:ui(N,L,r,"meta"),proIntegration:H,pro:B})}),d.jsx(vf,{type:"source",onClick:()=>{!_&&!H&&i("outHandle",m,O,{top:R?42-25.5:132,left:R?308:130-25.5})},position:R?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",isConnectable:!0,className:"sourceHandleStyle",style:{...R?{top:"50%",left:256,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${A.palette.neutral.main}`,opacity:H?.5:1},isValidConnection:U=>{if(!m.find(J=>U.source===J.id)||U.source===U.target||Ed(U.source,U.target,O))return!1;const W=O.filter(J=>J.type!==Hr.PLACEHOLDER);return!(W.some(J=>J.target===U.target&&J.source!==U.source)||W.some(J=>J.source===U.source))}})]})}),Cst=(e,t,r,n,i)=>{const o=E.useTheme(),s=Rt.useNodes(),a=Rt.useEdges(),l=pt.useDispatch(),u=bn(),{analytics:c,ENTITY_ID:f,WORKFLOW_URLS:p}=Ii(),{activity_names:h}=pt.useSelector(I=>I.activities),{selectedPlaceholderId:A}=pt.useSelector(I=>I.canvas),g=(I,P)=>[...I,P],{captureEvent:m,WORKFLOW_EVENTS:O}=c||{},y=C.useCallback(I=>{I.preventDefault(),A&&l({type:Kp,payload:null});const P=JSON.parse(I.dataTransfer.getData("application/reactflow")),{currentNodeId:k,parentNodeId:N,isTrigger:L}=P,M=s.find(U=>U.id===k);let B=k||Na(P?.name||"node",s);if(P.openingFromPlaceholder){typeof k=="string"&&k.startsWith("placeholder_")&&!M&&(B=Na(P?.name||"node",s)),M?.type===xt.PLACEHOLDER&&(B=Na(P?.name||"node",s));const U=l1(I,P,e,B,s,u,i,N?[N]:[],{x:M?.position?.x,y:(M?.position?.y||0)-16});XC(l,U,L,N,M,k,h,n,r,s,a,m,O,f||"",u||void 0,p?.VORTEX_MAIN_URL);return}if(s.some(U=>U.type===xt.TRIGGER)&&L){l({type:Xr,payload:{open:!0,title:"Only one trigger is allowed",type:"error"}});return}l({type:Ad,payload:null});const j=s.find(U=>U.type===xt.PLACEHOLDER&&U.data?.isTriggerPlaceholder),X=j?.id,F=s.filter(U=>U.type!==xt.TRIGGER),V=Na(P?.name||"trigger",F),G=P.type===xt.TRIGGER&&j?.position?j.position:null,D=l1(I,P,e,P.type===xt.TRIGGER?V:B,s,u,i,[],G);l({type:"SET_ACTIVITY_NAMES",payload:[...h,D.data.name]}),t(),l({type:ea,payload:!1});const $=s.filter(U=>U.type!==xt.PLACEHOLDER&&U.type!==xt.TRIGGER);if(u&&$.length===0&&D.type!==xt.TRIGGER&&!P.openingFromPlaceholder){const U=s.find(q=>q.type===xt.TRIGGER||q?.data?.isTriggerPlaceholder);if(U){const q={source:U.id,sourceHandle:"outHandle",target:D.id,targetHandle:"targetHandle",type:U.type===Hr.PLACEHOLDER?Hr.PLACEHOLDER:Hr.SMOOTH},z=[...s,D];m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:D?.data?.properties?.integration_slug,name:D?.data?.name}),T(q,z,a)}}else{let U;j&&D.type===xt.TRIGGER?U=s.map(q=>q.type===xt.PLACEHOLDER&&q.data?.isTriggerPlaceholder?D:q):U=g(s,D),j&&X&&X!==D.id&&D.type===xt.TRIGGER&&(U=U.map(q=>{if(Array.isArray(q.incomingPorts)&&q.incomingPorts.includes(X))return{...q,incomingPorts:q.incomingPorts.map(z=>z===X?D.id:z)};if(q.id===D.id&&j.outgoingPorts){const z=j.outgoingPorts.map(W=>{const Q=U.find(Y=>Array.isArray(Y.incomingPorts)&&Y.incomingPorts.includes(X));return Q?{...W,id:Q.id}:W});return{...q,outgoingPorts:z}}return q}),n(q=>(q||a).map(z=>({...z,source:z.source===X?D.id:z.source,target:z.target===X?D.id:z.target})))),m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:D?.data?.properties?.integration_slug,name:D?.data?.name}),r(U)}l({type:Au,payload:{id:D.id}})},[s,a,l,e,u,i,h,n,r,m,O,f,p?.VORTEX_MAIN_URL,o]),T=C.useCallback((I,P,k)=>{const N={...I,type:"smooth",id:K4(k||a),markerEnd:{type:Rt.MarkerType.ArrowClosed,color:w4(I,o)}};t();const L=Mo(P||s).map(M=>{if(M.id===I.source){const B=(P||s).find(H=>H.id===I.target);I.sourceHandle==="failureHandle"?M.outgoingPorts.push({id:B?.id,ref:"failure",name:B?.data.name}):I.sourceHandle!=="outHandle"?M.outgoingPorts.push({id:B?.id,ref:I.sourceHandle,name:B?.data.name}):M.outgoingPorts.push({id:B?.id,name:B?.data.name})}if(M.id===I.target){const B=(P||s).find(H=>H.id===I.source);M.incomingPorts.push(B?.id)}return M});r(L),n(Rt.addEdge(N,k||a)),t()},[s,a,r,n,o,t]),v=C.useCallback(()=>{t()},[t]),_=C.useCallback((I,P)=>{r(k=>{const N=!!(I&&(I.shiftKey||I.metaKey||I.ctrlKey)),L=k.reduce((M,B)=>{const H=B.zIndex??0;return H>M?H:M},0)||0;return k.map(M=>M.id===P.id?{...M,zIndex:L+1,style:{...M.style||{},zIndex:L+1},...N?{}:{selected:!0}}:N?M:{...M,selected:!1})}),t()},[r,t]),x=C.useCallback(I=>{I&&I.length>0&&r(P=>{let k=[...P];return I.forEach(N=>{const L=N.target,M=N.source;k=k.map(B=>{if(B.id===L){const{data:H,...j}=B,{ref:X,...F}=H;return{...j,data:F,incomingPorts:(B.incomingPorts||[]).filter(V=>V!==M)}}return B.id===M?{...B,outgoingPorts:(B.outgoingPorts||[]).filter(H=>H.id!==L)}:B})}),k}),t()},[r,t]),b=C.useCallback(()=>{s.find(P=>P.selected)&&r(P=>P.map(k=>({...k,selected:!1}))),t()},[s,r]),w=C.useCallback(I=>{I.shiftKey&&I.preventDefault()},[]),R=C.useCallback(I=>{const{nodes:P}=I,k=a||[],N=s||[];if(!Array.isArray(P)||P.length===0){t();return}P.forEach(W=>{W.type!==xt.PLACEHOLDER&&l({type:d4,payload:{id:W.id}})});const L=P.map(W=>W.id),M=new Set(L),B=k.filter(W=>M.has(W.source)||M.has(W.target)),H=new Set;B.forEach(W=>{const Q=N.find(J=>J.id===W.source),Y=N.find(J=>J.id===W.target);Q?.type===xt.PLACEHOLDER&&!M.has(Q.id)&&H.add(Q.id),Y?.type===xt.PLACEHOLDER&&!M.has(Y.id)&&H.add(Y.id)}),N.forEach(W=>{if(W?.type!==xt.PLACEHOLDER)return;const Q=Array.isArray(W.incomingPorts)&&W.incomingPorts.some(J=>M.has(J)),Y=Array.isArray(W.outgoingPorts)&&W.outgoingPorts.some(J=>M.has(J?.id));(Q||Y)&&H.add(W.id)});const j=[];P.forEach(W=>{if(W.type===xt.TRIGGER||W.type===xt.PLACEHOLDER)return;if(!(W.outgoingPorts&&W.outgoingPorts.length>1||W.data?.properties?.continue_on_failure===!0||W.data?.properties?.cases&&W.data.properties.cases.length>0||W.data?.properties?.branches&&W.data.properties.branches.length>1)){const Y=B.filter(ee=>ee.target===W.id&&ee.type!==Hr.PLACEHOLDER),J=B.filter(ee=>ee.source===W.id&&ee.type!==Hr.PLACEHOLDER);if(Y.length===1&&J.length===1){const ee=Y[0].source,le=J[0].target;if(M.has(ee)||M.has(le)||H.has(ee)||H.has(le))return;j.push({sourceNodeId:ee,targetNodeId:le,sourceHandle:Y[0].sourceHandle||"outHandle",targetHandle:J[0].targetHandle||"targetHandle"})}}});let X=N.filter(W=>!(M.has(W.id)||H.has(W.id)));const F=P.find(W=>W.type===xt.TRIGGER);if(F){const W=_4(),Q=Na("trigger-placeholder",X);X=[{...W,id:Q,position:F.position},...X]}const V=new Set(X.map(W=>W.id));let G=k.filter(W=>V.has(W.source)&&V.has(W.target));j.length>0&&j.forEach(({sourceNodeId:W,targetNodeId:Q,sourceHandle:Y,targetHandle:J})=>{if(!V.has(W)||!V.has(Q)||G.some(ne=>ne.source===W&&ne.target===Q&&(ne.sourceHandle||"outHandle")===(Y||"outHandle")&&(ne.targetHandle||"targetHandle")===(J||"targetHandle")&&ne.type!==Hr.PLACEHOLDER))return;const le={id:K4(G),source:W,sourceHandle:Y,target:Q,targetHandle:J,type:Hr.SMOOTH,markerEnd:{type:Rt.MarkerType.ArrowClosed,color:w4({sourceHandle:Y},o)}};G=Rt.addEdge(le,G)});const D=new Map;X.forEach(W=>D.set(W.id,W?.data?.name));const $=new Map,U=new Map;(G||[]).filter(W=>W.type!==Hr.PLACEHOLDER).forEach(W=>{if(!V.has(W.source)||!V.has(W.target))return;const Q=$.get(W.target)||new Set;Q.add(W.source),$.set(W.target,Q);const Y=W.sourceHandle==="failureHandle"?"failure":W.sourceHandle&&W.sourceHandle!=="outHandle"?W.sourceHandle:void 0,J=U.get(W.source)||[];J.push({id:W.target,name:D.get(W.target),...Y?{ref:Y}:{}}),U.set(W.source,J)});const z=X.map(W=>{const Q=Array.from($.get(W.id)||[]),Y=U.get(W.id)||[],J=new Set,ee=Y.filter(ve=>{const oe=`${ve?.id||""}::${ve?.ref||""}`;return J.has(oe)?!1:(J.add(oe),!0)}),{data:le,...ne}=W,{ref:ue,...Oe}=le||{};return{...ne,data:Oe,incomingPorts:Q,outgoingPorts:ee}});n(G),r(z),t()},[s,a,r,n,t,l,o]);return{onDrop:y,onConnect:T,onSelectionDragStart:v,onEdgesDelete:x,onPaneClick:b,onMouseDown:w,onDelete:R,onNodeDragStart:_}},U8={maxHistorySize:25,enableShortcuts:!0},_st=({maxHistorySize:e=U8.maxHistorySize,enableShortcuts:t=U8.enableShortcuts}=U8)=>{const{getNodes:r,getEdges:n,setNodes:i,setEdges:o}=Rt.useReactFlow(),{selectedActivityId:s}=pt.useSelector(y=>y.canvas),a=r(),l=n(),[u,c]=C.useState([]),[f,p]=C.useState([]),h=C.useCallback(()=>{c(y=>{const T=y[y.length-1];return T&&T.nodes===a&&T.edges===l?y:[...y.slice(-e+1),{nodes:a,edges:l}]}),p([])},[a,l,e]),A=()=>{c([]),p([])},g=C.useCallback((y,T,v,_)=>{if(s)return;const x=y[y.length-1];if(x){const b=y.slice(0,-1),w=[...T,{nodes:a,edges:l}];v(b),_(w),i(x.nodes),o(x.edges)}},[i,o,a,l]),m=C.useCallback(()=>g(u,f,c,p),[u,f,g]),O=C.useCallback(()=>g(f,u,p,c),[u,f,g]);return C.useEffect(()=>{if(!t)return;const y=T=>{T.key==="z"&&(T.ctrlKey||T.metaKey)&&T.shiftKey?O():T.key==="z"&&(T.ctrlKey||T.metaKey)&&m()};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[m,O,t]),{undo:m,redo:O,takeSnapshot:h,clearSnapshot:A,canUndo:!u.length,canRedo:!f.length}},wst=({open:e})=>{const t=pf();return e?d.jsxs(E.Stack,{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center",spacing:1,sx:{backgroundColor:Za(t.palette.common.white,.75),pointerEvents:"auto",zIndex:t.zIndex.modal},children:[d.jsx(Oi,{size:32}),d.jsx(E.Typography,{variant:"smNormal",sx:{color:"text.secondary"},children:"Arranging automation canvas..."})]}):null},ME=["When a new message is posted in Slack","When a new email is received in Gmail","When a webhook is received"],gre=["Send email via Gmail","Post to Slack channel","Make API call"],Ist=new Set(["maximum_timeout","continue_on_failure","retry_config.maximum_timeout","retry_config.maximum_attempts","retry_config.backoff_coefficient","retry_config.initial_interval","retry_config.maximum_interval"]),Dst=e=>{const t=String(e||"").trim();return!!(!t||Ist.has(t))},Ere=(e,t,r="")=>{if(!e||typeof e!="object")return{};const n={},i=Object.entries(e);for(const[o,s]of i){const a=String(o),l=r?`${r}.${a}`:a;if(!t(l)&&!(s==null||s==="")){if(Array.isArray(s)){s.length>0&&(n[l]=s);continue}if(typeof s=="object"){Object.assign(n,Ere(s,t,l));continue}n[l]=s}}return n},Ore=e=>e==="prompt"||e==="error"||e===void 0,yre=({promptKind:e,mode:t,promptValue:r,onPromptChange:n,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f,setChoice:p,onContinueChoice:h,auth:A,setAuth:g,onContinueAuth:m,parameters:O,setParameters:y,onContinueParameters:T,inferTesseractEntity:v,ENTITY_ID:_,WORKFLOW_URLS:x,openIntegrationDrawer:b,onAddNewAccount:w,vortexMainUrl:R})=>({promptKind:e,mode:t,promptValue:r,onPromptChange:n,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f?{label:f.label,options:f.options,selected:f.selected,multiSelect:f.multiSelect,selectedMultiple:f.selectedMultiple,onSelect:I=>p(P=>P&&{...P,selected:I}),onSelectMultiple:I=>p(P=>P&&{...P,selectedMultiple:I}),onContinue:h,continueDisabled:f.multiSelect?!(f.selectedMultiple&&f.selectedMultiple.length>0):!f.selected}:null,auth:A?{label:A.label,options:A.options,selected:A.selected,loading:A.loading,errorText:A.errorText,onSelect:I=>g(P=>P&&{...P,selected:I}),onContinue:m,continueDisabled:A.loading||!A.selected,addNewAccount:{type:v(A.integration_slug,A.field_name),ENTITY_ID:String(_||""),FRONTEND_URL:String(x?.FRONTEND_URL??""),TESSERACT_MAIN_URL:String(x?.TESSERACT_MAIN_URL??""),openIntegrationDrawer:b,onClick:w}}:null,parameters:O?{integrationName:O.integrationName,fields:O.fields,values:O.values,resolvedAuth:O.resolvedAuth,entityId:O.entityId,onValuesChange:I=>y(P=>P&&{...P,values:I}),onContinue:I=>T(I),continueDisabled:O.fields.some(I=>{const P=String(I.name??""),k=O.values[P];return I.required&&(k==null||String(k).trim()==="")})}:null,vortexMainUrl:R,workflowUrls:x});async function Rst(e){const{baseUrl:t,body:r,signal:n,onMessage:i}=e;let o="",s=0;const a=f=>{const p=f.split(`
687
+ `)}),Ke.clipboardData.setData("text/plain",nt)},[_e]),kt=C.useCallback(function(){te(!0)},[te]),Gt=C.useCallback(function(){te(!1)},[te]),St=C.useCallback(function(Ke){var Ge=Ke.element,nt=!1;if(Ge.type==="chip"&&_e.selection)try{var Et=ir.findPath(_e,Ge),yt=_e.selection;if(yt&&!Yt.isCollapsed(yt)){var Dt=Yt.edges(yt),we=Dt[0],Qe=Dt[1],Je={path:Et,offset:0};nt=ht.compare(Je.path,we.path)>=0&&ht.compare(Je.path,Qe.path)<=0}}catch{nt=!1}switch(Ge.type){case"chip":return C.createElement(got,Object.assign({},Ke,{suggestion:Ge.suggestion,onDelete:function(){return!Q&&!T&&!_&&dt(Ge.suggestion.id)},isSelected:nt}));case"paragraph":return C.createElement(Oot,Object.assign({},Ke,{size:M}));default:return C.createElement(Eot,Object.assign({},Ke,{size:M}))}},[dt,M,_e]),je=C.useCallback(function(){try{var Ke=_e.children[0],Ge=_e.children.length===1&&Zi.isElement(Ke)&&Ke.children.length===1&&"text"in Ke.children[0]&&Ke.children[0].text==="";return Ge?"100%":"auto"}catch{return"auto"}},[_e]);return C.createElement(E.FormControl,{className:"meta-form-control "+u,sx:{width:"100%",maxWidth:"100%",position:"relative"},fullWidth:!0,key:o,ref:et},(f||H)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:X},C.createElement(Qo,{className:"meta-select-label",required:P,description:O,label:f}),C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:4,color:"neutral.80"},H)),C.createElement(E.Paper,{elevation:0,sx:ar(ar(ar(ar(ar({border:"1px solid "+(he&&$e?dn.error.main:dn.neutral.outlined.border),":hover":{borderColor:dn.text.primary}},Z&&{border:"1px solid "+Ye.palette.primary.main,":hover":{borderColor:Q||T||_?dn.text.secondary:Ye.palette.primary.main}}),{},{display:"flex"},(Q||T||_)&&st&&{opacity:.4}),(Q||T||_)&&{cursor:"not-allowed"}),{},{justifyContent:"center",gap:"1rem"},fot[M]),M!=="xs"&&D&&{resize:"vertical",overflowY:"auto",position:"relative","&::after":{content:'""',display:"block",position:"absolute",width:"18px",height:"18px",bottom:"2px",right:"2px",cursor:"nwse-resize",backgroundImage:"linear-gradient(135deg, transparent 0px, transparent 3px, "+Ye.palette.grey[500]+" 3px, "+Ye.palette.grey[500]+" 4px,)",pointerEvents:"none"}})},C.createElement(E.Box,{sx:ar(ar(ar(ar({flex:1,overflow:"auto"},M==="xs"&&{overflowX:"auto",overflowY:"hidden","-ms-overflow-style":"none","scrollbar-width":"none"}),D&&M!=="xs"?{height:"100%"}:{maxHeight:pot[M]}),{},{"&::-webkit-scrollbar":{display:"none"},'& [data-slate-node="text"]':{minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative",marginRight:"6px",width:je}},M==="xs"&&{"&::-webkit-scrollbar":{display:"none"},'& [data-testid="paragraph-element"]::-webkit-scrollbar':{display:"none"}}),{},{'& [data-slate-node="text"]:empty::before, & [data-slate-zero-width="n"]::before':{content:'""',display:"inline-block",minWidth:"1px",minHeight:"16px",position:"relative"},'& [data-slate-placeholder="true"] [data-slate-node="text"]:empty::before, & [data-slate-placeholder="true"] [data-slate-zero-width="n"]::before':{display:"none !important"},'& [data-testid="paragraph-element"]':{marginBottom:M==="xs"?"0":"1px"},'& [data-testid="paragraph-element"]:not(:last-child)':{marginBottom:M==="xs"?"0":"2px"}})},C.createElement(ws,{name:o,control:U,rules:vt($)?{}:ar(ar({},$),{},{validate:function(Ge){return/^\s*$/.test(Ge)&&P?"Field cannot consist solely of spaces. Please include some characters.":Ge&&h==="url"?vx(Ge)?!0:"Enter a valid URL":Ge&&h==="email"?Tx(Ge)?!0:"Enter a valid email":!0}}),render:function(Ge){var nt=Ge.field,Et=nt.onChange,yt=el(nt,Aot);return C.createElement(H7,Object.assign({editor:_e,initialValue:Te,onChange:function(we){return He(Et,we)}},yt),C.createElement(j7,Object.assign({id:ae,renderElement:St,onKeyDown:Tt,onPaste:ct,onClick:function(we){return!Q&&!T&&!_&&oe(we.currentTarget)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",onCopy:rt,"data-testid":"suggestion-input-"+o,placeholder:b,readOnly:Q||T||_,style:ar({outline:"none",wordWrap:M==="xs"?"normal":"break-word",whiteSpace:M==="xs"?"pre":"pre-wrap",overflowWrap:M==="xs"?"normal":"break-word",fontWeight:500,fontSize:14,lineHeight:"20px",fontFamily:"Inter"},T&&{opacity:.45}),onFocus:kt,onBlur:Gt},ue)))}})),V&&!Q&&!T&&C.createElement(E.IconButton,{size:"small",onClick:function(Ge){return oe(function(nt){return nt?null:Ge.currentTarget})},"data-testid":"add-suggestion-btn",title:"Click to add dynamic values",sx:ar({height:"1rem",width:"1rem",alignItems:"center",justifyContent:"center",padding:"0.5rem",border:"1px solid "+dn.neutral.outlined.border,borderRadius:"0.25rem"},M==="xs"&&{":hover":{backgroundColor:"transparent"}})},C.createElement(zr,{src:"ic_plus",width:16,height:16}))),C.createElement(E.Stack,null,he&&$e&&C.createElement(E.FormHelperText,{component:"span",error:!0,dangerouslySetInnerHTML:{__html:xo($e)}})),C.createElement(qte,{anchorEl:ve,setAnchorEl:oe,handleSuggestionClick:lt,suggestionsData:z,ref:et,handleCustom:ne,isLoading:le}))},got=function(t){var r=t.attributes,n=t.children,i=t.suggestion,o=t.onDelete,s=t.isSelected,a=function(u){u.stopPropagation(),u.preventDefault(),o()};return C.createElement("span",Object.assign({},r,{contentEditable:!1,"data-testid":i?.label+"-chip",style:{display:"inline",marginRight:4}}),C.createElement(dot,{suggestion:i,onDelete:a,isSelected:s}),n)},Eot=function(t){var r=t.attributes,n=t.children,i=t.size;return C.createElement("span",Object.assign({},r,{"data-testid":"default-element",style:ar({minWidth:"2px",minHeight:"16px",display:"inline-block",position:"relative"},i==="xs"&&{flexWrap:"nowrap",gap:"2px 0"})}),n)},Oot=function(t){var r=t.attributes,n=t.children,i=t.size;return C.createElement("div",Object.assign({},r,{"data-testid":"paragraph-element",style:ar(ar({margin:0,padding:0},i!=="xs"&&{display:"flex",flexWrap:"wrap"}),{},{gap:i==="xs"?"4px":"4px 0px",alignItems:"center",minHeight:"20px",position:"relative"},i==="xs"&&{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none"})}),n)},yot=function(t){var r=t.name,n=t.control,i=t.meta,o=t.onFocus,s=t.handleChange,a=t.validationRules,l=t.viewOnly,u=l===void 0?!1:l,c=t.MCP_INTEGRATION_FORM,f=i||{},p=f.displayName,h=p===void 0?"":p,A=f.value,g=A===void 0?!1:A,m=f.description,O=m===void 0?"":m,y=f.error,T=y===void 0?{}:y,v=f.readOnly,_=v===void 0?!1:v,x=f.isDisabled,b=x===void 0?!1:x,w=f.validation,R=w===void 0?{}:w,I=R.disabled,P=I===void 0?!1:I,k=R.required,N=k===void 0?!1:k,L=f.htmlProps,M=L===void 0?{}:L,B=f.htmlProps,H=B===void 0?{}:B,j=H.allowDynamic,X=j===void 0?!1:j,F=xo(O),V=C.useState(!1),G=V[0],D=V[1];C.useEffect(function(){typeof g=="string"&&g==="true"?D(!0):typeof g=="boolean"&&D(g)},[]);var $=function(q){o(q,r)};return C.createElement(E.FormControl,{fullWidth:!0,error:T!=null&&T.hasError?!0:void 0,sx:{marginTop:"8px"}},C.createElement(ws,{name:r,control:n,rules:a,defaultValue:G,render:function(q){var z=q.field,W=q.fieldState,Q=W===void 0?{}:W,Y=Q.error;return C.createElement(E.Stack,{spacing:"0.25rem"},C.createElement(E.Stack,{sx:{width:"100%",flexDirection:"row",alignItems:"center",justifyContent:X?"flex-end":"space-between"}},!X&&h&&C.createElement(Qo,{required:N,label:h,description:F}),C.createElement(E.FormControlLabel,Object.assign({disabled:P,label:c?"":z.value?"On":"Off",labelPlacement:"start",control:C.createElement(E.Switch,Object.assign({},z,{onFocus:$,onChange:function(ee){var le=ee.target.checked;(!u||r==="advanced_options")&&(z.onChange(le),s({field:r,value:z.value,fieldData:t}))},onBlur:z.onBlur,value:z.value,checked:z.value,name:r,readOnly:_,disabled:b||u&&r!=="advanced_options","data-testid":"ripple-switch-"+r}))},M,{htmlFor:r}))),Y?.message&&C.createElement(E.FormHelperText,{error:!!(Y!=null&&Y.message)},Y?.message))}}))},ire=C.createContext({fieldControlStates:{},setFieldControlState:function(){},getFieldControlState:function(){return""},transformFormData:function(t,r){return r}}),vot=function(t){var r=t.children,n=C.useState({}),i=n[0],o=n[1],s=function(c,f){o(function(p){var h;return ar(ar({},p),{},(h={},h[c]=f,h))})},a=function(c){return i[c]||""},l=function(c,f){if(!c||!f)return f;var p=ar({},f);return c.forEach(function(h){var A,g,m,O,y=h.name,T=f[y],v=a(y);if(T?p[y]=T:(!v||v==="")&&!T?p[y]="BOLTIC_AI":["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(v)&&(p[y]=v),(h==null||(A=h.meta)===null||A===void 0?void 0:A.displayType)==="array"&&Array.isArray(T)&&(g=h.meta)!==null&&g!==void 0&&g.children)p[y]=T.map(function(x){var b;return l((b=h.meta)===null||b===void 0?void 0:b.children,x)});else if((h==null||(m=h.meta)===null||m===void 0?void 0:m.displayType)==="object"&&typeof T=="object"&&T!==null&&(O=h.meta)!==null&&O!==void 0&&O.children){var _;p[y]=l((_=h.meta)===null||_===void 0?void 0:_.children,T)}}),p};return C.createElement(ire.Provider,{value:{fieldControlStates:i,setFieldControlState:s,getFieldControlState:a,transformFormData:l}},r)},ore=function(){return C.useContext(ire)},Tot=function(t){return function(n){var i,o,s,a,l=n.MCP_INTEGRATION_FORM,u=l===void 0?!1:l,c=n.name,f=c===void 0?"":c,p=n.MCP_EXCLUDED_FIELDS,h=p===void 0?[]:p,A=n.field,g=A===void 0?{}:A,m=n.handleChange,O=n.meta,y=O===void 0?{}:O,T=y.displayName,v=T===void 0?"":T,_=y.description,x=_===void 0?"":_,b=y.htmlProps,w=b===void 0?{}:b,R=rs(),I=R.setValue,P=w.showInfoIcon,k=P===void 0?!1:P,N=w.rightLabel,L=N===void 0?"":N,M=w.rightLabelAlignment,B=M===void 0?"center":M,H=w.showAddNew,j=H===void 0?!1:H,X=xo(x),F=rs(),V=(i=F.getValues)===null||i===void 0?void 0:i.call(F,f),G=ore(),D=G.setFieldControlState,$=C.useState(u?"BOLTIC_AI":"specific"),U=$[0],q=$[1];C.useEffect(function(){if(u){var Q="BOLTIC_AI";["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(V)?Q=V:V&&V!==""&&(Q="specific"),q(Q),D(f,Q)}},[]);var z=function(Y){var J=Y.target.value;q(J),D(f,J),["BOLTIC_AI","BOLTIC_AI_IGNORE"].includes(J)?(I(f,J),m?.({field:f,value:J,fieldData:n})):(I(f,""),m?.({field:f,value:"",fieldData:n}))},W=ar(ar({},n.meta),{},{htmlProps:ar(ar({},n==null||(o=n.meta)===null||o===void 0?void 0:o.htmlProps),{},{rightLabel:"",showInfoIcon:!1}),validation:{infoDetail:{infoMsg:""}},displayName:""});return u&&!h.includes(f)&&!["array","object","section"].includes(f)&&!g.hidden&&!f.includes("toolParamsMcp")?C.createElement(E.Stack,{spacing:j||L?0:"0.5rem"},C.createElement(E.FormControl,{fullWidth:!0},(v||L||k)&&C.createElement(E.Stack,{direction:"row",justifyContent:"space-between",alignItems:B},C.createElement(Qo,{required:n==null||(s=n.meta)===null||s===void 0||(a=s.validation)===null||a===void 0?void 0:a.required,label:v,description:X}),L&&C.createElement(E.Typography,{sx:{fontSize:"0.75rem",lineHeight:"1.125rem",fontWeight:500},pb:"0.25rem",color:"neutral.80"},L)),C.createElement(E.Select,{value:U,onChange:z,label:"Field Value Control"},C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI"},"Have AI generate a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE"},"Do not include a value for this field"),C.createElement(E.MenuItem,{sx:{py:.8},value:"specific"},"Set a specific value for this field"))),U==="specific"&&C.createElement(t,Object.assign({},n,{meta:ar({},W)}))):C.createElement(t,Object.assign({},n))}},oi={ACCORDION:"accordion",DIVIDER:"divider",SECTION:"section",TEXT:"text",SELECT:"select",RADIO:"radio",CHECKBOX:"checkbox",EMAIL:"email",NUMBER:"number",PASSWORD:"password",AUTOCOMPLETE:"autocomplete",FILE:"file",CODE:"code",BUTTON:"button",HIDDEN:"hidden",MULTITEXT:"multitext",TEXTAREA:"textarea",MULTISELECT:"multiselect",TOGGLE:"toggle",RADIOBUTTON:"radiobutton",ARRAY:"array",OBJECT:"object",PHONE:"phone",URL:"url",DATE:"date",TIME:"time",DATETIME:"datetime",KEYVALUE:"keyvalue",SLIDER:"slider"},Sot=function(t){var r,n=t.hidden,i=n===void 0?!0:n,o=t.meta,s=o===void 0?{}:o,a=s.displayType,l=a===void 0?"":a,u=s.displayName,c=u===void 0?"":u,f=s.htmlProps,p=f===void 0?{}:f,h=p.allowDynamic,A=h===void 0?!1:h,g=p.showInfoIcon,m=g===void 0?!1:g,O=p.rightLabel,y=O===void 0?"":O,T=p.size,v=T===void 0?"":T,_=p.overrideDynamicSupport,x=_===void 0?!1:_,b=s.validation,w=b===void 0?{}:b,R=w.infoDetail,I=R===void 0?{}:R,P=I.infoMsg,k=P===void 0?"":P,N=s.validation,L=N===void 0?{}:N,M=s.description,B=M===void 0?"":M,H=s.readOnly,j=H===void 0?!1:H,X=t.suggestions,F=X===void 0?{}:X,V=t.viewOnly,G=V===void 0?!1:V,D=F&&Object?.keys(F),$=["email","password","url","number","code","text","textarea"],U=(A||$.includes(l))&&D?.length>0,q=!["object"].includes(l),z=ar(ar({},t.meta),{},{htmlProps:ar(ar({},t==null||(r=t.meta)===null||r===void 0?void 0:r.htmlProps),{},{rightLabel:U&&q?"":y,showInfoIcon:U&&q?!1:m}),validation:ar(ar({},L),{},{infoDetail:{infoMsg:U&&q?"":k}}),displayName:U&&q?"":c}),W=rs(),Q=W.getValues,Y=W.setValue,J=W.watch,ee=C.useState("static"),le=ee[0],ne=ee[1],ue=C.useRef(null),Oe=function(dt,Tt){if(Tt==="static"){var Ie;Y(t.name,(t==null||(Ie=t.meta)===null||Ie===void 0?void 0:Ie.value)||"")}else{var lt;Y(t.name,String((t==null||(lt=t.meta)===null||lt===void 0?void 0:lt.value)||""))}ne(Tt)};C.useEffect(function(){var He=Q(t.name);typeof He=="string"&&He.startsWith("{{")?ne("dynamic"):ne("static")},[]);var ve=J(t.name),oe=(A&&!["text","textarea"].includes(l)||["email","password","url","number"].includes(l))&&!["file","code"].includes(l)&&!x&&!G&&!j&&D.length>0,ae=function(dt,Tt){var Ie,lt;return Tt===void 0&&(Tt="xs"),C.createElement(E.Stack,{className:"dynamic-wrapper"},C.createElement(E.FormControl,{fullWidth:!0,ref:ue},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&D?.length>0&&C.createElement(E.Stack,{alignItems:"flex-end",justifyContent:"space-between",direction:"row",pb:oe?"4px":0},(A||["email","password","url","number","textarea","text"].includes(l))&&!["file","code"].includes(l)&&D?.length>0&&C.createElement(Qo,{className:"meta-select-label",required:t==null||(Ie=t.meta)===null||Ie===void 0||(lt=Ie.validation)===null||lt===void 0?void 0:lt.required,label:c,description:B||k}),oe&&C.createElement(E.Tabs,{value:le,onChange:Oe,"aria-label":"select type",TabIndicatorProps:{sx:{display:"none"}}},rit.map(function(ct,rt){return C.createElement(E.Tab,{key:rt,label:ct.label,value:ct.value})}))),(le==="dynamic"&&l!==oi.CODE||["text","textarea"].includes(l))&&!x&&l!=="file"&&D&&D.length>0&&C.createElement(E.Stack,null,C.createElement(mot,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:ar(ar({},t.meta),{},{displayName:"",htmlProps:ar(ar({},t.meta.htmlProps),{},{showSuggestions:!0,size:Tt,rightLabel:""}),validation:L}),validationRules:ve!=null&&ve.includes("{")?{}:t?.validationRules}))),(le!=="dynamic"||l===oi.CODE)&&(!["text","textarea"].includes(l)||["text","textarea"].includes(l)&&vt(F)||x)&&dt))};if(i||l==="hidden")return null;var re=function(dt,Tt,Ie){return C.createElement(Xit,Object.assign({},t,{type:dt,htmlProps:Tt,textFieldProps:Ie,meta:z}))},Z=function(){var dt,Tt,Ie=(dt=t==null||(Tt=t.validation)===null||Tt===void 0?void 0:Tt.max)!=null?dt:"",lt=Ie?{maxLength:Ie}:void 0;return re("text",lt)},te=function(){var dt={type:"password"};return re("password",dt)},se=function(){return re("email")},he=function(){return re("number")},pe=function(){return re("url")},de=function(){var dt,Tt,Ie=t.meta.htmlProps,lt={multiline:!0,minRows:(dt=Ie?.minRows)!=null?dt:2,maxRows:(Tt=Ie?.maxRows)!=null?Tt:2};return re("text",{},lt)},xe=function(){return C.createElement(oot,Object.assign({},t,{meta:z}))},ge=function(){return C.createElement(cit,Object.assign({},t,{meta:z}))},Ee=function(){return C.createElement(lot,Object.assign({},t,{meta:z}))},ke=function(){return C.createElement(Jit,Object.assign({},t,{meta:z}))},We=function(){return C.createElement(uit,Object.assign({},t))},$e=function(){return C.createElement(Wit,Object.assign({},t))},et=function(){return C.createElement($it,Object.assign({},t,{suggestionsData:t.suggestions||{},meta:ar(ar({},t.meta),{},{htmlProps:ar(ar({},t.meta.htmlProps),{},{showSuggestions:!0})})}))},st=function(){return C.createElement(Qit,Object.assign({},t))},it=function(){return C.createElement(sot,Object.assign({},t))},Re=function(){return C.createElement(Hit,Object.assign({},t))},qe=function(){return C.createElement(yot,Object.assign({},t))},Ye=function(){return C.createElement(iot,Object.assign({},t,{meta:z}))},Se=function(){return C.createElement(Yit,Object.assign({},t,{meta:z}))},_e=function(){return C.createElement(Uit,Object.assign({},t,{meta:z}))},be=function(){return C.createElement(not,Object.assign({},t,{meta:z}))},K=function(){return C.createElement(ait,Object.assign({},t,{meta:z}))},ce=function(){return C.createElement(eot,Object.assign({},t,{meta:z}))},Te=function(){return C.createElement(qit,Object.assign({},t,{meta:z}))},Be=function(){return C.createElement(cot,Object.assign({},t,{meta:z}))},Fe=function(){return C.createElement(Ynt,Object.assign({},t,{meta:z}))};switch(l){case oi.TEXT:return ae(Z());case oi.PASSWORD:return ae(te());case oi.EMAIL:return ae(se());case oi.NUMBER:return ae(he());case oi.URL:return ae(pe());case oi.RADIO:return ae(xe());case oi.RADIOBUTTON:return ae(Ye());case oi.CHECKBOX:return ae(ge());case oi.CODE:return ae(et(),v||"md");case oi.TEXTAREA:return ae(de(),v||"sm");case oi.SELECT:case oi.AUTOCOMPLETE:return ae(Ee());case oi.MULTISELECT:return ae(ke());case oi.BUTTON:return ae(We());case oi.TOGGLE:return ae(qe());case oi.MULTITEXT:return ae(Se());case oi.HIDDEN:return st();case oi.FILE:return ae($e());case oi.SECTION:return ae(it());case oi.DIVIDER:return ae(Re());case oi.PHONE:return ae(be());case oi.DATE:return ae(_e());case oi.TIME:return ae(_e());case oi.DATETIME:return ae(_e());case oi.ARRAY:return ae(K(),v||"md");case oi.OBJECT:return ae(ce(),v||"md");case oi.KEYVALUE:return ae(Te(),v||"md");case oi.SLIDER:return ae(Be());case oi.ACCORDION:return ae(Fe());default:return C.createElement(E.Box,null,"Display Type: ",l," is not supported!")}},e0=Tot(C.memo(Sot)),xot=function(t,r){var n=C.useState(t),i=n[0],o=n[1],s=C.useCallback(function(a){return a?.map(function(l){var u,c=l?.meta||{},f=c.dependencies;if(f){var p=f.logic,h=p===void 0?"AND":p,A=f.conditions,g=A===void 0?[]:A,m=h==="AND";g.forEach(function(y){var T,v=y.operator,_=y.field,x=y.value,b=!1,w=Jnt(r,_)||(l==null||(T=l.meta)===null||T===void 0?void 0:T.value);switch(v){case"EQUALS":b=w===x;break;case"NOT_EQUALS":b=w!==x;break;case"GREATER_THAN":b=w>x;break;case"LESS_THAN":b=w<x;break;case"GREATER_THAN_OR_EQUALS":b=w>=x;break;case"LESS_THAN_OR_EQUALS":b=w<=x;break;case"CONTAINS":b=Array.isArray(w)?w.includes(x):w?.toString().includes(x);break;case"NOT_CONTAINS":b=Array.isArray(w)?!w.includes(x):!(w!=null&&w.toString().includes(x));break;case"STARTS_WITH":b=w?.toString().startsWith(x);break;case"ENDS_WITH":b=w?.toString().endsWith(x);break;case"REGEX":b=new RegExp(x).test(w?.toString());break;case"NOT_REGEX":b=!new RegExp(x).test(w?.toString());break;case"EMPTY":b=!w;break;case"NOT_EMPTY":b=!!w;break}m=h==="AND"?m&&b:m||b}),l.hidden=!m}if(["array","object","section"].includes(l==null||(u=l.meta)===null||u===void 0?void 0:u.displayType)){var O;l!=null&&(O=l.meta)!==null&&O!==void 0&&O.children&&(l.meta.children=s(l?.meta.children||[]))}return l})},[r]);return C.useEffect(function(){o(s(t))},[t,r,s]),i},bot=function(t){var r=t.reduce(function(n,i){return n[i.key]=i.value,n},{});return r},xx=function(t,r){return t.forEach(function(n){var i,o;if(["object","array","section"].includes((i=n.meta)===null||i===void 0?void 0:i.displayType))if(["configure","setup"].includes(n?.name)){var s;xx((s=n.meta)===null||s===void 0?void 0:s.children,r)}else{var a=r[n.name];if(a){var l;xx((l=n.meta)===null||l===void 0?void 0:l.children,a)}}else((o=n.meta)===null||o===void 0?void 0:o.displayType)==="keyvalue"&&Array.isArray(r[n.name])&&(r[n.name]=bot(r[n.name]))}),r},Cot=C.forwardRef(function(e,t){var r=e.name,n=e.schema,i=n===void 0?[]:n,o=e.form,s=o===void 0?{}:o,a=e.suggestions,l=e.onChange,u=e.onSubmit,c=e.onFocus,f=e.onCustom,p=e.buttonSchema,h=e.loading,A=e.onCancel,g=e.sx,m=e.isLoading,O=m===void 0?!1:m,y=e.useDefaultButtons,T=y===void 0?!0:y,v=e.viewOnly,_=v===void 0?!1:v,x=e.MCP_INTEGRATION_FORM,b=x===void 0?!1:x,w=e.MCP_EXCLUDED_FIELDS,R=w===void 0?[]:w,I=ar({},s),P=ore(),k=P.transformFormData,N=C.useMemo(function(){var Y;return(Y=_E(i,I))!=null?Y:{}},[i,I]),L=qJe({values:N,mode:"all"}),M=Aee({control:L.control,defaultValue:N}),B=C.useState(i),H=B[0],j=B[1],X=C.useMemo(function(){return i},[i,r]),F=C.useMemo(function(){return M},[M,r]),V=JA(i),G=xot(X,F);C.useEffect(function(){j(G)},[G,r]);var D=C.useCallback(function(Y){c&&c(Y)},[c]),$=C.useCallback(function(){A&&A()},[A]),U=C.useCallback(function(Y){if(l){var J=L.getValues(),ee=L.getValues(Y.field),le=ar(ar({},Y),{},{value:ee});l(le,J)}},[l,L,M]),q=C.useCallback(function(Y){return Y===void 0&&(Y=""),function(J){var ee=xx(i,J);if(b&&(ee=k(i,ee)),u){var le=xx(i,J);u(le,Y)}}},[u,i,k,b]),z=C.useCallback(function(Y,J,ee){if(J===void 0&&(J={}),ee===void 0&&(ee=""),f){var le=L.getValues();f(Y,ar(ar({},le),J),ee)}},[f,M]),W=C.useCallback(function(){try{return Promise.resolve(L.trigger()).then(function(Y){return!!Y})}catch(Y){return Promise.reject(Y)}},[L,H]);C.useImperativeHandle(t,function(){return{handleSubmit:function(J){var ee;J===void 0&&(J=""),(ee=L.handleSubmit(q(J)))===null||ee===void 0||ee()},getValues:L.getValues,isValidated:function(){try{return Promise.resolve(W())}catch(Y){return Promise.reject(Y)}}}});var Q=C.useRef(!1);return C.useEffect(function(){if(!(Q.current||!l)){Q.current=!0;var Y=function(le){le===void 0&&(le=[]);var ne=[];return le.forEach(function(ue){var Oe,ve,oe=ue==null||(Oe=ue.meta)===null||Oe===void 0?void 0:Oe.children;oe&&Array.isArray(oe)?ne.push.apply(ne,Y(oe)):(ue==null||(ve=ue.meta)===null||ve===void 0?void 0:ve.displayType)==="hidden"&&ne.push(ue)}),ne},J=Y(i);J.forEach(function(ee){U({field:ee.name,fieldData:ee})})}},[i,l,U]),C.createElement(kJe,Object.assign({},L),C.createElement("form",{key:r,name:"ripple-form",className:"ripple-form",noValidate:!0,style:ar({display:"flex",flexDirection:"column",height:"100%"},g)},C.createElement(E.Stack,{gap:1,alignItems:"center",sx:{overflowY:"auto",flexGrow:1},className:"ripple-form-container",width:"100%"},H&&H.length>0&&H.map(function(Y,J){var ee,le;return C.createElement(E.Stack,{width:"100%",key:Y?.name+"::"+J+"::"+r,sx:{display:(Y==null||(ee=Y.meta)===null||ee===void 0?void 0:ee.displayType)==="hidden"||Y?.hidden===!0?"none":"flex"}},C.createElement(Qnt,{fieldName:Y?.name},C.createElement(e0,Object.assign({},Y,{isLoading:O,field:Y,hidden:Y?.hidden||!1,control:L.control,handleChange:U,onFocus:D,handleCustom:z,viewOnly:_,validationRules:["object","array","keyvalue"].includes(Y==null||(le=Y.meta)===null||le===void 0?void 0:le.displayType)?V:V[Y?.name],suggestions:a,MCP_INTEGRATION_FORM:b,MCP_EXCLUDED_FIELDS:R}))))}),C.createElement(E.Stack,{width:"100%",alignItems:"center"},O&&C.createElement(E.CircularProgress,null))),T&&C.createElement(znt,{buttonSchema:p,onSubmit:function(J){return L.handleSubmit(q(J))()},onReset:function(){return L.reset()},onCancel:$,loading:h||O,style:{flexShrink:0}})))}),bx=C.forwardRef(function(e,t){var r=C.useRef(null);return C.useImperativeHandle(t,function(){var n;return{handleSubmit:function(o){var s,a;o===void 0&&(o=""),r==null||(s=r.current)===null||s===void 0||(a=s.handleSubmit)===null||a===void 0||a.call(s,o)},isValidated:r==null||(n=r.current)===null||n===void 0?void 0:n.isValidated}}),C.createElement(vot,null,C.createElement(Cot,Object.assign({},e,{ref:r})))});const _ot=(e,t,r)=>{const n=[Kr.WORKFLOW_EXECUTION_COMPLETED,Kr.ACTIVITY_TASK_COMPLETED],i=[Kr.ACTIVITY_TASK_FAILED,Kr.ACTIVITY_TASK_TIMED_OUT,Kr.WORKFLOW_EXECUTION_FAILED,Kr.WORKFLOW_EXECUTION_TIMED_OUT,Kr.WORKFLOW_EXECUTION_TERMINATED,Kr.WORKFLOW_EXECUTION_CANCELED,Kr.WORKFLOW_TASK_TIMED_OUT];{if(n.includes(e))return r.palette.success.main;if(i.includes(e))return r.palette.error.main}},DE=e=>{const t=[Kr.WORKFLOW_EXECUTION_COMPLETED,Kr.WORKFLOW_EXECUTION_FAILED,Kr.WORKFLOW_EXECUTION_TIMED_OUT,Kr.WORKFLOW_EXECUTION_TERMINATED,Kr.WORKFLOW_EXECUTION_CANCELED,Kr.WORKFLOW_EXECUTION_TERMINATED,Kr.WORKFLOW_TASK_FAILED,Kr.WORKFLOW_TASK_TIMED_OUT];return e?e.some(r=>t.includes(r.eventType)):[]};function wot(e){const t=e.eventType.replace(/_/g," ").replace("EVENT TYPE","").replace(/\w\S*/g,r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).trim();if(e.eventType===Kr.ACTIVITY_TASK_SCHEDULED&&e.activityTaskScheduledEventAttributes){const r=e.activityTaskScheduledEventAttributes?.input?.payloads?.[0]?.data?.name;return r?`${t}: ${r}`:t}return t}function Iot(e){if(e==null||typeof e!="object"||Array.isArray(e))return e;const{isBranch:t,branchToExecute:r,...n}=e;return n}const Cx=e=>{if(!(typeof e=="string"||e instanceof String))return;const t=e.match(/\{\{([^{}]+)\}\}/);if(t)return t[1].trim()},Dot=(e,t)=>new Promise((r,n)=>{const i=t.split(".");let o=e;for(const[s,a]of i.entries())if(a.includes("[")){let l,u;if(!a.includes("]"))throw l=a.split("["),u=l[0],n(`Invalid Syntax while using ${u}`),new Error(`Invalid Syntax while using ${u}`);l=a.split("["),u=l[0];const c=parseInt(l[1].replace("]",""));if(!Array.isArray(o[u]))throw n(`${u} should be an array, found ${typeof o[u]}`),new Error(`${u} should be an array, found ${typeof o[u]}`);if(isNaN(c)||c<0)throw n(`Invalid array index for ${a}`),new Error(`Invalid array index for ${a}`);if(c>=o[u].length)throw n(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`),new Error(`Invalid array index: ${a}, Max length of ${u} is ${o[u].length}`);o=o[u][c]}else if(a==="uuid4()")o=y5();else if(o=o[a],o&&s<i.length-1&&Array.isArray(o)){if(i.includes("length")&&i[i.length-1]==="length")continue;throw n(`Invalid Syntax, Use ${a}[${s}]`),new Error(`Invalid Syntax, Use ${a}[${s}]`)}r(o)}),Rot=async(e,t)=>{if(typeof e!="string")return e;const r=/{{([^{}]*)}}/g,n=[];let i;for(;(i=r.exec(e))!==null;)n.push(i);for(const o of n){const s=o[1],a=await Dot(t,s),l=a!==void 0?typeof a=="object"?JSON.stringify(a):a.toString():"";e=e.replace(o[0],l)}return e},B8=async(e,t)=>{const r=Array.isArray(e)?[]:{};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const i=e[n];typeof i=="object"&&i!==null?r[n]=await B8(i,t):typeof i=="string"?r[n]=await Rot(i,t):r[n]=i}return r},j8=[{name:"activity_name",meta:{displayName:"Custom Name",displayType:"hidden",placeholder:"Enter the custom name",validation:{required:!0},value:""}},{name:"integration_slug",meta:{displayName:"Integration Slug",displayType:"hidden",placeholder:"Enter the integration slug",validation:{required:!0},value:""}}],Pot=[{name:"advanced_options",meta:{displayName:"Advanced Options",displayType:"accordion",htmlProps:{headerVariant:"smSemiBold"},children:[{name:"continue_on_failure",meta:{displayName:"Continue on Failure",displayType:"toggle",description:"When enabled, a failure handle appears on this node. If this node fails, workflow continues through the failure path. If disabled and this node fails, the entire workflow stops.",value:!1,readOnly:!1}},{name:"retry_config",meta:{displayType:"object",children:[{name:"maximum_attempts",meta:{displayName:"Maximum Number of Attempts",displayType:"number",placeholder:"Enter the maximum number of tries",description:"The maximum number of times to try the activity, including the first attempt. If set to 3, the activity will run at most 3 times.",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:1,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"backoff_coefficient",meta:{displayName:"Retry Backoff Rate",displayType:"number",placeholder:"Enter the wait time between tries",description:"Constants factor by which the time delay between the retry attempts increase after the each failure",validation:{required:!0},htmlProps:{allowDynamic:!1,overrideDynamicSupport:!0},value:2,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"initial_interval",meta:{displayName:"Wait Time Before First Retry (seconds)",displayType:"number",placeholder:"Enter the initial wait time",description:"The time to wait before the first retry after a failure. For example, if set to 5 seconds, the first retry will occur 5 seconds after the failure.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e3,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_interval",meta:{displayName:"Maximum Wait Between Retries (seconds)",displayType:"number",placeholder:"Enter the maximum wait time",description:"The longest time to wait between retries, regardless of backoff. Prevents the delay from growing indefinitely.",validation:{required:!0},htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},value:1e5,dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}},{name:"maximum_timeout",meta:{displayName:"Maximum Activity Completion Timeout in (m/s)",displayType:"number",placeholder:"Enter the maximum timeout",description:"Maximum time to wait for the Activity to complete",validation:{required:!0},value:6e4,htmlProps:{overrideDynamicSupport:!0,allowDynamic:!1},dependencies:{conditions:[{field:"advanced_options",operator:"EQUALS",value:!0}]}}}],dependencies:{conditions:[{field:"secret",operator:"NOT_EMPTY"},{field:"resource",operator:"NOT_EMPTY"},{field:"operation",operator:"NOT_EMPTY"}]}}}],_x=async(e,t)=>{const{url:r,method:n,body:i}=e,o=n,s=i&&await B8({body:i},{parameters:t}),a={};s&&(o==="post"||o==="put"||o==="patch")&&(a.data=s.body);const{data:l}=await Qt[o](r,a);return l},Not=async(e,t,r,n,i,o)=>{const{integration_id:s,resource:a,operation:l,integration_slug:u}=e,c=[];if(!s&&!u)throw new Error("integration_slug or integration_id is required in payload");const p=[r,"v1.0",n,"integrations",u||s],h=Xt(...p,"configuration"),{data:A}=await Qt.get(h),g=A.data.content.parameters;if(c.push(...g),a&&p.push("resource",a),!vt(a)){const m=Xt(...p),{data:O}=await Qt.get(m);if(!O.data.content.parameters)throw new Error("No integration schema data found");c.push(...O.data.content.parameters)}if(!vt(a)&&!vt(l)){l&&p.push("operation",l);const m=Xt(...p),{data:O}=await Qt.get(m),y=O?.data?.content;if(!y)throw new Error("No Operation schema found");if(y?.config){const{method:T,urlType:v,body:_,condition:x}=y.config;if(x){const b=Cx(x);if(b){const w=b.split(".")[1];if(t?.[w]){let{url:R}=y.config;R=Xt(r,"v1.0",n,R);const I={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},P=Object.assign({},{url:R,method:T,urlType:v,body:I}),k=await _x(P,t);c.push(...y.parameters,...k)}else c.push(...y.parameters)}}else{let{url:b}=y.config;b=Xt(r,"v1.0",n,b);const w={..._,...u&&{integration_slug:u},...s&&{integration_id:s}},R=Object.assign({},{url:b,method:T,urlType:v,body:w}),I=await _x(R,t);c.push(...y.parameters,...I)}}else c.push(...y.parameters)}return i||o?c.push(...j8):c.push(...j8,...Pot),c},Lot=async(e,t,r,n)=>{const{integration_id:i,resource:o="webhook",operation:s,integration_slug:a}=e,l=[];let u;if(!i&&!a)throw new Error("integration_slug or integration_id is required in payload");const f=[r,"v1.0",n,"integrations",a||i];if(o&&o==="webhook"){f.push("webhook");const p=Xt(...f),{data:h}=await Qt.get(p);if(u=h.data.content,!u)throw new Error("No integration schema data found");l.push(...u.parameters)}if(!vt(o)&&!vt(s)){if(u?.config){const{method:h,urlType:A,body:g,condition:m}=u.config;if(m){const O=Cx(m);if(O){const y=O.split(".")[1];if(t?.[y]){let{url:T}=u.config;T=Xt(r,"v1.0",n,T);const v={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},_=Object.assign({},{url:T,method:h,urlType:A,body:v}),x=await _x(_,t);l.push(...u.parameters,...x)}else l.push(...u.parameters)}}else{let{url:O}=u.config;O=Xt(r,"v1.0",n,O);const y={...g,...a&&{integration_slug:a},...i&&{integration_id:i}},T=Object.assign({},{url:O,method:h,urlType:A,body:y}),v=await _x(T,t);l.push(...u.parameters,...v)}}const p=u[s]?.parameters;l.push(...p)}return l.push(...j8),{data:l,polling_interval:u?.polling_interval}},wx=({formData:e,isLoop:t=!1,selectedNode:r,INTEGRATION_DATA:n,SET_INTEGRATION_DATA:i,onClose:o,openIntegrationDrawer:s,handleRunActivity:a,handleCompleteSetup:l,setPollingInterval:u,onSubmit:c,source:f="",MCP_INTEGRATION_FORM:p=!1})=>{const[h,A]=C.useState([]),[g,m]=C.useState({}),[O,y]=C.useState(!1),[T,v]=C.useState({headers:{},query:"",variables:{}}),_=C.useRef(!1),x=C.useRef(null),b=pt.useDispatch(),[w,R]=C.useState(!1),{WORKFLOW_URLS:I,ENTITY_ID:P=""}=Ii(),{VORTEX_MAIN_URL:k,TESSERACT_MAIN_URL:N,FRONTEND_URL:L}=I,M=r?.data?.type,B=r?.data?.properties?.activity_name,H=r?.data?.properties?.activity_id,j=r?.data?.properties?.integration_slug,X=ne=>{if(!ne)return{};if(typeof ne=="string")try{const ue=JSON.parse(ne);return typeof ue=="object"&&ue!==null?ue:{}}catch{return{}}return typeof ne=="object"?ne:{}},F=(ne,ue)=>{m(Oe=>{const ve={...Oe,[ne]:ue};return Oe?.properties&&typeof Oe.properties=="object"&&(ve.properties={...Oe.properties,[ne]:ue}),ve})},V=()=>{y(!1),v({headers:{},query:"",variables:{}})},G=ne=>{F("query",ne),v(ue=>({...ue,query:ne}))},D=ne=>{v(ve=>({...ve,variables:ne}));const Oe=typeof g?.variables=="string"&&typeof ne!="string"?JSON.stringify(ne,null,2):ne;F("variables",Oe),V()},$=()=>O?d.jsx(Io,{open:O,handleClose:V,title:"GraphQL Inspector",subtitle:"Explore the GraphQL schema and build queries by selecting fields",icon:d.jsx(Ue,{src:"ic_schema"}),sx:{".MuiDialogContent-root":{padding:"16px 24px !important"}},content:d.jsx(YJ,{form:g,headers:X4(T.headers||{}),currentQuery:T.query||"",onQueryUpdate:G,onVariablesUpdate:D})}):null,U=async ne=>{if(x.current!==ne){x.current=ne;try{const ue=Xt(N,`/v1/integrations/${ne}/validate-token`),Oe=await Qt.get(ue),{data:ve}=Oe.data;if(ve){const{is_revoked:oe}=ve;if(_.current!==oe&&(_.current=oe,h.length>0)){const ae=h.map(re=>re.name==="secret"?{...re,meta:{...re.meta,htmlProps:{...re.meta.htmlProps,showReconnect:oe}}}:re);A(ae)}}}catch(ue){sr(ue,b)}}},q=async()=>{if(g.secret)if(s)s({_id:g.secret},"edit");else{const ne=`${L}/accounts/${P}/integrations/destination/new-destination/${g.secret}/edit`;window.open(ne)}},z=async({resource:ne,operation:ue,currentFormData:Oe={},schema:ve=[]})=>{try{let oe=ve;if(M!==Ze.SERVERLESS){R(!0);const Z={...j&&{integration_slug:j},...H&&{integration_id:H},...ue&&{operation:ue},...ne&&{resource:ne}};let te={};if(vt(Oe)?te=vt(g)?e.properties:g:te=Oe,M===Ze.CLOUD_TRIGGER){const{data:se,polling_interval:he}=await Lot(Z,te,k,P);oe=se,u&&u?.(he)}else oe=await Not(Z,te,k,P,t,p)}let ae=oe;const re=async(Z,te=[])=>{if(f?.includes("commerce_")&&M===Ze.PLATFORM_FDK_ACTIVITY){const se=f?.split("_"),he=se&&se.length>1?se[1]:null,pe=se&&se.length>2?se.slice(2).join("_"):he;ae=ae?.map(de=>de.name==="secret"?(delete de.meta.config,{...de,meta:{...de.meta,options:[{value:f,label:pe}],value:f,isDisabled:!0,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}):de)}for(const se of Z){if((se?.meta?.displayType==="select"||se?.meta?.displayType==="autocomplete"||se?.meta?.displayType==="multiselect")&&se?.meta?.config?.url){const{method:he,labelKey:pe,valueKey:de,urlType:xe,body:ge,condition:Ee}=se.meta.config;let{url:ke}=se.meta.config;xe==="secret"?ke=Xt(N,"v1/integrations/entity",ke):xe==="options"&&(ke=Xt(k,"v1.0",P,ke));const We={...ge,...H&&{integration_id:H},...j&&{integration_slug:j}},$e=Object.assign({},{url:ke,method:he,labelKey:pe,valueKey:de,body:We});if(Ee){const et=Cx(Ee);if(et){const st=et.split(".")[1];(g[st]||e?.properties?.[st])&&(ae=await Q(se.name,$e,ae,[...te,se.name]))}}else ae=await Q(se.name,$e,ae,[...te,se.name])}se?.meta?.children&&se?.meta?.children?.length>0&&await re(se?.meta?.children,[...te,se.name])}};await re(ae),_.current&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&(ae=ae.map(Z=>(Z.name==="secret"&&(Z.meta.htmlProps={...Z.meta.htmlProps,showReconnect:_.current}),Z))),A(ae)}catch(oe){sr(oe,b)}finally{R(!1)}},W=async()=>{const ne=Xt(k,"v1.0",P,"integrations",j,"configuration"),ue={advanced_options:!0};Qt.get(ne,{params:ue}).then(async({data:Oe})=>{if(t){const ve=Oe.data.content.parameters.filter(oe=>!["advanced_options","maximum_attempts","backoff_coefficient","initial_interval","maximum_interval","maximum_timeout"].includes(oe.name));await z({schema:ve})}else await z({schema:Oe.data.content.parameters})})},Q=async(ne,ue,Oe,ve=[])=>{R(!0);try{const{url:oe,method:ae,labelKey:re,valueKey:Z,body:te}=ue,se=ae,he=te&&await B8({body:te},{parameters:vt(g)?e.properties:g}),pe={};he&&(se==="post"||se==="put"||se==="patch")&&(pe.data=he.body);const de=await Qt[se](oe,pe),ge=(ne==="secret"?de.data.data:de.data)?.map(ke=>({value:ke[Z],label:ke[re]}));let Ee=[];if(ve?.length===0)Ee=Oe?.map(ke=>ke.name===ne?{...ke,meta:{...ke.meta,options:ge}}:ke);else{Ee=Oe;const ke=(We,$e,et,st=0)=>{We.forEach(it=>{it.name===$e[st]&&(st===$e.length-1?it.meta={...it.meta,options:et}:it?.meta?.children&&it?.meta?.children?.length>0&&ke(it?.meta?.children,$e,et,st+1))})};ve?.length>0&&ke(Ee,ve,ge)}return Ee}catch(oe){return sr(oe,b),Oe}finally{R(!1)}};return C.useEffect(()=>{if(x.current=null,_.current=!1,M===Ze.SERVERLESS)W();else{async function ne(){r&&(A([]),await z({}))}ne()}},[r.id,B,H,j]),C.useEffect(()=>{async function ne(){if(n?._id&&n?.meta?.entity===B.toUpperCase()){n?.meta?.auth_status==="ACTIVE"&&(_.current=!1),M===Ze.SERVERLESS?await z({schema:h}):await z({});const ue={maximum_attempts:1,backoff_coefficient:2,initial_interval:1e3,maximum_interval:1e5},Oe={...g?.activity_id&&{activity_id:g.activity_id},...j&&{integration_slug:j},...g?.activity_name&&{activity_name:g.activity_name},...M!==Ze.CLOUD_TRIGGER?{maximum_timeout:6e4,retry_config:ue}:{}};m({...Oe,secret:n._id})}}ne()},[n]),C.useEffect(()=>{const ne=async()=>{const{secret:ue,resource:Oe,operation:ve}=e.properties;if(M===Ze.SERVERLESS)vt(ue)||await z({schema:h});else if(e?.properties||!vt(ue)){if(M===Ze.SERVERLESS&&!vt(ue))await z(h);else if(vt(Oe)||await z({resource:Oe}),!vt(ve)){const[oe,ae]=ve.split(".");await z({resource:oe,operation:ae})}}};vt(e.properties)||(m(e.properties),e.properties.secret&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&U(e.properties.secret),ne())},[e]),C.useEffect(()=>{if(p&&h.length>0){const ne=(ue,Oe="")=>{const ve={...g};ue.forEach(oe=>{const ae=oe.name,re=Oe?`${Oe}.${ae}`:ae;if(of.includes(ae)||of.some(te=>re.includes(te)))return;g[ae]||(oe.meta?.displayType==="array"?ve[ae]=["BOLTIC_AI"]:oe.meta?.displayType!=="object"&&(ve[ae]="BOLTIC_AI"));const Z=[];h.forEach(te=>{te.meta?.displayType!=="hidden"&&!of.includes(te.name)&&!of.some(se=>te.name.includes(se))&&Z.push({key:te.name,...te.meta?.displayType==="array"&&{name:te.meta?.name||te.name},description:te.meta?.description||"",type:te.meta?.displayType||"",value:ve[te.name]||null,required:te?.validation?.required||!1})}),ve.payload=Z,oe?.meta?.children&&oe?.meta?.children?.length>0&&ne(oe.meta.children,re)}),m(ve)};ne(h)}},[p,h]),{form:g,formSchema:h,loading:w,handleFocus:async ne=>{let ue=h;const{fieldData:Oe}=ne;if((Oe?.meta?.displayType==="select"||Oe?.meta?.displayType==="autocomplete"||Oe?.meta?.displayType==="multiselect")&&Oe?.meta?.config?.url){const{method:ve,labelKey:oe,valueKey:ae,urlType:re,body:Z,condition:te}=Oe.meta.config;let{url:se}=Oe.meta.config;re==="secret"?se=Xt(N,"v1/integrations/entity",se):re==="options"&&(se=Xt(k,"v1.0",P,se));const he={...Z,...H&&{integration_id:H},...j&&{integration_slug:j}},pe=Object.assign({},{url:se,method:ve,labelKey:oe,valueKey:ae,body:he});if(R(!0),te){const de=Cx(te);if(de){const xe=de.split(".")[1];(g[xe]||e?.properties?.[xe])&&(ue=await Q(Oe.name,pe,ue))}}else ue=await Q(Oe.name,pe,ue);R(!1),_.current&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&(ue=ue.map(de=>de.name==="secret"?{...de,meta:{...de.meta,htmlProps:{...de.meta.htmlProps,showReconnect:_.current}}}:de))}A(ue)},handleChange:async(ne,ue)=>{if(M===Ze.SERVERLESS){m(ue);return}const{field:Oe,value:ve,fieldData:oe={}}=ne,ae={...ue,[Oe]:ve};if(Oe==="secret")m(ae),ve&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY)&&U(ve);else if(Oe==="resource")m(ae),await z({resource:ve});else if(Oe==="operation"){const[re,Z]=ve.split(".");m(ae),await z({resource:re,operation:Z})}else if(oe?.meta?.loadDynamicParameters){const[re,Z]=g.operation.split(".");m({...ue,[Oe]:ve}),await z({resource:re,operation:Z,currentFormData:{...ue,[Oe]:ve}})}else m(ue)},handleCustom:(ne,ue,Oe="")=>{if(Oe==="run_activity"){a?.(ue?.canvasNodeId);return}else if(Oe==="configure_activity"){l?.(ue?.canvasNodeId);return}if(m(ue),ne.type==="add-new"){R(!0);let ve=B;const oe=h.find(Z=>Z.name==="secret"&&Z.meta.config);if(oe){const{url:Z}=oe.meta.config;ve=Z.split("?")[0].replace("/","")}const ae={current_page:1,page_size:1,entity:ve.toUpperCase(),state:r.activity_data.status},re=Xt(N,"/v1/catalog");Qt.get(re,{params:ae}).then(Z=>{if(s){s(Z.data.data[0],"create");return}const te=`${L}/accounts/${P}/integrations/destination/new-destination/${Z.data.data[0]._id}/create?integration_id=${H}&integration_slug=${j}`;window.open(te)}).catch(Z=>{sr(Z,b)}).finally(()=>{R(!1)})}else if(ne.type==="complete-step")R(!0),b({type:f4,payload:[ne.data?.id]}),b({type:wb,payload:"focused"}),R(!1);else if(ne.type==="add-sample-data"){R(!0);const{data:ve}=ne;ve.name==="global_variables"?b({type:h4,payload:ve.data}):ve.name==="payload"?b({type:md,payload:{id:ve?.id,data:ve.data,loading:!1}}):b({type:md,payload:{id:ve.id,data:{result:ve.data,events:[]},loading:!1}}),R(!1)}else if(ne.type==="reconnect"&&(M===Ze.CLOUD_TRIGGER||M===Ze.CUSTOM_ACTIVITY))q();else if(ne.type==="graphql-inspector"){const oe=!!ue?.properties&&typeof ue.properties=="object"&&!Array.isArray(ue.properties)?ue.properties:ue,ae=oe?.query,re=oe?.headers,Z=X(oe?.variables);v({headers:re||{},query:typeof ae=="string"?ae:ae?JSON.stringify(ae,null,2):"",variables:Z}),y(!0)}},setForm:m,handleCancel:()=>{o?.(),m({}),A([]),i(null)},setFormSchema:A,GraphQLInspectorModal:$}},Ix=e=>{if(!e||e.length===0)return!1;const t=e.some(n=>["secret","resource","operation"].includes(n.name)),r=e.some(n=>!["secret","resource","operation"].includes(n.name));return t&&r},Dx=(e,t)=>{const r=t?.secret&&!vt(t.secret),n=e.filter(u=>u.name==="operation"?r||!r&&t?.resource:["secret","resource"].includes(u.name)),i=e.filter(u=>!["secret","resource","operation"].includes(u.name)),o=[{name:"setup",meta:{className:"setup-section",displayType:"section",displayName:"Setup",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:n}}],s=i.length>0,a=t?.resource&&!vt(t.resource),l=t?.operation&&!vt(t.operation);return s&&a&&l&&(o.push({meta:{displayType:"divider",htmlProps:{my:"1rem"}}}),o.push({name:"configure",meta:{className:"configure-section",displayType:"section",displayName:"Configure",htmlProps:{border:!1,divider:!1,headerVariant:"lgSemiBold"},children:i}})),o},kot=C.forwardRef((e,t)=>{const{formData:r,selectedNode:n,type:i,activity_id:o,initialState:s,isLoop:a=!1,cloudRef:l,suggestionsData:u,SET_INTEGRATION_DATA:c,INTEGRATION_DATA:f,openIntegrationDrawer:p,isLoading:h=!1,onSubmit:A,onClose:g}=e,{loopSuggestionsData:m={}}=pt.useSelector(M=>M.loopActivity),{viewOnly:O}=pt.useSelector(M=>M.canvas),{form:y,formSchema:T,loading:v,handleFocus:_,handleChange:x,handleCustom:b,setForm:w,handleCancel:R,setFormSchema:I,GraphQLInspectorModal:P}=wx({formData:r,selectedNode:n,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:c,onClose:g,openIntegrationDrawer:p,onSubmit:A});C.useImperativeHandle(t,()=>({getData:()=>y,validateForm:()=>!0,resetFormData:()=>{w({}),I([])}}),[y]);const k=(M,B="")=>{if(!a){const H={type:i,name:n.data.name,activity_id:o,properties:{...s.properties,...M}};e.onSubmit?.(H,B)}},L=Ix(T)?Dx(T,y):T;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:l,name:`${n.data.name}-integration-form`,schema:L,form:y,onChange:x,onSubmit:k,isLoading:v||h,onFocus:_,onCustom:b,onCancel:R,useDefaultButtons:!1,suggestions:a?m:u,viewOnly:O}),d.jsx(P,{})]})}),sre=Xi(kot),Fot=({url:e})=>{const t=E.useTheme(),r=pt.useDispatch(),[n,i]=C.useState(!1);C.useEffect(()=>{n&&setTimeout(()=>{i(!1)},2e3)},[n]);const o=()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),r({type:Xr,payload:{open:!0,title:"Copied to clipboard",type:"success"}})}).catch(()=>{r({type:Xr,payload:{open:!0,title:"Failed to copy",type:"error"}})})};return d.jsx(E.Grid,{item:!0,xs:12,children:d.jsxs(E.Stack,{direction:"row",alignItems:"center",spacing:2,sx:{border:s=>`1px solid ${s.palette.grey[200]}`,borderRadius:1,p:2,background:t.palette.neutral.soft.bg,position:"relative",userSelect:"none"},children:[d.jsx(E.Typography,{sx:{color:t.palette.primary.main,px:1,py:.5,borderRadius:"4px",border:"1px solid"},children:"POST"}),d.jsx(E.Tooltip,{title:e,arrow:!0,children:d.jsx(E.Typography,{sx:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-all",maxWidth:"80%"},children:e})}),d.jsx(E.Tooltip,{title:"Copy to clipboard",placement:"top",arrow:!0,children:d.jsx(E.IconButton,{"data-testid":"button-copy-webhook-url",onClick:o,sx:{position:"absolute",right:"6px",top:"6px"},children:d.jsx(Ue,{src:"ic_copy",width:15,height:15,sx:{path:{fill:t.palette.common.black}}})})})]})})},Mot=C.forwardRef((e,t)=>{const r=pt.useDispatch(),n=E.useTheme(),{type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,VORTEX_MAIN_URL:a,FRONTEND_URL:l,WORKFLOW_URLS:u,INTEGRATION_DATA:c,viewOnly:f=!1,openIntegrationDrawer:p}=e,[h,A]=C.useState([]),[g,m]=C.useState(!1),[O,y]=C.useState([]),[T,v]=C.useState([]),[_,x]=C.useState(!1),[b,w]=C.useState(!1),[R,I]=C.useState(!1),{control:P,watch:k,setValue:N,trigger:L}=Rr(),M=k("properties.slack_auth_id"),B=k("properties"),[H,j]=C.useState(!1),[X,F]=C.useState(""),V=()=>{m(!0);const J={page_size:999,current_page:1,type:"BOTH"},ee=Xt(o,"/v1/integrations/entity/SLACK_V2");Qt.get(ee,{params:J}).then(({data:le})=>{const ne=io(le.data,["integration_meta"]);A(ne)}).catch(le=>{sr(le,r)}).finally(()=>{m(!1)})},G=Xt(a,`/v1.0/${s}`,"/implementations/choices"),D=async({slackAuthId:J,inputFieldId:ee,fieldsToFill:le,type:ne,refresh:ue=!1})=>{const Oe=`${G}${ue?"?refresh=true":""}`;return Qt.post(Oe,{data:{secret:J,input_field_id:ee,selected_api:"slackAPI",fields_to_fill:le,operation:"get",...ne&&{type:ne}}})},$=async(J,ee=!1)=>{I(!ee),ee&&j(!0);const{event:le}=B;let ne;["public_channel_message","public_channel_message_mention"].includes(le)?ne="public_channel":["private_channel_message","private_channel_message_mention"].includes(le)&&(ne="private_channel");try{const ue=await D({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Nf,type:ne,refresh:ee});y(ue.data)}catch(ue){y([]),sr(ue,r)}finally{I(!1),j(!1)}},U=async(J,ee=!1)=>{I(!ee),ee&&j(!0);try{const[le,ne]=await Promise.all([D({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Nf,type:"public_channel",refresh:ee}),D({slackAuthId:J,inputFieldId:"channel",fieldsToFill:Nf,type:"private_channel",refresh:ee})]);y([...le.data,...ne.data])}catch(le){y([]),sr(le,r)}finally{I(!1),j(!1)}},q=async(J,ee=!1)=>{x(!ee),ee&&w(!0);try{const le=await D({slackAuthId:J,inputFieldId:"user",fieldsToFill:ck,refresh:ee});v(le.data)}catch(le){sr(le,r)}finally{x(!1),w(!1)}},z=async J=>{const{slack_auth_id:ee,event:le}=B;if(!ee||!le)return;const ne=["public_channel_message","private_channel_message"].includes(le),ue=["public_channel_message_mention","private_channel_message_mention"].includes(le);J==="channel"?ne||ue?await $(ee,!0):le==="app_mention"&&await U(ee,!0):J==="user"&&ue&&await q(ee,!0)};C.useEffect(()=>{(M===""||M===null||M===void 0)&&(N("properties.event",""),N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),y([]),v([]))},[M,N]),C.useEffect(()=>{B.event&&B.event!==null&&!vt(B)&&(N("properties.channel",""),N("properties.username",""),N("properties.word",""),N("properties.listen_workspace",!1),N("properties.listen_for_bot_message",!1),v([]),y([]))},[B.event,N]),C.useEffect(()=>{const{slack_auth_id:J,event:ee}=B;!vt(J)&&!vt(ee)&&(["public_channel_message","private_channel_message"].includes(ee)?$(J):ee==="app_mention"?U(J):["public_channel_message_mention","private_channel_message_mention"].includes(ee)&&($(J),q(J)))},[B.slack_auth_id,B.event]),C.useEffect(()=>{B.listen_workspace&&N("properties.channel","")},[B.listen_workspace,N]),C.useEffect(()=>{V()},[]),C.useEffect(()=>{try{const ee=window.location.pathname.split("/"),le=ee.findIndex(ue=>ue==="version");let ne="";if(le>-1&&le<ee.length-1)ne=ee[le+1];else{const ue=["draft","published","scheduled"],Oe=ee.findIndex(ve=>ue.includes(ve));ne=Oe>-1?ee[Oe+1]:""}u?.VORTEX_WEBHOOK_URL&&s&&ne&&F(Xt(u.VORTEX_WEBHOOK_URL,`/v1.0/${s}`,"workflows/execute/",ne))}catch{}},[u,s]),C.useEffect(()=>{c?._id&&c?.meta?.entity==="SLACK_V2"&&(V(),N("properties.slack_auth_id",c._id,{shouldValidate:!0}))},[c]);const W=h.find(J=>J.id===B.slack_auth_id),Q=W?.integration_meta?.type==="oauth2",Y=W?.integration_meta?.bot_name;return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.slack_auth_id",control:P,meta:{options:Tn(h),displayProps:{loading:g},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:l,ENTITY_ID:s,openIntegrationDrawer:p,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack Account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${u.GYRATE_MAIN_URL}/integrations/Triggers/slack" target="_blank" rel="noopener noreferrer" style="color: ${n.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},viewOnly:f,id:i,handleChange:()=>{}})})})}),B.slack_auth_id&&d.jsx(E.Divider,{}),B.slack_auth_id&&d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(B.slack_auth_id)&&h.length>0&&(!(h.find(le=>le.id===B.slack_auth_id)?.integration_meta?.type==="oauth2")&&X?d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{container:!0,gap:1,children:d.jsx(Fot,{url:X})}),d.jsx(Ul,{message:'Copy the webhook URL above and paste it into the "Request URL" field on the Event Subscriptions page in your Slack app settings. This enables Slack to send events to your workflow.'})]}):null),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{name:"properties.event",control:P,meta:{options:Hue,displayName:"Operation",searchFieldPlaceholder:"Search operation",description:"This is what starts the Workflow",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},required:!0,viewOnly:f,handleChange:()=>{}})}),B.event==="app_mention"&&!Q&&Y&&d.jsx(Ul,{variant:"info",message:`To trigger workflows, mention your bot using @${Y} in any Slack channel where the bot is invited.`}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(gn,{label:"Watch Whole Workspace",description:co("If enabled, triggers across the entire workspace; channel selection is not required."),sx:{fontSize:14,fontWeight:400,color:n.palette.text.primary}}),d.jsx(hr,{name:"properties.listen_workspace",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),!vt(B.slack_auth_id)&&!vt(B.event)&&d.jsxs(d.Fragment,{children:[!B?.listen_workspace&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!B?.listen_workspace,name:"properties.channel",control:P,meta:{options:Tn(O),displayName:"Select Channel",displayProps:{loading:R,refreshing:H},value:"",searchFieldPlaceholder:"Search",description:"Only channels your bot is a member of will appear in this list.",placeholder:"Select Channel"},validationRules:{...B?.listen_workspace?{}:{required:"Channel is required"}},viewOnly:f,id:"channel",refreshOptions:()=>z("channel"),refreshTooltip:"Refresh Channels"})}),["public_channel_message_mention","private_channel_message_mention"].includes(B.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{name:"properties.username",control:P,meta:{options:Tn((T||[]).map(J=>{let ee="";return J.real_name&&J.name?ee=`${J.real_name} (${J.name})`:ee=J.real_name||J.name||"",{id:J.id,name:ee}})),displayProps:{loading:_,refreshing:b},displayName:"Select User",value:"",searchFieldPlaceholder:"Search User",placeholder:"Select User",description:"Triggers the workflow when this user is mentioned. Specify either a Username, a Highlight Word, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.word");return!J&&(!ee||ee.trim()==="")?"Either User selection or Highlight Word is required":!0}},viewOnly:f,id:"user",virtualized:!0,refreshOptions:()=>z("user"),refreshTooltip:"Refresh Users",handleChange:()=>{L("properties.word")}})}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Mr,{name:"properties.word",control:P,viewOnly:f,meta:{displayName:"Highlight Word",placeholder:"Enter text...",description:"Triggers the workflow when this word is mentioned (case-insensitive). Specify either a Highlight Word, a Username, or both. If both are set, the workflow triggers only when both appear in the message."},validationRules:{validate:J=>{const ee=k("properties.username"),le=J;return(!le||le.trim()==="")&&!ee?"Either Highlight Word or User selection is required":!0}},handleChange:()=>{L("properties.username")}})})]}),d.jsx(Ul,{message:`Invite ${Q?"the Boltic app":"your bot"} to your Slack channel to receive events. In the channel, type: /invite @${Q?"Boltic":Y||"your-app-name"}`}),B?.event!=="app_mention"&&d.jsxs(d.Fragment,{children:[d.jsxs(E.Grid,{sx:{mt:1,...mi},children:[d.jsx(gn,{label:"Listen for Bot Messages",description:co("If no, only messages sent by users will trigger the Workflow. If yes, messages sent by users and slackbots will trigger the Workflow."),sx:{fontSize:14,fontWeight:400,color:n.palette.text.primary}}),d.jsx(hr,{name:"properties.listen_for_bot_message",control:P,render:({field:J})=>d.jsx(E.FormControlLabel,{label:J.value?"On":"Off",labelPlacement:"start",control:d.jsx(E.Switch,{...J,checked:!!J.value,disabled:f}),sx:{mr:0,ml:2},componentsProps:{typography:{variant:"smNormal"}}})})]}),B?.listen_for_bot_message&&d.jsx(Ul,{textColor:n.palette.text.tertiary,variant:"warning",message:"Avoid infinite loops! If your workflow posts messages to the same channel that triggers it, and 'Listen for Bot Messages' is enabled, it will create an endless loop. Consider disabling bot message listening or posting to a different channel."})]})]})]})})]})}),are=({field:e,items:t,type:r,nodeId:n,viewOnly:i=!1,eventType:o,handleArrayItemDelete:s,validationRules:a={},isLoop:l})=>{const u=E.useTheme(),{control:c,formState:{errors:f}}=Rr(),p=C.useMemo(()=>t?.map((h,A)=>`${n}-${e}-${Date.now()}-${A}`),[n,e,t?.length]);return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{py:1},alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:11,children:d.jsx(hr,{name:`properties.${o}.${e}.${A}`,control:c,rules:a,render:({field:g})=>d.jsx(fo,{...g,id:n,fullWidth:!0,required:e==="emails",name:"email",viewOnly:i,label:"Email",isLoop:l,errorMsg:f.properties?.[o]?.[e]?.[A]?.message,showSuggestions:!0,helperText:In(r,e),editorId:`${r}-${e}-${A}`,__withFieldValueControlApplied:!0})})}),d.jsx(E.Grid,{item:!0,xs:1,sx:{display:"flex",justifyContent:"center",alignSelf:"flex-end",paddingBottom:"2px"},children:e==="emails"&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-email-button",sx:{p:.75,width:28,height:28,"& path":{fill:u.palette.neutral.solid.bg},"&:hover path":{fill:u.palette.error[60]},"&:hover":{backgroundColor:"transparent"}},disabled:i,onClick:()=>s(e,A),children:d.jsx(Ue,{src:"ic_delete",width:20,height:20})})})]},p[A]))})},Bot=e=>{const{field:t,eventType:r,viewOnly:n=!1}=e,i=`properties.${r}.${t}`,{watch:o,setValue:s,unregister:a}=Rr(),{setFieldControlState:l}=aa(),u=o(i),[c,f]=C.useState("BOLTIC_AI"),p=C.useRef([]);C.useEffect(()=>{u==="BOLTIC_AI"||u==="BOLTIC_AI_IGNORE"?f(u):Array.isArray(u)&&f("specific")},[u]);const h=A=>{const g=A.target.value;if(f(g),l(i,g),g==="specific"){const m=Array.isArray(u)&&u.length>0?u:p.current.length>0?p.current:[""];s(i,m)}else Array.isArray(u)&&(p.current=u,u.forEach((m,O)=>{a?.(`${i}.${O}`)}),a?.(i)),s(i,g)};return d.jsxs(E.Stack,{spacing:1.5,children:[d.jsx(E.FormControl,{fullWidth:!0,disabled:n,children:d.jsxs(E.Select,{value:c,onChange:h,children:[d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI",children:"Have AI generate a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"BOLTIC_AI_IGNORE",children:"Do not include a value for this field"}),d.jsx(E.MenuItem,{sx:{py:.8},value:"specific",children:"Set a specific value for this field"})]})}),c==="specific"&&d.jsx(are,{...e})]})},jot=e=>{const{MCP_INTEGRATION_FORM:t}=aa();return t?d.jsx(Bot,{...e}):d.jsx(are,{...e})},lre=C.forwardRef(({property:e,viewOnly:t=!1,value:r,onChange:n},i)=>{const o=E.useTheme(),s=a=>{switch(a){case"add_workflow_link":return"Include Boltic Link at the end of the message";case"pause_workflow":return"Pause the Workflow, once this activity has completed its execution";default:return""}};return d.jsx(E.Grid,{item:!0,xs:12,ref:i,children:d.jsx(E.FormControlLabel,{label:s(e),sx:{display:"block",mr:0,"& .MuiFormControlLabel-label":{fontSize:a=>a.typography.xsNormal.fontSize,color:a=>a.typography.allVariants.color}},control:d.jsx(E.Checkbox,{sx:{p:0,"& .MuiSvgIcon-root":{fontSize:16}},icon:d.jsx(Ue,{src:"ic_unchecked",width:16,height:16,sx:{path:{fill:o.palette.common.white}}}),checkedIcon:d.jsx(Ue,{src:"ic_checked",width:16,height:16}),disabled:t,checked:r,onChange:n})})})}),$ot=Xi(({label:e,type:t,eventKey:r,required:n=!1,showExpandOption:i=!0,errorMsg:o="",suggestionsData:s,isLoop:a,viewOnly:l=!1,value:u,onChange:c})=>{const{loopSuggestionsData:f={}}=pt.useSelector(p=>p.loopActivity);return d.jsxs(E.Box,{children:[d.jsxs(E.Grid,{sx:{...mi},children:[d.jsx(gn,{required:n,label:e,description:co(In(t,"body"))}),d.jsx(E.Typography,{variant:"xsBold",children:d.jsx(E.Link,{href:"https://api.slack.com/block-kit",target:"_blank",rel:"noopener noreferrer",underline:"none",color:p=>p.palette.primary.main,children:"How to use Slack Block Builder?"})})]}),d.jsx($i,{size:"md",language:"json",showSuggestions:!0,viewOnly:l,value:u,handleChange:p=>c(p),id:`${t}-${r}-body`,suggestionsData:a?f:s,showExpandOption:i}),!!o&&d.jsx(E.FormHelperText,{error:!0,children:o})]})},""),Uot=C.forwardRef((e,t)=>{const r=pt.useDispatch(),n=E.useTheme(),{control:i,setValue:o,watch:s,clearErrors:a,formState:{errors:l}}=Rr(),u=s("properties");hA(s,o);const{VORTEX_MAIN_URL:c,ENTITY_ID:f,TESSERACT_MAIN_URL:p,FRONTEND_URL:h,WORKFLOW_URLS:A,type:g,id:m,isLoop:O=!1,INTEGRATION_DATA:y,viewOnly:T=!1,openIntegrationDrawer:v}=e,[_,x]=C.useState([]),[b,w]=C.useState(!1),[R,I]=C.useState(!1),[P,k]=C.useState(!1),[N,L]=C.useState([]),[M,B]=C.useState([]),[H,j]=C.useState("Query Params"),[X,F]=C.useState(!1),[V,G]=C.useState(!1),[D,$]=C.useState(!1),U=D?Bb:Bb.filter(oe=>oe.value),q=async()=>{w(!0);const oe={page_size:999,current_page:1,type:"BOTH"},ae=Xt(p,"/v1/integrations/entity/SLACK_V2");Qt.get(ae,{params:oe}).then(({data:re})=>{const Z=io(re.data,["integration_meta"]);x(Z)}).catch(re=>{sr(re,r)}).finally(()=>{w(!1)})},z=async(oe,ae,re=!1)=>{I(!0);let Z=Xt(c,`/v1.0/${f}`,"/implementations/choices");re&&(Z+="?refresh=true");try{const te=await Qt.post(Z,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Nf,operation:"get",type:ae===Yo.SEND_PUBLIC_CHANNEL_MESSAGE?"public_channel":"private_channel"}});L(Tn(te.data))}catch(te){L([]),sr(te,r)}finally{I(!1)}},W=async(oe,ae=!1)=>{I(!0);let re=Xt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(re+="?refresh=true");try{const[Z,te]=await Promise.all([Qt.post(re,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Nf,operation:"get",type:"public_channel"}}),Qt.post(re,{data:{secret:oe,input_field_id:"channel",selected_api:"slackAPI",fields_to_fill:Nf,operation:"get",type:"private_channel"}})]),se=[...Z.data,...te.data];L(Tn(se))}catch(Z){sr(Z,r)}finally{I(!1)}},Q=async(oe,ae=!1)=>{k(!0);let re=Xt(c,`/v1.0/${f}`,"/implementations/choices");ae&&(re+="?refresh=true");try{const Z=await Qt.post(re,{data:{secret:oe,input_field_id:"user",selected_api:"slackAPI",fields_to_fill:ck,operation:"get"}});B(Z.data.map(te=>({title:te.real_name?`${te.real_name} (${te.name})`:te.name,value:te.id})))}catch(Z){sr(Z,r)}finally{k(!1)}},Y=(oe,ae)=>{const re=u[u.event][oe].filter((Z,te)=>te!==ae);o("properties",{...u,[u.event]:{...u[u.event],[oe]:re}})},J=(oe,ae)=>{o("properties",{...u,[u.event]:{...u[u.event],[oe]:[...u[u.event][oe],ae]}})},ee=oe=>{o(`properties.${u.event}.${oe}`,null)},le=oe=>Ice[oe],ne=async(oe,ae,re="",Z=!1)=>{vt(oe)||vt(ae)||(re==="Channel"?F(!0):re==="Users"&&G(!0),!vt(oe)&&!vt(ae)&&[Yo.SEND_PUBLIC_CHANNEL_MESSAGE,Yo.SEND_PRIVATE_CHANNEL_MESSAGE].includes(ae)?await z(oe,ae,Z):ae===Yo.SEND_USER_MESSAGE?await Q(oe,Z):ae===Yo.SET_CHANNEL_TOPIC?await W(oe,Z):ae===Yo.INVITE_USERS&&(re==="Channel"?await W(oe,Z):re==="Users"?await Q(oe,Z):(!re||re==="")&&await Promise.all([Q(oe,Z),W(oe,Z)])),re==="Channel"?F(!1):re==="Users"&&G(!1))},ue=oe=>{const{slack_auth_id:ae,event:re}=u;ne(ae,re,oe,!0)};C.useEffect(()=>{vt(u)||(u.event===Yo.SEND_PRIVATE_CHANNEL_MESSAGE&&u?.send_private_channel_message?.attachment&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[u.send_private_channel_message.attachment]),u.event===Yo.SEND_PRIVATE_CHANNEL_MESSAGE&&!u?.send_private_channel_message?.attachments&&(u.send_private_channel_message.attachments=[]),u.event===Yo.SEND_PUBLIC_CHANNEL_MESSAGE&&u?.send_public_channel_message?.attachment&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[u.send_public_channel_message.attachment]),u.event===Yo.SEND_PUBLIC_CHANNEL_MESSAGE&&!u?.send_public_channel_message?.attachments&&(u.send_public_channel_message.attachments=[]),q())},[]),C.useEffect(()=>{y?._id&&y?.meta?.entity==="SLACK_V2"&&(q(),o("properties.slack_auth_id",y._id,{shouldValidate:!0}))},[y]),C.useEffect(()=>{if(_.length>0&&u?.slack_auth_id){const oe=_.find(ae=>ae.id===u.slack_auth_id);$(oe?.integration_meta?.type==="oauth2")}else $(!1)},[_,u?.slack_auth_id]),C.useEffect(()=>{const{slack_auth_id:oe,event:ae}=u;ne(oe,ae)},[u.event,u.slack_auth_id]);const Oe=u[u.event]?.attachments==="BOLTIC_AI_IGNORE"||u[u.event]?.attachments==="BOLTIC_AI",ve=u[u.event]?.emails==="BOLTIC_AI_IGNORE"||u[u.event]?.emails==="BOLTIC_AI";return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.slack_auth_id",control:i,meta:{options:Tn(_),displayProps:{loading:b},displayName:"Slack Account",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:p,FRONTEND_URL:h,ENTITY_ID:f,openIntegrationDrawer:v,addNewButtonText:"Add new account",searchFieldPlaceholder:"Search Slack account",authType:"SLACK_V2",description:`Slack is a secure partner with Boltic. Your credentials are encrypted & can be removed at any time. <a href="${A?.GYRATE_MAIN_URL}/integrations/Communication/slack" target="_blank" rel="noopener noreferrer" style="color: ${n.palette.primary.main}">View setup guide</a>`,placeholder:"Select Slack Account"},validationRules:{required:"Slack account is required"},handleChange:({field:oe,value:ae})=>{vt(ae)&&(L([]),B([])),vt(ae)?o("properties.event",""):o(oe,ae)},viewOnly:T,id:"slack_auth_id"})}),u.slack_auth_id&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.event",control:i,meta:{options:Vue,displayProps:{loading:b},displayName:"Operation",description:"This is performed when the Workflow runs.",searchFieldPlaceholder:"Search operation",placeholder:"Select a operation"},validationRules:{required:"Operation is required"},handleChange:({value:oe})=>{o("properties",{...u,[oe]:le(oe),event:oe}),L([]),B([])},viewOnly:T})})]})}),u.slack_auth_id&&u.event&&d.jsx(E.Divider,{}),u.slack_auth_id&&u.event&&d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[!vt(u.slack_auth_id)&&d.jsxs(d.Fragment,{children:[u.event===Yo.CUSTOM&&d.jsx(d.Fragment,{children:d.jsx(Tl,{id:m,type:g,isLoop:O,viewOnly:T,customSelectedTab:H,setCustomSelectedTab:j})}),_ce.includes(u.event)&&d.jsx(Mr,{required:!0,id:m,name:`properties.${u.event}.channel_name`,control:i,meta:{displayName:"Channel Name",description:"Name for the channel to be created. Channel names are normalized by converting to lowercase, replacing any non-allowed characters with hyphens or underscore, and truncating to 80 characters.",placeholder:"Enter channel name"},validationRules:{required:"Chanel name is required"},viewOnly:T,editorId:`${g}-slack-channel_name`,showSuggestions:!0,isLoop:O},u.event),bce.includes(u.event)&&d.jsx(lf,{required:!0,name:`properties.${u.event}.channel_id`,id:m,control:i,isLoading:R,type:g,label:"Channel",viewOnly:T,isLoop:O,virtualized:!0,helperTextForDropdown:D?"channel_id":"channel_id_for_bot",helperTextForTextField:"dynamic_channel_id",isMultiple:!1,data:N,value:u[u.event]?.channel_id,onTabChange:()=>{ee("channel_id")},eventName:u.event,fieldName:"channel_id",refreshData:ue,refreshing:X,willRefresh:!0,refreshTooltip:"Refresh Channels"},u.event),u.event===Yo.SEND_PRIVATE_CHANNEL_MESSAGE&&d.jsx(Ul,{message:`To send a message to a private channel, please invite ${D?"the Boltic app":"your bot"} to the channel.`}),[Yo.SET_CHANNEL_TOPIC].includes(u.event)&&d.jsx(Mr,{required:!0,id:m,name:`properties.${u.event}.topic`,control:i,meta:{displayName:"Topic",description:"Topic to be set for the Slack channel",placeholder:"Enter topic"},validationRules:{required:"Topic is required"},viewOnly:T,editorId:`${g}-slack-topic`,showSuggestions:!0,isLoop:O}),wce.includes(u.event)&&d.jsx(lf,{name:`properties.${u.event}.user_id`,control:i,required:!0,isMultiple:!0,viewOnly:T,isLoading:P,id:m,type:g,isLoop:O,label:"Users",helperTextForTextField:"user_id",virtualized:!0,helperTextForDropdown:u.event===Yo.SEND_USER_MESSAGE?"user_ids_message":"user_ids_invite",data:M,value:u[u.event]?.user_id,onTabChange:()=>{ee("user_id")},eventName:u.event,fieldName:"user_id",refreshData:ue,refreshing:V,willRefresh:!0,refreshTooltip:"Refresh Users",handleChange:oe=>{const{field:ae,value:re}=oe;o(ae,re,{shouldValidate:!0})}}),Cce.includes(u.event)&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:`properties.${u.event}.body_type`,control:i,validationRules:{required:"Message Body type is required"},meta:{options:Due,displayName:"Message Body Type",description:In(g,"body_type"),searchFieldPlaceholder:"Search",placeholder:"Select Message Body Type"},viewOnly:T,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae===y0.BLOCKS?ik:"",blocks:ae===y0.BLOCKS?[]:u[u.event].blocks}),a(`properties.${u.event}.body`)}})}),d.jsxs(E.Grid,{item:!0,xs:12,children:[u[u.event]?.body_type==="text"&&d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Mr,{required:!0,id:m,multiline:!0,name:`properties.${u.event}.body`,control:i,meta:{displayName:"Message Body",description:"Specify text / Define Slack Blocks of the message to send",placeholder:"Type or add suggestion"},validationRules:{required:"Message Body is required"},viewOnly:T,editorId:`${g}-slack-body`,showSuggestions:!0,isLoop:O,size:"md"})}),d.jsx(E.Grid,{item:!0,xs:12,children:u.event!==Yo.SEND_USER_MESSAGE&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Stack,{width:"100%",direction:"row",alignItems:"center",justifyContent:"space-between",sx:{"& > .MuiStack-root > .MuiStack-root":{pb:0}},children:[d.jsx(gn,{label:"Attachments",description:"The total attachments size limit is 1GB. The maximum number of attachments is 5."}),!Oe&&d.jsx(E.IconButton,{disabled:u[u.event].attachments?.length>=5,onClick:()=>J("attachments",""),sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:n.palette.primary.main}}})})]}),d.jsx(nN,{nodeId:m,type:g,isLoop:O,field:`properties.${u.event}.attachments`})]},u.event)})]}),u[u.event]?.body_type===y0.BLOCKS&&d.jsxs(d.Fragment,{children:[d.jsx(E.Grid,{item:!0,xs:12,sx:{marginBottom:"0.5rem"},children:d.jsx(qt,{required:!0,name:`properties.${u.event}.block_type`,control:i,meta:{options:Dce,displayName:"Slack Block Type",searchFieldPlaceholder:"Search Block Type",placeholder:"Select Block Type",description:In(g,"block_type")},disabled:T,validationRules:{required:"Slack Block Type is required"},handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],body:ae==="message"?ik:Tce,blocks:[]})},viewOnly:T,id:g})}),d.jsx(hr,{name:`properties.${u.event}.body`,control:i,render:({field:oe})=>d.jsx($ot,{...oe,id:m,label:"Slack Blocks",viewOnly:T,type:g,isLoop:O,eventKey:u.event,required:!0,showExpandOption:!0,errorMsg:l.properties?.[u.event]?.body?.message})})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:`properties.${u.event}.send_as_bot`,control:i,meta:{options:U,displayName:"Send as Bot",description:In(g,"send_as_bot"),placeholder:"Select Send as Bot",showSearch:!1},viewOnly:T,id:g,handleChange:oe=>{const{value:ae}=oe;o(`properties.${u.event}`,{...u[u.event],send_as_bot:ae,bot_name:"",bot_icon:""})}})}),u?.[u.event]?.send_as_bot&&d.jsxs(d.Fragment,{children:[d.jsx(Mr,{id:m,name:`properties.${u.event}.bot_name`,control:i,meta:{displayName:"Bot Name",description:"Specify the bot name which appears as a bold username above the message inside Slack. Defaults to Boltic.",placeholder:"Enter bot name"},viewOnly:T,editorId:`${g}-slack-bot_name`,showSuggestions:!0,isLoop:O}),d.jsx(Mr,{id:m,name:`properties.${u.event}.bot_icon`,control:i,meta:{displayName:"Bot Icon",description:"Either an image url or an emoji available to your team (surrounded by :). For example, https://site.com/icon_256.png or :robot_face:",placeholder:"Enter bot icon"},viewOnly:T,editorId:`${g}-slack-bot_icon`,showSuggestions:!0,isLoop:O})]}),d.jsx(Mr,{id:m,name:`properties.${u.event}.thread_ts`,control:i,meta:{displayName:"Thread Id",description:"If you want this to be part of a thread, you'll need the timestamp (Ts) of the parent message. For example: 1345232312616.1231232",placeholder:"Enter thread id"},viewOnly:T,editorId:`${g}-slack-thread_ts`,showSuggestions:!0,isLoop:O}),u[u.event]?.thread_ts&&u[u.event]?.thread_ts!==""&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:`properties.${u.event}.send_with_thread`,control:i,meta:{options:Bb,displayName:"Send Channel Message?",description:In(g,"send_with_thread"),placeholder:"Select Send Channel Message",showSearch:!1},viewOnly:T,id:g})}),d.jsx(hr,{name:`properties.${u.event}.add_workflow_link`,control:i,render:({field:oe})=>d.jsx(lre,{...oe,viewOnly:T,property:"add_workflow_link",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.body_type===y0.BLOCKS&&u?.[u.event].body!==""&&["message",void 0].includes(u?.[u.event]?.block_type)&&d.jsxs(d.Fragment,{children:[d.jsx(hr,{name:`properties.${u.event}.pause_workflow`,control:i,render:({field:oe})=>d.jsx(lre,{...oe,viewOnly:T,property:"pause_workflow",onChange:ae=>{oe.onChange(ae.target.checked)}})}),u[u.event]?.pause_workflow&&d.jsx(Ul,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),u?.[u.event]?.pause_workflow&&d.jsx(Ul,{message:'To enable interactive buttons in Slack, include buttons with action IDs "yes" and "no" in your block layout.'})]}),[Yo.FIND_BY_EMAIL].includes(u.event)&&d.jsxs(E.Grid,{item:!0,xs:12,children:[d.jsxs(E.Box,{sx:{display:"flex",alignItems:"center"},children:[d.jsx(E.FormControl,{fullWidth:!0,children:d.jsx(gn,{label:"Add Emails below"})}),!ve&&d.jsx(E.IconButton,{onClick:()=>J("emails",""),disabled:T,sx:{border:oe=>`1px solid ${oe.palette.grey.brainstem}`,width:24,height:24},color:"primary",children:d.jsx(Ue,{src:"ic_plus",width:16,height:16,sx:{path:{fill:n.palette.primary.main}}})})]}),d.jsx(jot,{eventType:u.event,handleArrayItemDelete:Y,nodeId:m,type:g,viewOnly:T,field:"emails",items:u[u.event].emails,isLoop:O,validationRules:{required:"Email is required"}})]})]}),!O&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Ui,{viewOnly:T,type:g})})]})})]})}),Hot=C.forwardRef((e,t)=>{const{viewOnly:r=!1}=e,{control:n,formState:{errors:i}}=Rr();return d.jsx(En,{children:d.jsx(hr,{name:"properties.timeout",control:n,rules:{required:"Timeout is required",min:{value:1,message:"Timeout must be greater than or equal to 1"},max:{value:2160*60*60*1e3,message:"Timeout must be less than or equal to 90 days (7,776,000 seconds)"}},render:({field:o})=>d.jsx(fo,{...o,label:"Timeout(seconds)",viewOnly:r,fullWidth:!0,type:"number",id:"timeout",required:!0,errorMsg:i.properties?.timeout.message,value:o.value/1e3||"",onChange:s=>o.onChange(Number(s.target.value)*1e3),inputProps:{step:1,min:1,max:2160*60*60*1e3},helperText:"The time to wait before starting the next Activity Execution"})})})}),Vot=({field:e,items:t,type:r,nodeId:n,requiredValue:i,autoFocus:o,hideLabel:s,placeholder:a="",viewOnly:l=!1,name:u,handleArrayItemDelete:c})=>{const f=E.useTheme(),{control:p}=Rr();return d.jsx(d.Fragment,{children:t.map((h,A)=>d.jsxs(E.Grid,{container:!0,sx:{mb:1},alignItems:"flex-start",justifyContent:"space-between",children:[d.jsx(E.Grid,{item:!0,xs:2.4,children:d.jsx(qt,{required:!0,name:`${u}.${A}.caseType`,control:p,meta:{options:Yue,displayName:s?"":"Type",searchFieldPlaceholder:"Search type",description:In(r,"from_type"),placeholder:s?"":"Select Type"},validationRules:{required:"Type is required"},viewOnly:l,id:r})}),d.jsx(E.Grid,{item:!0,xs:8.2,children:d.jsx(Mr,{meta:{displayName:!s&&"Case",placeholder:`${a} ${A+1}`},name:`${u}.${A}.caseValue`,control:p,validationRules:{required:"Case value is required"},autoFocus:o,id:n,required:i,viewOnly:l,showSuggestions:!0,helperText:In(r,e),editorId:`${r}-${e}-${A}`})}),d.jsx(E.Grid,{item:!0,xs:1,children:i&&t.length>1&&d.jsx(E.IconButton,{"data-testid":"delete-switch-button",sx:{width:28,height:28,position:"relative",top:24,"&:hover":{backgroundColor:"transparent","& path":{fill:f.palette.error[60]}}},onClick:()=>{c(e,A)},disabled:l,children:d.jsx(Ue,{src:"ic_delete",sx:{"& path":{fill:f.palette.neutral.solid.bg}},width:20,height:20})})})]},`switch-array-${A}`))})},Got=C.forwardRef((e,t)=>{const{type:r,id:n,isLoop:i,viewOnly:o=!1}=e,{control:s,setValue:a,watch:l,formState:{errors:u}}=Rr(),c=l("properties"),f=l("properties.next_counter"),p=l("properties.cases"),h=m=>{const O=l(`properties.${m}`);a("properties.next_counter",f+1),a(`properties.${m}`,[...O,{caseKey:`case${f+1}Handle`,caseValue:"",caseType:"string"}])},A=(m,O)=>{const y=l(`properties.${m}`).filter((T,v)=>v!==O);a(`properties.${m}`,y)},g=m=>/^.*\{\{[^{}]+\}\}.*$/.test(m);return d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(hr,{name:"properties.condition",control:s,rules:{required:"Condition is required",validate:m=>g(m)?!0:"Invalid condition. Dynamic placeholders {{ }} are required."},render:({field:m})=>d.jsx(fo,{...m,id:n,viewOnly:o,showSuggestions:!0,label:"Condition",name:"condition",editorId:`${r}-condition`,placeholder:"Enter a condition",fullWidth:!0,isLoop:i,required:!0,errorMsg:u.properties?.condition?.message,helperText:In(r,"condition")})})})})}),c.condition&&g(c.condition)&&d.jsx(E.Divider,{}),c.condition&&g(c.condition)&&d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsxs(E.Grid,{item:!0,xs:12,pb:1,children:[d.jsx(gn,{label:"Cases"}),d.jsx(Vot,{placeholder:"Case",nodeId:n,viewOnly:o,type:r,field:"cases",requiredValue:!0,isLoop:i,items:p.filter(m=>m.caseValue!=="default"),name:"properties.cases",handleArrayItemDelete:A},p.length),d.jsxs(E.Button,{variant:"text",disabled:o,onClick:()=>h("cases"),sx:{color:m=>m.palette.primary[60],mt:1,"&:hover":{backgroundColor:"transparent",color:m=>m.palette.primary[50],"& .MuiTypography-root":{color:m=>m.palette.primary[50]},"& svg path":{fill:m=>m.palette.primary[50]}}},disableFocusRipple:!0,disableTouchRipple:!0,disableRipple:!0,disableElevation:!0,children:[d.jsx(Ue,{src:"ic_plus",sx:{fontSize:"18px",marginRight:"5px",path:{fill:"currentColor"}}}),d.jsx(E.Typography,{variant:"smNormal",sx:{alignItems:"center"},children:"Add"})]})]}),d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Ui,{viewOnly:o,type:r})})]})})]})}),Wot=C.forwardRef((e,t)=>{const{type:r,VORTEX_MAIN_URL:n,ENTITY_ID:i,suggestionsData:o,isLoop:s=!1,viewOnly:a=!1}=e,{loopSuggestionsData:l={}}=pt.useSelector(f=>f.loopActivity),{control:u,formState:{errors:c}}=Rr();return d.jsx(En,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(hr,{name:"properties.template",control:u,rules:{required:"Template is required"},render:({field:f})=>d.jsx($i,{...f,label:"Template",suggestionLabel:"Template",id:`${r}-template`,size:"xl",viewOnly:a,activityType:r,VORTEX_MAIN_URL:n,ENTITY_ID:i,language:"html",helperText:d.jsxs(E.Box,{children:["Create dynamic web templates easily using Nunjucks, a powerful JavaScript templating engine.see",d.jsx(E.Link,{href:"https://mozilla.github.io/nunjucks/",target:"_blank",children:" Nunjucks Docs"})]}),error:!!c.properties?.template?.message,errorMsg:c.properties?.template?.message,handleChange:p=>f.onChange(p),required:!0,showSuggestions:!0,suggestionsData:s?l:o,showExpandOption:!0})})}),!s&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Ui,{viewOnly:a,type:r})})]})})}),Qot=Xi(Wot),zot=C.forwardRef((e,t)=>{const r=pt.useDispatch(),{id:n,type:i,TESSERACT_MAIN_URL:o,ENTITY_ID:s,FRONTEND_URL:a,INTEGRATION_DATA:l,viewOnly:u=!1,openIntegrationDrawer:c}=e,[f,p]=C.useState([]),[h,A]=C.useState(!1),{control:g,resetField:m,watch:O,setValue:y}=Rr(),T=O("properties.auth_type"),v=()=>{A(!0);const _={page_size:999,current_page:1,type:"SOURCE"},x=Xt(o,"/v1/integrations/entity/AUTHENTICATION");Qt.get(x,{params:_}).then(({data:b})=>{const w=io(b.data,["integration_meta"]),R=yT(w);p(vT(R))}).catch(b=>{sr(b,r)}).finally(()=>{A(!1)})};return C.useEffect(()=>{l?._id&&l?.meta?.entity==="AUTHENTICATION"&&(v(),y("properties.auth_id",l._id,{shouldValidate:!0}))},[l]),C.useEffect(()=>{!vt(T)&&T!==Ml.NONE?v():m("properties.auth_id")},[T]),d.jsxs(E.Stack,{gap:2.5,children:[d.jsx(Si,{children:d.jsxs(E.Grid,{container:!0,gap:1.5,children:[d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.auth_type",control:g,meta:{options:e1,displayName:"Authentication Type",searchFieldPlaceholder:"Search authentication type",description:"Select Authentication Type (Basic Auth, Header Auth or None)",placeholder:"Select Authentication type"},validationRules:{required:"Auth type is required"},viewOnly:u,id:i})}),T&&T!==Ml.NONE&&d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(qt,{required:!0,name:"properties.auth_id",control:g,meta:{options:Tn(f),displayProps:{loading:h},displayName:"Authentication",value:"",htmlProps:{showAddNew:!0},TESSERACT_MAIN_URL:o,FRONTEND_URL:a,ENTITY_ID:s,openIntegrationDrawer:c,addNewButtonText:"Add new",searchFieldPlaceholder:"Search authentication",authType:"AUTHENTICATION",description:"Select Authentication you have saved in the Secrets. You can also create a new Secret using Add new button. Your credentials are encrypted & can be removed at any time.",placeholder:"Select Authentication"},validationRules:{required:"Authentication is required"},viewOnly:u,id:i,groupBy:"integration_meta.auth_type"})})]})}),d.jsx(E.Divider,{}),d.jsx(En,{children:d.jsx(E.Grid,{container:!0,gap:1.5,children:d.jsx(E.Grid,{item:!0,xs:12,children:d.jsx(Yu,{name:"properties.test_payload",label:"Test Trigger Payload",viewOnly:u,required:!0,id:n,validationRules:{required:"Value is required"},fullScreen:!0,showSuggestions:!0,excludePayloadSuggestions:!0})})})})]})}),Xot=Object.freeze(Object.defineProperty({__proto__:null,CopilotWebhook:l7e,FyndAIPIM:iq,FyndCommerceB2B:lN,FyndEngage:cN,FyndKonnect:fN,FyndTMS:oq,apiActivity:tBe,askAgent:lBe,bolticStorageActivity:cBe,bolticTableActivity:XBe,boltic_storage:uBe,boltic_table:dBe,browserbase:YBe,calendly:KBe,converterActivity:a7e,emailActivity:f7e,executeChildWorkflow:h7e,fp_webhook:S7e,functionActivity:b7e,gmailActivity:B7e,gmail_trigger:F7e,googleCalendarActivity:WZe,googleMeet:QZe,googleSheetsReadActivity:zZe,googleSheetsWriteActivity:XZe,gpt:YZe,graphql:KZe,http:ZZe,ifActivity:oJe,logConsole:lJe,loop:dJe,mapper:pJe,mcp:OJe,monitor:vJe,parallel:TJe,response:xJe,schedule:PJe,serverless:sre,slackActivity:Uot,slack_trigger:Mot,sleep:Hot,switchActivity:Got,template:Qot,webhook:zot},Symbol.toStringTag,{value:"Module"})),qot=C.forwardRef((e,t)=>{const{type:r,formData:n,selectedNode:i,onClose:o,isLoop:s=!1,cloudRef:a,suggestionsData:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleRunActivity:h,handleCompleteSetup:A,MCP_INTEGRATION_FORM:g=!1,onSubmit:m}=e,{viewOnly:O}=pt.useSelector(H=>H.canvas),{loopSuggestionsData:y={}}=pt.useSelector(H=>H.loopActivity),{form:T,formSchema:v,loading:_,handleFocus:x,handleChange:b,handleCustom:w,setForm:R,handleCancel:I,setFormSchema:P,GraphQLInspectorModal:k}=wx({formData:n,isLoop:s,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:o,handleRunActivity:h,handleCompleteSetup:A,openIntegrationDrawer:u,onSubmit:m,MCP_INTEGRATION_FORM:g}),N=()=>{},L=(H,j="")=>{if(!s){const X={type:r,name:i.data.name,properties:H};e.onSubmit?.(X,j)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:T,type:r}),validateForm:()=>!0,resetFormData:()=>{R({}),P([])}}),[T]);const B=Ix(v)?Dx(v,T):v;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:a,name:`${i.id}-db-form`,schema:g?v:B,onSubmit:L,onChange:b,onFocus:x,onReset:N,onCancel:I,onCustom:w,form:T,isLoading:_||p,suggestions:s||g?y:l,useDefaultButtons:!1,viewOnly:O,MCP_INTEGRATION_FORM:g,MCP_EXCLUDED_FIELDS:of}),d.jsx(k,{})]})}),Yot=Xi(qot),Kot=C.forwardRef(({type:e,formData:t,onSubmit:r,selectedNode:n,onClose:i,cloudRef:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,isLoading:u=!1,setPollingInterval:c},f)=>{const{viewOnly:p}=pt.useSelector(k=>k.canvas),{form:h,formSchema:A,loading:g,handleFocus:m,handleChange:O,handleCustom:y,setForm:T,handleCancel:v,setFormSchema:_,GraphQLInspectorModal:x}=wx({formData:t,selectedNode:n,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,onClose:i,openIntegrationDrawer:s,onSubmit:r,setPollingInterval:c});C.useImperativeHandle(f,()=>({getData:()=>({name:n.data.properties.activity_name,properties:h,type:e}),validateForm:()=>!0,resetFormData:()=>{T({}),_([])}}),[h]);const b=(k,N="")=>{const L=k,M={type:e,name:n.data.name,properties:{...L}};r?.(M,N)},w=()=>{},I=Ix(A)?Dx(A,h):A,P=h;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:o,name:`${n.data.name}-trigger-integration-form`,schema:I,onSubmit:b,onChange:O,onFocus:m,onReset:w,onCancel:v,onCustom:y,form:P,isLoading:g||u,useDefaultButtons:!1,viewOnly:p}),d.jsx(x,{})]})}),Zot=C.forwardRef((e,t)=>{const{type:r,formData:n,selectedNode:i,isLoop:o=!1,cloudRef:s,suggestionsData:a,onClose:l,openIntegrationDrawer:u,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,isLoading:p=!1,handleCompleteSetup:h,handleRunActivity:A,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O=!1}=e,{viewOnly:y}=pt.useSelector(j=>j.canvas),{loopSuggestionsData:T={}}=pt.useSelector(j=>j.loopActivity),{form:v,formSchema:_,loading:x,handleFocus:b,handleChange:w,handleCustom:R,setForm:I,handleCancel:P,setFormSchema:k,GraphQLInspectorModal:N}=wx({formData:n,isLoop:o,selectedNode:i,INTEGRATION_DATA:c,SET_INTEGRATION_DATA:f,onClose:l,handleRunActivity:A,handleCompleteSetup:h,openIntegrationDrawer:u,onSubmit:g,source:m,MCP_INTEGRATION_FORM:O}),L=()=>{},M=(j,X="")=>{if(O&&I(j),!o){const F={type:r,name:i.data.name,properties:j};e.onSubmit?.(F,X)}};C.useImperativeHandle(t,()=>({getData:()=>({name:i.data.properties.activity_name,properties:v,type:r}),validateForm:()=>!0,resetFormData:()=>{I({}),k([])}}),[v]);const H=Ix(_)?Dx(_,v):_;return d.jsxs(E.Box,{sx:{overflowY:"auto",height:"100%","& .MuiSwitch-root":{marginLeft:"7px"}},children:[d.jsx(bx,{ref:s,name:`${i.id}-integration-form`,schema:O?_:H,onSubmit:M,onChange:w,onFocus:b,onReset:L,onCancel:P,viewOnly:y,onCustom:R,form:v,isLoading:x||p,useDefaultButtons:!1,suggestions:o||O?T:a,MCP_INTEGRATION_FORM:O,MCP_EXCLUDED_FIELDS:of}),d.jsx(N,{})]})}),Jot=Xi(Zot),est={"blt-int.fynd-aipim":iq,"blt-int.fynd-konnect":fN,"blt-int.konnect":fN,"blt-int.fynd-engage":cN,"blt-int.engage":cN,"blt-int.fynd-commerce-b2b":lN,"blt-int.commerce-b2b":lN,"blt-int.fynd-tms":oq},ure=C.forwardRef((e,t)=>{const{type:r,selectedNode:n,formData:i,initialState:o,onSubmit:s,onClose:a,openIntegrationDrawer:l,ENTITY_ID:u,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isExecutionLoading:A=!1,isLoop:g=!1,viewOnly:m,actionRef:O,activityDataRef:y,handleRunActivity:T,handleCompleteSetup:v,setPollingInterval:_,methods:x,activityName:b,MCP_INTEGRATION_FORM:w=!1}=e,{VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,ATHENA_MAIN_URL:H,NEO_MAIN_URL:j,TRINITY_MAIN_DOMAIN:X}=c||{},F=D=>{let $=D;n.data.type===Ze.LOOP&&($=y.current?.getData());const U=zb($),q=U?.integration_slug||n?.data?.properties?.integration_slug;s({...n.data,type:n.data.type,name:b||n.data.name,properties:{...U,...q?{integration_slug:q}:{}},id:n.id})},V=n?.data?.properties?.integration_slug,G=V?est[V]:void 0;if(G)return g?d.jsx(G,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w}):d.jsx("form",{autoComplete:"off",style:{height:"100%"},onSubmit:x.handleSubmit(F),children:d.jsx(G,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w,NEO_MAIN_URL:j,TRINITY_MAIN_DOMAIN:X})});switch(r){case"CloudTrigger":return d.jsx(Kot,{id:n.id,ref:y,cloudRef:O,formData:i,onSubmit:s,initialState:o,isLoading:A,type:r,selectedNode:n,VORTEX_MAIN_URL:R,openIntegrationDrawer:l,ENTITY_ID:u,TESSERACT_MAIN_URL:P,onClose:a,FRONTEND_URL:k,SERVERLESS_URL:I,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,setPollingInterval:_});case"platformFdkActivity":case"applicationFdkActivity":case"customActivity":return d.jsx(Jot,{id:n.id,ref:y,cloudRef:O,formData:i,handleRunActivity:T,initialState:o,handleCompleteSetup:v,isLoading:A,onSubmit:s,openIntegrationDrawer:l,type:r,FRONTEND_URL:k,selectedNode:n,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,source:h,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"CloudDatabase":return d.jsx(Yot,{id:n.id,ref:y,cloudRef:O,formData:i,initialState:o,handleRunActivity:T,handleCompleteSetup:v,onSubmit:s,openIntegrationDrawer:l,type:r,FRONTEND_URL:k,isLoading:A,selectedNode:n,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,MCP_INTEGRATION_FORM:w,...g?{useDefaultButtons:!1}:{}});case"serverless":return d.jsx(sre,{id:n.id,ref:y,handleRunActivity:T,handleCompleteSetup:v,cloudRef:O,formData:i,isLoading:A,onSubmit:s,type:r,openIntegrationDrawer:l,FRONTEND_URL:k,initialState:o,selectedNode:n,ENTITY_ID:u,onClose:a,WORKFLOW_URLS:c,activity_id:n.data.activity_id,INTEGRATION_DATA:f,SET_INTEGRATION_DATA:p,isLoop:g,...g?{useDefaultButtons:!1}:{}});default:{const $={...Xot}[r];return $?(w&&C.useImperativeHandle(O,()=>({getData:()=>({name:n.data.properties.activity_name,properties:i,type:r}),validateForm:()=>!0,handleSubmit:async()=>{const U=await x?.trigger();if(U){let q=x?.getValues();q=u1(q,of),F(q)}return U},isValidated:x?.formState?.isValid}),[i,r,n.data.properties.activity_name,x]),g?d.jsx($,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w}):d.jsx("form",{autoComplete:"off",style:{height:"100%"},onSubmit:x.handleSubmit(F),children:d.jsx($,{ref:y,formData:i,id:n.id,onSubmit:s,onClose:a,type:r,openIntegrationDrawer:l,initialState:o,ENTITY_ID:u,VORTEX_MAIN_URL:R,SERVERLESS_URL:I,TESSERACT_MAIN_URL:P,FRONTEND_URL:k,VORTEX_WEBHOOK_URL:N,VORTEX_SYNC_DOMAIN:L,HITMAN_PUBLIC_DOMAIN:M,HITMAN_PLTM_URL:B,INTEGRATION_DATA:f,WORKFLOW_URLS:c,ATHENA_MAIN_URL:H,SET_INTEGRATION_DATA:p,source:h,viewOnly:m,isLoop:g,MCP_INTEGRATION_FORM:w,NEO_MAIN_URL:j,TRINITY_MAIN_DOMAIN:X})})):null}}}),cre=({onSubmit:e,selectedNode:t,onClose:r,initialState:n,drawerWidth:i,setSelectedNode:o,openIntegrationDrawer:s,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,openDocs:u,setOpenDocs:c,source:f,actionRef:p,MCP_INTEGRATION_FORM:h=!1})=>{const A=E.useTheme(),g=pt.useDispatch(),m=Rt.useNodes(),{setNodes:O,getNode:y,getEdges:T}=Rt.useReactFlow(),v=p||C.useRef(null),_=C.useRef(null),x=C.useMemo(()=>_o(),[]),{activities:b,triggers:w,reserved_keywords:R,activity_names:I}=pt.useSelector(Ge=>Ge.activities),{canvasWorkflow:P,activityExecutionData:k,viewOnly:N=!1,triggerNodeTest:L}=pt.useSelector(Ge=>Ge.canvas),M=ui(b?.data?.data,w?.data?.data,t.data,"slug"),{ENTITY_ID:B,WORKFLOW_URLS:H,openAddonModal:j,currentSubscription:X}=Ii(),{workflow:F}=pt.useSelector(Ge=>Ge.workflows),V=f||F?.source||"",G=n1(t,V),D=rw({defaultValues:G,mode:"onChange"}),$=C.useRef(null),{analytics:U={}}=Ii(),[q,z]=C.useState(!1),[W,Q]=C.useState([]),[Y,J]=C.useState(!1),ee=C.useRef(null),{data:le}=m.find(Ge=>Ge.id===t?.id)||{},{blt_node_states:ne}=le||{},{test:ue="",setup_and_configure:Oe="",node:ve=""}=ne||{},[oe,ae]=C.useState(0),[re,Z]=C.useState([{label:"Setup & Configure",state:"default"},{label:"Test",state:""}]),{initialNodes:te=[]}=pt.useSelector(Ge=>Ge.workflows),se=C.useMemo(()=>{try{return!Rf.includes(t?.data?.type)}catch{return!0}},[t?.data?.type]);C.useEffect(()=>{const Ge=[{label:"Setup & Configure",state:"default"}];Z(se?[...Ge,{label:"Test",state:""}]:Ge),ae(0)},[se]),C.useEffect(()=>()=>{$.current&&clearTimeout($.current)},[]);const he=Ge=>{Z(nt=>nt.map((Et,yt)=>{const we=["setup_and_configure","test"][yt];return Ge[we]?{...Et,state:I6e(Ge[we])}:Et}))};C.useEffect(()=>{(Oe||ue||ve)&&he({setup_and_configure:Oe||"default",test:ue||"",node:ve||""})},[Oe,ue,ve]);const pe=C.useRef(!1),de=C.useRef(null);C.useEffect(()=>{if(t?.id)if(L?.nodeId===t.id){ae(1);const Ge=`${L.nodeId}-${L.runWithPrevious}`;if(de.current===Ge){g({type:Nb});return}de.current=Ge,Te(L.runWithPrevious),g({type:Nb}),pe.current=!0}else de.current=null,pe.current?pe.current=!1:ae(ve==="completed"&&se?1:0)},[t?.id,L?.nodeId,L?.runWithPrevious,ve,se]);const{VORTEX_MAIN_URL:xe}=H,[ge,Ee]=C.useState(!1),[ke,We]=C.useState(t?.data?.name||""),[$e,et]=C.useState(null),st=bn(x),it=bn(Dr.VERSION),[Re,qe]=C.useState(null),Ye=async Ge=>await dce(Ge.trim(),t.data.name,R,I)||null,Se=C.useRef(Da(Ge=>{g({type:Xr,payload:{open:!0,title:Ge,type:"error",width:"30rem",duration:3e3}})},300)).current,_e=async Ge=>{We(Ge);const nt=await Ye(Ge.trim());if(nt){et(nt),Se(nt);return}const Et=t.data.name;let yt=Mo(I);if(yt.includes(Et)){const Dt=yt.findIndex(we=>we===Et);yt=[...yt.slice(0,Dt),Ge.trim(),...yt.slice(Dt+1)]}else yt=[...yt,Ge.trim()];g({type:wi.SET_ACTIVITY_NAMES,payload:yt}),O(Dt=>{const Qe=JSON.stringify(Dt).replace(new RegExp(`{{${Et}`,"g"),`{{${Ge.trim()}`).replace(new RegExp(`result.${Et}`,"g"),`result.${Ge.trim()}`);return JSON.parse(Qe)}),et(null),K(Ge.trim())},be=()=>{["error","completed"].includes(ue)||x===jn.DRAFT&&Ra(O,t,{}),r(),c?.(!1)},K=Ge=>{const nt=_.current?.getData()||D.getValues();o(Et=>Et?{...Et,data:{...Et.data,name:Ge,properties:{...nt?.properties}}}:null),O(Et=>Et.map(yt=>yt.id===t.id?{...yt,data:{...yt.data,name:Ge}}:{...yt}))},ce=async(Ge,nt,Et)=>{const yt=[...Array.isArray(m)?m:[]],Dt={nodes:nt?[Oc({...Ge})]:[Oc({...t,data:Ge})],result:K0(P,m,k,Ge?.id||t?.id,T())};z(!0);const we=it||st;J(!0);const{success:Qe,isError:Je,data:De}=await Y0(nt?Ge:t,g,xe,B,yt,m,Dt,$,U,we,j,X,Et,void 0,void 0,Et?T():void 0);if(Qe&&!Je)return St(),z(!1),Qe;if(Je&&(setTimeout(()=>{St()},500),De)){delete De.singleRunFailure,Ra(O,t,{test:"error",node:"failed",setup_and_configure:"completed"});const at=Object.keys(De);at&&at.length>0&&at.forEach(Ot=>{ZO(De[Ot]).forEach(ur=>{g({type:Xr,payload:{open:!0,title:typeof ur!="string"?JSON.stringify(ur):ur,type:"error",width:"30rem",duration:3e3}})})})}return z(!1),!1},Te=async Ge=>{const nt=await Ye(ke.trim()),Et=gd(t.data);if(nt&&Et!==xt.TRIGGER){Se(nt);return}const yt=m.find(we=>we.id===t.id);let Dt=!0;Dt=await ce({...yt,outgoingPorts:[Ze.IF,Ze.SWITCH].includes(t.data.type)?t?.outgoingPorts||yt?.outgoingPorts||[]:[]},!0,Ge),Dt&&(Ra(O,t,{test:"completed",node:"completed"}),z(!1))},Be=async(Ge,nt,Et=!1)=>{Ge.preventDefault();const yt=await Ye(ke.trim()),Dt=gd(t.data);if(yt&&Dt!==xt.TRIGGER){Se(yt);return}if(Dt===xt.TRIGGER||vt($e)){const we=await D.trigger();let Qe;if(t?.data?.type===Ze.LOOP&&_.current&&(Qe=await _.current?.validateForm()),we&&(t?.data?.type!==Ze.LOOP||Qe!==!1)||Et){const Je=m?.find(at=>at.id===t.id)?.data?.properties;let De=D.watch();if(t.data.type===Ze.LOOP&&_.current&&(De=_.current.getData()),Od.includes(t.data.type)&&(De={...De,properties:{...typeof De.properties=="object"&&De.properties?De.properties:{},...typeof Je=="object"&&Je?Je:{}}}),nt==="skip_test"){const at=zb(De),Ot=M||at?.integration_slug||t?.data?.properties?.integration_slug;e({...t.data,type:t.data.type,name:ke||t.data.name,properties:{...at,...Ot?{integration_slug:Ot}:{}},id:t.id},nt)}if(nt==="save"){l(null),ae(0),Z(at=>at.map(Ot=>({...Ot,state:"default"}))),g({type:Ad,payload:null}),r();return}se&&(ae(1),Z(at=>at.map(Ot=>({...Ot,state:Ot.state===""?"default":Ot.state}))))}}};C.useEffect(()=>{if(h)return;const Ge=m.find(nt=>nt.id===t?.id);(!Ge||Ge?.type===xt.PLACEHOLDER)&&o(null)},[m,o,t?.id,h]),C.useEffect(()=>{if(Ee(!1),t?.id){const nt=m.find(Dt=>Dt.id===t?.id)||t;if(!nt?.data)return;const Et=Vb(nt.data);if(ee.current===Et)return;ee.current=Et;const yt=n1(nt,V);D.reset(yt,{keepDefaultValues:!1,keepErrors:!1,keepDirty:!1,keepIsSubmitted:!1,keepTouched:!1,keepIsValid:!1,keepSubmitCount:!1}),We(yt.name)}else ee.current=null},[t?.id,m,D,V]);const Fe=ui(b?.data?.data,w?.data?.data,t.data),He=ui(b?.data?.data,w?.data?.data,t.data,"meta"),dt=C.useMemo(()=>{const Ge=m.find(nt=>nt.id===t?.id);return Ge?{...Ge.data}:{...t.data}},[t?.id,m]);C.useEffect(()=>()=>{l(null)},[]),C.useEffect(()=>{h||t&&(y(t.id)||o(null))},[m,h]);const Tt=ui(b?.data?.data,w?.data?.data,t.data,"status"),Ie=!!ui(b?.data?.data,w?.data?.data,t.data,"pro"),lt=async(Ge,nt="")=>{const Et=await Ye(ke.trim()),yt=gd(t.data);if(Et&&yt!==xt.TRIGGER){Se(Et);return}if(nt===""){e({...Ge,name:ge?ke:t.data.name,id:t.id},nt);return}if(yt===xt.TRIGGER||vt($e)){let Dt=!0;if(nt==="skip_test")try{const we=te?.find(Qe=>Qe?.id===t?.id);Vb(we?.data)!==Vb(Ge)&&g({type:md,payload:{type:"replace",data:{...k,[t?.id]:{}}}})}catch{}nt==="test_and_save"&&(Dt=await ce(Ge,!1)),Dt&&e({...Ge,name:ge?ke:t.data.name,id:t.id},nt)}se&&(ae(1),Z(Dt=>Dt.map((we,Qe)=>Qe===0?{...we,state:"completed"}:{...we,state:["error","completed"].includes(ue)?ue:"default"})))},ct=Ge=>{g({type:Au,payload:{id:Ge}})},rt=async Ge=>{const nt=m?.find(Et=>Et?.id===Ge);await ce(nt,!0)},kt=()=>{ae(0),c?.(!1),r(),Z(Ge=>Ge.map((nt,Et)=>Et===0?{...nt,state:"default"}:{...nt,state:"default"}))},Gt=async(Ge,nt)=>{const Et=Xt(xe,`/v1.0/${B}/`,`workflows/${Ge}/integrations/${nt}/executions`);return await Qt.get(Et)},St=async()=>{J(!0);const Ge=it||st;try{if(t?.data?.type!=="webhook"&&Ge){const{data:nt}=await Gt(Ge,t.data.properties.integration_slug&&t.id?`${t.data.properties.integration_slug}_${t.id}`:t.id);Q(nt.data)}}catch(nt){sr(nt,g)}finally{J(!1)}},je=C.useMemo(()=>d.jsx(ure,{type:t.data.type,selectedNode:t,formData:dt,initialState:n,onSubmit:lt,onClose:kt,openIntegrationDrawer:s,ENTITY_ID:B,WORKFLOW_URLS:H,INTEGRATION_DATA:a,SET_INTEGRATION_DATA:l,source:f,isExecutionLoading:q,actionRef:v,activityDataRef:_,handleRunActivity:rt,handleCompleteSetup:ct,setPollingInterval:qe,methods:D,activityName:ke,viewOnly:N,MCP_INTEGRATION_FORM:h},t?.id),[t?.id,t.data.type,dt,n,lt,kt,s,B,H,a,l,f,q,v,_,rt,ct,qe,D,ke,N]),Ke=C.useMemo(()=>d.jsx(w6e,{activityExecutionList:W,setActivityExecutionList:Q,ENTITY_ID:B,VORTEX_MAIN_URL:xe,selectedNode:t,loading:Y,fetchActivityExecutions:St,viewOnly:N}),[W,Q,B,xe,t,Y,St,N]);return d.jsx(iye,{MCP_INTEGRATION_FORM:h,MCP_EXCLUDED_FIELDS:of,children:d.jsx(KM,{...D,children:d.jsxs(E.Stack,{position:h?"relative":"absolute",top:0,right:0,sx:{height:"100%",width:"100%",...h?{border:`1px solid ${A.palette.grey[300]}`,borderRadius:2}:{borderLeft:`1px solid ${A.palette.grey[300]}`,borderRight:u?`1px solid ${A.palette.grey[300]}`:0},zIndex:A.zIndex.drawer+2},children:[!h&&d.jsxs(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:0,zIndex:1,py:1.5,px:2,height:48},children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1.5,children:[Fe?d.jsx("img",{src:Fe,alt:t.data.name,width:30,height:30,style:{border:`1px solid ${A.palette.grey[300]}`,borderRadius:"4px",padding:"2px",width:32,height:32}}):d.jsx(E.Avatar,{variant:"square",sx:{width:32,height:32,p:2},children:t.data.name.slice(0,2).toUpperCase()}),d.jsx(vX,{value:t?.data.name,onSave:_e,minWidth:64,maxWidth:240,isEditing:ge,setIsEditing:Ge=>{Ee(Ge),Ge&&et(null)},disabled:N||t.type===xt.TRIGGER,maxLength:50,error:$e,variant:"mdSemiBold",textSx:{color:A.palette.text.primary,maxWidth:240,lineHeight:"32px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},inputSx:{height:"100%",fontSize:"1.5rem",".MuiInputBase-input":{py:"5px",px:1,fontSize:"16px",fontWeight:600},"& .MuiFormHelperText-root.Mui-error":{width:"max-content"},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"auto"}},autoResize:!0,enableDoubleClick:!0,showEditIcon:!N&&t.type!==xt.TRIGGER}),t?.type===xt.TRIGGER&&He?.trigger_type===zO.SCHEDULED&&(He?.polling_interval||Re)&&d.jsx(E.Tooltip,{arrow:!0,title:`The trigger checks for new data every ${He?.polling_interval||Re} minutes.`,children:d.jsxs(E.Box,{display:"flex",alignItems:"center",borderRadius:1,ml:1,px:.5,sx:{border:`1px solid ${A.palette.grey.outlined.border}`},children:[d.jsx(Ue,{src:"ic_schedule",sx:{cursor:"pointer",mr:.5,width:18}}),d.jsxs(E.Typography,{variant:"xsMedium",sx:{fontStyle:"normal",lineHeight:"24px"},children:[He?.polling_interval||Re," mins"]})]})})]}),d.jsxs(E.Stack,{alignItems:"center",gap:1.5,flexDirection:"row",children:[Tt===qp.DRAFT&&d.jsx(E.Stack,{direction:"row",alignItems:"center",sx:{padding:"2px 8px",borderRadius:6,background:Ge=>Ge.palette.grey[200]},children:d.jsx(E.Typography,{variant:"xsNormal",sx:{textTransform:"capitalize"},children:Tt})}),Ie&&d.jsx(sf,{}),d.jsxs(E.Button,{onClick:()=>c?.(!u),variant:"outlined",sx:{px:"8px !important",py:"2px !important",borderRadius:"6px","&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${u?A.palette.primary.main:A.palette.neutral.outlined.border}`,"& path":{fill:u?A.palette.primary.main:A.palette.neutral.solid.bg}},"&:hover":{"& .MuiTypography-root":{color:A.palette.primary.main},"& path":{fill:A.palette.primary.main},"&.MuiButtonBase-root.MuiButton-root.MuiButton-outlined":{border:`1px solid ${A.palette.primary.main}`,"& path":{fill:A.palette.primary.main}}}},children:[d.jsx(Ue,{src:"ic_document"}),d.jsx(E.Typography,{variant:"smSemiBold",sx:{pl:.5,color:u?A.palette.primary.main:A.palette.neutral.plain},children:"Docs"})]}),d.jsx(E.IconButton,{onClick:be,sx:Ni(A),children:d.jsx(Ue,{width:24,height:24,src:"ic_close"})})]})]}),!h&&d.jsx(E.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{position:"sticky",top:48,zIndex:1,py:1,px:2,height:48,backgroundColor:A.palette.white.smoke},children:d.jsx(B0e,{steps:re,activeStep:oe,setActiveStep:ae})}),d.jsxs(E.Stack,{gap:"12px",sx:{overflowY:"auto",p:2,height:h?"calc(100% - 10px)":"calc(100% - 152px)","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:A.palette.grey[300],borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:A.palette.grey[400]}},children:[(oe===0||h)&&je,oe===1&&!h&&Ke]}),!h&&d.jsx(L0e,{isExecutionLoading:q,selectedNodeType:t.data.type,onClose:kt,validateAndSubmit:Be,activityExecutionList:W,isViewOnly:N,drawerWidth:i,selectedNode:t,activeStep:oe,ref:v,setNodes:O,testActivity:Te,MCP_INTEGRATION_FORM:h})]})})})},tst=C.memo(e=>{const t=E.useTheme(),r=Rt.useNodes(),n=Rt.useEdges(),{setNodes:i,setEdges:o}=Rt.useReactFlow(),{canvasWorkflow:s}=pt.useSelector(O=>O.canvas),a=s?.meta?.isHorizontal??!0,{fromX:l,fromY:u,toX:c,toY:f,fromNode:p,sourcePosition:h,targetPosition:A}=e;if([l,u,c,f].some(O=>typeof O!="number"||Number.isNaN(O)))return null;C.useEffect(()=>{const{id:O}=p,y=n.filter(T=>T.source===O&&T.type===Hr.PLACEHOLDER);if(y.length>0){let T=null,v=1/0;if(y.forEach(_=>{const x=r.find(b=>b.id===_.target);if(x){const b=x.position.y+(x.height||51)/2,w=Math.abs(b-u);w<v&&(v=w,T=_)}}),T&&v<30){const _=T.target,x=n.filter(R=>R.id!==T.id);o(x);const b=r.find(R=>R.id===O),w=r.filter(R=>R.id!==_);if(b){b.outgoingPorts=(b.outgoingPorts||[]).filter(I=>I.id!==_);const R=w.filter(I=>I.id!==O);i([...R,b])}else i(w)}}},[]);const[m]=Rt.getBezierPath({sourceX:a?c:l,sourceY:a?f:u,sourcePosition:a?A:h,targetX:a?l:c,targetY:a?u:f,targetPosition:a?h:A});return d.jsx("path",{fill:"none",stroke:t.palette.primary.main,strokeWidth:1.5,className:"animated",d:m})}),dre=e=>String(e??"").trim(),rst=e=>String(e??"").split(",").map(t=>dre(t)).filter(Boolean),RE=(e,t)=>{const r=dre(e),n=rst(t);return!r||n.length===0?!1:n.includes(r)},Rx=({edgeCenterX:e,edgeCenterY:t,onClick:r,isSelected:n=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-delete-button ${n?"selected":""}`,onClick:r,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-delete-square",children:d.jsx("div",{className:"react-flow__edge-delete-square-inner"})}),d.jsx("g",{transform:`translate(${e-8}, ${t-8})`,className:"react-flow__edge-delete-icon",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",children:d.jsx("path",{fill:i.palette.error.main,d:"M11.667 2.5C11.903 2.50007 12.1011 2.57961 12.2607 2.73926C12.4204 2.89891 12.4999 3.09704 12.5 3.33301H15.833C16.0691 3.33301 16.267 3.41352 16.4268 3.57324C16.5865 3.73296 16.667 3.93088 16.667 4.16699C16.6669 4.40296 16.5864 4.60109 16.4268 4.76074C16.2671 4.92025 16.069 5 15.833 5V15.833C15.833 16.2913 15.6701 16.6844 15.3438 17.0107C15.0175 17.3369 14.6251 17.4999 14.167 17.5H5.83301C5.37489 17.4999 4.98253 17.3369 4.65625 17.0107C4.32986 16.6844 4.16699 16.2913 4.16699 15.833V5C3.93104 5 3.73291 4.92025 3.57324 4.76074C3.41359 4.60109 3.33308 4.40296 3.33301 4.16699C3.33301 3.93088 3.41352 3.73296 3.57324 3.57324C3.73296 3.41352 3.93088 3.33301 4.16699 3.33301H7.5C7.50007 3.09704 7.57961 2.89891 7.73926 2.73926C7.89891 2.57961 8.09704 2.50007 8.33301 2.5H11.667ZM5.83301 15.833H14.167V5H5.83301V15.833ZM8.33301 6.66699C8.56904 6.66699 8.76706 6.74664 8.92676 6.90625C9.08648 7.06597 9.16699 7.26389 9.16699 7.5V13.333C9.16699 13.5691 9.08648 13.767 8.92676 13.9268C8.76704 14.0865 8.56912 14.167 8.33301 14.167C8.09704 14.1669 7.89891 14.0864 7.73926 13.9268C7.57975 13.7671 7.5 13.569 7.5 13.333V7.5C7.5 7.26397 7.57964 7.06594 7.73926 6.90625C7.89891 6.7466 8.09704 6.66707 8.33301 6.66699ZM11.667 6.66699C11.903 6.66707 12.1011 6.7466 12.2607 6.90625C12.4204 7.06594 12.5 7.26397 12.5 7.5V13.333C12.5 13.569 12.4202 13.7671 12.2607 13.9268C12.1011 14.0864 11.903 14.1669 11.667 14.167C11.4309 14.167 11.233 14.0865 11.0732 13.9268C10.9135 13.767 10.833 13.5691 10.833 13.333V7.5C10.833 7.26389 10.9135 7.06597 11.0732 6.90625C11.2329 6.74664 11.431 6.66699 11.667 6.66699Z"})})})]})},Px=({edgeCenterX:e,edgeCenterY:t,onClick:r,isSelected:n=!1})=>{const i=E.useTheme();return d.jsxs("g",{className:`react-flow__edge-add-button ${n?"selected":""}`,onClick:r,children:[d.jsx("foreignObject",{x:e-12,y:t-12,width:24,height:24,className:"react-flow__edge-add-square",children:d.jsx("div",{className:"react-flow__edge-add-square-inner"})}),d.jsx("g",{transform:`translate(${e-12}, ${t-12})`,className:"react-flow__edge-add-icon",children:d.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",fill:"white"}),d.jsx("rect",{className:"add-button-border",x:"0.5",y:"0.5",width:"23",height:"23",rx:"4",ry:"4",stroke:i.palette.neutral?.outlined?.border,fill:"none"}),d.jsx("path",{className:"add-button-icon",fillRule:"evenodd",clipRule:"evenodd",d:"M11.333 14.6663V12.6663H9.33301C9.14412 12.6663 8.98579 12.6025 8.85801 12.4747C8.73023 12.3469 8.66634 12.1886 8.66634 11.9997C8.66634 11.8108 8.73023 11.6525 8.85801 11.5247C8.98579 11.3969 9.14412 11.333 9.33301 11.333H11.333V9.33301C11.333 9.14412 11.3969 8.98579 11.5247 8.85801C11.6525 8.73023 11.8108 8.66634 11.9997 8.66634C12.1886 8.66634 12.3469 8.73023 12.4747 8.85801C12.6025 8.98579 12.6663 9.14412 12.6663 9.33301V11.333H14.6663C14.8552 11.333 15.0136 11.3969 15.1413 11.5247C15.2691 11.6525 15.333 11.8108 15.333 11.9997C15.333 12.1886 15.2691 12.3469 15.1413 12.4747C15.0136 12.6025 14.8552 12.6663 14.6663 12.6663H12.6663V14.6663C12.6663 14.8552 12.6025 15.0136 12.4747 15.1413C12.3469 15.2691 12.1886 15.333 11.9997 15.333C11.8108 15.333 11.6525 15.2691 11.5247 15.1413C11.3969 15.0136 11.333 14.8552 11.333 14.6663ZM9.39967 18.1413C10.2108 18.4913 11.0775 18.6663 11.9997 18.6663C12.9219 18.6663 13.7886 18.4913 14.5997 18.1413C15.4108 17.7913 16.1163 17.3163 16.7163 16.7163C17.3163 16.1163 17.7913 15.4108 18.1413 14.5997C18.4913 13.7886 18.6663 12.9219 18.6663 11.9997C18.6663 11.0775 18.4913 10.2108 18.1413 9.39967C17.7913 8.58856 17.3163 7.88301 16.7163 7.28301C16.1163 6.68301 15.4108 6.20801 14.5997 5.85801C13.7886 5.50801 12.9219 5.33301 11.9997 5.33301C11.0775 5.33301 10.2108 5.50801 9.39967 5.85801C8.58856 6.20801 7.88301 6.68301 7.28301 7.28301C6.68301 7.88301 6.20801 8.58856 5.85801 9.39967C5.50801 10.2108 5.33301 11.0775 5.33301 11.9997C5.33301 12.9219 5.50801 13.7886 5.85801 14.5997C6.20801 15.4108 6.68301 16.1163 7.28301 16.7163C7.88301 17.3163 8.58856 17.7913 9.39967 18.1413ZM15.783 15.783C14.7497 16.8163 13.4886 17.333 11.9997 17.333C10.5108 17.333 9.24967 16.8163 8.21634 15.783C7.18301 14.7497 6.66634 13.4886 6.66634 11.9997C6.66634 10.5108 7.18301 9.24967 8.21634 8.21634C9.24967 7.18301 10.5108 6.66634 11.9997 6.66634C13.4886 6.66634 14.7497 7.18301 15.783 8.21634C16.8163 9.24967 17.333 10.5108 17.333 11.9997C17.333 13.4886 16.8163 14.7497 15.783 15.783Z",fill:i.palette.neutral?.solid?.bg})]})})]})},nst=e=>{const t=E.useTheme(),{canvasWorkflow:r}=pt.useSelector(z=>z.canvas),{ENTITY_ID:n,allowedAccount:i}=Ii(),o=RE(n,i),s=r?.meta?.isHorizontal??!0,{id:a,sourceX:l,sourceY:u,targetX:c,targetY:f,sourcePosition:p,targetPosition:h,style:A={stroke:t.palette.neutral.main},markerEnd:g,source:m,target:O,sourceHandle:y,targetHandle:T}=e;if([l,u,c,f].some(z=>typeof z!="number"||Number.isNaN(z))||!p||!h)return null;const v=Rt.useEdges(),_=Rt.useNodes(),{deleteElements:x}=Rt.useReactFlow(),b=pt.useDispatch(),{viewOnly:w}=pt.useSelector(z=>z.canvas),R=v.find(z=>z.id===a),I=R?.data?.isStraight===!0,P=()=>Rt.getBezierPath({sourceX:l,sourceY:u,sourcePosition:p,targetX:c,targetY:f,targetPosition:h,curvature:.25});let k,N,L;I&&s?Math.abs(u-f)<2?(k=`M ${l},${u} L ${c},${u}`,N=(l+c)/2,L=u):(k=`M ${l},${u} L ${c},${u} L ${c},${f}`,N=(l+c)/2,L=(u+f)/2):[k,N,L]=P();const M=c-l,B=f-u,H=Math.sqrt(M*M+B*B),j=M/H,X=B/H,F=20,V=z=>{z.stopPropagation(),a&&x({nodes:[{id:R.target}],edges:[{id:a}]})},G=z=>{if(z.stopPropagation(),!w){b({type:Zp,payload:{x:z.clientX,y:z.clientY}}),b({type:w0,payload:!1});const W=`placeholder_${Math.trunc(Math.random()*1e9)}`;if(b({type:C0,payload:{id:W,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:T}}),!o){b({type:ss,payload:{type:"activities",active:!0,nodeId:W,edgeId:a,sourceNodeId:m,targetNodeId:O,sourceHandle:y,targetHandle:T}}),b({type:ea,payload:!0});return}b({type:ea,payload:!1}),b({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),b({type:Ns,payload:"prompt"}),b({type:_0,payload:!0})}},D=_.find(z=>z.id===O),$=v.some(z=>z.source===O&&z.id!==a),U=D?.data?.outgoingPorts,q=$||Array.isArray(U)&&U.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:V,id:`${a}-interaction`,className:w?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:k,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:V,id:a,style:{...A},className:w?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:k,markerEnd:g}),!w&&d.jsx(d.Fragment,{children:s?d.jsxs(d.Fragment,{children:[q&&d.jsx(Px,{edgeCenterX:N-F*j,edgeCenterY:L-F*X,onClick:G}),d.jsx(Rx,{edgeCenterX:q?N+F*j:N,edgeCenterY:q?L+F*X:L,onClick:V})]}):d.jsxs(d.Fragment,{children:[q&&d.jsx(Px,{edgeCenterX:N-F*j,edgeCenterY:L-F*X,onClick:G}),d.jsx(Rx,{edgeCenterX:q?N+F*j:N,edgeCenterY:q?L+F*X:L,onClick:V})]})})]})},ist=e=>{const t=E.useTheme(),{id:r,sourceX:n,sourceY:i,targetX:o,targetY:s,sourcePosition:a,targetPosition:l,style:u={stroke:t.palette.neutral.main},markerEnd:c,source:f,target:p,sourceHandle:h,targetHandle:A}=e,{deleteElements:g}=Rt.useReactFlow(),m=pt.useDispatch(),{ENTITY_ID:O,allowedAccount:y}=Ii(),T=RE(O,y),v=Rt.useNodes(),_=Rt.useEdges(),{viewOnly:x,canvasWorkflow:b,activitiesPopover:w}=pt.useSelector(q=>q.canvas),R=b?.meta?.isHorizontal??!0,I=w?.edgeId===r&&w?.active;if([n,i,o,s].some(q=>typeof q!="number"||Number.isNaN(q))||!a||!l)return null;const[P,k,N]=Rt.getBezierPath({sourceX:n,sourceY:i,sourcePosition:a,targetX:o,targetY:s,targetPosition:l,curvature:.25}),L=o-n,M=s-i,B=Math.sqrt(L*L+M*M),H=L/B,j=M/B,X=20,F=q=>{q.stopPropagation(),r&&!x&&g({edges:[{id:r}]})},V=q=>{if(q.stopPropagation(),!x){const z=q.currentTarget?.getBoundingClientRect?.(),W=z&&Number.isFinite(z.left)&&Number.isFinite(z.top)?{x:z.left+z.width/2,y:z.top+z.height/2}:{x:q.clientX,y:q.clientY};m({type:Zp,payload:W}),m({type:w0,payload:!1});const Q=`ai_prompt_${Math.trunc(Math.random()*1e9)}`,Y={id:r,source:f,target:p,sourceHandle:h,targetHandle:A,type:Hr.SMOOTH,markerEnd:c,style:u};if(m({type:C0,payload:{id:Q,edgeId:r,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A,originalEdge:Y}}),!T){m({type:ss,payload:{type:"activities",active:!0,nodeId:Q,edgeId:r,sourceNodeId:f,targetNodeId:p,sourceHandle:h,targetHandle:A}}),m({type:ea,payload:!0});return}m({type:ea,payload:!1}),m({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),m({type:Ns,payload:"prompt"}),m({type:_0,payload:!0})}},G=v.find(q=>q.id===p),D=_.some(q=>q.source===p&&q.id!==r),$=G?.data?.outgoingPorts,U=D||Array.isArray($)&&$.length>0;return d.jsxs(d.Fragment,{children:[d.jsx("path",{onClick:F,id:`${r}-interaction`,className:x?"react-flow__edge-interaction viewModeCursor":"react-flow__edge-interaction",d:P,style:{stroke:"transparent",strokeWidth:12,fill:"none",pointerEvents:"stroke"}}),d.jsx("path",{onClick:F,id:r,style:{...u},className:x?"react-flow__edge-path viewModeCursor":"react-flow__edge-path",d:P,markerEnd:c}),!x&&d.jsx(d.Fragment,{children:R?d.jsxs(d.Fragment,{children:[U&&d.jsx(Px,{edgeCenterX:k-X*H,edgeCenterY:N-X*j,onClick:V,isSelected:I}),d.jsx(Rx,{edgeCenterX:U?k+X*H:k,edgeCenterY:U?N+X*j:N,onClick:F,isSelected:I})]}):d.jsxs(d.Fragment,{children:[U&&d.jsx(Px,{edgeCenterX:k-X*H,edgeCenterY:N-X*j,onClick:V,isSelected:I}),d.jsx(Rx,{edgeCenterX:U?k+X*H:k,edgeCenterY:U?N+X*j:N,onClick:F,isSelected:I})]})})]})},PE=e=>e.canvas,fre=e=>e.activities,pre=sl.createSelector([PE],e=>e.canvasWorkflow);sl.createSelector([pre],e=>e?.meta?.isHorizontal??!0);const ost=sl.createSelector([PE],e=>e.activityExecutionData),sst=sl.createSelector([PE],e=>e.selectedActivityId),ast=sl.createSelector([PE],e=>e.viewOnly);sl.createSelector([PE],e=>e.nodesToFocus);const lst=sl.createSelector([fre],e=>e.activities?.data?.data||[]),ust=sl.createSelector([fre],e=>e.triggers?.data?.data||[]),NE=sl.createSelector([lst,ust],(e,t)=>({activities:e,triggers:t})),cst=sl.createSelector([ost,(e,t)=>t],(e,t)=>e?.[t]?.loading??!1),dst=sl.createSelector([pre,ast,sst],(e,t,r)=>({isHorizontal:e?.meta?.isHorizontal??!0,viewOnly:t,selectedActivityId:r})),Nx=()=>{const e=E.useTheme();return d.jsx(E.Box,{className:"warning",sx:{background:e.palette.neutral.plain,color:e.palette.common.white,p:"2px 5px",margin:"14px 0px 0px",borderRadius:1.5,position:"relative",top:10},children:d.jsx(E.Typography,{variant:"smSemiBold",sx:{display:"block",width:200,fontFamily:"Inter"},children:"An activity can not be connected to more than one other activity"})})},vf=({type:e,position:t,id:r,isConnectable:n,className:i,isValidConnection:o,style:s,onClick:a})=>{const l=E.useTheme(),{viewOnly:u}=pt.useSelector(c=>c.canvas);return d.jsx(Rt.Handle,{onClick:u?void 0:a,type:e,position:t,id:r,isConnectable:n,isValidConnection:o,className:u?i+" viewModeCursor":i,style:{...s,backgroundColor:l.palette.common.white,cursor:u?"not-allowed":"pointer"},children:!u&&d.jsx(E.Box,{className:"handle_icon",sx:{bgcolor:l.palette.common.white,borderRadius:"50%"},children:d.jsx(Ue,{src:"ic_add_circle_outlined",width:"100%",height:"100%",sx:{path:{fill:l.palette.primary.main}}})})})};function fst(e=!1){const t=pt.useDispatch(),{getNodes:r,getEdges:n}=Rt.useReactFlow(),i=r(),o=n(),s=C.useRef({x:0,y:0}),{activity_names:a}=pt.useSelector(m=>m.activities),{setNodes:l,screenToFlowPosition:u}=Rt.useReactFlow(),[c,f]=C.useState([]),p=C.useCallback((m=u({x:s.current.x,y:s.current.y}))=>{const O=i.filter(v=>v.id===m);let y=[...i];const T=O.map(v=>{const _=Math.trunc(Math.random()*20),x=v.position.x+80+_,b=v.position.y+100+_,w=v?.data?.name||v?.data?.type||"node",I=Na(w,y),P=l1(null,v.data,null,I,y,null,"",[],{x,y:b});return v.activity_data&&(P.activity_data={...v.activity_data}),t({type:wi.SET_ACTIVITY_NAMES,payload:[...a,P.data.name]}),y=[...y,P],P});l([...i.map(v=>({...v,selected:!1})),...T])},[i,l,u]),h=C.useCallback(()=>{const m=i.filter(T=>T.selected);if(m.find(T=>T.type===xt.TRIGGER)){t({type:Xr,payload:{open:!0,title:"Trigger can't be copy",type:"error"}});return}let O=[...i];const y=m.map(T=>{const v=Math.trunc(Math.random()*20),_=T.data.name.split("_")[0],x=jb(_,O),b=T.position.x+60+v,w=T.position.y+60+v,R=Na(T?.data?.name||T?.data?.type||"node",O),I={...T,id:R,position:{x:b,y:w},data:{name:x,properties:T.data.properties,type:T.data.type},incomingPorts:[],outgoingPorts:[]};return O=[...O,{...I}],I});f(y),y.length===0?t({type:Xr,payload:{open:!0,title:"Please select a node to copy",type:"error"}}):t({type:Xr,payload:{open:!0,title:"Activity copied successfully",type:"success"}})},[i,o]),A=C.useCallback(({x:m,y:O}=u({x:s.current.x,y:s.current.y}))=>{const y=Math.min(...c.map(_=>_.position.x)),T=Math.min(...c.map(_=>_.position.y)),v=c.map(_=>{const x=_.id,b=m+(_.position.x-y),w=O+(_.position.y-T);return{..._,id:x,position:{x:b,y:w}}});l([...i.map(_=>({..._,selected:!1})),...v])},[c,u,l]),g=i.find(m=>m?.selected);return hre(e&&g?["Meta+c","Ctrl+c"]:[],h),hre(e&&g?["Meta+v","Ctrl+v"]:[],A),{copy:h,clone:p,paste:A,bufferedNodes:c}}function hre(e,t){const[r,n]=C.useState(!1),i=Rt.useKeyPress(e);C.useEffect(()=>{i&&!r?(t(),n(!0)):n(i)},[i,r,t])}const LE=({name:e,id:t,isTriggerNode:r,nodeData:n,handleDeleteNode:i,proIntegration:o=!1,onRunWithPrevious:s})=>{const a=E.useTheme(),l=pt.useDispatch(),{viewOnly:u}=pt.useSelector(j=>j.canvas),{workflow:c}=pt.useSelector(j=>j.workflows),{activities:f,triggers:p}=pt.useSelector(j=>j.activities),A=new URLSearchParams(typeof window<"u"?window.location.search:"").get("source")?.toLowerCase()||c?.source,g=r&&A?.includes("commerce_"),{clone:m}=fst(),O=ui(f?.data?.data,p?.data?.data,n),y=n?.properties?.integration_slug||"",T=n?.type,v=!r&&!Rf.includes(T),_=n?.blt_node_states||{},x=_.setup_and_configure||"default",b=_.node||"default",w=v&&x!=="completed"&&b!=="completed",R=Rt.useEdges(),I=C.useMemo(()=>R.some(j=>j.target===t&&j.type!==Hr.PLACEHOLDER),[R,t]),P=C.useCallback(()=>{o||w||(l({type:Au,payload:{id:t}}),l({type:Df,payload:!0}),l({type:Pb,payload:{nodeId:t,runWithPrevious:!1}}))},[t,o,w,l]),k=C.useCallback(()=>{o||w||!I||(s?s(t):(l({type:Au,payload:{id:t}}),l({type:Df,payload:!0}),l({type:Pb,payload:{nodeId:t,runWithPrevious:!0}})))},[t,o,w,I,l,s]),N=C.useCallback(()=>{o||m(t)},[t,o,m]),L=C.useCallback(()=>{i([{id:t,name:e,icon:O,integration_slug:y}])},[t,e,O,y,i]),M=C.useCallback(()=>{l({type:Df,payload:!1}),l({type:ss,payload:{type:"triggers",active:!0,nodeId:t}})},[t,l]);if(u)return null;const B={"&.Mui-disabled":{opacity:1}},H=a.palette.primary.disabled??a.palette.grey?.normal;return d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:.5,onClick:j=>j.stopPropagation(),children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",sx:{backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)",p:.25},children:[r&&d.jsx(E.Tooltip,{arrow:!0,title:"Switch Trigger",placement:"top",children:d.jsx(E.IconButton,{onClick:M,sx:{p:.5,width:28,height:28,...Ni(a)},"data-testid":"node-action-switch-trigger",children:d.jsx(Ue,{src:"ic_swap",width:20,height:20,sx:{path:{fill:a.palette.neutral.solid.bg||"#656A70"}}})})}),v&&d.jsxs(d.Fragment,{children:[d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to Test Node":"Test Node",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:P,disabled:w,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run",children:d.jsx(Ue,{src:"ic_play",width:20,height:20,sx:{path:{fill:w?H:a.palette.primary.main}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:w?"Complete configuration to run":I?"Run with previous":"No previous node attached",placement:"top",children:d.jsx("span",{children:d.jsx(E.IconButton,{onClick:k,disabled:w||!I,sx:{p:.5,width:28,height:28,...B},"data-testid":"node-action-run-with-previous",children:d.jsx(Ue,{src:"ic_autoplay",width:20,height:20,sx:{path:{fill:w||!I?H:a.palette.primary.main}}})})})})]}),!r&&d.jsx(E.Tooltip,{arrow:!0,title:"Duplicate",placement:"top",children:d.jsx(E.IconButton,{onClick:N,disabled:o,sx:{p:.5,width:28,height:28,...Ni(a),...B},"data-testid":"node-action-duplicate",children:d.jsx(Ue,{src:"ic_copy",width:20,height:20,sx:{path:{fill:o?a.palette.text?.tertiary??a.palette.neutral?.solid?.bg:a.palette.neutral.solid.bg}}})})})]}),d.jsx(E.Tooltip,{arrow:!0,title:"Delete",placement:"top",children:d.jsx(E.IconButton,{onClick:L,disabled:g,sx:{p:.5,width:28,height:28,backgroundColor:a.palette.common.white,borderRadius:"8px",boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.08)","&:hover":{backgroundColor:a.palette.common.white,"& .inline-svg path":{fill:`${a.palette.error.main} !important`}}},"data-testid":"node-action-delete",children:d.jsx(Ue,{src:"ic_new_delete",width:20,height:20,sx:{path:{fill:a.palette.error.main||"#C41C1C"}}})})})]})},pst=250,kE=({children:e,id:t,nodeData:r,focused:n,sx:i={},actionBar:o})=>{const s=Rt.useNodes(),[a,l]=C.useState(!1),u=C.useRef(null),c=()=>{u.current&&(clearTimeout(u.current),u.current=null)},f=()=>{c(),u.current=setTimeout(()=>l(!1),pst)},p=()=>{c(),l(!0)};C.useEffect(()=>()=>c(),[]);const{setNodes:h}=Rt.useReactFlow(),{nodesToFocus:A}=pt.useSelector(P=>P.canvas),g=pt.useDispatch(),m=A.nodes.includes(t),[O,y]=C.useState(r?.activity_comment?.body||""),T=A.type,v=C.useRef(null),_=C.useRef(!1),[x,b]=C.useState(!1);C.useEffect(()=>{_.current||y(r?.activity_comment?.body||"")},[r?.activity_comment?.body]),C.useLayoutEffect(()=>{if(x&&_.current&&v.current&&document.activeElement!==v.current){const P=v.current;P.focus();const k=P.value.length;P.setSelectionRange(k,k)}});const w=C.useMemo(()=>Da(k=>{const N=s.map(L=>L.id===t?{...L,data:{...L.data,activity_comment:{...L.data.activity_comment,body:k,visible:k.trim()!==""}}}:L);h(N)},300),[s,t,g]);C.useEffect(()=>()=>{w.cancel()},[w]);const R=P=>{let k=P.target.value;k.length>299&&(k=k.substring(0,299)),y(k),w(k)},I=C.useMemo(()=>m&&A.show||n?{border:P=>`1px solid ${T==="focused"||n?P.palette.primary.main:P.palette.error.main}`,...i}:{border:P=>`1px solid ${P.palette.neutral.outlined.border}`,...i},[m,n,T,A.show,i]);return d.jsxs(E.Box,{className:"nodeContainer",position:"relative",sx:I,onMouseEnter:p,onMouseLeave:f,children:[o&&a&&d.jsx(E.Box,{"data-node-action-bar":!0,onMouseEnter:p,onMouseLeave:f,sx:{position:"absolute",bottom:"100%",left:0,right:0,display:"flex",justifyContent:"flex-end",mb:.75,zIndex:10,pointerEvents:"auto"},children:o}),d.jsxs(E.Box,{sx:{display:"flex",flexDirection:"column",flex:1},children:[e,(r?.activity_comment?.visible||x)&&d.jsx(E.Box,{position:"absolute",top:"100%",zIndex:1,width:"100%",height:"auto",mt:.75,mx:0,sx:{userSelect:"all",pointerEvents:"auto"},children:d.jsx(E.TextField,{fullWidth:!0,multiline:!0,variant:"outlined",value:O,inputRef:v,placeholder:"Add a comment",autoFocus:O.trim()==="",sx:{width:"100%",background:P=>P.palette.white.ivory,borderRadius:"8px","&:hover":{".MuiInputBase-root":{"&:hover":{".MuiOutlinedInput-notchedOutline":{borderColor:P=>P.palette.primary.main}},boxShadow:P=>`0 0 8px ${P.palette.primary.main}`}},"& .MuiInputBase-root.MuiOutlinedInput-root":{minHeight:"32px",padding:"10px 4px"}},onChange:R,onFocus:()=>{_.current=!0,b(!0)},onBlur:P=>{if(_.current=!1,b(!1),P.relatedTarget?.tagName==="BUTTON")return;w.cancel();const k=s.map(N=>N.id===t?{...N,data:{...N.data,activity_comment:{...N.data.activity_comment,body:O,visible:O.trim()!==""}}}:N);h(k)}})})]})]},t)},hst=(e,t)=>{try{const r=e.replace(/properties\.([a-zA-Z_]\w*)/g,(i,o)=>{const s=t[o];return s!=null&&s!==""?s.toString():"undefined"});if(r.includes("undefined")||!/^[\d+\-*/().\s]+$/.test(r))return null;const n=new Function(`return ${r}`)();return typeof n=="number"&&!isNaN(n)?n:null}catch{return null}},Ast=(e,t,r)=>{if(!e)return{result:e,allReplaced:!1};let n=!0;return{result:e.replace(/\{\{([^}]+)\}\}/g,(o,s)=>{if(/[+\-*/()]/.test(s)){const a=hst(s,t);return a!==null?a.toString():(n=!1,o)}else{const l=s.replace(/^properties\??\./,"").replace(/\?/g,"").split(".");let u=t;for(const c of l)if(u&&typeof u=="object"&&c in u)u=u[c];else{u=void 0;break}if(u!=null&&u!==""){if(Array.isArray(u)&&u.length>0)return u.join(", ");if(Array.isArray(u)&&u.length===0)return n=!1,o;let c=r;for(const f of l)if(c&&typeof c=="object"&&f in c)c=c[f];else{c=void 0;break}return c&&typeof c=="object"&&u in c?c[u]:typeof u=="string"?$8(u):u}else return n=!1,o}}),allReplaced:n}},$8=e=>{if(!e)return"";const[t,...r]=e.split("."),n=r.length>0?r.join("."):"",i=(a,l=!1)=>{if(!a)return"";const u=a.replace(/[_\-\.]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g,"$1 $2").replace(/\s+/g," ").trim();return l?u.replace(/\b\w/g,c=>c.toUpperCase()):u.charAt(0).toUpperCase()+u.slice(1)},o=i(t),s=i(n);return s?`${s} [${o}]`:o},mst=e=>{const t=ece();if(Od.includes(e.data?.type))return e.data.properties?.operation?$8(e.data.properties.operation):"Select an operation";if(e.data?.type in t){const r=e.data.properties,n=t[e.data.type];let i={},o="";if(e.type===xt.TRIGGER?(i=n.trigger,o=n?.trigger?.manual_type):(i=n.integration,o=n?.integration?.manual_type),e.data?.type===Ze.SCHEDULE){const l=r?.spec;if(l){if(l.calendars&&l.calendars.length>0)return"Calendar Schedule";if(l.cron_expressions&&l.cron_expressions.length>0)return"Cron Schedule";if(l.intervals&&l.intervals.length>0)return"Interval Schedule"}return"Configure Schedule"}const s=Object.keys(i)[0],a=r?.[s];if(o){const{result:l,allReplaced:u}=Ast(o,r,i);return u?l:i.default}if(!a||typeof a=="object"&&vt(a))return i.default;if(i[s]){if(Array.isArray(a))return a.map(l=>i[s]?.[typeof l=="object"?l?.value?.toLowerCase():l?.toLowerCase()]).join(", ");if(e.data?.type===Ze.BOLTIC_TABLE_ACTIVITY){if(a==="sql_query"||r?.query)return"SQL Query";if(a==="custom_event"||a&&!i[s]?.[a])return $8(a)}return xb.includes(e.data?.type)&&(a==="custom"||e.data?.type===Ze.GOOGLE_SHEETS_WRITE&&s==="mode"&&r?.operation==="custom")?"Custom API":i[s]?.[a]}return a}return""},Are=e=>{switch(e?.node){case"not-configured-yet":return"ic_warning_circle";case"skipped":return"ic_skipped";case"failed":return"ic_error";case"completed":return"ic_success_small";default:return""}},gst=({nodeData:e})=>{const t=E.useTheme(),r=mst(e);return d.jsxs(E.Stack,{direction:"row",width:"100%",alignItems:"center",justifyContent:"space-between",children:[d.jsx(E.Tooltip,{title:r,arrow:!0,placement:"top",children:d.jsx(E.Typography,{variant:"smNormal",color:t.palette.text.tertiary,sx:{maxWidth:200,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r})}),!vt(Are(e.data?.blt_node_states))&&d.jsx(E.Stack,{direction:"row",sx:{cursor:"pointer",flexShrink:0},children:d.jsx(E.Tooltip,{arrow:!0,title:Ps(e.data?.blt_node_states?.node),children:d.jsx(Ue,{width:20,height:20,src:Are(e.data?.blt_node_states)})})})]})},FE=({id:e,nodeData:t,iconSrc:r,title:n,children:i,isTriggerNode:o,meta:s=null,proIntegration:a=!1,pro:l=!1})=>{const u=pt.useDispatch(),c=E.useTheme(),{setNodes:f,getNodes:p}=Rt.useReactFlow(),{activitiesPopover:h}=pt.useSelector(m=>m.canvas),A=C.useMemo(()=>r?oh(r,"t.resize(h:24,w:24)"):"",[r]),g=m=>{u({type:Au,payload:{id:m}})};return d.jsxs(E.Stack,{alignItems:"center",p:1.5,gap:1,onClick:m=>{m.stopPropagation(),!a&&(h.nodeId===t.id?u({type:ss,payload:{type:"",active:!1,nodeId:null}}):g(t.id))},sx:{cursor:a?"not-allowed":"pointer"},children:[d.jsxs(E.Stack,{direction:"row",overflow:a?"visible":"hidden",alignItems:"center",width:"100%",justifyContent:"space-between",flex:1,children:[d.jsx(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",flex:1,minWidth:0,display:"flex",alignItems:"center"},children:d.jsxs(E.Stack,{direction:"row",gap:1,alignItems:"center",flex:1,minWidth:0,overflow:"visible",children:[d.jsx(E.Stack,{sx:{...Qi},width:24,height:24,children:r?d.jsx("img",{src:A,alt:n,width:24,height:24,decoding:"async",style:{width:24,height:24,objectFit:"contain",display:"block"}}):d.jsx(E.Box,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.palette.grey.A400}`,borderRadius:1,background:c.palette.grey.A400,padding:.5,color:c.palette.common.white},children:n.slice(0,2).toUpperCase()})}),d.jsx(E.Tooltip,{arrow:!0,title:n,placement:"top",children:d.jsx(E.Typography,{sx:{maxWidth:148,...hu,lineHeight:"142%"},variant:"smSemiBold",color:c.palette.text.primary,children:n})}),l&&d.jsx(E.Box,{flexShrink:0,children:d.jsx(sf,{})})]})}),d.jsxs(E.Stack,{alignItems:"center",gap:1,flexShrink:0,justifyContent:"self-end",direction:"row",children:[d.jsxs(E.Box,{sx:{opacity:a?.5:1,filter:a?"grayscale(1)":"none",display:"flex",alignItems:"center",gap:1},children:[o&&(t.data.type===Ze.GMAIL_TRIGGER||s?.trigger_type===zO.SCHEDULED)&&d.jsx(E.Tooltip,{arrow:!0,title:"The trigger will check for new data in intervals.",children:d.jsx(E.Box,{display:"flex",alignItems:"center",children:d.jsx(E.IconButton,{sx:{p:0},children:d.jsx(Ue,{src:"ic_schedule",width:16,height:16,sx:{cursor:"pointer",path:{fill:c.palette.neutral.solid.bg}}})})})}),d.jsx(E.Tooltip,{arrow:!0,title:"Toggle Comment",children:d.jsx(E.IconButton,{onClick:m=>{if(a)return;m.stopPropagation(),m.preventDefault();const O=p().map(y=>y.id===e?{...y,data:{...y.data,activity_comment:{...y.data?.activity_comment,visible:!y.data?.activity_comment?.visible}}}:y);f(O)},sx:{p:0,...Ni(c)},children:d.jsx(Ue,{src:"ic_comment",width:16,height:16})})})]}),d.jsx(E.Box,{sx:{position:"relative",zIndex:1,opacity:1,flexShrink:0},children:i})]})]}),d.jsxs(E.Box,{sx:{width:"100%",opacity:a?.5:1,filter:a?"grayscale(1)":"none"},children:[d.jsx(E.Divider,{sx:{width:"100%"}}),d.jsx(E.Box,{sx:{pt:1},children:d.jsx(gst,{nodeData:t})})]})]})},Est=C.memo(e=>{const t=Rt.useNodes(),r=Rt.useEdges(),n=E.useTheme(),{canvasWorkflow:i,activityExecutionData:o,viewOnly:s,selectedActivityId:a}=pt.useSelector(H=>H.canvas),l=i?.meta?.isHorizontal??!0,u=Rt.useUpdateNodeInternals(),{setNodes:c}=Rt.useReactFlow(),{id:f,data:p,onHandleClick:h,handleDeleteNode:A,selected:g,pro_integration:m,onRunWithPrevious:O}=e,y=t.find(H=>H.id===a),{activities:T,triggers:v}=pt.useSelector(NE),_=Array.isArray(T)?T:[],x=Array.isArray(v)?v:[],b=ui(_,x,p,"pro"),w=!!b&&b!=="",R=w&&m===!1,I=o?.[p.name]?.loading??!1;let P=Array.isArray(p.properties?.branches)?p.properties.branches:[];(p.type===Ze.API||p.type===Ze.GRAPHQL)&&p.properties?.continue_on_failure===!1&&(P=P.filter(H=>H.ref==="success")),C.useEffect(()=>{u(f)},[f,P.length,p.properties?.continue_on_failure]),C.useEffect(()=>{c(H=>H.map(j=>{if(j.id===f){const X=R;if(j.draggable!==!X||j.selectable!==!X||j.connectable!==!X)return{...j,draggable:!X,selectable:!X,connectable:!X}}return j}))},[R,f,c]);const k=P.length+1,N=Math.max(k*16,84),L=H=>{const j=k-1,X=j*8,F=(j-1)*8,V=X+F,D=(N-V+4)/2+H*16,$=l?D:84;return isNaN($)?84:$},M=H=>{const j=k,X=k>4?260+32*(k-4):260,F=l?255:(H+1)*(X/j);return isNaN(F)?l?254:253:F},B=(H,j,X)=>{const F=p.type===Ze.API||p.type===Ze.GRAPHQL;return H===0?F?"success":"if":H===j-1?F?"failure":"else":X[H]?.ref||`branch_${H}`};return d.jsxs(E.Box,{position:"relative",className:"nowheel",onClick:H=>{if(R){H.stopPropagation();return}},sx:{cursor:R?"not-allowed":"default",pointerEvents:"auto",width:"100%",height:"100%"},children:[d.jsx(Rt.Handle,{type:"target",position:l?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:l?"50%":0,left:l?1:"50%",background:n.palette.common.white,border:`1px solid ${n.palette.neutral.main}`,opacity:R?.5:1},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:f,focused:y?.id===f||g,nodeData:e.data,actionBar:d.jsx(LE,{name:p.name,id:f,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:R,onRunWithPrevious:O}),sx:l?{height:N,minHeight:84,width:260}:{width:k>4?260+32*(k-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:f,nodeData:e,iconSrc:ui(_,x,p),title:p.name,running:I,proIntegration:R,pro:w})}),P.map((H,j)=>{const X=B(j,P.length,P),F=X==="failure"||X==="else";return d.jsx(vf,{type:"source",position:l?Rt.Position.Right:Rt.Position.Bottom,id:X,className:"sourceHandleStyle",style:{position:"absolute",top:L(j),left:M(j),transform:"translateY(-50%)",border:`1px solid ${F?n.palette.error[50]:n.palette.neutral.main}`,opacity:R?.5:1},isConnectable:!R,onClick:()=>{!s&&!R&&h(X,t,r,{top:l?L(j)-25.5:L(j)+48,left:l?M(j)+48:M(j)-25.5+3.5})},isValidConnection:V=>{const G=t.find(W=>V.source===W.id);if(!G||V.source===V.target||Ed(V.source,V.target,r))return!1;const $=r.filter(W=>W.type!==Hr.PLACEHOLDER);return!($.some(W=>G.id===W.source&&V.sourceHandle===W.sourceHandle)||$.some(W=>W.target===V.target&&W.source===V.source)||$.some(W=>W.target===V.target&&W.source!==V.source))}},`condition-branch-${j}`)})]})}),Ost=C.memo(e=>{const t=Rt.useNodes(),r=Rt.useEdges(),n=E.useTheme(),{isHorizontal:i,viewOnly:o,selectedActivityId:s}=pt.useSelector(dst),{activities:a,triggers:l}=pt.useSelector(NE),u=pt.useSelector(B=>cst(B,e.data.name)),c=Array.isArray(a)?a:[],f=Array.isArray(l)?l:[],p=Rt.useUpdateNodeInternals(),{id:h,data:A,selected:g,onHandleClick:m,handleDeleteNode:O,pro_integration:y,onRunWithPrevious:T}=e,v=ui(c,f,A,"pro"),_=!!v&&v!=="",x=_&&y===!1;C.useEffect(()=>{p(e.id)},[e.id,e.data?.properties?.continue_on_failure]);const b=C.useMemo(()=>t.find(B=>B.id===s),[t,s]),R=(Array.isArray(A?.properties?.branches)?A.properties.branches:[]).length+1,I=Math.max(R*16,84),N=(e.data.properties?.continue_on_failure===!0?2:1)+1,L=B=>{const H=N-1,j=H*8,X=(H-1)*8,F=j+X,G=(I-F+4)/2+B*16,D=i?G:86;return isNaN(D)?86:D},M=B=>{const j=i?255:(B+1)*(260/N);return isNaN(j)?255:j};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:x?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:i?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:o?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:i?"50%":0,left:i?1:"50%",background:n.palette.common.white,border:`1px solid ${n.palette.neutral.main}`},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:h,focused:b?.id===h||g,nodeData:e.data,actionBar:d.jsx(LE,{name:A.name,id:h,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:O,proIntegration:x,onRunWithPrevious:T}),sx:i?{height:I,minHeight:84,width:260}:{width:R>4?260+32*(R-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:h,nodeData:e,iconSrc:ui(c,f,A),title:A.name,running:u,proIntegration:x,pro:_})}),e.data.type!==Ze.RESPONSE&&d.jsx(vf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",onClick:()=>{!o&&!x&&m("outHandle",t,r,{top:i?L(0)-25.5:L(0)+48,left:i?M(0)+48:M(0)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:L(0),left:M(0),transform:"translateY(-50%)",border:`1px solid ${n.palette.neutral.main}`,opacity:x?.5:1},isValidConnection:B=>{const H=t.find(V=>B.source===V.id);if(B.source===B.target||Ed(B.source,B.target,r))return!1;const X=(H.outgoingPorts||[]).some(V=>!V.ref||V.ref!=="failure");return!r.some(V=>V.target===B.target&&V.type!==Hr.PLACEHOLDER)&&!X}}),e.data.properties?.continue_on_failure===!0&&d.jsx(vf,{type:"source",position:i?Rt.Position.Right:Rt.Position.Bottom,id:"failureHandle",onClick:()=>{!o&&!x&&m("failureHandle",t,r,{top:i?L(1)-25.5:L(1)+48,left:i?M(1)+48:M(1)-25.5+3.5})},isConnectable:!0,className:"sourceHandleStyle failureHandle",style:{position:"absolute",top:L(1),left:M(1),transform:"translateY(-50%)",border:`1px solid ${n.palette.error.main}`,background:n.palette.error.light,opacity:x?.5:1},isValidConnection:B=>{if(!t.find(D=>B.source===D.id)||B.source===B.target||Ed(B.source,B.target,r))return!1;const X=r.filter(D=>D.type!==Hr.PLACEHOLDER);return!(X.some(D=>D.source===B.source&&D.target===B.target&&D.sourceHandle==="failureHandle")||X.some(D=>D.target===B.target&&D.source===B.source)||X.some(D=>D.target===B.target&&D.source!==B.source))}})]})}),yst=C.memo(e=>{const t=Rt.useNodes(),r=Rt.useEdges(),n=E.useTheme(),{activityExecutionData:i,canvasWorkflow:o,viewOnly:s,selectedActivityId:a}=pt.useSelector(B=>B.canvas),l=t.find(B=>B.id===a),u=Rt.useUpdateNodeInternals(),{id:c,data:f,selected:p,onHandleClick:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,{activities:O,triggers:y}=pt.useSelector(NE),T=Array.isArray(O)?O:[],v=Array.isArray(y)?y:[],_=ui(T,v,f,"pro"),x=!!_&&_!=="",b=x&&g===!1,w=o?.meta?.isHorizontal??!0,R=f.properties?.no_of_parallel_threads||0;C.useEffect(()=>{u(c)},[c,R]);const I=i?.[f.name]?.loading??!1,P=B=>`parallel_${B}`,k=R+1,N=Math.max(k*16,84),L=B=>{const H=k-1,j=H*8,X=(H-1)*8,F=j+X,G=(N-F+4)/2+B*16,D=w?G:86;return isNaN(D)?86:D},M=B=>{const H=R+1,j=R>5?260+32*(R-4):260,X=w?255:(B+1)*(j/H);return isNaN(X)?255:X};return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:b?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:w?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!b,className:s?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:w?"50%":0,left:w?1:"50%",background:n.palette.common.white,border:`1px solid ${n.palette.neutral.main}`,opacity:b?.5:1},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:c,focused:l?.id===c||p,nodeData:e.data,actionBar:d.jsx(LE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:b,onRunWithPrevious:m}),sx:w?{height:`${N}px`,minHeight:84,width:260}:{width:R>5?260+32*(R-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:c,nodeData:e,iconSrc:ui(T,v,f),title:f.name,running:I,proIntegration:b,pro:x})}),[...Array(R)].map((B,H)=>d.jsx(vf,{type:"source",position:w?Rt.Position.Right:Rt.Position.Bottom,id:P(H),isConnectable:!0,className:"sourceHandleStyle",style:{top:L(H),left:M(H),transform:"translateY(-50%)",border:`1px solid ${n.palette.neutral.main}`,opacity:b?.5:1},isValidConnection:j=>{const X=t.find(U=>j.source===U.id);if(!X||j.source===j.target||Ed(j.source,j.target,r))return!1;const V=r.filter(U=>U.type!==Hr.PLACEHOLDER);return!(V.some(U=>X.id===U.source&&j.sourceHandle===U.sourceHandle)||V.some(U=>U.target===j.target&&U.source===j.source)||V.some(U=>U.target===j.target&&U.source!==j.source))},onClick:()=>{!s&&!b&&h(P(H),t,r,{top:w?L(H)-25.5:L(H)+48,left:w?M(H)+48:M(H)-25.5+3.5})}},`parallel-thread-${H}`))]})}),mre=({id:e,overlayProps:t,allowDrag:r=!1,hideTargetHandle:n=!1})=>{const i=E.useTheme(),o=Rt.useUpdateNodeInternals(),{canvasWorkflow:s}=pt.useSelector(l=>l.canvas),a=s?.meta?.isHorizontal??!0;return C.useEffect(()=>{e&&o(e)},[e,o]),d.jsxs("div",{style:{pointerEvents:"auto"},children:[!n&&d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:a?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:"targetHandleStyle",style:{top:a?"50%":0,left:a?0:"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}}),d.jsx(Gde,{open:!0,variant:"inline",draggable:!1,...t}),d.jsx(Rt.Handle,{type:"source",id:"outHandle",position:a?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!1,className:"sourceHandleStyle",style:{top:a?"50%":"100%",left:a?"100%":"50%",transform:"translate(-50%, -50%)",background:i.palette.common.white,border:`1px solid ${i.palette.neutral.main}`}})]})},vst=e=>{const{handle:t,tooltip:r,toggleListing:n,id:i}=e,o=E.useTheme(),{selectedPlaceholderId:s}=pt.useSelector(a=>a.canvas);return d.jsx(E.Box,{className:"nowheel",sx:{position:"relative",width:51,...s===i&&{"& .MuiButtonBase-root.MuiButton-root":{borderColor:o.palette.primary.main}}},children:d.jsx(E.Tooltip,{arrow:!0,title:r,disableInteractive:!0,children:d.jsxs("span",{children:[d.jsx(E.Button,{sx:{minWidth:50,width:51,height:51,border:`1px solid ${o.palette.grey.outlined.border}`,backgroundColor:o.palette.common.white,"& svg":{width:20,height:20},"&:hover":{backgroundColor:o.palette.common.white,transform:"none"}},onClick:n,children:d.jsx(Ue,{width:24,height:24,src:"ic_add_circle_outlined",sx:{path:{fill:o.palette.primary.main}}})}),t]})})})},Tst=e=>{const{handle:t,toggleListing:r,id:n}=e,i=E.useTheme(),{selectedPlaceholderId:o}=pt.useSelector(s=>s.canvas);return d.jsx(E.Box,{className:"nowheel",children:d.jsxs(E.Stack,{p:1.5,alignItems:"flex-start",border:`1px dashed ${i.palette.neutral.solid.bg}`,borderRadius:2,onClick:r,sx:{backgroundColor:i.palette.common.white,width:260,height:84,...o===n&&{borderColor:i.palette.primary.main}},children:[d.jsxs(E.Stack,{gap:1,width:"100%",children:[d.jsxs(E.Stack,{direction:"row",alignItems:"center",gap:1,children:[d.jsx(Ue,{src:"ic_spark",width:24,height:24,sx:{path:{fill:i.palette.primary.main}}}),d.jsx(E.Stack,{direction:"row",gap:.5,children:d.jsx(E.Typography,{variant:"smMedium",lineHeight:1,children:"Choose trigger"})})]}),d.jsx(E.Divider,{}),d.jsx(E.Typography,{variant:"smNormal",color:i.palette.text.tertiary,children:"Select an event"})]}),t]})})},Sst=({id:e,data:t,onHandleClick:r})=>{const{isTriggerPlaceholder:n}=t,i=E.useTheme(),o=Rt.useNodes(),s=Rt.useEdges(),{ENTITY_ID:a,allowedAccount:l}=Ii(),u=pt.useDispatch(),{activitiesPopover:c,viewOnly:f,canvasWorkflow:p,selectedActivityId:h}=pt.useSelector(O=>O.canvas),A=RE(a,l),g=p?.meta?.isHorizontal??!0,m=O=>{if(f)return;if(h&&u({type:Ad,payload:null}),u({type:C0,payload:e}),c?.active&&u({type:ss,payload:{type:"",active:!1,nodeId:null,edgeId:null}}),n&&!A){u({type:ss,payload:{type:"triggers",active:!0,nodeId:e,edgeId:null}}),u({type:ea,payload:!0});return}if(!A){u({type:ss,payload:{type:"activities",active:!0,nodeId:e,edgeId:null}}),u({type:ea,payload:!0});return}const y=O?.currentTarget?.getBoundingClientRect?.()??O?.target?.getBoundingClientRect?.();y&&Number.isFinite(y.left)&&Number.isFinite(y.top)?u({type:Zp,payload:{x:y.left+y.width/2,y:y.top+y.height/2}}):O?.clientX&&O?.clientY&&u({type:Zp,payload:{x:O.clientX,y:O.clientY}}),u({type:w0,payload:!1}),u({type:Ns,payload:"prompt"}),u({type:_0,payload:!0})};return n?d.jsx(Tst,{id:e,handle:d.jsx(vf,{type:"source",id:"outHandle",position:g?Rt.Position.Right:Rt.Position.Bottom,isConnectable:!0,className:"sourceHandleStyle",style:{...g?{top:45,left:255,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${i.palette.neutral.main}`},isValidConnection:O=>{if(!o.find(b=>O.source===b.id)||O.source===O.target||Ed(O.source,O.target,s))return!1;const v=s.filter(b=>b.type!==Hr.PLACEHOLDER);return!(v.some(b=>b.target===O.target&&b.source!==O.source)||v.some(b=>b.source===O.source))},onClick:O=>{O.stopPropagation(),!f&&r("outHandle",o,s,{top:g?42-25.5+2:132,left:g?308:130-25.5})}}),toggleListing:m}):d.jsx(vst,{id:e,handle:d.jsx(Rt.Handle,{type:"target",id:"targetHandle",position:g?Rt.Position.Left:Rt.Position.Top,isConnectable:!1,className:f?"viewModeCursor":"",style:{position:"absolute",background:"transparent",border:"none",left:g?0:"50%",top:g?"50%":0,transform:g?"translateY(-50%)":"translateX(-50%)"}}),tooltip:"Click here to add action",toggleListing:m})},xst=C.memo(e=>{const{canvasWorkflow:t,activityExecutionData:r,viewOnly:n,selectedActivityId:i}=pt.useSelector(L=>L.canvas),o=t?.meta?.isHorizontal??!0,s=Rt.useNodes(),a=Rt.useEdges(),l=E.useTheme(),u=Rt.useUpdateNodeInternals(),{id:c,data:f,onHandleClick:p,selected:h,handleDeleteNode:A,pro_integration:g,onRunWithPrevious:m}=e,O=s.find(L=>L.id===i),y=(f.properties?.cases?.length||0)+1;C.useEffect(()=>{u(c)},[c,f.properties?.cases?.length,u]);const T=r?.[f.name]?.loading??!1,{activities:v,triggers:_}=pt.useSelector(NE),x=Array.isArray(v)?v:[],b=Array.isArray(_)?_:[],w=ui(x,b,f,"pro"),R=!!w&&w!=="",I=R&&g===!1,P=Math.max(y*16,84),k=L=>o?y===1?P/2:P/(y+1)*(L+1):84,N=L=>{const M=y+1,B=y>4?260+32*(y-5):260;return o?o?254:253:(L+1)*(B/M)};return d.jsxs(E.Stack,{direction:o?"row":"column",alignItems:"center",position:"relative",className:"nowheel",sx:{cursor:I?"not-allowed":"default",pointerEvents:"auto"},children:[d.jsx(Rt.Handle,{type:"target",position:o?Rt.Position.Left:Rt.Position.Top,id:"targetHandle",isConnectable:!0,className:n?"targetHandleStyle viewModeCursor":"targetHandleStyle",style:{top:o?"50%":0,left:o?1:"50%",background:l.palette.common.white,border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},isConnectableStart:!1,children:d.jsx(Nx,{})}),d.jsx(kE,{id:c,focused:O?.id===c||h,nodeData:e.data,actionBar:d.jsx(LE,{name:f.name,id:c,isTriggerNode:!1,nodeData:e.data,handleDeleteNode:A,proIntegration:I,onRunWithPrevious:m}),sx:o?{height:`${P}px`,minHeight:84,width:260}:{width:y>4?260+32*(y-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:c,nodeData:e,running:T,iconSrc:ui(x,b,f),title:f.name,proIntegration:I,pro:R})}),d.jsxs(E.Stack,{gap:o?.5:2,direction:o?"column":"row",children:[(f.properties?.cases||[]).map((L,M)=>{const B=k(M),H=N(M);return d.jsx(vf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:`${L.caseKey}`,isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${B}px`,left:`${H}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.neutral.main}`,opacity:I?.5:1},onClick:()=>{if(!n&&!I&&p){const j=k(M),X=N(M);p(L.caseKey,s,a,{top:o?j-25.5:j+48,left:o?X+48:X-25.5+3.5})}},isValidConnection:j=>{const X=s.find(U=>j.source===U.id);if(!X||j.source===j.target||Ed(j.source,j.target,a))return!1;const V=a.filter(U=>U.type!==Hr.PLACEHOLDER);return!(V.some(U=>X.id===U.source&&j.sourceHandle===U.sourceHandle)||V.some(U=>U.target===j.target&&U.source===j.source)||V.some(U=>U.target===j.target&&U.source!==j.source))}},`${L.caseKey}-${M}`)}),d.jsx(vf,{type:"source",position:o?Rt.Position.Right:Rt.Position.Bottom,id:"defaultHandle",isConnectable:!0,className:"sourceHandleStyle",style:{position:"absolute",top:`${k(f.properties?.cases?.length||0)}px`,left:`${N(f.properties?.cases?.length||0)}px`,transform:"translateY(-50%)",border:`1px solid ${l.palette.error[50]}`,opacity:I?.5:1},onClick:()=>{if(!n&&!I&&p){const L=f.properties?.cases?.length||0,M=k(L),B=N(L);p("defaultHandle",s,a,{top:o?M-25.5:M+48,left:o?B+48:B-25.5+3.5})}},isValidConnection:L=>{const M=s.find(V=>L.source===V.id);if(!M||L.source===L.target||Ed(L.source,L.target,a))return!1;const H=a.filter(V=>V.type!==Hr.PLACEHOLDER);return!(H.some(V=>M.id===V.source&&L.sourceHandle===V.sourceHandle)||H.some(V=>V.target===L.target&&V.source===L.source)||H.some(V=>V.target===L.target&&V.source!==L.source))}},"defaultHandle")]})]})}),bst=C.memo(e=>{const{id:t,data:r,selected:n,onHandleClick:i,VORTEX_MAIN_URL:o,ENTITY_ID:s,handleDeleteNode:a,currentSubscription:l,pro_integration:u}=e,c=bn(Dr.VERSION),f=_o(),p=bn(f),h=pt.useDispatch(),A=E.useTheme(),{analytics:g}=Ii(),m=Rt.useNodes(),O=Rt.useEdges(),{workflow:y}=pt.useSelector(U=>U.workflows),{canvasWorkflow:T,activityExecutionData:v,viewOnly:_,showDebugLogs:x,selectedActivityId:b}=pt.useSelector(U=>U.canvas),w=m.find(U=>U.id===b),R=T?.meta?.isHorizontal??!0,I=m?.find(U=>U?.type===xt.TRIGGER),{activities:P,triggers:k}=pt.useSelector(NE),N=Array.isArray(P)?P:[],L=Array.isArray(k)?k:[],M=ui(N,L,r,"pro"),B=!!M&&M!=="",H=B&&u===!1,[j,X]=C.useState(!1),F=v?.[r.name]?.loading??!1,V=I?.data?.type,D=(Array.isArray(r?.properties?.branches)?r.properties.branches:[]).length+1,$=Math.max(D*16,84);return d.jsxs(E.Box,{position:"relative",className:"nowheel",sx:{cursor:H?"not-allowed":"default",pointerEvents:"auto"},children:[p&&I&&V!==Ze.HTTP&&d.jsx(E.Tooltip,{arrow:!0,title:l?.workflowExecution?.remaining<=0?"You cannot execute this workflow as you have reached execution limit.":l[0]?.status==="EXPIRED"?"You cannot execute this workflow as your subscription has expired.":l[0]?.status==="CANCELLED"?"You cannot execute this workflow as your subscription has been cancelled.":"Run Workflow",children:d.jsx(E.Box,{sx:{display:"inline-flex",position:"absolute",top:28,left:-44},children:d.jsx(E.IconButton,{color:"primary",sx:{width:32,height:32,color:U=>U.palette.primary.main,opacity:l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED"?.3:1,cursor:"pointer",backgroundColor:A.palette.common.white,border:`1px solid ${b||j?A.palette.neutral.outlined.border:A.palette.primary.main}`,"&:hover":{backgroundColor:A.palette.common.white}},onClick:async()=>{if(I)if(I0(I,m)){const q=vt(c)?p:c;X(!0),await W6(y,q,[I],h,o,s,c,p,x,g),X(!1)}else h({type:Xr,payload:{open:!0,title:"Please complete all activities configurations to execute this workflow",type:"error"}})},disabled:!!b||j||l?.workflowExecution?.remaining<=0||l[0]?.status==="EXPIRED"||l[0]?.status==="CANCELLED",children:j?d.jsx(E.CircularProgress,{sx:{color:A.palette.grey.normal},size:16}):d.jsx(Ue,{src:"ic_run",sx:{path:{fill:b?"currentColor":A.palette.primary.main}}})})})}),d.jsx(kE,{focused:w?.id===t||n,id:t,nodeData:e.data,actionBar:d.jsx(LE,{name:r.name,id:t,isTriggerNode:!0,nodeData:e.data,handleDeleteNode:a,proIntegration:H}),sx:R?{height:$,minHeight:84,width:260}:{width:D>4?260+32*(D-4):260,minWidth:260,height:84,minHeight:84},children:d.jsx(FE,{id:t,nodeData:e,iconSrc:ui(N,L,r),title:r.name,running:F,isTriggerNode:!0,meta:ui(N,L,r,"meta"),proIntegration:H,pro:B})}),d.jsx(vf,{type:"source",onClick:()=>{!_&&!H&&i("outHandle",m,O,{top:R?42-25.5:132,left:R?308:130-25.5})},position:R?Rt.Position.Right:Rt.Position.Bottom,id:"outHandle",isConnectable:!0,className:"sourceHandleStyle",style:{...R?{top:"50%",left:256,transform:"translateY(-50%)"}:{left:"50%"},border:`1px solid ${A.palette.neutral.main}`,opacity:H?.5:1},isValidConnection:U=>{if(!m.find(J=>U.source===J.id)||U.source===U.target||Ed(U.source,U.target,O))return!1;const W=O.filter(J=>J.type!==Hr.PLACEHOLDER);return!(W.some(J=>J.target===U.target&&J.source!==U.source)||W.some(J=>J.source===U.source))}})]})}),Cst=(e,t,r,n,i)=>{const o=E.useTheme(),s=Rt.useNodes(),a=Rt.useEdges(),l=pt.useDispatch(),u=bn(),{analytics:c,ENTITY_ID:f,WORKFLOW_URLS:p}=Ii(),{activity_names:h}=pt.useSelector(I=>I.activities),{selectedPlaceholderId:A}=pt.useSelector(I=>I.canvas),g=(I,P)=>[...I,P],{captureEvent:m,WORKFLOW_EVENTS:O}=c||{},y=C.useCallback(I=>{I.preventDefault(),A&&l({type:Kp,payload:null});const P=JSON.parse(I.dataTransfer.getData("application/reactflow")),{currentNodeId:k,parentNodeId:N,isTrigger:L}=P,M=s.find(U=>U.id===k);let B=k||Na(P?.name||"node",s);if(P.openingFromPlaceholder){typeof k=="string"&&k.startsWith("placeholder_")&&!M&&(B=Na(P?.name||"node",s)),M?.type===xt.PLACEHOLDER&&(B=Na(P?.name||"node",s));const U=l1(I,P,e,B,s,u,i,N?[N]:[],{x:M?.position?.x,y:(M?.position?.y||0)-16});XC(l,U,L,N,M,k,h,n,r,s,a,m,O,f||"",u||void 0,p?.VORTEX_MAIN_URL);return}if(s.some(U=>U.type===xt.TRIGGER)&&L){l({type:Xr,payload:{open:!0,title:"Only one trigger is allowed",type:"error"}});return}l({type:Ad,payload:null});const j=s.find(U=>U.type===xt.PLACEHOLDER&&U.data?.isTriggerPlaceholder),X=j?.id,F=s.filter(U=>U.type!==xt.TRIGGER),V=Na(P?.name||"trigger",F),G=P.type===xt.TRIGGER&&j?.position?j.position:null,D=l1(I,P,e,P.type===xt.TRIGGER?V:B,s,u,i,[],G);l({type:"SET_ACTIVITY_NAMES",payload:[...h,D.data.name]}),t(),l({type:ea,payload:!1});const $=s.filter(U=>U.type!==xt.PLACEHOLDER&&U.type!==xt.TRIGGER);if(u&&$.length===0&&D.type!==xt.TRIGGER&&!P.openingFromPlaceholder){const U=s.find(q=>q.type===xt.TRIGGER||q?.data?.isTriggerPlaceholder);if(U){const q={source:U.id,sourceHandle:"outHandle",target:D.id,targetHandle:"targetHandle",type:U.type===Hr.PLACEHOLDER?Hr.PLACEHOLDER:Hr.SMOOTH},z=[...s,D];m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:D?.data?.properties?.integration_slug,name:D?.data?.name}),T(q,z,a)}}else{let U;j&&D.type===xt.TRIGGER?U=s.map(q=>q.type===xt.PLACEHOLDER&&q.data?.isTriggerPlaceholder?D:q):U=g(s,D),j&&X&&X!==D.id&&D.type===xt.TRIGGER&&(U=U.map(q=>{if(Array.isArray(q.incomingPorts)&&q.incomingPorts.includes(X))return{...q,incomingPorts:q.incomingPorts.map(z=>z===X?D.id:z)};if(q.id===D.id&&j.outgoingPorts){const z=j.outgoingPorts.map(W=>{const Q=U.find(Y=>Array.isArray(Y.incomingPorts)&&Y.incomingPorts.includes(X));return Q?{...W,id:Q.id}:W});return{...q,outgoingPorts:z}}return q}),n(q=>(q||a).map(z=>({...z,source:z.source===X?D.id:z.source,target:z.target===X?D.id:z.target})))),m?.(O.WORKFLOW.ACTIVITY_ADD,{"console.product_account_id":f,message:"Activity added to workflow",integration_slug:D?.data?.properties?.integration_slug,name:D?.data?.name}),r(U)}l({type:Au,payload:{id:D.id}})},[s,a,l,e,u,i,h,n,r,m,O,f,p?.VORTEX_MAIN_URL,o]),T=C.useCallback((I,P,k)=>{const N={...I,type:"smooth",id:K4(k||a),markerEnd:{type:Rt.MarkerType.ArrowClosed,color:w4(I,o)}};t();const L=Mo(P||s).map(M=>{if(M.id===I.source){const B=(P||s).find(H=>H.id===I.target);I.sourceHandle==="failureHandle"?M.outgoingPorts.push({id:B?.id,ref:"failure",name:B?.data.name}):I.sourceHandle!=="outHandle"?M.outgoingPorts.push({id:B?.id,ref:I.sourceHandle,name:B?.data.name}):M.outgoingPorts.push({id:B?.id,name:B?.data.name})}if(M.id===I.target){const B=(P||s).find(H=>H.id===I.source);M.incomingPorts.push(B?.id)}return M});r(L),n(Rt.addEdge(N,k||a)),t()},[s,a,r,n,o,t]),v=C.useCallback(()=>{t()},[t]),_=C.useCallback((I,P)=>{r(k=>{const N=!!(I&&(I.shiftKey||I.metaKey||I.ctrlKey)),L=k.reduce((M,B)=>{const H=B.zIndex??0;return H>M?H:M},0)||0;return k.map(M=>M.id===P.id?{...M,zIndex:L+1,style:{...M.style||{},zIndex:L+1},...N?{}:{selected:!0}}:N?M:{...M,selected:!1})}),t()},[r,t]),x=C.useCallback(I=>{I&&I.length>0&&r(P=>{let k=[...P];return I.forEach(N=>{const L=N.target,M=N.source;k=k.map(B=>{if(B.id===L){const{data:H,...j}=B,{ref:X,...F}=H;return{...j,data:F,incomingPorts:(B.incomingPorts||[]).filter(V=>V!==M)}}return B.id===M?{...B,outgoingPorts:(B.outgoingPorts||[]).filter(H=>H.id!==L)}:B})}),k}),t()},[r,t]),b=C.useCallback(()=>{s.find(P=>P.selected)&&r(P=>P.map(k=>({...k,selected:!1}))),t()},[s,r]),w=C.useCallback(I=>{I.shiftKey&&I.preventDefault()},[]),R=C.useCallback(I=>{const{nodes:P}=I,k=a||[],N=s||[];if(!Array.isArray(P)||P.length===0){t();return}P.forEach(W=>{W.type!==xt.PLACEHOLDER&&l({type:d4,payload:{id:W.id}})});const L=P.map(W=>W.id),M=new Set(L),B=k.filter(W=>M.has(W.source)||M.has(W.target)),H=new Set;B.forEach(W=>{const Q=N.find(J=>J.id===W.source),Y=N.find(J=>J.id===W.target);Q?.type===xt.PLACEHOLDER&&!M.has(Q.id)&&H.add(Q.id),Y?.type===xt.PLACEHOLDER&&!M.has(Y.id)&&H.add(Y.id)}),N.forEach(W=>{if(W?.type!==xt.PLACEHOLDER)return;const Q=Array.isArray(W.incomingPorts)&&W.incomingPorts.some(J=>M.has(J)),Y=Array.isArray(W.outgoingPorts)&&W.outgoingPorts.some(J=>M.has(J?.id));(Q||Y)&&H.add(W.id)});const j=[];P.forEach(W=>{if(W.type===xt.TRIGGER||W.type===xt.PLACEHOLDER)return;if(!(W.outgoingPorts&&W.outgoingPorts.length>1||W.data?.properties?.continue_on_failure===!0||W.data?.properties?.cases&&W.data.properties.cases.length>0||W.data?.properties?.branches&&W.data.properties.branches.length>1)){const Y=B.filter(ee=>ee.target===W.id&&ee.type!==Hr.PLACEHOLDER),J=B.filter(ee=>ee.source===W.id&&ee.type!==Hr.PLACEHOLDER);if(Y.length===1&&J.length===1){const ee=Y[0].source,le=J[0].target;if(M.has(ee)||M.has(le)||H.has(ee)||H.has(le))return;j.push({sourceNodeId:ee,targetNodeId:le,sourceHandle:Y[0].sourceHandle||"outHandle",targetHandle:J[0].targetHandle||"targetHandle"})}}});let X=N.filter(W=>!(M.has(W.id)||H.has(W.id)));const F=P.find(W=>W.type===xt.TRIGGER);if(F){const W=_4(),Q=Na("trigger-placeholder",X);X=[{...W,id:Q,position:F.position},...X]}const V=new Set(X.map(W=>W.id));let G=k.filter(W=>V.has(W.source)&&V.has(W.target));j.length>0&&j.forEach(({sourceNodeId:W,targetNodeId:Q,sourceHandle:Y,targetHandle:J})=>{if(!V.has(W)||!V.has(Q)||G.some(ne=>ne.source===W&&ne.target===Q&&(ne.sourceHandle||"outHandle")===(Y||"outHandle")&&(ne.targetHandle||"targetHandle")===(J||"targetHandle")&&ne.type!==Hr.PLACEHOLDER))return;const le={id:K4(G),source:W,sourceHandle:Y,target:Q,targetHandle:J,type:Hr.SMOOTH,markerEnd:{type:Rt.MarkerType.ArrowClosed,color:w4({sourceHandle:Y},o)}};G=Rt.addEdge(le,G)});const D=new Map;X.forEach(W=>D.set(W.id,W?.data?.name));const $=new Map,U=new Map;(G||[]).filter(W=>W.type!==Hr.PLACEHOLDER).forEach(W=>{if(!V.has(W.source)||!V.has(W.target))return;const Q=$.get(W.target)||new Set;Q.add(W.source),$.set(W.target,Q);const Y=W.sourceHandle==="failureHandle"?"failure":W.sourceHandle&&W.sourceHandle!=="outHandle"?W.sourceHandle:void 0,J=U.get(W.source)||[];J.push({id:W.target,name:D.get(W.target),...Y?{ref:Y}:{}}),U.set(W.source,J)});const z=X.map(W=>{const Q=Array.from($.get(W.id)||[]),Y=U.get(W.id)||[],J=new Set,ee=Y.filter(ve=>{const oe=`${ve?.id||""}::${ve?.ref||""}`;return J.has(oe)?!1:(J.add(oe),!0)}),{data:le,...ne}=W,{ref:ue,...Oe}=le||{};return{...ne,data:Oe,incomingPorts:Q,outgoingPorts:ee}});n(G),r(z),t()},[s,a,r,n,t,l,o]);return{onDrop:y,onConnect:T,onSelectionDragStart:v,onEdgesDelete:x,onPaneClick:b,onMouseDown:w,onDelete:R,onNodeDragStart:_}},U8={maxHistorySize:25,enableShortcuts:!0},_st=({maxHistorySize:e=U8.maxHistorySize,enableShortcuts:t=U8.enableShortcuts}=U8)=>{const{getNodes:r,getEdges:n,setNodes:i,setEdges:o}=Rt.useReactFlow(),{selectedActivityId:s}=pt.useSelector(y=>y.canvas),a=r(),l=n(),[u,c]=C.useState([]),[f,p]=C.useState([]),h=C.useCallback(()=>{c(y=>{const T=y[y.length-1];return T&&T.nodes===a&&T.edges===l?y:[...y.slice(-e+1),{nodes:a,edges:l}]}),p([])},[a,l,e]),A=()=>{c([]),p([])},g=C.useCallback((y,T,v,_)=>{if(s)return;const x=y[y.length-1];if(x){const b=y.slice(0,-1),w=[...T,{nodes:a,edges:l}];v(b),_(w),i(x.nodes),o(x.edges)}},[i,o,a,l]),m=C.useCallback(()=>g(u,f,c,p),[u,f,g]),O=C.useCallback(()=>g(f,u,p,c),[u,f,g]);return C.useEffect(()=>{if(!t)return;const y=T=>{T.key==="z"&&(T.ctrlKey||T.metaKey)&&T.shiftKey?O():T.key==="z"&&(T.ctrlKey||T.metaKey)&&m()};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},[m,O,t]),{undo:m,redo:O,takeSnapshot:h,clearSnapshot:A,canUndo:!u.length,canRedo:!f.length}},wst=({open:e})=>{const t=pf();return e?d.jsxs(E.Stack,{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center",spacing:1,sx:{backgroundColor:Za(t.palette.common.white,.75),pointerEvents:"auto",zIndex:t.zIndex.modal},children:[d.jsx(Oi,{size:32}),d.jsx(E.Typography,{variant:"smNormal",sx:{color:"text.secondary"},children:"Arranging automation canvas..."})]}):null},ME=["When a new message is posted in Slack","When a new email is received in Gmail","When a webhook is received"],gre=["Send email via Gmail","Post to Slack channel","Make API call"],Ist=new Set(["maximum_timeout","continue_on_failure","retry_config.maximum_timeout","retry_config.maximum_attempts","retry_config.backoff_coefficient","retry_config.initial_interval","retry_config.maximum_interval"]),Dst=e=>{const t=String(e||"").trim();return!!(!t||Ist.has(t))},Ere=(e,t,r="")=>{if(!e||typeof e!="object")return{};const n={},i=Object.entries(e);for(const[o,s]of i){const a=String(o),l=r?`${r}.${a}`:a;if(!t(l)&&!(s==null||s==="")){if(Array.isArray(s)){s.length>0&&(n[l]=s);continue}if(typeof s=="object"){Object.assign(n,Ere(s,t,l));continue}n[l]=s}}return n},Ore=e=>e==="prompt"||e==="error"||e===void 0,yre=({promptKind:e,mode:t,promptValue:r,onPromptChange:n,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f,setChoice:p,onContinueChoice:h,auth:A,setAuth:g,onContinueAuth:m,parameters:O,setParameters:y,onContinueParameters:T,inferTesseractEntity:v,ENTITY_ID:_,WORKFLOW_URLS:x,openIntegrationDrawer:b,onAddNewAccount:w,vortexMainUrl:R})=>({promptKind:e,mode:t,promptValue:r,onPromptChange:n,onClose:i,onSubmit:o,onRetry:s,onAddManually:a,steps:l,suggestions:u,errorText:c,choice:f?{label:f.label,options:f.options,selected:f.selected,multiSelect:f.multiSelect,selectedMultiple:f.selectedMultiple,onSelect:I=>p(P=>P&&{...P,selected:I}),onSelectMultiple:I=>p(P=>P&&{...P,selectedMultiple:I}),onContinue:h,continueDisabled:f.multiSelect?!(f.selectedMultiple&&f.selectedMultiple.length>0):!f.selected}:null,auth:A?{label:A.label,options:A.options,selected:A.selected,loading:A.loading,errorText:A.errorText,onSelect:I=>g(P=>P&&{...P,selected:I}),onContinue:m,continueDisabled:A.loading||!A.selected,addNewAccount:{type:v(A.integration_slug,A.field_name),ENTITY_ID:String(_||""),FRONTEND_URL:String(x?.FRONTEND_URL??""),TESSERACT_MAIN_URL:String(x?.TESSERACT_MAIN_URL??""),openIntegrationDrawer:b,onClick:w}}:null,parameters:O?{integrationName:O.integrationName,fields:O.fields,values:O.values,resolvedAuth:O.resolvedAuth,entityId:O.entityId,onValuesChange:I=>y(P=>P&&{...P,values:I}),onContinue:I=>T(I),continueDisabled:O.fields.some(I=>{const P=String(I.name??""),k=O.values[P];return I.required&&(k==null||String(k).trim()==="")})}:null,vortexMainUrl:R,workflowUrls:x});async function Rst(e){const{baseUrl:t,body:r,signal:n,onMessage:i}=e;let o="",s=0;const a=f=>{const p=f.split(`
688
688
  `).map(O=>O.trimEnd()).filter(O=>O.length>0);let h=null;const A=[];for(const O of p)O.startsWith("event:")?h=O.slice(6).trim():O.startsWith("data:")&&A.push(O.slice(5).trim());if(!h)return;const g=A.join(`
689
689
  `);let m=g;try{m=g?JSON.parse(g):{}}catch{}i({event:h,data:m})},l=()=>{let f;for(;(f=o.indexOf(`
690
690