LearnPress – WordPress LMS Plugin - Version 4.1.7.2

Version Description

(2022-10-03) = ~ Removed: delete file mu-plugin (Moved to the plugin Thim Optimize). ~ Fixed: CVE-2022-3360 security. ~ Fixed: error "Quiz is not auto submitted when the time is expired". ~ Fixed: error "Completed item is not redirected to the next item". ~ Modified: Shortcode button LP. ~ Removed: delete shortcode 'learn_press_button_enroll'. We recommend using the shortcode 'learn_press_button_course' instead. ~ Fixed: error "Email content on one line when you save".

Download this release

Release Info

Developer ThimPress
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 4.1.7.2
Comparing to
See all releases

Code changes from version 4.1.7.1 to 4.1.7.2

Files changed (83) hide show
  1. assets/js/admin/admin.min.js +1 -1
  2. assets/js/dist/frontend/courses.min.js +1 -1
  3. assets/js/dist/frontend/quiz.js +3 -9
  4. assets/js/dist/frontend/quiz.min.js +1 -1
  5. assets/js/vendor/plugins.all.js +1 -359
  6. assets/js/vendor/vue/vue_libs.js +1 -14524
  7. assets/src/apps/js/frontend/quiz/components/timer/index.js +1 -10
  8. assets/src/js/admin/admin.js +19 -11
  9. inc/admin/class-lp-install-sample-data.php +8 -11
  10. inc/admin/class-lp-setup-wizard.php +1 -1
  11. inc/admin/lp-admin-functions.php +1 -1
  12. inc/admin/meta-box/class-lp-meta-box-helper.php +5 -5
  13. inc/admin/meta-box/fields/email-content.php +2 -2
  14. inc/admin/views/updates/html-updated-latest-message.php +1 -1
  15. inc/cart/class-lp-cart.php +54 -38
  16. inc/cart/lp-cart-functions.php +8 -8
  17. inc/class-lp-ajax.php +32 -168
  18. inc/class-lp-assets.php +1 -1
  19. inc/class-lp-checkout.php +8 -8
  20. inc/class-lp-file-system.php +1 -21
  21. inc/class-lp-helper.php +7 -1
  22. inc/class-lp-page-controller.php +55 -38
  23. inc/class-lp-query.php +1 -1
  24. inc/class-lp-request-handler.php +25 -0
  25. inc/class-lp-shortcodes.php +1 -11
  26. inc/class-lp-thumbnail-helper.php +1 -1
  27. inc/class-lp-widget.php +1 -4
  28. inc/course/abstract-course.php +6 -67
  29. inc/course/class-lp-course-item.php +7 -176
  30. inc/course/lp-course-functions.php +2 -1
  31. inc/curds/class-lp-user-curd.php +3 -2
  32. inc/custom-post-types/abstract.php +1 -1
  33. inc/databases/class-lp-course-db.php +2 -2
  34. inc/databases/class-lp-user-items-db.php +0 -1
  35. inc/emails/class-lp-email.php +1 -30
  36. inc/external-plugin/elementor/widgets/list-courses.php +1 -1
  37. inc/external-plugin/elementor/widgets/login-form.php +1 -1
  38. inc/external-plugin/elementor/widgets/register-form.php +1 -1
  39. inc/gateways/class-lp-gateways.php +1 -1
  40. inc/gateways/offline-payment/class-lp-gateway-offline-payment.php +1 -1
  41. inc/gateways/paypal/class-lp-gateway-paypal.php +3 -3
  42. inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php +9 -9
  43. inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php +1 -1
  44. inc/lp-core-functions.php +106 -595
  45. inc/lp-deprecated.php +10 -10
  46. inc/lp-template-functions.php +29 -37
  47. inc/lp-template-hooks.php +110 -113
  48. inc/order/class-lp-order.php +2 -2
  49. inc/order/lp-order-functions.php +1 -1
  50. inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php +9 -9
  51. inc/rest-api/v1/frontend/class-lp-rest-widgets-controller.php +2 -9
  52. inc/shortcodes/class-lp-shortcode-button-course.php +34 -13
  53. inc/shortcodes/class-lp-shortcode-button-purchase.php +7 -21
  54. inc/shortcodes/class-lp-shortcode-checkout.php +2 -2
  55. inc/templates/abstract-template.php +2 -2
  56. inc/templates/class-lp-template-checkout.php +3 -3
  57. inc/templates/class-lp-template-course.php +72 -175
  58. inc/user-item/class-lp-user-item-course.php +2 -0
  59. inc/user-item/class-lp-user-item-quiz.php +0 -13
  60. inc/user-item/class-lp-user-item.php +0 -83
  61. inc/user/abstract-lp-user.php +24 -701
  62. inc/user/class-lp-profile-tabs.php +6 -1
  63. inc/user/class-lp-profile.php +1 -1
  64. inc/user/lp-user-functions.php +19 -117
  65. inc/widgets/course-extra.php +3 -3
  66. languages/learnpress.pot +557 -573
  67. learnpress.php +7 -33
  68. mu-plugin/class-lp-mu-plugin.php +13 -4
  69. readme.txt +10 -1
  70. templates/archive-course.php +3 -3
  71. templates/checkout/account-login.php +1 -1
  72. templates/checkout/account-register.php +1 -1
  73. templates/checkout/empty-cart.php +1 -1
  74. templates/checkout/form.php +1 -1
  75. templates/checkout/guest-checkout-link.php +1 -1
  76. templates/checkout/guest-checkout.php +5 -5
  77. templates/checkout/payment.php +1 -1
  78. templates/shortcode/list-courses.php +2 -2
  79. templates/single-course/buttons/purchase.php +1 -1
  80. templates/single-course/content-item/popup-content.php +2 -2
  81. templates/single-course/content-item/popup-sidebar.php +1 -1
  82. templates/single-course/meta-primary.php +2 -2
  83. templates/{single-course/meta-secondary.php → single-cour} +0 -0
