var N=Object.defineProperty;var g=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var m=(t,s,e)=>s in t?N(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e,o=(t,s)=>{for(var e in s||(s={}))P.call(s,e)&&m(t,e,s[e]);if(g)for(var e of g(s))_.call(s,e)&&m(t,e,s[e]);return t};import{b as v,z as p,_ as n,j as i}from"./main.2.9.0.js";import{u as y}from"./CopyIcn.CEA_lFLo.js";import{u as x,a9 as A}from"./Note.NSUdvR3c.js";const h=(t,s)=>{const e=v({},"wpCourseware_courses").then(c=>{o({},t),s(u=>x(u,d=>{c.data.WPCWCourses&&(d.default.WPCWCourses=c.data.WPCWCourses)}))});p.promise(e,{success:n("Course Refreshed","bit-integrations"),error:n("Failed, Try Again","bit-integrations"),loading:n("Fetching...")})},S=(t,s,e)=>{const c=o({},s);c.name=t.target.value,e(o({},c))};function z({wpCoursewareConf:t,setWPCoursewareConf:s,isLoading:e,setIsLoading:c,setSnackbar:u}){var b;const d=({target:{name:l,value:a}})=>{s(r=>x(r,W=>{W[l]=a})),h(t,s)},j=l=>{const a=o({},t);l.includes("select_all_course")?a.selectedAllCourse=t.default.WPCWCourses.filter(r=>r.id!=="select_all_course").map(r=>r.id):delete a.selectedAllCourse,a.course=l?l.split(","):[],s(o({},a))};return i.jsxs(i.Fragment,{children:[i.jsx("br",{}),i.jsxs("div",{className:"flx",children:[i.jsx("b",{className:"wdt-200 d-in-b",children:n("WP Courseware Actions:","bit-integrations")}),i.jsxs("select",{onChange:l=>d(l),name:"action",value:t.action,className:"btcd-paper-inp w-5",children:[i.jsx("option",{value:"",children:n("Select Action","bit-integrations")}),i.jsx("option",{value:"enroll",children:n("Enroll user in a Course","bit-integrations")}),i.jsx("option",{value:"unroll",children:n("Unroll user in a Course","bit-integrations")})]})]}),(t==null?void 0:t.action)&&i.jsxs("div",{className:"flx mt-4",children:[i.jsx("b",{className:"wdt-200 d-in-b",children:n("WP Courseware Courses:","bit-integrations")}),i.jsx(y,{defaultValue:t==null?void 0:t.course,className:"btcd-paper-drpdwn w-5",options:((b=t==null?void 0:t.default)==null?void 0:b.WPCWCourses)&&Object.values(t.default.WPCWCourses).map(({id:l,title:a})=>({label:a,value:l.toString()})),onChange:l=>j(l)}),i.jsx("button",{onClick:()=>h(t,s),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${n("Refresh WP Courseware Courses","bit-integrations")}'`},type:"button",disabled:e,children:"↻"})]}),i.jsx("br",{}),i.jsx("br",{}),i.jsx(A,{note:n("This integration will only work for logged-in users.","bit-integrations")})]})}export{z as W,S as h};
