@apextelemed/partner-core 0.5.1 → 0.5.3

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 (43) hide show
  1. package/README.md +65 -14
  2. package/dist/api/index.d.ts +1 -1
  3. package/dist/api/index.js +3 -3
  4. package/dist/api/index.jsx +3 -3
  5. package/dist/chunk/{DQE4K55D.jsx → 2MRJESYW.jsx} +15 -1
  6. package/dist/chunk/{XHOD3HUQ.js → 3MRCEVWC.js} +3 -3
  7. package/dist/chunk/{XHOD3HUQ.js.map → 3MRCEVWC.js.map} +1 -1
  8. package/dist/chunk/{ZJENZPAM.jsx → 4A2CPTUM.jsx} +5 -5
  9. package/dist/chunk/{5D7SGF46.js → 7AJQ5SVA.js} +16 -2
  10. package/dist/chunk/7AJQ5SVA.js.map +1 -0
  11. package/dist/chunk/{ZD2MMEXL.js → AH2VJK7Q.js} +6 -6
  12. package/dist/chunk/{ZD2MMEXL.js.map → AH2VJK7Q.js.map} +1 -1
  13. package/dist/chunk/{2UWULNSX.jsx → BVHNZLDK.jsx} +2 -2
  14. package/dist/chunk/{GNG53L37.jsx → FNOEL4FK.jsx} +2 -2
  15. package/dist/chunk/{AH3PJBED.jsx → IWWUVNBB.jsx} +306 -49
  16. package/dist/chunk/{7ZESUC4Q.js → LVGOEJHQ.js} +3 -3
  17. package/dist/chunk/{7ZESUC4Q.js.map → LVGOEJHQ.js.map} +1 -1
  18. package/dist/chunk/{JTG4H4I5.jsx → OLLSJX7B.jsx} +89 -11
  19. package/dist/chunk/{FUOUTRAO.jsx → OWTKSSYT.jsx} +2 -2
  20. package/dist/chunk/{GPVYUP3H.js → QCYSYBQ7.js} +89 -13
  21. package/dist/chunk/QCYSYBQ7.js.map +1 -0
  22. package/dist/chunk/{C7TELVJF.js → RFDMPQG4.js} +3 -3
  23. package/dist/chunk/{C7TELVJF.js.map → RFDMPQG4.js.map} +1 -1
  24. package/dist/chunk/{JXPPJF2V.js → XKCIXSN4.js} +513 -280
  25. package/dist/chunk/XKCIXSN4.js.map +1 -0
  26. package/dist/{client-BD9_HCZY.d.ts → client-CY8nbizi.d.ts} +27 -1
  27. package/dist/flows/index.d.ts +54 -6
  28. package/dist/flows/index.js +6 -6
  29. package/dist/flows/index.jsx +6 -6
  30. package/dist/index/index.d.ts +1 -1
  31. package/dist/index/index.js +7 -7
  32. package/dist/index/index.jsx +7 -7
  33. package/dist/pages/index.d.ts +6 -1
  34. package/dist/pages/index.js +5 -5
  35. package/dist/pages/index.jsx +5 -5
  36. package/dist/stores/index.d.ts +1 -1
  37. package/dist/stores/index.js +2 -2
  38. package/dist/stores/index.jsx +2 -2
  39. package/dist/theme/member-portal.css +130 -0
  40. package/package.json +1 -1
  41. package/dist/chunk/5D7SGF46.js.map +0 -1
  42. package/dist/chunk/GPVYUP3H.js.map +0 -1
  43. package/dist/chunk/JXPPJF2V.js.map +0 -1
@@ -7,6 +7,7 @@ import {
7
7
  LIFECYCLE_BUCKETS,
8
8
  LIFECYCLE_LABEL,
9
9
  LIFECYCLE_TONE,
10
+ SUPPORT_CATEGORIES,
10
11
  US_STATE_OPTIONS,
11
12
  accountSource,
12
13
  availableStateOptions,
@@ -15,6 +16,7 @@ import {
15
16
  buildTrackerView,
16
17
  buildTrackingUrl,
17
18
  captureFunnelEmail,
19
+ categoryLabel,
18
20
  deriveAttention,
19
21
  deriveJourney,
20
22
  emailGateAnswered,
@@ -48,10 +50,10 @@ import {
48
50
  useSurveyFlow,
49
51
  useSurveyV2Flow,
50
52
  useUpdatePaymentMethodFlow
51
- } from "./JTG4H4I5.jsx";
53
+ } from "./OLLSJX7B.jsx";
52
54
  import {
53
55
  fetchFunnelConfig
54
- } from "./2UWULNSX.jsx";
56
+ } from "./BVHNZLDK.jsx";
55
57
  import {
56
58
  usePrimitives
57
59
  } from "./J63XPQP4.jsx";
