@nivaro/react 0.2.55 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/components/slots/TasksSlot.js +31 -29
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +101 -1
  5. package/dist/index.js +538 -525
  6. package/dist/shared/components/ItemEditForm.js +666 -658
  7. package/dist/shared/components/MyWorkView.js +47 -37
  8. package/dist/shared/components/ProfileView.js +163 -144
  9. package/dist/shared/components/ai/AiPlanCard.js +427 -0
  10. package/dist/shared/components/ai/AiPlanChanges.js +117 -0
  11. package/dist/shared/components/ai/TaskDo.js +1022 -0
  12. package/dist/shared/components/chat/ChatAnalyticsView.js +19 -17
  13. package/dist/shared/components/chat/ChatPanel.js +1356 -1317
  14. package/dist/shared/components/chat/HuddleAnalyticsTab.js +198 -0
  15. package/dist/shared/components/chat/RoomHeaderMenu.js +78 -65
  16. package/dist/shared/components/chat/chat-core.js +273 -264
  17. package/dist/shared/components/chat/huddle/HuddleAudioUi.js +397 -0
  18. package/dist/shared/components/chat/huddle/HuddleCallBar.js +296 -0
  19. package/dist/shared/components/chat/huddle/HuddleCallLayer.js +180 -0
  20. package/dist/shared/components/chat/huddle/HuddleCamera.js +124 -0
  21. package/dist/shared/components/chat/huddle/HuddleCollab.js +320 -0
  22. package/dist/shared/components/chat/huddle/HuddleControls.js +82 -121
  23. package/dist/shared/components/chat/huddle/HuddleDraw.js +231 -0
  24. package/dist/shared/components/chat/huddle/HuddleLiveBadge.js +52 -0
  25. package/dist/shared/components/chat/huddle/HuddlePeoplePicker.js +143 -0
  26. package/dist/shared/components/chat/huddle/HuddleScheduleCard.js +190 -0
  27. package/dist/shared/components/chat/huddle/HuddleScheduleForm.js +188 -0
  28. package/dist/shared/components/chat/huddle/HuddleStage.js +184 -89
  29. package/dist/shared/components/chat/huddle/HuddleStageTools.js +197 -0
  30. package/dist/shared/components/chat/huddle/huddle-audio-logic.js +156 -0
  31. package/dist/shared/components/chat/huddle/huddle-audio.js +69 -0
  32. package/dist/shared/components/chat/huddle/huddle-calls.js +129 -0
  33. package/dist/shared/components/chat/huddle/huddle-camera.js +143 -0
  34. package/dist/shared/components/chat/huddle/huddle-collab-store.js +391 -0
  35. package/dist/shared/components/chat/huddle/huddle-device-prefs.js +55 -0
  36. package/dist/shared/components/chat/huddle/huddle-devices.js +99 -0
  37. package/dist/shared/components/chat/huddle/huddle-draw.js +226 -0
  38. package/dist/shared/components/chat/huddle/huddle-follow-bus.js +96 -0
  39. package/dist/shared/components/chat/huddle/huddle-hold.js +62 -0
  40. package/dist/shared/components/chat/huddle/huddle-link-quality.js +159 -0
  41. package/dist/shared/components/chat/huddle/huddle-live.js +82 -0
  42. package/dist/shared/components/chat/huddle/huddle-pip.js +343 -0
  43. package/dist/shared/components/chat/huddle/huddle-quality.js +22 -0
  44. package/dist/shared/components/chat/huddle/huddle-reactions.js +71 -0
  45. package/dist/shared/components/chat/huddle/huddle-ring-refused.js +34 -0
  46. package/dist/shared/components/chat/huddle/huddle-schedule.js +102 -0
  47. package/dist/shared/components/chat/huddle/huddle-sfu.js +176 -0
  48. package/dist/shared/components/chat/huddle/huddle-shortcuts.js +91 -0
  49. package/dist/shared/components/chat/huddle/huddle-speaking.js +100 -0
  50. package/dist/shared/components/chat/huddle/huddle-store.js +431 -157
  51. package/dist/shared/components/chat/huddle/useHuddle.js +46 -38
  52. package/dist/shared/components/chat/huddle/useHuddleAudio.js +35 -0
  53. package/dist/shared/components/item-edit/GroupSection.js +1 -0
  54. package/dist/shared/components/item-edit/RecordChatActions.js +68 -59
  55. package/dist/shared/components/item-edit/UserChip.js +145 -142
  56. package/dist/shared/components/panels/TaskPanel.js +51 -49
  57. package/dist/shared/components/support/TicketDetailSheet.js +57 -42
  58. package/dist/shared/lib/notification-sound.js +25 -16
  59. package/dist/shared/lib/stale-chunk.js +60 -0
  60. package/package.json +2 -1
