@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.cjs CHANGED
@@ -35,6 +35,219 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
35
35
  throw Error('Dynamic require of "' + x + '" is not supported');
36
36
  });
37
37
 
38
+ // src/types/advancedTexts.ts
39
+ var EXPANDED_DEFAULT_TEXTS = {
40
+ // Textos adicionais
41
+ confirm: "Confirmar",
42
+ cancel: "Cancelar",
43
+ loading: "Carregando...",
44
+ // Feedback
45
+ feedback: {
46
+ saveSuccess: "Prefer\xEAncias salvas com sucesso!",
47
+ saveError: "Erro ao salvar prefer\xEAncias. Tente novamente.",
48
+ consentUpdated: "Consentimento atualizado.",
49
+ cookiesRejected: "Cookies opcionais rejeitados.",
50
+ settingsReset: "Configura\xE7\xF5es resetadas."
51
+ },
52
+ // Acessibilidade
53
+ accessibility: {
54
+ bannerLabel: "Banner de consentimento de cookies",
55
+ modalLabel: "Modal de prefer\xEAncias de cookies",
56
+ keyboardNavigation: "Use Tab para navegar, Enter para selecionar",
57
+ toggleState: {
58
+ enabled: "Habilitado",
59
+ disabled: "Desabilitado"
60
+ },
61
+ liveRegion: "Regi\xE3o de an\xFAncios din\xE2micos"
62
+ },
63
+ // Categorias
64
+ categories: {
65
+ necessary: {
66
+ name: "Cookies Necess\xE1rios",
67
+ description: "Essenciais para o funcionamento b\xE1sico do site",
68
+ examples: "Sess\xE3o, seguran\xE7a, prefer\xEAncias de idioma"
69
+ },
70
+ analytics: {
71
+ name: "Cookies de Analytics",
72
+ description: "Ajudam a entender como os visitantes usam o site",
73
+ examples: "Google Analytics, contadores de p\xE1gina"
74
+ },
75
+ marketing: {
76
+ name: "Cookies de Marketing",
77
+ description: "Usados para personalizar an\xFAncios e ofertas",
78
+ examples: "Facebook Pixel, Google Ads, remarketing"
79
+ },
80
+ functional: {
81
+ name: "Cookies Funcionais",
82
+ description: "Melhoram a funcionalidade e personaliza\xE7\xE3o",
83
+ examples: "Chat, mapas, v\xEDdeos embarcados"
84
+ },
85
+ performance: {
86
+ name: "Cookies de Performance",
87
+ description: "Coletam informa\xE7\xF5es sobre velocidade e estabilidade",
88
+ examples: "Monitoramento de erro, otimiza\xE7\xE3o de velocidade"
89
+ }
90
+ },
91
+ // Contextos específicos
92
+ contexts: {
93
+ ecommerce: {
94
+ cartAbandonment: "Lembramos dos produtos no seu carrinho",
95
+ personalizedOffers: "Ofertas personalizadas baseadas no seu hist\xF3rico",
96
+ paymentSecurity: "Seguran\xE7a adicional no processo de pagamento",
97
+ productRecommendations: "Sugest\xF5es de produtos relevantes"
98
+ },
99
+ saas: {
100
+ userAnalytics: "An\xE1lise de uso para melhorar funcionalidades",
101
+ performanceMonitoring: "Monitoramento de performance da aplica\xE7\xE3o",
102
+ featureUsage: "Estat\xEDsticas de uso de recursos",
103
+ customerSupport: "Suporte ao cliente mais eficiente"
104
+ },
105
+ government: {
106
+ citizenServices: "Melhoria dos servi\xE7os ao cidad\xE3o",
107
+ dataProtection: "Prote\xE7\xE3o rigorosa dos dados pessoais",
108
+ transparency: "Transpar\xEAncia no uso de dados",
109
+ accessibility: "Recursos de acessibilidade digital"
110
+ },
111
+ education: {
112
+ studentProgress: "Acompanhamento do progresso educacional",
113
+ learningAnalytics: "Analytics para melhorar o aprendizado",
114
+ accessibility: "Recursos educacionais acess\xEDveis",
115
+ parentalConsent: "Consentimento parental quando necess\xE1rio"
116
+ }
117
+ },
118
+ // Variações de tom
119
+ variants: {
120
+ formal: {
121
+ bannerMessage: "Este s\xEDtio eletr\xF4nico utiliza cookies para otimizar a experi\xEAncia de navega\xE7\xE3o.",
122
+ acceptAll: "Concordar com todos os cookies",
123
+ declineAll: "Recusar cookies opcionais",
124
+ modalTitle: "Configura\xE7\xE3o de Cookies"
125
+ },
126
+ casual: {
127
+ bannerMessage: "\u{1F36A} Ei! Usamos cookies para tornar sua experi\xEAncia ainda melhor!",
128
+ acceptAll: "Aceitar tudo",
129
+ declineAll: "S\xF3 o essencial",
130
+ modalTitle: "Seus Cookies"
131
+ },
132
+ concise: {
133
+ bannerMessage: "Usamos cookies. Voc\xEA aceita?",
134
+ acceptAll: "Sim",
135
+ declineAll: "N\xE3o",
136
+ modalTitle: "Cookies"
137
+ },
138
+ detailed: {
139
+ 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.",
140
+ acceptAll: "Aceitar todos os cookies e tecnologias",
141
+ declineAll: "Recusar todos os cookies opcionais",
142
+ modalTitle: "Centro de Prefer\xEAncias de Privacidade"
143
+ }
144
+ },
145
+ // Internacionalização simplificada (apenas textos básicos)
146
+ i18n: {
147
+ en: {
148
+ bannerMessage: "We use cookies to enhance your experience.",
149
+ acceptAll: "Accept All",
150
+ declineAll: "Decline",
151
+ preferences: "Preferences",
152
+ modalTitle: "Cookie Preferences",
153
+ modalIntro: "Customize your cookie preferences below.",
154
+ save: "Save Preferences",
155
+ necessaryAlwaysOn: "Necessary cookies (always active)"
156
+ },
157
+ es: {
158
+ bannerMessage: "Utilizamos cookies para mejorar su experiencia.",
159
+ acceptAll: "Aceptar Todo",
160
+ declineAll: "Rechazar",
161
+ preferences: "Preferencias",
162
+ modalTitle: "Preferencias de Cookies",
163
+ modalIntro: "Personalice sus preferencias de cookies a continuaci\xF3n.",
164
+ save: "Guardar Preferencias",
165
+ necessaryAlwaysOn: "Cookies necess\xE1rias (sempre ativas)"
166
+ },
167
+ fr: {
168
+ bannerMessage: "Nous utilisons des cookies pour am\xE9liorer votre exp\xE9rience.",
169
+ acceptAll: "Tout Accepter",
170
+ declineAll: "Refuser",
171
+ preferences: "Pr\xE9f\xE9rences",
172
+ modalTitle: "Pr\xE9f\xE9rences des Cookies",
173
+ modalIntro: "Personnalisez vos pr\xE9f\xE9rences de cookies ci-dessous.",
174
+ save: "Enregistrer les Pr\xE9f\xE9rences",
175
+ necessaryAlwaysOn: "Cookies n\xE9cessaires (toujours actifs)"
176
+ }
177
+ },
178
+ // Textos técnicos
179
+ technical: {
180
+ sessionCookies: "Cookies de sess\xE3o s\xE3o tempor\xE1rios e expiram quando voc\xEA fecha o navegador.",
181
+ persistentCookies: "Cookies persistentes permanecem no seu dispositivo at\xE9 expirarem ou serem removidos.",
182
+ thirdPartyCookies: "Cookies de terceiros s\xE3o definidos por dom\xEDnios diferentes do site que voc\xEA est\xE1 visitando.",
183
+ browserSettings: "Voc\xEA pode gerenciar cookies nas configura\xE7\xF5es do seu navegador.",
184
+ disablingImpact: "Desabilitar cookies pode afetar a funcionalidade do site."
185
+ },
186
+ // Cookie details
187
+ cookieDetails: {
188
+ tableHeaders: {
189
+ name: "Nome",
190
+ purpose: "Finalidade",
191
+ duration: "Dura\xE7\xE3o",
192
+ provider: "Fornecedor",
193
+ type: "Tipo"
194
+ },
195
+ noCookies: "Nenhum cookie encontrado para esta categoria.",
196
+ toggleDetails: {
197
+ expand: "Ver detalhes",
198
+ collapse: "Ocultar detalhes"
199
+ },
200
+ scriptLabelPrefix: "(script) ",
201
+ scriptPurpose: "Script de integra\xE7\xE3o ativo"
202
+ }
203
+ };
204
+ function resolveTexts(texts, options = {}) {
205
+ const { language = "pt", variant } = options;
206
+ let resolved = { ...texts };
207
+ if (variant && texts.variants?.[variant]) {
208
+ resolved = { ...resolved, ...texts.variants[variant] };
209
+ }
210
+ if (language !== "pt" && texts.i18n?.[language]) {
211
+ resolved = { ...resolved, ...texts.i18n[language] };
212
+ }
213
+ return resolved;
214
+ }
215
+ var TEXT_TEMPLATES = {
216
+ ecommerce: {
217
+ ...EXPANDED_DEFAULT_TEXTS,
218
+ bannerMessage: "Utilizamos cookies para personalizar ofertas e melhorar sua experi\xEAncia de compra.",
219
+ acceptAll: "Aceitar e continuar",
220
+ variants: {
221
+ casual: {
222
+ bannerMessage: "\u{1F6D2} Usamos cookies para encontrar as melhores ofertas para voc\xEA!",
223
+ acceptAll: "Quero ofertas personalizadas!"
224
+ }
225
+ }
226
+ },
227
+ saas: {
228
+ ...EXPANDED_DEFAULT_TEXTS,
229
+ bannerMessage: "Utilizamos cookies para otimizar o desempenho da aplica\xE7\xE3o e sua experi\xEAncia.",
230
+ acceptAll: "Aceitar e otimizar",
231
+ variants: {
232
+ formal: {
233
+ bannerMessage: "Esta aplica\xE7\xE3o utiliza cookies para an\xE1lise de performance e melhoria cont\xEDnua da experi\xEAncia do usu\xE1rio.",
234
+ acceptAll: "Autorizar coleta de dados de uso"
235
+ }
236
+ }
237
+ },
238
+ government: {
239
+ ...EXPANDED_DEFAULT_TEXTS,
240
+ bannerMessage: "Este portal utiliza cookies em conformidade com a LGPD para melhorar os servi\xE7os p\xFAblicos.",
241
+ acceptAll: "Aceitar em conformidade",
242
+ variants: {
243
+ formal: {
244
+ 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.",
245
+ acceptAll: "Concordar com o uso de cookies"
246
+ }
247
+ }
248
+ }
249
+ };
250
+
38
251
  // src/utils/categoryUtils.ts
