var N=Object.defineProperty;var x=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(i,s,a)=>s in i?N(i,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[s]=a,v=(i,s)=>{for(var a in s||(s={}))w.call(s,a)&&S(i,a,s[a]);if(x)for(var a of x(s))F.call(s,a)&&S(i,a,s[a]);return i};import{_ as t,j as r,z as m}from"./main.2.8.1.js";import{u as z,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as C}from"./SnackMsg.S8DrwLlT.js";import{S as E}from"./Steps.1hz7v9Vj.js";import{I as L,g as T}from"./Integrations.D2bgBas2.js";import P from"./MailRelayAuthorization.DuqFWJ53.js";import{h as A,c as B}from"./MailRelayCommonFunc.aFET2gXM.js";import{M as R}from"./MailRelayIntegLayout.B1CpFASu.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function ae({formFields:i,setFlow:s,flow:a,allIntegURL:p}){const b=z(),[j,g]=o.useState(!1),[f,y]=o.useState({auth:!1,groups:!1,customFields:!1}),[n,h]=o.useState(1),[q,u]=o.useState({show:!1}),M=[{key:"email",label:t("Email","bit-integrations"),required:!0},{key:"name",label:t("Name","bit-integrations"),required:!1},{key:"sms_phone",label:t("SMS Phone","bit-integrations"),required:!1},{key:"address",label:t("Address","bit-integrations"),required:!1},{key:"city",label:t("City","bit-integrations"),required:!1},{key:"state",label:t("State","bit-integrations"),required:!1},{key:"country",label:t("Country","bit-integrations"),required:!1},{key:"birthday",label:t("Birthday","bit-integrations"),required:!1},{key:"website",label:t("Website","bit-integrations"),required:!1},{key:"locale",label:t("Locale","bit-integrations"),required:!1},{key:"time_zone",label:t("Time Zone","bit-integrations"),required:!1}],[e,l]=o.useState({name:"MailRelay",type:"MailRelay",auth_token:"",domain:"",field_map:[{formField:"",mailRelayFormField:""}],staticFields:M,status:"",customFields:[],groups:[],selectedGroups:[],actions:{}}),_=()=>{g(!0),T(a,s,p,e,b,"","",g).then(c=>{var k;c.success?(m.success((k=c.data)==null?void 0:k.msg),b(p)):m.error(c.data||c)})},I=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!B(e)){m.error(t("Please map mandatory fields","bit-integrations"));return}e.field_map.length>0&&h(d)};return r.jsxs("div",{children:[r.jsx(C,{snack:q,setSnackbar:u}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(E,{step:3,active:n})}),r.jsx(P,{mailRelayConf:e,setMailRelayConf:l,step:n,setStep:h,loading:f,setLoading:y,setSnackbar:u}),r.jsxs("div",{className:"btcd-stp-page",style:v({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(R,{formFields:i,handleInput:d=>A(d,e,l),mailRelayConf:e,setMailRelayConf:l,loading:f,setLoading:y,setSnackbar:u}),(e==null?void 0:e.status)&&r.jsxs("button",{onClick:()=>I(3),disabled:!(e!=null&&e.status),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[t("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.status)&&r.jsx(L,{step:n,saveConfig:()=>_(),isLoading:j,dataConf:e,setDataConf:l,formFields:i})]})}export{ae as default};
