@apextelemed/partner-core 0.23.0-dev.80 → 0.23.0-dev.82

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.
Files changed (40) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +3 -3
  3. package/dist/api/index.jsx +3 -3
  4. package/dist/chunk/{IM27S2HM.jsx → 2TGKQDQV.jsx} +2 -2
  5. package/dist/chunk/{M6PV6FON.js → 4GYQYONL.js} +5 -7
  6. package/dist/chunk/4GYQYONL.js.map +1 -0
  7. package/dist/chunk/{KPFIVXLP.jsx → 6TJPPA6S.jsx} +32 -10
  8. package/dist/chunk/{2OXKVNNY.js → 6TO6ZQVD.js} +39 -11
  9. package/dist/chunk/6TO6ZQVD.js.map +1 -0
  10. package/dist/chunk/{TNGDSXSC.js → 74A4ERWQ.js} +3 -3
  11. package/dist/chunk/{TNGDSXSC.js.map → 74A4ERWQ.js.map} +1 -1
  12. package/dist/chunk/{6X2C7K6K.jsx → GIJCNQCB.jsx} +2 -2
  13. package/dist/chunk/{AA7EUOB6.jsx → GWVFWHTO.jsx} +1 -1
  14. package/dist/chunk/{GF4CVY2S.js → K2TKMLIY.js} +3 -3
  15. package/dist/chunk/{GF4CVY2S.js.map → K2TKMLIY.js.map} +1 -1
  16. package/dist/chunk/{2GTWVO52.jsx → L5DLLO2G.jsx} +5 -5
  17. package/dist/chunk/{PXICBLZI.jsx → L7TIWRSK.jsx} +5 -7
  18. package/dist/chunk/{BJXH2J3Z.js → PK74TNA6.js} +3 -3
  19. package/dist/chunk/{BJXH2J3Z.js.map → PK74TNA6.js.map} +1 -1
  20. package/dist/chunk/{MCZVL3GO.js → SAHG4GZB.js} +6 -6
  21. package/dist/chunk/{MCZVL3GO.js.map → SAHG4GZB.js.map} +1 -1
  22. package/dist/chunk/{3PUSGUJX.js → Y74YTJXR.js} +2 -2
  23. package/dist/chunk/{3PUSGUJX.js.map → Y74YTJXR.js.map} +1 -1
  24. package/dist/chunk/{QKCN523Q.jsx → Z33DIIG6.jsx} +2 -2
  25. package/dist/{client-CsxG6Mdf.d.ts → client-BdY7wkDp.d.ts} +6 -0
  26. package/dist/flows/index.d.ts +3 -2
  27. package/dist/flows/index.js +6 -6
  28. package/dist/flows/index.jsx +8 -6
  29. package/dist/index/index.d.ts +2 -2
  30. package/dist/index/index.js +7 -7
  31. package/dist/index/index.jsx +9 -7
  32. package/dist/pages/index.d.ts +1 -1
  33. package/dist/pages/index.js +5 -5
  34. package/dist/pages/index.jsx +5 -5
  35. package/dist/stores/index.d.ts +1 -1
  36. package/dist/stores/index.js +2 -2
  37. package/dist/stores/index.jsx +2 -2
  38. package/package.json +1 -1
  39. package/dist/chunk/2OXKVNNY.js.map +0 -1
  40. package/dist/chunk/M6PV6FON.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { onTokensCleared, authStorageKey, getTokens, usersApi, ApiError, affiliateAuthStorageKey, getAffiliateTokens, affiliatePortalApi, clearTokens, authApi, clearAffiliateTokens, setTokens, setAffiliateTokens } from './3PUSGUJX.js';
1
+ import { onTokensCleared, authStorageKey, getTokens, usersApi, ApiError, affiliateAuthStorageKey, getAffiliateTokens, affiliatePortalApi, clearTokens, authApi, clearAffiliateTokens, setTokens, setAffiliateTokens } from './Y74YTJXR.js';
2
2
  import { onConfigured, getConfig } from './2IFPDU4D.js';
3
3
  import { createRoot, createSignal, createMemo, batch } from 'solid-js';
4
4
 
@@ -382,5 +382,5 @@ var medicationStore = createRoot(createMedicationStore);
382
382
  var medication_default = medicationStore;
383
383
 
384
384
  export { affiliateAuth_default, auth_default, cart_default, medication_default };
