var w=Object.defineProperty;var h=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var v=(i,e,s)=>e in i?w(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s,j=(i,e)=>{for(var s in e||(e={}))F.call(e,s)&&v(i,s,e[s]);if(h)for(var s of h(e))z.call(e,s)&&v(i,s,e[s]);return i};import{j as a,_ as o,z as r}from"./main.2.9.0.js";import{u as E,b as n}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as L}from"./SnackMsg.DYSD96P4.js";import{S as T}from"./Steps.BYe8zHkm.js";import{I as G,g as M}from"./Integrations.DL8wqGct.js";import B from"./SenderAuthorization.BMdKSMfe.js";import{a as I,c as k}from"./SenderCommonFunc.DTpdnXOK.js";import{S as D}from"./SenderIntegLayout.DuOrfddn.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./ProUtilHelpers.CHf_DzPf.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./GlobalIntegrationHelper.B6YI8w_n.js";function at({formFields:i,setFlow:e,flow:s,allIntegURL:u}){const g=E(),[f,m]=n.useState(!1),[y,A]=n.useState({field:!1,auth:!1,group:!1}),[c,b]=n.useState(1),[N,l]=n.useState({show:!1}),[t,d]=n.useState({name:"Sender",type:"Sender",api_token:"",field_map:[{formField:"",senderField:""}],mainAction:"",senderFields:[],allGroups:[],allFields:[],groups:[],groupId:"",actions:{}}),P=()=>{if(I.includes(t==null?void 0:t.mainAction)&&!(t!=null&&t.groupId)){r.error(o("Please select a group","bit-integrations"));return}if(!k(t)){r.error(o("Please map mandatory fields","bit-integrations"));return}m(!0),M(s,e,u,t,g,"","",m).then(p=>{var S;p.success?(r.success((S=p.data)==null?void 0:S.msg),g(u)):r.error(p.data||p)})},_=x=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!t.mainAction){r.error(o("Please select an action","bit-integrations"));return}if(I.includes(t==null?void 0:t.mainAction)&&!(t!=null&&t.groupId)){r.error(o("Please select a group","bit-integrations"));return}if(!k(t)){r.error(o("Please map mandatory fields","bit-integrations"));return}b(x)};return a.jsxs("div",{children:[a.jsx(L,{snack:N,setSnackbar:l}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(T,{step:3,active:c})}),a.jsx(B,{senderConf:t,setSenderConf:d,step:c,setstep:b,loading:y,setLoading:A,setSnackbar:l}),a.jsxs("div",{className:"btcd-stp-page",style:j({},c===2&&{width:900,minHeight:"500px",overflow:"visible"}),children:[a.jsx(D,{formFields:i,senderConf:t,setSenderConf:d,isLoading:f,setIsLoading:m,setSnackbar:l}),(t==null?void 0:t.mainAction)&&a.jsxs("button",{onClick:()=>_(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[o("Next","bit-integrations"),"  ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(G,{step:c,saveConfig:()=>P(),isLoading:f,dataConf:t,setDataConf:d,formFields:i})]})}export{at as default};