@@ -59,7 +61,7 @@ import {
59
61
  affiliateAuth_default,
60
62
  auth_default,
61
63
  cart_default
62
- } from "./GNG53L37.jsx";
64
+ } from "./FNOEL4FK.jsx";
63
65
  import {
64
66
  ApiError,
65
67
  SUPPORT_ATTACHMENT_MAX_BYTES,
@@ -73,7 +75,7 @@ import {
73
75
  membersApi,
74
76
  subscriptionsApi,
75
77
  usersApi
76
- } from "./DQE4K55D.jsx";
78
+ } from "./2MRJESYW.jsx";
77
79
 
78
80
  // src/pages/Survey.tsx
79
81
  import { Show, For, createEffect, on } from "solid-js";
@@ -14138,12 +14140,18 @@ function Funnel() {
14138
14140
  const s = summary();
14139
14141
  if (!s) return [];
14140
14142
  return [
14141
- { label: "Surveys started", value: s.sessions.started },
14142
- { label: "Surveys completed", value: s.captures.total },
14143
- { label: "Qualified", value: s.captures.qualified },
14144
- { label: "Signed up", value: s.captures.converted }
14143
+ { label: "Surveys started", value: s.sessions.started, of: null, group: "tracked" },
14144
+ { label: "Surveys completed", value: s.sessions.completed, of: s.sessions.started, group: "tracked" },
14145
+ { label: "Visits completed", value: s.captures.total, of: null, group: "visits" },
14146
+ { label: "Qualified", value: s.captures.qualified, of: s.captures.total, group: "visits" },
14147
+ { label: "Signed up", value: s.captures.converted, of: s.captures.leads, group: "visits" }
14145
14148
  ];
14146
14149
  };
14150
+ const trackingGap = () => {
14151
+ const s = summary();
14152
+ if (!s) return null;
14153
+ return s.captures.total > s.sessions.completed ? { tracked: s.sessions.completed, total: s.captures.total } : null;
14154
+ };
14147
14155
  const stageMax = () => Math.max(1, ...stages().map((s) => s.value));
14148
14156
  const dropoffMax = () => Math.max(1, ...(summary()?.stepDropoff ?? []).map((b) => b.count));
14149
14157
  const totalRecovered = () => (summary()?.recovery.captureRecovered ?? 0) + (summary()?.recovery.sessionRecovered ?? 0);
@@ -14173,14 +14181,17 @@ function Funnel() {
14173
14181
  }}
14174
14182
  >
14175
14183
  <StatCard label="Surveys Started" value={s().sessions.started} />
14176
- <StatCard label="Completion Rate" value={pct(s().captures.total, s().sessions.started)} />
14184
+ <StatCard label="Completion Rate" value={pct(s().sessions.completed, s().sessions.started)} />
14177
14185
  <StatCard label="Qualified Rate" value={pct(s().captures.qualified, s().captures.total)} />
14178
14186
  <StatCard label="Signup Conversion" value={pct(s().captures.converted, s().captures.leads)} />
14179
14187
  <StatCard label="Recovered by Email" value={totalRecovered()} />
14180
14188
  </div>
14181
14189
 
14182
14190
  <div class="app-admin-card" style={{ "margin-top": "1.25rem" }}>
14183
- <CardHeader title="Funnel stages" />
14191
+ <CardHeader
14192
+ title="Funnel stages"
14193
+ note="Step tracking covers visits since telemetry was switched on; completed visits are recorded independently, so the two counts are read separately."
14194
+ />
14184
14195
  <div style={{ padding: "1rem 1.25rem", display: "grid", gap: "0.625rem" }}>
14185
14196
  <For30 each={stages()}>
14186
14197
  {(stage, i) => <div
@@ -14191,6 +14202,8 @@ function Funnel() {
14191
14202
  gap: "0.75rem"
14192
14203
  }}
