@saar-ai/web-widget 0.15.0 → 0.16.1

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.
@@ -0,0 +1,18 @@
1
+ import { type CSSProperties } from 'react';
2
+ /**
3
+ * The product's own colours for the attribution badge, as literal sRGB hex: the
4
+ * marketing `Wordmark` in light mode (rose-500 → amber-400 dot, plum-800 text
5
+ * on white; here with no plate behind it). Never a custom property, because every `--brand-*` the widget
6
+ * sees is the TENANT's skin. `__tests__/brand-mark.test.tsx` pins them to
7
+ * apps/marketing/src/app/icon.svg and packages/ui/src/theme/color-tokens.css.
8
+ */
9
+ export declare const BRAND_MARK_STOPS: readonly ['#f83e54', '#f3b01d'];
10
+ export declare const BRAND_WORDMARK_COLOR = "#80027c";
11
+ /** Wordmark size in px; the mark and gap scale with it (em units). Owner 2026-10-20. */
12
+ export declare const BRAND_WORDMARK_SIZE = 12;
13
+ /** The badge is plain text and a dot: never a chip. Applied to the badge link in both renderers. */
14
+ export declare const BRAND_BADGE_PLAIN: CSSProperties;
15
+ export declare function BrandWordmark({ name }: {
16
+ readonly name: string;
17
+ }): import("react").JSX.Element;
18
+ //# sourceMappingURL=brand-mark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-mark.d.ts","sourceRoot":"","sources":["../src/brand-mark.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,YAAI,SAAS,EAAE,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAE9C,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,EAAE,aAI/B,CAAC;AAeF,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,+BAchE"}
@@ -645,6 +645,12 @@ var WidgetChatAddToCartEventSchema = object({
645
645
  * (it arrives ahead of the reply's text on the same stream).
646
646
  */
647
647
  var WidgetChatResumedEventSchema = object({ type: literal("resumed") });
648
+ /**
649
+ * The concierge has picked the shopper's message up (SAA-449): the turn has
650
+ * an agent and is about to generate. The widget draws the second tick on the
651
+ * shopper's own bubble from it. Never sent while a person holds the thread.
652
+ */
653
+ var WidgetChatReadEventSchema = object({ type: literal("read") });
648
654
  var WidgetChatDoneEventSchema = object({
649
655
  type: literal("done"),
650
656
  turnId: string().min(1)
@@ -665,6 +671,7 @@ var WidgetChatSseEventSchema = discriminatedUnion("type", [
665
671
  WidgetChatCaptureCardEventSchema,
666
672
  WidgetChatFillFormEventSchema,
667
673
  WidgetChatResumedEventSchema,
674
+ WidgetChatReadEventSchema,
668
675
  WidgetChatDoneEventSchema,
669
676
  WidgetChatErrorEventSchema
670
677
  ]);
@@ -1112,4 +1119,4 @@ function parseWidgetChatCart(value) {
1112
1119
  return parsed.success ? parsed.data : null;
1113
1120
  }
1114
1121
  //#endregion
1115
- export { CART_LINE_PLATFORM_VARIANT_ID_PATTERN, CART_LINE_VARIANT_ID_PATTERN, DROPPABLE_CARD_FIELDS, MAX_CARDS_PER_EVENT, MAX_CART_LINES, WidgetCartAddFailedReportSchema, WidgetCartAddReportSchema, WidgetChatAddToCartEventSchema, WidgetChatCardSchema, WidgetChatCardsEventSchema, WidgetChatCartLineSchema, WidgetChatCartSchema, WidgetChatCartSourceSchema, WidgetChatCheckoutEventSchema, WidgetChatDoneEventSchema, WidgetChatErrorEventSchema, WidgetChatEscalatedEventSchema, WidgetChatReportSchema, WidgetChatResumedEventSchema, WidgetChatSseEventSchema, WidgetChatTextDeltaEventSchema, WidgetToolEventSchema, WidgetVariantChoiceRequestReportSchema, buildWidgetChatCard, buildWidgetChatCardsEvent, buildWithDroppableFields, extractWidgetToolEvent, parseWidgetChatCart, parseWidgetChatReport };
1122
+ export { CART_LINE_PLATFORM_VARIANT_ID_PATTERN, CART_LINE_VARIANT_ID_PATTERN, DROPPABLE_CARD_FIELDS, MAX_CARDS_PER_EVENT, MAX_CART_LINES, WidgetCartAddFailedReportSchema, WidgetCartAddReportSchema, WidgetChatAddToCartEventSchema, WidgetChatCardSchema, WidgetChatCardsEventSchema, WidgetChatCartLineSchema, WidgetChatCartSchema, WidgetChatCartSourceSchema, WidgetChatCheckoutEventSchema, WidgetChatDoneEventSchema, WidgetChatErrorEventSchema, WidgetChatEscalatedEventSchema, WidgetChatReadEventSchema, WidgetChatReportSchema, WidgetChatResumedEventSchema, WidgetChatSseEventSchema, WidgetChatTextDeltaEventSchema, WidgetToolEventSchema, WidgetVariantChoiceRequestReportSchema, buildWidgetChatCard, buildWidgetChatCardsEvent, buildWithDroppableFields, extractWidgetToolEvent, parseWidgetChatCart, parseWidgetChatReport };
@@ -4622,8 +4622,9 @@ var defaultWidgetMessages = {
4622
4622
  capture_saved_event: "Thanks — sent.",
4623
4623
  capture_declined_event: "No problem — skipped.",
4624
4624
  escalated_banner: "A human teammate will pick this up shortly.",
4625
- status_sending: "Sending",
4626
- status_sent: "Sent",
4625
+ status_sending: "Queued",
4626
+ status_sent: "Delivered",
4627
+ status_read: "Read",
4627
4628
  typing: "Typing",
4628
4629
  suggestions_label: "Suggested questions",
4629
4630
  suggestion_1: "What is popular right now?",
@@ -8334,6 +8335,61 @@ function deriveView(state, input) {
8334
8335
  throw new TypeError(`Unknown dock state: ${JSON.stringify(state)}`);
8335
8336
  }
8336
8337
  //#endregion
8338
+ //#region src/brand-mark.tsx
8339
+ /**
8340
+ * The product's own colours for the attribution badge, as literal sRGB hex: the
8341
+ * marketing `Wordmark` in light mode (rose-500 → amber-400 dot, plum-800 text
8342
+ * on white; here with no plate behind it). Never a custom property, because every `--brand-*` the widget
8343
+ * sees is the TENANT's skin. `__tests__/brand-mark.test.tsx` pins them to
8344
+ * apps/marketing/src/app/icon.svg and packages/ui/src/theme/color-tokens.css.
8345
+ */
8346
+ var BRAND_MARK_STOPS = ["#f83e54", "#f3b01d"];
8347
+ var BRAND_WORDMARK_COLOR = "#80027c";
8348
+ /** The badge is plain text and a dot: never a chip. Applied to the badge link in both renderers. */
8349
+ var BRAND_BADGE_PLAIN = {
8350
+ background: "none",
8351
+ border: "none",
8352
+ boxShadow: "none"
8353
+ };
8354
+ var WORDMARK_STYLE = {
8355
+ display: "inline-flex",
8356
+ alignItems: "center",
8357
+ gap: ".4em",
8358
+ fontSize: 12,
8359
+ fontWeight: 600,
8360
+ letterSpacing: "-.025em",
8361
+ color: BRAND_WORDMARK_COLOR,
8362
+ WebkitTextFillColor: BRAND_WORDMARK_COLOR
8363
+ };
8364
+ var MARK_STYLE = {
8365
+ width: ".5em",
8366
+ height: ".5em"
8367
+ };
8368
+ function BrandWordmark({ name }) {
8369
+ const id = "wgt-mark" + useId().replace(/\W/g, "");
8370
+ return /* @__PURE__ */ jsxs("span", {
8371
+ style: WORDMARK_STYLE,
8372
+ children: [/* @__PURE__ */ jsxs("svg", {
8373
+ "aria-hidden": "true",
8374
+ viewBox: "0 0 32 32",
8375
+ style: MARK_STYLE,
8376
+ children: [/* @__PURE__ */ jsxs("linearGradient", {
8377
+ id,
8378
+ y2: "1",
8379
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: BRAND_MARK_STOPS[0] }), /* @__PURE__ */ jsx("stop", {
8380
+ offset: "1",
8381
+ stopColor: BRAND_MARK_STOPS[1]
8382
+ })]
8383
+ }), /* @__PURE__ */ jsx("circle", {
8384
+ cx: "16",
8385
+ cy: "16",
8386
+ r: "16",
8387
+ fill: `url(#${id})`
8388
+ })]
8389
+ }), name]
8390
+ });
8391
+ }
8392
+ //#endregion
8337
8393
  //#region src/dock/dock.tsx
8338
8394
  var DEFAULT_COLOR = {
8339
8395
  primary: "#4c1d50",
@@ -8351,7 +8407,7 @@ var DEFAULT_LAYOUT = {
8351
8407
  };
8352
8408
  var INTERRUPT_SEEN_STORAGE_KEY = "wgt_dock_interrupt_seen";
8353
8409
  function Dock(props) {
8354
- const { identity, color = DEFAULT_COLOR, type = DEFAULT_TYPE, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady } = props;
8410
+ const { identity, color = DEFAULT_COLOR, type = DEFAULT_TYPE, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, onShown } = props;
8355
8411
  const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
8356
8412
  const rootRef = useRef(null);
8357
8413
  const rowRef = useRef(null);
@@ -8393,6 +8449,7 @@ function Dock(props) {
8393
8449
  persistMinimised(window, next === "pill");
8394
8450
  }, [layout.minimised, preview]);
8395
8451
  const [sheet, setSheet] = useState("closed");
8452
+ useEffect(() => onShown?.(sheet !== "closed"), [sheet, onShown]);
8396
8453
  /**
8397
8454
  * The sheet has been open at least once this session — one of the three
8398
8455
  * things that retire the greeting placeholder (see `placeholder` below).
@@ -9380,7 +9437,8 @@ function Dock(props) {
9380
9437
  href: attribution.href,
9381
9438
  target: "_blank",
9382
9439
  rel: "noopener noreferrer",
9383
- children: attribution.name
9440
+ style: BRAND_BADGE_PLAIN,
9441
+ children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
9384
9442
  }) : null,
9385
9443
  privacyChoices !== void 0 ? /* @__PURE__ */ jsx("button", {
9386
9444
  type: "button",
@@ -10927,6 +10985,11 @@ function voiceStatePillDotColor(pillState) {
10927
10985
  * there was the HOST's, which is how "Privacy choices" went near-invisible.
10928
10986
  */
10929
10987
  var FOOTER_PILL = "absolute bottom-[env(safe-area-inset-bottom,0px)] h-7 rounded-full bg-[var(--widget-card)] px-2.5 text-xs shadow-sm ring-1 ring-black/5 transition-opacity duration-300";
10988
+ /**
10989
+ * The attribution badge under the panel: same slot as `FOOTER_PILL` but plain text and a
10990
+ * dot, never a chip (SAA-451), so no fill, ring or shadow; `h-7` keeps the hit area.
10991
+ */
10992
+ var BADGE_LINK = "absolute bottom-[env(safe-area-inset-bottom,0px)] h-7 px-1 transition-opacity duration-300";
10930
10993
  /** How long the opening flourish runs. Matches `.widget-portal`'s own duration. */
10931
10994
  var PORTAL_MS = 720;
10932
10995
  function ConciergeShell({ open, onOpenChange, state, messageArrived = false, launcher, launcherInitials, typing = false, operatorName, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution, privacyChoices, focusOnOpen = true }) {
@@ -11376,19 +11439,14 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
11376
11439
  })
11377
11440
  ]
11378
11441
  }),
11379
- attribution ? /* @__PURE__ */ jsxs("a", {
11442
+ attribution ? /* @__PURE__ */ jsx("a", {
11380
11443
  href: attribution.href,
11381
11444
  target: "_blank",
11382
11445
  rel: "noopener noreferrer",
11383
11446
  "data-testid": "widget-branding",
11384
- className: cn(FOOTER_PILL, "left-1/2 inline-flex -translate-x-1/2 items-center gap-1.5 whitespace-nowrap", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
11385
- children: [/* @__PURE__ */ jsx("span", {
11386
- "aria-hidden": true,
11387
- className: "size-2.5 rounded-full bg-gradient-to-br from-brand-rose to-brand-amber"
11388
- }), /* @__PURE__ */ jsx("span", {
11389
- className: "text-brand-plum font-semibold tracking-tight",
11390
- children: attribution.name
11391
- })]
11447
+ className: cn(BADGE_LINK, "left-1/2 inline-flex -translate-x-1/2 items-center whitespace-nowrap", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
11448
+ style: BRAND_BADGE_PLAIN,
11449
+ children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
11392
11450
  }) : null,
11393
11451
  privacyChoices ? /* @__PURE__ */ jsx("button", {
11394
11452
  type: "button",
@@ -11709,7 +11767,11 @@ function positionFor(dock) {
11709
11767
  function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, dock }) {
11710
11768
  const [restored] = useState(readOpen);
11711
11769
  const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
11712
- useEffect(() => writeOpen(open), [open]);
11770
+ const onShown = dock?.onShown;
11771
+ useEffect(() => {
11772
+ writeOpen(open);
11773
+ onShown?.(open);
11774
+ }, [open, onShown]);
11713
11775
  const onReady = dock?.onReady;
11714
11776
  useLayoutEffect(() => {
11715
11777
  onReady?.();
@@ -12817,30 +12879,30 @@ function TranscriptEvent({ event, awaitingReply, messages }) {
12817
12879
  });
12818
12880
  }
12819
12881
  /**
12820
- * The shopper's own send state, under their own bubble.
12821
- *
12822
- * Two states, deliberately — see `ChatTurnDelivery`. A third ("delivered" or
12823
- * "read" on a message the shopper SENT) would have to be inferred from the
12824
- * absence of an error or from the arrival of a reply, and this codebase does
12825
- * not ship a tick it cannot back with an observation.
12826
- *
12827
- * The state is carried on `data-delivery` as well as in the accessible name
12828
- * so that the assertion in a test — and any host styling — reads the actual
12829
- * state rather than matching on a glyph.
12882
+ * The shopper's own message receipt, under their bubble (SAA-449): no tick
12883
+ * while queued, one once the server stored it, two once it was read — see
12884
+ * `ChatTurnDelivery`. The ticks are an SVG and the state is the accessible
12885
+ * name, so the row's text carries no receipt words; `data-delivery` carries
12886
+ * the state for tests and host styling.
12830
12887
  */
12831
12888
  function TurnDeliveryStatus({ delivery, messages }) {
12832
- const label = delivery === "sent" ? messages.status_sent ?? defaultWidgetMessages.status_sent : messages.status_sending ?? defaultWidgetMessages.status_sending;
12833
- return /* @__PURE__ */ jsxs("span", {
12889
+ const key = delivery === "read" ? "status_read" : delivery === "sent" ? "status_sent" : "status_sending";
12890
+ return /* @__PURE__ */ jsx("span", {
12891
+ role: "img",
12892
+ "aria-label": messages[key] ?? defaultWidgetMessages[key],
12834
12893
  "data-testid": "widget-turn-status",
12835
12894
  "data-delivery": delivery,
12836
- className: `pt-0.5 pe-0.5 text-[10px] leading-none text-[var(--widget-foreground-muted)] ${delivery === "sending" ? "opacity-60" : ""}`,
12837
- children: [/* @__PURE__ */ jsx("span", {
12838
- className: "sr-only",
12839
- children: label
12840
- }), /* @__PURE__ */ jsx("span", {
12895
+ className: "pt-0.5 pe-0.5 text-[var(--widget-foreground-muted)]",
12896
+ children: delivery !== "sending" ? /* @__PURE__ */ jsx("svg", {
12897
+ viewBox: "0 0 16 10",
12898
+ width: "16",
12899
+ height: "10",
12900
+ fill: "none",
12901
+ stroke: "currentColor",
12902
+ strokeWidth: "1.6",
12841
12903
  "aria-hidden": "true",
12842
- children: delivery === "sent" ? "✓" : "◦"
12843
- })]
12904
+ children: /* @__PURE__ */ jsx("path", { d: `M1 5l3 3 6-7${delivery === "read" ? "M7 8l6-7" : ""}` })
12905
+ }) : null
12844
12906
  });
12845
12907
  }
12846
12908
  /** Kept in sync with `ATTACHMENT_IMAGE_CONTENT_TYPES` in `apps/api/src/conversations/attachment-limits.ts` — display-only, never a security decision on this side. */
@@ -14482,6 +14544,7 @@ function useChatSession(options) {
14482
14544
  const [connection, setConnection] = useState("idle");
14483
14545
  /** See `UseChatSessionResult.deskTyping`. Expiry timer lives in `deskTypingTimerRef`. */
14484
14546
  const [deskTyping, setDeskTyping] = useState(false);
14547
+ const [shown, setShown] = useState();
14485
14548
  /**
14486
14549
  * Counts SESSIONS, not renders — bumped once per successful `bootSession`,
14487
14550
  * and by nothing else. A token ROTATION deliberately does not bump it.
@@ -14768,12 +14831,25 @@ function useChatSession(options) {
14768
14831
  seq: t.seq,
14769
14832
  ...t.attachments && t.attachments.length > 0 ? { attachments: t.attachments } : {},
14770
14833
  ...t.cards && Array.isArray(t.cards.items) && t.cards.items.length > 0 ? { cards: t.cards } : {},
14771
- ...typeof t.operatorName === "string" && t.operatorName !== "" ? { operatorName: t.operatorName } : {}
14834
+ ...typeof t.operatorName === "string" && t.operatorName !== "" ? { operatorName: t.operatorName } : {},
14835
+ ...t.readAt !== void 0 ? { delivery: t.readAt ? "read" : "sent" } : {}
14772
14836
  })) insertBySeq(next, turn);
14773
14837
  return next;
14774
14838
  });
14775
14839
  }, [clearDeskTyping]);
14776
14840
  /**
14841
+ * SAA-449: the shopper's delivered bubbles named by `ids` become read — the
14842
+ * one the SSE `read` frame answers, or those whose server turn id the
14843
+ * holder's `desk:read` named. Only ever on the server's word.
14844
+ */
14845
+ const markRead = useCallback((ids) => {
14846
+ if (!mountedRef.current) return;
14847
+ setTurns((prev) => prev.map((t) => t.delivery === "sent" && ids.includes(t.id.split(":")[0]) ? {
14848
+ ...t,
14849
+ delivery: "read"
14850
+ } : t));
14851
+ }, []);
14852
+ /**
14777
14853
  * Records the handoff to a human AS AN EVENT IN THE TRANSCRIPT, at the
14778
14854
  * point in the thread where it happened, and flips `status`.
14779
14855
  *
@@ -15379,6 +15455,9 @@ function useChatSession(options) {
15379
15455
  socket.on(DESK_MESSAGE_EVENT, (message) => {
15380
15456
  mergeIncoming([message], "push");
15381
15457
  });
15458
+ socket.on("desk:read", (payload) => {
15459
+ if (Array.isArray(payload?.ids)) markRead(payload.ids);
15460
+ });
15382
15461
  socket.on(DESK_OWNERSHIP_EVENT, (payload) => {
15383
15462
  const event = parseDeskOwnershipEvent(payload);
15384
15463
  if (!event || !mountedRef.current) return;
@@ -15405,6 +15484,7 @@ function useChatSession(options) {
15405
15484
  status,
15406
15485
  socketFactory,
15407
15486
  mergeIncoming,
15487
+ markRead,
15408
15488
  clearDeskTyping,
15409
15489
  markHandbackToAi,
15410
15490
  markHandoffToHuman,
@@ -15576,13 +15656,18 @@ function useChatSession(options) {
15576
15656
  next: "streaming"
15577
15657
  });
15578
15658
  },
15659
+ onRead: () => markRead([callerTurnId]),
15579
15660
  onDone: (turnId) => {
15580
15661
  release();
15581
15662
  if (!mountedRef.current) return;
15582
- setTurns((prev) => prev.filter((t) => t.id !== turnId || t.id === agentTurnId).map((t) => t.id === agentTurnId ? {
15663
+ const inId = `${turnId}:in`;
15664
+ setTurns((prev) => prev.filter((t) => t.id !== turnId && t.id !== inId || t.id === agentTurnId).map((t) => t.id === agentTurnId ? {
15583
15665
  ...t,
15584
15666
  id: turnId,
15585
15667
  final: true
15668
+ } : t.id === callerTurnId ? {
15669
+ ...t,
15670
+ id: inId
15586
15671
  } : t));
15587
15672
  setStatus((prev) => prev === "escalated" ? prev : "idle");
15588
15673
  },
@@ -15612,7 +15697,8 @@ function useChatSession(options) {
15612
15697
  fetchImpl,
15613
15698
  status,
15614
15699
  markHandoffToHuman,
15615
- markHandbackToAi
15700
+ markHandbackToAi,
15701
+ markRead
15616
15702
  ]);
15617
15703
  useEffect(() => {
15618
15704
  if (status === "streaming" || replyInFlightRef.current !== null) return;
@@ -15846,11 +15932,14 @@ function useChatSession(options) {
15846
15932
  * synonym for "read" and left the state it exists to express — reached
15847
15933
  * them, has not been looked at — unrepresentable.
15848
15934
  *
15849
- * **Read waits for the tab, and nothing else.** `document.visibilityState
15850
- * === 'visible'` is the honest limit of what a browser can say about the
15851
- * shopper having seen a reply. It over-claims (a visible tab in another
15852
- * window, a shopper who walked away) and this is stated plainly in the
15853
- * field's own GraphQL description rather than dressed up.
15935
+ * **Read waits for the tab AND the panel (SAA-449).** `document.
15936
+ * visibilityState === 'visible'` with the transcript on screen — the
15937
+ * renderer reports its panel/sheet through `setShown` — is the honest limit
15938
+ * of what a browser can say about the shopper having seen a reply. A closed
15939
+ * panel holds the read until it opens. A host that never calls `setShown`
15940
+ * keeps the tab-only rule. It over-claims (a visible tab in another window,
15941
+ * a shopper who walked away) and this is stated plainly in the field's own
15942
+ * GraphQL description rather than dressed up.
15854
15943
  *
15855
15944
  * **`final`, not merely present, is what counts — for both.** A streaming
15856
15945
  * reply renders as an agent-speaker turn from its FIRST token
@@ -15878,7 +15967,7 @@ function useChatSession(options) {
15878
15967
  const reportReceipts = () => {
15879
15968
  const delivered = deliveredTurnIdsRef.current;
15880
15969
  const read = readTurnIdsRef.current;
15881
- const visible = isTabVisible();
15970
+ const visible = isTabVisible() && shown !== false;
15882
15971
  const kinds = [];
15883
15972
  let sawNewDelivery = false;
15884
15973
  let sawNewRead = false;
@@ -15901,7 +15990,11 @@ function useChatSession(options) {
15901
15990
  if (typeof document === "undefined") return;
15902
15991
  document.addEventListener("visibilitychange", reportReceipts);
15903
15992
  return () => document.removeEventListener("visibilitychange", reportReceipts);
15904
- }, [turns, sendClientReceipts]);
15993
+ }, [
15994
+ turns,
15995
+ shown,
15996
+ sendClientReceipts
15997
+ ]);
15905
15998
  const checkout = useCallback(async (items, curationId, cartAttributionToken) => {
15906
15999
  const chatToken = chatTokenRef.current;
15907
16000
  if (chatToken === void 0 || items.length === 0) return null;
@@ -16033,6 +16126,7 @@ function useChatSession(options) {
16033
16126
  submitCapture,
16034
16127
  sendEvent,
16035
16128
  notifyTyping,
16129
+ setShown,
16036
16130
  checkout,
16037
16131
  sendAttachment,
16038
16132
  markHandoffToHuman,
@@ -16045,7 +16139,7 @@ function useChatSession(options) {
16045
16139
  * promise and is trivially unit-testable with a synthetic `ReadableStream`.
16046
16140
  */
16047
16141
  async function streamReply(args) {
16048
- const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onDone, onError, isMounted } = args;
16142
+ const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onRead, onDone, onError, isMounted } = args;
16049
16143
  const reader = body.getReader();
16050
16144
  const decoder = new TextDecoder();
16051
16145
  const parser = new SseFrameParser();
@@ -16191,6 +16285,9 @@ async function streamReply(args) {
16191
16285
  case "resumed":
16192
16286
  onResumed();
16193
16287
  break;
16288
+ case "read":
16289
+ onRead();
16290
+ break;
16194
16291
  case "done":
16195
16292
  onDone(evt.data?.turnId ?? agentTurnId);
16196
16293
  break;
@@ -16213,7 +16310,7 @@ async function streamReply(args) {
16213
16310
  * cache makes a second `start()` after `stop()` free).
16214
16311
  */
16215
16312
  async function loadVoiceProtocol() {
16216
- const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-CrbRIHVN.js")]);
16313
+ const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-DUERxmYS.js")]);
16217
16314
  return {
16218
16315
  decodeTelemetry: telemetry.decodeTelemetry,
16219
16316
  encodeCallerText: telemetry.encodeCallerText,
@@ -19821,7 +19918,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
19821
19918
  ...insets !== void 0 ? { insets } : {},
19822
19919
  ...hold !== void 0 ? { hold } : {},
19823
19920
  ...audio !== void 0 ? { audio } : {},
19824
- ...onReady !== void 0 ? { onReady } : {}
19921
+ ...onReady !== void 0 ? { onReady } : {},
19922
+ onShown: session.setShown
19825
19923
  };
19826
19924
  return /* @__PURE__ */ jsx(VoiceWidgetWithRenderer, {
19827
19925
  renderer,