@@ -0,0 +1,197 @@
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import { Hand as b, X as g, VideoOff as k, SmilePlus as w } from "lucide-react";
3
+ import { useMemo as N, useSyncExternalStore as v, useState as S } from "react";
4
+ import { cn as m } from "../../../lib/utils.js";
5
+ import { Popover as C, PopoverTrigger as H, PopoverContent as R } from "../../ui/popover.js";
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({
10
+ me: a,
11
+ handAt: s,
12
+ disabled: t,
13
+ showHand: n = !0,
14
+ children: r
15
+ }) {
16
+ const [i, c] = S(!1), l = !!s;
17
+ 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: [
19
+ /* @__PURE__ */ e(H, { asChild: !0, children: /* @__PURE__ */ e(
20
+ "button",
21
+ {
22
+ type: "button",
23
+ disabled: t,
24
+ className: m(p, i ? x : f),
25
+ "aria-label": "React",
26
+ "data-tip": i ? void 0 : "React — everyone in the huddle sees it",
27
+ "data-huddle-react": !0,
28
+ children: /* @__PURE__ */ e(w, { className: "h-3.5 w-3.5", strokeWidth: 2 })
29
+ }
30
+ ) }),
31
+ /* @__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
+ /* @__PURE__ */ e("legend", { className: "sr-only", children: "Send a reaction" }),
33
+ E.map((d) => /* @__PURE__ */ e(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ onClick: () => a && h.send(d, a.id),
38
+ 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
41
+ },
42
+ d
43
+ ))
44
+ ] }) })
45
+ ] }),
46
+ n && /* @__PURE__ */ e(
47
+ "button",
48
+ {
49
+ type: "button",
50
+ onClick: () => y(!l),
51
+ disabled: t,
52
+ className: m(p, l ? x : f),
53
+ "aria-pressed": l,
54
+ "aria-label": l ? "Lower your hand" : "Raise your hand",
55
+ "data-tip": l ? "Lower hand" : "Raise hand — you join the queue",
56
+ "data-huddle-hand": l ? "up" : "down",
57
+ children: /* @__PURE__ */ e(b, { className: "h-3.5 w-3.5", strokeWidth: 2 })
58
+ }
59
+ ),
60
+ r
61
+ ] });
62
+ }
63
+ function M({ roster: a, self: s }) {
64
+ const t = N(() => j(a), [a]);
65
+ return t.length ? /* @__PURE__ */ o(
66
+ "div",
67
+ {
68
+ className: "mt-1 flex flex-wrap items-center gap-1 text-[11px] text-slate-600 dark:text-slate-300",
69
+ "data-huddle-hands": !0,
70
+ children: [
71
+ /* @__PURE__ */ e(b, { className: "h-3 w-3 text-slate-500 dark:text-slate-400", strokeWidth: 2, "aria-hidden": !0 }),
72
+ /* @__PURE__ */ e("span", { className: "font-medium", children: "Hands up" }),
73
+ /* @__PURE__ */ e("ol", { className: "m-0 flex list-none flex-wrap items-center gap-1 p-0", children: t.map((n, r) => /* @__PURE__ */ o(
74
+ "li",
75
+ {
76
+ className: "inline-flex h-5 items-center gap-1 rounded-full bg-white pl-1 pr-2 ring-1 ring-slate-200 dark:bg-card dark:ring-border",
77
+ children: [
78
+ /* @__PURE__ */ e("span", { className: "flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-slate-100 px-1 text-[9.5px] font-semibold tabular-nums text-slate-600 dark:bg-muted dark:text-slate-300", children: r + 1 }),
79
+ /* @__PURE__ */ e("span", { className: "max-w-[120px] truncate", children: n.socket === s ? "You" : n.name ?? "Someone" }),
80
+ n.socket === s && /* @__PURE__ */ e(
81
+ "button",
82
+ {
83
+ type: "button",
84
+ onClick: () => y(!1),
85
+ className: "-mr-1 flex h-4 w-4 items-center justify-center rounded-full text-slate-400 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:hover:bg-white/10 dark:hover:text-slate-100",
86
+ "aria-label": "Lower your hand",
87
+ children: /* @__PURE__ */ e(g, { className: "h-2.5 w-2.5", strokeWidth: 2.5 })
88
+ }
89
+ )
90
+ ]
91
+ },
92
+ n.socket
93
+ )) }),
94
+ t.length > 0 && /* @__PURE__ */ e(
95
+ "button",
96
+ {
97
+ type: "button",
98
+ onClick: () => L(),
99
+ 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
+ "data-huddle-lower-all": !0,
101
+ children: "Lower all"
102
+ }
103
+ )
104
+ ]
105
+ }
106
+ ) : null;
107
+ }
108
+ function O({ r: a, name: s }) {
109
+ return /* @__PURE__ */ e("span", { className: "absolute bottom-1 -translate-x-1/2", style: { left: `${a.lane * 100}%` }, children: /* @__PURE__ */ o(
110
+ "span",
111
+ {
112
+ ref: (t) => {
113
+ var r, i;
114
+ if (!t || t.dataset.started) return;
115
+ t.dataset.started = "1";
116
+ const n = typeof window < "u" && ((r = window.matchMedia) == null ? void 0 : r.call(window, "(prefers-reduced-motion: reduce)").matches);
117
+ (i = t.animate) == null || i.call(
118
+ t,
119
+ n ? [
120
+ { opacity: 0 },
121
+ { opacity: 1, offset: 0.1 },
122
+ { opacity: 1, offset: 0.7 },
123
+ { opacity: 0 }
124
+ ] : [
125
+ { transform: "translateY(0) scale(0.7)", opacity: 0 },
126
+ { transform: "translateY(-14px) scale(1)", opacity: 1, offset: 0.12 },
127
+ { opacity: 1, offset: 0.6 },
128
+ { transform: "translateY(-104px) scale(1)", opacity: 0 }
129
+ ],
130
+ {
131
+ duration: W,
132
+ easing: n ? "linear" : "cubic-bezier(0.16, 1, 0.3, 1)",
133
+ fill: "forwards"
134
+ }
135
+ );
136
+ },
137
+ className: "flex flex-col items-center gap-0.5 opacity-0",
138
+ children: [
139
+ /* @__PURE__ */ e("span", { className: "text-[22px] leading-none drop-shadow-sm", children: a.emoji }),
140
+ /* @__PURE__ */ e("span", { className: "max-w-[96px] truncate rounded bg-[#0f172a]/80 px-1 py-px text-[9.5px] font-medium text-white", children: s })
141
+ ]
142
+ }
143
+ ) });
144
+ }
145
+ function _({
146
+ roster: a,
147
+ me: s
148
+ }) {
149
+ const t = v(h.subscribe, h.getSnapshot);
150
+ if (!t.length) return null;
151
+ const n = (r) => {
152
+ 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";
154
+ };
155
+ return /* @__PURE__ */ o(
156
+ "div",
157
+ {
158
+ className: "pointer-events-none absolute inset-x-0 top-0 z-20 h-[calc(100%+96px)] overflow-hidden",
159
+ "aria-live": "polite",
160
+ "data-huddle-reaction-layer": !0,
161
+ children: [
162
+ t.map((r) => /* @__PURE__ */ e(O, { r, name: n(r.user) }, r.id)),
163
+ /* @__PURE__ */ e("span", { className: "sr-only", children: t.length ? `${n(t[t.length - 1].user)} reacted ${t[t.length - 1].emoji}` : "" })
164
+ ]
165
+ }
166
+ );
167
+ }
168
+ function q() {
169
+ const a = v(u.subscribe, u.getSnapshot);
170
+ return a.error ? /* @__PURE__ */ o(
171
+ "div",
172
+ {
173
+ className: "mt-1.5 flex items-start gap-1.5 rounded-md border border-red-200 bg-red-50 px-2 py-1 text-[11.5px] text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200",
174
+ role: "alert",
175
+ children: [
176
+ /* @__PURE__ */ e(k, { className: "mt-px h-3.5 w-3.5 shrink-0", strokeWidth: 2, "aria-hidden": !0 }),
177
+ /* @__PURE__ */ e("span", { className: "min-w-0 flex-1", children: a.error }),
178
+ /* @__PURE__ */ e(
179
+ "button",
180
+ {
181
+ type: "button",
182
+ onClick: () => u.clearError(),
183
+ className: "-my-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-red-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan dark:hover:bg-red-500/20",
184
+ "aria-label": "Dismiss",
185
+ children: /* @__PURE__ */ e(g, { className: "h-3 w-3", strokeWidth: 2 })
186
+ }
187
+ )
188
+ ]
189
+ }
190
+ ) : null;
191
+ }
192
+ export {
193
+ q as HuddleCameraNotice,
194
+ M as HuddleHands,
195
+ _ as HuddleReactionLayer,
196
+ I as HuddleStageTools
197
+ };
@@ -0,0 +1,156 @@
1
+ var R = Object.defineProperty;
2
+ var P = (e, t, n) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var a = (e, t, n) => P(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const j = 0.02, D = 0.012, H = 300, $ = 2e3;
5
+ class w {
6
+ constructor(t = 0.02, n = 0.012, s = 300) {
7
+ a(this, "speaking", !1);
8
+ a(this, "quietSince", null);
9
+ this.on = t, this.off = n, this.holdMs = s;
10
+ }
11
+ push(t, n) {
12
+ return t >= this.on ? (this.speaking = !0, this.quietSince = null) : this.speaking && (t < this.off ? (this.quietSince ?? (this.quietSince = n), n - this.quietSince >= this.holdMs && (this.speaking = !1, this.quietSince = null)) : this.quietSince = null), this.speaking;
13
+ }
14
+ reset() {
15
+ this.speaking = !1, this.quietSince = null;
16
+ }
17
+ }
18
+ function G(e) {
19
+ if (!e.length) return 0;
20
+ let t = 0;
21
+ for (let n = 0; n < e.length; n++) t += e[n] * e[n];
22
+ return Math.sqrt(t / e.length);
23
+ }
24
+ function U(e) {
25
+ if (e <= 0) return 0;
26
+ const t = 20 * Math.log10(e);
27
+ return Math.min(1, Math.max(0, (t + 60) / 50));
28
+ }
29
+ function B(e, t) {
30
+ const n = new Set(t), s = e.filter((o) => n.has(o)), u = new Set(s);
31
+ for (const o of t) u.has(o) || s.push(o);
32
+ return s;
33
+ }
34
+ function V(e, t) {
35
+ return e.map((n, s) => ({ id: n, i: s, t: t[n] ?? Number.NEGATIVE_INFINITY })).sort((n, s) => s.t === n.t ? n.i - s.i : s.t > n.t ? 1 : -1).map((n) => n.id);
36
+ }
37
+ function z(e, t) {
38
+ return e.length === t.length && e.every((n, s) => n === t[s]);
39
+ }
40
+ const Q = {
41
+ editable: !1,
42
+ interactive: !1,
43
+ typeahead: !1,
44
+ inHuddleControls: !1
45
+ };
46
+ function W(e, t, n) {
47
+ if (e.ctrlKey || e.metaKey || e.altKey || t.editable) return null;
48
+ if (e.code === "Space" || e.key === " " || e.key === "Spacebar")
49
+ return !n.muted || t.interactive && !t.inHuddleControls ? null : "ptt";
50
+ if (e.repeat || t.typeahead) return null;
51
+ if (e.key === "?") return "help";
52
+ const u = e.key.length === 1 ? e.key.toLowerCase() : "";
53
+ return u === "m" && !e.shiftKey ? "mute" : u === "s" && e.shiftKey ? n.canShare ? "share" : null : u === "l" && !e.shiftKey ? "leave" : null;
54
+ }
55
+ const Y = [
56
+ { keys: ["Space"], label: "Hold to talk while muted" },
57
+ { keys: ["M"], label: "Mute or unmute" },
58
+ { keys: ["Shift", "S"], label: "Share your screen or stop" },
59
+ { keys: ["L"], label: "Leave the huddle" },
60
+ { keys: ["?"], label: "Show these shortcuts" }
61
+ ], L = /head(set|phone)|ear(bud|phone|pod)|airpods|buds|bluetooth|hands-?free/i;
62
+ function T(e) {
63
+ return e.deviceId === "default" || e.deviceId === "communications" || e.deviceId === "";
64
+ }
65
+ function J(e, t, n) {
66
+ const s = (r) => r.filter((l) => l.kind === "audioinput" && !T(l)), u = new Set(s(e).map((r) => r.deviceId)), o = s(t).find((r) => !u.has(r.deviceId) && L.test(r.label));
67
+ return o && o.deviceId !== n ? { kind: "switch", device: o } : n && !T({ deviceId: n }) && !t.some((r) => r.kind === "audioinput" && r.deviceId === n) ? { kind: "fallback" } : { kind: "none" };
68
+ }
69
+ const g = 5, K = 400, F = 1e4, x = 6e3;
70
+ function C(e) {
71
+ if (e.rtt == null && e.loss == null) return 0;
72
+ const t = e.rtt ?? 0, n = e.loss ?? 0, s = e.jitter ?? 0;
73
+ return t < 150 && n < 1 && s < 30 ? 4 : t < 300 && n < 3 && s < 50 ? 3 : t <= K && n <= g && s < 100 ? 2 : 1;
74
+ }
75
+ function N(e) {
76
+ return (e.loss ?? 0) > g || (e.rtt ?? 0) > K;
77
+ }
78
+ function X(e, t, n) {
79
+ const s = /* @__PURE__ */ new Map();
80
+ for (const i of e) i != null && i.id && s.set(i.id, i);
81
+ const u = e.find((i) => i.type === "transport" && i.selectedCandidatePairId), o = u && s.get(u.selectedCandidatePairId) || e.find((i) => i.type === "candidate-pair" && i.selected) || e.find((i) => i.type === "candidate-pair" && i.nominated && i.state === "succeeded"), r = o ? s.get(o.localCandidateId) : void 0, l = o ? s.get(o.remoteCandidateId) : void 0, _ = o ? (r == null ? void 0 : r.candidateType) === "relay" || (l == null ? void 0 : l.candidateType) === "relay" ? "relay" : "direct" : null, b = e.filter(
82
+ (i) => i.type === "inbound-rtp" && (i.kind ?? i.mediaType) === "audio"
83
+ ), E = e.filter(
84
+ (i) => i.type === "remote-inbound-rtp" && (i.kind ?? i.mediaType) === "audio"
85
+ );
86
+ let d = 0, h = 0, f = null;
87
+ for (const i of b)
88
+ d += Math.max(0, Number(i.packetsLost) || 0), h += Number(i.packetsReceived) || 0, typeof i.jitter == "number" && (f = Math.max(f ?? 0, i.jitter * 1e3));
89
+ let p = typeof (o == null ? void 0 : o.currentRoundTripTime) == "number" ? o.currentRoundTripTime * 1e3 : null, c = null;
90
+ for (const i of E)
91
+ p == null && typeof i.roundTripTime == "number" && (p = i.roundTripTime * 1e3), typeof i.fractionLost == "number" && (c = Math.max(c ?? 0, i.fractionLost * 100));
92
+ let y = null;
93
+ if (t && b.length) {
94
+ const i = d - t.lost, O = h - t.received;
95
+ i + O > 0 && (y = Math.max(0, i) / (Math.max(0, i) + Math.max(0, O)) * 100);
96
+ }
97
+ const I = y == null && c == null ? null : Math.max(y ?? 0, c ?? 0), S = Number(o == null ? void 0 : o.bytesReceived) || 0, k = Number(o == null ? void 0 : o.bytesSent) || 0;
98
+ let M = null, v = null;
99
+ if (t && n > t.at) {
100
+ const i = (n - t.at) / 1e3;
101
+ M = Math.max(0, (S - t.bytesIn) * 8 / 1e3 / i), v = Math.max(0, (k - t.bytesOut) * 8 / 1e3 / i);
102
+ }
103
+ const m = { rtt: p, loss: I, jitter: f };
104
+ return {
105
+ quality: {
106
+ ...m,
107
+ path: _,
108
+ inKbps: M,
109
+ outKbps: v,
110
+ bars: C(m),
111
+ poor: N(m)
112
+ },
113
+ cursor: { at: n, bytesIn: S, bytesOut: k, lost: d, received: h }
114
+ };
115
+ }
116
+ class Z {
117
+ constructor(t = F, n = x) {
118
+ a(this, "active", !1);
119
+ a(this, "since", null);
120
+ this.afterMs = t, this.recoverMs = n;
121
+ }
122
+ push(t, n) {
123
+ return t === this.active ? (this.since = null, this.active) : (this.since ?? (this.since = n), n - this.since >= (this.active ? this.recoverMs : this.afterMs) && (this.active = t, this.since = null), this.active);
124
+ }
125
+ }
126
+ function q(e, t) {
127
+ if (!t || t.bars === 0) return `${e} — measuring the connection`;
128
+ const s = [`${["", "Bad", "Weak", "Fair", "Good"][t.bars]} connection to ${e}`];
129
+ return t.rtt != null && s.push(`${Math.round(t.rtt)} ms`), t.loss != null && s.push(`${t.loss < 10 ? t.loss.toFixed(1) : Math.round(t.loss)} % loss`), t.jitter != null && s.push(`${Math.round(t.jitter)} ms jitter`), t.path && s.push(t.path === "relay" ? "via relay" : "direct"), t.inKbps != null && t.outKbps != null && s.push(`${Math.round(t.inKbps)} kbit/s in, ${Math.round(t.outKbps)} out`), s.join(" · ");
130
+ }
131
+ export {
132
+ Y as HUDDLE_SHORTCUTS,
133
+ Q as NO_FOCUS,
134
+ F as POOR_AFTER_MS,
135
+ g as POOR_LOSS,
136
+ K as POOR_RTT,
137
+ Z as PoorDetector,
138
+ x as RECOVER_AFTER_MS,
139
+ $ as REORDER_MS,
140
+ H as SPEAK_HOLD_MS,
141
+ D as SPEAK_OFF,
142
+ j as SPEAK_ON,
143
+ w as SpeakingGate,
144
+ C as gradeQuality,
145
+ N as isPoor,
146
+ T as isPseudoDevice,
147
+ U as meterFill,
148
+ J as micChange,
149
+ V as orderByLastSpoke,
150
+ q as qualityTip,
151
+ B as reconcileOrder,
152
+ G as rms,
153
+ z as sameOrder,
154
+ W as shortcutFor,
155
+ X as summarizeStats
156
+ };
@@ -0,0 +1,69 @@
1
+ import { rms as m } from "./huddle-audio-logic.js";
2
+ let i = null, l = !1;
3
+ function d() {
4
+ if (typeof window > "u") return null;
5
+ if (!i) {
6
+ const e = window.AudioContext ?? window.webkitAudioContext;
7
+ if (!e) return null;
8
+ try {
9
+ i = new e();
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+ if (i.state === "suspended" && i.resume().catch(() => null), !l) {
15
+ l = !0;
16
+ const e = () => {
17
+ (i == null ? void 0 : i.state) === "suspended" && i.resume().catch(() => null);
18
+ };
19
+ window.addEventListener("pointerdown", e, { capture: !0, passive: !0 }), window.addEventListener("keydown", e, { capture: !0 });
20
+ }
21
+ return i;
22
+ }
23
+ function w(e) {
24
+ const t = d();
25
+ if (!t || !e.getAudioTracks().length) return null;
26
+ try {
27
+ const c = t.createMediaStreamSource(e), n = t.createAnalyser();
28
+ n.fftSize = 512, n.smoothingTimeConstant = 0.2, c.connect(n);
29
+ const o = new Float32Array(n.fftSize);
30
+ return {
31
+ level() {
32
+ return n.getFloatTimeDomainData(o), m(o);
33
+ },
34
+ stop() {
35
+ try {
36
+ c.disconnect();
37
+ } catch {
38
+ }
39
+ }
40
+ };
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+ function y() {
46
+ return typeof HTMLMediaElement < "u" && "setSinkId" in HTMLMediaElement.prototype;
47
+ }
48
+ async function T(e) {
49
+ const t = d();
50
+ if (!t) return;
51
+ await t.resume().catch(() => null);
52
+ const c = t.createMediaStreamDestination(), n = t.createGain();
53
+ n.connect(c);
54
+ const o = t.currentTime;
55
+ for (const [a, f] of [523.25, 783.99].entries()) {
56
+ const u = t.createOscillator();
57
+ u.type = "sine", u.frequency.setValueAtTime(f, o + a * 0.35);
58
+ const s = t.createGain();
59
+ s.gain.setValueAtTime(1e-4, o + a * 0.35), s.gain.exponentialRampToValueAtTime(0.25, o + a * 0.35 + 0.03), s.gain.exponentialRampToValueAtTime(1e-4, o + a * 0.35 + 0.5), u.connect(s).connect(n), u.start(o + a * 0.35), u.stop(o + a * 0.35 + 0.55);
60
+ }
61
+ const r = document.createElement("audio");
62
+ r.srcObject = c.stream, e && typeof r.setSinkId == "function" && await r.setSinkId(e).catch(() => null), await r.play().catch(() => null), await new Promise((a) => setTimeout(a, 1e3)), r.pause(), r.srcObject = null, n.disconnect();
63
+ }
64
+ export {
65
+ w as createLevelMeter,
66
+ d as huddleAudioContext,
67
+ T as playTestTone,
68
+ y as speakerChoiceSupported
69
+ };
@@ -0,0 +1,129 @@
1
+ var h = Object.defineProperty;
2
+ var c = (i, e, t) => e in i ? h(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var r = (i, e, t) => c(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { watchRingRefused as l } from "./huddle-ring-refused.js";
5
+ const f = 3e4, d = { incoming: [], outgoing: {} };
6
+ function m(i, e) {
7
+ return [...i.filter((t) => t.room !== e.room), e];
8
+ }
9
+ function w(i, e = Date.now()) {
10
+ return i.filter((t) => e - t.at < f);
11
+ }
12
+ function y(i, e) {
13
+ const t = e.user.toUpperCase(), s = e.accept ? "accepted" : e.reason === "timeout" ? "timeout" : "declined";
14
+ return i.some((n) => n.id.toUpperCase() === t) ? i.map((n) => n.id.toUpperCase() === t ? { ...n, name: n.name ?? e.name, state: s } : n) : [...i, { id: e.user, name: e.name, state: s }];
15
+ }
16
+ class C {
17
+ constructor() {
18
+ r(this, "state", d);
19
+ r(this, "listeners", /* @__PURE__ */ new Set());
20
+ r(this, "transport", null);
21
+ r(this, "offs", []);
22
+ r(this, "sweep", null);
23
+ /** Answered results fade from the stage after a moment. */
24
+ r(this, "fades", /* @__PURE__ */ new Map());
25
+ r(this, "subscribe", (e) => (this.listeners.add(e), () => {
26
+ this.listeners.delete(e);
27
+ }));
28
+ r(this, "getSnapshot", () => this.state);
29
+ }
30
+ set(e) {
31
+ this.state = { ...this.state, ...e };
32
+ for (const t of this.listeners) t();
33
+ }
34
+ attach(e) {
35
+ if (this.transport !== e) {
36
+ for (const t of this.offs) t();
37
+ this.transport = e, this.offs = [
38
+ e.on("huddle:ring", (t) => {
39
+ typeof (t == null ? void 0 : t.room) != "string" || typeof t.from != "string" || (this.set({
40
+ incoming: m(this.state.incoming, {
41
+ room: t.room,
42
+ from: t.from,
43
+ name: t.name ?? null,
44
+ at: Date.now(),
45
+ scheduled: typeof t.scheduled == "number" ? t.scheduled : null
46
+ })
47
+ }), this.startSweep());
48
+ }),
49
+ e.on("huddle:ring-cancel", (t) => {
50
+ typeof (t == null ? void 0 : t.room) == "string" && this.set({ incoming: this.state.incoming.filter((s) => s.room !== t.room) });
51
+ }),
52
+ e.on("huddle:ringing", (t) => {
53
+ if (typeof (t == null ? void 0 : t.room) != "string" || !Array.isArray(t.users)) return;
54
+ const o = [...this.state.outgoing[t.room] ?? []];
55
+ for (const n of t.users) {
56
+ if (!(n != null && n.id)) continue;
57
+ const u = o.findIndex((g) => g.id.toUpperCase() === n.id.toUpperCase()), a = { id: n.id, name: n.name ?? null, state: "ringing" };
58
+ u >= 0 ? o[u] = a : o.push(a);
59
+ }
60
+ this.set({ outgoing: { ...this.state.outgoing, [t.room]: o } });
61
+ }),
62
+ e.on(
63
+ "huddle:ring-result",
64
+ (t) => {
65
+ if (typeof (t == null ? void 0 : t.room) != "string" || typeof t.user != "string") return;
66
+ const s = y(this.state.outgoing[t.room] ?? [], {
67
+ user: t.user,
68
+ name: t.name ?? null,
69
+ accept: !!t.accept,
70
+ reason: t.reason
71
+ });
72
+ this.set({ outgoing: { ...this.state.outgoing, [t.room]: s } }), this.fadeLater(t.room, t.user);
73
+ }
74
+ ),
75
+ // A ring the server would not place says so (security review finding 1).
76
+ l(e)
77
+ ];
78
+ }
79
+ }
80
+ fadeLater(e, t) {
81
+ const s = `${e}|${t.toUpperCase()}`, o = this.fades.get(s);
82
+ o && clearTimeout(o);
83
+ const n = setTimeout(() => {
84
+ this.fades.delete(s);
85
+ const u = (this.state.outgoing[e] ?? []).filter(
86
+ (a) => a.id.toUpperCase() !== t.toUpperCase() || a.state === "ringing"
87
+ );
88
+ this.set({ outgoing: { ...this.state.outgoing, [e]: u } });
89
+ }, 6e3);
90
+ this.fades.set(s, n);
91
+ }
92
+ startSweep() {
93
+ this.sweep || (this.sweep = setInterval(() => {
94
+ const e = w(this.state.incoming);
95
+ e.length !== this.state.incoming.length && this.set({ incoming: e }), !e.length && this.sweep && (clearInterval(this.sweep), this.sweep = null);
96
+ }, 1e3));
97
+ }
98
+ /** Accept or decline an incoming call; the toast goes either way. */
99
+ answer(e, t) {
100
+ var s;
101
+ this.set({ incoming: this.state.incoming.filter((o) => o.room !== e) }), (s = this.transport) == null || s.emit("huddle:ring-answer", { room: e, accept: t });
102
+ }
103
+ /** Stop ringing everyone I rang in this room. */
104
+ cancel(e) {
105
+ var o;
106
+ (o = this.transport) == null || o.emit("huddle:ring-cancel", { room: e });
107
+ const { [e]: t, ...s } = this.state.outgoing;
108
+ this.set({ outgoing: s });
109
+ }
110
+ /** Ring more people into the huddle I am in (#2844). */
111
+ invite(e, t) {
112
+ var s;
113
+ t.length && ((s = this.transport) == null || s.emit("huddle:invite", { room: e, users: t }));
114
+ }
115
+ /** The stage left the room: forget its ringing list (the server hung up for us). */
116
+ clearOutgoing(e) {
117
+ if (!this.state.outgoing[e]) return;
118
+ const { [e]: t, ...s } = this.state.outgoing;
119
+ this.set({ outgoing: s });
120
+ }
121
+ }
122
+ const p = new C();
123
+ export {
124
+ f as INCOMING_TTL_MS,
125
+ m as addIncoming,
126
+ y as applyResult,
127
+ p as huddleCalls,
128
+ w as pruneIncoming
129
+ };