var L=Object.defineProperty;var j=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var k=(i,e,s)=>e in i?L(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s,y=(i,e)=>{for(var s in e||(e={}))z.call(e,s)&&k(i,s,e[s]);if(j)for(var s of j(e))B.call(e,s)&&k(i,s,e[s]);return i};import{G as J,g as O,r as l,f as _,j as a,S as $,M as q,_ as G}from"./main-343.js";import"./bf-649-79.js";import{S as H}from"./bf-149-261.js";import{C as K}from"./bf-559-89.js";import{ac as Q,a7 as V}from"./bf-659-81.js";import{I as W}from"./bf-58-184.js";import{N as X}from"./bf-713-109.js";import v from"./bf-849-122.js";import{f as Y,a as Z,c as C}from"./bf-164-177.js";import{A as R}from"./bf-692-222.js";import"./bf-974-82.js";import"./bf-594-113.js";import"./bf-745-202.js";function ut({formFields:i,setIntegration:e,integrations:s,allIntegURL:A}){const x=J(),{formID:h}=O(),[N,m]=l.useState(!1),[g,d]=l.useState(!1),[o,u]=l.useState(1),[M,c]=l.useState({show:!1}),P=[{key:"1",label:"Add/Update Subscriber"},{key:"2",label:"Delete Subscriber"}],E=[{key:"email",label:"Email",required:!0}],[t,n]=l.useState({name:"Acumbamail",type:"Acumbamail",mainAction:"",listId:"",auth_token:"",field_map:[{formField:"",acumbamailFormField:"email"}],addSubsCriberFields:E,allActions:P,address_field:[],actions:{}}),b=Q([t.type]),F=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!C(t)){c({show:!0,msg:"Please map fields to continue."});return}t.listId!==""&&u(3)},T=()=>{V(s,e,A,t,x)},D=(r,w)=>{if(r.integration_type===t.type){const f=JSON.parse(r.integration_details);n(p=>_(p,I=>{I.parentAppId=r.id,I.auth_token=f.auth_token})),u(2)}},S=()=>{setTimeout(()=>{x(`${A}/new/${t.type}`)},1e3),m(!1)};return l.useEffect(()=>{n(r=>_(r,w=>{const f=b.find(p=>p.id===t.parentAppId);if(f){const p=JSON.parse(f.integration_details);w.auth_token=p.auth_token}})),t!=null&&t.parentAppId&&Y(t,n,d)},[t.parentAppId]),a.jsxs("div",{children:[a.jsx($,{snack:M,setSnackbar:c}),a.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:a.jsx(H,{step:3,active:o})}),a.jsx(q,{title:G("Connect New Active Campaing API"),show:N,setModal:()=>m(!1),children:a.jsx(v,{formID:h,acumbamailConf:t,setAcumbamailConf:n,step:o,setstep:u,isLoading:g,setIsLoading:d,setSnackbar:c,authorizedAction:S})}),b.length>0&&o===1&&a.jsx(K,{allIntegURL:A,specificTypes:[t.type],onClickAction:D,allowAddNew:!0,addNewAction:()=>m(!0)}),o===1&&b.length===0&&a.jsx(v,{formID:h,acumbamailConf:t,setAcumbamailConf:n,step:o,setstep:u,isLoading:g,setIsLoading:d,setSnackbar:c,authorizedAction:S}),a.jsxs("div",{className:"btcd-stp-page",style:y({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(R,{formFields:i,handleInput:r=>Z(r,t,n,d,c,h),acumbamailConf:t,setAcumbamailConf:n,isLoading:g,setIsLoading:d,setSnackbar:c,setShowMdl:m}),a.jsx(X,{nextPageHandler:()=>F(),disabled:!t.mainAction||!C(t)})]}),a.jsx(W,{step:o,saveConfig:()=>T()})]})}export{ut as default};