385
- //# sourceMappingURL=TNGDSXSC.js.map
386
- //# sourceMappingURL=TNGDSXSC.js.map
385
+ //# sourceMappingURL=74A4ERWQ.js.map
386
+ //# sourceMappingURL=74A4ERWQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stores/cart.ts","../../src/stores/auth.ts","../../src/stores/affiliateAuth.ts","../../src/st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S;AACtB,IAAA,IAAI;AACF,MAAA,MAAM,mBAAmB,MAAA,EAAO;AAAA,IAClC,CAAA,SAAE;AACA,MAAA,UAAA,CAAW,IAAI,CAAA;AAAA,IACjB;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,SAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAEA,IAAM,kBAAA,GAAqBD,WAAW,wBAAwB,CAAA;AAC9D,IAAO,qBAAA,GAAQ;AC5Jf,SAAS,qBAAA,GAAwB;AAC/B,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAID,aAAyC,IAAI,CAAA;AAE7E,EAAA,SAAS,OAAO,UAAA,EAAiC;AAC/C,IAAA,WAAA,CAAY,UAAU,CAAA;AAAA,EACxB;AAEA,EAAA,SAAS,KAAA,GAAQ;AACf,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EAClB;AAEA,EAAA,OAAO,EAAE,QAAA,EAAU,MAAA,EAAQ,KAAA,EAAM;AACnC;AAEA,IAAM,eAAA,GAAkBC,WAAW,qBAAqB,CAAA;AACxD,IAAO,kBAAA,GAAQ","file":"TNGDSXSC.js","sourcesContent":["import { createSignal, createRoot } from 'solid-js';\nimport { getConfig } from '../config';\n\nconst cartStorageKey = () => `${getConfig().storagePrefix}-cart`;\nconst promoStorageKey = () => `${getConfig().storagePrefix}-cart-promo`;\n\nexport interface CartItem {\n productId: string;\n productName: string;\n dosage: string;\n /** Dose redesign (Phase 8): optional patient-requested intake hints, mirroring\n * Apex intake — `requestedSku` is the binding patient-bought SKU,\n * `requestedClinicalDose` is the advisory dose. Default undefined; carried\n * through to the /apex/requests medications payload. Nothing sets these yet. */\n requestedSku?: string;\n /** SKU identity S4: the stable, opaque `skus[].id` form of `requestedSku`\n * (from Apex's /v1/drugs catalog). Preferred over the label — survives a\n * relabel. Additive; carried through to the medications payload. */\n requestedSkuId?: string;\n requestedClinicalDose?: { value: number; unit: string };\n quantity: number;\n priceCents: number;\n drugId: string | null;\n /** The linked Apex drug id, copied from the catalog product. Matches the id\n * the survey qualification verdict (`drugResults[].drugId`) is keyed on, so\n * request creation can gate out drugs the survey marked ineligible. Null/\n * undefined for non-Apex products or carts saved before this field existed. */\n apexDrugId?: string | null;\n categories: string[];\n thumbnailUrl?: string;\n /** True when the product uses flat_fee pricing. The dosage is still set\n * (Apex needs it for the prescription) but consumer cart drawers should\n * skip rendering the dose suffix. */\n hideDoseLabel?: boolean;\n /** Copied from the catalog's `is_subscription` at add-time. The one-time\n * checkout flow excludes subscription items (the backend 400s a\n * /payments/checkout containing one, and stays the authority). Undefined —\n * legacy persisted carts, non-catalog adds — is treated as one-time-purchasable. */\n isSubscription?: boolean;\n}\n\nexport interface AppliedPromoCode {\n code: string;\n discountType: 'percent' | 'fixed';\n discountValueCents: number;\n discountCents: number;\n}\n\nfunction itemKey(productId: string, dosage: string): string {\n return `${productId}::${dosage}`;\n}\n\nfunction loadInitial(): CartItem[] {\n try {\n const raw = localStorage.getItem(cartStorageKey());\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n // Preserve a sane persisted quantity (set via setQuantity); anything else\n // — legacy carts, tampered storage — normalizes back to 1.\n return parsed.map((i: CartItem) => ({\n ...i,\n quantity: Number.isInteger(i.quantity) && i.quantity > 0 ? i.quantity : 1,\n }));\n } catch {\n return [];\n }\n}\n\nfunction loadInitialPromo(): AppliedPromoCode | null {\n try {\n const raw = localStorage.getItem(promoStorageKey());\n if (!raw) return null;\n return JSON.parse(raw) as AppliedPromoCode;\n } catch {\n return null;\n }\n}\n\nfunction persist(items: CartItem[]) {\n try {\n localStorage.setItem(cartStorageKey(), JSON.stringify(items));\n } catch {\n // noop\n }\n}\n\nfunction persistPromo(promo: AppliedPromoCode | null) {\n try {\n if (promo) localStorage.setItem(promoStorageKey(), JSON.stringify(promo));\n else localStorage.removeItem(promoStorageKey());\n } catch {\n // noop\n }\n}\n\nfunction createCartStore() {\n const [items, setItems] = createSignal<CartItem[]>(loadInitial());\n const [isOpen, setIsOpen] = createSignal(false);\n const [appliedPromo, setAppliedPromo] = createSignal<AppliedPromoCode | null>(loadInitialPromo());\n\n function write(next: CartItem[]) {\n setItems(next);\n persist(next);\n }\n\n function count() {\n return items().length;\n }\n\n function subtotalCents() {\n return items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);\n }\n\n function add(item: CartItem) {\n const key = itemKey(item.productId, item.dosage);\n const current = items();\n if (current.some(i => itemKey(i.productId, i.dosage) === key)) return;\n write([...current, { ...item, quantity: 1 }]);\n }\n\n function remove(key: string) {\n write(items().filter(i => itemKey(i.productId, i.dosage) !== key));\n }\n\n /** Set an item's quantity (floored, clamped to ≥1 — removing is `remove`'s\n * job). Non-finite input and unknown keys are ignored. `add` still starts\n * every item at 1; this is the only quantity mutator. */\n function setQuantity(key: string, quantity: number) {\n if (!Number.isFinite(quantity)) return;\n const clamped = Math.max(1, Math.floor(quantity));\n const current = items();\n if (!current.some(i => itemKey(i.productId, i.dosage) === key)) return;\n write(current.map(i => (itemKey(i.productId, i.dosage) === key ? { ...i, quantity: clamped } : i)));\n }\n\n /**\n * Replace the whole cart in one write. For catalog reconciliation\n * (`flows/cartReconcile`), which drops lines the catalog no longer offers and\n * refreshes the snapshots of the ones it does — neither expressible as\n * add/remove, and both must land as a single persist so a half-written cart\n * can never be read back. Quantities are taken as given (unlike `add`, which\n * always starts at 1).\n */\n function replace(next: CartItem[]) {\n write(next);\n }\n\n function clear() {\n // Preserve the applied promo across cart resets — the survey submission\n // clears the cart but the customer still expects the code they entered to\n // apply to subsequent prescription purchases. Removing the promo is an\n // explicit action via the cart drawer's \"remove\" link.\n write([]);\n }\n\n function hasGlp1() {\n return items().some(i =>\n i.categories.some(c => c.toLowerCase().includes('weight') || c.toLowerCase().includes('glp')),\n );\n }\n\n function isMultiItem() {\n return items().length > 1;\n }\n\n function setPromo(promo: AppliedPromoCode | null) {\n setAppliedPromo(promo);\n persistPromo(promo);\n }\n\n return {\n items,\n count,\n subtotalCents,\n add,\n remove,\n setQuantity,\n replace,\n clear,\n hasGlp1,\n isMultiItem,\n itemKey,\n isOpen,\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen(v => !v),\n appliedPromo,\n setPromo,\n };\n}\n\nconst cartStore = createRoot(createCartStore);\nexport default cartStore;\n","import { createSignal, createMemo, createRoot, batch } from 'solid-js';\nimport { onConfigured } from '../config';\nimport {\n authApi,\n getTokens,\n setTokens,\n clearTokens,\n usersApi,\n ApiError,\n onTokensCleared,\n authStorageKey,\n type User,\n type AuthTokens,\n type RegisterPayload,\n type RegisterAndSubscribePayload,\n} from '../api/client';\nimport cartStore from './cart';\n\nfunction createAuthStore() {\n // ── Signals ─────────────────────────────────────────────────────\n\n const [tokens, _setTokens] = createSignal<AuthTokens | null>(null);\n const [user, setUser] = createSignal<User | null>(null);\n const [isAuthenticated, setIsAuthenticated] = createSignal(false);\n const [loading, setLoading] = createSignal(false);\n\n // Derived, not a second signal: admin-ness must never be observable out of\n // step with the user it describes. As separate writes, Solid flushed\n // dependents between setUser and setIsAdmin, so an admin gate combining\n // \"hydrated\" (user() !== null) with isAdmin() saw \"hydrated but not admin\"\n // for one tick on every hard load of /admin and bounced to the fallback\n // route.\n const isAdmin = createMemo(() => user()?.role === 'admin');\n\n // ── Internal helpers ────────────────────────────────────────────\n\n /** Reset the in-memory session signals WITHOUT touching token storage.\n * Used by the token-cleared/storage listeners, where storage is already\n * gone (writing it back would re-notify and loop). */\n function dropSession() {\n batch(() => {\n _setTokens(null);\n setIsAuthenticated(false);\n setUser(null);\n });\n }\n\n function syncTokens(t: AuthTokens | null) {\n _setTokens(t);\n if (t) {\n setTokens(t);\n setIsAuthenticated(true);\n } else {\n clearTokens();\n dropSession();\n // Kiosk/shared-browser hygiene: ending the session must not hand the\n // next visitor the previous member's cart + promo (audit cart.ts:4).\n // Done HERE — not in dropSession — so an explicit logout or definitive\n // auth rejection wipes them, while an out-of-band token expiry in the\n // middle of an active shopper's visit leaves their cart alone.\n // Deliberately NOT userId-namespaced: the cart is populated anonymously\n // pre-signup and must survive the anonymous→signup transition.\n cartStore.clear();\n cartStore.setPromo(null);\n }\n }\n\n // The transport clears tokens out-of-band (refresh failure, post-refresh\n // 401). Without this subscription isAuthenticated() stayed true and the\n // chrome kept rendering an authenticated shell whose every request 401s\n // until a hard reload (audit auth.ts:26).\n onTokensCleared('patient', dropSession);\n\n // Cross-tab convergence: logout (or login) in another tab updates shared\n // localStorage but fires no event in-store — converge on the peer's state.\n // The `storage` event never fires in the acting tab, which is why the\n // same-tab path above is a separate, direct subscription.\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n let key: string;\n try {\n key = authStorageKey();\n } catch {\n return; // not configured yet — nothing to converge on\n }\n if (e.key !== null && e.key !== key) return; // null key = storage.clear()\n const stored = getTokens();\n if (stored?.accessToken) {\n const wasAuthenticated = isAuthenticated();\n batch(() => {\n _setTokens(stored);\n setIsAuthenticated(true);\n });\n if (!wasAuthenticated) void fetchProfile();\n } else {\n dropSession();\n }\n });\n }\n\n async function fetchProfile() {\n try {\n const res = await usersApi.getProfile();\n if (res.data) {\n setUser(res.data);\n }\n } catch (err) {\n // Only a definitive auth rejection ends the session. The transport has\n // already refreshed-and-retried before a 401 reaches here (and cleared\n // the stored tokens itself); a transient 5xx / network blip during a\n // reload must NOT destroy a valid refresh token and force-log-out a\n // returning member (audit auth.ts:46). The profile simply stays\n // unhydrated and can be fetched again later.\n if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {\n syncTokens(null);\n }\n }\n }\n\n // ── Initialize ──────────────────────────────────────────────────\n\n // Hydrate from token storage AFTER `configure()` runs. The store is a\n // singleton created at import time (see `createRoot` below), which is before\n // the host site calls `configure()`; reading `getTokens()` then would route\n // through `getConfig()` and throw, leaving a returning member rendered\n // logged-out until their first live API call. `onConfigured` defers this.\n let hydrated = false;\n function hydrate() {\n if (hydrated) return;\n hydrated = true;\n const stored = getTokens();\n if (stored?.accessToken) {\n _setTokens(stored);\n setIsAuthenticated(true);\n // Fire-and-forget profile hydration\n fetchProfile();\n }\n }\n onConfigured(hydrate);\n\n // ── Public API ──────────────────────────────────────────────────\n\n async function login(email: string, password: string) {\n setLoading(true);\n try {\n const res = await authApi.login({ email, password });\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n // Backend login doesn't return full user profile — fetch it\n await fetchProfile();\n }\n } finally {\n setLoading(false);\n }\n }\n\n async function signup(payload: RegisterPayload) {\n setLoading(true);\n try {\n const res = await authApi.register(payload);\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n await fetchProfile();\n }\n } finally {\n setLoading(false);\n }\n }\n\n async function signupAndSubscribe(\n payload: RegisterAndSubscribePayload,\n opts?: { idempotencyKey?: string },\n ) {\n setLoading(true);\n try {\n const res = await authApi.registerAndSubscribe(payload, opts);\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n await fetchProfile();\n return res.data;\n }\n } finally {\n setLoading(false);\n }\n }\n\n function logout() {\n syncTokens(null);\n }\n\n return {\n // Reactive getters\n tokens,\n user,\n isAuthenticated,\n isAdmin,\n loading,\n // Actions\n login,\n signup,\n signupAndSubscribe,\n logout,\n fetchProfile,\n };\n}\n\n// Singleton store created inside a reactive root\nconst authStore = createRoot(createAuthStore);\nexport default authStore;\n","import { createSignal, createRoot, batch } from 'solid-js';\nimport { onConfigured } from '../config';\nimport {\n affiliatePortalApi,\n getAffiliateTokens,\n setAffiliateTokens,\n clearAffiliateTokens,\n ApiError,\n onTokensCleared,\n affiliateAuthStorageKey,\n type Affiliate,\n type AffiliateAuthTokens,\n type AffiliateRegisterInput,\n} from '../api/client';\n\nfunction createAffiliateAuthStore() {\n const [tokens, _setTokens] = createSignal<AffiliateAuthTokens | null>(null);\n const [affiliate, setAffiliate] = createSignal<Affiliate | null>(null);\n const [isAuthenticated, setIsAuthenticated] = createSignal(false);\n const [isHydrated, setIsHydrated] = createSignal(false);\n const [loading, setLoading] = createSignal(false);\n\n /** Reset in-memory session signals WITHOUT touching token storage (see\n * stores/auth.ts dropSession — same loop-avoidance rationale). */\n function dropSession() {\n // Batched so a consumer combining these signals can never observe a\n // half-dropped session between flushes (same class of glitch as the\n // patient store's setUser→setIsAdmin admin-gate race).\n batch(() => {\n _setTokens(null);\n setIsAuthenticated(false);\n setAffiliate(null);\n });\n }\n\n function syncTokens(t: AffiliateAuthTokens | null) {\n _setTokens(t);\n if (t) {\n setAffiliateTokens(t);\n setIsAuthenticated(true);\n } else {\n clearAffiliateTokens();\n dropSession();\n }\n }\n\n // Same-tab: the transport's refresh-failure path clears affiliate tokens\n // out-of-band — flip the store immediately instead of rendering a stuck\n // authenticated-but-empty portal until a manual reload (audit client.ts:1682).\n onTokensCleared('affiliate', dropSession);\n\n // Cross-tab: converge on a peer tab's logout/login (audit affiliateAuth.ts:16).\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n let key: string;\n try {\n key = affiliateAuthStorageKey();\n } catch {\n return; // not configured yet\n }\n if (e.key !== null && e.key !== key) return; // null key = storage.clear()\n const stored = getAffiliateTokens();\n if (stored?.accessToken) {\n const wasAuthenticated = isAuthenticated();\n _setTokens(stored);\n setIsAuthenticated(true);\n if (!wasAuthenticated) void fetchProfile();\n } else {\n dropSession();\n }\n });\n }\n\n async function fetchProfile() {\n try {\n const res = await affiliatePortalApi.getProfile();\n setAffiliate(res.affiliate);\n } catch (err) {\n // Clear only on a definitive auth rejection (the transport has already\n // refreshed-and-retried before a 401 surfaces here). A transient\n // 5xx/network blip during hydration or right after login() must not\n // erase a valid refresh token — that logged out every affiliate loading\n // the app during a backend hiccup, and made login() resolve into an\n // instantly-dead session (audit affiliateAuth.ts:43 + :59). On a\n // transient failure the session stands; the profile stays null and can\n // be re-fetched.\n if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {\n syncTokens(null);\n }\n } finally {\n setIsHydrated(true);\n }\n }\n\n // Hydrate from token storage after `configure()` (see stores/auth.ts for the\n // boot-ordering rationale). fetchProfile() flips isHydrated in its finally;\n // the no-session branch flips it here.\n let hydrated = false;\n function hydrate() {\n if (hydrated) return;\n hydrated = true;\n const stored = getAffiliateTokens();\n if (stored?.accessToken) {\n _setTokens(stored);\n setIsAuthenticated(true);\n fetchProfile();\n } else {\n setIsHydrated(true);\n }\n }\n onConfigured(hydrate);\n\n async function login(email: string, password: string) {\n setLoading(true);\n try {\n const session = await affiliatePortalApi.login(email, password);\n syncTokens({\n accessToken: session.idToken,\n refreshToken: session.refreshToken,\n affiliateId: session.affiliateId,\n });\n setIsHydrated(false);\n await fetchProfile();\n } finally {\n setLoading(false);\n }\n }\n\n async function register(input: AffiliateRegisterInput) {\n setLoading(true);\n try {\n await affiliatePortalApi.register(input);\n // Backend register does NOT return tokens — new affiliates start as\n // 'pending' and must be approved by an admin before they can log in.\n // We surface the affiliate ID via the resolved promise so the page\n // can show a \"pending approval\" success state without logging in.\n } finally {\n setLoading(false);\n }\n }\n\n async function logout() {\n try {\n await affiliatePortalApi.logout();\n } finally {\n syncTokens(null);\n }\n }\n\n return {\n tokens,\n affiliate,\n isAuthenticated,\n isHydrated,\n loading,\n login,\n register,\n logout,\n fetchProfile,\n };\n}\n\nconst affiliateAuthStore = createRoot(createAffiliateAuthStore);\nexport default affiliateAuthStore;\n","import { createSignal, createRoot } from 'solid-js';\n\nexport interface MedicationSelection {\n drugId: string | null; // null = general consultation\n drugName: string;\n}\n\nfunction createMedicationStore() {\n const [selected, setSelected] = createSignal<MedicationSelection | null>(null);\n\n function select(medication: MedicationSelection) {\n setSelected(medication);\n }\n\n function clear() {\n setSelected(null);\n }\n\n return { selected, select, clear };\n}\n\nconst medicationStore = createRoot(createMedicationStore);\nexport default medicationStore;\n"]}
1
+ {"version":3,"sources":["../../src/stores/cart.ts","../../src/stores/auth.ts","../../src/stores/affiliateAuth.ts","../../src/stores/medication.ts"],"names":["createSignal","createRoot","batch"],"mappings":";;;;AAGA,IAAM,cAAA,GAAiB,MAAM,CAAA,EAAG,SAAA,GAAY,aAAa,CAAA,KAAA,CAAA;AACzD,IAAM,eAAA,GAAkB,MAAM,CAAA,EAAG,SAAA,GAAY,aAAa,CAAA,WAAA,CAAA;AA4C1D,SAAS,OAAA,CAAQ,WAAmB,MAAA,EAAwB;AAC1D,EAAA,OAAO,CAAA,EAAG,SAAS,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA;AAChC;AAEA,SAAS,WAAA,GAA0B;AACjC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,YAAA,CAAa,OAAA,CAAQ,cAAA,EAAgB,CAAA;AACjD,IAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC7B,IAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,SAAU,EAAC;AAGpC,IAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA,MAAiB;AAAA,MAClC,GAAG,CAAA;AAAA,MACH,QAAA,EAAU,MAAA,CAAO,SAAA,CAAU,CAAA,CAAE,QAAQ,KAAK,CAAA,CAAE,QAAA,GAAW,CAAA,GAAI,CAAA,CAAE,QAAA,GAAW;AAAA,KAC1E,CAAE,CAAA;AAAA,EACJ,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACF;AAEA,SAAS,gBAAA,GAA4C;AACnD,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,YAAA,CAAa,OAAA,CAAQ,eAAA,EAAiB,CAAA;AAClD,IAAA,IAAI,CAAC,K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AA,CAAmB,SAAS,KAAK,CAAA;AAAA,IAKzC,CAAA,SAAE;AACA,MAAA,UAAA,CAAW,KAAK,CAAA;AAAA,IAClB;AAAA,EACF;AAEA,EAAA,eAAe,MAAA,GAAS;AACtB,IAAA,IAAI;AACF,MAAA,MAAM,mBAAmB,MAAA,EAAO;AAAA,IAClC,CAAA,SAAE;AACA,MAAA,UAAA,CAAW,IAAI,CAAA;AAAA,IACjB;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,SAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF;AAEA,IAAM,kBAAA,GAAqBD,WAAW,wBAAwB,CAAA;AAC9D,IAAO,qBAAA,GAAQ;AC5Jf,SAAS,qBAAA,GAAwB;AAC/B,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAID,aAAyC,IAAI,CAAA;AAE7E,EAAA,SAAS,OAAO,UAAA,EAAiC;AAC/C,IAAA,WAAA,CAAY,UAAU,CAAA;AAAA,EACxB;AAEA,EAAA,SAAS,KAAA,GAAQ;AACf,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EAClB;AAEA,EAAA,OAAO,EAAE,QAAA,EAAU,MAAA,EAAQ,KAAA,EAAM;AACnC;AAEA,IAAM,eAAA,GAAkBC,WAAW,qBAAqB,CAAA;AACxD,IAAO,kBAAA,GAAQ","file":"74A4ERWQ.js","sourcesContent":["import { createSignal, createRoot } from 'solid-js';\nimport { getConfig } from '../config';\n\nconst cartStorageKey = () => `${getConfig().storagePrefix}-cart`;\nconst promoStorageKey = () => `${getConfig().storagePrefix}-cart-promo`;\n\nexport interface CartItem {\n productId: string;\n productName: string;\n dosage: string;\n /** Dose redesign (Phase 8): optional patient-requested intake hints, mirroring\n * Apex intake — `requestedSku` is the binding patient-bought SKU,\n * `requestedClinicalDose` is the advisory dose. Default undefined; carried\n * through to the /apex/requests medications payload. Nothing sets these yet. */\n requestedSku?: string;\n /** SKU identity S4: the stable, opaque `skus[].id` form of `requestedSku`\n * (from Apex's /v1/drugs catalog). Preferred over the label — survives a\n * relabel. Additive; carried through to the medications payload. */\n requestedSkuId?: string;\n requestedClinicalDose?: { value: number; unit: string };\n quantity: number;\n priceCents: number;\n drugId: string | null;\n /** The linked Apex drug id, copied from the catalog product. Matches the id\n * the survey qualification verdict (`drugResults[].drugId`) is keyed on, so\n * request creation can gate out drugs the survey marked ineligible. Null/\n * undefined for non-Apex products or carts saved before this field existed. */\n apexDrugId?: string | null;\n categories: string[];\n thumbnailUrl?: string;\n /** True when the product uses flat_fee pricing. The dosage is still set\n * (Apex needs it for the prescription) but consumer cart drawers should\n * skip rendering the dose suffix. */\n hideDoseLabel?: boolean;\n /** Copied from the catalog's `is_subscription` at add-time. The one-time\n * checkout flow excludes subscription items (the backend 400s a\n * /payments/checkout containing one, and stays the authority). Undefined —\n * legacy persisted carts, non-catalog adds — is treated as one-time-purchasable. */\n isSubscription?: boolean;\n}\n\nexport interface AppliedPromoCode {\n code: string;\n discountType: 'percent' | 'fixed';\n discountValueCents: number;\n discountCents: number;\n}\n\nfunction itemKey(productId: string, dosage: string): string {\n return `${productId}::${dosage}`;\n}\n\nfunction loadInitial(): CartItem[] {\n try {\n const raw = localStorage.getItem(cartStorageKey());\n if (!raw) return [];\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n // Preserve a sane persisted quantity (set via setQuantity); anything else\n // — legacy carts, tampered storage — normalizes back to 1.\n return parsed.map((i: CartItem) => ({\n ...i,\n quantity: Number.isInteger(i.quantity) && i.quantity > 0 ? i.quantity : 1,\n }));\n } catch {\n return [];\n }\n}\n\nfunction loadInitialPromo(): AppliedPromoCode | null {\n try {\n const raw = localStorage.getItem(promoStorageKey());\n if (!raw) return null;\n return JSON.parse(raw) as AppliedPromoCode;\n } catch {\n return null;\n }\n}\n\nfunction persist(items: CartItem[]) {\n try {\n localStorage.setItem(cartStorageKey(), JSON.stringify(items));\n } catch {\n // noop\n }\n}\n\nfunction persistPromo(promo: AppliedPromoCode | null) {\n try {\n if (promo) localStorage.setItem(promoStorageKey(), JSON.stringify(promo));\n else localStorage.removeItem(promoStorageKey());\n } catch {\n // noop\n }\n}\n\nfunction createCartStore() {\n const [items, setItems] = createSignal<CartItem[]>(loadInitial());\n const [isOpen, setIsOpen] = createSignal(false);\n const [appliedPromo, setAppliedPromo] = createSignal<AppliedPromoCode | null>(loadInitialPromo());\n\n function write(next: CartItem[]) {\n setItems(next);\n persist(next);\n }\n\n function count() {\n return items().length;\n }\n\n function subtotalCents() {\n return items().reduce((sum, i) => sum + i.priceCents * (i.quantity || 1), 0);\n }\n\n function add(item: CartItem) {\n const key = itemKey(item.productId, item.dosage);\n const current = items();\n if (current.some(i => itemKey(i.productId, i.dosage) === key)) return;\n write([...current, { ...item, quantity: 1 }]);\n }\n\n function remove(key: string) {\n write(items().filter(i => itemKey(i.productId, i.dosage) !== key));\n }\n\n /** Set an item's quantity (floored, clamped to ≥1 — removing is `remove`'s\n * job). Non-finite input and unknown keys are ignored. `add` still starts\n * every item at 1; this is the only quantity mutator. */\n function setQuantity(key: string, quantity: number) {\n if (!Number.isFinite(quantity)) return;\n const clamped = Math.max(1, Math.floor(quantity));\n const current = items();\n if (!current.some(i => itemKey(i.productId, i.dosage) === key)) return;\n write(current.map(i => (itemKey(i.productId, i.dosage) === key ? { ...i, quantity: clamped } : i)));\n }\n\n /**\n * Replace the whole cart in one write. For catalog reconciliation\n * (`flows/cartReconcile`), which drops lines the catalog no longer offers and\n * refreshes the snapshots of the ones it does — neither expressible as\n * add/remove, and both must land as a single persist so a half-written cart\n * can never be read back. Quantities are taken as given (unlike `add`, which\n * always starts at 1).\n */\n function replace(next: CartItem[]) {\n write(next);\n }\n\n function clear() {\n // Preserve the applied promo across cart resets — the survey submission\n // clears the cart but the customer still expects the code they entered to\n // apply to subsequent prescription purchases. Removing the promo is an\n // explicit action via the cart drawer's \"remove\" link.\n write([]);\n }\n\n function hasGlp1() {\n return items().some(i =>\n i.categories.some(c => c.toLowerCase().includes('weight') || c.toLowerCase().includes('glp')),\n );\n }\n\n function isMultiItem() {\n return items().length > 1;\n }\n\n function setPromo(promo: AppliedPromoCode | null) {\n setAppliedPromo(promo);\n persistPromo(promo);\n }\n\n return {\n items,\n count,\n subtotalCents,\n add,\n remove,\n setQuantity,\n replace,\n clear,\n hasGlp1,\n isMultiItem,\n itemKey,\n isOpen,\n open: () => setIsOpen(true),\n close: () => setIsOpen(false),\n toggle: () => setIsOpen(v => !v),\n appliedPromo,\n setPromo,\n };\n}\n\nconst cartStore = createRoot(createCartStore);\nexport default cartStore;\n","import { createSignal, createMemo, createRoot, batch } from 'solid-js';\nimport { onConfigured } from '../config';\nimport {\n authApi,\n getTokens,\n setTokens,\n clearTokens,\n usersApi,\n ApiError,\n onTokensCleared,\n authStorageKey,\n type User,\n type AuthTokens,\n type RegisterPayload,\n type RegisterAndSubscribePayload,\n} from '../api/client';\nimport cartStore from './cart';\n\nfunction createAuthStore() {\n // ── Signals ─────────────────────────────────────────────────────\n\n const [tokens, _setTokens] = createSignal<AuthTokens | null>(null);\n const [user, setUser] = createSignal<User | null>(null);\n const [isAuthenticated, setIsAuthenticated] = createSignal(false);\n const [loading, setLoading] = createSignal(false);\n\n // Derived, not a second signal: admin-ness must never be observable out of\n // step with the user it describes. As separate writes, Solid flushed\n // dependents between setUser and setIsAdmin, so an admin gate combining\n // \"hydrated\" (user() !== null) with isAdmin() saw \"hydrated but not admin\"\n // for one tick on every hard load of /admin and bounced to the fallback\n // route.\n const isAdmin = createMemo(() => user()?.role === 'admin');\n\n // ── Internal helpers ────────────────────────────────────────────\n\n /** Reset the in-memory session signals WITHOUT touching token storage.\n * Used by the token-cleared/storage listeners, where storage is already\n * gone (writing it back would re-notify and loop). */\n function dropSession() {\n batch(() => {\n _setTokens(null);\n setIsAuthenticated(false);\n setUser(null);\n });\n }\n\n function syncTokens(t: AuthTokens | null) {\n _setTokens(t);\n if (t) {\n setTokens(t);\n setIsAuthenticated(true);\n } else {\n clearTokens();\n dropSession();\n // Kiosk/shared-browser hygiene: ending the session must not hand the\n // next visitor the previous member's cart + promo (audit cart.ts:4).\n // Done HERE — not in dropSession — so an explicit logout or definitive\n // auth rejection wipes them, while an out-of-band token expiry in the\n // middle of an active shopper's visit leaves their cart alone.\n // Deliberately NOT userId-namespaced: the cart is populated anonymously\n // pre-signup and must survive the anonymous→signup transition.\n cartStore.clear();\n cartStore.setPromo(null);\n }\n }\n\n // The transport clears tokens out-of-band (refresh failure, post-refresh\n // 401). Without this subscription isAuthenticated() stayed true and the\n // chrome kept rendering an authenticated shell whose every request 401s\n // until a hard reload (audit auth.ts:26).\n onTokensCleared('patient', dropSession);\n\n // Cross-tab convergence: logout (or login) in another tab updates shared\n // localStorage but fires no event in-store — converge on the peer's state.\n // The `storage` event never fires in the acting tab, which is why the\n // same-tab path above is a separate, direct subscription.\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n let key: string;\n try {\n key = authStorageKey();\n } catch {\n return; // not configured yet — nothing to converge on\n }\n if (e.key !== null && e.key !== key) return; // null key = storage.clear()\n const stored = getTokens();\n if (stored?.accessToken) {\n const wasAuthenticated = isAuthenticated();\n batch(() => {\n _setTokens(stored);\n setIsAuthenticated(true);\n });\n if (!wasAuthenticated) void fetchProfile();\n } else {\n dropSession();\n }\n });\n }\n\n async function fetchProfile() {\n try {\n const res = await usersApi.getProfile();\n if (res.data) {\n setUser(res.data);\n }\n } catch (err) {\n // Only a definitive auth rejection ends the session. The transport has\n // already refreshed-and-retried before a 401 reaches here (and cleared\n // the stored tokens itself); a transient 5xx / network blip during a\n // reload must NOT destroy a valid refresh token and force-log-out a\n // returning member (audit auth.ts:46). The profile simply stays\n // unhydrated and can be fetched again later.\n if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {\n syncTokens(null);\n }\n }\n }\n\n // ── Initialize ──────────────────────────────────────────────────\n\n // Hydrate from token storage AFTER `configure()` runs. The store is a\n // singleton created at import time (see `createRoot` below), which is before\n // the host site calls `configure()`; reading `getTokens()` then would route\n // through `getConfig()` and throw, leaving a returning member rendered\n // logged-out until their first live API call. `onConfigured` defers this.\n let hydrated = false;\n function hydrate() {\n if (hydrated) return;\n hydrated = true;\n const stored = getTokens();\n if (stored?.accessToken) {\n _setTokens(stored);\n setIsAuthenticated(true);\n // Fire-and-forget profile hydration\n fetchProfile();\n }\n }\n onConfigured(hydrate);\n\n // ── Public API ──────────────────────────────────────────────────\n\n async function login(email: string, password: string) {\n setLoading(true);\n try {\n const res = await authApi.login({ email, password });\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n // Backend login doesn't return full user profile — fetch it\n await fetchProfile();\n }\n } finally {\n setLoading(false);\n }\n }\n\n async function signup(payload: RegisterPayload) {\n setLoading(true);\n try {\n const res = await authApi.register(payload);\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n await fetchProfile();\n }\n } finally {\n setLoading(false);\n }\n }\n\n async function signupAndSubscribe(\n payload: RegisterAndSubscribePayload,\n opts?: { idempotencyKey?: string },\n ) {\n setLoading(true);\n try {\n const res = await authApi.registerAndSubscribe(payload, opts);\n if (res.data) {\n syncTokens({\n accessToken: res.data.accessToken,\n refreshToken: res.data.refreshToken,\n userId: res.data.userId,\n });\n await fetchProfile();\n return res.data;\n }\n } finally {\n setLoading(false);\n }\n }\n\n function logout() {\n syncTokens(null);\n }\n\n return {\n // Reactive getters\n tokens,\n user,\n isAuthenticated,\n isAdmin,\n loading,\n // Actions\n login,\n signup,\n signupAndSubscribe,\n logout,\n fetchProfile,\n };\n}\n\n// Singleton store created inside a reactive root\nconst authStore = createRoot(createAuthStore);\nexport default authStore;\n","import { createSignal, createRoot, batch } from 'solid-js';\nimport { onConfigured } from '../config';\nimport {\n affiliatePortalApi,\n getAffiliateTokens,\n setAffiliateTokens,\n clearAffiliateTokens,\n ApiError,\n onTokensCleared,\n affiliateAuthStorageKey,\n type Affiliate,\n type AffiliateAuthTokens,\n type AffiliateRegisterInput,\n} from '../api/client';\n\nfunction createAffiliateAuthStore() {\n const [tokens, _setTokens] = createSignal<AffiliateAuthTokens | null>(null);\n const [affiliate, setAffiliate] = createSignal<Affiliate | null>(null);\n const [isAuthenticated, setIsAuthenticated] = createSignal(false);\n const [isHydrated, setIsHydrated] = createSignal(false);\n const [loading, setLoading] = createSignal(false);\n\n /** Reset in-memory session signals WITHOUT touching token storage (see\n * stores/auth.ts dropSession — same loop-avoidance rationale). */\n function dropSession() {\n // Batched so a consumer combining these signals can never observe a\n // half-dropped session between flushes (same class of glitch as the\n // patient store's setUser→setIsAdmin admin-gate race).\n batch(() => {\n _setTokens(null);\n setIsAuthenticated(false);\n setAffiliate(null);\n });\n }\n\n function syncTokens(t: AffiliateAuthTokens | null) {\n _setTokens(t);\n if (t) {\n setAffiliateTokens(t);\n setIsAuthenticated(true);\n } else {\n clearAffiliateTokens();\n dropSession();\n }\n }\n\n // Same-tab: the transport's refresh-failure path clears affiliate tokens\n // out-of-band — flip the store immediately instead of rendering a stuck\n // authenticated-but-empty portal until a manual reload (audit client.ts:1682).\n onTokensCleared('affiliate', dropSession);\n\n // Cross-tab: converge on a peer tab's logout/login (audit affiliateAuth.ts:16).\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n let key: string;\n try {\n key = affiliateAuthStorageKey();\n } catch {\n return; // not configured yet\n }\n if (e.key !== null && e.key !== key) return; // null key = storage.clear()\n const stored = getAffiliateTokens();\n if (stored?.accessToken) {\n const wasAuthenticated = isAuthenticated();\n _setTokens(stored);\n setIsAuthenticated(true);\n if (!wasAuthenticated) void fetchProfile();\n } else {\n dropSession();\n }\n });\n }\n\n async function fetchProfile() {\n try {\n const res = await affiliatePortalApi.getProfile();\n setAffiliate(res.affiliate);\n } catch (err) {\n // Clear only on a definitive auth rejection (the transport has already\n // refreshed-and-retried before a 401 surfaces here). A transient\n // 5xx/network blip during hydration or right after login() must not\n // erase a valid refresh token — that logged out every affiliate loading\n // the app during a backend hiccup, and made login() resolve into an\n // instantly-dead session (audit affiliateAuth.ts:43 + :59). On a\n // transient failure the session stands; the profile stays null and can\n // be re-fetched.\n if (err instanceof ApiError && (err.status === 401 || err.status === 403)) {\n syncTokens(null);\n }\n } finally {\n setIsHydrated(true);\n }\n }\n\n // Hydrate from token storage after `configure()` (see stores/auth.ts for the\n // boot-ordering rationale). fetchProfile() flips isHydrated in its finally;\n // the no-session branch flips it here.\n let hydrated = false;\n function hydrate() {\n if (hydrated) return;\n hydrated = true;\n const stored = getAffiliateTokens();\n if (stored?.accessToken) {\n _setTokens(stored);\n setIsAuthenticated(true);\n fetchProfile();\n } else {\n setIsHydrated(true);\n }\n }\n onConfigured(hydrate);\n\n async function login(email: string, password: string) {\n setLoading(true);\n try {\n const session = await affiliatePortalApi.login(email, password);\n syncTokens({\n accessToken: session.idToken,\n refreshToken: session.refreshToken,\n affiliateId: session.affiliateId,\n });\n setIsHydrated(false);\n await fetchProfile();\n } finally {\n setLoading(false);\n }\n }\n\n async function register(input: AffiliateRegisterInput) {\n setLoading(true);\n try {\n await affiliatePortalApi.register(input);\n // Backend register does NOT return tokens — new affiliates start as\n // 'pending' and must be approved by an admin before they can log in.\n // We surface the affiliate ID via the resolved promise so the page\n // can show a \"pending approval\" success state without logging in.\n } finally {\n setLoading(false);\n }\n }\n\n async function logout() {\n try {\n await affiliatePortalApi.logout();\n } finally {\n syncTokens(null);\n }\n }\n\n return {\n tokens,\n affiliate,\n isAuthenticated,\n isHydrated,\n loading,\n login,\n register,\n logout,\n fetchProfile,\n };\n}\n\nconst affiliateAuthStore = createRoot(createAffiliateAuthStore);\nexport default affiliateAuthStore;\n","import { createSignal, createRoot } from 'solid-js';\n\nexport interface MedicationSelection {\n drugId: string | null; // null = general consultation\n drugName: string;\n}\n\nfunction createMedicationStore() {\n const [selected, setSelected] = createSignal<MedicationSelection | null>(null);\n\n function select(medication: MedicationSelection) {\n setSelected(medication);\n }\n\n function clear() {\n setSelected(null);\n }\n\n return { selected, select, clear };\n}\n\nconst medicationStore = createRoot(createMedicationStore);\nexport default medicationStore;\n"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  captureAuthHeader,
3
3
  peekFunnelSessionId
4
- } from "./IM27S2HM.jsx";
4
+ } from "./2TGKQDQV.jsx";
5
5
  import {
6
6
  getConfig
7
7
  } from "./QVZ7BRNO.jsx";
