@nivaro/react 0.3.15 → 0.3.17

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 (37) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +127 -6
  4. package/dist/index.js +736 -734
  5. package/dist/shared/components/CollectionBrowserView.js +2344 -2309
  6. package/dist/shared/components/ItemEditForm.js +3773 -3604
  7. package/dist/shared/components/RecordGridEditor.js +319 -282
  8. package/dist/shared/components/RecordReadView.js +202 -200
  9. package/dist/shared/components/cbv/unknown-fields.js +18 -8
  10. package/dist/shared/components/chat/ChatAnalyticsView.js +2 -2
  11. package/dist/shared/components/import/DocumentAutofillButton.js +148 -142
  12. package/dist/shared/components/item-edit/CatalogPickerField.js +264 -276
  13. package/dist/shared/components/item-edit/FieldRenderer.js +136 -133
  14. package/dist/shared/components/item-edit/FieldRow.js +198 -184
  15. package/dist/shared/components/item-edit/HeaderTools.js +107 -99
  16. package/dist/shared/components/item-edit/InlineTableField.js +138 -136
  17. package/dist/shared/components/item-edit/RecordLiveSync.js +1 -0
  18. package/dist/shared/components/item-edit/RelationCombobox.js +30 -23
  19. package/dist/shared/components/item-edit/SummaryPanel.js +334 -294
  20. package/dist/shared/components/item-edit/column-length.js +12 -0
  21. package/dist/shared/components/panels/AccessDeniedPanel.js +47 -37
  22. package/dist/shared/components/panels/ItemLockBanner.js +307 -285
  23. package/dist/shared/components/panels/PipelinePanel.js +486 -465
  24. package/dist/shared/components/panels/RevisionsPanel.js +210 -204
  25. package/dist/shared/components/pipeline/PipelineEditorView.js +1672 -1568
  26. package/dist/shared/components/profile/DelegationCard.js +178 -121
  27. package/dist/shared/components/profile/PersonActivity.js +152 -139
  28. package/dist/shared/components/queue/QueueWorklist.js +668 -659
  29. package/dist/shared/components/queue/transition-note.js +90 -0
  30. package/dist/shared/components/support/SupportRequestDialog.js +100 -89
  31. package/dist/shared/components/support/TicketDetailSheet.js +104 -91
  32. package/dist/shared/lib/autofill-runs.js +33 -26
  33. package/dist/shared/lib/draft-store.js +40 -24
  34. package/dist/shared/lib/live-queries.js +10 -9
  35. package/dist/shared/lib/request-gate.js +140 -127
  36. package/dist/shared/lib/restore-skipped.js +10 -0
  37. package/package.json +1 -1
