@redacto.io/consent-sdk-react 10.3.1 → 11.0.0-beta.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
@@ -3,8 +3,13 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res) => function __init() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ var __esm = (fn, res, err) => function __init() {
7
+ if (err) throw err[0];
8
+ try {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ } catch (e) {
11
+ throw err = [e], e;
12
+ }
8
13
  };
9
14
  var __export = (target, all) => {
10
15
  for (var name in all)
@@ -88,7 +93,7 @@ __export(src_exports, {
88
93
  module.exports = __toCommonJS(src_exports);
89
94
 
90
95
  // src/RedactoNoticeConsent/RedactoNoticeConsent.tsx
91
- var import_react8 = require("react");
96
+ var import_react9 = require("react");
92
97
 
93
98
  // src/RedactoNoticeConsent/api/index.ts
94
99
  var import_jwt_decode2 = require("jwt-decode");
@@ -1297,6 +1302,96 @@ var noticeChromeCopy = (language) => {
1297
1302
  };
1298
1303
  var NOTICE_CHROME_LANGUAGES = Object.keys(TRANSLATIONS);
1299
1304
 
1305
+ // src/shared/appearance/constants.ts
1306
+ var NOTICE_COLOR_KEYS = [
1307
+ "background",
1308
+ "surface",
1309
+ "heading",
1310
+ "text",
1311
+ "muted_text",
1312
+ "link",
1313
+ "border",
1314
+ "overlay",
1315
+ "accept_all_bg",
1316
+ "accept_all_text",
1317
+ "accept_bg",
1318
+ "accept_text",
1319
+ "decline_bg",
1320
+ "decline_text",
1321
+ "decline_border",
1322
+ "language_bg",
1323
+ "language_text",
1324
+ "language_selected_bg",
1325
+ "language_selected_text",
1326
+ "toggle_on",
1327
+ "toggle_off",
1328
+ "toggle_knob",
1329
+ "tts_highlight_bg",
1330
+ "tts_highlight_text"
1331
+ ];
1332
+ var NOTICE_SELECTION_CONTROLS = ["checkbox", "radio", "dropdown"];
1333
+ var NOTICE_CONTROL_STYLES = ["checkbox", "switch"];
1334
+ var NOTICE_RADIUS_MIN = 0;
1335
+ var NOTICE_RADIUS_MAX = 28;
1336
+ var NOTICE_MOBILE_LAYOUTS = ["modal", "sheet"];
1337
+ var NOTICE_DESKTOP_POSITIONS = [
1338
+ "center",
1339
+ "bottom-right",
1340
+ "bottom-left",
1341
+ "bottom-bar"
1342
+ ];
1343
+ var NOTICE_BACKDROPS = ["dim", "none"];
1344
+ var NOTICE_PHONE_FOOTERS = ["stacked", "paired"];
1345
+ var NOTICE_TEXT_SCALES = ["sm", "md", "lg"];
1346
+ var DEFAULT_TEXT_SCALE = "md";
1347
+ var DEFAULT_DESKTOP_POSITION = "center";
1348
+ var NOTICE_TEXT_SCALE_FACTORS = {
1349
+ sm: 0.92,
1350
+ md: 1,
1351
+ lg: 1.1
1352
+ };
1353
+ var NOTICE_WIDTH_MIN = 320;
1354
+ var NOTICE_WIDTH_MAX = 960;
1355
+ var NOTICE_LOGO_SIZE_MIN = 16;
1356
+ var NOTICE_LOGO_SIZE_MAX = 96;
1357
+ var NOTICE_CUSTOM_CSS_MAX_LENGTH = 2e4;
1358
+ var NOTICE_DISALLOWED_CSS_TOKENS = [
1359
+ "</style",
1360
+ "@import",
1361
+ "javascript:",
1362
+ "expression(",
1363
+ "behavior:"
1364
+ ];
1365
+ var CSS_SCOPE_AT_RULE = "@scope";
1366
+ var CSS_STRING_SPECIALS_RE = /["\\\n]/g;
1367
+ var CSS_ESCAPE_RE = /\\([0-9a-f]{1,6})(?:\r\n|[ \t\r\n\f])?|\\([\s\S])/gi;
1368
+ var CSS_BRACKET_PAIRS = {
1369
+ "{": "}",
1370
+ "(": ")",
1371
+ "[": "]"
1372
+ };
1373
+ var CSS_CLOSING_BRACKETS = Object.values(CSS_BRACKET_PAIRS);
1374
+ var CSS_QUOTES = ['"', "'"];
1375
+ var CSS_NEWLINES = ["\n", "\r", "\f"];
1376
+ var CSS_REPLACEMENT_CHARACTER = "\uFFFD";
1377
+ var MAX_CODE_POINT = 1114111;
1378
+ var HEX_RADIX = 16;
1379
+ var SURROGATE_MIN = 55296;
1380
+ var SURROGATE_MAX = 57343;
1381
+ var NOTICE_HEX_COLOR_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
1382
+ var DEFAULT_TTS_HIGHLIGHT_BG = "#FFF9C4";
1383
+ var NOTICE_THEME_VARS = {
1384
+ accent: "--redacto-accent",
1385
+ controlOff: "--redacto-control-off",
1386
+ knob: "--redacto-toggle-knob",
1387
+ ttsBackground: "--redacto-tts-bg",
1388
+ ttsText: "--redacto-tts-text"
1389
+ };
1390
+ var THEMED_ACCENT = `var(${NOTICE_THEME_VARS.accent}, #4f87ff)`;
1391
+ var THEMED_CONTROL_OFF = `var(${NOTICE_THEME_VARS.controlOff}, #d0d5dd)`;
1392
+ var THEMED_TTS_BACKGROUND = `var(${NOTICE_THEME_VARS.ttsBackground}, ${DEFAULT_TTS_HIGHLIGHT_BG})`;
1393
+ var TTS_TEXT_ATTRIBUTE = "data-redacto-tts-text";
1394
+
1300
1395
  // src/RedactoNoticeConsent/constants.ts
1301
1396
  var DEFAULT_LOGO_POSITION = "left";
1302
1397
  var DEFAULT_PURPOSE_SECTION_HEADING = "Manage What You Share";
@@ -1414,8 +1509,6 @@ var MOTION_ATTRIBUTE = "data-redacto-motion";
1414
1509
  var MOTION_OFF = "off";
1415
1510
  var NOTICE_ID_ATTRIBUTE = "data-redacto-notice-id";
1416
1511
  var CUSTOM_CSS_ATTRIBUTE = "data-redacto-notice-css";
1417
- var CSS_SCOPE_AT_RULE = "@scope";
1418
- var CSS_STRING_SPECIALS_RE = /["\\\n]/g;
1419
1512
  var PX_LENGTH_RE = /^(\d+(?:\.\d+)?)px$/;
1420
1513
  var FONT_SIZE_PRECISION = 10;
1421
1514
  var DARK_SCHEME_QUERY = "(prefers-color-scheme: dark)";
@@ -2153,94 +2246,6 @@ var NoticeFooter = ({
2153
2246
  ] });
2154
2247
  };
2155
2248
 
2156
- // src/shared/appearance/constants.ts
2157
- var NOTICE_COLOR_KEYS = [
2158
- "background",
2159
- "surface",
2160
- "heading",
2161
- "text",
2162
- "muted_text",
2163
- "link",
2164
- "border",
2165
- "overlay",
2166
- "accept_all_bg",
2167
- "accept_all_text",
2168
- "accept_bg",
2169
- "accept_text",
2170
- "decline_bg",
2171
- "decline_text",
2172
- "decline_border",
2173
- "language_bg",
2174
- "language_text",
2175
- "language_selected_bg",
2176
- "language_selected_text",
2177
- "toggle_on",
2178
- "toggle_off",
2179
- "toggle_knob",
2180
- "tts_highlight_bg",
2181
- "tts_highlight_text"
2182
- ];
2183
- var NOTICE_SELECTION_CONTROLS = ["checkbox", "radio", "dropdown"];
2184
- var NOTICE_CONTROL_STYLES = ["checkbox", "switch"];
2185
- var NOTICE_RADIUS_MIN = 0;
2186
- var NOTICE_RADIUS_MAX = 28;
2187
- var NOTICE_MOBILE_LAYOUTS = ["modal", "sheet"];
2188
- var NOTICE_DESKTOP_POSITIONS = [
2189
- "center",
2190
- "bottom-right",
2191
- "bottom-left",
2192
- "bottom-bar"
2193
- ];
2194
- var NOTICE_BACKDROPS = ["dim", "none"];
2195
- var NOTICE_PHONE_FOOTERS = ["stacked", "paired"];
2196
- var NOTICE_TEXT_SCALES = ["sm", "md", "lg"];
2197
- var DEFAULT_TEXT_SCALE = "md";
2198
- var DEFAULT_DESKTOP_POSITION = "center";
2199
- var NOTICE_TEXT_SCALE_FACTORS = {
2200
- sm: 0.92,
2201
- md: 1,
2202
- lg: 1.1
2203
- };
2204
- var NOTICE_WIDTH_MIN = 320;
2205
- var NOTICE_WIDTH_MAX = 960;
2206
- var NOTICE_LOGO_SIZE_MIN = 16;
2207
- var NOTICE_LOGO_SIZE_MAX = 96;
2208
- var NOTICE_CUSTOM_CSS_MAX_LENGTH = 2e4;
2209
- var NOTICE_DISALLOWED_CSS_TOKENS = [
2210
- "</style",
2211
- "@import",
2212
- "javascript:",
2213
- "expression(",
2214
- "behavior:"
2215
- ];
2216
- var CSS_ESCAPE_RE = /\\([0-9a-f]{1,6})(?:\r\n|[ \t\r\n\f])?|\\([\s\S])/gi;
2217
- var CSS_BRACKET_PAIRS = {
2218
- "{": "}",
2219
- "(": ")",
2220
- "[": "]"
2221
- };
2222
- var CSS_CLOSING_BRACKETS = Object.values(CSS_BRACKET_PAIRS);
2223
- var CSS_QUOTES = ['"', "'"];
2224
- var CSS_NEWLINES = ["\n", "\r", "\f"];
2225
- var CSS_REPLACEMENT_CHARACTER = "\uFFFD";
2226
- var MAX_CODE_POINT = 1114111;
2227
- var HEX_RADIX = 16;
2228
- var SURROGATE_MIN = 55296;
2229
- var SURROGATE_MAX = 57343;
2230
- var NOTICE_HEX_COLOR_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
2231
- var DEFAULT_TTS_HIGHLIGHT_BG = "#FFF9C4";
2232
- var NOTICE_THEME_VARS = {
2233
- accent: "--redacto-accent",
2234
- controlOff: "--redacto-control-off",
2235
- knob: "--redacto-toggle-knob",
2236
- ttsBackground: "--redacto-tts-bg",
2237
- ttsText: "--redacto-tts-text"
2238
- };
2239
- var THEMED_ACCENT = `var(${NOTICE_THEME_VARS.accent}, #4f87ff)`;
2240
- var THEMED_CONTROL_OFF = `var(${NOTICE_THEME_VARS.controlOff}, #d0d5dd)`;
2241
- var THEMED_TTS_BACKGROUND = `var(${NOTICE_THEME_VARS.ttsBackground}, ${DEFAULT_TTS_HIGHLIGHT_BG})`;
2242
- var TTS_TEXT_ATTRIBUTE = "data-redacto-tts-text";
2243
-
2244
2249
  // src/shared/appearance/ttsCssVariables.ts
2245
2250
  var buildTtsCssVariables = (colors) => Object.fromEntries(
2246
2251
  [
@@ -4884,21 +4889,26 @@ var showsNoticePolicyLink = (productCount, entryCount) => entryCount === 0 || pr
4884
4889
  // src/RedactoNoticeConsent/useNoticeAppearance.ts
4885
4890
  var import_react7 = require("react");
4886
4891
 
4887
- // src/RedactoNoticeConsent/services/customCss.ts
4892
+ // src/shared/appearance/scopedCss.ts
4888
4893
  var escapesScope = (style) => {
4889
4894
  var _a, _b;
4890
4895
  return Array.from((_b = (_a = style.sheet) == null ? void 0 : _a.cssRules) != null ? _b : []).some(
4891
4896
  (rule) => !rule.cssText.startsWith(CSS_SCOPE_AT_RULE)
4892
4897
  );
4893
4898
  };
4894
- var applyNoticeCustomCss = (noticeId, css3) => {
4895
- if (typeof document === "undefined") {
4899
+ var applyScopedCustomCss = ({
4900
+ scopeAttribute,
4901
+ scopeId,
4902
+ markerAttribute,
4903
+ css: css3
4904
+ }) => {
4905
+ if (typeof document === "undefined" || !css3.trim() || !isSafeCustomCss(css3)) {
4896
4906
  return () => void 0;
4897
4907
  }
4898
- const id = noticeId.replace(CSS_STRING_SPECIALS_RE, "\\$&");
4908
+ const id = scopeId.replace(CSS_STRING_SPECIALS_RE, "\\$&");
4899
4909
  const style = document.createElement("style");
4900
- style.setAttribute(CUSTOM_CSS_ATTRIBUTE, noticeId);
4901
- style.textContent = `${CSS_SCOPE_AT_RULE} ([${NOTICE_ID_ATTRIBUTE}="${id}"]) {
4910
+ style.setAttribute(markerAttribute, scopeId);
4911
+ style.textContent = `${CSS_SCOPE_AT_RULE} ([${scopeAttribute}="${id}"]) {
4902
4912
  ${css3}
4903
4913
  }`;
4904
4914
  document.head.appendChild(style);
@@ -4909,6 +4919,14 @@ ${css3}
4909
4919
  return () => style.remove();
4910
4920
  };
4911
4921
 
4922
+ // src/RedactoNoticeConsent/services/customCss.ts
4923
+ var applyNoticeCustomCss = (noticeId, css3) => applyScopedCustomCss({
4924
+ scopeAttribute: NOTICE_ID_ATTRIBUTE,
4925
+ scopeId: noticeId,
4926
+ markerAttribute: CUSTOM_CSS_ATTRIBUTE,
4927
+ css: css3
4928
+ });
4929
+
4912
4930
  // src/RedactoNoticeConsent/utils/mergeHostSettings.ts
4913
4931
  var definedColors = (colors) => Object.fromEntries(
4914
4932
  Object.entries(colors).filter(([, value]) => Boolean(value))
@@ -5065,6 +5083,65 @@ var updateConsentState = (updates) => {
5065
5083
  }
5066
5084
  };
5067
5085
 
5086
+ // src/shared/useResolvedEndpoints.ts
5087
+ var import_react8 = require("react");
5088
+
5089
+ // src/shared/endpoints.ts
5090
+ var CONSENT_PATH = "/consent";
5091
+ var LEDGER_PATH = "/consent-ledger";
5092
+ var ABSOLUTE_HTTP_URL = /^https?:\/\/(?:\[[0-9a-f:.]+\]|[^\s/?#@:[\]]+)(?::\d+)?(?:\/[^\s?#]*)?$/i;
5093
+ var trimUrl = (value) => (value != null ? value : "").trim().replace(/\/+$/, "");
5094
+ var isConsentServerUrl = (trimmed) => ABSOLUTE_HTTP_URL.test(trimmed) && trimmed.endsWith(CONSENT_PATH);
5095
+ var isHostForm = (trimmed) => ABSOLUTE_HTTP_URL.test(trimmed) && !trimmed.endsWith(CONSENT_PATH);
5096
+ function resolveEndpoints(baseUrl, ledgerBaseUrl) {
5097
+ const trimmed = trimUrl(baseUrl);
5098
+ if (!isHostForm(trimmed)) {
5099
+ return { mode: "legacy", apiHost: void 0, baseUrl, ledgerBaseUrl };
5100
+ }
5101
+ const apiHost = trimmed.endsWith(LEDGER_PATH) ? trimmed.slice(0, -LEDGER_PATH.length) : trimmed;
5102
+ return {
5103
+ mode: "host",
5104
+ apiHost,
5105
+ baseUrl: `${apiHost}${CONSENT_PATH}`,
5106
+ ledgerBaseUrl: `${apiHost}${LEDGER_PATH}`
5107
+ };
5108
+ }
5109
+ var ENDPOINT_WARNINGS = {
5110
+ missingBaseUrl: "[Redacto] baseUrl is not set, so the SDK's built-in production default is used. Pass baseUrl: your API host.",
5111
+ consentServerBaseUrl: "[Redacto] baseUrl is the consent server URL (ending in /consent), which is deprecated. Pass the API host instead; the SDK derives the consent server and ledger URLs from it.",
5112
+ ledgerBaseUrl: "[Redacto] ledgerBaseUrl is deprecated. Pass the Redacto API host as baseUrl instead; the SDK then reaches the consent server and the ledger under it.",
5113
+ ledgerBaseUrlIgnored: "[Redacto] ledgerBaseUrl is ignored because baseUrl is the API host; the SDK reaches the ledger under that host. Remove ledgerBaseUrl.",
5114
+ slugIgnored: "[Redacto] slug is deprecated and ignored. The Privacy Center reads the organisation from the access token, or from organisationUuid and workspaceUuid. Remove slug."
5115
+ };
5116
+ var issuedWarnings = /* @__PURE__ */ new Set();
5117
+ var warnOnce = (warning) => {
5118
+ if (issuedWarnings.has(warning)) {
5119
+ return;
5120
+ }
5121
+ issuedWarnings.add(warning);
5122
+ console.warn(ENDPOINT_WARNINGS[warning]);
5123
+ };
5124
+ var warnEndpointUsage = (baseUrl, ledgerBaseUrl, { hasBuiltInDefault }) => {
5125
+ if (!baseUrl) {
5126
+ if (hasBuiltInDefault) {
5127
+ warnOnce("missingBaseUrl");
5128
+ }
5129
+ } else if (isConsentServerUrl(trimUrl(baseUrl))) {
5130
+ warnOnce("consentServerBaseUrl");
5131
+ }
5132
+ if (trimUrl(ledgerBaseUrl)) {
5133
+ warnOnce(isHostForm(trimUrl(baseUrl)) ? "ledgerBaseUrlIgnored" : "ledgerBaseUrl");
5134
+ }
5135
+ };
5136
+
5137
+ // src/shared/useResolvedEndpoints.ts
5138
+ var useResolvedEndpoints = (baseUrl, ledgerBaseUrl, { warn = true, hasBuiltInDefault = true } = {}) => (0, import_react8.useMemo)(() => {
5139
+ if (warn) {
5140
+ warnEndpointUsage(baseUrl, ledgerBaseUrl, { hasBuiltInDefault });
5141
+ }
5142
+ return resolveEndpoints(baseUrl, ledgerBaseUrl);
5143
+ }, [baseUrl, ledgerBaseUrl, warn, hasBuiltInDefault]);
5144
+
5068
5145
  // src/RedactoNoticeConsent/RedactoNoticeConsent.tsx
5069
5146
  var import_jsx_runtime7 = require("react/jsx-runtime");
5070
5147
  var DEFAULT_HEADING_COLOR = "#323B4B";
@@ -5220,7 +5297,7 @@ var PurposeItem = ({
5220
5297
  }) => {
5221
5298
  var _a, _b;
5222
5299
  const stateKey = productPurposeKey(productUuid, purpose.uuid);
5223
- const handlePurposeToggle = (0, import_react8.useCallback)(
5300
+ const handlePurposeToggle = (0, import_react9.useCallback)(
5224
5301
  () => onPurposeToggle(purpose.uuid, productUuid),
5225
5302
  [onPurposeToggle, purpose.uuid, productUuid]
5226
5303
  );
@@ -5229,13 +5306,13 @@ var PurposeItem = ({
5229
5306
  purpose.name,
5230
5307
  purpose.uuid
5231
5308
  )}`;
5232
- const headingStyle = (0, import_react8.useMemo)(
5309
+ const headingStyle = (0, import_react9.useMemo)(
5233
5310
  () => ({
5234
5311
  color: (settings == null ? void 0 : settings.headingColor) || DEFAULT_HEADING_COLOR
5235
5312
  }),
5236
5313
  [settings == null ? void 0 : settings.headingColor]
5237
5314
  );
5238
- const textStyle = (0, import_react8.useMemo)(
5315
+ const textStyle = (0, import_react9.useMemo)(
5239
5316
  () => ({
5240
5317
  color: (settings == null ? void 0 : settings.textColor) || "#344054"
5241
5318
  }),
@@ -5481,12 +5558,12 @@ var GuardianForm = ({
5481
5558
  logoUrl
5482
5559
  }) => {
5483
5560
  var _a, _b, _c, _d, _e;
5484
- const [isDropdownOpen, setIsDropdownOpen] = (0, import_react8.useState)(false);
5485
- const [focusedIndex, setFocusedIndex] = (0, import_react8.useState)(-1);
5486
- const [openUpward, setOpenUpward] = (0, import_react8.useState)(false);
5487
- const dropdownRef = (0, import_react8.useRef)(null);
5488
- const optionsRef = (0, import_react8.useRef)(null);
5489
- (0, import_react8.useEffect)(() => {
5561
+ const [isDropdownOpen, setIsDropdownOpen] = (0, import_react9.useState)(false);
5562
+ const [focusedIndex, setFocusedIndex] = (0, import_react9.useState)(-1);
5563
+ const [openUpward, setOpenUpward] = (0, import_react9.useState)(false);
5564
+ const dropdownRef = (0, import_react9.useRef)(null);
5565
+ const optionsRef = (0, import_react9.useRef)(null);
5566
+ (0, import_react9.useEffect)(() => {
5490
5567
  if (!isDropdownOpen) return;
5491
5568
  const handleClickOutside = (e) => {
5492
5569
  if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
@@ -5497,7 +5574,7 @@ var GuardianForm = ({
5497
5574
  document.addEventListener("mousedown", handleClickOutside);
5498
5575
  return () => document.removeEventListener("mousedown", handleClickOutside);
5499
5576
  }, [isDropdownOpen]);
5500
- (0, import_react8.useEffect)(() => {
5577
+ (0, import_react9.useEffect)(() => {
5501
5578
  if (!isDropdownOpen || !dropdownRef.current) return;
5502
5579
  const rect = dropdownRef.current.getBoundingClientRect();
5503
5580
  const spaceBelow = window.innerHeight - rect.bottom;
@@ -5542,7 +5619,7 @@ var GuardianForm = ({
5542
5619
  break;
5543
5620
  }
5544
5621
  };
5545
- (0, import_react8.useEffect)(() => {
5622
+ (0, import_react9.useEffect)(() => {
5546
5623
  var _a2;
5547
5624
  if (focusedIndex >= 0 && optionsRef.current) {
5548
5625
  const option = optionsRef.current.children[focusedIndex];
@@ -6351,8 +6428,8 @@ var NoticeConsentView = ({
6351
6428
  ucic,
6352
6429
  organisationUuid,
6353
6430
  workspaceUuid,
6354
- baseUrl,
6355
- ledgerBaseUrl,
6431
+ baseUrl: baseUrlProp,
6432
+ ledgerBaseUrl: ledgerBaseUrlProp,
6356
6433
  language = "en",
6357
6434
  blockUI = true,
6358
6435
  onAccept,
@@ -6374,7 +6451,11 @@ var NoticeConsentView = ({
6374
6451
  forceColorScheme
6375
6452
  }) => {
6376
6453
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
6377
- const sandboxParams = (0, import_react8.useMemo)(
6454
+ const endpoints = useResolvedEndpoints(baseUrlProp, ledgerBaseUrlProp, {
6455
+ warn: !previewContent
6456
+ });
6457
+ const { baseUrl, ledgerBaseUrl } = endpoints;
6458
+ const sandboxParams = (0, import_react9.useMemo)(
6378
6459
  () => ({
6379
6460
  token,
6380
6461
  sandboxUcic: ucic,
@@ -6385,7 +6466,7 @@ var NoticeConsentView = ({
6385
6466
  }),
6386
6467
  [token, ucic, email, mobile, organisationUuid, workspaceUuid]
6387
6468
  );
6388
- const propValidationError = (0, import_react8.useMemo)(() => {
6469
+ const propValidationError = (0, import_react9.useMemo)(() => {
6389
6470
  if (previewContent) {
6390
6471
  return null;
6391
6472
  }
@@ -6435,12 +6516,12 @@ var NoticeConsentView = ({
6435
6516
  }
6436
6517
  );
6437
6518
  }
6438
- const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
6439
- const [isSubmitting, setIsSubmitting] = (0, import_react8.useState)(false);
6440
- const [isSubmittingAccept, setIsSubmittingAccept] = (0, import_react8.useState)(false);
6441
- const [isSubmittingDecline, setIsSubmittingDecline] = (0, import_react8.useState)(false);
6442
- const [content, setContent] = (0, import_react8.useState)(null);
6443
- const [cachedAppearance, setCachedAppearance] = (0, import_react8.useState)(void 0);
6519
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(true);
6520
+ const [isSubmitting, setIsSubmitting] = (0, import_react9.useState)(false);
6521
+ const [isSubmittingAccept, setIsSubmittingAccept] = (0, import_react9.useState)(false);
6522
+ const [isSubmittingDecline, setIsSubmittingDecline] = (0, import_react9.useState)(false);
6523
+ const [content, setContent] = (0, import_react9.useState)(null);
6524
+ const [cachedAppearance, setCachedAppearance] = (0, import_react9.useState)(void 0);
6444
6525
  useIsomorphicLayoutEffect(() => {
6445
6526
  setCachedAppearance(readCachedAppearance(noticeId));
6446
6527
  }, [noticeId]);
@@ -6450,101 +6531,101 @@ var NoticeConsentView = ({
6450
6531
  settings,
6451
6532
  forceColorScheme
6452
6533
  );
6453
- (0, import_react8.useEffect)(() => {
6534
+ (0, import_react9.useEffect)(() => {
6454
6535
  if (content && !previewContent) {
6455
6536
  writeCachedAppearance(content.notice_uuid, content.appearance);
6456
6537
  }
6457
6538
  }, [content, previewContent]);
6458
- const noticeSettings = (0, import_react8.useMemo)(
6539
+ const noticeSettings = (0, import_react9.useMemo)(
6459
6540
  () => toNoticeStyleSettings(noticeAppearance),
6460
6541
  [noticeAppearance]
6461
6542
  );
6462
- const [categorizedPurposes, setCategorizedPurposes] = (0, import_react8.useState)(null);
6463
- const [selectedPurposes, setSelectedPurposes] = (0, import_react8.useState)({});
6464
- const [selectedDataElements, setSelectedDataElements] = (0, import_react8.useState)({});
6465
- const [initialDataElementSelections, setInitialDataElementSelections] = (0, import_react8.useState)({});
6466
- const [recordedPurposeSelections, setRecordedPurposeSelections] = (0, import_react8.useState)({});
6467
- const [recordedAnswers, setRecordedAnswers] = (0, import_react8.useState)({});
6468
- const [collapsedProducts, setCollapsedProducts] = (0, import_react8.useState)({});
6469
- const [pendingAction, setPendingAction] = (0, import_react8.useState)(null);
6470
- const pendingActionRef = (0, import_react8.useRef)(null);
6543
+ const [categorizedPurposes, setCategorizedPurposes] = (0, import_react9.useState)(null);
6544
+ const [selectedPurposes, setSelectedPurposes] = (0, import_react9.useState)({});
6545
+ const [selectedDataElements, setSelectedDataElements] = (0, import_react9.useState)({});
6546
+ const [initialDataElementSelections, setInitialDataElementSelections] = (0, import_react9.useState)({});
6547
+ const [recordedPurposeSelections, setRecordedPurposeSelections] = (0, import_react9.useState)({});
6548
+ const [recordedAnswers, setRecordedAnswers] = (0, import_react9.useState)({});
6549
+ const [collapsedProducts, setCollapsedProducts] = (0, import_react9.useState)({});
6550
+ const [pendingAction, setPendingAction] = (0, import_react9.useState)(null);
6551
+ const pendingActionRef = (0, import_react9.useRef)(null);
6471
6552
  pendingActionRef.current = pendingAction;
6472
- const [confirmAction, setConfirmAction] = (0, import_react8.useState)("accept-selected");
6473
- const [collapsedPurposes, setCollapsedPurposes] = (0, import_react8.useState)({});
6474
- const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react8.useState)(false);
6475
- const [consentedProducts, setConsentedProducts] = (0, import_react8.useState)({});
6476
- const [consentedPurposes, setConsentedPurposes] = (0, import_react8.useState)({});
6477
- const [isFullyConsentedReviewMode, setIsFullyConsentedReviewMode] = (0, import_react8.useState)(false);
6478
- const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react8.useState)(false);
6479
- const [selectedLanguage, setSelectedLanguage] = (0, import_react8.useState)(language);
6480
- const chrome = (0, import_react8.useMemo)(
6553
+ const [confirmAction, setConfirmAction] = (0, import_react9.useState)("accept-selected");
6554
+ const [collapsedPurposes, setCollapsedPurposes] = (0, import_react9.useState)({});
6555
+ const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react9.useState)(false);
6556
+ const [consentedProducts, setConsentedProducts] = (0, import_react9.useState)({});
6557
+ const [consentedPurposes, setConsentedPurposes] = (0, import_react9.useState)({});
6558
+ const [isFullyConsentedReviewMode, setIsFullyConsentedReviewMode] = (0, import_react9.useState)(false);
6559
+ const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react9.useState)(false);
6560
+ const [selectedLanguage, setSelectedLanguage] = (0, import_react9.useState)(language);
6561
+ const chrome = (0, import_react9.useMemo)(
6481
6562
  () => noticeChromeCopy(selectedLanguage),
6482
6563
  [selectedLanguage]
6483
6564
  );
6484
- const [errorMessage, setErrorMessage] = (0, import_react8.useState)(null);
6485
- const [fetchError, setFetchError] = (0, import_react8.useState)(null);
6486
- const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react8.useState)(null);
6487
- const [isTTSAvailable, setIsTTSAvailable] = (0, import_react8.useState)(false);
6488
- const [isPlaying, setIsPlaying] = (0, import_react8.useState)(false);
6489
- const [isPaused, setIsPaused] = (0, import_react8.useState)(false);
6490
- const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react8.useState)(0);
6491
- const [highlightedElementId, setHighlightedElementId] = (0, import_react8.useState)(null);
6492
- const [showAgeVerification, setShowAgeVerification] = (0, import_react8.useState)(false);
6493
- const [isMinorFlow, setIsMinorFlow] = (0, import_react8.useState)(false);
6494
- const [selfDeclaredAdult, setSelfDeclaredAdult] = (0, import_react8.useState)(false);
6495
- const [showGuardianForm, setShowGuardianForm] = (0, import_react8.useState)(false);
6496
- const [isSubmittingGuardian, setIsSubmittingGuardian] = (0, import_react8.useState)(false);
6497
- const [otpPendingMode, setOtpPendingMode] = (0, import_react8.useState)(null);
6498
- const preGateSelectionRef = (0, import_react8.useRef)(null);
6499
- const otpVerifiedRef = (0, import_react8.useRef)(false);
6500
- const otpTokenAtVerifyRef = (0, import_react8.useRef)(void 0);
6501
- const [otpAcceptAfterToken, setOtpAcceptAfterToken] = (0, import_react8.useState)(null);
6502
- const [otpCode, setOtpCode] = (0, import_react8.useState)("");
6503
- const [otpError, setOtpError] = (0, import_react8.useState)(null);
6504
- const [otpBusy, setOtpBusy] = (0, import_react8.useState)(false);
6565
+ const [errorMessage, setErrorMessage] = (0, import_react9.useState)(null);
6566
+ const [fetchError, setFetchError] = (0, import_react9.useState)(null);
6567
+ const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react9.useState)(null);
6568
+ const [isTTSAvailable, setIsTTSAvailable] = (0, import_react9.useState)(false);
6569
+ const [isPlaying, setIsPlaying] = (0, import_react9.useState)(false);
6570
+ const [isPaused, setIsPaused] = (0, import_react9.useState)(false);
6571
+ const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react9.useState)(0);
6572
+ const [highlightedElementId, setHighlightedElementId] = (0, import_react9.useState)(null);
6573
+ const [showAgeVerification, setShowAgeVerification] = (0, import_react9.useState)(false);
6574
+ const [isMinorFlow, setIsMinorFlow] = (0, import_react9.useState)(false);
6575
+ const [selfDeclaredAdult, setSelfDeclaredAdult] = (0, import_react9.useState)(false);
6576
+ const [showGuardianForm, setShowGuardianForm] = (0, import_react9.useState)(false);
6577
+ const [isSubmittingGuardian, setIsSubmittingGuardian] = (0, import_react9.useState)(false);
6578
+ const [otpPendingMode, setOtpPendingMode] = (0, import_react9.useState)(null);
6579
+ const preGateSelectionRef = (0, import_react9.useRef)(null);
6580
+ const otpVerifiedRef = (0, import_react9.useRef)(false);
6581
+ const otpTokenAtVerifyRef = (0, import_react9.useRef)(void 0);
6582
+ const [otpAcceptAfterToken, setOtpAcceptAfterToken] = (0, import_react9.useState)(null);
6583
+ const [otpCode, setOtpCode] = (0, import_react9.useState)("");
6584
+ const [otpError, setOtpError] = (0, import_react9.useState)(null);
6585
+ const [otpBusy, setOtpBusy] = (0, import_react9.useState)(false);
6505
6586
  const otpLocked = otpPendingMode !== null;
6506
6587
  const focusOtpDigit = (index) => {
6507
6588
  var _a2;
6508
6589
  if (index < 0 || index >= OTP_GATE_LENGTH) return;
6509
6590
  (_a2 = document.getElementById(`notice-otp-digit-${index}`)) == null ? void 0 : _a2.focus();
6510
6591
  };
6511
- const [guardianFormData, setGuardianFormData] = (0, import_react8.useState)({
6592
+ const [guardianFormData, setGuardianFormData] = (0, import_react9.useState)({
6512
6593
  guardianName: "",
6513
6594
  guardianContact: "",
6514
6595
  guardianRelationship: ""
6515
6596
  });
6516
- const [guardianFormErrors, setGuardianFormErrors] = (0, import_react8.useState)({});
6517
- const [showVerificationScreen, setShowVerificationScreen] = (0, import_react8.useState)(false);
6518
- const [verificationReference, setVerificationReference] = (0, import_react8.useState)(null);
6519
- const [isInitiatingVerification, setIsInitiatingVerification] = (0, import_react8.useState)(false);
6520
- const [verificationError, setVerificationError] = (0, import_react8.useState)(
6597
+ const [guardianFormErrors, setGuardianFormErrors] = (0, import_react9.useState)({});
6598
+ const [showVerificationScreen, setShowVerificationScreen] = (0, import_react9.useState)(false);
6599
+ const [verificationReference, setVerificationReference] = (0, import_react9.useState)(null);
6600
+ const [isInitiatingVerification, setIsInitiatingVerification] = (0, import_react9.useState)(false);
6601
+ const [verificationError, setVerificationError] = (0, import_react9.useState)(
6521
6602
  null
6522
6603
  );
6523
- const [verificationErrorCode, setVerificationErrorCode] = (0, import_react8.useState)(null);
6524
- const [canRetryVerification, setCanRetryVerification] = (0, import_react8.useState)(false);
6525
- const [isPollingStatus, setIsPollingStatus] = (0, import_react8.useState)(false);
6526
- const [isVerificationComplete, setIsVerificationComplete] = (0, import_react8.useState)(false);
6527
- const [isAutoTransitioning, setIsAutoTransitioning] = (0, import_react8.useState)(false);
6528
- const modalRef = (0, import_react8.useRef)(null);
6529
- const firstFocusableRef = (0, import_react8.useRef)(null);
6530
- const lastFocusableRef = (0, import_react8.useRef)(null);
6531
- const abortControllerRef = (0, import_react8.useRef)(null);
6532
- const isRequestInProgressRef = (0, import_react8.useRef)(false);
6533
- const currentAudioRef = (0, import_react8.useRef)(null);
6534
- const popupCheckIntervalRef = (0, import_react8.useRef)(null);
6535
- const statusPollIntervalRef = (0, import_react8.useRef)(null);
6536
- const verificationPopupRef = (0, import_react8.useRef)(null);
6537
- const pollingCleanupRef = (0, import_react8.useRef)(null);
6538
- const autoTransitionTimerRef = (0, import_react8.useRef)(
6604
+ const [verificationErrorCode, setVerificationErrorCode] = (0, import_react9.useState)(null);
6605
+ const [canRetryVerification, setCanRetryVerification] = (0, import_react9.useState)(false);
6606
+ const [isPollingStatus, setIsPollingStatus] = (0, import_react9.useState)(false);
6607
+ const [isVerificationComplete, setIsVerificationComplete] = (0, import_react9.useState)(false);
6608
+ const [isAutoTransitioning, setIsAutoTransitioning] = (0, import_react9.useState)(false);
6609
+ const modalRef = (0, import_react9.useRef)(null);
6610
+ const firstFocusableRef = (0, import_react9.useRef)(null);
6611
+ const lastFocusableRef = (0, import_react9.useRef)(null);
6612
+ const abortControllerRef = (0, import_react9.useRef)(null);
6613
+ const isRequestInProgressRef = (0, import_react9.useRef)(false);
6614
+ const currentAudioRef = (0, import_react9.useRef)(null);
6615
+ const popupCheckIntervalRef = (0, import_react9.useRef)(null);
6616
+ const statusPollIntervalRef = (0, import_react9.useRef)(null);
6617
+ const verificationPopupRef = (0, import_react9.useRef)(null);
6618
+ const pollingCleanupRef = (0, import_react9.useRef)(null);
6619
+ const autoTransitionTimerRef = (0, import_react9.useRef)(
6539
6620
  null
6540
6621
  );
6541
- const digilockerRedirectTimeoutRef = (0, import_react8.useRef)(null);
6542
- const isInitialMountRef = (0, import_react8.useRef)(true);
6543
- const isPollingStatusRef = (0, import_react8.useRef)(false);
6544
- const verificationSessionTokenRef = (0, import_react8.useRef)(null);
6622
+ const digilockerRedirectTimeoutRef = (0, import_react9.useRef)(null);
6623
+ const isInitialMountRef = (0, import_react9.useRef)(true);
6624
+ const isPollingStatusRef = (0, import_react9.useRef)(false);
6625
+ const verificationSessionTokenRef = (0, import_react9.useRef)(null);
6545
6626
  const isNarrowViewport = useMediaQuery("(max-width: 768px)");
6546
6627
  const isMobile = forceMobile != null ? forceMobile : isNarrowViewport;
6547
- const baseResponsiveStyles = (0, import_react8.useMemo)(
6628
+ const baseResponsiveStyles = (0, import_react9.useMemo)(
6548
6629
  () => ({
6549
6630
  modal: {
6550
6631
  width: isMobile ? "90%" : "700px"
@@ -6625,7 +6706,7 @@ var NoticeConsentView = ({
6625
6706
  );
6626
6707
  const appearance = noticeAppearance.style;
6627
6708
  const appearanceColors = noticeAppearance.colors;
6628
- const layout = (0, import_react8.useMemo)(
6709
+ const layout = (0, import_react9.useMemo)(
6629
6710
  () => resolveNoticeLayout(noticeAppearance),
6630
6711
  [noticeAppearance]
6631
6712
  );
@@ -6635,7 +6716,7 @@ var NoticeConsentView = ({
6635
6716
  const textColor = (noticeSettings == null ? void 0 : noticeSettings.textColor) || DEFAULT_TEXT_COLOR;
6636
6717
  const classicAccentColor = ((_b = (_a = noticeSettings == null ? void 0 : noticeSettings.button) == null ? void 0 : _a.accept) == null ? void 0 : _b.backgroundColor) || (content == null ? void 0 : content.primary_color) || (content ? DEFAULT_ACCENT_COLOR : headingColor);
6637
6718
  const accentColor = (_e = appearanceColors.toggle_on) != null ? _e : hasNoticeSkin(appearance) ? ((_d = (_c = noticeSettings == null ? void 0 : noticeSettings.button) == null ? void 0 : _c.acceptAll) == null ? void 0 : _d.backgroundColor) || classicAccentColor : classicAccentColor;
6638
- const variantStyles = (0, import_react8.useMemo)(
6719
+ const variantStyles = (0, import_react9.useMemo)(
6639
6720
  () => buildVariantStyles(
6640
6721
  styles,
6641
6722
  appearance,
@@ -6644,7 +6725,7 @@ var NoticeConsentView = ({
6644
6725
  ),
6645
6726
  [appearance, appearanceColors, accentColor]
6646
6727
  );
6647
- const skin = (0, import_react8.useMemo)(
6728
+ const skin = (0, import_react9.useMemo)(
6648
6729
  () => {
6649
6730
  var _a2;
6650
6731
  return buildNoticeSkin(appearance, variantStyles, {
@@ -6669,26 +6750,26 @@ var NoticeConsentView = ({
6669
6750
  ]
6670
6751
  );
6671
6752
  const textScale = NOTICE_TEXT_SCALE_FACTORS[(_f = noticeAppearance.textScale) != null ? _f : DEFAULT_TEXT_SCALE];
6672
- const styles4 = (0, import_react8.useMemo)(
6753
+ const styles4 = (0, import_react9.useMemo)(
6673
6754
  () => {
6674
6755
  var _a2;
6675
6756
  return scaleFontSizes((_a2 = skin == null ? void 0 : skin.styles) != null ? _a2 : variantStyles, textScale);
6676
6757
  },
6677
6758
  [skin, variantStyles, textScale]
6678
6759
  );
6679
- const overlayStyle2 = (0, import_react8.useMemo)(() => {
6760
+ const overlayStyle2 = (0, import_react9.useMemo)(() => {
6680
6761
  if (!layout.dimBackdrop) {
6681
6762
  return { ...styles4.overlay, backgroundColor: "transparent" };
6682
6763
  }
6683
6764
  return appearanceColors.overlay ? { ...styles4.overlay, backgroundColor: appearanceColors.overlay } : styles4.overlay;
6684
6765
  }, [styles4.overlay, appearanceColors.overlay, layout.dimBackdrop]);
6685
6766
  const styleRadii = STYLE_RADII[appearance];
6686
- const themeCssVariables = (0, import_react8.useMemo)(
6767
+ const themeCssVariables = (0, import_react9.useMemo)(
6687
6768
  () => buildThemeCssVariables(appearanceColors),
6688
6769
  [appearanceColors]
6689
6770
  );
6690
6771
  const logoSize = noticeAppearance.logoSize;
6691
- const responsiveStyles = (0, import_react8.useMemo)(() => {
6772
+ const responsiveStyles = (0, import_react9.useMemo)(() => {
6692
6773
  var _a2;
6693
6774
  const merged = {
6694
6775
  ...baseResponsiveStyles
@@ -6707,7 +6788,7 @@ var NoticeConsentView = ({
6707
6788
  return scaleFontSizes(merged, textScale);
6708
6789
  }, [baseResponsiveStyles, skin, logoSize, textScale]);
6709
6790
  const sheetParts = skin == null ? void 0 : skin.parts;
6710
- const layoutParts = (0, import_react8.useMemo)(() => {
6791
+ const layoutParts = (0, import_react9.useMemo)(() => {
6711
6792
  var _a2;
6712
6793
  const parts = (_a2 = skin == null ? void 0 : skin.parts) != null ? _a2 : buildLayoutParts(
6713
6794
  solidSurface(appearanceColors, accentColor, STYLE_RADII[appearance]),
@@ -6750,12 +6831,12 @@ var NoticeConsentView = ({
6750
6831
  }
6751
6832
  }, [appearance, drawsSwitches]);
6752
6833
  useNoticeCustomCss(noticeId, noticeAppearance.customCss);
6753
- const [openSections, setOpenSections] = (0, import_react8.useState)({
6834
+ const [openSections, setOpenSections] = (0, import_react9.useState)({
6754
6835
  about: false,
6755
6836
  dpo: false
6756
6837
  });
6757
6838
  const isTalkbackActive = isPlaying || isPaused;
6758
- const keepFocusedSectionsOpen = (0, import_react8.useCallback)(() => {
6839
+ const keepFocusedSectionsOpen = (0, import_react9.useCallback)(() => {
6759
6840
  if (typeof document === "undefined") {
6760
6841
  return;
6761
6842
  }
@@ -6779,25 +6860,25 @@ var NoticeConsentView = ({
6779
6860
  hostFont: settings == null ? void 0 : settings.font,
6780
6861
  noticeFont: content == null ? void 0 : content.font_preference
6781
6862
  });
6782
- const componentHeadingStyle = (0, import_react8.useMemo)(
6863
+ const componentHeadingStyle = (0, import_react9.useMemo)(
6783
6864
  () => ({
6784
6865
  color: (noticeSettings == null ? void 0 : noticeSettings.headingColor) || "#323B4B"
6785
6866
  }),
6786
6867
  [noticeSettings == null ? void 0 : noticeSettings.headingColor]
6787
6868
  );
6788
- const componentTextStyle = (0, import_react8.useMemo)(
6869
+ const componentTextStyle = (0, import_react9.useMemo)(
6789
6870
  () => ({
6790
6871
  color: (noticeSettings == null ? void 0 : noticeSettings.textColor) || "#344054"
6791
6872
  }),
6792
6873
  [noticeSettings == null ? void 0 : noticeSettings.textColor]
6793
6874
  );
6794
- const sectionStyle = (0, import_react8.useMemo)(
6875
+ const sectionStyle = (0, import_react9.useMemo)(
6795
6876
  () => ({
6796
6877
  color: (noticeSettings == null ? void 0 : noticeSettings.textColor) || "#344054"
6797
6878
  }),
6798
6879
  [noticeSettings == null ? void 0 : noticeSettings.textColor]
6799
6880
  );
6800
- const logoRowStyle = (0, import_react8.useMemo)(
6881
+ const logoRowStyle = (0, import_react9.useMemo)(
6801
6882
  () => ({
6802
6883
  ...styles4.logoRow,
6803
6884
  justifyContent: logoRowJustify(
@@ -6806,7 +6887,7 @@ var NoticeConsentView = ({
6806
6887
  }),
6807
6888
  [styles4, content == null ? void 0 : content.logo_position]
6808
6889
  );
6809
- const purposeRows = (0, import_react8.useMemo)(
6890
+ const purposeRows = (0, import_react9.useMemo)(
6810
6891
  () => {
6811
6892
  var _a2;
6812
6893
  return noticePurposeRows(
@@ -6817,7 +6898,7 @@ var NoticeConsentView = ({
6817
6898
  },
6818
6899
  [content]
6819
6900
  );
6820
- const renderedPurposes = (0, import_react8.useMemo)(
6901
+ const renderedPurposes = (0, import_react9.useMemo)(
6821
6902
  () => {
6822
6903
  var _a2;
6823
6904
  return purposesInRenderOrder(
@@ -6828,7 +6909,7 @@ var NoticeConsentView = ({
6828
6909
  },
6829
6910
  [content]
6830
6911
  );
6831
- const productGroups = (0, import_react8.useMemo)(
6912
+ const productGroups = (0, import_react9.useMemo)(
6832
6913
  () => {
6833
6914
  var _a2;
6834
6915
  return groupPurposesByProduct(
@@ -6839,15 +6920,15 @@ var NoticeConsentView = ({
6839
6920
  },
6840
6921
  [content]
6841
6922
  );
6842
- const productMandatoryIsAuthoritative = (0, import_react8.useMemo)(
6923
+ const productMandatoryIsAuthoritative = (0, import_react9.useMemo)(
6843
6924
  () => serverMarksMandatoryProducts(content == null ? void 0 : content.products),
6844
6925
  [content]
6845
6926
  );
6846
- const gatedProducts = (0, import_react8.useMemo)(
6927
+ const gatedProducts = (0, import_react9.useMemo)(
6847
6928
  () => gatedProductUuids(content == null ? void 0 : content.products),
6848
6929
  [content]
6849
6930
  );
6850
- const productIsRequiredFor = (0, import_react8.useCallback)(
6931
+ const productIsRequiredFor = (0, import_react9.useCallback)(
6851
6932
  (productUuid) => {
6852
6933
  var _a2;
6853
6934
  if (!productMandatoryIsAuthoritative) return void 0;
@@ -6856,7 +6937,7 @@ var NoticeConsentView = ({
6856
6937
  },
6857
6938
  [productMandatoryIsAuthoritative, gatedProducts, content]
6858
6939
  );
6859
- const confirmVerdict = (0, import_react8.useMemo)(() => {
6940
+ const confirmVerdict = (0, import_react9.useMemo)(() => {
6860
6941
  var _a2;
6861
6942
  if (!content) return { ok: false, reason: "nothing-chosen", blocking: [] };
6862
6943
  if (purposeRows.length === 0)
@@ -6938,7 +7019,7 @@ var NoticeConsentView = ({
6938
7019
  gatedProducts
6939
7020
  ]);
6940
7021
  const acceptDisabled = isSubmitting || !confirmVerdict.ok;
6941
- (0, import_react8.useEffect)(() => {
7022
+ (0, import_react9.useEffect)(() => {
6942
7023
  var _a2, _b2;
6943
7024
  clearApiCache();
6944
7025
  isRequestInProgressRef.current = false;
@@ -7005,7 +7086,7 @@ var NoticeConsentView = ({
7005
7086
  }
7006
7087
  isInitialMountRef.current = false;
7007
7088
  }, [accessToken]);
7008
- (0, import_react8.useEffect)(() => {
7089
+ (0, import_react9.useEffect)(() => {
7009
7090
  if (hasAlreadyConsented) {
7010
7091
  onAccept == null ? void 0 : onAccept();
7011
7092
  }
@@ -7337,7 +7418,7 @@ var NoticeConsentView = ({
7337
7418
  isRequestInProgressRef.current = false;
7338
7419
  }
7339
7420
  };
7340
- (0, import_react8.useEffect)(() => {
7421
+ (0, import_react9.useEffect)(() => {
7341
7422
  injectCheckboxStyles();
7342
7423
  fetchNotice();
7343
7424
  }, [
@@ -7416,7 +7497,7 @@ var NoticeConsentView = ({
7416
7497
  });
7417
7498
  setSelectedDataElements((prev) => ({ ...prev, ...elementOverrides }));
7418
7499
  };
7419
- const productBoxPurposes = (0, import_react8.useCallback)((purposes) => {
7500
+ const productBoxPurposes = (0, import_react9.useCallback)((purposes) => {
7420
7501
  const required = purposes.filter(hasRequiredDataElement);
7421
7502
  return required.length > 0 ? required : purposes;
7422
7503
  }, []);
@@ -7618,7 +7699,7 @@ var NoticeConsentView = ({
7618
7699
  setIsSubmitting(false);
7619
7700
  }
7620
7701
  };
7621
- const handleDecline = (0, import_react8.useCallback)(async () => {
7702
+ const handleDecline = (0, import_react9.useCallback)(async () => {
7622
7703
  try {
7623
7704
  setIsSubmittingDecline(true);
7624
7705
  setIsSubmitting(true);
@@ -7636,14 +7717,14 @@ var NoticeConsentView = ({
7636
7717
  setConfirmAction(kind);
7637
7718
  setPendingAction(() => action);
7638
7719
  };
7639
- const dismissConfirm = (0, import_react8.useCallback)(() => setPendingAction(null), []);
7640
- const runPendingAction = (0, import_react8.useCallback)(() => {
7720
+ const dismissConfirm = (0, import_react9.useCallback)(() => setPendingAction(null), []);
7721
+ const runPendingAction = (0, import_react9.useCallback)(() => {
7641
7722
  const action = pendingActionRef.current;
7642
7723
  if (!action) return;
7643
7724
  setPendingAction(null);
7644
7725
  action();
7645
7726
  }, []);
7646
- const handleGuardianFormChange = (0, import_react8.useCallback)(
7727
+ const handleGuardianFormChange = (0, import_react9.useCallback)(
7647
7728
  (field, value) => {
7648
7729
  setGuardianFormData((prev) => ({
7649
7730
  ...prev,
@@ -7672,7 +7753,7 @@ var NoticeConsentView = ({
7672
7753
  setGuardianFormErrors(errors);
7673
7754
  return Object.keys(errors).length === 0;
7674
7755
  };
7675
- const handleGuardianFormNext = (0, import_react8.useCallback)(async () => {
7756
+ const handleGuardianFormNext = (0, import_react9.useCallback)(async () => {
7676
7757
  if (!validateGuardianForm()) {
7677
7758
  return;
7678
7759
  }
@@ -7813,20 +7894,20 @@ var NoticeConsentView = ({
7813
7894
  noticeId,
7814
7895
  onError
7815
7896
  ]);
7816
- const handleAgeVerificationYes = (0, import_react8.useCallback)(() => {
7897
+ const handleAgeVerificationYes = (0, import_react9.useCallback)(() => {
7817
7898
  setShowAgeVerification(false);
7818
7899
  setIsMinorFlow(false);
7819
7900
  setSelfDeclaredAdult(true);
7820
7901
  }, []);
7821
- const handleAgeVerificationNo = (0, import_react8.useCallback)(() => {
7902
+ const handleAgeVerificationNo = (0, import_react9.useCallback)(() => {
7822
7903
  setShowAgeVerification(false);
7823
7904
  setShowGuardianForm(true);
7824
7905
  }, []);
7825
- const handleVerificationContinue = (0, import_react8.useCallback)(() => {
7906
+ const handleVerificationContinue = (0, import_react9.useCallback)(() => {
7826
7907
  setShowVerificationScreen(false);
7827
7908
  setIsVerificationComplete(false);
7828
7909
  }, []);
7829
- const handlePopupClosed = (0, import_react8.useCallback)(async () => {
7910
+ const handlePopupClosed = (0, import_react9.useCallback)(async () => {
7830
7911
  var _a2, _b2;
7831
7912
  if (popupCheckIntervalRef.current) {
7832
7913
  clearInterval(popupCheckIntervalRef.current);
@@ -7868,7 +7949,7 @@ var NoticeConsentView = ({
7868
7949
  isPollingStatusRef.current = false;
7869
7950
  setIsInitiatingVerification(false);
7870
7951
  }, [accessToken, sandboxParams, baseUrl]);
7871
- const startPopupMonitoring = (0, import_react8.useCallback)(
7952
+ const startPopupMonitoring = (0, import_react9.useCallback)(
7872
7953
  (popup) => {
7873
7954
  popupCheckIntervalRef.current = window.setInterval(() => {
7874
7955
  if (popup.closed) {
@@ -7878,7 +7959,7 @@ var NoticeConsentView = ({
7878
7959
  },
7879
7960
  [handlePopupClosed]
7880
7961
  );
7881
- const getVerificationErrorMessage = (0, import_react8.useCallback)(
7962
+ const getVerificationErrorMessage = (0, import_react9.useCallback)(
7882
7963
  (errorCode, fallbackError) => {
7883
7964
  switch (errorCode) {
7884
7965
  case "GUARDIAN_UNDER_18":
@@ -7897,7 +7978,7 @@ var NoticeConsentView = ({
7897
7978
  },
7898
7979
  []
7899
7980
  );
7900
- const startStatusPolling = (0, import_react8.useCallback)(
7981
+ const startStatusPolling = (0, import_react9.useCallback)(
7901
7982
  (token2) => {
7902
7983
  verificationSessionTokenRef.current = token2;
7903
7984
  setIsPollingStatus(true);
@@ -8029,7 +8110,7 @@ var NoticeConsentView = ({
8029
8110
  },
8030
8111
  [accessToken, sandboxParams, baseUrl, getVerificationErrorMessage]
8031
8112
  );
8032
- const handleBackToGuardianForm = (0, import_react8.useCallback)((clearName = false) => {
8113
+ const handleBackToGuardianForm = (0, import_react9.useCallback)((clearName = false) => {
8033
8114
  var _a2, _b2;
8034
8115
  (_a2 = verificationPopupRef.current) == null ? void 0 : _a2.close();
8035
8116
  verificationPopupRef.current = null;
@@ -8065,7 +8146,7 @@ var NoticeConsentView = ({
8065
8146
  }
8066
8147
  clearConsentState();
8067
8148
  }, []);
8068
- const availableLanguages = (0, import_react8.useMemo)(() => {
8149
+ const availableLanguages = (0, import_react9.useMemo)(() => {
8069
8150
  if (!content) return [language];
8070
8151
  const pinned = ["English"];
8071
8152
  if (content.default_language && content.default_language !== "English" && content.default_language !== "en") {
@@ -8074,7 +8155,7 @@ var NoticeConsentView = ({
8074
8155
  const rest = content.supported_languages_and_translations ? Object.keys(content.supported_languages_and_translations).filter((lang) => !pinned.includes(lang)).sort((a, b) => a.localeCompare(b, "en")) : [];
8075
8156
  return [...pinned, ...rest];
8076
8157
  }, [content, language]);
8077
- const getLanguageCode = (0, import_react8.useCallback)(
8158
+ const getLanguageCode = (0, import_react9.useCallback)(
8078
8159
  (displayLanguage) => {
8079
8160
  if (!content) return "English";
8080
8161
  if (displayLanguage === "English" || displayLanguage === "en") {
@@ -8087,7 +8168,7 @@ var NoticeConsentView = ({
8087
8168
  },
8088
8169
  [content]
8089
8170
  );
8090
- const audioSequence = (0, import_react8.useMemo)(() => {
8171
+ const audioSequence = (0, import_react9.useMemo)(() => {
8091
8172
  if (!ttsAudioUrls || !content) return [];
8092
8173
  const sequence = [];
8093
8174
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -8159,7 +8240,7 @@ var NoticeConsentView = ({
8159
8240
  }
8160
8241
  return sequence;
8161
8242
  }, [ttsAudioUrls, content, categorizedPurposes]);
8162
- const elementIdSequence = (0, import_react8.useMemo)(() => {
8243
+ const elementIdSequence = (0, import_react9.useMemo)(() => {
8163
8244
  if (!ttsAudioUrls || !content) return [];
8164
8245
  const elementIds = [];
8165
8246
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -8227,7 +8308,7 @@ var NoticeConsentView = ({
8227
8308
  }
8228
8309
  return elementIds;
8229
8310
  }, [ttsAudioUrls, content, categorizedPurposes]);
8230
- const stopAudio = (0, import_react8.useCallback)(() => {
8311
+ const stopAudio = (0, import_react9.useCallback)(() => {
8231
8312
  if (currentAudioRef.current) {
8232
8313
  currentAudioRef.current.pause();
8233
8314
  currentAudioRef.current.currentTime = 0;
@@ -8239,7 +8320,7 @@ var NoticeConsentView = ({
8239
8320
  setCurrentAudioIndex(0);
8240
8321
  setHighlightedElementId(null);
8241
8322
  }, [keepFocusedSectionsOpen]);
8242
- const playNextAudio = (0, import_react8.useCallback)(
8323
+ const playNextAudio = (0, import_react9.useCallback)(
8243
8324
  (index) => {
8244
8325
  if (index >= audioSequence.length) {
8245
8326
  stopAudio();
@@ -8273,7 +8354,7 @@ var NoticeConsentView = ({
8273
8354
  },
8274
8355
  [audioSequence, elementIdSequence, stopAudio, keepFocusedSectionsOpen]
8275
8356
  );
8276
- const playAudio = (0, import_react8.useCallback)(() => {
8357
+ const playAudio = (0, import_react9.useCallback)(() => {
8277
8358
  if (audioSequence.length === 0) return;
8278
8359
  if (isPaused && currentAudioRef.current) {
8279
8360
  currentAudioRef.current.play().then(() => {
@@ -8287,21 +8368,21 @@ var NoticeConsentView = ({
8287
8368
  playNextAudio(startIndex);
8288
8369
  }
8289
8370
  }, [audioSequence, isPaused, isPlaying, currentAudioIndex, playNextAudio]);
8290
- const pauseAudio = (0, import_react8.useCallback)(() => {
8371
+ const pauseAudio = (0, import_react9.useCallback)(() => {
8291
8372
  if (currentAudioRef.current && isPlaying) {
8292
8373
  currentAudioRef.current.pause();
8293
8374
  setIsPlaying(false);
8294
8375
  setIsPaused(true);
8295
8376
  }
8296
8377
  }, [isPlaying]);
8297
- const toggleAudio = (0, import_react8.useCallback)(() => {
8378
+ const toggleAudio = (0, import_react9.useCallback)(() => {
8298
8379
  if (isPlaying) {
8299
8380
  pauseAudio();
8300
8381
  } else {
8301
8382
  playAudio();
8302
8383
  }
8303
8384
  }, [isPlaying, playAudio, pauseAudio]);
8304
- (0, import_react8.useEffect)(() => {
8385
+ (0, import_react9.useEffect)(() => {
8305
8386
  var _a2;
8306
8387
  if (!isPlaying || !content || audioSequence.length === 0) return;
8307
8388
  const currentIndex = currentAudioIndex;
@@ -8346,7 +8427,7 @@ var NoticeConsentView = ({
8346
8427
  categorizedPurposes,
8347
8428
  collapsedPurposes
8348
8429
  ]);
8349
- (0, import_react8.useEffect)(() => {
8430
+ (0, import_react9.useEffect)(() => {
8350
8431
  const removeAllHighlights = () => {
8351
8432
  document.querySelectorAll(".redacto-tts-highlight").forEach((el) => {
8352
8433
  el.classList.remove("redacto-tts-highlight");
@@ -8382,7 +8463,7 @@ var NoticeConsentView = ({
8382
8463
  removeAllHighlights();
8383
8464
  };
8384
8465
  }, [highlightedElementId, isPlaying]);
8385
- (0, import_react8.useEffect)(() => {
8466
+ (0, import_react9.useEffect)(() => {
8386
8467
  setIsTTSAvailable(false);
8387
8468
  setTtsAudioUrls(null);
8388
8469
  stopAudio();
@@ -8393,7 +8474,7 @@ var NoticeConsentView = ({
8393
8474
  const ttsAbortController = new AbortController();
8394
8475
  fetchTTSAudioUrls({
8395
8476
  accessToken,
8396
- baseUrl,
8477
+ baseUrl: endpoints.mode === "host" ? ledgerBaseUrl : baseUrl,
8397
8478
  ledgerBaseUrl,
8398
8479
  noticeUuid: content.notice_uuid,
8399
8480
  language: languageCode,
@@ -8418,6 +8499,7 @@ var NoticeConsentView = ({
8418
8499
  sandboxParams,
8419
8500
  baseUrl,
8420
8501
  ledgerBaseUrl,
8502
+ endpoints.mode,
8421
8503
  getLanguageCode
8422
8504
  ]);
8423
8505
  const hostRadius = noticeSettings == null ? void 0 : noticeSettings.borderRadius;
@@ -8454,7 +8536,7 @@ var NoticeConsentView = ({
8454
8536
  color: ((_v = (_u = noticeSettings == null ? void 0 : noticeSettings.button) == null ? void 0 : _u.decline) == null ? void 0 : _v.textColor) || (skin ? textColor : "#000000"),
8455
8537
  borderColor: (_w = appearanceColors.decline_border) != null ? _w : (noticeSettings == null ? void 0 : noticeSettings.borderColor) || (skin ? skin.palette.outline : "#d0d5dd")
8456
8538
  };
8457
- const confirmHint = (0, import_react8.useMemo)(() => {
8539
+ const confirmHint = (0, import_react9.useMemo)(() => {
8458
8540
  var _a2;
8459
8541
  const { ok, reason, blocking } = confirmVerdict;
8460
8542
  if (ok || reason === "ok" || isSubmitting) return null;
@@ -8511,7 +8593,7 @@ var NoticeConsentView = ({
8511
8593
  otpTokenAtVerifyRef.current = accessToken;
8512
8594
  setOtpAcceptAfterToken(mode);
8513
8595
  };
8514
- (0, import_react8.useEffect)(() => {
8596
+ (0, import_react9.useEffect)(() => {
8515
8597
  if (!otpAcceptAfterToken) {
8516
8598
  return;
8517
8599
  }
@@ -8525,7 +8607,7 @@ var NoticeConsentView = ({
8525
8607
  const hasPrivacyCenterLine = Boolean(
8526
8608
  (content == null ? void 0 : content.privacy_center_url) || (content == null ? void 0 : content.additional_text)
8527
8609
  );
8528
- const productPolicyLinks = (0, import_react8.useMemo)(
8610
+ const productPolicyLinks = (0, import_react9.useMemo)(
8529
8611
  () => productPolicyEntries(
8530
8612
  content == null ? void 0 : content.products,
8531
8613
  content == null ? void 0 : content.product_privacy_policies
@@ -8604,7 +8686,7 @@ var NoticeConsentView = ({
8604
8686
  const handleCloseError = () => {
8605
8687
  setErrorMessage(null);
8606
8688
  };
8607
- (0, import_react8.useEffect)(() => {
8689
+ (0, import_react9.useEffect)(() => {
8608
8690
  const handleKeyDown = (event) => {
8609
8691
  if (!modalRef.current) return;
8610
8692
  if (pendingActionRef.current) return;
@@ -8649,13 +8731,13 @@ var NoticeConsentView = ({
8649
8731
  modal == null ? void 0 : modal.removeEventListener("keydown", handleKeyDown);
8650
8732
  };
8651
8733
  }, [isLoading, handleDecline, previewContent]);
8652
- (0, import_react8.useEffect)(() => {
8734
+ (0, import_react9.useEffect)(() => {
8653
8735
  stopAudio();
8654
8736
  }, [selectedLanguage, stopAudio]);
8655
- (0, import_react8.useEffect)(() => {
8737
+ (0, import_react9.useEffect)(() => {
8656
8738
  stopAudio();
8657
8739
  }, [content, stopAudio]);
8658
- (0, import_react8.useEffect)(() => {
8740
+ (0, import_react9.useEffect)(() => {
8659
8741
  return () => {
8660
8742
  var _a2, _b2;
8661
8743
  if (abortControllerRef.current) {
@@ -8681,7 +8763,7 @@ var NoticeConsentView = ({
8681
8763
  }
8682
8764
  };
8683
8765
  }, [stopAudio]);
8684
- (0, import_react8.useEffect)(() => {
8766
+ (0, import_react9.useEffect)(() => {
8685
8767
  const persistedState = getConsentState();
8686
8768
  if (!persistedState) return;
8687
8769
  if (persistedState.noticeId && persistedState.noticeId !== noticeId) {
@@ -9802,7 +9884,7 @@ var NoticeConsentView = ({
9802
9884
  var RedactoNoticeConsent = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NoticeConsentView, { ...props });
9803
9885
 
9804
9886
  // src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx
9805
- var import_react10 = require("react");
9887
+ var import_react11 = require("react");
9806
9888
 
9807
9889
  // src/RedactoNoticeConsentInline/api/index.ts
9808
9890
  var BASE_URL2 = DEFAULT_CONSENT_API_BASE_URL;
@@ -10262,11 +10344,11 @@ var styles2 = {
10262
10344
  };
10263
10345
 
10264
10346
  // src/RedactoNoticeConsentInline/useMediaQuery.ts
10265
- var import_react9 = require("react");
10347
+ var import_react10 = require("react");
10266
10348
  var useMediaQuery2 = (query) => {
10267
10349
  const getMatches = () => typeof window !== "undefined" ? window.matchMedia(query).matches : false;
10268
- const [matches, setMatches] = (0, import_react9.useState)(getMatches);
10269
- (0, import_react9.useEffect)(() => {
10350
+ const [matches, setMatches] = (0, import_react10.useState)(getMatches);
10351
+ (0, import_react10.useEffect)(() => {
10270
10352
  if (typeof window === "undefined") return;
10271
10353
  const media = window.matchMedia(query);
10272
10354
  const listener = (e) => {
@@ -10323,8 +10405,8 @@ var RedactoConsentInlineComponent = ({
10323
10405
  workspace_uuid,
10324
10406
  notice_uuid,
10325
10407
  accessToken,
10326
- baseUrl,
10327
- ledgerBaseUrl,
10408
+ baseUrl: baseUrlProp,
10409
+ ledgerBaseUrl: ledgerBaseUrlProp,
10328
10410
  language = "en",
10329
10411
  onAccept,
10330
10412
  onError,
@@ -10333,24 +10415,51 @@ var RedactoConsentInlineComponent = ({
10333
10415
  applicationId
10334
10416
  }) => {
10335
10417
  var _a, _b, _c;
10336
- const [content, setContent] = (0, import_react10.useState)(null);
10337
- const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
10338
- const [isSubmitting, setIsSubmitting] = (0, import_react10.useState)(false);
10339
- const [selectedLanguage, setSelectedLanguage] = (0, import_react10.useState)(language);
10340
- const [collapsedPurposes, setCollapsedPurposes] = (0, import_react10.useState)({});
10341
- const [selectedPurposes, setSelectedPurposes] = (0, import_react10.useState)({});
10342
- const [selectedDataElements, setSelectedDataElements] = (0, import_react10.useState)({});
10343
- const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react10.useState)(false);
10344
- const [isCheckingConsent, setIsCheckingConsent] = (0, import_react10.useState)(
10418
+ const endpoints = useResolvedEndpoints(baseUrlProp, ledgerBaseUrlProp);
10419
+ const { baseUrl, ledgerBaseUrl } = endpoints;
10420
+ const [content, setContent] = (0, import_react11.useState)(null);
10421
+ const [isLoading, setIsLoading] = (0, import_react11.useState)(true);
10422
+ const [isSubmitting, setIsSubmitting] = (0, import_react11.useState)(false);
10423
+ const [selectedLanguage, setSelectedLanguage] = (0, import_react11.useState)(language);
10424
+ const [collapsedPurposes, setCollapsedPurposes] = (0, import_react11.useState)({});
10425
+ const [selectedPurposes, setSelectedPurposes] = (0, import_react11.useState)({});
10426
+ const [selectedDataElements, setSelectedDataElements] = (0, import_react11.useState)({});
10427
+ const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react11.useState)(false);
10428
+ const [isCheckingConsent, setIsCheckingConsent] = (0, import_react11.useState)(
10345
10429
  Boolean(ledgerBaseUrl) && !applicationId
10346
10430
  );
10347
- const [fetchError, setFetchError] = (0, import_react10.useState)(null);
10348
- const [errorMessage, setErrorMessage] = (0, import_react10.useState)(null);
10349
- const hasSubmittedRef = (0, import_react10.useRef)(false);
10350
- const [awaitingConfirm, setAwaitingConfirm] = (0, import_react10.useState)(false);
10351
- const refusedSelectionRef = (0, import_react10.useRef)(null);
10352
- const confirmedSelectionRef = (0, import_react10.useRef)(null);
10353
- (0, import_react10.useEffect)(() => {
10431
+ const [fetchError, setFetchError] = (0, import_react11.useState)(null);
10432
+ const [errorMessage, setErrorMessage] = (0, import_react11.useState)(null);
10433
+ const hasSubmittedRef = (0, import_react11.useRef)(false);
10434
+ const [awaitingConfirm, setAwaitingConfirm] = (0, import_react11.useState)(false);
10435
+ const refusedSelectionRef = (0, import_react11.useRef)(null);
10436
+ const confirmedSelectionRef = (0, import_react11.useRef)(null);
10437
+ const endpointsKey = JSON.stringify([endpoints.mode, baseUrl != null ? baseUrl : "", ledgerBaseUrl != null ? ledgerBaseUrl : ""]);
10438
+ const [loadedEndpointsKey, setLoadedEndpointsKey] = (0, import_react11.useState)(endpointsKey);
10439
+ if (loadedEndpointsKey !== endpointsKey) {
10440
+ setLoadedEndpointsKey(endpointsKey);
10441
+ setContent(null);
10442
+ setIsLoading(true);
10443
+ setFetchError(null);
10444
+ setErrorMessage(null);
10445
+ setHasAlreadyConsented(false);
10446
+ setIsCheckingConsent(Boolean(ledgerBaseUrl) && !applicationId);
10447
+ setIsSubmitting(false);
10448
+ setAwaitingConfirm(false);
10449
+ }
10450
+ const endpointsGenerationRef = (0, import_react11.useRef)(0);
10451
+ const committedEndpointsKeyRef = (0, import_react11.useRef)(endpointsKey);
10452
+ useIsomorphicLayoutEffect(() => {
10453
+ if (committedEndpointsKeyRef.current === endpointsKey) {
10454
+ return;
10455
+ }
10456
+ committedEndpointsKeyRef.current = endpointsKey;
10457
+ endpointsGenerationRef.current += 1;
10458
+ hasSubmittedRef.current = false;
10459
+ refusedSelectionRef.current = null;
10460
+ confirmedSelectionRef.current = null;
10461
+ }, [endpointsKey]);
10462
+ (0, import_react11.useEffect)(() => {
10354
10463
  injectSpinnerAnimation();
10355
10464
  injectCheckboxStyles();
10356
10465
  }, []);
@@ -10358,18 +10467,18 @@ var RedactoConsentInlineComponent = ({
10358
10467
  const { colors } = inlineAppearance;
10359
10468
  useNoticeCustomCss(notice_uuid, inlineAppearance.customCss);
10360
10469
  const drawsSwitches = resolveNoticeLayout(inlineAppearance).switchControl;
10361
- (0, import_react10.useEffect)(() => {
10470
+ (0, import_react11.useEffect)(() => {
10362
10471
  if (drawsSwitches) {
10363
10472
  injectSwitchStyles();
10364
10473
  }
10365
10474
  }, [drawsSwitches]);
10366
10475
  const textScale = NOTICE_TEXT_SCALE_FACTORS[(_a = inlineAppearance.textScale) != null ? _a : DEFAULT_TEXT_SCALE];
10367
- const styles4 = (0, import_react10.useMemo)(
10476
+ const styles4 = (0, import_react11.useMemo)(
10368
10477
  () => scaleFontSizes(styles2, textScale),
10369
10478
  [textScale]
10370
10479
  );
10371
10480
  const isMobile = useMediaQuery2("(max-width: 768px)");
10372
- const responsiveStyles = (0, import_react10.useMemo)(
10481
+ const responsiveStyles = (0, import_react11.useMemo)(
10373
10482
  () => scaleFontSizes(
10374
10483
  {
10375
10484
  optionTitle: {
@@ -10390,7 +10499,7 @@ var RedactoConsentInlineComponent = ({
10390
10499
  ),
10391
10500
  [isMobile, textScale]
10392
10501
  );
10393
- const purposeRows = (0, import_react10.useMemo)(
10502
+ const purposeRows = (0, import_react11.useMemo)(
10394
10503
  () => {
10395
10504
  var _a2;
10396
10505
  return noticePurposeRows(
@@ -10401,7 +10510,7 @@ var RedactoConsentInlineComponent = ({
10401
10510
  },
10402
10511
  [content]
10403
10512
  );
10404
- const areAllRequiredElementsChecked = (0, import_react10.useMemo)(() => {
10513
+ const areAllRequiredElementsChecked = (0, import_react11.useMemo)(() => {
10405
10514
  if (!content) return false;
10406
10515
  return purposeRows.every(
10407
10516
  ({ purpose, productUuid }) => purpose.data_elements.filter(isBlockingRequiredElement).every(
@@ -10409,10 +10518,10 @@ var RedactoConsentInlineComponent = ({
10409
10518
  )
10410
10519
  );
10411
10520
  }, [content, purposeRows, selectedDataElements]);
10412
- (0, import_react10.useEffect)(() => {
10521
+ (0, import_react11.useEffect)(() => {
10413
10522
  onValidationChange == null ? void 0 : onValidationChange(areAllRequiredElementsChecked);
10414
10523
  }, [areAllRequiredElementsChecked, onValidationChange]);
10415
- (0, import_react10.useEffect)(() => {
10524
+ (0, import_react11.useEffect)(() => {
10416
10525
  if (hasAlreadyConsented) {
10417
10526
  onAccept == null ? void 0 : onAccept();
10418
10527
  }
@@ -10469,12 +10578,13 @@ var RedactoConsentInlineComponent = ({
10469
10578
  setFetchError(null);
10470
10579
  setHasAlreadyConsented(false);
10471
10580
  try {
10581
+ const noticeBaseUrl = endpoints.mode === "host" && accessToken && !applicationId ? ledgerBaseUrl : baseUrl;
10472
10582
  const consentContentData = await fetchConsentContent2({
10473
10583
  org_uuid,
10474
10584
  workspace_uuid,
10475
10585
  notice_uuid,
10476
10586
  accessToken,
10477
- baseUrl,
10587
+ baseUrl: noticeBaseUrl,
10478
10588
  language,
10479
10589
  specific_uuid: applicationId,
10480
10590
  signal
@@ -10526,7 +10636,7 @@ var RedactoConsentInlineComponent = ({
10526
10636
  }
10527
10637
  }
10528
10638
  };
10529
- (0, import_react10.useEffect)(() => {
10639
+ (0, import_react11.useEffect)(() => {
10530
10640
  const controller = new AbortController();
10531
10641
  void fetchNotice(controller.signal);
10532
10642
  return () => {
@@ -10538,9 +10648,10 @@ var RedactoConsentInlineComponent = ({
10538
10648
  notice_uuid,
10539
10649
  language,
10540
10650
  applicationId,
10541
- accessToken
10651
+ accessToken,
10652
+ endpointsKey
10542
10653
  ]);
10543
- (0, import_react10.useEffect)(() => {
10654
+ (0, import_react11.useEffect)(() => {
10544
10655
  if (!ledgerBaseUrl || applicationId) {
10545
10656
  return;
10546
10657
  }
@@ -10637,12 +10748,14 @@ var RedactoConsentInlineComponent = ({
10637
10748
  return newState;
10638
10749
  });
10639
10750
  };
10640
- const handleAcceptWithToken = (0, import_react10.useCallback)(
10751
+ const handleAcceptWithToken = (0, import_react11.useCallback)(
10641
10752
  async (tokenToUse) => {
10642
10753
  if (!tokenToUse || !content) {
10643
10754
  setErrorMessage("Unable to submit consent. Please try again.");
10644
10755
  throw new Error("Access token or content not available");
10645
10756
  }
10757
+ const generation = endpointsGenerationRef.current;
10758
+ const isCurrent = () => endpointsGenerationRef.current === generation;
10646
10759
  try {
10647
10760
  setIsSubmitting(true);
10648
10761
  setErrorMessage(null);
@@ -10678,16 +10791,24 @@ var RedactoConsentInlineComponent = ({
10678
10791
  declined: false,
10679
10792
  meta_data: applicationId ? { specific_uuid: applicationId } : void 0
10680
10793
  });
10794
+ if (!isCurrent()) {
10795
+ return;
10796
+ }
10681
10797
  onAccept == null ? void 0 : onAccept();
10682
10798
  hasSubmittedRef.current = false;
10683
10799
  } catch (error) {
10800
+ if (!isCurrent()) {
10801
+ return;
10802
+ }
10684
10803
  const err = error;
10685
10804
  const message = err.message || "Failed to submit consent. Please try again.";
10686
10805
  setErrorMessage(message);
10687
10806
  hasSubmittedRef.current = false;
10688
10807
  throw error;
10689
10808
  } finally {
10690
- setIsSubmitting(false);
10809
+ if (isCurrent()) {
10810
+ setIsSubmitting(false);
10811
+ }
10691
10812
  }
10692
10813
  },
10693
10814
  [
@@ -10704,11 +10825,11 @@ var RedactoConsentInlineComponent = ({
10704
10825
  ]
10705
10826
  );
10706
10827
  const confirmBeforeSubmit = inlineAppearance.confirmBeforeSubmit === true;
10707
- const selectionSignature = (0, import_react10.useMemo)(
10828
+ const selectionSignature = (0, import_react11.useMemo)(
10708
10829
  () => JSON.stringify([selectedPurposes, selectedDataElements]),
10709
10830
  [selectedPurposes, selectedDataElements]
10710
10831
  );
10711
- const confirmSubmission = (0, import_react10.useCallback)(() => {
10832
+ const confirmSubmission = (0, import_react11.useCallback)(() => {
10712
10833
  setAwaitingConfirm(false);
10713
10834
  confirmedSelectionRef.current = selectionSignature;
10714
10835
  hasSubmittedRef.current = true;
@@ -10718,11 +10839,11 @@ var RedactoConsentInlineComponent = ({
10718
10839
  onError == null ? void 0 : onError(err);
10719
10840
  });
10720
10841
  }, [accessToken, handleAcceptWithToken, onError, selectionSignature]);
10721
- const refuseSubmission = (0, import_react10.useCallback)(() => {
10842
+ const refuseSubmission = (0, import_react11.useCallback)(() => {
10722
10843
  setAwaitingConfirm(false);
10723
10844
  refusedSelectionRef.current = selectionSignature;
10724
10845
  }, [selectionSignature]);
10725
- (0, import_react10.useEffect)(() => {
10846
+ (0, import_react11.useEffect)(() => {
10726
10847
  if (accessToken && content && areAllRequiredElementsChecked && !isSubmitting && !isCheckingConsent && !hasAlreadyConsented && !hasSubmittedRef.current) {
10727
10848
  if (confirmBeforeSubmit) {
10728
10849
  if (refusedSelectionRef.current === selectionSignature || confirmedSelectionRef.current === selectionSignature) {
@@ -10753,7 +10874,7 @@ var RedactoConsentInlineComponent = ({
10753
10874
  confirmBeforeSubmit,
10754
10875
  selectionSignature
10755
10876
  ]);
10756
- (0, import_react10.useEffect)(() => {
10877
+ (0, import_react11.useEffect)(() => {
10757
10878
  refusedSelectionRef.current = null;
10758
10879
  confirmedSelectionRef.current = null;
10759
10880
  if (!accessToken) {
@@ -11042,10 +11163,10 @@ var RedactoConsentInlineComponent = ({
11042
11163
  );
11043
11164
  };
11044
11165
  RedactoConsentInlineComponent.displayName = "RedactoConsentInline";
11045
- var RedactoConsentInline = (0, import_react10.memo)(RedactoConsentInlineComponent);
11166
+ var RedactoConsentInline = (0, import_react11.memo)(RedactoConsentInlineComponent);
11046
11167
 
11047
11168
  // src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx
11048
- var import_react12 = require("react");
11169
+ var import_react13 = require("react");
11049
11170
 
11050
11171
  // src/RedactoNoticeAssisted/styles.ts
11051
11172
  var styles3 = {
@@ -12005,11 +12126,11 @@ var injectAssistedStyles = () => {
12005
12126
  };
12006
12127
 
12007
12128
  // src/RedactoNoticeAssisted/useMediaQuery.ts
12008
- var import_react11 = require("react");
12129
+ var import_react12 = require("react");
12009
12130
  var useMediaQuery3 = (query) => {
12010
12131
  const getMatches = () => typeof window !== "undefined" ? window.matchMedia(query).matches : false;
12011
- const [matches, setMatches] = (0, import_react11.useState)(getMatches);
12012
- (0, import_react11.useEffect)(() => {
12132
+ const [matches, setMatches] = (0, import_react12.useState)(getMatches);
12133
+ (0, import_react12.useEffect)(() => {
12013
12134
  if (typeof window === "undefined") return;
12014
12135
  const media = window.matchMedia(query);
12015
12136
  const listener = (e) => {
@@ -13630,56 +13751,60 @@ var RedactoNoticeAssisted = ({
13630
13751
  organisationUuid,
13631
13752
  workspaceUuid,
13632
13753
  noticeUuid,
13633
- baseUrl,
13634
- ledgerBaseUrl,
13754
+ baseUrl: baseUrlProp,
13755
+ ledgerBaseUrl: ledgerBaseUrlProp,
13635
13756
  onDecline,
13636
13757
  onComplete,
13637
13758
  settings
13638
13759
  }) => {
13639
13760
  var _a, _b, _c, _d;
13761
+ const { baseUrl, ledgerBaseUrl } = useResolvedEndpoints(
13762
+ baseUrlProp,
13763
+ ledgerBaseUrlProp
13764
+ );
13640
13765
  const isMobile = useMediaQuery3("(max-width: 768px)");
13641
- const [content, setContent] = (0, import_react12.useState)(null);
13642
- const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
13643
- const [fetchError, setFetchError] = (0, import_react12.useState)(null);
13644
- const [step, setStep] = (0, import_react12.useState)("notice");
13645
- const [acceptMode, setAcceptMode] = (0, import_react12.useState)("selected");
13646
- const [selectedPurposes, setSelectedPurposes] = (0, import_react12.useState)({});
13647
- const [selectedDataElements, setSelectedDataElements] = (0, import_react12.useState)({});
13648
- const [collapsedPurposes, setCollapsedPurposes] = (0, import_react12.useState)({});
13649
- const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react12.useState)(false);
13650
- const [selectedLanguage, setSelectedLanguage] = (0, import_react12.useState)("English");
13651
- const languageContainerRef = (0, import_react12.useRef)(null);
13652
- const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react12.useState)(null);
13653
- const [isTTSAvailable, setIsTTSAvailable] = (0, import_react12.useState)(false);
13654
- const [isPlaying, setIsPlaying] = (0, import_react12.useState)(false);
13655
- const [isPaused, setIsPaused] = (0, import_react12.useState)(false);
13656
- const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react12.useState)(0);
13657
- const [highlightedElementId, setHighlightedElementId] = (0, import_react12.useState)(null);
13658
- const currentAudioRef = (0, import_react12.useRef)(null);
13659
- const [verifyMethod, setVerifyMethod] = (0, import_react12.useState)(
13766
+ const [content, setContent] = (0, import_react13.useState)(null);
13767
+ const [isLoading, setIsLoading] = (0, import_react13.useState)(true);
13768
+ const [fetchError, setFetchError] = (0, import_react13.useState)(null);
13769
+ const [step, setStep] = (0, import_react13.useState)("notice");
13770
+ const [acceptMode, setAcceptMode] = (0, import_react13.useState)("selected");
13771
+ const [selectedPurposes, setSelectedPurposes] = (0, import_react13.useState)({});
13772
+ const [selectedDataElements, setSelectedDataElements] = (0, import_react13.useState)({});
13773
+ const [collapsedPurposes, setCollapsedPurposes] = (0, import_react13.useState)({});
13774
+ const [isLanguageDropdownOpen, setIsLanguageDropdownOpen] = (0, import_react13.useState)(false);
13775
+ const [selectedLanguage, setSelectedLanguage] = (0, import_react13.useState)("English");
13776
+ const languageContainerRef = (0, import_react13.useRef)(null);
13777
+ const [ttsAudioUrls, setTtsAudioUrls] = (0, import_react13.useState)(null);
13778
+ const [isTTSAvailable, setIsTTSAvailable] = (0, import_react13.useState)(false);
13779
+ const [isPlaying, setIsPlaying] = (0, import_react13.useState)(false);
13780
+ const [isPaused, setIsPaused] = (0, import_react13.useState)(false);
13781
+ const [currentAudioIndex, setCurrentAudioIndex] = (0, import_react13.useState)(0);
13782
+ const [highlightedElementId, setHighlightedElementId] = (0, import_react13.useState)(null);
13783
+ const currentAudioRef = (0, import_react13.useRef)(null);
13784
+ const [verifyMethod, setVerifyMethod] = (0, import_react13.useState)(
13660
13785
  "mobile"
13661
13786
  );
13662
- const [mobile, setMobile] = (0, import_react12.useState)("");
13663
- const mobileInputRef = (0, import_react12.useRef)(null);
13664
- const [email, setEmail] = (0, import_react12.useState)("");
13665
- const emailInputRef = (0, import_react12.useRef)(null);
13666
- const [otpSent, setOtpSent] = (0, import_react12.useState)(false);
13667
- const verifyBlockRef = (0, import_react12.useRef)(null);
13668
- const otpSectionRef = (0, import_react12.useRef)(null);
13669
- const [otpDigits, setOtpDigits] = (0, import_react12.useState)(
13787
+ const [mobile, setMobile] = (0, import_react13.useState)("");
13788
+ const mobileInputRef = (0, import_react13.useRef)(null);
13789
+ const [email, setEmail] = (0, import_react13.useState)("");
13790
+ const emailInputRef = (0, import_react13.useRef)(null);
13791
+ const [otpSent, setOtpSent] = (0, import_react13.useState)(false);
13792
+ const verifyBlockRef = (0, import_react13.useRef)(null);
13793
+ const otpSectionRef = (0, import_react13.useRef)(null);
13794
+ const [otpDigits, setOtpDigits] = (0, import_react13.useState)(
13670
13795
  () => Array.from({ length: ASSISTED_CONFIG.otpLength }, () => "")
13671
13796
  );
13672
- const otpInputRefs = (0, import_react12.useRef)([]);
13673
- const [resendCountdown, setResendCountdown] = (0, import_react12.useState)(0);
13674
- const [otpUuid, setOtpUuid] = (0, import_react12.useState)("");
13675
- const [isSendingOtp, setIsSendingOtp] = (0, import_react12.useState)(false);
13676
- const [isVerifying, setIsVerifying] = (0, import_react12.useState)(false);
13677
- const [createError, setCreateError] = (0, import_react12.useState)(null);
13678
- const [otpError, setOtpError] = (0, import_react12.useState)(null);
13679
- (0, import_react12.useEffect)(() => {
13797
+ const otpInputRefs = (0, import_react13.useRef)([]);
13798
+ const [resendCountdown, setResendCountdown] = (0, import_react13.useState)(0);
13799
+ const [otpUuid, setOtpUuid] = (0, import_react13.useState)("");
13800
+ const [isSendingOtp, setIsSendingOtp] = (0, import_react13.useState)(false);
13801
+ const [isVerifying, setIsVerifying] = (0, import_react13.useState)(false);
13802
+ const [createError, setCreateError] = (0, import_react13.useState)(null);
13803
+ const [otpError, setOtpError] = (0, import_react13.useState)(null);
13804
+ (0, import_react13.useEffect)(() => {
13680
13805
  injectAssistedStyles();
13681
13806
  }, []);
13682
- (0, import_react12.useEffect)(() => {
13807
+ (0, import_react13.useEffect)(() => {
13683
13808
  const controller = new AbortController();
13684
13809
  setIsLoading(true);
13685
13810
  setFetchError(null);
@@ -13715,14 +13840,14 @@ var RedactoNoticeAssisted = ({
13715
13840
  });
13716
13841
  return () => controller.abort();
13717
13842
  }, [organisationUuid, workspaceUuid, noticeUuid, baseUrl]);
13718
- (0, import_react12.useEffect)(() => {
13843
+ (0, import_react13.useEffect)(() => {
13719
13844
  if (resendCountdown <= 0) return;
13720
13845
  const intervalId = window.setInterval(() => {
13721
13846
  setResendCountdown((prev) => prev <= 1 ? 0 : prev - 1);
13722
13847
  }, 1e3);
13723
13848
  return () => window.clearInterval(intervalId);
13724
13849
  }, [resendCountdown]);
13725
- (0, import_react12.useEffect)(() => {
13850
+ (0, import_react13.useEffect)(() => {
13726
13851
  if (step !== "verify") return;
13727
13852
  const id = window.setTimeout(
13728
13853
  () => scrollIntoViewSoft(verifyBlockRef.current),
@@ -13730,7 +13855,7 @@ var RedactoNoticeAssisted = ({
13730
13855
  );
13731
13856
  return () => window.clearTimeout(id);
13732
13857
  }, [step]);
13733
- (0, import_react12.useEffect)(() => {
13858
+ (0, import_react13.useEffect)(() => {
13734
13859
  if (!otpSent) return;
13735
13860
  const id = window.setTimeout(
13736
13861
  () => scrollIntoViewSoft(otpSectionRef.current),
@@ -13738,7 +13863,7 @@ var RedactoNoticeAssisted = ({
13738
13863
  );
13739
13864
  return () => window.clearTimeout(id);
13740
13865
  }, [otpSent]);
13741
- (0, import_react12.useEffect)(() => {
13866
+ (0, import_react13.useEffect)(() => {
13742
13867
  if (!isLanguageDropdownOpen) return;
13743
13868
  const handleClickOutside = (e) => {
13744
13869
  if (languageContainerRef.current && !languageContainerRef.current.contains(e.target)) {
@@ -13753,7 +13878,7 @@ var RedactoNoticeAssisted = ({
13753
13878
  const isMobileValid = mobile.replace(/\D/g, "").length >= 10;
13754
13879
  const isEmailValid = EMAIL_REGEX.test(email.trim());
13755
13880
  const isContactValid = verifyMethod === "email" ? isEmailValid : isMobileValid;
13756
- const displayedPurposes = (0, import_react12.useMemo)(
13881
+ const displayedPurposes = (0, import_react13.useMemo)(
13757
13882
  () => {
13758
13883
  var _a2;
13759
13884
  return purposesInRenderOrder(
@@ -13764,7 +13889,7 @@ var RedactoNoticeAssisted = ({
13764
13889
  },
13765
13890
  [content]
13766
13891
  );
13767
- const areAllRequiredElementsChecked = (0, import_react12.useMemo)(() => {
13892
+ const areAllRequiredElementsChecked = (0, import_react13.useMemo)(() => {
13768
13893
  if (!content) return false;
13769
13894
  return displayedPurposes.every((purpose) => {
13770
13895
  const requiredElements = purpose.data_elements.filter(
@@ -13775,20 +13900,20 @@ var RedactoNoticeAssisted = ({
13775
13900
  );
13776
13901
  });
13777
13902
  }, [content, displayedPurposes, selectedDataElements]);
13778
- const normalizedDefaultLang = (0, import_react12.useMemo)(() => {
13903
+ const normalizedDefaultLang = (0, import_react13.useMemo)(() => {
13779
13904
  const dl = content == null ? void 0 : content.default_language;
13780
13905
  if (!dl) return "English";
13781
13906
  return dl === "en" || dl === "EN" ? "English" : dl;
13782
13907
  }, [content]);
13783
- const isDefaultLanguage = (0, import_react12.useCallback)(
13908
+ const isDefaultLanguage = (0, import_react13.useCallback)(
13784
13909
  (lang) => lang === "English" || lang === "en" || lang === "EN",
13785
13910
  []
13786
13911
  );
13787
- const ts = (0, import_react12.useMemo)(
13912
+ const ts = (0, import_react13.useMemo)(
13788
13913
  () => makeStaticT(toBcp47Code(selectedLanguage)),
13789
13914
  [selectedLanguage]
13790
13915
  );
13791
- const getTranslatedText = (0, import_react12.useCallback)(
13916
+ const getTranslatedText = (0, import_react13.useCallback)(
13792
13917
  (key, fallback, itemId) => {
13793
13918
  var _a2, _b2, _c2;
13794
13919
  if (!content) return fallback;
@@ -13818,7 +13943,7 @@ var RedactoNoticeAssisted = ({
13818
13943
  },
13819
13944
  [content, selectedLanguage, isDefaultLanguage]
13820
13945
  );
13821
- const getTranslatedDpoText = (0, import_react12.useCallback)(
13946
+ const getTranslatedDpoText = (0, import_react13.useCallback)(
13822
13947
  (key, fallback) => {
13823
13948
  var _a2, _b2;
13824
13949
  if (!(content == null ? void 0 : content.dpo_info)) return fallback;
@@ -13830,7 +13955,7 @@ var RedactoNoticeAssisted = ({
13830
13955
  },
13831
13956
  [content, selectedLanguage, isDefaultLanguage]
13832
13957
  );
13833
- const availableLanguages = (0, import_react12.useMemo)(() => {
13958
+ const availableLanguages = (0, import_react13.useMemo)(() => {
13834
13959
  if (!content) return [selectedLanguage];
13835
13960
  const pinned = ["English"];
13836
13961
  if (normalizedDefaultLang && normalizedDefaultLang !== "English") {
@@ -13860,7 +13985,7 @@ var RedactoNoticeAssisted = ({
13860
13985
  const assistedStyle = assistedAppearance.style;
13861
13986
  const radii = STYLE_RADII[assistedStyle];
13862
13987
  const textScale = NOTICE_TEXT_SCALE_FACTORS[(_a = assistedAppearance.textScale) != null ? _a : DEFAULT_TEXT_SCALE];
13863
- const styles4 = (0, import_react12.useMemo)(
13988
+ const styles4 = (0, import_react13.useMemo)(
13864
13989
  () => scaleFontSizes(
13865
13990
  buildVariantStyles(
13866
13991
  mergeNoticeStyles(styles3, {
@@ -13898,7 +14023,7 @@ var RedactoNoticeAssisted = ({
13898
14023
  const hasPrivacyCenterLine = Boolean(
13899
14024
  (content == null ? void 0 : content.privacy_center_url) || (content == null ? void 0 : content.additional_text)
13900
14025
  );
13901
- const responsive = (0, import_react12.useMemo)(
14026
+ const responsive = (0, import_react13.useMemo)(
13902
14027
  () => scaleFontSizes(
13903
14028
  {
13904
14029
  modal: { width: isMobile ? "90%" : "700px" },
@@ -13939,7 +14064,7 @@ var RedactoNoticeAssisted = ({
13939
14064
  ),
13940
14065
  [isMobile, textScale]
13941
14066
  );
13942
- const togglePurpose = (0, import_react12.useCallback)(
14067
+ const togglePurpose = (0, import_react13.useCallback)(
13943
14068
  (uuid) => {
13944
14069
  setSelectedPurposes((prev) => {
13945
14070
  const next = !prev[uuid];
@@ -13956,10 +14081,10 @@ var RedactoNoticeAssisted = ({
13956
14081
  },
13957
14082
  [content]
13958
14083
  );
13959
- const togglePurposeCollapse = (0, import_react12.useCallback)((uuid) => {
14084
+ const togglePurposeCollapse = (0, import_react13.useCallback)((uuid) => {
13960
14085
  setCollapsedPurposes((prev) => ({ ...prev, [uuid]: !prev[uuid] }));
13961
14086
  }, []);
13962
- const handleDataElementToggle = (0, import_react12.useCallback)(
14087
+ const handleDataElementToggle = (0, import_react13.useCallback)(
13963
14088
  (purposeUuid, elementUuid) => {
13964
14089
  if (!content) return;
13965
14090
  const combinedId = `${purposeUuid}-${elementUuid}`;
@@ -13985,14 +14110,14 @@ var RedactoNoticeAssisted = ({
13985
14110
  },
13986
14111
  [content]
13987
14112
  );
13988
- const toggleLanguageDropdown = (0, import_react12.useCallback)(() => {
14113
+ const toggleLanguageDropdown = (0, import_react13.useCallback)(() => {
13989
14114
  setIsLanguageDropdownOpen((prev) => !prev);
13990
14115
  }, []);
13991
- const handleLanguageSelect = (0, import_react12.useCallback)((lang) => {
14116
+ const handleLanguageSelect = (0, import_react13.useCallback)((lang) => {
13992
14117
  setSelectedLanguage(lang);
13993
14118
  setIsLanguageDropdownOpen(false);
13994
14119
  }, []);
13995
- const audioSequence = (0, import_react12.useMemo)(() => {
14120
+ const audioSequence = (0, import_react13.useMemo)(() => {
13996
14121
  if (!ttsAudioUrls || !content) return [];
13997
14122
  const sequence = [];
13998
14123
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -14053,7 +14178,7 @@ var RedactoNoticeAssisted = ({
14053
14178
  }
14054
14179
  return sequence;
14055
14180
  }, [ttsAudioUrls, content, displayedPurposes]);
14056
- const elementIdSequence = (0, import_react12.useMemo)(() => {
14181
+ const elementIdSequence = (0, import_react13.useMemo)(() => {
14057
14182
  if (!ttsAudioUrls || !content) return [];
14058
14183
  const elementIds = [];
14059
14184
  if (ttsAudioUrls.notice_banner_heading_audio_url) {
@@ -14110,7 +14235,7 @@ var RedactoNoticeAssisted = ({
14110
14235
  }
14111
14236
  return elementIds;
14112
14237
  }, [ttsAudioUrls, content, displayedPurposes]);
14113
- const stopAudio = (0, import_react12.useCallback)(() => {
14238
+ const stopAudio = (0, import_react13.useCallback)(() => {
14114
14239
  if (currentAudioRef.current) {
14115
14240
  currentAudioRef.current.pause();
14116
14241
  currentAudioRef.current.currentTime = 0;
@@ -14121,7 +14246,7 @@ var RedactoNoticeAssisted = ({
14121
14246
  setCurrentAudioIndex(0);
14122
14247
  setHighlightedElementId(null);
14123
14248
  }, []);
14124
- const playNextAudio = (0, import_react12.useCallback)(
14249
+ const playNextAudio = (0, import_react13.useCallback)(
14125
14250
  (index) => {
14126
14251
  if (index >= audioSequence.length) {
14127
14252
  stopAudio();
@@ -14154,7 +14279,7 @@ var RedactoNoticeAssisted = ({
14154
14279
  },
14155
14280
  [audioSequence, elementIdSequence, stopAudio]
14156
14281
  );
14157
- const playAudio = (0, import_react12.useCallback)(() => {
14282
+ const playAudio = (0, import_react13.useCallback)(() => {
14158
14283
  if (audioSequence.length === 0) return;
14159
14284
  if (isPaused && currentAudioRef.current) {
14160
14285
  currentAudioRef.current.play().then(() => {
@@ -14168,21 +14293,21 @@ var RedactoNoticeAssisted = ({
14168
14293
  playNextAudio(startIndex);
14169
14294
  }
14170
14295
  }, [audioSequence, isPaused, isPlaying, currentAudioIndex, playNextAudio]);
14171
- const pauseAudio = (0, import_react12.useCallback)(() => {
14296
+ const pauseAudio = (0, import_react13.useCallback)(() => {
14172
14297
  if (currentAudioRef.current && isPlaying) {
14173
14298
  currentAudioRef.current.pause();
14174
14299
  setIsPlaying(false);
14175
14300
  setIsPaused(true);
14176
14301
  }
14177
14302
  }, [isPlaying]);
14178
- const toggleAudio = (0, import_react12.useCallback)(() => {
14303
+ const toggleAudio = (0, import_react13.useCallback)(() => {
14179
14304
  if (isPlaying) {
14180
14305
  pauseAudio();
14181
14306
  } else {
14182
14307
  playAudio();
14183
14308
  }
14184
14309
  }, [isPlaying, playAudio, pauseAudio]);
14185
- (0, import_react12.useEffect)(() => {
14310
+ (0, import_react13.useEffect)(() => {
14186
14311
  setIsTTSAvailable(false);
14187
14312
  setTtsAudioUrls(null);
14188
14313
  stopAudio();
@@ -14213,7 +14338,7 @@ var RedactoNoticeAssisted = ({
14213
14338
  baseUrl,
14214
14339
  stopAudio
14215
14340
  ]);
14216
- (0, import_react12.useEffect)(() => {
14341
+ (0, import_react13.useEffect)(() => {
14217
14342
  const elementId = elementIdSequence[currentAudioIndex];
14218
14343
  if (!isPlaying || !elementId) {
14219
14344
  return;
@@ -14231,7 +14356,7 @@ var RedactoNoticeAssisted = ({
14231
14356
  displayedPurposes,
14232
14357
  collapsedPurposes
14233
14358
  ]);
14234
- (0, import_react12.useEffect)(() => {
14359
+ (0, import_react13.useEffect)(() => {
14235
14360
  const removeAllHighlights = () => {
14236
14361
  document.querySelectorAll(".redacto-tts-highlight").forEach((el) => {
14237
14362
  el.classList.remove("redacto-tts-highlight");
@@ -14262,7 +14387,7 @@ var RedactoNoticeAssisted = ({
14262
14387
  removeAllHighlights();
14263
14388
  };
14264
14389
  }, [highlightedElementId, isPlaying]);
14265
- const handleConfirmStep = (0, import_react12.useCallback)(
14390
+ const handleConfirmStep = (0, import_react13.useCallback)(
14266
14391
  (mode = "selected") => {
14267
14392
  if (mode !== "selected" && content) {
14268
14393
  const selection = buildSelectionForMode(
@@ -14287,15 +14412,15 @@ var RedactoNoticeAssisted = ({
14287
14412
  },
14288
14413
  [content, selectedPurposes, selectedDataElements, verifyMethod, stopAudio]
14289
14414
  );
14290
- const handleAcceptAll = (0, import_react12.useCallback)(
14415
+ const handleAcceptAll = (0, import_react13.useCallback)(
14291
14416
  () => handleConfirmStep("all"),
14292
14417
  [handleConfirmStep]
14293
14418
  );
14294
- const handleAcceptSelected = (0, import_react12.useCallback)(
14419
+ const handleAcceptSelected = (0, import_react13.useCallback)(
14295
14420
  () => handleConfirmStep("selected"),
14296
14421
  [handleConfirmStep]
14297
14422
  );
14298
- const handleEditSelections = (0, import_react12.useCallback)(() => {
14423
+ const handleEditSelections = (0, import_react13.useCallback)(() => {
14299
14424
  setAcceptMode("selected");
14300
14425
  setStep("notice");
14301
14426
  setOtpSent(false);
@@ -14309,7 +14434,7 @@ var RedactoNoticeAssisted = ({
14309
14434
  }, []);
14310
14435
  const otpRecipient = verifyMethod === "email" ? email.trim() : `${ASSISTED_CONFIG.dialCode}${mobile}`;
14311
14436
  const otpChannel = verifyMethod === "email" ? ASSISTED_CONFIG.emailChannel : ASSISTED_CONFIG.channel;
14312
- const sendOtp = (0, import_react12.useCallback)(async () => {
14437
+ const sendOtp = (0, import_react13.useCallback)(async () => {
14313
14438
  setCreateError(null);
14314
14439
  setIsSendingOtp(true);
14315
14440
  try {
@@ -14335,11 +14460,11 @@ var RedactoNoticeAssisted = ({
14335
14460
  setIsSendingOtp(false);
14336
14461
  }
14337
14462
  }, [organisationUuid, workspaceUuid, otpRecipient, otpChannel, baseUrl, ts]);
14338
- const handleGetOtp = (0, import_react12.useCallback)(() => {
14463
+ const handleGetOtp = (0, import_react13.useCallback)(() => {
14339
14464
  if (!isContactValid || isSendingOtp) return;
14340
14465
  void sendOtp();
14341
14466
  }, [isContactValid, isSendingOtp, sendOtp]);
14342
- const handleSelectMethod = (0, import_react12.useCallback)(
14467
+ const handleSelectMethod = (0, import_react13.useCallback)(
14343
14468
  (method) => {
14344
14469
  if (otpSent || isSendingOtp) return;
14345
14470
  setVerifyMethod(method);
@@ -14351,11 +14476,11 @@ var RedactoNoticeAssisted = ({
14351
14476
  },
14352
14477
  [otpSent, isSendingOtp]
14353
14478
  );
14354
- const handleResend = (0, import_react12.useCallback)(() => {
14479
+ const handleResend = (0, import_react13.useCallback)(() => {
14355
14480
  if (isSendingOtp) return;
14356
14481
  void sendOtp();
14357
14482
  }, [isSendingOtp, sendOtp]);
14358
- const handleChangeContact = (0, import_react12.useCallback)(() => {
14483
+ const handleChangeContact = (0, import_react13.useCallback)(() => {
14359
14484
  setOtpSent(false);
14360
14485
  setOtpUuid("");
14361
14486
  setOtpDigits(Array.from({ length: ASSISTED_CONFIG.otpLength }, () => ""));
@@ -14367,7 +14492,7 @@ var RedactoNoticeAssisted = ({
14367
14492
  (_a2 = (verifyMethod === "email" ? emailInputRef : mobileInputRef).current) == null ? void 0 : _a2.focus();
14368
14493
  }, 0);
14369
14494
  }, [verifyMethod]);
14370
- const handleOtpChange = (0, import_react12.useCallback)((index, raw) => {
14495
+ const handleOtpChange = (0, import_react13.useCallback)((index, raw) => {
14371
14496
  var _a2;
14372
14497
  const digit = raw.replace(/\D/g, "").slice(-1);
14373
14498
  setOtpDigits((prev) => {
@@ -14379,7 +14504,7 @@ var RedactoNoticeAssisted = ({
14379
14504
  (_a2 = otpInputRefs.current[index + 1]) == null ? void 0 : _a2.focus();
14380
14505
  }
14381
14506
  }, []);
14382
- const handleOtpKeyDown = (0, import_react12.useCallback)(
14507
+ const handleOtpKeyDown = (0, import_react13.useCallback)(
14383
14508
  (index, e) => {
14384
14509
  var _a2;
14385
14510
  if (e.key === "Backspace" && !otpDigits[index] && index > 0) {
@@ -14388,7 +14513,7 @@ var RedactoNoticeAssisted = ({
14388
14513
  },
14389
14514
  [otpDigits]
14390
14515
  );
14391
- const handleOtpPaste = (0, import_react12.useCallback)((e) => {
14516
+ const handleOtpPaste = (0, import_react13.useCallback)((e) => {
14392
14517
  var _a2;
14393
14518
  const pasted = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, ASSISTED_CONFIG.otpLength);
14394
14519
  if (!pasted) return;
@@ -14405,7 +14530,7 @@ var RedactoNoticeAssisted = ({
14405
14530
  const focusIndex = Math.min(pasted.length, ASSISTED_CONFIG.otpLength - 1);
14406
14531
  (_a2 = otpInputRefs.current[focusIndex]) == null ? void 0 : _a2.focus();
14407
14532
  }, []);
14408
- const resetFlow = (0, import_react12.useCallback)(() => {
14533
+ const resetFlow = (0, import_react13.useCallback)(() => {
14409
14534
  var _a2;
14410
14535
  setStep("notice");
14411
14536
  const preselection = buildPreselection(
@@ -14424,7 +14549,7 @@ var RedactoNoticeAssisted = ({
14424
14549
  setCreateError(null);
14425
14550
  setOtpError(null);
14426
14551
  }, [content]);
14427
- const handleSuccess = (0, import_react12.useCallback)(() => {
14552
+ const handleSuccess = (0, import_react13.useCallback)(() => {
14428
14553
  if (onComplete) {
14429
14554
  onComplete();
14430
14555
  return;
@@ -14432,7 +14557,7 @@ var RedactoNoticeAssisted = ({
14432
14557
  console.log("[RedactoNoticeAssisted] consent recorded");
14433
14558
  resetFlow();
14434
14559
  }, [onComplete, resetFlow]);
14435
- const handleConfirm = (0, import_react12.useCallback)(async () => {
14560
+ const handleConfirm = (0, import_react13.useCallback)(async () => {
14436
14561
  if (!isOtpComplete || isVerifying || !content) return;
14437
14562
  setOtpError(null);
14438
14563
  setIsVerifying(true);
@@ -14525,7 +14650,7 @@ var RedactoNoticeAssisted = ({
14525
14650
  handleSuccess,
14526
14651
  ts
14527
14652
  ]);
14528
- const handleDecline = (0, import_react12.useCallback)(() => {
14653
+ const handleDecline = (0, import_react13.useCallback)(() => {
14529
14654
  if (onDecline) {
14530
14655
  onDecline();
14531
14656
  return;
@@ -15421,20 +15546,29 @@ var RedactoNoticePreview = ({
15421
15546
  ) });
15422
15547
 
15423
15548
  // src/RedactoNoticeConsent/components/DigiLockerCallback.tsx
15424
- var import_react13 = require("react");
15549
+ var import_react14 = require("react");
15425
15550
  var import_jsx_runtime11 = require("react/jsx-runtime");
15551
+ var sameOriginUrlOrRoot = (candidate) => {
15552
+ if (!candidate) return "/";
15553
+ try {
15554
+ const url = new URL(candidate, window.location.origin);
15555
+ return url.origin === window.location.origin ? url.href : "/";
15556
+ } catch {
15557
+ return "/";
15558
+ }
15559
+ };
15426
15560
  var DigiLockerCallback = ({
15427
15561
  accessToken: propAccessToken,
15428
15562
  baseUrl,
15429
15563
  onSuccess,
15430
15564
  onError
15431
15565
  }) => {
15432
- const [status, setStatus] = (0, import_react13.useState)("processing");
15433
- const [message, setMessage] = (0, import_react13.useState)("Verifying your guardian...");
15434
- const [errorDetail, setErrorDetail] = (0, import_react13.useState)(null);
15435
- const retryTimeoutRef = (0, import_react13.useRef)(null);
15436
- const redirectTimeoutRef = (0, import_react13.useRef)(null);
15437
- const isMountedRef = (0, import_react13.useRef)(true);
15566
+ const [status, setStatus] = (0, import_react14.useState)("processing");
15567
+ const [message, setMessage] = (0, import_react14.useState)("Verifying your guardian...");
15568
+ const [errorDetail, setErrorDetail] = (0, import_react14.useState)(null);
15569
+ const retryTimeoutRef = (0, import_react14.useRef)(null);
15570
+ const redirectTimeoutRef = (0, import_react14.useRef)(null);
15571
+ const isMountedRef = (0, import_react14.useRef)(true);
15438
15572
  const getErrorMessage = (errorCode) => {
15439
15573
  switch (errorCode) {
15440
15574
  case "GUARDIAN_UNDER_18":
@@ -15451,7 +15585,7 @@ var DigiLockerCallback = ({
15451
15585
  return "Verification failed. Please try again.";
15452
15586
  }
15453
15587
  };
15454
- const redirectToOriginalPage = (0, import_react13.useCallback)(
15588
+ const redirectToOriginalPage = (0, import_react14.useCallback)(
15455
15589
  (originalUrl, verificationResult, verificationReference) => {
15456
15590
  updateConsentState({
15457
15591
  verificationResult,
@@ -15459,12 +15593,12 @@ var DigiLockerCallback = ({
15459
15593
  flowState: verificationResult === "verified" ? "consent-form" : "error"
15460
15594
  });
15461
15595
  redirectTimeoutRef.current = setTimeout(() => {
15462
- window.location.href = originalUrl;
15596
+ window.location.href = sameOriginUrlOrRoot(originalUrl);
15463
15597
  }, 1500);
15464
15598
  },
15465
15599
  []
15466
15600
  );
15467
- const handleCallback = (0, import_react13.useCallback)(async () => {
15601
+ const handleCallback = (0, import_react14.useCallback)(async () => {
15468
15602
  var _a, _b;
15469
15603
  try {
15470
15604
  const params = new URLSearchParams(window.location.search);
@@ -15531,7 +15665,7 @@ var DigiLockerCallback = ({
15531
15665
  return;
15532
15666
  }
15533
15667
  setMessage("Processing verification...");
15534
- const apiBaseUrl = baseUrl || storedBaseUrl;
15668
+ const apiBaseUrl = resolveEndpoints(baseUrl || storedBaseUrl).baseUrl;
15535
15669
  const response = await verifyGuardianStatus({
15536
15670
  accessToken,
15537
15671
  baseUrl: apiBaseUrl,
@@ -15679,7 +15813,7 @@ var DigiLockerCallback = ({
15679
15813
  }
15680
15814
  }
15681
15815
  }, [propAccessToken, baseUrl, onSuccess, onError, redirectToOriginalPage]);
15682
- (0, import_react13.useEffect)(() => {
15816
+ (0, import_react14.useEffect)(() => {
15683
15817
  injectCheckboxStyles();
15684
15818
  handleCallback();
15685
15819
  return () => {
@@ -15688,11 +15822,11 @@ var DigiLockerCallback = ({
15688
15822
  if (redirectTimeoutRef.current) clearTimeout(redirectTimeoutRef.current);
15689
15823
  };
15690
15824
  }, [handleCallback]);
15691
- const handleRetry = (0, import_react13.useCallback)(() => {
15825
+ const handleRetry = (0, import_react14.useCallback)(() => {
15692
15826
  const persistedState = getConsentState();
15693
15827
  if (persistedState == null ? void 0 : persistedState.originalUrl) {
15694
15828
  clearConsentState();
15695
- window.location.href = persistedState.originalUrl;
15829
+ window.location.href = sameOriginUrlOrRoot(persistedState.originalUrl);
15696
15830
  } else {
15697
15831
  window.location.href = "/";
15698
15832
  }