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