@mediansh/widget 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-77KIJLPP.js";
11
11
 
12
12
  // ../../apps/web/src/components/support-widget/sdk/median-support.tsx
13
- import { useEffect as useEffect24 } from "react";
13
+ import { useEffect as useEffect26 } from "react";
14
14
 
15
15
  // ../../apps/web/src/components/support-widget/markdown-chunk.tsx
16
16
  import { lazy, useSyncExternalStore } from "react";
@@ -69,12 +69,12 @@ import { useCallback as useCallback7, useEffect as useEffect10, useRef as useRef
69
69
  import * as e from "react";
70
70
  var w = e.forwardRef((l5, s4) => {
71
71
  const {
72
- alt: r38,
73
- color: a29 = "currentColor",
74
- size: t11 = "1em",
75
- weight: o46 = "regular",
72
+ alt: r42,
73
+ color: a30 = "currentColor",
74
+ size: t14 = "1em",
75
+ weight: o54 = "regular",
76
76
  mirrored: i3 = false,
77
- children: n,
77
+ children: n2,
78
78
  weights: c8,
79
79
  ...m5
80
80
  } = l5;
@@ -83,16 +83,16 @@ var w = e.forwardRef((l5, s4) => {
83
83
  {
84
84
  ref: s4,
85
85
  xmlns: "http://www.w3.org/2000/svg",
86
- width: t11,
87
- height: t11,
88
- fill: a29,
86
+ width: t14,
87
+ height: t14,
88
+ fill: a30,
89
89
  viewBox: "0 0 256 256",
90
90
  transform: i3 ? "scale(-1, 1)" : void 0,
91
91
  ...m5
92
92
  },
93
- !!r38 && /* @__PURE__ */ e.createElement("title", null, r38),
94
- n,
95
- c8.get(o46)
93
+ !!r42 && /* @__PURE__ */ e.createElement("title", null, r42),
94
+ n2,
95
+ c8.get(o54)
96
96
  );
97
97
  });
98
98
  w.displayName = "SSRBase";
@@ -130,7 +130,7 @@ var a = /* @__PURE__ */ new Map([
130
130
  ]);
131
131
 
132
132
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowDown.es.js
133
- var r = o.forwardRef((e56, t11) => /* @__PURE__ */ o.createElement(w, { ref: t11, ...e56, weights: a }));
133
+ var r = o.forwardRef((e62, t14) => /* @__PURE__ */ o.createElement(w, { ref: t14, ...e62, weights: a }));
134
134
  r.displayName = "ArrowDownIcon";
135
135
 
136
136
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowRight.es.js
@@ -166,7 +166,7 @@ var a2 = /* @__PURE__ */ new Map([
166
166
  ]);
167
167
 
168
168
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowRight.es.js
169
- var o2 = r2.forwardRef((t11, e56) => /* @__PURE__ */ r2.createElement(w, { ref: e56, ...t11, weights: a2 }));
169
+ var o2 = r2.forwardRef((t14, e62) => /* @__PURE__ */ r2.createElement(w, { ref: e62, ...t14, weights: a2 }));
170
170
  o2.displayName = "ArrowRightIcon";
171
171
 
172
172
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowUp.es.js
@@ -202,7 +202,7 @@ var a3 = /* @__PURE__ */ new Map([
202
202
  ]);
203
203
 
204
204
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowUp.es.js
205
- var o3 = r3.forwardRef((e56, t11) => /* @__PURE__ */ r3.createElement(w, { ref: t11, ...e56, weights: a3 }));
205
+ var o3 = r3.forwardRef((e62, t14) => /* @__PURE__ */ r3.createElement(w, { ref: t14, ...e62, weights: a3 }));
206
206
  o3.displayName = "ArrowUpIcon";
207
207
 
208
208
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowsClockwise.es.js
@@ -238,7 +238,7 @@ var e5 = /* @__PURE__ */ new Map([
238
238
  ]);
239
239
 
240
240
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowsClockwise.es.js
241
- var r4 = o4.forwardRef((e56, s4) => /* @__PURE__ */ o4.createElement(w, { ref: s4, ...e56, weights: e5 }));
241
+ var r4 = o4.forwardRef((e62, s4) => /* @__PURE__ */ o4.createElement(w, { ref: s4, ...e62, weights: e5 }));
242
242
  r4.displayName = "ArrowsClockwiseIcon";
243
243
 
244
244
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowsIn.es.js
@@ -280,7 +280,7 @@ var e6 = /* @__PURE__ */ new Map([
280
280
  ]);
281
281
 
282
282
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowsIn.es.js
283
- var o5 = r5.forwardRef((e56, s4) => /* @__PURE__ */ r5.createElement(w, { ref: s4, ...e56, weights: e6 }));
283
+ var o5 = r5.forwardRef((e62, s4) => /* @__PURE__ */ r5.createElement(w, { ref: s4, ...e62, weights: e6 }));
284
284
  o5.displayName = "ArrowsInIcon";
285
285
 
286
286
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowsOut.es.js
@@ -316,7 +316,7 @@ var e7 = /* @__PURE__ */ new Map([
316
316
  ]);
317
317
 
318
318
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ArrowsOut.es.js
319
- var o6 = r6.forwardRef((t11, e56) => /* @__PURE__ */ r6.createElement(w, { ref: e56, ...t11, weights: e7 }));
319
+ var o6 = r6.forwardRef((t14, e62) => /* @__PURE__ */ r6.createElement(w, { ref: e62, ...t14, weights: e7 }));
320
320
  o6.displayName = "ArrowsOutIcon";
321
321
 
322
322
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Bug.es.js
@@ -352,7 +352,7 @@ var e8 = /* @__PURE__ */ new Map([
352
352
  ]);
353
353
 
354
354
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Bug.es.js
355
- var e9 = o7.forwardRef((r38, t11) => /* @__PURE__ */ o7.createElement(w, { ref: t11, ...r38, weights: e8 }));
355
+ var e9 = o7.forwardRef((r42, t14) => /* @__PURE__ */ o7.createElement(w, { ref: t14, ...r42, weights: e8 }));
356
356
  e9.displayName = "BugIcon";
357
357
 
358
358
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/CaretDown.es.js
@@ -388,7 +388,7 @@ var t = /* @__PURE__ */ new Map([
388
388
  ]);
389
389
 
390
390
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/CaretDown.es.js
391
- var e11 = o8.forwardRef((r38, t11) => /* @__PURE__ */ o8.createElement(w, { ref: t11, ...r38, weights: t }));
391
+ var e11 = o8.forwardRef((r42, t14) => /* @__PURE__ */ o8.createElement(w, { ref: t14, ...r42, weights: t }));
392
392
  e11.displayName = "CaretDownIcon";
393
393
 
394
394
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/CaretRight.es.js
@@ -424,7 +424,7 @@ var t2 = /* @__PURE__ */ new Map([
424
424
  ]);
425
425
 
426
426
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/CaretRight.es.js
427
- var e13 = t3.forwardRef((r38, o46) => /* @__PURE__ */ t3.createElement(w, { ref: o46, ...r38, weights: t2 }));
427
+ var e13 = t3.forwardRef((r42, o54) => /* @__PURE__ */ t3.createElement(w, { ref: o54, ...r42, weights: t2 }));
428
428
  e13.displayName = "CaretRightIcon";
429
429
 
430
430
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ChatCircleDots.es.js
@@ -466,7 +466,7 @@ var e14 = /* @__PURE__ */ new Map([
466
466
  ]);
467
467
 
468
468
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ChatCircleDots.es.js
469
- var o9 = t4.forwardRef((e56, r38) => /* @__PURE__ */ t4.createElement(w, { ref: r38, ...e56, weights: e14 }));
469
+ var o9 = t4.forwardRef((e62, r42) => /* @__PURE__ */ t4.createElement(w, { ref: r42, ...e62, weights: e14 }));
470
470
  o9.displayName = "ChatCircleDotsIcon";
471
471
 
472
472
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Check.es.js
@@ -508,7 +508,7 @@ var a9 = /* @__PURE__ */ new Map([
508
508
  ]);
509
509
 
510
510
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Check.es.js
511
- var o10 = e16.forwardRef((r38, t11) => /* @__PURE__ */ e16.createElement(w, { ref: t11, ...r38, weights: a9 }));
511
+ var o10 = e16.forwardRef((r42, t14) => /* @__PURE__ */ e16.createElement(w, { ref: t14, ...r42, weights: a9 }));
512
512
  o10.displayName = "CheckIcon";
513
513
 
514
514
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/EnvelopeSimple.es.js
@@ -580,7 +580,7 @@ var a11 = /* @__PURE__ */ new Map([
580
580
  ]);
581
581
 
582
582
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/File.es.js
583
- var o12 = e20.forwardRef((r38, t11) => /* @__PURE__ */ e20.createElement(w, { ref: t11, ...r38, weights: a11 }));
583
+ var o12 = e20.forwardRef((r42, t14) => /* @__PURE__ */ e20.createElement(w, { ref: t14, ...r42, weights: a11 }));
584
584
  o12.displayName = "FileIcon";
585
585
 
586
586
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ImageSquare.es.js
@@ -622,7 +622,7 @@ var e21 = /* @__PURE__ */ new Map([
622
622
  ]);
623
623
 
624
624
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/ImageSquare.es.js
625
- var a13 = e22.forwardRef((r38, o46) => /* @__PURE__ */ e22.createElement(w, { ref: o46, ...r38, weights: e21 }));
625
+ var a13 = e22.forwardRef((r42, o54) => /* @__PURE__ */ e22.createElement(w, { ref: o54, ...r42, weights: e21 }));
626
626
  a13.displayName = "ImageSquareIcon";
627
627
 
628
628
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Lightbulb.es.js
@@ -664,7 +664,7 @@ var e23 = /* @__PURE__ */ new Map([
664
664
  ]);
665
665
 
666
666
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Lightbulb.es.js
667
- var o13 = t5.forwardRef((e56, r38) => /* @__PURE__ */ t5.createElement(w, { ref: r38, ...e56, weights: e23 }));
667
+ var o13 = t5.forwardRef((e62, r42) => /* @__PURE__ */ t5.createElement(w, { ref: r42, ...e62, weights: e23 }));
668
668
  o13.displayName = "LightbulbIcon";
669
669
 
670
670
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/LockSimple.es.js
@@ -706,7 +706,7 @@ var e24 = /* @__PURE__ */ new Map([
706
706
  ]);
707
707
 
708
708
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/LockSimple.es.js
709
- var e25 = o14.forwardRef((m5, r38) => /* @__PURE__ */ o14.createElement(w, { ref: r38, ...m5, weights: e24 }));
709
+ var e25 = o14.forwardRef((m5, r42) => /* @__PURE__ */ o14.createElement(w, { ref: r42, ...m5, weights: e24 }));
710
710
  e25.displayName = "LockSimpleIcon";
711
711
 
712
712
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Play.es.js
@@ -748,7 +748,7 @@ var a16 = /* @__PURE__ */ new Map([
748
748
  ]);
749
749
 
750
750
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Play.es.js
751
- var a17 = o15.forwardRef((e56, r38) => /* @__PURE__ */ o15.createElement(w, { ref: r38, ...e56, weights: a16 }));
751
+ var a17 = o15.forwardRef((e62, r42) => /* @__PURE__ */ o15.createElement(w, { ref: r42, ...e62, weights: a16 }));
752
752
  a17.displayName = "PlayIcon";
753
753
 
754
754
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Plus.es.js
@@ -790,7 +790,7 @@ var a18 = /* @__PURE__ */ new Map([
790
790
  ]);
791
791
 
792
792
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Plus.es.js
793
- var e28 = o16.forwardRef((r38, s4) => /* @__PURE__ */ o16.createElement(w, { ref: s4, ...r38, weights: a18 }));
793
+ var e28 = o16.forwardRef((r42, s4) => /* @__PURE__ */ o16.createElement(w, { ref: s4, ...r42, weights: a18 }));
794
794
  e28.displayName = "PlusIcon";
795
795
 
796
796
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Sparkle.es.js
@@ -832,7 +832,7 @@ var l = /* @__PURE__ */ new Map([
832
832
  ]);
833
833
 
834
834
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Sparkle.es.js
835
- var r7 = e29.forwardRef((o46, a29) => /* @__PURE__ */ e29.createElement(w, { ref: a29, ...o46, weights: l }));
835
+ var r7 = e29.forwardRef((o54, a30) => /* @__PURE__ */ e29.createElement(w, { ref: a30, ...o54, weights: l }));
836
836
  r7.displayName = "SparkleIcon";
837
837
 
838
838
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Star.es.js
@@ -874,7 +874,7 @@ var l2 = /* @__PURE__ */ new Map([
874
874
  ]);
875
875
 
876
876
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/Star.es.js
877
- var t6 = r8.forwardRef((o46, a29) => /* @__PURE__ */ r8.createElement(w, { ref: a29, ...o46, weights: l2 }));
877
+ var t6 = r8.forwardRef((o54, a30) => /* @__PURE__ */ r8.createElement(w, { ref: a30, ...o54, weights: l2 }));
878
878
  t6.displayName = "StarIcon";
879
879
 
880
880
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/UserCircle.es.js
@@ -916,7 +916,7 @@ var a21 = /* @__PURE__ */ new Map([
916
916
  ]);
917
917
 
918
918
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/UserCircle.es.js
919
- var r9 = e31.forwardRef((o46, s4) => /* @__PURE__ */ e31.createElement(w, { ref: s4, ...o46, weights: a21 }));
919
+ var r9 = e31.forwardRef((o54, s4) => /* @__PURE__ */ e31.createElement(w, { ref: s4, ...o54, weights: a21 }));
920
920
  r9.displayName = "UserCircleIcon";
921
921
 
922
922
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/WarningCircle.es.js
@@ -952,7 +952,7 @@ var a22 = /* @__PURE__ */ new Map([
952
952
  ]);
953
953
 
954
954
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/WarningCircle.es.js
955
- var e33 = r10.forwardRef((o46, a29) => /* @__PURE__ */ r10.createElement(w, { ref: a29, ...o46, weights: a22 }));
955
+ var e33 = r10.forwardRef((o54, a30) => /* @__PURE__ */ r10.createElement(w, { ref: a30, ...o54, weights: a22 }));
956
956
  e33.displayName = "WarningCircleIcon";
957
957
 
958
958
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/X.es.js
@@ -994,7 +994,7 @@ var a23 = /* @__PURE__ */ new Map([
994
994
  ]);
995
995
 
996
996
  // ../../node_modules/.bun/@phosphor-icons+react@2.1.10+005eabf3d8b6ef06/node_modules/@phosphor-icons/react/dist/ssr/X.es.js
997
- var e35 = o17.forwardRef((r38, t11) => /* @__PURE__ */ o17.createElement(w, { ref: t11, ...r38, weights: a23 }));
997
+ var e35 = o17.forwardRef((r42, t14) => /* @__PURE__ */ o17.createElement(w, { ref: t14, ...r42, weights: a23 }));
998
998
  e35.displayName = "XIcon";
999
999
 
1000
1000
  // ../../apps/web/src/components/icons.tsx
@@ -1130,17 +1130,21 @@ var COLLAPSE_MS = 200;
1130
1130
  function Collapse({
1131
1131
  isOpen,
1132
1132
  id,
1133
+ direction = "vertical",
1133
1134
  children,
1134
1135
  className
1135
1136
  }) {
1137
+ const isSideways = direction === "horizontal";
1136
1138
  return /* @__PURE__ */ jsx2(
1137
1139
  "div",
1138
1140
  {
1139
1141
  id,
1140
1142
  inert: isOpen ? void 0 : true,
1141
1143
  className: cn(
1142
- "grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
1143
- isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0",
1144
+ "grid duration-200 ease-out motion-reduce:transition-none",
1145
+ isSideways ? "transition-[grid-template-columns,opacity]" : "transition-[grid-template-rows,opacity]",
1146
+ isSideways ? isOpen ? "grid-cols-[1fr]" : "grid-cols-[0fr]" : isOpen ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
1147
+ isOpen ? "opacity-100" : "opacity-0",
1144
1148
  className
1145
1149
  ),
1146
1150
  children: /* @__PURE__ */ jsx2("div", { className: "overflow-hidden", children })
@@ -1153,57 +1157,57 @@ import * as React3 from "react";
1153
1157
 
1154
1158
  // ../../node_modules/.bun/@shadcn+react@0.3.0+03aa47d54245a271/node_modules/@shadcn/react/dist/chunk-HBS6WEDP.js
1155
1159
  import * as i2 from "react";
1156
- function S({ defaultTagName: a29, props: r38, render: t11, state: n = {}, stateAttributesMapping: e56 }) {
1157
- let o46 = d(R(n, e56), r38);
1158
- if (!t11) return i2.createElement(a29, o46);
1159
- if (typeof t11 == "function") return t11(o46, n);
1160
- if (!i2.isValidElement(t11)) return null;
1161
- let s4 = t11.props, u = { ...d(o46, s4), ref: f8(o46.ref, s4.ref) };
1162
- return i2.cloneElement(t11, u);
1163
- }
1164
- function d(...a29) {
1165
- let r38 = {};
1166
- for (let t11 of a29) {
1167
- if (!t11) continue;
1168
- let n = t11;
1169
- for (let e56 of Object.keys(n)) {
1170
- let o46 = n[e56];
1171
- if (o46 === void 0) continue;
1172
- let s4 = r38[e56];
1173
- e56 === "className" ? r38[e56] = [s4, o46].filter(Boolean).join(" ") : e56 === "style" ? r38[e56] = { ...s4, ...o46 } : e56 === "ref" ? r38[e56] = f8(s4, o46) : l4(e56) && typeof s4 == "function" && typeof o46 == "function" ? r38[e56] = p2(o46, s4) : r38[e56] = o46;
1160
+ function S({ defaultTagName: a30, props: r42, render: t14, state: n2 = {}, stateAttributesMapping: e62 }) {
1161
+ let o54 = d(R(n2, e62), r42);
1162
+ if (!t14) return i2.createElement(a30, o54);
1163
+ if (typeof t14 == "function") return t14(o54, n2);
1164
+ if (!i2.isValidElement(t14)) return null;
1165
+ let s4 = t14.props, u = { ...d(o54, s4), ref: f8(o54.ref, s4.ref) };
1166
+ return i2.cloneElement(t14, u);
1167
+ }
1168
+ function d(...a30) {
1169
+ let r42 = {};
1170
+ for (let t14 of a30) {
1171
+ if (!t14) continue;
1172
+ let n2 = t14;
1173
+ for (let e62 of Object.keys(n2)) {
1174
+ let o54 = n2[e62];
1175
+ if (o54 === void 0) continue;
1176
+ let s4 = r42[e62];
1177
+ e62 === "className" ? r42[e62] = [s4, o54].filter(Boolean).join(" ") : e62 === "style" ? r42[e62] = { ...s4, ...o54 } : e62 === "ref" ? r42[e62] = f8(s4, o54) : l4(e62) && typeof s4 == "function" && typeof o54 == "function" ? r42[e62] = p2(o54, s4) : r42[e62] = o54;
1174
1178
  }
1175
1179
  }
1176
- return r38;
1180
+ return r42;
1177
1181
  }
1178
- function R(a29, r38) {
1179
- let t11 = {};
1180
- for (let n of Object.keys(a29)) {
1181
- let e56 = a29[n], o46 = r38?.[n]?.(e56);
1182
- if (o46) {
1183
- Object.assign(t11, o46);
1182
+ function R(a30, r42) {
1183
+ let t14 = {};
1184
+ for (let n2 of Object.keys(a30)) {
1185
+ let e62 = a30[n2], o54 = r42?.[n2]?.(e62);
1186
+ if (o54) {
1187
+ Object.assign(t14, o54);
1184
1188
  continue;
1185
1189
  }
1186
- if (n === "slot") {
1187
- t11["data-slot"] = e56;
1190
+ if (n2 === "slot") {
1191
+ t14["data-slot"] = e62;
1188
1192
  continue;
1189
1193
  }
1190
- let s4 = `data-${String(n).replace(/[A-Z]/g, (c8) => `-${c8.toLowerCase()}`)}`;
1191
- typeof e56 == "boolean" ? t11[s4] = e56 ? "" : void 0 : e56 != null && (t11[s4] = String(e56));
1194
+ let s4 = `data-${String(n2).replace(/[A-Z]/g, (c8) => `-${c8.toLowerCase()}`)}`;
1195
+ typeof e62 == "boolean" ? t14[s4] = e62 ? "" : void 0 : e62 != null && (t14[s4] = String(e62));
1192
1196
  }
1193
- return t11;
1197
+ return t14;
1194
1198
  }
1195
- function p2(a29, r38) {
1196
- return function(n) {
1197
- a29(n), n.defaultPrevented || r38(n);
1199
+ function p2(a30, r42) {
1200
+ return function(n2) {
1201
+ a30(n2), n2.defaultPrevented || r42(n2);
1198
1202
  };
1199
1203
  }
1200
- function l4(a29) {
1201
- return /^on[A-Z]/.test(a29);
1204
+ function l4(a30) {
1205
+ return /^on[A-Z]/.test(a30);
1202
1206
  }
1203
- function f8(...a29) {
1204
- let r38 = a29.filter(Boolean);
1205
- if (r38.length !== 0) return (t11) => {
1206
- for (let n of r38) typeof n == "function" ? n(t11) : n && (n.current = t11);
1207
+ function f8(...a30) {
1208
+ let r42 = a30.filter(Boolean);
1209
+ if (r42.length !== 0) return (t14) => {
1210
+ for (let n2 of r42) typeof n2 == "function" ? n2(t14) : n2 && (n2.current = t14);
1207
1211
  };
1208
1212
  }
1209
1213
 
@@ -1219,15 +1223,15 @@ var Be = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "End", "Home", "PageDo
1219
1223
  var ge = { start: false, end: false };
1220
1224
  var dt = [];
1221
1225
  var Q = { currentAnchorId: null, visibleMessageIds: dt };
1222
- function De({ content: e56, scrollEdgeThreshold: t11, spacer: r38, viewport: n }) {
1223
- if (!n || !e56) return ge;
1224
- let o46 = Se({ content: e56, spacer: r38, viewport: n });
1225
- return { start: n.scrollTop > t11, end: o46 - n.scrollTop - n.clientHeight > t11 };
1226
- }
1227
- function Fe({ content: e56, scrollMargin: t11, scrollPreviousItemPeek: r38, spacer: n, viewport: o46, visibleMessageIds: i3 }) {
1228
- if (!e56 || !o46) return Q;
1229
- let S2 = o46.getBoundingClientRect(), l5 = S2.top + t11 + r38, d2 = typeof IntersectionObserver > "u", E = [], b2 = null;
1230
- for (let C of ee(e56, n)) {
1226
+ function De({ content: e62, scrollEdgeThreshold: t14, spacer: r42, viewport: n2 }) {
1227
+ if (!n2 || !e62) return ge;
1228
+ let o54 = Se({ content: e62, spacer: r42, viewport: n2 });
1229
+ return { start: n2.scrollTop > t14, end: o54 - n2.scrollTop - n2.clientHeight > t14 };
1230
+ }
1231
+ function Fe({ content: e62, scrollMargin: t14, scrollPreviousItemPeek: r42, spacer: n2, viewport: o54, visibleMessageIds: i3 }) {
1232
+ if (!e62 || !o54) return Q;
1233
+ let S2 = o54.getBoundingClientRect(), l5 = S2.top + t14 + r42, d2 = typeof IntersectionObserver > "u", E = [], b2 = null;
1234
+ for (let C of ee(e62, n2)) {
1231
1235
  let p3 = C.dataset.messageId;
1232
1236
  if (!p3) continue;
1233
1237
  let m5 = C.dataset.scrollAnchor === "true", L = m5 || d2 ? C.getBoundingClientRect() : null;
@@ -1235,100 +1239,100 @@ function Fe({ content: e56, scrollMargin: t11, scrollPreviousItemPeek: r38, spac
1235
1239
  }
1236
1240
  return E.length === 0 && b2 === null ? Q : { currentAnchorId: b2, visibleMessageIds: E };
1237
1241
  }
1238
- function ee(e56, t11) {
1239
- return Array.from(e56.children).filter((r38) => r38 instanceof HTMLElement && r38 !== t11);
1242
+ function ee(e62, t14) {
1243
+ return Array.from(e62.children).filter((r42) => r42 instanceof HTMLElement && r42 !== t14);
1240
1244
  }
1241
- function je(e56, t11) {
1242
- for (let r38 = t11; r38 < e56.length; r38++) {
1243
- let n = e56[r38];
1244
- if (n?.dataset.scrollAnchor === "true") return n;
1245
+ function je(e62, t14) {
1246
+ for (let r42 = t14; r42 < e62.length; r42++) {
1247
+ let n2 = e62[r42];
1248
+ if (n2?.dataset.scrollAnchor === "true") return n2;
1245
1249
  }
1246
1250
  return null;
1247
1251
  }
1248
- function Ge(e56, t11) {
1249
- for (let r38 of e56) if (r38.dataset.scrollAnchor === "true" && !t11.has(r38)) return r38;
1252
+ function Ge(e62, t14) {
1253
+ for (let r42 of e62) if (r42.dataset.scrollAnchor === "true" && !t14.has(r42)) return r42;
1250
1254
  return null;
1251
1255
  }
1252
- function Ne(e56, t11) {
1253
- let r38 = 0;
1254
- for (let n = t11; n < e56.length; n++) if (e56[n]?.dataset.scrollAnchor === "true" && (r38 += 1, r38 > 1)) return true;
1256
+ function Ne(e62, t14) {
1257
+ let r42 = 0;
1258
+ for (let n2 = t14; n2 < e62.length; n2++) if (e62[n2]?.dataset.scrollAnchor === "true" && (r42 += 1, r42 > 1)) return true;
1255
1259
  return false;
1256
1260
  }
1257
- function Ue(e56) {
1258
- for (let t11 = e56.length - 1; t11 >= 0; t11--) {
1259
- let r38 = e56[t11];
1260
- if (r38?.dataset.scrollAnchor === "true") return r38;
1261
+ function Ue(e62) {
1262
+ for (let t14 = e62.length - 1; t14 >= 0; t14--) {
1263
+ let r42 = e62[t14];
1264
+ if (r42?.dataset.scrollAnchor === "true") return r42;
1261
1265
  }
1262
1266
  return null;
1263
1267
  }
1264
- function Ye({ content: e56, spacer: t11, viewport: r38 }) {
1265
- let n = r38.getBoundingClientRect();
1266
- for (let o46 of ee(e56, t11)) {
1267
- if (!o46.dataset.messageId) continue;
1268
- let i3 = o46.getBoundingClientRect();
1269
- if (i3.bottom > n.top && i3.top < n.bottom) return o46;
1268
+ function Ye({ content: e62, spacer: t14, viewport: r42 }) {
1269
+ let n2 = r42.getBoundingClientRect();
1270
+ for (let o54 of ee(e62, t14)) {
1271
+ if (!o54.dataset.messageId) continue;
1272
+ let i3 = o54.getBoundingClientRect();
1273
+ if (i3.bottom > n2.top && i3.top < n2.bottom) return o54;
1270
1274
  }
1271
1275
  return null;
1272
1276
  }
1273
- function ze({ align: e56, element: t11, scrollMargin: r38, spacer: n, viewport: o46 }) {
1274
- let i3 = pe(t11, o46), S2 = t11.getBoundingClientRect().height, l5 = bt(n);
1275
- if (e56 === "center") {
1276
- let d2 = Math.max(0, o46.clientHeight - l5.start - l5.end);
1277
- return i3 - l5.start - (d2 - S2) / 2 - r38;
1277
+ function ze({ align: e62, element: t14, scrollMargin: r42, spacer: n2, viewport: o54 }) {
1278
+ let i3 = pe(t14, o54), S2 = t14.getBoundingClientRect().height, l5 = bt(n2);
1279
+ if (e62 === "center") {
1280
+ let d2 = Math.max(0, o54.clientHeight - l5.start - l5.end);
1281
+ return i3 - l5.start - (d2 - S2) / 2 - r42;
1278
1282
  }
1279
- if (e56 === "end") return i3 - o46.clientHeight + S2 + l5.end + r38;
1280
- if (e56 === "nearest") {
1281
- let d2 = i3 + S2, E = o46.scrollTop + l5.start, b2 = o46.scrollTop + o46.clientHeight - l5.end;
1282
- return i3 >= E && d2 <= b2 ? o46.scrollTop : i3 < E ? i3 - l5.start - r38 : d2 - o46.clientHeight + l5.end + r38;
1283
+ if (e62 === "end") return i3 - o54.clientHeight + S2 + l5.end + r42;
1284
+ if (e62 === "nearest") {
1285
+ let d2 = i3 + S2, E = o54.scrollTop + l5.start, b2 = o54.scrollTop + o54.clientHeight - l5.end;
1286
+ return i3 >= E && d2 <= b2 ? o54.scrollTop : i3 < E ? i3 - l5.start - r42 : d2 - o54.clientHeight + l5.end + r42;
1283
1287
  }
1284
- return i3 - l5.start - r38;
1288
+ return i3 - l5.start - r42;
1285
1289
  }
1286
- function pe(e56, t11) {
1287
- let r38 = e56.getBoundingClientRect(), n = t11.getBoundingClientRect();
1288
- return r38.top - n.top + t11.scrollTop;
1290
+ function pe(e62, t14) {
1291
+ let r42 = e62.getBoundingClientRect(), n2 = t14.getBoundingClientRect();
1292
+ return r42.top - n2.top + t14.scrollTop;
1289
1293
  }
1290
- function te(e56, t11) {
1291
- return e56.getBoundingClientRect().top - t11.getBoundingClientRect().top;
1294
+ function te(e62, t14) {
1295
+ return e62.getBoundingClientRect().top - t14.getBoundingClientRect().top;
1292
1296
  }
1293
- function qe({ content: e56, scrollTop: t11, spacer: r38, viewport: n }) {
1294
- let o46 = Se({ content: e56, spacer: r38, viewport: n });
1295
- return t11 + n.clientHeight - o46;
1297
+ function qe({ content: e62, scrollTop: t14, spacer: r42, viewport: n2 }) {
1298
+ let o54 = Se({ content: e62, spacer: r42, viewport: n2 });
1299
+ return t14 + n2.clientHeight - o54;
1296
1300
  }
1297
- function Se({ content: e56, spacer: t11, viewport: r38 }) {
1298
- let n = ee(e56, t11), o46 = We(e56), i3 = r38.getBoundingClientRect(), S2 = r38.scrollTop, l5 = o46.start + o46.end;
1299
- for (let d2 of n) {
1301
+ function Se({ content: e62, spacer: t14, viewport: r42 }) {
1302
+ let n2 = ee(e62, t14), o54 = We(e62), i3 = r42.getBoundingClientRect(), S2 = r42.scrollTop, l5 = o54.start + o54.end;
1303
+ for (let d2 of n2) {
1300
1304
  let E = d2.getBoundingClientRect();
1301
- l5 = Math.max(l5, E.bottom - i3.top + S2 + o46.end);
1305
+ l5 = Math.max(l5, E.bottom - i3.top + S2 + o54.end);
1302
1306
  }
1303
1307
  return l5;
1304
1308
  }
1305
- function Ke(e56) {
1306
- return Math.max(0, e56.scrollHeight - e56.clientHeight);
1309
+ function Ke(e62) {
1310
+ return Math.max(0, e62.scrollHeight - e62.clientHeight);
1307
1311
  }
1308
- function We(e56) {
1309
- let t11 = window.getComputedStyle(e56);
1310
- return { end: Re(t11.paddingBlockEnd || t11.paddingBottom), start: Re(t11.paddingBlockStart || t11.paddingTop) };
1312
+ function We(e62) {
1313
+ let t14 = window.getComputedStyle(e62);
1314
+ return { end: Re(t14.paddingBlockEnd || t14.paddingBottom), start: Re(t14.paddingBlockStart || t14.paddingTop) };
1311
1315
  }
1312
- function bt(e56) {
1313
- let t11 = e56?.parentElement;
1314
- return t11 ? We(t11) : { end: 0, start: 0 };
1316
+ function bt(e62) {
1317
+ let t14 = e62?.parentElement;
1318
+ return t14 ? We(t14) : { end: 0, start: 0 };
1315
1319
  }
1316
- function $e(e56) {
1317
- if (!e56) return 0;
1318
- let t11 = window.getComputedStyle(e56), r38 = t11.rowGap === "normal" ? t11.gap : t11.rowGap;
1319
- return Re(r38);
1320
+ function $e(e62) {
1321
+ if (!e62) return 0;
1322
+ let t14 = window.getComputedStyle(e62), r42 = t14.rowGap === "normal" ? t14.gap : t14.rowGap;
1323
+ return Re(r42);
1320
1324
  }
1321
- function Re(e56) {
1322
- if (!e56) return 0;
1323
- let t11 = Number.parseFloat(e56);
1324
- return Number.isFinite(t11) ? t11 : 0;
1325
+ function Re(e62) {
1326
+ if (!e62) return 0;
1327
+ let t14 = Number.parseFloat(e62);
1328
+ return Number.isFinite(t14) ? t14 : 0;
1325
1329
  }
1326
- function Je({ refs: e56, commitScrollState: t11, scheduleStateCommit: r38, scheduleVisibilitySync: n }) {
1327
- let { streamingTurnRef: o46, autoScrollRef: i3, autoscrollingRef: S2, autoscrollingTimeoutRef: l5, contentRef: d2, defaultScrollPositionAppliedRef: E, itemCountRef: b2, messageElementsRef: C, modeRef: p3, pendingScrollToMessageRef: m5, prependRestoreRef: L, scrollMarginRef: y, scrollPreviousItemPeekRef: u, spacerGapRef: x, spacerHeightRef: Y, spacerRef: k, viewportRef: _ } = e56, G = g.useCallback((c8) => {
1328
- l5.current !== null && (window.clearTimeout(l5.current), l5.current = null), S2.current !== c8 && (S2.current = c8, t11()), c8 && (l5.current = window.setTimeout(() => {
1329
- l5.current = null, S2.current = false, t11();
1330
+ function Je({ refs: e62, commitScrollState: t14, scheduleStateCommit: r42, scheduleVisibilitySync: n2 }) {
1331
+ let { streamingTurnRef: o54, autoScrollRef: i3, autoscrollingRef: S2, autoscrollingTimeoutRef: l5, contentRef: d2, defaultScrollPositionAppliedRef: E, itemCountRef: b2, messageElementsRef: C, modeRef: p3, pendingScrollToMessageRef: m5, prependRestoreRef: L, scrollMarginRef: y, scrollPreviousItemPeekRef: u, spacerGapRef: x, spacerHeightRef: Y, spacerRef: k, viewportRef: _ } = e62, G = g.useCallback((c8) => {
1332
+ l5.current !== null && (window.clearTimeout(l5.current), l5.current = null), S2.current !== c8 && (S2.current = c8, t14()), c8 && (l5.current = window.setTimeout(() => {
1333
+ l5.current = null, S2.current = false, t14();
1330
1334
  }, ke));
1331
- }, [t11]), v = g.useCallback((c8) => {
1335
+ }, [t14]), v = g.useCallback((c8) => {
1332
1336
  let f9 = k.current;
1333
1337
  if (!f9) return;
1334
1338
  let h = Math.max(0, Math.ceil(c8));
@@ -1338,20 +1342,20 @@ function Je({ refs: e56, commitScrollState: t11, scheduleStateCommit: r38, sched
1338
1342
  if (!P) return;
1339
1343
  let V = Math.max(0, c8);
1340
1344
  if (Math.abs(P.scrollTop - V) <= J) {
1341
- P.scrollTop = V, t11();
1345
+ P.scrollTop = V, t14();
1342
1346
  return;
1343
1347
  }
1344
- h && G(true), P.scrollTo({ top: V, behavior: f9 }), r38();
1345
- }, [t11, r38, G]), N = g.useCallback(({ behavior: c8 = "auto" } = {}) => _.current ? (v(0), o46.current = null, p3.current = "free-scrolling", H(0, { behavior: c8 }), n(), true) : false, [n, H, v]), ne = g.useCallback(({ behavior: c8 = "auto" } = {}) => {
1348
+ h && G(true), P.scrollTo({ top: V, behavior: f9 }), r42();
1349
+ }, [t14, r42, G]), N = g.useCallback(({ behavior: c8 = "auto" } = {}) => _.current ? (v(0), o54.current = null, p3.current = "free-scrolling", H(0, { behavior: c8 }), n2(), true) : false, [n2, H, v]), ne = g.useCallback(({ behavior: c8 = "auto" } = {}) => {
1346
1350
  let f9 = _.current;
1347
- return f9 ? (v(0), o46.current = null, p3.current = i3.current ? "following-bottom" : "free-scrolling", H(Ke(f9), { autoscrolling: true, behavior: c8 }), n(), true) : false;
1348
- }, [n, H, v]), A = g.useCallback((c8, { align: f9 = "start", behavior: h = "auto", scrollMargin: P = y.current } = {}, { keepPreviousPeek: V = false } = {}) => {
1351
+ return f9 ? (v(0), o54.current = null, p3.current = i3.current ? "following-bottom" : "free-scrolling", H(Ke(f9), { autoscrolling: true, behavior: c8 }), n2(), true) : false;
1352
+ }, [n2, H, v]), A = g.useCallback((c8, { align: f9 = "start", behavior: h = "auto", scrollMargin: P = y.current } = {}, { keepPreviousPeek: V = false } = {}) => {
1349
1353
  let z = d2.current, q = _.current;
1350
1354
  if (!z || !q || !z.contains(c8)) return false;
1351
1355
  let K = ze({ align: f9, element: c8, scrollMargin: V ? P + u.current : P, spacer: k.current, viewport: q }), se = qe({ content: z, scrollTop: K, spacer: k.current, viewport: q });
1352
- return v(se), L.current = { element: c8, viewportTop: te(c8, q) }, p3.current = V ? "anchored-to-message" : "settling-jump", o46.current = V ? c8 : null, H(K, { behavior: h }), n(), true;
1353
- }, [n, H, v]), B = g.useCallback(() => {
1354
- let c8 = o46.current;
1356
+ return v(se), L.current = { element: c8, viewportTop: te(c8, q) }, p3.current = V ? "anchored-to-message" : "settling-jump", o54.current = V ? c8 : null, H(K, { behavior: h }), n2(), true;
1357
+ }, [n2, H, v]), B = g.useCallback(() => {
1358
+ let c8 = o54.current;
1355
1359
  return !c8 || !c8.isConnected || p3.current !== "anchored-to-message" ? false : A(c8, { align: "start" }, { keepPreviousPeek: true });
1356
1360
  }, [A]), D = g.useCallback((c8, f9) => {
1357
1361
  let h = C.current.get(c8);
@@ -1364,52 +1368,52 @@ function Je({ refs: e56, commitScrollState: t11, scheduleStateCommit: r38, sched
1364
1368
  return !f9 || !A(f9, c8.options) ? false : (m5.current = null, E.current = true, true);
1365
1369
  }, [A]), reanchorToAnchoredMessage: B, scrollToElement: A, scrollToEnd: ne, scrollToMessage: D, scrollToStart: N };
1366
1370
  }
1367
- function Qe(e56, t11) {
1368
- let r38 = e56, n = /* @__PURE__ */ new Set();
1369
- return { getSnapshot: () => r38, hasListeners: () => n.size > 0, setSnapshot: (o46) => {
1370
- t11(r38, o46) || (r38 = o46, n.forEach((i3) => i3()));
1371
- }, subscribe: (o46, i3, S2) => {
1372
- let l5 = n.size === 0;
1373
- return n.add(o46), l5 && i3?.(), () => {
1374
- n.delete(o46), n.size === 0 && S2?.();
1371
+ function Qe(e62, t14) {
1372
+ let r42 = e62, n2 = /* @__PURE__ */ new Set();
1373
+ return { getSnapshot: () => r42, hasListeners: () => n2.size > 0, setSnapshot: (o54) => {
1374
+ t14(r42, o54) || (r42 = o54, n2.forEach((i3) => i3()));
1375
+ }, subscribe: (o54, i3, S2) => {
1376
+ let l5 = n2.size === 0;
1377
+ return n2.add(o54), l5 && i3?.(), () => {
1378
+ n2.delete(o54), n2.size === 0 && S2?.();
1375
1379
  };
1376
1380
  } };
1377
1381
  }
1378
- function Xe(e56, t11) {
1379
- return Qe(e56, t11);
1382
+ function Xe(e62, t14) {
1383
+ return Qe(e62, t14);
1380
1384
  }
1381
1385
  function Ze() {
1382
1386
  return Qe(Q, Tt);
1383
1387
  }
1384
- function et(e56, t11) {
1385
- return e56.start === t11.start && e56.end === t11.end;
1388
+ function et(e62, t14) {
1389
+ return e62.start === t14.start && e62.end === t14.end;
1386
1390
  }
1387
- function Tt(e56, t11) {
1388
- return e56.currentAnchorId !== t11.currentAnchorId || e56.visibleMessageIds.length !== t11.visibleMessageIds.length ? false : e56.visibleMessageIds.every((r38, n) => r38 === t11.visibleMessageIds[n]);
1391
+ function Tt(e62, t14) {
1392
+ return e62.currentAnchorId !== t14.currentAnchorId || e62.visibleMessageIds.length !== t14.visibleMessageIds.length ? false : e62.visibleMessageIds.every((r42, n2) => r42 === t14.visibleMessageIds[n2]);
1389
1393
  }
1390
- function tt({ autoScroll: e56, scrollEdgeThreshold: t11, scrollMargin: r38, scrollPreviousItemPeek: n }) {
1391
- let o46 = g.useRef(e56), i3 = g.useRef(false), S2 = g.useRef(null), l5 = g.useRef(false), d2 = g.useRef(t11), E = g.useRef(0), b2 = g.useRef(null), C = g.useRef(0), p3 = g.useRef(e56 ? "following-bottom" : "free-scrolling"), m5 = g.useRef(/* @__PURE__ */ new Map()), L = g.useRef(null), y = g.useRef(null), u = g.useRef(null), x = g.useRef(n), Y = g.useRef(true), k = g.useRef(null), _ = g.useRef(r38), G = g.useRef(null), v = g.useRef(0), H = g.useRef(0), N = g.useRef(null), ne = g.useRef(null), A = g.useRef(null), B = g.useRef(null), D = g.useRef(null), U = g.useRef(null), c8 = g.useRef(null), f9 = g.useRef(null), h = g.useRef(/* @__PURE__ */ new Set()), P = g.useRef(/* @__PURE__ */ new WeakSet());
1392
- return A.current === null && (A.current = Xe(ge, et)), f9.current === null && (f9.current = Ze()), o46.current = e56, d2.current = t11, _.current = r38, x.current = n, { autoScrollRef: o46, autoscrollingRef: i3, autoscrollingTimeoutRef: B, streamingTurnRef: u, contentRef: S2, defaultScrollPositionAppliedRef: l5, firstItemRef: b2, itemCountRef: E, lastScrollTopRef: C, messageElementsRef: m5, modeRef: p3, pendingScrollFrameRef: G, pendingScrollToMessageRef: L, prependRestoreRef: y, preserveScrollOnPrependRef: Y, rootRef: k, scrollEdgeThresholdRef: d2, scrollMarginRef: _, scrollPreviousItemPeekRef: x, spacerGapRef: v, spacerHeightRef: H, spacerRef: N, stateFrameRef: ne, stateStore: A.current, viewportRef: D, visibilityFrameRef: U, visibilityObserverRef: c8, visibilityStore: f9.current, visibleMessageIdsRef: h, handledScrollAnchorsRef: P };
1394
+ function tt({ autoScroll: e62, scrollEdgeThreshold: t14, scrollMargin: r42, scrollPreviousItemPeek: n2 }) {
1395
+ let o54 = g.useRef(e62), i3 = g.useRef(false), S2 = g.useRef(null), l5 = g.useRef(false), d2 = g.useRef(t14), E = g.useRef(0), b2 = g.useRef(null), C = g.useRef(0), p3 = g.useRef(e62 ? "following-bottom" : "free-scrolling"), m5 = g.useRef(/* @__PURE__ */ new Map()), L = g.useRef(null), y = g.useRef(null), u = g.useRef(null), x = g.useRef(n2), Y = g.useRef(true), k = g.useRef(null), _ = g.useRef(r42), G = g.useRef(null), v = g.useRef(0), H = g.useRef(0), N = g.useRef(null), ne = g.useRef(null), A = g.useRef(null), B = g.useRef(null), D = g.useRef(null), U = g.useRef(null), c8 = g.useRef(null), f9 = g.useRef(null), h = g.useRef(/* @__PURE__ */ new Set()), P = g.useRef(/* @__PURE__ */ new WeakSet());
1396
+ return A.current === null && (A.current = Xe(ge, et)), f9.current === null && (f9.current = Ze()), o54.current = e62, d2.current = t14, _.current = r42, x.current = n2, { autoScrollRef: o54, autoscrollingRef: i3, autoscrollingTimeoutRef: B, streamingTurnRef: u, contentRef: S2, defaultScrollPositionAppliedRef: l5, firstItemRef: b2, itemCountRef: E, lastScrollTopRef: C, messageElementsRef: m5, modeRef: p3, pendingScrollFrameRef: G, pendingScrollToMessageRef: L, prependRestoreRef: y, preserveScrollOnPrependRef: Y, rootRef: k, scrollEdgeThresholdRef: d2, scrollMarginRef: _, scrollPreviousItemPeekRef: x, spacerGapRef: v, spacerHeightRef: H, spacerRef: N, stateFrameRef: ne, stateStore: A.current, viewportRef: D, visibilityFrameRef: U, visibilityObserverRef: c8, visibilityStore: f9.current, visibleMessageIdsRef: h, handledScrollAnchorsRef: P };
1393
1397
  }
1394
- function rt(e56, t11) {
1395
- return g.useCallback((r38) => {
1396
- e56.current = r38, r38 && t11();
1397
- }, [e56, t11]);
1398
+ function rt(e62, t14) {
1399
+ return g.useCallback((r42) => {
1400
+ e62.current = r42, r42 && t14();
1401
+ }, [e62, t14]);
1398
1402
  }
1399
- function nt({ autoScroll: e56 = false, defaultScrollPosition: t11 = "end", scrollEdgeThreshold: r38 = xe, scrollPreviousItemPeek: n = Ve, scrollMargin: o46 = _e }) {
1400
- let i3 = tt({ autoScroll: e56, scrollEdgeThreshold: r38, scrollMargin: o46, scrollPreviousItemPeek: n }), { streamingTurnRef: S2, autoScrollRef: l5, autoscrollingRef: d2, autoscrollingTimeoutRef: E, contentRef: b2, defaultScrollPositionAppliedRef: C, firstItemRef: p3, itemCountRef: m5, lastScrollTopRef: L, messageElementsRef: y, modeRef: u, pendingScrollFrameRef: x, pendingScrollToMessageRef: Y, prependRestoreRef: k, preserveScrollOnPrependRef: _, rootRef: G, scrollEdgeThresholdRef: v, scrollMarginRef: H, scrollPreviousItemPeekRef: N, spacerGapRef: ne, spacerHeightRef: A, spacerRef: B, stateFrameRef: D, stateStore: U, viewportRef: c8, visibilityFrameRef: f9, visibilityObserverRef: h, visibilityStore: P, visibleMessageIdsRef: V, handledScrollAnchorsRef: z } = i3, q = g.useRef(t11);
1401
- q.current !== t11 && (q.current = t11, C.current = false);
1403
+ function nt({ autoScroll: e62 = false, defaultScrollPosition: t14 = "end", scrollEdgeThreshold: r42 = xe, scrollPreviousItemPeek: n2 = Ve, scrollMargin: o54 = _e }) {
1404
+ let i3 = tt({ autoScroll: e62, scrollEdgeThreshold: r42, scrollMargin: o54, scrollPreviousItemPeek: n2 }), { streamingTurnRef: S2, autoScrollRef: l5, autoscrollingRef: d2, autoscrollingTimeoutRef: E, contentRef: b2, defaultScrollPositionAppliedRef: C, firstItemRef: p3, itemCountRef: m5, lastScrollTopRef: L, messageElementsRef: y, modeRef: u, pendingScrollFrameRef: x, pendingScrollToMessageRef: Y, prependRestoreRef: k, preserveScrollOnPrependRef: _, rootRef: G, scrollEdgeThresholdRef: v, scrollMarginRef: H, scrollPreviousItemPeekRef: N, spacerGapRef: ne, spacerHeightRef: A, spacerRef: B, stateFrameRef: D, stateStore: U, viewportRef: c8, visibilityFrameRef: f9, visibilityObserverRef: h, visibilityStore: P, visibleMessageIdsRef: V, handledScrollAnchorsRef: z } = i3, q = g.useRef(t14);
1405
+ q.current !== t14 && (q.current = t14, C.current = false);
1402
1406
  let K = g.useCallback((s4) => {
1403
- let a29 = G.current, T = c8.current, O = [s4.start && "start", s4.end && "end"].filter(Boolean).join(" "), ue = d2.current;
1404
- for (let W of [a29, T]) W && (O ? W.setAttribute("data-scrollable", O) : W.removeAttribute("data-scrollable"), W.toggleAttribute("data-autoscrolling", ue));
1407
+ let a30 = G.current, T = c8.current, O = [s4.start && "start", s4.end && "end"].filter(Boolean).join(" "), ue = d2.current;
1408
+ for (let W of [a30, T]) W && (O ? W.setAttribute("data-scrollable", O) : W.removeAttribute("data-scrollable"), W.toggleAttribute("data-autoscrolling", ue));
1405
1409
  }, []), se = g.useCallback((s4) => {
1406
- let a29 = c8.current?.scrollTop ?? 0, T = a29 < L.current - J;
1407
- L.current = a29, l5.current && !s4.end && u.current !== "settling-jump" && u.current !== "anchored-to-message" ? u.current = "following-bottom" : u.current === "following-bottom" && s4.end && T && !d2.current && (u.current = "free-scrolling");
1410
+ let a30 = c8.current?.scrollTop ?? 0, T = a30 < L.current - J;
1411
+ L.current = a30, l5.current && !s4.end && u.current !== "settling-jump" && u.current !== "anchored-to-message" ? u.current = "following-bottom" : u.current === "following-bottom" && s4.end && T && !d2.current && (u.current = "free-scrolling");
1408
1412
  }, []), F = g.useCallback(() => {
1409
1413
  let s4 = De({ content: b2.current, scrollEdgeThreshold: v.current, spacer: B.current, viewport: c8.current });
1410
1414
  se(s4);
1411
- let a29 = u.current === "following-bottom" ? { ...s4, end: false } : s4;
1412
- K(a29), U.setSnapshot(a29);
1415
+ let a30 = u.current === "following-bottom" ? { ...s4, end: false } : s4;
1416
+ K(a30), U.setSnapshot(a30);
1413
1417
  }, [se, U, K]), oe = g.useCallback(() => {
1414
1418
  D.current === null && (D.current = window.requestAnimationFrame(() => {
1415
1419
  D.current = null, F();
@@ -1419,54 +1423,54 @@ function nt({ autoScroll: e56 = false, defaultScrollPosition: t11 = "end", scrol
1419
1423
  f9.current = null, P.hasListeners() && P.setSnapshot(Fe({ content: b2.current, scrollMargin: H.current, scrollPreviousItemPeek: N.current, spacer: B.current, viewport: c8.current, visibleMessageIds: V.current }));
1420
1424
  }));
1421
1425
  }, [P]), { flushPendingScrollToMessage: ce, reanchorToAnchoredMessage: me, scrollToElement: le, scrollToEnd: I2, scrollToMessage: Me, scrollToStart: ae } = Je({ refs: i3, commitScrollState: F, scheduleStateCommit: oe, scheduleVisibilitySync: w2 }), de = g.useCallback(() => {
1422
- let s4 = k.current, a29 = c8.current;
1423
- if (!s4 || !a29 || !s4.element.isConnected) return false;
1424
- let O = te(s4.element, a29) - s4.viewportTop;
1425
- return Math.abs(O) <= J ? false : (a29.scrollTop += O, s4.viewportTop = te(s4.element, a29), oe(), w2(), true);
1426
+ let s4 = k.current, a30 = c8.current;
1427
+ if (!s4 || !a30 || !s4.element.isConnected) return false;
1428
+ let O = te(s4.element, a30) - s4.viewportTop;
1429
+ return Math.abs(O) <= J ? false : (a30.scrollTop += O, s4.viewportTop = te(s4.element, a30), oe(), w2(), true);
1426
1430
  }, [oe, w2]), Z = g.useCallback(() => {
1427
- let s4 = b2.current, a29 = c8.current;
1428
- if (!s4 || !a29) {
1431
+ let s4 = b2.current, a30 = c8.current;
1432
+ if (!s4 || !a30) {
1429
1433
  k.current = null;
1430
1434
  return;
1431
1435
  }
1432
- let T = Ye({ content: s4, spacer: B.current, viewport: a29 });
1433
- k.current = T ? { element: T, viewportTop: te(T, a29) } : null;
1436
+ let T = Ye({ content: s4, spacer: B.current, viewport: a30 });
1437
+ k.current = T ? { element: T, viewportTop: te(T, a30) } : null;
1434
1438
  }, []), be = g.useCallback(() => {
1435
1439
  x.current === null && (x.current = window.requestAnimationFrame(() => {
1436
1440
  x.current = null, ce() && Z();
1437
1441
  }));
1438
1442
  }, [Z, ce]), ie = g.useCallback(() => {
1439
- if (!t11 || C.current || m5.current === 0) return false;
1443
+ if (!t14 || C.current || m5.current === 0) return false;
1440
1444
  let s4 = false;
1441
- if (t11 === "last-anchor") {
1442
- let a29 = b2.current, T = c8.current, O = a29 && T ? Ue(ee(a29, B.current)) : null;
1443
- if (!a29 || !T || !O) s4 = I2({ behavior: "auto" });
1445
+ if (t14 === "last-anchor") {
1446
+ let a30 = b2.current, T = c8.current, O = a30 && T ? Ue(ee(a30, B.current)) : null;
1447
+ if (!a30 || !T || !O) s4 = I2({ behavior: "auto" });
1444
1448
  else {
1445
1449
  let ue = pe(O, T);
1446
- s4 = Se({ content: a29, spacer: B.current, viewport: T }) - ue <= T.clientHeight ? I2({ behavior: "auto" }) : le(O, { align: "start" }, { keepPreviousPeek: true });
1450
+ s4 = Se({ content: a30, spacer: B.current, viewport: T }) - ue <= T.clientHeight ? I2({ behavior: "auto" }) : le(O, { align: "start" }, { keepPreviousPeek: true });
1447
1451
  }
1448
- } else s4 = t11 === "end" ? I2({ behavior: "auto" }) : ae({ behavior: "auto" });
1452
+ } else s4 = t14 === "end" ? I2({ behavior: "auto" }) : ae({ behavior: "auto" });
1449
1453
  return s4 ? (C.current = true, true) : false;
1450
- }, [t11, le, I2, ae]), Te = g.useCallback(() => {
1454
+ }, [t14, le, I2, ae]), Te = g.useCallback(() => {
1451
1455
  let s4 = b2.current;
1452
1456
  if (!s4) return;
1453
- let a29 = ee(s4, B.current), T = m5.current, O = p3.current;
1454
- m5.current = a29.length, p3.current = a29[0] ?? null, (() => {
1457
+ let a30 = ee(s4, B.current), T = m5.current, O = p3.current;
1458
+ m5.current = a30.length, p3.current = a30[0] ?? null, (() => {
1455
1459
  if (ce()) return;
1456
1460
  if (T === 0) {
1457
- if (ie() || a29.length > 0 && l5.current && I2({ behavior: "auto" })) return;
1461
+ if (ie() || a30.length > 0 && l5.current && I2({ behavior: "auto" })) return;
1458
1462
  F(), w2();
1459
1463
  return;
1460
1464
  }
1461
- let W = O ? a29.indexOf(O) : -1;
1465
+ let W = O ? a30.indexOf(O) : -1;
1462
1466
  if (_.current && W > 0) {
1463
1467
  de();
1464
1468
  return;
1465
1469
  }
1466
- if (a29.length > T) {
1467
- let $ = je(a29, T);
1470
+ if (a30.length > T) {
1471
+ let $ = je(a30, T);
1468
1472
  if ($) {
1469
- if (l5.current && u.current === "following-bottom" && Ne(a29, T)) {
1473
+ if (l5.current && u.current === "following-bottom" && Ne(a30, T)) {
1470
1474
  I2({ behavior: "auto" });
1471
1475
  return;
1472
1476
  }
@@ -1474,8 +1478,8 @@ function nt({ autoScroll: e56 = false, defaultScrollPosition: t11 = "end", scrol
1474
1478
  return;
1475
1479
  }
1476
1480
  }
1477
- if (a29.length === T) {
1478
- let $ = Ge(a29, z.current);
1481
+ if (a30.length === T) {
1482
+ let $ = Ge(a30, z.current);
1479
1483
  if ($) {
1480
1484
  le($, { align: "start" }, { keepPreviousPeek: true }), z.current.add($);
1481
1485
  return;
@@ -1501,21 +1505,21 @@ function nt({ autoScroll: e56 = false, defaultScrollPosition: t11 = "end", scrol
1501
1505
  w2();
1502
1506
  return;
1503
1507
  }
1504
- h.current || (h.current = new IntersectionObserver((a29) => {
1505
- for (let T of a29) {
1508
+ h.current || (h.current = new IntersectionObserver((a30) => {
1509
+ for (let T of a30) {
1506
1510
  let O = T.target.dataset.messageId;
1507
1511
  O && (T.isIntersecting ? V.current.add(O) : V.current.delete(O));
1508
1512
  }
1509
1513
  w2();
1510
- }, { root: s4, rootMargin: `${-(H.current + N.current)}px 0px 0px 0px`, threshold: [0, 0.01, 0.5, 1] })), y.current.forEach((a29) => {
1511
- h.current?.observe(a29);
1514
+ }, { root: s4, rootMargin: `${-(H.current + N.current)}px 0px 0px 0px`, threshold: [0, 0.01, 0.5, 1] })), y.current.forEach((a30) => {
1515
+ h.current?.observe(a30);
1512
1516
  }), w2();
1513
1517
  }
1514
1518
  }, [w2, P]), he = g.useCallback(() => {
1515
1519
  f9.current !== null && (window.cancelAnimationFrame(f9.current), f9.current = null), h.current?.disconnect(), h.current = null, V.current.clear(), P.setSnapshot(Q);
1516
- }, [P]), pt = g.useCallback((s4, a29, T) => {
1517
- if (a29) {
1518
- y.current.set(s4, a29), h.current?.observe(a29), w2(), Y.current?.messageId === s4 && be();
1520
+ }, [P]), pt = g.useCallback((s4, a30, T) => {
1521
+ if (a30) {
1522
+ y.current.set(s4, a30), h.current?.observe(a30), w2(), Y.current?.messageId === s4 && be();
1519
1523
  return;
1520
1524
  }
1521
1525
  T && y.current.get(s4) === T && (y.current.delete(s4), V.current.delete(s4), h.current?.unobserve(T), w2());
@@ -1533,54 +1537,54 @@ function nt({ autoScroll: e56 = false, defaultScrollPosition: t11 = "end", scrol
1533
1537
  }, [ie]), g.useEffect(() => () => {
1534
1538
  D.current !== null && (window.cancelAnimationFrame(D.current), D.current = null), f9.current !== null && (window.cancelAnimationFrame(f9.current), f9.current = null), E.current !== null && (window.clearTimeout(E.current), E.current = null), x.current !== null && (window.cancelAnimationFrame(x.current), x.current = null), h.current?.disconnect(), h.current = null;
1535
1539
  }, []), g.useLayoutEffect(() => {
1536
- if (e56 && u.current === "following-bottom" && m5.current > 0) {
1540
+ if (e62 && u.current === "following-bottom" && m5.current > 0) {
1537
1541
  I2({ behavior: "auto" });
1538
1542
  return;
1539
1543
  }
1540
1544
  F();
1541
- }, [e56, F, I2]), { context: mt, registerMessage: pt };
1545
+ }, [e62, F, I2]), { context: mt, registerMessage: pt };
1542
1546
  }
1543
- function lt(e56) {
1544
- let t11 = g.useRef(e56);
1545
- return t11.current = e56, t11;
1547
+ function lt(e62) {
1548
+ let t14 = g.useRef(e62);
1549
+ return t14.current = e62, t14;
1546
1550
  }
1547
1551
  var st = g.createContext(null);
1548
1552
  var ct = g.createContext(null);
1549
1553
  function X2() {
1550
- let e56 = g.useContext(st);
1551
- if (!e56) throw new Error("useMessageScroller must be used within a MessageScroller.");
1552
- return e56;
1554
+ let e62 = g.useContext(st);
1555
+ if (!e62) throw new Error("useMessageScroller must be used within a MessageScroller.");
1556
+ return e62;
1553
1557
  }
1554
1558
  function Et() {
1555
- let e56 = g.useContext(ct);
1556
- if (!e56) throw new Error("MessageScrollerItem must be used within a MessageScroller.");
1557
- return e56;
1559
+ let e62 = g.useContext(ct);
1560
+ if (!e62) throw new Error("MessageScrollerItem must be used within a MessageScroller.");
1561
+ return e62;
1558
1562
  }
1559
- function at({ autoScroll: e56 = false, children: t11, defaultScrollPosition: r38 = "end", scrollEdgeThreshold: n, scrollPreviousItemPeek: o46, scrollMargin: i3 }) {
1560
- let { context: S2, registerMessage: l5 } = nt({ autoScroll: e56, defaultScrollPosition: r38, scrollEdgeThreshold: n, scrollPreviousItemPeek: o46, scrollMargin: i3 });
1561
- return jsx3(st.Provider, { value: S2, children: jsx3(ct.Provider, { value: l5, children: t11 }) });
1563
+ function at({ autoScroll: e62 = false, children: t14, defaultScrollPosition: r42 = "end", scrollEdgeThreshold: n2, scrollPreviousItemPeek: o54, scrollMargin: i3 }) {
1564
+ let { context: S2, registerMessage: l5 } = nt({ autoScroll: e62, defaultScrollPosition: r42, scrollEdgeThreshold: n2, scrollPreviousItemPeek: o54, scrollMargin: i3 });
1565
+ return jsx3(st.Provider, { value: S2, children: jsx3(ct.Provider, { value: l5, children: t14 }) });
1562
1566
  }
1563
- function it({ children: e56, ...t11 }) {
1564
- let { setRootElement: r38 } = X2();
1565
- return jsx3("div", { ref: r38, ...t11, children: e56 });
1567
+ function it({ children: e62, ...t14 }) {
1568
+ let { setRootElement: r42 } = X2();
1569
+ return jsx3("div", { ref: r42, ...t14, children: e62 });
1566
1570
  }
1567
- function ut({ "aria-label": e56, children: t11, onKeyDown: r38, onScroll: n, onTouchMove: o46, onWheel: i3, preserveScrollOnPrepend: S2 = true, ref: l5, role: d2, tabIndex: E, ...b2 }) {
1571
+ function ut({ "aria-label": e62, children: t14, onKeyDown: r42, onScroll: n2, onTouchMove: o54, onWheel: i3, preserveScrollOnPrepend: S2 = true, ref: l5, role: d2, tabIndex: E, ...b2 }) {
1568
1572
  let { handleResize: C, preserveScrollOnPrependRef: p3, setViewportElement: m5, syncAfterScroll: L, userScrollIntent: y, viewportRef: u } = X2();
1569
1573
  p3.current = S2;
1570
1574
  let x = g.useCallback((v) => {
1571
1575
  m5(v), f8(l5)?.(v);
1572
1576
  }, [l5, m5]);
1573
1577
  function Y(v) {
1574
- L(), n?.(v);
1578
+ L(), n2?.(v);
1575
1579
  }
1576
1580
  function k(v) {
1577
1581
  y(), i3?.(v);
1578
1582
  }
1579
1583
  function _(v) {
1580
- y(), o46?.(v);
1584
+ y(), o54?.(v);
1581
1585
  }
1582
1586
  function G(v) {
1583
- Be.has(v.key) && y(), r38?.(v);
1587
+ Be.has(v.key) && y(), r42?.(v);
1584
1588
  }
1585
1589
  return g.useEffect(() => {
1586
1590
  let v = u.current;
@@ -1591,12 +1595,12 @@ function ut({ "aria-label": e56, children: t11, onKeyDown: r38, onScroll: n, onT
1591
1595
  return N.observe(v), () => {
1592
1596
  window.cancelAnimationFrame(H), N.disconnect();
1593
1597
  };
1594
- }, [C, u]), jsx3("div", { ref: x, role: d2 ?? "region", "aria-label": e56 ?? "Messages", tabIndex: E ?? 0, onKeyDown: G, onScroll: Y, onTouchMove: _, onWheel: k, ...b2, children: t11 });
1598
+ }, [C, u]), jsx3("div", { ref: x, role: d2 ?? "region", "aria-label": e62 ?? "Messages", tabIndex: E ?? 0, onKeyDown: G, onScroll: Y, onTouchMove: _, onWheel: k, ...b2, children: t14 });
1595
1599
  }
1596
- function ft({ "aria-relevant": e56, children: t11, ref: r38, role: n, spacerClassName: o46, ...i3 }) {
1600
+ function ft({ "aria-relevant": e62, children: t14, ref: r42, role: n2, spacerClassName: o54, ...i3 }) {
1597
1601
  let { handleContentChange: S2, handleResize: l5, setContentElement: d2, setSpacerElement: E } = X2(), b2 = g.useRef(null), C = g.useCallback((p3) => {
1598
- b2.current = p3, d2(p3), f8(r38)?.(p3);
1599
- }, [r38, d2]);
1602
+ b2.current = p3, d2(p3), f8(r42)?.(p3);
1603
+ }, [r42, d2]);
1600
1604
  return g.useLayoutEffect(() => {
1601
1605
  let p3 = b2.current;
1602
1606
  if (!p3 || (S2(), typeof MutationObserver > "u")) return;
@@ -1613,23 +1617,23 @@ function ft({ "aria-relevant": e56, children: t11, ref: r38, role: n, spacerClas
1613
1617
  return L.observe(p3), () => {
1614
1618
  window.cancelAnimationFrame(m5), L.disconnect();
1615
1619
  };
1616
- }, [l5]), jsxs("div", { ref: C, role: n ?? "log", "aria-relevant": e56 ?? "additions", ...i3, children: [t11, jsx3("div", { ref: E, "aria-hidden": "true", "data-message-scroller-spacer": "", hidden: true, className: o46 })] });
1620
+ }, [l5]), jsxs("div", { ref: C, role: n2 ?? "log", "aria-relevant": e62 ?? "additions", ...i3, children: [t14, jsx3("div", { ref: E, "aria-hidden": "true", "data-message-scroller-spacer": "", hidden: true, className: o54 })] });
1617
1621
  }
1618
- function gt({ messageId: e56, ref: t11, scrollAnchor: r38 = false, ...n }) {
1619
- let o46 = Et(), i3 = g.useRef(null), S2 = g.useCallback((l5) => {
1622
+ function gt({ messageId: e62, ref: t14, scrollAnchor: r42 = false, ...n2 }) {
1623
+ let o54 = Et(), i3 = g.useRef(null), S2 = g.useCallback((l5) => {
1620
1624
  let d2 = i3.current;
1621
- i3.current = l5, e56 && o46(e56, l5, d2), f8(t11)?.(l5);
1622
- }, [e56, t11, o46]);
1623
- return jsx3("div", { ref: S2, "data-message-id": e56, "data-scroll-anchor": r38 ? "true" : "false", ...n });
1625
+ i3.current = l5, e62 && o54(e62, l5, d2), f8(t14)?.(l5);
1626
+ }, [e62, t14, o54]);
1627
+ return jsx3("div", { ref: S2, "data-message-id": e62, "data-scroll-anchor": r42 ? "true" : "false", ...n2 });
1624
1628
  }
1625
- function St({ behavior: e56 = "smooth", children: t11, direction: r38 = "end", onClick: n, render: o46, tabIndex: i3, type: S2 = "button", ...l5 }) {
1626
- let { scrollToEnd: d2, scrollToStart: E, stateStore: b$1 } = X2(), C = lt(n), p3 = g.useCallback((u) => b$1.subscribe(u), [b$1]), m5 = g.useCallback(() => {
1629
+ function St({ behavior: e62 = "smooth", children: t14, direction: r42 = "end", onClick: n2, render: o54, tabIndex: i3, type: S2 = "button", ...l5 }) {
1630
+ let { scrollToEnd: d2, scrollToStart: E, stateStore: b$1 } = X2(), C = lt(n2), p3 = g.useCallback((u) => b$1.subscribe(u), [b$1]), m5 = g.useCallback(() => {
1627
1631
  let u = b$1.getSnapshot();
1628
- return r38 === "start" ? u.start : u.end;
1629
- }, [r38, b$1]), L = g.useSyncExternalStore(p3, m5, m5), y = g.useCallback((u) => {
1630
- L && (C.current?.(u), u.defaultPrevented || (u.currentTarget.blur(), r38 === "start" ? E({ behavior: e56 }) : d2({ behavior: e56 })));
1631
- }, [e56, r38, L, C, d2, E]);
1632
- return S({ defaultTagName: "button", props: d({ type: S2, inert: !L, tabIndex: L ? i3 : -1, children: t11 ?? jsxs("span", { children: ["Scroll to ", r38] }), onClick: y }, l5), render: o46, state: { active: L, direction: r38 }, stateAttributesMapping: { active: (u) => ({ "data-active": u ? "true" : "false" }) } });
1632
+ return r42 === "start" ? u.start : u.end;
1633
+ }, [r42, b$1]), L = g.useSyncExternalStore(p3, m5, m5), y = g.useCallback((u) => {
1634
+ L && (C.current?.(u), u.defaultPrevented || (u.currentTarget.blur(), r42 === "start" ? E({ behavior: e62 }) : d2({ behavior: e62 })));
1635
+ }, [e62, r42, L, C, d2, E]);
1636
+ return S({ defaultTagName: "button", props: d({ type: S2, inert: !L, tabIndex: L ? i3 : -1, children: t14 ?? jsxs("span", { children: ["Scroll to ", r42] }), onClick: y }, l5), render: o54, state: { active: L, direction: r42 }, stateAttributesMapping: { active: (u) => ({ "data-active": u ? "true" : "false" }) } });
1633
1637
  }
1634
1638
  var $t = { Provider: at, Root: it, Viewport: ut, Content: ft, Item: gt, Button: St };
1635
1639
 
@@ -2502,7 +2506,7 @@ var widgetButtonVariants = cva(
2502
2506
  variant: {
2503
2507
  default: "bg-primary text-primary-foreground hover:bg-primary/80",
2504
2508
  outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
2505
- secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
2509
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary,oklch(0.97_0_0)),var(--foreground,oklch(0.145_0_0))_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
2506
2510
  ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
2507
2511
  destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
2508
2512
  link: "text-primary underline-offset-4 hover:underline"
@@ -2721,7 +2725,11 @@ function ShimmerLogo({
2721
2725
  WebkitMaskSize: "contain",
2722
2726
  WebkitMaskRepeat: "no-repeat",
2723
2727
  WebkitMaskPosition: "center",
2724
- backgroundImage: "linear-gradient(115deg, var(--muted) 34%, var(--muted-foreground) 50%, var(--muted) 66%)",
2728
+ backgroundImage: (
2729
+ // With the widget's own light values behind the host's, since this
2730
+ // mark also draws on pages that define neither.
2731
+ "linear-gradient(115deg, var(--muted, oklch(0.955 0 0)) 34%, var(--muted-foreground, oklch(0.556 0 0)) 50%, var(--muted, oklch(0.955 0 0)) 66%)"
2732
+ ),
2725
2733
  backgroundSize: "300% 100%"
2726
2734
  },
2727
2735
  className: cn(
@@ -3794,7 +3802,7 @@ function lineSlices(root) {
3794
3802
  return [{ top: 0, height: host.height }];
3795
3803
  }
3796
3804
  const unique = [...new Set(tops.map((top) => Math.round(top)))].sort(
3797
- (a29, b2) => a29 - b2
3805
+ (a30, b2) => a30 - b2
3798
3806
  );
3799
3807
  return unique.map((top, index) => {
3800
3808
  const next = unique[index + 1] ?? Math.ceil(host.height);
@@ -3936,7 +3944,7 @@ function WidgetTyping({ label }) {
3936
3944
  import { Fragment as Fragment28, jsx as jsx29, jsxs as jsxs14 } from "react/jsx-runtime";
3937
3945
  var BUBBLE = "max-w-[min(80%,36rem)] rounded-2xl px-4 py-2.5 text-base";
3938
3946
  var COMPACT_BUBBLE = "max-w-[min(80%,36rem)] rounded-2xl px-3.5 py-2 text-sm";
3939
- var VISITOR_BUBBLE = "bg-[color-mix(in_oklch,var(--muted),var(--foreground)_12%)]";
3947
+ var VISITOR_BUBBLE = "bg-[color-mix(in_oklch,var(--muted,oklch(0.955_0_0)),var(--foreground,oklch(0.145_0_0))_12%)]";
3940
3948
  var ARRIVES = "animate-in fade-in-0 slide-in-from-bottom-1 duration-300 ease-out-quint motion-reduce:animate-none";
3941
3949
  var SENT = "animate-in fade-in-0 slide-in-from-bottom-3 zoom-in-95 origin-bottom-right duration-400 ease-out-quint motion-reduce:animate-none";
3942
3950
  var LADDER_DELAY_MS = Math.round(MORPH_MS * 0.7);
@@ -4557,10 +4565,10 @@ function useLauncherDrag({
4557
4565
  const box = boxRef.current;
4558
4566
  if (box) box.style.transform = "";
4559
4567
  }, [boxRef]);
4560
- const holdPointer = useCallback6((held) => {
4561
- document.body.style.userSelect = held ? "none" : "";
4562
- document.body.style.cursor = held ? "grabbing" : "";
4563
- if (held) window.getSelection()?.removeAllRanges();
4568
+ const holdPointer = useCallback6((held2) => {
4569
+ document.body.style.userSelect = held2 ? "none" : "";
4570
+ document.body.style.cursor = held2 ? "grabbing" : "";
4571
+ if (held2) window.getSelection()?.removeAllRanges();
4564
4572
  }, []);
4565
4573
  const handlePointerDown = useCallback6(
4566
4574
  (event) => {
@@ -4597,57 +4605,57 @@ function useLauncherDrag({
4597
4605
  );
4598
4606
  const handlePointerMove = useCallback6(
4599
4607
  (event) => {
4600
- const held = grip.current;
4608
+ const held2 = grip.current;
4601
4609
  const box = boxRef.current;
4602
- if (held === null || box === null) return;
4603
- if (!held.moved) {
4610
+ if (held2 === null || box === null) return;
4611
+ if (!held2.moved) {
4604
4612
  const travelled = Math.hypot(
4605
- event.clientX - held.startX,
4606
- event.clientY - held.startY
4613
+ event.clientX - held2.startX,
4614
+ event.clientY - held2.startY
4607
4615
  );
4608
4616
  if (travelled < DRAG_THRESHOLD) return;
4609
- held.moved = true;
4617
+ held2.moved = true;
4610
4618
  holdPointer(true);
4611
4619
  setIsMoving(true);
4612
4620
  }
4613
- held.at = {
4621
+ held2.at = {
4614
4622
  x: clamp2(
4615
- event.clientX - held.grabX,
4616
- held.bounds.left + held.margin,
4617
- held.bounds.left + held.bounds.width - held.margin - held.dragged.width
4623
+ event.clientX - held2.grabX,
4624
+ held2.bounds.left + held2.margin,
4625
+ held2.bounds.left + held2.bounds.width - held2.margin - held2.dragged.width
4618
4626
  ),
4619
4627
  y: clamp2(
4620
- event.clientY - held.grabY,
4621
- held.bounds.top + held.margin,
4622
- held.bounds.top + held.bounds.height - held.margin - held.dragged.height
4628
+ event.clientY - held2.grabY,
4629
+ held2.bounds.top + held2.margin,
4630
+ held2.bounds.top + held2.bounds.height - held2.margin - held2.dragged.height
4623
4631
  )
4624
4632
  };
4625
- box.style.transform = `translate3d(${held.at.x - held.resting.x}px, ${held.at.y - held.resting.y}px, 0)`;
4633
+ box.style.transform = `translate3d(${held2.at.x - held2.resting.x}px, ${held2.at.y - held2.resting.y}px, 0)`;
4626
4634
  },
4627
4635
  [boxRef, holdPointer]
4628
4636
  );
4629
4637
  const finishDrag = useCallback6(() => {
4630
- const held = grip.current;
4631
- if (held === null) return;
4638
+ const held2 = grip.current;
4639
+ if (held2 === null) return;
4632
4640
  grip.current = null;
4633
4641
  holdPointer(false);
4634
4642
  const box = boxRef.current;
4635
- if (!held.moved || box === null) {
4643
+ if (!held2.moved || box === null) {
4636
4644
  setIsMoving(false);
4637
4645
  return;
4638
4646
  }
4639
4647
  justDragged.current = true;
4640
- const target = held.subject === "panel" ? spotFromPanel(held.at, held.bounds, held.size, held.box, held.margin) : spotFrom(held.at, held.bounds, held.size, held.margin);
4648
+ const target = held2.subject === "panel" ? spotFromPanel(held2.at, held2.bounds, held2.size, held2.box, held2.margin) : spotFrom(held2.at, held2.bounds, held2.size, held2.margin);
4641
4649
  const home = metricsFor(
4642
4650
  target,
4643
- held.bounds,
4644
- held.size,
4645
- held.box.height,
4646
- held.margin
4651
+ held2.bounds,
4652
+ held2.size,
4653
+ held2.box.height,
4654
+ held2.margin
4647
4655
  );
4648
4656
  const from = {
4649
- x: held.at.x - (target.side === "left" ? held.bounds.left + held.margin : held.bounds.left + held.bounds.width - held.margin - held.dragged.width),
4650
- y: held.at.y - (held.subject === "panel" ? home.boxTop : home.buttonY)
4657
+ x: held2.at.x - (target.side === "left" ? held2.bounds.left + held2.margin : held2.bounds.left + held2.bounds.width - held2.margin - held2.dragged.width),
4658
+ y: held2.at.y - (held2.subject === "panel" ? home.boxTop : home.buttonY)
4651
4659
  };
4652
4660
  flushSync(() => setSpot(target));
4653
4661
  settle();
@@ -4766,7 +4774,7 @@ function usePageLock(isLocked) {
4766
4774
  useEffect8(() => {
4767
4775
  if (!isLocked) return;
4768
4776
  const { style } = document.body;
4769
- const held = {
4777
+ const held2 = {
4770
4778
  position: style.position,
4771
4779
  top: style.top,
4772
4780
  left: style.left,
@@ -4780,11 +4788,11 @@ function usePageLock(isLocked) {
4780
4788
  style.right = "0";
4781
4789
  style.overflow = "hidden";
4782
4790
  return () => {
4783
- style.position = held.position;
4784
- style.top = held.top;
4785
- style.left = held.left;
4786
- style.right = held.right;
4787
- style.overflow = held.overflow;
4791
+ style.position = held2.position;
4792
+ style.top = held2.top;
4793
+ style.left = held2.left;
4794
+ style.right = held2.right;
4795
+ style.overflow = held2.overflow;
4788
4796
  window.scrollTo({ top: scrollY, behavior: "instant" });
4789
4797
  };
4790
4798
  }, [isLocked]);
@@ -4888,7 +4896,7 @@ function useScrollLock(isLocked) {
4888
4896
  useEffect9(() => {
4889
4897
  if (!isLocked) return;
4890
4898
  const { body } = document;
4891
- const held = {
4899
+ const held2 = {
4892
4900
  overflow: body.style.overflow,
4893
4901
  paddingRight: body.style.paddingRight
4894
4902
  };
@@ -4899,8 +4907,8 @@ function useScrollLock(isLocked) {
4899
4907
  body.style.paddingRight = `${existing + gutter}px`;
4900
4908
  }
4901
4909
  return () => {
4902
- body.style.overflow = held.overflow;
4903
- body.style.paddingRight = held.paddingRight;
4910
+ body.style.overflow = held2.overflow;
4911
+ body.style.paddingRight = held2.paddingRight;
4904
4912
  };
4905
4913
  }, [isLocked]);
4906
4914
  }
@@ -5017,9 +5025,9 @@ function WidgetTeaser({
5017
5025
  onOpen,
5018
5026
  onDismiss
5019
5027
  }) {
5020
- const [held, setHeld] = useState14(message);
5021
- if (message !== null && message !== held) setHeld(message);
5022
- const shown = message ?? held;
5028
+ const [held2, setHeld] = useState14(message);
5029
+ if (message !== null && message !== held2) setHeld(message);
5030
+ const shown = message ?? held2;
5023
5031
  if (shown === null) return null;
5024
5032
  const agent = shown.agent;
5025
5033
  const text = plainTextOf(shown.body);
@@ -5521,7 +5529,9 @@ function WidgetSpotlight({ selector }) {
5521
5529
  {
5522
5530
  className: [
5523
5531
  "absolute -inset-1 rounded-lg outline-2 outline-offset-0 outline-primary",
5524
- "shadow-[0_0_0_6px_color-mix(in_oklch,var(--primary)_20%,transparent)]",
5532
+ // With the widget's own primary behind the host's, like every
5533
+ // other colour it draws.
5534
+ "shadow-[0_0_0_6px_color-mix(in_oklch,var(--primary,oklch(0.205_0_0))_20%,transparent)]",
5525
5535
  "transition-opacity duration-300 ease-out motion-reduce:transition-none",
5526
5536
  isLeaving ? "opacity-0" : "opacity-100"
5527
5537
  ].join(" ")
@@ -5545,7 +5555,7 @@ function WidgetSpotlight({ selector }) {
5545
5555
  }
5546
5556
 
5547
5557
  // ../../apps/web/src/components/support-widget/sdk/control.ts
5548
- import { useSyncExternalStore as useSyncExternalStore12 } from "react";
5558
+ import { useSyncExternalStore as useSyncExternalStore13 } from "react";
5549
5559
 
5550
5560
  // ../backend/convex/shared/customData.ts
5551
5561
  var MAX_CUSTOM_ENTRIES = 8;
@@ -5592,7 +5602,20 @@ function mergeCustomData(...sources) {
5592
5602
  }
5593
5603
 
5594
5604
  // ../../apps/web/src/components/support-widget/sdk/custom-data.ts
5605
+ import { useEffect as useEffect12 } from "react";
5595
5606
  var queued = [];
5607
+ var senders = 0;
5608
+ function useCustomDataSender() {
5609
+ useEffect12(() => {
5610
+ senders += 1;
5611
+ return () => {
5612
+ senders -= 1;
5613
+ };
5614
+ }, []);
5615
+ }
5616
+ function hasCustomDataSender() {
5617
+ return senders > 0;
5618
+ }
5596
5619
  function queueCustomData(label, value) {
5597
5620
  const cleaned = cleanCustomData([{ label, value }]);
5598
5621
  if (cleaned === void 0) return false;
@@ -5610,13 +5633,16 @@ function restoreCustomData(entries) {
5610
5633
  }
5611
5634
 
5612
5635
  // ../../apps/web/src/components/support-widget/sdk/open-store.ts
5613
- import { useCallback as useCallback8, useEffect as useEffect12, useSyncExternalStore as useSyncExternalStore7 } from "react";
5636
+ import { useCallback as useCallback8, useEffect as useEffect13, useRef as useRef16, useSyncExternalStore as useSyncExternalStore7 } from "react";
5614
5637
  var isDevelopment = typeof process !== "undefined" && process.env.NODE_ENV === "development";
5615
5638
  function createOpenStore(component) {
5616
5639
  let requested = null;
5617
5640
  let effective = false;
5618
5641
  let mounted = 0;
5642
+ const mountedNames = [];
5619
5643
  const listeners7 = /* @__PURE__ */ new Set();
5644
+ const requestListeners = /* @__PURE__ */ new Set();
5645
+ let isReporting = false;
5620
5646
  function emit() {
5621
5647
  for (const listener of listeners7) listener();
5622
5648
  }
@@ -5640,6 +5666,20 @@ function createOpenStore(component) {
5640
5666
  request(next) {
5641
5667
  requested = next;
5642
5668
  emit();
5669
+ if (isReporting) return;
5670
+ isReporting = true;
5671
+ try {
5672
+ for (const listener of requestListeners) listener(next);
5673
+ } finally {
5674
+ isReporting = false;
5675
+ }
5676
+ },
5677
+ /** Hears each request: a trigger, the hook, or the panel's own button. */
5678
+ onRequest(listener) {
5679
+ requestListeners.add(listener);
5680
+ return () => {
5681
+ requestListeners.delete(listener);
5682
+ };
5643
5683
  },
5644
5684
  /** Told, not asked: the panel saying what it settled on. */
5645
5685
  settle(next) {
@@ -5647,12 +5687,17 @@ function createOpenStore(component) {
5647
5687
  effective = next;
5648
5688
  emit();
5649
5689
  },
5650
- countMounted() {
5690
+ countMounted(name = component) {
5651
5691
  mounted += 1;
5692
+ mountedNames.push(name);
5652
5693
  return mounted;
5653
5694
  },
5654
- countUnmounted() {
5695
+ /** The components on the page, for a warning that names them. */
5696
+ mountedNames: () => [...mountedNames],
5697
+ countUnmounted(name = component) {
5655
5698
  mounted -= 1;
5699
+ const at2 = mountedNames.indexOf(name);
5700
+ if (at2 !== -1) mountedNames.splice(at2, 1);
5656
5701
  if (mounted === 0 && effective) {
5657
5702
  effective = false;
5658
5703
  emit();
@@ -5690,52 +5735,52 @@ function useOpenState(store3, {
5690
5735
  store3.readServerRequested
5691
5736
  );
5692
5737
  const isOpen = open ?? asked ?? defaultOpen;
5693
- useEffect12(() => {
5738
+ useEffect13(() => {
5694
5739
  store3.settle(isOpen);
5695
5740
  }, [store3, isOpen]);
5741
+ const reportRef = useRef16(onOpenChange);
5742
+ useEffect13(() => {
5743
+ reportRef.current = onOpenChange;
5744
+ });
5745
+ useEffect13(
5746
+ () => store3.onRequest((next) => reportRef.current?.(next)),
5747
+ [store3]
5748
+ );
5696
5749
  const setOpen = useCallback8(
5697
5750
  (next) => {
5698
5751
  store3.request(next);
5699
- onOpenChange?.(next);
5700
5752
  },
5701
- [store3, onOpenChange]
5753
+ [store3]
5702
5754
  );
5703
5755
  return [isOpen, setOpen];
5704
5756
  }
5705
- function useRegister(store3) {
5706
- useEffect12(() => {
5707
- if (store3.countMounted() > 1 && isDevelopment) {
5757
+ function useRegister(store3, name = store3.component) {
5758
+ useEffect13(() => {
5759
+ if (store3.countMounted(name) > 1 && isDevelopment) {
5760
+ const names = [...new Set(store3.mountedNames())];
5761
+ const which = names.length === 1 ? `more than one <${names[0]}> is mounted` : `${names.map((one) => `<${one}>`).join(" and ")} are both mounted`;
5708
5762
  console.warn(
5709
- `Median: more than one <${store3.component}> is mounted. They share one open state and open together. Mount it once, near the root of your app.`
5763
+ `Median: ${which}. They share one open state and open together. Mount one, once, near the root of your app.`
5710
5764
  );
5711
5765
  }
5712
- return () => store3.countUnmounted();
5713
- }, [store3]);
5766
+ return () => store3.countUnmounted(name);
5767
+ }, [store3, name]);
5714
5768
  }
5715
5769
 
5716
- // ../backend/convex/shared/auditResult.ts
5770
+ // ../backend/convex/shared/mutationResult.ts
5717
5771
  import { ConvexError } from "convex/values";
5718
- function unwrapAuditResult(result) {
5772
+ function unwrapResult(result) {
5719
5773
  if (result.auditResult === "error") throw new ConvexError(result.data);
5720
5774
  return result.value;
5721
5775
  }
5722
5776
 
5723
- // ../backend/client/auditedMutation.ts
5777
+ // ../backend/client/mutationResult.ts
5724
5778
  function unwrapMutationResult(result) {
5725
5779
  if (result && typeof result === "object" && "auditResult" in result && (result.auditResult === "ok" && "value" in result || result.auditResult === "error" && "data" in result)) {
5726
- return unwrapAuditResult(
5727
- result
5728
- );
5780
+ return unwrapResult(result);
5729
5781
  }
5730
5782
  return result;
5731
5783
  }
5732
- function auditedClientMutation(mutation) {
5733
- const invoke = async (...args) => {
5734
- return unwrapMutationResult(await mutation(...args));
5735
- };
5736
- invoke.withOptimisticUpdate = (update) => auditedClientMutation(mutation.withOptimisticUpdate(update));
5737
- return invoke;
5738
- }
5739
5784
 
5740
5785
  // ../backend/convex/_generated/api.js
5741
5786
  import { anyApi, componentsGeneric } from "convex/server";
@@ -5966,7 +6011,7 @@ function cleanClientDiagnostics(input) {
5966
6011
  }
5967
6012
 
5968
6013
  // ../../apps/web/src/components/support-widget/sdk/diagnostics.ts
5969
- import { useCallback as useCallback9, useEffect as useEffect13, useRef as useRef16 } from "react";
6014
+ import { useCallback as useCallback9, useEffect as useEffect14, useRef as useRef17 } from "react";
5970
6015
  function settingsOf(option) {
5971
6016
  if (option === void 0 || option === false) return null;
5972
6017
  if (option === true) return { errors: true, network: false, console: false };
@@ -5996,9 +6041,8 @@ function messageOf(value) {
5996
6041
  function stackOf(value) {
5997
6042
  return value instanceof Error && typeof value.stack === "string" ? value.stack.slice(0, STACK_MAX_LENGTH) : void 0;
5998
6043
  }
5999
- function collect(settings) {
6000
- const undo = [];
6001
- if (settings.errors) {
6044
+ var INSTALLERS = {
6045
+ errors: () => {
6002
6046
  const onError = (event) => {
6003
6047
  if (!event.error && !event.message) return;
6004
6048
  record({
@@ -6024,12 +6068,14 @@ function collect(settings) {
6024
6068
  };
6025
6069
  window.addEventListener("error", onError);
6026
6070
  window.addEventListener("unhandledrejection", onRejection);
6027
- undo.push(() => {
6071
+ return () => {
6028
6072
  window.removeEventListener("error", onError);
6029
6073
  window.removeEventListener("unhandledrejection", onRejection);
6030
- });
6031
- }
6032
- if (settings.network && typeof window.fetch === "function") {
6074
+ };
6075
+ },
6076
+ network: () => {
6077
+ if (typeof window.fetch !== "function") return () => {
6078
+ };
6033
6079
  const original = window.fetch;
6034
6080
  window.fetch = async function medianFetch(...args) {
6035
6081
  const [input, init] = args;
@@ -6063,11 +6109,11 @@ function collect(settings) {
6063
6109
  throw thrown;
6064
6110
  }
6065
6111
  };
6066
- undo.push(() => {
6112
+ return () => {
6067
6113
  window.fetch = original;
6068
- });
6069
- }
6070
- if (settings.console) {
6114
+ };
6115
+ },
6116
+ console: () => {
6071
6117
  const original = console.error;
6072
6118
  console.error = function medianConsoleError(...args) {
6073
6119
  record({
@@ -6078,12 +6124,32 @@ function collect(settings) {
6078
6124
  });
6079
6125
  original.apply(console, args);
6080
6126
  };
6081
- undo.push(() => {
6127
+ return () => {
6082
6128
  console.error = original;
6083
- });
6129
+ };
6130
+ }
6131
+ };
6132
+ var wanted = {
6133
+ errors: 0,
6134
+ network: 0,
6135
+ console: 0
6136
+ };
6137
+ var removers = {};
6138
+ function collect(settings) {
6139
+ const kinds = Object.keys(settings).filter(
6140
+ (kind) => settings[kind]
6141
+ );
6142
+ for (const kind of kinds) {
6143
+ wanted[kind] += 1;
6144
+ if (wanted[kind] === 1) removers[kind] = INSTALLERS[kind]();
6084
6145
  }
6085
6146
  return () => {
6086
- for (const off of undo) off();
6147
+ for (const kind of kinds) {
6148
+ wanted[kind] -= 1;
6149
+ if (wanted[kind] > 0) continue;
6150
+ removers[kind]?.();
6151
+ delete removers[kind];
6152
+ }
6087
6153
  };
6088
6154
  }
6089
6155
  function snapshot(state) {
@@ -6097,24 +6163,37 @@ function snapshot(state) {
6097
6163
  });
6098
6164
  }
6099
6165
  function snapshotNow(extraState) {
6100
- return snapshot({ ...latestState, ...extraState });
6166
+ const merged = { ...extraState };
6167
+ for (const [key, value] of Object.entries(latestState ?? {})) {
6168
+ if (!Object.prototype.hasOwnProperty.call(merged, key)) {
6169
+ merged[key] = value;
6170
+ }
6171
+ }
6172
+ return snapshot(merged);
6101
6173
  }
6102
6174
  function useDiagnostics(option, appState) {
6103
6175
  const settings = settingsOf(option);
6104
6176
  const key = settings === null ? null : JSON.stringify(settings);
6105
- const stateRef = useRef16(appState);
6106
- useEffect13(() => {
6177
+ const stateRef = useRef17(appState);
6178
+ const shared = useRef17(void 0);
6179
+ useEffect14(() => {
6107
6180
  stateRef.current = appState;
6108
- latestState = appState;
6181
+ if (appState !== void 0) {
6182
+ latestState = appState;
6183
+ } else if (shared.current !== void 0 && latestState === shared.current) {
6184
+ latestState = void 0;
6185
+ }
6186
+ shared.current = appState;
6109
6187
  });
6110
- const sentAt = useRef16(null);
6111
- useEffect13(() => {
6188
+ const sentAt = useRef17(null);
6189
+ useEffect14(() => {
6112
6190
  if (key === null) return;
6113
6191
  return collect(JSON.parse(key));
6114
6192
  }, [key]);
6115
6193
  const take = useCallback9(() => {
6116
6194
  if (key === null) return void 0;
6117
- if (sentAt.current !== null && sentAt.current === recorded) return void 0;
6195
+ if (sentAt.current !== null && sentAt.current === recorded)
6196
+ return void 0;
6118
6197
  sentAt.current = recorded;
6119
6198
  return snapshot(stateRef.current);
6120
6199
  }, [key]);
@@ -6122,7 +6201,7 @@ function useDiagnostics(option, appState) {
6122
6201
  }
6123
6202
 
6124
6203
  // ../../apps/web/src/components/support-widget/sdk/install.ts
6125
- import { useEffect as useEffect14 } from "react";
6204
+ import { useEffect as useEffect15 } from "react";
6126
6205
  var install = null;
6127
6206
  var listeners3 = /* @__PURE__ */ new Set();
6128
6207
  function rememberInstall(next) {
@@ -6144,7 +6223,7 @@ function hasInstall() {
6144
6223
  return install !== null;
6145
6224
  }
6146
6225
  function useRememberInstall(apiKey, user) {
6147
- useEffect14(() => {
6226
+ useEffect15(() => {
6148
6227
  if (apiKey === void 0) return;
6149
6228
  rememberInstall({ apiKey, ...user ? { user } : {} });
6150
6229
  });
@@ -6257,6 +6336,10 @@ function isClear(color) {
6257
6336
  var STORAGE_PREFIX = "median:session:";
6258
6337
  var inMemorySessions = /* @__PURE__ */ new Map();
6259
6338
  var listeners4 = /* @__PURE__ */ new Set();
6339
+ var resetCount = 0;
6340
+ function getResetCount() {
6341
+ return resetCount;
6342
+ }
6260
6343
  function subscribeSession(listener) {
6261
6344
  listeners4.add(listener);
6262
6345
  return () => {
@@ -6279,6 +6362,7 @@ function getOrCreateSessionId(apiKey) {
6279
6362
  }
6280
6363
  }
6281
6364
  function resetSessions() {
6365
+ resetCount += 1;
6282
6366
  inMemorySessions.clear();
6283
6367
  if (typeof window !== "undefined") {
6284
6368
  try {
@@ -6295,30 +6379,33 @@ function resetSessions() {
6295
6379
  }
6296
6380
 
6297
6381
  // ../../apps/web/src/components/support-widget/sdk/use-median-thread.ts
6298
- import { useQuery } from "convex/react";
6382
+ import { useMutation as useMutation2, useQuery } from "convex/react";
6299
6383
 
6300
- // ../../apps/web/src/hooks/use-audited-mutation.ts
6301
- import { useMemo as useMemo2 } from "react";
6384
+ // ../../apps/web/src/components/support-widget/sdk/use-widget-mutation.ts
6302
6385
  import { useMutation } from "convex/react";
6303
- function useAuditedMutation(reference) {
6386
+ import { useCallback as useCallback10 } from "react";
6387
+ function useWidgetMutation(reference) {
6304
6388
  const mutation = useMutation(reference);
6305
- return useMemo2(() => auditedClientMutation(mutation), [mutation]);
6389
+ return useCallback10(
6390
+ async (...args) => unwrapMutationResult(await mutation(...args)),
6391
+ [mutation]
6392
+ );
6306
6393
  }
6307
6394
 
6308
6395
  // ../../apps/web/src/components/support-widget/sdk/use-median-thread.ts
6309
6396
  import {
6310
- useCallback as useCallback11,
6311
- useEffect as useEffect17,
6312
- useMemo as useMemo3,
6397
+ useCallback as useCallback12,
6398
+ useEffect as useEffect18,
6399
+ useMemo as useMemo2,
6313
6400
  useState as useState18,
6314
6401
  useSyncExternalStore as useSyncExternalStore9
6315
6402
  } from "react";
6316
6403
 
6317
6404
  // ../../apps/web/src/hooks/use-now.ts
6318
- import { useEffect as useEffect15, useState as useState17 } from "react";
6405
+ import { useEffect as useEffect16, useState as useState17 } from "react";
6319
6406
  function useNow(intervalMs = 3e4) {
6320
6407
  const [now, setNow] = useState17(() => Date.now());
6321
- useEffect15(() => {
6408
+ useEffect16(() => {
6322
6409
  const timer = setInterval(() => setNow(Date.now()), intervalMs);
6323
6410
  return () => clearInterval(timer);
6324
6411
  }, [intervalMs]);
@@ -6328,6 +6415,10 @@ function useNow(intervalMs = 3e4) {
6328
6415
  // ../../apps/web/src/lib/errors.ts
6329
6416
  import { ConvexError as ConvexError2 } from "convex/values";
6330
6417
  var FALLBACK = "Something went wrong on our end. Please try again.";
6418
+ var OUT_OF_DATE = "This page is out of date. Refresh to get the latest version.";
6419
+ function isMissingFunction(error) {
6420
+ return error instanceof Error && error.message.includes("Could not find public function");
6421
+ }
6331
6422
  function isErrorPayload(data) {
6332
6423
  return typeof data === "object" && data !== null && "message" in data && typeof data.message === "string";
6333
6424
  }
@@ -6336,6 +6427,7 @@ function errorMessage(error) {
6336
6427
  if (typeof error.data === "string") return error.data;
6337
6428
  if (isErrorPayload(error.data)) return error.data.message;
6338
6429
  }
6430
+ if (isMissingFunction(error)) return OUT_OF_DATE;
6339
6431
  return FALLBACK;
6340
6432
  }
6341
6433
 
@@ -6434,14 +6526,14 @@ function widgetReadReceipts(messages, now) {
6434
6526
  }
6435
6527
 
6436
6528
  // ../../apps/web/src/components/support-widget/sdk/use-screenshot-ask.ts
6437
- import { useEffect as useEffect16, useRef as useRef17 } from "react";
6529
+ import { useEffect as useEffect17, useRef as useRef18 } from "react";
6438
6530
  function useScreenshotAsk({
6439
6531
  ask,
6440
6532
  enabled: enabled2,
6441
6533
  answer
6442
6534
  }) {
6443
- const answered = useRef17(/* @__PURE__ */ new Set());
6444
- useEffect16(() => {
6535
+ const answered = useRef18(/* @__PURE__ */ new Set());
6536
+ useEffect17(() => {
6445
6537
  if (ask === null || answered.current.has(ask.key)) return;
6446
6538
  answered.current.add(ask.key);
6447
6539
  void (async () => {
@@ -6454,7 +6546,7 @@ function useScreenshotAsk({
6454
6546
  }
6455
6547
 
6456
6548
  // ../../apps/web/src/components/support-widget/sdk/visitor-email.ts
6457
- import { useCallback as useCallback10, useSyncExternalStore as useSyncExternalStore8 } from "react";
6549
+ import { useCallback as useCallback11, useSyncExternalStore as useSyncExternalStore8 } from "react";
6458
6550
  var STORAGE_PREFIX3 = "median:email:";
6459
6551
  var inMemory2 = /* @__PURE__ */ new Map();
6460
6552
  var listeners5 = /* @__PURE__ */ new Set();
@@ -6499,10 +6591,10 @@ function resetVisitorEmails() {
6499
6591
  function useVisitorEmail(apiKey) {
6500
6592
  const email = useSyncExternalStore8(
6501
6593
  subscribeVisitorEmail,
6502
- useCallback10(() => readVisitorEmail(apiKey), [apiKey]),
6594
+ useCallback11(() => readVisitorEmail(apiKey), [apiKey]),
6503
6595
  () => null
6504
6596
  );
6505
- const setEmail = useCallback10(
6597
+ const setEmail = useCallback11(
6506
6598
  (next) => writeVisitorEmail(apiKey, next),
6507
6599
  [apiKey]
6508
6600
  );
@@ -6542,7 +6634,7 @@ function useMedianThread({
6542
6634
  }) {
6543
6635
  const sessionId = useSyncExternalStore9(
6544
6636
  subscribeSession,
6545
- useCallback11(() => getOrCreateSessionId(apiKey), [apiKey]),
6637
+ useCallback12(() => getOrCreateSessionId(apiKey), [apiKey]),
6546
6638
  () => null
6547
6639
  );
6548
6640
  const config = useQuery(api.widget.config, { apiKey });
@@ -6552,14 +6644,14 @@ function useMedianThread({
6552
6644
  api.widget.thread,
6553
6645
  sessionId === null || isLocked ? "skip" : { apiKey, sessionId }
6554
6646
  );
6555
- const send = useAuditedMutation(api.widget.sendV2);
6556
- const sendTyping = useAuditedMutation(api.widget.setTyping);
6557
- const sendPresence = useAuditedMutation(api.widget.presence);
6558
- const rateConversation = useAuditedMutation(api.widget.rateV2);
6559
- const identify = useAuditedMutation(api.widget.identifyV2);
6560
- const generateUploadUrl = useAuditedMutation(api.widget.generateUploadUrlV2);
6561
- const answerScreenshot = useAuditedMutation(api.widget.answerScreenshotV2);
6562
- const answerAsk = useCallback11(
6647
+ const send = useWidgetMutation(api.widget.sendV2);
6648
+ const sendTyping = useMutation2(api.widget.setTyping);
6649
+ const sendPresence = useMutation2(api.widget.presence);
6650
+ const rateConversation = useWidgetMutation(api.widget.rateV2);
6651
+ const identify = useWidgetMutation(api.widget.identifyV2);
6652
+ const generateUploadUrl = useWidgetMutation(api.widget.generateUploadUrlV2);
6653
+ const answerScreenshot = useWidgetMutation(api.widget.answerScreenshotV2);
6654
+ const answerAsk = useCallback12(
6563
6655
  async (key, shot) => {
6564
6656
  if (sessionId === null) return;
6565
6657
  let attachment;
@@ -6586,11 +6678,11 @@ function useMedianThread({
6586
6678
  [apiKey, sessionId, generateUploadUrl, answerScreenshot]
6587
6679
  );
6588
6680
  const identityKey = user ? JSON.stringify(user) : null;
6589
- const identity = useMemo3(
6681
+ const identity = useMemo2(
6590
6682
  () => identityKey === null ? null : JSON.parse(identityKey),
6591
6683
  [identityKey]
6592
6684
  );
6593
- useEffect17(() => {
6685
+ useEffect18(() => {
6594
6686
  if (sessionId === null || identity === null) return;
6595
6687
  const { facts, claim } = splitIdentity(identity);
6596
6688
  identify({
@@ -6611,7 +6703,7 @@ function useMedianThread({
6611
6703
  const takeDiagnostics = useDiagnostics(diagnostics, appState);
6612
6704
  const [isSending, setIsSending] = useState18(false);
6613
6705
  const [sendError, setSendError] = useState18(null);
6614
- const agent = useMemo3(
6706
+ const agent = useMemo2(
6615
6707
  () => config === void 0 ? null : {
6616
6708
  id: "median-agent",
6617
6709
  name: config.agent.name,
@@ -6620,7 +6712,7 @@ function useMedianThread({
6620
6712
  },
6621
6713
  [config]
6622
6714
  );
6623
- const messages = useMemo3(() => {
6715
+ const messages = useMemo2(() => {
6624
6716
  if (!thread || agent === null) return [];
6625
6717
  const out = [];
6626
6718
  let previousAt;
@@ -6669,7 +6761,7 @@ function useMedianThread({
6669
6761
  }
6670
6762
  return out;
6671
6763
  }, [thread, agent, now]);
6672
- const presence = useMemo3(() => {
6764
+ const presence = useMemo2(() => {
6673
6765
  if (config === void 0 || agent === null) return null;
6674
6766
  const humans = /* @__PURE__ */ new Map();
6675
6767
  for (const message of messages) {
@@ -6683,7 +6775,7 @@ function useMedianThread({
6683
6775
  team: [...[...humans.values()].slice(-2), agent]
6684
6776
  };
6685
6777
  }, [config, agent, messages]);
6686
- const unread = useMemo3(() => {
6778
+ const unread = useMemo2(() => {
6687
6779
  const unreadIds = new Set(
6688
6780
  thread?.messages.filter(isUnreadReply).map((message) => message._id)
6689
6781
  );
@@ -6760,11 +6852,11 @@ function useMedianThread({
6760
6852
  const readsKey = JSON.stringify(
6761
6853
  widgetReadReceipts(thread?.messages ?? [], now)
6762
6854
  );
6763
- const reads = useMemo3(
6855
+ const reads = useMemo2(
6764
6856
  () => JSON.parse(readsKey),
6765
6857
  [readsKey]
6766
6858
  );
6767
- const reportPresence = useCallback11(() => {
6859
+ const reportPresence = useCallback12(() => {
6768
6860
  if (sessionId === null || isLocked) return;
6769
6861
  sendPresence({
6770
6862
  apiKey,
@@ -6940,8 +7032,51 @@ function useCanReportError() {
6940
7032
  return isInstalled && Boolean(MEDIAN_DEPLOYMENT_URL);
6941
7033
  }
6942
7034
 
7035
+ // ../../apps/web/src/components/support-widget/sdk/signed-out.ts
7036
+ import { useEffect as useEffect19, useRef as useRef19, useState as useState19, useSyncExternalStore as useSyncExternalStore11 } from "react";
7037
+ var held = /* @__PURE__ */ new Map();
7038
+ var signedOut = /* @__PURE__ */ new Set();
7039
+ var RELEASE_AFTER_MS = 2e3;
7040
+ function signOutHeldUsers() {
7041
+ for (const person of held.values()) signedOut.add(person);
7042
+ }
7043
+ function releaseLater(person) {
7044
+ if (!signedOut.has(person)) return;
7045
+ setTimeout(() => {
7046
+ for (const other of held.values()) if (other === person) return;
7047
+ signedOut.delete(person);
7048
+ }, RELEASE_AFTER_MS);
7049
+ }
7050
+ function personKey(user) {
7051
+ if (user === void 0) return null;
7052
+ return user.id && user.hash ? `id:${user.id}` : JSON.stringify(user);
7053
+ }
7054
+ function useSignedInUser(user) {
7055
+ const person = personKey(user);
7056
+ useSyncExternalStore11(subscribeSession, getResetCount, () => 0);
7057
+ const [token] = useState19(() => Symbol("median-panel"));
7058
+ const previous = useRef19(null);
7059
+ useEffect19(() => {
7060
+ if (previous.current !== null && previous.current !== person) {
7061
+ signedOut.delete(previous.current);
7062
+ }
7063
+ previous.current = person;
7064
+ if (person === null) held.delete(token);
7065
+ else held.set(token, person);
7066
+ }, [person, token]);
7067
+ useEffect19(
7068
+ () => () => {
7069
+ const person2 = held.get(token);
7070
+ held.delete(token);
7071
+ if (person2 !== void 0) releaseLater(person2);
7072
+ },
7073
+ [token]
7074
+ );
7075
+ return person !== null && signedOut.has(person) ? void 0 : user;
7076
+ }
7077
+
6943
7078
  // ../../apps/web/src/components/support-widget/sdk/unread-store.ts
6944
- import { useSyncExternalStore as useSyncExternalStore11 } from "react";
7079
+ import { useSyncExternalStore as useSyncExternalStore12 } from "react";
6945
7080
  var count = 0;
6946
7081
  var listeners6 = /* @__PURE__ */ new Set();
6947
7082
  var unreadStore = {
@@ -6961,7 +7096,7 @@ var unreadStore = {
6961
7096
  }
6962
7097
  };
6963
7098
  function useUnreadCount() {
6964
- return useSyncExternalStore11(
7099
+ return useSyncExternalStore12(
6965
7100
  unreadStore.subscribe,
6966
7101
  unreadStore.read,
6967
7102
  unreadStore.readServer
@@ -7006,7 +7141,13 @@ var medianSupport = {
7006
7141
  }
7007
7142
  return;
7008
7143
  }
7009
- store.warnIfNothingIsMounted("data was attached");
7144
+ if (!isDevelopment || hasCustomDataSender()) return;
7145
+ setTimeout(() => {
7146
+ if (hasCustomDataSender()) return;
7147
+ console.warn(
7148
+ "Median: data was attached, but no <MedianSupport>, <MedianFeedback> or contact form is on the page to send it. It goes with the next message, note, sendMedianContact() or reportError() call."
7149
+ );
7150
+ }, 1e3);
7010
7151
  },
7011
7152
  /**
7012
7153
  * File the crash your error screen is showing, with everything the browser
@@ -7025,14 +7166,19 @@ var medianSupport = {
7025
7166
  * Forget this browser's conversation, so the next one starts fresh and
7026
7167
  * anonymous. Call it when your user signs out: whoever sits down next
7027
7168
  * should not find somebody else's thread waiting.
7169
+ *
7170
+ * The user the widget holds right now is signed out with it, even if your
7171
+ * own state still passes them for a moment, and an identity route is read
7172
+ * again.
7028
7173
  */
7029
7174
  reset() {
7175
+ signOutHeldUsers();
7030
7176
  resetSessions();
7031
7177
  resetVisitorEmails();
7032
7178
  }
7033
7179
  };
7034
7180
  function useMedianSupport() {
7035
- const isOpen = useSyncExternalStore12(
7181
+ const isOpen = useSyncExternalStore13(
7036
7182
  store.subscribe,
7037
7183
  store.readEffective,
7038
7184
  store.readServerEffective
@@ -7052,18 +7198,18 @@ function useMedianSupport() {
7052
7198
  function useMedianOpenState(options) {
7053
7199
  return useOpenState(store, options);
7054
7200
  }
7055
- function useRegisterMedianSupport() {
7056
- useRegister(store);
7201
+ function useRegisterMedianSupport(name = "MedianSupport") {
7202
+ useRegister(store, name);
7057
7203
  }
7058
7204
 
7059
7205
  // ../../apps/web/src/components/support-widget/sdk/error-boundary.tsx
7060
7206
  import { ConvexError as ConvexError3 } from "convex/values";
7061
7207
  import { Component } from "react";
7062
- function adviceFor(error) {
7208
+ function adviceFor(error, component) {
7063
7209
  if (error instanceof ConvexError3 && typeof error.data === "object" && error.data !== null && error.data.code === "invalid_api_key") {
7064
- return "Median did not recognize the apiKey passed to <MedianSupport>, so the widget has been hidden. Derive it from an active MEDIAN_KEY with publicKeyFromMedianKey.";
7210
+ return `Median did not recognize the apiKey passed to <${component}>, so it has been hidden. Derive it from an active MEDIAN_KEY with publicKeyFromMedianKey.`;
7065
7211
  }
7066
- return "The Median support widget hit an error and has been hidden. Your page is unaffected.";
7212
+ return `Median: <${component}> hit an error and has been hidden. Your page is unaffected.`;
7067
7213
  }
7068
7214
  var MedianErrorBoundary = class extends Component {
7069
7215
  state = { hasFailed: false };
@@ -7071,7 +7217,7 @@ var MedianErrorBoundary = class extends Component {
7071
7217
  return { hasFailed: true };
7072
7218
  }
7073
7219
  componentDidCatch(error) {
7074
- console.error(adviceFor(error), error);
7220
+ console.error(adviceFor(error, this.props.component), error);
7075
7221
  }
7076
7222
  render() {
7077
7223
  return this.state.hasFailed ? null : this.props.children;
@@ -7079,7 +7225,7 @@ var MedianErrorBoundary = class extends Component {
7079
7225
  };
7080
7226
 
7081
7227
  // ../../apps/web/src/components/support-widget/sdk/use-identity.ts
7082
- import { useEffect as useEffect18, useState as useState19 } from "react";
7228
+ import { useEffect as useEffect20, useState as useState20, useSyncExternalStore as useSyncExternalStore14 } from "react";
7083
7229
  var NOTHING = {
7084
7230
  apiKey: void 0,
7085
7231
  user: void 0,
@@ -7087,8 +7233,9 @@ var NOTHING = {
7087
7233
  };
7088
7234
  var WAITING = { ...NOTHING, isLoading: true };
7089
7235
  var inFlight2 = /* @__PURE__ */ new Map();
7090
- function read3(endpoint) {
7091
- const existing = inFlight2.get(endpoint);
7236
+ function read3(endpoint, resets) {
7237
+ const cacheKey = `${resets}:${endpoint}`;
7238
+ const existing = inFlight2.get(cacheKey);
7092
7239
  if (existing !== void 0) return existing;
7093
7240
  const request = (async () => {
7094
7241
  const response = await fetch(endpoint, {
@@ -7103,26 +7250,27 @@ function read3(endpoint) {
7103
7250
  );
7104
7251
  }
7105
7252
  return await response.json();
7106
- })().finally(() => inFlight2.delete(endpoint));
7107
- inFlight2.set(endpoint, request);
7253
+ })().finally(() => inFlight2.delete(cacheKey));
7254
+ inFlight2.set(cacheKey, request);
7108
7255
  return request;
7109
7256
  }
7110
- function useMissingCredentials(component, apiKey, endpoint) {
7111
- useEffect18(() => {
7257
+ function useMissingCredentials(caller, apiKey, endpoint, consequence = "nothing is on the page") {
7258
+ useEffect20(() => {
7112
7259
  if (apiKey !== void 0 || endpoint !== void 0) return;
7113
7260
  console.error(
7114
- `Median: <${component}> was given neither apiKey nor identity, so nothing is on the page. Pass the median_pk_ id from publicKeyFromMedianKey(MEDIAN_KEY), or the path of a route built with medianIdentity().`
7261
+ `Median: ${caller} was given neither apiKey nor identity, so ${consequence}. Pass the median_pk_ id from publicKeyFromMedianKey(MEDIAN_KEY), or the path of a route built with medianIdentity().`
7115
7262
  );
7116
- }, [component, apiKey, endpoint]);
7263
+ }, [caller, apiKey, endpoint, consequence]);
7117
7264
  }
7118
7265
  function useMedianIdentity(endpoint) {
7119
- const [answered, setAnswered] = useState19(null);
7120
- useEffect18(() => {
7266
+ const [answered, setAnswered] = useState20(null);
7267
+ const resets = useSyncExternalStore14(subscribeSession, getResetCount, () => 0);
7268
+ useEffect20(() => {
7121
7269
  if (endpoint === void 0) return;
7122
7270
  let listening = true;
7123
7271
  void (async () => {
7124
7272
  try {
7125
- const body = await read3(endpoint);
7273
+ const body = await read3(endpoint, resets);
7126
7274
  if (!listening) return;
7127
7275
  setAnswered({
7128
7276
  endpoint,
@@ -7146,7 +7294,7 @@ function useMedianIdentity(endpoint) {
7146
7294
  return () => {
7147
7295
  listening = false;
7148
7296
  };
7149
- }, [endpoint]);
7297
+ }, [endpoint, resets]);
7150
7298
  if (endpoint === void 0) return NOTHING;
7151
7299
  if (answered?.endpoint === endpoint) return answered.identity;
7152
7300
  return WAITING;
@@ -7154,10 +7302,10 @@ function useMedianIdentity(endpoint) {
7154
7302
 
7155
7303
  // ../../apps/web/src/components/support-widget/sdk/use-median-branding.ts
7156
7304
  import { ConvexHttpClient as ConvexHttpClient2 } from "convex/browser";
7157
- import { useEffect as useEffect19, useState as useState20 } from "react";
7305
+ import { useEffect as useEffect21, useState as useState21 } from "react";
7158
7306
  function useMedianBranding(apiKey) {
7159
- const [state, setState] = useState20({ key: apiKey, show: true });
7160
- useEffect19(() => {
7307
+ const [state, setState] = useState21({ key: apiKey, show: true });
7308
+ useEffect21(() => {
7161
7309
  if (!apiKey || !MEDIAN_DEPLOYMENT_URL) return;
7162
7310
  const client3 = new ConvexHttpClient2(MEDIAN_DEPLOYMENT_URL);
7163
7311
  let active = true;
@@ -7193,13 +7341,13 @@ function useMedianBranding(apiKey) {
7193
7341
 
7194
7342
  // ../../apps/web/src/components/support-widget/sdk/median-connection.tsx
7195
7343
  import { ConvexProvider, ConvexReactClient } from "convex/react";
7196
- import { useState as useState21 } from "react";
7344
+ import { useState as useState22 } from "react";
7197
7345
  import { jsx as jsx37 } from "react/jsx-runtime";
7198
7346
  function MedianConnection({
7199
7347
  what,
7200
7348
  children
7201
7349
  }) {
7202
- const [client3] = useState21(() => {
7350
+ const [client3] = useState22(() => {
7203
7351
  if (!MEDIAN_DEPLOYMENT_URL) {
7204
7352
  throw new Error(
7205
7353
  `The Median ${what} was built without a deployment URL. Set NEXT_PUBLIC_CONVEX_URL.`
@@ -7211,15 +7359,15 @@ function MedianConnection({
7211
7359
  }
7212
7360
 
7213
7361
  // ../../apps/web/src/components/support-widget/sdk/use-api-key-warning.ts
7214
- import { useEffect as useEffect20 } from "react";
7215
- function useApiKeyShapeWarning(component, apiKey) {
7216
- useEffect20(() => {
7362
+ import { useEffect as useEffect22 } from "react";
7363
+ function useApiKeyShapeWarning(caller, apiKey) {
7364
+ useEffect22(() => {
7217
7365
  if (apiKey === void 0 || hasPrefix(apiKey, API_KEY_PREFIX)) return;
7218
7366
  const shown = apiKey === "" ? "an empty string" : `"${apiKey.length > 16 ? `${apiKey.slice(0, 16)}\u2026` : apiKey}"`;
7219
7367
  console.error(
7220
- `Median: the apiKey passed to <${component}> is ${shown}, which does not look like the browser-safe id from publicKeyFromMedianKey(MEDIAN_KEY). It should start with ${API_KEY_PREFIX}.`
7368
+ `Median: the apiKey passed to ${caller} is ${shown}, which does not look like the browser-safe id from publicKeyFromMedianKey(MEDIAN_KEY). It should start with ${API_KEY_PREFIX}.`
7221
7369
  );
7222
- }, [component, apiKey]);
7370
+ }, [caller, apiKey]);
7223
7371
  }
7224
7372
 
7225
7373
  // ../../node_modules/.bun/cuelume@0.2.2/node_modules/cuelume/dist/sounds/recipes.js
@@ -7540,16 +7688,16 @@ function play(sound = "chime", options) {
7540
7688
  }
7541
7689
 
7542
7690
  // ../../apps/web/src/components/support-widget/sdk/use-message-sound.ts
7543
- import { useEffect as useEffect21, useRef as useRef18 } from "react";
7691
+ import { useEffect as useEffect23, useRef as useRef20 } from "react";
7544
7692
  var ARRIVAL_VOLUME = 0.45;
7545
7693
  function useMessageSound({
7546
7694
  messages,
7547
7695
  conversationId = null,
7548
7696
  isLoading
7549
7697
  }) {
7550
- const heard = useRef18(null);
7551
- const watching = useRef18(null);
7552
- useEffect21(() => {
7698
+ const heard = useRef20(null);
7699
+ const watching = useRef20(null);
7700
+ useEffect23(() => {
7553
7701
  if (isLoading) {
7554
7702
  heard.current = null;
7555
7703
  return;
@@ -7573,7 +7721,7 @@ function useMessageSound({
7573
7721
  }
7574
7722
 
7575
7723
  // ../../apps/web/src/components/support-widget/sdk/use-navigation.ts
7576
- import { useCallback as useCallback12, useEffect as useEffect22, useLayoutEffect as useLayoutEffect10, useRef as useRef19, useState as useState22 } from "react";
7724
+ import { useCallback as useCallback13, useEffect as useEffect24, useLayoutEffect as useLayoutEffect10, useRef as useRef21, useState as useState23 } from "react";
7577
7725
  var isDevelopment2 = typeof process !== "undefined" && process.env.NODE_ENV === "development";
7578
7726
  var STALE_AFTER_MS = 5 * 60 * 1e3;
7579
7727
  function isFresh(at2) {
@@ -7617,12 +7765,12 @@ function useSupportNavigation({
7617
7765
  isLoading,
7618
7766
  onNavigate
7619
7767
  }) {
7620
- const seen = useRef19(null);
7621
- const watching = useRef19(null);
7622
- const [spotlight, setSpotlight] = useState22(null);
7623
- const drawn = useRef19(0);
7624
- const [taken, setTaken] = useState22(null);
7625
- const follow = useCallback12(
7768
+ const seen = useRef21(null);
7769
+ const watching = useRef21(null);
7770
+ const [spotlight, setSpotlight] = useState23(null);
7771
+ const drawn = useRef21(0);
7772
+ const [taken, setTaken] = useState23(null);
7773
+ const follow = useCallback13(
7626
7774
  (destination) => {
7627
7775
  if (onNavigate === void 0) return;
7628
7776
  const path = pathOnThisSite(destination.path);
@@ -7662,8 +7810,8 @@ function useSupportNavigation({
7662
7810
  }
7663
7811
  if (latest !== null) setSpotlight(latest);
7664
7812
  }, [messages, ask, conversationId, isLoading]);
7665
- const warned = useRef19(false);
7666
- useEffect22(() => {
7813
+ const warned = useRef21(false);
7814
+ useEffect24(() => {
7667
7815
  if (!isDevelopment2 || onNavigate !== void 0 || warned.current) return;
7668
7816
  const offered = messages.some((message) => message.navigateTo !== void 0) || ask?.navigateTo != null;
7669
7817
  if (!offered) return;
@@ -7672,8 +7820,8 @@ function useSupportNavigation({
7672
7820
  "Median: a tool offered to take this visitor to a page, but <MedianSupport> has no onNavigate, so no button is shown for it. Pass one, such as onNavigate={router.push}."
7673
7821
  );
7674
7822
  }, [messages, ask, onNavigate]);
7675
- const [, expire] = useState22(0);
7676
- useEffect22(() => {
7823
+ const [, expire] = useState23(0);
7824
+ useEffect24(() => {
7677
7825
  if (ask === null || ask.navigateTo === null) return;
7678
7826
  const left = ask.at + STALE_AFTER_MS - Date.now();
7679
7827
  if (left <= 0) return;
@@ -7685,7 +7833,7 @@ function useSupportNavigation({
7685
7833
  }
7686
7834
 
7687
7835
  // ../../apps/web/src/components/support-widget/sdk/use-teaser.ts
7688
- import { useCallback as useCallback13, useState as useState23 } from "react";
7836
+ import { useCallback as useCallback14, useState as useState24 } from "react";
7689
7837
 
7690
7838
  // ../../apps/web/src/components/support-widget/sdk/stamps.ts
7691
7839
  var inMemory3 = /* @__PURE__ */ new Map();
@@ -7724,11 +7872,11 @@ function writeTeaserDismissedAt(apiKey, at2) {
7724
7872
 
7725
7873
  // ../../apps/web/src/components/support-widget/sdk/use-teaser.ts
7726
7874
  function useTeaser(apiKey, latestUnread) {
7727
- const [dismissedAt, setDismissedAt] = useState23(
7875
+ const [dismissedAt, setDismissedAt] = useState24(
7728
7876
  () => readTeaserDismissedAt(apiKey)
7729
7877
  );
7730
7878
  const teaser = latestUnread !== null && (latestUnread.sentAt ?? 0) > dismissedAt ? latestUnread : null;
7731
- const dismiss = useCallback13(() => {
7879
+ const dismiss = useCallback14(() => {
7732
7880
  if (teaser === null) return;
7733
7881
  const at2 = teaser.sentAt ?? Date.now();
7734
7882
  writeTeaserDismissedAt(apiKey, at2);
@@ -7738,12 +7886,12 @@ function useTeaser(apiKey, latestUnread) {
7738
7886
  }
7739
7887
 
7740
7888
  // ../../apps/web/src/components/support-widget/sdk/use-unread-title.ts
7741
- import { useEffect as useEffect23 } from "react";
7889
+ import { useEffect as useEffect25 } from "react";
7742
7890
  function badged(count2, title) {
7743
7891
  return `(${count2}) ${title}`.trim();
7744
7892
  }
7745
7893
  function useUnreadTitle(unreadCount) {
7746
- useEffect23(() => {
7894
+ useEffect25(() => {
7747
7895
  if (unreadCount === 0 || typeof document === "undefined") return;
7748
7896
  let plain = document.title;
7749
7897
  let shown = badged(unreadCount, plain);
@@ -7779,7 +7927,7 @@ function MedianSupportPreview({
7779
7927
  className,
7780
7928
  ...props
7781
7929
  }) {
7782
- return /* @__PURE__ */ jsx38(MedianErrorBoundary, { children: /* @__PURE__ */ jsx38(
7930
+ return /* @__PURE__ */ jsx38(MedianErrorBoundary, { component: componentName(presentation), children: /* @__PURE__ */ jsx38(
7783
7931
  MedianIdentity,
7784
7932
  {
7785
7933
  ...props,
@@ -7789,17 +7937,25 @@ function MedianSupportPreview({
7789
7937
  }
7790
7938
  ) });
7791
7939
  }
7940
+ function componentName(presentation) {
7941
+ return presentation === "modal" ? "MedianSupportModal" : "MedianSupport";
7942
+ }
7792
7943
  function MedianIdentity({ apiKey, identity, user, ...rest }) {
7793
7944
  const resolved = useMedianIdentity(identity);
7794
- useMissingCredentials("MedianSupport", apiKey, identity);
7945
+ useMissingCredentials(
7946
+ `<${componentName(rest.presentation)}>`,
7947
+ apiKey,
7948
+ identity
7949
+ );
7795
7950
  const key = apiKey ?? resolved.apiKey;
7951
+ const person = useSignedInUser(user ?? resolved.user);
7796
7952
  if (key === void 0) return null;
7797
7953
  return /* @__PURE__ */ jsx38(MedianConnection, { what: "widget", children: /* @__PURE__ */ jsx38(
7798
7954
  MedianLauncher,
7799
7955
  {
7800
7956
  ...rest,
7801
7957
  apiKey: key,
7802
- user: user ?? resolved.user,
7958
+ user: person,
7803
7959
  isResolvingIdentity: resolved.isLoading
7804
7960
  }
7805
7961
  ) });
@@ -7825,11 +7981,9 @@ function MedianLauncher({
7825
7981
  isResolvingIdentity,
7826
7982
  className
7827
7983
  }) {
7828
- useRegisterMedianSupport();
7829
- useApiKeyShapeWarning(
7830
- presentation === "modal" ? "MedianSupportModal" : "MedianSupport",
7831
- apiKey
7832
- );
7984
+ useRegisterMedianSupport(componentName(presentation));
7985
+ useCustomDataSender();
7986
+ useApiKeyShapeWarning(`<${componentName(presentation)}>`, apiKey);
7833
7987
  useRememberInstall(apiKey, user);
7834
7988
  const showBranding = useMedianBranding(apiKey);
7835
7989
  const [isOpen, setOpen] = useMedianOpenState({
@@ -7868,11 +8022,11 @@ function MedianLauncher({
7868
8022
  });
7869
8023
  const { teaser, dismiss: dismissTeaser } = useTeaser(apiKey, latestUnread);
7870
8024
  const isSettling = isLoading || isResolvingIdentity;
7871
- useEffect24(() => {
8025
+ useEffect26(() => {
7872
8026
  if (!threadRendersMarkdown(messages)) return;
7873
8027
  return warmMarkdownWhenIdle();
7874
8028
  }, [messages]);
7875
- useEffect24(() => {
8029
+ useEffect26(() => {
7876
8030
  if (!isOpen) return;
7877
8031
  const beat = () => {
7878
8032
  if (document.visibilityState === "visible") reportPresence();
@@ -7906,10 +8060,10 @@ function MedianLauncher({
7906
8060
  isLoading: isSettling || isLocked
7907
8061
  });
7908
8062
  useUnreadTitle(titleCount ? unreadCount : 0);
7909
- useEffect24(() => {
8063
+ useEffect26(() => {
7910
8064
  unreadStore.set(unreadCount);
7911
8065
  }, [unreadCount]);
7912
- useEffect24(() => () => unreadStore.set(0), []);
8066
+ useEffect26(() => () => unreadStore.set(0), []);
7913
8067
  const resolvedPresence = presence ?? {
7914
8068
  name: "Support",
7915
8069
  status: "Connecting",
@@ -8037,10 +8191,10 @@ function mountMedianSupportModal(options) {
8037
8191
 
8038
8192
  // ../../apps/web/src/components/support-widget/sdk/median-feedback.tsx
8039
8193
  import {
8040
- useCallback as useCallback15,
8041
- useEffect as useEffect27,
8042
- useRef as useRef22,
8043
- useState as useState27
8194
+ useCallback as useCallback16,
8195
+ useEffect as useEffect29,
8196
+ useRef as useRef24,
8197
+ useState as useState28
8044
8198
  } from "react";
8045
8199
 
8046
8200
  // ../backend/convex/shared/feedback.ts
@@ -8051,17 +8205,17 @@ var MAX_REPORT_IMAGES = 6;
8051
8205
 
8052
8206
  // ../../apps/web/src/components/support-widget/feedback/feedback-panel.tsx
8053
8207
  import {
8054
- useEffect as useEffect26,
8055
- useRef as useRef21,
8056
- useState as useState25
8208
+ useEffect as useEffect28,
8209
+ useRef as useRef23,
8210
+ useState as useState26
8057
8211
  } from "react";
8058
8212
 
8059
8213
  // ../../apps/web/src/components/support-widget/feedback/feedback-popover.tsx
8060
- import { useEffect as useEffect25, useRef as useRef20 } from "react";
8214
+ import { useEffect as useEffect27, useRef as useRef22 } from "react";
8061
8215
  import { createPortal as createPortal3 } from "react-dom";
8062
8216
 
8063
8217
  // ../../apps/web/src/components/support-widget/feedback/use-anchor.ts
8064
- import { useLayoutEffect as useLayoutEffect11, useState as useState24 } from "react";
8218
+ import { useLayoutEffect as useLayoutEffect11, useState as useState25 } from "react";
8065
8219
  var GAP2 = 8;
8066
8220
  var MARGIN2 = 16;
8067
8221
  function findAnchor(selector) {
@@ -8081,7 +8235,7 @@ function useAnchor({
8081
8235
  panelRef,
8082
8236
  isOpen
8083
8237
  }) {
8084
- const [side, setSide] = useState24("bottom");
8238
+ const [side, setSide] = useState25("bottom");
8085
8239
  useLayoutEffect11(() => {
8086
8240
  if (!isOpen) return;
8087
8241
  let frame = 0;
@@ -8150,12 +8304,12 @@ function FeedbackPopover({
8150
8304
  width,
8151
8305
  children
8152
8306
  }) {
8153
- const panelRef = useRef20(null);
8307
+ const panelRef = useRef22(null);
8154
8308
  const side = useAnchor({ triggerRef, anchor, panelRef, isOpen });
8155
8309
  const isHydrated = useHydrated();
8156
- const opener = useRef20(null);
8157
- const wasOpen = useRef20(isOpen);
8158
- useEffect25(() => {
8310
+ const opener = useRef22(null);
8311
+ const wasOpen = useRef22(isOpen);
8312
+ useEffect27(() => {
8159
8313
  if (!isOpen) return;
8160
8314
  function handleKeyDown(event) {
8161
8315
  if (event.key === "Escape") onClose();
@@ -8163,7 +8317,7 @@ function FeedbackPopover({
8163
8317
  document.addEventListener("keydown", handleKeyDown);
8164
8318
  return () => document.removeEventListener("keydown", handleKeyDown);
8165
8319
  }, [isOpen, onClose]);
8166
- useEffect25(() => {
8320
+ useEffect27(() => {
8167
8321
  if (!isOpen) return;
8168
8322
  function handlePointerDown(event) {
8169
8323
  const target = event.target;
@@ -8175,7 +8329,7 @@ function FeedbackPopover({
8175
8329
  document.addEventListener("pointerdown", handlePointerDown);
8176
8330
  return () => document.removeEventListener("pointerdown", handlePointerDown);
8177
8331
  }, [isOpen, onClose, triggerRef]);
8178
- useEffect25(() => {
8332
+ useEffect27(() => {
8179
8333
  if (wasOpen.current === isOpen) return;
8180
8334
  wasOpen.current = isOpen;
8181
8335
  if (isOpen) {
@@ -8244,17 +8398,17 @@ function FeedbackPanel({
8244
8398
  placeholder = "Tell us what could be better.",
8245
8399
  className
8246
8400
  }) {
8247
- const [draft, setDraft] = useState25("");
8248
- const [isSending, setSending] = useState25(false);
8249
- const [isSent, setSent] = useState25(false);
8250
- const fileInputRef = useRef21(null);
8401
+ const [draft, setDraft] = useState26("");
8402
+ const [isSending, setSending] = useState26(false);
8403
+ const [isSent, setSent] = useState26(false);
8404
+ const fileInputRef = useRef23(null);
8251
8405
  const images = useAttachmentDrafts({
8252
8406
  accept: "image",
8253
8407
  max: MAX_REPORT_IMAGES
8254
8408
  });
8255
8409
  const target = useAttachmentTarget({ onFiles: images.add });
8256
8410
  const canSend = draft.trim().length > 0 && !images.hasBlocker && !isSending && !isSent;
8257
- useEffect26(() => {
8411
+ useEffect28(() => {
8258
8412
  if (!isSent) return;
8259
8413
  const timer = setTimeout(() => onSent?.(), THANKS_MS2);
8260
8414
  return () => clearTimeout(timer);
@@ -8414,7 +8568,7 @@ function FeedbackPanel({
8414
8568
  }
8415
8569
 
8416
8570
  // ../../apps/web/src/components/support-widget/sdk/feedback-control.ts
8417
- import { useSyncExternalStore as useSyncExternalStore13 } from "react";
8571
+ import { useSyncExternalStore as useSyncExternalStore15 } from "react";
8418
8572
  var store2 = createOpenStore("MedianFeedback");
8419
8573
  var medianFeedback = {
8420
8574
  /** What the panel is doing right now. */
@@ -8437,7 +8591,7 @@ var medianFeedback = {
8437
8591
  }
8438
8592
  };
8439
8593
  function useMedianFeedback() {
8440
- const isOpen = useSyncExternalStore13(
8594
+ const isOpen = useSyncExternalStore15(
8441
8595
  store2.subscribe,
8442
8596
  store2.readEffective,
8443
8597
  store2.readServerEffective
@@ -8457,7 +8611,7 @@ function useRegisterMedianFeedback() {
8457
8611
  }
8458
8612
 
8459
8613
  // ../../apps/web/src/components/support-widget/sdk/use-feedback-note.ts
8460
- import { useCallback as useCallback14, useState as useState26, useSyncExternalStore as useSyncExternalStore14 } from "react";
8614
+ import { useCallback as useCallback15, useState as useState27, useSyncExternalStore as useSyncExternalStore16 } from "react";
8461
8615
  var REFUSALS = {
8462
8616
  off: "Feedback is currently unavailable. Try again later.",
8463
8617
  empty: "Enter your feedback before sending."
@@ -8470,16 +8624,16 @@ function useFeedbackNote({
8470
8624
  diagnostics,
8471
8625
  appState
8472
8626
  }) {
8473
- const sessionId = useSyncExternalStore14(
8627
+ const sessionId = useSyncExternalStore16(
8474
8628
  subscribeSession,
8475
- useCallback14(() => getOrCreateSessionId(apiKey), [apiKey]),
8629
+ useCallback15(() => getOrCreateSessionId(apiKey), [apiKey]),
8476
8630
  () => null
8477
8631
  );
8478
- const submitNote = useAuditedMutation(api.feedback.submitV2);
8479
- const getUploadUrl = useAuditedMutation(api.widget.generateUploadUrlV2);
8632
+ const submitNote = useWidgetMutation(api.feedback.submitV2);
8633
+ const getUploadUrl = useWidgetMutation(api.widget.generateUploadUrlV2);
8480
8634
  const takeDiagnostics = useDiagnostics(diagnostics, appState);
8481
- const [notice, setNotice] = useState26(null);
8482
- const submit = useCallback14(
8635
+ const [notice, setNotice] = useState27(null);
8636
+ const submit = useCallback15(
8483
8637
  async (body, images = []) => {
8484
8638
  setNotice(null);
8485
8639
  if (sessionId === null) {
@@ -8547,7 +8701,7 @@ function useFeedbackNote({
8547
8701
  import { Fragment as Fragment33, jsx as jsx44, jsxs as jsxs24 } from "react/jsx-runtime";
8548
8702
  var DEFAULT_WIDTH2 = "20rem";
8549
8703
  function MedianFeedback(props) {
8550
- return /* @__PURE__ */ jsx44(MedianErrorBoundary, { children: /* @__PURE__ */ jsx44(FeedbackIdentity, { ...props }) });
8704
+ return /* @__PURE__ */ jsx44(MedianErrorBoundary, { component: "MedianFeedback", children: /* @__PURE__ */ jsx44(FeedbackIdentity, { ...props }) });
8551
8705
  }
8552
8706
  function FeedbackIdentity({
8553
8707
  apiKey,
@@ -8556,9 +8710,9 @@ function FeedbackIdentity({
8556
8710
  ...rest
8557
8711
  }) {
8558
8712
  const resolved = useMedianIdentity(identity);
8559
- useMissingCredentials("MedianFeedback", apiKey, identity);
8713
+ useMissingCredentials("<MedianFeedback>", apiKey, identity);
8560
8714
  const key = apiKey ?? resolved.apiKey;
8561
- const person = user ?? resolved.user;
8715
+ const person = useSignedInUser(user ?? resolved.user);
8562
8716
  if (key === void 0) return null;
8563
8717
  return /* @__PURE__ */ jsx44(MedianConnection, { what: "feedback panel", children: /* @__PURE__ */ jsx44(Feedback, { ...rest, apiKey: key, ...person ? { user: person } : {} }) });
8564
8718
  }
@@ -8579,9 +8733,10 @@ function Feedback({
8579
8733
  placeholder
8580
8734
  }) {
8581
8735
  useRegisterMedianFeedback();
8582
- useApiKeyShapeWarning("MedianFeedback", apiKey);
8736
+ useApiKeyShapeWarning("<MedianFeedback>", apiKey);
8737
+ useCustomDataSender();
8583
8738
  useRememberInstall(apiKey, user);
8584
- const triggerRef = useRef22(null);
8739
+ const triggerRef = useRef24(null);
8585
8740
  const [isOpen, setOpen] = useMedianFeedbackOpenState({
8586
8741
  ...open !== void 0 ? { open } : {},
8587
8742
  ...onOpenChange ? { onOpenChange } : {}
@@ -8595,10 +8750,10 @@ function Feedback({
8595
8750
  ...appState ? { appState } : {}
8596
8751
  });
8597
8752
  const showBranding = useMedianBranding(apiKey);
8598
- const close = useCallback15(() => setOpen(false), [setOpen]);
8599
- const [attempt, setAttempt] = useState27(0);
8600
- const hasSent = useRef22(false);
8601
- useEffect27(() => {
8753
+ const close = useCallback16(() => setOpen(false), [setOpen]);
8754
+ const [attempt, setAttempt] = useState28(0);
8755
+ const hasSent = useRef24(false);
8756
+ useEffect29(() => {
8602
8757
  if (!isOpen || !hasSent.current) return;
8603
8758
  hasSent.current = false;
8604
8759
  setAttempt((count2) => count2 + 1);
@@ -8661,19 +8816,19 @@ function mountMedianFeedback(options) {
8661
8816
  }
8662
8817
 
8663
8818
  // ../../apps/web/src/components/support-widget/sdk/median-contact-form.tsx
8664
- import { useEffect as useEffect29, useMemo as useMemo6 } from "react";
8819
+ import { useEffect as useEffect31, useMemo as useMemo5 } from "react";
8665
8820
 
8666
8821
  // ../../apps/web/src/components/support-widget/contact/contact-form.tsx
8667
8822
  import {
8668
- useEffect as useEffect28,
8823
+ useEffect as useEffect30,
8669
8824
  useId,
8670
- useMemo as useMemo4,
8671
- useRef as useRef24,
8672
- useState as useState29
8825
+ useMemo as useMemo3,
8826
+ useRef as useRef26,
8827
+ useState as useState30
8673
8828
  } from "react";
8674
8829
 
8675
8830
  // ../../apps/web/src/components/support-widget/contact/contact-field.tsx
8676
- import { useState as useState28 } from "react";
8831
+ import { useState as useState29 } from "react";
8677
8832
  import { jsx as jsx46, jsxs as jsxs25 } from "react/jsx-runtime";
8678
8833
  var LINE_MAX_LENGTH = 200;
8679
8834
  var SHELL = cn(
@@ -8691,9 +8846,9 @@ function ContactField({
8691
8846
  onChange,
8692
8847
  onSubmit
8693
8848
  }) {
8694
- const [held, setHeld] = useState28(error);
8695
- if (error !== null && error !== held) setHeld(error);
8696
- const shown = error ?? held;
8849
+ const [held2, setHeld] = useState29(error);
8850
+ if (error !== null && error !== held2) setHeld(error);
8851
+ const shown = error ?? held2;
8697
8852
  const errorId = `${id}-error`;
8698
8853
  const control = {
8699
8854
  id,
@@ -8899,7 +9054,7 @@ function fieldComplaints(fields) {
8899
9054
  }
8900
9055
 
8901
9056
  // ../../apps/web/src/components/support-widget/contact/sent-mark.tsx
8902
- import { useLayoutEffect as useLayoutEffect12, useRef as useRef23 } from "react";
9057
+ import { useLayoutEffect as useLayoutEffect12, useRef as useRef25 } from "react";
8903
9058
  import { jsx as jsx47, jsxs as jsxs26 } from "react/jsx-runtime";
8904
9059
  var EASE_OUT = "cubic-bezier(0.22, 1, 0.36, 1)";
8905
9060
  var TRAVEL_MS = 550;
@@ -8913,10 +9068,10 @@ function SentMark({
8913
9068
  from = null,
8914
9069
  className
8915
9070
  }) {
8916
- const frame = useRef23(null);
8917
- const square = useRef23(null);
8918
- const tick = useRef23(null);
8919
- const ring = useRef23(null);
9071
+ const frame = useRef25(null);
9072
+ const square = useRef25(null);
9073
+ const tick = useRef25(null);
9074
+ const ring = useRef25(null);
8920
9075
  useLayoutEffect12(() => {
8921
9076
  const rest = frame.current;
8922
9077
  const box = square.current;
@@ -9062,20 +9217,20 @@ function ContactForm({
9062
9217
  showBadge = true,
9063
9218
  className
9064
9219
  }) {
9065
- const fields = useMemo4(() => resolveFields(hostFields), [hostFields]);
9220
+ const fields = useMemo3(() => resolveFields(hostFields), [hostFields]);
9066
9221
  const prefix = useId();
9067
- const formRef = useRef24(null);
9068
- const sendRef = useRef24(null);
9069
- const [values, setValues] = useState29(
9222
+ const formRef = useRef26(null);
9223
+ const sendRef = useRef26(null);
9224
+ const [values, setValues] = useState30(
9070
9225
  () => startingValues(fields, initialValues)
9071
9226
  );
9072
- const [errors, setErrors] = useState29({});
9073
- const [isSending, setSending] = useState29(false);
9074
- const [sent, setSent] = useState29(null);
9227
+ const [errors, setErrors] = useState30({});
9228
+ const [isSending, setSending] = useState30(false);
9229
+ const [sent, setSent] = useState30(null);
9075
9230
  const isSent = sent !== null;
9076
9231
  const knownEmail = initialValues?.email;
9077
9232
  const knownName = initialValues?.name;
9078
- const [known, setKnown] = useState29({ email: knownEmail, name: knownName });
9233
+ const [known, setKnown] = useState30({ email: knownEmail, name: knownName });
9079
9234
  if (known.email !== knownEmail || known.name !== knownName) {
9080
9235
  setKnown({ email: knownEmail, name: knownName });
9081
9236
  setValues((current2) => {
@@ -9085,8 +9240,8 @@ function ContactForm({
9085
9240
  return next;
9086
9241
  });
9087
9242
  }
9088
- const [focusRequest, setFocusRequest] = useState29(0);
9089
- useEffect28(() => {
9243
+ const [focusRequest, setFocusRequest] = useState30(0);
9244
+ useEffect30(() => {
9090
9245
  if (focusRequest === 0) return;
9091
9246
  formRef.current?.querySelector('[aria-invalid="true"]')?.focus({ preventScroll: false });
9092
9247
  }, [focusRequest]);
@@ -9283,7 +9438,7 @@ function ContactForm({
9283
9438
  }
9284
9439
 
9285
9440
  // ../../apps/web/src/components/support-widget/sdk/use-median-contact.ts
9286
- import { useCallback as useCallback16, useMemo as useMemo5, useState as useState30, useSyncExternalStore as useSyncExternalStore15 } from "react";
9441
+ import { useCallback as useCallback17, useMemo as useMemo4, useState as useState31, useSyncExternalStore as useSyncExternalStore17 } from "react";
9287
9442
 
9288
9443
  // ../../apps/web/src/components/support-widget/sdk/contact.ts
9289
9444
  import { ConvexHttpClient as ConvexHttpClient3 } from "convex/browser";
@@ -9314,7 +9469,9 @@ async function deliverContact(options, message) {
9314
9469
  ...context ? { context } : {},
9315
9470
  ...page ? { page } : {},
9316
9471
  ...options.diagnostics ? { diagnostics: options.diagnostics } : {},
9317
- ...custom ? { customData: custom } : {}
9472
+ ...custom ? { customData: custom } : {},
9473
+ // Replies go to the address they typed: nothing on the page shows one.
9474
+ fromContactForm: true
9318
9475
  }).then(unwrapMutationResult);
9319
9476
  } catch (caught) {
9320
9477
  if (custom) restoreCustomData(custom);
@@ -9334,18 +9491,19 @@ async function sendMedianContact(options, message) {
9334
9491
  }
9335
9492
 
9336
9493
  // ../../apps/web/src/components/support-widget/sdk/use-median-contact.ts
9337
- function useMedianContact(options) {
9494
+ function useMedianContact(options, caller = "useMedianContact()") {
9338
9495
  const { apiKey, identity, user, telemetry, diagnostics, appState } = options;
9339
9496
  const resolved = useMedianIdentity(identity);
9340
- useMissingCredentials("useMedianContact", apiKey, identity);
9497
+ useMissingCredentials(caller, apiKey, identity, "it cannot send");
9341
9498
  const key = apiKey ?? resolved.apiKey;
9342
9499
  const showBranding = useMedianBranding(key);
9343
- useApiKeyShapeWarning("useMedianContact", key);
9344
- const person = user ?? resolved.user;
9500
+ useApiKeyShapeWarning(caller, key);
9501
+ useCustomDataSender();
9502
+ const person = useSignedInUser(user ?? resolved.user);
9345
9503
  useRememberInstall(key, person);
9346
- const sessionId = useSyncExternalStore15(
9504
+ const sessionId = useSyncExternalStore17(
9347
9505
  subscribeSession,
9348
- useCallback16(
9506
+ useCallback17(
9349
9507
  () => key === void 0 ? null : getOrCreateSessionId(key),
9350
9508
  [key]
9351
9509
  ),
@@ -9353,9 +9511,9 @@ function useMedianContact(options) {
9353
9511
  );
9354
9512
  const takeDiagnostics = useDiagnostics(diagnostics, appState);
9355
9513
  const [knownEmail] = useVisitorEmail(key ?? "");
9356
- const [isSending, setSending] = useState30(false);
9357
- const [error, setError] = useState30(null);
9358
- const send = useCallback16(
9514
+ const [isSending, setSending] = useState31(false);
9515
+ const [error, setError] = useState31(null);
9516
+ const send = useCallback17(
9359
9517
  async (message) => {
9360
9518
  setError(null);
9361
9519
  if (key === void 0 || sessionId === null) {
@@ -9385,7 +9543,7 @@ function useMedianContact(options) {
9385
9543
  },
9386
9544
  [key, sessionId, person, telemetry, takeDiagnostics]
9387
9545
  );
9388
- const known = useMemo5(() => {
9546
+ const known = useMemo4(() => {
9389
9547
  const email = person?.email || knownEmail || void 0;
9390
9548
  if (person === void 0 && email === void 0) return void 0;
9391
9549
  return { ...person, ...email ? { email } : {} };
@@ -9403,11 +9561,11 @@ function useMedianContact(options) {
9403
9561
  // ../../apps/web/src/components/support-widget/sdk/median-contact-form.tsx
9404
9562
  import { jsx as jsx49 } from "react/jsx-runtime";
9405
9563
  function MedianContactForm(props) {
9406
- return /* @__PURE__ */ jsx49(MedianErrorBoundary, { children: /* @__PURE__ */ jsx49(ConnectedContactForm, { ...props }) });
9564
+ return /* @__PURE__ */ jsx49(MedianErrorBoundary, { component: "MedianContactForm", children: /* @__PURE__ */ jsx49(ConnectedContactForm, { ...props }) });
9407
9565
  }
9408
9566
  function useFieldComplaints(fields) {
9409
9567
  const key = fields === void 0 ? null : JSON.stringify(fields);
9410
- useEffect29(() => {
9568
+ useEffect31(() => {
9411
9569
  if (key === null) return;
9412
9570
  for (const complaint of fieldComplaints(JSON.parse(key))) {
9413
9571
  console.error(
@@ -9423,11 +9581,11 @@ function ConnectedContactForm({
9423
9581
  onSent,
9424
9582
  ...options
9425
9583
  }) {
9426
- const contact = useMedianContact(options);
9584
+ const contact = useMedianContact(options, "<MedianContactForm>");
9427
9585
  useFieldComplaints(fields);
9428
9586
  const knownEmail = contact.user?.email || void 0;
9429
9587
  const knownName = contact.user?.name || void 0;
9430
- const initialValues = useMemo6(
9588
+ const initialValues = useMemo5(
9431
9589
  () => ({
9432
9590
  ...knownEmail ? { email: knownEmail } : {},
9433
9591
  ...knownName ? { name: knownName } : {}
@@ -9441,7 +9599,14 @@ function ConnectedContactForm({
9441
9599
  fields,
9442
9600
  onSubmit: async (message) => {
9443
9601
  await contact.send(message);
9444
- onSent?.();
9602
+ try {
9603
+ onSent?.();
9604
+ } catch (caught) {
9605
+ console.error(
9606
+ "Median: onSent threw after the message was sent.",
9607
+ caught
9608
+ );
9609
+ }
9445
9610
  },
9446
9611
  notice: contact.error,
9447
9612
  initialValues,