@apextelemed/partner-core 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/api/index.d.ts +14 -1
  2. package/dist/api/index.js +2 -2
  3. package/dist/api/index.jsx +8 -2
  4. package/dist/chunk/{SNAV6DII.jsx → 6HLXYY4F.jsx} +26 -4
  5. package/dist/chunk/{FJZHH5T4.jsx → AAWNUGML.jsx} +310 -2
  6. package/dist/chunk/ACE7M2YA.jsx +1 -0
  7. package/dist/chunk/{MEWFN6IW.jsx → B63K5R7M.jsx} +32 -2
  8. package/dist/chunk/{EIXV4DCU.js → FBVNUFJM.js} +26 -6
  9. package/dist/chunk/FBVNUFJM.js.map +1 -0
  10. package/dist/chunk/JSHO46VZ.js +3 -0
  11. package/dist/chunk/JSHO46VZ.js.map +1 -0
  12. package/dist/chunk/{6TFBQECC.jsx → NP4CMOLW.jsx} +41 -1
  13. package/dist/chunk/{OEXSGX5F.js → QSSVQ5PR.js} +664 -329
  14. package/dist/chunk/QSSVQ5PR.js.map +1 -0
  15. package/dist/chunk/{KFJXIKD4.js → SE6JHCPZ.js} +32 -3
  16. package/dist/chunk/SE6JHCPZ.js.map +1 -0
  17. package/dist/chunk/{J6KNY37T.js → XMYPS7PT.js} +40 -3
  18. package/dist/chunk/XMYPS7PT.js.map +1 -0
  19. package/dist/flows/index.js +3 -3
  20. package/dist/flows/index.jsx +3 -3
  21. package/dist/index/index.d.ts +1 -1
  22. package/dist/index/index.js +5 -5
  23. package/dist/index/index.jsx +11 -5
  24. package/dist/pages/index.js +2 -2
  25. package/dist/pages/index.jsx +2 -2
  26. package/dist/testing/storage.d.ts +1 -1
  27. package/dist/testing/storage.d.ts.map +1 -1
  28. package/dist/testing/storage.js +1 -0
  29. package/dist/testing/storage.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk/AN3WPMEP.js +0 -3
  32. package/dist/chunk/AN3WPMEP.js.map +0 -1
  33. package/dist/chunk/EIXV4DCU.js.map +0 -1
  34. package/dist/chunk/J6KNY37T.js.map +0 -1
  35. package/dist/chunk/KFJXIKD4.js.map +0 -1
  36. package/dist/chunk/O3QK7YZR.jsx +0 -1
  37. package/dist/chunk/OEXSGX5F.js.map +0 -1
@@ -9,4 +9,17 @@ declare function readAffiliateRef(): string | null;
9
9
  /** Drop the stored referral code. */
10
10
  declare function clearAffiliateRef(): void;
11
11
 
12
- export { captureAffiliateRef, clearAffiliateRef, readAffiliateRef };
12
+ /** Persist a promo code from a `?promo=` landing. No-op for empty input. */
13
+ declare function capturePromoCode(code: string): void;
14
+ /**
15
+ * Read the stored promo code, or null if absent or past the storage window.
16
+ *
17
+ * Being within the window says nothing about whether the CODE is still valid —
18
+ * a campaign can end while the stash is fresh. The caller re-validates against
19
+ * the server before showing it to anyone.
20
+ */
21
+ declare function readPromoCode(): string | null;
22
+ /** Drop the stored promo code. */
23
+ declare function clearPromoCode(): void;
24
+
25
+ export { captureAffiliateRef, capturePromoCode, clearAffiliateRef, clearPromoCode, readAffiliateRef, readPromoCode };
package/dist/api/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import '../chunk/AN3WPMEP.js';
2
- export { adoptCartId, cartId, fetchCartConfig, fetchResumedCart, postCartSnapshot, readCartToken, resetCartConfigCache, resetCartId, stripCartToken } from '../chunk/J6KNY37T.js';
1
+ import '../chunk/JSHO46VZ.js';
2
+ export { adoptCartId, capturePromoCode, cartId, clearPromoCode, fetchCartConfig, fetchResumedCart, postCartSnapshot, readCartToken, readPromoCode, resetCartConfigCache, resetCartId, stripCartToken } from '../chunk/XMYPS7PT.js';
3
3
  export { EmbedApiError2 as ApexV2ApiError, EmbedApiError, createEmbedApiClient, disqualificationReasonText, disqualifiedDrugIds, qualifiedDrugIds } from '../chunk/LZWA44KD.js';