39
252
  function createProjectPreferences(config, defaultValue = false) {
40
253
  const preferences = {
@@ -346,15 +559,16 @@ var DEFAULT_COOKIE_OPTS = {
346
559
  maxAge: DEFAULT_MAX_AGE_SECONDS,
347
560
  maxAgeDays: 365,
348
561
  sameSite: "Lax",
349
- secure: globalThis.window === void 0 ? false : globalThis.window.location.protocol === "https:",
562
+ secure: false,
350
563
  path: "/",
351
564
  domain: void 0
352
565
  };
353
566
  function resolveCookieOptions(opts) {
354
- const protocols = [
355
- typeof globalThis.window !== "undefined" ? globalThis.window?.location?.protocol : void 0,
356
- typeof globalThis.location !== "undefined" ? globalThis.location?.protocol : void 0
357
- ].filter(Boolean);
567
+ const currentWindow = globalThis.window;
568
+ const currentLocation = globalThis.location;
569
+ const protocols = [currentWindow?.location?.protocol, currentLocation?.protocol].filter(
570
+ Boolean
571
+ );
358
572
  const forceHttps = globalThis.__LGPD_FORCE_HTTPS__ === true;
359
573
  const isHttps = forceHttps || protocols.includes("https:");
360
574
  const maxAgeSecondsFromDays = typeof opts?.maxAgeDays === "number" ? Math.max(0, opts.maxAgeDays * 24 * 60 * 60) : null;
@@ -363,7 +577,7 @@ function resolveCookieOptions(opts) {
363
577
  name: opts?.name ?? DEFAULT_COOKIE_OPTS.name,
364
578
  maxAge: maxAgeSeconds,
365
579
  sameSite: opts?.sameSite ?? DEFAULT_COOKIE_OPTS.sameSite ?? "Lax",
366
- secure: typeof opts?.secure === "boolean" ? opts.secure : isHttps ? true : DEFAULT_COOKIE_OPTS.secure ?? false,
580
+ secure: typeof opts?.secure === "boolean" ? opts.secure : isHttps ? true : DEFAULT_COOKIE_OPTS.secure,
367
581
  path: opts?.path ?? DEFAULT_COOKIE_OPTS.path ?? "/",
368
582
  domain: opts?.domain ?? DEFAULT_COOKIE_OPTS.domain ?? void 0
369
583
  };
@@ -371,7 +585,7 @@ function resolveCookieOptions(opts) {
371
585
  var COOKIE_SCHEMA_VERSION = "1.0";
372
586
  function readConsentCookie(name = DEFAULT_COOKIE_OPTS.name) {
373
587
  logger.debug("Reading consent cookie", { name });
374
- if (typeof document === "undefined") {
588
+ if (globalThis.document === void 0) {
375
589
  logger.debug("Cookie read skipped: server-side environment");
376
590
  return null;
377
591
  }
@@ -422,7 +636,7 @@ function migrateLegacyCookie(legacyData) {
422
636
  }
423
637
  }
424
638
  function writeConsentCookie(state, config, opts, source = "banner") {
425
- if (typeof document === "undefined" || typeof window === "undefined" || globalThis.__LGPD_SSR__ === true) {
639
+ if (globalThis.document === void 0 || globalThis.window === void 0 || globalThis.__LGPD_SSR__ === true) {
426
640
  logger.debug("Cookie write skipped: server-side environment");
427
641
  return;
428
642
  }
@@ -471,7 +685,7 @@ function createConsentAuditEntry(state, params) {
471
685
  };
472
686
  }
473
687
  function removeConsentCookie(opts) {
474
- if (typeof document === "undefined") {
688
+ if (globalThis.document === void 0) {
475
689
  logger.debug("Cookie removal skipped: server-side environment");
476
690
  return;
477
691
  }
@@ -482,14 +696,23 @@ function removeConsentCookie(opts) {
482
696
  }
483
697
 
484
698
  // src/utils/dataLayerEvents.ts
485
- var LIBRARY_VERSION = "0.7.1";
699
+ var LIBRARY_VERSION = "0.7.2";
486
700
  function ensureDataLayer() {
487
- var _a;
488
- if (globalThis.window === void 0) return;
489
- (_a = globalThis.window).dataLayer ?? (_a.dataLayer = []);
701
+ const currentWindow = globalThis.window;
702
+ if (!currentWindow) return;
703
+ const currentLayer = currentWindow.dataLayer;
704
+ if (currentLayer == null) {
705
+ currentWindow.dataLayer = [];
706
+ return;
707
+ }
708
+ if (typeof currentLayer.push !== "function") {
709
+ const env = globalThis.process?.env?.NODE_ENV ?? "production";
710
+ if (env !== "production") {
711
+ console.warn("[LGPD-CONSENT] dataLayer presente mas sem push; eventos n\xE3o ser\xE3o registrados.");
712
+ }
713
+ }
490
714
  }
491
715
  function pushConsentInitializedEvent(categories) {
492
- if (globalThis.window === void 0) return;
493
716
  ensureDataLayer();
494
717
  const event = {
495
718
  event: "consent_initialized",
@@ -498,10 +721,12 @@ function pushConsentInitializedEvent(categories) {
498
721
  categories,
499
722
  preferences: categories
500
723
  };
501
- globalThis.window.dataLayer?.push(event);
724
+ const layer = globalThis.window?.dataLayer;
725
+ if (layer && typeof layer.push === "function") {
726
+ layer.push(event);
727
+ }
502
728
  }
503
729
  function pushConsentUpdatedEvent(categories, origin, previousCategories) {
504
- if (globalThis.window === void 0) return;
505
730
  ensureDataLayer();
506
731
  const changedCategories = previousCategories ? Object.keys(categories).filter((key) => categories[key] !== previousCategories[key]) : [];
507
732
  const event = {
@@ -513,7 +738,10 @@ function pushConsentUpdatedEvent(categories, origin, previousCategories) {
513
738
  preferences: categories,
514
739
  changed_categories: changedCategories
515
740
  };
516
- globalThis.window.dataLayer?.push(event);
741
+ const layer = globalThis.window?.dataLayer;
742
+ if (layer && typeof layer.push === "function") {
743
+ layer.push(event);
744
+ }
517
745
  }
518
746
  function useDataLayerEvents() {
519
747
  return {
@@ -843,7 +1071,7 @@ function analyzeDeveloperConfiguration(config) {
843
1071
  const gt = globalThis;
844
1072
  const implied = (gt.__LGPD_REQUIRED_CATEGORIES__ || []).filter(Boolean);
845
1073
  implied.forEach((id) => {
846
- if (!guidance.activeCategoriesInfo.find((c) => c.id === id)) {
1074
+ if (!guidance.activeCategoriesInfo.some((c) => c.id === id)) {
847
1075
  const info = NAMES[id];
848
1076
  if (info) {
849
1077
  guidance.activeCategoriesInfo.push({
@@ -883,6 +1111,27 @@ function analyzeDeveloperConfiguration(config) {
883
1111
  'Apenas cookies necess\xE1rios est\xE3o configurados. Para compliance LGPD, considere adicionar categorias como "analytics" ou "functional" conforme uso real.',
884
1112
  "compliance"
885
1113
  );
1114
+ } else {
1115
+ addMessage(
1116
+ "info",
1117
+ "Cookies n\xE3o necess\xE1rios devem iniciar desativados e exigir consentimento expresso, sem pr\xE9-sele\xE7\xE3o e sem consentimento t\xE1cito.",
1118
+ "consent"
1119
+ );
1120
+ addMessage(
1121
+ "info",
1122
+ "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.",
1123
+ "consent"
1124
+ );
1125
+ addMessage(
1126
+ "info",
1127
+ "Informe finalidades espec\xEDficas, per\xEDodo de reten\xE7\xE3o e compartilhamento com terceiros em pol\xEDtica/aviso de cookies.",
1128
+ "transparency"
1129
+ );
1130
+ addMessage(
1131
+ "info",
1132
+ "Disponibilize mecanismo pr\xF3prio de gerenciamento de cookies; configura\xE7\xF5es do navegador s\xE3o apenas complementares.",
1133
+ "transparency"
1134
+ );
886
1135
  }
887
1136
  if (totalToggleable > 5) {
888
1137
  addMessage(
@@ -907,7 +1156,7 @@ function getComplianceScoreColor(score) {
907
1156
  function logComplianceScore(prefix, score) {
908
1157
  const color = getComplianceScoreColor(score);
909
1158
  console.log(
910
- `%c${prefix} Score de Conformidade LGPD: ${score}/100`,
1159
+ `%c${prefix} Score de Conformidade LGPD (orientativo): ${score}/100`,
911
1160
  `color: ${color}; font-weight: bold; font-size: 14px;`
912
1161
  );
913
1162
  }
@@ -1002,7 +1251,7 @@ function logServerSideIfAvailable(guidance) {
1002
1251
  }
1003
1252
  function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
1004
1253
  const gt = globalThis;
1005
- const nodeEnv = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
1254
+ const nodeEnv = gt.process ? gt.process?.env?.NODE_ENV : void 0;
1006
1255
  const isProd = nodeEnv === "production" || gt.__LGPD_PRODUCTION__ === true;
1007
1256
  if (isProd || disableGuidanceProp) return;
1008
1257
  const guidanceHash = getGuidanceHash(guidance);
@@ -1060,11 +1309,21 @@ function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
1060
1309
  "color: #9c27b0;",
1061
1310
  "color: #7b1fa2;"
1062
1311
  );
1312
+ console.info(
1313
+ `%c${PREFIX}%c Evite consentimento t\xE1cito e op\xE7\xF5es pr\xE9-selecionadas`,
1314
+ "color: #9c27b0;",
1315
+ "color: #7b1fa2;"
1316
+ );
1063
1317
  console.info(
1064
1318
  `%c${PREFIX}%c Documente pol\xEDticas claras por categoria`,
1065
1319
  "color: #9c27b0;",
1066
1320
  "color: #7b1fa2;"
1067
1321
  );
1322
+ console.info(
1323
+ `%c${PREFIX}%c Informe finalidades, reten\xE7\xE3o e revoga\xE7\xE3o simples e gratuita`,
1324
+ "color: #9c27b0;",
1325
+ "color: #7b1fa2;"
1326
+ );
1068
1327
  console.info(
1069
1328
  `%c${PREFIX}%c Registre consentimento com data/hora/origem`,
1070
1329
  "color: #9c27b0;",
@@ -1076,7 +1335,9 @@ function logDeveloperGuidance(guidance, disableGuidanceProp, config) {
1076
1335
  function useDeveloperGuidance(config, disableGuidanceProp, guidanceConfig) {
1077
1336
  const guidance = React4__namespace.default.useMemo(() => analyzeDeveloperConfiguration(config), [config]);
1078
1337
  React4__namespace.default.useEffect(() => {
1079
- if (!disableGuidanceProp) logDeveloperGuidance(guidance, disableGuidanceProp, guidanceConfig);
1338
+ if (globalThis.window !== void 0 && !disableGuidanceProp) {
1339
+ logDeveloperGuidance(guidance, disableGuidanceProp, guidanceConfig);
1340
+ }
1080
1341
  }, [guidance, disableGuidanceProp, guidanceConfig]);
1081
1342
  return guidance;
1082
1343
  }
@@ -1379,28 +1640,30 @@ function getMessages() {
1379
1640
  };
1380
1641
  }
1381
1642
  function detectMultipleReactInstances() {
1382
- if (globalThis.window === void 0) return false;
1643
+ const currentWindow = globalThis.window;
1644
+ if (currentWindow === void 0) return false;
1383
1645
  try {
1384
- const reactSymbols = Object.getOwnPropertySymbols(globalThis.window).map(String).filter((name) => name.includes("react"));
1646
+ const reactSymbols = Object.getOwnPropertySymbols(currentWindow).map(String).filter((name) => name.includes("react"));
1385
1647
  if (reactSymbols.length > 1) {
1386
1648
  return true;
1387
1649
  }
1388
- const ReactModule = window.React;
1650
+ const ReactModule = currentWindow.React;
1389
1651
  if (ReactModule && Array.isArray(ReactModule)) {
1390
1652
  return true;
1391
1653
  }
1392
- const hasMultipleVersions = window.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers?.size > 1;
1654
+ const hasMultipleVersions = (currentWindow.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers?.size ?? 0) > 1;
1393
1655
  return hasMultipleVersions || false;
1394
1656
  } catch {
1395
1657
  return false;
1396
1658
  }
1397
1659
  }
1398
1660
  function getPackageVersion(packageName) {
1399
- if (globalThis.window === void 0) return null;
1661
+ const currentWindow = globalThis.window;
1662
+ if (currentWindow === void 0) return null;
1400
1663
  try {
1401
- const pkg = window[packageName];
1664
+ const pkg = currentWindow[packageName];
1402
1665
  if (pkg?.version) return pkg.version;
1403
- const React6 = window.React;
1666
+ const React6 = currentWindow.React;
1404
1667
  if (packageName === "react" && React6?.version) {
1405
1668
  return React6.version;
1406
1669
  }
@@ -1424,7 +1687,8 @@ function checkPeerDeps(options = {}) {
1424
1687
  if (skipInProduction && isProduction) {
1425
1688
  return result;
1426
1689
  }
1427
- if (globalThis.window === void 0) {
1690
+ const currentWindow = globalThis.window;
1691
+ if (currentWindow === void 0) {
1428
1692
  return result;
1429
1693
  }
1430
1694
  const messages = getMessages();
@@ -1446,7 +1710,7 @@ function checkPeerDeps(options = {}) {
1446
1710
  }
1447
1711
  }
1448
1712
  }
1449
- const muiVersion = window["@mui/material"]?.version;
1713
+ const muiVersion = currentWindow["@mui/material"]?.version;
1450
1714
  if (muiVersion) {
1451
1715
  if (!isVersionInRange(muiVersion, 5, 7)) {
1452
1716
  result.warnings.push(messages.MUI_OUT_OF_RANGE(muiVersion));
@@ -1576,10 +1840,11 @@ function validateConsentProviderProps(props) {
1576
1840
 
1577
1841
  // src/utils/cookieDiscovery.ts
1578
1842
  function discoverRuntimeCookies() {
1579
- if (typeof document === "undefined" || !document.cookie) return [];
1843
+ const currentDocument = globalThis.document;
1844
+ if (currentDocument === void 0 || !currentDocument.cookie) return [];
1580
1845
  const names = Array.from(
1581
1846
  new Set(
1582
- document.cookie.split(";").map((s) => s.trim()).filter(Boolean).map((s) => s.split("=")[0])
1847
+ currentDocument.cookie.split(";").map((s) => s.trim()).filter(Boolean).map((s) => s.split("=")[0])
1583
1848
  )
1584
1849
  );
1585
1850
  const list = names.map((name) => ({ name }));
@@ -1590,27 +1855,34 @@ function discoverRuntimeCookies() {
1590
1855
  }
1591
1856
  return list;
1592
1857
  }
1858
+ function tryDecode(val) {
1859
+ try {
1860
+ return decodeURIComponent(val);
1861
+ } catch {
1862
+ return val;
1863
+ }
1864
+ }
1865
+ function isConsentJson(val) {
1866
+ if (!val.startsWith("{")) return false;
1867
+ try {
1868
+ const obj = JSON.parse(val);
1869
+ return obj && typeof obj === "object" && "preferences" in obj && "version" in obj;
1870
+ } catch {
1871
+ return false;
1872
+ }
1873
+ }
1593
1874
  function detectConsentCookieName() {
1594
- if (typeof document === "undefined" || !document.cookie) return null;
1875
+ const currentDocument = globalThis.document;
1876
+ if (currentDocument === void 0 || !currentDocument.cookie) return null;
1595
1877
  try {
1596
- const pairs = document.cookie.split(";").map((s) => s.trim()).filter(Boolean);
1878
+ const pairs = currentDocument.cookie.split(";").map((s) => s.trim()).filter(Boolean);
1597
1879
  for (const p of pairs) {
1598
1880
  const [name, ...rest] = p.split("=");
1599
1881
  const raw = rest.join("=");
1600
1882
  if (!raw) continue;
1601
- let val = raw;
1602
- try {
1603
- val = decodeURIComponent(raw);
1604
- } catch {
1605
- }
1606
- if (val.startsWith("{")) {
1607
- try {
1608
- const obj = JSON.parse(val);
1609
- if (obj && typeof obj === "object" && "preferences" in obj && "version" in obj) {
1610
- return name;
1611
- }
1612
- } catch {
1613
- }
1883
+ const val = tryDecode(raw);
1884
+ if (isConsentJson(val)) {
1885
+ return name;
1614
1886
  }
1615
1887
  }
1616
1888
  } catch {
@@ -1652,15 +1924,6 @@ function CategoriesProvider({
1652
1924
  disableDiscoveryLog
1653
1925
  }) {
1654
1926
  const [impliedVersion, setImpliedVersion] = React4__namespace.useState(0);
1655
- React4__namespace.useEffect(() => {
1656
- const handler = () => setImpliedVersion((v) => v + 1);
1657
- if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
1658
- window.addEventListener("lgpd:requiredCategories", handler);
1659
- return () => window.removeEventListener("lgpd:requiredCategories", handler);
1660
- }
1661
- return () => {
1662
- };
1663
- }, []);
1664
1927
  const contextValue = React4__namespace.useMemo(() => {
1665
1928
  const finalConfig = config || DEFAULT_PROJECT_CATEGORIES;
1666
1929
  const guidance = analyzeDeveloperConfiguration(config);
@@ -1672,35 +1935,47 @@ function CategoriesProvider({
1672
1935
  allCategories: guidance.activeCategoriesInfo
1673
1936
  };
1674
1937
  }, [config, impliedVersion]);
1938
+ React4__namespace.useEffect(() => {
1939
+ const currentWindow = globalThis.window;
1940
+ if (!currentWindow || typeof currentWindow.addEventListener !== "function") return;
1941
+ const handler = () => {
1942
+ setImpliedVersion((current) => current + 1);
1943
+ };
1944
+ currentWindow.addEventListener("lgpd:requiredCategories", handler);
1945
+ return () => {
1946
+ currentWindow.removeEventListener("lgpd:requiredCategories", handler);
1947
+ };
1948
+ }, []);
1675
1949
  React4__namespace.useEffect(() => {
1676
1950
  logDeveloperGuidance(contextValue.guidance, disableDeveloperGuidance);
1677
1951
  }, [contextValue.guidance, disableDeveloperGuidance]);
1678
1952
  React4__namespace.useEffect(() => {
1679
1953
  try {
1680
1954
  const gt = globalThis;
1681
- const env = typeof gt.process !== "undefined" ? gt.process?.env?.NODE_ENV : void 0;
1955
+ const env = gt.process?.env?.NODE_ENV;
1682
1956
  const isDev2 = env === "development";
1683
- if (!isDev2 || gt.__LGPD_DISCOVERY_LOGGED__ === true || disableDiscoveryLog) return;
1684
- const discovered = discoverRuntimeCookies();
1685
- const consentName = detectConsentCookieName() || DEFAULT_COOKIE_OPTS.name;
1686
- const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
1687
- if (typeof console !== "undefined") {
1688
- try {
1689
- console.group(`${PREFIX} \u{1F50E} Descoberta de cookies (experimental)`);
1690
- const names = Array.from(
1691
- new Set([consentName, ...discovered.map((d) => d.name)].filter(Boolean))
1692
- );
1693
- const rows = names.map((n) => ({ Cookie: n }));
1694
- if (typeof console.table === "function") console.table(rows);
1695
- else console.log(rows);
1696
- console.info(
1697
- `${PREFIX} \u2139\uFE0F Estes nomes s\xE3o detectados em tempo de execu\xE7\xE3o. Ajuste ou categorize via APIs de override se necess\xE1rio.`
1698
- );
1699
- console.groupEnd();
1700
- } catch {
1957
+ if (isDev2 && gt.__LGPD_DISCOVERY_LOGGED__ !== true && !disableDiscoveryLog) {
1958
+ const discovered = discoverRuntimeCookies();
1959
+ const consentName = detectConsentCookieName() || DEFAULT_COOKIE_OPTS.name;
1960
+ const PREFIX = "[\u{1F36A} LGPD-CONSENT]";
1961
+ if (typeof console !== "undefined") {
1962
+ try {
1963
+ console.group(`${PREFIX} \u{1F50E} Descoberta de cookies (experimental)`);
1964
+ const names = Array.from(
1965
+ new Set([consentName, ...discovered.map((d) => d.name)].filter(Boolean))
1966
+ );
1967
+ const rows = names.map((n) => ({ Cookie: n }));
1968
+ if (typeof console.table === "function") console.table(rows);
1969
+ else console.log(rows);
1970
+ console.info(
1971
+ `${PREFIX} \u2139\uFE0F Estes nomes s\xE3o detectados em tempo de execu\xE7\xE3o. Ajuste ou categorize via APIs de override se necess\xE1rio.`
1972
+ );
1973
+ console.groupEnd();
1974
+ } catch {
1975
+ }
1701
1976
  }
1977
+ gt.__LGPD_DISCOVERY_LOGGED__ = true;
1702
1978
  }
1703
- gt.__LGPD_DISCOVERY_LOGGED__ = true;
1704
1979
  } catch {
1705
1980
  }
1706
1981
  }, [disableDiscoveryLog]);
@@ -1750,7 +2025,7 @@ function createFullConsentState(consented, preferences, source, projectConfig, i
1750
2025
  isModalOpen
1751
2026
  };
1752
2027
  }
1753
- var DEFAULT_TEXTS = {
2028
+ var BASE_TEXTS = {
1754
2029
  // Textos básicos
1755
2030
  bannerMessage: "Utilizamos cookies para melhorar sua experi\xEAncia.",
1756
2031
  acceptAll: "Aceitar todos",
@@ -1787,6 +2062,10 @@ var DEFAULT_TEXTS = {
1787
2062
  transferCountries: void 0
1788
2063
  // Exibido se definido
1789
2064
  };
2065
+ var DEFAULT_TEXTS = {
2066
+ ...BASE_TEXTS,
2067
+ ...EXPANDED_DEFAULT_TEXTS
2068
+ };
1790
2069
  function reducer(state, action) {
1791
2070
  logger.consentState(action.type, state);
1792
2071
  switch (action.type) {
@@ -1870,6 +2149,8 @@ function ConsentProvider({
1870
2149
  initialState,
1871
2150
  categories,
1872
2151
  texts: textsProp,
2152
+ language,
2153
+ textVariant,
1873
2154
  designTokens,
1874
2155
  PreferencesModalComponent,
1875
2156
  preferencesModalProps = {},
@@ -1894,7 +2175,11 @@ function ConsentProvider({
1894
2175
  onConsentChange,
1895
2176
  onAuditLog
1896
2177
  }) {
1897
- const texts = React4__namespace.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
2178
+ const mergedTexts = React4__namespace.useMemo(() => ({ ...DEFAULT_TEXTS, ...textsProp ?? {} }), [textsProp]);
2179
+ const texts = React4__namespace.useMemo(
2180
+ () => resolveTexts(mergedTexts, { language, variant: textVariant }),
2181
+ [mergedTexts, language, textVariant]
2182
+ );
1898
2183
  const cookie = React4__namespace.useMemo(() => {
1899
2184
  const base = { ...DEFAULT_COOKIE_OPTS, ...cookieOpts ?? {} };
1900
2185
  base.name = cookieOpts?.name ?? buildConsentStorageKey({
@@ -2311,8 +2596,9 @@ function hasCategoryConsent(snapshot, category) {
2311
2596
  return Boolean(snapshot.preferences?.[category]);
2312
2597
  }
2313
2598
  function loadScript(id, src, category = null, attrs = {}, nonce, options) {
2314
- if (typeof document === "undefined") return Promise.resolve();
2315
- if (document.getElementById(id)) return Promise.resolve();
2599
+ const currentDocument = globalThis.document;
2600
+ if (!src || currentDocument === void 0) return Promise.resolve();
2601
+ if (currentDocument.getElementById(id)) return Promise.resolve();
2316
2602
  const existingPromise = LOADING_SCRIPTS.get(id);
2317
2603
  if (existingPromise) return existingPromise;
2318
2604
  const pollInterval = options?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL;
@@ -2320,7 +2606,7 @@ function loadScript(id, src, category = null, attrs = {}, nonce, options) {
2320
2606
  const mergedAttrs = { ...attrs };
2321
2607
  const promise = new Promise((resolve, reject) => {
2322
2608
  const inject = () => {
2323
- const s = document.createElement("script");
2609
+ const s = currentDocument.createElement("script");
2324
2610
  s.id = id;
2325
2611
  s.src = src;
2326
2612
  s.async = mergedAttrs.async !== "false";
@@ -2338,7 +2624,7 @@ function loadScript(id, src, category = null, attrs = {}, nonce, options) {
2338
2624
  LOADING_SCRIPTS.delete(id);
2339
2625
  reject(new Error(`Failed to load script: ${src}`));
2340
2626
  };
2341
- document.body.appendChild(s);
2627
+ currentDocument.body.appendChild(s);
2342
2628
  };
2343
2629
  const snapshot = options?.consentSnapshot;
2344
2630
  const skipChecks = options?.skipConsentCheck === true;
@@ -2826,6 +3112,31 @@ function useConsentScriptLoader() {
2826
3112
  }
2827
3113
 
2828
3114
  // src/utils/scriptIntegrations.ts
3115
+ function createSuggestedIntegration(config) {
3116
+ const suggested = suggestCategoryForScript(config.id)[0] ?? "analytics";
3117
+ const category = resolveCategory(suggested, config.category);
3118
+ const { category: _ignored, ...rest } = config;
3119
+ return { ...rest, category };
3120
+ }
3121
+ var resolveCategory = (fallback, override) => {
3122
+ if (typeof override === "string" && override.trim().length > 0) return override.trim();
3123
+ return fallback;
3124
+ };
3125
+ var isDevEnv = () => {
3126
+ const env = typeof globalThis !== "undefined" ? globalThis.process?.env?.NODE_ENV : void 0;
3127
+ return env !== "production";
3128
+ };
3129
+ var resolveRequiredString = (value, field, integrationId) => {
3130
+ if (typeof value !== "string" || value.trim().length === 0) {
3131
+ if (isDevEnv()) {
3132
+ console.error(
3133
+ `[LGPD-CONSENT] Config inv\xE1lida: integra\xE7\xE3o "${integrationId}" requer "${field}".`
3134
+ );
3135
+ }
3136
+ return null;
3137
+ }
3138
+ return value.trim();
3139
+ };
2829
3140
  function buildConsentModeSignals(preferences) {
2830
3141
  const analytics = preferences.analytics ? "granted" : "denied";
2831
3142
  const marketing = preferences.marketing ? "granted" : "denied";
@@ -2837,16 +3148,18 @@ function buildConsentModeSignals(preferences) {
2837
3148
  };
2838
3149
  }
2839
3150
  function pushToLayer(entry, dataLayerName) {
2840
- if (typeof globalThis.window === "undefined") return;
2841
- const registry = globalThis.window;
3151
+ const currentWindow = globalThis.window;
3152
+ if (currentWindow === void 0) return;
3153
+ const registry = currentWindow;
2842
3154
  const name = dataLayerName ?? "dataLayer";
2843
3155
  const layer = registry[name] ?? [];
2844
3156
  registry[name] = layer;
2845
3157
  layer.push(entry);
2846
3158
  }
2847
3159
  function ensureGtag(dataLayerName = "dataLayer") {
2848
- if (typeof globalThis.window === "undefined") return null;
2849
- const w = window;
3160
+ const currentWindow = globalThis.window;
3161
+ if (currentWindow === void 0) return null;
3162
+ const w = currentWindow;
2850
3163
  const registry = w;
2851
3164
  const layer = registry[dataLayerName] ?? [];
2852
3165
  registry[dataLayerName] = layer;
@@ -2878,10 +3191,45 @@ function applyConsentModeUpdate(preferences, dataLayerName) {
2878
3191
  pushToLayer(["consent", "update", payload], dataLayerName);
2879
3192
  }
2880
3193
  function createGoogleAnalyticsIntegration(config) {
2881
- const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtag/js?id=${config.measurementId}`;
3194
+ const category = resolveCategory("analytics", config.category);
3195
+ const measurementId = resolveRequiredString(
3196
+ config.measurementId,
3197
+ "measurementId",
3198
+ "google-analytics"
3199
+ );
3200
+ if (!measurementId) {
3201
+ return {
3202
+ id: "google-analytics",
3203
+ category,
3204
+ src: "",
3205
+ cookies: ["_ga", "_ga_*", "_gid"],
3206
+ cookiesInfo: [
3207
+ {
3208
+ name: "_ga",
3209
+ purpose: "Identifica\xE7\xE3o \xFAnica de visitantes para an\xE1lise de tr\xE1fego",
3210
+ duration: "2 anos",
3211
+ provider: "Google Analytics"
3212
+ },
3213
+ {
3214
+ name: "_ga_*",
3215
+ purpose: "Rastreamento de sess\xF5es e eventos espec\xEDficos do stream GA4",
3216
+ duration: "2 anos",
3217
+ provider: "Google Analytics"
3218
+ },
3219
+ {
3220
+ name: "_gid",
3221
+ purpose: "Distin\xE7\xE3o de visitantes \xFAnicos em per\xEDodo de 24h",
3222
+ duration: "24 horas",
3223
+ provider: "Google Analytics"
3224
+ }
3225
+ ],
3226
+ attrs: { async: "true" }
3227
+ };
3228
+ }
3229
+ const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
2882
3230
  return {
2883
3231
  id: "google-analytics",
2884
- category: "analytics",
3232
+ category,
2885
3233
  src,
2886
3234
  cookies: ["_ga", "_ga_*", "_gid"],
2887
3235
  cookiesInfo: [
@@ -2914,16 +3262,26 @@ function createGoogleAnalyticsIntegration(config) {
2914
3262
  const gtag = ensureGtag();
2915
3263
  if (!gtag) return;
2916
3264
  gtag("js", /* @__PURE__ */ new Date());
2917
- gtag("config", config.measurementId, config.config ?? {});
3265
+ gtag("config", measurementId, config.config ?? {});
2918
3266
  },
2919
3267
  attrs: { async: "true" }
2920
3268
  };
2921
3269
  }
2922
3270
  function createGoogleTagManagerIntegration(config) {
2923
- const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtm.js?id=${config.containerId}`;
3271
+ const category = resolveCategory("analytics", config.category);
3272
+ const containerId = resolveRequiredString(config.containerId, "containerId", "google-tag-manager");
3273
+ if (!containerId) {
3274
+ return {
3275
+ id: "google-tag-manager",
3276
+ category,
3277
+ src: "",
3278
+ cookies: ["_gcl_au"]
3279
+ };
3280
+ }
3281
+ const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtm.js?id=${containerId}`;
2924
3282
  return {
2925
3283
  id: "google-tag-manager",
2926
- category: "analytics",
3284
+ category,
2927
3285
  src,
2928
3286
  cookies: ["_gcl_au"],
2929
3287
  bootstrap: () => {
@@ -2933,9 +3291,10 @@ function createGoogleTagManagerIntegration(config) {
2933
3291
  applyConsentModeUpdate(preferences, config.dataLayerName);
2934
3292
  },
2935
3293
  init: () => {
2936
- if (globalThis.window !== void 0) {
3294
+ const currentWindow = globalThis.window;
3295
+ if (currentWindow !== void 0) {
2937
3296
  const dataLayerName = config.dataLayerName || "dataLayer";
2938
- const w = window;
3297
+ const w = currentWindow;
2939
3298
  const layer = w[dataLayerName] ?? [];
2940
3299
  w[dataLayerName] = layer;
2941
3300
  layer.push({ "gtm.start": Date.now(), event: "gtm.js" });
@@ -2944,20 +3303,31 @@ function createGoogleTagManagerIntegration(config) {
2944
3303
  };
2945
3304
  }
2946
3305
  function createUserWayIntegration(config) {
3306
+ const category = resolveCategory("functional", config.category);
3307
+ const accountId = resolveRequiredString(config.accountId, "accountId", "userway");
3308
+ if (!accountId) {
3309
+ return {
3310
+ id: "userway",
3311
+ category,
3312
+ src: "",
3313
+ cookies: ["_userway_*"]
3314
+ };
3315
+ }
2947
3316
  const src = config.scriptUrl ?? "https://cdn.userway.org/widget.js";
2948
3317
  return {
2949
3318
  id: "userway",
2950
- category: "functional",
3319
+ category,
2951
3320
  src,
2952
3321
  cookies: ["_userway_*"],
2953
3322
  init: () => {
2954
- if (globalThis.window !== void 0) {
2955
- const w = window;
3323
+ const currentWindow = globalThis.window;
3324
+ if (currentWindow !== void 0) {
3325
+ const w = currentWindow;
2956
3326
  w.UserWayWidgetApp = w.UserWayWidgetApp || {};
2957
- w.UserWayWidgetApp.accountId = config.accountId;
3327
+ w.UserWayWidgetApp.accountId = accountId;
2958
3328
  }
2959
3329
  },
2960
- attrs: { "data-account": config.accountId }
3330
+ attrs: { "data-account": accountId }
2961
3331
  };
2962
3332
  }
2963
3333
  var COMMON_INTEGRATIONS = {
@@ -2966,15 +3336,26 @@ var COMMON_INTEGRATIONS = {
2966
3336
  userway: createUserWayIntegration
2967
3337
  };
2968
3338
  function createFacebookPixelIntegration(config) {
3339
+ const category = resolveCategory("marketing", config.category);
3340
+ const pixelId = resolveRequiredString(config.pixelId, "pixelId", "facebook-pixel");
3341
+ if (!pixelId) {
3342
+ return {
3343
+ id: "facebook-pixel",
3344
+ category,
3345
+ src: "",
3346
+ cookies: ["_fbp", "fr"]
3347
+ };
3348
+ }
2969
3349
  const src = config.scriptUrl ?? "https://connect.facebook.net/en_US/fbevents.js";
2970
3350
  return {
2971
3351
  id: "facebook-pixel",
2972
- category: "marketing",
3352
+ category,
2973
3353
  src,
2974
3354
  cookies: ["_fbp", "fr"],
2975
3355
  init: () => {
2976
- if (globalThis.window !== void 0) {
2977
- const w = window;
3356
+ const currentWindow = globalThis.window;
3357
+ if (currentWindow !== void 0) {
3358
+ const w = currentWindow;
2978
3359
  if (!w.fbq) {
2979
3360
  const fbq = (...args) => {
2980
3361
  if (w.fbq && typeof w.fbq.callMethod === "function") {
@@ -2987,18 +3368,34 @@ function createFacebookPixelIntegration(config) {
2987
3368
  fbq.loaded = true;
2988
3369
  w.fbq = fbq;
2989
3370
  }
2990
- w.fbq("init", config.pixelId, config.advancedMatching ?? {});
3371
+ w.fbq("init", pixelId, config.advancedMatching ?? {});
2991
3372
  if (config.autoTrack !== false) w.fbq("track", "PageView");
2992
3373
  }
2993
3374
  }
2994
3375
  };
2995
3376
  }
2996
3377
  function createHotjarIntegration(config) {
3378
+ const category = resolveCategory("analytics", config.category);
3379
+ const siteId = resolveRequiredString(config.siteId, "siteId", "hotjar");
2997
3380
  const v = config.version ?? 6;
2998
- const src = config.scriptUrl ?? `https://static.hotjar.com/c/hotjar-${config.siteId}.js?sv=${v}`;
3381
+ if (!siteId) {
3382
+ return {
3383
+ id: "hotjar",
3384
+ category,
3385
+ src: "",
3386
+ cookies: [
3387
+ "_hjSession_*",
3388
+ "_hjSessionUser_*",
3389
+ "_hjFirstSeen",
3390
+ "_hjIncludedInSessionSample",
3391
+ "_hjAbsoluteSessionInProgress"
3392
+ ]
3393
+ };
3394
+ }
3395
+ const src = config.scriptUrl ?? `https://static.hotjar.com/c/hotjar-${siteId}.js?sv=${v}`;
2999
3396
  return {
3000
3397
  id: "hotjar",
3001
- category: "analytics",
3398
+ category,
3002
3399
  src,
3003
3400
  cookies: [
3004
3401
  "_hjSession_*",
@@ -3040,9 +3437,10 @@ function createHotjarIntegration(config) {
3040
3437
  }
3041
3438
  ],
3042
3439
  init: () => {
3043
- if (globalThis.window !== void 0) {
3044
- const w = window;
3045
- w._hjSettings = { hjid: config.siteId, hjsv: v };
3440
+ const currentWindow = globalThis.window;
3441
+ if (currentWindow !== void 0) {
3442
+ const w = currentWindow;
3443
+ w._hjSettings = { hjid: siteId, hjsv: v };
3046
3444
  if (!w.hj) {
3047
3445
  const hj = (...args) => {
3048
3446
  hj.q = hj.q || [];
@@ -3051,17 +3449,35 @@ function createHotjarIntegration(config) {
3051
3449
  w.hj = hj;
3052
3450
  }
3053
3451
  if (config.debug && typeof console !== "undefined" && typeof console.info === "function") {
3054
- console.info("[Hotjar] initialized with siteId", config.siteId);
3452
+ console.info("[Hotjar] initialized with siteId", siteId);
3055
3453
  }
3056
3454
  }
3057
3455
  }
3058
3456
  };
3059
3457
  }
3060
3458
  function createMixpanelIntegration(config) {
3459
+ const category = resolveCategory("analytics", config.category);
3460
+ const token = resolveRequiredString(config.token, "token", "mixpanel");
3461
+ if (!token) {
3462
+ return {
3463
+ id: "mixpanel",
3464
+ category,
3465
+ src: "",
3466
+ cookies: ["mp_*"],
3467
+ cookiesInfo: [
3468
+ {
3469
+ name: "mp_*",
3470
+ purpose: "Rastreamento de eventos e propriedades do usu\xE1rio para analytics",
3471
+ duration: "1 ano",
3472
+ provider: "Mixpanel"
3473
+ }
3474
+ ]
3475
+ };
3476
+ }
3061
3477
  const src = config.scriptUrl ?? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";
3062
3478
  return {
3063
3479
  id: "mixpanel",
3064
- category: "analytics",
3480
+ category,
3065
3481
  src,
3066
3482
  cookies: ["mp_*"],
3067
3483
  cookiesInfo: [
@@ -3073,12 +3489,13 @@ function createMixpanelIntegration(config) {
3073
3489
  }
3074
3490
  ],
3075
3491
  init: () => {
3076
- if (globalThis.window !== void 0) {
3077
- const w = window;
3492
+ const currentWindow = globalThis.window;
3493
+ if (currentWindow !== void 0) {
3494
+ const w = currentWindow;
3078
3495
  w.mixpanel = w.mixpanel || { init: () => void 0 };
3079
3496
  if (w.mixpanel && typeof w.mixpanel.init === "function") {
3080
3497
  try {
3081
- w.mixpanel.init(config.token, config.config ?? {}, config.api_host);
3498
+ w.mixpanel.init(token, config.config ?? {}, config.api_host);
3082
3499
  } catch (error) {
3083
3500
  if (typeof console !== "undefined" && typeof console.warn === "function") {
3084
3501
  console.warn("[Mixpanel] Failed to initialize:", error);
@@ -3090,15 +3507,26 @@ function createMixpanelIntegration(config) {
3090
3507
  };
3091
3508
  }
3092
3509
  function createClarityIntegration(config) {
3093
- const src = config.scriptUrl ?? `https://www.clarity.ms/tag/${config.projectId}`;
3510
+ const category = resolveCategory("analytics", config.category);
3511
+ const projectId = resolveRequiredString(config.projectId, "projectId", "clarity");
3512
+ if (!projectId) {
3513
+ return {
3514
+ id: "clarity",
3515
+ category,
3516
+ src: "",
3517
+ cookies: ["_clck", "_clsk", "CLID", "ANONCHK", "MR", "MUID", "SM"]
3518
+ };
3519
+ }
3520
+ const src = config.scriptUrl ?? `https://www.clarity.ms/tag/${projectId}`;
3094
3521
  return {
3095
3522
  id: "clarity",
3096
- category: "analytics",
3523
+ category,
3097
3524
  src,
3098
3525
  cookies: ["_clck", "_clsk", "CLID", "ANONCHK", "MR", "MUID", "SM"],
3099
3526
  init: () => {
3100
- if (globalThis.window !== void 0 && typeof config.upload !== "undefined") {
3101
- const w = window;
3527
+ const currentWindow = globalThis.window;
3528
+ if (currentWindow !== void 0 && typeof config.upload !== "undefined") {
3529
+ const w = currentWindow;
3102
3530
  if (typeof w.clarity === "function") {
3103
3531
  try {
3104
3532
  w.clarity("set", "upload", config.upload);
@@ -3113,18 +3541,29 @@ function createClarityIntegration(config) {
3113
3541
  };
3114
3542
  }
3115
3543
  function createIntercomIntegration(config) {
3116
- const src = config.scriptUrl ?? `https://widget.intercom.io/widget/${config.app_id}`;
3544
+ const category = resolveCategory("functional", config.category);
3545
+ const appId = resolveRequiredString(config.app_id, "app_id", "intercom");
3546
+ if (!appId) {
3547
+ return {
3548
+ id: "intercom",
3549
+ category,
3550
+ src: "",
3551
+ cookies: ["intercom-id-*", "intercom-session-*"]
3552
+ };
3553
+ }
3554
+ const src = config.scriptUrl ?? `https://widget.intercom.io/widget/${appId}`;
3117
3555
  return {
3118
3556
  id: "intercom",
3119
- category: "functional",
3557
+ category,
3120
3558
  src,
3121
3559
  cookies: ["intercom-id-*", "intercom-session-*"],
3122
3560
  init: () => {
3123
- if (globalThis.window !== void 0) {
3124
- const w = window;
3561
+ const currentWindow = globalThis.window;
3562
+ if (currentWindow !== void 0) {
3563
+ const w = currentWindow;
3125
3564
  if (typeof w.Intercom === "function") {
3126
3565
  try {
3127
- w.Intercom("boot", { app_id: config.app_id });
3566
+ w.Intercom("boot", { app_id: appId });
3128
3567
  } catch (error) {
3129
3568
  if (typeof console !== "undefined" && typeof console.warn === "function") {
3130
3569
  console.warn("[Intercom] Failed to boot:", error);
@@ -3136,18 +3575,29 @@ function createIntercomIntegration(config) {
3136
3575
  };
3137
3576
  }
3138
3577
  function createZendeskChatIntegration(config) {
3139
- const src = config.scriptUrl ?? `https://static.zdassets.com/ekr/snippet.js?key=${config.key}`;
3578
+ const category = resolveCategory("functional", config.category);
3579
+ const key = resolveRequiredString(config.key, "key", "zendesk-chat");
3580
+ if (!key) {
3581
+ return {
3582
+ id: "zendesk-chat",
3583
+ category,
3584
+ src: "",
3585
+ cookies: ["__zlcmid", "_zendesk_shared_session"]
3586
+ };
3587
+ }
3588
+ const src = config.scriptUrl ?? `https://static.zdassets.com/ekr/snippet.js?key=${key}`;
3140
3589
  return {
3141
3590
  id: "zendesk-chat",
3142
- category: "functional",
3591
+ category,
3143
3592
  src,
3144
3593
  cookies: ["__zlcmid", "_zendesk_shared_session"],
3145
3594
  init: () => {
3146
- if (globalThis.window !== void 0) {
3147
- const w = window;
3595
+ const currentWindow = globalThis.window;
3596
+ if (currentWindow !== void 0) {
3597
+ const w = currentWindow;
3148
3598
  if (typeof w.zE === "function") {
3149
3599
  try {
3150
- w.zE("webWidget", "identify", { key: config.key });
3600
+ w.zE("webWidget", "identify", { key });
3151
3601
  } catch (error) {
3152
3602
  if (typeof console !== "undefined" && typeof console.warn === "function") {
3153
3603
  console.warn("[Zendesk] Failed to identify:", error);
@@ -3269,217 +3719,6 @@ function createAnpdCategoriesConfig(options = {}) {
3269
3719
  };
3270
3720
  }
3271
3721
 
3272
- // src/types/advancedTexts.ts
3273
- var EXPANDED_DEFAULT_TEXTS = {
3274
- // Textos adicionais
3275
- confirm: "Confirmar",
3276
- cancel: "Cancelar",
3277
- loading: "Carregando...",
3278
- // Feedback
3279
- feedback: {
3280
- saveSuccess: "Prefer\xEAncias salvas com sucesso!",
3281
- saveError: "Erro ao salvar prefer\xEAncias. Tente novamente.",
3282
- consentUpdated: "Consentimento atualizado.",
3283
- cookiesRejected: "Cookies opcionais rejeitados.",
3284
- settingsReset: "Configura\xE7\xF5es resetadas."
3285
- },
3286
- // Acessibilidade
3287
- accessibility: {
3288
- bannerLabel: "Banner de consentimento de cookies",
3289
- modalLabel: "Modal de prefer\xEAncias de cookies",
3290
- keyboardNavigation: "Use Tab para navegar, Enter para selecionar",
3291
- toggleState: {
3292
- enabled: "Habilitado",
3293
- disabled: "Desabilitado"
3294
- },
3295
- liveRegion: "Regi\xE3o de an\xFAncios din\xE2micos"
3296
- },
3297
- // Categorias
3298
- categories: {
3299
- necessary: {
3300
- name: "Cookies Necess\xE1rios",
3301
- description: "Essenciais para o funcionamento b\xE1sico do site",
3302
- examples: "Sess\xE3o, seguran\xE7a, prefer\xEAncias de idioma"
3303
- },
3304
- analytics: {
3305
- name: "Cookies de Analytics",
3306
- description: "Ajudam a entender como os visitantes usam o site",
3307
- examples: "Google Analytics, contadores de p\xE1gina"
3308
- },
3309
- marketing: {
3310
- name: "Cookies de Marketing",
3311
- description: "Usados para personalizar an\xFAncios e ofertas",
3312
- examples: "Facebook Pixel, Google Ads, remarketing"
3313
- },
3314
- functional: {
3315
- name: "Cookies Funcionais",
3316
- description: "Melhoram a funcionalidade e personaliza\xE7\xE3o",
3317
- examples: "Chat, mapas, v\xEDdeos embarcados"
3318
- },
3319
- performance: {
3320
- name: "Cookies de Performance",
3321
- description: "Coletam informa\xE7\xF5es sobre velocidade e estabilidade",
3322
- examples: "Monitoramento de erro, otimiza\xE7\xE3o de velocidade"
3323
- }
3324
- },
3325
- // Contextos específicos
3326
- contexts: {
3327
- ecommerce: {
3328
- cartAbandonment: "Lembramos dos produtos no seu carrinho",
3329
- personalizedOffers: "Ofertas personalizadas baseadas no seu hist\xF3rico",
3330
- paymentSecurity: "Seguran\xE7a adicional no processo de pagamento",
3331
- productRecommendations: "Sugest\xF5es de produtos relevantes"
3332
- },
3333
- saas: {
3334
- userAnalytics: "An\xE1lise de uso para melhorar funcionalidades",
3335
- performanceMonitoring: "Monitoramento de performance da aplica\xE7\xE3o",
3336
- featureUsage: "Estat\xEDsticas de uso de recursos",
3337
- customerSupport: "Suporte ao cliente mais eficiente"
3338
- },
3339
- government: {
3340
- citizenServices: "Melhoria dos servi\xE7os ao cidad\xE3o",
3341
- dataProtection: "Prote\xE7\xE3o rigorosa dos dados pessoais",
3342
- transparency: "Transpar\xEAncia no uso de dados",
3343
- accessibility: "Recursos de acessibilidade digital"
3344
- },
3345
- education: {
3346
- studentProgress: "Acompanhamento do progresso educacional",
3347
- learningAnalytics: "Analytics para melhorar o aprendizado",
3348
- accessibility: "Recursos educacionais acess\xEDveis",
3349
- parentalConsent: "Consentimento parental quando necess\xE1rio"
3350
- }
3351
- },
3352
- // Variações de tom
3353
- variants: {
3354
- formal: {
3355
- bannerMessage: "Este s\xEDtio eletr\xF4nico utiliza cookies para otimizar a experi\xEAncia de navega\xE7\xE3o.",
3356
- acceptAll: "Concordar com todos os cookies",
3357
- declineAll: "Recusar cookies opcionais",
3358
- modalTitle: "Configura\xE7\xE3o de Cookies"
3359
- },
3360
- casual: {
3361
- bannerMessage: "\u{1F36A} Ei! Usamos cookies para tornar sua experi\xEAncia ainda melhor!",
3362
- acceptAll: "Aceitar tudo",
3363
- declineAll: "S\xF3 o essencial",
3364
- modalTitle: "Seus Cookies"
3365
- },
3366
- concise: {
3367
- bannerMessage: "Usamos cookies. Voc\xEA aceita?",
3368
- acceptAll: "Sim",
3369
- declineAll: "N\xE3o",
3370
- modalTitle: "Cookies"
3371
- },
3372
- detailed: {
3373
- 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.",
3374
- acceptAll: "Aceitar todos os cookies e tecnologias",
3375
- declineAll: "Recusar todos os cookies opcionais",
3376
- modalTitle: "Centro de Prefer\xEAncias de Privacidade"
3377
- }
3378
- },
3379
- // Internacionalização simplificada (apenas textos básicos)
3380
- i18n: {
3381
- en: {
3382
- bannerMessage: "We use cookies to enhance your experience.",
3383
- acceptAll: "Accept All",
3384
- declineAll: "Decline",
3385
- preferences: "Preferences",
3386
- modalTitle: "Cookie Preferences",
3387
- modalIntro: "Customize your cookie preferences below.",
3388
- save: "Save Preferences",
3389
- necessaryAlwaysOn: "Necessary cookies (always active)"
3390
- },
3391
- es: {
3392
- bannerMessage: "Utilizamos cookies para mejorar su experiencia.",
3393
- acceptAll: "Aceptar Todo",
3394
- declineAll: "Rechazar",
3395
- preferences: "Preferencias",
3396
- modalTitle: "Preferencias de Cookies",
3397
- modalIntro: "Personalice sus preferencias de cookies a continuaci\xF3n.",
3398
- save: "Guardar Preferencias",
3399
- necessaryAlwaysOn: "Cookies necess\xE1rias (sempre ativas)"
3400
- },
3401
- fr: {
3402
- bannerMessage: "Nous utilisons des cookies pour am\xE9liorer votre exp\xE9rience.",
3403
- acceptAll: "Tout Accepter",
3404
- declineAll: "Refuser",
3405
- preferences: "Pr\xE9f\xE9rences",
3406
- modalTitle: "Pr\xE9f\xE9rences des Cookies",
3407
- modalIntro: "Personnalisez vos pr\xE9f\xE9rences de cookies ci-dessous.",
3408
- save: "Enregistrer les Pr\xE9f\xE9rences",
3409
- necessaryAlwaysOn: "Cookies n\xE9cessaires (toujours actifs)"
3410
- }
3411
- },
3412
- // Textos técnicos
3413
- technical: {
3414
- sessionCookies: "Cookies de sess\xE3o s\xE3o tempor\xE1rios e expiram quando voc\xEA fecha o navegador.",
3415
- persistentCookies: "Cookies persistentes permanecem no seu dispositivo at\xE9 expirarem ou serem removidos.",
3416
- thirdPartyCookies: "Cookies de terceiros s\xE3o definidos por dom\xEDnios diferentes do site que voc\xEA est\xE1 visitando.",
3417
- browserSettings: "Voc\xEA pode gerenciar cookies nas configura\xE7\xF5es do seu navegador.",
3418
- disablingImpact: "Desabilitar cookies pode afetar a funcionalidade do site."
3419
- },
3420
- // Cookie details
3421
- cookieDetails: {
3422
- tableHeaders: {
3423
- name: "Nome",
3424
- purpose: "Finalidade",
3425
- duration: "Dura\xE7\xE3o",
3426
- provider: "Fornecedor",
3427
- type: "Tipo"
3428
- },
3429
- noCookies: "Nenhum cookie encontrado para esta categoria.",
3430
- toggleDetails: {
3431
- expand: "Ver detalhes",
3432
- collapse: "Ocultar detalhes"
3433
- }
3434
- }
3435
- };
3436
- function resolveTexts(texts, options = {}) {
3437
- const { language = "pt", variant } = options;
3438
- let resolved = { ...texts };
3439
- if (variant && texts.variants?.[variant]) {
3440
- resolved = { ...resolved, ...texts.variants[variant] };
3441
- }
3442
- if (language !== "pt" && texts.i18n?.[language]) {
3443
- resolved = { ...resolved, ...texts.i18n[language] };
3444
- }
3445
- return resolved;
3446
- }
3447
- var TEXT_TEMPLATES = {
3448
- ecommerce: {
3449
- ...EXPANDED_DEFAULT_TEXTS,
3450
- bannerMessage: "Utilizamos cookies para personalizar ofertas e melhorar sua experi\xEAncia de compra.",
3451
- acceptAll: "Aceitar e continuar",
3452
- variants: {
3453
- casual: {
3454
- bannerMessage: "\u{1F6D2} Usamos cookies para encontrar as melhores ofertas para voc\xEA!",
3455
- acceptAll: "Quero ofertas personalizadas!"
3456
- }
3457
- }
3458
- },
3459
- saas: {
3460
- ...EXPANDED_DEFAULT_TEXTS,
3461
- bannerMessage: "Utilizamos cookies para otimizar o desempenho da aplica\xE7\xE3o e sua experi\xEAncia.",
3462
- acceptAll: "Aceitar e otimizar",
3463
- variants: {
3464
- formal: {
3465
- bannerMessage: "Esta aplica\xE7\xE3o utiliza cookies para an\xE1lise de performance e melhoria cont\xEDnua da experi\xEAncia do usu\xE1rio.",
3466
- acceptAll: "Autorizar coleta de dados de uso"
3467
- }
3468
- }
3469
- },
3470
- government: {
3471
- ...EXPANDED_DEFAULT_TEXTS,
3472
- bannerMessage: "Este portal utiliza cookies em conformidade com a LGPD para melhorar os servi\xE7os p\xFAblicos.",
3473
- acceptAll: "Aceitar em conformidade",
3474
- variants: {
3475
- formal: {
3476
- 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.",
3477
- acceptAll: "Concordar com o uso de cookies"
3478
- }
3479
- }
3480
- }
3481
- };
3482
-
3483
3722
  exports.ANPD_CATEGORY_PRESETS = ANPD_CATEGORY_PRESETS;
3484
3723
  exports.COMMON_INTEGRATIONS = COMMON_INTEGRATIONS;
3485
3724
  exports.ConsentGate = ConsentGate;
@@ -3511,6 +3750,7 @@ exports.createIntercomIntegration = createIntercomIntegration;
3511
3750
  exports.createMixpanelIntegration = createMixpanelIntegration;
3512
3751
  exports.createProjectPreferences = createProjectPreferences;
3513
3752
  exports.createSaaSIntegrations = createSaaSIntegrations;
3753
+ exports.createSuggestedIntegration = createSuggestedIntegration;
3514
3754
  exports.createUserWayIntegration = createUserWayIntegration;
3515
3755
  exports.createZendeskChatIntegration = createZendeskChatIntegration;
3516
3756
  exports.defaultTexts = defaultTexts;