lineas-romero-cookies-consent 1.1.1 → 1.1.3

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.
@@ -1,47 +1,50 @@
1
- const y = "CookieConsent";
2
- function C(o) {
1
+ const C = "CookieConsent";
2
+ function y(o) {
3
3
  if (!o || typeof o != "object")
4
4
  throw new Error("initCookieConsent(config): config is required");
5
5
  const e = Array.isArray(o.categories) ? o.categories : [];
6
6
  if (e.length === 0)
7
7
  throw new Error("initCookieConsent(config): config.categories is required");
8
- const t = e.map((r) => {
9
- if (!r || typeof r != "object")
8
+ const t = e.map((i) => {
9
+ if (!i || typeof i != "object")
10
10
  throw new Error("initCookieConsent(config): invalid category");
11
- if (!r.id)
11
+ if (!i.id)
12
12
  throw new Error("initCookieConsent(config): category.id is required");
13
13
  return {
14
- id: String(r.id),
15
- label: r.label ? String(r.label) : String(r.id),
16
- description: r.description ? String(r.description) : "",
17
- enabled: !!r.enabled,
18
- readonly: !!r.readonly,
19
- cookiePatterns: Array.isArray(r.cookiePatterns) ? r.cookiePatterns.map(String) : []
14
+ id: String(i.id),
15
+ label: i.label ? String(i.label) : String(i.id),
16
+ description: i.description ? String(i.description) : "",
17
+ enabled: !!i.enabled,
18
+ readonly: !!i.readonly,
19
+ cookiePatterns: Array.isArray(i.cookiePatterns) ? i.cookiePatterns.map(String) : []
20
20
  };
21
- }), n = o.cookieName ? String(o.cookieName) : y, i = Number.isFinite(o.cookieExpiresDays) ? Number(o.cookieExpiresDays) : 180;
21
+ }), n = o.cookieName ? String(o.cookieName) : C, a = Number.isFinite(o.cookieExpiresDays) ? Number(o.cookieExpiresDays) : 180;
22
22
  return {
23
23
  siteName: o.siteName ? String(o.siteName) : "",
24
24
  autoClear: !!o.autoClear,
25
25
  cookieName: n,
26
- cookieExpiresDays: i,
26
+ cookieExpiresDays: a,
27
27
  categories: t,
28
28
  onAccept: typeof o.onAccept == "function" ? o.onAccept : null
29
29
  };
30
30
  }
31
- function A(o) {
31
+ function P(o) {
32
32
  const e = {};
33
33
  for (const t of o)
34
34
  e[t.id] = t.readonly ? !0 : !!t.enabled;
35
35
  return e;
36
36
  }
37
- function S(o) {
37
+ function N(o) {
38
38
  try {
39
39
  return JSON.parse(decodeURIComponent(o));
40
40
  } catch {
41
41
  return null;
42
42
  }
43
43
  }
44
- function b(o) {
44
+ function A() {
45
+ return "LR-" + Math.random().toString(36).substr(2, 9).toUpperCase() + "-" + Date.now().toString(36).toUpperCase();
46
+ }
47
+ function E(o) {
45
48
  if (typeof document > "u") return null;
46
49
  const e = document.cookie ? document.cookie.split("; ") : [];
47
50
  for (const t of e) {
@@ -51,154 +54,178 @@ function b(o) {
51
54
  }
52
55
  return null;
53
56
  }
54
- function N(o, e, { expiresDays: t }) {
57
+ function S(o, e, { expiresDays: t }) {
55
58
  if (typeof document > "u") return;
56
59
  const n = /* @__PURE__ */ new Date();
57
60
  n.setTime(n.getTime() + t * 24 * 60 * 60 * 1e3);
58
- const i = encodeURIComponent(JSON.stringify(e));
59
- document.cookie = `${o}=${i}; Expires=${n.toUTCString()}; Path=/; SameSite=Lax`;
61
+ const a = encodeURIComponent(JSON.stringify(e));
62
+ document.cookie = `${o}=${a}; Expires=${n.toUTCString()}; Path=/; SameSite=Lax`;
60
63
  }
61
- function f(o, e) {
64
+ function p(o, e) {
62
65
  return e ? o === e ? !0 : o.startsWith(e) : !1;
63
66
  }
64
- function p() {
67
+ function m() {
65
68
  return typeof document > "u" ? [] : (document.cookie ? document.cookie.split("; ") : []).map((e) => {
66
69
  const t = e.indexOf("=");
67
70
  return t >= 0 ? e.slice(0, t) : e;
68
71
  }).filter(Boolean);
69
72
  }
70
- function P(o) {
73
+ function _(o) {
71
74
  const e = /* @__PURE__ */ new Set();
72
75
  if (!o) return Array.from(e);
73
76
  e.add(o), o.includes(".") && e.add(`.${o}`);
74
77
  const t = o.split(".").filter(Boolean);
75
78
  for (let n = 1; n < t.length - 1; n += 1) {
76
- const i = t.slice(n).join(".");
77
- e.add(i), e.add(`.${i}`);
79
+ const a = t.slice(n).join(".");
80
+ e.add(a), e.add(`.${a}`);
78
81
  }
79
82
  return Array.from(e);
80
83
  }
81
- function m(o) {
84
+ function g(o) {
82
85
  if (typeof document > "u") return;
83
- const e = "Thu, 01 Jan 1970 00:00:00 GMT", t = typeof location < "u" ? location.hostname : "", n = P(t);
86
+ const e = "Thu, 01 Jan 1970 00:00:00 GMT", t = typeof location < "u" ? location.hostname : "", n = _(t);
84
87
  document.cookie = `${o}=; Expires=${e}; Path=/; SameSite=Lax`;
85
- for (const i of n)
86
- document.cookie = `${o}=; Expires=${e}; Path=/; Domain=${i}; SameSite=Lax`;
88
+ for (const a of n)
89
+ document.cookie = `${o}=; Expires=${e}; Path=/; Domain=${a}; SameSite=Lax`;
87
90
  }
88
- function E(o, e) {
91
+ function w(o, e) {
89
92
  return o.find((t) => t.id === e) || null;
90
93
  }
91
- function _(o, e) {
92
- const t = E(o, e);
94
+ function D(o, e) {
95
+ const t = w(o, e);
93
96
  return t ? t.cookiePatterns : [];
94
97
  }
95
- function x({ categories: o, allowedPreferences: e }) {
96
- const t = p();
98
+ function h({ categories: o, allowedPreferences: e }) {
99
+ const t = m();
97
100
  for (const n of o)
98
101
  if (!e[n.id])
99
- for (const r of t)
100
- n.cookiePatterns.some((l) => f(r, l)) && m(r);
102
+ for (const i of t)
103
+ n.cookiePatterns.some((l) => p(i, l)) && g(i);
101
104
  }
102
- function u(o, e) {
105
+ function f(o, e) {
103
106
  const t = {};
104
107
  for (const n of o) {
105
- const i = e && Object.prototype.hasOwnProperty.call(e, n.id) ? !!e[n.id] : !!n.enabled;
106
- t[n.id] = n.readonly ? !0 : i;
108
+ const a = e && Object.prototype.hasOwnProperty.call(e, n.id) ? !!e[n.id] : !!n.enabled;
109
+ t[n.id] = n.readonly ? !0 : a;
107
110
  }
108
111
  return t;
109
112
  }
110
- function h(o) {
111
- const e = C(o), t = A(e.categories), n = b(e.cookieName), i = n ? S(n) : null;
112
- let a = i && i.preferences ? u(e.categories, i.preferences) : t;
113
- i && i.preferences && e.onAccept && e.onAccept({ ...a });
114
- function l(s) {
115
- return a = u(e.categories, s), N(
113
+ function L(o) {
114
+ const e = y(o), t = P(e.categories), n = E(e.cookieName), a = n ? N(n) : null;
115
+ let i = a && a.preferences ? f(e.categories, a.preferences) : t, c = a ? a.consentId : null, l = a ? a.updatedAt : null;
116
+ a && a.preferences && e.onAccept && e.onAccept({ ...i });
117
+ function d(r) {
118
+ return i = f(e.categories, r), c || (c = A()), l = (/* @__PURE__ */ new Date()).toISOString(), S(
116
119
  e.cookieName,
117
120
  {
118
- preferences: a,
119
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
121
+ preferences: i,
122
+ consentId: c,
123
+ // Guardamos el ID
124
+ updatedAt: l,
125
+ // Guardamos la fecha
120
126
  siteName: e.siteName
121
127
  },
122
128
  { expiresDays: e.cookieExpiresDays }
123
- ), e.autoClear && x({ categories: e.categories, allowedPreferences: a }), e.onAccept && e.onAccept({ ...a }), { ...a };
129
+ ), e.autoClear && h({ categories: e.categories, allowedPreferences: i }), e.onAccept && e.onAccept({ ...i }), { ...i };
124
130
  }
125
131
  return {
132
+ getConsentDetails() {
133
+ return {
134
+ consentId: c || "No registrado",
135
+ consentDate: l || "No registrado",
136
+ preferences: { ...i }
137
+ };
138
+ },
126
139
  getConfig() {
127
140
  return {
128
141
  siteName: e.siteName,
129
142
  autoClear: e.autoClear,
130
143
  cookieName: e.cookieName,
131
144
  cookieExpiresDays: e.cookieExpiresDays,
132
- categories: e.categories.map((s) => ({ ...s }))
145
+ categories: e.categories.map((r) => ({ ...r }))
133
146
  };
134
147
  },
135
148
  hasStoredConsent() {
136
- return !!(i && i.preferences);
149
+ return !!(a && a.preferences);
137
150
  },
138
151
  getPreferences() {
139
- return { ...a };
152
+ return { ...i };
140
153
  },
141
154
  acceptAll() {
142
- const s = {};
143
- for (const c of e.categories)
144
- s[c.id] = !0;
145
- return l(s);
155
+ const r = {};
156
+ for (const s of e.categories)
157
+ r[s.id] = !0;
158
+ return d(r);
146
159
  },
147
160
  rejectAll() {
148
- const s = {};
149
- for (const c of e.categories)
150
- s[c.id] = !!c.readonly;
151
- return l(s);
161
+ const r = {};
162
+ for (const s of e.categories)
163
+ r[s.id] = !!s.readonly;
164
+ return d(r);
152
165
  },
153
- setPreferences(s) {
154
- return l({ ...a, ...s || {} });
166
+ setPreferences(r) {
167
+ return d({ ...i, ...r || {} });
155
168
  },
156
- clearCategoryCookies(s) {
157
- const c = _(e.categories, s), g = p();
158
- for (const d of g)
159
- c.some((k) => f(d, k)) && m(d);
169
+ clearCategoryCookies(r) {
170
+ const s = D(e.categories, r), k = m();
171
+ for (const u of k)
172
+ s.some((b) => p(u, b)) && g(u);
160
173
  }
161
174
  };
162
175
  }
163
- const w = {
176
+ const I = {
164
177
  siteName: "Lineas Romero NextJS",
165
178
  autoClear: !0,
166
179
  categories: [
167
180
  {
168
181
  id: "necessary",
169
- label: "Strictly Necessary",
170
- description: "Essential for booking and site functionality.",
182
+ label: "Necesario",
183
+ description: "Las cookies necesarias ayudan a hacer una página web utilizable activando funciones básicas como la navegación en la página y el acceso a áreas seguras de la página web.",
171
184
  enabled: !0,
172
185
  readonly: !0,
173
- cookiePatterns: ["fh_", "fareharbor", "next-", "__Host-", "connect.sid"]
186
+ cookiePatterns: ["fh_", "fareharbor", "next-", "__Host-", "connect.sid", "CookieConsent", "NEXT_LOCALE"]
187
+ },
188
+ {
189
+ id: "preferences",
190
+ label: "Preferencias",
191
+ description: "Las cookies de preferencias permiten a la página web recordar información que cambia la forma en que la página se comporta o el aspecto que tiene.",
192
+ enabled: !1,
193
+ cookiePatterns: []
174
194
  },
175
195
  {
176
- id: "analytics",
177
- label: "Analytics",
178
- description: "Metrics to improve our service.",
196
+ id: "statistics",
197
+ // Renombrado de 'analytics' a 'statistics'
198
+ label: "Estadística",
199
+ description: "Las cookies estadísticas ayudan a los propietarios de páginas web a comprender cómo interactúan los visitantes con las páginas web reuniendo información de forma anónima.",
179
200
  enabled: !1,
180
201
  cookiePatterns: ["_ga", "_gid", "_gat", "mc_", "metricool"]
181
202
  },
182
203
  {
183
204
  id: "marketing",
184
205
  label: "Marketing",
185
- description: "Personalized advertising.",
206
+ description: "Las cookies de marketing se utilizan para rastrear a los visitantes en las páginas web. La intención es mostrar anuncios relevantes.",
207
+ enabled: !1,
208
+ cookiePatterns: ["_fbp", "fr", "tr", "_gcl", "_gac"]
209
+ },
210
+ {
211
+ id: "unclassified",
212
+ label: "No clasificadas",
213
+ description: "Cookies que estamos en proceso de clasificar.",
186
214
  enabled: !1,
187
- cookiePatterns: ["_fbp", "fr", "tr"]
215
+ cookiePatterns: []
188
216
  }
189
217
  ],
190
- /* aqui es donde voy a inicializar los scripts de analytics y marketing, y cualquiera que sea */
191
218
  onAccept: (o) => {
192
- o.analytics, o.marketing;
219
+ o.statistics, o.marketing;
193
220
  }
194
- }, B = {
221
+ }, v = {
195
222
  siteName: "Apartamentos Lineas Romero",
196
223
  autoClear: !0,
197
224
  categories: [
198
225
  {
199
226
  id: "necessary",
200
- label: "Strictly Necessary",
201
- description: "Language selection and basic functions.",
227
+ label: "Necesario",
228
+ description: "Las cookies necesarias ayudan a hacer una página web utilizable activando funciones básicas.",
202
229
  enabled: !0,
203
230
  readonly: !0,
204
231
  cookiePatterns: [
@@ -210,46 +237,77 @@ const w = {
210
237
  "__Secure-BUCKET"
211
238
  ]
212
239
  },
240
+ {
241
+ id: "preferences",
242
+ label: "Preferencias",
243
+ description: "Permiten recordar información que cambia el aspecto o comportamiento del sitio.",
244
+ enabled: !1,
245
+ cookiePatterns: []
246
+ },
247
+ {
248
+ id: "statistics",
249
+ label: "Estadística",
250
+ description: "Ayudan a comprender cómo interactúan los visitantes con la web.",
251
+ enabled: !1,
252
+ cookiePatterns: ["_ga", "_gid"]
253
+ },
213
254
  {
214
255
  id: "marketing",
215
- label: "Marketing & Ads",
216
- description: "Google Maps and Advertising integration.",
256
+ label: "Marketing",
257
+ description: "Se utilizan para rastrear a los visitantes y mostrar anuncios relevantes.",
217
258
  enabled: !1,
218
259
  cookiePatterns: ["IDE", "_gcl", "ar_debug", "SOCS", "__Secure-ENID", "NID", "1P_JAR"]
260
+ },
261
+ {
262
+ id: "unclassified",
263
+ label: "No clasificadas",
264
+ description: "Cookies en proceso de clasificación.",
265
+ enabled: !1,
266
+ cookiePatterns: []
219
267
  }
220
268
  ],
221
269
  onAccept: (o) => {
222
270
  o.marketing;
223
271
  }
224
- }, I = {
272
+ }, B = {
225
273
  siteName: "Visit La Graciosa",
226
274
  autoClear: !0,
227
275
  categories: [
228
276
  {
229
277
  id: "necessary",
230
- label: "Strictly Necessary",
231
- description: "Essential for language preferences and site functionality.",
278
+ label: "Necesario",
279
+ description: "Esenciales para preferencias de idioma y funcionamiento del sitio.",
232
280
  enabled: !0,
233
281
  readonly: !0,
234
- cookiePatterns: [
235
- "pll_",
236
- "session_id",
237
- "PHPSESSID"
238
- ]
282
+ cookiePatterns: ["pll_", "session_id", "PHPSESSID"]
239
283
  },
240
284
  {
241
- id: "analytics",
242
- label: "Analytics",
243
- description: "Anonymous usage statistics.",
285
+ id: "preferences",
286
+ label: "Preferencias",
287
+ description: "Configuración regional e idioma.",
288
+ enabled: !1,
289
+ cookiePatterns: []
290
+ },
291
+ {
292
+ id: "statistics",
293
+ label: "Estadística",
294
+ description: "Estadísticas de uso anónimo.",
244
295
  enabled: !1,
245
296
  cookiePatterns: ["_ga", "_gid"]
246
297
  },
247
298
  {
248
299
  id: "marketing",
249
300
  label: "Marketing",
250
- description: "Advertising and conversion tracking.",
301
+ description: "Publicidad y seguimiento de conversiones.",
251
302
  enabled: !1,
252
303
  cookiePatterns: ["_gcl", "_gac"]
304
+ },
305
+ {
306
+ id: "unclassified",
307
+ label: "No clasificadas",
308
+ description: "Pendientes de clasificar.",
309
+ enabled: !1,
310
+ cookiePatterns: []
253
311
  }
254
312
  ],
255
313
  onAccept: (o) => {
@@ -257,8 +315,8 @@ const w = {
257
315
  }
258
316
  };
259
317
  export {
260
- h as initCookieConsent,
261
- w as nextJsConfig,
262
- I as visitLaGraciosaConfig,
263
- B as wpApartamentosConfig
318
+ L as initCookieConsent,
319
+ I as nextJsConfig,
320
+ B as visitLaGraciosaConfig,
321
+ v as wpApartamentosConfig
264
322
  };
@@ -1 +1 @@
1
- (function(a,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(a=typeof globalThis<"u"?globalThis:a||self,d(a.LineasRomeroCookies={}))})(this,(function(a){"use strict";const d="CookieConsent";function y(o){if(!o||typeof o!="object")throw new Error("initCookieConsent(config): config is required");const e=Array.isArray(o.categories)?o.categories:[];if(e.length===0)throw new Error("initCookieConsent(config): config.categories is required");const t=e.map(r=>{if(!r||typeof r!="object")throw new Error("initCookieConsent(config): invalid category");if(!r.id)throw new Error("initCookieConsent(config): category.id is required");return{id:String(r.id),label:r.label?String(r.label):String(r.id),description:r.description?String(r.description):"",enabled:!!r.enabled,readonly:!!r.readonly,cookiePatterns:Array.isArray(r.cookiePatterns)?r.cookiePatterns.map(String):[]}}),n=o.cookieName?String(o.cookieName):d,i=Number.isFinite(o.cookieExpiresDays)?Number(o.cookieExpiresDays):180;return{siteName:o.siteName?String(o.siteName):"",autoClear:!!o.autoClear,cookieName:n,cookieExpiresDays:i,categories:t,onAccept:typeof o.onAccept=="function"?o.onAccept:null}}function C(o){const e={};for(const t of o)e[t.id]=t.readonly?!0:!!t.enabled;return e}function A(o){try{return JSON.parse(decodeURIComponent(o))}catch{return null}}function b(o){if(typeof document>"u")return null;const e=document.cookie?document.cookie.split("; "):[];for(const t of e){const n=t.indexOf("=");if((n>=0?t.slice(0,n):t)===o)return n>=0?t.slice(n+1):""}return null}function S(o,e,{expiresDays:t}){if(typeof document>"u")return;const n=new Date;n.setTime(n.getTime()+t*24*60*60*1e3);const i=encodeURIComponent(JSON.stringify(e));document.cookie=`${o}=${i}; Expires=${n.toUTCString()}; Path=/; SameSite=Lax`}function u(o,e){return e?o===e?!0:o.startsWith(e):!1}function p(){return typeof document>"u"?[]:(document.cookie?document.cookie.split("; "):[]).map(e=>{const t=e.indexOf("=");return t>=0?e.slice(0,t):e}).filter(Boolean)}function N(o){const e=new Set;if(!o)return Array.from(e);e.add(o),o.includes(".")&&e.add(`.${o}`);const t=o.split(".").filter(Boolean);for(let n=1;n<t.length-1;n+=1){const i=t.slice(n).join(".");e.add(i),e.add(`.${i}`)}return Array.from(e)}function m(o){if(typeof document>"u")return;const e="Thu, 01 Jan 1970 00:00:00 GMT",t=typeof location<"u"?location.hostname:"",n=N(t);document.cookie=`${o}=; Expires=${e}; Path=/; SameSite=Lax`;for(const i of n)document.cookie=`${o}=; Expires=${e}; Path=/; Domain=${i}; SameSite=Lax`}function P(o,e){return o.find(t=>t.id===e)||null}function E(o,e){const t=P(o,e);return t?t.cookiePatterns:[]}function _({categories:o,allowedPreferences:e}){const t=p();for(const n of o)if(!e[n.id])for(const r of t)n.cookiePatterns.some(f=>u(r,f))&&m(r)}function g(o,e){const t={};for(const n of o){const i=e&&Object.prototype.hasOwnProperty.call(e,n.id)?!!e[n.id]:!!n.enabled;t[n.id]=n.readonly?!0:i}return t}function h(o){const e=y(o),t=C(e.categories),n=b(e.cookieName),i=n?A(n):null;let c=i&&i.preferences?g(e.categories,i.preferences):t;i&&i.preferences&&e.onAccept&&e.onAccept({...c});function f(s){return c=g(e.categories,s),S(e.cookieName,{preferences:c,updatedAt:new Date().toISOString(),siteName:e.siteName},{expiresDays:e.cookieExpiresDays}),e.autoClear&&_({categories:e.categories,allowedPreferences:c}),e.onAccept&&e.onAccept({...c}),{...c}}return{getConfig(){return{siteName:e.siteName,autoClear:e.autoClear,cookieName:e.cookieName,cookieExpiresDays:e.cookieExpiresDays,categories:e.categories.map(s=>({...s}))}},hasStoredConsent(){return!!(i&&i.preferences)},getPreferences(){return{...c}},acceptAll(){const s={};for(const l of e.categories)s[l.id]=!0;return f(s)},rejectAll(){const s={};for(const l of e.categories)s[l.id]=!!l.readonly;return f(s)},setPreferences(s){return f({...c,...s||{}})},clearCategoryCookies(s){const l=E(e.categories,s),L=p();for(const k of L)l.some(B=>u(k,B))&&m(k)}}}const w={siteName:"Lineas Romero NextJS",autoClear:!0,categories:[{id:"necessary",label:"Strictly Necessary",description:"Essential for booking and site functionality.",enabled:!0,readonly:!0,cookiePatterns:["fh_","fareharbor","next-","__Host-","connect.sid"]},{id:"analytics",label:"Analytics",description:"Metrics to improve our service.",enabled:!1,cookiePatterns:["_ga","_gid","_gat","mc_","metricool"]},{id:"marketing",label:"Marketing",description:"Personalized advertising.",enabled:!1,cookiePatterns:["_fbp","fr","tr"]}],onAccept:o=>{o.analytics,o.marketing}},D={siteName:"Apartamentos Lineas Romero",autoClear:!0,categories:[{id:"necessary",label:"Strictly Necessary",description:"Language selection and basic functions.",enabled:!0,readonly:!0,cookiePatterns:["wp-settings","wordpress_","pll_","CookieConsent","AEC","__Secure-BUCKET"]},{id:"marketing",label:"Marketing & Ads",description:"Google Maps and Advertising integration.",enabled:!1,cookiePatterns:["IDE","_gcl","ar_debug","SOCS","__Secure-ENID","NID","1P_JAR"]}],onAccept:o=>{o.marketing}},x={siteName:"Visit La Graciosa",autoClear:!0,categories:[{id:"necessary",label:"Strictly Necessary",description:"Essential for language preferences and site functionality.",enabled:!0,readonly:!0,cookiePatterns:["pll_","session_id","PHPSESSID"]},{id:"analytics",label:"Analytics",description:"Anonymous usage statistics.",enabled:!1,cookiePatterns:["_ga","_gid"]},{id:"marketing",label:"Marketing",description:"Advertising and conversion tracking.",enabled:!1,cookiePatterns:["_gcl","_gac"]}],onAccept:o=>{o.marketing}};a.initCookieConsent=h,a.nextJsConfig=w,a.visitLaGraciosaConfig=x,a.wpApartamentosConfig=D,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(r,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(r=typeof globalThis<"u"?globalThis:r||self,l(r.LineasRomeroCookies={}))})(this,(function(r){"use strict";const l="CookieConsent";function b(o){if(!o||typeof o!="object")throw new Error("initCookieConsent(config): config is required");const e=Array.isArray(o.categories)?o.categories:[];if(e.length===0)throw new Error("initCookieConsent(config): config.categories is required");const i=e.map(t=>{if(!t||typeof t!="object")throw new Error("initCookieConsent(config): invalid category");if(!t.id)throw new Error("initCookieConsent(config): category.id is required");return{id:String(t.id),label:t.label?String(t.label):String(t.id),description:t.description?String(t.description):"",enabled:!!t.enabled,readonly:!!t.readonly,cookiePatterns:Array.isArray(t.cookiePatterns)?t.cookiePatterns.map(String):[]}}),n=o.cookieName?String(o.cookieName):l,a=Number.isFinite(o.cookieExpiresDays)?Number(o.cookieExpiresDays):180;return{siteName:o.siteName?String(o.siteName):"",autoClear:!!o.autoClear,cookieName:n,cookieExpiresDays:a,categories:i,onAccept:typeof o.onAccept=="function"?o.onAccept:null}}function y(o){const e={};for(const i of o)e[i.id]=i.readonly?!0:!!i.enabled;return e}function P(o){try{return JSON.parse(decodeURIComponent(o))}catch{return null}}function N(){return"LR-"+Math.random().toString(36).substr(2,9).toUpperCase()+"-"+Date.now().toString(36).toUpperCase()}function A(o){if(typeof document>"u")return null;const e=document.cookie?document.cookie.split("; "):[];for(const i of e){const n=i.indexOf("=");if((n>=0?i.slice(0,n):i)===o)return n>=0?i.slice(n+1):""}return null}function S(o,e,{expiresDays:i}){if(typeof document>"u")return;const n=new Date;n.setTime(n.getTime()+i*24*60*60*1e3);const a=encodeURIComponent(JSON.stringify(e));document.cookie=`${o}=${a}; Expires=${n.toUTCString()}; Path=/; SameSite=Lax`}function p(o,e){return e?o===e?!0:o.startsWith(e):!1}function m(){return typeof document>"u"?[]:(document.cookie?document.cookie.split("; "):[]).map(e=>{const i=e.indexOf("=");return i>=0?e.slice(0,i):e}).filter(Boolean)}function E(o){const e=new Set;if(!o)return Array.from(e);e.add(o),o.includes(".")&&e.add(`.${o}`);const i=o.split(".").filter(Boolean);for(let n=1;n<i.length-1;n+=1){const a=i.slice(n).join(".");e.add(a),e.add(`.${a}`)}return Array.from(e)}function g(o){if(typeof document>"u")return;const e="Thu, 01 Jan 1970 00:00:00 GMT",i=typeof location<"u"?location.hostname:"",n=E(i);document.cookie=`${o}=; Expires=${e}; Path=/; SameSite=Lax`;for(const a of n)document.cookie=`${o}=; Expires=${e}; Path=/; Domain=${a}; SameSite=Lax`}function _(o,e){return o.find(i=>i.id===e)||null}function w(o,e){const i=_(o,e);return i?i.cookiePatterns:[]}function h({categories:o,allowedPreferences:e}){const i=m();for(const n of o)if(!e[n.id])for(const t of i)n.cookiePatterns.some(f=>p(t,f))&&g(t)}function k(o,e){const i={};for(const n of o){const a=e&&Object.prototype.hasOwnProperty.call(e,n.id)?!!e[n.id]:!!n.enabled;i[n.id]=n.readonly?!0:a}return i}function D(o){const e=b(o),i=y(e.categories),n=A(e.cookieName),a=n?P(n):null;let t=a&&a.preferences?k(e.categories,a.preferences):i,d=a?a.consentId:null,f=a?a.updatedAt:null;a&&a.preferences&&e.onAccept&&e.onAccept({...t});function u(s){return t=k(e.categories,s),d||(d=N()),f=new Date().toISOString(),S(e.cookieName,{preferences:t,consentId:d,updatedAt:f,siteName:e.siteName},{expiresDays:e.cookieExpiresDays}),e.autoClear&&h({categories:e.categories,allowedPreferences:t}),e.onAccept&&e.onAccept({...t}),{...t}}return{getConsentDetails(){return{consentId:d||"No registrado",consentDate:f||"No registrado",preferences:{...t}}},getConfig(){return{siteName:e.siteName,autoClear:e.autoClear,cookieName:e.cookieName,cookieExpiresDays:e.cookieExpiresDays,categories:e.categories.map(s=>({...s}))}},hasStoredConsent(){return!!(a&&a.preferences)},getPreferences(){return{...t}},acceptAll(){const s={};for(const c of e.categories)s[c.id]=!0;return u(s)},rejectAll(){const s={};for(const c of e.categories)s[c.id]=!!c.readonly;return u(s)},setPreferences(s){return u({...t,...s||{}})},clearCategoryCookies(s){const c=w(e.categories,s),I=m();for(const C of I)c.some(O=>p(C,O))&&g(C)}}}const L={siteName:"Lineas Romero NextJS",autoClear:!0,categories:[{id:"necessary",label:"Necesario",description:"Las cookies necesarias ayudan a hacer una página web utilizable activando funciones básicas como la navegación en la página y el acceso a áreas seguras de la página web.",enabled:!0,readonly:!0,cookiePatterns:["fh_","fareharbor","next-","__Host-","connect.sid","CookieConsent","NEXT_LOCALE"]},{id:"preferences",label:"Preferencias",description:"Las cookies de preferencias permiten a la página web recordar información que cambia la forma en que la página se comporta o el aspecto que tiene.",enabled:!1,cookiePatterns:[]},{id:"statistics",label:"Estadística",description:"Las cookies estadísticas ayudan a los propietarios de páginas web a comprender cómo interactúan los visitantes con las páginas web reuniendo información de forma anónima.",enabled:!1,cookiePatterns:["_ga","_gid","_gat","mc_","metricool"]},{id:"marketing",label:"Marketing",description:"Las cookies de marketing se utilizan para rastrear a los visitantes en las páginas web. La intención es mostrar anuncios relevantes.",enabled:!1,cookiePatterns:["_fbp","fr","tr","_gcl","_gac"]},{id:"unclassified",label:"No clasificadas",description:"Cookies que estamos en proceso de clasificar.",enabled:!1,cookiePatterns:[]}],onAccept:o=>{o.statistics,o.marketing}},x={siteName:"Apartamentos Lineas Romero",autoClear:!0,categories:[{id:"necessary",label:"Necesario",description:"Las cookies necesarias ayudan a hacer una página web utilizable activando funciones básicas.",enabled:!0,readonly:!0,cookiePatterns:["wp-settings","wordpress_","pll_","CookieConsent","AEC","__Secure-BUCKET"]},{id:"preferences",label:"Preferencias",description:"Permiten recordar información que cambia el aspecto o comportamiento del sitio.",enabled:!1,cookiePatterns:[]},{id:"statistics",label:"Estadística",description:"Ayudan a comprender cómo interactúan los visitantes con la web.",enabled:!1,cookiePatterns:["_ga","_gid"]},{id:"marketing",label:"Marketing",description:"Se utilizan para rastrear a los visitantes y mostrar anuncios relevantes.",enabled:!1,cookiePatterns:["IDE","_gcl","ar_debug","SOCS","__Secure-ENID","NID","1P_JAR"]},{id:"unclassified",label:"No clasificadas",description:"Cookies en proceso de clasificación.",enabled:!1,cookiePatterns:[]}],onAccept:o=>{o.marketing}},v={siteName:"Visit La Graciosa",autoClear:!0,categories:[{id:"necessary",label:"Necesario",description:"Esenciales para preferencias de idioma y funcionamiento del sitio.",enabled:!0,readonly:!0,cookiePatterns:["pll_","session_id","PHPSESSID"]},{id:"preferences",label:"Preferencias",description:"Configuración regional e idioma.",enabled:!1,cookiePatterns:[]},{id:"statistics",label:"Estadística",description:"Estadísticas de uso anónimo.",enabled:!1,cookiePatterns:["_ga","_gid"]},{id:"marketing",label:"Marketing",description:"Publicidad y seguimiento de conversiones.",enabled:!1,cookiePatterns:["_gcl","_gac"]},{id:"unclassified",label:"No clasificadas",description:"Pendientes de clasificar.",enabled:!1,cookiePatterns:[]}],onAccept:o=>{o.marketing}};r.initCookieConsent=D,r.nextJsConfig=L,r.visitLaGraciosaConfig=v,r.wpApartamentosConfig=x,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
package/index.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ // index.d.ts
2
+
3
+ export interface CookieCategory {
4
+ id: string;
5
+ label?: string;
6
+ description?: string;
7
+ enabled?: boolean;
8
+ readonly?: boolean;
9
+ cookiePatterns?: string[];
10
+ }
11
+
12
+ export interface UserPreferences {
13
+ [categoryId: string]: boolean;
14
+ }
15
+
16
+ export interface CookieConsentConfig {
17
+ siteName?: string;
18
+ cookieName?: string;
19
+ cookieExpiresDays?: number;
20
+ autoClear?: boolean;
21
+ categories: CookieCategory[];
22
+ onAccept?: (preferences: UserPreferences) => void;
23
+ }
24
+
25
+ export interface ConsentAPI {
26
+ getConfig(): CookieConsentConfig;
27
+ hasStoredConsent(): boolean;
28
+ getPreferences(): UserPreferences;
29
+ acceptAll(): UserPreferences;
30
+ rejectAll(): UserPreferences;
31
+ setPreferences(preferences: UserPreferences): UserPreferences;
32
+ clearCategoryCookies(categoryId: string): void;
33
+ }
34
+
35
+ // Función principal
36
+ export function initCookieConsent(config: CookieConsentConfig): ConsentAPI;
37
+
38
+ // Presets exportados
39
+ export const nextJsConfig: CookieConsentConfig;
40
+ export const wpApartamentosConfig: CookieConsentConfig;
41
+ export const visitLaGraciosaConfig: CookieConsentConfig;
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "lineas-romero-cookies-consent",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Gestor en vanilla JS + CSS para granular las cookies de las páginas de LR, Apartamentos y Visit La Graciosa de manera manual.",
5
5
  "type": "module",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "index.d.ts"
8
9
  ],
10
+ "types": "./index.d.ts",
9
11
  "main": "./dist/lineas-romero-cookies-consent.umd.cjs",
10
12
  "module": "./dist/lineas-romero-cookies-consent.js",
11
13
  "exports": {
12
14
  ".": {
15
+ "types": "./index.d.ts",
13
16
  "import": "./dist/lineas-romero-cookies-consent.js",
14
17
  "require": "./dist/lineas-romero-cookies-consent.umd.cjs"
15
18
  },