(()=>{"use strict";var e={};// The module cache
var t={};// The require function
function r(i){// Check if module is in cache
var n=t[i];if(n!==undefined){return n.exports}// Create a new module (and put it into the cache)
var o=t[i]={exports:{}};// Execute the module function
e[i](o,o.exports,r);// Return the exports of the module
return o.exports}// expose the modules object (__webpack_modules__)
r.m=e;// webpack/runtime/define_property_getters
(()=>{r.d=(e,t)=>{for(var i in t){if(r.o(t,i)&&!r.o(e,i)){Object.defineProperty(e,i,{enumerable:true,get:t[i]})}}}})();// webpack/runtime/ensure_chunk
(()=>{r.f={};// This file contains only the entry chunk.
// The chunk loading function for additional chunks
r.e=e=>{return Promise.all(Object.keys(r.f).reduce((t,i)=>{r.f[i](e,t);return t},[]))}})();// webpack/runtime/get javascript chunk filename
(()=>{// This function allow to reference chunks
r.u=e=>{// return url for filenames not based on template
if(e==="4")return"js/lazy-chunks/tutor-dnd-kit.js?ver=4.0.0";// return url for filenames based on template
return""+e+".javascript"}})();// webpack/runtime/get mini-css chunk filename
(()=>{// This function allow to reference chunks
r.miniCssF=e=>{// return url for filenames not based on template
// return url for filenames based on template
return""+e+".css"}})();// webpack/runtime/get_full_hash
(()=>{r.h=()=>"4627d878f4dec41b"})();// webpack/runtime/global
(()=>{r.g=(()=>{if(typeof globalThis==="object")return globalThis;try{return this||new Function("return this")()}catch(e){if(typeof window==="object")return window}})()})();// webpack/runtime/has_own_property
(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();// webpack/runtime/load_script
(()=>{var e={};var t="tutor:";// loadScript function to load a script via script tag
r.l=function(i,n,o,a){if(e[i]){e[i].push(n);return}var s,l;if(o!==undefined){var u=document.getElementsByTagName("script");for(var d=0;d<u.length;d++){var c=u[d];if(c.getAttribute("src")==i||c.getAttribute("data-webpack")==t+o){s=c;break}}}if(!s){l=true;s=document.createElement("script");s.timeout=120;if(r.nc){s.setAttribute("nonce",r.nc)}s.setAttribute("data-webpack",t+o);s.src=i}e[i]=[n];var v=function(t,r){s.onerror=s.onload=null;clearTimeout(h);var n=e[i];delete e[i];s.parentNode&&s.parentNode.removeChild(s);n&&n.forEach(function(e){return e(r)});if(t)return t(r)};var h=setTimeout(v.bind(null,undefined,{type:"timeout",target:s}),12e4);s.onerror=v.bind(null,s.onerror);s.onload=v.bind(null,s.onload);l&&document.head.appendChild(s)}})();// webpack/runtime/make_namespace_object
(()=>{// define __esModule on exports
r.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();// webpack/runtime/rspack_version
(()=>{r.rv=()=>"1.6.5"})();// webpack/runtime/auto_public_path
(()=>{var e;if(r.g.importScripts)e=r.g.location+"";var t=r.g.document;if(!e&&t){// Technically we could use `document.currentScript instanceof window.HTMLScriptElement`,
// but an attacker could try to inject `<script>HTMLScriptElement = HTMLImageElement</script>`
// and use `<img name="currentScript" src="https://attacker.controlled.server/"></img>`
if(t.currentScript&&t.currentScript.tagName.toUpperCase()==="SCRIPT")e=t.currentScript.src;if(!e){var i=t.getElementsByTagName("script");if(i.length){var n=i.length-1;while(n>-1&&(!e||!/^http(s?):/.test(e)))e=i[n--].src}}}// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration",
// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.',
if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");r.p=e+"../"})();// webpack/runtime/jsonp_chunk_loading
(()=>{// object to store loaded and loading chunks
// undefined = chunk not loaded, null = chunk preloaded/prefetched
// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
var e={"675":0};r.f.j=function(t,i){// JSONP chunk loading for javascript
var n=r.o(e,t)?e[t]:undefined;if(n!==0){// 0 means "already installed".
// a Promise means "currently loading".
if(n){i.push(n[2])}else{if(true){// setup Promise in chunk cache
var o=new Promise((r,i)=>n=e[t]=[r,i]);i.push(n[2]=o);// start chunk loading
var a=r.p+r.u(t);// create error before stack unwound to get useful stacktrace later
var s=new Error;var l=function(i){if(r.o(e,t)){n=e[t];if(n!==0)e[t]=undefined;if(n){var o=i&&(i.type==="load"?"missing":i.type);var a=i&&i.target&&i.target.src;s.message="Loading chunk "+t+" failed.\n("+o+": "+a+")";s.name="ChunkLoadError";s.type=o;s.request=a;n[1](s)}}};r.l(a,l,"chunk-"+t,t)}}}};// install a JSONP callback for chunk loading
var t=(t,i)=>{var[n,o,a]=i;// add "moreModules" to the modules object,
// then flag all "chunkIds" as loaded and fire callback
var s,l,u=0;if(n.some(t=>e[t]!==0)){for(s in o){if(r.o(o,s)){r.m[s]=o[s]}}if(a)var d=a(r)}if(t)t(i);for(;u<n.length;u++){l=n[u];if(r.o(e,l)&&e[l]){e[l][0]()}e[l]=0}};var i=self["webpackChunktutor"]=self["webpackChunktutor"]||[];i.forEach(t.bind(null,0));i.push=t.bind(null,i.push.bind(i))})();// webpack/runtime/rspack_unique_id
(()=>{r.ruid="bundler=rspack@1.6.5"})();var i={};// UNUSED EXPORTS: initializeLearningArea
;// CONCATENATED MODULE: ./node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_async_to_generator.js
function n(e,t,r,i,n,o,a){try{var s=e[o](a);var l=s.value}catch(e){r(e);return}if(s.done)t(l);else Promise.resolve(l).then(i,n)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(i,o){var a=e.apply(t,r);function s(e){n(a,i,o,s,l,"next",e)}function l(e){n(a,i,o,s,l,"throw",e)}s(undefined)})}};// CONCATENATED MODULE: ./node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_define_property.js
function a(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else e[t]=r;return e};// CONCATENATED MODULE: ./node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_object_spread.js
function s(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}i.forEach(function(t){a(e,t,r[t])})}return e};// CONCATENATED MODULE: ./node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_object_spread_props.js
function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);if(t){i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,i)}return r}function u(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors)Object.defineProperties(e,Object.getOwnPropertyDescriptors(t));else{l(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e};// CONCATENATED MODULE: external "wp.i18n"
const d=wp.i18n;// CONCATENATED MODULE: ./assets/src/js/frontend/components/reviews.ts
var c=()=>{var{query:e,endpoints:t,toast:r}=window.TutorCore;var{wpPost:i}=window.TutorCore.api;return{query:e,$el:null,deleteReviewMutation:null,init(){if(!this.$el){return}this.deleteReviewMutation=this.query.useMutation(this.deleteReview,{onSuccess:e=>{window.location.reload();var t;r.success((t=e===null||e===void 0?void 0:e.message)!==null&&t!==void 0?t:(0,d.__)("Review deleted successfully","tutor"))},onError:e=>{r.error(e.message||(0,d.__)("Failed to delete review","tutor"))}})},handleDeleteReview(e){return o(function*(){var t;yield(t=this.deleteReviewMutation)===null||t===void 0?void 0:t.mutate(e)}).call(this)},deleteReview(e){return o(function*(){return i(t.DELETE_REVIEW,{review_id:e})})()}}};var v=()=>{var{query:e,modal:t,toast:r,endpoints:i}=window.TutorCore;var{wpPost:n}=window.TutorCore.api;var{convertToErrorMessage:a}=window.TutorCore.error;return{query:e,saveRatingMutation:null,clear_review_popup_data:false,init(){this.saveRatingMutation=this.query.useMutation(this.saveRating,{onSuccess:(e,i)=>o(function*(){if(this.clear_review_popup_data){yield this.clearReviewPopupData(i.course_id)}t.closeModal("create-review-modal");r.success(e.message);window.location.reload()}).call(this),onError:e=>{r.error(a(e))}})},handleReviewSubmit(e){return o(function*(){var t;this.clear_review_popup_data=!!e.clear_review_popup_data;var r=this.convertFormDataToPayload(e);yield(t=this.saveRatingMutation)===null||t===void 0?void 0:t.mutate(r)}).call(this)},saveRating(e){return o(function*(){return n(i.PLACE_RATING,e)})()},clearReviewPopupData(e){return o(function*(){return n(i.CLEAR_REVIEW_POPUP_DATA,{course_id:e})})()},convertFormDataToPayload(e){return u(s({},e.comment_ID&&{comment_id:e.comment_ID}),{course_id:e.comment_post_ID,tutor_rating_gen_input:e.rating,review:e.comment_content})}}};var h=e=>{var{query:t,endpoints:r,toast:i}=window.TutorCore;var{wpPost:n}=window.TutorCore.api;var{convertToErrorMessage:a}=window.TutorCore.error;return{query:t,id:e,isEditMode:false,$el:null,$refs:{},saveRatingMutation:null,handlers:{},init(){var e,t,r;if(!this.$el){return}// Bind handlers once to maintain stable references for cleanup
this.handlers.toggleEditMode=()=>this.toggleEditMode();(e=this.$refs.edit)===null||e===void 0?void 0:e.addEventListener("click",this.handlers.toggleEditMode);(t=this.$refs.cancel)===null||t===void 0?void 0:t.addEventListener("click",this.handlers.toggleEditMode);(r=this.$refs.delete)===null||r===void 0?void 0:r.addEventListener("click",this.handlers.onDeleteButtonClick);this.saveRatingMutation=this.query.useMutation(this.saveRating,{onSuccess:e=>{this.isEditMode=false;i.success(e.message);window.location.reload()},onError:e=>{i.error(a(e))}})},destroy(){var e,t,r;(e=this.$refs.edit)===null||e===void 0?void 0:e.removeEventListener("click",this.handlers.toggleEditMode);(t=this.$refs.cancel)===null||t===void 0?void 0:t.removeEventListener("click",this.handlers.toggleEditMode);(r=this.$refs.delete)===null||r===void 0?void 0:r.removeEventListener("click",this.handlers.onDeleteButtonClick)},handleReviewSubmit(e){return o(function*(){var t;var r=this.convertFormDataToPayload(e);yield(t=this.saveRatingMutation)===null||t===void 0?void 0:t.mutate(r)}).call(this)},saveRating(e){return o(function*(){return n(r.PLACE_RATING,e)})()},convertFormDataToPayload(e){return u(s({},e.comment_ID&&{comment_id:e.comment_ID}),{course_id:e.comment_post_ID,tutor_rating_gen_input:e.rating,review:e.comment_content})},toggleEditMode(){this.isEditMode=!this.isEditMode}}};var m={name:"reviewDeleteModal",component:c};var f={name:"reviewModal",component:v};var p={name:"reviewCard",component:h};var _=()=>{window.TutorComponentRegistry.registerAll({components:[p,m,f]});window.TutorComponentRegistry.initWithAlpine(window.Alpine)};// CONCATENATED MODULE: ./assets/core/ts/config/config.ts
/* eslint-disable @typescript-eslint/no-explicit-any */var T,E;var g={ID:0,ajaxurl:"",site_url:"",home_url:"",site_title:"",base_path:"",tutor_url:"",tutor_pro_url:"",dashboard_url:"",nonce_key:"",_tutor_nonce:"",loading_icon_url:"",placeholder_img_src:"",enable_lesson_classic_editor:"",tutor_frontend_dashboard_url:"",backend_course_list_url:"",backend_bundle_list_url:"",frontend_course_list_url:"",frontend_bundle_list_url:"",wp_date_format:"",wp_rest_nonce:"",is_admin:"",is_admin_bar_showing:"",is_tour_completed:"",max_upload_size:"",content_change_event:"",is_tutor_course_edit:"",assignment_max_file_allowed:"",current_page:"",quiz_answer_display_time:"",is_ssl:"",course_list_page_url:"",course_post_type:"",local:"",tutor_pn_vapid_key:"",tutor_pn_client_id:"",tutor_pn_subscription_saved:"",difficulty_levels:[],supported_video_sources:[],edd_products:[],bp_groups:[],timezones:{},addons_data:[],kids_icons_registry:[],is_kids_mode:false,user_preferences:{auto_play_next:false,contrast:"",font_scale:1,learning_mood:"modern",motion_effects:"auto",theme:"light",vision:"normal"},is_legacy_learning_mode:false,current_user:{data:{id:"",user_login:"",user_pass:"",user_nicename:"",user_email:"",user_url:"",user_registered:"",user_activation_key:"",user_status:"",display_name:""},caps:{},cap_key:"",roles:[],allcaps:{},filter:null},settings:{learning_mode:"",monetize_by:"tutor",enable_course_marketplace:"off",course_permalink_base:"",supported_video_sources:"",enrollment_expiry_enabled:"off",enable_q_and_a_on_course:"off",instructor_can_delete_course:"off",instructor_can_change_course_author:"off",instructor_can_manage_co_instructors:"off",chatgpt_enable:"off",course_builder_logo_url:"",chatgpt_key_exist:false,hide_admin_bar_for_users:"off",enable_redirect_on_course_publish_from_frontend:"off",instructor_can_publish_course:"off",youtube_api_key_exist:false,membership_only_mode:false,enable_tax:false,enable_individual_tax_control:false,is_tax_included_in_price:false},tutor_currency:{symbol:"",currency:"",position:"",thousand_separator:"",decimal_separator:"",no_of_decimal:""},visibility_control:{course_builder:{}}};var A=window._tutorobject||g;window.ajaxurl=A.ajaxurl;var w={TUTOR_SITE_URL:A.site_url,WP_AJAX_BASE_URL:A.ajaxurl,WP_API_BASE_URL:"".concat(((T=window.wpApiSettings)===null||T===void 0?void 0:T.root)||"").concat(((E=window.wpApiSettings)===null||E===void 0?void 0:E.versionString)||""),VIDEO_SOURCES_SETTINGS_URL:"".concat(A.site_url,"/wp-admin/admin.php?page=tutor_settings&tab_page=course#field_supported_video_sources"),MONETIZATION_SETTINGS_URL:"".concat(A.site_url,"/wp-admin/admin.php?page=tutor_settings&tab_page=monetization"),TUTOR_PRICING_PAGE:"https://tutorlms.com/pricing/",TUTOR_ADDONS_PAGE:"".concat(A.site_url,"/wp-admin/admin.php?page=tutor-addons"),CHATGPT_PLATFORM_URL:"https://platform.openai.com/account/api-keys",TUTOR_MY_COURSES_PAGE_URL:"".concat(A.tutor_frontend_dashboard_url,"/my-courses"),TUTOR_SUPPORT_PAGE_URL:"https://tutorlms.com/support",TUTOR_SUBSCRIPTIONS_PAGE:"".concat(A.site_url,"/wp-admin/admin.php?page=tutor-subscriptions"),TUTOR_ENROLLMENTS_PAGE:"".concat(A.site_url,"/wp-admin/admin.php?page=enrollments"),TUTOR_COUPONS_PAGE:"".concat(A.site_url,"/wp-admin/admin.php?page=tutor_coupons"),TUTOR_IMPORT_EXPORT_PAGE:"".concat(A.site_url,"/wp-admin/admin.php?page=tutor-tools&sub_page=import_export")};/* export default */const S=/* unused pure expression or super */null&&w;// CONCATENATED MODULE: ./assets/core/ts/constant.ts
var y={TAB_CHANGE:"tutor-tab-change",MODAL_OPEN:"tutor-modal-open",MODAL_UPDATE:"tutor-modal-update",MODAL_CLOSE:"tutor-modal-close",MODAL_CLOSED:"tutor-modal-closed",TOAST_SHOW:"tutor-toast-show",TOAST_CLEAR:"tutor-toast-clear",FORM_REGISTER:"tutor-form-register",FORM_UNREGISTER:"tutor-form-unregister",FORM_STATE_CHANGE:"tutor-form-state-change",FORM_RESET:"tutor-form-reset",WP_EDITOR_FOCUS:"wp-editor-focus",TUTOR_PLAYER_READY:"tutor-player-ready",COMMENT_REPLIED:"tutor:comment:replied",LESSON_PLAYER_READY:"tutorLessonPlayerReady",QUIZ_TIME_EXPIRED:"tutor-quiz-time-expired",QUIZ_ABANDON_REQUESTED:"tutor-quiz-abandon-requested",QUIZ_ATTEMPT_COMPLETED:"tutor-quiz-attempt-completed"};// CONCATENATED MODULE: ./assets/src/js/frontend/components/tour.ts
var I={NEXT:"next",BACK:"back"};var R=e=>{var{slidesData:t,modalId:r}=e;var{modal:i,api:n,endpoints:o}=window.TutorCore;var a=Number(A.is_tour_completed);return{currentSlide:0,slides:t||[],isOpen:false,slideDirection:I.NEXT,$nextTick:undefined,_onModalClose:undefined,init(){this._onModalClose=e=>{var t;if(((t=e.detail)===null||t===void 0?void 0:t.id)===r){this.isOpen=false}};document.addEventListener(y.MODAL_CLOSE,this._onModalClose);if(!a){var e,t;this.isOpen=true;(e=(t=this).$nextTick)===null||e===void 0?void 0:e.call(t,()=>{i.showModal(r)})}},destroy(){document.removeEventListener(y.MODAL_CLOSE,this._onModalClose)},next(){this.slideDirection=I.NEXT;if(this.currentSlide<this.slides.length-1){this.currentSlide++}else{this.skip()}},back(){this.slideDirection=I.BACK;if(this.currentSlide>0){this.currentSlide--}},skip(){// Fire-and-forget AJAX call to save user meta
n.wpPost(o.COMPLETE_TOUR);this.isOpen=false;i.closeModal(r)}}};var O=()=>{window.TutorComponentRegistry.register({type:"component",meta:{name:"tour",component:R}});window.TutorComponentRegistry.initWithAlpine(window.Alpine)};// CONCATENATED MODULE: ./assets/src/js/frontend/services/common.ts
var b=()=>{var{query:e,toast:t,endpoints:r}=window.TutorCore;var{wpPost:i}=window.TutorCore.api;var{convertToErrorMessage:n}=window.TutorCore.error;return{createCourseMutation:null,init(){if(this.createCourseMutation){return}this.createCourseMutation=e.useMutation(this.createCourseRequest,{onSuccess:e=>{var t;window.location.href=(t=e.data)!==null&&t!==void 0?t:""},onError:e=>{t.error(n(e))}})},createCourseRequest(){return o(function*(){return i(r.CREATE_DRAFT_COURSE,{from_dashboard:true})})()},handleCreateCourse(){return o(function*(){var e;yield(e=this.createCourseMutation)===null||e===void 0?void 0:e.mutate({})}).call(this)}}};var C=()=>{var e=b();e.init();var t=document.querySelectorAll(".tutor-create-new-course");t.forEach(t=>{t.addEventListener("click",r=>o(function*(){r.preventDefault();t.classList.add(...["tutor-loading","tutor-btn-loading"]);t.setAttribute("disabled","true");var i=r.target;i.innerHTML="Creating...";try{yield e.handleCreateCourse()}finally{t.classList.remove(...["tutor-loading","tutor-btn-loading"]);t.removeAttribute("disabled")}})())})};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/common.ts
/**
 * Common handlers for course completion and retake.
 * These are globally registered in the learning area.
 */var N=()=>{var{query:e,toast:t,modal:r,endpoints:i}=window.TutorCore;var{wpPost:n}=window.TutorCore.api;var{convertToErrorMessage:a}=window.TutorCore.error;return{courseCompleteMutation:null,courseRetakeMutation:null,init(){if(this.courseCompleteMutation){return}this.courseCompleteMutation=e.useMutation(this.completeCourseRequest,{onSuccess:()=>{r.closeModal("tutor-course-complete-modal");window.location.reload()},onError:e=>{var r;t.error(a(e));if((r=e.message)===null||r===void 0?void 0:r.includes("HTTP")){window.location.reload()}}});this.courseRetakeMutation=e.useMutation(this.retakeCourseRequest,{onSuccess:e=>{var r;if((r=e.data)===null||r===void 0?void 0:r.redirect_to){window.location.href=e.data.redirect_to}else{t.error((0,d.__)("Something went wrong","tutor"))}},onError:e=>{t.error(a(e))}})},// Complete
completeCourseRequest(e){return o(function*(){return n(i.TUTOR_COMPLETE_COURSE,e)})()},handleCourseComplete(e){return o(function*(){var t;yield(t=this.courseCompleteMutation)===null||t===void 0?void 0:t.mutate({course_id:e})}).call(this)},// Retake
retakeCourseRequest(e){return o(function*(){return n(i.RESET_COURSE_PROGRESS,e)})()},handleCourseRetake(e){return o(function*(){var t;yield(t=this.courseRetakeMutation)===null||t===void 0?void 0:t.mutate({course_id:e,context:"learning-area"})}).call(this)}}};var M=()=>{if(window.TutorComponentRegistry){window.TutorComponentRegistry.register({type:"component",meta:{name:"courseCompleteHandler",component:N}})}};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/lesson/comments.ts
var P="tutor-comment-";var L="tutor-comment-reply-";var D="tutor-comment-replies-";var Q="lesson-comment-reply-form-";var q="lesson-comment-form";var U={COMMENT_ITEM:"tutor-comment-item",REPLY_ITEM:"tutor-comment-reply-item",REPLIES_WRAPPER:"tutor-comment-replies",COMMENT_CONTENT:"tutor-comment-content"};var x="delete-comment-modal";/**
 * Get comment or reply DOM ID
 *
 * @param id Comment ID
 * @param isReply Whether it's a reply
 */var k=(e,t)=>{return t?"".concat(L).concat(e):"".concat(P).concat(e)};/**
 * Lesson Comments Component
 */var z=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;var{query:r,toast:i,form:n,modal:o,endpoints:a}=window.TutorCore;var{convertToErrorMessage:s}=window.TutorCore.error;var{wpPost:l}=window.TutorCore.api;var{TUTOR_CUSTOM_EVENTS:u}=window.TutorCore.constants;return{query:r,lessonId:e,totalComments:t,currentPage:1,loading:false,hasMore:true,currentOrder:"DESC",isReloading:false,isEmpty:false,$el:null,$refs:{},editingId:null,replyingId:null,createCommentMutation:null,editCommentMutation:null,deleteCommentMutation:null,replyCommentMutation:null,init(){// Initialize order from URL.
var e=new URL(window.location.href);var t=e.searchParams.get("order");this.currentOrder=t==="ASC"?"ASC":"DESC";var r=this.$refs.commentList.querySelectorAll(":scope > .".concat(U.COMMENT_ITEM)).length;this.hasMore=this.totalComments>r;this.isEmpty=r===0;this.initInfiniteScroll();// Lesson comment create mutation.
this.createCommentMutation=this.query.useMutation(this.createComment,{onSuccess:e=>{i.success((0,d.__)("Comment added successfully.","tutor"));var t=e.data;if(t.html){if(this.currentOrder==="DESC"){this.$refs.commentList.insertAdjacentHTML("afterbegin",t.html)}else if(!this.hasMore){this.$refs.commentList.insertAdjacentHTML("beforeend",t.html)}}if(t.count!==undefined){this.totalComments=t.count;this.isEmpty=false}if(n.hasForm(q)){n.reset(q)}},onError:e=>{i.error(s(e))}});// Lesson comment edit mutation.
this.editCommentMutation=this.query.useMutation(this.updateComment,{onSuccess:e=>{i.success((0,d.__)("Comment updated successfully.","tutor"));var t=e.data;var r=k(t.comment_id,t.is_reply);var n=document.getElementById(r);if(n&&t.html){n.outerHTML=t.html}else{this.reloadComments()}this.editingId=null},onError:e=>{i.error(s(e))}});// Lesson comment delete mutation.
this.deleteCommentMutation=this.query.useMutation(this.deleteComment,{onSuccess:e=>{i.success((0,d.__)("Comment deleted successfully.","tutor"));o.closeModal(x);var t=e.data;var r=k(t.comment_id,t.is_reply);var n=document.getElementById(r);if(n){n.remove()}if(t.is_reply){// Check if there are any replies left. If not, remove the replies container.
var a=document.getElementById("".concat(D).concat(t.parent_id));if(a&&a.querySelectorAll(".".concat(U.REPLY_ITEM)).length===0){a.remove()}}if(t.count!==undefined){this.totalComments=t.count;var s=this.$refs.commentList.querySelectorAll(":scope > .".concat(U.COMMENT_ITEM)).length;this.hasMore=this.totalComments>s;// If we deleted a main comment and there are more items on the server,
// trigger a load to fill the gap.
if(!t.is_reply&&this.hasMore){this.loadNextPage()}this.isEmpty=this.$refs.commentList.querySelectorAll(":scope > .".concat(U.COMMENT_ITEM)).length===0}},onError:e=>{i.error(s(e))}});// Lesson comment reply mutation
this.replyCommentMutation=this.query.useMutation(this.replyComment,{onSuccess:(e,t)=>{i.success((0,d.__)("Reply saved successfully","tutor"));var r=e.data;var o=t.comment_parent;var a=document.getElementById("".concat(D).concat(o));var s=a===null||a===void 0?void 0:a.querySelector(".".concat(U.REPLIES_WRAPPER));if(r.html){if(r.is_first_reply||!s){// Append to parent flex container if replies wrapper doesn't exist yet
var l=document.getElementById("".concat(P).concat(o));var c=l===null||l===void 0?void 0:l.querySelector(".".concat(U.COMMENT_CONTENT));c===null||c===void 0?void 0:c.insertAdjacentHTML("beforeend",r.html)}else{// Append item directly if wrapper exists
s.insertAdjacentHTML("beforeend",r.html)}// Notify Alpine to expand the replies and hide the form via custom event.
window.dispatchEvent(new CustomEvent(u.COMMENT_REPLIED,{detail:{parentId:o}}));// Reset the specific reply form.
var v="".concat(Q).concat(o);if(n.hasForm(v)){n.reset(v)}}else{// Fallback to reload if something went wrong
this.reloadComments()}if(r.count!==undefined){this.totalComments=r.count}this.replyingId=null},onError:e=>{i.error(s(e))}})},createComment(e){return l(a.CREATE_LESSON_COMMENT,e)},updateComment(e){return l(a.UPDATE_LESSON_COMMENT,e)},deleteComment(e){return l(a.DELETE_LESSON_COMMENT,e)},replyComment(e){return l(a.REPLY_LESSON_COMMENT,e)},handleReplyComment(e,t){var r;(r=this.replyCommentMutation)===null||r===void 0?void 0:r.mutate({comment_post_ID:this.lessonId,comment_parent:t,comment:e.comment,order:this.currentOrder})},handleEditComment(e,t){var r;(r=this.editCommentMutation)===null||r===void 0?void 0:r.mutate({comment_id:t,comment:e.comment})},handleChangeOrder(e){if(this.currentOrder===e)return;this.currentOrder=e;this.updateURL(e);this.reloadComments()},handleDeleteComment(e){o.showModal(x,{commentId:e.commentId})},updateURL(e){var t=new URL(window.location.href);t.searchParams.set("order",e);window.history.pushState({},"",t)},reloadComments(){this.isReloading=true;this.currentPage=1;this.hasMore=true;l(a.LOAD_LESSON_COMMENTS,{lesson_id:this.lessonId,current_page:1,order:this.currentOrder}).then(e=>{var t;// Replace entire comment list.
this.$refs.commentList.innerHTML=e.data.html;this.hasMore=e.data.has_more;if(e.data.count!==undefined){this.totalComments=e.data.count}this.isEmpty=!((t=e.data.html)===null||t===void 0?void 0:t.trim())}).catch(e=>{i.error(s(e))}).finally(()=>{this.isReloading=false})},loadNextPage(){if(!this.lessonId||this.loading||!this.hasMore){return}this.loading=true;// Calculate offset based on main comments in DOM.
var e=this.$refs.commentList.querySelectorAll(":scope > .".concat(U.COMMENT_ITEM)).length;l(a.LOAD_LESSON_COMMENTS,{lesson_id:this.lessonId,offset:e,order:this.currentOrder}).then(e=>{var t;if(e.data.has_more!==undefined){this.hasMore=e.data.has_more}if((t=e.data.html)===null||t===void 0?void 0:t.trim()){this.currentPage++;this.$refs.commentList.insertAdjacentHTML("beforeend",e.data.html)}this.isEmpty=this.$refs.commentList.querySelectorAll(":scope > .".concat(U.COMMENT_ITEM)).length===0}).catch(e=>{i.error(s(e))}).finally(()=>{this.loading=false})},handleKeydown(e){if((e.metaKey||e.ctrlKey)&&e.key==="Enter"){var t;(t=e.target.closest("form"))===null||t===void 0?void 0:t.requestSubmit()}},initInfiniteScroll(){var e=new IntersectionObserver(e=>{var[t]=e;if(t.isIntersecting&&this.hasMore&&!this.loading){this.loadNextPage()}},{rootMargin:"200px"});e.observe(this.$refs.loadMoreTrigger)}}};var F=()=>{window.TutorComponentRegistry.register({type:"component",meta:{name:"lessonComments",component:z}})};// CONCATENATED MODULE: ./assets/src/js/frontend/types/index.ts
function B(e){return e.provider==="youtube"}function H(e){return e.provider==="vimeo"};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/lesson/player.ts
class ${/**
   * Get player data from hidden input
   */getPlayerData(){var e=document.getElementById("tutor_video_tracking_information");if(!(e instanceof HTMLInputElement)||!e.value){return{}}try{return JSON.parse(e.value)}catch(e){return{}}}/**
   * Check if the current lesson requires a watch percentage
   */isRequiredPercentage(){var{strict_mode:e,control_video_lesson_completion:t,lesson_completed:r,is_enrolled:i}=this.playerData;var{tutorConfig:n}=window.TutorCore.config;return Boolean(n.tutor_pro_url&&i&&!r&&e&&t)}/**
   * Calculate percentage
   */getPercentage(e,t){if(e>0&&t>0){return Math.round(e/t*100)}return 0}/**
   * UI: Enable Complete Lesson Button
   */enableCompleteLessonBtn(){var e=document.querySelector('button[name="complete_lesson_btn"]');if(!e||!this.player)return;var t=this.getPercentage(Number(this.player.currentTime),Number(this.player.duration));var r=this.playerData.required_percentage||0;if(t>=r){var i,n;e.disabled=false;if((i=e.nextElementSibling)===null||i===void 0?void 0:i.classList.contains("tutor-tooltip")){e.nextElementSibling.remove()}if((n=e.parentElement)===null||n===void 0?void 0:n.classList.contains("tutor-tooltip-wrap")){e.parentElement.replaceWith(e)}}}/**
   * UI: Disable Complete Lesson Button
   */disableCompleteLessonBtn(){var{best_watch_time:e=0,video_duration:t=0,required_percentage:r=0}=this.playerData;var i=this.getPercentage(Number(e),Number(t));if(i<r){var n=document.querySelector('button[name="complete_lesson_btn"]');if(n&&!n.disabled){var o,a;n.disabled=true;if(!((o=n.parentElement)===null||o===void 0?void 0:o.classList.contains("tutor-tooltip-wrap"))){var s;var l=document.createElement("div");l.className="tutor-tooltip-wrap";l.setAttribute("x-data",'tutorTooltip({ placement: "top" })');(s=n.parentNode)===null||s===void 0?void 0:s.insertBefore(l,n);l.appendChild(n);n.setAttribute("x-ref","trigger")}if(!((a=n.nextElementSibling)===null||a===void 0?void 0:a.classList.contains("tutor-tooltip"))){n.insertAdjacentHTML("afterend",'<div x-ref="content" class="tutor-tooltip" x-show="open" x-cloak x-transition>'.concat((0,d.sprintf)(/* translators: %s is the required watch percentage (e.g., 80) */(0,d.__)("Watch at least %s%% to complete the lesson.","tutor"),r),"</div>"));if(window.Alpine){window.Alpine.initTree(n.parentElement)}}}}}/**
   * Sync time with server
   */syncTime(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.player||!this.playerData.post_id)return;if(this.isRequiredPercentage()){this.enableCompleteLessonBtn()}var t=s({currentTime:this.player.currentTime,duration:this.player.duration,post_id:this.playerData.post_id},e);var{wpPost:r}=window.TutorCore.api;r("sync_video_playback",t);var i=this.player.currentTime;var n=this.playerData.best_watch_time||0;var o=n>i?n:i;if(o>this.maxSeekTime){this.maxSeekTime=o}}/**
   * Autoload next course content
   */autoloadContent(){if(!this.playerData.post_id)return;var{wpPost:e}=window.TutorCore.api;e("autoload_next_course_content",{post_id:this.playerData.post_id}).then(e=>{var t;if(e.success&&((t=e.data)===null||t===void 0?void 0:t.next_url)){window.location.href=e.data.next_url}})}/**
   * Get target time from seek event input
   */getTargetTime(e,t){var r=t.target;if(r instanceof HTMLInputElement){var i=Number(r.value);var n=Number(r.max)||1;return i/n*e.duration}return Number(t)}/**
   * Initialize Plyr
   */initPlyr(){if(typeof window.Plyr==="undefined")return;var e=this.isRequiredPercentage();var t={keyboard:{focused:!e,global:false},listeners:s({},e&&{seek:e=>{if(!this.player)return true;var t=this.getTargetTime(this.player,e);var r=this.player.currentTime;var i=r>this.maxSeekTime?r:this.maxSeekTime;if(t>i){e.preventDefault();window.TutorCore.toast.warning((0,d.__)("Forward seeking is disabled","tutor"));return false}return true}})};this.player=new window.Plyr(this.element,t);this.setupEvents();if(e){this.disableCompleteLessonBtn()}}/**
   * Setup Plyr events
   */setupEvents(){if(!this.player)return;this.player.on("ready",e=>{var t;(t=document.querySelector(".tutor-video-player .loading-spinner"))===null||t===void 0?void 0:t.remove();this.syncTime();var r=e.detail.plyr;/**
       * Play from best watch time
       */var{best_watch_time:i=0}=this.playerData;var{tutorConfig:n}=window.TutorCore.config;if(n.tutor_pro_url&&i>0){var o=Math.floor(i);setTimeout(()=>{if(r.playing!==true&&r.currentTime!==o){if(B(r)){r.embed.seekTo(i)}else{r.currentTime=o}}},0)}/**
       * Fix: Mobile Vimeo autoplay sound issue
       * Always start muted on mobile to comply with autoplay policy.
       */var{isMobileDevice:a}=window.TutorCore.device;if(H(r)&&a()){try{r.muted=true;if(typeof r.mute==="function"){r.mute()}}catch(e){// eslint-disable-next-line no-console
console.warn("Vimeo mute init failed:",e)}}// Dispatch custom event and set player to window
var s=new CustomEvent("tutorLessonPlayerReady",{detail:{player:r}});window.dispatchEvent(s);window.TutorLessonPlayer=r});this.player.on("play",e=>{if(this.syncInterval)clearInterval(this.syncInterval);this.playedOnce=true;/**
       * Send to tutor backend about video playing time in this interval
       */var t=10;var{tutorConfig:r}=window.TutorCore.config;if(r.tutor_pro_url){this.syncInterval=setInterval(()=>{this.syncTime()},t*1e3)}/**
       * Unmute automatically after first user interaction
       * Mobile browsers allow audio only after gesture.
       */var i=e.detail.plyr;var{isMobileDevice:n}=window.TutorCore.device;if(H(i)&&n()){try{i.muted=false;if(typeof i.unmute==="function"){i.unmute()}}catch(e){// eslint-disable-next-line no-console
console.warn("Vimeo unmute on play failed:",e)}}/**
       * Fix: YouTube poster issue
       */if(r.tutor_pro_url&&i.provider==="youtube"){var o;var a=(o=i.elements.container)===null||o===void 0?void 0:o.querySelector(".plyr__poster");if(a){a.style.opacity="0"}}});this.player.on("pause",()=>{if(this.syncInterval)clearInterval(this.syncInterval);var{tutorConfig:e}=window.TutorCore.config;if(e.tutor_pro_url){this.syncTime()}});this.player.on("ended",e=>{if(this.syncInterval)clearInterval(this.syncInterval);var t=e.detail.plyr;this.syncTime({is_ended:true});var{tutorConfig:r}=window.TutorCore.config;if(r.user_preferences.auto_play_next&&this.playedOnce){this.autoloadContent()}/**
       * Fix: YouTube poster issue
       */if(r.tutor_pro_url&&t.provider==="youtube"){var i;var n=(i=t.elements.container)===null||i===void 0?void 0:i.querySelector(".plyr__poster");if(n){n.style.opacity="1"}}})}/**
   * Initialize Lesson Player
   */static init(){var e=document.querySelector(".tutor-lesson-video-wrapper .tutorPlayer");if(e){new $(e)}else{var t;(t=document.querySelector(".tutor-video-player .loading-spinner"))===null||t===void 0?void 0:t.remove()}}constructor(e){a(this,"element",void 0);a(this,"player",null);a(this,"playerData",void 0);a(this,"syncInterval",null);a(this,"maxSeekTime",0);a(this,"playedOnce",false);this.element=e;this.playerData=this.getPlayerData();this.maxSeekTime=this.playerData.best_watch_time||0;this.initPlyr()}}var W=()=>{$.init()};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/lesson/index.ts
