@parallelworks/tandem-web 0.189.4 → 0.189.6

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.
@@ -0,0 +1,1473 @@
1
+ import { api as e, unwrap as t } from "../api/client.js";
2
+ import { invalidateIssueViews as n, useUpdateIssue as r } from "../api/mutations.js";
3
+ import { areasQuery as i, attachmentsQuery as a, branchesQuery as o, commentsQuery as s, cyclesQuery as c, eventsQuery as l, issueDecisionsQuery as u, issueDocsQuery as d, issueLinksQuery as f, issueQuery as p, labelsQuery as m, meQuery as h, projectsQuery as g, pullRequestsQuery as _, reactionsQuery as v, runsQuery as y, statusesQuery as b, teamsQuery as x } from "../api/queries.js";
4
+ import { assigneeKey as S, parseAssigneeKey as C, useAssigneeOptions as ee } from "../lib/assignees.js";
5
+ import { actorAvatar as w } from "../lib/avatar.js";
6
+ import { branchName as T } from "../lib/branch.js";
7
+ import { caretColor as te, useCollabSession as E } from "../lib/collab.js";
8
+ import { useConfirm as D } from "../lib/confirm.js";
9
+ import { customFieldsQuery as O, hasValue as k } from "../lib/customFields.js";
10
+ import { docRef as ne, useDocMenu as A } from "../lib/docs.js";
11
+ import { issueURL as j, useIssueMenu as re } from "../lib/issueMenu.js";
12
+ import { issueTypesQuery as M, typeShows as N, typesFor as P } from "../lib/issueTypes.js";
13
+ import { useLinkedIssues as ie } from "../lib/linkedIssues.js";
14
+ import { useOthersOn as ae, useReportLocation as oe } from "../lib/live.js";
15
+ import { copyItem as F } from "../lib/menus.js";
16
+ import { useReadIssueNotifications as se } from "../lib/notifications.js";
17
+ import { connectorActor as ce, usePeople as I } from "../lib/people.js";
18
+ import { PickManyBox as le, usePickMany as ue } from "../lib/pickMany.js";
19
+ import { rememberPage as de } from "../lib/recent.js";
20
+ import { issueScope as fe, useCan as pe } from "../lib/roles.js";
21
+ import { Link as L, useNavigate as me } from "../lib/router.js";
22
+ import { useShortcuts as he } from "../lib/shortcuts.js";
23
+ import { useTime as ge } from "../lib/time.js";
24
+ import { Timeline as _e } from "./ActivityTimeline.js";
25
+ import { ActorLink as ve } from "./ActorLink.js";
26
+ import { AgentPage as ye } from "./AgentPage.js";
27
+ import { AgentWork as be } from "./AgentWork.js";
28
+ import { AreaLink as xe } from "./AreaLink.js";
29
+ import { AttachButton as Se, IssueAttachments as Ce, UploadStatus as we, useAttachmentUpload as Te } from "./Attachments.js";
30
+ import { CollabEditor as Ee } from "./CollabEditor.js";
31
+ import { CustomerRequests as De } from "./CustomerRequests.js";
32
+ import { IssueFields as Oe } from "./CustomFields.js";
33
+ import { Editor as R } from "./Editor.js";
34
+ import { EntityIcon as ke } from "./EntityIcon.js";
35
+ import { FavoriteStar as Ae } from "./FavoriteStar.js";
36
+ import { IssueDesigns as je } from "./Figma.js";
37
+ import { IssueLinkChips as Me, IssueLinks as Ne, IssueSyncCards as Pe, SharedThreadHeader as Fe } from "./GitHub.js";
38
+ import { IssueCode as Ie } from "./IssueCode.js";
39
+ import { EventLine as Le } from "./IssueEvent.js";
40
+ import { IssueIntercom as Re } from "./IssueIntercom.js";
41
+ import { ParentProperty as ze, SubIssuesAndRelations as Be } from "./IssueRelations.js";
42
+ import { IssueSentry as Ve } from "./IssueSentry.js";
43
+ import { TypeIcon as He } from "./IssueTypes.js";
44
+ import { IssueZendesk as Ue } from "./IssueZendesk.js";
45
+ import { AreaIcon as We, BranchIcon as Ge, CalendarIcon as Ke, CloseIcon as qe, CycleIcon as Je, EstimateIcon as Ye, FileTextIcon as Xe, InboxIcon as Ze, PriorityIcon as Qe, ProjectIcon as $e, StatusIcon as et, usePriorityNames as tt } from "./icons.js";
46
+ import { PersonHoverCard as nt } from "./PersonHoverCard.js";
47
+ import { DueDate as rt, ProjectStatusIcon as it, SlaBadge as at, scalePoints as ot, useEstimateLabel as st } from "./Planning.js";
48
+ import { FieldNote as ct, Viewers as lt } from "./Presence.js";
49
+ import { Reactions as ut } from "./Reactions.js";
50
+ import { TimeInStatus as dt } from "./Reports.js";
51
+ import { SubscribeButton as ft } from "./SubscribeButton.js";
52
+ import { TriageActions as pt, TriageBanner as mt } from "./TriageBanner.js";
53
+ import { Widgets as ht } from "./Widgets.js";
54
+ import { Avatar as gt, Button as z, Callout as _t, Card as vt, Combobox as B, CopyButton as yt, DatePicker as bt, ErrorText as xt, IconButton as St, Kbd as Ct, RelativeTime as wt, Select as V, TitleInput as Tt, Tooltip as Et, buttonClasses as Dt, menuDivider as Ot, toast as kt, useOpenMenu as H } from "@parallelworks/ui";
55
+ import { createContext as At, useCallback as jt, useContext as U, useEffect as Mt, useMemo as Nt, useRef as W, useState as G } from "react";
56
+ import { useErrorMessage as Pt } from "@parallelworks/problem/react";
57
+ import { useFormatter as Ft, useTranslations as K } from "use-intl";
58
+ import { Fragment as q, jsx as J, jsxs as Y } from "react/jsx-runtime";
59
+ import { useMutation as X, useQuery as Z, useQueryClient as It, useSuspenseQuery as Q } from "@tanstack/react-query";
60
+ import { MoreButton as Lt } from "@parallelworks/ui/list";
61
+ import { ArchiveIcon as Rt } from "@parallelworks/ui/icons";
62
+ // src/components/IssueView.tsx
63
+ async function zt(e, t, n) {
64
+ let r = await e.ensureQueryData(p(t, n)), i = (await e.ensureQueryData(x(t))).find((e) => e.id === r.teamId)?.key;
65
+ await Promise.all([
66
+ e.ensureQueryData(s(t, n)),
67
+ e.ensureQueryData(a(t, n)),
68
+ e.ensureQueryData(l(t, n)),
69
+ e.ensureQueryData(y(t, n)),
70
+ e.ensureQueryData(u(t, n)),
71
+ e.ensureQueryData(d(t, n)),
72
+ e.ensureQueryData(f(t, n)),
73
+ e.ensureQueryData(_(t, n)),
74
+ e.ensureQueryData(o(t, n)),
75
+ i && e.ensureQueryData(b(t, i))
76
+ ]);
77
+ }
78
+ function Bt({ workspace: i, identifier: a, inPane: o = !1, onTriaged: s }) {
79
+ let c = K("issue"), l = ge(), u = Pt(), d = K("common"), { data: m } = Q(p(i, a)), { data: g } = Q(x(i)), { data: _ } = Q(h), { data: v = [] } = Z(f(i, a)), [y, b] = G();
80
+ oe({
81
+ identifier: m.identifier,
82
+ ...y && { field: y }
83
+ }), se(i, m.identifier);
84
+ let S = me(), C = T(m.identifier, m.title);
85
+ Mt(() => {
86
+ !o && !window.location.pathname.endsWith(`/issues/${C}`) && S({
87
+ to: "/$workspace/issues/$identifier",
88
+ params: {
89
+ workspace: i,
90
+ identifier: m.identifier
91
+ },
92
+ search: !0,
93
+ hash: !0,
94
+ replace: !0
95
+ });
96
+ }, [
97
+ o,
98
+ C,
99
+ S,
100
+ i,
101
+ m.identifier
102
+ ]);
103
+ let ee = pe(i, "delete_issues", fe(m)), w = It(), { confirm: te, dialog: E } = D(), O = X({
104
+ mutationFn: async () => t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/restore", { params: { path: {
105
+ workspace: i,
106
+ identifier: m.identifier
107
+ } } })),
108
+ onSuccess: (e) => {
109
+ w.setQueryData(p(i, m.identifier).queryKey, e), n(w, i, m.identifier);
110
+ }
111
+ }), k = X({
112
+ mutationFn: async () => t(await e.DELETE("/api/v1/workspaces/{workspace}/issues/{identifier}", { params: { path: {
113
+ workspace: i,
114
+ identifier: m.identifier
115
+ } } })),
116
+ onSuccess: () => {
117
+ kt.success(c("deleted", { identifier: m.identifier })), n(w, i);
118
+ let e = g.find((e) => e.id === m.teamId)?.key;
119
+ S(e ? {
120
+ to: "/$workspace/teams/$key/issues",
121
+ params: {
122
+ workspace: i,
123
+ key: e
124
+ }
125
+ } : {
126
+ to: "/$workspace/issues",
127
+ params: { workspace: i }
128
+ });
129
+ }
130
+ }), ne = jt((e) => S({
131
+ to: "/$workspace/issues/$identifier",
132
+ params: {
133
+ workspace: i,
134
+ identifier: e
135
+ }
136
+ }), [S, i]);
137
+ ie(i, m.body, ne), Mt(() => {
138
+ de(i, {
139
+ kind: "issue",
140
+ href: `/${i}/issues/${m.identifier}`,
141
+ label: `${m.identifier} ${m.title}`
142
+ });
143
+ }, [
144
+ i,
145
+ m.identifier,
146
+ m.title
147
+ ]);
148
+ let A = ae({ issue: m.identifier }, _?.user.username), j = W(m.triage);
149
+ Mt(() => {
150
+ j.current && !m.triage && s?.(), j.current = m.triage;
151
+ }, [m.triage, s]);
152
+ let M = g.find((e) => e.id === m.teamId), N = r(i, a), [P, F] = G(null), ce = H(), I = re(i);
153
+ return he({
154
+ s: () => F("status"),
155
+ p: () => F("priority"),
156
+ a: () => F("assignees"),
157
+ l: () => F("labels"),
158
+ ...!o && { Escape: () => S({
159
+ to: "/$workspace/issues",
160
+ params: { workspace: i }
161
+ }) }
162
+ }, P === null), /* @__PURE__ */ Y("div", {
163
+ className: "flex h-full flex-col",
164
+ children: [
165
+ /* @__PURE__ */ Y("header", {
166
+ className: "flex h-12 shrink-0 items-center gap-2 border-b border-border px-4 text-sm md:px-5",
167
+ onContextMenu: (e) => ce(e, I([m])),
168
+ children: [
169
+ o ? /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J("span", {
170
+ className: "shrink-0 text-muted-foreground tabular-nums",
171
+ children: m.identifier
172
+ }), /* @__PURE__ */ J("span", {
173
+ className: "min-w-0 truncate font-medium",
174
+ children: m.title
175
+ })] }) : /* @__PURE__ */ Y(q, { children: [
176
+ /* @__PURE__ */ J(L, {
177
+ to: M ? "/$workspace/teams/$key/issues" : "/$workspace/issues",
178
+ params: {
179
+ workspace: i,
180
+ key: M?.key ?? ""
181
+ },
182
+ className: "text-muted-foreground hover:text-foreground",
183
+ children: M?.name ?? c("issues")
184
+ }),
185
+ /* @__PURE__ */ J("span", {
186
+ className: "text-muted-foreground",
187
+ "aria-hidden": "true",
188
+ children: "/"
189
+ }),
190
+ /* @__PURE__ */ J("span", {
191
+ className: "shrink-0 font-medium whitespace-nowrap",
192
+ children: m.identifier
193
+ })
194
+ ] }),
195
+ /* @__PURE__ */ J(Ae, {
196
+ workspace: i,
197
+ kind: "issue",
198
+ target: m.id
199
+ }),
200
+ !o && /* @__PURE__ */ J(ft, {
201
+ workspace: i,
202
+ identifier: m.identifier
203
+ }),
204
+ !o && /* @__PURE__ */ J(yt, {
205
+ text: T(m.identifier, m.title),
206
+ label: c("branchName"),
207
+ icon: /* @__PURE__ */ J(Ge, {}),
208
+ size: "sm",
209
+ variant: "ghost",
210
+ success: c("copiedBranchName", { name: T(m.identifier, m.title) }),
211
+ failure: c("copyFailed"),
212
+ className: "max-sm:hidden"
213
+ }),
214
+ !o && /* @__PURE__ */ J(Me, { links: v }),
215
+ /* @__PURE__ */ Y("span", {
216
+ className: "ml-auto flex items-center gap-3",
217
+ children: [
218
+ o && m.triage && /* @__PURE__ */ J(pt, {
219
+ workspace: i,
220
+ issue: m,
221
+ compact: !0
222
+ }),
223
+ N.isPending && /* @__PURE__ */ J("span", {
224
+ className: "text-xs text-muted-foreground",
225
+ children: d("saving")
226
+ }),
227
+ /* @__PURE__ */ J(lt, {
228
+ workspace: i,
229
+ others: A
230
+ }),
231
+ /* @__PURE__ */ J(Lt, {
232
+ items: () => [...I([m]), ...ee ? [{
233
+ label: c("deleteIssue"),
234
+ destructive: !0,
235
+ onClick: () => te({
236
+ title: c("deleteTitle", { identifier: m.identifier }),
237
+ description: c("deleteDescription"),
238
+ confirmLabel: c("deleteIssue"),
239
+ onConfirm: () => k.mutateAsync()
240
+ })
241
+ }] : []],
242
+ label: d("moreActionsFor", { name: m.identifier }),
243
+ visible: !0
244
+ })
245
+ ]
246
+ }),
247
+ N.isError && /* @__PURE__ */ J(xt, {
248
+ inline: !0,
249
+ className: "ml-auto text-xs",
250
+ children: u(N.error)
251
+ })
252
+ ]
253
+ }),
254
+ E,
255
+ /* @__PURE__ */ Y("div", {
256
+ className: "flex min-h-0 flex-1 flex-col overflow-y-auto md:flex-row md:overflow-hidden",
257
+ children: [/* @__PURE__ */ J("div", {
258
+ className: "min-w-0 px-4 md:flex-1 md:overflow-y-auto md:px-8",
259
+ children: /* @__PURE__ */ Y("article", {
260
+ className: "mx-auto w-full max-w-reading pt-6 pb-24 md:pt-8",
261
+ children: [
262
+ /* @__PURE__ */ Y(on.Provider, {
263
+ value: b,
264
+ children: [
265
+ o ? /* @__PURE__ */ J(Pe, { links: v }) : m.triage && /* @__PURE__ */ J(mt, {
266
+ workspace: i,
267
+ issue: m
268
+ }),
269
+ m.archivedAt && /* @__PURE__ */ J(_t, {
270
+ tone: "muted",
271
+ icon: /* @__PURE__ */ J(Rt, {}),
272
+ className: "mb-5",
273
+ children: /* @__PURE__ */ Y("span", {
274
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1",
275
+ children: [c("archivedNote", { when: l.day(m.archivedAt.slice(0, 10)) }), /* @__PURE__ */ J(z, {
276
+ type: "button",
277
+ size: "sm",
278
+ onClick: () => O.mutate(),
279
+ loading: O.isPending,
280
+ children: c("restore")
281
+ })]
282
+ })
283
+ }),
284
+ /* @__PURE__ */ J(Vt, {
285
+ issue: m,
286
+ onSave: (e) => N.mutate({ title: e })
287
+ }),
288
+ /* @__PURE__ */ J(ct, {
289
+ workspace: i,
290
+ others: A,
291
+ field: "title"
292
+ }),
293
+ /* @__PURE__ */ J(Ht, {
294
+ workspace: i,
295
+ issue: m
296
+ }),
297
+ /* @__PURE__ */ J(ct, {
298
+ workspace: i,
299
+ others: A,
300
+ field: "body"
301
+ }),
302
+ /* @__PURE__ */ J(Be, {
303
+ workspace: i,
304
+ issue: m
305
+ }),
306
+ /* @__PURE__ */ J(De, {
307
+ workspace: i,
308
+ identifier: m.identifier,
309
+ enabled: !!M?.customerRequestsEnabled
310
+ }),
311
+ /* @__PURE__ */ J(Ut, {
312
+ workspace: i,
313
+ identifier: a
314
+ }),
315
+ /* @__PURE__ */ J(je, {
316
+ workspace: i,
317
+ identifier: a
318
+ }),
319
+ /* @__PURE__ */ J(Ie, {
320
+ workspace: i,
321
+ identifier: a,
322
+ title: m.title
323
+ }),
324
+ /* @__PURE__ */ J(Ue, {
325
+ workspace: i,
326
+ identifier: a
327
+ }),
328
+ /* @__PURE__ */ J(Ve, {
329
+ workspace: i,
330
+ identifier: a
331
+ }),
332
+ /* @__PURE__ */ J(Re, {
333
+ workspace: i,
334
+ identifier: a
335
+ }),
336
+ /* @__PURE__ */ J(be, {
337
+ workspace: i,
338
+ identifier: a
339
+ }),
340
+ /* @__PURE__ */ J($t, {
341
+ workspace: i,
342
+ identifier: a,
343
+ others: A
344
+ })
345
+ ]
346
+ }),
347
+ /* @__PURE__ */ J(Qt, {
348
+ workspace: i,
349
+ identifier: a
350
+ }),
351
+ /* @__PURE__ */ J(Ce, {
352
+ workspace: i,
353
+ identifier: a
354
+ })
355
+ ]
356
+ })
357
+ }), /* @__PURE__ */ J(Wt, {
358
+ workspace: i,
359
+ issue: m,
360
+ team: M,
361
+ open: P,
362
+ setOpen: F,
363
+ update: (e) => N.mutate(e),
364
+ compact: o
365
+ })]
366
+ })
367
+ ]
368
+ });
369
+ }
370
+ function Vt({ issue: e, onSave: t }) {
371
+ let n = K("issue"), r = U(on);
372
+ return /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J("h1", {
373
+ className: "sr-only",
374
+ children: e.title
375
+ }), /* @__PURE__ */ J(Tt, {
376
+ value: e.title,
377
+ onCommit: t,
378
+ onFocus: () => r("title"),
379
+ onBlur: () => r(void 0),
380
+ "aria-label": n("title")
381
+ })] });
382
+ }
383
+ function Ht({ workspace: e, issue: t }) {
384
+ let n = K("issue"), r = K("common"), i = U(on), { data: a } = Q(h), o = W(null), s = Nt(() => ({
385
+ name: a?.user.name ?? n("someone"),
386
+ color: te(a?.user.username ?? "")
387
+ }), [
388
+ a?.user.name,
389
+ a?.user.username,
390
+ n
391
+ ]), { session: c, error: l } = E({
392
+ workspace: e,
393
+ target: { issue: t.identifier },
394
+ user: s,
395
+ getMarkdown: o
396
+ }), u = W(null), d = Te(e, t.identifier), { data: f = [] } = Z(v(e, t.identifier)), p = pe(e, "comment", fe(t));
397
+ return /* @__PURE__ */ Y("div", {
398
+ className: "group mt-4 min-h-32",
399
+ children: [
400
+ c ? /* @__PURE__ */ J(Ee, {
401
+ session: c,
402
+ user: s,
403
+ getMarkdown: o,
404
+ onFocus: () => i("body"),
405
+ onBlur: () => i(void 0),
406
+ onEditor: (e) => {
407
+ u.current = e;
408
+ },
409
+ onFiles: (e, t) => d.upload(u.current, e, t),
410
+ placeholder: n("addDescription"),
411
+ label: r("description"),
412
+ className: "min-h-32"
413
+ }, `${c.generation}:${c.doc.guid}`) : /* @__PURE__ */ J(R, {
414
+ value: t.body,
415
+ editable: !1,
416
+ className: "min-h-32"
417
+ }),
418
+ /* @__PURE__ */ J(xt, {
419
+ className: "mt-1",
420
+ children: l
421
+ }),
422
+ c && /* @__PURE__ */ Y("div", {
423
+ className: "mt-1 flex items-center justify-end gap-2",
424
+ children: [/* @__PURE__ */ J(we, {
425
+ pending: d.pending,
426
+ error: d.error
427
+ }), /* @__PURE__ */ J(Se, { onFiles: (e) => d.upload(u.current, e) })]
428
+ }),
429
+ /* @__PURE__ */ J(ut, {
430
+ workspace: e,
431
+ identifier: t.identifier,
432
+ reactions: f,
433
+ me: a?.user.username,
434
+ disabled: !p
435
+ })
436
+ ]
437
+ });
438
+ }
439
+ function Ut({ workspace: e, identifier: t }) {
440
+ let n = K("issue"), { data: r } = Q(d(e, t)), i = H(), a = A(e);
441
+ return r.length === 0 ? null : /* @__PURE__ */ Y("section", {
442
+ className: "mt-6",
443
+ "aria-label": n("docs"),
444
+ children: [/* @__PURE__ */ J("h2", {
445
+ className: "text-xs font-medium text-muted-foreground",
446
+ children: n("docs")
447
+ }), /* @__PURE__ */ J("ul", {
448
+ className: "mt-1 flex flex-wrap gap-1.5",
449
+ children: r.map((t) => /* @__PURE__ */ J("li", { children: /* @__PURE__ */ Y(L, {
450
+ to: "/$workspace/docs/$doc",
451
+ params: {
452
+ workspace: e,
453
+ doc: ne(t)
454
+ },
455
+ onContextMenu: (e) => i(e, a(t)),
456
+ className: `${Dt({ size: "sm" })} max-w-72`,
457
+ children: [/* @__PURE__ */ J(Xe, { className: "size-3.5 text-muted-foreground" }), /* @__PURE__ */ J("span", {
458
+ className: "truncate",
459
+ children: t.title
460
+ })]
461
+ }) }, t.id))
462
+ })]
463
+ });
464
+ }
465
+ function Wt({ workspace: n, issue: r, team: i, open: a, setOpen: o, update: s, compact: c = !1 }) {
466
+ let l = K("relations"), u = i?.key, d = K("issue.properties"), p = K("common"), h = tt(), { data: g = [] } = Z({
467
+ ...b(n, u ?? ""),
468
+ enabled: !!u
469
+ }), { data: _ = [] } = Z(m(n)), { data: v = [] } = Z(f(n, r.identifier)), { nameOf: y, actorName: x, avatarOf: T } = I(n), te = It(), E = X({
470
+ mutationFn: async (r) => t(await e.POST("/api/v1/workspaces/{workspace}/labels", {
471
+ params: { path: { workspace: n } },
472
+ body: {
473
+ name: r,
474
+ color: Gt[_.length % Gt.length] ?? "#d73a4a"
475
+ }
476
+ })),
477
+ onSuccess: (e) => {
478
+ te.invalidateQueries({ queryKey: m(n).queryKey }), s({ addLabels: [e.id] });
479
+ }
480
+ }), D = r.assignees.map(S), O = ee(n, !0), k = (e) => (t) => o(t ? e : null), ne = ue(a === "assignees", () => o(null)), A = ue(a === "labels", () => o(null)), j = "flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm hover:bg-muted", M = H(), N = re(n), P = me(), ie = (e, t) => {
481
+ e.stopPropagation(), M(e, t);
482
+ };
483
+ return /* @__PURE__ */ J("aside", {
484
+ className: c ? "order-first flex shrink-0 flex-col gap-0.5 border-b border-border px-3 py-4 md:order-none md:w-64 md:overflow-y-auto md:border-b-0 md:border-l" : "order-first grid shrink-0 grid-cols-2 gap-4 border-b border-border px-4 py-4 md:order-none md:block md:w-72 md:space-y-5 md:overflow-y-auto md:border-b-0 md:border-l md:py-6",
485
+ "aria-label": d("title"),
486
+ onContextMenu: (e) => M(e, N([r])),
487
+ children: /* @__PURE__ */ Y(Yt.Provider, {
488
+ value: c,
489
+ children: [
490
+ c && i && /* @__PURE__ */ J($, {
491
+ label: d("team"),
492
+ slot: "team",
493
+ children: /* @__PURE__ */ Y("span", {
494
+ className: j,
495
+ children: [/* @__PURE__ */ J(ke, {
496
+ icon: i.icon,
497
+ name: i.name,
498
+ className: "size-4"
499
+ }), /* @__PURE__ */ J("span", {
500
+ className: "truncate",
501
+ children: i.name
502
+ })]
503
+ })
504
+ }),
505
+ /* @__PURE__ */ J($, {
506
+ label: p("status"),
507
+ shortcut: "S",
508
+ slot: "status",
509
+ children: /* @__PURE__ */ J(B, {
510
+ "aria-label": p("status"),
511
+ open: a === "status",
512
+ onOpenChange: k("status"),
513
+ items: g.map((e) => ({
514
+ value: e.id,
515
+ label: e.name,
516
+ icon: /* @__PURE__ */ J(et, {
517
+ category: e.category,
518
+ review: e.review,
519
+ step: e.step
520
+ })
521
+ })),
522
+ value: r.status.id,
523
+ onValueChange: (e) => e !== null && e !== r.status.id && s({ statusId: e }),
524
+ placeholder: d("changeStatus"),
525
+ trigger: /* @__PURE__ */ Y("button", {
526
+ type: "button",
527
+ className: j,
528
+ children: [/* @__PURE__ */ J(et, {
529
+ category: r.status.category,
530
+ review: r.status.review,
531
+ step: r.status.step
532
+ }), r.status.name]
533
+ })
534
+ })
535
+ }),
536
+ /* @__PURE__ */ J(Jt, {
537
+ workspace: n,
538
+ issue: r,
539
+ update: s,
540
+ row: j
541
+ }),
542
+ /* @__PURE__ */ J($, {
543
+ label: p("priority"),
544
+ shortcut: "P",
545
+ slot: "priority",
546
+ children: /* @__PURE__ */ J(B, {
547
+ "aria-label": p("priority"),
548
+ open: a === "priority",
549
+ onOpenChange: k("priority"),
550
+ items: [
551
+ 1,
552
+ 2,
553
+ 3,
554
+ 4,
555
+ 0
556
+ ].map((e) => ({
557
+ value: String(e),
558
+ label: h[e] ?? "",
559
+ icon: /* @__PURE__ */ J(Qe, { priority: e })
560
+ })),
561
+ value: String(r.priority),
562
+ onValueChange: (e) => e !== null && s({ priority: Number(e) }),
563
+ placeholder: d("setPriority"),
564
+ trigger: /* @__PURE__ */ Y("button", {
565
+ type: "button",
566
+ className: j,
567
+ children: [/* @__PURE__ */ J(Qe, { priority: r.priority }), h[r.priority]]
568
+ })
569
+ })
570
+ }),
571
+ /* @__PURE__ */ J($, {
572
+ label: d("assignees"),
573
+ shortcut: "A",
574
+ slot: "assignees",
575
+ children: /* @__PURE__ */ J(B, {
576
+ "aria-label": d("assignees"),
577
+ multiple: !0,
578
+ open: a === "assignees",
579
+ onOpenChange: k("assignees"),
580
+ items: O,
581
+ value: D,
582
+ onValueChange: (e) => {
583
+ let t = e.filter((e) => !D.includes(e)), n = D.filter((t) => !e.includes(t));
584
+ s({
585
+ ...t.length > 0 && { addAssignees: t.map(C) },
586
+ ...n.length > 0 && { removeAssignees: n.map(C) }
587
+ }), ne();
588
+ },
589
+ placeholder: d("assignTo"),
590
+ trigger: /* @__PURE__ */ Y("button", {
591
+ type: "button",
592
+ className: `${j} h-auto min-h-8 flex-wrap py-1`,
593
+ children: [r.assignees.length === 0 && /* @__PURE__ */ J("span", {
594
+ className: "text-muted-foreground",
595
+ children: d("unassigned")
596
+ }), r.assignees.map((e) => {
597
+ let t = y(e.kind, e.handle);
598
+ return /* @__PURE__ */ J("span", {
599
+ onContextMenu: (r) => ie(r, [{
600
+ label: d("unassign", { name: t }),
601
+ onClick: () => s({ removeAssignees: [{
602
+ kind: e.kind,
603
+ handle: e.handle
604
+ }] })
605
+ }, {
606
+ label: d("viewTheirIssues"),
607
+ onClick: () => P({
608
+ to: "/$workspace/issues",
609
+ params: { workspace: n },
610
+ search: {
611
+ assignee: e.handle,
612
+ ...e.kind === "agent" && { assigneeKind: "agent" }
613
+ }
614
+ })
615
+ }]),
616
+ className: "flex items-center gap-1.5",
617
+ children: /* @__PURE__ */ Y(nt, {
618
+ workspace: n,
619
+ kind: e.kind,
620
+ handle: e.handle,
621
+ className: "flex items-center gap-1.5",
622
+ children: [/* @__PURE__ */ J(gt, {
623
+ ...w(e.kind),
624
+ name: t,
625
+ src: T(e.kind, e.handle),
626
+ size: "xs",
627
+ decorative: !0
628
+ }), t]
629
+ })
630
+ }, `${e.kind}:${e.handle}`);
631
+ })]
632
+ })
633
+ })
634
+ }),
635
+ /* @__PURE__ */ J($, {
636
+ label: p("labels"),
637
+ shortcut: "L",
638
+ slot: "labels",
639
+ children: /* @__PURE__ */ J(B, {
640
+ "aria-label": p("labels"),
641
+ multiple: !0,
642
+ open: a === "labels",
643
+ onOpenChange: k("labels"),
644
+ items: _.map((e) => ({
645
+ value: e.id,
646
+ label: e.name,
647
+ icon: /* @__PURE__ */ Y("span", {
648
+ className: "flex items-center gap-2",
649
+ children: [/* @__PURE__ */ J(le, {}), /* @__PURE__ */ J("span", {
650
+ className: "size-2.5 rounded-full",
651
+ style: { background: e.color }
652
+ })]
653
+ })
654
+ })),
655
+ value: r.labels.map((e) => e.id),
656
+ onValueChange: (e) => {
657
+ A();
658
+ let t = r.labels.map((e) => e.id), n = e.filter((e) => !t.includes(e)), i = t.filter((t) => !e.includes(t));
659
+ s({
660
+ ...n.length > 0 && { addLabels: n },
661
+ ...i.length > 0 && { removeLabels: i }
662
+ });
663
+ },
664
+ onCreate: (e) => E.mutate(e),
665
+ placeholder: d("addLabels"),
666
+ trigger: /* @__PURE__ */ Y("button", {
667
+ type: "button",
668
+ className: `${j} h-auto min-h-8 flex-wrap py-1`,
669
+ children: [r.labels.length === 0 && /* @__PURE__ */ J("span", {
670
+ className: "text-muted-foreground",
671
+ children: d("noLabels")
672
+ }), r.labels.map((e) => /* @__PURE__ */ Y("span", {
673
+ onContextMenu: (t) => ie(t, [{
674
+ label: d("removeLabel", { name: e.name }),
675
+ onClick: () => s({ removeLabels: [e.id] })
676
+ }, {
677
+ label: d("viewLabelIssues"),
678
+ onClick: () => P({
679
+ to: "/$workspace/issues",
680
+ params: { workspace: n },
681
+ search: { label: e.name }
682
+ })
683
+ }]),
684
+ title: e.name,
685
+ className: "inline-flex max-w-full min-w-0 items-center gap-1 rounded-full border border-border px-2 py-0.5 text-xs",
686
+ children: [/* @__PURE__ */ J("span", {
687
+ className: "size-2 shrink-0 rounded-full",
688
+ style: { background: e.color }
689
+ }), /* @__PURE__ */ J("span", {
690
+ className: "truncate",
691
+ children: e.name
692
+ })]
693
+ }, e.id))]
694
+ })
695
+ })
696
+ }),
697
+ /* @__PURE__ */ J($, {
698
+ label: l("parent"),
699
+ children: /* @__PURE__ */ J(ze, {
700
+ workspace: n,
701
+ issue: r,
702
+ row: j
703
+ })
704
+ }),
705
+ /* @__PURE__ */ J(qt, {
706
+ workspace: n,
707
+ issue: r,
708
+ team: i,
709
+ update: s,
710
+ row: j
711
+ }),
712
+ /* @__PURE__ */ J($, {
713
+ label: d("created"),
714
+ children: /* @__PURE__ */ Y("p", {
715
+ className: "flex items-center gap-2 px-2 text-sm",
716
+ children: [/* @__PURE__ */ J(nt, {
717
+ workspace: n,
718
+ kind: r.creator.kind,
719
+ handle: r.creator.handle,
720
+ children: /* @__PURE__ */ J(gt, {
721
+ ...w(r.creator.kind),
722
+ name: x(r.creator),
723
+ src: T(r.creator.kind, r.creator.handle),
724
+ size: "xs",
725
+ tooltip: r.creator.kind !== "user"
726
+ })
727
+ }), /* @__PURE__ */ J(wt, {
728
+ value: r.createdAt,
729
+ exact: "medium"
730
+ })]
731
+ })
732
+ }),
733
+ /* @__PURE__ */ J($, {
734
+ label: d("timeInStatus"),
735
+ children: /* @__PURE__ */ J(dt, {
736
+ workspace: n,
737
+ identifier: r.identifier
738
+ })
739
+ }),
740
+ /* @__PURE__ */ J(Oe, {
741
+ workspace: n,
742
+ issue: r,
743
+ label: (e, t, n) => /* @__PURE__ */ J($, {
744
+ label: e,
745
+ children: t
746
+ }, n)
747
+ }),
748
+ v.length > 0 && /* @__PURE__ */ J($, {
749
+ label: d("syncedWith"),
750
+ children: /* @__PURE__ */ J(Ne, { links: v })
751
+ })
752
+ ]
753
+ })
754
+ });
755
+ }
756
+ var Gt = [
757
+ "#d73a4a",
758
+ "#2f8a57",
759
+ "#8250df",
760
+ "#0a7ea4",
761
+ "#c2185b",
762
+ "#57606a",
763
+ "#1a7f37"
764
+ ];
765
+ function Kt({ workspace: e, origin: t, className: n }) {
766
+ let r = "size-3.5 shrink-0 text-muted-foreground", i = t.title.replace(/[*_`#>[\]]/g, "").replace(/\s+/g, " ").trim();
767
+ switch (t.kind) {
768
+ case "decision": return /* @__PURE__ */ Y(L, {
769
+ to: "/$workspace/issues/$identifier",
770
+ params: {
771
+ workspace: e,
772
+ identifier: t.key
773
+ },
774
+ className: n,
775
+ children: [/* @__PURE__ */ J(Ze, { className: r }), /* @__PURE__ */ J(Et, {
776
+ content: i,
777
+ overflowOnly: !0,
778
+ children: /* @__PURE__ */ J("span", {
779
+ className: "truncate",
780
+ children: i
781
+ })
782
+ })]
783
+ });
784
+ case "area": return /* @__PURE__ */ Y(xe, {
785
+ workspace: e,
786
+ area: { key: t.key },
787
+ className: n,
788
+ children: [/* @__PURE__ */ J(We, { className: r }), /* @__PURE__ */ J("span", {
789
+ className: "truncate",
790
+ children: i
791
+ })]
792
+ });
793
+ default: return /* @__PURE__ */ Y(L, {
794
+ to: "/$workspace/docs/$doc",
795
+ params: {
796
+ workspace: e,
797
+ doc: t.key
798
+ },
799
+ className: n,
800
+ children: [/* @__PURE__ */ J(Xe, { className: r }), /* @__PURE__ */ J("span", {
801
+ className: "truncate",
802
+ children: i
803
+ })]
804
+ });
805
+ }
806
+ }
807
+ function qt({ workspace: e, issue: t, team: n, update: r, row: a }) {
808
+ let o = K("planning"), s = K("flow"), l = ge(), u = st(), { data: d = [] } = Z(g(e)), f = d.find((e) => e.id === t.project?.id), { data: p = [] } = Z({
809
+ ...c(e, n?.key ?? ""),
810
+ enabled: !!n?.cyclesEnabled
811
+ }), m = n?.estimateScale ?? "none", h = t.status.category === "completed" || t.status.category === "canceled", _ = (e) => e.name ? o("cycleNamed", {
812
+ number: e.number,
813
+ name: e.name
814
+ }) : o("cycle", { number: e.number }), v = p.filter((e) => e.state !== "past" || e.id === t.cycle?.id), { data: y = [] } = Z(i(e)), b = y.filter((e) => !e.teamId || e.teamId === t.teamId);
815
+ return /* @__PURE__ */ Y(q, { children: [
816
+ n && n.flow.length > 0 && /* @__PURE__ */ J($, {
817
+ label: s("stage"),
818
+ children: /* @__PURE__ */ J(V, {
819
+ "aria-label": s("stage"),
820
+ value: t.stage ?? "",
821
+ onValueChange: (e) => r({ stage: e ?? "" }),
822
+ items: [{
823
+ value: "",
824
+ label: s("notInFlow")
825
+ }, ...n.flow.map((e) => ({
826
+ value: e.stage,
827
+ label: s(`stages.${e.stage}`)
828
+ }))],
829
+ trigger: /* @__PURE__ */ Y("button", {
830
+ type: "button",
831
+ className: a,
832
+ children: [/* @__PURE__ */ J(Je, { className: "size-3.5 shrink-0 text-muted-foreground" }), t.stage ? /* @__PURE__ */ J("span", {
833
+ className: "truncate",
834
+ children: s(`stages.${t.stage}`)
835
+ }) : /* @__PURE__ */ J("span", {
836
+ className: "text-muted-foreground",
837
+ children: s("notInFlow")
838
+ })]
839
+ })
840
+ })
841
+ }),
842
+ /* @__PURE__ */ J($, {
843
+ label: o("area"),
844
+ children: /* @__PURE__ */ J(V, {
845
+ "aria-label": o("area"),
846
+ value: t.area?.key ?? "",
847
+ onValueChange: (e) => r({ area: e ?? "" }),
848
+ items: [{
849
+ value: "",
850
+ label: o("noArea")
851
+ }, ...b.map((e) => ({
852
+ value: e.key,
853
+ label: e.title,
854
+ ...e.status === "proposed" && { description: o("proposedArea") }
855
+ }))],
856
+ trigger: /* @__PURE__ */ Y("button", {
857
+ type: "button",
858
+ className: a,
859
+ children: [/* @__PURE__ */ J(We, { className: "size-3.5 shrink-0 text-muted-foreground" }), t.area ? /* @__PURE__ */ J("span", {
860
+ className: "truncate",
861
+ children: t.area.title
862
+ }) : /* @__PURE__ */ J("span", {
863
+ className: "text-muted-foreground",
864
+ children: o("noArea")
865
+ })]
866
+ })
867
+ })
868
+ }),
869
+ t.origin && /* @__PURE__ */ J($, {
870
+ label: o("startedFrom"),
871
+ children: /* @__PURE__ */ J(Kt, {
872
+ workspace: e,
873
+ origin: t.origin,
874
+ className: a
875
+ })
876
+ }),
877
+ /* @__PURE__ */ J($, {
878
+ label: o("project"),
879
+ slot: "project",
880
+ children: /* @__PURE__ */ J(V, {
881
+ "aria-label": o("project"),
882
+ value: t.project?.id ?? "",
883
+ onValueChange: (e) => r({ projectId: e ?? "" }),
884
+ items: [{
885
+ value: "",
886
+ label: o("noProject")
887
+ }, ...d.map((e) => ({
888
+ value: e.id,
889
+ label: e.name,
890
+ icon: /* @__PURE__ */ J(it, { status: e.status })
891
+ }))],
892
+ trigger: /* @__PURE__ */ Y("button", {
893
+ type: "button",
894
+ className: a,
895
+ children: [/* @__PURE__ */ J($e, { className: "size-3.5 shrink-0 text-muted-foreground" }), t.project ? /* @__PURE__ */ J("span", {
896
+ className: "truncate",
897
+ children: t.project.name
898
+ }) : /* @__PURE__ */ J("span", {
899
+ className: "text-muted-foreground",
900
+ children: o("noProject")
901
+ })]
902
+ })
903
+ })
904
+ }),
905
+ t.project && /* @__PURE__ */ J($, {
906
+ label: o("milestone"),
907
+ children: /* @__PURE__ */ J(V, {
908
+ "aria-label": o("milestone"),
909
+ value: t.milestone?.id ?? "",
910
+ onValueChange: (e) => r({ milestoneId: e ?? "" }),
911
+ items: [{
912
+ value: "",
913
+ label: o("noMilestone")
914
+ }, ...(f?.milestones ?? []).map((e) => ({
915
+ value: e.id,
916
+ label: e.name,
917
+ ...e.targetDate && { description: l.day(e.targetDate) }
918
+ }))],
919
+ trigger: /* @__PURE__ */ J("button", {
920
+ type: "button",
921
+ className: a,
922
+ children: t.milestone ? /* @__PURE__ */ J("span", {
923
+ className: "truncate",
924
+ children: t.milestone.name
925
+ }) : /* @__PURE__ */ J("span", {
926
+ className: "text-muted-foreground",
927
+ children: o("noMilestone")
928
+ })
929
+ })
930
+ })
931
+ }),
932
+ n?.cyclesEnabled && /* @__PURE__ */ J($, {
933
+ label: o("cycleLabel"),
934
+ slot: "cycle",
935
+ children: /* @__PURE__ */ J(V, {
936
+ "aria-label": o("cycleLabel"),
937
+ value: t.cycle?.id ?? "",
938
+ onValueChange: (e) => r({ cycleId: e ?? "" }),
939
+ items: [{
940
+ value: "",
941
+ label: o("noCycle")
942
+ }, ...v.map((e) => ({
943
+ value: e.id,
944
+ label: _(e),
945
+ description: o("stateAndDates", {
946
+ state: o(`states.${e.state}`),
947
+ dates: l.dayRange(e.startsOn, e.endsOn)
948
+ })
949
+ }))],
950
+ trigger: /* @__PURE__ */ Y("button", {
951
+ type: "button",
952
+ className: a,
953
+ children: [/* @__PURE__ */ J(Je, { className: "size-3.5 shrink-0 text-muted-foreground" }), t.cycle ? /* @__PURE__ */ J("span", {
954
+ className: "truncate",
955
+ children: _(t.cycle)
956
+ }) : /* @__PURE__ */ J("span", {
957
+ className: "text-muted-foreground",
958
+ children: o("noCycle")
959
+ })]
960
+ })
961
+ })
962
+ }),
963
+ (m !== "none" || !!t.estimate) && /* @__PURE__ */ J($, {
964
+ label: o("estimate"),
965
+ slot: "estimate",
966
+ children: /* @__PURE__ */ J(V, {
967
+ "aria-label": o("estimate"),
968
+ value: t.estimate ?? 0,
969
+ onValueChange: (e) => r({ estimate: e ?? 0 }),
970
+ items: [{
971
+ value: 0,
972
+ label: o("noEstimate")
973
+ }, ...ot(m).map((e) => ({
974
+ value: e,
975
+ label: u(e, m)
976
+ }))],
977
+ trigger: /* @__PURE__ */ Y("button", {
978
+ type: "button",
979
+ className: a,
980
+ children: [/* @__PURE__ */ J(Ye, { className: "size-3.5 shrink-0 text-muted-foreground" }), t.estimate ? u(t.estimate, m) : /* @__PURE__ */ J("span", {
981
+ className: "text-muted-foreground",
982
+ children: o("noEstimate")
983
+ })]
984
+ })
985
+ })
986
+ }),
987
+ /* @__PURE__ */ J($, {
988
+ label: o("dueDate"),
989
+ children: /* @__PURE__ */ Y("div", {
990
+ className: "flex items-center",
991
+ children: [/* @__PURE__ */ J(bt, {
992
+ value: t.dueDate ?? "",
993
+ onValueChange: (e) => r({ dueDate: e }),
994
+ "aria-label": o("dueDate"),
995
+ required: !0,
996
+ trigger: /* @__PURE__ */ J("button", {
997
+ type: "button",
998
+ className: a,
999
+ children: t.dueDate ? /* @__PURE__ */ J(rt, {
1000
+ date: t.dueDate,
1001
+ closed: h
1002
+ }) : /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J(Ke, { className: "size-3.5 shrink-0 text-muted-foreground" }), /* @__PURE__ */ J("span", {
1003
+ className: "text-muted-foreground",
1004
+ children: o("noDueDate")
1005
+ })] })
1006
+ })
1007
+ }), t.dueDate && /* @__PURE__ */ J(St, {
1008
+ variant: "ghost",
1009
+ icon: /* @__PURE__ */ J(qe, { className: "size-3.5" }),
1010
+ label: o("clearDueDate"),
1011
+ onClick: () => r({ dueDate: "" })
1012
+ })]
1013
+ })
1014
+ }),
1015
+ t.slaDueAt && !h && /* @__PURE__ */ J($, {
1016
+ label: o("sla.label"),
1017
+ children: /* @__PURE__ */ J("span", {
1018
+ className: "flex h-7 items-center px-2",
1019
+ children: /* @__PURE__ */ J(at, {
1020
+ issue: t,
1021
+ team: n
1022
+ })
1023
+ })
1024
+ })
1025
+ ] });
1026
+ }
1027
+ function Jt({ workspace: e, issue: t, update: n, row: r }) {
1028
+ let i = K("issueTypes"), a = Ft(), { data: o } = Z(M(e)), { data: s } = Z(O(e)), { confirm: c, dialog: l } = D(), [u, d] = G(!1), f = P(o, t.teamId);
1029
+ if (f.length === 0 && !t.type) return null;
1030
+ let p = (e) => {
1031
+ let r = f.find((t) => t.id === e), o = (s ?? []).filter((e) => k(t.fields[e.id]) && !N(r, e.id));
1032
+ if (!r || o.length === 0) return n({ typeId: e });
1033
+ c({
1034
+ title: i("hiddenTitle"),
1035
+ description: i("hidden", {
1036
+ type: r.name,
1037
+ fields: a.list(o.map((e) => e.name))
1038
+ }),
1039
+ confirmLabel: i("change"),
1040
+ destructive: !1,
1041
+ onConfirm: async () => n({ typeId: e })
1042
+ });
1043
+ };
1044
+ return /* @__PURE__ */ Y($, {
1045
+ label: i("type"),
1046
+ children: [/* @__PURE__ */ J(B, {
1047
+ "aria-label": i("type"),
1048
+ open: u,
1049
+ onOpenChange: d,
1050
+ items: [{
1051
+ value: "",
1052
+ label: i("noType")
1053
+ }, ...f.map((e) => ({
1054
+ value: e.id,
1055
+ label: e.name,
1056
+ icon: /* @__PURE__ */ J(He, { type: e })
1057
+ }))],
1058
+ value: t.type?.id ?? "",
1059
+ onValueChange: (e) => e !== null && e !== (t.type?.id ?? "") && p(e),
1060
+ placeholder: i("type"),
1061
+ trigger: /* @__PURE__ */ J("button", {
1062
+ type: "button",
1063
+ className: r,
1064
+ children: t.type ? /* @__PURE__ */ Y(q, { children: [/* @__PURE__ */ J(He, { type: t.type }), t.type.name] }) : /* @__PURE__ */ J("span", {
1065
+ className: "text-muted-foreground",
1066
+ children: i("noType")
1067
+ })
1068
+ })
1069
+ }), l]
1070
+ });
1071
+ }
1072
+ var Yt = At(!1), Xt = {
1073
+ status: 1,
1074
+ team: 2,
1075
+ priority: 3,
1076
+ assignees: 4,
1077
+ estimate: 5,
1078
+ cycle: 6,
1079
+ labels: 7,
1080
+ project: 8
1081
+ }, Zt = /* @__PURE__ */ new Set(["labels", "project"]);
1082
+ function $({ label: e, shortcut: t, slot: n, children: r }) {
1083
+ if (U(Yt)) {
1084
+ let t = !n || Zt.has(n);
1085
+ return /* @__PURE__ */ Y("div", {
1086
+ style: { order: (n && Xt[n]) ?? 20 },
1087
+ className: t ? "mt-3" : "",
1088
+ children: [/* @__PURE__ */ J("p", {
1089
+ className: t ? "mb-1 px-2 text-xs text-muted-foreground" : "sr-only",
1090
+ children: e
1091
+ }), r]
1092
+ });
1093
+ }
1094
+ return /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ Y("p", {
1095
+ className: "mb-1 flex items-center justify-between px-2 text-xs text-muted-foreground",
1096
+ children: [e, t && /* @__PURE__ */ J(Ct, {
1097
+ keys: t,
1098
+ size: "xs",
1099
+ className: "hidden md:inline-flex"
1100
+ })]
1101
+ }), r] });
1102
+ }
1103
+ function Qt({ workspace: e, identifier: t }) {
1104
+ let n = K("issue.activity"), { data: r } = Q(l(e, t)), [i, a] = G(!1), o = Nt(() => {
1105
+ let e = [];
1106
+ for (let t of r) {
1107
+ if (t.type.startsWith("comment.") || t.type.startsWith("issue.reaction_") || t.type === "issue.triage_accepted" && t.data.pullRequest) continue;
1108
+ let n = e.at(-1);
1109
+ t.type === "issue.body_changed" && n?.type === "issue.body_changed" && n.actor.handle === t.actor.handle ? e[e.length - 1] = t : e.push(t);
1110
+ }
1111
+ return e;
1112
+ }, [r]), s = i ? 0 : Math.max(0, o.length - 5);
1113
+ return /* @__PURE__ */ Y("section", {
1114
+ className: "mt-10",
1115
+ "aria-label": n("title"),
1116
+ children: [
1117
+ /* @__PURE__ */ J("h2", {
1118
+ className: "text-base font-semibold",
1119
+ children: n("title")
1120
+ }),
1121
+ s > 0 && /* @__PURE__ */ J("button", {
1122
+ type: "button",
1123
+ onClick: () => a(!0),
1124
+ className: "mt-3 text-xs text-muted-foreground hover:text-foreground",
1125
+ children: n("showEarlier", { count: s })
1126
+ }),
1127
+ /* @__PURE__ */ J(_e, {
1128
+ className: "mt-3",
1129
+ children: o.slice(s).map((t) => /* @__PURE__ */ J(Le, {
1130
+ workspace: e,
1131
+ event: t
1132
+ }, t.id))
1133
+ })
1134
+ ]
1135
+ });
1136
+ }
1137
+ function $t({ workspace: e, identifier: t, others: n }) {
1138
+ let r = K("issue.comments"), { data: i } = Q(s(e, t)), { data: a = [] } = Z(f(e, t)), o = Nt(() => {
1139
+ let e = i.filter((e) => !e.parentId);
1140
+ return e.sort((e, t) => Number(en(t)) - Number(en(e))), e.map((e) => ({
1141
+ root: e,
1142
+ replies: i.filter((t) => t.parentId === e.id)
1143
+ }));
1144
+ }, [i]), [c, l] = G(null), u = i.filter((e) => !e.deletedAt && !en(e)).length;
1145
+ return /* @__PURE__ */ Y("section", {
1146
+ className: "mt-12 border-t border-border pt-6",
1147
+ "aria-label": r("title"),
1148
+ children: [
1149
+ /* @__PURE__ */ Y("h2", {
1150
+ className: "text-base font-semibold",
1151
+ children: [
1152
+ r("title"),
1153
+ " ",
1154
+ u > 0 && /* @__PURE__ */ J("span", {
1155
+ className: "font-normal text-muted-foreground",
1156
+ children: u
1157
+ })
1158
+ ]
1159
+ }),
1160
+ /* @__PURE__ */ J("div", {
1161
+ className: "mt-4 space-y-3",
1162
+ children: o.map(({ root: n, replies: i }) => {
1163
+ let o = en(n) ? n.sharedWith : void 0, s = o ? ce(o).source : void 0;
1164
+ return /* @__PURE__ */ Y(vt, {
1165
+ size: "fill",
1166
+ padding: "none",
1167
+ highlight: !!o,
1168
+ render: /* @__PURE__ */ J("article", {
1169
+ id: `comment-${n.id}`,
1170
+ "aria-label": s && r("sharedThreadLabel", { source: s })
1171
+ }),
1172
+ children: [
1173
+ o && s ? /* @__PURE__ */ J(Fe, {
1174
+ source: s,
1175
+ link: a.find((e) => e.connector === o)
1176
+ }) : /* @__PURE__ */ J(nn, {
1177
+ workspace: e,
1178
+ identifier: t,
1179
+ comment: n,
1180
+ onReply: () => l(n.id)
1181
+ }),
1182
+ i.length > 0 && /* @__PURE__ */ J("ol", {
1183
+ className: o ? "" : "border-t border-border/70",
1184
+ children: i.map((r) => /* @__PURE__ */ J("li", {
1185
+ id: `comment-${r.id}`,
1186
+ className: "border-b border-border/50 last:border-b-0",
1187
+ children: /* @__PURE__ */ J(nn, {
1188
+ workspace: e,
1189
+ identifier: t,
1190
+ comment: r,
1191
+ onReply: () => l(n.id)
1192
+ })
1193
+ }, r.id))
1194
+ }),
1195
+ /* @__PURE__ */ J("div", {
1196
+ className: "border-t border-border/70 px-3 py-2",
1197
+ children: c === n.id ? /* @__PURE__ */ J(an, {
1198
+ workspace: e,
1199
+ identifier: t,
1200
+ parentId: n.id,
1201
+ publicOn: s,
1202
+ autofocus: !0,
1203
+ onDone: () => l(null)
1204
+ }) : /* @__PURE__ */ J("button", {
1205
+ type: "button",
1206
+ onClick: () => l(n.id),
1207
+ className: "w-full text-left text-xs text-muted-foreground hover:text-foreground",
1208
+ children: s ? r("replyPublic", { source: s }) : r("replyPlaceholder")
1209
+ })
1210
+ })
1211
+ ]
1212
+ }, n.id);
1213
+ })
1214
+ }),
1215
+ /* @__PURE__ */ J(vt, {
1216
+ size: "fill",
1217
+ padding: "sm",
1218
+ focusWithin: !0,
1219
+ className: "mt-4",
1220
+ children: /* @__PURE__ */ J(an, {
1221
+ workspace: e,
1222
+ identifier: t
1223
+ })
1224
+ }),
1225
+ /* @__PURE__ */ J("div", {
1226
+ className: "mt-2",
1227
+ children: /* @__PURE__ */ J(ct, {
1228
+ workspace: e,
1229
+ others: n,
1230
+ field: "comment"
1231
+ })
1232
+ })
1233
+ ]
1234
+ });
1235
+ }
1236
+ var en = (e) => !!e.sharedWith && !e.parentId;
1237
+ function tn({ comment: e }) {
1238
+ let t = K("issue.comments");
1239
+ return e.author.kind === "connector" ? /* @__PURE__ */ J("span", {
1240
+ className: "rounded border border-border px-1.5 py-px text-[10px] text-muted-foreground",
1241
+ children: t("via", { source: ce(e.author.handle).source })
1242
+ }) : null;
1243
+ }
1244
+ function nn({ workspace: r, identifier: i, comment: a, onReply: o }) {
1245
+ let s = K("issue.comments"), c = K("common"), { actorName: l, avatarOf: u } = I(r), { data: d } = Q(h), { data: f = [] } = Z(v(r, i)), p = pe(r, "comment", { team: i.slice(0, i.lastIndexOf("-")) }), m = It(), g = H(), [_, y] = G(!1), [b, x] = G(a.body), [S, C] = G(!1), ee = W(null), T = Te(r, i), te = a.author.kind === "user" && a.author.handle === d?.user.username, E = { path: {
1246
+ workspace: r,
1247
+ identifier: i,
1248
+ commentId: a.id
1249
+ } }, D = () => n(m, r, i), O = X({
1250
+ mutationFn: async () => t(await e.PATCH("/api/v1/workspaces/{workspace}/issues/{identifier}/comments/{commentId}", {
1251
+ params: E,
1252
+ body: { body: b }
1253
+ })),
1254
+ onSuccess: () => {
1255
+ y(!1), D();
1256
+ }
1257
+ }), k = X({
1258
+ mutationFn: async () => t(await e.DELETE("/api/v1/workspaces/{workspace}/issues/{identifier}/comments/{commentId}", { params: E })),
1259
+ onSuccess: D
1260
+ });
1261
+ if (a.deletedAt) return /* @__PURE__ */ J("p", {
1262
+ className: "px-3 py-2.5 text-xs text-muted-foreground italic",
1263
+ children: s("deleted")
1264
+ });
1265
+ let ne = `${j(r, i)}#comment-${a.id}`, A = [
1266
+ {
1267
+ label: s("reply"),
1268
+ onClick: o
1269
+ },
1270
+ F(c("copyLink"), ne),
1271
+ F(s("copyText"), a.body),
1272
+ ...te ? [
1273
+ Ot,
1274
+ {
1275
+ label: s("edit"),
1276
+ onClick: () => {
1277
+ x(a.body), y(!0);
1278
+ }
1279
+ },
1280
+ {
1281
+ label: c("delete"),
1282
+ destructive: !0,
1283
+ onClick: () => C(!0)
1284
+ }
1285
+ ] : []
1286
+ ];
1287
+ return /* @__PURE__ */ Y("div", {
1288
+ className: "group px-3 py-2.5",
1289
+ onContextMenu: (e) => !_ && g(e, A),
1290
+ children: [/* @__PURE__ */ Y("div", {
1291
+ className: "flex items-center gap-2 text-xs",
1292
+ children: [
1293
+ /* @__PURE__ */ Y(ve, {
1294
+ workspace: r,
1295
+ actor: a.author,
1296
+ className: "flex items-center gap-2 font-medium hover:underline",
1297
+ children: [/* @__PURE__ */ J(gt, {
1298
+ ...w(a.author.kind),
1299
+ name: l(a.author),
1300
+ src: u(a.author.kind, a.author.handle),
1301
+ size: "xs",
1302
+ decorative: !0
1303
+ }), l(a.author)]
1304
+ }),
1305
+ /* @__PURE__ */ J(tn, { comment: a }),
1306
+ /* @__PURE__ */ Y("span", {
1307
+ className: "text-muted-foreground",
1308
+ children: [/* @__PURE__ */ J(wt, {
1309
+ value: a.createdAt,
1310
+ exact: "medium"
1311
+ }), a.updatedAt !== a.createdAt && /* @__PURE__ */ Y(q, { children: [" ", s("edited")] })]
1312
+ }),
1313
+ !S && !_ && /* @__PURE__ */ J(Lt, {
1314
+ items: A,
1315
+ className: "ml-auto"
1316
+ }),
1317
+ S && /* @__PURE__ */ Y("span", {
1318
+ className: "ml-auto flex gap-2 text-muted-foreground",
1319
+ children: [
1320
+ /* @__PURE__ */ J("span", { children: s("confirmDelete") }),
1321
+ /* @__PURE__ */ J("button", {
1322
+ type: "button",
1323
+ className: "text-danger hover:underline",
1324
+ onClick: () => k.mutate(),
1325
+ children: c("delete")
1326
+ }),
1327
+ /* @__PURE__ */ J("button", {
1328
+ type: "button",
1329
+ className: "hover:underline",
1330
+ onClick: () => C(!1),
1331
+ children: s("keep")
1332
+ })
1333
+ ]
1334
+ })
1335
+ ]
1336
+ }), /* @__PURE__ */ J("div", {
1337
+ className: "mt-1",
1338
+ children: _ ? /* @__PURE__ */ Y(q, { children: [
1339
+ /* @__PURE__ */ J(R, {
1340
+ value: b,
1341
+ onChange: x,
1342
+ onSubmit: () => O.mutate(),
1343
+ autofocus: !0,
1344
+ label: s("editLabel"),
1345
+ onEditor: (e) => {
1346
+ ee.current = e;
1347
+ },
1348
+ onFiles: (e, t) => T.upload(ee.current, e, t)
1349
+ }),
1350
+ /* @__PURE__ */ J(we, {
1351
+ pending: T.pending,
1352
+ error: T.error
1353
+ }),
1354
+ /* @__PURE__ */ Y("div", {
1355
+ className: "mt-2 flex justify-end gap-2",
1356
+ children: [/* @__PURE__ */ J(z, {
1357
+ type: "button",
1358
+ variant: "ghost",
1359
+ size: "sm",
1360
+ onClick: () => y(!1),
1361
+ children: c("cancel")
1362
+ }), /* @__PURE__ */ J(z, {
1363
+ type: "button",
1364
+ variant: "primary",
1365
+ size: "sm",
1366
+ onClick: () => O.mutate(),
1367
+ disabled: !b.trim() || T.pending > 0,
1368
+ children: c("save")
1369
+ })]
1370
+ })
1371
+ ] }) : /* @__PURE__ */ Y(q, { children: [
1372
+ /* @__PURE__ */ J(R, {
1373
+ value: a.body,
1374
+ editable: !1
1375
+ }),
1376
+ /* @__PURE__ */ J(ht, {
1377
+ workspace: r,
1378
+ widgets: a.widgets
1379
+ }),
1380
+ /* @__PURE__ */ J(rn, {
1381
+ workspace: r,
1382
+ identifier: i,
1383
+ comment: a
1384
+ }),
1385
+ /* @__PURE__ */ J(ut, {
1386
+ workspace: r,
1387
+ identifier: i,
1388
+ commentId: a.id,
1389
+ reactions: f,
1390
+ me: d?.user.username,
1391
+ disabled: !p
1392
+ })
1393
+ ] })
1394
+ })]
1395
+ });
1396
+ }
1397
+ function rn({ workspace: e, identifier: t, comment: n }) {
1398
+ let { data: r = [] } = Z(a(e, t)), { actorName: i } = I(e), o = r.filter((e) => e.page && e.commentId === n.id);
1399
+ return o.length === 0 ? null : /* @__PURE__ */ J("div", {
1400
+ className: "mt-2 space-y-2",
1401
+ children: o.map((e) => /* @__PURE__ */ J(ye, {
1402
+ attachmentId: e.id,
1403
+ name: e.name,
1404
+ agent: i(n.author)
1405
+ }, e.id))
1406
+ });
1407
+ }
1408
+ function an({ workspace: r, identifier: i, parentId: a, publicOn: o, autofocus: s = !1, onDone: c }) {
1409
+ let l = K("issue.comments"), u = Pt(), d = K("common"), f = U(on), p = It(), [m, h] = G(""), [g, _] = G(0), v = W(null), y = Te(r, i), b = X({
1410
+ mutationFn: async () => t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/comments", {
1411
+ params: { path: {
1412
+ workspace: r,
1413
+ identifier: i
1414
+ } },
1415
+ body: {
1416
+ body: m,
1417
+ ...a && { parentId: a }
1418
+ }
1419
+ })),
1420
+ onSuccess: () => {
1421
+ h(""), _((e) => e + 1), n(p, r, i), c?.();
1422
+ }
1423
+ }), x = () => m.trim() && !b.isPending && y.pending === 0 && b.mutate();
1424
+ return /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J(R, {
1425
+ value: "",
1426
+ onChange: h,
1427
+ onSubmit: x,
1428
+ onFocus: () => f("comment"),
1429
+ onBlur: () => f(void 0),
1430
+ autofocus: s,
1431
+ onEditor: (e) => {
1432
+ v.current = e;
1433
+ },
1434
+ onFiles: (e, t) => y.upload(v.current, e, t),
1435
+ placeholder: o ? l("replyPublic", { source: o }) : l(a ? "replyPlaceholder" : "placeholder"),
1436
+ label: o ? l("replyPublicButton", { source: o }) : l(a ? "reply" : "newComment"),
1437
+ className: a ? "min-h-8" : "min-h-12"
1438
+ }, g), /* @__PURE__ */ Y("div", {
1439
+ className: "mt-1 flex items-center justify-end gap-3",
1440
+ children: [
1441
+ /* @__PURE__ */ Y("span", {
1442
+ className: "mr-auto flex min-w-0 items-center gap-2",
1443
+ children: [/* @__PURE__ */ J(Se, { onFiles: (e) => y.upload(v.current, e) }), /* @__PURE__ */ J(we, {
1444
+ pending: y.pending,
1445
+ error: y.error
1446
+ })]
1447
+ }),
1448
+ b.isError && /* @__PURE__ */ J(xt, {
1449
+ inline: !0,
1450
+ className: "text-xs",
1451
+ children: u(b.error)
1452
+ }),
1453
+ c && /* @__PURE__ */ J(z, {
1454
+ type: "button",
1455
+ variant: "ghost",
1456
+ size: "sm",
1457
+ onClick: c,
1458
+ children: d("cancel")
1459
+ }),
1460
+ /* @__PURE__ */ J(z, {
1461
+ type: "button",
1462
+ variant: "primary",
1463
+ size: "sm",
1464
+ onClick: x,
1465
+ disabled: !m.trim() || y.pending > 0,
1466
+ loading: b.isPending,
1467
+ children: o ? l("replyPublicButton", { source: o }) : l(a ? "reply" : "submit")
1468
+ })
1469
+ ]
1470
+ })] });
1471
+ }
1472
+ var on = At(() => {});
1473
+ export { Bt as IssueView, zt as loadIssue };