dsh-knowledge-library 0.0.0-stage → 0.1.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/client.js ADDED
@@ -0,0 +1,721 @@
1
+ window.__ModuleLoader__.load({id:"dsh-knowledge-library",factory:(require)=>{var module={exports:{}};var exports=module.exports;
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/client.tsx
22
+ var client_exports = {};
23
+ __export(client_exports, {
24
+ apply: () => apply,
25
+ inject: () => inject
26
+ });
27
+ module.exports = __toCommonJS(client_exports);
28
+
29
+ // src/ui/App.tsx
30
+ var import_react = require("react");
31
+
32
+ // src/ui/icons.tsx
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ function Icon({ name, size = 20 }) {
35
+ const paths = {
36
+ library: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 4h5v16H4zM12 4h3v16h-3zM17 5l3-1 4 15-3 1z" }) }),
37
+ plus: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 5v14M5 12h14" }),
38
+ search: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
39
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "10.5", cy: "10.5", r: "6.5" }),
40
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m16 16 4 4" })
41
+ ] }),
42
+ file: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 3H5v18h14V8zM14 3v5h5M8 13h8M8 17h6" }) }),
43
+ web: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
45
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 12h18M12 3c5 5 5 13 0 18-5-5-5-13 0-18" })
46
+ ] }),
47
+ video: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
48
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
49
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m10 9 5 3-5 3z" })
50
+ ] }),
51
+ note: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 4H5v16h14v-8M10 14l1-4 8-8 3 3-8 8z" }) }),
52
+ folder: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 6h7l2 3h9v11H3z" }),
53
+ inbox: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 4h14l3 11v5H2v-5zM2 15h6l2 3h4l2-3h6" }) }),
54
+ tag: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 3h9l9 9-9 9-9-9z" }),
56
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "8", r: "1" })
57
+ ] }),
58
+ arrow: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m9 5 7 7-7 7" }),
59
+ close: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12M18 6 6 18" }),
60
+ upload: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 16V3m-5 5 5-5 5 5M3 15v6h18v-6" }) }),
61
+ check: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m5 12 4 4L19 6" }),
62
+ clock: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 7v6l4 2" })
65
+ ] }),
66
+ copy: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "8", y: "8", width: "12", height: "13", rx: "2" }),
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 8V3H3v13h5" })
69
+ ] }),
70
+ download: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 3v13m-5-5 5 5 5-5M3 17v4h18v-4" }) }),
71
+ settings: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 7h16M4 17h16" }),
73
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "9", cy: "7", r: "3" }),
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "15", cy: "17", r: "3" })
75
+ ] })
76
+ };
77
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths[name] || paths.file });
78
+ }
79
+ var LibraryIcon = ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "library", size });
80
+
81
+ // src/ui/App.tsx
82
+ var import_jsx_runtime2 = require("react/jsx-runtime");
83
+ var API = "/knowledge-library/api";
84
+ var kinds = {
85
+ web: { label: "\u7F51\u9875", icon: "web" },
86
+ text: { label: "\u6587\u672C", icon: "file" },
87
+ file: { label: "\u6587\u4EF6", icon: "file" },
88
+ video: { label: "\u97F3\u89C6\u9891", icon: "video" },
89
+ transcript: { label: "\u5B57\u5E55", icon: "video" },
90
+ note: { label: "\u7B14\u8BB0", icon: "note" }
91
+ };
92
+ var time = (v) => `${String(Math.floor(v / 3600)).padStart(2, "0")}:${String(Math.floor(v / 60) % 60).padStart(2, "0")}:${String(Math.floor(v) % 60).padStart(2, "0")}`;
93
+ var date = (value) => new Intl.DateTimeFormat("zh-CN", { month: "2-digit", day: "2-digit" }).format(new Date(value));
94
+ async function api(path, options = {}) {
95
+ const response = await fetch(API + path, { ...options, headers: { "Content-Type": "application/json", "X-Knowledge-Library": "1", ...options.headers } });
96
+ const data = await response.json();
97
+ if (!response.ok) throw new Error(data.error || `\u8BF7\u6C42\u5931\u8D25\uFF1A${response.status}`);
98
+ return data;
99
+ }
100
+ var post = (path, value, method = "POST") => api(path, { method, body: JSON.stringify(value) });
101
+ function splitTags(value) {
102
+ return value.split(/[,,]/).map((v) => v.trim()).filter(Boolean);
103
+ }
104
+ function App() {
105
+ const [stats, setStats] = (0, import_react.useState)();
106
+ const [items, setItems] = (0, import_react.useState)([]);
107
+ const [total, setTotal] = (0, import_react.useState)(0);
108
+ const [query, setQuery] = (0, import_react.useState)("");
109
+ const [filter, setFilter] = (0, import_react.useState)({});
110
+ const [selected, setSelected] = (0, import_react.useState)();
111
+ const [detail, setDetail] = (0, import_react.useState)();
112
+ const [anchor, setAnchor] = (0, import_react.useState)();
113
+ const [editor, setEditor] = (0, import_react.useState)();
114
+ const [jobs, setJobs] = (0, import_react.useState)([]);
115
+ const [showJobs, setShowJobs] = (0, import_react.useState)(false);
116
+ const [showInfo, setShowInfo] = (0, import_react.useState)(false);
117
+ const [error, setError] = (0, import_react.useState)("");
118
+ const [toast, setToast] = (0, import_react.useState)("");
119
+ const [loading, setLoading] = (0, import_react.useState)(true);
120
+ const [detailLoading, setDetailLoading] = (0, import_react.useState)(false);
121
+ const [revision, setRevision] = (0, import_react.useState)(0);
122
+ const [limit, setLimit] = (0, import_react.useState)(40);
123
+ const searchRef = (0, import_react.useRef)(null);
124
+ const detailRef = (0, import_react.useRef)(null);
125
+ const refresh = (0, import_react.useCallback)(() => setRevision((v) => v + 1), []);
126
+ const notify = (message) => setToast(message);
127
+ const chooseFilter = (next) => {
128
+ setFilter(next);
129
+ setLimit(40);
130
+ setSelected(void 0);
131
+ setAnchor(void 0);
132
+ setDetail(void 0);
133
+ };
134
+ const refreshMeta = (0, import_react.useCallback)(async () => {
135
+ const [s, j] = await Promise.all([api("/stats"), api("/jobs")]);
136
+ setStats(s);
137
+ setJobs(j);
138
+ }, []);
139
+ (0, import_react.useEffect)(() => {
140
+ void refreshMeta().catch((e) => setError(e.message));
141
+ }, [revision, refreshMeta]);
142
+ (0, import_react.useEffect)(() => {
143
+ const controller = new AbortController();
144
+ const timer = setTimeout(() => {
145
+ setLoading(true);
146
+ const params = new URLSearchParams({ query, limit: String(limit) });
147
+ for (const [key, value] of Object.entries(filter)) if (value) params.set(key, value);
148
+ api(`/materials?${params}`, { signal: controller.signal }).then((result) => {
149
+ setItems(result.items);
150
+ setTotal(result.total);
151
+ }).catch((e) => {
152
+ if (e.name !== "AbortError") setError(e.message);
153
+ }).finally(() => {
154
+ if (!controller.signal.aborted) setLoading(false);
155
+ });
156
+ }, query ? 180 : 0);
157
+ return () => {
158
+ clearTimeout(timer);
159
+ controller.abort();
160
+ };
161
+ }, [query, filter, revision, limit]);
162
+ (0, import_react.useEffect)(() => {
163
+ if (!selected) {
164
+ setDetail(void 0);
165
+ return;
166
+ }
167
+ const controller = new AbortController();
168
+ setDetailLoading(true);
169
+ setDetail(void 0);
170
+ api(`/materials/${selected}`, { signal: controller.signal }).then(setDetail).catch((e) => {
171
+ if (e.name !== "AbortError") setError(e.message);
172
+ }).finally(() => {
173
+ if (!controller.signal.aborted) setDetailLoading(false);
174
+ });
175
+ return () => controller.abort();
176
+ }, [selected, revision]);
177
+ (0, import_react.useEffect)(() => {
178
+ if (!detail || !anchor) return;
179
+ const element = Array.from(detailRef.current?.querySelectorAll("[data-segment-id]") || []).find((el) => el.dataset.segmentId === anchor);
180
+ element?.scrollIntoView({ block: "center" });
181
+ }, [detail, anchor]);
182
+ const pending = jobs.filter((j) => ["queued", "running"].includes(j.status)).length;
183
+ (0, import_react.useEffect)(() => {
184
+ if (!pending) return;
185
+ const interval = setInterval(refresh, 2500);
186
+ return () => clearInterval(interval);
187
+ }, [pending, refresh]);
188
+ (0, import_react.useEffect)(() => {
189
+ if (!toast) return;
190
+ const timer = setTimeout(() => setToast(""), 3500);
191
+ return () => clearTimeout(timer);
192
+ }, [toast]);
193
+ (0, import_react.useEffect)(() => {
194
+ const listener = (event) => {
195
+ if ((event.ctrlKey || event.metaKey) && event.key === "k") {
196
+ event.preventDefault();
197
+ searchRef.current?.focus();
198
+ }
199
+ };
200
+ window.addEventListener("keydown", listener);
201
+ return () => window.removeEventListener("keydown", listener);
202
+ }, []);
203
+ async function copy(text) {
204
+ try {
205
+ await navigator.clipboard.writeText(text);
206
+ notify("\u5F15\u7528\u5DF2\u590D\u5236");
207
+ } catch {
208
+ setError("\u526A\u8D34\u677F\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4ECE\u8D44\u6599\u8BE6\u60C5\u624B\u52A8\u590D\u5236\u8D44\u6599 ID");
209
+ }
210
+ }
211
+ const currentTitle = filter.category || filter.collection || (filter.tag ? `\u6807\u7B7E \xB7 ${filter.tag}` : filter.kind === "note" ? "\u77E5\u8BC6\u7B14\u8BB0" : "\u5168\u90E8\u8D44\u6599");
212
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-app", children: [
213
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("aside", { className: "kl-nav", children: [
214
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-brand", children: [
215
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-mark", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "library", size: 24 }) }),
216
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
217
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u62FE\u9875" }),
218
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u672C\u5730\u8D44\u6599\u5E93" })
219
+ ] }),
220
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-version", children: "01" })
221
+ ] }),
222
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-primary kl-add", onClick: () => setEditor({ mode: "capture" }), children: [
223
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "plus", size: 18 }),
224
+ "\u6536\u96C6\u8D44\u6599"
225
+ ] }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("nav", { "aria-label": "\u8D44\u6599\u5BFC\u822A", children: [
227
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: !Object.values(filter).some(Boolean) ? "active" : "", onClick: () => chooseFilter({}), children: [
228
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "library", size: 18 }),
229
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5168\u90E8\u8D44\u6599" }),
230
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: stats?.total ?? "\u2014" })
231
+ ] }),
232
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: filter.category === "\u6536\u4EF6\u7BB1" ? "active" : "", onClick: () => chooseFilter({ category: "\u6536\u4EF6\u7BB1" }), children: [
233
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "inbox", size: 18 }),
234
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6536\u4EF6\u7BB1" }),
235
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: stats?.inbox ?? "\u2014" })
236
+ ] }),
237
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: filter.kind === "note" ? "active" : "", onClick: () => chooseFilter({ kind: "note" }), children: [
238
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "note", size: 18 }),
239
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u77E5\u8BC6\u7B14\u8BB0" }),
240
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: stats?.notes ?? "\u2014" })
241
+ ] })
242
+ ] }),
243
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-section", children: [
244
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-label", children: [
245
+ "\u5206\u7C7B ",
246
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6309\u4E3B\u9898\u5F52\u6863" })
247
+ ] }),
248
+ stats?.categories.filter((c) => c.name !== "\u6536\u4EF6\u7BB1").map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `kl-nav-row ${filter.category === c.name ? "active" : ""}`, onClick: () => chooseFilter({ category: c.name }), children: [
249
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "folder", size: 16 }),
250
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { title: c.name, children: c.name }),
251
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: c.count })
252
+ ] }, c.name)),
253
+ !stats?.categories.some((c) => c.name !== "\u6536\u4EF6\u7BB1") && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "kl-nav-hint", children: [
254
+ "\u6536\u96C6\u65F6\u586B\u5199\u5206\u7C7B\uFF0C",
255
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("br", {}),
256
+ "\u5728\u8FD9\u91CC\u627E\u5230\u5B83\u4EEC\u3002"
257
+ ] })
258
+ ] }),
259
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-section", children: [
260
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-label", children: [
261
+ "\u4E13\u9898 ",
262
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u56F4\u7ED5\u4E00\u4E2A\u95EE\u9898" })
263
+ ] }),
264
+ stats?.collections.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `kl-nav-row ${filter.collection === c.name ? "active" : ""}`, onClick: () => chooseFilter({ collection: c.name }), children: [
265
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-collection-dot" }),
266
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: c.name }),
267
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: c.count })
268
+ ] }, c.name)),
269
+ !stats?.collections.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "kl-nav-hint", children: "\u628A\u4E0D\u540C\u6765\u6E90\u653E\u8FDB\u540C\u4E00\u4E13\u9898\u3002" })
270
+ ] }),
271
+ !!stats?.tags.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-section", children: [
272
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-nav-label", children: "\u6807\u7B7E" }),
273
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-tag-cloud", children: stats.tags.slice(0, 15).map((tag) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: filter.tag === tag.name ? "active" : "", onClick: () => chooseFilter({ tag: tag.name }), children: [
274
+ "#",
275
+ tag.name
276
+ ] }, tag.name)) })
277
+ ] }),
278
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-bottom", children: [
279
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { onClick: () => setShowInfo(true), children: [
280
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-live-dot" }),
281
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u4FDD\u5B58\u5728\u8FD9\u53F0\u7535\u8111" }),
282
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "settings", size: 16 })
283
+ ] }),
284
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u6765\u6E90\u53EF\u8FFD\u6EAF \xB7 \u5185\u5BB9\u53EF\u5E26\u8D70" })
285
+ ] })
286
+ ] }),
287
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("main", { className: "kl-workspace", children: [
288
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "kl-header", children: [
289
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
290
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-eyebrow", children: "COLLECT / CONNECT / UNDERSTAND" }),
291
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: currentTitle }),
292
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u7559\u4F4F\u503C\u5F97\u518D\u8BFB\u7684\u5185\u5BB9\uFF0C\u8BA9\u6BCF\u4E00\u6B21\u601D\u8003\u90FD\u6709\u51FA\u5904\u3002" })
293
+ ] }),
294
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-secondary", onClick: () => setEditor({ mode: "note" }), children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "note", size: 17 }),
296
+ "\u5199\u7B14\u8BB0"
297
+ ] })
298
+ ] }),
299
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-toolbar", children: [
300
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "kl-search", children: [
301
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "search", size: 19 }),
302
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { ref: searchRef, "aria-label": "\u641C\u7D22\u8D44\u6599", placeholder: "\u641C\u7D22\u6B63\u6587\u3001\u6807\u9898\u3001\u6807\u7B7E\u2026", value: query, onChange: (e) => {
303
+ setQuery(e.target.value);
304
+ setLimit(40);
305
+ } }),
306
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("kbd", { children: "Ctrl K" })
307
+ ] }),
308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `kl-job-button ${pending ? "has-jobs" : ""}`, onClick: () => setShowJobs(true), children: [
309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "clock", size: 17 }),
310
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: pending ? `${pending} \u9879\u5904\u7406\u4E2D` : "\u91C7\u96C6\u4EFB\u52A1" }),
311
+ jobs.some((j) => j.status === "failed") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {})
312
+ ] })
313
+ ] }),
314
+ !!error && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-error", role: "alert", children: [
315
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: error }),
316
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-label": "\u5173\u95ED\u9519\u8BEF", onClick: () => setError(""), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", size: 16 }) })
317
+ ] }),
318
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-filterbar", children: [
319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
320
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: total }),
321
+ " \u4EFD\u8D44\u6599",
322
+ query && ` \xB7 \u201C${query}\u201D`
323
+ ] }),
324
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
325
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { "aria-label": "\u6309\u7C7B\u578B\u7B5B\u9009", value: filter.kind || "", onChange: (e) => {
326
+ setFilter({ ...filter, kind: e.target.value || void 0 });
327
+ setLimit(40);
328
+ }, children: [
329
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\u6240\u6709\u7C7B\u578B" }),
330
+ Object.entries(kinds).map(([value, kind]) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value, children: kind.label }, value))
331
+ ] }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-sort-label", children: "\u6700\u8FD1\u66F4\u65B0 \u2193" })
333
+ ] })
334
+ ] }),
335
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `kl-body ${detail || detailLoading ? "with-detail" : ""}`, children: [
336
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "kl-list", "aria-label": "\u8D44\u6599\u5217\u8868", "aria-busy": loading, children: [
337
+ loading && !items.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty", children: [
338
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-spinner" }),
339
+ "\u6B63\u5728\u8BFB\u53D6\u8D44\u6599\u5E93\u2026"
340
+ ] }) : !items.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty", children: [
341
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty-art", children: [
342
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
343
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file", size: 46 }),
344
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {})
345
+ ] }),
346
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: query || Object.values(filter).some(Boolean) ? "\u8FD9\u91CC\u8FD8\u6CA1\u6709\u5339\u914D\u7684\u8D44\u6599" : "\u4ECE\u7B2C\u4E00\u4EFD\u503C\u5F97\u4FDD\u5B58\u7684\u8D44\u6599\u5F00\u59CB" }),
347
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: query ? "\u8BD5\u8BD5\u66F4\u77ED\u7684\u5173\u952E\u8BCD\uFF0C\u6216\u5207\u6362\u5206\u7C7B\u3002" : "\u4E00\u7BC7\u7F51\u9875\u3001\u4E00\u6BB5\u6458\u5F55\uFF0C\u6216\u4E00\u4EFD\u89C6\u9891\u5B57\u5E55\u3002" }),
348
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-secondary", onClick: () => query || Object.values(filter).some(Boolean) ? (setQuery(""), chooseFilter({})) : setEditor({ mode: "capture" }), children: [
349
+ query || Object.values(filter).some(Boolean) ? "\u67E5\u770B\u5168\u90E8\u8D44\u6599" : "\u6536\u96C6\u7B2C\u4E00\u4EFD\u8D44\u6599",
350
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 16 })
351
+ ] })
352
+ ] }) : items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `kl-item ${selected === item.id ? "selected" : ""}`, onClick: () => {
353
+ setAnchor(void 0);
354
+ setSelected(item.id);
355
+ }, children: [
356
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-item-top", children: [
357
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `kl-type kl-type-${item.kind}`, children: [
358
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: kinds[item.kind].icon, size: 15 }),
359
+ kinds[item.kind].label
360
+ ] }),
361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { children: date(item.createdAt) })
362
+ ] }),
363
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: item.title }),
364
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: item.excerpt || item.extraction }),
365
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-item-bottom", children: [
366
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "kl-category", children: [
367
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "folder", size: 13 }),
368
+ item.category
369
+ ] }),
370
+ item.tags.slice(0, 2).map((tag) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-chip", children: tag }, tag)),
371
+ item.status === "stored" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-stored", children: "\u4EC5\u5F52\u6863" }),
372
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 15 })
373
+ ] })
374
+ ] }, item.id)),
375
+ items.length < total && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "kl-load-more", onClick: () => setLimit((v) => Math.min(100, v + 40)), disabled: limit >= 100, children: limit >= 100 ? "\u8BF7\u7F29\u5C0F\u641C\u7D22\u8303\u56F4\uFF08\u6700\u591A\u663E\u793A 100 \u6761\uFF09" : "\u52A0\u8F7D\u66F4\u591A" })
376
+ ] }),
377
+ !selected && !!items.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("aside", { className: "kl-reading-placeholder", children: [
378
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-placeholder-number", children: "\u62FE / \u9875" }),
379
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("h2", { children: [
380
+ "\u6536\u96C6\u4E4B\u540E\uFF0C",
381
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("br", {}),
382
+ "\u7ED9\u77E5\u8BC6\u4E00\u70B9\u751F\u957F\u7684\u7A7A\u95F4\u3002"
383
+ ] }),
384
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { children: [
385
+ "\u9009\u62E9\u4E00\u4EFD\u8D44\u6599\u5F00\u59CB\u9605\u8BFB\u3002",
386
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("br", {}),
387
+ "\u6458\u5F55\u3001\u5173\u8054\uFF0C\u518D\u4EA4\u7ED9 Agent \u6DF1\u5165\u5206\u6790\u3002"
388
+ ] }),
389
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
390
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
391
+ stats?.ready ?? 0,
392
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u53EF\u68C0\u7D22\u8D44\u6599" })
393
+ ] }),
394
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
395
+ stats?.notes ?? 0,
396
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u77E5\u8BC6\u7B14\u8BB0" })
397
+ ] })
398
+ ] })
399
+ ] }),
400
+ selected && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "kl-detail", "aria-label": "\u8D44\u6599\u8BE6\u60C5", ref: detailRef, children: [
401
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-detail-toolbar", children: [
402
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-back", onClick: () => {
403
+ setSelected(void 0);
404
+ setDetail(void 0);
405
+ }, children: [
406
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", size: 18 }),
407
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5173\u95ED\u9605\u8BFB" })
408
+ ] }),
409
+ detail && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
410
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { title: "\u590D\u5236\u8D44\u6599\u5F15\u7528", "aria-label": "\u590D\u5236\u8D44\u6599\u5F15\u7528", onClick: () => void copy(`library://${detail.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "copy", size: 17 }) }),
411
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { title: "\u5BFC\u51FA Markdown", "aria-label": "\u5BFC\u51FA Markdown", href: `${API}/materials/${detail.id}/export`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "download", size: 17 }) }),
412
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => setEditor({ mode: "edit", source: detail }), children: "\u7F16\u8F91\u4FE1\u606F" })
413
+ ] })
414
+ ] }),
415
+ detailLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty", children: [
416
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-spinner" }),
417
+ "\u8BFB\u53D6\u4E2D\u2026"
418
+ ] }) : detail && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
419
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-detail-kicker", children: [
420
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: kinds[detail.kind].label }),
421
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: detail.category })
422
+ ] }),
423
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: detail.title }),
424
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-source", children: [
425
+ detail.sourceUrl ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: detail.sourceUrl, target: "_blank", rel: "noreferrer", children: [
426
+ new URL(detail.sourceUrl).hostname,
427
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 12 })
428
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: detail.originalName || "\u672C\u5730\u6536\u96C6" }),
429
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: new Date(detail.createdAt).toLocaleDateString("zh-CN") }),
430
+ detail.author && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: detail.author })
431
+ ] }),
432
+ !!detail.tags.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-detail-tags", children: detail.tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "kl-chip", children: [
433
+ "#",
434
+ t
435
+ ] }, t)) }),
436
+ detail.sourceNote && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("aside", { className: "kl-source-note", children: detail.sourceNote }),
437
+ detail.status === "stored" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-notice", children: [
438
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file" }),
439
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
440
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u539F\u6587\u4EF6\u5DF2\u5B89\u5168\u5F52\u6863" }),
441
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: detail.extraction })
442
+ ] })
443
+ ] }),
444
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-content", children: detail.segments.map((segment) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `kl-segment ${anchor === segment.id ? "kl-cited" : ""}`, id: segment.id, "data-segment-id": segment.id, children: [
445
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-segment-line", children: [
446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: segment.startSeconds !== void 0 ? time(segment.startSeconds) : segment.id }),
447
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { title: "\u6458\u5F55\u4E3A\u7B14\u8BB0", "aria-label": `\u6458\u5F55 ${segment.id} \u4E3A\u7B14\u8BB0`, onClick: () => setEditor({ mode: "note", source: detail, segment }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "note", size: 14 }) }),
448
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { title: "\u590D\u5236\u6BB5\u843D\u5F15\u7528", "aria-label": `\u590D\u5236 ${segment.id} \u5F15\u7528`, onClick: () => void copy(`library://${detail.id}/${segment.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "copy", size: 14 }) })
449
+ ] }),
450
+ /^#{1,6}\s/.test(segment.text) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: segment.text.replace(/^#{1,6}\s+/, "") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: segment.text })
451
+ ] }, segment.id)) }),
452
+ !!detail.citations.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-references", children: [
453
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: "\u6765\u6E90\u5F15\u7528" }),
454
+ detail.citations.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { "aria-label": `\u67E5\u770B\u5F15\u7528 ${i + 1}`, onClick: () => {
455
+ setAnchor(c.segmentId);
456
+ setSelected(c.materialId);
457
+ }, children: [
458
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file", size: 15 }),
459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
460
+ c.materialId.slice(0, 15),
461
+ "\u2026",
462
+ c.segmentId ? ` / ${c.segmentId}` : ""
463
+ ] }),
464
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 14 })
465
+ ] }, i))
466
+ ] }),
467
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { className: "kl-detail-footer", children: [
468
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
469
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-live-dot" }),
470
+ detail.extraction
471
+ ] }),
472
+ detail.originalFile && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: `${API}/materials/${detail.id}/original`, children: [
473
+ "\u4E0B\u8F7D\u539F\u59CB\u6587\u4EF6",
474
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "download", size: 14 })
475
+ ] }),
476
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: detail.id })
477
+ ] })
478
+ ] })
479
+ ] })
480
+ ] })
481
+ ] }),
482
+ editor && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EditorDialog, { editor, categories: stats?.categories.map((c) => c.name) || [], onClose: () => setEditor(void 0), onSaved: (result) => {
483
+ setEditor(void 0);
484
+ refresh();
485
+ if (result.material) {
486
+ chooseFilter({});
487
+ setQuery("");
488
+ setSelected(result.material.id);
489
+ notify(result.duplicate ? "\u8D44\u6599\u5DF2\u5B58\u5728\uFF0C\u5DF2\u6253\u5F00\u539F\u8BB0\u5F55" : "\u5DF2\u4FDD\u5B58\u5230\u672C\u5730\u8D44\u6599\u5E93");
490
+ } else if (result.id) {
491
+ setSelected(result.id);
492
+ notify("\u8D44\u6599\u4FE1\u606F\u5DF2\u66F4\u65B0");
493
+ } else {
494
+ setShowJobs(true);
495
+ notify("\u7F51\u9875\u5DF2\u52A0\u5165\u91C7\u96C6\u961F\u5217");
496
+ }
497
+ } }),
498
+ showJobs && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dialog, { title: "\u91C7\u96C6\u4EFB\u52A1", description: "\u7F51\u9875\u5728\u540E\u53F0\u63D0\u53D6\u6B63\u6587\u3002\u5173\u95ED\u5E94\u7528\u540E\uFF0C\u4E0B\u6B21\u542F\u52A8\u4F1A\u6062\u590D\u672A\u5B8C\u6210\u4EFB\u52A1\u3002", onClose: () => setShowJobs(false), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-jobs", children: !jobs.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "kl-muted", children: "\u8FD8\u6CA1\u6709\u91C7\u96C6\u4EFB\u52A1\u3002\u6DFB\u52A0\u4E00\u4E2A\u7F51\u9875\u94FE\u63A5\u5F00\u59CB\u3002" }) : jobs.map((job) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-job", children: [
499
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `kl-job-status ${job.status}`, children: { queued: "\u6392\u961F\u4E2D", running: "\u63D0\u53D6\u4E2D", completed: "\u5DF2\u5B8C\u6210", failed: "\u5931\u8D25" }[job.status] }),
501
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { children: date(job.createdAt) })
502
+ ] }),
503
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: job.url }),
504
+ job.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: job.status === "failed" ? "alert" : void 0, children: job.error }),
505
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
506
+ job.materialId && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { onClick: () => {
507
+ setSelected(job.materialId);
508
+ setShowJobs(false);
509
+ refresh();
510
+ }, children: [
511
+ "\u67E5\u770B\u8D44\u6599 ",
512
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 14 })
513
+ ] }),
514
+ job.status === "failed" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => void post(`/jobs/${job.id}/retry`, {}).then(refresh).catch((e) => setError(e.message)), children: "\u91CD\u65B0\u91C7\u96C6" })
515
+ ] })
516
+ ] }, job.id)) }) }),
517
+ showInfo && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dialog, { title: "\u4F60\u7684\u8D44\u6599\uFF0C\u7531\u4F60\u4FDD\u7BA1", description: "\u5185\u5BB9\u4EE5\u666E\u901A\u6587\u4EF6\u4FDD\u5B58\uFF0C\u7D22\u5F15\u53EF\u4EE5\u91CD\u5EFA\u3002", onClose: () => setShowInfo(false), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-info", children: [
518
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "\u8D44\u6599\u5E93\u76EE\u5F55" }),
519
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: stats?.root }),
520
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u6BCF\u4EFD\u8D44\u6599\u4FDD\u7559\u539F\u59CB\u6587\u4EF6\u3001\u6B63\u6587\u3001\u5143\u6570\u636E\u548C\u5F15\u7528\u6BB5\u843D\u3002\u5206\u7C7B\u5BF9\u5E94\u672C\u5730\u6587\u4EF6\u5939\uFF0C\u63D2\u4EF6\u5378\u8F7D\u4E0D\u4F1A\u5220\u9664\u8FD9\u4E9B\u6587\u4EF6\u3002" }),
521
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u672C\u7248\u672C\u53EF\u63D0\u53D6\u6587\u7AE0\u6B63\u6587\u53CA\u5B57\u5E55\uFF1B\u97F3\u89C6\u9891\u3001PDF \u7B49\u683C\u5F0F\u53EF\u4EE5\u5F52\u6863\uFF0C\u81EA\u52A8\u8F6C\u5199\u548C OCR \u5C1A\u672A\u63A5\u5165\u3002" }),
522
+ stats?.warnings.map((w) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: "alert", children: w }, w)),
523
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "kl-secondary", onClick: () => void post("/rebuild", {}).then(() => {
524
+ refresh();
525
+ notify("\u7D22\u5F15\u5DF2\u91CD\u5EFA");
526
+ }).catch((e) => setError(e.message)), children: "\u4ECE\u8D44\u6599\u6587\u4EF6\u91CD\u5EFA\u7D22\u5F15" })
527
+ ] }) }),
528
+ toast && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-toast", role: "status", children: [
529
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "check", size: 17 }),
530
+ toast
531
+ ] })
532
+ ] });
533
+ }
534
+ function Dialog({ title, description, onClose, children }) {
535
+ const ref = (0, import_react.useRef)(null);
536
+ const closeRef = (0, import_react.useRef)(onClose);
537
+ closeRef.current = onClose;
538
+ (0, import_react.useEffect)(() => {
539
+ const previous = document.activeElement;
540
+ const timer = setTimeout(() => ref.current?.querySelector("input,textarea,button")?.focus(), 0);
541
+ const key = (event) => {
542
+ if (event.key === "Escape") closeRef.current();
543
+ if (event.key === "Tab") {
544
+ const elements = Array.from(ref.current?.querySelectorAll("button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select,a[href]") || []);
545
+ const first = elements[0], last = elements[elements.length - 1];
546
+ if (event.shiftKey && document.activeElement === first) {
547
+ event.preventDefault();
548
+ last?.focus();
549
+ }
550
+ if (!event.shiftKey && document.activeElement === last) {
551
+ event.preventDefault();
552
+ first?.focus();
553
+ }
554
+ }
555
+ };
556
+ document.addEventListener("keydown", key);
557
+ return () => {
558
+ clearTimeout(timer);
559
+ document.removeEventListener("keydown", key);
560
+ previous?.focus();
561
+ };
562
+ }, []);
563
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-modal-backdrop", onMouseDown: (event) => {
564
+ if (event.target === event.currentTarget) onClose();
565
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, ref, children: [
566
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
567
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
568
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: title }),
569
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description })
570
+ ] }),
571
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-label": "\u5173\u95ED\u5F39\u7A97", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close" }) })
572
+ ] }),
573
+ children
574
+ ] }) });
575
+ }
576
+ function EditorDialog({ editor, categories, onClose, onSaved }) {
577
+ const editing = editor.mode === "edit";
578
+ const note = editor.mode === "note";
579
+ const source = editor.source;
580
+ const [type, setType] = (0, import_react.useState)("url");
581
+ const [title, setTitle] = (0, import_react.useState)(editing ? source?.title || "" : note && source ? `${source.title} \xB7 \u6458\u5F55` : "");
582
+ const [content, setContent] = (0, import_react.useState)(editor.segment ? `> ${editor.segment.text}
583
+
584
+ ` : "");
585
+ const [category, setCategory] = (0, import_react.useState)(editing ? source?.category || "\u6536\u4EF6\u7BB1" : note ? "\u77E5\u8BC6\u7B14\u8BB0" : "\u6536\u4EF6\u7BB1");
586
+ const [tags, setTags] = (0, import_react.useState)(editing ? source?.tags.join("\uFF0C") || "" : "");
587
+ const [collection, setCollection] = (0, import_react.useState)(source?.collection || "");
588
+ const [sourceNote, setSourceNote] = (0, import_react.useState)(editing ? source?.sourceNote || "" : "");
589
+ const [file, setFile] = (0, import_react.useState)();
590
+ const [busy, setBusy] = (0, import_react.useState)(false);
591
+ const [error, setError] = (0, import_react.useState)("");
592
+ const citations = source && note ? [{ materialId: source.id, ...editor.segment ? { segmentId: editor.segment.id } : {} }] : [];
593
+ async function submit(event) {
594
+ event.preventDefault();
595
+ setError("");
596
+ setBusy(true);
597
+ try {
598
+ const data = { title, category, tags: splitTags(tags), collection, sourceNote };
599
+ let result;
600
+ if (editing) result = await post(`/materials/${source.id}`, data, "PATCH");
601
+ else if (note) result = await post("/notes", { ...data, content, citations });
602
+ else if (type === "file") {
603
+ if (!file) throw new Error("\u8BF7\u9009\u62E9\u4E00\u4E2A\u6587\u4EF6");
604
+ if (file.size > 64 * 1024 * 1024) throw new Error("\u6587\u4EF6\u8D85\u8FC7 64 MB\uFF0C\u8BF7\u5148\u62C6\u5206\u6216\u5BFC\u5165\u5B57\u5E55");
605
+ const base64 = await new Promise((resolve, reject) => {
606
+ const reader = new FileReader();
607
+ reader.onload = () => resolve(String(reader.result).split(",")[1]);
608
+ reader.onerror = () => reject(new Error("\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6"));
609
+ reader.readAsDataURL(file);
610
+ });
611
+ result = await post("/upload", { ...data, name: file.name, base64 });
612
+ } else result = await post("/capture", { ...data, type, content });
613
+ onSaved(result);
614
+ } catch (e) {
615
+ setError(e.message);
616
+ } finally {
617
+ setBusy(false);
618
+ }
619
+ }
620
+ const changeType = (value) => {
621
+ setType(value);
622
+ setContent("");
623
+ setError("");
624
+ };
625
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dialog, { title: editing ? "\u6574\u7406\u8D44\u6599" : note ? "\u5199\u4E00\u4EFD\u77E5\u8BC6\u7B14\u8BB0" : "\u6536\u96C6\u4E00\u4EFD\u8D44\u6599", description: editing ? "\u5206\u7C7B\u4F1A\u540C\u6B65\u5230\u672C\u5730\u6587\u4EF6\u5939\uFF0C\u539F\u6587\u548C\u5F15\u7528\u4FDD\u6301\u4E0D\u53D8\u3002" : note ? "\u5199\u4E0B\u7406\u89E3\uFF0C\u4E5F\u7559\u4E0B\u5B83\u7684\u6765\u6E90\u3002" : "\u5148\u6536\u96C6\uFF0C\u518D\u6162\u6162\u6574\u7406\u3002\u6240\u6709\u5185\u5BB9\u4FDD\u5B58\u5728\u4F60\u7684\u7535\u8111\u3002", onClose: () => {
626
+ if (!busy) onClose();
627
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { onSubmit: submit, className: "kl-editor", children: [
628
+ !editing && !note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-tabs", role: "tablist", "aria-label": "\u91C7\u96C6\u65B9\u5F0F", children: ["url", "text", "file"].map((value) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role: "tab", "aria-selected": type === value, className: type === value ? "active" : "", onClick: () => changeType(value), children: [
629
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: value === "url" ? "web" : value === "file" ? "upload" : "file", size: 17 }),
630
+ value === "url" ? "\u7F51\u9875\u94FE\u63A5" : value === "file" ? "\u672C\u5730\u6587\u4EF6" : "\u6587\u672C\u6458\u5F55"
631
+ ] }, value)) }),
632
+ !editing && !note && type === "url" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
633
+ "\u7F51\u9875\u5730\u5740",
634
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "url", required: true, placeholder: "https://\u2026", value: content, onChange: (e) => setContent(e.target.value) }),
635
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u652F\u6301\u53EF\u76F4\u63A5\u8BBF\u95EE\u7684\u6587\u7AE0\u7F51\u9875\u3002\u767B\u5F55\u9875\u6216\u52A8\u6001\u9875\u9762\u53EF\u590D\u5236\u6B63\u6587\u5BFC\u5165\u3002" })
636
+ ] }),
637
+ !editing && !note && type === "file" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "kl-upload", children: [
638
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "upload", size: 27 }),
639
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: file?.name || "\u9009\u62E9\u6216\u62D6\u5165\u6587\u4EF6" }),
640
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6587\u672C\u3001HTML\u3001SRT / VTT \u5B57\u5E55\u53CA\u5176\u4ED6\u6587\u4EF6 \xB7 \u6700\u5927 64 MB" }),
641
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { "aria-label": "\u9009\u62E9\u672C\u5730\u6587\u4EF6", type: "file", onChange: (e) => setFile(e.target.files?.[0]) }),
642
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u89C6\u9891\u548C PDF \u53EF\u5F52\u6863\uFF0C\u5F53\u524D\u7248\u672C\u4E0D\u4F1A\u81EA\u52A8\u8F6C\u5199\u6216 OCR\u3002" })
643
+ ] }),
644
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
645
+ "\u6807\u9898",
646
+ !editing && !note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
647
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { required: editing || note, value: title, onChange: (e) => setTitle(e.target.value), placeholder: type === "url" && !note ? "\u81EA\u52A8\u63D0\u53D6\u7F51\u9875\u6807\u9898\uFF0C\u4E5F\u53EF\u4EE5\u81EA\u5DF1\u586B\u5199" : "\u7ED9\u8FD9\u4EFD\u5185\u5BB9\u8D77\u4E2A\u540D\u5B57", maxLength: 300 })
648
+ ] }),
649
+ !editing && (note || type === "text") && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
650
+ note ? "\u7B14\u8BB0\u5185\u5BB9" : "\u6B63\u6587",
651
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { required: true, rows: 7, value: content, onChange: (e) => setContent(e.target.value), placeholder: note ? "\u8BB0\u5F55\u4F60\u7684\u7406\u89E3\u3001\u7ED3\u8BBA\u4E0E\u5C1A\u5F85\u9A8C\u8BC1\u7684\u95EE\u9898\u2026" : "\u7C98\u8D34\u60F3\u4FDD\u7559\u7684\u6587\u5B57\uFF0C\u652F\u6301 Markdown\u2026" })
652
+ ] }),
653
+ !!citations.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-citation-preview", children: [
654
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file", size: 16 }),
655
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
656
+ "\u5F15\u7528\uFF1A",
657
+ source.title,
658
+ editor.segment ? ` / ${editor.segment.id}` : ""
659
+ ] })
660
+ ] }),
661
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-form-grid", children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
663
+ "\u5206\u7C7B",
664
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { list: "kl-categories", value: category, onChange: (e) => setCategory(e.target.value), placeholder: "\u4F8B\u5982 \u6280\u672F/AI" }),
665
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("datalist", { id: "kl-categories", children: categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: c }, c)) })
666
+ ] }),
667
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
668
+ "\u4E13\u9898",
669
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
670
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: collection, onChange: (e) => setCollection(e.target.value), placeholder: "\u56F4\u7ED5\u4E00\u4E2A\u95EE\u9898\u7EC4\u7EC7\u8D44\u6599" })
671
+ ] })
672
+ ] }),
673
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
674
+ "\u6807\u7B7E",
675
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
676
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: tags, onChange: (e) => setTags(e.target.value), placeholder: "\u7528\u9017\u53F7\u5206\u9694\uFF0C\u4F8B\u5982\uFF1A\u5F85\u8BFB\uFF0CRAG\uFF0C\u5B9E\u8DF5" })
677
+ ] }),
678
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
679
+ "\u6765\u6E90\u5907\u6CE8",
680
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
681
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: sourceNote, onChange: (e) => setSourceNote(e.target.value), placeholder: "\u4E3A\u4EC0\u4E48\u503C\u5F97\u4FDD\u5B58\uFF0C\u6216\u8005\u5B83\u6765\u81EA\u54EA\u91CC" })
682
+ ] }),
683
+ error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-form-error", role: "alert", children: error }),
684
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { children: [
685
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
686
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-live-dot" }),
687
+ "\u4EC5\u4FDD\u5B58\u5728\u672C\u5730"
688
+ ] }),
689
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
690
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-primary", type: "submit", disabled: busy, children: [
691
+ busy ? "\u4FDD\u5B58\u4E2D\u2026" : editing ? "\u4FDD\u5B58\u4FEE\u6539" : note ? "\u4FDD\u5B58\u7B14\u8BB0" : type === "url" ? "\u5F00\u59CB\u91C7\u96C6" : "\u4FDD\u5B58\u8D44\u6599",
692
+ !busy && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 16 })
693
+ ] })
694
+ ] })
695
+ ] }) });
696
+ }
697
+
698
+ // src/ui/style.css
699
+ var style_default = ':root { font-synthesis: none; }\n.kl-app,.kl-app *,.kl-modal-backdrop * { box-sizing:border-box; }\n.kl-app { --kl-paper:#faf9f5;--kl-ink:#283a31;--kl-muted:#82887f;--kl-line:#e5e6df;--kl-green:#315b45;--kl-soft:#eaf0e7;--kl-serif:"Noto Serif SC","Source Han Serif SC","Songti SC","SimSun",serif; font-family:"PingFang SC","Microsoft YaHei","Segoe UI",sans-serif;color:var(--kl-ink);font-size:13px;display:flex;background:var(--kl-paper);height:100%;min-height:560px;width:100%;overflow:hidden; }\nbody:has(> #root) { margin:0; }\n#root>.kl-app { height:100dvh; }\n.kl-app button,.kl-app input,.kl-app textarea,.kl-app select { font:inherit; }\n.kl-app button { cursor:pointer;color:inherit; }\n.kl-app button:disabled { opacity:.5;cursor:wait; }\n.kl-app button,.kl-app a,.kl-app input,.kl-app textarea,.kl-app select { -webkit-tap-highlight-color:transparent; }\n.kl-app button:focus-visible,.kl-app a:focus-visible { outline:2px solid #5c886b;outline-offset:3px; }\n.kl-app input:focus,.kl-app textarea:focus,.kl-app select:focus { outline:2px solid #b2c6ae;outline-offset:1px; }\n.kl-app svg { flex-shrink:0; }\n.kl-primary,.kl-secondary { border-radius:7px;display:inline-flex;align-items:center;justify-content:center;gap:9px;padding:10px 15px;min-height:39px;transition:background .18s;white-space:nowrap; }\n.kl-app .kl-primary { color:#fff;background:#315b45;border:1px solid #315b45; }\n.kl-app .kl-primary:hover { background:#244c37; }\n.kl-secondary { background:transparent;border:1px solid #d7dcd3; }\n.kl-secondary:hover { background:#eef1e9; }\n.kl-nav { width:218px;flex-shrink:0;border-right:1px solid var(--kl-line);padding:28px 18px 18px;background:#f2f3ed;display:flex;flex-direction:column;overflow-y:auto; }\n.kl-brand { display:flex;gap:11px;align-items:center;padding:0 6px 28px; }\n.kl-mark { width:39px;height:42px;color:#315b45;display:grid;place-items:center;border:1px solid #9fae96;border-radius:9px 9px 2px 2px; }\n.kl-brand strong { display:block;font-family:var(--kl-serif);font-size:24px;letter-spacing:4px;font-weight:600;line-height:1.2; }\n.kl-brand div>span { font-size:10px;display:block;letter-spacing:2px;color:var(--kl-muted);margin-top:5px; }\n.kl-version { margin-left:auto;color:#a2aa99;font:10px Georgia,serif;align-self:flex-start;padding-top:5px; }\n.kl-add { width:100%;margin-bottom:25px; }\n.kl-nav nav { display:grid;gap:5px; }\n.kl-nav nav>button,.kl-nav-row { width:100%;display:flex;align-items:center;gap:10px;background:none;border:0;border-radius:6px;padding:10px;text-align:left;min-width:0; }\n.kl-nav button.active { background:#e1e8dc;color:#254b35; }\n.kl-nav nav>button:hover,.kl-nav-row:hover { background:#e9ede3; }\n.kl-nav nav small,.kl-nav-row small { margin-left:auto;color:#8b9285;font-size:11px; }\n.kl-nav-row>span:not(.kl-collection-dot) { overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }\n.kl-nav-section { margin-top:27px; }\n.kl-nav-label { padding:0 10px 9px;color:#5d6c5b;font-size:11px;letter-spacing:1px;display:flex;justify-content:space-between; }\n.kl-nav-label>span { font-size:9px;letter-spacing:0;color:#9aa293; }\n.kl-nav-hint { color:#9aa092;font-size:11px;line-height:1.9;padding:0 10px;margin:4px 0; }\n.kl-collection-dot { width:7px;height:7px;border-radius:50%;border:1px solid #7e9177;flex-shrink:0;margin:0 4px; }\n.kl-tag-cloud { display:flex;flex-wrap:wrap;gap:5px;padding:3px 8px; }\n.kl-tag-cloud button { padding:4px 6px;border:0;background:transparent;color:#7d8775;font-size:11px;border-radius:4px; }\n.kl-nav-bottom { margin-top:auto;padding-top:35px; }\n.kl-nav-bottom>button { display:flex;align-items:center;gap:8px;border:0;background:transparent;width:100%;padding:9px 6px;font-size:11px; }\n.kl-nav-bottom svg { margin-left:auto; }\n.kl-nav-bottom p { color:#a0a696;font-size:9px;letter-spacing:1px;margin:4px 6px; }\n.kl-live-dot { width:6px;height:6px;border-radius:50%;background:#6a8f60;display:inline-block;flex-shrink:0; }\n.kl-workspace { min-width:0;flex:1;display:flex;flex-direction:column; }\n.kl-header { padding:36px 38px 26px;display:flex;align-items:center;justify-content:space-between;gap:20px; }\n.kl-eyebrow { font-size:9px;letter-spacing:2.4px;color:#8b957f;margin-bottom:12px; }\n.kl-header h1 { font-family:var(--kl-serif);font-size:30px;font-weight:500;letter-spacing:2px;margin:0 0 10px;line-height:1.35; }\n.kl-header p { font-size:12px;color:#8c9187;margin:0; }\n.kl-toolbar { padding:0 38px 22px;display:flex;gap:15px;align-items:center; }\n.kl-search { display:flex;align-items:center;gap:11px;flex:1;min-width:0;background:#fff;border:1px solid #dde1d6;border-radius:7px;padding:11px 13px;color:#88937e; }\n.kl-search input { border:0;background:none;flex:1;min-width:0;color:#344732;font-size:12px; }\n.kl-search input:focus { outline:0; }\n.kl-search:focus-within { border-color:#709170;box-shadow:0 0 0 2px #dce7d8; }\n.kl-search kbd { font:9px "Segoe UI",sans-serif;color:#9ba291;border:1px solid #e8ebe2;border-radius:3px;padding:2px 4px; }\n.kl-job-button { border:0;background:none;display:flex;align-items:center;gap:7px;font-size:11px!important;color:#77836d!important;padding:8px 0 8px 5px;white-space:nowrap; }\n.kl-job-button i { height:5px;width:5px;background:#b5844d;border-radius:50%; }\n.kl-job-button.has-jobs { color:#315b45!important; }\n.kl-filterbar { display:flex;align-items:center;justify-content:space-between;padding:13px 38px;border-top:1px solid var(--kl-line);border-bottom:1px solid var(--kl-line);color:#939a8c;font-size:11px; }\n.kl-filterbar b { font-weight:500;color:#456141; }\n.kl-filterbar>div { display:flex;align-items:center;gap:18px; }\n.kl-filterbar select { border:0;background:transparent;color:#77806f;max-width:110px;font-size:11px; }\n.kl-sort-label { color:#969e8f; }\n.kl-body { display:flex;flex:1;min-height:0;overflow:hidden; }\n.kl-list { flex:1;min-width:0;overflow-y:auto;padding:0 26px; }\n.kl-body.with-detail .kl-list { flex:0 0 36%;padding:0 18px;min-width:250px; }\n.kl-item { width:100%;display:block;text-align:left;padding:23px 13px;border:0;border-bottom:1px solid var(--kl-line);background:transparent;position:relative; }\n.kl-item:hover { background:#f2f4ed; }\n.kl-item.selected { background:#edf2e8; }\n.kl-item.selected:before { content:"";position:absolute;left:0;top:22px;bottom:22px;width:3px;background:#4d7350;border-radius:0 2px 2px 0; }\n.kl-item-top { display:flex;justify-content:space-between;align-items:center;margin-bottom:12px; }\n.kl-type { display:inline-flex;gap:5px;align-items:center;font-size:10px;color:#86907c; }\n.kl-type-note { color:#aa8654; }\n.kl-type-web { color:#6c8d79; }\n.kl-type-transcript,.kl-type-video { color:#8b819f; }\n.kl-item time { font:10px "Segoe UI",sans-serif;color:#a3a89a; }\n.kl-item h2 { font-size:15px;font-weight:500;line-height:1.6;margin:0 0 8px;color:#344631; }\n.kl-item>p { font-size:11px;line-height:1.9;color:#93988b;margin:0 0 14px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere; }\n.kl-item-bottom { display:flex;align-items:center;gap:6px;flex-wrap:wrap; }\n.kl-category { color:#88927d;font-size:10px;display:flex;align-items:center;gap:4px;margin-right:3px;max-width:55%;overflow:hidden;white-space:nowrap; }\n.kl-chip { font-size:9px;padding:3px 6px;background:#edf0e7;color:#7c896e;border-radius:3px;white-space:nowrap; }\n.kl-item.selected .kl-chip { background:#e3eadd; }\n.kl-item-bottom>svg { margin-left:auto;color:#abb39f; }\n.kl-stored { color:#a88759;font-size:9px; }\n.kl-reading-placeholder { flex:0 0 44%;border-left:1px solid var(--kl-line);padding:70px 40px 35px;background:#f6f6f0;display:flex;flex-direction:column;justify-content:center; }\n.kl-placeholder-number { font-family:var(--kl-serif);font-size:12px;letter-spacing:4px;color:#9fae94;margin-bottom:40px; }\n.kl-reading-placeholder h2 { font-family:var(--kl-serif);font-size:25px;font-weight:400;line-height:1.8;letter-spacing:1px;margin:0 0 19px; }\n.kl-reading-placeholder>p { color:#8c9681;line-height:2;font-size:11px; }\n.kl-reading-placeholder>div:last-child { display:flex;gap:50px;border-top:1px solid #e1e5d8;padding-top:25px;margin-top:45px; }\n.kl-reading-placeholder>div:last-child span { font:30px Georgia,serif;color:#668061; }\n.kl-reading-placeholder small { display:block;font:10px "Microsoft YaHei",sans-serif;color:#9ca58f;margin-top:9px; }\n.kl-detail { flex:1;min-width:0;overflow-y:auto;border-left:1px solid var(--kl-line);background:#fffefa; }\n.kl-detail-toolbar { display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #eceee5;padding:12px 24px;position:sticky;top:0;background:#fffefa;z-index:1; }\n.kl-detail-toolbar>div { display:flex;align-items:center;gap:13px; }\n.kl-detail-toolbar button,.kl-detail-toolbar a { display:flex;align-items:center;gap:5px;background:none;border:0;padding:4px;color:#88937d;text-decoration:none;font-size:10px; }\n.kl-detail article { padding:32px 36px 40px; }\n.kl-detail-kicker { display:flex;gap:10px;font-size:10px;color:#7c8b6d; }\n.kl-detail-kicker span+span:before { content:"/";margin-right:10px;color:#b4bda9; }\n.kl-detail article>h2 { font-family:var(--kl-serif);font-size:25px;font-weight:500;line-height:1.6;letter-spacing:.5px;margin:15px 0;overflow-wrap:anywhere; }\n.kl-source { display:flex;flex-wrap:wrap;align-items:center;gap:13px;color:#9ca58e;font-size:10px; }\n.kl-source a { color:#778b66;display:flex;align-items:center;gap:4px;text-decoration:none; }\n.kl-detail-tags { display:flex;gap:6px;margin-top:16px; }\n.kl-source-note { border-left:2px solid #bacaa9;padding:9px 12px;font-size:11px;line-height:1.8;color:#869677;background:#f7f8f2;margin:22px 0; }\n.kl-content { margin-top:28px; }\n.kl-segment { margin-bottom:20px; }\n.kl-segment.kl-cited { background:#f0f4e7;box-shadow:0 0 0 10px #f0f4e7;border-radius:2px; }\n.kl-segment-line { display:flex;align-items:center;gap:9px;margin-bottom:5px;font:9px "Segoe UI",sans-serif;color:#b0b7a6; }\n.kl-segment-line>span { margin-right:auto; }\n.kl-segment-line button { background:none;border:0;color:#a4af98;padding:2px;opacity:.3; }\n.kl-segment:hover button,.kl-segment:focus-within button { opacity:1; }\n.kl-segment p { white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:2.05;margin:0;color:#59644f; }\n.kl-segment h3 { font-size:17px;line-height:1.8;margin:0;font-weight:500;color:#3f5538; }\n.kl-detail-footer { margin-top:40px;padding-top:18px;border-top:1px solid #e8ecdf;font-size:9px;color:#a0aa92; }\n.kl-detail-footer>div { display:flex;gap:6px;align-items:center;line-height:1.9; }\n.kl-detail-footer a { display:flex;align-items:center;gap:6px;color:#7d8f6a;text-decoration:none;margin:12px 0; }\n.kl-detail-footer code { display:block;font-size:8px;margin-top:12px;overflow-wrap:anywhere; }\n.kl-empty { min-height:350px;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:10px;padding:40px 20px;text-align:center;color:#8d9983; }\n.kl-empty-art { display:flex;align-items:center;gap:12px;margin-bottom:20px;position:relative;height:80px;color:#819675; }\n.kl-empty-art>svg { width:66px;height:80px;padding:14px 8px;border:1px solid #bdcbb0;background:#f5f8ee;transform:rotate(-5deg); }\n.kl-empty-art>span { width:38px;height:56px;border:1px solid #d3dcc9;background:#f4f6ee;transform:rotate(12deg); }\n.kl-empty-art>span:first-child { transform:rotate(-14deg); }\n.kl-empty h2 { font:20px var(--kl-serif);font-weight:400;color:#627557;letter-spacing:1px;margin:8px 0; }\n.kl-empty p { font-size:12px;margin:0 0 15px;line-height:1.9; }\n.kl-empty .kl-secondary { font-size:11px; }\n.kl-load-more { width:100%;padding:18px;border:0;background:transparent;font-size:11px;color:#79906a; }\n.kl-notice { display:flex;gap:12px;padding:18px;background:#f4f2e9;margin-top:25px;border-radius:5px;color:#8d805e; }\n.kl-notice strong { font-size:12px;font-weight:500; }\n.kl-notice p { font-size:11px;line-height:1.9;margin:7px 0 0; }\n.kl-references { background:#f1f5eb;padding:17px;border-radius:5px;margin-top:24px; }\n.kl-references h3 { font-size:11px;color:#718561;margin:0 0 12px; }\n.kl-references button { display:flex;gap:7px;align-items:center;border:0;background:none;font-size:10px;color:#7b8f6b;padding:6px 0;width:100%; }\n.kl-references button>svg:last-child { margin-left:auto; }\n.kl-modal-backdrop { position:fixed;inset:0;background:#1c2a2355;backdrop-filter:blur(3px);z-index:1000;display:flex;align-items:center;justify-content:center;padding:24px; }\n.kl-dialog { background:#fffefa;color:#344631;width:580px;max-width:100%;max-height:90dvh;overflow:auto;border-radius:12px;box-shadow:0 20px 90px #15241633;animation:kl-enter .18s ease-out; }\n.kl-dialog>header { padding:25px 28px 20px;border-bottom:1px solid #e9ecdf;display:flex;justify-content:space-between;align-items:flex-start;gap:18px; }\n.kl-dialog>header h2 { font:24px var(--kl-serif);margin:0 0 9px;letter-spacing:1px; }\n.kl-dialog>header p { color:#97a08b;font-size:11px;line-height:1.8;margin:0; }\n.kl-dialog>header>button { border:0;background:none;color:#9eaa92;padding:2px; }\n.kl-editor { padding:22px 28px 0; }\n.kl-tabs { display:flex;background:#f0f3e9;border-radius:6px;padding:4px;gap:5px;margin-bottom:22px; }\n.kl-tabs button { flex:1;display:flex;align-items:center;justify-content:center;gap:7px;background:none;border:0;color:#93a082;border-radius:4px;padding:9px;font-size:12px; }\n.kl-tabs button.active { background:#fffefa;box-shadow:0 1px 4px #536b3320;color:#3f6332; }\n.kl-editor label { display:flex;flex-direction:column;gap:7px;font-size:11px;color:#6e805d;margin-bottom:16px;position:relative; }\n.kl-editor label>em { position:absolute;right:0;top:0;font-size:9px;color:#a1ac94;font-style:normal; }\n.kl-editor input,.kl-editor textarea { width:100%;background:#fffefa;border:1px solid #dce3d3;border-radius:5px;padding:10px 11px;color:#4b603e;font-size:12px; }\n.kl-editor input::placeholder,.kl-editor textarea::placeholder { color:#b0b9a5; }\n.kl-editor textarea { resize:vertical;line-height:1.8;min-height:120px;max-height:280px; }\n.kl-editor label>small { color:#a0ac91;font-size:10px;line-height:1.7; }\n.kl-form-grid { display:grid;grid-template-columns:1fr 1fr;gap:16px; }\n.kl-editor footer { display:flex;align-items:center;gap:9px;margin:20px -28px 0;padding:17px 28px;border-top:1px solid #e7ecdf; }\n.kl-editor footer>span { display:flex;align-items:center;gap:6px;font-size:10px;color:#9ba98c;margin-right:auto; }\n.kl-editor footer button { font-size:12px; }\n.kl-editor .kl-upload { align-items:center;gap:12px;position:relative;border:1px dashed #bacba9;background:#f5f8f0;padding:22px 16px;border-radius:6px;text-align:center; }\n.kl-upload>strong { font-size:12px;font-weight:400; }\n.kl-upload>span { font-size:10px;color:#93a280; }\n.kl-upload input { position:absolute;inset:0;opacity:0;cursor:pointer; }\n.kl-citation-preview { display:flex;gap:8px;align-items:center;background:#edf4e6;font-size:10px;color:#718a60;padding:10px;border-radius:5px;margin-bottom:18px; }\n.kl-jobs,.kl-info { padding:24px 28px; }\n.kl-muted { color:#97a58b;font-size:12px; }\n.kl-job { border-bottom:1px solid #e6ecdc;padding:0 0 18px;margin-bottom:18px; }\n.kl-job>div { display:flex;justify-content:space-between;align-items:center; }\n.kl-job time { font-size:10px;color:#a2ad95; }\n.kl-job>strong { display:block;overflow-wrap:anywhere;font-size:12px;font-weight:400;margin:12px 0;color:#7f8f6d; }\n.kl-job>p { font-size:11px;color:#ac6e51;line-height:1.8; }\n.kl-job button { display:flex;align-items:center;gap:4px;color:#6b8756;font-size:11px;border:0;background:none;padding:4px 0; }\n.kl-job-status { font-size:10px;border-radius:3px;padding:4px 7px;background:#eef2e6;color:#7f9568; }\n.kl-job-status.failed { background:#fbede4;color:#ae7452; }\n.kl-job-status.running { background:#e4f0df;color:#528342; }\n.kl-info label { display:block;font-size:11px;color:#849772;margin-bottom:10px; }\n.kl-info code { display:block;overflow-wrap:anywhere;background:#f0f4e9;padding:14px;border-radius:5px;font-size:11px;color:#647d4f; }\n.kl-info p { font-size:12px;line-height:2;color:#8d9d7b;margin:20px 0; }\n.kl-info button { font-size:11px; }\n.kl-error,.kl-form-error { background:#f9ede6;color:#a25b40;font-size:12px;line-height:1.8;padding:11px 15px; }\n.kl-error { display:flex;align-items:center;gap:12px;margin:0 38px 15px;border-radius:5px; }\n.kl-error button { margin-left:auto;border:0;background:none;color:inherit;display:flex; }\n.kl-form-error { border-radius:5px;margin-bottom:14px; }\n.kl-toast { position:fixed;bottom:28px;left:50%;transform:translateX(-50%);background:#2f513a;color:#f1f7eb;padding:12px 22px;display:flex;gap:9px;align-items:center;border-radius:8px;box-shadow:0 5px 20px #213b2a25;font-size:12px;z-index:1100; }\n.kl-spinner { height:20px;width:20px;border:2px solid #d4e0c8;border-top-color:#718c5f;border-radius:50%;animation:kl-spin 1s linear infinite; }\n@keyframes kl-spin { to { transform:rotate(360deg); } }\n@keyframes kl-enter { from { opacity:0;transform:translateY(8px); } to { opacity:1;transform:translateY(0); } }\n@media(min-width:1500px) { .kl-header,.kl-toolbar { padding-left:48px;padding-right:48px; }.kl-filterbar { padding-left:48px;padding-right:48px; }.kl-detail article { padding:40px 50px; }.kl-body.with-detail .kl-list { flex-basis:39%; } }\n@media(max-width:1050px) { .kl-nav { width:180px;padding:25px 12px 15px; }.kl-header { padding:28px 25px 22px; }.kl-toolbar { padding:0 25px 20px; }.kl-filterbar { padding:12px 25px; }.kl-detail article { padding:25px 24px; }.kl-body.with-detail .kl-list { flex-basis:34%;min-width:220px;padding:0 10px; }.kl-reading-placeholder { padding:35px 25px; }.kl-reading-placeholder h2 { font-size:21px; }.kl-item h2 { font-size:13px; }.kl-detail-toolbar { padding:10px 16px; }.kl-back span { display:none; } }\n@media(max-width:760px) { .kl-app { min-height:500px; }.kl-nav { width:64px;padding:22px 8px; }.kl-brand { padding:0 0 22px;justify-content:center; }.kl-brand>div,.kl-version,.kl-nav-section,.kl-nav-bottom,.kl-nav nav span,.kl-nav nav small { display:none; }.kl-mark { width:34px;height:38px; }.kl-nav .kl-add { font-size:0;gap:0;padding:10px;margin-bottom:15px; }.kl-nav nav>button { justify-content:center;padding:11px; }.kl-header { padding:24px 20px 20px; }.kl-header h1 { font-size:24px; }.kl-header p { font-size:10px;max-width:230px;line-height:1.8; }.kl-eyebrow { font-size:7px;letter-spacing:1.2px; }.kl-header>.kl-secondary { font-size:10px;padding:8px 10px; }.kl-toolbar { padding:0 20px 18px;gap:8px; }.kl-search kbd { display:none; }.kl-job-button span { display:none; }.kl-filterbar { padding:12px 20px; }.kl-sort-label { display:none; }.kl-body.with-detail .kl-list { display:none; }.kl-reading-placeholder { display:none; }.kl-detail { border-left:0; }.kl-list { padding:0 10px; }.kl-detail article { padding:24px 24px; }.kl-detail-toolbar { padding:10px 20px; }.kl-back span { display:inline; }.kl-empty h2 { font-size:18px;line-height:1.8; }.kl-modal-backdrop { padding:10px; }.kl-dialog { max-height:94dvh; }.kl-dialog>header { padding:22px 20px 17px; }.kl-editor { padding:18px 20px 0; }.kl-editor footer { margin-left:-20px;margin-right:-20px;padding:15px 20px; }.kl-editor footer>span { font-size:8px; }.kl-form-grid { gap:10px; }.kl-error { margin:0 20px 14px; } }\n@media(prefers-reduced-motion:reduce) { .kl-app * { animation:none!important;transition:none!important; } }\n';
700
+
701
+ // src/client.tsx
702
+ var import_jsx_runtime3 = require("react/jsx-runtime");
703
+ var inject = ["slots"];
704
+ function apply(ctx) {
705
+ ctx.effect(() => {
706
+ const style = document.createElement("style");
707
+ style.dataset.plugin = "dsh-knowledge-library";
708
+ style.textContent = style_default;
709
+ document.head.append(style);
710
+ return () => style.remove();
711
+ });
712
+ ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: "knowledge-library" }, () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(App, {})));
713
+ ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
714
+ name: "sidebar.panellist",
715
+ id: "knowledge-library",
716
+ order: 20,
717
+ label: "\u8D44\u6599\u5E93"
718
+ }, () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LibraryIcon, { size: 20 })));
719
+ }
720
+
721
+ return module.exports;}});