File: /var/www/html/wpprotonperinggit/wp-content/plugins/creame-whatsapp-me/admin/js/joinchat-page.min.js
((p,v,j)=>{function m(){p(this).height(0).height(this.scrollHeight)}function b(t){return t.replace(/^0+|\D/,"").replace(/^54(0|1|2|3|4|5|6|7|8)/,"549$1").replace(/^(54\d{5})15(\d{6})/,"$1$2").replace(/^52(0|2|3|4|5|6|7|8|9)/,"521$1")}function f(e,n){let i=null;return(...t)=>{clearTimeout(i),i=setTimeout(()=>e.apply(null,t),n)}}p(function(){var n,t,e,i="function"==typeof intlTelInput&&v.intl_tel_l10n,o=p("#joinchat_phone"),a=(i&&(t=!(!(t=JSON.parse(localStorage.joinchat_country_code||"{}")).code||t.date!=(new Date).toDateString())&&t.code,v.joinchat_intl_tel_config={hiddenInput:()=>({phone:o.data("name")||"joinchat[telephone]"}),strictMode:!0,separateDialCode:!0,initialCountry:t||"auto",geoIpLookup:t?null:(e,t)=>{fetch("https://ipapi.co/json").then(t=>t.json()).then(t=>{localStorage.joinchat_country_code=JSON.stringify({code:t.country_code,date:(new Date).toDateString()}),e(t.country_code)}).catch(()=>t())},customPlaceholder:t=>intl_tel_l10n.placeholder+" "+t,i18n:intl_tel_l10n},o.length)&&((e=intlTelInput(o[0],joinchat_intl_tel_config)).promise.then(()=>{o.trigger("input")}),o.on("input countrychange",function(){var t=e.isValidNumber(!0);p(this).css("color",this.value.trim()&&!t?"#ca4a1f":""),e.hiddenInput.value=e.getNumber(),p("#joinchat_phone_test").attr("disabled",!t)})),p(".nav-tab").on("click",function(t){t.preventDefault();var t=p(this),e=t.attr("href"),n=p("input[name=_wp_http_referer]"),i=n.val();n.val(i.substr(0,i.indexOf("page=joinchat"))+"page=joinchat&tab="+e.substr(14)),p(".nav-tab").removeClass("nav-tab-active").attr("aria-selected","false"),t.addClass("nav-tab-active").attr("aria-selected","true").get(0).blur(),p(".joinchat-tab").removeClass("joinchat-tab-active"),p(e).addClass("joinchat-tab-active"),p(j).trigger("navtabchange",[p(e),e])}),p(j).on("navtabchange",function(t,e){e.find("textarea").each(m)}),o.length&&(i||o.on("input change",function(){p("#joinchat_phone_test").attr("disabled",this.value.length<7)}),p("#joinchat_phone_test").on("click",function(){var t=i?intlTelInput.getInstance(o[0]).getNumber():o.val();v.open("https://wa.me/"+encodeURIComponent(b(t)),"joinchat","noopener")})),p("#joinchat_mobile_only").on("change",function(){p("#joinchat_whatsapp_web").closest("tr").toggleClass("joinchat-dimmed",this.checked)}).trigger("change"),p('input[name="joinchat[header]"]').on("change",function(){p("#joinchat_header_custom").toggleClass("joinchat-dimmed","__custom__"!=this.value)}).trigger("change"),p("#joinchat_message_delay_on").on("change",function(){p("#joinchat_message_delay, #joinchat_message_views, #joinchat_message_badge").parent().toggleClass("joinchat-dimmed",!this.checked),p(".joinchat-cookies-notice").toggleClass("joinchat-hidden",!this.checked)}).trigger("change"),p(".joinchat-show-help").on("click",function(t){t.preventDefault();t=p(this).attr("href");p("#contextual-help-wrap").is(":visible")?p("html, body").animate({scrollTop:0}):p("#contextual-help-link").trigger("click"),p("#"!=t?t:"#tab-link-styles-and-vars").find("a").trigger("click")}),p("textarea","#joinchat_form").on("focus",function(){p(this).closest("tr").addClass("joinchat--focus")}).on("blur",function(){p(this).closest("tr").removeClass("joinchat--focus")}).on("input",m).each(m),p("#joinchat_form").find(".autofill").on("change",function(){this.title=""==this.value?joinchat_admin.example:""}).on("dblclick",function(){""==this.value&&(this.value=this.placeholder,this.title="",p(this).trigger("change"))}).trigger("change"),p("#joinchat_tab_visibility")),c=p(".joinchat_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]};function s(t,e){var n;t=t||"all",e=e||p('input[name="joinchat[view]['+t+']"]:checked').val(),p(".view_inheritance_"+t).toggleClass("dashicons-visibility","yes"==e).toggleClass("dashicons-hidden","no"==e),"cpts"==t?p("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==e).toggleClass("dashicons-hidden","no"==e):t in c&&(n=""===(n=p('input[name="joinchat[view]['+t+']"]:checked').val())?e:n,p.each(c[t],function(){s(this,n)}))}p("input",a).on("change",function(){s()}),p(".joinchat_view_reset").on("click",function(t){t.preventDefault(),p('input[value=""]',a).prop("checked",!0),p(".joinchat_view_all input",a).first().prop("checked",!0),s()}),s(),p("#joinchat_button_image_add").on("click",function(t){t.preventDefault(),n||((n=wp.media({title:p(this).data("title")||"Select button image",button:{text:p(this).data("button")||"Use Image"},library:{type:"image,video"},multiple:!1})).on("select",function(){var t=n.state().get("selection").first().toJSON(),e=t.sizes&&t.sizes.thumbnail&&t.sizes.thumbnail.url||t.url,e="video"==t.type?'<video autoplay loop muted playsinline src="'+e+'"></video>':'<img src="'+e+'">';p("#joinchat_button_image_holder").html(e),p("#joinchat_button_image").val(t.id),p("#joinchat_button_image_wrapper").removeClass("no-image"),l&&(l.chatbox_hide(),l.$(".joinchat__button__image").innerHTML=e)}),n.on("open",function(){var t=wp.media.attachment(p("#joinchat_button_image").val());n.state().get("selection").add(t?[t]:[])})),n.open()}),p("#joinchat_button_image_remove").on("click",function(t){t.preventDefault(),p("#joinchat_button_image_holder").empty(),p("#joinchat_button_image").val(""),p("#joinchat_button_image_wrapper").addClass("no-image"),l&&l.$(".joinchat__button__image").replaceChildren()}),p("#joinchat_color").wpColorPicker({change:function(t,e){p(this).trigger("changecolor",[e.color.toHsl()])}}),p("#joinchat_color").on("changecolor",function(t,e){var n=p("#joinchat_form").get(0).style;n.setProperty("--ch",e.h),n.setProperty("--cs",e.s+"%"),n.setProperty("--cl",e.l+"%")}),p('input[name="joinchat[color][text]"]').on("change",function(){p("#joinchat_form").get(0).style.setProperty("--bw",this.value)}),p("#joinchat_header_custom").on("click",function(){p(this).prev().find("input").trigger("click")}),p('label[for="joinchat_optin_text"]').on("click",function(){tinymce.get("joinchat_optin_text").focus()}),p("#joinchat_woo_btn_position").on("change",function(){p("#joinchat_woo_btn_text").closest("tr").toggleClass("joinchat-hidden","none"==p(this).val())}).trigger("change");var h=wp.codeEditor.initialize(p("#joinchat_custom_css"),custom_css_settings),l=(p(j).on("navtabchange",function(t,e,n){"#joinchat_tab_advanced"==n&&h.codemirror.refresh()}),p('label[for="joinchat_custom_css"]').on("click",function(){h.codemirror.focus()}),p(".joinchat_custom_css_prefill").on("click",function(t){t.preventDefault(),h.codemirror.setValue(joinchat_admin.example_css)}),p(j).on("navtabchange",function(t,e,n){"#joinchat_tab_general"==n||"#joinchat_tab_advanced"==n?p("#joinchat_preview_show").removeClass("disabled"):(p("body").removeClass("jcpreview"),p("#joinchat_preview_show").addClass("disabled").removeClass("active"))}),null),r=!0;function _(t){if(void 0===t)return parseInt(getComputedStyle(j.documentElement).getPropertyValue("--preview-width"));t=Math.min(Math.max(t,360),680);j.documentElement.style.setProperty("--preview-width",t+"px"),p("#joinchatprev__devices .desktop").toggleClass("active",480<t),p("#joinchatprev__devices .mobile").toggleClass("active",t<=480)}function u(){l.has_chatbox=l.has_cta||l.has_optin,l.$div.classList.toggle("joinchat--btn",!l.has_chatbox)}function g(){r&&l.has_chatbox?l.chatbox_show():l.chatbox_hide()}function d(){var t=tinymce.get("joinchat_optin_text").getContent(),e=p("#joinchat_optin_check")[0].checked;l.has_optin=""!=t,u(),l.$div.classList.toggle("joinchat--optout",""!=t&&e),""==t?l.$(".joinchat__optin").replaceChildren():(t=t.replaceAll("<p>","").replaceAll("</p>","<br><br>").replace(/<br><br>$/,""),t=e?'<label for="joinchat_optin">'+t+"</label>":"<span>"+t+"</span>",l.$(".joinchat__optin").innerHTML='<input type="checkbox" id="joinchat_optin">'+t,l.$("#joinchat_optin").addEventListener("change",t=>l.$div.classList.toggle("joinchat--optout",!t.target.checked))),g()}p("#joinchat_preview_show").on("click",function(t){var e,n,i;function o(t){t.preventDefault(),_(n+(e-t.clientX)*i)}function a(t){t.preventDefault(),p("body").removeClass("jcpreview-resize").off("mousemove mouseup",o).off("mouseup mouseleave",a)}t.preventDefault(),p(this).hasClass("disabled")||(t=p(this).hasClass("active"),p(this).toggleClass("active",!t),p("body").toggleClass("jcpreview",!t),t)||0!=p("#joinchatprev").length||(p("#wpwrap").append(`
<div id="joinchatprev">
<div id="joinchatprev__resize"></div>
<div id="joinchatprev__devices">
<div class="button-group">
<button class="button desktop" title="Desktop"><span class="dashicons dashicons-desktop"></span></button>
<button class="button active mobile" title="Mobile"><span class="dashicons dashicons-smartphone"></span></button>
</div>
</div>
<iframe id="joinchat_preview" src="${joinchat_admin.home}?joinchat-preview=1" scrolling="no"></iframe>
</div>`),p("#joinchat_preview").on("load",function(){(l=this.contentWindow.joinchat_obj).has_cta=""!=p("#joinchat_message_text").val().trim(),l.has_optin=""!=tinymce.get("joinchat_optin_text").getContent(),p(j).trigger("preview",[this,l])}),p("#joinchatprev__devices .desktop").on("click",function(){_()<=480&&_(500)}),p("#joinchatprev__devices .mobile").on("click",function(){480<_()&&_(380)}),i=0<p("[dir=rtl]").length?-1:1,p("#joinchatprev__resize").on("mousedown",function(t){t.preventDefault(),e=t.clientX,n=_(),p("body").addClass("jcpreview-resize").on("mousemove mouseup",o).on("mouseup mouseleave",a)}))}),p(j).on("preview",function(){var t;function e(t){l.has_cta=""!=p(t.target).val().trim(),u(),l.update_cta(p(t.target).val().trim()),g()}u(),o.on("change",function(){l.settings.telephone=b(i?intlTelInput.getInstance(this).getNumber():p(this).val()),l.$div.classList.toggle("joinchat--disabled",""==l.settings.telephone)}),p("#joinchat_message_send").on("change",function(){l.settings.message_send=p(this).val()}),p("#joinchat_mobile_only").on("change",function(){l.$div.classList.toggle("joinchat--mobile_only",this.checked)}),p("#joinchat_button_tip").on("focus blur",t=>{"focus"==t.type&&l.chatbox_hide(),l.$(".joinchat__tooltip").classList.toggle("joinchat--show","focus"==t.type)}).on("input change",f(t=>{l.$(".joinchat__tooltip").classList.toggle("joinchat--hidden",""==p(t.target).val().trim()),l.$(".joinchat__tooltip div").textContent=p(t.target).val()},100)),p('input[name="joinchat[position]"]').on("change",function(){l.$div.classList.toggle("joinchat--right","right"==this.value),l.$div.classList.toggle("joinchat--left","left"==this.value)}),p('input[name="joinchat[button_image_fixed]"]').on("change",function(){l.chatbox_hide(),l.$div.classList.toggle("joinchat--img","yes"==this.value)}),p("#joinchat_qr").on("change",function(){clearTimeout(t),p("#joinchat_mobile_only")[0].checked||(this.checked&&(l.$(".joinchat__qr canvas")?.remove(),l.$(".joinchat__qr").appendChild(l.qr(l.get_wa_link(void 0,void 0,!1)))),r&&this.checked&&_()<=480&&_(481),r&&this.checked&&l.has_chatbox&&l.chatbox_show(),r&&(l.$(".joinchat__qr").classList.toggle("joinchat--show",this.checked),t=setTimeout(function(){l.$(".joinchat__qr").classList.remove("joinchat--show")},5e3)))}),p('#joinchat_message_text,#joinchat_message_start,input[name="joinchat[color][text]"],input[name="joinchat[dark_mode]"],input[name="joinchat[header]"],#joinchat_header_custom').on("focus",g),p("#joinchat_message_text").on("input",f(e,500)).on("change",e),p("#joinchat_message_start").on("input change",f(t=>{l.$(".joinchat__open__text").textContent=p(t.target).val().trim(),g()},100)),p('input[name="joinchat[button_ico]"]').on("change",function(){l.$(".joinchat__button__ico")?.remove(),"app"!=this.value&&l.$(".joinchat__button").insertAdjacentHTML("afterbegin",`<div class="joinchat__button__ico">${this.nextElementSibling.firstElementChild.outerHTML}</div>`),l.chatbox_hide()}),p("#joinchat_color").on("changecolor",function(t,e){var n=l.$div.style;n.setProperty("--ch",e.h),n.setProperty("--cs",e.s+"%"),n.setProperty("--cl",e.l+"%"),g()}),p('input[name="joinchat[color][text]"]').on("change",function(){l.$div.style.setProperty("--bw",this.value),g()}),p('input[name="joinchat[dark_mode]"]').on("change",function(){l.$div.classList.toggle("joinchat--dark","yes"==this.value),l.$div.classList.toggle("joinchat--dark-auto","auto"==this.value),g()}),p('input[name="joinchat[header]"]').on("change",function(){l.$("#joinchat__label a").classList.toggle("joinchat--hidden","__jc__"!=this.value),l.$("#joinchat__label span").classList.toggle("joinchat--hidden","__custom__"!=this.value),l.$("#joinchat__label .joinchat__wa").classList.toggle("joinchat--hidden","__wa__"!=this.value),g()}),p("#joinchat_header_custom").on("input change",f(t=>{l.$("#joinchat__label span").textContent=p(t.target).val(),g()},100)),p("#joinchat_message_badge").on("change",function(){l.settings.message_badge=this.checked,l.has_cta&&(this.checked?l.chatbox_hide():l.chatbox_show(),l.$(".joinchat__badge").classList.toggle("joinchat__badge--in",this.checked))}),tinymce.get("joinchat_optin_text").on("change",d),p("#joinchat_optin_check").on("change",d),h.codemirror.on("change",function(t){p("#joinchat_preview")[0].contentDocument.getElementById("joinchat-inline-css").innerHTML=t.getValue().replace(/(<([^>]+)>)/gi,"")}),r=!1,p("#joinchat_tab_general").find('input[type="text"],input[type="number"],input[type="checkbox"],input[type="radio"]:checked,textarea').trigger("change"),p("#joinchat_color").wpColorPicker("color",p("#joinchat_color").val());var n=h.codemirror.getValue();h.codemirror.setValue(n+" "),h.codemirror.setValue(n),r=!0}),p(".nav-tab-active").trigger("click")})})(jQuery,window,document);