@nivaro/react 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ import { normalizeReplaySampling as x, replaySampleDraw as Ae, currentReplayRout
8
8
  import { emitReplayTap as Ce, setReplayRecorderMode as N, registerReplayCapture as Ie, clipEndOffset as _e, withClipKind as De } from "../shared/lib/replay-capture.js";
9
9
  import { instrumentConsole as qe, instrumentRequests as Le, redactSecrets as Te } from "../shared/lib/replay-context.js";
10
10
  import { instrumentSocket as Pe } from "../shared/lib/replay-socket.js";
11
- const Ne = "nivaro-react@0.3.1", j = 1e4, Me = 150, Oe = 3e3, Ue = 600, We = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
11
+ const Ne = "nivaro-react@0.3.3", j = 1e4, Me = 150, Oe = 3e3, Ue = 600, We = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
12
  function Fe(n) {
13
13
  return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
14
14
  const l = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
@@ -1,20 +1,21 @@
1
- import { jsxs as l, jsx as e, Fragment as V } from "react/jsx-runtime";
2
- import { MicOff as U, WifiOff as X, ChevronDown as _, Settings2 as Q, Volume2 as q, Keyboard as z } from "lucide-react";
3
- import { useState as m, useRef as b, useId as Z, useCallback as P, useEffect as g, useMemo as ee } from "react";
4
- import { toast as te } from "sonner";
1
+ import { jsxs as l, jsx as e, Fragment as U } from "react/jsx-runtime";
2
+ import { MicOff as X, WifiOff as _, ChevronDown as Q, Settings2 as q, Volume2 as z, Keyboard as Z } from "lucide-react";
3
+ import { useState as m, useRef as b, useId as ee, useCallback as P, useEffect as g, useMemo as te } from "react";
4
+ import { toast as ae } from "sonner";
5
5
  import { cn as f } from "../../../lib/utils.js";
6
- import { Popover as v, PopoverTrigger as L, PopoverContent as y, PopoverAnchor as ae } from "../../ui/popover.js";
6
+ import { Popover as y, PopoverTrigger as F, PopoverContent as N, PopoverAnchor as re } from "../../ui/popover.js";
7
7
  import { SimpleSelect as D } from "../../ui/SimpleSelect.js";
8
- import { Skeleton as O } from "../../ui/skeleton.js";
9
- import { Switch as re } from "../../ui/switch.js";
10
- import { createLevelMeter as ne, speakerChoiceSupported as se, playTestTone as le } from "./huddle-audio.js";
11
- import { HUDDLE_SHORTCUTS as oe, qualityTip as ie, isPseudoDevice as ce, meterFill as de } from "./huddle-audio-logic.js";
12
- import { loadDevicePrefs as ue } from "./huddle-device-prefs.js";
13
- import { listAudioDevices as pe, openMic as me, currentMicId as he, applyDevicePrefs as E } from "./huddle-devices.js";
14
- import { huddleShortcuts as F } from "./huddle-shortcuts.js";
15
- import { huddleSpeaking as fe } from "./huddle-speaking.js";
16
- import { useHuddleShortcuts as be } from "./useHuddleAudio.js";
17
- function Fe({
8
+ import { Skeleton as E } from "../../ui/skeleton.js";
9
+ import { Switch as ne } from "../../ui/switch.js";
10
+ import { createLevelMeter as se, speakerChoiceSupported as le, playTestTone as oe } from "./huddle-audio.js";
11
+ import { HUDDLE_SHORTCUTS as ie, qualityTip as ce, isPseudoDevice as de, meterFill as ue } from "./huddle-audio-logic.js";
12
+ import { loadDevicePrefs as pe } from "./huddle-device-prefs.js";
13
+ import { listAudioDevices as me, openMic as he, currentMicId as fe, applyDevicePrefs as A } from "./huddle-devices.js";
14
+ import { useCloseOnWindowBlur as H } from "./huddle-dismiss.js";
15
+ import { huddleShortcuts as v } from "./huddle-shortcuts.js";
16
+ import { huddleSpeaking as be } from "./huddle-speaking.js";
17
+ import { useHuddleShortcuts as xe } from "./useHuddleAudio.js";
18
+ function We({
18
19
  speaking: r,
19
20
  children: n
20
21
  }) {
@@ -33,14 +34,14 @@ function Fe({
33
34
  )
34
35
  ] });
35
36
  }
36
- const xe = {
37
+ const ke = {
37
38
  4: "bg-emerald-500 dark:bg-emerald-400",
38
39
  3: "bg-emerald-500 dark:bg-emerald-400",
39
40
  2: "bg-amber-500 dark:bg-amber-400",
40
41
  1: "bg-red-500 dark:bg-red-400"
41
42
  };
42
- function He({ name: r, quality: n }) {
43
- const s = (n == null ? void 0 : n.bars) ?? 0, i = ie(r, n);
43
+ function $e({ name: r, quality: n }) {
44
+ const s = (n == null ? void 0 : n.bars) ?? 0, i = ce(r, n);
44
45
  return /* @__PURE__ */ e(
45
46
  "span",
46
47
  {
@@ -54,7 +55,7 @@ function He({ name: r, quality: n }) {
54
55
  {
55
56
  className: f(
56
57
  "w-[2px] rounded-[1px]",
57
- a <= s ? xe[s] : "bg-slate-300 dark:bg-slate-600"
58
+ a <= s ? ke[s] : "bg-slate-300 dark:bg-slate-600"
58
59
  ),
59
60
  style: { height: `${3 + a * 2}px` }
60
61
  },
@@ -63,7 +64,7 @@ function He({ name: r, quality: n }) {
63
64
  }
64
65
  );
65
66
  }
66
- function We({ sharing: r }) {
67
+ function Ge({ sharing: r }) {
67
68
  return /* @__PURE__ */ l(
68
69
  "div",
69
70
  {
@@ -71,7 +72,7 @@ function We({ sharing: r }) {
71
72
  className: "mt-1.5 flex items-start gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2 py-1 text-[11.5px] text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
72
73
  "data-huddle-poor": !0,
73
74
  children: [
74
- /* @__PURE__ */ e(X, { className: "mt-px h-3.5 w-3.5 shrink-0", strokeWidth: 2 }),
75
+ /* @__PURE__ */ e(_, { className: "mt-px h-3.5 w-3.5 shrink-0", strokeWidth: 2 }),
75
76
  /* @__PURE__ */ l("span", { children: [
76
77
  "Your connection is poor — others may hear you break up.",
77
78
  r && " Your shared screen is sent at a lower quality until it recovers."
@@ -80,7 +81,7 @@ function We({ sharing: r }) {
80
81
  }
81
82
  );
82
83
  }
83
- function $e() {
84
+ function Be() {
84
85
  return /* @__PURE__ */ l(
85
86
  "span",
86
87
  {
@@ -88,18 +89,18 @@ function $e() {
88
89
  className: "inline-flex h-6 items-center gap-1 rounded-full bg-red-50 px-2 text-[11px] font-medium text-red-700 motion-safe:animate-in motion-safe:fade-in motion-safe:duration-150 dark:bg-red-500/15 dark:text-red-200",
89
90
  "data-huddle-muted-talking": !0,
90
91
  children: [
91
- /* @__PURE__ */ e(U, { className: "h-3 w-3", strokeWidth: 2 }),
92
+ /* @__PURE__ */ e(X, { className: "h-3 w-3", strokeWidth: 2 }),
92
93
  "You are muted — hold Space to talk"
93
94
  ]
94
95
  }
95
96
  );
96
97
  }
97
- function ke({ read: r }) {
98
+ function ge({ read: r }) {
98
99
  const n = b(null), s = b(r);
99
100
  return s.current = r, g(() => {
100
101
  let i = 0, a = 0;
101
102
  const u = () => {
102
- const c = de(s.current());
103
+ const c = ue(s.current());
103
104
  a = c > a ? c : a * 0.85 + c * 0.15, n.current && (n.current.style.transform = `scaleX(${a.toFixed(3)})`), i = requestAnimationFrame(u);
104
105
  };
105
106
  return i = requestAnimationFrame(u), () => cancelAnimationFrame(i);
@@ -120,8 +121,8 @@ function ke({ read: r }) {
120
121
  }
121
122
  );
122
123
  }
123
- function A(r, n) {
124
- const s = r.find((a) => a.deviceId === "default"), i = r.filter((a) => !ce(a));
124
+ function L(r, n) {
125
+ const s = r.find((a) => a.deviceId === "default"), i = r.filter((a) => !de(a));
125
126
  return [
126
127
  {
127
128
  value: "",
@@ -130,7 +131,7 @@ function A(r, n) {
130
131
  ...i.map((a, u) => ({ value: a.deviceId, label: a.label || `${n} ${u + 1}` }))
131
132
  ];
132
133
  }
133
- const ge = [
134
+ const ve = [
134
135
  { key: "noiseSuppression", label: "Noise suppression", hint: "Filters out typing and fans" },
135
136
  {
136
137
  key: "echoCancellation",
@@ -139,14 +140,14 @@ const ge = [
139
140
  },
140
141
  { key: "autoGainControl", label: "Automatic volume", hint: "Evens out how loud you sound" }
141
142
  ];
142
- function H({
143
+ function W({
143
144
  mode: r,
144
145
  muted: n,
145
146
  onJoin: s,
146
147
  onShortcuts: i
147
148
  }) {
148
- const [a, u] = m(ue), [c, $] = m(null), [N, w] = m(null), [C, S] = m(!1), h = b(null), x = se(), I = Z(), p = P(() => {
149
- pe().then($);
149
+ const [a, u] = m(pe), [c, G] = m(null), [w, C] = m(null), [S, I] = m(!1), h = b(null), x = le(), O = ee(), p = P(() => {
150
+ me().then(G);
150
151
  }, []);
151
152
  g(() => {
152
153
  var o;
@@ -157,7 +158,7 @@ function H({
157
158
  return (d = t == null ? void 0 : t.removeEventListener) == null ? void 0 : d.call(t, "devicechange", p);
158
159
  };
159
160
  }, [p]);
160
- const T = ee(
161
+ const T = te(
161
162
  () => ({
162
163
  micId: a.micId,
163
164
  speakerId: null,
@@ -170,59 +171,59 @@ function H({
170
171
  g(() => {
171
172
  if (r !== "prejoin") return;
172
173
  let t = !1;
173
- return w(null), me(T).then((o) => {
174
+ return C(null), he(T).then((o) => {
174
175
  if (t) {
175
176
  for (const d of o.getTracks()) d.stop();
176
177
  return;
177
178
  }
178
- h.current = { stream: o, meter: ne(o) }, p();
179
+ h.current = { stream: o, meter: se(o) }, p();
179
180
  }).catch((o) => {
180
- t || w(
181
+ t || C(
181
182
  (o == null ? void 0 : o.name) === "NotAllowedError" ? "Microphone access is blocked for this site." : "This microphone could not be started."
182
183
  );
183
184
  }), () => {
184
185
  var o, d, M;
185
186
  t = !0, (d = (o = h.current) == null ? void 0 : o.meter) == null || d.stop();
186
- for (const J of ((M = h.current) == null ? void 0 : M.stream.getTracks()) ?? []) J.stop();
187
+ for (const V of ((M = h.current) == null ? void 0 : M.stream.getTracks()) ?? []) V.stop();
187
188
  h.current = null;
188
189
  };
189
190
  }, [r, T, p]);
190
- const G = P(
191
+ const B = P(
191
192
  () => {
192
193
  var t, o;
193
- return r === "live" ? fe.selfLevel() : ((o = (t = h.current) == null ? void 0 : t.meter) == null ? void 0 : o.level()) ?? 0;
194
+ return r === "live" ? be.selfLevel() : ((o = (t = h.current) == null ? void 0 : t.meter) == null ? void 0 : o.level()) ?? 0;
194
195
  },
195
196
  [r]
196
197
  ), k = async (t) => {
197
198
  if (u((d) => ({ ...d, ...t })), r === "prejoin") {
198
- await E(t);
199
+ await A(t);
199
200
  return;
200
201
  }
201
- await E(t) || te.error("That microphone could not be started — still using the previous one.");
202
+ await A(t) || ae.error("That microphone could not be started — still using the previous one.");
202
203
  }, R = async () => {
203
- S(!0);
204
+ I(!0);
204
205
  try {
205
- await le(x ? a.speakerId ?? "" : "");
206
+ await oe(x ? a.speakerId ?? "" : "");
206
207
  } finally {
207
- S(!1);
208
+ I(!1);
208
209
  }
209
- }, B = r === "live" ? he() : null, K = a.micId && (c != null && c.mics.some((t) => t.deviceId === a.micId)) ? a.micId : "", Y = a.speakerId && (c != null && c.speakers.some((t) => t.deviceId === a.speakerId)) ? a.speakerId : "", j = "h-7 w-full gap-1 rounded-md border-slate-200 bg-white px-2 text-left text-[12px] dark:border-border dark:bg-card [&>span]:min-w-0 [&>span]:flex-1 [&>span]:truncate";
210
+ }, K = r === "live" ? fe() : null, Y = a.micId && (c != null && c.mics.some((t) => t.deviceId === a.micId)) ? a.micId : "", J = a.speakerId && (c != null && c.speakers.some((t) => t.deviceId === a.speakerId)) ? a.speakerId : "", j = "h-7 w-full gap-1 rounded-md border-slate-200 bg-white px-2 text-left text-[12px] dark:border-border dark:bg-card [&>span]:min-w-0 [&>span]:flex-1 [&>span]:truncate";
210
211
  return /* @__PURE__ */ l("div", { className: "flex flex-col gap-3 text-[12px]", "data-huddle-devices": r, children: [
211
212
  /* @__PURE__ */ l("div", { className: "flex flex-col gap-1.5", children: [
212
213
  /* @__PURE__ */ e("span", { className: "text-[11.5px] font-medium text-slate-700 dark:text-slate-200", children: "Microphone" }),
213
214
  c ? /* @__PURE__ */ e(
214
215
  D,
215
216
  {
216
- value: K,
217
+ value: Y,
217
218
  onChange: (t) => void k({ micId: t || null }),
218
- options: A(c.mics, "Microphone"),
219
+ options: L(c.mics, "Microphone"),
219
220
  ariaLabel: "Microphone",
220
221
  className: j,
221
- triggerProps: { "data-huddle-mic": B ?? "" }
222
+ triggerProps: { "data-huddle-mic": K ?? "" }
222
223
  }
223
- ) : /* @__PURE__ */ e(O, { className: "h-7 w-full" }),
224
- N ? /* @__PURE__ */ e("span", { className: "text-[11px] text-red-600 dark:text-red-300", role: "alert", children: N }) : /* @__PURE__ */ l(V, { children: [
225
- /* @__PURE__ */ e(ke, { read: G }),
224
+ ) : /* @__PURE__ */ e(E, { className: "h-7 w-full" }),
225
+ w ? /* @__PURE__ */ e("span", { className: "text-[11px] text-red-600 dark:text-red-300", role: "alert", children: w }) : /* @__PURE__ */ l(U, { children: [
226
+ /* @__PURE__ */ e(ge, { read: B }),
226
227
  /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: r === "live" && n ? "You are muted — the bar still shows your level, nobody hears it." : "Say something — the bar should move." })
227
228
  ] })
228
229
  ] }),
@@ -232,41 +233,41 @@ function H({
232
233
  x && (c ? /* @__PURE__ */ e(
233
234
  D,
234
235
  {
235
- value: Y,
236
+ value: J,
236
237
  onChange: (t) => void k({ speakerId: t || null }),
237
- options: A(c.speakers, "Speaker"),
238
+ options: L(c.speakers, "Speaker"),
238
239
  ariaLabel: "Speaker",
239
240
  className: f(j, "min-w-0 flex-1")
240
241
  }
241
- ) : /* @__PURE__ */ e(O, { className: "h-7 min-w-0 flex-1" })),
242
+ ) : /* @__PURE__ */ e(E, { className: "h-7 min-w-0 flex-1" })),
242
243
  /* @__PURE__ */ l(
243
244
  "button",
244
245
  {
245
246
  type: "button",
246
247
  onClick: () => void R(),
247
- disabled: C,
248
+ disabled: S,
248
249
  className: f(
249
250
  "flex h-7 shrink-0 items-center gap-1 rounded-md border border-slate-200 bg-white px-2 text-[11.5px] font-medium text-slate-700 transition-colors hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-60 dark:border-border dark:bg-card dark:text-slate-200 dark:hover:bg-white/5",
250
251
  !x && "self-start"
251
252
  ),
252
253
  "data-huddle-test-speaker": !0,
253
254
  children: [
254
- /* @__PURE__ */ e(q, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
255
- C ? "Playing…" : "Test speaker"
255
+ /* @__PURE__ */ e(z, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
256
+ S ? "Playing…" : "Test speaker"
256
257
  ]
257
258
  }
258
259
  )
259
260
  ] })
260
261
  ] }),
261
- /* @__PURE__ */ e("div", { className: "flex flex-col gap-2 border-t border-slate-200 pt-2.5 dark:border-border", children: ge.map((t) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-3", children: [
262
- /* @__PURE__ */ l("label", { htmlFor: `${I}-${t.key}`, className: "flex min-w-0 cursor-pointer flex-col", children: [
262
+ /* @__PURE__ */ e("div", { className: "flex flex-col gap-2 border-t border-slate-200 pt-2.5 dark:border-border", children: ve.map((t) => /* @__PURE__ */ l("div", { className: "flex items-center justify-between gap-3", children: [
263
+ /* @__PURE__ */ l("label", { htmlFor: `${O}-${t.key}`, className: "flex min-w-0 cursor-pointer flex-col", children: [
263
264
  /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-700 dark:text-slate-200", children: t.label }),
264
265
  /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: t.hint })
265
266
  ] }),
266
267
  /* @__PURE__ */ e(
267
- re,
268
+ ne,
268
269
  {
269
- id: `${I}-${t.key}`,
270
+ id: `${O}-${t.key}`,
270
271
  checked: a[t.key],
271
272
  onCheckedChange: (o) => void k({ [t.key]: o }),
272
273
  className: "h-4 w-7 [&>span]:h-3 [&>span]:w-3 [&>span]:data-[state=checked]:translate-x-3",
@@ -291,22 +292,24 @@ function H({
291
292
  className: "flex items-center justify-between rounded-md px-1 py-0.5 text-[11.5px] text-slate-600 transition-colors hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-slate-300 dark:hover:bg-white/10",
292
293
  children: [
293
294
  /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5", children: [
294
- /* @__PURE__ */ e(z, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
295
+ /* @__PURE__ */ e(Z, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
295
296
  "Keyboard shortcuts"
296
297
  ] }),
297
- /* @__PURE__ */ e(W, { children: "?" })
298
+ /* @__PURE__ */ e($, { children: "?" })
298
299
  ]
299
300
  }
300
301
  )
301
302
  ] });
302
303
  }
303
- function Ge({
304
+ function Re({
304
305
  muted: r,
305
306
  variant: n = "gear"
306
307
  }) {
307
- const [s, i] = m(!1), a = b(!1);
308
- return /* @__PURE__ */ l(v, { open: s, onOpenChange: i, children: [
309
- /* @__PURE__ */ e(L, { asChild: !0, children: /* @__PURE__ */ e(
308
+ const [s, i] = m(!1);
309
+ H(s, () => i(!1));
310
+ const a = b(!1);
311
+ return /* @__PURE__ */ l(y, { open: s, onOpenChange: i, children: [
312
+ /* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
310
313
  "button",
311
314
  {
312
315
  type: "button",
@@ -318,19 +321,19 @@ function Ge({
318
321
  "aria-label": "Microphone and speaker settings",
319
322
  "data-tip": "Microphone and speaker",
320
323
  "data-huddle-device-button": !0,
321
- children: n === "chevron" ? /* @__PURE__ */ e(_, { className: "h-3 w-3", strokeWidth: 2.25 }) : /* @__PURE__ */ e(Q, { className: "h-3.5 w-3.5", strokeWidth: 2 })
324
+ children: n === "chevron" ? /* @__PURE__ */ e(Q, { className: "h-3 w-3", strokeWidth: 2.25 }) : /* @__PURE__ */ e(q, { className: "h-3.5 w-3.5", strokeWidth: 2 })
322
325
  }
323
326
  ) }),
324
327
  /* @__PURE__ */ e(
325
- y,
328
+ N,
326
329
  {
327
330
  align: n === "chevron" ? "start" : "end",
328
331
  className: "w-72 p-3",
329
332
  onCloseAutoFocus: (u) => {
330
- a.current && (a.current = !1, u.preventDefault(), F.setHelpOpen(!0));
333
+ a.current && (a.current = !1, u.preventDefault(), v.setHelpOpen(!0));
331
334
  },
332
335
  children: s && /* @__PURE__ */ e(
333
- H,
336
+ W,
334
337
  {
335
338
  mode: "live",
336
339
  muted: r,
@@ -343,20 +346,20 @@ function Ge({
343
346
  )
344
347
  ] });
345
348
  }
346
- function Re({
349
+ function Ke({
347
350
  onJoin: r,
348
351
  children: n
349
352
  }) {
350
353
  const [s, i] = m(!1);
351
- return /* @__PURE__ */ l(v, { open: s, onOpenChange: i, children: [
352
- /* @__PURE__ */ e(L, { asChild: !0, children: n }),
353
- /* @__PURE__ */ e(y, { align: "end", className: "w-72 p-3", children: s && /* @__PURE__ */ l("div", { className: "flex flex-col gap-2.5", children: [
354
+ return /* @__PURE__ */ l(y, { open: s, onOpenChange: i, children: [
355
+ /* @__PURE__ */ e(F, { asChild: !0, children: n }),
356
+ /* @__PURE__ */ e(N, { align: "end", className: "w-72 p-3", children: s && /* @__PURE__ */ l("div", { className: "flex flex-col gap-2.5", children: [
354
357
  /* @__PURE__ */ l("div", { className: "flex flex-col", children: [
355
358
  /* @__PURE__ */ e("span", { className: "text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Check before you join" }),
356
359
  /* @__PURE__ */ e("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a microphone and make sure the bar moves when you talk." })
357
360
  ] }),
358
361
  /* @__PURE__ */ e(
359
- H,
362
+ W,
360
363
  {
361
364
  mode: "prejoin",
362
365
  onJoin: () => {
@@ -367,31 +370,31 @@ function Re({
367
370
  ] }) })
368
371
  ] });
369
372
  }
370
- function W({ children: r }) {
373
+ function $({ children: r }) {
371
374
  return /* @__PURE__ */ e("kbd", { className: "inline-flex h-5 min-w-5 items-center justify-center rounded border border-slate-200 bg-slate-50 px-1 font-sans text-[10.5px] font-medium text-slate-600 dark:border-border dark:bg-muted dark:text-slate-300", children: r });
372
375
  }
373
- function Be() {
374
- const { helpOpen: r } = be();
375
- return /* @__PURE__ */ l(v, { open: r, onOpenChange: (n) => F.setHelpOpen(n), children: [
376
- /* @__PURE__ */ e(ae, { asChild: !0, children: /* @__PURE__ */ e("span", { "aria-hidden": !0, className: "w-0 self-stretch" }) }),
377
- /* @__PURE__ */ l(y, { align: "end", className: "w-64 p-3", "data-huddle-shortcuts": !0, children: [
376
+ function Ye() {
377
+ const { helpOpen: r } = xe();
378
+ return H(r, () => v.setHelpOpen(!1)), /* @__PURE__ */ l(y, { open: r, onOpenChange: (n) => v.setHelpOpen(n), children: [
379
+ /* @__PURE__ */ e(re, { asChild: !0, children: /* @__PURE__ */ e("span", { "aria-hidden": !0, className: "w-0 self-stretch" }) }),
380
+ /* @__PURE__ */ l(N, { align: "end", className: "w-64 p-3", "data-huddle-shortcuts": !0, children: [
378
381
  /* @__PURE__ */ e("div", { className: "mb-2 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Huddle shortcuts" }),
379
- /* @__PURE__ */ e("ul", { className: "flex flex-col gap-1.5", children: oe.map((n) => /* @__PURE__ */ l("li", { className: "flex items-center justify-between gap-3 text-[12px]", children: [
382
+ /* @__PURE__ */ e("ul", { className: "flex flex-col gap-1.5", children: ie.map((n) => /* @__PURE__ */ l("li", { className: "flex items-center justify-between gap-3 text-[12px]", children: [
380
383
  /* @__PURE__ */ e("span", { className: "text-slate-600 dark:text-slate-300", children: n.label }),
381
- /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center gap-0.5", children: n.keys.map((s) => /* @__PURE__ */ e(W, { children: s }, s)) })
384
+ /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center gap-0.5", children: n.keys.map((s) => /* @__PURE__ */ e($, { children: s }, s)) })
382
385
  ] }, n.label)) }),
383
386
  /* @__PURE__ */ e("p", { className: "mt-2.5 text-[11px] text-slate-500 dark:text-slate-400", children: "These work while you are in a huddle and not typing in a field. While you share, L asks once more before leaving." })
384
387
  ] })
385
388
  ] });
386
389
  }
387
390
  export {
388
- H as DevicePanel,
389
- Ge as DeviceSettingsButton,
390
- ke as LevelMeter,
391
- $e as MutedTalkingHint,
392
- We as PoorConnectionBanner,
393
- Re as PreJoinCheck,
394
- He as QualityBars,
395
- Be as ShortcutSheetAnchor,
396
- Fe as SpeakingRing
391
+ W as DevicePanel,
392
+ Re as DeviceSettingsButton,
393
+ ge as LevelMeter,
394
+ Be as MutedTalkingHint,
395
+ Ge as PoorConnectionBanner,
396
+ Ke as PreJoinCheck,
397
+ $e as QualityBars,
398
+ Ye as ShortcutSheetAnchor,
399
+ We as SpeakingRing
397
400
  };
@@ -1,5 +1,5 @@
1
1
  import { jsxs as i, jsx as e, Fragment as C } from "react/jsx-runtime";
2
- import { Headphones as H, MicOff as M, Mic as j, ScreenShare as L, PhoneOff as P, MoreHorizontal as W, ChevronLeft as O, UserPlus as B, Hand as R, Presentation as I, PictureInPicture2 as A, Keyboard as D } from "lucide-react";
2
+ import { Headphones as H, MicOff as M, Mic as j, ScreenShare as W, PhoneOff as L, MoreHorizontal as P, ChevronLeft as O, UserPlus as B, Hand as R, Presentation as I, PictureInPicture2 as A, Keyboard as D } from "lucide-react";
3
3
  import { useRef as w, useState as g, useEffect as y } from "react";
4
4
  import { cn as b } from "../../../lib/utils.js";
5
5
  import { Popover as z, PopoverTrigger as E, PopoverContent as T } from "../../ui/popover.js";
@@ -8,46 +8,47 @@ import { HuddleCameraButton as K } from "./HuddleCamera.js";
8
8
  import { useHuddleCollab as V, HuddleNotesButton as q } from "./HuddleCollab.js";
9
9
  import { HuddleInviteButton as G, HuddleInviteList as J } from "./HuddlePeoplePicker.js";
10
10
  import { HuddleStageTools as Q } from "./HuddleStageTools.js";
11
- import { raiseHand as X } from "./huddle-reactions.js";
12
- import { huddleShortcuts as Y } from "./huddle-shortcuts.js";
13
- import { formatElapsed as Z } from "./huddle-store.js";
14
- import { useHuddleSpeaking as _, useHuddleShortcuts as $ } from "./useHuddleAudio.js";
11
+ import { useCloseOnWindowBlur as X } from "./huddle-dismiss.js";
12
+ import { raiseHand as Y } from "./huddle-reactions.js";
13
+ import { huddleShortcuts as Z } from "./huddle-shortcuts.js";
14
+ import { formatElapsed as _ } from "./huddle-store.js";
15
+ import { useHuddleSpeaking as $, useHuddleShortcuts as ee } from "./useHuddleAudio.js";
15
16
  const k = "flex h-6 w-6 shrink-0 items-center justify-center rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-40", N = "text-slate-500 hover:bg-slate-200/70 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-white/10 dark:hover:text-slate-100", S = "bg-nvr-cyan/15 text-slate-900 dark:text-slate-100";
16
- function ee(s) {
17
- const [d, a] = g(0);
17
+ function te(s) {
18
+ const [d, n] = g(0);
18
19
  return y(() => {
19
20
  const o = s.current;
20
21
  if (!o || typeof ResizeObserver > "u") return;
21
- const r = new ResizeObserver(([t]) => a(Math.round(t.contentRect.width)));
22
+ const r = new ResizeObserver(([t]) => n(Math.round(t.contentRect.width)));
22
23
  return r.observe(o), () => r.disconnect();
23
24
  }, [s]), d;
24
25
  }
25
- function te({ since: s }) {
26
+ function ne({ since: s }) {
26
27
  const [, d] = g(0);
27
28
  return y(() => {
28
- const a = setInterval(() => d((o) => o + 1), 1e3);
29
- return () => clearInterval(a);
30
- }, []), s ? /* @__PURE__ */ e("span", { className: "tabular-nums text-slate-500 dark:text-slate-400", "data-huddle-elapsed": !0, children: Z(Date.now() - s) }) : null;
29
+ const n = setInterval(() => d((o) => o + 1), 1e3);
30
+ return () => clearInterval(n);
31
+ }, []), s ? /* @__PURE__ */ e("span", { className: "tabular-nums text-slate-500 dark:text-slate-400", "data-huddle-elapsed": !0, children: _(Date.now() - s) }) : null;
31
32
  }
32
33
  function v({
33
34
  icon: s,
34
35
  children: d,
35
- onClick: a,
36
+ onClick: n,
36
37
  disabled: o,
37
38
  active: r,
38
39
  tip: t,
39
- data: p
40
+ data: h
40
41
  }) {
41
42
  return /* @__PURE__ */ i(
42
43
  "button",
43
44
  {
44
45
  type: "button",
45
46
  role: "menuitem",
46
- onClick: a,
47
+ onClick: n,
47
48
  disabled: o,
48
49
  className: "flex min-h-8 w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted focus-visible:bg-muted focus-visible:outline-none disabled:opacity-50 disabled:hover:bg-transparent dark:text-slate-200",
49
50
  "data-tip": t,
50
- "data-huddle-menu": p,
51
+ "data-huddle-menu": h,
51
52
  children: [
52
53
  /* @__PURE__ */ e(
53
54
  "span",
@@ -67,31 +68,35 @@ function v({
67
68
  function ae({
68
69
  room: s,
69
70
  huddle: d,
70
- pip: a,
71
+ pip: n,
71
72
  fold: o,
72
73
  followAction: r,
73
74
  renderAvatar: t
74
75
  }) {
75
- const [p, u] = g(!1), [f, l] = g("menu"), h = w(!1), x = d.state.status === "joining", m = !!d.state.handAt, c = (n) => () => {
76
- u(!1), n();
76
+ const [h, c] = g(!1), [f, l] = g("menu");
77
+ X(h, () => {
78
+ c(!1), l("menu");
79
+ });
80
+ const m = w(!1), x = d.state.status === "joining", p = !!d.state.handAt, u = (a) => () => {
81
+ c(!1), a();
77
82
  };
78
83
  return /* @__PURE__ */ i(
79
84
  z,
80
85
  {
81
- open: p,
82
- onOpenChange: (n) => {
83
- u(n), n || l("menu");
86
+ open: h,
87
+ onOpenChange: (a) => {
88
+ c(a), a || l("menu");
84
89
  },
85
90
  children: [
86
91
  /* @__PURE__ */ e(E, { asChild: !0, children: /* @__PURE__ */ e(
87
92
  "button",
88
93
  {
89
94
  type: "button",
90
- className: b(k, p ? S : N),
95
+ className: b(k, h ? S : N),
91
96
  "aria-label": "More huddle actions",
92
97
  "data-tip": "More",
93
98
  "data-huddle-more": !0,
94
- children: /* @__PURE__ */ e(W, { className: "h-3.5 w-3.5", strokeWidth: 2 })
99
+ children: /* @__PURE__ */ e(P, { className: "h-3.5 w-3.5", strokeWidth: 2 })
95
100
  }
96
101
  ) }),
97
102
  /* @__PURE__ */ e(
@@ -102,8 +107,8 @@ function ae({
102
107
  "p-1",
103
108
  f === "invite" ? "w-[280px] max-w-[calc(100vw-16px)]" : "w-[232px]"
104
109
  ),
105
- onCloseAutoFocus: (n) => {
106
- h.current && (h.current = !1, n.preventDefault(), Y.setHelpOpen(!0));
110
+ onCloseAutoFocus: (a) => {
111
+ m.current && (m.current = !1, a.preventDefault(), Z.setHelpOpen(!0));
107
112
  },
108
113
  "data-huddle-more-menu": !0,
109
114
  children: f === "invite" ? /* @__PURE__ */ i("div", { children: [
@@ -124,7 +129,7 @@ function ae({
124
129
  {
125
130
  room: s,
126
131
  renderAvatar: t,
127
- onDone: () => u(!1)
132
+ onDone: () => c(!1)
128
133
  }
129
134
  )
130
135
  ] }) : /* @__PURE__ */ i("div", { role: "menu", "aria-label": "More huddle actions", className: "flex flex-col", children: [
@@ -133,18 +138,18 @@ function ae({
133
138
  v,
134
139
  {
135
140
  icon: /* @__PURE__ */ e(R, {}),
136
- onClick: c(() => X(!m)),
141
+ onClick: u(() => Y(!p)),
137
142
  disabled: x,
138
- active: m,
143
+ active: p,
139
144
  data: "hand",
140
- children: m ? "Lower your hand" : "Raise your hand"
145
+ children: p ? "Lower your hand" : "Raise your hand"
141
146
  }
142
147
  ),
143
148
  r && /* @__PURE__ */ e(
144
149
  v,
145
150
  {
146
151
  icon: /* @__PURE__ */ e(I, {}),
147
- onClick: c(r.run),
152
+ onClick: u(r.run),
148
153
  disabled: r.disabled,
149
154
  active: r.active,
150
155
  tip: r.tip,
@@ -152,15 +157,15 @@ function ae({
152
157
  children: r.label
153
158
  }
154
159
  ),
155
- a.supported && /* @__PURE__ */ e(
160
+ n.supported && /* @__PURE__ */ e(
156
161
  v,
157
162
  {
158
163
  icon: /* @__PURE__ */ e(A, {}),
159
- onClick: c(a.toggle),
160
- active: a.open,
161
- tip: a.open ? void 0 : "A small window that stays on top of other windows",
164
+ onClick: u(n.toggle),
165
+ active: n.open,
166
+ tip: n.open ? void 0 : "A small window that stays on top of other windows",
162
167
  data: "pip",
163
- children: a.open ? "Close the mini-player" : "Pop out a mini-player"
168
+ children: n.open ? "Close the mini-player" : "Pop out a mini-player"
164
169
  }
165
170
  ),
166
171
  /* @__PURE__ */ e(
@@ -168,7 +173,7 @@ function ae({
168
173
  {
169
174
  icon: /* @__PURE__ */ e(D, {}),
170
175
  onClick: () => {
171
- h.current = !0, u(!1);
176
+ m.current = !0, c(!1);
172
177
  },
173
178
  data: "shortcuts",
174
179
  children: /* @__PURE__ */ i("span", { className: "flex items-center justify-between gap-2", children: [
@@ -184,25 +189,25 @@ function ae({
184
189
  }
185
190
  );
186
191
  }
187
- function ve({
192
+ function ge({
188
193
  room: s,
189
194
  me: d,
190
- huddle: a,
195
+ huddle: n,
191
196
  pip: o,
192
197
  renderAvatar: r
193
198
  }) {
194
- const { state: t, support: p } = a, u = w(null), f = ee(u), l = f >= 460, h = f > 0 && f < 340, x = _(), { talking: m } = $(), c = V(s, a), n = t.status === "joining";
195
- return /* @__PURE__ */ i("div", { ref: u, className: "flex min-w-0 items-center gap-1.5 text-[11px]", "data-huddle-callbar": !0, children: [
199
+ const { state: t, support: h } = n, c = w(null), f = te(c), l = f >= 460, m = f > 0 && f < 340, x = $(), { talking: p } = ee(), u = V(s, n), a = t.status === "joining";
200
+ return /* @__PURE__ */ i("div", { ref: c, className: "flex min-w-0 items-center gap-1.5 text-[11px]", "data-huddle-callbar": !0, children: [
196
201
  /* @__PURE__ */ i(
197
202
  "span",
198
203
  {
199
204
  className: "inline-flex min-w-0 items-center gap-1 font-medium text-slate-700 dark:text-slate-200",
200
- "data-tip": l || n ? void 0 : "Huddle — time since it started",
205
+ "data-tip": l || a ? void 0 : "Huddle — time since it started",
201
206
  children: [
202
207
  /* @__PURE__ */ e(H, { className: "h-3.5 w-3.5 shrink-0 text-nvr-cyan", strokeWidth: 2, "aria-hidden": !0 }),
203
- n ? /* @__PURE__ */ e("span", { className: "truncate", children: "Connecting…" }) : /* @__PURE__ */ i(C, { children: [
208
+ a ? /* @__PURE__ */ e("span", { className: "truncate", children: "Connecting…" }) : /* @__PURE__ */ i(C, { children: [
204
209
  /* @__PURE__ */ e("span", { className: l ? void 0 : "sr-only", children: "Huddle" }),
205
- /* @__PURE__ */ e(te, { since: t.startedAt })
210
+ /* @__PURE__ */ e(ne, { since: t.startedAt })
206
211
  ] })
207
212
  ]
208
213
  }
@@ -220,50 +225,50 @@ function ve({
220
225
  "button",
221
226
  {
222
227
  type: "button",
223
- onClick: a.toggleMute,
224
- disabled: n,
228
+ onClick: n.toggleMute,
229
+ disabled: a,
225
230
  className: b(
226
231
  k,
227
- t.muted ? "bg-red-50 text-red-600 dark:bg-red-500/15 dark:text-red-300" : m || x.selfSpeaking ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300" : "text-slate-600 hover:bg-slate-200/70 dark:text-slate-300 dark:hover:bg-white/10"
232
+ t.muted ? "bg-red-50 text-red-600 dark:bg-red-500/15 dark:text-red-300" : p || x.selfSpeaking ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300" : "text-slate-600 hover:bg-slate-200/70 dark:text-slate-300 dark:hover:bg-white/10"
228
233
  ),
229
234
  "aria-pressed": t.muted,
230
235
  "aria-label": t.muted ? "Unmute microphone" : "Mute microphone",
231
- "data-tip": m ? "Talking — let go of Space to mute" : t.muted ? "Unmute (M)" : "Mute (M)",
236
+ "data-tip": p ? "Talking — let go of Space to mute" : t.muted ? "Unmute (M)" : "Mute (M)",
232
237
  "data-huddle-mute": t.muted ? "on" : "off",
233
- "data-huddle-ptt": m ? "on" : void 0,
238
+ "data-huddle-ptt": p ? "on" : void 0,
234
239
  children: t.muted ? /* @__PURE__ */ e(M, { className: "h-3.5 w-3.5", strokeWidth: 2 }) : /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5", strokeWidth: 2 })
235
240
  }
236
241
  ),
237
- !n && /* @__PURE__ */ e(U, { muted: t.muted, variant: "chevron" })
242
+ !a && /* @__PURE__ */ e(U, { muted: t.muted, variant: "chevron" })
238
243
  ] }),
239
- /* @__PURE__ */ e(K, { disabled: n }),
240
- p.screen && /* @__PURE__ */ e(
244
+ /* @__PURE__ */ e(K, { disabled: a }),
245
+ h.screen && /* @__PURE__ */ e(
241
246
  "button",
242
247
  {
243
248
  type: "button",
244
- onClick: a.toggleShare,
245
- disabled: n,
249
+ onClick: n.toggleShare,
250
+ disabled: a,
246
251
  className: b(k, t.sharing ? S : N),
247
252
  "aria-pressed": t.sharing,
248
253
  "aria-label": t.sharing ? "Stop sharing your screen" : "Share your screen",
249
254
  "data-tip": t.sharing ? "Stop sharing (Shift+S)" : "Share screen (Shift+S)",
250
255
  "data-huddle-share": t.sharing ? "on" : "off",
251
- children: /* @__PURE__ */ e(L, { className: "h-3.5 w-3.5", strokeWidth: 2 })
256
+ children: /* @__PURE__ */ e(W, { className: "h-3.5 w-3.5", strokeWidth: 2 })
252
257
  }
253
258
  ),
254
259
  /* @__PURE__ */ e("span", { className: "mx-1 h-3.5 w-px bg-slate-200 dark:bg-border", "aria-hidden": !0 }),
255
- /* @__PURE__ */ i(Q, { me: d, handAt: t.handAt, disabled: n, showHand: !h, children: [
256
- c.live && /* @__PURE__ */ e(q, { open: c.notes.open, unseen: c.notes.unseen }),
257
- !h && !n && /* @__PURE__ */ e(G, { room: s, renderAvatar: r })
260
+ /* @__PURE__ */ i(Q, { me: d, handAt: t.handAt, disabled: a, showHand: !m, children: [
261
+ u.live && /* @__PURE__ */ e(q, { open: u.notes.open, unseen: u.notes.unseen }),
262
+ !m && !a && /* @__PURE__ */ e(G, { room: s, renderAvatar: r })
258
263
  ] }),
259
264
  /* @__PURE__ */ e(
260
265
  ae,
261
266
  {
262
267
  room: s,
263
- huddle: a,
268
+ huddle: n,
264
269
  pip: o,
265
- fold: h,
266
- followAction: c.followAction,
270
+ fold: m,
271
+ followAction: u.followAction,
267
272
  renderAvatar: r
268
273
  }
269
274
  ),
@@ -272,7 +277,7 @@ function ve({
272
277
  "button",
273
278
  {
274
279
  type: "button",
275
- onClick: a.leave,
280
+ onClick: n.leave,
276
281
  className: b(
277
282
  "ml-1 flex h-6 shrink-0 items-center justify-center gap-1 rounded bg-red-50 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:bg-red-500/15 dark:text-red-300 dark:hover:bg-red-500/25",
278
283
  l ? "px-2" : "w-7"
@@ -281,7 +286,7 @@ function ve({
281
286
  "data-tip": l ? "Leave (L)" : "Leave the huddle (L)",
282
287
  "data-huddle-leave": !0,
283
288
  children: [
284
- /* @__PURE__ */ e(P, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
289
+ /* @__PURE__ */ e(L, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
285
290
  l && "Leave"
286
291
  ]
287
292
  }
@@ -292,5 +297,5 @@ function ve({
292
297
  ] });
293
298
  }
294
299
  export {
295
- ve as HuddleCallBar
300
+ ge as HuddleCallBar
296
301
  };
@@ -6,31 +6,32 @@ import { toast as C } from "sonner";
6
6
  import { useNivaroClient as w } from "../../../context.js";
7
7
  import { get as H } from "../../../lib/commands.js";
8
8
  import { cn as h } from "../../../lib/utils.js";
9
- import { Command as P, CommandInput as T, CommandList as I, CommandEmpty as S, CommandGroup as j, CommandItem as L } from "../../ui/command.js";
10
- import { Popover as W, PopoverTrigger as q, PopoverContent as D } from "../../ui/popover.js";
9
+ import { Command as P, CommandInput as T, CommandList as I, CommandEmpty as S, CommandGroup as W, CommandItem as j } from "../../ui/command.js";
10
+ import { Popover as L, PopoverTrigger as q, PopoverContent as D } from "../../ui/popover.js";
11
11
  import { huddleCalls as E } from "./huddle-calls.js";
12
- function A(a, n, r = !0) {
13
- const l = w(), [o, m] = u(n);
12
+ import { useCloseOnWindowBlur as O } from "./huddle-dismiss.js";
13
+ function A(a, l, o = !0) {
14
+ const n = w(), [r, m] = u(l);
14
15
  return N(() => {
15
- const s = setTimeout(() => m(n), 180);
16
+ const s = setTimeout(() => m(l), 180);
16
17
  return () => clearTimeout(s);
17
- }, [n]), v({
18
- queryKey: ["nvr-huddle-people", a, o],
19
- queryFn: () => l.request(
20
- H("/chat/huddle/people", { room: a, q: o })
18
+ }, [l]), v({
19
+ queryKey: ["nvr-huddle-people", a, r],
20
+ queryFn: () => n.request(
21
+ H("/chat/huddle/people", { room: a, q: r })
21
22
  ).then((s) => s.data),
22
- enabled: r && !!a,
23
+ enabled: o && !!a,
23
24
  staleTime: 2e4,
24
25
  placeholderData: (s) => s
25
26
  });
26
27
  }
27
- const F = "flex items-center gap-2 rounded-md px-2 py-1.5 text-[12.5px] text-slate-700 aria-selected:bg-muted dark:text-slate-200";
28
- function O({
28
+ const B = "flex items-center gap-2 rounded-md px-2 py-1.5 text-[12.5px] text-slate-700 aria-selected:bg-muted dark:text-slate-200";
29
+ function F({
29
30
  room: a,
30
- selected: n,
31
- onPick: r,
32
- renderAvatar: l,
33
- placeholder: o = "Search people…",
31
+ selected: l,
32
+ onPick: o,
33
+ renderAvatar: n,
34
+ placeholder: r = "Search people…",
34
35
  excludeInHuddle: m
35
36
  }) {
36
37
  const [s, p] = u(""), { data: d, isLoading: x, isError: f } = A(a, s);
@@ -40,7 +41,7 @@ function O({
40
41
  {
41
42
  value: s,
42
43
  onValueChange: p,
43
- placeholder: o,
44
+ placeholder: r,
44
45
  className: "h-8 text-[12.5px]"
45
46
  }
46
47
  ),
@@ -48,18 +49,18 @@ function O({
48
49
  x && !d && /* @__PURE__ */ e("div", { className: "space-y-1.5 p-2", "aria-busy": "true", children: [0, 1, 2].map((t) => /* @__PURE__ */ e("div", { className: "h-7 animate-pulse rounded-md bg-slate-100 dark:bg-white/5" }, t)) }),
49
50
  f && /* @__PURE__ */ e("p", { className: "px-2 py-3 text-[11.5px] text-red-600 dark:text-red-300", children: "Could not load people. Try again in a moment." }),
50
51
  d && d.length === 0 && /* @__PURE__ */ e(S, { className: "py-4 text-[11.5px] text-slate-500 dark:text-slate-400", children: s ? "Nobody with that name can see this room." : "Nobody else can see this room." }),
51
- d && d.length > 0 && /* @__PURE__ */ e(j, { children: d.map((t) => {
52
- const c = !!m && t.in_huddle, g = n.has(t.id.toUpperCase());
52
+ d && d.length > 0 && /* @__PURE__ */ e(W, { children: d.map((t) => {
53
+ const c = !!m && t.in_huddle, g = l.has(t.id.toUpperCase());
53
54
  return /* @__PURE__ */ i(
54
- L,
55
+ j,
55
56
  {
56
57
  value: t.id,
57
58
  disabled: c,
58
- onSelect: () => !c && r(t),
59
- className: h(F, c && "opacity-50"),
59
+ onSelect: () => !c && o(t),
60
+ className: h(B, c && "opacity-50"),
60
61
  "data-huddle-person-row": t.id,
61
62
  children: [
62
- /* @__PURE__ */ e("span", { style: { lineHeight: 0 }, children: l(t.id, t.name) }),
63
+ /* @__PURE__ */ e("span", { style: { lineHeight: 0 }, children: n(t.id, t.name) }),
63
64
  /* @__PURE__ */ i("span", { className: "min-w-0 flex-1", children: [
64
65
  /* @__PURE__ */ e("span", { className: "block truncate", children: t.name }),
65
66
  t.title && /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-500 dark:text-slate-400", children: t.title })
@@ -85,38 +86,38 @@ function O({
85
86
  }
86
87
  function Q({
87
88
  room: a,
88
- renderAvatar: n,
89
- onDone: r
89
+ renderAvatar: l,
90
+ onDone: o
90
91
  }) {
91
92
  return /* @__PURE__ */ e(
92
- O,
93
+ F,
93
94
  {
94
95
  room: a,
95
96
  selected: /* @__PURE__ */ new Set(),
96
97
  excludeInHuddle: !0,
97
- renderAvatar: n,
98
+ renderAvatar: l,
98
99
  placeholder: "Who should join?",
99
- onPick: (l) => {
100
- E.invite(a, [l.id]), C(`Ringing ${l.name}`, { description: "They get a call and a notification." }), r();
100
+ onPick: (n) => {
101
+ E.invite(a, [n.id]), C(`Ringing ${n.name}`, { description: "They get a call and a notification." }), o();
101
102
  }
102
103
  }
103
104
  );
104
105
  }
105
- function X({
106
+ function Z({
106
107
  room: a,
107
- renderAvatar: n,
108
- className: r
108
+ renderAvatar: l,
109
+ className: o
109
110
  }) {
110
- const [l, o] = u(!1);
111
- return /* @__PURE__ */ i(W, { open: l, onOpenChange: o, children: [
111
+ const [n, r] = u(!1);
112
+ return O(n, () => r(!1)), /* @__PURE__ */ i(L, { open: n, onOpenChange: r, children: [
112
113
  /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
113
114
  "button",
114
115
  {
115
116
  type: "button",
116
117
  className: h(
117
118
  "flex h-6 w-6 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-200/70 hover:text-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-slate-400 dark:hover:bg-white/10 dark:hover:text-slate-100",
118
- l && "bg-slate-200/70 text-slate-800 dark:bg-white/10 dark:text-slate-100",
119
- r
119
+ n && "bg-slate-200/70 text-slate-800 dark:bg-white/10 dark:text-slate-100",
120
+ o
120
121
  ),
121
122
  "aria-label": "Add people to the huddle",
122
123
  "data-tip": "Add people — they get a call",
@@ -130,14 +131,14 @@ function X({
130
131
  align: "end",
131
132
  className: "w-[280px] max-w-[calc(100vw-16px)] p-1",
132
133
  "data-huddle-invite-picker": !0,
133
- children: /* @__PURE__ */ e(Q, { room: a, renderAvatar: n, onDone: () => o(!1) })
134
+ children: /* @__PURE__ */ e(Q, { room: a, renderAvatar: l, onDone: () => r(!1) })
134
135
  }
135
136
  )
136
137
  ] });
137
138
  }
138
139
  export {
139
- X as HuddleInviteButton,
140
+ Z as HuddleInviteButton,
140
141
  Q as HuddleInviteList,
141
- O as HuddlePeopleList,
142
+ F as HuddlePeopleList,
142
143
  A as useHuddlePeople
143
144
  };
@@ -1,27 +1,30 @@
1
1
  import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
2
  import { Hand as b, X as g, VideoOff as k, SmilePlus as w } from "lucide-react";
3
3
  import { useMemo as N, useSyncExternalStore as v, useState as S } from "react";
4
- import { cn as m } from "../../../lib/utils.js";
4
+ import { cn as h } from "../../../lib/utils.js";
5
5
  import { Popover as C, PopoverTrigger as H, PopoverContent as R } from "../../ui/popover.js";
6
6
  import { cameraStore as u } from "./huddle-camera.js";
7
- import { handQueue as j, raiseHand as y, lowerAllHands as L, reactionFeed as h, HUDDLE_REACTIONS as E, REACTION_LIFE_MS as W } from "./huddle-reactions.js";
8
- const p = "flex h-6 w-6 shrink-0 items-center justify-center rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-40", f = "text-slate-500 hover:bg-slate-200/70 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-white/10 dark:hover:text-slate-100", x = "bg-nvr-cyan/15 text-slate-900 dark:text-slate-100";
9
- function I({
7
+ import { useCloseOnWindowBlur as j } from "./huddle-dismiss.js";
8
+ import { handQueue as L, raiseHand as y, lowerAllHands as W, reactionFeed as m, HUDDLE_REACTIONS as E, REACTION_LIFE_MS as O } from "./huddle-reactions.js";
9
+ const f = "flex h-6 w-6 shrink-0 items-center justify-center rounded transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:opacity-40", p = "text-slate-500 hover:bg-slate-200/70 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-white/10 dark:hover:text-slate-100", x = "bg-nvr-cyan/15 text-slate-900 dark:text-slate-100";
10
+ function _({
10
11
  me: a,
11
12
  handAt: s,
12
13
  disabled: t,
13
14
  showHand: n = !0,
14
15
  children: r
15
16
  }) {
16
- const [i, c] = S(!1), l = !!s;
17
+ const [i, d] = S(!1);
18
+ j(i, () => d(!1));
19
+ const l = !!s;
17
20
  return /* @__PURE__ */ o("div", { className: "flex items-center gap-0.5", "data-huddle-stage-tools": !0, children: [
18
- /* @__PURE__ */ o(C, { open: i, onOpenChange: c, children: [
21
+ /* @__PURE__ */ o(C, { open: i, onOpenChange: d, children: [
19
22
  /* @__PURE__ */ e(H, { asChild: !0, children: /* @__PURE__ */ e(
20
23
  "button",
21
24
  {
22
25
  type: "button",
23
26
  disabled: t,
24
- className: m(p, i ? x : f),
27
+ className: h(f, i ? x : p),
25
28
  "aria-label": "React",
26
29
  "data-tip": i ? void 0 : "React — everyone in the huddle sees it",
27
30
  "data-huddle-react": !0,
@@ -30,16 +33,16 @@ function I({
30
33
  ) }),
31
34
  /* @__PURE__ */ e(R, { side: "bottom", align: "center", className: "w-auto p-1", "data-huddle-reactions": !0, children: /* @__PURE__ */ o("fieldset", { className: "m-0 flex min-w-0 items-center gap-0.5 border-0 p-0", children: [
32
35
  /* @__PURE__ */ e("legend", { className: "sr-only", children: "Send a reaction" }),
33
- E.map((d) => /* @__PURE__ */ e(
36
+ E.map((c) => /* @__PURE__ */ e(
34
37
  "button",
35
38
  {
36
39
  type: "button",
37
- onClick: () => a && h.send(d, a.id),
40
+ onClick: () => a && m.send(c, a.id),
38
41
  className: "flex h-8 w-8 items-center justify-center rounded-md text-[17px] leading-none transition-transform hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan active:scale-90",
39
- "aria-label": `React ${d}`,
40
- children: d
42
+ "aria-label": `React ${c}`,
43
+ children: c
41
44
  },
42
- d
45
+ c
43
46
  ))
44
47
  ] }) })
45
48
  ] }),
@@ -49,7 +52,7 @@ function I({
49
52
  type: "button",
50
53
  onClick: () => y(!l),
51
54
  disabled: t,
52
- className: m(p, l ? x : f),
55
+ className: h(f, l ? x : p),
53
56
  "aria-pressed": l,
54
57
  "aria-label": l ? "Lower your hand" : "Raise your hand",
55
58
  "data-tip": l ? "Lower hand" : "Raise hand — you join the queue",
@@ -60,8 +63,8 @@ function I({
60
63
  r
61
64
  ] });
62
65
  }
63
- function M({ roster: a, self: s }) {
64
- const t = N(() => j(a), [a]);
66
+ function q({ roster: a, self: s }) {
67
+ const t = N(() => L(a), [a]);
65
68
  return t.length ? /* @__PURE__ */ o(
66
69
  "div",
67
70
  {
@@ -95,7 +98,7 @@ function M({ roster: a, self: s }) {
95
98
  "button",
96
99
  {
97
100
  type: "button",
98
- onClick: () => L(),
101
+ onClick: () => W(),
99
102
  className: "rounded px-1.5 py-0.5 font-medium text-slate-500 transition-colors hover:bg-slate-200/70 hover:text-slate-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:text-slate-400 dark:hover:bg-white/10 dark:hover:text-slate-100",
100
103
  "data-huddle-lower-all": !0,
101
104
  children: "Lower all"
@@ -105,7 +108,7 @@ function M({ roster: a, self: s }) {
105
108
  }
106
109
  ) : null;
107
110
  }
108
- function O({ r: a, name: s }) {
111
+ function P({ r: a, name: s }) {
109
112
  return /* @__PURE__ */ e("span", { className: "absolute bottom-1 -translate-x-1/2", style: { left: `${a.lane * 100}%` }, children: /* @__PURE__ */ o(
110
113
  "span",
111
114
  {
@@ -128,7 +131,7 @@ function O({ r: a, name: s }) {
128
131
  { transform: "translateY(-104px) scale(1)", opacity: 0 }
129
132
  ],
130
133
  {
131
- duration: W,
134
+ duration: O,
132
135
  easing: n ? "linear" : "cubic-bezier(0.16, 1, 0.3, 1)",
133
136
  fill: "forwards"
134
137
  }
@@ -142,15 +145,15 @@ function O({ r: a, name: s }) {
142
145
  }
143
146
  ) });
144
147
  }
145
- function _({
148
+ function z({
146
149
  roster: a,
147
150
  me: s
148
151
  }) {
149
- const t = v(h.subscribe, h.getSnapshot);
152
+ const t = v(m.subscribe, m.getSnapshot);
150
153
  if (!t.length) return null;
151
154
  const n = (r) => {
152
155
  var i;
153
- return r === (s == null ? void 0 : s.id) ? "You" : ((i = a.find((c) => c.user === r)) == null ? void 0 : i.name) ?? "Someone";
156
+ return r === (s == null ? void 0 : s.id) ? "You" : ((i = a.find((d) => d.user === r)) == null ? void 0 : i.name) ?? "Someone";
154
157
  };
155
158
  return /* @__PURE__ */ o(
156
159
  "div",
@@ -159,13 +162,13 @@ function _({
159
162
  "aria-live": "polite",
160
163
  "data-huddle-reaction-layer": !0,
161
164
  children: [
162
- t.map((r) => /* @__PURE__ */ e(O, { r, name: n(r.user) }, r.id)),
165
+ t.map((r) => /* @__PURE__ */ e(P, { r, name: n(r.user) }, r.id)),
163
166
  /* @__PURE__ */ e("span", { className: "sr-only", children: t.length ? `${n(t[t.length - 1].user)} reacted ${t[t.length - 1].emoji}` : "" })
164
167
  ]
165
168
  }
166
169
  );
167
170
  }
168
- function q() {
171
+ function B() {
169
172
  const a = v(u.subscribe, u.getSnapshot);
170
173
  return a.error ? /* @__PURE__ */ o(
171
174
  "div",
@@ -190,8 +193,8 @@ function q() {
190
193
  ) : null;
191
194
  }
192
195
  export {
193
- q as HuddleCameraNotice,
194
- M as HuddleHands,
195
- _ as HuddleReactionLayer,
196
- I as HuddleStageTools
196
+ B as HuddleCameraNotice,
197
+ q as HuddleHands,
198
+ z as HuddleReactionLayer,
199
+ _ as HuddleStageTools
197
200
  };
@@ -0,0 +1,12 @@
1
+ import { useRef as o, useEffect as u } from "react";
2
+ function f(e, n) {
3
+ const r = o(n);
4
+ r.current = n, u(() => {
5
+ if (!e || typeof window > "u") return;
6
+ const t = () => r.current();
7
+ return window.addEventListener("blur", t), () => window.removeEventListener("blur", t);
8
+ }, [e]);
9
+ }
10
+ export {
11
+ f as useCloseOnWindowBlur
12
+ };
@@ -4,7 +4,7 @@ var c = (h, t, e) => w(h, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { micConstraints as y, loadDevicePrefs as T } from "./huddle-device-prefs.js";
5
5
  import { huddleLive as M } from "./huddle-live.js";
6
6
  import { aggregateQuality as b } from "./huddle-quality.js";
7
- import { SfuSession as L, MESH_OVERLAP_MS as A } from "./huddle-sfu.js";
7
+ import { SfuSession as A, MESH_OVERLAP_MS as L } from "./huddle-sfu.js";
8
8
  const p = {
9
9
  room: null,
10
10
  status: "idle",
@@ -18,8 +18,13 @@ const p = {
18
18
  mode: "mesh",
19
19
  micLabel: null,
20
20
  handAt: null
21
- }, V = 15e3;
22
- function O(h, t) {
21
+ }, O = 15e3, V = {
22
+ video: { frameRate: 15, width: { ideal: 1920 }, height: { ideal: 1080 } },
23
+ audio: !1,
24
+ selfBrowserSurface: "include",
25
+ surfaceSwitching: "include"
26
+ };
27
+ function C(h, t) {
23
28
  return h < t;
24
29
  }
25
30
  function g(h, t, e) {
@@ -31,15 +36,15 @@ function g(h, t, e) {
31
36
  }
32
37
  return s;
33
38
  }
34
- function R(h) {
39
+ function $(h) {
35
40
  const t = h.map((e) => e.name || "Someone");
36
41
  return t.length === 0 ? "" : t.length === 1 ? t[0] : t.length === 2 ? `${t[0]} and ${t[1]}` : `${t[0]}, ${t[1]} and ${t.length - 2} other${t.length - 2 === 1 ? "" : "s"}`;
37
42
  }
38
- function $(h) {
43
+ function q(h) {
39
44
  const t = Math.max(0, Math.floor(h / 1e3)), e = Math.floor(t / 60), s = Math.floor(e / 60), i = String(e % 60).padStart(2, "0"), o = String(t % 60).padStart(2, "0");
40
45
  return s ? `${s}:${i}:${o}` : `${e}:${o}`;
41
46
  }
42
- class C {
47
+ class I {
43
48
  constructor() {
44
49
  c(this, "state", p);
45
50
  c(this, "listeners", /* @__PURE__ */ new Set());
@@ -112,7 +117,7 @@ class C {
112
117
  // ── Transport ─────────────────────────────────────────────────────────────
113
118
  /** Bind the host's socket adapter once; later calls with the same adapter are no-ops. */
114
119
  attach(t, e, s) {
115
- if (this.fetchIce = e, this.fetchSfu = s ?? null, this.transport !== t) {
120
+ if (this.fetchIce = e, s && (this.fetchSfu = s), this.transport !== t) {
116
121
  for (const i of this.offs) i();
117
122
  this.transport = t, M.attach(t), this.offs = [
118
123
  t.on("huddle:peers", (i) => this.onPeers(i)),
@@ -230,7 +235,7 @@ class C {
230
235
  this.ping && clearInterval(this.ping), this.ping = setInterval(() => {
231
236
  var n;
232
237
  this.state.room && ((n = this.transport) == null || n.emit("huddle:ping", { room: this.state.room }));
233
- }, V), (this.state.muted || this.state.sharing) && ((r = this.transport) == null || r.emit("huddle:state", {
238
+ }, O), (this.state.muted || this.state.sharing) && ((r = this.transport) == null || r.emit("huddle:state", {
234
239
  room: t.room,
235
240
  muted: this.state.muted,
236
241
  screen: this.state.sharing
@@ -287,7 +292,7 @@ class C {
287
292
  let i;
288
293
  try {
289
294
  const f = await this.fetchSfu(e, s);
290
- if (this.state.room !== e || this.state.self !== s || (i = new L(), this.sfu = i, await i.connect(f, {
295
+ if (this.state.room !== e || this.state.self !== s || (i = new A(), this.sfu = i, await i.connect(f, {
291
296
  onTrack: (a, d, v) => this.onSfuTrack(a, d, v),
292
297
  onTrackEnd: (a, d) => this.onSfuTrackEnd(a, d),
293
298
  onReconnecting: () => {
@@ -315,7 +320,7 @@ class C {
315
320
  });
316
321
  return;
317
322
  }
318
- this.meshCloseTimer && clearTimeout(this.meshCloseTimer), this.meshCloseTimer = setTimeout(() => this.closeMeshLinks(), A);
323
+ this.meshCloseTimer && clearTimeout(this.meshCloseTimer), this.meshCloseTimer = setTimeout(() => this.closeMeshLinks(), L);
319
324
  }
320
325
  /** The SFU's labelled video for a peer (#2858): camera tile and shared screen, apart. */
321
326
  sfuVideoOf(t) {
@@ -372,6 +377,8 @@ class C {
372
377
  off: "Huddles are turned off on this instance.",
373
378
  "no-dm": "Huddles run in channels and record rooms.",
374
379
  "not-signed-in": "Sign in again to join.",
380
+ // One seat per person: joining from another window or app moves you there.
381
+ moved: "You joined this huddle from another window, so it ended here.",
375
382
  unavailable: "The huddle service is unavailable right now."
376
383
  };
377
384
  this.teardown(), this.set({
@@ -399,7 +406,7 @@ class C {
399
406
  if (this.links.has(t)) return this.links.get(t) ?? null;
400
407
  const r = new RTCPeerConnection({ iceServers: o }), l = {
401
408
  pc: r,
402
- polite: O(s, t),
409
+ polite: C(s, t),
403
410
  makingOffer: !1,
404
411
  ignoreOffer: !1,
405
412
  screenSender: null,
@@ -504,10 +511,7 @@ class C {
504
511
  if (this.state.status !== "live" || this.state.sharing) return;
505
512
  let t;
506
513
  try {
507
- t = await navigator.mediaDevices.getDisplayMedia({
508
- video: { frameRate: 15, width: { ideal: 1920 }, height: { ideal: 1080 } },
509
- audio: !1
510
- });
514
+ t = await navigator.mediaDevices.getDisplayMedia(V);
511
515
  } catch {
512
516
  return;
513
517
  }
@@ -596,7 +600,7 @@ async function k(h, t) {
596
600
  const e = h;
597
601
  typeof e.setSinkId == "function" && await e.setSinkId(t).catch(() => null);
598
602
  }
599
- const q = new C();
603
+ const N = new I();
600
604
  function F() {
601
605
  if (typeof navigator > "u" || typeof window > "u")
602
606
  return { audio: !1, screen: !1 };
@@ -607,10 +611,11 @@ function F() {
607
611
  };
608
612
  }
609
613
  export {
610
- $ as formatElapsed,
611
- q as huddleStore,
614
+ V as SCREEN_SHARE_OPTIONS,
615
+ q as formatElapsed,
616
+ N as huddleStore,
612
617
  F as huddleSupport,
613
618
  g as mergeRoster,
614
- R as peerSummary,
615
- O as politeFor
619
+ $ as peerSummary,
620
+ C as politeFor
616
621
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",