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