import{_ as a,j as e}from"./main.2.8.10.js";import{u as j,e as v,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{B as C}from"./BackIcn.BFDZx8No.js";import{S as I}from"./SnackMsg.7BjcJK1j.js";import{S}from"./Steps.B84Ui3GU.js";import{I as k,g as y}from"./Integrations.BFhED4ck.js";import N from"./CampaignMonitorAuthorization.tRmmIISU.js";import{c as _}from"./CampaignMonitorCommonFunc.8rIeLB4z.js";import{C as M}from"./CampaignMonitorIntegLayout.BOjrLi_p.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function U({formFields:l,setFlow:d,flow:g,allIntegURL:u}){const f=j(),{formID:p}=v(),[r,n]=o.useState(!1),[s,c]=o.useState(1),[b,i]=o.useState({show:!1}),x=[{key:"Name",label:a("Name","bit-integrations"),required:!1},{key:"EmailAddress",label:a("Email Address","bit-integrations"),required:!0}],[t,m]=o.useState({name:"CampaignMonitor",type:"CampaignMonitor",client_id:"",api_key:"",field_map:[{formField:"",campaignMonitorField:""}],subscriberFields:x,actions:{}}),h=w=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300);{if(!_(t)){i({show:!0,msg:a("Please map all required fields to continue.","bit-integrations")});return}if(!(t!=null&&t.listId)){i({show:!0,msg:a("Please select list to continue.","bit-integrations")});return}t.name!==""&&t.field_map.length>0&&c(3)}};return e.jsxs("div",{children:[e.jsx(I,{snack:b,setSnackbar:i}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(S,{step:3,active:s})}),e.jsx(N,{formID:p,campaignMonitorConf:t,setCampaignMonitorConf:m,step:s,setstep:c,isLoading:r,setIsLoading:n,setSnackbar:i}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===2&&900,height:s===2&&"auto"},children:[e.jsx(M,{formID:p,formFields:l,campaignMonitorConf:t,setCampaignMonitorConf:m,isLoading:r,setIsLoading:n,setSnackbar:i}),e.jsxs("button",{onClick:()=>h(),disabled:!(t!=null&&t.listId)||t.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[a("Next","bit-integrations"),"  ",e.jsx(C,{className:"ml-1 rev-icn"})]})]}),e.jsx(k,{step:s,saveConfig:()=>y(g,d,u,t,f,"","",n),isLoading:r,dataConf:t,setDataConf:m,formFields:l})]})}export{U as default};
