var C=Object.defineProperty;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var b=(s,e,t)=>e in s?C(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,S=(s,e)=>{for(var t in e||(e={}))I.call(e,t)&&b(s,t,e[t]);if(y)for(var t of y(e))N.call(e,t)&&b(s,t,e[t]);return s};import{u as w,r as l,j as a}from"./main-406.js";import{d as E,_ as F,I as T,G as q,c as u}from"./bi.394.85.js";import{S as L}from"./bi.68.941.js";import M from"./bi.429.261.js";import{S as P,h as z,c as A}from"./bi.464.777.js";import"./bi.46.744.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function W({formFields:s,setFlow:e,flow:t,allIntegURL:f}){const g=w(),[p,i]=l.useState(!1),[o,h]=l.useState(1),[v,m]=l.useState({show:!1}),j=[{key:"email",label:"Email",required:!0},{key:"name",label:"Name",required:!1}],[n,r]=l.useState({name:"Sendy",type:"Sendy",api_key:"",sendy_url:"",field_map:[{formField:"",sendyField:""}],subscriberFields:j,actions:{}}),k=()=>{i(!0),q(t,e,f,n,g,"","",i).then(d=>{var x;d.success?(u.success((x=d.data)==null?void 0:x.msg),g(f)):u.error(d.data||d)})},_=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!A(n)){u.error("Please map mandatory fields");return}n.field_map.length>0&&h(c)};return a.jsxs("div",{children:[a.jsx(E,{snack:v,setSnackbar:m}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(L,{step:3,active:o})}),a.jsx(M,{sendyConf:n,setSendyConf:r,step:o,setstep:h,isLoading:p,setIsLoading:i,setSnackbar:m}),a.jsxs("div",{className:"btcd-stp-page",style:S({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(P,{formFields:s,handleInput:c=>z(c,n,r),sendyConf:n,setSendyConf:r,isLoading:p,setIsLoading:i,setSnackbar:m}),a.jsxs("button",{onClick:()=>_(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[F("Next","bit-integrations")," "," ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(T,{step:o,saveConfig:()=>k(),isLoading:p,dataConf:n,setDataConf:r,formFields:s})]})}export{W as default};
