react-lgpd-consent 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/README.en.md +15 -0
- package/README.md +28 -0
- package/dist/core.cjs +12 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.js +1 -0
- package/dist/index.cjs +6 -1085
- package/dist/index.d.cts +1 -3775
- package/dist/index.d.ts +1 -3775
- package/dist/index.js +1 -930
- package/dist/integrations.cjs +66 -0
- package/dist/integrations.d.cts +1 -0
- package/dist/integrations.d.ts +1 -0
- package/dist/integrations.js +1 -0
- package/dist/mui.cjs +12 -0
- package/dist/mui.d.cts +1 -0
- package/dist/mui.d.ts +1 -0
- package/dist/mui.js +1 -0
- package/package.json +42 -80
- package/dist/FloatingPreferencesButton-4AGBXNHH.cjs +0 -11
- package/dist/FloatingPreferencesButton-IY7TFD7D.js +0 -2
- package/dist/PreferencesModal-5KNHWW57.js +0 -2
- package/dist/PreferencesModal-YBCWCVUI.cjs +0 -11
- package/dist/chunk-25XEI2DZ.cjs +0 -193
- package/dist/chunk-FJKRAERJ.cjs +0 -119
- package/dist/chunk-N3QOW4SA.js +0 -178
- package/dist/chunk-ORI4PLVG.cjs +0 -1899
- package/dist/chunk-PJFGQMCI.js +0 -92
- package/dist/chunk-RWT2ORFE.js +0 -1840
package/dist/chunk-RWT2ORFE.js
DELETED
|
@@ -1,1840 +0,0 @@
|
|
|
1
|
-
import * as React4 from 'react';
|
|
2
|
-
import React4__default from 'react';
|
|
3
|
-
import Cookies from 'js-cookie';
|
|
4
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import Link from '@mui/material/Link';
|
|
6
|
-
import Typography from '@mui/material/Typography';
|
|
7
|
-
import { ThemeProvider } from '@mui/material/styles';
|
|
8
|
-
import Button from '@mui/material/Button';
|
|
9
|
-
import Box from '@mui/material/Box';
|
|
10
|
-
import Paper from '@mui/material/Paper';
|
|
11
|
-
import Snackbar from '@mui/material/Snackbar';
|
|
12
|
-
import Stack from '@mui/material/Stack';
|
|
13
|
-
|
|
14
|
-
// react-lgpd-consent - Tree-shakeable ESM build
|
|
15
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
16
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
17
|
-
}) : x)(function(x) {
|
|
18
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
19
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// src/utils/cookieRegistry.ts
|
|
23
|
-
var COOKIE_PATTERNS_BY_CATEGORY = {
|
|
24
|
-
necessary: ["cookieConsent"],
|
|
25
|
-
analytics: ["_ga", "_ga_*", "_gid", "_gcl_au", "_hj*", "mp_*", "_clck", "_clsk"],
|
|
26
|
-
functional: ["intercom-*", "__zlcmid", "_zendesk_shared_session", "_userway_*"],
|
|
27
|
-
marketing: ["_fbp", "fr"],
|
|
28
|
-
social: [],
|
|
29
|
-
personalization: []
|
|
30
|
-
};
|
|
31
|
-
var COOKIE_INFO_BY_INTEGRATION = {
|
|
32
|
-
"google-analytics": [
|
|
33
|
-
{
|
|
34
|
-
name: "_ga",
|
|
35
|
-
purpose: "Identifica\xE7\xE3o \xFAnica de visitantes para an\xE1lise de tr\xE1fego",
|
|
36
|
-
duration: "2 anos",
|
|
37
|
-
provider: "Google Analytics"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "_ga_*",
|
|
41
|
-
purpose: "Rastreamento de sess\xF5es e eventos espec\xEDficos do stream GA4",
|
|
42
|
-
duration: "2 anos",
|
|
43
|
-
provider: "Google Analytics"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "_gid",
|
|
47
|
-
purpose: "Distin\xE7\xE3o de visitantes \xFAnicos em per\xEDodo de 24h",
|
|
48
|
-
duration: "24 horas",
|
|
49
|
-
provider: "Google Analytics"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"google-tag-manager": [
|
|
53
|
-
{
|
|
54
|
-
name: "_gcl_au",
|
|
55
|
-
purpose: "Rastreamento de convers\xF5es de an\xFAncios",
|
|
56
|
-
duration: "90 dias",
|
|
57
|
-
provider: "Google"
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
hotjar: [
|
|
61
|
-
{
|
|
62
|
-
name: "_hjSession_*",
|
|
63
|
-
purpose: "Rastreamento de sess\xE3o",
|
|
64
|
-
duration: "30 minutos",
|
|
65
|
-
provider: "Hotjar"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "_hjSessionUser_*",
|
|
69
|
-
purpose: "Persist\xEAncia de usu\xE1rio entre sess\xF5es",
|
|
70
|
-
duration: "365 dias",
|
|
71
|
-
provider: "Hotjar"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "_hjFirstSeen",
|
|
75
|
-
purpose: "Detec\xE7\xE3o da primeira visita do usu\xE1rio",
|
|
76
|
-
duration: "Sess\xE3o",
|
|
77
|
-
provider: "Hotjar"
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
mixpanel: [
|
|
81
|
-
{
|
|
82
|
-
name: "mp_*",
|
|
83
|
-
purpose: "Rastreamento de eventos e propriedades do usu\xE1rio para analytics",
|
|
84
|
-
duration: "1 ano",
|
|
85
|
-
provider: "Mixpanel"
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
clarity: [
|
|
89
|
-
{
|
|
90
|
-
name: "_clck",
|
|
91
|
-
purpose: "Identificador de usu\xE1rio",
|
|
92
|
-
duration: "365 dias",
|
|
93
|
-
provider: "Microsoft"
|
|
94
|
-
},
|
|
95
|
-
{ name: "_clsk", purpose: "Rastreamento de sess\xE3o", duration: "1 dia", provider: "Microsoft" }
|
|
96
|
-
],
|
|
97
|
-
intercom: [
|
|
98
|
-
{
|
|
99
|
-
name: "intercom-id-*",
|
|
100
|
-
purpose: "Identificador do usu\xE1rio",
|
|
101
|
-
duration: "9 meses",
|
|
102
|
-
provider: "Intercom"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "intercom-session-*",
|
|
106
|
-
purpose: "Gerenciamento de sess\xE3o",
|
|
107
|
-
duration: "1 semana",
|
|
108
|
-
provider: "Intercom"
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
"zendesk-chat": [
|
|
112
|
-
{
|
|
113
|
-
name: "__zlcmid",
|
|
114
|
-
purpose: "Identificador de sess\xE3o de chat",
|
|
115
|
-
duration: "1 ano",
|
|
116
|
-
provider: "Zendesk"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: "_zendesk_shared_session",
|
|
120
|
-
purpose: "Gerenciamento de sess\xE3o",
|
|
121
|
-
duration: "Sess\xE3o",
|
|
122
|
-
provider: "Zendesk"
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
userway: [
|
|
126
|
-
{
|
|
127
|
-
name: "_userway_*",
|
|
128
|
-
purpose: "Prefer\xEAncias de acessibilidade",
|
|
129
|
-
duration: "1 ano",
|
|
130
|
-
provider: "UserWay"
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
"facebook-pixel": [
|
|
134
|
-
{ name: "_fbp", purpose: "Rastreamento de an\xFAncios", duration: "90 dias", provider: "Meta" },
|
|
135
|
-
{ name: "fr", purpose: "Direcionamento de an\xFAncios", duration: "90 dias", provider: "Meta" }
|
|
136
|
-
]
|
|
137
|
-
};
|
|
138
|
-
var INTEGRATION_DEFAULT_CATEGORY = {
|
|
139
|
-
"google-analytics": "analytics",
|
|
140
|
-
"google-tag-manager": "analytics",
|
|
141
|
-
hotjar: "analytics",
|
|
142
|
-
mixpanel: "analytics",
|
|
143
|
-
clarity: "analytics",
|
|
144
|
-
intercom: "functional",
|
|
145
|
-
"zendesk-chat": "functional",
|
|
146
|
-
userway: "functional",
|
|
147
|
-
"facebook-pixel": "marketing"
|
|
148
|
-
};
|
|
149
|
-
var COOKIE_CATALOG_OVERRIDES = {};
|
|
150
|
-
var COOKIE_CATEGORY_OVERRIDES = {};
|
|
151
|
-
function setCookieCatalogOverrides(overrides) {
|
|
152
|
-
COOKIE_CATALOG_OVERRIDES = {
|
|
153
|
-
byCategory: { ...COOKIE_CATALOG_OVERRIDES.byCategory || {}, ...overrides.byCategory || {} },
|
|
154
|
-
byIntegration: {
|
|
155
|
-
...COOKIE_CATALOG_OVERRIDES.byIntegration || {},
|
|
156
|
-
...overrides.byIntegration || {}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function setCookieCategoryOverrides(map) {
|
|
161
|
-
COOKIE_CATEGORY_OVERRIDES = { ...COOKIE_CATEGORY_OVERRIDES, ...map };
|
|
162
|
-
}
|
|
163
|
-
function matchPattern(name, pattern) {
|
|
164
|
-
if (pattern.endsWith("*")) return name.startsWith(pattern.slice(0, -1));
|
|
165
|
-
return name === pattern;
|
|
166
|
-
}
|
|
167
|
-
function getCookiesInfoForCategory(categoryId, usedIntegrations) {
|
|
168
|
-
const result = [];
|
|
169
|
-
usedIntegrations.forEach((id) => {
|
|
170
|
-
const defaultCat = INTEGRATION_DEFAULT_CATEGORY[id];
|
|
171
|
-
const defaults = COOKIE_INFO_BY_INTEGRATION[id] || [];
|
|
172
|
-
const list = COOKIE_CATALOG_OVERRIDES.byIntegration?.[id] || defaults;
|
|
173
|
-
list.forEach((desc) => {
|
|
174
|
-
const overrideCat = Object.entries(COOKIE_CATEGORY_OVERRIDES).find(
|
|
175
|
-
([pattern]) => matchPattern(desc.name, pattern)
|
|
176
|
-
)?.[1];
|
|
177
|
-
const finalCat = overrideCat ?? defaultCat;
|
|
178
|
-
if (finalCat === categoryId && !result.find((d) => d.name === desc.name)) result.push(desc);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
const catOverride = COOKIE_CATALOG_OVERRIDES.byCategory?.[categoryId];
|
|
182
|
-
if (catOverride) {
|
|
183
|
-
catOverride.forEach((d) => {
|
|
184
|
-
const idx = result.findIndex((x) => x.name === d.name);
|
|
185
|
-
if (idx >= 0) result[idx] = d;
|
|
186
|
-
else result.push(d);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (categoryId === "necessary") {
|
|
190
|
-
if (!result.find((d) => d.name === "cookieConsent")) {
|
|
191
|
-
result.push({
|
|
192
|
-
name: "cookieConsent",
|
|
193
|
-
purpose: "Armazena suas prefer\xEAncias de consentimento",
|
|
194
|
-
duration: "365 dias",
|
|
195
|
-
provider: "Este site"
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// src/utils/cookieDiscovery.ts
|
|
203
|
-
function discoverRuntimeCookies() {
|
|
204
|
-
if (typeof document === "undefined" || !document.cookie) return [];
|
|
205
|
-
const names = Array.from(
|
|
206
|
-
new Set(
|
|
207
|
-
document.cookie.split(";").map((s) => s.trim()).filter(Boolean).map((s) => s.split("=")[0])
|
|
208
|
-
)
|
|
209
|
-
);
|
|
210
|
-
const list = names.map((name) => ({ name }));
|
|
211
|
-
try {
|
|
212
|
-
;
|
|
213
|
-
globalThis.__LGPD_DISCOVERED_COOKIES__ = list;
|
|
214
|
-
} catch {
|
|
215
|
-
}
|
|
216
|
-
return list;
|
|
217
|
-
}
|
|
218
|
-
function detectConsentCookieName() {
|
|
219
|
-
if (typeof document === "undefined" || !document.cookie) return null;
|
|
220
|
-
try {
|
|
221
|
-
const pairs = document.cookie.split(";").map((s) => s.trim()).filter(Boolean);
|
|
222
|
-
for (const p of pairs) {
|
|
223
|
-
const [name, ...rest] = p.split("=");
|
|
224
|
-
const raw = rest.join("=");
|
|
225
|
-
if (!raw) continue;
|
|
226
|
-
let val = raw;
|
|
227
|
-
try {
|
|
228
|
-
val = decodeURIComponent(raw);
|
|
229
|
-
} catch {
|
|
230
|
-
}
|
|
231
|
-
if (val.startsWith("{")) {
|
|
232
|
-
try {
|
|
233
|
-
const obj = JSON.parse(val);
|
|
234
|
-
if (obj && typeof obj === "object" && "preferences" in obj && "version" in obj) {
|
|
235
|
-
return name;
|
|
236
|
-
}
|
|
237
|
-
} catch {
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
} catch {
|
|
242
|
-
}
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
function categorizeDiscoveredCookies(discovered, registerOverrides = false) {
|
|
246
|
-
const list = discovered || globalThis.__LGPD_DISCOVERED_COOKIES__ || [];
|
|
247
|
-
const out = {};
|
|
248
|
-
function matchPattern2(name, pattern) {
|
|
249
|
-
if (pattern.endsWith("*")) return name.startsWith(pattern.slice(0, -1));
|
|
250
|
-
return name === pattern;
|
|
251
|
-
}
|
|
252
|
-
list.filter((d) => d.name && d.name !== "cookieConsent").forEach((d) => {
|
|
253
|
-
let assigned = null;
|
|
254
|
-
Object.keys(COOKIE_PATTERNS_BY_CATEGORY).forEach((cat2) => {
|
|
255
|
-
if (assigned) return;
|
|
256
|
-
const patterns = COOKIE_PATTERNS_BY_CATEGORY[cat2] || [];
|
|
257
|
-
if (patterns.some((p) => matchPattern2(d.name, p))) assigned = cat2;
|
|
258
|
-
});
|
|
259
|
-
const cat = assigned || "analytics";
|
|
260
|
-
out[cat] = out[cat] || [];
|
|
261
|
-
if (!out[cat].find((x) => x.name === d.name)) out[cat].push(d);
|
|
262
|
-
});
|
|
263
|
-
if (registerOverrides) {
|
|
264
|
-
const byCategory = {};
|
|
265
|
-
Object.entries(out).forEach(([cat, cookies]) => {
|
|
266
|
-
byCategory[cat] = cookies;
|
|
267
|
-
});
|
|
268
|
-
setCookieCatalogOverrides({ byCategory });
|
|
269
|
-
}
|
|
270
|
-
return out;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// src/utils/logger.ts
|
|
274
|
-
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
275
|
-
LogLevel2[LogLevel2["ERROR"] = 0] = "ERROR";
|
|
276
|
-
LogLevel2[LogLevel2["WARN"] = 1] = "WARN";
|
|
277
|
-
LogLevel2[LogLevel2["INFO"] = 2] = "INFO";
|
|
278
|
-
LogLevel2[LogLevel2["DEBUG"] = 3] = "DEBUG";
|
|
279
|
-
return LogLevel2;
|
|
280
|
-
})(LogLevel || {});
|
|
281
|
-
var _ConsentLogger = class _ConsentLogger {
|
|
282
|
-
constructor() {
|
|
283
|
-
this.enabled = _ConsentLogger.IS_DEVELOPMENT;
|
|
284
|
-
this.level = 2 /* INFO */;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Habilita ou desabilita o sistema de logging.
|
|
288
|
-
* @param {boolean} enabled Se `true`, os logs serão exibidos; caso contrário, serão suprimidos.
|
|
289
|
-
*/
|
|
290
|
-
setEnabled(enabled) {
|
|
291
|
-
this.enabled = enabled;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Define o nível mínimo de severidade para os logs.
|
|
295
|
-
* Mensagens com severidade menor que o nível definido não serão exibidas.
|
|
296
|
-
* @param {LogLevel} level O nível mínimo de severidade (ex: `LogLevel.DEBUG` para ver todos os logs).
|
|
297
|
-
*/
|
|
298
|
-
setLevel(level) {
|
|
299
|
-
this.level = level;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Registra uma mensagem de erro.
|
|
303
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
304
|
-
*/
|
|
305
|
-
error(...args) {
|
|
306
|
-
if (this.enabled && this.level >= 0 /* ERROR */) {
|
|
307
|
-
console.error(_ConsentLogger.LOG_PREFIX, "[ERROR]", ...args);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Registra uma mensagem de aviso.
|
|
312
|
-
* Suprimido em produção por padrão (apenas se logging estiver explicitamente habilitado).
|
|
313
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
314
|
-
*/
|
|
315
|
-
warn(...args) {
|
|
316
|
-
if (this.enabled && this.level >= 1 /* WARN */ && !_ConsentLogger.IS_PRODUCTION) {
|
|
317
|
-
console.warn(_ConsentLogger.LOG_PREFIX, "[WARN]", ...args);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Registra uma mensagem informativa.
|
|
322
|
-
* Suprimido em produção por padrão.
|
|
323
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
324
|
-
*/
|
|
325
|
-
info(...args) {
|
|
326
|
-
if (this.enabled && this.level >= 2 /* INFO */ && !_ConsentLogger.IS_PRODUCTION) {
|
|
327
|
-
console.info(_ConsentLogger.LOG_PREFIX, "[INFO]", ...args);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Registra uma mensagem de depuração.
|
|
332
|
-
* Sempre suprimido em produção.
|
|
333
|
-
* @param {...unknown[]} args Argumentos a serem logados.
|
|
334
|
-
*/
|
|
335
|
-
debug(...args) {
|
|
336
|
-
if (this.enabled && this.level >= 3 /* DEBUG */ && !_ConsentLogger.IS_PRODUCTION) {
|
|
337
|
-
console.debug(_ConsentLogger.LOG_PREFIX, "[DEBUG]", ...args);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Inicia um grupo de logs no console.
|
|
342
|
-
* Suprimido em produção.
|
|
343
|
-
* @param {...unknown[]} args Argumentos para o título do grupo.
|
|
344
|
-
*/
|
|
345
|
-
group(...args) {
|
|
346
|
-
if (this.enabled && this.level >= 3 /* DEBUG */ && !_ConsentLogger.IS_PRODUCTION) {
|
|
347
|
-
console.group(_ConsentLogger.LOG_PREFIX, ...args);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Finaliza o grupo de logs mais recente no console.
|
|
352
|
-
* Suprimido em produção.
|
|
353
|
-
*/
|
|
354
|
-
groupEnd() {
|
|
355
|
-
if (this.enabled && this.level >= 3 /* DEBUG */ && !_ConsentLogger.IS_PRODUCTION) {
|
|
356
|
-
console.groupEnd();
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Exibe dados tabulares no console.
|
|
361
|
-
* Suprimido em produção.
|
|
362
|
-
* @param {unknown} tabularData Dados a serem exibidos na tabela.
|
|
363
|
-
* @param {string[]} [properties] Propriedades opcionais para exibir.
|
|
364
|
-
*/
|
|
365
|
-
table(tabularData, properties) {
|
|
366
|
-
if (this.enabled && this.level >= 3 /* DEBUG */ && !_ConsentLogger.IS_PRODUCTION) {
|
|
367
|
-
console.table(tabularData, properties);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Registra informações sobre a compatibilidade do tema Material-UI.
|
|
372
|
-
* @param {unknown} themeInfo Objeto potencialmente parcial do tema (inspeção segura).
|
|
373
|
-
*/
|
|
374
|
-
themeCompatibility(themeInfo) {
|
|
375
|
-
const isRecord = (v) => typeof v === "object" && v !== null;
|
|
376
|
-
const theme = isRecord(themeInfo) ? themeInfo : void 0;
|
|
377
|
-
const palette = theme && isRecord(theme["palette"]) ? theme["palette"] : void 0;
|
|
378
|
-
const primary = palette && isRecord(palette["primary"]);
|
|
379
|
-
const transitions = theme && isRecord(theme["transitions"]) ? theme["transitions"] : void 0;
|
|
380
|
-
const duration = transitions && isRecord(transitions["duration"]);
|
|
381
|
-
this.debug("Theme compatibility check:", {
|
|
382
|
-
hasTheme: !!theme,
|
|
383
|
-
hasPalette: !!palette,
|
|
384
|
-
hasPrimary: !!primary,
|
|
385
|
-
hasTransitions: !!transitions,
|
|
386
|
-
hasDuration: !!duration
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Registra mudanças no estado de consentimento.
|
|
391
|
-
* @param {string} action Ação que causou a mudança de estado.
|
|
392
|
-
* @param {{ consented?: boolean; isModalOpen?: boolean; preferences?: Record<string, unknown> }} state Estado atual.
|
|
393
|
-
*/
|
|
394
|
-
consentState(action, state) {
|
|
395
|
-
this.debug(`Consent state change [${action}]:`, {
|
|
396
|
-
consented: state.consented,
|
|
397
|
-
isModalOpen: state.isModalOpen,
|
|
398
|
-
preferencesCount: Object.keys(state.preferences || {}).length
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Registra operações de cookie (leitura, escrita, remoção).
|
|
403
|
-
* @param {'read' | 'write' | 'delete'} operation Tipo de operação.
|
|
404
|
-
* @param {string} cookieName Nome do cookie.
|
|
405
|
-
* @param {unknown} [data] Dados associados, se aplicável.
|
|
406
|
-
*/
|
|
407
|
-
cookieOperation(operation, cookieName, data) {
|
|
408
|
-
this.debug(`Cookie ${operation}:`, {
|
|
409
|
-
name: cookieName,
|
|
410
|
-
hasData: !!data,
|
|
411
|
-
dataSize: data ? JSON.stringify(data).length : 0
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Registra a renderização de um componente.
|
|
416
|
-
* @param {string} componentName Nome do componente.
|
|
417
|
-
* @param {Record<string, unknown>} [props] Propriedades do componente.
|
|
418
|
-
*/
|
|
419
|
-
componentRender(componentName, props) {
|
|
420
|
-
this.debug(`Component render [${componentName}]:`, {
|
|
421
|
-
hasProps: !!props,
|
|
422
|
-
propsKeys: props ? Object.keys(props) : []
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Registra o status de carregamento de scripts de integração.
|
|
427
|
-
* @param {string} scriptName O nome do script.
|
|
428
|
-
* @param {'load' | 'remove'} action A ação realizada (carregar ou remover).
|
|
429
|
-
* @param {boolean} success Se a operação foi bem-sucedida.
|
|
430
|
-
*/
|
|
431
|
-
scriptIntegration(scriptName, action, success) {
|
|
432
|
-
this.info(`Script ${action} [${scriptName}]:`, success ? "SUCCESS" : "FAILED");
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Registra chamadas à API interna da biblioteca.
|
|
436
|
-
* @param {string} method Nome do método da API chamado.
|
|
437
|
-
* @param {unknown} [params] Parâmetros passados para o método.
|
|
438
|
-
*/
|
|
439
|
-
apiUsage(method, params) {
|
|
440
|
-
this.debug(`API call [${method}]:`, params);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
_ConsentLogger.IS_DEVELOPMENT = typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV === "development";
|
|
444
|
-
_ConsentLogger.IS_PRODUCTION = typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV === "production";
|
|
445
|
-
_ConsentLogger.LOG_PREFIX = "[react-lgpd-consent]";
|
|
446
|
-
var ConsentLogger = _ConsentLogger;
|
|
447
|
-
var logger = new ConsentLogger();
|
|
448
|
-
function setDebugLogging(enabled, level = 2 /* INFO */) {
|
|
449
|
-
logger.setEnabled(enabled);
|
|
450
|
-
logger.setLevel(level);
|
|
451
|
-
logger.info(`Debug logging ${enabled ? "enabled" : "disabled"} with level ${LogLevel[level]}`);
|
|
452
|
-
}
|
|
453
|
-
var DEFAULT_PROJECT_CATEGORIES = {
|
|
454
|
-
enabledCategories: ["analytics"]
|
|
455
|
-
};
|
|
456
|
-
function calculateComplianceScore(guidance) {
|
|
457
|
-
let score = 0;
|
|
458
|
-
const maxScore = 100;
|
|
459
|
-
if (!guidance.usingDefaults) score += 30;
|
|
460
|
-
const totalCategories = guidance.activeCategoriesInfo.length;
|
|
461
|
-
const toggleableCategories = guidance.activeCategoriesInfo.filter((c) => c.uiRequired).length;
|
|
462
|
-
if (totalCategories > 1) score += 20;
|
|
463
|
-
if (toggleableCategories >= 2 && toggleableCategories <= 4) score += 25;
|
|
464
|
-
const criticalWarnings = guidance.messages.filter((m) => m.severity === "error").length;
|
|
465
|
-
const warnings = guidance.messages.filter((m) => m.severity === "warning").length;
|
|
466
|
-
if (criticalWarnings === 0) score += 15;
|
|
467
|
-
if (warnings === 0) score += 10;
|
|
468
|
-
return Math.min(score, maxScore);
|
|
469
|
-
}
|
|
470
|
-
function analyzeDeveloperConfiguration(config) {
|
|
471
|
-
const guidance = {
|
|
472
|
-
warnings: [],
|
|
473
|
-
suggestions: [],
|
|
474
|
-
messages: [],
|
|
475
|
-
activeCategoriesInfo: [],
|
|
476
|
-
usingDefaults: !config,
|
|
477
|
-
complianceScore: 0
|
|
478
|
-
};
|
|
479
|
-
const addMessage = (severity, message, category, actionable = true) => {
|
|
480
|
-
const guidanceMessage = { severity, message, category, actionable };
|
|
481
|
-
guidance.messages.push(guidanceMessage);
|
|
482
|
-
if (severity === "warning" || severity === "error") {
|
|
483
|
-
guidance.warnings.push(message);
|
|
484
|
-
} else {
|
|
485
|
-
guidance.suggestions.push(message);
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
|
|
489
|
-
if (!config) {
|
|
490
|
-
addMessage(
|
|
491
|
-
"warning",
|
|
492
|
-
'LGPD-CONSENT: Nenhuma configura\xE7\xE3o de categorias especificada. Usando padr\xE3o: necessary + analytics. Para produ\xE7\xE3o, especifique explicitamente as categorias via prop "categories".',
|
|
493
|
-
"configuration"
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
guidance.activeCategoriesInfo.push({
|
|
497
|
-
id: "necessary",
|
|
498
|
-
name: "Cookies Necess\xE1rios",
|
|
499
|
-
description: "Essenciais para funcionamento b\xE1sico do site",
|
|
500
|
-
essential: true,
|
|
501
|
-
uiRequired: false,
|
|
502
|
-
cookies: COOKIE_PATTERNS_BY_CATEGORY["necessary"]
|
|
503
|
-
});
|
|
504
|
-
const enabled = finalConfig.enabledCategories || [];
|
|
505
|
-
const NAMES = {
|
|
506
|
-
analytics: { name: "Cookies Anal\xEDticos", description: "Medem uso e performance do site" },
|
|
507
|
-
functional: {
|
|
508
|
-
name: "Cookies Funcionais",
|
|
509
|
-
description: "Melhoram experi\xEAncia e funcionalidades"
|
|
510
|
-
},
|
|
511
|
-
marketing: { name: "Cookies de Marketing", description: "Publicidade direcionada e campanhas" },
|
|
512
|
-
social: { name: "Cookies de Redes Sociais", description: "Integra\xE7\xE3o com plataformas sociais" },
|
|
513
|
-
personalization: { name: "Cookies de Personaliza\xE7\xE3o", description: "Adapta\xE7\xE3o de conte\xFAdo" }
|
|
514
|
-
};
|
|
515
|
-
enabled.forEach((id) => {
|
|
516
|
-
const info = NAMES[id];
|
|
517
|
-
if (info) {
|
|
518
|
-
guidance.activeCategoriesInfo.push({
|
|
519
|
-
id,
|
|
520
|
-
name: info.name,
|
|
521
|
-
description: info.description,
|
|
522
|
-
essential: false,
|
|
523
|
-
uiRequired: true,
|
|
524
|
-
cookies: COOKIE_PATTERNS_BY_CATEGORY[id]
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
const custom = finalConfig.customCategories || [];
|
|
529
|
-
custom.forEach((cat) => {
|
|
530
|
-
if (!cat?.id || cat.id === "necessary") return;
|
|
531
|
-
guidance.activeCategoriesInfo.push({
|
|
532
|
-
id: cat.id,
|
|
533
|
-
name: cat.name,
|
|
534
|
-
description: cat.description,
|
|
535
|
-
essential: !!cat.essential,
|
|
536
|
-
uiRequired: !cat.essential,
|
|
537
|
-
cookies: cat.cookies
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
try {
|
|
541
|
-
const gt = globalThis;
|
|
542
|
-
const implied = (gt.__LGPD_REQUIRED_CATEGORIES__ || []).filter(Boolean);
|
|
543
|
-
implied.forEach((id) => {
|
|
544
|
-
if (!guidance.activeCategoriesInfo.find((c) => c.id === id)) {
|
|
545
|
-
const info = NAMES[id];
|
|
546
|
-
if (info) {
|
|
547
|
-
guidance.activeCategoriesInfo.push({
|
|
548
|
-
id,
|
|
549
|
-
name: info.name,
|
|
550
|
-
description: info.description,
|
|
551
|
-
essential: false,
|
|
552
|
-
uiRequired: true,
|
|
553
|
-
cookies: COOKIE_PATTERNS_BY_CATEGORY[id]
|
|
554
|
-
});
|
|
555
|
-
if (!enabled.includes(id)) {
|
|
556
|
-
addMessage(
|
|
557
|
-
"info",
|
|
558
|
-
`Integra\xE7\xF5es detectadas requerem a categoria '${id}'. Adicione-a em categories.enabledCategories.`,
|
|
559
|
-
"integration"
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
} catch {
|
|
566
|
-
}
|
|
567
|
-
try {
|
|
568
|
-
const gt2 = globalThis;
|
|
569
|
-
const used = gt2.__LGPD_USED_INTEGRATIONS__ || [];
|
|
570
|
-
guidance.activeCategoriesInfo = guidance.activeCategoriesInfo.map((c) => {
|
|
571
|
-
const info = getCookiesInfoForCategory(c.id, used);
|
|
572
|
-
const names = Array.from(/* @__PURE__ */ new Set([...c.cookies || [], ...info.map((d) => d.name)]));
|
|
573
|
-
return { ...c, cookies: names };
|
|
574
|
-
});
|
|
575
|
-
} catch {
|
|
576
|
-
}
|
|
577
|
-
const totalToggleable = guidance.activeCategoriesInfo.filter((c) => c.uiRequired).length;
|
|
578
|
-
if (totalToggleable === 0) {
|
|
579
|
-
addMessage(
|
|
580
|
-
"info",
|
|
581
|
-
'Apenas cookies necess\xE1rios est\xE3o configurados. Para compliance LGPD, considere adicionar categorias como "analytics" ou "functional" conforme uso real.',
|
|
582
|
-
"compliance"
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
|
-
if (totalToggleable > 5) {
|
|
586
|
-
addMessage(
|
|
587
|
-
"warning",
|
|
588
|
-
`${totalToggleable} categorias opcionais detectadas. UI com muitas op\xE7\xF5es pode prejudicar a experi\xEAncia. Considere agrupar categorias similares.`,
|
|
589
|
-
"usability"
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
guidance.complianceScore = calculateComplianceScore(guidance);
|
|
593
|
-
return guidance;
|
|
594
|
-
}
|
|
595
|
-
var GUIDANCE_CACHE = /* @__PURE__ */ new Set();
|
|
596
|
-
var SESSION_LOGGED = {
|
|
597
|
-
intro: false,
|
|
598
|
-
bestPractices: false
|
|
599
|
-
};
|
|
600
|
-
function getComplianceScoreColor(score) {
|
|
601
|
-
if (score >= 80) return "#4caf50";
|
|
602
|
-
if (score >= 60) return "#ff9800";
|
|
603
|
-
return "#f44336";
|
|
604
|
-
}
|
|
605
|
-
function logComplianceScore(prefix, score) {
|
|
606
|
-
const color = getComplianceScoreColor(score);
|
|
607
|
-
console.log(
|
|
608
|
-
`%c${prefix} Score de Conformidade LGPD: ${score}/100`,
|
|
609
|
-
`color: ${color}; font-weight: bold; font-size: 14px;`
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
function logMessagesByType(prefix, messages, type, config) {
|
|
613
|
-
const filteredMessages = messages.filter((m) => m.severity === type);
|
|
614
|
-
if (filteredMessages.length === 0) return false;
|
|
615
|
-
const typeConfig = {
|
|
616
|
-
error: {
|
|
617
|
-
show: config.showWarnings,
|
|
618
|
-
title: "Erros Cr\xEDticos",
|
|
619
|
-
color: "#d32f2f",
|
|
620
|
-
method: console.error
|
|
621
|
-
},
|
|
622
|
-
warning: {
|
|
623
|
-
show: config.showWarnings,
|
|
624
|
-
title: "Avisos de Configura\xE7\xE3o",
|
|
625
|
-
color: "#f57c00",
|
|
626
|
-
method: console.warn
|
|
627
|
-
},
|
|
628
|
-
info: {
|
|
629
|
-
show: config.showSuggestions,
|
|
630
|
-
title: "Sugest\xF5es",
|
|
631
|
-
color: "#2196f3",
|
|
632
|
-
method: console.info
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
const typeSettings = typeConfig[type];
|
|
636
|
-
if (!typeSettings.show) return false;
|
|
637
|
-
console.group(
|
|
638
|
-
`%c${prefix} ${typeSettings.title}`,
|
|
639
|
-
`color: ${typeSettings.color}; font-weight: bold;`
|
|
640
|
-
);
|
|
641
|
-
filteredMessages.forEach(
|
|
642
|
-
(msg) => typeSettings.method(
|
|
643
|
-
`%c${prefix}%c ${msg.message}`,
|
|
644
|
-
`color: ${typeSettings.color};`,
|
|
645
|
-
"color: #333;"
|
|
646
|
-
)
|
|
647
|
-
);
|
|
648
|
-
console.groupEnd();
|
|
649
|
-
return true;
|
|
650
|
-
}
|
|
651
|
-
function getGuidanceHash(guidance) {
|
|
652
|
-
const sortedWarnings = [...guidance.warnings].sort((a, b) => a.localeCompare(b));
|
|
653
|
-
const sortedSuggestions = [...guidance.suggestions].sort(
|
|
654
|
-
(a, b) => a.localeCompare(b)
|
|
655
|
-
);
|
|
656
|
-
const sortedCategories = guidance.activeCategoriesInfo.map((c) => c.id).sort((a, b) => a.localeCompare(b));
|
|
657
|
-
return JSON.stringify({
|
|
658
|
-
warnings: sortedWarnings,
|
|
659
|
-
suggestions: sortedSuggestions,
|
|
660
|
-
categories: sortedCategories,
|
|
661
|
-
usingDefaults: guidance.usingDefaults
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
function logIntroOnce() {
|
|
665
|
-
if (SESSION_LOGGED.intro) return;
|
|
666
|
-
SESSION_LOGGED.intro = true;
|
|
667
|
-
console.log(
|
|
668
|
-
`%c\u{1F36A} LGPD-CONSENT %c- Sistema de Consentimento Ativo`,
|
|
669
|
-
"background: #4caf50; color: white; padding: 4px 8px; border-radius: 4px; font-weight: bold;",
|
|
670
|
-
"color: #2e7d32; font-weight: 500;"
|
|
671
|
-
);
|
|
672
|
-
}
|
|
673
|
-
function logServerSideIfAvailable(guidance) {
|
|
674
|
-
try {
|
|
675
|
-
const gt = globalThis;
|
|
676
|
-
if (gt.process?.stdout?.write) {
|
|
677
|
-
const prefix = "\x1B[36m[LGPD-CONSENT]\x1B[0m";
|
|
678
|
-
const warnings = guidance.warnings.length;
|
|
679
|
-
const suggestions = guidance.suggestions.length;
|
|
680
|
-
const stdout = gt.process.stdout;
|
|
681
|
-
if (warnings > 0 || suggestions > 0) {
|
|
682
|
-
stdout.write(`${prefix} \u{1F527} Config: ${warnings} avisos, ${suggestions} sugest\xF5es
|
|
683
|
-
`);
|
|
684
|
-
if (warnings > 0) {
|
|
685
|
-
guidance.warnings.forEach((w) => {
|
|
686
|
-
stdout.write(`${prefix} \x1B[33m\u26A0\uFE0F ${w}\x1B[0m
|
|
687
|
-
`);
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
if (suggestions > 0) {
|
|
691
|
-
guidance.suggestions.forEach((s) => {
|
|
692
|
-
stdout.write(`${prefix} \x1B[36m\u{1F4A1} ${s}\x1B[0m
|
|
693
|
-
`);
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
} catch {
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
|
|
702
|
-
const gt = globalThis;
|
|
703
|
-
const nodeEnv = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
|
|
704
|
-
const isProd = nodeEnv === "production" || gt.__LGPD_PRODUCTION__ === true;
|
|
705
|
-
if (isProd || disableGuidanceProp) return;
|
|
706
|
-
const guidanceHash = getGuidanceHash(guidance);
|
|
707
|
-
if (GUIDANCE_CACHE.has(guidanceHash)) return;
|
|
708
|
-
GUIDANCE_CACHE.add(guidanceHash);
|
|
709
|
-
logServerSideIfAvailable(guidance);
|
|
710
|
-
const guidanceConfig = {
|
|
711
|
-
showWarnings: true,
|
|
712
|
-
showSuggestions: true,
|
|
713
|
-
showCategoriesTable: true,
|
|
714
|
-
showBestPractices: true,
|
|
715
|
-
showComplianceScore: true,
|
|
716
|
-
minimumSeverity: "info",
|
|
717
|
-
...config
|
|
718
|
-
};
|
|
719
|
-
if (guidanceConfig.messageProcessor) {
|
|
720
|
-
guidanceConfig.messageProcessor(guidance.messages);
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
logIntroOnce();
|
|
724
|
-
const PREFIX = "\u{1F36A}";
|
|
725
|
-
let hasImportantInfo = false;
|
|
726
|
-
const filteredMessages = guidance.messages.filter((msg) => {
|
|
727
|
-
const severityLevels = { info: 0, warning: 1, error: 2 };
|
|
728
|
-
const minLevel = severityLevels[guidanceConfig.minimumSeverity || "info"];
|
|
729
|
-
const msgLevel = severityLevels[msg.severity];
|
|
730
|
-
return msgLevel >= minLevel;
|
|
731
|
-
});
|
|
732
|
-
hasImportantInfo = logMessagesByType(PREFIX, filteredMessages, "error", guidanceConfig) || hasImportantInfo;
|
|
733
|
-
hasImportantInfo = logMessagesByType(PREFIX, filteredMessages, "warning", guidanceConfig) || hasImportantInfo;
|
|
734
|
-
if (hasImportantInfo || guidance.usingDefaults) {
|
|
735
|
-
hasImportantInfo = logMessagesByType(PREFIX, filteredMessages, "info", guidanceConfig) || hasImportantInfo;
|
|
736
|
-
}
|
|
737
|
-
if (guidanceConfig.showComplianceScore && guidance.complianceScore !== void 0) {
|
|
738
|
-
logComplianceScore(PREFIX, guidance.complianceScore);
|
|
739
|
-
}
|
|
740
|
-
if (guidanceConfig.showCategoriesTable && (hasImportantInfo || guidance.usingDefaults)) {
|
|
741
|
-
const rows = guidance.activeCategoriesInfo.map((cat) => ({
|
|
742
|
-
"\u{1F4CA} Categoria": cat.id,
|
|
743
|
-
"\u{1F3F7}\uFE0F Nome": cat.name,
|
|
744
|
-
"\u{1F39B}\uFE0F UI": cat.uiRequired ? "\u2705" : "\u{1F512}",
|
|
745
|
-
"\u{1F36A} Cookies": (cat.cookies || []).slice(0, 3).join(", ") + (cat.cookies && cat.cookies.length > 3 ? ` (+${cat.cookies.length - 3})` : "")
|
|
746
|
-
}));
|
|
747
|
-
if (typeof console.table === "function") {
|
|
748
|
-
console.group(`%c${PREFIX} Configura\xE7\xE3o Ativa`, "color: #4caf50; font-weight: bold;");
|
|
749
|
-
console.table(rows);
|
|
750
|
-
console.groupEnd();
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
if (!SESSION_LOGGED.bestPractices && hasImportantInfo) {
|
|
754
|
-
SESSION_LOGGED.bestPractices = true;
|
|
755
|
-
console.group(`%c${PREFIX} LGPD - Boas Pr\xE1ticas`, "color: #9c27b0; font-weight: bold;");
|
|
756
|
-
console.info(
|
|
757
|
-
`%c${PREFIX}%c Necessary: sempre ativo \u2022 Demais: opt-out por padr\xE3o`,
|
|
758
|
-
"color: #9c27b0;",
|
|
759
|
-
"color: #7b1fa2;"
|
|
760
|
-
);
|
|
761
|
-
console.info(
|
|
762
|
-
`%c${PREFIX}%c Documente pol\xEDticas claras por categoria`,
|
|
763
|
-
"color: #9c27b0;",
|
|
764
|
-
"color: #7b1fa2;"
|
|
765
|
-
);
|
|
766
|
-
console.info(
|
|
767
|
-
`%c${PREFIX}%c Registre consentimento com data/hora/origem`,
|
|
768
|
-
"color: #9c27b0;",
|
|
769
|
-
"color: #7b1fa2;"
|
|
770
|
-
);
|
|
771
|
-
console.groupEnd();
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
function useDeveloperGuidance(config, disableGuidanceProp, guidanceConfig) {
|
|
775
|
-
const guidance = React4__default.useMemo(() => analyzeDeveloperConfiguration(config), [config]);
|
|
776
|
-
React4__default.useEffect(() => {
|
|
777
|
-
if (!disableGuidanceProp) logDeveloperGuidance(guidance, disableGuidanceProp, guidanceConfig);
|
|
778
|
-
}, [guidance, disableGuidanceProp, guidanceConfig]);
|
|
779
|
-
return guidance;
|
|
780
|
-
}
|
|
781
|
-
var GUIDANCE_PRESETS = {
|
|
782
|
-
/** Configuração completa para desenvolvimento */
|
|
783
|
-
development: {
|
|
784
|
-
showWarnings: true,
|
|
785
|
-
showSuggestions: true,
|
|
786
|
-
showCategoriesTable: true,
|
|
787
|
-
showBestPractices: true,
|
|
788
|
-
showComplianceScore: true,
|
|
789
|
-
minimumSeverity: "info"
|
|
790
|
-
},
|
|
791
|
-
/** Configuração silenciosa para produção */
|
|
792
|
-
production: {
|
|
793
|
-
showWarnings: false,
|
|
794
|
-
showSuggestions: false,
|
|
795
|
-
showCategoriesTable: false,
|
|
796
|
-
showBestPractices: false,
|
|
797
|
-
showComplianceScore: false,
|
|
798
|
-
minimumSeverity: "error"
|
|
799
|
-
},
|
|
800
|
-
/** Apenas erros críticos */
|
|
801
|
-
minimal: {
|
|
802
|
-
showWarnings: true,
|
|
803
|
-
showSuggestions: false,
|
|
804
|
-
showCategoriesTable: false,
|
|
805
|
-
showBestPractices: false,
|
|
806
|
-
showComplianceScore: false,
|
|
807
|
-
minimumSeverity: "error"
|
|
808
|
-
},
|
|
809
|
-
/** Focado em conformidade LGPD */
|
|
810
|
-
compliance: {
|
|
811
|
-
showWarnings: true,
|
|
812
|
-
showSuggestions: true,
|
|
813
|
-
showCategoriesTable: true,
|
|
814
|
-
showBestPractices: true,
|
|
815
|
-
showComplianceScore: true,
|
|
816
|
-
minimumSeverity: "warning"
|
|
817
|
-
}
|
|
818
|
-
};
|
|
819
|
-
var DEFAULT_COOKIE_OPTS = {
|
|
820
|
-
name: "cookieConsent",
|
|
821
|
-
maxAgeDays: 365,
|
|
822
|
-
sameSite: "Lax",
|
|
823
|
-
secure: typeof window !== "undefined" ? window.location.protocol === "https:" : false,
|
|
824
|
-
path: "/"
|
|
825
|
-
};
|
|
826
|
-
var COOKIE_SCHEMA_VERSION = "1.0";
|
|
827
|
-
function readConsentCookie(name = DEFAULT_COOKIE_OPTS.name) {
|
|
828
|
-
logger.debug("Reading consent cookie", { name });
|
|
829
|
-
if (typeof document === "undefined") {
|
|
830
|
-
logger.debug("Cookie read skipped: server-side environment");
|
|
831
|
-
return null;
|
|
832
|
-
}
|
|
833
|
-
const raw = Cookies.get(name);
|
|
834
|
-
if (!raw) {
|
|
835
|
-
logger.debug("No consent cookie found");
|
|
836
|
-
return null;
|
|
837
|
-
}
|
|
838
|
-
try {
|
|
839
|
-
const data = JSON.parse(raw);
|
|
840
|
-
logger.cookieOperation("read", name, data);
|
|
841
|
-
if (!data.version) {
|
|
842
|
-
logger.debug("Migrating legacy cookie format");
|
|
843
|
-
return migrateLegacyCookie(data);
|
|
844
|
-
}
|
|
845
|
-
if (data.version !== COOKIE_SCHEMA_VERSION) {
|
|
846
|
-
logger.warn(`Cookie version mismatch: ${data.version} != ${COOKIE_SCHEMA_VERSION}`);
|
|
847
|
-
return null;
|
|
848
|
-
}
|
|
849
|
-
return data;
|
|
850
|
-
} catch (error) {
|
|
851
|
-
logger.error("Error parsing consent cookie", error);
|
|
852
|
-
return null;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
function migrateLegacyCookie(legacyData) {
|
|
856
|
-
try {
|
|
857
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
858
|
-
return {
|
|
859
|
-
version: COOKIE_SCHEMA_VERSION,
|
|
860
|
-
consented: Boolean(legacyData.consented) || false,
|
|
861
|
-
preferences: legacyData.preferences && typeof legacyData.preferences === "object" ? legacyData.preferences : { necessary: true },
|
|
862
|
-
consentDate: now,
|
|
863
|
-
lastUpdate: now,
|
|
864
|
-
source: "banner",
|
|
865
|
-
isModalOpen: false
|
|
866
|
-
};
|
|
867
|
-
} catch {
|
|
868
|
-
return null;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
function writeConsentCookie(state, config, opts, source = "banner") {
|
|
872
|
-
if (typeof document === "undefined") {
|
|
873
|
-
logger.debug("Cookie write skipped: server-side environment");
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
877
|
-
const o = { ...DEFAULT_COOKIE_OPTS, ...opts };
|
|
878
|
-
const cookieData = {
|
|
879
|
-
version: COOKIE_SCHEMA_VERSION,
|
|
880
|
-
consented: state.consented,
|
|
881
|
-
preferences: state.preferences,
|
|
882
|
-
consentDate: state.consentDate || now,
|
|
883
|
-
lastUpdate: now,
|
|
884
|
-
source,
|
|
885
|
-
projectConfig: config
|
|
886
|
-
};
|
|
887
|
-
logger.cookieOperation("write", o.name, cookieData);
|
|
888
|
-
Cookies.set(o.name, JSON.stringify(cookieData), {
|
|
889
|
-
expires: o.maxAgeDays,
|
|
890
|
-
sameSite: o.sameSite,
|
|
891
|
-
secure: o.secure,
|
|
892
|
-
path: o.path
|
|
893
|
-
});
|
|
894
|
-
logger.info("Consent cookie saved", {
|
|
895
|
-
consented: cookieData.consented,
|
|
896
|
-
source: cookieData.source,
|
|
897
|
-
preferencesCount: Object.keys(cookieData.preferences).length
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
function removeConsentCookie(opts) {
|
|
901
|
-
if (typeof document === "undefined") {
|
|
902
|
-
logger.debug("Cookie removal skipped: server-side environment");
|
|
903
|
-
return;
|
|
904
|
-
}
|
|
905
|
-
const o = { ...DEFAULT_COOKIE_OPTS, ...opts };
|
|
906
|
-
logger.cookieOperation("delete", o.name);
|
|
907
|
-
Cookies.remove(o.name, { path: o.path });
|
|
908
|
-
logger.info("Consent cookie removed");
|
|
909
|
-
}
|
|
910
|
-
var CategoriesContext = React4.createContext(null);
|
|
911
|
-
function CategoriesProvider({
|
|
912
|
-
children,
|
|
913
|
-
config,
|
|
914
|
-
disableDeveloperGuidance,
|
|
915
|
-
disableDiscoveryLog
|
|
916
|
-
}) {
|
|
917
|
-
const [impliedVersion, setImpliedVersion] = React4.useState(0);
|
|
918
|
-
React4.useEffect(() => {
|
|
919
|
-
const handler = () => setImpliedVersion((v) => v + 1);
|
|
920
|
-
if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
|
|
921
|
-
window.addEventListener("lgpd:requiredCategories", handler);
|
|
922
|
-
return () => window.removeEventListener("lgpd:requiredCategories", handler);
|
|
923
|
-
}
|
|
924
|
-
return () => {
|
|
925
|
-
};
|
|
926
|
-
}, []);
|
|
927
|
-
const contextValue = React4.useMemo(() => {
|
|
928
|
-
const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
|
|
929
|
-
const guidance = analyzeDeveloperConfiguration(config);
|
|
930
|
-
const toggleableCategories = guidance.activeCategoriesInfo.filter((cat) => cat.uiRequired);
|
|
931
|
-
return {
|
|
932
|
-
config: finalConfig,
|
|
933
|
-
guidance,
|
|
934
|
-
toggleableCategories,
|
|
935
|
-
allCategories: guidance.activeCategoriesInfo
|
|
936
|
-
};
|
|
937
|
-
}, [config, impliedVersion]);
|
|
938
|
-
React4.useEffect(() => {
|
|
939
|
-
logDeveloperGuidance(contextValue.guidance, disableDeveloperGuidance);
|
|
940
|
-
}, [contextValue.guidance, disableDeveloperGuidance]);
|
|
941
|
-
React4.useEffect(() => {
|
|
942
|
-
try {
|
|
943
|
-
const gt = globalThis;
|
|
944
|
-
const env = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
|
|
945
|
-
const isDev2 = env === "development";
|
|
946
|
-
if (!isDev2 || gt.__LGPD_DISCOVERY_LOGGED__ === true || disableDiscoveryLog) return;
|
|
947
|
-
const discovered = discoverRuntimeCookies();
|
|
948
|
-
const consentName = detectConsentCookieName() || DEFAULT_COOKIE_OPTS.name;
|
|
949
|
-
const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
|
|
950
|
-
if (typeof console !== "undefined") {
|
|
951
|
-
try {
|
|
952
|
-
console.group(`${PREFIX} \u{1F50E} Descoberta de cookies (experimental)`);
|
|
953
|
-
const names = Array.from(
|
|
954
|
-
new Set([consentName, ...discovered.map((d) => d.name)].filter(Boolean))
|
|
955
|
-
);
|
|
956
|
-
const rows = names.map((n) => ({ Cookie: n }));
|
|
957
|
-
if (typeof console.table === "function") console.table(rows);
|
|
958
|
-
else console.log(rows);
|
|
959
|
-
console.info(
|
|
960
|
-
`${PREFIX} \u2139\uFE0F Estes nomes s\xE3o detectados em tempo de execu\xE7\xE3o. Ajuste ou categorize via APIs de override se necess\xE1rio.`
|
|
961
|
-
);
|
|
962
|
-
console.groupEnd();
|
|
963
|
-
} catch {
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
gt.__LGPD_DISCOVERY_LOGGED__ = true;
|
|
967
|
-
} catch {
|
|
968
|
-
}
|
|
969
|
-
}, [disableDiscoveryLog]);
|
|
970
|
-
return /* @__PURE__ */ jsx(CategoriesContext.Provider, { value: contextValue, children });
|
|
971
|
-
}
|
|
972
|
-
function useCategories() {
|
|
973
|
-
const context = React4.useContext(CategoriesContext);
|
|
974
|
-
if (!context) {
|
|
975
|
-
throw new Error(
|
|
976
|
-
"useCategories deve ser usado dentro de CategoriesProvider. Certifique-se de que o ConsentProvider est\xE1 envolvendo seu componente."
|
|
977
|
-
);
|
|
978
|
-
}
|
|
979
|
-
return context;
|
|
980
|
-
}
|
|
981
|
-
function useCategoryStatus(categoryId) {
|
|
982
|
-
const { allCategories } = useCategories();
|
|
983
|
-
const category = allCategories.find((cat) => cat.id === categoryId);
|
|
984
|
-
return {
|
|
985
|
-
isActive: !!category,
|
|
986
|
-
isEssential: category?.essential || false,
|
|
987
|
-
needsToggle: category?.uiRequired || false,
|
|
988
|
-
name: category?.name,
|
|
989
|
-
description: category?.description
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
var DesignContext = React4.createContext(void 0);
|
|
993
|
-
function DesignProvider({
|
|
994
|
-
tokens,
|
|
995
|
-
children
|
|
996
|
-
}) {
|
|
997
|
-
return /* @__PURE__ */ jsx(DesignContext.Provider, { value: tokens, children });
|
|
998
|
-
}
|
|
999
|
-
function useDesignTokens() {
|
|
1000
|
-
return React4.useContext(DesignContext);
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
// src/utils/categoryUtils.ts
|
|
1004
|
-
function createProjectPreferences(config, defaultValue = false) {
|
|
1005
|
-
const preferences = {
|
|
1006
|
-
necessary: true
|
|
1007
|
-
// Sempre presente e true (essencial)
|
|
1008
|
-
};
|
|
1009
|
-
const enabledCategories = config?.enabledCategories || [];
|
|
1010
|
-
enabledCategories.forEach((category) => {
|
|
1011
|
-
if (category !== "necessary") {
|
|
1012
|
-
preferences[category] = defaultValue;
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
const customCategories = config?.customCategories || [];
|
|
1016
|
-
customCategories.forEach((cat) => {
|
|
1017
|
-
if (cat.id && cat.id !== "necessary") {
|
|
1018
|
-
preferences[cat.id] = defaultValue;
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
return preferences;
|
|
1022
|
-
}
|
|
1023
|
-
function validateProjectPreferences(preferences, config) {
|
|
1024
|
-
const validPreferences = {
|
|
1025
|
-
necessary: true
|
|
1026
|
-
// Sempre válida
|
|
1027
|
-
};
|
|
1028
|
-
const enabledCategories = config?.enabledCategories || [];
|
|
1029
|
-
enabledCategories.forEach((category) => {
|
|
1030
|
-
if (category !== "necessary" && preferences[category] !== void 0) {
|
|
1031
|
-
validPreferences[category] = preferences[category];
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1034
|
-
const customCategories = config?.customCategories || [];
|
|
1035
|
-
customCategories.forEach((cat) => {
|
|
1036
|
-
const id = cat.id;
|
|
1037
|
-
if (id && id !== "necessary" && preferences[id] !== void 0) {
|
|
1038
|
-
validPreferences[id] = preferences[id];
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
return validPreferences;
|
|
1042
|
-
}
|
|
1043
|
-
function getAllProjectCategories(config) {
|
|
1044
|
-
const allCategories = [
|
|
1045
|
-
{
|
|
1046
|
-
id: "necessary",
|
|
1047
|
-
name: "Necess\xE1rios",
|
|
1048
|
-
description: "Cookies essenciais para funcionamento b\xE1sico do site",
|
|
1049
|
-
essential: true
|
|
1050
|
-
}
|
|
1051
|
-
];
|
|
1052
|
-
const enabledCategories = config?.enabledCategories || [];
|
|
1053
|
-
enabledCategories.forEach((category) => {
|
|
1054
|
-
if (category !== "necessary") {
|
|
1055
|
-
allCategories.push(getDefaultCategoryDefinition(category));
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
const customCategories = config?.customCategories || [];
|
|
1059
|
-
customCategories.forEach((cat) => {
|
|
1060
|
-
if (cat.id && cat.id !== "necessary") {
|
|
1061
|
-
allCategories.push({ ...cat, essential: !!cat.essential });
|
|
1062
|
-
}
|
|
1063
|
-
});
|
|
1064
|
-
return allCategories;
|
|
1065
|
-
}
|
|
1066
|
-
function getDefaultCategoryDefinition(category) {
|
|
1067
|
-
const definitions = {
|
|
1068
|
-
necessary: {
|
|
1069
|
-
id: "necessary",
|
|
1070
|
-
name: "Necess\xE1rios",
|
|
1071
|
-
description: "Cookies essenciais para funcionamento b\xE1sico do site",
|
|
1072
|
-
essential: true
|
|
1073
|
-
},
|
|
1074
|
-
analytics: {
|
|
1075
|
-
id: "analytics",
|
|
1076
|
-
name: "An\xE1lise e Estat\xEDsticas",
|
|
1077
|
-
description: "Cookies para an\xE1lise de uso e estat\xEDsticas do site",
|
|
1078
|
-
essential: false
|
|
1079
|
-
},
|
|
1080
|
-
functional: {
|
|
1081
|
-
id: "functional",
|
|
1082
|
-
name: "Funcionalidades",
|
|
1083
|
-
description: "Cookies para funcionalidades extras como prefer\xEAncias e idioma",
|
|
1084
|
-
essential: false
|
|
1085
|
-
},
|
|
1086
|
-
marketing: {
|
|
1087
|
-
id: "marketing",
|
|
1088
|
-
name: "Marketing e Publicidade",
|
|
1089
|
-
description: "Cookies para publicidade direcionada e marketing",
|
|
1090
|
-
essential: false
|
|
1091
|
-
},
|
|
1092
|
-
social: {
|
|
1093
|
-
id: "social",
|
|
1094
|
-
name: "Redes Sociais",
|
|
1095
|
-
description: "Cookies para integra\xE7\xE3o com redes sociais e compartilhamento",
|
|
1096
|
-
essential: false
|
|
1097
|
-
},
|
|
1098
|
-
personalization: {
|
|
1099
|
-
id: "personalization",
|
|
1100
|
-
name: "Personaliza\xE7\xE3o",
|
|
1101
|
-
description: "Cookies para personaliza\xE7\xE3o de conte\xFAdo e experi\xEAncia",
|
|
1102
|
-
essential: false
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1105
|
-
return definitions[category];
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// src/utils/validation.ts
|
|
1109
|
-
var isDev = () => typeof process !== "undefined" && process?.env?.NODE_ENV !== "production";
|
|
1110
|
-
function validateConsentProviderProps(props) {
|
|
1111
|
-
const warnings = [];
|
|
1112
|
-
const errors = [];
|
|
1113
|
-
const sanitized = {};
|
|
1114
|
-
if (!isDev()) {
|
|
1115
|
-
if (props.categories) {
|
|
1116
|
-
const enabled = Array.from(/* @__PURE__ */ new Set([...props.categories.enabledCategories ?? []]));
|
|
1117
|
-
const sanitizedEnabled = enabled.filter((c) => c !== "necessary");
|
|
1118
|
-
sanitized.categories = {
|
|
1119
|
-
enabledCategories: sanitizedEnabled,
|
|
1120
|
-
customCategories: props.categories.customCategories
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
return { sanitized, warnings, errors };
|
|
1124
|
-
}
|
|
1125
|
-
let z;
|
|
1126
|
-
try {
|
|
1127
|
-
z = __require("zod");
|
|
1128
|
-
} catch {
|
|
1129
|
-
z = void 0;
|
|
1130
|
-
}
|
|
1131
|
-
const issues = [];
|
|
1132
|
-
if (z) {
|
|
1133
|
-
const CustomCategorySchema = z.object({
|
|
1134
|
-
id: z.string().min(1, "customCategories[].id deve ser uma string n\xE3o vazia"),
|
|
1135
|
-
name: z.string().min(1, "customCategories[].name deve ser uma string n\xE3o vazia"),
|
|
1136
|
-
description: z.string().min(1, "customCategories[].description deve ser uma string n\xE3o vazia"),
|
|
1137
|
-
essential: z.boolean().optional(),
|
|
1138
|
-
cookies: z.array(z.string().min(1)).optional()
|
|
1139
|
-
});
|
|
1140
|
-
const ProjectCategoriesConfigSchema = z.object({
|
|
1141
|
-
enabledCategories: z.array(z.string().min(1)).optional(),
|
|
1142
|
-
customCategories: z.array(CustomCategorySchema).optional()
|
|
1143
|
-
}).strict();
|
|
1144
|
-
const res = ProjectCategoriesConfigSchema.safeParse(props.categories);
|
|
1145
|
-
if (!res.success) {
|
|
1146
|
-
res.error.issues.forEach(
|
|
1147
|
-
(issue) => issues.push({ path: `categories.${issue.path.join(".")}`, message: issue.message })
|
|
1148
|
-
);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
if (!props.categories) {
|
|
1152
|
-
warnings.push(
|
|
1153
|
-
"Prop 'categories' n\xE3o fornecida. A lib aplicar\xE1 um padr\xE3o seguro, mas recomenda-se definir 'categories.enabledCategories' explicitamente para clareza e auditoria."
|
|
1154
|
-
);
|
|
1155
|
-
} else {
|
|
1156
|
-
const cat = props.categories;
|
|
1157
|
-
const enabled = Array.from(/* @__PURE__ */ new Set([...cat.enabledCategories ?? []]));
|
|
1158
|
-
if (enabled.includes("necessary")) {
|
|
1159
|
-
warnings.push("'necessary' \xE9 sempre inclu\xEDda automaticamente \u2014 remova de enabledCategories.");
|
|
1160
|
-
}
|
|
1161
|
-
const sanitizedEnabled = enabled.filter((c) => c !== "necessary");
|
|
1162
|
-
const invalidEnabled = sanitizedEnabled.filter((c) => typeof c !== "string" || c.trim() === "");
|
|
1163
|
-
if (invalidEnabled.length > 0) {
|
|
1164
|
-
warnings.push(
|
|
1165
|
-
`enabledCategories cont\xE9m valores inv\xE1lidos: ${invalidEnabled.map((v) => String(v)).join(", ")} \u2014 remova ou corrija os IDs de categoria`
|
|
1166
|
-
);
|
|
1167
|
-
}
|
|
1168
|
-
const custom = cat.customCategories ?? [];
|
|
1169
|
-
if (z) {
|
|
1170
|
-
const CustomCategorySchema = z.object({
|
|
1171
|
-
id: z.string().min(1),
|
|
1172
|
-
name: z.string().min(1),
|
|
1173
|
-
description: z.string().min(1),
|
|
1174
|
-
essential: z.boolean().optional(),
|
|
1175
|
-
cookies: z.array(z.string().min(1)).optional()
|
|
1176
|
-
});
|
|
1177
|
-
const customParse = z.array(CustomCategorySchema).safeParse(custom);
|
|
1178
|
-
if (!customParse.success) {
|
|
1179
|
-
customParse.error.issues.forEach(
|
|
1180
|
-
(issue) => issues.push({ path: `customCategories.${issue.path.join(".")}`, message: issue.message })
|
|
1181
|
-
);
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1185
|
-
const dupes = [];
|
|
1186
|
-
["necessary", ...sanitizedEnabled].forEach((id) => {
|
|
1187
|
-
if (ids.has(id)) dupes.push(id);
|
|
1188
|
-
ids.add(id);
|
|
1189
|
-
});
|
|
1190
|
-
custom.forEach((c) => {
|
|
1191
|
-
if (ids.has(c.id)) dupes.push(c.id);
|
|
1192
|
-
ids.add(c.id);
|
|
1193
|
-
});
|
|
1194
|
-
if (dupes.length > 0) {
|
|
1195
|
-
warnings.push(
|
|
1196
|
-
`IDs de categoria duplicados detectados: ${Array.from(new Set(dupes)).join(
|
|
1197
|
-
", "
|
|
1198
|
-
)} \u2014 verifique 'enabledCategories' e 'customCategories'.`
|
|
1199
|
-
);
|
|
1200
|
-
}
|
|
1201
|
-
sanitized.categories = {
|
|
1202
|
-
enabledCategories: sanitizedEnabled,
|
|
1203
|
-
customCategories: custom
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
if (warnings.length > 0) {
|
|
1207
|
-
logger.warn("Valida\xE7\xE3o do ConsentProvider:", ...warnings);
|
|
1208
|
-
}
|
|
1209
|
-
if (errors.length > 0 || issues.length > 0) {
|
|
1210
|
-
issues.forEach((i) => errors.push(`Prop inv\xE1lida: ${i.path} \u2014 ${i.message}`));
|
|
1211
|
-
logger.error("Erros de configura\xE7\xE3o do ConsentProvider:", ...errors);
|
|
1212
|
-
}
|
|
1213
|
-
return { sanitized, warnings, errors };
|
|
1214
|
-
}
|
|
1215
|
-
function CookieBanner({
|
|
1216
|
-
policyLinkUrl,
|
|
1217
|
-
termsLinkUrl,
|
|
1218
|
-
debug,
|
|
1219
|
-
blocking = true,
|
|
1220
|
-
hideBranding = false,
|
|
1221
|
-
SnackbarProps,
|
|
1222
|
-
PaperProps
|
|
1223
|
-
}) {
|
|
1224
|
-
const { consented, acceptAll, rejectAll, openPreferences } = useConsent();
|
|
1225
|
-
const texts = useConsentTexts();
|
|
1226
|
-
const isHydrated = useConsentHydration();
|
|
1227
|
-
const designTokens = useDesignTokens();
|
|
1228
|
-
const open = debug ? true : isHydrated && !consented;
|
|
1229
|
-
logger.componentRender("CookieBanner", {
|
|
1230
|
-
open,
|
|
1231
|
-
consented,
|
|
1232
|
-
isHydrated,
|
|
1233
|
-
blocking,
|
|
1234
|
-
hideBranding
|
|
1235
|
-
});
|
|
1236
|
-
if (!open) return null;
|
|
1237
|
-
const bannerStyle = (theme) => ({
|
|
1238
|
-
p: designTokens?.spacing?.padding?.banner ?? 2,
|
|
1239
|
-
maxWidth: 720,
|
|
1240
|
-
mx: "auto",
|
|
1241
|
-
backgroundColor: designTokens?.colors?.background ?? theme.palette.background?.paper,
|
|
1242
|
-
color: designTokens?.colors?.text ?? theme.palette.text?.primary,
|
|
1243
|
-
borderRadius: designTokens?.spacing?.borderRadius?.banner,
|
|
1244
|
-
fontFamily: designTokens?.typography?.fontFamily
|
|
1245
|
-
});
|
|
1246
|
-
const bannerContent = /* @__PURE__ */ jsx(Paper, { elevation: 3, sx: bannerStyle, ...PaperProps, children: /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
|
|
1247
|
-
/* @__PURE__ */ jsxs(Typography, { variant: "body2", sx: { fontSize: designTokens?.typography?.fontSize?.banner }, children: [
|
|
1248
|
-
texts.bannerMessage,
|
|
1249
|
-
" ",
|
|
1250
|
-
policyLinkUrl && /* @__PURE__ */ jsx(
|
|
1251
|
-
Link,
|
|
1252
|
-
{
|
|
1253
|
-
href: policyLinkUrl,
|
|
1254
|
-
underline: "hover",
|
|
1255
|
-
target: "_blank",
|
|
1256
|
-
rel: "noopener noreferrer",
|
|
1257
|
-
sx: { color: designTokens?.colors?.primary },
|
|
1258
|
-
children: texts.policyLink ?? "Saiba mais"
|
|
1259
|
-
}
|
|
1260
|
-
)
|
|
1261
|
-
] }),
|
|
1262
|
-
/* @__PURE__ */ jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 1, justifyContent: "flex-end", children: [
|
|
1263
|
-
/* @__PURE__ */ jsx(
|
|
1264
|
-
Button,
|
|
1265
|
-
{
|
|
1266
|
-
variant: "outlined",
|
|
1267
|
-
onClick: () => {
|
|
1268
|
-
logger.apiUsage("rejectAll", { source: "banner" });
|
|
1269
|
-
rejectAll();
|
|
1270
|
-
},
|
|
1271
|
-
sx: { color: designTokens?.colors?.secondary },
|
|
1272
|
-
children: texts.declineAll
|
|
1273
|
-
}
|
|
1274
|
-
),
|
|
1275
|
-
/* @__PURE__ */ jsx(
|
|
1276
|
-
Button,
|
|
1277
|
-
{
|
|
1278
|
-
variant: "contained",
|
|
1279
|
-
onClick: () => {
|
|
1280
|
-
logger.apiUsage("acceptAll", { source: "banner" });
|
|
1281
|
-
acceptAll();
|
|
1282
|
-
},
|
|
1283
|
-
sx: { backgroundColor: designTokens?.colors?.primary },
|
|
1284
|
-
children: texts.acceptAll
|
|
1285
|
-
}
|
|
1286
|
-
),
|
|
1287
|
-
/* @__PURE__ */ jsx(
|
|
1288
|
-
Button,
|
|
1289
|
-
{
|
|
1290
|
-
variant: "text",
|
|
1291
|
-
onClick: () => {
|
|
1292
|
-
logger.apiUsage("openPreferences", { source: "banner" });
|
|
1293
|
-
openPreferences();
|
|
1294
|
-
},
|
|
1295
|
-
sx: { color: designTokens?.colors?.text },
|
|
1296
|
-
children: texts.preferences
|
|
1297
|
-
}
|
|
1298
|
-
)
|
|
1299
|
-
] }),
|
|
1300
|
-
!hideBranding && /* @__PURE__ */ jsx(Branding, { variant: "banner" })
|
|
1301
|
-
] }) });
|
|
1302
|
-
const positionStyle = {
|
|
1303
|
-
position: "fixed",
|
|
1304
|
-
zIndex: 1300,
|
|
1305
|
-
...designTokens?.layout?.position === "top" ? { top: 0 } : { bottom: 0 },
|
|
1306
|
-
left: 0,
|
|
1307
|
-
right: 0,
|
|
1308
|
-
width: designTokens?.layout?.width?.desktop ?? "100%",
|
|
1309
|
-
p: 2
|
|
1310
|
-
};
|
|
1311
|
-
const backdropToken = designTokens?.layout?.backdrop;
|
|
1312
|
-
const resolveBackdropColor = (theme) => {
|
|
1313
|
-
if (backdropToken === false) return "transparent";
|
|
1314
|
-
if (typeof backdropToken === "string") {
|
|
1315
|
-
if (backdropToken.toLowerCase() === "auto") {
|
|
1316
|
-
const isDark2 = theme?.palette?.mode === "dark";
|
|
1317
|
-
return isDark2 ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.4)";
|
|
1318
|
-
}
|
|
1319
|
-
return backdropToken;
|
|
1320
|
-
}
|
|
1321
|
-
const isDark = theme?.palette?.mode === "dark";
|
|
1322
|
-
return isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.4)";
|
|
1323
|
-
};
|
|
1324
|
-
const isSafeRoute = (() => {
|
|
1325
|
-
try {
|
|
1326
|
-
if (typeof window === "undefined") return false;
|
|
1327
|
-
const current = new URL(window.location.href);
|
|
1328
|
-
const safeUrls = [policyLinkUrl, termsLinkUrl].filter(Boolean);
|
|
1329
|
-
return safeUrls.some((u) => {
|
|
1330
|
-
try {
|
|
1331
|
-
const target = new URL(u, current.origin);
|
|
1332
|
-
return target.pathname === current.pathname;
|
|
1333
|
-
} catch {
|
|
1334
|
-
return false;
|
|
1335
|
-
}
|
|
1336
|
-
});
|
|
1337
|
-
} catch {
|
|
1338
|
-
return false;
|
|
1339
|
-
}
|
|
1340
|
-
})();
|
|
1341
|
-
const effectiveBlocking = blocking && !isSafeRoute;
|
|
1342
|
-
if (effectiveBlocking) {
|
|
1343
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1344
|
-
/* @__PURE__ */ jsx(
|
|
1345
|
-
Box,
|
|
1346
|
-
{
|
|
1347
|
-
sx: (theme) => ({
|
|
1348
|
-
position: "fixed",
|
|
1349
|
-
top: 0,
|
|
1350
|
-
left: 0,
|
|
1351
|
-
right: 0,
|
|
1352
|
-
bottom: 0,
|
|
1353
|
-
backgroundColor: resolveBackdropColor(theme),
|
|
1354
|
-
zIndex: 1299
|
|
1355
|
-
})
|
|
1356
|
-
}
|
|
1357
|
-
),
|
|
1358
|
-
/* @__PURE__ */ jsx(Box, { sx: positionStyle, children: bannerContent })
|
|
1359
|
-
] });
|
|
1360
|
-
}
|
|
1361
|
-
return /* @__PURE__ */ jsx(
|
|
1362
|
-
Snackbar,
|
|
1363
|
-
{
|
|
1364
|
-
open,
|
|
1365
|
-
anchorOrigin: {
|
|
1366
|
-
vertical: designTokens?.layout?.position === "top" ? "top" : "bottom",
|
|
1367
|
-
horizontal: "center"
|
|
1368
|
-
},
|
|
1369
|
-
...SnackbarProps,
|
|
1370
|
-
children: bannerContent
|
|
1371
|
-
}
|
|
1372
|
-
);
|
|
1373
|
-
}
|
|
1374
|
-
var PreferencesModal = React4.lazy(
|
|
1375
|
-
() => import('./PreferencesModal-5KNHWW57.js').then((m) => ({
|
|
1376
|
-
default: m.PreferencesModal
|
|
1377
|
-
}))
|
|
1378
|
-
);
|
|
1379
|
-
var FloatingPreferencesButton = React4.lazy(
|
|
1380
|
-
() => import('./FloatingPreferencesButton-IY7TFD7D.js').then((m) => ({
|
|
1381
|
-
default: m.FloatingPreferencesButton
|
|
1382
|
-
}))
|
|
1383
|
-
);
|
|
1384
|
-
function createFullConsentState(consented, preferences, source, projectConfig, isModalOpen = false, existingState) {
|
|
1385
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1386
|
-
return {
|
|
1387
|
-
version: "1.0",
|
|
1388
|
-
consented,
|
|
1389
|
-
preferences,
|
|
1390
|
-
consentDate: existingState?.consentDate || now,
|
|
1391
|
-
lastUpdate: now,
|
|
1392
|
-
source,
|
|
1393
|
-
projectConfig,
|
|
1394
|
-
isModalOpen
|
|
1395
|
-
};
|
|
1396
|
-
}
|
|
1397
|
-
var DEFAULT_TEXTS = {
|
|
1398
|
-
// Textos básicos
|
|
1399
|
-
bannerMessage: "Utilizamos cookies para melhorar sua experi\xEAncia.",
|
|
1400
|
-
acceptAll: "Aceitar todos",
|
|
1401
|
-
declineAll: "Recusar",
|
|
1402
|
-
preferences: "Prefer\xEAncias",
|
|
1403
|
-
policyLink: "Saiba mais",
|
|
1404
|
-
modalTitle: "Prefer\xEAncias de Cookies",
|
|
1405
|
-
modalIntro: "Ajuste as categorias de cookies. Cookies necess\xE1rios s\xE3o sempre utilizados para funcionalidades b\xE1sicas.",
|
|
1406
|
-
save: "Salvar prefer\xEAncias",
|
|
1407
|
-
necessaryAlwaysOn: "Cookies necess\xE1rios (sempre ativos)",
|
|
1408
|
-
// Textos adicionais para UI customizada
|
|
1409
|
-
preferencesButton: "Configurar Cookies",
|
|
1410
|
-
preferencesTitle: "Gerenciar Prefer\xEAncias de Cookies",
|
|
1411
|
-
preferencesDescription: "Escolha quais tipos de cookies voc\xEA permite que sejam utilizados.",
|
|
1412
|
-
close: "Fechar",
|
|
1413
|
-
accept: "Aceitar",
|
|
1414
|
-
reject: "Rejeitar",
|
|
1415
|
-
// Textos ANPD expandidos (opcionais)
|
|
1416
|
-
brandingPoweredBy: "fornecido por",
|
|
1417
|
-
controllerInfo: void 0,
|
|
1418
|
-
// Exibido se definido
|
|
1419
|
-
dataTypes: void 0,
|
|
1420
|
-
// Exibido se definido
|
|
1421
|
-
thirdPartySharing: void 0,
|
|
1422
|
-
// Exibido se definido
|
|
1423
|
-
userRights: void 0,
|
|
1424
|
-
// Exibido se definido
|
|
1425
|
-
contactInfo: void 0,
|
|
1426
|
-
// Exibido se definido
|
|
1427
|
-
retentionPeriod: void 0,
|
|
1428
|
-
// Exibido se definido
|
|
1429
|
-
lawfulBasis: void 0,
|
|
1430
|
-
// Exibido se definido
|
|
1431
|
-
transferCountries: void 0
|
|
1432
|
-
// Exibido se definido
|
|
1433
|
-
};
|
|
1434
|
-
function reducer(state, action) {
|
|
1435
|
-
logger.consentState(action.type, state);
|
|
1436
|
-
switch (action.type) {
|
|
1437
|
-
case "ACCEPT_ALL": {
|
|
1438
|
-
const prefs = createProjectPreferences(action.config, true);
|
|
1439
|
-
const newState = createFullConsentState(true, prefs, "banner", action.config, false, state);
|
|
1440
|
-
logger.info("User accepted all cookies", {
|
|
1441
|
-
preferences: newState.preferences
|
|
1442
|
-
});
|
|
1443
|
-
return newState;
|
|
1444
|
-
}
|
|
1445
|
-
case "REJECT_ALL": {
|
|
1446
|
-
const prefs = createProjectPreferences(action.config, false);
|
|
1447
|
-
const newState = createFullConsentState(true, prefs, "banner", action.config, false, state);
|
|
1448
|
-
logger.info("User rejected all cookies", {
|
|
1449
|
-
preferences: newState.preferences
|
|
1450
|
-
});
|
|
1451
|
-
return newState;
|
|
1452
|
-
}
|
|
1453
|
-
case "SET_CATEGORY":
|
|
1454
|
-
logger.debug("Category preference changed", {
|
|
1455
|
-
category: action.category,
|
|
1456
|
-
value: action.value
|
|
1457
|
-
});
|
|
1458
|
-
return {
|
|
1459
|
-
...state,
|
|
1460
|
-
preferences: {
|
|
1461
|
-
...state.preferences,
|
|
1462
|
-
[action.category]: action.value
|
|
1463
|
-
},
|
|
1464
|
-
lastUpdate: (/* @__PURE__ */ new Date()).toISOString()
|
|
1465
|
-
};
|
|
1466
|
-
case "SET_PREFERENCES":
|
|
1467
|
-
logger.info("Preferences saved", { preferences: action.preferences });
|
|
1468
|
-
return createFullConsentState(true, action.preferences, "modal", action.config, false, state);
|
|
1469
|
-
case "OPEN_MODAL":
|
|
1470
|
-
return { ...state, isModalOpen: true };
|
|
1471
|
-
case "CLOSE_MODAL":
|
|
1472
|
-
return createFullConsentState(true, state.preferences, "modal", action.config, false, state);
|
|
1473
|
-
case "RESET": {
|
|
1474
|
-
return createFullConsentState(
|
|
1475
|
-
false,
|
|
1476
|
-
createProjectPreferences(action.config),
|
|
1477
|
-
"programmatic",
|
|
1478
|
-
action.config,
|
|
1479
|
-
false
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
case "HYDRATE": {
|
|
1483
|
-
const validatedPreferences = validateProjectPreferences(
|
|
1484
|
-
action.state.preferences,
|
|
1485
|
-
action.config
|
|
1486
|
-
);
|
|
1487
|
-
return {
|
|
1488
|
-
...action.state,
|
|
1489
|
-
preferences: validatedPreferences,
|
|
1490
|
-
isModalOpen: false
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
default:
|
|
1494
|
-
return state;
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
var StateCtx = React4.createContext(null);
|
|
1498
|
-
var ActionsCtx = React4.createContext(null);
|
|
1499
|
-
var TextsCtx = React4.createContext(DEFAULT_TEXTS);
|
|
1500
|
-
var HydrationCtx = React4.createContext(false);
|
|
1501
|
-
function ConsentProvider({
|
|
1502
|
-
initialState,
|
|
1503
|
-
categories,
|
|
1504
|
-
texts: textsProp,
|
|
1505
|
-
theme,
|
|
1506
|
-
designTokens,
|
|
1507
|
-
PreferencesModalComponent,
|
|
1508
|
-
preferencesModalProps = {},
|
|
1509
|
-
CookieBannerComponent,
|
|
1510
|
-
cookieBannerProps = {},
|
|
1511
|
-
FloatingPreferencesButtonComponent,
|
|
1512
|
-
floatingPreferencesButtonProps = {},
|
|
1513
|
-
disableFloatingPreferencesButton = false,
|
|
1514
|
-
blocking = false,
|
|
1515
|
-
blockingStrategy = "auto",
|
|
1516
|
-
hideBranding = false,
|
|
1517
|
-
onConsentGiven,
|
|
1518
|
-
onPreferencesSaved,
|
|
1519
|
-
cookie: cookieOpts,
|
|
1520
|
-
disableDeveloperGuidance,
|
|
1521
|
-
guidanceConfig,
|
|
1522
|
-
children,
|
|
1523
|
-
disableDiscoveryLog
|
|
1524
|
-
}) {
|
|
1525
|
-
const texts = React4.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
|
|
1526
|
-
const cookie = React4.useMemo(
|
|
1527
|
-
() => ({ ...DEFAULT_COOKIE_OPTS, ...cookieOpts ?? {} }),
|
|
1528
|
-
[cookieOpts]
|
|
1529
|
-
);
|
|
1530
|
-
const mergedTheme = theme;
|
|
1531
|
-
const finalCategoriesConfig = React4.useMemo(() => {
|
|
1532
|
-
const isProd = typeof process !== "undefined" && process.env?.NODE_ENV === "production";
|
|
1533
|
-
if (!categories) return DEFAULT_PROJECT_CATEGORIES;
|
|
1534
|
-
if (isProd) return categories;
|
|
1535
|
-
const { sanitized } = validateConsentProviderProps({ categories });
|
|
1536
|
-
return sanitized.categories ?? categories;
|
|
1537
|
-
}, [categories]);
|
|
1538
|
-
React4.useEffect(() => {
|
|
1539
|
-
const isProd = typeof process !== "undefined" && process.env?.NODE_ENV === "production";
|
|
1540
|
-
if (!isProd && !categories) {
|
|
1541
|
-
logger.warn(
|
|
1542
|
-
"Prop 'categories' n\xE3o fornecida. A lib aplicar\xE1 um padr\xE3o seguro, mas recomenda-se definir 'categories.enabledCategories' explicitamente para clareza e auditoria."
|
|
1543
|
-
);
|
|
1544
|
-
}
|
|
1545
|
-
}, [categories]);
|
|
1546
|
-
useDeveloperGuidance(finalCategoriesConfig, disableDeveloperGuidance, guidanceConfig);
|
|
1547
|
-
React4.useEffect(() => {
|
|
1548
|
-
const isProd = typeof process !== "undefined" && process.env?.NODE_ENV === "production";
|
|
1549
|
-
if (!isProd && PreferencesModalComponent) {
|
|
1550
|
-
console.info(
|
|
1551
|
-
"[LGPD-CONSENT] Dica: seu PreferencesModal \xE9 customizado. Garanta exibir os detalhes dos cookies por categoria (nome, finalidade, dura\xE7\xE3o) usando as APIs setCookieCatalogOverrides / setCookieCategoryOverrides e getCookiesInfoForCategory. Consulte QUICKSTART e INTEGRACOES.md."
|
|
1552
|
-
);
|
|
1553
|
-
}
|
|
1554
|
-
}, [PreferencesModalComponent]);
|
|
1555
|
-
const boot = React4.useMemo(() => {
|
|
1556
|
-
if (initialState) return { ...initialState, isModalOpen: false };
|
|
1557
|
-
return createFullConsentState(
|
|
1558
|
-
false,
|
|
1559
|
-
createProjectPreferences(finalCategoriesConfig),
|
|
1560
|
-
"banner",
|
|
1561
|
-
finalCategoriesConfig,
|
|
1562
|
-
false
|
|
1563
|
-
);
|
|
1564
|
-
}, [initialState, finalCategoriesConfig]);
|
|
1565
|
-
const [state, dispatch] = React4.useReducer(reducer, boot);
|
|
1566
|
-
const [isHydrated, setIsHydrated] = React4.useState(false);
|
|
1567
|
-
React4.useEffect(() => {
|
|
1568
|
-
if (!initialState) {
|
|
1569
|
-
const saved = readConsentCookie(cookie.name);
|
|
1570
|
-
if (saved?.consented) {
|
|
1571
|
-
dispatch({
|
|
1572
|
-
type: "HYDRATE",
|
|
1573
|
-
state: saved,
|
|
1574
|
-
config: finalCategoriesConfig
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
setIsHydrated(true);
|
|
1579
|
-
}, [cookie.name, initialState, finalCategoriesConfig]);
|
|
1580
|
-
React4.useEffect(() => {
|
|
1581
|
-
if (state.consented) writeConsentCookie(state, finalCategoriesConfig, cookie);
|
|
1582
|
-
}, [state, cookie, finalCategoriesConfig]);
|
|
1583
|
-
const prevConsented = React4.useRef(state.consented);
|
|
1584
|
-
React4.useEffect(() => {
|
|
1585
|
-
if (!prevConsented.current && state.consented && onConsentGiven) {
|
|
1586
|
-
setTimeout(() => onConsentGiven(state), 150);
|
|
1587
|
-
}
|
|
1588
|
-
prevConsented.current = state.consented;
|
|
1589
|
-
}, [state, onConsentGiven]);
|
|
1590
|
-
const api = React4.useMemo(() => {
|
|
1591
|
-
const acceptAll = () => dispatch({ type: "ACCEPT_ALL", config: finalCategoriesConfig });
|
|
1592
|
-
const rejectAll = () => dispatch({ type: "REJECT_ALL", config: finalCategoriesConfig });
|
|
1593
|
-
const setPreference = (category, value) => dispatch({ type: "SET_CATEGORY", category, value });
|
|
1594
|
-
const setPreferences = (preferences) => {
|
|
1595
|
-
dispatch({
|
|
1596
|
-
type: "SET_PREFERENCES",
|
|
1597
|
-
preferences,
|
|
1598
|
-
config: finalCategoriesConfig
|
|
1599
|
-
});
|
|
1600
|
-
if (onPreferencesSaved) {
|
|
1601
|
-
setTimeout(() => onPreferencesSaved(preferences), 150);
|
|
1602
|
-
}
|
|
1603
|
-
};
|
|
1604
|
-
const openPreferences = () => dispatch({ type: "OPEN_MODAL" });
|
|
1605
|
-
const closePreferences = () => dispatch({ type: "CLOSE_MODAL", config: finalCategoriesConfig });
|
|
1606
|
-
const resetConsent = () => {
|
|
1607
|
-
removeConsentCookie(cookie);
|
|
1608
|
-
dispatch({ type: "RESET", config: finalCategoriesConfig });
|
|
1609
|
-
};
|
|
1610
|
-
return {
|
|
1611
|
-
consented: !!state.consented,
|
|
1612
|
-
preferences: state.preferences,
|
|
1613
|
-
isModalOpen: state.isModalOpen,
|
|
1614
|
-
acceptAll,
|
|
1615
|
-
rejectAll,
|
|
1616
|
-
setPreference,
|
|
1617
|
-
setPreferences,
|
|
1618
|
-
openPreferences,
|
|
1619
|
-
closePreferences,
|
|
1620
|
-
resetConsent
|
|
1621
|
-
};
|
|
1622
|
-
}, [state, cookie, finalCategoriesConfig, onPreferencesSaved]);
|
|
1623
|
-
React4.useEffect(() => {
|
|
1624
|
-
_registerGlobalOpenPreferences(api.openPreferences);
|
|
1625
|
-
return () => _unregisterGlobalOpenPreferences();
|
|
1626
|
-
}, [api.openPreferences]);
|
|
1627
|
-
const providerBackdropColor = React4.useMemo(() => {
|
|
1628
|
-
const backdrop = designTokens?.layout?.backdrop;
|
|
1629
|
-
if (backdrop === false) return "transparent";
|
|
1630
|
-
if (typeof backdrop === "string") return backdrop;
|
|
1631
|
-
return "rgba(0, 0, 0, 0.4)";
|
|
1632
|
-
}, [designTokens]);
|
|
1633
|
-
const content = /* @__PURE__ */ jsx(StateCtx.Provider, { value: state, children: /* @__PURE__ */ jsx(ActionsCtx.Provider, { value: api, children: /* @__PURE__ */ jsx(TextsCtx.Provider, { value: texts, children: /* @__PURE__ */ jsx(HydrationCtx.Provider, { value: isHydrated, children: /* @__PURE__ */ jsx(DesignProvider, { tokens: designTokens, children: /* @__PURE__ */ jsxs(
|
|
1634
|
-
CategoriesProvider,
|
|
1635
|
-
{
|
|
1636
|
-
config: finalCategoriesConfig,
|
|
1637
|
-
disableDeveloperGuidance,
|
|
1638
|
-
disableDiscoveryLog,
|
|
1639
|
-
children: [
|
|
1640
|
-
children,
|
|
1641
|
-
/* @__PURE__ */ jsx(React4.Suspense, { fallback: null, children: PreferencesModalComponent ? /* @__PURE__ */ jsx(
|
|
1642
|
-
PreferencesModalComponent,
|
|
1643
|
-
{
|
|
1644
|
-
preferences: api.preferences,
|
|
1645
|
-
setPreferences: api.setPreferences,
|
|
1646
|
-
closePreferences: api.closePreferences,
|
|
1647
|
-
isModalOpen: api.isModalOpen,
|
|
1648
|
-
texts,
|
|
1649
|
-
...preferencesModalProps
|
|
1650
|
-
}
|
|
1651
|
-
) : /* @__PURE__ */ jsx(PreferencesModal, { hideBranding }) }),
|
|
1652
|
-
blocking && isHydrated && !state.consented && blockingStrategy === "provider" && /* @__PURE__ */ jsx(
|
|
1653
|
-
"div",
|
|
1654
|
-
{
|
|
1655
|
-
style: {
|
|
1656
|
-
position: "fixed",
|
|
1657
|
-
top: 0,
|
|
1658
|
-
left: 0,
|
|
1659
|
-
right: 0,
|
|
1660
|
-
bottom: 0,
|
|
1661
|
-
backgroundColor: providerBackdropColor,
|
|
1662
|
-
zIndex: 1299
|
|
1663
|
-
},
|
|
1664
|
-
"data-testid": "lgpd-provider-overlay",
|
|
1665
|
-
"aria-hidden": true
|
|
1666
|
-
}
|
|
1667
|
-
),
|
|
1668
|
-
!state.consented && isHydrated && (CookieBannerComponent ? /* @__PURE__ */ jsx(
|
|
1669
|
-
CookieBannerComponent,
|
|
1670
|
-
{
|
|
1671
|
-
consented: api.consented,
|
|
1672
|
-
acceptAll: api.acceptAll,
|
|
1673
|
-
rejectAll: api.rejectAll,
|
|
1674
|
-
openPreferences: api.openPreferences,
|
|
1675
|
-
texts,
|
|
1676
|
-
blocking,
|
|
1677
|
-
...cookieBannerProps
|
|
1678
|
-
}
|
|
1679
|
-
) : /* @__PURE__ */ jsx(
|
|
1680
|
-
CookieBanner,
|
|
1681
|
-
{
|
|
1682
|
-
blocking,
|
|
1683
|
-
hideBranding,
|
|
1684
|
-
...cookieBannerProps
|
|
1685
|
-
}
|
|
1686
|
-
)),
|
|
1687
|
-
state.consented && !disableFloatingPreferencesButton && /* @__PURE__ */ jsx(React4.Suspense, { fallback: null, children: FloatingPreferencesButtonComponent ? /* @__PURE__ */ jsx(
|
|
1688
|
-
FloatingPreferencesButtonComponent,
|
|
1689
|
-
{
|
|
1690
|
-
openPreferences: api.openPreferences,
|
|
1691
|
-
consented: api.consented,
|
|
1692
|
-
...floatingPreferencesButtonProps
|
|
1693
|
-
}
|
|
1694
|
-
) : (
|
|
1695
|
-
// Encaminha `floatingPreferencesButtonProps` para o componente padrão
|
|
1696
|
-
/* @__PURE__ */ jsx(
|
|
1697
|
-
FloatingPreferencesButton,
|
|
1698
|
-
{
|
|
1699
|
-
...floatingPreferencesButtonProps ?? {}
|
|
1700
|
-
}
|
|
1701
|
-
)
|
|
1702
|
-
) })
|
|
1703
|
-
]
|
|
1704
|
-
}
|
|
1705
|
-
) }) }) }) }) });
|
|
1706
|
-
if (mergedTheme) {
|
|
1707
|
-
return /* @__PURE__ */ jsx(ThemeProvider, { theme: mergedTheme, children: content });
|
|
1708
|
-
}
|
|
1709
|
-
return content;
|
|
1710
|
-
}
|
|
1711
|
-
function useConsentStateInternal() {
|
|
1712
|
-
const ctx = React4.useContext(StateCtx);
|
|
1713
|
-
if (!ctx) throw new Error("useConsentState must be used within ConsentProvider");
|
|
1714
|
-
return ctx;
|
|
1715
|
-
}
|
|
1716
|
-
function useConsentActionsInternal() {
|
|
1717
|
-
const ctx = React4.useContext(ActionsCtx);
|
|
1718
|
-
if (!ctx) throw new Error("useConsentActions must be used within ConsentProvider");
|
|
1719
|
-
return ctx;
|
|
1720
|
-
}
|
|
1721
|
-
function useConsentTextsInternal() {
|
|
1722
|
-
const ctx = React4.useContext(TextsCtx);
|
|
1723
|
-
return ctx;
|
|
1724
|
-
}
|
|
1725
|
-
function useConsentHydrationInternal() {
|
|
1726
|
-
return React4.useContext(HydrationCtx);
|
|
1727
|
-
}
|
|
1728
|
-
var defaultTexts = DEFAULT_TEXTS;
|
|
1729
|
-
|
|
1730
|
-
// src/hooks/useConsent.ts
|
|
1731
|
-
function useConsent() {
|
|
1732
|
-
const state = useConsentStateInternal();
|
|
1733
|
-
const actions = useConsentActionsInternal();
|
|
1734
|
-
return {
|
|
1735
|
-
consented: state.consented,
|
|
1736
|
-
preferences: state.preferences,
|
|
1737
|
-
isModalOpen: state.isModalOpen,
|
|
1738
|
-
acceptAll: actions.acceptAll,
|
|
1739
|
-
rejectAll: actions.rejectAll,
|
|
1740
|
-
setPreference: actions.setPreference,
|
|
1741
|
-
setPreferences: actions.setPreferences,
|
|
1742
|
-
openPreferences: actions.openPreferences,
|
|
1743
|
-
closePreferences: actions.closePreferences,
|
|
1744
|
-
resetConsent: actions.resetConsent
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
function useConsentTexts() {
|
|
1748
|
-
return useConsentTextsInternal();
|
|
1749
|
-
}
|
|
1750
|
-
function useConsentHydration() {
|
|
1751
|
-
return useConsentHydrationInternal();
|
|
1752
|
-
}
|
|
1753
|
-
var globalOpenPreferences = null;
|
|
1754
|
-
function _registerGlobalOpenPreferences(openPreferences) {
|
|
1755
|
-
globalOpenPreferences = openPreferences;
|
|
1756
|
-
}
|
|
1757
|
-
function _unregisterGlobalOpenPreferences() {
|
|
1758
|
-
globalOpenPreferences = null;
|
|
1759
|
-
}
|
|
1760
|
-
function useOpenPreferencesModal() {
|
|
1761
|
-
const actions = useConsentActionsInternal();
|
|
1762
|
-
if (!actions) {
|
|
1763
|
-
throw new Error(
|
|
1764
|
-
"[LGPD-CONSENT] useOpenPreferencesModal deve ser usado dentro do ConsentProvider. Envolva seu componente com <ConsentProvider>."
|
|
1765
|
-
);
|
|
1766
|
-
}
|
|
1767
|
-
return actions.openPreferences;
|
|
1768
|
-
}
|
|
1769
|
-
function openPreferencesModal() {
|
|
1770
|
-
if (globalOpenPreferences) {
|
|
1771
|
-
globalOpenPreferences();
|
|
1772
|
-
} else {
|
|
1773
|
-
logger.warn(
|
|
1774
|
-
"openPreferencesModal called but no ConsentProvider is mounted. Make sure ConsentProvider is rendered before calling this function."
|
|
1775
|
-
);
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
var brandingStyles = {
|
|
1779
|
-
banner: {
|
|
1780
|
-
fontSize: "0.65rem",
|
|
1781
|
-
textAlign: "right",
|
|
1782
|
-
mt: 1,
|
|
1783
|
-
opacity: 0.7,
|
|
1784
|
-
fontStyle: "italic",
|
|
1785
|
-
width: "100%"
|
|
1786
|
-
},
|
|
1787
|
-
modal: {
|
|
1788
|
-
fontSize: "0.65rem",
|
|
1789
|
-
textAlign: "right",
|
|
1790
|
-
px: 3,
|
|
1791
|
-
pb: 1,
|
|
1792
|
-
opacity: 0.7,
|
|
1793
|
-
fontStyle: "italic",
|
|
1794
|
-
width: "100%"
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
var linkStyles = {
|
|
1798
|
-
textDecoration: "none",
|
|
1799
|
-
fontWeight: 500,
|
|
1800
|
-
"&:hover": {
|
|
1801
|
-
textDecoration: "underline"
|
|
1802
|
-
}
|
|
1803
|
-
};
|
|
1804
|
-
var Branding = React4.memo(function Branding2({
|
|
1805
|
-
variant,
|
|
1806
|
-
hidden = false
|
|
1807
|
-
}) {
|
|
1808
|
-
const texts = useConsentTexts();
|
|
1809
|
-
const designTokens = useDesignTokens();
|
|
1810
|
-
if (hidden) return null;
|
|
1811
|
-
return /* @__PURE__ */ jsxs(
|
|
1812
|
-
Typography,
|
|
1813
|
-
{
|
|
1814
|
-
variant: "caption",
|
|
1815
|
-
sx: (theme) => ({
|
|
1816
|
-
...brandingStyles[variant],
|
|
1817
|
-
color: designTokens?.colors?.text ?? theme.palette.text.secondary
|
|
1818
|
-
}),
|
|
1819
|
-
children: [
|
|
1820
|
-
texts.brandingPoweredBy || "fornecido por",
|
|
1821
|
-
" ",
|
|
1822
|
-
/* @__PURE__ */ jsx(
|
|
1823
|
-
Link,
|
|
1824
|
-
{
|
|
1825
|
-
href: "https://www.ledipo.eti.br",
|
|
1826
|
-
target: "_blank",
|
|
1827
|
-
rel: "noopener noreferrer",
|
|
1828
|
-
sx: (theme) => ({
|
|
1829
|
-
...linkStyles,
|
|
1830
|
-
color: designTokens?.colors?.primary ?? theme.palette.primary.main
|
|
1831
|
-
}),
|
|
1832
|
-
children: "L\xC9dipO.eti.br"
|
|
1833
|
-
}
|
|
1834
|
-
)
|
|
1835
|
-
]
|
|
1836
|
-
}
|
|
1837
|
-
);
|
|
1838
|
-
});
|
|
1839
|
-
|
|
1840
|
-
export { Branding, ConsentProvider, CookieBanner, DEFAULT_PROJECT_CATEGORIES, GUIDANCE_PRESETS, LogLevel, analyzeDeveloperConfiguration, categorizeDiscoveredCookies, createProjectPreferences, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, getAllProjectCategories, getCookiesInfoForCategory, logDeveloperGuidance, logger, openPreferencesModal, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentTexts, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateProjectPreferences };
|