var C=Object.defineProperty;var L=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var j=(a,s,n)=>s in a?C(a,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[s]=n,y=(a,s)=>{for(var n in s||(s={}))I.call(s,n)&&j(a,n,s[n]);if(L)for(var n of L(s))w.call(s,n)&&j(a,n,s[n]);return a};import{j as t,_ as i,s as A,b as z}from"./main.2.8.10.js";import{b as m,u as T,e as _}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as E}from"./SnackMsg.7BjcJK1j.js";import{S as B}from"./Steps.B84Ui3GU.js";import{I as D,s as F}from"./Integrations.BFhED4ck.js";import{L as M,h as P,c as H}from"./LifterLmsIntegLayout.CzCZxo5t.js";import{B as K}from"./BackIcn.BFDZx8No.js";import{y as U,x as q}from"./Note.DalStCGz.js";import{T as G}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";function J({formID:a,lifterLmsConf:s,setLifterLmsConf:n,step:u,setStep:g,isLoading:f,setIsLoading:p,setSnackbar:x}){const[o,d]=m.useState(!1),[l,b]=m.useState(!1),v=()=>{p("auth"),z({},"lifterLms_authorize").then(r=>{r!=null&&r.success&&(d(!0),x({show:!0,msg:i("Connected with LifterLms Successfully","bit-integrations")})),p(!1),b(!0)})},c=r=>{const e=q(s);e[r.target.name]=r.target.value,n(e)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:u===1&&900,height:u===1&&"auto"},children:[t.jsx(G,{linkKey:"lifterLms"}),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:c,name:"name",value:s.name,type:"text",placeholder:i("Integration Name...","bit-integrations")}),f==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(U,{size:25,clr:"#022217",className:"mr-2"}),"Checking if LifterLms is active!!!"]}),l&&!o&&!f&&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:"×"}),A(i("%s plugin must be activated to integrate with Bit Integrations","bit-integrations"),"LifterLms")]}),!o&&t.jsx("button",{onClick:v,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(K,{className:"ml-1 rev-icn"})]})]})}function at({formFields:a,setFlow:s,flow:n,allIntegURL:u,isInfo:g,edit:f}){const p=T(),{formID:x}=_(),[o,d]=m.useState(!1),[l,b]=m.useState(1),[v,c]=m.useState({show:!1}),r=[{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,h]=m.useState({name:"LifterLms",type:"LifterLms",mainAction:"",field_map:[{formField:"",lifterLmsFormField:""}],allActions:r,actions:{}}),k=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),e.mainAction==="11"&&!H(e)){c({show:!0,msg:i("Please map fields to continue.","bit-integrations")});return}e.mainAction!==""&&b(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(E,{snack:v,setSnackbar:c}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(B,{step:3,active:l})}),t.jsx(J,{formID:x,lifterLmsConf:e,setLifterLmsConf:h,step:l,setStep:b,isLoading:o,setIsLoading:d,setSnackbar:c}),t.jsxs("div",{className:"btcd-stp-page",style:y({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[t.jsx(M,{formFields:a,handleInput:S=>P(S,e,h),lifterLmsConf:e,setLifterLmsConf:h,isLoading:o,setIsLoading:d,setSnackbar:c,allIntegURL:u,isInfo:g,edit:f}),t.jsxs("button",{onClick:()=>k(),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(D,{step:l,saveConfig:()=>F({flow:n,setFlow:s,allIntegURL:u,navigate:p,conf:e,setIsLoading:d,setSnackbar:c}),isLoading:o,dataConf:e,setDataConf:h,formFields:a})]})}export{at as default};
