import{u as j,k as S,r as a,j as e}from"./main-406.js";import{d as b,_ as M,I as k,s as v}from"./bi.394.85.js";import{B as w}from"./bi.46.744.js";import{S as N}from"./bi.68.941.js";import _ from"./bi.735.243.js";import{s as y,h as L,f as E,c as P}from"./bi.189.732.js";import{M as T}from"./bi.401.733.js";import"./bi.150.760.js";import"./bi.209.734.js";import"./bi.704.707.js";import"./bi.701.708.js";function O({formFields:d,setFlow:f,flow:h,allIntegURL:g}){const x=j(),{formID:m}=S(),[l,n]=a.useState(!1),[c,p]=a.useState({}),[i,u]=a.useState(1),[C,s]=a.useState({show:!1}),[t,o]=a.useState({name:"Mail Chimp",type:"Mail Chimp",clientId:"",clientSecret:"",listId:"",listName:"",tags:"",field_map:[{formField:"",mailChimpField:""}],address_field:[],module:"",actions:{},moduleLists:[]});a.useEffect(()=>{window.opener&&y("mailChimp")},[]);const I=()=>{var r;if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),(r=t.actions)!=null&&r.address&&!E(t)){s({show:!0,msg:"Please map address required fields to continue."});return}if(!P(t)){s({show:!0,msg:"Please map fields to continue."});return}t.listId!==""&&u(3)};return e.jsxs("div",{children:[e.jsx(b,{snack:C,setSnackbar:s}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(N,{step:3,active:i})}),e.jsx(_,{formID:m,mailChimpConf:t,setMailChimpConf:o,step:i,setstep:u,isLoading:l,setIsLoading:n,setSnackbar:s}),e.jsxs("div",{className:"btcd-stp-page",style:{width:i===2&&900,height:i===2&&"auto"},children:[e.jsx(T,{formID:m,formFields:d,handleInput:r=>L(r,t,o,m,c,p,s,n),mailChimpConf:t,setMailChimpConf:o,isLoading:l,setIsLoading:n,setSnackbar:s,loading:c,setLoading:p}),e.jsxs("button",{onClick:()=>I(),disabled:!t.listId||t.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[M("Next","bit-integrations"),e.jsx(w,{className:"ml-1 rev-icn"})]})]}),e.jsx(k,{step:i,saveConfig:()=>v({flow:h,setFlow:f,allIntegURL:g,navigate:x,conf:t,setIsLoading:n,setSnackbar:s}),isLoading:l,dataConf:t,setDataConf:o,formFields:d})]})}export{O as default};
