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