@@ -174,4 +174,4 @@ export {
174
174
  readCartToken,
175
175
  stripCartToken
176
176
  };
177
- //# sourceMappingURL=6X2C7K6K.jsx.map
177
+ //# sourceMappingURL=GIJCNQCB.jsx.map
@@ -1672,4 +1672,4 @@ export {
1672
1672
  clearAffiliateTokens,
1673
1673
  affiliatePortalApi
1674
1674
  };
1675
- //# sourceMappingURL=AA7EUOB6.jsx.map
1675
+ //# sourceMappingURL=GWVFWHTO.jsx.map
@@ -1,4 +1,4 @@
1
- import { peekFunnelSessionId, captureAuthHeader } from './BJXH2J3Z.js';
1
+ import { peekFunnelSessionId, captureAuthHeader } from './PK74TNA6.js';
2
2
  import { getConfig } from './2IFPDU4D.js';
3
3
 
4
4
  // src/api/promoRef.ts
@@ -156,5 +156,5 @@ function stripCartToken() {
156
156
  }
157
157
 
158
158
  export { adoptCartId, capturePromoCode, cartId, clearPromoCode, fetchCartConfig, fetchResumedCart, postCartSnapshot, readCartToken, readPromoCode, resetCartConfigCache, resetCartId, stripCartToken };
