import{j as e,_ as i}from"./main.2.8.1.js";import{u as _,h as j,d as r}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as I}from"./BackIcn._kGL_vVw.js";import{S}from"./SnackMsg.S8DrwLlT.js";import{S as v}from"./Steps.1hz7v9Vj.js";import{I as w,g as k}from"./Integrations.D2bgBas2.js";import N from"./ConvertKitAuthorization.QW5h0kEL.js";import{c as p}from"./ConvertKitCommonFunc.CHf5MZxu.js";import{C as P}from"./ConvertKitIntegLayout.BKoqLsqg.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function O({formFields:l,setFlow:c,flow:g,allIntegURL:f}){const b=_(),{formID:u}=j(),[o,m]=r.useState(!1),[a,d]=r.useState(1),[h,s]=r.useState({show:!1}),[t,n]=r.useState({name:"Kit(ConvertKit)",type:"Kit(ConvertKit)",api_secret:"",field_map:[{formField:"",convertKitField:""}],actions:{},module:""}),x=y=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300);{if(!p(t)){s({show:!0,msg:i("Please map all required fields to continue.","bit-integrations")});return}if(!(t!=null&&t.module)){s({show:!0,msg:i("Please select module to continue.","bit-integrations")});return}if((t==null?void 0:t.module)==="add_subscriber_to_a_form"&&!(t!=null&&t.formId)){s({show:!0,msg:i("Please select form to continue.","bit-integrations")});return}if(((t==null?void 0:t.module)==="add_tags_to_a_subscriber"||(t==null?void 0:t.module)==="remove_tags_to_a_subscriber")&&!(t!=null&&t.tagIds)){s({show:!0,msg:i("Please select tag continue.","bit-integrations")});return}t.name!==""&&t.field_map.length>0&&d(3)}};return e.jsxs("div",{children:[e.jsx(S,{snack:h,setSnackbar:s}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(v,{step:3,active:a})}),e.jsx(N,{formID:u,convertKitConf:t,setConvertKitConf:n,step:a,setstep:d,isLoading:o,setIsLoading:m,setSnackbar:s}),e.jsxs("div",{className:"btcd-stp-page",style:{width:a===2&&900,height:a===2&&"auto"},children:[e.jsx(P,{formID:u,formFields:l,convertKitConf:t,setConvertKitConf:n,isLoading:o,setIsLoading:m,setSnackbar:s}),e.jsxs("button",{onClick:()=>x(),disabled:!p(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations"),"  ",e.jsx(I,{className:"ml-1 rev-icn"})]})]}),e.jsx(w,{step:a,saveConfig:()=>k(g,c,f,t,b,"","",m),isLoading:o,dataConf:t,setDataConf:n,formFields:l})]})}export{O as default};
