var I=Object.defineProperty;var v=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var w=(s,t,e)=>t in s?I(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,N=(s,t)=>{for(var e in t||(t={}))F.call(t,e)&&w(s,e,t[e]);if(v)for(var e of v(t))L.call(t,e)&&w(s,e,t[e]);return s};import{j as a,_ as j,z as m}from"./main.2.9.0.js";import{u as z,b as i}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as E}from"./SnackMsg.DYSD96P4.js";import{S as T}from"./Steps.BYe8zHkm.js";import{I as M,g as P}from"./Integrations.DL8wqGct.js";import{s as A,c as S}from"./NewsletterCommonFunc.BmwQNvkW.js";import{N as B}from"./NewsletterIntegLayout.DhWAW-Gr.js";import D from"./NewsletterAuthorization.CVqpadm0.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./TutorialLink.CFG7bS5c.js";function st({formFields:s,setFlow:t,flow:e,allIntegURL:p}){const d=z(),[C,f]=i.useState(!1),[g,u]=i.useState({auth:!1}),[r,x]=i.useState(1),[k,c]=i.useState({show:!1}),[o,l]=i.useState({name:"Newsletter",type:"Newsletter",field_map:[{formField:"",newsletterFormField:""}],staticFields:A,lists:[],selectedLists:"",groups:[],actions:{}}),y=()=>{f(!0),P(e,t,p,o,d,"","",f).then(n=>{var h;n.success?(m.success((h=n.data)==null?void 0:h.msg),d(p)):m.error(n.data||n)})},_=b=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!S(o)){m.error(j("Please map mandatory fields","bit-integrations"));return}o.field_map.length>0&&x(b)};return a.jsxs("div",{children:[a.jsx(E,{snack:k,setSnackbar:c}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(T,{step:3,active:r})}),a.jsx(D,{newsletterConf:o,setNewsletterConf:l,step:r,setStep:x,loading:g,setLoading:u,setSnackbar:c}),a.jsxs("div",{className:"btcd-stp-page",style:N({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(B,{formFields:s,newsletterConf:o,setNewsletterConf:l,loading:g,setLoading:u,setSnackbar:c}),a.jsxs("button",{onClick:()=>_(3),disabled:!S(o),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[j("Next","bit-integrations"),"  ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(M,{step:r,saveConfig:()=>y(),isLoading:C,dataConf:o,setDataConf:l,formFields:s})]})}export{st as default};