159
- //# sourceMappingURL=GF4CVY2S.js.map
160
- //# sourceMappingURL=GF4CVY2S.js.map
159
+ //# sourceMappingURL=K2TKMLIY.js.map
160
+ //# sourceMappingURL=K2TKMLIY.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/promoRef.ts","../../src/api/cart.ts"],"names":[],"mappings":";;;;AAiBA,IAAM,MAAA,GAAS,E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AAgB;AAAA,KAC/E;AAAA,EACF,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAGO,SAAS,aAAA,GAA+B;AAC7C,EAAA,IAAI;AACF,IAAA,MAAM,KAAA,GAAQ,IAAI,eAAA,CAAgB,MAAA,CAAO,SAAS,MAAM,CAAA,CAAE,IAAI,MAAM,CAAA;AACpE,IAAA,OAAO,KAAA,IAAS,KAAA,CAAM,MAAA,GAAS,CAAA,GAAI,KAAA,GAAQ,IAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAOO,SAAS,cAAA,GAAuB;AACrC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,MAAA,CAAO,SAAS,IAAI,CAAA;AACxC,IAAA,IAAI,CAAC,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG;AACnC,IAAA,GAAA,CAAI,YAAA,CAAa,OAAO,MAAM,CAAA;AAC9B,IAAA,MAAA,CAAO,QAAQ,YAAA,CAAa,IAAI,EAAA,EAAI,GAAA,CAAI,UAAU,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"GF4CVY2S.js","sourcesContent":["// ── First-party promo-code capture from a `?promo=` landing ──────────\n//\n// A campaign link can carry its own code (`/?promo=TRUE10`) so the member does\n// not have to type it. Stashed in the storefront's own localStorage and read\n// back when the intake reaches the promo field.\n//\n// Mirrors `affiliateRef` deliberately — same storage shape, same 30-day window —\n// but is a SEPARATE concern: an affiliate ref attributes a sale to a partner and\n// is validated server-side at checkout, while this only pre-fills an input the\n// member still has to submit.\n\nimport { getConfig } from '../config';\n\n// Matches the affiliate-ref window. A stash that outlives the promo it carries\n// is not a correctness problem — the code is re-validated before it is used,\n// and silently dropped if it has expired — but there is no reason to keep one\n// around longer than a campaign plausibly runs.\nconst TTL_MS = 30 * 24 * 60 * 60 * 1000;\n\nconst storageKey = () => `${getConfig().storagePrefix}-promo-code`;\n\ninterface StoredPromo {\n code: string;\n ts: number;\n}\n\n/** Persist a promo code from a `?promo=` landing. No-op for empty input. */\nexport function capturePromoCode(code: string): void {\n if (typeof localStorage === 'undefined') return;\n const trimmed = code.trim();\n if (!trimmed) return;\n try {\n const entry: StoredPromo = { code: trimmed, ts: Date.now() };\n localStorage.setItem(storageKey(), JSON.stringify(entry));\n } catch {\n // storage unavailable (private mode / quota) — non-fatal\n }\n}\n\n/**\n * Read the stored promo code, or null if absent or past the storage window.\n *\n * Being within the window says nothing about whether the CODE is still valid —\n * a campaign can end while the stash is fresh. The caller re-validates against\n * the server before showing it to anyone.\n */\nexport function readPromoCode(): string | null {\n if (typeof localStorage === 'undefined') return null;\n try {\n const raw = localStorage.getItem(storageKey());\n if (!raw) return null;\n const parsed = JSON.parse(raw) as Partial<StoredPromo>;\n if (!parsed.code || typeof parsed.ts !== 'number') return null;\n if (Date.now() - parsed.ts > TTL_MS) {\n localStorage.removeItem(storageKey());\n return null;\n }\n return parsed.code;\n } catch {\n return null;\n }\n}\n\n/** Drop the stored promo code. */\nexport function clearPromoCode(): void {\n if (typeof localStorage === 'undefined') return;\n try {\n localStorage.removeItem(storageKey());\n } catch {\n // non-fatal\n }\n}\n","import { getConfig } from '../config';\nimport { captureAuthHeader, peekFunnelSessionId } from './funnel';\n\n// ── Abandoned-cart transport ────────────────────────────────────────────────\n//\n// Thin client for the-backend's cart-capture endpoints:\n// GET /config/cart → whether this tenant mirrors carts at all\n// POST /cart/snapshot → server-side mirror of the browser's cart\n// GET /cart/resume → trade an emailed token for the saved cart\n//\n// Sibling of ./funnel, and the same posture: fire-and-forget, fail-silent.\n// Cart capture is marketing instrumentation and must never break, block or\n// slow down shopping.\n\nexport interface CartCaptureConfig {\n /** Tenant opted in (features.cartRecovery); false = never send anything. */\n snapshot: boolean;\n}\n\nconst DISABLED: CartCaptureConfig = { snapshot: false };\n\nlet configPromise: Promise<CartCaptureConfig> | null = null;\n\n/**\n * The tenant's cart-capture posture, fetched once per page load and cached.\n * Fails closed: any error reads as \"off\".\n */\nexport function fetchCartConfig(): Promise<CartCaptureConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/cart`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<CartCaptureConfig>;\n return { snapshot: body.snapshot === true };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetCartConfigCache(): void {\n configPromise = null;\n}\n\nconst cartIdKey = () => `${getConfig().storagePrefix}-cart-id`;\n\n/**\n * Stable id for this shopper's cart, minted on first use and kept in\n * localStorage — NOT sessionStorage like the survey session.\n *\n * A cart outlives the tab it was filled in: someone adds items, closes the\n * browser, comes back tomorrow and finds the cart still there (the cart store\n * itself persists the same way). The id has to survive with it, or every visit\n * would look like a brand-new abandoned cart and one shopper would accumulate\n * a row — and a reminder track — per session.\n */\nexport function cartId(): string {\n let id: string | null = null;\n try {\n id = localStorage.getItem(cartIdKey());\n } catch {\n /* storage unavailable (private mode) — fall through to an ephemeral id */\n }\n if (!id) {\n id =\n typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* ephemeral it is */\n }\n }\n return id;\n}\n\n/**\n * Continue the cart a recovery email points at, instead of the one this browser\n * happens to hold. Adopting the emailed id keeps the reminder history, the\n * email address and the eventual conversion on ONE row.\n */\nexport function adoptCartId(id: string): void {\n if (!id) return;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* storage unavailable — the adoption is ephemeral */\n }\n}\n\n/**\n * Start a fresh cart id. Called after a purchase: the old id is stamped\n * converted server-side and must never be written to again, or a new cart\n * would inherit a bought cart's row (and its silence — converted rows are\n * never nudged).\n */\nexport function resetCartId(): void {\n try {\n localStorage.removeItem(cartIdKey());\n } catch {\n /* nothing to clear */\n }\n}\n\nexport interface CartSnapshotLine {\n productId: string;\n dosage?: string;\n quantity: number;\n}\n\n/**\n * Mirror the cart server-side. Identity only — the backend re-prices from the\n * catalog and ignores anything else we send, so there is no point shipping\n * names or prices.\n *\n * `keepalive` lets the request survive the page unload that so often IS the\n * abandonment.\n *\n * The bearer token, when there is one, is how a signed-in shopper's cart gets\n * their user id: the endpoint takes identity from the token and never from the\n * body (`optionalAuth`), so omitting it left every logged-in cart anonymous —\n * joinable only by whatever email happened to be attached.\n */\nexport function postCartSnapshot(params: {\n items: CartSnapshotLine[];\n promoCode?: string | null;\n email?: string | null;\n}): void {\n try {\n const cfg = getConfig();\n void fetch(`${cfg.apiBase}/cart/snapshot`, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Tenant-Key': cfg.tenantKey,\n ...captureAuthHeader(),\n },\n body: JSON.stringify({\n cartId: cartId(),\n items: params.items,\n promoCode: params.promoCode ?? null,\n ...(params.email ? { email: params.email } : {}),\n // Only when a survey session already exists: it lets the backend reuse\n // the address the pre-survey email gate collected, which is often the\n // only handle we have on an anonymous shopper.\n ...(peekFunnelSessionId() ? { sessionId: peekFunnelSessionId() } : {}),\n }),\n }).catch(() => {});\n } catch {\n /* not configured yet — drop */\n }\n}\n\n/** A resumed cart line, already re-priced against today's catalog. */\nexport interface ResumedCartLine {\n productId: string;\n dosage?: string;\n quantity: number;\n name: string;\n priceCents: number;\n salePriceCents: number | null;\n thumbnailUrl: string | null;\n isSubscription: boolean;\n apexDrugId: string | null;\n categories: string[];\n hideDoseLabel: boolean;\n}\n\nexport interface ResumedCart {\n cartId: string;\n items: ResumedCartLine[];\n /** Lines whose product has since been discontinued or deactivated. */\n unavailable: Array<{ productId: string; dosage?: string; quantity: number }>;\n promoCode: string | null;\n subtotalCents: number;\n}\n\n/**\n * Exchange an emailed recovery token for the saved cart.\n *\n * The token is the ONLY thing authorizing this read — the-backend verifies its\n * HMAC before returning anything. A 404 (expired, already bought, tampered, or\n * every product gone) resolves to null so the caller simply keeps whatever cart\n * this browser already had.\n */\nexport async function fetchResumedCart(token: string): Promise<ResumedCart | null> {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/cart/resume?token=${encodeURIComponent(token)}`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Partial<ResumedCart>;\n if (!body.cartId || !Array.isArray(body.items) || body.items.length === 0) return null;\n return {\n cartId: body.cartId,\n items: body.items,\n unavailable: Array.isArray(body.unavailable) ? body.unavailable : [],\n promoCode: body.promoCode ?? null,\n subtotalCents: typeof body.subtotalCents === 'number' ? body.subtotalCents : 0,\n };\n } catch {\n return null;\n }\n}\n\n/** Read the `?cart=` token from the current URL. */\nexport function readCartToken(): string | null {\n try {\n const token = new URLSearchParams(window.location.search).get('cart');\n return token && token.length > 0 ? token : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Drop `?cart=` from the address bar once it's been redeemed, so a refresh (or\n * a shared URL) doesn't re-run the restore over a cart the shopper has since\n * edited. History is replaced, not pushed — the token was never a page.\n */\nexport function stripCartToken(): void {\n try {\n const url = new URL(window.location.href);\n if (!url.searchParams.has('cart')) return;\n url.searchParams.delete('cart');\n window.history.replaceState({}, '', url.toString());\n } catch {\n /* no history API — leaving the param is harmless */\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/api/promoRef.ts","../../src/api/cart.ts"],"names":[],"mappings":";;;;AAiBA,IAAM,MAAA,GAAS,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,GAAA;AAEnC,IAAM,UAAA,GAAa,MAAM,CAAA,EAAG,SAAA,GAAY,aAAa,CAAA,WAAA,CAAA;AAQ9C,SAAS,iBAAiB,IAAA,EAAoB;AACnD,EAAA,IAAI,OAAO,iBAAiB,W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AM,CAAA,CAAE,IAAI,MAAM,CAAA;AACpE,IAAA,OAAO,KAAA,IAAS,KAAA,CAAM,MAAA,GAAS,CAAA,GAAI,KAAA,GAAQ,IAAA;AAAA,EAC7C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAOO,SAAS,cAAA,GAAuB;AACrC,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,MAAA,CAAO,SAAS,IAAI,CAAA;AACxC,IAAA,IAAI,CAAC,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG;AACnC,IAAA,GAAA,CAAI,YAAA,CAAa,OAAO,MAAM,CAAA;AAC9B,IAAA,MAAA,CAAO,QAAQ,YAAA,CAAa,IAAI,EAAA,EAAI,GAAA,CAAI,UAAU,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"K2TKMLIY.js","sourcesContent":["// ── First-party promo-code capture from a `?promo=` landing ──────────\n//\n// A campaign link can carry its own code (`/?promo=TRUE10`) so the member does\n// not have to type it. Stashed in the storefront's own localStorage and read\n// back when the intake reaches the promo field.\n//\n// Mirrors `affiliateRef` deliberately — same storage shape, same 30-day window —\n// but is a SEPARATE concern: an affiliate ref attributes a sale to a partner and\n// is validated server-side at checkout, while this only pre-fills an input the\n// member still has to submit.\n\nimport { getConfig } from '../config';\n\n// Matches the affiliate-ref window. A stash that outlives the promo it carries\n// is not a correctness problem — the code is re-validated before it is used,\n// and silently dropped if it has expired — but there is no reason to keep one\n// around longer than a campaign plausibly runs.\nconst TTL_MS = 30 * 24 * 60 * 60 * 1000;\n\nconst storageKey = () => `${getConfig().storagePrefix}-promo-code`;\n\ninterface StoredPromo {\n code: string;\n ts: number;\n}\n\n/** Persist a promo code from a `?promo=` landing. No-op for empty input. */\nexport function capturePromoCode(code: string): void {\n if (typeof localStorage === 'undefined') return;\n const trimmed = code.trim();\n if (!trimmed) return;\n try {\n const entry: StoredPromo = { code: trimmed, ts: Date.now() };\n localStorage.setItem(storageKey(), JSON.stringify(entry));\n } catch {\n // storage unavailable (private mode / quota) — non-fatal\n }\n}\n\n/**\n * Read the stored promo code, or null if absent or past the storage window.\n *\n * Being within the window says nothing about whether the CODE is still valid —\n * a campaign can end while the stash is fresh. The caller re-validates against\n * the server before showing it to anyone.\n */\nexport function readPromoCode(): string | null {\n if (typeof localStorage === 'undefined') return null;\n try {\n const raw = localStorage.getItem(storageKey());\n if (!raw) return null;\n const parsed = JSON.parse(raw) as Partial<StoredPromo>;\n if (!parsed.code || typeof parsed.ts !== 'number') return null;\n if (Date.now() - parsed.ts > TTL_MS) {\n localStorage.removeItem(storageKey());\n return null;\n }\n return parsed.code;\n } catch {\n return null;\n }\n}\n\n/** Drop the stored promo code. */\nexport function clearPromoCode(): void {\n if (typeof localStorage === 'undefined') return;\n try {\n localStorage.removeItem(storageKey());\n } catch {\n // non-fatal\n }\n}\n","import { getConfig } from '../config';\nimport { captureAuthHeader, peekFunnelSessionId } from './funnel';\n\n// ── Abandoned-cart transport ────────────────────────────────────────────────\n//\n// Thin client for the-backend's cart-capture endpoints:\n// GET /config/cart → whether this tenant mirrors carts at all\n// POST /cart/snapshot → server-side mirror of the browser's cart\n// GET /cart/resume → trade an emailed token for the saved cart\n//\n// Sibling of ./funnel, and the same posture: fire-and-forget, fail-silent.\n// Cart capture is marketing instrumentation and must never break, block or\n// slow down shopping.\n\nexport interface CartCaptureConfig {\n /** Tenant opted in (features.cartRecovery); false = never send anything. */\n snapshot: boolean;\n}\n\nconst DISABLED: CartCaptureConfig = { snapshot: false };\n\nlet configPromise: Promise<CartCaptureConfig> | null = null;\n\n/**\n * The tenant's cart-capture posture, fetched once per page load and cached.\n * Fails closed: any error reads as \"off\".\n */\nexport function fetchCartConfig(): Promise<CartCaptureConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/cart`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<CartCaptureConfig>;\n return { snapshot: body.snapshot === true };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetCartConfigCache(): void {\n configPromise = null;\n}\n\nconst cartIdKey = () => `${getConfig().storagePrefix}-cart-id`;\n\n/**\n * Stable id for this shopper's cart, minted on first use and kept in\n * localStorage — NOT sessionStorage like the survey session.\n *\n * A cart outlives the tab it was filled in: someone adds items, closes the\n * browser, comes back tomorrow and finds the cart still there (the cart store\n * itself persists the same way). The id has to survive with it, or every visit\n * would look like a brand-new abandoned cart and one shopper would accumulate\n * a row — and a reminder track — per session.\n */\nexport function cartId(): string {\n let id: string | null = null;\n try {\n id = localStorage.getItem(cartIdKey());\n } catch {\n /* storage unavailable (private mode) — fall through to an ephemeral id */\n }\n if (!id) {\n id =\n typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* ephemeral it is */\n }\n }\n return id;\n}\n\n/**\n * Continue the cart a recovery email points at, instead of the one this browser\n * happens to hold. Adopting the emailed id keeps the reminder history, the\n * email address and the eventual conversion on ONE row.\n */\nexport function adoptCartId(id: string): void {\n if (!id) return;\n try {\n localStorage.setItem(cartIdKey(), id);\n } catch {\n /* storage unavailable — the adoption is ephemeral */\n }\n}\n\n/**\n * Start a fresh cart id. Called after a purchase: the old id is stamped\n * converted server-side and must never be written to again, or a new cart\n * would inherit a bought cart's row (and its silence — converted rows are\n * never nudged).\n */\nexport function resetCartId(): void {\n try {\n localStorage.removeItem(cartIdKey());\n } catch {\n /* nothing to clear */\n }\n}\n\nexport interface CartSnapshotLine {\n productId: string;\n dosage?: string;\n quantity: number;\n}\n\n/**\n * Mirror the cart server-side. Identity only — the backend re-prices from the\n * catalog and ignores anything else we send, so there is no point shipping\n * names or prices.\n *\n * `keepalive` lets the request survive the page unload that so often IS the\n * abandonment.\n *\n * The bearer token, when there is one, is how a signed-in shopper's cart gets\n * their user id: the endpoint takes identity from the token and never from the\n * body (`optionalAuth`), so omitting it left every logged-in cart anonymous —\n * joinable only by whatever email happened to be attached.\n */\nexport function postCartSnapshot(params: {\n items: CartSnapshotLine[];\n promoCode?: string | null;\n email?: string | null;\n}): void {\n try {\n const cfg = getConfig();\n void fetch(`${cfg.apiBase}/cart/snapshot`, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Tenant-Key': cfg.tenantKey,\n ...captureAuthHeader(),\n },\n body: JSON.stringify({\n cartId: cartId(),\n items: params.items,\n promoCode: params.promoCode ?? null,\n ...(params.email ? { email: params.email } : {}),\n // Only when a survey session already exists: it lets the backend reuse\n // the address the pre-survey email gate collected, which is often the\n // only handle we have on an anonymous shopper.\n ...(peekFunnelSessionId() ? { sessionId: peekFunnelSessionId() } : {}),\n }),\n }).catch(() => {});\n } catch {\n /* not configured yet — drop */\n }\n}\n\n/** A resumed cart line, already re-priced against today's catalog. */\nexport interface ResumedCartLine {\n productId: string;\n dosage?: string;\n quantity: number;\n name: string;\n priceCents: number;\n salePriceCents: number | null;\n thumbnailUrl: string | null;\n isSubscription: boolean;\n apexDrugId: string | null;\n categories: string[];\n hideDoseLabel: boolean;\n}\n\nexport interface ResumedCart {\n cartId: string;\n items: ResumedCartLine[];\n /** Lines whose product has since been discontinued or deactivated. */\n unavailable: Array<{ productId: string; dosage?: string; quantity: number }>;\n promoCode: string | null;\n subtotalCents: number;\n}\n\n/**\n * Exchange an emailed recovery token for the saved cart.\n *\n * The token is the ONLY thing authorizing this read — the-backend verifies its\n * HMAC before returning anything. A 404 (expired, already bought, tampered, or\n * every product gone) resolves to null so the caller simply keeps whatever cart\n * this browser already had.\n */\nexport async function fetchResumedCart(token: string): Promise<ResumedCart | null> {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/cart/resume?token=${encodeURIComponent(token)}`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Partial<ResumedCart>;\n if (!body.cartId || !Array.isArray(body.items) || body.items.length === 0) return null;\n return {\n cartId: body.cartId,\n items: body.items,\n unavailable: Array.isArray(body.unavailable) ? body.unavailable : [],\n promoCode: body.promoCode ?? null,\n subtotalCents: typeof body.subtotalCents === 'number' ? body.subtotalCents : 0,\n };\n } catch {\n return null;\n }\n}\n\n/** Read the `?cart=` token from the current URL. */\nexport function readCartToken(): string | null {\n try {\n const token = new URLSearchParams(window.location.search).get('cart');\n return token && token.length > 0 ? token : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Drop `?cart=` from the address bar once it's been redeemed, so a refresh (or\n * a shared URL) doesn't re-run the restore over a cart the shopper has since\n * edited. History is replaced, not pushed — the token was never a page.\n */\nexport function stripCartToken(): void {\n try {\n const url = new URL(window.location.href);\n if (!url.searchParams.has('cart')) return;\n url.searchParams.delete('cart');\n window.history.replaceState({}, '', url.toString());\n } catch {\n /* no history API — leaving the param is harmless */\n }\n}\n"]}
@@ -8,7 +8,7 @@ import {
8
8
  readPromoCode,
9
9
  resetCartId,
10
10
  stripCartToken
11
- } from "./6X2C7K6K.jsx";
11
+ } from "./GIJCNQCB.jsx";
12
12
  import {
13
13
  PHONE_ERROR,
14
14
  bestOfferDiscount,
@@ -25,11 +25,11 @@ import {
25
25
  useCatalogAvailability,
26
26
  useSmsConsent,
27
27
  validateAddress
28
- } from "./PXICBLZI.jsx";
28
+ } from "./L7TIWRSK.jsx";
29
29
  import {
30
30
  auth_default,
31
31
  cart_default
32
- } from "./QKCN523Q.jsx";
32
+ } from "./Z33DIIG6.jsx";
33
33
  import {
34
34
  ApiError,
35
35
  newIdempotencyKey,
@@ -37,7 +37,7 @@ import {
37
37
  promoCodesApi,
38
38
  subscriptionsApi,
39
39
  usersApi
40
- } from "./AA7EUOB6.jsx";
40
+ } from "./GWVFWHTO.jsx";
41
41
  import {
42
42
  getConfig
43
43
  } from "./QVZ7BRNO.jsx";
