(() => { var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // scripts/templates/consent-env.js var CC_MODAL_ID = "cc-modal-cookies-banner"; var CC_PENDING_COOKIES_KEY = "captainConsentPending"; var CC_COOKIE_MODAL = "cc_consent"; var CC_SERVER_URL = "https://cc-platform-api-prod.fly.dev"; var CC_STANDARD_MODE_ONLY_SETTINGS = "ONLY_SETTINGS"; var CC_STANDARD_MODE_BANNER_LINEAL = "BANNER_LINEAL"; var CC_MODES_ALLOWED = [ "STRICTLY_NECESSARY_COOKIES", "UNCLASSIFIED_COOKIES" ]; var CC_MODE_DO_NOT_SELL_PERSONAL_INFO = "DO_NOT_SELL_PERSONAL_INFORMATION"; var CC_MODAL_ID_SETTINGS = "cc-modal-cookies-banner-settings"; var CC_OVERLAY_ID = "captain-compliance-modal-overlay"; var CC_USER_LOCATION = "cc-modal-user-location"; var IS_DEV = false; var IS_PROD = true; // scripts/templates/utils.js function getCountryFromCookie() { if (typeof document === "undefined") return null; const cookies = document.cookie.split(";"); for (const cookie of cookies) { const [key, value] = cookie.trim().split("="); if (key && value && key.toLowerCase().includes("cf-ipcountry")) { return value.trim().toUpperCase(); } } return null; } __name(getCountryFromCookie, "getCountryFromCookie"); function getDomain() { return window.location.hostname.replace("www.", ""); } __name(getDomain, "getDomain"); function getDomainFromString(urlString) { try { const url = new URL(urlString); return url.hostname.replace("www.", ""); } catch (error) { return "Invalid URL"; } } __name(getDomainFromString, "getDomainFromString"); function getCookie(name) { const cookies = document.cookie.split("; "); for (const cookie of cookies) { const [cookieName, cookieValue] = cookie.split("="); if (cookieName === name) { return decodeURIComponent(cookieValue); } } return null; } __name(getCookie, "getCookie"); function transformTriggerValue(triggerValue, { fallbackMs = 5e3, maxMs = 6e4 } = {}) { const MAX_SET_TIMEOUT = 2147483647; if (typeof triggerValue !== "string") return fallbackMs; const raw = triggerValue.trim(); const match = raw.match(/^(\d+(?:\.\d+)?)\s*s?$/i); if (!match) return fallbackMs; const seconds = Number(match[1]); if (!Number.isFinite(seconds) || seconds <= 0) return fallbackMs; const ms = Math.round(seconds * 1e3); if (!Number.isFinite(ms) || ms <= 0) return fallbackMs; const cappedMax = Math.min(maxMs, MAX_SET_TIMEOUT); return Math.min(ms, cappedMax); } __name(transformTriggerValue, "transformTriggerValue"); var logIfDev = /* @__PURE__ */ __name((...args) => { if (!IS_PROD) console.log(...args); }, "logIfDev"); var warnIfDev = /* @__PURE__ */ __name((...args) => { if (!IS_PROD) console.warn(...args); }, "warnIfDev"); var errorIfDev = /* @__PURE__ */ __name((...args) => { if (!IS_PROD) console.error(...args); }, "errorIfDev"); // scripts/templates/auto-blocking.js var blockedScriptsRegistry = /* @__PURE__ */ new WeakMap(); var _blockedNodes = []; function isStrictlyNecessary(category) { return category === "STRICTLY_NECESSARY_COOKIES"; } __name(isStrictlyNecessary, "isStrictlyNecessary"); function _srcMatchesRule(src, ruleSrc) { if (/^https?:\/\/|^\/\//.test(src)) { const base = typeof window !== "undefined" ? window.location.href : void 0; try { const srcHostname = new URL(src, base).hostname; if (srcHostname) { let ruleHostname; try { ruleHostname = new URL(ruleSrc, base).hostname; } catch { ruleHostname = ruleSrc.replace(/^https?:\/\//, "").replace(/^\./, "").split("/")[0].split("?")[0]; } if (ruleHostname) { return srcHostname === ruleHostname || srcHostname.endsWith("." + ruleHostname); } } } catch { } } return src.includes(ruleSrc); } __name(_srcMatchesRule, "_srcMatchesRule"); function findMatchBySrc(list, src) { if (!src) return null; for (const item of list) { if (item.src && _srcMatchesRule(src, item.src)) return item; if (item.pattern && new RegExp(item.pattern).test(src)) return item; } return null; } __name(findMatchBySrc, "findMatchBySrc"); function findMatchByName(list, name) { if (!name) return null; for (const item of list) { if (item?.name && name.includes(item?.name)) return item; if (item?.src && name.includes(item?.src)) return item; if (item?.pattern && new RegExp(item?.pattern).test(name)) return item; } return null; } __name(findMatchByName, "findMatchByName"); function shouldBlockScript(script, scriptsToBlock, inlineRules, userConsent) { if (!userConsent) return null; if (script.getAttribute("data-cookie-category") != null) return null; if (script.getAttribute("type") === "text/plain") return null; const src = script.getAttribute("src"); const match = src ? findMatchBySrc(scriptsToBlock, src) : findMatchBySrc(inlineRules, script.innerHTML); if (!match || isStrictlyNecessary(match.category) || userConsent[match.category]) return null; return match; } __name(shouldBlockScript, "shouldBlockScript"); function logBlock(action, src, match, reason) { if (match) { warnIfDev( `\u26D4 ${action} blocked by consent:`, src, "\u2192 category:", match.category ); } else { logIfDev( `\u2139\uFE0F ${action} evaluated but doesn't match any rules:`, src, reason || "" ); } } __name(logBlock, "logBlock"); var ORIGINAL_ATTR_KEY = "data-cc-original-attrs"; function serializeAttributes(node) { return Array.from(node.attributes || [])?.reduce((acc, attr) => { const { name, value } = attr; acc[name] = value === "" ? true : value; return acc; }, {}); } __name(serializeAttributes, "serializeAttributes"); function applySerializedAttributes(target, serialized) { if (!serialized) return; Object.entries(serialized).forEach(([name, value]) => { if (name === "src") return; if (value === true) { target.setAttribute(name, ""); } else { target.setAttribute(name, value); } }); } __name(applySerializedAttributes, "applySerializedAttributes"); var blockingState = { initialized: false, currentConsent: null, activatedCategories: /* @__PURE__ */ new Set(), observerInitialized: false, interceptorsInitialized: false }; function shallowEqual(a, b) { if (a === b) return true; if (!a || !b) return false; const keysA = Object.keys(a); const keysB = Object.keys(b); if (keysA.length !== keysB.length) return false; return keysA.every((key) => a[key] === b[key]); } __name(shallowEqual, "shallowEqual"); function blockScripts(scriptsToBlock, userConsent) { document.querySelectorAll("script[src]").forEach((node) => { const src = node.getAttribute("src"); const match = findMatchBySrc(scriptsToBlock, src); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { logBlock("Script", src, match); const placeholder = document.createElement("script"); placeholder.type = "text/plain"; placeholder.className = `blocked-${match.category}`; placeholder.setAttribute("data-cookie-category", match.category); placeholder.setAttribute("data-src", src); placeholder.setAttribute( ORIGINAL_ATTR_KEY, JSON.stringify(serializeAttributes(node)) ); node.parentNode.replaceChild(placeholder, node); blockedScriptsRegistry.set(placeholder, { category: match.category, originalType: null, // placeholder was created with type="text/plain" activated: false, isInPlace: false // initial-scan path: needs createElement on activation }); _blockedNodes.push(placeholder); } else { logBlock( "Script", src, match, "allowed by consent or strictly necessary" ); } }); } __name(blockScripts, "blockScripts"); function blockAllScripts(scriptsToBlock) { const rejectAll = { STRICTLY_NECESSARY_COOKIES: true, PERFORMANCE_COOKIES: false, FUNCTIONALITY_COOKIES: false, TARGETING_COOKIES: false, UNCLASSIFIED: false }; blockScripts(scriptsToBlock, rejectAll); } __name(blockAllScripts, "blockAllScripts"); function blockIframes(iframesToBlock, userConsent) { document.querySelectorAll("iframe").forEach((node) => { const name = node.getAttribute("name"); const src = node.getAttribute("src"); const match = findMatchByName(iframesToBlock, name); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { logBlock("Iframe", `name: ${name}, src: ${src}`, match); const placeholder = document.createElement("iframe"); placeholder.type = "text/plain"; placeholder.className = `blocked-${match.category}`; placeholder.setAttribute("data-cookie-category", match.category); if (src) placeholder.setAttribute("data-src", src); if (name) placeholder.setAttribute("data-name", name); placeholder.setAttribute( ORIGINAL_ATTR_KEY, JSON.stringify(serializeAttributes(node)) ); placeholder.style.display = "none"; node.parentNode.replaceChild(placeholder, node); blockedScriptsRegistry.set(placeholder, { category: match.category, originalType: null, activated: false, isInPlace: false }); _blockedNodes.push(placeholder); } else { logBlock( "Iframe", `name: ${name}, src: ${src}`, match, "allowed by consent or strictly necessary" ); } }); } __name(blockIframes, "blockIframes"); function blockAllIframes(iframesToBlock) { const rejectAll = { STRICTLY_NECESSARY_COOKIES: true, PERFORMANCE_COOKIES: false, FUNCTIONALITY_COOKIES: false, TARGETING_COOKIES: false, UNCLASSIFIED: false }; blockIframes(iframesToBlock, rejectAll); } __name(blockAllIframes, "blockAllIframes"); function blockInlineScripts(inlineRules, userConsent) { document.querySelectorAll("script:not([src])").forEach((node) => { const content = node.innerHTML; const match = findMatchBySrc(inlineRules, content); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { logBlock("Inline Script", "[inline code...]", match); const placeholder = document.createElement("script"); placeholder.type = "text/plain"; placeholder.className = `blocked-${match.category}`; placeholder.setAttribute("data-cookie-category", match.category); placeholder.setAttribute( "data-inline-pattern", match.pattern || match.src ); placeholder.setAttribute("data-original-content", node.innerHTML); placeholder.setAttribute( ORIGINAL_ATTR_KEY, JSON.stringify(serializeAttributes(node)) ); node.parentNode.replaceChild(placeholder, node); blockedScriptsRegistry.set(placeholder, { category: match.category, originalType: null, activated: false, isInPlace: false }); _blockedNodes.push(placeholder); } else if (match) { logBlock( "Inline Script", "[inline code...]", match, "allowed by consent" ); } }); } __name(blockInlineScripts, "blockInlineScripts"); function blockAllInline(inlineRules) { const rejectAll = { STRICTLY_NECESSARY_COOKIES: true, PERFORMANCE_COOKIES: false, FUNCTIONALITY_COOKIES: false, TARGETING_COOKIES: false, UNCLASSIFIED: false }; blockInlineScripts(inlineRules, rejectAll); } __name(blockAllInline, "blockAllInline"); function _activateFromRegistry(category) { _blockedNodes.forEach((node) => { const entry = blockedScriptsRegistry.get(node); if (!entry || entry.category !== category || entry.activated) return; entry.activated = true; if (entry.isInPlace) { node.type = entry.originalType || "text/javascript"; node.removeAttribute("data-cc-blocked"); logIfDev( "[CC] \u2705 Reactivated in-place:", node.getAttribute("src") || "[inline]" ); return; } const tag = node.tagName; const attrsJson = node.getAttribute(ORIGINAL_ATTR_KEY); if (tag === "SCRIPT") { const src = node.getAttribute("data-src"); const restored = document.createElement("script"); if (attrsJson) { try { applySerializedAttributes(restored, JSON.parse(attrsJson)); } catch (e) { warnIfDev("[CC] Failed to restore script attributes:", e); } } if (src) { restored.src = src; logIfDev("[CC] \u2705 Script activated:", src); } else { restored.textContent = node.getAttribute("data-original-content"); logIfDev( "[CC] \u2705 Inline script activated:", node.getAttribute("data-inline-pattern") ); } restored.setAttribute("data-cookie-category", category); if (node.parentNode) node.parentNode.replaceChild(restored, node); } else if (tag === "IFRAME") { const src = node.getAttribute("data-src"); const name = node.getAttribute("data-name"); const restored = document.createElement("iframe"); if (attrsJson) { try { applySerializedAttributes(restored, JSON.parse(attrsJson)); } catch (e) { warnIfDev("[CC] Failed to restore iframe attributes:", e); } } if (src) restored.src = src; if (name) restored.name = name; restored.setAttribute("data-cookie-category", category); if (node.parentNode) node.parentNode.replaceChild(restored, node); logIfDev( "[CC] \u2705 Iframe activated:", name ? `name: ${name}` : `src: ${src}` ); } }); } __name(_activateFromRegistry, "_activateFromRegistry"); function activateScriptsForCategory(category) { if (!category || isStrictlyNecessary(category)) return; blockingState.activatedCategories.add(category); logIfDev("[CC] Activating blocked content for category:", category); _activateFromRegistry(category); } __name(activateScriptsForCategory, "activateScriptsForCategory"); function _initDynamicBlockingObserver({ scriptsToBlock, iframesToBlock, inlineRules }) { if (blockingState.observerInitialized) return; blockingState.observerInitialized = true; const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.nodeType !== Node.ELEMENT_NODE) return; if (blockedScriptsRegistry.has(node)) return; if (node.getAttribute("data-cookie-category") != null && node.getAttribute("type") === "text/plain") { const interceptedCategory = node.getAttribute("data-cookie-category"); if (!isStrictlyNecessary(interceptedCategory)) { blockedScriptsRegistry.set(node, { category: interceptedCategory, originalType: null, activated: false, isInPlace: false }); _blockedNodes.push(node); } return; } if (node.getAttribute("data-cookie-category") != null) return; const userConsent = blockingState.currentConsent; if (node.tagName === "SCRIPT") { const match = shouldBlockScript( node, scriptsToBlock, inlineRules, userConsent ); if (match) { const originalType = node.getAttribute("type") || ""; node.type = "text/plain"; node.setAttribute("data-cc-blocked", "true"); node.setAttribute("data-cookie-category", match.category); blockedScriptsRegistry.set(node, { category: match.category, originalType, activated: false, isInPlace: true // activation restores type in-place, no createElement }); _blockedNodes.push(node); warnIfDev( "[CC] Dynamically blocked script:", node.getAttribute("src") || "[inline]" ); } return; } if (node.tagName === "IFRAME") { if (node.getAttribute("data-cookie-category") != null || node.getAttribute("type") === "text/plain") return; if (!userConsent) return; const name = node.getAttribute("name"); const src = node.getAttribute("src"); const match = findMatchByName(iframesToBlock, name); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { warnIfDev( "[CC] Dynamically blocked iframe:", name ? `name: ${name}` : `src: ${src}` ); const placeholder = document.createElement("iframe"); placeholder.type = "text/plain"; placeholder.className = `blocked-${match.category}`; placeholder.setAttribute("data-cookie-category", match.category); if (src) placeholder.setAttribute("data-src", src); if (name) placeholder.setAttribute("data-name", name); placeholder.setAttribute( ORIGINAL_ATTR_KEY, JSON.stringify(serializeAttributes(node)) ); placeholder.style.display = "none"; node.parentNode.replaceChild(placeholder, node); blockedScriptsRegistry.set(placeholder, { category: match.category, originalType: null, activated: false, isInPlace: false }); _blockedNodes.push(placeholder); } } }); }); }); observer.observe(document.documentElement, { childList: true, subtree: true }); logIfDev("[CC] Dynamic blocking observer initialized"); } __name(_initDynamicBlockingObserver, "_initDynamicBlockingObserver"); function _neutralizeHtmlFragment(html, { scriptsToBlock, iframesToBlock, inlineRules }) { const userConsent = blockingState.currentConsent; if (!userConsent) return html; const parser = new DOMParser(); const doc = parser.parseFromString( `
${html}`, "text/html" ); let modified = false; doc.querySelectorAll("script[src]").forEach((node) => { if (node.getAttribute("data-cookie-category") != null) return; const src = node.getAttribute("src"); const match = findMatchBySrc(scriptsToBlock, src); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { warnIfDev("[CC] Intercepted script in dynamic HTML:", src); const originalAttrs = serializeAttributes(node); node.type = "text/plain"; node.setAttribute("data-cookie-category", match.category); node.setAttribute("data-src", src); node.removeAttribute("src"); node.setAttribute(ORIGINAL_ATTR_KEY, JSON.stringify(originalAttrs)); modified = true; } }); doc.querySelectorAll("script:not([src])").forEach((node) => { if (node.getAttribute("data-cookie-category") != null) return; const content = node.innerHTML; const match = findMatchBySrc(inlineRules, content); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { warnIfDev( "[CC] Intercepted inline script in dynamic HTML:", match.pattern || match.src ); const originalAttrs = serializeAttributes(node); node.type = "text/plain"; node.setAttribute("data-cookie-category", match.category); node.setAttribute("data-inline-pattern", match.pattern || match.src); node.setAttribute("data-original-content", content); node.setAttribute(ORIGINAL_ATTR_KEY, JSON.stringify(originalAttrs)); modified = true; } }); doc.querySelectorAll("iframe").forEach((node) => { if (node.getAttribute("data-cookie-category") != null) return; const name = node.getAttribute("name"); const src = node.getAttribute("src"); const match = findMatchByName(iframesToBlock, name); if (match && !isStrictlyNecessary(match.category) && !userConsent[match.category]) { warnIfDev( "[CC] Intercepted iframe in dynamic HTML:", name ? `name: ${name}` : `src: ${src}` ); const originalAttrs = serializeAttributes(node); node.type = "text/plain"; node.setAttribute("data-cookie-category", match.category); if (src) node.setAttribute("data-src", src); if (name) node.setAttribute("data-name", name); node.setAttribute(ORIGINAL_ATTR_KEY, JSON.stringify(originalAttrs)); node.style.display = "none"; modified = true; } }); return modified ? doc.body.innerHTML : html; } __name(_neutralizeHtmlFragment, "_neutralizeHtmlFragment"); function _interceptDocumentWrite({ scriptsToBlock, iframesToBlock, inlineRules }) { const _origWrite = document.write.bind(document); const _origWriteln = document.writeln.bind(document); function _patchedWrite(args, origFn) { const html = [...args].join(""); if (!/