@loomcycle/explorer 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.
package/dist/index.js CHANGED
@@ -1,104 +1,161 @@
1
- import { jsx as n, jsxs as d, Fragment as q } from "react/jsx-runtime";
2
- import { createContext as Pe, useContext as Te, useMemo as A, useState as b, useRef as ee, useEffect as I, useCallback as G } from "react";
3
- import { LoomcycleClient as Oe } from "@loomcycle/client";
4
- import Ie from "react-markdown";
5
- import Ae from "remark-gfm";
6
- function he(e) {
1
+ import { jsx as n, jsxs as l, Fragment as q } from "react/jsx-runtime";
2
+ import { createContext as Ye, useContext as Ke, useMemo as G, useState as k, useRef as ne, useEffect as U, useCallback as A } from "react";
3
+ import { LoomcycleClient as et } from "@loomcycle/client";
4
+ import tt from "react-markdown";
5
+ import nt from "remark-gfm";
6
+ function Ne(e, a) {
7
7
  return {
8
- pathLs: (a, t, r, c) => e.path(
9
- { op: "ls", path: a, scope: t, recursive: r },
10
- c
8
+ pathLs: (t, r, o, s) => e.path(
9
+ { op: "ls", path: t, scope: r, recursive: o },
10
+ s
11
11
  ),
12
- pathMkdir: (a, t, r) => e.path({ op: "mkdir", path: a, scope: t }, r),
13
- pathMv: (a, t, r, c) => e.path({ op: "mv", path: a, to: t, scope: r }, c),
14
- pathRm: (a, t, r, c) => e.path({ op: "rm", path: a, scope: t, recursive: r }, c),
15
- documentCreate: (a, t, r, c) => e.document(
16
- { op: "create_document", title: a, path: t, scope: r },
17
- c
12
+ pathMkdir: (t, r, o) => e.path({ op: "mkdir", path: t, scope: r }, o),
13
+ pathMv: (t, r, o, s) => e.path({ op: "mv", path: t, to: r, scope: o }, s),
14
+ pathRm: (t, r, o, s) => e.path({ op: "rm", path: t, scope: r, recursive: o }, s),
15
+ documentCreate: (t, r, o, s) => e.document(
16
+ { op: "create_document", title: t, path: r, scope: o },
17
+ s
18
18
  ),
19
- documentDelete: (a, t, r) => e.document({ op: "delete_document", id: a, scope: t }, r),
20
- documentGet: (a, t, r) => e.document({ op: "get_document", id: a, scope: t }, r),
21
- documentsSummary: (a, t, r) => e.document(
19
+ documentDelete: (t, r, o) => e.document({ op: "delete_document", id: t, scope: r }, o),
20
+ documentGet: (t, r, o) => e.document({ op: "get_document", id: t, scope: r }, o),
21
+ documentsSummary: (t, r, o) => e.document(
22
22
  // documents_summary + document_ids are RFC BN wire additions the pinned
23
23
  // SDK type doesn't enumerate; the /v1/_document passthrough accepts them
24
24
  // verbatim, so cast past DocumentToolInput (same pattern as update_chunk).
25
25
  {
26
26
  op: "documents_summary",
27
- scope: t,
28
- ...a.documentIds ? { document_ids: a.documentIds } : {},
29
- ...a.underPath ? { under_path: a.underPath } : {}
27
+ scope: r,
28
+ ...t.documentIds ? { document_ids: t.documentIds } : {},
29
+ ...t.underPath ? { under_path: t.underPath } : {}
30
30
  },
31
- r
31
+ o
32
32
  ),
33
- documentQueryChunks: (a, t, r) => e.document(
34
- { op: "query_chunks", document_id: a, scope: t, limit: 1e3 },
35
- r
33
+ documentQueryChunks: (t, r, o) => e.document(
34
+ { op: "query_chunks", document_id: t, scope: r, limit: 1e3 },
35
+ o
36
36
  ),
37
- documentGetChunk: (a, t, r) => e.document({ op: "get_chunk", id: a, scope: t }, r),
38
- documentGetEdges: (a, t, r) => e.document(
37
+ documentGetChunk: (t, r, o) => e.document({ op: "get_chunk", id: t, scope: r }, o),
38
+ documentCreateChunk: (t, r, o, s, c, i) => e.document(
39
+ {
40
+ op: "create_chunk",
41
+ document_id: t,
42
+ parent_id: r,
43
+ scope: s,
44
+ ...i ? { after_id: i } : {},
45
+ ...o
46
+ },
47
+ c
48
+ ),
49
+ documentReorderChunk: (t, r, o, s) => e.document(
50
+ // reorder_chunk is an RFC BP wire op the pinned SDK type doesn't
51
+ // enumerate; the /v1/_document passthrough accepts it verbatim.
52
+ { op: "reorder_chunk", id: t, direction: r, scope: o },
53
+ s
54
+ ),
55
+ documentDeleteChunk: (t, r, o) => e.document({ op: "delete_chunk", id: t, scope: r }, o),
56
+ documentSetAsset: (t, r, o, s, c, i) => e.document(
57
+ // set_asset is an RFC BO wire op the pinned SDK type doesn't enumerate;
58
+ // the /v1/_document passthrough accepts it verbatim.
59
+ {
60
+ op: "set_asset",
61
+ id: t,
62
+ media_type: r,
63
+ data: o,
64
+ ...s ? { filename: s } : {},
65
+ scope: c
66
+ },
67
+ i
68
+ ),
69
+ documentGetEdges: (t, r, o) => e.document(
39
70
  // get_edges is an RFC BN P4 wire op the pinned SDK type doesn't
40
71
  // enumerate; the /v1/_document passthrough accepts it verbatim.
41
- { op: "get_edges", document_id: a, scope: t },
42
- r
72
+ { op: "get_edges", document_id: t, scope: r },
73
+ o
43
74
  ),
44
- documentUpdateChunk: (a, t, r, c, l) => e.document(
75
+ documentUpdateChunk: (t, r, o, s, c) => e.document(
45
76
  // `patch.fields` is unknown but DocumentToolInput.fields is a typed
46
77
  // Record; the cast reconciles the spread (the server accepts arbitrary
47
78
  // JSON there). Op order + arg names mirror the wire contract exactly.
48
79
  {
49
80
  op: "update_chunk",
50
- id: a,
51
- revision: t,
52
- scope: c,
53
- ...r
81
+ id: t,
82
+ revision: r,
83
+ scope: s,
84
+ ...o
54
85
  },
55
- l
86
+ c
56
87
  ),
57
- documentExportMd: (a, t, r, c) => e.document(
88
+ documentExportMd: (t, r, o, s) => e.document(
58
89
  {
59
90
  op: "export_md",
60
- document_id: a,
61
- scope: t,
62
- include_metadata: r
91
+ document_id: t,
92
+ scope: r,
93
+ include_metadata: o
63
94
  },
64
- c
65
- )
95
+ s
96
+ ),
97
+ // Present only when an AssetFetch was supplied (the connection path); a bare
98
+ // client can't do the raw binary GET, so the op is omitted and the viewer
99
+ // shows a placeholder.
100
+ ...a ? {
101
+ documentAssetObjectUrl: async (t, r, o) => {
102
+ const s = new URLSearchParams({ scope: r });
103
+ o?.scopeId && s.set("scope_id", o.scopeId), o?.tenant && s.set("tenant", o.tenant);
104
+ const c = await a(
105
+ `/v1/_document/asset/${encodeURIComponent(t)}?${s.toString()}`
106
+ );
107
+ if (!c.ok) throw new Error(`asset fetch failed: ${c.status}`);
108
+ const i = await c.blob();
109
+ return URL.createObjectURL(i);
110
+ }
111
+ } : {}
66
112
  };
67
113
  }
68
- const ve = Pe(null);
69
- function Ge({
114
+ const Me = Ye(null);
115
+ function at({
70
116
  value: e,
71
117
  children: a
72
118
  }) {
73
- return /* @__PURE__ */ n(ve.Provider, { value: e, children: a });
119
+ return /* @__PURE__ */ n(Me.Provider, { value: e, children: a });
74
120
  }
75
- function ce() {
76
- const e = Te(ve);
121
+ function se() {
122
+ const e = Ke(Me);
77
123
  if (!e)
78
124
  throw new Error(
79
125
  "useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)"
80
126
  );
81
127
  return e;
82
128
  }
83
- function je(e) {
129
+ function rt(e) {
84
130
  const a = e.fetch;
85
- return new Oe({
131
+ return new et({
86
132
  baseUrl: e.baseUrl,
87
133
  authToken: e.token || void 0,
88
134
  fetch: (t, r) => a ? a(t, r) : fetch(t, r)
89
135
  });
90
136
  }
91
- function Ne(e) {
137
+ function ot(e) {
138
+ const a = e.fetch, t = (r, o) => a ? a(r, o) : fetch(r, o);
139
+ return (r) => {
140
+ const o = {};
141
+ return e.token && (o.Authorization = `Bearer ${e.token}`), t(e.baseUrl + r, { headers: o });
142
+ };
143
+ }
144
+ function Le(e) {
92
145
  const { dataLayer: a, client: t, connection: r } = e;
93
- return A(() => a || (t ? he(t) : r ? he(je(r)) : null), [a, t, r?.baseUrl, r?.token, r?.fetch]);
146
+ return G(() => a || (t ? Ne(t) : r ? Ne(
147
+ rt(r),
148
+ ot(r)
149
+ // RFC BO — binary image-asset GET
150
+ ) : null), [a, t, r?.baseUrl, r?.token, r?.fetch]);
94
151
  }
95
- function we({
152
+ function Re({
96
153
  theme: e,
97
154
  dataLayer: a,
98
155
  children: t
99
156
  }) {
100
157
  const r = e ? { "data-theme": e } : {};
101
- return a ? /* @__PURE__ */ n("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ n(Ge, { value: a, children: t }) }) : /* @__PURE__ */ n("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ d("div", { className: "error-banner", children: [
158
+ return a ? /* @__PURE__ */ n("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ n(at, { value: a, children: t }) }) : /* @__PURE__ */ n("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ l("div", { className: "error-banner", children: [
102
159
  "@loomcycle/explorer: provide a ",
103
160
  /* @__PURE__ */ n("code", { children: "connection" }),
104
161
  ", ",
@@ -109,48 +166,48 @@ function we({
109
166
  " prop."
110
167
  ] }) });
111
168
  }
112
- const me = 6;
113
- function Ue({
169
+ const we = 6;
170
+ function ct({
114
171
  children: e,
115
172
  defaultLeftWidth: a = 380,
116
173
  minLeftWidth: t = 180,
117
174
  minRightWidth: r = 240,
118
- storageKey: c,
119
- className: l
175
+ storageKey: o,
176
+ className: s
120
177
  }) {
121
- const [s, o] = b(() => {
122
- if (c) {
123
- const v = localStorage.getItem(c), E = v ? parseInt(v, 10) : NaN;
124
- if (Number.isFinite(E) && E >= t) return E;
178
+ const [c, i] = k(() => {
179
+ if (o) {
180
+ const N = localStorage.getItem(o), T = N ? parseInt(N, 10) : NaN;
181
+ if (Number.isFinite(T) && T >= t) return T;
125
182
  }
126
183
  return a;
127
- }), i = ee(null), [u, h] = b(!1);
128
- I(() => {
129
- !c || u || localStorage.setItem(c, String(Math.round(s)));
130
- }, [c, s, u]);
131
- const f = G((v) => {
132
- v.preventDefault(), h(!0), v.target.setPointerCapture(v.pointerId);
133
- }, []), g = G(
134
- (v) => {
135
- if (!u || !i.current) return;
136
- const E = i.current.getBoundingClientRect(), O = v.clientX - E.left, R = E.width - r - me, j = Math.max(t, Math.min(O, R));
137
- o(j);
184
+ }), d = ne(null), [g, m] = k(!1);
185
+ U(() => {
186
+ !o || g || localStorage.setItem(o, String(Math.round(c)));
187
+ }, [o, c, g]);
188
+ const b = A((N) => {
189
+ N.preventDefault(), m(!0), N.target.setPointerCapture(N.pointerId);
190
+ }, []), p = A(
191
+ (N) => {
192
+ if (!g || !d.current) return;
193
+ const T = d.current.getBoundingClientRect(), j = N.clientX - T.left, P = T.width - r - we, W = Math.max(t, Math.min(j, P));
194
+ i(W);
138
195
  },
139
- [u, t, r]
140
- ), M = G((v) => {
141
- h(!1);
196
+ [g, t, r]
197
+ ), O = A((N) => {
198
+ m(!1);
142
199
  try {
143
- v.target.releasePointerCapture(v.pointerId);
200
+ N.target.releasePointerCapture(N.pointerId);
144
201
  } catch {
145
202
  }
146
203
  }, []);
147
- return /* @__PURE__ */ d(
204
+ return /* @__PURE__ */ l(
148
205
  "div",
149
206
  {
150
- ref: i,
151
- className: `splitter ${l ?? ""} ${u ? "dragging" : ""}`,
207
+ ref: d,
208
+ className: `splitter ${s ?? ""} ${g ? "dragging" : ""}`,
152
209
  style: {
153
- gridTemplateColumns: `${s}px ${me}px 1fr`
210
+ gridTemplateColumns: `${c}px ${we}px 1fr`
154
211
  },
155
212
  children: [
156
213
  /* @__PURE__ */ n("div", { className: "splitter-pane splitter-left", children: e[0] }),
@@ -160,11 +217,11 @@ function Ue({
160
217
  className: "splitter-handle",
161
218
  role: "separator",
162
219
  "aria-orientation": "vertical",
163
- "aria-valuenow": Math.round(s),
164
- onPointerDown: f,
165
- onPointerMove: g,
166
- onPointerUp: M,
167
- onPointerCancel: M
220
+ "aria-valuenow": Math.round(c),
221
+ onPointerDown: b,
222
+ onPointerMove: p,
223
+ onPointerUp: O,
224
+ onPointerCancel: O
168
225
  }
169
226
  ),
170
227
  /* @__PURE__ */ n("div", { className: "splitter-pane splitter-right", children: e[1] })
@@ -172,7 +229,39 @@ function Ue({
172
229
  }
173
230
  );
174
231
  }
175
- const se = {
232
+ const it = ["image/png", "image/jpeg", "image/gif", "image/webp"];
233
+ function Ae(e) {
234
+ return it.includes(e);
235
+ }
236
+ function Te(e) {
237
+ return new Promise((a, t) => {
238
+ if (!Ae(e.type)) {
239
+ t(new Error(`unsupported image type "${e.type || "unknown"}" (png, jpeg, gif, webp only)`));
240
+ return;
241
+ }
242
+ const r = new FileReader();
243
+ r.onerror = () => t(r.error ?? new Error("failed to read file")), r.onload = () => {
244
+ const o = String(r.result ?? ""), s = o.indexOf(",");
245
+ if (s < 0) {
246
+ t(new Error("could not decode image data"));
247
+ return;
248
+ }
249
+ a({ mediaType: e.type, data: o.slice(s + 1) });
250
+ }, r.readAsDataURL(e);
251
+ });
252
+ }
253
+ function st(e) {
254
+ if (!e) return null;
255
+ for (let a = 0; a < e.length; a++) {
256
+ const t = e[a];
257
+ if (t.kind === "file" && Ae(t.type)) {
258
+ const r = t.getAsFile();
259
+ if (r) return r;
260
+ }
261
+ }
262
+ return null;
263
+ }
264
+ const fe = {
176
265
  "doc.rfc.draft": "#c99a3a",
177
266
  "doc.rfc.review": "#6a7bd6",
178
267
  "doc.rfc.confirmed": "#3a9ad6",
@@ -184,479 +273,516 @@ const se = {
184
273
  "chunk.review": "#6a7bd6",
185
274
  "chunk.confirmed": "#3a9ad6",
186
275
  "chunk.done": "#3aa06a"
187
- }, Be = 0.16;
188
- function ie(e) {
189
- return e && Object.keys(e).length > 0 ? e : se;
276
+ }, lt = 0.16;
277
+ function ye(e) {
278
+ return e && Object.keys(e).length > 0 ? e : fe;
190
279
  }
191
- function Ce(e, a, t) {
192
- const r = e ?? "", c = a ?? "";
193
- if (r && c && t[`doc.${r}.${c}`]) return t[`doc.${r}.${c}`];
280
+ function Pe(e, a, t) {
281
+ const r = e ?? "", o = a ?? "";
282
+ if (r && o && t[`doc.${r}.${o}`]) return t[`doc.${r}.${o}`];
194
283
  if (r && t[`doc.${r}`]) return t[`doc.${r}`];
195
284
  }
196
- function Fe(e, a) {
285
+ function dt(e, a) {
197
286
  const t = e ?? "";
198
287
  return t ? a[`chunk.${t}`] : void 0;
199
288
  }
200
- function He(e) {
289
+ function ut(e) {
201
290
  const a = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
202
291
  if (!a) return;
203
292
  let t = a[1];
204
293
  t.length === 3 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]);
205
- const r = parseInt(t.slice(0, 2), 16), c = parseInt(t.slice(2, 4), 16), l = parseInt(t.slice(4, 6), 16);
206
- return `rgba(${r}, ${c}, ${l}, ${Be})`;
294
+ const r = parseInt(t.slice(0, 2), 16), o = parseInt(t.slice(2, 4), 16), s = parseInt(t.slice(4, 6), 16);
295
+ return `rgba(${r}, ${o}, ${s}, ${lt})`;
207
296
  }
208
- function de(e) {
297
+ function be(e) {
209
298
  if (!e) return;
210
- const a = He(e);
299
+ const a = ut(e);
211
300
  if (a)
212
301
  return { background: a, borderLeft: `3px solid ${e}` };
213
302
  }
214
- function We(e) {
303
+ function ht(e) {
215
304
  const a = /* @__PURE__ */ new Map();
216
- e.forEach((c) => a.set(c.id, { row: c, children: [] }));
305
+ e.forEach((o) => a.set(o.id, { row: o, children: [] }));
217
306
  const t = [];
218
- e.forEach((c) => {
219
- const l = a.get(c.id);
220
- c.parent_id && a.has(c.parent_id) ? a.get(c.parent_id).children.push(l) : t.push(l);
307
+ e.forEach((o) => {
308
+ const s = a.get(o.id);
309
+ o.parent_id && a.has(o.parent_id) ? a.get(o.parent_id).children.push(s) : t.push(s);
221
310
  });
222
- const r = (c) => {
223
- c.sort((l, s) => l.row.position - s.row.position), c.forEach((l) => r(l.children));
311
+ const r = (o) => {
312
+ o.sort((s, c) => s.row.position - c.row.position), o.forEach((s) => r(s.children));
224
313
  };
225
314
  return r(t), t;
226
315
  }
227
- function _e(e, a) {
316
+ function Ce(e) {
317
+ return e === "image" ? "🖼" : e === "mermaid" ? "📊" : "";
318
+ }
319
+ function Ie(e, a) {
228
320
  for (const t of e) {
229
321
  if (t.row.id === a) return t;
230
- const r = _e(t.children, a);
322
+ const r = Ie(t.children, a);
231
323
  if (r) return r;
232
324
  }
233
325
  }
234
- function ze({
326
+ function mt({
235
327
  tree: e,
236
328
  selectedId: a,
237
329
  onSelect: t,
238
330
  colorEnabled: r,
239
- scheme: c,
240
- linkedIds: l
331
+ scheme: o,
332
+ linkedIds: s
241
333
  }) {
242
- const [s, o] = b(() => /* @__PURE__ */ new Map()), i = G((h) => {
243
- o((f) => {
244
- const g = new Map(f);
245
- return g.set(h, f.get(h) === !1), g;
334
+ const [c, i] = k(() => /* @__PURE__ */ new Map()), d = A((m) => {
335
+ i((b) => {
336
+ const p = new Map(b);
337
+ return p.set(m, b.get(m) === !1), p;
246
338
  });
247
339
  }, []);
248
- I(() => {
340
+ U(() => {
249
341
  if (!a) return;
250
- const h = Je(e, a);
251
- h.length !== 0 && o((f) => {
252
- let g = !1;
253
- const M = new Map(f);
254
- for (const v of h)
255
- M.get(v) === !1 && (M.set(v, !0), g = !0);
256
- return g ? M : f;
342
+ const m = pt(e, a);
343
+ m.length !== 0 && i((b) => {
344
+ let p = !1;
345
+ const O = new Map(b);
346
+ for (const N of m)
347
+ O.get(N) === !1 && (O.set(N, !0), p = !0);
348
+ return p ? O : b;
257
349
  });
258
350
  }, [e, a]);
259
- const u = r ? ie(c) : null;
260
- return e.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "No chunks." }) }) : /* @__PURE__ */ n("ul", { className: "tree chunk-tree", children: e.map((h) => /* @__PURE__ */ n(
261
- xe,
351
+ const g = r ? ye(o) : null;
352
+ return e.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "No chunks." }) }) : /* @__PURE__ */ n("ul", { className: "tree chunk-tree", children: e.map((m) => /* @__PURE__ */ n(
353
+ Ue,
262
354
  {
263
- node: h,
264
- expanded: s,
265
- toggle: i,
355
+ node: m,
356
+ expanded: c,
357
+ toggle: d,
266
358
  selectedId: a,
267
359
  onSelect: t,
268
- tintScheme: u,
269
- linkedIds: l
360
+ tintScheme: g,
361
+ linkedIds: s
270
362
  },
271
- h.row.id
363
+ m.row.id
272
364
  )) });
273
365
  }
274
- function Je(e, a) {
275
- const t = [], r = (c, l) => {
276
- for (const s of c) {
277
- if (s.row.id === a)
278
- return t.push(...l), !0;
279
- if (r(s.children, [...l, s.row.id])) return !0;
366
+ function pt(e, a) {
367
+ const t = [], r = (o, s) => {
368
+ for (const c of o) {
369
+ if (c.row.id === a)
370
+ return t.push(...s), !0;
371
+ if (r(c.children, [...s, c.row.id])) return !0;
280
372
  }
281
373
  return !1;
282
374
  };
283
375
  return r(e, []), t;
284
376
  }
285
- function xe({ node: e, expanded: a, toggle: t, selectedId: r, onSelect: c, tintScheme: l, linkedIds: s }) {
286
- const o = e.children.length > 0, i = a.get(e.row.id) !== !1, u = r === e.row.id, h = l ? de(Fe(e.row.status, l)) : void 0, f = s?.has(e.row.id);
287
- return /* @__PURE__ */ d("li", { className: `node chunk-node ${u ? "selected" : ""}`, children: [
288
- /* @__PURE__ */ d("div", { className: "row chunk-row", style: h, children: [
377
+ function Ue({ node: e, expanded: a, toggle: t, selectedId: r, onSelect: o, tintScheme: s, linkedIds: c }) {
378
+ const i = e.children.length > 0, d = a.get(e.row.id) !== !1, g = r === e.row.id, m = s ? be(dt(e.row.status, s)) : void 0, b = c?.has(e.row.id);
379
+ return /* @__PURE__ */ l("li", { className: `node chunk-node ${g ? "selected" : ""}`, children: [
380
+ /* @__PURE__ */ l("div", { className: "row chunk-row", style: m, children: [
289
381
  /* @__PURE__ */ n(
290
382
  "button",
291
383
  {
292
384
  type: "button",
293
385
  className: "tree-caret",
294
- "aria-label": i ? "collapse" : "expand",
295
- disabled: !o,
296
- onClick: (g) => {
297
- g.stopPropagation(), o && t(e.row.id);
386
+ "aria-label": d ? "collapse" : "expand",
387
+ disabled: !i,
388
+ onClick: (p) => {
389
+ p.stopPropagation(), i && t(e.row.id);
298
390
  },
299
- children: o ? i ? "▼" : "▶" : "·"
391
+ children: i ? d ? "▼" : "▶" : "·"
300
392
  }
301
393
  ),
302
- /* @__PURE__ */ d(
394
+ /* @__PURE__ */ l(
303
395
  "button",
304
396
  {
305
397
  type: "button",
306
398
  className: "chunk-link",
307
- onClick: () => c(e),
399
+ onClick: () => o(e),
308
400
  title: e.row.title,
309
401
  children: [
402
+ Ce(e.row.type) && /* @__PURE__ */ n("span", { className: "chunk-type-icon", "aria-hidden": !0, children: Ce(e.row.type) }),
310
403
  /* @__PURE__ */ n("span", { className: "chunk-title", children: e.row.title || "(untitled)" }),
311
404
  e.row.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: e.row.type }),
312
405
  e.row.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: e.row.status }),
313
- f && /* @__PURE__ */ n("span", { className: "chunk-link-badge", title: "Has cross-reference links", "aria-label": "linked", children: "🔗" })
406
+ b && /* @__PURE__ */ n("span", { className: "chunk-link-badge", title: "Has cross-reference links", "aria-label": "linked", children: "🔗" })
314
407
  ]
315
408
  }
316
409
  )
317
410
  ] }),
318
- o && i && /* @__PURE__ */ n("ul", { className: "children chunk-children", children: e.children.map((g) => /* @__PURE__ */ n(
319
- xe,
411
+ i && d && /* @__PURE__ */ n("ul", { className: "children chunk-children", children: e.children.map((p) => /* @__PURE__ */ n(
412
+ Ue,
320
413
  {
321
- node: g,
414
+ node: p,
322
415
  expanded: a,
323
416
  toggle: t,
324
417
  selectedId: r,
325
- onSelect: c,
326
- tintScheme: l,
327
- linkedIds: s
418
+ onSelect: o,
419
+ tintScheme: s,
420
+ linkedIds: c
328
421
  },
329
- g.row.id
422
+ p.row.id
330
423
  )) })
331
424
  ] });
332
425
  }
333
- function Ve({ chunk: e, scope: a, browse: t, onClose: r, onSaved: c }) {
334
- const l = ce(), [s, o] = b(e.title), [i, u] = b(e.type ?? ""), [h, f] = b(e.status ?? ""), [g, M] = b(e.body ?? ""), [v, E] = b(
426
+ let ft = 0;
427
+ function le({ code: e }) {
428
+ const a = ne(null), [t, r] = k({});
429
+ return U(() => {
430
+ let o = !1;
431
+ return (async () => {
432
+ try {
433
+ const s = (await import("mermaid")).default, c = a.current?.closest("[data-theme]")?.getAttribute("data-theme"), i = c ? c === "dark" : !0;
434
+ s.initialize({ startOnLoad: !1, theme: i ? "dark" : "default", securityLevel: "strict" });
435
+ const { svg: d } = await s.render(`lc-mmd-${ft++}`, e);
436
+ o || r({ svg: d });
437
+ } catch {
438
+ o || r({ err: !0 });
439
+ }
440
+ })(), () => {
441
+ o = !0;
442
+ };
443
+ }, [e]), t.err ? /* @__PURE__ */ n("pre", { className: "md-pre md-mermaid-error", title: "diagram failed to render", children: /* @__PURE__ */ n("code", { children: e }) }) : t.svg ? /* @__PURE__ */ n("div", { ref: a, className: "md-mermaid", dangerouslySetInnerHTML: { __html: t.svg } }) : /* @__PURE__ */ n("div", { ref: a, className: "md-mermaid md-mermaid-loading", children: "rendering diagram…" });
444
+ }
445
+ function gt({ chunk: e, scope: a, browse: t, onClose: r, onSaved: o }) {
446
+ const s = se(), [c, i] = k(e.title), [d, g] = k(e.type ?? ""), [m, b] = k(e.status ?? ""), [p, O] = k(e.body ?? ""), [N, T] = k(
335
447
  e.fields ? JSON.stringify(e.fields, null, 2) : ""
336
- ), [O, R] = b(!1), [j, D] = b(null), [U, $] = b(!1);
337
- return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: r, children: /* @__PURE__ */ d("form", { className: "modal chunk-editor", onClick: (k) => k.stopPropagation(), onSubmit: async (k) => {
338
- k.preventDefault(), D(null), $(!1);
339
- const N = {
340
- body: g,
341
- title: s,
342
- type: i,
343
- status: h
448
+ ), [j, P] = k(!1), [W, R] = k(null), [z, F] = k(!1), B = d === "mermaid", x = d === "image" || !!e.asset, [C, I] = k(p);
449
+ U(() => {
450
+ if (!B) return;
451
+ const h = setTimeout(() => I(p), 400);
452
+ return () => clearTimeout(h);
453
+ }, [p, B]);
454
+ const J = async (h) => {
455
+ R(null), P(!0);
456
+ try {
457
+ const { mediaType: f, data: E } = await Te(h), D = await s.documentSetAsset(e.id, f, E, h.name, a, t);
458
+ o(D), r();
459
+ } catch (f) {
460
+ R(f instanceof Error ? f.message : String(f)), P(!1);
461
+ }
462
+ };
463
+ return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: r, children: /* @__PURE__ */ l("form", { className: "modal chunk-editor", onClick: (h) => h.stopPropagation(), onSubmit: async (h) => {
464
+ h.preventDefault(), R(null), F(!1);
465
+ const f = {
466
+ body: p,
467
+ title: c,
468
+ type: d,
469
+ status: m
344
470
  };
345
- if (v.trim() !== "")
471
+ if (N.trim() !== "")
346
472
  try {
347
- N.fields = JSON.parse(v);
473
+ f.fields = JSON.parse(N);
348
474
  } catch {
349
- D("fields must be valid JSON");
475
+ R("fields must be valid JSON");
350
476
  return;
351
477
  }
352
- R(!0);
478
+ P(!0);
353
479
  try {
354
- const _ = await l.documentUpdateChunk(e.id, e.revision, N, a, t);
355
- c(_), r();
356
- } catch (_) {
357
- const F = _ instanceof Error ? _.message : String(_);
358
- D(F), $(/revision conflict/i.test(F)), R(!1);
480
+ const E = await s.documentUpdateChunk(e.id, e.revision, f, a, t);
481
+ o(E), r();
482
+ } catch (E) {
483
+ const D = E instanceof Error ? E.message : String(E);
484
+ R(D), F(/revision conflict/i.test(D)), P(!1);
359
485
  }
360
486
  }, children: [
361
- /* @__PURE__ */ d("div", { className: "modal-header sticky-top", children: [
487
+ /* @__PURE__ */ l("div", { className: "modal-header sticky-top", children: [
362
488
  /* @__PURE__ */ n("h3", { children: "Edit chunk" }),
363
- /* @__PURE__ */ d("div", { className: "modal-buttons modal-buttons-top", children: [
364
- /* @__PURE__ */ n("button", { type: "button", onClick: r, disabled: O, children: "cancel" }),
365
- /* @__PURE__ */ n("button", { type: "submit", className: "primary", disabled: O, children: O ? "saving…" : "save" })
489
+ /* @__PURE__ */ l("div", { className: "modal-buttons modal-buttons-top", children: [
490
+ /* @__PURE__ */ n("button", { type: "button", onClick: r, disabled: j, children: "cancel" }),
491
+ /* @__PURE__ */ n("button", { type: "submit", className: "primary", disabled: j, children: j ? "saving…" : "save" })
366
492
  ] })
367
493
  ] }),
368
- j && /* @__PURE__ */ d("div", { className: "modal-err", children: [
369
- j,
370
- U && " — reopen the chunk to load the latest, then reapply your edit."
494
+ W && /* @__PURE__ */ l("div", { className: "modal-err", children: [
495
+ W,
496
+ z && " — reopen the chunk to load the latest, then reapply your edit."
371
497
  ] }),
372
- /* @__PURE__ */ d("label", { className: "path-field", children: [
498
+ /* @__PURE__ */ l("label", { className: "path-field", children: [
373
499
  /* @__PURE__ */ n("span", { children: "Title" }),
374
- /* @__PURE__ */ n("input", { className: "path-modal-input", value: s, onChange: (k) => o(k.target.value) })
500
+ /* @__PURE__ */ n("input", { className: "path-modal-input", value: c, onChange: (h) => i(h.target.value) })
375
501
  ] }),
376
- /* @__PURE__ */ d("div", { className: "chunk-editor-row", children: [
377
- /* @__PURE__ */ d("label", { className: "path-field", children: [
502
+ /* @__PURE__ */ l("div", { className: "chunk-editor-row", children: [
503
+ /* @__PURE__ */ l("label", { className: "path-field", children: [
378
504
  /* @__PURE__ */ n("span", { children: "Type" }),
379
505
  /* @__PURE__ */ n(
380
506
  "input",
381
507
  {
382
508
  className: "path-modal-input",
383
- value: i,
509
+ value: d,
384
510
  placeholder: "(none)",
385
- onChange: (k) => u(k.target.value)
511
+ onChange: (h) => g(h.target.value)
386
512
  }
387
513
  )
388
514
  ] }),
389
- /* @__PURE__ */ d("label", { className: "path-field", children: [
515
+ /* @__PURE__ */ l("label", { className: "path-field", children: [
390
516
  /* @__PURE__ */ n("span", { children: "Status" }),
391
517
  /* @__PURE__ */ n(
392
518
  "input",
393
519
  {
394
520
  className: "path-modal-input",
395
- value: h,
521
+ value: m,
396
522
  placeholder: "(none)",
397
- onChange: (k) => f(k.target.value)
523
+ onChange: (h) => b(h.target.value)
398
524
  }
399
525
  )
400
526
  ] })
401
527
  ] }),
402
- /* @__PURE__ */ d("label", { className: "path-field", children: [
403
- /* @__PURE__ */ n("span", { children: "Body (Markdown)" }),
528
+ x && /* @__PURE__ */ l("label", { className: "path-field", children: [
529
+ /* @__PURE__ */ n("span", { children: "Replace image" }),
530
+ /* @__PURE__ */ n(
531
+ "input",
532
+ {
533
+ type: "file",
534
+ accept: "image/png,image/jpeg,image/gif,image/webp",
535
+ disabled: j,
536
+ onChange: (h) => {
537
+ const f = h.target.files?.[0];
538
+ f && J(f);
539
+ }
540
+ }
541
+ )
542
+ ] }),
543
+ /* @__PURE__ */ l("label", { className: "path-field", children: [
544
+ /* @__PURE__ */ n("span", { children: B ? "Mermaid source" : x ? "Caption (optional)" : "Body (Markdown)" }),
404
545
  /* @__PURE__ */ n(
405
546
  "textarea",
406
547
  {
407
548
  className: "modal-textarea chunk-body-input",
408
- rows: 12,
409
- value: g,
410
- onChange: (k) => M(k.target.value)
549
+ rows: B ? 8 : 12,
550
+ value: p,
551
+ onChange: (h) => O(h.target.value)
411
552
  }
412
553
  )
413
554
  ] }),
414
- /* @__PURE__ */ d("label", { className: "path-field", children: [
555
+ B && /* @__PURE__ */ l("div", { className: "path-field", children: [
556
+ /* @__PURE__ */ n("span", { children: "Preview" }),
557
+ /* @__PURE__ */ n("div", { className: "chunk-mermaid-preview", children: C.trim() ? /* @__PURE__ */ n(le, { code: C }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "(enter Mermaid source above)" }) })
558
+ ] }),
559
+ /* @__PURE__ */ l("label", { className: "path-field", children: [
415
560
  /* @__PURE__ */ n("span", { children: "Fields (JSON, optional)" }),
416
561
  /* @__PURE__ */ n(
417
562
  "textarea",
418
563
  {
419
564
  className: "modal-textarea chunk-fields-input",
420
565
  rows: 4,
421
- value: v,
566
+ value: N,
422
567
  placeholder: "{}",
423
- onChange: (k) => E(k.target.value)
568
+ onChange: (h) => T(h.target.value)
424
569
  }
425
570
  )
426
571
  ] })
427
572
  ] }) });
428
573
  }
429
- function Ze(e) {
574
+ function yt(e) {
430
575
  const a = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
431
576
  if (!a) return "#888888";
432
577
  let t = a[1];
433
578
  return t.length === 3 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]), "#" + t.toLowerCase();
434
579
  }
435
- function qe({
580
+ function bt({
436
581
  documentId: e,
437
582
  rootChunkId: a,
438
583
  docType: t,
439
584
  docStatus: r,
440
- chunkStatuses: c,
441
- scope: l,
442
- browse: s,
443
- onClose: o,
444
- onSaved: i
585
+ chunkStatuses: o,
586
+ scope: s,
587
+ browse: c,
588
+ onClose: i,
589
+ onSaved: d
445
590
  }) {
446
- const u = ce(), [h, f] = b(null), [g, M] = b(!1), [v, E] = b({}), [O, R] = b(!1), [j, D] = b(null), [U, $] = b(null), J = A(() => {
447
- const p = new Set(Object.keys(se));
448
- t && p.add(`doc.${t}.${r || "draft"}`);
449
- for (const m of c) m && p.add(`chunk.${m}`);
450
- return [...p].sort();
451
- }, [t, r, c]);
452
- I(() => {
453
- let p = !1;
454
- return u.documentGetChunk(a, l, s).then((m) => {
455
- if (p) return;
456
- f(m);
457
- const T = m.fields ?? {};
458
- M(T.color_enabled === !0);
459
- const S = T.color_scheme ?? {};
460
- E({ ...se, ...S });
461
- }).catch((m) => !p && $(m instanceof Error ? m.message : String(m))), () => {
462
- p = !0;
591
+ const g = se(), [m, b] = k(null), [p, O] = k(!1), [N, T] = k({}), [j, P] = k(!1), [W, R] = k(null), [z, F] = k(null), B = G(() => {
592
+ const h = new Set(Object.keys(fe));
593
+ t && h.add(`doc.${t}.${r || "draft"}`);
594
+ for (const f of o) f && h.add(`chunk.${f}`);
595
+ return [...h].sort();
596
+ }, [t, r, o]);
597
+ U(() => {
598
+ let h = !1;
599
+ return g.documentGetChunk(a, s, c).then((f) => {
600
+ if (h) return;
601
+ b(f);
602
+ const E = f.fields ?? {};
603
+ O(E.color_enabled === !0);
604
+ const D = E.color_scheme ?? {};
605
+ T({ ...fe, ...D });
606
+ }).catch((f) => !h && F(f instanceof Error ? f.message : String(f))), () => {
607
+ h = !0;
463
608
  };
464
- }, [u, a, l, s]);
465
- const k = (p, m) => E((T) => ({ ...T, [p]: m })), N = (p) => ({
466
- ...p ?? {},
467
- color_enabled: g,
468
- color_scheme: v
469
- }), _ = async () => {
470
- if (h) {
471
- R(!0), $(null), D(null);
609
+ }, [g, a, s, c]);
610
+ const x = (h, f) => T((E) => ({ ...E, [h]: f })), C = (h) => ({
611
+ ...h ?? {},
612
+ color_enabled: p,
613
+ color_scheme: N
614
+ }), I = async () => {
615
+ if (m) {
616
+ P(!0), F(null), R(null);
472
617
  try {
473
- await u.documentUpdateChunk(
618
+ await g.documentUpdateChunk(
474
619
  a,
475
- h.revision,
476
- { fields: N(h.fields) },
477
- l,
478
- s
479
- ), i(), o();
480
- } catch (p) {
481
- $(p instanceof Error ? p.message : String(p)), R(!1);
620
+ m.revision,
621
+ { fields: C(m.fields) },
622
+ s,
623
+ c
624
+ ), d(), i();
625
+ } catch (h) {
626
+ F(h instanceof Error ? h.message : String(h)), P(!1);
482
627
  }
483
628
  }
484
- }, F = async () => {
629
+ }, J = async () => {
485
630
  if (!t) {
486
- $("this document has no type to match");
631
+ F("this document has no type to match");
487
632
  return;
488
633
  }
489
- R(!0), $(null), D(null);
634
+ P(!0), F(null), R(null);
490
635
  try {
491
- const { documents: p } = await u.documentsSummary({ underPath: "/" }, l, s), m = (p ?? []).filter(
492
- (S) => S.type === t && S.document_id !== e && S.root_chunk_id
636
+ const { documents: h } = await g.documentsSummary({ underPath: "/" }, s, c), f = (h ?? []).filter(
637
+ (D) => D.type === t && D.document_id !== e && D.root_chunk_id
493
638
  );
494
- let T = 0;
495
- for (const S of m)
639
+ let E = 0;
640
+ for (const D of f)
496
641
  try {
497
- const W = await u.documentGetChunk(S.root_chunk_id, l, s);
498
- await u.documentUpdateChunk(
499
- S.root_chunk_id,
500
- W.revision,
501
- { fields: N(W.fields) },
502
- l,
503
- s
504
- ), T++;
642
+ const Y = await g.documentGetChunk(D.root_chunk_id, s, c);
643
+ await g.documentUpdateChunk(
644
+ D.root_chunk_id,
645
+ Y.revision,
646
+ { fields: C(Y.fields) },
647
+ s,
648
+ c
649
+ ), E++;
505
650
  } catch {
506
651
  }
507
- D(`Applied to ${T} other ${t} document(s).`), i();
508
- } catch (p) {
509
- $(p instanceof Error ? p.message : String(p));
652
+ R(`Applied to ${E} other ${t} document(s).`), d();
653
+ } catch (h) {
654
+ F(h instanceof Error ? h.message : String(h));
510
655
  } finally {
511
- R(!1);
656
+ P(!1);
512
657
  }
513
- }, Z = J.filter((p) => p.startsWith("doc.")), P = J.filter((p) => p.startsWith("chunk."));
514
- return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: o, children: /* @__PURE__ */ d("div", { className: "modal scheme-editor", onClick: (p) => p.stopPropagation(), children: [
515
- /* @__PURE__ */ d("div", { className: "scheme-editor-head", children: [
658
+ }, Q = B.filter((h) => h.startsWith("doc.")), M = B.filter((h) => h.startsWith("chunk."));
659
+ return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: i, children: /* @__PURE__ */ l("div", { className: "modal scheme-editor", onClick: (h) => h.stopPropagation(), children: [
660
+ /* @__PURE__ */ l("div", { className: "scheme-editor-head", children: [
516
661
  /* @__PURE__ */ n("h3", { children: "Document colors" }),
517
- /* @__PURE__ */ d("div", { className: "scheme-editor-actions", children: [
518
- /* @__PURE__ */ n("button", { type: "button", onClick: o, disabled: O, children: "cancel" }),
662
+ /* @__PURE__ */ l("div", { className: "scheme-editor-actions", children: [
663
+ /* @__PURE__ */ n("button", { type: "button", onClick: i, disabled: j, children: "cancel" }),
519
664
  /* @__PURE__ */ n("button", { type: "button", className: "primary", onClick: () => {
520
- _();
521
- }, disabled: O || !h, children: O ? "saving…" : "save" })
665
+ I();
666
+ }, disabled: j || !m, children: j ? "saving…" : "save" })
522
667
  ] })
523
668
  ] }),
524
- U && /* @__PURE__ */ n("div", { className: "modal-err", children: U }),
525
- h ? /* @__PURE__ */ d(q, { children: [
526
- /* @__PURE__ */ d("label", { className: "scheme-toggle", children: [
669
+ z && /* @__PURE__ */ n("div", { className: "modal-err", children: z }),
670
+ m ? /* @__PURE__ */ l(q, { children: [
671
+ /* @__PURE__ */ l("label", { className: "scheme-toggle", children: [
527
672
  /* @__PURE__ */ n(
528
673
  "input",
529
674
  {
530
675
  type: "checkbox",
531
- checked: g,
532
- onChange: (p) => M(p.target.checked)
676
+ checked: p,
677
+ onChange: (h) => O(h.target.checked)
533
678
  }
534
679
  ),
535
680
  /* @__PURE__ */ n("span", { children: "Enable coloring for this document" })
536
681
  ] }),
537
682
  /* @__PURE__ */ n("p", { className: "modal-context", children: "Document rows are tinted by type + status; chunk tiles by status. Colors apply as a semi-transparent wash so text stays readable." }),
538
- /* @__PURE__ */ d("div", { className: "scheme-group", children: [
683
+ /* @__PURE__ */ l("div", { className: "scheme-group", children: [
539
684
  /* @__PURE__ */ n("h4", { children: "Document (type · status)" }),
540
- Z.map((p) => /* @__PURE__ */ n(pe, { label: p.slice(4), value: v[p], onChange: (m) => k(p, m) }, p))
685
+ Q.map((h) => /* @__PURE__ */ n(_e, { label: h.slice(4), value: N[h], onChange: (f) => x(h, f) }, h))
541
686
  ] }),
542
- /* @__PURE__ */ d("div", { className: "scheme-group", children: [
687
+ /* @__PURE__ */ l("div", { className: "scheme-group", children: [
543
688
  /* @__PURE__ */ n("h4", { children: "Chunks (status)" }),
544
- P.map((p) => /* @__PURE__ */ n(pe, { label: p.slice(6), value: v[p], onChange: (m) => k(p, m) }, p))
689
+ M.map((h) => /* @__PURE__ */ n(_e, { label: h.slice(6), value: N[h], onChange: (f) => x(h, f) }, h))
545
690
  ] }),
546
- /* @__PURE__ */ d("div", { className: "scheme-editor-foot", children: [
547
- /* @__PURE__ */ d("button", { type: "button", onClick: () => {
548
- F();
549
- }, disabled: O || !t, title: t ? `Apply this palette to every other ${t} document` : "This document has no type", children: [
691
+ /* @__PURE__ */ l("div", { className: "scheme-editor-foot", children: [
692
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => {
693
+ J();
694
+ }, disabled: j || !t, title: t ? `Apply this palette to every other ${t} document` : "This document has no type", children: [
550
695
  "copy to all ",
551
696
  t || "same-type",
552
697
  " documents"
553
698
  ] }),
554
- j && /* @__PURE__ */ n("span", { className: "scheme-status", children: j })
699
+ W && /* @__PURE__ */ n("span", { className: "scheme-status", children: W })
555
700
  ] })
556
701
  ] }) : /* @__PURE__ */ n("p", { className: "modal-context", children: "Loading…" })
557
702
  ] }) });
558
703
  }
559
- function pe({ label: e, value: a, onChange: t }) {
560
- const r = Ze(a);
561
- return /* @__PURE__ */ d("label", { className: "scheme-row", children: [
562
- /* @__PURE__ */ n("input", { type: "color", value: r, onChange: (c) => t(c.target.value) }),
704
+ function _e({ label: e, value: a, onChange: t }) {
705
+ const r = yt(a);
706
+ return /* @__PURE__ */ l("label", { className: "scheme-row", children: [
707
+ /* @__PURE__ */ n("input", { type: "color", value: r, onChange: (o) => t(o.target.value) }),
563
708
  /* @__PURE__ */ n("span", { className: "scheme-key", children: e }),
564
709
  /* @__PURE__ */ n("code", { className: "scheme-hex", children: r })
565
710
  ] });
566
711
  }
567
- let Qe = 0;
568
- function Se({ code: e }) {
569
- const a = ee(null), [t, r] = b({});
570
- return I(() => {
571
- let c = !1;
572
- return (async () => {
573
- try {
574
- const l = (await import("mermaid")).default, s = a.current?.closest("[data-theme]")?.getAttribute("data-theme"), o = s ? s === "dark" : !0;
575
- l.initialize({ startOnLoad: !1, theme: o ? "dark" : "default", securityLevel: "strict" });
576
- const { svg: i } = await l.render(`lc-mmd-${Qe++}`, e);
577
- c || r({ svg: i });
578
- } catch {
579
- c || r({ err: !0 });
580
- }
581
- })(), () => {
582
- c = !0;
583
- };
584
- }, [e]), t.err ? /* @__PURE__ */ n("pre", { className: "md-pre md-mermaid-error", title: "diagram failed to render", children: /* @__PURE__ */ n("code", { children: e }) }) : t.svg ? /* @__PURE__ */ n("div", { ref: a, className: "md-mermaid", dangerouslySetInnerHTML: { __html: t.svg } }) : /* @__PURE__ */ n("div", { ref: a, className: "md-mermaid md-mermaid-loading", children: "rendering diagram…" });
585
- }
586
- const oe = 24;
587
- function Xe({
712
+ const pe = 24;
713
+ function kt({
588
714
  edges: e,
589
715
  documentId: a,
590
716
  selectedId: t,
591
717
  onSelectChunk: r
592
718
  }) {
593
- const [c, l] = b(!1), [s, o] = b(!1);
719
+ const [o, s] = k(!1), [c, i] = k(!1);
594
720
  if (e.length === 0) return null;
595
- const i = t ? e.filter((f) => f.from_id === t || f.to_id === t) : [], u = s ? e : e.slice(0, oe), h = Ye(u);
596
- return /* @__PURE__ */ d("div", { className: "doc-refs", children: [
597
- t && /* @__PURE__ */ d("div", { className: "doc-refs-list-wrap", children: [
721
+ const d = t ? e.filter((b) => b.from_id === t || b.to_id === t) : [], g = c ? e : e.slice(0, pe), m = Nt(g);
722
+ return /* @__PURE__ */ l("div", { className: "doc-refs", children: [
723
+ t && /* @__PURE__ */ l("div", { className: "doc-refs-list-wrap", children: [
598
724
  /* @__PURE__ */ n("h4", { children: "References" }),
599
- i.length === 0 ? /* @__PURE__ */ n("p", { className: "doc-refs-empty", children: "This chunk has no links." }) : /* @__PURE__ */ n("ul", { className: "doc-refs-list", children: i.map((f, g) => /* @__PURE__ */ n(
600
- Ke,
725
+ d.length === 0 ? /* @__PURE__ */ n("p", { className: "doc-refs-empty", children: "This chunk has no links." }) : /* @__PURE__ */ n("ul", { className: "doc-refs-list", children: d.map((b, p) => /* @__PURE__ */ n(
726
+ vt,
601
727
  {
602
- edge: f,
728
+ edge: b,
603
729
  selectedId: t,
604
730
  documentId: a,
605
731
  onSelectChunk: r
606
732
  },
607
- `${f.from_id}-${f.to_id}-${f.kind}-${g}`
733
+ `${b.from_id}-${b.to_id}-${b.kind}-${p}`
608
734
  )) })
609
735
  ] }),
610
- /* @__PURE__ */ d("div", { className: "doc-graph", children: [
611
- /* @__PURE__ */ d("button", { type: "button", className: "doc-graph-toggle", onClick: () => l((f) => !f), children: [
612
- c ? "▼" : "▶",
736
+ /* @__PURE__ */ l("div", { className: "doc-graph", children: [
737
+ /* @__PURE__ */ l("button", { type: "button", className: "doc-graph-toggle", onClick: () => s((b) => !b), children: [
738
+ o ? "▼" : "▶",
613
739
  " relationship graph (",
614
740
  e.length,
615
741
  ")"
616
742
  ] }),
617
- c && /* @__PURE__ */ d(q, { children: [
618
- /* @__PURE__ */ n(Se, { code: h }),
619
- e.length > oe && /* @__PURE__ */ n("button", { type: "button", className: "doc-graph-more", onClick: () => o((f) => !f), children: s ? `show top ${oe}` : `show all ${e.length}` })
743
+ o && /* @__PURE__ */ l(q, { children: [
744
+ /* @__PURE__ */ n(le, { code: m }),
745
+ e.length > pe && /* @__PURE__ */ n("button", { type: "button", className: "doc-graph-more", onClick: () => i((b) => !b), children: c ? `show top ${pe}` : `show all ${e.length}` })
620
746
  ] })
621
747
  ] })
622
748
  ] });
623
749
  }
624
- function Ke({
750
+ function vt({
625
751
  edge: e,
626
752
  selectedId: a,
627
753
  documentId: t,
628
754
  onSelectChunk: r
629
755
  }) {
630
- const c = e.from_id === a, l = c ? e.to_id : e.from_id, s = (c ? e.to_title : e.from_title) || l.slice(0, 8), o = c ? e.to_document_id : e.from_document_id, i = !o || o === t;
631
- return /* @__PURE__ */ d("li", { className: "doc-ref", children: [
756
+ const o = e.from_id === a, s = o ? e.to_id : e.from_id, c = (o ? e.to_title : e.from_title) || s.slice(0, 8), i = o ? e.to_document_id : e.from_document_id, d = !i || i === t;
757
+ return /* @__PURE__ */ l("li", { className: "doc-ref", children: [
632
758
  /* @__PURE__ */ n("span", { className: "doc-ref-kind", children: e.kind }),
633
- /* @__PURE__ */ n("span", { className: "doc-ref-arrow", "aria-hidden": !0, children: c ? "→" : "←" }),
634
- i ? /* @__PURE__ */ n("button", { type: "button", className: "doc-ref-target", onClick: () => r(l), children: s }) : /* @__PURE__ */ d("span", { className: "doc-ref-target external", title: "In another document", children: [
635
- s,
759
+ /* @__PURE__ */ n("span", { className: "doc-ref-arrow", "aria-hidden": !0, children: o ? "→" : "←" }),
760
+ d ? /* @__PURE__ */ n("button", { type: "button", className: "doc-ref-target", onClick: () => r(s), children: c }) : /* @__PURE__ */ l("span", { className: "doc-ref-target external", title: "In another document", children: [
761
+ c,
636
762
  " ↗"
637
763
  ] })
638
764
  ] });
639
765
  }
640
- function Ye(e) {
766
+ function Nt(e) {
641
767
  const a = ["graph LR"];
642
768
  for (const t of e) {
643
- const r = `${fe(t.from_id)}["${be(t.from_title, t.from_id)}"]`, c = `${fe(t.to_id)}["${be(t.to_title, t.to_id)}"]`, l = (t.kind || "link").replace(/[|"]/g, " ");
644
- a.push(` ${r} -->|${l}| ${c}`);
769
+ const r = `${Se(t.from_id)}["${Ee(t.from_title, t.from_id)}"]`, o = `${Se(t.to_id)}["${Ee(t.to_title, t.to_id)}"]`, s = (t.kind || "link").replace(/[|"]/g, " ");
770
+ a.push(` ${r} -->|${s}| ${o}`);
645
771
  }
646
772
  return a.join(`
647
773
  `);
648
774
  }
649
- function fe(e) {
775
+ function Se(e) {
650
776
  return "n" + e.replace(/[^a-zA-Z0-9]/g, "");
651
777
  }
652
- function be(e, a) {
778
+ function Ee(e, a) {
653
779
  const r = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || a.slice(0, 6);
654
780
  return r.length > 30 ? r.slice(0, 29) + "…" : r;
655
781
  }
656
- function ye({ source: e }) {
657
- return /* @__PURE__ */ n("div", { className: "md", children: /* @__PURE__ */ n(Ie, { remarkPlugins: [Ae], components: et, children: e }) });
782
+ function xe({ source: e }) {
783
+ return /* @__PURE__ */ n("div", { className: "md", children: /* @__PURE__ */ n(tt, { remarkPlugins: [nt], components: wt, children: e }) });
658
784
  }
659
- const et = {
785
+ const wt = {
660
786
  // react-markdown already sanitized the href; add target/rel for external links.
661
787
  a({ href: e, children: a }) {
662
788
  const t = e ?? "", r = /^https?:\/\//i.test(t);
@@ -669,166 +795,336 @@ const et = {
669
795
  },
670
796
  code({ className: e, children: a }) {
671
797
  const t = /language-(\w+)/.exec(e ?? "")?.[1], r = String(a ?? "");
672
- return t === "mermaid" ? /* @__PURE__ */ n(Se, { code: r.replace(/\n$/, "") }) : t || r.includes(`
798
+ return t === "mermaid" ? /* @__PURE__ */ n(le, { code: r.replace(/\n$/, "") }) : t || r.includes(`
673
799
  `) ? /* @__PURE__ */ n("pre", { className: "md-pre", children: /* @__PURE__ */ n("code", { className: e, children: a }) }) : /* @__PURE__ */ n("code", { children: a });
674
800
  }
675
801
  };
676
- function Ee({
802
+ function Ct(e) {
803
+ const a = e.fields ?? {};
804
+ return typeof a.alt == "string" && a.alt.trim() !== "" ? a.alt : e.title || "image";
805
+ }
806
+ function Oe({
677
807
  documentId: e,
678
808
  scope: a,
679
809
  titleHint: t,
680
810
  browse: r,
681
- principal: c,
682
- renderAssistant: l
811
+ principal: o,
812
+ renderAssistant: s
683
813
  }) {
684
- const s = ce(), o = A(
814
+ const c = se(), i = G(
685
815
  () => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
686
816
  [r?.scopeId, r?.tenant]
687
- ), [i, u] = b([]), [h, f] = b(void 0), [g, M] = b(null), [v, E] = b("chunks"), [O, R] = b(null), [j, D] = b(null), [U, $] = b(null), [J, k] = b(!1), [N, _] = b(0), [F, Z] = b(!1), [P, p] = b(null), [m, T] = b(!1), [S, W] = b([]), Q = G(() => _((y) => y + 1), []), X = A(() => We(i), [i]), K = A(() => i.find((C) => !C.parent_id)?.title || t || "document", [i, t]), te = A(
688
- () => !!g && !g.parent_id,
689
- [g]
690
- ), Y = A(
691
- () => P?.root_chunk_id ?? i.find((y) => !y.parent_id)?.id,
692
- [P, i]
693
- ), w = A(
694
- () => [...new Set(i.map((y) => y.status).filter((y) => !!y))],
695
- [i]
696
- ), x = !!P?.color_enabled, L = A(() => {
697
- const y = /* @__PURE__ */ new Set();
698
- for (const C of S)
699
- y.add(C.from_id), y.add(C.to_id);
700
- return y;
701
- }, [S]), H = A(
702
- () => x ? de(Ce(P?.type, P?.status, ie(P?.color_scheme))) : void 0,
703
- [x, P?.type, P?.status, P?.color_scheme]
817
+ ), [d, g] = k([]), [m, b] = k(void 0), [p, O] = k(null), [N, T] = k("chunks"), [j, P] = k(null), [W, R] = k(null), [z, F] = k(null), B = ne(null), [x, C] = k(null), [I, J] = k(!1), [Q, M] = k(null), [h, f] = k(!1), [E, D] = k(0), [Y, de] = k(!1), [H, ee] = k(null), [te, re] = k(!1), [w, L] = k([]), _ = A(() => D((u) => u + 1), []), V = G(() => ht(d), [d]), ae = G(() => d.find((y) => !y.parent_id)?.title || t || "document", [d, t]), K = G(
818
+ () => !!p && !p.parent_id,
819
+ [p]
820
+ ), Z = G(
821
+ () => H?.root_chunk_id ?? d.find((u) => !u.parent_id)?.id,
822
+ [H, d]
823
+ ), Ge = G(
824
+ () => [...new Set(d.map((u) => u.status).filter((u) => !!u))],
825
+ [d]
826
+ ), oe = !!H?.color_enabled, Be = G(() => {
827
+ const u = /* @__PURE__ */ new Set();
828
+ for (const y of w)
829
+ u.add(y.from_id), u.add(y.to_id);
830
+ return u;
831
+ }, [w]), He = G(
832
+ () => oe ? be(Pe(H?.type, H?.status, ye(H?.color_scheme))) : void 0,
833
+ [oe, H?.type, H?.status, H?.color_scheme]
704
834
  );
705
- I(() => {
706
- let y = !1;
707
- return k(!0), $(null), s.documentQueryChunks(e, a, o).then((C) => {
708
- if (y) return;
709
- const z = C.chunks ?? [];
710
- u(z), f((V) => V ?? z.find((B) => !B.parent_id)?.id);
711
- }).catch((C) => !y && $(C instanceof Error ? C.message : String(C))).finally(() => !y && k(!1)), () => {
712
- y = !0;
835
+ U(() => {
836
+ let u = !1;
837
+ return f(!0), M(null), c.documentQueryChunks(e, a, i).then((y) => {
838
+ if (u) return;
839
+ const v = y.chunks ?? [];
840
+ g(v), b((S) => S ?? v.find(($) => !$.parent_id)?.id);
841
+ }).catch((y) => !u && M(y instanceof Error ? y.message : String(y))).finally(() => !u && f(!1)), () => {
842
+ u = !0;
713
843
  };
714
- }, [s, e, a, N, o]), I(() => {
715
- let y = !1;
716
- return s.documentGet(e, a, o).then((C) => !y && p(C)).catch(() => !y && p(null)), () => {
717
- y = !0;
844
+ }, [c, e, a, E, i]), U(() => {
845
+ let u = !1;
846
+ return c.documentGet(e, a, i).then((y) => !u && ee(y)).catch(() => !u && ee(null)), () => {
847
+ u = !0;
718
848
  };
719
- }, [s, e, a, N, o]), I(() => {
720
- let y = !1;
721
- return s.documentGetEdges(e, a, o).then((C) => !y && W(C.edges ?? [])).catch(() => !y && W([])), () => {
722
- y = !0;
849
+ }, [c, e, a, E, i]), U(() => {
850
+ let u = !1;
851
+ return c.documentGetEdges(e, a, i).then((y) => !u && L(y.edges ?? [])).catch(() => !u && L([])), () => {
852
+ u = !0;
723
853
  };
724
- }, [s, e, a, N, o]), I(() => {
725
- f(void 0), M(null), R(null), E("chunks"), p(null), W([]);
726
- }, [e, a]), I(() => {
727
- if (!h) {
728
- M(null);
854
+ }, [c, e, a, E, i]), U(() => {
855
+ b(void 0), O(null), P(null), T("chunks"), ee(null), L([]);
856
+ }, [e, a]), U(() => {
857
+ if (!m) {
858
+ O(null);
729
859
  return;
730
860
  }
731
- let y = !1;
732
- return s.documentGetChunk(h, a, o).then((C) => !y && M(C)).catch((C) => !y && $(C instanceof Error ? C.message : String(C))), () => {
733
- y = !0;
861
+ let u = !1;
862
+ return c.documentGetChunk(m, a, i).then((y) => !u && O(y)).catch((y) => !u && M(y instanceof Error ? y.message : String(y))), () => {
863
+ u = !0;
734
864
  };
735
- }, [s, h, a, N, o]), I(() => {
736
- if (v !== "markdown" || !h) {
737
- R(null);
865
+ }, [c, m, a, E, i]), U(() => {
866
+ const u = p?.type === "image" || !!p?.asset;
867
+ if (!p || !u || !c.documentAssetObjectUrl) {
868
+ R(null), F(null);
738
869
  return;
739
870
  }
740
- const y = _e(X, h);
741
- if (!y) return;
742
- let C = !1;
743
- const z = [], V = (B, ae) => {
744
- z.push({ node: B, depth: ae }), B.children.forEach((re) => V(re, ae + 1));
871
+ let y = !1, v = null;
872
+ return F(null), c.documentAssetObjectUrl(p.id, a, i).then((S) => {
873
+ if (y) {
874
+ URL.revokeObjectURL(S);
875
+ return;
876
+ }
877
+ v = S, R(S);
878
+ }).catch((S) => !y && F(S instanceof Error ? S.message : String(S))), () => {
879
+ y = !0, v && URL.revokeObjectURL(v);
745
880
  };
746
- return V(y, 0), Promise.all(z.map((B) => s.documentGetChunk(B.node.row.id, a, o))).then((B) => {
747
- if (C) return;
748
- const ae = z.map((re, Le) => {
749
- const Re = Math.min(re.depth + 1, 6), ue = B[Le];
750
- return "#".repeat(Re) + " " + re.node.row.title + (ue.body ? `
881
+ }, [c, p, a, i]), U(() => {
882
+ if (N !== "markdown" || !m) {
883
+ P(null);
884
+ return;
885
+ }
886
+ const u = Ie(V, m);
887
+ if (!u) return;
888
+ let y = !1;
889
+ const v = [], S = ($, ce) => {
890
+ v.push({ node: $, depth: ce }), $.children.forEach((ie) => S(ie, ce + 1));
891
+ };
892
+ return S(u, 0), Promise.all(v.map(($) => c.documentGetChunk($.node.row.id, a, i))).then(($) => {
893
+ if (y) return;
894
+ const ce = v.map((ie, qe) => {
895
+ const Qe = Math.min(ie.depth + 1, 6), X = $[qe], me = "#".repeat(Qe) + " " + ie.node.row.title;
896
+ if (X.type === "mermaid" && X.body)
897
+ return me + "\n\n```mermaid\n" + X.body + "\n```\n";
898
+ if (X.type === "image" || X.asset) {
899
+ const Xe = X.body ? " — " + X.body : "";
900
+ return me + `
901
+
902
+ _🖼 image chunk_` + Xe + `
903
+ `;
904
+ }
905
+ return me + (X.body ? `
751
906
 
752
- ` + ue.body : "") + `
907
+ ` + X.body : "") + `
753
908
  `;
754
909
  }).join(`
755
910
  `);
756
- R(ae);
757
- }).catch((B) => !C && $(B instanceof Error ? B.message : String(B))), () => {
758
- C = !0;
911
+ P(ce);
912
+ }).catch(($) => !y && M($ instanceof Error ? $.message : String($))), () => {
913
+ y = !0;
759
914
  };
760
- }, [s, v, h, X, a, N, o]);
761
- const ne = G((y) => f(y.row.id), []), De = G(async () => {
915
+ }, [c, N, m, V, a, E, i]);
916
+ const We = A((u) => b(u.row.id), []), ze = A(async () => {
917
+ try {
918
+ const u = await c.documentExportMd(e, a, !0, i), y = new Blob([u.markdown], { type: "text/markdown" }), v = URL.createObjectURL(y), S = document.createElement("a");
919
+ S.href = v, S.download = (u.title || "document").replace(/[^\w.-]+/g, "_") + ".md", S.click(), URL.revokeObjectURL(v);
920
+ } catch (u) {
921
+ M(u instanceof Error ? u.message : String(u));
922
+ }
923
+ }, [c, e, a, i]), ue = !!c.documentCreateChunk && !!Z, he = A(
924
+ async (u) => {
925
+ if (!c.documentCreateChunk || !c.documentSetAsset) return;
926
+ const y = m || Z;
927
+ if (y) {
928
+ M(null);
929
+ try {
930
+ const { mediaType: v, data: S } = await Te(u), $ = await c.documentCreateChunk(
931
+ e,
932
+ y,
933
+ { title: u.name || "image", type: "image" },
934
+ a,
935
+ i
936
+ );
937
+ await c.documentSetAsset($.id, v, S, u.name, a, i), _(), b($.id);
938
+ } catch (v) {
939
+ M(v instanceof Error ? v.message : String(v));
940
+ }
941
+ }
942
+ },
943
+ [c, e, a, i, m, Z, _]
944
+ ), Je = A(async () => {
945
+ if (!c.documentCreateChunk) return;
946
+ const u = m || Z;
947
+ if (u) {
948
+ M(null);
949
+ try {
950
+ const y = await c.documentCreateChunk(
951
+ e,
952
+ u,
953
+ { title: "Diagram", type: "mermaid", body: `graph TD
954
+ A[Start] --> B[End]` },
955
+ a,
956
+ i
957
+ );
958
+ _(), b(y.id), C(y);
959
+ } catch (y) {
960
+ M(y instanceof Error ? y.message : String(y));
961
+ }
962
+ }
963
+ }, [c, e, a, i, m, Z, _]), Ve = A(async () => {
964
+ if (!c.documentCreateChunk) return;
965
+ const u = m && !K ? m : void 0, y = m || Z;
966
+ if (y) {
967
+ M(null);
968
+ try {
969
+ const v = await c.documentCreateChunk(
970
+ e,
971
+ u ? "" : y,
972
+ // after_id resolves the parent server-side
973
+ { title: "Text", body: "" },
974
+ a,
975
+ i,
976
+ u
977
+ );
978
+ _(), b(v.id), C(v);
979
+ } catch (v) {
980
+ M(v instanceof Error ? v.message : String(v));
981
+ }
982
+ }
983
+ }, [c, e, a, i, m, K, Z, _]), ke = G(() => {
984
+ if (!p || K) return { canUp: !1, canDown: !1 };
985
+ const u = p.parent_id ?? "", y = d.filter((S) => (S.parent_id ?? "") === u).sort((S, $) => S.position - $.position || S.id.localeCompare($.id)), v = y.findIndex((S) => S.id === p.id);
986
+ return { canUp: v > 0, canDown: v >= 0 && v < y.length - 1 };
987
+ }, [d, p, K]), ve = A(
988
+ async (u) => {
989
+ if (!(!c.documentReorderChunk || !m)) {
990
+ M(null);
991
+ try {
992
+ await c.documentReorderChunk(m, u, a, i), _();
993
+ } catch (y) {
994
+ M(y instanceof Error ? y.message : String(y));
995
+ }
996
+ }
997
+ },
998
+ [c, m, a, i, _]
999
+ ), Ze = A(async () => {
1000
+ if (!c.documentDeleteChunk || !p) return;
1001
+ M(null);
1002
+ const u = p.parent_id;
762
1003
  try {
763
- const y = await s.documentExportMd(e, a, !0, o), C = new Blob([y.markdown], { type: "text/markdown" }), z = URL.createObjectURL(C), V = document.createElement("a");
764
- V.href = z, V.download = (y.title || "document").replace(/[^\w.-]+/g, "_") + ".md", V.click(), URL.revokeObjectURL(z);
1004
+ await c.documentDeleteChunk(p.id, a, i), J(!1), b(u || Z), _();
765
1005
  } catch (y) {
766
- $(y instanceof Error ? y.message : String(y));
1006
+ M(y instanceof Error ? y.message : String(y)), J(!1);
767
1007
  }
768
- }, [s, e, a, o]);
769
- return /* @__PURE__ */ d("div", { className: "doc-viewer", children: [
770
- /* @__PURE__ */ d("div", { className: "doc-toolbar", style: H, children: [
771
- /* @__PURE__ */ n("strong", { className: "doc-title", title: K, children: K }),
772
- /* @__PURE__ */ d("div", { className: "doc-toolbar-actions", children: [
1008
+ }, [c, p, a, i, Z, _]);
1009
+ return U(() => {
1010
+ if (!ue) return;
1011
+ const u = (y) => {
1012
+ if (x || te) return;
1013
+ const v = document.activeElement, S = v?.tagName;
1014
+ if (S === "INPUT" || S === "TEXTAREA" || v?.isContentEditable) return;
1015
+ const $ = st(y.clipboardData?.items);
1016
+ $ && (y.preventDefault(), he($));
1017
+ };
1018
+ return window.addEventListener("paste", u), () => window.removeEventListener("paste", u);
1019
+ }, [ue, x, te, he]), /* @__PURE__ */ l("div", { className: "doc-viewer", children: [
1020
+ /* @__PURE__ */ n(
1021
+ "input",
1022
+ {
1023
+ ref: B,
1024
+ type: "file",
1025
+ accept: "image/png,image/jpeg,image/gif,image/webp",
1026
+ style: { display: "none" },
1027
+ onChange: (u) => {
1028
+ const y = u.target.files?.[0];
1029
+ u.target.value = "", y && he(y);
1030
+ }
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ l("div", { className: "doc-toolbar", style: He, children: [
1034
+ /* @__PURE__ */ n("strong", { className: "doc-title", title: ae, children: ae }),
1035
+ /* @__PURE__ */ l("div", { className: "doc-toolbar-actions", children: [
1036
+ ue && /* @__PURE__ */ l(q, { children: [
1037
+ /* @__PURE__ */ n(
1038
+ "button",
1039
+ {
1040
+ type: "button",
1041
+ onClick: () => {
1042
+ Ve();
1043
+ },
1044
+ title: "Add a text chunk after the selected chunk",
1045
+ children: "+ text"
1046
+ }
1047
+ ),
1048
+ /* @__PURE__ */ n(
1049
+ "button",
1050
+ {
1051
+ type: "button",
1052
+ onClick: () => B.current?.click(),
1053
+ title: "Add an image chunk (upload — or paste a screenshot into the view)",
1054
+ children: "+ image"
1055
+ }
1056
+ ),
1057
+ /* @__PURE__ */ n(
1058
+ "button",
1059
+ {
1060
+ type: "button",
1061
+ onClick: () => {
1062
+ Je();
1063
+ },
1064
+ title: "Add a Mermaid diagram chunk",
1065
+ children: "+ diagram"
1066
+ }
1067
+ )
1068
+ ] }),
773
1069
  /* @__PURE__ */ n(
774
1070
  "button",
775
1071
  {
776
1072
  type: "button",
777
- className: x ? "active" : "",
778
- onClick: () => T(!0),
779
- disabled: !Y,
1073
+ className: oe ? "active" : "",
1074
+ onClick: () => re(!0),
1075
+ disabled: !Z,
780
1076
  title: "Colors — tint chunk tiles + the Path tree by type/status",
781
1077
  children: "colors"
782
1078
  }
783
1079
  ),
784
1080
  /* @__PURE__ */ n("button", { type: "button", onClick: () => {
785
- De();
1081
+ ze();
786
1082
  }, title: "Download the whole document as Markdown (.md)", children: "↓ .md" }),
787
- l && /* @__PURE__ */ n(
1083
+ s && /* @__PURE__ */ n(
788
1084
  "button",
789
1085
  {
790
1086
  type: "button",
791
- className: F ? "active" : "",
792
- onClick: () => Z((y) => !y),
1087
+ className: Y ? "active" : "",
1088
+ onClick: () => de((u) => !u),
793
1089
  title: "Document Assistant — instruct an agent to restructure/import/link chunks",
794
1090
  children: "assistant"
795
1091
  }
796
1092
  ),
797
- /* @__PURE__ */ n("button", { type: "button", onClick: Q, title: "Reload", children: "↻" })
1093
+ /* @__PURE__ */ n("button", { type: "button", onClick: _, title: "Reload", children: "↻" })
798
1094
  ] })
799
1095
  ] }),
800
- U && /* @__PURE__ */ n("div", { className: "paths-err", children: U }),
801
- /* @__PURE__ */ d("div", { className: "doc-split", children: [
802
- /* @__PURE__ */ n("div", { className: "doc-chunktree", children: J && i.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Loading…" }) }) : /* @__PURE__ */ n(
803
- ze,
1096
+ Q && /* @__PURE__ */ n("div", { className: "paths-err", children: Q }),
1097
+ /* @__PURE__ */ l("div", { className: "doc-split", children: [
1098
+ /* @__PURE__ */ n("div", { className: "doc-chunktree", children: h && d.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Loading…" }) }) : /* @__PURE__ */ n(
1099
+ mt,
804
1100
  {
805
- tree: X,
806
- selectedId: h,
807
- onSelect: ne,
808
- colorEnabled: x,
809
- scheme: P?.color_scheme,
810
- linkedIds: L
1101
+ tree: V,
1102
+ selectedId: m,
1103
+ onSelect: We,
1104
+ colorEnabled: oe,
1105
+ scheme: H?.color_scheme,
1106
+ linkedIds: Be
811
1107
  }
812
1108
  ) }),
813
- /* @__PURE__ */ n("div", { className: "doc-content", children: g ? /* @__PURE__ */ d(q, { children: [
814
- /* @__PURE__ */ d("div", { className: "doc-content-head", children: [
815
- /* @__PURE__ */ n("h3", { children: g.title || "(untitled)" }),
816
- /* @__PURE__ */ d("div", { className: "doc-content-meta", children: [
817
- g.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: g.type }),
818
- g.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: g.status }),
819
- /* @__PURE__ */ d("span", { className: "chunk-rev", children: [
1109
+ /* @__PURE__ */ n("div", { className: "doc-content", children: p ? /* @__PURE__ */ l(q, { children: [
1110
+ /* @__PURE__ */ l("div", { className: "doc-content-head", children: [
1111
+ /* @__PURE__ */ n("h3", { children: p.title || "(untitled)" }),
1112
+ /* @__PURE__ */ l("div", { className: "doc-content-meta", children: [
1113
+ p.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: p.type }),
1114
+ p.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: p.status }),
1115
+ /* @__PURE__ */ l("span", { className: "chunk-rev", children: [
820
1116
  "rev ",
821
- g.revision
1117
+ p.revision
822
1118
  ] })
823
1119
  ] }),
824
- /* @__PURE__ */ d("div", { className: "doc-content-controls", children: [
825
- /* @__PURE__ */ d("div", { className: "doc-mode-toggle", children: [
1120
+ /* @__PURE__ */ l("div", { className: "doc-content-controls", children: [
1121
+ /* @__PURE__ */ l("div", { className: "doc-mode-toggle", children: [
826
1122
  /* @__PURE__ */ n(
827
1123
  "button",
828
1124
  {
829
1125
  type: "button",
830
- className: v === "chunks" ? "active" : "",
831
- onClick: () => E("chunks"),
1126
+ className: N === "chunks" ? "active" : "",
1127
+ onClick: () => T("chunks"),
832
1128
  title: "This chunk's own content",
833
1129
  children: "chunk"
834
1130
  }
@@ -837,355 +1133,420 @@ function Ee({
837
1133
  "button",
838
1134
  {
839
1135
  type: "button",
840
- className: v === "markdown" ? "active" : "",
841
- onClick: () => E("markdown"),
842
- title: te ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
1136
+ className: N === "markdown" ? "active" : "",
1137
+ onClick: () => T("markdown"),
1138
+ title: K ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
843
1139
  children: "markdown"
844
1140
  }
845
1141
  )
846
1142
  ] }),
847
- /* @__PURE__ */ n("button", { type: "button", onClick: () => D(g), children: "edit" })
1143
+ /* @__PURE__ */ n("button", { type: "button", onClick: () => C(p), children: "edit" }),
1144
+ !K && /* @__PURE__ */ l(q, { children: [
1145
+ /* @__PURE__ */ n(
1146
+ "button",
1147
+ {
1148
+ type: "button",
1149
+ onClick: () => {
1150
+ ve("up");
1151
+ },
1152
+ disabled: !ke.canUp,
1153
+ title: "Move this chunk up within its level",
1154
+ children: "↑"
1155
+ }
1156
+ ),
1157
+ /* @__PURE__ */ n(
1158
+ "button",
1159
+ {
1160
+ type: "button",
1161
+ onClick: () => {
1162
+ ve("down");
1163
+ },
1164
+ disabled: !ke.canDown,
1165
+ title: "Move this chunk down within its level",
1166
+ children: "↓"
1167
+ }
1168
+ )
1169
+ ] }),
1170
+ !K && /* @__PURE__ */ n(
1171
+ "button",
1172
+ {
1173
+ type: "button",
1174
+ className: "danger",
1175
+ onClick: () => J(!0),
1176
+ title: "Delete this chunk and its sub-chunks",
1177
+ children: "delete"
1178
+ }
1179
+ )
848
1180
  ] })
849
1181
  ] }),
850
- /* @__PURE__ */ n("div", { className: "doc-content-body", children: v === "markdown" ? O !== null ? /* @__PURE__ */ n(ye, { source: O }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : g.body ? /* @__PURE__ */ n(ye, { source: g.body }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "(empty chunk)" }) }),
1182
+ /* @__PURE__ */ n("div", { className: "doc-content-body", children: p.type === "mermaid" ? (
1183
+ // RFC BO — a diagram chunk: body IS the Mermaid source.
1184
+ p.body ? /* @__PURE__ */ l(q, { children: [
1185
+ /* @__PURE__ */ n(le, { code: p.body }),
1186
+ N === "markdown" && /* @__PURE__ */ n("pre", { className: "md-pre doc-mermaid-source", children: /* @__PURE__ */ n("code", { children: p.body }) })
1187
+ ] }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "(empty diagram)" })
1188
+ ) : p.type === "image" || p.asset ? (
1189
+ // RFC BO — an image chunk: bytes come from the auth'd asset GET.
1190
+ z ? /* @__PURE__ */ l("p", { className: "doc-empty-body", children: [
1191
+ "Image failed to load: ",
1192
+ z
1193
+ ] }) : W ? /* @__PURE__ */ l("figure", { className: "doc-image", children: [
1194
+ /* @__PURE__ */ n("img", { src: W, alt: Ct(p) }),
1195
+ p.body && /* @__PURE__ */ n("figcaption", { children: p.body })
1196
+ ] }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "Loading image…" })
1197
+ ) : N === "markdown" ? j !== null ? /* @__PURE__ */ n(xe, { source: j }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : p.body ? /* @__PURE__ */ n(xe, { source: p.body }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "(empty chunk)" }) }),
851
1198
  /* @__PURE__ */ n(
852
- Xe,
1199
+ kt,
853
1200
  {
854
- edges: S,
1201
+ edges: w,
855
1202
  documentId: e,
856
- selectedId: h,
857
- onSelectChunk: f
1203
+ selectedId: m,
1204
+ onSelectChunk: b
858
1205
  }
859
1206
  )
860
1207
  ] }) : /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Select a chunk on the left." }) }) })
861
1208
  ] }),
862
- F && l && /* @__PURE__ */ n("div", { className: "doc-assistant", children: l({
1209
+ Y && s && /* @__PURE__ */ n("div", { className: "doc-assistant", children: s({
863
1210
  documentId: e,
864
1211
  scope: a,
865
- subject: c?.subject,
1212
+ subject: o?.subject,
866
1213
  // Pass the viewer's own reload so the injected assistant can refresh
867
1214
  // the tree + selected chunk after a turn mutates the document.
868
- onChanged: Q
1215
+ onChanged: _
869
1216
  }) }),
870
- j && /* @__PURE__ */ n(
871
- Ve,
1217
+ x && /* @__PURE__ */ n(
1218
+ gt,
872
1219
  {
873
- chunk: j,
1220
+ chunk: x,
874
1221
  scope: a,
875
- browse: o,
876
- onClose: () => D(null),
877
- onSaved: Q
1222
+ browse: i,
1223
+ onClose: () => C(null),
1224
+ onSaved: _
878
1225
  }
879
1226
  ),
880
- m && Y && /* @__PURE__ */ n(
881
- qe,
1227
+ te && Z && /* @__PURE__ */ n(
1228
+ bt,
882
1229
  {
883
1230
  documentId: e,
884
- rootChunkId: Y,
885
- docType: P?.type,
886
- docStatus: P?.status,
887
- chunkStatuses: w,
1231
+ rootChunkId: Z,
1232
+ docType: H?.type,
1233
+ docStatus: H?.status,
1234
+ chunkStatuses: Ge,
888
1235
  scope: a,
889
- browse: o,
890
- onClose: () => T(!1),
891
- onSaved: Q
1236
+ browse: i,
1237
+ onClose: () => re(!1),
1238
+ onSaved: _
892
1239
  }
893
- )
1240
+ ),
1241
+ I && p && /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: () => J(!1), children: /* @__PURE__ */ l("div", { className: "modal chunk-delete-confirm", onClick: (u) => u.stopPropagation(), children: [
1242
+ /* @__PURE__ */ n("h3", { children: "Delete chunk" }),
1243
+ /* @__PURE__ */ l("p", { className: "modal-context", children: [
1244
+ "Delete “",
1245
+ p.title || "(untitled)",
1246
+ "” and all of its sub-chunks? This cannot be undone."
1247
+ ] }),
1248
+ /* @__PURE__ */ l("div", { className: "modal-buttons", children: [
1249
+ /* @__PURE__ */ n("button", { type: "button", onClick: () => J(!1), children: "cancel" }),
1250
+ /* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: () => {
1251
+ Ze();
1252
+ }, children: "delete" })
1253
+ ] })
1254
+ ] }) })
894
1255
  ] });
895
1256
  }
896
- function tt(e) {
1257
+ function _t(e) {
897
1258
  const a = {
898
1259
  name: "",
899
1260
  fullPath: "",
900
1261
  kind: "directory",
901
1262
  explicit: !0,
902
1263
  children: []
903
- }, t = /* @__PURE__ */ new Map([["", a]]), r = (l) => {
904
- const s = t.get(l);
905
- if (s) return s;
906
- const o = l.lastIndexOf("/"), i = o <= 0 ? "" : l.slice(0, o), u = l.slice(o + 1), h = r(i), f = {
907
- name: u,
908
- fullPath: l,
1264
+ }, t = /* @__PURE__ */ new Map([["", a]]), r = (s) => {
1265
+ const c = t.get(s);
1266
+ if (c) return c;
1267
+ const i = s.lastIndexOf("/"), d = i <= 0 ? "" : s.slice(0, i), g = s.slice(i + 1), m = r(d), b = {
1268
+ name: g,
1269
+ fullPath: s,
909
1270
  kind: "directory",
910
1271
  explicit: !1,
911
1272
  children: []
912
1273
  };
913
- return h.children.push(f), t.set(l, f), f;
1274
+ return m.children.push(b), t.set(s, b), b;
914
1275
  };
915
- for (const l of e) {
916
- const s = r(l.full_path);
917
- s.kind = l.kind, s.explicit = !0, s.resourceRef = l.resource_ref;
1276
+ for (const s of e) {
1277
+ const c = r(s.full_path);
1278
+ c.kind = s.kind, c.explicit = !0, c.resourceRef = s.resource_ref;
918
1279
  }
919
- const c = (l) => {
920
- l.sort((s, o) => {
921
- const i = s.kind === "directory", u = o.kind === "directory";
922
- return i !== u ? i ? -1 : 1 : s.name.localeCompare(o.name);
923
- }), l.forEach((s) => c(s.children));
1280
+ const o = (s) => {
1281
+ s.sort((c, i) => {
1282
+ const d = c.kind === "directory", g = i.kind === "directory";
1283
+ return d !== g ? d ? -1 : 1 : c.name.localeCompare(i.name);
1284
+ }), s.forEach((c) => o(c.children));
924
1285
  };
925
- return c(a.children), a.children;
1286
+ return o(a.children), a.children;
926
1287
  }
927
- function le(e) {
1288
+ function ge(e) {
928
1289
  const a = e.lastIndexOf("/");
929
1290
  return a <= 0 ? "" : e.slice(0, a);
930
1291
  }
931
- function nt(e) {
1292
+ function St(e) {
932
1293
  const a = [], t = (r) => {
933
1294
  if (r.kind === "document") {
934
- const c = r.resourceRef;
935
- c?.document_id && a.push(c.document_id);
1295
+ const o = r.resourceRef;
1296
+ o?.document_id && a.push(o.document_id);
936
1297
  }
937
1298
  r.children.forEach(t);
938
1299
  };
939
1300
  return t(e), a;
940
1301
  }
941
- const at = {
1302
+ const Et = {
942
1303
  directory: "📁",
943
1304
  document: "📄",
944
1305
  volume_mount: "💾",
945
1306
  memory_entry: "🧠"
946
1307
  };
947
- function rt({ tree: e, selectedPath: a, onSelect: t, summaries: r }) {
948
- const [c, l] = b(() => /* @__PURE__ */ new Map()), s = G((o) => {
949
- l((i) => {
950
- const u = new Map(i);
951
- return u.set(o, i.get(o) === !1), u;
1308
+ function xt({ tree: e, selectedPath: a, onSelect: t, summaries: r }) {
1309
+ const [o, s] = k(() => /* @__PURE__ */ new Map()), c = A((i) => {
1310
+ s((d) => {
1311
+ const g = new Map(d);
1312
+ return g.set(i, d.get(i) === !1), g;
952
1313
  });
953
1314
  }, []);
954
- return I(() => {
955
- a && l((o) => {
956
- let i = !1;
957
- const u = new Map(o);
958
- let h = le(a);
959
- for (; h !== ""; )
960
- u.get(h) === !1 && (u.set(h, !0), i = !0), h = le(h);
961
- return i ? u : o;
1315
+ return U(() => {
1316
+ a && s((i) => {
1317
+ let d = !1;
1318
+ const g = new Map(i);
1319
+ let m = ge(a);
1320
+ for (; m !== ""; )
1321
+ g.get(m) === !1 && (g.set(m, !0), d = !0), m = ge(m);
1322
+ return d ? g : i;
962
1323
  });
963
- }, [a]), e.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "This tree is empty. Create a folder or document to begin." }) }) : /* @__PURE__ */ n("ul", { className: "tree path-tree", children: e.map((o) => /* @__PURE__ */ n(
964
- $e,
1324
+ }, [a]), e.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "This tree is empty. Create a folder or document to begin." }) }) : /* @__PURE__ */ n("ul", { className: "tree path-tree", children: e.map((i) => /* @__PURE__ */ n(
1325
+ je,
965
1326
  {
966
- node: o,
967
- expanded: c,
968
- toggle: s,
1327
+ node: i,
1328
+ expanded: o,
1329
+ toggle: c,
969
1330
  selectedPath: a,
970
1331
  onSelect: t,
971
1332
  summaries: r
972
1333
  },
973
- o.fullPath
1334
+ i.fullPath
974
1335
  )) });
975
1336
  }
976
- function ct(e, a) {
1337
+ function Dt(e, a) {
977
1338
  if (e.kind !== "document" || !a) return;
978
1339
  const t = e.resourceRef;
979
1340
  return t?.document_id ? a.get(t.document_id) : void 0;
980
1341
  }
981
- function $e({ node: e, expanded: a, toggle: t, selectedPath: r, onSelect: c, summaries: l }) {
982
- const s = e.children.length > 0, o = a.get(e.fullPath) !== !1, i = r === e.fullPath, u = ct(e, l), h = u && u.color_enabled ? de(Ce(u.type, u.status, ie(u.color_scheme))) : void 0;
983
- return /* @__PURE__ */ d("li", { className: `node path-node kind-${e.kind} ${i ? "selected" : ""}`, children: [
984
- /* @__PURE__ */ d("div", { className: "row path-row", style: h, children: [
1342
+ function je({ node: e, expanded: a, toggle: t, selectedPath: r, onSelect: o, summaries: s }) {
1343
+ const c = e.children.length > 0, i = a.get(e.fullPath) !== !1, d = r === e.fullPath, g = Dt(e, s), m = g && g.color_enabled ? be(Pe(g.type, g.status, ye(g.color_scheme))) : void 0;
1344
+ return /* @__PURE__ */ l("li", { className: `node path-node kind-${e.kind} ${d ? "selected" : ""}`, children: [
1345
+ /* @__PURE__ */ l("div", { className: "row path-row", style: m, children: [
985
1346
  /* @__PURE__ */ n(
986
1347
  "button",
987
1348
  {
988
1349
  type: "button",
989
1350
  className: "tree-caret",
990
- "aria-label": o ? "collapse" : "expand",
991
- disabled: !s,
992
- onClick: (f) => {
993
- f.stopPropagation(), s && t(e.fullPath);
1351
+ "aria-label": i ? "collapse" : "expand",
1352
+ disabled: !c,
1353
+ onClick: (b) => {
1354
+ b.stopPropagation(), c && t(e.fullPath);
994
1355
  },
995
- children: s ? o ? "▼" : "▶" : "·"
1356
+ children: c ? i ? "▼" : "▶" : "·"
996
1357
  }
997
1358
  ),
998
- /* @__PURE__ */ d(
1359
+ /* @__PURE__ */ l(
999
1360
  "button",
1000
1361
  {
1001
1362
  type: "button",
1002
1363
  className: "path-link",
1003
- onClick: () => c(e),
1364
+ onClick: () => o(e),
1004
1365
  title: e.fullPath,
1005
1366
  children: [
1006
- /* @__PURE__ */ n("span", { className: "path-kind-icon", "aria-hidden": !0, children: at[e.kind] ?? "•" }),
1367
+ /* @__PURE__ */ n("span", { className: "path-kind-icon", "aria-hidden": !0, children: Et[e.kind] ?? "•" }),
1007
1368
  /* @__PURE__ */ n("span", { className: "path-name", children: e.name }),
1008
- u?.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: u.type }),
1009
- u?.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: u.status }),
1369
+ g?.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: g.type }),
1370
+ g?.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: g.status }),
1010
1371
  !e.explicit && /* @__PURE__ */ n("span", { className: "path-implicit", title: "Implicit directory (no stored entry)", children: "implicit" })
1011
1372
  ]
1012
1373
  }
1013
1374
  )
1014
1375
  ] }),
1015
- s && o && /* @__PURE__ */ n("ul", { className: "children path-children", children: e.children.map((f) => /* @__PURE__ */ n(
1016
- $e,
1376
+ c && i && /* @__PURE__ */ n("ul", { className: "children path-children", children: e.children.map((b) => /* @__PURE__ */ n(
1377
+ je,
1017
1378
  {
1018
- node: f,
1379
+ node: b,
1019
1380
  expanded: a,
1020
1381
  toggle: t,
1021
1382
  selectedPath: r,
1022
- onSelect: c,
1023
- summaries: l
1383
+ onSelect: o,
1384
+ summaries: s
1024
1385
  },
1025
- f.fullPath
1386
+ b.fullPath
1026
1387
  )) })
1027
1388
  ] });
1028
1389
  }
1029
- const ge = /^[A-Za-z0-9._-]+$/;
1030
- function ke(e, a) {
1390
+ const De = /^[A-Za-z0-9._-]+$/;
1391
+ function $e(e, a) {
1031
1392
  return `${e}/${a}`;
1032
1393
  }
1033
- function Me(e, a) {
1394
+ function Fe(e, a) {
1034
1395
  for (const t of e) {
1035
1396
  if (t.fullPath === a) return t;
1036
- const r = Me(t.children, a);
1397
+ const r = Fe(t.children, a);
1037
1398
  if (r) return r;
1038
1399
  }
1039
1400
  }
1040
- function mt(e) {
1041
- const { theme: a, defaultScope: t, path: r, onPathChange: c, browse: l, principal: s, renderAssistant: o, onError: i } = e, u = Ne(e);
1042
- return /* @__PURE__ */ n(we, { theme: a, dataLayer: u, children: /* @__PURE__ */ n(
1043
- ot,
1401
+ function It(e) {
1402
+ const { theme: a, defaultScope: t, path: r, onPathChange: o, browse: s, principal: c, renderAssistant: i, onError: d } = e, g = Le(e);
1403
+ return /* @__PURE__ */ n(Re, { theme: a, dataLayer: g, children: /* @__PURE__ */ n(
1404
+ $t,
1044
1405
  {
1045
1406
  defaultScope: t,
1046
1407
  path: r,
1047
- onPathChange: c,
1048
- browse: l,
1049
- principal: s,
1050
- renderAssistant: o,
1051
- onError: i
1408
+ onPathChange: o,
1409
+ browse: s,
1410
+ principal: c,
1411
+ renderAssistant: i,
1412
+ onError: d
1052
1413
  }
1053
1414
  ) });
1054
1415
  }
1055
- function ot({
1416
+ function $t({
1056
1417
  defaultScope: e,
1057
1418
  path: a,
1058
1419
  onPathChange: t,
1059
1420
  browse: r,
1060
- principal: c,
1061
- renderAssistant: l,
1062
- onError: s
1421
+ principal: o,
1422
+ renderAssistant: s,
1423
+ onError: c
1063
1424
  }) {
1064
- const o = ce(), [i, u] = b(e ?? "user"), [h, f] = b([]), [g, M] = b(void 0), [v, E] = b(null), [O, R] = b(!1), [j, D] = b(null), U = a !== void 0 ? a : g, $ = ee(t);
1065
- I(() => {
1066
- $.current = t;
1425
+ const i = se(), [d, g] = k(e ?? "user"), [m, b] = k([]), [p, O] = k(void 0), [N, T] = k(null), [j, P] = k(!1), [W, R] = k(null), z = a !== void 0 ? a : p, F = ne(t);
1426
+ U(() => {
1427
+ F.current = t;
1067
1428
  }, [t]);
1068
- const J = ee(s);
1069
- I(() => {
1070
- J.current = s;
1071
- }, [s]);
1072
- const k = G((w) => {
1073
- $.current?.(w), M(w);
1074
- }, []), N = A(
1429
+ const B = ne(c);
1430
+ U(() => {
1431
+ B.current = c;
1432
+ }, [c]);
1433
+ const x = A((w) => {
1434
+ F.current?.(w), O(w);
1435
+ }, []), C = G(
1075
1436
  () => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
1076
1437
  [r?.scopeId, r?.tenant]
1077
- ), _ = G(async () => {
1078
- R(!0), E(null);
1438
+ ), I = A(async () => {
1439
+ P(!0), T(null);
1079
1440
  try {
1080
- const w = await o.pathLs("/", i, !0, N);
1081
- f(w.entries ?? []);
1441
+ const w = await i.pathLs("/", d, !0, C);
1442
+ b(w.entries ?? []);
1082
1443
  } catch (w) {
1083
- E(w instanceof Error ? w.message : String(w)), f([]), J.current?.(w);
1444
+ T(w instanceof Error ? w.message : String(w)), b([]), B.current?.(w);
1084
1445
  } finally {
1085
- R(!1);
1446
+ P(!1);
1086
1447
  }
1087
- }, [o, i, N]), F = ee(!0);
1088
- I(() => {
1089
- F.current ? F.current = !1 : k(void 0), _();
1090
- }, [_, k]);
1091
- const Z = A(() => tt(h), [h]), [P, p] = b(() => /* @__PURE__ */ new Map());
1092
- I(() => {
1093
- if (i === "tenant") {
1094
- p(/* @__PURE__ */ new Map());
1448
+ }, [i, d, C]), J = ne(!0);
1449
+ U(() => {
1450
+ J.current ? J.current = !1 : x(void 0), I();
1451
+ }, [I, x]);
1452
+ const Q = G(() => _t(m), [m]), [M, h] = k(() => /* @__PURE__ */ new Map());
1453
+ U(() => {
1454
+ if (d === "tenant") {
1455
+ h(/* @__PURE__ */ new Map());
1095
1456
  return;
1096
1457
  }
1097
- const w = h.filter((L) => L.kind === "document").map((L) => L.resource_ref?.document_id).filter((L) => !!L);
1458
+ const w = m.filter((_) => _.kind === "document").map((_) => _.resource_ref?.document_id).filter((_) => !!_);
1098
1459
  if (w.length === 0) {
1099
- p(/* @__PURE__ */ new Map());
1460
+ h(/* @__PURE__ */ new Map());
1100
1461
  return;
1101
1462
  }
1102
- let x = !1;
1103
- return o.documentsSummary({ documentIds: w }, i, N).then((L) => {
1104
- if (x) return;
1105
- const H = /* @__PURE__ */ new Map();
1106
- for (const ne of L.documents ?? []) H.set(ne.document_id, ne);
1107
- p(H);
1463
+ let L = !1;
1464
+ return i.documentsSummary({ documentIds: w }, d, C).then((_) => {
1465
+ if (L) return;
1466
+ const V = /* @__PURE__ */ new Map();
1467
+ for (const ae of _.documents ?? []) V.set(ae.document_id, ae);
1468
+ h(V);
1108
1469
  }).catch(() => {
1109
- x || p(/* @__PURE__ */ new Map());
1470
+ L || h(/* @__PURE__ */ new Map());
1110
1471
  }), () => {
1111
- x = !0;
1472
+ L = !0;
1112
1473
  };
1113
- }, [o, h, i, N]);
1114
- const m = A(
1115
- () => U ? Me(Z, U) : void 0,
1116
- [Z, U]
1117
- ), T = A(() => m ? m.kind === "directory" ? m.fullPath : le(m.fullPath) : "", [m]), S = T || "/", W = i !== "tenant", Q = G(() => {
1118
- D({
1119
- title: `New folder in ${S}`,
1474
+ }, [i, m, d, C]);
1475
+ const f = G(
1476
+ () => z ? Fe(Q, z) : void 0,
1477
+ [Q, z]
1478
+ ), E = G(() => f ? f.kind === "directory" ? f.fullPath : ge(f.fullPath) : "", [f]), D = E || "/", Y = d !== "tenant", de = A(() => {
1479
+ R({
1480
+ title: `New folder in ${D}`,
1120
1481
  fields: [{ key: "name", label: "Folder name", placeholder: "e.g. launches" }],
1121
1482
  submitLabel: "Create",
1122
1483
  onSubmit: async (w) => {
1123
- const x = w.name.trim();
1124
- if (!ge.test(x)) throw new Error("name may contain only [A-Za-z0-9._-]");
1125
- const L = ke(T, x);
1126
- await o.pathMkdir(L, i, N), await _(), k(L);
1484
+ const L = w.name.trim();
1485
+ if (!De.test(L)) throw new Error("name may contain only [A-Za-z0-9._-]");
1486
+ const _ = $e(E, L);
1487
+ await i.pathMkdir(_, d, C), await I(), x(_);
1127
1488
  }
1128
1489
  });
1129
- }, [o, T, S, i, N, _, k]), X = G(() => {
1130
- D({
1131
- title: `New document in ${S}`,
1490
+ }, [i, E, D, d, C, I, x]), H = A(() => {
1491
+ R({
1492
+ title: `New document in ${D}`,
1132
1493
  fields: [
1133
1494
  { key: "name", label: "Path name", placeholder: "e.g. launch-plan" },
1134
1495
  { key: "title", label: "Title", placeholder: "e.g. Launch Plan" }
1135
1496
  ],
1136
1497
  submitLabel: "Create",
1137
1498
  onSubmit: async (w) => {
1138
- const x = w.name.trim();
1139
- if (!ge.test(x)) throw new Error("name may contain only [A-Za-z0-9._-]");
1140
- const L = w.title.trim() || x, H = ke(T, x);
1141
- await o.documentCreate(L, H, i, N), await _(), k(H);
1499
+ const L = w.name.trim();
1500
+ if (!De.test(L)) throw new Error("name may contain only [A-Za-z0-9._-]");
1501
+ const _ = w.title.trim() || L, V = $e(E, L);
1502
+ await i.documentCreate(_, V, d, C), await I(), x(V);
1142
1503
  }
1143
1504
  });
1144
- }, [o, T, S, i, N, _, k]), K = G(() => {
1145
- m && D({
1146
- title: `Rename / move ${m.fullPath}`,
1147
- fields: [{ key: "to", label: "New path", value: m.fullPath }],
1505
+ }, [i, E, D, d, C, I, x]), ee = A(() => {
1506
+ f && R({
1507
+ title: `Rename / move ${f.fullPath}`,
1508
+ fields: [{ key: "to", label: "New path", value: f.fullPath }],
1148
1509
  submitLabel: "Move",
1149
1510
  onSubmit: async (w) => {
1150
- const x = w.to.trim();
1151
- if (!x.startsWith("/")) throw new Error("path must start with /");
1152
- await o.pathMv(m.fullPath, x, i, N), await _(), k(x);
1511
+ const L = w.to.trim();
1512
+ if (!L.startsWith("/")) throw new Error("path must start with /");
1513
+ await i.pathMv(f.fullPath, L, d, C), await I(), x(L);
1153
1514
  }
1154
1515
  });
1155
- }, [o, m, i, N, _, k]), te = G(() => {
1156
- if (!m) return;
1157
- if (m.kind === "document") {
1158
- const H = m.resourceRef?.document_id;
1159
- D({
1160
- title: `Delete document ${m.fullPath}`,
1516
+ }, [i, f, d, C, I, x]), te = A(() => {
1517
+ if (!f) return;
1518
+ if (f.kind === "document") {
1519
+ const V = f.resourceRef?.document_id;
1520
+ R({
1521
+ title: `Delete document ${f.fullPath}`,
1161
1522
  message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
1162
1523
  fields: [],
1163
1524
  submitLabel: "Delete",
1164
1525
  danger: !0,
1165
1526
  onSubmit: async () => {
1166
- if (!H) throw new Error("this document dirent has no document_id");
1167
- await o.documentDelete(H, i, N), await _(), k(void 0);
1527
+ if (!V) throw new Error("this document dirent has no document_id");
1528
+ await i.documentDelete(V, d, C), await I(), x(void 0);
1168
1529
  }
1169
1530
  });
1170
1531
  return;
1171
1532
  }
1172
- const w = i === "tenant" ? [] : nt(m), x = m.children.length;
1173
- D({
1174
- title: `Delete branch ${m.fullPath}`,
1175
- message: x === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (w.length > 0 ? ` — including ${w.length} document(s), whose chunks are deleted.` : "."),
1533
+ const w = d === "tenant" ? [] : St(f), L = f.children.length;
1534
+ R({
1535
+ title: `Delete branch ${f.fullPath}`,
1536
+ message: L === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (w.length > 0 ? ` — including ${w.length} document(s), whose chunks are deleted.` : "."),
1176
1537
  fields: [],
1177
1538
  submitLabel: "Delete",
1178
1539
  danger: !0,
1179
1540
  onSubmit: async () => {
1180
- for (const L of w)
1181
- await o.documentDelete(L, i, N);
1182
- await o.pathRm(m.fullPath, i, !0, N), await _(), k(void 0);
1541
+ for (const _ of w)
1542
+ await i.documentDelete(_, d, C);
1543
+ await i.pathRm(f.fullPath, d, !0, C), await I(), x(void 0);
1183
1544
  }
1184
1545
  });
1185
- }, [o, m, i, N, _, k]), Y = m && (m.kind === "directory" || m.kind === "document");
1186
- return /* @__PURE__ */ d(q, { children: [
1187
- /* @__PURE__ */ d(
1188
- Ue,
1546
+ }, [i, f, d, C, I, x]), re = f && (f.kind === "directory" || f.kind === "document");
1547
+ return /* @__PURE__ */ l(q, { children: [
1548
+ /* @__PURE__ */ l(
1549
+ ct,
1189
1550
  {
1190
1551
  className: "paths-view",
1191
1552
  defaultLeftWidth: 420,
@@ -1193,163 +1554,164 @@ function ot({
1193
1554
  minRightWidth: 300,
1194
1555
  storageKey: "loomcycle.explorer.split.paths",
1195
1556
  children: [
1196
- /* @__PURE__ */ d("div", { className: "left", children: [
1197
- /* @__PURE__ */ d("div", { className: "paths-toolbar", children: [
1198
- /* @__PURE__ */ d("label", { className: "paths-scope", children: [
1557
+ /* @__PURE__ */ l("div", { className: "left", children: [
1558
+ /* @__PURE__ */ l("div", { className: "paths-toolbar", children: [
1559
+ /* @__PURE__ */ l("label", { className: "paths-scope", children: [
1199
1560
  /* @__PURE__ */ n("span", { children: "scope" }),
1200
- /* @__PURE__ */ d("select", { value: i, onChange: (w) => u(w.target.value), children: [
1561
+ /* @__PURE__ */ l("select", { value: d, onChange: (w) => g(w.target.value), children: [
1201
1562
  /* @__PURE__ */ n("option", { value: "user", children: "user" }),
1202
1563
  /* @__PURE__ */ n("option", { value: "agent", children: "agent" }),
1203
1564
  /* @__PURE__ */ n("option", { value: "tenant", children: "tenant" })
1204
1565
  ] })
1205
1566
  ] }),
1206
- /* @__PURE__ */ d("div", { className: "paths-toolbar-actions", children: [
1207
- /* @__PURE__ */ n("button", { type: "button", onClick: Q, title: `New folder in ${S}`, children: "+ folder" }),
1567
+ /* @__PURE__ */ l("div", { className: "paths-toolbar-actions", children: [
1568
+ /* @__PURE__ */ n("button", { type: "button", onClick: de, title: `New folder in ${D}`, children: "+ folder" }),
1208
1569
  /* @__PURE__ */ n(
1209
1570
  "button",
1210
1571
  {
1211
1572
  type: "button",
1212
- onClick: X,
1213
- disabled: !W,
1214
- title: W ? `New document in ${S}` : "Documents are agent/user scope only",
1573
+ onClick: H,
1574
+ disabled: !Y,
1575
+ title: Y ? `New document in ${D}` : "Documents are agent/user scope only",
1215
1576
  children: "+ document"
1216
1577
  }
1217
1578
  ),
1218
1579
  /* @__PURE__ */ n("button", { type: "button", onClick: () => {
1219
- _();
1580
+ I();
1220
1581
  }, title: "Reload the tree", children: "↻" })
1221
1582
  ] })
1222
1583
  ] }),
1223
- /* @__PURE__ */ d("p", { className: "paths-context", children: [
1584
+ /* @__PURE__ */ l("p", { className: "paths-context", children: [
1224
1585
  "new items → ",
1225
- /* @__PURE__ */ n("code", { children: S }),
1226
- N?.scopeId && /* @__PURE__ */ d(q, { children: [
1586
+ /* @__PURE__ */ n("code", { children: D }),
1587
+ C?.scopeId && /* @__PURE__ */ l(q, { children: [
1227
1588
  " · ",
1228
1589
  "subject ",
1229
- /* @__PURE__ */ n("code", { children: N.scopeId })
1590
+ /* @__PURE__ */ n("code", { children: C.scopeId })
1230
1591
  ] }),
1231
- N?.tenant && /* @__PURE__ */ d(q, { children: [
1592
+ C?.tenant && /* @__PURE__ */ l(q, { children: [
1232
1593
  " · ",
1233
1594
  "tenant ",
1234
- /* @__PURE__ */ n("code", { children: N.tenant })
1595
+ /* @__PURE__ */ n("code", { children: C.tenant })
1235
1596
  ] })
1236
1597
  ] }),
1237
- v && /* @__PURE__ */ n("div", { className: "paths-err", children: v }),
1238
- O && h.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Loading…" }) }) : /* @__PURE__ */ n(
1239
- rt,
1598
+ N && /* @__PURE__ */ n("div", { className: "paths-err", children: N }),
1599
+ j && m.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Loading…" }) }) : /* @__PURE__ */ n(
1600
+ xt,
1240
1601
  {
1241
- tree: Z,
1242
- selectedPath: U,
1243
- onSelect: (w) => k(w.fullPath),
1244
- summaries: P
1602
+ tree: Q,
1603
+ selectedPath: z,
1604
+ onSelect: (w) => x(w.fullPath),
1605
+ summaries: M
1245
1606
  }
1246
1607
  )
1247
1608
  ] }),
1248
- /* @__PURE__ */ n("div", { className: "right", children: m ? m.kind === "document" ? /* @__PURE__ */ d("div", { className: "paths-doc", children: [
1249
- /* @__PURE__ */ d("div", { className: "paths-doc-head", children: [
1250
- /* @__PURE__ */ n("code", { className: "paths-doc-path", children: m.fullPath }),
1251
- /* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
1252
- /* @__PURE__ */ n("button", { type: "button", onClick: K, children: "rename / move" }),
1609
+ /* @__PURE__ */ n("div", { className: "right", children: f ? f.kind === "document" ? /* @__PURE__ */ l("div", { className: "paths-doc", children: [
1610
+ /* @__PURE__ */ l("div", { className: "paths-doc-head", children: [
1611
+ /* @__PURE__ */ n("code", { className: "paths-doc-path", children: f.fullPath }),
1612
+ /* @__PURE__ */ l("div", { className: "paths-detail-actions", children: [
1613
+ /* @__PURE__ */ n("button", { type: "button", onClick: ee, children: "rename / move" }),
1253
1614
  /* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: te, children: "delete" })
1254
1615
  ] })
1255
1616
  ] }),
1256
1617
  /* @__PURE__ */ n(
1257
- Ee,
1618
+ Oe,
1258
1619
  {
1259
- documentId: m.resourceRef?.document_id ?? "",
1260
- scope: i === "agent" ? "agent" : "user",
1261
- titleHint: m.name,
1262
- browse: N,
1263
- principal: c,
1264
- renderAssistant: l
1620
+ documentId: f.resourceRef?.document_id ?? "",
1621
+ scope: d === "agent" ? "agent" : "user",
1622
+ titleHint: f.name,
1623
+ browse: C,
1624
+ principal: o,
1625
+ renderAssistant: s
1265
1626
  }
1266
1627
  )
1267
- ] }) : /* @__PURE__ */ d("div", { className: "paths-detail", children: [
1268
- /* @__PURE__ */ d("h2", { children: [
1269
- /* @__PURE__ */ n("span", { className: "paths-detail-kind", children: m.kind }),
1270
- /* @__PURE__ */ n("code", { children: m.fullPath })
1628
+ ] }) : /* @__PURE__ */ l("div", { className: "paths-detail", children: [
1629
+ /* @__PURE__ */ l("h2", { children: [
1630
+ /* @__PURE__ */ n("span", { className: "paths-detail-kind", children: f.kind }),
1631
+ /* @__PURE__ */ n("code", { children: f.fullPath })
1271
1632
  ] }),
1272
- /* @__PURE__ */ d("dl", { className: "paths-detail-meta", children: [
1633
+ /* @__PURE__ */ l("dl", { className: "paths-detail-meta", children: [
1273
1634
  /* @__PURE__ */ n("dt", { children: "scope" }),
1274
- /* @__PURE__ */ n("dd", { children: i }),
1635
+ /* @__PURE__ */ n("dd", { children: d }),
1275
1636
  /* @__PURE__ */ n("dt", { children: "stored" }),
1276
- /* @__PURE__ */ n("dd", { children: m.explicit ? "yes" : "implicit (no entry)" })
1637
+ /* @__PURE__ */ n("dd", { children: f.explicit ? "yes" : "implicit (no entry)" })
1277
1638
  ] }),
1278
- Y ? /* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
1279
- /* @__PURE__ */ n("button", { type: "button", onClick: K, children: "rename / move" }),
1639
+ re ? /* @__PURE__ */ l("div", { className: "paths-detail-actions", children: [
1640
+ /* @__PURE__ */ n("button", { type: "button", onClick: ee, children: "rename / move" }),
1280
1641
  /* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: te, children: "delete" })
1281
- ] }) : /* @__PURE__ */ d("p", { className: "paths-readonly", children: [
1642
+ ] }) : /* @__PURE__ */ l("p", { className: "paths-readonly", children: [
1282
1643
  "Read-only — ",
1283
- m.kind,
1644
+ f.kind,
1284
1645
  " entries are managed by their own tool."
1285
1646
  ] })
1286
1647
  ] }) : /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Select a path on the left, or create a folder / document." }) }) })
1287
1648
  ]
1288
1649
  }
1289
1650
  ),
1290
- j && /* @__PURE__ */ n(st, { state: j, onClose: () => D(null) })
1651
+ W && /* @__PURE__ */ n(Mt, { state: W, onClose: () => R(null) })
1291
1652
  ] });
1292
1653
  }
1293
- function st({ state: e, onClose: a }) {
1294
- const [t, r] = b(
1295
- () => Object.fromEntries(e.fields.map((u) => [u.key, u.value ?? ""]))
1296
- ), [c, l] = b(!1), [s, o] = b(null);
1297
- return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: a, children: /* @__PURE__ */ d("form", { className: "modal", onClick: (u) => u.stopPropagation(), onSubmit: async (u) => {
1298
- u.preventDefault(), l(!0), o(null);
1654
+ function Mt({ state: e, onClose: a }) {
1655
+ const [t, r] = k(
1656
+ () => Object.fromEntries(e.fields.map((g) => [g.key, g.value ?? ""]))
1657
+ ), [o, s] = k(!1), [c, i] = k(null);
1658
+ return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: a, children: /* @__PURE__ */ l("form", { className: "modal", onClick: (g) => g.stopPropagation(), onSubmit: async (g) => {
1659
+ g.preventDefault(), s(!0), i(null);
1299
1660
  try {
1300
1661
  await e.onSubmit(t), a();
1301
- } catch (h) {
1302
- o(h instanceof Error ? h.message : String(h)), l(!1);
1662
+ } catch (m) {
1663
+ i(m instanceof Error ? m.message : String(m)), s(!1);
1303
1664
  }
1304
1665
  }, children: [
1305
- /* @__PURE__ */ d("div", { className: "modal-header sticky-top", children: [
1666
+ /* @__PURE__ */ l("div", { className: "modal-header sticky-top", children: [
1306
1667
  /* @__PURE__ */ n("h3", { children: e.title }),
1307
- /* @__PURE__ */ d("div", { className: "modal-buttons modal-buttons-top", children: [
1308
- /* @__PURE__ */ n("button", { type: "button", onClick: a, disabled: c, children: "cancel" }),
1309
- /* @__PURE__ */ n("button", { type: "submit", className: e.danger ? "danger" : "primary", disabled: c, children: c ? "working…" : e.submitLabel })
1668
+ /* @__PURE__ */ l("div", { className: "modal-buttons modal-buttons-top", children: [
1669
+ /* @__PURE__ */ n("button", { type: "button", onClick: a, disabled: o, children: "cancel" }),
1670
+ /* @__PURE__ */ n("button", { type: "submit", className: e.danger ? "danger" : "primary", disabled: o, children: o ? "working…" : e.submitLabel })
1310
1671
  ] })
1311
1672
  ] }),
1312
1673
  e.message && /* @__PURE__ */ n("p", { className: "modal-context", children: e.message }),
1313
- e.fields.map((u, h) => /* @__PURE__ */ d("label", { className: "path-field", children: [
1314
- /* @__PURE__ */ n("span", { children: u.label }),
1674
+ e.fields.map((g, m) => /* @__PURE__ */ l("label", { className: "path-field", children: [
1675
+ /* @__PURE__ */ n("span", { children: g.label }),
1315
1676
  /* @__PURE__ */ n(
1316
1677
  "input",
1317
1678
  {
1318
1679
  className: "path-modal-input",
1319
- value: t[u.key],
1320
- placeholder: u.placeholder,
1321
- autoFocus: h === 0,
1322
- onChange: (f) => r((g) => ({ ...g, [u.key]: f.target.value }))
1680
+ value: t[g.key],
1681
+ placeholder: g.placeholder,
1682
+ autoFocus: m === 0,
1683
+ onChange: (b) => r((p) => ({ ...p, [g.key]: b.target.value }))
1323
1684
  }
1324
1685
  )
1325
- ] }, u.key)),
1326
- s && /* @__PURE__ */ n("div", { className: "modal-err", children: s })
1686
+ ] }, g.key)),
1687
+ c && /* @__PURE__ */ n("div", { className: "modal-err", children: c })
1327
1688
  ] }) });
1328
1689
  }
1329
- function pt(e) {
1330
- const { documentId: a, scope: t, titleHint: r, browse: c, theme: l, principal: s, renderAssistant: o } = e, i = Ne(e);
1331
- return /* @__PURE__ */ n(we, { theme: l, dataLayer: i, children: /* @__PURE__ */ n(
1332
- Ee,
1690
+ function Ut(e) {
1691
+ const { documentId: a, scope: t, titleHint: r, browse: o, theme: s, principal: c, renderAssistant: i } = e, d = Le(e);
1692
+ return /* @__PURE__ */ n(Re, { theme: s, dataLayer: d, children: /* @__PURE__ */ n(
1693
+ Oe,
1333
1694
  {
1334
1695
  documentId: a,
1335
1696
  scope: t,
1336
1697
  titleHint: r,
1337
- browse: c,
1338
- principal: s,
1339
- renderAssistant: o
1698
+ browse: o,
1699
+ principal: c,
1700
+ renderAssistant: i
1340
1701
  }
1341
1702
  ) });
1342
1703
  }
1343
1704
  export {
1344
- se as DEFAULT_SCHEME,
1345
- pt as DocumentViewer,
1346
- mt as PathExplorer,
1347
- Fe as chunkColor,
1348
- je as createLoomcycleClient,
1349
- he as dataLayerFromClient,
1350
- Ce as docColor,
1351
- ie as effectiveScheme,
1352
- He as hexToTint,
1353
- de as tintStyle
1705
+ fe as DEFAULT_SCHEME,
1706
+ Ut as DocumentViewer,
1707
+ It as PathExplorer,
1708
+ ot as assetFetchFromConnection,
1709
+ dt as chunkColor,
1710
+ rt as createLoomcycleClient,
1711
+ Ne as dataLayerFromClient,
1712
+ Pe as docColor,
1713
+ ye as effectiveScheme,
1714
+ ut as hexToTint,
1715
+ be as tintStyle
1354
1716
  };
1355
1717
  //# sourceMappingURL=index.js.map