@@ -661,4 +661,4 @@ export {
661
661
  restoreCartFromLink,
662
662
  startCartCapture
663
663
  };
664
- //# sourceMappingURL=2GTWVO52.jsx.map
664
+ //# sourceMappingURL=L5DLLO2G.jsx.map
@@ -8,13 +8,13 @@ import {
8
8
  resetSmsConfigCache,
9
9
  saveFunnelDraft,
10
10
  stripResumeToken
11
- } from "./IM27S2HM.jsx";
11
+ } from "./2TGKQDQV.jsx";
12
12
  import {
13
13
  affiliateAuth_default,
14
14
  auth_default,
15
15
  cart_default,
16
16
  medication_default
17
- } from "./QKCN523Q.jsx";
17
+ } from "./Z33DIIG6.jsx";
18
18
  import {
19
19
  ApiError,
20
20
  addressesApi,
@@ -35,7 +35,7 @@ import {
35
35
  subscriptionsApi,
36
36
  supportApi,
37
37
  usersApi
38
- } from "./AA7EUOB6.jsx";
38
+ } from "./GWVFWHTO.jsx";
39
39
  import {
40
40
  getConfig
41
41
  } from "./QVZ7BRNO.jsx";
@@ -1577,9 +1577,6 @@ function formatUsPhone(raw) {
1577
1577
  return `(${ten.slice(0, 3)}) ${ten.slice(3, 6)}-${ten.slice(6)}`;
1578
1578
  }
