(()=>{"use strict";var e={};// The module cache
var t={};// The require function
function r(o){// Check if module is in cache
var a=t[o];if(a!==undefined){return a.exports}// Create a new module (and put it into the cache)
var i=t[o]={exports:{}};// Execute the module function
e[o](i,i.exports,r);// Return the exports of the module
return i.exports}// webpack/runtime/rspack_version
(()=>{r.rv=()=>"1.6.5"})();// webpack/runtime/rspack_unique_id
(()=>{r.ruid="bundler=rspack@1.6.5"})();// CONCATENATED MODULE: ./node_modules/@swc/helpers/esm/_async_to_generator.js
function o(e,t,r,o,a,i,l){try{var n=e[i](l);var s=n.value}catch(e){r(e);return}if(n.done)t(s);else Promise.resolve(s).then(o,a)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(a,i){var l=e.apply(t,r);function n(e){o(l,a,i,n,s,"next",e)}function s(e){o(l,a,i,n,s,"throw",e)}n(undefined)})}};// CONCATENATED MODULE: ./addons/tutor-email/assets/react/modules/utils.js
/**
 * Check valid test e-mail address.
 * 
 * @since 2.5.0
 *
 * @param {string} emails comma separated email address. 
 *
 * @return bool
 */function i(e){var t=e.split(",");var r=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;for(var o=0;o<t.length;o++){var a=t[o].trim();if(!r.test(a)){return false}}return true}function l(e,t){var{__}=wp.i18n;return new Promise((r,o)=>{var a=new FormData(e);a.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);var l=a.get("action");if(l==="save_email_template"){a.append(t.name,t.value)}if(l==="save_email_settings"){// Sender Email Address and Name are required for default configuration
var n=a.get("email_from_address");var s=a.get("email_from_name");if(!n||!s){e.reportValidity();return o(__("Sender Email Address and Name are required!","tutor-pro"))}if(!i(n)){e.reportValidity();return o(__("Please provide a valid Email Address","tutor-pro"))}}else{// E-mail subject and heading are required for trigger template.
var c=a.get("email-subject")||a.get("email_subject");var u=a.get("email-heading")||a.get("email_heading");if(!c||!u){e.reportValidity();return o(__("Email subject and heading are required!","tutor-pro"))}}var d=new XMLHttpRequest;d.open("POST",_tutorobject.ajaxurl,true);d.send(a);d.onreadystatechange=e=>{if(d.readyState===4){var t=JSON.parse(d.response);if(t.success){r(t.message)}else{o(t.message)}}}})}function n(e,t){if(e){if(e.src){e.src=t}else{e.innerHTML=t}}}function s(e){var t=document.createElement("iframe");t.width="100%";t.height="800px";t.src="".concat(_tutorobject.home_url,"?page=tutor-email-preview&template=").concat(e);return t}function c(e){var t=e.querySelector(".tutor-email-body");var r=e.querySelector(".tutor-email-footer-text");var o=e.querySelector(".tutor-email-footer-content");var a=e.querySelectorAll("a");t.style.paddingTop="0px";t.style.paddingLeft="0px";t.style.paddingRight="0px";t.style.backgroundColor="transparent";o.style.backgroundColor="transparent";a.forEach(e=>{e.classList.add("preview-only");e.addEventListener("click",e=>e.preventDefault())});if(r){var i=new URLSearchParams(window.location.href);var l=i.get("edit");if(l==="settings"){r.innerText="Example of a no-reply or instructional footnote"}}// Replace user avatar with dummy image
var n=t.querySelectorAll(".user-avatar");n.forEach(e=>{e.src="http://2.gravatar.com/avatar/bc78e9eeca4abe2043bb671018d504ef?s=96&d=mm&r=g"})}function u(e){if(!e||e.length===0){return""}return'	\n        <ul class="tutor-dropdown" style="width: 100%; margin: 0; max-height: 200px; overflow: scroll;">\n            '.concat(e.map(e=>{return'\n                    <li>\n                        <a class="tutor-dropdown-item tutor-d-flex tutor-justify-between" href="#" data-state-text="'.concat(e.placeholder,'">\n                            <span class="tutor-color-muted">').concat(e.placeholder,"</span>\n                            <span>").concat(e.label,"</span>\n                        </a>\n                    </li>\n                ")}).join(""),"\n        </ul>\n    ")}function d(e,t){var r=new FormData;r.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);r.append("action","tutor_manual_email_receiver_count_help_text");r.append("receiver_type",e);if(t){t.forEach(e=>{r.append("course_ids[]",e)})}return jQuery.ajax({url:_tutorobject.ajaxurl,method:"POST",data:r,processData:false,contentType:false})}function m(e,t,r,o){if(e){e.style.setProperty(t,r,o)}}function p(e){var t=e.selection.getRng();var r=t.getClientRects()[0];// Use the first rectangle in the list
if(r){var o={offsetTop:r.top+124,offsetLeft:r.left};return o}return{}}// Replace email triggers default contents
function v(e){var t={subject:"email-subject",heading:"email-heading",message:"email-additional-message",before_button:"email-before-button",footer_text:"email-footer-text"};Object.keys(e).map(r=>{if(r==="message"){var o=tinymce.get(t[r]);if(o){o.setContent(JSON.parse(e[r]));tinymce.triggerSave()}}else{var a=document.querySelector("[name=".concat(t[r],"]"));if(a){a.value=e[r];a.dispatchEvent(new Event("input",{bubbles:true}))}}})};// CONCATENATED MODULE: ./addons/tutor-email/assets/react/modules/default-settings.js
document.addEventListener("DOMContentLoaded",()=>{var e=document.querySelector("#tutor-email-settings-form")||document.querySelector("#tutor-mailer-form");if(e){var t;// Reflect the changes in preview
var r=e.querySelectorAll("input");r.forEach(e=>{e.addEventListener("input",e=>{var{name:t,value:r}=e.target;var o=document.querySelector(".template-preview iframe");if(o){var a=o.contentWindow.document;var i=a.querySelector(".tutor-email-logo img");var l=a.querySelector(".tutor-email-header");var n=a.querySelector(".tutor-email-content");var s=a.querySelector(".tutor-email-footer");var c=a.querySelector(".tutor-email-footer-text");var u=a.querySelector(".tutor-email-heading");var d=a.querySelector(".tutor-email-buttons");var p=a.querySelector(".tutor-email-button");var v=a.querySelector(".tutor-email-button-bordered");switch(t){case"email_logo_position":m(i.parentElement,"text-align",r);break;case"email_logo_height":m(i,"height",r+"px");break;case"email_logo_alt_text":i.setAttribute("alt",r);break;case"email_template_button_position":m(d,"text-align",r);break;case"email_template_colors[header_background_color]":m(l,"background-color",r);break;case"email_template_colors[header_divider_color]":m(l,"border-color",r);break;case"email_template_colors[body_background_color]":m(n,"background-color",r);m(s,"background-color",r);break;case"email_template_colors[email_title_color]":m(u,"color",r);break;case"email_template_colors[email_text_color]":m(n,"color",r);break;case"email_template_colors[email_short_code_color]":a.querySelectorAll("strong").forEach(e=>{m(e,"color",r)});break;case"email_template_colors[footnote_color]":m(c,"color",r);break;case"email_template_colors[primary_button_color]":m(p,"--primary-button-color",r);break;case"email_template_colors[primary_button_hover_color]":m(p,"--primary-button-hover-color",r);break;case"email_template_colors[primary_button_text_color]":m(p,"color",r,"important");break;case"email_template_colors[secondary_button_color]":m(v,"--secondary-button-color",r);break;case"email_template_colors[secondary_button_hover_color]":m(v,"--secondary-button-hover-color",r);break;case"email_template_colors[secondary_button_text_color]":m(v,"color",r,"important");break;default:break}}})});(t=document.querySelector(".tutor-thumbnail-uploader"))===null||t===void 0?void 0:t.addEventListener("tutor_settings_media_selected",e=>{var t=document.querySelector(".template-preview iframe");if(t){var r=t.contentWindow.document;var o=r.querySelector(".tutor-email-logo img");o.setAttribute("src",e.detail.attachment.url)}});// Restore default colors
var o=document.querySelector(".tutor-email-colors");var a=document.querySelector(".tutor-color-restore-button");a.addEventListener("click",e=>{var t=JSON.parse(e.target.dataset.defaults);var r=o.querySelectorAll("input[type=color]");r.forEach(e=>{e.value=t[e.dataset.picker];e.dispatchEvent(new Event("input"))})});jQuery(document).on("input","input.email-logo-url",function(){var e=jQuery(this),t=e.val(),r=e.parent().parent().find(".thumbnail-preview img").eq(0);if(r){r.attr("src",t)}})}// Card collapse functions
jQuery(".tutor-card-collapse-button").click(function(e){if(jQuery(this).find("i").hasClass("tutor-icon-angle-up")){jQuery(this).find("i").removeClass("tutor-icon-angle-up").addClass("tutor-icon-angle-down")}else{jQuery(this).find("i").removeClass("tutor-icon-angle-down").addClass("tutor-icon-angle-up")}jQuery(e.target.closest(".tutor-card")).find(".tutor-card-body").slideToggle()})});// CONCATENATED MODULE: ./addons/tutor-email/assets/react/modules/email-placeholders.js
window.addEventListener("DOMContentLoaded",()=>{// Add dropdown with placeholder items
var e=document.querySelectorAll(".tutor-option-field-input.tutor-email-placeholders");e.forEach(e=>{var t=e.dataset.placeholders;var r=document.createElement("div");r.setAttribute("class","tutor-dropdown-parent");r.innerHTML=u(t?JSON.parse(t):window._tutorEmailPlaceholders);var o=e.classList.contains("tutor-has-tinymce-editor");e.insertBefore(r,o?e.firstChild:e.lastChild)});// Open dropdown when '{' is pressed
var t=document.querySelectorAll('.tutor-option-field-input.tutor-email-placeholders input[type="text"], .tutor-option-field-input.tutor-email-placeholders textarea');t.forEach(e=>{e.addEventListener("input",e=>{var t=e.target.parentNode.querySelector(".tutor-dropdown-parent");if(t&&t.hasChildNodes()){if(e.data==="{"){e.target.blur();t.classList.add("is-open");t.querySelectorAll(".tutor-dropdown-item")[0].classList.add("is-active");t.querySelectorAll(".tutor-dropdown-item")[0].focus();document.querySelector("body").style.overflow="hidden";setTimeout(()=>{t.querySelector(".tutor-dropdown").scrollTop=0},100)}else{t.classList.remove("is-open");document.querySelector("body").style.overflow="auto"}}})});// Handle dropdown item click
var r=document.querySelectorAll(".tutor-option-field-input.tutor-email-placeholders .tutor-dropdown-item");r.forEach(e=>{e.addEventListener("click",t=>{t.preventDefault();var r=e.getAttribute("data-state-text");r=r.slice(1,r.length);var o=e.closest(".tutor-option-field-input").querySelector(":scope > input, :scope > textarea");if(o){var a=o.selectionStart;var i=a+r.length;o.value=o.value.substring(0,a)+r+o.value.substring(a);o.dispatchEvent(new Event("input",{bubbles:true}));o.setSelectionRange(i,i);o.focus()}else if(tinymce.activeEditor){tinymce.activeEditor.insertContent(r);tinymce.triggerSave()}})});var o=0;document.addEventListener("keydown",function(e){var t=document.querySelector(".tutor-email-placeholders .tutor-dropdown-parent.is-open");if(t){var r=t.querySelectorAll(".tutor-dropdown-item");if(e.key==="ArrowUp"){if(o>0){o-=1;r.forEach(e=>{e.classList.remove("is-active");e.blur()});r[o].classList.add("is-active");r[o].focus()}}else if(e.key==="ArrowDown"){if(o<r.length-1){o+=1;r.forEach(e=>{e.classList.remove("is-active");e.blur()});r[o].classList.add("is-active");r[o].focus()}}else if(e.key==="Enter"){var a=document.querySelector(".tutor-email-placeholders .tutor-dropdown-item.is-active");if(a){a.click();o=0;r.forEach(e=>{e.classList.remove("is-active");e.blur()})}}else{o=0}if(e.key==="Escape"){t.classList.remove("is-open");r.forEach(e=>{e.classList.remove("is-active");e.blur()});var i=t.closest(".tutor-option-field-input").querySelector(":scope > input, :scope > textarea");if(i){i.focus()}else if(tinymce.activeEditor){tinymce.activeEditor.focus()}}}});document.querySelectorAll(".tutor-email-placeholders .tutor-dropdown-parent").forEach(e=>{e.addEventListener("tutor_dropdown_closed",e=>{document.querySelector("body").style.overflow="auto";e.target.querySelectorAll(".tutor-dropdown-item").forEach(e=>e.classList.remove("is-active"))})})});document.addEventListener("readystatechange",()=>{if(typeof tinymce!="undefined"&&tinymce.activeEditor){tinymce.activeEditor.on("input",function(e){var{offsetTop:t,offsetLeft:r}=p(tinymce.activeEditor);var o=document.querySelector(".wp-editor-wrap");var a=o.parentNode.querySelector(".tutor-dropdown-parent");if(a&&a.hasChildNodes()){if(e.data==="{"){var i=document.createElement("input");a.appendChild(i);i.focus();a.removeChild(i);a.classList.add("is-open");a.querySelector(".tutor-dropdown").style.top=t+"px";a.querySelectorAll(".tutor-dropdown-item")[0].classList.add("is-active");a.querySelectorAll(".tutor-dropdown-item")[0].focus();document.querySelector("body").style.overflow="hidden";setTimeout(()=>{a.querySelector(".tutor-dropdown").scrollTop=0},100)}else{a.classList.remove("is-open");document.querySelector("body").style.overflow="auto"}}})}});// CONCATENATED MODULE: ./addons/tutor-email/assets/react/email-template.js
var f=["instructors_of_courses","instructors_except_courses","students_of_courses","students_except_courses","students_completed_courses"];document.addEventListener("DOMContentLoaded",()=>a(function*(){var{__,_x:e,_n:t,_nx:r,sprintf:o}=wp.i18n;var u=__("Success","tutor-pro");var m=__("Error","tutor-pro");var p=document.querySelector("#email_template_title");var y=document.querySelector("#email_option_data");var _=document.querySelector("#tutor-email-template-form");var g=document.querySelector("#tutor-email-settings-form");var b=document.querySelector("#tutor-mailer-form");var h;if(_){h=_}else if(g){h=g}else if(b){h=b}var S=document.querySelector("[action-tutor-email-template-save]");var q=document.querySelector("#tutor-btn-test-mail");var E=document.querySelector("#tutor-btn-save-draft");var w=document.querySelector("#tutor-btn-confirm-manual-mail");var L=document.querySelector("#tutor-btn-send-manual-mail");var x=document.querySelector(".template-preview");var k=x.dataset.email_template;var j=s(k);x.append(j);j.addEventListener("load",e=>{var t;(t=document.querySelector(".loading-spinner"))===null||t===void 0?void 0:t.remove();var r=e.target.contentWindow.document;c(r);// Email responsive preview buttons
    var o=document.querySelectorAll(".tutor-email-preview-responsive-buttons button");o.forEach(e=>{e.addEventListener("click",t=>{t.stopImmediatePropagation();o.forEach(e=>e.classList.remove("active"));e.classList.add("active");if(e.dataset.previewMode==="mobile"){j.width="375px"}else{j.width="100%"}})});// TinyMce editor content realtime update.
    if(typeof tinymce!=="undefined"&&tinymce.activeEditor){tinymce.activeEditor.on("change",e=>{var t=r.querySelector("[data-source=".concat(e.target.id,"]"));var o=tinymce.activeEditor.getContent().replace("/<[/]{0,1}div[^>]*>/i","");if(t){t.innerHTML=o}tinymce.triggerSave()})}// Email trigger template input fields value live preview on iframe
    var a=document.querySelectorAll('.tutor-email-edit-form input[type="hidden"], .tutor-email-edit-form input[type="text"], .tutor-email-edit-form textarea');a.forEach(e=>{var{name:t,value:o}=e;if(t){var a=r.querySelector("[data-source=".concat(t,"]"));n(a,o);e.addEventListener("input",e=>{n(a,e.target.value)})}});// Mailer settings functionalities
    if(b){var i=r.querySelector(".tutor-email-buttons");var l=document.querySelector(".mailer-page input[name=email_action_button]");var s=document.querySelector(".mailer-page input[name=email_action_position]");if(l.value==="off"){i.style.display="none";l.closest(".tutor-card").querySelector(".tutor-card-body").style.display="none"}l.nextElementSibling.addEventListener("change",e=>{jQuery(e.target.closest(".tutor-card")).find(".tutor-card-body").slideToggle();if(l.value==="on"){i.style.display="block"}else{i.style.display="none"}});s.addEventListener("input",e=>{i.style.textAlign=e.target.value});// Hide email footer if there is no text
    var u=b.querySelector("input[name=email_footer]");if(u){if(u.value){r.querySelector(".tutor-email-footer").style.display="block"}else{r.querySelector(".tutor-email-footer").style.display="none"}u.addEventListener("input",e=>{if(e.target.value){r.querySelector(".tutor-email-footer").style.display="block"}else{r.querySelector(".tutor-email-footer").style.display="none"}})}}});// Mailer select course hide and show function
    if(b){var A=b.querySelector("select[name=receiver_type]");var T=b.querySelector("#tutor-mailer-course-ids");var C=b.querySelector(".tutor-receiver-count-message");if(A&&T){// Initiate select 2 library
    jQuery(T).select2();if(T.dataset.selected){jQuery(T).val(JSON.parse(T.dataset.selected)).trigger("change")}// Hide select course initially
    if(!f.includes(A.value)){T.parentElement.style.display="none"}// Show mail receiver count message initially
    if(A.value){var Q=[];var D=jQuery(T).select2("data");if(D.length){Q=D.map(e=>e.id)}var P=yield d(A.value,Q);if(P.success&&C){C.style.setProperty("display","flex","important");C.querySelector("div").innerText=P.data.message;document.querySelector(".tutor-email-modal-title strong").innerText=P.data.count}}A.addEventListener("change",e=>a(function*(){var t=e.target.value;if(f.includes(t)){T.parentElement.style.display="block"}else{T.parentElement.style.display="none"}// Reset selected course value
        if(jQuery(T).select2("data").length){jQuery(T).val(null).trigger("change")}// Show mail receiver count message
        if(!f.includes(A.value)){var r=yield d(t);if(r.success&&C){C.style.setProperty("display","flex","important");C.querySelector("div").innerText=r.data.message;document.querySelector(".tutor-email-modal-title strong").innerText=r.data.count}}})());// Show mail receiver count message
    jQuery(T).on("change",e=>a(function*(){var e=jQuery(T).select2("data");if(e.length){var t=e.map(e=>e.id);var r=yield d(A.value,t);if(r.success&&C){C.style.setProperty("display","flex","important");C.querySelector("div").innerText=r.data.message;document.querySelector(".tutor-email-modal-title strong").innerText=r.data.count}}})())}}// Restore email triggers default contents
    var N=document.querySelector(".tutor-trigger-restore-button");if(N){N.addEventListener("click",function(e){if(e.target.dataset.defaults){v(JSON.parse(e.target.dataset.defaults))}})}if(q){q.addEventListener("click",e=>{e.preventDefault();var t=document.getElementsByName("testing_email")[0].value;if(!i(t)){tutor_toast(__("Sorry","tutor-pro"),__("Invalid e-mail address","tutor-pro"),"error");return}var r;if(_){r="trigger_template"}else if(g){r="email_settings"}else if(b){r="mailer"}var a=new FormData;a.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);a.append("test_type",r);a.append("email_template",k);a.append("action","send_test_email_ajax");a.append("testing_email",t);if(_){a.append("email_to",document.getElementsByName("to")[0].value);a.append("email_key",document.getElementsByName("key")[0].value)}q.classList.add("is-loading");q.disabled=true;l(h,y).then(()=>{jQuery.ajax({url:_tutorobject.ajaxurl,method:"POST",data:a,processData:false,contentType:false,success:function e(e){var t=q.closest(".tutor-dropdown-parent");if(t){t.classList.remove("is-open")}tutor_toast(u,o(/* Translators: %s template name. */__("A test email for %s has been sent to admin!","tutor-pro"),'"'.concat(p.innerText,'"')),"success")},complete:function e(){q.classList.remove("is-loading");q.disabled=false}})}).catch(e=>{tutor_toast(m,e,"error");q.classList.remove("is-loading");q.disabled=false})})}if(S){S.addEventListener("click",e=>{S.classList.add("is-loading");S.disabled=true;if(!e.detail||e.detail==1){e.preventDefault();l(h,y).then(()=>{tutor_toast(u,o(/* Translators: %s template name. */__("%s email template updated!","tutor-pro"),'"'.concat(p.innerText,'"')),"success")}).catch(e=>{tutor_toast(m,e,"error")}).finally(()=>{S.classList.remove("is-loading");S.disabled=false})}})}if(E){E.addEventListener("click",e=>{e.preventDefault();var t=e.target;t.classList.add("is-loading");t.disabled=true;l(b).then(()=>{tutor_toast(u,__("Email saved successfully!","tutor-pro"),"success")}).catch(e=>{tutor_toast(m,e,"error")}).finally(()=>{t.classList.remove("is-loading");t.disabled=false})})}if(w){w.addEventListener("click",e=>{var t;e.preventDefault();var r=b.querySelector("#tutor-mailer-course-ids");var o=jQuery(r).select2("data");var a=(t=b.querySelector("select[name=receiver_type]"))===null||t===void 0?void 0:t.value;if(!a){return tutor_toast(m,__("Email receiver type is required!","tutor-pro"),"error")}if(f.includes(a)&&o.length===0){return tutor_toast(m,__("Select courses is required!","tutor-pro"),"error")}document.querySelector("#tutor-email-confirmation-modal").classList.add("tutor-is-active")})}if(L){L.addEventListener("click",e=>{e.preventDefault();var t=e.target;var r=new FormData;r.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);r.append("email_template",k);r.append("action","tutor_sent_manual_email");t.classList.add("is-loading");t.disabled=true;l(b).then(()=>{jQuery.ajax({url:_tutorobject.ajaxurl,method:"POST",data:r,processData:false,contentType:false,success:function e(e){if(e.success){tutor_toast(u,e.message,"success")}else{tutor_toast(m,e.message,"error")}},complete:function e(){t.classList.remove("is-loading");t.disabled=false;document.querySelector("#tutor-email-confirmation-modal").classList.remove("tutor-is-active")}})}).catch(e=>{tutor_toast(m,e,"error");t.classList.remove("is-loading");t.disabled=false})})}})())})();