@nivaro/react 0.2.56 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) 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 +414 -1
  5. package/dist/index.js +767 -716
  6. package/dist/shared/components/ClientChaosToolbar.js +410 -0
  7. package/dist/shared/components/ItemEditForm.js +666 -658
  8. package/dist/shared/components/LoadErrorNote.js +49 -0
  9. package/dist/shared/components/MyWorkView.js +47 -37
  10. package/dist/shared/components/PretendDown.js +258 -0
  11. package/dist/shared/components/ProfileView.js +208 -184
  12. package/dist/shared/components/QueryErrorState.js +16 -0
  13. package/dist/shared/components/ReportView.js +1351 -1338
  14. package/dist/shared/components/WidgetSlot.js +438 -418
  15. package/dist/shared/components/ai/AiPlanCard.js +427 -0
  16. package/dist/shared/components/ai/AiPlanChanges.js +117 -0
  17. package/dist/shared/components/ai/TaskDo.js +1022 -0
  18. package/dist/shared/components/chaos/DeclareIncidentButton.js +72 -0
  19. package/dist/shared/components/chaos/DrillBanner.js +119 -0
  20. package/dist/shared/components/chaos/DrillTag.js +62 -0
  21. package/dist/shared/components/chaos/GameDayStrip.js +61 -0
  22. package/dist/shared/components/chat/ChatAnalyticsView.js +19 -17
  23. package/dist/shared/components/chat/ChatPanel.js +1356 -1317
  24. package/dist/shared/components/chat/HuddleAnalyticsTab.js +198 -0
  25. package/dist/shared/components/chat/RoomHeaderMenu.js +78 -65
  26. package/dist/shared/components/chat/chat-core.js +273 -264
  27. package/dist/shared/components/chat/huddle/HuddleAudioUi.js +397 -0
  28. package/dist/shared/components/chat/huddle/HuddleCallBar.js +296 -0
  29. package/dist/shared/components/chat/huddle/HuddleCallLayer.js +180 -0
  30. package/dist/shared/components/chat/huddle/HuddleCamera.js +124 -0
  31. package/dist/shared/components/chat/huddle/HuddleCollab.js +320 -0
  32. package/dist/shared/components/chat/huddle/HuddleControls.js +82 -121
  33. package/dist/shared/components/chat/huddle/HuddleDraw.js +231 -0
  34. package/dist/shared/components/chat/huddle/HuddleLiveBadge.js +52 -0
  35. package/dist/shared/components/chat/huddle/HuddlePeoplePicker.js +143 -0
  36. package/dist/shared/components/chat/huddle/HuddleScheduleCard.js +190 -0
  37. package/dist/shared/components/chat/huddle/HuddleScheduleForm.js +188 -0
  38. package/dist/shared/components/chat/huddle/HuddleStage.js +184 -89
  39. package/dist/shared/components/chat/huddle/HuddleStageTools.js +197 -0
  40. package/dist/shared/components/chat/huddle/huddle-audio-logic.js +156 -0
  41. package/dist/shared/components/chat/huddle/huddle-audio.js +69 -0
  42. package/dist/shared/components/chat/huddle/huddle-calls.js +129 -0
  43. package/dist/shared/components/chat/huddle/huddle-camera.js +143 -0
  44. package/dist/shared/components/chat/huddle/huddle-collab-store.js +391 -0
  45. package/dist/shared/components/chat/huddle/huddle-device-prefs.js +55 -0
  46. package/dist/shared/components/chat/huddle/huddle-devices.js +99 -0
  47. package/dist/shared/components/chat/huddle/huddle-draw.js +226 -0
  48. package/dist/shared/components/chat/huddle/huddle-follow-bus.js +96 -0
  49. package/dist/shared/components/chat/huddle/huddle-hold.js +62 -0
  50. package/dist/shared/components/chat/huddle/huddle-link-quality.js +159 -0
  51. package/dist/shared/components/chat/huddle/huddle-live.js +82 -0
  52. package/dist/shared/components/chat/huddle/huddle-pip.js +343 -0
  53. package/dist/shared/components/chat/huddle/huddle-quality.js +22 -0
  54. package/dist/shared/components/chat/huddle/huddle-reactions.js +71 -0
  55. package/dist/shared/components/chat/huddle/huddle-ring-refused.js +34 -0
  56. package/dist/shared/components/chat/huddle/huddle-schedule.js +102 -0
  57. package/dist/shared/components/chat/huddle/huddle-sfu.js +176 -0
  58. package/dist/shared/components/chat/huddle/huddle-shortcuts.js +91 -0
  59. package/dist/shared/components/chat/huddle/huddle-speaking.js +100 -0
  60. package/dist/shared/components/chat/huddle/huddle-store.js +431 -157
  61. package/dist/shared/components/chat/huddle/useHuddle.js +46 -38
  62. package/dist/shared/components/chat/huddle/useHuddleAudio.js +35 -0
  63. package/dist/shared/components/client-chaos-gate.js +51 -0
  64. package/dist/shared/components/integrations/console/SignalCard.js +172 -167
  65. package/dist/shared/components/item-edit/GroupSection.js +1 -0
  66. package/dist/shared/components/item-edit/RecordChatActions.js +68 -59
  67. package/dist/shared/components/item-edit/UserChip.js +145 -142
  68. package/dist/shared/components/layout-editor/EditorTopBar.js +108 -105
  69. package/dist/shared/components/layout-editor/LayoutEditor.js +514 -508
  70. package/dist/shared/components/notifications/NotificationAnalyticsView.js +18 -10
  71. package/dist/shared/components/panels/TaskPanel.js +51 -49
  72. package/dist/shared/components/pipeline/PipelineEditorView.js +495 -479
  73. package/dist/shared/components/pipeline/TeamsView.js +184 -169
  74. package/dist/shared/components/support/TicketDetailSheet.js +57 -42
  75. package/dist/shared/lib/client-chaos.js +359 -0
  76. package/dist/shared/lib/load-error.js +26 -0
  77. package/dist/shared/lib/notification-sound.js +25 -16
  78. package/dist/shared/lib/socket-realtime.js +31 -30
  79. package/dist/shared/lib/worker-socket.js +108 -89
  80. package/package.json +2 -1