1579
1579
 
1580
- // src/flows/signup.ts
1581
- import { createEffect as createEffect6, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1582
-
1583
1580
  // src/flows/_internal/smsConsent.ts
1584
1581
  import { createEffect as createEffect5, createSignal as createSignal7, on as on2, onCleanup as onCleanup3, onMount as onMount5 } from "solid-js";
1585
1582
  function offerFromConfig(cfg) {
@@ -1646,6 +1643,7 @@ function useSmsConsent(phone, restoredVersion) {
1646
1643
  }
1647
1644
 
1648
1645
  // src/flows/signup.ts
1646
+ import { createEffect as createEffect6, createSignal as createSignal8, onMount as onMount6 } from "solid-js";
1649
1647
  var DRAFT_TTL_MS = 7 * 24 * 3600 * 1e3;
1650
1648
  var MAX_RESTORABLE_STEP = 2;
1651
1649
  function draftKey() {
@@ -6807,4 +6805,4 @@ export {
6807
6805
  useAddPharmacy,
6808
6806
  useSmsPreferences
6809
6807
  };
6810
- //# sourceMappingURL=PXICBLZI.jsx.map
6808
+ //# sourceMappingURL=L7TIWRSK.jsx.map
@@ -1,4 +1,4 @@
1
- import { getTokens } from './3PUSGUJX.js';
1
+ import { getTokens } from './Y74YTJXR.js';
2
2
  import { getConfig } from './2IFPDU4D.js';
3
3
 
4
4
  // src/api/funnel.ts
@@ -174,5 +174,5 @@ function resetSmsConfigCache() {
174
174
  }
175
175
 
176
176
  export { adoptFunnelSessionId, captureAuthHeader, fetchFunnelConfig, fetchResumedDraft, fetchSmsConfig, funnelSessionId, peekFunnelSessionId, postFunnelEvent, readResumeToken, resetFunnelConfigCache, resetSmsConfigCache, saveFunnelDraft, stripResumeToken };
177
- //# sourceMappingURL=BJXH2J3Z.js.map
178
- //# sourceMappingURL=BJXH2J3Z.js.map
177
+ //# sourceMappingURL=PK74TNA6.js.map
178
+ //# sourceMappingURL=PK74TNA6.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/funnel.ts","../../src/api/sms.ts"],"names":["DISABLED","configPromise"],"mappings":";;;;AAmBA,IAAM,WAAyB,EAAE,SAAA,EAAW,OAAO,SAAA,EAAW,KAAA,EAAO,mBAAmB,KAAA,EAAM;AAE9F,IAAI,aAAA,GAA8C,IAAA;AAM3C,SAAS,iBAAA,GAA2C;AACzD,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,aAAA,GAAA,CAAiB,YAAY;AAC3B,MAAA,IAAI;AACF,QAAA,MAAM,MAAM,SAAA,EAAU;AACtB,QAAA,MAAM,MAAM,MAAM,KAAA,CAAM,CAAA,EAAG,GAAA,CAAI,OAAO,CAAA,cAAA,CAAA,EAAkB;AAAA,UACtD,OAAA,EAAS,EAAE,cAAA,EAAgB,GAAA,CAAI,SAAA;AAAU,SAC1C,CAAA;AACD,QAAA,IAAI,C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MAAM,MAAM,SAAA,EAAU;AACtB,QAAA,MAAM,MAAM,MAAM,KAAA,CAAM,CAAA,EAAG,GAAA,CAAI,OAAO,CAAA,WAAA,CAAA,EAAe;AAAA,UACnD,OAAA,EAAS,EAAE,cAAA,EAAgB,GAAA,CAAI,SAAA;AAAU,SAC1C,CAAA;AACD,QAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAOD,SAAAA;AACpB,QAAA,MAAM,IAAA,GAAQ,MAAM,GAAA,CAAI,IAAA,EAAK;AAC7B,QAAA,MAAM,WAAA,GAAc,GAAA,CAAI,IAAA,CAAK,WAAW,CAAA;AACxC,QAAA,MAAM,kBAAA,GAAqB,GAAA,CAAI,IAAA,CAAK,kBAAkB,CAAA;AACtD,QAAA,IAAI,KAAK,OAAA,KAAY,IAAA,IAAQ,CAAC,WAAA,IAAe,CAAC,oBAAoB,OAAOA,SAAAA;AACzE,QAAA,OAAO;AAAA,UACL,OAAA,EAAS,IAAA;AAAA,UACT,SAAA,EAAW,GAAA,CAAI,IAAA,CAAK,SAAS,CAAA;AAAA,UAC7B,WAAA;AAAA,UACA,kBAAA;AAAA,UACA,QAAA,EAAU,GAAA,CAAI,IAAA,CAAK,QAAQ,CAAA;AAAA,UAC3B,UAAA,EAAY,GAAA,CAAI,IAAA,CAAK,UAAU;AAAA,SACjC;AAAA,MACF,CAAA,CAAA,MAAQ;AACN,QAAA,OAAOA,SAAAA;AAAA,MACT;AAAA,IACF,CAAA,GAAG;AAAA,EACL;AACA,EAAA,OAAOC,cAAAA;AACT;AAGO,SAAS,mBAAA,GAA4B;AAC1C,EAAAA,cAAAA,GAAgB,IAAA;AAClB","file":"BJXH2J3Z.js","sourcesContent":["import { getConfig } from '../config';\nimport { getTokens } from './client';\n\n// ── Funnel telemetry transport ──────────────────────────────────────────────\n//\n// Thin client for the-backend's abandoned-funnel capture endpoints:\n// GET /config/funnel → which capture features this tenant enabled\n// POST /funnel/events → survey-session telemetry sink\n//\n// Everything here is fire-and-forget and fail-silent: funnel capture is\n// marketing instrumentation, and it must never break or slow the survey.\n\nexport interface FunnelConfig {\n telemetry: boolean;\n emailGate: boolean;\n /** When true (tenant features.funnelEmailGateRequired), the gate offers no skip. */\n emailGateRequired: boolean;\n}\n\nconst DISABLED: FunnelConfig = { telemetry: false, emailGate: false, emailGateRequired: false };\n\nlet configPromise: Promise<FunnelConfig> | null = null;\n\n/**\n * The tenant's funnel-capture posture, fetched once per page load and cached.\n * Fails closed: any error reads as \"both off\".\n */\nexport function fetchFunnelConfig(): Promise<FunnelConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/funnel`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<FunnelConfig>;\n return {\n telemetry: body.telemetry === true,\n emailGate: body.emailGate === true,\n emailGateRequired: body.emailGateRequired === true,\n };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/**\n * Continue an existing funnel session (resume-from-email): the emailed link\n * identifies the session that already holds this person's email and reminder\n * history, so adopting its id keeps everything on one row instead of forking a\n * new one that looks like a brand-new visitor.\n */\nexport function adoptFunnelSessionId(id: string): void {\n if (!id) return;\n try {\n sessionStorage.setItem(sessionIdKey(), id);\n } catch {\n /* storage unavailable — the session stays ephemeral */\n }\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetFunnelConfigCache(): void {\n configPromise = null;\n}\n\nconst sessionIdKey = () => `${getConfig().storagePrefix}-funnel-session`;\n\n/**\n * Stable id for this survey session, minted on first use and kept in\n * sessionStorage — a refresh continues the same session (matching the survey\n * draft's resume behavior); a new tab or browser session starts a new one.\n */\nexport function funnelSessionId(): string {\n let id: string | null = null;\n try {\n id = sessionStorage.getItem(sessionIdKey());\n } catch {\n /* storage unavailable (private mode) — fall through to ephemeral id */\n }\n if (!id) {\n id =\n typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n try {\n sessionStorage.setItem(sessionIdKey(), id);\n } catch {\n /* ephemeral it is */\n }\n }\n return id;\n}\n\n/**\n * The current survey session id, or null — WITHOUT minting one.\n *\n * `funnelSessionId()` creates an id on first read, which is right for the\n * survey (asking means a survey is starting) and wrong for anything else. Cart\n * capture uses this to say \"if this shopper also has a survey session, here it\n * is\" — letting the backend borrow the email the gate already collected —\n * without conjuring survey sessions on a storefront that never runs one.\n */\nexport function peekFunnelSessionId(): string | null {\n try {\n return sessionStorage.getItem(sessionIdKey());\n } catch {\n return null;\n }\n}\n\n/**\n * The member's access token, when this browser has one.\n *\n * Read raw and never refreshed: these are fire-and-forget telemetry posts, and\n * a token refresh is a real network round-trip on the unload path. An expired\n * token is not a failure either — the sinks take it with `optionalAuth`, so a\n * stale one simply reads as an anonymous visitor, which is what we had before.\n */\nexport function captureAuthHeader(): Record<string, string> {\n try {\n const token = getTokens()?.accessToken;\n return token ? { Authorization: `Bearer ${token}` } : {};\n } catch {\n return {};\n }\n}\n\n/**\n * Fire-and-forget event post. `keepalive` lets the request survive a page\n * unload — which is exactly when the `abandoned` event is sent. (This is why\n * it's `fetch` and not `navigator.sendBeacon`: beacons can't carry the\n * X-Tenant-Key header the tenant-scoped mount requires — nor the bearer token\n * below.)\n *\n * The token identifies a signed-in member to the sink. Without it a member's\n * session is stored anonymously, and the pre-survey email gate — the only\n * other writer of a session's identity — is deliberately never shown to\n * someone already signed in, so their drop-off could never be attributed to\n * them. That is the whole population of a site where the account is created\n * before the questionnaire (savings-program signups, returning members\n * starting a second intake).\n */\nexport function postFunnelEvent(type: string, data?: Record<string, unknown>): void {\n try {\n const cfg = getConfig();\n void fetch(`${cfg.apiBase}/funnel/events`, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Tenant-Key': cfg.tenantKey,\n ...captureAuthHeader(),\n },\n body: JSON.stringify({ sessionId: funnelSessionId(), type, data }),\n }).catch(() => {});\n } catch {\n /* not configured yet — drop */\n }\n}\n\n// ── Survey drafts (cross-device resume) ─────────────────────────────────────\n\nexport interface FunnelDraftPayload {\n answers: Array<{ questionId: string; value: unknown }>;\n stepIndex: number;\n}\n\n/**\n * Save in-progress answers to Apex (through the-backend's embed proxy) and\n * return the draft id, so the next save updates the same row.\n *\n * Answers travel to the CLINICAL system — the partner backend stores only the\n * returned pointer. Returns null on any failure: a draft is best-effort, and\n * losing one costs a retype, never correctness.\n */\nexport async function saveFunnelDraft(\n draft: FunnelDraftPayload & { draftId?: string; drugIds?: string[]; templateId?: string; mode?: string },\n): Promise<string | null> {\n try {\n const cfg = getConfig();\n if (!cfg.apexEmbedApiBase) return null;\n const res = await fetch(`${cfg.apexEmbedApiBase}/v2/embed/surveys/drafts`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json', 'X-Tenant-Key': cfg.tenantKey },\n body: JSON.stringify(draft),\n });\n if (!res.ok) return null;\n const body = (await res.json()) as { draftId?: string };\n return body.draftId ?? null;\n } catch {\n return null;\n }\n}\n\nexport interface ResumedDraft extends FunnelDraftPayload {\n sessionId: string;\n draftId: string;\n}\n\n/**\n * Exchange an emailed resume token for the saved answers.\n *\n * The token is the ONLY thing authorizing this read — the-backend verifies its\n * HMAC before fetching from Apex with credentials the browser never sees. A\n * 404 (expired, already submitted, tampered) resolves to null so the caller\n * simply starts a fresh survey.\n */\nexport async function fetchResumedDraft(token: string): Promise<ResumedDraft | null> {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/funnel/resume?token=${encodeURIComponent(token)}`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Partial<ResumedDraft>;\n if (!body.draftId || !Array.isArray(body.answers)) return null;\n return {\n sessionId: String(body.sessionId ?? ''),\n draftId: body.draftId,\n answers: body.answers,\n stepIndex: typeof body.stepIndex === 'number' ? body.stepIndex : 0,\n };\n } catch {\n return null;\n }\n}\n\n/** Read the `?resume=` token from the current URL. */\nexport function readResumeToken(): string | null {\n try {\n const token = new URLSearchParams(window.location.search).get('resume');\n return token && token.length > 0 ? token : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Drop `?resume=` from the address bar once it has been redeemed.\n *\n * This token authorizes a read of someone's clinical answers, so leaving it in\n * the address bar is worse than leaving the cart's there: it gets bookmarked,\n * pasted into a support chat, or captured by whatever the patient's browser\n * syncs. The answers are mirrored into local storage on redemption, so a\n * refresh resumes from this device without it. History is replaced, not\n * pushed — the token was never a page.\n */\nexport function stripResumeToken(): void {\n try {\n const url = new URL(window.location.href);\n if (!url.searchParams.has('resume')) return;\n url.searchParams.delete('resume');\n window.history.replaceState({}, '', url.toString());\n } catch {\n /* no history API — leaving the param is harmless */\n }\n}\n","import { getConfig } from '../config';\n\n// ── Customer text-message config ────────────────────────────────────────────\n//\n// Thin client for the-backend's tenant-level SMS posture:\n// GET /config/sms → whether this tenant texts customers at all, and the exact\n// consent wording (and its version) to show beside the box\n//\n// Sibling of ./cart and ./funnel, and the same posture: unauthenticated, cached\n// once per page load, fail-closed. Unlike those two it gates something a person\n// is asked to AGREE to, so \"any doubt\" reads as \"off\" — a consent box with no\n// wording to show must never render.\n\nexport interface SmsConfig {\n /** Tenant texts customers (feature on, number registered, switched on). false = show nothing. */\n enabled: boolean;\n /** The sender the consent wording names, e.g. \"Acme Health\". */\n brandName?: string;\n /** The consent wording, verbatim. Never reword it: what the person saw is what the record holds. */\n consentText?: string;\n /** Identifies `consentText`; sent back with a grant so the server knows which words were shown. */\n consentTextVersion?: string;\n termsUrl?: string;\n privacyUrl?: string;\n}\n\nconst DISABLED: SmsConfig = { enabled: false };\n\nconst str = (v: unknown): string | undefined => (typeof v === 'string' && v.trim() ? v : undefined);\n\nlet configPromise: Promise<SmsConfig> | null = null;\n\n/**\n * The tenant's text-message posture, fetched once per page load and cached.\n * Fails closed: any error — and an \"enabled\" reply that arrives without the\n * wording or its version — reads as \"off\".\n */\nexport function fetchSmsConfig(): Promise<SmsConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/sms`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<Record<keyof SmsConfig, unknown>>;\n const consentText = str(body.consentText);\n const consentTextVersion = str(body.consentTextVersion);\n if (body.enabled !== true || !consentText || !consentTextVersion) return DISABLED;\n return {\n enabled: true,\n brandName: str(body.brandName),\n consentText,\n consentTextVersion,\n termsUrl: str(body.termsUrl),\n privacyUrl: str(body.privacyUrl),\n };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetSmsConfigCache(): void {\n configPromise = null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/api/funnel.ts","../../src/api/sms.ts"],"names":["DISABLED","configPromise"],"mappings":";;;;AAmBA,IAAM,WAAyB,EAAE,SAAA,EAAW,OAAO,SAAA,EAAW,KAAA,EAAO,mBAAmB,KAAA,EAAM;AAE9F,IAAI,aAAA,GAA8C,IAAA;AAM3C,SAAS,iBAAA,GAA2C;AACzD,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,aAAA,GAAA,CAAiB,YAAY;AAC3B,MAAA,IAAI;AACF,QAAA,MAAM,MAAM,SAAA,EAAU;AACtB,QAAA,MAAM,MAAM,MAAM,KAAA,CAAM,CAAA,EAAG,GAAA,CAAI,OAAO,CAAA,cAAA,CAAA,EAAkB;AAAA,UACtD,OAAA,EAAS,EAAE,cAAA,EAAgB,GAAA,CAAI,SAAA;AAAU,SAC1C,CAAA;AACD,QAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAO,QAAA;AACpB,QAAA,MAAM,IAAA,GAAQ,MAAM,GAAA,CAAI,IAAA,EAAK;AAC7B,QAAA,OAAO;AAAA,UACL,SAAA,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EAAS,EAAE,cAAA,EAAgB,GAAA,CAAI,SAAA;AAAU,SAC1C,CAAA;AACD,QAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAOD,SAAAA;AACpB,QAAA,MAAM,IAAA,GAAQ,MAAM,GAAA,CAAI,IAAA,EAAK;AAC7B,QAAA,MAAM,WAAA,GAAc,GAAA,CAAI,IAAA,CAAK,WAAW,CAAA;AACxC,QAAA,MAAM,kBAAA,GAAqB,GAAA,CAAI,IAAA,CAAK,kBAAkB,CAAA;AACtD,QAAA,IAAI,KAAK,OAAA,KAAY,IAAA,IAAQ,CAAC,WAAA,IAAe,CAAC,oBAAoB,OAAOA,SAAAA;AACzE,QAAA,OAAO;AAAA,UACL,OAAA,EAAS,IAAA;AAAA,UACT,SAAA,EAAW,GAAA,CAAI,IAAA,CAAK,SAAS,CAAA;AAAA,UAC7B,WAAA;AAAA,UACA,kBAAA;AAAA,UACA,QAAA,EAAU,GAAA,CAAI,IAAA,CAAK,QAAQ,CAAA;AAAA,UAC3B,UAAA,EAAY,GAAA,CAAI,IAAA,CAAK,UAAU;AAAA,SACjC;AAAA,MACF,CAAA,CAAA,MAAQ;AACN,QAAA,OAAOA,SAAAA;AAAA,MACT;AAAA,IACF,CAAA,GAAG;AAAA,EACL;AACA,EAAA,OAAOC,cAAAA;AACT;AAGO,SAAS,mBAAA,GAA4B;AAC1C,EAAAA,cAAAA,GAAgB,IAAA;AAClB","file":"PK74TNA6.js","sourcesContent":["import { getConfig } from '../config';\nimport { getTokens } from './client';\n\n// ── Funnel telemetry transport ──────────────────────────────────────────────\n//\n// Thin client for the-backend's abandoned-funnel capture endpoints:\n// GET /config/funnel → which capture features this tenant enabled\n// POST /funnel/events → survey-session telemetry sink\n//\n// Everything here is fire-and-forget and fail-silent: funnel capture is\n// marketing instrumentation, and it must never break or slow the survey.\n\nexport interface FunnelConfig {\n telemetry: boolean;\n emailGate: boolean;\n /** When true (tenant features.funnelEmailGateRequired), the gate offers no skip. */\n emailGateRequired: boolean;\n}\n\nconst DISABLED: FunnelConfig = { telemetry: false, emailGate: false, emailGateRequired: false };\n\nlet configPromise: Promise<FunnelConfig> | null = null;\n\n/**\n * The tenant's funnel-capture posture, fetched once per page load and cached.\n * Fails closed: any error reads as \"both off\".\n */\nexport function fetchFunnelConfig(): Promise<FunnelConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/funnel`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<FunnelConfig>;\n return {\n telemetry: body.telemetry === true,\n emailGate: body.emailGate === true,\n emailGateRequired: body.emailGateRequired === true,\n };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/**\n * Continue an existing funnel session (resume-from-email): the emailed link\n * identifies the session that already holds this person's email and reminder\n * history, so adopting its id keeps everything on one row instead of forking a\n * new one that looks like a brand-new visitor.\n */\nexport function adoptFunnelSessionId(id: string): void {\n if (!id) return;\n try {\n sessionStorage.setItem(sessionIdKey(), id);\n } catch {\n /* storage unavailable — the session stays ephemeral */\n }\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetFunnelConfigCache(): void {\n configPromise = null;\n}\n\nconst sessionIdKey = () => `${getConfig().storagePrefix}-funnel-session`;\n\n/**\n * Stable id for this survey session, minted on first use and kept in\n * sessionStorage — a refresh continues the same session (matching the survey\n * draft's resume behavior); a new tab or browser session starts a new one.\n */\nexport function funnelSessionId(): string {\n let id: string | null = null;\n try {\n id = sessionStorage.getItem(sessionIdKey());\n } catch {\n /* storage unavailable (private mode) — fall through to ephemeral id */\n }\n if (!id) {\n id =\n typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n try {\n sessionStorage.setItem(sessionIdKey(), id);\n } catch {\n /* ephemeral it is */\n }\n }\n return id;\n}\n\n/**\n * The current survey session id, or null — WITHOUT minting one.\n *\n * `funnelSessionId()` creates an id on first read, which is right for the\n * survey (asking means a survey is starting) and wrong for anything else. Cart\n * capture uses this to say \"if this shopper also has a survey session, here it\n * is\" — letting the backend borrow the email the gate already collected —\n * without conjuring survey sessions on a storefront that never runs one.\n */\nexport function peekFunnelSessionId(): string | null {\n try {\n return sessionStorage.getItem(sessionIdKey());\n } catch {\n return null;\n }\n}\n\n/**\n * The member's access token, when this browser has one.\n *\n * Read raw and never refreshed: these are fire-and-forget telemetry posts, and\n * a token refresh is a real network round-trip on the unload path. An expired\n * token is not a failure either — the sinks take it with `optionalAuth`, so a\n * stale one simply reads as an anonymous visitor, which is what we had before.\n */\nexport function captureAuthHeader(): Record<string, string> {\n try {\n const token = getTokens()?.accessToken;\n return token ? { Authorization: `Bearer ${token}` } : {};\n } catch {\n return {};\n }\n}\n\n/**\n * Fire-and-forget event post. `keepalive` lets the request survive a page\n * unload — which is exactly when the `abandoned` event is sent. (This is why\n * it's `fetch` and not `navigator.sendBeacon`: beacons can't carry the\n * X-Tenant-Key header the tenant-scoped mount requires — nor the bearer token\n * below.)\n *\n * The token identifies a signed-in member to the sink. Without it a member's\n * session is stored anonymously, and the pre-survey email gate — the only\n * other writer of a session's identity — is deliberately never shown to\n * someone already signed in, so their drop-off could never be attributed to\n * them. That is the whole population of a site where the account is created\n * before the questionnaire (savings-program signups, returning members\n * starting a second intake).\n */\nexport function postFunnelEvent(type: string, data?: Record<string, unknown>): void {\n try {\n const cfg = getConfig();\n void fetch(`${cfg.apiBase}/funnel/events`, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Tenant-Key': cfg.tenantKey,\n ...captureAuthHeader(),\n },\n body: JSON.stringify({ sessionId: funnelSessionId(), type, data }),\n }).catch(() => {});\n } catch {\n /* not configured yet — drop */\n }\n}\n\n// ── Survey drafts (cross-device resume) ─────────────────────────────────────\n\nexport interface FunnelDraftPayload {\n answers: Array<{ questionId: string; value: unknown }>;\n stepIndex: number;\n}\n\n/**\n * Save in-progress answers to Apex (through the-backend's embed proxy) and\n * return the draft id, so the next save updates the same row.\n *\n * Answers travel to the CLINICAL system — the partner backend stores only the\n * returned pointer. Returns null on any failure: a draft is best-effort, and\n * losing one costs a retype, never correctness.\n */\nexport async function saveFunnelDraft(\n draft: FunnelDraftPayload & { draftId?: string; drugIds?: string[]; templateId?: string; mode?: string },\n): Promise<string | null> {\n try {\n const cfg = getConfig();\n if (!cfg.apexEmbedApiBase) return null;\n const res = await fetch(`${cfg.apexEmbedApiBase}/v2/embed/surveys/drafts`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json', 'X-Tenant-Key': cfg.tenantKey },\n body: JSON.stringify(draft),\n });\n if (!res.ok) return null;\n const body = (await res.json()) as { draftId?: string };\n return body.draftId ?? null;\n } catch {\n return null;\n }\n}\n\nexport interface ResumedDraft extends FunnelDraftPayload {\n sessionId: string;\n draftId: string;\n}\n\n/**\n * Exchange an emailed resume token for the saved answers.\n *\n * The token is the ONLY thing authorizing this read — the-backend verifies its\n * HMAC before fetching from Apex with credentials the browser never sees. A\n * 404 (expired, already submitted, tampered) resolves to null so the caller\n * simply starts a fresh survey.\n */\nexport async function fetchResumedDraft(token: string): Promise<ResumedDraft | null> {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/funnel/resume?token=${encodeURIComponent(token)}`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Partial<ResumedDraft>;\n if (!body.draftId || !Array.isArray(body.answers)) return null;\n return {\n sessionId: String(body.sessionId ?? ''),\n draftId: body.draftId,\n answers: body.answers,\n stepIndex: typeof body.stepIndex === 'number' ? body.stepIndex : 0,\n };\n } catch {\n return null;\n }\n}\n\n/** Read the `?resume=` token from the current URL. */\nexport function readResumeToken(): string | null {\n try {\n const token = new URLSearchParams(window.location.search).get('resume');\n return token && token.length > 0 ? token : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Drop `?resume=` from the address bar once it has been redeemed.\n *\n * This token authorizes a read of someone's clinical answers, so leaving it in\n * the address bar is worse than leaving the cart's there: it gets bookmarked,\n * pasted into a support chat, or captured by whatever the patient's browser\n * syncs. The answers are mirrored into local storage on redemption, so a\n * refresh resumes from this device without it. History is replaced, not\n * pushed — the token was never a page.\n */\nexport function stripResumeToken(): void {\n try {\n const url = new URL(window.location.href);\n if (!url.searchParams.has('resume')) return;\n url.searchParams.delete('resume');\n window.history.replaceState({}, '', url.toString());\n } catch {\n /* no history API — leaving the param is harmless */\n }\n}\n","import { getConfig } from '../config';\n\n// ── Customer text-message config ────────────────────────────────────────────\n//\n// Thin client for the-backend's tenant-level SMS posture:\n// GET /config/sms → whether this tenant texts customers at all, and the exact\n// consent wording (and its version) to show beside the box\n//\n// Sibling of ./cart and ./funnel, and the same posture: unauthenticated, cached\n// once per page load, fail-closed. Unlike those two it gates something a person\n// is asked to AGREE to, so \"any doubt\" reads as \"off\" — a consent box with no\n// wording to show must never render.\n\nexport interface SmsConfig {\n /** Tenant texts customers (feature on, number registered, switched on). false = show nothing. */\n enabled: boolean;\n /** The sender the consent wording names, e.g. \"Acme Health\". */\n brandName?: string;\n /** The consent wording, verbatim. Never reword it: what the person saw is what the record holds. */\n consentText?: string;\n /** Identifies `consentText`; sent back with a grant so the server knows which words were shown. */\n consentTextVersion?: string;\n termsUrl?: string;\n privacyUrl?: string;\n}\n\nconst DISABLED: SmsConfig = { enabled: false };\n\nconst str = (v: unknown): string | undefined => (typeof v === 'string' && v.trim() ? v : undefined);\n\nlet configPromise: Promise<SmsConfig> | null = null;\n\n/**\n * The tenant's text-message posture, fetched once per page load and cached.\n * Fails closed: any error — and an \"enabled\" reply that arrives without the\n * wording or its version — reads as \"off\".\n */\nexport function fetchSmsConfig(): Promise<SmsConfig> {\n if (!configPromise) {\n configPromise = (async () => {\n try {\n const cfg = getConfig();\n const res = await fetch(`${cfg.apiBase}/config/sms`, {\n headers: { 'X-Tenant-Key': cfg.tenantKey },\n });\n if (!res.ok) return DISABLED;\n const body = (await res.json()) as Partial<Record<keyof SmsConfig, unknown>>;\n const consentText = str(body.consentText);\n const consentTextVersion = str(body.consentTextVersion);\n if (body.enabled !== true || !consentText || !consentTextVersion) return DISABLED;\n return {\n enabled: true,\n brandName: str(body.brandName),\n consentText,\n consentTextVersion,\n termsUrl: str(body.termsUrl),\n privacyUrl: str(body.privacyUrl),\n };\n } catch {\n return DISABLED;\n }\n })();\n }\n return configPromise;\n}\n\n/** Test seam: forget the cached config so the next fetch re-resolves. */\nexport function resetSmsConfigCache(): void {\n configPromise = null;\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { readPromoCode, clearPromoCode, readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './GF4CVY2S.js';
2
- import { useCardTokenizer, useSmsConsent, useAddressPair, useCatalogAvailability, isLive, formatCvv, formatExpiry, formatCardNumber, bestOfferDiscount, offerBeatsPromo, catalogUnavailableMessage, firstAddressError, validateAddress, isValidUsPhone, PHONE_ERROR } from './M6PV6FON.js';
3
- import { auth_default, cart_default } from './TNGDSXSC.js';
4
- import { promoCodesApi, subscriptionsApi, offersApi, newIdempotencyKey, usersApi, ApiError } from './3PUSGUJX.js';
1
+ import { readPromoCode, clearPromoCode, readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './K2TKMLIY.js';
2
+ import { useCardTokenizer, useSmsConsent, useAddressPair, useCatalogAvailability, isLive, formatCvv, formatExpiry, formatCardNumber, bestOfferDiscount, offerBeatsPromo, catalogUnavailableMessage, firstAddressError, validateAddress, isValidUsPhone, PHONE_ERROR } from './4GYQYONL.js';
3
+ import { auth_default, cart_default } from './74A4ERWQ.js';
4
+ import { promoCodesApi, subscriptionsApi, offersApi, newIdempotencyKey, usersApi, ApiError } from './Y74YTJXR.js';
5
5
  import { getConfig } from './2IFPDU4D.js';
6
6
  import { createSignal, onMount, createEffect, on, createRoot } from 'solid-js';
7
7
 
@@ -613,5 +613,5 @@ function startCartCapture(opts = {}) {
613
613
  }
614
614
 
615
615
  export { OFFER_BEATS_PROMO_NOTICE, restoreCartFromLink, startCartCapture, useSubscriptionIntakeFlow, validateResumedPromo };
616
- //# sourceMappingURL=MCZVL3GO.js.map
617
- //# sourceMappingURL=MCZVL3GO.js.map
616
+ //# sourceMappingURL=SAHG4GZB.js.map
617
+ //# sourceMappingURL=SAHG4GZB.js.map