/**
 * Initialize all lesson related logic
 */var G=()=>{W();F()};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/pages/course-info.ts
/**
 * Course Info Page logic
 *
 * @since 4.0.0
 *//**
 * Note: courseCompleteHandler has been moved to common.ts
 * to be available globally (header/footer) in the learning area.
 * Keeps course-info.ts for future page-specific logic.
 */var V=()=>{// Add course-info specific logic here
};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/pages/qna.ts
var j={QNA_FORM:"learning-area-qna-form",QNA_EDIT:"qna-edit-",QNA_REPLY:"qna-reply-form-"};var Z={QNA_TEXT_PREFIX:"tutor-qna-text-",REPLIES_LIST_CONTAINER:"tutor-discussion-replies-list"};var X={QNA_DELETE:"tutor-qna-delete-modal"};var Y={QUESTION_ID:"question_id",ORDER:"order"};/**
 * Q&A Page Component
 * Handles Q&A related action in learning area
 */var K=()=>{var{query:e,form:t,modal:r,toast:i,endpoints:n}=window.TutorCore;var{convertToErrorMessage:a}=window.TutorCore.error;var{wpPost:s}=window.TutorCore.api;return{query:e,createQnAMutation:null,updateQnAMutation:null,replyQnAMutation:null,deleteQnAMutation:null,editingId:null,editingFormId:null,replyingId:null,loadingReplies:false,repliesOrder:"DESC",$nextTick:undefined,init(){this.createQnAMutation=this.query.useMutation(this.createQnA,{onSuccess:()=>{i.success((0,d.__)("Question saved successfully","tutor"));var e=j.QNA_FORM;if(t.hasForm(e)){t.reset(e)}window.location.reload()},onError:e=>{i.error(a(e))}});this.updateQnAMutation=this.query.useMutation(this.updateQnA,{onSuccess:(e,t)=>{i.success((0,d.__)("Updated successfully","tutor"));// Update DOM directly for immediate feedback
var r=document.getElementById("".concat(Z.QNA_TEXT_PREFIX).concat(t.question_id));if(r){r.innerHTML=t.answer;// Re-trigger syntax highlighting if Prism is available.
var n=window.Prism;if(n===null||n===void 0?void 0:n.highlightAllUnder){n.highlightAllUnder(r)}}if(this.editingId===t.question_id){this.setEditing(null)}},onError:e=>{i.error(a(e))}});this.replyQnAMutation=this.query.useMutation(this.replyQnA,{onSuccess:(e,r)=>{i.success((0,d.__)("Reply saved successfully","tutor"));var n="".concat(j.QNA_REPLY).concat(r.question_id);if(t.hasForm(n)){t.reset(n)}if(r.reply_context==="single"){// this.reloadReplies();
window.location.reload()}else{this.setReplying(null);this.updateReplyCount(r.question_id);this.highlightCard(r.question_id)}},onError:e=>{i.error(a(e))}});this.deleteQnAMutation=this.query.useMutation(this.deleteQnA,{onSuccess:(e,t)=>{if(t.context==="reply"){i.success((0,d.__)("Reply deleted successfully","tutor"));r.closeModal(X.QNA_DELETE);// this.reloadReplies();
window.location.reload()}else{i.success((0,d.__)("Question deleted successfully","tutor"));r.closeModal(X.QNA_DELETE);// Reload the page.
var n=new URL(window.location.href);n.searchParams.delete(Y.QUESTION_ID);window.location.href=n.toString()}},onError:e=>{i.error(a(e))}})},createQnA(e){return s(n.CREATE_UPDATE_QNA,e)},updateQnA(e){return s(n.UPDATE_QNA,e)},replyQnA(e){return s(n.CREATE_UPDATE_QNA,e)},deleteQnA(e){return s(n.DELETE_DASHBOARD_QNA,e)},reloadReplies(e){return o(function*(){if(e){this.repliesOrder=e}var t=new URL(window.location.href);var r=parseInt(t.searchParams.get(Y.QUESTION_ID)||"0");if(!r)return;this.loadingReplies=true;try{var i;var o=yield s(n.LOAD_QNA_REPLIES,{comment_id:r,order:this.repliesOrder,context:"learning-area"});var a=document.getElementById(Z.REPLIES_LIST_CONTAINER);if(a&&typeof((i=o.data)===null||i===void 0?void 0:i.html)==="string"){a.innerHTML=o.data.html;// Re-trigger syntax highlighting if Prism is available.
var l=window.Prism;if(l===null||l===void 0?void 0:l.highlightAllUnder){l.highlightAllUnder(a)}// Update URL without reload
var u=new URL(window.location.href);u.searchParams.set(Y.ORDER,this.repliesOrder);window.history.pushState({},"",u.toString())}}catch(e){// eslint-disable-next-line no-console
console.error("Failed to reload replies:",e)}finally{this.loadingReplies=false}}).call(this)},setEditing(e){this.editingId=e;var r=e?"".concat(j.QNA_EDIT).concat(e):null;this.editingFormId=r;if(e&&r){var i,n;(i=(n=this).$nextTick)===null||i===void 0?void 0:i.call(n,()=>{if(t.hasForm(r)){t.setFocus(r,"answer")}})}},setReplying(e){this.replyingId=e;if(e){var r,i;var n="".concat(j.QNA_REPLY).concat(e);(r=(i=this).$nextTick)===null||r===void 0?void 0:r.call(i,()=>{if(t.hasForm(n)){t.setFocus(n,"answer")}})}},toggleReply(e){if(this.replyingId===e){this.setReplying(null)}else{this.setReplying(e)}},updateReplyCount(e){var t=document.querySelector('[data-question-id="'.concat(e,'"]'));if(t){var r=t.querySelector(".tutor-discussion-card-reply-count");if(r){var i=parseInt(r.textContent||"0",10);r.textContent=String(i+1)}}},highlightCard(e){var t=document.querySelector('[data-question-id="'.concat(e,'"]'));var r;var i=(r=t===null||t===void 0?void 0:t.closest(".tutor-discussion-card"))!==null&&r!==void 0?r:t;if(!i)return;if(window.innerWidth>576){i.style.boxShadow="0 0 0 2px var(--tutor-text-brand-secondary)";setTimeout(()=>{i.style.boxShadow=""},300)}},handleKeydown(e){if((e.metaKey||e.ctrlKey)&&e.key==="Enter"){var t;(t=e.target.closest("form"))===null||t===void 0?void 0:t.requestSubmit()}}}};var J=()=>{window.TutorComponentRegistry.register({type:"component",meta:{name:"QnA",component:K}})};// CONCATENATED MODULE: ./assets/src/js/frontend/components/quiz/retry-attempt.ts
var ee=()=>{var{query:e,toast:t,endpoints:r}=window.TutorCore;var{wpPostForm:i}=window.TutorCore.api;var{convertToErrorMessage:n}=window.TutorCore.error;return{retryMutation:null,init(){this.retryMutation=e.useMutation(this.retryAttempt,{onSuccess:(e,t)=>{window.location.href=t.redirectURL},onError:e=>{t.error(n(e))}})},retryAttempt(e){return i(e.redirectURL,{tutor_action:r.START_QUIZ,quiz_id:e.quizID})}}};var et={name:"quizRetryAttempt",component:ee};// CONCATENATED MODULE: ./assets/src/js/frontend/components/quiz/summary-sidebar.ts
var er="question-";var ei=".tutor-quiz-summary-header";var en='[data-question-id="%s"]';var eo='[data-question-id="'.concat(er,'%s"]');var ea='[data-question-id="%s"]';var es=new RegExp("^#".concat(er,"(\\d+)$"));var el=16;var eu=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var t;return{activeQuestionId:String((t=e.firstQuestionId)!==null&&t!==void 0?t:""),$el:null,init(){var e=this.getQuestionIdFromHash(window.location.hash);if(e&&this.hasQuestionItem(e)){this.activeQuestionId=e}},getQuestionIdFromHash(e){var t=e.match(es);return t?t[1]:null},hasQuestionItem(e){if(!e||!this.$el){return false}return!!this.$el.querySelector(ea.replace("%s",e))},setActiveQuestion(e){var t=String(e||"");if(!t){return}this.activeQuestionId=t;history.replaceState(null,"","#".concat(er).concat(t));this.scrollToQuestionAnswer(t)},scrollToQuestionAnswer(e){var t=String(e||"");if(!t){return}var r=document.getElementById("".concat(er).concat(t))||document.querySelector(eo.replace("%s",t))||document.querySelector(en.replace("%s",t));if(r instanceof HTMLElement){var i=document.querySelector(ei);var n=i instanceof HTMLElement?i.getBoundingClientRect().top+i.offsetHeight:0;var o=r.getBoundingClientRect().top+window.scrollY-n-el;window.scrollTo({top:Math.max(0,o),behavior:"smooth"})}}}};var ed={name:"quizSummarySidebar",component:eu};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/constants.ts
var ec={ANSWER_CONTEXT_ID:"tutor-quiz-context",DEFAULT_WAIT_MS:2e3,SUPPORTED_TYPES:["true_false","single_choice","multiple_choice"],OPTION_SELECTOR:".tutor-quiz-question-option",QUESTION_SELECTOR:".tutor-quiz-question",EXPLANATION_SELECTOR:"[data-quiz-explanation]",EXPLANATION_TRIGGER_SELECTOR:"[data-quiz-explanation-toggle]",EXPLANATION_BODY_SELECTOR:".tutor-quiz-explanation-body",EXPLANATION_CONTENT_DATASET:"quizExplanationContent",DATA_OPTION_ATTR:"data-option",DATA_REVEALED_ATTR:"data-revealed",DATA_RESULT_ATTR:"data-reveal-result",DATA_OPTION_CORRECT:"correct",DATA_OPTION_INCORRECT:"incorrect"};var ev={NAVIGATION_EVENT:"click",IGNORE_ANCHOR_PREFIXES:["#","javascript:"]};var eh={AUTO_ABANDON:"auto_abandon",AUTO_SUBMIT:"auto_submit"};var em={QUESTION_BELOW_EACH_OTHER:"question_below_each_other",QUESTION_PAGINATION:"question_pagination",SINGLE_QUESTION:"single_question"};var ef={SUBMIT_FAILED:"Failed to submit quiz",ABANDON_FAILED:"Failed to abandon quiz",REQUIRED_QUESTIONS:"Please answer all required questions before submitting."};var ep={QUESTION_WRAPPER_ATTR:"data-quiz-question-index",QUESTION_WRAPPER:".tutor-quiz-question-wrapper"};var e_={QUESTION_VALUE_PREFIX:"[quiz_question]"};var eT={AUTO_START_COMPLETE:"tutor-quiz-autostart-complete"};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/auto-start.ts
var eE=e=>{var t;var{query:r,toast:i,modal:n,endpoints:o}=window.TutorCore;var{convertToErrorMessage:a}=window.TutorCore.error;var{wpPostForm:s}=window.TutorCore.api;var{tutorConfig:l}=window.TutorCore.config;var u=eT.AUTO_START_COMPLETE;var d;return{quizID:e.quizID,autoStart:typeof e.autoStart==="boolean"?e.autoStart:Number((t=l.quiz_options)===null||t===void 0?void 0:t.quiz_auto_start)>0,autoStartModalId:(d=e.autoStartModalId)!==null&&d!==void 0?d:"",countdownSeconds:Number(e.countdownSeconds)||5,isCountdownActive:false,autoStartListener:null,startQuizMutation:null,init(){this.autoStartListener=()=>{var e;if(!this.isCountdownActive){return}this.isCountdownActive=false;(e=this.startQuizMutation)===null||e===void 0?void 0:e.mutate({quizID:this.quizID})};document.addEventListener(u,this.autoStartListener);this.startQuizMutation=r.useMutation(this.startQuiz,{onSuccess:()=>{window.location.reload()},onError:e=>{if(this.autoStartModalId){var t;n===null||n===void 0?void 0:(t=n.closeModal)===null||t===void 0?void 0:t.call(n,this.autoStartModalId)}i.error(a(e))}});if(!this.autoStart){return}this.startAutoStartCountdown()},handleStartQuiz(){var e;(e=this.startQuizMutation)===null||e===void 0?void 0:e.mutate({quizID:this.quizID})},startAutoStartCountdown(){if(!this.autoStartModalId){var e;(e=this.startQuizMutation)===null||e===void 0?void 0:e.mutate({quizID:this.quizID});return}if(this.isCountdownActive){return}this.isCountdownActive=true;window.setTimeout(()=>{var e;n===null||n===void 0?void 0:(e=n.showModal)===null||e===void 0?void 0:e.call(n,this.autoStartModalId)},0)},startQuiz(e){return s(window.location.href,{tutor_action:o.START_QUIZ,quiz_id:e.quizID})},destroy(){if(this.autoStartListener){document.removeEventListener(u,this.autoStartListener)}}}};var eg={name:"quizAutoStart",component:eE};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/helpers.ts
var eA=e=>{var t=e.match(/.{1,2}/g);if(!t){return null}return t.map(e=>String.fromCharCode(parseInt(e,16))).join("")};var ew=e=>{if(!e){return""}try{var t=eA(e);if(t){return decodeURIComponent(t)}}catch(e){// fall through to legacy decode
}try{return decodeURIComponent(e.split("").reverse().join(""))}catch(e){return""}};var eS=(e,t)=>{var r;var i=e.querySelector(ec.QUESTION_SELECTOR);if(!i){return}if(i.getAttribute(ec.DATA_REVEALED_ATTR)==="1"){return}var n=e.querySelector(ec.EXPLANATION_TRIGGER_SELECTOR);var o=e.querySelector(ec.EXPLANATION_SELECTOR);var a;var s=(a=o===null||o===void 0?void 0:o.querySelector(ec.EXPLANATION_BODY_SELECTOR))!==null&&a!==void 0?a:null;var l;var u=(l=o===null||o===void 0?void 0:(r=o.dataset)===null||r===void 0?void 0:r[ec.EXPLANATION_CONTENT_DATASET])!==null&&l!==void 0?l:"";if(s&&u&&!s.innerHTML.trim()){var d=ew(u);if(d){s.innerHTML=d}}if(n&&n.getAttribute("aria-expanded")!=="true"){n.click()}var c=Array.from(i.querySelectorAll('input[type="radio"], input[type="checkbox"]'));var v=new Set;var h=new Set;c.forEach(e=>{var r=e.closest(ec.OPTION_SELECTOR);if(!r){return}var i=Number(e.value);if(Number.isNaN(i)){return}if(e.checked){v.add(i)}var n=t.includes(i);if(n){h.add(i)}if(n){r.setAttribute(ec.DATA_OPTION_ATTR,ec.DATA_OPTION_CORRECT)}else if(e.checked){r.setAttribute(ec.DATA_OPTION_ATTR,ec.DATA_OPTION_INCORRECT)}e.disabled=true});var m=v.size>0&&v.size===h.size&&Array.from(v).every(e=>h.has(e));i.setAttribute(ec.DATA_RESULT_ATTR,m?ec.DATA_OPTION_CORRECT:ec.DATA_OPTION_INCORRECT);i.setAttribute(ec.DATA_REVEALED_ATTR,"1")};var ey=e=>{var t=function(t){var r="".concat(e_.QUESTION_VALUE_PREFIX,"[").concat(t,"]");var i=Object.entries(e).some(e=>{var[t,i]=e;if(!t.includes(r)){return false}if(i===""||i===null||i===undefined){return false}if(Array.isArray(i)&&i.length===0){return false}return true});if(i){n++}};var r=Object.entries(e).find(e=>{var[t]=e;return t.includes("[quiz_question_ids]")});if(!r){return 0}var i=Array.isArray(r[1])?r[1]:[];var n=0;for(var o of i)t(o);return n};var eI=e=>{var t;var r=(t=window.TutorCore)===null||t===void 0?void 0:t.form;if(!r||!e||!r.hasForm(e)){return 0}var i;var n=(i=r.getFormState(e).values)!==null&&i!==void 0?i:{};return ey(n)};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/layout.ts
var eR=e=>{var{form:t,tutorConfig:r}=window.TutorCore;var i=null;var n=null;var a=null;var s,l,u,d;return{layout:(s=e.layout)!==null&&s!==void 0?s:em.QUESTION_BELOW_EACH_OTHER,formId:(l=e.formId)!==null&&l!==void 0?l:"",totalQuestions:Number(e.totalQuestions)||0,currentIndex:1,enableAnswerReveal:(u=e.enableAnswerReveal)!==null&&u!==void 0?u:false,revealWaitMs:(d=e.revealWaitMs)!==null&&d!==void 0?d:null,revealAnswerIds:[],answerRequiredByIndex:{},revealStateByIndex:{},skippedByIndex:{},revealFooterState:"",isRevealing:false,revealTimeoutId:null,$el:null,$root:null,init(){var e;var t;i=(e=(t=this.$root)!==null&&t!==void 0?t:this.$el)===null||e===void 0?void 0:e.querySelector(".tutor-quiz-questions");// Keyboard vs Mouse Navigation helper for focus styles
n=e=>{if(e.key==="Tab"){i===null||i===void 0?void 0:i.classList.add("tutor-keyboard-nav");if(n)window.removeEventListener("keydown",n);if(a){window.addEventListener("mousedown",a);window.addEventListener("touchstart",a)}}};a=()=>{i===null||i===void 0?void 0:i.classList.remove("tutor-keyboard-nav");if(a){window.removeEventListener("mousedown",a);window.removeEventListener("touchstart",a)}if(n)window.addEventListener("keydown",n)};if(n)window.addEventListener("keydown",n);this.revealAnswerIds=this.getRevealAnswerIds();this.answerRequiredByIndex=this.getAnswerRequiredMap();this.revealStateByIndex=this.getRevealStateMap();this.skippedByIndex=this.getSkippedStateMap();if(this.layout===em.QUESTION_BELOW_EACH_OTHER){return}this.currentIndex=1;this.syncCurrentRevealFooterState()},destroy(){if(n){window.removeEventListener("keydown",n)}if(a){window.removeEventListener("mousedown",a);window.removeEventListener("touchstart",a)}},isQuestionActive(e){if(this.layout===em.QUESTION_BELOW_EACH_OTHER){return true}return e===this.currentIndex},canSkip(e){if(this.layout===em.QUESTION_BELOW_EACH_OTHER){return false}if(e>=this.totalQuestions){return false}if(Object.prototype.hasOwnProperty.call(this.answerRequiredByIndex,e)){return!this.answerRequiredByIndex[e]}var t=this.getQuestionWrapper(e);if(!t){return false}return t.dataset.answerRequired!=="1"},hasAttemptedValue(e){if(e===null||e===undefined){return false}if(typeof e==="string"){return e.trim().length>0}if(Array.isArray(e)){return e.some(e=>this.hasAttemptedValue(e))}if(typeof e==="object"){return Object.values(e).some(e=>this.hasAttemptedValue(e))}return true},isQuestionAttempted(e){if(!t||!this.formId||!t.hasForm(this.formId)){return false}var r;var i=(r=t.getFormState(this.formId).values)!==null&&r!==void 0?r:{};var n=this.getQuestionFieldNames(i,e);if(!n.length){return false}return n.some(e=>this.hasAttemptedValue(i[e]))},shouldDisableNextButton(){if(this.layout!==em.SINGLE_QUESTION){return false}return this.answerRequiredByIndex[this.currentIndex]&&!this.isQuestionAttempted(this.currentIndex)},getPaginationState(e){if(this.revealStateByIndex[e]){return this.revealStateByIndex[e]}if(this.isQuestionAttempted(e)){return"answered"}if(this.skippedByIndex[e]){return"skipped"}return null},getPaginationItemClass(e){var t=this.getPaginationState(e);return{active:this.currentIndex===e,answered:t==="answered",correct:t==="correct",incorrect:t==="incorrect",skipped:t==="skipped",upcoming:e>this.currentIndex&&t===null}},syncRevealFooterState(e){if(!this.isRevealMode()){this.revealFooterState="";return}var t=this.getQuestionElement(e);if(!t||t.getAttribute(ec.DATA_REVEALED_ATTR)!=="1"){this.revealFooterState="";return}var r=t.getAttribute(ec.DATA_RESULT_ATTR);if(r===ec.DATA_OPTION_CORRECT){this.revealStateByIndex[this.currentIndex]="correct";this.revealFooterState="correct";return}if(r===ec.DATA_OPTION_INCORRECT){this.revealStateByIndex[this.currentIndex]="incorrect";this.revealFooterState="incorrect";return}this.revealFooterState=""},syncCurrentRevealFooterState(){if(!this.isRevealMode()){this.revealFooterState="";return}var e=this.getQuestionWrapper(this.currentIndex);if(!e){this.revealFooterState="";return}this.syncRevealFooterState(e)},goPrev(){if(this.layout===em.QUESTION_BELOW_EACH_OTHER){return}if(this.currentIndex>1){this.clearRevealTimeout();this.markCurrentAsSkipped();this.runWithViewTransition(()=>{this.currentIndex-=1;this.syncCurrentRevealFooterState()},"back");this.scrollToQuestion()}},goNext(){return o(function*(){var{skipValidation:e=false}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.layout===em.QUESTION_BELOW_EACH_OTHER){return}if(!e&&this.shouldDisableNextButton()){return}var t=this.getQuestionWrapper(this.currentIndex);if(!t){return}if(!e){var r=yield this.triggerQuestionValidation(this.currentIndex);if(!r){return}}if(!e&&this.isRevealMode()&&this.shouldReveal(t)){if(this.isQuestionRevealed(t)){this.clearRevealTimeout();this.moveToNextQuestion();return}if(!this.isQuestionAttempted(this.currentIndex)){this.moveToNextQuestion();return}this.isRevealing=true;this.revealQuestion(t);this.syncRevealFooterState(t);var i=this.getRevealWaitTime();this.revealTimeoutId=window.setTimeout(()=>{this.isRevealing=false;this.revealTimeoutId=null;this.moveToNextQuestion()},i);return}this.moveToNextQuestion()}).apply(this,arguments)},goTo(e){if(this.layout===em.QUESTION_BELOW_EACH_OTHER){return}if(!e||e<1||e>this.totalQuestions){return}this.clearRevealTimeout();this.markCurrentAsSkipped();this.runWithViewTransition(()=>{this.currentIndex=e;this.syncCurrentRevealFooterState()},e<this.currentIndex?"back":"forward");this.scrollToQuestion()},runWithViewTransition(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"forward";void t;e()},clearRevealTimeout(){if(this.revealTimeoutId!==null){window.clearTimeout(this.revealTimeoutId);this.revealTimeoutId=null}this.isRevealing=false},moveToNextQuestion(){if(this.currentIndex<this.totalQuestions){this.markCurrentAsSkipped();this.runWithViewTransition(()=>{this.currentIndex+=1;this.syncCurrentRevealFooterState()});this.scrollToQuestion()}},getRevealWaitTime(){var e;var t=Number((e=this.revealWaitMs)!==null&&e!==void 0?e:"");if(!Number.isNaN(t)&&t>0){return t}var i;var n=Number((i=r.quiz_answer_display_time)!==null&&i!==void 0?i:"");if(!Number.isNaN(n)&&n>0){return n}return ec.DEFAULT_WAIT_MS},isRevealMode(){return this.enableAnswerReveal},getRevealAnswerIds(){var e=document.getElementById(ec.ANSWER_CONTEXT_ID);if(!(e===null||e===void 0?void 0:e.textContent)){return[]}try{var t;var r=e.textContent.trim();var i=(t=r.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(e=>String.fromCharCode(parseInt(e,16))).join("");if(!i){return[]}var n=JSON.parse(i);if(!Array.isArray(n)){return[]}return n.map(e=>Number(e)).filter(e=>!Number.isNaN(e))}catch(e){return[]}},getQuestionElement(e){return e.querySelector(ec.QUESTION_SELECTOR)},isQuestionRevealed(e){var t=this.getQuestionElement(e);return(t===null||t===void 0?void 0:t.getAttribute(ec.DATA_REVEALED_ATTR))==="1"},getQuestionType(e){var t,r;var i;return(i=(r=this.getQuestionElement(e))===null||r===void 0?void 0:(t=r.dataset)===null||t===void 0?void 0:t.question)!==null&&i!==void 0?i:""},shouldReveal(e){if(!this.isRevealMode()){return false}if(!this.revealAnswerIds.length){return false}var t=this.getQuestionType(e);return ec.SUPPORTED_TYPES.includes(t)},revealQuestion(e){eS(e,this.revealAnswerIds)},revealOnSubmit(){if(!this.isRevealMode()){return false}if(this.layout===em.QUESTION_BELOW_EACH_OTHER){var e;var t,r;var i=Array.from((r=(e=(t=this.$root)!==null&&t!==void 0?t:this.$el)===null||e===void 0?void 0:e.querySelectorAll("".concat(ep.QUESTION_WRAPPER)))!==null&&r!==void 0?r:[]);var n=false;i.forEach(e=>{if(this.shouldReveal(e)){this.revealQuestion(e);n=true}});return n}var o=this.getQuestionWrapper(this.currentIndex);if(!o||!this.shouldReveal(o)){return false}this.revealQuestion(o);return true},getQuestionWrapper(e){var t;var r=(t=this.$root)!==null&&t!==void 0?t:this.$el;return r===null||r===void 0?void 0:r.querySelector("".concat(ep.QUESTION_WRAPPER,"[").concat(ep.QUESTION_WRAPPER_ATTR,'="').concat(e,'"]'))},getAnswerRequiredMap(){var e;var t=(e=this.$root)!==null&&e!==void 0?e:this.$el;if(!t){return{}}var r=Array.from(t.querySelectorAll(ep.QUESTION_WRAPPER));var i={};r.forEach(e=>{var t=Number(e.getAttribute(ep.QUESTION_WRAPPER_ATTR));if(Number.isNaN(t)||t<1){return}i[t]=e.dataset.answerRequired==="1"});return i},getRevealStateMap(){var e;var t=(e=this.$root)!==null&&e!==void 0?e:this.$el;if(!t||!this.isRevealMode()){return{}}var r=Array.from(t.querySelectorAll(ep.QUESTION_WRAPPER));var i={};r.forEach(e=>{var t=Number(e.getAttribute(ep.QUESTION_WRAPPER_ATTR));if(Number.isNaN(t)||t<1){return}var r=this.getQuestionElement(e);if(!r||r.getAttribute(ec.DATA_REVEALED_ATTR)!=="1"){return}var n=r.getAttribute(ec.DATA_RESULT_ATTR);if(n===ec.DATA_OPTION_CORRECT){i[t]="correct";return}if(n===ec.DATA_OPTION_INCORRECT){i[t]="incorrect"}});return i},getSkippedStateMap(){var e;var t=(e=this.$root)!==null&&e!==void 0?e:this.$el;if(!t){return{}}var r=Array.from(t.querySelectorAll(ep.QUESTION_WRAPPER));var i={};r.forEach(e=>{var t=Number(e.getAttribute(ep.QUESTION_WRAPPER_ATTR));if(Number.isNaN(t)||t<1){return}i[t]=false});return i},markCurrentAsSkipped(){var e=this.currentIndex;if(!e||e<1||e>this.totalQuestions){return}if(this.revealStateByIndex[e]){this.skippedByIndex[e]=false;return}var t=this.isQuestionAttempted(e);this.skippedByIndex[e]=!t},scrollToQuestion(){var e=this.getQuestionWrapper(this.currentIndex);if(!e){return}e.scrollIntoView({behavior:"smooth",block:"start"})},getQuestionIdByIndex(e,t){var r=Object.entries(e).find(e=>{var[t]=e;return t.includes("[quiz_question_ids]")});if(!r){return null}var[,i]=r;var n=Array.isArray(i)?i:[];if(!n.length){return null}var o;return(o=n[t-1])!==null&&o!==void 0?o:null},getQuestionFieldNames(e,t){var r=this.getQuestionIdByIndex(e,t);if(!r){return[]}var i="".concat(e_.QUESTION_VALUE_PREFIX,"[").concat(r,"]");return Object.keys(e).filter(e=>e.includes(i))},triggerQuestionValidation(e){return o(function*(){if(!t||!this.formId||!t.hasForm(this.formId)){return true}var r;var i=(r=t.getFormState(this.formId).values)!==null&&r!==void 0?r:{};var n=this.getQuestionFieldNames(i,e);if(!n.length){return true}return yield t.trigger(this.formId,n)}).call(this)}}};var eO={name:"quizLayout",component:eR};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/questions/matching.ts
var eb=()=>o(function*(){var e=yield r.e(/* import() | tutor-dnd-kit */"4").then(r.bind(r,8679));return{DragDropManager:e.DragDropManager,Draggable:e.Draggable,Droppable:e.Droppable,KeyboardSensor:e.KeyboardSensor,PointerSensor:e.PointerSensor}})();var eC={CLASSES:{QUESTION_OPTION:"tutor-quiz-question-option",DROP_ZONE:"tutor-quiz-question-option-drop-zone",TEXT_SUBDUED:"tutor-text-subdued",DROPPED:"dropped"},ATTRS:{OPTION:"data-option",ID:"data-id",GRAB_HANDLE:"data-grab-handle",DROP_ZONE_ID:"data-drop-zone-id",DROP_PLACEHOLDER:"data-drop-placeholder",DROP_PLACEHOLDER_TEXT:"data-drop-placeholder-text"},VALUES:{DRAGGABLE:"draggable",DRAGGING:"dragging",DROPPED:"dropped"},DATASET:{ID:"id",DROP_ZONE_ID:"dropZoneId",DROP_PLACEHOLDER_TEXT:"dropPlaceholderText"}};/**
 * Question Matching Component
 * Handles drag-and-drop matching of quiz question options to drop zones
 */var eN=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{_draggables:[],_dropZones:[],_matches:{},_dropZoneOrder:[],_questionId:e.questionId,_callbacks:{onDrop:e.onDrop,onClear:e.onClear},$el:null,$event:null,initialized:false,_getValuesFromMatches(){return this._dropZoneOrder.map(e=>{var t;return(t=this._matches[e])!==null&&t!==void 0?t:""})},clearDropZone(){var e,t,r;var i=(e=this.$event)===null||e===void 0?void 0:e.target;var n=i===null||i===void 0?void 0:i.closest(".".concat(eC.CLASSES.DROP_ZONE));if(!n){return}var o=n.querySelector("[".concat(eC.ATTRS.OPTION,'="').concat(eC.VALUES.DROPPED,'"]'));if(o){o.remove()}this._restoreDropPlaceholder(n);var a=n.dataset[eC.DATASET.DROP_ZONE_ID];if(a&&this._matches[a]){delete this._matches[a]}var s=this._getValuesFromMatches();(t=(r=this._callbacks).onClear)===null||t===void 0?void 0:t.call(r,s)},_restoreDropPlaceholder(e){var t=e.querySelector("[".concat(eC.ATTRS.DROP_PLACEHOLDER,"]"));if(t){return}var r=document.createElement("span");r.setAttribute(eC.ATTRS.DROP_PLACEHOLDER,"");r.className=eC.CLASSES.TEXT_SUBDUED;r.textContent=e.dataset[eC.DATASET.DROP_PLACEHOLDER_TEXT]||(0,d.__)("Drop here","tutor");e.prepend(r)},_animateDropSnap(e,t){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){return}e.animate([{transform:"scale(0.985)"},{transform:"scale(1.02)"},{transform:"scale(1)"}],{duration:220,easing:"cubic-bezier(0.2, 0.9, 0.2, 1)"});t.animate([{transform:"scale(0.94)",opacity:.86},{transform:"scale(1.015)",opacity:1},{transform:"scale(1)",opacity:1}],{duration:180,easing:"cubic-bezier(0.22, 1, 0.36, 1)"})},init(){if(!this.initialized){this.setupDrag();this.initialized=true}},setupDrag(){return o(function*(){var e=this.$el;if(!e){return}var{DragDropManager:t,Draggable:r,Droppable:i,KeyboardSensor:n,PointerSensor:o}=yield eb();if(!this.initialized){return}var a=new t({sensors:[o,n]});var s=Array.from(e.querySelectorAll(".".concat(eC.CLASSES.QUESTION_OPTION,"[").concat(eC.ATTRS.OPTION,'="').concat(eC.VALUES.DRAGGABLE,'"]')));s.forEach((e,t)=>{var i=e.querySelector("[".concat(eC.ATTRS.GRAB_HANDLE,"]"));var n;var o=(n=e.dataset[eC.DATASET.ID])!==null&&n!==void 0?n:String(t);var s=new r({id:o,element:e,handle:i!==null&&i!==void 0?i:undefined,feedback:"clone"},a);this._draggables.push(s)});var l=Array.from(e.querySelectorAll(".".concat(eC.CLASSES.DROP_ZONE)));l.forEach((e,t)=>{var r;var n=(r=e.dataset[eC.DATASET.ID])!==null&&r!==void 0?r:String(t);e.dataset[eC.DATASET.DROP_ZONE_ID]=n;this._dropZoneOrder.push(n);var o=new i({id:n,element:e},a);this._dropZones.push(o)});a.monitor.addEventListener("dragstart",e=>{var t=e.operation;if(!t.source){return}var r=t.source.element;if(r){r.setAttribute(eC.ATTRS.OPTION,eC.VALUES.DRAGGING)}});a.monitor.addEventListener("dragend",e=>{var t=e.operation;if(!t.source){return}var r=t.source.element;var i=t.target;if(r){r.setAttribute(eC.ATTRS.OPTION,eC.VALUES.DRAGGABLE)}if(i){var n,o;var a=i.element;var s=t.source.id;if(!a){return}var l=document.createElement("div");l.setAttribute(eC.ATTRS.OPTION,eC.VALUES.DROPPED);l.setAttribute(eC.ATTRS.ID,String(s));var u;l.textContent=(u=r===null||r===void 0?void 0:r.textContent)!==null&&u!==void 0?u:"";var d=a===null||a===void 0?void 0:a.querySelector("[".concat(eC.ATTRS.DROP_PLACEHOLDER,"]"));var c=a===null||a===void 0?void 0:a.querySelector("[".concat(eC.ATTRS.OPTION,'="').concat(eC.VALUES.DROPPED,'"]'));if(d){d.replaceWith(l)}else if(c){c.replaceWith(l)}this._animateDropSnap(a,l);this._matches[i.id]=String(s);var v=this._getValuesFromMatches();(n=(o=this._callbacks).onDrop)===null||n===void 0?void 0:n.call(o,v)}})}).call(this)},// @TODO: Will be removed if not needed
