@solvenza/cookies-compliance 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +245 -0
  2. package/bin/audit-cli.js +25 -0
  3. package/bin/init-cli.js +126 -0
  4. package/dist/chunk-DDAAVRWG.js +25 -0
  5. package/dist/chunk-DDAAVRWG.js.map +1 -0
  6. package/dist/chunk-LIWFUVWY.js +1858 -0
  7. package/dist/chunk-LIWFUVWY.js.map +1 -0
  8. package/dist/consent-engine-BvsH_wqV.d.cts +191 -0
  9. package/dist/consent-engine-BvsH_wqV.d.ts +191 -0
  10. package/dist/consent.esm.cjs +2051 -0
  11. package/dist/consent.esm.cjs.map +1 -0
  12. package/dist/consent.esm.d.cts +146 -0
  13. package/dist/consent.esm.d.ts +146 -0
  14. package/dist/consent.esm.js +184 -0
  15. package/dist/consent.esm.js.map +1 -0
  16. package/dist/consent.min.js +589 -0
  17. package/dist/consent.min.js.map +1 -0
  18. package/dist/wrappers/angular.cjs +1867 -0
  19. package/dist/wrappers/angular.cjs.map +1 -0
  20. package/dist/wrappers/angular.d.cts +20 -0
  21. package/dist/wrappers/angular.d.ts +20 -0
  22. package/dist/wrappers/angular.js +42 -0
  23. package/dist/wrappers/angular.js.map +1 -0
  24. package/dist/wrappers/next.cjs +1840 -0
  25. package/dist/wrappers/next.cjs.map +1 -0
  26. package/dist/wrappers/next.d.cts +3 -0
  27. package/dist/wrappers/next.d.ts +3 -0
  28. package/dist/wrappers/next.js +15 -0
  29. package/dist/wrappers/next.js.map +1 -0
  30. package/dist/wrappers/react.cjs +1882 -0
  31. package/dist/wrappers/react.cjs.map +1 -0
  32. package/dist/wrappers/react.d.cts +4 -0
  33. package/dist/wrappers/react.d.ts +4 -0
  34. package/dist/wrappers/react.js +56 -0
  35. package/dist/wrappers/react.js.map +1 -0
  36. package/dist/wrappers/wordpress.cjs +64 -0
  37. package/dist/wrappers/wordpress.cjs.map +1 -0
  38. package/dist/wrappers/wordpress.d.cts +10 -0
  39. package/dist/wrappers/wordpress.d.ts +10 -0
  40. package/dist/wrappers/wordpress.js +41 -0
  41. package/dist/wrappers/wordpress.js.map +1 -0
  42. package/package.json +85 -0
  43. package/schema.json +165 -0
