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