"use strict";(()=>{function m(t){if(t.src.trim())return;let e=t.contentDocument||t.contentWindow?.document;if(!e)return;let r=e.documentElement.outerHTML;t.srcdoc=r}var x="/";var g=47;function d(...t){let e=t[0];for(let r=1;r!f(t)||l(t)?t:e?d("https://proxy.cside.dev/","loader",encodeURIComponent(e),encodeURIComponent(t)):d("https://proxy.cside.dev/",t);function f(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function l(t){return t.startsWith("https://proxy.cside.dev/")}var b=["stripe.com"];function a(t){try{let e=new URL(t);return b.some(r=>e.hostname.includes(r))}catch{return!1}}function h(t){if(!t.startsWith("loader/"))return t;let[r,o]=t.replace("loader/","").split("/");return[decodeURIComponent(r),decodeURIComponent(o)]}function S(t,...e){console.log("%cc/side%c","background-color: #fff; border-radius: 5px; padding: 3px 6px; color: #2500DC;font-weight:700;","background: none; color: #c43dfd;",t,...e)}function p(t,e){if(t.src===""||t.src===null||!f(t.src))return;let r=l(t.src),o=r?t.src.split("https://proxy.cside.dev/").pop()??t.src:t.src;if("sendBeacon"in navigator&&!u.has(` ${window.location.href}:${decodeURIComponent(o)}`)){let n=h(o);navigator.sendBeacon("https://proxy.cside.dev/sources",JSON.stringify({sessionId:sessionStorage.getItem("cside-session-id"),scriptUrl:typeof n=="string"?n:n[1],href:window.location.href,parent:typeof n=="string"?null:n[0]})),u.add(`${window.location.href}:${decodeURIComponent(o)}`)}if(r||a(t.src))return;e?.();let i=document.createElement("script");t.after(i),t.remove();for(let n of t.attributes)n.name!=="src"&&i.setAttribute(n.name,n.value);i.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),i.src=s(t.src)}function w(){let t=Document.prototype.createElement;document.createElement=function(e){let r=t.call(this,e),o=this.currentScript;return e==="script"&&Object.defineProperty(r,"src",{get(){return this.getAttribute("src")},set(i){let n=String(i);if(a(n)||c){this.setAttribute("src",n);return}let L=s(n,o?.getAttribute("src")??void 0);this.setAttribute("src",L)}}),r},Object.freeze(document.createElement)}function y(){if(!sessionStorage.getItem("cside-session-id")){let t=Date.now().toString(36),e=Math.random().toString(36).slice(2,6);sessionStorage.setItem("cside-session-id",`${e}:${t}`)}console.log("%cThis page is protected by c/side security","color:#2500DC;font-size:1.5rem;font-weight:700;background:#fff;padding:0.75rem 1rem;border-radius:8px;"),c&&S("We've noticed you're in development mode, scripts will not be proxied."),w()}var u=new Set;y(),new MutationObserver(t=>{if(!c)for(let e of t)for(let r of e.addedNodes)r instanceof HTMLIFrameElement&&m(r),r instanceof HTMLScriptElement&&p(r)}).observe(document,{childList:!0,subtree:!0}),document.addEventListener("beforescriptexecute",async t=>{!t.target||!(t.target instanceof HTMLScriptElement)||p(t.target,()=>{t.preventDefault(),t.stopPropagation()})});})();