@@ -1,24 +1,24 @@
1
- import { jsx as a, jsxs as r, Fragment as h } from "react/jsx-runtime";
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
- import { useState as w } from "react";
5
- import { useNivaroClient as O, useApiFetchConfig as E, useItemNavigation as H, useNavigation as W } from "../../context.js";
6
- import { get as _, post as S, patch as B } from "../../lib/commands.js";
7
- import { useTopicPresence as G, signalSentence as q } from "../../lib/presence-signals.js";
8
- import { replayHref as M } from "../../lib/replay-capture.js";
9
- import { TaskDoButton as z } from "../ai/TaskDo.js";
10
- import { RelationCombobox as J } from "../item-edit/RelationCombobox.js";
11
- import { SimpleSelect as C } from "../ui/SimpleSelect.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";
14
- import { STATUS_TONE as T } from "./types.js";
15
- const $ = [
1
+ import { jsx as a, jsxs as r, Fragment as y } from "react/jsx-runtime";
2
+ import { useQueryClient as O, useQuery as _, useMutation as f } from "@tanstack/react-query";
3
+ import { Loader2 as H, PlayCircle as W, Paperclip as B } from "lucide-react";
4
+ import { useState as S } from "react";
5
+ import { useNivaroClient as G, useApiFetchConfig as M, useItemNavigation as z, useNavigation as J } from "../../context.js";
6
+ import { get as q, post as T, patch as V } from "../../lib/commands.js";
7
+ import { useTopicPresence as X, signalSentence as C } from "../../lib/presence-signals.js";
8
+ import { replayHref as Y } from "../../lib/replay-capture.js";
9
+ import { TaskDoButton as Z } from "../ai/TaskDo.js";
10
+ import { RelationCombobox as I } from "../item-edit/RelationCombobox.js";
11
+ import { SimpleSelect as $ } from "../ui/SimpleSelect.js";
12
+ import { Sheet as ee, SheetContent as te, SheetTitle as K, SheetDescription as F, SheetHeader as ae } from "../ui/sheet.js";
13
+ import { TicketTraffic as re } from "./TicketTraffic.js";
14
+ import { STATUS_TONE as R } from "./types.js";
15
+ const P = [
16
16
  { value: "open", label: "Open" },
17
17
  { value: "in_progress", label: "In progress" },
18
18
  { value: "done", label: "Done" },
19
19
  { value: "cancelled", label: "Cancelled" }
20
20
  ];
21
- function y(n) {
21
+ function b(n) {
22
22
  return n ? new Date(n).toLocaleString(void 0, {
23
23
  month: "short",
24
24
  day: "numeric",
@@ -26,92 +26,105 @@ function y(n) {
26
26
  minute: "2-digit"
27
27
  }) : "";
28
28
  }
29
- function te({ status: n, label: c }) {
30
- var s;
29
+ function ne({ status: n, label: c }) {
30
+ var l;
31
31
  return /* @__PURE__ */ a(
32
32
  "span",
33
33
  {
34
34
  "data-ticket-status": n,
35
- className: `inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${T[n] ?? T.open}`,
36
- children: c ?? ((s = $.find((l) => l.value === n)) == null ? void 0 : s.label) ?? n
35
+ className: `inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${R[n] ?? R.open}`,
36
+ children: c ?? ((l = P.find((i) => i.value === n)) == null ? void 0 : l.label) ?? n
37
37
  }
38
38
  );
39
39
  }
40
- function ge({
40
+ function be({
41
41
  ticketId: n,
42
42
  onOpenChange: c
43
43
  }) {
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
+ const l = G(), i = O(), { apiBase: j } = M(), { urlFor: D, open: Q } = z(), m = J(), [u, v] = S(""), [k, A] = S(null), o = X(
45
+ n != null && Number.isSafeInteger(n) && n > 0 ? `ticket:${n}` : null
46
+ ), p = n != null && Number.isSafeInteger(n) && n > 0, {
47
+ data: e,
48
+ isLoading: U,
49
+ isError: L
50
+ } = _({
45
51
  queryKey: ["support-ticket", n],
46
- queryFn: () => s.request(_(`/support/tickets/${n}`)).then((t) => t.data),
47
- enabled: n != null
48
- }), { data: R = [] } = N({
52
+ queryFn: () => l.request(q(`/support/tickets/${n}`)).then((t) => t.data),
53
+ enabled: p,
54
+ retry: (t, s) => {
55
+ const g = s == null ? void 0 : s.status;
56
+ return g !== 404 && g !== 403 && g !== 400 && t < 2;
57
+ }
58
+ }), { data: E = [] } = _({
49
59
  queryKey: ["support-categories", "all-for", (e == null ? void 0 : e.collection) ?? null],
50
- queryFn: () => s.request(
51
- _("/support/categories", e != null && e.collection ? { collection: e.collection } : void 0)
60
+ queryFn: () => l.request(
61
+ q("/support/categories", e != null && e.collection ? { collection: e.collection } : void 0)
52
62
  ).then((t) => t.data ?? []),
53
63
  enabled: !!(e != null && e.can.work)
54
- }), u = () => {
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`)),
58
- onSuccess: u,
59
- onError: x
60
- }), o = g({
61
- mutationFn: (t) => s.request(B(`/support/tickets/${n}`, t)),
62
- onSuccess: u,
63
- onError: x
64
- }), v = g({
65
- mutationFn: () => s.request(S(`/support/tickets/${n}/comments`, { text: p.trim() })),
64
+ }), x = () => {
65
+ i.invalidateQueries({ queryKey: ["support-ticket", n] }), i.invalidateQueries({ queryKey: ["support-tickets"] }), i.invalidateQueries({ queryKey: ["support-summary"] }), i.invalidateQueries({ queryKey: ["my-work"] });
66
+ }, h = (t) => A(t.message || "That did not work"), N = f({
67
+ mutationFn: () => l.request(T(`/support/tickets/${n}/claim`)),
68
+ onSuccess: x,
69
+ onError: h
70
+ }), d = f({
71
+ mutationFn: (t) => l.request(V(`/support/tickets/${n}`, t)),
72
+ onSuccess: x,
73
+ onError: h
74
+ }), w = f({
75
+ mutationFn: () => l.request(T(`/support/tickets/${n}/comments`, { text: u.trim() })),
66
76
  onSuccess: () => {
67
- f(""), i.signalReplying(!1), u();
77
+ v(""), o.signalReplying(!1), x();
68
78
  },
69
- onError: x
79
+ onError: h
70
80
  });
71
- return /* @__PURE__ */ a(V, { open: n != null, onOpenChange: c, children: /* @__PURE__ */ a(
72
- X,
81
+ return /* @__PURE__ */ a(ee, { open: n != null, onOpenChange: c, children: /* @__PURE__ */ a(
82
+ te,
73
83
  {
74
84
  side: "right",
75
85
  className: "flex w-[560px] max-w-[96vw] flex-col gap-0 p-0 sm:max-w-[560px] dark:bg-card",
76
86
  "data-support-ticket": n ?? "",
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: [
87
+ children: !p || L ? /* @__PURE__ */ r("div", { className: "flex flex-1 flex-col items-center justify-center gap-1 px-6 text-center", children: [
88
+ /* @__PURE__ */ a(K, { className: "text-[14px] font-semibold text-slate-800 dark:text-slate-100", children: "Request not found" }),
89
+ /* @__PURE__ */ a(F, { className: "text-[12.5px] text-slate-500 dark:text-muted-foreground", children: p ? `Request #${n} does not exist, or it is not one you can open.` : "This link does not point to a request." })
90
+ ] }) : U || !e ? /* @__PURE__ */ a("div", { className: "flex flex-1 items-center justify-center text-slate-400", children: /* @__PURE__ */ a(H, { className: "h-5 w-5 animate-spin" }) }) : /* @__PURE__ */ r(y, { children: [
91
+ /* @__PURE__ */ r(ae, { className: "border-b border-slate-200 px-5 py-4 dark:border-border", children: [
79
92
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 pr-6", children: [
80
93
  /* @__PURE__ */ r("span", { className: "font-mono text-[11.5px] text-slate-400", children: [
81
94
  "#",
82
95
  e.id
83
96
  ] }),
84
- /* @__PURE__ */ a(te, { status: e.status, label: e.status_label }),
97
+ /* @__PURE__ */ a(ne, { status: e.status, label: e.status_label }),
85
98
  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" })
86
99
  ] }),
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: [
100
+ /* @__PURE__ */ a(K, { className: "mt-1 text-left text-[16px] font-semibold text-slate-900 dark:text-slate-100", children: e.title }),
101
+ /* @__PURE__ */ r(F, { className: "text-left text-[12px] text-slate-500 dark:text-muted-foreground", children: [
89
102
  e.requester_name ?? "Someone",
90
103
  " · ",
91
- y(e.created_at),
104
+ b(e.created_at),
92
105
  e.category_name ? ` · ${e.category_name}` : ""
93
106
  ] }),
94
107
  /* @__PURE__ */ a("div", { className: "mt-1 text-[12px]", children: e.collection && e.item ? /* @__PURE__ */ a(
95
108
  "a",
96
109
  {
97
- href: F({ collection: e.collection, itemId: e.item }),
110
+ href: D({ collection: e.collection, itemId: e.item }),
98
111
  onClick: (t) => {
99
- t.metaKey || t.ctrlKey || t.shiftKey || t.button !== 0 || (t.preventDefault(), P({ collection: e.collection, itemId: e.item }));
112
+ t.metaKey || t.ctrlKey || t.shiftKey || t.button !== 0 || (t.preventDefault(), Q({ collection: e.collection, itemId: e.item }));
100
113
  },
101
114
  "data-ticket-record": !0,
102
115
  className: "font-medium text-[#00789a] hover:underline dark:text-nvr-cyan",
103
116
  children: e.record_label ?? e.item
104
117
  }
105
118
  ) : /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: "General Support" }) }),
106
- i.viewers.length > 0 && /* @__PURE__ */ r(
119
+ o.viewers.length > 0 && /* @__PURE__ */ r(
107
120
  "p",
108
121
  {
109
122
  className: "mt-1 flex items-center gap-1.5 text-[11.5px] text-sky-700 dark:text-sky-300",
110
123
  "data-ticket-viewing": !0,
111
124
  children: [
112
125
  /* @__PURE__ */ a("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-sky-400" }),
113
- q(
114
- i.viewers.map((t) => t.name),
126
+ C(
127
+ o.viewers.map((t) => t.name),
115
128
  "looking at this"
116
129
  )
117
130
  ]
@@ -126,15 +139,15 @@ function ge({
126
139
  className: "grid grid-cols-2 gap-3 rounded-lg border border-slate-200 p-3 dark:border-border",
127
140
  children: [
128
141
  /* @__PURE__ */ r("div", { className: "col-span-2 flex items-center justify-between gap-2", children: [
129
- /* @__PURE__ */ a("span", { className: "text-[12px] text-slate-600 dark:text-slate-300", children: e.assignee_name ? /* @__PURE__ */ r(h, { children: [
142
+ /* @__PURE__ */ a("span", { className: "text-[12px] text-slate-600 dark:text-slate-300", children: e.assignee_name ? /* @__PURE__ */ r(y, { children: [
130
143
  "Assigned to ",
131
144
  /* @__PURE__ */ a("b", { className: "font-medium", children: e.assignee_name })
132
- ] }) : /* @__PURE__ */ r(h, { children: [
145
+ ] }) : /* @__PURE__ */ r(y, { children: [
133
146
  "Not picked up yet",
134
147
  e.team_name ? ` · ${e.team_name}` : " · Administrators"
135
148
  ] }) }),
136
149
  /* @__PURE__ */ a(
137
- z,
150
+ Z,
138
151
  {
139
152
  task: {
140
153
  id: e.id,
@@ -144,7 +157,7 @@ function ge({
144
157
  category_id: e.category_id,
145
158
  title: e.title
146
159
  },
147
- onTaskChanged: () => void l.invalidateQueries({ queryKey: ["support-ticket", n] })
160
+ onTaskChanged: () => void i.invalidateQueries({ queryKey: ["support-ticket", n] })
148
161
  }
149
162
  ),
150
163
  (e.status === "open" || e.status === "in_progress") && /* @__PURE__ */ a(
@@ -152,8 +165,8 @@ function ge({
152
165
  {
153
166
  type: "button",
154
167
  "data-ticket-claim": !0,
155
- disabled: k.isPending,
156
- onClick: () => k.mutate(),
168
+ disabled: N.isPending,
169
+ onClick: () => N.mutate(),
157
170
  className: "h-7 rounded-md border border-nvr-cyan/60 bg-nvr-cyan/10 px-2.5 text-[12px] font-medium text-nvr-navy hover:bg-nvr-cyan/15 disabled:opacity-50 dark:text-nvr-cyan",
158
171
  children: e.assignee ? "Take it over" : "Pick it up"
159
172
  }
@@ -162,11 +175,11 @@ function ge({
162
175
  /* @__PURE__ */ r("div", { className: "block text-[11px] font-medium text-slate-500 dark:text-muted-foreground", children: [
163
176
  "Status",
164
177
  /* @__PURE__ */ a(
165
- C,
178
+ $,
166
179
  {
167
180
  value: e.status,
168
- onChange: (t) => o.mutate({ status: t }),
169
- options: $,
181
+ onChange: (t) => d.mutate({ status: t }),
182
+ options: P,
170
183
  ariaLabel: "Status",
171
184
  className: "mt-1"
172
185
  }
@@ -175,13 +188,13 @@ function ge({
175
188
  /* @__PURE__ */ r("div", { className: "block text-[11px] font-medium text-slate-500 dark:text-muted-foreground", children: [
176
189
  "Type",
177
190
  /* @__PURE__ */ a(
178
- C,
191
+ $,
179
192
  {
180
193
  value: e.category_id != null ? String(e.category_id) : "",
181
- onChange: (t) => o.mutate({ category_id: t ? Number(t) : null }),
194
+ onChange: (t) => d.mutate({ category_id: t ? Number(t) : null }),
182
195
  options: [
183
196
  { value: "", label: "No type" },
184
- ...R.map((t) => ({ value: String(t.id), label: t.name }))
197
+ ...E.map((t) => ({ value: String(t.id), label: t.name }))
185
198
  ],
186
199
  ariaLabel: "Type",
187
200
  className: "mt-1"
@@ -191,11 +204,11 @@ function ge({
191
204
  /* @__PURE__ */ r("div", { className: "col-span-2 text-[11px] font-medium text-slate-500 dark:text-muted-foreground", children: [
192
205
  "Assignee",
193
206
  /* @__PURE__ */ a("div", { className: "mt-1", children: /* @__PURE__ */ a(
194
- J,
207
+ I,
195
208
  {
196
209
  collection: "nivaro_users",
197
210
  value: e.assignee,
198
- onChange: (t) => o.mutate({ assignee: t ? String(t) : null }),
211
+ onChange: (t) => d.mutate({ assignee: t ? String(t) : null }),
199
212
  placeholder: "Nobody yet"
200
213
  }
201
214
  ) })
@@ -207,28 +220,28 @@ function ge({
207
220
  /* @__PURE__ */ a("h3", { className: "mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-muted-foreground", children: "Request" }),
208
221
  /* @__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." }) }),
209
222
  e.replay && e.can.work && (() => {
210
- const t = M(e.replay), d = m.consoleUrl ? m.consoleUrl(t) : t;
211
- return d ? /* @__PURE__ */ r(
223
+ const t = Y(e.replay), s = m.consoleUrl ? m.consoleUrl(t) : t;
224
+ return s ? /* @__PURE__ */ r(
212
225
  "a",
213
226
  {
214
- href: d,
227
+ href: s,
215
228
  target: "_blank",
216
229
  rel: "noreferrer",
217
230
  "data-ticket-replay": e.replay.recording_id,
218
231
  className: "mt-2 inline-flex items-center gap-1.5 rounded-md border border-nvr-cyan/50 bg-nvr-cyan/10 px-2 py-1 text-[12px] font-medium text-nvr-navy hover:bg-nvr-cyan/15 dark:text-nvr-cyan",
219
232
  children: [
220
- /* @__PURE__ */ a(U, { className: "h-3.5 w-3.5" }),
233
+ /* @__PURE__ */ a(W, { className: "h-3.5 w-3.5" }),
221
234
  "Watch what they saw"
222
235
  ]
223
236
  }
224
237
  ) : null;
225
238
  })(),
226
239
  e.issue_id != null && e.can.work && (() => {
227
- const t = `/issues/${e.issue_id}`, d = m.consoleUrl ? m.consoleUrl(t) : t;
228
- return d ? /* @__PURE__ */ r(
240
+ const t = `/issues/${e.issue_id}`, s = m.consoleUrl ? m.consoleUrl(t) : t;
241
+ return s ? /* @__PURE__ */ r(
229
242
  "a",
230
243
  {
231
- href: d,
244
+ href: s,
232
245
  target: "_blank",
233
246
  rel: "noreferrer",
234
247
  "data-ticket-issue": e.issue_id,
@@ -243,18 +256,18 @@ function ge({
243
256
  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(
244
257
  "a",
245
258
  {
246
- href: `${K}/files/${t.id}`,
259
+ href: `${j}/files/${t.id}`,
247
260
  target: "_blank",
248
261
  rel: "noreferrer",
249
262
  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",
250
263
  children: [
251
- /* @__PURE__ */ a(L, { className: "h-3 w-3" }),
264
+ /* @__PURE__ */ a(B, { className: "h-3 w-3" }),
252
265
  t.title || t.filename_download || "File"
253
266
  ]
254
267
  }
255
268
  ) }, t.id)) })
256
269
  ] }),
257
- e.can.work && /* @__PURE__ */ a(ee, { ticketId: e.id }),
270
+ e.can.work && /* @__PURE__ */ a(re, { ticketId: e.id }),
258
271
  /* @__PURE__ */ r("section", { "data-ticket-thread": !0, children: [
259
272
  /* @__PURE__ */ a("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-muted-foreground", children: "Conversation" }),
260
273
  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(
@@ -264,7 +277,7 @@ function ge({
264
277
  children: [
265
278
  /* @__PURE__ */ r("div", { className: "mb-0.5 flex items-baseline justify-between gap-2 text-[11.5px]", children: [
266
279
  /* @__PURE__ */ a("b", { className: "font-medium text-slate-800 dark:text-slate-100", children: t.user_name ?? "Someone" }),
267
- /* @__PURE__ */ a("span", { className: "text-slate-400", children: y(t.created_at) })
280
+ /* @__PURE__ */ a("span", { className: "text-slate-400", children: b(t.created_at) })
268
281
  ] }),
269
282
  /* @__PURE__ */ a("p", { className: "whitespace-pre-wrap text-[12.5px] text-slate-700 dark:text-slate-200", children: t.text })
270
283
  ]
@@ -276,30 +289,30 @@ function ge({
276
289
  {
277
290
  className: "mt-3",
278
291
  onSubmit: (t) => {
279
- t.preventDefault(), p.trim() && v.mutate();
292
+ t.preventDefault(), u.trim() && w.mutate();
280
293
  },
281
294
  children: [
282
295
  /* @__PURE__ */ a(
283
296
  "textarea",
284
297
  {
285
298
  "data-ticket-reply": !0,
286
- value: p,
299
+ value: u,
287
300
  onChange: (t) => {
288
- f(t.target.value), i.signalReplying(!!t.target.value.trim());
301
+ v(t.target.value), o.signalReplying(!!t.target.value.trim());
289
302
  },
290
303
  rows: 3,
291
304
  placeholder: "Write a reply",
292
305
  className: "w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-[12.5px] text-slate-900 outline-none focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-100"
293
306
  }
294
307
  ),
295
- i.replying.length > 0 && /* @__PURE__ */ r(
308
+ o.replying.length > 0 && /* @__PURE__ */ r(
296
309
  "p",
297
310
  {
298
311
  className: "mt-1 flex items-center gap-1.5 text-[11.5px] italic text-slate-400",
299
312
  "data-ticket-replying": !0,
300
313
  children: [
301
314
  /* @__PURE__ */ a("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-nvr-cyan" }),
302
- q(i.replying, "replying"),
315
+ C(o.replying, "replying"),
303
316
  "…"
304
317
  ]
305
318
  }
@@ -310,7 +323,7 @@ function ge({
310
323
  {
311
324
  type: "button",
312
325
  "data-ticket-cancel": !0,
313
- onClick: () => o.mutate({ status: "cancelled" }),
326
+ onClick: () => d.mutate({ status: "cancelled" }),
314
327
  className: "h-7 rounded-md px-2.5 text-[12px] text-slate-500 hover:text-slate-800 dark:hover:text-slate-100",
315
328
  children: "Withdraw request"
316
329
  }
@@ -320,7 +333,7 @@ function ge({
320
333
  {
321
334
  type: "button",
322
335
  "data-ticket-reopen": !0,
323
- onClick: () => o.mutate({ status: "open" }),
336
+ onClick: () => d.mutate({ status: "open" }),
324
337
  className: "h-7 rounded-md px-2.5 text-[12px] text-slate-500 hover:text-slate-800 dark:hover:text-slate-100",
325
338
  children: "Reopen"
326
339
  }
@@ -330,7 +343,7 @@ function ge({
330
343
  {
331
344
  type: "submit",
332
345
  "data-ticket-send": !0,
333
- disabled: !p.trim() || v.isPending,
346
+ disabled: !u.trim() || w.isPending,
334
347
  className: "h-7 rounded-md border border-nvr-cyan/60 bg-nvr-cyan/10 px-2.5 text-[12px] font-medium text-nvr-navy hover:bg-nvr-cyan/15 disabled:opacity-50 dark:text-nvr-cyan",
335
348
  children: "Reply"
336
349
  }
@@ -339,7 +352,7 @@ function ge({
339
352
  ]
340
353
  }
341
354
  ),
342
- b && /* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-red-600 dark:text-red-400", role: "alert", children: b })
355
+ k && /* @__PURE__ */ a("p", { className: "mt-1 text-[12px] text-red-600 dark:text-red-400", role: "alert", children: k })
343
356
  ] }),
344
357
  /* @__PURE__ */ r("section", { "data-ticket-history": !0, children: [
345
358
  /* @__PURE__ */ a("h3", { className: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-muted-foreground", children: "History" }),
@@ -350,7 +363,7 @@ function ge({
350
363
  "· ",
351
364
  t.user_name ?? "System",
352
365
  " · ",
353
- y(t.at)
366
+ b(t.at)
354
367
  ] })
355
368
  ] }, t.id)) })
356
369
  ] })
@@ -360,6 +373,6 @@ function ge({
360
373
  ) });
361
374
  }
362
375
  export {
363
- te as StatusPill,
364
- ge as TicketDetailSheet
376
+ ne as StatusPill,
377
+ be as TicketDetailSheet
365
378
  };
@@ -1,8 +1,8 @@
1
1
  import { useSyncExternalStore as g } from "react";
2
- import { pollProposal as R } from "./autofill-poll.js";
2
+ import { pollProposal as A } from "./autofill-poll.js";
3
3
  let n = [];
4
4
  const r = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), c = "nvr:autofill-runs";
5
- function h() {
5
+ function R() {
6
6
  try {
7
7
  const e = n.map((t) => ({
8
8
  id: t.id,
@@ -15,32 +15,35 @@ function h() {
15
15
  }
16
16
  }
17
17
  function a() {
18
- n = [...n], h();
18
+ n = [...n], R();
19
19
  for (const e of u) e();
20
20
  }
21
21
  function l(e, t) {
22
22
  const o = n.findIndex((i) => i.id === e);
23
23
  o < 0 || (n[o] = { ...n[o], ...t }, a());
24
24
  }
25
- function m() {
25
+ function p() {
26
26
  return n;
27
27
  }
28
28
  function d(e) {
29
29
  return n.find((t) => t.id === e);
30
30
  }
31
- function A(e) {
31
+ function h(e) {
32
32
  return u.add(e), () => {
33
33
  u.delete(e);
34
34
  };
35
35
  }
36
- function S() {
37
- return g(A, m, m);
36
+ function I() {
37
+ return g(h, p, p);
38
38
  }
39
39
  function E(e) {
40
- const t = S();
40
+ const t = I();
41
41
  return e ? t.find((o) => o.id === e) : void 0;
42
42
  }
43
- function I(e, t, o = {}) {
43
+ function v(e) {
44
+ return typeof e == "string" && /^[A-Za-z0-9-]{8,64}$/.test(e);
45
+ }
46
+ function S(e, t, o = {}) {
44
47
  const i = d(t.id);
45
48
  if (i) return i;
46
49
  const f = {
@@ -55,12 +58,15 @@ function I(e, t, o = {}) {
55
58
  presented: !1
56
59
  };
57
60
  n = [...n, f], a();
58
- const p = (o.poll ?? R)({
61
+ const m = (o.poll ?? A)({
59
62
  fetchResult: async () => {
60
- const s = await fetch(`${e.apiBase}/ai/extract-record/result/${t.id}`, {
61
- headers: e.authHeaders,
62
- credentials: e.credentials
63
- }), y = await s.json().catch(() => ({}));
63
+ const s = await fetch(
64
+ `${e.apiBase}/ai/extract-record/result/${encodeURIComponent(t.id)}`,
65
+ {
66
+ headers: e.authHeaders,
67
+ credentials: e.credentials
68
+ }
69
+ ), y = await s.json().catch(() => ({}));
64
70
  return { status: s.status, ok: s.ok, json: y };
65
71
  },
66
72
  onRunning: (s) => {
@@ -70,17 +76,17 @@ function I(e, t, o = {}) {
70
76
  onError: (s) => l(t.id, { status: "failed", error: s }),
71
77
  onSettled: () => r.delete(t.id)
72
78
  });
73
- return r.set(t.id, p), f;
79
+ return r.set(t.id, m), f;
74
80
  }
75
- function v(e, t) {
81
+ function O(e, t) {
76
82
  const o = d(e);
77
83
  o && o.presented !== t && l(e, { presented: t });
78
84
  }
79
- function O(e) {
85
+ function P(e) {
80
86
  var t;
81
87
  (t = r.get(e)) == null || t(), r.delete(e), d(e) && (n = n.filter((o) => o.id !== e), a());
82
88
  }
83
- function b(e) {
89
+ function $(e) {
84
90
  let t = [];
85
91
  try {
86
92
  const o = sessionStorage.getItem(c);
@@ -89,16 +95,17 @@ function b(e) {
89
95
  t = [];
90
96
  }
91
97
  for (const o of t)
92
- o && typeof o.id == "string" && typeof o.collection == "string" && I(e, o);
98
+ o && typeof o.id == "string" && typeof o.collection == "string" && S(e, o);
93
99
  }
94
100
  export {
95
- O as dismissAutofillRun,
101
+ P as dismissAutofillRun,
96
102
  d as getAutofillRun,
97
- m as getAutofillRuns,
98
- b as hydrateAutofillRuns,
99
- v as setAutofillRunPresented,
100
- I as startAutofillRun,
101
- A as subscribeAutofillRuns,
103
+ p as getAutofillRuns,
104
+ $ as hydrateAutofillRuns,
105
+ v as isAutofillProposalId,
106
+ O as setAutofillRunPresented,
107
+ S as startAutofillRun,
108
+ h as subscribeAutofillRuns,
102
109
  E as useAutofillRun,
103
- S as useAutofillRuns
110
+ I as useAutofillRuns
104
111
  };