@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
@@ -1,15 +1,16 @@
1
1
  import { jsx as a, jsxs as r, Fragment as h } from "react/jsx-runtime";
2
- import { useQueryClient as D, useQuery as N, useMutation as g } from "@tanstack/react-query";
3
- import { Loader2 as Q, PlayCircle as U, Paperclip as L } from "lucide-react";
2
+ import { useQueryClient as j, useQuery as N, useMutation as g } from "@tanstack/react-query";
3
+ import { Loader2 as A, PlayCircle as U, Paperclip as L } from "lucide-react";
4
4
  import { useState as w } from "react";
5
5
  import { useNivaroClient as O, useApiFetchConfig as E, useItemNavigation as H, useNavigation as W } from "../../context.js";
6
6
  import { get as _, post as S, patch as B } from "../../lib/commands.js";
7
7
  import { useTopicPresence as G, signalSentence as q } from "../../lib/presence-signals.js";
8
8
  import { replayHref as M } from "../../lib/replay-capture.js";
9
- import { RelationCombobox as z } from "../item-edit/RelationCombobox.js";
9
+ import { TaskDoButton as z } from "../ai/TaskDo.js";
10
+ import { RelationCombobox as J } from "../item-edit/RelationCombobox.js";
10
11
  import { SimpleSelect as C } from "../ui/SimpleSelect.js";
11
- import { Sheet as J, SheetContent as V, SheetHeader as X, SheetTitle as Y, SheetDescription as Z } from "../ui/sheet.js";
12
- import { TicketTraffic as I } from "./TicketTraffic.js";
12
+ import { Sheet as V, SheetContent as X, SheetHeader as Y, SheetTitle as Z, SheetDescription as I } from "../ui/sheet.js";
13
+ import { TicketTraffic as ee } from "./TicketTraffic.js";
13
14
  import { STATUS_TONE as T } from "./types.js";
14
15
  const $ = [
15
16
  { value: "open", label: "Open" },
@@ -25,66 +26,66 @@ function y(n) {
25
26
  minute: "2-digit"
26
27
  }) : "";
27
28
  }