reset(){this._dropZones.forEach(e=>{var t=e.element;while(t===null||t===void 0?void 0:t.firstChild){t.removeChild(t.firstChild)}});this._draggables.forEach(e=>{var t,r;(t=e.element)===null||t===void 0?void 0:t.setAttribute(eC.ATTRS.OPTION,eC.VALUES.DRAGGABLE);(r=e.element)===null||r===void 0?void 0:r.classList.remove(eC.CLASSES.DROPPED)});this._matches={};this._dropZoneOrder=[]},destroy(){this._draggables.forEach(e=>e.destroy());this._draggables=[];this._dropZones.forEach(e=>e.destroy());this._dropZones=[];this._matches={};this._dropZoneOrder=[];this.initialized=false}}};var eM={name:"questionMatching",component:eN};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/questions/ordering.ts
var eP=()=>o(function*(){var[e,t]=yield Promise.all([r.e(/* import() | tutor-dnd-kit */"4").then(r.bind(r,8679)),r.e(/* import() | tutor-dnd-kit */"4").then(r.bind(r,99375))]);return{DragDropManager:e.DragDropManager,KeyboardSensor:e.KeyboardSensor,PointerSensor:e.PointerSensor,Sortable:t.Sortable}})();var eL={CLASSES:{QUESTION_OPTION:"tutor-quiz-question-option"},ATTRS:{OPTION:"data-option",ID:"data-id",GRAB_HANDLE:"data-grab-handle"},VALUES:{DRAGGABLE:"draggable",DRAGGING:"dragging"},DATASET:{ID:"id"}};/**
 * Question Ordering Component
 * Handles drag-and-drop reordering of quiz question options
 */var eD=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return{_sortables:[],_questionId:e.questionId,_callbacks:{onOrder:e.onOrder},initialized:false,$el:null,init(){if(!this.initialized){this.setupDrag();this.initialized=true}},setupDrag(){return o(function*(){var e=this.$el;if(!e){return}var{DragDropManager:t,KeyboardSensor:r,PointerSensor:i,Sortable:n}=yield eP();if(!this.initialized){return}var o=new t({sensors:[i,r]});var a=Array.from(e.querySelectorAll(".".concat(eL.CLASSES.QUESTION_OPTION,"[").concat(eL.ATTRS.OPTION,'="').concat(eL.VALUES.DRAGGABLE,'"]')));this._sortables=[];a.forEach((e,t)=>{var r=e.querySelector("[".concat(eL.ATTRS.GRAB_HANDLE,"]"));var i;var a=(i=e.dataset[eL.DATASET.ID])!==null&&i!==void 0?i:String(t);var s=new n({id:a,index:t,element:e,handle:r!==null&&r!==void 0?r:undefined},o);this._sortables.push(s)});o.monitor.addEventListener("dragstart",e=>{var t=e.operation;if(!t.source){return}var r=t.source.element;if(!r){return}r.setAttribute(eL.ATTRS.OPTION,eL.VALUES.DRAGGING)});o.monitor.addEventListener("dragend",e=>{var t=e.operation;if(!t.source){return}var r=t.source.element;if(!r){return}r.setAttribute(eL.ATTRS.OPTION,eL.VALUES.DRAGGABLE);if(this.$el){this.$el.dataset.hasInteraction="1"}requestAnimationFrame(()=>{var e,t;(e=(t=this._callbacks).onOrder)===null||e===void 0?void 0:e.call(t,this.getOrder())})})}).call(this)},getOrder(){var e=this.$el;if(!e){return[]}var t=Array.from(e.querySelectorAll(".".concat(eL.CLASSES.QUESTION_OPTION)));return[...new Set(t.map(e=>e.dataset[eL.DATASET.ID]).filter(e=>typeof e==="string"))]},destroy(){this._sortables.forEach(e=>e.destroy());this._sortables=[];this.initialized=false}}};var eQ={name:"questionOrdering",component:eD};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/radar.ts
