@loomcycle/explorer 0.1.0 → 0.2.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,231 +1,302 @@
1
- import { jsx as t, jsxs as d, Fragment as G } from "react/jsx-runtime";
2
- import { createContext as pe, useContext as fe, useMemo as U, useState as f, useRef as H, useEffect as j, useCallback as S } from "react";
3
- import { LoomcycleClient as be } from "@loomcycle/client";
4
- function K(a) {
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) {
5
7
  return {
6
- pathLs: (e, r, n, s) => a.path(
7
- { op: "ls", path: e, scope: r, recursive: n },
8
- s
8
+ pathLs: (a, t, r, c) => e.path(
9
+ { op: "ls", path: a, scope: t, recursive: r },
10
+ c
9
11
  ),
10
- pathMkdir: (e, r, n) => a.path({ op: "mkdir", path: e, scope: r }, n),
11
- pathMv: (e, r, n, s) => a.path({ op: "mv", path: e, to: r, scope: n }, s),
12
- pathRm: (e, r, n, s) => a.path({ op: "rm", path: e, scope: r, recursive: n }, s),
13
- documentCreate: (e, r, n, s) => a.document(
14
- { op: "create_document", title: e, path: r, scope: n },
15
- s
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
16
18
  ),
17
- documentDelete: (e, r, n) => a.document({ op: "delete_document", id: e, scope: r }, n),
18
- documentQueryChunks: (e, r, n) => a.document(
19
- { op: "query_chunks", document_id: e, scope: r, limit: 1e3 },
20
- n
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(
22
+ // documents_summary + document_ids are RFC BN wire additions the pinned
23
+ // SDK type doesn't enumerate; the /v1/_document passthrough accepts them
24
+ // verbatim, so cast past DocumentToolInput (same pattern as update_chunk).
25
+ {
26
+ op: "documents_summary",
27
+ scope: t,
28
+ ...a.documentIds ? { document_ids: a.documentIds } : {},
29
+ ...a.underPath ? { under_path: a.underPath } : {}
30
+ },
31
+ r
21
32
  ),
22
- documentGetChunk: (e, r, n) => a.document({ op: "get_chunk", id: e, scope: r }, n),
23
- documentUpdateChunk: (e, r, n, s, c) => a.document(
33
+ documentQueryChunks: (a, t, r) => e.document(
34
+ { op: "query_chunks", document_id: a, scope: t, limit: 1e3 },
35
+ r
36
+ ),
37
+ documentGetChunk: (a, t, r) => e.document({ op: "get_chunk", id: a, scope: t }, r),
38
+ documentGetEdges: (a, t, r) => e.document(
39
+ // get_edges is an RFC BN P4 wire op the pinned SDK type doesn't
40
+ // enumerate; the /v1/_document passthrough accepts it verbatim.
41
+ { op: "get_edges", document_id: a, scope: t },
42
+ r
43
+ ),
44
+ documentUpdateChunk: (a, t, r, c, l) => e.document(
24
45
  // `patch.fields` is unknown but DocumentToolInput.fields is a typed
25
46
  // Record; the cast reconciles the spread (the server accepts arbitrary
26
47
  // JSON there). Op order + arg names mirror the wire contract exactly.
27
48
  {
28
49
  op: "update_chunk",
29
- id: e,
30
- revision: r,
31
- scope: s,
32
- ...n
50
+ id: a,
51
+ revision: t,
52
+ scope: c,
53
+ ...r
33
54
  },
34
- c
55
+ l
35
56
  ),
36
- documentExportMd: (e, r, n, s) => a.document(
57
+ documentExportMd: (a, t, r, c) => e.document(
37
58
  {
38
59
  op: "export_md",
39
- document_id: e,
40
- scope: r,
41
- include_metadata: n
60
+ document_id: a,
61
+ scope: t,
62
+ include_metadata: r
42
63
  },
43
- s
64
+ c
44
65
  )
45
66
  };
46
67
  }
47
- const re = pe(null);
48
- function ge({
49
- value: a,
50
- children: e
68
+ const ve = Pe(null);
69
+ function Ge({
70
+ value: e,
71
+ children: a
51
72
  }) {
52
- return /* @__PURE__ */ t(re.Provider, { value: a, children: e });
73
+ return /* @__PURE__ */ n(ve.Provider, { value: e, children: a });
53
74
  }
54
- function X() {
55
- const a = fe(re);
56
- if (!a)
75
+ function ce() {
76
+ const e = Te(ve);
77
+ if (!e)
57
78
  throw new Error(
58
79
  "useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)"
59
80
  );
60
- return a;
61
- }
62
- function ke(a) {
63
- const e = a.fetch;
64
- return new be({
65
- baseUrl: a.baseUrl,
66
- authToken: a.token || void 0,
67
- fetch: (r, n) => e ? e(r, n) : fetch(r, n)
81
+ return e;
82
+ }
83
+ function je(e) {
84
+ const a = e.fetch;
85
+ return new Oe({
86
+ baseUrl: e.baseUrl,
87
+ authToken: e.token || void 0,
88
+ fetch: (t, r) => a ? a(t, r) : fetch(t, r)
68
89
  });
69
90
  }
70
- function le(a) {
71
- const { dataLayer: e, client: r, connection: n } = a;
72
- return U(() => e || (r ? K(r) : n ? K(ke(n)) : null), [e, r, n?.baseUrl, n?.token, n?.fetch]);
91
+ function Ne(e) {
92
+ 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]);
73
94
  }
74
- function se({
75
- theme: a,
76
- dataLayer: e,
77
- children: r
95
+ function we({
96
+ theme: e,
97
+ dataLayer: a,
98
+ children: t
78
99
  }) {
79
- const n = a ? { "data-theme": a } : {};
80
- return e ? /* @__PURE__ */ t("div", { className: "loomcycle-explorer", ...n, children: /* @__PURE__ */ t(ge, { value: e, children: r }) }) : /* @__PURE__ */ t("div", { className: "loomcycle-explorer", ...n, children: /* @__PURE__ */ d("div", { className: "error-banner", children: [
100
+ 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: [
81
102
  "@loomcycle/explorer: provide a ",
82
- /* @__PURE__ */ t("code", { children: "connection" }),
103
+ /* @__PURE__ */ n("code", { children: "connection" }),
83
104
  ", ",
84
- /* @__PURE__ */ t("code", { children: "client" }),
105
+ /* @__PURE__ */ n("code", { children: "client" }),
85
106
  ", or",
86
107
  " ",
87
- /* @__PURE__ */ t("code", { children: "dataLayer" }),
108
+ /* @__PURE__ */ n("code", { children: "dataLayer" }),
88
109
  " prop."
89
110
  ] }) });
90
111
  }
91
- const ee = 6;
92
- function ye({
93
- children: a,
94
- defaultLeftWidth: e = 380,
95
- minLeftWidth: r = 180,
96
- minRightWidth: n = 240,
97
- storageKey: s,
98
- className: c
112
+ const me = 6;
113
+ function Ue({
114
+ children: e,
115
+ defaultLeftWidth: a = 380,
116
+ minLeftWidth: t = 180,
117
+ minRightWidth: r = 240,
118
+ storageKey: c,
119
+ className: l
99
120
  }) {
100
- const [l, i] = f(() => {
101
- if (s) {
102
- const y = localStorage.getItem(s), E = y ? parseInt(y, 10) : NaN;
103
- if (Number.isFinite(E) && E >= r) return E;
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;
104
125
  }
105
- return e;
106
- }), o = H(null), [u, h] = f(!1);
107
- j(() => {
108
- !s || u || localStorage.setItem(s, String(Math.round(l)));
109
- }, [s, l, u]);
110
- const x = S((y) => {
111
- y.preventDefault(), h(!0), y.target.setPointerCapture(y.pointerId);
112
- }, []), k = S(
113
- (y) => {
114
- if (!u || !o.current) return;
115
- const E = o.current.getBoundingClientRect(), T = y.clientX - E.left, L = E.width - n - ee, P = Math.max(r, Math.min(T, L));
116
- i(P);
126
+ 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);
117
138
  },
118
- [u, r, n]
119
- ), M = S((y) => {
139
+ [u, t, r]
140
+ ), M = G((v) => {
120
141
  h(!1);
121
142
  try {
122
- y.target.releasePointerCapture(y.pointerId);
143
+ v.target.releasePointerCapture(v.pointerId);
123
144
  } catch {
124
145
  }
125
146
  }, []);
126
147
  return /* @__PURE__ */ d(
127
148
  "div",
128
149
  {
129
- ref: o,
130
- className: `splitter ${c ?? ""} ${u ? "dragging" : ""}`,
150
+ ref: i,
151
+ className: `splitter ${l ?? ""} ${u ? "dragging" : ""}`,
131
152
  style: {
132
- gridTemplateColumns: `${l}px ${ee}px 1fr`
153
+ gridTemplateColumns: `${s}px ${me}px 1fr`
133
154
  },
134
155
  children: [
135
- /* @__PURE__ */ t("div", { className: "splitter-pane splitter-left", children: a[0] }),
136
- /* @__PURE__ */ t(
156
+ /* @__PURE__ */ n("div", { className: "splitter-pane splitter-left", children: e[0] }),
157
+ /* @__PURE__ */ n(
137
158
  "div",
138
159
  {
139
160
  className: "splitter-handle",
140
161
  role: "separator",
141
162
  "aria-orientation": "vertical",
142
- "aria-valuenow": Math.round(l),
143
- onPointerDown: x,
144
- onPointerMove: k,
163
+ "aria-valuenow": Math.round(s),
164
+ onPointerDown: f,
165
+ onPointerMove: g,
145
166
  onPointerUp: M,
146
167
  onPointerCancel: M
147
168
  }
148
169
  ),
149
- /* @__PURE__ */ t("div", { className: "splitter-pane splitter-right", children: a[1] })
170
+ /* @__PURE__ */ n("div", { className: "splitter-pane splitter-right", children: e[1] })
150
171
  ]
151
172
  }
152
173
  );
153
174
  }
154
- function ve(a) {
155
- const e = /* @__PURE__ */ new Map();
156
- a.forEach((s) => e.set(s.id, { row: s, children: [] }));
157
- const r = [];
158
- a.forEach((s) => {
159
- const c = e.get(s.id);
160
- s.parent_id && e.has(s.parent_id) ? e.get(s.parent_id).children.push(c) : r.push(c);
175
+ const se = {
176
+ "doc.rfc.draft": "#c99a3a",
177
+ "doc.rfc.review": "#6a7bd6",
178
+ "doc.rfc.confirmed": "#3a9ad6",
179
+ "doc.rfc.done": "#3aa06a",
180
+ "doc.document.done": "#3aa06a",
181
+ "doc.research.done": "#8a6ad6",
182
+ "doc.publication.draft": "#c99a3a",
183
+ "chunk.draft": "#c99a3a",
184
+ "chunk.review": "#6a7bd6",
185
+ "chunk.confirmed": "#3a9ad6",
186
+ "chunk.done": "#3aa06a"
187
+ }, Be = 0.16;
188
+ function ie(e) {
189
+ return e && Object.keys(e).length > 0 ? e : se;
190
+ }
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}`];
194
+ if (r && t[`doc.${r}`]) return t[`doc.${r}`];
195
+ }
196
+ function Fe(e, a) {
197
+ const t = e ?? "";
198
+ return t ? a[`chunk.${t}`] : void 0;
199
+ }
200
+ function He(e) {
201
+ const a = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
202
+ if (!a) return;
203
+ let t = a[1];
204
+ 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})`;
207
+ }
208
+ function de(e) {
209
+ if (!e) return;
210
+ const a = He(e);
211
+ if (a)
212
+ return { background: a, borderLeft: `3px solid ${e}` };
213
+ }
214
+ function We(e) {
215
+ const a = /* @__PURE__ */ new Map();
216
+ e.forEach((c) => a.set(c.id, { row: c, children: [] }));
217
+ 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);
161
221
  });
162
- const n = (s) => {
163
- s.sort((c, l) => c.row.position - l.row.position), s.forEach((c) => n(c.children));
222
+ const r = (c) => {
223
+ c.sort((l, s) => l.row.position - s.row.position), c.forEach((l) => r(l.children));
164
224
  };
165
- return n(r), r;
225
+ return r(t), t;
166
226
  }
167
- function ce(a, e) {
168
- for (const r of a) {
169
- if (r.row.id === e) return r;
170
- const n = ce(r.children, e);
171
- if (n) return n;
227
+ function _e(e, a) {
228
+ for (const t of e) {
229
+ if (t.row.id === a) return t;
230
+ const r = _e(t.children, a);
231
+ if (r) return r;
172
232
  }
173
233
  }
174
- function Ne({ tree: a, selectedId: e, onSelect: r }) {
175
- const [n, s] = f(() => /* @__PURE__ */ new Map()), c = S((l) => {
176
- s((i) => {
177
- const o = new Map(i);
178
- return o.set(l, i.get(l) === !1), o;
234
+ function ze({
235
+ tree: e,
236
+ selectedId: a,
237
+ onSelect: t,
238
+ colorEnabled: r,
239
+ scheme: c,
240
+ linkedIds: l
241
+ }) {
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;
179
246
  });
180
247
  }, []);
181
- return j(() => {
182
- if (!e) return;
183
- const l = we(a, e);
184
- l.length !== 0 && s((i) => {
185
- let o = !1;
186
- const u = new Map(i);
187
- for (const h of l)
188
- u.get(h) === !1 && (u.set(h, !0), o = !0);
189
- return o ? u : i;
248
+ I(() => {
249
+ 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;
190
257
  });
191
- }, [a, e]), a.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "No chunks." }) }) : /* @__PURE__ */ t("ul", { className: "tree chunk-tree", children: a.map((l) => /* @__PURE__ */ t(
192
- oe,
258
+ }, [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,
193
262
  {
194
- node: l,
195
- expanded: n,
196
- toggle: c,
197
- selectedId: e,
198
- onSelect: r
263
+ node: h,
264
+ expanded: s,
265
+ toggle: i,
266
+ selectedId: a,
267
+ onSelect: t,
268
+ tintScheme: u,
269
+ linkedIds: l
199
270
  },
200
- l.row.id
271
+ h.row.id
201
272
  )) });
202
273
  }
203
- function we(a, e) {
204
- const r = [], n = (s, c) => {
205
- for (const l of s) {
206
- if (l.row.id === e)
207
- return r.push(...c), !0;
208
- if (n(l.children, [...c, l.row.id])) return !0;
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;
209
280
  }
210
281
  return !1;
211
282
  };
212
- return n(a, []), r;
283
+ return r(e, []), t;
213
284
  }
214
- function oe({ node: a, expanded: e, toggle: r, selectedId: n, onSelect: s }) {
215
- const c = a.children.length > 0, l = e.get(a.row.id) !== !1, i = n === a.row.id;
216
- return /* @__PURE__ */ d("li", { className: `node chunk-node ${i ? "selected" : ""}`, children: [
217
- /* @__PURE__ */ d("div", { className: "row chunk-row", children: [
218
- /* @__PURE__ */ t(
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: [
289
+ /* @__PURE__ */ n(
219
290
  "button",
220
291
  {
221
292
  type: "button",
222
293
  className: "tree-caret",
223
- "aria-label": l ? "collapse" : "expand",
224
- disabled: !c,
225
- onClick: (o) => {
226
- o.stopPropagation(), c && r(a.row.id);
294
+ "aria-label": i ? "collapse" : "expand",
295
+ disabled: !o,
296
+ onClick: (g) => {
297
+ g.stopPropagation(), o && t(e.row.id);
227
298
  },
228
- children: c ? l ? "▼" : "▶" : "·"
299
+ children: o ? i ? "▼" : "▶" : "·"
229
300
  }
230
301
  ),
231
302
  /* @__PURE__ */ d(
@@ -233,469 +304,695 @@ function oe({ node: a, expanded: e, toggle: r, selectedId: n, onSelect: s }) {
233
304
  {
234
305
  type: "button",
235
306
  className: "chunk-link",
236
- onClick: () => s(a),
237
- title: a.row.title,
307
+ onClick: () => c(e),
308
+ title: e.row.title,
238
309
  children: [
239
- /* @__PURE__ */ t("span", { className: "chunk-title", children: a.row.title || "(untitled)" }),
240
- a.row.type && /* @__PURE__ */ t("span", { className: "chunk-badge", children: a.row.type }),
241
- a.row.status && /* @__PURE__ */ t("span", { className: "chunk-badge chunk-status", children: a.row.status })
310
+ /* @__PURE__ */ n("span", { className: "chunk-title", children: e.row.title || "(untitled)" }),
311
+ e.row.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: e.row.type }),
312
+ 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: "🔗" })
242
314
  ]
243
315
  }
244
316
  )
245
317
  ] }),
246
- c && l && /* @__PURE__ */ t("ul", { className: "children chunk-children", children: a.children.map((o) => /* @__PURE__ */ t(
247
- oe,
318
+ o && i && /* @__PURE__ */ n("ul", { className: "children chunk-children", children: e.children.map((g) => /* @__PURE__ */ n(
319
+ xe,
248
320
  {
249
- node: o,
250
- expanded: e,
251
- toggle: r,
252
- selectedId: n,
253
- onSelect: s
321
+ node: g,
322
+ expanded: a,
323
+ toggle: t,
324
+ selectedId: r,
325
+ onSelect: c,
326
+ tintScheme: l,
327
+ linkedIds: s
254
328
  },
255
- o.row.id
329
+ g.row.id
256
330
  )) })
257
331
  ] });
258
332
  }
259
- function Ce({ chunk: a, scope: e, browse: r, onClose: n, onSaved: s }) {
260
- const c = X(), [l, i] = f(a.title), [o, u] = f(a.type ?? ""), [h, x] = f(a.status ?? ""), [k, M] = f(a.body ?? ""), [y, E] = f(
261
- a.fields ? JSON.stringify(a.fields, null, 2) : ""
262
- ), [T, L] = f(!1), [P, D] = f(null), [W, R] = f(!1);
263
- return /* @__PURE__ */ t("div", { className: "modal-overlay", onClick: n, children: /* @__PURE__ */ d("form", { className: "modal chunk-editor", onClick: (b) => b.stopPropagation(), onSubmit: async (b) => {
264
- b.preventDefault(), D(null), R(!1);
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(
335
+ 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);
265
339
  const N = {
266
- body: k,
267
- title: l,
268
- type: o,
340
+ body: g,
341
+ title: s,
342
+ type: i,
269
343
  status: h
270
344
  };
271
- if (y.trim() !== "")
345
+ if (v.trim() !== "")
272
346
  try {
273
- N.fields = JSON.parse(y);
347
+ N.fields = JSON.parse(v);
274
348
  } catch {
275
349
  D("fields must be valid JSON");
276
350
  return;
277
351
  }
278
- L(!0);
352
+ R(!0);
279
353
  try {
280
- const C = await c.documentUpdateChunk(a.id, a.revision, N, e, r);
281
- s(C), n();
282
- } catch (C) {
283
- const B = C instanceof Error ? C.message : String(C);
284
- D(B), R(/revision conflict/i.test(B)), L(!1);
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);
285
359
  }
286
360
  }, children: [
287
- /* @__PURE__ */ t("h3", { children: "Edit chunk" }),
361
+ /* @__PURE__ */ d("div", { className: "modal-header sticky-top", children: [
362
+ /* @__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" })
366
+ ] })
367
+ ] }),
368
+ j && /* @__PURE__ */ d("div", { className: "modal-err", children: [
369
+ j,
370
+ U && " — reopen the chunk to load the latest, then reapply your edit."
371
+ ] }),
288
372
  /* @__PURE__ */ d("label", { className: "path-field", children: [
289
- /* @__PURE__ */ t("span", { children: "Title" }),
290
- /* @__PURE__ */ t("input", { className: "path-modal-input", value: l, onChange: (b) => i(b.target.value) })
373
+ /* @__PURE__ */ n("span", { children: "Title" }),
374
+ /* @__PURE__ */ n("input", { className: "path-modal-input", value: s, onChange: (k) => o(k.target.value) })
291
375
  ] }),
292
376
  /* @__PURE__ */ d("div", { className: "chunk-editor-row", children: [
293
377
  /* @__PURE__ */ d("label", { className: "path-field", children: [
294
- /* @__PURE__ */ t("span", { children: "Type" }),
295
- /* @__PURE__ */ t(
378
+ /* @__PURE__ */ n("span", { children: "Type" }),
379
+ /* @__PURE__ */ n(
296
380
  "input",
297
381
  {
298
382
  className: "path-modal-input",
299
- value: o,
383
+ value: i,
300
384
  placeholder: "(none)",
301
- onChange: (b) => u(b.target.value)
385
+ onChange: (k) => u(k.target.value)
302
386
  }
303
387
  )
304
388
  ] }),
305
389
  /* @__PURE__ */ d("label", { className: "path-field", children: [
306
- /* @__PURE__ */ t("span", { children: "Status" }),
307
- /* @__PURE__ */ t(
390
+ /* @__PURE__ */ n("span", { children: "Status" }),
391
+ /* @__PURE__ */ n(
308
392
  "input",
309
393
  {
310
394
  className: "path-modal-input",
311
395
  value: h,
312
396
  placeholder: "(none)",
313
- onChange: (b) => x(b.target.value)
397
+ onChange: (k) => f(k.target.value)
314
398
  }
315
399
  )
316
400
  ] })
317
401
  ] }),
318
402
  /* @__PURE__ */ d("label", { className: "path-field", children: [
319
- /* @__PURE__ */ t("span", { children: "Body (Markdown)" }),
320
- /* @__PURE__ */ t(
403
+ /* @__PURE__ */ n("span", { children: "Body (Markdown)" }),
404
+ /* @__PURE__ */ n(
321
405
  "textarea",
322
406
  {
323
407
  className: "modal-textarea chunk-body-input",
324
408
  rows: 12,
325
- value: k,
326
- onChange: (b) => M(b.target.value)
409
+ value: g,
410
+ onChange: (k) => M(k.target.value)
327
411
  }
328
412
  )
329
413
  ] }),
330
414
  /* @__PURE__ */ d("label", { className: "path-field", children: [
331
- /* @__PURE__ */ t("span", { children: "Fields (JSON, optional)" }),
332
- /* @__PURE__ */ t(
415
+ /* @__PURE__ */ n("span", { children: "Fields (JSON, optional)" }),
416
+ /* @__PURE__ */ n(
333
417
  "textarea",
334
418
  {
335
419
  className: "modal-textarea chunk-fields-input",
336
420
  rows: 4,
337
- value: y,
421
+ value: v,
338
422
  placeholder: "{}",
339
- onChange: (b) => E(b.target.value)
423
+ onChange: (k) => E(k.target.value)
340
424
  }
341
425
  )
342
- ] }),
343
- P && /* @__PURE__ */ d("div", { className: "modal-err", children: [
344
- P,
345
- W && " — reopen the chunk to load the latest, then reapply your edit."
346
- ] }),
347
- /* @__PURE__ */ d("div", { className: "modal-buttons", children: [
348
- /* @__PURE__ */ t("button", { type: "button", onClick: n, disabled: T, children: "cancel" }),
349
- /* @__PURE__ */ t("button", { type: "submit", className: "primary", disabled: T, children: T ? "saving…" : "save" })
350
426
  ] })
351
427
  ] }) });
352
428
  }
353
- function te({ source: a }) {
354
- return /* @__PURE__ */ t("div", { className: "md", children: xe(a) });
355
- }
356
- function xe(a) {
357
- const e = a.replace(/\r\n/g, `
358
- `).split(`
359
- `), r = [];
360
- let n = 0, s = 0;
361
- for (; n < e.length; ) {
362
- const c = e[n];
363
- if (c.trim() === "") {
364
- n++;
365
- continue;
366
- }
367
- if (c.startsWith("```")) {
368
- const h = [];
369
- for (n++; n < e.length && !e[n].startsWith("```"); )
370
- h.push(e[n]), n++;
371
- n++, r.push(
372
- /* @__PURE__ */ t("pre", { className: "md-pre", children: /* @__PURE__ */ t("code", { children: h.join(`
373
- `) }) }, s++)
374
- );
375
- continue;
429
+ function Ze(e) {
430
+ const a = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
431
+ if (!a) return "#888888";
432
+ let t = a[1];
433
+ return t.length === 3 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]), "#" + t.toLowerCase();
434
+ }
435
+ function qe({
436
+ documentId: e,
437
+ rootChunkId: a,
438
+ docType: t,
439
+ docStatus: r,
440
+ chunkStatuses: c,
441
+ scope: l,
442
+ browse: s,
443
+ onClose: o,
444
+ onSaved: i
445
+ }) {
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;
463
+ };
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);
472
+ try {
473
+ await u.documentUpdateChunk(
474
+ 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);
482
+ }
376
483
  }
377
- const l = /^(#{1,6})\s+(.*)$/.exec(c);
378
- if (l) {
379
- r.push(Ee(l[1].length, z(l[2]), s++)), n++;
380
- continue;
484
+ }, F = async () => {
485
+ if (!t) {
486
+ $("this document has no type to match");
487
+ return;
381
488
  }
382
- if (/^>\s?/.test(c)) {
383
- const h = [];
384
- for (; n < e.length && /^>\s?/.test(e[n]); )
385
- h.push(e[n].replace(/^>\s?/, "")), n++;
386
- r.push(
387
- /* @__PURE__ */ t("blockquote", { children: z(h.join(" ")) }, s++)
489
+ R(!0), $(null), D(null);
490
+ 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
388
493
  );
389
- continue;
494
+ let T = 0;
495
+ for (const S of m)
496
+ 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++;
505
+ } catch {
506
+ }
507
+ D(`Applied to ${T} other ${t} document(s).`), i();
508
+ } catch (p) {
509
+ $(p instanceof Error ? p.message : String(p));
510
+ } finally {
511
+ R(!1);
390
512
  }
391
- const i = /^[-*]\s+(.*)$/, o = /^\d+\.\s+(.*)$/;
392
- if (i.test(c) || o.test(c)) {
393
- const h = o.test(c), x = h ? o : i, k = [];
394
- let M = 0;
395
- for (; n < e.length && x.test(e[n]); ) {
396
- const y = x.exec(e[n]);
397
- k.push(/* @__PURE__ */ t("li", { children: z(y[1]) }, M++)), n++;
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: [
516
+ /* @__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" }),
519
+ /* @__PURE__ */ n("button", { type: "button", className: "primary", onClick: () => {
520
+ _();
521
+ }, disabled: O || !h, children: O ? "saving…" : "save" })
522
+ ] })
523
+ ] }),
524
+ U && /* @__PURE__ */ n("div", { className: "modal-err", children: U }),
525
+ h ? /* @__PURE__ */ d(q, { children: [
526
+ /* @__PURE__ */ d("label", { className: "scheme-toggle", children: [
527
+ /* @__PURE__ */ n(
528
+ "input",
529
+ {
530
+ type: "checkbox",
531
+ checked: g,
532
+ onChange: (p) => M(p.target.checked)
533
+ }
534
+ ),
535
+ /* @__PURE__ */ n("span", { children: "Enable coloring for this document" })
536
+ ] }),
537
+ /* @__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: [
539
+ /* @__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))
541
+ ] }),
542
+ /* @__PURE__ */ d("div", { className: "scheme-group", children: [
543
+ /* @__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))
545
+ ] }),
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: [
550
+ "copy to all ",
551
+ t || "same-type",
552
+ " documents"
553
+ ] }),
554
+ j && /* @__PURE__ */ n("span", { className: "scheme-status", children: j })
555
+ ] })
556
+ ] }) : /* @__PURE__ */ n("p", { className: "modal-context", children: "Loading…" })
557
+ ] }) });
558
+ }
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) }),
563
+ /* @__PURE__ */ n("span", { className: "scheme-key", children: e }),
564
+ /* @__PURE__ */ n("code", { className: "scheme-hex", children: r })
565
+ ] });
566
+ }
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 });
398
580
  }
399
- r.push(h ? /* @__PURE__ */ t("ol", { children: k }, s++) : /* @__PURE__ */ t("ul", { children: k }, s++));
400
- continue;
401
- }
402
- const u = [];
403
- for (; n < e.length && e[n].trim() !== "" && !e[n].startsWith("```") && !/^(#{1,6})\s+/.test(e[n]) && !/^>\s?/.test(e[n]) && !i.test(e[n]) && !o.test(e[n]); )
404
- u.push(e[n]), n++;
405
- r.push(/* @__PURE__ */ t("p", { children: z(u.join(" ")) }, s++));
406
- }
407
- return r;
408
- }
409
- function Ee(a, e, r) {
410
- switch (a) {
411
- case 1:
412
- return /* @__PURE__ */ t("h1", { children: e }, r);
413
- case 2:
414
- return /* @__PURE__ */ t("h2", { children: e }, r);
415
- case 3:
416
- return /* @__PURE__ */ t("h3", { children: e }, r);
417
- case 4:
418
- return /* @__PURE__ */ t("h4", { children: e }, r);
419
- case 5:
420
- return /* @__PURE__ */ t("h5", { children: e }, r);
421
- default:
422
- return /* @__PURE__ */ t("h6", { children: e }, r);
423
- }
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…" });
424
585
  }
425
- const Se = /(`[^`]+`)|(\*\*[^*]+?\*\*)|(\*[^*]+?\*)|(\[[^\]]+\]\([^)]+\))/;
426
- function z(a) {
427
- const e = [];
428
- let r = a, n = 0;
429
- for (; r.length > 0; ) {
430
- const s = Se.exec(r);
431
- if (!s) {
432
- e.push(r);
433
- break;
434
- }
435
- s.index > 0 && e.push(r.slice(0, s.index));
436
- const c = s[0];
437
- if (c.startsWith("`"))
438
- e.push(/* @__PURE__ */ t("code", { children: c.slice(1, -1) }, n++));
439
- else if (c.startsWith("**"))
440
- e.push(/* @__PURE__ */ t("strong", { children: c.slice(2, -2) }, n++));
441
- else if (c.startsWith("*"))
442
- e.push(/* @__PURE__ */ t("em", { children: c.slice(1, -1) }, n++));
443
- else {
444
- const l = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(c), i = l[1], o = l[2], u = o.startsWith("/") && !o.startsWith("//");
445
- /^https?:\/\//i.test(o) || u ? e.push(
446
- /* @__PURE__ */ t("a", { href: o, target: "_blank", rel: "noopener noreferrer", children: i }, n++)
447
- ) : e.push(i);
448
- }
449
- r = r.slice(s.index + c.length);
586
+ const oe = 24;
587
+ function Xe({
588
+ edges: e,
589
+ documentId: a,
590
+ selectedId: t,
591
+ onSelectChunk: r
592
+ }) {
593
+ const [c, l] = b(!1), [s, o] = b(!1);
594
+ 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: [
598
+ /* @__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,
601
+ {
602
+ edge: f,
603
+ selectedId: t,
604
+ documentId: a,
605
+ onSelectChunk: r
606
+ },
607
+ `${f.from_id}-${f.to_id}-${f.kind}-${g}`
608
+ )) })
609
+ ] }),
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 ? "▼" : "▶",
613
+ " relationship graph (",
614
+ e.length,
615
+ ")"
616
+ ] }),
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}` })
620
+ ] })
621
+ ] })
622
+ ] });
623
+ }
624
+ function Ke({
625
+ edge: e,
626
+ selectedId: a,
627
+ documentId: t,
628
+ onSelectChunk: r
629
+ }) {
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: [
632
+ /* @__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,
636
+ " ↗"
637
+ ] })
638
+ ] });
639
+ }
640
+ function Ye(e) {
641
+ const a = ["graph LR"];
642
+ 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}`);
450
645
  }
451
- return e;
646
+ return a.join(`
647
+ `);
452
648
  }
453
- function ie({
454
- documentId: a,
455
- scope: e,
456
- titleHint: r,
457
- browse: n,
458
- principal: s,
459
- renderAssistant: c
649
+ function fe(e) {
650
+ return "n" + e.replace(/[^a-zA-Z0-9]/g, "");
651
+ }
652
+ function be(e, a) {
653
+ const r = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || a.slice(0, 6);
654
+ return r.length > 30 ? r.slice(0, 29) + "…" : r;
655
+ }
656
+ function ye({ source: e }) {
657
+ return /* @__PURE__ */ n("div", { className: "md", children: /* @__PURE__ */ n(Ie, { remarkPlugins: [Ae], components: et, children: e }) });
658
+ }
659
+ const et = {
660
+ // react-markdown already sanitized the href; add target/rel for external links.
661
+ a({ href: e, children: a }) {
662
+ const t = e ?? "", r = /^https?:\/\//i.test(t);
663
+ return /* @__PURE__ */ n("a", { href: t, target: r ? "_blank" : void 0, rel: r ? "noopener noreferrer" : void 0, children: a });
664
+ },
665
+ // Let the code renderer own the block wrapper so a mermaid fence isn't wrapped
666
+ // in a <pre> (and a normal code block gets exactly one <pre>).
667
+ pre({ children: e }) {
668
+ return /* @__PURE__ */ n(q, { children: e });
669
+ },
670
+ code({ className: e, children: a }) {
671
+ const t = /language-(\w+)/.exec(e ?? "")?.[1], r = String(a ?? "");
672
+ return t === "mermaid" ? /* @__PURE__ */ n(Se, { code: r.replace(/\n$/, "") }) : t || r.includes(`
673
+ `) ? /* @__PURE__ */ n("pre", { className: "md-pre", children: /* @__PURE__ */ n("code", { className: e, children: a }) }) : /* @__PURE__ */ n("code", { children: a });
674
+ }
675
+ };
676
+ function Ee({
677
+ documentId: e,
678
+ scope: a,
679
+ titleHint: t,
680
+ browse: r,
681
+ principal: c,
682
+ renderAssistant: l
460
683
  }) {
461
- const l = X(), i = U(
462
- () => n && (n.scopeId || n.tenant) ? { scopeId: n.scopeId, tenant: n.tenant } : void 0,
463
- [n?.scopeId, n?.tenant]
464
- ), [o, u] = f([]), [h, x] = f(void 0), [k, M] = f(null), [y, E] = f("chunks"), [T, L] = f(null), [P, D] = f(null), [W, R] = f(null), [F, b] = f(!1), [N, C] = f(0), [B, J] = f(!1), m = S(() => C((g) => g + 1), []), A = U(() => ve(o), [o]), $ = U(() => o.find((w) => !w.parent_id)?.title || r || "document", [o, r]), V = U(
465
- () => !!k && !k.parent_id,
466
- [k]
684
+ const s = ce(), o = A(
685
+ () => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
686
+ [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]
467
704
  );
468
- j(() => {
469
- let g = !1;
470
- return b(!0), R(null), l.documentQueryChunks(a, e, i).then((w) => {
471
- if (g) return;
472
- const I = w.chunks ?? [];
473
- u(I), x((p) => p ?? I.find((v) => !v.parent_id)?.id);
474
- }).catch((w) => !g && R(w instanceof Error ? w.message : String(w))).finally(() => !g && b(!1)), () => {
475
- g = !0;
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;
713
+ };
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;
718
+ };
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;
476
723
  };
477
- }, [l, a, e, N, i]), j(() => {
478
- x(void 0), M(null), L(null), E("chunks");
479
- }, [a, e]), j(() => {
724
+ }, [s, e, a, N, o]), I(() => {
725
+ f(void 0), M(null), R(null), E("chunks"), p(null), W([]);
726
+ }, [e, a]), I(() => {
480
727
  if (!h) {
481
728
  M(null);
482
729
  return;
483
730
  }
484
- let g = !1;
485
- return l.documentGetChunk(h, e, i).then((w) => !g && M(w)).catch((w) => !g && R(w instanceof Error ? w.message : String(w))), () => {
486
- g = !0;
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;
487
734
  };
488
- }, [l, h, e, N, i]), j(() => {
489
- if (y !== "markdown" || !h) {
490
- L(null);
735
+ }, [s, h, a, N, o]), I(() => {
736
+ if (v !== "markdown" || !h) {
737
+ R(null);
491
738
  return;
492
739
  }
493
- const g = ce(A, h);
494
- if (!g) return;
495
- let w = !1;
496
- const I = [], p = (v, _) => {
497
- I.push({ node: v, depth: _ }), v.children.forEach((O) => p(O, _ + 1));
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));
498
745
  };
499
- return p(g, 0), Promise.all(I.map((v) => l.documentGetChunk(v.node.row.id, e, i))).then((v) => {
500
- if (w) return;
501
- const _ = I.map((O, he) => {
502
- const me = Math.min(O.depth + 1, 6), Y = v[he];
503
- return "#".repeat(me) + " " + O.node.row.title + (Y.body ? `
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 ? `
504
751
 
505
- ` + Y.body : "") + `
752
+ ` + ue.body : "") + `
506
753
  `;
507
754
  }).join(`
508
755
  `);
509
- L(_);
510
- }).catch((v) => !w && R(v instanceof Error ? v.message : String(v))), () => {
511
- w = !0;
756
+ R(ae);
757
+ }).catch((B) => !C && $(B instanceof Error ? B.message : String(B))), () => {
758
+ C = !0;
512
759
  };
513
- }, [l, y, h, A, e, N, i]);
514
- const Z = S((g) => x(g.row.id), []), q = S(async () => {
760
+ }, [s, v, h, X, a, N, o]);
761
+ const ne = G((y) => f(y.row.id), []), De = G(async () => {
515
762
  try {
516
- const g = await l.documentExportMd(a, e, !0, i), w = new Blob([g.markdown], { type: "text/markdown" }), I = URL.createObjectURL(w), p = document.createElement("a");
517
- p.href = I, p.download = (g.title || "document").replace(/[^\w.-]+/g, "_") + ".md", p.click(), URL.revokeObjectURL(I);
518
- } catch (g) {
519
- R(g instanceof Error ? g.message : String(g));
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);
765
+ } catch (y) {
766
+ $(y instanceof Error ? y.message : String(y));
520
767
  }
521
- }, [l, a, e, i]);
768
+ }, [s, e, a, o]);
522
769
  return /* @__PURE__ */ d("div", { className: "doc-viewer", children: [
523
- /* @__PURE__ */ d("div", { className: "doc-toolbar", children: [
524
- /* @__PURE__ */ t("strong", { className: "doc-title", title: $, children: $ }),
770
+ /* @__PURE__ */ d("div", { className: "doc-toolbar", style: H, children: [
771
+ /* @__PURE__ */ n("strong", { className: "doc-title", title: K, children: K }),
525
772
  /* @__PURE__ */ d("div", { className: "doc-toolbar-actions", children: [
526
- /* @__PURE__ */ t("button", { type: "button", onClick: () => {
527
- q();
773
+ /* @__PURE__ */ n(
774
+ "button",
775
+ {
776
+ type: "button",
777
+ className: x ? "active" : "",
778
+ onClick: () => T(!0),
779
+ disabled: !Y,
780
+ title: "Colors — tint chunk tiles + the Path tree by type/status",
781
+ children: "colors"
782
+ }
783
+ ),
784
+ /* @__PURE__ */ n("button", { type: "button", onClick: () => {
785
+ De();
528
786
  }, title: "Download the whole document as Markdown (.md)", children: "↓ .md" }),
529
- c && /* @__PURE__ */ t(
787
+ l && /* @__PURE__ */ n(
530
788
  "button",
531
789
  {
532
790
  type: "button",
533
- className: B ? "active" : "",
534
- onClick: () => J((g) => !g),
791
+ className: F ? "active" : "",
792
+ onClick: () => Z((y) => !y),
535
793
  title: "Document Assistant — instruct an agent to restructure/import/link chunks",
536
794
  children: "assistant"
537
795
  }
538
796
  ),
539
- /* @__PURE__ */ t("button", { type: "button", onClick: m, title: "Reload", children: "↻" })
797
+ /* @__PURE__ */ n("button", { type: "button", onClick: Q, title: "Reload", children: "↻" })
540
798
  ] })
541
799
  ] }),
542
- W && /* @__PURE__ */ t("div", { className: "paths-err", children: W }),
800
+ U && /* @__PURE__ */ n("div", { className: "paths-err", children: U }),
543
801
  /* @__PURE__ */ d("div", { className: "doc-split", children: [
544
- /* @__PURE__ */ t("div", { className: "doc-chunktree", children: F && o.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Loading…" }) }) : /* @__PURE__ */ t(Ne, { tree: A, selectedId: h, onSelect: Z }) }),
545
- /* @__PURE__ */ t("div", { className: "doc-content", children: k ? /* @__PURE__ */ d(G, { 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,
804
+ {
805
+ tree: X,
806
+ selectedId: h,
807
+ onSelect: ne,
808
+ colorEnabled: x,
809
+ scheme: P?.color_scheme,
810
+ linkedIds: L
811
+ }
812
+ ) }),
813
+ /* @__PURE__ */ n("div", { className: "doc-content", children: g ? /* @__PURE__ */ d(q, { children: [
546
814
  /* @__PURE__ */ d("div", { className: "doc-content-head", children: [
547
- /* @__PURE__ */ t("h3", { children: k.title || "(untitled)" }),
815
+ /* @__PURE__ */ n("h3", { children: g.title || "(untitled)" }),
548
816
  /* @__PURE__ */ d("div", { className: "doc-content-meta", children: [
549
- k.type && /* @__PURE__ */ t("span", { className: "chunk-badge", children: k.type }),
550
- k.status && /* @__PURE__ */ t("span", { className: "chunk-badge chunk-status", children: k.status }),
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 }),
551
819
  /* @__PURE__ */ d("span", { className: "chunk-rev", children: [
552
820
  "rev ",
553
- k.revision
821
+ g.revision
554
822
  ] })
555
823
  ] }),
556
824
  /* @__PURE__ */ d("div", { className: "doc-content-controls", children: [
557
825
  /* @__PURE__ */ d("div", { className: "doc-mode-toggle", children: [
558
- /* @__PURE__ */ t(
826
+ /* @__PURE__ */ n(
559
827
  "button",
560
828
  {
561
829
  type: "button",
562
- className: y === "chunks" ? "active" : "",
830
+ className: v === "chunks" ? "active" : "",
563
831
  onClick: () => E("chunks"),
564
832
  title: "This chunk's own content",
565
833
  children: "chunk"
566
834
  }
567
835
  ),
568
- /* @__PURE__ */ t(
836
+ /* @__PURE__ */ n(
569
837
  "button",
570
838
  {
571
839
  type: "button",
572
- className: y === "markdown" ? "active" : "",
840
+ className: v === "markdown" ? "active" : "",
573
841
  onClick: () => E("markdown"),
574
- title: V ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
842
+ title: te ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
575
843
  children: "markdown"
576
844
  }
577
845
  )
578
846
  ] }),
579
- /* @__PURE__ */ t("button", { type: "button", onClick: () => D(k), children: "edit" })
847
+ /* @__PURE__ */ n("button", { type: "button", onClick: () => D(g), children: "edit" })
580
848
  ] })
581
849
  ] }),
582
- /* @__PURE__ */ t("div", { className: "doc-content-body", children: y === "markdown" ? T !== null ? /* @__PURE__ */ t(te, { source: T }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : k.body ? /* @__PURE__ */ t(te, { source: k.body }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "(empty chunk)" }) })
583
- ] }) : /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Select a chunk on the left." }) }) })
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)" }) }),
851
+ /* @__PURE__ */ n(
852
+ Xe,
853
+ {
854
+ edges: S,
855
+ documentId: e,
856
+ selectedId: h,
857
+ onSelectChunk: f
858
+ }
859
+ )
860
+ ] }) : /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Select a chunk on the left." }) }) })
584
861
  ] }),
585
- B && c && /* @__PURE__ */ t("div", { className: "doc-assistant", children: c({
586
- documentId: a,
587
- scope: e,
588
- subject: s?.subject,
862
+ F && l && /* @__PURE__ */ n("div", { className: "doc-assistant", children: l({
863
+ documentId: e,
864
+ scope: a,
865
+ subject: c?.subject,
589
866
  // Pass the viewer's own reload so the injected assistant can refresh
590
867
  // the tree + selected chunk after a turn mutates the document.
591
- onChanged: m
868
+ onChanged: Q
592
869
  }) }),
593
- P && /* @__PURE__ */ t(
594
- Ce,
870
+ j && /* @__PURE__ */ n(
871
+ Ve,
595
872
  {
596
- chunk: P,
597
- scope: e,
598
- browse: i,
873
+ chunk: j,
874
+ scope: a,
875
+ browse: o,
599
876
  onClose: () => D(null),
600
- onSaved: m
877
+ onSaved: Q
878
+ }
879
+ ),
880
+ m && Y && /* @__PURE__ */ n(
881
+ qe,
882
+ {
883
+ documentId: e,
884
+ rootChunkId: Y,
885
+ docType: P?.type,
886
+ docStatus: P?.status,
887
+ chunkStatuses: w,
888
+ scope: a,
889
+ browse: o,
890
+ onClose: () => T(!1),
891
+ onSaved: Q
601
892
  }
602
893
  )
603
894
  ] });
604
895
  }
605
- function De(a) {
606
- const e = {
896
+ function tt(e) {
897
+ const a = {
607
898
  name: "",
608
899
  fullPath: "",
609
900
  kind: "directory",
610
901
  explicit: !0,
611
902
  children: []
612
- }, r = /* @__PURE__ */ new Map([["", e]]), n = (c) => {
613
- const l = r.get(c);
614
- if (l) return l;
615
- const i = c.lastIndexOf("/"), o = i <= 0 ? "" : c.slice(0, i), u = c.slice(i + 1), h = n(o), x = {
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 = {
616
907
  name: u,
617
- fullPath: c,
908
+ fullPath: l,
618
909
  kind: "directory",
619
910
  explicit: !1,
620
911
  children: []
621
912
  };
622
- return h.children.push(x), r.set(c, x), x;
913
+ return h.children.push(f), t.set(l, f), f;
623
914
  };
624
- for (const c of a) {
625
- const l = n(c.full_path);
626
- l.kind = c.kind, l.explicit = !0, l.resourceRef = c.resource_ref;
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;
627
918
  }
628
- const s = (c) => {
629
- c.sort((l, i) => {
630
- const o = l.kind === "directory", u = i.kind === "directory";
631
- return o !== u ? o ? -1 : 1 : l.name.localeCompare(i.name);
632
- }), c.forEach((l) => s(l.children));
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));
633
924
  };
634
- return s(e.children), e.children;
925
+ return c(a.children), a.children;
635
926
  }
636
- function Q(a) {
637
- const e = a.lastIndexOf("/");
638
- return e <= 0 ? "" : a.slice(0, e);
927
+ function le(e) {
928
+ const a = e.lastIndexOf("/");
929
+ return a <= 0 ? "" : e.slice(0, a);
639
930
  }
640
- function Me(a) {
641
- const e = [], r = (n) => {
642
- if (n.kind === "document") {
643
- const s = n.resourceRef;
644
- s?.document_id && e.push(s.document_id);
931
+ function nt(e) {
932
+ const a = [], t = (r) => {
933
+ if (r.kind === "document") {
934
+ const c = r.resourceRef;
935
+ c?.document_id && a.push(c.document_id);
645
936
  }
646
- n.children.forEach(r);
937
+ r.children.forEach(t);
647
938
  };
648
- return r(a), e;
939
+ return t(e), a;
649
940
  }
650
- const _e = {
941
+ const at = {
651
942
  directory: "📁",
652
943
  document: "📄",
653
944
  volume_mount: "💾",
654
945
  memory_entry: "🧠"
655
946
  };
656
- function Le({ tree: a, selectedPath: e, onSelect: r }) {
657
- const [n, s] = f(() => /* @__PURE__ */ new Map()), c = S((l) => {
658
- s((i) => {
659
- const o = new Map(i);
660
- return o.set(l, i.get(l) === !1), o;
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;
661
952
  });
662
953
  }, []);
663
- return j(() => {
664
- e && s((l) => {
954
+ return I(() => {
955
+ a && l((o) => {
665
956
  let i = !1;
666
- const o = new Map(l);
667
- let u = Q(e);
668
- for (; u !== ""; )
669
- o.get(u) === !1 && (o.set(u, !0), i = !0), u = Q(u);
670
- return i ? o : l;
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;
671
962
  });
672
- }, [e]), a.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "This tree is empty. Create a folder or document to begin." }) }) : /* @__PURE__ */ t("ul", { className: "tree path-tree", children: a.map((l) => /* @__PURE__ */ t(
673
- de,
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,
674
965
  {
675
- node: l,
676
- expanded: n,
677
- toggle: c,
678
- selectedPath: e,
679
- onSelect: r
966
+ node: o,
967
+ expanded: c,
968
+ toggle: s,
969
+ selectedPath: a,
970
+ onSelect: t,
971
+ summaries: r
680
972
  },
681
- l.fullPath
973
+ o.fullPath
682
974
  )) });
683
975
  }
684
- function de({ node: a, expanded: e, toggle: r, selectedPath: n, onSelect: s }) {
685
- const c = a.children.length > 0, l = e.get(a.fullPath) !== !1, i = n === a.fullPath;
686
- return /* @__PURE__ */ d("li", { className: `node path-node kind-${a.kind} ${i ? "selected" : ""}`, children: [
687
- /* @__PURE__ */ d("div", { className: "row path-row", children: [
688
- /* @__PURE__ */ t(
976
+ function ct(e, a) {
977
+ if (e.kind !== "document" || !a) return;
978
+ const t = e.resourceRef;
979
+ return t?.document_id ? a.get(t.document_id) : void 0;
980
+ }
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: [
985
+ /* @__PURE__ */ n(
689
986
  "button",
690
987
  {
691
988
  type: "button",
692
989
  className: "tree-caret",
693
- "aria-label": l ? "collapse" : "expand",
694
- disabled: !c,
695
- onClick: (o) => {
696
- o.stopPropagation(), c && r(a.fullPath);
990
+ "aria-label": o ? "collapse" : "expand",
991
+ disabled: !s,
992
+ onClick: (f) => {
993
+ f.stopPropagation(), s && t(e.fullPath);
697
994
  },
698
- children: c ? l ? "▼" : "▶" : "·"
995
+ children: s ? o ? "▼" : "▶" : "·"
699
996
  }
700
997
  ),
701
998
  /* @__PURE__ */ d(
@@ -703,136 +1000,162 @@ function de({ node: a, expanded: e, toggle: r, selectedPath: n, onSelect: s }) {
703
1000
  {
704
1001
  type: "button",
705
1002
  className: "path-link",
706
- onClick: () => s(a),
707
- title: a.fullPath,
1003
+ onClick: () => c(e),
1004
+ title: e.fullPath,
708
1005
  children: [
709
- /* @__PURE__ */ t("span", { className: "path-kind-icon", "aria-hidden": !0, children: _e[a.kind] ?? "•" }),
710
- /* @__PURE__ */ t("span", { className: "path-name", children: a.name }),
711
- !a.explicit && /* @__PURE__ */ t("span", { className: "path-implicit", title: "Implicit directory (no stored entry)", children: "implicit" })
1006
+ /* @__PURE__ */ n("span", { className: "path-kind-icon", "aria-hidden": !0, children: at[e.kind] ?? "•" }),
1007
+ /* @__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 }),
1010
+ !e.explicit && /* @__PURE__ */ n("span", { className: "path-implicit", title: "Implicit directory (no stored entry)", children: "implicit" })
712
1011
  ]
713
1012
  }
714
1013
  )
715
1014
  ] }),
716
- c && l && /* @__PURE__ */ t("ul", { className: "children path-children", children: a.children.map((o) => /* @__PURE__ */ t(
717
- de,
1015
+ s && o && /* @__PURE__ */ n("ul", { className: "children path-children", children: e.children.map((f) => /* @__PURE__ */ n(
1016
+ $e,
718
1017
  {
719
- node: o,
720
- expanded: e,
721
- toggle: r,
722
- selectedPath: n,
723
- onSelect: s
1018
+ node: f,
1019
+ expanded: a,
1020
+ toggle: t,
1021
+ selectedPath: r,
1022
+ onSelect: c,
1023
+ summaries: l
724
1024
  },
725
- o.fullPath
1025
+ f.fullPath
726
1026
  )) })
727
1027
  ] });
728
1028
  }
729
- const ne = /^[A-Za-z0-9._-]+$/;
730
- function ae(a, e) {
731
- return `${a}/${e}`;
1029
+ const ge = /^[A-Za-z0-9._-]+$/;
1030
+ function ke(e, a) {
1031
+ return `${e}/${a}`;
732
1032
  }
733
- function ue(a, e) {
734
- for (const r of a) {
735
- if (r.fullPath === e) return r;
736
- const n = ue(r.children, e);
737
- if (n) return n;
1033
+ function Me(e, a) {
1034
+ for (const t of e) {
1035
+ if (t.fullPath === a) return t;
1036
+ const r = Me(t.children, a);
1037
+ if (r) return r;
738
1038
  }
739
1039
  }
740
- function Oe(a) {
741
- const { theme: e, defaultScope: r, path: n, onPathChange: s, browse: c, principal: l, renderAssistant: i, onError: o } = a, u = le(a);
742
- return /* @__PURE__ */ t(se, { theme: e, dataLayer: u, children: /* @__PURE__ */ t(
743
- Re,
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,
744
1044
  {
745
- defaultScope: r,
746
- path: n,
747
- onPathChange: s,
748
- browse: c,
749
- principal: l,
750
- renderAssistant: i,
751
- onError: o
1045
+ defaultScope: t,
1046
+ path: r,
1047
+ onPathChange: c,
1048
+ browse: l,
1049
+ principal: s,
1050
+ renderAssistant: o,
1051
+ onError: i
752
1052
  }
753
1053
  ) });
754
1054
  }
755
- function Re({
756
- defaultScope: a,
757
- path: e,
758
- onPathChange: r,
759
- browse: n,
760
- principal: s,
761
- renderAssistant: c,
762
- onError: l
1055
+ function ot({
1056
+ defaultScope: e,
1057
+ path: a,
1058
+ onPathChange: t,
1059
+ browse: r,
1060
+ principal: c,
1061
+ renderAssistant: l,
1062
+ onError: s
763
1063
  }) {
764
- const i = X(), [o, u] = f(a ?? "user"), [h, x] = f([]), [k, M] = f(void 0), [y, E] = f(null), [T, L] = f(!1), [P, D] = f(null), W = e !== void 0 ? e : k, R = H(r);
765
- j(() => {
766
- R.current = r;
767
- }, [r]);
768
- const F = H(l);
769
- j(() => {
770
- F.current = l;
771
- }, [l]);
772
- const b = S((p) => {
773
- R.current?.(p), M(p);
774
- }, []), N = U(
775
- () => n && (n.scopeId || n.tenant) ? { scopeId: n.scopeId, tenant: n.tenant } : void 0,
776
- [n?.scopeId, n?.tenant]
777
- ), C = S(async () => {
778
- L(!0), E(null);
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;
1067
+ }, [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(
1075
+ () => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
1076
+ [r?.scopeId, r?.tenant]
1077
+ ), _ = G(async () => {
1078
+ R(!0), E(null);
779
1079
  try {
780
- const p = await i.pathLs("/", o, !0, N);
781
- x(p.entries ?? []);
782
- } catch (p) {
783
- E(p instanceof Error ? p.message : String(p)), x([]), F.current?.(p);
1080
+ const w = await o.pathLs("/", i, !0, N);
1081
+ f(w.entries ?? []);
1082
+ } catch (w) {
1083
+ E(w instanceof Error ? w.message : String(w)), f([]), J.current?.(w);
784
1084
  } finally {
785
- L(!1);
1085
+ R(!1);
1086
+ }
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());
1095
+ return;
786
1096
  }
787
- }, [i, o, N]), B = H(!0);
788
- j(() => {
789
- B.current ? B.current = !1 : b(void 0), C();
790
- }, [C, b]);
791
- const J = U(() => De(h), [h]), m = U(
792
- () => W ? ue(J, W) : void 0,
793
- [J, W]
794
- ), A = U(() => m ? m.kind === "directory" ? m.fullPath : Q(m.fullPath) : "", [m]), $ = A || "/", V = o !== "tenant", Z = S(() => {
1097
+ const w = h.filter((L) => L.kind === "document").map((L) => L.resource_ref?.document_id).filter((L) => !!L);
1098
+ if (w.length === 0) {
1099
+ p(/* @__PURE__ */ new Map());
1100
+ return;
1101
+ }
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);
1108
+ }).catch(() => {
1109
+ x || p(/* @__PURE__ */ new Map());
1110
+ }), () => {
1111
+ x = !0;
1112
+ };
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(() => {
795
1118
  D({
796
- title: `New folder in ${$}`,
1119
+ title: `New folder in ${S}`,
797
1120
  fields: [{ key: "name", label: "Folder name", placeholder: "e.g. launches" }],
798
1121
  submitLabel: "Create",
799
- onSubmit: async (p) => {
800
- const v = p.name.trim();
801
- if (!ne.test(v)) throw new Error("name may contain only [A-Za-z0-9._-]");
802
- const _ = ae(A, v);
803
- await i.pathMkdir(_, o, N), await C(), b(_);
1122
+ 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);
804
1127
  }
805
1128
  });
806
- }, [i, A, $, o, N, C, b]), q = S(() => {
1129
+ }, [o, T, S, i, N, _, k]), X = G(() => {
807
1130
  D({
808
- title: `New document in ${$}`,
1131
+ title: `New document in ${S}`,
809
1132
  fields: [
810
1133
  { key: "name", label: "Path name", placeholder: "e.g. launch-plan" },
811
1134
  { key: "title", label: "Title", placeholder: "e.g. Launch Plan" }
812
1135
  ],
813
1136
  submitLabel: "Create",
814
- onSubmit: async (p) => {
815
- const v = p.name.trim();
816
- if (!ne.test(v)) throw new Error("name may contain only [A-Za-z0-9._-]");
817
- const _ = p.title.trim() || v, O = ae(A, v);
818
- await i.documentCreate(_, O, o, N), await C(), b(O);
1137
+ 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);
819
1142
  }
820
1143
  });
821
- }, [i, A, $, o, N, C, b]), g = S(() => {
1144
+ }, [o, T, S, i, N, _, k]), K = G(() => {
822
1145
  m && D({
823
1146
  title: `Rename / move ${m.fullPath}`,
824
1147
  fields: [{ key: "to", label: "New path", value: m.fullPath }],
825
1148
  submitLabel: "Move",
826
- onSubmit: async (p) => {
827
- const v = p.to.trim();
828
- if (!v.startsWith("/")) throw new Error("path must start with /");
829
- await i.pathMv(m.fullPath, v, o, N), await C(), b(v);
1149
+ 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);
830
1153
  }
831
1154
  });
832
- }, [i, m, o, N, C, b]), w = S(() => {
1155
+ }, [o, m, i, N, _, k]), te = G(() => {
833
1156
  if (!m) return;
834
1157
  if (m.kind === "document") {
835
- const O = m.resourceRef?.document_id;
1158
+ const H = m.resourceRef?.document_id;
836
1159
  D({
837
1160
  title: `Delete document ${m.fullPath}`,
838
1161
  message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
@@ -840,29 +1163,29 @@ function Re({
840
1163
  submitLabel: "Delete",
841
1164
  danger: !0,
842
1165
  onSubmit: async () => {
843
- if (!O) throw new Error("this document dirent has no document_id");
844
- await i.documentDelete(O, o, N), await C(), b(void 0);
1166
+ if (!H) throw new Error("this document dirent has no document_id");
1167
+ await o.documentDelete(H, i, N), await _(), k(void 0);
845
1168
  }
846
1169
  });
847
1170
  return;
848
1171
  }
849
- const p = o === "tenant" ? [] : Me(m), v = m.children.length;
1172
+ const w = i === "tenant" ? [] : nt(m), x = m.children.length;
850
1173
  D({
851
1174
  title: `Delete branch ${m.fullPath}`,
852
- message: v === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (p.length > 0 ? ` — including ${p.length} document(s), whose chunks are deleted.` : "."),
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.` : "."),
853
1176
  fields: [],
854
1177
  submitLabel: "Delete",
855
1178
  danger: !0,
856
1179
  onSubmit: async () => {
857
- for (const _ of p)
858
- await i.documentDelete(_, o, N);
859
- await i.pathRm(m.fullPath, o, !0, N), await C(), b(void 0);
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);
860
1183
  }
861
1184
  });
862
- }, [i, m, o, N, C, b]), I = m && (m.kind === "directory" || m.kind === "document");
863
- return /* @__PURE__ */ d(G, { children: [
1185
+ }, [o, m, i, N, _, k]), Y = m && (m.kind === "directory" || m.kind === "document");
1186
+ return /* @__PURE__ */ d(q, { children: [
864
1187
  /* @__PURE__ */ d(
865
- ye,
1188
+ Ue,
866
1189
  {
867
1190
  className: "paths-view",
868
1191
  defaultLeftWidth: 420,
@@ -873,151 +1196,160 @@ function Re({
873
1196
  /* @__PURE__ */ d("div", { className: "left", children: [
874
1197
  /* @__PURE__ */ d("div", { className: "paths-toolbar", children: [
875
1198
  /* @__PURE__ */ d("label", { className: "paths-scope", children: [
876
- /* @__PURE__ */ t("span", { children: "scope" }),
877
- /* @__PURE__ */ d("select", { value: o, onChange: (p) => u(p.target.value), children: [
878
- /* @__PURE__ */ t("option", { value: "user", children: "user" }),
879
- /* @__PURE__ */ t("option", { value: "agent", children: "agent" }),
880
- /* @__PURE__ */ t("option", { value: "tenant", children: "tenant" })
1199
+ /* @__PURE__ */ n("span", { children: "scope" }),
1200
+ /* @__PURE__ */ d("select", { value: i, onChange: (w) => u(w.target.value), children: [
1201
+ /* @__PURE__ */ n("option", { value: "user", children: "user" }),
1202
+ /* @__PURE__ */ n("option", { value: "agent", children: "agent" }),
1203
+ /* @__PURE__ */ n("option", { value: "tenant", children: "tenant" })
881
1204
  ] })
882
1205
  ] }),
883
1206
  /* @__PURE__ */ d("div", { className: "paths-toolbar-actions", children: [
884
- /* @__PURE__ */ t("button", { type: "button", onClick: Z, title: `New folder in ${$}`, children: "+ folder" }),
885
- /* @__PURE__ */ t(
1207
+ /* @__PURE__ */ n("button", { type: "button", onClick: Q, title: `New folder in ${S}`, children: "+ folder" }),
1208
+ /* @__PURE__ */ n(
886
1209
  "button",
887
1210
  {
888
1211
  type: "button",
889
- onClick: q,
890
- disabled: !V,
891
- title: V ? `New document in ${$}` : "Documents are agent/user scope only",
1212
+ onClick: X,
1213
+ disabled: !W,
1214
+ title: W ? `New document in ${S}` : "Documents are agent/user scope only",
892
1215
  children: "+ document"
893
1216
  }
894
1217
  ),
895
- /* @__PURE__ */ t("button", { type: "button", onClick: () => {
896
- C();
1218
+ /* @__PURE__ */ n("button", { type: "button", onClick: () => {
1219
+ _();
897
1220
  }, title: "Reload the tree", children: "↻" })
898
1221
  ] })
899
1222
  ] }),
900
1223
  /* @__PURE__ */ d("p", { className: "paths-context", children: [
901
1224
  "new items → ",
902
- /* @__PURE__ */ t("code", { children: $ }),
903
- N?.scopeId && /* @__PURE__ */ d(G, { children: [
1225
+ /* @__PURE__ */ n("code", { children: S }),
1226
+ N?.scopeId && /* @__PURE__ */ d(q, { children: [
904
1227
  " · ",
905
1228
  "subject ",
906
- /* @__PURE__ */ t("code", { children: N.scopeId })
1229
+ /* @__PURE__ */ n("code", { children: N.scopeId })
907
1230
  ] }),
908
- N?.tenant && /* @__PURE__ */ d(G, { children: [
1231
+ N?.tenant && /* @__PURE__ */ d(q, { children: [
909
1232
  " · ",
910
1233
  "tenant ",
911
- /* @__PURE__ */ t("code", { children: N.tenant })
1234
+ /* @__PURE__ */ n("code", { children: N.tenant })
912
1235
  ] })
913
1236
  ] }),
914
- y && /* @__PURE__ */ t("div", { className: "paths-err", children: y }),
915
- T && h.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Loading…" }) }) : /* @__PURE__ */ t(
916
- Le,
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,
917
1240
  {
918
- tree: J,
919
- selectedPath: W,
920
- onSelect: (p) => b(p.fullPath)
1241
+ tree: Z,
1242
+ selectedPath: U,
1243
+ onSelect: (w) => k(w.fullPath),
1244
+ summaries: P
921
1245
  }
922
1246
  )
923
1247
  ] }),
924
- /* @__PURE__ */ t("div", { className: "right", children: m ? m.kind === "document" ? /* @__PURE__ */ d("div", { className: "paths-doc", children: [
1248
+ /* @__PURE__ */ n("div", { className: "right", children: m ? m.kind === "document" ? /* @__PURE__ */ d("div", { className: "paths-doc", children: [
925
1249
  /* @__PURE__ */ d("div", { className: "paths-doc-head", children: [
926
- /* @__PURE__ */ t("code", { className: "paths-doc-path", children: m.fullPath }),
1250
+ /* @__PURE__ */ n("code", { className: "paths-doc-path", children: m.fullPath }),
927
1251
  /* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
928
- /* @__PURE__ */ t("button", { type: "button", onClick: g, children: "rename / move" }),
929
- /* @__PURE__ */ t("button", { type: "button", className: "danger", onClick: w, children: "delete" })
1252
+ /* @__PURE__ */ n("button", { type: "button", onClick: K, children: "rename / move" }),
1253
+ /* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: te, children: "delete" })
930
1254
  ] })
931
1255
  ] }),
932
- /* @__PURE__ */ t(
933
- ie,
1256
+ /* @__PURE__ */ n(
1257
+ Ee,
934
1258
  {
935
1259
  documentId: m.resourceRef?.document_id ?? "",
936
- scope: o === "agent" ? "agent" : "user",
1260
+ scope: i === "agent" ? "agent" : "user",
937
1261
  titleHint: m.name,
938
1262
  browse: N,
939
- principal: s,
940
- renderAssistant: c
1263
+ principal: c,
1264
+ renderAssistant: l
941
1265
  }
942
1266
  )
943
1267
  ] }) : /* @__PURE__ */ d("div", { className: "paths-detail", children: [
944
1268
  /* @__PURE__ */ d("h2", { children: [
945
- /* @__PURE__ */ t("span", { className: "paths-detail-kind", children: m.kind }),
946
- /* @__PURE__ */ t("code", { children: m.fullPath })
1269
+ /* @__PURE__ */ n("span", { className: "paths-detail-kind", children: m.kind }),
1270
+ /* @__PURE__ */ n("code", { children: m.fullPath })
947
1271
  ] }),
948
1272
  /* @__PURE__ */ d("dl", { className: "paths-detail-meta", children: [
949
- /* @__PURE__ */ t("dt", { children: "scope" }),
950
- /* @__PURE__ */ t("dd", { children: o }),
951
- /* @__PURE__ */ t("dt", { children: "stored" }),
952
- /* @__PURE__ */ t("dd", { children: m.explicit ? "yes" : "implicit (no entry)" })
1273
+ /* @__PURE__ */ n("dt", { children: "scope" }),
1274
+ /* @__PURE__ */ n("dd", { children: i }),
1275
+ /* @__PURE__ */ n("dt", { children: "stored" }),
1276
+ /* @__PURE__ */ n("dd", { children: m.explicit ? "yes" : "implicit (no entry)" })
953
1277
  ] }),
954
- I ? /* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
955
- /* @__PURE__ */ t("button", { type: "button", onClick: g, children: "rename / move" }),
956
- /* @__PURE__ */ t("button", { type: "button", className: "danger", onClick: w, children: "delete" })
1278
+ Y ? /* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
1279
+ /* @__PURE__ */ n("button", { type: "button", onClick: K, children: "rename / move" }),
1280
+ /* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: te, children: "delete" })
957
1281
  ] }) : /* @__PURE__ */ d("p", { className: "paths-readonly", children: [
958
1282
  "Read-only — ",
959
1283
  m.kind,
960
1284
  " entries are managed by their own tool."
961
1285
  ] })
962
- ] }) : /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Select a path on the left, or create a folder / document." }) }) })
1286
+ ] }) : /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Select a path on the left, or create a folder / document." }) }) })
963
1287
  ]
964
1288
  }
965
1289
  ),
966
- P && /* @__PURE__ */ t(Ie, { state: P, onClose: () => D(null) })
1290
+ j && /* @__PURE__ */ n(st, { state: j, onClose: () => D(null) })
967
1291
  ] });
968
1292
  }
969
- function Ie({ state: a, onClose: e }) {
970
- const [r, n] = f(
971
- () => Object.fromEntries(a.fields.map((u) => [u.key, u.value ?? ""]))
972
- ), [s, c] = f(!1), [l, i] = f(null);
973
- return /* @__PURE__ */ t("div", { className: "modal-overlay", onClick: e, children: /* @__PURE__ */ d("form", { className: "modal", onClick: (u) => u.stopPropagation(), onSubmit: async (u) => {
974
- u.preventDefault(), c(!0), i(null);
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);
975
1299
  try {
976
- await a.onSubmit(r), e();
1300
+ await e.onSubmit(t), a();
977
1301
  } catch (h) {
978
- i(h instanceof Error ? h.message : String(h)), c(!1);
1302
+ o(h instanceof Error ? h.message : String(h)), l(!1);
979
1303
  }
980
1304
  }, children: [
981
- /* @__PURE__ */ t("h3", { children: a.title }),
982
- a.message && /* @__PURE__ */ t("p", { className: "modal-context", children: a.message }),
983
- a.fields.map((u, h) => /* @__PURE__ */ d("label", { className: "path-field", children: [
984
- /* @__PURE__ */ t("span", { children: u.label }),
985
- /* @__PURE__ */ t(
1305
+ /* @__PURE__ */ d("div", { className: "modal-header sticky-top", children: [
1306
+ /* @__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 })
1310
+ ] })
1311
+ ] }),
1312
+ 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 }),
1315
+ /* @__PURE__ */ n(
986
1316
  "input",
987
1317
  {
988
1318
  className: "path-modal-input",
989
- value: r[u.key],
1319
+ value: t[u.key],
990
1320
  placeholder: u.placeholder,
991
1321
  autoFocus: h === 0,
992
- onChange: (x) => n((k) => ({ ...k, [u.key]: x.target.value }))
1322
+ onChange: (f) => r((g) => ({ ...g, [u.key]: f.target.value }))
993
1323
  }
994
1324
  )
995
1325
  ] }, u.key)),
996
- l && /* @__PURE__ */ t("div", { className: "modal-err", children: l }),
997
- /* @__PURE__ */ d("div", { className: "modal-buttons", children: [
998
- /* @__PURE__ */ t("button", { type: "button", onClick: e, disabled: s, children: "cancel" }),
999
- /* @__PURE__ */ t("button", { type: "submit", className: a.danger ? "danger" : "primary", disabled: s, children: s ? "working…" : a.submitLabel })
1000
- ] })
1326
+ s && /* @__PURE__ */ n("div", { className: "modal-err", children: s })
1001
1327
  ] }) });
1002
1328
  }
1003
- function je(a) {
1004
- const { documentId: e, scope: r, titleHint: n, browse: s, theme: c, principal: l, renderAssistant: i } = a, o = le(a);
1005
- return /* @__PURE__ */ t(se, { theme: c, dataLayer: o, children: /* @__PURE__ */ t(
1006
- ie,
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,
1007
1333
  {
1008
- documentId: e,
1009
- scope: r,
1010
- titleHint: n,
1011
- browse: s,
1012
- principal: l,
1013
- renderAssistant: i
1334
+ documentId: a,
1335
+ scope: t,
1336
+ titleHint: r,
1337
+ browse: c,
1338
+ principal: s,
1339
+ renderAssistant: o
1014
1340
  }
1015
1341
  ) });
1016
1342
  }
1017
1343
  export {
1018
- je as DocumentViewer,
1019
- Oe as PathExplorer,
1020
- ke as createLoomcycleClient,
1021
- K as dataLayerFromClient
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
1022
1354
  };
1023
1355
  //# sourceMappingURL=index.js.map