(()=>{"use strict";var t={};// The module cache
var e={};// The require function
function n(r){// Check if module is in cache
var i=e[r];if(i!==undefined){return i.exports}// Create a new module (and put it into the cache)
var o=e[r]={exports:{}};// Execute the module function
t[r](o,o.exports,n);// Return the exports of the module
return o.exports}// webpack/runtime/rspack_version
(()=>{n.rv=()=>"1.6.5"})();// webpack/runtime/rspack_unique_id
(()=>{n.ruid="bundler=rspack@1.6.5"})();// CONCATENATED MODULE: ./node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_async_to_generator.js
function r(t,e,n,r,i,o,a){try{var s=t[o](a);var u=s.value}catch(t){n(t);return}if(s.done)e(u);else Promise.resolve(u).then(r,i)}function i(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var a=t.apply(e,n);function s(t){r(a,i,o,s,u,"next",t)}function u(t){r(a,i,o,s,u,"throw",t)}s(undefined)})}};// CONCATENATED MODULE: external "wp.i18n"
const o=wp.i18n;// CONCATENATED MODULE: ./assets/src/js/device-management.ts
var a=".tutor-devices-card";var s="data-id";var u="data-current";var l=t=>{var{query:e,toast:n,modal:r,endpoints:l}=window.TutorCore;var{wpPost:c}=window.TutorCore.api;var{convertToErrorMessage:d}=window.TutorCore.error;return{query:e,toast:n,$el:null,deviceCount:t,signOutMutation:null,clearAllSessionsMutation:null,init(){if(!this.$el){return}this.signOutMutation=e.useMutation(this.signOut,{onSuccess:(t,e)=>{var n;this.toast.success(t.data.msg);var i=(n=this.$el)===null||n===void 0?void 0:n.querySelector("[".concat(s,'="').concat(e.umetaId,'"]'));if(i){i.remove();this.deviceCount--}r.closeModal();if(t.data.redirect_to){window.location.href=t.data.redirect_to}},onError:t=>{this.toast.error(d(t))}});this.clearAllSessionsMutation=e.useMutation(this.clearAll,{onSuccess:t=>{var e;this.toast.success(t.message);var n;var i=(n=(e=this.$el)===null||e===void 0?void 0:e.querySelectorAll(a))!==null&&n!==void 0?n:[];i.forEach(t=>{if(!t.hasAttribute(u)){t.remove()}});this.deviceCount=1;r.closeModal()},onError:t=>{this.toast.error(d(t))}})},get formattedCountLabel(){return(0,o.sprintf)((0,o._n)("%s Signed-in Device","%s Signed-in Devices",this.deviceCount,"tutor-pro"),'<span class="tutor-font-semibold" x-text="deviceCount"></span>')},signOut(t){return i(function*(){return c(l.REMOVE_DEVICE_MANUALLY,{umeta_id:t.umetaId})})()},clearAll(){return i(function*(){return c(l.REMOVE_ALL_ACTIVE_LOGINS)})()},handleSignOut(t){return i(function*(){var e;var n={umetaId:t};yield(e=this.signOutMutation)===null||e===void 0?void 0:e.mutateAsync(n)}).call(this)},handleClearAllSessions(){return i(function*(){var t;yield(t=this.clearAllSessionsMutation)===null||t===void 0?void 0:t.mutateAsync({})}).call(this)}}};var c={name:"deviceManagement",component:l};document.addEventListener("alpine:init",()=>{window.TutorComponentRegistry.register({type:"component",meta:c});window.TutorComponentRegistry.initWithAlpine(window.Alpine)})})();