@react-lgpd-consent/core 0.7.1 → 0.7.2

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.js CHANGED
@@ -11,6 +11,219 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
11
11
  throw Error('Dynamic require of "' + x + '" is not supported');
12
12
  });
13
13
 
14
+ // src/types/advancedTexts.ts
15
+ var EXPANDED_DEFAULT_TEXTS = {
16
+ // Textos adicionais
17
+ confirm: "Confirmar",
18
+ cancel: "Cancelar",
19
+ loading: "Carregando...",
20
+ // Feedback
21
+ feedback: {
22
+ saveSuccess: "Prefer\xEAncias salvas com sucesso!",
23
+ saveError: "Erro ao salvar prefer\xEAncias. Tente novamente.",
24
+ consentUpdated: "Consentimento atualizado.",
25
+ cookiesRejected: "Cookies opcionais rejeitados.",
26
+ settingsReset: "Configura\xE7\xF5es resetadas."
27
+ },
28
+ // Acessibilidade
29
+ accessibility: {
30
+ bannerLabel: "Banner de consentimento de cookies",
31
+ modalLabel: "Modal de prefer\xEAncias de cookies",
32
+ keyboardNavigation: "Use Tab para navegar, Enter para selecionar",
33
+ toggleState: {
34
+ enabled: "Habilitado",
35
+ disabled: "Desabilitado"
36
+ },
37
+ liveRegion: "Regi\xE3o de an\xFAncios din\xE2micos"
38
+ },
39
+ // Categorias
40
+ categories: {
41
+ necessary: {
42
+ name: "Cookies Necess\xE1rios",
43
+ description: "Essenciais para o funcionamento b\xE1sico do site",
44
+ examples: "Sess\xE3o, seguran\xE7a, prefer\xEAncias de idioma"
45
+ },
46
+ analytics: {
47
+ name: "Cookies de Analytics",
48
+ description: "Ajudam a entender como os visitantes usam o site",
49
+ examples: "Google Analytics, contadores de p\xE1gina"
50
+ },
51
+ marketing: {
52
+ name: "Cookies de Marketing",
53
+ description: "Usados para personalizar an\xFAncios e ofertas",
54
+ examples: "Facebook Pixel, Google Ads, remarketing"
55
+ },
56
+ functional: {
57
+ name: "Cookies Funcionais",
58
+ description: "Melhoram a funcionalidade e personaliza\xE7\xE3o",
59
+ examples: "Chat, mapas, v\xEDdeos embarcados"
60
+ },
61
+ performance: {
62
+ name: "Cookies de Performance",
63
+ description: "Coletam informa\xE7\xF5es sobre velocidade e estabilidade",
64
+ examples: "Monitoramento de erro, otimiza\xE7\xE3o de velocidade"
65
+ }
66
+ },
67
+ // Contextos específicos
68
+ contexts: {
69
+ ecommerce: {
70
+ cartAbandonment: "Lembramos dos produtos no seu carrinho",
71
+ personalizedOffers: "Ofertas personalizadas baseadas no seu hist\xF3rico",
72
+ paymentSecurity: "Seguran\xE7a adicional no processo de pagamento",
73
+ productRecommendations: "Sugest\xF5es de produtos relevantes"
74
+ },
75
+ saas: {
76
+ userAnalytics: "An\xE1lise de uso para melhorar funcionalidades",
77
+ performanceMonitoring: "Monitoramento de performance da aplica\xE7\xE3o",
78
+ featureUsage: "Estat\xEDsticas de uso de recursos",
79
+ customerSupport: "Suporte ao cliente mais eficiente"
80
+ },
81
+ government: {
82
+ citizenServices: "Melhoria dos servi\xE7os ao cidad\xE3o",
83
+ dataProtection: "Prote\xE7\xE3o rigorosa dos dados pessoais",
84
+ transparency: "Transpar\xEAncia no uso de dados",
85
+ accessibility: "Recursos de acessibilidade digital"
86
+ },
87
+ education: {
88
+ studentProgress: "Acompanhamento do progresso educacional",
89
+ learningAnalytics: "Analytics para melhorar o aprendizado",
90
+ accessibility: "Recursos educacionais acess\xEDveis",
91
+ parentalConsent: "Consentimento parental quando necess\xE1rio"
92
+ }
93
+ },
94
+ // Variações de tom
95
+ variants: {
96
+ formal: {
97
+ bannerMessage: "Este s\xEDtio eletr\xF4nico utiliza cookies para otimizar a experi\xEAncia de navega\xE7\xE3o.",
98
+ acceptAll: "Concordar com todos os cookies",
99
+ declineAll: "Recusar cookies opcionais",
100
+ modalTitle: "Configura\xE7\xE3o de Cookies"
101
+ },
102
+ casual: {
103
+ bannerMessage: "\u{1F36A} Ei! Usamos cookies para tornar sua experi\xEAncia ainda melhor!",
104
+ acceptAll: "Aceitar tudo",
105
+ declineAll: "S\xF3 o essencial",
106
+ modalTitle: "Seus Cookies"
107
+ },
108
+ concise: {
109
+ bannerMessage: "Usamos cookies. Voc\xEA aceita?",
110
+ acceptAll: "Sim",
111
+ declineAll: "N\xE3o",
112
+ modalTitle: "Cookies"
113
+ },
114
+ detailed: {
115
+ 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.",
116
+ acceptAll: "Aceitar todos os cookies e tecnologias",
117
+ declineAll: "Recusar todos os cookies opcionais",
118
+ modalTitle: "Centro de Prefer\xEAncias de Privacidade"
119
+ }
120
+ },
121
+ // Internacionalização simplificada (apenas textos básicos)
122
+ i18n: {
123
+ en: {
124
+ bannerMessage: "We use cookies to enhance your experience.",
125
+ acceptAll: "Accept All",
126
+ declineAll: "Decline",
127
+ preferences: "Preferences",
128
+ modalTitle: "Cookie Preferences",
129
+ modalIntro: "Customize your cookie preferences below.",
130
+ save: "Save Preferences",
131
+ necessaryAlwaysOn: "Necessary cookies (always active)"
132
+ },
133
+ es: {
134
+ bannerMessage: "Utilizamos cookies para mejorar su experiencia.",
135
+ acceptAll: "Aceptar Todo",
136
+ declineAll: "Rechazar",
137
+ preferences: "Preferencias",
138
+ modalTitle: "Preferencias de Cookies",
139
+ modalIntro: "Personalice sus preferencias de cookies a continuaci\xF3n.",
140
+ save: "Guardar Preferencias",
141
+ necessaryAlwaysOn: "Cookies necess\xE1rias (sempre ativas)"
142
+ },
143
+ fr: {
144
+ bannerMessage: "Nous utilisons des cookies pour am\xE9liorer votre exp\xE9rience.",
145
+ acceptAll: "Tout Accepter",
146
+ declineAll: "Refuser",
147
+ preferences: "Pr\xE9f\xE9rences",
148
+ modalTitle: "Pr\xE9f\xE9rences des Cookies",
149
+ modalIntro: "Personnalisez vos pr\xE9f\xE9rences de cookies ci-dessous.",
150
+ save: "Enregistrer les Pr\xE9f\xE9rences",
151
+ necessaryAlwaysOn: "Cookies n\xE9cessaires (toujours actifs)"
152
+ }
153
+ },
154
+ // Textos técnicos
155
+ technical: {
156
+ sessionCookies: "Cookies de sess\xE3o s\xE3o tempor\xE1rios e expiram quando voc\xEA fecha o navegador.",
157
+ persistentCookies: "Cookies persistentes permanecem no seu dispositivo at\xE9 expirarem ou serem removidos.",
158
+ thirdPartyCookies: "Cookies de terceiros s\xE3o definidos por dom\xEDnios diferentes do site que voc\xEA est\xE1 visitando.",
159
+ browserSettings: "Voc\xEA pode gerenciar cookies nas configura\xE7\xF5es do seu navegador.",
160
+ disablingImpact: "Desabilitar cookies pode afetar a funcionalidade do site."
161
+ },
162
+ // Cookie details
163
+ cookieDetails: {
164
+ tableHeaders: {
165
+ name: "Nome",
166
+ purpose: "Finalidade",
167
+ duration: "Dura\xE7\xE3o",
168
+ provider: "Fornecedor",
169
+ type: "Tipo"
170
+ },
171
+ noCookies: "Nenhum cookie encontrado para esta categoria.",
172
+ toggleDetails: {
173
+ expand: "Ver detalhes",
174
+ collapse: "Ocultar detalhes"
175
+ },
176
+ scriptLabelPrefix: "(script) ",
177
+ scriptPurpose: "Script de integra\xE7\xE3o ativo"
178
+ }
179
+ };
180
+ function resolveTexts(texts, options = {}) {
181
+ const { language = "pt", variant } = options;
182
+ let resolved = { ...texts };
183
+ if (variant && texts.variants?.[variant]) {
184
+ resolved = { ...resolved, ...texts.variants[variant] };
185
+ }
186
+ if (language !== "pt" && texts.i18n?.[language]) {
187
+ resolved = { ...resolved, ...texts.i18n[language] };
188
+ }
189
+ return resolved;
190
+ }
191
+ var TEXT_TEMPLATES = {
192
+ ecommerce: {
193
+ ...EXPANDED_DEFAULT_TEXTS,
194
+ bannerMessage: "Utilizamos cookies para personalizar ofertas e melhorar sua experi\xEAncia de compra.",
195
+ acceptAll: "Aceitar e continuar",
196
+ variants: {
197
+ casual: {
198
+ bannerMessage: "\u{1F6D2} Usamos cookies para encontrar as melhores ofertas para voc\xEA!",
199
+ acceptAll: "Quero ofertas personalizadas!"
200
+ }
201
+ }
202
+ },
203
+ saas: {
204
+ ...EXPANDED_DEFAULT_TEXTS,
205
+ bannerMessage: "Utilizamos cookies para otimizar o desempenho da aplica\xE7\xE3o e sua experi\xEAncia.",
206
+ acceptAll: "Aceitar e otimizar",
207
+ variants: {
208
+ formal: {
209
+ bannerMessage: "Esta aplica\xE7\xE3o utiliza cookies para an\xE1lise de performance e melhoria cont\xEDnua da experi\xEAncia do usu\xE1rio.",
210
+ acceptAll: "Autorizar coleta de dados de uso"
211
+ }
212
+ }
213
+ },
214
+ government: {
215
+ ...EXPANDED_DEFAULT_TEXTS,
216
+ bannerMessage: "Este portal utiliza cookies em conformidade com a LGPD para melhorar os servi\xE7os p\xFAblicos.",
217
+ acceptAll: "Aceitar em conformidade",
218
+ variants: {
219
+ formal: {
220
+ 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.",
221
+ acceptAll: "Concordar com o uso de cookies"
222
+ }
223
+ }
224
+ }
225
+ };
226
+
14
227
  // src/utils/categoryUtils.ts