var eq=5;var eU={BG_CANVAS:'[data-quiz-autostart-canvas="bg"]',SWEEP_CANVAS:'[data-quiz-autostart-canvas="sweep"]',DIGIT:"[data-quiz-autostart-digit]"};var ex=e=>({seconds:Number(e.seconds)||eq,eventName:e.eventName||eT.AUTO_START_COMPLETE,remaining:0,angle:-90,lastTick:null,animationFrame:null,countdownTimer:null,card:null,bgCanvas:null,sweepCanvas:null,resizeHandler:null,$el:null,init(){this.remaining=this.seconds;this.cacheElements();this.waitForLayout()},destroy(){if(this.animationFrame){window.cancelAnimationFrame(this.animationFrame);this.animationFrame=null}if(this.countdownTimer){window.clearInterval(this.countdownTimer);this.countdownTimer=null}if(this.resizeHandler){window.removeEventListener("resize",this.resizeHandler);this.resizeHandler=null}},cacheElements(){this.card=this.$el;this.bgCanvas=this.card.querySelector(eU.BG_CANVAS);this.sweepCanvas=this.card.querySelector(eU.SWEEP_CANVAS);if(!this.resizeHandler){this.resizeHandler=()=>this.resize();window.addEventListener("resize",this.resizeHandler)}},resize(){if(!this.card||!this.bgCanvas||!this.sweepCanvas){return}var e=this.card.getBoundingClientRect();var t=Math.max(0,Math.floor(e.width));var r=Math.max(0,Math.floor(e.height));this.bgCanvas.width=t;this.bgCanvas.height=r;this.sweepCanvas.width=t;this.sweepCanvas.height=r;this.drawBackground()},waitForLayout(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:30;if(!this.card){return}var t=this.card.getBoundingClientRect();if(t.width>0&&t.height>0){this.resize();this.startRadarAnimation();this.startCountdownTimer();return}if(e<=0){return}window.requestAnimationFrame(()=>this.waitForLayout(e-1))},drawBackground(){if(!this.bgCanvas||!this.card){return}var e=this.bgCanvas.getContext("2d");if(!e){return}var t=this.card.clientWidth;var r=this.card.clientHeight;var i=t/2;var n=r/2;var o=Math.sqrt(i*i+n*n);var a=o*.3;var s=o*.52;var l=document.documentElement.getAttribute("data-tutor-theme")==="dark";e.clearRect(0,0,t,r);e.beginPath();e.arc(i,n,a,0,Math.PI*2);e.fillStyle=l?"#2c3342":"#E7EDFC";e.fill();e.beginPath();e.arc(i,n,s,0,Math.PI*2);e.strokeStyle=l?"#3F63DF":"#E7EDFC";e.lineWidth=1.5;e.stroke()},drawSweep(){if(!this.sweepCanvas||!this.card){return}var e=this.sweepCanvas.getContext("2d");if(!e){return}var t=this.card.clientWidth;var r=this.card.clientHeight;var i=t/2;var n=r/2;var o=Math.sqrt(i*i+n*n);// Fixed anchor: 12 o'clock
    var a=-90;var s=a*Math.PI/180;// Moving end: goes from 0° → 360° (i.e. -90° clockwise back to -90°) over 1 s
    var l=this.angle/360;// 0..1
    var u=s+l*Math.PI*2;var d=340;var c=document.documentElement.getAttribute("data-tutor-theme")==="dark";var v=c?[112,133,222]:[197,208,245];var h=c?[44,51,66]:[241,245,254];e.clearRect(0,0,t,r);// Draw gradient fan from the fixed anchor to the moving arm
    for(var m=d;m>=0;m--){var f=m/d;// 1 = near moving arm, 0 = near anchor
    var p=u-(u-s)*f;var _=f<.3?0:(f-.3)/.7;var T=[Math.round(v[0]+(h[0]-v[0])*_),Math.round(v[1]+(h[1]-v[1])*_),Math.round(v[2]+(h[2]-v[2])*_)];var E=.3+(1-.3)*_;e.beginPath();e.moveTo(i,n);e.arc(i,n,o,p,p+.025);e.closePath();e.fillStyle="rgba(".concat(T[0],",").concat(T[1],",").concat(T[2],",").concat((E*(1-f*.5)).toFixed(3),")");e.fill()}// Draw moving arm
    e.beginPath();e.moveTo(i,n);e.lineTo(i+Math.cos(u)*o,n+Math.sin(u)*o);e.strokeStyle=c?"rgba(63, 99, 223, 1)":"rgba(62,100,222,0.30)";e.lineWidth=1.5;e.stroke()},startRadarAnimation(){// this.angle tracks degrees elapsed within the current 1-second cycle (0..360)
    this.angle=0;var e=t=>{if(this.lastTick!==null){var r=t-this.lastTick;// Complete one full revolution per second
    this.angle+=360/1e3*r;// Reset to beginning of next cycle (stays in sync with 1-s countdown)
    if(this.angle>=360){this.angle-=360}}this.drawSweep();this.lastTick=t;this.animationFrame=window.requestAnimationFrame(e)};this.animationFrame=window.requestAnimationFrame(e)},startCountdownTimer(){var e;var t=(e=this.card)===null||e===void 0?void 0:e.querySelector(eU.DIGIT);if(t){t.textContent=String(this.remaining)}this.countdownTimer=window.setInterval(()=>{this.remaining=Math.max(0,this.remaining-1);if(t){t.textContent=String(this.remaining)}if(this.remaining===0){this.finishCountdown()}},1e3)},finishCountdown(){if(this.countdownTimer){window.clearInterval(this.countdownTimer);this.countdownTimer=null}document.dispatchEvent(new CustomEvent(this.eventName))}});var ek={name:"radar",component:ex};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/submission.ts
