react-lgpd-consent 0.4.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,1091 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkFJKRAERJ_cjs = require('./chunk-FJKRAERJ.cjs');
4
- var chunk25XEI2DZ_cjs = require('./chunk-25XEI2DZ.cjs');
5
- var chunkORI4PLVG_cjs = require('./chunk-ORI4PLVG.cjs');
6
- var jsxRuntime = require('react/jsx-runtime');
7
- var styles = require('@mui/material/styles');
8
- var React = require('react');
3
+ var mui = require('@react-lgpd-consent/mui');
9
4
 
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
5
 
28
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
6
 
30
- // react-lgpd-consent - Tree-shakeable ESM build
31
- function ConsentGate(props) {
32
- const { preferences } = chunkORI4PLVG_cjs.useConsent();
33
- if (!preferences[props.category]) return null;
34
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
35
- }
36
-
37
- // src/utils/scriptLoader.ts
38
- function loadScript(id, src, category = null, attrs = {}) {
39
- if (typeof document === "undefined") return Promise.resolve();
40
- if (document.getElementById(id)) return Promise.resolve();
41
- return new Promise((resolve, reject) => {
42
- const checkConsent = () => {
43
- const consentCookie = document.cookie.split("; ").find((row) => row.startsWith("cookieConsent="))?.split("=")[1];
44
- if (!consentCookie) {
45
- setTimeout(checkConsent, 100);
46
- return;
47
- }
48
- try {
49
- const consent = JSON.parse(decodeURIComponent(consentCookie));
50
- if (!consent.consented || consent.isModalOpen) {
51
- setTimeout(checkConsent, 100);
52
- return;
53
- }
54
- if (category && !consent.preferences[category]) {
55
- reject(new Error(`Consent not given for ${category} scripts`));
56
- return;
57
- }
58
- const s = document.createElement("script");
59
- s.id = id;
60
- s.src = src;
61
- s.async = true;
62
- for (const [k, v] of Object.entries(attrs)) s.setAttribute(k, v);
63
- s.onload = () => resolve();
64
- s.onerror = () => reject(new Error(`Failed to load script: ${src}`));
65
- document.body.appendChild(s);
66
- } catch {
67
- setTimeout(checkConsent, 100);
68
- }
69
- };
70
- checkConsent();
71
- });
72
- }
73
- function createDefaultConsentTheme() {
74
- return styles.createTheme({
75
- palette: {
76
- primary: {
77
- main: "#1976d2",
78
- contrastText: "#ffffff"
79
- },
80
- secondary: {
81
- main: "#dc004e",
82
- contrastText: "#ffffff"
83
- },
84
- background: {
85
- default: "#fafafa",
86
- paper: "#ffffff"
87
- },
88
- text: {
89
- primary: "#333333",
90
- secondary: "#666666"
91
- },
92
- action: {
93
- hover: "rgba(25, 118, 210, 0.04)"
94
- }
95
- },
96
- typography: {
97
- fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
98
- body2: {
99
- fontSize: "0.875rem",
100
- lineHeight: 1.43
101
- },
102
- button: {
103
- fontWeight: 500,
104
- textTransform: "none"
105
- }
106
- },
107
- components: {
108
- MuiButton: {
109
- styleOverrides: {
110
- root: {
111
- borderRadius: 8,
112
- paddingX: 16,
113
- paddingY: 8
114
- },
115
- contained: {
116
- boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
117
- "&:hover": {
118
- boxShadow: "0 4px 8px rgba(0,0,0,0.15)"
119
- }
120
- }
121
- }
122
- },
123
- MuiPaper: {
124
- styleOverrides: {
125
- root: {
126
- borderRadius: 12
127
- }
128
- }
129
- },
130
- MuiDialog: {
131
- styleOverrides: {
132
- paper: {
133
- borderRadius: 16
134
- }
135
- }
136
- }
137
- }
138
- });
139
- }
140
- var defaultConsentTheme = () => createDefaultConsentTheme();
141
-
142
- // src/utils/autoConfigureCategories.ts
143
- var FORBIDDEN_NECESSARY_SCRIPTS = /* @__PURE__ */ new Set([
144
- // Analytics & Performance
145
- "google-analytics",
146
- "google-tag-manager",
147
- "hotjar",
148
- "mixpanel",
149
- "clarity",
150
- "amplitude",
151
- "segment",
152
- // Marketing & Advertising
153
- "facebook-pixel",
154
- "twitter-pixel",
155
- "linkedin-insight",
156
- "pinterest-tag",
157
- "snapchat-pixel",
158
- "tiktok-pixel",
159
- "reddit-pixel",
160
- // Communication & Support
161
- "intercom",
162
- "zendesk-chat",
163
- "drift",
164
- "crisp",
165
- "freshchat",
166
- // A/B Testing & Optimization
167
- "optimizely",
168
- "vwo",
169
- "google-optimize",
170
- "unbounce",
171
- // Social & Content
172
- "youtube-embed",
173
- "vimeo-embed",
174
- "twitter-widget",
175
- "facebook-widget",
176
- "instagram-widget",
177
- // Accessibility (exceto scripts críticos)
178
- "userway"
179
- ]);
180
- function analyzeIntegrationCategories(integrations) {
181
- const categoryMap = {};
182
- integrations.forEach((integration) => {
183
- const category = integration.category;
184
- if (!categoryMap[category]) {
185
- categoryMap[category] = [];
186
- }
187
- categoryMap[category].push(integration.id);
188
- });
189
- return categoryMap;
190
- }
191
- function autoConfigureCategories(originalConfig, integrations, options = {}) {
192
- const { warningOnly = false, silent = false } = options;
193
- const config = originalConfig || { enabledCategories: ["analytics"] };
194
- const categoryIntegrations = analyzeIntegrationCategories(integrations);
195
- const requiredCategories = Object.keys(categoryIntegrations);
196
- const currentCategories = new Set(config.enabledCategories || []);
197
- const missingCategories = requiredCategories.filter((cat) => !currentCategories.has(cat));
198
- let adjustedConfig = { ...config };
199
- let autoEnabledCategories = [];
200
- if (missingCategories.length > 0) {
201
- if (warningOnly) {
202
- if (!silent) {
203
- logMissingCategoriesWarning(missingCategories, categoryIntegrations);
204
- }
205
- } else {
206
- autoEnabledCategories = [...missingCategories];
207
- adjustedConfig = {
208
- ...config,
209
- enabledCategories: [...currentCategories, ...missingCategories]
210
- };
211
- if (!silent) {
212
- logAutoEnabledCategories(autoEnabledCategories, categoryIntegrations);
213
- }
214
- }
215
- }
216
- return {
217
- originalConfig: config,
218
- adjustedConfig,
219
- autoEnabledCategories,
220
- missingCategories,
221
- wasAdjusted: autoEnabledCategories.length > 0,
222
- categoryIntegrations
223
- };
224
- }
225
- function logMissingCategoriesWarning(missingCategories, categoryIntegrations) {
226
- const isDev = process.env.NODE_ENV !== "production";
227
- if (!isDev) return;
228
- const PREFIX = "[\u{1F36A} LGPD-CONSENT AUTO-CONFIG]";
229
- console.group(`${PREFIX} \u26A0\uFE0F Categorias Requeridas N\xE3o Habilitadas`);
230
- missingCategories.forEach((category) => {
231
- const integrations = categoryIntegrations[category] || [];
232
- console.warn(
233
- `${PREFIX} Categoria '${category}' requerida por integra\xE7\xF5es: ${integrations.join(", ")}`
234
- );
235
- });
236
- const categoriesCode = missingCategories.map((c) => `'${c}'`).join(", ");
237
- console.warn(
238
- `${PREFIX} Para corrigir, adicione estas categorias ao ConsentProvider:`,
239
- `categories={{ enabledCategories: [...existingCategories, ${categoriesCode}] }}`
240
- );
241
- console.groupEnd();
242
- }
243
- function logAutoEnabledCategories(autoEnabledCategories, categoryIntegrations) {
244
- const isDev = process.env.NODE_ENV !== "production";
245
- if (!isDev) return;
246
- const PREFIX = "[\u{1F36A} LGPD-CONSENT AUTO-CONFIG]";
247
- console.group(`${PREFIX} \u2705 Categorias Auto-Habilitadas`);
248
- autoEnabledCategories.forEach((category) => {
249
- const integrations = categoryIntegrations[category] || [];
250
- console.info(
251
- `${PREFIX} Categoria '${category}' auto-habilitada para integra\xE7\xF5es: ${integrations.join(", ")}`
252
- );
253
- });
254
- console.info(`${PREFIX} \u{1F4A1} Essas categorias foram automaticamente adicionadas \xE0 configura\xE7\xE3o.`);
255
- console.info(`${PREFIX} \u{1F527} Para controle manual, especifique explicitamente no ConsentProvider.`);
256
- console.groupEnd();
257
- }
258
- function validateIntegrationCategories(integrations, enabledCategories) {
259
- const requiredCategories = integrations.map((i) => i.category);
260
- const enabledSet = new Set(enabledCategories);
261
- return requiredCategories.every((category) => enabledSet.has(category));
262
- }
263
- function extractCategoriesFromIntegrations(integrations) {
264
- const categories = /* @__PURE__ */ new Set();
265
- integrations.forEach((integration) => {
266
- categories.add(integration.category);
267
- });
268
- return Array.from(categories);
269
- }
270
- function validateNecessaryClassification(integrations, enabledCategories) {
271
- const warnings = [];
272
- const hasNecessaryCategory = enabledCategories.includes("necessary");
273
- if (!hasNecessaryCategory) {
274
- return warnings;
275
- }
276
- const problematicIntegrations = integrations.filter(
277
- (integration) => integration.category === "necessary" && FORBIDDEN_NECESSARY_SCRIPTS.has(integration.id)
278
- );
279
- if (problematicIntegrations.length > 0) {
280
- warnings.push(
281
- `\u26A0\uFE0F ATEN\xC7\xC3O GDPR/LGPD: As seguintes integra\xE7\xF5es NUNCA devem ser classificadas como 'necessary':`
282
- );
283
- problematicIntegrations.forEach((integration) => {
284
- warnings.push(
285
- ` \u2022 '${integration.id}' (categoria: ${integration.category}) - Requer consentimento expl\xEDcito`
286
- );
287
- });
288
- warnings.push(
289
- `\u{1F4A1} Scripts 'necessary' executam SEM consentimento e podem resultar em multas.`,
290
- `\u{1F4DA} Apenas scripts de seguran\xE7a, autentica\xE7\xE3o ou core do site se qualificam.`,
291
- `\u{1F527} Mova estes scripts para categorias apropriadas (analytics, marketing, etc.)`
292
- );
293
- }
294
- return warnings;
295
- }
296
-
297
- // src/utils/ConsentScriptLoader.tsx
298
- function ConsentScriptLoader({
299
- integrations,
300
- reloadOnChange = false
301
- }) {
302
- const { preferences, consented } = chunkORI4PLVG_cjs.useConsent();
303
- const categories = chunkORI4PLVG_cjs.useCategories();
304
- const loadedScripts = React__namespace.useRef(/* @__PURE__ */ new Set());
305
- React__namespace.useEffect(() => {
306
- try {
307
- const ids = (integrations || []).map((i) => i.id);
308
- const gt = globalThis;
309
- const current = Array.isArray(gt.__LGPD_USED_INTEGRATIONS__) ? gt.__LGPD_USED_INTEGRATIONS__ : [];
310
- const merged = Array.from(/* @__PURE__ */ new Set([...current, ...ids]));
311
- gt.__LGPD_USED_INTEGRATIONS__ = merged;
312
- try {
313
- const gmap = globalThis;
314
- const map = gmap.__LGPD_INTEGRATIONS_MAP__ || {};
315
- (integrations || []).forEach((i) => {
316
- map[i.id] = i.category;
317
- });
318
- gmap.__LGPD_INTEGRATIONS_MAP__ = map;
319
- } catch {
320
- }
321
- } catch {
322
- }
323
- }, [integrations]);
324
- React__namespace.useEffect(() => {
325
- try {
326
- const required = Array.from(new Set((integrations || []).map((i) => i.category))).filter(
327
- Boolean
328
- );
329
- const gt = globalThis;
330
- const current = Array.isArray(gt.__LGPD_REQUIRED_CATEGORIES__) ? gt.__LGPD_REQUIRED_CATEGORIES__ : [];
331
- const merged = Array.from(/* @__PURE__ */ new Set([...current, ...required]));
332
- gt.__LGPD_REQUIRED_CATEGORIES__ = merged;
333
- if (typeof window !== "undefined" && typeof window.dispatchEvent === "function") {
334
- window.dispatchEvent(new CustomEvent("lgpd:requiredCategories"));
335
- }
336
- } catch {
337
- }
338
- }, [integrations]);
339
- React__namespace.useEffect(() => {
340
- const isDev = process.env.NODE_ENV !== "production";
341
- if (!isDev || integrations.length === 0) return;
342
- const enabledCategories = categories.allCategories.map((cat) => cat.id);
343
- const isValid = validateIntegrationCategories(integrations, enabledCategories);
344
- if (!isValid) {
345
- autoConfigureCategories({ enabledCategories }, integrations, {
346
- warningOnly: true,
347
- silent: false
348
- });
349
- }
350
- const necessaryWarnings = validateNecessaryClassification(integrations, enabledCategories);
351
- if (necessaryWarnings.length > 0) {
352
- console.group("\u{1F6A8} [LGPD-CONSENT] VALIDA\xC7\xC3O DE COMPLIANCE");
353
- necessaryWarnings.forEach((warning) => {
354
- if (warning.startsWith("\u26A0\uFE0F")) {
355
- console.error(warning);
356
- } else if (warning.startsWith("\u{1F4A1}") || warning.startsWith("\u{1F4DA}") || warning.startsWith("\u{1F527}")) {
357
- console.warn(warning);
358
- } else {
359
- console.log(warning);
360
- }
361
- });
362
- console.groupEnd();
363
- }
364
- }, [integrations, categories]);
365
- React__namespace.useEffect(() => {
366
- if (!consented) return;
367
- integrations.forEach(async (integration) => {
368
- const shouldLoad = preferences[integration.category];
369
- const alreadyLoaded = loadedScripts.current.has(integration.id);
370
- if (shouldLoad && (!alreadyLoaded || reloadOnChange)) {
371
- try {
372
- await loadScript(integration.id, integration.src, integration.category, integration.attrs);
373
- if (integration.init) {
374
- integration.init();
375
- }
376
- loadedScripts.current.add(integration.id);
377
- } catch (error) {
378
- chunkORI4PLVG_cjs.logger.error(`\u274C Failed to load script: ${integration.id}`, error);
379
- }
380
- }
381
- });
382
- }, [preferences, consented, integrations, reloadOnChange]);
383
- return null;
384
- }
385
- function useConsentScriptLoader() {
386
- const { preferences, consented } = chunkORI4PLVG_cjs.useConsent();
387
- return React__namespace.useCallback(
388
- async (integration) => {
389
- if (!consented) {
390
- chunkORI4PLVG_cjs.logger.warn(`\u26A0\uFE0F Cannot load script ${integration.id}: No consent given`);
391
- return false;
392
- }
393
- const shouldLoad = preferences[integration.category];
394
- if (!shouldLoad) {
395
- chunkORI4PLVG_cjs.logger.warn(
396
- `\u26A0\uFE0F Cannot load script ${integration.id}: Category '${integration.category}' not consented`
397
- );
398
- return false;
399
- }
400
- try {
401
- await loadScript(integration.id, integration.src, integration.category, integration.attrs);
402
- if (integration.init) {
403
- integration.init();
404
- }
405
- return true;
406
- } catch (error) {
407
- chunkORI4PLVG_cjs.logger.error(`\u274C Failed to load script: ${integration.id}`, error);
408
- return false;
409
- }
410
- },
411
- [preferences, consented]
412
- );
413
- }
414
-
415
- // src/utils/scriptIntegrations.ts
416
- function createGoogleAnalyticsIntegration(config) {
417
- const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtag/js?id=${config.measurementId}`;
418
- return {
419
- id: "google-analytics",
420
- category: "analytics",
421
- src,
422
- cookies: ["_ga", "_ga_*", "_gid"],
423
- cookiesInfo: [
424
- {
425
- name: "_ga",
426
- purpose: "Identifica\xE7\xE3o \xFAnica de visitantes para an\xE1lise de tr\xE1fego",
427
- duration: "2 anos",
428
- provider: "Google Analytics"
429
- },
430
- {
431
- name: "_ga_*",
432
- purpose: "Rastreamento de sess\xF5es e eventos espec\xEDficos do stream GA4",
433
- duration: "2 anos",
434
- provider: "Google Analytics"
435
- },
436
- {
437
- name: "_gid",
438
- purpose: "Distin\xE7\xE3o de visitantes \xFAnicos em per\xEDodo de 24h",
439
- duration: "24 horas",
440
- provider: "Google Analytics"
441
- }
442
- ],
443
- init: () => {
444
- if (typeof window !== "undefined") {
445
- const w = window;
446
- w.dataLayer = w.dataLayer ?? [];
447
- const gtag = (...args) => {
448
- w.dataLayer.push(...args);
449
- };
450
- w.gtag = gtag;
451
- gtag("js", /* @__PURE__ */ new Date());
452
- gtag("config", config.measurementId, config.config ?? {});
453
- }
454
- },
455
- attrs: { async: "true" }
456
- };
457
- }
458
- function createGoogleTagManagerIntegration(config) {
459
- const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtm.js?id=${config.containerId}`;
460
- return {
461
- id: "google-tag-manager",
462
- category: "analytics",
463
- src,
464
- cookies: ["_gcl_au"],
465
- init: () => {
466
- if (typeof window !== "undefined") {
467
- const dataLayerName = config.dataLayerName || "dataLayer";
468
- const w = window;
469
- const layer = w[dataLayerName] ?? [];
470
- w[dataLayerName] = layer;
471
- layer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
472
- }
473
- }
474
- };
475
- }
476
- function createUserWayIntegration(config) {
477
- const src = config.scriptUrl ?? "https://cdn.userway.org/widget.js";
478
- return {
479
- id: "userway",
480
- category: "functional",
481
- src,
482
- cookies: ["_userway_*"],
483
- init: () => {
484
- if (typeof window !== "undefined") {
485
- const w = window;
486
- w.UserWayWidgetApp = w.UserWayWidgetApp || {};
487
- w.UserWayWidgetApp.accountId = config.accountId;
488
- }
489
- },
490
- attrs: { "data-account": config.accountId }
491
- };
492
- }
493
- var COMMON_INTEGRATIONS = {
494
- googleAnalytics: createGoogleAnalyticsIntegration,
495
- googleTagManager: createGoogleTagManagerIntegration,
496
- userway: createUserWayIntegration
497
- };
498
- function createFacebookPixelIntegration(config) {
499
- const src = config.scriptUrl ?? "https://connect.facebook.net/en_US/fbevents.js";
500
- return {
501
- id: "facebook-pixel",
502
- category: "marketing",
503
- src,
504
- cookies: ["_fbp", "fr"],
505
- init: () => {
506
- if (typeof window !== "undefined") {
507
- const w = window;
508
- if (!w.fbq) {
509
- const fbq = (...args) => {
510
- if (w.fbq && typeof w.fbq.callMethod === "function") {
511
- w.fbq.callMethod(...args);
512
- } else {
513
- fbq.queue = fbq.queue || [];
514
- fbq.queue.push(args);
515
- }
516
- };
517
- fbq.loaded = true;
518
- w.fbq = fbq;
519
- }
520
- w.fbq("init", config.pixelId, config.advancedMatching ?? {});
521
- if (config.autoTrack !== false) w.fbq("track", "PageView");
522
- }
523
- }
524
- };
525
- }
526
- function createHotjarIntegration(config) {
527
- const v = config.version ?? 6;
528
- const src = config.scriptUrl ?? `https://static.hotjar.com/c/hotjar-${config.siteId}.js?sv=${v}`;
529
- return {
530
- id: "hotjar",
531
- category: "analytics",
532
- src,
533
- cookies: [
534
- "_hjSession_*",
535
- "_hjSessionUser_*",
536
- "_hjFirstSeen",
537
- "_hjIncludedInSessionSample",
538
- "_hjAbsoluteSessionInProgress"
539
- ],
540
- cookiesInfo: [
541
- {
542
- name: "_hjSession_*",
543
- purpose: "Identifica\xE7\xE3o \xFAnica da sess\xE3o de grava\xE7\xE3o e heatmaps",
544
- duration: "30 minutos",
545
- provider: "Hotjar"
546
- },
547
- {
548
- name: "_hjSessionUser_*",
549
- purpose: "Identifica\xE7\xE3o persistente do usu\xE1rio entre sess\xF5es",
550
- duration: "365 dias",
551
- provider: "Hotjar"
552
- },
553
- {
554
- name: "_hjFirstSeen",
555
- purpose: "Detec\xE7\xE3o de primeira visita do usu\xE1rio ao site",
556
- duration: "Sess\xE3o",
557
- provider: "Hotjar"
558
- },
559
- {
560
- name: "_hjIncludedInSessionSample",
561
- purpose: "Indica se a sess\xE3o est\xE1 inclu\xEDda na amostra de grava\xE7\xE3o",
562
- duration: "30 minutos",
563
- provider: "Hotjar"
564
- },
565
- {
566
- name: "_hjAbsoluteSessionInProgress",
567
- purpose: "Detecta se uma sess\xE3o absoluta est\xE1 em progresso",
568
- duration: "30 minutos",
569
- provider: "Hotjar"
570
- }
571
- ],
572
- init: () => {
573
- if (typeof window !== "undefined") {
574
- const w = window;
575
- w._hjSettings = { hjid: config.siteId, hjsv: v };
576
- if (!w.hj) {
577
- const hj = (...args) => {
578
- hj.q = hj.q || [];
579
- hj.q.push(args);
580
- };
581
- w.hj = hj;
582
- }
583
- if (config.debug && typeof console !== "undefined" && typeof console.info === "function") {
584
- console.info("[Hotjar] initialized with siteId", config.siteId);
585
- }
586
- }
587
- }
588
- };
589
- }
590
- function createMixpanelIntegration(config) {
591
- const src = config.scriptUrl ?? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";
592
- return {
593
- id: "mixpanel",
594
- category: "analytics",
595
- src,
596
- cookies: ["mp_*"],
597
- cookiesInfo: [
598
- {
599
- name: "mp_*",
600
- purpose: "Rastreamento de eventos e propriedades do usu\xE1rio para analytics",
601
- duration: "1 ano",
602
- provider: "Mixpanel"
603
- }
604
- ],
605
- init: () => {
606
- if (typeof window !== "undefined") {
607
- const w = window;
608
- w.mixpanel = w.mixpanel || { init: () => void 0 };
609
- if (w.mixpanel && typeof w.mixpanel.init === "function") {
610
- try {
611
- w.mixpanel.init(config.token, config.config ?? {}, config.api_host);
612
- } catch (error) {
613
- if (typeof console !== "undefined" && typeof console.warn === "function") {
614
- console.warn("[Mixpanel] Failed to initialize:", error);
615
- }
616
- }
617
- }
618
- }
619
- }
620
- };
621
- }
622
- function createClarityIntegration(config) {
623
- const src = config.scriptUrl ?? `https://www.clarity.ms/tag/${config.projectId}`;
624
- return {
625
- id: "clarity",
626
- category: "analytics",
627
- src,
628
- cookies: ["_clck", "_clsk", "CLID", "ANONCHK", "MR", "MUID", "SM"],
629
- init: () => {
630
- if (typeof window !== "undefined" && typeof config.upload !== "undefined") {
631
- const w = window;
632
- if (typeof w.clarity === "function") {
633
- try {
634
- w.clarity("set", "upload", config.upload);
635
- } catch (error) {
636
- if (typeof console !== "undefined" && typeof console.warn === "function") {
637
- console.warn("[Clarity] Failed to configure upload setting:", error);
638
- }
639
- }
640
- }
641
- }
642
- }
643
- };
644
- }
645
- function createIntercomIntegration(config) {
646
- const src = config.scriptUrl ?? `https://widget.intercom.io/widget/${config.app_id}`;
647
- return {
648
- id: "intercom",
649
- category: "functional",
650
- src,
651
- cookies: ["intercom-id-*", "intercom-session-*"],
652
- init: () => {
653
- if (typeof window !== "undefined") {
654
- const w = window;
655
- if (typeof w.Intercom === "function") {
656
- try {
657
- w.Intercom("boot", { app_id: config.app_id });
658
- } catch (error) {
659
- if (typeof console !== "undefined" && typeof console.warn === "function") {
660
- console.warn("[Intercom] Failed to boot:", error);
661
- }
662
- }
663
- }
664
- }
665
- }
666
- };
667
- }
668
- function createZendeskChatIntegration(config) {
669
- const src = config.scriptUrl ?? `https://static.zdassets.com/ekr/snippet.js?key=${config.key}`;
670
- return {
671
- id: "zendesk-chat",
672
- category: "functional",
673
- src,
674
- cookies: ["__zlcmid", "_zendesk_shared_session"],
675
- init: () => {
676
- if (typeof window !== "undefined") {
677
- const w = window;
678
- if (typeof w.zE === "function") {
679
- try {
680
- w.zE("webWidget", "identify", { key: config.key });
681
- } catch (error) {
682
- if (typeof console !== "undefined" && typeof console.warn === "function") {
683
- console.warn("[Zendesk] Failed to identify:", error);
684
- }
685
- }
686
- }
687
- }
688
- }
689
- };
690
- }
691
- function createECommerceIntegrations(cfg) {
692
- const list = [];
693
- if (cfg.googleAnalytics) list.push(createGoogleAnalyticsIntegration(cfg.googleAnalytics));
694
- if (cfg.facebookPixel) list.push(createFacebookPixelIntegration(cfg.facebookPixel));
695
- if (cfg.hotjar) list.push(createHotjarIntegration(cfg.hotjar));
696
- if (cfg.userway) list.push(createUserWayIntegration(cfg.userway));
697
- return list;
698
- }
699
- function createSaaSIntegrations(cfg) {
700
- const list = [];
701
- if (cfg.googleAnalytics) list.push(createGoogleAnalyticsIntegration(cfg.googleAnalytics));
702
- if (cfg.mixpanel) list.push(createMixpanelIntegration(cfg.mixpanel));
703
- if (cfg.intercom) list.push(createIntercomIntegration(cfg.intercom));
704
- if (cfg.hotjar) list.push(createHotjarIntegration(cfg.hotjar));
705
- return list;
706
- }
707
- function createCorporateIntegrations(cfg) {
708
- const list = [];
709
- if (cfg.googleAnalytics) list.push(createGoogleAnalyticsIntegration(cfg.googleAnalytics));
710
- if (cfg.clarity) list.push(createClarityIntegration(cfg.clarity));
711
- if (cfg.zendesk) list.push(createZendeskChatIntegration(cfg.zendesk));
712
- if (cfg.userway) list.push(createUserWayIntegration(cfg.userway));
713
- return list;
714
- }
715
- var INTEGRATION_TEMPLATES = {
716
- ecommerce: {
717
- essential: ["google-analytics", "facebook-pixel"],
718
- optional: ["hotjar", "userway"],
719
- categories: ["analytics", "marketing", "functional"]
720
- },
721
- saas: {
722
- essential: ["google-analytics", "mixpanel"],
723
- optional: ["intercom", "hotjar"],
724
- categories: ["analytics", "functional"]
725
- },
726
- corporate: {
727
- essential: ["google-analytics"],
728
- optional: ["userway", "zendesk-chat", "clarity"],
729
- categories: ["analytics", "functional"]
730
- }
731
- };
732
- function suggestCategoryForScript(name) {
733
- const n = name.toLowerCase();
734
- if (n.includes("facebook") || n.includes("pixel") || n.includes("ads")) return ["marketing"];
735
- if (n.includes("hotjar") || n.includes("mixpanel") || n.includes("clarity")) return ["analytics"];
736
- if (n.includes("intercom") || n.includes("zendesk") || n.includes("chat")) return ["functional"];
737
- return ["analytics"];
738
- }
739
-
740
- // src/types/advancedTexts.ts
741
- var EXPANDED_DEFAULT_TEXTS = {
742
- // Textos adicionais
743
- confirm: "Confirmar",
744
- cancel: "Cancelar",
745
- loading: "Carregando...",
746
- // Feedback
747
- feedback: {
748
- saveSuccess: "Prefer\xEAncias salvas com sucesso!",
749
- saveError: "Erro ao salvar prefer\xEAncias. Tente novamente.",
750
- consentUpdated: "Consentimento atualizado.",
751
- cookiesRejected: "Cookies opcionais rejeitados.",
752
- settingsReset: "Configura\xE7\xF5es resetadas."
753
- },
754
- // Acessibilidade
755
- accessibility: {
756
- bannerLabel: "Banner de consentimento de cookies",
757
- modalLabel: "Modal de prefer\xEAncias de cookies",
758
- keyboardNavigation: "Use Tab para navegar, Enter para selecionar",
759
- toggleState: {
760
- enabled: "Habilitado",
761
- disabled: "Desabilitado"
762
- },
763
- liveRegion: "Regi\xE3o de an\xFAncios din\xE2micos"
764
- },
765
- // Categorias
766
- categories: {
767
- necessary: {
768
- name: "Cookies Necess\xE1rios",
769
- description: "Essenciais para o funcionamento b\xE1sico do site",
770
- examples: "Sess\xE3o, seguran\xE7a, prefer\xEAncias de idioma"
771
- },
772
- analytics: {
773
- name: "Cookies de Analytics",
774
- description: "Ajudam a entender como os visitantes usam o site",
775
- examples: "Google Analytics, contadores de p\xE1gina"
776
- },
777
- marketing: {
778
- name: "Cookies de Marketing",
779
- description: "Usados para personalizar an\xFAncios e ofertas",
780
- examples: "Facebook Pixel, Google Ads, remarketing"
781
- },
782
- functional: {
783
- name: "Cookies Funcionais",
784
- description: "Melhoram a funcionalidade e personaliza\xE7\xE3o",
785
- examples: "Chat, mapas, v\xEDdeos embarcados"
786
- },
787
- performance: {
788
- name: "Cookies de Performance",
789
- description: "Coletam informa\xE7\xF5es sobre velocidade e estabilidade",
790
- examples: "Monitoramento de erro, otimiza\xE7\xE3o de velocidade"
791
- }
792
- },
793
- // Contextos específicos
794
- contexts: {
795
- ecommerce: {
796
- cartAbandonment: "Lembramos dos produtos no seu carrinho",
797
- personalizedOffers: "Ofertas personalizadas baseadas no seu hist\xF3rico",
798
- paymentSecurity: "Seguran\xE7a adicional no processo de pagamento",
799
- productRecommendations: "Sugest\xF5es de produtos relevantes"
800
- },
801
- saas: {
802
- userAnalytics: "An\xE1lise de uso para melhorar funcionalidades",
803
- performanceMonitoring: "Monitoramento de performance da aplica\xE7\xE3o",
804
- featureUsage: "Estat\xEDsticas de uso de recursos",
805
- customerSupport: "Suporte ao cliente mais eficiente"
806
- },
807
- government: {
808
- citizenServices: "Melhoria dos servi\xE7os ao cidad\xE3o",
809
- dataProtection: "Prote\xE7\xE3o rigorosa dos dados pessoais",
810
- transparency: "Transpar\xEAncia no uso de dados",
811
- accessibility: "Recursos de acessibilidade digital"
812
- },
813
- education: {
814
- studentProgress: "Acompanhamento do progresso educacional",
815
- learningAnalytics: "Analytics para melhorar o aprendizado",
816
- accessibility: "Recursos educacionais acess\xEDveis",
817
- parentalConsent: "Consentimento parental quando necess\xE1rio"
818
- }
819
- },
820
- // Variações de tom
821
- variants: {
822
- formal: {
823
- bannerMessage: "Este s\xEDtio eletr\xF4nico utiliza cookies para otimizar a experi\xEAncia de navega\xE7\xE3o.",
824
- acceptAll: "Concordar com todos os cookies",
825
- declineAll: "Recusar cookies opcionais",
826
- modalTitle: "Configura\xE7\xE3o de Cookies"
827
- },
828
- casual: {
829
- bannerMessage: "\u{1F36A} Ei! Usamos cookies para tornar sua experi\xEAncia ainda melhor!",
830
- acceptAll: "Aceitar tudo",
831
- declineAll: "S\xF3 o essencial",
832
- modalTitle: "Seus Cookies"
833
- },
834
- concise: {
835
- bannerMessage: "Usamos cookies. Voc\xEA aceita?",
836
- acceptAll: "Sim",
837
- declineAll: "N\xE3o",
838
- modalTitle: "Cookies"
839
- },
840
- detailed: {
841
- bannerMessage: "Utilizamos cookies e tecnologias similares para melhorar sua experi\xEAncia de navega\xE7\xE3o, personalizar conte\xFAdo, analisar tr\xE1fego e oferecer funcionalidades de redes sociais.",
842
- acceptAll: "Aceitar todos os cookies e tecnologias",
843
- declineAll: "Recusar todos os cookies opcionais",
844
- modalTitle: "Centro de Prefer\xEAncias de Privacidade"
845
- }
846
- },
847
- // Internacionalização simplificada (apenas textos básicos)
848
- i18n: {
849
- en: {
850
- bannerMessage: "We use cookies to enhance your experience.",
851
- acceptAll: "Accept All",
852
- declineAll: "Decline",
853
- preferences: "Preferences",
854
- modalTitle: "Cookie Preferences",
855
- modalIntro: "Customize your cookie preferences below.",
856
- save: "Save Preferences",
857
- necessaryAlwaysOn: "Necessary cookies (always active)"
858
- },
859
- es: {
860
- bannerMessage: "Utilizamos cookies para mejorar su experiencia.",
861
- acceptAll: "Aceptar Todo",
862
- declineAll: "Rechazar",
863
- preferences: "Preferencias",
864
- modalTitle: "Preferencias de Cookies",
865
- modalIntro: "Personalice sus preferencias de cookies a continuaci\xF3n.",
866
- save: "Guardar Preferencias",
867
- necessaryAlwaysOn: "Cookies necess\xE1rias (sempre ativas)"
868
- },
869
- fr: {
870
- bannerMessage: "Nous utilisons des cookies pour am\xE9liorer votre exp\xE9rience.",
871
- acceptAll: "Tout Accepter",
872
- declineAll: "Refuser",
873
- preferences: "Pr\xE9f\xE9rences",
874
- modalTitle: "Pr\xE9f\xE9rences des Cookies",
875
- modalIntro: "Personnalisez vos pr\xE9f\xE9rences de cookies ci-dessous.",
876
- save: "Enregistrer les Pr\xE9f\xE9rences",
877
- necessaryAlwaysOn: "Cookies n\xE9cessaires (toujours actifs)"
878
- }
879
- },
880
- // Textos técnicos
881
- technical: {
882
- sessionCookies: "Cookies de sess\xE3o s\xE3o tempor\xE1rios e expiram quando voc\xEA fecha o navegador.",
883
- persistentCookies: "Cookies persistentes permanecem no seu dispositivo at\xE9 expirarem ou serem removidos.",
884
- thirdPartyCookies: "Cookies de terceiros s\xE3o definidos por dom\xEDnios diferentes do site que voc\xEA est\xE1 visitando.",
885
- browserSettings: "Voc\xEA pode gerenciar cookies nas configura\xE7\xF5es do seu navegador.",
886
- disablingImpact: "Desabilitar cookies pode afetar a funcionalidade do site."
887
- },
888
- // Cookie details
889
- cookieDetails: {
890
- tableHeaders: {
891
- name: "Nome",
892
- purpose: "Finalidade",
893
- duration: "Dura\xE7\xE3o",
894
- provider: "Fornecedor",
895
- type: "Tipo"
896
- },
897
- noCookies: "Nenhum cookie encontrado para esta categoria.",
898
- toggleDetails: {
899
- expand: "Ver detalhes",
900
- collapse: "Ocultar detalhes"
901
- }
902
- }
903
- };
904
- function resolveTexts(texts, options = {}) {
905
- const { language = "pt", variant } = options;
906
- let resolved = { ...texts };
907
- if (variant && texts.variants?.[variant]) {
908
- resolved = { ...resolved, ...texts.variants[variant] };
909
- }
910
- if (language !== "pt" && texts.i18n?.[language]) {
911
- resolved = { ...resolved, ...texts.i18n[language] };
912
- }
913
- return resolved;
914
- }
915
- var TEXT_TEMPLATES = {
916
- ecommerce: {
917
- ...EXPANDED_DEFAULT_TEXTS,
918
- bannerMessage: "Utilizamos cookies para personalizar ofertas e melhorar sua experi\xEAncia de compra.",
919
- acceptAll: "Aceitar e continuar",
920
- variants: {
921
- casual: {
922
- bannerMessage: "\u{1F6D2} Usamos cookies para encontrar as melhores ofertas para voc\xEA!",
923
- acceptAll: "Quero ofertas personalizadas!"
924
- }
925
- }
926
- },
927
- saas: {
928
- ...EXPANDED_DEFAULT_TEXTS,
929
- bannerMessage: "Utilizamos cookies para otimizar o desempenho da aplica\xE7\xE3o e sua experi\xEAncia.",
930
- acceptAll: "Aceitar e otimizar",
931
- variants: {
932
- formal: {
933
- bannerMessage: "Esta aplica\xE7\xE3o utiliza cookies para an\xE1lise de performance e melhoria cont\xEDnua da experi\xEAncia do usu\xE1rio.",
934
- acceptAll: "Autorizar coleta de dados de uso"
935
- }
936
- }
937
- },
938
- government: {
939
- ...EXPANDED_DEFAULT_TEXTS,
940
- bannerMessage: "Este portal utiliza cookies em conformidade com a LGPD para melhorar os servi\xE7os p\xFAblicos.",
941
- acceptAll: "Aceitar em conformidade",
942
- variants: {
943
- formal: {
944
- bannerMessage: "Este s\xEDtio eletr\xF4nico do governo utiliza cookies estritamente necess\xE1rios e opcionais, em conformidade com a Lei Geral de Prote\xE7\xE3o de Dados.",
945
- acceptAll: "Concordar com o uso de cookies"
946
- }
947
- }
948
- }
949
- };
950
-
951
- Object.defineProperty(exports, "FloatingPreferencesButton", {
952
- enumerable: true,
953
- get: function () { return chunkFJKRAERJ_cjs.FloatingPreferencesButton; }
954
- });
955
- Object.defineProperty(exports, "PreferencesModal", {
956
- enumerable: true,
957
- get: function () { return chunk25XEI2DZ_cjs.PreferencesModal; }
958
- });
959
- Object.defineProperty(exports, "ConsentProvider", {
960
- enumerable: true,
961
- get: function () { return chunkORI4PLVG_cjs.ConsentProvider; }
962
- });
963
- Object.defineProperty(exports, "CookieBanner", {
964
- enumerable: true,
965
- get: function () { return chunkORI4PLVG_cjs.CookieBanner; }
966
- });
967
- Object.defineProperty(exports, "DEFAULT_PROJECT_CATEGORIES", {
968
- enumerable: true,
969
- get: function () { return chunkORI4PLVG_cjs.DEFAULT_PROJECT_CATEGORIES; }
970
- });
971
- Object.defineProperty(exports, "GUIDANCE_PRESETS", {
972
- enumerable: true,
973
- get: function () { return chunkORI4PLVG_cjs.GUIDANCE_PRESETS; }
974
- });
975
- Object.defineProperty(exports, "LogLevel", {
976
- enumerable: true,
977
- get: function () { return chunkORI4PLVG_cjs.LogLevel; }
978
- });
979
- Object.defineProperty(exports, "analyzeDeveloperConfiguration", {
980
- enumerable: true,
981
- get: function () { return chunkORI4PLVG_cjs.analyzeDeveloperConfiguration; }
982
- });
983
- Object.defineProperty(exports, "categorizeDiscoveredCookies", {
984
- enumerable: true,
985
- get: function () { return chunkORI4PLVG_cjs.categorizeDiscoveredCookies; }
986
- });
987
- Object.defineProperty(exports, "createProjectPreferences", {
988
- enumerable: true,
989
- get: function () { return chunkORI4PLVG_cjs.createProjectPreferences; }
990
- });
991
- Object.defineProperty(exports, "defaultTexts", {
992
- enumerable: true,
993
- get: function () { return chunkORI4PLVG_cjs.defaultTexts; }
994
- });
995
- Object.defineProperty(exports, "detectConsentCookieName", {
996
- enumerable: true,
997
- get: function () { return chunkORI4PLVG_cjs.detectConsentCookieName; }
998
- });
999
- Object.defineProperty(exports, "discoverRuntimeCookies", {
1000
- enumerable: true,
1001
- get: function () { return chunkORI4PLVG_cjs.discoverRuntimeCookies; }
1002
- });
1003
- Object.defineProperty(exports, "getAllProjectCategories", {
1004
- enumerable: true,
1005
- get: function () { return chunkORI4PLVG_cjs.getAllProjectCategories; }
1006
- });
1007
- Object.defineProperty(exports, "getCookiesInfoForCategory", {
1008
- enumerable: true,
1009
- get: function () { return chunkORI4PLVG_cjs.getCookiesInfoForCategory; }
1010
- });
1011
- Object.defineProperty(exports, "logDeveloperGuidance", {
1012
- enumerable: true,
1013
- get: function () { return chunkORI4PLVG_cjs.logDeveloperGuidance; }
1014
- });
1015
- Object.defineProperty(exports, "openPreferencesModal", {
1016
- enumerable: true,
1017
- get: function () { return chunkORI4PLVG_cjs.openPreferencesModal; }
1018
- });
1019
- Object.defineProperty(exports, "setCookieCatalogOverrides", {
1020
- enumerable: true,
1021
- get: function () { return chunkORI4PLVG_cjs.setCookieCatalogOverrides; }
1022
- });
1023
- Object.defineProperty(exports, "setCookieCategoryOverrides", {
1024
- enumerable: true,
1025
- get: function () { return chunkORI4PLVG_cjs.setCookieCategoryOverrides; }
1026
- });
1027
- Object.defineProperty(exports, "setDebugLogging", {
1028
- enumerable: true,
1029
- get: function () { return chunkORI4PLVG_cjs.setDebugLogging; }
1030
- });
1031
- Object.defineProperty(exports, "useCategories", {
1032
- enumerable: true,
1033
- get: function () { return chunkORI4PLVG_cjs.useCategories; }
1034
- });
1035
- Object.defineProperty(exports, "useCategoryStatus", {
1036
- enumerable: true,
1037
- get: function () { return chunkORI4PLVG_cjs.useCategoryStatus; }
1038
- });
1039
- Object.defineProperty(exports, "useConsent", {
1040
- enumerable: true,
1041
- get: function () { return chunkORI4PLVG_cjs.useConsent; }
1042
- });
1043
- Object.defineProperty(exports, "useConsentHydration", {
1044
- enumerable: true,
1045
- get: function () { return chunkORI4PLVG_cjs.useConsentHydration; }
1046
- });
1047
- Object.defineProperty(exports, "useConsentTexts", {
1048
- enumerable: true,
1049
- get: function () { return chunkORI4PLVG_cjs.useConsentTexts; }
1050
- });
1051
- Object.defineProperty(exports, "useDeveloperGuidance", {
1052
- enumerable: true,
1053
- get: function () { return chunkORI4PLVG_cjs.useDeveloperGuidance; }
1054
- });
1055
- Object.defineProperty(exports, "useOpenPreferencesModal", {
1056
- enumerable: true,
1057
- get: function () { return chunkORI4PLVG_cjs.useOpenPreferencesModal; }
1058
- });
1059
- Object.defineProperty(exports, "validateProjectPreferences", {
1060
- enumerable: true,
1061
- get: function () { return chunkORI4PLVG_cjs.validateProjectPreferences; }
7
+ Object.keys(mui).forEach(function (k) {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
+ enumerable: true,
10
+ get: function () { return mui[k]; }
11
+ });
1062
12
  });
