@active-reach/web-sdk 1.52.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/aegis-boot.min.js +2 -0
- package/dist/aegis-boot.min.js.map +1 -0
- package/dist/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-DMY0Q0rI.mjs → analytics-CM31xECy.mjs} +3 -211
- package/dist/analytics-CM31xECy.mjs.map +1 -0
- package/dist/boot.d.ts +46 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/boot.js +63 -0
- package/dist/boot.js.map +1 -0
- package/dist/core/bootstrap.d.ts.map +1 -1
- package/dist/core/prefetch-bundle-client.d.ts.map +1 -1
- package/dist/fetch-abort-Bs-Stg-I.mjs +216 -0
- package/dist/fetch-abort-Bs-Stg-I.mjs.map +1 -0
- package/dist/inapp/AegisInAppManager.d.ts +8 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/inapp/active-request.d.ts +63 -0
- package/dist/inapp/active-request.d.ts.map +1 -0
- package/dist/inapp/marketing-consent.d.ts +45 -0
- package/dist/inapp/marketing-consent.d.ts.map +1 -0
- package/dist/index.js +134 -183
- package/dist/index.js.map +1 -1
- package/dist/integrations/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/storage-D5jp9bO-.mjs +212 -0
- package/dist/storage-D5jp9bO-.mjs.map +1 -0
- package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
- package/dist/utils/fetch-abort.d.ts +17 -0
- package/dist/utils/fetch-abort.d.ts.map +1 -1
- package/dist/widgets/AegisWidgetManager.d.ts +2 -0
- package/dist/widgets/AegisWidgetManager.d.ts.map +1 -1
- package/package.json +9 -3
- package/dist/analytics-DMY0Q0rI.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -448,6 +448,20 @@ await runtime.initialize();
|
|
|
448
448
|
|
|
449
449
|
Campaign content, audience, schedule, and frequency caps are configured server-side in the dashboard (**In-App Personalization**). The SDK evaluates client-side triggers (scroll depth, time on page, exit intent, inactivity, custom events) and renders the matching campaign automatically.
|
|
450
450
|
|
|
451
|
+
### Early boot — start the first in-app read before your bundle
|
|
452
|
+
|
|
453
|
+
`@active-reach/web-sdk/boot` (CDN: `aegis-boot.min.js`) is a tiny script, safe to load before the page is interactive, that starts the page's first `/v1/in-app/active` read from its `data-*` attributes; `AegisMessageRuntime` adopts the answer when it initialises (same URL, same headers), so rails paint on the very first load. Warm the host first:
|
|
454
|
+
|
|
455
|
+
```html
|
|
456
|
+
<link rel="preconnect" href="https://YOUR_CELL.activereach.ai">
|
|
457
|
+
<link rel="dns-prefetch" href="https://YOUR_CELL.activereach.ai">
|
|
458
|
+
<script src="https://platform.active-reach.ai/sdk/aegis-boot.min.js"
|
|
459
|
+
data-write-key="YOUR_WRITE_KEY" data-api-host="https://YOUR_CELL.activereach.ai"
|
|
460
|
+
data-surface="storefront_catalog" data-screen="storefront.home"></script>
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
> **Bundling it yourself?** The package is `sideEffects: false`, so a bare `import '@active-reach/web-sdk/boot'` can be tree-shaken away; call `bootActive({ writeKey, apiHost, surface, screen })` explicitly, as early as your bundle runs.
|
|
464
|
+
|
|
451
465
|
### Drive triggers & identity from your app
|
|
452
466
|
|
|
453
467
|
```typescript
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var AegisBoot=function(e){"use strict";const t=new RegExp(`([?&])(${["t","k","code","session_code","aegis_pair","u","carrier_token"].join("|")})=([^&#\\s"'<>]+)`,"g");const o="aegis_new_visitor_session";let n=null;function r(){if(null!==n)return n;const e=function(){try{if("undefined"==typeof sessionStorage)return null;const e=sessionStorage.getItem(o);return"1"===e||"0"!==e&&null}catch{return null}}();return null!==e?(n=e,n):(n=function(){try{return"undefined"!=typeof localStorage&&null===localStorage.getItem("aegis_returning_user")}catch{return!1}}(),function(e){try{if("undefined"==typeof sessionStorage)return;sessionStorage.setItem(o,e?"1":"0")}catch{}}(n),n)}function i(){if("undefined"==typeof window||!window.location)return!1;try{return(e=new URLSearchParams(window.location.search||"")).has("preview_as_of")||"1"===e.get("section_names")||e.has("preview_store")||e.has("campaign_preview")||"admin"===e.get("preview")}catch{return!1}var e}const a="aegis_";class c{constructor(e={}){this.options=e,this.useLocalStorage=this.isLocalStorageAvailable()}isLocalStorageAvailable(){try{const e="__aegis_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}set(e,t,o=365){const n=a+e;if(this.useLocalStorage)try{const e={value:t,expiry:Date.now()+24*o*60*60*1e3};localStorage.setItem(n,JSON.stringify(e))}catch(r){console.warn("[Active Reach Storage] localStorage.setItem failed:",r)}this.setCookie(n,t,o)}get(e){const t=a+e;if(this.useLocalStorage)try{const e=localStorage.getItem(t);if(e){const o=JSON.parse(e);if(Date.now()<o.expiry)return o.value;localStorage.removeItem(t)}}catch(o){console.warn("[Active Reach Storage] localStorage.getItem failed:",o)}return this.getCookie(t)}remove(e){const t=a+e;if(this.useLocalStorage)try{localStorage.removeItem(t)}catch(o){console.warn("[Active Reach Storage] localStorage.removeItem failed:",o)}this.deleteCookie(t)}clear(){if(this.useLocalStorage)try{Object.keys(localStorage).forEach(e=>{e.startsWith(a)&&localStorage.removeItem(e)})}catch(e){console.warn("[Active Reach Storage] localStorage.clear failed:",e)}document.cookie.split(";").forEach(e=>{const t=e.split("=")[0].trim();t.startsWith(a)&&this.deleteCookie(t)})}setCookie(e,t,o){try{const n=new Date;n.setTime(n.getTime()+24*o*60*60*1e3);let r=`${e}=${t};${`expires=${n.toUTCString()}`};path=/`;if(this.options.secureCookie&&"https:"===window.location.protocol&&(r+=";Secure"),r+=";SameSite=Lax",this.options.cookieDomain)r+=`;domain=${this.options.cookieDomain}`;else if(this.options.crossDomain){const e=this.getRootDomain();e&&(r+=`;domain=${e}`)}document.cookie=r}catch(n){console.warn("[Active Reach Storage] setCookie failed:",n)}}getCookie(e){try{const t=e+"=",o=document.cookie.split(";");for(let e=0;e<o.length;e++){let n=o[e];for(;" "===n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(t))return n.substring(t.length,n.length)}}catch(t){console.warn("[Active Reach Storage] getCookie failed:",t)}return null}deleteCookie(e){try{let t=`${e}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`;if(this.options.cookieDomain)t+=`;domain=${this.options.cookieDomain}`;else if(this.options.crossDomain){const e=this.getRootDomain();e&&(t+=`;domain=${e}`)}document.cookie=t}catch(t){console.warn("[Active Reach Storage] deleteCookie failed:",t)}}getRootDomain(){try{const e=window.location.hostname;if(/^(\d{1,3}\.){3}\d{1,3}$/.test(e))return null;if("localhost"===e)return null;const t=e.split(".");return t.length<=2?`.${e}`:`.${t.slice(-2).join(".")}`}catch(e){return console.warn("[Active Reach Storage] getRootDomain failed:",e),null}}}const s=new Set(["bill","storefront_catalog","storefront_rewards","storefront_feedback","storefront_reviews","storefront_members","storefront_orders","storefront_account","storefront_referrals","external_website","external_mobile_screen"]);function l(){if("undefined"!=typeof document)try{return(new c).get("anon_id")??void 0}catch{return}}function u(){if("undefined"==typeof navigator)return"desktop";const e=navigator.userAgent;return/Mobi|Android/i.test(e)?"mobile":/iPad|Tablet/i.test(e)?"tablet":"desktop"}function d(){return"undefined"!=typeof window&&window.location?function(e){if("string"!=typeof e||0===e.length)return e;try{return e.replace(t,"$1$2=REDACTED")}catch{return e}}((window.location.pathname||"")+(window.location.search||"")):null}function f(e){return[d()??"/",e.surface??"",e.screen??"",e.locationId??"",(t=e.cartProductIds,null===t?"-":[...t].sort().join(","))].join("|");var t}function g(e){const t=new URLSearchParams({device_type:u(),page_url:d()??"/"});t.set("is_new_user",r()?"true":"false"),e.surface&&t.set("current_surface",e.surface),e.screen&&t.set("current_screen",e.screen),e.locationId&&t.set("location_id",e.locationId),null!==e.cartProductIds&&t.set("cart_product_ids",e.cartProductIds.join(","));const o=function(){if("undefined"==typeof window||!window.location)return null;try{const e=new URLSearchParams(window.location.search||"").get("preview_as_of");return e&&e.length<=600?e:null}catch{return null}}();o&&t.set("preview_as_of",o),e.previewOnly&&t.set("preview","1");const n={"X-Aegis-Write-Key":e.writeKey,"Content-Type":"application/json"};e.userId&&(n["X-User-ID"]=e.userId),e.contactId&&(n["X-Contact-ID"]=e.contactId),e.contactId&&e.contactToken&&(n["X-Contact-Token"]=e.contactToken),e.organizationId&&(n["X-Organization-ID"]=e.organizationId),e.propertyId&&(n["X-Property-Id"]=e.propertyId);const i=function(){try{return"undefined"==typeof localStorage?{}:JSON.parse(localStorage.getItem("aegis_ab_assignments")||"{}")}catch{return{}}}();return Object.keys(i).length>0&&(n["X-AB-Assignments"]=btoa(JSON.stringify(i))),{url:`${a=e.apiHost,a.replace(/\/+$/,"")}/v1/in-app/active?${t.toString()}`,headers:n,key:f(e)};var a}function h(e,t={},o=800){const n=Math.min(o,800);if("undefined"==typeof AbortController)return fetch(e,t);const r=new AbortController,i=t.signal;i&&(i.aborted?r.abort():i.addEventListener("abort",()=>r.abort(),{once:!0}));const a=setTimeout(()=>r.abort(),n);return fetch(e,{...t,signal:r.signal}).catch(e=>{throw clearTimeout(a),e})}function p(e){if("undefined"==typeof window||!e.writeKey||!e.apiHost)return null;const t=function(e,t){const o=t||e||null;return{surface:e&&s.has(e)?e:null,screen:o&&"page_view"!==o?o:null}}(e.surface,e.screen),o=g({apiHost:e.apiHost,writeKey:e.writeKey,userId:l(),contactId:e.contactId||void 0,contactToken:e.contactToken||void 0,organizationId:e.organizationId||void 0,propertyId:e.propertyId||void 0,surface:t.surface,screen:t.screen,locationId:e.locationId||null,cartProductIds:null,previewOnly:i()}),n=async function(e,t={},o=800){var n;try{return await h(e,t,o)}catch(r){if(!function(e){return!!e&&"object"==typeof e&&("AbortError"===e.name||"TimeoutError"===e.name)}(r)||(null==(n=t.signal)?void 0:n.aborted))throw r;return h(e,t,o)}}(o.url,{method:"GET",headers:o.headers,credentials:"include"});n.catch(()=>{});const r={key:o.key,url:o.url,headers:o.headers,promise:n};return function(e){"undefined"!=typeof window&&(window.__aegisActiveBoot=e)}(r),r}function w(e){if(!e)return null;const t=t=>e.getAttribute(`data-${t}`),o=t("write-key"),n=t("api-host");return o&&n?{writeKey:o,apiHost:n,surface:t("surface"),screen:t("screen"),locationId:t("location-id"),organizationId:t("organization-id"),propertyId:t("property-id"),contactId:t("contact-id"),contactToken:t("contact-token")}:null}function m(e=function(){return"undefined"==typeof document?null:document.currentScript??document.querySelector("script[data-aegis-boot][data-write-key]")}()){const t=w(e);return t?p(t):null}return m(),e.bootActive=p,e.bootFromScript=m,e.bootOptionsFromScript=w,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
2
|
+
//# sourceMappingURL=aegis-boot.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aegis-boot.min.js","sources":["../src/utils/redact-url.ts","../src/utils/visitor.ts","../src/utils/preview-as-of.ts","../src/utils/storage.ts","../src/inapp/active-request.ts","../src/utils/fetch-abort.ts","../src/boot.ts"],"sourcesContent":["/**\n * URL credential redaction — the browser-SDK layer (Aman 2026-09-13).\n *\n * A landing URL can carry a credential: `k` (one order's view key), `t` (the\n * server-verified landing token), `code` / `session_code` (claim codes),\n * `aegis_pair` (a device-pairing code) and `u` (a contact token). The SDK must\n * never SEND one of those values — not in a page object, an event property, a\n * beacon or a query string to our own API. What it sends instead is the key\n * with its value replaced by `REDACTED`, so the shape of the URL (and the fact\n * that a credential was present) survives while the secret does not.\n *\n * The server twin is `libs/data-governance/data_governance/credential_params.py`\n * (`CREDENTIAL_URL_PARAMS`, `REDACTED`). The two lists MUST stay identical; a\n * parity guard compares them. Change both in the same commit or neither.\n *\n * Deliberately NOT in the list: `aegis_code`. It is the attribution join key\n * (the short link's own code), not a credential — redacting it would sever\n * the link from the order it brought in.\n *\n * Reading is untouched. The SDK's own inbound param readers (`aegis_code`,\n * gclid / fbclid, utm, `aegis_pair` for pairing) still read `location.search`\n * directly; only what leaves the browser is redacted.\n *\n * Why a targeted regex and not `new URL()`: a URL round-trip re-encodes and\n * reorders the rest of the string, so the value we send would no longer be\n * the page the visitor was on. The regex touches only the credential values.\n *\n * What it does not see: a percent-encoded key (`%6B=` for `k`), a `;`\n * separator, or a key whose case differs (`K=`). The server list has the same\n * shape, so both layers agree on what counts as a match.\n */\n\nexport const CREDENTIAL_URL_PARAMS = [\n 't',\n 'k',\n 'code',\n 'session_code',\n 'aegis_pair',\n 'u',\n // The Shopify CarrierService callback token (2026-09-18). Server-to-server\n // today, so the SDK never sees one — it is here because the two lists are\n // ONE rule, and a list that is only correct for today's callers is not.\n 'carrier_token',\n] as const;\n\nexport const REDACTED = 'REDACTED';\n\n// Byte-identical to the server's rule (credential_params.py):\n// - a key counts ONLY when introduced by `?` or `&` — `utm_t=` is not `t=`,\n// and prose such as \"k=3 cakes\" (even at the start of a string) is untouched;\n// - the value stops at `& # whitespace \" ' < >`, so a URL inside JSON, HTML\n// or a sentence keeps its closing quote / bracket / following words (the\n// first cut used `[^&#]*` and swallowed `\"}` out of `{\"href\":\"…?k=9\"}`);\n// - an EMPTY value is left alone — there is nothing to hide.\n// Shared cases: libs/data-governance/tests/fixtures/credential_param_cases.json.\nconst CREDENTIAL_PARAM_PATTERN = new RegExp(\n `([?&])(${CREDENTIAL_URL_PARAMS.join('|')})=([^&#\\\\s\"'<>]+)`,\n 'g',\n);\n\n/**\n * Replace the value of every credential query param with `REDACTED`.\n * Idempotent, fragment-preserving, and it never throws: input it cannot\n * handle is returned unchanged.\n */\nexport function redactUrl(value: string): string {\n if (typeof value !== 'string' || value.length === 0) return value;\n try {\n return value.replace(CREDENTIAL_PARAM_PATTERN, `$1$2=${REDACTED}`);\n } catch {\n return value;\n }\n}\n\n/**\n * Walk plain objects / arrays and apply `redactUrl` to every string — the TS\n * twin of the server's `redact_credentials_deep` (same depth cap, 12).\n *\n * Added for the SERVER consumers of `channel.delivery.status_{cell}` (BK-87,\n * 2026-09-13): that topic is a dual-route that never passes the governance\n * engine, and its click/receipt payloads carry URLs (`metadata.original_url`,\n * `referrer`, provider echoes). analytics-consumer and event-ingress's\n * delivery-status bridge import THIS module by relative path, so there is one\n * TS rule, not a copy. Redacting per string value (before serialisation) keeps\n * JSON valid even when a value itself holds escaped JSON.\n *\n * Only plain objects and arrays are walked; anything else (Date, Buffer, class\n * instances) is returned as is.\n */\nexport function redactCredentialsDeep<T>(value: T, depth = 0): T {\n if (depth > 12) return value;\n if (typeof value === 'string') return redactUrl(value) as unknown as T;\n if (Array.isArray(value)) {\n return value.map((v: unknown) => redactCredentialsDeep(v, depth + 1)) as unknown as T;\n }\n if (value !== null && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n out[k] = redactCredentialsDeep(v, depth + 1);\n }\n return out as T;\n }\n return value;\n}\n","/**\n * New-visitor verdict — the ONE reader and writer of the returning-visitor\n * marker (2026-09-13).\n *\n * `/v1/in-app/active` and `/v1/sdk/prefetch-bundle` both take `is_new_user`,\n * and the server drops any campaign whose `display_rules.show_to_new_users_only`\n * is set when it arrives false. The SDK used to write `aegis_returning_user=1`\n * at the top of `AegisInAppManager.initialize()` and read it afterwards, inside\n * the fetch — so the read always saw its own write, every fetch said\n * `is_new_user=false`, and a new-users-only campaign could never be served.\n *\n * The rule this module enforces: the marker is read ONCE, before anything\n * writes it, and the verdict is held for the whole browsing session.\n *\n * - `isNewVisitor()` resolves the verdict on first call and caches it in\n * memory (this page load) and in sessionStorage (later page loads in the\n * same tab session), so every fetch in a session sends the same value and\n * the verdict does not flip after the marker is written.\n * - `markReturningVisitor()` is the only writer. It resolves the verdict\n * first, so no call order can make the read see the write.\n *\n * Storage unavailable (SSR, blocked site data, a browser that throws on\n * access): the verdict is RETURNING (`false`). \"New\" is a positive claim that\n * unlocks first-visit-only messages; when the SDK cannot remember a visit it\n * cannot prove one never happened, and because the marker can never be saved,\n * answering \"new\" would re-show a first-visit message on every page of every\n * visit forever. `false` is also what the server assumes when the parameter is\n * absent, so an unknown visitor reads the same on both sides.\n */\n\nconst RETURNING_MARKER_KEY = 'aegis_returning_user';\nconst SESSION_VERDICT_KEY = 'aegis_new_visitor_session';\n\nlet cachedVerdict: boolean | null = null;\n\nfunction readSessionVerdict(): boolean | null {\n try {\n if (typeof sessionStorage === 'undefined') return null;\n const stored = sessionStorage.getItem(SESSION_VERDICT_KEY);\n if (stored === '1') return true;\n if (stored === '0') return false;\n return null;\n } catch {\n return null;\n }\n}\n\nfunction writeSessionVerdict(verdict: boolean): void {\n try {\n if (typeof sessionStorage === 'undefined') return;\n sessionStorage.setItem(SESSION_VERDICT_KEY, verdict ? '1' : '0');\n } catch {\n // sessionStorage blocked — the in-memory cache still holds this page load\n }\n}\n\nfunction readMarkerVerdict(): boolean {\n try {\n if (typeof localStorage === 'undefined') return false;\n return localStorage.getItem(RETURNING_MARKER_KEY) === null;\n } catch {\n return false;\n }\n}\n\n/**\n * Whether this browsing session belongs to a visitor the SDK has never seen\n * before. Stable for the whole session; see the module doc for the default\n * when storage is unavailable.\n */\nexport function isNewVisitor(): boolean {\n if (cachedVerdict !== null) return cachedVerdict;\n const sessionVerdict = readSessionVerdict();\n if (sessionVerdict !== null) {\n cachedVerdict = sessionVerdict;\n return cachedVerdict;\n }\n cachedVerdict = readMarkerVerdict();\n writeSessionVerdict(cachedVerdict);\n return cachedVerdict;\n}\n\n/**\n * Record that this visitor has now been seen, so the NEXT session reads as\n * returning. Resolves the current session's verdict before writing.\n */\nexport function markReturningVisitor(): void {\n isNewVisitor();\n try {\n if (typeof localStorage === 'undefined') return;\n localStorage.setItem(RETURNING_MARKER_KEY, '1');\n } catch {\n // storage blocked — nothing to remember; the verdict stays as resolved\n }\n}\n\n/** Test seam: forget the in-memory verdict, as a fresh page load would. */\nexport function resetVisitorVerdictCacheForTests(): void {\n cachedVerdict = null;\n}\n","/**\n * The store editor's dated whole-page preview (Amita RULED 11-12): the preview\n * link carries a SIGNED `preview_as_of` token for one brand. The token reaches\n * /v1/in-app/active unchanged (the cell honours it only for that brand).\n *\n * A page whose address carries the token, or any other editor preview marker\n * (`isPreviewPage`), is a PREVIEW, never a visit, whatever runtime the host\n * mounted on it: the in-app runtime treats it as previewOnly (reads and draws,\n * writes nothing) and the analytics core records nothing. One reader, so every\n * runtime agrees on what a preview is.\n */\n\n/** Longest token the SDK forwards (a signed `{org, as_of}` pair is far shorter). */\nconst MAX_TOKEN_LENGTH = 600;\n\n/** The dated whole-page preview's signed token from the page address, or null. */\nexport function previewAsOfToken(): string | null {\n if (typeof window === 'undefined' || !window.location) return null;\n try {\n const v = new URLSearchParams(window.location.search || '').get('preview_as_of');\n return v && v.length <= MAX_TOKEN_LENGTH ? v : null;\n } catch {\n return null;\n }\n}\n\n/** True on a dated preview page (the link carries the Date's token). */\nexport function isDatedPreviewPage(): boolean {\n return previewAsOfToken() !== null;\n}\n\n/**\n * The address markers of every editor preview link (Amita RULED 11-12: a\n * preview never records engagement, dated or not):\n * - `preview_as_of` the whole-page preview with a Date;\n * - `section_names=1` the whole-page preview (page-model `scopedPreviewUrl`\n * always adds it, with or without a Date or Store);\n * - `preview_store` the whole-page preview's Store on a page without a\n * per-store address;\n * - `campaign_preview` the campaign editor's live-page iframe;\n * - `preview=admin` the storefront admin's iframe.\n * A customer link carries none of them; a customer who adds one only stops\n * their own page from writing.\n */\nfunction hasEditorPreviewMarker(search: URLSearchParams): boolean {\n return (\n search.has('preview_as_of') ||\n search.get('section_names') === '1' ||\n search.has('preview_store') ||\n search.has('campaign_preview') ||\n search.get('preview') === 'admin'\n );\n}\n\n/** True on ANY editor preview page: nothing on it may write (no page view, no\n * identify, no impression, no returning-visitor mark, no consumed state).\n * The one reader every runtime (analytics core, in-app runtime, the host's\n * pixels) asks, so they all agree on what a preview is. */\nexport function isPreviewPage(): boolean {\n if (typeof window === 'undefined' || !window.location) return false;\n try {\n return hasEditorPreviewMarker(new URLSearchParams(window.location.search || ''));\n } catch {\n return false;\n }\n}\n","const STORAGE_PREFIX = 'aegis_';\n\nexport interface StorageOptions {\n cookieDomain?: string | null;\n secureCookie?: boolean;\n crossDomain?: boolean;\n}\n\nexport class Storage {\n private useLocalStorage: boolean;\n private options: StorageOptions;\n\n constructor(options: StorageOptions = {}) {\n this.options = options;\n this.useLocalStorage = this.isLocalStorageAvailable();\n }\n\n private isLocalStorageAvailable(): boolean {\n try {\n const test = '__aegis_test__';\n localStorage.setItem(test, test);\n localStorage.removeItem(test);\n return true;\n } catch {\n return false;\n }\n }\n\n set(key: string, value: string, expiryDays: number = 365): void {\n const fullKey = STORAGE_PREFIX + key;\n\n if (this.useLocalStorage) {\n try {\n const item = {\n value,\n expiry: Date.now() + expiryDays * 24 * 60 * 60 * 1000,\n };\n localStorage.setItem(fullKey, JSON.stringify(item));\n } catch (error) {\n console.warn('[Active Reach Storage] localStorage.setItem failed:', error);\n }\n }\n\n this.setCookie(fullKey, value, expiryDays);\n }\n\n get(key: string): string | null {\n const fullKey = STORAGE_PREFIX + key;\n\n if (this.useLocalStorage) {\n try {\n const itemStr = localStorage.getItem(fullKey);\n if (itemStr) {\n const item = JSON.parse(itemStr);\n if (Date.now() < item.expiry) {\n return item.value;\n } else {\n localStorage.removeItem(fullKey);\n }\n }\n } catch (error) {\n console.warn('[Active Reach Storage] localStorage.getItem failed:', error);\n }\n }\n\n return this.getCookie(fullKey);\n }\n\n remove(key: string): void {\n const fullKey = STORAGE_PREFIX + key;\n\n if (this.useLocalStorage) {\n try {\n localStorage.removeItem(fullKey);\n } catch (error) {\n console.warn('[Active Reach Storage] localStorage.removeItem failed:', error);\n }\n }\n\n this.deleteCookie(fullKey);\n }\n\n clear(): void {\n if (this.useLocalStorage) {\n try {\n const keys = Object.keys(localStorage);\n keys.forEach((key) => {\n if (key.startsWith(STORAGE_PREFIX)) {\n localStorage.removeItem(key);\n }\n });\n } catch (error) {\n console.warn('[Active Reach Storage] localStorage.clear failed:', error);\n }\n }\n\n const cookies = document.cookie.split(';');\n cookies.forEach((cookie) => {\n const key = cookie.split('=')[0].trim();\n if (key.startsWith(STORAGE_PREFIX)) {\n this.deleteCookie(key);\n }\n });\n }\n\n private setCookie(name: string, value: string, days: number): void {\n try {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n const expires = `expires=${date.toUTCString()}`;\n \n let cookieStr = `${name}=${value};${expires};path=/`;\n \n if (this.options.secureCookie && window.location.protocol === 'https:') {\n cookieStr += ';Secure';\n }\n \n cookieStr += ';SameSite=Lax';\n \n if (this.options.cookieDomain) {\n cookieStr += `;domain=${this.options.cookieDomain}`;\n } else if (this.options.crossDomain) {\n const domain = this.getRootDomain();\n if (domain) {\n cookieStr += `;domain=${domain}`;\n }\n }\n \n document.cookie = cookieStr;\n } catch (error) {\n console.warn('[Active Reach Storage] setCookie failed:', error);\n }\n }\n\n private getCookie(name: string): string | null {\n try {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n \n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') {\n c = c.substring(1, c.length);\n }\n if (c.indexOf(nameEQ) === 0) {\n return c.substring(nameEQ.length, c.length);\n }\n }\n } catch (error) {\n console.warn('[Active Reach Storage] getCookie failed:', error);\n }\n \n return null;\n }\n\n private deleteCookie(name: string): void {\n try {\n let cookieStr = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`;\n \n if (this.options.cookieDomain) {\n cookieStr += `;domain=${this.options.cookieDomain}`;\n } else if (this.options.crossDomain) {\n const domain = this.getRootDomain();\n if (domain) {\n cookieStr += `;domain=${domain}`;\n }\n }\n \n document.cookie = cookieStr;\n } catch (error) {\n console.warn('[Active Reach Storage] deleteCookie failed:', error);\n }\n }\n\n private getRootDomain(): string | null {\n try {\n const hostname = window.location.hostname;\n \n if (/^(\\d{1,3}\\.){3}\\d{1,3}$/.test(hostname)) {\n return null;\n }\n \n if (hostname === 'localhost') {\n return null;\n }\n \n const parts = hostname.split('.');\n \n if (parts.length <= 2) {\n return `.${hostname}`;\n }\n \n return `.${parts.slice(-2).join('.')}`;\n } catch (error) {\n console.warn('[Active Reach Storage] getRootDomain failed:', error);\n return null;\n }\n }\n}\n","/**\n * The ONE builder for the `/v1/in-app/active` request (Aman 2026-11-19).\n *\n * `AegisInAppManager.refreshCampaigns()` and the early-boot script\n * (`@active-reach/web-sdk/boot`, src/boot.ts) build the SAME URL, headers and\n * request key through this module, so a response the boot script started\n * before the SDK loaded is exactly the one the manager would have asked for,\n * and the manager adopts it instead of asking again. Never a second builder.\n *\n * The request key (`activeRequestKey`) is the page context the answer is for:\n * redacted page URL + surface + screen + outlet + cart ids. Identity and the\n * write key travel in headers and are matched separately when a boot answer is\n * adopted (`takeActiveBoot`).\n */\nimport { redactUrl } from '../utils/redact-url';\nimport { isNewVisitor } from '../utils/visitor';\nimport { previewAsOfToken } from '../utils/preview-as-of';\nimport { Storage } from '../utils/storage';\n\n/** The logical surfaces a host may declare (aegis.page(name) / config.surface). */\nexport const KNOWN_SURFACES: ReadonlySet<string> = new Set([\n 'bill',\n 'storefront_catalog',\n 'storefront_rewards',\n 'storefront_feedback',\n 'storefront_reviews',\n 'storefront_members',\n 'storefront_orders',\n 'storefront_account',\n 'storefront_referrals',\n 'external_website',\n 'external_mobile_screen',\n]);\n\nexport interface ActiveRequestContext {\n apiHost: string;\n writeKey: string;\n /** The visitor's anonymous id (analytics `anon_id`) or the host's user id. */\n userId?: string;\n contactId?: string;\n contactToken?: string;\n organizationId?: string;\n propertyId?: string;\n surface: string | null;\n screen: string | null;\n locationId: string | null;\n /** `null` = no cart known (param omitted); `[]` = an empty cart (sent empty). */\n cartProductIds: string[] | null;\n previewOnly: boolean;\n}\n\nexport interface ActiveRequest {\n url: string;\n headers: Record<string, string>;\n key: string;\n}\n\n/** The page context a host declares before init, normalised exactly as the\n * manager's constructor records it: only a known surface sets the surface,\n * the screen falls back to the surface, and `page_view` is no screen. */\nexport function normalizePageContext(\n surface: string | null | undefined,\n screen: string | null | undefined,\n): { surface: string | null; screen: string | null } {\n const s = surface && KNOWN_SURFACES.has(surface) ? surface : null;\n const sc = screen || surface || null;\n return { surface: s, screen: sc && sc !== 'page_view' ? sc : null };\n}\n\n/** The visitor's anonymous id as the analytics SDK stores it (`anon_id`). */\nexport function readAnonIdFromStorage(): string | undefined {\n if (typeof document === 'undefined') return undefined;\n try {\n const storage = new Storage();\n return storage.get('anon_id') ?? undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function detectDeviceType(): 'mobile' | 'desktop' | 'tablet' {\n if (typeof navigator === 'undefined') return 'desktop';\n const ua = navigator.userAgent;\n if (/Mobi|Android/i.test(ua)) return 'mobile';\n if (/iPad|Tablet/i.test(ua)) return 'tablet';\n return 'desktop';\n}\n\nexport function readABAssignments(): Record<string, string> {\n try {\n if (typeof localStorage === 'undefined') return {};\n return JSON.parse(localStorage.getItem('aegis_ab_assignments') || '{}');\n } catch {\n return {};\n }\n}\n\n/** The redacted page URL the request sends as `page_url` (null outside a window). */\nexport function currentPageUrl(): string | null {\n if (typeof window === 'undefined' || !window.location) return null;\n return redactUrl((window.location.pathname || '') + (window.location.search || ''));\n}\n\n/** The cart ids as a request-key part: sorted + deduped so a reorder is not a\n * change; `-` = no cart known, distinct from `` = an empty cart. */\nexport function cartKeyPartOf(ids: string[] | null): string {\n return ids === null ? '-' : [...ids].sort().join(',');\n}\n\nexport function activeRequestKey(\n ctx: Pick<ActiveRequestContext, 'surface' | 'screen' | 'locationId' | 'cartProductIds'>,\n): string {\n const url = currentPageUrl() ?? '/';\n return [url, ctx.surface ?? '', ctx.screen ?? '', ctx.locationId ?? '', cartKeyPartOf(ctx.cartProductIds)].join('|');\n}\n\n/** The api host without a trailing slash (one spelling for the request URL). */\nexport function normalizeApiHost(apiHost: string): string {\n return apiHost.replace(/\\/+$/, '');\n}\n\nexport function buildActiveRequest(ctx: ActiveRequestContext): ActiveRequest {\n const context = new URLSearchParams({\n device_type: detectDeviceType(),\n page_url: currentPageUrl() ?? '/',\n });\n // Geo is resolved server-side from IP. The new-visitor verdict is fixed for\n // the session (utils/visitor.ts), so every request in a session sends the\n // same value, the boot script's included.\n context.set('is_new_user', isNewVisitor() ? 'true' : 'false');\n if (ctx.surface) context.set('current_surface', ctx.surface);\n if (ctx.screen) context.set('current_screen', ctx.screen);\n if (ctx.locationId) context.set('location_id', ctx.locationId);\n if (ctx.cartProductIds !== null) context.set('cart_product_ids', ctx.cartProductIds.join(','));\n const previewAsOf = previewAsOfToken();\n if (previewAsOf) context.set('preview_as_of', previewAsOf);\n if (ctx.previewOnly) context.set('preview', '1');\n\n const headers: Record<string, string> = {\n 'X-Aegis-Write-Key': ctx.writeKey,\n 'Content-Type': 'application/json',\n };\n if (ctx.userId) headers['X-User-ID'] = ctx.userId;\n if (ctx.contactId) headers['X-Contact-ID'] = ctx.contactId;\n if (ctx.contactId && ctx.contactToken) headers['X-Contact-Token'] = ctx.contactToken;\n if (ctx.organizationId) headers['X-Organization-ID'] = ctx.organizationId;\n if (ctx.propertyId) headers['X-Property-Id'] = ctx.propertyId;\n const abAssignments = readABAssignments();\n if (Object.keys(abAssignments).length > 0) {\n headers['X-AB-Assignments'] = btoa(JSON.stringify(abAssignments));\n }\n // The host is normalised HERE, for the manager and the boot script alike: a\n // configured `https://api.example/` and `https://api.example` build the same\n // URL, so a boot answer is adopted either way (portal audit 2026-11-20).\n return {\n url: `${normalizeApiHost(ctx.apiHost)}/v1/in-app/active?${context.toString()}`,\n headers,\n key: activeRequestKey(ctx),\n };\n}\n\n/** What the early-boot script leaves on `window.__aegisActiveBoot`. */\nexport interface ActiveBootHandle {\n key: string;\n url: string;\n headers: Record<string, string>;\n promise: Promise<Response>;\n}\n\nexport const ACTIVE_BOOT_GLOBAL = '__aegisActiveBoot';\n\ntype BootWindow = Window & { [ACTIVE_BOOT_GLOBAL]?: ActiveBootHandle };\n\nexport function readActiveBoot(): ActiveBootHandle | undefined {\n if (typeof window === 'undefined') return undefined;\n return (window as BootWindow)[ACTIVE_BOOT_GLOBAL];\n}\n\nexport function storeActiveBoot(handle: ActiveBootHandle): void {\n if (typeof window === 'undefined') return;\n (window as BootWindow)[ACTIVE_BOOT_GLOBAL] = handle;\n}\n\nexport function clearActiveBoot(): void {\n if (typeof window === 'undefined') return;\n delete (window as BootWindow)[ACTIVE_BOOT_GLOBAL];\n}\n\n/** A boot answer is the manager's own when it asked the same URL with the same\n * headers. The one header the manager may ADD is `X-User-ID`: on a first\n * visit the analytics SDK mints the anonymous id after the boot script ran,\n * and the server holds no state for a brand-new id, so the answer is the same. */\nexport function bootMatches(boot: Pick<ActiveBootHandle, 'key' | 'url' | 'headers'>, req: ActiveRequest): boolean {\n if (boot.key !== req.key || boot.url !== req.url) return false;\n for (const [name, value] of Object.entries(boot.headers)) {\n if (req.headers[name] !== value) return false;\n }\n for (const name of Object.keys(req.headers)) {\n if (!(name in boot.headers) && name !== 'X-User-ID') return false;\n }\n return true;\n}\n\n/** Adopt the early-boot answer for `req` (the global is cleared either way:\n * a boot answer is for the page's FIRST request only). */\nexport function takeActiveBoot(req: ActiveRequest): Promise<Response> | null {\n const boot = readActiveBoot();\n if (!boot) return null;\n clearActiveBoot();\n return bootMatches(boot, req) ? boot.promise : null;\n}\n","/**\n * The SDK's client abort (Aman 11-01, Q3 speed ruling / WP17 L14): SDK and\n * rail reads answer p95 < 300 ms, and the client gives up at 800 ms so a slow\n * gateway never holds the host page. Each caller then falls back (last config,\n * last bundle, last good rail; bootstrap raises) and never blocks render or\n * checkout.\n *\n * The timer keeps running after the headers arrive, so the BODY read is inside\n * the same 800 ms budget: a body still streaming at 800 ms rejects with an\n * AbortError, which every caller already treats as a failed fetch. An abort\n * after the body was read is a no-op.\n *\n * Uses an AbortController + setTimeout rather than `AbortSignal.timeout`\n * (Safari < 16 lacks it). A caller-supplied signal still aborts the request.\n *\n * Guard: tests/drift-sdk-fetch-abort.test.ts (every listed SDK read passes\n * through here with a budget <= 800 ms).\n */\nexport const SDK_FETCH_ABORT_MS = 800;\n\nexport function fetchWithAbort(\n input: string,\n init: RequestInit = {},\n timeoutMs: number = SDK_FETCH_ABORT_MS\n): Promise<Response> {\n const budget = Math.min(timeoutMs, SDK_FETCH_ABORT_MS);\n if (typeof AbortController === 'undefined') {\n return fetch(input, init);\n }\n const controller = new AbortController();\n const outer = init.signal;\n if (outer) {\n if (outer.aborted) controller.abort();\n else outer.addEventListener('abort', () => controller.abort(), { once: true });\n }\n const timer = setTimeout(() => controller.abort(), budget);\n return fetch(input, { ...init, signal: controller.signal }).catch((err: unknown) => {\n clearTimeout(timer);\n throw err;\n });\n}\n\n/**\n * A BOOT read: the first answer a page gets from an endpoint, with nothing to\n * fall back on (no last bundle, no saved rails, no cookie). On a cold\n * connection the 800 ms budget is spent on DNS + TCP + TLS + the CORS\n * preflight, and the browser aborts before the real request ever leaves\n * (measured on the Cake House store 2026-11-19: two `OPTIONS /v1/in-app/active`\n * reached the gateway, no GET followed, and the page stayed empty until a\n * reload). The second try rides the warm connection and lands in 100-250 ms,\n * so one retry on an ABORT (never on an HTTP status or a network error) is\n * the whole fix. Budget: 800 ms per try, one retry on abort only (Aman\n * 2026-11-20; the 11-01 ruling reads \"per try\", no cap on the total). A\n * caller's own aborted signal is honoured and never retried. Readers that already hold an answer\n * (a later poll) keep using fetchWithAbort: a stale answer beats a late one.\n *\n * Guard: tests/drift-sdk-fetch-abort.test.ts (the boot reads use this helper).\n */\nexport async function fetchWithAbortRetry(\n input: string,\n init: RequestInit = {},\n timeoutMs: number = SDK_FETCH_ABORT_MS\n): Promise<Response> {\n try {\n return await fetchWithAbort(input, init, timeoutMs);\n } catch (err) {\n if (!isAbortError(err) || init.signal?.aborted) throw err;\n return fetchWithAbort(input, init, timeoutMs);\n }\n}\n\n/** True when `err` is the abort raised by fetchWithAbort's budget (or any abort). */\nexport function isAbortError(err: unknown): boolean {\n return (\n !!err &&\n typeof err === 'object' &&\n ((err as { name?: string }).name === 'AbortError' || (err as { name?: string }).name === 'TimeoutError')\n );\n}\n","/**\n * `@active-reach/web-sdk/boot` — the early-boot script (Aman 2026-11-19,\n * \"preconnect + earlier boot\").\n *\n * A tiny script, safe to load before the page is interactive, that starts the\n * page's FIRST `/v1/in-app/active` read the moment the HTML is parsed, instead\n * of after the app bundle loaded, hydrated and built the SDK runtime (the\n * Cake House store paid ~0.7 s of that on a phone, then lost the request to\n * the cold connection). The request is built by the SAME builder the manager\n * uses (inapp/active-request.ts), so when `AegisInAppManager.refreshCampaigns`\n * runs it finds `window.__aegisActiveBoot`, sees its own URL + headers, and\n * adopts the answer in flight. A boot for a different page context (or a\n * different identity) is ignored and cleared; nothing is asked twice.\n *\n * Script tag (IIFE build `aegis-boot.min.js`, or this module bundled):\n * <script src=\".../aegis-boot.min.js\" data-write-key=\"wk_…\"\n * data-api-host=\"https://api.active-reach.ai\" data-surface=\"storefront_catalog\"\n * data-screen=\"storefront.home\" data-location-id=\"loc_…\"\n * data-organization-id=\"org_…\" data-property-id=\"prop_…\"></script>\n * Optional: data-contact-id / data-contact-token (a signed-in visitor the host\n * already knows server-side); without them an identified session is not\n * adopted (the manager's answer carries X-Contact-ID, the boot's did not).\n *\n * Same endpoint, same budget: one 800 ms try plus one retry on an abort\n * (utils/fetch-abort.ts). No new API.\n */\nimport {\n buildActiveRequest,\n normalizePageContext,\n readAnonIdFromStorage,\n storeActiveBoot,\n type ActiveBootHandle,\n} from './inapp/active-request';\nimport { fetchWithAbortRetry } from './utils/fetch-abort';\nimport { isPreviewPage } from './utils/preview-as-of';\n\nexport interface AegisActiveBootOptions {\n writeKey: string;\n apiHost: string;\n surface?: string | null;\n screen?: string | null;\n locationId?: string | null;\n organizationId?: string | null;\n propertyId?: string | null;\n contactId?: string | null;\n contactToken?: string | null;\n}\n\n/** Start the page's first /active read and publish it for the SDK to adopt.\n * Returns the handle, or null outside a browser / with no write key. */\nexport function bootActive(options: AegisActiveBootOptions): ActiveBootHandle | null {\n if (typeof window === 'undefined' || !options.writeKey || !options.apiHost) return null;\n const page = normalizePageContext(options.surface, options.screen);\n const req = buildActiveRequest({\n apiHost: options.apiHost,\n writeKey: options.writeKey,\n userId: readAnonIdFromStorage(),\n contactId: options.contactId || undefined,\n contactToken: options.contactToken || undefined,\n organizationId: options.organizationId || undefined,\n propertyId: options.propertyId || undefined,\n surface: page.surface,\n screen: page.screen,\n locationId: options.locationId || null,\n cartProductIds: null,\n // A preview page records nothing; the manager sends `preview=1` there too.\n previewOnly: isPreviewPage(),\n });\n const promise = fetchWithAbortRetry(req.url, {\n method: 'GET',\n headers: req.headers,\n credentials: 'include',\n });\n // An unadopted boot (the SDK never loaded, or asked for another page) must\n // not surface as an unhandled rejection.\n promise.catch(() => undefined);\n const handle: ActiveBootHandle = { key: req.key, url: req.url, headers: req.headers, promise };\n storeActiveBoot(handle);\n return handle;\n}\n\n/** Read the options off a script tag's data-* attributes. */\nexport function bootOptionsFromScript(script: Element | null): AegisActiveBootOptions | null {\n if (!script) return null;\n const attr = (name: string): string | null => script.getAttribute(`data-${name}`);\n const writeKey = attr('write-key');\n const apiHost = attr('api-host');\n if (!writeKey || !apiHost) return null;\n return {\n writeKey,\n apiHost,\n surface: attr('surface'),\n screen: attr('screen'),\n locationId: attr('location-id'),\n organizationId: attr('organization-id'),\n propertyId: attr('property-id'),\n contactId: attr('contact-id'),\n contactToken: attr('contact-token'),\n };\n}\n\n/** Boot from the running script tag's data-* attributes (no-op without them). */\nexport function bootFromScript(script: Element | null = currentScript()): ActiveBootHandle | null {\n const options = bootOptionsFromScript(script);\n return options ? bootActive(options) : null;\n}\n\nfunction currentScript(): Element | null {\n if (typeof document === 'undefined') return null;\n return document.currentScript ?? document.querySelector('script[data-aegis-boot][data-write-key]');\n}\n\n// Auto-run for the script-tag distribution: a tag with data-write-key boots\n// on load; an npm import with no such tag does nothing until bootActive().\nbootFromScript();\n"],"names":["CREDENTIAL_PARAM_PATTERN","RegExp","join","SESSION_VERDICT_KEY","cachedVerdict","isNewVisitor","sessionVerdict","sessionStorage","stored","getItem","readSessionVerdict","localStorage","readMarkerVerdict","verdict","setItem","writeSessionVerdict","isPreviewPage","window","location","search","URLSearchParams","has","get","STORAGE_PREFIX","Storage","constructor","options","this","useLocalStorage","isLocalStorageAvailable","test","removeItem","set","key","value","expiryDays","fullKey","item","expiry","Date","now","JSON","stringify","error","console","warn","setCookie","itemStr","parse","getCookie","remove","deleteCookie","clear","Object","keys","forEach","startsWith","document","cookie","split","trim","name","days","date","setTime","getTime","cookieStr","toUTCString","secureCookie","protocol","cookieDomain","crossDomain","domain","getRootDomain","nameEQ","ca","i","length","c","charAt","substring","indexOf","hostname","parts","slice","KNOWN_SURFACES","Set","readAnonIdFromStorage","detectDeviceType","navigator","ua","userAgent","currentPageUrl","replace","redactUrl","pathname","activeRequestKey","ctx","surface","screen","locationId","ids","cartProductIds","sort","buildActiveRequest","context","device_type","page_url","previewAsOf","v","previewAsOfToken","previewOnly","headers","writeKey","userId","contactId","contactToken","organizationId","propertyId","abAssignments","readABAssignments","btoa","url","apiHost","toString","fetchWithAbort","input","init","timeoutMs","budget","Math","min","AbortController","fetch","controller","outer","signal","aborted","abort","addEventListener","once","timer","setTimeout","catch","err","clearTimeout","bootActive","page","sc","normalizePageContext","req","promise","async","isAbortError","_a","fetchWithAbortRetry","method","credentials","handle","storeActiveBoot","bootOptionsFromScript","script","attr","getAttribute","bootFromScript","currentScript","querySelector"],"mappings":"uCAgCO,MAuBDA,EAA2B,IAAIC,OACnC,UAxBmC,CACnC,IACA,IACA,OACA,eACA,aACA,IAIA,iBAcgCC,KAAK,wBACrC,KC3BF,MACMC,EAAsB,4BAE5B,IAAIC,EAAgC,KAqC7B,SAASC,IACd,GAAsB,OAAlBD,EAAwB,OAAOA,EACnC,MAAME,EArCR,WACE,IACE,GAA8B,oBAAnBC,eAAgC,OAAO,KAClD,MAAMC,EAASD,eAAeE,QAAQN,GACtC,MAAe,MAAXK,GACW,MAAXA,GACG,IACT,CAAA,MACE,OAAO,IACT,CACF,CA2ByBE,GACvB,OAAuB,OAAn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