var S=Object.defineProperty;var y=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var g=(t,e,a)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,h=(t,e)=>{for(var a in e||(e={}))_.call(e,a)&&g(t,a,e[a]);if(y)for(var a of y(e))I.call(e,a)&&g(t,a,e[a]);return t};import{u as R,r as f,j as r}from"./main-406.js";import{d as w,_ as C,I as N,G as F,c as p}from"./bi.394.85.js";import{S as T}from"./bi.68.941.js";import L from"./bi.304.237.js";import{h as z,c as B}from"./bi.570.721.js";import{R as G}from"./bi.410.722.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function V({formFields:t,setFlow:e,flow:a,allIntegURL:u}){const x=R(),[c,i]=f.useState(!1),[l,b]=f.useState(1),[q,m]=f.useState({show:!1}),v=[{key:"email",label:"Email",required:!0},{key:"firstname",label:"First name",required:!1},{key:"lastname",label:"Last name",required:!1},{key:"gender",label:"Gender",required:!1},{key:"title",label:"Title",required:!1},{key:"zip",label:"Zip",required:!1},{key:"birthdate",label:"Birthdate",required:!1},{key:"extra1",label:"Extra field 1",required:!1},{key:"extra2",label:"Extra field 2",required:!1},{key:"extra3",label:"Extra field 3",required:!1},{key:"extra4",label:"Extra field 4",required:!1},{key:"extra5",label:"Extra field 5",required:!1},{key:"extra6",label:"Extra field 6",required:!1},{key:"extra7",label:"Extra field 7",required:!1},{key:"extra8",label:"Extra field 8",required:!1},{key:"extra9",label:"Extra field 9",required:!1},{key:"extra10",label:"Extra field 10",required:!1}],[s,d]=f.useState({name:"Rapidmail",type:"Rapidmail",username:"",password:"",field_map:[{formField:"",rapidmailFormField:""}],recipientsFields:v,actions:{send_activationmail:!1}}),E=()=>{i(!0),F(a,e,u,s,x,"","",i).then(o=>{var k;o.success?(p.success((k=o.data)==null?void 0:k.msg),x(u)):p.error(o.data||o)})},j=n=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!B(s)){p.error("Please map mandatory fields");return}s.field_map.length>0&&b(n)};return r.jsxs("div",{children:[r.jsx(w,{snack:q,setSnackbar:m}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(T,{step:3,active:l})}),r.jsx(L,{rapidmailConf:s,setRapidmailConf:d,step:l,setstep:b,isLoading:c,setIsLoading:i,setSnackbar:m}),r.jsxs("div",{className:"btcd-stp-page",style:h({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(G,{formFields:t,handleInput:n=>z(n,s,d),rapidmailConf:s,setRapidmailConf:d,isLoading:c,setIsLoading:i,setSnackbar:m}),r.jsxs("button",{onClick:()=>j(3),disabled:!(s!=null&&s.recipient_id),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[C("Next","bit-integrations")," "," ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),r.jsx(N,{step:l,saveConfig:()=>E(),isLoading:c,dataConf:s,setDataConf:d,formFields:t})]})}export{V as default};
