var y=Object.defineProperty;var v=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var j=(a,s,e)=>s in a?y(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e,S=(a,s)=>{for(var e in s||(s={}))L.call(s,e)&&j(a,e,s[e]);if(v)for(var e of v(s))N.call(s,e)&&j(a,e,s[e]);return a};import{j as i,_ as E,z as p}from"./main.2.8.10.js";import{u as w,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as C}from"./SnackMsg.7BjcJK1j.js";import{S as T}from"./Steps.B84Ui3GU.js";import{I as z,g as M}from"./Integrations.BFhED4ck.js";import P from"./EmailOctopusAuthorization.BBuQWsyv.js";import{h as A,c as k}from"./EmailOctopusCommonFunc.Hi4e18bk.js";import{E as B}from"./EmailOctopusIntegLayout.BVXLzG56.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 et({formFields:a,setFlow:s,flow:e,allIntegURL:d}){const u=w(),[F,f]=o.useState(!1),[g,h]=o.useState({auth:!1,tags:!1,customFields:!1,lists:!1,emailOctopusFields:!1}),[n,x]=o.useState(1),[I,m]=o.useState({show:!1}),[t,r]=o.useState({name:"EmailOctopus",type:"EmailOctopus",auth_token:"",field_map:[{formField:"",emailOctopusFormField:""}],emailOctopusFields:[],lists:[],selectedList:"",status:"",tags:[],selectedTags:[],actions:{}}),O=()=>{f(!0),M(e,s,d,t,u,"","",f).then(l=>{var b;l.success?(p.success((b=l.data)==null?void 0:b.msg),u(d)):p.error(l.data||l)})},_=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!k(t)){p.error(E("Please map mandatory emailOctopusFields","bit-integrations"));return}t.field_map.length>0&&x(c)};return i.jsxs("div",{children:[i.jsx(C,{snack:I,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(T,{step:3,active:n})}),i.jsx(P,{emailOctopusConf:t,setEmailOctopusConf:r,step:n,setStep:x,loading:g,setLoading:h,setSnackbar:m}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,handleInput:c=>A(c,t,r),emailOctopusConf:t,setEmailOctopusConf:r,loading:g,setLoading:h,setSnackbar:m}),(t==null?void 0:t.selectedList)&&i.jsxs("button",{onClick:()=>_(3),disabled:!k(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[E("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.selectedList)&&i.jsx(z,{step:n,saveConfig:()=>O(),isLoading:F,dataConf:t,setDataConf:r,formFields:a})]})}export{et as default};