14193
14204
  title={`${stage.label}: ${stage.value}`}
14205
+ classList={{ "app-admin-funnel-stage": true }}
14206
+ data-group={stage.group}
14194
14207
  >
14195
14208
  <span style={{ "font-size": "0.8125rem", color: "var(--app-admin-fg-muted)" }}>
14196
14209
  {stage.label}
@@ -14209,11 +14222,17 @@ function Funnel() {
14209
14222
  <span style={{ "font-size": "0.8125rem", "text-align": "right" }}>
14210
14223
  {stage.value}
14211
14224
  <span style={{ color: "var(--app-admin-fg-subtle)", "margin-left": "0.375rem" }}>
14212
- {i() > 0 ? pct(stage.value, stages()[i() - 1].value) : ""}
14225
+ {stage.of != null ? pct(stage.value, stage.of) : ""}
14213
14226
  </span>
14214
14227
  </span>
14215
14228
  </div>}
14216
14229
  </For30>
14230
+ <Show42 when={trackingGap()}>
14231
+ {(gap) => <p class="app-admin-text-muted" style={{ "font-size": "0.75rem", margin: "0.25rem 0 0" }}>
14232
+ Step-by-step tracking saw {gap().tracked} of {gap().total} completed visits in this window — the
14233
+ rest finished before telemetry was switched on, or from a browser that never reported.
14234
+ </p>}
14235
+ </Show42>
14217
14236
  </div>
14218
14237
  </div>
14219
14238
 
@@ -15062,7 +15081,7 @@ function UpdatePaymentMethod(props) {
15062
15081
  }
15063
15082
 
15064
15083
  // src/pages/MemberPortal.tsx
15065
- import { Show as Show53, Switch as Switch3, Match as Match3, For as For38, createSignal as createSignal35, onMount as onMount3 } from "solid-js";
15084
+ import { Show as Show53, Switch as Switch4, Match as Match4, For as For38, createSignal as createSignal35, onMount as onMount3 } from "solid-js";
15066
15085
 
15067
15086
  // src/pages/member/OrderTracker.tsx
15068
15087
  import { Show as Show46, For as For33, createSignal as createSignal29 } from "solid-js";
@@ -15689,7 +15708,7 @@ function MedicationGuide(props) {
15689
15708
  }
15690
15709
 
15691
15710
  // src/pages/member/MessagesPanel.tsx
15692
- import { Show as Show51, For as For36, createEffect as createEffect11, createSignal as createSignal33 } from "solid-js";
15711
+ import { Show as Show51, For as For36, Switch as Switch3, Match as Match3, createEffect as createEffect11, createSignal as createSignal33 } from "solid-js";
15693
15712
  import DOMPurify from "dompurify";
