@markmo/europacore-session-ui 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/dist/ArtifactsPage-BxaqShTv.js +1178 -0
  3. package/dist/{BoardPage-BAQrGP7G.js → BoardPage-DH7p5o99.js} +274 -265
  4. package/dist/{CardDetail-CCgP8R61.js → CardDetail-LfDCJQhS.js} +42 -33
  5. package/dist/{ComparePage-FcLLhKzC.js → ComparePage-CrbCyu4u.js} +33 -33
  6. package/dist/MemoriesPage-BRA53Hlb.js +679 -0
  7. package/dist/{OverviewPage-CbfbyGNT.js → OverviewPage-BSBqY83_.js} +50 -49
  8. package/dist/{RegisterPage-3-hJNQEV.js → RegisterPage-64yGl9E-.js} +76 -76
  9. package/dist/SessionPage-C4hSlxWQ.js +906 -0
  10. package/dist/api/agentClient.d.ts +66 -1
  11. package/dist/api/wire.d.ts +540 -4
  12. package/dist/features/artifacts/ArtifactDetail.d.ts +15 -0
  13. package/dist/features/artifacts/ArtifactDialogs.d.ts +29 -0
  14. package/dist/features/artifacts/ArtifactLedger.d.ts +11 -0
  15. package/dist/features/artifacts/ArtifactStats.d.ts +9 -0
  16. package/dist/features/artifacts/ArtifactsPage.d.ts +1 -0
  17. package/dist/features/artifacts/artifactsCommands.d.ts +3 -0
  18. package/dist/features/artifacts/artifactsStore.d.ts +27 -0
  19. package/dist/features/artifacts/artifactsUi.d.ts +33 -0
  20. package/dist/features/bootstrap.d.ts +1 -0
  21. package/dist/features/chat/model/artifactAccess.d.ts +50 -0
  22. package/dist/features/chat/model/artifactCsv.d.ts +11 -0
  23. package/dist/features/chat/model/artifactExport.d.ts +45 -0
  24. package/dist/features/chat/model/artifactStats.d.ts +79 -0
  25. package/dist/features/chat/model/artifacts.d.ts +151 -0
  26. package/dist/features/chat/model/claims.d.ts +102 -0
  27. package/dist/features/chat/model/contextSources.d.ts +41 -0
  28. package/dist/features/chat/model/entries.d.ts +37 -2
  29. package/dist/features/chat/model/fleet.d.ts +11 -0
  30. package/dist/features/chat/model/format.d.ts +6 -0
  31. package/dist/features/chat/model/inspect.d.ts +11 -0
  32. package/dist/features/chat/model/memory.d.ts +3 -3
  33. package/dist/features/chat/model/memoryRecords.d.ts +79 -0
  34. package/dist/features/chat/model/monitors.d.ts +11 -0
  35. package/dist/features/chat/model/progress.d.ts +73 -0
  36. package/dist/features/chat/model/routing.d.ts +20 -0
  37. package/dist/features/chat/model/store.d.ts +5 -0
  38. package/dist/features/chat/model/tasks.d.ts +1 -1
  39. package/dist/features/chat/panels/ProgressPanel.d.ts +8 -0
  40. package/dist/features/chat/session/ComposerHistory.d.ts +1 -1
  41. package/dist/features/chat/session/SessionController.d.ts +3 -2
  42. package/dist/features/chat/session/useFileMentions.d.ts +18 -5
  43. package/dist/features/chat/transcript/ArtifactCard.d.ts +8 -0
  44. package/dist/features/chat/transcript/Rows.d.ts +12 -1
  45. package/dist/features/commands/InspectDialog.d.ts +3 -0
  46. package/dist/features/commands/dialogs.d.ts +1 -1
  47. package/dist/features/commands/registry.d.ts +1 -1
  48. package/dist/features/memories/MemoriesPage.d.ts +1 -0
  49. package/dist/features/memories/memoriesCommands.d.ts +3 -0
  50. package/dist/features/memories/memoriesController.d.ts +81 -0
  51. package/dist/features/memory/MemoryDialog.d.ts +1 -1
  52. package/dist/features/memory/memoryService.d.ts +10 -10
  53. package/dist/features/workspace/claimsCommands.d.ts +26 -0
  54. package/dist/features/workspace/collisionsWatcher.d.ts +7 -0
  55. package/dist/features/workspace/useSessionPageHooks.d.ts +1 -1
  56. package/dist/{index-NjGO7Jg1.js → index-CMPf-3JZ.js} +4821 -3447
  57. package/dist/index.d.ts +2 -0
  58. package/dist/index.js +86 -82
  59. package/dist/lib/paths.d.ts +12 -0
  60. package/dist/lib/zip.d.ts +14 -0
  61. package/dist/{promptHistory-DjSCHmEk.js → promptHistory-BR0NpLCI.js} +14 -14
  62. package/package.json +1 -1
  63. package/dist/SessionPage-CA9hAakW.js +0 -865
