function m(a,t,e){var n=a.indexOf("?")!==-1?"&":"?",o="notifal_onpage_preview="+encodeURIComponent(t)+"&_wpnonce="+encodeURIComponent(e);return a+n+o}function E(a,t){var e=(a||"").trim();if(!e)return null;if(e.indexOf("://")!==-1)try{return new URL(e).href}catch{return null}var n=t?t.replace(/\/$/,""):"";if(!n)return null;var o=e.indexOf("/")===0?e:"/"+e;return n+o}function w(){var a=document.querySelector(".notifal-onpage-preview-banner");if(!a)return;var t=document.getElementById("notifal-onpage-preview-url"),e=document.getElementById("notifal-onpage-preview-url-btn"),n=document.getElementById("notifal-onpage-preview-url-error"),o=a.querySelectorAll(".notifal-onpage-preview-banner-device"),i=window.notifalOnPagePreviewConfig||{},c=i.notificationId,u=i.nonce,g=i.homeUrl||"";if(!c||!u)return;function p(r){n&&(n.textContent=r,n.hidden=!1)}function s(){n&&(n.textContent="",n.hidden=!0)}t&&e&&(e.addEventListener("click",function(){s();var r=(t.value||"").trim();if(!r){var v=i.strings&&i.strings.preview_url_required||"Please enter a path or URL.";p(v);return}var l=E(r,g);if(!l){var d=i.strings&&i.strings.preview_url_invalid||"Please enter a valid path or URL.";p(d);return}var f=m(l,c,u);window.location.href=f}),t.addEventListener("input",s),t.addEventListener("keydown",function(r){r.key==="Enter"&&(r.preventDefault(),e.click())}));var h={desktop:null,tablet:{width:768,height:1024},mobile:{width:375,height:667}};o.length&&o.forEach(function(r){r.addEventListener("click",function(){var v=r.getAttribute("data-viewport");if(v){o.forEach(function(f){f.classList.remove("notifal-onpage-preview-banner-device--active")}),r.classList.add("notifal-onpage-preview-banner-device--active");var l=h[v];if(l){var d="width="+l.width+",height="+l.height+",scrollbars=yes,resizable=yes,location=yes";window.open(window.location.href,"notifal_preview_"+v,d)}}})})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w();
