dsh-taskflow 0.1.2 → 0.1.4
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/CHANGELOG.md +44 -0
- package/LICENSE +201 -201
- package/NOTICE +6 -1
- package/README.md +247 -43
- package/README_en.md +34 -61
- package/client.js +2428 -62
- package/docs/DETAIL.md +32 -5
- package/docs/DETAIL.zh-CN.md +13 -3
- package/licenses/Marked-MIT.txt +44 -0
- package/package.json +138 -134
- package/src/application/task-runtime.mjs +123 -114
- package/src/domain/task-service.mjs +247 -178
- package/src/domain/tool-view.mjs +11 -0
- package/src/server/config.mjs +1 -1
- package/src/server/index.mjs +18 -8
- package/src/server/inline-sessions.mjs +171 -0
- package/src/server/planning-check.mjs +105 -0
- package/src/server/prompts.mjs +12 -8
- package/src/server/quick-replies.mjs +88 -0
- package/src/server/rpc.mjs +43 -22
- package/src/server/session-context.mjs +11 -5
- package/src/server/task-actions.mjs +63 -0
- package/src/server/tool-schemas.mjs +33 -0
- package/src/server/tool-views.mjs +36 -8
- package/src/server/tools.mjs +20 -14
package/client.js
CHANGED
|
@@ -58,23 +58,73 @@ __export(client_exports, {
|
|
|
58
58
|
inject: () => inject
|
|
59
59
|
});
|
|
60
60
|
module.exports = __toCommonJS(client_exports);
|
|
61
|
-
var
|
|
62
|
-
var
|
|
61
|
+
var import_react15 = __toESM(require("react"));
|
|
62
|
+
var import_react_dom4 = require("react-dom");
|
|
63
63
|
|
|
64
64
|
// taskflow-source:src/client/components/task-panel.jsx
|
|
65
|
-
var
|
|
65
|
+
var import_react5 = __toESM(require("react"));
|
|
66
66
|
|
|
67
67
|
// taskflow-source:src/client/model.mjs
|
|
68
|
-
var STATUS = { pending: "待执行", queued: "排队中", running: "
|
|
68
|
+
var STATUS = { pending: "待执行", queued: "排队中", running: "进行中", awaiting_children: "等待下级", paused: "已暂停", blocked: "受阻", failed: "失败", completed: "已完成", cancelled: "已取消" };
|
|
69
69
|
var TOOL_NAMES = { browser: "浏览器", editor: "编辑器", terminal: "终端", plugin: "插件", orchestration: "编排" };
|
|
70
|
+
function taskOwner(plan, task) {
|
|
71
|
+
const parent = plan.tasks[task.parentId];
|
|
72
|
+
return parent ? parent.mode === "delegate" && parent.executionSessionId ? parent.executionSessionId : taskOwner(plan, parent) : plan.rootSessionId;
|
|
73
|
+
}
|
|
74
|
+
function taskTarget(plan, task) {
|
|
75
|
+
if (task.mode === "delegate" && task.executionSessionId && task.executionCreated !== false) return { parentSessionId: task.executionParentSessionId || taskOwner(plan, task), childSessionId: task.executionSessionId, mode: "unknown" };
|
|
76
|
+
if (task.recordSession?.created) return { parentSessionId: task.recordSession.parentSessionId, childSessionId: task.recordSession.id, mode: "one-shot" };
|
|
77
|
+
const owner = taskOwner(plan, task);
|
|
78
|
+
const parent = Object.values(plan.tasks).find((t) => t.mode === "delegate" && t.executionSessionId === owner);
|
|
79
|
+
return parent ? taskTarget(plan, parent) : owner;
|
|
80
|
+
}
|
|
81
|
+
function executionTarget(plan, task) {
|
|
82
|
+
const sid = task.executionSessionId || taskOwner(plan, task);
|
|
83
|
+
const parent = Object.values(plan.tasks).find((t) => t.mode === "delegate" && t.executionSessionId === sid);
|
|
84
|
+
return parent ? taskTarget(plan, parent) : sid;
|
|
85
|
+
}
|
|
86
|
+
function sessionTree(plan) {
|
|
87
|
+
if (!plan) return [];
|
|
88
|
+
const nodes = Object.values(plan.tasks).flatMap((t) => [
|
|
89
|
+
...(t.sessionHistory ?? []).map((h) => ({ ...t, title: `${t.title}(历史执行)`, status: h.status, executionSessionId: h.sessionId, target: { parentSessionId: h.parentSessionId, childSessionId: h.sessionId, mode: "unknown" }, children: [] })),
|
|
90
|
+
...t.mode === "delegate" && t.executionSessionId && t.executionCreated !== false ? [{ ...t, target: taskTarget(plan, t), children: [] }] : [],
|
|
91
|
+
...[...t.recordHistory ?? [], ...t.recordSession ? [t.recordSession] : []].filter((r) => r.created && t.attempts > 0).map((r) => ({ ...t, title: r === t.recordSession && t.mode === "inline" ? t.title : `${t.title}(历史执行记录)`, status: r === t.recordSession && t.mode === "inline" ? t.status : r.status || t.report?.status || "paused", executionSessionId: r.id, target: { parentSessionId: r.parentSessionId, childSessionId: r.id, mode: "one-shot" }, children: [] }))
|
|
92
|
+
]);
|
|
93
|
+
const bySession = new Map(nodes.map((t) => [t.executionSessionId, t])), roots = [];
|
|
94
|
+
for (const t of nodes) {
|
|
95
|
+
const parent = bySession.get(t.target.parentSessionId);
|
|
96
|
+
(parent && parent !== t ? parent.children : roots).push(t);
|
|
97
|
+
}
|
|
98
|
+
return roots;
|
|
99
|
+
}
|
|
100
|
+
function sessionPath(plan, sessionId) {
|
|
101
|
+
if (!plan) return [];
|
|
102
|
+
const root = { sessionId: plan.rootSessionId, title: plan.title, target: plan.rootSessionId };
|
|
103
|
+
const find = (nodes, path) => {
|
|
104
|
+
for (const t of nodes) {
|
|
105
|
+
const next = [...path, { sessionId: t.executionSessionId, title: `${t.id} ${t.title}`, target: t.target }];
|
|
106
|
+
if (t.executionSessionId === sessionId) return next;
|
|
107
|
+
const found = find(t.children, next);
|
|
108
|
+
if (found) return found;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return sessionId === root.sessionId ? [root] : find(sessionTree(plan), [root]) ?? [];
|
|
112
|
+
}
|
|
113
|
+
function executionLabel(plan, task, sessionId) {
|
|
114
|
+
if (task.mode === "delegate") return task.executionSessionId && task.executionCreated !== false ? "独立子会话" : "按需委派";
|
|
115
|
+
const owner = taskOwner(plan, task);
|
|
116
|
+
if (owner === sessionId) return "本会话内执行";
|
|
117
|
+
const parent = Object.values(plan.tasks).find((t) => t.mode === "delegate" && t.executionSessionId === owner);
|
|
118
|
+
return parent ? `在 ${parent.id} 会话内执行` : "在主会话内执行";
|
|
119
|
+
}
|
|
70
120
|
function visibleTree(plan, { filter = "all", scope = "global", sessionId } = {}) {
|
|
71
121
|
if (!plan) return [];
|
|
72
122
|
const all = Object.values(plan.tasks), kept = /* @__PURE__ */ new Set();
|
|
73
|
-
const matches = (t) => (filter === "all" || (filter === "active" ? !["completed", "cancelled"].includes(t.status) : t.status === filter)) && (scope === "global" || t.executionSessionId === sessionId || (t.parentId ? plan.tasks[t.parentId].executionSessionId : plan.rootSessionId) === sessionId);
|
|
123
|
+
const matches = (t) => (filter === "all" || (filter === "active" ? !["completed", "cancelled"].includes(t.status) : t.status === filter)) && (scope === "global" || t.executionSessionId === sessionId || t.recordSession?.id === sessionId || t.recordHistory?.some((r) => r.id === sessionId) || (t.parentId ? plan.tasks[t.parentId].executionSessionId : plan.rootSessionId) === sessionId);
|
|
74
124
|
for (const t of all.filter(matches)) {
|
|
75
|
-
for (let
|
|
76
|
-
if (kept.has(
|
|
77
|
-
kept.add(
|
|
125
|
+
for (let x2 = t; x2; x2 = plan.tasks[x2.parentId]) {
|
|
126
|
+
if (kept.has(x2.id)) break;
|
|
127
|
+
kept.add(x2.id);
|
|
78
128
|
}
|
|
79
129
|
}
|
|
80
130
|
const walk = (parentId) => all.filter((t) => t.parentId === parentId && kept.has(t.id)).map((t) => ({ ...t, children: walk(t.id) }));
|
|
@@ -86,23 +136,29 @@ function progress(plan) {
|
|
|
86
136
|
return { done, total: roots.length, percent: roots.length ? Math.round(done / roots.length * 100) : 0 };
|
|
87
137
|
}
|
|
88
138
|
|
|
89
|
-
// taskflow-source:src/client/
|
|
139
|
+
// taskflow-source:src/client/components/task-icon.jsx
|
|
90
140
|
var import_react = __toESM(require("react"));
|
|
141
|
+
function TaskIcon(props) {
|
|
142
|
+
return /* @__PURE__ */ import_react.default.createElement("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", ...props }, /* @__PURE__ */ import_react.default.createElement("rect", { x: "3", y: "3", width: "4", height: "4", rx: "1" }), /* @__PURE__ */ import_react.default.createElement("rect", { x: "3", y: "10", width: "4", height: "4", rx: "1" }), /* @__PURE__ */ import_react.default.createElement("rect", { x: "3", y: "17", width: "4", height: "4", rx: "1" }), /* @__PURE__ */ import_react.default.createElement("path", { d: "M11 5h10M11 12h10M11 19h10" }));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// taskflow-source:src/client/generated/icons.jsx
|
|
146
|
+
var import_react2 = __toESM(require("react"));
|
|
91
147
|
var paths = { layers: "m12 3 9 5-9 5-9-5 9-5zm-9 9 9 5 9-5M3 16l9 5 9-5", chat: "M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6A8.4 8.4 0 0 1 12.5 3h.5a8.5 8.5 0 0 1 8 8v.5z", check: "m5 12 4 4L19 6", chevron: "m9 5 7 7-7 7", arrow: "M5 12h14m-6-6 6 6-6 6", back: "M19 12H5m6-6-6 6 6 6", plus: "M12 5v14M5 12h14", search: "m21 21-4.3-4.3M19 10.5a8.5 8.5 0 1 1-17 0 8.5 8.5 0 0 1 17 0", browser: "M3 8h18M5 4h14a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m1 2h.01M9 6h.01", code: "m8 6-6 6 6 6m8-12 6 6-6 6m-3-15-2 18", terminal: "m4 5 6 6-6 6m9 1h7", plugin: "M8 3v4H4v5h4v4h4v5h5v-5h4v-5h-4V7h-4V3H8z", settings: "M9 3h6l1 4 4 1 1 6-4 2-1 4H9l-1-4-4-1-1-6 4-2 2-4zm7 9a4 4 0 1 1-8 0 4 4 0 0 1 8 0", file: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zm0 0v6h6M8 13h8m-8 4h6", branch: "M6 3v12a3 3 0 0 0 3 3h9M6 8h8a4 4 0 0 0 4-4m-9 14a3 3 0 1 1-6 0 3 3 0 0 1 6 0m12-15a3 3 0 1 1-6 0 3 3 0 0 1 6 0", clock: "M12 7v5l3 2m6-2a9 9 0 1 1-18 0 9 9 0 0 1 18 0", download: "M12 3v12m-5-5 5 5 5-5M4 16v4h16v-4", send: "m22 2-7 20-4-9-9-4 20-7zM22 2 11 13", close: "m6 6 12 12M6 18 18 6", upload: "M12 16V3M7 8l5-5 5 5M4 16v5h16v-5", refresh: "M20 7V3l-4 4a8 8 0 1 0 4 8M20 3h-5", lock: "M6 11h12v10H6zm3 0V7a3 3 0 0 1 6 0v4", expand: "M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5", eye: "M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zm13 0a3 3 0 1 1-6 0 3 3 0 0 1 6 0", book: "M12 5s-4-3-9-2v16c5-1 9 2 9 2s4-3 9-2V3c-5-1-9 2-9 2zm0 0v16", info: "M12 11v6m0-10h.01m9 5a9 9 0 1 1-18 0 9 9 0 0 1 18 0", dots: "M5 12h.01M12 12h.01M19 12h.01" };
|
|
92
148
|
paths.folder = "M3 7V5h6l2 2h10v13H3V7z";
|
|
93
149
|
paths.panel = "M3 4h18v16H3zm7 0v16";
|
|
94
150
|
paths.edit = "m16 3 5 5-12 12-6 1 1-6L16 3zm-3 3 5 5";
|
|
95
151
|
paths.moon = "M20 15a9 9 0 0 1-11-11 9 9 0 1 0 11 11";
|
|
96
152
|
function Icon({ name, ...props }) {
|
|
97
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ import_react2.default.createElement("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", ...props }, /* @__PURE__ */ import_react2.default.createElement("path", { d: paths[name] || paths.file }));
|
|
98
154
|
}
|
|
99
155
|
|
|
100
156
|
// taskflow-source:src/client/components/task-dialog.jsx
|
|
101
|
-
var
|
|
157
|
+
var import_react3 = __toESM(require("react"));
|
|
102
158
|
var import_react_dom = require("react-dom");
|
|
103
159
|
function TaskDialog({ title, subtitle, children, actions, onClose, closeLabel = "关闭任务详情" }) {
|
|
104
|
-
const ref = (0,
|
|
105
|
-
(0,
|
|
160
|
+
const ref = (0, import_react3.useRef)(null);
|
|
161
|
+
(0, import_react3.useEffect)(() => {
|
|
106
162
|
const d = ref.current;
|
|
107
163
|
if (typeof d.showModal === "function") d.showModal();
|
|
108
164
|
else d.setAttribute("open", "");
|
|
@@ -110,7 +166,7 @@ function TaskDialog({ title, subtitle, children, actions, onClose, closeLabel =
|
|
|
110
166
|
if (d.open && typeof d.close === "function") d.close();
|
|
111
167
|
};
|
|
112
168
|
}, []);
|
|
113
|
-
return (0, import_react_dom.createPortal)(/* @__PURE__ */
|
|
169
|
+
return (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react3.default.createElement("dialog", { ref, className: "tf-dialog", "aria-label": title, onCancel: (e) => {
|
|
114
170
|
e.preventDefault();
|
|
115
171
|
onClose();
|
|
116
172
|
}, onClick: (e) => {
|
|
@@ -118,23 +174,33 @@ function TaskDialog({ title, subtitle, children, actions, onClose, closeLabel =
|
|
|
118
174
|
const r = ref.current.getBoundingClientRect();
|
|
119
175
|
if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) onClose();
|
|
120
176
|
}
|
|
121
|
-
} }, /* @__PURE__ */
|
|
177
|
+
} }, /* @__PURE__ */ import_react3.default.createElement("header", { className: "dialog-head" }, /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement("small", null, subtitle), /* @__PURE__ */ import_react3.default.createElement("h2", null, title)), /* @__PURE__ */ import_react3.default.createElement("button", { className: "iconbtn", "aria-label": closeLabel, onClick: onClose }, /* @__PURE__ */ import_react3.default.createElement(Icon, { name: "close" }))), /* @__PURE__ */ import_react3.default.createElement("div", { className: "dialog-body" }, children), actions && /* @__PURE__ */ import_react3.default.createElement("footer", { className: "dialog-actions" }, actions)), document.body);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// taskflow-source:src/client/components/task-spinner.jsx
|
|
181
|
+
var import_react4 = __toESM(require("react"));
|
|
182
|
+
function TaskSpinner({ label = "进行中" }) {
|
|
183
|
+
return /* @__PURE__ */ import_react4.default.createElement("svg", { className: "tf-task-spinner", viewBox: "0 0 24 24", role: "img", "aria-label": label }, /* @__PURE__ */ import_react4.default.createElement("circle", { cx: "12", cy: "12", r: "9", opacity: ".2" }), /* @__PURE__ */ import_react4.default.createElement("path", { d: "M12 3a9 9 0 0 1 9 9" }));
|
|
122
184
|
}
|
|
123
185
|
|
|
124
186
|
// taskflow-source:src/client/components/task-panel.jsx
|
|
125
187
|
function TaskPanel({ view, sessionId, action, navigate, augment, onError }) {
|
|
126
|
-
const [filter, setFilter] = (0,
|
|
127
|
-
(0,
|
|
188
|
+
const [filter, setFilter] = (0, import_react5.useState)("all"), [scope, setScope] = (0, import_react5.useState)("global"), [collapsed, setCollapsed] = (0, import_react5.useState)(/* @__PURE__ */ new Set()), [detail, setDetail] = (0, import_react5.useState)(null), [busy, setBusy] = (0, import_react5.useState)(false), [error, setError] = (0, import_react5.useState)(""), [feedback, setFeedback] = (0, import_react5.useState)("");
|
|
189
|
+
(0, import_react5.useEffect)(() => {
|
|
128
190
|
setDetail(null);
|
|
129
191
|
setError("");
|
|
192
|
+
setFeedback("");
|
|
130
193
|
}, [sessionId]);
|
|
131
|
-
const p = view.plan, pr = progress(p);
|
|
194
|
+
const p = view.plan, pr = progress(p), path = sessionPath(p, sessionId);
|
|
132
195
|
const perform = async (type, data) => {
|
|
133
196
|
if (busy) return;
|
|
134
197
|
setBusy(true);
|
|
135
198
|
setError("");
|
|
199
|
+
setFeedback("");
|
|
136
200
|
try {
|
|
137
|
-
await action(type, data);
|
|
201
|
+
const result = await action(type, data);
|
|
202
|
+
if (result?.message) setFeedback(result.message);
|
|
203
|
+
if (type === "resume" && result?.accepted) setDetail(null);
|
|
138
204
|
} catch (e) {
|
|
139
205
|
setError(e.message);
|
|
140
206
|
onError?.(e);
|
|
@@ -142,37 +208,176 @@ function TaskPanel({ view, sessionId, action, navigate, augment, onError }) {
|
|
|
142
208
|
setBusy(false);
|
|
143
209
|
}
|
|
144
210
|
};
|
|
145
|
-
const prompt = (value) => {
|
|
146
|
-
|
|
147
|
-
|
|
211
|
+
const prompt = async (value) => {
|
|
212
|
+
try {
|
|
213
|
+
await augment(value);
|
|
214
|
+
setDetail(null);
|
|
215
|
+
} catch (e) {
|
|
216
|
+
setError(e.message);
|
|
217
|
+
}
|
|
148
218
|
};
|
|
149
|
-
const row = (t) => /* @__PURE__ */
|
|
150
|
-
const target =
|
|
151
|
-
if (target
|
|
219
|
+
const row = (t) => /* @__PURE__ */ import_react5.default.createElement("div", { className: "task-node", key: t.id }, /* @__PURE__ */ import_react5.default.createElement("div", { className: `tf-row task-row ${t.status} ${view.currentTaskId === t.id ? "focused" : ""}`, "data-task-id": t.id, "data-status": t.status }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "task-line" }, /* @__PURE__ */ import_react5.default.createElement("span", { className: `task-box ${t.status}`, "aria-label": STATUS[t.status] }, t.status === "running" ? /* @__PURE__ */ import_react5.default.createElement(TaskSpinner, { label: `${t.id} 进行中` }) : t.status === "completed" ? /* @__PURE__ */ import_react5.default.createElement(Icon, { name: "check" }) : t.status === "cancelled" ? "−" : null), /* @__PURE__ */ import_react5.default.createElement("div", { className: "task-copy" }, /* @__PURE__ */ import_react5.default.createElement("button", { className: "tf-task task-title", onClick: () => {
|
|
220
|
+
const target = taskTarget(p, t);
|
|
221
|
+
if ((typeof target === "string" ? target : target.childSessionId) !== sessionId) navigate(target);
|
|
152
222
|
else void perform("focus", { taskId: t.id });
|
|
153
|
-
} }, t.title), /* @__PURE__ */
|
|
223
|
+
} }, t.title), /* @__PURE__ */ import_react5.default.createElement("div", { className: "task-meta" }, /* @__PURE__ */ import_react5.default.createElement("code", null, t.id), /* @__PURE__ */ import_react5.default.createElement("span", { title: t.executionReason }, "· ", executionLabel(p, t, sessionId)), t.version > 1 && /* @__PURE__ */ import_react5.default.createElement("span", null, "v", t.version), t.children.length > 0 && /* @__PURE__ */ import_react5.default.createElement("button", { className: "tf-fold", "aria-label": `${collapsed.has(t.id) ? "展开" : "折叠"} ${t.title}`, onClick: () => setCollapsed((old) => {
|
|
154
224
|
const n = new Set(old);
|
|
155
225
|
n.has(t.id) ? n.delete(t.id) : n.add(t.id);
|
|
156
226
|
return n;
|
|
157
|
-
}) }, /* @__PURE__ */
|
|
227
|
+
}) }, /* @__PURE__ */ import_react5.default.createElement(Icon, { name: "chevron", style: { transform: collapsed.has(t.id) ? "" : "rotate(90deg)" } })))), /* @__PURE__ */ import_react5.default.createElement("button", { className: "iconbtn", "aria-label": `查看 ${t.id} 详情`, onClick: () => setDetail(t.id) }, /* @__PURE__ */ import_react5.default.createElement(Icon, { name: "dots" }))), !["completed", "cancelled"].includes(t.status) && /* @__PURE__ */ import_react5.default.createElement("div", { className: "task-status" }, /* @__PURE__ */ import_react5.default.createElement("span", { className: `pill ${t.status === "running" ? "blue" : ""}` }, /* @__PURE__ */ import_react5.default.createElement("i", { className: `dot ${t.status}` }), STATUS[t.status]), ["pending", "paused", "blocked", "failed"].includes(t.status) && /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small outline", disabled: busy, onClick: () => void perform("resume", { taskId: t.id, version: t.version }) }, t.status === "pending" ? "开始" : "继续")), ["blocked", "failed"].includes(t.status) && /* @__PURE__ */ import_react5.default.createElement("p", { className: "tf-blocked-reason" }, /* @__PURE__ */ import_react5.default.createElement("strong", null, t.status === "blocked" ? "受阻原因:" : "失败原因:"), t.report?.summary || "尚未记录原因,请查看会话详情。"), t.recordError && /* @__PURE__ */ import_react5.default.createElement("p", { className: "tf-blocked-reason", role: "status" }, "子会话记录待同步:", t.recordError)), !collapsed.has(t.id) && t.children.length > 0 && /* @__PURE__ */ import_react5.default.createElement("div", { className: "child-tasks" }, t.children.map(row)));
|
|
158
228
|
const selected = p?.tasks[detail];
|
|
159
|
-
return /* @__PURE__ */
|
|
229
|
+
return /* @__PURE__ */ import_react5.default.createElement("section", { className: "tf-panel", "aria-label": "待办任务清单" }, /* @__PURE__ */ import_react5.default.createElement("header", { className: "plan-tabs" }, /* @__PURE__ */ import_react5.default.createElement("span", { className: "tab" }, /* @__PURE__ */ import_react5.default.createElement(TaskIcon, null), "待办任务清单"), /* @__PURE__ */ import_react5.default.createElement("span", { className: "pill", style: { fontSize: 10 } }, "持久计划"), /* @__PURE__ */ import_react5.default.createElement("button", { className: "iconbtn", "aria-label": "查看任务动态", onClick: () => setDetail("activity") }, /* @__PURE__ */ import_react5.default.createElement(Icon, { name: "dots" }))), view.loading ? /* @__PURE__ */ import_react5.default.createElement("p", { className: "empty" }, "正在加载任务…") : !p ? /* @__PURE__ */ import_react5.default.createElement("div", { className: "empty" }, /* @__PURE__ */ import_react5.default.createElement(Icon, { name: "check" }), /* @__PURE__ */ import_react5.default.createElement("p", null, "暂无任务计划"), /* @__PURE__ */ import_react5.default.createElement("p", null, "在会话中描述目标,模型将根据任务复杂度规划待办。")) : /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("div", { className: "plan-heading" }, path.length > 1 && /* @__PURE__ */ import_react5.default.createElement("nav", { className: "tf-session-path", "aria-label": "会话层级" }, path.map((part, index) => /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, { key: part.sessionId }, index > 0 && /* @__PURE__ */ import_react5.default.createElement("span", { "aria-hidden": "true" }, "/"), index === path.length - 1 ? /* @__PURE__ */ import_react5.default.createElement("span", { "aria-current": "page" }, part.title) : /* @__PURE__ */ import_react5.default.createElement("button", { onClick: () => navigate(part.target) }, part.title))), /* @__PURE__ */ import_react5.default.createElement("button", { onClick: () => navigate(path.at(-2).target) }, "返回父会话")), /* @__PURE__ */ import_react5.default.createElement("h2", null, p.title), /* @__PURE__ */ import_react5.default.createElement("div", { className: "progress-label" }, /* @__PURE__ */ import_react5.default.createElement("strong", null, pr.done, " / ", pr.total, " 项已完成"), /* @__PURE__ */ import_react5.default.createElement("span", null, "v", p.version, " · ", pr.percent, "%")), /* @__PURE__ */ import_react5.default.createElement("div", { className: "progress-track", role: "progressbar", "aria-label": "根任务完成进度", "aria-valuenow": pr.percent, "aria-valuemin": 0, "aria-valuemax": 100 }, /* @__PURE__ */ import_react5.default.createElement("span", { style: { width: `${pr.percent}%` } }))), /* @__PURE__ */ import_react5.default.createElement("div", { className: "plan-controls" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "segments" }, [["global", "全局计划"], ["local", "当前会话"]].map(([id, title]) => /* @__PURE__ */ import_react5.default.createElement("button", { key: id, className: scope === id ? "selected" : "", "aria-pressed": scope === id, onClick: () => setScope(id) }, title))), /* @__PURE__ */ import_react5.default.createElement("select", { "aria-label": "任务筛选", value: filter, onChange: (e) => setFilter(e.target.value) }, /* @__PURE__ */ import_react5.default.createElement("option", { value: "all" }, "全部事项"), /* @__PURE__ */ import_react5.default.createElement("option", { value: "active" }, "未完成"), /* @__PURE__ */ import_react5.default.createElement("option", { value: "completed" }, "已完成"), /* @__PURE__ */ import_react5.default.createElement("option", { value: "cancelled" }, "已取消"))), /* @__PURE__ */ import_react5.default.createElement("div", { className: "task-list" }, visibleTree(p, { filter, scope, sessionId }).map(row)), /* @__PURE__ */ import_react5.default.createElement("footer", { className: "plan-bottom" }, /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn outline", onClick: () => void prompt(view.currentTaskId ? `在 ${view.currentTaskId} 下新增一个` : "新增一个待办事项:") }, /* @__PURE__ */ import_react5.default.createElement(Icon, { name: "plus" }), view.currentTaskId ? "在当前任务下增补" : "在主任务下增补"), /* @__PURE__ */ import_react5.default.createElement("p", null, "稳定 ID · 跨轮保留 · 刷新恢复"))), !p && view.planning && view.planning.phase !== "skipped" && /* @__PURE__ */ import_react5.default.createElement("p", { role: view.planning.phase === "blocked" ? "alert" : "status", className: view.planning.phase === "blocked" ? "tf-error" : "tf-planning" }, view.planning.message), feedback && /* @__PURE__ */ import_react5.default.createElement("p", { role: "status", className: "tf-feedback" }, feedback), (error || view.error) && /* @__PURE__ */ import_react5.default.createElement("p", { role: "alert", className: "tf-error" }, error || view.error), selected && /* @__PURE__ */ import_react5.default.createElement(TaskDialog, { title: selected.title, subtitle: `${selected.id} · 任务详情`, onClose: () => setDetail(null), actions: /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, ["pending", "paused", "blocked", "failed"].includes(selected.status) && /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small primary", disabled: busy, onClick: () => void perform("resume", { taskId: selected.id, version: selected.version }) }, "继续执行"), selected.status !== "cancelled" && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small outline", onClick: () => prompt(`在 ${selected.id} 下新增一个`) }, "增补下级事项"), /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small outline", onClick: () => prompt(`修改 ${selected.id} 的要求为:`) }, "修改要求")), !["cancelled", "completed"].includes(selected.status) && /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small danger", disabled: busy, onClick: () => void perform("cancel", { taskId: selected.id, version: selected.version }) }, "取消任务"), /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small", disabled: busy, onClick: () => void perform("reorder", { taskId: selected.id, direction: -1, expectedVersion: p.version }) }, "上移"), /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small", disabled: busy, onClick: () => void perform("reorder", { taskId: selected.id, direction: 1, expectedVersion: p.version }) }, "下移")) }, /* @__PURE__ */ import_react5.default.createElement("dl", { className: "detail-kv" }, /* @__PURE__ */ import_react5.default.createElement("dt", null, "状态"), /* @__PURE__ */ import_react5.default.createElement("dd", null, /* @__PURE__ */ import_react5.default.createElement("span", { className: "pill" }, STATUS[selected.status], " · v", selected.version)), /* @__PURE__ */ import_react5.default.createElement("dt", null, "执行方式"), /* @__PURE__ */ import_react5.default.createElement("dd", null, executionLabel(p, selected, sessionId)), /* @__PURE__ */ import_react5.default.createElement("dt", null, "执行说明"), /* @__PURE__ */ import_react5.default.createElement("dd", null, selected.executionReason || (selected.mode === "delegate" ? "按需创建真实子会话" : "在负责会话内执行"), selected.mode === "inline" && ";此事项在父会话执行,过程与结果保存到只读事项子会话。"), /* @__PURE__ */ import_react5.default.createElement("dt", null, "所属会话"), /* @__PURE__ */ import_react5.default.createElement("dd", null, /* @__PURE__ */ import_react5.default.createElement("button", { className: "btn small outline", onClick: () => navigate(taskTarget(p, selected)) }, selected.mode === "inline" && selected.recordSession?.created ? "查看事项子会话" : "打开执行会话")), /* @__PURE__ */ import_react5.default.createElement("dt", null, "父级事项"), /* @__PURE__ */ import_react5.default.createElement("dd", null, selected.parentId || "主任务"), /* @__PURE__ */ import_react5.default.createElement("dt", null, "任务要求"), /* @__PURE__ */ import_react5.default.createElement("dd", null, selected.instructions || selected.title), /* @__PURE__ */ import_react5.default.createElement("dt", null, "完成标准"), /* @__PURE__ */ import_react5.default.createElement("dd", null, selected.criteria || "按当前任务要求完成")), selected.report && /* @__PURE__ */ import_react5.default.createElement("div", { className: "notice" }, /* @__PURE__ */ import_react5.default.createElement("strong", null, selected.report.version === selected.version ? "执行结果" : `历史结果 v${selected.report.version}(当前要求已变化)`), /* @__PURE__ */ import_react5.default.createElement("p", null, selected.report.summary)), error && /* @__PURE__ */ import_react5.default.createElement("p", { className: "tf-error", role: "alert" }, error)), detail === "activity" && p && /* @__PURE__ */ import_react5.default.createElement(TaskDialog, { title: "任务动态", subtitle: `持久计划 · v${p.version}`, closeLabel: "关闭任务动态", onClose: () => setDetail(null) }, [...p.events].reverse().map((e) => /* @__PURE__ */ import_react5.default.createElement("article", { className: "history", key: e.id }, /* @__PURE__ */ import_react5.default.createElement("time", null, e.at.replace("T", " ").slice(0, 19), " · ", e.taskId), e.detail))));
|
|
160
230
|
}
|
|
161
231
|
|
|
162
232
|
// taskflow-source:src/client/components/tool-panel.jsx
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
233
|
+
var import_react7 = __toESM(require("react"));
|
|
234
|
+
var import_react_dom2 = require("react-dom");
|
|
235
|
+
|
|
236
|
+
// taskflow-source:src/client/components/tool-document.jsx
|
|
237
|
+
var import_react6 = __toESM(require("react"));
|
|
238
|
+
function ToolDocument({ tool, file, sessionId, openers, foreground, custom = false }) {
|
|
239
|
+
const [loading, setLoading] = (0, import_react6.useState)(false), [error, setError] = (0, import_react6.useState)(""), [hasOpened, setHasOpened] = (0, import_react6.useState)(false);
|
|
240
|
+
const opened = (0, import_react6.useRef)(/* @__PURE__ */ new Set()), generation = (0, import_react6.useRef)(0), container = (0, import_react6.useRef)(null), preview = (0, import_react6.useRef)(null);
|
|
241
|
+
const target = file?.path || tool.url;
|
|
242
|
+
const open = async (automatic = false) => {
|
|
243
|
+
const current = ++generation.current;
|
|
244
|
+
setLoading(true);
|
|
245
|
+
setError("");
|
|
246
|
+
try {
|
|
247
|
+
preview.current?.dispose();
|
|
248
|
+
preview.current = null;
|
|
249
|
+
const result = await (file ? openers.openDocument(sessionId, file, { container: container.current }) : openers.openBrowser(sessionId, tool.url, { automatic }));
|
|
250
|
+
if (generation.current === current) {
|
|
251
|
+
preview.current = typeof result === "object" ? result : null;
|
|
252
|
+
setHasOpened(true);
|
|
253
|
+
} else result.dispose?.();
|
|
254
|
+
} catch (e) {
|
|
255
|
+
if (generation.current === current) setError(e.message);
|
|
256
|
+
} finally {
|
|
257
|
+
if (generation.current === current) setLoading(false);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
(0, import_react6.useEffect)(() => {
|
|
261
|
+
setLoading(false);
|
|
262
|
+
setError("");
|
|
263
|
+
setHasOpened(false);
|
|
264
|
+
return () => {
|
|
265
|
+
generation.current++;
|
|
266
|
+
preview.current?.dispose();
|
|
267
|
+
preview.current = null;
|
|
268
|
+
opened.current.clear();
|
|
269
|
+
};
|
|
270
|
+
}, [sessionId, target, tool.id, foreground]);
|
|
271
|
+
(0, import_react6.useEffect)(() => {
|
|
272
|
+
const key = `${sessionId}:${tool.id}:${target}`;
|
|
273
|
+
if (!openers || !foreground || custom || !target || tool.phase !== "ready" || tool.autoOpen === false || opened.current.has(key)) return;
|
|
274
|
+
opened.current.add(key);
|
|
275
|
+
void open(true);
|
|
276
|
+
}, [sessionId, tool.id, tool.phase, tool.autoOpen, target, foreground, openers, custom]);
|
|
277
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", { className: "tf-document-view" }, (error || tool.autoOpen === false && !hasOpened && !loading) && /* @__PURE__ */ import_react6.default.createElement("div", { className: "tf-document-actions" }, error && /* @__PURE__ */ import_react6.default.createElement("p", { role: "alert", className: "tf-error" }, error), /* @__PURE__ */ import_react6.default.createElement("button", { className: "btn small outline", disabled: !openers || !foreground || loading, onClick: () => void open() }, error ? "重试打开" : "打开预览")), loading && /* @__PURE__ */ import_react6.default.createElement("p", { role: "status", className: "tf-preview-loading" }, "正在打开预览…"), file ? /* @__PURE__ */ import_react6.default.createElement("div", { ref: container, className: "tf-document-preview-target", "aria-label": `${file.path} 文档预览` }) : /* @__PURE__ */ import_react6.default.createElement("div", { className: "notice" }, `网页操作由 ${tool.sourceTool || "浏览器工具"} 执行。浏览器视图打开相同地址;登录状态和页面进度由对应浏览器插件管理。`));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// taskflow-source:src/client/components/tool-panel.jsx
|
|
281
|
+
var fit = (n, min, max) => Math.max(min, Math.min(n, Math.max(min, max)));
|
|
282
|
+
var bounds = (p) => {
|
|
283
|
+
const width = fit(p.width, Math.min(280, window.innerWidth - 16), window.innerWidth - 16);
|
|
284
|
+
const height = fit(p.height, Math.min(200, window.innerHeight - 16), window.innerHeight - 16);
|
|
285
|
+
return { ...p, width, height, x: fit(p.x, 8, window.innerWidth - width - 8), y: fit(p.y, 8, window.innerHeight - height - 8) };
|
|
286
|
+
};
|
|
287
|
+
var initial = (sessionId) => {
|
|
288
|
+
let saved;
|
|
289
|
+
try {
|
|
290
|
+
saved = JSON.parse(window.localStorage.getItem(`dsh-taskflow:tool-layout:${sessionId}`));
|
|
291
|
+
} catch {
|
|
292
|
+
}
|
|
293
|
+
const p = { floating: saved?.floating === true, dockWidth: 440, width: 560, height: 440, x: 48, y: 80 };
|
|
294
|
+
for (const key of ["dockWidth", "width", "height", "x", "y"]) if (Number.isFinite(saved?.[key])) p[key] = saved[key];
|
|
295
|
+
return bounds(p);
|
|
296
|
+
};
|
|
297
|
+
function ToolPanel({ tool, onClose, renderer, mount, sessionId, openers, foreground = true }) {
|
|
298
|
+
const [layout, setLayout] = (0, import_react7.useState)(() => initial(sessionId)), [dragging, setDragging] = (0, import_react7.useState)(false);
|
|
299
|
+
const stopDrag = (0, import_react7.useRef)(() => {
|
|
300
|
+
}), latest = (0, import_react7.useRef)(layout);
|
|
301
|
+
latest.current = layout;
|
|
302
|
+
(0, import_react7.useEffect)(() => {
|
|
303
|
+
const parent = mount?.parentElement;
|
|
304
|
+
if (!parent) return;
|
|
305
|
+
parent.classList.toggle("tf-tool-layout", !layout.floating);
|
|
306
|
+
mount.classList.toggle("tf-floating-mount", layout.floating);
|
|
307
|
+
const clamp2 = () => setLayout((old) => ({ ...bounds(old), dockWidth: fit(old.dockWidth, 240, (parent.getBoundingClientRect().width || 1e3) - 320) }));
|
|
308
|
+
clamp2();
|
|
309
|
+
window.addEventListener("resize", clamp2);
|
|
310
|
+
const observer = typeof window.ResizeObserver === "function" ? new window.ResizeObserver(clamp2) : null;
|
|
311
|
+
observer?.observe(parent);
|
|
312
|
+
return () => {
|
|
313
|
+
observer?.disconnect();
|
|
314
|
+
window.removeEventListener("resize", clamp2);
|
|
315
|
+
parent.classList.remove("tf-tool-layout");
|
|
316
|
+
parent.style.removeProperty("--tf-tool-width");
|
|
317
|
+
mount.classList.remove("tf-floating-mount");
|
|
318
|
+
};
|
|
319
|
+
}, [mount, layout.floating]);
|
|
320
|
+
(0, import_react7.useEffect)(() => {
|
|
321
|
+
mount?.parentElement?.style.setProperty("--tf-tool-width", `${layout.dockWidth}px`);
|
|
322
|
+
try {
|
|
323
|
+
window.localStorage.setItem(`dsh-taskflow:tool-layout:${sessionId}`, JSON.stringify(layout));
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
}, [layout, mount, sessionId]);
|
|
327
|
+
(0, import_react7.useEffect)(() => () => stopDrag.current(), []);
|
|
328
|
+
const drag = (event, kind) => {
|
|
329
|
+
if (event.button !== 0 || kind === "move" && event.target.closest("button,a,input")) return;
|
|
330
|
+
event.preventDefault();
|
|
331
|
+
stopDrag.current();
|
|
332
|
+
const start = { ...latest.current }, x2 = event.clientX, y2 = event.clientY, pointerId = event.pointerId;
|
|
333
|
+
setDragging(true);
|
|
334
|
+
const move = (e) => {
|
|
335
|
+
if (e.pointerId !== pointerId) return;
|
|
336
|
+
const dx = e.clientX - x2, dy = e.clientY - y2;
|
|
337
|
+
if (kind === "move") setLayout(bounds({ ...start, x: start.x + dx, y: start.y + dy }));
|
|
338
|
+
else if (start.floating) setLayout(bounds({ ...start, width: start.width + dx, height: kind === "corner" ? start.height + dy : start.height }));
|
|
339
|
+
else setLayout({ ...start, dockWidth: fit(start.dockWidth + dx, 240, (mount?.parentElement?.getBoundingClientRect().width || 1e3) - 320) });
|
|
340
|
+
};
|
|
341
|
+
const end = () => {
|
|
342
|
+
window.removeEventListener("pointermove", move);
|
|
343
|
+
window.removeEventListener("pointerup", end);
|
|
344
|
+
window.removeEventListener("pointercancel", end);
|
|
345
|
+
window.removeEventListener("blur", end);
|
|
346
|
+
setDragging(false);
|
|
347
|
+
};
|
|
348
|
+
stopDrag.current = end;
|
|
349
|
+
window.addEventListener("pointermove", move);
|
|
350
|
+
window.addEventListener("pointerup", end);
|
|
351
|
+
window.addEventListener("pointercancel", end);
|
|
352
|
+
window.addEventListener("blur", end);
|
|
353
|
+
};
|
|
354
|
+
const keyboardResize = (e) => {
|
|
355
|
+
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) return;
|
|
356
|
+
e.preventDefault();
|
|
357
|
+
const delta = e.key === "ArrowLeft" ? -24 : 24;
|
|
358
|
+
setLayout((p) => p.floating ? bounds({ ...p, width: e.key === "Home" ? 280 : e.key === "End" ? window.innerWidth - 16 : p.width + delta }) : { ...p, dockWidth: fit(e.key === "Home" ? 240 : e.key === "End" ? Infinity : p.dockWidth + delta, 240, (mount?.parentElement?.getBoundingClientRect().width || 1e3) - 320) });
|
|
359
|
+
};
|
|
166
360
|
if (!tool?.open) return null;
|
|
167
|
-
|
|
361
|
+
const content = /* @__PURE__ */ import_react7.default.createElement("aside", { className: `tf-tool ${layout.floating ? "tf-tool-floating" : "tf-tool-docked"} ${dragging ? "tf-tool-dragging" : ""}`, style: layout.floating ? { left: layout.x, top: layout.y, width: layout.width, height: layout.height } : void 0, "aria-label": `${TOOL_NAMES[tool.kind]}工具视图` }, /* @__PURE__ */ import_react7.default.createElement("header", { className: "tool-header", onPointerDown: (e) => layout.floating && drag(e, "move") }, /* @__PURE__ */ import_react7.default.createElement(Icon, { name: tool.kind === "editor" ? "code" : tool.kind }), /* @__PURE__ */ import_react7.default.createElement("span", null, TOOL_NAMES[tool.kind]), /* @__PURE__ */ import_react7.default.createElement("span", { className: "binding" }, tool.taskId), /* @__PURE__ */ import_react7.default.createElement("button", { className: "iconbtn", "aria-label": layout.floating ? "停靠工具视图" : "悬浮工具视图", title: layout.floating ? "停靠到对话左侧" : "悬浮并拖动位置", onClick: () => {
|
|
362
|
+
stopDrag.current();
|
|
363
|
+
setLayout((p) => ({ ...bounds(p), floating: !p.floating }));
|
|
364
|
+
} }, /* @__PURE__ */ import_react7.default.createElement(Icon, { name: layout.floating ? "panel" : "expand" })), /* @__PURE__ */ import_react7.default.createElement("button", { className: "iconbtn", "aria-label": "收起工具视图", onClick: onClose }, /* @__PURE__ */ import_react7.default.createElement(Icon, { name: "close" }))), /* @__PURE__ */ import_react7.default.createElement("div", { className: `tool-content${tool.files?.length ? " tf-tool-documents" : ""}` }, tool.files?.length && tool.phase !== "running" && tool.phase !== "failed" ? tool.files.map((file) => /* @__PURE__ */ import_react7.default.createElement(ToolDocument, { key: file.path, tool, file, sessionId, openers, foreground })) : (() => {
|
|
365
|
+
const rendered = renderer?.(tool);
|
|
366
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, tool.kind === "browser" && tool.url && tool.phase !== "running" && tool.phase !== "failed" && /* @__PURE__ */ import_react7.default.createElement(ToolDocument, { tool, sessionId, openers, foreground, custom: !!rendered }), rendered || (tool.kind !== "browser" || !tool.url || tool.phase === "running" || tool.phase === "failed" ? tool.kind === "terminal" ? /* @__PURE__ */ import_react7.default.createElement("pre", { className: "terminal" }, tool.content) : /* @__PURE__ */ import_react7.default.createElement("div", { className: "code-window" }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "file-tab" }, tool.title), /* @__PURE__ */ import_react7.default.createElement("pre", null, tool.content)) : null));
|
|
367
|
+
})()), /* @__PURE__ */ import_react7.default.createElement("div", { className: "tf-tool-resizer", role: "separator", tabIndex: 0, "aria-label": "调整工具视图宽度", "aria-orientation": "vertical", "aria-valuemin": 240, "aria-valuemax": layout.floating ? window.innerWidth - 16 : Math.max(240, (mount?.parentElement?.getBoundingClientRect().width || 1e3) - 320), "aria-valuenow": Math.round(layout.floating ? layout.width : layout.dockWidth), onKeyDown: keyboardResize, onPointerDown: (e) => drag(e, "resize") }), layout.floating && /* @__PURE__ */ import_react7.default.createElement("div", { className: "tf-tool-corner", "aria-hidden": "true", onPointerDown: (e) => drag(e, "corner") }), dragging && /* @__PURE__ */ import_react7.default.createElement("div", { className: "tf-tool-drag-shield" }));
|
|
368
|
+
return layout.floating ? (0, import_react_dom2.createPortal)(content, document.body) : content;
|
|
168
369
|
}
|
|
169
370
|
|
|
371
|
+
// taskflow-source:src/client/components/session-tree.jsx
|
|
372
|
+
var import_react9 = __toESM(require("react"));
|
|
373
|
+
var import_react_dom3 = require("react-dom");
|
|
374
|
+
|
|
170
375
|
// taskflow-source:src/client/hooks/use-taskflow.mjs
|
|
171
|
-
var
|
|
172
|
-
function useTaskflow(api, sessionId) {
|
|
173
|
-
const [state, setState] = (0,
|
|
174
|
-
const latest = (0,
|
|
175
|
-
(0,
|
|
376
|
+
var import_react8 = require("react");
|
|
377
|
+
function useTaskflow(api, sessionId, interval = 1200) {
|
|
378
|
+
const [state, setState] = (0, import_react8.useState)({ plan: null, loading: true });
|
|
379
|
+
const latest = (0, import_react8.useRef)(0);
|
|
380
|
+
(0, import_react8.useEffect)(() => {
|
|
176
381
|
let alive = true;
|
|
177
382
|
const generation = ++latest.current;
|
|
178
383
|
setState({ plan: null, loading: true });
|
|
@@ -190,33 +395,2141 @@ function useTaskflow(api, sessionId) {
|
|
|
190
395
|
}
|
|
191
396
|
};
|
|
192
397
|
void load();
|
|
193
|
-
const timer = setInterval(load,
|
|
398
|
+
const timer = setInterval(load, interval);
|
|
194
399
|
return () => {
|
|
195
400
|
alive = false;
|
|
196
401
|
clearInterval(timer);
|
|
197
402
|
};
|
|
198
|
-
}, [api, sessionId]);
|
|
403
|
+
}, [api, sessionId, interval]);
|
|
199
404
|
return state;
|
|
200
405
|
}
|
|
201
406
|
|
|
407
|
+
// taskflow-source:src/client/components/session-tree.jsx
|
|
408
|
+
function SessionTree({ api, sessionId, currentSessionId, navigate }) {
|
|
409
|
+
const view = useTaskflow(api, sessionId), anchor = (0, import_react9.useRef)(null), [mount, setMount] = (0, import_react9.useState)(null), [opened, setOpened] = (0, import_react9.useState)(/* @__PURE__ */ new Set()), [expanded, setExpanded] = (0, import_react9.useState)(false), groupId = (0, import_react9.useId)();
|
|
410
|
+
const nodes = sessionTree(view.plan);
|
|
411
|
+
const isRoot = view.plan?.rootSessionId === sessionId && nodes.length > 0;
|
|
412
|
+
(0, import_react9.useEffect)(() => {
|
|
413
|
+
if (!isRoot) return;
|
|
414
|
+
const node = document.createElement("div");
|
|
415
|
+
node.className = "tf-session-tree-mount";
|
|
416
|
+
node.dataset.taskflowParentSession = sessionId;
|
|
417
|
+
const control = document.createElement("span");
|
|
418
|
+
control.className = "tf-session-toggle-mount";
|
|
419
|
+
const status = document.createElement("span");
|
|
420
|
+
status.className = "tf-session-root-status";
|
|
421
|
+
setMount({ tree: node, control, status });
|
|
422
|
+
let attachedRow;
|
|
423
|
+
const clickRow = (event) => {
|
|
424
|
+
if (!event.defaultPrevented && !event.target.closest('button, a, input, [role="menuitem"]')) setExpanded((value) => !value);
|
|
425
|
+
};
|
|
426
|
+
const keyRow = (event) => {
|
|
427
|
+
if (event.target === attachedRow && ["Enter", " "].includes(event.key) && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) setExpanded((value) => !value);
|
|
428
|
+
};
|
|
429
|
+
const detachRow = () => {
|
|
430
|
+
attachedRow?.removeEventListener("click", clickRow);
|
|
431
|
+
attachedRow?.removeEventListener("keydown", keyRow);
|
|
432
|
+
attachedRow?.classList.remove("tf-session-root");
|
|
433
|
+
attachedRow?.querySelectorAll(".tf-session-native-leading,.tf-session-native-trailing,.tf-session-native-title").forEach((e) => e.classList.remove("tf-session-native-leading", "tf-session-native-trailing", "tf-session-native-title"));
|
|
434
|
+
attachedRow = null;
|
|
435
|
+
};
|
|
436
|
+
const attach = () => {
|
|
437
|
+
const row = anchor.current?.closest("[data-row-key]");
|
|
438
|
+
if (!row?.isConnected || row.dataset.rowKey !== `session:${sessionId}`) {
|
|
439
|
+
node.remove();
|
|
440
|
+
control.remove();
|
|
441
|
+
status.remove();
|
|
442
|
+
detachRow();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (attachedRow !== row) {
|
|
446
|
+
detachRow();
|
|
447
|
+
attachedRow = row;
|
|
448
|
+
row.classList.add("tf-session-root");
|
|
449
|
+
const trailing = [...row.children].find((e) => e.contains(anchor.current));
|
|
450
|
+
trailing?.classList.add("tf-session-native-trailing");
|
|
451
|
+
if (row.firstElementChild !== trailing) row.firstElementChild?.classList.add("tf-session-native-leading");
|
|
452
|
+
if (row.children[1] !== trailing) row.children[1]?.classList.add("tf-session-native-title");
|
|
453
|
+
row.addEventListener("click", clickRow);
|
|
454
|
+
row.addEventListener("keydown", keyRow);
|
|
455
|
+
}
|
|
456
|
+
if (row.nextElementSibling !== node) row.after(node);
|
|
457
|
+
if (row.firstElementChild !== control) row.prepend(control);
|
|
458
|
+
if (row.lastElementChild !== status) row.append(status);
|
|
459
|
+
};
|
|
460
|
+
const observer = new MutationObserver(attach);
|
|
461
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
462
|
+
attach();
|
|
463
|
+
return () => {
|
|
464
|
+
observer.disconnect();
|
|
465
|
+
detachRow();
|
|
466
|
+
node.remove();
|
|
467
|
+
control.remove();
|
|
468
|
+
status.remove();
|
|
469
|
+
setMount(null);
|
|
470
|
+
};
|
|
471
|
+
}, [sessionId, isRoot]);
|
|
472
|
+
const toggle = (id) => setOpened((old) => {
|
|
473
|
+
const next = new Set(old);
|
|
474
|
+
next.has(id) ? next.delete(id) : next.add(id);
|
|
475
|
+
return next;
|
|
476
|
+
});
|
|
477
|
+
const count = (tasks) => tasks.reduce((n, t) => n + 1 + count(t.children), 0);
|
|
478
|
+
const render = (tasks) => tasks.map((t) => /* @__PURE__ */ import_react9.default.createElement("div", { key: t.executionSessionId, className: "tf-session-node", "data-taskflow-session": t.executionSessionId }, /* @__PURE__ */ import_react9.default.createElement("div", { className: `session-row tf-session-line ${currentSessionId === t.executionSessionId ? "selected" : ""}`, onClick: () => {
|
|
479
|
+
navigate(t.target);
|
|
480
|
+
if (t.children.length) toggle(t.executionSessionId);
|
|
481
|
+
} }, t.children.length ? /* @__PURE__ */ import_react9.default.createElement("button", { className: "tf-session-arrow", "aria-label": `${opened.has(t.executionSessionId) ? "折叠" : "展开"}子会话 ${t.id}`, "aria-expanded": opened.has(t.executionSessionId), onClick: (event) => {
|
|
482
|
+
event.stopPropagation();
|
|
483
|
+
toggle(t.executionSessionId);
|
|
484
|
+
} }, /* @__PURE__ */ import_react9.default.createElement(Icon, { name: "chevron", style: { transform: opened.has(t.executionSessionId) ? "rotate(90deg)" : void 0 } })) : t.status === "running" ? /* @__PURE__ */ import_react9.default.createElement(TaskSpinner, { label: `${t.id} 进行中` }) : /* @__PURE__ */ import_react9.default.createElement(Icon, { name: "chat", "data-icon": "chat" }), /* @__PURE__ */ import_react9.default.createElement("button", { className: "tf-session-link", title: `${t.id} · ${STATUS[t.status]} · ${t.title}`, "aria-current": currentSessionId === t.executionSessionId ? "page" : void 0, "aria-expanded": t.children.length ? opened.has(t.executionSessionId) : void 0 }, t.children.length > 0 && t.status === "running" && /* @__PURE__ */ import_react9.default.createElement(TaskSpinner, { label: `${t.id} 进行中` }), /* @__PURE__ */ import_react9.default.createElement("span", { className: "title" }, t.id, " ", t.title), /* @__PURE__ */ import_react9.default.createElement("span", { className: `dot ${t.status}`, role: "img", "aria-label": STATUS[t.status] }))), opened.has(t.executionSessionId) && t.children.length > 0 && /* @__PURE__ */ import_react9.default.createElement("div", { className: "session-children", role: "group" }, render(t.children))));
|
|
485
|
+
const label = `“${view.plan?.title}”的 ${count(nodes)} 个子会话`;
|
|
486
|
+
const rootStatus = Object.values(view.plan?.tasks ?? {}).some((t) => t.status === "running") ? "running" : Object.values(view.plan?.tasks ?? {}).every((t) => ["completed", "cancelled"].includes(t.status)) ? "completed" : "pending";
|
|
487
|
+
return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, /* @__PURE__ */ import_react9.default.createElement("span", { ref: anchor, className: "tf-session-tree-anchor" }), mount && /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, (0, import_react_dom3.createPortal)(/* @__PURE__ */ import_react9.default.createElement("span", { onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react9.default.createElement("button", { type: "button", className: "tf-session-toggle", title: label, "aria-label": `${expanded ? "折叠" : "展开"}${label}`, "aria-expanded": expanded, "aria-controls": groupId, onClick: () => setExpanded((value) => !value) }, /* @__PURE__ */ import_react9.default.createElement(Icon, { name: "chevron", style: { transform: expanded ? "rotate(90deg)" : void 0 } }))), mount.control), (0, import_react_dom3.createPortal)(/* @__PURE__ */ import_react9.default.createElement("span", { className: `dot ${rootStatus}`, role: "img", "aria-label": STATUS[rootStatus] }), mount.status), (0, import_react_dom3.createPortal)(/* @__PURE__ */ import_react9.default.createElement("nav", { id: groupId, className: "tf-session-tree", "aria-label": label, hidden: !expanded, onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react9.default.createElement("div", { className: "session-children" }, render(nodes))), mount.tree)));
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// taskflow-source:src/client/components/quick-replies.jsx
|
|
491
|
+
var import_react10 = __toESM(require("react"));
|
|
492
|
+
function QuickReplies({ api, sessionId, foreground = true, input, inputActions, focus }) {
|
|
493
|
+
const [view, setView] = (0, import_react10.useState)({ phase: "idle", items: [] }), [error, setError] = (0, import_react10.useState)("");
|
|
494
|
+
const request = (0, import_react10.useRef)(() => {
|
|
495
|
+
});
|
|
496
|
+
(0, import_react10.useEffect)(() => {
|
|
497
|
+
let alive = true, busy = false;
|
|
498
|
+
setView({ phase: foreground ? "loading" : "idle", items: [] });
|
|
499
|
+
setError("");
|
|
500
|
+
if (!foreground) return;
|
|
501
|
+
const load = async (refresh = false) => {
|
|
502
|
+
if (busy) return;
|
|
503
|
+
busy = true;
|
|
504
|
+
if (refresh) {
|
|
505
|
+
setView((previous) => ({ ...previous, phase: "loading" }));
|
|
506
|
+
setError("");
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
const next = await api.action(sessionId, "quick-replies", { refresh });
|
|
510
|
+
if (alive) {
|
|
511
|
+
setView(next);
|
|
512
|
+
setError("");
|
|
513
|
+
}
|
|
514
|
+
} catch (e) {
|
|
515
|
+
if (alive) {
|
|
516
|
+
setView((previous) => ({ ...previous, phase: "unavailable" }));
|
|
517
|
+
setError(e.message === "不支持的操作" ? "当前后端尚未加载推荐功能,请重启 DSH。" : "推荐服务连接失败,请稍后重试;若刚更新插件,请重启 DSH。");
|
|
518
|
+
}
|
|
519
|
+
} finally {
|
|
520
|
+
busy = false;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
request.current = load;
|
|
524
|
+
void load();
|
|
525
|
+
const timer = setInterval(load, 1200);
|
|
526
|
+
return () => {
|
|
527
|
+
alive = false;
|
|
528
|
+
clearInterval(timer);
|
|
529
|
+
request.current = () => {
|
|
530
|
+
};
|
|
531
|
+
};
|
|
532
|
+
}, [api, sessionId, foreground]);
|
|
533
|
+
const fill = (item) => {
|
|
534
|
+
try {
|
|
535
|
+
const draft = input?.draft ?? "";
|
|
536
|
+
if (input?.phase && input.phase !== "plain") throw new Error("请先完成当前输入操作,再选择推荐回复。");
|
|
537
|
+
if (inputActions?.insertText && Number.isInteger(input?.draftRev)) {
|
|
538
|
+
if (!inputActions.insertText(`${draft ? "\n" : ""}${item.text}`, { start: draft.length, end: draft.length, draftRev: input.draftRev })) throw new Error("草稿已变化,请重试。");
|
|
539
|
+
} else if (!draft && inputActions?.setDraft) inputActions.setDraft(item.text);
|
|
540
|
+
else throw new Error("请先保留现有草稿,再选择推荐回复。");
|
|
541
|
+
focus?.();
|
|
542
|
+
setError("");
|
|
543
|
+
} catch (e) {
|
|
544
|
+
setError(e.message);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
if (!foreground || view.phase === "idle" && !error) return null;
|
|
548
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", { className: "tf-quick-replies-wrap" }, /* @__PURE__ */ import_react10.default.createElement("nav", { className: "tf-quick-replies", "aria-label": "模型推荐回复" }, view.items?.map((item) => /* @__PURE__ */ import_react10.default.createElement("button", { type: "button", key: item.label, title: item.text, onClick: () => fill(item) }, item.label))), ["loading", "generating", "busy"].includes(view.phase) && /* @__PURE__ */ import_react10.default.createElement("span", { className: "tf-reply-status tf-reply-loading", role: "status", title: view.phase === "busy" ? "等待当前回复完成后生成推荐" : void 0 }, /* @__PURE__ */ import_react10.default.createElement("span", { "aria-hidden": "true" }, /* @__PURE__ */ import_react10.default.createElement(TaskSpinner, null)), /* @__PURE__ */ import_react10.default.createElement("span", null, "正在推荐中...")), (error || view.phase === "unavailable") && /* @__PURE__ */ import_react10.default.createElement("span", { className: "tf-reply-status", role: "status" }, error || view.message, /* @__PURE__ */ import_react10.default.createElement("button", { type: "button", onClick: () => void request.current(true) }, "重试")));
|
|
549
|
+
}
|
|
550
|
+
|
|
202
551
|
// taskflow-source:src/client/styles.css
|
|
203
|
-
var styles_default =
|
|
552
|
+
var styles_default = `/* Host-only adaptations. Component declarations are synced from the PRD. */
|
|
553
|
+
.tf-panel,.tf-tool,.tf-dialog,.tf-session-root,.tf-session-tree,.tf-quick-replies-wrap{--ink:var(--dsw-alias-label-primary,#262626);--secondary:var(--dsw-alias-label-secondary,#666);--muted:var(--dsw-alias-label-tertiary,#999);--line:var(--dsw-alias-border-l2,#eee);--surface:var(--dsw-alias-bg-base,#fff);--hover:var(--dsw-alias-interactive-bg-hover,#f5f5f5);--blue:var(--dsw-alias-state-business-primary,#4d6bfe);--hairline:1px;box-sizing:border-box;color:var(--ink);font:14px var(--dsw-font-family,system-ui,sans-serif);-webkit-font-smoothing:antialiased}
|
|
554
|
+
.tf-panel *,.tf-tool *,.tf-dialog *{box-sizing:border-box}:where(.tf-panel,.tf-tool,.tf-dialog) button{font-family:inherit;color:inherit;cursor:pointer;border:0;background:none}:where(.tf-panel,.tf-tool,.tf-dialog) button:hover{background:var(--hover)}.tf-panel button:disabled,.tf-dialog button:disabled{opacity:.4;cursor:default}.tf-panel button:focus-visible,.tf-tool button:focus-visible,.tf-dialog button:focus-visible{outline:2px solid var(--blue);outline-offset:2px}.tf-panel svg,.tf-tool svg,.tf-dialog svg,.tf-entry svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;vertical-align:middle;flex-shrink:0}
|
|
555
|
+
.tf-panel.tf-panel{height:100%;border:0;overflow:hidden}.tf-panel .tf-task{text-align:left;padding:0;display:block;width:100%;overflow-wrap:anywhere;border-radius:0}.tf-panel .tf-task:hover{background:none}.tf-fold{padding:0;display:inline-grid;place-items:center}.tf-panel .tf-fold svg{width:11px;height:11px}.tf-error{font-size:12px;color:#d33;overflow-wrap:anywhere;padding:8px 16px}.tf-dialog dd{white-space:pre-wrap}.tf-tool.tf-tool{height:100%;width:100%;max-width:none;min-width:0}.tf-tool iframe{display:block;border:0;width:100%;height:430px;background:white}.tf-tool .tool-header>span:first-of-type{white-space:nowrap}.tf-tool .tool-header .iconbtn{margin-left:0}
|
|
556
|
+
.tf-tool-layout{display:grid!important;grid-template-columns:minmax(240px,var(--tf-tool-width,440px)) minmax(320px,1fr)!important;grid-template-rows:auto minmax(0,1fr)!important}.tf-tool-layout>[data-conversation-content]{grid-column:2;grid-row:2;min-width:0}.tf-tool-layout>:not([data-conversation-content]):not(.tf-tool-mount){grid-column:1/-1}.tf-tool-mount{grid-column:1;grid-row:2;min-height:0;min-width:0}.tf-tool-layout.tf-tool-body{grid-template-rows:minmax(0,1fr)!important}.tf-tool-body>[data-conversation-content],.tf-tool-body>.tf-tool-mount{grid-row:1!important}.tf-entry-anchor:empty{display:none}.tf-header-entry-mount{display:inline-flex;align-items:center}.tf-entry{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-width:32px;height:30px;padding:0 8px;border:0;border-radius:7px;background:transparent;color:inherit;font:inherit;font-size:12px;cursor:pointer;-webkit-app-region:no-drag}.tf-entry svg{width:17px;height:17px}.tf-entry:hover{background:rgba(77,107,254,.09)}.tf-entry:focus-visible{outline:2px solid #4d6bfe;outline-offset:2px}.tf-mobile-view{display:none}
|
|
557
|
+
@media(max-width:1250px){.tf-tool-layout{grid-template-columns:minmax(240px,var(--tf-tool-width,440px)) minmax(320px,1fr)!important}.tf-tool-layout .messages{padding:23px 16px}.tf-tool-layout .composer{padding:12px 14px 7px}.tf-tool-layout .suggestions{display:none}.tf-tool-layout .composer-controls .model{display:none}}
|
|
558
|
+
@media(max-width:1080px){.tf-tool-layout{grid-template-columns:minmax(0,1fr)!important}.tf-tool-layout>.tf-tool-mount{grid-row:2;grid-column:1;display:none}.tf-tool-layout>[data-conversation-content]{grid-row:2;grid-column:1}.tf-tool-layout.tf-tool-show-tool>.tf-tool-mount{display:block}.tf-tool-layout.tf-tool-show-tool>[data-conversation-content]{display:none}.tf-mobile-view{display:flex;gap:2px}.tf-mobile-view button{font:inherit;font-size:11px;border:0;padding:4px 6px;border-radius:6px;background:transparent;color:inherit;white-space:nowrap;cursor:pointer}.tf-mobile-view button[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover,#f4f5f7)}}
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
@media(max-width:790px){.tf-tool-layout .tf-tool .tool-content{padding:18px 14px}}
|
|
562
|
+
|
|
563
|
+
@media(prefers-color-scheme:dark){.tf-entry:hover{background:rgba(125,149,255,.14)}.tf-entry:focus-visible{outline-color:#7d95ff}}
|
|
564
|
+
@media(max-width:480px){.tf-entry>span{display:none}}
|
|
565
|
+
|
|
566
|
+
.tf-planning{font-size:12px;color:var(--secondary);padding:8px 16px;overflow-wrap:anywhere}
|
|
567
|
+
|
|
568
|
+
/* Tool surface layout is user controlled; no host nodes are moved. */
|
|
569
|
+
.tf-tool-mount{position:relative}.tf-floating-mount{display:none!important}
|
|
570
|
+
.tf-tool.tf-tool-docked{position:relative;overflow:visible}
|
|
571
|
+
.tf-tool.tf-tool-floating{position:fixed;z-index:1200;border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 48px #0003;overflow:visible;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);background:var(--surface)}
|
|
572
|
+
.tf-tool-floating>.tool-header{cursor:move;touch-action:none;border-radius:12px 12px 0 0}
|
|
573
|
+
.tf-tool-floating>.tool-footer{border-radius:0 0 12px 12px;background:var(--surface)}
|
|
574
|
+
.tf-tool .tf-tool-resizer{position:absolute;right:-4px;top:0;bottom:0;width:8px;cursor:col-resize;touch-action:none;z-index:3;border-radius:4px}
|
|
575
|
+
.tf-tool-resizer:hover,.tf-tool-resizer:focus-visible{background:var(--blue);outline:0;opacity:.6}
|
|
576
|
+
.tf-tool-corner{position:absolute;bottom:0;right:0;width:16px;height:16px;cursor:nwse-resize;touch-action:none;z-index:4;background:linear-gradient(135deg,transparent 60%,var(--muted) 61%,transparent 68%,var(--muted) 69%,transparent 77%);border-radius:0 0 8px}
|
|
577
|
+
.tf-tool-drag-shield{position:absolute;inset:38px 4px 0 0;z-index:2;cursor:inherit}.tf-tool-dragging{user-select:none}
|
|
578
|
+
.tf-tool-layout.tf-tool-show-tool:has(>.tf-floating-mount)>[data-conversation-content]{display:revert}
|
|
579
|
+
.tf-blocked-reason{margin:6px 0 0 26px;font-size:11px;line-height:1.6;color:var(--secondary);white-space:pre-wrap;overflow-wrap:anywhere;max-height:7em;overflow:auto}
|
|
580
|
+
.tf-feedback{font-size:12px;padding:8px 16px;color:var(--blue);overflow-wrap:anywhere}
|
|
581
|
+
.tf-session-tree-anchor:empty{display:none}.tf-session-tree-mount{width:100%;min-width:0;flex-shrink:0}
|
|
582
|
+
.tf-session-tree{padding:0 4px 0 calc(var(--dsh-workspace-indent,0px));min-width:0}.tf-session-tree[hidden]{display:none}
|
|
583
|
+
.tf-session-root.tf-session-root{border:0;box-sizing:border-box;cursor:pointer;padding-left:calc(9px + var(--dsh-workspace-indent,0px));line-height:20px}
|
|
584
|
+
.tf-session-root[aria-selected=true]{background:var(--hover)}
|
|
585
|
+
.tf-session-native-leading,.tf-session-native-trailing{display:none!important}.tf-session-native-title{font:inherit!important;flex:1}
|
|
586
|
+
.tf-session-root-status{display:inline-flex;align-items:center;flex:none}.tf-session-root-status .dot{width:5px;height:5px}
|
|
587
|
+
.tf-session-toggle-mount{display:inline-flex;align-items:center;flex:none}.tf-session-toggle{display:inline-grid;place-items:center;border:0;background:none;color:var(--muted);cursor:pointer;padding:0;width:16px;height:20px}
|
|
588
|
+
.tf-session-toggle svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}.tf-session-toggle:focus-visible{outline:2px solid var(--blue)}
|
|
589
|
+
.tf-session-path{display:flex;flex-wrap:wrap;align-items:center;gap:5px;font-size:11px;color:var(--secondary);margin-bottom:8px}
|
|
590
|
+
.tf-session-path button{font:inherit;color:var(--blue);border:0;background:none;cursor:pointer;padding:2px}.tf-session-path [aria-current]{overflow-wrap:anywhere}
|
|
591
|
+
.tf-session-line{box-sizing:border-box;color:var(--ink);cursor:pointer}.tf-session-line:hover{background:var(--hover)}
|
|
592
|
+
.tf-session-tree button{border:0;background:none;color:inherit;font:inherit;cursor:pointer;text-align:left;min-width:0}
|
|
593
|
+
.tf-session-tree button:focus-visible{outline:2px solid var(--blue);border-radius:4px}
|
|
594
|
+
.tf-session-line svg{fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
|
|
595
|
+
.tf-session-arrow{display:grid;place-items:center;width:16px;flex:none;padding:0}.tf-session-link{display:flex;align-items:center;gap:6px;flex:1;padding:0;height:100%;overflow:hidden}.tf-session-link>span.title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.tf-session-link .dot{width:5px;height:5px}
|
|
596
|
+
@media(max-width:1080px){.tf-tool-docked>.tf-tool-resizer{display:none}}
|
|
597
|
+
|
|
598
|
+
.tf-panel .task-box.running{border:0;background:none;box-shadow:none}.tf-task-spinner{animation:tf-task-spin .85s linear infinite;flex:none;fill:none;stroke:currentColor;stroke-width:2;color:var(--blue,#4d6bfe)}.tf-panel .task-box .tf-task-spinner{width:17px;height:17px}.tf-session-link .tf-task-spinner{width:13px;height:13px;opacity:1}
|
|
599
|
+
@keyframes tf-task-spin{to{transform:rotate(360deg)}}
|
|
600
|
+
@media(prefers-reduced-motion:reduce){.tf-task-spinner{animation:none}}
|
|
601
|
+
.tf-document-view{min-width:0}.tf-document-source{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.7 ui-monospace,monospace}.tf-markdown-preview{font-size:14px;line-height:1.8;overflow-wrap:anywhere}.tf-markdown-preview h1{font-size:24px}.tf-markdown-preview h2{font-size:20px}.tf-markdown-preview h3{font-size:17px}.tf-markdown-preview h1,.tf-markdown-preview h2,.tf-markdown-preview h3{line-height:1.4;margin:1em 0 .5em}.tf-markdown-preview pre{white-space:pre;overflow:auto;padding:12px;background:var(--hover);border:1px solid var(--line);border-radius:8px;font:12px/1.7 ui-monospace,monospace}.tf-markdown-preview :not(pre)>code{padding:2px 4px;background:var(--hover);border-radius:4px;font-size:12px}.tf-markdown-preview blockquote{margin:12px 0;padding:0 12px;border-left:3px solid var(--line);color:var(--secondary)}.tf-markdown-preview a{color:var(--blue)}.tf-markdown-table{max-width:100%;overflow:auto}.tf-markdown-table table{width:100%;border-collapse:collapse;font-size:12px}.tf-markdown-table td,.tf-markdown-table th{padding:6px 8px;border:1px solid var(--line);text-align:left}.tf-markdown-preview input[type=checkbox]{pointer-events:none}.tf-markdown-image{font-size:12px;color:var(--secondary)}
|
|
602
|
+
|
|
603
|
+
.tf-quick-replies-wrap{min-width:0;font:inherit}.tf-quick-replies:empty{display:none}.tf-quick-replies button{font-family:inherit;background:transparent;cursor:pointer;line-height:1.4}.tf-quick-replies button:hover{background:var(--hover);color:var(--ink)}.tf-quick-replies button:focus-visible{outline:2px solid var(--blue);outline-offset:2px}.tf-reply-status{display:block;font-size:11px;color:var(--secondary);margin-bottom:8px}.tf-reply-status button{border:0;background:none;color:var(--blue);font:inherit;cursor:pointer;margin-left:6px}
|
|
604
|
+
.tf-checklist-root{display:flex;flex:1;flex-direction:column;min-width:0;min-height:0;height:100%}
|
|
605
|
+
/* Keep the compact width local to the selected normal checklist. Fullscreen,
|
|
606
|
+
floating tabs, other plugins and the host's saved width remain untouched. */
|
|
607
|
+
:has(>[data-rightbar-col] [data-tf-compact-checklist]):not([data-rightbar-collapsed]):not([data-rightbar-fullscreen]){grid-template-columns:var(--tf-sidebar-track) minmax(400px,1fr) var(--tf-checklist-width,300px)!important}
|
|
608
|
+
[data-tf-compact-checklist][data-sidebar-right-panel="push"]{width:var(--tf-checklist-width,300px)!important;--dsh-sidebar-width:var(--tf-checklist-width,300px)!important}
|
|
609
|
+
:has(>[data-rightbar-col] [data-tf-compact-checklist])>[data-side="rightbar"]{display:none}
|
|
610
|
+
.tf-checklist-resizer{position:absolute;left:0;top:0;bottom:0;width:6px;z-index:30;pointer-events:auto;cursor:col-resize;touch-action:none}
|
|
611
|
+
.tf-checklist-resizer:hover,.tf-checklist-resizer:focus-visible{background:var(--dsw-alias-state-business-primary,#4d6bfe);opacity:.5;outline:0}
|
|
612
|
+
.tf-checklist-resize-shield{position:fixed;inset:0;z-index:1205;pointer-events:auto;cursor:col-resize;user-select:none;touch-action:none}
|
|
613
|
+
.tf-quick-replies-wrap{width:100%;max-width:780px;margin:0 auto;text-align:left}
|
|
614
|
+
.tf-reply-loading{display:flex;align-items:center;justify-content:flex-start;gap:5px;line-height:18px}
|
|
615
|
+
.tf-reply-loading>span:first-child{display:inline-flex;align-items:center}
|
|
616
|
+
.tf-reply-loading .tf-task-spinner{width:12px;height:12px;stroke-width:2}
|
|
617
|
+
.tf-tool .tool-content.tf-tool-documents{display:flex;flex-direction:column;gap:8px;padding:4px;overscroll-behavior:contain}
|
|
618
|
+
.tf-tool-documents>.tf-document-view{position:relative;display:flex;flex-direction:column;flex:0 0 max(300px,100%);min-height:0;min-width:0}
|
|
619
|
+
.tf-tool-documents>.tf-document-view:only-child{flex:1;overflow:hidden}
|
|
620
|
+
.tf-document-actions{display:flex;align-items:center;gap:8px;padding:8px;flex-shrink:0}.tf-document-actions .tf-error{margin:0;padding:0;flex:1}.tf-preview-loading{position:absolute;inset:8px auto auto 8px;margin:0;font-size:12px;z-index:1;color:var(--secondary)}
|
|
621
|
+
.tf-document-preview-target{flex:1;min-height:0;min-width:0;border:0;border-radius:4px;overflow:hidden}
|
|
622
|
+
.tf-host-preview.tf-host-preview{position:fixed!important;border:0!important;border-radius:8px!important;box-shadow:none!important;overflow:hidden!important}
|
|
623
|
+
.tf-host-preview [data-dockkit-float-grip],.tf-host-preview>[data-dockkit-float-resize]{display:none!important}
|
|
624
|
+
.tf-host-preview [data-textpreview-path]{display:none!important}
|
|
625
|
+
.tf-execution-record{margin:12px 0 18px;border:1px solid var(--dsw-alias-border-light,var(--border,#e5e7eb));border-radius:12px;overflow:hidden;color:inherit;font:inherit}
|
|
626
|
+
.tf-record-heading{display:flex;align-items:center;flex-wrap:wrap;gap:8px;width:100%;padding:10px 14px;border:0;background:var(--dsw-alias-bg-container-secondary,rgba(127,127,127,.04));color:inherit;font:inherit;font-size:13px;text-align:left;cursor:pointer}
|
|
627
|
+
.tf-record-heading strong{font-weight:600}.tf-record-marker{color:var(--dsw-alias-state-business-primary,#4d6bfe)}.tf-record-task,.tf-record-duration,.tf-record-model{color:var(--dsw-alias-text-secondary,var(--secondary,#747983));font-size:12px}.tf-record-chevron{margin-left:auto}
|
|
628
|
+
.tf-record-body{padding:4px 16px 14px;min-width:0;font-size:14px;line-height:1.7;overflow-wrap:anywhere}.tf-record-model{margin:6px 0}.tf-record-body .tf-markdown-preview{padding:0;font:inherit}.tf-record-body pre{overflow:auto;max-width:100%;padding:12px;border-radius:8px;background:rgba(127,127,127,.07);font-size:12px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
629
|
+
.tf-record-body .tf-markdown-table{overflow:auto}.tf-record-body table{border-collapse:collapse;width:100%}.tf-record-body th,.tf-record-body td{padding:6px 10px;border:1px solid var(--border,#e5e7eb);text-align:left}
|
|
630
|
+
`;
|
|
204
631
|
|
|
205
632
|
// taskflow-source:src/client/generated/prototype.css
|
|
206
|
-
var prototype_default = '/* Generated from docs/prototype/dsh-taskflow-prd.html.\n * Original DeepSeek UI styles: MIT; see licenses/DeepSeek-MIT.txt.\n * Run npm run build to resync. */\n:where(.tf-panel,.tf-tool,.tf-dialog) .iconbtn{display:inline-grid;place-items:center;width:28px;height:28px;border-radius:8px;color:var(--secondary);padding:0;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .iconbtn svg{width:16px;height:16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:36px;border:0;border-radius:12px;padding:0 14px;background:transparent;color:var(--ink);font-size:14px;line-height:22px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.small{min-height:28px;height:auto;padding:4px 10px;border-radius:8px;font-size:12px;line-height:18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.outline{box-shadow:inset 0 0 0 var(--hairline) var(--dsw-alias-border-l3)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.primary{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.primary:hover{background:var(--dsw-alias-button-primary-hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.blue{color:var(--blue);background:var(--dsw-specific-bubble)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.danger{color:var(--dsw-alias-state-danger-primary,#ec1313)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn svg{width:16px;height:16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .subtle{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill{display:inline-flex;align-items:center;gap:5px;background:var(--hover);color:var(--secondary);font-size:11px;line-height:18px;padding:2px 7px;border-radius:6px;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill.blue{color:var(--blue);background:var(--dsw-specific-bubble)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill.success{color:var(--dsw-alias-state-success-primary,#168349);background:var(--dsw-static-green-500-a08)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot{width:6px;height:6px;border-radius:50%;background:var(--muted);display:inline-block;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot.running{background:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot.completed{background:var(--dsw-static-green-500)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dot.awaiting_children{background:var(--dsw-static-amber-500)}\n.tf-tool{display:flex;flex-direction:column;flex:0 0 48%;max-width:650px;min-width:300px;min-height:0;border-right:1px solid var(--dsw-alias-border-l3);background:var(--surface);order:-1}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header{height:38px;flex-shrink:0;display:flex;align-items:center;gap:7px;padding:0 10px;font-size:12px;border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header svg{width:15px;height:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header .binding{font-size:11px;color:var(--muted);margin-left:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-context{height:38px;flex-shrink:0;display:flex;align-items:center;gap:6px;padding:0 12px;font-size:11px;color:var(--muted);border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-content{flex:1;min-height:0;overflow:auto;padding:20px 16px;background:var(--dsw-specific-sidebar-fill);scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-footer{padding:8px 12px;font-size:10px;color:var(--muted);border-top:1px solid var(--line);line-height:1.7}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-window{border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--surface)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar{height:42px;display:flex;align-items:center;gap:5px;border-bottom:1px solid var(--line);padding:0 8px;background:var(--dsw-specific-sidebar-fill)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar .iconbtn{width:22px;height:25px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar .iconbtn svg{width:13px;height:13px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address{border:1px solid var(--line);border-radius:8px;background:var(--surface);height:26px;display:flex;align-items:center;gap:5px;flex:1;min-width:0;padding:0 8px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address svg{width:11px;height:11px;color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address input{font-size:10px;background:none;border:0;outline:0;min-width:0;width:100%;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .code-window{border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .file-tab{background:var(--dsw-specific-sidebar-fill);padding:11px 12px;font-size:11px;border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .code-window pre{font:12px/2 Consolas,var(--dsw-font-family);white-space:pre-wrap;margin:0;padding:18px 14px;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .terminal{background:var(--dsw-static-neutral-bluish-950);color:var(--dsw-static-neutral-bluish-100);padding:18px 15px;border-radius:8px;min-height:250px;font:11px/2 Consolas,var(--dsw-font-family);white-space:pre-wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card{border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:18px;margin-bottom:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card h3{font-size:15px;margin:12px 0;font-weight:500}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card p{font-size:12px;line-height:1.9;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-caption{font-size:10px;line-height:1.8;color:var(--muted);margin:12px 0}\n.tf-panel{grid-column:3;grid-row:2;display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--surface);border-left:1px solid var(--dsw-alias-border-l3)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs{display:flex;align-items:center;gap:7px;min-height:38px;height:38px;padding:0 10px;border-bottom:1px solid var(--line);font-size:12px;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .tab{display:flex;align-items:center;gap:5px;border-bottom:2px solid var(--ink);height:38px;padding:0 6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .tab svg{width:14px;height:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .iconbtn{margin-left:auto}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:16px 18px 14px;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading h2{font-size:15px;font-weight:500;line-height:1.5;margin:0 0 8px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading p{font-size:12px;color:var(--muted);margin:0;line-height:1.8}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-label{display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--muted);margin-top:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-label strong{font-weight:400;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-track{height:3px;background:var(--hover);border-radius:3px;overflow:hidden;margin-top:9px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-track span{background:var(--blue);height:100%;display:block;transition:width .2s}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 16px 12px;display:flex;align-items:center;gap:7px;border-bottom:1px solid var(--line);flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments{display:flex;flex:1;padding:3px;border-radius:8px;background:var(--hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments button{flex:1;padding:4px 5px;border-radius:6px;color:var(--muted);font-size:11px;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments button.selected{background:var(--surface);color:var(--ink);box-shadow:0 1px 3px #00000008}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls select{font-size:11px;width:72px;padding:6px 2px;border:0;background:transparent;color:var(--secondary);border-radius:6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-list{overflow:auto;flex:1;min-height:0;padding:10px 10px 16px;scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row{margin:2px 0;border-radius:8px;padding:11px 8px;cursor:pointer;border:1px solid transparent}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row:hover{background:var(--hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.focused{background:var(--dsw-specific-bubble);border-color:var(--dsw-static-deepseek-100)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.cancelled{opacity:.55}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.context-only{background:transparent}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.context-only .task-title{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-line{display:flex;gap:8px;align-items:flex-start}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box{width:15px;height:15px;display:grid;place-items:center;border:1px solid var(--dsw-alias-border-l4);border-radius:4px;flex-shrink:0;margin-top:3px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box svg{width:11px;height:11px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.completed{background:var(--blue);border-color:var(--blue);color:var(--dsw-static-neutral-00)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.running{border-color:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.running:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-copy{flex:1;min-width:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:13px;line-height:1.7;font-weight:400}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.completed .task-title{color:var(--muted);text-decoration:line-through;text-decoration-color:var(--dsw-alias-border-l4)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta{font-size:10px;color:var(--muted);display:flex;align-items:center;gap:5px;margin-top:4px;flex-wrap:wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta code{font:10px Consolas,var(--dsw-font-family)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row .iconbtn{height:22px;width:20px;margin-right:-3px;color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row .iconbtn svg{width:14px;height:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status{display:flex;align-items:center;gap:7px;margin:8px 0 0 23px;font-size:11px;color:var(--muted);flex-wrap:wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status .pill{font-size:10px;padding:1px 5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status .btn{font-size:10px;min-height:23px;padding:2px 7px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .child-tasks{border-left:1px solid var(--line);margin-left:15px;padding-left:5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom{padding:12px 16px;border-top:1px solid var(--line);flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom .btn{width:100%;font-size:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom p{text-align:center;font-size:10px;color:var(--muted);margin:9px 0 0;line-height:1.8}\n:where(.tf-panel,.tf-tool,.tf-dialog) .empty{padding:35px 18px;color:var(--muted);font-size:13px;line-height:1.9;text-align:center}\n:where(.tf-panel,.tf-tool,.tf-dialog) .empty svg{width:24px;height:24px;margin-bottom:10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .saved:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--dsw-static-green-500);display:inline-block;vertical-align:2px;margin-right:5px}\n.tf-dialog{width:min(590px,calc(100vw - 28px));max-height:88dvh;padding:0;border:1px solid var(--line);border-radius:20px;background:var(--surface);color:var(--ink);box-shadow:0 10px 45px #00000020}\n.tf-dialog::backdrop{background:#00000040;backdrop-filter:blur(2px)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head{padding:21px 24px 17px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head h2{font-size:17px;line-height:1.6;font-weight:500;margin:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head small{display:block;font-size:10px;color:var(--muted);margin-bottom:5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-body{padding:7px 24px 20px;max-height:calc(88dvh - 145px);overflow:auto;scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions{border-top:1px solid var(--line);display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:7px;padding:13px 24px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice{background:var(--hover);border-radius:12px;padding:12px 14px;margin:15px 0;font-size:12px;line-height:1.9;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice.blue{background:var(--dsw-specific-bubble);color:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice.warn{background:var(--dsw-static-amber-100);color:#9a6c25}\nbody[data-ds-dark-theme] :where(.tf-panel,.tf-tool,.tf-dialog) .notice.warn{background:var(--dsw-static-amber-900);color:var(--dsw-static-amber-400)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field{display:block;color:var(--secondary);font-size:12px;margin:17px 0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field input,:where(.tf-panel,.tf-tool,.tf-dialog) .field textarea,:where(.tf-panel,.tf-tool,.tf-dialog) .field select{display:block;width:100%;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--surface);color:var(--ink);font-size:13px;line-height:1.8;padding:8px 10px;margin-top:7px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field textarea{resize:vertical;min-height:85px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field small{display:block;color:var(--muted);font-size:11px;line-height:1.8;margin-top:6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv{display:grid;grid-template-columns:86px 1fr;gap:12px;font-size:12px;line-height:1.9;margin:21px 0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv dt{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv dd{margin:0;overflow-wrap:anywhere}\n:where(.tf-panel,.tf-tool,.tf-dialog) .history{padding:12px 0;border-top:1px solid var(--line);font-size:12px;line-height:1.9}\n:where(.tf-panel,.tf-tool,.tf-dialog) .history time{display:block;font-size:10px;color:var(--muted);margin-bottom:4px}\n@media(min-width:1700px){.tf-tool{flex-basis:49%}\n}\n@media(max-width:1250px){:where(.tf-panel,.tf-tool,.tf-dialog) .tool-content{padding:14px 10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:12px}\n}\n@media(max-width:1080px){:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 12px 12px}\n}\n@media(max-width:790px){.tf-tool{min-width:0;max-width:none;flex:1}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header .binding{font-size:10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 18px 14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-list{padding:0 16px 16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:13px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta{font-size:11px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row{padding:12px 10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom{padding:12px 20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head{padding:18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-body{padding:5px 18px 20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions{padding:12px 18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions .btn{font-size:12px;padding:0 10px}\n}\n';
|
|
633
|
+
var prototype_default = '/* Generated from docs/prototype/dsh-taskflow-prd.html.\n * Original DeepSeek UI styles: MIT; see licenses/DeepSeek-MIT.txt.\n * Run npm run build to resync. */\n:where(.tf-panel,.tf-tool,.tf-dialog) .iconbtn{display:inline-grid;place-items:center;width:28px;height:28px;border-radius:8px;color:var(--secondary);padding:0;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .iconbtn svg{width:16px;height:16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:36px;border:0;border-radius:12px;padding:0 14px;background:transparent;color:var(--ink);font-size:14px;line-height:22px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.small{min-height:28px;height:auto;padding:4px 10px;border-radius:8px;font-size:12px;line-height:18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.outline{box-shadow:inset 0 0 0 var(--hairline) var(--dsw-alias-border-l3)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.primary{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.primary:hover{background:var(--dsw-alias-button-primary-hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.blue{color:var(--blue);background:var(--dsw-specific-bubble)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn.danger{color:var(--dsw-alias-state-danger-primary,#ec1313)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .btn svg{width:16px;height:16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .subtle{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill{display:inline-flex;align-items:center;gap:5px;background:var(--hover);color:var(--secondary);font-size:11px;line-height:18px;padding:2px 7px;border-radius:6px;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill.blue{color:var(--blue);background:var(--dsw-specific-bubble)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .pill.success{color:var(--dsw-alias-state-success-primary,#168349);background:var(--dsw-static-green-500-a08)}\n:where(.tf-panel,.tf-tool,.tf-dialog,.tf-session-tree,.tf-session-root) .dot{width:6px;height:6px;border-radius:50%;background:var(--muted);display:inline-block;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog,.tf-session-tree,.tf-session-root) .dot.running{background:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog,.tf-session-tree,.tf-session-root) .dot.completed{background:var(--dsw-static-green-500)}\n:where(.tf-panel,.tf-tool,.tf-dialog,.tf-session-tree,.tf-session-root) .dot.awaiting_children{background:var(--dsw-static-amber-500)}\n:is(.tf-session-root,.tf-session-tree .session-row){display:flex;align-items:center;width:calc(100% - 6px);height:36px;border-radius:12px;text-align:left;margin:3px;gap:6px;padding:0 9px;font-size:13px;min-width:0}\n:is(.tf-session-root,.tf-session-tree .session-row).selected{background:var(--hover)}\n:is(.tf-session-root,.tf-session-tree .session-row) svg{width:16px;height:16px;color:var(--muted)}\n:is(.tf-session-root,.tf-session-tree .session-row) span.title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}\n.tf-session-tree .session-children{padding-left:14px;position:relative;margin-left:8px}\n.tf-session-tree .session-children:before{content:"";position:absolute;left:6px;top:3px;bottom:3px;width:1px;background:var(--line)}\n:is(.tf-session-root,.tf-session-tree .session-row) .dot{width:5px;height:5px}\n.tf-quick-replies{display:flex;align-items:center;gap:7px;flex-wrap:wrap;max-width:780px;margin:0 auto 11px}\n.tf-quick-replies button{font-size:11px;color:var(--secondary);border:1px solid var(--line);border-radius:8px;padding:5px 8px}\n.tf-tool{display:flex;flex-direction:column;flex:0 0 48%;max-width:650px;min-width:300px;min-height:0;border-right:1px solid var(--dsw-alias-border-l3);background:var(--surface);order:-1}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header{height:38px;flex-shrink:0;display:flex;align-items:center;gap:7px;padding:0 10px;font-size:12px;border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header svg{width:15px;height:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header .binding{font-size:11px;color:var(--muted);margin-left:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-context{height:38px;flex-shrink:0;display:flex;align-items:center;gap:6px;padding:0 12px;font-size:11px;color:var(--muted);border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-content{flex:1;min-height:0;overflow:auto;padding:20px 16px;background:var(--dsw-specific-sidebar-fill);scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-footer{padding:8px 12px;font-size:10px;color:var(--muted);border-top:1px solid var(--line);line-height:1.7}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-window{border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--surface)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar{height:42px;display:flex;align-items:center;gap:5px;border-bottom:1px solid var(--line);padding:0 8px;background:var(--dsw-specific-sidebar-fill)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar .iconbtn{width:22px;height:25px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .browser-toolbar .iconbtn svg{width:13px;height:13px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address{border:1px solid var(--line);border-radius:8px;background:var(--surface);height:26px;display:flex;align-items:center;gap:5px;flex:1;min-width:0;padding:0 8px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address svg{width:11px;height:11px;color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .address input{font-size:10px;background:none;border:0;outline:0;min-width:0;width:100%;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .code-window{border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .file-tab{background:var(--dsw-specific-sidebar-fill);padding:11px 12px;font-size:11px;border-bottom:1px solid var(--line)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .code-window pre{font:12px/2 Consolas,var(--dsw-font-family);white-space:pre-wrap;margin:0;padding:18px 14px;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .terminal{background:var(--dsw-static-neutral-bluish-950);color:var(--dsw-static-neutral-bluish-100);padding:18px 15px;border-radius:8px;min-height:250px;font:11px/2 Consolas,var(--dsw-font-family);white-space:pre-wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card{border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:18px;margin-bottom:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card h3{font-size:15px;margin:12px 0;font-weight:500}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plugin-card p{font-size:12px;line-height:1.9;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-caption{font-size:10px;line-height:1.8;color:var(--muted);margin:12px 0}\n.tf-panel{grid-column:3;grid-row:2;display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--surface);border-left:1px solid var(--dsw-alias-border-l3)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs{display:flex;align-items:center;gap:7px;min-height:38px;height:38px;padding:0 10px;border-bottom:1px solid var(--line);font-size:12px;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .tab{display:flex;align-items:center;gap:5px;border-bottom:2px solid var(--ink);height:38px;padding:0 6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .tab svg{width:14px;height:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-tabs .iconbtn{margin-left:auto}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:16px 18px 14px;flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading h2{font-size:15px;font-weight:500;line-height:1.5;margin:0 0 8px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading p{font-size:12px;color:var(--muted);margin:0;line-height:1.8}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-label{display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--muted);margin-top:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-label strong{font-weight:400;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-track{height:3px;background:var(--hover);border-radius:3px;overflow:hidden;margin-top:9px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .progress-track span{background:var(--blue);height:100%;display:block;transition:width .2s}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 16px 12px;display:flex;align-items:center;gap:7px;border-bottom:1px solid var(--line);flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments{display:flex;flex:1;padding:3px;border-radius:8px;background:var(--hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments button{flex:1;padding:4px 5px;border-radius:6px;color:var(--muted);font-size:11px;white-space:nowrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .segments button.selected{background:var(--surface);color:var(--ink);box-shadow:0 1px 3px #00000008}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls select{font-size:11px;width:72px;padding:6px 2px;border:0;background:transparent;color:var(--secondary);border-radius:6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-list{overflow:auto;flex:1;min-height:0;padding:10px 10px 16px;scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row{margin:2px 0;border-radius:8px;padding:11px 8px;cursor:pointer;border:1px solid transparent}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row:hover{background:var(--hover)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.focused{background:var(--dsw-specific-bubble);border-color:var(--dsw-static-deepseek-100)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.cancelled{opacity:.55}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.context-only{background:transparent}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.context-only .task-title{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-line{display:flex;gap:8px;align-items:flex-start}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box{width:15px;height:15px;display:grid;place-items:center;border:1px solid var(--dsw-alias-border-l4);border-radius:4px;flex-shrink:0;margin-top:3px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box svg{width:11px;height:11px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.completed{background:var(--blue);border-color:var(--blue);color:var(--dsw-static-neutral-00)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.running{border-color:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-box.running:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-copy{flex:1;min-width:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:13px;line-height:1.7;font-weight:400}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row.completed .task-title{color:var(--muted);text-decoration:line-through;text-decoration-color:var(--dsw-alias-border-l4)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta{font-size:10px;color:var(--muted);display:flex;align-items:center;gap:5px;margin-top:4px;flex-wrap:wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta code{font:10px Consolas,var(--dsw-font-family)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row .iconbtn{height:22px;width:20px;margin-right:-3px;color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row .iconbtn svg{width:14px;height:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status{display:flex;align-items:center;gap:7px;margin:8px 0 0 23px;font-size:11px;color:var(--muted);flex-wrap:wrap}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status .pill{font-size:10px;padding:1px 5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-status .btn{font-size:10px;min-height:23px;padding:2px 7px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .child-tasks{border-left:1px solid var(--line);margin-left:15px;padding-left:5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom{padding:12px 16px;border-top:1px solid var(--line);flex-shrink:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom .btn{width:100%;font-size:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom p{text-align:center;font-size:10px;color:var(--muted);margin:9px 0 0;line-height:1.8}\n:where(.tf-panel,.tf-tool,.tf-dialog) .empty{padding:35px 18px;color:var(--muted);font-size:13px;line-height:1.9;text-align:center}\n:where(.tf-panel,.tf-tool,.tf-dialog) .empty svg{width:24px;height:24px;margin-bottom:10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .saved:before{content:"";width:5px;height:5px;border-radius:50%;background:var(--dsw-static-green-500);display:inline-block;vertical-align:2px;margin-right:5px}\n.tf-dialog{width:min(590px,calc(100vw - 28px));max-height:88dvh;padding:0;border:1px solid var(--line);border-radius:20px;background:var(--surface);color:var(--ink);box-shadow:0 10px 45px #00000020}\n.tf-dialog::backdrop{background:#00000040;backdrop-filter:blur(2px)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head{padding:21px 24px 17px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:12px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head h2{font-size:17px;line-height:1.6;font-weight:500;margin:0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head small{display:block;font-size:10px;color:var(--muted);margin-bottom:5px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-body{padding:7px 24px 20px;max-height:calc(88dvh - 145px);overflow:auto;scrollbar-width:thin}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions{border-top:1px solid var(--line);display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:7px;padding:13px 24px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice{background:var(--hover);border-radius:12px;padding:12px 14px;margin:15px 0;font-size:12px;line-height:1.9;color:var(--secondary)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice.blue{background:var(--dsw-specific-bubble);color:var(--blue)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .notice.warn{background:var(--dsw-static-amber-100);color:#9a6c25}\nbody[data-ds-dark-theme] :where(.tf-panel,.tf-tool,.tf-dialog) .notice.warn{background:var(--dsw-static-amber-900);color:var(--dsw-static-amber-400)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field{display:block;color:var(--secondary);font-size:12px;margin:17px 0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field input,:where(.tf-panel,.tf-tool,.tf-dialog) .field textarea,:where(.tf-panel,.tf-tool,.tf-dialog) .field select{display:block;width:100%;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--surface);color:var(--ink);font-size:13px;line-height:1.8;padding:8px 10px;margin-top:7px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field textarea{resize:vertical;min-height:85px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .field small{display:block;color:var(--muted);font-size:11px;line-height:1.8;margin-top:6px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv{display:grid;grid-template-columns:86px 1fr;gap:12px;font-size:12px;line-height:1.9;margin:21px 0}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv dt{color:var(--muted)}\n:where(.tf-panel,.tf-tool,.tf-dialog) .detail-kv dd{margin:0;overflow-wrap:anywhere}\n:where(.tf-panel,.tf-tool,.tf-dialog) .history{padding:12px 0;border-top:1px solid var(--line);font-size:12px;line-height:1.9}\n:where(.tf-panel,.tf-tool,.tf-dialog) .history time{display:block;font-size:10px;color:var(--muted);margin-bottom:4px}\n@media(min-width:1700px){.tf-tool{flex-basis:49%}\n}\n@media(max-width:1250px){:where(.tf-panel,.tf-tool,.tf-dialog) .tool-content{padding:14px 10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:12px}\n}\n@media(max-width:1080px){:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:15px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 12px 12px}\n}\n@media(max-width:790px){.tf-quick-replies{gap:5px}\n.tf-quick-replies button{font-size:10px;padding:4px 6px}\n.tf-tool{min-width:0;max-width:none;flex:1}\n:where(.tf-panel,.tf-tool,.tf-dialog) .tool-header .binding{font-size:10px}\n:is(.tf-session-root,.tf-session-tree .session-row){height:40px;font-size:14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-heading{padding:20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-controls{padding:0 18px 14px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-list{padding:0 16px 16px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-title{font-size:13px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-meta{font-size:11px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .task-row{padding:12px 10px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .plan-bottom{padding:12px 20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-head{padding:18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-body{padding:5px 18px 20px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions{padding:12px 18px}\n:where(.tf-panel,.tf-tool,.tf-dialog) .dialog-actions .btn{font-size:12px;padding:0 10px}\n}\n';
|
|
634
|
+
|
|
635
|
+
// taskflow-source:src/client/hooks/use-header-entry-target.mjs
|
|
636
|
+
var import_react11 = require("react");
|
|
637
|
+
function useHeaderEntryTarget(anchor) {
|
|
638
|
+
const [target, setTarget] = (0, import_react11.useState)(null);
|
|
639
|
+
(0, import_react11.useEffect)(() => {
|
|
640
|
+
const header = anchor.current?.closest("header");
|
|
641
|
+
if (!header) return;
|
|
642
|
+
const node = document.createElement("span");
|
|
643
|
+
node.className = "tf-header-entry-mount";
|
|
644
|
+
const attach = () => {
|
|
645
|
+
const progress2 = header.querySelector("[data-conversation-header-corner] [data-tp-entry]");
|
|
646
|
+
if (progress2?.parentElement) {
|
|
647
|
+
if (progress2.nextElementSibling !== node) progress2.after(node);
|
|
648
|
+
setTarget((current) => current === node ? current : node);
|
|
649
|
+
} else {
|
|
650
|
+
node.remove();
|
|
651
|
+
setTarget((current) => current === null ? current : null);
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const observer = new MutationObserver(attach);
|
|
655
|
+
observer.observe(header, { childList: true, subtree: true });
|
|
656
|
+
attach();
|
|
657
|
+
return () => {
|
|
658
|
+
observer.disconnect();
|
|
659
|
+
node.remove();
|
|
660
|
+
};
|
|
661
|
+
}, [anchor]);
|
|
662
|
+
return target;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// taskflow-source:src/client/embedded-preview.mjs
|
|
666
|
+
function embedPreview({ sidebar, sessionId, tabId, container }) {
|
|
667
|
+
const doc = container.ownerDocument, win = doc.defaultView;
|
|
668
|
+
let frame, pane, host, hostLayer, disposed = false;
|
|
669
|
+
const previous = /* @__PURE__ */ new Map();
|
|
670
|
+
const set = (name, value) => {
|
|
671
|
+
if (!previous.has(name)) previous.set(name, [pane.style.getPropertyValue(name), pane.style.getPropertyPriority(name)]);
|
|
672
|
+
if (pane.style.getPropertyValue(name) !== value || pane.style.getPropertyPriority(name) !== "important") pane.style.setProperty(name, value, "important");
|
|
673
|
+
};
|
|
674
|
+
const restore = () => {
|
|
675
|
+
if (!pane) return;
|
|
676
|
+
pane.classList.remove("tf-host-preview");
|
|
677
|
+
for (const [name, [value, priority]] of previous) value ? pane.style.setProperty(name, value, priority) : pane.style.removeProperty(name);
|
|
678
|
+
if (host) {
|
|
679
|
+
const [value, priority] = hostLayer;
|
|
680
|
+
value ? host.style.setProperty("--dsh-dockkit-float-layer", value, priority) : host.style.removeProperty("--dsh-dockkit-float-layer");
|
|
681
|
+
}
|
|
682
|
+
previous.clear();
|
|
683
|
+
pane = void 0;
|
|
684
|
+
host = void 0;
|
|
685
|
+
};
|
|
686
|
+
const update = () => {
|
|
687
|
+
if (disposed) return;
|
|
688
|
+
if (!pane?.isConnected || !pane.hasAttribute("data-dockkit-float")) {
|
|
689
|
+
const body = [...doc.querySelectorAll("[data-sidebar-right-tab]")].find((node) => node.dataset.sidebarRightTab === tabId && node.closest("[data-dockkit-float]"));
|
|
690
|
+
const nextPane = body?.closest("[data-dockkit-float]");
|
|
691
|
+
if (pane !== nextPane) {
|
|
692
|
+
restore();
|
|
693
|
+
pane = nextPane;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (pane) {
|
|
697
|
+
if (!host) {
|
|
698
|
+
host = pane.closest('[data-dockkit-host="float"]');
|
|
699
|
+
if (host) hostLayer = [host.style.getPropertyValue("--dsh-dockkit-float-layer"), host.style.getPropertyPriority("--dsh-dockkit-float-layer")];
|
|
700
|
+
}
|
|
701
|
+
pane.classList.add("tf-host-preview");
|
|
702
|
+
const rect = container.getBoundingClientRect(), scrollport = container.closest(".tool-content")?.getBoundingClientRect() ?? rect;
|
|
703
|
+
const top = Math.max(0, scrollport.top, rect.top), bottom = Math.min(win.innerHeight, scrollport.bottom, rect.bottom);
|
|
704
|
+
const left = Math.max(0, scrollport.left, rect.left), right = Math.min(win.innerWidth, scrollport.right, rect.right);
|
|
705
|
+
const visible = container.isConnected && sidebar.mounted.getSnapshot() === sessionId && rect.width > 0 && rect.height > 0 && bottom > top && right > left && win.getComputedStyle(container.closest(".tf-tool-mount") ?? container).display !== "none";
|
|
706
|
+
set("visibility", visible ? "visible" : "hidden");
|
|
707
|
+
set("left", `${rect.left}px`);
|
|
708
|
+
set("top", `${rect.top}px`);
|
|
709
|
+
set("width", `${rect.width}px`);
|
|
710
|
+
set("height", `${rect.height}px`);
|
|
711
|
+
set("min-width", "0px");
|
|
712
|
+
set("min-height", "0px");
|
|
713
|
+
set("max-width", "none");
|
|
714
|
+
set("max-height", "none");
|
|
715
|
+
set("transform", "none");
|
|
716
|
+
set("z-index", container.closest(".tf-tool-floating") ? "1201" : "30");
|
|
717
|
+
const layer = container.closest(".tf-tool-floating") ? "1201" : "60";
|
|
718
|
+
if (host && host.style.getPropertyValue("--dsh-dockkit-float-layer") !== layer) host.style.setProperty("--dsh-dockkit-float-layer", layer);
|
|
719
|
+
set("clip-path", `inset(${Math.max(0, top - rect.top)}px ${Math.max(0, rect.right - right)}px ${Math.max(0, rect.bottom - bottom)}px ${Math.max(0, left - rect.left)}px)`);
|
|
720
|
+
}
|
|
721
|
+
frame = win.requestAnimationFrame(update);
|
|
722
|
+
};
|
|
723
|
+
update();
|
|
724
|
+
return () => {
|
|
725
|
+
if (disposed) return;
|
|
726
|
+
disposed = true;
|
|
727
|
+
win.cancelAnimationFrame(frame);
|
|
728
|
+
restore();
|
|
729
|
+
sidebar.closeIn(sessionId, tabId);
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// taskflow-source:src/client/tool-openers.mjs
|
|
734
|
+
function sessionFileAddress(sessionId, path) {
|
|
735
|
+
const encode = (s) => encodeURIComponent(s).replace(/%3A/gi, ":");
|
|
736
|
+
return `dsh-resource://file/session/${encode(sessionId)}/${path.replace(/\\/g, "/").replace(/^(?:\.\/)+/, "").split("/").map(encode).join("/")}`;
|
|
737
|
+
}
|
|
738
|
+
function createToolOpeners(ctx) {
|
|
739
|
+
const browserUrls = /* @__PURE__ */ new Map();
|
|
740
|
+
const get = (name) => ctx.get ? ctx.get(name) : ctx[name];
|
|
741
|
+
const foreground = (sid) => {
|
|
742
|
+
const sidebar = get("sidebarRight");
|
|
743
|
+
if (!sidebar?.mounted || sidebar.mounted.getSnapshot() !== sid) throw new Error("请先打开此任务会话,再打开工具产物");
|
|
744
|
+
return sidebar;
|
|
745
|
+
};
|
|
746
|
+
return {
|
|
747
|
+
async openDocument(sid, file, { container } = {}) {
|
|
748
|
+
const sidebar = foreground(sid), address = sessionFileAddress(sid, file.path), tabs = get("sidebarRightTabs");
|
|
749
|
+
let claim;
|
|
750
|
+
try {
|
|
751
|
+
claim = tabs?.claim(address);
|
|
752
|
+
} catch {
|
|
753
|
+
throw new Error("文档预览插件尚未就绪,请启用后重试");
|
|
754
|
+
}
|
|
755
|
+
if (!claim) throw new Error("文档预览插件尚未就绪,请启用后重试");
|
|
756
|
+
if (container) {
|
|
757
|
+
if (!sidebar.float || !sidebar.active || !sidebar.closeIn) throw new Error("当前宿主不支持工具区文档预览,请更新宿主");
|
|
758
|
+
const previous = sidebar.active(), expanded = sidebar.isExpanded();
|
|
759
|
+
const restorePanel = () => {
|
|
760
|
+
if (previous) sidebar.focus(previous.id);
|
|
761
|
+
if (!expanded && sidebar.isExpanded()) sidebar.toggleExpanded();
|
|
762
|
+
};
|
|
763
|
+
sidebar.openResource(address, { revealIfOpened: false });
|
|
764
|
+
const tab = sidebar.active();
|
|
765
|
+
if (!tab || tab.id === previous?.id || tab.contentId !== address) throw new Error("宿主未建立文档预览,请重试");
|
|
766
|
+
try {
|
|
767
|
+
sidebar.float(tab.id);
|
|
768
|
+
restorePanel();
|
|
769
|
+
return { message: "已在工具视图中打开", dispose: embedPreview({ sidebar, sessionId: sid, tabId: tab.id, container }) };
|
|
770
|
+
} catch (error) {
|
|
771
|
+
sidebar.closeIn(sid, tab.id);
|
|
772
|
+
restorePanel();
|
|
773
|
+
throw error;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
await sidebar.openResource(address, { destination: "float" });
|
|
777
|
+
return "已交给文档插件打开";
|
|
778
|
+
},
|
|
779
|
+
async openBrowser(sid, url, { automatic = false } = {}) {
|
|
780
|
+
const sidebar = foreground(sid);
|
|
781
|
+
if (!get("sidebarRightTabs")?.get("browser")) throw new Error("浏览器插件尚未就绪,请启用后重试");
|
|
782
|
+
if (automatic && browserUrls.get(sid) === url) return "此地址已交给浏览器插件打开";
|
|
783
|
+
sidebar.openTab("browser", { params: { url } });
|
|
784
|
+
browserUrls.set(sid, url);
|
|
785
|
+
return "已交给浏览器插件打开";
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// taskflow-source:src/client/hooks/use-compact-checklist.mjs
|
|
791
|
+
var import_react12 = require("react");
|
|
792
|
+
var MIN_WIDTH = 280;
|
|
793
|
+
var MAX_WIDTH = 720;
|
|
794
|
+
var STORAGE_KEY = "dsh-taskflow:checklist-width";
|
|
795
|
+
var clamp = (width, max) => Math.round(Math.max(MIN_WIDTH, Math.min(width, max)));
|
|
796
|
+
var savedWidth = () => {
|
|
797
|
+
try {
|
|
798
|
+
const width = JSON.parse(window.localStorage.getItem(STORAGE_KEY));
|
|
799
|
+
return Number.isFinite(width) ? clamp(width, MAX_WIDTH) : 300;
|
|
800
|
+
} catch {
|
|
801
|
+
return 300;
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
function useCompactChecklist(enabled) {
|
|
805
|
+
const anchor = (0, import_react12.useRef)(null), desired = (0, import_react12.useRef)(null), bridge = (0, import_react12.useRef)(null), stopDrag = (0, import_react12.useRef)(() => {
|
|
806
|
+
});
|
|
807
|
+
if (desired.current === null) desired.current = savedWidth();
|
|
808
|
+
const [panel, setPanel] = (0, import_react12.useState)(null), [size, setSize] = (0, import_react12.useState)({ width: 300, max: MAX_WIDTH }), [dragging, setDragging] = (0, import_react12.useState)(false);
|
|
809
|
+
const save = () => {
|
|
810
|
+
try {
|
|
811
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(desired.current));
|
|
812
|
+
} catch {
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
(0, import_react12.useEffect)(() => {
|
|
816
|
+
if (!enabled) return;
|
|
817
|
+
const panel2 = anchor.current?.closest('[data-sidebar-right-panel="push"]');
|
|
818
|
+
const frame = panel2?.closest("[data-rightbar-col]")?.parentElement;
|
|
819
|
+
if (!frame || !/^\s*[\d.]+px\s/.test(frame.style.gridTemplateColumns)) return;
|
|
820
|
+
const sync = () => {
|
|
821
|
+
const first = frame.style.gridTemplateColumns.match(/^\s*([\d.]+px)\s/)?.[1];
|
|
822
|
+
if (!first) return;
|
|
823
|
+
const viewport = frame.getBoundingClientRect().width || window.innerWidth;
|
|
824
|
+
const max = Math.max(MIN_WIDTH, Math.floor(Math.min(MAX_WIDTH, viewport * 0.7, viewport - parseFloat(first) - 400)));
|
|
825
|
+
const width = clamp(desired.current, max);
|
|
826
|
+
for (const [name, value] of [["--tf-sidebar-track", first], ["--tf-checklist-width", `${width}px`]]) if (frame.style.getPropertyValue(name) !== value) frame.style.setProperty(name, value);
|
|
827
|
+
bridge.current = { sync, width, max };
|
|
828
|
+
setSize((previous) => previous.width === width && previous.max === max ? previous : { width, max });
|
|
829
|
+
};
|
|
830
|
+
sync();
|
|
831
|
+
panel2.dataset.tfCompactChecklist = "";
|
|
832
|
+
setPanel(panel2);
|
|
833
|
+
const observer = new MutationObserver(sync);
|
|
834
|
+
observer.observe(frame, { attributes: true, attributeFilter: ["style"] });
|
|
835
|
+
const resize = typeof window.ResizeObserver === "function" ? new window.ResizeObserver(sync) : null;
|
|
836
|
+
resize?.observe(frame);
|
|
837
|
+
window.addEventListener("resize", sync);
|
|
838
|
+
return () => {
|
|
839
|
+
stopDrag.current();
|
|
840
|
+
observer.disconnect();
|
|
841
|
+
resize?.disconnect();
|
|
842
|
+
window.removeEventListener("resize", sync);
|
|
843
|
+
bridge.current = null;
|
|
844
|
+
setPanel(null);
|
|
845
|
+
delete panel2.dataset.tfCompactChecklist;
|
|
846
|
+
if (!frame.querySelector("[data-tf-compact-checklist]")) {
|
|
847
|
+
frame.style.removeProperty("--tf-sidebar-track");
|
|
848
|
+
frame.style.removeProperty("--tf-checklist-width");
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
}, [enabled]);
|
|
852
|
+
const onPointerDown = (event) => {
|
|
853
|
+
if (event.button !== 0 || !bridge.current) return;
|
|
854
|
+
event.preventDefault();
|
|
855
|
+
stopDrag.current();
|
|
856
|
+
const startX = event.clientX, startWidth = bridge.current.width, pointerId = event.pointerId, handle = event.currentTarget;
|
|
857
|
+
const move = (e) => {
|
|
858
|
+
if (e.pointerId !== pointerId || !bridge.current) return;
|
|
859
|
+
desired.current = clamp(startWidth + startX - e.clientX, bridge.current.max);
|
|
860
|
+
bridge.current.sync();
|
|
861
|
+
};
|
|
862
|
+
const end = (e) => {
|
|
863
|
+
if (e?.pointerId !== void 0 && e.pointerId !== pointerId) return;
|
|
864
|
+
stopDrag.current = () => {
|
|
865
|
+
};
|
|
866
|
+
window.removeEventListener("pointermove", move, true);
|
|
867
|
+
window.removeEventListener("pointerup", up, true);
|
|
868
|
+
window.removeEventListener("pointercancel", end, true);
|
|
869
|
+
window.removeEventListener("blur", end);
|
|
870
|
+
handle.removeEventListener("lostpointercapture", end);
|
|
871
|
+
if (handle.hasPointerCapture?.(pointerId)) handle.releasePointerCapture(pointerId);
|
|
872
|
+
setDragging(false);
|
|
873
|
+
save();
|
|
874
|
+
};
|
|
875
|
+
const up = (e) => {
|
|
876
|
+
if (e.pointerId === pointerId) {
|
|
877
|
+
move(e);
|
|
878
|
+
end(e);
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
stopDrag.current = end;
|
|
882
|
+
setDragging(true);
|
|
883
|
+
window.addEventListener("pointermove", move, true);
|
|
884
|
+
window.addEventListener("pointerup", up, true);
|
|
885
|
+
window.addEventListener("pointercancel", end, true);
|
|
886
|
+
window.addEventListener("blur", end);
|
|
887
|
+
handle.addEventListener("lostpointercapture", end);
|
|
888
|
+
handle.setPointerCapture?.(pointerId);
|
|
889
|
+
};
|
|
890
|
+
const onKeyDown = (event) => {
|
|
891
|
+
if (!bridge.current || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
|
|
892
|
+
event.preventDefault();
|
|
893
|
+
desired.current = clamp(event.key === "Home" ? MIN_WIDTH : event.key === "End" ? bridge.current.max : bridge.current.width + (event.key === "ArrowLeft" ? 24 : -24), bridge.current.max);
|
|
894
|
+
bridge.current.sync();
|
|
895
|
+
save();
|
|
896
|
+
};
|
|
897
|
+
return { anchor, panel, dragging, separator: { role: "separator", tabIndex: 0, "aria-label": "调整待办任务清单宽度", "aria-orientation": "vertical", "aria-valuemin": MIN_WIDTH, "aria-valuemax": size.max, "aria-valuenow": size.width, onPointerDown, onKeyDown } };
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// taskflow-source:src/client/components/execution-record.jsx
|
|
901
|
+
var import_react14 = __toESM(require("react"));
|
|
902
|
+
|
|
903
|
+
// taskflow-source:src/client/components/markdown-preview.jsx
|
|
904
|
+
var import_react13 = __toESM(require("react"));
|
|
905
|
+
|
|
906
|
+
// taskflow-vendor:node_modules/marked/lib/marked.esm.js
|
|
907
|
+
function G() {
|
|
908
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
909
|
+
}
|
|
910
|
+
var S = G();
|
|
911
|
+
function ue(l3) {
|
|
912
|
+
S = l3;
|
|
913
|
+
}
|
|
914
|
+
var q = { exec: () => null };
|
|
915
|
+
function D(l3) {
|
|
916
|
+
let e = [];
|
|
917
|
+
return (t) => {
|
|
918
|
+
let n = Math.max(0, Math.min(3, t - 1)), r = e[n];
|
|
919
|
+
return r || (r = l3(n), e[n] = r), r;
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
function g(l3, e = "") {
|
|
923
|
+
let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (r, s) => {
|
|
924
|
+
let o = typeof s == "string" ? s : s.source;
|
|
925
|
+
return o = o.replace(O.caret, "$1"), t = t.replace(r, o), n;
|
|
926
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
927
|
+
return n;
|
|
928
|
+
}
|
|
929
|
+
var _e = ((l3 = "") => {
|
|
930
|
+
try {
|
|
931
|
+
return !!new RegExp("(?<=1)(?<!1)" + l3);
|
|
932
|
+
} catch {
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
})();
|
|
936
|
+
var O = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, listInterruptsParagraph: /^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, leadingSpaceTab: /^[ \t]+/, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, blockquoteMarkerWhitespace: /^( {0,3}>)(\t[ \t]*)/gm, nestedBlockMarker: /^ {0,3}(?:(?:[*+-]|\d{1,9}[.)])(?: |$)|> ?)/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\][ \t]+\S/, listReplaceTask: /^\[[ xX]\][ \t]+/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/, numericCharacterReferenceOrAmpersand: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: D((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: D((l3) => new RegExp(`^ {0,${l3}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: D((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: D((l3) => new RegExp(`^ {0,${l3}}#{1,6}(?:\\s|$)`)), pedanticHeadingBeginRegex: D((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: D((l3) => new RegExp(`^ {0,${l3}}(?:</?(?:${he})(?:[ \\t]+|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, "i")), blockquoteBeginRegex: D((l3) => new RegExp(`^ {0,${l3}}>`)), nestedContainerMarkers: /^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/ };
|
|
937
|
+
var Ge = /^(?:[ \t]*(?:\n|$))+/;
|
|
938
|
+
var Ne = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
939
|
+
var Fe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/;
|
|
940
|
+
var V = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
941
|
+
var Qe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
942
|
+
var ce = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
943
|
+
var he = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
944
|
+
var J = g(" {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag", he).getRegex();
|
|
945
|
+
var $e = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/;
|
|
946
|
+
var Le = g($e).replace(/bull/g, ce).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/\|table/g, "").replace(/html/g, J).getRegex();
|
|
947
|
+
var We = g($e).replace(/bull/g, ce).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).replace(/html/g, J).getRegex();
|
|
948
|
+
var de = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
949
|
+
var Ue = /^[^\n]+/;
|
|
950
|
+
var ge = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/;
|
|
951
|
+
var Ke = g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<(?:\\.|[^\n<>\\])*>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", ge).replace("title", /(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex();
|
|
952
|
+
var Xe = g(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, ce).getRegex();
|
|
953
|
+
var ke = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
954
|
+
var Ve = g("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*?[ \\t]*/?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", ke).replace("tag", he).replace("attribute", /[ \t]+[a-zA-Z:_][\w.:-]*(?:[ \t]*=[ \t]*"[^"\n]*"|[ \t]*=[ \t]*'[^'\n]*'|[ \t]*=[ \t]*[^\s"'=<>`]+)?/).getRegex();
|
|
955
|
+
var Ce = (l3) => g(de).replace("hr", V).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l3).replace("html", J).getRegex();
|
|
956
|
+
var Je = Ce(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
957
|
+
var Ye = Ce(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
958
|
+
var et = g(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace("paragraph", Ye).getRegex();
|
|
959
|
+
var fe = { blockquote: et, code: Ne, def: Ke, fences: Fe, heading: Qe, hr: V, html: Ve, lheading: Le, list: Xe, newline: Ge, paragraph: Je, table: q, text: Ue };
|
|
960
|
+
var Pe = g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", V).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", J).getRegex();
|
|
961
|
+
var tt = { ...fe, lheading: We, table: Pe, paragraph: g(de).replace("hr", V).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Pe).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", J).getRegex() };
|
|
962
|
+
var nt = { ...fe, html: g(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace("comment", ke).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: q, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: g(de).replace("hr", V).replace("heading", ` *#{1,6} *[^
|
|
963
|
+
]`).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").replace("lheading", Le).getRegex() };
|
|
964
|
+
var rt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
965
|
+
var st = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
966
|
+
var Ie = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
|
|
967
|
+
var it = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
968
|
+
var L = /[\p{P}\p{S}]/u;
|
|
969
|
+
var N = /[\s\p{P}\p{S}]/u;
|
|
970
|
+
var Y = /[^\s\p{P}\p{S}]/u;
|
|
971
|
+
var ot = g(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, N).getRegex();
|
|
972
|
+
var at = /[\p{Pi}\p{Ps}"']/u;
|
|
973
|
+
var Ae = /(?!~)[\p{P}\p{S}]/u;
|
|
974
|
+
var lt = /(?!~)[\s\p{P}\p{S}]/u;
|
|
975
|
+
var ut = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
976
|
+
var pt = g(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", _e ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
977
|
+
var Ee = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
978
|
+
var ct = g(Ee, "u").replace(/punct/g, L).getRegex();
|
|
979
|
+
var ht = g(Ee, "u").replace(/punct/g, Ae).getRegex();
|
|
980
|
+
var dt = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
981
|
+
var gt = g(dt, "u").replace(/openQuote/g, at).replace(/punct/g, L).getRegex();
|
|
982
|
+
var ze = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
983
|
+
var kt = g(ze, "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, N).replace(/punct/g, L).getRegex();
|
|
984
|
+
var ft = g(ze, "gu").replace(/notPunctSpace/g, ut).replace(/punctSpace/g, lt).replace(/punct/g, Ae).getRegex();
|
|
985
|
+
var mt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
986
|
+
var xt = g(mt, "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, N).replace(/punct/g, L).getRegex();
|
|
987
|
+
var bt = g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, N).replace(/punct/g, L).getRegex();
|
|
988
|
+
var Rt = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
989
|
+
var Tt = g(Rt, "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, N).replace(/punct/g, L).getRegex();
|
|
990
|
+
var Ot = g(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, L).getRegex();
|
|
991
|
+
var wt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
992
|
+
var Pt = g(wt, "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, N).replace(/punct/g, L).getRegex();
|
|
993
|
+
var yt = g(/\\(punct)/, "gu").replace(/punct/g, L).getRegex();
|
|
994
|
+
var St = g(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/, "gu").replace(/punct/g, L).getRegex();
|
|
995
|
+
var _t = g(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
996
|
+
var $t = g(ke).replace("(?:-->|$)", "-->").getRegex();
|
|
997
|
+
var Lt = g("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", $t).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
998
|
+
var Me = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
|
|
999
|
+
var ie = g(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", Me).getRegex();
|
|
1000
|
+
var Ct = g(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", ie).replace("href", /<(?:\\.|[^\n<>\\])*>|(?!<)[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex();
|
|
1001
|
+
var It = g(/^!?\[(label)\]\[(ref)\]/).replace("label", ie).replace("ref", ge).getRegex();
|
|
1002
|
+
var At = g(/^!?\[(ref)\](?:\[\])?/).replace("ref", ge).getRegex();
|
|
1003
|
+
var ye = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
|
|
1004
|
+
var Et = g(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", Me).getRegex();
|
|
1005
|
+
var zt = g("reflink|nolink(?!\\()", "g").replace("reflink", g(/^!?\[(label)\]\[(ref)\]/).replace("label", Et).replace("ref", ye).getRegex()).replace("nolink", g(/^!?\[(ref)\](?:\[\])?/).replace("ref", ye).getRegex()).getRegex();
|
|
1006
|
+
var Se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
1007
|
+
var Mt = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
|
|
1008
|
+
var Bt = g(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, Mt).getRegex();
|
|
1009
|
+
var me = { _backpedal: q, anyPunctuation: yt, anyPunctuationOutsideCode: St, autolink: _t, blockSkip: pt, br: Ie, code: st, del: q, delLDelim: q, delRDelim: q, emStrongLDelim: ct, emStrongRDelimAst: kt, emStrongRDelimUnd: bt, escape: rt, link: Ct, nolink: At, punctuation: ot, reflink: It, reflinkSearch: zt, tag: Lt, text: it, url: q };
|
|
1010
|
+
var Dt = { ...me, emStrongLDelim: gt, emStrongRDelimAst: xt, emStrongRDelimUnd: Tt, link: g(/^!?\[(label)\]\((.*?)\)/).replace("label", ie).getRegex(), reflink: g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", ie).getRegex() };
|
|
1011
|
+
var pe = { ...me, emStrongRDelimAst: ft, emStrongLDelim: ht, delLDelim: Ot, delRDelim: Pt, url: g(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Bt).replace("protocol", Se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: g(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", Se).replace(/emailProtocol/g, /(?:mailto|xmpp):/).replace("wwwStart", _e ? "(?<![^\\s*_~(])www\\." : "www\\.").getRegex() };
|
|
1012
|
+
var qt = { ...pe, br: g(Ie).replace("{2,}", "*").getRegex(), text: g(pe.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
1013
|
+
var ee = { normal: fe, gfm: tt, pedantic: nt };
|
|
1014
|
+
var F = { normal: me, gfm: pe, breaks: qt, pedantic: Dt };
|
|
1015
|
+
var vt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
1016
|
+
var Be = (l3) => vt[l3];
|
|
1017
|
+
function y(l3, e) {
|
|
1018
|
+
if (e) {
|
|
1019
|
+
if (O.escapeTest.test(l3)) return l3.replace(O.escapeReplace, Be);
|
|
1020
|
+
} else if (O.escapeTestNoEncode.test(l3)) return l3.replace(O.escapeReplaceNoEncode, Be);
|
|
1021
|
+
return l3;
|
|
1022
|
+
}
|
|
1023
|
+
function De(l3) {
|
|
1024
|
+
return O.numericCharacterReference.test(l3) ? l3.replace(O.numericCharacterReferenceOrAmpersand, (e, t, n) => {
|
|
1025
|
+
if (t === void 0 && n === void 0) return "&";
|
|
1026
|
+
let r = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
|
|
1027
|
+
return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : r === 38 ? "&" : String.fromCodePoint(r);
|
|
1028
|
+
}) : l3;
|
|
1029
|
+
}
|
|
1030
|
+
function xe(l3) {
|
|
1031
|
+
try {
|
|
1032
|
+
l3 = encodeURI(l3).replace(O.percentDecode, "%");
|
|
1033
|
+
} catch {
|
|
1034
|
+
return null;
|
|
1035
|
+
}
|
|
1036
|
+
return l3;
|
|
1037
|
+
}
|
|
1038
|
+
function be(l3, e) {
|
|
1039
|
+
let t = l3.replace(O.findPipe, (s, o, i) => {
|
|
1040
|
+
let a = false, c = o;
|
|
1041
|
+
for (; --c >= 0 && i[c] === "\\"; ) a = !a;
|
|
1042
|
+
return a ? "|" : " |";
|
|
1043
|
+
}), n = t.split(O.splitPipe), r = 0;
|
|
1044
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
1045
|
+
else for (; n.length < e; ) n.push("");
|
|
1046
|
+
for (; r < n.length; r++) n[r] = n[r].trim().replace(O.slashPipe, "|");
|
|
1047
|
+
return n;
|
|
1048
|
+
}
|
|
1049
|
+
function C(l3, e, t) {
|
|
1050
|
+
let n = l3.length;
|
|
1051
|
+
if (n === 0) return "";
|
|
1052
|
+
let r = 0;
|
|
1053
|
+
for (; r < n; ) {
|
|
1054
|
+
let s = l3.charAt(n - r - 1);
|
|
1055
|
+
if (s === e && !t) r++;
|
|
1056
|
+
else if (s !== e && t) r++;
|
|
1057
|
+
else break;
|
|
1058
|
+
}
|
|
1059
|
+
return l3.slice(0, n - r);
|
|
1060
|
+
}
|
|
1061
|
+
function Re(l3) {
|
|
1062
|
+
let e = l3.split(`
|
|
1063
|
+
`), t = e.length - 1;
|
|
1064
|
+
for (; t >= 0 && O.blankLine.test(e[t]); ) t--;
|
|
1065
|
+
return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
|
|
1066
|
+
`);
|
|
1067
|
+
}
|
|
1068
|
+
function W(l3) {
|
|
1069
|
+
return l3.trim().replace(O.multipleSpaceGlobal, " ").toLowerCase().toUpperCase().toLowerCase();
|
|
1070
|
+
}
|
|
1071
|
+
function Te(l3, e) {
|
|
1072
|
+
if (l3.indexOf(e[0]) === -1 && l3.indexOf(e[1]) === -1) return -1;
|
|
1073
|
+
let t = 0;
|
|
1074
|
+
for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
|
|
1075
|
+
else if (l3[n] === e[0]) t++;
|
|
1076
|
+
else if (l3[n] === e[1] && (t--, t < 0)) return n;
|
|
1077
|
+
return t > 0 ? -2 : -1;
|
|
1078
|
+
}
|
|
1079
|
+
var Q = /* @__PURE__ */ new WeakMap();
|
|
1080
|
+
function Oe(l3) {
|
|
1081
|
+
let e = { "*": -1, _: -1 }, t = -1, n = l3.length;
|
|
1082
|
+
for (let r = 0; r < n; r++) {
|
|
1083
|
+
let s = l3[r];
|
|
1084
|
+
if (s !== "*" && s !== "_" && s !== "~") continue;
|
|
1085
|
+
let o = r === 0 ? `
|
|
1086
|
+
` : l3[r - 1], i = r + 1;
|
|
1087
|
+
for (; i < n && l3[i] === s; ) i++;
|
|
1088
|
+
o !== " " && o !== " " && o !== `
|
|
1089
|
+
` && o !== "\r" && o !== "\f" && (s === "~" ? t = r : e[s] = r), r = i - 1;
|
|
1090
|
+
}
|
|
1091
|
+
return { maskedSrc: l3, lastPossibleEmStrongCloserIndex: e, lastPossibleDelCloserIndex: t };
|
|
1092
|
+
}
|
|
1093
|
+
function qe(l3, e) {
|
|
1094
|
+
let t = Oe(e), n = Q.get(l3);
|
|
1095
|
+
n ? n.push(t) : Q.set(l3, [t]);
|
|
1096
|
+
}
|
|
1097
|
+
function ve(l3) {
|
|
1098
|
+
let e = Q.get(l3);
|
|
1099
|
+
e && (e.pop(), e.length === 0 && Q.delete(l3));
|
|
1100
|
+
}
|
|
1101
|
+
function oe(l3, e, t) {
|
|
1102
|
+
let n = Q.get(l3)?.at(-1);
|
|
1103
|
+
return n && n.maskedSrc === e ? n.lastPossibleEmStrongCloserIndex[t] : Oe(e).lastPossibleEmStrongCloserIndex[t];
|
|
1104
|
+
}
|
|
1105
|
+
function ae(l3, e) {
|
|
1106
|
+
let t = Q.get(l3)?.at(-1);
|
|
1107
|
+
return t && t.maskedSrc === e ? t.lastPossibleDelCloserIndex : Oe(e).lastPossibleDelCloserIndex;
|
|
1108
|
+
}
|
|
1109
|
+
function te(l3, e = 0) {
|
|
1110
|
+
let t = e, n = "";
|
|
1111
|
+
for (let r of l3) if (r === " ") {
|
|
1112
|
+
let s = 4 - t % 4;
|
|
1113
|
+
n += " ".repeat(s), t += s;
|
|
1114
|
+
} else n += r, t++;
|
|
1115
|
+
return n;
|
|
1116
|
+
}
|
|
1117
|
+
function Ht(l3, e) {
|
|
1118
|
+
let t = "";
|
|
1119
|
+
for (let n = 0; n < l3.length; n++) {
|
|
1120
|
+
if (l3[n] === "`") {
|
|
1121
|
+
let r = e.inline.code.exec(l3.slice(n));
|
|
1122
|
+
if (r) {
|
|
1123
|
+
t += r[0], n += r[0].length - 1;
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (l3[n] === "\\" && (l3[n + 1] === "[" || l3[n + 1] === "]")) {
|
|
1128
|
+
t += l3[n + 1], n++;
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
t += l3[n];
|
|
1132
|
+
}
|
|
1133
|
+
return t;
|
|
1134
|
+
}
|
|
1135
|
+
function He(l3, e, t, n, r) {
|
|
1136
|
+
let s = e.href, o = e.title || null, i = Ht(l3[1], r), a = l3[0].charAt(0) === "!", c = n.state.inLink, u = n.state.linkEmitted, d = n.state.inRawBlock;
|
|
1137
|
+
n.state.inLink = true, n.state.linkEmitted = false;
|
|
1138
|
+
let h = n.inlineTokens(i), p = n.state.linkEmitted;
|
|
1139
|
+
if (n.state.linkEmitted = u, n.state.inLink = c, !a) {
|
|
1140
|
+
if (p) {
|
|
1141
|
+
n.state.inRawBlock = d;
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
n.state.linkEmitted = true;
|
|
1145
|
+
}
|
|
1146
|
+
return { type: a ? "image" : "link", raw: t, href: s, title: o, text: i, tokens: h };
|
|
1147
|
+
}
|
|
1148
|
+
function Zt(l3, e, t) {
|
|
1149
|
+
let n = l3.match(t.other.indentCodeCompensation);
|
|
1150
|
+
if (n === null) return e;
|
|
1151
|
+
let r = n[1];
|
|
1152
|
+
return e.split(`
|
|
1153
|
+
`).map((s) => {
|
|
1154
|
+
let o = s.match(t.other.beginningSpace);
|
|
1155
|
+
if (o === null) return s;
|
|
1156
|
+
let [i] = o;
|
|
1157
|
+
return s.slice(Math.min(i.length, r.length));
|
|
1158
|
+
}).join(`
|
|
1159
|
+
`);
|
|
1160
|
+
}
|
|
1161
|
+
function Ze(l3, e, t, n) {
|
|
1162
|
+
if (!e.includes("<")) return false;
|
|
1163
|
+
for (let r = 0; r < e.length; r++) {
|
|
1164
|
+
if (e[r] === "\\") {
|
|
1165
|
+
r++;
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
if (e[r] === "`") {
|
|
1169
|
+
let i = n.inline.code.exec(e.slice(r));
|
|
1170
|
+
if (i) {
|
|
1171
|
+
r += i[0].length - 1;
|
|
1172
|
+
continue;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
if (e[r] !== "<") continue;
|
|
1176
|
+
let s = l3.slice(t + r), o = n.inline.tag.exec(s) || n.inline.autolink.exec(s);
|
|
1177
|
+
if (o) {
|
|
1178
|
+
if (o[0].length > e.length - r) return true;
|
|
1179
|
+
r += o[0].length - 1;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1184
|
+
var _ = class {
|
|
1185
|
+
options;
|
|
1186
|
+
rules;
|
|
1187
|
+
lexer;
|
|
1188
|
+
constructor(e) {
|
|
1189
|
+
this.options = e || S;
|
|
1190
|
+
}
|
|
1191
|
+
space(e) {
|
|
1192
|
+
let t = this.rules.block.newline.exec(e);
|
|
1193
|
+
if (t && t[0].length > 0) return { type: "space", raw: t[0] };
|
|
1194
|
+
}
|
|
1195
|
+
code(e) {
|
|
1196
|
+
let t = this.rules.block.code.exec(e);
|
|
1197
|
+
if (t) {
|
|
1198
|
+
let n = this.options.pedantic ? t[0] : Re(t[0]), r = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
1199
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: r };
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
fences(e) {
|
|
1203
|
+
let t = this.rules.block.fences.exec(e);
|
|
1204
|
+
if (t) {
|
|
1205
|
+
let n = t[0], r = Zt(n, t[3] || "", this.rules);
|
|
1206
|
+
return t[3] !== void 0 && (r === "" || r.endsWith(`
|
|
1207
|
+
`)) && (r += `
|
|
1208
|
+
`), { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: r };
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
heading(e) {
|
|
1212
|
+
let t = this.rules.block.heading.exec(e);
|
|
1213
|
+
if (t) {
|
|
1214
|
+
let n = t[2].trim();
|
|
1215
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
1216
|
+
let r = C(n, "#");
|
|
1217
|
+
(this.options.pedantic || !r || this.rules.other.endingSpaceTabChar.test(r)) && (n = r.trim());
|
|
1218
|
+
}
|
|
1219
|
+
return { type: "heading", raw: C(t[0], `
|
|
1220
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
hr(e) {
|
|
1224
|
+
let t = this.rules.block.hr.exec(e);
|
|
1225
|
+
if (t) return { type: "hr", raw: C(t[0], `
|
|
1226
|
+
`) };
|
|
1227
|
+
}
|
|
1228
|
+
blockquote(e) {
|
|
1229
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
1230
|
+
if (t) {
|
|
1231
|
+
let n = C(t[0], `
|
|
1232
|
+
`).split(`
|
|
1233
|
+
`), r = "", s = "", o = [];
|
|
1234
|
+
for (; n.length > 0; ) {
|
|
1235
|
+
let i = false, a = [], c;
|
|
1236
|
+
for (c = 0; c < n.length; c++) if (this.rules.other.blockquoteStart.test(n[c])) a.push(n[c]), i = true;
|
|
1237
|
+
else if (!i) a.push(n[c]);
|
|
1238
|
+
else break;
|
|
1239
|
+
n = n.slice(c);
|
|
1240
|
+
let u = a.join(`
|
|
1241
|
+
`), d = u.replace(this.rules.other.blockquoteMarkerWhitespace, (k, m, b) => b.startsWith(" ") ? m + " " + b.slice(1) : m + te(b, m.length)).replace(this.rules.other.blockquoteSetextReplace, `
|
|
1242
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1243
|
+
r = r ? `${r}
|
|
1244
|
+
${u}` : u, s = s ? `${s}
|
|
1245
|
+
${d}` : d;
|
|
1246
|
+
let h = this.lexer.state.top;
|
|
1247
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(d, o, true), this.lexer.state.top = h, n.length === 0) break;
|
|
1248
|
+
let p = o.at(-1);
|
|
1249
|
+
if (p?.type === "code" || p?.type === "heading" || p?.type === "hr" || p?.type === "html" || p?.type === "table") break;
|
|
1250
|
+
if (p?.type === "blockquote") {
|
|
1251
|
+
let k = p, m = n.join(`
|
|
1252
|
+
`), b = k.raw + `
|
|
1253
|
+
` + m.replace(this.rules.other.blockquoteSetextReplace2, ""), f = this.blockquote(b);
|
|
1254
|
+
o[o.length - 1] = f;
|
|
1255
|
+
let R = b.substring(f.raw.length).replace(/^\n/, ""), E = R ? R.split(`
|
|
1256
|
+
`).length : 0, T = E ? n.slice(0, -E) : n;
|
|
1257
|
+
if (T.length > 0 && (r = `${r}
|
|
1258
|
+
${T.join(`
|
|
1259
|
+
`)}`), s = s.substring(0, s.length - k.text.length) + f.text, n = n.slice(T.length), n.length > 0 && this.rules.other.blockquoteStart.test(n[0])) continue;
|
|
1260
|
+
break;
|
|
1261
|
+
} else if (p?.type === "list") {
|
|
1262
|
+
let k = p, m = k.raw + `
|
|
1263
|
+
` + n.join(`
|
|
1264
|
+
`), b = this.list(m);
|
|
1265
|
+
o[o.length - 1] = b;
|
|
1266
|
+
let f = b.raw.length > k.raw.length ? m.slice(k.raw.length + 1, b.raw.length).split(`
|
|
1267
|
+
`).length : 0;
|
|
1268
|
+
if (f > 0) {
|
|
1269
|
+
let R = n.slice(0, f).join(`
|
|
1270
|
+
`);
|
|
1271
|
+
r = `${r}
|
|
1272
|
+
${R}`, s = `${s}
|
|
1273
|
+
${R}`;
|
|
1274
|
+
}
|
|
1275
|
+
if (n = n.slice(f), n.length > 0 && !this.rules.other.blockquoteStart.test(n[0])) break;
|
|
1276
|
+
continue;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
return { type: "blockquote", raw: r, tokens: o, text: s };
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
list(e) {
|
|
1283
|
+
let t = this.rules.block.list.exec(e);
|
|
1284
|
+
if (t) {
|
|
1285
|
+
if (!this.options.pedantic && this.lexer.state.lastToken?.type === "text" && !this.rules.other.listInterruptsParagraph.test(e)) return;
|
|
1286
|
+
let n = e, r = () => n.length - e.length, s = t[1].trim(), o = s.length > 1, i = { type: "list", raw: "", ordered: o, start: o ? +s.slice(0, -1) : "", loose: false, items: [] };
|
|
1287
|
+
s = o ? `\\d{1,9}\\${s.slice(-1)}` : `\\${s}`, this.options.pedantic && (s = o ? s : "[*+-]");
|
|
1288
|
+
let a = this.rules.other.listItemRegex(s), c = false;
|
|
1289
|
+
for (; e; ) {
|
|
1290
|
+
let h = false, p = "";
|
|
1291
|
+
if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
1292
|
+
let k = r();
|
|
1293
|
+
e = e.substring(t[0].length);
|
|
1294
|
+
let m = t[2].split(`
|
|
1295
|
+
`, 1)[0], b = t[1].length, f = this.options.pedantic ? te(m, b) : m.replace(this.rules.other.leadingSpaceTab, (H) => te(H, b)), R = e.split(`
|
|
1296
|
+
`, 1)[0], E = !f.trim(), T = 0;
|
|
1297
|
+
if (this.options.pedantic ? (T = 2, p = f.trimStart()) : E ? T = b + 1 : (T = f.search(this.rules.other.nonSpaceChar), T = T > 4 ? 1 : T, p = f.slice(T), T += b), E && this.rules.other.blankLine.test(R) && (e = e.substring(R.length + 1), h = true), !h) {
|
|
1298
|
+
let H = this.rules.other.nextBulletRegex(T), K = this.rules.other.hrRegex(T), re = this.rules.other.fencesBeginRegex(T), B = this.options.pedantic ? this.rules.other.pedanticHeadingBeginRegex(T) : this.rules.other.headingBeginRegex(T), X = this.rules.other.htmlBeginRegex(T), se = this.rules.other.blockquoteBeginRegex(T), le = false;
|
|
1299
|
+
for (; e; ) {
|
|
1300
|
+
let we = e.split(`
|
|
1301
|
+
`, 1)[0], Z;
|
|
1302
|
+
if (R = we, this.options.pedantic ? (R = R.replace(this.rules.other.listReplaceNesting, " "), Z = R) : Z = R.replace(this.rules.other.leadingSpaceTab, ($) => te($)), re.test(R) || B.test(R) || X.test(R) || se.test(R) || H.test(R) || K.test(R)) break;
|
|
1303
|
+
if (Z.search(this.rules.other.nonSpaceChar) >= T || !R.trim()) p += `
|
|
1304
|
+
` + Z.slice(T), le = false;
|
|
1305
|
+
else {
|
|
1306
|
+
if (E) break;
|
|
1307
|
+
let $ = f;
|
|
1308
|
+
if (!this.options.pedantic && !p.includes(`
|
|
1309
|
+
`) && !f.includes(" ")) {
|
|
1310
|
+
let j;
|
|
1311
|
+
for (; !K.test($) && (j = this.rules.other.nestedBlockMarker.exec($)); ) $ = $.slice(j[0].length);
|
|
1312
|
+
if (!$.trim()) break;
|
|
1313
|
+
}
|
|
1314
|
+
if ($.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || re.test($) || B.test($) || X.test($) || K.test($)) break;
|
|
1315
|
+
if (!this.options.pedantic && !le) {
|
|
1316
|
+
let j = f.replace(this.rules.other.nestedContainerMarkers, "");
|
|
1317
|
+
if (this.rules.block.fences.test(j) || this.rules.block.heading.test(j) || this.rules.block.hr.test(j)) break;
|
|
1318
|
+
}
|
|
1319
|
+
let je = !this.options.pedantic && /^ {0,3}(?:=+|-+) *$/.test(R) && this.rules.block.lheading.test(`${f}
|
|
1320
|
+
${R}`) ? ` ${Z.replace(/^ {0,3}/, "")}` : R;
|
|
1321
|
+
p += `
|
|
1322
|
+
` + je, le = true;
|
|
1323
|
+
}
|
|
1324
|
+
E = !R.trim(), e = e.substring(we.length + 1), f = Z.slice(T);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
let U = n.slice(k, r());
|
|
1328
|
+
i.loose || (c ? i.loose = true : this.rules.other.doubleBlankLine.test(U) && (c = true)), i.items.push({ type: "list_item", raw: U, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] });
|
|
1329
|
+
}
|
|
1330
|
+
let u = i.items.at(-1);
|
|
1331
|
+
if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
|
|
1332
|
+
else return;
|
|
1333
|
+
i.raw = n.slice(0, r()).trimEnd();
|
|
1334
|
+
let d = [];
|
|
1335
|
+
for (let h of i.items) if (this.lexer.state.top = false, d.push(this.lexer.inlineQueue.length), h.tokens = this.lexer.blockTokens(h.text, []), !i.loose) {
|
|
1336
|
+
let p = h.tokens.filter((m) => m.type === "space"), k = p.length > 0 && p.some((m) => this.rules.other.anyLine.test(m.raw));
|
|
1337
|
+
i.loose = k;
|
|
1338
|
+
}
|
|
1339
|
+
for (let h = 0; h < i.items.length; h++) {
|
|
1340
|
+
let p = i.items[h], k = p.tokens[0];
|
|
1341
|
+
if (p.task && (k?.type === "text" || k?.type === "paragraph")) {
|
|
1342
|
+
p.text = p.text.replace(this.rules.other.listReplaceTask, ""), k.raw = k.raw.replace(this.rules.other.listReplaceTask, ""), k.text = k.text.replace(this.rules.other.listReplaceTask, "");
|
|
1343
|
+
let m = this.lexer.inlineQueue;
|
|
1344
|
+
for (let f = d[h]; f < m.length; f++) if (m[f].tokens === k.tokens) {
|
|
1345
|
+
m[f].src = m[f].src.replace(this.rules.other.listReplaceTask, "");
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
let b = this.rules.other.listTaskCheckbox.exec(p.raw);
|
|
1349
|
+
if (b) {
|
|
1350
|
+
let f = { type: "checkbox", raw: b[0] + " ", checked: b[0] !== "[ ]" };
|
|
1351
|
+
p.checked = f.checked, i.loose ? p.tokens[0] && ["paragraph", "text"].includes(p.tokens[0].type) && "tokens" in p.tokens[0] && p.tokens[0].tokens ? (p.tokens[0].raw = f.raw + p.tokens[0].raw, p.tokens[0].text = f.raw + p.tokens[0].text, p.tokens[0].tokens.unshift(f)) : p.tokens.unshift({ type: "paragraph", raw: f.raw, text: f.raw, tokens: [f] }) : p.tokens.unshift(f);
|
|
1352
|
+
}
|
|
1353
|
+
} else p.task && (p.task = false);
|
|
1354
|
+
}
|
|
1355
|
+
if (i.loose) for (let h of i.items) {
|
|
1356
|
+
h.loose = true;
|
|
1357
|
+
for (let p of h.tokens) p.type === "text" && (p.type = "paragraph");
|
|
1358
|
+
}
|
|
1359
|
+
return i;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
html(e) {
|
|
1363
|
+
let t = this.rules.block.html.exec(e);
|
|
1364
|
+
if (t) {
|
|
1365
|
+
if (this.lexer.state.lastToken?.type === "paragraph" && !this.rules.other.htmlBeginRegex(4).test(e)) return;
|
|
1366
|
+
let n = Re(t[0]);
|
|
1367
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
def(e) {
|
|
1371
|
+
let t = this.rules.block.def.exec(e);
|
|
1372
|
+
if (t) {
|
|
1373
|
+
if (!this.rules.other.startAngleBracket.test(t[2]) && Te(t[2], "()") !== -1) return;
|
|
1374
|
+
let n = W(t[1]), r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", s = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
1375
|
+
return { type: "def", tag: n, raw: C(t[0], `
|
|
1376
|
+
`), href: r, title: s };
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
table(e) {
|
|
1380
|
+
let t = this.rules.block.table.exec(e);
|
|
1381
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
1382
|
+
let n = be(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), s = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
1383
|
+
`) : [], o = { type: "table", raw: C(t[0], `
|
|
1384
|
+
`), header: [], align: [], rows: [] };
|
|
1385
|
+
if (n.length === r.length) {
|
|
1386
|
+
for (let i of r) this.rules.other.tableAlignRight.test(i) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? o.align.push("left") : o.align.push(null);
|
|
1387
|
+
for (let i = 0; i < n.length; i++) o.header.push({ text: n[i], tokens: this.lexer.inline(n[i]), header: true, align: o.align[i] });
|
|
1388
|
+
for (let i of s) o.rows.push(be(i, o.header.length).map((a, c) => ({ text: a, tokens: this.lexer.inline(a), header: false, align: o.align[c] })));
|
|
1389
|
+
return o;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
lheading(e) {
|
|
1393
|
+
let t = this.rules.block.lheading.exec(e);
|
|
1394
|
+
if (t) {
|
|
1395
|
+
let n = t[1].trim();
|
|
1396
|
+
return { type: "heading", raw: C(t[0], `
|
|
1397
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
paragraph(e) {
|
|
1401
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
1402
|
+
if (t) {
|
|
1403
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
1404
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
1405
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
text(e) {
|
|
1409
|
+
let t = this.rules.block.text.exec(e);
|
|
1410
|
+
if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
1411
|
+
}
|
|
1412
|
+
escape(e) {
|
|
1413
|
+
if (e.charCodeAt(0) !== 92) return;
|
|
1414
|
+
let t = this.rules.inline.escape.exec(e);
|
|
1415
|
+
if (t) return { type: "escape", raw: t[0], text: t[1] };
|
|
1416
|
+
}
|
|
1417
|
+
tag(e) {
|
|
1418
|
+
if (e.charCodeAt(0) !== 60) return;
|
|
1419
|
+
let t = this.rules.inline.tag.exec(e);
|
|
1420
|
+
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
1421
|
+
}
|
|
1422
|
+
link(e) {
|
|
1423
|
+
if (this.lexer.state.linkParenPossible === false) return;
|
|
1424
|
+
let t = e.charCodeAt(0);
|
|
1425
|
+
if (t !== 91 && t !== 33) return;
|
|
1426
|
+
let n = this.rules.inline.link.exec(e);
|
|
1427
|
+
if (n) {
|
|
1428
|
+
let r = n[0].charAt(0) === "!" ? 2 : 1;
|
|
1429
|
+
if (!this.options.pedantic && Ze(e, n[1], r, this.rules)) return;
|
|
1430
|
+
let s = n[2].trim();
|
|
1431
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(s)) {
|
|
1432
|
+
if (!this.rules.other.endAngleBracket.test(s)) return;
|
|
1433
|
+
let c = C(s.slice(0, -1), "\\");
|
|
1434
|
+
if ((s.length - c.length) % 2 === 0) return;
|
|
1435
|
+
} else {
|
|
1436
|
+
let c = Te(n[2], "()");
|
|
1437
|
+
if (c === -2) return;
|
|
1438
|
+
if (c > -1) {
|
|
1439
|
+
let d = (n[0].indexOf("!") === 0 ? 5 : 4) + n[1].length + c;
|
|
1440
|
+
n[2] = n[2].substring(0, c), n[0] = n[0].substring(0, d).trim(), n[3] = "";
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
let o = C(n[0].slice(0, -1), "\\");
|
|
1444
|
+
if ((n[0].length - o.length) % 2 === 0) return;
|
|
1445
|
+
let i = n[2], a = "";
|
|
1446
|
+
if (this.options.pedantic) {
|
|
1447
|
+
let c = this.rules.other.pedanticHrefTitle.exec(i);
|
|
1448
|
+
c && (i = c[1], a = c[3]);
|
|
1449
|
+
} else a = n[3] ? n[3].slice(1, -1) : "";
|
|
1450
|
+
return i = i.trim(), this.rules.other.startAngleBracket.test(i) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(s) ? i = i.slice(1) : i = i.slice(1, -1)), He(n, { href: i && i.replace(this.rules.inline.anyPunctuation, "$1"), title: a && a.replace(this.rules.inline.anyPunctuation, "$1") }, n[0], this.lexer, this.rules);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
reflink(e, t) {
|
|
1454
|
+
let n = e.charCodeAt(0);
|
|
1455
|
+
if (n !== 91 && n !== 33) return;
|
|
1456
|
+
let r;
|
|
1457
|
+
if ((r = this.rules.inline.reflink.exec(e)) || (r = this.rules.inline.nolink.exec(e))) {
|
|
1458
|
+
let s = r[0].charAt(0) === "!" ? 2 : 1;
|
|
1459
|
+
if (!this.options.pedantic && Ze(e, r[1], s, this.rules)) return;
|
|
1460
|
+
let o = t[W(r[2] || r[1])];
|
|
1461
|
+
if (!o) {
|
|
1462
|
+
let i = r[0].charAt(0);
|
|
1463
|
+
return { type: "text", raw: i, text: i };
|
|
1464
|
+
}
|
|
1465
|
+
return He(r, o, r[0], this.lexer, this.rules);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
emStrong(e, t, n = "") {
|
|
1469
|
+
let r = this.rules.inline.emStrongLDelim.exec(e);
|
|
1470
|
+
if (!r || !r[1] && !r[2] && !r[3] && !r[4]) return;
|
|
1471
|
+
let s = r[0][0], o = n === s, i = t.length - e.length, a = i;
|
|
1472
|
+
for (; !this.options.pedantic && a > 0 && t[a - 1] === s; ) a--;
|
|
1473
|
+
let c = [...t.slice(Math.max(0, a - 2), a)].at(-1) ?? "", u = c === "*" || c === "_" || !!this.rules.inline.punctuation.exec(c);
|
|
1474
|
+
a < i && (n = c);
|
|
1475
|
+
let d = a < i ? u : n === "*" || n === "_" || !!this.rules.inline.punctuation.exec(n);
|
|
1476
|
+
if (r[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
1477
|
+
let h = r[1] || r[3] || "";
|
|
1478
|
+
if (!h || !n || d) {
|
|
1479
|
+
let p = [...r[0]].length - 1, k, m, b = p, f = 0, R = i - a + p, E = !this.options.pedantic && !!c.trim() && (!!h || s === "*" && !u);
|
|
1480
|
+
if (s !== "*" && s !== "_") return;
|
|
1481
|
+
let T = s === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd, U = oe(this, t, s), H = t.length - e.length + p;
|
|
1482
|
+
if (U < H) return;
|
|
1483
|
+
t = t.slice(-1 * e.length + p);
|
|
1484
|
+
let K = U - H;
|
|
1485
|
+
for (T.lastIndex = 0; (r = T.exec(t)) !== null && !(r.index > K); ) {
|
|
1486
|
+
if (k = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !k) continue;
|
|
1487
|
+
if (m = [...k].length, r[3] || r[4]) {
|
|
1488
|
+
b += m;
|
|
1489
|
+
continue;
|
|
1490
|
+
} else if ((r[5] || r[6] || E) && R % 3 && !((R + m) % 3)) {
|
|
1491
|
+
if (o && (r[5] || r[6])) break;
|
|
1492
|
+
f += m;
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
if (b -= m, b > 0) continue;
|
|
1496
|
+
m = Math.min(m, m + b + f);
|
|
1497
|
+
let re = [...r[0]][0].length, B = e.slice(0, p + r.index + re + m);
|
|
1498
|
+
if (Math.min(p, m) % 2) {
|
|
1499
|
+
let se = B.slice(1, -1);
|
|
1500
|
+
return { type: "em", raw: B, text: se, tokens: this.lexer.inlineTokens(se) };
|
|
1501
|
+
}
|
|
1502
|
+
let X = B.slice(2, -2);
|
|
1503
|
+
return { type: "strong", raw: B, text: X, tokens: this.lexer.inlineTokens(X) };
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
codespan(e) {
|
|
1508
|
+
if (e.charCodeAt(0) !== 96) return;
|
|
1509
|
+
let t = this.rules.inline.code.exec(e);
|
|
1510
|
+
if (t) {
|
|
1511
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), r = this.rules.other.nonSpaceChar.test(n), s = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
1512
|
+
return r && s && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
br(e) {
|
|
1516
|
+
let t = e.charCodeAt(0);
|
|
1517
|
+
if (t !== 32 && t !== 92 && t !== 10) return;
|
|
1518
|
+
let n = this.rules.inline.br.exec(e);
|
|
1519
|
+
if (n) return { type: "br", raw: n[0] };
|
|
1520
|
+
}
|
|
1521
|
+
del(e, t, n = "") {
|
|
1522
|
+
if (e.charCodeAt(0) !== 126) return;
|
|
1523
|
+
let r = this.rules.inline.delLDelim.exec(e);
|
|
1524
|
+
if (!r) return;
|
|
1525
|
+
if (!(r[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1526
|
+
let o = [...r[0]].length - 1, i, a, c = o, u = this.rules.inline.delRDelim, d = ae(this, t), h = t.length - e.length + o;
|
|
1527
|
+
if (d < h) return;
|
|
1528
|
+
t = t.slice(-1 * e.length + o);
|
|
1529
|
+
let p = d - h;
|
|
1530
|
+
for (u.lastIndex = 0; (r = u.exec(t)) !== null && !(r.index > p); ) {
|
|
1531
|
+
if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== o)) continue;
|
|
1532
|
+
if (r[3] || r[4]) {
|
|
1533
|
+
c += a;
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
if (c -= a, c > 0) continue;
|
|
1537
|
+
a = Math.min(a, a + c);
|
|
1538
|
+
let k = [...r[0]][0].length, m = e.slice(0, o + r.index + k + a), b = m.slice(o, -o);
|
|
1539
|
+
return { type: "del", raw: m, text: b, tokens: this.lexer.inlineTokens(b) };
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
autolink(e) {
|
|
1544
|
+
if (e.charCodeAt(0) !== 60) return;
|
|
1545
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
1546
|
+
if (t) {
|
|
1547
|
+
let n, r;
|
|
1548
|
+
return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), { type: "link", raw: t[0], text: n, href: r, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
url(e) {
|
|
1552
|
+
let t;
|
|
1553
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
1554
|
+
let n, r;
|
|
1555
|
+
if (t[2] === "@") n = t[0], r = "mailto:" + n;
|
|
1556
|
+
else {
|
|
1557
|
+
let s;
|
|
1558
|
+
do
|
|
1559
|
+
s = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
1560
|
+
while (s !== t[0]);
|
|
1561
|
+
n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
1562
|
+
}
|
|
1563
|
+
return { type: "link", raw: t[0], text: n, href: r, autolink: true, tokens: [{ type: "text", raw: n, text: n }] };
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
inlineText(e) {
|
|
1567
|
+
let t = this.rules.inline.text.exec(e);
|
|
1568
|
+
if (t) {
|
|
1569
|
+
let n = this.lexer.state.inRawBlock;
|
|
1570
|
+
return { type: "text", raw: t[0], text: n ? t[0] : De(t[0]), escaped: n };
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
var w = class l {
|
|
1575
|
+
tokens;
|
|
1576
|
+
options;
|
|
1577
|
+
state;
|
|
1578
|
+
inlineQueue;
|
|
1579
|
+
tokenizer;
|
|
1580
|
+
constructor(e) {
|
|
1581
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || S, this.options.tokenizer = this.options.tokenizer || new _(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, linkParenPossible: true, top: true };
|
|
1582
|
+
let t = { other: O, block: ee.normal, inline: F.normal };
|
|
1583
|
+
this.options.pedantic ? (t.block = ee.pedantic, t.inline = F.pedantic) : this.options.gfm && (t.block = ee.gfm, this.options.breaks ? t.inline = F.breaks : t.inline = F.gfm), this.tokenizer.rules = t;
|
|
1584
|
+
}
|
|
1585
|
+
static get rules() {
|
|
1586
|
+
return { block: ee, inline: F };
|
|
1587
|
+
}
|
|
1588
|
+
static lex(e, t) {
|
|
1589
|
+
return new l(t).lex(e);
|
|
1590
|
+
}
|
|
1591
|
+
static lexInline(e, t) {
|
|
1592
|
+
return new l(t).inlineTokens(e);
|
|
1593
|
+
}
|
|
1594
|
+
lex(e) {
|
|
1595
|
+
e = e.replace(O.carriageReturn, `
|
|
1596
|
+
`), this.blockTokens(e, this.tokens);
|
|
1597
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
1598
|
+
let n = this.inlineQueue[t];
|
|
1599
|
+
this.state.inRawBlock = false, this.inlineTokens(n.src, n.tokens);
|
|
1600
|
+
}
|
|
1601
|
+
return this.inlineQueue = [], this.tokens;
|
|
1602
|
+
}
|
|
1603
|
+
blockTokens(e, t = [], n = false) {
|
|
1604
|
+
this.tokenizer.lexer = this;
|
|
1605
|
+
let r = this.state.lastToken;
|
|
1606
|
+
this.options.pedantic && (e = e.replace(O.tabCharGlobal, " ").replace(O.spaceLine, ""));
|
|
1607
|
+
let s = 1 / 0, o, i = this.options.gfm && !this.options.pedantic && this.tokenizer.paragraph === _.prototype.paragraph;
|
|
1608
|
+
for (; e; ) {
|
|
1609
|
+
if (e.length < s) s = e.length;
|
|
1610
|
+
else {
|
|
1611
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
this.state.lastToken = t.at(-1);
|
|
1615
|
+
let a;
|
|
1616
|
+
if (this.options.extensions?.block?.some((u) => (a = u.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false)) continue;
|
|
1617
|
+
if (a = this.tokenizer.space(e)) {
|
|
1618
|
+
e = e.substring(a.raw.length);
|
|
1619
|
+
let u = t.at(-1);
|
|
1620
|
+
a.raw.length === 1 && u !== void 0 ? u.raw += `
|
|
1621
|
+
` : t.push(a);
|
|
1622
|
+
continue;
|
|
1623
|
+
}
|
|
1624
|
+
if (a = this.tokenizer.code(e)) {
|
|
1625
|
+
e = e.substring(a.raw.length);
|
|
1626
|
+
let u = t.at(-1);
|
|
1627
|
+
u?.type === "paragraph" || u?.type === "text" ? (u.raw += (u.raw.endsWith(`
|
|
1628
|
+
`) ? "" : `
|
|
1629
|
+
`) + a.raw, u.text += `
|
|
1630
|
+
` + a.text, this.inlineQueue.at(-1).src = u.text) : t.push(a);
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
if (a = this.tokenizer.fences(e)) {
|
|
1634
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1635
|
+
continue;
|
|
1636
|
+
}
|
|
1637
|
+
if (a = this.tokenizer.heading(e)) {
|
|
1638
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
if (a = this.tokenizer.hr(e)) {
|
|
1642
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1643
|
+
continue;
|
|
1644
|
+
}
|
|
1645
|
+
if (a = this.tokenizer.blockquote(e)) {
|
|
1646
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
if (a = this.tokenizer.list(e)) {
|
|
1650
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
if (a = this.tokenizer.html(e)) {
|
|
1654
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1655
|
+
continue;
|
|
1656
|
+
}
|
|
1657
|
+
if (a = this.tokenizer.def(e)) {
|
|
1658
|
+
e = e.substring(a.raw.length);
|
|
1659
|
+
let u = t.at(-1);
|
|
1660
|
+
u?.type === "paragraph" || u?.type === "text" ? (u.raw += (u.raw.endsWith(`
|
|
1661
|
+
`) ? "" : `
|
|
1662
|
+
`) + a.raw, u.text += `
|
|
1663
|
+
` + a.raw, this.inlineQueue.at(-1).src = u.text) : (this.tokens.links[a.tag] || (this.tokens.links[a.tag] = { href: a.href, title: a.title }), t.push(a));
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1666
|
+
if (a = this.tokenizer.table(e)) {
|
|
1667
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
if (a = this.tokenizer.lheading(e)) {
|
|
1671
|
+
e = e.substring(a.raw.length), t.push(a);
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
let c = e;
|
|
1675
|
+
if (this.options.extensions?.startBlock) {
|
|
1676
|
+
let u = 1 / 0, d = e.slice(1), h;
|
|
1677
|
+
this.options.extensions.startBlock.forEach((p) => {
|
|
1678
|
+
h = p.call({ lexer: this }, d), typeof h == "number" && h >= 0 && (u = Math.min(u, h));
|
|
1679
|
+
}), u < 1 / 0 && u >= 0 && (c = e.substring(0, u + 1));
|
|
1680
|
+
}
|
|
1681
|
+
if (this.state.top && (a = this.tokenizer.paragraph(c))) {
|
|
1682
|
+
let u = t.at(-1);
|
|
1683
|
+
(n || u === o && i) && u?.type === "paragraph" ? (u.raw += (u.raw.endsWith(`
|
|
1684
|
+
`) ? "" : `
|
|
1685
|
+
`) + a.raw, u.text += `
|
|
1686
|
+
` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text, o = u) : (t.push(a), o = a), n = c.length !== e.length, e = e.substring(a.raw.length);
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
if (a = this.tokenizer.text(e)) {
|
|
1690
|
+
e = e.substring(a.raw.length);
|
|
1691
|
+
let u = t.at(-1);
|
|
1692
|
+
u?.type === "text" ? (u.raw += (u.raw.endsWith(`
|
|
1693
|
+
`) ? "" : `
|
|
1694
|
+
`) + a.raw, u.text += `
|
|
1695
|
+
` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text) : t.push(a);
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
if (e) {
|
|
1699
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
return this.state.top = true, this.state.lastToken = r, t;
|
|
1704
|
+
}
|
|
1705
|
+
inline(e, t = []) {
|
|
1706
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
1707
|
+
}
|
|
1708
|
+
linkInText(e) {
|
|
1709
|
+
if (!e.includes("[")) return false;
|
|
1710
|
+
let t = this.tokenizer.rules.inline.link;
|
|
1711
|
+
for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return true;
|
|
1712
|
+
for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
|
|
1713
|
+
let r = n[0], s = r.lastIndexOf("[");
|
|
1714
|
+
if (!(r.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, W(r.slice(s + 1, -1)))) && !(s > 1 && this.linkInText(r.slice(1, s - 1)))) return true;
|
|
1715
|
+
}
|
|
1716
|
+
return false;
|
|
1717
|
+
}
|
|
1718
|
+
inlineTokens(e, t = []) {
|
|
1719
|
+
this.tokenizer.lexer = this;
|
|
1720
|
+
let n = this.state.linkParenPossible;
|
|
1721
|
+
this.state.linkParenPossible = e.includes(")");
|
|
1722
|
+
try {
|
|
1723
|
+
return this.#t(e, t);
|
|
1724
|
+
} finally {
|
|
1725
|
+
this.state.linkParenPossible = n;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
#t(e, t) {
|
|
1729
|
+
let n = e.includes("*") || e.includes("_") || e.includes("~"), r = n || this.options.hooks?.emStrongMask || this.tokenizer.emStrong !== _.prototype.emStrong || this.tokenizer.del !== _.prototype.del ? this.#r(e) : e;
|
|
1730
|
+
if (!n) return this.#e(e, r, t);
|
|
1731
|
+
qe(this.tokenizer, r);
|
|
1732
|
+
try {
|
|
1733
|
+
return this.#e(e, r, t);
|
|
1734
|
+
} finally {
|
|
1735
|
+
ve(this.tokenizer);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
#e(e, t, n) {
|
|
1739
|
+
let r = false, s = "", o = 1 / 0;
|
|
1740
|
+
for (; e; ) {
|
|
1741
|
+
if (e.length < o) o = e.length;
|
|
1742
|
+
else {
|
|
1743
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1744
|
+
break;
|
|
1745
|
+
}
|
|
1746
|
+
r || (s = ""), r = false;
|
|
1747
|
+
let i;
|
|
1748
|
+
if (this.options.extensions?.inline?.some((u) => (i = u.call({ lexer: this }, e, n)) ? (e = e.substring(i.raw.length), n.push(i), true) : false)) continue;
|
|
1749
|
+
if (i = this.tokenizer.escape(e)) {
|
|
1750
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1751
|
+
continue;
|
|
1752
|
+
}
|
|
1753
|
+
if (i = this.tokenizer.tag(e)) {
|
|
1754
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1755
|
+
continue;
|
|
1756
|
+
}
|
|
1757
|
+
if (i = this.tokenizer.link(e)) {
|
|
1758
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
if (i = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1762
|
+
e = e.substring(i.raw.length);
|
|
1763
|
+
let u = n.at(-1);
|
|
1764
|
+
i.type === "text" && u?.type === "text" ? (u.raw += i.raw, u.text += i.text) : n.push(i);
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
let a = e[0];
|
|
1768
|
+
if (a === "*" || a === "_") {
|
|
1769
|
+
let u = t.length - e.length;
|
|
1770
|
+
if (oe(this.tokenizer, t, a) <= u) {
|
|
1771
|
+
let h = 1;
|
|
1772
|
+
for (; h < e.length && e.charCodeAt(h) === a.charCodeAt(0); ) h++;
|
|
1773
|
+
let p = e.substring(0, h), k = n.at(-1);
|
|
1774
|
+
k?.type === "text" && !k.escaped ? (k.raw += p, k.text += p) : n.push({ type: "text", raw: p, text: p, escaped: false }), e = e.substring(h), s = a, r = true;
|
|
1775
|
+
continue;
|
|
1776
|
+
}
|
|
1777
|
+
} else if (a === "~") {
|
|
1778
|
+
let u = t.length - e.length;
|
|
1779
|
+
if (ae(this.tokenizer, t) <= u) {
|
|
1780
|
+
let h = 1;
|
|
1781
|
+
for (; h < e.length && e.charCodeAt(h) === 126; ) h++;
|
|
1782
|
+
let p = e.substring(0, h), k = n.at(-1);
|
|
1783
|
+
k?.type === "text" && !k.escaped ? (k.raw += p, k.text += p) : n.push({ type: "text", raw: p, text: p, escaped: false }), e = e.substring(h), s = a, r = true;
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
if (i = this.tokenizer.emStrong(e, t, s)) {
|
|
1788
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (i = this.tokenizer.codespan(e)) {
|
|
1792
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1793
|
+
continue;
|
|
1794
|
+
}
|
|
1795
|
+
if (i = this.tokenizer.br(e)) {
|
|
1796
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1797
|
+
continue;
|
|
1798
|
+
}
|
|
1799
|
+
if (i = this.tokenizer.del(e, t, s)) {
|
|
1800
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1801
|
+
continue;
|
|
1802
|
+
}
|
|
1803
|
+
if (i = this.tokenizer.autolink(e)) {
|
|
1804
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1805
|
+
continue;
|
|
1806
|
+
}
|
|
1807
|
+
if (!this.state.inLink && (i = this.tokenizer.url(e))) {
|
|
1808
|
+
e = e.substring(i.raw.length), n.push(i);
|
|
1809
|
+
continue;
|
|
1810
|
+
}
|
|
1811
|
+
let c = e;
|
|
1812
|
+
if (this.options.extensions?.startInline) {
|
|
1813
|
+
let u = 1 / 0, d = e.slice(1), h;
|
|
1814
|
+
this.options.extensions.startInline.forEach((p) => {
|
|
1815
|
+
h = p.call({ lexer: this }, d), typeof h == "number" && h >= 0 && (u = Math.min(u, h));
|
|
1816
|
+
}), u < 1 / 0 && u >= 0 && (c = e.substring(0, u + 1));
|
|
1817
|
+
}
|
|
1818
|
+
if (i = this.tokenizer.inlineText(c)) {
|
|
1819
|
+
e = e.substring(i.raw.length), i.raw.slice(-1) !== "_" && (s = i.raw.slice(-1)), r = true;
|
|
1820
|
+
let u = n.at(-1);
|
|
1821
|
+
u?.type === "text" ? (u.raw += i.raw, u.text += i.text) : n.push(i);
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
if (e) {
|
|
1825
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return n;
|
|
1830
|
+
}
|
|
1831
|
+
#n(e) {
|
|
1832
|
+
let { blockSkip: t, tag: n, autolink: r } = this.tokenizer.rules.inline, s = "", o = 0, i;
|
|
1833
|
+
for (t.lastIndex = 0; i = t.exec(e); ) {
|
|
1834
|
+
let a = i.index + (i[2] ? i[2].length : 0), c = i.index + i[0].length;
|
|
1835
|
+
if (e.charAt(a) === "<") {
|
|
1836
|
+
let u = e.slice(a), d = n.exec(u) || r.exec(u);
|
|
1837
|
+
if (!d) {
|
|
1838
|
+
t.lastIndex = a + 1;
|
|
1839
|
+
continue;
|
|
1840
|
+
}
|
|
1841
|
+
c = a + d[0].length, t.lastIndex = c;
|
|
1842
|
+
}
|
|
1843
|
+
s += e.slice(o, a) + "[" + "a".repeat(c - a - 2) + "]", o = c;
|
|
1844
|
+
}
|
|
1845
|
+
return s + e.slice(o);
|
|
1846
|
+
}
|
|
1847
|
+
#r(e) {
|
|
1848
|
+
let t = e;
|
|
1849
|
+
if (this.tokens.links && e.includes("[")) {
|
|
1850
|
+
let n = this.tokenizer.rules.inline.reflinkSearch, r = (s) => {
|
|
1851
|
+
let o = s.lastIndexOf("[");
|
|
1852
|
+
if (!Object.hasOwn(this.tokens.links, W(s.slice(o + 1, -1)))) return s;
|
|
1853
|
+
if (o > 1 && s.charAt(0) !== "!") {
|
|
1854
|
+
let i = s.slice(1, o - 1);
|
|
1855
|
+
if (this.linkInText(i)) return "[" + i.replace(n, r) + "][" + "a".repeat(s.length - o - 2) + "]";
|
|
1856
|
+
}
|
|
1857
|
+
return "[" + "a".repeat(s.length - 2) + "]";
|
|
1858
|
+
};
|
|
1859
|
+
t = t.replace(n, r);
|
|
1860
|
+
}
|
|
1861
|
+
return t = t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode, (n, r, s) => s ? "+".repeat(n.length) : r ? r + n.slice(r.length, -r.length).replace(/`/g, "+") + r : n), t = this.#n(t), t = this.options.hooks?.emStrongMask?.call({ lexer: this }, t) ?? t, t;
|
|
1862
|
+
}
|
|
1863
|
+
infiniteLoopError(e) {
|
|
1864
|
+
let t = "Infinite loop on byte: " + e;
|
|
1865
|
+
if (this.options.silent) console.error(t);
|
|
1866
|
+
else throw new Error(t);
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
var I = class {
|
|
1870
|
+
options;
|
|
1871
|
+
parser;
|
|
1872
|
+
constructor(e) {
|
|
1873
|
+
this.options = e || S;
|
|
1874
|
+
}
|
|
1875
|
+
space(e) {
|
|
1876
|
+
return "";
|
|
1877
|
+
}
|
|
1878
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
1879
|
+
let r = (t || "").match(O.notSpaceStart)?.[0], s = e ? e.replace(O.endingNewline, "") + `
|
|
1880
|
+
` : "";
|
|
1881
|
+
return r ? '<pre><code class="language-' + y(r) + '">' + (n ? s : y(s, true)) + `</code></pre>
|
|
1882
|
+
` : "<pre><code>" + (n ? s : y(s, true)) + `</code></pre>
|
|
1883
|
+
`;
|
|
1884
|
+
}
|
|
1885
|
+
blockquote({ tokens: e }) {
|
|
1886
|
+
return `<blockquote>
|
|
1887
|
+
${this.parser.parse(e)}</blockquote>
|
|
1888
|
+
`;
|
|
1889
|
+
}
|
|
1890
|
+
html({ text: e }) {
|
|
1891
|
+
return e;
|
|
1892
|
+
}
|
|
1893
|
+
def(e) {
|
|
1894
|
+
return "";
|
|
1895
|
+
}
|
|
1896
|
+
heading({ tokens: e, depth: t }) {
|
|
1897
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
1898
|
+
`;
|
|
1899
|
+
}
|
|
1900
|
+
hr(e) {
|
|
1901
|
+
return `<hr>
|
|
1902
|
+
`;
|
|
1903
|
+
}
|
|
1904
|
+
list(e) {
|
|
1905
|
+
let t = e.ordered, n = e.start, r = "";
|
|
1906
|
+
for (let i = 0; i < e.items.length; i++) {
|
|
1907
|
+
let a = e.items[i];
|
|
1908
|
+
r += this.listitem(a);
|
|
1909
|
+
}
|
|
1910
|
+
let s = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1911
|
+
return "<" + s + o + `>
|
|
1912
|
+
` + r + "</" + s + `>
|
|
1913
|
+
`;
|
|
1914
|
+
}
|
|
1915
|
+
listitem(e) {
|
|
1916
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
1917
|
+
`;
|
|
1918
|
+
}
|
|
1919
|
+
checkbox({ checked: e }) {
|
|
1920
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
1921
|
+
}
|
|
1922
|
+
paragraph({ tokens: e }) {
|
|
1923
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
1924
|
+
`;
|
|
1925
|
+
}
|
|
1926
|
+
table(e) {
|
|
1927
|
+
let t = "", n = "";
|
|
1928
|
+
for (let s = 0; s < e.header.length; s++) n += this.tablecell(e.header[s]);
|
|
1929
|
+
t += this.tablerow({ text: n });
|
|
1930
|
+
let r = "";
|
|
1931
|
+
for (let s = 0; s < e.rows.length; s++) {
|
|
1932
|
+
let o = e.rows[s];
|
|
1933
|
+
n = "";
|
|
1934
|
+
for (let i = 0; i < o.length; i++) n += this.tablecell(o[i]);
|
|
1935
|
+
r += this.tablerow({ text: n });
|
|
1936
|
+
}
|
|
1937
|
+
return r && (r = `<tbody>${r}</tbody>`), `<table>
|
|
1938
|
+
<thead>
|
|
1939
|
+
` + t + `</thead>
|
|
1940
|
+
` + r + `</table>
|
|
1941
|
+
`;
|
|
1942
|
+
}
|
|
1943
|
+
tablerow({ text: e }) {
|
|
1944
|
+
return `<tr>
|
|
1945
|
+
${e}</tr>
|
|
1946
|
+
`;
|
|
1947
|
+
}
|
|
1948
|
+
tablecell(e) {
|
|
1949
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
1950
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
1951
|
+
`;
|
|
1952
|
+
}
|
|
1953
|
+
strong({ tokens: e }) {
|
|
1954
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
1955
|
+
}
|
|
1956
|
+
em({ tokens: e }) {
|
|
1957
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
1958
|
+
}
|
|
1959
|
+
codespan({ text: e }) {
|
|
1960
|
+
return `<code>${y(e, true)}</code>`;
|
|
1961
|
+
}
|
|
1962
|
+
br(e) {
|
|
1963
|
+
return "<br>";
|
|
1964
|
+
}
|
|
1965
|
+
del({ tokens: e }) {
|
|
1966
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1967
|
+
}
|
|
1968
|
+
link({ href: e, title: t, text: n, tokens: r, autolink: s }) {
|
|
1969
|
+
let o = s ? y(n, true) : this.parser.parseInline(r), i = xe(e);
|
|
1970
|
+
if (i === null) return o;
|
|
1971
|
+
e = y(i, s);
|
|
1972
|
+
let a = '<a href="' + e + '"';
|
|
1973
|
+
return t && (a += ' title="' + y(t) + '"'), a += ">" + o + "</a>", a;
|
|
1974
|
+
}
|
|
1975
|
+
image({ href: e, title: t, text: n, tokens: r }) {
|
|
1976
|
+
r && (n = this.parser.parseInline(r, this.parser.textRenderer));
|
|
1977
|
+
let s = xe(e);
|
|
1978
|
+
if (s === null) return y(n);
|
|
1979
|
+
e = s;
|
|
1980
|
+
let o = `<img src="${y(e)}" alt="${y(n)}"`;
|
|
1981
|
+
return t && (o += ` title="${y(t)}"`), o += ">", o;
|
|
1982
|
+
}
|
|
1983
|
+
text(e) {
|
|
1984
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : y(e.text);
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
var z = class {
|
|
1988
|
+
parser;
|
|
1989
|
+
strong({ text: e, tokens: t }) {
|
|
1990
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
1991
|
+
}
|
|
1992
|
+
em({ text: e, tokens: t }) {
|
|
1993
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
1994
|
+
}
|
|
1995
|
+
codespan({ text: e }) {
|
|
1996
|
+
return e;
|
|
1997
|
+
}
|
|
1998
|
+
del({ text: e, tokens: t }) {
|
|
1999
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
2000
|
+
}
|
|
2001
|
+
html({ text: e }) {
|
|
2002
|
+
return e;
|
|
2003
|
+
}
|
|
2004
|
+
text({ text: e }) {
|
|
2005
|
+
return e;
|
|
2006
|
+
}
|
|
2007
|
+
link({ text: e, tokens: t }) {
|
|
2008
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
2009
|
+
}
|
|
2010
|
+
image({ text: e, tokens: t }) {
|
|
2011
|
+
return t ? this.parser.parseInline(t, this) : e;
|
|
2012
|
+
}
|
|
2013
|
+
br() {
|
|
2014
|
+
return `
|
|
2015
|
+
`;
|
|
2016
|
+
}
|
|
2017
|
+
checkbox({ raw: e }) {
|
|
2018
|
+
return e;
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
var P = class l2 {
|
|
2022
|
+
options;
|
|
2023
|
+
renderer;
|
|
2024
|
+
textRenderer;
|
|
2025
|
+
constructor(e) {
|
|
2026
|
+
this.options = e || S, this.options.renderer = this.options.renderer || new I(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new z(), this.textRenderer.parser = this;
|
|
2027
|
+
}
|
|
2028
|
+
static parse(e, t) {
|
|
2029
|
+
return new l2(t).parse(e);
|
|
2030
|
+
}
|
|
2031
|
+
static parseInline(e, t) {
|
|
2032
|
+
return new l2(t).parseInline(e);
|
|
2033
|
+
}
|
|
2034
|
+
parse(e) {
|
|
2035
|
+
this.renderer.parser = this;
|
|
2036
|
+
let t = "";
|
|
2037
|
+
for (let n = 0; n < e.length; n++) {
|
|
2038
|
+
let r = e[n];
|
|
2039
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
2040
|
+
let o = r, i = this.options.extensions.renderers[o.type].call({ parser: this }, o);
|
|
2041
|
+
if (i !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(o.type)) {
|
|
2042
|
+
t += i === false ? "" : i ?? "";
|
|
2043
|
+
continue;
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
let s = r;
|
|
2047
|
+
switch (s.type) {
|
|
2048
|
+
case "space": {
|
|
2049
|
+
t += this.renderer.space(s);
|
|
2050
|
+
break;
|
|
2051
|
+
}
|
|
2052
|
+
case "hr": {
|
|
2053
|
+
t += this.renderer.hr(s);
|
|
2054
|
+
break;
|
|
2055
|
+
}
|
|
2056
|
+
case "heading": {
|
|
2057
|
+
t += this.renderer.heading(s);
|
|
2058
|
+
break;
|
|
2059
|
+
}
|
|
2060
|
+
case "code": {
|
|
2061
|
+
t += this.renderer.code(s);
|
|
2062
|
+
break;
|
|
2063
|
+
}
|
|
2064
|
+
case "table": {
|
|
2065
|
+
t += this.renderer.table(s);
|
|
2066
|
+
break;
|
|
2067
|
+
}
|
|
2068
|
+
case "blockquote": {
|
|
2069
|
+
t += this.renderer.blockquote(s);
|
|
2070
|
+
break;
|
|
2071
|
+
}
|
|
2072
|
+
case "list": {
|
|
2073
|
+
t += this.renderer.list(s);
|
|
2074
|
+
break;
|
|
2075
|
+
}
|
|
2076
|
+
case "checkbox": {
|
|
2077
|
+
t += this.renderer.checkbox(s);
|
|
2078
|
+
break;
|
|
2079
|
+
}
|
|
2080
|
+
case "html": {
|
|
2081
|
+
t += this.renderer.html(s);
|
|
2082
|
+
break;
|
|
2083
|
+
}
|
|
2084
|
+
case "def": {
|
|
2085
|
+
t += this.renderer.def(s);
|
|
2086
|
+
break;
|
|
2087
|
+
}
|
|
2088
|
+
case "paragraph": {
|
|
2089
|
+
t += this.renderer.paragraph(s);
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
2092
|
+
case "text": {
|
|
2093
|
+
t += this.renderer.text(s);
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
default: {
|
|
2097
|
+
let o = 'Token with "' + s.type + '" type was not found.';
|
|
2098
|
+
if (this.options.silent) return console.error(o), "";
|
|
2099
|
+
throw new Error(o);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
return t;
|
|
2104
|
+
}
|
|
2105
|
+
parseInline(e, t = this.renderer) {
|
|
2106
|
+
this.renderer.parser = this;
|
|
2107
|
+
let n = "";
|
|
2108
|
+
for (let r = 0; r < e.length; r++) {
|
|
2109
|
+
let s = e[r];
|
|
2110
|
+
if (this.options.extensions?.renderers?.[s.type]) {
|
|
2111
|
+
let i = this.options.extensions.renderers[s.type].call({ parser: this }, s);
|
|
2112
|
+
if (i !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(s.type)) {
|
|
2113
|
+
n += i === false ? "" : i ?? "";
|
|
2114
|
+
continue;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
let o = s;
|
|
2118
|
+
switch (o.type) {
|
|
2119
|
+
case "escape": {
|
|
2120
|
+
n += t.text(o);
|
|
2121
|
+
break;
|
|
2122
|
+
}
|
|
2123
|
+
case "html": {
|
|
2124
|
+
n += t.html(o);
|
|
2125
|
+
break;
|
|
2126
|
+
}
|
|
2127
|
+
case "link": {
|
|
2128
|
+
n += t.link(o);
|
|
2129
|
+
break;
|
|
2130
|
+
}
|
|
2131
|
+
case "image": {
|
|
2132
|
+
n += t.image(o);
|
|
2133
|
+
break;
|
|
2134
|
+
}
|
|
2135
|
+
case "checkbox": {
|
|
2136
|
+
n += t.checkbox(o);
|
|
2137
|
+
break;
|
|
2138
|
+
}
|
|
2139
|
+
case "strong": {
|
|
2140
|
+
n += t.strong(o);
|
|
2141
|
+
break;
|
|
2142
|
+
}
|
|
2143
|
+
case "em": {
|
|
2144
|
+
n += t.em(o);
|
|
2145
|
+
break;
|
|
2146
|
+
}
|
|
2147
|
+
case "codespan": {
|
|
2148
|
+
n += t.codespan(o);
|
|
2149
|
+
break;
|
|
2150
|
+
}
|
|
2151
|
+
case "br": {
|
|
2152
|
+
n += t.br(o);
|
|
2153
|
+
break;
|
|
2154
|
+
}
|
|
2155
|
+
case "del": {
|
|
2156
|
+
n += t.del(o);
|
|
2157
|
+
break;
|
|
2158
|
+
}
|
|
2159
|
+
case "text": {
|
|
2160
|
+
n += t.text(o);
|
|
2161
|
+
break;
|
|
2162
|
+
}
|
|
2163
|
+
default: {
|
|
2164
|
+
let i = 'Token with "' + o.type + '" type was not found.';
|
|
2165
|
+
if (this.options.silent) return console.error(i), "";
|
|
2166
|
+
throw new Error(i);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
return n;
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
var A = class {
|
|
2174
|
+
options;
|
|
2175
|
+
block;
|
|
2176
|
+
constructor(e) {
|
|
2177
|
+
this.options = e || S;
|
|
2178
|
+
}
|
|
2179
|
+
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
2180
|
+
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2181
|
+
preprocess(e) {
|
|
2182
|
+
return e;
|
|
2183
|
+
}
|
|
2184
|
+
postprocess(e) {
|
|
2185
|
+
return e;
|
|
2186
|
+
}
|
|
2187
|
+
processAllTokens(e) {
|
|
2188
|
+
return e;
|
|
2189
|
+
}
|
|
2190
|
+
emStrongMask(e) {
|
|
2191
|
+
return e;
|
|
2192
|
+
}
|
|
2193
|
+
provideLexer(e = this.block) {
|
|
2194
|
+
return e ? w.lex : w.lexInline;
|
|
2195
|
+
}
|
|
2196
|
+
provideParser(e = this.block) {
|
|
2197
|
+
return e ? P.parse : P.parseInline;
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
function M(l3, e) {
|
|
2201
|
+
if (Array.isArray(e)) for (let t = 0; t < e.length; t++) l3.push(e[t]);
|
|
2202
|
+
else l3.push(e);
|
|
2203
|
+
}
|
|
2204
|
+
var ne = class {
|
|
2205
|
+
defaults = G();
|
|
2206
|
+
options = this.setOptions;
|
|
2207
|
+
parse = this.parseMarkdown(true);
|
|
2208
|
+
parseInline = this.parseMarkdown(false);
|
|
2209
|
+
Parser = P;
|
|
2210
|
+
Renderer = I;
|
|
2211
|
+
TextRenderer = z;
|
|
2212
|
+
Lexer = w;
|
|
2213
|
+
Tokenizer = _;
|
|
2214
|
+
Hooks = A;
|
|
2215
|
+
constructor(...e) {
|
|
2216
|
+
this.use(...e);
|
|
2217
|
+
}
|
|
2218
|
+
walkTokens(e, t) {
|
|
2219
|
+
let n = [];
|
|
2220
|
+
for (let r of e) switch (M(n, t.call(this, r)), r.type) {
|
|
2221
|
+
case "table": {
|
|
2222
|
+
let s = r;
|
|
2223
|
+
for (let o of s.header) M(n, this.walkTokens(o.tokens, t));
|
|
2224
|
+
for (let o of s.rows) for (let i of o) M(n, this.walkTokens(i.tokens, t));
|
|
2225
|
+
break;
|
|
2226
|
+
}
|
|
2227
|
+
case "list": {
|
|
2228
|
+
let s = r;
|
|
2229
|
+
M(n, this.walkTokens(s.items, t));
|
|
2230
|
+
break;
|
|
2231
|
+
}
|
|
2232
|
+
default: {
|
|
2233
|
+
let s = r;
|
|
2234
|
+
this.defaults.extensions?.childTokens?.[s.type] ? this.defaults.extensions.childTokens[s.type].forEach((o) => {
|
|
2235
|
+
let i = s[o].flat(1 / 0);
|
|
2236
|
+
M(n, this.walkTokens(i, t));
|
|
2237
|
+
}) : s.tokens && M(n, this.walkTokens(s.tokens, t));
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
return n;
|
|
2241
|
+
}
|
|
2242
|
+
use(...e) {
|
|
2243
|
+
let t = this.defaults.extensions || { renderers: /* @__PURE__ */ Object.create(null), childTokens: /* @__PURE__ */ Object.create(null) };
|
|
2244
|
+
return e.forEach((n) => {
|
|
2245
|
+
let r = { ...n };
|
|
2246
|
+
if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach((s) => {
|
|
2247
|
+
if (!s.name) throw new Error("extension name required");
|
|
2248
|
+
if ("renderer" in s) {
|
|
2249
|
+
let o = t.renderers[s.name];
|
|
2250
|
+
o ? t.renderers[s.name] = function(...i) {
|
|
2251
|
+
let a = s.renderer.apply(this, i);
|
|
2252
|
+
return a === false && (a = o.apply(this, i)), a;
|
|
2253
|
+
} : t.renderers[s.name] = s.renderer;
|
|
2254
|
+
}
|
|
2255
|
+
if ("tokenizer" in s) {
|
|
2256
|
+
if (!s.level || s.level !== "block" && s.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
2257
|
+
let o = t[s.level];
|
|
2258
|
+
o ? o.unshift(s.tokenizer) : t[s.level] = [s.tokenizer], s.start && (s.level === "block" ? t.startBlock ? t.startBlock.push(s.start) : t.startBlock = [s.start] : s.level === "inline" && (t.startInline ? t.startInline.push(s.start) : t.startInline = [s.start]));
|
|
2259
|
+
}
|
|
2260
|
+
"childTokens" in s && s.childTokens && (t.childTokens[s.name] = s.childTokens);
|
|
2261
|
+
}), r.extensions = t), n.renderer) {
|
|
2262
|
+
let s = this.defaults.renderer || new I(this.defaults);
|
|
2263
|
+
for (let o in n.renderer) {
|
|
2264
|
+
if (!(o in s)) throw new Error(`renderer '${o}' does not exist`);
|
|
2265
|
+
if (["options", "parser"].includes(o)) continue;
|
|
2266
|
+
let i = o, a = n.renderer[i], c = s[i];
|
|
2267
|
+
s[i] = (...u) => {
|
|
2268
|
+
let d = a.apply(s, u);
|
|
2269
|
+
return d === false && (d = c.apply(s, u)), d === false ? "" : d ?? "";
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
r.renderer = s;
|
|
2273
|
+
}
|
|
2274
|
+
if (n.tokenizer) {
|
|
2275
|
+
let s = this.defaults.tokenizer || new _(this.defaults);
|
|
2276
|
+
for (let o in n.tokenizer) {
|
|
2277
|
+
if (!(o in s)) throw new Error(`tokenizer '${o}' does not exist`);
|
|
2278
|
+
if (["options", "rules", "lexer"].includes(o)) continue;
|
|
2279
|
+
let i = o, a = n.tokenizer[i], c = s[i];
|
|
2280
|
+
s[i] = (...u) => {
|
|
2281
|
+
let d = a.apply(s, u);
|
|
2282
|
+
return d === false && (d = c.apply(s, u)), d;
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
r.tokenizer = s;
|
|
2286
|
+
}
|
|
2287
|
+
if (n.hooks) {
|
|
2288
|
+
let s = this.defaults.hooks || new A();
|
|
2289
|
+
for (let o in n.hooks) {
|
|
2290
|
+
if (!(o in s)) throw new Error(`hook '${o}' does not exist`);
|
|
2291
|
+
if (["options", "block"].includes(o)) continue;
|
|
2292
|
+
let i = o, a = n.hooks[i], c = s[i];
|
|
2293
|
+
A.passThroughHooks.has(o) ? s[i] = (u) => {
|
|
2294
|
+
if (s.options.async && A.passThroughHooksRespectAsync.has(o)) return (async () => {
|
|
2295
|
+
let h = await a.call(s, u);
|
|
2296
|
+
return c.call(s, h);
|
|
2297
|
+
})();
|
|
2298
|
+
let d = a.call(s, u);
|
|
2299
|
+
return c.call(s, d);
|
|
2300
|
+
} : s[i] = (...u) => {
|
|
2301
|
+
if (s.options.async) return (async () => {
|
|
2302
|
+
let h = await a.apply(s, u);
|
|
2303
|
+
return h === false && (h = await c.apply(s, u)), h;
|
|
2304
|
+
})();
|
|
2305
|
+
let d = a.apply(s, u);
|
|
2306
|
+
return d === false && (d = c.apply(s, u)), d;
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
r.hooks = s;
|
|
2310
|
+
}
|
|
2311
|
+
if (n.walkTokens) {
|
|
2312
|
+
let s = this.defaults.walkTokens, o = n.walkTokens;
|
|
2313
|
+
r.walkTokens = function(i) {
|
|
2314
|
+
let a = [];
|
|
2315
|
+
return M(a, o.call(this, i)), s && M(a, s.call(this, i)), a;
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
this.defaults = { ...this.defaults, ...r };
|
|
2319
|
+
}), this;
|
|
2320
|
+
}
|
|
2321
|
+
setOptions(e) {
|
|
2322
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
2323
|
+
}
|
|
2324
|
+
lexer(e, t) {
|
|
2325
|
+
return w.lex(e, t ?? this.defaults);
|
|
2326
|
+
}
|
|
2327
|
+
parser(e, t) {
|
|
2328
|
+
return P.parse(e, t ?? this.defaults);
|
|
2329
|
+
}
|
|
2330
|
+
parseMarkdown(e) {
|
|
2331
|
+
return (n, r) => {
|
|
2332
|
+
let s = { ...r }, o = { ...this.defaults, ...s }, i = this.onError(!!o.silent, !!o.async);
|
|
2333
|
+
if (this.defaults.async === true && s.async === false) return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
2334
|
+
if (typeof n > "u" || n === null) return i(new Error("marked(): input parameter is undefined or null"));
|
|
2335
|
+
if (typeof n != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
2336
|
+
if (o.hooks && (o.hooks.options = o, o.hooks.block = e), o.async) return (async () => {
|
|
2337
|
+
let a = o.hooks ? await o.hooks.preprocess(n) : n, u = await (o.hooks ? await o.hooks.provideLexer(e) : e ? w.lex : w.lexInline)(a, o), d = o.hooks ? await o.hooks.processAllTokens(u) : u;
|
|
2338
|
+
o.walkTokens && await Promise.all(this.walkTokens(d, o.walkTokens));
|
|
2339
|
+
let p = await (o.hooks ? await o.hooks.provideParser(e) : e ? P.parse : P.parseInline)(d, o);
|
|
2340
|
+
return o.hooks ? await o.hooks.postprocess(p) : p;
|
|
2341
|
+
})().catch(i);
|
|
2342
|
+
try {
|
|
2343
|
+
o.hooks && (n = o.hooks.preprocess(n));
|
|
2344
|
+
let c = (o.hooks ? o.hooks.provideLexer(e) : e ? w.lex : w.lexInline)(n, o);
|
|
2345
|
+
o.hooks && (c = o.hooks.processAllTokens(c)), o.walkTokens && this.walkTokens(c, o.walkTokens);
|
|
2346
|
+
let d = (o.hooks ? o.hooks.provideParser(e) : e ? P.parse : P.parseInline)(c, o);
|
|
2347
|
+
return o.hooks && (d = o.hooks.postprocess(d)), d;
|
|
2348
|
+
} catch (a) {
|
|
2349
|
+
return i(a);
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
onError(e, t) {
|
|
2354
|
+
return (n) => {
|
|
2355
|
+
if (n.message += `
|
|
2356
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
2357
|
+
let r = "<p>An error occurred:</p><pre>" + y(n.message + "", true) + "</pre>";
|
|
2358
|
+
return t ? Promise.resolve(r) : r;
|
|
2359
|
+
}
|
|
2360
|
+
if (t) return Promise.reject(n);
|
|
2361
|
+
throw n;
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
var v = new ne();
|
|
2366
|
+
function x(l3, e) {
|
|
2367
|
+
return v.parse(l3, e);
|
|
2368
|
+
}
|
|
2369
|
+
x.options = x.setOptions = function(l3) {
|
|
2370
|
+
return v.setOptions(l3), x.defaults = v.defaults, ue(x.defaults), x;
|
|
2371
|
+
};
|
|
2372
|
+
x.getDefaults = G;
|
|
2373
|
+
x.defaults = S;
|
|
2374
|
+
function jt(...l3) {
|
|
2375
|
+
return v.use(...l3), x.defaults = v.defaults, ue(x.defaults), x;
|
|
2376
|
+
}
|
|
2377
|
+
x.use = jt;
|
|
2378
|
+
x.walkTokens = function(l3, e) {
|
|
2379
|
+
return v.walkTokens(l3, e);
|
|
2380
|
+
};
|
|
2381
|
+
x.parseInline = v.parseInline;
|
|
2382
|
+
x.Parser = P;
|
|
2383
|
+
x.parser = P.parse;
|
|
2384
|
+
x.Renderer = I;
|
|
2385
|
+
x.TextRenderer = z;
|
|
2386
|
+
x.Lexer = w;
|
|
2387
|
+
x.lexer = w.lex;
|
|
2388
|
+
x.Tokenizer = _;
|
|
2389
|
+
x.Hooks = A;
|
|
2390
|
+
x.parse = x;
|
|
2391
|
+
var En = x.options;
|
|
2392
|
+
var zn = x.setOptions;
|
|
2393
|
+
var Mn = x.walkTokens;
|
|
2394
|
+
var Bn = x.parseInline;
|
|
2395
|
+
var qn = P.parse;
|
|
2396
|
+
var vn = w.lex;
|
|
2397
|
+
|
|
2398
|
+
// taskflow-source:src/client/components/markdown-preview.jsx
|
|
2399
|
+
var safeHref = (href) => {
|
|
2400
|
+
try {
|
|
2401
|
+
const u = new URL(href);
|
|
2402
|
+
return ["http:", "https:", "mailto:"].includes(u.protocol) && !u.username && !u.password ? href : null;
|
|
2403
|
+
} catch {
|
|
2404
|
+
return href.startsWith("#") ? href : null;
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
function MarkdownPreview({ text, label = "Markdown 文档预览" }) {
|
|
2408
|
+
const nodes = (0, import_react13.useMemo)(() => {
|
|
2409
|
+
const render = (tokens, depth = 0) => depth > 64 ? null : tokens.map((t, i) => {
|
|
2410
|
+
const inner = () => t.tokens ? render(t.tokens, depth + 1) : t.text;
|
|
2411
|
+
switch (t.type) {
|
|
2412
|
+
case "space":
|
|
2413
|
+
return null;
|
|
2414
|
+
case "heading":
|
|
2415
|
+
return import_react13.default.createElement(`h${t.depth}`, { key: i }, inner());
|
|
2416
|
+
case "paragraph":
|
|
2417
|
+
return /* @__PURE__ */ import_react13.default.createElement("p", { key: i }, inner());
|
|
2418
|
+
case "strong":
|
|
2419
|
+
return /* @__PURE__ */ import_react13.default.createElement("strong", { key: i }, inner());
|
|
2420
|
+
case "em":
|
|
2421
|
+
return /* @__PURE__ */ import_react13.default.createElement("em", { key: i }, inner());
|
|
2422
|
+
case "del":
|
|
2423
|
+
return /* @__PURE__ */ import_react13.default.createElement("del", { key: i }, inner());
|
|
2424
|
+
case "code":
|
|
2425
|
+
return /* @__PURE__ */ import_react13.default.createElement("pre", { key: i }, /* @__PURE__ */ import_react13.default.createElement("code", null, t.text));
|
|
2426
|
+
case "codespan":
|
|
2427
|
+
return /* @__PURE__ */ import_react13.default.createElement("code", { key: i }, t.text);
|
|
2428
|
+
case "blockquote":
|
|
2429
|
+
return /* @__PURE__ */ import_react13.default.createElement("blockquote", { key: i }, inner());
|
|
2430
|
+
case "br":
|
|
2431
|
+
return /* @__PURE__ */ import_react13.default.createElement("br", { key: i });
|
|
2432
|
+
case "hr":
|
|
2433
|
+
return /* @__PURE__ */ import_react13.default.createElement("hr", { key: i });
|
|
2434
|
+
case "link": {
|
|
2435
|
+
const href = safeHref(t.href);
|
|
2436
|
+
return href ? /* @__PURE__ */ import_react13.default.createElement("a", { key: i, href, target: "_blank", rel: "noopener noreferrer" }, inner()) : /* @__PURE__ */ import_react13.default.createElement("span", { key: i }, inner());
|
|
2437
|
+
}
|
|
2438
|
+
case "image":
|
|
2439
|
+
return /* @__PURE__ */ import_react13.default.createElement("span", { key: i, className: "tf-markdown-image" }, "[图片:", t.text || "未命名", "]");
|
|
2440
|
+
case "list":
|
|
2441
|
+
return import_react13.default.createElement(t.ordered ? "ol" : "ul", { key: i, start: t.ordered ? t.start : void 0 }, t.items.map((item, j) => /* @__PURE__ */ import_react13.default.createElement("li", { key: j }, item.task && /* @__PURE__ */ import_react13.default.createElement("input", { type: "checkbox", checked: !!item.checked, readOnly: true, "aria-label": item.checked ? "已完成" : "未完成" }), " ", render(item.tokens, depth + 1))));
|
|
2442
|
+
case "table":
|
|
2443
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", { className: "tf-markdown-table", key: i }, /* @__PURE__ */ import_react13.default.createElement("table", null, /* @__PURE__ */ import_react13.default.createElement("thead", null, /* @__PURE__ */ import_react13.default.createElement("tr", null, t.header.map((c, j) => /* @__PURE__ */ import_react13.default.createElement("th", { key: j }, render(c.tokens, depth + 1))))), /* @__PURE__ */ import_react13.default.createElement("tbody", null, t.rows.map((row, j) => /* @__PURE__ */ import_react13.default.createElement("tr", { key: j }, row.map((c, k) => /* @__PURE__ */ import_react13.default.createElement("td", { key: k }, render(c.tokens, depth + 1))))))));
|
|
2444
|
+
default:
|
|
2445
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, { key: i }, t.type === "html" ? t.raw : inner() ?? t.raw);
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
try {
|
|
2449
|
+
return render(x.lexer(text, { gfm: true }));
|
|
2450
|
+
} catch {
|
|
2451
|
+
return /* @__PURE__ */ import_react13.default.createElement("pre", null, text);
|
|
2452
|
+
}
|
|
2453
|
+
}, [text]);
|
|
2454
|
+
return /* @__PURE__ */ import_react13.default.createElement("article", { className: "tf-markdown-preview", "aria-label": label }, nodes);
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
// taskflow-source:src/client/components/execution-record.jsx
|
|
2458
|
+
var labels = { requirements: "任务要求", status: "执行状态", progress: "阶段进展", "model-call": "模型调用", "model-output": "模型输出", "tool-call": "工具调用", "tool-result": "工具结果", result: "最终结果", process: "执行记录" };
|
|
2459
|
+
function executionRecord(data) {
|
|
2460
|
+
const source = data?.source, summary = source?.summary;
|
|
2461
|
+
if (source?.kind !== "taskflow" || typeof summary !== "string" || !/^T-\d+\s/.test(summary)) return null;
|
|
2462
|
+
const text = (data.content ?? []).filter((block) => block.type === "text").map((block) => block.text).join("\n");
|
|
2463
|
+
if (!text.trim()) return null;
|
|
2464
|
+
const detail = source.record ?? {};
|
|
2465
|
+
const category = detail.category in labels ? detail.category : /任务要求$/.test(summary) ? "requirements" : /最终结果|已完成$/.test(summary) ? "result" : /^执行工具:/.test(text) ? "tool-call" : /执行状态$/.test(summary) ? "status" : /执行进展$/.test(summary) ? "progress" : "process";
|
|
2466
|
+
return { ...detail, taskId: summary.match(/^T-\d+/)[0], category, text, categoryLabel: labels[category] };
|
|
2467
|
+
}
|
|
2468
|
+
function formattedJson(text) {
|
|
2469
|
+
try {
|
|
2470
|
+
return JSON.stringify(JSON.parse(text), null, 2);
|
|
2471
|
+
} catch {
|
|
2472
|
+
return null;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
function ExecutionRecord({ data }) {
|
|
2476
|
+
const record = executionRecord(data), [expanded, setExpanded] = (0, import_react14.useState)(true);
|
|
2477
|
+
if (!record) return null;
|
|
2478
|
+
const { text, category, categoryLabel, taskId } = record;
|
|
2479
|
+
const tool = record.tool || text.match(/^执行工具:([^\n]+)/)?.[1];
|
|
2480
|
+
const input = category === "tool-call" ? text.replace(/^执行工具:[^\n]*\n?/, "") : null;
|
|
2481
|
+
const json = input === null && category === "tool-result" ? formattedJson(text) : null;
|
|
2482
|
+
return /* @__PURE__ */ import_react14.default.createElement("section", { className: "tf-execution-record", "data-taskflow-record": category }, /* @__PURE__ */ import_react14.default.createElement("button", { type: "button", className: "tf-record-heading", "aria-expanded": expanded, onClick: () => setExpanded((value) => !value) }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "tf-record-marker", "aria-hidden": "true" }, category === "tool-call" ? "↗" : category === "tool-result" ? "↙" : "•"), /* @__PURE__ */ import_react14.default.createElement("strong", null, categoryLabel), /* @__PURE__ */ import_react14.default.createElement("span", { className: "tf-record-task" }, taskId), tool && /* @__PURE__ */ import_react14.default.createElement("code", null, tool), record.status === "failed" && /* @__PURE__ */ import_react14.default.createElement("span", { className: "tf-error" }, "失败"), Number.isFinite(record.durationMs) && /* @__PURE__ */ import_react14.default.createElement("span", { className: "tf-record-duration" }, (record.durationMs / 1e3).toFixed(1), "s"), /* @__PURE__ */ import_react14.default.createElement("span", { className: "tf-record-chevron", "aria-hidden": "true" }, expanded ? "⌃" : "⌄")), expanded && /* @__PURE__ */ import_react14.default.createElement("div", { className: "tf-record-body" }, record.model?.provider && record.model?.model && /* @__PURE__ */ import_react14.default.createElement("p", { className: "tf-record-model" }, record.model.provider, " / ", record.model.model), input !== null ? /* @__PURE__ */ import_react14.default.createElement("pre", { "aria-label": "工具调用参数" }, /* @__PURE__ */ import_react14.default.createElement("code", null, formattedJson(input) ?? input)) : json !== null ? /* @__PURE__ */ import_react14.default.createElement("pre", { "aria-label": "工具返回结果" }, /* @__PURE__ */ import_react14.default.createElement("code", null, json)) : /* @__PURE__ */ import_react14.default.createElement(MarkdownPreview, { text, label: "执行内容" })));
|
|
2483
|
+
}
|
|
2484
|
+
function registerExecutionRecords(ctx) {
|
|
2485
|
+
const slots = ctx.slots, seat = "conversation.chat.node";
|
|
2486
|
+
if (typeof slots.entries !== "function" || typeof slots.subscribe !== "function") return;
|
|
2487
|
+
ctx.effect(() => slots.inject(seat, () => {
|
|
2488
|
+
const ours = /* @__PURE__ */ new Set();
|
|
2489
|
+
let original, remove, disposed = false;
|
|
2490
|
+
const refresh = () => {
|
|
2491
|
+
if (disposed) return;
|
|
2492
|
+
const entry = slots.entries(seat).find((candidate) => candidate.options.key === "context" && !ours.has(candidate.component));
|
|
2493
|
+
if (entry === original) return;
|
|
2494
|
+
original = entry;
|
|
2495
|
+
remove?.();
|
|
2496
|
+
remove = void 0;
|
|
2497
|
+
if (!entry) return;
|
|
2498
|
+
const Original = entry.component;
|
|
2499
|
+
function RecordOrContext(props) {
|
|
2500
|
+
return executionRecord(props.node?.data) ? /* @__PURE__ */ import_react14.default.createElement(ExecutionRecord, { data: props.node.data }) : /* @__PURE__ */ import_react14.default.createElement(Original, { ...props });
|
|
2501
|
+
}
|
|
2502
|
+
ours.add(RecordOrContext);
|
|
2503
|
+
remove = slots.register({ name: seat, key: "context", priority: (entry.options.priority ?? 0) - 1, locale: entry.locale, inject: entry.inject }, RecordOrContext);
|
|
2504
|
+
};
|
|
2505
|
+
const unsubscribe = slots.subscribe(seat, refresh);
|
|
2506
|
+
refresh();
|
|
2507
|
+
return () => {
|
|
2508
|
+
disposed = true;
|
|
2509
|
+
unsubscribe();
|
|
2510
|
+
remove?.();
|
|
2511
|
+
};
|
|
2512
|
+
}));
|
|
2513
|
+
}
|
|
207
2514
|
|
|
208
2515
|
// taskflow-source:src/client/index.jsx
|
|
209
2516
|
var inject = ["slots", "sessions", "connection"];
|
|
210
2517
|
function createApi(connection) {
|
|
211
2518
|
const call = async (method, data) => {
|
|
212
|
-
const result = await connection.rpc.call("/
|
|
2519
|
+
const result = await connection.rpc.call("/api", method, data);
|
|
213
2520
|
if (!result.ok) throw new Error(result.error.message);
|
|
214
2521
|
return result.value;
|
|
215
2522
|
};
|
|
216
|
-
return { view: (sessionId) => call("view", { sessionId }), action: (sessionId, action, data) => call("action", { sessionId, action, ...data }) };
|
|
2523
|
+
return { view: (sessionId) => call("taskflow/view", { sessionId }), action: (sessionId, action, data) => call("taskflow/action", { sessionId, action, ...data }) };
|
|
217
2524
|
}
|
|
218
2525
|
function apply(ctx) {
|
|
2526
|
+
registerExecutionRecords(ctx);
|
|
219
2527
|
const api = createApi(ctx.connection), renderers = /* @__PURE__ */ new Map();
|
|
2528
|
+
const panels = /* @__PURE__ */ new Map(), panelListeners = /* @__PURE__ */ new Set();
|
|
2529
|
+
const updatePanel = (key, value) => {
|
|
2530
|
+
value ? panels.set(key, value) : panels.delete(key);
|
|
2531
|
+
panelListeners.forEach((fn) => fn());
|
|
2532
|
+
};
|
|
220
2533
|
ctx.provide("taskflowViews", { register(kind, component) {
|
|
221
2534
|
renderers.set(kind, component);
|
|
222
2535
|
return () => {
|
|
@@ -226,35 +2539,79 @@ function apply(ctx) {
|
|
|
226
2539
|
ctx.effect(() => {
|
|
227
2540
|
const style = document.createElement("style");
|
|
228
2541
|
style.dataset.dshTaskflow = "";
|
|
229
|
-
style.textContent =
|
|
2542
|
+
style.textContent = prototype_default + "\n" + styles_default;
|
|
230
2543
|
document.head.append(style);
|
|
231
2544
|
return () => style.remove();
|
|
232
2545
|
});
|
|
233
2546
|
ctx.inject(["sidebarRightTabs", "sidebarRight", "uiWorkspace"], (scope) => {
|
|
234
|
-
|
|
2547
|
+
const openers = createToolOpeners(scope);
|
|
2548
|
+
scope.effect(() => scope.sidebarRightTabs.register({ id: "dsh-taskflow", kind: "taskflow", priority: "extension", keepMounted: true, title: () => "待办任务清单", guide: [{ id: "taskflow", order: 0, title: () => "待办任务清单", icon: TaskIcon, description: () => "持久层级待办" }] }));
|
|
235
2549
|
const register = (slot, options, Component) => scope.effect(() => scope.slots.inject(slot, () => scope.slots.register({ name: slot, ...options }, Component)));
|
|
236
|
-
const augment = (props, value) => {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
input.
|
|
242
|
-
|
|
2550
|
+
const augment = async (props, value, target) => {
|
|
2551
|
+
const sid = typeof target === "string" ? target : target?.childSessionId || props.sessionId;
|
|
2552
|
+
if (target) scope.uiWorkspace.openSession(target);
|
|
2553
|
+
const deadline = Date.now() + 2500;
|
|
2554
|
+
do {
|
|
2555
|
+
const binding = ctx.sessions.binding(sid), input = binding && ctx.conversation?.input?.for(binding.ctx);
|
|
2556
|
+
if (input) {
|
|
2557
|
+
input.setDraft(value);
|
|
2558
|
+
input.focus();
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
if (sid === props.sessionId && props.inputActions) {
|
|
2562
|
+
props.inputActions.setDraft(value);
|
|
2563
|
+
return;
|
|
2564
|
+
}
|
|
2565
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
2566
|
+
} while (Date.now() < deadline);
|
|
2567
|
+
throw new Error("负责会话尚未就绪,请返回父会话后增补事项");
|
|
243
2568
|
};
|
|
244
2569
|
function Panel(props) {
|
|
245
|
-
const view = useTaskflow(api, props.sessionId);
|
|
246
|
-
|
|
2570
|
+
const view = useTaskflow(api, props.sessionId), tabInfo = props.useTabInfo?.(), key = (0, import_react15.useRef)(Symbol());
|
|
2571
|
+
const visible = tabInfo?.tab.visible;
|
|
2572
|
+
const compact = useCompactChecklist(visible === true && !tabInfo?.sidebar?.fullscreen && !tabInfo?.panel?.isFloating);
|
|
2573
|
+
(0, import_react15.useEffect)(() => {
|
|
2574
|
+
if (tabInfo) updatePanel(key.current, { sid: props.sessionId, visible });
|
|
2575
|
+
return () => updatePanel(key.current);
|
|
2576
|
+
}, [props.sessionId, visible]);
|
|
2577
|
+
const recordTask = Object.values(view.plan?.tasks ?? {}).find((t) => t.recordSession?.id === props.sessionId || t.recordHistory?.some((r) => r.id === props.sessionId));
|
|
2578
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", { ref: compact.anchor, className: "tf-checklist-root" }, /* @__PURE__ */ import_react15.default.createElement(TaskPanel, { view, sessionId: props.sessionId, action: (type, data) => api.action(props.sessionId, type, data), navigate: (id) => scope.uiWorkspace.openSession(id), augment: (value) => augment(props, value, recordTask && executionTarget(view.plan, recordTask)) }), compact.panel && (0, import_react_dom4.createPortal)(/* @__PURE__ */ import_react15.default.createElement("div", { className: "tf-checklist-resizer", ...compact.separator }), compact.panel), compact.dragging && (0, import_react_dom4.createPortal)(/* @__PURE__ */ import_react15.default.createElement("div", { className: "tf-checklist-resize-shield" }), document.body));
|
|
247
2579
|
}
|
|
248
2580
|
register("sidebar.right.pane.tab", { key: "dsh-taskflow" }, Panel);
|
|
2581
|
+
function Tree(props) {
|
|
2582
|
+
const current = scope.sidebarRight.mounted;
|
|
2583
|
+
const sid = (0, import_react15.useSyncExternalStore)(current ? (listener) => current.subscribe(listener) : () => () => {
|
|
2584
|
+
}, current ? () => current.getSnapshot() : () => null);
|
|
2585
|
+
return /* @__PURE__ */ import_react15.default.createElement(SessionTree, { api, sessionId: props.sessionId, currentSessionId: sid, navigate: (target) => scope.uiWorkspace.openSession(target) });
|
|
2586
|
+
}
|
|
2587
|
+
register("sidebar.session.row.trailing", { id: "taskflow-children", order: 10 }, Tree);
|
|
2588
|
+
function Replies(props) {
|
|
2589
|
+
const current = scope.sidebarRight.mounted;
|
|
2590
|
+
const foreground = (0, import_react15.useSyncExternalStore)(current ? (listener) => current.subscribe(listener) : () => () => {
|
|
2591
|
+
}, current ? () => current.getSnapshot() === props.sessionId : () => true);
|
|
2592
|
+
return /* @__PURE__ */ import_react15.default.createElement(QuickReplies, { key: props.sessionId, api, ...props, foreground, focus: () => {
|
|
2593
|
+
const binding = ctx.sessions.binding(props.sessionId);
|
|
2594
|
+
if (binding) ctx.conversation?.input?.for(binding.ctx)?.focus();
|
|
2595
|
+
} });
|
|
2596
|
+
}
|
|
2597
|
+
register("conversation.input.dock", { id: "taskflow-quick-replies", order: -10 }, Replies);
|
|
249
2598
|
function SessionEntry(props) {
|
|
250
|
-
const
|
|
251
|
-
(0,
|
|
2599
|
+
const entryAnchor = (0, import_react15.useRef)(null), entryTarget = useHeaderEntryTarget(entryAnchor);
|
|
2600
|
+
const panelVisible = (0, import_react15.useSyncExternalStore)((fn) => {
|
|
2601
|
+
panelListeners.add(fn);
|
|
2602
|
+
return () => panelListeners.delete(fn);
|
|
2603
|
+
}, () => [...panels.values()].some((p) => p.sid === props.sessionId && p.visible));
|
|
2604
|
+
const current = scope.sidebarRight.mounted;
|
|
2605
|
+
const foreground = (0, import_react15.useSyncExternalStore)(current ? (listener) => current.subscribe(listener) : () => () => {
|
|
2606
|
+
}, current ? () => current.getSnapshot() === props.sessionId : () => true);
|
|
2607
|
+
const view = useTaskflow(api, props.sessionId), [mount, setMount] = (0, import_react15.useState)(null), [showTool, setShowTool] = (0, import_react15.useState)(true), [, refreshEntry] = (0, import_react15.useState)(0), autoOpened = (0, import_react15.useRef)(false);
|
|
2608
|
+
(0, import_react15.useEffect)(() => {
|
|
252
2609
|
if (mount) mount.parentElement?.classList.toggle("tf-tool-show-tool", showTool);
|
|
253
2610
|
}, [mount, showTool]);
|
|
254
|
-
(0,
|
|
2611
|
+
(0, import_react15.useEffect)(() => {
|
|
255
2612
|
if (view.tool?.open) setShowTool(true);
|
|
256
2613
|
}, [view.tool?.open, props.sessionId]);
|
|
257
|
-
(0,
|
|
2614
|
+
(0, import_react15.useEffect)(() => {
|
|
258
2615
|
if (view.plan && !autoOpened.current) {
|
|
259
2616
|
try {
|
|
260
2617
|
scope.sidebarRight.openTab("taskflow");
|
|
@@ -263,10 +2620,10 @@ function apply(ctx) {
|
|
|
263
2620
|
}
|
|
264
2621
|
}
|
|
265
2622
|
}, [view.plan?.id, props.sessionId]);
|
|
266
|
-
(0,
|
|
2623
|
+
(0, import_react15.useEffect)(() => {
|
|
267
2624
|
autoOpened.current = false;
|
|
268
2625
|
}, [props.sessionId]);
|
|
269
|
-
(0,
|
|
2626
|
+
(0, import_react15.useEffect)(() => {
|
|
270
2627
|
if (!view.tool?.open) {
|
|
271
2628
|
setMount(null);
|
|
272
2629
|
return;
|
|
@@ -303,8 +2660,17 @@ function apply(ctx) {
|
|
|
303
2660
|
setMount(null);
|
|
304
2661
|
};
|
|
305
2662
|
}, [view.tool?.open, props.sessionId]);
|
|
306
|
-
const
|
|
307
|
-
|
|
2663
|
+
const renderer = (tool, file) => {
|
|
2664
|
+
const Renderer = renderers.get(file?.format) || renderers.get(tool.kind);
|
|
2665
|
+
return Renderer ? /* @__PURE__ */ import_react15.default.createElement(Renderer, { tool, file, sessionId: props.sessionId }) : null;
|
|
2666
|
+
};
|
|
2667
|
+
const expanded = scope.sidebarRight.isExpanded() && (panelVisible || scope.sidebarRight.active()?.kind === "taskflow");
|
|
2668
|
+
const entry = /* @__PURE__ */ import_react15.default.createElement("button", { type: "button", className: "tf-entry", title: expanded ? "收起待办任务清单" : "展开待办任务清单", "aria-label": "待办任务清单", "aria-expanded": expanded, onClick: () => {
|
|
2669
|
+
if (scope.sidebarRight.isExpanded() && (panelVisible || scope.sidebarRight.active()?.kind === "taskflow")) scope.sidebarRight.toggleExpanded();
|
|
2670
|
+
else scope.sidebarRight.openTab("taskflow");
|
|
2671
|
+
refreshEntry((n) => n + 1);
|
|
2672
|
+
} }, /* @__PURE__ */ import_react15.default.createElement(TaskIcon, null), /* @__PURE__ */ import_react15.default.createElement("span", null, "任务"));
|
|
2673
|
+
return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, /* @__PURE__ */ import_react15.default.createElement("span", { ref: entryAnchor, className: "tf-entry-anchor" }, entryTarget ? (0, import_react_dom4.createPortal)(entry, entryTarget) : entry), view.tool?.open && /* @__PURE__ */ import_react15.default.createElement("span", { className: "tf-mobile-view" }, /* @__PURE__ */ import_react15.default.createElement("button", { "aria-pressed": !showTool, onClick: () => setShowTool(false) }, "看对话"), /* @__PURE__ */ import_react15.default.createElement("button", { "aria-pressed": showTool, onClick: () => setShowTool(true) }, "看工具")), mount && (0, import_react_dom4.createPortal)(/* @__PURE__ */ import_react15.default.createElement(ToolPanel, { key: props.sessionId, sessionId: props.sessionId, mount, tool: view.tool, onClose: () => void api.action(props.sessionId, "close-view", {}), renderer, openers, foreground }), mount));
|
|
308
2674
|
}
|
|
309
2675
|
register("conversation.session.header.utilities", { id: "taskflow", order: -5 }, SessionEntry);
|
|
310
2676
|
});
|