28
- function ee({ status: n, label: d }) {
29
- var l;
29
+ function te({ status: n, label: c }) {
30
+ var s;
30
31
  return /* @__PURE__ */ a(
31
32
  "span",
32
33
  {
33
34
  "data-ticket-status": n,
34
35
  className: `inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${T[n] ?? T.open}`,
35
- children: d ?? ((l = $.find((s) => s.value === n)) == null ? void 0 : l.label) ?? n
36
+ children: c ?? ((s = $.find((l) => l.value === n)) == null ? void 0 : s.label) ?? n
36
37
  }
37
38
  );
38
39
  }
39
- function xe({
40
+ function ge({
40
41
  ticketId: n,
41
- onOpenChange: d
42
+ onOpenChange: c
42
43
  }) {
43
- const l = O(), s = D(), { apiBase: F } = E(), { urlFor: K, open: P } = H(), m = W(), [p, b] = w(""), [f, R] = w(null), i = G(n != null ? `ticket:${n}` : null), { data: e, isLoading: j } = N({
44
+ const s = O(), l = j(), { apiBase: K } = E(), { urlFor: F, open: P } = H(), m = W(), [p, f] = w(""), [b, D] = w(null), i = G(n != null ? `ticket:${n}` : null), { data: e, isLoading: Q } = N({
44
45
  queryKey: ["support-ticket", n],
45
- queryFn: () => l.request(_(`/support/tickets/${n}`)).then((t) => t.data),
46
+ queryFn: () => s.request(_(`/support/tickets/${n}`)).then((t) => t.data),
46
47
  enabled: n != null
47
- }), { data: A = [] } = N({
48
+ }), { data: R = [] } = N({
48
49
  queryKey: ["support-categories", "all-for", (e == null ? void 0 : e.collection) ?? null],
49
- queryFn: () => l.request(
50
+ queryFn: () => s.request(
50
51
  _("/support/categories", e != null && e.collection ? { collection: e.collection } : void 0)
51
52
  ).then((t) => t.data ?? []),
52
53
  enabled: !!(e != null && e.can.work)
53
54
  }), u = () => {
54
- s.invalidateQueries({ queryKey: ["support-ticket", n] }), s.invalidateQueries({ queryKey: ["support-tickets"] }), s.invalidateQueries({ queryKey: ["support-summary"] }), s.invalidateQueries({ queryKey: ["my-work"] });
55
- }, x = (t) => R(t.message || "That did not work"), k = g({
56
- mutationFn: () => l.request(S(`/support/tickets/${n}/claim`)),
55
+ l.invalidateQueries({ queryKey: ["support-ticket", n] }), l.invalidateQueries({ queryKey: ["support-tickets"] }), l.invalidateQueries({ queryKey: ["support-summary"] }), l.invalidateQueries({ queryKey: ["my-work"] });
56
+ }, x = (t) => D(t.message || "That did not work"), k = g({
57
+ mutationFn: () => s.request(S(`/support/tickets/${n}/claim`)),
57
58
  onSuccess: u,
58
59
  onError: x
59
60
  }), o = g({
60
- mutationFn: (t) => l.request(B(`/support/tickets/${n}`, t)),
61
+ mutationFn: (t) => s.request(B(`/support/tickets/${n}`, t)),
61
62
  onSuccess: u,
62
63
  onError: x
63
64
  }), v = g({
64
- mutationFn: () => l.request(S(`/support/tickets/${n}/comments`, { text: p.trim() })),
65
+ mutationFn: () => s.request(S(`/support/tickets/${n}/comments`, { text: p.trim() })),
65
66
  onSuccess: () => {
66
- b(""), i.signalReplying(!1), u();
67
+ f(""), i.signalReplying(!1), u();
67
68
  },
68
69
  onError: x
69
70
  });
70
- return /* @__PURE__ */ a(J, { open: n != null, onOpenChange: d, children: /* @__PURE__ */ a(
71
- V,
71
+ return /* @__PURE__ */ a(V, { open: n != null, onOpenChange: c, children: /* @__PURE__ */ a(
72
+ X,
72
73
  {
73
74
  side: "right",
74
75
  className: "flex w-[560px] max-w-[96vw] flex-col gap-0 p-0 sm:max-w-[560px] dark:bg-card",
75
76
  "data-support-ticket": n ?? "",
76
- children: j || !e ? /* @__PURE__ */ a("div", { className: "flex flex-1 items-center justify-center text-slate-400", children: /* @__PURE__ */ a(Q, { className: "h-5 w-5 animate-spin" }) }) : /* @__PURE__ */ r(h, { children: [
77
- /* @__PURE__ */ r(X, { className: "border-b border-slate-200 px-5 py-4 dark:border-border", children: [
77
+ children: Q || !e ? /* @__PURE__ */ a("div", { className: "flex flex-1 items-center justify-center text-slate-400", children: /* @__PURE__ */ a(A, { className: "h-5 w-5 animate-spin" }) }) : /* @__PURE__ */ r(h, { children: [
78
+ /* @__PURE__ */ r(Y, { className: "border-b border-slate-200 px-5 py-4 dark:border-border", children: [
78
79
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 pr-6", children: [
79
80
  /* @__PURE__ */ r("span", { className: "font-mono text-[11.5px] text-slate-400", children: [
80
81
  "#",
81
82
  e.id
82
83
  ] }),
83
- /* @__PURE__ */ a(ee, { status: e.status, label: e.status_label }),
84
+ /* @__PURE__ */ a(te, { status: e.status, label: e.status_label }),
84
85
  e.priority === "urgent" && /* @__PURE__ */ a("span", { className: "rounded bg-red-500/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400", children: "urgent" })
85
86
  ] }),
86
- /* @__PURE__ */ a(Y, { className: "mt-1 text-left text-[16px] font-semibold text-slate-900 dark:text-slate-100", children: e.title }),
87
- /* @__PURE__ */ r(Z, { className: "text-left text-[12px] text-slate-500 dark:text-muted-foreground", children: [
87
+ /* @__PURE__ */ a(Z, { className: "mt-1 text-left text-[16px] font-semibold text-slate-900 dark:text-slate-100", children: e.title }),
88
+ /* @__PURE__ */ r(I, { className: "text-left text-[12px] text-slate-500 dark:text-muted-foreground", children: [
88
89
  e.requester_name ?? "Someone",
89
90
  " · ",
90
91
  y(e.created_at),
@@ -93,7 +94,7 @@ function xe({
93
94
  /* @__PURE__ */ a("div", { className: "mt-1 text-[12px]", children: e.collection && e.item ? /* @__PURE__ */ a(
94
95
  "a",
95
96
  {
96
- href: K({ collection: e.collection, itemId: e.item }),
97
+ href: F({ collection: e.collection, itemId: e.item }),
97
98
  onClick: (t) => {
98
99
  t.metaKey || t.ctrlKey || t.shiftKey || t.button !== 0 || (t.preventDefault(), P({ collection: e.collection, itemId: e.item }));
99
100
  },
@@ -132,6 +133,20 @@ function xe({
132
133
  "Not picked up yet",
133
134
  e.team_name ? ` · ${e.team_name}` : " · Administrators"
134
135
  ] }) }),
136
+ /* @__PURE__ */ a(
137
+ z,
138
+ {
139
+ task: {
140
+ id: e.id,
141
+ kind: "support",
142
+ status: e.status,
143
+ assignee: e.assignee,
144
+ category_id: e.category_id,
145
+ title: e.title
146
+ },
147
+ onTaskChanged: () => void l.invalidateQueries({ queryKey: ["support-ticket", n] })
148
+ }
149
+ ),
135
150
  (e.status === "open" || e.status === "in_progress") && /* @__PURE__ */ a(
136
151
  "button",
137
152
  {
@@ -166,7 +181,7 @@ function xe({
166
181
  onChange: (t) => o.mutate({ category_id: t ? Number(t) : null }),
167
182
  options: [
168
183
  { value: "", label: "No type" },
169
- ...A.map((t) => ({ value: String(t.id), label: t.name }))
184
+ ...R.map((t) => ({ value: String(t.id), label: t.name }))
170
185
  ],
171
186
  ariaLabel: "Type",
172
187
  className: "mt-1"
@@ -176,7 +191,7 @@ function xe({
176
191
  /* @__PURE__ */ r("div", { className: "col-span-2 text-[11px] font-medium text-slate-500 dark:text-muted-foreground", children: [
177
192
  "Assignee",
178
193
  /* @__PURE__ */ a("div", { className: "mt-1", children: /* @__PURE__ */ a(
179
- z,
194
+ J,
180
195
  {
181
196
  collection: "nivaro_users",
182
197
  value: e.assignee,
@@ -192,11 +207,11 @@ function xe({
192
207
  /* @__PURE__ */ a("h3", { className: "mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-muted-foreground", children: "Request" }),
193
208
  /* @__PURE__ */ a("p", { className: "whitespace-pre-wrap text-[13px] leading-relaxed text-slate-800 dark:text-slate-200", children: e.description || /* @__PURE__ */ a("span", { className: "text-slate-400", children: "No details given." }) }),
194
209
  e.replay && e.can.work && (() => {
195
- const t = M(e.replay), c = m.consoleUrl ? m.consoleUrl(t) : t;
196
- return c ? /* @__PURE__ */ r(
210
+ const t = M(e.replay), d = m.consoleUrl ? m.consoleUrl(t) : t;
211
+ return d ? /* @__PURE__ */ r(
197
212
  "a",
198
213
  {
199
- href: c,
214
+ href: d,
200
215
  target: "_blank",
201
216
  rel: "noreferrer",
202
217
  "data-ticket-replay": e.replay.recording_id,
@@ -209,11 +224,11 @@ function xe({
209
224
  ) : null;
210
225
  })(),
211
226
  e.issue_id != null && e.can.work && (() => {
212
- const t = `/issues/${e.issue_id}`, c = m.consoleUrl ? m.consoleUrl(t) : t;
213
- return c ? /* @__PURE__ */ r(
227
+ const t = `/issues/${e.issue_id}`, d = m.consoleUrl ? m.consoleUrl(t) : t;
228
+ return d ? /* @__PURE__ */ r(
214
229
  "a",
215
230
  {
216
- href: c,
231
+ href: d,
217
232
  target: "_blank",
218
233
  rel: "noreferrer",
219
234
  "data-ticket-issue": e.issue_id,
@@ -228,7 +243,7 @@ function xe({
228
243
  e.files.length > 0 && /* @__PURE__ */ a("ul", { className: "mt-2 flex flex-wrap gap-1.5", children: e.files.map((t) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ r(
229
244
  "a",
230
245
  {
231
- href: `${F}/files/${t.id}`,
246
+ href: `${K}/files/${t.id}`,
232
247
  target: "_blank",
233
248
  rel: "noreferrer",
234
249
  className: "inline-flex items-center gap-1 rounded bg-slate-100 px-2 py-0.5 text-[11.5px] text-slate-700 hover:underline dark:bg-white/10 dark:text-slate-200",
@@ -239,7 +254,7 @@ function xe({
239
254
  }
240
255
  ) }, t.id)) })
241
256
  ] }),
242
- e.can.work && /* @__PURE__ */ a(I, { ticketId: e.id }),
257
+ e.can.work && /* @__PURE__ */ a(ee, { ticketId: e.id }),
243
258
  /* @__PURE__ */ r("section", { "data-ticket-thread": !0, children: [
244
259
  /* @__PURE__ */ a("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-muted-foreground", children: "Conversation" }),
245
260
  e.thread.length === 0 ? /* @__PURE__ */ a("p", { className: "text-[12px] text-slate-400", children: "No replies yet." }) : /* @__PURE__ */ a("ul", { className: "space-y-2.5", children: e.thread.map((t) => /* @__PURE__ */ r(
@@ -270,7 +285,7 @@ function xe({
270
285
  "data-ticket-reply": !0,
271
286
  value: p,
272
287
  onChange: (t) => {
273
- b(t.target.value), i.signalReplying(!!t.target.value.trim());
288
+ f(t.target.value), i.signalReplying(!!t.target.value.trim());
274
289
  },
275
290
  rows: 3,
276
291
  placeholder: "Write a reply",
@@ -324,7 +339,7 @@ function xe({
324
339
  ]
325
340
  }
326
341
  ),
327
- f && /* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-red-600 dark:text-red-400", role: "alert", children: f })
342
+ b && /* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-red-600 dark:text-red-400", role: "alert", children: b })
328
343
  ] }),
329
344
  /* @__PURE__ */ r("section", { "data-ticket-history": !0, children: [
330
345
  /* @__PURE__ */ a("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-muted-foreground", children: "History" }),
@@ -345,6 +360,6 @@ function xe({
345
360
  ) });
346
361
  }
347
362
  export {
348
- ee as StatusPill,
349
- xe as TicketDetailSheet
363
+ te as StatusPill,
364
+ ge as TicketDetailSheet
350
365
  };
@@ -0,0 +1,359 @@
1
+ const h = "x-nivaro-client-chaos", y = "nvr-client-chaos", K = 1e4, Y = 18e5, z = 50, D = {
2
+ flaky: { min: 5, max: 90, step: 5, initial: 30 },
3
+ slow: { min: 250, max: 1e4, step: 250, initial: 2e3 }
4
+ };
5
+ function Q(e) {
6
+ return !!(e != null && e.is_admin) && !e.masquerade;
7
+ }
8
+ let o = null, A = !1, u = null;
9
+ const C = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
10
+ let k = 0;
11
+ function R() {
12
+ try {
13
+ return typeof sessionStorage > "u" ? null : sessionStorage;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+ function M() {
19
+ const e = R();
20
+ if (e)
21
+ try {
22
+ o ? e.setItem(y, JSON.stringify(o)) : e.removeItem(y);
23
+ } catch {
24
+ }
25
+ }
26
+ function P(e) {
27
+ const t = e;
28
+ return !!t && t.v === 1 && typeof t.endsAt == "number" && typeof t.startedAt == "number" && typeof t.strength == "number" && typeof t.failWrites == "number" && (t.preset === null || t.preset === "flaky" || t.preset === "api-down" || t.preset === "slow" || t.preset === "offline" || t.preset === "socket-gone");
29
+ }
30
+ function v(e) {
31
+ if (A) return;
32
+ A = !0;
33
+ const t = R();
34
+ if (t)
35
+ try {
36
+ const n = t.getItem(y);
37
+ if (!n) return;
38
+ const r = JSON.parse(n);
39
+ P(r) && r.endsAt > e && r.endsAt - r.startedAt <= 18e5 ? (o = r, O(e)) : t.removeItem(y);
40
+ } catch {
41
+ }
42
+ }
43
+ function p() {
44
+ for (const e of [...C])
45
+ try {
46
+ e();
47
+ } catch {
48
+ }
49
+ }
50
+ function O(e) {
51
+ u && clearTimeout(u), u = null, o && (u = setTimeout(
52
+ () => {
53
+ u = null, m();
54
+ },
55
+ Math.max(0, o.endsAt - e) + 5
56
+ ));
57
+ }
58
+ function _(e = !0) {
59
+ u && clearTimeout(u), u = null;
60
+ const t = o !== null;
61
+ o = null, M(), t && (e ? p() : Promise.resolve().then(p));
62
+ }
63
+ function m(e = Date.now()) {
64
+ return v(e), o && e >= o.endsAt && _(!1), o && o.preset === null && o.failWrites <= 0 && _(!1), o;
65
+ }
66
+ function Z(e, t = Date.now()) {
67
+ v(t);
68
+ const n = Math.min(
69
+ 18e5,
70
+ Math.max(1e4, Math.round(e.durationMs) || 0)
71
+ ), r = e.preset === "flaky" || e.preset === "slow" ? D[e.preset] : null, a = r ? Math.min(r.max, Math.max(r.min, Math.round(e.strength ?? r.initial))) : 0, s = Math.min(
72
+ 50,
73
+ Math.max(0, Math.floor(e.failWrites ?? 0))
74
+ );
75
+ return o = {
76
+ v: 1,
77
+ preset: e.preset,
78
+ strength: a,
79
+ failWrites: s,
80
+ startedAt: t,
81
+ endsAt: t + n
82
+ }, M(), O(t), p(), o;
83
+ }
84
+ function ee() {
85
+ v(Date.now()), _();
86
+ }
87
+ function N(e) {
88
+ return C.add(e), () => C.delete(e);
89
+ }
90
+ function U(e, t) {
91
+ const n = l.get(e);
92
+ !t.length && !n || (t.length ? l.set(e, t) : l.delete(e), k += 1, p());
93
+ }
94
+ const te = "nvr:pretend-down";
95
+ function ne(e) {
96
+ return l.get(e) ?? [];
97
+ }
98
+ function re(e) {
99
+ U(e, []);
100
+ }
101
+ function se() {
102
+ return k;
103
+ }
104
+ function W(e = Date.now()) {
105
+ var t;
106
+ if (((t = m(e)) == null ? void 0 : t.preset) === "socket-gone") return !0;
107
+ for (const n of l.values()) if (n.some((r) => r.socket)) return !0;
108
+ return !1;
109
+ }
110
+ function I(e = Date.now()) {
111
+ return m(e) !== null || l.size > 0;
112
+ }
113
+ function H(e) {
114
+ let t = e;
115
+ try {
116
+ t = new URL(
117
+ e,
118
+ typeof window < "u" && window.location ? window.location.href : "http://local/"
119
+ ).pathname;
120
+ } catch {
121
+ t = e.split(/[?#]/)[0];
122
+ }
123
+ return t === "/api" ? "/" : t.startsWith("/api/") ? t.slice(4) : null;
124
+ }
125
+ const q = /^\/(chaos(\/|$)|auth\/(login|logout|callback|me)(\/|$)|issues\/client$|rum$|connection-reports$)/, $ = /^\/(issues\/client|rum|connection-reports)$/, g = /^\/(items\/batch-read|items\/[^/]+\/aggregate|users\/cards|graphql(\/|$)|widgets-internal\/[^/]+\/render|record-views\/|presence\/|page-at|field-rules\/(evaluate|explain)|custom-queries\/[^/]+\/(run|execute)|search(\/|$)|realtime\/)/;
126
+ function G(e, t) {
127
+ const n = e.toUpperCase();
128
+ return n === "PATCH" || n === "PUT" || n === "DELETE" ? !0 : n === "POST" && !g.test(t);
129
+ }
130
+ const X = { status: 503, statusText: "Service Unavailable" }, j = {
131
+ 500: "Internal Server Error",
132
+ 502: "Bad Gateway",
133
+ 503: "Service Unavailable",
134
+ 504: "Gateway Timeout"
135
+ };
136
+ function f(e, t, n) {
137
+ return Math.round(t + e() * (n - t));
138
+ }
139
+ function x(e, t = Math.random, n = Date.now()) {
140
+ const r = m(n);
141
+ if (!r && l.size === 0) return { kind: "pass", mark: null };
142
+ const a = H(e.url);
143
+ if (a === null) return { kind: "pass", mark: null };
144
+ const s = (r == null ? void 0 : r.preset) ?? (r ? "fail-saves" : "pretend-down");
145
+ if (q.test(a))
146
+ return { kind: "pass", mark: $.test(a) ? s : null };
147
+ const i = (e.method ?? "GET").toUpperCase();
148
+ for (const d of l.values()) {
149
+ const E = d.find((w) => w.patterns.some((L) => L.test(a)));
150
+ if (E) {
151
+ const w = E.status ?? 503;
152
+ return {
153
+ kind: "status",
154
+ delayMs: f(t, 150, 600),
155
+ status: w,
156
+ statusText: j[w] ?? "Service Unavailable",
157
+ body: JSON.stringify({ error: `${E.label} is unavailable` }),
158
+ contentType: "application/json; charset=utf-8",
159
+ mark: "pretend-down"
160
+ };
161
+ }
162
+ }
163
+ if (!r) return { kind: "pass", mark: null };
164
+ if (r.failWrites > 0 && G(i, a))
165
+ return o = { ...r, failWrites: r.failWrites - 1 }, M(), p(), {
166
+ kind: "status",
167
+ delayMs: f(t, 100, 400),
168
+ status: 500,
169
+ statusText: "Internal Server Error",
170
+ body: JSON.stringify({
171
+ statusCode: 500,
172
+ error: "Internal Server Error",
173
+ message: "Internal Server Error"
174
+ }),
175
+ contentType: "application/json; charset=utf-8",
176
+ mark: "fail-saves"
177
+ };
178
+ switch (r.preset) {
179
+ case "offline":
180
+ return { kind: "network", delayMs: 0, mark: s };
181
+ case "api-down":
182
+ return {
183
+ kind: "status",
184
+ delayMs: f(t, 20, 120),
185
+ ...X,
186
+ body: "Service Unavailable",
187
+ contentType: "text/plain; charset=utf-8",
188
+ mark: s
189
+ };
190
+ case "slow":
191
+ return { kind: "delay", ms: Math.max(0, Math.round(r.strength * (0.8 + t() * 0.4))) };
192
+ case "flaky":
193
+ return t() * 100 < r.strength ? { kind: "network", delayMs: f(t, 100, 1500), mark: s } : { kind: "delay", ms: f(t, 50, 800) };
194
+ default:
195
+ return { kind: "pass", mark: null };
196
+ }
197
+ }
198
+ function T() {
199
+ try {
200
+ return new DOMException("The user aborted a request.", "AbortError");
201
+ } catch {
202
+ const e = new Error("The user aborted a request.");
203
+ return e.name = "AbortError", e;
204
+ }
205
+ }
206
+ function c(e, t) {
207
+ return e <= 0 ? t != null && t.aborted ? Promise.reject(T()) : Promise.resolve() : new Promise((n, r) => {
208
+ if (t != null && t.aborted) return r(T());
209
+ const a = setTimeout(() => {
210
+ t == null || t.removeEventListener("abort", s), n();
211
+ }, e), s = () => {
212
+ clearTimeout(a), r(T());
213
+ };
214
+ t == null || t.addEventListener("abort", s, { once: !0 });
215
+ });
216
+ }
217
+ function F(e) {
218
+ return typeof e == "string" ? e : e instanceof URL ? e.href : e.url;
219
+ }
220
+ function J(e) {
221
+ return async (n, r) => {
222
+ if (!I()) return e(n, r);
223
+ const a = (r == null ? void 0 : r.method) ?? (typeof Request < "u" && n instanceof Request ? n.method : "GET"), s = x({ method: a, url: F(n) }), i = (r == null ? void 0 : r.signal) ?? (typeof Request < "u" && n instanceof Request ? n.signal : null);
224
+ switch (s.kind) {
225
+ case "pass": {
226
+ if (!s.mark) return e(n, r);
227
+ const d = new Headers(
228
+ (r == null ? void 0 : r.headers) ?? (typeof Request < "u" && n instanceof Request ? n.headers : void 0)
229
+ );
230
+ return d.set(h, s.mark), e(n, { ...r, headers: d });
231
+ }
232
+ case "delay":
233
+ return await c(s.ms, i), e(n, r);
234
+ case "network":
235
+ throw await c(s.delayMs, i), new TypeError("Failed to fetch");
236
+ case "status":
237
+ return await c(s.delayMs, i), new Response(s.body, {
238
+ status: s.status,
239
+ statusText: s.statusText,
240
+ headers: { "content-type": s.contentType, [h]: s.mark }
241
+ });
242
+ }
243
+ };
244
+ }
245
+ let b = !1;
246
+ function ae() {
247
+ if (b || typeof window > "u" || typeof window.fetch != "function") return;
248
+ b = !0, window.fetch = J(window.fetch.bind(window));
249
+ let e = !1;
250
+ const t = () => {
251
+ var r;
252
+ const n = ((r = m()) == null ? void 0 : r.preset) === "offline";
253
+ n !== e && (e = n, V(n));
254
+ };
255
+ N(t), t();
256
+ }
257
+ function V(e) {
258
+ try {
259
+ e ? Object.defineProperty(navigator, "onLine", { configurable: !0, get: () => !1 }) : delete navigator.onLine;
260
+ } catch {
261
+ }
262
+ try {
263
+ window.dispatchEvent(new Event(e ? "offline" : "online"));
264
+ } catch {
265
+ }
266
+ }
267
+ function B(e) {
268
+ const t = e.url ?? "";
269
+ return /^https?:\/\//i.test(t) || !e.baseURL ? t : `${e.baseURL.replace(/\/$/, "")}/${t.replace(/^\//, "")}`;
270
+ }
271
+ function oe(e) {
272
+ return async (t) => {
273
+ if (!I()) return t;
274
+ const n = x({ method: t.method ?? "get", url: B(t) }), r = t.signal ?? null;
275
+ switch (n.kind) {
276
+ case "pass":
277
+ return n.mark && t.headers && (typeof t.headers.set == "function" ? t.headers.set(h, n.mark) : t.headers[h] = n.mark), t;
278
+ case "delay":
279
+ return await c(n.ms, r), t;
280
+ case "network":
281
+ return t.adapter = async () => {
282
+ throw await c(n.delayMs, r), new e("Network Error", "ERR_NETWORK", t, {});
283
+ }, t;
284
+ case "status":
285
+ return t.adapter = async () => {
286
+ await c(n.delayMs, r);
287
+ let a = n.body;
288
+ if (n.contentType.startsWith("application/json"))
289
+ try {
290
+ a = JSON.parse(n.body);
291
+ } catch {
292
+ }
293
+ const s = {
294
+ data: a,
295
+ status: n.status,
296
+ statusText: n.statusText,
297
+ headers: { "content-type": n.contentType, [h]: n.mark },
298
+ config: t,
299
+ request: {}
300
+ };
301
+ throw new e(
302
+ `Request failed with status code ${n.status}`,
303
+ n.status >= 500 ? "ERR_BAD_RESPONSE" : "ERR_BAD_REQUEST",
304
+ t,
305
+ {},
306
+ s
307
+ );
308
+ }, t;
309
+ }
310
+ };
311
+ }
312
+ const S = /* @__PURE__ */ new WeakSet();
313
+ function ie(e) {
314
+ if (!e || S.has(e)) return () => {
315
+ };
316
+ S.add(e);
317
+ let t = !1;
318
+ const n = () => {
319
+ var s, i;
320
+ const a = W();
321
+ if (a !== t) {
322
+ t = a;
323
+ try {
324
+ typeof e.chaosPause == "function" ? e.chaosPause(a) : a ? (s = e.disconnect) == null || s.call(e) : (i = e.connect) == null || i.call(e);
325
+ } catch {
326
+ }
327
+ }
328
+ }, r = N(n);
329
+ return n(), () => {
330
+ r(), S.delete(e);
331
+ };
332
+ }
333
+ export {
334
+ h as CLIENT_CHAOS_HEADER,
335
+ z as CLIENT_CHAOS_MAX_FAIL_WRITES,
336
+ Y as CLIENT_CHAOS_MAX_MS,
337
+ K as CLIENT_CHAOS_MIN_MS,
338
+ y as CLIENT_CHAOS_STORAGE_KEY,
339
+ D as CLIENT_CHAOS_STRENGTH,
340
+ te as PRETEND_DOWN_EVENT,
341
+ ie as bindClientChaosSocket,
342
+ Q as canUseClientChaos,
343
+ re as clearPretendDown,
344
+ I as clientChaosActive,
345
+ H as clientChaosApiPath,
346
+ oe as clientChaosAxiosInterceptor,
347
+ W as clientSocketGone,
348
+ x as decideClientChaos,
349
+ m as getClientChaos,
350
+ ne as getPretendDown,
351
+ ae as installClientChaosFetch,
352
+ G as isClientChaosWrite,
353
+ se as pretendDownVersion,
354
+ U as setPretendDown,
355
+ Z as startClientChaos,
356
+ ee as stopClientChaos,
357
+ N as subscribeClientChaos,
358
+ J as withClientChaos
359
+ };
@@ -0,0 +1,26 @@
1
+ function a(e) {
2
+ var r;
3
+ const t = e, n = (t == null ? void 0 : t.status) ?? ((r = t == null ? void 0 : t.response) == null ? void 0 : r.status);
4
+ return typeof n == "number" ? n : null;
5
+ }
6
+ function l(e, t = "this") {
7
+ const n = a(e);
8
+ if (n == null) {
9
+ const r = e instanceof Error ? e.message : String(e ?? "");
10
+ return /timed? ?out|timeout/i.test(r) || (e == null ? void 0 : e.name) === "TimeoutError" ? `Couldn’t load ${t}: it is taking too long to answer.` : e instanceof TypeError || /network|failed to fetch|load failed/i.test(r) ? "Can’t reach the server. Check the connection." : `Couldn’t load ${t}.`;
11
+ }
12
+ return n === 502 || n === 503 || n === 504 ? "The service behind this is unavailable right now." : n === 401 ? "Your sign-in has ended. Sign in again to see it." : n === 403 ? "You don’t have access to this." : n === 404 ? `${t === "this" ? "This" : t[0].toUpperCase() + t.slice(1)} no longer exists.` : n === 429 ? "Too many requests just now. Try again in a moment." : n >= 500 ? `The server hit an error loading ${t}.` : `Couldn’t load ${t}.`;
13
+ }
14
+ const u = /^(service unavailable|internal server error|bad gateway|gateway timeout|not found|forbidden|unauthorized)$/i;
15
+ function c(e) {
16
+ var o, i, s;
17
+ const t = e, n = ((i = (o = t == null ? void 0 : t.response) == null ? void 0 : o.data) == null ? void 0 : i.error) ?? ((s = t == null ? void 0 : t.response) == null ? void 0 : s.error);
18
+ if (typeof n != "string") return null;
19
+ const r = n.trim();
20
+ return !r || u.test(r) ? null : r.length > 200 ? `${r.slice(0, 197)}…` : r;
21
+ }
22
+ export {
23
+ a as loadErrorStatus,
24
+ l as loadErrorText,
25
+ c as serverErrorText
26
+ };
@@ -1,29 +1,38 @@
1
- import { isCleanRecording as l } from "../components/help-videos/recorder/cleanRecording.js";
2
- import { shouldPlayHere as f } from "./tab-sound.js";
3
- let r = null;
4
- function s() {
1
+ import { isCleanRecording as f } from "../components/help-videos/recorder/cleanRecording.js";
2
+ import { shouldPlayHere as l } from "./tab-sound.js";
3
+ let u = null;
4
+ function d() {
5
5
  if (typeof window > "u") return null;
6
6
  try {
7
- return r || (r = new AudioContext()), r.state === "suspended" && r.resume().catch(() => {
8
- }), r;
7
+ return u || (u = new AudioContext()), u.state === "suspended" && u.resume().catch(() => {
8
+ }), u;
9
9
  } catch {
10
10
  return null;
11
11
  }
12
12
  }
13
- function u(n, c, e, t, a) {
14
- const i = n.createOscillator(), o = n.createGain();
15
- i.type = "sine", i.frequency.value = c, o.gain.setValueAtTime(1e-4, e), o.gain.exponentialRampToValueAtTime(a, e + 0.015), o.gain.exponentialRampToValueAtTime(1e-4, e + t), i.connect(o), o.connect(n.destination), i.start(e), i.stop(e + t + 0.05);
13
+ function a(n, o, t, e, r) {
14
+ const i = n.createOscillator(), c = n.createGain();
15
+ i.type = "sine", i.frequency.value = o, c.gain.setValueAtTime(1e-4, t), c.gain.exponentialRampToValueAtTime(r, t + 0.015), c.gain.exponentialRampToValueAtTime(1e-4, t + e), i.connect(c), c.connect(n.destination), i.start(t), i.stop(t + e + 0.05);
16
16
  }
17
- function d(n, c = {}) {
18
- if (!n || n === "off" || l() || !c.preview && !f()) return;
19
- const e = s();
20
- if (e)
17
+ function y(n, o = {}) {
18
+ if (!n || n === "off" || f() || !o.preview && !l()) return;
19
+ const t = d();
20
+ if (t)
21
21
  try {
22
- const t = e.currentTime;
23
- n === "chime" ? (u(e, 660, t, 0.14, 0.06), u(e, 880, t + 0.12, 0.2, 0.06)) : u(e, 880, t, 0.09, 0.03);
22
+ const e = t.currentTime;
23
+ n === "chime" ? (a(t, 660, e, 0.14, 0.06), a(t, 880, e + 0.12, 0.2, 0.06)) : a(t, 880, e, 0.09, 0.03);
24
24
  } catch {
25
25
  }
26
26
  }
27
+ function g(n, o) {
28
+ const t = n == null ? void 0 : n.notification_sounds;
29
+ if (o && t && typeof t == "object") {
30
+ const e = t[o];
31
+ if (e === "off" || e === "subtle" || e === "chime") return e;
32
+ }
33
+ return typeof (n == null ? void 0 : n.notification_sound) == "string" ? n.notification_sound : "off";
34
+ }
27
35
  export {
28
- d as playNotificationSound
36
+ y as playNotificationSound,
37
+ g as soundForCategory
29
38
  };