@cookieyes/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";const e="cookieyes-consent",t=new Set(["consentid","consent","action","tax","lastRenewedDate"]);function o(e){const o={categories:{}};for(const n of e.split(",")){const e=n.indexOf(":");if(-1===e)continue;const r=n.slice(0,e).trim(),i=n.slice(e+1).trim();t.has(r)?o[r]=i:r.length>0&&(o.categories[r]=i)}return o}function n(e){const t=[`consentid:${e.consentId}`,"consent:"+(e.hasActed?"yes":"no"),"action:"+(e.hasActed?"yes":"no")];e.taxonomyHash&&t.push(`tax:${e.taxonomyHash}`);for(const[o,n]of Object.entries(e.categories))t.push(`${o}:${n?"yes":"no"}`);return t.push(`lastRenewedDate:${e.lastRenewed??Date.now()}`),t.join(",")}function r(t){for(const n of t.split(";")){const t=n.trim(),r=t.indexOf("=");if(-1===r)continue;if(t.slice(0,r).trim()!==e)continue;const i=t.slice(r+1).trim();try{return o(decodeURIComponent(i))}catch{return null}}return null}function i(t){if("undefined"==typeof document)return;const o=encodeURIComponent(n(t));document.cookie=`${e}=${o}; max-age=31536000; path=/; SameSite=Lax`}function s(){"undefined"!=typeof document&&(document.cookie=`${e}=; max-age=0; path=/`)}function a(){const e=new Uint8Array(32);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(256*Math.random());return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"").slice(0,44)}function c(e,t,o){const n={};for(const t of o.ids)n[t]=!!o.requiredIds.has(t)||"yes"===e.categories[t];return{consentId:e.consentid??a(),hasActed:"yes"===e.action,categories:n,regulation:t,lastRenewed:e.lastRenewedDate?Number(e.lastRenewedDate):void 0,taxonomyHash:e.tax}}function l(e,t,o){const n="CCPA"===t,r={};for(const e of o.ids)r[e]=!!o.requiredIds.has(e)||n;return{consentId:e,hasActed:!1,categories:r,regulation:t,taxonomyHash:o.taxonomyHash}}const d=[{id:"necessary",required:!0},{id:"functional",gcm:["functionality_storage","personalization_storage"]},{id:"analytics",gcm:["analytics_storage"]},{id:"performance"},{id:"advertisement",gcm:["ad_storage","ad_user_data","ad_personalization"]}];function u(e){let t=2166136261;for(let o=0;o<e.length;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function g(e,t){const o=e.map(e=>e.id),n=new Set(e.filter(e=>e.required).map(e=>e.id)),r=e.map(e=>`${e.id}:${e.required?1:0}:${(e.gcm??[]).join("+")}`).join("|");return{list:e,ids:o,requiredIds:n,taxonomyHash:u(r),isDefault:t}}function f(e){if(!e||0===e.length)return g(d,!0);const o=function(e){const o=e.map(e=>e.id);return o.some(e=>"string"!=typeof e||0===e.length)?"every category needs a non-empty string id":o.some(e=>e.includes(",")||e.includes(":"))?"category ids must not contain ',' or ':'":new Set(o).size!==o.length?"category ids must be unique":o.some(e=>t.has(e))?`category ids must not be one of the reserved keys: ${[...t].join(", ")}`:e.some(e=>!0===e.required)?null:"at least one category must be marked { required: true }"}(e);return o?("undefined"!=typeof console&&console.warn(`[cookieyes] Invalid categories config (${o}). Falling back to the default five (necessary, functional, analytics, performance, advertisement).`),g(d,!0)):g(e,!1)}function p(e){"undefined"!=typeof console&&console.warn(e)}function h(e){const t={mode:e.mode},o=e.overrides?.regulation;return void 0!==e.regulation?(t.regulation=e.regulation,void 0!==o&&p("[CookieYes] Received both `regulation` and the deprecated `overrides.regulation`. Using the top-level `regulation` and ignoring `overrides`. Drop the `overrides` object — it is deprecated and will be removed after three release cycles.")):void 0!==o&&(t.regulation=o),void 0!==e.region&&(t.region=e.region),void 0!==e.colorScheme&&(t.colorScheme=e.colorScheme),void 0!==e.theme&&(t.theme=e.theme),void 0!==e.i18n&&(t.i18n=e.i18n),void 0!==e.categories&&(t.categories=e.categories),void 0!==e.networkBlocker&&(t.networkBlocker=e.networkBlocker),void 0!==e.reloadOnRevoke&&(t.reloadOnRevoke=e.reloadOnRevoke),void 0!==e.googleConsentMatch&&(t.googleConsentMatch=e.googleConsentMatch),void 0!==e.integrations&&(t.integrations=e.integrations),void 0!==e.builtInIntegrations&&(t.builtInIntegrations=e.builtInIntegrations),void 0!==e.customStopHandlers&&(t.customStopHandlers=e.customStopHandlers),void 0!==e.onConsentReady&&(t.onConsentReady=e.onConsentReady),void 0!==e.onConsentUpdate&&(t.onConsentUpdate=e.onConsentUpdate),"self-hosted"===e.mode&&(void 0!==e.apiKey&&(t.apiKey=e.apiKey),void 0!==e.backend&&(t.backend=e.backend),void 0!==e.apiUrl?(t.apiUrl=e.apiUrl,void 0!==e.backendURL&&p("[CookieYes] Received both `apiUrl` and the deprecated `backendURL`. Using `apiUrl` and ignoring `backendURL`. Rename `backendURL` to `apiUrl` — the alias is deprecated and will be removed after three release cycles.")):void 0!==e.backendURL&&(t.apiUrl=e.backendURL)),t}let y=!1;function m(){y||(y=!0,"undefined"!=typeof console&&console.warn('[cookieyes] mode: "offline" has been renamed to "cookie-only". Both do exactly the same thing, but "offline" is deprecated and will be removed after three release cycles. See https://github.com/cookieyes/cookieyes/blob/main/apps/web/content/docs/migration.mdx for the full migration guide. Update to .mode("cookie-only") (or { mode: "cookie-only" }).'))}let v=!1;function w(){v||(v=!0,"undefined"!=typeof console&&console.warn("[cookieyes] `builtInIntegrations` (formerly the `integrations` field) is deprecated and will be removed after three release cycles. Use the `integrations` field with a preset from `@cookieyes/scripts` instead. See https://github.com/cookieyes/cookieyes/blob/main/apps/web/content/docs/migration.mdx for the full migration guide."))}function b(e){const t={save:new Set,change:new Set};let o={...e()};function n(e,t,o){try{e.listener(o)}catch(e){"undefined"!=typeof console&&console.error(`[cookieyes] a consent "${t}" listener threw; others are unaffected:`,e)}}function r(e,o){for(const r of[...t[e]])r.category&&!o.changedCategories.includes(r.category)||n(r,e,o)}return{on(o,r,i){const s=i?.category?{listener:r,category:i.category}:{listener:r};return t[o].add(s),n(s,o,{categories:{...e()},changedCategories:[],isInitial:!0}),()=>{t[o].delete(s)}},push(e){const t={...e},n=[];for(const e of Object.keys(t))o[e]!==t[e]&&n.push(e);o=t,r("save",{categories:t,changedCategories:n,isInitial:!1}),n.length>0&&r("change",{categories:t,changedCategories:n,isInitial:!1})}}}function k(e){"undefined"!=typeof console&&console.warn(`[cookieyes] ${e}`)}const C=["ad_storage","ad_user_data","ad_personalization","analytics_storage","functionality_storage","personalization_storage","security_storage"];function x(e,t,o="any"){const n={};for(const r of C){if("security_storage"===r){n[r]="granted";continue}const i=e.list.filter(e=>e.gcm?.includes(r));if(0===i.length){n[r]="denied";continue}const s="all"===o?i.every(e=>!0===t[e.id]):i.some(e=>!0===t[e.id]);n[r]=s?"granted":"denied"}return n}function R(e,t,o="any"){if("undefined"==typeof window||!Array.isArray(window.dataLayer))return;const n=x(e,t,o),r=window.dataLayer;if(!r)return;!function(){r.push(arguments)}("consent","update",n)}const S={bannerTitle:"We value your privacy",bannerDescription:"We use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking “Accept All”, you consent to our use of cookies.",acceptAll:"Accept All",rejectAll:"Reject All",managePreferences:"Customise",savePreferences:"Save My Preferences",doNotSell:"Do Not Sell or Share My Personal Information",ccpaDescription:"This website or its third-party tools process personal data. You can opt out of the sale of your personal information by clicking on the “Do Not Sell or Share My Personal Information” link.",accept:"Accept",poweredBy:"Powered by CookieYes",preferencesTitle:"Customise Consent Preferences",preferencesIntro:"We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.",alwaysActive:"Always Active",preferencesDialogLabel:"Cookie preferences",optOutDialogLabel:"Opt-out preferences",recallButtonLabel:"Consent Preferences",categories:{necessary:{label:"Necessary",description:"Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data."},functional:{label:"Functional",description:"Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features."},analytics:{label:"Analytics",description:"Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc."},performance:{label:"Performance",description:"Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors."},advertisement:{label:"Advertisement",description:"Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns."}},optOut:{title:"Opt-out Preferences",description:'We use third-party cookies that help us analyse how you use this website, store your preferences, and provide the content and advertisements that are relevant to you. However, you can opt out of these cookies by checking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button. Once you opt out, you can opt in again at any time by unchecking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button.',cancel:"Cancel",successText:"Your opt-out preference has been honored.",successCountdown:"Banner closes automatically in {seconds} s..."},bannerCloseLabel:"Close",preferencesCloseLabel:"Close preferences",optOutCloseLabel:"Close",gatedFrame:{placeholder:"This content requires {category} cookies to be enabled.",action:"Manage Preferences"},reloadNotice:{message:"Some tracking on this page can only be fully stopped by reloading. Reload to apply your change, or dismiss to keep browsing.",reloadButton:"Reload page",dismissButton:"Dismiss"}},I=new Set(["ar","he","fa","ur","ps","sd","yi","dv"]);function A(e){return e.split("-")[0]?.toLowerCase()??""}function L(e){return I.has(A(e))?"rtl":"ltr"}function O(e,t){if(!t)return e;const o={...e};for(const[n,r]of Object.entries(t)){if(null==r)continue;const t=e[n],i="object"==typeof r&&!Array.isArray(r)&&"object"==typeof t&&null!=t;o[n]=i?O(t,r):r}return o}function U(e){const t=e?.messages??{},o=[];e?.locale&&o.push(e.locale),(e?.detectBrowserLanguage??1)&&"undefined"!=typeof navigator&&navigator.language&&o.push(navigator.language);for(const e of o){if(t[e])return e;const o=A(e);if(o&&t[o])return o}return"en"}function $(e,t){const o=new Set(e);for(const e of t)o.has(e)&&P(`"${e}" is configured as both a script integration and a built-in integration — remove one to avoid loading it twice (e.g. double-counted events).`)}function M(e,t){const o=new Set(t);for(const t of e){if("afterConsent"!==t.load)continue;const e=t.category,n=Array.isArray(e)?e:[e];if(0!==n.length)for(const e of n)o.has(e)||P(`integration "${t.id}" is gated on category "${e}", which isn't in your configured categories — it will never load. Pass a category that exists (e.g. segment({ category: "…" })), or add it to your taxonomy.`);else P(`integration "${t.id}" has an empty category list — it will never load. Give it at least one category that exists in your taxonomy.`)}}function P(e,t){"undefined"!=typeof console&&(void 0!==t?console.error(`[cookieyes] ${e}`,t):console.warn(`[cookieyes] ${e}`))}function H(e,t){const o=Array.isArray(e.category)?e.category:[e.category];return 0!==o.length&&("any"===e.match?o.some(e=>t.granted(e)):o.every(e=>t.granted(e)))}function B(e,t){const o=[],n=new Set;let r=!1;for(const t of e){const e=t;"string"!=typeof e.vendor||"function"==typeof e.setup?1===t.version?n.has(t.id)?P(`integration "${t.id}" is registered more than once; skipping the duplicate.`):(n.add(t.id),o.push({integration:t,status:"idle",everLoaded:!1,loading:!1,control:void 0,subs:new Set,wasGranted:!1})):P(`integration "${t.id}" uses format version ${t.version}, but this build understands 1. Skipping it.`):P(`an entry in "integrations" looks like the old built-in format ({ vendor: "${e.vendor}" }). That moved to "builtInIntegrations" — move it there, or use a preset from "@cookieyes/scripts" in "integrations". Skipping it.`)}function i(e){for(const t of e.subs)try{t()}catch{}e.subs.clear()}function s(e){i(e),"active"===e.status&&(!function(e){const{integration:t,control:o}=e;try{"remove"===t.onRevoke?o?.():"silence"===t.onRevoke&&o?.silence()}catch(e){P(`integration "${t.id}" threw while being torn down.`,e)}e.control=void 0}(e),"remove"===e.integration.onRevoke?e.status="removed":"silence"===e.integration.onRevoke&&(e.status="silenced"))}function a(e){e.loading=!0,e.status="loading",Promise.resolve().then(()=>e.integration.setup(function(e){return{granted:()=>H(e.integration,t),onConsentChange:o=>{const n=t.subscribe(o);return e.subs.add(n),()=>{e.subs.delete(n)&&n()}},region:t.region}}(e))).then(t=>{e.loading=!1,e.control=t??void 0,e.everLoaded=!0,e.status="active",r?s(e):c(e)}).catch(t=>{e.loading=!1,e.status="error",i(e),P(`integration "${e.integration.id}" failed to load; will retry on the next change.`,t)})}function c(e){const{integration:o}=e,n=H(o,t);if(n&&(e.wasGranted=!0),r||e.loading)return;if("idle"===e.status||"removed"===e.status||"error"===e.status){return void((e.everLoaded?n:"immediately"===o.load||n)&&a(e))}if("keep"===o.onRevoke)return;if("remove"===o.onRevoke){if(!n&&"active"===e.status&&e.wasGranted){i(e);try{e.control?.()}catch(e){P(`integration "${o.id}" cleanup threw on revoke.`,e)}e.control=void 0,e.status="removed"}return}const s=e.control;if(n||"active"!==e.status){if(n&&"silenced"===e.status){try{s?.resume()}catch(e){P(`integration "${o.id}" resume() threw.`,e)}e.status="active"}}else{try{s?.silence()}catch(e){P(`integration "${o.id}" silence() threw.`,e)}e.status="silenced"}}function l(){for(const e of o)c(e)}const d=t.subscribe(l);return l(),{status:()=>{const e={};for(const t of o)e[t.integration.id]=t.status;return e},list:()=>o.map(e=>({id:e.integration.id,category:e.integration.category,load:e.integration.load,onRevoke:e.integration.onRevoke,status:e.status})),stop:()=>{if(!r){r=!0,d();for(const e of o)s(e)}}}}function T(e,t){const o={...e?.messages},n=e?.loadLanguage,r=new Set;let i=U(e),s=d(i),a=u();function c(e){return o[e]??o[A(e)]}function l(e){return"en"===A(e)||void 0!==c(e)}function d(e){return O(S,c(e))}function u(){return{language:i,direction:L(i),languages:Array.from(new Set(["en",...Object.keys(o)]))}}function g(e){i=e,s=d(e),a=u(),t()}function f(e,t){r.has(e)||"undefined"==typeof console||(r.add(e),console.warn(`[cookieyes] no translations for language "${e}"; staying on "${i}". Add it to i18n.messages or provide i18n.loadLanguage.`,t??""))}function p(e){return l(e)?(g(e),Promise.resolve()):n?Promise.resolve().then(()=>n(e)).then(t=>{o[e]=t,g(e)}).catch(t=>f(e,t)):(f(e),Promise.resolve())}return n&&e?.locale&&!l(e.locale)&&"undefined"!=typeof window&&p(e.locale),{getTranslations:()=>s,getLanguageInfo:()=>a,setLanguage:p,getCategoryText:function(e){return c(i)?.categories?.[e]}}}const _=new Map,D=new Map;function q(e,t){if(document.getElementById(e))return;const o=document.createElement("script");o.id=e,o.src=t.src,o.async=!0,t.onLoad&&o.addEventListener("load",t.onLoad,{once:!0}),document.head.appendChild(o),D.set(e,o)}function j(e){return"needsReload"in e&&!0===e.needsReload}function N(e){switch(e.vendor){case"meta":return{id:"meta",category:e.category??"advertisement",stop:()=>window.fbq?.("consent","revoke"),resume:()=>window.fbq?.("consent","grant")};case"tiktok":return{id:"tiktok",category:e.category??"advertisement",needsReload:!0};case"linkedin":return{id:"linkedin",category:e.category??"advertisement",needsReload:!0};case"hotjar":return{id:"hotjar",category:e.category??"analytics",needsReload:!0};case"segment":return{id:"segment",category:e.category??"analytics",needsReload:!0}}}const E=new Map,G=new Set,F=new Set;function X(e){E.set(e.id,e)}function z(e){const t=[];for(const o of E.values()){const n=!0!==e[o.category];if(j(o))n?F.has(o.id)&&(t.push(o.id),F.delete(o.id)):F.add(o.id);else if(n){if(!G.has(o.id))try{o.stop(),G.add(o.id)}catch{t.push(o.id)}}else if(G.has(o.id)){G.delete(o.id);try{o.resume?.()}catch{}}}return{reloadRequiredBy:t}}function K(e,t){const o={consentId:e.consentId,categories:e.categories,regulation:e.regulation,domain:"undefined"!=typeof window?window.location.hostname:"unknown"};return t&&(o.region=t),o}function W(e){const t=new Set,o=f(e.categories),n=e.googleConsentMatch??"any";let d;void 0===e.googleConsentMatch&&function(e){const t=new Map;for(const o of e.list)for(const e of o.gcm??[]){let n=t.get(e);n||(n=new Set,t.set(e,n)),n.add(o.id)}for(const[e,o]of t)o.size<=1||k(`categories ${[...o].map(e=>JSON.stringify(e)).join(", ")} all map to the Google signal "${e}", which is a single on/off — this mapping is lossy. Set \`googleConsentMatch: "all"\` to grant it only when all are granted, or "any" (default) to grant it when any is.`)}(o);let u,g,p=!1;function h(e){const t={};for(const n of o.ids)t[n]=!!o.requiredIds.has(n)||e(n);return t}let y=[],m=!1;for(const t of e.integrations??[])X(N(t));for(const t of e.customStopHandlers??[])X(t);const v="undefined"==typeof document?null:r(document.cookie),w=e.regulation??"DEFAULT",b=v?.tax,C=b===o.taxonomyHash,x=null!=v&&(C||void 0===b&&o.isDefault);if(null!=v&&x)d=c(v,w,o);else{const e=v?.consentid??a();d=l(e,w,o),null!=v&&s(),"CCPA"===d.regulation&&i(d)}function S(){const e={consentId:d.consentId,hasActed:d.hasActed,categories:{...d.categories},regulation:d.regulation,lastRenewed:d.lastRenewed,taxonomyHash:d.taxonomyHash};for(const o of t)o(e)}function I(){!function(e){if("undefined"!=typeof document)for(const[t,o]of _)!0===e[o.category]&&(D.has(t)||q(t,o))}(g)}function A(){d={...d,hasActed:!0,lastRenewed:Date.now()},i(d);let t=!1;for(const e of o.ids)if(u[e]&&!d.categories[e]){t=!0;break}if(u={...d.categories},g={...d.categories},S(),e.onConsentUpdate?.(d),e.backend)try{Promise.resolve(e.backend.persist(K(d,e.region))).catch(()=>{})}catch{}else e.apiUrl&&async function(e,t,o,n){const r=K(o,n),i={"Content-Type":"application/json"};t&&(i.Authorization=`Bearer ${t}`);try{await fetch(e,{method:"POST",headers:i,body:JSON.stringify(r),keepalive:!0})}catch{}}(e.apiUrl,e.apiKey,d,e.region);try{I()}catch{}let r=!1;try{const{reloadRequiredBy:e}=z(g);r=function(e){const t=e.length!==y.length||e.some((e,t)=>e!==y[t]);return t&&(y=e,m=!1),t}(e)}catch{}try{R(o,g,n)}catch{}r&&S(),t&&e.reloadOnRevoke&&"undefined"!=typeof window&&window.location.reload()}d={...d,taxonomyHash:o.taxonomyHash},e.gpcOptOut&&!d.hasActed&&(d={...d,categories:h(()=>!1)},i(d)),u={...d.categories},g={...d.categories},Promise.resolve().then(()=>e.onConsentReady?.(d));const L={get consentId(){return d.consentId},get hasActed(){return d.hasActed},get categories(){return{...d.categories}},get committedCategories(){return{...g}},get regulation(){return d.regulation},get lastRenewed(){return d.lastRenewed},get taxonomyHash(){return d.taxonomyHash},get isPreferencesOpen(){return p},acceptAll(){d={...d,categories:h(()=>!0)},p=!1,A()},rejectAll(){d={...d,categories:h(()=>!1)},p=!1,A()},acceptSelected(e){d={...d,categories:h(t=>e.includes(t))},p=!1,A()},updateCategory(e,t){o.requiredIds.has(e)||o.ids.includes(e)&&(d={...d,categories:{...d.categories,[e]:t}},S())},savePreferences(){p=!1,A()},resetConsent(){s();const e=a();d=l(e,d.regulation,o),g={...d.categories},u={...d.categories},p=!1,z(g),R(o,g,n),y=[],m=!1,S()},showPreferences(){p=!0,S()},hidePreferences(){p=!1,S()},subscribe:e=>(t.add(e),()=>t.delete(e)),registerScript(e){!function(e){_.set(e.id,e)}(e),I()},get reloadNotice(){return{required:y.length>0&&!m,reasons:[...y]}},dismissReloadNotice(){m||(m=!0,S())}};I();try{!function(e){for(const t of E.values()){const o=!0!==e[t.category];if(j(t))o?F.delete(t.id):F.add(t.id);else try{o?(t.stop(),G.add(t.id)):(G.delete(t.id),t.resume?.())}catch{}}}(d.categories)}catch{}try{R(o,d.categories,n)}catch{}return L}function Y(e,t,o,n){let r;try{const e="undefined"!=typeof window?window.location.href:"http://localhost";r=new URL(t,e)}catch{return null}const i=r.hostname.toLowerCase(),s=r.pathname+r.search,a=o.toUpperCase();for(const t of e){const e=t.domain.toLowerCase();if((i===e||i.endsWith("."+e))&&((!t.pathIncludes||s.includes(t.pathIncludes))&&(!t.methods||t.methods.map(e=>e.toUpperCase()).includes(a))&&!n(t.category)))return t}return null}let V=null;function J(e,t){if("undefined"==typeof window)return()=>{};if(V)return()=>{};if(!e.rules.length)return()=>{};const o={originalFetch:window.fetch,originalXhrOpen:XMLHttpRequest.prototype.open,originalXhrSend:XMLHttpRequest.prototype.send,originalSendBeacon:"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon?navigator.sendBeacon:void 0};V=o;const n=!1!==e.logBlockedRequests;function r(t){n&&console.warn(`[cookieyes] blocked ${t.method} ${t.url} (rule "${t.rule.id}", category: ${t.rule.category})`),e.onRequestBlocked?.(t)}if(window.fetch=function(n,i){let s="",a=i?.method??"GET";"string"==typeof n?s=n:n instanceof URL?s=n.toString():(s=n.url,a=i?.method??n.method);const c=Y(e.rules,s,a,t);return c?(r({rule:c,url:s,method:a}),Promise.reject(new TypeError(`Blocked by consent (rule: ${c.id}, category: ${c.category})`))):o.originalFetch.call(window,n,i)},XMLHttpRequest.prototype.open=function(e,t,...n){return this._cyUrl=t.toString(),this._cyMethod=e,o.originalXhrOpen.apply(this,[e,t,...n])},XMLHttpRequest.prototype.send=function(n){const i=this._cyUrl??"",s=this._cyMethod??"GET",a=Y(e.rules,i,s,t);return a?(r({rule:a,url:i,method:s}),void this.abort()):o.originalXhrSend.call(this,n)},o.originalSendBeacon){const n=o.originalSendBeacon;navigator.sendBeacon=function(o,i){const s=Y(e.rules,o.toString(),"POST",t);return s?(r({rule:s,url:o.toString(),method:"POST"}),!0):n.call(navigator,o,i)}}return Q}function Q(){V&&("undefined"!=typeof window&&(window.fetch=V.originalFetch,XMLHttpRequest.prototype.open=V.originalXhrOpen,XMLHttpRequest.prototype.send=V.originalXhrSend,V.originalSendBeacon&&(navigator.sendBeacon=V.originalSendBeacon)),V=null)}const Z=[{country:"x-vercel-ip-country",region:"x-vercel-ip-country-region"},{country:"cf-ipcountry"}];function ee(){return"undefined"!=typeof navigator&&!0===navigator.globalPrivacyControl}function te(e,t){const o=e.strictest??"GDPR";if(t)return e.detect&&"undefined"!=typeof console&&console.warn("[cookieyes] `regulation` is set manually, so region detection is ignored. Remove one of them to clear the conflict."),{region:void 0,regulation:t,source:"manual",confidence:"high"};const n=e.detect?.(),r=n?function(e,t){if(e)return e[t]??e[t.split("-")[0]??""]}(e.map,n):void 0;return{region:n,regulation:r??o,source:r?"detected":"strictest",confidence:r?"high":"low"}}function oe(e,t){"undefined"!=typeof console&&console.info("[cookieyes] region detection",{region:e.region,regulation:e.regulation,source:e.source,confidence:e.confidence,gpcOptOut:t})}let ne=null,re=null;function ie(e){if(ne)return ne;"offline"===e.mode&&m();const t=h(e),o=new Set,n=t.onConsentUpdate;let r;const i=t.region?te(t.region,t.regulation):{region:void 0,regulation:t.regulation??"DEFAULT",source:"manual",confidence:"high"},s={};"self-hosted"===t.mode&&(t.backend?s.backend=t.backend:t.apiUrl&&(s.apiUrl=t.apiUrl)),t.apiKey&&(s.apiKey=t.apiKey),s.regulation=i.regulation,i.region&&(s.region=i.region);const a=(c=i.regulation,l=t.region,"CCPA"===c&&(l?.honorGpc??!0)&&ee());var c,l;a&&(s.gpcOptOut=!0),t.region?.debug&&oe(i,a),t.colorScheme&&(s.colorScheme=t.colorScheme),t.theme&&(s.theme=t.theme),t.reloadOnRevoke&&(s.reloadOnRevoke=t.reloadOnRevoke),t.googleConsentMatch&&(s.googleConsentMatch=t.googleConsentMatch),t.builtInIntegrations&&t.builtInIntegrations.length>0&&(w(),s.integrations=t.builtInIntegrations),t.customStopHandlers&&(s.customStopHandlers=t.customStopHandlers),t.categories&&(s.categories=t.categories),t.onConsentReady&&(s.onConsentReady=t.onConsentReady),s.onConsentUpdate=e=>{n?.(e),r.push(e.categories);const t=function(e){const t=[],o=[];for(const n of Object.keys(e))e[n]?t.push(n):o.push(n);return{allowedCategories:t,deniedCategories:o}}(e.categories);for(const e of o)e(t)};const d=W(s);r=b(()=>d.committedCategories);const u=f(t.categories),g=new Set;function p(){const e=v();for(const t of g)t(e)}d.subscribe(p);const y=T(t.i18n,p);function v(){const e=d.categories;return{consentId:d.consentId,hasActed:d.hasActed,categories:e,consents:e,committedConsents:d.committedCategories,regulation:d.regulation,lastRenewed:d.lastRenewed,taxonomyHash:d.taxonomyHash,activeUI:d.isPreferencesOpen?"dialog":d.hasActed?null:"banner",has:e=>!0===d.committedCategories[e],saveConsents:async e=>{"all"===e?d.acceptAll():"necessary"===e?d.rejectAll():d.acceptSelected(e)},setConsent:(e,t)=>d.updateCategory(e,t),subscribeToConsentChanges:e=>(o.add(e),()=>{o.delete(e)})}}const k={subscribe:e=>(g.add(e),()=>{g.delete(e)}),getState:v,on:(e,t,o)=>r.on(e,t,o),get translations(){return y.getTranslations()},getLanguageInfo:y.getLanguageInfo,setLanguage:y.setLanguage,getCategoryText:y.getCategoryText,categories:u,getRegion:()=>i};return t.networkBlocker&&t.networkBlocker.rules.length>0&&J(t.networkBlocker,e=>!0===d.committedCategories[e]),t.integrations&&t.integrations.length>0&&($(t.integrations.map(e=>e.id),(t.builtInIntegrations??[]).map(e=>e.vendor)),M(t.integrations,u.ids),re=B(t.integrations,{granted:e=>!0===d.committedCategories[e],subscribe:e=>d.subscribe(()=>e()),region:i})),ne={consentManager:d,consentStore:k,getIntegrations:()=>re?.list()??[]},ne}exports.CORE_VERSION="0.5.0",exports.DEFAULT_CATEGORIES=d,exports.INTEGRATION_FORMAT_VERSION=1,exports._clearScriptRegistry=function(){if("undefined"!=typeof document)for(const e of D.values())e.remove();_.clear(),D.clear()},exports._clearStopHandlers=function(){E.clear(),G.clear(),F.clear()},exports._logRegionDecision=oe,exports._normalizeConfig=h,exports._resetBuiltInIntegrationsWarning=function(){v=!1},exports._resetOfflineModeWarning=function(){y=!1},exports._warnBuiltInIntegrationsDeprecated=w,exports._warnOfflineModeDeprecated=m,exports.broadcastGoogleConsent=R,exports.computeGoogleConsent=x,exports.createConsentEmitter=b,exports.createConsentManager=W,exports.createLanguageController=T,exports.defaultTranslations=S,exports.generateConsentId=a,exports.getOrCreateConsentRuntime=ie,exports.getTextDirection=L,exports.initCookieYes=function(e){return ie(e)},exports.installNetworkBlocker=J,exports.mergeTranslations=O,exports.parseCookie=o,exports.parseCookieHeader=r,exports.pickLanguage=U,exports.primaryOf=A,exports.readGpc=ee,exports.readServerConsent=function(e,t={}){if("string"!=typeof e||0===e.length)return null;const o=r(e);if(null==o)return null;const n=f(t.categories),i=o.tax;if(!(i===n.taxonomyHash||void 0===i&&n.isDefault))return null;const s=c(o,t.regulation??"DEFAULT",n);return s.hasActed?{...s,taxonomyHash:n.taxonomyHash}:null},exports.regionFromHeaders=function(e,t){if(t?.header)return e.get(t.header)||void 0;for(const{country:t,region:o}of Z){const n=e.get(t);if(!n)continue;const r=o?e.get(o):void 0;return r?`${n}-${r}`:n}},exports.registerStopHandler=X,exports.resetConsentRuntime=function(){Q(),re?.stop(),re=null,ne=null},exports.resolveBuiltInIntegration=N,exports.resolveCategories=f,exports.resolveRegion=te,exports.resolveTranslations=function(e){const t=e?.messages??{},o=U(e);return O(S,t[o]??t[A(o)])},exports.runIntegrations=B,exports.serializeCookie=n,exports.uninstallNetworkBlocker=Q,exports.warnOverlappingVendors=$,exports.warnUnknownCategories=M;
1
+ "use strict";var e=require("./integrations.cjs"),t=require("./network-blocker--Z2J__Xr.cjs");const o="cookieyes-consent",n=new Set(["consentid","consent","action","tax","lastRenewedDate"]);function r(e){const t={categories:{}};for(const o of e.split(",")){const e=o.indexOf(":");if(-1===e)continue;const r=o.slice(0,e).trim(),s=o.slice(e+1).trim();n.has(r)?t[r]=s:r.length>0&&(t.categories[r]=s)}return t}function s(e){const t=[`consentid:${e.consentId}`,"consent:"+(e.hasActed?"yes":"no"),"action:"+(e.hasActed?"yes":"no")];e.taxonomyHash&&t.push(`tax:${e.taxonomyHash}`);for(const[o,n]of Object.entries(e.categories))t.push(`${o}:${n?"yes":"no"}`);return t.push(`lastRenewedDate:${e.lastRenewed??Date.now()}`),t.join(",")}function i(e){for(const t of e.split(";")){const e=t.trim(),n=e.indexOf("=");if(-1===n)continue;if(e.slice(0,n).trim()!==o)continue;const s=e.slice(n+1).trim();try{return r(decodeURIComponent(s))}catch{return null}}return null}function a(e){if("undefined"==typeof document)return;const t=encodeURIComponent(s(e));document.cookie=`${o}=${t}; max-age=31536000; path=/; SameSite=Lax`}function c(){"undefined"!=typeof document&&(document.cookie=`${o}=; max-age=0; path=/`)}function l(){const e=new Uint8Array(32);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(256*Math.random());return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"").slice(0,44)}function d(e,t,o){const n={};for(const t of o.ids)n[t]=!!o.requiredIds.has(t)||"yes"===e.categories[t];return{consentId:e.consentid??l(),hasActed:"yes"===e.action,categories:n,regulation:t,lastRenewed:e.lastRenewedDate?Number(e.lastRenewedDate):void 0,taxonomyHash:e.tax}}function u(e,t,o){const n="CCPA"===t,r={};for(const e of o.ids)r[e]=!!o.requiredIds.has(e)||n;return{consentId:e,hasActed:!1,categories:r,regulation:t,taxonomyHash:o.taxonomyHash}}const g=[{id:"necessary",required:!0},{id:"functional",gcm:["functionality_storage","personalization_storage"]},{id:"analytics",gcm:["analytics_storage"]},{id:"performance"},{id:"advertisement",gcm:["ad_storage","ad_user_data","ad_personalization"]}];function f(e){let t=2166136261;for(let o=0;o<e.length;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function p(e,t){const o=e.map(e=>e.id),n=new Set(e.filter(e=>e.required).map(e=>e.id)),r=e.map(e=>`${e.id}:${e.required?1:0}:${(e.gcm??[]).join("+")}`).join("|");return{list:e,ids:o,requiredIds:n,taxonomyHash:f(r),isDefault:t}}function h(e){if(!e||0===e.length)return p(g,!0);const t=function(e){const t=e.map(e=>e.id);return t.some(e=>"string"!=typeof e||0===e.length)?"every category needs a non-empty string id":t.some(e=>e.includes(",")||e.includes(":"))?"category ids must not contain ',' or ':'":new Set(t).size!==t.length?"category ids must be unique":t.some(e=>n.has(e))?`category ids must not be one of the reserved keys: ${[...n].join(", ")}`:e.some(e=>!0===e.required)?null:"at least one category must be marked { required: true }"}(e);return t?("undefined"!=typeof console&&console.warn(`[cookieyes] Invalid categories config (${t}). Falling back to the default five (necessary, functional, analytics, performance, advertisement).`),p(g,!0)):p(e,!1)}function y(e){"undefined"!=typeof console&&console.warn(e)}function m(e){const t={mode:e.mode},o=e.overrides?.regulation;return void 0!==e.regulation?(t.regulation=e.regulation,void 0!==o&&y("[CookieYes] Received both `regulation` and the deprecated `overrides.regulation`. Using the top-level `regulation` and ignoring `overrides`. Drop the `overrides` object — it is deprecated and will be removed after three release cycles.")):void 0!==o&&(t.regulation=o),void 0!==e.region&&(t.region=e.region),void 0!==e.colorScheme&&(t.colorScheme=e.colorScheme),void 0!==e.theme&&(t.theme=e.theme),void 0!==e.i18n&&(t.i18n=e.i18n),void 0!==e.categories&&(t.categories=e.categories),void 0!==e.networkBlocker&&(t.networkBlocker=e.networkBlocker),void 0!==e.reloadOnRevoke&&(t.reloadOnRevoke=e.reloadOnRevoke),void 0!==e.googleConsentMatch&&(t.googleConsentMatch=e.googleConsentMatch),void 0!==e.integrations&&(t.integrations=e.integrations),void 0!==e.builtInIntegrations&&(t.builtInIntegrations=e.builtInIntegrations),void 0!==e.customStopHandlers&&(t.customStopHandlers=e.customStopHandlers),void 0!==e.onConsentReady&&(t.onConsentReady=e.onConsentReady),void 0!==e.onConsentUpdate&&(t.onConsentUpdate=e.onConsentUpdate),"self-hosted"===e.mode&&(void 0!==e.apiKey&&(t.apiKey=e.apiKey),void 0!==e.backend&&(t.backend=e.backend),void 0!==e.apiUrl?(t.apiUrl=e.apiUrl,void 0!==e.backendURL&&y("[CookieYes] Received both `apiUrl` and the deprecated `backendURL`. Using `apiUrl` and ignoring `backendURL`. Rename `backendURL` to `apiUrl` — the alias is deprecated and will be removed after three release cycles.")):void 0!==e.backendURL&&(t.apiUrl=e.backendURL)),t}let k=!1;function w(){"production"!==process.env.NODE_ENV&&(k||(k=!0,"undefined"!=typeof console&&console.warn('[cookieyes] mode: "offline" has been renamed to "cookie-only". Both do exactly the same thing, but "offline" is deprecated and will be removed after three release cycles. See https://github.com/cookieyes/cookieyes/blob/main/apps/web/content/docs/migration.mdx for the full migration guide. Update to .mode("cookie-only") (or { mode: "cookie-only" }).')))}let v=!1;function b(){"production"!==process.env.NODE_ENV&&(v||(v=!0,"undefined"!=typeof console&&console.warn("[cookieyes] `builtInIntegrations` (formerly the `integrations` field) is deprecated and will be removed after three release cycles. Use the `integrations` field with a preset from `@cookieyes/scripts` instead. See https://github.com/cookieyes/cookieyes/blob/main/apps/web/content/docs/migration.mdx for the full migration guide.")))}function C(e){const t={save:new Set,change:new Set};let o={...e()};function n(e,t,o){try{e.listener(o)}catch(e){"undefined"!=typeof console&&console.error(`[cookieyes] a consent "${t}" listener threw; others are unaffected:`,e)}}function r(e,o){for(const r of[...t[e]])r.category&&!o.changedCategories.includes(r.category)||n(r,e,o)}return{on(o,r,s){const i=s?.category?{listener:r,category:s.category}:{listener:r};return t[o].add(i),n(i,o,{categories:{...e()},changedCategories:[],isInitial:!0}),()=>{t[o].delete(i)}},push(e){const t={...e},n=[];for(const e of Object.keys(t))o[e]!==t[e]&&n.push(e);o=t,r("save",{categories:t,changedCategories:n,isInitial:!1}),n.length>0&&r("change",{categories:t,changedCategories:n,isInitial:!1})}}}function x(e){"undefined"!=typeof console&&console.warn(`[cookieyes] ${e}`)}const R=["ad_storage","ad_user_data","ad_personalization","analytics_storage","functionality_storage","personalization_storage","security_storage"];function I(e,t,o="any"){const n={};for(const r of R){if("security_storage"===r){n[r]="granted";continue}const s=e.list.filter(e=>e.gcm?.includes(r));if(0===s.length){n[r]="denied";continue}const i="all"===o?s.every(e=>!0===t[e.id]):s.some(e=>!0===t[e.id]);n[r]=i?"granted":"denied"}return n}function S(e,t,o="any"){if("undefined"==typeof window||!Array.isArray(window.dataLayer))return;const n=I(e,t,o),r=window.dataLayer;if(!r)return;!function(){r.push(arguments)}("consent","update",n)}const A={bannerTitle:"We value your privacy",bannerDescription:"We use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking “Accept All”, you consent to our use of cookies.",acceptAll:"Accept All",rejectAll:"Reject All",managePreferences:"Customise",savePreferences:"Save My Preferences",doNotSell:"Do Not Sell or Share My Personal Information",ccpaDescription:"This website or its third-party tools process personal data. You can opt out of the sale of your personal information by clicking on the “Do Not Sell or Share My Personal Information” link.",accept:"Accept",poweredBy:"Powered by CookieYes",preferencesTitle:"Customise Consent Preferences",preferencesIntro:"We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.",alwaysActive:"Always Active",preferencesDialogLabel:"Cookie preferences",optOutDialogLabel:"Opt-out preferences",recallButtonLabel:"Consent Preferences",categories:{necessary:{label:"Necessary",description:"Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data."},functional:{label:"Functional",description:"Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features."},analytics:{label:"Analytics",description:"Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc."},performance:{label:"Performance",description:"Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors."},advertisement:{label:"Advertisement",description:"Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns."}},optOut:{title:"Opt-out Preferences",description:'We use third-party cookies that help us analyse how you use this website, store your preferences, and provide the content and advertisements that are relevant to you. However, you can opt out of these cookies by checking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button. Once you opt out, you can opt in again at any time by unchecking "Do Not Sell or Share My Personal Information" and clicking the "Save My Preferences" button.',cancel:"Cancel",successText:"Your opt-out preference has been honored.",successCountdown:"Banner closes automatically in {seconds} s..."},bannerCloseLabel:"Close",preferencesCloseLabel:"Close preferences",optOutCloseLabel:"Close",gatedFrame:{placeholder:"This content requires {category} cookies to be enabled.",action:"Manage Preferences"},reloadNotice:{message:"Some tracking on this page can only be fully stopped by reloading. Reload to apply your change, or dismiss to keep browsing.",reloadButton:"Reload page",dismissButton:"Dismiss"}},O=new Set(["ar","he","fa","ur","ps","sd","yi","dv"]);function _(e){return e.split("-")[0]?.toLowerCase()??""}function U(e){return O.has(_(e))?"rtl":"ltr"}function N(e,t){if(!t)return e;const o={...e};for(const[n,r]of Object.entries(t)){if(null==r)continue;const t=e[n],s="object"==typeof r&&!Array.isArray(r)&&"object"==typeof t&&null!=t;o[n]=s?N(t,r):r}return o}function B(e){const t=e?.messages??{},o=[];e?.locale&&o.push(e.locale),(e?.detectBrowserLanguage??1)&&"undefined"!=typeof navigator&&navigator.language&&o.push(navigator.language);for(const e of o){if(t[e])return e;const o=_(e);if(o&&t[o])return o}return"en"}async function L(){const e=await Promise.resolve().then(function(){return require("./integrations.cjs")});return{runIntegrations:e.runIntegrations,warnOverlappingVendors:e.warnOverlappingVendors,warnUnknownCategories:e.warnUnknownCategories}}function P(e,t){const o={...e?.messages},n=e?.loadLanguage,r=new Set;let s=B(e),i=d(s),a=u();function c(e){return o[e]??o[_(e)]}function l(e){return"en"===_(e)||void 0!==c(e)}function d(e){return N(A,c(e))}function u(){return{language:s,direction:U(s),languages:Array.from(new Set(["en",...Object.keys(o)]))}}function g(e){s=e,i=d(e),a=u(),t()}function f(e,t){r.has(e)||"undefined"==typeof console||(r.add(e),console.warn(`[cookieyes] no translations for language "${e}"; staying on "${s}". Add it to i18n.messages or provide i18n.loadLanguage.`,t??""))}function p(e){return l(e)?(g(e),Promise.resolve()):n?Promise.resolve().then(()=>n(e)).then(t=>{o[e]=t,g(e)}).catch(t=>f(e,t)):(f(e),Promise.resolve())}return n&&e?.locale&&!l(e.locale)&&"undefined"!=typeof window&&p(e.locale),{getTranslations:()=>i,getLanguageInfo:()=>a,setLanguage:p,getCategoryText:function(e){return c(s)?.categories?.[e]}}}const D=new Map,H=new Map;function M(e,t){if(document.getElementById(e))return;const o=document.createElement("script");o.id=e,o.src=t.src,o.async=!0,t.onLoad&&o.addEventListener("load",t.onLoad,{once:!0}),document.head.appendChild(o),H.set(e,o)}function T(e){return"needsReload"in e&&!0===e.needsReload}function j(e){switch(e.vendor){case"meta":return{id:"meta",category:e.category??"advertisement",stop:()=>window.fbq?.("consent","revoke"),resume:()=>window.fbq?.("consent","grant")};case"tiktok":return{id:"tiktok",category:e.category??"advertisement",needsReload:!0};case"linkedin":return{id:"linkedin",category:e.category??"advertisement",needsReload:!0};case"hotjar":return{id:"hotjar",category:e.category??"analytics",needsReload:!0};case"segment":return{id:"segment",category:e.category??"analytics",needsReload:!0}}}const $=new Map,q=new Set,E=new Set;function V(e){$.set(e.id,e)}function F(e){const t=[];for(const o of $.values()){const n=!0!==e[o.category];if(T(o))n?E.has(o.id)&&(t.push(o.id),E.delete(o.id)):E.add(o.id);else if(n){if(!q.has(o.id))try{o.stop(),q.add(o.id)}catch{t.push(o.id)}}else if(q.has(o.id)){q.delete(o.id);try{o.resume?.()}catch{}}}return{reloadRequiredBy:t}}function z(e,t){const o={consentId:e.consentId,categories:e.categories,regulation:e.regulation,domain:"undefined"!=typeof window?window.location.hostname:"unknown"};return t&&(o.region=t),o}function G(e){const t=new Set,o=h(e.categories),n=e.googleConsentMatch??"any";let r;void 0===e.googleConsentMatch&&function(e){const t=new Map;for(const o of e.list)for(const e of o.gcm??[]){let n=t.get(e);n||(n=new Set,t.set(e,n)),n.add(o.id)}for(const[e,o]of t)o.size<=1||x(`categories ${[...o].map(e=>JSON.stringify(e)).join(", ")} all map to the Google signal "${e}", which is a single on/off — this mapping is lossy. Set \`googleConsentMatch: "all"\` to grant it only when all are granted, or "any" (default) to grant it when any is.`)}(o);let s,g,f=!1;function p(e){const t={};for(const n of o.ids)t[n]=!!o.requiredIds.has(n)||e(n);return t}let y=[],m=!1;for(const t of e.integrations??[])V(j(t));for(const t of e.customStopHandlers??[])V(t);const k="undefined"==typeof document?null:i(document.cookie),w=e.regulation??"DEFAULT",v=k?.tax,b=v===o.taxonomyHash,C=null!=k&&(b||void 0===v&&o.isDefault);if(null!=k&&C)r=d(k,w,o);else{const e=k?.consentid??l();r=u(e,w,o),null!=k&&c(),"CCPA"===r.regulation&&a(r)}function R(){const e={consentId:r.consentId,hasActed:r.hasActed,categories:{...r.categories},regulation:r.regulation,lastRenewed:r.lastRenewed,taxonomyHash:r.taxonomyHash};for(const o of t)o(e)}function I(){!function(e){if("undefined"!=typeof document)for(const[t,o]of D)!0===e[o.category]&&(H.has(t)||M(t,o))}(g)}function A(){r={...r,hasActed:!0,lastRenewed:Date.now()},a(r);let t=!1;for(const e of o.ids)if(s[e]&&!r.categories[e]){t=!0;break}if(s={...r.categories},g={...r.categories},R(),e.onConsentUpdate?.(r),e.backend)try{Promise.resolve(e.backend.persist(z(r,e.region))).catch(()=>{})}catch{}else e.apiUrl&&async function(e,t,o,n){const r=z(o,n),s={"Content-Type":"application/json"};t&&(s.Authorization=`Bearer ${t}`);try{await fetch(e,{method:"POST",headers:s,body:JSON.stringify(r),keepalive:!0})}catch{}}(e.apiUrl,e.apiKey,r,e.region);try{I()}catch{}let i=!1;try{const{reloadRequiredBy:e}=F(g);i=function(e){const t=e.length!==y.length||e.some((e,t)=>e!==y[t]);return t&&(y=e,m=!1),t}(e)}catch{}try{S(o,g,n)}catch{}i&&R(),t&&e.reloadOnRevoke&&"undefined"!=typeof window&&window.location.reload()}r={...r,taxonomyHash:o.taxonomyHash},e.gpcOptOut&&!r.hasActed&&(r={...r,categories:p(()=>!1)},a(r)),s={...r.categories},g={...r.categories},Promise.resolve().then(()=>e.onConsentReady?.(r));const O={get consentId(){return r.consentId},get hasActed(){return r.hasActed},get categories(){return{...r.categories}},get committedCategories(){return{...g}},get regulation(){return r.regulation},get lastRenewed(){return r.lastRenewed},get taxonomyHash(){return r.taxonomyHash},get isPreferencesOpen(){return f},acceptAll(){r={...r,categories:p(()=>!0)},f=!1,A()},rejectAll(){r={...r,categories:p(()=>!1)},f=!1,A()},acceptSelected(e){r={...r,categories:p(t=>e.includes(t))},f=!1,A()},updateCategory(e,t){o.requiredIds.has(e)||o.ids.includes(e)&&(r={...r,categories:{...r.categories,[e]:t}},R())},savePreferences(){f=!1,A()},resetConsent(){c();const e=l();r=u(e,r.regulation,o),g={...r.categories},s={...r.categories},f=!1,F(g),S(o,g,n),y=[],m=!1,R()},showPreferences(){f=!0,R()},hidePreferences(){f=!1,R()},subscribe:e=>(t.add(e),()=>t.delete(e)),registerScript(e){!function(e){D.set(e.id,e)}(e),I()},get reloadNotice(){return{required:y.length>0&&!m,reasons:[...y]}},dismissReloadNotice(){m||(m=!0,R())}};I();try{!function(e){for(const t of $.values()){const o=!0!==e[t.category];if(T(t))o?E.delete(t.id):E.add(t.id);else try{o?(t.stop(),q.add(t.id)):(q.delete(t.id),t.resume?.())}catch{}}}(r.categories)}catch{}try{S(o,r.categories,n)}catch{}return O}const K=[{country:"x-vercel-ip-country",region:"x-vercel-ip-country-region"},{country:"cf-ipcountry"}];function Y(){return"undefined"!=typeof navigator&&!0===navigator.globalPrivacyControl}function W(e,t){const o=e.strictest??"GDPR";if(t)return e.detect&&"undefined"!=typeof console&&console.warn("[cookieyes] `regulation` is set manually, so region detection is ignored. Remove one of them to clear the conflict."),{region:void 0,regulation:t,source:"manual",confidence:"high"};const n=e.detect?.(),r=n?function(e,t){if(e)return e[t]??e[t.split("-")[0]??""]}(e.map,n):void 0;return{region:n,regulation:r??o,source:r?"detected":"strictest",confidence:r?"high":"low"}}function J(e,t){"undefined"!=typeof console&&console.info("[cookieyes] region detection",{region:e.region,regulation:e.regulation,source:e.source,confidence:e.confidence,gpcOptOut:t})}let Q=null,X=null,Z=0;function ee(e){if(Q)return Q;"offline"===e.mode&&w();const o=m(e),n=new Set,r=o.onConsentUpdate;let s;const i=o.region?W(o.region,o.regulation):{region:void 0,regulation:o.regulation??"DEFAULT",source:"manual",confidence:"high"},a={};"self-hosted"===o.mode&&(o.backend?a.backend=o.backend:o.apiUrl&&(a.apiUrl=o.apiUrl)),o.apiKey&&(a.apiKey=o.apiKey),a.regulation=i.regulation,i.region&&(a.region=i.region);const c=(l=i.regulation,d=o.region,"CCPA"===l&&(d?.honorGpc??!0)&&Y());var l,d;c&&(a.gpcOptOut=!0),o.region?.debug&&J(i,c),o.colorScheme&&(a.colorScheme=o.colorScheme),o.theme&&(a.theme=o.theme),o.reloadOnRevoke&&(a.reloadOnRevoke=o.reloadOnRevoke),o.googleConsentMatch&&(a.googleConsentMatch=o.googleConsentMatch),o.builtInIntegrations&&o.builtInIntegrations.length>0&&(b(),a.integrations=o.builtInIntegrations),o.customStopHandlers&&(a.customStopHandlers=o.customStopHandlers),o.categories&&(a.categories=o.categories),o.onConsentReady&&(a.onConsentReady=o.onConsentReady),a.onConsentUpdate=e=>{r?.(e),s.push(e.categories);const t=function(e){const t=[],o=[];for(const n of Object.keys(e))e[n]?t.push(n):o.push(n);return{allowedCategories:t,deniedCategories:o}}(e.categories);for(const e of n)e(t)};const u=G(a);s=C(()=>u.committedCategories);const g=h(o.categories),f=new Set;function p(){const e=k();for(const t of f)t(e)}u.subscribe(p);const y=P(o.i18n,p);function k(){const e=u.categories;return{consentId:u.consentId,hasActed:u.hasActed,categories:e,consents:e,committedConsents:u.committedCategories,regulation:u.regulation,lastRenewed:u.lastRenewed,taxonomyHash:u.taxonomyHash,activeUI:u.isPreferencesOpen?"dialog":u.hasActed?null:"banner",has:e=>!0===u.committedCategories[e],saveConsents:async e=>{"all"===e?u.acceptAll():"necessary"===e?u.rejectAll():u.acceptSelected(e)},setConsent:(e,t)=>u.updateCategory(e,t),subscribeToConsentChanges:e=>(n.add(e),()=>{n.delete(e)})}}const v={subscribe:e=>(f.add(e),()=>{f.delete(e)}),getState:k,on:(e,t,o)=>s.on(e,t,o),get translations(){return y.getTranslations()},getLanguageInfo:y.getLanguageInfo,setLanguage:y.setLanguage,getCategoryText:y.getCategoryText,categories:g,getRegion:()=>i};o.networkBlocker&&o.networkBlocker.rules.length>0&&t._installRegisteredNetworkBlocker(o.networkBlocker,e=>!0===u.committedCategories[e]);let x=Promise.resolve();if(o.integrations&&o.integrations.length>0){const e=o.integrations,t=o.builtInIntegrations??[],n=++Z;x=L().then(o=>{n===Z&&(o.warnOverlappingVendors(e.map(e=>e.id),t.map(e=>e.vendor)),o.warnUnknownCategories(e,g.ids),X=o.runIntegrations(e,{granted:e=>!0===u.committedCategories[e],subscribe:e=>u.subscribe(()=>e()),region:i}))})}return Q={consentManager:u,consentStore:v,getIntegrations:()=>X?.list()??[],integrationsReady:x},Q}exports.INTEGRATION_FORMAT_VERSION=e.INTEGRATION_FORMAT_VERSION,exports.runIntegrations=e.runIntegrations,exports.warnOverlappingVendors=e.warnOverlappingVendors,exports.warnUnknownCategories=e.warnUnknownCategories,exports._clearNetworkBlockerInstaller=t._clearNetworkBlockerInstaller,exports._hasNetworkBlockerInstaller=t._hasNetworkBlockerInstaller,exports._installRegisteredNetworkBlocker=t._installRegisteredNetworkBlocker,exports._uninstallRegisteredNetworkBlocker=t._uninstallRegisteredNetworkBlocker,exports.installNetworkBlocker=t.installNetworkBlocker,exports.registerNetworkBlocker=t.registerNetworkBlocker,exports.uninstallNetworkBlocker=t.uninstallNetworkBlocker,exports.CORE_VERSION="0.6.0",exports.DEFAULT_CATEGORIES=g,exports._clearScriptRegistry=function(){if("undefined"!=typeof document)for(const e of H.values())e.remove();D.clear(),H.clear()},exports._clearStopHandlers=function(){$.clear(),q.clear(),E.clear()},exports._loadIntegrations=L,exports._logRegionDecision=J,exports._normalizeConfig=m,exports._resetBuiltInIntegrationsWarning=function(){v=!1},exports._resetOfflineModeWarning=function(){k=!1},exports._warnBuiltInIntegrationsDeprecated=b,exports._warnOfflineModeDeprecated=w,exports.broadcastGoogleConsent=S,exports.computeGoogleConsent=I,exports.createConsentEmitter=C,exports.createConsentManager=G,exports.createLanguageController=P,exports.defaultTranslations=A,exports.generateConsentId=l,exports.getOrCreateConsentRuntime=ee,exports.getTextDirection=U,exports.initCookieYes=function(e){return ee(e)},exports.mergeTranslations=N,exports.parseCookie=r,exports.parseCookieHeader=i,exports.pickLanguage=B,exports.primaryOf=_,exports.readGpc=Y,exports.readServerConsent=function(e,t={}){if("string"!=typeof e||0===e.length)return null;const o=i(e);if(null==o)return null;const n=h(t.categories),r=o.tax;if(!(r===n.taxonomyHash||void 0===r&&n.isDefault))return null;const s=d(o,t.regulation??"DEFAULT",n);return s.hasActed?{...s,taxonomyHash:n.taxonomyHash}:null},exports.regionFromHeaders=function(e,t){if(t?.header)return e.get(t.header)||void 0;for(const{country:t,region:o}of K){const n=e.get(t);if(!n)continue;const r=o?e.get(o):void 0;return r?`${n}-${r}`:n}},exports.registerStopHandler=V,exports.resetConsentRuntime=function(){t._uninstallRegisteredNetworkBlocker(),Z++,X?.stop(),X=null,Q=null},exports.resolveBuiltInIntegration=j,exports.resolveCategories=h,exports.resolveRegion=W,exports.resolveTranslations=function(e){const t=e?.messages??{},o=B(e);return N(A,t[o]??t[_(o)])},exports.serializeCookie=s;
2
2
  //# sourceMappingURL=index.cjs.map