15
228
  function createProjectPreferences(config, defaultValue = false) {
16
229
  const preferences = {
@@ -322,15 +535,16 @@ var DEFAULT_COOKIE_OPTS = {
322
535
  maxAge: DEFAULT_MAX_AGE_SECONDS,
323
536
  maxAgeDays: 365,
324
537
  sameSite: "Lax",
325
- secure: globalThis.window === void 0 ? false : globalThis.window.location.protocol === "https:",
538
+ secure: false,
326
539
  path: "/",
327
540
  domain: void 0
328
541
  };
329
542
  function resolveCookieOptions(opts) {
330
- const protocols = [
331
- typeof globalThis.window !== "undefined" ? globalThis.window?.location?.protocol : void 0,
332
- typeof globalThis.location !== "undefined" ? globalThis.location?.protocol : void 0
333
- ].filter(Boolean);
543
+ const currentWindow = globalThis.window;
544
+ const currentLocation = globalThis.location;
545
+ const protocols = [currentWindow?.location?.protocol, currentLocation?.protocol].filter(
546
+ Boolean
547
+ );
334
548
  const forceHttps = globalThis.__LGPD_FORCE_HTTPS__ === true;
335
549
  const isHttps = forceHttps || protocols.includes("https:");
336
550
  const maxAgeSecondsFromDays = typeof opts?.maxAgeDays === "number" ? Math.max(0, opts.maxAgeDays * 24 * 60 * 60) : null;
@@ -339,7 +553,7 @@ function resolveCookieOptions(opts) {
339
553
  name: opts?.name ?? DEFAULT_COOKIE_OPTS.name,
340
554
  maxAge: maxAgeSeconds,
341
555
  sameSite: opts?.sameSite ?? DEFAULT_COOKIE_OPTS.sameSite ?? "Lax",
342
- secure: typeof opts?.secure === "boolean" ? opts.secure : isHttps ? true : DEFAULT_COOKIE_OPTS.secure ?? false,
556
+ secure: typeof opts?.secure === "boolean" ? opts.secure : isHttps ? true : DEFAULT_COOKIE_OPTS.secure,
343
557
  path: opts?.path ?? DEFAULT_COOKIE_OPTS.path ?? "/",
344
558
  domain: opts?.domain ?? DEFAULT_COOKIE_OPTS.domain ?? void 0
345
559
  };
@@ -347,7 +561,7 @@ function resolveCookieOptions(opts) {
347
561
  var COOKIE_SCHEMA_VERSION = "1.0";
348
562
  function readConsentCookie(name = DEFAULT_COOKIE_OPTS.name) {
349
563
  logger.debug("Reading consent cookie", { name });
350
- if (typeof document === "undefined") {
564
+ if (globalThis.document === void 0) {
351
565
  logger.debug("Cookie read skipped: server-side environment");
352
566
  return null;
353
567
  }
@@ -398,7 +612,7 @@ function migrateLegacyCookie(legacyData) {
398
612
  }
399
613
  }
400
614
  function writeConsentCookie(state, config, opts, source = "banner") {
401
- if (typeof document === "undefined" || typeof window === "undefined" || globalThis.__LGPD_SSR__ === true) {
615
+ if (globalThis.document === void 0 || globalThis.window === void 0 || globalThis.__LGPD_SSR__ === true) {
402
616
  logger.debug("Cookie write skipped: server-side environment");
403
617
  return;
404
618
  }
@@ -447,7 +661,7 @@ function createConsentAuditEntry(state, params) {
447
661
  };
448
662
  }
449
663
  function removeConsentCookie(opts) {
450
- if (typeof document === "undefined") {
664
+ if (globalThis.document === void 0) {
451
665
  logger.debug("Cookie removal skipped: server-side environment");
452
666
  return;
453
667
  }
@@ -458,14 +672,23 @@ function removeConsentCookie(opts) {
458
672
  }
459
673
 
460
674
  // src/utils/dataLayerEvents.ts
461
- var LIBRARY_VERSION = "0.7.1";
675
+ var LIBRARY_VERSION = "0.7.2";
462
676
  function ensureDataLayer() {
463
- var _a;
464
- if (globalThis.window === void 0) return;
465
- (_a = globalThis.window).dataLayer ?? (_a.dataLayer = []);
677
+ const currentWindow = globalThis.window;
678
+ if (!currentWindow) return;
679
+ const currentLayer = currentWindow.dataLayer;
680
+ if (currentLayer == null) {
681
+ currentWindow.dataLayer = [];
682
+ return;
683
+ }
684
+ if (typeof currentLayer.push !== "function") {
685
+ const env = globalThis.process?.env?.NODE_ENV ?? "production";
686
+ if (env !== "production") {
687
+ console.warn("[LGPD-CONSENT] dataLayer presente mas sem push; eventos n\xE3o ser\xE3o registrados.");
688
+ }
689
+ }
466
690
  }
467
691
  function pushConsentInitializedEvent(categories) {
468
- if (globalThis.window === void 0) return;
469
692
  ensureDataLayer();
470
693
  const event = {
471
694
  event: "consent_initialized",
@@ -474,10 +697,12 @@ function pushConsentInitializedEvent(categories) {
474
697
  categories,
475
698
  preferences: categories
476
699
  };
477
- globalThis.window.dataLayer?.push(event);
700
+ const layer = globalThis.window?.dataLayer;
701
+ if (layer && typeof layer.push === "function") {
702
+ layer.push(event);
703
+ }
478
704
  }
479
705
  function pushConsentUpdatedEvent(categories, origin, previousCategories) {
480
- if (globalThis.window === void 0) return;
481
706
  ensureDataLayer();
482
707
  const changedCategories = previousCategories ? Object.keys(categories).filter((key) => categories[key] !== previousCategories[key]) : [];
483
708
  const event = {
@@ -489,7 +714,10 @@ function pushConsentUpdatedEvent(categories, origin, previousCategories) {
489
714
  preferences: categories,
490
715
  changed_categories: changedCategories
491
716
  };
492
- globalThis.window.dataLayer?.push(event);
717
+ const layer = globalThis.window?.dataLayer;
718
+ if (layer && typeof layer.push === "function") {
719
+ layer.push(event);
720
+ }
493
721
  }
494
722
  function useDataLayerEvents() {
495
723
  return {
@@ -819,7 +1047,7 @@ function analyzeDeveloperConfiguration(config) {
819
1047
  const gt = globalThis;
820
1048
  const implied = (gt.__LGPD_REQUIRED_CATEGORIES__ || []).filter(Boolean);
821
1049
  implied.forEach((id) => {
822
- if (!guidance.activeCategoriesInfo.find((c) => c.id === id)) {
1050
+ if (!guidance.activeCategoriesInfo.some((c) => c.id === id)) {
823
1051
  const info = NAMES[id];
824
1052
  if (info) {
825
1053
  guidance.activeCategoriesInfo.push({
@@ -859,6 +1087,27 @@ function analyzeDeveloperConfiguration(config) {
859
1087
  'Apenas cookies necess\xE1rios est\xE3o configurados. Para compliance LGPD, considere adicionar categorias como "analytics" ou "functional" conforme uso real.',
860
1088
  "compliance"
861
1089
  );
1090
+ } else {
1091
+ addMessage(
1092
+ "info",
1093
+ "Cookies n\xE3o necess\xE1rios devem iniciar desativados e exigir consentimento expresso, sem pr\xE9-sele\xE7\xE3o e sem consentimento t\xE1cito.",
1094
+ "consent"
1095
+ );
1096
+ addMessage(
1097
+ "info",
1098
+ "Ofere\xE7a op\xE7\xF5es claras de aceitar, rejeitar e gerenciar prefer\xEAncias com o mesmo destaque, al\xE9m de revoga\xE7\xE3o simples e gratuita.",
1099
+ "consent"
1100
+ );
1101
+ addMessage(
1102
+ "info",
1103
+ "Informe finalidades espec\xEDficas, per\xEDodo de reten\xE7\xE3o e compartilhamento com terceiros em pol\xEDtica/aviso de cookies.",
1104
+ "transparency"
1105
+ );
1106
+ addMessage(
1107
+ "info",
1108
+ "Disponibilize mecanismo pr\xF3prio de gerenciamento de cookies; configura\xE7\xF5es do navegador s\xE3o apenas complementares.",
1109
+ "transparency"
1110
+ );
862
1111
  }
863
1112
  if (totalToggleable > 5) {
864
1113
  addMessage(
@@ -883,7 +1132,7 @@ function getComplianceScoreColor(score) {
883
1132
  function logComplianceScore(prefix, score) {
884
1133
  const color = getComplianceScoreColor(score);
885
1134
  console.log(
886
- `%c${prefix} Score de Conformidade LGPD: ${score}/100`,
1135
+ `%c${prefix} Score de Conformidade LGPD (orientativo): ${score}/100`,
887
1136
  `color: ${color}; font-weight: bold; font-size: 14px;`
888
1137
  );
889
1138
  }
@@ -978,7 +1227,7 @@ function logServerSideIfAvailable(guidance) {
978
1227
  }
979
1228
  function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
980
1229
  const gt = globalThis;
981
- const nodeEnv = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
1230
+ const nodeEnv = gt.process ? gt.process?.env?.NODE_ENV : void 0;
982
1231
  const isProd = nodeEnv === "production" || gt.__LGPD_PRODUCTION__ === true;
983
1232
  if (isProd || disableGuidanceProp) return;
984
1233
  const guidanceHash = getGuidanceHash(guidance);
@@ -1036,11 +1285,21 @@ function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
1036
1285
  "color: #9c27b0;",
1037
1286
  "color: #7b1fa2;"
1038
1287
  );
1288
+ console.info(
1289
+ `%c${PREFIX}%c Evite consentimento t\xE1cito e op\xE7\xF5es pr\xE9-selecionadas`,
1290
+ "color: #9c27b0;",
1291
+ "color: #7b1fa2;"
1292
+ );
1039
1293
  console.info(
1040
1294
  `%c${PREFIX}%c Documente pol\xEDticas claras por categoria`,
1041
1295
  "color: #9c27b0;",
1042
1296
  "color: #7b1fa2;"
1043
1297
  );
1298
+ console.info(
1299
+ `%c${PREFIX}%c Informe finalidades, reten\xE7\xE3o e revoga\xE7\xE3o simples e gratuita`,
1300
+ "color: #9c27b0;",
1301
+ "color: #7b1fa2;"
1302
+ );
1044
1303
  console.info(
1045
1304
  `%c${PREFIX}%c Registre consentimento com data/hora/origem`,
1046
1305
  "color: #9c27b0;",
@@ -1052,7 +1311,9 @@ function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
1052
1311
  function useDeveloperGuidance(config, disableGuidanceProp, guidanceConfig) {
1053
1312
  const guidance = React4__default.useMemo(() => analyzeDeveloperConfiguration(config), [config]);
1054
1313
  React4__default.useEffect(() => {
1055
- if (!disableGuidanceProp) logDeveloperGuidance(guidance, disableGuidanceProp, guidanceConfig);
1314
+ if (globalThis.window !== void 0 && !disableGuidanceProp) {
1315
+ logDeveloperGuidance(guidance, disableGuidanceProp, guidanceConfig);
1316
+ }
1056
1317
  }, [guidance, disableGuidanceProp, guidanceConfig]);
1057
1318
  return guidance;
1058
1319
  }
@@ -1355,28 +1616,30 @@ function getMessages() {
1355
1616
  };
1356
1617
  }
1357
1618
  function detectMultipleReactInstances() {
1358
- if (globalThis.window === void 0) return false;
1619
+ const currentWindow = globalThis.window;
1620
+ if (currentWindow === void 0) return false;
1359
1621
  try {
1360
- const reactSymbols = Object.getOwnPropertySymbols(globalThis.window).map(String).filter((name) => name.includes("react"));
1622
+ const reactSymbols = Object.getOwnPropertySymbols(currentWindow).map(String).filter((name) => name.includes("react"));
1361
1623
  if (reactSymbols.length > 1) {
1362
1624
  return true;
1363
1625
  }
1364
- const ReactModule = window.React;
1626
+ const ReactModule = currentWindow.React;
1365
1627
  if (ReactModule && Array.isArray(ReactModule)) {
1366
1628
  return true;
1367
1629
  }
1368
- const hasMultipleVersions = window.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers?.size > 1;
1630
+ const hasMultipleVersions = (currentWindow.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers?.size ?? 0) > 1;
1369
1631
  return hasMultipleVersions || false;
1370
1632
  } catch {
1371
1633
  return false;
1372
1634
  }
1373
1635
  }
1374
1636
  function getPackageVersion(packageName) {
1375
- if (globalThis.window === void 0) return null;
1637
+ const currentWindow = globalThis.window;
1638
+ if (currentWindow === void 0) return null;
1376
1639
  try {
1377
- const pkg = window[packageName];
1640
+ const pkg = currentWindow[packageName];
1378
1641
  if (pkg?.version) return pkg.version;
1379
- const React6 = window.React;
1642
+ const React6 = currentWindow.React;
1380
1643
  if (packageName === "react" && React6?.version) {
1381
1644
  return React6.version;
1382
1645
  }
@@ -1400,7 +1663,8 @@ function checkPeerDeps(options = {}) {
1400
1663
  if (skipInProduction && isProduction) {
1401
1664
  return result;
1402
1665
  }
1403
- if (globalThis.window === void 0) {
1666
+ const currentWindow = globalThis.window;
1667
+ if (currentWindow === void 0) {
1404
1668
  return result;
1405
1669
  }
1406
1670
  const messages = getMessages();
@@ -1422,7 +1686,7 @@ function checkPeerDeps(options = {}) {
1422
1686
  }
1423
1687
  }
1424
1688
  }
1425
- const muiVersion = window["@mui/material"]?.version;
1689
+ const muiVersion = currentWindow["@mui/material"]?.version;
1426
1690
  if (muiVersion) {
1427
1691
  if (!isVersionInRange(muiVersion, 5, 7)) {
1428
1692
  result.warnings.push(messages.MUI_OUT_OF_RANGE(muiVersion));
@@ -1552,10 +1816,11 @@ function validateConsentProviderProps(props) {
1552
1816
 
1553
1817
  // src/utils/cookieDiscovery.ts
1554
1818
  function discoverRuntimeCookies() {
1555
- if (typeof document === "undefined" || !document.cookie) return [];
1819
+ const currentDocument = globalThis.document;
1820
+ if (currentDocument === void 0 || !currentDocument.cookie) return [];
1556
1821
  const names = Array.from(
1557
1822
  new Set(
1558
- document.cookie.split(";").map((s) => s.trim()).filter(Boolean).map((s) => s.split("=")[0])
1823
+ currentDocument.cookie.split(";").map((s) => s.trim()).filter(Boolean).map((s) => s.split("=")[0])
1559
1824
  )
1560
1825
  );
1561
1826
  const list = names.map((name) => ({ name }));
@@ -1566,27 +1831,34 @@ function discoverRuntimeCookies() {
1566
1831
  }
1567
1832
  return list;
1568
1833
  }
1834
+ function tryDecode(val) {
1835
+ try {
1836
+ return decodeURIComponent(val);
1837
+ } catch {
1838
+ return val;
1839
+ }
1840
+ }
1841
+ function isConsentJson(val) {
1842
+ if (!val.startsWith("{")) return false;
1843
+ try {
1844
+ const obj = JSON.parse(val);
1845
+ return obj && typeof obj === "object" && "preferences" in obj && "version" in obj;
1846
+ } catch {
1847
+ return false;
1848
+ }
1849
+ }
1569
1850
  function detectConsentCookieName() {
1570
- if (typeof document === "undefined" || !document.cookie) return null;
1851
+ const currentDocument = globalThis.document;
1852
+ if (currentDocument === void 0 || !currentDocument.cookie) return null;
1571
1853
  try {
1572
- const pairs = document.cookie.split(";").map((s) => s.trim()).filter(Boolean);
1854
+ const pairs = currentDocument.cookie.split(";").map((s) => s.trim()).filter(Boolean);
1573
1855
  for (const p of pairs) {
1574
1856
  const [name, ...rest] = p.split("=");
1575
1857
  const raw = rest.join("=");
1576
1858
  if (!raw) continue;
1577
- let val = raw;
1578
- try {
1579
- val = decodeURIComponent(raw);
1580
- } catch {
1581
- }
1582
- if (val.startsWith("{")) {
1583
- try {
1584
- const obj = JSON.parse(val);
1585
- if (obj && typeof obj === "object" && "preferences" in obj && "version" in obj) {
1586
- return name;
1587
- }
1588
- } catch {
1589
- }
1859
+ const val = tryDecode(raw);
1860
+ if (isConsentJson(val)) {
1861
+ return name;
1590
1862
  }
1591
1863
  }
1592
1864
  } catch {
@@ -1628,15 +1900,6 @@ function CategoriesProvider({
1628
1900
  disableDiscoveryLog
1629
1901
  }) {
1630
1902
  const [impliedVersion, setImpliedVersion] = React4.useState(0);
1631
- React4.useEffect(() => {
1632
- const handler = () => setImpliedVersion((v) => v + 1);
1633
- if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
1634
- window.addEventListener("lgpd:requiredCategories", handler);
1635
- return () => window.removeEventListener("lgpd:requiredCategories", handler);
1636
- }
1637
- return () => {
1638
- };
1639
- }, []);
1640
1903
  const contextValue = React4.useMemo(() => {
1641
1904
  const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
1642
1905
  const guidance = analyzeDeveloperConfiguration(config);
@@ -1648,35 +1911,47 @@ function CategoriesProvider({
1648
1911
  allCategories: guidance.activeCategoriesInfo
1649
1912
  };
1650
1913
  }, [config, impliedVersion]);
1914
+ React4.useEffect(() => {
1915
+ const currentWindow = globalThis.window;
1916
+ if (!currentWindow || typeof currentWindow.addEventListener !== "function") return;
1917
+ const handler = () => {
1918
+ setImpliedVersion((current) => current + 1);
1919
+ };
1920
+ currentWindow.addEventListener("lgpd:requiredCategories", handler);
1921
+ return () => {
1922
+ currentWindow.removeEventListener("lgpd:requiredCategories", handler);
1923
+ };
1924
+ }, []);
1651
1925
  React4.useEffect(() => {
1652
1926
  logDeveloperGuidance(contextValue.guidance, disableDeveloperGuidance);
1653
1927
  }, [contextValue.guidance, disableDeveloperGuidance]);
1654
1928
  React4.useEffect(() => {
1655
1929
  try {
1656
1930
  const gt = globalThis;
1657
- const env = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
1931
+ const env = gt.process?.env?.NODE_ENV;
1658
1932
  const isDev2 = env === "development";
1659
- if (!isDev2 || gt.__LGPD_DISCOVERY_LOGGED__ === true || disableDiscoveryLog) return;
1660
- const discovered = discoverRuntimeCookies();
1661
- const consentName = detectConsentCookieName() || DEFAULT_COOKIE_OPTS.name;
1662
- const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
1663
- if (typeof console !== "undefined") {
1664
- try {
1665
- console.group(`${PREFIX} \u{1F50E} Descoberta de cookies (experimental)`);
1666
- const names = Array.from(
1667
- new Set([consentName, ...discovered.map((d) => d.name)].filter(Boolean))
1668
- );
1669
- const rows = names.map((n) => ({ Cookie: n }));
1670
- if (typeof console.table === "function") console.table(rows);
1671
- else console.log(rows);
1672
- console.info(
1673
- `${PREFIX} \u2139\uFE0F Estes nomes s\xE3o detectados em tempo de execu\xE7\xE3o. Ajuste ou categorize via APIs de override se necess\xE1rio.`
1674
- );
1675
- console.groupEnd();
1676
- } catch {
1933
+ if (isDev2 && gt.__LGPD_DISCOVERY_LOGGED__ !== true && !disableDiscoveryLog) {
1934
+ const discovered = discoverRuntimeCookies();
1935
+ const consentName = detectConsentCookieName() || DEFAULT_COOKIE_OPTS.name;
1936
+ const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
1937
+ if (typeof console !== "undefined") {
1938
+ try {
1939
+ console.group(`${PREFIX} \u{1F50E} Descoberta de cookies (experimental)`);
1940
+ const names = Array.from(
1941
+ new Set([consentName, ...discovered.map((d) => d.name)].filter(Boolean))
1942
+ );
1943
+ const rows = names.map((n) => ({ Cookie: n }));
1944
+ if (typeof console.table === "function") console.table(rows);
1945
+ else console.log(rows);
1946
+ console.info(
1947
+ `${PREFIX} \u2139\uFE0F Estes nomes s\xE3o detectados em tempo de execu\xE7\xE3o. Ajuste ou categorize via APIs de override se necess\xE1rio.`
1948
+ );
1949
+ console.groupEnd();
1950
+ } catch {
1951
+ }
1677
1952
  }
1953
+ gt.__LGPD_DISCOVERY_LOGGED__ = true;
1678
1954
  }
1679
- gt.__LGPD_DISCOVERY_LOGGED__ = true;
1680
1955
  } catch {
1681
1956
  }
1682
1957
  }, [disableDiscoveryLog]);
@@ -1726,7 +2001,7 @@ function createFullConsentState(consented, preferences, source, projectConfig, i
1726
2001
  isModalOpen
1727
2002
  };
1728
2003
  }
1729
- var DEFAULT_TEXTS = {
2004
+ var BASE_TEXTS = {
1730
2005
  // Textos básicos
1731
2006
  bannerMessage: "Utilizamos cookies para melhorar sua experi\xEAncia.",
1732
2007
  acceptAll: "Aceitar todos",
@@ -1763,6 +2038,10 @@ var DEFAULT_TEXTS = {
1763
2038
  transferCountries: void 0
1764
2039
  // Exibido se definido
1765
2040
  };
2041
+ var DEFAULT_TEXTS = {
2042
+ ...BASE_TEXTS,
2043
+ ...EXPANDED_DEFAULT_TEXTS
2044
+ };
1766
2045
  function reducer(state, action) {
1767
2046
  logger.consentState(action.type, state);
1768
2047
  switch (action.type) {
@@ -1846,6 +2125,8 @@ function ConsentProvider({
1846
2125
  initialState,
1847
2126
  categories,
1848
2127
  texts: textsProp,
2128
+ language,
2129
+ textVariant,
1849
2130
  designTokens,
1850
2131
  PreferencesModalComponent,
1851
2132
  preferencesModalProps = {},
@@ -1870,7 +2151,11 @@ function ConsentProvider({
1870
2151
  onConsentChange,
1871
2152
  onAuditLog
1872
2153
  }) {
1873
- const texts = React4.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
2154
+ const mergedTexts = React4.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
2155
+ const texts = React4.useMemo(
2156
+ () => resolveTexts(mergedTexts, { language, variant: textVariant }),
2157
+ [mergedTexts, language, textVariant]
2158
+ );
1874
2159
  const cookie = React4.useMemo(() => {
1875
2160
  const base = { ...DEFAULT_COOKIE_OPTS, ...cookieOpts ?? {} };
1876
2161
  base.name = cookieOpts?.name ?? buildConsentStorageKey({
@@ -2287,8 +2572,9 @@ function hasCategoryConsent(snapshot, category) {
2287
2572
  return Boolean(snapshot.preferences?.[category]);
2288
2573
  }
2289
2574
  function loadScript(id, src, category = null, attrs = {}, nonce, options) {
2290
- if (typeof document === "undefined") return Promise.resolve();
2291
- if (document.getElementById(id)) return Promise.resolve();
2575
+ const currentDocument = globalThis.document;
2576
+ if (!src || currentDocument === void 0) return Promise.resolve();
2577
+ if (currentDocument.getElementById(id)) return Promise.resolve();
2292
2578
  const existingPromise = LOADING_SCRIPTS.get(id);
2293
2579
  if (existingPromise) return existingPromise;
2294
2580
  const pollInterval = options?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL;
@@ -2296,7 +2582,7 @@ function loadScript(id, src, category = null, attrs = {}, nonce, options) {
2296
2582
  const mergedAttrs = { ...attrs };
2297
2583
  const promise = new Promise((resolve, reject) => {
2298
2584
  const inject = () => {
2299
- const s = document.createElement("script");
2585
+ const s = currentDocument.createElement("script");
2300
2586
  s.id = id;
2301
2587
  s.src = src;
2302
2588
  s.async = mergedAttrs.async !== "false";
@@ -2314,7 +2600,7 @@ function loadScript(id, src, category = null, attrs = {}, nonce, options) {
2314
2600
  LOADING_SCRIPTS.delete(id);
2315
2601
  reject(new Error(`Failed to load script: ${src}`));
2316
2602
  };
2317
- document.body.appendChild(s);
2603
+ currentDocument.body.appendChild(s);
2318
2604
  };
2319
2605
  const snapshot = options?.consentSnapshot;
2320
2606
  const skipChecks = options?.skipConsentCheck === true;
@@ -2802,6 +3088,31 @@ function useConsentScriptLoader() {
2802
3088
  }
2803
3089
 
2804
3090
  // src/utils/scriptIntegrations.ts
3091
+ function createSuggestedIntegration(config) {
3092
+ const suggested = suggestCategoryForScript(config.id)[0] ?? "analytics";
3093
+ const category = resolveCategory(suggested, config.category);
3094
+ const { category: _ignored, ...rest } = config;
3095
+ return { ...rest, category };
3096
+ }
3097
+ var resolveCategory = (fallback, override) => {
3098
+ if (typeof override === "string" && override.trim().length > 0) return override.trim();
3099
+ return fallback;
3100
+ };
3101
+ var isDevEnv = () => {
3102
+ const env = typeof globalThis !== "undefined" ? globalThis.process?.env?.NODE_ENV : void 0;
3103
+ return env !== "production";
3104
+ };
3105
+ var resolveRequiredString = (value, field, integrationId) => {
3106
+ if (typeof value !== "string" || value.trim().length === 0) {
3107
+ if (isDevEnv()) {
3108
+ console.error(
3109
+ `[LGPD-CONSENT] Config inv\xE1lida: integra\xE7\xE3o "${integrationId}" requer "${field}".`
3110
+ );
3111
+ }
3112
+ return null;
3113
+ }
3114
+ return value.trim();
3115
+ };
2805
3116
  function buildConsentModeSignals(preferences) {
2806
3117
  const analytics = preferences.analytics ? "granted" : "denied";
2807
3118
  const marketing = preferences.marketing ? "granted" : "denied";
@@ -2813,16 +3124,18 @@ function buildConsentModeSignals(preferences) {
2813
3124
  };
2814
3125
  }
2815
3126
  function pushToLayer(entry, dataLayerName) {
2816
- if (typeof globalThis.window === "undefined") return;
2817
- const registry = globalThis.window;
3127
+ const currentWindow = globalThis.window;
3128
+ if (currentWindow === void 0) return;
3129
+ const registry = currentWindow;
2818
3130
  const name = dataLayerName ?? "dataLayer";
2819
3131
  const layer = registry[name] ?? [];
2820
3132
  registry[name] = layer;
2821
3133
  layer.push(entry);
2822
3134
  }
2823
3135
  function ensureGtag(dataLayerName = "dataLayer") {
2824
- if (typeof globalThis.window === "undefined") return null;
2825
- const w = window;
3136
+ const currentWindow = globalThis.window;
3137
+ if (currentWindow === void 0) return null;
3138
+ const w = currentWindow;
2826
3139
  const registry = w;
2827
3140
  const layer = registry[dataLayerName] ?? [];
2828
3141
  registry[dataLayerName] = layer;
@@ -2854,10 +3167,45 @@ function applyConsentModeUpdate(preferences, dataLayerName) {
2854
3167
  pushToLayer(["consent", "update", payload], dataLayerName);
2855
3168
  }
2856
3169
  function createGoogleAnalyticsIntegration(config) {
2857
- const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtag/js?id=${config.measurementId}`;
3170
+ const category = resolveCategory("analytics", config.category);
3171
+ const measurementId = resolveRequiredString(
3172
+ config.measurementId,
3173
+ "measurementId",
3174
+ "google-analytics"
3175
+ );
3176
+ if (!measurementId) {
3177
+ return {
3178
+ id: "google-analytics",
3179
+ category,
3180
+ src: "",
3181
+ cookies: ["_ga", "_ga_*", "_gid"],
3182
+ cookiesInfo: [
3183
+ {
3184
+ name: "_ga",
3185
+ purpose: "Identifica\xE7\xE3o \xFAnica de visitantes para an\xE1lise de tr\xE1fego",
3186
+ duration: "2 anos",
3187
+ provider: "Google Analytics"
3188
+ },
3189
+ {
3190
+ name: "_ga_*",
3191
+ purpose: "Rastreamento de sess\xF5es e eventos espec\xEDficos do stream GA4",
3192
+ duration: "2 anos",
3193
+ provider: "Google Analytics"
3194
+ },
3195
+ {
3196
+ name: "_gid",
3197
+ purpose: "Distin\xE7\xE3o de visitantes \xFAnicos em per\xEDodo de 24h",
3198
+ duration: "24 horas",
3199
+ provider: "Google Analytics"
3200
+ }
3201
+ ],
3202
+ attrs: { async: "true" }
3203
+ };
3204
+ }
3205
+ const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
2858
3206
  return {
2859
3207
  id: "google-analytics",
2860
- category: "analytics",
3208
+ category,
2861
3209
  src,
2862
3210
  cookies: ["_ga", "_ga_*", "_gid"],
2863
3211
  cookiesInfo: [
@@ -2890,16 +3238,26 @@ function createGoogleAnalyticsIntegration(config) {
2890
3238
  const gtag = ensureGtag();
2891
3239
  if (!gtag) return;
2892
3240
  gtag("js", /* @__PURE__ */ new Date());
2893
- gtag("config", config.measurementId, config.config ?? {});
3241
+ gtag("config", measurementId, config.config ?? {});
2894
3242
  },
2895
3243
  attrs: { async: "true" }
2896
3244
  };
2897
3245
  }
2898
3246
  function createGoogleTagManagerIntegration(config) {
2899
- const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtm.js?id=${config.containerId}`;
3247
+ const category = resolveCategory("analytics", config.category);
3248
+ const containerId = resolveRequiredString(config.containerId, "containerId", "google-tag-manager");
3249
+ if (!containerId) {
3250
+ return {
3251
+ id: "google-tag-manager",
3252
+ category,
3253
+ src: "",
3254
+ cookies: ["_gcl_au"]
3255
+ };
3256
+ }
3257
+ const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtm.js?id=${containerId}`;
2900
3258
  return {
2901
3259
  id: "google-tag-manager",
2902
- category: "analytics",
3260
+ category,
2903
3261
  src,
2904
3262
  cookies: ["_gcl_au"],
2905
3263
  bootstrap: () => {
@@ -2909,9 +3267,10 @@ function createGoogleTagManagerIntegration(config) {
2909
3267
  applyConsentModeUpdate(preferences, config.dataLayerName);
2910
3268
  },
2911
3269
  init: () => {
2912
- if (globalThis.window !== void 0) {
3270
+ const currentWindow = globalThis.window;
3271
+ if (currentWindow !== void 0) {
2913
3272
  const dataLayerName = config.dataLayerName || "dataLayer";
2914
- const w = window;
3273
+ const w = currentWindow;
2915
3274
  const layer = w[dataLayerName] ?? [];
2916
3275
  w[dataLayerName] = layer;
2917
3276
  layer.push({ "gtm.start": Date.now(), event: "gtm.js" });
@@ -2920,20 +3279,31 @@ function createGoogleTagManagerIntegration(config) {
2920
3279
  };
2921
3280
  }
2922
3281
  function createUserWayIntegration(config) {
3282
+ const category = resolveCategory("functional", config.category);
3283
+ const accountId = resolveRequiredString(config.accountId, "accountId", "userway");
3284
+ if (!accountId) {
3285
+ return {
3286
+ id: "userway",
3287
+ category,
3288
+ src: "",
3289
+ cookies: ["_userway_*"]
3290
+ };
3291
+ }
2923
3292
  const src = config.scriptUrl ?? "https://cdn.userway.org/widget.js";
2924
3293
  return {
2925
3294
  id: "userway",
2926
- category: "functional",
3295
+ category,
2927
3296
  src,
2928
3297
  cookies: ["_userway_*"],
2929
3298
  init: () => {
2930
- if (globalThis.window !== void 0) {
2931
- const w = window;
3299
+ const currentWindow = globalThis.window;
3300
+ if (currentWindow !== void 0) {
3301
+ const w = currentWindow;
2932
3302
  w.UserWayWidgetApp = w.UserWayWidgetApp || {};
2933
- w.UserWayWidgetApp.accountId = config.accountId;
3303
+ w.UserWayWidgetApp.accountId = accountId;
2934
3304
  }
2935
3305
  },
2936
- attrs: { "data-account": config.accountId }
3306
+ attrs: { "data-account": accountId }
2937
3307
  };
2938
3308
  }
2939
3309
  var COMMON_INTEGRATIONS = {
@@ -2942,15 +3312,26 @@ var COMMON_INTEGRATIONS = {
2942
3312
  userway: createUserWayIntegration
2943
3313
  };
2944
3314
  function createFacebookPixelIntegration(config) {
3315
+ const category = resolveCategory("marketing", config.category);
3316
+ const pixelId = resolveRequiredString(config.pixelId, "pixelId", "facebook-pixel");
3317
+ if (!pixelId) {
3318
+ return {
3319
+ id: "facebook-pixel",
3320
+ category,
3321
+ src: "",
3322
+ cookies: ["_fbp", "fr"]
3323
+ };
3324
+ }
2945
3325
  const src = config.scriptUrl ?? "https://connect.facebook.net/en_US/fbevents.js";
2946
3326
  return {
2947
3327
  id: "facebook-pixel",
2948
- category: "marketing",
3328
+ category,
2949
3329
  src,
2950
3330
  cookies: ["_fbp", "fr"],
2951
3331
  init: () => {
2952
- if (globalThis.window !== void 0) {
2953
- const w = window;
3332
+ const currentWindow = globalThis.window;
3333
+ if (currentWindow !== void 0) {
3334
+ const w = currentWindow;
2954
3335
  if (!w.fbq) {
2955
3336
  const fbq = (...args) => {
2956
3337
  if (w.fbq && typeof w.fbq.callMethod === "function") {
@@ -2963,18 +3344,34 @@ function createFacebookPixelIntegration(config) {
2963
3344
  fbq.loaded = true;
2964
3345
  w.fbq = fbq;
2965
3346
  }
2966
- w.fbq("init", config.pixelId, config.advancedMatching ?? {});
3347
+ w.fbq("init", pixelId, config.advancedMatching ?? {});
2967
3348
  if (config.autoTrack !== false) w.fbq("track", "PageView");
2968
3349
  }
2969
3350
  }
2970
3351
  };
2971
3352
  }
2972
3353
  function createHotjarIntegration(config) {
3354
+ const category = resolveCategory("analytics", config.category);
3355
+ const siteId = resolveRequiredString(config.siteId, "siteId", "hotjar");
2973
3356
  const v = config.version ?? 6;
2974
- const src = config.scriptUrl ?? `https://static.hotjar.com/c/hotjar-${config.siteId}.js?sv=${v}`;
3357
+ if (!siteId) {
3358
+ return {
3359
+ id: "hotjar",
3360
+ category,
3361
+ src: "",
3362
+ cookies: [
3363
+ "_hjSession_*",
3364
+ "_hjSessionUser_*",
3365
+ "_hjFirstSeen",
3366
+ "_hjIncludedInSessionSample",
3367
+ "_hjAbsoluteSessionInProgress"
3368
+ ]
3369
+ };
3370
+ }
3371
+ const src = config.scriptUrl ?? `https://static.hotjar.com/c/hotjar-${siteId}.js?sv=${v}`;
2975
3372
  return {
2976
3373
  id: "hotjar",
2977
- category: "analytics",
3374
+ category,
2978
3375
  src,
2979
3376
  cookies: [
2980
3377
  "_hjSession_*",
@@ -3016,9 +3413,10 @@ function createHotjarIntegration(config) {
3016
3413
  }
3017
3414
  ],
3018
3415
  init: () => {
3019
- if (globalThis.window !== void 0) {
3020
- const w = window;
3021
- w._hjSettings = { hjid: config.siteId, hjsv: v };
3416
+ const currentWindow = globalThis.window;
3417
+ if (currentWindow !== void 0) {
3418
+ const w = currentWindow;
3419
+ w._hjSettings = { hjid: siteId, hjsv: v };
3022
3420
  if (!w.hj) {
3023
3421
  const hj = (...args) => {
3024
3422
  hj.q = hj.q || [];
@@ -3027,17 +3425,35 @@ function createHotjarIntegration(config) {
3027
3425
  w.hj = hj;
3028
3426
  }
3029
3427
  if (config.debug && typeof console !== "undefined" && typeof console.info === "function") {
3030
- console.info("[Hotjar] initialized with siteId", config.siteId);
3428
+ console.info("[Hotjar] initialized with siteId", siteId);
3031
3429
  }
3032
3430
  }
3033
3431
  }
3034
3432
  };
3035
3433
  }
3036
3434
  function createMixpanelIntegration(config) {
3435
+ const category = resolveCategory("analytics", config.category);
3436
+ const token = resolveRequiredString(config.token, "token", "mixpanel");
3437
+ if (!token) {
3438
+ return {
3439
+ id: "mixpanel",
3440
+ category,
3441
+ src: "",
3442
+ cookies: ["mp_*"],
3443
+ cookiesInfo: [
3444
+ {
3445
+ name: "mp_*",
3446
+ purpose: "Rastreamento de eventos e propriedades do usu\xE1rio para analytics",
3447
+ duration: "1 ano",
3448
+ provider: "Mixpanel"
3449
+ }
3450
+ ]
3451
+ };
3452
+ }
3037
3453
  const src = config.scriptUrl ?? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";
3038
3454
  return {
3039
3455
  id: "mixpanel",
3040
- category: "analytics",
3456
+ category,
3041
3457
  src,
3042
3458
  cookies: ["mp_*"],
3043
3459
  cookiesInfo: [
@@ -3049,12 +3465,13 @@ function createMixpanelIntegration(config) {
3049
3465
  }
3050
3466
  ],
3051
3467
  init: () => {
3052
- if (globalThis.window !== void 0) {
3053
- const w = window;
3468
+ const currentWindow = globalThis.window;
3469
+ if (currentWindow !== void 0) {
3470
+ const w = currentWindow;
3054
3471
  w.mixpanel = w.mixpanel || { init: () => void 0 };
3055
3472
  if (w.mixpanel && typeof w.mixpanel.init === "function") {
3056
3473
  try {
3057
- w.mixpanel.init(config.token, config.config ?? {}, config.api_host);
3474
+ w.mixpanel.init(token, config.config ?? {}, config.api_host);
3058
3475
  } catch (error) {
3059
3476
  if (typeof console !== "undefined" && typeof console.warn === "function") {
3060
3477
  console.warn("[Mixpanel] Failed to initialize:", error);
@@ -3066,15 +3483,26 @@ function createMixpanelIntegration(config) {
3066
3483
  };
3067
3484
  }
3068
3485
  function createClarityIntegration(config) {
3069
- const src = config.scriptUrl ?? `https://www.clarity.ms/tag/${config.projectId}`;
3486
+ const category = resolveCategory("analytics", config.category);
3487
+ const projectId = resolveRequiredString(config.projectId, "projectId", "clarity");
3488
+ if (!projectId) {
3489
+ return {
3490
+ id: "clarity",
3491
+ category,
3492
+ src: "",
3493
+ cookies: ["_clck", "_clsk", "CLID", "ANONCHK", "MR", "MUID", "SM"]
3494
+ };
3495
+ }
3496
+ const src = config.scriptUrl ?? `https://www.clarity.ms/tag/${projectId}`;
3070
3497
  return {
3071
3498
  id: "clarity",
3072
- category: "analytics",
3499
+ category,
3073
3500
  src,
3074
3501
  cookies: ["_clck", "_clsk", "CLID", "ANONCHK", "MR", "MUID", "SM"],
3075
3502
  init: () => {
3076
- if (globalThis.window !== void 0 && typeof config.upload !== "undefined") {
3077
- const w = window;
3503
+ const currentWindow = globalThis.window;
3504
+ if (currentWindow !== void 0 && typeof config.upload !== "undefined") {
3505
+ const w = currentWindow;
3078
3506
  if (typeof w.clarity === "function") {
3079
3507
  try {
3080
3508
  w.clarity("set", "upload", config.upload);
@@ -3089,18 +3517,29 @@ function createClarityIntegration(config) {
3089
3517
  };
3090
3518
  }
3091
3519
  function createIntercomIntegration(config) {
3092
- const src = config.scriptUrl ?? `https://widget.intercom.io/widget/${config.app_id}`;
3520
+ const category = resolveCategory("functional", config.category);
3521
+ const appId = resolveRequiredString(config.app_id, "app_id", "intercom");
3522
+ if (!appId) {
3523
+ return {
3524
+ id: "intercom",
3525
+ category,
3526
+ src: "",
3527
+ cookies: ["intercom-id-*", "intercom-session-*"]
3528
+ };
3529
+ }
3530
+ const src = config.scriptUrl ?? `https://widget.intercom.io/widget/${appId}`;
3093
3531
  return {
3094
3532
  id: "intercom",
3095
- category: "functional",
3533
+ category,
3096
3534
  src,
3097
3535
  cookies: ["intercom-id-*", "intercom-session-*"],
3098
3536
  init: () => {
3099
- if (globalThis.window !== void 0) {
3100
- const w = window;
3537
+ const currentWindow = globalThis.window;
3538
+ if (currentWindow !== void 0) {
3539
+ const w = currentWindow;
3101
3540
  if (typeof w.Intercom === "function") {
3102
3541
  try {
3103
- w.Intercom("boot", { app_id: config.app_id });
3542
+ w.Intercom("boot", { app_id: appId });
3104
3543
  } catch (error) {
3105
3544
  if (typeof console !== "undefined" && typeof console.warn === "function") {
3106
3545
  console.warn("[Intercom] Failed to boot:", error);
@@ -3112,18 +3551,29 @@ function createIntercomIntegration(config) {
3112
3551
  };
3113
3552
  }
3114
3553
  function createZendeskChatIntegration(config) {
3115
- const src = config.scriptUrl ?? `https://static.zdassets.com/ekr/snippet.js?key=${config.key}`;
3554
+ const category = resolveCategory("functional", config.category);
3555
+ const key = resolveRequiredString(config.key, "key", "zendesk-chat");
3556
+ if (!key) {
3557
+ return {
3558
+ id: "zendesk-chat",
3559
+ category,
3560
+ src: "",
3561
+ cookies: ["__zlcmid", "_zendesk_shared_session"]
3562
+ };
3563
+ }
3564
+ const src = config.scriptUrl ?? `https://static.zdassets.com/ekr/snippet.js?key=${key}`;
3116
3565
  return {
3117
3566
  id: "zendesk-chat",
3118
- category: "functional",
3567
+ category,
3119
3568
  src,
3120
3569
  cookies: ["__zlcmid", "_zendesk_shared_session"],
3121
3570
  init: () => {
3122
- if (globalThis.window !== void 0) {
3123
- const w = window;
3571
+ const currentWindow = globalThis.window;
3572
+ if (currentWindow !== void 0) {
3573
+ const w = currentWindow;
3124
3574
  if (typeof w.zE === "function") {
3125
3575
  try {
3126
- w.zE("webWidget", "identify", { key: config.key });
3576
+ w.zE("webWidget", "identify", { key });
3127
3577
  } catch (error) {
3128
3578
  if (typeof console !== "undefined" && typeof console.warn === "function") {
3129
3579
  console.warn("[Zendesk] Failed to identify:", error);
@@ -3245,215 +3695,4 @@ function createAnpdCategoriesConfig(options = {}) {
3245
3695
  };
3246
3696
  }
3247
3697
 
3248
- // src/types/advancedTexts.ts
3249
- var EXPANDED_DEFAULT_TEXTS = {
3250
- // Textos adicionais
3251
- confirm: "Confirmar",
3252
- cancel: "Cancelar",
3253
- loading: "Carregando...",
3254
- // Feedback
3255
- feedback: {
3256
- saveSuccess: "Prefer\xEAncias salvas com sucesso!",
3257
- saveError: "Erro ao salvar prefer\xEAncias. Tente novamente.",
3258
- consentUpdated: "Consentimento atualizado.",
3259
- cookiesRejected: "Cookies opcionais rejeitados.",
3260
- settingsReset: "Configura\xE7\xF5es resetadas."
3261
- },
3262
- // Acessibilidade
3263
- accessibility: {
3264
- bannerLabel: "Banner de consentimento de cookies",
3265
- modalLabel: "Modal de prefer\xEAncias de cookies",
3266
- keyboardNavigation: "Use Tab para navegar, Enter para selecionar",
3267
- toggleState: {
3268
- enabled: "Habilitado",
3269
- disabled: "Desabilitado"
3270
- },
3271
- liveRegion: "Regi\xE3o de an\xFAncios din\xE2micos"
3272
- },
3273
- // Categorias
3274
- categories: {
3275
- necessary: {
3276
- name: "Cookies Necess\xE1rios",
3277
- description: "Essenciais para o funcionamento b\xE1sico do site",
3278
- examples: "Sess\xE3o, seguran\xE7a, prefer\xEAncias de idioma"
3279
- },
3280
- analytics: {
3281
- name: "Cookies de Analytics",
3282
- description: "Ajudam a entender como os visitantes usam o site",
3283
- examples: "Google Analytics, contadores de p\xE1gina"
3284
- },
3285
- marketing: {
3286
- name: "Cookies de Marketing",
3287
- description: "Usados para personalizar an\xFAncios e ofertas",
3288
- examples: "Facebook Pixel, Google Ads, remarketing"
3289
- },
3290
- functional: {
3291
- name: "Cookies Funcionais",
3292
- description: "Melhoram a funcionalidade e personaliza\xE7\xE3o",
3293
- examples: "Chat, mapas, v\xEDdeos embarcados"
3294
- },
3295
- performance: {
3296
- name: "Cookies de Performance",
3297
- description: "Coletam informa\xE7\xF5es sobre velocidade e estabilidade",
3298
- examples: "Monitoramento de erro, otimiza\xE7\xE3o de velocidade"
3299
- }
3300
- },
3301
- // Contextos específicos
3302
- contexts: {
3303
- ecommerce: {
3304
- cartAbandonment: "Lembramos dos produtos no seu carrinho",
3305
- personalizedOffers: "Ofertas personalizadas baseadas no seu hist\xF3rico",
3306
- paymentSecurity: "Seguran\xE7a adicional no processo de pagamento",
3307
- productRecommendations: "Sugest\xF5es de produtos relevantes"
3308
- },
3309
- saas: {
3310
- userAnalytics: "An\xE1lise de uso para melhorar funcionalidades",
3311
- performanceMonitoring: "Monitoramento de performance da aplica\xE7\xE3o",
3312
- featureUsage: "Estat\xEDsticas de uso de recursos",
3313
- customerSupport: "Suporte ao cliente mais eficiente"
3314
- },
3315
- government: {
3316
- citizenServices: "Melhoria dos servi\xE7os ao cidad\xE3o",
3317
- dataProtection: "Prote\xE7\xE3o rigorosa dos dados pessoais",
3318
- transparency: "Transpar\xEAncia no uso de dados",
3319
- accessibility: "Recursos de acessibilidade digital"
3320
- },
3321
- education: {
3322
- studentProgress: "Acompanhamento do progresso educacional",
3323
- learningAnalytics: "Analytics para melhorar o aprendizado",
3324
- accessibility: "Recursos educacionais acess\xEDveis",
3325
- parentalConsent: "Consentimento parental quando necess\xE1rio"
3326
- }
3327
- },
3328
- // Variações de tom
3329
- variants: {
3330
- formal: {
3331
- bannerMessage: "Este s\xEDtio eletr\xF4nico utiliza cookies para otimizar a experi\xEAncia de navega\xE7\xE3o.",
3332
- acceptAll: "Concordar com todos os cookies",
3333
- declineAll: "Recusar cookies opcionais",
3334
- modalTitle: "Configura\xE7\xE3o de Cookies"
3335
- },
3336
- casual: {
3337
- bannerMessage: "\u{1F36A} Ei! Usamos cookies para tornar sua experi\xEAncia ainda melhor!",
3338
- acceptAll: "Aceitar tudo",
3339
- declineAll: "S\xF3 o essencial",
3340
- modalTitle: "Seus Cookies"
3341
- },
3342
- concise: {
3343
- bannerMessage: "Usamos cookies. Voc\xEA aceita?",
3344
- acceptAll: "Sim",
3345
- declineAll: "N\xE3o",
3346
- modalTitle: "Cookies"
3347
- },
3348
- detailed: {
3349
- 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.",
3350
- acceptAll: "Aceitar todos os cookies e tecnologias",
3351
- declineAll: "Recusar todos os cookies opcionais",
3352
- modalTitle: "Centro de Prefer\xEAncias de Privacidade"
3353
- }
3354
- },
3355
- // Internacionalização simplificada (apenas textos básicos)
3356
- i18n: {
3357
- en: {
3358
- bannerMessage: "We use cookies to enhance your experience.",
3359
- acceptAll: "Accept All",
3360
- declineAll: "Decline",
3361
- preferences: "Preferences",
3362
- modalTitle: "Cookie Preferences",
3363
- modalIntro: "Customize your cookie preferences below.",
3364
- save: "Save Preferences",
3365
- necessaryAlwaysOn: "Necessary cookies (always active)"
3366
- },
3367
- es: {
3368
- bannerMessage: "Utilizamos cookies para mejorar su experiencia.",
3369
- acceptAll: "Aceptar Todo",
3370
- declineAll: "Rechazar",
3371
- preferences: "Preferencias",
3372
- modalTitle: "Preferencias de Cookies",
3373
- modalIntro: "Personalice sus preferencias de cookies a continuaci\xF3n.",
3374
- save: "Guardar Preferencias",
3375
- necessaryAlwaysOn: "Cookies necess\xE1rias (sempre ativas)"
3376
- },
3377
- fr: {
3378
- bannerMessage: "Nous utilisons des cookies pour am\xE9liorer votre exp\xE9rience.",
3379
- acceptAll: "Tout Accepter",
3380
- declineAll: "Refuser",
3381
- preferences: "Pr\xE9f\xE9rences",
3382
- modalTitle: "Pr\xE9f\xE9rences des Cookies",
3383
- modalIntro: "Personnalisez vos pr\xE9f\xE9rences de cookies ci-dessous.",
3384
- save: "Enregistrer les Pr\xE9f\xE9rences",
3385
- necessaryAlwaysOn: "Cookies n\xE9cessaires (toujours actifs)"
3386
- }
3387
- },
3388
- // Textos técnicos
3389
- technical: {
3390
- sessionCookies: "Cookies de sess\xE3o s\xE3o tempor\xE1rios e expiram quando voc\xEA fecha o navegador.",
3391
- persistentCookies: "Cookies persistentes permanecem no seu dispositivo at\xE9 expirarem ou serem removidos.",
3392
- thirdPartyCookies: "Cookies de terceiros s\xE3o definidos por dom\xEDnios diferentes do site que voc\xEA est\xE1 visitando.",
3393
- browserSettings: "Voc\xEA pode gerenciar cookies nas configura\xE7\xF5es do seu navegador.",
3394
- disablingImpact: "Desabilitar cookies pode afetar a funcionalidade do site."
3395
- },
3396
- // Cookie details
3397
- cookieDetails: {
3398
- tableHeaders: {
3399
- name: "Nome",
3400
- purpose: "Finalidade",
3401
- duration: "Dura\xE7\xE3o",
3402
- provider: "Fornecedor",
3403
- type: "Tipo"
3404
- },
3405
- noCookies: "Nenhum cookie encontrado para esta categoria.",
3406
- toggleDetails: {
3407
- expand: "Ver detalhes",
3408
- collapse: "Ocultar detalhes"
3409
- }
3410
- }
3411
- };
3412
- function resolveTexts(texts, options = {}) {
3413
- const { language = "pt", variant } = options;
3414
- let resolved = { ...texts };
3415
- if (variant && texts.variants?.[variant]) {
3416
- resolved = { ...resolved, ...texts.variants[variant] };
3417
- }
3418
- if (language !== "pt" && texts.i18n?.[language]) {
3419
- resolved = { ...resolved, ...texts.i18n[language] };
3420
- }
3421
- return resolved;
3422
- }
3423
- var TEXT_TEMPLATES = {
3424
- ecommerce: {
3425
- ...EXPANDED_DEFAULT_TEXTS,
3426
- bannerMessage: "Utilizamos cookies para personalizar ofertas e melhorar sua experi\xEAncia de compra.",
3427
- acceptAll: "Aceitar e continuar",
3428
- variants: {
3429
- casual: {
3430
- bannerMessage: "\u{1F6D2} Usamos cookies para encontrar as melhores ofertas para voc\xEA!",
3431
- acceptAll: "Quero ofertas personalizadas!"
3432
- }
3433
- }
3434
- },
3435
- saas: {
3436
- ...EXPANDED_DEFAULT_TEXTS,
3437
- bannerMessage: "Utilizamos cookies para otimizar o desempenho da aplica\xE7\xE3o e sua experi\xEAncia.",
3438
- acceptAll: "Aceitar e otimizar",
3439
- variants: {
3440
- formal: {
3441
- bannerMessage: "Esta aplica\xE7\xE3o utiliza cookies para an\xE1lise de performance e melhoria cont\xEDnua da experi\xEAncia do usu\xE1rio.",
3442
- acceptAll: "Autorizar coleta de dados de uso"
3443
- }
3444
- }
3445
- },
3446
- government: {
3447
- ...EXPANDED_DEFAULT_TEXTS,
3448
- bannerMessage: "Este portal utiliza cookies em conformidade com a LGPD para melhorar os servi\xE7os p\xFAblicos.",
3449
- acceptAll: "Aceitar em conformidade",
3450
- variants: {
3451
- formal: {
3452
- 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.",
3453
- acceptAll: "Concordar com o uso de cookies"
3454
- }
3455
- }
3456
- }
3457
- };
3458
-
3459
- export { ANPD_CATEGORY_PRESETS, COMMON_INTEGRATIONS, ConsentGate, ConsentProvider, ConsentScriptLoader, DEFAULT_PROJECT_CATEGORIES, DesignProvider, EXPANDED_DEFAULT_TEXTS, GUIDANCE_PRESETS, INTEGRATION_TEMPLATES, LogLevel, TEXT_TEMPLATES, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, buildConsentStorageKey, categorizeDiscoveredCookies, checkPeerDeps, createAnpdCategoriesConfig, createClarityIntegration, createConsentAuditEntry, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, ensureNecessaryAlwaysOn, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, getPeerDepsLocale, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, registerScript, resetPeerDepsMessages, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, setPeerDepsLocale, setPeerDepsMessages, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };
3698
+ export { ANPD_CATEGORY_PRESETS, COMMON_INTEGRATIONS, ConsentGate, ConsentProvider, ConsentScriptLoader, DEFAULT_PROJECT_CATEGORIES, DesignProvider, EXPANDED_DEFAULT_TEXTS, GUIDANCE_PRESETS, INTEGRATION_TEMPLATES, LogLevel, TEXT_TEMPLATES, analyzeDeveloperConfiguration, analyzeIntegrationCategories, autoConfigureCategories, buildConsentStorageKey, categorizeDiscoveredCookies, checkPeerDeps, createAnpdCategoriesConfig, createClarityIntegration, createConsentAuditEntry, createCorporateIntegrations, createECommerceIntegrations, createFacebookPixelIntegration, createGoogleAnalyticsIntegration, createGoogleTagManagerIntegration, createHotjarIntegration, createIntercomIntegration, createMixpanelIntegration, createProjectPreferences, createSaaSIntegrations, createSuggestedIntegration, createUserWayIntegration, createZendeskChatIntegration, defaultTexts, detectConsentCookieName, discoverRuntimeCookies, ensureNecessaryAlwaysOn, extractCategoriesFromIntegrations, getAllProjectCategories, getCookiesInfoForCategory, getPeerDepsLocale, loadScript, logDeveloperGuidance, logger, openPreferencesModal, pushConsentInitializedEvent, pushConsentUpdatedEvent, registerScript, resetPeerDepsMessages, resolveTexts, runPeerDepsCheck, setCookieCatalogOverrides, setCookieCategoryOverrides, setDebugLogging, setPeerDepsLocale, setPeerDepsMessages, suggestCategoryForScript, useCategories, useCategoryStatus, useConsent, useConsentHydration, useConsentScriptLoader, useConsentTexts, useDataLayerEvents, useDesignTokens, useDeveloperGuidance, useOpenPreferencesModal, validateIntegrationCategories, validateNecessaryClassification, validateProjectPreferences };