1063
- exports.COMMON_INTEGRATIONS = COMMON_INTEGRATIONS;
1064
- exports.ConsentGate = ConsentGate;
1065
- exports.ConsentScriptLoader = ConsentScriptLoader;
1066
- exports.EXPANDED_DEFAULT_TEXTS = EXPANDED_DEFAULT_TEXTS;
1067
- exports.INTEGRATION_TEMPLATES = INTEGRATION_TEMPLATES;
1068
- exports.TEXT_TEMPLATES = TEXT_TEMPLATES;
1069
- exports.analyzeIntegrationCategories = analyzeIntegrationCategories;
1070
- exports.autoConfigureCategories = autoConfigureCategories;
1071
- exports.createClarityIntegration = createClarityIntegration;
1072
- exports.createCorporateIntegrations = createCorporateIntegrations;
1073
- exports.createDefaultConsentTheme = createDefaultConsentTheme;
1074
- exports.createECommerceIntegrations = createECommerceIntegrations;
1075
- exports.createFacebookPixelIntegration = createFacebookPixelIntegration;
1076
- exports.createGoogleAnalyticsIntegration = createGoogleAnalyticsIntegration;
1077
- exports.createGoogleTagManagerIntegration = createGoogleTagManagerIntegration;
1078
- exports.createHotjarIntegration = createHotjarIntegration;
1079
- exports.createIntercomIntegration = createIntercomIntegration;
1080
- exports.createMixpanelIntegration = createMixpanelIntegration;
1081
- exports.createSaaSIntegrations = createSaaSIntegrations;
1082
- exports.createUserWayIntegration = createUserWayIntegration;
1083
- exports.createZendeskChatIntegration = createZendeskChatIntegration;
1084
- exports.defaultConsentTheme = defaultConsentTheme;
1085
- exports.extractCategoriesFromIntegrations = extractCategoriesFromIntegrations;
1086
- exports.loadScript = loadScript;
1087
- exports.resolveTexts = resolveTexts;
1088
- exports.suggestCategoryForScript = suggestCategoryForScript;
1089
- exports.useConsentScriptLoader = useConsentScriptLoader;
1090
- exports.validateIntegrationCategories = validateIntegrationCategories;
1091
- exports.validateNecessaryClassification = validateNecessaryClassification;