@@ -0,0 +1,231 @@
1
+ import { jsxs as P, Fragment as Y, jsx as g } from "react/jsx-runtime";
2
+ import { Eraser as x, MousePointer2 as K, PenLine as V, MoveUpRight as X } from "lucide-react";
3
+ import { useRef as N, useState as C, useSyncExternalStore as q, useEffect as L, useCallback as J } from "react";
4
+ import { cn as T } from "../../../lib/utils.js";
5
+ import { drawStore as l, contentRect as G, markOpacity as z } from "./huddle-draw.js";
6
+ import { huddleStore as Q } from "./huddle-store.js";
7
+ const Z = 33, tt = 40, et = 3e-3, nt = 600, ot = [
8
+ {
9
+ id: "pointer",
10
+ label: "Point",
11
+ tip: "Point — everyone sees where you are pointing",
12
+ Icon: K
13
+ },
14
+ { id: "pen", label: "Draw", tip: "Draw on the shared screen", Icon: V },
15
+ { id: "arrow", label: "Arrow", tip: "Draw an arrow", Icon: X }
16
+ ], R = "flex h-6 w-6 items-center justify-center rounded text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan";
17
+ function rt(e, u, b, m) {
18
+ const o = u.pts.map(b);
19
+ if (!o.length) return;
20
+ const M = (a, w) => {
21
+ if (e.strokeStyle = w, e.lineWidth = a * m, e.beginPath(), u.tool === "arrow") {
22
+ const [h, i] = o[0], [f, c] = o[o.length - 1], d = Math.atan2(c - i, f - h), k = 13 * m;
23
+ e.moveTo(h, i), e.lineTo(f, c), e.moveTo(f - k * Math.cos(d - 0.45), c - k * Math.sin(d - 0.45)), e.lineTo(f, c), e.lineTo(f - k * Math.cos(d + 0.45), c - k * Math.sin(d + 0.45));
24
+ } else {
25
+ e.moveTo(o[0][0], o[0][1]);
26
+ for (const [h, i] of o.slice(1)) e.lineTo(h, i);
27
+ o.length === 1 && e.lineTo(o[0][0] + 0.1, o[0][1]);
28
+ }
29
+ e.stroke();
30
+ };
31
+ M(6.5, "rgba(15,23,42,0.55)"), M(3.5, u.color);
32
+ }
33
+ function st(e, u, [b, m], o, M) {
34
+ var c;
35
+ if (e.fillStyle = u.color, e.strokeStyle = "#ffffff", e.lineWidth = 2 * o, e.beginPath(), e.arc(b, m, 7 * o, 0, Math.PI * 2), e.fill(), e.stroke(), M) return;
36
+ const a = u.name;
37
+ e.font = `600 ${11 * o}px system-ui, sans-serif`;
38
+ const w = e.measureText(a).width + 10 * o, h = 17 * o, i = b + 10 * o + w > e.canvas.width ? b - 10 * o - w : b + 10 * o, f = m + 6 * o;
39
+ e.fillStyle = "rgba(15,23,42,0.8)", e.beginPath(), (c = e.roundRect) == null || c.call(e, i, f, w, h, 4 * o), e.roundRect || e.rect(i, f, w, h), e.fill(), e.fillStyle = "#ffffff", e.textBaseline = "middle", e.fillText(a, i + 5 * o, f + h / 2);
40
+ }
41
+ function ft({
42
+ screen: e,
43
+ videoRef: u,
44
+ presenter: b
45
+ }) {
46
+ var W;
47
+ const m = N(null), [o, M] = C({ x: 0, y: 0, w: 0, h: 0 }), [a, w] = C(null), h = q(l.subscribe, l.getSnapshot), [i, f] = C(0);
48
+ L(() => {
49
+ const t = u.current;
50
+ if (!t) return;
51
+ const n = () => {
52
+ M(
53
+ (s) => s.x === t.offsetLeft && s.y === t.offsetTop && s.w === t.offsetWidth && s.h === t.offsetHeight ? s : { x: t.offsetLeft, y: t.offsetTop, w: t.offsetWidth, h: t.offsetHeight }
54
+ );
55
+ };
56
+ n();
57
+ const r = typeof ResizeObserver < "u" ? new ResizeObserver(n) : null;
58
+ return r == null || r.observe(t), t.addEventListener("loadedmetadata", n), t.addEventListener("resize", n), document.addEventListener("fullscreenchange", n), () => {
59
+ r == null || r.disconnect(), t.removeEventListener("loadedmetadata", n), t.removeEventListener("resize", n), document.removeEventListener("fullscreenchange", n);
60
+ };
61
+ }, [u]);
62
+ const c = J(() => {
63
+ const t = u.current;
64
+ return G(o.w, o.h, (t == null ? void 0 : t.videoWidth) ?? 0, (t == null ? void 0 : t.videoHeight) ?? 0);
65
+ }, [o, u]);
66
+ L(() => {
67
+ const t = m.current;
68
+ if (!t || !o.w || !o.h) return;
69
+ const n = t.getContext("2d");
70
+ if (!n) return;
71
+ const r = window.devicePixelRatio || 1;
72
+ t.width !== Math.round(o.w * r) && (t.width = Math.round(o.w * r)), t.height !== Math.round(o.h * r) && (t.height = Math.round(o.h * r));
73
+ let s = 0;
74
+ const v = () => {
75
+ var _;
76
+ const y = Date.now(), j = l.prune(y), S = c(), A = ([p, U]) => [
77
+ (S.x + p * S.w) * r,
78
+ (S.y + U * S.h) * r
79
+ ];
80
+ n.clearRect(0, 0, t.width, t.height), n.lineCap = "round", n.lineJoin = "round";
81
+ for (const p of l.getSnapshot().marks.get(e) ?? [])
82
+ n.globalAlpha = z(y - p.at), rt(n, p, A, r);
83
+ const F = Q.getSnapshot().self;
84
+ for (const p of ((_ = l.getSnapshot().pointers.get(e)) == null ? void 0 : _.values()) ?? [])
85
+ n.globalAlpha = z(y - p.at), st(n, p, A([p.x, p.y]), r, p.from === F);
86
+ n.globalAlpha = 1, f(l.pointing(e, y)), j && (s = requestAnimationFrame(v));
87
+ };
88
+ return v(), () => cancelAnimationFrame(s);
89
+ }, [h.version, o, e, c]);
90
+ const d = N(null), k = N(0), D = (t) => {
91
+ const n = m.current;
92
+ if (!n) return null;
93
+ const r = n.getBoundingClientRect(), s = c();
94
+ if (!s.w || !s.h) return null;
95
+ const v = (t.clientX - r.left - s.x) / s.w, y = (t.clientY - r.top - s.y) / s.h;
96
+ return v < -0.02 || v > 1.02 || y < -0.02 || y > 1.02 ? null : [Math.min(1, Math.max(0, v)), Math.min(1, Math.max(0, y))];
97
+ }, E = () => {
98
+ const t = d.current;
99
+ if (!t) return;
100
+ if (t.timer && clearTimeout(t.timer), t.timer = null, t.tool === "arrow") {
101
+ const r = t.pts[0], s = t.pts[t.pts.length - 1];
102
+ l.send({ t: "st", s: e, id: t.id, tool: "arrow", k: 0, p: [...r, ...s] });
103
+ return;
104
+ }
105
+ if (t.sent >= t.pts.length) return;
106
+ const n = t.pts.slice(t.sent).flat();
107
+ l.send({ t: "st", s: e, id: t.id, tool: "pen", k: t.sent, p: n }), t.sent = t.pts.length;
108
+ }, B = () => {
109
+ const t = d.current;
110
+ t && !t.timer && (t.timer = setTimeout(E, tt));
111
+ }, H = (t) => {
112
+ var r, s;
113
+ if (!a) return;
114
+ const n = D(t);
115
+ if (n) {
116
+ if (t.preventDefault(), (s = (r = t.currentTarget).setPointerCapture) == null || s.call(r, t.pointerId), a === "pointer") {
117
+ l.send({ t: "pt", s: e, x: n[0], y: n[1] });
118
+ return;
119
+ }
120
+ d.current = { id: l.nextStrokeId(), tool: a, pts: [n, n], sent: 0, timer: null }, E();
121
+ }
122
+ }, $ = (t) => {
123
+ if (!a) return;
124
+ const n = D(t);
125
+ if (!n) return;
126
+ if (a === "pointer") {
127
+ const s = Date.now();
128
+ if (s - k.current < Z) return;
129
+ k.current = s, l.send({ t: "pt", s: e, x: n[0], y: n[1] });
130
+ return;
131
+ }
132
+ const r = d.current;
133
+ if (r) {
134
+ if (r.tool === "arrow")
135
+ r.pts = [r.pts[0], n];
136
+ else {
137
+ const s = r.pts[r.pts.length - 1];
138
+ if (Math.hypot(n[0] - s[0], n[1] - s[1]) < et || r.pts.length >= nt)
139
+ return;
140
+ r.pts.push(n);
141
+ }
142
+ B();
143
+ }
144
+ }, I = () => {
145
+ E(), d.current = null;
146
+ };
147
+ L(() => {
148
+ if (!a) return;
149
+ const t = (n) => {
150
+ n.key === "Escape" && w(null);
151
+ };
152
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
153
+ }, [a]);
154
+ const O = !!((W = h.marks.get(e)) != null && W.length);
155
+ return /* @__PURE__ */ P(Y, { children: [
156
+ /* @__PURE__ */ g(
157
+ "canvas",
158
+ {
159
+ ref: m,
160
+ className: T("absolute", a ? "cursor-crosshair touch-none" : "pointer-events-none"),
161
+ style: { left: o.x, top: o.y, width: o.w, height: o.h },
162
+ onPointerDown: H,
163
+ onPointerMove: $,
164
+ onPointerUp: I,
165
+ onPointerCancel: I,
166
+ "aria-hidden": !0,
167
+ "data-huddle-draw-canvas": !0
168
+ }
169
+ ),
170
+ b ? i > 0 || O ? /* @__PURE__ */ P("div", { className: "absolute left-1.5 top-1.5 flex items-center gap-1", "data-huddle-pointing": !0, children: [
171
+ i > 0 && /* @__PURE__ */ g("span", { className: "rounded bg-black/65 px-1.5 py-0.5 text-[10.5px] font-medium text-white", children: i === 1 ? "1 person is pointing" : `${i} people are pointing` }),
172
+ /* @__PURE__ */ g(
173
+ "button",
174
+ {
175
+ type: "button",
176
+ onClick: () => l.send({ t: "clr", s: e }),
177
+ className: T(R, "bg-black/55 hover:bg-black/75"),
178
+ "aria-label": "Clear the marks on your screen",
179
+ "data-tip": "Clear marks",
180
+ children: /* @__PURE__ */ g(x, { className: "h-3.5 w-3.5", strokeWidth: 2 })
181
+ }
182
+ )
183
+ ] }) : null : /* @__PURE__ */ P(
184
+ "div",
185
+ {
186
+ role: "toolbar",
187
+ "aria-label": "Mark up the shared screen",
188
+ className: "absolute left-1.5 top-1.5 flex items-center gap-0.5 rounded-md bg-black/60 p-0.5",
189
+ "data-huddle-draw-tools": !0,
190
+ children: [
191
+ ot.map(({ id: t, label: n, tip: r, Icon: s }) => /* @__PURE__ */ g(
192
+ "button",
193
+ {
194
+ type: "button",
195
+ onClick: () => w((v) => v === t ? null : t),
196
+ className: T(
197
+ R,
198
+ a === t ? "bg-white text-slate-900" : "hover:bg-white/15"
199
+ ),
200
+ "aria-pressed": a === t,
201
+ "aria-label": n,
202
+ "data-tip": a === t ? `${n} — click again or press Esc to stop` : r,
203
+ "data-huddle-tool": t,
204
+ children: /* @__PURE__ */ g(s, { className: "h-3.5 w-3.5", strokeWidth: 2 })
205
+ },
206
+ t
207
+ )),
208
+ /* @__PURE__ */ g("span", { className: "mx-0.5 h-3.5 w-px bg-white/25", "aria-hidden": !0 }),
209
+ /* @__PURE__ */ g(
210
+ "button",
211
+ {
212
+ type: "button",
213
+ onClick: () => l.send({ t: "clr", s: e }),
214
+ disabled: !O,
215
+ className: T(
216
+ R,
217
+ "hover:bg-white/15 disabled:opacity-40 disabled:hover:bg-transparent"
218
+ ),
219
+ "aria-label": "Clear all marks",
220
+ "data-tip": "Clear all marks",
221
+ children: /* @__PURE__ */ g(x, { className: "h-3.5 w-3.5", strokeWidth: 2 })
222
+ }
223
+ )
224
+ ]
225
+ }
226
+ )
227
+ ] });
228
+ }
229
+ export {
230
+ ft as HuddleDrawOverlay
231
+ };
@@ -0,0 +1,52 @@
1
+ import { jsxs as t, jsx as d } from "react/jsx-runtime";
2
+ import { Headphones as n } from "lucide-react";
3
+ import { cn as l } from "../../../lib/utils.js";
4
+ function o({
5
+ count: e,
6
+ label: r,
7
+ className: i
8
+ }) {
9
+ if (e <= 0) return null;
10
+ const a = `${e} ${e === 1 ? "person" : "people"} in a huddle${r ? ` in ${r}` : ""}`;
11
+ return /* @__PURE__ */ t(
12
+ "span",
13
+ {
14
+ className: l(
15
+ "inline-flex shrink-0 items-center gap-0.5 rounded-full bg-emerald-50 px-1.5 py-px text-[10px] font-semibold tabular-nums text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",
16
+ i
17
+ ),
18
+ "data-tip": a,
19
+ role: "img",
20
+ "aria-label": a,
21
+ "data-huddle-live-badge": e,
22
+ children: [
23
+ /* @__PURE__ */ d(n, { className: "h-3 w-3", strokeWidth: 2 }),
24
+ e
25
+ ]
26
+ }
27
+ );
28
+ }
29
+ function u({
30
+ label: e,
31
+ className: r
32
+ }) {
33
+ return e ? /* @__PURE__ */ t(
34
+ "span",
35
+ {
36
+ className: l(
37
+ "inline-flex items-center gap-1 text-[11.5px] text-emerald-700 dark:text-emerald-300",
38
+ r
39
+ ),
40
+ "data-huddle-presence": !0,
41
+ children: [
42
+ /* @__PURE__ */ d(n, { className: "h-3 w-3 shrink-0", strokeWidth: 2 }),
43
+ "In a huddle in ",
44
+ e
45
+ ]
46
+ }
47
+ ) : null;
48
+ }
49
+ export {
50
+ o as HuddleLiveBadge,
51
+ u as HuddlePresenceLine
52
+ };
@@ -0,0 +1,143 @@
1
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
+ import { useQuery as v } from "@tanstack/react-query";
3
+ import { Headphones as b, Check as y, UserPlus as k } from "lucide-react";
4
+ import { useState as u, useEffect as N } from "react";
5
+ import { toast as C } from "sonner";
6
+ import { useNivaroClient as w } from "../../../context.js";
7
+ import { get as H } from "../../../lib/commands.js";
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";
11
+ import { huddleCalls as E } from "./huddle-calls.js";
12
+ function A(a, n, r = !0) {
13
+ const l = w(), [o, m] = u(n);
14
+ return N(() => {
15
+ const s = setTimeout(() => m(n), 180);
16
+ 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 })
21
+ ).then((s) => s.data),
22
+ enabled: r && !!a,
23
+ staleTime: 2e4,
24
+ placeholderData: (s) => s
25
+ });
26
+ }
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({
29
+ room: a,
30
+ selected: n,
31
+ onPick: r,
32
+ renderAvatar: l,
33
+ placeholder: o = "Search people…",
34
+ excludeInHuddle: m
35
+ }) {
36
+ const [s, p] = u(""), { data: d, isLoading: x, isError: f } = A(a, s);
37
+ return /* @__PURE__ */ i(P, { shouldFilter: !1, className: "bg-transparent", children: [
38
+ /* @__PURE__ */ e(
39
+ T,
40
+ {
41
+ value: s,
42
+ onValueChange: p,
43
+ placeholder: o,
44
+ className: "h-8 text-[12.5px]"
45
+ }
46
+ ),
47
+ /* @__PURE__ */ i(I, { className: "max-h-[220px]", children: [
48
+ 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
+ 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
+ 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());
53
+ return /* @__PURE__ */ i(
54
+ L,
55
+ {
56
+ value: t.id,
57
+ disabled: c,
58
+ onSelect: () => !c && r(t),
59
+ className: h(F, c && "opacity-50"),
60
+ "data-huddle-person-row": t.id,
61
+ children: [
62
+ /* @__PURE__ */ e("span", { style: { lineHeight: 0 }, children: l(t.id, t.name) }),
63
+ /* @__PURE__ */ i("span", { className: "min-w-0 flex-1", children: [
64
+ /* @__PURE__ */ e("span", { className: "block truncate", children: t.name }),
65
+ t.title && /* @__PURE__ */ e("span", { className: "block truncate text-[11px] text-slate-500 dark:text-slate-400", children: t.title })
66
+ ] }),
67
+ c ? /* @__PURE__ */ i("span", { className: "flex items-center gap-1 text-[11px] text-slate-500 dark:text-slate-400", children: [
68
+ /* @__PURE__ */ e(b, { className: "h-3 w-3 text-nvr-cyan", strokeWidth: 2 }),
69
+ " here"
70
+ ] }) : g ? /* @__PURE__ */ e(
71
+ y,
72
+ {
73
+ className: "h-3.5 w-3.5 text-nvr-cyan",
74
+ strokeWidth: 2.25,
75
+ "aria-label": "Selected"
76
+ }
77
+ ) : null
78
+ ]
79
+ },
80
+ t.id
81
+ );
82
+ }) })
83
+ ] })
84
+ ] });
85
+ }
86
+ function Q({
87
+ room: a,
88
+ renderAvatar: n,
89
+ onDone: r
90
+ }) {
91
+ return /* @__PURE__ */ e(
92
+ O,
93
+ {
94
+ room: a,
95
+ selected: /* @__PURE__ */ new Set(),
96
+ excludeInHuddle: !0,
97
+ renderAvatar: n,
98
+ 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();
101
+ }
102
+ }
103
+ );
104
+ }
105
+ function X({
106
+ room: a,
107
+ renderAvatar: n,
108
+ className: r
109
+ }) {
110
+ const [l, o] = u(!1);
111
+ return /* @__PURE__ */ i(W, { open: l, onOpenChange: o, children: [
112
+ /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ className: h(
117
+ "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
120
+ ),
121
+ "aria-label": "Add people to the huddle",
122
+ "data-tip": "Add people — they get a call",
123
+ "data-huddle-invite": !0,
124
+ children: /* @__PURE__ */ e(k, { className: "h-3.5 w-3.5", strokeWidth: 2 })
125
+ }
126
+ ) }),
127
+ /* @__PURE__ */ e(
128
+ D,
129
+ {
130
+ align: "end",
131
+ className: "w-[280px] max-w-[calc(100vw-16px)] p-1",
132
+ "data-huddle-invite-picker": !0,
133
+ children: /* @__PURE__ */ e(Q, { room: a, renderAvatar: n, onDone: () => o(!1) })
134
+ }
135
+ )
136
+ ] });
137
+ }
138
+ export {
139
+ X as HuddleInviteButton,
140
+ Q as HuddleInviteList,
141
+ O as HuddlePeopleList,
142
+ A as useHuddlePeople
143
+ };
@@ -0,0 +1,190 @@
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import { useQueryClient as $, useQuery as H, useMutation as P } from "@tanstack/react-query";
3
+ import { Headphones as i, CalendarClock as Q, CalendarPlus as F, ExternalLink as K } from "lucide-react";
4
+ import { useState as w, useEffect as L } from "react";
5
+ import { toast as y } from "sonner";
6
+ import { useNivaroClient as T } from "../../../context.js";
7
+ import { get as Y, del as z } from "../../../lib/commands.js";
8
+ import { cn as l } from "../../../lib/utils.js";
9
+ import { schedulePhase as C, formatScheduleWhen as D, formatStartsIn as J, downloadIcs as M, outlookComposeUrl as A } from "./huddle-schedule.js";
10
+ import { huddleStore as c } from "./huddle-store.js";
11
+ function re({
12
+ id: s,
13
+ mine: S,
14
+ renderAvatar: j,
15
+ roomUrl: h
16
+ }) {
17
+ const u = T(), W = $(), { data: t, isLoading: q, isError: I } = H({
18
+ queryKey: ["nvr-huddle-schedule", s],
19
+ queryFn: () => u.request(Y(`/chat/huddle/schedules/${s}`)).then((a) => a.data),
20
+ staleTime: 3e4,
21
+ refetchInterval: (a) => {
22
+ const d = a.state.data;
23
+ if (!d) return !1;
24
+ const N = C(d);
25
+ return N === "ended" || N === "cancelled" ? !1 : 6e4;
26
+ },
27
+ retry: !1
28
+ }), [, E] = w(0);
29
+ L(() => {
30
+ const a = setInterval(() => E((d) => d + 1), 3e4);
31
+ return () => clearInterval(a);
32
+ }, []);
33
+ const [O, m] = w(!1), p = P({
34
+ mutationFn: () => u.request(z(`/chat/huddle/schedules/${s}`)),
35
+ onSuccess: () => {
36
+ W.invalidateQueries({ queryKey: ["nvr-huddle-schedule", s] }), y.success("Huddle cancelled");
37
+ },
38
+ onError: () => y.error("Could not cancel it")
39
+ }), x = l(
40
+ "mt-1 w-[300px] max-w-full rounded-lg border px-3 py-2.5 text-left",
41
+ S ? "border-white/40 bg-white/95 text-slate-800 dark:border-white/20 dark:bg-card dark:text-slate-100" : "border-slate-200 bg-white text-slate-800 dark:border-border dark:bg-card dark:text-slate-100"
42
+ );
43
+ if (q && !t)
44
+ return /* @__PURE__ */ r("div", { className: x, "aria-busy": "true", "data-huddle-card": "loading", children: [
45
+ /* @__PURE__ */ e("div", { className: "h-3.5 w-2/3 animate-pulse rounded bg-slate-200 dark:bg-white/10" }),
46
+ /* @__PURE__ */ e("div", { className: "mt-2 h-3 w-1/2 animate-pulse rounded bg-slate-200 dark:bg-white/10" }),
47
+ /* @__PURE__ */ e("div", { className: "mt-3 h-7 w-24 animate-pulse rounded bg-slate-200 dark:bg-white/10" })
48
+ ] });
49
+ if (I || !t)
50
+ return /* @__PURE__ */ e(
51
+ "p",
52
+ {
53
+ className: "mt-1 text-[11px] italic text-slate-500 dark:text-slate-400",
54
+ "data-huddle-card": "gone",
55
+ children: "This huddle is no longer available."
56
+ }
57
+ );
58
+ const n = C(t), b = n === "live" || n === "soon", _ = () => void c.join(t.room), v = c.getSnapshot().room === t.room && c.getSnapshot().status === "live", o = t.invitees.slice(0, 5), g = t.invitees.length - o.length, k = "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan", f = l(
59
+ k,
60
+ "border border-slate-200 text-slate-700 hover:bg-slate-50 dark:border-border dark:text-slate-200 dark:hover:bg-white/5"
61
+ );
62
+ return /* @__PURE__ */ r("div", { className: x, "data-huddle-card": n, children: [
63
+ /* @__PURE__ */ r("div", { className: "flex items-start gap-2", children: [
64
+ /* @__PURE__ */ e(
65
+ "span",
66
+ {
67
+ className: l(
68
+ "mt-0.5 grid h-7 w-7 shrink-0 place-items-center rounded-md",
69
+ n === "live" ? "bg-nvr-cyan/15 text-nvr-navy dark:text-nvr-cyan" : "bg-slate-100 text-slate-500 dark:bg-white/10 dark:text-slate-300"
70
+ ),
71
+ "aria-hidden": !0,
72
+ children: n === "live" ? /* @__PURE__ */ e(i, { className: "h-4 w-4", strokeWidth: 2 }) : /* @__PURE__ */ e(Q, { className: "h-4 w-4", strokeWidth: 2 })
73
+ }
74
+ ),
75
+ /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: [
76
+ /* @__PURE__ */ e(
77
+ "p",
78
+ {
79
+ className: l(
80
+ "line-clamp-2 break-words text-[12.5px] font-semibold",
81
+ n === "cancelled" && "line-through opacity-60"
82
+ ),
83
+ children: t.title
84
+ }
85
+ ),
86
+ /* @__PURE__ */ e("p", { className: "mt-0.5 text-[11.5px] text-slate-600 dark:text-slate-300", children: D(t.starts_at, t.ends_at) }),
87
+ /* @__PURE__ */ e("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: n === "cancelled" ? "Cancelled" : n === "ended" ? "Ended" : n === "live" ? t.live ? "On now — people are talking" : "On now — nobody has joined yet" : `Starts ${J(t.starts_at)} · ${t.organizer.name ?? "Someone"} organised it` })
88
+ ] })
89
+ ] }),
90
+ t.invitees.length > 0 && /* @__PURE__ */ r("div", { className: "mt-2 flex items-center gap-1.5", "data-huddle-card-invitees": !0, children: [
91
+ /* @__PURE__ */ e("span", { className: "flex -space-x-1.5", children: o.map((a) => /* @__PURE__ */ e(
92
+ "span",
93
+ {
94
+ className: "rounded-full ring-2 ring-white dark:ring-card",
95
+ style: { lineHeight: 0 },
96
+ "data-tip": a.name ?? void 0,
97
+ children: j(a.id, a.name)
98
+ },
99
+ a.id
100
+ )) }),
101
+ /* @__PURE__ */ r("span", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: [
102
+ o.map((a) => a.name ?? "Someone").join(", "),
103
+ g > 0 && ` +${g}`
104
+ ] })
105
+ ] }),
106
+ n !== "cancelled" && n !== "ended" && /* @__PURE__ */ r("div", { className: "mt-2.5 flex flex-wrap items-center gap-1.5", children: [
107
+ b && !v && /* @__PURE__ */ r(
108
+ "button",
109
+ {
110
+ type: "button",
111
+ onClick: _,
112
+ className: l(k, "bg-nvr-cyan text-white hover:bg-[#00b8e0]"),
113
+ "data-huddle-card-join": !0,
114
+ children: [
115
+ /* @__PURE__ */ e(i, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
116
+ "Join"
117
+ ]
118
+ }
119
+ ),
120
+ b && v && /* @__PURE__ */ r("span", { className: "inline-flex h-7 items-center gap-1 text-[11.5px] font-medium text-nvr-navy dark:text-nvr-cyan", children: [
121
+ /* @__PURE__ */ e(i, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
122
+ "You are in it"
123
+ ] }),
124
+ /* @__PURE__ */ r(
125
+ "button",
126
+ {
127
+ type: "button",
128
+ onClick: () => M(t, h ?? null),
129
+ className: f,
130
+ "data-tip": "Download a calendar file (.ics)",
131
+ "data-huddle-card-ics": !0,
132
+ children: [
133
+ /* @__PURE__ */ e(F, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
134
+ "Calendar"
135
+ ]
136
+ }
137
+ ),
138
+ /* @__PURE__ */ r(
139
+ "a",
140
+ {
141
+ href: A(t, h ?? null),
142
+ target: "_blank",
143
+ rel: "noopener noreferrer",
144
+ className: f,
145
+ "data-tip": "Open a pre-filled event in Outlook on the web",
146
+ "data-huddle-card-outlook": !0,
147
+ children: [
148
+ /* @__PURE__ */ e(K, { className: "h-3.5 w-3.5", strokeWidth: 2 }),
149
+ "Outlook"
150
+ ]
151
+ }
152
+ ),
153
+ t.can_cancel && /* @__PURE__ */ e("span", { className: "ml-auto", children: O ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 text-[11px]", children: [
154
+ /* @__PURE__ */ e("span", { className: "text-slate-500 dark:text-slate-400", children: "Cancel it?" }),
155
+ /* @__PURE__ */ e(
156
+ "button",
157
+ {
158
+ type: "button",
159
+ onClick: () => p.mutate(),
160
+ disabled: p.isPending,
161
+ className: "h-6 rounded px-1.5 font-medium text-red-600 hover:bg-red-50 dark:text-red-300 dark:hover:bg-red-500/15",
162
+ "data-huddle-card-cancel-confirm": !0,
163
+ children: "Yes"
164
+ }
165
+ ),
166
+ /* @__PURE__ */ e(
167
+ "button",
168
+ {
169
+ type: "button",
170
+ onClick: () => m(!1),
171
+ className: "h-6 rounded px-1.5 text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-white/10",
172
+ children: "No"
173
+ }
174
+ )
175
+ ] }) : /* @__PURE__ */ e(
176
+ "button",
177
+ {
178
+ type: "button",
179
+ onClick: () => m(!0),
180
+ className: "h-6 rounded px-1.5 text-[11px] text-slate-500 hover:bg-slate-100 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-white/10 dark:hover:text-slate-100",
181
+ "data-huddle-card-cancel": !0,
182
+ children: "Cancel huddle"
183
+ }
184
+ ) })
185
+ ] })
186
+ ] });
187
+ }
188
+ export {
189
+ re as HuddleScheduleCard
190
+ };