var I=Object.defineProperty;var v=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var j=(a,s,t)=>s in a?I(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t,k=(a,s)=>{for(var t in s||(s={}))_.call(s,t)&&j(a,t,s[t]);if(v)for(var t of v(s))q.call(s,t)&&j(a,t,s[t]);return a};import{u as w,r,j as i}from"./main-333.js";import{d as T,_ as E,I as L,F as z,c as u}from"./bi.636.93.js";import{S as A}from"./bi.563.969.js";import B from"./bi.577.297.js";import{h as C,c as P}from"./bi.980.855.js";import{M as D}from"./bi.53.856.js";import"./bi.318.783.js";import"./bi.535.730.js";import"./bi.286.731.js";function Y({formFields:a,setFlow:s,flow:t,allIntegURL:m}){const p=w(),[y,b]=r.useState(!1),[f,g]=r.useState({auth:!1,customFields:!1}),[o,h]=r.useState(1),[S,d]=r.useState({show:!1}),N=[{key:"email",label:"Email",required:!0},{key:"firstName",label:"First Name",required:!1},{key:"lastName",label:"Last Name",required:!1},{key:"timezone",label:"Timezone",required:!1},{key:"ipAddress",label:"Ip Address",required:!1}],[e,n]=r.useState({name:"MailBluster",type:"MailBluster",auth_token:"",field_map:[{formField:"",mailBlusterFormField:""}],staticFields:N,subscribed:"",customFields:[],selectedTags:[],actions:{}}),M=()=>{b(!0),z(t,s,m,e,p,"","",b).then(c=>{var x;c.success?(u.success((x=c.data)==null?void 0:x.msg),p(m)):u.error(c.data||c)})},F=l=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!P(e)){u.error("Please map mandatory fields");return}e.field_map.length>0&&h(l)};return i.jsxs("div",{children:[i.jsx(T,{snack:S,setSnackbar:d}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(A,{step:3,active:o})}),i.jsx(B,{mailBlusterConf:e,setMailBlusterConf:n,step:o,setStep:h,loading:f,setLoading:g,setSnackbar:d}),i.jsxs("div",{className:"btcd-stp-page",style:k({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(D,{formFields:a,handleInput:l=>C(l,e,n),mailBlusterConf:e,setMailBlusterConf:n,loading:f,setLoading:g,setSnackbar:d}),(e==null?void 0:e.subscribed)&&i.jsxs("button",{onClick:()=>F(3),disabled:!(e!=null&&e.subscribed),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"})]})]}),(e==null?void 0:e.subscribed)&&i.jsx(L,{step:o,saveConfig:()=>M(),isLoading:y,dataConf:e,setDataConf:n,formFields:a})]})}export{Y as default};
