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{b as w,$ as V,h as W,k as q,i as D,j as r,_ as l}from"./main.2.8.1.js";import{u as T,d as f}from"./react-router-dom.9mCuUg3q.js";import{S as z}from"./SnackMsg.S8DrwLlT.js";import{al as x}from"./Note.BeM7sN-p.js";import{S as B,I as G,s as F}from"./Integrations.D2bgBas2.js";import{h as H,i as J,c as _}from"./FabmanCommonFunc.Cuzm8kdW.js";import{F as K}from"./FabmanIntegLayout.B2Pal0x8.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function le({allIntegURL:s}){const t=T(),[a,O]=w(V),[e,m]=w(W),[d,y]=f.useState({list:!1,field:!1,auth:!1}),[N,o]=f.useState({show:!1}),c=q(D),[j,k]=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:l("Please select an action","bit-integrations")});return}if(["update_member","delete_member"].includes(e.actionName)){if(!_(e)){o({show:!0,msg:l("Please map mandatory fields","bit-integrations")});return}if(S()){o({show:!0,msg:l("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:l("Please map mandatory fields","bit-integrations")});return}if((e.actionName==="update_spaces"||e.actionName==="delete_spaces")&&!e.selectedWorkspace){o({show:!0,msg:l("Please select a workspace","bit-integrations")});return}F({flow:a,allIntegURL:s,conf:e,navigate:t,edit:1,setSnackbar:o})},I=n=>{k(n.target.value),m(i=>b(h({},i),{name:n.target.value}))};return r.jsxs("div",{style:{width:900},children:[r.jsx(z,{snack:N,setSnackbar:o}),r.jsxs("div",{className:"flx mt-3",children:[r.jsx("b",{className:"wdt-200 d-in-b",children:l("Integration Name:","bit-integrations")}),r.jsx("input",{className:"btcd-paper-inp w-5",onChange:I,name:"name",value:j,type:"text",placeholder:l("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,m),fabmanConf:e,setFabmanConf:m,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:m,formFields:c}),r.jsx("br",{})]})}export{le as default};