15694
15713
  function sanitizeMessageHtml(html) {
15695
15714
  return DOMPurify.sanitize(html, {
@@ -15745,8 +15764,12 @@ function rejectionReason(file) {
15745
15764
  function MessagesPanel(props) {
15746
15765
  const thread = () => props.thread;
15747
15766
  const [composing, setComposing] = createSignal33(false);
15767
+ const [composeStep, setComposeStep] = createSignal33(
15768
+ "choice"
15769
+ );
15748
15770
  const [newSubject, setNewSubject] = createSignal33("");
15749
15771
  const [newBody, setNewBody] = createSignal33("");
15772
+ const [newCategory, setNewCategory] = createSignal33(null);
15750
15773
  const [composeError, setComposeError] = createSignal33(null);
15751
15774
  const [pendingFile, setPendingFile] = createSignal33(null);
15752
15775
  const [newFile, setNewFile] = createSignal33(null);
@@ -15780,13 +15803,31 @@ function MessagesPanel(props) {
15780
15803
  thread().clearSelection();
15781
15804
  setNewSubject("");
15782
15805
  setNewBody("");
15806
+ setNewCategory(null);
15783
15807
  setComposeError(null);
15808
+ setComposeStep("choice");
15784
15809
  setComposing(true);
15785
15810
  }
15811
+ let composerRef;
15812
+ async function pickCareTeam() {
15813
+ const convo = thread().conversations().find((c) => c.source === "clinical");
15814
+ if (!convo) {
15815
+ setComposeStep("care");
15816
+ return;
15817
+ }
15818
+ setComposing(false);
15819
+ await thread().selectConversation(convo.id);
15820
+ requestAnimationFrame(() => composerRef?.focus());
15821
+ }
15786
15822
  async function submitCompose(e) {
15787
15823
  e.preventDefault();
15788
15824
  setComposeError(null);
15789
- const result = await thread().startSupportThread(newSubject(), newBody(), newFile() ?? void 0);
15825
+ const result = await thread().startSupportThread(
15826
+ newSubject(),
15827
+ newBody(),
15828
+ newFile() ?? void 0,
15829
+ newCategory()
15830
+ );
15790
15831
  if (!result.created) {
15791
15832
  setComposeError("That didn't send. Please try again.");
15792
15833
  return;
@@ -15794,6 +15835,30 @@ function MessagesPanel(props) {
15794
15835
  setComposing(false);
15795
15836
  setNewSubject("");
15796
15837
  setNewBody("");
15838
+ setNewCategory(null);
15839
+ const file = newFile();
15840
+ setNewFile(null);
15841
+ if (result.attachmentFailed && file) {
15842
+ setPendingFile(file);
15843
+ setAttachError("Your message was sent, but the file didn\u2019t attach. Try sending it again.");
15844
+ }
15845
+ }
15846
+ async function submitCareCompose(e) {
15847
+ e.preventDefault();
15848
+ setComposeError(null);
15849
+ const result = await thread().startCareTeamThread(newBody(), newFile() ?? void 0);
15850
+ if (result.reason === "no_care_team") {
15851
+ setComposeStep("care-notice");
15852
+ return;
15853
+ }
15854
+ if (!result.created) {
15855
+ setComposeError("That didn't send. Please try again.");
15856
+ return;
15857
+ }
15858
+ setComposing(false);
15859
+ setNewSubject("");
15860
+ setNewBody("");
15861
+ setNewCategory(null);
15797
15862
  const file = newFile();
15798
15863
  setNewFile(null);
15799
15864
  if (result.attachmentFailed && file) {
@@ -15813,6 +15878,16 @@ function MessagesPanel(props) {
15813
15878
  void handleSend();
15814
15879
  }
15815
15880
  }
15881
+ const ChannelChip = (p) => <span
15882
+ class={`channel-chip channel-chip--${p.source}`}
15883
+ data-testid="channel-chip"
15884
+ data-channel={p.source}
15885
+ >
15886
+ {p.source === "clinical" ? "Care team" : "Support"}
15887
+ <Show51 when={p.source === "support" && categoryLabel(p.category)}>
15888
+ {(label) => <span class="channel-chip__category">{label()}</span>}
15889
+ </Show51>
15890
+ </span>;
15816
15891
  const ConversationList = () => <>
15817
15892
  <div class="msg-list__header">
15818
15893
  <h2 class="msg-list__title">Messages</h2>
@@ -15823,7 +15898,7 @@ function MessagesPanel(props) {
15823
15898
  onClick={openCompose}
15824
15899
  >
15825
15900
  <i class="ph-thin ph-plus" aria-hidden="true" />
15826
- Message support
15901
+ New message
15827
15902
  </button>
15828
15903
  </div>
15829
15904
 
@@ -15839,8 +15914,9 @@ function MessagesPanel(props) {
15839
15914
  <i class="ph-thin ph-chat-circle msg-list__empty-icon" aria-hidden="true" />
15840
15915
  <p class="msg-list__empty-title">No conversations yet.</p>
15841
15916
  <p class="msg-list__empty-hint">
15842
- Your care team will reach out after reviewing your case — or message support with
15843
- a question any time.
15917
+ Your care team reviews and responds to anything about your treatment, medication or
15918
+ side effects. For questions about your account, an order, billing or the site,
15919
+ message support instead.
15844
15920
  </p>
15845
15921
  </div>
15846
15922
  </Show51>
@@ -15853,7 +15929,10 @@ function MessagesPanel(props) {
15853
15929
  onClick={() => thread().selectConversation(convo.id)}
15854
15930
  >
15855
15931
  <div class="msg-list__row">
15856
- <span class="msg-list__name">{convo.participantName ?? "Provider"}</span>
15932
+ <span class="msg-list__name-group">
15933
+ <span class="msg-list__name">{convo.participantName ?? "Provider"}</span>
15934
+ <ChannelChip source={convo.source} category={convo.category} />
15935
+ </span>
15857
15936
  <span class="msg-list__time">{formatConversationTime(convo.lastMessageAt)}</span>
15858
15937
  </div>
15859
15938
  <div class="msg-list__row">
@@ -15974,8 +16053,9 @@ function MessagesPanel(props) {
15974
16053
  <button
15975
16054
  type="button"
15976
16055
  class="msg-thread__back-btn"
15977
- aria-label="Back to conversations"
15978
- onClick={() => setComposing(false)}
16056
+ aria-label="Back"
16057
+ data-testid="support-compose-back"
16058
+ onClick={() => setComposeStep("choice")}
15979
16059
  >
15980
16060
  <i class="ph-thin ph-arrow-left" aria-hidden="true" />
15981
16061
  </button>
@@ -15986,8 +16066,25 @@ function MessagesPanel(props) {
15986
16066
  </div>
15987
16067
 
15988
16068
  <div class="msg-compose__new">
16069
+ <label class="msg-compose__label" id="support-category-label">
16070
+ What's this about? <span class="msg-compose__label-optional">(optional)</span>
16071
+ </label>
16072
+ <div class="msg-compose__categories" role="group" aria-labelledby="support-category-label">
16073
+ <For36 each={SUPPORT_CATEGORIES}>
16074
+ {(c) => <button
16075
+ type="button"
16076
+ class={`msg-compose__category-chip${newCategory() === c.key ? " is-selected" : ""}`}
16077
+ data-testid={`compose-category-${c.key}`}
16078
+ aria-pressed={newCategory() === c.key}
16079
+ onClick={() => setNewCategory((prev) => prev === c.key ? null : c.key)}
16080
+ >
16081
+ {c.label}
16082
+ </button>}
16083
+ </For36>
16084
+ </div>
16085
+
15989
16086
  <label class="msg-compose__label" for="support-subject">
15990
- What's this about?
16087
+ Subject
15991
16088
  </label>
15992
16089
  <input
15993
16090
  id="support-subject"
@@ -16053,6 +16150,147 @@ function MessagesPanel(props) {
16053
16150
  </button>
16054
16151
  </div>
16055
16152
  </form>;
16153
+ const NewCareTeamThread = () => <form class="msg-thread msg-thread--compose" onSubmit={submitCareCompose} data-testid="care-compose">
16154
+ <div class="msg-thread__header">
16155
+ <button
16156
+ type="button"
16157
+ class="msg-thread__back-btn"
16158
+ aria-label="Back"
16159
+ data-testid="care-compose-back"
16160
+ onClick={() => setComposeStep("choice")}
16161
+ >
16162
+ <i class="ph-thin ph-arrow-left" aria-hidden="true" />
16163
+ </button>
16164
+ <div>
16165
+ <h3 class="msg-thread__name">Message your care team</h3>
16166
+ <p class="msg-thread__role">Your prescriber or their team will reply</p>
16167
+ </div>
16168
+ </div>
16169
+
16170
+ <div class="msg-compose__new">
16171
+ <label class="msg-compose__label" for="care-body">
16172
+ Message
16173
+ </label>
16174
+ <textarea
16175
+ id="care-body"
16176
+ class="msg-compose__body"
16177
+ rows={6}
16178
+ maxLength={5e3}
16179
+ required
16180
+ placeholder="Tell your care team what's going on…"
16181
+ value={newBody()}
16182
+ onInput={(e) => setNewBody(e.currentTarget.value)}
16183
+ />
16184
+
16185
+ <label class="msg-compose__attach msg-compose__attach--block" title="Attach a file">
16186
+ <i class="ph-thin ph-paperclip" aria-hidden="true" />
16187
+ <span class="msg-compose__attach-label">
16188
+ {newFile()?.name ?? "Attach a file (optional)"}
16189
+ </span>
16190
+ <input
16191
+ class="msg-compose__file-input"
16192
+ type="file"
16193
+ accept={SUPPORT_ATTACHMENT_MIME_TYPES.join(",")}
16194
+ data-testid="care-compose-attach"
16195
+ onChange={(e) => stageFile(e.currentTarget, setNewFile)}
16196
+ />
16197
+ </label>
16198
+ <Show51 when={newFile()}>
16199
+ <button
16200
+ type="button"
16201
+ class="msg-compose__staged-remove msg-compose__staged-remove--inline"
16202
+ onClick={() => setNewFile(null)}
16203
+ >
16204
+ Remove file
16205
+ </button>
16206
+ </Show51>
16207
+
16208
+ <Show51 when={attachError() || composeError()}>
16209
+ <p class="msg-compose__error" role="alert">
16210
+ {attachError() ?? composeError()}
16211
+ </p>
16212
+ </Show51>
16213
+
16214
+ <button
16215
+ type="submit"
16216
+ class="msg-compose__send"
16217
+ data-testid="care-compose-send"
16218
+ disabled={thread().startingCareTeamThread() || !newBody().trim()}
16219
+ >
16220
+ {thread().startingCareTeamThread() ? "Sending\u2026" : "Send"}
16221
+ </button>
16222
+ </div>
16223
+ </form>;
16224
+ const ChannelChoice = () => <div class="msg-thread msg-choice" data-testid="messages-channel-choice">
16225
+ <div class="msg-thread__header">
16226
+ <button
16227
+ type="button"
16228
+ class="msg-thread__back-btn"
16229
+ aria-label="Back to conversations"
16230
+ onClick={() => setComposing(false)}
16231
+ >
16232
+ <i class="ph-thin ph-arrow-left" aria-hidden="true" />
16233
+ </button>
16234
+ <div>
16235
+ <h3 class="msg-thread__name">New message</h3>
16236
+ <p class="msg-thread__role">What's this about?</p>
16237
+ </div>
16238
+ </div>
16239
+
16240
+ <div class="msg-choice__options">
16241
+ <button
16242
+ type="button"
16243
+ class="msg-choice__option"
16244
+ data-testid="choice-care-team"
16245
+ onClick={() => void pickCareTeam()}
16246
+ >
16247
+ <i class="ph-thin ph-heartbeat msg-choice__option-icon" aria-hidden="true" />
16248
+ <span class="msg-choice__option-title">My treatment, medication or side effects</span>
16249
+ <span class="msg-choice__option-sub">Goes to your care team</span>
16250
+ </button>
16251
+ <button
16252
+ type="button"
16253
+ class="msg-choice__option"
16254
+ data-testid="choice-support"
16255
+ onClick={() => setComposeStep("support")}
16256
+ >
16257
+ <i class="ph-thin ph-lifebuoy msg-choice__option-icon" aria-hidden="true" />
16258
+ <span class="msg-choice__option-title">My account, order, billing or the website</span>
16259
+ <span class="msg-choice__option-sub">Goes to support</span>
16260
+ </button>
16261
+ </div>
16262
+ </div>;
16263
+ const CareTeamNotice = () => <div class="msg-thread msg-choice" data-testid="care-team-notice">
16264
+ <div class="msg-thread__header">
16265
+ <button
16266
+ type="button"
16267
+ class="msg-thread__back-btn"
16268
+ aria-label="Back"
16269
+ onClick={() => setComposeStep("choice")}
16270
+ >
16271
+ <i class="ph-thin ph-arrow-left" aria-hidden="true" />
16272
+ </button>
16273
+ <div>
16274
+ <h3 class="msg-thread__name">Care team</h3>
16275
+ <p class="msg-thread__role">Goes to your care team</p>
16276
+ </div>
16277
+ </div>
16278
+
16279
+ <div class="msg-choice__notice">
16280
+ <p class="msg-choice__notice-text">
16281
+ Your care team will reach out after reviewing your case. If you have a question about
16282
+ your account or order in the meantime, send it to support.
16283
+ </p>
16284
+ <button
16285
+ type="button"
16286
+ class="portal-btn portal-btn--primary"
16287
+ data-testid="care-team-notice-switch"
16288
+ onClick={() => setComposeStep("support")}
16289
+ >
16290
+ Message support instead
16291
+ </button>
16292
+ </div>
16293
+ </div>;
16056
16294
  const Thread = () => <>
16057
16295
  <div class="msg-thread__header">
16058
16296
  <button
@@ -16065,7 +16303,12 @@ function MessagesPanel(props) {
16065
16303
  <i class="ph-thin ph-arrow-left" aria-hidden="true" />
16066
16304
  </button>
16067
16305
  <div>
16068
- <h3 class="msg-thread__name">{selectedConvo()?.participantName ?? "Provider"}</h3>
16306
+ <div class="msg-thread__title-row">
16307
+ <h3 class="msg-thread__name">{selectedConvo()?.participantName ?? "Provider"}</h3>
16308
+ <Show51 when={selectedConvo()}>
16309
+ {(convo) => <ChannelChip source={convo().source} category={convo().category} />}
16310
+ </Show51>
16311
+ </div>
16069
16312
  <p class="msg-thread__role">{selectedConvo()?.participantRole ?? "Prescriber"}</p>
16070
16313
  </div>
16071
16314
  {
@@ -16133,6 +16376,7 @@ function MessagesPanel(props) {
16133
16376
  </label>
16134
16377
  </Show51>
16135
16378
  <textarea
16379
+ ref={composerRef}
16136
16380
  class="msg-compose__input"
16137
16381
  rows={1}
16138
16382
  placeholder="Type a message…"
@@ -16159,7 +16403,20 @@ function MessagesPanel(props) {
16159
16403
  </div>
16160
16404
  <div class={`msg-panel__main${threadOpen() ? "" : " msg-panel__main--hidden-mobile"}`}>
16161
16405
  <Show51 when={composing()}>
16162
- <NewSupportThread />
16406
+ <Switch3>
16407
+ <Match3 when={composeStep() === "choice"}>
16408
+ <ChannelChoice />
16409
+ </Match3>
16410
+ <Match3 when={composeStep() === "care"}>
16411
+ <NewCareTeamThread />
16412
+ </Match3>
16413
+ <Match3 when={composeStep() === "care-notice"}>
16414
+ <CareTeamNotice />
16415
+ </Match3>
16416
+ <Match3 when={composeStep() === "support"}>
16417
+ <NewSupportThread />
16418
+ </Match3>
16419
+ </Switch3>
16163
16420
  </Show51>
16164
16421
  <Show51 when={!composing()}>
16165
16422
  <Show51
@@ -16425,11 +16682,11 @@ function MemberPortal(props) {
16425
16682
  </button>
16426
16683
  </div>}
16427
16684
  >
16428
- <Switch3 fallback={<TrackerTab />}>
16429
- <Match3 when={tab() === "instructions" && guide()}>
16685
+ <Switch4 fallback={<TrackerTab />}>
16686
+ <Match4 when={tab() === "instructions" && guide()}>
16430
16687
  {(g) => <MedicationGuide guide={g()} currentDose={currentDose()} />}
16431
- </Match3>
16432
- <Match3 when={tab() === "plan"}>
16688
+ </Match4>
16689
+ <Match4 when={tab() === "plan"}>
16433
16690
  <PlanBilling
16434
16691
  subscriptions={data.subscriptions()}
16435
16692
  brandName={props.brand.name}
@@ -16437,11 +16694,11 @@ function MemberPortal(props) {
16437
16694
  intakeHref={props.routes.intake}
16438
16695
  onChanged={() => data.refetch()}
16439
16696
  />
16440
- </Match3>
16441
- <Match3 when={tab() === "history" && props.surveyHistory}>
16697
+ </Match4>
16698
+ <Match4 when={tab() === "history" && props.surveyHistory}>
16442
16699
  <SurveyHistory />
16443
- </Match3>
16444
- <Match3 when={tab() === "account"}>
16700
+ </Match4>
16701
+ <Match4 when={tab() === "account"}>
16445
16702
  <AccountPanel
16446
16703
  member={data.member()}
16447
16704
  legalLinks={props.legalLinks}
@@ -16449,11 +16706,11 @@ function MemberPortal(props) {
16449
16706
  onOpenMessages={openMessages}
16450
16707
  messagingEnabled={messagingEnabled()}
16451
16708
  />
16452
- </Match3>
16453
- <Match3 when={tab() === "messages"}>
16709
+ </Match4>
16710
+ <Match4 when={tab() === "messages"}>
16454
16711
  <MessagesPanel thread={messages} />
16455
- </Match3>
16456
- </Switch3>
16712
+ </Match4>
16713
+ </Switch4>
16457
16714
  </Show53>
16458
16715
  </Show53>;
16459
16716
  return <main
@@ -16525,7 +16782,7 @@ function MemberPortal(props) {
16525
16782
  }
16526
16783
 
16527
16784
  // src/pages/AffiliatePortal.tsx
16528
- import { createEffect as createEffect12, createSignal as createSignal37, Match as Match4, Show as Show59, Switch as Switch4, For as For43 } from "solid-js";
16785
+ import { createEffect as createEffect12, createSignal as createSignal37, Match as Match5, Show as Show59, Switch as Switch5, For as For43 } from "solid-js";
16529
16786
 
16530
16787
  // src/pages/affiliate/Overview.tsx
16531
16788
  import { Show as Show54, For as For39 } from "solid-js";
@@ -17211,23 +17468,23 @@ function AffiliatePortal(props) {
17211
17468
  </aside>
17212
17469
 
17213
17470
  <div class="app-affiliate-content">
17214
- <Switch4 fallback={<AffiliateOverview />}>
17215
- <Match4 when={currentTab() === "overview"}>
17471
+ <Switch5 fallback={<AffiliateOverview />}>
17472
+ <Match5 when={currentTab() === "overview"}>
17216
17473
  <AffiliateOverview />
17217
- </Match4>
17218
- <Match4 when={currentTab() === "conversions"}>
17474
+ </Match5>
17475
+ <Match5 when={currentTab() === "conversions"}>
17219
17476
  <AffiliateConversions />
17220
- </Match4>
17221
- <Match4 when={currentTab() === "downline"}>
17477
+ </Match5>
17478
+ <Match5 when={currentTab() === "downline"}>
17222
17479
  <AffiliateDownline />
17223
- </Match4>
17224
- <Match4 when={currentTab() === "referral"}>
17480
+ </Match5>
17481
+ <Match5 when={currentTab() === "referral"}>
17225
17482
  <AffiliateReferralLink />
17226
- </Match4>
17227
- <Match4 when={currentTab() === "settings"}>
17483
+ </Match5>
17484
+ <Match5 when={currentTab() === "settings"}>
17228
17485
  <AffiliateSettings />
17229
- </Match4>
17230
- </Switch4>
17486
+ </Match5>
17487
+ </Switch5>
17231
17488
  </div>
17232
17489
  </div>
17233
17490
  </Show59>;
@@ -18399,4 +18656,4 @@ export {
18399
18656
  AffiliateForgotPassword,
18400
18657
  AffiliateResetPassword
18401
18658
  };
18402
- //# sourceMappingURL=AH3PJBED.jsx.map
18659
+ //# sourceMappingURL=IWWUVNBB.jsx.map
@@ -1,4 +1,4 @@
1
- import { getTokens } from './5D7SGF46.js';
1
+ import { getTokens } from './7AJQ5SVA.js';
2
2
  import { getConfig } from './5XGPFYIJ.js';
3
3
 
4
4
  // src/api/funnel.ts
@@ -138,5 +138,5 @@ function stripResumeToken() {
138
138
  }
139
139
 
140
140
  export { adoptFunnelSessionId, captureAuthHeader, fetchFunnelConfig, fetchResumedDraft, funnelSessionId, peekFunnelSessionId, postFunnelEvent, readResumeToken, resetFunnelConfigCache, saveFunnelDraft, stripResumeToken };
141
- //# sourceMappingURL=7ZESUC4Q.js.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GAAA,CAAI,MAAA,CAAO,SAAS,IAAI,CAAA;AACxC,IAAA,IAAI,CAAC,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,QAAQ,CAAA,EAAG;AACrC,IAAA,GAAA,CAAI,YAAA,CAAa,OAAO,QAAQ,CAAA;AAChC,IAAA,MAAA,CAAO,QAAQ,YAAA,CAAa,IAAI,EAAA,EAAI,GAAA,CAAI,UAAU,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"7ZESUC4Q.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"]}
1
+ {"version":3,"sources":["../../src/api/funnel.ts"],"names":[],"mappings":";;;;AAmBA,IAAM,WAAyB,EAAE,SAAA,EAAW,OAAO,SAAA,EAAW,KAAA,EAAO,mBAAmB,KAAA,EAAM;AAE9F,IAAI,aAAA,GAA8C,IAAA;AAM3C,SAAS,iBAAA,GAA2C;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HQ.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"]}