var ez=e=>{var{query:t,toast:r,form:i,modal:n,constants:o,endpoints:a}=window.TutorCore;var{convertToErrorMessage:l}=window.TutorCore.error;var{wpPostForm:u,wpPost:d}=window.TutorCore.api;var{tutorConfig:c}=window.TutorCore.config;var{TUTOR_CUSTOM_EVENTS:v}=o;var h,m,f,p;return{formId:e.formId,attemptId:e.attemptId,quizId:e.quizId,abandonModalId:e.abandonModalId,totalQuestions:Number(e.totalQuestions)||0,enableAnswerReveal:(h=e.enableAnswerReveal)!==null&&h!==void 0?h:false,revealWaitMs:(m=e.revealWaitMs)!==null&&m!==void 0?m:null,submittedModalId:(f=e.submittedModalId)!==null&&f!==void 0?f:"",timeoutModalId:(p=e.timeoutModalId)!==null&&p!==void 0?p:"",submitQuizMutation:null,abandonQuizMutation:null,timeoutQuizMutation:null,hasTimedOut:false,isRevealSubmitting:false,beforeUnloadTriggered:false,isAbandoningNavigation:false,skipBeforeUnload:false,pendingNavigationAction:"",pendingNavigationUrl:"",pendingTimeoutSubmission:false,resultModalOpenId:"",modalCloseHandler:null,beforeUnloadHandler:null,navigationHandler:null,$el:null,$root:null,init(){this.handleQuizSubmit=this.handleQuizSubmit.bind(this);this.handleQuizError=this.handleQuizError.bind(this);this.handleQuizTimeout=this.handleQuizTimeout.bind(this);document.addEventListener(v.QUIZ_TIME_EXPIRED,e=>{var t;var r=(t=e===null||e===void 0?void 0:e.detail)!==null&&t!==void 0?t:{};if((r===null||r===void 0?void 0:r.formId)&&r.formId!==this.formId){return}this.handleQuizTimeout(r)});document.addEventListener(v.QUIZ_ABANDON_REQUESTED,e=>{var t;var r=(t=e===null||e===void 0?void 0:e.detail)!==null&&t!==void 0?t:{};if((r===null||r===void 0?void 0:r.formId)&&r.formId!==this.formId){return}this.handleAbandonQuiz()});this.beforeUnloadHandler=this.handleBeforeUnload.bind(this);this.navigationHandler=this.handleNavigationAttempt.bind(this);this.modalCloseHandler=this.handleModalClose.bind(this);window.addEventListener("beforeunload",this.beforeUnloadHandler);document.addEventListener(ev.NAVIGATION_EVENT,this.navigationHandler,true);document.addEventListener(v.MODAL_CLOSED,this.modalCloseHandler);this.submitQuizMutation=t.useMutation(this.submitQuizAttempt,{onSuccess:()=>{var e=this.pendingTimeoutSubmission;this.pendingTimeoutSubmission=false;this.handleSubmissionSuccess(e)},onError:e=>{this.pendingTimeoutSubmission=false;r.error(l(e))}});this.abandonQuizMutation=t.useMutation(this.abandonQuizAttempt,{onSuccess:()=>{this.isAbandoningNavigation=false;if(this.pendingNavigationAction==="navigate"&&this.pendingNavigationUrl){var e=this.pendingNavigationUrl;this.pendingNavigationAction="";this.pendingNavigationUrl="";this.performSafeNavigate(e);return}this.pendingNavigationAction="";this.pendingNavigationUrl="";this.performSafeReload()},onError:e=>{this.isAbandoningNavigation=false;this.skipBeforeUnload=false;r.error(l(e))}});this.timeoutQuizMutation=t.useMutation(this.timeoutQuizAttempt,{onSuccess:()=>{this.handleTimeoutSuccess()},onError:e=>{r.error(l(e))}})},handleQuizSubmit(e){var t;if(this.isRevealSubmitting){return}if(this.isRevealMode()){var r=this.getRevealWaitTime();var i=this.revealOnSubmit();if(i){this.isRevealSubmitting=true;var n=this.buildSubmitPayload(e);window.setTimeout(()=>{var e;(e=this.submitQuizMutation)===null||e===void 0?void 0:e.mutate(n);this.isRevealSubmitting=false},r);return}}var o=this.buildSubmitPayload(e);(t=this.submitQuizMutation)===null||t===void 0?void 0:t.mutate(o)},getRevealWaitTime(){var e;var t=Number((e=this.revealWaitMs)!==null&&e!==void 0?e:"");if(!Number.isNaN(t)&&t>0){return t}var r;var i=Number((r=c.quiz_answer_display_time)!==null&&r!==void 0?r:"");if(!Number.isNaN(i)&&i>0){return i}return ec.DEFAULT_WAIT_MS},isRevealMode(){return this.enableAnswerReveal},getRevealAnswerIds(){var e=document.getElementById(ec.ANSWER_CONTEXT_ID);if(!(e===null||e===void 0?void 0:e.textContent)){return[]}try{var t;var r=e.textContent.trim();var i=(t=r.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(e=>String.fromCharCode(parseInt(e,16))).join("");if(!i){return[]}var n=JSON.parse(i);if(!Array.isArray(n)){return[]}return n.map(e=>Number(e)).filter(e=>!Number.isNaN(e))}catch(e){return[]}},revealQuestion(e,t){eS(e,t)},revealOnSubmit(){var e=this.getRevealAnswerIds();if(!e.length){return false}var t;var r=(t=this.$root)!==null&&t!==void 0?t:this.$el;if(!r){return false}var i=Array.from(r.querySelectorAll(ep.QUESTION_WRAPPER));var n=false;i.forEach(t=>{var r;var i=t.querySelector(ec.QUESTION_SELECTOR);if(!i){return}var o;var a=(o=(r=i.dataset)===null||r===void 0?void 0:r.question)!==null&&o!==void 0?o:"";if(!ec.SUPPORTED_TYPES.includes(a)){return}this.revealQuestion(t,e);n=true});return n},handleQuizError(){r.error(ef.REQUIRED_QUESTIONS)},handleAbandonQuiz(){var e,t,r;if(!this.formId||!i.hasForm(this.formId)){return}var n;var o=(n=(t=i.getFormState)===null||t===void 0?void 0:(e=t.call(i,this.formId))===null||e===void 0?void 0:e.values)!==null&&n!==void 0?n:{};var a=this.buildSubmitPayload(o);(r=this.abandonQuizMutation)===null||r===void 0?void 0:r.mutate(a)},handleAbandonConfirm(){this.isAbandoningNavigation=true;this.prepareForNavigation();if(!this.pendingNavigationAction){this.pendingNavigationAction="reload"}this.handleAbandonQuiz()},handleAbandonCancel(){this.pendingNavigationAction="";this.pendingNavigationUrl="";this.isAbandoningNavigation=false;this.skipBeforeUnload=false;this.beforeUnloadTriggered=false},handleNavigationAttempt(e){var t;var r=e.target;if(!r){return}var i=r.closest("a");if(!i){return}if(i.hasAttribute("download")){return}var o=i.getAttribute("href")||"";if(!o||ev.IGNORE_ANCHOR_PREFIXES.some(e=>o.startsWith(e))){return}var a=(i.getAttribute("target")||"").toLowerCase();if(a&&a!=="_self"){return}if(!this.shouldWarnOnUnload()){return}e.preventDefault();this.pendingNavigationAction="navigate";this.pendingNavigationUrl=i.href;n===null||n===void 0?void 0:(t=n.showModal)===null||t===void 0?void 0:t.call(n,this.abandonModalId)},handleBeforeUnload(e){if(!this.shouldWarnOnUnload()){this.beforeUnloadTriggered=false;return}this.beforeUnloadTriggered=true;e.preventDefault();e.returnValue="";return""},shouldWarnOnUnload(){var e,t,r;if(!this.formId||!(i===null||i===void 0?void 0:(e=i.hasForm)===null||e===void 0?void 0:e.call(i,this.formId))){return false}if(this.skipBeforeUnload){return false}if(this.isAbandoningNavigation){return false}if(this.hasTimedOut||this.isRevealSubmitting){return false}if(((t=this.submitQuizMutation)===null||t===void 0?void 0:t.isPending)||((r=this.abandonQuizMutation)===null||r===void 0?void 0:r.isPending)){return false}return true},prepareForNavigation(){this.skipBeforeUnload=true;this.beforeUnloadTriggered=false;if(this.beforeUnloadHandler){window.removeEventListener("beforeunload",this.beforeUnloadHandler)}if(this.navigationHandler){document.removeEventListener(ev.NAVIGATION_EVENT,this.navigationHandler,true)}},performSafeReload(){this.prepareForNavigation();window.location.reload()},performSafeNavigate(e){this.prepareForNavigation();window.location.assign(e)},getAttemptedCount(){return eI(this.formId)},openResultModal(e,t){var r;if(!e){this.performSafeReload();return}this.prepareForNavigation();this.resultModalOpenId=e;n===null||n===void 0?void 0:(r=n.showModal)===null||r===void 0?void 0:r.call(n,e,t!==null&&t!==void 0?t:null)},notifyAttemptCompleted(){document.dispatchEvent(new CustomEvent(v.QUIZ_ATTEMPT_COMPLETED,{detail:{formId:this.formId,attemptId:this.attemptId,quizId:this.quizId}}))},handleSubmissionSuccess(e){this.notifyAttemptCompleted();if(e){this.openResultModal(this.timeoutModalId,{attempted:this.getAttemptedCount(),total:this.totalQuestions});return}this.openResultModal(this.submittedModalId)},handleTimeoutSuccess(){this.notifyAttemptCompleted();this.openResultModal(this.timeoutModalId,{attempted:this.getAttemptedCount(),total:this.totalQuestions})},handleModalClose(e){var t;var r=(t=e===null||e===void 0?void 0:e.detail)!==null&&t!==void 0?t:{};var i=r===null||r===void 0?void 0:r.id;if(!this.resultModalOpenId){return}if(i&&i!==this.resultModalOpenId){return}var n=this.resultModalOpenId===this.submittedModalId||this.resultModalOpenId===this.timeoutModalId;this.resultModalOpenId="";if(n){this.performSafeReload()}},handleQuizTimeoutAbandon(){var e;if(!this.quizId){return}(e=this.timeoutQuizMutation)===null||e===void 0?void 0:e.mutate({quiz_id:this.quizId})},handleQuizTimeout(e){var t,r,n,o,a;var s=e===null||e===void 0?void 0:e.action;if(!s||!this.formId||!i.hasForm(this.formId)){return}if(this.hasTimedOut){return}if(((t=this.submitQuizMutation)===null||t===void 0?void 0:t.isPending)||((r=this.abandonQuizMutation)===null||r===void 0?void 0:r.isPending)||((n=this.timeoutQuizMutation)===null||n===void 0?void 0:n.isPending)){return}var l;var u=(l=(a=i.getFormState)===null||a===void 0?void 0:(o=a.call(i,this.formId))===null||o===void 0?void 0:o.values)!==null&&l!==void 0?l:{};if(s===eh.AUTO_SUBMIT){this.hasTimedOut=true;this.pendingTimeoutSubmission=true;this.handleQuizSubmit(u);return}if(s===eh.AUTO_ABANDON){this.hasTimedOut=true;this.handleQuizTimeoutAbandon()}},buildSubmitPayload(e){var t=this.normalizePayload(e);t.attempt_id=this.attemptId;return t},normalizePayload(e){var t=new Map;return Object.entries(e).reduce((e,r)=>{var[i,n]=r;var o=i.replace(/\[\].*$/,"");var a;var s=(a=t.get(o))!==null&&a!==void 0?a:0;var l=s+1;t.set(o,l);var u=(e,t)=>{if(Array.isArray(t)){t.forEach(t=>e.push(t));return}e.push(t)};if(l===1){e[o]=n;return e}var d=e[o];var c=[];if(l===2){u(c,d)}else if(Array.isArray(d)){d.forEach(e=>c.push(e))}u(c,n);e[o]=c;return e},{})},submitQuizAttempt(e){return u(window.location.href,s({tutor_action:a.QUIZ_ATTEMPT_SUBMIT},e))},abandonQuizAttempt(e){return d(a.QUIZ_ABANDON,s({tutor_action:a.QUIZ_ATTEMPT_SUBMIT},e))},timeoutQuizAttempt(e){return d(a.QUIZ_TIMEOUT,s({},e))},destroy(){if(this.beforeUnloadHandler){window.removeEventListener("beforeunload",this.beforeUnloadHandler)}if(this.navigationHandler){document.removeEventListener(ev.NAVIGATION_EVENT,this.navigationHandler,true)}if(this.modalCloseHandler){document.removeEventListener(v.MODAL_CLOSED,this.modalCloseHandler)}}}};var eF={name:"quizSubmission",component:ez};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/timer.ts
var eB={PROGRESS_ANIMATE:"tutor-quiz-progress-animate"};/**
 * Quiz Timer Component
 * Manages countdown timer for quiz attempts
 */var eH=e=>{var t=Math.max(0,e.duration);var r=typeof e.hasLimit==="boolean"?e.hasLimit:t>0;var i;var n=(i=e.expiresAction)!==null&&i!==void 0?i:"auto_submit";var o;return{total:t,remaining:t,hasLimit:r,expired:false,isReady:false,expiresAction:n,formId:(o=e.formId)!==null&&o!==void 0?o:"",timer:null,shakeTimer:null,shaking:false,totalQuestions:Number(e.totalQuestions)||0,$el:null,init(){if(!this.hasLimit){this.isReady=true;return}document.addEventListener(y.QUIZ_ATTEMPT_COMPLETED,e=>{var t;var r=(t=e===null||e===void 0?void 0:e.detail)!==null&&t!==void 0?t:{};if((r===null||r===void 0?void 0:r.formId)&&r.formId!==this.formId){return}this.stop()});if(this.remaining<=0){this.isReady=true;this.handleExpire();return}this.isReady=true;this.start()},start(){var e;this.stop();this.timer=window.setInterval(()=>{if(this.remaining>0){this.remaining--}else{this.handleExpire()}},1e3);this.startShakeInterval();(e=this.$el)===null||e===void 0?void 0:e.classList.add(eB.PROGRESS_ANIMATE)},stop(){if(this.timer){var e;clearInterval(this.timer);this.timer=null;(e=this.$el)===null||e===void 0?void 0:e.classList.remove(eB.PROGRESS_ANIMATE)}this.stopShakeInterval()},startShakeInterval(){this.stopShakeInterval();this.shakeTimer=window.setInterval(()=>{if(this.timerState==="critical"){this.shaking=true;window.setTimeout(()=>{this.shaking=false},500)}},2e3)},stopShakeInterval(){if(this.shakeTimer){clearInterval(this.shakeTimer);this.shakeTimer=null}this.shaking=false},normalizeExpireAction(e){if(e==="autosubmit"){return"auto_submit"}return e},dispatchQuizEvent(e){document.dispatchEvent(new CustomEvent(y.QUIZ_TIME_EXPIRED,{detail:{action:this.normalizeExpireAction(e),formId:this.formId}}))},requestAbandon(){document.dispatchEvent(new CustomEvent(y.QUIZ_ABANDON_REQUESTED,{detail:{formId:this.formId}}))},handleExpire(){if(this.expired){return}this.expired=true;this.remaining=0;this.stop();this.dispatchQuizEvent(this.expiresAction)},get minutes(){if(this.days>0||this.hours>0){return Math.floor(this.remaining%3600/60)}return Math.floor(this.remaining/60)},get hours(){if(this.days>0){return Math.floor(this.remaining%86400/3600)}return Math.floor(this.remaining/3600)},get days(){return Math.floor(this.remaining/86400)},get seconds(){return this.remaining%60},get timerFormat(){if(this.days>0){return"days"}if(this.hours>0){return"hours"}return"compact"},get displayTokens(){var a=[];var s=(e,t)=>{t.split("").forEach((t,r)=>{a.push({key:"".concat(e,"-").concat(r),type:"digit",value:t})})};if(this.timerFormat==="days"){s("days",String(this.days));a.push({key:"days-suffix",type:"suffix",value:"d"});a.push({key:"days-spacer",type:"spacer",value:" "})}if(this.timerFormat==="days"||this.timerFormat==="hours"){s("hours",String(this.hours).padStart(2,"0"));a.push({key:"hours-separator",type:"separator",value:":"})}s("minutes",String(this.minutes).padStart(2,"0"));a.push({key:"minutes-separator",type:"separator",value:":"});s("seconds",String(this.seconds).padStart(2,"0"));return a},get progress(){if(!this.total){return 0}return(this.total-this.remaining)/this.total*100},get timerState(){if(!this.total||!this.hasLimit){return"initial"}var l=this.remaining/this.total*100;if(l<=25){return"critical"}if(l<=50){return"warning"}return"initial"},get attemptedCount(){return eI(this.formId)},get attemptedProgress(){if(!this.totalQuestions){return 0}return this.attemptedCount/this.totalQuestions*100}}};var e$={name:"quizTimer",component:eH};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/quiz/index.ts
var eW=()=>{window.TutorComponentRegistry.registerAll({components:[e$,eQ,eM,eF,eg,ek,eO,et,ed]});window.TutorComponentRegistry.initWithAlpine(window.Alpine)};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/sidebar.ts
/**
 * Learning Area Sidebar logic
 *
 * @since 4.0.0
 */var eG=e=>{var{courseId:t,resetModalId:r}=e;var{query:i,modal:n,toast:o}=window.TutorCore;var{wpPost:a}=window.TutorCore.api;var{convertToErrorMessage:s}=window.TutorCore.error;var{endpoints:l}=window.TutorCore;return{pagesHeight:null,resizing:false,sidebarOpen:false,courseId:t,resetModalId:r,resetProgressMutation:null,$refs:{},$nextTick:{},init(){this.$nextTick(()=>{if(this.$refs.pagesList){this.pagesHeight=this.$refs.pagesList.scrollHeight}});this.resetProgressMutation=i.useMutation(e=>a(l.RESET_COURSE_PROGRESS,e),{onSuccess:e=>{var t;if(e.status_code===200&&((t=e.data)===null||t===void 0?void 0:t.redirect_to)){n.closeModal(this.resetModalId);window.location.href=e.data.redirect_to}},onError:e=>{var t;o.error(s(e));if((t=e.message)===null||t===void 0?void 0:t.includes("HTTP")){window.location.reload()}}})},toggleSidebar(){this.sidebarOpen=!this.sidebarOpen},closeSidebar(){this.sidebarOpen=false},startResizing(e){var t;this.resizing=true;var r=e.clientY;var i=((t=this.$refs.pagesList)===null||t===void 0?void 0:t.offsetHeight)||0;var n=e=>{var t=r-e.clientY;// Constraint height between 36px and 400px.
this.pagesHeight=Math.max(36,Math.min(400,i+t))};var o=()=>{this.resizing=false;window.removeEventListener("mousemove",n);window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",n);window.addEventListener("mouseup",o)},togglePagesHeight(){if((this.pagesHeight||0)>36){this.pagesHeight=36}else if(this.$refs.pagesList){this.pagesHeight=this.$refs.pagesList.scrollHeight}},confirmReset(){n.showModal(this.resetModalId)},resetProgress(){var e;(e=this.resetProgressMutation)===null||e===void 0?void 0:e.mutate({course_id:this.courseId,context:"learning-area-sidebar"})}}};var eV=()=>{if(window.TutorComponentRegistry){window.TutorComponentRegistry.register({type:"component",meta:{name:"learningSidebar",component:eG}})}};// CONCATENATED MODULE: ./assets/src/js/frontend/learning-area/index.ts
// Learning Area Entry Point
// Initializes learning area functionality based on current page
var ej=()=>{M();C();eV();O();_();var{pathname:e,search:t}=window.location;// Normalize path segments
var r=e.split("/").filter(Boolean);var{tutorConfig:i}=window.TutorCore.config;var{lesson_slug:n="lessons",quiz_slug:o="quizzes"}=i||{};var a=null;if(r.includes(n)){a="lesson"}else if(r.includes(o)){a="quiz"}else{// fallback to query param (older behavior)
var s=new URLSearchParams(t);a=s.get("subpage")}switch(a){case"quiz":eW();break;case"lesson":G();break;case"qna":J();break;case"course-info":V();break;default:// eslint-disable-next-line no-console
console.warn("Unknown learning area page:",a)}// Ensure all registered components are initialized with Alpine.
if(window.TutorComponentRegistry){window.TutorComponentRegistry.initWithAlpine(window.Alpine)}};if(document.readyState==="loading"){document.addEventListener("alpine:init",ej)}else{ej()}})();