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