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.1.js";import{u as C,d as r}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as z}from"./SnackMsg.S8DrwLlT.js";import{S as F}from"./Steps.1hz7v9Vj.js";import{I as T,g as M}from"./Integrations.D2bgBas2.js";import A from"./LivestormAuthorization.BF24epnE.js";import{c as k}from"./LivestormCommonFunc.vzw31SuH.js";import{L as B}from"./LivestormIntegLayout.CjbFqE19.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function U({formFields:a,setFlow:e,flow:s,allIntegURL:g}){const f=C(),[u,p]=r.useState(!1),[v,x]=r.useState({}),[n,b]=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&&b(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:b,loading:v,setLoading:x,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:x,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};
