@banzamel/mineralui 1.0.5 → 1.0.6

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Modern React UI framework with a sharp admin aesthetic, theming system, and production-ready components.
4
4
 
5
5
  - npm: `@banzamel/mineralui`
6
- - version: `1.0.5`
6
+ - version: `1.0.6`
7
7
  - peer dependencies: `react >= 19`, `react-dom >= 19`
8
8
  - repository: `https://github.com/Banzamel/mineralui`
9
9
  - homepage: `https://mineralui.io`
@@ -373,8 +373,7 @@ function W(e) {
373
373
  }
374
374
  async function G(e, t) {
375
375
  let n = U(e), r = n?.scanEndpoint ?? n?.reportEndpoint;
376
- if (!r || typeof fetch > "u") return t ?? W(n);
377
- if (!n) return t ?? null;
376
+ if (!r || typeof fetch > "u" || !n) return t ?? null;
378
377
  let i = t ?? W(n);
379
378
  return i ? (await fetch(r, {
380
379
  method: n.reportMethod ?? "POST",
@@ -393,11 +392,11 @@ function K(e) {
393
392
  let n = M(t), r = null, i = null, a = () => {
394
393
  r != null && (window.clearTimeout(r), r = null), i != null && (window.clearTimeout(i), i = null);
395
394
  }, o = (e = 0, n) => {
396
- a(), r = window.setTimeout(() => {
395
+ !t.scanEndpoint && !t.reportEndpoint || (a(), r = window.setTimeout(() => {
397
396
  r = null, G(t);
398
397
  }, e), typeof n == "number" && (i = window.setTimeout(() => {
399
398
  i = null, G(t);
400
- }, n));
399
+ }, n)));
401
400
  }, s = (e) => {
402
401
  n = e === void 0 ? M(t) : e, B(n, t);
403
402
  };
@@ -434,4 +433,4 @@ function q() {
434
433
  //#endregion
435
434
  export { i as _, W as a, S as c, _ as d, v as f, e as g, n as h, G as i, C as l, t as m, K as n, x as o, f as p, U as r, b as s, q as t, y as u, a as v, r as y };
436
435
 
437
- //# sourceMappingURL=MCookieBootstrap-DEEHYxXi.js.map
436
+ //# sourceMappingURL=MCookieBootstrap-BbpXuRtS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MCookieBootstrap-DEEHYxXi.js","names":[],"sources":["../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.defaults.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.inventory.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.storage.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.types.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.ts"],"sourcesContent":["import type {MCookieConsentTexts} from '../../../../i18n/frameworkTexts'\nimport type {MCookieCategoryDefinition, MCookieConsentPersistence, MCookieDeclarationItem} from './MCookieConsent.types'\n\nexport const COOKIE_CONSENT_STORAGE_KEY = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_NAME = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_MAX_AGE_DAYS = 180\nexport const COOKIE_CONSENT_STORAGE: MCookieConsentPersistence = 'localStorage'\n\nexport function mergeCookieConsentTexts(\n baseTexts: MCookieConsentTexts,\n override?: Partial<MCookieConsentTexts>\n): MCookieConsentTexts {\n return {\n ...baseTexts,\n ...override,\n }\n}\n\nexport function createCookieConsentCategories(texts: MCookieConsentTexts): MCookieCategoryDefinition[] {\n return [\n {\n key: 'necessary',\n label: texts.necessaryLabel,\n description: texts.necessaryDescription,\n required: true,\n defaultValue: true,\n },\n {\n key: 'preferences',\n label: texts.preferencesLabel,\n description: texts.preferencesDescriptionLabel,\n defaultValue: false,\n },\n {\n key: 'analytics',\n label: texts.analyticsLabel,\n description: texts.analyticsDescription,\n defaultValue: false,\n },\n {\n key: 'marketing',\n label: texts.marketingLabel,\n description: texts.marketingDescription,\n defaultValue: false,\n },\n ]\n}\n\nexport function createCookieConsentDeclaration(): MCookieDeclarationItem[] {\n return []\n}\n","import {COOKIE_CONSENT_COOKIE_NAME} from './MCookieConsent.defaults'\nimport type {\n MCookieCategoryRules,\n MCookieDetectedCookie,\n MCookieDetectedCookieMatch,\n MCookieMatchRule,\n} from './MCookieConsent.types'\n\nconst INTERNAL_REQUIRED_COOKIE_RULES: MCookieMatchRule[] = [\n COOKIE_CONSENT_COOKIE_NAME,\n /^PHPSESSID$/i,\n /^JSESSIONID$/i,\n /^ASP\\.NET_SessionId$/i,\n /^__Host-/i,\n /^__Secure-/i,\n /csrf/i,\n /xsrf/i,\n /session/i,\n /auth/i,\n /token/i,\n /^sid$/i,\n]\n\nconst BUILT_IN_CATEGORY_RULES: Record<string, MCookieMatchRule[]> = {\n preferences: [/theme/i, /locale/i, /lang/i, /currency/i, /timezone/i, /consent/i],\n analytics: [/^_ga/i, /^_gid/i, /^_gat/i, /^_pk_/i, /^pk_/i, /^_hj/i, /^hj/i, /^amplitude/i, /^mp_/i, /^matomo/i],\n marketing: [/^_fbp$/i, /^_fbc$/i, /^_gcl_/i, /^IDE$/i, /^test_cookie$/i, /^li_/i, /^tt_/i, /^_uet/i, /^pin_utm/i],\n}\n\nfunction matchCookieRule(name: string, rule: MCookieMatchRule) {\n if (typeof rule === 'string') {\n const normalizedRule = rule.trim().toLowerCase()\n const normalizedName = name.trim().toLowerCase()\n\n if (normalizedRule.endsWith('*')) {\n return normalizedName.startsWith(normalizedRule.slice(0, -1))\n }\n\n return normalizedName === normalizedRule\n }\n\n return rule.test(name)\n}\n\nfunction matchCookieRules(name: string, rules?: MCookieMatchRule[]) {\n return Array.isArray(rules) && rules.some((rule) => matchCookieRule(name, rule))\n}\n\nfunction parseDocumentCookies(cookieString: string) {\n if (!cookieString.trim()) {\n return []\n }\n\n return cookieString\n .split(';')\n .map((chunk) => chunk.trim())\n .filter(Boolean)\n .map((chunk) => {\n const separatorIndex = chunk.indexOf('=')\n if (separatorIndex === -1) {\n return {\n name: chunk,\n value: '',\n }\n }\n\n return {\n name: chunk.slice(0, separatorIndex).trim(),\n value: chunk.slice(separatorIndex + 1).trim(),\n }\n })\n .filter((item) => item.name.length > 0)\n}\n\nfunction classifyCookie(\n name: string,\n requiredCookies: MCookieMatchRule[],\n categoryRules: MCookieCategoryRules\n): Pick<MCookieDetectedCookie, 'category' | 'required' | 'matchedBy'> {\n if (matchCookieRules(name, [...INTERNAL_REQUIRED_COOKIE_RULES, ...requiredCookies])) {\n return {\n category: 'necessary',\n required: true,\n matchedBy: 'required',\n }\n }\n\n for (const [category, rules] of Object.entries(categoryRules)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'custom',\n }\n }\n }\n\n for (const [category, rules] of Object.entries(BUILT_IN_CATEGORY_RULES)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'built-in',\n }\n }\n }\n\n return {\n category: 'preferences',\n required: false,\n matchedBy: 'fallback',\n }\n}\n\nexport function detectDocumentCookies({\n cookieString,\n requiredCookies = [],\n categoryRules = {},\n}: {\n cookieString?: string\n requiredCookies?: MCookieMatchRule[]\n categoryRules?: MCookieCategoryRules\n}) {\n const source = cookieString ?? (typeof document !== 'undefined' ? document.cookie : '')\n\n return parseDocumentCookies(source).map<MCookieDetectedCookie>((item) => {\n const classification = classifyCookie(item.name, requiredCookies, categoryRules)\n\n return {\n name: item.name,\n value: item.value,\n category: classification.category,\n required: classification.required,\n matchedBy: classification.matchedBy as MCookieDetectedCookieMatch,\n source: 'document.cookie',\n }\n })\n}\n","import type {MCookieConsentPersistence, MCookieConsentState} from './MCookieConsent.types'\n\ninterface CookieConsentStorageOptions {\n storage: MCookieConsentPersistence\n storageKey: string\n cookieName: string\n cookieMaxAgeDays: number\n}\n\nfunction isCookieConsentState(value: unknown): value is MCookieConsentState {\n if (!value || typeof value !== 'object') {\n return false\n }\n\n const candidate = value as MCookieConsentState\n\n return (\n typeof candidate.version === 'string' &&\n typeof candidate.decidedAt === 'string' &&\n typeof candidate.source === 'string' &&\n candidate.categories != null &&\n typeof candidate.categories === 'object'\n )\n}\n\nfunction readCookieValue(name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const prefix = `${encodeURIComponent(name)}=`\n\n for (const chunk of document.cookie.split(';')) {\n const trimmed = chunk.trim()\n if (trimmed.startsWith(prefix)) {\n return decodeURIComponent(trimmed.slice(prefix.length))\n }\n }\n\n return null\n}\n\nfunction writeCookieValue(name: string, value: string, maxAgeDays: number) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; path=/; max-age=${Math.floor(\n maxAgeDays * 24 * 60 * 60\n )}; samesite=lax`\n}\n\nfunction clearCookieValue(name: string) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=; path=/; max-age=0; samesite=lax`\n}\n\nexport function readStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>): MCookieConsentState | null {\n try {\n const raw = storage === 'cookie' ? readCookieValue(cookieName) : localStorage.getItem(storageKey)\n if (!raw) {\n return null\n }\n\n const parsed = JSON.parse(raw) as unknown\n return isCookieConsentState(parsed) ? parsed : null\n } catch {\n return null\n }\n}\n\nexport function writeStoredCookieConsent(\n {storage, storageKey, cookieName, cookieMaxAgeDays}: CookieConsentStorageOptions,\n state: MCookieConsentState\n) {\n try {\n const serialized = JSON.stringify(state)\n\n if (storage === 'cookie') {\n writeCookieValue(cookieName, serialized, cookieMaxAgeDays)\n return\n }\n\n localStorage.setItem(storageKey, serialized)\n } catch {\n /* noop */\n }\n}\n\nexport function clearStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>) {\n try {\n if (storage === 'cookie') {\n clearCookieValue(cookieName)\n return\n }\n\n localStorage.removeItem(storageKey)\n } catch {\n /* noop */\n }\n}\n","import type {\n MCookieCategoryDefinition,\n MCookieConsentPersistence,\n MCookieConsentState,\n MCookieDeclarationItem,\n} from '../MCookieConsentProvider'\n\nexport const MCOOKIE_CONSENT_CHANGE_EVENT = 'mineralui:cookie-consent-change'\nexport const MCOOKIE_BOOTSTRAP_CONFIG_KEY = '__MINERAL_COOKIE_CONFIG__'\nexport const MCOOKIE_RUNTIME_KEY = '__MINERAL_COOKIE_RUNTIME__'\nexport const MCOOKIE_RUNTIME_READY_EVENT = 'mineralui:cookie-runtime-ready'\n\nexport type MCookieBootstrapResourceKind = 'script' | 'iframe' | 'image'\n\nexport interface MCookieBootstrapResourceRules {\n scripts?: Record<string, string[]>\n iframes?: Record<string, string[]>\n images?: Record<string, string[]>\n}\n\nexport interface MCookieBootstrapScanOptions {\n cookies?: boolean\n storage?: boolean\n scripts?: boolean\n iframes?: boolean\n images?: boolean\n}\n\nexport interface MCookieBootstrapConfig {\n siteKey?: string\n domain?: string\n version?: string\n storage?: MCookieConsentPersistence\n storageKey?: string\n cookieName?: string\n cookieMaxAgeDays?: number\n categories?: MCookieCategoryDefinition[]\n hideOnAccept?: boolean\n autoShow?: boolean\n reopenOnVersionChange?: boolean\n requiredCookies?: string[]\n categoryRules?: Record<string, string[]>\n resources?: MCookieBootstrapResourceRules\n scan?: MCookieBootstrapScanOptions\n configEndpoint?: string\n scanEndpoint?: string\n reportEndpoint?: string\n reportMethod?: 'POST' | 'PUT'\n reportHeaders?: Record<string, string>\n}\n\nexport interface MCookieRuntime {\n config: MCookieBootstrapConfig\n getDeclaration?: () => Promise<MCookieDeclarationItem[]>\n getConsent?: () => Promise<MCookieConsentState | null>\n saveConsent?: (state: MCookieConsentState) => void | Promise<void>\n}\n\nexport interface MCookieBootstrapChangeDetail {\n state: MCookieConsentState | null\n}\n\nexport interface MCookieScanStorageItem {\n kind: 'localStorage' | 'sessionStorage'\n key: string\n value: string\n}\n\nexport interface MCookieScanResourceItem {\n kind: MCookieBootstrapResourceKind\n src: string\n host: string\n category?: string\n}\n\nexport interface MCookieScanCookieItem {\n name: string\n value: string\n category: string\n required: boolean\n matchedBy: string\n source: string\n}\n\nexport interface MCookieScanReport {\n siteKey?: string\n domain: string\n url: string\n scannedAt: string\n cookies: MCookieScanCookieItem[]\n storage: MCookieScanStorageItem[]\n resources: MCookieScanResourceItem[]\n}\n\nexport interface MCookieBootstrapHandle {\n config: MCookieBootstrapConfig\n destroy: () => void\n getState: () => MCookieConsentState | null\n sync: (state?: MCookieConsentState | null) => void\n}\n\ndeclare global {\n interface Window {\n __MINERAL_COOKIE_CONFIG__?: MCookieBootstrapConfig\n __MINERAL_COOKIE_RUNTIME__?: MCookieRuntime\n MineralCookieConsentBootstrap?: MCookieBootstrapHandle\n }\n}\n","import {detectDocumentCookies} from '../MCookieConsentProvider/MCookieConsent.inventory'\nimport {\n COOKIE_CONSENT_COOKIE_NAME,\n COOKIE_CONSENT_STORAGE,\n COOKIE_CONSENT_STORAGE_KEY,\n} from '../MCookieConsentProvider/MCookieConsent.defaults'\nimport {readStoredCookieConsent} from '../MCookieConsentProvider/MCookieConsent.storage'\nimport type {MCookieConsentState} from '../MCookieConsentProvider'\nimport {MCOOKIE_BOOTSTRAP_CONFIG_KEY, MCOOKIE_CONSENT_CHANGE_EVENT} from './MCookieBootstrap.types'\nimport type {\n MCookieBootstrapConfig,\n MCookieBootstrapHandle,\n MCookieBootstrapResourceKind,\n MCookieScanReport,\n MCookieScanResourceItem,\n MCookieScanStorageItem,\n} from './MCookieBootstrap.types'\n\nconst CATEGORY_ATTRIBUTE = 'data-mineral-cookie-category'\nconst BLOCKED_ATTRIBUTE = 'data-mineral-cookie-blocked'\nconst SRC_ATTRIBUTE = 'data-mineral-cookie-src'\nconst TYPE_ATTRIBUTE = 'data-mineral-cookie-type'\n\nfunction toPatternRegExp(pattern: string) {\n const escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '.*')\n return new RegExp(`^${escaped}$`, 'i')\n}\n\nfunction matchesPattern(value: string, pattern: string) {\n return toPatternRegExp(pattern).test(value)\n}\n\nfunction getElementSource(node: Element) {\n if (node instanceof HTMLScriptElement || node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n return node.getAttribute('src') ?? node.getAttribute(SRC_ATTRIBUTE) ?? ''\n }\n\n return ''\n}\n\nfunction getSourceHost(src: string) {\n try {\n return new URL(src, window.location.href).hostname\n } catch {\n return ''\n }\n}\n\nfunction getConsentState(config: MCookieBootstrapConfig) {\n return readStoredCookieConsent({\n storage: config.storage ?? COOKIE_CONSENT_STORAGE,\n storageKey: config.storageKey ?? COOKIE_CONSENT_STORAGE_KEY,\n cookieName: config.cookieName ?? COOKIE_CONSENT_COOKIE_NAME,\n })\n}\n\nfunction isCategoryAllowed(state: MCookieConsentState | null, category: string) {\n if (category === 'necessary') {\n return true\n }\n\n return state?.categories?.[category] === true\n}\n\nfunction findMatchedCategory(node: Element, config: MCookieBootstrapConfig) {\n const explicitCategory = node.getAttribute(CATEGORY_ATTRIBUTE)\n if (explicitCategory) {\n return explicitCategory\n }\n\n const src = getElementSource(node)\n if (!src) {\n return null\n }\n\n const host = getSourceHost(src)\n if (!host) {\n return null\n }\n\n const kind: MCookieBootstrapResourceKind | null =\n node instanceof HTMLScriptElement\n ? 'script'\n : node instanceof HTMLIFrameElement\n ? 'iframe'\n : node instanceof HTMLImageElement\n ? 'image'\n : null\n\n if (!kind) {\n return null\n }\n\n const rules =\n kind === 'script'\n ? config.resources?.scripts\n : kind === 'iframe'\n ? config.resources?.iframes\n : config.resources?.images\n\n if (!rules) {\n return null\n }\n\n for (const [category, patterns] of Object.entries(rules)) {\n if (patterns.some((pattern) => matchesPattern(host, pattern) || matchesPattern(src, pattern))) {\n node.setAttribute(CATEGORY_ATTRIBUTE, category)\n return category\n }\n }\n\n return null\n}\n\nfunction blockNode(node: Element) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) === 'true') {\n return\n }\n\n if (node instanceof HTMLScriptElement) {\n const currentType = node.getAttribute('type') ?? ''\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(TYPE_ATTRIBUTE, currentType === 'text/plain' ? '' : currentType)\n node.type = 'text/plain'\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n }\n}\n\nfunction activateScript(node: HTMLScriptElement) {\n const src = node.getAttribute(SRC_ATTRIBUTE)\n const clone = document.createElement('script')\n\n for (const attribute of node.getAttributeNames()) {\n if (\n attribute === 'type' ||\n attribute === BLOCKED_ATTRIBUTE ||\n attribute === SRC_ATTRIBUTE ||\n attribute === TYPE_ATTRIBUTE\n ) {\n continue\n }\n\n clone.setAttribute(attribute, node.getAttribute(attribute) ?? '')\n }\n\n const originalType = node.getAttribute(TYPE_ATTRIBUTE)\n if (originalType) {\n clone.type = originalType\n }\n\n if (src) {\n clone.src = src\n } else {\n clone.textContent = node.textContent\n }\n\n node.replaceWith(clone)\n}\n\nfunction activateNode(node: Element) {\n if (node instanceof HTMLScriptElement) {\n const canActivate =\n node.getAttribute(BLOCKED_ATTRIBUTE) === 'true' ||\n (node.type === 'text/plain' && node.hasAttribute(CATEGORY_ATTRIBUTE))\n\n if (!canActivate) {\n return\n }\n\n activateScript(node)\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) !== 'true' && !node.hasAttribute(SRC_ATTRIBUTE)) {\n return\n }\n\n const src = node.getAttribute(SRC_ATTRIBUTE)\n if (src) {\n node.setAttribute('src', src)\n }\n\n node.removeAttribute(SRC_ATTRIBUTE)\n node.removeAttribute(BLOCKED_ATTRIBUTE)\n }\n}\n\nfunction collectCandidateNodes(root: ParentNode) {\n const directNodes: Element[] = []\n\n if (root instanceof Element) {\n directNodes.push(root)\n }\n\n const nestedNodes = Array.from(root.querySelectorAll('script, iframe, img'))\n return [...directNodes, ...nestedNodes]\n}\n\nfunction syncNode(node: Element, state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const category = findMatchedCategory(node, config)\n if (!category) {\n return\n }\n\n if (isCategoryAllowed(state, category)) {\n activateNode(node)\n return\n }\n\n blockNode(node)\n}\n\nfunction syncDocument(state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n for (const node of collectCandidateNodes(document)) {\n syncNode(node, state, config)\n }\n}\n\nfunction patchDomInsertion(getState: () => MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const appendChild = Node.prototype.appendChild\n const insertBefore = Node.prototype.insertBefore\n const replaceChild = Node.prototype.replaceChild\n\n Node.prototype.appendChild = function patchedAppendChild<T extends Node>(node: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return appendChild.call(this, node) as T\n }\n\n Node.prototype.insertBefore = function patchedInsertBefore<T extends Node>(node: T, child: Node | null) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return insertBefore.call(this, node, child) as T\n }\n\n Node.prototype.replaceChild = function patchedReplaceChild<T extends Node>(node: Node, child: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return replaceChild.call(this, node, child) as T\n }\n\n return () => {\n Node.prototype.appendChild = appendChild\n Node.prototype.insertBefore = insertBefore\n Node.prototype.replaceChild = replaceChild\n }\n}\n\nfunction scanStorage(storage: Storage, kind: 'localStorage' | 'sessionStorage') {\n const items: MCookieScanStorageItem[] = []\n\n try {\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index)\n if (!key) {\n continue\n }\n\n items.push({\n kind,\n key,\n value: storage.getItem(key) ?? '',\n })\n }\n } catch {\n return []\n }\n\n return items\n}\n\nexport function readMCookieBootstrapConfig(config?: MCookieBootstrapConfig | null) {\n if (config) {\n return config\n }\n\n if (typeof window === 'undefined') {\n return null\n }\n\n return window[MCOOKIE_BOOTSTRAP_CONFIG_KEY] ?? null\n}\n\nexport function scanMCookieSurface(config?: MCookieBootstrapConfig | null): MCookieScanReport | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n const scan = resolvedConfig.scan ?? {}\n const storageItems: MCookieScanStorageItem[] = []\n const resources: MCookieScanResourceItem[] = []\n\n if (scan.storage !== false) {\n storageItems.push(...scanStorage(window.localStorage, 'localStorage'))\n storageItems.push(...scanStorage(window.sessionStorage, 'sessionStorage'))\n }\n\n const resourceSelectors: Array<[boolean, string, MCookieBootstrapResourceKind]> = [\n [scan.scripts !== false, 'script[src], script[data-mineral-cookie-src]', 'script'],\n [scan.iframes !== false, 'iframe[src], iframe[data-mineral-cookie-src]', 'iframe'],\n [scan.images !== false, 'img[src], img[data-mineral-cookie-src]', 'image'],\n ]\n\n for (const [enabled, selector, kind] of resourceSelectors) {\n if (!enabled) {\n continue\n }\n\n for (const node of Array.from(document.querySelectorAll(selector))) {\n const src = getElementSource(node)\n if (!src) {\n continue\n }\n\n resources.push({\n kind,\n src,\n host: getSourceHost(src),\n category: node.getAttribute(CATEGORY_ATTRIBUTE) ?? undefined,\n })\n }\n }\n\n return {\n siteKey: resolvedConfig.siteKey,\n domain: resolvedConfig.domain ?? window.location.hostname,\n url: window.location.href,\n scannedAt: new Date().toISOString(),\n cookies:\n scan.cookies === false\n ? []\n : detectDocumentCookies({\n requiredCookies: resolvedConfig.requiredCookies ?? [],\n categoryRules: resolvedConfig.categoryRules ?? {},\n }).map((item) => ({\n ...item,\n matchedBy: item.matchedBy,\n source: item.source,\n })),\n storage: storageItems,\n resources,\n }\n}\n\nexport async function reportMCookieSurface(config?: MCookieBootstrapConfig | null, report?: MCookieScanReport | null) {\n const resolvedConfig = readMCookieBootstrapConfig(config)\n const endpoint = resolvedConfig?.scanEndpoint ?? resolvedConfig?.reportEndpoint\n\n if (!endpoint || typeof fetch === 'undefined') {\n return report ?? scanMCookieSurface(resolvedConfig)\n }\n\n if (!resolvedConfig) {\n return report ?? null\n }\n\n const payload = report ?? scanMCookieSurface(resolvedConfig)\n if (!payload) {\n return null\n }\n\n await fetch(endpoint, {\n method: resolvedConfig.reportMethod ?? 'POST',\n headers: {\n 'content-type': 'application/json',\n ...(resolvedConfig.siteKey ? {'x-mineral-site-key': resolvedConfig.siteKey} : {}),\n ...resolvedConfig.reportHeaders,\n },\n body: JSON.stringify(payload),\n })\n\n return payload\n}\n\nexport function bootstrapMCookieConsent(config?: MCookieBootstrapConfig | null): MCookieBootstrapHandle | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n let state = getConsentState(resolvedConfig)\n let reportTimer: number | null = null\n let followUpReportTimer: number | null = null\n\n const clearReportTimers = () => {\n if (reportTimer != null) {\n window.clearTimeout(reportTimer)\n reportTimer = null\n }\n\n if (followUpReportTimer != null) {\n window.clearTimeout(followUpReportTimer)\n followUpReportTimer = null\n }\n }\n\n const scheduleReport = (primaryDelay = 0, followUpDelay?: number) => {\n clearReportTimers()\n\n reportTimer = window.setTimeout(() => {\n reportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, primaryDelay)\n\n if (typeof followUpDelay === 'number') {\n followUpReportTimer = window.setTimeout(() => {\n followUpReportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, followUpDelay)\n }\n }\n\n const sync = (nextState?: MCookieConsentState | null) => {\n state = nextState === undefined ? getConsentState(resolvedConfig) : nextState\n syncDocument(state, resolvedConfig)\n }\n\n sync(state)\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of Array.from(record.addedNodes)) {\n if (!(node instanceof Element)) {\n continue\n }\n\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, state, resolvedConfig)\n }\n }\n }\n })\n\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n })\n\n const handleConsentChange = (event: Event) => {\n const detail = (event as CustomEvent<{state: MCookieConsentState | null}>).detail\n sync(detail?.state ?? null)\n scheduleReport(300, 1500)\n }\n\n window.addEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n\n const restoreDom = patchDomInsertion(() => state, resolvedConfig)\n\n const handleWindowLoad = () => {\n scheduleReport()\n }\n\n if (document.readyState === 'complete') {\n handleWindowLoad()\n } else {\n window.addEventListener('load', handleWindowLoad, {once: true})\n }\n\n const handle: MCookieBootstrapHandle = {\n config: resolvedConfig,\n destroy: () => {\n observer.disconnect()\n restoreDom()\n clearReportTimers()\n window.removeEventListener('load', handleWindowLoad)\n window.removeEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n if (window.MineralCookieConsentBootstrap === handle) {\n delete window.MineralCookieConsentBootstrap\n }\n },\n getState: () => state,\n sync,\n }\n\n window.MineralCookieConsentBootstrap = handle\n return handle\n}\n\nexport function autoBootstrapMCookieConsent() {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n return bootstrapMCookieConsent(readMCookieBootstrapConfig())\n}\n"],"mappings":";AAGA,IAAa,IAA6B,4BAC7B,IAA6B,4BAE7B,IAAoD;AAEjE,SAAgB,EACZ,GACA,GACmB;AACnB,QAAO;EACH,GAAG;EACH,GAAG;EACN;;AAGL,SAAgB,EAA8B,GAAyD;AACnG,QAAO;EACH;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,UAAU;GACV,cAAc;GACjB;EACD;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,cAAc;GACjB;EACD;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,cAAc;GACjB;EACD;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,cAAc;GACjB;EACJ;;AAGL,SAAgB,IAA2D;AACvE,QAAO,EAAE;;;;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Q,MAA2C;AAErD,EADA,IAAQ,MAAc,KAAA,IAAY,EAAgB,EAAe,GAAG,GACpE,EAAa,GAAO,EAAe;;AAGvC,GAAK,EAAM;CAEX,IAAM,IAAW,IAAI,kBAAkB,MAAY;AAC/C,OAAK,IAAM,KAAU,EACjB,MAAK,IAAM,KAAQ,MAAM,KAAK,EAAO,WAAW,CACtC,kBAAgB,QAItB,MAAK,IAAM,KAAW,EAAsB,EAAK,CAC7C,GAAS,GAAS,GAAO,EAAe;GAItD;AAEF,GAAS,QAAQ,SAAS,iBAAiB;EACvC,WAAW;EACX,SAAS;EACZ,CAAC;CAEF,IAAM,KAAuB,MAAiB;EAC1C,IAAM,IAAU,EAA2D;AAE3E,EADA,EAAK,GAAQ,SAAS,KAAK,EAC3B,EAAe,KAAK,KAAK;;AAG7B,QAAO,iBAAiB,GAA8B,EAAoB;CAE1E,IAAM,IAAa,QAAwB,GAAO,EAAe,EAE3D,UAAyB;AAC3B,KAAgB;;AAGpB,CAAI,SAAS,eAAe,aACxB,GAAkB,GAElB,OAAO,iBAAiB,QAAQ,GAAkB,EAAC,MAAM,IAAK,CAAC;CAGnE,IAAM,IAAiC;EACnC,QAAQ;EACR,eAAe;AAMX,GALA,EAAS,YAAY,EACrB,GAAY,EACZ,GAAmB,EACnB,OAAO,oBAAoB,QAAQ,EAAiB,EACpD,OAAO,oBAAoB,GAA8B,EAAoB,EACzE,OAAO,kCAAkC,KACzC,OAAO,OAAO;;EAGtB,gBAAgB;EAChB;EACH;AAGD,QADA,OAAO,gCAAgC,GAChC;;AAGX,SAAgB,IAA8B;AAK1C,QAJI,OAAO,SAAW,OAAe,OAAO,WAAa,MAC9C,OAGJ,EAAwB,GAA4B,CAAC"}
1
+ {"version":3,"file":"MCookieBootstrap-BbpXuRtS.js","names":[],"sources":["../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.defaults.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.inventory.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.storage.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.types.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.ts"],"sourcesContent":["import type {MCookieConsentTexts} from '../../../../i18n/frameworkTexts'\nimport type {MCookieCategoryDefinition, MCookieConsentPersistence, MCookieDeclarationItem} from './MCookieConsent.types'\n\nexport const COOKIE_CONSENT_STORAGE_KEY = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_NAME = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_MAX_AGE_DAYS = 180\nexport const COOKIE_CONSENT_STORAGE: MCookieConsentPersistence = 'localStorage'\n\nexport function mergeCookieConsentTexts(\n baseTexts: MCookieConsentTexts,\n override?: Partial<MCookieConsentTexts>\n): MCookieConsentTexts {\n return {\n ...baseTexts,\n ...override,\n }\n}\n\nexport function createCookieConsentCategories(texts: MCookieConsentTexts): MCookieCategoryDefinition[] {\n return [\n {\n key: 'necessary',\n label: texts.necessaryLabel,\n description: texts.necessaryDescription,\n required: true,\n defaultValue: true,\n },\n {\n key: 'preferences',\n label: texts.preferencesLabel,\n description: texts.preferencesDescriptionLabel,\n defaultValue: false,\n },\n {\n key: 'analytics',\n label: texts.analyticsLabel,\n description: texts.analyticsDescription,\n defaultValue: false,\n },\n {\n key: 'marketing',\n label: texts.marketingLabel,\n description: texts.marketingDescription,\n defaultValue: false,\n },\n ]\n}\n\nexport function createCookieConsentDeclaration(): MCookieDeclarationItem[] {\n return []\n}\n","import {COOKIE_CONSENT_COOKIE_NAME} from './MCookieConsent.defaults'\nimport type {\n MCookieCategoryRules,\n MCookieDetectedCookie,\n MCookieDetectedCookieMatch,\n MCookieMatchRule,\n} from './MCookieConsent.types'\n\nconst INTERNAL_REQUIRED_COOKIE_RULES: MCookieMatchRule[] = [\n COOKIE_CONSENT_COOKIE_NAME,\n /^PHPSESSID$/i,\n /^JSESSIONID$/i,\n /^ASP\\.NET_SessionId$/i,\n /^__Host-/i,\n /^__Secure-/i,\n /csrf/i,\n /xsrf/i,\n /session/i,\n /auth/i,\n /token/i,\n /^sid$/i,\n]\n\nconst BUILT_IN_CATEGORY_RULES: Record<string, MCookieMatchRule[]> = {\n preferences: [/theme/i, /locale/i, /lang/i, /currency/i, /timezone/i, /consent/i],\n analytics: [/^_ga/i, /^_gid/i, /^_gat/i, /^_pk_/i, /^pk_/i, /^_hj/i, /^hj/i, /^amplitude/i, /^mp_/i, /^matomo/i],\n marketing: [/^_fbp$/i, /^_fbc$/i, /^_gcl_/i, /^IDE$/i, /^test_cookie$/i, /^li_/i, /^tt_/i, /^_uet/i, /^pin_utm/i],\n}\n\nfunction matchCookieRule(name: string, rule: MCookieMatchRule) {\n if (typeof rule === 'string') {\n const normalizedRule = rule.trim().toLowerCase()\n const normalizedName = name.trim().toLowerCase()\n\n if (normalizedRule.endsWith('*')) {\n return normalizedName.startsWith(normalizedRule.slice(0, -1))\n }\n\n return normalizedName === normalizedRule\n }\n\n return rule.test(name)\n}\n\nfunction matchCookieRules(name: string, rules?: MCookieMatchRule[]) {\n return Array.isArray(rules) && rules.some((rule) => matchCookieRule(name, rule))\n}\n\nfunction parseDocumentCookies(cookieString: string) {\n if (!cookieString.trim()) {\n return []\n }\n\n return cookieString\n .split(';')\n .map((chunk) => chunk.trim())\n .filter(Boolean)\n .map((chunk) => {\n const separatorIndex = chunk.indexOf('=')\n if (separatorIndex === -1) {\n return {\n name: chunk,\n value: '',\n }\n }\n\n return {\n name: chunk.slice(0, separatorIndex).trim(),\n value: chunk.slice(separatorIndex + 1).trim(),\n }\n })\n .filter((item) => item.name.length > 0)\n}\n\nfunction classifyCookie(\n name: string,\n requiredCookies: MCookieMatchRule[],\n categoryRules: MCookieCategoryRules\n): Pick<MCookieDetectedCookie, 'category' | 'required' | 'matchedBy'> {\n if (matchCookieRules(name, [...INTERNAL_REQUIRED_COOKIE_RULES, ...requiredCookies])) {\n return {\n category: 'necessary',\n required: true,\n matchedBy: 'required',\n }\n }\n\n for (const [category, rules] of Object.entries(categoryRules)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'custom',\n }\n }\n }\n\n for (const [category, rules] of Object.entries(BUILT_IN_CATEGORY_RULES)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'built-in',\n }\n }\n }\n\n return {\n category: 'preferences',\n required: false,\n matchedBy: 'fallback',\n }\n}\n\nexport function detectDocumentCookies({\n cookieString,\n requiredCookies = [],\n categoryRules = {},\n}: {\n cookieString?: string\n requiredCookies?: MCookieMatchRule[]\n categoryRules?: MCookieCategoryRules\n}) {\n const source = cookieString ?? (typeof document !== 'undefined' ? document.cookie : '')\n\n return parseDocumentCookies(source).map<MCookieDetectedCookie>((item) => {\n const classification = classifyCookie(item.name, requiredCookies, categoryRules)\n\n return {\n name: item.name,\n value: item.value,\n category: classification.category,\n required: classification.required,\n matchedBy: classification.matchedBy as MCookieDetectedCookieMatch,\n source: 'document.cookie',\n }\n })\n}\n","import type {MCookieConsentPersistence, MCookieConsentState} from './MCookieConsent.types'\n\ninterface CookieConsentStorageOptions {\n storage: MCookieConsentPersistence\n storageKey: string\n cookieName: string\n cookieMaxAgeDays: number\n}\n\nfunction isCookieConsentState(value: unknown): value is MCookieConsentState {\n if (!value || typeof value !== 'object') {\n return false\n }\n\n const candidate = value as MCookieConsentState\n\n return (\n typeof candidate.version === 'string' &&\n typeof candidate.decidedAt === 'string' &&\n typeof candidate.source === 'string' &&\n candidate.categories != null &&\n typeof candidate.categories === 'object'\n )\n}\n\nfunction readCookieValue(name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const prefix = `${encodeURIComponent(name)}=`\n\n for (const chunk of document.cookie.split(';')) {\n const trimmed = chunk.trim()\n if (trimmed.startsWith(prefix)) {\n return decodeURIComponent(trimmed.slice(prefix.length))\n }\n }\n\n return null\n}\n\nfunction writeCookieValue(name: string, value: string, maxAgeDays: number) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; path=/; max-age=${Math.floor(\n maxAgeDays * 24 * 60 * 60\n )}; samesite=lax`\n}\n\nfunction clearCookieValue(name: string) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=; path=/; max-age=0; samesite=lax`\n}\n\nexport function readStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>): MCookieConsentState | null {\n try {\n const raw = storage === 'cookie' ? readCookieValue(cookieName) : localStorage.getItem(storageKey)\n if (!raw) {\n return null\n }\n\n const parsed = JSON.parse(raw) as unknown\n return isCookieConsentState(parsed) ? parsed : null\n } catch {\n return null\n }\n}\n\nexport function writeStoredCookieConsent(\n {storage, storageKey, cookieName, cookieMaxAgeDays}: CookieConsentStorageOptions,\n state: MCookieConsentState\n) {\n try {\n const serialized = JSON.stringify(state)\n\n if (storage === 'cookie') {\n writeCookieValue(cookieName, serialized, cookieMaxAgeDays)\n return\n }\n\n localStorage.setItem(storageKey, serialized)\n } catch {\n /* noop */\n }\n}\n\nexport function clearStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>) {\n try {\n if (storage === 'cookie') {\n clearCookieValue(cookieName)\n return\n }\n\n localStorage.removeItem(storageKey)\n } catch {\n /* noop */\n }\n}\n","import type {\n MCookieCategoryDefinition,\n MCookieConsentPersistence,\n MCookieConsentState,\n MCookieDeclarationItem,\n} from '../MCookieConsentProvider'\n\nexport const MCOOKIE_CONSENT_CHANGE_EVENT = 'mineralui:cookie-consent-change'\nexport const MCOOKIE_BOOTSTRAP_CONFIG_KEY = '__MINERAL_COOKIE_CONFIG__'\nexport const MCOOKIE_RUNTIME_KEY = '__MINERAL_COOKIE_RUNTIME__'\nexport const MCOOKIE_RUNTIME_READY_EVENT = 'mineralui:cookie-runtime-ready'\n\nexport type MCookieBootstrapResourceKind = 'script' | 'iframe' | 'image'\n\nexport interface MCookieBootstrapResourceRules {\n scripts?: Record<string, string[]>\n iframes?: Record<string, string[]>\n images?: Record<string, string[]>\n}\n\nexport interface MCookieBootstrapScanOptions {\n cookies?: boolean\n storage?: boolean\n scripts?: boolean\n iframes?: boolean\n images?: boolean\n}\n\nexport interface MCookieBootstrapConfig {\n siteKey?: string\n domain?: string\n version?: string\n storage?: MCookieConsentPersistence\n storageKey?: string\n cookieName?: string\n cookieMaxAgeDays?: number\n categories?: MCookieCategoryDefinition[]\n hideOnAccept?: boolean\n autoShow?: boolean\n reopenOnVersionChange?: boolean\n requiredCookies?: string[]\n categoryRules?: Record<string, string[]>\n resources?: MCookieBootstrapResourceRules\n scan?: MCookieBootstrapScanOptions\n configEndpoint?: string\n scanEndpoint?: string\n reportEndpoint?: string\n reportMethod?: 'POST' | 'PUT'\n reportHeaders?: Record<string, string>\n}\n\nexport interface MCookieRuntime {\n config: MCookieBootstrapConfig\n getDeclaration?: () => Promise<MCookieDeclarationItem[]>\n getConsent?: () => Promise<MCookieConsentState | null>\n saveConsent?: (state: MCookieConsentState) => void | Promise<void>\n}\n\nexport interface MCookieBootstrapChangeDetail {\n state: MCookieConsentState | null\n}\n\nexport interface MCookieScanStorageItem {\n kind: 'localStorage' | 'sessionStorage'\n key: string\n value: string\n}\n\nexport interface MCookieScanResourceItem {\n kind: MCookieBootstrapResourceKind\n src: string\n host: string\n category?: string\n}\n\nexport interface MCookieScanCookieItem {\n name: string\n value: string\n category: string\n required: boolean\n matchedBy: string\n source: string\n}\n\nexport interface MCookieScanReport {\n siteKey?: string\n domain: string\n url: string\n scannedAt: string\n cookies: MCookieScanCookieItem[]\n storage: MCookieScanStorageItem[]\n resources: MCookieScanResourceItem[]\n}\n\nexport interface MCookieBootstrapHandle {\n config: MCookieBootstrapConfig\n destroy: () => void\n getState: () => MCookieConsentState | null\n sync: (state?: MCookieConsentState | null) => void\n}\n\ndeclare global {\n interface Window {\n __MINERAL_COOKIE_CONFIG__?: MCookieBootstrapConfig\n __MINERAL_COOKIE_RUNTIME__?: MCookieRuntime\n MineralCookieConsentBootstrap?: MCookieBootstrapHandle\n }\n}\n","import {detectDocumentCookies} from '../MCookieConsentProvider/MCookieConsent.inventory'\nimport {\n COOKIE_CONSENT_COOKIE_NAME,\n COOKIE_CONSENT_STORAGE,\n COOKIE_CONSENT_STORAGE_KEY,\n} from '../MCookieConsentProvider/MCookieConsent.defaults'\nimport {readStoredCookieConsent} from '../MCookieConsentProvider/MCookieConsent.storage'\nimport type {MCookieConsentState} from '../MCookieConsentProvider'\nimport {MCOOKIE_BOOTSTRAP_CONFIG_KEY, MCOOKIE_CONSENT_CHANGE_EVENT} from './MCookieBootstrap.types'\nimport type {\n MCookieBootstrapConfig,\n MCookieBootstrapHandle,\n MCookieBootstrapResourceKind,\n MCookieScanReport,\n MCookieScanResourceItem,\n MCookieScanStorageItem,\n} from './MCookieBootstrap.types'\n\nconst CATEGORY_ATTRIBUTE = 'data-mineral-cookie-category'\nconst BLOCKED_ATTRIBUTE = 'data-mineral-cookie-blocked'\nconst SRC_ATTRIBUTE = 'data-mineral-cookie-src'\nconst TYPE_ATTRIBUTE = 'data-mineral-cookie-type'\n\nfunction toPatternRegExp(pattern: string) {\n const escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '.*')\n return new RegExp(`^${escaped}$`, 'i')\n}\n\nfunction matchesPattern(value: string, pattern: string) {\n return toPatternRegExp(pattern).test(value)\n}\n\nfunction getElementSource(node: Element) {\n if (node instanceof HTMLScriptElement || node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n return node.getAttribute('src') ?? node.getAttribute(SRC_ATTRIBUTE) ?? ''\n }\n\n return ''\n}\n\nfunction getSourceHost(src: string) {\n try {\n return new URL(src, window.location.href).hostname\n } catch {\n return ''\n }\n}\n\nfunction getConsentState(config: MCookieBootstrapConfig) {\n return readStoredCookieConsent({\n storage: config.storage ?? COOKIE_CONSENT_STORAGE,\n storageKey: config.storageKey ?? COOKIE_CONSENT_STORAGE_KEY,\n cookieName: config.cookieName ?? COOKIE_CONSENT_COOKIE_NAME,\n })\n}\n\nfunction isCategoryAllowed(state: MCookieConsentState | null, category: string) {\n if (category === 'necessary') {\n return true\n }\n\n return state?.categories?.[category] === true\n}\n\nfunction findMatchedCategory(node: Element, config: MCookieBootstrapConfig) {\n const explicitCategory = node.getAttribute(CATEGORY_ATTRIBUTE)\n if (explicitCategory) {\n return explicitCategory\n }\n\n const src = getElementSource(node)\n if (!src) {\n return null\n }\n\n const host = getSourceHost(src)\n if (!host) {\n return null\n }\n\n const kind: MCookieBootstrapResourceKind | null =\n node instanceof HTMLScriptElement\n ? 'script'\n : node instanceof HTMLIFrameElement\n ? 'iframe'\n : node instanceof HTMLImageElement\n ? 'image'\n : null\n\n if (!kind) {\n return null\n }\n\n const rules =\n kind === 'script'\n ? config.resources?.scripts\n : kind === 'iframe'\n ? config.resources?.iframes\n : config.resources?.images\n\n if (!rules) {\n return null\n }\n\n for (const [category, patterns] of Object.entries(rules)) {\n if (patterns.some((pattern) => matchesPattern(host, pattern) || matchesPattern(src, pattern))) {\n node.setAttribute(CATEGORY_ATTRIBUTE, category)\n return category\n }\n }\n\n return null\n}\n\nfunction blockNode(node: Element) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) === 'true') {\n return\n }\n\n if (node instanceof HTMLScriptElement) {\n const currentType = node.getAttribute('type') ?? ''\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(TYPE_ATTRIBUTE, currentType === 'text/plain' ? '' : currentType)\n node.type = 'text/plain'\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n }\n}\n\nfunction activateScript(node: HTMLScriptElement) {\n const src = node.getAttribute(SRC_ATTRIBUTE)\n const clone = document.createElement('script')\n\n for (const attribute of node.getAttributeNames()) {\n if (\n attribute === 'type' ||\n attribute === BLOCKED_ATTRIBUTE ||\n attribute === SRC_ATTRIBUTE ||\n attribute === TYPE_ATTRIBUTE\n ) {\n continue\n }\n\n clone.setAttribute(attribute, node.getAttribute(attribute) ?? '')\n }\n\n const originalType = node.getAttribute(TYPE_ATTRIBUTE)\n if (originalType) {\n clone.type = originalType\n }\n\n if (src) {\n clone.src = src\n } else {\n clone.textContent = node.textContent\n }\n\n node.replaceWith(clone)\n}\n\nfunction activateNode(node: Element) {\n if (node instanceof HTMLScriptElement) {\n const canActivate =\n node.getAttribute(BLOCKED_ATTRIBUTE) === 'true' ||\n (node.type === 'text/plain' && node.hasAttribute(CATEGORY_ATTRIBUTE))\n\n if (!canActivate) {\n return\n }\n\n activateScript(node)\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) !== 'true' && !node.hasAttribute(SRC_ATTRIBUTE)) {\n return\n }\n\n const src = node.getAttribute(SRC_ATTRIBUTE)\n if (src) {\n node.setAttribute('src', src)\n }\n\n node.removeAttribute(SRC_ATTRIBUTE)\n node.removeAttribute(BLOCKED_ATTRIBUTE)\n }\n}\n\nfunction collectCandidateNodes(root: ParentNode) {\n const directNodes: Element[] = []\n\n if (root instanceof Element) {\n directNodes.push(root)\n }\n\n const nestedNodes = Array.from(root.querySelectorAll('script, iframe, img'))\n return [...directNodes, ...nestedNodes]\n}\n\nfunction syncNode(node: Element, state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const category = findMatchedCategory(node, config)\n if (!category) {\n return\n }\n\n if (isCategoryAllowed(state, category)) {\n activateNode(node)\n return\n }\n\n blockNode(node)\n}\n\nfunction syncDocument(state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n for (const node of collectCandidateNodes(document)) {\n syncNode(node, state, config)\n }\n}\n\nfunction patchDomInsertion(getState: () => MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const appendChild = Node.prototype.appendChild\n const insertBefore = Node.prototype.insertBefore\n const replaceChild = Node.prototype.replaceChild\n\n Node.prototype.appendChild = function patchedAppendChild<T extends Node>(node: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return appendChild.call(this, node) as T\n }\n\n Node.prototype.insertBefore = function patchedInsertBefore<T extends Node>(node: T, child: Node | null) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return insertBefore.call(this, node, child) as T\n }\n\n Node.prototype.replaceChild = function patchedReplaceChild<T extends Node>(node: Node, child: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return replaceChild.call(this, node, child) as T\n }\n\n return () => {\n Node.prototype.appendChild = appendChild\n Node.prototype.insertBefore = insertBefore\n Node.prototype.replaceChild = replaceChild\n }\n}\n\nfunction scanStorage(storage: Storage, kind: 'localStorage' | 'sessionStorage') {\n const items: MCookieScanStorageItem[] = []\n\n try {\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index)\n if (!key) {\n continue\n }\n\n items.push({\n kind,\n key,\n value: storage.getItem(key) ?? '',\n })\n }\n } catch {\n return []\n }\n\n return items\n}\n\nexport function readMCookieBootstrapConfig(config?: MCookieBootstrapConfig | null) {\n if (config) {\n return config\n }\n\n if (typeof window === 'undefined') {\n return null\n }\n\n return window[MCOOKIE_BOOTSTRAP_CONFIG_KEY] ?? null\n}\n\nexport function scanMCookieSurface(config?: MCookieBootstrapConfig | null): MCookieScanReport | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n const scan = resolvedConfig.scan ?? {}\n const storageItems: MCookieScanStorageItem[] = []\n const resources: MCookieScanResourceItem[] = []\n\n if (scan.storage !== false) {\n storageItems.push(...scanStorage(window.localStorage, 'localStorage'))\n storageItems.push(...scanStorage(window.sessionStorage, 'sessionStorage'))\n }\n\n const resourceSelectors: Array<[boolean, string, MCookieBootstrapResourceKind]> = [\n [scan.scripts !== false, 'script[src], script[data-mineral-cookie-src]', 'script'],\n [scan.iframes !== false, 'iframe[src], iframe[data-mineral-cookie-src]', 'iframe'],\n [scan.images !== false, 'img[src], img[data-mineral-cookie-src]', 'image'],\n ]\n\n for (const [enabled, selector, kind] of resourceSelectors) {\n if (!enabled) {\n continue\n }\n\n for (const node of Array.from(document.querySelectorAll(selector))) {\n const src = getElementSource(node)\n if (!src) {\n continue\n }\n\n resources.push({\n kind,\n src,\n host: getSourceHost(src),\n category: node.getAttribute(CATEGORY_ATTRIBUTE) ?? undefined,\n })\n }\n }\n\n return {\n siteKey: resolvedConfig.siteKey,\n domain: resolvedConfig.domain ?? window.location.hostname,\n url: window.location.href,\n scannedAt: new Date().toISOString(),\n cookies:\n scan.cookies === false\n ? []\n : detectDocumentCookies({\n requiredCookies: resolvedConfig.requiredCookies ?? [],\n categoryRules: resolvedConfig.categoryRules ?? {},\n }).map((item) => ({\n ...item,\n matchedBy: item.matchedBy,\n source: item.source,\n })),\n storage: storageItems,\n resources,\n }\n}\n\nexport async function reportMCookieSurface(config?: MCookieBootstrapConfig | null, report?: MCookieScanReport | null) {\n const resolvedConfig = readMCookieBootstrapConfig(config)\n const endpoint = resolvedConfig?.scanEndpoint ?? resolvedConfig?.reportEndpoint\n\n if (!endpoint || typeof fetch === 'undefined') {\n return report ?? null\n }\n\n if (!resolvedConfig) {\n return report ?? null\n }\n\n const payload = report ?? scanMCookieSurface(resolvedConfig)\n if (!payload) {\n return null\n }\n\n await fetch(endpoint, {\n method: resolvedConfig.reportMethod ?? 'POST',\n headers: {\n 'content-type': 'application/json',\n ...(resolvedConfig.siteKey ? {'x-mineral-site-key': resolvedConfig.siteKey} : {}),\n ...resolvedConfig.reportHeaders,\n },\n body: JSON.stringify(payload),\n })\n\n return payload\n}\n\nexport function bootstrapMCookieConsent(config?: MCookieBootstrapConfig | null): MCookieBootstrapHandle | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n let state = getConsentState(resolvedConfig)\n let reportTimer: number | null = null\n let followUpReportTimer: number | null = null\n\n const clearReportTimers = () => {\n if (reportTimer != null) {\n window.clearTimeout(reportTimer)\n reportTimer = null\n }\n\n if (followUpReportTimer != null) {\n window.clearTimeout(followUpReportTimer)\n followUpReportTimer = null\n }\n }\n\n const scheduleReport = (primaryDelay = 0, followUpDelay?: number) => {\n if (!resolvedConfig.scanEndpoint && !resolvedConfig.reportEndpoint) {\n return\n }\n\n clearReportTimers()\n\n reportTimer = window.setTimeout(() => {\n reportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, primaryDelay)\n\n if (typeof followUpDelay === 'number') {\n followUpReportTimer = window.setTimeout(() => {\n followUpReportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, followUpDelay)\n }\n }\n\n const sync = (nextState?: MCookieConsentState | null) => {\n state = nextState === undefined ? getConsentState(resolvedConfig) : nextState\n syncDocument(state, resolvedConfig)\n }\n\n sync(state)\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of Array.from(record.addedNodes)) {\n if (!(node instanceof Element)) {\n continue\n }\n\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, state, resolvedConfig)\n }\n }\n }\n })\n\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n })\n\n const handleConsentChange = (event: Event) => {\n const detail = (event as CustomEvent<{state: MCookieConsentState | null}>).detail\n sync(detail?.state ?? null)\n scheduleReport(300, 1500)\n }\n\n window.addEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n\n const restoreDom = patchDomInsertion(() => state, resolvedConfig)\n\n const handleWindowLoad = () => {\n scheduleReport()\n }\n\n if (document.readyState === 'complete') {\n handleWindowLoad()\n } else {\n window.addEventListener('load', handleWindowLoad, {once: true})\n }\n\n const handle: MCookieBootstrapHandle = {\n config: resolvedConfig,\n destroy: () => {\n observer.disconnect()\n restoreDom()\n clearReportTimers()\n window.removeEventListener('load', handleWindowLoad)\n window.removeEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n if (window.MineralCookieConsentBootstrap === handle) {\n delete window.MineralCookieConsentBootstrap\n }\n },\n getState: () => state,\n sync,\n }\n\n window.MineralCookieConsentBootstrap = handle\n return handle\n}\n\nexport function autoBootstrapMCookieConsent() {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n return bootstrapMCookieConsent(readMCookieBootstrapConfig())\n}\n"],"mappings":";AAGA,IAAa,IAA6B,4BAC7B,IAA6B,4BAE7B,IAAoD;AAEjE,SAAgB,EACZ,GACA,GACmB;AACnB,QAAO;EACH,GAAG;EACH,GAAG;EACN;;AAGL,SAAgB,EAA8B,GAAyD;AACnG,QAAO;EACH;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,UAAU;GACV,cAAc;GACjB;EACD;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,cAAc;GACjB;EACD;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,cAAc;GACjB;EACD;GACI,KAAK;GACL,OAAO,EAAM;GACb,aAAa,EAAM;GACnB,cAAc;GACjB;EACJ;;AAGL,SAAgB,IAA2D;AACvE,QAAO,EAAE;;;;ACzCb,IAAM,IAAqD;CACvD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACH,EAEK,IAA8D;CAChE,aAAa;EAAC;EAAU;EAAW;EAAS;EAAa;EAA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Y;AAC/C,OAAK,IAAM,KAAU,EACjB,MAAK,IAAM,KAAQ,MAAM,KAAK,EAAO,WAAW,CACtC,kBAAgB,QAItB,MAAK,IAAM,KAAW,EAAsB,EAAK,CAC7C,GAAS,GAAS,GAAO,EAAe;GAItD;AAEF,GAAS,QAAQ,SAAS,iBAAiB;EACvC,WAAW;EACX,SAAS;EACZ,CAAC;CAEF,IAAM,KAAuB,MAAiB;EAC1C,IAAM,IAAU,EAA2D;AAE3E,EADA,EAAK,GAAQ,SAAS,KAAK,EAC3B,EAAe,KAAK,KAAK;;AAG7B,QAAO,iBAAiB,GAA8B,EAAoB;CAE1E,IAAM,IAAa,QAAwB,GAAO,EAAe,EAE3D,UAAyB;AAC3B,KAAgB;;AAGpB,CAAI,SAAS,eAAe,aACxB,GAAkB,GAElB,OAAO,iBAAiB,QAAQ,GAAkB,EAAC,MAAM,IAAK,CAAC;CAGnE,IAAM,IAAiC;EACnC,QAAQ;EACR,eAAe;AAMX,GALA,EAAS,YAAY,EACrB,GAAY,EACZ,GAAmB,EACnB,OAAO,oBAAoB,QAAQ,EAAiB,EACpD,OAAO,oBAAoB,GAA8B,EAAoB,EACzE,OAAO,kCAAkC,KACzC,OAAO,OAAO;;EAGtB,gBAAgB;EAChB;EACH;AAGD,QADA,OAAO,gCAAgC,GAChC;;AAGX,SAAgB,IAA8B;AAK1C,QAJI,OAAO,SAAW,OAAe,OAAO,WAAa,MAC9C,OAGJ,EAAwB,GAA4B,CAAC"}
@@ -1,2 +1,2 @@
1
- var e=`mineralui-cookie-consent`,t=`mineralui-cookie-consent`,n=`localStorage`;function r(e,t){return{...e,...t}}function i(e){return[{key:`necessary`,label:e.necessaryLabel,description:e.necessaryDescription,required:!0,defaultValue:!0},{key:`preferences`,label:e.preferencesLabel,description:e.preferencesDescriptionLabel,defaultValue:!1},{key:`analytics`,label:e.analyticsLabel,description:e.analyticsDescription,defaultValue:!1},{key:`marketing`,label:e.marketingLabel,description:e.marketingDescription,defaultValue:!1}]}function a(){return[]}var o=[t,/^PHPSESSID$/i,/^JSESSIONID$/i,/^ASP\.NET_SessionId$/i,/^__Host-/i,/^__Secure-/i,/csrf/i,/xsrf/i,/session/i,/auth/i,/token/i,/^sid$/i],s={preferences:[/theme/i,/locale/i,/lang/i,/currency/i,/timezone/i,/consent/i],analytics:[/^_ga/i,/^_gid/i,/^_gat/i,/^_pk_/i,/^pk_/i,/^_hj/i,/^hj/i,/^amplitude/i,/^mp_/i,/^matomo/i],marketing:[/^_fbp$/i,/^_fbc$/i,/^_gcl_/i,/^IDE$/i,/^test_cookie$/i,/^li_/i,/^tt_/i,/^_uet/i,/^pin_utm/i]};function c(e,t){if(typeof t==`string`){let n=t.trim().toLowerCase(),r=e.trim().toLowerCase();return n.endsWith(`*`)?r.startsWith(n.slice(0,-1)):r===n}return t.test(e)}function l(e,t){return Array.isArray(t)&&t.some(t=>c(e,t))}function u(e){return e.trim()?e.split(`;`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf(`=`);return t===-1?{name:e,value:``}:{name:e.slice(0,t).trim(),value:e.slice(t+1).trim()}}).filter(e=>e.name.length>0):[]}function d(e,t,n){if(l(e,[...o,...t]))return{category:`necessary`,required:!0,matchedBy:`required`};for(let[t,r]of Object.entries(n))if(l(e,r))return{category:t,required:!1,matchedBy:`custom`};for(let[t,n]of Object.entries(s))if(l(e,n))return{category:t,required:!1,matchedBy:`built-in`};return{category:`preferences`,required:!1,matchedBy:`fallback`}}function f({cookieString:e,requiredCookies:t=[],categoryRules:n={}}){return u(e??(typeof document<`u`?document.cookie:``)).map(e=>{let r=d(e.name,t,n);return{name:e.name,value:e.value,category:r.category,required:r.required,matchedBy:r.matchedBy,source:`document.cookie`}})}function p(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.version==`string`&&typeof t.decidedAt==`string`&&typeof t.source==`string`&&t.categories!=null&&typeof t.categories==`object`}function m(e){if(typeof document>`u`)return null;let t=`${encodeURIComponent(e)}=`;for(let e of document.cookie.split(`;`)){let n=e.trim();if(n.startsWith(t))return decodeURIComponent(n.slice(t.length))}return null}function h(e,t,n){typeof document>`u`||(document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/; max-age=${Math.floor(n*24*60*60)}; samesite=lax`)}function g(e){typeof document>`u`||(document.cookie=`${encodeURIComponent(e)}=; path=/; max-age=0; samesite=lax`)}function _({storage:e,storageKey:t,cookieName:n}){try{let r=e===`cookie`?m(n):localStorage.getItem(t);if(!r)return null;let i=JSON.parse(r);return p(i)?i:null}catch{return null}}function v({storage:e,storageKey:t,cookieName:n,cookieMaxAgeDays:r},i){try{let a=JSON.stringify(i);if(e===`cookie`){h(n,a,r);return}localStorage.setItem(t,a)}catch{}}function y({storage:e,storageKey:t,cookieName:n}){try{if(e===`cookie`){g(n);return}localStorage.removeItem(t)}catch{}}var b=`mineralui:cookie-consent-change`,x=`__MINERAL_COOKIE_CONFIG__`,S=`__MINERAL_COOKIE_RUNTIME__`,C=`mineralui:cookie-runtime-ready`,w=`data-mineral-cookie-category`,T=`data-mineral-cookie-blocked`,E=`data-mineral-cookie-src`,D=`data-mineral-cookie-type`;function O(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`.*`);return RegExp(`^${t}$`,`i`)}function k(e,t){return O(t).test(e)}function A(e){return e instanceof HTMLScriptElement||e instanceof HTMLIFrameElement||e instanceof HTMLImageElement?e.getAttribute(`src`)??e.getAttribute(E)??``:``}function j(e){try{return new URL(e,window.location.href).hostname}catch{return``}}function M(e){return _({storage:e.storage??`localStorage`,storageKey:e.storageKey??`mineralui-cookie-consent`,cookieName:e.cookieName??`mineralui-cookie-consent`})}function N(e,t){return t===`necessary`?!0:e?.categories?.[t]===!0}function P(e,t){let n=e.getAttribute(w);if(n)return n;let r=A(e);if(!r)return null;let i=j(r);if(!i)return null;let a=e instanceof HTMLScriptElement?`script`:e instanceof HTMLIFrameElement?`iframe`:e instanceof HTMLImageElement?`image`:null;if(!a)return null;let o=a===`script`?t.resources?.scripts:a===`iframe`?t.resources?.iframes:t.resources?.images;if(!o)return null;for(let[t,n]of Object.entries(o))if(n.some(e=>k(i,e)||k(r,e)))return e.setAttribute(w,t),t;return null}function F(e){if(e.getAttribute(T)!==`true`){if(e instanceof HTMLScriptElement){let t=e.getAttribute(`type`)??``,n=e.getAttribute(`src`);n&&(e.setAttribute(E,n),e.removeAttribute(`src`)),e.setAttribute(D,t===`text/plain`?``:t),e.type=`text/plain`,e.setAttribute(T,`true`);return}if(e instanceof HTMLIFrameElement||e instanceof HTMLImageElement){let t=e.getAttribute(`src`);t&&(e.setAttribute(E,t),e.removeAttribute(`src`)),e.setAttribute(T,`true`)}}}function I(e){let t=e.getAttribute(E),n=document.createElement(`script`);for(let t of e.getAttributeNames())t===`type`||t===T||t===E||t===D||n.setAttribute(t,e.getAttribute(t)??``);let r=e.getAttribute(D);r&&(n.type=r),t?n.src=t:n.textContent=e.textContent,e.replaceWith(n)}function L(e){if(e instanceof HTMLScriptElement){if(!(e.getAttribute(T)===`true`||e.type===`text/plain`&&e.hasAttribute(w)))return;I(e);return}if(e instanceof HTMLIFrameElement||e instanceof HTMLImageElement){if(e.getAttribute(T)!==`true`&&!e.hasAttribute(E))return;let t=e.getAttribute(E);t&&e.setAttribute(`src`,t),e.removeAttribute(E),e.removeAttribute(T)}}function R(e){let t=[];e instanceof Element&&t.push(e);let n=Array.from(e.querySelectorAll(`script, iframe, img`));return[...t,...n]}function z(e,t,n){let r=P(e,n);if(r){if(N(t,r)){L(e);return}F(e)}}function B(e,t){for(let n of R(document))z(n,e,t)}function V(e,t){let n=Node.prototype.appendChild,r=Node.prototype.insertBefore,i=Node.prototype.replaceChild;return Node.prototype.appendChild=function(r){if(r instanceof Element)for(let n of R(r))z(n,e(),t);return n.call(this,r)},Node.prototype.insertBefore=function(n,i){if(n instanceof Element)for(let r of R(n))z(r,e(),t);return r.call(this,n,i)},Node.prototype.replaceChild=function(n,r){if(n instanceof Element)for(let r of R(n))z(r,e(),t);return i.call(this,n,r)},()=>{Node.prototype.appendChild=n,Node.prototype.insertBefore=r,Node.prototype.replaceChild=i}}function H(e,t){let n=[];try{for(let r=0;r<e.length;r+=1){let i=e.key(r);i&&n.push({kind:t,key:i,value:e.getItem(i)??``})}}catch{return[]}return n}function U(e){return e||(typeof window>`u`?null:window.__MINERAL_COOKIE_CONFIG__??null)}function W(e){if(typeof window>`u`||typeof document>`u`)return null;let t=U(e);if(!t)return null;let n=t.scan??{},r=[],i=[];n.storage!==!1&&(r.push(...H(window.localStorage,`localStorage`)),r.push(...H(window.sessionStorage,`sessionStorage`)));let a=[[n.scripts!==!1,`script[src], script[data-mineral-cookie-src]`,`script`],[n.iframes!==!1,`iframe[src], iframe[data-mineral-cookie-src]`,`iframe`],[n.images!==!1,`img[src], img[data-mineral-cookie-src]`,`image`]];for(let[e,t,n]of a)if(e)for(let e of Array.from(document.querySelectorAll(t))){let t=A(e);t&&i.push({kind:n,src:t,host:j(t),category:e.getAttribute(w)??void 0})}return{siteKey:t.siteKey,domain:t.domain??window.location.hostname,url:window.location.href,scannedAt:new Date().toISOString(),cookies:n.cookies===!1?[]:f({requiredCookies:t.requiredCookies??[],categoryRules:t.categoryRules??{}}).map(e=>({...e,matchedBy:e.matchedBy,source:e.source})),storage:r,resources:i}}async function G(e,t){let n=U(e),r=n?.scanEndpoint??n?.reportEndpoint;if(!r||typeof fetch>`u`)return t??W(n);if(!n)return t??null;let i=t??W(n);return i?(await fetch(r,{method:n.reportMethod??`POST`,headers:{"content-type":`application/json`,...n.siteKey?{"x-mineral-site-key":n.siteKey}:{},...n.reportHeaders},body:JSON.stringify(i)}),i):null}function K(e){if(typeof window>`u`||typeof document>`u`)return null;let t=U(e);if(!t)return null;let n=M(t),r=null,i=null,a=()=>{r!=null&&(window.clearTimeout(r),r=null),i!=null&&(window.clearTimeout(i),i=null)},o=(e=0,n)=>{a(),r=window.setTimeout(()=>{r=null,G(t)},e),typeof n==`number`&&(i=window.setTimeout(()=>{i=null,G(t)},n))},s=e=>{n=e===void 0?M(t):e,B(n,t)};s(n);let c=new MutationObserver(e=>{for(let r of e)for(let e of Array.from(r.addedNodes))if(e instanceof Element)for(let r of R(e))z(r,n,t)});c.observe(document.documentElement,{childList:!0,subtree:!0});let l=e=>{let t=e.detail;s(t?.state??null),o(300,1500)};window.addEventListener(b,l);let u=V(()=>n,t),d=()=>{o()};document.readyState===`complete`?d():window.addEventListener(`load`,d,{once:!0});let f={config:t,destroy:()=>{c.disconnect(),u(),a(),window.removeEventListener(`load`,d),window.removeEventListener(b,l),window.MineralCookieConsentBootstrap===f&&delete window.MineralCookieConsentBootstrap},getState:()=>n,sync:s};return window.MineralCookieConsentBootstrap=f,f}function q(){return typeof window>`u`||typeof document>`u`?null:K(U())}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return r}});
2
- //# sourceMappingURL=MCookieBootstrap-Ct5mIm5P.cjs.map
1
+ var e=`mineralui-cookie-consent`,t=`mineralui-cookie-consent`,n=`localStorage`;function r(e,t){return{...e,...t}}function i(e){return[{key:`necessary`,label:e.necessaryLabel,description:e.necessaryDescription,required:!0,defaultValue:!0},{key:`preferences`,label:e.preferencesLabel,description:e.preferencesDescriptionLabel,defaultValue:!1},{key:`analytics`,label:e.analyticsLabel,description:e.analyticsDescription,defaultValue:!1},{key:`marketing`,label:e.marketingLabel,description:e.marketingDescription,defaultValue:!1}]}function a(){return[]}var o=[t,/^PHPSESSID$/i,/^JSESSIONID$/i,/^ASP\.NET_SessionId$/i,/^__Host-/i,/^__Secure-/i,/csrf/i,/xsrf/i,/session/i,/auth/i,/token/i,/^sid$/i],s={preferences:[/theme/i,/locale/i,/lang/i,/currency/i,/timezone/i,/consent/i],analytics:[/^_ga/i,/^_gid/i,/^_gat/i,/^_pk_/i,/^pk_/i,/^_hj/i,/^hj/i,/^amplitude/i,/^mp_/i,/^matomo/i],marketing:[/^_fbp$/i,/^_fbc$/i,/^_gcl_/i,/^IDE$/i,/^test_cookie$/i,/^li_/i,/^tt_/i,/^_uet/i,/^pin_utm/i]};function c(e,t){if(typeof t==`string`){let n=t.trim().toLowerCase(),r=e.trim().toLowerCase();return n.endsWith(`*`)?r.startsWith(n.slice(0,-1)):r===n}return t.test(e)}function l(e,t){return Array.isArray(t)&&t.some(t=>c(e,t))}function u(e){return e.trim()?e.split(`;`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf(`=`);return t===-1?{name:e,value:``}:{name:e.slice(0,t).trim(),value:e.slice(t+1).trim()}}).filter(e=>e.name.length>0):[]}function d(e,t,n){if(l(e,[...o,...t]))return{category:`necessary`,required:!0,matchedBy:`required`};for(let[t,r]of Object.entries(n))if(l(e,r))return{category:t,required:!1,matchedBy:`custom`};for(let[t,n]of Object.entries(s))if(l(e,n))return{category:t,required:!1,matchedBy:`built-in`};return{category:`preferences`,required:!1,matchedBy:`fallback`}}function f({cookieString:e,requiredCookies:t=[],categoryRules:n={}}){return u(e??(typeof document<`u`?document.cookie:``)).map(e=>{let r=d(e.name,t,n);return{name:e.name,value:e.value,category:r.category,required:r.required,matchedBy:r.matchedBy,source:`document.cookie`}})}function p(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.version==`string`&&typeof t.decidedAt==`string`&&typeof t.source==`string`&&t.categories!=null&&typeof t.categories==`object`}function m(e){if(typeof document>`u`)return null;let t=`${encodeURIComponent(e)}=`;for(let e of document.cookie.split(`;`)){let n=e.trim();if(n.startsWith(t))return decodeURIComponent(n.slice(t.length))}return null}function h(e,t,n){typeof document>`u`||(document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/; max-age=${Math.floor(n*24*60*60)}; samesite=lax`)}function g(e){typeof document>`u`||(document.cookie=`${encodeURIComponent(e)}=; path=/; max-age=0; samesite=lax`)}function _({storage:e,storageKey:t,cookieName:n}){try{let r=e===`cookie`?m(n):localStorage.getItem(t);if(!r)return null;let i=JSON.parse(r);return p(i)?i:null}catch{return null}}function v({storage:e,storageKey:t,cookieName:n,cookieMaxAgeDays:r},i){try{let a=JSON.stringify(i);if(e===`cookie`){h(n,a,r);return}localStorage.setItem(t,a)}catch{}}function y({storage:e,storageKey:t,cookieName:n}){try{if(e===`cookie`){g(n);return}localStorage.removeItem(t)}catch{}}var b=`mineralui:cookie-consent-change`,x=`__MINERAL_COOKIE_CONFIG__`,S=`__MINERAL_COOKIE_RUNTIME__`,C=`mineralui:cookie-runtime-ready`,w=`data-mineral-cookie-category`,T=`data-mineral-cookie-blocked`,E=`data-mineral-cookie-src`,D=`data-mineral-cookie-type`;function O(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`.*`);return RegExp(`^${t}$`,`i`)}function k(e,t){return O(t).test(e)}function A(e){return e instanceof HTMLScriptElement||e instanceof HTMLIFrameElement||e instanceof HTMLImageElement?e.getAttribute(`src`)??e.getAttribute(E)??``:``}function j(e){try{return new URL(e,window.location.href).hostname}catch{return``}}function M(e){return _({storage:e.storage??`localStorage`,storageKey:e.storageKey??`mineralui-cookie-consent`,cookieName:e.cookieName??`mineralui-cookie-consent`})}function N(e,t){return t===`necessary`?!0:e?.categories?.[t]===!0}function P(e,t){let n=e.getAttribute(w);if(n)return n;let r=A(e);if(!r)return null;let i=j(r);if(!i)return null;let a=e instanceof HTMLScriptElement?`script`:e instanceof HTMLIFrameElement?`iframe`:e instanceof HTMLImageElement?`image`:null;if(!a)return null;let o=a===`script`?t.resources?.scripts:a===`iframe`?t.resources?.iframes:t.resources?.images;if(!o)return null;for(let[t,n]of Object.entries(o))if(n.some(e=>k(i,e)||k(r,e)))return e.setAttribute(w,t),t;return null}function F(e){if(e.getAttribute(T)!==`true`){if(e instanceof HTMLScriptElement){let t=e.getAttribute(`type`)??``,n=e.getAttribute(`src`);n&&(e.setAttribute(E,n),e.removeAttribute(`src`)),e.setAttribute(D,t===`text/plain`?``:t),e.type=`text/plain`,e.setAttribute(T,`true`);return}if(e instanceof HTMLIFrameElement||e instanceof HTMLImageElement){let t=e.getAttribute(`src`);t&&(e.setAttribute(E,t),e.removeAttribute(`src`)),e.setAttribute(T,`true`)}}}function I(e){let t=e.getAttribute(E),n=document.createElement(`script`);for(let t of e.getAttributeNames())t===`type`||t===T||t===E||t===D||n.setAttribute(t,e.getAttribute(t)??``);let r=e.getAttribute(D);r&&(n.type=r),t?n.src=t:n.textContent=e.textContent,e.replaceWith(n)}function L(e){if(e instanceof HTMLScriptElement){if(!(e.getAttribute(T)===`true`||e.type===`text/plain`&&e.hasAttribute(w)))return;I(e);return}if(e instanceof HTMLIFrameElement||e instanceof HTMLImageElement){if(e.getAttribute(T)!==`true`&&!e.hasAttribute(E))return;let t=e.getAttribute(E);t&&e.setAttribute(`src`,t),e.removeAttribute(E),e.removeAttribute(T)}}function R(e){let t=[];e instanceof Element&&t.push(e);let n=Array.from(e.querySelectorAll(`script, iframe, img`));return[...t,...n]}function z(e,t,n){let r=P(e,n);if(r){if(N(t,r)){L(e);return}F(e)}}function B(e,t){for(let n of R(document))z(n,e,t)}function V(e,t){let n=Node.prototype.appendChild,r=Node.prototype.insertBefore,i=Node.prototype.replaceChild;return Node.prototype.appendChild=function(r){if(r instanceof Element)for(let n of R(r))z(n,e(),t);return n.call(this,r)},Node.prototype.insertBefore=function(n,i){if(n instanceof Element)for(let r of R(n))z(r,e(),t);return r.call(this,n,i)},Node.prototype.replaceChild=function(n,r){if(n instanceof Element)for(let r of R(n))z(r,e(),t);return i.call(this,n,r)},()=>{Node.prototype.appendChild=n,Node.prototype.insertBefore=r,Node.prototype.replaceChild=i}}function H(e,t){let n=[];try{for(let r=0;r<e.length;r+=1){let i=e.key(r);i&&n.push({kind:t,key:i,value:e.getItem(i)??``})}}catch{return[]}return n}function U(e){return e||(typeof window>`u`?null:window.__MINERAL_COOKIE_CONFIG__??null)}function W(e){if(typeof window>`u`||typeof document>`u`)return null;let t=U(e);if(!t)return null;let n=t.scan??{},r=[],i=[];n.storage!==!1&&(r.push(...H(window.localStorage,`localStorage`)),r.push(...H(window.sessionStorage,`sessionStorage`)));let a=[[n.scripts!==!1,`script[src], script[data-mineral-cookie-src]`,`script`],[n.iframes!==!1,`iframe[src], iframe[data-mineral-cookie-src]`,`iframe`],[n.images!==!1,`img[src], img[data-mineral-cookie-src]`,`image`]];for(let[e,t,n]of a)if(e)for(let e of Array.from(document.querySelectorAll(t))){let t=A(e);t&&i.push({kind:n,src:t,host:j(t),category:e.getAttribute(w)??void 0})}return{siteKey:t.siteKey,domain:t.domain??window.location.hostname,url:window.location.href,scannedAt:new Date().toISOString(),cookies:n.cookies===!1?[]:f({requiredCookies:t.requiredCookies??[],categoryRules:t.categoryRules??{}}).map(e=>({...e,matchedBy:e.matchedBy,source:e.source})),storage:r,resources:i}}async function G(e,t){let n=U(e),r=n?.scanEndpoint??n?.reportEndpoint;if(!r||typeof fetch>`u`||!n)return t??null;let i=t??W(n);return i?(await fetch(r,{method:n.reportMethod??`POST`,headers:{"content-type":`application/json`,...n.siteKey?{"x-mineral-site-key":n.siteKey}:{},...n.reportHeaders},body:JSON.stringify(i)}),i):null}function K(e){if(typeof window>`u`||typeof document>`u`)return null;let t=U(e);if(!t)return null;let n=M(t),r=null,i=null,a=()=>{r!=null&&(window.clearTimeout(r),r=null),i!=null&&(window.clearTimeout(i),i=null)},o=(e=0,n)=>{!t.scanEndpoint&&!t.reportEndpoint||(a(),r=window.setTimeout(()=>{r=null,G(t)},e),typeof n==`number`&&(i=window.setTimeout(()=>{i=null,G(t)},n)))},s=e=>{n=e===void 0?M(t):e,B(n,t)};s(n);let c=new MutationObserver(e=>{for(let r of e)for(let e of Array.from(r.addedNodes))if(e instanceof Element)for(let r of R(e))z(r,n,t)});c.observe(document.documentElement,{childList:!0,subtree:!0});let l=e=>{let t=e.detail;s(t?.state??null),o(300,1500)};window.addEventListener(b,l);let u=V(()=>n,t),d=()=>{o()};document.readyState===`complete`?d():window.addEventListener(`load`,d,{once:!0});let f={config:t,destroy:()=>{c.disconnect(),u(),a(),window.removeEventListener(`load`,d),window.removeEventListener(b,l),window.MineralCookieConsentBootstrap===f&&delete window.MineralCookieConsentBootstrap},getState:()=>n,sync:s};return window.MineralCookieConsentBootstrap=f,f}function q(){return typeof window>`u`||typeof document>`u`?null:K(U())}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=MCookieBootstrap-Ck_8aUQK.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MCookieBootstrap-Ct5mIm5P.cjs","names":[],"sources":["../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.defaults.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.inventory.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.storage.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.types.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.ts"],"sourcesContent":["import type {MCookieConsentTexts} from '../../../../i18n/frameworkTexts'\nimport type {MCookieCategoryDefinition, MCookieConsentPersistence, MCookieDeclarationItem} from './MCookieConsent.types'\n\nexport const COOKIE_CONSENT_STORAGE_KEY = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_NAME = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_MAX_AGE_DAYS = 180\nexport const COOKIE_CONSENT_STORAGE: MCookieConsentPersistence = 'localStorage'\n\nexport function mergeCookieConsentTexts(\n baseTexts: MCookieConsentTexts,\n override?: Partial<MCookieConsentTexts>\n): MCookieConsentTexts {\n return {\n ...baseTexts,\n ...override,\n }\n}\n\nexport function createCookieConsentCategories(texts: MCookieConsentTexts): MCookieCategoryDefinition[] {\n return [\n {\n key: 'necessary',\n label: texts.necessaryLabel,\n description: texts.necessaryDescription,\n required: true,\n defaultValue: true,\n },\n {\n key: 'preferences',\n label: texts.preferencesLabel,\n description: texts.preferencesDescriptionLabel,\n defaultValue: false,\n },\n {\n key: 'analytics',\n label: texts.analyticsLabel,\n description: texts.analyticsDescription,\n defaultValue: false,\n },\n {\n key: 'marketing',\n label: texts.marketingLabel,\n description: texts.marketingDescription,\n defaultValue: false,\n },\n ]\n}\n\nexport function createCookieConsentDeclaration(): MCookieDeclarationItem[] {\n return []\n}\n","import {COOKIE_CONSENT_COOKIE_NAME} from './MCookieConsent.defaults'\nimport type {\n MCookieCategoryRules,\n MCookieDetectedCookie,\n MCookieDetectedCookieMatch,\n MCookieMatchRule,\n} from './MCookieConsent.types'\n\nconst INTERNAL_REQUIRED_COOKIE_RULES: MCookieMatchRule[] = [\n COOKIE_CONSENT_COOKIE_NAME,\n /^PHPSESSID$/i,\n /^JSESSIONID$/i,\n /^ASP\\.NET_SessionId$/i,\n /^__Host-/i,\n /^__Secure-/i,\n /csrf/i,\n /xsrf/i,\n /session/i,\n /auth/i,\n /token/i,\n /^sid$/i,\n]\n\nconst BUILT_IN_CATEGORY_RULES: Record<string, MCookieMatchRule[]> = {\n preferences: [/theme/i, /locale/i, /lang/i, /currency/i, /timezone/i, /consent/i],\n analytics: [/^_ga/i, /^_gid/i, /^_gat/i, /^_pk_/i, /^pk_/i, /^_hj/i, /^hj/i, /^amplitude/i, /^mp_/i, /^matomo/i],\n marketing: [/^_fbp$/i, /^_fbc$/i, /^_gcl_/i, /^IDE$/i, /^test_cookie$/i, /^li_/i, /^tt_/i, /^_uet/i, /^pin_utm/i],\n}\n\nfunction matchCookieRule(name: string, rule: MCookieMatchRule) {\n if (typeof rule === 'string') {\n const normalizedRule = rule.trim().toLowerCase()\n const normalizedName = name.trim().toLowerCase()\n\n if (normalizedRule.endsWith('*')) {\n return normalizedName.startsWith(normalizedRule.slice(0, -1))\n }\n\n return normalizedName === normalizedRule\n }\n\n return rule.test(name)\n}\n\nfunction matchCookieRules(name: string, rules?: MCookieMatchRule[]) {\n return Array.isArray(rules) && rules.some((rule) => matchCookieRule(name, rule))\n}\n\nfunction parseDocumentCookies(cookieString: string) {\n if (!cookieString.trim()) {\n return []\n }\n\n return cookieString\n .split(';')\n .map((chunk) => chunk.trim())\n .filter(Boolean)\n .map((chunk) => {\n const separatorIndex = chunk.indexOf('=')\n if (separatorIndex === -1) {\n return {\n name: chunk,\n value: '',\n }\n }\n\n return {\n name: chunk.slice(0, separatorIndex).trim(),\n value: chunk.slice(separatorIndex + 1).trim(),\n }\n })\n .filter((item) => item.name.length > 0)\n}\n\nfunction classifyCookie(\n name: string,\n requiredCookies: MCookieMatchRule[],\n categoryRules: MCookieCategoryRules\n): Pick<MCookieDetectedCookie, 'category' | 'required' | 'matchedBy'> {\n if (matchCookieRules(name, [...INTERNAL_REQUIRED_COOKIE_RULES, ...requiredCookies])) {\n return {\n category: 'necessary',\n required: true,\n matchedBy: 'required',\n }\n }\n\n for (const [category, rules] of Object.entries(categoryRules)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'custom',\n }\n }\n }\n\n for (const [category, rules] of Object.entries(BUILT_IN_CATEGORY_RULES)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'built-in',\n }\n }\n }\n\n return {\n category: 'preferences',\n required: false,\n matchedBy: 'fallback',\n }\n}\n\nexport function detectDocumentCookies({\n cookieString,\n requiredCookies = [],\n categoryRules = {},\n}: {\n cookieString?: string\n requiredCookies?: MCookieMatchRule[]\n categoryRules?: MCookieCategoryRules\n}) {\n const source = cookieString ?? (typeof document !== 'undefined' ? document.cookie : '')\n\n return parseDocumentCookies(source).map<MCookieDetectedCookie>((item) => {\n const classification = classifyCookie(item.name, requiredCookies, categoryRules)\n\n return {\n name: item.name,\n value: item.value,\n category: classification.category,\n required: classification.required,\n matchedBy: classification.matchedBy as MCookieDetectedCookieMatch,\n source: 'document.cookie',\n }\n })\n}\n","import type {MCookieConsentPersistence, MCookieConsentState} from './MCookieConsent.types'\n\ninterface CookieConsentStorageOptions {\n storage: MCookieConsentPersistence\n storageKey: string\n cookieName: string\n cookieMaxAgeDays: number\n}\n\nfunction isCookieConsentState(value: unknown): value is MCookieConsentState {\n if (!value || typeof value !== 'object') {\n return false\n }\n\n const candidate = value as MCookieConsentState\n\n return (\n typeof candidate.version === 'string' &&\n typeof candidate.decidedAt === 'string' &&\n typeof candidate.source === 'string' &&\n candidate.categories != null &&\n typeof candidate.categories === 'object'\n )\n}\n\nfunction readCookieValue(name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const prefix = `${encodeURIComponent(name)}=`\n\n for (const chunk of document.cookie.split(';')) {\n const trimmed = chunk.trim()\n if (trimmed.startsWith(prefix)) {\n return decodeURIComponent(trimmed.slice(prefix.length))\n }\n }\n\n return null\n}\n\nfunction writeCookieValue(name: string, value: string, maxAgeDays: number) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; path=/; max-age=${Math.floor(\n maxAgeDays * 24 * 60 * 60\n )}; samesite=lax`\n}\n\nfunction clearCookieValue(name: string) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=; path=/; max-age=0; samesite=lax`\n}\n\nexport function readStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>): MCookieConsentState | null {\n try {\n const raw = storage === 'cookie' ? readCookieValue(cookieName) : localStorage.getItem(storageKey)\n if (!raw) {\n return null\n }\n\n const parsed = JSON.parse(raw) as unknown\n return isCookieConsentState(parsed) ? parsed : null\n } catch {\n return null\n }\n}\n\nexport function writeStoredCookieConsent(\n {storage, storageKey, cookieName, cookieMaxAgeDays}: CookieConsentStorageOptions,\n state: MCookieConsentState\n) {\n try {\n const serialized = JSON.stringify(state)\n\n if (storage === 'cookie') {\n writeCookieValue(cookieName, serialized, cookieMaxAgeDays)\n return\n }\n\n localStorage.setItem(storageKey, serialized)\n } catch {\n /* noop */\n }\n}\n\nexport function clearStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>) {\n try {\n if (storage === 'cookie') {\n clearCookieValue(cookieName)\n return\n }\n\n localStorage.removeItem(storageKey)\n } catch {\n /* noop */\n }\n}\n","import type {\n MCookieCategoryDefinition,\n MCookieConsentPersistence,\n MCookieConsentState,\n MCookieDeclarationItem,\n} from '../MCookieConsentProvider'\n\nexport const MCOOKIE_CONSENT_CHANGE_EVENT = 'mineralui:cookie-consent-change'\nexport const MCOOKIE_BOOTSTRAP_CONFIG_KEY = '__MINERAL_COOKIE_CONFIG__'\nexport const MCOOKIE_RUNTIME_KEY = '__MINERAL_COOKIE_RUNTIME__'\nexport const MCOOKIE_RUNTIME_READY_EVENT = 'mineralui:cookie-runtime-ready'\n\nexport type MCookieBootstrapResourceKind = 'script' | 'iframe' | 'image'\n\nexport interface MCookieBootstrapResourceRules {\n scripts?: Record<string, string[]>\n iframes?: Record<string, string[]>\n images?: Record<string, string[]>\n}\n\nexport interface MCookieBootstrapScanOptions {\n cookies?: boolean\n storage?: boolean\n scripts?: boolean\n iframes?: boolean\n images?: boolean\n}\n\nexport interface MCookieBootstrapConfig {\n siteKey?: string\n domain?: string\n version?: string\n storage?: MCookieConsentPersistence\n storageKey?: string\n cookieName?: string\n cookieMaxAgeDays?: number\n categories?: MCookieCategoryDefinition[]\n hideOnAccept?: boolean\n autoShow?: boolean\n reopenOnVersionChange?: boolean\n requiredCookies?: string[]\n categoryRules?: Record<string, string[]>\n resources?: MCookieBootstrapResourceRules\n scan?: MCookieBootstrapScanOptions\n configEndpoint?: string\n scanEndpoint?: string\n reportEndpoint?: string\n reportMethod?: 'POST' | 'PUT'\n reportHeaders?: Record<string, string>\n}\n\nexport interface MCookieRuntime {\n config: MCookieBootstrapConfig\n getDeclaration?: () => Promise<MCookieDeclarationItem[]>\n getConsent?: () => Promise<MCookieConsentState | null>\n saveConsent?: (state: MCookieConsentState) => void | Promise<void>\n}\n\nexport interface MCookieBootstrapChangeDetail {\n state: MCookieConsentState | null\n}\n\nexport interface MCookieScanStorageItem {\n kind: 'localStorage' | 'sessionStorage'\n key: string\n value: string\n}\n\nexport interface MCookieScanResourceItem {\n kind: MCookieBootstrapResourceKind\n src: string\n host: string\n category?: string\n}\n\nexport interface MCookieScanCookieItem {\n name: string\n value: string\n category: string\n required: boolean\n matchedBy: string\n source: string\n}\n\nexport interface MCookieScanReport {\n siteKey?: string\n domain: string\n url: string\n scannedAt: string\n cookies: MCookieScanCookieItem[]\n storage: MCookieScanStorageItem[]\n resources: MCookieScanResourceItem[]\n}\n\nexport interface MCookieBootstrapHandle {\n config: MCookieBootstrapConfig\n destroy: () => void\n getState: () => MCookieConsentState | null\n sync: (state?: MCookieConsentState | null) => void\n}\n\ndeclare global {\n interface Window {\n __MINERAL_COOKIE_CONFIG__?: MCookieBootstrapConfig\n __MINERAL_COOKIE_RUNTIME__?: MCookieRuntime\n MineralCookieConsentBootstrap?: MCookieBootstrapHandle\n }\n}\n","import {detectDocumentCookies} from '../MCookieConsentProvider/MCookieConsent.inventory'\nimport {\n COOKIE_CONSENT_COOKIE_NAME,\n COOKIE_CONSENT_STORAGE,\n COOKIE_CONSENT_STORAGE_KEY,\n} from '../MCookieConsentProvider/MCookieConsent.defaults'\nimport {readStoredCookieConsent} from '../MCookieConsentProvider/MCookieConsent.storage'\nimport type {MCookieConsentState} from '../MCookieConsentProvider'\nimport {MCOOKIE_BOOTSTRAP_CONFIG_KEY, MCOOKIE_CONSENT_CHANGE_EVENT} from './MCookieBootstrap.types'\nimport type {\n MCookieBootstrapConfig,\n MCookieBootstrapHandle,\n MCookieBootstrapResourceKind,\n MCookieScanReport,\n MCookieScanResourceItem,\n MCookieScanStorageItem,\n} from './MCookieBootstrap.types'\n\nconst CATEGORY_ATTRIBUTE = 'data-mineral-cookie-category'\nconst BLOCKED_ATTRIBUTE = 'data-mineral-cookie-blocked'\nconst SRC_ATTRIBUTE = 'data-mineral-cookie-src'\nconst TYPE_ATTRIBUTE = 'data-mineral-cookie-type'\n\nfunction toPatternRegExp(pattern: string) {\n const escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '.*')\n return new RegExp(`^${escaped}$`, 'i')\n}\n\nfunction matchesPattern(value: string, pattern: string) {\n return toPatternRegExp(pattern).test(value)\n}\n\nfunction getElementSource(node: Element) {\n if (node instanceof HTMLScriptElement || node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n return node.getAttribute('src') ?? node.getAttribute(SRC_ATTRIBUTE) ?? ''\n }\n\n return ''\n}\n\nfunction getSourceHost(src: string) {\n try {\n return new URL(src, window.location.href).hostname\n } catch {\n return ''\n }\n}\n\nfunction getConsentState(config: MCookieBootstrapConfig) {\n return readStoredCookieConsent({\n storage: config.storage ?? COOKIE_CONSENT_STORAGE,\n storageKey: config.storageKey ?? COOKIE_CONSENT_STORAGE_KEY,\n cookieName: config.cookieName ?? COOKIE_CONSENT_COOKIE_NAME,\n })\n}\n\nfunction isCategoryAllowed(state: MCookieConsentState | null, category: string) {\n if (category === 'necessary') {\n return true\n }\n\n return state?.categories?.[category] === true\n}\n\nfunction findMatchedCategory(node: Element, config: MCookieBootstrapConfig) {\n const explicitCategory = node.getAttribute(CATEGORY_ATTRIBUTE)\n if (explicitCategory) {\n return explicitCategory\n }\n\n const src = getElementSource(node)\n if (!src) {\n return null\n }\n\n const host = getSourceHost(src)\n if (!host) {\n return null\n }\n\n const kind: MCookieBootstrapResourceKind | null =\n node instanceof HTMLScriptElement\n ? 'script'\n : node instanceof HTMLIFrameElement\n ? 'iframe'\n : node instanceof HTMLImageElement\n ? 'image'\n : null\n\n if (!kind) {\n return null\n }\n\n const rules =\n kind === 'script'\n ? config.resources?.scripts\n : kind === 'iframe'\n ? config.resources?.iframes\n : config.resources?.images\n\n if (!rules) {\n return null\n }\n\n for (const [category, patterns] of Object.entries(rules)) {\n if (patterns.some((pattern) => matchesPattern(host, pattern) || matchesPattern(src, pattern))) {\n node.setAttribute(CATEGORY_ATTRIBUTE, category)\n return category\n }\n }\n\n return null\n}\n\nfunction blockNode(node: Element) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) === 'true') {\n return\n }\n\n if (node instanceof HTMLScriptElement) {\n const currentType = node.getAttribute('type') ?? ''\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(TYPE_ATTRIBUTE, currentType === 'text/plain' ? '' : currentType)\n node.type = 'text/plain'\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n }\n}\n\nfunction activateScript(node: HTMLScriptElement) {\n const src = node.getAttribute(SRC_ATTRIBUTE)\n const clone = document.createElement('script')\n\n for (const attribute of node.getAttributeNames()) {\n if (\n attribute === 'type' ||\n attribute === BLOCKED_ATTRIBUTE ||\n attribute === SRC_ATTRIBUTE ||\n attribute === TYPE_ATTRIBUTE\n ) {\n continue\n }\n\n clone.setAttribute(attribute, node.getAttribute(attribute) ?? '')\n }\n\n const originalType = node.getAttribute(TYPE_ATTRIBUTE)\n if (originalType) {\n clone.type = originalType\n }\n\n if (src) {\n clone.src = src\n } else {\n clone.textContent = node.textContent\n }\n\n node.replaceWith(clone)\n}\n\nfunction activateNode(node: Element) {\n if (node instanceof HTMLScriptElement) {\n const canActivate =\n node.getAttribute(BLOCKED_ATTRIBUTE) === 'true' ||\n (node.type === 'text/plain' && node.hasAttribute(CATEGORY_ATTRIBUTE))\n\n if (!canActivate) {\n return\n }\n\n activateScript(node)\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) !== 'true' && !node.hasAttribute(SRC_ATTRIBUTE)) {\n return\n }\n\n const src = node.getAttribute(SRC_ATTRIBUTE)\n if (src) {\n node.setAttribute('src', src)\n }\n\n node.removeAttribute(SRC_ATTRIBUTE)\n node.removeAttribute(BLOCKED_ATTRIBUTE)\n }\n}\n\nfunction collectCandidateNodes(root: ParentNode) {\n const directNodes: Element[] = []\n\n if (root instanceof Element) {\n directNodes.push(root)\n }\n\n const nestedNodes = Array.from(root.querySelectorAll('script, iframe, img'))\n return [...directNodes, ...nestedNodes]\n}\n\nfunction syncNode(node: Element, state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const category = findMatchedCategory(node, config)\n if (!category) {\n return\n }\n\n if (isCategoryAllowed(state, category)) {\n activateNode(node)\n return\n }\n\n blockNode(node)\n}\n\nfunction syncDocument(state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n for (const node of collectCandidateNodes(document)) {\n syncNode(node, state, config)\n }\n}\n\nfunction patchDomInsertion(getState: () => MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const appendChild = Node.prototype.appendChild\n const insertBefore = Node.prototype.insertBefore\n const replaceChild = Node.prototype.replaceChild\n\n Node.prototype.appendChild = function patchedAppendChild<T extends Node>(node: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return appendChild.call(this, node) as T\n }\n\n Node.prototype.insertBefore = function patchedInsertBefore<T extends Node>(node: T, child: Node | null) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return insertBefore.call(this, node, child) as T\n }\n\n Node.prototype.replaceChild = function patchedReplaceChild<T extends Node>(node: Node, child: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return replaceChild.call(this, node, child) as T\n }\n\n return () => {\n Node.prototype.appendChild = appendChild\n Node.prototype.insertBefore = insertBefore\n Node.prototype.replaceChild = replaceChild\n }\n}\n\nfunction scanStorage(storage: Storage, kind: 'localStorage' | 'sessionStorage') {\n const items: MCookieScanStorageItem[] = []\n\n try {\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index)\n if (!key) {\n continue\n }\n\n items.push({\n kind,\n key,\n value: storage.getItem(key) ?? '',\n })\n }\n } catch {\n return []\n }\n\n return items\n}\n\nexport function readMCookieBootstrapConfig(config?: MCookieBootstrapConfig | null) {\n if (config) {\n return config\n }\n\n if (typeof window === 'undefined') {\n return null\n }\n\n return window[MCOOKIE_BOOTSTRAP_CONFIG_KEY] ?? null\n}\n\nexport function scanMCookieSurface(config?: MCookieBootstrapConfig | null): MCookieScanReport | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n const scan = resolvedConfig.scan ?? {}\n const storageItems: MCookieScanStorageItem[] = []\n const resources: MCookieScanResourceItem[] = []\n\n if (scan.storage !== false) {\n storageItems.push(...scanStorage(window.localStorage, 'localStorage'))\n storageItems.push(...scanStorage(window.sessionStorage, 'sessionStorage'))\n }\n\n const resourceSelectors: Array<[boolean, string, MCookieBootstrapResourceKind]> = [\n [scan.scripts !== false, 'script[src], script[data-mineral-cookie-src]', 'script'],\n [scan.iframes !== false, 'iframe[src], iframe[data-mineral-cookie-src]', 'iframe'],\n [scan.images !== false, 'img[src], img[data-mineral-cookie-src]', 'image'],\n ]\n\n for (const [enabled, selector, kind] of resourceSelectors) {\n if (!enabled) {\n continue\n }\n\n for (const node of Array.from(document.querySelectorAll(selector))) {\n const src = getElementSource(node)\n if (!src) {\n continue\n }\n\n resources.push({\n kind,\n src,\n host: getSourceHost(src),\n category: node.getAttribute(CATEGORY_ATTRIBUTE) ?? undefined,\n })\n }\n }\n\n return {\n siteKey: resolvedConfig.siteKey,\n domain: resolvedConfig.domain ?? window.location.hostname,\n url: window.location.href,\n scannedAt: new Date().toISOString(),\n cookies:\n scan.cookies === false\n ? []\n : detectDocumentCookies({\n requiredCookies: resolvedConfig.requiredCookies ?? [],\n categoryRules: resolvedConfig.categoryRules ?? {},\n }).map((item) => ({\n ...item,\n matchedBy: item.matchedBy,\n source: item.source,\n })),\n storage: storageItems,\n resources,\n }\n}\n\nexport async function reportMCookieSurface(config?: MCookieBootstrapConfig | null, report?: MCookieScanReport | null) {\n const resolvedConfig = readMCookieBootstrapConfig(config)\n const endpoint = resolvedConfig?.scanEndpoint ?? resolvedConfig?.reportEndpoint\n\n if (!endpoint || typeof fetch === 'undefined') {\n return report ?? scanMCookieSurface(resolvedConfig)\n }\n\n if (!resolvedConfig) {\n return report ?? null\n }\n\n const payload = report ?? scanMCookieSurface(resolvedConfig)\n if (!payload) {\n return null\n }\n\n await fetch(endpoint, {\n method: resolvedConfig.reportMethod ?? 'POST',\n headers: {\n 'content-type': 'application/json',\n ...(resolvedConfig.siteKey ? {'x-mineral-site-key': resolvedConfig.siteKey} : {}),\n ...resolvedConfig.reportHeaders,\n },\n body: JSON.stringify(payload),\n })\n\n return payload\n}\n\nexport function bootstrapMCookieConsent(config?: MCookieBootstrapConfig | null): MCookieBootstrapHandle | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n let state = getConsentState(resolvedConfig)\n let reportTimer: number | null = null\n let followUpReportTimer: number | null = null\n\n const clearReportTimers = () => {\n if (reportTimer != null) {\n window.clearTimeout(reportTimer)\n reportTimer = null\n }\n\n if (followUpReportTimer != null) {\n window.clearTimeout(followUpReportTimer)\n followUpReportTimer = null\n }\n }\n\n const scheduleReport = (primaryDelay = 0, followUpDelay?: number) => {\n clearReportTimers()\n\n reportTimer = window.setTimeout(() => {\n reportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, primaryDelay)\n\n if (typeof followUpDelay === 'number') {\n followUpReportTimer = window.setTimeout(() => {\n followUpReportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, followUpDelay)\n }\n }\n\n const sync = (nextState?: MCookieConsentState | null) => {\n state = nextState === undefined ? getConsentState(resolvedConfig) : nextState\n syncDocument(state, resolvedConfig)\n }\n\n sync(state)\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of Array.from(record.addedNodes)) {\n if (!(node instanceof Element)) {\n continue\n }\n\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, state, resolvedConfig)\n }\n }\n }\n })\n\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n })\n\n const handleConsentChange = (event: Event) => {\n const detail = (event as CustomEvent<{state: MCookieConsentState | null}>).detail\n sync(detail?.state ?? null)\n scheduleReport(300, 1500)\n }\n\n window.addEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n\n const restoreDom = patchDomInsertion(() => state, resolvedConfig)\n\n const handleWindowLoad = () => {\n scheduleReport()\n }\n\n if (document.readyState === 'complete') {\n handleWindowLoad()\n } else {\n window.addEventListener('load', handleWindowLoad, {once: true})\n }\n\n const handle: MCookieBootstrapHandle = {\n config: resolvedConfig,\n destroy: () => {\n observer.disconnect()\n restoreDom()\n clearReportTimers()\n window.removeEventListener('load', handleWindowLoad)\n window.removeEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n if (window.MineralCookieConsentBootstrap === handle) {\n delete window.MineralCookieConsentBootstrap\n }\n },\n getState: () => state,\n sync,\n }\n\n window.MineralCookieConsentBootstrap = handle\n return handle\n}\n\nexport function autoBootstrapMCookieConsent() {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n return bootstrapMCookieConsent(readMCookieBootstrapConfig())\n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,GACzC,OAAO,OAAO,+BAGtB,aAAgB,EAChB,OACH,CAGD,MADA,QAAO,8BAAgC,EAChC,EAGX,SAAgB,GAA8B,CAK1C,OAJI,OAAO,OAAW,KAAe,OAAO,SAAa,IAC9C,KAGJ,EAAwB,GAA4B,CAAC"}
1
+ {"version":3,"file":"MCookieBootstrap-Ck_8aUQK.cjs","names":[],"sources":["../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.defaults.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.inventory.ts","../src/components/feedback/MCookie/MCookieConsentProvider/MCookieConsent.storage.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.types.ts","../src/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.ts"],"sourcesContent":["import type {MCookieConsentTexts} from '../../../../i18n/frameworkTexts'\nimport type {MCookieCategoryDefinition, MCookieConsentPersistence, MCookieDeclarationItem} from './MCookieConsent.types'\n\nexport const COOKIE_CONSENT_STORAGE_KEY = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_NAME = 'mineralui-cookie-consent'\nexport const COOKIE_CONSENT_COOKIE_MAX_AGE_DAYS = 180\nexport const COOKIE_CONSENT_STORAGE: MCookieConsentPersistence = 'localStorage'\n\nexport function mergeCookieConsentTexts(\n baseTexts: MCookieConsentTexts,\n override?: Partial<MCookieConsentTexts>\n): MCookieConsentTexts {\n return {\n ...baseTexts,\n ...override,\n }\n}\n\nexport function createCookieConsentCategories(texts: MCookieConsentTexts): MCookieCategoryDefinition[] {\n return [\n {\n key: 'necessary',\n label: texts.necessaryLabel,\n description: texts.necessaryDescription,\n required: true,\n defaultValue: true,\n },\n {\n key: 'preferences',\n label: texts.preferencesLabel,\n description: texts.preferencesDescriptionLabel,\n defaultValue: false,\n },\n {\n key: 'analytics',\n label: texts.analyticsLabel,\n description: texts.analyticsDescription,\n defaultValue: false,\n },\n {\n key: 'marketing',\n label: texts.marketingLabel,\n description: texts.marketingDescription,\n defaultValue: false,\n },\n ]\n}\n\nexport function createCookieConsentDeclaration(): MCookieDeclarationItem[] {\n return []\n}\n","import {COOKIE_CONSENT_COOKIE_NAME} from './MCookieConsent.defaults'\nimport type {\n MCookieCategoryRules,\n MCookieDetectedCookie,\n MCookieDetectedCookieMatch,\n MCookieMatchRule,\n} from './MCookieConsent.types'\n\nconst INTERNAL_REQUIRED_COOKIE_RULES: MCookieMatchRule[] = [\n COOKIE_CONSENT_COOKIE_NAME,\n /^PHPSESSID$/i,\n /^JSESSIONID$/i,\n /^ASP\\.NET_SessionId$/i,\n /^__Host-/i,\n /^__Secure-/i,\n /csrf/i,\n /xsrf/i,\n /session/i,\n /auth/i,\n /token/i,\n /^sid$/i,\n]\n\nconst BUILT_IN_CATEGORY_RULES: Record<string, MCookieMatchRule[]> = {\n preferences: [/theme/i, /locale/i, /lang/i, /currency/i, /timezone/i, /consent/i],\n analytics: [/^_ga/i, /^_gid/i, /^_gat/i, /^_pk_/i, /^pk_/i, /^_hj/i, /^hj/i, /^amplitude/i, /^mp_/i, /^matomo/i],\n marketing: [/^_fbp$/i, /^_fbc$/i, /^_gcl_/i, /^IDE$/i, /^test_cookie$/i, /^li_/i, /^tt_/i, /^_uet/i, /^pin_utm/i],\n}\n\nfunction matchCookieRule(name: string, rule: MCookieMatchRule) {\n if (typeof rule === 'string') {\n const normalizedRule = rule.trim().toLowerCase()\n const normalizedName = name.trim().toLowerCase()\n\n if (normalizedRule.endsWith('*')) {\n return normalizedName.startsWith(normalizedRule.slice(0, -1))\n }\n\n return normalizedName === normalizedRule\n }\n\n return rule.test(name)\n}\n\nfunction matchCookieRules(name: string, rules?: MCookieMatchRule[]) {\n return Array.isArray(rules) && rules.some((rule) => matchCookieRule(name, rule))\n}\n\nfunction parseDocumentCookies(cookieString: string) {\n if (!cookieString.trim()) {\n return []\n }\n\n return cookieString\n .split(';')\n .map((chunk) => chunk.trim())\n .filter(Boolean)\n .map((chunk) => {\n const separatorIndex = chunk.indexOf('=')\n if (separatorIndex === -1) {\n return {\n name: chunk,\n value: '',\n }\n }\n\n return {\n name: chunk.slice(0, separatorIndex).trim(),\n value: chunk.slice(separatorIndex + 1).trim(),\n }\n })\n .filter((item) => item.name.length > 0)\n}\n\nfunction classifyCookie(\n name: string,\n requiredCookies: MCookieMatchRule[],\n categoryRules: MCookieCategoryRules\n): Pick<MCookieDetectedCookie, 'category' | 'required' | 'matchedBy'> {\n if (matchCookieRules(name, [...INTERNAL_REQUIRED_COOKIE_RULES, ...requiredCookies])) {\n return {\n category: 'necessary',\n required: true,\n matchedBy: 'required',\n }\n }\n\n for (const [category, rules] of Object.entries(categoryRules)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'custom',\n }\n }\n }\n\n for (const [category, rules] of Object.entries(BUILT_IN_CATEGORY_RULES)) {\n if (matchCookieRules(name, rules)) {\n return {\n category,\n required: false,\n matchedBy: 'built-in',\n }\n }\n }\n\n return {\n category: 'preferences',\n required: false,\n matchedBy: 'fallback',\n }\n}\n\nexport function detectDocumentCookies({\n cookieString,\n requiredCookies = [],\n categoryRules = {},\n}: {\n cookieString?: string\n requiredCookies?: MCookieMatchRule[]\n categoryRules?: MCookieCategoryRules\n}) {\n const source = cookieString ?? (typeof document !== 'undefined' ? document.cookie : '')\n\n return parseDocumentCookies(source).map<MCookieDetectedCookie>((item) => {\n const classification = classifyCookie(item.name, requiredCookies, categoryRules)\n\n return {\n name: item.name,\n value: item.value,\n category: classification.category,\n required: classification.required,\n matchedBy: classification.matchedBy as MCookieDetectedCookieMatch,\n source: 'document.cookie',\n }\n })\n}\n","import type {MCookieConsentPersistence, MCookieConsentState} from './MCookieConsent.types'\n\ninterface CookieConsentStorageOptions {\n storage: MCookieConsentPersistence\n storageKey: string\n cookieName: string\n cookieMaxAgeDays: number\n}\n\nfunction isCookieConsentState(value: unknown): value is MCookieConsentState {\n if (!value || typeof value !== 'object') {\n return false\n }\n\n const candidate = value as MCookieConsentState\n\n return (\n typeof candidate.version === 'string' &&\n typeof candidate.decidedAt === 'string' &&\n typeof candidate.source === 'string' &&\n candidate.categories != null &&\n typeof candidate.categories === 'object'\n )\n}\n\nfunction readCookieValue(name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const prefix = `${encodeURIComponent(name)}=`\n\n for (const chunk of document.cookie.split(';')) {\n const trimmed = chunk.trim()\n if (trimmed.startsWith(prefix)) {\n return decodeURIComponent(trimmed.slice(prefix.length))\n }\n }\n\n return null\n}\n\nfunction writeCookieValue(name: string, value: string, maxAgeDays: number) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; path=/; max-age=${Math.floor(\n maxAgeDays * 24 * 60 * 60\n )}; samesite=lax`\n}\n\nfunction clearCookieValue(name: string) {\n if (typeof document === 'undefined') {\n return\n }\n\n document.cookie = `${encodeURIComponent(name)}=; path=/; max-age=0; samesite=lax`\n}\n\nexport function readStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>): MCookieConsentState | null {\n try {\n const raw = storage === 'cookie' ? readCookieValue(cookieName) : localStorage.getItem(storageKey)\n if (!raw) {\n return null\n }\n\n const parsed = JSON.parse(raw) as unknown\n return isCookieConsentState(parsed) ? parsed : null\n } catch {\n return null\n }\n}\n\nexport function writeStoredCookieConsent(\n {storage, storageKey, cookieName, cookieMaxAgeDays}: CookieConsentStorageOptions,\n state: MCookieConsentState\n) {\n try {\n const serialized = JSON.stringify(state)\n\n if (storage === 'cookie') {\n writeCookieValue(cookieName, serialized, cookieMaxAgeDays)\n return\n }\n\n localStorage.setItem(storageKey, serialized)\n } catch {\n /* noop */\n }\n}\n\nexport function clearStoredCookieConsent({\n storage,\n storageKey,\n cookieName,\n}: Pick<CookieConsentStorageOptions, 'storage' | 'storageKey' | 'cookieName'>) {\n try {\n if (storage === 'cookie') {\n clearCookieValue(cookieName)\n return\n }\n\n localStorage.removeItem(storageKey)\n } catch {\n /* noop */\n }\n}\n","import type {\n MCookieCategoryDefinition,\n MCookieConsentPersistence,\n MCookieConsentState,\n MCookieDeclarationItem,\n} from '../MCookieConsentProvider'\n\nexport const MCOOKIE_CONSENT_CHANGE_EVENT = 'mineralui:cookie-consent-change'\nexport const MCOOKIE_BOOTSTRAP_CONFIG_KEY = '__MINERAL_COOKIE_CONFIG__'\nexport const MCOOKIE_RUNTIME_KEY = '__MINERAL_COOKIE_RUNTIME__'\nexport const MCOOKIE_RUNTIME_READY_EVENT = 'mineralui:cookie-runtime-ready'\n\nexport type MCookieBootstrapResourceKind = 'script' | 'iframe' | 'image'\n\nexport interface MCookieBootstrapResourceRules {\n scripts?: Record<string, string[]>\n iframes?: Record<string, string[]>\n images?: Record<string, string[]>\n}\n\nexport interface MCookieBootstrapScanOptions {\n cookies?: boolean\n storage?: boolean\n scripts?: boolean\n iframes?: boolean\n images?: boolean\n}\n\nexport interface MCookieBootstrapConfig {\n siteKey?: string\n domain?: string\n version?: string\n storage?: MCookieConsentPersistence\n storageKey?: string\n cookieName?: string\n cookieMaxAgeDays?: number\n categories?: MCookieCategoryDefinition[]\n hideOnAccept?: boolean\n autoShow?: boolean\n reopenOnVersionChange?: boolean\n requiredCookies?: string[]\n categoryRules?: Record<string, string[]>\n resources?: MCookieBootstrapResourceRules\n scan?: MCookieBootstrapScanOptions\n configEndpoint?: string\n scanEndpoint?: string\n reportEndpoint?: string\n reportMethod?: 'POST' | 'PUT'\n reportHeaders?: Record<string, string>\n}\n\nexport interface MCookieRuntime {\n config: MCookieBootstrapConfig\n getDeclaration?: () => Promise<MCookieDeclarationItem[]>\n getConsent?: () => Promise<MCookieConsentState | null>\n saveConsent?: (state: MCookieConsentState) => void | Promise<void>\n}\n\nexport interface MCookieBootstrapChangeDetail {\n state: MCookieConsentState | null\n}\n\nexport interface MCookieScanStorageItem {\n kind: 'localStorage' | 'sessionStorage'\n key: string\n value: string\n}\n\nexport interface MCookieScanResourceItem {\n kind: MCookieBootstrapResourceKind\n src: string\n host: string\n category?: string\n}\n\nexport interface MCookieScanCookieItem {\n name: string\n value: string\n category: string\n required: boolean\n matchedBy: string\n source: string\n}\n\nexport interface MCookieScanReport {\n siteKey?: string\n domain: string\n url: string\n scannedAt: string\n cookies: MCookieScanCookieItem[]\n storage: MCookieScanStorageItem[]\n resources: MCookieScanResourceItem[]\n}\n\nexport interface MCookieBootstrapHandle {\n config: MCookieBootstrapConfig\n destroy: () => void\n getState: () => MCookieConsentState | null\n sync: (state?: MCookieConsentState | null) => void\n}\n\ndeclare global {\n interface Window {\n __MINERAL_COOKIE_CONFIG__?: MCookieBootstrapConfig\n __MINERAL_COOKIE_RUNTIME__?: MCookieRuntime\n MineralCookieConsentBootstrap?: MCookieBootstrapHandle\n }\n}\n","import {detectDocumentCookies} from '../MCookieConsentProvider/MCookieConsent.inventory'\nimport {\n COOKIE_CONSENT_COOKIE_NAME,\n COOKIE_CONSENT_STORAGE,\n COOKIE_CONSENT_STORAGE_KEY,\n} from '../MCookieConsentProvider/MCookieConsent.defaults'\nimport {readStoredCookieConsent} from '../MCookieConsentProvider/MCookieConsent.storage'\nimport type {MCookieConsentState} from '../MCookieConsentProvider'\nimport {MCOOKIE_BOOTSTRAP_CONFIG_KEY, MCOOKIE_CONSENT_CHANGE_EVENT} from './MCookieBootstrap.types'\nimport type {\n MCookieBootstrapConfig,\n MCookieBootstrapHandle,\n MCookieBootstrapResourceKind,\n MCookieScanReport,\n MCookieScanResourceItem,\n MCookieScanStorageItem,\n} from './MCookieBootstrap.types'\n\nconst CATEGORY_ATTRIBUTE = 'data-mineral-cookie-category'\nconst BLOCKED_ATTRIBUTE = 'data-mineral-cookie-blocked'\nconst SRC_ATTRIBUTE = 'data-mineral-cookie-src'\nconst TYPE_ATTRIBUTE = 'data-mineral-cookie-type'\n\nfunction toPatternRegExp(pattern: string) {\n const escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '.*')\n return new RegExp(`^${escaped}$`, 'i')\n}\n\nfunction matchesPattern(value: string, pattern: string) {\n return toPatternRegExp(pattern).test(value)\n}\n\nfunction getElementSource(node: Element) {\n if (node instanceof HTMLScriptElement || node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n return node.getAttribute('src') ?? node.getAttribute(SRC_ATTRIBUTE) ?? ''\n }\n\n return ''\n}\n\nfunction getSourceHost(src: string) {\n try {\n return new URL(src, window.location.href).hostname\n } catch {\n return ''\n }\n}\n\nfunction getConsentState(config: MCookieBootstrapConfig) {\n return readStoredCookieConsent({\n storage: config.storage ?? COOKIE_CONSENT_STORAGE,\n storageKey: config.storageKey ?? COOKIE_CONSENT_STORAGE_KEY,\n cookieName: config.cookieName ?? COOKIE_CONSENT_COOKIE_NAME,\n })\n}\n\nfunction isCategoryAllowed(state: MCookieConsentState | null, category: string) {\n if (category === 'necessary') {\n return true\n }\n\n return state?.categories?.[category] === true\n}\n\nfunction findMatchedCategory(node: Element, config: MCookieBootstrapConfig) {\n const explicitCategory = node.getAttribute(CATEGORY_ATTRIBUTE)\n if (explicitCategory) {\n return explicitCategory\n }\n\n const src = getElementSource(node)\n if (!src) {\n return null\n }\n\n const host = getSourceHost(src)\n if (!host) {\n return null\n }\n\n const kind: MCookieBootstrapResourceKind | null =\n node instanceof HTMLScriptElement\n ? 'script'\n : node instanceof HTMLIFrameElement\n ? 'iframe'\n : node instanceof HTMLImageElement\n ? 'image'\n : null\n\n if (!kind) {\n return null\n }\n\n const rules =\n kind === 'script'\n ? config.resources?.scripts\n : kind === 'iframe'\n ? config.resources?.iframes\n : config.resources?.images\n\n if (!rules) {\n return null\n }\n\n for (const [category, patterns] of Object.entries(rules)) {\n if (patterns.some((pattern) => matchesPattern(host, pattern) || matchesPattern(src, pattern))) {\n node.setAttribute(CATEGORY_ATTRIBUTE, category)\n return category\n }\n }\n\n return null\n}\n\nfunction blockNode(node: Element) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) === 'true') {\n return\n }\n\n if (node instanceof HTMLScriptElement) {\n const currentType = node.getAttribute('type') ?? ''\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(TYPE_ATTRIBUTE, currentType === 'text/plain' ? '' : currentType)\n node.type = 'text/plain'\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n const src = node.getAttribute('src')\n if (src) {\n node.setAttribute(SRC_ATTRIBUTE, src)\n node.removeAttribute('src')\n }\n\n node.setAttribute(BLOCKED_ATTRIBUTE, 'true')\n }\n}\n\nfunction activateScript(node: HTMLScriptElement) {\n const src = node.getAttribute(SRC_ATTRIBUTE)\n const clone = document.createElement('script')\n\n for (const attribute of node.getAttributeNames()) {\n if (\n attribute === 'type' ||\n attribute === BLOCKED_ATTRIBUTE ||\n attribute === SRC_ATTRIBUTE ||\n attribute === TYPE_ATTRIBUTE\n ) {\n continue\n }\n\n clone.setAttribute(attribute, node.getAttribute(attribute) ?? '')\n }\n\n const originalType = node.getAttribute(TYPE_ATTRIBUTE)\n if (originalType) {\n clone.type = originalType\n }\n\n if (src) {\n clone.src = src\n } else {\n clone.textContent = node.textContent\n }\n\n node.replaceWith(clone)\n}\n\nfunction activateNode(node: Element) {\n if (node instanceof HTMLScriptElement) {\n const canActivate =\n node.getAttribute(BLOCKED_ATTRIBUTE) === 'true' ||\n (node.type === 'text/plain' && node.hasAttribute(CATEGORY_ATTRIBUTE))\n\n if (!canActivate) {\n return\n }\n\n activateScript(node)\n return\n }\n\n if (node instanceof HTMLIFrameElement || node instanceof HTMLImageElement) {\n if (node.getAttribute(BLOCKED_ATTRIBUTE) !== 'true' && !node.hasAttribute(SRC_ATTRIBUTE)) {\n return\n }\n\n const src = node.getAttribute(SRC_ATTRIBUTE)\n if (src) {\n node.setAttribute('src', src)\n }\n\n node.removeAttribute(SRC_ATTRIBUTE)\n node.removeAttribute(BLOCKED_ATTRIBUTE)\n }\n}\n\nfunction collectCandidateNodes(root: ParentNode) {\n const directNodes: Element[] = []\n\n if (root instanceof Element) {\n directNodes.push(root)\n }\n\n const nestedNodes = Array.from(root.querySelectorAll('script, iframe, img'))\n return [...directNodes, ...nestedNodes]\n}\n\nfunction syncNode(node: Element, state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const category = findMatchedCategory(node, config)\n if (!category) {\n return\n }\n\n if (isCategoryAllowed(state, category)) {\n activateNode(node)\n return\n }\n\n blockNode(node)\n}\n\nfunction syncDocument(state: MCookieConsentState | null, config: MCookieBootstrapConfig) {\n for (const node of collectCandidateNodes(document)) {\n syncNode(node, state, config)\n }\n}\n\nfunction patchDomInsertion(getState: () => MCookieConsentState | null, config: MCookieBootstrapConfig) {\n const appendChild = Node.prototype.appendChild\n const insertBefore = Node.prototype.insertBefore\n const replaceChild = Node.prototype.replaceChild\n\n Node.prototype.appendChild = function patchedAppendChild<T extends Node>(node: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return appendChild.call(this, node) as T\n }\n\n Node.prototype.insertBefore = function patchedInsertBefore<T extends Node>(node: T, child: Node | null) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return insertBefore.call(this, node, child) as T\n }\n\n Node.prototype.replaceChild = function patchedReplaceChild<T extends Node>(node: Node, child: T) {\n if (node instanceof Element) {\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, getState(), config)\n }\n }\n\n return replaceChild.call(this, node, child) as T\n }\n\n return () => {\n Node.prototype.appendChild = appendChild\n Node.prototype.insertBefore = insertBefore\n Node.prototype.replaceChild = replaceChild\n }\n}\n\nfunction scanStorage(storage: Storage, kind: 'localStorage' | 'sessionStorage') {\n const items: MCookieScanStorageItem[] = []\n\n try {\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index)\n if (!key) {\n continue\n }\n\n items.push({\n kind,\n key,\n value: storage.getItem(key) ?? '',\n })\n }\n } catch {\n return []\n }\n\n return items\n}\n\nexport function readMCookieBootstrapConfig(config?: MCookieBootstrapConfig | null) {\n if (config) {\n return config\n }\n\n if (typeof window === 'undefined') {\n return null\n }\n\n return window[MCOOKIE_BOOTSTRAP_CONFIG_KEY] ?? null\n}\n\nexport function scanMCookieSurface(config?: MCookieBootstrapConfig | null): MCookieScanReport | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n const scan = resolvedConfig.scan ?? {}\n const storageItems: MCookieScanStorageItem[] = []\n const resources: MCookieScanResourceItem[] = []\n\n if (scan.storage !== false) {\n storageItems.push(...scanStorage(window.localStorage, 'localStorage'))\n storageItems.push(...scanStorage(window.sessionStorage, 'sessionStorage'))\n }\n\n const resourceSelectors: Array<[boolean, string, MCookieBootstrapResourceKind]> = [\n [scan.scripts !== false, 'script[src], script[data-mineral-cookie-src]', 'script'],\n [scan.iframes !== false, 'iframe[src], iframe[data-mineral-cookie-src]', 'iframe'],\n [scan.images !== false, 'img[src], img[data-mineral-cookie-src]', 'image'],\n ]\n\n for (const [enabled, selector, kind] of resourceSelectors) {\n if (!enabled) {\n continue\n }\n\n for (const node of Array.from(document.querySelectorAll(selector))) {\n const src = getElementSource(node)\n if (!src) {\n continue\n }\n\n resources.push({\n kind,\n src,\n host: getSourceHost(src),\n category: node.getAttribute(CATEGORY_ATTRIBUTE) ?? undefined,\n })\n }\n }\n\n return {\n siteKey: resolvedConfig.siteKey,\n domain: resolvedConfig.domain ?? window.location.hostname,\n url: window.location.href,\n scannedAt: new Date().toISOString(),\n cookies:\n scan.cookies === false\n ? []\n : detectDocumentCookies({\n requiredCookies: resolvedConfig.requiredCookies ?? [],\n categoryRules: resolvedConfig.categoryRules ?? {},\n }).map((item) => ({\n ...item,\n matchedBy: item.matchedBy,\n source: item.source,\n })),\n storage: storageItems,\n resources,\n }\n}\n\nexport async function reportMCookieSurface(config?: MCookieBootstrapConfig | null, report?: MCookieScanReport | null) {\n const resolvedConfig = readMCookieBootstrapConfig(config)\n const endpoint = resolvedConfig?.scanEndpoint ?? resolvedConfig?.reportEndpoint\n\n if (!endpoint || typeof fetch === 'undefined') {\n return report ?? null\n }\n\n if (!resolvedConfig) {\n return report ?? null\n }\n\n const payload = report ?? scanMCookieSurface(resolvedConfig)\n if (!payload) {\n return null\n }\n\n await fetch(endpoint, {\n method: resolvedConfig.reportMethod ?? 'POST',\n headers: {\n 'content-type': 'application/json',\n ...(resolvedConfig.siteKey ? {'x-mineral-site-key': resolvedConfig.siteKey} : {}),\n ...resolvedConfig.reportHeaders,\n },\n body: JSON.stringify(payload),\n })\n\n return payload\n}\n\nexport function bootstrapMCookieConsent(config?: MCookieBootstrapConfig | null): MCookieBootstrapHandle | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n const resolvedConfig = readMCookieBootstrapConfig(config)\n if (!resolvedConfig) {\n return null\n }\n\n let state = getConsentState(resolvedConfig)\n let reportTimer: number | null = null\n let followUpReportTimer: number | null = null\n\n const clearReportTimers = () => {\n if (reportTimer != null) {\n window.clearTimeout(reportTimer)\n reportTimer = null\n }\n\n if (followUpReportTimer != null) {\n window.clearTimeout(followUpReportTimer)\n followUpReportTimer = null\n }\n }\n\n const scheduleReport = (primaryDelay = 0, followUpDelay?: number) => {\n if (!resolvedConfig.scanEndpoint && !resolvedConfig.reportEndpoint) {\n return\n }\n\n clearReportTimers()\n\n reportTimer = window.setTimeout(() => {\n reportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, primaryDelay)\n\n if (typeof followUpDelay === 'number') {\n followUpReportTimer = window.setTimeout(() => {\n followUpReportTimer = null\n void reportMCookieSurface(resolvedConfig)\n }, followUpDelay)\n }\n }\n\n const sync = (nextState?: MCookieConsentState | null) => {\n state = nextState === undefined ? getConsentState(resolvedConfig) : nextState\n syncDocument(state, resolvedConfig)\n }\n\n sync(state)\n\n const observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of Array.from(record.addedNodes)) {\n if (!(node instanceof Element)) {\n continue\n }\n\n for (const element of collectCandidateNodes(node)) {\n syncNode(element, state, resolvedConfig)\n }\n }\n }\n })\n\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n })\n\n const handleConsentChange = (event: Event) => {\n const detail = (event as CustomEvent<{state: MCookieConsentState | null}>).detail\n sync(detail?.state ?? null)\n scheduleReport(300, 1500)\n }\n\n window.addEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n\n const restoreDom = patchDomInsertion(() => state, resolvedConfig)\n\n const handleWindowLoad = () => {\n scheduleReport()\n }\n\n if (document.readyState === 'complete') {\n handleWindowLoad()\n } else {\n window.addEventListener('load', handleWindowLoad, {once: true})\n }\n\n const handle: MCookieBootstrapHandle = {\n config: resolvedConfig,\n destroy: () => {\n observer.disconnect()\n restoreDom()\n clearReportTimers()\n window.removeEventListener('load', handleWindowLoad)\n window.removeEventListener(MCOOKIE_CONSENT_CHANGE_EVENT, handleConsentChange)\n if (window.MineralCookieConsentBootstrap === handle) {\n delete window.MineralCookieConsentBootstrap\n }\n },\n getState: () => state,\n sync,\n }\n\n window.MineralCookieConsentBootstrap = handle\n return handle\n}\n\nexport function autoBootstrapMCookieConsent() {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return null\n }\n\n return bootstrapMCookieConsent(readMCookieBootstrapConfig())\n}\n"],"mappings":"AAGA,IAAa,EAA6B,2BAC7B,EAA6B,2BAE7B,EAAoD,eAEjE,SAAgB,EACZ,EACA,EACmB,CACnB,MAAO,CACH,GAAG,EACH,GAAG,EACN,CAGL,SAAgB,EAA8B,EAAyD,CACnG,MAAO,CACH,CACI,IAAK,YACL,MAAO,EAAM,eACb,YAAa,EAAM,qBACnB,SAAU,GACV,aAAc,GACjB,CACD,CACI,IAAK,cACL,MAAO,EAAM,iBACb,YAAa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??`mineralui-cookie-consent`}-key`}function n(e){if(typeof window>`u`)return null;try{return window.localStorage.getItem(e)}catch{return null}}function r(e,t){if(!(typeof window>`u`||!t))try{window.localStorage.setItem(e,t)}catch{}}function i(t){typeof window>`u`||(window[e.o]=t.config,window[e.c]=t,window.dispatchEvent(new CustomEvent(e.l)))}function a(e){if(typeof document>`u`)return null;for(let t of Array.from(document.querySelectorAll(`script[src]`)))try{let n=new URL(t.src,window.location.href);if(n.href===e.href||n.origin===e.origin&&n.pathname===e.pathname)return t}catch{}return null}function o(e,i,a){let o=`${i.origin}/cookie/sites/${encodeURIComponent(a)}`,s=t(e);return{config:e,getDeclaration:async()=>{let e=await fetch(`${o}/declaration`);return e.ok?(await e.json()).items??[]:[]},getConsent:async()=>{let e=n(s);if(!e)return null;let t=await fetch(`${o}/consent?consentKey=${encodeURIComponent(e)}`);return t.ok?(await t.json()).state??null:null},saveConsent:async t=>{let i=n(s),a=await fetch(`${o}/consent`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...i?{consentKey:i}:{},version:t.version,decidedAt:t.decidedAt,source:t.source,categories:t.categories,domain:typeof window<`u`?window.location.hostname:e.domain??null})});a.ok&&r(s,(await a.json()).consentKey)}}}async function s(){if(typeof window>`u`||typeof fetch>`u`)return null;let t=window[e.o];if(t)return t;let n;try{n=new URL({}.url)}catch{return null}let r=a(n),s=r?.dataset.siteKey??n.searchParams.get(`siteKey`);if(!s)return null;let c=r?.dataset.configEndpoint??n.searchParams.get(`configEndpoint`)??`${n.origin}/cookie/bootstrap/${encodeURIComponent(s)}`;try{let e=await fetch(c,{headers:{"x-mineral-site-key":s}});if(!e.ok)return null;let t=await e.json(),a={...t,siteKey:t.siteKey??s,scanEndpoint:t.scanEndpoint??r?.dataset.scanEndpoint??n.searchParams.get(`scanEndpoint`)??void 0};return i(o(a,n,s)),a}catch{return null}}s().finally(()=>{e.t()}),exports.MCOOKIE_BOOTSTRAP_CONFIG_KEY=e.o,exports.MCOOKIE_CONSENT_CHANGE_EVENT=e.s,exports.MCOOKIE_RUNTIME_KEY=e.c,exports.MCOOKIE_RUNTIME_READY_EVENT=e.l,exports.autoBootstrapMCookieConsent=e.t,exports.bootstrapMCookieConsent=e.n,exports.readMCookieBootstrapConfig=e.r,exports.reportMCookieSurface=e.i,exports.scanMCookieSurface=e.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./MCookieBootstrap-Ck_8aUQK.cjs`);function t(e){return`${e.storageKey??`mineralui-cookie-consent`}-key`}function n(e){if(typeof window>`u`)return null;try{return window.localStorage.getItem(e)}catch{return null}}function r(e,t){if(!(typeof window>`u`||!t))try{window.localStorage.setItem(e,t)}catch{}}function i(t){typeof window>`u`||(window[e.o]=t.config,window[e.c]=t,window.dispatchEvent(new CustomEvent(e.l)))}function a(e){if(typeof document>`u`)return null;for(let t of Array.from(document.querySelectorAll(`script[src]`)))try{let n=new URL(t.src,window.location.href);if(n.href===e.href||n.origin===e.origin&&n.pathname===e.pathname)return t}catch{}return null}function o(e,i,a){let o=`${i.origin}/cookie/sites/${encodeURIComponent(a)}`,s=t(e);return{config:e,getDeclaration:async()=>{let e=await fetch(`${o}/declaration`);return e.ok?(await e.json()).items??[]:[]},getConsent:async()=>{let e=n(s);if(!e)return null;let t=await fetch(`${o}/consent?consentKey=${encodeURIComponent(e)}`);return t.ok?(await t.json()).state??null:null},saveConsent:async t=>{let i=n(s),a=await fetch(`${o}/consent`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...i?{consentKey:i}:{},version:t.version,decidedAt:t.decidedAt,source:t.source,categories:t.categories,domain:typeof window<`u`?window.location.hostname:e.domain??null})});a.ok&&r(s,(await a.json()).consentKey)}}}async function s(){if(typeof window>`u`||typeof fetch>`u`)return null;let t=window[e.o];if(t)return t;let n;try{n=new URL({}.url)}catch{return null}let r=a(n),s=r?.dataset.siteKey??n.searchParams.get(`siteKey`);if(!s)return null;let c=r?.dataset.configEndpoint??n.searchParams.get(`configEndpoint`)??`${n.origin}/cookie/bootstrap/${encodeURIComponent(s)}`;try{let e=await fetch(c,{headers:{"x-mineral-site-key":s}});if(!e.ok)return null;let t=await e.json(),a={...t,siteKey:t.siteKey??s,scanEndpoint:t.scanEndpoint??r?.dataset.scanEndpoint??n.searchParams.get(`scanEndpoint`)??void 0};return i(o(a,n,s)),a}catch{return null}}s().finally(()=>{e.t()}),exports.MCOOKIE_BOOTSTRAP_CONFIG_KEY=e.o,exports.MCOOKIE_CONSENT_CHANGE_EVENT=e.s,exports.MCOOKIE_RUNTIME_KEY=e.c,exports.MCOOKIE_RUNTIME_READY_EVENT=e.l,exports.autoBootstrapMCookieConsent=e.t,exports.bootstrapMCookieConsent=e.n,exports.readMCookieBootstrapConfig=e.r,exports.reportMCookieSurface=e.i,exports.scanMCookieSurface=e.a;
2
2
  //# sourceMappingURL=cookie-consent-bootstrap.cjs.map
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./MCookieBootstrap-DEEHYxXi.js";
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./MCookieBootstrap-BbpXuRtS.js";
2
2
  //#region src/cookie-consent-bootstrap.ts
3
3
  function l(e) {
4
4
  return `${e.storageKey ?? "mineralui-cookie-consent"}-key`;