var G=Object.defineProperty;var S=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(s,t,i)=>t in s?G(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i,_=(s,t)=>{for(var i in t||(t={}))L.call(t,i)&&x(s,i,t[i]);if(S)for(var i of S(t))w.call(t,i)&&x(s,i,t[i]);return s};import{_ as e,j as a,z as m}from"./main.2.8.1.js";import{u as E,d as n}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as I}from"./SnackMsg.S8DrwLlT.js";import{S as P}from"./Steps.1hz7v9Vj.js";import{I as A,g as z}from"./Integrations.D2bgBas2.js";import T from"./SendGridAuthorization.9Rddyij0.js";import{c as q}from"./SendGridCommonFunc.C-4o5Kgg.js";import{S as M}from"./SendGridIntegLayout.D63eydpL.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 ie({formFields:s,setFlow:t,flow:i,allIntegURL:u}){const b=E(),[v,p]=n.useState(!1),[f,g]=n.useState({auth:!1,customFields:!1,lists:!1}),[o,y]=n.useState(1),[j,d]=n.useState({show:!1}),C=[{key:"email",label:e("Email","bit-integrations"),required:!0},{key:"first_name",label:e("First Name","bit-integrations"),required:!1},{key:"last_name",label:e("Last Name","bit-integrations"),required:!1},{key:"alternate_emails",label:e("Alternate Emails","bit-integrations"),required:!1},{key:"address_line_1",label:e("Address Line 1","bit-integrations"),required:!1},{key:"address_line_2",label:e("Address Line 2","bit-integrations"),required:!1},{key:"city",label:e("City","bit-integrations"),required:!1},{key:"state_province_region",label:e("State Province Region","bit-integrations"),required:!1},{key:"postal_code",label:e("Postal Code","bit-integrations"),required:!1},{key:"country",label:e("Country","bit-integrations"),required:!1},{key:"phone_number",label:e("Phone Number","bit-integrations"),required:!1},{key:"whatsapp",label:e("Whatsapp","bit-integrations"),required:!1},{key:"line",label:e("Line","bit-integrations"),required:!1},{key:"facebook",label:e("Facebook","bit-integrations"),required:!1},{key:"unique_name",label:e("Unique Name","bit-integrations"),required:!1}],[r,c]=n.useState({name:"SendGrid",type:"SendGrid",apiKey:"",field_map:[{formField:"",sendGridFormField:""}],staticFields:C,lists:[],customFields:[],selectedLists:"",groups:[],actions:{}}),N=()=>{p(!0),z(i,t,u,r,b,"","",p).then(l=>{var h;l.success?(m.success((h=l.data)==null?void 0:h.msg),b(u)):m.error(l.data||l)})},F=k=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!q(r)){m.error(e("Please map mandatory fields","bit-integrations"));return}r.field_map.length>0&&y(k)};return a.jsxs("div",{children:[a.jsx(I,{snack:j,setSnackbar:d}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(P,{step:3,active:o})}),a.jsx(T,{sendGridConf:r,setSendGridConf:c,step:o,setStep:y,loading:f,setLoading:g,setSnackbar:d}),a.jsxs("div",{className:"btcd-stp-page",style:_({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(M,{formFields:s,sendGridConf:r,setSendGridConf:c,loading:f,setLoading:g,setSnackbar:d}),a.jsxs("button",{onClick:()=>F(3),disabled:!q(r),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[e("Next","bit-integrations"),"  ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(A,{step:o,saveConfig:()=>N(),isLoading:v,dataConf:r,setDataConf:c,formFields:s})]})}export{ie as default};
