var w=Object.defineProperty;var j=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var L=(a,e,s)=>e in a?w(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,N=(a,e)=>{for(var s in e||(e={}))I.call(e,s)&&L(a,s,e[s]);if(j)for(var s of j(e))P.call(e,s)&&L(a,s,e[s]);return a};import{j as i,_ as m,z as o}from"./main.2.8.10.js";import{u as C,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as z}from"./SnackMsg.7BjcJK1j.js";import{S as F}from"./Steps.B84Ui3GU.js";import{I as T,g as M}from"./Integrations.BFhED4ck.js";import A from"./LivestormAuthorization.CLWHYuER.js";import{c as k}from"./LivestormCommonFunc.BGKM5-TZ.js";import{L as B}from"./LivestormIntegLayout.DiCqVipg.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";function U({formFields:a,setFlow:e,flow:s,allIntegURL:g}){const f=C(),[u,p]=r.useState(!1),[v,b]=r.useState({}),[n,x]=r.useState(1),[y,d]=r.useState({show:!1}),[t,l]=r.useState({name:"Livestorm",type:"Livestorm",api_key:"",field_map:[{formField:"",livestormFormField:""}],actionName:"addPeopletoEventSession",actions:{}}),_=()=>{p(!0),M(s,e,g,t,f,"","",p).then(c=>{var S;c.success?(o.success((S=c.data)==null?void 0:S.msg),f(g)):o.error(c.data||c)})},E=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!k(t)){o.error(m("Please map mandatory fields","bit-integrations"));return}if(!t.selectedEvent){o.error(m("Please select an Event","bit-integrations"));return}if(!t.selectedSession){o.error(m("Please select a Session","bit-integrations"));return}t.field_map.length>0&&x(h)};return i.jsxs("div",{children:[i.jsx(z,{snack:y,setSnackbar:d}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(F,{step:3,active:n})}),i.jsx(A,{livestormConf:t,setLivestormConf:l,step:n,setStep:x,loading:v,setLoading:b,setSnackbar:d}),i.jsxs("div",{className:"btcd-stp-page",style:N({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,livestormConf:t,setLivestormConf:l,loading:v,setLoading:b,isLoading:u,setIsLoading:p,setSnackbar:d}),(t==null?void 0:t.actionName)&&i.jsxs("button",{onClick:()=>E(3),disabled:!k(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[m("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.actionName)&&i.jsx(T,{step:n,saveConfig:()=>_(),isLoading:u,dataConf:t,setDataConf:l,formFields:a})]})}export{U as default};
