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