import{u as I,k as v,r as n,j as t}from"./main-406.js";import{d as B,_ as l,I as k,G as y}from"./bi.394.85.js";import{B as C}from"./bi.46.744.js";import{S as _}from"./bi.68.941.js";import N from"./bi.677.245.js";import{c as w}from"./bi.782.738.js";import{S as E}from"./bi.923.739.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function A({formFields:m,setFlow:u,flow:f,allIntegURL:g}){const x=I(),{formID:d}=v(),[i,r]=n.useState(!1),[s,c]=n.useState(1),[S,a]=n.useState({show:!1}),[b,p]=n.useState({templateId:"",RedirectionUrl:""}),[e,o]=n.useState({name:"Brevo(Sendinblue)",type:"Brevo(Sendinblue)",lists:[],api_key:"",field_map:[{formField:"",sendinBlueField:""}],actions:{}}),h=j=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),j===3){if(e.templateId===""||e.redirectionUrl===""){p({templateId:e.templateId?"":l("Template name cann't be empty","bit-integrations"),redirectionUrl:e.redirectionUrl?"":l("Redirection url name cann't be empty","bit-integrations")});return}if(!w(e)){a({show:!0,msg:"Please map all required fields to continue."});return}e.name!==""&&e.field_map.length>0&&c(3)}};return t.jsxs("div",{children:[t.jsx(B,{snack:S,setSnackbar:a}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(_,{step:3,active:s})}),t.jsx(N,{formID:d,sendinBlueConf:e,setSendinBlueConf:o,step:s,setstep:c,isLoading:i,setIsLoading:r,setSnackbar:a}),t.jsxs("div",{className:"btcd-stp-page",style:{width:s===2&&900,height:s===2&&"auto"},children:[t.jsx(E,{formID:d,formFields:m,sendinBlueConf:e,setSendinBlueConf:o,isLoading:i,setIsLoading:r,setSnackbar:a,error:b,setError:p}),t.jsxs("button",{onClick:()=>h(3),disabled:e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[l("Next","bit-integrations"),t.jsx(C,{className:"ml-1 rev-icn"})]})]}),t.jsx(k,{step:s,saveConfig:()=>y(f,u,g,e,x,"","",r),isLoading:i,dataConf:e,setDataConf:o,formFields:m})]})}export{A as default};