4
4
  export { adoptFunnelSessionId, fetchFunnelConfig, fetchResumedDraft, funnelSessionId, peekFunnelSessionId, postFunnelEvent, readResumeToken, resetFunnelConfigCache, saveFunnelDraft, stripResumeToken } from '../chunk/DS4E7FAI.js';
5
5
  export { ApiError, SUPPORT_ATTACHMENT_MAX_BYTES, SUPPORT_ATTACHMENT_MIME_TYPES, addressesApi, adminAffiliatesApi, adminApi, affiliateAuthStorageKey, affiliatePortalApi, apexApi, apiFetch, authApi, authStorageKey, captureAffiliateRef, clearAffiliateRef, clearAffiliateTokens, clearTokens, getAffiliateTokens, getTokens, membersApi, messagesApi, newIdempotencyKey, onTokensCleared, ordersApi, paymentsApi, productsApi, promoCodesApi, readAffiliateRef, setAffiliateTokens, setTokens, subscriptionsApi, supportApi, usersApi } from '../chunk/UNAI6NBV.js';
@@ -1,15 +1,18 @@
1
- import "../chunk/O3QK7YZR.jsx";
1
+ import "../chunk/ACE7M2YA.jsx";
2
2
  import {
3
3
  adoptCartId,
4
+ capturePromoCode,
4
5
  cartId,
6
+ clearPromoCode,
5
7
  fetchCartConfig,
6
8
  fetchResumedCart,
7
9
  postCartSnapshot,
8
10
  readCartToken,
11
+ readPromoCode,
9
12
  resetCartConfigCache,
10
13
  resetCartId,
11
14
  stripCartToken
12
- } from "../chunk/6TFBQECC.jsx";
15
+ } from "../chunk/NP4CMOLW.jsx";
13
16
  import {
14
17
  EmbedApiError,
15
18
  EmbedApiError2,
@@ -83,9 +86,11 @@ export {
83
86
  authApi,
84
87
  authStorageKey,
85
88
  captureAffiliateRef,
89
+ capturePromoCode,
86
90
  cartId,
87
91
  clearAffiliateRef,
88
92
  clearAffiliateTokens,
93
+ clearPromoCode,
89
94
  clearTokens,
90
95
  createEmbedApiClient,
91
96
  disqualificationReasonText,
@@ -111,6 +116,7 @@ export {
111
116
  qualifiedDrugIds,
112
117
  readAffiliateRef,
113
118
  readCartToken,
119
+ readPromoCode,
114
120
  readResumeToken,
115
121
  resetCartConfigCache,
116
122
  resetCartId,
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  adoptCartId,
3
+ clearPromoCode,
3
4
  fetchCartConfig,
4
5
  fetchResumedCart,
5
6
  postCartSnapshot,
6
7
  readCartToken,
8
+ readPromoCode,
7
9
  resetCartId,
8
10
  stripCartToken
9
- } from "./6TFBQECC.jsx";
11
+ } from "./NP4CMOLW.jsx";
10
12
  import {
11
13
  firstAddressError,
12
14
  formatCardNumber,
@@ -16,7 +18,7 @@ import {
16
18
  useAddressPair,
17
19
  useCardTokenizer,
18
20
  validateAddress
19
- } from "./MEWFN6IW.jsx";
21
+ } from "./B63K5R7M.jsx";
20
22
  import {
21
23
  auth_default,
22
24
  cart_default,
@@ -289,6 +291,20 @@ function useSubscriptionIntakeFlow(options) {
289
291
  const [promoValidating, setPromoValidating] = createSignal2(false);
290
292
  const [promoError, setPromoError] = createSignal2(null);
291
293
  const [promoApplied, setPromoApplied] = createSignal2(null);
294
+ onMount(async () => {
295
+ if (promoCode().trim()) return;
296
+ const stashed = readPromoCode();
297
+ if (!stashed) return;
298
+ try {
299
+ const res = await promoCodesApi.validate(stashed, {
300
+ productIds: [options.pricing.productId],
301
+ subtotalCents: savingsBaseCents()
302
+ });
303
+ if (res.valid) setPromoCode(stashed);
304
+ else clearPromoCode();
305
+ } catch {
306
+ }
307
+ });
292
308
  const [idemKey, setIdemKey] = createSignal2(restored.idempotencyKey ?? "");
293
309
  onMount(() => {
294
310
  createEffect(() => {
@@ -353,7 +369,13 @@ function useSubscriptionIntakeFlow(options) {
353
369
  try {
354
370
  const res = await promoCodesApi.validate(code, {
355
371
  productIds: [options.pricing.productId],
356
- subtotalCents: options.pricing.priceCents
372
+ // The base the promo will actually be applied to. For a savings member
373
+ // that is the savings price, not list: the server discounts the
374
+ // savings-substituted subtotal at checkout, so quoting off list would
375
+ // show a percentage promo as a bigger saving than it is (10% of $399
376
+ // displayed, 10% of $280 charged). Same rule as savingsBaseCents — keep
377
+ // the two in step.
378
+ subtotalCents: savingsBaseCents()
357
379
  });
358
380
  if (!res.valid) {
359
381
  setPromoError(res.error ?? "Invalid promo code.");
@@ -730,4 +752,4 @@ export {
730
752
  restoreCartFromLink,
731
753
  startCartCapture
732
754
  };
733
- //# sourceMappingURL=SNAV6DII.jsx.map
755
+ //# sourceMappingURL=6HLXYY4F.jsx.map
@@ -19,6 +19,7 @@ import {
19
19
  redeemResumeLink,
20
20
  resolveSurveyV2DrugIntent,
21
21
  stateAvailabilityNote,
22
+ uploadPrescriptionPhoto,
22
23
  useAffiliateConversions,
23
24
  useAffiliateDownline,
24
25
  useAffiliateLinks,
@@ -34,7 +35,7 @@ import {
34
35
  useSurveyFlow,
35
36
  useSurveyV2Flow,
36
37
  useUpdatePaymentMethodFlow
37
- } from "./MEWFN6IW.jsx";
38
+ } from "./B63K5R7M.jsx";
38
39
  import {
39
40
  fetchFunnelConfig
40
41
  } from "./I46Y2J5W.jsx";
@@ -1633,6 +1634,305 @@ function MultiSelectQuestion(props) {
1633
1634
  </div>
1634
1635
  </Show3>;
1635
1636
  }
1637
+ var PHOTO_CHECKLIST_ITEMS = [
1638
+ { key: "drugName", label: "Drug name" },
1639
+ { key: "dosageSchedule", label: "Dosage & schedule" },
1640
+ { key: "expiration", label: "Expiration date" },
1641
+ { key: "prescriber", label: "Prescriber" },
1642
+ { key: "refillsLeft", label: "Refills left" },
1643
+ { key: "rxNumber", label: "Prescription number" },
1644
+ { key: "pharmacy", label: "Pharmacy" },
1645
+ { key: "phone", label: "Pharmacy phone" }
1646
+ ];
1647
+ function emptyChecklist() {
1648
+ return {
1649
+ drugName: false,
1650
+ dosageSchedule: false,
1651
+ expiration: false,
1652
+ prescriber: false,
1653
+ refillsLeft: false,
1654
+ rxNumber: false,
1655
+ pharmacy: false,
1656
+ phone: false
1657
+ };
1658
+ }
1659
+ function PrescriptionPhotosQuestion(props) {
1660
+ const { Button, Banner, Spinner, Textarea } = usePrimitives();
1661
+ const initial = props.value;
1662
+ const restoredPhotos = initial && "photos" in initial && Array.isArray(initial.photos) ? initial.photos.map((p) => ({
1663
+ photoId: p.photoId,
1664
+ checklist: { ...emptyChecklist(), ...p.checklist }
1665
+ })) : [];
1666
+ const [entries, setEntries] = createSignal(restoredPhotos);
1667
+ const [done, setDone] = createSignal(restoredPhotos.length > 0);
1668
+ const [none, setNone] = createSignal(!!initial && "none" in initial && initial.none === true);
1669
+ const [manual, setManual] = createSignal(
1670
+ !!initial && "manual" in initial && typeof initial.manual === "string"
1671
+ );
1672
+ const [manualText, setManualText] = createSignal(
1673
+ initial && "manual" in initial && typeof initial.manual === "string" ? initial.manual : ""
1674
+ );
1675
+ const [uploading, setUploading] = createSignal(false);
1676
+ const [error, setError] = createSignal(null);
1677
+ let fileInput;
1678
+ const allChecked = (e) => PHOTO_CHECKLIST_ITEMS.every((i) => e.checklist[i.key]);
1679
+ function emit() {
1680
+ if (none()) return props.onChange({ version: 1, none: true });
1681
+ if (manual()) {
1682
+ const text = manualText().trim();
1683
+ return props.onChange(text ? { version: 1, manual: manualText() } : void 0);
1684
+ }
1685
+ const list = entries();
1686
+ if (list.length > 0 && done() && list.every(allChecked)) {
1687
+ return props.onChange({
1688
+ version: 1,
1689
+ photos: list.map((e) => ({ photoId: e.photoId, checklist: e.checklist }))
1690
+ });
1691
+ }
1692
+ props.onChange(void 0);
1693
+ }
1694
+ async function handleFile(file) {
1695
+ if (!file) return;
1696
+ setError(null);
1697
+ setUploading(true);
1698
+ try {
1699
+ const { photoId } = await uploadPrescriptionPhoto(file);
1700
+ setEntries((prev) => [
1701
+ ...prev,
1702
+ { photoId, checklist: emptyChecklist(), objectUrl: URL.createObjectURL(file) }
1703
+ ]);
1704
+ setDone(false);
1705
+ emit();
1706
+ } catch (err) {
1707
+ setError(err instanceof Error ? err.message : "Photo upload failed. Please try again.");
1708
+ } finally {
1709
+ setUploading(false);
1710
+ if (fileInput) fileInput.value = "";
1711
+ }
1712
+ }
1713
+ function removeEntry(photoId) {
1714
+ const entry = entries().find((e) => e.photoId === photoId);
1715
+ if (entry?.objectUrl) URL.revokeObjectURL(entry.objectUrl);
1716
+ setEntries((prev) => prev.filter((e) => e.photoId !== photoId));
1717
+ emit();
1718
+ }
1719
+ function toggleCheck(photoId, key, checked) {
1720
+ setEntries(
1721
+ (prev) => prev.map(
1722
+ (e) => e.photoId === photoId ? { ...e, checklist: { ...e.checklist, [key]: checked } } : e
1723
+ )
1724
+ );
1725
+ emit();
1726
+ }
1727
+ const blockedHint = () => {
1728
+ if (none() || manual() && manualText().trim()) return null;
1729
+ const list = entries();
1730
+ if (list.length === 0 && !manual()) {
1731
+ return "Add at least one prescription photo \u2014 or choose an option below if you have none or can\u2019t upload.";
1732
+ }
1733
+ if (manual()) return "Enter your prescription information to continue.";
1734
+ if (!list.every(allChecked)) {
1735
+ return "Confirm each item is visible in every photo (retake the photo if something isn\u2019t).";
1736
+ }
1737
+ if (!done()) return 'Check "I\u2019ve added all my prescriptions" when you\u2019re finished.';
1738
+ return null;
1739
+ };
1740
+ return <div style={{ display: "flex", "flex-direction": "column", gap: "0.75rem" }}>
1741
+ <div>
1742
+ <div style={{ "font-size": "0.875rem", "font-weight": 500 }}>{props.label}</div>
1743
+ <Show3 when={props.helpText}>
1744
+ <div style={{ "font-size": "0.8125rem", opacity: 0.65, "margin-top": "0.25rem" }}>
1745
+ {props.helpText}
1746
+ </div>
1747
+ </Show3>
1748
+ </div>
1749
+
1750
+ <Show3 when={error()}>
1751
+ <Banner variant="error">{error()}</Banner>
1752
+ </Show3>
1753
+
1754
+ {
1755
+ /* Uploaded photos, each with its visibility checklist. */
1756
+ }
1757
+ <For2 each={entries()}>
1758
+ {(entry, i) => <div
1759
+ style={{
1760
+ border: "1px solid rgba(128,128,128,0.25)",
1761
+ "border-radius": "0.5rem",
1762
+ padding: "0.75rem",
1763
+ display: "flex",
1764
+ "flex-direction": "column",
1765
+ gap: "0.5rem"
1766
+ }}
1767
+ >
1768
+ <div style={{ display: "flex", gap: "0.75rem", "align-items": "flex-start" }}>
1769
+ <Show3
1770
+ when={entry.objectUrl}
1771
+ fallback={<div
1772
+ style={{
1773
+ width: "72px",
1774
+ height: "72px",
1775
+ "border-radius": "0.375rem",
1776
+ background: "rgba(128,128,128,0.12)",
1777
+ display: "flex",
1778
+ "align-items": "center",
1779
+ "justify-content": "center",
1780
+ "font-size": "0.6875rem",
1781
+ opacity: 0.7,
1782
+ "text-align": "center",
1783
+ "flex-shrink": 0
1784
+ }}
1785
+ >
1786
+ Photo uploaded
1787
+ </div>}
1788
+ >
1789
+ <img
1790
+ src={entry.objectUrl}
1791
+ alt={`Prescription photo ${i() + 1}`}
1792
+ style={{
1793
+ width: "72px",
1794
+ height: "72px",
1795
+ "object-fit": "cover",
1796
+ "border-radius": "0.375rem",
1797
+ "flex-shrink": 0
1798
+ }}
1799
+ />
1800
+ </Show3>
1801
+ <div style={{ flex: 1 }}>
1802
+ <div style={{ "font-size": "0.8125rem", "font-weight": 500, "margin-bottom": "0.25rem" }}>
1803
+ Prescription {i() + 1} — confirm these are visible:
1804
+ </div>
1805
+ <div
1806
+ style={{
1807
+ display: "grid",
1808
+ "grid-template-columns": "repeat(auto-fill, minmax(10rem, 1fr))",
1809
+ gap: "0.25rem 0.75rem"
1810
+ }}
1811
+ >
1812
+ <For2 each={PHOTO_CHECKLIST_ITEMS}>
1813
+ {(item) => <label
1814
+ style={{
1815
+ display: "flex",
1816
+ gap: "0.375rem",
1817
+ "align-items": "center",
1818
+ "font-size": "0.8125rem",
1819
+ cursor: "pointer"
1820
+ }}
1821
+ >
1822
+ <input
1823
+ type="checkbox"
1824
+ checked={entry.checklist[item.key]}
1825
+ onChange={(e) => toggleCheck(entry.photoId, item.key, e.currentTarget.checked)}
1826
+ />
1827
+ {item.label}
1828
+ </label>}
1829
+ </For2>
1830
+ </div>
1831
+ </div>
1832
+ </div>
1833
+ <div>
1834
+ <Button variant="ghost" size="sm" onClick={() => removeEntry(entry.photoId)}>
1835
+ Remove photo
1836
+ </Button>
1837
+ </div>
1838
+ </div>}
1839
+ </For2>
1840
+
1841
+ {
1842
+ /* Camera on mobile (capture), file picker on desktop. */
1843
+ }
1844
+ <input
1845
+ ref={fileInput}
1846
+ type="file"
1847
+ accept="image/*"
1848
+ capture="environment"
1849
+ hidden
1850
+ onChange={(e) => void handleFile(e.currentTarget.files?.[0] ?? void 0)}
1851
+ />
1852
+ <Show3 when={!none() && !manual()}>
1853
+ <div style={{ display: "flex", gap: "0.5rem", "align-items": "center" }}>
1854
+ <Button
1855
+ variant="secondary"
1856
+ disabled={uploading()}
1857
+ onClick={() => fileInput?.click()}
1858
+ >
1859
+ {entries().length === 0 ? "Take or upload a photo" : "Add another prescription"}
1860
+ </Button>
1861
+ <Show3 when={uploading()}>
1862
+ <Spinner size="sm" />
1863
+ </Show3>
1864
+ </div>
1865
+ </Show3>
1866
+
1867
+ <Show3 when={entries().length > 0}>
1868
+ <label
1869
+ style={{ display: "flex", gap: "0.5rem", "align-items": "center", "font-size": "0.875rem", cursor: "pointer" }}
1870
+ >
1871
+ <input
1872
+ type="checkbox"
1873
+ checked={done()}
1874
+ onChange={(e) => {
1875
+ setDone(e.currentTarget.checked);
1876
+ emit();
1877
+ }}
1878
+ />
1879
+ I&rsquo;ve added all my prescriptions
1880
+ </label>
1881
+ </Show3>
1882
+
1883
+ {
1884
+ /* The no-photo paths, mutually exclusive with photos and each other. */
1885
+ }
1886
+ <Show3 when={entries().length === 0}>
1887
+ <div style={{ display: "flex", "flex-direction": "column", gap: "0.375rem" }}>
1888
+ <label
1889
+ style={{ display: "flex", gap: "0.5rem", "align-items": "center", "font-size": "0.875rem", cursor: "pointer" }}
1890
+ >
1891
+ <input
1892
+ type="checkbox"
1893
+ checked={none()}
1894
+ onChange={(e) => {
1895
+ setNone(e.currentTarget.checked);
1896
+ if (e.currentTarget.checked) setManual(false);
1897
+ emit();
1898
+ }}
1899
+ />
1900
+ I have no current prescriptions
1901
+ </label>
1902
+ <label
1903
+ style={{ display: "flex", gap: "0.5rem", "align-items": "center", "font-size": "0.875rem", cursor: "pointer" }}
1904
+ >
1905
+ <input
1906
+ type="checkbox"
1907
+ checked={manual()}
1908
+ onChange={(e) => {
1909
+ setManual(e.currentTarget.checked);
1910
+ if (e.currentTarget.checked) setNone(false);
1911
+ emit();
1912
+ }}
1913
+ />
1914
+ I can&rsquo;t upload a photo. I will enter my prescription information manually.
1915
+ </label>
1916
+ </div>
1917
+ </Show3>
1918
+
1919
+ <Show3 when={manual() && entries().length === 0}>
1920
+ <Textarea
1921
+ value={manualText()}
1922
+ onInput={(v) => {
1923
+ setManualText(v);
1924
+ emit();
1925
+ }}
1926
+ rows={4}
1927
+ placeholder="For each prescription: drug name, dosage & schedule, prescriber, refills left, prescription number, pharmacy and phone"
1928
+ />
1929
+ </Show3>
1930
+
1931
+ <Show3 when={blockedHint()}>
1932
+ <div style={{ "font-size": "0.8125rem", opacity: 0.7 }}>{blockedHint()}</div>
1933
+ </Show3>
1934
+ </div>;
1935
+ }
1636
1936
  function QuestionField2(props) {
1637
1937
  const { TextField, Textarea, Select, RadioGroup, CheckboxGroup } = usePrimitives();
1638
1938
  const q = () => props.question;
@@ -1742,6 +2042,14 @@ function QuestionField2(props) {
1742
2042
  </div>
1743
2043
  </div>;
1744
2044
  })()}
2045
+ </Show3>
2046
+ <Show3 when={q().type === "prescription_photos"}>
2047
+ <PrescriptionPhotosQuestion
2048
+ label={lbl()}
2049
+ helpText={q().helpText}
2050
+ value={val()}
2051
+ onChange={(v) => props.onChange(v)}
2052
+ />
1745
2053
  </Show3>
1746
2054
  <Show3 when={q().type === "address"}>
1747
2055
  {(() => {
@@ -16692,4 +17000,4 @@ export {
16692
17000
  AffiliateForgotPassword,
16693
17001
  AffiliateResetPassword
16694
17002
  };
16695
- //# sourceMappingURL=FJZHH5T4.jsx.map
17003
+ //# sourceMappingURL=AAWNUGML.jsx.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ACE7M2YA.jsx.map
@@ -3279,6 +3279,35 @@ function useSurveyV2Flow(opts) {
3279
3279
  onError: opts.onError
3280
3280
  });
3281
3281
  }
3282
+ var PRESCRIPTION_PHOTO_MAX_BYTES = 10 * 1024 * 1024;
3283
+ async function uploadPrescriptionPhoto(file) {
3284
+ const cfg = getConfig();
3285
+ if (!cfg.apexEmbedApiBase) {
3286
+ throw new Error("apex-partner-core: apexEmbedApiBase is not configured.");
3287
+ }
3288
+ if (file.size > PRESCRIPTION_PHOTO_MAX_BYTES) {
3289
+ throw new Error("That photo is larger than 10MB. Please retake it at a lower resolution.");
3290
+ }
3291
+ const formData = new FormData();
3292
+ formData.append("photo", file);
3293
+ const res = await fetch(`${cfg.apexEmbedApiBase}/surveys/prescription-photos`, {
3294
+ method: "POST",
3295
+ headers: {
3296
+ ...cfg.apexPublishableKey ? { "x-apex-publishable-key": cfg.apexPublishableKey } : {},
3297
+ ...cfg.tenantKey ? { "X-Tenant-Key": cfg.tenantKey } : {}
3298
+ },
3299
+ body: formData
3300
+ });
3301
+ let parsed = null;
3302
+ try {
3303
+ parsed = await res.json();
3304
+ } catch {
3305
+ }
3306
+ if (!res.ok || !parsed?.photoId) {
3307
+ throw new Error(parsed?.error || `Photo upload failed (HTTP ${res.status})`);
3308
+ }
3309
+ return { photoId: parsed.photoId };
3310
+ }
3282
3311
 
3283
3312
  export {
3284
3313
  isQuestionVisible,
@@ -3331,6 +3360,7 @@ export {
3331
3360
  redeemResumeLink,
3332
3361
  resetResumeRedemption,
3333
3362
  resolveSurveyV2DrugIntent,
3334
- useSurveyV2Flow
3363
+ useSurveyV2Flow,
3364
+ uploadPrescriptionPhoto
3335
3365
  };
3336
- //# sourceMappingURL=MEWFN6IW.jsx.map
3366
+ //# sourceMappingURL=B63K5R7M.jsx.map
@@ -1,7 +1,7 @@
1
- import { readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './J6KNY37T.js';
2
- import { useCardTokenizer, useAddressPair, isLive, formatCvv, formatExpiry, formatCardNumber, firstAddressError, validateAddress } from './KFJXIKD4.js';
1
+ import { readPromoCode, clearPromoCode, readCartToken, fetchResumedCart, stripCartToken, adoptCartId, fetchCartConfig, postCartSnapshot, resetCartId } from './XMYPS7PT.js';
2
+ import { useCardTokenizer, useAddressPair, isLive, formatCvv, formatExpiry, formatCardNumber, firstAddressError, validateAddress } from './SE6JHCPZ.js';
3
3
  import { cart_default, auth_default, medication_default } from './FWUBNK42.js';
4
- import { productsApi, subscriptionsApi, promoCodesApi, newIdempotencyKey, usersApi, ApiError } from './UNAI6NBV.js';
4
+ import { productsApi, promoCodesApi, subscriptionsApi, newIdempotencyKey, usersApi, ApiError } from './UNAI6NBV.js';
5
5
  import { getConfig } from './5XGPFYIJ.js';
6
6
  import { createResource, createMemo, createSignal, onMount, createEffect, createRoot, on } from 'solid-js';
7
7
 
@@ -255,6 +255,20 @@ function useSubscriptionIntakeFlow(options) {
255
255
  const [promoValidating, setPromoValidating] = createSignal(false);
256
256
  const [promoError, setPromoError] = createSignal(null);
257
257
  const [promoApplied, setPromoApplied] = createSignal(null);
258
+ onMount(async () => {
259
+ if (promoCode().trim()) return;
260
+ const stashed = readPromoCode();
261
+ if (!stashed) return;
262
+ try {
263
+ const res = await promoCodesApi.validate(stashed, {
264
+ productIds: [options.pricing.productId],
265
+ subtotalCents: savingsBaseCents()
266
+ });
267
+ if (res.valid) setPromoCode(stashed);
268
+ else clearPromoCode();
269
+ } catch {
270
+ }
271
+ });
258
272
  const [idemKey, setIdemKey] = createSignal(restored.idempotencyKey ?? "");
259
273
  onMount(() => {
260
274
  createEffect(() => {
@@ -319,7 +333,13 @@ function useSubscriptionIntakeFlow(options) {
319
333
  try {
320
334
  const res = await promoCodesApi.validate(code, {
321
335
  productIds: [options.pricing.productId],
322
- subtotalCents: options.pricing.priceCents
336
+ // The base the promo will actually be applied to. For a savings member
337
+ // that is the savings price, not list: the server discounts the
338
+ // savings-substituted subtotal at checkout, so quoting off list would
339
+ // show a percentage promo as a bigger saving than it is (10% of $399
340
+ // displayed, 10% of $280 charged). Same rule as savingsBaseCents — keep
341
+ // the two in step.
342
+ subtotalCents: savingsBaseCents()
323
343
  });
324
344
  if (!res.valid) {
325
345
  setPromoError(res.error ?? "Invalid promo code.");
@@ -682,5 +702,5 @@ function startCartCapture(opts = {}) {
682
702
  }
683
703
 
684
704
  export { DEFAULT_COLOR_PALETTE, categoryColor, lowestPrice, lowestSalePrice, restoreCartFromLink, startCartCapture, useCatalog, useMedicationSelect, useProductDetail, useSubscriptionIntakeFlow };
685
- //# sourceMappingURL=EIXV4DCU.js.map
686
- //# sourceMappingURL=EIXV4DCU.js.map
705
+ //# sourceMappingURL=FBVNUFJM.js.map
706
+ //# sourceMappingURL=FBVNUFJM.js.map