(()=>{function n(n){let e=document.querySelector(n);return e instanceof HTMLElement?e:null}function e(n){let e=document.querySelectorAll(n),t=[];for(let n=0;n<e.length;n++){let o=e[n];o instanceof HTMLElement&&t.push(o)}return t}function t(n){let e=document.querySelector(n);return e instanceof HTMLInputElement?e:null}!function(o){let i;let s=n(".udb-onboarding-page"),a=n(".onboarding-heatbox .heatbox-footer"),d=n(".onboarding-heatbox .skip-button"),u=n(".onboarding-heatbox .save-button"),l=n(".onboarding-heatbox .subscribe-button"),c=n(".udb-skip-discount a"),r=e("[data-udb-show-on='subscribe']"),b=e("[data-udb-show-on='skip-discount']"),f=n(".onboarding-heatbox .udb-discount-notif"),p=["modules","subscription","finished"],g="modules",h=!1,m=window.udbPluginOnboarding;function x(n){"modules"===(g=p[n.index])?(f?.classList.add("is-hidden"),a?.classList.remove("is-hidden")):"subscription"===g?(f?.classList.remove("is-hidden"),a?.classList.add("is-hidden")):"finished"===g&&(f?.classList.add("is-hidden"),a?.classList.add("is-hidden"))}function v(n){switch(g){case"modules":i.goTo("next");break;case"subscription":window.location.href=m?.adminUrl??""}}function y(n){h||(E(u),o.ajax({url:m?.ajaxUrl,type:"POST",data:{action:"udb_plugin_onboarding_save_modules",nonce:m?.nonces.saveModules,modules:function(){let n=function(n){let e=document.querySelectorAll(n),t=[];for(let n=0;n<e.length;n++){let o=e[n];o instanceof HTMLInputElement&&t.push(o)}return t}('.udb-modules-slide .module-toggle input[type="checkbox"]');if(!n.length)return[];let e=[];return n.forEach(function(n){let t=n.id.replace("udb_modules__","");n.checked&&e.push(t)}),e}()}}).done(function(n){n.success&&i.goTo("next")}).fail(w).always(function(){k(u)}))}function L(n){let e=t("#udb-subscription-name"),a=t("#udb-subscription-email");!h&&e&&a&&(E(l),o.ajax({url:m?.ajaxUrl,type:"POST",data:{action:"udb_plugin_onboarding_subscribe",nonce:m?.nonces.subscribe,name:e.value,email:a.value,referrer:s?.dataset.udbReferrer??""}}).done(function(n){n.success&&(b.forEach(function(n){n.style.display="none"}),S(),i.goTo("next"))}).fail(w).always(function(){k(l)}))}function _(n){n.preventDefault(),h||(E(c?.parentElement),o.ajax({url:m?.ajaxUrl,type:"POST",data:{action:"udb_plugin_onboarding_skip_discount",nonce:m?.nonces.skipDiscount,referrer:s?.dataset.udbReferrer}}).done(function(n){n.success&&(r.forEach(function(n){n.style.display="none"}),S(),i.goTo("next"))}).fail(w).always(function(){k(c?.parentElement)}))}function w(n){let e="Something went wrong";n.responseJSON&&n.responseJSON.data&&(e=n.responseJSON.data),alert(e)}function E(n){h=!0,n?.classList.add("is-loading")}function k(n){n?.classList.remove("is-loading"),h=!1}function S(){let n=e("#menu-posts-udb_widgets .wp-submenu > li > a");if(n.length)for(let e=0;e<n.length;e++){let t=n[e];if(t instanceof HTMLAnchorElement&&t.href.includes("page=udb_plugin_onboarding")){t.parentElement?.remove();break}}}s&&a&&d&&u&&f&&l&&c&&(i=window.tns({container:".udb-onboarding-slides",items:1,loop:!1,autoHeight:!0,controls:!1,navPosition:"bottom",onInit:function(n){i.events.on("indexChanged",x);let e=document.querySelector(".onboarding-heatbox .udb-dots");e&&n.navContainer&&e.appendChild(n.navContainer),d?.addEventListener("click",v),u?.addEventListener("click",y),l?.addEventListener("click",L),c?.addEventListener("click",_)}}))}(jQuery)})();
//# sourceMappingURL=plugin-onboarding.js.map
