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