@@ -0,0 +1,589 @@
1
+ "use strict";var ConsentSDK=(()=>{var G=Object.defineProperty,Se=Object.defineProperties,Ee=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertyNames,be=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ye=(r,e,t)=>e in r?G(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y=(r,e)=>{for(var t in e||(e={}))ve.call(e,t)&&ye(r,t,e[t]);if(be)for(var t of be(e))je.call(e,t)&&ye(r,t,e[t]);return r},xe=(r,e)=>Se(r,Ae(e));var Re=(r,e)=>{for(var t in e)G(r,t,{get:e[t],enumerable:!0})},Me=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ie(e))!ve.call(r,s)&&s!==t&&G(r,s,{get:()=>e[s],enumerable:!(n=Ee(e,s))||n.enumerable});return r};var Le=r=>Me(G({},"__esModule",{value:!0}),r);var Pe={};Re(Pe,{ConfigValidationError:()=>m,Consent:()=>N,ConsentConfigBuilder:()=>U,ConsentEngine:()=>V,CookieStorageProvider:()=>D,CookieStore:()=>C,GoogleConsentAdapter:()=>E,I18nEngine:()=>ce,IframeGate:()=>M,IframeResourceBlocker:()=>ee,ImageResourceBlocker:()=>te,MemoryStorageProvider:()=>S,MemoryStore:()=>O,PolicyGenerator:()=>B,ResourceGate:()=>_,ResourceScanner:()=>q,ScriptGate:()=>R,ScriptResourceBlocker:()=>Z,StorageFactory:()=>ae,computeReceiptSignature:()=>z,createReceipt:()=>Y,isReceiptExpired:()=>X,parseReceipt:()=>Q,sanitizeHtml:()=>g,validateConfig:()=>P,verifyReceiptIntegrity:()=>Ce});var m=class extends Error{constructor(e){super(`[ConsentSDK Config Error] ${e}`),this.name="ConfigValidationError"}};function P(r){if(!r)throw new m("Configuration object is null or undefined.");if(typeof r.schemaVersion!="number"||r.schemaVersion<1)throw new m("Invalid or missing 'schemaVersion'. Expected integer >= 1.");if(!r.policyVersion||typeof r.policyVersion!="string")throw new m("Invalid or missing 'policyVersion'. String required.");if(!r.categories||typeof r.categories!="object")throw new m("Missing 'categories' map in configuration.");if(Object.keys(r.categories).length===0)throw new m("At least one category must be defined in 'categories'.");let t=r.categories.necessary;if(!t)throw new m("Category 'necessary' must be defined.");if(t.required!==!0)throw new m("Category 'necessary' must have 'required: true'.");for(let[n,s]of Object.entries(r.categories))if(n!=="necessary"&&!s.required&&s.default===!0)throw new m(`Legal violation (AEPD): Optional category '${n}' cannot have default: true. All optional categories must be opt-in (default: false).`);if(r.services&&typeof r.services=="object")for(let[n,s]of Object.entries(r.services)){if(!s.category)throw new m(`Service '${n}' missing 'category' reference.`);if(!r.categories[s.category])throw new m(`Service '${n}' references non-existent category '${s.category}'.`)}}var W=class{constructor(){this.state={initialized:!1,policyVersion:"",locale:"es",receipt:null,choices:{}};this.config=null}init(e,t,n){var s;this.config=e,this.state={initialized:!0,policyVersion:e.policyVersion,locale:((s=e.locale)==null?void 0:s.default)||"es",receipt:n,choices:t}}getConfig(){return this.config}getState(){return y({},this.state)}getChoices(){return y({},this.state.choices)}getReceipt(){return this.state.receipt}hasCategory(e){return this.state.choices[e]===!0}hasService(e){if(!this.config||!this.config.services)return!1;let t=this.config.services[e];return t?this.hasCategory(t.category):!1}updateChoices(e){this.state.receipt=e,this.state.choices=y({},e.choices)}clearChoices(){if(!this.config)return;let e={};for(let[t,n]of Object.entries(this.config.categories))e[t]=n.required===!0;this.state.choices=e,this.state.receipt=null}};var J=class{constructor(){this.handlers=new Map}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);let n=this.handlers.get(e);return n.add(t),()=>{n.delete(t)}}emit(e,t){let n=this.handlers.get(e);if(n)for(let s of n)try{s(t)}catch(o){console.error(`[ConsentSDK Event Error] Handler for '${e}' failed:`,o)}}clear(){this.handlers.clear()}};function $e(r){let e,t,n="",s=r.length*8,o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],c=[];for(e=0;e<r.length;e++)c[e>>2]|=r.charCodeAt(e)<<24-e%4*8;for(c[s>>5]|=128<<24-s%32,c[(s+64>>9<<4)+15]=s,e=0;e<c.length;e+=16){let a=c.slice(e,e+16),p=[...o];for(t=0;t<64;t++){let d=a[t-15],l=a[t-2],f=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,v=(l>>>17|l<<15)^(l>>>19|l<<13)^l>>>10;a[t]=t<16?a[t]||0:a[t-16]+f+a[t-7]+v|0;let u=o[4]&o[5]^~o[4]&o[6],w=o[0]&o[1]^o[0]&o[2]^o[1]&o[2],h=(o[0]>>>2|o[0]<<30)^(o[0]>>>13|o[0]<<19)^(o[0]>>>22|o[0]<<10),L=(o[4]>>>6|o[4]<<26)^(o[4]>>>11|o[4]<<21)^(o[4]>>>25|o[4]<<7),j=o[7]+L+u+i[t]+(a[t]|0),K=h+w;o[7]=o[6],o[6]=o[5],o[5]=o[4],o[4]=o[3]+j|0,o[3]=o[2],o[2]=o[1],o[1]=o[0],o[0]=j+K|0}for(t=0;t<8;t++)o[t]=o[t]+p[t]|0}for(e=0;e<8;e++)for(t=3;t>=0;t--){let a=o[e]>>t*8&255;n+=(a<16?"0":"")+a.toString(16)}return n}function z(r,e){if(e)return $e(`${e}:${r}:${e}`);let t=2166136261;for(let n=0;n<r.length;n++)t^=r.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function Ce(r,e,t){return e?z(r,t)===e:!1}function g(r){return r?r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""}function le(r){if(!r)return"#";let e=r.trim().toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:")||e.startsWith("vbscript:")?"#":r}function Te(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Y(r,e,t,n,s){let o=new Date().toISOString(),i=(n==null?void 0:n.receiptId)||Te(),c=(n==null?void 0:n.decidedAt)||o,a=`${i}:${r}:${JSON.stringify(e)}`,p=z(a,s);return{schema:1,receiptId:i,policyVersion:r,decidedAt:c,updatedAt:o,source:t,choices:e,signature:p}}function Q(r){try{let e=JSON.parse(r);return typeof e=="object"&&e!==null&&typeof e.receiptId=="string"&&typeof e.policyVersion=="string"&&typeof e.choices=="object"?e:null}catch(e){return null}}function X(r,e=365){if(!r.updatedAt)return!0;let t=new Date(r.updatedAt).getTime(),n=Date.now(),s=e*86400*1e3;return n-t>s}function we(r,e){var o,i,c;let t={};for(let[a,p]of Object.entries(r.categories))t[a]=p.required===!0;if(!e)return{isValid:!1,reason:"missing",choices:t};if(e.policyVersion!==r.policyVersion)return{isValid:!1,reason:"policy_version_changed",choices:t};let n=(i=(o=r.consent)==null?void 0:o.maxAgeDays)!=null?i:365;if(X(e,n))return{isValid:!1,reason:"expired",choices:t};if(e.signature){let a=`${e.receiptId}:${e.policyVersion}:${JSON.stringify(e.choices)}`,p=z(a,(c=r.security)==null?void 0:c.secretKey);if(e.signature!==p)return{isValid:!1,reason:"tampered",choices:t}}let s=y({},t);for(let a of Object.keys(r.categories))a==="necessary"?s[a]=!0:typeof e.choices[a]=="boolean"&&(s[a]=e.choices[a]);return{isValid:!0,reason:"valid",choices:s}}var D=class{get(e){return C.get(e)}set(e,t,n){C.set(e,t,n)}remove(e,t="/"){C.remove(e,t)}},C=class{static get(e){if(typeof document=="undefined")return null;let t=encodeURIComponent(e)+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let o=n[s];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return decodeURIComponent(o.substring(t.length,o.length))}return null}static set(e,t,n={}){var l,f;if(typeof document=="undefined")return;let s=n.path||"/",o=(l=n.maxAgeDays)!=null?l:365,i=Math.floor(o*86400),c=n.sameSite||"Lax",a=typeof window!="undefined"&&window.location.protocol==="https:",p=(f=n.secure)!=null?f:a,d=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; Path=${s}; Max-Age=${i}; SameSite=${c}`;p&&(d+="; Secure"),document.cookie=d}static remove(e,t="/"){typeof document!="undefined"&&(document.cookie=`${encodeURIComponent(e)}=; Path=${t}; Max-Age=0; SameSite=Lax`)}};var H=class H{get(e){var t;return(t=H.store.get(e))!=null?t:null}set(e,t){H.store.set(e,t)}remove(e){H.store.delete(e)}clear(){H.store.clear()}};H.store=new Map;var S=H,O={get:r=>new S().get(r),set:(r,e)=>new S().set(r,e),remove:r=>new S().remove(r),clear:()=>new S().clear()};var Z=class{constructor(){this.type="script"}process(e,t){R.scanAndActivate(e,t)}},R=class{static scanAndActivate(e,t,n){var o;if(typeof document=="undefined")return;let s=Array.from(document.querySelectorAll('script[type="text/plain"][data-consent], script[type="text/plain"][data-service]'));for(let i of s){if(this.executedScripts.has(i))continue;let c=i.getAttribute("data-consent"),a=i.getAttribute("data-service"),p=!1;if(a?p=t(a):c&&(p=e(c)),!p)continue;this.executedScripts.add(i);let d=document.createElement("script");for(let l=0;l<i.attributes.length;l++){let f=i.attributes[l];if(f.name!=="type"){if(f.name==="data-src"){d.src=f.value;continue}d.setAttribute(f.name,f.value)}}d.type="text/javascript",!d.src&&i.textContent&&(d.textContent=i.textContent),(o=i.parentNode)==null||o.replaceChild(d,i),(a||c)&&(n==null||n(a||c,c||"custom"))}}};R.executedScripts=new Set;var ee=class{constructor(){this.type="iframe"}process(e,t){M.processIframes(e,t)}},M=class{static processIframes(e,t,n={}){if(typeof document=="undefined")return;let s=Array.from(document.querySelectorAll("iframe[data-consent], iframe[data-service]"));for(let o of s){let i=o.getAttribute("data-consent"),c=o.getAttribute("data-service"),a=!1;c?a=t(c):i&&(a=e(i));let p=o.getAttribute("data-src")||o.getAttribute("src");p&&(o.getAttribute("data-src")||o.setAttribute("data-src",p),a?this.unlockIframe(o,p):this.lockIframe(o,i||"marketing",c||void 0,n))}}static lockIframe(e,t,n,s){var p;if(e.hasAttribute("src")&&e.removeAttribute("src"),this.placeholders.has(e))return;let o=document.createElement("div");o.className="consent-iframe-placeholder",o.style.cssText=`
2
+ width: ${e.width?e.width.endsWith("%")||e.width.endsWith("px")?e.width:e.width+"px":"100%"};
3
+ height: ${e.height?e.height.endsWith("%")||e.height.endsWith("px")?e.height:e.height+"px":"315px"};
4
+ min-height: 200px;
5
+ background: #0f172a;
6
+ color: #f8fafc;
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ justify-content: center;
11
+ text-align: center;
12
+ padding: 1.5rem;
13
+ border-radius: 8px;
14
+ box-sizing: border-box;
15
+ font-family: system-ui, -apple-system, sans-serif;
16
+ `;let i=n?`Contenido de ${n} bloqueado`:"Contenido externo bloqueado",c="Este contenido est\xE1 bloqueado hasta que autorices esta finalidad de privacidad.";o.innerHTML=`
17
+ <div style="font-weight: 600; font-size: 1.1rem; margin-bottom: 0.5rem; color: #f8fafc;">
18
+ ${i}
19
+ </div>
20
+ <p style="font-size: 0.9rem; color: #94a3b8; margin: 0 0 1rem 0; max-width: 400px;">
21
+ ${c}
22
+ </p>
23
+ <button type="button" class="consent-placeholder-allow-btn" style="
24
+ background: #2563eb;
25
+ color: #ffffff;
26
+ border: none;
27
+ padding: 0.6rem 1.2rem;
28
+ border-radius: 6px;
29
+ font-weight: 500;
30
+ cursor: pointer;
31
+ font-size: 0.9rem;
32
+ transition: background 0.2s ease;
33
+ ">
34
+ Permitir y mostrar contenido
35
+ </button>
36
+ `;let a=o.querySelector(".consent-placeholder-allow-btn");a==null||a.addEventListener("click",()=>{var d;(d=s.onAllowClick)==null||d.call(s,t,n)}),e.style.display="none",(p=e.parentNode)==null||p.insertBefore(o,e),this.placeholders.set(e,o)}static unlockIframe(e,t){var s;e.getAttribute("src")!==t&&e.setAttribute("src",t),e.style.display="";let n=this.placeholders.get(e);n&&((s=n.parentNode)==null||s.removeChild(n),this.placeholders.delete(e))}};M.placeholders=new Map;var te=class{constructor(){this.type="image"}process(e,t){_.processImages(e,t)}},_=class{static processImages(e,t){if(typeof document=="undefined")return;let n=Array.from(document.querySelectorAll("img[data-consent], img[data-service]"));for(let s of n){let o=s.getAttribute("data-consent"),i=s.getAttribute("data-service"),c=!1;i?c=t(i):o&&(c=e(o));let a=s.getAttribute("data-src")||s.getAttribute("src");a&&(s.getAttribute("data-src")||s.setAttribute("data-src",a),c?s.getAttribute("src")!==a&&s.setAttribute("src",a):s.hasAttribute("src")&&s.removeAttribute("src"))}}};var ne=class{constructor(){this.observer=null}init(e,t,n,s){let o=()=>{R.scanAndActivate(e,t,s),M.processIframes(e,t,n),_.processImages(e,t)};o(),typeof MutationObserver!="undefined"&&typeof document!="undefined"&&(this.observer=new MutationObserver(()=>{o()}),this.observer.observe(document.documentElement||document.body,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null)}};var E=class{static initDefault(e){typeof window!="undefined"&&(window.dataLayer=window.dataLayer||[],window.gtag||(window.gtag=function(){var t;(t=window.dataLayer)==null||t.push(arguments)}),this.initialized||(window.gtag("consent","default",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",wait_for_update:500}),this.initialized=!0))}static update(e,t){if(typeof window=="undefined")return;this.initDefault(t);let n=(t==null?void 0:t.analytics_storage)||"analytics",s=(t==null?void 0:t.ad_storage)||"marketing",o=e[n]===!0,i=e[s]===!0;window.gtag("consent","update",{analytics_storage:o?"granted":"denied",ad_storage:i?"granted":"denied",ad_user_data:i?"granted":"denied",ad_personalization:i?"granted":"denied"})}};E.initialized=!1;var oe=class{static createWhen(e,t,n){return function(o,i){if(t(o)||n(o))try{i()}catch(c){console.error("[ConsentSDK when()] Callback execution failed:",c)}return e.on("consent:changed",({choices:c})=>{if(c[o]===!0||n(o))try{i()}catch(a){console.error("[ConsentSDK when()] Callback execution failed:",a)}})}}};function re(r){if(typeof document=="undefined")return;let e=document.getElementById("consent-sdk-styles");e&&e.remove();let t=document.createElement("style");t.id="consent-sdk-styles",r&&t.setAttribute("nonce",r),t.textContent=`
37
+ :root {
38
+ --consent-bg: #ffffff;
39
+ --consent-fg: #0f172a;
40
+ --consent-muted: #64748b;
41
+ --consent-divider: #f1f5f9;
42
+ --consent-border: #e2e8f0;
43
+ --consent-hover-bg: #f8fafc;
44
+ --consent-primary: #0f172a;
45
+ --consent-primary-hover: #1e293b;
46
+ --consent-primary-fg: #ffffff;
47
+ --consent-secondary: #f8fafc;
48
+ --consent-secondary-hover: #f1f5f9;
49
+ --consent-secondary-fg: #0f172a;
50
+ --consent-accent: #2563eb;
51
+ --consent-focus-ring: rgba(37, 99, 235, 0.3);
52
+ --consent-font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
53
+ --consent-modal-shadow: 0 32px 64px -16px rgba(15, 23, 42, 0.2), 0 0 1px rgba(15, 23, 42, 0.12);
54
+ }
55
+
56
+ @media (prefers-color-scheme: dark) {
57
+ :root {
58
+ --consent-bg: #0f172a;
59
+ --consent-fg: #f8fafc;
60
+ --consent-muted: #94a3b8;
61
+ --consent-divider: #1e293b;
62
+ --consent-border: #334155;
63
+ --consent-hover-bg: #1e293b;
64
+ --consent-primary: #f8fafc;
65
+ --consent-primary-hover: #ffffff;
66
+ --consent-primary-fg: #0f172a;
67
+ --consent-secondary: #1e293b;
68
+ --consent-secondary-hover: #334155;
69
+ --consent-secondary-fg: #f8fafc;
70
+ --consent-modal-shadow: 0 32px 64px -16px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.12);
71
+ }
72
+ }
73
+
74
+ @keyframes consentSlideUp {
75
+ from {
76
+ opacity: 0;
77
+ transform: translateY(16px) scale(0.985);
78
+ }
79
+ to {
80
+ opacity: 1;
81
+ transform: translateY(0) scale(1);
82
+ }
83
+ }
84
+
85
+ @keyframes consentFadeIn {
86
+ from { opacity: 0; }
87
+ to { opacity: 1; }
88
+ }
89
+
90
+ /* 1st Layer Banner - Clean & Seamless */
91
+ .consent-banner-wrapper {
92
+ position: fixed;
93
+ bottom: 1.25rem;
94
+ left: 1.25rem;
95
+ right: 1.25rem;
96
+ max-width: 1060px;
97
+ margin: 0 auto;
98
+ z-index: 2147483645;
99
+ background: var(--consent-bg);
100
+ color: var(--consent-fg);
101
+ border: 1px solid var(--consent-border);
102
+ border-radius: 20px;
103
+ box-shadow: var(--consent-modal-shadow);
104
+ padding: 1.5rem 1.75rem;
105
+ font-family: var(--consent-font);
106
+ font-size: 0.92rem;
107
+ line-height: 1.5;
108
+ animation: consentSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
109
+ box-sizing: border-box;
110
+ }
111
+
112
+ .consent-banner-container {
113
+ display: flex;
114
+ flex-direction: column;
115
+ gap: 1.25rem;
116
+ }
117
+
118
+ @media (min-width: 860px) {
119
+ .consent-banner-container {
120
+ flex-direction: row;
121
+ align-items: center;
122
+ justify-content: space-between;
123
+ }
124
+ }
125
+
126
+ .consent-banner-text {
127
+ flex: 1;
128
+ }
129
+
130
+ .consent-banner-title {
131
+ font-size: 1.1rem;
132
+ font-weight: 700;
133
+ letter-spacing: -0.015em;
134
+ margin: 0 0 0.35rem 0;
135
+ color: var(--consent-fg);
136
+ display: flex;
137
+ align-items: center;
138
+ gap: 0.5rem;
139
+ }
140
+
141
+ .consent-banner-title-icon {
142
+ display: inline-flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ width: 22px;
146
+ height: 22px;
147
+ border-radius: 6px;
148
+ background: rgba(37, 99, 235, 0.1);
149
+ color: var(--consent-accent);
150
+ }
151
+
152
+ .consent-banner-desc {
153
+ margin: 0;
154
+ color: var(--consent-muted);
155
+ font-size: 0.88rem;
156
+ max-width: 720px;
157
+ }
158
+
159
+ .consent-banner-links {
160
+ margin-top: 0.4rem;
161
+ }
162
+
163
+ .consent-banner-links a {
164
+ color: var(--consent-muted);
165
+ font-size: 0.83rem;
166
+ text-decoration: underline;
167
+ text-underline-offset: 3px;
168
+ font-weight: 500;
169
+ margin-right: 1.2rem;
170
+ transition: color 0.15s ease;
171
+ }
172
+
173
+ .consent-banner-links a:hover {
174
+ color: var(--consent-fg);
175
+ }
176
+
177
+ /* Equal Visual Prominence CTAs */
178
+ .consent-banner-actions {
179
+ display: flex;
180
+ flex-direction: column;
181
+ gap: 0.5rem;
182
+ width: 100%;
183
+ }
184
+
185
+ @media (min-width: 640px) {
186
+ .consent-banner-actions {
187
+ flex-direction: row;
188
+ width: auto;
189
+ align-items: center;
190
+ }
191
+ }
192
+
193
+ .consent-btn {
194
+ display: inline-flex;
195
+ align-items: center;
196
+ justify-content: center;
197
+ padding: 0.6rem 1.2rem;
198
+ font-size: 0.88rem;
199
+ font-weight: 600;
200
+ border-radius: 10px;
201
+ border: 1px solid var(--consent-border);
202
+ cursor: pointer;
203
+ font-family: inherit;
204
+ transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
205
+ min-height: 42px;
206
+ min-width: 110px;
207
+ box-sizing: border-box;
208
+ user-select: none;
209
+ }
210
+
211
+ .consent-btn:hover {
212
+ transform: translateY(-1px);
213
+ }
214
+
215
+ .consent-btn:active {
216
+ transform: translateY(0) scale(0.98);
217
+ }
218
+
219
+ .consent-btn:focus-visible {
220
+ outline: 3px solid var(--consent-focus-ring);
221
+ outline-offset: 2px;
222
+ }
223
+
224
+ .consent-btn-reject {
225
+ background: var(--consent-secondary);
226
+ color: var(--consent-secondary-fg);
227
+ border-color: var(--consent-border);
228
+ }
229
+
230
+ .consent-btn-reject:hover {
231
+ background: var(--consent-secondary-hover);
232
+ }
233
+
234
+ .consent-btn-configure {
235
+ background: transparent;
236
+ color: var(--consent-muted);
237
+ border-color: transparent;
238
+ }
239
+
240
+ .consent-btn-configure:hover {
241
+ color: var(--consent-fg);
242
+ background: var(--consent-secondary);
243
+ }
244
+
245
+ .consent-btn-accept {
246
+ background: var(--consent-primary);
247
+ color: var(--consent-primary-fg);
248
+ border-color: var(--consent-primary);
249
+ }
250
+
251
+ .consent-btn-accept:hover {
252
+ background: var(--consent-primary-hover);
253
+ }
254
+
255
+ /* 2nd Layer Preference Modal - Ultra Clean Linear List Style */
256
+ .consent-dialog-backdrop {
257
+ position: fixed;
258
+ top: 0;
259
+ left: 0;
260
+ width: 100vw;
261
+ height: 100vh;
262
+ background: rgba(15, 23, 42, 0.45);
263
+ backdrop-filter: blur(8px);
264
+ -webkit-backdrop-filter: blur(8px);
265
+ z-index: 2147483646;
266
+ display: flex;
267
+ align-items: center;
268
+ justify-content: center;
269
+ padding: 1.25rem;
270
+ box-sizing: border-box;
271
+ animation: consentFadeIn 0.2s ease forwards;
272
+ }
273
+
274
+ .consent-dialog {
275
+ background: var(--consent-bg);
276
+ color: var(--consent-fg);
277
+ border: 1px solid var(--consent-border);
278
+ border-radius: 20px;
279
+ width: 100%;
280
+ max-width: 600px;
281
+ max-height: 85vh;
282
+ display: flex;
283
+ flex-direction: column;
284
+ box-shadow: var(--consent-modal-shadow);
285
+ font-family: var(--consent-font);
286
+ overflow: hidden;
287
+ animation: consentSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
288
+ }
289
+
290
+ .consent-dialog-header {
291
+ padding: 1.5rem 1.75rem 1.25rem 1.75rem;
292
+ border-bottom: 1px solid var(--consent-divider);
293
+ display: flex;
294
+ justify-content: space-between;
295
+ align-items: flex-start;
296
+ }
297
+
298
+ .consent-dialog-title {
299
+ font-size: 1.15rem;
300
+ font-weight: 700;
301
+ letter-spacing: -0.015em;
302
+ margin: 0;
303
+ }
304
+
305
+ .consent-dialog-close {
306
+ background: transparent;
307
+ border: none;
308
+ color: var(--consent-muted);
309
+ cursor: pointer;
310
+ padding: 0.35rem;
311
+ border-radius: 8px;
312
+ display: flex;
313
+ align-items: center;
314
+ justify-content: center;
315
+ transition: background 0.15s ease, color 0.15s ease;
316
+ margin: -0.35rem -0.35rem 0 0;
317
+ }
318
+
319
+ .consent-dialog-close:hover {
320
+ background: var(--consent-secondary);
321
+ color: var(--consent-fg);
322
+ }
323
+
324
+ /* Seamless Category List Body (NO individual boxed divs) */
325
+ .consent-dialog-body {
326
+ padding: 0;
327
+ overflow-y: auto;
328
+ display: flex;
329
+ flex-direction: column;
330
+ }
331
+
332
+ .consent-category-row {
333
+ padding: 1.25rem 1.75rem;
334
+ border-bottom: 1px solid var(--consent-divider);
335
+ transition: background 0.15s ease;
336
+ }
337
+
338
+ .consent-category-row:last-child {
339
+ border-bottom: none;
340
+ }
341
+
342
+ .consent-category-row:hover {
343
+ background: var(--consent-hover-bg);
344
+ }
345
+
346
+ .consent-category-header {
347
+ display: flex;
348
+ justify-content: space-between;
349
+ align-items: flex-start;
350
+ gap: 1rem;
351
+ }
352
+
353
+ .consent-category-name {
354
+ font-weight: 600;
355
+ font-size: 0.95rem;
356
+ color: var(--consent-fg);
357
+ }
358
+
359
+ .consent-category-desc {
360
+ margin: 0.3rem 0 0 0;
361
+ font-size: 0.85rem;
362
+ color: var(--consent-muted);
363
+ line-height: 1.45;
364
+ }
365
+
366
+ /* Minimalist Badges */
367
+ .consent-badge {
368
+ display: inline-flex;
369
+ align-items: center;
370
+ padding: 0.15rem 0.5rem;
371
+ border-radius: 6px;
372
+ font-size: 0.7rem;
373
+ font-weight: 600;
374
+ letter-spacing: 0.01em;
375
+ }
376
+
377
+ .consent-badge-required {
378
+ background: rgba(16, 185, 129, 0.1);
379
+ color: #059669;
380
+ }
381
+
382
+ .consent-badge-optional {
383
+ background: rgba(100, 116, 139, 0.08);
384
+ color: var(--consent-muted);
385
+ }
386
+
387
+ /* Inline Service Disclosure Button */
388
+ .consent-toggle-services-btn {
389
+ border: none;
390
+ background: transparent;
391
+ color: var(--consent-accent);
392
+ font-size: 0.78rem;
393
+ font-weight: 600;
394
+ cursor: pointer;
395
+ padding: 0.35rem 0 0 0;
396
+ display: inline-flex;
397
+ align-items: center;
398
+ gap: 0.25rem;
399
+ font-family: inherit;
400
+ }
401
+
402
+ .consent-toggle-services-btn:hover {
403
+ opacity: 0.85;
404
+ }
405
+
406
+ /* Minimalist Toggle Switch */
407
+ .consent-toggle {
408
+ position: relative;
409
+ display: inline-block;
410
+ width: 40px;
411
+ height: 22px;
412
+ flex-shrink: 0;
413
+ margin-top: 0.15rem;
414
+ }
415
+
416
+ .consent-toggle input {
417
+ opacity: 0;
418
+ width: 0;
419
+ height: 0;
420
+ }
421
+
422
+ .consent-toggle-slider {
423
+ position: absolute;
424
+ cursor: pointer;
425
+ top: 0; left: 0; right: 0; bottom: 0;
426
+ background-color: #cbd5e1;
427
+ transition: background-color 0.2s ease;
428
+ border-radius: 22px;
429
+ }
430
+
431
+ .consent-toggle-slider:before {
432
+ position: absolute;
433
+ content: "";
434
+ height: 16px;
435
+ width: 16px;
436
+ left: 3px;
437
+ bottom: 3px;
438
+ background-color: white;
439
+ transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
440
+ border-radius: 50%;
441
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
442
+ }
443
+
444
+ .consent-toggle input:checked + .consent-toggle-slider {
445
+ background-color: var(--consent-accent);
446
+ }
447
+
448
+ .consent-toggle input:checked + .consent-toggle-slider:before {
449
+ transform: translateX(18px);
450
+ }
451
+
452
+ .consent-toggle input:disabled + .consent-toggle-slider {
453
+ opacity: 0.45;
454
+ cursor: not-allowed;
455
+ }
456
+
457
+ /* Footer */
458
+ .consent-dialog-footer {
459
+ padding: 1.25rem 1.75rem;
460
+ border-top: 1px solid var(--consent-divider);
461
+ background: var(--consent-bg);
462
+ display: flex;
463
+ flex-direction: column;
464
+ gap: 0.6rem;
465
+ justify-content: space-between;
466
+ align-items: center;
467
+ }
468
+
469
+ @media (min-width: 520px) {
470
+ .consent-dialog-footer {
471
+ flex-direction: row;
472
+ }
473
+ }
474
+ `,document.head.appendChild(t)}var se=class{constructor(){this.element=null}render(e,t){var f,v,u,w,h,L,j;if(typeof document=="undefined")return;this.remove(),re((f=e.csp)==null?void 0:f.nonce);let n=((v=e.ui)==null?void 0:v.banner)||{},s=g(n.title||"Tu privacidad, bajo tu control"),o=g(n.description||"Usamos tecnolog\xEDas necesarias para el funcionamiento del sitio. Con tu permiso, tambi\xE9n podemos utilizar anal\xEDtica y marketing."),i=g(n.accept||"Aceptar todas"),c=g(n.reject||"Rechazar todas"),a=g(n.configure||"Configurar"),p=le(((u=e.policy)==null?void 0:u.privacyUrl)||"/politica-privacidad"),d=le(((w=e.policy)==null?void 0:w.cookiesUrl)||"/politica-cookies"),l=document.createElement("div");l.className="consent-banner-wrapper",l.setAttribute("role","region"),l.setAttribute("aria-label","Gesti\xF3n de consentimiento de privacidad"),l.innerHTML=`
475
+ <div class="consent-banner-container">
476
+ <div class="consent-banner-text">
477
+ <h2 class="consent-banner-title">
478
+ <span class="consent-banner-title-icon">
479
+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
480
+ <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
481
+ </svg>
482
+ </span>
483
+ ${s}
484
+ </h2>
485
+ <p class="consent-banner-desc">${o}</p>
486
+ <div class="consent-banner-links">
487
+ <a href="${d}" target="_blank" rel="noopener">Pol\xEDtica de cookies</a>
488
+ <a href="${p}" target="_blank" rel="noopener">Pol\xEDtica de privacidad</a>
489
+ </div>
490
+ </div>
491
+ <div class="consent-banner-actions">
492
+ <button type="button" class="consent-btn consent-btn-reject" id="consent-btn-reject">
493
+ ${c}
494
+ </button>
495
+ <button type="button" class="consent-btn consent-btn-configure" id="consent-btn-configure">
496
+ ${a}
497
+ </button>
498
+ <button type="button" class="consent-btn consent-btn-accept" id="consent-btn-accept">
499
+ ${i}
500
+ </button>
501
+ </div>
502
+ </div>
503
+ `,(h=l.querySelector("#consent-btn-reject"))==null||h.addEventListener("click",()=>{t.onRejectAll(),this.remove()}),(L=l.querySelector("#consent-btn-configure"))==null||L.addEventListener("click",()=>{t.onConfigure()}),(j=l.querySelector("#consent-btn-accept"))==null||j.addEventListener("click",()=>{t.onAcceptAll(),this.remove()}),document.body.appendChild(l),this.element=l}remove(){this.element&&this.element.parentNode&&(this.element.parentNode.removeChild(this.element),this.element=null)}};var ie=class{constructor(){this.backdrop=null;this.lastFocusedElement=null}render(e,t,n){var L,j,K,pe,fe,ge,ue;if(typeof document=="undefined")return;this.close(),re((L=e.csp)==null?void 0:L.nonce),this.lastFocusedElement=document.activeElement;let s=((j=e.ui)==null?void 0:j.preferences)||{},o=g(s.title||"Preferencias de privacidad"),i=g(s.save||"Guardar selecci\xF3n"),c=g(s.acceptAll||"Permitir todas"),a=g(s.rejectAll||"Rechazar opcionales"),p=document.createElement("div");p.className="consent-dialog-backdrop";let d=document.createElement("div");d.className="consent-dialog",d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("aria-labelledby","consent-dialog-title-id");let l=document.createElement("div");l.className="consent-dialog-header",l.innerHTML=`
504
+ <div>
505
+ <h2 class="consent-dialog-title" id="consent-dialog-title-id">${o}</h2>
506
+ <p style="margin: 0.2rem 0 0 0; font-size: 0.84rem; color: var(--consent-muted); font-weight: 400;">
507
+ Gestiona tus permisos de almacenamiento por finalidad (LSSI art. 22.2 &amp; RGPD).
508
+ </p>
509
+ </div>
510
+ <button type="button" class="consent-dialog-close" aria-label="Cerrar ventana">
511
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round">
512
+ <line x1="18" y1="6" x2="6" y2="18"></line>
513
+ <line x1="6" y1="6" x2="18" y2="18"></line>
514
+ </svg>
515
+ </button>
516
+ `;let f=document.createElement("div");f.className="consent-dialog-body";let v=y({},t);for(let[b,$]of Object.entries(e.categories)){let x=document.createElement("div");x.className="consent-category-row";let A=$.required===!0,ke=A?!0:(K=v[b])!=null?K:!1,T=e.services?Object.entries(e.services).filter(([I,k])=>k.category===b):[],me="";if(T.length>0&&(me=`
517
+ <div class="consent-category-services" id="cat-services-${b}" style="display: none; margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px dashed var(--consent-divider); font-size: 0.82rem;">
518
+ <div style="font-weight: 600; color: var(--consent-muted); margin-bottom: 0.4rem; font-size: 0.75rem; letter-spacing: 0.02em;">
519
+ Servicios incluidos (${T.length})
520
+ </div>
521
+ <div style="display: flex; flex-direction: column; gap: 0.3rem;">
522
+ ${T.map(([I,k])=>`
523
+ <div style="display: flex; justify-content: space-between; align-items: center; padding: 0.2rem 0;">
524
+ <span style="font-weight: 500;">${g(k.label||I)}</span>
525
+ <span style="color: var(--consent-muted); font-size: 0.78rem;">${g(k.provider||"Terceros")}</span>
526
+ </div>
527
+ `).join("")}
528
+ </div>
529
+ </div>
530
+ `),x.innerHTML=`
531
+ <div class="consent-category-header">
532
+ <div style="flex: 1; padding-right: 1rem;">
533
+ <div style="display: flex; align-items: center; gap: 0.4rem;">
534
+ <span class="consent-category-name">${g($.label)}</span>
535
+ ${A?'<span class="consent-badge consent-badge-required">Requerida</span>':'<span class="consent-badge consent-badge-optional">Opcional</span>'}
536
+ </div>
537
+ <p class="consent-category-desc">${g($.description)}</p>
538
+ ${T.length>0?`<button type="button" class="consent-toggle-services-btn" data-target="cat-services-${b}">
539
+ Ver servicios (${T.length}) \u25BE
540
+ </button>`:""}
541
+ </div>
542
+ <label class="consent-toggle">
543
+ <input type="checkbox" id="cat-toggle-${b}" ${ke?"checked":""} ${A?"disabled":""}>
544
+ <span class="consent-toggle-slider"></span>
545
+ </label>
546
+ </div>
547
+ ${me}
548
+ `,!A){let I=x.querySelector(`#cat-toggle-${b}`);I==null||I.addEventListener("change",k=>{v[b]=k.target.checked})}let F=x.querySelector(".consent-toggle-services-btn");F&&F.addEventListener("click",()=>{let I=F.getAttribute("data-target");if(I){let k=x.querySelector(`#${I}`);if(k){let he=k.style.display==="none";k.style.display=he?"block":"none",F.textContent=he?`Ocultar servicios (${T.length}) \u25B4`:`Ver servicios (${T.length}) \u25BE`}}}),f.appendChild(x)}let u=document.createElement("div");u.className="consent-dialog-footer",u.innerHTML=`
549
+ <button type="button" class="consent-btn consent-btn-reject" id="consent-pref-reject">
550
+ ${a}
551
+ </button>
552
+ <div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
553
+ <button type="button" class="consent-btn consent-btn-configure" id="consent-pref-accept">
554
+ ${c}
555
+ </button>
556
+ <button type="button" class="consent-btn consent-btn-accept" id="consent-pref-save">
557
+ ${i}
558
+ </button>
559
+ </div>
560
+ `,d.appendChild(l),d.appendChild(f),d.appendChild(u),p.appendChild(d),(pe=l.querySelector(".consent-dialog-close"))==null||pe.addEventListener("click",()=>{n.onClose(),this.close()}),(fe=u.querySelector("#consent-pref-reject"))==null||fe.addEventListener("click",()=>{n.onRejectAll(),this.close()}),(ge=u.querySelector("#consent-pref-accept"))==null||ge.addEventListener("click",()=>{n.onAcceptAll(),this.close()}),(ue=u.querySelector("#consent-pref-save"))==null||ue.addEventListener("click",()=>{n.onSave(v),this.close()});let w=b=>{if(b.key==="Escape"){n.onClose(),this.close();return}if(b.key==="Tab"){let $=d.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),x=$[0],A=$[$.length-1];b.shiftKey?document.activeElement===x&&(A==null||A.focus(),b.preventDefault()):document.activeElement===A&&(x==null||x.focus(),b.preventDefault())}};document.addEventListener("keydown",w),this._keyListener=w,document.body.appendChild(p),this.backdrop=p;let h=d.querySelector("button");h==null||h.focus()}close(){this._keyListener&&(document.removeEventListener("keydown",this._keyListener),delete this._keyListener),this.backdrop&&this.backdrop.parentNode&&(this.backdrop.parentNode.removeChild(this.backdrop),this.backdrop=null),this.lastFocusedElement&&typeof this.lastFocusedElement.focus=="function"&&(this.lastFocusedElement.focus(),this.lastFocusedElement=null)}};var q=class r{static runDiagnostic(e,t){let n=[];return typeof document!="undefined"&&document.querySelectorAll("script[src]").forEach(o=>{let i=o.getAttribute("src");i&&(i.startsWith("http://")||i.startsWith("https://"))&&n.push(i)}),{timestamp:new Date().toISOString(),unblockedThirdPartyScripts:t?[]:n,compliant:t||n.length===0}}scanThirdPartyResources(){return r.runDiagnostic({},!0).unblockedThirdPartyScripts}};var B=class{static renderTable(e){let t=`
561
+ <div class="consent-policy-table-wrapper" style="margin: 1.5rem 0; font-family: system-ui, sans-serif;">
562
+ <table style="width: 100%; border-collapse: collapse; text-align: left; border: 1px solid #e2e8f0;">
563
+ <thead>
564
+ <tr style="background: #f8fafc; border-bottom: 2px solid #cbd5e1;">
565
+ <th style="padding: 0.75rem; border: 1px solid #e2e8f0;">Categor\xEDa / Servicio</th>
566
+ <th style="padding: 0.75rem; border: 1px solid #e2e8f0;">Proveedor</th>
567
+ <th style="padding: 0.75rem; border: 1px solid #e2e8f0;">Finalidad</th>
568
+ <th style="padding: 0.75rem; border: 1px solid #e2e8f0;">Requerida</th>
569
+ </tr>
570
+ </thead>
571
+ <tbody>
572
+ `;for(let[n,s]of Object.entries(e.categories)){let o=s.required?"S\xED (T\xE9cnica)":"No (Opcional)";if(t+=`
573
+ <tr style="background: #ffffff; font-weight: 600;">
574
+ <td style="padding: 0.75rem; border: 1px solid #e2e8f0;" colspan="3">${g(s.label)}</td>
575
+ <td style="padding: 0.75rem; border: 1px solid #e2e8f0;">${o}</td>
576
+ </tr>
577
+ `,e.services)for(let[i,c]of Object.entries(e.services))c.category===n&&(t+=`
578
+ <tr style="background: #f8fafc; font-size: 0.9rem;">
579
+ <td style="padding: 0.5rem 0.75rem 0.5rem 1.5rem; border: 1px solid #e2e8f0;">\u21B3 ${g(c.label||i)}</td>
580
+ <td style="padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;">${g(c.provider||"-")}</td>
581
+ <td style="padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;">${g(s.description||"-")}</td>
582
+ <td style="padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;">${o}</td>
583
+ </tr>
584
+ `)}return t+=`
585
+ </tbody>
586
+ </table>
587
+ </div>
588
+ `,t}};var V=class{constructor(){this.stateManager=new W;this.eventBus=new J;this.blockerRegistry=new ne;this.banner=new se;this.preferencesModal=new ie;this.initPromise=null;this.resolveReady=null;this.readyPromise=new Promise(e=>{this.resolveReady=e})}async init(e){return this.initPromise?this.initPromise:(this.initPromise=(async()=>{var a,p,d;let t;if(typeof e=="string"){let l=await fetch(e);if(!l.ok)throw new Error(`[ConsentSDK] Failed to fetch consent configuration from '${e}' (HTTP ${l.status})`);t=await l.json()}else t=e;P(t);let n=((a=t.storage)==null?void 0:a.name)||"site_consent",s=((p=t.storage)==null?void 0:p.type)==="memory"?O.get(n):C.get(n),o=s?Q(s):null,i=we(t,o),c=i.isValid?o:null;this.stateManager.init(t,i.choices,c),E.initDefault(),i.isValid&&E.update(i.choices),this.blockerRegistry.init(l=>this.has(l),l=>this.hasService(l),{onAllowClick:l=>{let f=this.stateManager.getChoices();f[l]=!0,this.setPreferences(f)}},(l,f)=>{this.eventBus.emit("service:loaded",{serviceId:l,category:f})}),this.setupGlobalRevocationTrigger(),(d=this.resolveReady)==null||d.call(this),this.eventBus.emit("ready",{state:this.getConsent()}),i.isValid||this.showBanner()})(),this.initPromise)}async ready(){return this.readyPromise}getConsent(){return this.stateManager.getState()}has(e){return this.stateManager.hasCategory(e)}hasService(e){return this.stateManager.hasService(e)}acceptAll(){let e=this.stateManager.getConfig();if(!e)return;let t={};for(let n of Object.keys(e.categories))t[n]=!0;this.saveChoices(t,"banner"),this.eventBus.emit("consent:accepted",{choices:t,receipt:this.getReceipt()})}rejectAll(){let e=this.stateManager.getConfig();if(!e)return;let t={};for(let[n,s]of Object.entries(e.categories))t[n]=s.required===!0;this.saveChoices(t,"banner"),this.eventBus.emit("consent:rejected",{choices:t,receipt:this.getReceipt()})}setPreferences(e){if(!this.stateManager.getConfig())return;let n=y({},e);n.necessary=!0,this.saveChoices(n,"preferences")}openPreferences(){let e=this.stateManager.getConfig();e&&(this.preferencesModal.render(e,this.stateManager.getChoices(),{onSave:t=>this.setPreferences(t),onAcceptAll:()=>this.acceptAll(),onRejectAll:()=>this.rejectAll(),onClose:()=>{this.eventBus.emit("preferences:closed",void 0)}}),this.eventBus.emit("preferences:opened",void 0))}closePreferences(){this.preferencesModal.close()}withdraw(){var s,o;let e=this.stateManager.getChoices(),t=this.stateManager.getConfig();if(!t)return;let n=((s=t.storage)==null?void 0:s.name)||"site_consent";((o=t.storage)==null?void 0:o.type)==="memory"?O.remove(n):C.remove(n),this.stateManager.clearChoices(),E.update(this.stateManager.getChoices()),this.eventBus.emit("consent:withdrawn",{previousChoices:e}),this.showBanner()}when(e,t){return oe.createWhen(this.eventBus,n=>this.has(n),n=>this.hasService(n))(e,t)}on(e,t){return this.eventBus.on(e,t)}getReceipt(){return this.stateManager.getReceipt()}rescan(){let e=this.stateManager.getConfig();if(!e)throw new Error("[ConsentSDK] SDK not initialized.");let t=!!this.getReceipt();return q.runDiagnostic(e,t)}mountPolicy(e){let t=this.stateManager.getConfig();if(!t)throw new Error("[ConsentSDK] SDK not initialized.");let n=typeof e=="string"?document.querySelector(e):e;n&&(n.innerHTML=B.renderTable(t))}saveChoices(e,t){var c,a,p,d,l,f,v,u,w;let n=this.stateManager.getConfig();if(!n)return;let s=Y(n.policyVersion,e,t,this.stateManager.getReceipt(),(c=n.security)==null?void 0:c.secretKey);this.stateManager.updateChoices(s);let o=((a=n.storage)==null?void 0:a.name)||"site_consent",i=JSON.stringify(s);if(((p=n.storage)==null?void 0:p.type)==="memory"?O.set(o,i):C.set(o,i,{path:((d=n.storage)==null?void 0:d.path)||"/",maxAgeDays:(f=(l=n.consent)==null?void 0:l.maxAgeDays)!=null?f:365,sameSite:((v=n.storage)==null?void 0:v.sameSite)||"Lax",secure:(u=n.storage)==null?void 0:u.secure}),E.update(e),this.blockerRegistry.init(h=>this.has(h),h=>this.hasService(h)),(w=n.logging)!=null&&w.enabled&&n.logging.endpoint)try{fetch(n.logging.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:i}).catch(()=>{})}catch(h){}this.banner.remove(),this.eventBus.emit("consent:changed",{choices:e,receipt:s})}showBanner(){let e=this.stateManager.getConfig();e&&(this.banner.render(e,{onAcceptAll:()=>this.acceptAll(),onRejectAll:()=>this.rejectAll(),onConfigure:()=>this.openPreferences()}),this.eventBus.emit("banner:shown",void 0))}setupGlobalRevocationTrigger(){typeof document!="undefined"&&document.addEventListener("click",e=>{let t=e.target;t!=null&&t.closest("[data-consent-open]")&&(e.preventDefault(),this.openPreferences())})}},de=typeof window!="undefined"?window:globalThis;de.__ConsentSDK_Instance__||(de.__ConsentSDK_Instance__=new V);var N=de.__ConsentSDK_Instance__;var U=class{constructor(e){this.config={schemaVersion:1,policyVersion:"1.0.0",categories:{},services:{}};e&&(this.config.policyVersion=e)}setSchemaVersion(e){return this.config.schemaVersion=e,this}setPolicyVersion(e){return this.config.policyVersion=e,this}setPolicyUrls(e,t){return this.config.policy={privacyUrl:e,cookiesUrl:t},this}setLocale(e,t=!0){return this.config.locale={default:e,autoDetect:t},this}addCategory(e,t){return this.config.categories||(this.config.categories={}),this.config.categories[e]=t,this}addService(e,t){return this.config.services||(this.config.services={}),this.config.services[e]=t,this}build(){var t;(t=this.config.categories)!=null&&t.necessary||(this.config.categories=xe(y({},this.config.categories),{necessary:{required:!0,default:!0,label:"Necesarias",description:"Cookies y almacenamiento imprescindible para el funcionamiento del sitio."}}));let e=this.config;return P(e),e}};var ae=class{static create(e){switch(e){case"cookie":return new D;case"memory":return new S;default:return new D}}};var ce=class{constructor(){this.locale="es"}setLocale(e){this.locale=e}getLocale(){return this.locale}detectBrowserLocale(){return typeof navigator!="undefined"&&navigator.language?navigator.language.split("-")[0].toLowerCase():"es"}};typeof window!="undefined"&&(window.Consent=N,window.ConsentSDK={Consent:N,ConsentEngine:V,ConsentConfigBuilder:U,validateConfig:P,PolicyGenerator:B,ResourceScanner:q});if(typeof document!="undefined"){let r=document.currentScript,e=r==null?void 0:r.getAttribute("data-config");if(e){let t=()=>{N.init(e).catch(n=>{console.warn("[ConsentSDK AutoInit Warning]",n)})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}}return Le(Pe);})();
589
+ //# sourceMappingURL=consent.min.js.map