var T=Object.defineProperty;var j=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var L=(a,n,s)=>n in a?T(a,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[n]=s,S=(a,n)=>{for(var s in n||(n={}))N.call(n,s)&&L(a,s,n[s]);if(j)for(var s of j(n))k.call(n,s)&&L(a,s,n[s]);return a};import{r as u,j as t,u as y}from"./main-333.js";import{_ as h,L as C,b as w,z as I,d as M,I as z,s as A}from"./bi.636.93.js";import{S as _}from"./bi.563.969.js";import{B}from"./bi.429.767.js";import{T as v,t as E}from"./bi.318.783.js";import{T as D,h as F}from"./bi.166.772.js";function H({tutorlmsConf:a,setTutorlmsConf:n,step:s,setStep:g,setSnackbar:b}){const[i,r]=u.useState(!1),[o,p]=u.useState(!1),[x,l]=u.useState(!1),{tutorlms:e}=E,d=()=>{p("auth"),w({},"tutor_authorize").then(c=>{c!=null&&c.success&&(r(!0),b({show:!0,msg:h("Connected with Tutor LMS Successfully","bit-integrations")})),p(!1),l(!0)})},f=c=>{const m=I(a);m[c.target.name]=c.target.value,n(m)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"auto"},children:[(e==null?void 0:e.youTubeLink)&&t.jsx(v,{title:"Tutor LMS",youTubeLink:e==null?void 0:e.youTubeLink}),(e==null?void 0:e.docLink)&&t.jsx(v,{title:"Tutor LMS",docLink:e==null?void 0:e.docLink}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:h("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:f,name:"name",value:a.name,type:"text",placeholder:h("Integration Name...","bit-integrations")}),o==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(C,{size:25,clr:"#022217",className:"mr-2"}),"Checking if Tutor LMS is active!!!"]}),x&&!i&&!o&&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:"×"}),"Tutor LMS plugin must be activated to integrate with Bit Integrations."]}),!i&&t.jsx("button",{onClick:d,className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:h("Connect","bit-integrations")}),i&&t.jsxs("button",{onClick:()=>g(2),className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",disabled:!i,children:[h("Next","bit-integrations"),t.jsx(B,{className:"ml-1 rev-icn"})]})]})}function O({formFields:a,setFlow:n,flow:s,allIntegURL:g}){const b=y(),[i,r]=u.useState(!1),[o,p]=u.useState(1),[x,l]=u.useState({show:!1}),[e,d]=u.useState({name:"Tutor LMS",type:"Tutor Lms",field_map:[{formField:"",tutorField:""}],actions:{},actionData:{}}),f=()=>{r(!0),A({flow:s,setFlow:n,allIntegURL:g,conf:e,navigate:b,setIsLoading:r,setSnackbar:l})},c=m=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),p(m)};return t.jsxs("div",{children:[t.jsx(M,{snack:x,setSnackbar:l}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(_,{step:3,active:o})}),t.jsx(H,{tutorlmsConf:e,setTutorlmsConf:d,step:o,setStep:p,isLoading:i,setIsLoading:r,setSnackbar:l}),t.jsxs("div",{className:"btcd-stp-page",style:S({},o===2&&{width:900,height:"auto",minHeight:o===2&&"260px",overflow:"visible"}),children:[t.jsx(D,{formFields:a,handleInput:m=>F(m,e,d,r,l),tutorlmsConf:e,setTutorlmsConf:d,isLoading:i,setIsLoading:r,setSnackbar:l}),t.jsxs("button",{onClick:()=>c(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[h("Next","bit-integrations")," "," ",t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsx(z,{step:o,saveConfig:()=>f(),isLoading:i,dataConf:e,setDataConf:d,formFields:a})]})}export{O as default};