assets/js/admin/admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){const t=function(){e.ajax({url:"",data:{"lp-ajax":"toggle_item_preview",item_id:this.value,previewable:this.checked?"yes":"no",nonce:e(this).attr("data-nonce")},dataType:"text",success:function(e){e=LP.parseJSON(e)}})},a=function(t){const a=e(this).addClass("disabled");t.preventDefault(),e.post({url:a.attr("href"),data:{"lp-ajax":"create-pages"},dataType:"text",success:function(e){const t=a.closest(".lp-notice").html("<p>"+e+"</p>");setTimeout((function(){t.fadeOut()}),2e3)}})},n=function(t){t.preventDefault();e(this).closest(".lp-upgrade-notice").fadeOut(),e.post({url:"",data:{"lp-hide-upgrade-message":"yes"},success:function(e){}})},o=function(t){if(e(t.target).hasClass("buy-now"))return;t.preventDefault();const a=e(this).closest(".plugin-card");e(this).hasClass("updating-message")||(e(this).addClass("updating-message button-working disabled"),e.ajax({url:e(this).attr("href"),data:{},success:function(t){e.ajax({url:window.location.href,success:function(t){const n=e(t).find("#"+a.attr("id"));n.length?a.replaceWith(n):a.find(".plugin-action-buttons a").removeClass("updating-message button-working").html(learn_press_admin_localize.plugin_installed)}})}}))},l=function(e){return e.preventDefault(),!1};e.fn._filter_post_by_author=function(){const t=e("#post-search-input");if(!t.length)return;const a=e(t[0].form),n=e('<select name="author" id="author"></select>').insertAfter(t).select2({ajax:{url:window.location.href+"&lp-ajax=search-authors",dataType:"json",s:""},placeholder:wp.i18n.__("Search by user","learnpress"),minimumInputLength:3,allowClear:!0}).on("select2:select",(function(){e('input[name="author"]').val(n.val())}));a.on("submit",(function(){window.location.href.removeQueryVar("author").addQueryVar("author",n.val())}))};const s=()=>{e(".lp-button-upgrade").each((function(){e(this).on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").removeClass("lp-update-db-modal__hidden")}))})),e(".lp-update-db-modal__button").on("click",(function(t){t.preventDefault();const a=e(this),n=a.text(),o=a.data("loading"),l=e(".lp-update-db-modal__content-text").data("text");a.addClass("loading"),a.text(o);const s=()=>{e.ajax({url:lpGlobalSettings.ajax+"?action=lp_update_database",method:"GET",success(t){if("success"===t.status)return a.text(n),e(".lp-update-db-modal__content").addClass("lp-update-db-modal__success"),e(".lp-update-db-modal__content-text > h3").text(l),a.removeClass("loading"),!1;s()}})};s()}));e(".lp-update-db-modal__cancel").on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").addClass("lp-update-db-modal__hidden")}))},i=()=>{e(".lp-meta-box__file").each((t,a)=>{let n;const o=e(a).find(".lp-meta-box__file_input"),l=e(a).find(".lp-meta-box__file_list"),s=e(a).find(".btn-upload"),i=!!e(a).data("multil");e(s).on("click",e=>{e.preventDefault(),n||(n=wp.media({states:[new wp.media.controller.Library({filterable:"all",multiple:i})]}),n.on("select",(function(){const e=n.state().get("selection");let t=o.val();e.forEach((function(e){if((e=e.toJSON()).id)if(i?t=t?t+","+e.id:e.id:(t=e.id,l.empty()),"image"===e.type){const t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img src="'+t+'" /><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')}else l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img class="is_file" src="'+e.icon+'" /><span>'+e.filename+'</span><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')})),c(),o.val(t)}))),n.open()}),i&&l.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"lp-metabox-sortable-placeholder",start(e,t){t.item.css("background-color","#f6f6f6")},stop(e,t){t.item.removeAttr("style")},update(){let t="";l.find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),c(),o.val(t)}});const c=()=>{e(l).find("li.image").each((t,a)=>{e(a).find("a.delete").on("click",(function(){if(e(a).remove(),i){let t="";e(l).find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),o.val(t)}else o.val("");return!1}))})};c()})};e(document).ready((function(){if(i(),s(),e(".learn-press-dropdown-pages").LP("DropdownPages"),e(".learn-press-advertisement-slider").LP("Advertisement","a","s").appendTo(e("#wpbody-content")),e(".learn-press-toggle-item-preview").on("change",t),e(".learn-press-tip").LP("QuickTip"),e(document).on("click","#learn-press-create-pages",a).on("click",".lp-upgrade-notice .close-notice",n).on("click",".plugin-action-buttons a",o).on("click","[data-remove-confirm]",l).on("mousedown",".lp-sortable-handle",(function(t){e("html, body").addClass("lp-item-moving"),e(t.target).closest(".lp-sortable-handle").css("cursor","inherit")})).on("mouseup",(function(t){e("html, body").removeClass("lp-item-moving"),e(".lp-sortable-handle").css("cursor","")})),e("#order-export__section").length){document.querySelectorAll(".tabs");const t=document.querySelectorAll(".tab"),a=document.querySelectorAll(".panel");function c(e){for(let e=0;e<t.length;e++)t[e].classList.remove("active");for(let e=0;e<a.length;e++)a[e].classList.remove("active");e.target.classList.add("active");const n=e.target.getAttribute("data-target");document.getElementById("panels").getElementsByClassName(n)[0].classList.add("active")}for(let e=0;e<t.length;e++)t[e].addEventListener("click",c,!1);const n=document.getElementById("myModal"),o=document.getElementById("order-export__button"),l=document.getElementsByClassName("close")[0];o.onclick=function(){n.style.display="block"},l.onclick=function(){n.style.display="none"},window.onclick=function(e){e.target==n&&(n.style.display="none")},e("#lp-invoice__content").length&&e("#lp-invoice__export").click((function(){const t=new jsPDF("p","pt","letter"),a={"#bypassme":(e,t)=>!0},n={top:80,bottom:60,left:40,width:522};t.fromHTML(e("#lp-invoice__content")[0],n.left,n.top,{width:n.width,elementHandlers:a},(function(e){const a=t.output("blob");window.open(URL.createObjectURL(a))}),n)})),e("#lp-invoice__update").click((function(){let t=e(this).data("id"),a=e('input[name="site_title"]'),n=e('input[name="order_date"]'),o=e('input[name="invoice_no"]'),l=e('input[name="order_customer"]'),s=e('input[name="order_email"]'),i=e('input[name="order_payment"]');a=a.is(":checked")?"check":"uncheck",n=n.is(":checked")?"check":"uncheck",o=o.is(":checked")?"check":"uncheck",l=l.is(":checked")?"check":"uncheck",s=s.is(":checked")?"check":"uncheck",i=i.is(":checked")?"check":"uncheck",e.ajax({type:"post",dataType:"html",url:"admin-ajax.php",data:{site_title:a,order_date:n,invoice_no:o,order_customer:l,order_email:s,order_id:t,order_payment:i,action:"learnpress_update_order_exports"},beforeSend(){e(".export-options__loading").addClass("active")},success(t){e("#lp-invoice__content").html(""),e("#lp-invoice__content").append(t),e(".export-options__loading").removeClass("active"),e(".options-tab").removeClass("active"),e(".preview-tab").addClass("active"),e("#panels .export-options").removeClass("active"),e("#panels .pdf-preview").addClass("active")},error(e,t,a){console.log("The following error occured: "+t,a)}})}))}if(e.fn._filter_post_by_author(),window.location.hash){const t=window.location.hash;if("#_lp_passing_grade"==t){const a=document.querySelector(t);e("html, body").animate({scrollTop:e(t).offset().top},900,"swing"),a.parentNode.style.border="2px solid orangered"}}e("input").on("click",(function(t){const a=e(t.target),n=a.attr("id").replace("learn_press_",""),o=e(".show_if_"+n);a.is(":checked")?o.show():o.hide()}))}))}(jQuery);
1
+ !function(e){const t=function(){e.ajax({url:"",data:{"lp-ajax":"toggle_item_preview",item_id:this.value,previewable:this.checked?"yes":"no",nonce:e(this).attr("data-nonce")},dataType:"text",success:function(e){e=LP.parseJSON(e)}})},a=function(t){const a=e(this).addClass("disabled");t.preventDefault(),e.post({url:a.attr("href"),data:{"lp-ajax":"create-pages"},dataType:"text",success:function(e){const t=a.closest(".lp-notice").html("<p>"+e+"</p>");setTimeout((function(){t.fadeOut()}),2e3)}})},n=function(t){t.preventDefault();e(this).closest(".lp-upgrade-notice").fadeOut(),e.post({url:"",data:{"lp-hide-upgrade-message":"yes"},success:function(e){}})},o=function(t){if(e(t.target).hasClass("buy-now"))return;t.preventDefault();const a=e(this).closest(".plugin-card");e(this).hasClass("updating-message")||(e(this).addClass("updating-message button-working disabled"),e.ajax({url:e(this).attr("href"),data:{},success:function(t){e.ajax({url:window.location.href,success:function(t){const n=e(t).find("#"+a.attr("id"));n.length?a.replaceWith(n):a.find(".plugin-action-buttons a").removeClass("updating-message button-working").html(learn_press_admin_localize.plugin_installed)}})}}))},l=function(e){return e.preventDefault(),!1};e.fn._filter_post_by_author=function(){const t=e("#post-search-input");if(!t.length)return;const a=e(t[0].form),n=e('<select name="author" id="author"></select>').insertAfter(t).select2({ajax:{url:window.location.href+"&lp-ajax=search-authors",dataType:"json",s:""},placeholder:wp.i18n.__("Search by user","learnpress"),minimumInputLength:3,allowClear:!0}).on("select2:select",(function(){e('input[name="author"]').val(n.val())}));a.on("submit",(function(){window.location.href.removeQueryVar("author").addQueryVar("author",n.val())}))};const s=()=>{e(".lp-button-upgrade").each((function(){e(this).on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").removeClass("lp-update-db-modal__hidden")}))})),e(".lp-update-db-modal__button").on("click",(function(t){t.preventDefault();const a=e(this),n=a.text(),o=a.data("loading"),l=e(".lp-update-db-modal__content-text").data("text");a.addClass("loading"),a.text(o);const s=()=>{e.ajax({url:lpGlobalSettings.ajax+"?action=lp_update_database",method:"GET",success(t){if("success"===t.status)return a.text(n),e(".lp-update-db-modal__content").addClass("lp-update-db-modal__success"),e(".lp-update-db-modal__content-text > h3").text(l),a.removeClass("loading"),!1;s()}})};s()}));e(".lp-update-db-modal__cancel").on("click",(function(t){t.preventDefault(),e("#lp-update-db-modal").addClass("lp-update-db-modal__hidden")}))},i=()=>{e(".lp-meta-box__file").each((t,a)=>{let n;const o=e(a).find(".lp-meta-box__file_input"),l=e(a).find(".lp-meta-box__file_list"),s=e(a).find(".btn-upload"),i=!!e(a).data("multil");e(s).on("click",e=>{e.preventDefault(),n||(n=wp.media({states:[new wp.media.controller.Library({filterable:"all",multiple:i})]}),n.on("select",(function(){const e=n.state().get("selection");let t=o.val();e.forEach((function(e){if((e=e.toJSON()).id)if(i?t=t?t+","+e.id:e.id:(t=e.id,l.empty()),"image"===e.type){const t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img src="'+t+'" /><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')}else l.append('<li class="lp-meta-box__file_list-item image" data-attachment_id="'+e.id+'"><img class="is_file" src="'+e.icon+'" /><span>'+e.filename+'</span><ul class="actions"><li><a href="#" class="delete"></a></li></ul></li>')})),c(),o.val(t)}))),n.open()}),i&&l.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"lp-metabox-sortable-placeholder",start(e,t){t.item.css("background-color","#f6f6f6")},stop(e,t){t.item.removeAttr("style")},update(){let t="";l.find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),c(),o.val(t)}});const c=()=>{e(l).find("li.image").each((t,a)=>{e(a).find("a.delete").on("click",(function(){if(e(a).remove(),i){let t="";e(l).find("li.image").css("cursor","default").each((function(){const a=e(this).attr("data-attachment_id");t=t+a+","})),o.val(t)}else o.val("");return!1}))})};c()})};e(document).ready((function(){if(i(),s(),e(".learn-press-dropdown-pages").LP("DropdownPages"),e(".learn-press-advertisement-slider").LP("Advertisement","a","s").appendTo(e("#wpbody-content")),e(".learn-press-toggle-item-preview").on("change",t),e(".learn-press-tip").LP("QuickTip"),e(document).on("click","#learn-press-create-pages",a).on("click",".lp-upgrade-notice .close-notice",n).on("click",".plugin-action-buttons a",o).on("click","[data-remove-confirm]",l).on("mousedown",".lp-sortable-handle",(function(t){e("html, body").addClass("lp-item-moving"),e(t.target).closest(".lp-sortable-handle").css("cursor","inherit")})).on("mouseup",(function(t){e("html, body").removeClass("lp-item-moving"),e(".lp-sortable-handle").css("cursor","")})),e("#order-export__section").length){document.querySelectorAll(".tabs");const t=document.querySelectorAll(".tab"),a=document.querySelectorAll(".panel");function c(e){for(let e=0;e<t.length;e++)t[e].classList.remove("active");for(let e=0;e<a.length;e++)a[e].classList.remove("active");e.target.classList.add("active");const n=e.target.getAttribute("data-target");document.getElementById("panels").getElementsByClassName(n)[0].classList.add("active")}for(let e=0;e<t.length;e++)t[e].addEventListener("click",c,!1);const n=document.getElementById("myModal"),o=document.getElementById("order-export__button"),l=document.getElementsByClassName("close")[0];o.onclick=function(){n.style.display="block"},l.onclick=function(){n.style.display="none"},window.onclick=function(e){e.target==n&&(n.style.display="none")},e("#lp-invoice__content").length&&e("#lp-invoice__export").click((function(){const t=new jsPDF("p","pt","letter"),a={"#bypassme":(e,t)=>!0},n={top:80,bottom:60,left:40,width:522};t.fromHTML(e("#lp-invoice__content")[0],n.left,n.top,{width:n.width,elementHandlers:a},(function(e){const a=t.output("blob");window.open(URL.createObjectURL(a))}),n)})),e("#lp-invoice__update").click((function(){let t=e(this).data("id"),a=e('input[name="site_title"]'),n=e('input[name="order_date"]'),o=e('input[name="invoice_no"]'),l=e('input[name="order_customer"]'),s=e('input[name="order_email"]'),i=e('input[name="order_payment"]');a=a.is(":checked")?"check":"uncheck",n=n.is(":checked")?"check":"uncheck",o=o.is(":checked")?"check":"uncheck",l=l.is(":checked")?"check":"uncheck",s=s.is(":checked")?"check":"uncheck",i=i.is(":checked")?"check":"uncheck",e.ajax({type:"post",dataType:"html",url:"admin-ajax.php",data:{site_title:a,order_date:n,invoice_no:o,order_customer:l,order_email:s,order_id:t,order_payment:i,action:"learnpress_update_order_exports"},beforeSend(){e(".export-options__loading").addClass("active")},success(t){e("#lp-invoice__content").html(""),e("#lp-invoice__content").append(t),e(".export-options__loading").removeClass("active"),e(".options-tab").removeClass("active"),e(".preview-tab").addClass("active"),e("#panels .export-options").removeClass("active"),e("#panels .pdf-preview").addClass("active")},error(e,t,a){console.log("The following error occured: "+t,a)}})}))}if(e.fn._filter_post_by_author(),window.location.hash){const t=window.location.hash;if("#_lp_passing_grade"==t){const a=document.querySelector(t);e("html, body").animate({scrollTop:e(t).offset().top},900,"swing"),a.parentNode.style.border="2px solid orangered"}}e("input").on("click",(function(t){const a=e(t.target);if(!a.length)return;const n=a.attr("id");if(!n)return;const o=n.replace("learn_press_",""),l=e(".show_if_"+o);a.is(":checked")?l.show():l.hide()}))}))}(jQuery);
assets/js/dist/frontend/courses.min.js CHANGED
@@ -1 +1 @@
1
- !function(){lpGlobalSettings.courses_url;const e=document.location.href;let t,r,o=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{},s=!1,n=1,c=null,l=null;lpGlobalSettings.is_course_archive&&(window.location.search.length||-1!==e.search("page")||(o={}));const a=(e,t)=>{const r=new URL(e);return Object.keys(t).forEach((e=>{r.searchParams.set(e,t[e])})),r};window.lpArchiveRequestCourse=(e,o)=>{const c=lpGlobalSettings.lp_rest_url;if(!c)return;if(!t)return;const u=l&&l.querySelector("div.lp-archive-courses .lp-content-area"),p=u&&u.querySelector("ul.learn-press-courses");if(!p)return;if(s)return;s=!0,r?p.append(t):r=t.outerHTML;const h=a(c+"lp/v1/courses/archive-course",{...lpGlobalSettings.lpArchiveSkeleton,...e}),d=lpGlobalSettings.lp_rest_url+"lp/v1/courses/archive-course"+h.search;fetch(d,{method:"GET"}).then((e=>e.json())).then((e=>{void 0!==e.data.content&&p&&(p.innerHTML=e.data.content||"");const t=e.data.pagination,r=document.querySelector(".learn-press-pagination");if(r&&r.remove(),void 0!==t){const e=(new DOMParser).parseFromString(t,"text/html").querySelector(".learn-press-pagination");e&&(p.after(e),i())}wp.hooks.doAction("lp-js-get-courses",e),"function"==typeof o&&o(e)})).catch((e=>{p.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/courses/archive-course"}</div>`,console.log(e)})).finally((()=>{if(s=!1,jQuery("form.search-courses button").removeClass("loading"),n)n=0;else{const e={behavior:"smooth"};l.scrollIntoView(e)}window.localStorage.setItem("lp_filter_courses",JSON.stringify(e));const t=a(document.location,e);window.history.pushState("","",t)}))};const i=()=>{const e=document.querySelectorAll(".lp-archive-courses .learn-press-pagination .page-numbers");e.length>0&&e.forEach((r=>r.addEventListener("click",(o=>{if(o.preventDefault(),o.stopPropagation(),!l)return;t&&(t.style.display="block"),l.scrollIntoView({behavior:"smooth"});let s={};if(s=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{},o.currentTarget.getAttribute("href")){const t=[...e].filter((e=>e.classList.contains("current"))),n=o.currentTarget.textContent||r.classList.contains("next")&&parseInt(t[0].textContent)+1||r.classList.contains("prev")&&parseInt(t[0].textContent)-1;s.paged=n,lpArchiveRequestCourse({...s})}}))))};function u(){t=document.querySelector(".lp-archive-course-skeleton"),c=document.querySelector(".no-first-load-ajax"),t&&(c?(i(),(()=>{const e=document.querySelectorAll("form.search-courses"),r=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};e.forEach((e=>{const o=e.querySelector('input[name="c_search"]'),s=e.querySelector('[type="submit"]');let n;o.addEventListener("keyup",(e=>{t&&(t.style.display="block"),e.preventDefault();const o=e.target.value.trim();(!o||o&&o.length>2)&&(void 0!==n&&clearTimeout(n),n=setTimeout((function(){s.classList.add("loading"),r.c_search=o,r.paged=1,lpArchiveRequestCourse({...r})}),800))})),e.addEventListener("submit",(t=>{t.preventDefault();const r=e.querySelector('input[name="c_search"]');r&&r.dispatchEvent(new Event("keyup"))}))}))})()):lpArchiveRequestCourse(o)),(()=>{const e=document.querySelectorAll('.lp-archive-courses input[name="lp-switch-layout-btn"]');e.length>0&&e.forEach((e=>e.addEventListener("change",(e=>{e.preventDefault();const t=e.target.value;if(t){const e=document.querySelector(".lp-archive-courses .learn-press-courses[data-layout]");e&&(e.dataset.layout=t),LP.Cookies.set("courses-layout",t)}}))))})(),(()=>{const e=LP.Cookies.get("courses-layout"),t=document.querySelectorAll('.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]');t.length>0&&[...t].map((t=>t.value===e&&(t.checked=!0)))})()}const p=setInterval((function(){void 0!==lpGlobalSettings.lpArchiveSkeleton&&(t=document.querySelector(".lp-archive-course-skeleton"),l=document.querySelector(".lp-archive-courses"),l&&t&&(u(),clearInterval(p)))}),1)}();
1
+ !function(){lpGlobalSettings.courses_url;const e=document.location.href;let t,r,o,s,n=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{},c=!1,l=1;lpGlobalSettings.is_course_archive&&(window.location.search.length||-1!==e.search("page")||(n={}));const a=(e,t)=>{const r=new URL(e);return Object.keys(t).forEach((e=>{r.searchParams.set(e,t[e])})),r};window.lpArchiveRequestCourse=(e,o)=>{const n=lpGlobalSettings.lp_rest_url;if(!n)return;if(!t)return;const u=s&&s.querySelector("div.lp-archive-courses .lp-content-area"),p=u&&u.querySelector("ul.learn-press-courses");if(!p)return;if(c)return;c=!0,r?p.append(t):r=t.outerHTML;const h=a(n+"lp/v1/courses/archive-course",{...lpGlobalSettings.lpArchiveSkeleton,...e}),d=lpGlobalSettings.lp_rest_url+"lp/v1/courses/archive-course"+h.search;fetch(d,{method:"GET"}).then((e=>e.json())).then((e=>{void 0!==e.data.content&&p&&(p.innerHTML=e.data.content||"");const t=e.data.pagination,r=document.querySelector(".learn-press-pagination");if(r&&r.remove(),void 0!==t){const e=(new DOMParser).parseFromString(t,"text/html").querySelector(".learn-press-pagination");e&&(p.after(e),i())}wp.hooks.doAction("lp-js-get-courses",e),"function"==typeof o&&o(e)})).catch((e=>{p.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/courses/archive-course"}</div>`,console.log(e)})).finally((()=>{if(c=!1,jQuery("form.search-courses button").removeClass("loading"),l)l=0;else{const e={behavior:"smooth"};s.scrollIntoView(e)}window.localStorage.setItem("lp_filter_courses",JSON.stringify(e));const t=a(document.location,e);window.history.pushState("","",t)}))};const i=()=>{const e=document.querySelectorAll(".lp-archive-courses .learn-press-pagination .page-numbers");e.length>0&&e.forEach((r=>r.addEventListener("click",(o=>{if(o.preventDefault(),o.stopPropagation(),!s)return;t&&(t.style.display="block"),s.scrollIntoView({behavior:"smooth"});let n={};if(n=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{},o.currentTarget.getAttribute("href")){const t=[...e].filter((e=>e.classList.contains("current"))),s=o.currentTarget.textContent||r.classList.contains("next")&&parseInt(t[0].textContent)+1||r.classList.contains("prev")&&parseInt(t[0].textContent)-1;n.paged=s,lpArchiveRequestCourse({...n})}}))))};function u(){t=document.querySelector(".lp-archive-course-skeleton"),o=document.querySelector(".no-first-load-ajax"),t&&(o||lpArchiveRequestCourse(n),i(),(()=>{const e=document.querySelectorAll("form.search-courses"),r=JSON.parse(window.localStorage.getItem("lp_filter_courses"))||{};e.forEach((e=>{const o=e.querySelector('input[name="c_search"]'),s=e.querySelector('[type="submit"]');let n;o.addEventListener("keyup",(e=>{t&&(t.style.display="block"),e.preventDefault();const o=e.target.value.trim();(!o||o&&o.length>2)&&(void 0!==n&&clearTimeout(n),n=setTimeout((function(){s.classList.add("loading"),r.c_search=o,r.paged=1,lpArchiveRequestCourse({...r})}),800))})),e.addEventListener("submit",(t=>{t.preventDefault();const r=e.querySelector('input[name="c_search"]');r&&r.dispatchEvent(new Event("keyup"))}))}))})()),(()=>{const e=document.querySelectorAll('.lp-archive-courses input[name="lp-switch-layout-btn"]');e.length>0&&e.forEach((e=>e.addEventListener("change",(e=>{e.preventDefault();const t=e.target.value;if(t){const e=document.querySelector(".lp-archive-courses .learn-press-courses[data-layout]");e&&(e.dataset.layout=t),LP.Cookies.set("courses-layout",t)}}))))})(),(()=>{const e=LP.Cookies.get("courses-layout"),t=document.querySelectorAll('.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]');t.length>0&&[...t].map((t=>t.value===e&&(t.checked=!0)))})()}const p=setInterval((function(){void 0!==lpGlobalSettings.lpArchiveSkeleton&&(t=document.querySelector(".lp-archive-course-skeleton"),s=document.querySelector(".lp-archive-courses"),s&&t&&(u(),clearInterval(p)))}),1)}();
assets/js/dist/frontend/quiz.js CHANGED
@@ -1907,18 +1907,12 @@ const Timer = () => {
1907
  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('learnpress/quiz');
1908
  const totalTime = getData('totalTime');
1909
  const durationTime = getData('duration');
1910
- /* const endTime = getData( 'endTime' );
1911
- const d1 = new Date( endTime.replace( /-/g, '/' ) );
1912
- const d2 = new Date();
1913
- const tz = new Date().getTimezoneOffset();
1914
- const t = parseInt( ( d1.getTime() / 1000 ) - ( ( d2.getTime() / 1000 ) + ( tz * 60 ) ) );*/
1915
-
1916
  const [seconds, setSeconds] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(totalTime);
1917
- let [timeSpend, setTimeSpend] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
1918
- const limitTime = totalTime > 0;
1919
  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1920
  const myInterval = setInterval(() => {
1921
- if (limitTime) {
1922
  let remainSeconds = seconds;
1923
  remainSeconds -= 1;
1924
 
1907
  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('learnpress/quiz');
1908
  const totalTime = getData('totalTime');
1909
  const durationTime = getData('duration');
 
 
 
 
 
 
1910
  const [seconds, setSeconds] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(totalTime);
1911
+ let [timeSpend, setTimeSpend] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); //const limitTime = totalTime > 0;
1912
+
1913
  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1914
  const myInterval = setInterval(() => {
1915
+ if (durationTime > 0) {
1916
  let remainSeconds = seconds;
1917
  remainSeconds -= 1;
1918
 
assets/js/dist/frontend/quiz.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var e={605:function(){LP.Hook.addAction("lp-compatible-builder",(()=>{LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(()=>(LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0))),LP.Hook.addAction("lp-question-compatible-builder",(()=>(LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0)))},184:function(e,t){var s;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var i=typeof s;if("string"===i||"number"===i)e.push(s);else if(Array.isArray(s)){if(s.length){var o=r.apply(null,s);o&&e.push(o)}}else if("object"===i)if(s.toString===Object.prototype.toString)for(var a in s)n.call(s,a)&&s[a]&&e.push(a);else e.push(s.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(s=function(){return r}.apply(t,[]))||(e.exports=s)}()},965:function(e){"use strict";function t(e,s){var n;if(Array.isArray(s))for(n=0;n<s.length;n++)t(e,s[n]);else for(n in s)e[n]=(e[n]||[]).concat(s[n])}e.exports=function(e){var s,n={};return t(n,e),(s=function(e){return function(t){return function(s){var r,i,o=n[s.type],a=t(s);if(o)for(r=0;r<o.length;r++)(i=o[r](s,e))&&e.dispatch(i);return a}}}).effects=n,s}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,s),i.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){"use strict";s.r(n),s.d(n,{default:function(){return tt},init:function(){return st}});var e={};s.r(e),s.d(e,{__requestBeforeStartQuiz:function(){return ge},__requestCheckAnswerSuccess:function(){return ze},__requestShowHintSuccess:function(){return ye},__requestStartQuizSuccess:function(){return fe},__requestSubmitQuiz:function(){return qe},__requestSubmitQuizSuccess:function(){return we},checkAnswer:function(){return be},markQuestionRendered:function(){return ke},sendKey:function(){return Qe},setCurrentPage:function(){return he},setCurrentQuestion:function(){return me},setQuizData:function(){return pe},setQuizMode:function(){return Pe},showHint:function(){return Ee},startQuiz:function(){return _e},submitQuiz:function(){return ve},updateUserQuestionAnswers:function(){return Se}});var t={};s.r(t),s.d(t,{getCurrentQuestion:function(){return Fe},getData:function(){return xe},getDefaultRestArgs:function(){return De},getItemStatus:function(){return Ae},getProp:function(){return Te},getQuestion:function(){return Ue},getQuestionAnswered:function(){return Me},getQuestionMark:function(){return He},getQuestionOptions:function(){return Ce},getQuestions:function(){return Le},getQuestionsSelectedAnswers:function(){return Be},getQuizAnswered:function(){return Oe},getQuizAttempts:function(){return Re},getUserMark:function(){return Je},isCheckedAnswer:function(){return $e},isCorrect:function(){return je}});var r=window.wp.element;function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var o=window.wp.compose,a=window.wp.data,u=window.wp.i18n,l=e=>{let t;const s=86400;if(e>s)t=(e-e%s)/s,e%=s;else if(e==s)return"24:00";const n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")};const{Hook:c}=LP;var d=()=>{const e=e=>(0,a.select)("learnpress/quiz").getData(e),t=c.applyFilters("quiz-meta-fields",{duration:{title:(0,u.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:(0,u.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:(0,u.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("ul",{className:"quiz-intro"},Object.values(t).map(((e,t)=>{const s=e.name||t;return(0,r.createElement)("li",{key:`quiz-intro-field-${t}`,className:`quiz-intro-item quiz-intro-item--${s}`},(0,r.createElement)("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),(0,r.createElement)("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};class p extends r.Component{constructor(){super(...arguments),i(this,"startQuiz",(e=>{e&&e.preventDefault();const t=document.querySelector(".lp-button.start");t&&t.setAttribute("disabled","disabled"),t.classList.add("loading");const{startQuiz:s,status:n}=this.props;if("completed"===n){const{confirm:e,isOpen:s}=(0,a.select)("learnpress/modal");if("no"===e((0,u.__)("Are you sure you want to retake quiz?","learnpress"),this.startQuiz))return void(!s()&&t&&t.removeAttribute("disabled"))}s()})),i(this,"nav",(e=>t=>{let{questionNav:s,currentPage:n,numPages:r,setCurrentPage:i}=this.props;"prev"===e?n>1?n-=1:n="infinity"===s?r:1:n<r?n+=1:n="infinity"===s?1:r,i(n)})),i(this,"moveTo",(e=>t=>{t.preventDefault();const{numPages:s,setCurrentPage:n}=this.props;e<1||e>s||n(e)})),i(this,"isLast",(()=>{const{currentPage:e,numPages:t}=this.props;return e===t})),i(this,"isFirst",(()=>{const{currentPage:e}=this.props;return 1===e})),i(this,"submit",(()=>{const{submitQuiz:e}=this.props,{confirm:t}=(0,a.select)("learnpress/modal");"no"!==t((0,u.__)("Are you sure to submit quiz?","learnpress"),this.submit)&&e()})),i(this,"setQuizMode",(e=>()=>{const{setQuizMode:t}=this.props;t(e)})),i(this,"isReviewing",(()=>{const{isReviewing:e}=this.props;return e}))}pageNumbers(e){const{numPages:t,currentPage:s}=this.props;if(t<2)return"";(e={numPages:t,currentPage:s,midSize:1,endSize:1,prevNext:!0,...e||{}}).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);const n=[...Array(t).keys()];let i=!1;return(0,r.createElement)("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&(0,r.createElement)("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},(0,u.__)("Prev","learnpress")),n.map((t=>(t+=1)===e.currentPage?(i=!0,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers current"},t)):t<=e.endSize||e.currentPage&&t>=e.currentPage-e.midSize&&t<=e.currentPage+e.midSize||t>e.numPages-e.endSize?(i=!0,(0,r.createElement)("button",{key:`page-number-${t}`,className:"page-numbers",onClick:this.moveTo(t)},t)):i?(i=!1,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers dots"},"…")):"")),e.prevNext&&!this.isLast()&&(0,r.createElement)("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},(0,u.__)("Next","learnpress")))}render(){const{status:e,questionNav:t,isReviewing:s,showReview:n,numPages:i,question:o,questionsPerPage:a,canRetry:l,retakeNumber:c,requiredPassword:d,allowRetake:p}=this.props,m=["quiz-buttons"];("started"===e||s)&&m.push("align-center"),"questionNav"===t&&m.push("infinity"),this.isFirst()&&m.push("is-first"),this.isLast()&&m.push("is-last");const h=document.querySelector("#popup-sidebar"),g=document.querySelector("#learn-press-quiz-app");let f="";f="started"===e||s?{marginLeft:h&&h.offsetWidth/2,width:g&&g.offsetWidth}:null;let _=" fixed";return"no"==lpQuizSettings.navigationPosition&&(_=" nav-center"),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:m.join(" ")},(0,r.createElement)("div",{className:"button-left"+("started"===e||s?_:""),style:f},("completed"===e&&l||-1!==["","viewed"].indexOf(e))&&!s&&!d&&(0,r.createElement)("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===e?`${(0,u.__)("Retake","learnpress")} ${p?"":" "+(c?` (${c})`:"")} `:" "+(0,u.__)("Start","learnpress")),("started"===e||s)&&i>1&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"questions-pagination"},this.pageNumbers()))),(0,r.createElement)("div",{className:"button-right"},"started"===e&&(0,r.createElement)(r.Fragment,null,("infinity"===t||this.isLast())&&!s&&(0,r.createElement)("button",{className:"lp-button submit-quiz",onClick:this.submit},(0,u.__)("Finish Quiz","learnpress"))),s&&n&&(0,r.createElement)("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},(0,u.__)("Result","learnpress")),"completed"===e&&n&&!s&&(0,r.createElement)("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},(0,u.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&(0,r.createElement)("div",{className:"learn-press-message error"},this.props.message))}}const m=(0,o.compose)((0,a.withSelect)((e=>{const{getData:t}=e("learnpress/quiz");return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((e=>{const{showCheck:t,checkedQuestions:s,hintedQuestions:n,question:i,status:o,type:a,Button:u}=e;if("started"!==o)return!1;const l=(0,r.createElement)(u,{question:i});switch(a){case"hint":return n?!!i.hasHint&&-1===n.indexOf(i.id)&&l:l;case"check":return!!t&&(s?-1===s.indexOf(i.id)&&l:l)}}));var h=(0,o.compose)([(0,a.withSelect)((e=>{const{getData:t,getCurrentQuestion:s}=e("learnpress/quiz"),n={id:t("id"),status:t("status"),questionIds:t("questionIds"),questionNav:t("questionNav"),isReviewing:t("reviewQuestions")&&"reviewing"===t("mode"),showReview:t("reviewQuestions"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),numPages:t("numPages"),pages:t("pages"),currentPage:t("currentPage"),questionsPerPage:t("questionsPerPage"),pageNumbers:t("pageNumbers"),keyPressed:t("keyPressed"),canRetry:t("retakeCount")>0&&t("retaken")<t("retakeCount"),retakeNumber:t("retakeCount")>0&&t("retaken")<t("retakeCount")?t("retakeCount")-t("retaken"):null,message:t("messageResponse")||!1,success:void 0===t("successResponse")||t("successResponse"),requiredPassword:t("requiredPassword"),allowRetake:t("allowRetake")};if(1===n.questionsPerPage&&(n.question=s("object")),1===lpQuizSettings.checkNorequizenroll){const e=window.localStorage.getItem("quiz_off_retaken_"+lpQuizSettings.id);t("retakeCount")>e?(n.retakeNumber=t("retakeCount")-e,n.canRetry=!0):n.canRetry=!1}return n.allowRetake&&(n.canRetry=!0),n})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{startQuiz:n,setCurrentQuestion:r,submitQuiz:i,setQuizMode:o,showHint:a,checkAnswer:u,setCurrentPage:l}=e("learnpress/quiz");return{startQuiz:n,setCurrentQuestion:r,setQuizMode:o,setCurrentPage:l,submitQuiz(e){i(e)},showHint(e){a(e)},checkAnswer(e){u(e)}}}))])(p);function g(){return g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},g.apply(this,arguments)}class f extends r.Component{constructor(){super(...arguments),i(this,"showHint",(()=>{const{showHint:e,question:t}=this.props;e(t.id,!t.showHint)}))}render(){const{question:e}=this.props;return e.hint?(0,r.createElement)("button",{className:"btn-show-hint",onClick:this.showHint},(0,r.createElement)("span",null,(0,u.__)("Hint","learnpress"))):""}}var _=(0,o.compose)((0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{showHint:n}=e("learnpress/quiz");return{showHint(e,t){n(e,t)}}})))(f),q=s(184),w=s.n(q);class v extends r.Component{constructor(){super(...arguments),i(this,"checkAnswer",(()=>{const{checkAnswer:e,question:t,answered:s}=this.props;s&&(e(t.id),this.setState({loading:!0}))})),this.state={loading:!1}}render(){const{answered:e}=this.props;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("button",{className:w()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},(0,r.createElement)("span",{className:"instant-check__icon"}),(0,u.__)("Check answer","learnpress"),!e&&(0,r.createElement)("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:(0,u.__)("You need to answer the question before check answer.","learnpress")}})))}}var S=(0,o.compose)((0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getQuestionAnswered:n}=e("learnpress/quiz");return{answered:n(s)}})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{checkAnswer:n}=e("learnpress/quiz");return{checkAnswer(e){n(e)}}})))(v),y=function(e){const{question:t}=e,s={"instant-check":()=>(0,r.createElement)(m,{type:"check",Button:S,question:t}),hint:()=>(0,r.createElement)(m,{type:"hint",Button:_,question:t})};return(0,r.createElement)(r.Fragment,null,LP.config.questionFooterButtons().map((e=>(0,r.createElement)(r.Fragment,{key:`button-${e}`},s[e]&&s[e]()))))};const E=window.jQuery,{uniqueId:z,isArray:b,isNumber:k,bind:P}=lodash;class Q extends r.Component{constructor(){super(...arguments),i(this,"setRef",(e=>{this.$wrap=E(e)})),i(this,"parseOptions",(e=>(e&&(e=b(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=b(e)?e:JSON.parse(e)),e||[]))),i(this,"getWrapperClass",(()=>{const{question:e,answered:t}=this.props,s=["question","question-"+e.type],n=this.parseOptions(e.options);return n.length&&void 0!==n[0].isTrue&&s.push("question-answered"),s})),i(this,"getEditLink",(()=>{const{question:e,editPermalink:t}=this.props;return t?t.replace(/post=(.*[0-9])/,`post=${e.id}`):""})),i(this,"editPermalink",(e=>(0,u.sprintf)('<a href="%s">%s</a>',e,(0,u.__)("Edit","learnpress")))),this.state={time:null,showHint:!1},this.$wrap=null}componentDidMount(e){const{question:t,isCurrent:s,markQuestionRendered:n}=this.props;return s&&n(t.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]),e}render(){const{question:e,isShow:t,isShowIndex:s,isShowHint:n,status:i}=this.props,o=LP.questionTypes.default,a=this.getEditLink();a&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",a);const l={index:()=>s?(0,r.createElement)("span",{className:"question-index"},s,"."):"",title:()=>(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:e.title}}),hint:()=>(0,r.createElement)(_,{question:e}),"edit-permalink":()=>a&&(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:this.editPermalink(a)},className:"edit-link"})},c={title:()=>(0,r.createElement)("h4",{className:"question-title"},LP.config.questionTitleParts().map((e=>(0,r.createElement)(r.Fragment,{key:`title-part-${e}`},l[e]&&l[e]())))),content:()=>(0,r.createElement)("div",{className:"question-content",dangerouslySetInnerHTML:{__html:e.content}}),"answer-options":()=>this.$wrap&&(0,r.createElement)(o,g({},this.props,{$wrap:this.$wrap})),explanation:()=>e.explanation&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-explanation-content"},(0,r.createElement)("strong",{className:"explanation-title"},(0,u.__)("Explanation","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.explanation}}))),hint:()=>e.hint&&!e.explanation&&e.showHint&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-hint-content"},(0,r.createElement)("strong",{className:"hint-title"},(0,u.__)("Hint","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.hint}}))),buttons:()=>"started"===i&&(0,r.createElement)(y,{question:e})},d=LP.config.questionBlocks();return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:this.getWrapperClass().join(" "),style:{display:t?"":"none"},"data-id":e.id,ref:this.setRef},d.map((e=>(0,r.createElement)(r.Fragment,{key:`block-${e}`},c[e]?c[e]():"")))))}}var N=(0,o.compose)([(0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getData:n,getQuestionAnswered:r,getQuestionMark:i}=e("learnpress/quiz");return{status:n("status"),questions:n("question"),answered:r(s),questionsRendered:n("questionsRendered"),editPermalink:n("editPermalink"),numPages:n("numPages"),mark:i(s)||""}})),(0,a.withDispatch)((e=>{const{updateUserQuestionAnswers:t,markQuestionRendered:s}=e("learnpress/quiz");return{markQuestionRendered:s,updateUserQuestionAnswers:t}}))])(Q);class I extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{e.preventDefault();const{startQuiz:t}=this.props;t()})),i(this,"isInVisibleRange",((e,t)=>{const{currentPage:s,questionsPerPage:n}=this.props;return s===Math.ceil(t/n)})),i(this,"nav",(e=>{const{sendKey:t}=this.props;switch(e.keyCode){case 37:return t("left");case 38:case 40:return;case 39:return t("right");default:e.keyCode>=49&&e.keyCode<=57&&t(e.keyCode-48)}})),this.needToTop=!1,this.state={isReviewing:null,currentPage:0,self:this}}static getDerivedStateFromProps(e,t){const s=["isReviewing","currentPage"],n={};for(let r=0;r<s.length;r++)e[s[r]]!==t[s[r]]&&(n[s[r]]=e[s[r]]);return Object.values(n).length?(t.self.needToTop=!0,n):null}componentDidUpdate(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}render(){const{status:e,currentQuestion:t,questions:s,questionsRendered:n,isReviewing:i,questionsPerPage:o}=this.props;let a=!0;return"completed"!==e||i||(a=!1),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{tabIndex:100,onKeyUp:this.nav},(0,r.createElement)("div",{className:"quiz-questions",style:{display:a?"":"none"}},s.map(((e,s)=>{const i=!o&&t===e.id,a=n&&-1!==n.indexOf(e.id),u=this.isInVisibleRange(e.id,s+1);return a||!a||u?(0,r.createElement)(N,{key:`loop-question-${e.id}`,isCurrent:i,isShow:u,isShowIndex:!!o&&s+1,questionsPerPage:o,question:e}):""})))))}}var C=(0,o.compose)((0,a.withSelect)(((e,t,s)=>{const{getData:n,getQuestions:r}=e("learnpress/quiz");return{status:n("status"),currentQuestion:n("currentQuestion"),questions:r(),questionsRendered:n("questionsRendered"),isReviewing:"reviewing"===n("mode"),numPages:n("numPages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{startQuiz:t,sendKey:s}=e("learnpress/quiz");return{startQuiz:t,sendKey:s}})))(I),A=()=>{const e=(0,a.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"quiz-attempts"},(0,r.createElement)("h4",{className:"attempts-heading"},(0,u.__)("Last Attempted","learnpress")),t&&(0,r.createElement)("table",null,(0,r.createElement)("thead",null,(0,r.createElement)("tr",null,(0,r.createElement)("th",{className:"quiz-attempts__questions"},(0,u.__)("Questions","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__spend"},(0,u.__)("Time spent","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__marks"},(0,u.__)("Marks","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__grade"},(0,u.__)("Passing grade","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__result"},(0,u.__)("Result","learnpress")))),(0,r.createElement)("tbody",null,e.map(((e,t)=>(0,r.createElement)("tr",{key:`attempt-${t}`},(0,r.createElement)("td",{className:"quiz-attempts__questions"},`${e.questionCorrect} / ${e.questionCount}`),(0,r.createElement)("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),(0,r.createElement)("td",{className:"quiz-attempts__marks"},`${e.userMark} / ${e.mark}`),(0,r.createElement)("td",{className:"quiz-attempts__grade"},e.passingGrade||"-"),(0,r.createElement)("td",{className:"quiz-attempts__result"},`${parseFloat(e.result).toFixed(2)}%`," ",(0,r.createElement)("span",null,e.graduationText)))))))))},T=()=>{const{getData:e}=(0,a.select)("learnpress/quiz"),{submitQuiz:t}=(0,a.dispatch)("learnpress/quiz"),s=e("totalTime"),n=e("duration"),[i,o]=(0,r.useState)(s);let[u,l]=(0,r.useState)(0);const c=s>0;return(0,r.useEffect)((()=>{const e=setInterval((()=>{if(c){let s=i;s-=1,s>0?(o(s),u++,l(n-s)):(clearInterval(e),t())}else u++,l(u),o(u)}),1e3);return()=>clearInterval(e)}),[i,u]),(0,r.createElement)("div",{className:"countdown"},(0,r.createElement)("i",{className:"fas fa-stopwatch"}),(0,r.createElement)("span",null,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";const t=[];let n;return s<3600?(t.push((i-i%60)/60),t.push(i%60)):s&&(t.push((i-i%3600)/3600),n=i%3600,t.push((n-n%60)/60),t.push(n%60)),t.map((e=>e<10?`0${e}`:e)).join(e)}()),(0,r.createElement)("input",{type:"hidden",name:"lp-quiz-time-spend",value:u}))},R=window.wp.url;const O=jQuery;let L=null;const x={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=O(".lp-overlay"),!!this.elLPOverlay.length&&(L=this.elLPOverlay,this.elMainContent=L.find(".main-content"),this.elTitle=L.find(".modal-title"),this.elBtnYes=L.find(".btn-yes"),this.elBtnNo=L.find(".btn-no"),this.elFooter=L.find(".lp-modal-footer"),O(document).on("click",".close, .btn-no",(function(){L.hide()})),O(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof x.callBackYes&&x.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var D=x,M={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){D.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})))))}};const{debounce:H}=lodash;var F=()=>{const[e,t]=(0,r.useState)(0),[s,n]=(0,r.useState)(!1),i=(0,a.useSelect)((e=>e("learnpress/quiz").getData("id")),[]),o=(0,a.useSelect)((e=>e("learnpress/quiz").getData("results")),[]),l=(0,a.useSelect)((e=>e("learnpress/quiz").getData("passingGrade")),[]),c=(0,a.useSelect)((e=>e("learnpress/quiz").getData("submitting")),[]);(0,r.useEffect)((()=>{p();let e="";if(e=o.graduation?o.graduation:o.result>=f?"passed":"failed",e){const t=document.querySelector(`.course-curriculum .course-item.course-item-${i}`);t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}const t=[...document.querySelectorAll("#popup-header .items-progress")][0],s=document.querySelector(".curriculum-sections");if(t&&s){const e=t.dataset.totalItems,s=t.querySelector(".items-completed"),n=t.querySelector(".learn-press-progress__active");if(s){const t=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");s.textContent=parseInt(t.length);const r=100-100*parseInt(t.length)/parseInt(e);n.style.left="-"+r+"%"}}}),[o]),(0,r.useEffect)((()=>{void 0!==c&&d()}),[c]);const d=()=>{const e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&(async e=>{const t=await wp.apiFetch({path:(0,R.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"}),{data:s}=t;e.innerHTML+=s,M.init()})(e[0])},p=()=>{t(0),n(!1),jQuery.easing._customEasing=function(e,t,s,n,r){return n*Math.sqrt(1-(t=t/r-1)*t)+s},H((()=>{const e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:o.result},{duration:1500,step:(e,s)=>{t(e)},done:()=>{n(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),H((()=>{jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),o.result>0?1e3:10)()};let m=e;Number.isInteger(e)||(m=parseFloat(e).toFixed(2));const h=190*Math.PI,g={strokeDasharray:`${h} ${h}`,strokeDashoffset:h-m/100*h},f=parseFloat(o.passingGrade||l);let _="";_=o.graduation?o.graduation:m>=f?"passed":"failed";let q="";q=o.graduationText?o.graduationText:"passed"===_?(0,u.__)("Passed","learnpress"):(0,u.__)("Failed","learnpress");const w=["quiz-result",_];return(0,r.createElement)("div",{className:w.join(" ")},(0,r.createElement)("h3",{className:"result-heading"},(0,u.__)("Your Result","learnpress")),(0,r.createElement)("div",{id:"quizResultGrade",className:"result-grade"},(0,r.createElement)("svg",{className:"circle-progress-bar",width:200,height:200},(0,r.createElement)("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),(0,r.createElement)("span",{className:"result-achieved"},`${m}%`),(0,r.createElement)("span",{className:"result-require"},f+"%"||0)),s&&(0,r.createElement)("p",{className:"result-message"},q),(0,r.createElement)("ul",{className:"result-statistic"},(0,r.createElement)("li",{className:"result-statistic-field result-time-spend"},(0,r.createElement)("span",null,(0,u.__)("Time spent","learnpress")),(0,r.createElement)("p",null,o.timeSpend)),(0,r.createElement)("li",{className:"result-statistic-field result-point"},(0,r.createElement)("span",null,(0,u.__)("Points","learnpress")),(0,r.createElement)("p",null,o.userMark," / ",o.mark)),(0,r.createElement)("li",{className:"result-statistic-field result-questions"},(0,r.createElement)("span",null,(0,u.__)("Questions","learnpress")),(0,r.createElement)("p",null,o.questionCount)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-correct"},(0,r.createElement)("span",null,(0,u.__)("Correct","learnpress")),(0,r.createElement)("p",null,o.questionCorrect)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-wrong"},(0,r.createElement)("span",null,(0,u.__)("Wrong","learnpress")),(0,r.createElement)("p",null,o.questionWrong)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-skipped"},(0,r.createElement)("span",null,(0,u.__)("Skipped","learnpress")),(0,r.createElement)("p",null,o.questionEmpty))))};const U=jQuery,{debounce:$}=lodash;var j=()=>{const{submitQuiz:e}=(0,a.dispatch)("learnpress/quiz");(0,r.useEffect)((()=>{const e=U("#popup-content");if(!e.length)return;const t=e.find(".content-item-scrollable:eq(1)"),s=e.find(".content-item-wrap"),n=e.find(".quiz-status"),r=n.offset().top-92;let i=!1,o="-"+s.css("margin-left");U(window).on("resize.refresh-quiz-stauts-bar",$((function(){o="-"+s.css("margin-left"),n.css({"margin-left":o,"margin-right":o})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(()=>{if(t.scrollTop()>=r){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}),[]);const t=()=>{const{confirm:s}=(0,a.select)("learnpress/modal");"no"!==s((0,u.__)("Are you sure to submit quiz?","learnpress"),t)&&e()},{getData:s,getUserMark:n}=(0,a.select)("learnpress/quiz"),i=s("currentPage"),o=s("questionsPerPage"),l=s("questionIds").length,c=s("submitting"),d=(s("duration"),n()),p=["quiz-status"],m=(i-1)*o+1;let h=m+o-1,g="";return h=Math.min(h,l),c&&p.push("submitting"),g=h<l?o>1?(0,u.sprintf)((0,u.__)("Question <span>%d to %d of %d</span>","learnpress"),m,h,l):(0,u.sprintf)((0,u.__)("Question <span>%d of %d</span>","learnpress"),m,l):(0,u.sprintf)((0,u.__)("Question <span>%d to %d</span>","learnpress"),m,h),(0,r.createElement)("div",{className:p.join(" ")},(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:g}}),(0,r.createElement)("div",{className:"current-point"},(0,u.sprintf)((0,u.__)("Earned Point: %s","learnpress"),d)),(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"submit-quiz"},(0,r.createElement)("button",{className:"lp-button",id:"button-submit-quiz",onClick:t},c?(0,u.__)("Submitting...","learnpress"):(0,u.__)("Finish Quiz","learnpress"))),(0,r.createElement)(T,null))))};const{omit:B,flow:J,isArray:G,chunk:K}=lodash,{camelCaseDashObjectKeys:W}=LP,{get:Z,set:Y}=LP.localStorage,V={},X=(e,t)=>{const{answered:s,id:n}=e,r={...s[t.questionId]||{},answered:t.answers,temp:!0};return n&&localStorage.setItem(`LP_Quiz_${n}_Answered`,JSON.stringify({...e.answered,[t.questionId]:r})),{...e,answered:{...e.answered,[t.questionId]:r}}},ee=(e,t)=>{const{questionsRendered:s}=e;return G(s)?(s.push(t.questionId),{...e,questionsRendered:[...s]}):{...e,questionsRendered:[t.questionId]}},te=(e,t)=>(t.currentPage&&Y(`Q${e.id}.currentPage`,t.currentPage),{...e,...t}),se=(e,t)=>{const s=e.questions.map((e=>e.id==t.questionId?{...e,showHint:t.showHint}:e));return{...e,questions:[...s]}},ne=(e,t)=>{const s=e.questions.map((e=>{if(e.id!==t.questionId)return e;const s={explanation:t.explanation};return t.options&&(s.options=t.options),{...e,...s}})),n={...e.answered,[t.questionId]:t.result};let r=localStorage.getItem(`LP_Quiz_${e.id}_Answered`);return r&&(r={...JSON.parse(r),...n},localStorage.setItem(`LP_Quiz_${e.id}_Answered`,JSON.stringify(r))),{...e,questions:[...s],answered:n,checkedQuestions:[...e.checkedQuestions,t.questionId]}},re=(e,t)=>{localStorage.removeItem(`LP_Quiz_${e.id}_Answered`);const s=e.questions.map((s=>{const n={};return e.reviewQuestions&&(t.results.questions[s.id].explanation&&(n.explanation=t.results.questions[s.id].explanation),t.results.questions[s.id].options&&(n.options=t.results.questions[s.id].options)),{...s,...n}}));return te(e,{submitting:!1,currentPage:1,...t.results,questions:[...s]})},ie=(e,t)=>{const s=void 0!==t.results.success&&t.results.success,n=t.results.message||!1;return te(e,{checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1,...t.results.results,successResponse:s,messageResponse:n})},oe=J(a.combineReducers,(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)))({a(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1}},b(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2}}});var ae=(0,a.combineReducers)({blocks:oe,userQuiz:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);const s=K(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=s.length,t.data.pages=s,{...e,...t.data,currentPage:Z(`Q${t.data.id}.currentPage`)||t.data.currentPage};case"SUBMIT_QUIZ":return{...e,submitting:!0};case"START_QUIZ":case"START_QUIZ_SUCCESS":return ie(e,t);case"SET_CURRENT_QUESTION":return Y(`Q${e.id}.currentQuestion`,t.questionId),{...e,currentQuestion:t.questionId};case"SET_CURRENT_PAGE":return Y(`Q${e.id}.currentPage`,t.currentPage),{...e,currentPage:t.currentPage};case"SUBMIT_QUIZ_SUCCESS":return re(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?X(e,t):e;case"MARK_QUESTION_RENDERED":return ee(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?te(e,{mode:t.mode}):{...e,mode:t.mode};case"SET_QUESTION_HINT":return se(e,t);case"CHECK_ANSWER":return ne(e,t);case"SEND_KEY":return{...e,keyPressed:t.keyPressed}}return e}}),ue=window.LP.dataControls;function le(){const e=[].slice.call(arguments,2),t=(0,a.dispatch)(arguments[0]),s=arguments[1];t[s](...e)}const{camelCaseDashObjectKeys:ce,Hook:de}=LP;function pe(e,t){return{type:"SET_QUIZ_DATA",data:ce(t="string"==typeof e?{[e]:t}:e)}}function me(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function he(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function ge(e,t,s){return{type:"BEFORE_START_QUIZ"}}function fe(e,t,s,n){return de.doAction("quiz-started",e,t,s,n),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:s,userId:n,results:e}}const _e=function*(){const{itemId:e,courseId:t}=(0,a.select)("learnpress/quiz").getDefaultRestArgs();if(!0!==de.applyFilters("before-start-quiz",!0,e,t))return;let s=yield(0,ue.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:e,course_id:t}});const n=document.querySelector(".lp-button.start");if("error"!==s.status){if(s=de.applyFilters("request-start-quiz-response",s,e,t),1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id;window.localStorage.removeItem(e);const t={endTime:Date.now()+1e3*s.results.duration,status:s.results.status};window.localStorage.setItem(e,JSON.stringify(t));const n="quiz_off_retaken_"+lpQuizSettings.id;let r=window.localStorage.getItem(n);null===r?r=0:r++,window.localStorage.setItem(n,r)}yield le("learnpress/quiz","__requestStartQuizSuccess",ce(s),e,t)}else{const e=document.querySelector(".quiz-buttons"),t=`<div class="learn-press-message error">${s.message}</div>`;e.insertAdjacentHTML("afterend",t),n.classList.remove("loading")}};function qe(){return{type:"SUBMIT_QUIZ"}}function we(e,t,s){return de.doAction("quiz-submitted",e,t,s),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function*ve(){const{getDefaultRestArgs:e,getQuestionsSelectedAnswers:t}=(0,a.select)("learnpress/quiz"),{itemId:s,courseId:n}=e();if(!0!==de.applyFilters("before-submit-quiz",!0))return;const r=t();if(1===lpQuizSettings.checkNorequizenroll){const e=`LP_Quiz_${s}_Answered`,t=localStorage.getItem(e);if(null!==t){const e=JSON.parse(t);for(const[t,s]of Object.entries(e))r[t]=s.answered}}let i=0;const o=document.querySelector("input[name=lp-quiz-time-spend]");o&&(i=o.value);let u=yield(0,ue.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:s,course_id:n,answered:r,time_spend:i}});if(u=de.applyFilters("request-submit-quiz-response",u,s,n),"success"===u.status){if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,t=window.localStorage.getItem(e);if(null!==t){const s=JSON.parse(t);s.status=u.results.status,s.results=u.results.results,window.localStorage.setItem(e,JSON.stringify(s)),window.localStorage.removeItem("LP_Quiz_"+lpQuizSettings.id+"_Answered")}}yield le("learnpress/quiz","__requestSubmitQuizSuccess",ce(u.results),s,n)}}function Se(e,t,s){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function ye(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function*Ee(e,t){yield le("learnpress/quiz","__requestShowHintSuccess",e,t)}function ze(e,t){return{type:"CHECK_ANSWER",questionId:e,...t}}function*be(e){const{getDefaultRestArgs:t,getQuestionAnswered:s}=(0,a.select)("learnpress/quiz"),{itemId:n,courseId:r}=t(),i=yield(0,ue.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:n,course_id:r,question_id:e,answered:s(e)||""}});if("success"===i.status){if(1===lpQuizSettings.checkNorequizenroll){const t="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(t);if(null!==s){const n=JSON.parse(s),r=i.options;void 0===n.checked_questions?(n.checked_questions=[],n.checked_questions.push(e)):-1===n.checked_questions.indexOf(e)&&n.checked_questions.push(e),void 0===n.question_options?(n.question_options={},n.question_options[e]=r):void 0===n.question_options[e]&&(n.question_options[e]=r),window.localStorage.setItem(t,JSON.stringify(n))}}yield le("learnpress/quiz","__requestCheckAnswerSuccess",e,ce(i))}}function ke(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Pe(e){return{type:"SET_QUIZ_MODE",mode:e}}function Qe(e){return setTimeout((()=>{le("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}const{get:Ne,isArray:Ie}=lodash,Ce=function(e,t){console.time("parseOptions");let s=Ue(e,t).options;return s=Ie(s)?s:JSON.parse(CryptoJS.AES.decrypt(s.data,s.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),s=Ie(s)?s:JSON.parse(s),console.timeEnd("parseOptions"),s};function Ae(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.status"):""}function Te(e,t,s){return e[t]||s}function Re(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.attempts"):[]}function Oe(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.answered",{}):{}}function Le(e){const{userQuiz:t}=e,s=Ne(t,"questions");return s?Object.values(s):[]}function xe(e,t){const{userQuiz:s}=e;return t?Ne(s,t):s}function De(e){const{userQuiz:t}=e;return{itemId:t.id,courseId:t.courseId}}function Me(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.answered`)||void 0}function He(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.mark`)||void 0}function Fe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=Ne(e,"userQuiz.questionsPerPage")||1;if(s>1)return!1;const n=Ne(e,"userQuiz.currentPage")||1;return Ne(e,"object"===t?`userQuiz.questions[${n-1}]`:`userQuiz.questionIds[${n-1}]`)}const Ue=function(e,t){const{userQuiz:s}=e;return(0,a.select)("learnpress/quiz").getQuestions().find((e=>e.id==t))};function $e(e,t){return-1!==(Ne(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function je(e,t){}const Be=function(e,t){const s=Ne(e,"userQuiz.answered"),n={};for(const e in s)if(s.hasOwnProperty(e)&&(s[e].temp||s[e].blanks)){if(t&&e===t)return s[e].answered;n[e]=s[e].answered}return n};function Je(e){const t=e.userQuiz||{},{answered:s,negativeMarking:n,questions:r,checkedQuestions:i}=t;let o=0;for(let e in s){if(!s.hasOwnProperty(e))continue;e=parseInt(e);const t=s[e],a=t.questionMark?t.questionMark:function(){const t=r.find((t=>t.id===e));return t?t.point:0}();i.indexOf(e),t.temp||(n?t.answered&&(o=t.correct?o+t.mark:o-a):t.answered&&t.correct&&(o+=t.mark))}return o>0?o:0}var Ge=s(965),Ke=s.n(Ge);const We={ENROLL_COURSE_X:(e,t)=>{}};const{controls:Ze}=LP.dataControls;!function(e){let t=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:e.getState,dispatch:function(){return t(...arguments)}};t=Ke()(We)(s)(e.dispatch),e.dispatch=t}((0,a.registerStore)("learnpress/quiz",{reducer:ae,selectors:t,actions:e,controls:{...Ze}}));const{chunk:Ye}=lodash;class Ve extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{this.props.startQuiz()})),this.state={currentPage:1,numPages:0,pages:[]}}componentDidMount(){const{settings:e,setQuizData:t}=this.props,{question_ids:s,questions_per_page:n}=e,r=Ye(s,n);e.currentPage=1,e.numPages=r.length,e.pages=r;const i=!!e.id&&localStorage.getItem(`LP_Quiz_${e.id}_Answered`);i&&(e.answered=JSON.parse(i)),t(e)}componentDidUpdate(e,t,s){const{status:n}=e,r=document.querySelector(".quiz-content");void 0!==n&&r&&(r.style.display="none")}render(){const{status:e,isReviewing:t}=this.props,s=-1!==["","completed","viewed"].indexOf(e)||!e,n=-1!==["","viewed",void 0].indexOf(e)||!e;return void 0!==e&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",null,!t&&"completed"===e&&(0,r.createElement)(F,null),!t&&n&&(0,r.createElement)(d,null),"started"===e&&(0,r.createElement)(j,null),(-1!==["completed","started"].indexOf(e)||t)&&(0,r.createElement)(C,null),(0,r.createElement)(h,null),s&&!t&&(0,r.createElement)(A,null)))}}var Xe=(0,o.compose)([(0,a.withSelect)((e=>{const{getQuestions:t,getData:s}=e("learnpress/quiz");return{questions:t(),status:s("status"),store:s(),answered:s("answered"),isReviewing:"reviewing"===s("mode"),questionIds:s("questionIds"),checkCount:s("instantCheck"),questionsPerPage:s("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{setQuizData:t,startQuiz:s}=e("learnpress/quiz");return{setQuizData:t,startQuiz:s}}))])(Ve);s(605);const{modal:{default:et}}=LP;var tt=Xe;const st=(e,t)=>{if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(e);if(null!==s){const e=JSON.parse(s);if(t.status=e.status,"started"===e.status){const s=Date.now();t.total_time=Math.floor((e.endTime-s)/1e3)}else"completed"===e.status&&(t.results=e.results,t.answered=e.results.answered,t.questions=e.results.questions);if(void 0!==e.checked_questions&&(t.checked_questions=e.checked_questions),void 0!==e.question_options)for(const s in t.questions){let n=t.questions[s];void 0!==e.question_options[n.id]&&(n.options=e.question_options[n.id]),t.questions[s]=n}}}wp.element.render((0,r.createElement)(et,null,(0,r.createElement)(Xe,{settings:t})),[...document.querySelectorAll(e)][0]),LP.Hook.doAction("lp-quiz-compatible-builder")}}(),(window.LP=window.LP||{}).quiz=n}();
1
+ !function(){var e={605:function(){LP.Hook.addAction("lp-compatible-builder",(()=>{LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(()=>(LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0))),LP.Hook.addAction("lp-question-compatible-builder",(()=>(LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0)))},184:function(e,t){var s;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var i=typeof s;if("string"===i||"number"===i)e.push(s);else if(Array.isArray(s)){if(s.length){var o=r.apply(null,s);o&&e.push(o)}}else if("object"===i)if(s.toString===Object.prototype.toString)for(var a in s)n.call(s,a)&&s[a]&&e.push(a);else e.push(s.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(s=function(){return r}.apply(t,[]))||(e.exports=s)}()},965:function(e){"use strict";function t(e,s){var n;if(Array.isArray(s))for(n=0;n<s.length;n++)t(e,s[n]);else for(n in s)e[n]=(e[n]||[]).concat(s[n])}e.exports=function(e){var s,n={};return t(n,e),(s=function(e){return function(t){return function(s){var r,i,o=n[s.type],a=t(s);if(o)for(r=0;r<o.length;r++)(i=o[r](s,e))&&e.dispatch(i);return a}}}).effects=n,s}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,s),i.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){"use strict";s.r(n),s.d(n,{default:function(){return tt},init:function(){return st}});var e={};s.r(e),s.d(e,{__requestBeforeStartQuiz:function(){return ge},__requestCheckAnswerSuccess:function(){return ze},__requestShowHintSuccess:function(){return ye},__requestStartQuizSuccess:function(){return fe},__requestSubmitQuiz:function(){return qe},__requestSubmitQuizSuccess:function(){return we},checkAnswer:function(){return be},markQuestionRendered:function(){return ke},sendKey:function(){return Qe},setCurrentPage:function(){return he},setCurrentQuestion:function(){return me},setQuizData:function(){return pe},setQuizMode:function(){return Pe},showHint:function(){return Ee},startQuiz:function(){return _e},submitQuiz:function(){return ve},updateUserQuestionAnswers:function(){return Se}});var t={};s.r(t),s.d(t,{getCurrentQuestion:function(){return Fe},getData:function(){return xe},getDefaultRestArgs:function(){return De},getItemStatus:function(){return Ae},getProp:function(){return Te},getQuestion:function(){return Ue},getQuestionAnswered:function(){return Me},getQuestionMark:function(){return He},getQuestionOptions:function(){return Ce},getQuestions:function(){return Le},getQuestionsSelectedAnswers:function(){return Be},getQuizAnswered:function(){return Oe},getQuizAttempts:function(){return Re},getUserMark:function(){return Je},isCheckedAnswer:function(){return $e},isCorrect:function(){return je}});var r=window.wp.element;function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var o=window.wp.compose,a=window.wp.data,u=window.wp.i18n,l=e=>{let t;const s=86400;if(e>s)t=(e-e%s)/s,e%=s;else if(e==s)return"24:00";const n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")};const{Hook:c}=LP;var d=()=>{const e=e=>(0,a.select)("learnpress/quiz").getData(e),t=c.applyFilters("quiz-meta-fields",{duration:{title:(0,u.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:(0,u.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:(0,u.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("ul",{className:"quiz-intro"},Object.values(t).map(((e,t)=>{const s=e.name||t;return(0,r.createElement)("li",{key:`quiz-intro-field-${t}`,className:`quiz-intro-item quiz-intro-item--${s}`},(0,r.createElement)("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),(0,r.createElement)("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};class p extends r.Component{constructor(){super(...arguments),i(this,"startQuiz",(e=>{e&&e.preventDefault();const t=document.querySelector(".lp-button.start");t&&t.setAttribute("disabled","disabled"),t.classList.add("loading");const{startQuiz:s,status:n}=this.props;if("completed"===n){const{confirm:e,isOpen:s}=(0,a.select)("learnpress/modal");if("no"===e((0,u.__)("Are you sure you want to retake quiz?","learnpress"),this.startQuiz))return void(!s()&&t&&t.removeAttribute("disabled"))}s()})),i(this,"nav",(e=>t=>{let{questionNav:s,currentPage:n,numPages:r,setCurrentPage:i}=this.props;"prev"===e?n>1?n-=1:n="infinity"===s?r:1:n<r?n+=1:n="infinity"===s?1:r,i(n)})),i(this,"moveTo",(e=>t=>{t.preventDefault();const{numPages:s,setCurrentPage:n}=this.props;e<1||e>s||n(e)})),i(this,"isLast",(()=>{const{currentPage:e,numPages:t}=this.props;return e===t})),i(this,"isFirst",(()=>{const{currentPage:e}=this.props;return 1===e})),i(this,"submit",(()=>{const{submitQuiz:e}=this.props,{confirm:t}=(0,a.select)("learnpress/modal");"no"!==t((0,u.__)("Are you sure to submit quiz?","learnpress"),this.submit)&&e()})),i(this,"setQuizMode",(e=>()=>{const{setQuizMode:t}=this.props;t(e)})),i(this,"isReviewing",(()=>{const{isReviewing:e}=this.props;return e}))}pageNumbers(e){const{numPages:t,currentPage:s}=this.props;if(t<2)return"";(e={numPages:t,currentPage:s,midSize:1,endSize:1,prevNext:!0,...e||{}}).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);const n=[...Array(t).keys()];let i=!1;return(0,r.createElement)("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&(0,r.createElement)("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},(0,u.__)("Prev","learnpress")),n.map((t=>(t+=1)===e.currentPage?(i=!0,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers current"},t)):t<=e.endSize||e.currentPage&&t>=e.currentPage-e.midSize&&t<=e.currentPage+e.midSize||t>e.numPages-e.endSize?(i=!0,(0,r.createElement)("button",{key:`page-number-${t}`,className:"page-numbers",onClick:this.moveTo(t)},t)):i?(i=!1,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers dots"},"…")):"")),e.prevNext&&!this.isLast()&&(0,r.createElement)("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},(0,u.__)("Next","learnpress")))}render(){const{status:e,questionNav:t,isReviewing:s,showReview:n,numPages:i,question:o,questionsPerPage:a,canRetry:l,retakeNumber:c,requiredPassword:d,allowRetake:p}=this.props,m=["quiz-buttons"];("started"===e||s)&&m.push("align-center"),"questionNav"===t&&m.push("infinity"),this.isFirst()&&m.push("is-first"),this.isLast()&&m.push("is-last");const h=document.querySelector("#popup-sidebar"),g=document.querySelector("#learn-press-quiz-app");let f="";f="started"===e||s?{marginLeft:h&&h.offsetWidth/2,width:g&&g.offsetWidth}:null;let _=" fixed";return"no"==lpQuizSettings.navigationPosition&&(_=" nav-center"),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:m.join(" ")},(0,r.createElement)("div",{className:"button-left"+("started"===e||s?_:""),style:f},("completed"===e&&l||-1!==["","viewed"].indexOf(e))&&!s&&!d&&(0,r.createElement)("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===e?`${(0,u.__)("Retake","learnpress")} ${p?"":" "+(c?` (${c})`:"")} `:" "+(0,u.__)("Start","learnpress")),("started"===e||s)&&i>1&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"questions-pagination"},this.pageNumbers()))),(0,r.createElement)("div",{className:"button-right"},"started"===e&&(0,r.createElement)(r.Fragment,null,("infinity"===t||this.isLast())&&!s&&(0,r.createElement)("button",{className:"lp-button submit-quiz",onClick:this.submit},(0,u.__)("Finish Quiz","learnpress"))),s&&n&&(0,r.createElement)("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},(0,u.__)("Result","learnpress")),"completed"===e&&n&&!s&&(0,r.createElement)("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},(0,u.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&(0,r.createElement)("div",{className:"learn-press-message error"},this.props.message))}}const m=(0,o.compose)((0,a.withSelect)((e=>{const{getData:t}=e("learnpress/quiz");return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((e=>{const{showCheck:t,checkedQuestions:s,hintedQuestions:n,question:i,status:o,type:a,Button:u}=e;if("started"!==o)return!1;const l=(0,r.createElement)(u,{question:i});switch(a){case"hint":return n?!!i.hasHint&&-1===n.indexOf(i.id)&&l:l;case"check":return!!t&&(s?-1===s.indexOf(i.id)&&l:l)}}));var h=(0,o.compose)([(0,a.withSelect)((e=>{const{getData:t,getCurrentQuestion:s}=e("learnpress/quiz"),n={id:t("id"),status:t("status"),questionIds:t("questionIds"),questionNav:t("questionNav"),isReviewing:t("reviewQuestions")&&"reviewing"===t("mode"),showReview:t("reviewQuestions"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),numPages:t("numPages"),pages:t("pages"),currentPage:t("currentPage"),questionsPerPage:t("questionsPerPage"),pageNumbers:t("pageNumbers"),keyPressed:t("keyPressed"),canRetry:t("retakeCount")>0&&t("retaken")<t("retakeCount"),retakeNumber:t("retakeCount")>0&&t("retaken")<t("retakeCount")?t("retakeCount")-t("retaken"):null,message:t("messageResponse")||!1,success:void 0===t("successResponse")||t("successResponse"),requiredPassword:t("requiredPassword"),allowRetake:t("allowRetake")};if(1===n.questionsPerPage&&(n.question=s("object")),1===lpQuizSettings.checkNorequizenroll){const e=window.localStorage.getItem("quiz_off_retaken_"+lpQuizSettings.id);t("retakeCount")>e?(n.retakeNumber=t("retakeCount")-e,n.canRetry=!0):n.canRetry=!1}return n.allowRetake&&(n.canRetry=!0),n})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{startQuiz:n,setCurrentQuestion:r,submitQuiz:i,setQuizMode:o,showHint:a,checkAnswer:u,setCurrentPage:l}=e("learnpress/quiz");return{startQuiz:n,setCurrentQuestion:r,setQuizMode:o,setCurrentPage:l,submitQuiz(e){i(e)},showHint(e){a(e)},checkAnswer(e){u(e)}}}))])(p);function g(){return g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},g.apply(this,arguments)}class f extends r.Component{constructor(){super(...arguments),i(this,"showHint",(()=>{const{showHint:e,question:t}=this.props;e(t.id,!t.showHint)}))}render(){const{question:e}=this.props;return e.hint?(0,r.createElement)("button",{className:"btn-show-hint",onClick:this.showHint},(0,r.createElement)("span",null,(0,u.__)("Hint","learnpress"))):""}}var _=(0,o.compose)((0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{showHint:n}=e("learnpress/quiz");return{showHint(e,t){n(e,t)}}})))(f),q=s(184),w=s.n(q);class v extends r.Component{constructor(){super(...arguments),i(this,"checkAnswer",(()=>{const{checkAnswer:e,question:t,answered:s}=this.props;s&&(e(t.id),this.setState({loading:!0}))})),this.state={loading:!1}}render(){const{answered:e}=this.props;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("button",{className:w()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},(0,r.createElement)("span",{className:"instant-check__icon"}),(0,u.__)("Check answer","learnpress"),!e&&(0,r.createElement)("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:(0,u.__)("You need to answer the question before check answer.","learnpress")}})))}}var S=(0,o.compose)((0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getQuestionAnswered:n}=e("learnpress/quiz");return{answered:n(s)}})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{checkAnswer:n}=e("learnpress/quiz");return{checkAnswer(e){n(e)}}})))(v),y=function(e){const{question:t}=e,s={"instant-check":()=>(0,r.createElement)(m,{type:"check",Button:S,question:t}),hint:()=>(0,r.createElement)(m,{type:"hint",Button:_,question:t})};return(0,r.createElement)(r.Fragment,null,LP.config.questionFooterButtons().map((e=>(0,r.createElement)(r.Fragment,{key:`button-${e}`},s[e]&&s[e]()))))};const E=window.jQuery,{uniqueId:z,isArray:b,isNumber:k,bind:P}=lodash;class Q extends r.Component{constructor(){super(...arguments),i(this,"setRef",(e=>{this.$wrap=E(e)})),i(this,"parseOptions",(e=>(e&&(e=b(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=b(e)?e:JSON.parse(e)),e||[]))),i(this,"getWrapperClass",(()=>{const{question:e,answered:t}=this.props,s=["question","question-"+e.type],n=this.parseOptions(e.options);return n.length&&void 0!==n[0].isTrue&&s.push("question-answered"),s})),i(this,"getEditLink",(()=>{const{question:e,editPermalink:t}=this.props;return t?t.replace(/post=(.*[0-9])/,`post=${e.id}`):""})),i(this,"editPermalink",(e=>(0,u.sprintf)('<a href="%s">%s</a>',e,(0,u.__)("Edit","learnpress")))),this.state={time:null,showHint:!1},this.$wrap=null}componentDidMount(e){const{question:t,isCurrent:s,markQuestionRendered:n}=this.props;return s&&n(t.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]),e}render(){const{question:e,isShow:t,isShowIndex:s,isShowHint:n,status:i}=this.props,o=LP.questionTypes.default,a=this.getEditLink();a&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",a);const l={index:()=>s?(0,r.createElement)("span",{className:"question-index"},s,"."):"",title:()=>(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:e.title}}),hint:()=>(0,r.createElement)(_,{question:e}),"edit-permalink":()=>a&&(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:this.editPermalink(a)},className:"edit-link"})},c={title:()=>(0,r.createElement)("h4",{className:"question-title"},LP.config.questionTitleParts().map((e=>(0,r.createElement)(r.Fragment,{key:`title-part-${e}`},l[e]&&l[e]())))),content:()=>(0,r.createElement)("div",{className:"question-content",dangerouslySetInnerHTML:{__html:e.content}}),"answer-options":()=>this.$wrap&&(0,r.createElement)(o,g({},this.props,{$wrap:this.$wrap})),explanation:()=>e.explanation&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-explanation-content"},(0,r.createElement)("strong",{className:"explanation-title"},(0,u.__)("Explanation","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.explanation}}))),hint:()=>e.hint&&!e.explanation&&e.showHint&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-hint-content"},(0,r.createElement)("strong",{className:"hint-title"},(0,u.__)("Hint","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.hint}}))),buttons:()=>"started"===i&&(0,r.createElement)(y,{question:e})},d=LP.config.questionBlocks();return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:this.getWrapperClass().join(" "),style:{display:t?"":"none"},"data-id":e.id,ref:this.setRef},d.map((e=>(0,r.createElement)(r.Fragment,{key:`block-${e}`},c[e]?c[e]():"")))))}}var N=(0,o.compose)([(0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getData:n,getQuestionAnswered:r,getQuestionMark:i}=e("learnpress/quiz");return{status:n("status"),questions:n("question"),answered:r(s),questionsRendered:n("questionsRendered"),editPermalink:n("editPermalink"),numPages:n("numPages"),mark:i(s)||""}})),(0,a.withDispatch)((e=>{const{updateUserQuestionAnswers:t,markQuestionRendered:s}=e("learnpress/quiz");return{markQuestionRendered:s,updateUserQuestionAnswers:t}}))])(Q);class I extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{e.preventDefault();const{startQuiz:t}=this.props;t()})),i(this,"isInVisibleRange",((e,t)=>{const{currentPage:s,questionsPerPage:n}=this.props;return s===Math.ceil(t/n)})),i(this,"nav",(e=>{const{sendKey:t}=this.props;switch(e.keyCode){case 37:return t("left");case 38:case 40:return;case 39:return t("right");default:e.keyCode>=49&&e.keyCode<=57&&t(e.keyCode-48)}})),this.needToTop=!1,this.state={isReviewing:null,currentPage:0,self:this}}static getDerivedStateFromProps(e,t){const s=["isReviewing","currentPage"],n={};for(let r=0;r<s.length;r++)e[s[r]]!==t[s[r]]&&(n[s[r]]=e[s[r]]);return Object.values(n).length?(t.self.needToTop=!0,n):null}componentDidUpdate(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}render(){const{status:e,currentQuestion:t,questions:s,questionsRendered:n,isReviewing:i,questionsPerPage:o}=this.props;let a=!0;return"completed"!==e||i||(a=!1),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{tabIndex:100,onKeyUp:this.nav},(0,r.createElement)("div",{className:"quiz-questions",style:{display:a?"":"none"}},s.map(((e,s)=>{const i=!o&&t===e.id,a=n&&-1!==n.indexOf(e.id),u=this.isInVisibleRange(e.id,s+1);return a||!a||u?(0,r.createElement)(N,{key:`loop-question-${e.id}`,isCurrent:i,isShow:u,isShowIndex:!!o&&s+1,questionsPerPage:o,question:e}):""})))))}}var C=(0,o.compose)((0,a.withSelect)(((e,t,s)=>{const{getData:n,getQuestions:r}=e("learnpress/quiz");return{status:n("status"),currentQuestion:n("currentQuestion"),questions:r(),questionsRendered:n("questionsRendered"),isReviewing:"reviewing"===n("mode"),numPages:n("numPages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{startQuiz:t,sendKey:s}=e("learnpress/quiz");return{startQuiz:t,sendKey:s}})))(I),A=()=>{const e=(0,a.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"quiz-attempts"},(0,r.createElement)("h4",{className:"attempts-heading"},(0,u.__)("Last Attempted","learnpress")),t&&(0,r.createElement)("table",null,(0,r.createElement)("thead",null,(0,r.createElement)("tr",null,(0,r.createElement)("th",{className:"quiz-attempts__questions"},(0,u.__)("Questions","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__spend"},(0,u.__)("Time spent","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__marks"},(0,u.__)("Marks","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__grade"},(0,u.__)("Passing grade","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__result"},(0,u.__)("Result","learnpress")))),(0,r.createElement)("tbody",null,e.map(((e,t)=>(0,r.createElement)("tr",{key:`attempt-${t}`},(0,r.createElement)("td",{className:"quiz-attempts__questions"},`${e.questionCorrect} / ${e.questionCount}`),(0,r.createElement)("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),(0,r.createElement)("td",{className:"quiz-attempts__marks"},`${e.userMark} / ${e.mark}`),(0,r.createElement)("td",{className:"quiz-attempts__grade"},e.passingGrade||"-"),(0,r.createElement)("td",{className:"quiz-attempts__result"},`${parseFloat(e.result).toFixed(2)}%`," ",(0,r.createElement)("span",null,e.graduationText)))))))))},T=()=>{const{getData:e}=(0,a.select)("learnpress/quiz"),{submitQuiz:t}=(0,a.dispatch)("learnpress/quiz"),s=e("totalTime"),n=e("duration"),[i,o]=(0,r.useState)(s);let[u,l]=(0,r.useState)(0);return(0,r.useEffect)((()=>{const e=setInterval((()=>{if(n>0){let s=i;s-=1,s>0?(o(s),u++,l(n-s)):(clearInterval(e),t())}else u++,l(u),o(u)}),1e3);return()=>clearInterval(e)}),[i,u]),(0,r.createElement)("div",{className:"countdown"},(0,r.createElement)("i",{className:"fas fa-stopwatch"}),(0,r.createElement)("span",null,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";const t=[];let n;return s<3600?(t.push((i-i%60)/60),t.push(i%60)):s&&(t.push((i-i%3600)/3600),n=i%3600,t.push((n-n%60)/60),t.push(n%60)),t.map((e=>e<10?`0${e}`:e)).join(e)}()),(0,r.createElement)("input",{type:"hidden",name:"lp-quiz-time-spend",value:u}))},R=window.wp.url;const O=jQuery;let L=null;const x={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=O(".lp-overlay"),!!this.elLPOverlay.length&&(L=this.elLPOverlay,this.elMainContent=L.find(".main-content"),this.elTitle=L.find(".modal-title"),this.elBtnYes=L.find(".btn-yes"),this.elBtnNo=L.find(".btn-no"),this.elFooter=L.find(".lp-modal-footer"),O(document).on("click",".close, .btn-no",(function(){L.hide()})),O(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof x.callBackYes&&x.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var D=x,M={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){D.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})))))}};const{debounce:H}=lodash;var F=()=>{const[e,t]=(0,r.useState)(0),[s,n]=(0,r.useState)(!1),i=(0,a.useSelect)((e=>e("learnpress/quiz").getData("id")),[]),o=(0,a.useSelect)((e=>e("learnpress/quiz").getData("results")),[]),l=(0,a.useSelect)((e=>e("learnpress/quiz").getData("passingGrade")),[]),c=(0,a.useSelect)((e=>e("learnpress/quiz").getData("submitting")),[]);(0,r.useEffect)((()=>{p();let e="";if(e=o.graduation?o.graduation:o.result>=f?"passed":"failed",e){const t=document.querySelector(`.course-curriculum .course-item.course-item-${i}`);t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}const t=[...document.querySelectorAll("#popup-header .items-progress")][0],s=document.querySelector(".curriculum-sections");if(t&&s){const e=t.dataset.totalItems,s=t.querySelector(".items-completed"),n=t.querySelector(".learn-press-progress__active");if(s){const t=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");s.textContent=parseInt(t.length);const r=100-100*parseInt(t.length)/parseInt(e);n.style.left="-"+r+"%"}}}),[o]),(0,r.useEffect)((()=>{void 0!==c&&d()}),[c]);const d=()=>{const e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&(async e=>{const t=await wp.apiFetch({path:(0,R.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"}),{data:s}=t;e.innerHTML+=s,M.init()})(e[0])},p=()=>{t(0),n(!1),jQuery.easing._customEasing=function(e,t,s,n,r){return n*Math.sqrt(1-(t=t/r-1)*t)+s},H((()=>{const e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:o.result},{duration:1500,step:(e,s)=>{t(e)},done:()=>{n(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),H((()=>{jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),o.result>0?1e3:10)()};let m=e;Number.isInteger(e)||(m=parseFloat(e).toFixed(2));const h=190*Math.PI,g={strokeDasharray:`${h} ${h}`,strokeDashoffset:h-m/100*h},f=parseFloat(o.passingGrade||l);let _="";_=o.graduation?o.graduation:m>=f?"passed":"failed";let q="";q=o.graduationText?o.graduationText:"passed"===_?(0,u.__)("Passed","learnpress"):(0,u.__)("Failed","learnpress");const w=["quiz-result",_];return(0,r.createElement)("div",{className:w.join(" ")},(0,r.createElement)("h3",{className:"result-heading"},(0,u.__)("Your Result","learnpress")),(0,r.createElement)("div",{id:"quizResultGrade",className:"result-grade"},(0,r.createElement)("svg",{className:"circle-progress-bar",width:200,height:200},(0,r.createElement)("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),(0,r.createElement)("span",{className:"result-achieved"},`${m}%`),(0,r.createElement)("span",{className:"result-require"},f+"%"||0)),s&&(0,r.createElement)("p",{className:"result-message"},q),(0,r.createElement)("ul",{className:"result-statistic"},(0,r.createElement)("li",{className:"result-statistic-field result-time-spend"},(0,r.createElement)("span",null,(0,u.__)("Time spent","learnpress")),(0,r.createElement)("p",null,o.timeSpend)),(0,r.createElement)("li",{className:"result-statistic-field result-point"},(0,r.createElement)("span",null,(0,u.__)("Points","learnpress")),(0,r.createElement)("p",null,o.userMark," / ",o.mark)),(0,r.createElement)("li",{className:"result-statistic-field result-questions"},(0,r.createElement)("span",null,(0,u.__)("Questions","learnpress")),(0,r.createElement)("p",null,o.questionCount)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-correct"},(0,r.createElement)("span",null,(0,u.__)("Correct","learnpress")),(0,r.createElement)("p",null,o.questionCorrect)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-wrong"},(0,r.createElement)("span",null,(0,u.__)("Wrong","learnpress")),(0,r.createElement)("p",null,o.questionWrong)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-skipped"},(0,r.createElement)("span",null,(0,u.__)("Skipped","learnpress")),(0,r.createElement)("p",null,o.questionEmpty))))};const U=jQuery,{debounce:$}=lodash;var j=()=>{const{submitQuiz:e}=(0,a.dispatch)("learnpress/quiz");(0,r.useEffect)((()=>{const e=U("#popup-content");if(!e.length)return;const t=e.find(".content-item-scrollable:eq(1)"),s=e.find(".content-item-wrap"),n=e.find(".quiz-status"),r=n.offset().top-92;let i=!1,o="-"+s.css("margin-left");U(window).on("resize.refresh-quiz-stauts-bar",$((function(){o="-"+s.css("margin-left"),n.css({"margin-left":o,"margin-right":o})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(()=>{if(t.scrollTop()>=r){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}),[]);const t=()=>{const{confirm:s}=(0,a.select)("learnpress/modal");"no"!==s((0,u.__)("Are you sure to submit quiz?","learnpress"),t)&&e()},{getData:s,getUserMark:n}=(0,a.select)("learnpress/quiz"),i=s("currentPage"),o=s("questionsPerPage"),l=s("questionIds").length,c=s("submitting"),d=(s("duration"),n()),p=["quiz-status"],m=(i-1)*o+1;let h=m+o-1,g="";return h=Math.min(h,l),c&&p.push("submitting"),g=h<l?o>1?(0,u.sprintf)((0,u.__)("Question <span>%d to %d of %d</span>","learnpress"),m,h,l):(0,u.sprintf)((0,u.__)("Question <span>%d of %d</span>","learnpress"),m,l):(0,u.sprintf)((0,u.__)("Question <span>%d to %d</span>","learnpress"),m,h),(0,r.createElement)("div",{className:p.join(" ")},(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:g}}),(0,r.createElement)("div",{className:"current-point"},(0,u.sprintf)((0,u.__)("Earned Point: %s","learnpress"),d)),(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"submit-quiz"},(0,r.createElement)("button",{className:"lp-button",id:"button-submit-quiz",onClick:t},c?(0,u.__)("Submitting...","learnpress"):(0,u.__)("Finish Quiz","learnpress"))),(0,r.createElement)(T,null))))};const{omit:B,flow:J,isArray:G,chunk:K}=lodash,{camelCaseDashObjectKeys:W}=LP,{get:Z,set:Y}=LP.localStorage,V={},X=(e,t)=>{const{answered:s,id:n}=e,r={...s[t.questionId]||{},answered:t.answers,temp:!0};return n&&localStorage.setItem(`LP_Quiz_${n}_Answered`,JSON.stringify({...e.answered,[t.questionId]:r})),{...e,answered:{...e.answered,[t.questionId]:r}}},ee=(e,t)=>{const{questionsRendered:s}=e;return G(s)?(s.push(t.questionId),{...e,questionsRendered:[...s]}):{...e,questionsRendered:[t.questionId]}},te=(e,t)=>(t.currentPage&&Y(`Q${e.id}.currentPage`,t.currentPage),{...e,...t}),se=(e,t)=>{const s=e.questions.map((e=>e.id==t.questionId?{...e,showHint:t.showHint}:e));return{...e,questions:[...s]}},ne=(e,t)=>{const s=e.questions.map((e=>{if(e.id!==t.questionId)return e;const s={explanation:t.explanation};return t.options&&(s.options=t.options),{...e,...s}})),n={...e.answered,[t.questionId]:t.result};let r=localStorage.getItem(`LP_Quiz_${e.id}_Answered`);return r&&(r={...JSON.parse(r),...n},localStorage.setItem(`LP_Quiz_${e.id}_Answered`,JSON.stringify(r))),{...e,questions:[...s],answered:n,checkedQuestions:[...e.checkedQuestions,t.questionId]}},re=(e,t)=>{localStorage.removeItem(`LP_Quiz_${e.id}_Answered`);const s=e.questions.map((s=>{const n={};return e.reviewQuestions&&(t.results.questions[s.id].explanation&&(n.explanation=t.results.questions[s.id].explanation),t.results.questions[s.id].options&&(n.options=t.results.questions[s.id].options)),{...s,...n}}));return te(e,{submitting:!1,currentPage:1,...t.results,questions:[...s]})},ie=(e,t)=>{const s=void 0!==t.results.success&&t.results.success,n=t.results.message||!1;return te(e,{checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1,...t.results.results,successResponse:s,messageResponse:n})},oe=J(a.combineReducers,(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)))({a(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1}},b(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2}}});var ae=(0,a.combineReducers)({blocks:oe,userQuiz:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);const s=K(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=s.length,t.data.pages=s,{...e,...t.data,currentPage:Z(`Q${t.data.id}.currentPage`)||t.data.currentPage};case"SUBMIT_QUIZ":return{...e,submitting:!0};case"START_QUIZ":case"START_QUIZ_SUCCESS":return ie(e,t);case"SET_CURRENT_QUESTION":return Y(`Q${e.id}.currentQuestion`,t.questionId),{...e,currentQuestion:t.questionId};case"SET_CURRENT_PAGE":return Y(`Q${e.id}.currentPage`,t.currentPage),{...e,currentPage:t.currentPage};case"SUBMIT_QUIZ_SUCCESS":return re(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?X(e,t):e;case"MARK_QUESTION_RENDERED":return ee(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?te(e,{mode:t.mode}):{...e,mode:t.mode};case"SET_QUESTION_HINT":return se(e,t);case"CHECK_ANSWER":return ne(e,t);case"SEND_KEY":return{...e,keyPressed:t.keyPressed}}return e}}),ue=window.LP.dataControls;function le(){const e=[].slice.call(arguments,2),t=(0,a.dispatch)(arguments[0]),s=arguments[1];t[s](...e)}const{camelCaseDashObjectKeys:ce,Hook:de}=LP;function pe(e,t){return{type:"SET_QUIZ_DATA",data:ce(t="string"==typeof e?{[e]:t}:e)}}function me(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function he(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function ge(e,t,s){return{type:"BEFORE_START_QUIZ"}}function fe(e,t,s,n){return de.doAction("quiz-started",e,t,s,n),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:s,userId:n,results:e}}const _e=function*(){const{itemId:e,courseId:t}=(0,a.select)("learnpress/quiz").getDefaultRestArgs();if(!0!==de.applyFilters("before-start-quiz",!0,e,t))return;let s=yield(0,ue.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:e,course_id:t}});const n=document.querySelector(".lp-button.start");if("error"!==s.status){if(s=de.applyFilters("request-start-quiz-response",s,e,t),1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id;window.localStorage.removeItem(e);const t={endTime:Date.now()+1e3*s.results.duration,status:s.results.status};window.localStorage.setItem(e,JSON.stringify(t));const n="quiz_off_retaken_"+lpQuizSettings.id;let r=window.localStorage.getItem(n);null===r?r=0:r++,window.localStorage.setItem(n,r)}yield le("learnpress/quiz","__requestStartQuizSuccess",ce(s),e,t)}else{const e=document.querySelector(".quiz-buttons"),t=`<div class="learn-press-message error">${s.message}</div>`;e.insertAdjacentHTML("afterend",t),n.classList.remove("loading")}};function qe(){return{type:"SUBMIT_QUIZ"}}function we(e,t,s){return de.doAction("quiz-submitted",e,t,s),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function*ve(){const{getDefaultRestArgs:e,getQuestionsSelectedAnswers:t}=(0,a.select)("learnpress/quiz"),{itemId:s,courseId:n}=e();if(!0!==de.applyFilters("before-submit-quiz",!0))return;const r=t();if(1===lpQuizSettings.checkNorequizenroll){const e=`LP_Quiz_${s}_Answered`,t=localStorage.getItem(e);if(null!==t){const e=JSON.parse(t);for(const[t,s]of Object.entries(e))r[t]=s.answered}}let i=0;const o=document.querySelector("input[name=lp-quiz-time-spend]");o&&(i=o.value);let u=yield(0,ue.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:s,course_id:n,answered:r,time_spend:i}});if(u=de.applyFilters("request-submit-quiz-response",u,s,n),"success"===u.status){if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,t=window.localStorage.getItem(e);if(null!==t){const s=JSON.parse(t);s.status=u.results.status,s.results=u.results.results,window.localStorage.setItem(e,JSON.stringify(s)),window.localStorage.removeItem("LP_Quiz_"+lpQuizSettings.id+"_Answered")}}yield le("learnpress/quiz","__requestSubmitQuizSuccess",ce(u.results),s,n)}}function Se(e,t,s){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function ye(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function*Ee(e,t){yield le("learnpress/quiz","__requestShowHintSuccess",e,t)}function ze(e,t){return{type:"CHECK_ANSWER",questionId:e,...t}}function*be(e){const{getDefaultRestArgs:t,getQuestionAnswered:s}=(0,a.select)("learnpress/quiz"),{itemId:n,courseId:r}=t(),i=yield(0,ue.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:n,course_id:r,question_id:e,answered:s(e)||""}});if("success"===i.status){if(1===lpQuizSettings.checkNorequizenroll){const t="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(t);if(null!==s){const n=JSON.parse(s),r=i.options;void 0===n.checked_questions?(n.checked_questions=[],n.checked_questions.push(e)):-1===n.checked_questions.indexOf(e)&&n.checked_questions.push(e),void 0===n.question_options?(n.question_options={},n.question_options[e]=r):void 0===n.question_options[e]&&(n.question_options[e]=r),window.localStorage.setItem(t,JSON.stringify(n))}}yield le("learnpress/quiz","__requestCheckAnswerSuccess",e,ce(i))}}function ke(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Pe(e){return{type:"SET_QUIZ_MODE",mode:e}}function Qe(e){return setTimeout((()=>{le("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}const{get:Ne,isArray:Ie}=lodash,Ce=function(e,t){console.time("parseOptions");let s=Ue(e,t).options;return s=Ie(s)?s:JSON.parse(CryptoJS.AES.decrypt(s.data,s.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),s=Ie(s)?s:JSON.parse(s),console.timeEnd("parseOptions"),s};function Ae(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.status"):""}function Te(e,t,s){return e[t]||s}function Re(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.attempts"):[]}function Oe(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.answered",{}):{}}function Le(e){const{userQuiz:t}=e,s=Ne(t,"questions");return s?Object.values(s):[]}function xe(e,t){const{userQuiz:s}=e;return t?Ne(s,t):s}function De(e){const{userQuiz:t}=e;return{itemId:t.id,courseId:t.courseId}}function Me(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.answered`)||void 0}function He(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.mark`)||void 0}function Fe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=Ne(e,"userQuiz.questionsPerPage")||1;if(s>1)return!1;const n=Ne(e,"userQuiz.currentPage")||1;return Ne(e,"object"===t?`userQuiz.questions[${n-1}]`:`userQuiz.questionIds[${n-1}]`)}const Ue=function(e,t){const{userQuiz:s}=e;return(0,a.select)("learnpress/quiz").getQuestions().find((e=>e.id==t))};function $e(e,t){return-1!==(Ne(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function je(e,t){}const Be=function(e,t){const s=Ne(e,"userQuiz.answered"),n={};for(const e in s)if(s.hasOwnProperty(e)&&(s[e].temp||s[e].blanks)){if(t&&e===t)return s[e].answered;n[e]=s[e].answered}return n};function Je(e){const t=e.userQuiz||{},{answered:s,negativeMarking:n,questions:r,checkedQuestions:i}=t;let o=0;for(let e in s){if(!s.hasOwnProperty(e))continue;e=parseInt(e);const t=s[e],a=t.questionMark?t.questionMark:function(){const t=r.find((t=>t.id===e));return t?t.point:0}();i.indexOf(e),t.temp||(n?t.answered&&(o=t.correct?o+t.mark:o-a):t.answered&&t.correct&&(o+=t.mark))}return o>0?o:0}var Ge=s(965),Ke=s.n(Ge);const We={ENROLL_COURSE_X:(e,t)=>{}};const{controls:Ze}=LP.dataControls;!function(e){let t=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:e.getState,dispatch:function(){return t(...arguments)}};t=Ke()(We)(s)(e.dispatch),e.dispatch=t}((0,a.registerStore)("learnpress/quiz",{reducer:ae,selectors:t,actions:e,controls:{...Ze}}));const{chunk:Ye}=lodash;class Ve extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{this.props.startQuiz()})),this.state={currentPage:1,numPages:0,pages:[]}}componentDidMount(){const{settings:e,setQuizData:t}=this.props,{question_ids:s,questions_per_page:n}=e,r=Ye(s,n);e.currentPage=1,e.numPages=r.length,e.pages=r;const i=!!e.id&&localStorage.getItem(`LP_Quiz_${e.id}_Answered`);i&&(e.answered=JSON.parse(i)),t(e)}componentDidUpdate(e,t,s){const{status:n}=e,r=document.querySelector(".quiz-content");void 0!==n&&r&&(r.style.display="none")}render(){const{status:e,isReviewing:t}=this.props,s=-1!==["","completed","viewed"].indexOf(e)||!e,n=-1!==["","viewed",void 0].indexOf(e)||!e;return void 0!==e&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",null,!t&&"completed"===e&&(0,r.createElement)(F,null),!t&&n&&(0,r.createElement)(d,null),"started"===e&&(0,r.createElement)(j,null),(-1!==["completed","started"].indexOf(e)||t)&&(0,r.createElement)(C,null),(0,r.createElement)(h,null),s&&!t&&(0,r.createElement)(A,null)))}}var Xe=(0,o.compose)([(0,a.withSelect)((e=>{const{getQuestions:t,getData:s}=e("learnpress/quiz");return{questions:t(),status:s("status"),store:s(),answered:s("answered"),isReviewing:"reviewing"===s("mode"),questionIds:s("questionIds"),checkCount:s("instantCheck"),questionsPerPage:s("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{setQuizData:t,startQuiz:s}=e("learnpress/quiz");return{setQuizData:t,startQuiz:s}}))])(Ve);s(605);const{modal:{default:et}}=LP;var tt=Xe;const st=(e,t)=>{if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(e);if(null!==s){const e=JSON.parse(s);if(t.status=e.status,"started"===e.status){const s=Date.now();t.total_time=Math.floor((e.endTime-s)/1e3)}else"completed"===e.status&&(t.results=e.results,t.answered=e.results.answered,t.questions=e.results.questions);if(void 0!==e.checked_questions&&(t.checked_questions=e.checked_questions),void 0!==e.question_options)for(const s in t.questions){let n=t.questions[s];void 0!==e.question_options[n.id]&&(n.options=e.question_options[n.id]),t.questions[s]=n}}}wp.element.render((0,r.createElement)(et,null,(0,r.createElement)(Xe,{settings:t})),[...document.querySelectorAll(e)][0]),LP.Hook.doAction("lp-quiz-compatible-builder")}}(),(window.LP=window.LP||{}).quiz=n}();
assets/js/vendor/plugins.all.js CHANGED
@@ -1,359 +1 @@
1
- if (!Object.prototype.watchChange) {
2
- var isFunction = function (fn) {
3
- return fn && {}.toString.call(fn) === '[object Function]';
4
- };
5
- Object.defineProperty(
6
- Object.prototype,
7
- 'watchChange',
8
- {
9
- enumerable: false,
10
- configurable: true,
11
- writable: false,
12
- value: function (prop, handler) {
13
- var obj = this;
14
-
15
- function x(prop, handler) {
16
- var oldval = obj[prop],
17
- newval = oldval,
18
- getter = function () {
19
- return newval;
20
- },
21
- setter = function (val) {
22
- return newval = handler.call(obj, prop, oldval, val);
23
- };
24
-
25
- if (delete obj[prop]) {
26
- Object.defineProperty(
27
- obj,
28
- prop,
29
- {
30
- get: getter,
31
- set: setter,
32
- enumerable: true,
33
- configurable: true
34
- }
35
- );
36
- }
37
- }
38
-
39
- if (isFunction(prop)) {
40
- for (var k in this) {
41
- new x(k, prop);
42
- }
43
- } else {
44
- new x(prop, handler)
45
- }
46
- }
47
- });
48
- }
49
-
50
- if (!Object.prototype.unwatchChange) {
51
- Object.defineProperty(
52
- Object.prototype,
53
- 'unwatchChange',
54
- {
55
- enumerable: false,
56
- configurable: true,
57
- writable: false,
58
- value: function (prop) {
59
- var val = this[prop];
60
- delete this[prop];
61
- this[prop] = val;
62
- }
63
- }
64
- );
65
- }
66
- /*!
67
- * jQuery.scrollTo
68
- * Copyright (c) 2007-2015 Ariel Flesler - aflesler ○ gmail • com | http://flesler.blogspot.com
69
- * Licensed under MIT
70
- * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
71
- * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
72
- * @author Ariel Flesler
73
- * @version 2.1.2
74
- */
75
- ;(function(factory) {
76
- 'use strict';
77
- if (typeof define === 'function' && define.amd) {
78
- // AMD
79
- define(['jquery'], factory);
80
- } else if (typeof module !== 'undefined' && module.exports) {
81
- // CommonJS
82
- module.exports = factory(require('jquery'));
83
- } else {
84
- // Global
85
- factory(jQuery);
86
- }
87
- })(function($) {
88
- 'use strict';
89
-
90
- var $scrollTo = $.scrollTo = function(target, duration, settings) {
91
- return $(window).scrollTo(target, duration, settings);
92
- };
93
-
94
- $scrollTo.defaults = {
95
- axis:'xy',
96
- duration: 0,
97
- limit:true
98
- };
99
-
100
- function isWin(elem) {
101
- return !elem.nodeName ||
102
- $.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1;
103
- }
104
-
105
- $.fn.scrollTo = function(target, duration, settings) {
106
- if (typeof duration === 'object') {
107
- settings = duration;
108
- duration = 0;
109
- }
110
- if (typeof settings === 'function') {
111
- settings = { onAfter:settings };
112
- }
113
- if (target === 'max') {
114
- target = 9e9;
115
- }
116
-
117
- settings = $.extend({}, $scrollTo.defaults, settings);
118
- // Speed is still recognized for backwards compatibility
119
- duration = duration || settings.duration;
120
- // Make sure the settings are given right
121
- var queue = settings.queue && settings.axis.length > 1;
122
- if (queue) {
123
- // Let's keep the overall duration
124
- duration /= 2;
125
- }
126
- settings.offset = both(settings.offset);
127
- settings.over = both(settings.over);
128
-
129
- return this.each(function() {
130
- // Null target yields nothing, just like jQuery does
131
- if (target === null) return;
132
-
133
- var win = isWin(this),
134
- elem = win ? this.contentWindow || window : this,
135
- $elem = $(elem),
136
- targ = target,
137
- attr = {},
138
- toff;
139
-
140
- switch (typeof targ) {
141
- // A number will pass the regex
142
- case 'number':
143
- case 'string':
144
- if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
145
- targ = both(targ);
146
- // We are done
147
- break;
148
- }
149
- // Relative/Absolute selector
150
- targ = win ? $(targ) : $(targ, elem);
151
- /* falls through */
152
- case 'object':
153
- if (targ.length === 0) return;
154
- // DOMElement / jQuery
155
- if (targ.is || targ.style) {
156
- // Get the real position of the target
157
- toff = (targ = $(targ)).offset();
158
- }
159
- }
160
-
161
- var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
162
-
163
- $.each(settings.axis.split(''), function(i, axis) {
164
- var Pos = axis === 'x' ? 'Left' : 'Top',
165
- pos = Pos.toLowerCase(),
166
- key = 'scroll' + Pos,
167
- prev = $elem[key](),
168
- max = $scrollTo.max(elem, axis);
169
-
170
- if (toff) {// jQuery / DOMElement
171
- attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]);
172
-
173
- // If it's a dom element, reduce the margin
174
- if (settings.margin) {
175
- attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0;
176
- attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0;
177
- }
178
-
179
- attr[key] += offset[pos] || 0;
180
-
181
- if (settings.over[pos]) {
182
- // Scroll to a fraction of its width/height
183
- attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos];
184
- }
185
- } else {
186
- var val = targ[pos];
187
- // Handle percentage values
188
- attr[key] = val.slice && val.slice(-1) === '%' ?
189
- parseFloat(val) / 100 * max
190
- : val;
191
- }
192
-
193
- // Number or 'number'
194
- if (settings.limit && /^\d+$/.test(attr[key])) {
195
- // Check the limits
196
- attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
197
- }
198
-
199
- // Don't waste time animating, if there's no need.
200
- if (!i && settings.axis.length > 1) {
201
- if (prev === attr[key]) {
202
- // No animation needed
203
- attr = {};
204
- } else if (queue) {
205
- // Intermediate animation
206
- animate(settings.onAfterFirst);
207
- // Don't animate this axis again in the next iteration.
208
- attr = {};
209
- }
210
- }
211
- });
212
-
213
- animate(settings.onAfter);
214
-
215
- function animate(callback) {
216
- var opts = $.extend({}, settings, {
217
- // The queue setting conflicts with animate()
218
- // Force it to always be true
219
- queue: true,
220
- duration: duration,
221
- complete: callback && function() {
222
- callback.call(elem, targ, settings);
223
- }
224
- });
225
- $elem.animate(attr, opts);
226
- }
227
- });
228
- };
229
-
230
- // Max scrolling position, works on quirks mode
231
- // It only fails (not too badly) on IE, quirks mode.
232
- $scrollTo.max = function(elem, axis) {
233
- var Dim = axis === 'x' ? 'Width' : 'Height',
234
- scroll = 'scroll'+Dim;
235
-
236
- if (!isWin(elem))
237
- return elem[scroll] - $(elem)[Dim.toLowerCase()]();
238
-
239
- var size = 'client' + Dim,
240
- doc = elem.ownerDocument || elem.document,
241
- html = doc.documentElement,
242
- body = doc.body;
243
-
244
- return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
245
- };
246
-
247
- function both(val) {
248
- return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
249
- }
250
-
251
- // Add special hooks so that window scroll properties can be animated
252
- $.Tween.propHooks.scrollLeft =
253
- $.Tween.propHooks.scrollTop = {
254
- get: function(t) {
255
- return $(t.elem)[t.prop]();
256
- },
257
- set: function(t) {
258
- var curr = this.get(t);
259
- // If interrupt is true and user scrolled, stop animating
260
- if (t.options.interrupt && t._last && t._last !== curr) {
261
- return $(t.elem).stop();
262
- }
263
- var next = Math.round(t.now);
264
- // Don't waste CPU
265
- // Browsers don't render floating point scroll
266
- if (curr !== next) {
267
- $(t.elem)[t.prop](next);
268
- t._last = this.get(t);
269
- }
270
- }
271
- };
272
-
273
- // AMD requirement
274
- return $scrollTo;
275
- });
276
- (function (e) {
277
- e.backward_timer = function (t) {
278
- var n = {seconds: 5, step: 1, format: "h%:m%:s%", value_setter: undefined, on_exhausted: function (e) {
279
- }, on_tick : function (e) {
280
- }}, r = this;
281
- r.seconds_left = 0;
282
- r.target = e(t);
283
- r.timeout = undefined;
284
- r.settings = {};
285
- r.methods = {init : function (t) {
286
- r.settings = e.extend({}, n, t);
287
- if (r.settings.value_setter == undefined) {
288
- if (r.target.is("input")) {
289
- r.settings.value_setter = "val"
290
- } else {
291
- r.settings.value_setter = "text"
292
- }
293
- }
294
- r.methods.reset()
295
- }, start : function () {
296
- if (r.timeout == undefined) {
297
- var e = r.seconds_left == r.settings.seconds ? 0 : r.settings.step * 1e3;
298
- setTimeout(r.methods._on_tick, e, e)
299
- }
300
- }, cancel : function () {
301
- if (r.timeout != undefined) {
302
- clearTimeout(r.timeout);
303
- r.timeout = undefined
304
- }
305
- }, reset : function () {
306
- r.seconds_left = r.settings.seconds;
307
- r.methods._render_seconds()
308
- }, _on_tick : function (e) {
309
- if (e != 0) {
310
- r.settings.on_tick(r)
311
- }
312
- r.methods._render_seconds();
313
- if (r.seconds_left > 0) {
314
- if (r.seconds_left < r.settings.step) {
315
- var t = r.seconds_left
316
- } else {
317
- var t = r.settings.step
318
- }
319
- r.seconds_left -= t;
320
- var n = t * 1e3;
321
- r.timeout = setTimeout(r.methods._on_tick, n, n)
322
- } else {
323
- r.timeout = undefined;
324
- r.settings.on_exhausted(r)
325
- }
326
- }, _render_seconds : function () {
327
- var e = r.methods._seconds_to_dhms(r.seconds_left), t = r.settings.format;
328
- if (t.indexOf("d%") !== -1) {
329
- t = t.replace("d%", e.d).replace("h%", r.methods._check_leading_zero(e.h))
330
- } else {
331
- t = t.replace("h%", e.d * 24 + e.h)
332
- }
333
- t = t.replace("m%", r.methods._check_leading_zero(e.m)).replace("s%", r.methods._check_leading_zero(e.s));
334
- r.target[r.settings.value_setter](t)
335
- }, _seconds_to_dhms : function (e) {
336
- var t = Math.floor(e / (24 * 3600)), e = e - t * 24 * 3600, n = Math.floor(e / 3600), e = e - n * 3600, r = Math.floor(e / 60), i = Math.floor(e - r * 60);
337
- return{d: t, h: n, m: r, s: i}
338
- }, _check_leading_zero: function (e) {
339
- return e < 10 ? "0" + e : "" + e
340
- }}
341
- };
342
- e.fn.backward_timer = function (t) {
343
- var n = arguments;
344
- return this.each(function () {
345
- var r = e(this).data("backward_timer");
346
- if (r == undefined) {
347
- r = new e.backward_timer(this);
348
- e(this).data("backward_timer", r)
349
- }
350
- if (r.methods[t]) {
351
- return r.methods[t].apply(this, Array.prototype.slice.call(n, 1))
352
- } else if (typeof t === "object" || !t) {
353
- return r.methods.init.apply(this, n)
354
- } else {
355
- e.error("Method " + t + " does not exist on jQuery.backward_timer")
356
- }
357
- })
358
- }
359
- })(jQuery);
1
+ if(!Object.prototype.watchChange){var isFunction=function(e){return e&&"[object Function]"==={}.toString.call(e)};Object.defineProperty(Object.prototype,"watchChange",{enumerable:!1,configurable:!0,writable:!1,value:function(e,t){var n=this;function o(e,t){var o=n[e],s=o;delete n[e]&&Object.defineProperty(n,e,{get:function(){return s},set:function(r){return s=t.call(n,e,o,r)},enumerable:!0,configurable:!0})}if(isFunction(e))for(var s in this)new o(s,e);else new o(e,t)}})}Object.prototype.unwatchChange||Object.defineProperty(Object.prototype,"unwatchChange",{enumerable:!1,configurable:!0,writable:!1,value:function(e){var t=this[e];delete this[e],this[e]=t}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}((function(e){"use strict";var t=e.scrollTo=function(t,n,o){return e(window).scrollTo(t,n,o)};function n(t){return!t.nodeName||-1!==e.inArray(t.nodeName.toLowerCase(),["iframe","#document","html","body"])}function o(t){return e.isFunction(t)||e.isPlainObject(t)?t:{top:t,left:t}}return t.defaults={axis:"xy",duration:0,limit:!0},e.fn.scrollTo=function(s,r,i){"object"==typeof r&&(i=r,r=0),"function"==typeof i&&(i={onAfter:i}),"max"===s&&(s=9e9),i=e.extend({},t.defaults,i),r=r||i.duration;var a=i.queue&&i.axis.length>1;return a&&(r/=2),i.offset=o(i.offset),i.over=o(i.over),this.each((function(){if(null!==s){var c,u=n(this),l=u?this.contentWindow||window:this,f=e(l),d=s,h={};switch(typeof d){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(d)){d=o(d);break}d=u?e(d):e(d,l);case"object":if(0===d.length)return;(d.is||d.style)&&(c=(d=e(d)).offset())}var m=e.isFunction(i.offset)&&i.offset(l,d)||i.offset;e.each(i.axis.split(""),(function(e,n){var o="x"===n?"Left":"Top",s=o.toLowerCase(),r="scroll"+o,p=f[r](),g=t.max(l,n);if(c)h[r]=c[s]+(u?0:p-f.offset()[s]),i.margin&&(h[r]-=parseInt(d.css("margin"+o),10)||0,h[r]-=parseInt(d.css("border"+o+"Width"),10)||0),h[r]+=m[s]||0,i.over[s]&&(h[r]+=d["x"===n?"width":"height"]()*i.over[s]);else{var v=d[s];h[r]=v.slice&&"%"===v.slice(-1)?parseFloat(v)/100*g:v}i.limit&&/^\d+$/.test(h[r])&&(h[r]=h[r]<=0?0:Math.min(h[r],g)),!e&&i.axis.length>1&&(p===h[r]?h={}:a&&(_(i.onAfterFirst),h={}))})),_(i.onAfter)}function _(t){var n=e.extend({},i,{queue:!0,duration:r,complete:t&&function(){t.call(l,d,i)}});f.animate(h,n)}}))},t.max=function(t,o){var s="x"===o?"Width":"Height",r="scroll"+s;if(!n(t))return t[r]-e(t)[s.toLowerCase()]();var i="client"+s,a=t.ownerDocument||t.document,c=a.documentElement,u=a.body;return Math.max(c[r],u[r])-Math.min(c[i],u[i])},e.Tween.propHooks.scrollLeft=e.Tween.propHooks.scrollTop={get:function(t){return e(t.elem)[t.prop]()},set:function(t){var n=this.get(t);if(t.options.interrupt&&t._last&&t._last!==n)return e(t.elem).stop();var o=Math.round(t.now);n!==o&&(e(t.elem)[t.prop](o),t._last=this.get(t))}},t})),function(e){e.backward_timer=function(t){var n={seconds:5,step:1,format:"h%:m%:s%",value_setter:void 0,on_exhausted:function(e){},on_tick:function(e){}},o=this;o.seconds_left=0,o.target=e(t),o.timeout=void 0,o.settings={},o.methods={init:function(t){o.settings=e.extend({},n,t),null==o.settings.value_setter&&(o.target.is("input")?o.settings.value_setter="val":o.settings.value_setter="text"),o.methods.reset()},start:function(){if(null==o.timeout){var e=o.seconds_left==o.settings.seconds?0:1e3*o.settings.step;setTimeout(o.methods._on_tick,e,e)}},cancel:function(){null!=o.timeout&&(clearTimeout(o.timeout),o.timeout=void 0)},reset:function(){o.seconds_left=o.settings.seconds,o.methods._render_seconds()},_on_tick:function(e){if(0!=e&&o.settings.on_tick(o),o.methods._render_seconds(),o.seconds_left>0){if(o.seconds_left<o.settings.step)var t=o.seconds_left;else t=o.settings.step;o.seconds_left-=t;var n=1e3*t;o.timeout=setTimeout(o.methods._on_tick,n,n)}else o.timeout=void 0,o.settings.on_exhausted(o)},_render_seconds:function(){var e=o.methods._seconds_to_dhms(o.seconds_left),t=o.settings.format;t=(t=-1!==t.indexOf("d%")?t.replace("d%",e.d).replace("h%",o.methods._check_leading_zero(e.h)):t.replace("h%",24*e.d+e.h)).replace("m%",o.methods._check_leading_zero(e.m)).replace("s%",o.methods._check_leading_zero(e.s)),o.target[o.settings.value_setter](t)},_seconds_to_dhms:function(e){var t=Math.floor(e/86400),n=(e-=24*t*3600,Math.floor(e/3600)),o=(e-=3600*n,Math.floor(e/60));return{d:t,h:n,m:o,s:Math.floor(e-60*o)}},_check_leading_zero:function(e){return e<10?"0"+e:""+e}}},e.fn.backward_timer=function(t){var n=arguments;return this.each((function(){var o=e(this).data("backward_timer");return null==o&&(o=new e.backward_timer(this),e(this).data("backward_timer",o)),o.methods[t]?o.methods[t].apply(this,Array.prototype.slice.call(n,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.backward_timer"):o.methods.init.apply(this,n)}))}}(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/vendor/vue/vue_libs.js CHANGED
@@ -1,14524 +1 @@
1
- /*!
2
- * Vue.js v2.6.10
3
- * (c) 2014-2019 Evan You
4
- * Released under the MIT License.
5
- */
6
-
7
- (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9
- typeof define === 'function' && define.amd ? define(factory) :
10
- (global = global || self, global.Vue = factory());
11
- }(this, function () { 'use strict';
12
-
13
- /* */
14
-
15
- var emptyObject = Object.freeze({});
16
-
17
- // These helpers produce better VM code in JS engines due to their
18
- // explicitness and function inlining.
19
- function isUndef (v) {
20
- return v === undefined || v === null
21
- }
22
-
23
- function isDef (v) {
24
- return v !== undefined && v !== null
25
- }
26
-
27
- function isTrue (v) {
28
- return v === true
29
- }
30
-
31
- function isFalse (v) {
32
- return v === false
33
- }
34
-
35
- /**
36
- * Check if value is primitive.
37
- */
38
- function isPrimitive (value) {
39
- return (
40
- typeof value === 'string' ||
41
- typeof value === 'number' ||
42
- // $flow-disable-line
43
- typeof value === 'symbol' ||
44
- typeof value === 'boolean'
45
- )
46
- }
47
-
48
- /**
49
- * Quick object check - this is primarily used to tell
50
- * Objects from primitive values when we know the value
51
- * is a JSON-compliant type.
52
- */
53
- function isObject (obj) {
54
- return obj !== null && typeof obj === 'object'
55
- }
56
-
57
- /**
58
- * Get the raw type string of a value, e.g., [object Object].
59
- */
60
- var _toString = Object.prototype.toString;
61
-
62
- function toRawType (value) {
63
- return _toString.call(value).slice(8, -1)
64
- }
65
-
66
- /**
67
- * Strict object type check. Only returns true
68
- * for plain JavaScript objects.
69
- */
70
- function isPlainObject (obj) {
71
- return _toString.call(obj) === '[object Object]'
72
- }
73
-
74
- function isRegExp (v) {
75
- return _toString.call(v) === '[object RegExp]'
76
- }
77
-
78
- /**
79
- * Check if val is a valid array index.
80
- */
81
- function isValidArrayIndex (val) {
82
- var n = parseFloat(String(val));
83
- return n >= 0 && Math.floor(n) === n && isFinite(val)
84
- }
85
-
86
- function isPromise (val) {
87
- return (
88
- isDef(val) &&
89
- typeof val.then === 'function' &&
90
- typeof val.catch === 'function'
91
- )
92
- }
93
-
94
- /**
95
- * Convert a value to a string that is actually rendered.
96
- */
97
- function toString (val) {
98
- return val == null
99
- ? ''
100
- : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
101
- ? JSON.stringify(val, null, 2)
102
- : String(val)
103
- }
104
-
105
- /**
106
- * Convert an input value to a number for persistence.
107
- * If the conversion fails, return original string.
108
- */
109
- function toNumber (val) {
110
- var n = parseFloat(val);
111
- return isNaN(n) ? val : n
112
- }
113
-
114
- /**
115
- * Make a map and return a function for checking if a key
116
- * is in that map.
117
- */
118
- function makeMap (
119
- str,
120
- expectsLowerCase
121
- ) {
122
- var map = Object.create(null);
123
- var list = str.split(',');
124
- for (var i = 0; i < list.length; i++) {
125
- map[list[i]] = true;
126
- }
127
- return expectsLowerCase
128
- ? function (val) { return map[val.toLowerCase()]; }
129
- : function (val) { return map[val]; }
130
- }
131
-
132
- /**
133
- * Check if a tag is a built-in tag.
134
- */
135
- var isBuiltInTag = makeMap('slot,component', true);
136
-
137
- /**
138
- * Check if an attribute is a reserved attribute.
139
- */
140
- var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
141
-
142
- /**
143
- * Remove an item from an array.
144
- */
145
- function remove (arr, item) {
146
- if (arr.length) {
147
- var index = arr.indexOf(item);
148
- if (index > -1) {
149
- return arr.splice(index, 1)
150
- }
151
- }
152
- }
153
-
154
- /**
155
- * Check whether an object has the property.
156
- */
157
- var hasOwnProperty = Object.prototype.hasOwnProperty;
158
- function hasOwn (obj, key) {
159
- return hasOwnProperty.call(obj, key)
160
- }
161
-
162
- /**
163
- * Create a cached version of a pure function.
164
- */
165
- function cached (fn) {
166
- var cache = Object.create(null);
167
- return (function cachedFn (str) {
168
- var hit = cache[str];
169
- return hit || (cache[str] = fn(str))
170
- })
171
- }
172
-
173
- /**
174
- * Camelize a hyphen-delimited string.
175
- */
176
- var camelizeRE = /-(\w)/g;
177
- var camelize = cached(function (str) {
178
- return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
179
- });
180
-
181
- /**
182
- * Capitalize a string.
183
- */
184
- var capitalize = cached(function (str) {
185
- return str.charAt(0).toUpperCase() + str.slice(1)
186
- });
187
-
188
- /**
189
- * Hyphenate a camelCase string.
190
- */
191
- var hyphenateRE = /\B([A-Z])/g;
192
- var hyphenate = cached(function (str) {
193
- return str.replace(hyphenateRE, '-$1').toLowerCase()
194
- });
195
-
196
- /**
197
- * Simple bind polyfill for environments that do not support it,
198
- * e.g., PhantomJS 1.x. Technically, we don't need this anymore
199
- * since native bind is now performant enough in most browsers.
200
- * But removing it would mean breaking code that was able to run in
201
- * PhantomJS 1.x, so this must be kept for backward compatibility.
202
- */
203
-
204
- /* istanbul ignore next */
205
- function polyfillBind (fn, ctx) {
206
- function boundFn (a) {
207
- var l = arguments.length;
208
- return l
209
- ? l > 1
210
- ? fn.apply(ctx, arguments)
211
- : fn.call(ctx, a)
212
- : fn.call(ctx)
213
- }
214
-
215
- boundFn._length = fn.length;
216
- return boundFn
217
- }
218
-
219
- function nativeBind (fn, ctx) {
220
- return fn.bind(ctx)
221
- }
222
-
223
- var bind = Function.prototype.bind
224
- ? nativeBind
225
- : polyfillBind;
226
-
227
- /**
228
- * Convert an Array-like object to a real Array.
229
- */
230
- function toArray (list, start) {
231
- start = start || 0;
232
- var i = list.length - start;
233
- var ret = new Array(i);
234
- while (i--) {
235
- ret[i] = list[i + start];
236
- }
237
- return ret
238
- }
239
-
240
- /**
241
- * Mix properties into target object.
242
- */
243
- function extend (to, _from) {
244
- for (var key in _from) {
245
- to[key] = _from[key];
246
- }
247
- return to
248
- }
249
-
250
- /**
251
- * Merge an Array of Objects into a single Object.
252
- */
253
- function toObject (arr) {
254
- var res = {};
255
- for (var i = 0; i < arr.length; i++) {
256
- if (arr[i]) {
257
- extend(res, arr[i]);
258
- }
259
- }
260
- return res
261
- }
262
-
263
- /* eslint-disable no-unused-vars */
264
-
265
- /**
266
- * Perform no operation.
267
- * Stubbing args to make Flow happy without leaving useless transpiled code
268
- * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
269
- */
270
- function noop (a, b, c) {}
271
-
272
- /**
273
- * Always return false.
274
- */
275
- var no = function (a, b, c) { return false; };
276
-
277
- /* eslint-enable no-unused-vars */
278
-
279
- /**
280
- * Return the same value.
281
- */
282
- var identity = function (_) { return _; };
283
-
284
- /**
285
- * Generate a string containing static keys from compiler modules.
286
- */
287
- function genStaticKeys (modules) {
288
- return modules.reduce(function (keys, m) {
289
- return keys.concat(m.staticKeys || [])
290
- }, []).join(',')
291
- }
292
-
293
- /**
294
- * Check if two values are loosely equal - that is,
295
- * if they are plain objects, do they have the same shape?
296
- */
297
- function looseEqual (a, b) {
298
- if (a === b) { return true }
299
- var isObjectA = isObject(a);
300
- var isObjectB = isObject(b);
301
- if (isObjectA && isObjectB) {
302
- try {
303
- var isArrayA = Array.isArray(a);
304
- var isArrayB = Array.isArray(b);
305
- if (isArrayA && isArrayB) {
306
- return a.length === b.length && a.every(function (e, i) {
307
- return looseEqual(e, b[i])
308
- })
309
- } else if (a instanceof Date && b instanceof Date) {
310
- return a.getTime() === b.getTime()
311
- } else if (!isArrayA && !isArrayB) {
312
- var keysA = Object.keys(a);
313
- var keysB = Object.keys(b);
314
- return keysA.length === keysB.length && keysA.every(function (key) {
315
- return looseEqual(a[key], b[key])
316
- })
317
- } else {
318
- /* istanbul ignore next */
319
- return false
320
- }
321
- } catch (e) {
322
- /* istanbul ignore next */
323
- return false
324
- }
325
- } else if (!isObjectA && !isObjectB) {
326
- return String(a) === String(b)
327
- } else {
328
- return false
329
- }
330
- }
331
-
332
- /**
333
- * Return the first index at which a loosely equal value can be
334
- * found in the array (if value is a plain object, the array must
335
- * contain an object of the same shape), or -1 if it is not present.
336
- */
337
- function looseIndexOf (arr, val) {
338
- for (var i = 0; i < arr.length; i++) {
339
- if (looseEqual(arr[i], val)) { return i }
340
- }
341
- return -1
342
- }
343
-
344
- /**
345
- * Ensure a function is called only once.
346
- */
347
- function once (fn) {
348
- var called = false;
349
- return function () {
350
- if (!called) {
351
- called = true;
352
- fn.apply(this, arguments);
353
- }
354
- }
355
- }
356
-
357
- var SSR_ATTR = 'data-server-rendered';
358
-
359
- var ASSET_TYPES = [
360
- 'component',
361
- 'directive',
362
- 'filter'
363
- ];
364
-
365
- var LIFECYCLE_HOOKS = [
366
- 'beforeCreate',
367
- 'created',
368
- 'beforeMount',
369
- 'mounted',
370
- 'beforeUpdate',
371
- 'updated',
372
- 'beforeDestroy',
373
- 'destroyed',
374
- 'activated',
375
- 'deactivated',
376
- 'errorCaptured',
377
- 'serverPrefetch'
378
- ];
379
-
380
- /* */
381
-
382
-
383
-
384
- var config = ({
385
- /**
386
- * Option merge strategies (used in core/util/options)
387
- */
388
- // $flow-disable-line
389
- optionMergeStrategies: Object.create(null),
390
-
391
- /**
392
- * Whether to suppress warnings.
393
- */
394
- silent: false,
395
-
396
- /**
397
- * Show production mode tip message on boot?
398
- */
399
- productionTip: "development" !== 'production',
400
-
401
- /**
402
- * Whether to enable devtools
403
- */
404
- devtools: "development" !== 'production',
405
-
406
- /**
407
- * Whether to record perf
408
- */
409
- performance: false,
410
-
411
- /**
412
- * Error handler for watcher errors
413
- */
414
- errorHandler: null,
415
-
416
- /**
417
- * Warn handler for watcher warns
418
- */
419
- warnHandler: null,
420
-
421
- /**
422
- * Ignore certain custom elements
423
- */
424
- ignoredElements: [],
425
-
426
- /**
427
- * Custom user key aliases for v-on
428
- */
429
- // $flow-disable-line
430
- keyCodes: Object.create(null),
431
-
432
- /**
433
- * Check if a tag is reserved so that it cannot be registered as a
434
- * component. This is platform-dependent and may be overwritten.
435
- */
436
- isReservedTag: no,
437
-
438
- /**
439
- * Check if an attribute is reserved so that it cannot be used as a component
440
- * prop. This is platform-dependent and may be overwritten.
441
- */
442
- isReservedAttr: no,
443
-
444
- /**
445
- * Check if a tag is an unknown element.
446
- * Platform-dependent.
447
- */
448
- isUnknownElement: no,
449
-
450
- /**
451
- * Get the namespace of an element
452
- */
453
- getTagNamespace: noop,
454
-
455
- /**
456
- * Parse the real tag name for the specific platform.
457
- */
458
- parsePlatformTagName: identity,
459
-
460
- /**
461
- * Check if an attribute must be bound using property, e.g. value
462
- * Platform-dependent.
463
- */
464
- mustUseProp: no,
465
-
466
- /**
467
- * Perform updates asynchronously. Intended to be used by Vue Test Utils
468
- * This will significantly reduce performance if set to false.
469
- */
470
- async: true,
471
-
472
- /**
473
- * Exposed for legacy reasons
474
- */
475
- _lifecycleHooks: LIFECYCLE_HOOKS
476
- });
477
-
478
- /* */
479
-
480
- /**
481
- * unicode letters used for parsing html tags, component names and property paths.
482
- * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
483
- * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
484
- */
485
- var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
486
-
487
- /**
488
- * Check if a string starts with $ or _
489
- */
490
- function isReserved (str) {
491
- var c = (str + '').charCodeAt(0);
492
- return c === 0x24 || c === 0x5F
493
- }
494
-
495
- /**
496
- * Define a property.
497
- */
498
- function def (obj, key, val, enumerable) {
499
- Object.defineProperty(obj, key, {
500
- value: val,
501
- enumerable: !!enumerable,
502
- writable: true,
503
- configurable: true
504
- });
505
- }
506
-
507
- /**
508
- * Parse simple path.
509
- */
510
- var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
511
- function parsePath (path) {
512
- if (bailRE.test(path)) {
513
- return
514
- }
515
- var segments = path.split('.');
516
- return function (obj) {
517
- for (var i = 0; i < segments.length; i++) {
518
- if (!obj) { return }
519
- obj = obj[segments[i]];
520
- }
521
- return obj
522
- }
523
- }
524
-
525
- /* */
526
-
527
- // can we use __proto__?
528
- var hasProto = '__proto__' in {};
529
-
530
- // Browser environment sniffing
531
- var inBrowser = typeof window !== 'undefined';
532
- var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
533
- var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
534
- var UA = inBrowser && window.navigator.userAgent.toLowerCase();
535
- var isIE = UA && /msie|trident/.test(UA);
536
- var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
537
- var isEdge = UA && UA.indexOf('edge/') > 0;
538
- var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
539
- var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
540
- var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
541
- var isPhantomJS = UA && /phantomjs/.test(UA);
542
- var isFF = UA && UA.match(/firefox\/(\d+)/);
543
-
544
- // Firefox has a "watch" function on Object.prototype...
545
- var nativeWatch = ({}).watch;
546
-
547
- var supportsPassive = false;
548
- if (inBrowser) {
549
- try {
550
- var opts = {};
551
- Object.defineProperty(opts, 'passive', ({
552
- get: function get () {
553
- /* istanbul ignore next */
554
- supportsPassive = true;
555
- }
556
- })); // https://github.com/facebook/flow/issues/285
557
- window.addEventListener('test-passive', null, opts);
558
- } catch (e) {}
559
- }
560
-
561
- // this needs to be lazy-evaled because vue may be required before
562
- // vue-server-renderer can set VUE_ENV
563
- var _isServer;
564
- var isServerRendering = function () {
565
- if (_isServer === undefined) {
566
- /* istanbul ignore if */
567
- if (!inBrowser && !inWeex && typeof global !== 'undefined') {
568
- // detect presence of vue-server-renderer and avoid
569
- // Webpack shimming the process
570
- _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
571
- } else {
572
- _isServer = false;
573
- }
574
- }
575
- return _isServer
576
- };
577
-
578
- // detect devtools
579
- var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
580
-
581
- /* istanbul ignore next */
582
- function isNative (Ctor) {
583
- return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
584
- }
585
-
586
- var hasSymbol =
587
- typeof Symbol !== 'undefined' && isNative(Symbol) &&
588
- typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
589
-
590
- var _Set;
591
- /* istanbul ignore if */ // $flow-disable-line
592
- if (typeof Set !== 'undefined' && isNative(Set)) {
593
- // use native Set when available.
594
- _Set = Set;
595
- } else {
596
- // a non-standard Set polyfill that only works with primitive keys.
597
- _Set = /*@__PURE__*/(function () {
598
- function Set () {
599
- this.set = Object.create(null);
600
- }
601
- Set.prototype.has = function has (key) {
602
- return this.set[key] === true
603
- };
604
- Set.prototype.add = function add (key) {
605
- this.set[key] = true;
606
- };
607
- Set.prototype.clear = function clear () {
608
- this.set = Object.create(null);
609
- };
610
-
611
- return Set;
612
- }());
613
- }
614
-
615
- /* */
616
-
617
- var warn = noop;
618
- var tip = noop;
619
- var generateComponentTrace = (noop); // work around flow check
620
- var formatComponentName = (noop);
621
-
622
- {
623
- var hasConsole = typeof console !== 'undefined';
624
- var classifyRE = /(?:^|[-_])(\w)/g;
625
- var classify = function (str) { return str
626
- .replace(classifyRE, function (c) { return c.toUpperCase(); })
627
- .replace(/[-_]/g, ''); };
628
-
629
- warn = function (msg, vm) {
630
- var trace = vm ? generateComponentTrace(vm) : '';
631
-
632
- if (config.warnHandler) {
633
- config.warnHandler.call(null, msg, vm, trace);
634
- } else if (hasConsole && (!config.silent)) {
635
- console.error(("[Vue warn]: " + msg + trace));
636
- }
637
- };
638
-
639
- tip = function (msg, vm) {
640
- if (hasConsole && (!config.silent)) {
641
- console.warn("[Vue tip]: " + msg + (
642
- vm ? generateComponentTrace(vm) : ''
643
- ));
644
- }
645
- };
646
-
647
- formatComponentName = function (vm, includeFile) {
648
- if (vm.$root === vm) {
649
- return '<Root>'
650
- }
651
- var options = typeof vm === 'function' && vm.cid != null
652
- ? vm.options
653
- : vm._isVue
654
- ? vm.$options || vm.constructor.options
655
- : vm;
656
- var name = options.name || options._componentTag;
657
- var file = options.__file;
658
- if (!name && file) {
659
- var match = file.match(/([^/\\]+)\.vue$/);
660
- name = match && match[1];
661
- }
662
-
663
- return (
664
- (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
665
- (file && includeFile !== false ? (" at " + file) : '')
666
- )
667
- };
668
-
669
- var repeat = function (str, n) {
670
- var res = '';
671
- while (n) {
672
- if (n % 2 === 1) { res += str; }
673
- if (n > 1) { str += str; }
674
- n >>= 1;
675
- }
676
- return res
677
- };
678
-
679
- generateComponentTrace = function (vm) {
680
- if (vm._isVue && vm.$parent) {
681
- var tree = [];
682
- var currentRecursiveSequence = 0;
683
- while (vm) {
684
- if (tree.length > 0) {
685
- var last = tree[tree.length - 1];
686
- if (last.constructor === vm.constructor) {
687
- currentRecursiveSequence++;
688
- vm = vm.$parent;
689
- continue
690
- } else if (currentRecursiveSequence > 0) {
691
- tree[tree.length - 1] = [last, currentRecursiveSequence];
692
- currentRecursiveSequence = 0;
693
- }
694
- }
695
- tree.push(vm);
696
- vm = vm.$parent;
697
- }
698
- return '\n\nfound in\n\n' + tree
699
- .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
700
- ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
701
- : formatComponentName(vm))); })
702
- .join('\n')
703
- } else {
704
- return ("\n\n(found in " + (formatComponentName(vm)) + ")")
705
- }
706
- };
707
- }
708
-
709
- /* */
710
-
711
- var uid = 0;
712
-
713
- /**
714
- * A dep is an observable that can have multiple
715
- * directives subscribing to it.
716
- */
717
- var Dep = function Dep () {
718
- this.id = uid++;
719
- this.subs = [];
720
- };
721
-
722
- Dep.prototype.addSub = function addSub (sub) {
723
- this.subs.push(sub);
724
- };
725
-
726
- Dep.prototype.removeSub = function removeSub (sub) {
727
- remove(this.subs, sub);
728
- };
729
-
730
- Dep.prototype.depend = function depend () {
731
- if (Dep.target) {
732
- Dep.target.addDep(this);
733
- }
734
- };
735
-
736
- Dep.prototype.notify = function notify () {
737
- // stabilize the subscriber list first
738
- var subs = this.subs.slice();
739
- if (!config.async) {
740
- // subs aren't sorted in scheduler if not running async
741
- // we need to sort them now to make sure they fire in correct
742
- // order
743
- subs.sort(function (a, b) { return a.id - b.id; });
744
- }
745
- for (var i = 0, l = subs.length; i < l; i++) {
746
- subs[i].update();
747
- }
748
- };
749
-
750
- // The current target watcher being evaluated.
751
- // This is globally unique because only one watcher
752
- // can be evaluated at a time.
753
- Dep.target = null;
754
- var targetStack = [];
755
-
756
- function pushTarget (target) {
757
- targetStack.push(target);
758
- Dep.target = target;
759
- }
760
-
761
- function popTarget () {
762
- targetStack.pop();
763
- Dep.target = targetStack[targetStack.length - 1];
764
- }
765
-
766
- /* */
767
-
768
- var VNode = function VNode (
769
- tag,
770
- data,
771
- children,
772
- text,
773
- elm,
774
- context,
775
- componentOptions,
776
- asyncFactory
777
- ) {
778
- this.tag = tag;
779
- this.data = data;
780
- this.children = children;
781
- this.text = text;
782
- this.elm = elm;
783
- this.ns = undefined;
784
- this.context = context;
785
- this.fnContext = undefined;
786
- this.fnOptions = undefined;
787
- this.fnScopeId = undefined;
788
- this.key = data && data.key;
789
- this.componentOptions = componentOptions;
790
- this.componentInstance = undefined;
791
- this.parent = undefined;
792
- this.raw = false;
793
- this.isStatic = false;
794
- this.isRootInsert = true;
795
- this.isComment = false;
796
- this.isCloned = false;
797
- this.isOnce = false;
798
- this.asyncFactory = asyncFactory;
799
- this.asyncMeta = undefined;
800
- this.isAsyncPlaceholder = false;
801
- };
802
-
803
- var prototypeAccessors = { child: { configurable: true } };
804
-
805
- // DEPRECATED: alias for componentInstance for backwards compat.
806
- /* istanbul ignore next */
807
- prototypeAccessors.child.get = function () {
808
- return this.componentInstance
809
- };
810
-
811
- Object.defineProperties( VNode.prototype, prototypeAccessors );
812
-
813
- var createEmptyVNode = function (text) {
814
- if ( text === void 0 ) text = '';
815
-
816
- var node = new VNode();
817
- node.text = text;
818
- node.isComment = true;
819
- return node
820
- };
821
-
822
- function createTextVNode (val) {
823
- return new VNode(undefined, undefined, undefined, String(val))
824
- }
825
-
826
- // optimized shallow clone
827
- // used for static nodes and slot nodes because they may be reused across
828
- // multiple renders, cloning them avoids errors when DOM manipulations rely
829
- // on their elm reference.
830
- function cloneVNode (vnode) {
831
- var cloned = new VNode(
832
- vnode.tag,
833
- vnode.data,
834
- // #7975
835
- // clone children array to avoid mutating original in case of cloning
836
- // a child.
837
- vnode.children && vnode.children.slice(),
838
- vnode.text,
839
- vnode.elm,
840
- vnode.context,
841
- vnode.componentOptions,
842
- vnode.asyncFactory
843
- );
844
- cloned.ns = vnode.ns;
845
- cloned.isStatic = vnode.isStatic;
846
- cloned.key = vnode.key;
847
- cloned.isComment = vnode.isComment;
848
- cloned.fnContext = vnode.fnContext;
849
- cloned.fnOptions = vnode.fnOptions;
850
- cloned.fnScopeId = vnode.fnScopeId;
851
- cloned.asyncMeta = vnode.asyncMeta;
852
- cloned.isCloned = true;
853
- return cloned
854
- }
855
-
856
- /*
857
- * not type checking this file because flow doesn't play well with
858
- * dynamically accessing methods on Array prototype
859
- */
860
-
861
- var arrayProto = Array.prototype;
862
- var arrayMethods = Object.create(arrayProto);
863
-
864
- var methodsToPatch = [
865
- 'push',
866
- 'pop',
867
- 'shift',
868
- 'unshift',
869
- 'splice',
870
- 'sort',
871
- 'reverse'
872
- ];
873
-
874
- /**
875
- * Intercept mutating methods and emit events
876
- */
877
- methodsToPatch.forEach(function (method) {
878
- // cache original method
879
- var original = arrayProto[method];
880
- def(arrayMethods, method, function mutator () {
881
- var args = [], len = arguments.length;
882
- while ( len-- ) args[ len ] = arguments[ len ];
883
-
884
- var result = original.apply(this, args);
885
- var ob = this.__ob__;
886
- var inserted;
887
- switch (method) {
888
- case 'push':
889
- case 'unshift':
890
- inserted = args;
891
- break
892
- case 'splice':
893
- inserted = args.slice(2);
894
- break
895
- }
896
- if (inserted) { ob.observeArray(inserted); }
897
- // notify change
898
- ob.dep.notify();
899
- return result
900
- });
901
- });
902
-
903
- /* */
904
-
905
- var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
906
-
907
- /**
908
- * In some cases we may want to disable observation inside a component's
909
- * update computation.
910
- */
911
- var shouldObserve = true;
912
-
913
- function toggleObserving (value) {
914
- shouldObserve = value;
915
- }
916
-
917
- /**
918
- * Observer class that is attached to each observed
919
- * object. Once attached, the observer converts the target
920
- * object's property keys into getter/setters that
921
- * collect dependencies and dispatch updates.
922
- */
923
- var Observer = function Observer (value) {
924
- this.value = value;
925
- this.dep = new Dep();
926
- this.vmCount = 0;
927
- def(value, '__ob__', this);
928
- if (Array.isArray(value)) {
929
- if (hasProto) {
930
- protoAugment(value, arrayMethods);
931
- } else {
932
- copyAugment(value, arrayMethods, arrayKeys);
933
- }
934
- this.observeArray(value);
935
- } else {
936
- this.walk(value);
937
- }
938
- };
939
-
940
- /**
941
- * Walk through all properties and convert them into
942
- * getter/setters. This method should only be called when
943
- * value type is Object.
944
- */
945
- Observer.prototype.walk = function walk (obj) {
946
- var keys = Object.keys(obj);
947
- for (var i = 0; i < keys.length; i++) {
948
- defineReactive$$1(obj, keys[i]);
949
- }
950
- };
951
-
952
- /**
953
- * Observe a list of Array items.
954
- */
955
- Observer.prototype.observeArray = function observeArray (items) {
956
- for (var i = 0, l = items.length; i < l; i++) {
957
- observe(items[i]);
958
- }
959
- };
960
-
961
- // helpers
962
-
963
- /**
964
- * Augment a target Object or Array by intercepting
965
- * the prototype chain using __proto__
966
- */
967
- function protoAugment (target, src) {
968
- /* eslint-disable no-proto */
969
- target.__proto__ = src;
970
- /* eslint-enable no-proto */
971
- }
972
-
973
- /**
974
- * Augment a target Object or Array by defining
975
- * hidden properties.
976
- */
977
- /* istanbul ignore next */
978
- function copyAugment (target, src, keys) {
979
- for (var i = 0, l = keys.length; i < l; i++) {
980
- var key = keys[i];
981
- def(target, key, src[key]);
982
- }
983
- }
984
-
985
- /**
986
- * Attempt to create an observer instance for a value,
987
- * returns the new observer if successfully observed,
988
- * or the existing observer if the value already has one.
989
- */
990
- function observe (value, asRootData) {
991
- if (!isObject(value) || value instanceof VNode) {
992
- return
993
- }
994
- var ob;
995
- if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
996
- ob = value.__ob__;
997
- } else if (
998
- shouldObserve &&
999
- !isServerRendering() &&
1000
- (Array.isArray(value) || isPlainObject(value)) &&
1001
- Object.isExtensible(value) &&
1002
- !value._isVue
1003
- ) {
1004
- ob = new Observer(value);
1005
- }
1006
- if (asRootData && ob) {
1007
- ob.vmCount++;
1008
- }
1009
- return ob
1010
- }
1011
-
1012
- /**
1013
- * Define a reactive property on an Object.
1014
- */
1015
- function defineReactive$$1 (
1016
- obj,
1017
- key,
1018
- val,
1019
- customSetter,
1020
- shallow
1021
- ) {
1022
- var dep = new Dep();
1023
-
1024
- var property = Object.getOwnPropertyDescriptor(obj, key);
1025
- if (property && property.configurable === false) {
1026
- return
1027
- }
1028
-
1029
- // cater for pre-defined getter/setters
1030
- var getter = property && property.get;
1031
- var setter = property && property.set;
1032
- if ((!getter || setter) && arguments.length === 2) {
1033
- val = obj[key];
1034
- }
1035
-
1036
- var childOb = !shallow && observe(val);
1037
- Object.defineProperty(obj, key, {
1038
- enumerable: true,
1039
- configurable: true,
1040
- get: function reactiveGetter () {
1041
- var value = getter ? getter.call(obj) : val;
1042
- if (Dep.target) {
1043
- dep.depend();
1044
- if (childOb) {
1045
- childOb.dep.depend();
1046
- if (Array.isArray(value)) {
1047
- dependArray(value);
1048
- }
1049
- }
1050
- }
1051
- return value
1052
- },
1053
- set: function reactiveSetter (newVal) {
1054
- var value = getter ? getter.call(obj) : val;
1055
- /* eslint-disable no-self-compare */
1056
- if (newVal === value || (newVal !== newVal && value !== value)) {
1057
- return
1058
- }
1059
- /* eslint-enable no-self-compare */
1060
- if (customSetter) {
1061
- customSetter();
1062
- }
1063
- // #7981: for accessor properties without setter
1064
- if (getter && !setter) { return }
1065
- if (setter) {
1066
- setter.call(obj, newVal);
1067
- } else {
1068
- val = newVal;
1069
- }
1070
- childOb = !shallow && observe(newVal);
1071
- dep.notify();
1072
- }
1073
- });
1074
- }
1075
-
1076
- /**
1077
- * Set a property on an object. Adds the new property and
1078
- * triggers change notification if the property doesn't
1079
- * already exist.
1080
- */
1081
- function set (target, key, val) {
1082
- if (isUndef(target) || isPrimitive(target)
1083
- ) {
1084
- warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
1085
- }
1086
- if (Array.isArray(target) && isValidArrayIndex(key)) {
1087
- target.length = Math.max(target.length, key);
1088
- target.splice(key, 1, val);
1089
- return val
1090
- }
1091
- if (key in target && !(key in Object.prototype)) {
1092
- target[key] = val;
1093
- return val
1094
- }
1095
- var ob = (target).__ob__;
1096
- if (target._isVue || (ob && ob.vmCount)) {
1097
- warn(
1098
- 'Avoid adding reactive properties to a Vue instance or its root $data ' +
1099
- 'at runtime - declare it upfront in the data option.'
1100
- );
1101
- return val
1102
- }
1103
- if (!ob) {
1104
- target[key] = val;
1105
- return val
1106
- }
1107
- defineReactive$$1(ob.value, key, val);
1108
- ob.dep.notify();
1109
- return val
1110
- }
1111
-
1112
- /**
1113
- * Delete a property and trigger change if necessary.
1114
- */
1115
- function del (target, key) {
1116
- if (isUndef(target) || isPrimitive(target)
1117
- ) {
1118
- warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
1119
- }
1120
- if (Array.isArray(target) && isValidArrayIndex(key)) {
1121
- target.splice(key, 1);
1122
- return
1123
- }
1124
- var ob = (target).__ob__;
1125
- if (target._isVue || (ob && ob.vmCount)) {
1126
- warn(
1127
- 'Avoid deleting properties on a Vue instance or its root $data ' +
1128
- '- just set it to null.'
1129
- );
1130
- return
1131
- }
1132
- if (!hasOwn(target, key)) {
1133
- return
1134
- }
1135
- delete target[key];
1136
- if (!ob) {
1137
- return
1138
- }
1139
- ob.dep.notify();
1140
- }
1141
-
1142
- /**
1143
- * Collect dependencies on array elements when the array is touched, since
1144
- * we cannot intercept array element access like property getters.
1145
- */
1146
- function dependArray (value) {
1147
- for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
1148
- e = value[i];
1149
- e && e.__ob__ && e.__ob__.dep.depend();
1150
- if (Array.isArray(e)) {
1151
- dependArray(e);
1152
- }
1153
- }
1154
- }
1155
-
1156
- /* */
1157
-
1158
- /**
1159
- * Option overwriting strategies are functions that handle
1160
- * how to merge a parent option value and a child option
1161
- * value into the final value.
1162
- */
1163
- var strats = config.optionMergeStrategies;
1164
-
1165
- /**
1166
- * Options with restrictions
1167
- */
1168
- {
1169
- strats.el = strats.propsData = function (parent, child, vm, key) {
1170
- if (!vm) {
1171
- warn(
1172
- "option \"" + key + "\" can only be used during instance " +
1173
- 'creation with the `new` keyword.'
1174
- );
1175
- }
1176
- return defaultStrat(parent, child)
1177
- };
1178
- }
1179
-
1180
- /**
1181
- * Helper that recursively merges two data objects together.
1182
- */
1183
- function mergeData (to, from) {
1184
- if (!from) { return to }
1185
- var key, toVal, fromVal;
1186
-
1187
- var keys = hasSymbol
1188
- ? Reflect.ownKeys(from)
1189
- : Object.keys(from);
1190
-
1191
- for (var i = 0; i < keys.length; i++) {
1192
- key = keys[i];
1193
- // in case the object is already observed...
1194
- if (key === '__ob__') { continue }
1195
- toVal = to[key];
1196
- fromVal = from[key];
1197
- if (!hasOwn(to, key)) {
1198
- set(to, key, fromVal);
1199
- } else if (
1200
- toVal !== fromVal &&
1201
- isPlainObject(toVal) &&
1202
- isPlainObject(fromVal)
1203
- ) {
1204
- mergeData(toVal, fromVal);
1205
- }
1206
- }
1207
- return to
1208
- }
1209
-
1210
- /**
1211
- * Data
1212
- */
1213
- function mergeDataOrFn (
1214
- parentVal,
1215
- childVal,
1216
- vm
1217
- ) {
1218
- if (!vm) {
1219
- // in a Vue.extend merge, both should be functions
1220
- if (!childVal) {
1221
- return parentVal
1222
- }
1223
- if (!parentVal) {
1224
- return childVal
1225
- }
1226
- // when parentVal & childVal are both present,
1227
- // we need to return a function that returns the
1228
- // merged result of both functions... no need to
1229
- // check if parentVal is a function here because
1230
- // it has to be a function to pass previous merges.
1231
- return function mergedDataFn () {
1232
- return mergeData(
1233
- typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1234
- typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1235
- )
1236
- }
1237
- } else {
1238
- return function mergedInstanceDataFn () {
1239
- // instance merge
1240
- var instanceData = typeof childVal === 'function'
1241
- ? childVal.call(vm, vm)
1242
- : childVal;
1243
- var defaultData = typeof parentVal === 'function'
1244
- ? parentVal.call(vm, vm)
1245
- : parentVal;
1246
- if (instanceData) {
1247
- return mergeData(instanceData, defaultData)
1248
- } else {
1249
- return defaultData
1250
- }
1251
- }
1252
- }
1253
- }
1254
-
1255
- strats.data = function (
1256
- parentVal,
1257
- childVal,
1258
- vm
1259
- ) {
1260
- if (!vm) {
1261
- if (childVal && typeof childVal !== 'function') {
1262
- warn(
1263
- 'The "data" option should be a function ' +
1264
- 'that returns a per-instance value in component ' +
1265
- 'definitions.',
1266
- vm
1267
- );
1268
-
1269
- return parentVal
1270
- }
1271
- return mergeDataOrFn(parentVal, childVal)
1272
- }
1273
-
1274
- return mergeDataOrFn(parentVal, childVal, vm)
1275
- };
1276
-
1277
- /**
1278
- * Hooks and props are merged as arrays.
1279
- */
1280
- function mergeHook (
1281
- parentVal,
1282
- childVal
1283
- ) {
1284
- var res = childVal
1285
- ? parentVal
1286
- ? parentVal.concat(childVal)
1287
- : Array.isArray(childVal)
1288
- ? childVal
1289
- : [childVal]
1290
- : parentVal;
1291
- return res
1292
- ? dedupeHooks(res)
1293
- : res
1294
- }
1295
-
1296
- function dedupeHooks (hooks) {
1297
- var res = [];
1298
- for (var i = 0; i < hooks.length; i++) {
1299
- if (res.indexOf(hooks[i]) === -1) {
1300
- res.push(hooks[i]);
1301
- }
1302
- }
1303
- return res
1304
- }
1305
-
1306
- LIFECYCLE_HOOKS.forEach(function (hook) {
1307
- strats[hook] = mergeHook;
1308
- });
1309
-
1310
- /**
1311
- * Assets
1312
- *
1313
- * When a vm is present (instance creation), we need to do
1314
- * a three-way merge between constructor options, instance
1315
- * options and parent options.
1316
- */
1317
- function mergeAssets (
1318
- parentVal,
1319
- childVal,
1320
- vm,
1321
- key
1322
- ) {
1323
- var res = Object.create(parentVal || null);
1324
- if (childVal) {
1325
- assertObjectType(key, childVal, vm);
1326
- return extend(res, childVal)
1327
- } else {
1328
- return res
1329
- }
1330
- }
1331
-
1332
- ASSET_TYPES.forEach(function (type) {
1333
- strats[type + 's'] = mergeAssets;
1334
- });
1335
-
1336
- /**
1337
- * Watchers.
1338
- *
1339
- * Watchers hashes should not overwrite one
1340
- * another, so we merge them as arrays.
1341
- */
1342
- strats.watch = function (
1343
- parentVal,
1344
- childVal,
1345
- vm,
1346
- key
1347
- ) {
1348
- // work around Firefox's Object.prototype.watch...
1349
- if (parentVal === nativeWatch) { parentVal = undefined; }
1350
- if (childVal === nativeWatch) { childVal = undefined; }
1351
- /* istanbul ignore if */
1352
- if (!childVal) { return Object.create(parentVal || null) }
1353
- {
1354
- assertObjectType(key, childVal, vm);
1355
- }
1356
- if (!parentVal) { return childVal }
1357
- var ret = {};
1358
- extend(ret, parentVal);
1359
- for (var key$1 in childVal) {
1360
- var parent = ret[key$1];
1361
- var child = childVal[key$1];
1362
- if (parent && !Array.isArray(parent)) {
1363
- parent = [parent];
1364
- }
1365
- ret[key$1] = parent
1366
- ? parent.concat(child)
1367
- : Array.isArray(child) ? child : [child];
1368
- }
1369
- return ret
1370
- };
1371
-
1372
- /**
1373
- * Other object hashes.
1374
- */
1375
- strats.props =
1376
- strats.methods =
1377
- strats.inject =
1378
- strats.computed = function (
1379
- parentVal,
1380
- childVal,
1381
- vm,
1382
- key
1383
- ) {
1384
- if (childVal && "development" !== 'production') {
1385
- assertObjectType(key, childVal, vm);
1386
- }
1387
- if (!parentVal) { return childVal }
1388
- var ret = Object.create(null);
1389
- extend(ret, parentVal);
1390
- if (childVal) { extend(ret, childVal); }
1391
- return ret
1392
- };
1393
- strats.provide = mergeDataOrFn;
1394
-
1395
- /**
1396
- * Default strategy.
1397
- */
1398
- var defaultStrat = function (parentVal, childVal) {
1399
- return childVal === undefined
1400
- ? parentVal
1401
- : childVal
1402
- };
1403
-
1404
- /**
1405
- * Validate component names
1406
- */
1407
- function checkComponents (options) {
1408
- for (var key in options.components) {
1409
- validateComponentName(key);
1410
- }
1411
- }
1412
-
1413
- function validateComponentName (name) {
1414
- if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
1415
- warn(
1416
- 'Invalid component name: "' + name + '". Component names ' +
1417
- 'should conform to valid custom element name in html5 specification.'
1418
- );
1419
- }
1420
- if (isBuiltInTag(name) || config.isReservedTag(name)) {
1421
- warn(
1422
- 'Do not use built-in or reserved HTML elements as component ' +
1423
- 'id: ' + name
1424
- );
1425
- }
1426
- }
1427
-
1428
- /**
1429
- * Ensure all props option syntax are normalized into the
1430
- * Object-based format.
1431
- */
1432
- function normalizeProps (options, vm) {
1433
- var props = options.props;
1434
- if (!props) { return }
1435
- var res = {};
1436
- var i, val, name;
1437
- if (Array.isArray(props)) {
1438
- i = props.length;
1439
- while (i--) {
1440
- val = props[i];
1441
- if (typeof val === 'string') {
1442
- name = camelize(val);
1443
- res[name] = { type: null };
1444
- } else {
1445
- warn('props must be strings when using array syntax.');
1446
- }
1447
- }
1448
- } else if (isPlainObject(props)) {
1449
- for (var key in props) {
1450
- val = props[key];
1451
- name = camelize(key);
1452
- res[name] = isPlainObject(val)
1453
- ? val
1454
- : { type: val };
1455
- }
1456
- } else {
1457
- warn(
1458
- "Invalid value for option \"props\": expected an Array or an Object, " +
1459
- "but got " + (toRawType(props)) + ".",
1460
- vm
1461
- );
1462
- }
1463
- options.props = res;
1464
- }
1465
-
1466
- /**
1467
- * Normalize all injections into Object-based format
1468
- */
1469
- function normalizeInject (options, vm) {
1470
- var inject = options.inject;
1471
- if (!inject) { return }
1472
- var normalized = options.inject = {};
1473
- if (Array.isArray(inject)) {
1474
- for (var i = 0; i < inject.length; i++) {
1475
- normalized[inject[i]] = { from: inject[i] };
1476
- }
1477
- } else if (isPlainObject(inject)) {
1478
- for (var key in inject) {
1479
- var val = inject[key];
1480
- normalized[key] = isPlainObject(val)
1481
- ? extend({ from: key }, val)
1482
- : { from: val };
1483
- }
1484
- } else {
1485
- warn(
1486
- "Invalid value for option \"inject\": expected an Array or an Object, " +
1487
- "but got " + (toRawType(inject)) + ".",
1488
- vm
1489
- );
1490
- }
1491
- }
1492
-
1493
- /**
1494
- * Normalize raw function directives into object format.
1495
- */
1496
- function normalizeDirectives (options) {
1497
- var dirs = options.directives;
1498
- if (dirs) {
1499
- for (var key in dirs) {
1500
- var def$$1 = dirs[key];
1501
- if (typeof def$$1 === 'function') {
1502
- dirs[key] = { bind: def$$1, update: def$$1 };
1503
- }
1504
- }
1505
- }
1506
- }
1507
-
1508
- function assertObjectType (name, value, vm) {
1509
- if (!isPlainObject(value)) {
1510
- warn(
1511
- "Invalid value for option \"" + name + "\": expected an Object, " +
1512
- "but got " + (toRawType(value)) + ".",
1513
- vm
1514
- );
1515
- }
1516
- }
1517
-
1518
- /**
1519
- * Merge two option objects into a new one.
1520
- * Core utility used in both instantiation and inheritance.
1521
- */
1522
- function mergeOptions (
1523
- parent,
1524
- child,
1525
- vm
1526
- ) {
1527
- {
1528
- checkComponents(child);
1529
- }
1530
-
1531
- if (typeof child === 'function') {
1532
- child = child.options;
1533
- }
1534
-
1535
- normalizeProps(child, vm);
1536
- normalizeInject(child, vm);
1537
- normalizeDirectives(child);
1538
-
1539
- // Apply extends and mixins on the child options,
1540
- // but only if it is a raw options object that isn't
1541
- // the result of another mergeOptions call.
1542
- // Only merged options has the _base property.
1543
- if (!child._base) {
1544
- if (child.extends) {
1545
- parent = mergeOptions(parent, child.extends, vm);
1546
- }
1547
- if (child.mixins) {
1548
- for (var i = 0, l = child.mixins.length; i < l; i++) {
1549
- parent = mergeOptions(parent, child.mixins[i], vm);
1550
- }
1551
- }
1552
- }
1553
-
1554
- var options = {};
1555
- var key;
1556
- for (key in parent) {
1557
- mergeField(key);
1558
- }
1559
- for (key in child) {
1560
- if (!hasOwn(parent, key)) {
1561
- mergeField(key);
1562
- }
1563
- }
1564
- function mergeField (key) {
1565
- var strat = strats[key] || defaultStrat;
1566
- options[key] = strat(parent[key], child[key], vm, key);
1567
- }
1568
- return options
1569
- }
1570
-
1571
- /**
1572
- * Resolve an asset.
1573
- * This function is used because child instances need access
1574
- * to assets defined in its ancestor chain.
1575
- */
1576
- function resolveAsset (
1577
- options,
1578
- type,
1579
- id,
1580
- warnMissing
1581
- ) {
1582
- /* istanbul ignore if */
1583
- if (typeof id !== 'string') {
1584
- return
1585
- }
1586
- var assets = options[type];
1587
- // check local registration variations first
1588
- if (hasOwn(assets, id)) { return assets[id] }
1589
- var camelizedId = camelize(id);
1590
- if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
1591
- var PascalCaseId = capitalize(camelizedId);
1592
- if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
1593
- // fallback to prototype chain
1594
- var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
1595
- if (warnMissing && !res) {
1596
- warn(
1597
- 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
1598
- options
1599
- );
1600
- }
1601
- return res
1602
- }
1603
-
1604
- /* */
1605
-
1606
-
1607
-
1608
- function validateProp (
1609
- key,
1610
- propOptions,
1611
- propsData,
1612
- vm
1613
- ) {
1614
- var prop = propOptions[key];
1615
- var absent = !hasOwn(propsData, key);
1616
- var value = propsData[key];
1617
- // boolean casting
1618
- var booleanIndex = getTypeIndex(Boolean, prop.type);
1619
- if (booleanIndex > -1) {
1620
- if (absent && !hasOwn(prop, 'default')) {
1621
- value = false;
1622
- } else if (value === '' || value === hyphenate(key)) {
1623
- // only cast empty string / same name to boolean if
1624
- // boolean has higher priority
1625
- var stringIndex = getTypeIndex(String, prop.type);
1626
- if (stringIndex < 0 || booleanIndex < stringIndex) {
1627
- value = true;
1628
- }
1629
- }
1630
- }
1631
- // check default value
1632
- if (value === undefined) {
1633
- value = getPropDefaultValue(vm, prop, key);
1634
- // since the default value is a fresh copy,
1635
- // make sure to observe it.
1636
- var prevShouldObserve = shouldObserve;
1637
- toggleObserving(true);
1638
- observe(value);
1639
- toggleObserving(prevShouldObserve);
1640
- }
1641
- {
1642
- assertProp(prop, key, value, vm, absent);
1643
- }
1644
- return value
1645
- }
1646
-
1647
- /**
1648
- * Get the default value of a prop.
1649
- */
1650
- function getPropDefaultValue (vm, prop, key) {
1651
- // no default, return undefined
1652
- if (!hasOwn(prop, 'default')) {
1653
- return undefined
1654
- }
1655
- var def = prop.default;
1656
- // warn against non-factory defaults for Object & Array
1657
- if (isObject(def)) {
1658
- warn(
1659
- 'Invalid default value for prop "' + key + '": ' +
1660
- 'Props with type Object/Array must use a factory function ' +
1661
- 'to return the default value.',
1662
- vm
1663
- );
1664
- }
1665
- // the raw prop value was also undefined from previous render,
1666
- // return previous default value to avoid unnecessary watcher trigger
1667
- if (vm && vm.$options.propsData &&
1668
- vm.$options.propsData[key] === undefined &&
1669
- vm._props[key] !== undefined
1670
- ) {
1671
- return vm._props[key]
1672
- }
1673
- // call factory function for non-Function types
1674
- // a value is Function if its prototype is function even across different execution context
1675
- return typeof def === 'function' && getType(prop.type) !== 'Function'
1676
- ? def.call(vm)
1677
- : def
1678
- }
1679
-
1680
- /**
1681
- * Assert whether a prop is valid.
1682
- */
1683
- function assertProp (
1684
- prop,
1685
- name,
1686
- value,
1687
- vm,
1688
- absent
1689
- ) {
1690
- if (prop.required && absent) {
1691
- warn(
1692
- 'Missing required prop: "' + name + '"',
1693
- vm
1694
- );
1695
- return
1696
- }
1697
- if (value == null && !prop.required) {
1698
- return
1699
- }
1700
- var type = prop.type;
1701
- var valid = !type || type === true;
1702
- var expectedTypes = [];
1703
- if (type) {
1704
- if (!Array.isArray(type)) {
1705
- type = [type];
1706
- }
1707
- for (var i = 0; i < type.length && !valid; i++) {
1708
- var assertedType = assertType(value, type[i]);
1709
- expectedTypes.push(assertedType.expectedType || '');
1710
- valid = assertedType.valid;
1711
- }
1712
- }
1713
-
1714
- if (!valid) {
1715
- warn(
1716
- getInvalidTypeMessage(name, value, expectedTypes),
1717
- vm
1718
- );
1719
- return
1720
- }
1721
- var validator = prop.validator;
1722
- if (validator) { <