var P=Object.defineProperty,A=Object.defineProperties;var M=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var g=(s,t,a)=>t in s?P(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,h=(s,t)=>{for(var a in t||(t={}))R.call(t,a)&&g(s,a,t[a]);if(u)for(var a of u(t))$.call(t,a)&&g(s,a,t[a]);return s},b=(s,t)=>A(s,M(t));import{h as w,$ as V,g as W,k as q,i as D,j as r,_ as m}from"./main.2.9.0.js";import{u as T,b as f}from"./react-router.DMwpH23k.js";import{S as z}from"./SnackMsg.DYSD96P4.js";import{ak as x}from"./Note.NSUdvR3c.js";import"./CopyIcn.CEA_lFLo.js";import{S as B,I as G,s as F}from"./Integrations.DL8wqGct.js";import{h as H,i as J,c as _}from"./FabmanCommonFunc.B7Fqgi78.js";import{F as K}from"./FabmanIntegLayout.D8WF9Wcw.js";import"./react-vendor.P7K3d6op.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function le({allIntegURL:s}){const t=T(),[a,O]=w(V),[e,l]=w(W),[d,y]=f.useState({list:!1,field:!1,auth:!1}),[k,o]=f.useState({show:!1}),c=q(D),[N,j]=f.useState(e.name||""),v=()=>(Array.isArray(e==null?void 0:e.field_map)?e.field_map:[]).find(i=>(i==null?void 0:i.fabmanFormField)==="emailAddress"),S=()=>{const n=v();if(!n)return!0;if(n.formField==="custom"){const p=(n.customValue||"").trim();return!p||!x(p)}const i=(c||[]).find(p=>p.name===n.formField);if(!i)return!0;const E=i.type&&String(i.type).toLowerCase()==="email",L=/email/i.test(i.name||"")||/email/i.test(i.label||"");return!E&&i.type&&!L},C=()=>{if(!e.actionName){o({show:!0,msg:m("Please select an action","bit-integrations")});return}if(["update_member","delete_member"].includes(e.actionName)){if(!_(e)){o({show:!0,msg:m("Please map mandatory fields","bit-integrations")});return}if(S()){o({show:!0,msg:m("Please map a valid email address","bit-integrations")});return}F({flow:a,allIntegURL:s,conf:e,navigate:t,edit:1,setSnackbar:o});return}if(!_(e)){o({show:!0,msg:m("Please map mandatory fields","bit-integrations")});return}if((e.actionName==="update_spaces"||e.actionName==="delete_spaces")&&!e.selectedWorkspace){o({show:!0,msg:m("Please select a workspace","bit-integrations")});return}F({flow:a,allIntegURL:s,conf:e,navigate:t,edit:1,setSnackbar:o})},I=n=>{j(n.target.value),l(i=>b(h({},i),{name:n.target.value}))};return r.jsxs("div",{style:{width:900},children:[r.jsx(z,{snack:k,setSnackbar:o}),r.jsxs("div",{className:"flx mt-3",children:[r.jsx("b",{className:"wdt-200 d-in-b",children:m("Integration Name:","bit-integrations")}),r.jsx("input",{className:"btcd-paper-inp w-5",onChange:I,name:"name",value:N,type:"text",placeholder:m("Integration Name...","bit-integrations")})]}),r.jsx("br",{}),r.jsx(B,{entity:a.triggered_entity,setSnackbar:o}),r.jsx(K,{formID:a.triggered_entity_id,formFields:c,handleInput:n=>H(n,e,l),fabmanConf:e,setFabmanConf:l,loading:d,setLoading:y,setSnackbar:o}),r.jsx(G,{edit:!0,saveConfig:C,disabled:J(e,c,x),isLoading:d.list||d.field||d.auth,dataConf:e,setDataConf:l,formFields:c}),r.jsx("br",{})]})}export{le as default};
