@fgbg/mdocs 0.8.22 → 0.8.23
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/README.md +1 -1
- package/agent-skills/changelog/SKILL.md +9 -1
- package/agent-skills/index.json +1 -1
- package/dist/server/cli/self-update.js +4 -0
- package/dist/server/cli/self-update.js.map +1 -1
- package/dist/web/assets/{AgentChatPanel-IrNTGpzN.js → AgentChatPanel-CtdLYtSw.js} +1 -1
- package/dist/web/assets/{AgentSkillFormCard-goRzD94F.js → AgentSkillFormCard-DeZnOTQg.js} +2 -2
- package/dist/web/assets/{AiWriteWorkbench-CMe6iuR8.js → AiWriteWorkbench-hUYjin2m.js} +1 -1
- package/dist/web/assets/DiagramEditor-NtNY3sZL-C9hL71kf.js +2 -0
- package/dist/web/assets/DocumentEditor-BmmnuieO.js +21 -0
- package/dist/web/assets/{MergeView-CMQVyBUA.js → MergeView-CjhCBNPa.js} +1 -1
- package/dist/web/assets/{PlaygroundPage-w1D9fzsK.js → PlaygroundPage-CgaNgQEp.js} +1 -1
- package/dist/web/assets/SettingsPage-Fl5Tu7u3.js +1 -0
- package/dist/web/assets/{Toolbar-DylP9gFR.js → Toolbar-BaKuyXey.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-D0i7oxrW.js → VisitorPickerModal-DPyg6mIt.js} +1 -1
- package/dist/web/assets/{copy-Ba87S6Rg.js → copy-UkvgEfIg.js} +1 -1
- package/dist/web/assets/diagram-BLCqfrbF.js +6257 -0
- package/dist/web/assets/index-Ct5Vt4tz.js +185 -0
- package/dist/web/assets/{index-7HUca950.css → index-Dt_PAYaR.css} +1 -1
- package/dist/web/assets/meta2d-D3b5RRN8.js +110 -0
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-BFAQue19.js → meta2dEngine-BD2XbzaV-2ovN6JHu.js} +1 -1
- package/dist/web/assets/{motion-C4pN8CfU.js → motion-Bz_inm1R.js} +1 -1
- package/dist/web/assets/{plus-BlTVBbk-.js → plus-B-uEAM2g.js} +1 -1
- package/dist/web/assets/react-6CQL39Gs.js +2382 -0
- package/dist/web/assets/react-vendor-BJFXgntS.js +242 -0
- package/dist/web/assets/{ui-DxdLi_28.js → ui-TwLH91RV.js} +133 -133
- package/dist/web/index.html +5 -5
- package/package.json +2 -2
- package/dist/web/assets/DiagramEditor-BTRe45TX-D1vc5s9F.js +0 -2
- package/dist/web/assets/DocumentEditor-CbksWmYP.js +0 -21
- package/dist/web/assets/SettingsPage-DzTINzaB.js +0 -1
- package/dist/web/assets/diagram-gfUK8OHx.js +0 -3016
- package/dist/web/assets/index-DOrcbEeP.js +0 -185
- package/dist/web/assets/meta2d-C8Z4cn-d.js +0 -110
- package/dist/web/assets/react-DedaIFYc.js +0 -2126
- package/dist/web/assets/react-vendor-BNpqFP9B.js +0 -242
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
面向个人开发者与小团队:产品内 **智能助手 + 帮写**,外部 **CLI / Skills** 接入 Cursor / Claude;SQLite + 本地文件,**无账户**即可协作。
|
|
6
6
|
|
|
7
|
-
[文档站点](https://xuhuafeifei.github.io/mdocs-site/) · [GitHub](https://github.com/xuhuafeifei/mdocs) · [npm `@fgbg/mdocs`](https://www.npmjs.com/package/@fgbg/mdocs) · 当前版本 **0.8.
|
|
7
|
+
[文档站点](https://xuhuafeifei.github.io/mdocs-site/) · [GitHub](https://github.com/xuhuafeifei/mdocs) · [npm `@fgbg/mdocs`](https://www.npmjs.com/package/@fgbg/mdocs) · 当前版本 **0.8.23**
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img src="image/site主页.png" alt="mdocs 文档站点首页" width="860" />
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: changelog
|
|
3
3
|
name: "更新日志"
|
|
4
|
-
description: "-
|
|
4
|
+
description: "- **手机阅读壳**:窄屏侧栏改为抽屉(默认不占宽);文档顶栏浮条/可吸附,隐藏域选择与帮写;设置页同样可收起左侧 Tab - **窄屏发布/删除**:浮条上提供紧凑发布、删除入口 - **`mdocs update`**:查最新版本时加 `--prefer-online`,避免本机 npm 缓存把 latest 钉在旧版 - **Markdown 文字颜色往返**:编辑器内设置的文字色 / 背"
|
|
5
5
|
keywords: []
|
|
6
6
|
source: changelog.md
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# 更新日志
|
|
10
10
|
|
|
11
|
+
## v0.8.23
|
|
12
|
+
|
|
13
|
+
- **手机阅读壳**:窄屏侧栏改为抽屉(默认不占宽);文档顶栏浮条/可吸附,隐藏域选择与帮写;设置页同样可收起左侧 Tab
|
|
14
|
+
- **窄屏发布/删除**:浮条上提供紧凑发布、删除入口
|
|
15
|
+
- **`mdocs update`**:查最新版本时加 `--prefer-online`,避免本机 npm 缓存把 latest 钉在旧版
|
|
16
|
+
- **Markdown 文字颜色往返**:编辑器内设置的文字色 / 背景色可写入 Markdown(`<span style="color: …">` / `background-color`),再导入时还原;段落与表格单元格均支持,代码块内忽略(依赖 `@fgbg/lobe-editor@1.0.0-fork.20`)
|
|
17
|
+
- **编辑器依赖**:升级 `@fgbg/lobe-editor@1.0.0-fork.20`
|
|
18
|
+
|
|
11
19
|
## v0.8.22
|
|
12
20
|
|
|
13
21
|
- **帮写 inline diff**:有未接受提案时强制进入 inline diff(不可切回源码);相同行 / 绿增可改提案,红删只读;写回仍以已接受的 `currentMd` 为准
|
package/agent-skills/index.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{
|
|
3
3
|
"id": "changelog",
|
|
4
4
|
"name": "更新日志",
|
|
5
|
-
"description": "-
|
|
5
|
+
"description": "- **手机阅读壳**:窄屏侧栏改为抽屉(默认不占宽);文档顶栏浮条/可吸附,隐藏域选择与帮写;设置页同样可收起左侧 Tab - **窄屏发布/删除**:浮条上提供紧凑发布、删除入口 - **`mdocs update`**:查最新版本时加 `--prefer-online`,避免本机 npm 缓存把 latest 钉在旧版 - **Markdown 文字颜色往返**:编辑器内设置的文字色 / 背",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"source": "changelog.md"
|
|
8
8
|
},
|
|
@@ -57,6 +57,9 @@ function fetchLatestVersion() {
|
|
|
57
57
|
MDOCS_UPDATE_PACKAGE,
|
|
58
58
|
"version",
|
|
59
59
|
`--registry=${MDOCS_UPDATE_REGISTRY}`,
|
|
60
|
+
// 避免本机 npm cache 把 latest 钉在旧版(镜像已同步仍报「已是最新」)
|
|
61
|
+
"--prefer-online",
|
|
62
|
+
"--fetch-retries=2",
|
|
60
63
|
]);
|
|
61
64
|
if (r.status !== 0 || !r.stdout) {
|
|
62
65
|
fail(`无法从 ${MDOCS_UPDATE_REGISTRY} 查询版本:${r.stderr || r.stdout || "empty"}`);
|
|
@@ -70,6 +73,7 @@ function packTo(destDir, version) {
|
|
|
70
73
|
`${MDOCS_UPDATE_PACKAGE}@${version}`,
|
|
71
74
|
`--registry=${MDOCS_UPDATE_REGISTRY}`,
|
|
72
75
|
`--pack-destination=${destDir}`,
|
|
76
|
+
"--prefer-online",
|
|
73
77
|
], destDir);
|
|
74
78
|
if (r.status !== 0) {
|
|
75
79
|
fail(`npm pack 失败:${r.stderr || r.stdout}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"self-update.js","sourceRoot":"","sources":["../../../src/server/cli/self-update.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,mBAAmB;AACnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AACtE,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAOlD,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,IAAI,CAAC,GAAW,EAAE,IAAI,GAAG,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,2BAA2B,CACzC,UAAkB,MAAM,CAAC,IAAI,CAAC,GAAG;IAEjC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,2CAA2C;IAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,IAAI,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAgB,CAAC;AAC/D,CAAC;AAED,wBAAwB;AACxB,SAAS,qBAAqB,CAAC,OAAe;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;QACvD,IAAI,CACF,gGAAgG,EAChG,CAAC,CACF,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACtC,IAAI,CACF,QAAQ,oBAAoB,QAAQ,GAAG,CAAC,IAAI,IAAI,GAAG,QAAQ,EAC3D,CAAC,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,GAAG,CAAC,IAAc,EAAE,GAAY;IACvC,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,GAAG;QACH,QAAQ,EAAE,MAAM;QAChB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;KACxB,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC;QACrB,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAC/B,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB;IACzB,MAAM,CAAC,GAAG,GAAG,CAAC;QACZ,MAAM;QACN,oBAAoB;QACpB,SAAS;QACT,cAAc,qBAAqB,EAAE;
|
|
1
|
+
{"version":3,"file":"self-update.js","sourceRoot":"","sources":["../../../src/server/cli/self-update.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,mBAAmB;AACnB,MAAM,CAAC,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AACtE,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAOlD,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,IAAI,CAAC,GAAW,EAAE,IAAI,GAAG,CAAC;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,2BAA2B,CACzC,UAAkB,MAAM,CAAC,IAAI,CAAC,GAAG;IAEjC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,2CAA2C;IAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,IAAI,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAgB,CAAC;AAC/D,CAAC;AAED,wBAAwB;AACxB,SAAS,qBAAqB,CAAC,OAAe;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;QACvD,IAAI,CACF,gGAAgG,EAChG,CAAC,CACF,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACtC,IAAI,CACF,QAAQ,oBAAoB,QAAQ,GAAG,CAAC,IAAI,IAAI,GAAG,QAAQ,EAC3D,CAAC,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,GAAG,CAAC,IAAc,EAAE,GAAY;IACvC,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,GAAG;QACH,QAAQ,EAAE,MAAM;QAChB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;KACxB,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC;QACrB,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAC/B,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB;IACzB,MAAM,CAAC,GAAG,GAAG,CAAC;QACZ,MAAM;QACN,oBAAoB;QACpB,SAAS;QACT,cAAc,qBAAqB,EAAE;QACrC,8CAA8C;QAC9C,iBAAiB;QACjB,mBAAmB;KACpB,CAAC,CAAC;IACH,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,qBAAqB,SAAS,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAG,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,OAAe,EAAE,OAAe;IAC9C,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,GAAG,GAAG,CACX;QACE,MAAM;QACN,GAAG,oBAAoB,IAAI,OAAO,EAAE;QACpC,cAAc,qBAAqB,EAAE;QACrC,sBAAsB,OAAO,EAAE;QAC/B,iBAAiB;KAClB,EACD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,IAAI,CAAC,eAAe,OAAO,EAAE,CAAC,CAAC;IAC5D,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,8BAA8B;AAC9B,SAAS,cAAc,CAAC,OAAe,EAAE,mBAA2B;IAClE,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,IAAI,IAAI,KAAK,cAAc;YAAE,SAAS;QACtC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;QAClD,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,SAAS,wBAAwB,CAAC,OAAe;IAC/C,GAAG,CAAC,8CAA8C,CAAC,CAAC;IACpD,MAAM,CAAC,GAAG,GAAG,CACX;QACE,SAAS;QACT,YAAY;QACZ,kBAAkB;QAClB,YAAY;QACZ,WAAW;QACX,oBAAoB;QACpB,cAAc,qBAAqB,EAAE;KACtC,EACD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC,CAAC,MAAM;QAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,2BAA2B,EAAE,CAAC;IAC9C,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE/B,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC;IAC9C,GAAG,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACxB,GAAG,CAAC,SAAS,cAAc,EAAE,CAAC,CAAC;IAC/B,GAAG,CAAC,WAAW,qBAAqB,EAAE,CAAC,CAAC;IAExC,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IAEvB,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;QAC9B,GAAG,CAAC,YAAY,CAAC,CAAC;QAClB,OAAO;IACT,CAAC;IAED,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACrE,IAAI,CAAC;QACH,GAAG,CAAC,MAAM,oBAAoB,IAAI,MAAM,IAAI,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC9C,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACzB,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACpF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAEtD,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACjC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC/B,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAElC,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACvC,GAAG,CAAC,SAAS,cAAc,MAAM,KAAK,CAAC,OAAO,IAAI,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e}from"./react-vendor-BNpqFP9B.js";import{aa as Ae,ab as Ce,i as me,ac as _e,ad as qe,ae as Re,af as $e,ag as Ee,ah as De,ai as xe,aj as Me,ak as Fe,al as Te}from"./index-DOrcbEeP.js";import{H as ze,S as Pe,A as Be}from"./AgentSkillFormCard-goRzD94F.js";import{P as Le}from"./plus-BlTVBbk-.js";import{M as He,r as Ke}from"./ui-DxdLi_28.js";import{C as Oe,a as Ue}from"./copy-Ba87S6Rg.js";import"./motion-C4pN8CfU.js";function te(r){var n;return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(te).join(""):typeof r=="object"&&"props"in r?te((n=r.props)==null?void 0:n.children):""}function We(r){const[n,c]=d.useState(!1),o=d.useRef(null),b=te(r.children).replace(/\n$/,"");d.useEffect(()=>()=>{o.current!=null&&window.clearTimeout(o.current)},[]);async function x(){if(b)try{await navigator.clipboard.writeText(b),c(!0),o.current!=null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>c(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void x(),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Oe,{size:14,"aria-hidden":!0}):e.jsx(Ue,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:r.children})]})}function pe(r){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(He,{remarkPlugins:[Ke],components:{pre:({children:n})=>e.jsx(We,{children:n})},children:r.children})})}const Ge=["如何发布文档?","草稿是什么?","如何创建域?"];function he(r,n){return n.map((c,o)=>{const b=c.skillNames&&c.skillNames.length>0?c.skillNames:c.skillIds&&c.skillIds.length>0?c.skillIds:void 0;return{id:`h-${r}-${o}-${c.role}`,role:c.role,content:c.content,skillNames:b}})}function Xe(r,n){const c=r.slice(),o=c[c.length-1];return(o==null?void 0:o.type)==="text"?c[c.length-1]={type:"text",text:o.text+n}:c.push({type:"text",text:n}),c}function Ye(r,n){const c=r.slice(),o=c[c.length-1];return(o==null?void 0:o.type)==="thinking"?c[c.length-1]={type:"thinking",text:o.text+n}:c.push({type:"thinking",text:n}),c}function fe(r){return r!=null&&r.length?r.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Je(r){return!!(r!=null&&r.some(n=>n.type==="thinking"&&n.text.length>0))}function Qe(r){const n=new Date(r);if(Number.isNaN(n.getTime()))return"";const c=new Date;return n.getFullYear()===c.getFullYear()&&n.getMonth()===c.getMonth()&&n.getDate()===c.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function ge(r){if(r>=1e3){const n=r/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(r)}function Ve(r){const{block:n,onResolved:c}=r,[o,b]=d.useState(""),[x,R]=d.useState(!1),[$,C]=d.useState(1),E=d.useRef(!1),z=d.useRef(c);z.current=c;const I=n.status==="open",_=d.useRef(0);d.useEffect(()=>{if(!I)return;E.current=!1;const k=new Date(n.expiresAt).getTime(),q=Date.now(),w=Math.max(k-q,1);_.current=w,C(1);const g=()=>{const F=k-Date.now(),K=Math.max(0,Math.min(1,F/w));C(K),F<=0&&!E.current&&(E.current=!0,Fe(n.requestId).catch(()=>{}).finally(()=>{z.current(n.requestId,"","expired")}))};g();const P=window.setInterval(g,100);return()=>window.clearInterval(P)},[I,n.expiresAt,n.requestId]);async function S(k){const q=k.trim();if(!(!q||x||!I)){R(!0);try{await Te(n.requestId,q),c(n.requestId,q,"selected")}catch{c(n.requestId,q,"failed")}finally{R(!1)}}}async function u(){if(!(x||!I)){R(!0),E.current=!0;try{await xe(n.requestId),c(n.requestId,"","cancelled")}catch{c(n.requestId,"","failed")}finally{R(!1)}}}const H=Math.max(0,Math.ceil($*_.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(I?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),I?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),I?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round($*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${$})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(k=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:x,onClick:()=>void S(k),children:k},k))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:o,disabled:x,placeholder:"或输入自己的内容…",onChange:k=>b(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),S(o))}}),e.jsx("button",{type:"button",disabled:x||!o.trim(),onClick:()=>void S(o),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:x,onClick:()=>void u(),children:"取消"})})]}):null]})}function Ze(r){const b=2*Math.PI*8.75,x=Math.min(100,Math.max(0,r.percent)),R=b*(1-x/100),$=x>=90?"danger":x>=70?"warn":"ok",C=`上下文 ${x}% · 已用 ${ge(r.used)} / ${ge(r.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+$,"data-tooltip":C,"aria-label":C,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:R,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function es(r){var n;for(const c of r)if(!(c.role!=="assistant"||!((n=c.blocks)!=null&&n.length))){for(const o of c.blocks)if((o.type==="choice_card"||o.type==="skill_form_card")&&o.status==="open")return!0}return!1}const cs=d.forwardRef(function(n,c){const{open:o,onClose:b,visitorName:x,anchorStyle:R,onOpenDocument:$,onTreeChanged:C,onDocumentOverwritten:E,onOpenCoding:z}=n,I=((x==null?void 0:x.trim().charAt(0))||"我").toUpperCase(),[_,S]=d.useState(!1),[u,H]=d.useState(null),[k,q]=d.useState(null),[w,g]=d.useState([]),[P,F]=d.useState(null),[K,ye]=d.useState([]),[je,ne]=d.useState(!1),[O,U]=d.useState(""),[B,ae]=d.useState([]),[y,W]=d.useState(!1),[ie,D]=d.useState(null),[G,re]=d.useState(null),[X,T]=d.useState(!1),[M,le]=d.useState(!1),ke=d.useRef(null),Y=d.useRef(null),v=d.useRef(null),ce=d.useRef(0),L=d.useRef(!0),J=d.useRef(w);J.current=w;function oe(s){return ce.current+=1,`${s}-${ce.current}`}function Ne(s,m=48){return s.scrollHeight-s.scrollTop-s.clientHeight<=m}function A(){const s=Y.current;!s||!L.current||(s.scrollTop=s.scrollHeight)}function be(){const s=Y.current;s&&(L.current=Ne(s))}async function Se(){ne(!0);try{const s=await Re();ye(s.sessions),P||F(s.lastOpenedSessionId)}catch{}finally{ne(!1)}}async function Q(){try{const s=await qe();re(s)}catch{}}d.useEffect(()=>{var m;if(!o){S(!1),(m=v.current)==null||m.abort(),v.current=null,W(!1);return}let s=!1;return(async()=>{try{const a=await Ae();s||(H(a),q(null))}catch(a){s||(H(null),q(a instanceof Error?a.message:String(a)))}})(),Q(),()=>{s=!0}},[o]),d.useEffect(()=>{if(!o)return;let s=!1;return(async()=>{try{const m=await Ce();if(s)return;F(m.sessionId),g(a=>a.length>0?a:he(m.sessionId,m.messages))}catch{}})(),()=>{s=!0}},[o]),d.useEffect(()=>{!o||!_||Se()},[o,_]);function V(){if(!M){if(es(J.current)){T(!0);return}T(!1),b()}}async function we(){var a;if(M)return;le(!0);const s=J.current,m=[];for(const j of s)if(!(j.role!=="assistant"||!j.blocks))for(const p of j.blocks)p.type==="choice_card"&&p.status==="open"&&m.push(xe(p.requestId).catch(()=>{})),p.type==="skill_form_card"&&p.status==="open"&&m.push(Me(p.requestId).catch(()=>{}));await Promise.all(m),(a=v.current)==null||a.abort(),g(j=>j.map(p=>p.role!=="assistant"||!p.blocks?p:{...p,blocks:p.blocks.map(h=>h.type==="choice_card"&&h.status==="open"?{...h,status:"cancelled"}:h.type==="skill_form_card"&&h.status==="open"?{...h,status:"cancelled"}:h)})),T(!1),le(!1),b()}const Z=d.useRef(V);Z.current=V,d.useImperativeHandle(c,()=>({requestClose:()=>Z.current()}),[]),d.useEffect(()=>{if(!o){T(!1);return}const s=m=>{if(m.key==="Escape"){if(X){M||T(!1);return}if(_){S(!1);return}Z.current()}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[o,_,X,M]);async function ee(s){var h;const m=s.trim();if(!m||y)return;if(!(u!=null&&u.enabled)){D((u==null?void 0:u.reason)==="missing_api_key"?"请先在设置 → AI 配置 DeepSeek API Key":(u==null?void 0:u.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(h=v.current)==null||h.abort();const a=new AbortController;v.current=a;const j={id:oe("u"),role:"user",content:m,skillNames:B.length>0?[...B]:void 0},p=oe("a");L.current=!0,g(N=>[...N,j,{id:p,role:"assistant",content:""}]),U(""),W(!0),D(null),S(!1),requestAnimationFrame(()=>A());try{let N=!1;await De(m,{skillNames:B.length>0?B:void 0,signal:a.signal,onEvent:i=>{i.type==="text_delta"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=Xe(t.blocks??[],i.text);return{...t,blocks:l,content:fe(l)}})),requestAnimationFrame(()=>A())):i.type==="thinking_delta"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=Ye(t.blocks??[],i.text);return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="sources"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=(t.blocks??[]).slice(),se=l[l.length-1];return(se==null?void 0:se.type)==="sources"?l[l.length-1]={type:"sources",items:i.items}:l.push({type:"sources",items:i.items}),{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="document_table"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_table",title:i.title,rows:i.rows}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="document_card"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_card",documentId:i.documentId,title:i.title,path:i.path,preview:i.preview}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="tool_notice"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"tool_notice",toolName:i.toolName,text:i.text}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="choice_card"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"choice_card",requestId:i.requestId,title:i.title,options:i.options,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="choice_expired"?g(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="skill_form_card"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"skill_form_card",requestId:i.requestId,mode:i.mode,title:i.title,currentName:i.currentName,initialName:i.initialName,initialDescription:i.initialDescription,initialBody:i.initialBody,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="skill_form_expired"?g(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="tree_changed"?C==null||C():i.type==="document_overwritten"?E==null||E({documentId:i.documentId,headCommitId:i.headCommitId}):i.type==="open_coding"?z==null||z({documentId:i.documentId,displayName:i.displayName}):i.type==="context_usage"?re({percent:i.percent,used:i.used,limit:i.limit}):i.type==="error"&&(N=!0,D(i.message))}}),!a.signal.aborted&&!N&&ae([])}catch(N){if(a.signal.aborted)return;D(N instanceof Error?N.message:String(N))}finally{v.current===a&&(v.current=null),W(!1)}}async function Ie(){var s;if(!y){(s=v.current)==null||s.abort(),D(null),S(!1),W(!1);try{const m=await $e();F(m.sessionId),g([]),U(""),L.current=!0,Q()}catch(m){D(m instanceof Error?m.message:String(m))}}}async function ve(s){var m;if(!y){if(s===P){S(!1);return}(m=v.current)==null||m.abort(),D(null);try{const a=await Ee(s);F(a.sessionId),g(he(a.sessionId,a.messages)),U(""),S(!1),L.current=!0,requestAnimationFrame(()=>A()),Q()}catch(a){D(a instanceof Error?a.message:String(a))}}}function de(s){!s||!$||$(s)}if(!o)return null;const ue=k??(u&&!u.enabled?u.reason==="missing_api_key"?"未配置 API Key:请打开设置 → AI":u.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:ke,className:"mdocs-agent-panel",role:"dialog","aria-label":"mdocs 智能助手",style:R,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:me,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:y,onClick:()=>void Ie(),children:e.jsx(Le,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(_?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>S(s=>!s),children:e.jsx(ze,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:V,children:e.jsx(_e,{size:16,strokeWidth:1.8})})]})]}),_?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>S(!1),children:"返回对话"})]}),je?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):K.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:K.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(s.id===P?" active":""),disabled:y,onClick:()=>void ve(s.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:s.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:Qe(s.updatedAt)})]})},s.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:Y,onScroll:be,children:w.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),ue?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ue}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Ge.map(s=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void ee(s),disabled:y||!(u!=null&&u.enabled),children:s},s))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:w.map(s=>{var m;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(s.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[s.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:me,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[s.role==="user"&&s.skillNames&&s.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",s.skillNames.length]}):null,s.role==="assistant"?s.blocks&&s.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[s.blocks.map((a,j)=>{var p;return a.type==="thinking"?a.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:y&&s.id===((p=w[w.length-1])==null?void 0:p.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:a.text})]},`${s.id}-th-${j}`):null:a.type==="text"?a.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(pe,{children:a.text})},`${s.id}-t-${j}`):null:a.type==="sources"?a.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",a.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:a.items.map(h=>e.jsx("li",{children:e.jsx("a",{href:h.url,target:"_blank",rel:"noreferrer",children:h.name})},h.id))})]})},`${s.id}-s-${j}`):a.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:a.text})},`${s.id}-n-${j}`):a.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ve,{block:a,onResolved:(h,N,i)=>{g(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===h?{...l,status:i,selected:i==="selected"?N:l.selected}:l)}))}})},`${s.id}-ch-${j}`):a.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Pe,{block:a,onResolved:(h,N,i)=>{g(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===h?{...l,status:N,submittedName:N==="submitted"?i:l.submittedName}:l)}))}})},`${s.id}-sf-${j}`):a.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:h=>{h.preventDefault(),h.stopPropagation(),de(a.documentId)},children:["《",a.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[a.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:a.path}):null,a.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:a.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${s.id}-c-${j}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[a.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:a.rows.length===0?"无结果":`${a.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:a.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:a.rows.map(h=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>de(h.documentId),children:h.title})}),e.jsx("td",{children:h.summary||"-"})]},h.documentId))})]})})]})},`${s.id}-d-${j}`)}),y&&s.id===((m=w[w.length-1])==null?void 0:m.id)&&!fe(s.blocks)&&!Je(s.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):s.content?e.jsx(pe,{children:s.content}):y?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:s.content]}),s.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:I}):null]},s.id)})})}),ie?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ie}):null,e.jsx(Be,{selectedNames:B,onChange:ae,disabled:y||!(u!=null&&u.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:u!=null&&u.enabled?"把你的问题告诉我…":"请先配置 API Key",value:O,disabled:y||!(u!=null&&u.enabled),onChange:s=>U(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),ee(O))}}),G?e.jsx(Ze,{percent:G.percent,used:G.used,limit:G.limit}):null,e.jsx("button",{type:"button",className:y?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:y?!1:!(u!=null&&u.enabled)||!O.trim(),onClick:()=>{var s;if(y){(s=v.current)==null||s.abort();return}ee(O)},title:y?"停止":"发送","aria-label":y?"停止":"发送",children:y?"■":"↑"})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),X?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{M||T(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:M,onClick:()=>T(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:M,onClick:()=>void we(),children:M?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{cs as AgentChatPanel};
|
|
1
|
+
import{r as d,j as e}from"./react-vendor-BJFXgntS.js";import{ad as Ae,ae as Ce,i as me,af as _e,ag as qe,ah as Re,ai as $e,aj as Ee,ak as De,al as xe,am as Me,an as Fe,ao as Te}from"./index-Ct5Vt4tz.js";import{H as ze,S as Pe,A as Be}from"./AgentSkillFormCard-DeZnOTQg.js";import{P as Le}from"./plus-B-uEAM2g.js";import{D as He,E as Ke}from"./ui-TwLH91RV.js";import{C as Oe,a as Ue}from"./copy-UkvgEfIg.js";import"./motion-Bz_inm1R.js";function te(r){var n;return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(te).join(""):typeof r=="object"&&"props"in r?te((n=r.props)==null?void 0:n.children):""}function We(r){const[n,c]=d.useState(!1),o=d.useRef(null),b=te(r.children).replace(/\n$/,"");d.useEffect(()=>()=>{o.current!=null&&window.clearTimeout(o.current)},[]);async function x(){if(b)try{await navigator.clipboard.writeText(b),c(!0),o.current!=null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>c(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void x(),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Oe,{size:14,"aria-hidden":!0}):e.jsx(Ue,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:r.children})]})}function pe(r){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(He,{remarkPlugins:[Ke],components:{pre:({children:n})=>e.jsx(We,{children:n})},children:r.children})})}const Ge=["如何发布文档?","草稿是什么?","如何创建域?"];function he(r,n){return n.map((c,o)=>{const b=c.skillNames&&c.skillNames.length>0?c.skillNames:c.skillIds&&c.skillIds.length>0?c.skillIds:void 0;return{id:`h-${r}-${o}-${c.role}`,role:c.role,content:c.content,skillNames:b}})}function Xe(r,n){const c=r.slice(),o=c[c.length-1];return(o==null?void 0:o.type)==="text"?c[c.length-1]={type:"text",text:o.text+n}:c.push({type:"text",text:n}),c}function Ye(r,n){const c=r.slice(),o=c[c.length-1];return(o==null?void 0:o.type)==="thinking"?c[c.length-1]={type:"thinking",text:o.text+n}:c.push({type:"thinking",text:n}),c}function fe(r){return r!=null&&r.length?r.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Je(r){return!!(r!=null&&r.some(n=>n.type==="thinking"&&n.text.length>0))}function Qe(r){const n=new Date(r);if(Number.isNaN(n.getTime()))return"";const c=new Date;return n.getFullYear()===c.getFullYear()&&n.getMonth()===c.getMonth()&&n.getDate()===c.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function ge(r){if(r>=1e3){const n=r/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(r)}function Ve(r){const{block:n,onResolved:c}=r,[o,b]=d.useState(""),[x,R]=d.useState(!1),[$,C]=d.useState(1),E=d.useRef(!1),z=d.useRef(c);z.current=c;const I=n.status==="open",_=d.useRef(0);d.useEffect(()=>{if(!I)return;E.current=!1;const k=new Date(n.expiresAt).getTime(),q=Date.now(),w=Math.max(k-q,1);_.current=w,C(1);const g=()=>{const F=k-Date.now(),K=Math.max(0,Math.min(1,F/w));C(K),F<=0&&!E.current&&(E.current=!0,Fe(n.requestId).catch(()=>{}).finally(()=>{z.current(n.requestId,"","expired")}))};g();const P=window.setInterval(g,100);return()=>window.clearInterval(P)},[I,n.expiresAt,n.requestId]);async function S(k){const q=k.trim();if(!(!q||x||!I)){R(!0);try{await Te(n.requestId,q),c(n.requestId,q,"selected")}catch{c(n.requestId,q,"failed")}finally{R(!1)}}}async function u(){if(!(x||!I)){R(!0),E.current=!0;try{await xe(n.requestId),c(n.requestId,"","cancelled")}catch{c(n.requestId,"","failed")}finally{R(!1)}}}const H=Math.max(0,Math.ceil($*_.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(I?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),I?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),I?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round($*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${$})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(k=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:x,onClick:()=>void S(k),children:k},k))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:o,disabled:x,placeholder:"或输入自己的内容…",onChange:k=>b(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),S(o))}}),e.jsx("button",{type:"button",disabled:x||!o.trim(),onClick:()=>void S(o),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:x,onClick:()=>void u(),children:"取消"})})]}):null]})}function Ze(r){const b=2*Math.PI*8.75,x=Math.min(100,Math.max(0,r.percent)),R=b*(1-x/100),$=x>=90?"danger":x>=70?"warn":"ok",C=`上下文 ${x}% · 已用 ${ge(r.used)} / ${ge(r.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+$,"data-tooltip":C,"aria-label":C,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:R,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function es(r){var n;for(const c of r)if(!(c.role!=="assistant"||!((n=c.blocks)!=null&&n.length))){for(const o of c.blocks)if((o.type==="choice_card"||o.type==="skill_form_card")&&o.status==="open")return!0}return!1}const cs=d.forwardRef(function(n,c){const{open:o,onClose:b,visitorName:x,anchorStyle:R,onOpenDocument:$,onTreeChanged:C,onDocumentOverwritten:E,onOpenCoding:z}=n,I=((x==null?void 0:x.trim().charAt(0))||"我").toUpperCase(),[_,S]=d.useState(!1),[u,H]=d.useState(null),[k,q]=d.useState(null),[w,g]=d.useState([]),[P,F]=d.useState(null),[K,ye]=d.useState([]),[je,ne]=d.useState(!1),[O,U]=d.useState(""),[B,ae]=d.useState([]),[y,W]=d.useState(!1),[ie,D]=d.useState(null),[G,re]=d.useState(null),[X,T]=d.useState(!1),[M,le]=d.useState(!1),ke=d.useRef(null),Y=d.useRef(null),v=d.useRef(null),ce=d.useRef(0),L=d.useRef(!0),J=d.useRef(w);J.current=w;function oe(s){return ce.current+=1,`${s}-${ce.current}`}function Ne(s,m=48){return s.scrollHeight-s.scrollTop-s.clientHeight<=m}function A(){const s=Y.current;!s||!L.current||(s.scrollTop=s.scrollHeight)}function be(){const s=Y.current;s&&(L.current=Ne(s))}async function Se(){ne(!0);try{const s=await Re();ye(s.sessions),P||F(s.lastOpenedSessionId)}catch{}finally{ne(!1)}}async function Q(){try{const s=await qe();re(s)}catch{}}d.useEffect(()=>{var m;if(!o){S(!1),(m=v.current)==null||m.abort(),v.current=null,W(!1);return}let s=!1;return(async()=>{try{const a=await Ae();s||(H(a),q(null))}catch(a){s||(H(null),q(a instanceof Error?a.message:String(a)))}})(),Q(),()=>{s=!0}},[o]),d.useEffect(()=>{if(!o)return;let s=!1;return(async()=>{try{const m=await Ce();if(s)return;F(m.sessionId),g(a=>a.length>0?a:he(m.sessionId,m.messages))}catch{}})(),()=>{s=!0}},[o]),d.useEffect(()=>{!o||!_||Se()},[o,_]);function V(){if(!M){if(es(J.current)){T(!0);return}T(!1),b()}}async function we(){var a;if(M)return;le(!0);const s=J.current,m=[];for(const j of s)if(!(j.role!=="assistant"||!j.blocks))for(const p of j.blocks)p.type==="choice_card"&&p.status==="open"&&m.push(xe(p.requestId).catch(()=>{})),p.type==="skill_form_card"&&p.status==="open"&&m.push(Me(p.requestId).catch(()=>{}));await Promise.all(m),(a=v.current)==null||a.abort(),g(j=>j.map(p=>p.role!=="assistant"||!p.blocks?p:{...p,blocks:p.blocks.map(h=>h.type==="choice_card"&&h.status==="open"?{...h,status:"cancelled"}:h.type==="skill_form_card"&&h.status==="open"?{...h,status:"cancelled"}:h)})),T(!1),le(!1),b()}const Z=d.useRef(V);Z.current=V,d.useImperativeHandle(c,()=>({requestClose:()=>Z.current()}),[]),d.useEffect(()=>{if(!o){T(!1);return}const s=m=>{if(m.key==="Escape"){if(X){M||T(!1);return}if(_){S(!1);return}Z.current()}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[o,_,X,M]);async function ee(s){var h;const m=s.trim();if(!m||y)return;if(!(u!=null&&u.enabled)){D((u==null?void 0:u.reason)==="missing_api_key"?"请先在设置 → AI 配置 DeepSeek API Key":(u==null?void 0:u.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(h=v.current)==null||h.abort();const a=new AbortController;v.current=a;const j={id:oe("u"),role:"user",content:m,skillNames:B.length>0?[...B]:void 0},p=oe("a");L.current=!0,g(N=>[...N,j,{id:p,role:"assistant",content:""}]),U(""),W(!0),D(null),S(!1),requestAnimationFrame(()=>A());try{let N=!1;await De(m,{skillNames:B.length>0?B:void 0,signal:a.signal,onEvent:i=>{i.type==="text_delta"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=Xe(t.blocks??[],i.text);return{...t,blocks:l,content:fe(l)}})),requestAnimationFrame(()=>A())):i.type==="thinking_delta"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=Ye(t.blocks??[],i.text);return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="sources"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=(t.blocks??[]).slice(),se=l[l.length-1];return(se==null?void 0:se.type)==="sources"?l[l.length-1]={type:"sources",items:i.items}:l.push({type:"sources",items:i.items}),{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="document_table"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_table",title:i.title,rows:i.rows}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="document_card"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_card",documentId:i.documentId,title:i.title,path:i.path,preview:i.preview}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="tool_notice"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"tool_notice",toolName:i.toolName,text:i.text}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="choice_card"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"choice_card",requestId:i.requestId,title:i.title,options:i.options,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="choice_expired"?g(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="skill_form_card"?(g(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"skill_form_card",requestId:i.requestId,mode:i.mode,title:i.title,currentName:i.currentName,initialName:i.initialName,initialDescription:i.initialDescription,initialBody:i.initialBody,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>A())):i.type==="skill_form_expired"?g(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="tree_changed"?C==null||C():i.type==="document_overwritten"?E==null||E({documentId:i.documentId,headCommitId:i.headCommitId}):i.type==="open_coding"?z==null||z({documentId:i.documentId,displayName:i.displayName}):i.type==="context_usage"?re({percent:i.percent,used:i.used,limit:i.limit}):i.type==="error"&&(N=!0,D(i.message))}}),!a.signal.aborted&&!N&&ae([])}catch(N){if(a.signal.aborted)return;D(N instanceof Error?N.message:String(N))}finally{v.current===a&&(v.current=null),W(!1)}}async function Ie(){var s;if(!y){(s=v.current)==null||s.abort(),D(null),S(!1),W(!1);try{const m=await $e();F(m.sessionId),g([]),U(""),L.current=!0,Q()}catch(m){D(m instanceof Error?m.message:String(m))}}}async function ve(s){var m;if(!y){if(s===P){S(!1);return}(m=v.current)==null||m.abort(),D(null);try{const a=await Ee(s);F(a.sessionId),g(he(a.sessionId,a.messages)),U(""),S(!1),L.current=!0,requestAnimationFrame(()=>A()),Q()}catch(a){D(a instanceof Error?a.message:String(a))}}}function de(s){!s||!$||$(s)}if(!o)return null;const ue=k??(u&&!u.enabled?u.reason==="missing_api_key"?"未配置 API Key:请打开设置 → AI":u.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:ke,className:"mdocs-agent-panel",role:"dialog","aria-label":"mdocs 智能助手",style:R,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:me,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:y,onClick:()=>void Ie(),children:e.jsx(Le,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(_?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>S(s=>!s),children:e.jsx(ze,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:V,children:e.jsx(_e,{size:16,strokeWidth:1.8})})]})]}),_?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>S(!1),children:"返回对话"})]}),je?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):K.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:K.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(s.id===P?" active":""),disabled:y,onClick:()=>void ve(s.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:s.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:Qe(s.updatedAt)})]})},s.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:Y,onScroll:be,children:w.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),ue?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ue}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Ge.map(s=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void ee(s),disabled:y||!(u!=null&&u.enabled),children:s},s))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:w.map(s=>{var m;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(s.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[s.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:me,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[s.role==="user"&&s.skillNames&&s.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",s.skillNames.length]}):null,s.role==="assistant"?s.blocks&&s.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[s.blocks.map((a,j)=>{var p;return a.type==="thinking"?a.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:y&&s.id===((p=w[w.length-1])==null?void 0:p.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:a.text})]},`${s.id}-th-${j}`):null:a.type==="text"?a.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(pe,{children:a.text})},`${s.id}-t-${j}`):null:a.type==="sources"?a.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",a.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:a.items.map(h=>e.jsx("li",{children:e.jsx("a",{href:h.url,target:"_blank",rel:"noreferrer",children:h.name})},h.id))})]})},`${s.id}-s-${j}`):a.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:a.text})},`${s.id}-n-${j}`):a.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ve,{block:a,onResolved:(h,N,i)=>{g(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===h?{...l,status:i,selected:i==="selected"?N:l.selected}:l)}))}})},`${s.id}-ch-${j}`):a.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Pe,{block:a,onResolved:(h,N,i)=>{g(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===h?{...l,status:N,submittedName:N==="submitted"?i:l.submittedName}:l)}))}})},`${s.id}-sf-${j}`):a.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:h=>{h.preventDefault(),h.stopPropagation(),de(a.documentId)},children:["《",a.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[a.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:a.path}):null,a.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:a.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${s.id}-c-${j}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[a.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:a.rows.length===0?"无结果":`${a.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:a.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:a.rows.map(h=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>de(h.documentId),children:h.title})}),e.jsx("td",{children:h.summary||"-"})]},h.documentId))})]})})]})},`${s.id}-d-${j}`)}),y&&s.id===((m=w[w.length-1])==null?void 0:m.id)&&!fe(s.blocks)&&!Je(s.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):s.content?e.jsx(pe,{children:s.content}):y?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:s.content]}),s.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:I}):null]},s.id)})})}),ie?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ie}):null,e.jsx(Be,{selectedNames:B,onChange:ae,disabled:y||!(u!=null&&u.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:u!=null&&u.enabled?"把你的问题告诉我…":"请先配置 API Key",value:O,disabled:y||!(u!=null&&u.enabled),onChange:s=>U(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),ee(O))}}),G?e.jsx(Ze,{percent:G.percent,used:G.used,limit:G.limit}):null,e.jsx("button",{type:"button",className:y?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:y?!1:!(u!=null&&u.enabled)||!O.trim(),onClick:()=>{var s;if(y){(s=v.current)==null||s.abort();return}ee(O)},title:y?"停止":"发送","aria-label":y?"停止":"发送",children:y?"■":"↑"})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),X?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{M||T(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:M,onClick:()=>T(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:M,onClick:()=>void we(),children:M?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{cs as AgentChatPanel};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as q,
|
|
1
|
+
import{c as q,_ as L,aq as D,am as _,ar as F}from"./index-Ct5Vt4tz.js";import{r as a,j as e}from"./react-vendor-BJFXgntS.js";/**
|
|
2
2
|
* @license lucide-react v0.562.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const B=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],O=q("history",B),j=5;function X(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await L();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const $=/^[A-Za-z0-9_]+$/;function
|
|
6
|
+
*/const B=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],O=q("history",B),j=5;function X(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await L();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const $=/^[A-Za-z0-9_]+$/;function K(i){const{block:t,onResolved:r}=i,[d,k]=a.useState(t.initialName),[u,p]=a.useState(t.initialDescription),[h,v]=a.useState(t.initialBody),[c,f]=a.useState(!1),[s,n]=a.useState(null),[o,g]=a.useState(1),x=a.useRef(!1),N=a.useRef(r);N.current=r;const m=t.status==="open",b=a.useRef(0);a.useEffect(()=>{if(!m)return;x.current=!1;const l=new Date(t.expiresAt).getTime(),C=Date.now(),y=Math.max(l-C,1);b.current=y,g(1);const S=()=>{const w=l-Date.now(),M=Math.max(0,Math.min(1,w/y));g(M),w<=0&&!x.current&&(x.current=!0,D(t.requestId).catch(()=>{}).finally(()=>{N.current(t.requestId,"expired")}))};S();const I=window.setInterval(S,100);return()=>window.clearInterval(I)},[m,t.expiresAt,t.requestId]);async function E(){if(c||!m)return;const l=d.trim();if(!l){n("名称不能为空");return}if(!$.test(l)){n("名称仅允许英文、数字、下划线");return}if(!h.trim()){n("正文不能为空");return}f(!0),n(null);try{await F(t.requestId,{name:l,description:u.trim(),body:h}),r(t.requestId,"submitted",l)}catch{r(t.requestId,"failed")}finally{f(!1)}}async function R(){if(!(c||!m)){f(!0),n(null),x.current=!0;try{await _(t.requestId),r(t.requestId,"cancelled")}catch{r(t.requestId,"failed")}finally{f(!1)}}}const A=Math.max(0,Math.ceil(o*b.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(m?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:t.title}),m?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[A,"s"]}):null]}),m?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${o})`}})}):null,t.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",t.submittedName?`:${t.submittedName}`:""]}):null,t.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,t.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,t.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,m?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:d,onChange:l=>k(l.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:u,onChange:l=>p(l.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:h,onChange:l=>v(l.target.value),rows:8,disabled:c})]}),s?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:s}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void R(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void E(),children:c?"提交中…":t.mode==="create"?"创建":"保存"})]})]}):null]})}export{X as A,O as H,K as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as u,j as n}from"./react-vendor-
|
|
1
|
+
import{r as u,j as n}from"./react-vendor-BJFXgntS.js";import{ad as le,ae as oe,i as re,ah as ce,ap as de,ai as ue,aj as me,ak as he}from"./index-Ct5Vt4tz.js";import{H as fe,S as ge,A as xe}from"./AgentSkillFormCard-DeZnOTQg.js";import{P as ke}from"./plus-B-uEAM2g.js";import{D as ye,E as we}from"./ui-TwLH91RV.js";import"./motion-Bz_inm1R.js";function U(e){return e===""?[]:e.split(`
|
|
2
2
|
`)}function te(e){return e.join(`
|
|
3
3
|
`)}function K(e,i){const t=U(e),a=U(i),m=t.length,k=a.length,y=Array.from({length:m+1},()=>Array.from({length:k+1},()=>0));for(let C=m-1;C>=0;C--)for(let I=k-1;I>=0;I--)t[C]===a[I]?y[C][I]=y[C+1][I+1]+1:y[C][I]=Math.max(y[C+1][I],y[C][I+1]);const S=[];let x=0,w=0;for(;x<m||w<k;)if(x<m&&w<k&&t[x]===a[w])S.push({kind:"eq",oi:x,ni:w}),x++,w++;else if(w<k&&(x===m||y[x][w+1]>=y[x+1][w]))S.push({kind:"ins",oi:x,ni:w}),w++;else if(x<m)S.push({kind:"del",oi:x,ni:w}),x++;else break;const E=[];let c=0,D=0;for(;c<S.length;){if(S[c].kind==="eq"){c++;continue}const C=S[c].oi,I=S[c].ni,T=[],L=[];let v=C,H=I;for(;c<S.length&&S[c].kind!=="eq";){const A=S[c];A.kind==="del"?(T.push(t[A.oi]),v=A.oi+1):(L.push(a[A.ni]),H=A.ni+1),c++}E.push({id:`h${D++}`,oldStart:C,oldEnd:v,newStart:I,newEnd:H,oldLines:T,newLines:L})}return E}function je(e,i){const t=U(e);return te([...t.slice(0,i.oldStart),...i.newLines,...t.slice(i.oldEnd)])}function pe(e,i){const t=U(e);return te([...t.slice(0,i.newStart),...i.oldLines,...t.slice(i.newEnd)])}function J(e){return e===""?[]:e.split(`
|
|
4
4
|
`)}function z(e){return e.join(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Q as I,S as H,T as F,U as O,V as G}from"./react-6CQL39Gs.js";import{r as c,j as e}from"./react-vendor-BJFXgntS.js";import{ensureMeta2dShapes as X,generateSvgFromMeta2d as Q,generateSvgFromDiagram as Y}from"./meta2dEngine-BD2XbzaV-2ovN6JHu.js";import{M as _}from"./meta2d-D3b5RRN8.js";import"./editor-ONzd_YnO.js";import"./ui-TwLH91RV.js";import"./motion-Bz_inm1R.js";import"./diagram-BLCqfrbF.js";import"./index-Ct5Vt4tz.js";import"./plus-B-uEAM2g.js";import"./copy-UkvgEfIg.js";let q=0;const P=new Set;function $(n){return P.add(n),()=>{P.delete(n)}}function M(){return q}function J(){q++,P.forEach(n=>n())}function z(n){let t=null;try{const[r]=I();t=r}catch{}const i=t;if(!i)throw new Error("[useEditorLocale] No editor found. Pass an editor instance or use this hook inside an <Editor> tree.");return c.useSyncExternalStore($,M,M),{setLocale:c.useCallback(r=>{i.setLocale(r),J()},[i]),t:c.useCallback((r,u)=>i.t(r,u),[i])}}const K={Activity:"meta2d.palette.groups.activity",Basic:"meta2d.palette.groups.basic","Fault tree":"meta2d.palette.groups.faultTree",Flow:"meta2d.palette.groups.flow","Sequence & class":"meta2d.palette.groups.sequenceClass"};function W(n){return`meta2d.palette.${n}`}const s={background:"#fff",color:"#1f1f1f",height:60,lineWidth:1,textColor:"#1f1f1f",width:120};function U(){return[{group:"Basic",key:"square",label:"Square",pen:{...s,height:100,name:"square",text:"",width:100}},{group:"Basic",key:"rect",label:"Rectangle",pen:{...s,name:"rectangle",text:"Rectangle"}},{group:"Basic",key:"roundRect",label:"Rounded",pen:{...s,borderRadius:.2,name:"rectangle",text:"Rounded"}},{group:"Basic",key:"circle",label:"Circle",pen:{...s,height:80,name:"circle",text:"Circle",width:80}},{group:"Basic",key:"triangle",label:"Triangle",pen:{...s,height:90,name:"triangle",text:"Triangle",width:100}},{group:"Basic",key:"diamond",label:"Diamond",pen:{...s,height:100,name:"diamond",text:"Decision",width:100}},{group:"Basic",key:"pentagon",label:"Pentagon",pen:{...s,height:100,name:"pentagon",text:"Pentagon",width:100}},{group:"Basic",key:"hexagon",label:"Hexagon",pen:{...s,height:100,name:"hexagon",text:"Hexagon",width:100}},{group:"Basic",key:"pentagram",label:"Star",pen:{...s,height:100,name:"pentagram",text:"",width:100}},{group:"Basic",key:"leftArrow",label:"Left arrow",pen:{height:60,name:"leftArrow",width:120}},{group:"Basic",key:"rightArrow",label:"Right arrow",pen:{height:60,name:"rightArrow",width:120}},{group:"Basic",key:"twowayArrow",label:"Two-way",pen:{height:60,name:"twowayArrow",width:150}},{group:"Basic",key:"cloud",label:"Cloud",pen:{height:100,name:"cloud",width:100}},{group:"Basic",key:"message",label:"Message",pen:{height:100,name:"message",textTop:-.1,width:100}},{group:"Basic",key:"file",label:"File",pen:{height:100,name:"file",width:80}},{group:"Basic",key:"cube",label:"Cube",pen:{height:100,name:"cube",width:60,z:.25}},{group:"Basic",key:"people",label:"Actor",pen:{height:100,name:"people",width:70}},{group:"Basic",key:"text",label:"Text",pen:{...s,background:"transparent",color:"transparent",height:32,name:"text",text:"text",width:120}},{group:"Basic",key:"line",label:"Line",pen:{color:"#1f1f1f",height:1,lineWidth:1,name:"line",width:160}},{group:"Flow",key:"flowTerminal",label:"Terminal",pen:{...s,borderRadius:.5,height:40,name:"rectangle",text:"Start / End",width:120}},{group:"Flow",key:"flowProcess",label:"Process",pen:{...s,height:40,name:"rectangle",text:"Process",width:120}},{group:"Flow",key:"flowDecision",label:"Decision",pen:{...s,height:60,name:"diamond",text:"Decision",width:120}},{group:"Flow",key:"flowData",label:"Data",pen:{...s,name:"flowData",offsetX:.14,text:"Data"}},{group:"Flow",key:"flowPrepare",label:"Prepare",pen:{...s,height:50,name:"hexagon",text:"Prepare",width:120}},{group:"Flow",key:"flowSubprocess",label:"Subprocess",pen:{...s,height:50,name:"flowSubprocess",text:"Subprocess",width:120}},{group:"Flow",key:"flowDb",label:"Database",pen:{...s,height:100,name:"flowDb",text:"DB",width:80}},{group:"Flow",key:"flowDocument",label:"Document",pen:{...s,height:100,name:"flowDocument",text:"Document",width:120}},{group:"Flow",key:"flowInternalStorage",label:"Int. storage",pen:{...s,height:80,name:"flowInternalStorage",text:"Internal",width:120}},{group:"Flow",key:"flowExternStorage",label:"Ext. storage",pen:{...s,height:80,name:"flowExternStorage",text:"External",width:120}},{group:"Flow",key:"flowQueue",label:"Queue",pen:{...s,height:100,name:"flowQueue",text:"Queue",width:100}},{group:"Flow",key:"flowManually",label:"Manual input",pen:{...s,height:80,name:"flowManually",text:"Manual",width:120}},{group:"Flow",key:"flowDisplay",label:"Display",pen:{...s,height:80,name:"flowDisplay",text:"Display",width:120}},{group:"Flow",key:"flowParallel",label:"Parallel",pen:{...s,height:50,name:"flowParallel",text:"Parallel",width:120}},{group:"Flow",key:"flowComment",label:"Comment",pen:{...s,height:100,name:"flowComment",text:"Note",width:100}},{group:"Activity",key:"actStart",label:"Start",pen:{background:"#555",height:30,lineWidth:0,name:"circle",text:"",width:30}},{group:"Activity",key:"actFinal",label:"Final",pen:{height:30,name:"activityFinal",width:30}},{group:"Activity",key:"actStep",label:"Action",pen:{...s,borderRadius:.25,height:50,name:"rectangle",text:"Action",width:120}},{group:"Activity",key:"actMerge",label:"Merge",pen:{...s,height:50,name:"diamond",text:"Merge",width:120}},{group:"Activity",key:"swimlaneV",label:"Swimlane V",pen:{height:500,lineTop:.08,name:"swimlaneV",text:"Swimlane",textBaseline:"top",textTop:20,width:200}},{group:"Activity",key:"swimlaneH",label:"Swimlane H",pen:{height:200,lineLeft:.08,name:"swimlaneH",text:"Swimlane",textAlign:"left",textLeft:.04,textWidth:.01,width:500}},{group:"Activity",key:"forkV",label:"Fork V",pen:{fillStyle:"#555",height:150,name:"forkV",strokeStyle:"transparent",text:"",width:10}},{group:"Activity",key:"forkH",label:"Fork H",pen:{fillStyle:"#555",height:10,name:"forkH",strokeStyle:"transparent",text:"",width:150}},{group:"Sequence & class",key:"lifeline",label:"Lifeline",pen:{height:400,name:"lifeline",text:"Object",textHeight:50,width:150}},{group:"Sequence & class",key:"sequenceFocus",label:"Activation",pen:{height:200,name:"sequenceFocus",text:"",width:12}},{group:"Sequence & class",key:"simpleClass",label:"Simple class",pen:{height:200,list:[{text:`- name: string
|
|
2
|
+
+ setName(name: string): void`}],name:"simpleClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Sequence & class",key:"interfaceClass",label:"Class",pen:{height:200,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}],name:"interfaceClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Fault tree",key:"andGate",label:"AND gate",pen:{height:150,name:"andGate",width:100}},{group:"Fault tree",key:"orGate",label:"OR gate",pen:{height:150,name:"orGate",width:100}},{group:"Fault tree",key:"basicEvent",label:"Basic event",pen:{height:150,name:"basicEvent",width:100}},{group:"Fault tree",key:"xorGate",label:"XOR gate",pen:{height:150,name:"xorGate",width:100}},{group:"Fault tree",key:"votingGate",label:"Voting gate",pen:{height:150,name:"votingGate",width:100}}]}function V(n){return G(structuredClone(n))}function Z(n){const t=new Map;for(const i of n){const r=t.get(i.group)??[];r.push(i),t.set(i.group,r)}return Array.from(t.entries())}function ee({name:n}){const t={fill:"#fff",stroke:"#1f1f1f",strokeWidth:1.2};return n==="circle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("circle",{cx:"14",cy:"14",r:"10",...t})}):n==="diamond"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,14 14,25 3,14",...t})}):n==="triangle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,4 25,24 3,24",...t})}):n==="pentagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,12 21,25 7,25 3,12",...t})}):n==="hexagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"8,4 20,4 25,14 20,24 8,24 3,14",...t})}):n==="pentagram"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 17,11 26,11 18,16 21,25 14,20 7,25 10,16 2,11 11,11",...t})}):n==="line"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("line",{x1:"4",x2:"24",y1:"14",y2:"14",...t})}):n==="text"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("text",{dominantBaseline:"middle",fill:"#1f1f1f",fontSize:"14",textAnchor:"middle",x:"14",y:"15",children:"T"})}):e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("rect",{height:"14",rx:"2",width:"20",x:"4",y:"7",...t})})}function te({disabled:n,engineRef:t,item:i,t:r}){const u=()=>{const a=t.current;if(!(!a||n))try{a.canvas.addCaches=[V(i.pen)]}catch{}};return e.jsxs("div",{draggable:!n,onClick:a=>{a.stopPropagation(),u()},onDragStart:a=>{if(n){a.preventDefault();return}const f=JSON.stringify(V(i.pen));a.dataTransfer.setData("Meta2d",f),a.dataTransfer.setData("Text",f),a.dataTransfer.effectAllowed="copy"},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),u())},role:"button",style:{alignItems:"center",border:"1px solid #efefef",borderRadius:6,cursor:n?"not-allowed":"grab",display:"flex",flexDirection:"column",gap:4,justifyContent:"center",minHeight:56,opacity:n?.5:1,outline:"none",padding:6},tabIndex:n?-1:0,title:`${r(W(i.key))||i.label} — drag or click to add`,children:[e.jsx(ee,{name:String(i.pen.name??"rectangle")}),e.jsx("span",{style:{fontSize:11},children:r(W(i.key))||i.label})]})}function ne({disabled:n,engineRef:t}){const{t:i}=z(),r=c.useMemo(()=>Z(U()),[]);return e.jsxs("aside",{style:{borderRight:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",padding:12,touchAction:"pan-y",width:240},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:4},children:i("meta2d.palette.title")}),e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:12},children:i("meta2d.palette.hint")}),r.map(([u,a])=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:6},children:i(K[u]||u)}),e.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"repeat(2, minmax(0, 1fr))"},children:a.map(f=>e.jsx(te,{disabled:n,engineRef:t,item:f,t:i},f.key))})]},u))]})}const N={borderLeft:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",width:220},A={color:"#8c8c8c",fontSize:12,marginBottom:4},D={borderBottom:"1px solid #f0f0f0",padding:"10px 12px"},y={alignItems:"center",display:"flex",gap:6,marginBottom:6},w={background:"#fafafa",border:"1px solid #e5e5e5",borderRadius:4,fontSize:12,height:28,outline:"none",padding:"0 6px"},b={color:"#8c8c8c",fontSize:11,minWidth:22},T={background:"#fff",border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer",fontSize:11,minWidth:48,padding:"4px 8px"},le=120;function ie({engine:n}){const{t}=z(),[i,r]=c.useState(null),[u,a]=c.useState(null),[f,v]=c.useState(""),p=c.useRef(null),j=c.useRef(null),B=c.useCallback((l,d)=>{!n||l===null||l===void 0||n.setValue({id:l,text:d},{render:!0})},[n]),k=c.useCallback(l=>{if(!l||l.length!==1){p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null;return}const d=l[0];if((d.globalAlpha===null||d.globalAlpha===void 0)&&(d.globalAlpha=1),d.id!==j.current&&(p.current&&(clearTimeout(p.current),p.current=null),j.current=d.id,v(d.text??"")),r(d),n)try{a(n.getPenRect(d))}catch{a(null)}},[n]),C=c.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null},[]);if(c.useEffect(()=>{if(n)return n.on("active",k),n.on("inactive",C),()=>{n.off("active",k),n.off("inactive",C),p.current&&(clearTimeout(p.current),p.current=null)}},[n,k,C]),!i||!n)return e.jsx("aside",{style:N,children:e.jsx("div",{style:{color:"#bbb",fontSize:12,padding:16,textAlign:"center"},children:t("meta2d.props.empty")})});const h=(l,d)=>{const m={id:i.id};m[l]=d,l==="dash"&&(m.lineDash=[void 0,[5,5]][d]),l!=="text"&&r(S=>S&&{...S,...m}),n.setValue(m,{render:!0})},o=l=>{v(l);const d=i.id;p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null,B(d,l)},le)},x=()=>{p.current&&(clearTimeout(p.current),p.current=null),B(i.id,f)},g=(l,d)=>{if(!u)return;const m={id:i.id};m[l]=d,n.setValue(m,{render:!0}),a(S=>S?{...S,[l]:d}:null)},R=l=>{l(n),n.render(!0)};return e.jsxs("aside",{style:N,children:[e.jsxs("div",{style:D,children:[e.jsx("div",{style:A,children:t("meta2d.props.text")}),e.jsx("div",{style:y,children:e.jsx("input",{onBlur:x,onChange:l=>o(l.target.value),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),l.target.blur())},style:{...w,flex:1,width:"100%"},type:"text",value:f})})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.appearance")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.color")}),e.jsx("input",{onChange:l=>h("color",l.target.value),style:{...w,flex:1},type:"color",value:i.color||"#1f1f1f"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.bg")}),e.jsx("input",{onChange:l=>h("background",l.target.value),style:{...w,flex:1},type:"color",value:i.background||"#ffffff"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.dash")}),e.jsxs("select",{onChange:l=>h("dash",Number(l.target.value)),style:{...w,flex:1},value:String(i.dash??0),children:[e.jsx("option",{value:"0",children:t("meta2d.props.solid")}),e.jsx("option",{value:"1",children:t("meta2d.props.dashLine")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.radius")}),e.jsx("input",{max:1,min:0,onChange:l=>h("borderRadius",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.borderRadius??0)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:i.borderRadius??0})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.alpha")}),e.jsx("input",{max:1,min:0,onChange:l=>h("globalAlpha",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.globalAlpha??1)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:(i.globalAlpha??1).toFixed(2)})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.position")}),[["X","x"],["Y","y"],["W","width"],["H","height"]].map(([l,d])=>e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:l}),e.jsx("input",{onChange:m=>g(d,Number(m.target.value)),style:{...w,flex:1},type:"number",value:u?u[d]:0})]},d))]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.textAlign")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.h")}),e.jsxs("select",{onChange:l=>h("textAlign",l.target.value),style:{...w,flex:1},value:i.textAlign||"center",children:[e.jsx("option",{value:"left",children:t("meta2d.props.left")}),e.jsx("option",{value:"center",children:t("meta2d.props.center")}),e.jsx("option",{value:"right",children:t("meta2d.props.right")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.v")}),e.jsxs("select",{onChange:l=>h("textBaseline",l.target.value),style:{...w,flex:1},value:i.textBaseline||"middle",children:[e.jsx("option",{value:"top",children:t("meta2d.props.topAlign")}),e.jsx("option",{value:"middle",children:t("meta2d.props.middle")}),e.jsx("option",{value:"bottom",children:t("meta2d.props.bottomAlign")})]})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.layer")}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.jsx("button",{onClick:()=>R(l=>l.top()),style:T,type:"button",children:t("meta2d.props.top")}),e.jsx("button",{onClick:()=>R(l=>l.up()),style:T,type:"button",children:t("meta2d.props.up")}),e.jsx("button",{onClick:()=>R(l=>l.down()),style:T,type:"button",children:t("meta2d.props.down")}),e.jsx("button",{onClick:()=>R(l=>l.bottom()),style:T,type:"button",children:t("meta2d.props.bottom")})]})]})]})}const L={background:"#fff",border:"1px solid #d9d9d9",borderRadius:6,cursor:"pointer",minWidth:68,padding:"6px 12px"},E={...L,fontSize:12,minWidth:52,padding:"4px 10px"};function re(n){c.useEffect(()=>{const t=document.documentElement,i=document.body,r=t.style.overflow,u=i.style.overflow;return t.style.overflow="hidden",i.style.overflow="hidden",()=>{t.style.overflow=r,i.style.overflow=u}},[n])}function me({diagram:n,onClose:t,onSave:i}){const{t:r}=z(),u=c.useRef(null),a=c.useRef(null),f=c.useRef(n),v=c.useRef(t),[p,j]=c.useState(null),[B,k]=c.useState(!1);re(!0),c.useLayoutEffect(()=>{v.current=t}),c.useEffect(()=>{if(!u.current)return;X();const o=new _(u.current,{grid:!0,rule:!1});a.current=o,j(o);try{const g=f.current;g!=null&&g.trim()?o.open(JSON.parse(g)):o.open(H()),F(o.data()),o.render(!0)}catch{o.open(H()),F(o.data()),o.render(!0)}const x=g=>{g.key==="Escape"&&v.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x);try{o.destroy()}catch{}a.current=null}},[]);const C=async()=>{const o=a.current;if(o){k(!0);try{F(o.data()),o.render(!0);const x=O(o.data()),g=JSON.stringify(x);i(g,await Q(o)||await Y(g)||'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="100%" height="100%" fill="#fafafa" stroke="#eee"/></svg>')}finally{k(!1)}}},h=o=>{const x=a.current;x&&o(x)};return e.jsx("div",{onClick:t,style:{alignItems:"center",background:"rgb(0 0 0 / 35%)",display:"flex",inset:0,justifyContent:"center",overflow:"hidden",position:"fixed",zIndex:1e3},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),onWheel:o=>o.stopPropagation(),style:{background:"#fff",borderRadius:10,boxShadow:"0 12px 30px rgb(0 0 0 / 20%)",display:"flex",flexDirection:"column",height:"86vh",maxHeight:"100%",maxWidth:"1200px",overflow:"hidden",width:"92vw"},children:[e.jsxs("div",{style:{alignItems:"center",borderBottom:"1px solid #f0f0f0",display:"flex",flexWrap:"wrap",gap:8,justifyContent:"space-between",padding:"10px 14px"},children:[e.jsx("span",{style:{fontWeight:600},children:r("meta2d.editor.title")}),e.jsxs("div",{style:{alignItems:"center",display:"flex",flexWrap:"wrap",gap:8},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.jsx("button",{onClick:()=>h(o=>o.undo()),style:E,title:`${r("meta2d.editor.undo")} (Ctrl+Z)`,type:"button",children:r("meta2d.editor.undo")}),e.jsx("button",{onClick:()=>h(o=>o.redo()),style:E,title:`${r("meta2d.editor.redo")} (Ctrl+Y)`,type:"button",children:r("meta2d.editor.redo")}),e.jsx("button",{onClick:()=>h(o=>o.delete()),style:E,title:r("meta2d.editor.delete"),type:"button",children:r("meta2d.editor.delete")}),e.jsx("button",{onClick:()=>h(o=>o.fitView(!0)),style:E,title:r("meta2d.editor.fit"),type:"button",children:r("meta2d.editor.fit")}),e.jsx("button",{onClick:()=>h(o=>{o.scale(1),o.centerView()}),style:E,title:r("meta2d.editor.zoom100"),type:"button",children:r("meta2d.editor.zoom100")})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:t,style:L,type:"button",children:r("meta2d.editor.close")}),e.jsx("button",{disabled:B,onClick:()=>void C(),style:{...L,background:"#1677ff",border:"none",color:"#fff"},type:"button",children:r(B?"meta2d.editor.saving":"meta2d.editor.save")})]})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsx(ne,{engineRef:a}),e.jsx("div",{ref:u,style:{flex:1,minHeight:0,minWidth:0}}),e.jsx(ie,{engine:p})]})]})})}export{me as DiagramEditor};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{r as i,j as n}from"./react-vendor-BJFXgntS.js";import{B as fe}from"./ui-TwLH91RV.js";import{c as K,g as Ie,u as Se,a as he,d as Oe,b as ze,f as He,e as pe,h as Fe,P as Ue,D as We,F as qe,l as ye,i as Ve,S as $e,M as Ye,j as Je,r as Ge,k as Ke,m as J,n as Xe,o as Qe,p as ge}from"./index-Ct5Vt4tz.js";import{z as Ze,A as et,m as ie,n as tt,o as nt,p as at,r as it,s as ot,t as st,v as rt,x as ct,B as lt,R as dt,a as ut,b as xe,c as mt,d as ft,e as ht,f as yt,g as gt,h as xt,i as vt,w as oe,j as bt,O as kt,E as It,q as St,l as Ct,C as wt,D as jt}from"./react-6CQL39Gs.js";import{H as Mt,a as Et,b as Rt,M as Dt,T as Nt,S as At,W as Pt,N as Tt,o as Lt,c as ve}from"./Toolbar-BaKuyXey.js";import{V as Bt}from"./VisitorPickerModal-DPyg6mIt.js";import"./motion-Bz_inm1R.js";import"./editor-ONzd_YnO.js";import"./diagram-BLCqfrbF.js";import"./plus-B-uEAM2g.js";import"./copy-UkvgEfIg.js";/**
|
|
2
|
+
* @license lucide-react v0.562.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const _t=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ot=K("refresh-cw",_t);/**
|
|
7
|
+
* @license lucide-react v0.562.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const zt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M6.376 18.91a6 6 0 0 1 11.249.003",key:"hnjrf2"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}]],Ht=K("shield-user",zt);/**
|
|
12
|
+
* @license lucide-react v0.562.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const pt=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Ft=K("text-align-justify",pt);/**
|
|
17
|
+
* @license lucide-react v0.562.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Ut=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Wt=K("users",Ut),qt=48;function G(e){try{const a=e.getDocument("markdown");return typeof a=="string"?a:""}catch{return null}}function Vt(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}function $t({editor:e,documentId:a,displayName:s,debounceMs:v=1e3,enabled:f=!0,localBaseCommitIdAtEditStart:N,snapshotMeta:_}){const[X,T]=i.useState(!1),[A,C]=i.useState(!1),[O,M]=i.useState(null),u=i.useRef(null),h=i.useRef(null),b=i.useRef(!1),k=i.useRef(""),x=i.useRef(!1),w=i.useRef(a),W=i.useRef(s),q=i.useRef(N),z=i.useRef(_);w.current=a,W.current=s,q.current=N,z.current=_;const j=i.useCallback(async()=>{if(!e)return;if(!k.current){console.log("[useAutoSave] performSave blocked: lastContentRef is empty");return}const l=Vt(e);l!=null&&(console.log("[useAutoSave] performSave saving draft, documentId:",w.current,"content preview:",l.slice(0,80)),await Ie(w.current).execute(()=>Se({documentId:w.current,content:l,displayName:W.current,localBaseCommitIdAtEditStart:q.current,snapshotMeta:z.current})),k.current=G(e)??k.current,C(!0),T(!1),M(Date.now()),b.current=!0,x.current=!1)},[e]);i.useEffect(()=>{let l=!1;return he(a).then(d=>{l||(d?(C(!0),M(d.updatedAt),b.current=!0):(C(!1),M(null),b.current=!1,x.current=!1))}),()=>{l=!0}},[a]),i.useEffect(()=>{var $,p;if(!f){($=h.current)==null||$.call(h),h.current=null;return}if(!e)return;const l=e.getLexicalEditor();if(!l)return;(p=h.current)==null||p.call(h);let d=!1,S=0,L=0;const H=()=>{if(d)return;const y=G(e);if(y===null){if(L+=1,L>qt)return;S=requestAnimationFrame(H);return}k.current=y;const c=l.registerUpdateListener(()=>{const P=G(e);P!==null&&P!==k.current&&(console.log("[useAutoSave] updateListener dirty, documentId:",a,"oldLen:",k.current.length,"newLen:",P.length),k.current=P,T(!0),x.current=!0,b.current=!1,u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null,j()},v))});h.current=()=>{c(),u.current&&(clearTimeout(u.current),u.current=null)}};return queueMicrotask(()=>{d||(S=requestAnimationFrame(H))}),()=>{var y;d=!0,cancelAnimationFrame(S),(y=h.current)==null||y.call(h)}},[f,e,a,s,v,N,_,j]),i.useEffect(()=>{var S;if(!f||!e)return;const l=(S=e.getLexicalEditor())==null?void 0:S.getRootElement();if(!l)return;const d=()=>{u.current&&(clearTimeout(u.current),u.current=null),x.current&&j()};return l.addEventListener("blur",d),()=>l.removeEventListener("blur",d)},[f,e,j]),i.useEffect(()=>{if(!f)return;const l=()=>{document.visibilityState==="hidden"&&(u.current&&(clearTimeout(u.current),u.current=null),x.current&&j())},d=()=>{x.current&&(u.current&&(clearTimeout(u.current),u.current=null),j())};return document.addEventListener("visibilitychange",l),window.addEventListener("beforeunload",d),()=>{document.removeEventListener("visibilitychange",l),window.removeEventListener("beforeunload",d)}},[f,j]);async function E(){await Oe(a),C(!1),T(!1),x.current=!1,b.current=!1,k.current=""}async function V(){const l=await he(a);return l?l.content:null}function I(){C(!0),T(!1),x.current=!1,M(Date.now()),b.current=!0,e&&(k.current=G(e)??"")}return{isDirty:X,draftExists:A,lastSavedAt:O,clearDraft:E,loadDraftContent:V,markDraftSaved:I}}function Yt({isDirty:e,draftExists:a}){const s=e&&!a;i.useEffect(()=>{if(!s)return;const v=f=>{f.preventDefault()};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[s])}function se(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}const be='{"root":{"direction":"ltr","format":"","indent":0,"version":1,"type":"root","children":[{"direction":"ltr","format":"","indent":0,"version":1,"textFormat":0,"textStyle":"","children":[],"type":"paragraph"}]}}';function ke(e){const s=(e instanceof Error?e.message:String(e)).trim();return/^File too large$/i.test(s)?"文件过大(单文件上限 55MB)":/^unsupported file type$/i.test(s)?"不支持的文件类型":/^not an image$/i.test(s)?"不是有效的图片文件":s||"上传失败"}function Jt(e,a){if(!e)return a==="json"?be:e;if(a!=="json")return e;try{const s=JSON.parse(e);if(s!=null&&s.root&&Array.isArray(s.root.children)&&s.root.children.length===0)return be}catch{}return e}function Gt({editor:e}){const{visible:a}=wt();return n.jsx("div",{className:"mdocs-outline-siderail",style:{flexShrink:0,overflow:"hidden",transition:"width 0.2s ease",width:a?200:0},children:n.jsx("div",{style:{width:200},children:n.jsx(jt,{editor:e})})})}function cn(e){const{t:a,lang:s}=ze(),[v,f]=i.useState(!1),N=i.useRef(null),[_,X]=i.useState([]),[T,A]=i.useState(!1),[C,O]=i.useState(e.meta.permission),[M,u]=i.useState(!1),[h,b]=i.useState(!1),[k,x]=i.useState(!1),[w,W]=i.useState(new Map),[q,z]=i.useState(!1);i.useEffect(()=>{const t=o=>{N.current&&!N.current.contains(o.target)&&f(!1)};return v&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[v]),i.useEffect(()=>{let t=!0;return He().then(o=>{t&&X(o)}).catch(()=>{}),()=>{t=!1}},[]);function j(t){const o=_.find(r=>r.visitorId===t);return(o==null?void 0:o.visitorName)??t.slice(0,8)}const[E,V]=i.useState(e.initialDisplayName),[I,l]=i.useState(!1),[d,S]=i.useState(!1),[L,H]=i.useState(!1),[$,p]=i.useState(()=>localStorage.getItem("mdocs.autoEdit")!=="false"),y=e.canEdit&&$,[c,P]=i.useState(null),[Ce,re]=i.useState(!1),Q=i.useRef(null);i.useLayoutEffect(()=>{re(!1),P(null),Q.current=null},[e.meta.documentId]),i.useEffect(()=>{const t=requestAnimationFrame(()=>re(!0));return()=>cancelAnimationFrame(t)},[e.meta.documentId]);const R=i.useMemo(()=>{var t;if(!e.initialContent)return"json";try{const o=JSON.parse(e.initialContent);return Array.isArray((t=o==null?void 0:o.root)==null?void 0:t.children)?"json":"markdown"}catch{return"markdown"}},[e.initialContent,e.contentRevision]),F=i.useMemo(()=>Jt(e.initialContent||"",R),[e.initialContent,R,e.contentRevision]),{isDirty:ce,draftExists:U,markDraftSaved:we}=$t({editor:c,documentId:e.meta.documentId,displayName:E,enabled:e.canEdit,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}});i.useEffect(()=>{var t;(t=e.onDraftExistsChange)==null||t.call(e,U)},[U,e.onDraftExistsChange]),Yt({isDirty:ce,draftExists:U}),i.useEffect(()=>{if(c)try{c.setDocument(R,F)}catch{}},[c,e.meta.documentId,e.contentRevision,F,R]),i.useEffect(()=>{c==null||c.setLocale(s==="zh"?Ze:et)},[c,s]),i.useEffect(()=>{V(e.initialDisplayName)},[e.initialDisplayName,e.meta.documentId,e.contentRevision]),i.useEffect(()=>{O(e.meta.permission)},[e.meta.permission,e.meta.documentId]),i.useEffect(()=>{let t=!0;return(async()=>{try{const o=await pe(e.meta.documentId);t&&S(o.bookmarked)}catch{}})(),()=>{t=!1}},[e.meta.documentId]);async function le(){var t,o;if(!L){H(!0);try{d?(await Ge(e.meta.documentId),S(!1),(t=e.onShowToast)==null||t.call(e,a("bookmarkRemoved"))):(await Ke(e.meta.documentId),S(!0),(o=e.onShowToast)==null||o.call(e,a("bookmarkAdded")))}finally{H(!1)}}}i.useEffect(()=>(e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=Pe),()=>{e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=void 0)})),i.useEffect(()=>{if(e.exportMarkdownRef)return e.exportMarkdownRef.current=()=>{const t=Q.current;if(!t)return"";try{const o=t.getDocument("markdown");return typeof o=="string"?o:String(o??"")}catch{return""}},()=>{e.exportMarkdownRef&&(e.exportMarkdownRef.current=void 0)}});function je(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const Me=i.useCallback(t=>{Q.current=t,P(t);const o=F;if(!o)return;const r=()=>{try{t.setDocument(R,o)}catch{requestAnimationFrame(()=>{try{t.setDocument(R,o)}catch{}})}};queueMicrotask(()=>{queueMicrotask(r)})},[R,F]);async function Z(){if(!(!c||!e.canEdit)){l(!0);try{const t=se(c);if(!t)return;await e.onPublish(t,E,e.meta.documentId)}catch(t){throw t}finally{l(!1)}}}async function Ee(){if(!e.canEdit)return;const t=e.initialDisplayName.trim();if(E.trim()!==t)try{await Z()}catch{}}const D=i.useMemo(()=>e.domains.find(t=>t.domainId===e.meta.domainId),[e.domains,e.meta.domainId]),Re=i.useMemo(()=>{const t=(D==null?void 0:D.permission)??"public";return Fe(t)},[D==null?void 0:D.permission]);function De(t){return t===J.PRIVATE?a("permissionPrivate"):t===J.DOMAIN_READ?a("permissionInvite"):t===J.DOMAIN_WRITE?a("permissionDomainWrite"):t===J.PUBLIC_READ?a("permissionPublicRead"):a("permissionPublicEdit")}async function Ne(){var t;if(M||C===e.meta.permission){A(!1);return}u(!0);try{const r=(c?se(c):null)??e.initialContent;await e.onPublish(r,E,e.meta.documentId,C),A(!1),(t=e.onShowToast)==null||t.call(e,a("docInfoPermissionUpdated"))}finally{u(!1)}}async function Ae(t){var o;if(!q){z(!0);try{const r=new Set(t.map(g=>g.visitorId)),ne=new Map(t.map(g=>[g.visitorId,g.permission]));for(const[g]of w)r.has(g)||await Xe(e.meta.documentId,g);for(const{visitorId:g,permission:ae}of t){const me=w.get(g);(!me||me!==ae)&&await Qe(e.meta.documentId,g,ae)}b(!1),(o=e.onShowToast)==null||o.call(e,a("docInfoInviteSuccess",{count:t.length}))}finally{z(!1)}}}async function Pe(){if(!c||!e.canEdit)return;if(!ce){console.log("[DocumentEditor.saveDraft] skipped: not dirty, documentId:",e.meta.documentId);return}const t=se(c);t&&(console.log("[DocumentEditor.saveDraft] saving draft, documentId:",e.meta.documentId,"content preview:",t.slice(0,80)),we(),await Ie(e.meta.documentId).execute(()=>Se({documentId:e.meta.documentId,content:t,displayName:E,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}})))}const Te=i.useMemo(()=>[{icon:Mt,key:"h1",label:"Heading 1",onSelect:t=>{t.dispatchCommand(ie,{tag:"h1"})}},{icon:Et,key:"h2",label:"Heading 2",onSelect:t=>{t.dispatchCommand(ie,{tag:"h2"})}},{icon:Rt,key:"h3",label:"Heading 3",onSelect:t=>{t.dispatchCommand(ie,{tag:"h3"})}},{type:"divider"},{icon:Dt,key:"hr",label:"Hr",onSelect:t=>{t.dispatchCommand(tt,{})}},{icon:Nt,key:"table",label:"Table",onSelect:t=>{t.dispatchCommand(nt,{columns:"3",rows:"3"})}},{icon:At,key:"tex",label:"TeX",onSelect:t=>{t.dispatchCommand(at,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>t.focus())}},{type:"divider"},{key:"file",label:"File",onSelect:t=>{Lt(o=>{for(const r of o)t.dispatchCommand(St,{file:r})})}},{key:"insert-link",label:"Insert Link",onSelect:t=>{t.dispatchCommand(it,{url:"https://example.com"}),queueMicrotask(()=>t.focus())}},{key:"insert-codeInline",label:"Inline Code",onSelect:t=>{t.dispatchCommand(ot,void 0),queueMicrotask(()=>t.focus())}},{key:"insert-codeBlock",label:"Code Block",onSelect:t=>{t.dispatchCommand(st,void 0),queueMicrotask(()=>t.focus())}},{icon:Pt,key:"meta2d",label:"Meta2d",onSelect:t=>{t.dispatchCommand(rt,void 0),queueMicrotask(()=>t.focus())}},{icon:Tt,key:"markmap",label:"Markmap",onSelect:t=>{t.dispatchCommand(ct,void 0),queueMicrotask(()=>t.focus())}}].map(t=>"type"in t&&t.type==="divider"?t:{...t,extra:n.jsx("span",{style:{color:"var(--mdocs-text-muted)",fontFamily:"monospace",fontSize:12},children:t.key})}),[]),Le=i.useMemo(()=>[lt,dt,ut,xe,mt,ft,ht,yt,gt,xt,vt,oe(bt,{children:c?n.jsx(ve,{editor:c,floating:!0,outlineCollapseTitle:a("outlineHide"),outlineExpandTitle:a("outlineShow"),outlineToggle:!0}):null}),oe(Ct,{handleUpload:async t=>{var o;try{return{url:await ge(t,e.meta.documentId)}}catch(r){throw(o=e.onShowError)==null||o.call(e,ke(r)),r}}}),oe(xe,{defaultBlockImage:!0,needRehost:t=>t.startsWith("blob:"),handleRehost:async t=>{var o;try{const ne=await(await fetch(t)).blob(),g=new File([ne],"image.png",{type:ne.type});return{url:await ge(g,e.meta.documentId)}}catch(r){throw(o=e.onShowError)==null||o.call(e,ke(r)),r}}})],[c,a,e.meta.documentId,e.onShowError]),m=!!e.readerChrome,[B,ee]=i.useState(!1),Y=i.useRef(null),[de,te]=i.useState(0);i.useEffect(()=>{if(!m){ee(!1),te(0);return}if(B)return;const t=window.setTimeout(()=>ee(!0),2800);return()=>window.clearTimeout(t)},[m,B,e.meta.documentId]);function Be(t){!m||B||t.target.closest("button, a, input, textarea, select")||(Y.current={startY:t.clientY,dragging:!0},t.currentTarget.setPointerCapture(t.pointerId))}function _e(t){const o=Y.current;if(!(o!=null&&o.dragging))return;const r=t.clientY-o.startY;te(Math.max(-72,Math.min(0,r)))}function ue(t){const o=Y.current;if(!(o!=null&&o.dragging))return;Y.current=null;const r=t.clientY-o.startY;te(0),r<-36&&ee(!0);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}return n.jsxs("div",{className:"mdocs-editor"+(m?" mdocs-editor--reader":"")+(m&&B?" mdocs-editor--reader-docked":""),children:[n.jsxs("div",{className:"mdocs-editor-toolbar"+(m?B?" mdocs-editor-toolbar--docked":" mdocs-editor-toolbar--float":""),style:m&&!B&&de!==0?{transform:`translate(-50%, ${de}px)`}:void 0,onPointerDown:Be,onPointerMove:_e,onPointerUp:ue,onPointerCancel:ue,children:[m?n.jsx("button",{type:"button",className:"mdocs-reader-nav-btn",onClick:()=>{var t;return(t=e.onOpenMobileNav)==null?void 0:t.call(e)},"aria-label":a("expandSidebar"),children:n.jsx(Ue,{size:18,strokeWidth:1.75})}):null,n.jsx("input",{className:"mdocs-editor-title-input",value:E,onChange:t=>V(t.target.value),onBlur:()=>void Ee(),placeholder:a("displayNamePlaceholder"),disabled:!y,readOnly:m&&!y}),m?null:n.jsx(We,{domains:e.domains.length?e.domains:[qe],value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:a("currentDomainAria"),localizeName:t=>ye(t,s,a)}),!m&&e.onAiWrite?n.jsxs("button",{type:"button",className:"secondary",onClick:()=>{var t;return(t=e.onAiWrite)==null?void 0:t.call(e)},style:{padding:"4px 10px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",gap:6},children:[n.jsx("img",{src:Ve,alt:"",width:16,height:16,style:{display:"block"}}),"帮写"]}):null,n.jsxs("button",{type:"button",className:"secondary mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>void le(),disabled:L,"data-tooltip":d?"取消收藏":"收藏",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,opacity:L?.5:1},children:[n.jsx($e,{size:18,strokeWidth:1.5,style:{color:d?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:d?"#faad14":"none"}}),!m&&d?n.jsx("span",{children:"已收藏"}):null]}),m?null:n.jsx("span",{className:"mdocs-editor-toolbar-spacer","aria-hidden":!0}),n.jsxs("div",{className:"mdocs-editor-toolbar-actions",children:[!m&&e.onSyncClick?n.jsxs("button",{type:"button",className:"mdocs-sync-btn mdocs-tooltip mdocs-tooltip-bottom"+(e.syncBehind?" behind":""),"data-tooltip":e.syncBehind?a("syncBehindHint"):a("syncPull"),onClick:()=>{var t;return void((t=e.onSyncClick)==null?void 0:t.call(e))},style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx(Ot,{size:16,strokeWidth:1.5}),n.jsx("span",{children:a("syncPull")})]}):null,m&&e.canEdit?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"primary mdocs-reader-action-btn",disabled:I,onClick:()=>{y||p(!0),Z().catch(()=>{})},children:a(I?"publishing":"publish")}),n.jsx("button",{type:"button",className:"danger mdocs-reader-action-btn",disabled:I,onClick:()=>void e.onDelete(),children:a("delete")})]}):null,!m&&y?n.jsxs(n.Fragment,{children:[localStorage.getItem("mdocs.autoPublish")!=="true"&&n.jsxs("span",{className:"mdocs-save-indicator",children:[n.jsx("span",{className:"mdocs-save-dot "+(I?"saving":U?"unsaved":"saved")}),n.jsx("span",{children:a(I?"publishing":U?"unsaved":"published")})]}),n.jsx("button",{type:"button",className:"primary",disabled:I,onClick:()=>{Z().catch(()=>{})},children:a(I?"publishing":"publish")}),n.jsx("button",{type:"button",className:"danger",disabled:I,onClick:e.onDelete,children:a("delete")})]}):null,!m&&!y&&e.canEdit?n.jsx("button",{type:"button",className:"primary",onClick:()=>p(!0),children:a("edit")}):null,n.jsxs("button",{type:"button",className:"secondary mdocs-tooltip mdocs-tooltip-bottom",onClick:e.onToggleComments,"data-tooltip":"评论",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,background:e.commentPanelOpen?"var(--mdocs-hover-bg, #f0f0f0)":void 0},children:[n.jsx(Ye,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}}),!m&&e.commentCount>0?n.jsx("span",{style:{fontSize:"0.85rem"},children:e.commentCount}):null]}),n.jsxs("div",{ref:N,className:"mdocs-tooltip mdocs-tooltip-bottom","data-tooltip":a("docInfo"),style:{position:"relative"},children:[n.jsx("button",{type:"button",className:"secondary",onClick:()=>f(!v),style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(Ft,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}})}),v&&n.jsxs("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"var(--mdocs-surface, #fff)",border:"1px solid var(--mdocs-border, #e5e5e5)",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)",minWidth:"220px",zIndex:100,padding:"8px 0"},children:[n.jsxs("div",{style:{padding:"4px 16px",fontSize:"13px"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoCreator")}),n.jsx("span",{children:j(e.meta.ownerVisitorId)})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoCreatedAt")}),n.jsx("span",{children:new Date(e.meta.createdAt).toLocaleString(s==="zh"?"zh-CN":"en-US")})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoSize")}),n.jsx("span",{children:je(new Blob([e.initialContent]).size)})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoUpdatedAt")}),n.jsx("span",{children:new Date(e.meta.updatedAt).toLocaleString(s==="zh"?"zh-CN":"en-US")})]})]}),n.jsx("div",{style:{height:"1px",background:"var(--mdocs-border, #e5e5e5)",margin:"8px 0"}}),n.jsxs("button",{type:"button",style:{width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:t=>{t.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:t=>{t.currentTarget.style.background="none"},onClick:()=>{le()},children:[n.jsx("span",{children:d?"⭐":"☆"}),n.jsx("span",{children:a(d?"bookmarkRemove":"bookmarkAdd")})]}),e.canManageInvites&&n.jsxs("button",{type:"button",style:{width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:t=>{t.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:t=>{t.currentTarget.style.background="none"},onClick:()=>{f(!1),(async()=>{x(!0);try{const t=await Je(e.meta.documentId),o=new Map(t.map(r=>[r.visitorId,r.permission]));W(o),b(!0)}finally{x(!1)}})()},children:[n.jsx(Wt,{size:14}),n.jsx("span",{children:a("docInfoInviteMember")})]}),n.jsxs("button",{type:"button",style:{width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:t=>{t.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:t=>{t.currentTarget.style.background="none"},onClick:()=>{f(!1),O(e.meta.permission),A(!0)},children:[n.jsx(Ht,{size:14}),n.jsx("span",{children:a("docInfoChangePermission")})]})]})]})]})]}),T&&n.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:t=>{t.target===t.currentTarget&&A(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480},children:[n.jsx("h1",{style:{fontSize:"1.1rem",marginBottom:12},children:a("docInfoChangePermission")}),n.jsxs("div",{className:"muted",style:{marginBottom:12},children:[a("domainPermission"),":",D?ye(D.domainName,s,a):e.meta.domainId]}),n.jsx("div",{style:{display:"grid",gap:8},children:Re.map(t=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[n.jsx("input",{type:"radio",name:"doc-permission",value:t,checked:C===t,onChange:()=>O(t)}),n.jsx("span",{children:De(t)})]},t))}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[n.jsx("button",{type:"button",onClick:()=>A(!1),children:a("cancel")}),n.jsx("button",{type:"button",className:"primary",disabled:M,onClick:()=>void Ne(),children:a(M?"publishing":"saveAndPublish")})]})]})}),e.canManageInvites&&n.jsx(Bt,{open:h,title:a("docInfoInviteMember"),initialSelectedIds:[...w.keys()],initialPermissions:w,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:a("invitePermissionRead")},{value:"edit",label:a("invitePermissionEdit")}],onClose:()=>b(!1),onConfirm:t=>{Ae(t)}}),n.jsx(kt,{children:n.jsx(fe,{flex:1,style:{minHeight:0},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[y&&c&&!m?n.jsx(ve,{editor:c,outlineCollapseTitle:a("outlineHide"),outlineExpandTitle:a("outlineShow"),outlineToggle:!0}):null,n.jsx("div",{className:"mdocs-editor-content-area",style:{flex:1,display:"flex",minHeight:0},children:n.jsxs(fe,{variant:"outlined",horizontal:!0,style:{background:"var(--mdocs-surface)",flex:1,minHeight:0,minWidth:0,borderRadius:0,outline:"none"},children:[n.jsx("div",{className:"mdocs-editor-scroll-host",children:Ce?n.jsx(It,{content:F,type:R,confirmPasteMarkdown:!0,editable:y,onInit:Me,plugins:Le,lineEmptyPlaceholder:a("displayNamePlaceholder"),placeholder:a("displayNamePlaceholder"),slashOption:{items:Te},className:"mdocs-document-editor-root"},e.meta.documentId):null}),c&&n.jsx(Gt,{editor:c})]})})]})})})]})}export{cn as DocumentEditor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as E,j as W}from"./react-vendor-
|
|
1
|
+
import{r as E,j as W}from"./react-vendor-BJFXgntS.js";import{b as io,as as js,at as sa,au as ra,av as oa}from"./index-Ct5Vt4tz.js";import{E as la,B as aa}from"./react-6CQL39Gs.js";import"./ui-TwLH91RV.js";import"./motion-Bz_inm1R.js";import"./editor-ONzd_YnO.js";import"./diagram-BLCqfrbF.js";import"./plus-B-uEAM2g.js";import"./copy-UkvgEfIg.js";function hn({lexicalJson:s,onMarkdown:e,onError:t}){const[i,n]=E.useState(null),r=E.useRef(!1);return E.useEffect(()=>{r.current=!1},[s]),E.useEffect(()=>{if(!(!i||r.current))try{i.setDocument("json",s);const o=i.getDocument("markdown");typeof o=="string"&&(r.current=!0,e(o))}catch{t==null||t()}},[i,s,e,t]),W.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:W.jsx(la,{content:s,type:"json",editable:!1,onInit:n,plugins:[aa]})})}let Ln=[],no=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?no:Ln).push(t=t+s[e])})();function ha(s){if(s<768)return!1;for(let e=0,t=Ln.length;;){let i=e+t>>1;if(s<Ln[i])t=i;else if(s>=no[i])e=i+1;else return!0;if(e==t)return!1}}function Ks(s){return s>=127462&&s<=127487}const qs=8205;function ca(s,e,t=!0,i=!0){return(t?so:fa)(s,e,i)}function so(s,e,t){if(e==s.length)return e;e&&ro(s.charCodeAt(e))&&oo(s.charCodeAt(e-1))&&e--;let i=cn(s,e);for(e+=$s(i);e<s.length;){let n=cn(s,e);if(i==qs||n==qs||t&&ha(n))e+=$s(n),i=n;else if(Ks(n)){let r=0,o=e-2;for(;o>=0&&Ks(cn(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function fa(s,e,t){for(;e>0;){let i=so(s,e-2,t);if(i<e)return i;e--}return 0}function cn(s,e){let t=s.charCodeAt(e);if(!oo(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ro(i)?(t-55296<<10)+(i-56320)+65536:t}function ro(s){return s>=56320&&s<57344}function oo(s){return s>=55296&&s<56320}function $s(s){return s<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bt(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Pe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bt(this,e,t);let i=[];return this.decompose(e,t,i,0),Pe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new qt(this),r=new qt(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new lo(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ao(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new _(e):Pe.from(_.split(e,[]))}}class _ extends I{constructor(e,t=ua(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new da(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new _(Us(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Mi(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new _(l,o.length+r.length));else{let a=l.length>>1;i.push(new _(l.slice(0,a)),new _(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof _))return super.replace(e,t,i);[e,t]=Bt(this,e,t);let n=Mi(this.text,Mi(i.text,Us(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new _(n,r):Pe.from(_.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){[e,t]=Bt(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new _(i,n)),i=[],n=-1);return n>-1&&t.push(new _(i,n)),t}}class Pe extends I{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=Bt(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Pe(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=Bt(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Pe))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let g of e)g.flatten(d);return new _(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let g;if(d.lines>r&&d instanceof Pe)for(let p of d.children)f(p);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof _&&a&&(g=c[c.length-1])instanceof _&&d.lines+g.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new _(g.text.concat(d.text),g.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Pe.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Pe(l,t)}}I.empty=new _([""],0);function ua(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Mi(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=t&&(a>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function Us(s,e,t){return Mi(s,[""],e,t)}class qt{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof _?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof _?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(n instanceof _){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof _?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class lo{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new qt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class ao{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(I.prototype[Symbol.iterator]=function(){return this.iter()},qt.prototype[Symbol.iterator]=lo.prototype[Symbol.iterator]=ao.prototype[Symbol.iterator]=function(){return this});class da{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Bt(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function le(s,e,t=!0,i=!0){return ca(s,e,t,i)}function ga(s){return s>=56320&&s<57344}function pa(s){return s>=55296&&s<56320}function ma(s,e){let t=s.charCodeAt(e);if(!pa(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ga(i)?(t-55296<<10)+(i-56320)+65536:t}function ya(s){return s<65536?1:2}const En=/\r\n?|\n/;var me=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(me||(me={}));class Ve{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){Rn(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new Ve(e)}composeDesc(e){return this.empty?e:e.empty?this:ho(this,e)}mapDesc(e,t=!1){return e.empty?this:In(this,e,t)}mapPos(e,t=-1,i=me.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>e)return r+(e-n);r+=l}else{if(i!=me.Simple&&h>=e&&(i==me.TrackDel&&n<e&&h>e||i==me.TrackBefore&&n<e||i==me.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ve(e)}static create(e){return new Ve(e)}}class Q extends Ve{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Rn(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return In(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(I.empty);i.push(o?e.slice(r,r+o):I.empty)}r+=o}return new Q(t,i)}compose(e){return this.empty?e:e.empty?this:ho(this,e,!0)}map(e,t=!1){return e.empty?this:In(this,e,t,!0)}iterChanges(e,t=!1){Rn(this,e,t)}get desc(){return Ve.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new Yt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);oe(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;oe(t,c,f),f>0&&Xe(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);oe(t,c,-1),oe(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new Q(t,i),filtered:Ve.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<t&&oe(n,t-o,-1);let f=new Q(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof Q){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=d?typeof d=="string"?I.of(d.split(i||En)):d:I.empty,p=g.length;if(f==u&&p==0)return;f<o&&a(),f>o&&oe(n,f-o,-1),oe(n,u-f,p),Xe(r,n,g),o=u}}return h(e),a(!l),l}static empty(e){return new Q(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(I.empty);i[n]=I.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new Q(t,i)}static createSet(e,t){return new Q(e,t)}}function oe(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function Xe(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(I.empty);s.push(t)}}function Rn(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=I.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,c,f),n=h,r=c}}}function In(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Yt(s),l=new Yt(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);oe(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(oe(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(oe(n,0,o.ins),r&&Xe(r,n,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;oe(n,h,a<o.i?o.ins:0),r&&a<o.i&&Xe(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?Q.createSet(n,r):Ve.create(n);throw new Error("Mismatched change set lengths")}}}function ho(s,e,t=!1){let i=[],n=t?[]:null,r=new Yt(s),o=new Yt(e);for(let l=!1;;){if(r.done&&o.done)return n?Q.createSet(i,n):Ve.create(i);if(r.ins==0)oe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)oe(i,0,o.ins,l),n&&Xe(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;oe(i,a,c,l),n&&c&&Xe(n,i,o.text)}else o.ins==-1?(oe(i,r.off?0:r.len,a,l),n&&Xe(n,i,r.textBit(a))):(oe(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&Xe(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Yt{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?I.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?I.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ct{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ct(i,n,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i){return new ct(e,t,i)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>ct.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,n){return ct.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,t,i,n,r){let o=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=t&&(r=t<e?1:-1),t<e?ct.create(t,e,48|o):ct.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function co(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let bs=0;class M{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=bs++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new M(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:xs),!!e.static,e.enables)}of(e){return new Di([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function xs(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class Di{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=bs++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Pn(f,c)){let d=i(f);if(l?!Gs(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,g=u.config.address[r];if(g!=null){let p=Ri(u,g);if(this.dependencies.every(m=>m instanceof M?u.facet(m)===f.facet(m):m instanceof ze?u.field(m,!1)==f.field(m,!1):!0)||(l?Gs(d=i(f),p,n):n(d=i(f),p)))return f.values[o]=p,0}else d=i(f);return f.values[o]=d,1}}}}function Gs(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function Pn(s,e){let t=!1;for(let i of e)$t(s,i)&1&&(t=!0);return t}function ba(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Ri(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)$t(a,h);return a.values[o]=l(a),1},update(a,h){if(!Pn(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Pn(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&xs(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const hi=M.define({static:!0});class ze{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new ze(bs++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(hi).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(hi),o=n.facet(hi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,hi.of({field:this,create:e})]}get extension(){return this}}const ht={lowest:4,low:3,default:2,high:1,highest:0};function Wt(s){return e=>new uo(e,s)}const fo={highest:Wt(ht.highest),high:Wt(ht.high),default:Wt(ht.default),low:Wt(ht.low),lowest:Wt(ht.lowest)};class uo{constructor(e,t){this.inner=e,this.prec=t}}class Yi{of(e){return new Nn(this,e)}reconfigure(e){return Yi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Nn{constructor(e,t){this.compartment=e,this.inner=t}}class Ei{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of xa(e,t,o))u instanceof ze?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],g=d[0].facet,p=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[g.id]=a.length<<1|1,xs(p,d))a.push(i.facet(g));else{let m=g.combine(d.map(y=>y.value));a.push(i&&g.compare(m,i.facet(g))?i.facet(g):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(y=>m.dynamicSlot(y)));l[g.id]=h.length<<1,h.push(m=>ba(m,g,d))}}let f=h.map(u=>u(l));return new Ei(e,o,f,l,a,r)}}function xa(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Nn&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Nn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof uo)r(o.inner,o.prec);else if(o instanceof ze)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Di)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,ht.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,ht.default),i.reduce((o,l)=>o.concat(l))}function $t(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function Ri(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const go=M.define(),Wn=M.define({combine:s=>s.some(e=>e),static:!0}),po=M.define({combine:s=>s.length?s[0]:void 0,static:!0}),mo=M.define(),yo=M.define(),bo=M.define(),xo=M.define({combine:s=>s.length?s[0]:!1});class nt{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}}class wa{of(e){return new nt(this,e)}}class ka{constructor(e){this.map=e}of(e){return new G(this,e)}}class G{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new G(this.type,t)}is(e){return this.type==e}static define(e={}){return new ka(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}G.reconfigure=G.define();G.appendConfig=G.define();class Z{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&co(i,t.newLength),r.some(l=>l.type==Z.time)||(this.annotations=r.concat(Z.time.of(Date.now())))}static create(e,t,i,n,r,o){return new Z(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Z.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Z.time=nt.define();Z.userEvent=nt.define();Z.addToHistory=nt.define();Z.remote=nt.define();function Sa(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function wo(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=Q.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:G.mapEffects(s.effects,n).concat(G.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function Hn(s,e,t){let i=e.selection,n=Ct(e.annotations);return e.userEvent&&(n=n.concat(Z.userEvent.of(e.userEvent))),{changes:e.changes instanceof Q?e.changes:Q.of(e.changes||[],t,s.facet(po)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:Ct(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function ko(s,e,t){let i=Hn(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=wo(i,Hn(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=Z.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Ca(t?va(n):n)}function va(s){let e=s.startState,t=!0;for(let n of e.facet(mo)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Sa(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=Q.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=Z.create(e,n,s.selection&&s.selection.map(r),G.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(yo);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof Z?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Z?s=r[0]:s=ko(e,Ct(r),!1)}return s}function Ca(s){let e=s.startState,t=e.facet(bo),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=wo(i,Hn(e,r,s.changes.newLength),!0))}return i==s?s:Z.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const Aa=[];function Ct(s){return s==null?Aa:Array.isArray(s)?s:[s]}var Ke=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(Ke||(Ke={}));const Ma=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Fn;try{Fn=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Da(s){if(Fn)return Fn.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Ma.test(t)))return!0}return!1}function Ta(s){return e=>{if(!/\S/.test(e))return Ke.Space;if(Da(e))return Ke.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Ke.Word;return Ke.Other}}class N{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)$t(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return $t(this,i),Ri(this,i)}update(...e){return ko(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(Yi.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(G.reconfigure)?(t=null,i=l.value):l.is(G.appendConfig)&&(t=null,i=Ct(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Ei.resolve(i,n,this),r=new N(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Wn)?e.newSelection:e.newSelection.asSingle();new N(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=Ct(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=G.mapEffects(o,c).concat(G.mapEffects(Ct(a.effects),f))}return{changes:n,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Q?e:Q.of(e,this.doc.length,this.facet(N.lineSeparator))}toText(e){return I.of(e.split(this.facet(N.lineSeparator)||En))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:($t(this,t),Ri(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof ze&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return N.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=Ei.resolve(e.extensions||[],new Map),i=e.doc instanceof I?e.doc:I.of((e.doc||"").split(t.staticFacet(N.lineSeparator)||En)),n=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return co(n,i.length),t.staticFacet(Wn)||(n=n.asSingle()),new N(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(N.tabSize)}get lineBreak(){return this.facet(N.lineSeparator)||`
|