var w=Object.defineProperty;var k=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var j=(i,s,n)=>s in i?w(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,v=(i,s)=>{for(var n in s||(s={}))C.call(s,n)&&j(i,n,s[n]);if(k)for(var n of k(s))A.call(s,n)&&j(i,n,s[n]);return i};import{r as u,j as e,u as T,k as z}from"./main-333.js";import{_ as l,L as M,b as _,z as E,d as B,I as D,s as F}from"./bi.636.93.js";import{S as P}from"./bi.563.969.js";import{L as H,h as U,c as q}from"./bi.952.891.js";import{B as G}from"./bi.429.767.js";import{T as y,t as J}from"./bi.318.783.js";function K({formID:i,lifterLmsConf:s,setLifterLmsConf:n,step:d,setStep:g,isLoading:p,setIsLoading:b,setSnackbar:x}){const[o,h]=u.useState(!1),[m,f]=u.useState(!1),{lifterLms:a}=J,r=()=>{b("auth"),_({},"lifterLms_authorize").then(t=>{t!=null&&t.success&&(h(!0),x({show:!0,msg:l("Connected with LifterLms Successfully","bit-integrations")})),b(!1),f(!0)})},L=t=>{const c=E(s);c[t.target.name]=t.target.value,n(c)};return e.jsxs("div",{className:"btcd-stp-page",style:{width:d===1&&900,height:d===1&&"auto"},children:[(a==null?void 0:a.youTubeLink)&&e.jsx(y,{title:"LifterLMS",youTubeLink:a==null?void 0:a.youTubeLink}),(a==null?void 0:a.docLink)&&e.jsx(y,{title:"LifterLMS",docLink:a==null?void 0:a.docLink}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:l("Integration Name:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:L,name:"name",value:s.name,type:"text",placeholder:l("Integration Name...","bit-integrations")}),p==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(M,{size:25,clr:"#022217",className:"mr-2"}),"Checking if LifterLms is active!!!"]}),m&&!o&&!p&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),"LifterLms plugin must be activated to integrate with Bit Integrations."]}),!o&&e.jsx("button",{onClick:r,className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:l("Connect","bit-integrations")}),o&&e.jsxs("button",{onClick:()=>g(2),className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",disabled:!o,children:[l("Next","bit-integrations"),e.jsx(G,{className:"ml-1 rev-icn"})]})]})}function Z({formFields:i,setFlow:s,flow:n,allIntegURL:d,isInfo:g,edit:p}){const b=T(),{formID:x}=z(),[o,h]=u.useState(!1),[m,f]=u.useState(1),[a,r]=u.useState({show:!1}),L=[{key:"1",label:"Lesson complete for the user"},{key:"2",label:"Section complete for the user"},{key:"3",label:"Enroll user in a course"},{key:"4",label:"Enroll user in a membership"},{key:"5",label:"Course complete for the user"},{key:"6",label:"Unenroll user from a course"},{key:"7",label:"Unenroll user from a membership"}],[t,c]=u.useState({name:"LifterLms",type:"LifterLms",mainAction:"",field_map:[{formField:"",lifterLmsFormField:""}],allActions:L,actions:{}}),N=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),t.mainAction==="11"&&!q(t)){r({show:!0,msg:l("Please map fields to continue.","bit-integrations")});return}t.mainAction!==""&&f(3)};function S(){switch(t.mainAction){case"1":return t.lessonId===void 0;case"2":return t.sectionId===void 0;case"3":case"5":case"6":return t.courseId===void 0;case"4":case"7":return t.membershipId===void 0;default:return!1}}return e.jsxs("div",{children:[e.jsx(B,{snack:a,setSnackbar:r}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(P,{step:3,active:m})}),e.jsx(K,{formID:x,lifterLmsConf:t,setLifterLmsConf:c,step:m,setStep:f,isLoading:o,setIsLoading:h,setSnackbar:r}),e.jsxs("div",{className:"btcd-stp-page",style:v({},m===2&&{width:900,height:"auto",overflow:"visible"}),children:[e.jsx(H,{formFields:i,handleInput:I=>U(I,t,c),lifterLmsConf:t,setLifterLmsConf:c,isLoading:o,setIsLoading:h,setSnackbar:r,allIntegURL:d,isInfo:g,edit:p}),e.jsxs("button",{onClick:()=>N(),disabled:!t.mainAction||o||S(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[l("Next","bit-integrations")," ",e.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),e.jsx(D,{step:m,saveConfig:()=>F({flow:n,setFlow:s,allIntegURL:d,navigate:b,conf:t,setIsLoading:h,setSnackbar:r}),isLoading:o,dataConf:t,setDataConf:c,formFields:i})]})}export{Z as default};