@@ -0,0 +1,1178 @@
1
+ import { jsx as t, jsxs as o, Fragment as j } from "react/jsx-runtime";
2
+ import { Download as Ie, FileCode as dt, FileText as He, Printer as ut, FileArchive as ht, FileSpreadsheet as pt, ExternalLink as Be, Copy as ft, KeyRound as mt, AtSign as gt, Globe as Ve, Undo2 as bt, Trash2 as qe, Link2 as xt, ArrowDown as wt, ArrowUp as kt, LayoutList as vt, Table2 as yt, BarChart3 as Nt, RefreshCw as $t, FileStack as Me, Search as Ct } from "lucide-react";
3
+ import { useState as $, useEffect as K, useMemo as le } from "react";
4
+ import { Link as St, useNavigate as zt, useSearchParams as _t } from "react-router";
5
+ import { b4 as ce, m as Ke, b5 as F, b6 as we, o as S, b7 as At, K as re, a2 as A, b8 as Ut, B as H, b9 as Dt, ba as Tt, bb as Lt, bc as Pt, bd as G, be as Ce, n as J, bf as Bt, bg as Ge, aq as Se, aK as B, bh as Mt, Y as N, bi as E, bj as Et, aD as Ot, aG as Ft, aE as jt, bk as Rt, l as ne, bl as Wt, bm as It, bn as Ht, bo as Vt, bp as qt, bq as Ee, br as Oe, bs as he, bt as Fe, O as Ye, bu as Y, bv as R, bw as D, bx as Ze, by as Kt, bz as Gt, bA as M, bB as Yt, a as Z, aU as ke, bC as Zt, H as Jt, bD as Xt, bE as Qt, bF as en, k as tn, bG as nn, bH as sn, ad as an, aJ as ln, V as je, bI as rn } from "./index-CMPf-3JZ.js";
6
+ import { Menu as on, MenuButton as cn } from "@headlessui/react";
7
+ const dn = [4, 8, 12, 26], Je = 30, un = 864e5;
8
+ function Xe(e) {
9
+ const n = new Date(e);
10
+ return n.setHours(0, 0, 0, 0), n.setDate(n.getDate() - (n.getDay() + 6) % 7), n.getTime();
11
+ }
12
+ function pe(e, n) {
13
+ const a = new Date(e);
14
+ return a.setDate(a.getDate() + 7 * n), a.getTime();
15
+ }
16
+ function se(e) {
17
+ const n = new Date(e);
18
+ return `${n.getDate()} ${n.toLocaleString("en", { month: "short" })}`;
19
+ }
20
+ const Qe = (e) => typeof e.bytes == "number" ? e.bytes : null;
21
+ function ae(e) {
22
+ const n = e.filter((a) => typeof a == "number");
23
+ return n.length ? n.reduce((a, s) => a + s, 0) : null;
24
+ }
25
+ function et(e) {
26
+ return ae(e.versions.map(Qe));
27
+ }
28
+ function tt(e, n = Date.now()) {
29
+ const a = Date.parse(e.updated_at);
30
+ return Number.isFinite(a) && n - a > Je * un;
31
+ }
32
+ function hn(e, n, a) {
33
+ return e.versions.some((s) => {
34
+ const l = Date.parse(s.created_at);
35
+ return l >= n && l < a;
36
+ });
37
+ }
38
+ function pn(e, n) {
39
+ return (e.projects ?? []).includes(n) || e.versions.some((a) => a.project === n);
40
+ }
41
+ function fn(e, n, a) {
42
+ const s = pe(Xe(n), -(a - 1)), l = Array.from({ length: a }, (d, f) => ({
43
+ start: pe(s, f),
44
+ end: pe(s, f + 1),
45
+ tokens: 0,
46
+ versions: 0
47
+ }));
48
+ for (const d of e.flatMap((f) => f.versions)) {
49
+ const f = Date.parse(d.created_at), p = l.find((c) => f >= c.start && f < c.end);
50
+ p && (p.versions += 1, p.tokens += d.usage?.total_tokens ?? 0);
51
+ }
52
+ return l;
53
+ }
54
+ function mn(e, n, a) {
55
+ const s = e.flatMap((i) => i.versions), l = s.filter((i) => i.usage), d = l.filter((i) => typeof i.usage?.cost_usd == "number"), f = l.length ? l.reduce((i, x) => i + (x.usage?.total_tokens ?? 0), 0) : null, p = e.filter((i) => i.versions.some((x) => x.usage)).length, c = { live: 0, temporary: 0, permanent: 0 };
56
+ let m = 0;
57
+ for (const i of e) {
58
+ const x = ce(i, n);
59
+ x && ((x.behind || x.expired) && (m += 1), !x.expired && (c.live += 1, x.expiresAt ? c.temporary += 1 : c.permanent += 1));
60
+ }
61
+ const b = e.filter((i) => tt(i, n)), k = /* @__PURE__ */ new Map();
62
+ for (const i of e) {
63
+ const x = k.get(i.format) ?? { tag: Ke(i.format), format: i.format, count: 0 };
64
+ x.count += 1, k.set(i.format, x);
65
+ }
66
+ const r = Xe(n);
67
+ return {
68
+ count: e.length,
69
+ newThisWeek: e.filter((i) => Date.parse(i.created_at) >= r).length,
70
+ tokens: f,
71
+ tokensPartial: f !== null && l.length < s.length,
72
+ perArtifact: f !== null && p ? Math.round(f / p) : null,
73
+ cost: d.length ? d.reduce((i, x) => i + (x.usage?.cost_usd ?? 0), 0) : null,
74
+ costPartial: d.length > 0 && d.length < s.length,
75
+ bytes: ae(s.map(Qe)),
76
+ files: s.reduce((i, x) => i + x.files.length, 0),
77
+ versions: s.length,
78
+ published: c,
79
+ stale: m,
80
+ untouched: {
81
+ count: b.length,
82
+ tokens: ae(b.map((i) => i.usage?.total_tokens ?? null)),
83
+ bytes: ae(b.map(et)),
84
+ openedLately: b.filter((i) => we(i) > 0).length
85
+ },
86
+ shared: e.some((i) => F(i)) ? {
87
+ count: e.filter((i) => F(i) === "workspace" || F(i) === "public").length,
88
+ workspace: e.filter((i) => F(i) === "workspace").length,
89
+ public: e.filter((i) => F(i) === "public").length,
90
+ opens: e.reduce((i, x) => i + we(x), 0)
91
+ } : null,
92
+ byFormat: [...k.values()].sort((i, x) => x.count - i.count || i.tag.localeCompare(x.tag)),
93
+ heaviest: e.filter((i) => (i.usage?.total_tokens ?? 0) > 0).sort((i, x) => (x.usage?.total_tokens ?? 0) - (i.usage?.total_tokens ?? 0)).slice(0, 5),
94
+ weeks: fn(e, n, a)
95
+ };
96
+ }
97
+ const gn = (() => {
98
+ const e = new Uint32Array(256);
99
+ for (let n = 0; n < 256; n++) {
100
+ let a = n;
101
+ for (let s = 0; s < 8; s++) a = a & 1 ? 3988292384 ^ a >>> 1 : a >>> 1;
102
+ e[n] = a >>> 0;
103
+ }
104
+ return e;
105
+ })();
106
+ function bn(e) {
107
+ let n = 4294967295;
108
+ for (let a = 0; a < e.length; a++) n = gn[(n ^ e[a]) & 255] ^ n >>> 8;
109
+ return (n ^ 4294967295) >>> 0;
110
+ }
111
+ async function xn(e) {
112
+ if (typeof CompressionStream > "u") return null;
113
+ try {
114
+ const n = new CompressionStream("deflate-raw"), a = n.writable.getWriter();
115
+ a.write(e), a.close();
116
+ const s = [], l = n.readable.getReader();
117
+ for (let p = await l.read(); !p.done; p = await l.read()) s.push(p.value);
118
+ const d = new Uint8Array(s.reduce((p, c) => p + c.length, 0));
119
+ let f = 0;
120
+ for (const p of s)
121
+ d.set(p, f), f += p.length;
122
+ return d;
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ function wn(e) {
128
+ const n = Math.max(1980, e.getFullYear());
129
+ return {
130
+ time: e.getHours() << 11 | e.getMinutes() << 5 | Math.floor(e.getSeconds() / 2),
131
+ date: n - 1980 << 9 | e.getMonth() + 1 << 5 | e.getDate()
132
+ };
133
+ }
134
+ async function Re(e) {
135
+ const n = new TextEncoder(), a = [], s = [];
136
+ let l = 0;
137
+ for (const b of e) {
138
+ const k = n.encode(b.path), r = await xn(b.data), i = !r || r.length >= b.data.length, x = i ? b.data : r, u = bn(b.data), { time: C, date: w } = wn(b.modified ?? /* @__PURE__ */ new Date()), v = new DataView(new ArrayBuffer(30));
139
+ v.setUint32(0, 67324752, !0), v.setUint16(4, 20, !0), v.setUint16(6, 2048, !0), v.setUint16(8, i ? 0 : 8, !0), v.setUint16(10, C, !0), v.setUint16(12, w, !0), v.setUint32(14, u, !0), v.setUint32(18, x.length, !0), v.setUint32(22, b.data.length, !0), v.setUint16(26, k.length, !0), a.push(new Uint8Array(v.buffer), k, x);
140
+ const y = new DataView(new ArrayBuffer(46));
141
+ y.setUint32(0, 33639248, !0), y.setUint16(4, 788, !0), y.setUint16(6, 20, !0), y.setUint16(8, 2048, !0), y.setUint16(10, i ? 0 : 8, !0), y.setUint16(12, C, !0), y.setUint16(14, w, !0), y.setUint32(16, u, !0), y.setUint32(20, x.length, !0), y.setUint32(24, b.data.length, !0), y.setUint16(28, k.length, !0), y.setUint32(38, 33188 << 16 >>> 0, !0), y.setUint32(42, l, !0), s.push(new Uint8Array(y.buffer), k), l += 30 + k.length + x.length;
142
+ }
143
+ const d = s.reduce((b, k) => b + k.length, 0), f = new DataView(new ArrayBuffer(22));
144
+ f.setUint32(0, 101010256, !0), f.setUint16(8, e.length, !0), f.setUint16(10, e.length, !0), f.setUint32(12, d, !0), f.setUint32(16, l, !0);
145
+ const p = [...a, ...s, new Uint8Array(f.buffer)], c = new Uint8Array(p.reduce((b, k) => b + k.length, 0));
146
+ let m = 0;
147
+ for (const b of p)
148
+ c.set(b, m), m += b.length;
149
+ return c;
150
+ }
151
+ const kn = [
152
+ "id",
153
+ "title",
154
+ "format",
155
+ "versions",
156
+ "created_at",
157
+ "updated_at",
158
+ "session_id",
159
+ "session_title",
160
+ "projects",
161
+ "tokens",
162
+ "cost_usd",
163
+ "size_bytes",
164
+ "storage_bytes",
165
+ "published_url",
166
+ "published_target",
167
+ "published_version",
168
+ "expires_at"
169
+ ];
170
+ function vn(e) {
171
+ if (e == null) return "";
172
+ if (typeof e == "number") return Number.isFinite(e) ? String(e) : "";
173
+ let n = S(e);
174
+ return /^[=+\-@]/.test(n) && (n = `'${n}`), /[",]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n;
175
+ }
176
+ function yn(e, n) {
177
+ const a = e.map((s) => {
178
+ const l = ce(s), d = [.../* @__PURE__ */ new Set([...s.projects ?? [], ...s.versions.map((f) => f.project ?? "")])].filter(Boolean);
179
+ return [
180
+ s.id,
181
+ s.title,
182
+ s.format,
183
+ s.versions.length,
184
+ s.created_at,
185
+ s.updated_at,
186
+ s.session_id,
187
+ n(s.session_id),
188
+ d.join(" "),
189
+ s.usage?.total_tokens,
190
+ s.usage?.cost_usd,
191
+ s.size,
192
+ et(s),
193
+ l?.url,
194
+ l?.target,
195
+ l?.version,
196
+ l?.expiresAt
197
+ ].map(vn);
198
+ });
199
+ return `${[kn, ...a].map((s) => s.join(",")).join(`\r
200
+ `)}\r
201
+ `;
202
+ }
203
+ const We = 10, fe = (e, n, a = `${n}s`) => `${e} ${e === 1 ? n : a}`;
204
+ function V(e, n) {
205
+ return n.targets.length === 1 && n.version !== void 0 ? n.version : e.version;
206
+ }
207
+ function Nn(e, n) {
208
+ const { rows: a, targets: s } = e, l = s.length === 1 ? s[0] : null, d = l ? V(l, e) : 0, f = l ? l.versions.find((m) => m.version === d)?.files.length ?? At(l) : 0, p = [
209
+ {
210
+ kind: "csv",
211
+ key: "c",
212
+ label: "CSV",
213
+ what: `${fe(a.length, "row")} ${e.rowsAre}, a line each; no viewer links`,
214
+ ...a.length ? {} : { unavailable: "no rows to write" }
215
+ }
216
+ ];
217
+ if (!s.length) return p;
218
+ p.push({
219
+ kind: "zip",
220
+ key: "z",
221
+ label: "ZIP",
222
+ what: l ? `every file of v${d} (${fe(f, "file")})` : `${fe(s.length, "artifact")}, a folder each, at their newest versions`
223
+ }), p.push({
224
+ kind: "pdf",
225
+ key: "p",
226
+ label: "PDF",
227
+ what: l ? `v${d} as the page prints, through the browser's print dialog` : "one per artifact, as each page prints",
228
+ ...n ? { unavailable: n } : s.length > We ? { unavailable: `more than ${We} at once: tick fewer, or take the ZIP` } : {}
229
+ });
230
+ const c = new Set(s.map((m) => m.format));
231
+ if (c.size === 1) {
232
+ const m = c.has("markdown"), b = c.has("html");
233
+ (m || b) && p.push({
234
+ kind: "source",
235
+ key: m ? "m" : "h",
236
+ label: m ? "Markdown" : "HTML",
237
+ what: l ? `${l.entry} of v${d}, as written${f > 1 ? "; its other files are in the ZIP" : ""}` : `each one's ${m ? ".md" : ".html"}, as written`
238
+ });
239
+ }
240
+ return p;
241
+ }
242
+ function ve(e) {
243
+ return e.replace(/[^\w.-]+/g, "-").replace(/^[.-]+|[.-]+$/g, "") || "artifact";
244
+ }
245
+ function me(e, n, a) {
246
+ return `${ve(e.id)}-v${n}.${a}`;
247
+ }
248
+ function ge(e, n = /* @__PURE__ */ new Date()) {
249
+ const a = (l) => String(l).padStart(2, "0");
250
+ return `artifacts-${`${n.getFullYear()}${a(n.getMonth() + 1)}${a(n.getDate())}`}-${a(n.getHours())}${a(n.getMinutes())}${a(n.getSeconds())}.${e}`;
251
+ }
252
+ function $n(e) {
253
+ return !e || e.startsWith("/") || e.includes("\\") || /^[a-z]:/i.test(e) ? !1 : e.split("/").every((n) => n !== "" && n !== "." && n !== "..");
254
+ }
255
+ function Cn(e, n, a, s) {
256
+ return s ? `${ve(e.id)}/v${n}/${a}` : `${ve(e.id)}-v${n}/${a}`;
257
+ }
258
+ function de({ format: e }) {
259
+ return /* @__PURE__ */ t("span", { className: "rounded border border-line-soft bg-surface-alt px-1 font-mono text-[10.5px] font-semibold text-muted", children: Ke(e) });
260
+ }
261
+ const Sn = { private: "neutral", workspace: "accent", public: "warn" };
262
+ function ze({ artifact: e }) {
263
+ const n = F(e);
264
+ return n ? /* @__PURE__ */ t(H, { tone: Sn[n], children: Dt[n] }) : null;
265
+ }
266
+ function _e({ artifact: e, now: n = Date.now() }) {
267
+ const a = ce(e, n);
268
+ return a ? a.expired ? /* @__PURE__ */ t(H, { tone: "danger", children: "Expired" }) : a.behind ? /* @__PURE__ */ o(H, { tone: "warn", children: [
269
+ "Published v",
270
+ a.version
271
+ ] }) : a.soon ? /* @__PURE__ */ t(H, { tone: "warn", children: "Expiring" }) : /* @__PURE__ */ t(H, { tone: "ok", children: "Published" }) : null;
272
+ }
273
+ const zn = 20, ie = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Set(), Ne = /* @__PURE__ */ new Set();
274
+ async function _n(e) {
275
+ await Promise.all(
276
+ e.map(async (n) => {
277
+ ye.add(n);
278
+ try {
279
+ ie.set(n, { kind: "session", session: await A.getSession(n), live: !!re.get(n) });
280
+ } catch (a) {
281
+ ie.set(n, a instanceof Ut && a.status === 404 ? { kind: "deleted" } : { kind: "unknown" });
282
+ } finally {
283
+ ye.delete(n);
284
+ }
285
+ })
286
+ );
287
+ for (const n of Ne) n();
288
+ }
289
+ function An(e) {
290
+ const [, n] = $(0), s = [...new Set(e.filter((l) => !!l))].join(",");
291
+ return K(() => {
292
+ const l = () => n((f) => f + 1);
293
+ Ne.add(l);
294
+ const d = s ? s.split(",").filter((f) => !ie.has(f) && !ye.has(f)) : [];
295
+ return d.length && _n(d.slice(0, zn)), () => {
296
+ Ne.delete(l);
297
+ };
298
+ }, [s]), (l) => {
299
+ if (!l) return { kind: "none" };
300
+ const d = re.get(l)?.session;
301
+ return d ? { kind: "session", session: d, live: !0 } : ie.get(l) ?? { kind: "unknown" };
302
+ };
303
+ }
304
+ function Un(e) {
305
+ return e.kind === "session" ? e.session.title ?? null : null;
306
+ }
307
+ async function Ae(e) {
308
+ if (!Pt(e)) return e;
309
+ const n = await A.artifact(e.id, G(e) ? e.owner : null);
310
+ return Ce(n), n;
311
+ }
312
+ async function q(e, n) {
313
+ const a = await Ae(e);
314
+ if (n !== void 0) return { url: Tt(A.artifactLink(a.url), n), what: "viewer" };
315
+ const s = Lt(a);
316
+ return s.what === "viewer" ? { url: A.artifactLink(s.url), what: "viewer" } : s;
317
+ }
318
+ async function $e(e) {
319
+ const n = window.open("about:blank", "_blank");
320
+ try {
321
+ const a = await e();
322
+ n ? (n.opener = null, n.location.href = a) : window.open(a, "_blank", "noopener");
323
+ } catch (a) {
324
+ throw n?.close(), a;
325
+ }
326
+ }
327
+ function te(e, n, a) {
328
+ const s = URL.createObjectURL(new Blob([n], { type: a })), l = document.createElement("a");
329
+ l.href = s, l.download = e, l.rel = "noopener", document.body.appendChild(l), l.click(), l.remove(), setTimeout(() => URL.revokeObjectURL(s), 1e3);
330
+ }
331
+ async function be(e, n, a) {
332
+ const s = await Ae(e), l = a ? [a] : s.versions.find((d) => d.version === n)?.files ?? [s.entry];
333
+ return Promise.all(
334
+ l.filter($n).map(async (d) => ({ path: d, data: await A.artifactFile(s.url, d, n) }))
335
+ );
336
+ }
337
+ async function nt(e, n, a) {
338
+ const { rows: s, targets: l } = n, d = l.length > 1;
339
+ if (e === "csv")
340
+ return te(ge("csv"), yn(s, a), "text/csv;charset=utf-8"), `Saved ${s.length} row${s.length === 1 ? "" : "s"} as CSV`;
341
+ if (e === "pdf") {
342
+ const m = l[0], b = V(m, n);
343
+ return await $e(async () => (await q(m, b)).url), "Opened the page: print it to PDF from the browser (⌘P or Ctrl+P)";
344
+ }
345
+ if (e === "zip") {
346
+ const m = [];
347
+ for (const k of l) {
348
+ const r = V(k, n);
349
+ for (const i of await be(k, r)) m.push({ path: Cn(k, r, i.path, d), data: i.data });
350
+ }
351
+ const b = d ? ge("zip") : me(l[0], V(l[0], n), "zip");
352
+ return te(b, await Re(m), "application/zip"), `Saved ${m.length} file${m.length === 1 ? "" : "s"} as ${b}`;
353
+ }
354
+ const f = (m) => m.format === "markdown" ? "md" : "html";
355
+ if (!d) {
356
+ const m = l[0], b = V(m, n), [k] = await be(m, b, m.entry), r = me(m, b, f(m));
357
+ return te(r, k.data, m.format === "markdown" ? "text/markdown;charset=utf-8" : "text/html;charset=utf-8"), `Saved ${r}`;
358
+ }
359
+ const p = [];
360
+ for (const m of l) {
361
+ const [b] = await be(m, m.version, m.entry);
362
+ p.push({ path: me(m, m.version, f(m)), data: b.data });
363
+ }
364
+ const c = ge("zip");
365
+ return te(c, await Re(p), "application/zip"), `Saved ${p.length} sources as ${c}`;
366
+ }
367
+ const oe = (e) => e.length === 1 ? `“${S(e[0].title)}”` : `${e.length} artifacts`;
368
+ function Dn({
369
+ items: e,
370
+ link: n,
371
+ canUnpublish: a,
372
+ onClose: s,
373
+ onDone: l,
374
+ onMakePrivate: d,
375
+ onExport: f
376
+ }) {
377
+ const { toast: p } = J(), c = Bt(e, n), m = e.filter((g) => Ge(g, a).ok), [b, k] = $(""), [r, i] = $(!1), [x, u] = $(null), [C, w] = $(null), v = c.confirm.kind === "type" ? c.confirm.word : null, y = v === null || b.trim().toLowerCase() === v, O = async () => {
378
+ u("delete"), w(null);
379
+ const g = [];
380
+ try {
381
+ for (const z of e)
382
+ await A.deleteArtifact(z.id, { unpublish: r && m.includes(z) }), g.push(z.id);
383
+ p(`Deleted ${oe(e)}`, "ok"), l();
384
+ } catch (z) {
385
+ w(`${g.length ? `Deleted ${g.length}, then: ` : ""}${E(z)}`);
386
+ } finally {
387
+ Rt(g), ne(void 0, !0), u(null);
388
+ }
389
+ };
390
+ return /* @__PURE__ */ t(
391
+ Se,
392
+ {
393
+ open: !0,
394
+ onClose: s,
395
+ title: `Delete ${oe(e)}?`,
396
+ size: "md",
397
+ footer: /* @__PURE__ */ o(j, { children: [
398
+ /* @__PURE__ */ t(N, { variant: "ghost", onClick: s, children: "Cancel" }),
399
+ /* @__PURE__ */ t(
400
+ N,
401
+ {
402
+ icon: /* @__PURE__ */ t(Ie, { size: 14 }),
403
+ loading: x === "save",
404
+ disabled: x !== null,
405
+ onClick: async () => {
406
+ u("save");
407
+ try {
408
+ await f();
409
+ } catch (g) {
410
+ w(E(g));
411
+ } finally {
412
+ u(null);
413
+ }
414
+ },
415
+ children: "Save a copy"
416
+ }
417
+ ),
418
+ e.every((g) => g.access && g.access !== "private") && /* @__PURE__ */ t(N, { disabled: x !== null, onClick: d, children: "Make private instead" }),
419
+ /* @__PURE__ */ t(N, { variant: "danger", loading: x === "delete", disabled: !y || x !== null, onClick: () => {
420
+ O();
421
+ }, children: "Delete" })
422
+ ] }),
423
+ children: /* @__PURE__ */ o("div", { className: "flex flex-col gap-3 text-[13px]", children: [
424
+ /* @__PURE__ */ t("ul", { className: "list-disc space-y-1 pl-5 text-ink", children: c.breaks.map((g) => /* @__PURE__ */ t("li", { children: g }, g)) }),
425
+ c.staysUp.length > 0 && /* @__PURE__ */ t(B, { tone: "warn", title: "What stays up", children: /* @__PURE__ */ t("ul", { className: "space-y-1", children: c.staysUp.map((g) => /* @__PURE__ */ t("li", { className: "break-words", children: g }, g)) }) }),
426
+ m.length > 0 && /* @__PURE__ */ o("label", { className: "flex items-center gap-2 text-ink", children: [
427
+ /* @__PURE__ */ t("input", { type: "checkbox", checked: r, onChange: (g) => i(g.target.checked) }),
428
+ "Take the published ",
429
+ m.length === 1 ? "copy" : "copies",
430
+ " down first (nothing is deleted if that fails)"
431
+ ] }),
432
+ v !== null && /* @__PURE__ */ o("label", { className: "flex flex-col gap-1.5", children: [
433
+ /* @__PURE__ */ o("span", { className: "text-muted", children: [
434
+ "Type ",
435
+ /* @__PURE__ */ t("strong", { className: "font-mono text-ink", children: v }),
436
+ " to delete."
437
+ ] }),
438
+ /* @__PURE__ */ t("input", { className: Mt, value: b, onChange: (g) => k(g.target.value), autoComplete: "off", spellCheck: !1, "aria-label": "Confirm" })
439
+ ] }),
440
+ C && /* @__PURE__ */ t(B, { tone: "danger", children: C })
441
+ ] })
442
+ }
443
+ );
444
+ }
445
+ function Tn({ items: e, onClose: n }) {
446
+ const { toast: a } = J(), s = Et(e), [l, d] = $(null), [f, p] = $(!1), [c, m] = $(null), b = async (r) => {
447
+ p(!0), m(null);
448
+ try {
449
+ for (const i of e) Ce(r === "revoke" ? await A.revokeArtifactLinks(i.id) : await A.setArtifactAccess(i.id, r));
450
+ a(`${e.length === 1 ? S(e[0].title) : `${e.length} artifacts`}: ${It(r)}`, "ok"), n();
451
+ } catch (i) {
452
+ m(E(i));
453
+ } finally {
454
+ p(!1);
455
+ }
456
+ }, k = (r) => {
457
+ if (r.current || r.unavailable) return;
458
+ const i = Wt(e, r.change);
459
+ i ? d({ choice: r, question: i }) : b(r.change);
460
+ };
461
+ return /* @__PURE__ */ o(
462
+ Se,
463
+ {
464
+ open: !0,
465
+ onClose: n,
466
+ title: `Who can open ${oe(e)}`,
467
+ size: "md",
468
+ footer: l ? /* @__PURE__ */ o(j, { children: [
469
+ /* @__PURE__ */ t(N, { variant: "ghost", onClick: () => d(null), children: "Back" }),
470
+ /* @__PURE__ */ t(N, { variant: l.choice.change === "public" ? "warning" : "danger", loading: f, onClick: () => {
471
+ b(l.choice.change);
472
+ }, children: l.choice.label })
473
+ ] }) : /* @__PURE__ */ t(N, { variant: "ghost", onClick: n, children: "Close" }),
474
+ children: [
475
+ l ? /* @__PURE__ */ t("p", { className: "text-[13px] text-ink", children: l.question }) : /* @__PURE__ */ t("ul", { className: "flex flex-col gap-1.5", children: s.map((r) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ o(
476
+ "button",
477
+ {
478
+ type: "button",
479
+ disabled: f || !!r.unavailable || r.current,
480
+ onClick: () => k(r),
481
+ className: "flex w-full flex-col rounded-lg border border-line-soft px-3 py-2 text-left hover:border-accent hover:bg-accent-soft disabled:cursor-default disabled:opacity-60 disabled:hover:border-line-soft disabled:hover:bg-transparent",
482
+ children: [
483
+ /* @__PURE__ */ o("span", { className: "text-[13px] font-semibold text-ink", children: [
484
+ r.label,
485
+ r.current && /* @__PURE__ */ t("span", { className: "ml-1.5 font-normal text-muted", children: "· now" })
486
+ ] }),
487
+ /* @__PURE__ */ t("span", { className: "text-[12px] text-muted", children: r.unavailable ?? r.what })
488
+ ]
489
+ }
490
+ ) }, r.key)) }),
491
+ c && /* @__PURE__ */ t(B, { tone: "danger", className: "mt-3", children: c })
492
+ ]
493
+ }
494
+ );
495
+ }
496
+ function Ln({ artifact: e, onClose: n }) {
497
+ const { toast: a } = J(), [s, l] = $(!1), [d, f] = $(null), p = async () => {
498
+ l(!0), f(null);
499
+ try {
500
+ Ce(await A.unpublishArtifact(e.id)), a(`Took the published copy of ${S(e.title)} down`, "ok"), n();
501
+ } catch (c) {
502
+ f(E(c));
503
+ } finally {
504
+ l(!1);
505
+ }
506
+ };
507
+ return /* @__PURE__ */ t(
508
+ Se,
509
+ {
510
+ open: !0,
511
+ onClose: n,
512
+ title: `Take ${oe([e])} down?`,
513
+ description: "The published address stops opening for everyone. The artifact itself stays here, and can be published again.",
514
+ size: "sm",
515
+ footer: /* @__PURE__ */ o(j, { children: [
516
+ /* @__PURE__ */ t(N, { variant: "ghost", onClick: n, children: "Cancel" }),
517
+ /* @__PURE__ */ t(N, { variant: "danger", loading: s, onClick: () => {
518
+ p();
519
+ }, children: "Take it down" })
520
+ ] }),
521
+ children: d && /* @__PURE__ */ t(B, { tone: "danger", children: d })
522
+ }
523
+ );
524
+ }
525
+ const Pn = { c: pt, z: ht, p: ut, m: He, h: dt };
526
+ function st({
527
+ scope: e,
528
+ sessionTitle: n,
529
+ label: a = "Export"
530
+ }) {
531
+ const { toast: s } = J(), [l, d] = $(!1), f = Nn(e, e.targets.length > 1 ? "the browser prints one page at a time: pick one, or take the ZIP" : null), p = async (c) => {
532
+ d(!0);
533
+ try {
534
+ s(await nt(c, e, n), "ok");
535
+ } catch (m) {
536
+ s(`Export failed: ${E(m)}`, "danger");
537
+ } finally {
538
+ d(!1);
539
+ }
540
+ };
541
+ return /* @__PURE__ */ o(on, { children: [
542
+ /* @__PURE__ */ t(cn, { as: N, size: "sm", icon: /* @__PURE__ */ t(Ie, { size: 14 }), loading: l, disabled: l || !e.rows.length && !e.targets.length, children: a }),
543
+ /* @__PURE__ */ o(Ot, { className: "w-80", children: [
544
+ /* @__PURE__ */ t(Ft, { children: e.targets.length === 1 ? S(e.targets[0].title) : `${e.rows.length} ${e.rowsAre}` }),
545
+ f.map((c) => {
546
+ const m = Pn[c.key] ?? He;
547
+ return /* @__PURE__ */ t(jt, { icon: /* @__PURE__ */ t(m, { size: 14, className: "shrink-0" }), disabled: !!c.unavailable, onClick: () => {
548
+ p(c.kind);
549
+ }, children: /* @__PURE__ */ o("span", { className: "flex min-w-0 flex-col", children: [
550
+ /* @__PURE__ */ t("span", { children: c.label }),
551
+ /* @__PURE__ */ t("span", { className: "text-[11.5px] text-muted", children: c.unavailable ?? c.what })
552
+ ] }) }, c.key);
553
+ })
554
+ ] })
555
+ ] });
556
+ }
557
+ function L({ label: e, children: n }) {
558
+ return /* @__PURE__ */ o("div", { className: "grid grid-cols-[96px_1fr] gap-2 text-[12.5px]", children: [
559
+ /* @__PURE__ */ t("dt", { className: "text-muted", children: e }),
560
+ /* @__PURE__ */ t("dd", { className: "min-w-0 break-words text-ink", children: n })
561
+ ] });
562
+ }
563
+ function Bn({ artifact: e }) {
564
+ const [n, a] = $(null), [s, l] = $(null);
565
+ return K(() => {
566
+ let d = !1;
567
+ return l(null), Ae(e).then((f) => !d && a(A.artifactLink(f.url))).catch((f) => !d && l(E(f))), () => {
568
+ d = !0;
569
+ };
570
+ }, [e]), s ? /* @__PURE__ */ o(B, { tone: "danger", children: [
571
+ "Could not open the page: ",
572
+ s
573
+ ] }) : n ? /* @__PURE__ */ t(
574
+ "iframe",
575
+ {
576
+ title: `${S(e.title)} (preview)`,
577
+ src: n,
578
+ sandbox: "allow-scripts allow-forms allow-popups allow-modals allow-downloads",
579
+ referrerPolicy: "no-referrer",
580
+ className: "h-[min(60vh,560px)] w-full rounded-lg border border-line-soft bg-white"
581
+ }
582
+ ) : /* @__PURE__ */ t("div", { className: "h-72 animate-pulse rounded-lg border border-line-soft bg-surface-sunken" });
583
+ }
584
+ function Mn({
585
+ artifact: e,
586
+ link: n,
587
+ canUnpublish: a,
588
+ mentionIn: s,
589
+ onAction: l,
590
+ sessionTitle: d
591
+ }) {
592
+ const { toast: f } = J(), p = Date.now(), c = ce(e, p), m = Ht(e, p), b = G(e), k = Ge(e, a, p), r = (w) => f(E(w), "danger"), i = async (w, v) => {
593
+ try {
594
+ const y = await Kt(await w);
595
+ f(y ? v : "Could not copy to the clipboard", y ? "ok" : "danger");
596
+ } catch (y) {
597
+ r(y);
598
+ }
599
+ }, x = () => {
600
+ i(
601
+ q(e).then((w) => w.url),
602
+ c && !c.expired ? "Copied the published link: anyone with it can open the page" : `Copied the link: ${he(e)}`
603
+ );
604
+ }, u = Vt(e), C = e.usage;
605
+ return /* @__PURE__ */ o("article", { className: "flex flex-col gap-4", children: [
606
+ /* @__PURE__ */ o("header", { className: "flex flex-col gap-1.5", children: [
607
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-1.5", children: [
608
+ /* @__PURE__ */ t(de, { format: e.format }),
609
+ /* @__PURE__ */ o("span", { className: "text-[12px] text-muted", children: [
610
+ "v",
611
+ e.version
612
+ ] }),
613
+ /* @__PURE__ */ t(ze, { artifact: e }),
614
+ /* @__PURE__ */ t(_e, { artifact: e, now: p }),
615
+ b && /* @__PURE__ */ t("span", { className: "text-[12px] text-muted", children: "shared with you" })
616
+ ] }),
617
+ /* @__PURE__ */ t("h2", { className: "text-[17px] font-semibold break-words text-ink", children: S(e.title) }),
618
+ e.description && /* @__PURE__ */ t("p", { className: "text-[13px] text-muted", children: S(e.description) }),
619
+ /* @__PURE__ */ t("p", { className: "font-mono text-[11.5px] text-faint", children: e.id })
620
+ ] }),
621
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap gap-1.5", children: [
622
+ /* @__PURE__ */ t(N, { size: "sm", variant: "primary", icon: /* @__PURE__ */ t(Be, { size: 14 }), onClick: () => {
623
+ $e(async () => (await q(e)).url).catch(r);
624
+ }, children: "Open" }),
625
+ /* @__PURE__ */ t(N, { size: "sm", icon: /* @__PURE__ */ t(ft, { size: 14 }), onClick: x, children: "Copy link" }),
626
+ c?.claimUrl && !c.expired && /* @__PURE__ */ t(N, { size: "sm", icon: /* @__PURE__ */ t(mt, { size: 14 }), onClick: () => {
627
+ i(c.claimUrl, "Copied the claim link: whoever opens it first can keep the page");
628
+ }, children: "Copy claim link" }),
629
+ s && /* @__PURE__ */ t(N, { size: "sm", icon: /* @__PURE__ */ t(gt, { size: 14 }), onClick: () => s.mention(`@artifact:${e.id} `), title: `Mention it in ${s.title}`, children: "Mention" }),
630
+ !b && e.access && /* @__PURE__ */ t(N, { size: "sm", icon: /* @__PURE__ */ t(Ve, { size: 14 }), onClick: () => l("access"), children: "Who can open" }),
631
+ !b && k.ok && /* @__PURE__ */ t(N, { size: "sm", icon: /* @__PURE__ */ t(bt, { size: 14 }), onClick: () => l("unpublish"), children: "Take down" }),
632
+ /* @__PURE__ */ t(st, { scope: { rows: [e], targets: [e], rowsAre: "shown" }, sessionTitle: d }),
633
+ !b && /* @__PURE__ */ t(N, { size: "sm", variant: "danger", icon: /* @__PURE__ */ t(qe, { size: 14 }), onClick: () => l("delete"), children: "Delete" })
634
+ ] }),
635
+ /* @__PURE__ */ t(Bn, { artifact: e }),
636
+ /* @__PURE__ */ o("dl", { className: "flex flex-col gap-1.5", children: [
637
+ c && /* @__PURE__ */ o(L, { label: "Published", children: [
638
+ /* @__PURE__ */ t("a", { href: c.url, target: "_blank", rel: "noreferrer noopener", className: "break-all text-accent hover:underline", children: S(c.url) }),
639
+ /* @__PURE__ */ o("span", { className: "text-muted", children: [
640
+ " ",
641
+ "· v",
642
+ c.version,
643
+ c.target ? ` · ${S(c.target)}` : "",
644
+ c.expired ? " · expired, unless someone claimed it" : c.expiresAt ? ` · expires in ${qt(c.expiresAt, p)}` : "",
645
+ c.behind && !c.expired ? ` · behind v${e.version}` : ""
646
+ ] }),
647
+ !k.ok && !c.expired && /* @__PURE__ */ t("div", { className: "text-[11.5px] text-faint", children: k.why })
648
+ ] }),
649
+ m && /* @__PURE__ */ o(L, { label: "Taken down", children: [
650
+ /* @__PURE__ */ t("span", { className: "break-all", children: S(m.url) }),
651
+ " ",
652
+ /* @__PURE__ */ o("span", { className: "text-muted", children: [
653
+ "· ",
654
+ Ee(m.at, p)
655
+ ] })
656
+ ] }),
657
+ Oe(e) && /* @__PURE__ */ t(L, { label: "Access", children: Oe(e) }),
658
+ /* @__PURE__ */ t(L, { label: "Its link", children: he(e, p) }),
659
+ Fe(e, p) && /* @__PURE__ */ t(L, { label: "Opened", children: Fe(e, p) }),
660
+ /* @__PURE__ */ t(L, { label: "Made in", children: u.length ? /* @__PURE__ */ t("span", { className: "flex flex-col", children: u.map((w) => {
661
+ const v = n(w);
662
+ return v.kind === "deleted" ? /* @__PURE__ */ t("span", { className: "text-muted", children: "a deleted session" }, w) : /* @__PURE__ */ t(St, { to: Ye(w), className: "truncate text-accent hover:underline", children: v.kind === "session" ? S(v.session.title ?? `Session ${w.slice(0, 8)}`) : `Session ${w.slice(0, 8)}` }, w);
663
+ }) }) : /* @__PURE__ */ t("span", { className: "text-muted", children: "no session" }) }),
664
+ e.projects?.length ? /* @__PURE__ */ t(L, { label: "Repository", children: e.projects.map(S).join(", ") }) : null,
665
+ /* @__PURE__ */ o(L, { label: "Updated", children: [
666
+ /* @__PURE__ */ t("time", { dateTime: e.updated_at, title: new Date(e.updated_at).toLocaleString(), children: Y(e.updated_at, p) }),
667
+ /* @__PURE__ */ o("span", { className: "text-muted", children: [
668
+ " · made ",
669
+ Y(e.created_at, p)
670
+ ] })
671
+ ] }),
672
+ (typeof e.size == "number" || C) && /* @__PURE__ */ o(L, { label: "Size", children: [
673
+ typeof e.size == "number" ? R(e.size) : "",
674
+ C ? `${typeof e.size == "number" ? " · " : ""}≈${D(C.total_tokens)} tokens${C.cost_usd ? ` · ${Ze(C.cost_usd)}` : ""}` : ""
675
+ ] })
676
+ ] }),
677
+ /* @__PURE__ */ o("section", { children: [
678
+ /* @__PURE__ */ t("h3", { className: "mb-1.5 text-[11px] font-semibold tracking-wider text-muted uppercase", children: "Versions" }),
679
+ /* @__PURE__ */ t("ol", { className: "flex flex-col divide-y divide-line-soft rounded-lg border border-line-soft", children: [...e.versions].reverse().map((w) => /* @__PURE__ */ o("li", { className: "flex items-center gap-2 px-2.5 py-1.5 text-[12.5px]", children: [
680
+ /* @__PURE__ */ o("span", { className: "w-8 font-mono text-muted", children: [
681
+ "v",
682
+ w.version
683
+ ] }),
684
+ /* @__PURE__ */ o("span", { className: "min-w-0 flex-1 truncate text-ink", children: [
685
+ Ee(w.created_at, p),
686
+ /* @__PURE__ */ o("span", { className: "text-muted", children: [
687
+ " ",
688
+ "· ",
689
+ w.files.length,
690
+ " file",
691
+ w.files.length === 1 ? "" : "s",
692
+ typeof w.bytes == "number" ? ` · ${R(w.bytes)}` : "",
693
+ w.published && !w.published.removed_at ? " · published" : "",
694
+ w.session_id && w.session_id !== e.session_id ? ` · ${d(w.session_id) ?? "another session"}` : ""
695
+ ] })
696
+ ] }),
697
+ /* @__PURE__ */ t(
698
+ N,
699
+ {
700
+ size: "xs",
701
+ variant: "ghost",
702
+ icon: /* @__PURE__ */ t(Be, { size: 12 }),
703
+ onClick: () => {
704
+ $e(async () => (await q(e, w.version)).url).catch(r);
705
+ },
706
+ children: "Open"
707
+ }
708
+ ),
709
+ /* @__PURE__ */ t(
710
+ N,
711
+ {
712
+ size: "xs",
713
+ variant: "ghost",
714
+ icon: /* @__PURE__ */ t(xt, { size: 12 }),
715
+ onClick: () => {
716
+ i(q(e, w.version).then((v) => v.url), `Copied the link to v${w.version}: ${he(e)}`);
717
+ },
718
+ children: "Copy"
719
+ }
720
+ )
721
+ ] }, w.version)) })
722
+ ] })
723
+ ] });
724
+ }
725
+ const En = [
726
+ { id: "type", label: "Type" },
727
+ { id: "title", label: "Title", className: "min-w-48" },
728
+ { id: "session", label: "Session", className: "hidden lg:table-cell" },
729
+ { id: "created", label: "Made", className: "hidden md:table-cell" },
730
+ { id: "updated", label: "Updated" },
731
+ { id: "version", label: "v", numeric: !0 },
732
+ { id: "tokens", label: "≈Tokens", numeric: !0, className: "hidden md:table-cell" },
733
+ { id: "size", label: "Size", numeric: !0, className: "hidden md:table-cell" },
734
+ { id: "published", label: "Published" },
735
+ { id: "access", label: "Access", className: "hidden sm:table-cell" },
736
+ { id: "views", label: "Opens", numeric: !0, className: "hidden lg:table-cell" }
737
+ ];
738
+ function On({
739
+ rows: e,
740
+ sessionTitle: n,
741
+ initialSort: a = "updated",
742
+ initialDescending: s = !0,
743
+ onOpen: l,
744
+ onDelete: d,
745
+ onAccess: f
746
+ }) {
747
+ const [p, c] = $(a), [m, b] = $(s), [k, r] = $(/* @__PURE__ */ new Set()), i = Date.now(), x = le(() => Gt(e, p, m, n, i), [e, p, m, n, i]), u = x.filter((g) => k.has(M(g))), C = u.filter((g) => !G(g)), w = Yt(x, i), v = (g) => {
748
+ g === p ? b((z) => !z) : (c(g), b(g !== "title" && g !== "type" && g !== "session"));
749
+ }, y = (g) => r((z) => {
750
+ const T = new Set(z), P = M(g);
751
+ return T.has(P) ? T.delete(P) : T.add(P), T;
752
+ }), O = x.length > 0 && u.length === x.length;
753
+ return /* @__PURE__ */ o("div", { className: "flex flex-col gap-2", children: [
754
+ /* @__PURE__ */ o("div", { className: "flex min-h-8 flex-wrap items-center gap-2 text-[12.5px] text-muted", children: [
755
+ /* @__PURE__ */ t("span", { children: u.length ? `${u.length} ticked` : "Tick rows to act on several" }),
756
+ /* @__PURE__ */ t(N, { size: "xs", variant: "subtle", icon: /* @__PURE__ */ t(Ve, { size: 12 }), disabled: !C.length, onClick: () => f(C), children: "Who can open" }),
757
+ /* @__PURE__ */ t(N, { size: "xs", variant: "subtle", icon: /* @__PURE__ */ t(qe, { size: 12 }), disabled: !C.length, onClick: () => d(C), children: "Delete" }),
758
+ /* @__PURE__ */ t("span", { className: "ml-auto", children: /* @__PURE__ */ t(
759
+ st,
760
+ {
761
+ scope: u.length ? { rows: u, targets: u, rowsAre: "ticked" } : { rows: x, targets: [], rowsAre: "shown" },
762
+ sessionTitle: n
763
+ }
764
+ ) })
765
+ ] }),
766
+ /* @__PURE__ */ t("div", { className: "overflow-x-auto rounded-xl border border-line bg-surface", children: /* @__PURE__ */ o("table", { className: "w-full text-[12.5px]", children: [
767
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ o("tr", { className: "border-b border-line text-left text-[11px] tracking-wider text-muted uppercase", children: [
768
+ /* @__PURE__ */ t("th", { className: "w-8 px-2 py-2", children: /* @__PURE__ */ t(
769
+ "input",
770
+ {
771
+ type: "checkbox",
772
+ "aria-label": "Tick every row",
773
+ checked: O,
774
+ onChange: () => r(O ? /* @__PURE__ */ new Set() : new Set(x.map(M)))
775
+ }
776
+ ) }),
777
+ En.map((g) => /* @__PURE__ */ t("th", { className: Z("px-2 py-2 font-semibold whitespace-nowrap", g.numeric && "text-right", g.className), "aria-sort": p === g.id ? m ? "descending" : "ascending" : void 0, children: /* @__PURE__ */ o("button", { type: "button", onClick: () => v(g.id), className: "inline-flex items-center gap-1 uppercase hover:text-ink", children: [
778
+ g.label,
779
+ p === g.id && (m ? /* @__PURE__ */ t(wt, { size: 11 }) : /* @__PURE__ */ t(kt, { size: 11 }))
780
+ ] }) }, g.id))
781
+ ] }) }),
782
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-line-soft", children: x.map((g) => {
783
+ const z = M(g);
784
+ return /* @__PURE__ */ o("tr", { className: Z("hover:bg-surface-hover", k.has(z) && "bg-accent-soft"), children: [
785
+ /* @__PURE__ */ t("td", { className: "px-2 py-1.5", children: /* @__PURE__ */ t("input", { type: "checkbox", "aria-label": `Tick ${S(g.title)}`, checked: k.has(z), onChange: () => y(g) }) }),
786
+ /* @__PURE__ */ t("td", { className: "px-2 py-1.5", children: /* @__PURE__ */ t(de, { format: g.format }) }),
787
+ /* @__PURE__ */ t("td", { className: "max-w-80 px-2 py-1.5", children: /* @__PURE__ */ t("button", { type: "button", onClick: () => l(g), className: "block w-full truncate text-left font-medium text-ink hover:text-accent hover:underline", children: S(g.title) }) }),
788
+ /* @__PURE__ */ t("td", { className: "hidden max-w-48 truncate px-2 py-1.5 text-muted lg:table-cell", children: n(g.session_id) ?? (g.session_id ? "…" : "—") }),
789
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-1.5 whitespace-nowrap text-muted md:table-cell", children: Y(g.created_at, i) }),
790
+ /* @__PURE__ */ t("td", { className: "px-2 py-1.5 whitespace-nowrap text-muted", children: Y(g.updated_at, i) }),
791
+ /* @__PURE__ */ t("td", { className: "px-2 py-1.5 text-right tabular-nums", children: g.version }),
792
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-1.5 text-right tabular-nums md:table-cell", children: g.usage ? D(g.usage.total_tokens) : "—" }),
793
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-1.5 text-right whitespace-nowrap tabular-nums md:table-cell", children: typeof g.size == "number" ? R(g.size) : "—" }),
794
+ /* @__PURE__ */ t("td", { className: "px-2 py-1.5", children: /* @__PURE__ */ t(_e, { artifact: g, now: i }) }),
795
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-1.5 sm:table-cell", children: /* @__PURE__ */ t(ze, { artifact: g }) }),
796
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-1.5 text-right tabular-nums lg:table-cell", children: g.views ? we(g) : "—" })
797
+ ] }, z);
798
+ }) }),
799
+ /* @__PURE__ */ t("tfoot", { children: /* @__PURE__ */ o("tr", { className: "border-t border-line text-[12px] font-semibold text-ink", children: [
800
+ /* @__PURE__ */ t("td", { className: "px-2 py-2", children: "Σ" }),
801
+ /* @__PURE__ */ o("td", { className: "px-2 py-2", colSpan: 2, children: [
802
+ w.count,
803
+ " artifact",
804
+ w.count === 1 ? "" : "s",
805
+ " · ",
806
+ w.published,
807
+ " published"
808
+ ] }),
809
+ /* @__PURE__ */ t("td", { className: "hidden lg:table-cell" }),
810
+ /* @__PURE__ */ t("td", { className: "hidden md:table-cell" }),
811
+ /* @__PURE__ */ t("td", {}),
812
+ /* @__PURE__ */ t("td", { className: "px-2 py-2 text-right tabular-nums", children: w.versions }),
813
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-2 text-right tabular-nums md:table-cell", title: w.partial ? "Some artifacts carry no usage: the sum leaves them out" : void 0, children: w.tokens === null ? "—" : `${D(w.tokens)}${w.partial ? "+" : ""}` }),
814
+ /* @__PURE__ */ t("td", { className: "hidden px-2 py-2 text-right tabular-nums md:table-cell", children: w.bytes === null ? "—" : R(w.bytes) }),
815
+ /* @__PURE__ */ t("td", { colSpan: 3 })
816
+ ] }) })
817
+ ] }) })
818
+ ] });
819
+ }
820
+ function I({ label: e, value: n, children: a, action: s }) {
821
+ return /* @__PURE__ */ o("section", { className: "flex flex-col gap-1 rounded-xl border border-line bg-surface px-3.5 py-3", children: [
822
+ /* @__PURE__ */ t("h3", { className: "text-[11px] font-semibold tracking-wider text-muted uppercase", children: e }),
823
+ /* @__PURE__ */ t("p", { className: "text-[22px] leading-tight font-semibold text-ink tabular-nums", children: n }),
824
+ a && /* @__PURE__ */ t("div", { className: "text-[12px] text-muted", children: a }),
825
+ s && /* @__PURE__ */ t("div", { className: "mt-auto pt-1", children: s })
826
+ ] });
827
+ }
828
+ function Fn({ weeks: e, picked: n, onPick: a }) {
829
+ const [s, l] = $(null), d = Math.max(0, ...e.map((c) => c.tokens)), f = Math.max(1, d), p = e.find((c) => c.start === (s ?? n)) ?? null;
830
+ return /* @__PURE__ */ o("div", { className: "flex flex-col gap-2", children: [
831
+ /* @__PURE__ */ o("div", { className: "flex h-5 items-baseline justify-between text-[12px]", children: [
832
+ /* @__PURE__ */ t("span", { className: "text-muted", children: "≈Tokens the versions took, by week" }),
833
+ /* @__PURE__ */ t("span", { className: "text-ink tabular-nums", children: p ? `${se(p.start)}: ≈${D(p.tokens)} · ${p.versions} version${p.versions === 1 ? "" : "s"}` : d ? `peak ≈${D(d)}` : "no usage measured in these weeks" })
834
+ ] }),
835
+ /* @__PURE__ */ t("fieldset", { className: "flex h-36 items-end gap-0.5 border-b border-line", "aria-label": "Tokens by week", children: e.map((c) => {
836
+ const m = c.tokens ? Math.max(2, c.tokens / f * 100) : 0, b = n === c.start;
837
+ return /* @__PURE__ */ t(
838
+ "button",
839
+ {
840
+ type: "button",
841
+ "aria-pressed": b,
842
+ "aria-label": `${se(c.start)}: about ${D(c.tokens)} tokens over ${c.versions} versions`,
843
+ onClick: () => a(b ? null : c.start),
844
+ onMouseEnter: () => l(c.start),
845
+ onMouseLeave: () => l(null),
846
+ onFocus: () => l(c.start),
847
+ onBlur: () => l(null),
848
+ className: "group flex h-full min-w-0 flex-1 items-end justify-center rounded-t-sm hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent",
849
+ children: /* @__PURE__ */ t(
850
+ "span",
851
+ {
852
+ className: Z("block w-full max-w-6 rounded-t-[4px] transition-[height]", b ? "bg-accent" : "bg-accent/60 group-hover:bg-accent"),
853
+ style: { height: `${m}%` }
854
+ }
855
+ )
856
+ },
857
+ c.start
858
+ );
859
+ }) }),
860
+ /* @__PURE__ */ o("div", { className: "flex justify-between text-[11px] text-faint", children: [
861
+ /* @__PURE__ */ t("span", { children: se(e[0].start) }),
862
+ /* @__PURE__ */ t("span", { children: "this week" })
863
+ ] })
864
+ ] });
865
+ }
866
+ function jn({
867
+ list: e,
868
+ project: n,
869
+ onOpen: a,
870
+ onLedger: s
871
+ }) {
872
+ const [l, d] = $(8), [f, p] = $(!1), [c, m] = $(null), b = Date.now(), k = le(() => f && n ? e.filter((u) => pn(u, n)) : e, [e, f, n]), r = le(() => mn(k, b, l), [k, b, l]), i = c === null ? null : r.weeks.find((u) => u.start === c), x = i ? k.filter((u) => hn(u, i.start, i.end)) : [];
873
+ return /* @__PURE__ */ o("div", { className: "flex flex-col gap-4", children: [
874
+ /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: [
875
+ /* @__PURE__ */ t(
876
+ ke,
877
+ {
878
+ label: "Weeks",
879
+ value: String(l),
880
+ onChange: (u) => {
881
+ d(Number(u)), m(null);
882
+ },
883
+ options: dn.map((u) => ({ value: String(u), label: `${u} weeks` }))
884
+ }
885
+ ),
886
+ /* @__PURE__ */ o("label", { className: Z("flex items-center gap-1.5 text-[12.5px]", n ? "text-ink" : "text-faint"), title: n ? void 0 : "Open this from a session in a repository to count only its artifacts", children: [
887
+ /* @__PURE__ */ t("input", { type: "checkbox", checked: f, disabled: !n, onChange: (u) => p(u.target.checked) }),
888
+ "Only ",
889
+ n ? /* @__PURE__ */ t("span", { className: "font-mono", children: n }) : "this repository"
890
+ ] })
891
+ ] }),
892
+ /* @__PURE__ */ o("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-5", children: [
893
+ /* @__PURE__ */ o(I, { label: "Artifacts", value: String(r.count), children: [
894
+ r.newThisWeek,
895
+ " new this week",
896
+ r.byFormat.length ? ` · ${r.byFormat.map((u) => `${u.count} ${u.tag}`).join(", ")}` : ""
897
+ ] }),
898
+ /* @__PURE__ */ o(I, { label: "≈Tokens", value: r.tokens === null ? "—" : `${D(r.tokens)}${r.tokensPartial ? "+" : ""}`, children: [
899
+ r.perArtifact !== null ? `≈${D(r.perArtifact)} each` : "not measured by this server",
900
+ r.cost !== null ? ` · ${Ze(r.cost, !r.costPartial)}` : ""
901
+ ] }),
902
+ /* @__PURE__ */ o(I, { label: "Storage", value: r.bytes === null ? "—" : R(r.bytes), children: [
903
+ r.versions,
904
+ " version",
905
+ r.versions === 1 ? "" : "s",
906
+ " · ",
907
+ r.files,
908
+ " file",
909
+ r.files === 1 ? "" : "s"
910
+ ] }),
911
+ /* @__PURE__ */ o(
912
+ I,
913
+ {
914
+ label: "Published",
915
+ value: String(r.published.live),
916
+ action: r.stale > 0 && /* @__PURE__ */ o(N, { size: "xs", variant: "subtle", onClick: () => s("stale"), children: [
917
+ r.stale,
918
+ " stale"
919
+ ] }),
920
+ children: [
921
+ r.published.temporary,
922
+ " temporary · ",
923
+ r.published.permanent,
924
+ " permanent",
925
+ r.shared ? ` · ${r.shared.count} shared, opened ${r.shared.opens}× in 30 days` : ""
926
+ ]
927
+ }
928
+ ),
929
+ /* @__PURE__ */ o(
930
+ I,
931
+ {
932
+ label: `Untouched ${Je} days`,
933
+ value: String(r.untouched.count),
934
+ action: r.untouched.count > 0 && /* @__PURE__ */ t(N, { size: "xs", variant: "subtle", onClick: () => s("untouched"), children: "Show them" }),
935
+ children: [
936
+ r.untouched.bytes !== null ? R(r.untouched.bytes) : "",
937
+ r.untouched.tokens !== null ? ` · ≈${D(r.untouched.tokens)} tokens` : "",
938
+ r.untouched.openedLately ? ` · ${r.untouched.openedLately} still opened by others` : ""
939
+ ]
940
+ }
941
+ )
942
+ ] }),
943
+ /* @__PURE__ */ o("div", { className: "grid gap-4 lg:grid-cols-[2fr_1fr]", children: [
944
+ /* @__PURE__ */ o("section", { className: "rounded-xl border border-line bg-surface p-3.5", children: [
945
+ /* @__PURE__ */ t(Fn, { weeks: r.weeks, picked: c, onPick: m }),
946
+ i && /* @__PURE__ */ o("div", { className: "mt-3", children: [
947
+ /* @__PURE__ */ o("h3", { className: "mb-1.5 text-[12px] font-semibold text-ink", children: [
948
+ "Written in the week of ",
949
+ se(i.start)
950
+ ] }),
951
+ x.length ? /* @__PURE__ */ t("ul", { className: "flex flex-col gap-1", children: x.map((u) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ o("button", { type: "button", onClick: () => a(u), className: "flex w-full items-center gap-2 text-left text-[12.5px] hover:text-accent", children: [
952
+ /* @__PURE__ */ t(de, { format: u.format }),
953
+ /* @__PURE__ */ t("span", { className: "truncate", children: S(u.title) })
954
+ ] }) }, `${u.owner}:${u.id}`)) }) : /* @__PURE__ */ t("p", { className: "text-[12.5px] text-muted", children: "Nothing." })
955
+ ] })
956
+ ] }),
957
+ /* @__PURE__ */ o("section", { className: "rounded-xl border border-line bg-surface p-3.5", children: [
958
+ /* @__PURE__ */ t("h3", { className: "mb-2 text-[11px] font-semibold tracking-wider text-muted uppercase", children: "Heaviest" }),
959
+ r.heaviest.length ? /* @__PURE__ */ t("ol", { className: "flex flex-col gap-1.5", children: r.heaviest.map((u) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ o("button", { type: "button", onClick: () => a(u), className: "flex w-full items-center gap-2 text-left text-[12.5px] hover:text-accent", children: [
960
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate text-ink", children: S(u.title) }),
961
+ /* @__PURE__ */ o("span", { className: "text-muted tabular-nums", children: [
962
+ "≈",
963
+ D(u.usage?.total_tokens ?? 0)
964
+ ] })
965
+ ] }) }, `${u.owner}:${u.id}`)) }) : /* @__PURE__ */ t("p", { className: "text-[12.5px] text-muted", children: "No artifact carries usage yet." })
966
+ ] })
967
+ ] })
968
+ ] });
969
+ }
970
+ const Rn = {
971
+ all: "All",
972
+ session: "This session",
973
+ published: "Published",
974
+ stale: "Stale",
975
+ shared: "Shared",
976
+ others: "Others'"
977
+ };
978
+ function Wn(e, n) {
979
+ const a = e.toLowerCase();
980
+ return n.toLowerCase().split(/\s+/).filter(Boolean).every((s) => a.includes(s));
981
+ }
982
+ function xe({ artifact: e, selected: n, onSelect: a, now: s }) {
983
+ return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ o(
984
+ "button",
985
+ {
986
+ type: "button",
987
+ onClick: a,
988
+ "aria-current": n || void 0,
989
+ className: Z(
990
+ "flex w-full flex-col gap-0.5 rounded-lg border px-3 py-2 text-left transition-colors",
991
+ n ? "border-accent bg-accent-soft" : "border-transparent hover:bg-surface-hover"
992
+ ),
993
+ children: [
994
+ /* @__PURE__ */ o("span", { className: "flex min-w-0 items-center gap-1.5", children: [
995
+ /* @__PURE__ */ t(de, { format: e.format }),
996
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate text-[13px] font-medium text-ink", children: S(e.title) }),
997
+ e.version > 1 && /* @__PURE__ */ o("span", { className: "text-[11.5px] text-muted", children: [
998
+ "v",
999
+ e.version
1000
+ ] })
1001
+ ] }),
1002
+ /* @__PURE__ */ o("span", { className: "flex min-w-0 flex-wrap items-center gap-1.5 text-[11.5px] text-muted", children: [
1003
+ /* @__PURE__ */ t(_e, { artifact: e, now: s }),
1004
+ /* @__PURE__ */ t(ze, { artifact: e }),
1005
+ /* @__PURE__ */ t("span", { children: Y(e.updated_at, s) })
1006
+ ] })
1007
+ ]
1008
+ }
1009
+ ) });
1010
+ }
1011
+ function Yn() {
1012
+ const e = zt(), [n, a] = _t(), s = n.get("view") ?? "list", l = n.get("q") ?? "", d = n.get("session"), f = n.get("only"), [p, c] = $(d ? "session" : "all"), [m, b] = $(!1), [k, r] = $(null), [i, x] = $(() => d ? re.get(d)?.session ?? null : null), u = Zt(), C = Jt((h) => h.info), w = !!C?.capabilities.artifact_unpublish, v = Date.now(), y = (h) => a(
1013
+ (_) => {
1014
+ const ue = new URLSearchParams(_);
1015
+ for (const [Le, Pe] of Object.entries(h))
1016
+ Pe === null ? ue.delete(Le) : ue.set(Le, Pe);
1017
+ return ue;
1018
+ },
1019
+ { replace: !0 }
1020
+ );
1021
+ K(() => {
1022
+ ne(d);
1023
+ }, [d]), K(() => {
1024
+ if (!d || i?.id === d) return;
1025
+ let h = !1;
1026
+ return A.getSession(d).then((_) => !h && x(_)).catch(() => {
1027
+ }), () => {
1028
+ h = !0;
1029
+ };
1030
+ }, [d, i?.id]);
1031
+ const O = u.list.some((h) => h.access) || u.shared.length > 0, g = rn(O), z = le(() => [...u.list, ...u.shared], [u.list, u.shared]), T = An(z.flatMap((h) => [h.session_id, ...h.versions.map((_) => _.session_id ?? null)])), P = (h) => Un(T(h)), Ue = Xt(i), at = Qt(u.list, Ue, v, u.shared), De = (p === "others" ? u.shared : u.list).filter((h) => en(h, p, Ue, v)), X = l.trim() ? De.filter((h) => Wn(tn(h, P(h.session_id)), l)) : De, lt = n.get("id") ? `${n.get("owner") ?? ""}:${n.get("id")}` : null, U = z.find((h) => `${G(h) ? h.owner ?? "" : ""}:${h.id}` === lt) ?? null, Q = n.get("id");
1032
+ K(() => {
1033
+ u.loaded && Q && !z.some((h) => h.id === Q) && y({ id: null, q: Q });
1034
+ }, [u.loaded, Q]);
1035
+ const W = (h) => y({ id: h.id, owner: G(h) ? h.owner ?? null : null, view: s === "stats" || s === "table" ? "list" : null }), rt = (h) => {
1036
+ U && r(h === "unpublish" ? { kind: "unpublish", artifact: U } : { kind: h, items: [U] });
1037
+ }, it = d && i ? {
1038
+ title: S(i.title ?? "the session"),
1039
+ mention: (h) => {
1040
+ const _ = re.get(d);
1041
+ _ && _.seedDraft(`${_.draft.trimEnd()}${_.draft.trim() ? " " : ""}${h}`), e(Ye(d));
1042
+ }
1043
+ } : null, ot = f === "untouched" ? u.list.filter((h) => tt(h, v)) : f === "stale" ? u.list.filter((h) => nn(h, v)) : X, ee = m ? sn(X, T) : null, ct = (h, _) => _.kind === "session" ? S(_.session.title ?? `Session ${h.slice(0, 8)}`) : `Session ${h.slice(0, 8)}`, Te = /* @__PURE__ */ o("div", { className: "flex flex-wrap items-center gap-2", children: [
1044
+ /* @__PURE__ */ o("div", { className: "relative w-full sm:w-64", children: [
1045
+ /* @__PURE__ */ t(Ct, { size: 14, className: "pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-faint", "aria-hidden": "true" }),
1046
+ /* @__PURE__ */ t(
1047
+ "input",
1048
+ {
1049
+ type: "search",
1050
+ value: l,
1051
+ onChange: (h) => y({ q: h.target.value || null }),
1052
+ placeholder: "Search titles, ids, descriptions, sessions",
1053
+ "aria-label": "Search artifacts",
1054
+ className: "h-8 w-full rounded-md border border-line bg-surface pr-2 pl-8 text-[13px] text-ink placeholder:text-faint focus:border-accent focus:ring-2 focus:ring-accent/20 focus:outline-none"
1055
+ }
1056
+ )
1057
+ ] }),
1058
+ /* @__PURE__ */ t(
1059
+ ke,
1060
+ {
1061
+ label: "Show",
1062
+ value: p,
1063
+ onChange: (h) => {
1064
+ c(h), y({ only: null });
1065
+ },
1066
+ className: "max-w-full overflow-x-auto",
1067
+ options: g.map((h) => ({
1068
+ value: h,
1069
+ label: /* @__PURE__ */ o("span", { className: "whitespace-nowrap", children: [
1070
+ Rn[h],
1071
+ " ",
1072
+ /* @__PURE__ */ t("span", { className: "text-faint tabular-nums", children: at[h] })
1073
+ ] })
1074
+ }))
1075
+ }
1076
+ ),
1077
+ s === "list" && /* @__PURE__ */ o("label", { className: "flex items-center gap-1.5 text-[12.5px] text-ink", children: [
1078
+ /* @__PURE__ */ t("input", { type: "checkbox", checked: m, onChange: (h) => b(h.target.checked) }),
1079
+ "Group by session"
1080
+ ] })
1081
+ ] });
1082
+ return /* @__PURE__ */ o("div", { className: "min-h-full bg-bg", children: [
1083
+ /* @__PURE__ */ t(
1084
+ an,
1085
+ {
1086
+ eyebrow: "Agents' pages",
1087
+ title: "Artifacts",
1088
+ subtitle: u.loaded ? `${u.list.length} yours${u.shared.length ? ` · ${u.shared.length} shared with you` : ""}${u.project ? ` · ${u.project}` : ""}` : "Loading…",
1089
+ actions: /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
1090
+ /* @__PURE__ */ t(
1091
+ ke,
1092
+ {
1093
+ label: "View",
1094
+ value: s,
1095
+ onChange: (h) => y({ view: h === "list" ? null : h, only: null }),
1096
+ options: [
1097
+ { value: "list", label: /* @__PURE__ */ t(vt, { size: 14, "aria-label": "List" }) },
1098
+ { value: "table", label: /* @__PURE__ */ t(yt, { size: 14, "aria-label": "Table" }) },
1099
+ { value: "stats", label: /* @__PURE__ */ t(Nt, { size: 14, "aria-label": "Usage" }) }
1100
+ ]
1101
+ }
1102
+ ),
1103
+ /* @__PURE__ */ t(N, { size: "sm", variant: "ghost", icon: /* @__PURE__ */ t($t, { size: 14 }), loading: u.loading, onClick: () => {
1104
+ ne(d);
1105
+ }, children: "Reload" })
1106
+ ] })
1107
+ }
1108
+ ),
1109
+ /* @__PURE__ */ o("div", { className: "mx-auto flex max-w-[1400px] flex-col gap-3 px-4 py-4 sm:px-5", children: [
1110
+ C && C.capabilities.artifacts === !1 && /* @__PURE__ */ t(B, { tone: "info", children: "This server keeps no artifacts: agents here cannot make pages." }),
1111
+ u.error && /* @__PURE__ */ o(B, { tone: "danger", action: /* @__PURE__ */ t(N, { size: "xs", onClick: () => {
1112
+ ne(d);
1113
+ }, children: "Retry" }), children: [
1114
+ "Could not list the artifacts: ",
1115
+ u.error
1116
+ ] }),
1117
+ !u.loaded && u.loading ? /* @__PURE__ */ t("div", { className: "flex justify-center py-16 text-accent", children: /* @__PURE__ */ t(ln, {}) }) : s === "stats" ? /* @__PURE__ */ t(jn, { list: u.list, project: u.project, onOpen: W, onLedger: (h) => y({ view: "table", only: h }) }) : s === "table" ? /* @__PURE__ */ o(j, { children: [
1118
+ f ? /* @__PURE__ */ t(B, { tone: "info", action: /* @__PURE__ */ t(N, { size: "xs", onClick: () => y({ only: null }), children: "Show all" }), children: f === "untouched" ? "What nobody has written for 30 days, oldest first." : "Published at an older version, or a temporary page past its expiry." }) : Te,
1119
+ /* @__PURE__ */ t(
1120
+ On,
1121
+ {
1122
+ rows: ot,
1123
+ sessionTitle: P,
1124
+ initialSort: "updated",
1125
+ initialDescending: f !== "untouched",
1126
+ onOpen: W,
1127
+ onDelete: (h) => r({ kind: "delete", items: h }),
1128
+ onAccess: (h) => r({ kind: "access", items: h })
1129
+ },
1130
+ f ?? "all"
1131
+ )
1132
+ ] }) : /* @__PURE__ */ o(j, { children: [
1133
+ Te,
1134
+ u.loaded && !z.length ? /* @__PURE__ */ t("div", { className: "rounded-xl border border-line bg-surface", children: /* @__PURE__ */ t(je, { icon: /* @__PURE__ */ t(Me, { size: 20 }), title: "No artifacts yet", children: "Ask an agent for a report, a dashboard or a walkthrough as a page: it shows here, and its card in the transcript opens it." }) }) : /* @__PURE__ */ o("div", { className: "grid gap-4 lg:grid-cols-[minmax(280px,380px)_1fr]", children: [
1135
+ /* @__PURE__ */ o("div", { className: "flex min-w-0 flex-col gap-1", children: [
1136
+ !X.length && /* @__PURE__ */ o("p", { className: "px-3 py-6 text-center text-[13px] text-muted", children: [
1137
+ "Nothing here",
1138
+ l ? ` matches “${l}”` : "",
1139
+ "."
1140
+ ] }),
1141
+ ee ? /* @__PURE__ */ o(j, { children: [
1142
+ ee.groups.map((h) => /* @__PURE__ */ o("section", { children: [
1143
+ /* @__PURE__ */ t("h3", { className: "truncate px-3 pt-2 pb-1 text-[11px] font-semibold tracking-wider text-muted uppercase", children: ct(h.id, h.link) }),
1144
+ /* @__PURE__ */ t("ul", { className: "flex flex-col gap-0.5", children: h.artifacts.map((_) => /* @__PURE__ */ t(xe, { artifact: _, now: v, selected: U === _, onSelect: () => W(_) }, M(_))) })
1145
+ ] }, h.id)),
1146
+ ee.orphans.length > 0 && /* @__PURE__ */ o("section", { children: [
1147
+ /* @__PURE__ */ t("h3", { className: "px-3 pt-2 pb-1 text-[11px] font-semibold tracking-wider text-muted uppercase", children: "No session, or a deleted one" }),
1148
+ /* @__PURE__ */ t("ul", { className: "flex flex-col gap-0.5", children: ee.orphans.map((h) => /* @__PURE__ */ t(xe, { artifact: h, now: v, selected: U === h, onSelect: () => W(h) }, M(h))) })
1149
+ ] })
1150
+ ] }) : /* @__PURE__ */ t("ul", { className: "flex flex-col gap-0.5", children: X.map((h) => /* @__PURE__ */ t(xe, { artifact: h, now: v, selected: U === h, onSelect: () => W(h) }, M(h))) })
1151
+ ] }),
1152
+ /* @__PURE__ */ t("div", { className: "min-w-0 rounded-xl border border-line bg-surface p-4", children: U ? /* @__PURE__ */ t(Mn, { artifact: U, link: T, canUnpublish: w, mentionIn: it, onAction: rt, sessionTitle: P }) : /* @__PURE__ */ t(je, { icon: /* @__PURE__ */ t(Me, { size: 20 }), title: "Pick an artifact", children: "Its page, who can open it, where it was published and its versions show here." }) })
1153
+ ] })
1154
+ ] })
1155
+ ] }),
1156
+ k?.kind === "delete" && /* @__PURE__ */ t(
1157
+ Dn,
1158
+ {
1159
+ items: k.items,
1160
+ link: T,
1161
+ canUnpublish: w,
1162
+ onClose: () => r(null),
1163
+ onDone: () => {
1164
+ r(null), U && k.items.includes(U) && y({ id: null, owner: null });
1165
+ },
1166
+ onMakePrivate: () => r({ kind: "access", items: k.items }),
1167
+ onExport: async () => {
1168
+ await nt("zip", { rows: k.items, targets: k.items }, P);
1169
+ }
1170
+ }
1171
+ ),
1172
+ k?.kind === "access" && /* @__PURE__ */ t(Tn, { items: k.items, onClose: () => r(null) }),
1173
+ k?.kind === "unpublish" && /* @__PURE__ */ t(Ln, { artifact: k.artifact, onClose: () => r(null) })
1174
+ ] });
1175
+ }
1176
+ export {
1177
+ Yn as default
1178
+ };