diff --git a/AGENTS.md b/AGENTS.md index bce55ac2..2ecaaafb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,6 +66,17 @@ - `design/old/` 下的历史废弃稿也统一按 `process/` 与 `done/` 分层,但标题继续标记 `[recycle]`。 - `design/90-reference/` 只放参考资料,不参与 `process/done` 状态迁移。 +## Bugs 目录规则 + +- `bugs/` 默认镜像 `design/` 的主线分类方式,按对应大类放置缺陷。 +- 每个大类继续按 `process/` 与 `done/` 分层: + - `process/`:缺陷已确认存在,仍在修复或验证中 + - `done/`:缺陷已修复,且已有真实代码与验证证据 +- 新确认的缺陷先放 `process/`;修复完成后必须移动到同类目的 `done/`,不要在两个目录同时保留同一条缺陷。 +- 缺陷归类以真正 owner 和长期主线为准,不以表面症状命名: + - `sidebar/topbar/breadcrumb/文档页壳/Wolai 体验对齐` 优先归到 `05-editor-mainline/` + - `projection/row model/selection/focus/keyboard/DnD/tree command` 优先归到 `04-tree-domain/` + ## 协作边界 - 仅修改与当前任务直接相关的文件。 @@ -95,6 +106,22 @@ - 影响主页入口、Sidebar、tree shell、文档页首屏时,优先补或复用 `scripts/task*-smoke.js` 这类 smoke 脚本。 - 排查高 CPU / 高内存 / 卡顿时,先看是否存在首屏误走实验性 tree shell、compat fallback、重复请求、轮询或回链面板持续刷新,再看数据底座。 +## mnote-tester 调用 + +- 当前固定网页测试员 profile 为 `mnote-tester`,Hermes profile 路径:`/home/lix/.hermes/profiles/mnote-tester`。 +- 默认优先通过别名调用:`/home/lix/.local/bin/mnote-tester`;等价命令是 `hermes -p mnote-tester`。 +- 需要让后续 agent 调它做真实浏览器测试时,优先使用 one-shot: + - `mnote-tester --yolo -z "<测试任务>"` + - 或 `hermes -p mnote-tester --yolo -z "<测试任务>"` +- 交给 `mnote-tester` 的任务描述必须明确写出: + - 测试目标页面或 URL + - 是否要求真实登录 + - 是否要求新建 / 修改 / 删除页面或块 + - 测试数据前缀,例如 `TEST-HERMES-` + - 是否要求发现 bug 后直接写入 `bugs//process/` +- `mnote-tester` 允许在 `3000` 主页面做最小写入型测试,包括新建、重命名、编辑、移动、归档、恢复、删除页面,以及新建、修改、删除块/模块;但默认只能操作“本轮新建的测试数据”或用户明确指定的测试区域,不能动既有用户内容。 +- `mnote-tester` 的默认证据目录是 `/mnt/Data1T/mnote/tmp/hermes-tester//`;若发现 bug,应按 `/mnt/Data1T/mnote/bugs/README.md` 与本文件规则归类,并把缺陷记录写到对应 `bugs//process/`。 +- 若 `/auth`、快速登录、首屏路由或上游服务本身已阻塞,`mnote-tester` 应立即停止后续写入动作,先输出阻塞证据并按规则记录 blocker bug,不要伪造“新建/修改/删除已验证通过”。 ## Wolai-aline 对标流程 diff --git a/browser-capability-20260512-current-page.png b/browser-capability-20260512-current-page.png new file mode 100644 index 00000000..4c41e085 Binary files /dev/null and b/browser-capability-20260512-current-page.png differ diff --git a/bugs/04-tree-domain/process/4-25-tree-command-create-delete-reload-latency-v1.md b/bugs/04-tree-domain/process/4-25-tree-command-create-delete-reload-latency-v1.md new file mode 100644 index 00000000..4f5c59b0 --- /dev/null +++ b/bugs/04-tree-domain/process/4-25-tree-command-create-delete-reload-latency-v1.md @@ -0,0 +1,117 @@ +# 4-25 [process][bug] 树命令新建/删除后强制刷新导致卡顿 v1 + +> 更新时间:2026-05-13 +> +> 分类归属: +> - `04-tree-domain/process` +> - 关联缺陷:`bugs/05-editor-mainline/process/5-11-mindmap-ghost-assets-and-tree-command-latency-v1.md` +> +> 用户反馈: +> - “删除页面和新建页面都很慢,不知道为什么这么卡。” + +## 1. 问题定义 + +当前页面树/文件树的新建页面、删除页面等命令,在服务端命令成功后仍会触发整页刷新或完整树刷新。用户感知是:新建和删除并不是局部更新,而是卡一下、等整套页面壳或树壳重新加载。 + +这属于 `tree command -> projection update -> UI apply` 链路问题,应归到 `04-tree-domain`,而不是只作为编辑器 UI 问题处理。 + +## 2. 真实现象 + +用户反馈: + +1. 新建页面慢。 +2. 删除页面慢。 +3. 卡顿与同轮 mindmap 文件树重复增长一起出现,怀疑树刷新链路被频繁触发。 + +期望结果: + +1. `tree.node.create` 成功后,树 UI 局部插入新节点并进入重命名/导航状态。 +2. `tree.node.archive` 成功后,树 UI 局部移除节点或移动到回收站 projection。 +3. 只有 delta 无法应用、projection 缺失、SSE 断线或数据不一致时,才进入 resync/reload fallback。 +4. 普通新建/删除不应默认整页 reload。 + +## 3. 证据 + +### 3.1 Rust tree shell 有硬刷新路径 + +`rust/crates/mnote-web/src/routes/tree.rs:2976` 到 `:2986`: + +- `scheduleRefresh()` 在 80ms 后执行 `window.location.reload()`。 +- 如果带 `renameRowId`,则通过 `window.location.assign(url.toString())` 重新加载。 + +调用点: + +- 文件树删除:`rust/crates/mnote-web/src/routes/tree.rs:2791` 到 `:2824` +- 新建页面:`rust/crates/mnote-web/src/routes/tree.rs:4309` 到 `:4340` +- 重命名:`rust/crates/mnote-web/src/routes/tree.rs:4373` 到 `:4406` +- 移动:`rust/crates/mnote-web/src/routes/tree.rs:4448` 到 `:4502` + +这条路径会让 tree shell 命令体验明显慢于纯 delta / reducer 更新。 + +### 3.2 主页面已有 tree live controller,但命令后仍刷新 + +主页面已经监听 tree live: + +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:3881` 到 `:3917` 处理 `tree:snapshot` / `tree:delta` / `tree:resync` +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:3939` 到 `:4050` 启动 `/api/tree/events` EventSource + +也就是说,命令完成后理论上可以由 delta/resync 更新 projection;当前硬 reload 与 live projection 机制重复。 + +### 3.3 命令本身已有 delta hint + +Bridge runtime 对树命令生成 stream delta hint: + +- `tree.node.create`:`rust/crates/bridge-runtime/src/lib.rs:9545` 到 `:9592` +- `tree.node.archive`:`rust/crates/bridge-runtime/src/lib.rs:9655` 到 `:9702` + +当前前端没有把这些结果作为默认局部更新来源,而是在 tree shell 中继续 reload。 + +### 3.4 React Sidebar 路径也存在重刷链 + +子代理只读调查发现 React Sidebar 路径也存在重刷: + +- 新建页面:`wolai-frontend/src/components/sidebar/sidebar.tsx:1799`、`:1847` 附近在 command 后 `await refreshTree()` 再跳转。 +- 删除页面:`wolai-frontend/src/components/sidebar/sidebar.tsx:2148` 附近删除后等待 command、`refreshTree()`、广播文档变化/跳转。 +- Next API 的 `api/tree/commands` create/delete 还会执行 workspace/default scaffold、bridge mutation、artifact 记录等多段流程。 + +这说明卡顿不只来自单个 reload,而是命令后刷新链路偏重。 + +## 4. 当前判断 + +当前慢的核心不是“Convex 一定慢”,而是树命令执行后缺少轻量本地 apply: + +1. 命令 result / delta hint 已经具备局部更新信息。 +2. UI 仍经常走 `refreshTree()`、`window.location.reload()` 或 full snapshot。 +3. `resync_required` 类事件会触发完整 workspace snapshot,结构性变化越多,越容易造成卡顿。 + +## 5. 建议验证 + +修复前先补一条计时 smoke: + +1. 登录真实测试账号。 +2. 新建 `TEST-TREE-LATENCY-` 页面。 +3. 记录 `POST /api/tree/commands` 响应耗时。 +4. 记录下一次 `tree:delta` / `tree:resync` 到达耗时。 +5. 断言过程中是否发生 `window.location.reload()` 或顶层 navigation。 +6. 删除该测试页面,重复同样计时。 +7. 输出新建/删除从点击到 DOM 稳定的总耗时。 + +## 6. 建议修复方向 + +1. `tree.node.create` 成功后直接用 command result 插入本地节点,并只在后台等待 live delta 校准。 +2. `tree.node.archive` 成功后直接从当前 projection 移除节点,并只在后台等待 live delta 校准。 +3. `scheduleRefresh()` 改成显式 fallback,只有 reducer 无法应用时才调用。 +4. React Sidebar 的 `refreshTree()` 应去重、节流,并避免与 SSE/full snapshot 同时触发。 +5. smoke 增加无 reload 断言和耗时阈值。 + +## 7. 流转条件 + +当前状态:`process` + +只有满足以下条件后才能移动到 `bugs/04-tree-domain/done/`: + +1. [ ] 新建页面普通路径不再默认整页 reload。 +2. [ ] 删除页面普通路径不再默认整页 reload。 +3. [ ] command result / tree delta 能局部更新页面树与文件树 projection。 +4. [ ] fallback reload 只在明确异常条件下触发,并有可观测标记。 +5. [ ] smoke 记录新建/删除耗时,并通过无 reload 断言。 diff --git a/bugs/05-editor-mainline/done/5-10-mindmap-filetree-index-single-truth-split-v1.md b/bugs/05-editor-mainline/done/5-10-mindmap-filetree-index-single-truth-split-v1.md new file mode 100644 index 00000000..21fc8149 --- /dev/null +++ b/bugs/05-editor-mainline/done/5-10-mindmap-filetree-index-single-truth-split-v1.md @@ -0,0 +1,154 @@ +# 5-10 [done][bug] 文件树思维导图打开污染 index.md 单一真源 v1 + +> 更新时间:2026-05-13 +> +> 分类归属: +> - `05-editor-mainline/done` +> - 涉及边界:`04-tree-domain/file_tree asset intent`、`03-rust-web/mindmap standalone shell`、`06-mindmap/projection editor` +> +> 关联文档: +> - `/mnt/Data1T/mnote/design/10-review/README.md` +> - `/mnt/Data1T/mnote/design/10-review/02-frontend-editor-tree-review.md` +> - `/mnt/Data1T/mnote/design/10-review/04-secondary-domains-and-design-governance-review.md` +> - `/mnt/Data1T/mnote/design/05-editor-mainline/process/5-5-page-aggregate-single-truth-alignment-v1.md` +> - `/mnt/Data1T/mnote/design/04-tree-domain/done/4-2-sidebar-pagetree-filetree-product-interaction-contract-v1.md` +> - `/mnt/Data1T/mnote/design/06-mindmap/process/6-mindmap-kernel-phase6-projection-editor-v1.md` + +## 1. 问题定义 + +当前文件树中的思维导图文件点击打开后,会进入 standalone `/mindmap/{documentId}/{mindmapId}` 壳。这个壳会构造一份只包含单个 mindmap block 的临时 editor bootstrap,而不是读取该页面真实的 `index.md` / Page Aggregate body。 + +结果是:用户从文件树打开思维导图、编辑、切换页面后,再点击同一页面的 `index.md`,可能看到只剩思维导图默认内容的页面体验。这里的核心问题不是单次保存失败,而是 `index.md` 页面正文与文件树里的 mindmap asset 没有明确收口到同一份页面真源。 + +## 2. 归类理由 + +本问题归到 `05-editor-mainline`,而不是只归到 `06-mindmap`,理由如下: + +- 用户可见故障发生在文档页壳、文件树点击打开、主编辑区内容切换体验上。 +- 受影响对象是 `index.md` 页面正文与主编辑区当前内容,而不只是 mindmap runtime 内部编辑能力。 +- `design/10-review` 已明确当前 Page Aggregate 仍是“主链已切、单一真源收口未完”的状态,本问题正是页面正文、asset view 与 standalone shell 边界未闭合的具体缺陷。 +- `04-tree-domain` 需要定义 filetree asset row 的 open intent,但真正承载用户体验和页面真源一致性的 owner 仍是编辑主线。 + +## 3. 真实现象 + +用户复现结论: + +1. 打开文件树中的思维导图文件,编辑后可以正常保存。 +2. 切换页面后,文件树中的思维导图仍能保存。 +3. 切换页面后点击文件树中的 `index.md`,主编辑区只显示思维导图默认内容,而不是该页面真实正文。 + +用户判断的根因方向: + +1. 之前对文件树中的思维导图文件点击操作会对主页面产生干扰,应取消该干扰。 +2. 思维导图文件的点击打开应该在主编辑区弹出新页面或新 tab,类似 VS Code,而不是污染 `index.md`。 +3. 当前文件树 `index.md` 与其中的思维导图没有只持有一份真源,需要收口成单一来源。 + +## 4. 证据 + +设计审查证据: + +- `design/10-review/README.md` 明确当前最需要收口的是 `Page Aggregate` 单一真源边界、tree realtime/live cache、side effect 一致性,以及 legacy/compat/fallback 退场边界。 +- `design/10-review/02-frontend-editor-tree-review.md` 的 F-01 指出 Page Aggregate 读链已 Rust-first,但客户端仍有本地 aggregate reducer 持有标题、正文、设置、子树快照等临时真相,页面域单一真源尚未闭环。 +- `design/10-review/04-secondary-domains-and-design-governance-review.md` 的 Mindmap 段落指出 standalone mindmap shell 已存在,但 compat 数据层仍承载导图数据,不应被描述为长期 canonical truth。 + +代码锚点: + +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:1100` 定义 `buildMindmapOpenPath(documentId, assetId)`,直接生成 `/mindmap/{documentId}/{assetId}`。 +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:1128` 到 `:1134` 的 `openConvexAssetFromFileTree` 在识别到 mindmap asset 后直接 `window.location.assign(buildMindmapOpenPath(documentId, assetId))`。 +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:1180` 到 `:1182` 将 `tree.asset.open` 统一交给 `openConvexAssetFromFileTree`。 +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:3551` 到 `:3555` 文件树点击 `index/document/markdown` 时导航到文档页,但非文档 row 且有 `assetId` 时 dispatch `tree.asset.open`,mindmap asset 因而进入 standalone mindmap 路由。 +- `rust/crates/mnote-web/src/routes/mindmap_shell.rs:75` 到 `:104` standalone mindmap shell 构造临时 `editor_bootstrap.content`,内容只有一个 `mnoteBlockType: "mindmap"` 的 paragraph block。 +- `rust/crates/mnote-web/src/routes/mindmap_shell.rs:105` 到 `:123` standalone contract 标记为 `mnote.mindmap_shell.v1`,projection source 仍是 `compat-blob`。 +- `wolai-frontend/src/components/sidebar/sidebar-navigation.ts:21` 到 `:33` 的 React 侧 `buildSidebarMindmapOpenTarget` 在 `main` 模式下返回 `/documents/{documentId}`,只有 `sidebar` 模式才打开 `/mindmap/{documentId}/{mindmapId}`;这说明至少已有一条路径表达了“主编辑区不应直接进入 standalone mindmap shell”的倾向。 + +## 5. 当前判断 + +当前更像是三条路径混在一起: + +1. `index.md` 应代表页面正文,并由 Page Aggregate body / page command 持有。 +2. 文件树中的 mindmap asset 应代表页面内某个 mindmap block 关联的资源视图或编辑入口。 +3. standalone `/mindmap/{doc}/{mindmap}` 是过渡兼容壳,应作为独立编辑页或调试/弹出入口,不应替代主编辑区的 `index.md` 真源。 + +因此,即使 mindmap asset 自己可以保存,也不能说明 `index.md` 与 mindmap block 已经同源。当前故障的关键是:打开 asset 的动作把用户带进了会伪造临时正文的 shell,导致页面主编辑体验看起来像 `index.md` 被替换成默认 mindmap。 + +## 6. 建议修复方向 + +### 阶段一:立即止血 + +1. 取消文件树 mindmap asset 点击直接 `window.location.assign('/mindmap/{doc}/{asset}')` 的主路径行为。 +2. 点击 `index.md` 必须始终打开真实 `/documents/{documentId}?treeView=filetree`,并读取真实 Page Aggregate body。 +3. mindmap asset 点击只能发出明确的 asset-open intent,不应改写当前页面正文、不应伪造 `index.md` 内容、不应让主编辑区误认为当前正文就是 standalone bootstrap。 +4. 保留 `/mindmap/{doc}/{asset}` 作为显式独立页面入口时,应只用于新窗口、新 tab、调试入口或明确的 asset editor,不作为普通文件树主点击默认行为。 + +### 阶段二:主编辑区 asset tab + +建议把文件树里的 mindmap asset 打开为主编辑区内的 asset tab / preview,而不是替换 `index.md`: + +- 标签形态类似 `index.md | mindmap.json`。 +- `index.md` tab 只显示真实页面正文。 +- `mindmap.json` 或 mindmap asset tab 使用 `{ documentId, mindmapId }` 加载 mindmap projection。 +- asset tab 保存只写 mindmap command / projection 对应资源,不创建第二份页面正文。 +- 关闭 asset tab 后回到 `index.md`,正文内容应保持不变。 + +### 阶段三:Page Aggregate 与 block-asset 单一真源 + +长期应把 mindmap asset 与页面正文 block 关系收口到 Page Aggregate / kernel projection: + +1. 页面正文中的 mindmap block attrs 持有稳定 `mindmapId`。 +2. 文件树 mindmap asset row 来自同一份 page aggregate/resource projection,而不是另起一套对象真相。 +3. mindmap asset 的删除、恢复、移动、重命名应同步维护 page body block 与 resource projection 的关系。 +4. standalone shell 如果继续存在,也必须声明自己是 asset editor,不再构造会被误认为 `index.md` 的页面正文 bootstrap。 + +## 7. 建议 smoke 验证 + +修复完成后至少补一条文件树 mindmap 回归 smoke: + +1. 登录真实测试账号。 +2. 新建测试页面,插入或生成一个 mindmap block,记录 `documentId` 与 `mindmapId`。 +3. 从文件树点击该页面下的 mindmap asset。 +4. 断言主编辑区没有导航到会污染 `index.md` 的 standalone bootstrap;如果打开 asset tab,则 tab 标识与 `index.md` 分离。 +5. 在 mindmap 中输入一段较长中文内容并保存。 +6. 切换到其它页面,再从文件树点击原页面 `index.md`。 +7. 断言 `index.md` 仍显示真实页面正文,且页面内 mindmap block 仍引用同一个 `mindmapId`。 +8. 再打开 mindmap asset,断言刚才输入的长中文内容仍存在。 + +需要保留一条负向断言: + +- 普通文件树主点击 mindmap asset 不应触发 `window.location.assign('/mindmap/{doc}/{asset}')` 并替换当前文档页正文。 + +## 8. 修复证据 + +本问题已按 `4-24` 与 `5-12` 收口: + +- `rust/crates/core-protocol/src/kernel.rs` 增加 `KernelObjectIdentity` / `KernelBlockAssetRelation`。 +- `rust/crates/bridge-runtime/src/lib.rs` 的 file tree projection 为 `index.md`、mindmap、OnlyOffice、代码附件、普通附件输出不同 `resourceMeta.objectIdentity`。 +- `rust/crates/mnote-web/src/tree_shell/filetree_renderer.rs`、`rust/crates/mnote-web/src/routes/tree.rs`、`rust/crates/mnote-web/src/ssr/pages/layout.rs` 将 `objectIdentity` 下发到文件树 DOM 与 `tree.asset.open` intent。 +- `/mindmap/{documentId}/{mindmapId}` 由 `rust/crates/mnote-web/src/ssr/pages/mindmap.rs` 明确标记为 `data-mnote-object-editor="mindmap"` 与 `data-mnote-object-identity="resource:mindmap:{documentId}:{mindmapId}"`。 +- `rust/crates/mnote-web/src/routes/mindmap_shell.rs` 的 standalone bootstrap 使用 `__mindmap_object__:{documentId}:{mindmapId}`,不复用真实页面正文草稿身份。 + +验证命令: + +```bash +cd /mnt/Data1T/mnote/rust && cargo test -p core-protocol --test resource_tree_contract -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p bridge-runtime file_tree_projection -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web file_tree_projection -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web mindmap -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web documents_save_route_executes_page_body_save_command -- --nocapture +cd /mnt/Data1T/mnote/rust/spikes/leptos-tiptap-spike && cargo test standalone_mindmap_object_uses_isolated_draft_identity -- --nocapture +node scripts/task112-tree-rust-family-regression-smoke.js +node scripts/task169-mindmap-realtime-smoke.js +``` + +`task169` 已覆盖:文件树 mindmap asset 打开、长中文编辑、保存、切页、从文件树回 `index.md`、再次打开 mindmap,且未触发 `page.body.save` 污染链。 + +## 9. 流转条件 + +当前状态:`done` + +只有在以下条件都满足后,本文才能移动到 `bugs/05-editor-mainline/done/`: + +1. [x] 文件树 mindmap asset 普通点击不再污染 `index.md` 主编辑区。 +2. [x] `index.md` 与页面内 mindmap block 的关系有明确单一真源,至少不再出现切页后只剩默认导图的现象。 +3. [x] `/mindmap/{doc}/{asset}` 的产品定位被明确为独立页、新 tab、debug 或 asset editor,不再被文件树主路径误用。 +4. [x] smoke 覆盖长中文 mindmap 编辑、保存、切页、回到 `index.md`、再次打开 asset 的完整链路。 +5. [x] 浏览器复测确认 mindmap 编辑可用性优先,不因实时刷新或路由切换导致闪烁、跑位或内容错乱。 diff --git a/bugs/05-editor-mainline/process/5-11-mindmap-ghost-assets-and-tree-command-latency-v1.md b/bugs/05-editor-mainline/process/5-11-mindmap-ghost-assets-and-tree-command-latency-v1.md new file mode 100644 index 00000000..c702d491 --- /dev/null +++ b/bugs/05-editor-mainline/process/5-11-mindmap-ghost-assets-and-tree-command-latency-v1.md @@ -0,0 +1,193 @@ +# 5-11 [process][bug] Mindmap 幽灵附件增长与树命令卡顿 v1 + +> 更新时间:2026-05-13 +> +> 分类归属: +> - `05-editor-mainline/process` +> - 涉及边界:`04-tree-domain/tree command + file_tree projection`、`06-mindmap/runtime save + resource relation` +> +> 用户证据: +> - `/mnt/Data1T/mnote/tmp/image copy 94.png` +> - `/mnt/Data1T/mnote/tmp/image copy 93.png` + +## 1. 问题定义 + +用户在页面中只是修改了一下 mindmap,文件树/资源树下却陆续出现多个 `mindmap-mindmap...` 附件行。截图显示同一页面 `新页面3` 下有 `index.md`,并且 mindmap 附件从 2 条增长到 4 条。 + +同一轮反馈还指出:删除页面和新建页面都很慢,表现为树操作后明显卡顿。 + +这不是单纯的图标显示问题。当前症状同时暴露两条链路风险: + +1. mindmap 编辑/初始化/保存链路会多次向资产层广播同一个资源存在,且缺少“页面正文 block 与 mindmap asset 关系唯一”的硬约束。 +2. tree shell 的页面新建、删除、重命名、移动仍在命令成功后强制整页刷新,和当前 live projection/SSE 机制重复,导致用户感知卡顿。 + +## 2. 真实现象 + +已观察到的用户现象: + +1. 新页面下初始只有 `index.md` 和少量 mindmap 附件。 +2. 用户只是编辑 mindmap,不是主动新建 mindmap。 +3. 等一会儿或再次修改后,同一页面下又出现新的 `mindmap-mindmap...` 行。 +4. 页面新建和删除动作响应慢,像是页面/树整体重新加载。 + +期望结果: + +1. 一个页面内的一个 mindmap block 只对应一个稳定 `mindmapId` 和一个 file tree asset row。 +2. mindmap 保存只能更新既有资源,不应创建新的 mindmap 资产行。 +3. file tree projection 应按 `{documentId, blockId, assetId}` 或明确 object identity 去重。 +4. 页面新建/删除成功后应优先消费 command result / tree delta 更新局部投影,不应默认整页 reload。 + +## 3. 初步调查证据 + +### 3.1 mindmap 资产广播存在多入口 + +`wolai-frontend/src/components/editor/blocks/MindmapBlock.tsx` 中同一个 mindmap 资源至少有三处会触发资产刷新广播: + +- 保存成功后广播 `emitAssetsChanged(docId, { id: mindmapId, asset_type: "mindmap", ... })`:`MindmapBlock.tsx:1499` 到 `:1534` +- 初始同步 `createOnly: true` 成功后广播:`MindmapBlock.tsx:1591` 到 `:1621` +- mindmap 实例就绪后立即广播:`MindmapBlock.tsx:1636` 到 `:1647` + +另一个 legacy/compat block wrapper 也会在 mount 时执行 `createOnly` 并广播资产:`MindmapBlock.tsx:3573` 到 `:3612`。 + +这些广播本身用 `id = mindmapId`,理论上同 ID 会被 sidebar 本地 state 去重;但只要保存/转换链路让同一视觉 mindmap 换了新的 `mindmapId`,就会生成新的资产行。 + +### 3.2 mindmapId 仍可能由时间戳生成 + +当前 `leptos-tiptap` 插入 mindmap 时使用: + +- `rust/spikes/leptos-tiptap-spike/src/lib.rs:5681` 到 `:5689` + +这里 `next_mindmap_id()` 生成 `mindmap_{Date.now()}`,并写入 paragraph attrs 的 `mindmapId`。如果后续转换、保存、重新挂载中丢失原 attrs,fallback 会用新的 block identity / 新插入节点创建新的 `mindmapId`,资产层就会认为这是另一个 mindmap。 + +相关转换锚点: + +- `rust/crates/mnote-web/src/routes/web_shell.rs:818` 到 `:838`:legacy block 转 TipTap 时写入 `mindmapId` +- `rust/crates/mnote-web/src/routes/web_shell.rs:983` 到 `:1009`:TipTap 节点转 editor block 时若 attrs 缺失则用 blockId fallback +- `wolai-frontend/src/lib/documents/tiptap-content-converter.ts:188` 到 `:213`:`mindmapReferenceProps` 会在缺少 `mindmapId` 时 fallback 到 blockId +- `wolai-frontend/src/lib/documents/tiptap-content-converter.ts:410` 到 `:418`:editor block 转 TipTap 时把 mindmap props 写回 paragraph attrs + +当前缺少一条回归断言:连续编辑同一个 mindmap 后,保存前后 `mindmapId` 必须保持不变,且 file tree 下同一页面 mindmap asset 数量不增长。 + +### 3.3 Convex mindmaps 表允许同页多 mindmap,但缺少 block 关系唯一约束 + +`wolai-frontend/convex/schema.ts:164` 到 `:183` 定义 mindmaps 表,并以 `(document_id, mindmap_id)` 做查询索引。注意这里是普通索引,不是唯一约束。 + +`wolai-frontend/convex/mindmaps.ts` 的 `put` 对同一 `(document_id, mindmap_id)` 是幂等 patch/insert,但它并不知道页面正文中的哪个 block 才是唯一来源。也就是说: + +- 同一个 `mindmapId` 重复保存不会多插入。 +- 如果历史或并发路径已经写出同一 `(document_id, mindmap_id)` 的多行,`put` 当前用 `.first()` 只会 patch 第一行,剩余重复行仍会被后续 list/projection 展示。 +- 但如果前端生成了新的 `mindmapId`,后端会按合法新 mindmap 插入。 +- file tree 会把同一 document 下所有 active mindmaps 映射为资产行。 + +对应映射: + +- `wolai-frontend/convex/mindmaps.ts:206` 到 `:245`:`put` 查询 `by_doc_mindmap` 后 `.first()`,不存在则 insert +- `wolai-frontend/convex/sidebar.ts:79` 到 `:100`:`mindmap_id` 被映射为 `id` 和 `mindmap-{mindmap_id}.json` +- `wolai-frontend/convex/sidebar.ts:193` 到 `:220`:所有 active mindmaps 都进入 `mindmap_assets` +- `rust/crates/bridge-runtime/src/lib.rs:7569` 到 `:7647`:file tree projection 从 `mindmap_assets` 构建资源行,并只按 asset id 去重 + +因此,当前有两个需要实测区分的分支: + +1. 同一视觉对象被保存成多个不同 `mindmapId`,每个都被合法展示为一个资源。 +2. 数据表中已经存在同一 `(document_id, mindmap_id)` 多行,`.first()` 更新掩盖重复行,sidebar list 把重复行全部暴露出来。 + +两者都会在截图中表现为同一页面下多个 `mindmap-mindmap...` 行。 + +### 3.4 Rust / Next API 都会把 mindmap 保存转成 tree resync + +保存路径还会触发树刷新: + +- Next API `POST /api/mindmap/[docId]/[mindmapId]` 构造 `mindmaps.put` 或 `mindmap.command.apply`:`wolai-frontend/src/app/api/mindmap/[docId]/[mindmapId]/route.ts:229` 到 `:254` +- Rust API 普通保存也包装为 `mindmaps.put` 并携带 `createOnly`:`rust/crates/mnote-web/src/routes/mindmap_api.rs:177` 到 `:200` +- Bridge runtime 给 `mindmaps.put` 生成 `resync_required` 树事件:`rust/crates/bridge-runtime/src/lib.rs:9273` 到 `:9326` + +这意味着 mindmap 每次保存都会推动资源树重新读 projection;如果底层 mindmaps 数据已经重复,保存/刷新会把重复行显性化。 + +## 4. 页面新建/删除慢的证据 + +tree shell 在多处命令成功后调用 `scheduleRefresh()`,而 `scheduleRefresh()` 的实现是 80ms 后整页 reload 或带 `renameRowId` 重新 assign: + +- `rust/crates/mnote-web/src/routes/tree.rs:2976` 到 `:2986` + +调用点包括: + +- 文件树删除:`rust/crates/mnote-web/src/routes/tree.rs:2791` 到 `:2824` +- 新建页面:`rust/crates/mnote-web/src/routes/tree.rs:4309` 到 `:4340` +- 重命名:`rust/crates/mnote-web/src/routes/tree.rs:4373` 到 `:4406` +- 移动:`rust/crates/mnote-web/src/routes/tree.rs:4448` 到 `:4502` + +与此同时,主页面已经有 tree live controller 接收 `snapshot` / `delta` / `resync`: + +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:3881` 到 `:3917` +- `rust/crates/mnote-web/src/ssr/pages/layout.rs:3939` 到 `:4050` + +这会造成两种低效叠加: + +1. 命令结果本身已经返回 `tree.node.created` / `tree.node.archived` 等 delta hint。 +2. 前端仍然整页刷新,重新加载 sidebar、file tree、workspace shell、编辑器 runtime。 + +这解释了“新建页面和删除页面都很慢”的用户感知。 + +## 5. 当前判断 + +当前根因尚需实测最终确认,但静态代码已经能支持以下判断: + +1. mindmap ghost asset 增长的高概率根因是 `mindmapId` 稳定性没有被端到端锁死。只要编辑/保存/重挂载过程中 attrs 丢失或重新创建 block,就会插入新 `mindmap_{timestamp}`,后端会合法保存,file tree 会合法展示。 +2. 另一个可疑根因是 `mindmaps` 表没有唯一约束,`put` 只 patch `.first()`,无法清除或阻止同键重复行。 +3. 资产广播入口过多会放大问题。它们让新 mindmapId 或重复数据几乎立即进入 sidebar 本地 state 和 Convex projection,用户就会看到“自己又新增了一个”。 +4. file tree projection 只按 `asset.id` 去重,无法识别“同一 document + 同一正文 block 的多个 mindmapId 其实是幽灵副本”,也无法处理同 id 多行投影的上游异常。 +5. 页面新建/删除慢不是 Convex 单点问题,当前 tree shell 命令成功后仍强制 reload,是明确的性能和体验缺陷。该慢操作应单独归入 `04-tree-domain` 跟踪,本文只保留关联证据。 + +## 6. 建议复现与验证 + +建议补一条失败优先 smoke,先不要直接修代码: + +1. 使用真实测试账号登录 `http://localhost:3000/auth`。 +2. 新建测试页面,记录 `documentId`。 +3. 插入一个 mindmap,记录首个 `mindmapId`。 +4. 连续修改 mindmap 中心主题或新增节点 3 次,每次等待保存完成。 +5. 切到文件树,统计该页面下 `asset_type=mindmap` 的行数和 `data-mnote-object-identity`。 +6. 刷新页面后再次统计。 +7. 断言同一页面下 mindmap asset 数量仍为 1,且 `mindmapId` 未变化。 +8. 同一脚本计时新建页面、删除页面从点击到 DOM 稳定的耗时,并记录是否触发 `window.location.reload()` / navigation。 + +建议同时检查 Convex 数据: + +- `mindmaps` 中同一 `document_id` 下是否出现多个 `mindmap_id`。 +- 新增出来的 `mindmap_id` 是否都形如 `mindmap_`。 +- 页面正文 TipTap JSON 中是否只有一个 mindmap paragraph,且 attrs.mindmapId 是否随保存变化。 + +## 7. 建议修复方向 + +### 阶段一:防止继续增长 + +1. mindmap block 创建时生成一次稳定 `blockId` 与 `mindmapId`,后续保存、转换、重挂载必须保留。 +2. `documents.save` / TipTap converter 对 `mnoteBlockType=mindmap` 增加 contract:缺少 `mindmapId` 时不得静默新建时间戳 ID,应先从 block identity / object identity 恢复,恢复不了则报可观测错误。 +3. `mindmaps.put` 或上层 command 增加可选 `blockId` / `blockAssetRelation`,对同一 `{documentId, blockId}` 已有关联 mindmap 时拒绝插入第二个 mindmapId。 +4. asset 广播入口收口:保存成功、initial createOnly、实例就绪不应都伪造 asset;前端应优先消费 kernel/file tree projection 返回的 object identity。 + +### 阶段二:清理幽灵副本 + +1. 提供只读诊断脚本:列出同一页面下多个 mindmapId、对应 updated_at、正文引用的 mindmapId。 +2. 只有在用户确认后,才可清理未被页面正文引用的 mindmap 行。 +3. 清理必须进入 bug 修复 checklist,不能在本缺陷说明阶段直接删除数据。 + +### 阶段三:树命令性能收口 + +1. `tree.node.create` 成功后用 command result / delta 局部插入节点,而不是 reload。 +2. `tree.node.archive` 成功后用 `remove_document` delta 局部移除节点。 +3. 只有 projection 丢失、SSE 断线或 reducer 无法应用时才走 resync/reload fallback。 +4. smoke 增加“无整页 reload”断言和耗时阈值。 + +## 8. 流转条件 + +当前状态:`process` + +只有满足以下条件后才能移动到 `bugs/05-editor-mainline/done/`: + +1. [ ] 已有 smoke 能稳定复现当前 mindmap 资产增长问题,或能证明 Convex 数据中存在同页多 mindmap 幽灵副本。 +2. [ ] 同一 mindmap 连续编辑保存后,`mindmapId` 和 file tree object identity 保持稳定。 +3. [ ] 同一页面下未主动新建多个 mindmap 时,file tree 只出现一个 mindmap asset row。 +4. [ ] 新建页面和删除页面不再默认整页 reload,或至少有明确 fallback 条件。 +5. [ ] 浏览器实测记录新建/删除耗时,并明显低于当前整页 reload 体验。 +6. [ ] 若清理历史幽灵副本,必须经用户确认,并保留清理前后证据。 diff --git a/bugs/05-editor-mainline/process/5-9-c12-topbar-sidebar-toggle-noop-v1.md b/bugs/05-editor-mainline/process/5-9-c12-topbar-sidebar-toggle-noop-v1.md new file mode 100644 index 00000000..557582f4 --- /dev/null +++ b/bugs/05-editor-mainline/process/5-9-c12-topbar-sidebar-toggle-noop-v1.md @@ -0,0 +1,114 @@ +# 5-9-C12 [process][bug] 文档页顶栏左上角切换侧栏按钮无效 v1 + +> 更新时间:2026-05-12 +> +> 分类归属: +> - `05-editor-mainline/process` +> - 对应体验主线:`5-9 Wolai-aline continuous checklist` +> +> 关联文档: +> - `/mnt/Data1T/mnote/design/05-editor-mainline/process/5-9-wolai-aline-continuous-checklist-v1.md` +> - `/mnt/Data1T/mnote/design/05-editor-mainline/process/5-7-wolai-page-tree-main-editor-experience-restoration-v1.md` +> - `/mnt/Data1T/mnote/design/04-tree-domain/done/4-2-sidebar-pagetree-filetree-product-interaction-contract-v1.md` + +## 1. 问题定义 + +当前 `3000` 文档页顶部左上角的 `切换侧栏` 按钮可以被点击,但点击后左侧 sidebar 没有收起,再次点击也没有重新展开的状态变化。 + +这不是页面树节点的展开/折叠问题,而是文档页壳层的 `sidebar shell toggle` 缺失。 + +## 2. 归类理由 + +本问题归到 `05-editor-mainline`,而不是 `04-tree-domain`,理由如下: + +- 问题入口位于文档页顶栏,不在 `page_tree/file_tree` 行内交互层。 +- 问题影响的是页面壳、顶栏和侧栏显隐体验,属于 `Wolai 页面树与主编辑器体验复刻` 主线。 +- `04-tree-domain` 更关注树 projection、row model、selection/focus、keyboard、DnD、tree command 等合同;本文问题不在这些运行时合同里。 + +## 3. 真实现象 + +复现路径: + +1. 打开 `http://127.0.0.1:3000/auth` +2. 点击 `测试账号快速登录` +3. 进入文档页后,点击顶栏左上角 `切换侧栏` +4. 观察左侧 sidebar 是否收起 +5. 再点击一次,观察是否重新展开 + +实际结果: + +- 第 1 次点击后,左侧 sidebar 仍然完整可见 +- 第 2 次点击后,左侧 sidebar 仍然完整可见 +- 页面 URL 不变 +- 浏览器 console 未出现报错 +- 关键 network 未出现与 toggle 对应的新请求 + +期望结果: + +- 第 1 次点击应收起左侧 sidebar +- 第 2 次点击应恢复展开 +- 行为应与 Wolai / 常规文档页壳的 sidebar toggle 一致 + +## 4. 证据 + +截图证据: + +- 切换前:`/mnt/Data1T/mnote/tmp/hermes-tester/manual-before-toggle.png` +- 点击一次后:`/mnt/Data1T/mnote/tmp/hermes-tester/manual-after-toggle.png` +- 点击两次后:`/mnt/Data1T/mnote/tmp/hermes-tester/manual-after-second-toggle.png` + +Hermes tester 首轮取证: + +- `/mnt/Data1T/mnote/tmp/hermes-tester/first-run/screenshots/01-auth-entry.png` +- `/mnt/Data1T/mnote/tmp/hermes-tester/first-run/screenshots/02-after-quick-login.png` + +窄范围侧栏取证: + +- `/mnt/Data1T/mnote/tmp/hermes-tester/sidebar-run/01-auth.png` +- `/mnt/Data1T/mnote/tmp/hermes-tester/sidebar-run/02-after-login-before-toggle.png` + +代码锚点: + +- 顶栏按钮渲染位于 `/mnt/Data1T/mnote/rust/crates/mnote-web/src/ssr/pages/layout.rs:3938` +- 当前仅能找到按钮渲染与样式,未看到对应的显隐切换绑定: + - `/mnt/Data1T/mnote/rust/crates/mnote-web/src/ssr/pages/layout.rs:3938` + - `/mnt/Data1T/mnote/rust/crates/mnote-web/src/ssr/styles.rs:1940` + +## 5. 当前判断 + +当前更像是: + +- 顶栏按钮已经进入 SSR 页面壳 +- 但 `sidebar open/collapsed` 状态未接线 +- 或按钮没有绑定到实际的 sidebar toggle handler + +也就是说,这是一条“控件已渲染,但未驱动真实状态”的缺陷,而不是视觉误差。 + +## 6. 建议完成方式 + +完成本缺陷至少需要满足下面四条: + +1. 顶栏 `切换侧栏` 按钮绑定真实的 sidebar toggle 状态 +2. 第 1 次点击后 sidebar 收起 +3. 第 2 次点击后 sidebar 再展开 +4. 增补可回归 smoke,覆盖: + - 登录后点击 toggle + - 收起态存在明确 DOM/样式状态 + - 再次点击后恢复展开 + +建议验收同时包含: + +- 代码验证:相关 Rust SSR / 前端状态接线 +- 浏览器 smoke:真实点击与状态断言 +- 截图复核:收起前 / 收起后 / 再展开后三张图 + +## 7. 流转条件 + +当前状态:`process` + +只有在以下条件都满足后,本文才能移动到 `bugs/05-editor-mainline/done/`: + +1. 真实代码已修复 +2. smoke 已覆盖且通过 +3. 浏览器复测确认收起/展开都生效 +4. 证据路径已补齐到修复后的截图或日志 diff --git a/bugs/README.md b/bugs/README.md new file mode 100644 index 00000000..587ba176 --- /dev/null +++ b/bugs/README.md @@ -0,0 +1,34 @@ +# bugs 缺陷索引 + +> 更新时间:2026-05-12 +> +> 状态口径以当前仓库真实代码与真实验证结果为准: +> - `[done]`:问题已修复,且已通过代码、smoke、浏览器或截图证据验证 +> - `[process]`:问题已确认存在,仍在修复、验证或等待收口 + +## 分类方式 + +- `bugs/` 默认镜像 `design/` 的主线分类方式。 +- 当前主线缺陷按对应大类放置,例如: + - `01-tree-first-graph-kernel/` + - `02-convex-rust-long-term-architecture/` + - `03-rust-web/` + - `04-tree-domain/` + - `05-editor-mainline/` + - `06-mindmap/` + - `07-ai/` +- 每个大类继续按 `process/` 与 `done/` 分层。 + +## 归类原则 + +- 缺陷归类以真正 owner 和长期主线为准,不以表面症状命名。 +- `sidebar`、`topbar`、`breadcrumb`、文档页壳、Wolai 体验对齐、页面树与主编辑器整体体验问题,优先归到 `05-editor-mainline/`。 +- `projection`、`row model`、`selection/focus model`、`keyboard`、`DnD`、`tree command`、`page_tree/file_tree/sidebar_tree` 协议问题,优先归到 `04-tree-domain/`。 +- `transport`、route、SSR page shell owner、compat/bridge 边界问题,按 owner 判断是否落到 `03-rust-web/` 或 `05-editor-mainline/`。 + +## 流转规则 + +- 新确认的缺陷先进入对应大类的 `process/`。 +- 缺陷在真实代码中修复并完成对应验证后,必须移动到对应大类的 `done/`。 +- 不允许在 `process/` 与 `done/` 同时保留同一条缺陷。 +- 若后续发现旧缺陷记录归类错误,应直接迁移到正确大类,而不是在错误大类继续追加。 diff --git a/design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md b/design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md new file mode 100644 index 00000000..6ca6f781 --- /dev/null +++ b/design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md @@ -0,0 +1,233 @@ +# 4-24 [done] Resource Tree / File Tree / Page Tree 真源合同与执行清单 v1 + +> 更新时间:2026-05-13 +> +> 上游依据: +> - `/mnt/Data1T/mnote/design/10-review/05-tree.md` +> - `/mnt/Data1T/mnote/design/04-tree-domain/done/4-2-sidebar-pagetree-filetree-product-interaction-contract-v1.md` +> - `/mnt/Data1T/mnote/design/04-tree-domain/done/4-20-vscode-explorer-file-tree-alignment-v1.md` +> - `/mnt/Data1T/mnote/design/05-editor-mainline/process/5-5-page-aggregate-single-truth-alignment-v1.md` +> - `/mnt/Data1T/mnote/design/10-review/README.md` + +## 1. 目标 + +本清单用于把 `design/10-review/05-tree.md` 中的判断落到树域主线: + +- `Resource Tree` 是长期对象组织真源,由 Rust kernel 持有语义。 +- `File Tree` 是 Resource Tree 的主组织投影,展示页面、`index.md`、附件、mindmap、OnlyOffice、代码附件等资源。 +- `Page Tree` 是页面导航投影 / 快捷视图,不拥有排序、父子、附件归属或资源归属的最终真相。 +- Sidebar、文件树 UI、页面树 UI 都只能消费 projection 和发 command,不能重新拼第二套结构真相。 + +## 2. 术语冻结 + +- `Resource Tree`:workspace 内对象与资源的 canonical hierarchy。它不是 UI 文件树组件,而是 kernel 层的资源组织语义。 +- `File Tree`:Resource Tree 面向 VS Code Explorer 体验的 projection。 +- `Page Tree`:Resource Tree 中页面对象的导航 projection,可做快捷显示,但不拥有资源归属。 +- `ObjectIdentity`:打开、保存、草稿、tab、command 使用的对象身份。 +- `BlockAssetRelation`:页面正文 block 与资源对象之间的稳定关联,例如 `documentId + blockId + assetId + assetKind`。 + +## 3. 非目标 + +- 不在本阶段重写 Convex 底层存储。 +- 不在本阶段一次性删除所有 compat/fallback。 +- 不把文件树 UI 组件提升为真源。 +- 不让 Page Tree 接管附件、mindmap 或 OnlyOffice 的归属。 + +## 4. 前置顺序与执行门 + +本清单是 `5-12` 的前置合同。执行顺序固定为: + +1. 先完成本文件的 `Resource Tree / File Tree / Page Tree` 真源合同。 +2. 再执行 `design/05-editor-mainline/done/5-12-main-editor-object-tab-resource-alignment-checklist-v1.md` 中的主编辑区 object tab、草稿隔离和打开路径调整。 + +不允许绕过本文件直接在编辑区里新增第二套 asset / page 归属判断。编辑区可以先做 mindmap 止血,但止血代码必须只消费本文件定义的 object identity / file tree intent,不得把临时前端判断提升为长期合同。 + +当前代码基线: + +- `rust/crates/core-protocol/src/kernel.rs` 已有 `KernelProjectionResourceKind`、`KernelProjectionAssetKind`、`KernelProjectionResourceMeta`、`KernelProjectionItem`。 +- `rust/crates/bridge-runtime/src/lib.rs` 已有 `build_file_tree_projection_result`、`make_projection_resource_meta`、`normalize_file_tree_asset` 等 file tree projection 构造逻辑。 +- `rust/crates/mnote-web/src/routes/tree.rs` 与 `rust/crates/mnote-web/src/ssr/pages/layout.rs` 已消费 `resourceMeta` 并发出 `tree.asset.open`。 +- `rust/crates/mnote-web/src/ssr/pages/layout.rs` 当前仍把 mindmap asset 主路径导航到 `/mindmap/{documentId}/{assetId}`,这是 `5-10` bug 的直接落点,但长期合同归属仍应先在本文件冻结。 + +阶段门: + +- G1:协议能表达 `index.md`、mindmap、OnlyOffice、普通附件、代码附件的不同 object identity。 +- G2:`file_tree` projection row 能稳定输出 object identity 或等价 `resourceMeta.extra.objectIdentity`。 +- G3:`page_tree` projection 被约束为页面导航投影,不承载 asset 归属。 +- G4:`tree.asset.open` 只表达打开资源对象的 intent,不决定“把资源当正文打开”。 +- G5:完成 G1-G4 后,`5-12` 才能把主编辑区打开路径、草稿 key、保存命令接入 object tab / object editor 规则。 + +## 5. 执行清单 + +### 5.1 协议模型 + +- [x] 在 `rust/crates/core-protocol/` 增加或扩展资源对象协议。 + - 优先落点:`rust/crates/core-protocol/src/kernel.rs`,必要时拆出 `rust/crates/core-protocol/src/resource.rs` 并在 `lib.rs` re-export。 + - 当前已有 `KernelProjectionResourceKind`,本阶段应补齐或映射为长期 `ResourceKind` 语义。 + - 最小资源种类:`page`、`index`、`mindmap`、`attachment`、`onlyoffice`、`code`。 + - `ObjectIdentity` 最小字段:`objectKind`、`documentId`、`blockId`、`assetId`。 + - `BlockAssetRelation` 最小字段:`documentId`、`blockId`、`assetId`、`assetKind`。 + - 命名规则:Rust 类型使用 `KernelObjectIdentity` / `KernelBlockAssetRelation` 或等价项目内前缀;序列化字段使用 camelCase。 + +- [x] 补协议单测。 + - 文件建议:`rust/crates/core-protocol/tests/resource_tree_contract.rs`。 + - 断言:mindmap、OnlyOffice、普通附件都能表达为 resource object。 + - 断言:`index.md` 的 object identity 与 mindmap asset 的 object identity 不相等。 + - 断言:`BlockAssetRelation` 能表达 `documentId + blockId + assetId + assetKind`,且不会被反序列化为页面正文 identity。 + - 运行命令: + - `cd /mnt/Data1T/mnote/rust && cargo test -p core-protocol --test resource_tree_contract -- --nocapture` + - 预期:新增协议测试通过,失败时不得继续进入 `5-12` 的 P1/P2。 + +### 5.2 Projection 合同 + +- [x] 扩展 `file_tree` projection 的 row contract。 + - 每个 row 必须带稳定 `row_id`、`node_id`、`projection_kind`、`resource_meta`。 + - `resource_meta` 至少包含 `resourceKind`、`documentId`、`assetId`、`assetKind`、`objectIdentity`。 + - 优先修改点:`rust/crates/core-protocol/src/kernel.rs` 的 `KernelProjectionResourceMeta`,以及 `rust/crates/bridge-runtime/src/lib.rs` 的 `make_projection_resource_meta`。 + - 兼容策略:已有 `resourceKind/documentId/assetId/assetKind` 保持不破坏;新增字段可先放入 `resourceMeta.extra.objectIdentity`,待前后端消费稳定后再提升为强类型字段。 + +- [x] 固定 `page_tree` projection 的降级边界。 + - `page_tree` 只输出页面导航关系。 + - `page_tree` 不输出附件归属、mindmap 归属、OnlyOffice 归属的最终判断。 + - 如需显示资源状态,只能引用 `resource_meta` 或 resource projection,不得在 page tree renderer 内拼装。 + - 优先检查点:`rust/crates/bridge-runtime/src/lib.rs` 中 `page_tree` projection 构造逻辑、`wolai-frontend/src/lib/tree-projection.ts`、`wolai-frontend/src/lib/documents/page-subtree.ts`。 + +- [x] 补 Rust projection 测试。 + - 文件优先看:`rust/crates/bridge-runtime/src/lib.rs`、`rust/crates/mnote-web/src/tree_shell/`。 + - 测试要求:同一页面下的 `index.md` 与 mindmap asset 生成不同 row,但共享同一 `documentId`,并通过 `BlockAssetRelation` 建立关系。 + - 建议新增或扩展测试: + - `kernel_project_view_query_executes_into_file_tree_projection_contract` + - `kernel_file_tree_projection_query_supports_extended_resources_and_max_results` + - 新增 `kernel_file_tree_projection_separates_index_and_mindmap_object_identity` + - 运行命令: + - `cd /mnt/Data1T/mnote/rust && cargo test -p bridge-runtime file_tree_projection -- --nocapture` + - `cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web file_tree_projection -- --nocapture` + +### 5.3 File Tree 派生规则 + +- [x] 页面节点下固定派生 `index.md` row。 + - `index.md` row 只能打开 Page Aggregate body。 + - `index.md` row 不得根据页面内第一个 block 类型改变打开目标。 + - 优先检查点:`rust/crates/bridge-runtime/src/lib.rs` 的 `build_file_tree_projection_result`,当前已固定创建 `index:{documentId}` node。 + - 前端消费检查点:`rust/crates/mnote-web/src/ssr/pages/layout.rs` 的 file tree row click 分支。 + +- [x] 页面内资源固定派生为 child resource row。 + - mindmap row 打开 mindmap object editor。 + - OnlyOffice row 打开 OnlyOffice object editor。 + - 代码附件 row 打开代码/预览编辑器。 + - 普通附件 row 打开签名资源或预览。 + - 优先检查点:`rust/crates/bridge-runtime/src/lib.rs` 的 `normalize_file_tree_asset`、`infer_file_tree_asset_shape`、`classify_asset_resource_kind`。 + - 必须保留 `documentId` 与 `assetId`,供 `5-12` 的 object tab identity 使用。 + +- [x] 文件树 row 不得从前端多份数据临时拼真相。 + - 允许前端显示、筛选、选中、展开。 + - 不允许前端决定资源归属、排序真相或 block-asset relation 真相。 + - 前端允许做的本地状态:`expanded`、`selected`、`hover`、`focus`、`dragging`、`drop target`。 + - 前端禁止新增长期字段:`assetParentDocumentId`、`mindmapOwnerPageId`、`pageTreeAssetChildren` 这类与 kernel projection 重复的归属真相。 + +### 5.4 Page Tree 派生规则 + +- [x] Page Tree 只消费页面导航投影。 + - 可显示页面标题、层级、当前页、快捷入口。 + - 不负责附件、mindmap、OnlyOffice、代码附件的生命周期。 + +- [x] Page Tree command 只发页面导航相关 command。 + - 页面新建、重命名、移动、归档继续走 `tree.node.*` 或正式 page/tree command。 + - 资源 attach/detach/rename/move 不进入 page tree 私有命令。 + - 负向检查:Page Tree renderer / host 中不得新增 mindmap、OnlyOffice、附件归属推导分支。 + +### 5.5 Command 边界 + +- [x] 新增或确认资源关系 command family。 + - `tree.asset.attach` + - `tree.asset.detach` + - `tree.resource.rename` + - `tree.resource.move` + +- [x] 明确不同对象写入 owner。 + - 页面正文:`page.body.save` + - 页面标题:`page.head.updateTitle` + - 页面设置:`page.layout.updateOptions` + - mindmap 内容:`mindmap.command.apply` + - OnlyOffice 内容:OnlyOffice callback / forcesave 写回链 + - 资源归属:`tree.asset.*` / `tree.resource.*` + - 优先检查点: + - `rust/crates/bridge-runtime/src/lib.rs` command plan + - `rust/crates/mnote-web/src/transport/convex.rs` command adapter + - `wolai-frontend/src/lib/documents/rust-runtime.test.ts` + +### 5.6 Smoke 与验收 + +- [x] 增加 Resource Tree / File Tree projection smoke。 + - 断言文件树同页下可见 `index.md`、mindmap、附件。 + - 断言点击 `index.md` 只打开 Page Aggregate body。 + - 断言点击 mindmap 不进入 Page Aggregate body 保存链。 + - 可复用脚本:`scripts/task112-tree-rust-family-regression-smoke.js`。 + - 建议新增断言脚本:`scripts/task170-resource-tree-filetree-source-smoke.js`,或在 task112 中增加独立 case。 + - 运行命令: + - `node scripts/task112-tree-rust-family-regression-smoke.js` + - 若新增脚本:`node scripts/task170-resource-tree-filetree-source-smoke.js` + +- [x] 增加 Page Tree 负向 smoke。 + - 断言 Page Tree 不显示资源归属为自己的结构真相。 + - 断言 Page Tree 操作不会改变 mindmap/附件归属。 + - 可复用脚本:`scripts/task112-tree-rust-family-regression-smoke.js`。 + - 负向检查输出需记录:操作 Page Tree 后,同一 `assetId` 的 `documentId` / `objectIdentity` 未变化。 + +## 6. 建议提交切片 + +本文件只定义设计顺序,不要求一次提交完成全部实现。后续执行时建议按以下切片推进: + +1. 协议切片:`core-protocol` 增补 object identity / relation 类型与测试。 +2. Projection 切片:`bridge-runtime` 与 `mnote-web` file tree projection 输出 object identity。 +3. UI 消费切片:file tree host 只转发 object open intent,不拼归属真相。 +4. Page Tree 负向切片:补 page tree 不持有资源归属的单测或 smoke。 +5. 验收切片:跑 Rust 测试与真实浏览器 smoke,把证据补回对应 bug / design 文档。 + +## 7. 验收命令 + +最低验收命令: + +```bash +cd /mnt/Data1T/mnote/rust && cargo test -p core-protocol --test resource_tree_contract -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p bridge-runtime file_tree_projection -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web file_tree_projection -- --nocapture +node scripts/task112-tree-rust-family-regression-smoke.js +``` + +如执行环境没有启动 `3000`,先运行仓库常用入口: + +```bash +npm run desktop:hot +``` + +真实浏览器 smoke 必须使用默认测试账号 `mnote.e2e@example.com` / `MnoteE2E123!`,不能用 `devFallback` 代替登录态。 + +## 8. Done Gate + +本文移动到 `done/` 前必须满足: + +- [x] `Resource Tree`、`File Tree`、`Page Tree` 三个术语在协议和文档中不再混用。 +- [x] `file_tree` row 能表达 `index.md`、mindmap、OnlyOffice、附件、代码附件的不同 object identity。 +- [x] `page_tree` 被验证为页面导航 projection,不拥有资源归属真相。 +- [x] mindmap 与 `index.md` 的打开、保存、草稿身份互相隔离。 +- [x] 至少一条真实浏览器 smoke 覆盖 `index.md + mindmap asset + 切页 + 再打开` 的完整链路。 + +## 9. 完成证据 + +- 协议:`rust/crates/core-protocol/src/kernel.rs` 增加 `KernelObjectIdentity`、`KernelObjectKind`、`KernelBlockAssetRelation`,并由 `rust/crates/core-protocol/tests/resource_tree_contract.rs` 覆盖。 +- Projection:`rust/crates/bridge-runtime/src/lib.rs` 的 file tree projection 输出 `resourceMeta.objectIdentity` / `blockAssetRelation`,并覆盖 index、mindmap、OnlyOffice、代码附件、普通附件。 +- UI intent:`rust/crates/mnote-web/src/ssr/pages/layout.rs`、`rust/crates/mnote-web/src/routes/tree.rs`、`rust/crates/mnote-web/src/tree_shell/filetree_renderer.rs` 将 `objectIdentity` 传入 file tree DOM 与 `tree.asset.open`。 +- Smoke:`node scripts/task112-tree-rust-family-regression-smoke.js` 通过,page tree host / file tree host 主链为 `dom`;debug tree shell 关闭项按当前主线记录为 skipped。 +- Mindmap 链路:`node scripts/task169-mindmap-realtime-smoke.js` 通过,覆盖 mindmap asset 打开、长中文编辑、保存、切页、回 `index.md`、再打开 mindmap。 + +## 10. 交接给 5-12 的输入 + +完成本文件后,`5-12` 可以依赖以下输入推进主编辑区: + +- 文件树 `index.md` row 的 `objectIdentity`:`page:index:{documentId}`。 +- 文件树 mindmap row 的 `objectIdentity`:`resource:mindmap:{documentId}:{assetId}`。 +- 文件树 OnlyOffice row 的 `objectIdentity`:`resource:onlyoffice:{documentId}:{assetId}`。 +- 文件树普通附件 row 的 `objectIdentity`:`resource:attachment:{documentId}:{assetId}`。 +- 文件树代码附件 row 的 `objectIdentity`:`resource:code:{documentId}:{assetId}`。 +- Page Tree 不再作为资源归属输入;它只提供页面导航选择。 diff --git a/design/05-editor-mainline/done/5-12-main-editor-object-tab-resource-alignment-checklist-v1.md b/design/05-editor-mainline/done/5-12-main-editor-object-tab-resource-alignment-checklist-v1.md new file mode 100644 index 00000000..0840cb74 --- /dev/null +++ b/design/05-editor-mainline/done/5-12-main-editor-object-tab-resource-alignment-checklist-v1.md @@ -0,0 +1,275 @@ +# 5-12 [done] 主编辑区 Object Tab 与 Resource Tree 对齐执行清单 v1 + +> 更新时间:2026-05-13 +> +> 上游依据: +> - `/mnt/Data1T/mnote/design/10-review/05-tree.md` +> - `/mnt/Data1T/mnote/bugs/05-editor-mainline/done/5-10-mindmap-filetree-index-single-truth-split-v1.md` +> - `/mnt/Data1T/mnote/design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md` +> - `/mnt/Data1T/mnote/design/05-editor-mainline/process/5-5-page-aggregate-single-truth-alignment-v1.md` +> - `/mnt/Data1T/mnote/design/06-mindmap/process/6-mindmap-kernel-phase6-projection-editor-v1.md` + +## 1. 目标 + +本清单用于把主编辑区从“只等于页面正文编辑器”推进为 workspace object tab host: + +- `index.md` tab 只编辑 Page Aggregate body。 +- mindmap tab 只编辑 mindmap projection / command。 +- OnlyOffice tab 只编辑对应附件对象。 +- 代码附件 / 普通附件 tab 只编辑或预览对应资源对象。 +- 所有 tab 使用独立 `ObjectIdentity`、草稿身份和保存命令,不互相伪装。 + +## 2. 当前优先级 + +P0 是关闭当前 mindmap 文件树打开污染 `index.md` 的缺陷。 + +P1 是建立主编辑区 object tab 的最小协议,让后续 mindmap、OnlyOffice、附件都能进入同一套打开/关闭/保存/恢复模型。 + +P2 是把 Page Aggregate 的 block-asset relation 与 Resource Tree projection 串起来。 + +执行前置: + +- 必须先按 `design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md` 固定 Resource Tree / File Tree / Page Tree 的真源合同。 +- 本文件不定义新的资源归属真相,只消费 `4-24` 输出的 `ObjectIdentity`、`resourceMeta` 和 `tree.asset.open` intent。 +- P0 可以作为止血先落地,但 P0 中所有草稿 key、保存命令、打开路径都必须与 `4-24` 的 object identity 兼容。 + +当前关键代码锚点: + +- `rust/crates/mnote-web/src/ssr/pages/layout.rs`:file tree asset 打开事件、`buildMindmapOpenPath`、`openConvexAssetFromFileTree`、`tree.asset.open` listener。 +- `rust/crates/mnote-web/src/routes/mindmap_shell.rs`:standalone mindmap shell 与临时 bootstrap。 +- `rust/crates/mnote-web/src/ssr/pages/mindmap.rs`:mindmap object editor 页面标记与 command form。 +- `rust/crates/mnote-web/src/routes/mindmap_api.rs`:mindmap command / put 保存链。 +- `rust/crates/mnote-web/src/routes/documents.rs`:`page.body.save` 页面正文保存链。 +- `rust/spikes/leptos-tiptap-spike/src/lib.rs`:文档页 island 草稿、bootstrap、保存 runtime。 +- `scripts/task169-mindmap-realtime-smoke.js`:当前 mindmap 长中文、保存、实时刷新 smoke,应升级为本 bug 的主验收脚本。 + +## 3. P0:mindmap object editor 止血清单 + +### 3.1 打开路径 + +- [x] 文件树 mindmap asset 普通点击必须打开明确的 mindmap object editor。 + - 当前允许继续使用 `/mindmap/{documentId}/{mindmapId}`。 + - 该路由必须声明自己是 object editor / asset editor。 + - 不允许被 `index.md` 吞掉。 + - 不允许把临时 mindmap-only bootstrap 视为真实页面正文。 + - 推荐实现口径: + - 保留 `/mindmap/{documentId}/{mindmapId}` 作为独立 object editor 路由。 + - 在 HTML 根节点或主容器加可测标记,例如 `data-mnote-object-editor="mindmap"`、`data-mnote-object-identity="resource:mindmap:{documentId}:{mindmapId}"`。 + - file tree 点击 mindmap 后,若继续整页导航,必须让页面显式进入 mindmap object editor,而不是复用文档页正文 island 的页面草稿 key。 + - 后续 object tab host 接入后,再把整页导航替换为主编辑区 tab 打开。 + +- [x] `index.md` 点击必须只打开真实文档页。 + - 目标为 `/documents/{documentId}?treeView=filetree`。 + - 读取来源为 Rust `/api/page-aggregate/{documentId}`。 + - 不读取 mindmap standalone 草稿。 + - 推荐检查点: + - `layout.rs` 中 file tree row click 对 `index/document/markdown` 的分支。 + - `leptos-tiptap` island 初始化时是否优先使用服务端 Page Aggregate bootstrap。 + +### 3.2 草稿与保存身份 + +- [x] standalone mindmap 的草稿 key 必须使用 object identity。 + - 推荐格式:`__mindmap_object__:{documentId}:{mindmapId}`。 + - 禁止使用真实页面的 `workspaceId:documentId` 草稿 key。 + - 推荐检查点:`rust/spikes/leptos-tiptap-spike/src/lib.rs` 内 localStorage 草稿读写 key 生成逻辑。 + - 负向要求:打开 `/mindmap/{documentId}/{mindmapId}` 后,localStorage 中不得新增或覆盖文档正文草稿 key。 + +- [x] 文档页有服务端 bootstrap content 时,不得被 localStorage 旧草稿覆盖。 + - 如果存在历史坏草稿,文档页应优先使用 Page Aggregate body。 + - 打开文档页后应把坏草稿覆盖或隔离,不让其继续污染后续打开。 + - 推荐策略: + - 当 bootstrap contract 是 `mnote.page_aggregate.v1` 时,优先采用 bootstrap content。 + - 对与 mindmap object key 匹配的草稿直接隔离,不参与文档页正文恢复。 + - 对历史坏草稿只允许在同一 `ObjectIdentity` 下恢复,不允许跨 `page:index` 与 `resource:mindmap` 恢复。 + +- [x] mindmap 保存只走 mindmap command。 + - 保存命令:`mindmap.command.apply` 或当前正式 mindmap put/apply 链。 + - 禁止触发 `page.body.save`。 + - 推荐检查点: + - `rust/crates/mnote-web/src/routes/mindmap_api.rs` + - `rust/crates/mnote-web/src/transport/convex.rs` + - `wolai-frontend/src/app/api/mindmap/[docId]/[mindmapId]/route.ts` + - 负向测试:mindmap object editor 保存期间拦截或记录网络请求,不能出现 `/api/documents/save` 或 canonical `page.body.save`。 + +### 3.3 真实网页 smoke + +- [x] 更新 `scripts/task169-mindmap-realtime-smoke.js`。 + - 新建测试页面。 + - 插入或生成 mindmap block。 + - 从文件树点击本轮 `documentId + mindmapId` 对应 mindmap asset。 + - 断言进入 mindmap object editor,而不是 `index.md`。 + - 输入长中文并保存。 + - 切到其他页面。 + - 再点击原页面 `index.md`。 + - 断言 `index.md` 仍显示 Page Aggregate body。 + - 再打开 mindmap asset。 + - 断言长中文仍存在。 + - 测试数据前缀:`TEST-T169-MINDMAP-OBJECT-`。 + - 必须记录并断言: + - `documentId` + - `mindmapId` + - mindmap object editor URL 或 tab identity + - `index.md` 返回 URL + - 长中文内容保存后的重开结果 + +- [x] 负向断言。 + - 点击 mindmap asset 后不得调用 `page.body.save`。 + - 打开 `index.md` 后不得加载 `__mindmap_object__` 草稿。 + - mindmap live refresh 不得在长中文编辑过程中重挂载或覆盖输入。 + - 修复前失败时 bug 留在 `bugs/05-editor-mainline/process/5-10-mindmap-filetree-index-single-truth-split-v1.md`;本轮通过后已移动到 done。 + +### 3.4 P0 建议实施顺序 + +- [x] Step 1:先补 smoke 红灯。 + - 修改:`scripts/task169-mindmap-realtime-smoke.js`。 + - 目标:当前实现应能暴露 `index.md` 与 mindmap object editor 身份混淆或草稿污染风险。 + - 运行:`node scripts/task169-mindmap-realtime-smoke.js`。 + - 预期:修复前至少一个负向断言失败,或者脚本明确输出当前路径仍有污染风险。 + +- [x] Step 2:标记 mindmap object editor 身份。 + - 修改:`rust/crates/mnote-web/src/routes/mindmap_shell.rs`、`rust/crates/mnote-web/src/ssr/pages/mindmap.rs`。 + - 目标:`/mindmap/{documentId}/{mindmapId}` 输出明确 object editor contract,不能被识别为 Page Aggregate body。 + - 验收:页面 DOM 能被 smoke 定位到 `data-mnote-object-editor="mindmap"` 或等价稳定标记。 + +- [x] Step 3:隔离 mindmap 草稿 key。 + - 修改:`rust/spikes/leptos-tiptap-spike/src/lib.rs`。 + - 目标:mindmap standalone 使用 `__mindmap_object__:{documentId}:{mindmapId}`;文档页使用 `page:index:{documentId}` 或现有页面草稿 key,但不得互读。 + - 验收:smoke 检查 localStorage 中 mindmap key 与 page key 分离。 + +- [x] Step 4:确认保存命令隔离。 + - 修改:优先不改实现,先用测试确认;如失败,再收口 `mindmap_api.rs` / `documents.rs` / transport adapter。 + - 目标:mindmap 保存只走 `mindmap.command.apply`,`index.md` 保存只走 `page.body.save`。 + - 验收:网络请求和 command result 中的 canonical command 分别正确。 + +- [x] Step 5:跑完整 smoke 并补 bug 证据。 + - 运行:`node scripts/task169-mindmap-realtime-smoke.js`。 + - 预期:长中文编辑、保存、切页、回 `index.md`、再开 mindmap 全链路通过。 + +## 4. P1:Object Tab Host 最小合同 + +### 4.1 Tab Identity + +- [x] 定义主编辑区 tab identity。 + - `page:index:{documentId}` + - `resource:mindmap:{documentId}:{mindmapId}` + - `resource:onlyoffice:{documentId}:{assetId}` + - `resource:attachment:{documentId}:{assetId}` + - `resource:code:{documentId}:{assetId}` + +- [x] 每个 tab 必须声明: + - `objectKind` + - `documentId` + - `blockId` + - `assetId` + - `title` + - `dirtyState` + - `saveCommand` + - `closeBehavior` + +### 4.2 Tab 打开规则 + +- [x] `index.md` row 打开 `page:index:{documentId}`。 +- [x] mindmap row 打开 `resource:mindmap:{documentId}:{mindmapId}`。 +- [x] OnlyOffice row 打开 `resource:onlyoffice:{documentId}:{assetId}`。 +- [x] 代码附件 row 打开 `resource:code:{documentId}:{assetId}`。 +- [x] 普通附件 row 打开 `resource:attachment:{documentId}:{assetId}`。 + - 输入来源只能是 `4-24` 的 file tree row `resourceMeta.objectIdentity` 或等价字段。 + - 如果字段缺失,允许临时由 `resourceKind + documentId + assetId` 推导,但必须在代码注释或测试名中标明是兼容推导,不得作为新真源。 + +### 4.3 Tab 保存规则 + +- [x] Page tab 保存只调用 `page.body.save`。 +- [x] Mindmap tab 保存只调用 `mindmap.command.apply`。 +- [x] OnlyOffice tab 保存只通过 OnlyOffice callback / forcesave。 +- [x] Code tab 保存只写对应 asset。 +- [x] Attachment preview tab 默认无正文保存行为。 + - 负向规则:任一 resource tab 保存不得调用 `page.body.save`,除非该操作明确修改的是 Page Aggregate body 中的引用 block。 + +### 4.4 P1 建议实施顺序 + +- [x] Step 1:定义 tab identity 类型。 + - 首选落点:`rust/crates/core-protocol/src/kernel.rs` 或 `rust/crates/core-protocol/src/editor/model.rs`。 + - 前端适配落点:`wolai-frontend/src/components/sidebar/tree-shell-dom-model.ts`、`wolai-frontend/src/components/sidebar/sidebar-navigation.ts`。 + +- [x] Step 2:让 file tree open intent 携带 tab identity。 + - 修改:`rust/crates/mnote-web/src/routes/tree.rs`、`rust/crates/mnote-web/src/ssr/pages/layout.rs`。 + - 验收:`tree.asset.open` detail 中包含 `objectIdentity` 或可无歧义生成 object identity 的字段。 + +- [x] Step 3:主编辑区 host 消费 tab identity。 + - 初期允许只有 `page:index` 与 `resource:mindmap` 两类 tab。 + - 不要求一次完成 OnlyOffice / code / attachment 的 UI,但必须保留类型位。 + +- [x] Step 4:补 tab identity 单测。 + - 建议测试文件:`wolai-frontend/src/components/sidebar/sidebar-navigation.test.ts`、`wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx`。 + - 断言:`index.md` 与 mindmap asset 打开生成不同 tab identity。 + +## 5. P2:Page Aggregate 与 Block-Asset Relation + +- [x] 页面正文中的 mindmap block attrs 必须持有稳定 `mindmapId`。 +- [x] Page Aggregate 输出 mindmap block 与 resource relation。 +- [x] File Tree mindmap row 来源于同一 relation。 +- [x] 删除 mindmap block 时,资源关系必须进入 detach / archive 计划。 +- [x] 删除 mindmap asset 时,页面正文 block 必须进入明确处理计划:删除 block、保留占位、或标记资源缺失,不能静默断链。 + - 优先落点:`rust/crates/core-protocol/src/page_aggregate.rs`、`rust/crates/bridge-runtime/src/lib.rs`、`wolai-frontend/src/lib/documents/tiptap-content-converter.ts`。 + - 验收:同一个 `mindmapId` 能同时从 Page Aggregate block attrs 与 File Tree resource row 追踪到。 + +## 6. P3:OnlyOffice / 附件 / 插件对象推广 + +- [x] OnlyOffice 附件打开复用 Object Tab identity。 +- [x] 代码附件编辑复用 Object Tab identity。 +- [x] 普通附件预览复用 Object Tab identity。 +- [x] 插件型对象只能通过 block-asset relation 接入页面正文,不能把插件 runtime data 当 Page Aggregate body。 + - OnlyOffice 参考落点:`rust/crates/mnote-web/src/routes/onlyoffice.rs`、`scripts/task174-rust-onlyoffice-attachment-open-smoke.js`。 + - 上传 / 普通附件参考落点:`rust/crates/mnote-web/src/routes/media.rs`、`scripts/task175-rust-upload-entry-smoke.js`。 + +## 7. 验收命令 + +最低验收顺序: + +```bash +node scripts/task169-mindmap-realtime-smoke.js +cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web mindmap -- --nocapture +cd /mnt/Data1T/mnote/rust && cargo test -p mnote-web documents_save_route_executes_page_body_save_command -- --nocapture +``` + +扩展验收: + +```bash +pnpm --dir wolai-frontend test -- sidebar-navigation.test.ts tree-shell-host.test.tsx +node scripts/task174-rust-onlyoffice-attachment-open-smoke.js +node scripts/task175-rust-upload-entry-smoke.js +``` + +如本地服务未启动,先执行: + +```bash +npm run desktop:hot +``` + +真实浏览器 smoke 必须使用默认测试账号 `mnote.e2e@example.com` / `MnoteE2E123!`,并优先从 `http://localhost:3000/auth` 的“测试账号快速登录”进入。 + +## 8. Done Gate + +本文移动到 `done/` 前必须满足: + +- [x] 当前 mindmap bug 文档 `5-10` 可移动到 `bugs/05-editor-mainline/done/`。 +- [x] 真实浏览器 smoke 证明 mindmap 文件树点击、长中文编辑、保存、切页、回 `index.md`、再开 mindmap 全链路正常。 +- [x] `index.md`、mindmap、OnlyOffice、附件的 object identity 已在打开路径和保存路径中区分。 +- [x] 至少 mindmap 与 `index.md` 已完成草稿隔离。 +- [x] 文件树打开行为不再让 asset 伪装成页面正文。 + +## 9. 完成证据 + +- Object identity:`rust/crates/core-protocol/src/kernel.rs` 定义 `KernelObjectIdentity`,file tree projection 与 DOM 传递 `page/index/mindmap/only_office/code/attachment` identity。 +- Mindmap object editor:`rust/crates/mnote-web/src/ssr/pages/mindmap.rs` 输出 `data-mnote-object-editor="mindmap"` 与 `data-mnote-object-identity="resource:mindmap:{documentId}:{mindmapId}"`。 +- 草稿隔离:`rust/crates/mnote-web/src/routes/mindmap_shell.rs` 使用 `__mindmap_object__:{doc}:{mindmap}` bootstrap identity;`rust/spikes/leptos-tiptap-spike/src/lib.rs` 的 `standalone_mindmap_object_uses_isolated_draft_identity` 通过。 +- 保存隔离:`cargo test -p mnote-web mindmap -- --nocapture` 与 `cargo test -p mnote-web documents_save_route_executes_page_body_save_command -- --nocapture` 通过。 +- 真实 smoke:`node scripts/task169-mindmap-realtime-smoke.js` 通过,覆盖文件树 mindmap 打开、长中文编辑、保存、切页、回 `index.md`、再打开 mindmap。 + +## 10. 完成后回填 + +实现完成后需要回填以下位置: + +- `bugs/05-editor-mainline/done/5-10-mindmap-filetree-index-single-truth-split-v1.md`:已补真实修复证据并移动到 `done/`。 +- `design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md`:已标记 `ObjectIdentity` 与 file tree row contract 被编辑区消费。 +- `design/10-review/05-tree.md`:补最终采用的 object editor / object tab 方案摘要。 diff --git a/design/06-mindmap/process/6-mindmap-phase6-kmind-parity-detail-checklist-v1.md b/design/06-mindmap/process/6-mindmap-phase6-kmind-parity-detail-checklist-v1.md new file mode 100644 index 00000000..c9de8f7f --- /dev/null +++ b/design/06-mindmap/process/6-mindmap-phase6-kmind-parity-detail-checklist-v1.md @@ -0,0 +1,475 @@ +# 6 [process] Mindmap Phase 6 KMind/simple-mind-map Parity Detail Checklist v1 + +> 日期:2026-05-11 +> +> 当前阶段:Phase 6 `leptos-mindmap` 已完成真实 `simple-mind-map` runtime + Leptos/Rust floating overlay shell 的第一轮收口;本 checklist 是后续细节优化入口。 +> +> 执行规则:每完成一个节点,必须基于代码、测试、截图或人工复核证据勾选对应项。未验证的实现不得勾选。 + +## 0. 目标与结论 + +**目标:**把当前 mindmap shell 从“可运行的 Leptos/Rust 浮动 UI 壳”推进到接近 KMind 与 simple-mind-map 官方编辑器的工作台体验。 + +当前不需要改变 Phase 6 的大方向: + +```text +Rust kernel truth + -> mindmap.simple_mind_map_scene.v1 + -> leptos-tiptap NodeView + -> simple-mind-map runtime + -> Leptos/Rust floating UI shell + -> command bridge / compatPayload.patch +``` + +本轮要修正的是 UI 与交互细节,而不是回退到以下路线: + +- 不直接嵌入完整 Vue `lx-doc/mind-map` 应用。 +- 不恢复旧 React `MindmapBlock.tsx` 为 3000 文档页默认主链。 +- 不启动 Rust-native renderer 重写。 +- 不把 `simple-mind-map` runtime data 保存为 canonical truth。 +- 不把 TypeScript NodeView 扩写成长期 toolbar/sidebar/navigator UI 框架;长期 UI shell 继续归到 Leptos/Rust。 + +## 1. 本次取证结论 + +### 1.1 当前实现差距 + +已对照: + +- 当前实现截图:`/mnt/Data1T/mnote/tmp/image copy 80.png` +- KMind 目标截图:`/mnt/Data1T/mnote/tmp/image copy 81.png` +- 隐藏 chrome 目标截图:`/mnt/Data1T/mnote/tmp/image copy 82.png` +- 右侧详细设置栏目标截图:`/mnt/Data1T/mnote/tmp/image copy 83.png` + +当前主要差距: + +- Toolbar 当前视觉上仍是三行:`rust/spikes/leptos-tiptap-spike/src/lib.rs` 中 `.mnote-mindmap-command-toolbar` 与 `.mnote-mindmap-toolbar-primary` 都允许 `flex-wrap: wrap`,并且每个分组都带文字分组名,导致不可能稳定保持 KMind/simple-mind-map 的单行工具组。 +- Toolbar 当前没有真正的 `更多` 溢出模型。lx-doc `Toolbar.vue` 通过测量工具栏宽度,把可见按钮放入 `horizontalList`,把溢出按钮放入 `verticalList`,这比单纯 CSS 横向滚动更接近目标。 +- 当前没有完整全屏状态。lx-doc `Fullscreen.vue` 同时提供“全屏查看”和“全屏编辑”,并在 fullscreen change 后调用 `mindMap.resize()`。 +- 当前没有“鼠标移出后隐藏 chrome,鼠标移入不自动恢复,点击才恢复”的状态机。KMind changelog 明确提到 floating toolbar 会在特定场景自动隐藏,并推荐结合 Zen mode 获得更大的编辑视图。 +- 当前右侧栏只是窄 tab + 148px 简化 body;KMind/simple-mind-map 是“右侧触发条 + 可隐藏把手 + 约 300px 详细抽屉”,结构面板中有布局卡片,设置项密度明显更高。 +- 当前 navigator 是文字按钮和常驻搜索输入框;目标是底部右侧图标工具条,搜索按需展开,全屏、小地图、只读、缩放、鼠标行为、设置等是同一条浮动控件。 + +### 1.2 参考实现证据 + +- `design/05-editor-mainline/reference-code/lx-doc/mind-map/src/pages/Edit/components/Toolbar.vue` + - `computeToolbarShow()` 根据宽度计算单行 `horizontalList` 与 `verticalList`。 + - `showMoreBtn` 显示 `更多` popover。 +- `design/05-editor-mainline/reference-code/lx-doc/mind-map/src/pages/Edit/components/ToolbarNodeBtnList.vue` + - 记录 toolbar action、禁用状态、active node 规则和 runtime command。 +- `design/05-editor-mainline/reference-code/lx-doc/mind-map/src/pages/Edit/components/SidebarTrigger.vue` + - 右侧触发条有 `show` 状态和 `toggleShowBtn` 隐藏把手。 + - 激活 panel 后容器从 `right: 0` 推到 `right: 305px`。 +- `design/05-editor-mainline/reference-code/lx-doc/mind-map/src/pages/Edit/components/NavigatorToolbar.vue` + - 底部 navigator 是图标工具条,不是常驻表单。 + - 包含回根、搜索、鼠标行为、小地图、只读、全屏、缩放、暗色、源码、演示等入口。 +- `design/05-editor-mainline/reference-code/lx-doc/mind-map/src/pages/Edit/components/Fullscreen.vue` + - 区分 `fullscreenShow` 和 `fullscreenEdit`。 +- `design/05-editor-mainline/reference-code/lx-doc/mind-map/src/config/zh.js` + - `sidebarTriggerList` 包含 `nodeStyle/baseStyle/theme/structure/outline/shortcutKey`。 +- `design/05-editor-mainline/reference-code/kmind-plugin/README_en_US.md` + - 明确提到 desktop floating toolbar、Zen mode、自动隐藏 UI、全局配置。 + +- [x] 已完成当前实现、截图和参考代码的首轮取证。 + +## 2. 文件职责边界 + +### 2.1 主要运行代码 + +- `rust/spikes/leptos-tiptap-spike/src/lib.rs` + - 当前 Leptos/Rust shell、CSS、mount/unmount、toolbar/sidebar/navigator 渲染集中在此。 + - 下一阶段应优先把 mindmap shell 拆出到专门模块,避免 `lib.rs` 继续膨胀。 +- `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` + - 当前 action、toolbar group、sidebar panel、navigator item、context menu 的 schema 来源。 + - 下一阶段需要扩展为可表达单行 toolbar、溢出、全屏、chrome visibility、详细 panel controls 的中立 schema。 +- `wolai-frontend/src/lib/mindmap/mindmap-action-map.ts` + - UI action 到 runtime/local/kernel/compat 的映射。 + - 下一阶段需要补全 `fullscreen`、`toggleChrome`、`toggleSidebar`、`toggleSearch`、`setScale`、`setMouseBehavior` 等 local view action。 +- `wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts` + - 当前只覆盖 active node、readonly、capability、disabled state。 + - 下一阶段需要补 chrome visibility、fullscreen、sidebar open、search open、toolbar overflow、navigator active state。 +- `wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts` + - 当前 runtime bridge。 + - 下一阶段需要确保 fullscreen/resize、search、minimap、scale input、sidebar style 写入都能通过 bridge 安全触达 runtime。 +- `wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.ts` + - projection/command endpoint 与 adapter 初始化。 + - 下一阶段继续保持薄桥接,不承载 UI 细节。 +- `scripts/task166-mindmap-phase6-block-smoke.js` + - 当前 Phase 6 smoke。 + - 下一阶段建议新增或扩展为 KMind parity smoke,保存对齐截图证据。 + +### 2.2 建议新增/拆分文件 + +- Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` + - Leptos/Rust shell 组件、状态结构、事件派发。 +- Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell_style.rs` 或保留同模块内常量 + - 如果现有 CSS 继续增长,单独收口 mindmap shell 样式字符串。 +- Create: `scripts/task167-mindmap-kmind-parity-smoke.js` + - 专门覆盖 toolbar 单行、全屏、chrome hide、右侧抽屉、截图对比。 +- Output: `tmp/task167-mindmap-kmind-parity-smoke/*.png` + - 保存每个视觉验收节点截图。 + +## 3. 状态模型先行 + +后续 UI 不应继续靠 CSS 和零散按钮状态拼凑。先把 shell state 定义清楚。 + +### Task 1: 扩展 Mindmap Shell State Contract + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-state.test.ts` +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` + +- [x] 定义 `MindmapChromeVisibilityState`: + - `visible` + - `hiddenByPointerLeave` + - `hiddenByToggle` + - `hiddenByFullscreen` +- [x] 定义 `MindmapToolbarOverflowState`: + - `availableWidth` + - `visibleActionIds` + - `overflowActionIds` + - `moreOpen` +- [x] 定义 `MindmapFullscreenState`: + - `mode: "none" | "canvas" | "page"` + - `isFullscreen` + - `target: "mindmap-root" | "document-body"` +- [x] 定义 `MindmapSidebarState`: + - `triggerVisible` + - `panelOpen` + - `activePanelId` + - `drawerWidth` + - `collapsedByToggle` +- [x] 定义 `MindmapNavigatorState`: + - `searchOpen` + - `minimapOpen` + - `readonly` + - `zoomPercent` + - `mouseBehavior` +- [x] TS 单测覆盖:鼠标移出后为 `hiddenByPointerLeave`;再次 mouseenter 不恢复;点击画布或点击显式恢复按钮才回到 `visible`。 +- [x] TS 单测覆盖:sidebar toggle 隐藏触发条后,不会清空 `activePanelId`;再次显示后保留最近面板。 +- [x] Rust/Leptos shell options 能接收上述 state,并向 DOM 输出稳定 `data-*` 标记,供 smoke 断言。 +- [x] 验证:`cd /mnt/Data1T/mnote/wolai-frontend && pnpm test -- mindmap-ui-state` + - 2026-05-11 通过:`mindmap-ui-state.test.ts` 6 项通过;同时复核 `npm run typecheck`、`npm run build`、`cargo check`、`node scripts/build-leptos-tiptap-island.js` 均通过。 + +## 4. 单行 Toolbar 与更多菜单 + +目标:对齐 `/mnt/Data1T/mnote/tmp/image copy 81.png` 与 lx-doc `Toolbar.vue`,主 toolbar 只占一行;溢出进入 `更多` 菜单;不要回到当前 `/mnt/Data1T/mnote/tmp/image copy 80.png` 的三行状态。 + +### Task 2: 设计单行 Toolbar Schema + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.test.ts` + +- [x] 为 toolbar action 增加 `iconKey`、`shortLabel`、`longLabel`、`priority`、`overflowGroup`。 +- [x] 移除默认渲染中强依赖的分组文字标签;分组仅作为视觉分隔线和溢出归类,不占据单行宽度。 +- [x] 把 import/export/historyRecord 规划为右侧独立 toolbar cluster,避免和节点编辑按钮互相挤压。 +- [x] 增加 `more` 虚拟 action,只有存在 `overflowActionIds` 时显示。 +- [x] 单测断言默认 toolbar 主按钮顺序与 lx-doc/KMind 对齐:undo、redo、editNode、insertSiblingAfter、deleteNode、insertChild、tag、hyperlink、note、image、icon、summary、associativeLine、formula、more。 +- [x] 单测断言 action id 不重复,且每个可见 action 都能映射到 action map。 +- [x] 验证:`cd /mnt/Data1T/mnote/wolai-frontend && pnpm test -- mindmap-ui-schema mindmap-action-map` + - 2026-05-11 通过:`mindmap-ui-schema.test.ts` 11 项通过;同轮 `mindmap-action-map.test.ts` 4 项通过。 + +### Task 3: 实现 Leptos 单行 Toolbar Layout + +**Files:** +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` +- Modify: `rust/spikes/leptos-tiptap-spike/src/lib.rs` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] Toolbar CSS 改为单行:`flex-wrap: nowrap`,固定按钮宽高,禁用 group 内换行。 +- [x] 顶部 toolbar 分为左/中/右 cluster:主编辑工具、导入导出/历史、更多。 +- [x] 用 `ResizeObserver` 或等价测量机制计算可见按钮与溢出按钮;窄宽度下不允许撑成第二行。 +- [x] `更多` 点击后打开浮层菜单,菜单内纵向列出溢出 action。 +- [x] `更多` 菜单失焦、点击菜单项或按 Escape 后关闭。 +- [x] 按钮视觉从“英文 icon 名 + 中文文字”修正为图标主导、短文字辅助;不得把 `palette/sliders/layout` 这类内部 icon key 作为可见正文。 +- [x] Smoke 断言 toolbar 高度不超过 72px,`toolbarRows <= 1` 或等价 DOM 断言通过。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/01-toolbar-single-row.png`,肉眼能看到 toolbar 单行而不是三行。 +- [x] 验证:`cd /mnt/Data1T/mnote/design/05-editor-mainline/reference-code/leptos-tiptap/tiptap && npm run typecheck && npm run build` +- [x] 验证:`cd /mnt/Data1T/mnote/wolai-frontend && node scripts/build-leptos-tiptap-island.js` +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage toolbar` + - 2026-05-11 通过:桌面 toolbar `height=56`、`toolbarRows=1`;窄宽度 toolbar `height=56`、`toolbarRows=1`,并产生 `overflowActions`;Escape 后 `moreOpen=false` 且 `toolbarRows=1`。 + +## 5. 全屏与大画布模式 + +目标:至少提供 KMind/simple-mind-map 级别的全屏按钮与状态。优先做 block/canvas fullscreen,随后再补 page fullscreen。 + +### Task 4: 增加 Fullscreen Action Contract + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-action-map.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-action-map.test.ts` + +- [x] 新增 action:`fullscreenCanvas`,对应 lx-doc 的“全屏查看”。 +- [x] 新增 action:`fullscreenPage`,对应 lx-doc 的“全屏编辑”,第一阶段先作为 schema/action contract 保留。 +- [x] 新增 action:`exitFullscreen`。 +- [x] `fullscreenCanvas/fullscreenPage/exitFullscreen` 均标记为 `localView`,不得产生 kernel command。 +- [x] `Fullscreen API` 不可用时,action disabled,并在 UI 有稳定 `data-disabled-reason="fullscreen-unavailable"`。 +- [x] 单测覆盖 fullscreen action 不依赖 active node,readonly 下仍可使用。 +- [x] 验证:`cd /mnt/Data1T/mnote/wolai-frontend && pnpm test -- mindmap-action-map mindmap-ui-state` + - 2026-05-11 通过:`mindmap-action-map.test.ts` 新增 fullscreen localView 合同与 readonly 断言;`mindmap-ui-state.test.ts` 断言 readonly/无 active node 下 fullscreen 仍可用。 + +### Task 5: 实现全屏按钮与 resize + +**Files:** +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` +- Modify: `rust/spikes/leptos-tiptap-spike/src/lib.rs` +- Modify: `wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] 底部 navigator 增加全屏图标按钮,默认显示 canvas fullscreen。 +- [x] 点击后对 `data-testid="mnote-mindmap-editor-root"` 或等价 canvas root 调用 Fullscreen API。 +- [x] 监听 `fullscreenchange`,退出时同步 shell state。 +- [x] fullscreen change 后调用 `mindMap.resize()` 或 bridge 暴露的 resize 方法,并居中或保持当前 view transform。 +- [x] 全屏时保持 toolbar/sidebar/navigator 浮动在画布上;不出现文档页滚动条错位。 +- [x] 全屏模式下 Escape 退出后,toolbar/sidebar/navigator 状态恢复到进入前状态。 +- [x] Smoke 断言点击全屏后 `document.fullscreenElement` 为 mindmap root 或其包含节点。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/02-fullscreen-canvas.png`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage fullscreen` + - 2026-05-11 通过:`fullscreenElementIsRoot=true`,`shellFullscreenActive=true`;Escape 退出后 `document.fullscreenElement === null` 且 `shellFullscreenActive=false`。 + +## 6. 鼠标移出隐藏 Chrome,点击恢复 + +目标:对齐 `/mnt/Data1T/mnote/tmp/image copy 82.png`。鼠标移出后隐藏 toolbar/sidebar/navigator 等菜单;鼠标重新移入不自动恢复;用户点击画布或显式按钮才恢复。 + +### Task 6: 实现 Chrome Visibility State Machine + +**Files:** +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` +- Modify: `rust/spikes/leptos-tiptap-spike/src/lib.rs` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] 在 mindmap root 上监听 pointer enter/leave/click,不依赖 document 全局 hover。 +- [x] pointer leave root 后进入 `hiddenByPointerLeave`,隐藏 toolbar、sidebar drawer、sidebar trigger、navigator、minimap;count 可保留或按 KMind 目标隐藏,需在 smoke 固定判定。 +- [x] pointer enter root 不改变 `hiddenByPointerLeave`。 +- [x] 点击画布空白区或节点后恢复 `visible`。 +- [x] 点击恢复后不触发误插入、不改变 active node,除非点击目标本身就是节点选择。 +- [x] 打开 `更多` 菜单或右侧 drawer 时,pointer leave 先关闭弹层,再隐藏 chrome,避免残留孤立菜单。 +- [x] fullscreen 模式与 hidden state 组合时,退出 fullscreen 不强制显示 chrome,除非进入 fullscreen 前是 visible。 +- [x] Smoke 操作:移动鼠标到 root 外 -> 断言 toolbar/sidebar/navigator hidden;移动回 root -> 仍 hidden;点击 root -> visible。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/03-chrome-hidden-after-leave.png`。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/04-chrome-restored-after-click.png`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage chrome-hide` + - 2026-05-11 通过:`sceneChromeVisibility/shellChromeVisibility` 从 `visible -> hiddenByPointerLeave -> hiddenByPointerLeave -> visible`;toolbar/sidebar/navigator 与截图状态一致。 + - 2026-05-11 补充通过:`fullscreen` stage 已覆盖 `visible -> enter fullscreen -> exit -> visible` 与 `hiddenByPointerLeave -> enter fullscreen -> exit -> hiddenByPointerLeave`,退出 fullscreen 不再强制显示 chrome。 + +## 7. 右侧详细设置栏与隐藏把手 + +目标:对齐 `/mnt/Data1T/mnote/tmp/image copy 83.png`。右侧不只是简化 tab,而是完整 panel drawer;触发条可以隐藏;隐藏后有把手可恢复。 + +### Task 7: 扩展 Sidebar Schema 到详细控件 + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-action-map.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.test.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-action-map.test.ts` + +- [x] Sidebar panel 增加 `kind`:`nodeStyle`、`baseStyle`、`theme`、`structure`、`outline`、`shortcutKey`、`settings`。 +- [x] Sidebar option 增加控件类型:`button`、`swatch`、`segmented`、`slider`、`numberInput`、`select`、`layoutCard`、`treeItem`、`toggle`。 +- [x] `structure` panel 定义布局卡片:逻辑结构图、思维导图、组织结构图、目录组织图、时间轴、鱼骨图。 +- [x] `theme` panel 定义主题卡片,至少包含 classic、classic4/KMind-like、simple、dark 入口。 +- [x] `nodeStyle` panel 定义节点填充、文字颜色、字号、加粗、斜体、形状、边框、线条颜色、线条宽度。 +- [x] `baseStyle` panel 定义连线风格、曲线/直线、彩虹线条、背景、节点间距、概要样式。 +- [x] `outline` panel 从 projection/runtime 派生树,不允许成为第二套树真相。 +- [x] `settings` 或 `shortcutKey` panel 第一阶段可显示只读内容,但需要在 schema 中有位置。 +- [x] 单测覆盖:每个 sidebar option 要么有 actionId,要么是只读控件;可写控件必须有 compat path 或 kernel command 映射。 +- [x] 验证:`cd /mnt/Data1T/mnote/wolai-frontend && pnpm test -- mindmap-ui-schema mindmap-action-map` + - 2026-05-11 通过:`mindmap-ui-schema.test.ts` 13 项通过;同轮 `mindmap-action-map.test.ts` 5 项通过。 + +### Task 8: 实现右侧 Trigger、Drawer、隐藏把手 + +**Files:** +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` +- Modify: `rust/spikes/leptos-tiptap-spike/src/lib.rs` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] 右侧 trigger 宽度对齐 KMind/simple-mind-map:约 60px,图标在上、文字在下。 +- [x] trigger active 状态使用蓝色强调条或蓝色文字,不再用整块按钮边框作为主要视觉。 +- [x] drawer 打开时宽度约 300px,右侧固定,覆盖画布,不挤压 runtime。 +- [x] drawer 顶部包含 panel 标题和关闭按钮。 +- [x] trigger 左侧或 drawer 边缘提供隐藏把手,点击后隐藏整个 trigger。 +- [x] 隐藏后保留一个小把手;鼠标移入不自动展开,点击把手才恢复。 +- [x] 点击 active trigger:若 drawer 已打开同一 panel,则关闭 drawer;若点击不同 panel,则切换 drawer 内容。 +- [x] 结构 panel 的布局卡片使用稳定尺寸,不能因文字或 hover 导致布局跳动。 +- [x] 右侧 drawer 打开时,底部 navigator 与 drawer 不重叠;必要时 navigator 向左避让或保持在 drawer 左侧。 +- [x] Smoke 断言:打开 `structure` panel 后可见标题“结构”,可见至少 6 个布局卡片,存在关闭按钮和隐藏把手。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/05-sidebar-structure-drawer.png`。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/06-sidebar-hidden-handle.png`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage sidebar` + - 2026-05-11 通过:`drawerWidth=300`,`title=结构`,`structureCardCount=6`;close/hide/restore 均通过。 + +### Task 9: 打通右侧设置到 Runtime/Kernel/Compat + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-action-map.ts` +- Modify: `wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts` +- Modify: `wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-command-diff.ts` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] `setLayout` 走 kernel command,并刷新 adapter projection。 +- [x] `setTheme` 走 kernel command,并刷新 adapter projection。 +- [x] 节点样式类 action 先走 runtime 预览,再以 `compatPayload.patch` 保存样式字段。 +- [x] 基础样式类 action 先走 runtime config/themeConfig,再以 `compatPayload.patch` 保存无法语义化字段。 +- [x] option 点击失败时显示 `command_failed` 或等价错误层,不能只改变 UI 本地状态。 +- [x] Smoke 点击结构卡片后 reload,断言 projection layout 保持。 +- [x] Smoke 点击主题卡片后 reload,断言 theme 保持。 +- [x] Smoke 点击节点样式后 reload,断言 compatPayload patch 可见或节点样式保留。 +- [x] 验证:`cd /mnt/Data1T/mnote/wolai-frontend && pnpm test -- mindmap-action-map simple-mind-map-bridge` +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage sidebar-actions` + - 2026-05-11 通过:`sidebarActions.beforeReload/afterReload` 均为 `layout=mindMap`、`theme=dark`、`rootFillColor=#dbeafe`;同时修正 metadata-only 本地 `put` 误分流,统一回到 `mindmap.command.apply -> mnote-web server-side apply -> mindmaps.put` 主链。 + +## 8. 底部 Navigator 图标化与 MiniMap/Search + +目标:对齐 KMind/simple-mind-map 底部右侧工具条。搜索不应长期占用输入框宽度;全屏、只读、小地图、缩放应统一成 icon/action。 + +### Task 10: Navigator Schema 与 UI 重排 + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] Navigator item 改为图标按钮为主:回根、搜索、小地图、只读/编辑、全屏、缩小、缩放值、放大、设置。 +- [x] 搜索默认只显示图标;点击后展开输入框;再次点击或 Escape 收起。 +- [x] 缩放值允许输入百分比;非法输入恢复上一次有效值。 +- [x] 小地图打开后显示在 navigator 上方或右下安全位置,不遮挡 drawer。 +- [x] 只读状态显示明确 active 状态,并同步 `mindMap.setMode("readonly" | "edit")`。 +- [x] Count 固定在左下角,文本保持简短:`字数 17`、`节点 4`。 +- [x] Smoke 断言默认 navigator 没有常驻搜索输入框;点击搜索后输入框出现。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/07-navigator-icons.png`。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/08-search-expanded.png`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage navigator` + - 2026-05-11 通过:默认 `searchOpen=false`、无常驻输入框;展开搜索后截图已保存;最终 `minimapOpen=true`、`readonly=true`、非法缩放输入恢复为 `100%`。 + +## 9. Context Menu 与快捷键基础对齐 + +目标:当前右键菜单已有第一阶段能力,但要对齐 KMind/simple-mind-map 的禁用状态、显示位置和隐藏行为。 + +### Task 11: Context Menu Parity + +**Files:** +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-action-map.ts` +- Modify/Create: `rust/spikes/leptos-tiptap-spike/src/mindmap_shell.rs` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] 区分节点右键菜单与画布右键菜单。 +- [x] 节点菜单包含插入子节点、插入同级、删除、展开/收起、概要、关联线、复制文本。 +- [x] 画布菜单包含回根、适应画布、搜索、只读切换、显示菜单。 +- [x] root/generalization 等特殊节点禁用不适用 action。 +- [x] 右键菜单打开时 pointer leave 不立即隐藏 chrome;点击菜单项、Escape、点击画布空白后关闭。 +- [x] 菜单位置不能超出 mindmap root 边界。 +- [x] Smoke 断言节点右键菜单与画布右键菜单的 action 列表不同。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/09-node-context-menu.png`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage context-menu` + - 2026-05-11 通过:节点菜单仅包含 node actions,root 节点 `insertSiblingAfter/deleteNode` 为 disabled;画布菜单为 `centerRoot/fitView/search/readonly/showMenu`;pointer leave 后菜单与 chrome 保持可见,Escape 后关闭。 + +## 10. KMind 视觉基线 + +目标:不要只实现功能按钮,要让默认观感接近 KMind/simple-mind-map 工作台。 + +### Task 12: 默认 Theme/Layout 视觉对齐 + +**Files:** +- Modify: `rust/crates/bridge-runtime/src/lib.rs` +- Modify: `wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts` +- Modify: `wolai-frontend/src/lib/mindmap/mindmap-projection.ts` +- Modify: `scripts/task167-mindmap-kmind-parity-smoke.js` + +- [x] 默认 root 节点使用红色/橙红色背景、白色粗体文字,接近 KMind 截图。 +- [x] 默认二级节点使用蓝色背景、白色文字。 +- [x] 分支主题使用蓝色文字,概要括号线使用红色或主题强调色。 +- [x] 默认 layout 选择与 KMind 截图一致的右向逻辑结构。 +- [x] 连线位置不再错位;节点中心线、概要括号线和子节点垂直中心对齐。 +- [x] Smoke 读取 canvas/svg 或截图像素,确认节点和连线非空、可见、位置不重叠。 +- [x] Screenshot:`tmp/task167-mindmap-kmind-parity-smoke/10-kmind-theme-baseline.png`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js --stage theme` + - 2026-05-11 通过:runtime 默认 `layout=logicalStructure`、`theme=default`,`themeConfig` 生效为 root 红底白字、二级蓝底白字、分支蓝字、红色概要线;smoke 读取到 `nodeCount=5`、`pathCount=9`、`overlaps=0`。 + +## 11. 验证体系 + +### Task 13: 新增 KMind Parity Smoke + +**Files:** +- Create: `scripts/task167-mindmap-kmind-parity-smoke.js` +- Output: `tmp/task167-mindmap-kmind-parity-smoke/result.json` +- Output: `tmp/task167-mindmap-kmind-parity-smoke/*.png` + +- [x] 启动前检查 `http://127.0.0.1:3000/` 可用,不强制重启已存在服务。 +- [x] 使用默认测试账号登录。 +- [x] 新建或打开临时文档,插入 mindmap block。 +- [x] 断言 `simple-mind-map` runtime 存在,canvas rect 非零。 +- [x] 断言 Leptos/Rust shell 来源为 `data-ui-shell-source="leptos-rust-shell"`。 +- [x] 断言 toolbar 单行。 +- [x] 断言 fullscreen 按钮存在并可进入/退出。 +- [x] 断言 pointer leave 隐藏 chrome、pointer enter 不恢复、click 恢复。 +- [x] 断言右侧 drawer 可打开、关闭、隐藏 trigger、点击把手恢复。 +- [x] 断言 navigator 搜索按需展开,小地图可打开。 +- [x] 断言 reload 后 layout/theme/view/compat patch 不丢。 +- [x] 输出 `result.json`,至少包含 `ok`、`baseUrl`、`documentId`、`mindmapId`、`toolbarRows`、`fullscreenOk`、`chromeHideOk`、`sidebarDrawerOk`、`navigatorOk`、`screenshots`。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task167-mindmap-kmind-parity-smoke.js` + - 2026-05-11 通过:默认执行 `all` stage,`result.json` 输出 `ok/baseUrl/documentId/mindmapId/toolbarRows/fullscreenOk/chromeHideOk/sidebarDrawerOk/navigatorOk/contextMenuOk/themeOk/reloadOk/screenshots`,截图 01-10 全量生成。 + +### Task 14: 回归现有 Phase 6 Smoke + +**Files:** +- Modify: `scripts/task166-mindmap-phase6-block-smoke.js` only if needed + +- [x] `task167` 新增后,`task166` 继续保持 runtime/projection/command/reload 基础验证,不与视觉 parity 重复过多。 +- [x] `task166` 不因 toolbar 单行、drawer、fullscreen 变化而误判旧 testid 缺失。 +- [x] `task166` 与 `task167` 输出目录分离。 +- [x] 验证:`cd /mnt/Data1T/mnote && node scripts/task166-mindmap-phase6-block-smoke.js` + - 2026-05-11 通过:`task166` 保持基础链路验证,兼容 navigator 搜索折叠与 zoom 输入框;`result.json` 输出在 `tmp/task166-mindmap-phase6-block-smoke/`,与 `task167` 分离。 + +## 12. 执行顺序建议 + +建议按以下顺序执行,避免先做 CSS 后返工状态模型: + +1. Task 1:状态模型。 +2. Task 2-3:单行 toolbar 与更多菜单。 +3. Task 4-5:全屏。 +4. Task 6:chrome hide/click restore。 +5. Task 7-9:右侧详细设置栏与持久化。 +6. Task 10:navigator 图标化。 +7. Task 11:context menu。 +8. Task 12:视觉主题与连线对齐。 +9. Task 13-14:smoke 与回归。 + +每次实现完成后,至少保存对应截图,再勾选节点。 + +## 13. 阶段验收标准 + +本 checklist 视为完成时,必须同时满足: + +- [x] `/mnt/Data1T/mnote/tmp/task167-mindmap-kmind-parity-smoke/01-toolbar-single-row.png` 显示单行 toolbar。 +- [x] `/mnt/Data1T/mnote/tmp/task167-mindmap-kmind-parity-smoke/02-fullscreen-canvas.png` 显示全屏画布与浮动 chrome。 +- [x] `/mnt/Data1T/mnote/tmp/task167-mindmap-kmind-parity-smoke/03-chrome-hidden-after-leave.png` 显示鼠标移出后的隐藏状态。 +- [x] `/mnt/Data1T/mnote/tmp/task167-mindmap-kmind-parity-smoke/05-sidebar-structure-drawer.png` 显示详细右侧结构面板。 +- [x] `/mnt/Data1T/mnote/tmp/task167-mindmap-kmind-parity-smoke/07-navigator-icons.png` 显示图标化底部 navigator。 +- [x] `node scripts/task166-mindmap-phase6-block-smoke.js` 通过。 +- [x] `node scripts/task167-mindmap-kmind-parity-smoke.js` 通过。 +- [x] `pnpm test -- mindmap-ui-schema mindmap-action-map mindmap-ui-state simple-mind-map-bridge` 通过。 +- [x] `npm run typecheck && npm run build` 在 `design/05-editor-mainline/reference-code/leptos-tiptap/tiptap` 通过。 +- [x] Rust `page.body.save` 主链保存 `mindmap` block 后,`/api/documents/content` 读回仍为 `type: "mindmap"`,不再退化成 `paragraph`。 + - 2026-05-12 通过:新增 `cargo test -p core-protocol preserves_mindmap_paragraph_placeholder`、`cargo test -p core-protocol tiptap_mindmap_placeholder_round_trip_preserves_mindmap_attrs`、`cargo test -p bridge-runtime documents_save_command_plan_preserves_mindmap_placeholder`;同时在真实 `http://127.0.0.1:3000` 上手工验证 `content[0].type === "mindmap"` 且 `pageSubtree.subtree.nodes[1].metadata.blockType === "mindmap"`。 +- [x] `GET /documents/{documentId}?workspaceId=...` 对有效导图文档返回 HTML 页面壳,而不是 `documents.content.get 未返回文档内容` 的错误 JSON。 + - 2026-05-12 通过:在前台 `mnote-web` 实例上重新创建临时导图文档后复测,返回 `200 text/html; charset=utf-8`,首屏 HTML 正常包含 document shell。 +- [x] 3000 文档页默认主链仍为 Leptos/Rust shell,不加载旧 React mindmap 主链。 + +## 14. 明确延期项 + +以下能力可参考 KMind,但不进入本 checklist 的完成条件: + +- 多根节点。 +- MOC 模式。 +- 思源块预览、镜像块、PDF 标注跳转。 +- Freemind/XMind 全量导入导出。 +- 主题设计器与主题分享。 +- 完整快捷键自定义配置。 +- 演示模式。 +- Rust-native renderer。 diff --git a/design/09-siyuan-reference/process/9-siyuan-reference-boundary-and-adoption-v1.md b/design/09-siyuan-reference/process/9-siyuan-reference-boundary-and-adoption-v1.md new file mode 100644 index 00000000..65553394 --- /dev/null +++ b/design/09-siyuan-reference/process/9-siyuan-reference-boundary-and-adoption-v1.md @@ -0,0 +1,362 @@ +# 9 [process] SiYuan 参考边界与可借鉴能力 v1 + +> 更新时间:2026-05-11 +> +> 上位依据: +> - `/mnt/Data1T/mnote/ARCHITECTURE.md` +> - `/mnt/Data1T/mnote/design/01-05-current-priority-overview.md` +> - `/mnt/Data1T/mnote/design/01-tree-first-graph-kernel/process/1-tree-first-graph-kernel-v1.md` +> - `/mnt/Data1T/mnote/design/03-rust-web/process/3-rust-web-long-term-architecture-v1.md` +> - `/mnt/Data1T/mnote/design/03-rust-web/process/3-3-rust-web-tree-realtime-event-stream-v1.md` +> - `/mnt/Data1T/mnote/design/05-editor-mainline/process/5-5-page-aggregate-single-truth-alignment-v1.md` +> - `/mnt/Data1T/mnote/design/06-mindmap/process/6-mindmap-kernel-phase6-projection-editor-v1.md` +> +> 外部参考: +> - `https://github.com/siyuan-note/siyuan` +> - `https://raw.githubusercontent.com/siyuan-note/siyuan/master/README_zh_CN.md` +> - `https://raw.githubusercontent.com/siyuan-note/siyuan/master/API_zh_CN.md` +> +> 本稿定位: +> - 本稿是 `mnote` 的参考与借鉴边界稿。 +> - 本稿不是新的上位架构来源。 +> - 本稿不覆盖 `01-05` 当前主线优先级。 + +## 1. 文档目的 + +这份稿只回答一个问题: + +> **思源笔记对当前 `mnote` 主线,哪些地方值得参考,哪些地方不应照搬。** + +当前结论固定为: + +> **思源更适合作为产品能力与交互参考,不适合作为 `mnote` 长期架构模板。** + +原因不是思源做得不成熟,而是两边长期目标不同: + +- 思源更接近 `本地优先工作空间 + 块文档 + Go kernel + TS/Electron 产品壳` +- `mnote` 当前主线是 `tree-first graph kernel + Rust 持有语义 + Page Aggregate / Tree Realtime / Tree Command 收口` + +因此,后续引用思源时必须先区分: + +1. 是在参考产品层能力 +2. 还是在引入架构层真相 + +只有第一类默认允许,第二类默认不允许。 + +--- + +## 2. 先给结论 + +### 2.1 思源值得参考的层级 + +思源当前最值得参考的是: + +- 块级引用、双向链接、反链、图谱、大纲这一整套产品能力的配套闭环 +- 属性 / 数据库视图的用户心智、操作颗粒度和投影形态 +- 本地优先工作区的数据组织、导入导出、资源目录和恢复路径 +- 大体量单机笔记产品的交互密度、功能面排布和“一个能力带一圈配套能力”的产品完成度 +- 编辑器相关的局部交互细节,以及导图插件这一类挂件的集成方式 + +### 2.2 思源不应成为 `mnote` 的长期架构模板 + +思源当前不应被拿来直接替代或覆盖: + +- `tree-first graph kernel` +- `Rust kernel` 的语义主导权 +- `mnote-web` 作为 `3000` 主执行面 +- `Page Aggregate` 作为页面域单一真相收口方向 +- `tree.*` 正式命令面与 `tree events` realtime 主链 + +一句话收口: + +> **思源可以提供“功能长什么样”的答案,但不能替代 `mnote` 对“系统真相由谁持有”的既定答案。** + +--- + +## 3. 为什么会觉得像思源 + +用户会感觉当前实现和思源接近,并不是错觉,主要有下面这些原因: + +- 都是块式文档体验,而不是传统线性文档页 +- 都强调页面树、块引用、双向链接、嵌入、导图或挂件类能力 +- 都不是纯 Markdown 文件列表产品,而是更接近“知识对象 + 多视图”的产品 +- 都会同时出现页面、块、资源、搜索、反链、图谱、数据库视图这些能力面 + +但相似主要停留在产品表层,不等于底层事实源一致。 + +当前两边关键差异是: + +- 思源偏 `workspace/data + .sy + API + 本地工作区` +- `mnote` 偏 `kernel truth + projection + command + realtime stream` + +这条差异决定了: + +> **参考思源时,应优先借它的产品形态,不要把它的数据真相层和 API 哲学直接搬进来。** + +--- + +## 4. 思源当前可见的能力面 + +从公开仓库、README 和 API 可见,思源不是“只有一个块编辑器”,而是已经形成下面这些稳定能力面: + +- 块:插入、更新、删除、移动、折叠、展开、块引用 +- 属性:块属性读写 +- SQL:查询与事务刷新 +- 属性视图 / 数据库视图:表格、看板、画廊等 +- 大纲、反链、图谱、搜索 +- 工作空间、文件树、资源文件、模板、插件、代码片段 +- 历史、同步、导出、剪藏、闪卡、OCR、AI、移动端与 Docker + +这说明思源真正有参考价值的不是某个单点组件,而是: + +> **当一个系统把“块”作为核心对象后,周边需要跟着长出来的整圈配套能力。** + +--- + +## 5. 可直接借鉴的部分 + +## 5.1 块级引用不是单点功能,而是一整圈产品能力 + +思源把块级引用、双向链接、反链、搜索、图谱、大纲做成了互相咬合的一组能力。 + +对 `mnote` 的启发不是“做一个 `((block))` 就够了”,而是: + +- 一旦有块引用,就应该有稳定的引用目标解析 +- 一旦有引用目标解析,就应该有反链和搜索投影 +- 一旦有反链和搜索投影,就应该考虑页面页头、阅读态、导图、AI 上下文如何共享这一组对象语义 + +这与当前 `mnote` 主线是相容的,因为这些都应该继续落到 Rust projection family,而不是前端各自维护一份块真相。 + +## 5.2 属性视图 / 数据库视图值得作为单独对象域评估 + +思源已经证明: + +- 属性不是补充字段 +- 数据库视图也不是“在文档里画个表格”就结束 + +它更接近: + +- 对象属性定义 +- 多视图投影 +- 排序 / 分组 / 过滤 / relation / rollup 一组相关语义 + +对 `mnote` 的启发是: + +> **如果后续做属性视图,不应只把它当成编辑器里的一个特殊块,而应评估它是否需要独立的 kernel object / projection / command family。** + +这里可以借思源的产品心智,但不要直接借它的存储组织。 + +## 5.3 本地工作区组织与导入导出心智值得参考 + +思源 README 明确公开了工作空间 `data/` 下的目录组织,例如: + +- `assets` +- `templates` +- `snippets` +- `plugins` +- `public` +- 文档与笔记本目录 + +这对 `mnote` 的参考价值主要在用户体验层: + +- 本地导出时,哪些内容算“工作区资产” +- 用户如何理解模板、资源、插件与公开文件 +- 发生故障时,用户该如何备份与迁移 + +这里适合作为: + +- 本地文件夹体验 +- 导入导出 UX +- 恢复与备份说明 + +的参考,不适合作为新的 canonical source。 + +## 5.4 导图与插件化挂件有参考意义 + +当前 `mnote` 已经在 `design/05-editor-mainline/reference-code/` 下保留了 `siyuan-kmind-plugin` 参考代码,这个方向是合理的。 + +对导图线的正确借法是: + +- 参考思源插件 / KMind 的 UI、行为、挂件边界 +- 参考其与文档块、引用预览、搜索、资源插入的交互方式 +- 不复制它的思源宿主耦合 + +这与当前 `Phase 6` 已经明确的口径一致: + +> **可以参考 KMind 的 UI 与行为,但不要复制它的思源插件耦合。** + +## 5.5 “成熟单机笔记产品的密度”本身值得参考 + +思源的一个重要价值,不是某个 API,而是它已经证明: + +- 用户愿意接受高密度功能面 +- 页面 / 树 / 搜索 / 反链 / 数据库 / 插件 / 导出 / 历史可以共存 +- 关键不在于功能少,而在于对象边界和入口是否清晰 + +这对 `mnote` 的启发是: + +> **后续不需要因为主线在收口,就把能力面理解成必须长期极简;真正要避免的是语义散乱,而不是能力丰富。** + +--- + +## 6. 不建议照搬的部分 + +## 6.1 不照搬 `.sy + 工作空间文件` 作为系统真相层 + +思源的数据组织很适合它自己的本地优先单机模型,但 `mnote` 当前已经明确: + +- `tree-first graph kernel` 是长期对象真相层 +- `Convex` 继续保留为当前存储 / 实时 / 文件协作底座 +- `mnote-web` 与 Rust kernel 持有主执行语义 + +因此后续即使增加本地文件夹能力,也不能把: + +- 工作空间目录结构 +- 导出文件形状 +- 调试缓存 + +误提升为新的系统真相层。 + +## 6.2 不把 SQL 暴露成长期核心产品契约 + +思源公开提供 SQL 查询接口,这很适合本地单机高级用户,但对 `mnote` 有明显风险: + +- 会绕开 `projection` 与 `command` 边界 +- 会破坏页面域和树域单一真源收口 +- 会让 AI、CLI、前端和脚本各自形成第二套数据读取口径 + +所以对 `mnote` 来说,正确借法是: + +- 借“高级查询能力”这个需求 +- 不借“把底层 SQL 直接暴露为长期主接口”这个做法 + +若未来需要高级查询,应优先考虑: + +- kernel query family +- projection query endpoint +- 受控 DSL + +而不是直接给业务面开放底层 SQL。 + +## 6.3 不把前端运行时做成第二语义中心 + +思源前端 `protyle` 与周边 TS runtime 很大,说明它有相当一部分产品组织与交互复杂度留在前端。 + +这对当前 `mnote` 不是该追的方向,因为你们当前最重要的事是: + +- 继续收口 `Page Aggregate` +- 继续收口 `tree command` +- 继续收口 `tree realtime` + +因此不应因为参考思源,就重新把: + +- 标题语义 +- 页面设置语义 +- 引用解析语义 +- 数据库视图真相 + +重新扩散到前端壳层或 compat 层。 + +## 6.4 不默认接受它的单用户 / 本地优先假设 + +思源大量设计天然偏: + +- 单机优先 +- 工作空间文件优先 +- 用户直接接触本地数据目录 + +而 `mnote` 当前仍保留: + +- Convex 自托管底座 +- realtime 协作链 +- Rust Web `3000` 主入口 + +因此参考思源时必须先问: + +> **这个能力是在单用户前提下成立,还是在当前 `mnote` 的协作 / realtime 前提下也能成立。** + +只在前者成立的方案,默认不能直接进入主线。 + +--- + +## 7. 对 `mnote` 的建议落点 + +| 参考主题 | 是否建议借鉴 | 推荐落点 | +| --- | --- | --- | +| 块级引用 / 双向链接 / 反链 | 建议 | Rust query / projection family,统一到 page/tree 相关投影 | +| 属性视图 / 数据库视图 | 建议 | 先做对象域评估,再决定 command / projection 边界 | +| 图谱 / 大纲 / 搜索 | 建议 | 作为引用体系的配套视图,而不是孤立功能 | +| 工作区导出 / 资源目录 / 模板心智 | 建议 | 本地文件夹、导出导入、恢复与帮助文档 | +| 导图插件交互 | 建议 | 继续作为 `leptos-mindmap` 的参考行为层 | +| `.sy` 文档真相层 | 不建议 | 不进入 `mnote` 主线 | +| SQL 直接开放给产品层 | 不建议 | 改用 kernel query / projection / DSL | +| 前端重语义运行时 | 不建议 | 继续把长期语义收口到 Rust kernel | +| 单机假设下的 API 组织 | 谨慎 | 只借需求,不借真相层与执行面 | + +--- + +## 8. 当前优先级下的使用方式 + +考虑到当前 `mnote` 的第一优先级仍然是: + +1. `Page Aggregate` +2. `Tree Command Cutover` +3. `Tree Realtime Event Stream` + +所以本稿的执行口径应固定为: + +### 8.1 允许用思源来校准需求 + +例如: + +- 块引用之后,用户预期还需要什么 +- 反链页、图谱页、搜索页应该有哪些最小能力 +- 属性视图第一版做成什么形态才不失真 +- 导出与本地资源管理要不要显式工作区概念 + +### 8.2 不允许用思源来打断当前收口顺序 + +例如不能因为思源已有某个能力,就跳过: + +- `Page Aggregate` 的主链闭环 +- `tree.*` 命令统一 +- `/api/tree/events` live cache 收口 + +否则会把参考稿误用成新的需求插队入口。 + +### 8.3 参考思源时优先写成“能力映射”,不要写成“照搬实现” + +后续如果再新增思源相关设计稿,优先采用: + +- “思源某能力对 `mnote` 的需求映射” +- “思源某交互对 `mnote` 的行为对照” + +而不是: + +- “把思源 API / 数据格式搬进来” +- “按思源目录结构重建 `mnote`” + +--- + +## 9. 当前建议的后续拆分 + +如果后续继续使用思源作为参考,建议只沿下面几个方向继续出稿: + +1. `块引用 / 反链 / 图谱 / 搜索` 的能力映射稿 +2. `属性视图 / 数据库视图` 的对象域评估稿 +3. `本地工作区 / 导入导出 / 资源目录` 的 UX 参考稿 +4. `导图插件 / 挂件 / 引用预览` 的行为对照稿 + +不建议出的稿: + +1. “按思源重写 `mnote` 数据层” +2. “引入思源式 SQL 主接口” +3. “以思源前端 runtime 替代当前 Rust 主线” + +--- + +## 10. 一句话收口 + +当前 `mnote` 对思源的正确态度应固定为: + +> **把思源当成成熟块知识产品的参考样本库,重点吸收它的能力面、交互完成度和配套闭环;但 `mnote` 的长期事实源、命令面、projection 与 realtime 主链,继续严格沿 `tree-first graph kernel` 推进。** diff --git a/design/10-review/01-rust-kernel-web-review.md b/design/10-review/01-rust-kernel-web-review.md new file mode 100644 index 00000000..51a18cdc --- /dev/null +++ b/design/10-review/01-rust-kernel-web-review.md @@ -0,0 +1,119 @@ +# Rust Kernel / Web 实现偏差审查 + +## 范围 + +本次只审查 Rust kernel / protocol / bridge-runtime / mnote-web / storage-convex-bridge 与当前设计主线的一致性。 + +重点对照设计: + +- `ARCHITECTURE.md` +- `design/01-05-current-priority-overview.md` +- `design/01-tree-first-graph-kernel/process/1-tree-first-graph-kernel-v1.md` +- `design/01-tree-first-graph-kernel/process/1-1-tree-first-graph-kernel-checklist-v2.md` +- `design/02-convex-rust-long-term-architecture/process/2-tree-first-graph-convex-rust-long-term-architecture-v1.md` +- `design/03-rust-web/process/3-rust-web-long-term-architecture-v1.md` +- `design/03-rust-web/process/3-1-rust-web-long-term-checklist-v2.md` +- `design/03-rust-web/process/3-3-rust-web-tree-realtime-event-stream-v1.md` +- `design/03-rust-web/process/3-15-runtime-fallback-retirement-checklist-v1.md` +- `design/04-tree-domain/done/4-6-tree-command-protocol-cutover-stage2-v1.md` + +重点代码: + +- `rust/crates/core-protocol/` +- `rust/crates/core-domain/` +- `rust/crates/bridge-runtime/` +- `rust/crates/mnote-web/` +- `rust/crates/storage-convex-bridge/` + +## 结论 + +Rust kernel / protocol / bridge-runtime / mnote-web 的主干方向与当前设计基本一致:`core-protocol` 已有统一 kernel node / edge / projection / page aggregate 协议;`bridge-runtime` 已能执行 kernel query / command / projection;`mnote-web` 已持有 3000 主入口、文档页 shell、`/api/page-aggregate/:id`、tree command、`/api/tree/events`、Search shell 等关键接缝;`storage-convex-bridge` 明确把 `tree.*` / `page.*` 等语义命令映射到底层 Convex mutation。 + +主要偏差不是“Rust 主线没有落地”,而是当前仍存在几类收口缺口: + +1. 部分 Rust Web 主路径仍会静默合成 fallback / fixture 数据,和 `Runtime Fallback 退场` 的激进口径不完全一致。 +2. Page Aggregate 对外标记为 `KernelProjection`,但 Rust Web 仍先取 `documents.meta/content` 再在 runtime 内拼成聚合;这是合理过渡实现,但“单一 kernel 真源”口径容易被写得过满。 +3. Tree realtime 已有正式 SSE 主链,但实现仍偏轮询 bridge overview,WS 仍是 snapshot/resync 骨架,尚未成为完整实时主链。 +4. Legacy / compat 能力默认大多关闭,但配置位、proxy 辅助函数和兼容源枚举仍在,设计文档中“全部退场”的勾选状态可能偏乐观。 + +## 关键发现表格 + +| 编号 | 分类 | 严重度 | 发现 | 证据 | +| --- | --- | --- | --- | --- | +| RK-01 | 未完成 | 中 | Kernel projection 仍主要从 `sidebar.dataset.list` 这一份 Convex 数据集构建,广义 node pool / reference edge / summary/index 真相层尚未完全独立。 | `rust/crates/mnote-web/src/routes/snapshot_support.rs:27` 定义 `sidebar.dataset.list`;`:93` 先加载 sidebar dataset 再执行 `kernel.project_view`;`rust/crates/bridge-runtime/src/lib.rs:8010` 后续由 sidebar 数据构建 subtree;`:8111` 再转为 projection。 | +| RK-02 | 实现偏差 / 风险 | 高 | Rust Web 主路径仍存在静默 fallback:workspace shell 在 projection 加载失败时无条件合成最小 workspace/documents;sidebar/filetree 在 `allow_dev_fixtures` 时合成开发数据;Search 在 Convex query 失败时返回内置搜索数据。这与 `3-15-runtime-fallback-retirement` 的“默认不再 fallback”口径冲突。 | `rust/crates/mnote-web/src/routes/web_shell.rs:2379` 到 `:2401` 无条件 fallback 最小 dataset;`:2432` 到 `:2461` 合成 sidebar dev dataset;`:2493` 到 `:2519` 合成 filetree dev dataset;`rust/crates/mnote-web/src/routes/search.rs:233` 到 `:247` 搜索失败后走 `fallback_search_dataset`。 | +| RK-03 | 方向变化 / 文档滞后 | 中 | Page Aggregate 已由 Rust Web 暴露正式 route,但实现仍是先读 `documents.meta/content`,再把 joined data 交给 `page.aggregate.get` 生成 projection。代码对外 source 标成 `KernelProjection`,但底层仍是 meta/content join 的迁移形态;需要文档明确这是 Rust runtime adapter,而非完整 kernel storage 真源。 | `rust/crates/mnote-web/src/routes/web_shell.rs:2282` 到 `:2315` 先读 meta/content 再执行 `page.aggregate.get`;`rust/crates/bridge-runtime/src/lib.rs:8246` 到 `:8253` 将 source 传为 `PageAggregateSource::KernelProjection`;`:5303` 到 `:5324` 从 meta/content 中抽取 title/content/revision。 | +| RK-04 | 未完成 | 中 | Tree realtime 正式 route 已存在,但当前 SSE 仍通过 polling `bridge.workspace.overview` 生成 snapshot/delta/resync;WS 只发送初始 snapshot,并只支持客户端请求 resync,不是完整主实时链路。 | `rust/crates/mnote-web/src/routes/sse.rs:51` 到 `:91` 循环 sleep/poll overview 后生成 delta;`rust/crates/mnote-web/src/routes/ws.rs:32` 发送 snapshot,`:40` 到 `:80` 只处理 resync 或 unsupported ack。 | +| RK-05 | 风险 / 文档滞后 | 低 | Legacy Next compat 默认关闭,但代码仍保留 env-gated proxy 能力、Next proxy 辅助函数和 compat 配置位。若文档继续写“legacy compat 已删除”,会与代码事实不一致;若保留,应写成显式调试/迁移边界。 | `rust/crates/mnote-web/src/app.rs:42` 到 `:54` 仍读取 `MNOTE_WEB_LEGACY_NEXT_BASE_URL` / `MNOTE_WEB_ENABLE_LEGACY_NEXT_COMPAT`;`rust/crates/mnote-web/src/routes/gateway.rs:86` 到 `:87` auth API 可转 legacy proxy;`:402` 到 `:499` legacy proxy 实现仍在;`rust/crates/mnote-web/src/routes/documents.rs:153` 当前 `should_proxy_via_next` 返回 false,但 Next proxy helper 仍保留。 | +| RK-06 | 实现一致 | 低 | Tree command cutover Stage 2 的长期命名面已在 Rust route / bridge / storage mapping 中落地,`documents.*` 仍作为 alias/底层 Convex mutation 名称存在,和 Stage 2A/2B 过渡口径基本一致。 | `rust/crates/storage-convex-bridge/src/mapping.rs:37` 到 `:43` 映射 `tree.*`;`:52` 到 `:68` 保留 `documents.*` / `page.*` alias;`rust/crates/mnote-web/src/tree_shell/dispatcher.rs:16` 到 `:23` 使用 `tree.*`;`rust/crates/mnote-web/src/routes/tree.rs:7634` 附近测试确认 documents alias 映射仍存在。 | +| RK-07 | 实现一致 | 低 | Debug shell 默认关闭,符合 `3104`/debug 壳默认退场口径。 | `rust/crates/mnote-web/src/routes/mod.rs:120` 到 `:124` 仅在 `enable_debug_shell_routes` 时挂 `/tree` 和 `/document-debug`;同文件测试 `:142` 到 `:184` 验证默认 404。 | + +## 证据 + +### 1. Kernel / projection 已落地,但底层仍主要基于 sidebar dataset + +- `rust/crates/core-protocol/src/kernel.rs:7` 到 `:42` 定义 `KernelNodeType`、`KernelEdgeType`、`KernelProjectionKind`。 +- `rust/crates/mnote-web/src/routes/kernel.rs:62` 到 `:85` 暴露 projection route,并经 `load_projection_snapshot` 获取投影。 +- `rust/crates/mnote-web/src/routes/snapshot_support.rs:27` 到 `:47` 固定 `sidebar.dataset.list` 为数据获取入口。 +- `rust/crates/bridge-runtime/src/lib.rs:8119` 到 `:8137` 在没有 root 时由当前数据构建 subtree,再生成 projection;`file_tree` 另走 `build_file_tree_projection_result`。 + +判断:这符合 `1-1` 中“真实主线已落地,但更广义 node pool/reference edge 仍后续”的口径,不应被写成“尚未开始”;也不应被写成“完整 kernel 真源已闭环”。 + +### 2. Runtime fallback 仍在主路径附近 + +- `rust/crates/mnote-web/src/routes/web_shell.rs:2379` 到 `:2401`:workspace shell projection 加载失败时合成 `active_workspace_id`、`workspaces`、`documents`。 +- `rust/crates/mnote-web/src/routes/web_shell.rs:2432` 到 `:2461`:`allow_dev_fixtures` 时合成 sidebar dev dataset。 +- `rust/crates/mnote-web/src/routes/web_shell.rs:2493` 到 `:2519`:`allow_dev_fixtures` 时合成 filetree dev dataset。 +- `rust/crates/mnote-web/src/routes/search.rs:233` 到 `:247`:搜索 Convex 查询失败后执行 `fallback_search_dataset(workspace_id)`。 + +判断:这与 `design/03-rust-web/process/3-15-runtime-fallback-retirement-checklist-v1.md` 的“默认运行时不再 fallback / 不静默降级”存在偏差。尤其 Search fallback 会产生看似真实的固定结果,风险高于空状态降级。 + +### 3. Page Aggregate 是 Rust route,但仍是迁移期 adapter + +- `rust/crates/mnote-web/src/routes/mod.rs:53` 到 `:56` 挂载 `/api/page-aggregate/{document_id}`。 +- `rust/crates/mnote-web/src/routes/web_shell.rs:2264` 到 `:2319` 构建 aggregate。 +- `rust/crates/bridge-runtime/src/lib.rs:5291` 到 `:5442` 从 meta/content 形状构建 `PageAggregateProjection`。 +- `rust/crates/core-protocol/src/page_aggregate.rs:4` 到 `:10` 协议层仍保留 `KernelProjection`、`CompatMetaContentJoin`、`Fixture` 三种 source。 +- `rust/crates/mnote-web/src/page_aggregate/builder.rs:66` 默认 source 仍是 `CompatMetaContentJoin`,但当前检索未发现该 builder 进入主要 route 主路径。 + +判断:当前代码已摆脱 TS builder runtime 主链,但还不是“页面域全部直接来自独立 kernel storage 真源”。文档应保留“Rust-first Page Aggregate 过渡态”的精确口径。 + +### 4. Tree realtime 主链已成立,但不是完整实时闭环 + +- `rust/crates/mnote-web/src/routes/mod.rs:113` 挂载 `/api/tree/events`,`:114` 挂载 `/api/stream/events`,`:115` 挂载 `/api/realtime/ws`。 +- `rust/crates/mnote-web/src/routes/sse.rs:127` 到 `:146` 给 `/api/tree/events` 打 `x-mnote-web-owner: mnote-web` 与 `x-mnote-tree-stream-owner: rust-web`。 +- `rust/crates/mnote-web/src/routes/sse.rs:51` 到 `:91` 通过 sleep/poll bridge overview 发现变化。 +- `rust/crates/mnote-web/src/routes/ws.rs:32` 到 `:80` WebSocket 当前只发 snapshot,并响应 resync 请求。 + +判断:这与 `3-3` 中“已完成 route / snapshot / delta / resync 基础,WS 尚未成为主链,live cache 未完全统一”一致;若 `3-15` 写成 tree realtime 补偿链已完全删除,则偏乐观。 + +### 5. Compat / legacy 未成为默认主链,但未完全删除 + +- `rust/crates/mnote-web/src/app.rs:42` 到 `:54` 仍读取 legacy Next 相关环境变量,默认 `enable_legacy_next_compat` 为 false。 +- `rust/crates/mnote-web/src/routes/gateway.rs:86` 到 `:87` 在 compat 开启且配置 legacy base URL 时,`/api/auth` 可走 legacy proxy。 +- `rust/crates/mnote-web/src/routes/documents.rs:153` 当前 `should_proxy_via_next` 返回 false,说明文档 API 默认不走 Next proxy。 + +判断:代码实际状态更像“默认关闭、残留显式迁移/调试能力”,不是“所有 legacy proxy 代码已删除”。 + +## 建议优先级 + +### P0 + +- 移除或显式隔离 Search 的 `fallback_search_dataset`。失败时应返回明确错误或空 projection,并带可观测错误头;不要返回固定假结果。 +- 对 `load_workspace_shell_projection` 的无条件合成 dataset 做决策:若用于首屏容错,应在响应或 contract 中显式标记 degraded;若严格执行 fallback 退场,应改为失败或空树,不再伪装成真实 workspace projection。 + +### P1 + +- 将 `allow_dev_fixtures` 相关 fallback 全部加上更明确的 debug/dev 标识,并确认 `desktop:hot` / 3000 默认启动链不会误开。 +- 补一条 Rust Web smoke:Convex/query 不可用时,搜索、Sidebar、filetree 不应返回假业务数据。 +- Page Aggregate 文档补一句:当前 Rust route 已是主读链,但底层仍通过 Rust runtime adapter 消费 meta/content substrate;完整页面域单一真源仍在推进。 + +### P2 + +- Tree realtime 后续应把 SSE polling overview 与真正 domain event stream 的边界写清楚,并继续推进 page subtree / filetree / preferred snapshot 同一 live cache。 +- Legacy Next proxy 若仍需保留,建议统一命名为 explicit migration/debug boundary;若不再需要,后续单独删除 proxy helper、配置位和测试样例,避免和 `3-15` 的退场状态长期冲突。 +- `PageAggregateSource::CompatMetaContentJoin` / `Fixture` 是否继续保留在 `core-protocol` 需要架构决策:保留则标记为迁移态 source;删除则需先确认没有测试、local folder、fixture 依赖。 + +## 修改的文件路径 + +- `/mnt/Data1T/mnote/design/10-review/01-rust-kernel-web-review.md` diff --git a/design/10-review/02-frontend-editor-tree-review.md b/design/10-review/02-frontend-editor-tree-review.md new file mode 100644 index 00000000..ee71789a --- /dev/null +++ b/design/10-review/02-frontend-editor-tree-review.md @@ -0,0 +1,123 @@ +# 前端编辑器 / 树体验实现偏差审查 + +## 范围 + +本报告只审查 `wolai-frontend` 当前文档页、`leptos-tiptap` island host、`Page Aggregate` 消费链、Sidebar / tree shell / tree stream 与设计文档的一致性。 + +重点对照设计: + +- `ARCHITECTURE.md` +- `design/01-05-current-priority-overview.md` +- `design/04-tree-domain/done/4-sidebar-pagetree-filetree-rust-web-rebuild-v1.md` +- `design/04-tree-domain/done/4-2-sidebar-pagetree-filetree-product-interaction-contract-v1.md` +- `design/04-tree-domain/done/4-6-tree-command-protocol-cutover-stage2-v1.md` +- `design/04-tree-domain/done/4-18-tree-final-dom-shell-cutover-hard-gate-v1.md` +- `design/04-tree-domain/process/4-23-local-cloud-explicit-bridge-p3-candidate-v1.md` +- `design/05-editor-mainline/process/5-4-leptos-tiptap-mainline-correction-v1.md` +- `design/05-editor-mainline/process/5-5-page-aggregate-single-truth-alignment-v1.md` +- `design/05-editor-mainline/process/5-6-page-aggregate-alignment-checklist-v1.md` +- `design/05-editor-mainline/done/5-5-1-page-aggregate-contract-v1.md` + +重点读取代码: + +- `wolai-frontend/src/app/(app)/documents/` +- `wolai-frontend/src/components/editor/` +- `wolai-frontend/src/lib/documents/` +- `wolai-frontend/src/components/sidebar/` +- `wolai-frontend/src/lib/tree-stream/` +- `wolai-frontend/src/lib/documents/tree-command-client.ts` + +## 结论 + +当前实现总体方向与最新设计主线一致:文档页 SSR 入口已消费 Rust `mnote.page_aggregate.v1`,默认主编辑器已折返到页面内 `leptos_tiptap_island`,tree command 前端主调用已进入 `/api/tree/commands` + `tree.*` 元数据口径,Sidebar 的默认 tree shell 已切到 `rust_wasm_dom_shell_host`,并且 `iframe_srcdoc` 只在显式 legacy flag 下存在。 + +但不能把当前状态描述为“前端编辑器 / 树体验已经完全收口到 Rust 单一真源”。主要未完成点集中在三处:页面本地 aggregate reducer 仍承担临时真相与补偿选择,`pageSubtree` 在本地正文变更后会被置空而不是形成同一份可持续 projection,Sidebar 仍通过 initial / query / tree stream 三源 freshness 选择维持一致性。此外,部分页面设置仍明确是 `planned` / `downgrade`,属于设计清单中尚未完成的范围。 + +## 关键发现表格 + +| 编号 | 分类 | 严重度 | 发现 | 证据 | +| --- | --- | --- | --- | --- | +| F-01 | 未完成 | 中 | Page Aggregate 读链已 Rust-first,但客户端仍有本地 aggregate reducer 持有标题、正文、设置、子树快照等临时真相;设计中的“页面域单一真源”尚未闭环。 | `wolai-frontend/src/components/editor/page-aggregate-client-state.ts:7` 定义本地 `PageAggregateClientState`,包含 `serverPageTitle / persistedPageTitle / draftPageTitle / options / content / serverPageSubtreeSnapshot / contentRevision / conflictDetectionKey`;`wolai-frontend/src/components/editor/document-content.tsx:144` 使用 reducer 作为文档页核心状态。 | +| F-02 | 实现偏差 | 中 | `pageSubtree` 不是跟随本地正文和标题持续更新的 page projection;一旦本地正文对象与服务器快照不同,就直接返回 `null`,AI 面板和阅读结构面会失去这份 projection。 | `wolai-frontend/src/components/editor/page-aggregate-client-state.ts:163` 通过 `content === serverContentSnapshot` 判断;`wolai-frontend/src/components/editor/page-aggregate-client-state.ts:166` 只有未改动时返回 `serverPageSubtreeSnapshot`,否则 `:169` 返回 `null`;`wolai-frontend/src/components/editor/document-content.tsx:867` 将该选择结果作为 AI snapshot 的 `pageSubtree` 来源,`:1162` 也传给阅读视图。 | +| F-03 | 未完成 | 中 | Sidebar / Breadcrumb / 文档页头已共享 preferred snapshot,但 live cache 仍不是唯一来源;当前仍在 initial、query refetch、tree stream 之间做 freshness 选择。 | `wolai-frontend/src/components/app-layout-shell.tsx:20` 同时创建 `useSidebarData` 与 `useSidebarTreeStream`;`:22` 用 `usePreferredSidebarSnapshot` 选择;`wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.ts:29` 在 `query / tree_stream / initial` 间选择;`wolai-frontend/src/components/sidebar/sidebar.tsx:201` Sidebar 内部也消费同样选择结果。 | +| F-04 | 未完成 | 低 | 页面设置运行时语义已有代码级分类,但仍有正式 UI 中可见的 planned / downgrade 项;这与 `5-6` 清单中“页面设置未整体收口”的口径一致。 | `wolai-frontend/src/lib/documents/page-option-semantics.ts:60` 将 `protectEditing` 标记为 `planned`,`:84` 将 `showBlockRefCount` 标记为 `planned`;`wolai-frontend/src/components/editor/page-options-sidebar.tsx:416` 对 downgrade 项显示 `待接线`,`:71` 让 `showBlockRefCount` 成为不可交互占位。 | +| F-05 | 方向变化/文档滞后 | 低 | `5-5-1` 中仍写着 `showHeadingNumbers / embedDefaultBlockId` 只完成字段贯通,但当前代码已把它们纳入 island runtime payload;这里更像文档滞后,而不是实现偏差。 | `design/05-editor-mainline/done/5-5-1-page-aggregate-contract-v1.md` 第 2.3 节仍说明两项“不可描述成正式支持”;`wolai-frontend/src/lib/documents/page-option-semantics.ts:48` 与 `:88` 均标记为 `wired`;`:121` 的 `pickLeptosTiptapRuntimePageOptions` 会把 `showHeadingNumbers / embedDefaultBlockId` 传给 island,`wolai-frontend/src/components/editor/leptos-tiptap-island-editor-host.tsx:717` 运行时更新这些选项。 | +| F-06 | 风险 | 低 | Tree final DOM shell 默认路径已符合 `4-18`,但 legacy iframe host 仍可被环境变量显式打开;后续需要保持负向 smoke,防止默认路径回退。 | `wolai-frontend/src/components/sidebar/tree-shell-host.tsx:131` 默认 `rust_family` 且有 workspace 时使用 DOM host,`:133` 仅在 `NEXT_PUBLIC_TREE_SHELL_LEGACY_IFRAME_HOST=1` 时启用 legacy iframe;`wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx:182` 覆盖默认不能进入 `iframe_srcdoc`,`:199` 覆盖显式 legacy flag。 | + +## 证据 + +### 已对齐部分 + +1. 文档页读取主链已进入 Rust Page Aggregate。 + - `wolai-frontend/src/app/(app)/documents/[id]/page.tsx:51` 调用 `loadPageAggregateFromNextHeaders`。 + - `wolai-frontend/src/lib/documents/page-aggregate-loader.ts:170` 请求 `/api/page-aggregate/:id`。 + - `wolai-frontend/src/lib/documents/page-aggregate-loader.ts:130` 校验 schema 必须是 `mnote.page_aggregate.v1`。 + - `wolai-frontend/src/lib/documents/page-aggregate-loader.ts:225` 的 `loadPageAggregate` 只返回 Rust snapshot,不再在运行时 fallback 到 TS builder。 + +2. 默认编辑器 host 已是页面内 `leptos_tiptap_island`。 + - `wolai-frontend/src/components/editor/editor-host-config.ts:1` 只保留 `EditorHostKind = "leptos_tiptap_island"`。 + - `wolai-frontend/src/components/editor/editor-host.tsx:7` 动态加载 `leptos-tiptap-island-editor-host`。 + - `wolai-frontend/src/components/editor/leptos-tiptap-island-editor-host.tsx:619` 直接调用 runtime module 的 `mount(container, ...)`,不是 iframe。 + +3. 页面写命令已经开始按 page command family 收口。 + - `wolai-frontend/src/lib/documents/page-command-contract.ts:15` 固定 `page.head.updateTitle / page.layout.updateOptions / page.body.save`。 + - `wolai-frontend/src/lib/documents/page-command-client.ts:72` 标题写入发送 `commandName: page.head.updateTitle`。 + - `wolai-frontend/src/lib/documents/page-command-client.ts:89` 页面设置写入发送 `commandName: page.layout.updateOptions`。 + - `wolai-frontend/src/app/api/documents/save/route.ts:35` 服务端 envelope 使用 `PAGE_COMMAND_NAMES.saveBody`。 + +4. tree command 前端调用主面已以 `tree.*` 为结果元数据口径。 + - `wolai-frontend/src/lib/documents/tree-command-client.ts:26` 定义 `tree.node.create / tree.node.rename / tree.subtree.move / tree.node.archive` 等 preferred command。 + - `wolai-frontend/src/lib/documents/tree-command-client.ts:185` 统一 POST 到 `/api/tree/commands`。 + - `wolai-frontend/src/app/api/tree/commands/route.ts:205` 由 `action` 分发 tree command,`:278` 创建命令使用 `tree.node.create`。 + +5. tree final DOM shell 默认路径已符合硬门禁。 + - `wolai-frontend/src/components/sidebar/tree-shell-host.tsx:139` 默认 implementation 为 `rust_wasm_dom_shell_host`。 + - `wolai-frontend/src/components/sidebar/tree-shell-surface.tsx:113` 旧 React page tree renderer 已显示为 removed fallback,不再作为正常 renderer。 + - `wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx:189` 测试断言默认 implementation 是 `rust_wasm_dom_shell_host`,`:194` 断言没有 iframe host。 + +### 仍需收口部分 + +1. 客户端 `PageAggregateClientState` 仍是混合态。 + - 它把 server snapshot、persisted title、draft title、本地 content、server subtree snapshot、revision/conflict key 放在同一个前端 reducer 中。 + - 这符合当前过渡态,但不等于 Rust page aggregate 已成为页面域唯一运行时真相。 + +2. `pageSubtree` 与正文编辑没有同源更新。 + - 本地正文变更只会触发 `apply_local_content_snapshot`,不会同步生成新的 `pageSubtree`。 + - selector 在内容对象不同于 server snapshot 时返回 `null`,因此 `AI / read view / TOC` 只能等待后续持久化与重新拉取。 + +3. Sidebar live cache 仍有 freshness 选择层。 + - `AppLayoutShell` 和 `Sidebar` 都依赖 `usePreferredSidebarSnapshot`。 + - 当前算法没有基于 Rust stream cursor / projection version 做统一仲裁,而是通过 sync key 与 `treeStreamStatus` 在 `query` 与 `tree_stream` 之间选择。 + +4. 页面设置中仍有显式未完成项。 + - `protectEditing` 与 `showBlockRefCount` 的代码状态已经诚实标为 `planned / downgrade`。 + - 这避免了误导用户,但也说明 `Page Aggregate -> island runtime` 的设置语义还没有完全完成。 + +## 建议优先级 + +### P0 + +暂无需要立即阻断主链的 P0。默认 Page Aggregate 读链、默认 island host、默认 DOM tree shell 均未发现与最新主线相反的实现。 + +### P1 + +1. 收口 `pageSubtree` 与本地正文编辑的关系。 + - 至少明确它是“server projection only”还是“本地编辑也应生成临时 projection”。 + - 如果 AI 面板需要稳定结构上下文,不应在用户正常编辑后直接拿到 `null`。 + +2. 将 Sidebar 的三源 preferred snapshot 推进为统一 live cache。 + - 建议以 Rust stream cursor / projection version / query snapshot version 为仲裁字段,减少仅靠 sync key 的 freshness 判断。 + +### P2 + +1. 继续移除或强门禁 legacy tree iframe host。 + - 当前显式 env flag 符合设计,但应保留负向 smoke,避免后续默认路径误回退。 + +2. 同步修正文档滞后。 + - `5-5-1` 对 `showHeadingNumbers / embedDefaultBlockId` 的描述已经落后于当前代码,应在后续文档整理时更新。 + +3. 页面设置 planned 项保持降级展示,直到真正进入 island runtime 或被产品侧移除。 + +## 修改的文件 + +- `/mnt/Data1T/mnote/design/10-review/02-frontend-editor-tree-review.md` diff --git a/design/10-review/03-convex-realtime-storage-review.md b/design/10-review/03-convex-realtime-storage-review.md new file mode 100644 index 00000000..b7427b94 --- /dev/null +++ b/design/10-review/03-convex-realtime-storage-review.md @@ -0,0 +1,215 @@ +# Convex / Realtime / Storage 实现偏差审查 + +## 范围 + +本报告审查 Convex / storage bridge / realtime / Page Aggregate 数据底座与当前设计主线的一致性,重点对照以下方向: + +- Convex 保留为自托管 storage / realtime substrate,不作为树语义 owner。 +- Rust kernel / bridge-runtime / mnote-web 持有 tree-first graph、projection、command、Page Aggregate 的语义主导权。 +- `/api/page-aggregate/:id` 作为文档页 Rust-first 读取主链。 +- `/api/tree/events` 作为 Rust Web tree realtime snapshot / delta / resync 主链。 +- 前端只消费稳定 projection、Page Aggregate 与 tree stream,不重新持有第二套对象真相。 + +重点读取范围: + +- `ARCHITECTURE.md` +- `design/01-05-current-priority-overview.md` +- `design/02-convex-rust-long-term-architecture/process/2-tree-first-graph-convex-rust-long-term-architecture-v1.md` +- `design/03-rust-web/process/3-3-rust-web-tree-realtime-event-stream-v1.md` +- `design/05-editor-mainline/process/5-5-page-aggregate-single-truth-alignment-v1.md` +- `design/05-editor-mainline/process/5-6-page-aggregate-alignment-checklist-v1.md` +- `design/05-editor-mainline/done/5-5-1-page-aggregate-contract-v1.md` +- `infra/convex/README.md` +- `wolai-frontend/convex/` +- `rust/crates/storage-convex-bridge/` +- `rust/crates/mnote-web/src/transport/convex.rs` +- `rust/crates/mnote-web/src/routes/documents.rs` +- `rust/crates/mnote-web/src/routes/tree.rs` +- `rust/crates/mnote-web/src/routes/sse.rs` +- `rust/crates/mnote-web/src/routes/stream_support.rs` +- `wolai-frontend/src/lib/documents/` +- `wolai-frontend/src/lib/tree-stream/` + +## 结论 + +整体方向与设计主线基本一致:Convex 没有被拆掉,仍承担本地自托管存储、文件和实时底座;Rust Web 已注册 `/api/page-aggregate/:document_id` 与 `/api/tree/events`;前端 tree stream 已直接使用 `EventSource("/api/tree/events")`;Next 的 `/api/documents/page` 与 `/api/mnote-web/stream` 已明确作为 410 compat 边界退场。 + +但当前实现仍是明显过渡态,主要问题集中在三处: + +1. Page Aggregate 读链虽然是 Rust endpoint,但实际数据仍由 `documents:getMeta` + `documents:getContent` 分别取回后在 bridge-runtime 中拼 projection,`source` 标识存在“看起来比真实实现更 canonical”的风险。 +2. Rust Web 的 `/api/documents/title`、`/api/documents/options` 与 Next route 的 page write adapter 在 bridge artifact 记录上不一致;tree stream 依赖 bridgeLogs 时,Rust page write 路径可能漏掉 command/domain event。 +3. `/api/tree/events` 是正式 SSE 入口,但当前 change detection 依赖周期性查询 `bridgeLogs:listWorkspaceOverview`,且 Convex query 内部会按 workspace collect 全量 command/domain rows 后内存过滤排序,实时性和规模风险较高。 + +## 关键发现表格 + +| 编号 | 分类 | 严重度 | 发现 | 证据 | +| --- | --- | --- | --- | --- | +| F1 | 实现偏差 | 高 | Rust Page Aggregate endpoint 对外是 `mnote.page_aggregate.v1`,但构建过程仍先分别读取 meta/content,再在 bridge-runtime 中拼 projection;`source=KernelProjection` 容易掩盖底层仍是兼容 join。 | `rust/crates/mnote-web/src/routes/web_shell.rs:2282`、`:2291`、`:2301`;`rust/crates/bridge-runtime/src/lib.rs:8246`、`:8252`、`:5291`、`:5303`、`:5386` | +| F2 | 风险 | 高 | Rust Web 的 title/options 写路由只执行 Convex mutation,不记录 bridge command/domain artifacts;而 tree stream 以 bridgeLogs 为事件来源,主路径 page 写入可能不进入实时流。 | `rust/crates/mnote-web/src/routes/documents.rs:714`、`:802`;`rust/crates/mnote-web/src/routes/command_support.rs:65`;对比 `rust/crates/mnote-web/src/routes/tree.rs:6529` 与 `wolai-frontend/src/lib/documents/page-write-command-adapter.ts:63` | +| F3 | 风险 | 高 | tree realtime 当前是 SSE transport,但后端通过 `sleep(poll_ms)` 周期性轮询 Convex bridgeLogs,而不是直接利用 Convex subscription/push;默认 2s,实时性和负载都需继续验证。 | `rust/crates/mnote-web/src/routes/sse.rs:25`、`:26`、`:51`、`:58`、`:60`;`rust/crates/mnote-web/src/routes/stream_support.rs:610` | +| F4 | 风险 | 中高 | `bridgeLogs:listWorkspaceOverview` 会按 workspace collect 全量 `command_logs` 与 `domain_events` 后在内存中过滤、排序、分页;SSE 轮询叠加后,历史日志增长会放大 Convex 读压力。 | `wolai-frontend/convex/bridgeLogs.ts:283`、`:287`、`:292`、`:301`、`:305` | +| F5 | 方向变化/文档滞后 | 中 | `storage-convex-bridge` 把 `page.aggregate.get` 映射到 `documents:getPageAggregate`,但 Convex `documents.ts` 只发现 `getMeta` / `getContent`,未发现 `getPageAggregate` export;当前真实 Page Aggregate 路线已绕到 Rust adapter。 | `rust/crates/storage-convex-bridge/src/mapping.rs:101`;`wolai-frontend/convex/documents.ts:684`、`:803`;全仓 `rg getPageAggregate` 未发现 Convex 实现 | +| F6 | 已完成/方向一致 | 中 | Next compat 读链和旧 stream alias 已显式退场,前端 tree stream 直接构造 `/api/tree/events`,符合当前主线口径。 | `wolai-frontend/src/app/api/documents/page/route.ts:17`;`wolai-frontend/src/app/api/mnote-web/stream/route.ts:9`;`wolai-frontend/src/lib/tree-stream/protocol.ts:66`、`:72` | +| F7 | 未完成 | 中 | Page Aggregate TS builder 已不在 runtime 主链中被引用,但文件仍保留;当前定位应继续写成 fallback / adapter / 测试材料,不能作为运行时主路径描述。 | `wolai-frontend/src/lib/documents/page-aggregate-builder.ts:51`;全仓非测试引用仅剩定义,runtime loader 只调用 Rust snapshot:`wolai-frontend/src/lib/documents/page-aggregate-loader.ts:225` | + +## 证据 + +### 1. Page Aggregate 读链已收口到 Rust endpoint,但仍由 meta/content join 生成 + +`mnote-web` 注册了正式 endpoint: + +- `rust/crates/mnote-web/src/routes/mod.rs:53` 到 `:56` 注册 `/api/page-aggregate/{document_id}`。 +- `rust/crates/mnote-web/src/routes/web_shell.rs:2227` 到 `:2252` 返回 `schema: "mnote.page_aggregate.v1"` 和 `result: aggregate`。 + +但实际构建流程仍是: + +- `rust/crates/mnote-web/src/routes/web_shell.rs:2282` 到 `:2290` 读取 `load_document_meta_result`。 +- `rust/crates/mnote-web/src/routes/web_shell.rs:2291` 到 `:2299` 读取 `load_document_content_result`。 +- `rust/crates/mnote-web/src/routes/web_shell.rs:2301` 到 `:2315` 把 `meta + content` 作为数据传给 `page.aggregate.get`。 +- `rust/crates/bridge-runtime/src/lib.rs:5291` 到 `:5312` 的 `build_page_aggregate_projection_result` 明确从 `data.meta` 和 `data.content` 中拆字段。 + +这说明“Rust-first 读取主链”成立,但“Page Aggregate 已经由 kernel 原生投影独立产出”仍未成立。该点与 `5-5/5-6` 的过渡态判断一致,但需要在后续文档和汇报中保持精确。 + +需进一步验证:`PageAggregateSource::KernelProjection` 是否应在这种 `meta/content join` 场景下继续使用,还是应保留 `CompatMetaContentJoin` 以避免 provenance 误导。 + +### 2. Page write side effects 在 Rust route 与 Next adapter 之间不一致 + +Next route 侧: + +- `wolai-frontend/src/app/api/documents/title/route.ts:58` 调用 `executePageWriteBridgeCommand`。 +- `wolai-frontend/src/app/api/documents/options/route.ts:47` 调用 `executePageWriteBridgeCommand`。 +- `wolai-frontend/src/app/api/documents/save/route.ts:43` 调用 `executePageWriteBridgeCommand`。 +- `wolai-frontend/src/lib/documents/page-write-command-adapter.ts:63` 到 `:69` 成功后调用 `recordRustBridgeCommandArtifacts`。 + +Rust route 侧: + +- `rust/crates/mnote-web/src/routes/documents.rs:579` 的正文保存使用 `execute_runtime_command_via_convex_with_artifacts`。 +- `rust/crates/mnote-web/src/routes/documents.rs:714` 的标题更新使用 `execute_runtime_command_via_convex`。 +- `rust/crates/mnote-web/src/routes/documents.rs:802` 的页面设置更新使用 `execute_runtime_command_via_convex`。 +- `rust/crates/mnote-web/src/routes/command_support.rs:65` 到 `:73` 的 `execute_runtime_command_via_convex` 只执行 Convex command plan,不持久化 artifacts。 +- `rust/crates/mnote-web/src/routes/command_support.rs:75` 到 `:93` 的 artifact 版本才会调用 `execute_convex_command_plan_with_artifacts`。 + +tree command route 是一致的: + +- `rust/crates/mnote-web/src/routes/tree.rs:6529` 使用 `execute_runtime_command_via_convex_with_artifacts`。 + +风险是:如果当前 3000 主入口走 Rust Web `/api/documents/title` 或 `/api/documents/options`,这些 page 写入不会进入 `command_logs/domain_events`,而 `/api/tree/events` 正是通过 bridgeLogs 检测变化。标题类写入尤其可能影响 sidebar/breadcrumb/page tree 的实时一致性。 + +需进一步验证:当前文档页标题编辑在 3000 主壳中到底走 `/api/documents/title` 还是 `/api/tree/commands`;如果走前者,应补 Rust route artifact 记录或统一到 tree/page command route。 + +### 3. Tree realtime 是正式 SSE 入口,但实现仍是 polling-backed stream + +正式入口成立: + +- `rust/crates/mnote-web/src/routes/mod.rs:130` 注册 `/api/tree/events`。 +- `rust/crates/mnote-web/src/routes/sse.rs:127` 到 `:146` 给 tree events 加 `x-mnote-tree-stream-owner: rust-web`。 +- `wolai-frontend/src/lib/tree-stream/protocol.ts:66` 到 `:77` 构造 `/api/tree/events` URL。 +- `wolai-frontend/src/lib/tree-stream/use-sidebar-tree-stream.ts:136` 到 `:143` 用 `EventSource` 监听 `snapshot/delta/resync`。 + +但服务端 change detection 是轮询: + +- `rust/crates/mnote-web/src/routes/sse.rs:25` 到 `:26` 读取 `max_polls` 和 `poll_ms`,默认 `2000ms`,最低 `250ms`。 +- `rust/crates/mnote-web/src/routes/sse.rs:51` 到 `:58` 循环中 `sleep(Duration::from_millis(poll_ms))`。 +- `rust/crates/mnote-web/src/routes/sse.rs:60` 到 `:67` 每轮调用 `load_stream_overview` 再 `resolve_stream_change`。 +- `rust/crates/mnote-web/src/routes/stream_support.rs:610` 到 `:625` 的 `load_stream_overview` 通过 `bridge.workspace.overview` 查询 Convex。 + +这与“Rust Web 提供正式实时 transport”一致,但还不是“基于 Convex realtime subscription 的 push stream”。短期可接受为过渡实现,长期如果继续承载主链,需要明确性能和延迟边界。 + +### 4. bridgeLogs overview 查询存在规模风险 + +`wolai-frontend/convex/bridgeLogs.ts` 的 `listWorkspaceOverview`: + +- `:283` 到 `:286` 按 workspace 查询并 `collect()` 所有 `command_logs`。 +- `:287` 到 `:290` 按 workspace 查询并 `collect()` 所有 `domain_events`。 +- `:292` 到 `:301` 在内存中过滤、排序、切片 command logs。 +- `:303` 到 `:312` 再用 commandId 集合过滤 domain events。 + +该实现作为调试/小数据过渡可以工作,但被 `/api/tree/events` 默认每 2 秒调用时,日志增长后会造成: + +- Convex query 读放大。 +- SSE 连接数量增加时成倍放大。 +- cursor 语义依赖内存排序,历史数据规模变大后容易出现延迟或超时。 + +建议后续至少增加按 `workspace_id + created_at/id` 的索引分页,避免每次 stream poll 全量扫描。 + +### 5. storage-convex-bridge 中存在疑似过时的 `page.aggregate.get` 映射 + +`rust/crates/storage-convex-bridge/src/mapping.rs:101`: + +```text +"page.aggregate.get" => "documents:getPageAggregate" +``` + +但当前 `wolai-frontend/convex/documents.ts` 中只发现: + +- `getMeta`:`wolai-frontend/convex/documents.ts:684` +- `getContent`:`wolai-frontend/convex/documents.ts:803` + +全仓搜索未发现 Convex `documents:getPageAggregate` 实现。当前真实 Page Aggregate 读取是 Rust Web 先读 meta/content,再由 bridge-runtime 生成 projection。因此该映射要么是未来目标,要么已经滞后;如果有代码路径直接通过 storage-convex-bridge 执行 `page.aggregate.get`,会存在运行时函数不存在风险。 + +需进一步验证:`storage-convex-bridge` 是否仍有生产路径直接执行 `page.aggregate.get -> documents:getPageAggregate`;如果没有,应把映射标注为 future/stale,或改为当前真实读链。 + +### 6. Convex substrate 定位总体一致 + +正向证据: + +- `infra/convex/README.md` 明确自托管 Convex backend/dashboard、HTTP Actions 和文件存储。 +- `wolai-frontend/convex/schema.ts:35` 到 `:91` 的 `documents` 表继续承接页面结构、正文、页面设置、统计字段。 +- `wolai-frontend/convex/schema.ts:121` 到 `:162` 的 `media_assets` 与 `_storage` 字段保留文件底座。 +- `rust/crates/storage-convex-bridge/README.md:5` 到 `:13` 明确 bridge 只做协议到 Convex 读写请求映射,不复制主事实层、不维护第二数据库。 + +这与“Convex 不拆,Rust 收口语义”的设计一致。 + +## 建议优先级 + +### P0:修正 Rust page write route 的 artifact 一致性 + +目标:让当前 3000 主入口的 `/api/documents/title`、`/api/documents/options` 至少在 side effect 上与 Next `page-write-command-adapter` 保持一致。 + +建议: + +- 将 `rust/crates/mnote-web/src/routes/documents.rs` 中 title/options 的 `execute_runtime_command_via_convex` 改为 artifact 版本,或统一复用 tree/page command route。 +- 对标题更新补最小回归:更新标题后 `bridgeLogs:listWorkspaceOverview` 能看到对应 command/domain event,`/api/tree/events` 能输出 delta 或 resync。 +- 对 artifact 写失败的策略重新定级:当前 `rust/crates/mnote-web/src/transport/convex.rs:759` 到 `:770` 是主 mutation 成功、artifact 失败仍返回成功;对 tree-relevant command 至少应打可观测错误并触发保守 resync。 + +### P1:收口 Page Aggregate provenance + +目标:避免把 `meta/content join` 误标为已完成的 kernel-native projection。 + +建议: + +- 明确 `PageAggregateSource::KernelProjection` 与 `CompatMetaContentJoin` 的使用边界。 +- 如果 `build_page_aggregate_snapshot` 仍通过 `load_document_meta_result + load_document_content_result` 构建,应在返回 source 或 header 中反映真实来源。 +- 如果目标是 kernel-native projection,则补正式 kernel/query 数据路径,避免 route 层长期手工拼装。 + +### P1:优化 tree stream 的 Convex 查询模型 + +目标:让 `/api/tree/events` 可以长期承载主链,而不是随着日志增长退化。 + +建议: + +- 为 `command_logs`、`domain_events` 增加按 `workspace_id + created_at/id` 的查询索引和 cursor 查询。 +- `listWorkspaceOverview` 不再 `collect()` 全量 workspace 日志后内存分页。 +- 明确 polling-backed SSE 是过渡实现,还是长期 realtime transport;若长期使用,应补连接数、日志量、延迟上限的 smoke/bench。 + +### P2:清理或标注 stale mapping + +目标:降低后续 worker 误用 `page.aggregate.get -> documents:getPageAggregate` 的风险。 + +建议: + +- 若 `documents:getPageAggregate` 不计划实现,移除或注释 `storage-convex-bridge` 中的映射。 +- 若计划实现,补 Convex query 与最小测试,并让 mnote-web Page Aggregate route 直接消费它或说明为什么不消费。 + +### P2:保留 Next compat 退场边界,但避免双实现继续发散 + +目标:Next route 继续作为 legacy/adapter 参考时,不与 Rust Web 主入口形成不同 side effects。 + +建议: + +- 对 `/api/documents/title/options/save` 明确 owner:Rust Web 主路径与 Next legacy 路径只能有一份 canonical side-effect 规则。 +- 对 `wolai-frontend/src/lib/documents/page-aggregate-builder.ts` 保留测试/adapter 标签,避免被重新接回 runtime 主链。 + +## 修改的文件路径 + +- `design/10-review/03-convex-realtime-storage-review.md` diff --git a/design/10-review/04-secondary-domains-and-design-governance-review.md b/design/10-review/04-secondary-domains-and-design-governance-review.md new file mode 100644 index 00000000..f80cb2a7 --- /dev/null +++ b/design/10-review/04-secondary-domains-and-design-governance-review.md @@ -0,0 +1,64 @@ +# 次级域与设计治理实现偏差审查 + +## 范围 + +本次只审查 Mindmap、AI、OnlyOffice、Wolai-aline、SiYuan reference,以及 `design/process/done` 治理口径与当前实现方向的一致性。重点读取了 `ARCHITECTURE.md`、`design/README.md`、`design/06-mindmap/process/*`、`design/07-ai/process/*`、`design/08-wolai-aline-test-flow/process/wolai-aline-test-flow-v1.md`、`design/09-siyuan-reference/process/9-siyuan-reference-boundary-and-adoption-v1.md`、`design/90-reference/*`,并对照了 Mindmap、AI route/lib、OnlyOffice route/adapter 与相关 Convex/Rust runtime 代码。 + +## 结论 + +总体方向与当前主线基本一致:Mindmap 已明确降为 `tree-first graph kernel` 的视图/编辑挂件,AI 主执行面正在向 `mnote-cli` 收口,OnlyOffice 仍是独立页面型编辑器边界,SiYuan 参考稿没有发现被提升为上位架构来源的证据。 + +主要风险集中在三处:OnlyOffice 在 `mnote-web` 主入口里的 callback/forcesave 仍是 no-op,而 legacy Next route 已有真实写回链;Mindmap 的导出 action 在 schema/action map 中暴露,但 bridge 安全命令集不支持;Mindmap AI 补完 route 当前硬返回 501,和 Rust tool 已登记的能力面不闭合。 + +## 关键发现表格 + +| ID | 分类 | 级别 | 发现 | 简短证据 | 建议 | +| --- | --- | --- | --- | --- | --- | +| F-01 | 实现偏差 / 风险 | P1 | OnlyOffice `mnote-web` 主入口已挂载 callback/forcesave,但当前实现不写回,只返回成功或 noop,可能让 3000 主链下的 OnlyOffice 保存丢失。 | `rust/crates/mnote-web/src/routes/mod.rs:78-84` 挂载 `/api/onlyoffice/callback` 与 `/api/onlyoffice/forcesave`;`rust/crates/mnote-web/src/routes/onlyoffice.rs:717-759` callback 只记录日志并返回 `{error:0}`,forcesave 返回 `mnote-web-rust-noop`;而 `wolai-frontend/src/app/api/onlyoffice/callback/route.ts:93-192` 有真实 Convex 写回链。 | 优先把 Rust route 接到 `onlyoffice_prepare_callback` / media asset writeback,或显式把该路由代理到 legacy Next,避免主入口 shadow 掉真实写回。 | +| F-02 | 未完成 | P2 | Mindmap `export` 动作暴露给 UI action map,但 simple-mind-map 安全执行器不允许 `EXPORT`,默认路径可能显示能力却执行失败。 | `wolai-frontend/src/lib/mindmap/mindmap-action-map.ts:65` 将 `export` 映射为 runtimeCommand `EXPORT`;`wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts:119-129` 的 `SIMPLE_MIND_MAP_SAFE_COMMANDS` 不包含 `EXPORT`。 | 要么把 `EXPORT` 加入安全命令并补 smoke,要么在 UI state 中继续禁用导出并标注为延期。 | +| F-03 | 未完成 / 方向变化 | P2 | Mindmap AI 补完 route 当前直接 501,后续大段旧 Supabase/在线 AI 实现被注释;但 Rust tool registry 已登记 `mindmap_expand_node`,形成“工具存在、产品入口不可用”的断层。 | `wolai-frontend/src/app/api/mindmap-ai/expand-node/route.ts:90-97` 校验后直接返回 `501`;同文件后续注释块仍保留旧 Supabase/AI 逻辑;`rust/crates/core-protocol/src/tool.rs:231-240` 与 `rust/crates/bridge-runtime/src/lib.rs:3803-3812` 已有 `mindmap_expand_node`。 | 若该能力仍在 Phase 6/7 范围内,应按 CLI/Rust bridge 路线重接;若延期,应把 route 标成 retired/debug,避免前端或测试误以为可用。 | +| F-04 | 方向变化 / 文档滞后 | P2 | AI 主 Web route 已收口到 `mnote-cli` host,但 `wolai-backend` 仍暴露 `openai_agents_python` 文档 agent route 与旧工具面;是否仍部署为可访问入口需进一步验证。 | `wolai-frontend/src/app/api/ai-agent/run/route.ts:36-57` 明确拒绝 codex/hermes/claudecode 并进入 `startMnoteCliAgentHostRun`;`wolai-backend/app/routers/ai_agent.py:34-57` 仍暴露 `/ai-agent/health`、`/ai-agent/document/run`,health 返回 `bridge: openai_agents_python`;`wolai-backend/app/services/ai_document_agent.py:1174-1470` 仍指令 agent 使用 `doc_insert_blocks`、`doc_replace_range`、`slash_run`。 | 在设计或代码注释中明确该后端只作为可插拔外置 agent/对照链;若不再使用,补退场计划和访问边界,尤其确认 `mnote_ai_orchestrator_api_key` 未配置时的开放行为。 | +| F-05 | 文档治理风险 | P3 | `design/90-reference` 符合“参考资料”目录定位,但内容仍带有问答式残留,容易被后续 worker 误用为正式设计结论。 | `design/README.md` 明确 `90-reference/` 不参与 process/done 状态判断;`design/90-reference/90-1-filetree.md` 末尾保留“需要我给你...”类对话尾巴;`design/90-reference/90-2-yemianshu.md` 同样保留示例请求口吻。 | 低优先级清理为中性参考笔记,并在引用时强制以 `ARCHITECTURE.md` 和主线设计为上位依据。 | + +## 证据 + +### Mindmap + +- 设计口径清晰:`design/06-mindmap/process/6-mindmap-kernel-phase6-projection-editor-v1.md` 明确 Phase 6 主线是 `Rust kernel truth -> mindmap.simple_mind_map_scene.v1 -> leptos-mindmap editor island -> simple-mind-map runtime -> command bridge`,并禁止把 runtime data 当唯一事实源。 +- 实现已对齐主线壳:`rust/crates/mnote-web/src/routes/mindmap_shell.rs:105-123` 输出 `mnote.mindmap_shell.v1`、`mindmap.simple_mind_map_scene.get` 与 `mindmap.command.apply`;`rust/crates/mnote-web/src/ssr/pages/mindmap.rs:50-56` 提供 standalone island 挂载点。 +- 旧 React 块已自我标注为 legacy/compat/reference:`wolai-frontend/src/components/editor/blocks/MindmapBlock.tsx:3-5` 明确 3000 文档页默认主链是 `leptos-tiptap NodeView + leptos-mindmap adapter`。 +- 仍有 compat 数据层:`wolai-frontend/convex/schema.ts:164-184` 的 `mindmaps.data: v.any()` 仍承载导图数据;这与当前过渡态兼容,但不应被描述为长期 canonical truth。 + +### AI + +- CLI-first 入口基本对齐:`wolai-frontend/src/app/api/ai-agent/run/route.ts:36-57` 将默认执行入口限定到 `mnote-cli host`,拒绝旧 provider。 +- 结构化 artifact 设计仍有未完成项:`design/07-ai/process/7-phase7-ai-kernel-projection-plan-v4.md` 中“后续权限收口”仍未勾选,说明 AI 写链权限模型尚未完全闭环。 +- 旧后端 agent 仍存在:`wolai-backend/app/routers/ai_agent.py:47-57` 仍提供 streaming run;这可作为外置 agent,但需要避免被误认为长期默认主编排。 + +### OnlyOffice + +- 正确边界已有:`rust/crates/adapter-onlyoffice/src/lib.rs:124-126` 明确 adapter 只定义资产定位、会话、签名、代理、callback/forcesave 边界,不把 OnlyOffice 变成主事实层。 +- `mnote-web` 页面是独立编辑页:`rust/crates/mnote-web/src/routes/onlyoffice.rs:325-630` 直接渲染 `/onlyoffice`,通过 DocsAPI 创建编辑器,未嵌入正文主编辑画布。 +- 关键风险是写回链 owner 分裂:Rust 主入口 no-op 与 legacy Next 真写回并存,见 F-01。 + +### Wolai-aline + +- 流程文档严格要求“Wolai 基线 -> RED smoke -> 小范围实现 -> 本地验证 -> subagent 复测 -> 主线程截图复核”:`design/08-wolai-aline-test-flow/process/wolai-aline-test-flow-v1.md`。 +- 本次不是具体 Wolai 对标实现任务,未执行浏览器对标;未发现该流程被错误提升为产品架构来源。 + +### SiYuan Reference + +- `design/09-siyuan-reference/process/9-siyuan-reference-boundary-and-adoption-v1.md` 的边界与当前主线一致:思源只作为产品能力与交互参考,不替代 `tree-first graph kernel`、Rust kernel、Page Aggregate、tree command 与 tree realtime。 +- 当前只读检索未发现将 SiYuan `.sy`、SQL API 或前端 runtime 直接提升为 mnote 长期事实源的实现证据;若后续新增属性视图/数据库视图,应继续先做对象域评估。 + +## 建议优先级 + +1. P1:补齐或明确代理 OnlyOffice Rust callback/forcesave 写回链,避免主入口下保存成功但内容未持久化。 +2. P2:收口 Mindmap action 可用性,先修 `export` 映射与安全命令不一致,再继续扩展 UI 能力。 +3. P2:处理 Mindmap AI route:要么按 Rust bridge/CLI-first 重接 `mindmap_expand_node`,要么显式退役该 Next route。 +4. P2:明确 `wolai-backend` AI agent 的外置/对照定位与访问边界,避免与 `mnote-cli` 唯一执行面口径冲突。 +5. P3:清理 `design/90-reference` 的问答残留,并在引用规范里再次强调它不是 process/done 设计稿。 + +## 本次修改文件 + +- `/mnt/Data1T/mnote/design/10-review/04-secondary-domains-and-design-governance-review.md` diff --git a/design/10-review/05-tree.md b/design/10-review/05-tree.md new file mode 100644 index 00000000..6f45fd33 --- /dev/null +++ b/design/10-review/05-tree.md @@ -0,0 +1,152 @@ +结论 + 我基本同意你的方向,但要把“文件树为根源”说得更精确:不应让“文件树 UI 组件”成为真源,而应让 Rust kernel 中的 workspace resource tree / file tree projection 背后 + 的资源层级 成为页面、附件、mindmap、OnlyOffice 等对象的组织根源。页面树则是从这棵资源/对象树派生出的导航投影,类似快捷方式、收藏视图或文档视图。 + + 对当前 bug 来说,最核心的规则应固定为: + + 1. index.md 只代表页面正文,即 Page Aggregate body。 + 2. mindmap 不是主编辑区正文替身,而是页面内某个 block 关联的 object / asset editor。 + 3. 文件树点击 mindmap 应打开 mindmap object editor,不能被 index.md 吞掉,也不能用临时 mindmap-only bootstrap 覆盖真实页面正文。 + 4. 页面树不应再持有独立结构真相,只显示“文档导航关系”;文件树显示“资源组织关系”。 + + 主编辑区与插件 + 主编辑区应该是一个工作区 tab host,而不是只等于文档正文编辑器。index.md 是其中一种 tab,mindmap、OnlyOffice、附件预览、代码附件都是其他 object tab/model。 + + Siyuan 这里值得借鉴:doc 和 asset 是不同 model/tab,asset 打开不伪装成 doc 正文;插件、widgets、assets、.sy 文档也在存储层分开。mnote 也应采用类似原则:插件/附 + 件/mindmap 可以嵌入页面,但它们的持久化真源不能变成页面正文本身,只能通过 block-asset relation 被 Page Aggregate 引用。 + + 文件树与页面树 + 我建议改成三层表述: + + - Resource Tree:长期 canonical 对象组织树,Rust kernel 持有语义,Convex 只是底层存储。 + - File Tree:Resource Tree 的主组织投影,展示页面文件夹、index.md、附件、mindmap、OnlyOffice、代码附件等。 + - Page Tree:面向阅读/导航的快捷投影,只显示页面关系,不拥有排序、父子、附件归属的最终真相。 + + 这样你的“文件树为根源”可以落地,但不会和现有 tree-first graph kernel 冲突。更准确地说:文件树背后的 resource hierarchy 是根源,页面树是它的页面导航视图。 + + 建议路线 + 短期先修当前 bug:保留 /mindmap/{doc}/{asset} 作为 object editor,但彻底隔离草稿 key、保存 command 和 Page Aggregate body,smoke 必须真实网页验证“点击 mindmap、 + 编辑长中文、保存、切回 index.md、再打开 mindmap 内容仍在”。 + + 中期做主编辑区 asset tab:index.md | mindmap.json | xxx.docx,每个 tab 有自己的 object identity 和保存命令。 + + 长期补 resource projection / block-asset relation:文件树 row、页面内 mindmap block、mindmap projection 必须来自同一关系索引,而不是前端临时按路由拼。 + + + + 推荐路线 + 我建议采用“分阶段收口 Resource Tree”的方案,不做一次性大重构。 + + 可选方案有三种: + + - 只修 mindmap bug:最快,但会继续留下页面树/文件树真源分裂。 + - 分阶段建立 Resource Tree -> File Tree/Page Tree projection:最稳,能解决当前 bug,也能承接附件、OnlyOffice、插件对象。 + - 全量重写 tree/page/resource 模型:理论干净,但当前工作区和主链都很活跃,风险太高。 + + 我推荐第二种。 + + 阶段 0:冻结合同 + 先把 design/10-review/05-tree.md 升级为正式设计合同,建议后续移动或补一份到: + + - design/04-tree-domain/process/4-24-resource-tree-filetree-pagetree-source-contract-v1.md + - 或 design/05-editor-mainline/process/5-11-main-editor-object-tab-resource-tree-alignment-v1.md + + 合同里固定四句话: + + - Resource Tree 是组织真源。 + - File Tree 是资源组织主投影。 + - Page Tree 是页面导航投影/快捷视图。 + - index.md、mindmap、OnlyOffice、附件是不同 object model,不能互相伪装。 + + 阶段 1:先关闭当前 mindmap bug + 目标:文件树 mindmap 仍可编辑保存,但不污染 index.md。 + + 重点文件: + + - rust/crates/mnote-web/src/ssr/pages/layout.rs + - rust/crates/mnote-web/src/routes/mindmap_shell.rs + - rust/spikes/leptos-tiptap-spike/src/lib.rs + - scripts/task169-mindmap-realtime-smoke.js + + 验收必须是真实浏览器链路: + + 1. 从文件树点击 mindmap asset。 + 2. 进入明确的 mindmap object editor。 + 3. 输入长中文并保存。 + 4. 切回同页 index.md,正文仍是 Page Aggregate body。 + 5. 再打开 mindmap,刚才内容仍在。 + 6. 确认没有用真实 documentId 写 standalone 草稿 key。 + + 阶段 2:补 Resource Projection 协议 + 在 Rust 协议层明确资源节点和 block-asset 关系。 + + 建议新增或扩展: + + - ResourceNode + - ResourceKind: page | index | mindmap | attachment | onlyoffice | code + - ObjectIdentity: { objectKind, documentId, blockId?, assetId? } + - BlockAssetRelation: { documentId, blockId, assetId, assetKind } + + 落点优先看: + + - rust/crates/core-protocol/ + - rust/crates/bridge-runtime/ + - rust/crates/mnote-web/src/tree_shell/ + + 这个阶段不要求立刻迁移所有数据,只要协议和 projection 能表达清楚。 + + 阶段 3:让 File Tree 从 Resource Tree 派生 + 当前 file tree 已有 resourceMeta、assetKind、file_tree projection 基础。下一步是收口为: + + - 页面节点下面固定有 index.md + - mindmap/附件/OnlyOffice 都是同一 Resource Tree 下的 child resource + - 文件树 row 不再临时从多份前端数据拼出第二真相 + + 同时保留 tree.asset.open,但它必须只表达 object open intent,不直接决定“把谁当正文”。 + + 阶段 4:Page Tree 降级为导航投影 + Page Tree 不再拥有资源归属、附件归属、mindmap 归属。它只显示页面导航关系: + + - 页面标题 + - 页面层级 + - 快捷入口/收藏/最近打开这类导航语义 + + 如果页面树需要显示某个资源状态,也只读 Resource Projection,不自己维护。 + + 阶段 5:主编辑区变成 Object Tab Host + 这是中期关键体验: + + - index.md tab:加载 Page Aggregate body。 + - mindmap.json tab:加载 mindmap projection/command。 + - xxx.docx tab:打开 OnlyOffice object editor。 + - attachment tab:预览/代码编辑/外部打开。 + + 这样 mindmap 不会被 index.md 吞掉,也不会伪装成正文。 + + 阶段 6:命令面统一 + 后续命令应逐步收口到: + + - tree.asset.attach + - tree.asset.detach + - tree.resource.rename + - tree.resource.move + - page.body.save + - mindmap.command.apply + + 关键规则:改资源关系走 tree/resource command,改页面正文走 page command,改导图内容走 mindmap command。 + + + 落地入口 + + 以上判断已落实到两个主线 done checklist: + + - /mnt/Data1T/mnote/design/04-tree-domain/done/4-24-resource-tree-filetree-pagetree-source-contract-checklist-v1.md + 用于冻结 Resource Tree / File Tree / Page Tree 的真源合同和 projection / command 边界。 + - /mnt/Data1T/mnote/design/05-editor-mainline/done/5-12-main-editor-object-tab-resource-alignment-checklist-v1.md + 用于落实主编辑区 Object Tab、mindmap object editor、草稿隔离和真实浏览器 smoke 验收。 + + 执行顺序固定为: + + 1. 先完成 4-24:协议、projection、command 边界必须能表达 `index.md`、mindmap、OnlyOffice、附件、代码附件的不同 object identity,并确认 Page Tree 只是页面导航投影。 + 2. 再完成 5-12:主编辑区只消费 4-24 输出的 object identity / resourceMeta / open intent,先关闭 mindmap 污染 `index.md` 的 P0 bug,再推进 Object Tab Host。 + 3. 验收以真实浏览器 smoke 为准,尤其是 `scripts/task169-mindmap-realtime-smoke.js` 覆盖“打开 mindmap、长中文编辑、保存、切页、回 `index.md`、再开 mindmap”的链路。 diff --git a/design/10-review/README.md b/design/10-review/README.md new file mode 100644 index 00000000..da4b3e55 --- /dev/null +++ b/design/10-review/README.md @@ -0,0 +1,44 @@ +# 10-review 审查总览 + +本目录汇总当前设计与实现的偏差审查结果。四份分域报告分别覆盖 Rust kernel/web、前端编辑器与树体验、Convex/realtime/storage、次级域与设计治理。 + +## 结论 + +当前主线方向总体没有跑偏,但实现仍停留在“主链已切、收口未完”的状态。最需要继续收口的是: + +1. `Page Aggregate` 的单一真源边界 +2. `tree realtime` 的统一 live cache 与查询模型 +3. `documents.*` / `tree.*` / `page.*` 的 side effect 一致性 +4. legacy / compat / fallback 的显式退场边界 + +## 优先级摘要 + +### P0 + +- Rust page write 路由与 artifact 一致性 +- 搜索 / workspace shell / fallback 数据不要再伪装成真实主链 + +### P1 + +- `pageSubtree` 与正文编辑的关系需要明确 +- Sidebar 的 `initial / query / tree_stream` 三源选择要继续向统一 live cache 收口 +- `PageAggregateSource` 的 provenance 口径要和真实读链对齐 +- Convex overview 查询要避免全量扫描放大 + +### P2 + +- 继续清理或标注 legacy compat、debug host、stale mapping +- 对 `design/90-reference` 和次级参考材料保持只读、非上位来源定位 + +## 报告文件 + +- [Rust Kernel / Web 实现偏差审查](./01-rust-kernel-web-review.md) +- [前端编辑器 / 树体验实现偏差审查](./02-frontend-editor-tree-review.md) +- [Convex / Realtime / Storage 实现偏差审查](./03-convex-realtime-storage-review.md) +- [次级域与设计治理实现偏差审查](./04-secondary-domains-and-design-governance-review.md) + +## 统一判断 + +当前最准确的描述不是“已经完成单一真源收口”,而是: + +> Rust 已经持有主语义主导权,前端与 Convex 也已切到新主线,但 projection、command、realtime、fallback 仍有若干兼容态残留,需要继续按优先级收口。 diff --git a/design/README.md b/design/README.md index ddf06903..55f927e4 100644 --- a/design/README.md +++ b/design/README.md @@ -1,6 +1,6 @@ # design 设计稿索引 -> 更新时间:2026-04-20 +> 更新时间:2026-05-11 > > 状态口径以当前仓库真实代码为准: > - `[done]`:对应阶段或收口目标已经在当前主线代码中成立 @@ -36,6 +36,10 @@ 7. `07-ai/` - `process/` 放推进中的主线稿 - `done/` 放已在真实代码中成立的主线稿 +8. `08-wolai-aline-test-flow/` + - `process/` 放推进中的测试流程与对标执行稿 +9. `09-siyuan-reference/` + - `process/` 放思源参考、借鉴边界与能力盘点稿 ## 迁移规则 diff --git a/docs/superpowers/plans/2026-05-10-mindmap-phase6-projection-editor-checklist.md b/docs/superpowers/plans/2026-05-10-mindmap-phase6-projection-editor-checklist.md index 7f090a19..d5e30a88 100644 --- a/docs/superpowers/plans/2026-05-10-mindmap-phase6-projection-editor-checklist.md +++ b/docs/superpowers/plans/2026-05-10-mindmap-phase6-projection-editor-checklist.md @@ -253,9 +253,9 @@ - [x] adapter 初始化时请求 `mindmap.simple_mind_map_scene.get`,把 projection 的 `root/layout/theme/themeConfig/view/config` 传给真实 `simple-mind-map`。 - [x] adapter 内部真实调用 `new MindMap({ el, data, layout, theme, themeConfig, viewData, config })`。 - [x] NodeView 销毁时调用 bridge `destroy()`,清理 runtime、监听器和 DOM。 -- [ ] `data_change` / `view_data_change` 通过 `mindmap-command-diff.ts` 转换为 kernel command 或 `compatPayload.patch`,再调用 `mindmap.command.apply`。 +- [x] `data_change` / `view_data_change` 通过 `mindmap-command-diff.ts` 转换为 kernel command 或 `compatPayload.patch`,再调用 `mindmap.command.apply`。 - [x] command 成功后刷新 adapter projection 或同步 runtime revision;失败时显示 `command_failed`,不得伪装保存成功。 -- [ ] toolbar 的“子节点 / 同级节点 / 删除 / 回根 / 缩放”优先调用 runtime command,再经 command bridge 回写 kernel。 +- [x] toolbar 的“子节点 / 同级节点 / 删除 / 回根 / 缩放”优先调用 runtime command,再经 command bridge 回写 kernel。 - [x] 右侧栏和底部栏只保留第一阶段 chrome,不再占据画布主要宽度;视觉对齐 `image copy 60.png` 的内嵌 KMind 工作台。 - [x] 删除或降级旧 `.mnote-mindmap-node`、手写 `mindmap-edge`、固定 `svg viewBox` 成为 fallback/debug,不作为默认主链。 - [x] 更新 smoke:禁止以手写 `.mnote-mindmap-node` 和 `path[data-testid="mindmap-edge"]` 作为成功条件。 diff --git a/infra/convex/docker-compose.yml b/infra/convex/docker-compose.yml index fa28f8e4..770d4d1b 100644 --- a/infra/convex/docker-compose.yml +++ b/infra/convex/docker-compose.yml @@ -6,6 +6,10 @@ services: image: ghcr.io/get-convex/convex-backend@sha256:2143ad479a997802e74ac52f5f1ce3d6e75309b1965e36069d1c939166e210eb stop_grace_period: 10s stop_signal: SIGINT + ulimits: + nofile: + soft: 65535 + hard: 65535 ports: - "3210:3210" - "3211:3211" diff --git a/playwright-snapshot-auth.md b/playwright-snapshot-auth.md new file mode 100644 index 00000000..19ec28d6 --- /dev/null +++ b/playwright-snapshot-auth.md @@ -0,0 +1 @@ +- generic [ref=e2] [box=0,13,1440,39]: "{\"ok\":false,\"code\":\"convex_upstream_error\",\"message\":\"Convex mutation 失败\",\"requestId\":\"req_1778542522227_65\",\"traceId\":\"trace_1778542522227_66\"}" \ No newline at end of file diff --git a/rust/crates/bridge-runtime/src/lib.rs b/rust/crates/bridge-runtime/src/lib.rs index 2e542087..5e3b0f04 100644 --- a/rust/crates/bridge-runtime/src/lib.rs +++ b/rust/crates/bridge-runtime/src/lib.rs @@ -13,10 +13,11 @@ use core_protocol::{ DocumentReadSubtree, EditorBlock, EditorBlockDocument, EditorBlockType, EditorCommand, EditorInsertBlockAfter, EditorReplaceBlock, EmbedBlock, GetBlock, GetBridgeCommand, GetBridgeRequest, GetBridgeTrace, GetMindmap, InvocationKind, KernelAttachEdge, - KernelAuditStamp, KernelContentPayload, KernelCreateNode, KernelDetachEdge, KernelEdge, - KernelEdgeListResult, KernelEdgeType, KernelGetNode, KernelGetSubtree, KernelGraphDirection, - KernelGraphTraversalResult, KernelGraphVisit, KernelListChildren, KernelListEdges, - KernelMoveSubtree, KernelNode, KernelNodeMetadata, KernelNodeType, KernelProjectionAssetKind, + KernelAuditStamp, KernelBlockAssetRelation, KernelContentPayload, KernelCreateNode, + KernelDetachEdge, KernelEdge, KernelEdgeListResult, KernelEdgeType, KernelGetNode, + KernelGetSubtree, KernelGraphDirection, KernelGraphTraversalResult, KernelGraphVisit, + KernelListChildren, KernelListEdges, KernelMoveSubtree, KernelNode, KernelNodeMetadata, + KernelNodeType, KernelObjectIdentity, KernelObjectKind, KernelProjectionAssetKind, KernelProjectionCapability, KernelProjectionFilter, KernelProjectionItem, KernelProjectionKind, KernelProjectionRequest, KernelProjectionResourceKind, KernelProjectionResourceMeta, KernelProjectionResult, KernelProjectionRowKind, KernelRefsPayload, KernelSubtreeRef, @@ -5547,7 +5548,7 @@ fn build_mindmap_kernel_projection_result( associative_lines: collect_mindmap_associative_lines(data), layout: read_mindmap_value_field(data, &["layout", "layoutHints", "layout_hints"]) .unwrap_or_else(|| json!("logicalStructure")), - theme: read_mindmap_value_field(data, &["theme"]).unwrap_or_else(|| json!("classic")), + theme: read_mindmap_value_field(data, &["theme"]).unwrap_or_else(|| json!("default")), view: read_mindmap_value_field(data, &["view"]).unwrap_or_else(|| json!({})), capabilities: MindmapKernelCapabilities { can_edit: true, @@ -5564,6 +5565,45 @@ fn build_mindmap_kernel_projection_result( }) } +fn default_mindmap_theme_config() -> Value { + json!({ + "lineColor": "#7aa2ff", + "lineStyle": "curve", + "rootLineKeepSameInCurve": true, + "rootLineStartPositionKeepSameInCurve": true, + "generalizationLineColor": "#ef6a5b", + "backgroundColor": "#f6f8fc", + "root": { + "fillColor": "#e25563", + "color": "#ffffff", + "fontWeight": "bold", + "borderColor": "transparent", + "borderWidth": 0, + "borderRadius": 8 + }, + "second": { + "fillColor": "#4f7df3", + "color": "#ffffff", + "borderColor": "transparent", + "borderWidth": 0, + "borderRadius": 8 + }, + "node": { + "fillColor": "transparent", + "color": "#315aa9", + "borderColor": "transparent", + "borderWidth": 0 + }, + "generalization": { + "fillColor": "#ffffff", + "color": "#ef6a5b", + "borderColor": "#ef6a5b", + "borderWidth": 1, + "borderRadius": 8 + } + }) +} + fn build_mindmap_adapter_projection_result( data: &Value, mindmap_id: &str, @@ -5577,9 +5617,9 @@ fn build_mindmap_adapter_projection_result( })?, layout: read_mindmap_value_field(data, &["layout", "layoutHints", "layout_hints"]) .unwrap_or_else(|| json!("logicalStructure")), - theme: read_mindmap_value_field(data, &["theme"]).unwrap_or_else(|| json!("classic")), + theme: read_mindmap_value_field(data, &["theme"]).unwrap_or_else(|| json!("default")), theme_config: read_mindmap_value_field(data, &["themeConfig", "theme_config"]) - .unwrap_or_else(|| json!({})), + .unwrap_or_else(default_mindmap_theme_config), view: read_mindmap_value_field(data, &["view"]).unwrap_or_else(|| json!({})), config: read_mindmap_value_field(data, &["config"]).unwrap_or_else(|| json!({})), compat_payload: read_mindmap_value_field(data, &["compatPayload", "compat_payload"]) @@ -7075,6 +7115,33 @@ fn is_book_asset(file_name: &str, mime_type: &str) -> bool { .any(|suffix| lowered_name.ends_with(suffix)) } +fn is_onlyoffice_asset(file_name: &str, mime_type: &str) -> bool { + let lowered_mime = mime_type.trim().to_ascii_lowercase(); + let lowered_name = file_name.trim().to_ascii_lowercase(); + lowered_mime.contains("officedocument") + || lowered_mime.contains("msword") + || lowered_mime.contains("ms-excel") + || lowered_mime.contains("ms-powerpoint") + || [ + ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".ods", ".odp", + ] + .iter() + .any(|suffix| lowered_name.ends_with(suffix)) +} + +fn is_code_asset(file_name: &str, mime_type: &str) -> bool { + let lowered_mime = mime_type.trim().to_ascii_lowercase(); + let lowered_name = file_name.trim().to_ascii_lowercase(); + lowered_mime.starts_with("text/") + && [ + ".c", ".cc", ".cpp", ".css", ".go", ".h", ".hpp", ".html", ".java", ".js", + ".jsx", ".json", ".kt", ".lua", ".md", ".py", ".rs", ".sh", ".sql", ".toml", + ".ts", ".tsx", ".xml", ".yaml", ".yml", + ] + .iter() + .any(|suffix| lowered_name.ends_with(suffix)) +} + fn classify_asset_kind( asset_type: &str, file_name: &str, @@ -7111,7 +7178,17 @@ fn classify_asset_kind( fn classify_asset_resource_kind( asset_kind: &KernelProjectionAssetKind, + file_name: &str, + mime_type: &str, ) -> KernelProjectionResourceKind { + if matches!(asset_kind, KernelProjectionAssetKind::File) { + if is_onlyoffice_asset(file_name, mime_type) { + return KernelProjectionResourceKind::OnlyOffice; + } + if is_code_asset(file_name, mime_type) { + return KernelProjectionResourceKind::Code; + } + } match asset_kind { KernelProjectionAssetKind::Mindmap => KernelProjectionResourceKind::Mindmap, KernelProjectionAssetKind::Table => KernelProjectionResourceKind::Table, @@ -7403,6 +7480,7 @@ fn make_projection_resource_meta( resource_kind: KernelProjectionResourceKind, document_id: Option, asset_id: Option, + block_id: Option, workspace_id: Option, asset_kind: Option, icon_hint: &str, @@ -7418,6 +7496,34 @@ fn make_projection_resource_meta( ) { extra.insert("source".into(), source); } + let object_kind = match (&resource_kind, &asset_kind, asset_id.as_ref()) { + (KernelProjectionResourceKind::Document, _, _) => KernelObjectKind::Page, + (KernelProjectionResourceKind::Index, _, _) => KernelObjectKind::Index, + (KernelProjectionResourceKind::Mindmap, _, _) => KernelObjectKind::Mindmap, + (KernelProjectionResourceKind::OnlyOffice, _, _) => KernelObjectKind::OnlyOffice, + (KernelProjectionResourceKind::Code, _, _) => KernelObjectKind::Code, + (_, Some(KernelProjectionAssetKind::Mindmap), _) => KernelObjectKind::Mindmap, + (_, _, Some(_)) => KernelObjectKind::Attachment, + _ => KernelObjectKind::Page, + }; + let object_identity = Some(KernelObjectIdentity { + object_kind, + document_id: document_id.clone(), + block_id: block_id.clone(), + asset_id: asset_id.clone(), + }); + let block_asset_relation = + match (document_id.clone(), block_id, asset_id.clone(), asset_kind.clone()) { + (Some(document_id), Some(block_id), Some(asset_id), Some(asset_kind)) => { + Some(KernelBlockAssetRelation { + document_id, + block_id, + asset_id, + asset_kind, + }) + } + _ => None, + }; KernelProjectionResourceMeta { resource_kind: Some(resource_kind), document_id, @@ -7425,6 +7531,8 @@ fn make_projection_resource_meta( workspace_id, asset_kind, icon_hint: Some(icon_hint.into()), + object_identity, + block_asset_relation, extra, } } @@ -7433,6 +7541,7 @@ fn make_projection_resource_meta( struct NormalizedFileTreeAsset { id: String, document_id: String, + block_id: Option, workspace_id: Option, title: String, resource_kind: KernelProjectionResourceKind, @@ -7451,7 +7560,7 @@ fn infer_file_tree_asset_shape( ) { let asset_kind = classify_asset_kind(asset_type, file_name, mime_type); ( - classify_asset_resource_kind(&asset_kind), + classify_asset_resource_kind(&asset_kind, file_name, mime_type), asset_kind.clone(), classify_asset_icon_hint(&asset_kind), ) @@ -7472,6 +7581,7 @@ fn normalize_file_tree_asset(value: &Value) -> Option { Some(NormalizedFileTreeAsset { id, document_id, + block_id: string_field(value, "block_id").or_else(|| string_field(value, "blockId")), workspace_id: string_field(value, "workspace_id") .or_else(|| string_field(value, "workspaceId")), title: file_name, @@ -7651,6 +7761,7 @@ fn build_file_tree_projection_result( KernelProjectionResourceKind::Document, Some(node.id.clone()), None, + None, workspace_id.clone(), None, "page", @@ -7682,6 +7793,7 @@ fn build_file_tree_projection_result( KernelProjectionResourceKind::Index, Some(node.id.clone()), None, + None, workspace_id.clone(), None, "index", @@ -7728,6 +7840,7 @@ fn build_file_tree_projection_result( asset.resource_kind.clone(), Some(asset.document_id.clone()), Some(asset.id.clone()), + asset.block_id.clone(), asset.workspace_id.clone(), Some(KernelProjectionAssetKind::Mindmap), "mindmap", @@ -7768,6 +7881,7 @@ fn build_file_tree_projection_result( child_asset.resource_kind.clone(), Some(child_asset.document_id.clone()), Some(child_asset.id.clone()), + child_asset.block_id.clone(), child_asset.workspace_id.clone(), Some(child_asset.asset_kind.clone()), child_asset.icon_hint, @@ -7808,6 +7922,7 @@ fn build_file_tree_projection_result( asset.resource_kind.clone(), Some(asset.document_id.clone()), Some(asset.id.clone()), + asset.block_id.clone(), asset.workspace_id.clone(), Some(asset.asset_kind.clone()), asset.icon_hint, @@ -8141,6 +8256,7 @@ fn build_kernel_projection_result( KernelProjectionResourceKind::Document, Some(node.id.clone()), None, + None, node.workspace_id.clone(), None, "page", @@ -9189,10 +9305,24 @@ fn execute_command( source: workspace_source_value(&command_wire.source), payload_json: request.payload_json, args_json: json!({ - "docId": payload.document_id, - "mindmapId": payload.mindmap_id, + "docId": payload.document_id.clone(), + "mindmapId": payload.mindmap_id.clone(), "data": payload.data, "createOnly": payload.create_only.unwrap_or(false), + "streamDeltaHint": tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.put", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + "domainEventHint": tree_domain_event_hint("tree.resource.mindmap.put"), + "domainEventPlan": tree_domain_event_plan( + "tree.resource.mindmap.put", + tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.put", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + ), }), })) } @@ -9229,11 +9359,25 @@ fn execute_command( source: workspace_source_value(&command_wire.source), payload_json: request.payload_json, args_json: json!({ - "documentId": payload.document_id, - "mindmapId": payload.mindmap_id, + "documentId": payload.document_id.clone(), + "mindmapId": payload.mindmap_id.clone(), "commands": payload.commands, "projectionRevision": payload.projection_revision, "canonicalCommand": "mindmap.command.apply", + "streamDeltaHint": tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.command.apply", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + "domainEventHint": tree_domain_event_hint("tree.resource.mindmap.updated"), + "domainEventPlan": tree_domain_event_plan( + "tree.resource.mindmap.updated", + tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.command.apply", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + ), }), })) } @@ -9265,8 +9409,22 @@ fn execute_command( source: workspace_source_value(&command_wire.source), payload_json: request.payload_json, args_json: json!({ - "docId": payload.document_id, - "mindmapId": payload.mindmap_id, + "docId": payload.document_id.clone(), + "mindmapId": payload.mindmap_id.clone(), + "streamDeltaHint": tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.delete", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + "domainEventHint": tree_domain_event_hint("tree.resource.mindmap.deleted"), + "domainEventPlan": tree_domain_event_plan( + "tree.resource.mindmap.deleted", + tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.delete", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + ), }), })) } @@ -9299,8 +9457,22 @@ fn execute_command( source: workspace_source_value(&command_wire.source), payload_json: request.payload_json, args_json: json!({ - "docId": payload.document_id, - "mindmapId": payload.mindmap_id, + "docId": payload.document_id.clone(), + "mindmapId": payload.mindmap_id.clone(), + "streamDeltaHint": tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.restore", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + "domainEventHint": tree_domain_event_hint("tree.resource.mindmap.restored"), + "domainEventPlan": tree_domain_event_plan( + "tree.resource.mindmap.restored", + tree_stream_delta_hint("resync_required", json!({ + "reason": "mindmap.restore", + "documentId": payload.document_id.clone(), + "blockId": payload.mindmap_id.clone(), + })), + ), }), })) } @@ -10036,6 +10208,7 @@ where fn normalize_editor_block_type_for_save(raw_type: &str) -> EditorBlockType { match raw_type { + "mindmap" => EditorBlockType::Mindmap, "heading" => EditorBlockType::Heading, "bullet_list_item" | "bullet_list" | "bullet-list" => EditorBlockType::BulletListItem, "numbered_list_item" | "ordered_list" | "ordered-list" => EditorBlockType::NumberedListItem, @@ -10058,11 +10231,9 @@ fn normalize_editor_block_from_legacy(block: &Value, index: usize) -> EditorBloc let raw_type = read_trimmed_string_field(block, &["blockType", "type"]) .unwrap_or_else(|| "paragraph".into()) .to_lowercase(); + let normalized_block_type = normalize_editor_block_type_for_save(&raw_type); let mut props = BlockProps::default(); - if matches!( - normalize_editor_block_type_for_save(&raw_type), - EditorBlockType::Heading - ) { + if matches!(normalized_block_type, EditorBlockType::Heading) { props.heading_level = block .get("props") .and_then(Value::as_object) @@ -10076,20 +10247,14 @@ fn normalize_editor_block_from_legacy(block: &Value, index: usize) -> EditorBloc .and_then(|map| map.get("collapsed")) .and_then(Value::as_bool); } - if matches!( - normalize_editor_block_type_for_save(&raw_type), - EditorBlockType::Todo - ) { + if matches!(normalized_block_type, EditorBlockType::Todo) { props.checked = block .get("props") .and_then(Value::as_object) .and_then(|map| map.get("checked")) .and_then(Value::as_bool); } - if matches!( - normalize_editor_block_type_for_save(&raw_type), - EditorBlockType::CodeBlock - ) { + if matches!(normalized_block_type, EditorBlockType::CodeBlock) { props.language = block .get("props") .and_then(Value::as_object) @@ -10121,15 +10286,72 @@ fn normalize_editor_block_from_legacy(block: &Value, index: usize) -> EditorBloc { props.extra.insert("tiptapTocNode".into(), tiptap_toc); } + if matches!(normalized_block_type, EditorBlockType::Mindmap) { + let props_map = block.get("props").and_then(Value::as_object); + let legacy_data = props_map.and_then(|map| map.get("data")); + let data_object = legacy_data.and_then(Value::as_object); + if let Some(mindmap_id) = props_map + .and_then(|map| map.get("mindmapId").or_else(|| map.get("mindmap_id"))) + .and_then(Value::as_str) + .or_else(|| { + data_object.and_then(|map| { + map.get("mindmapId") + .or_else(|| map.get("mindmap_id")) + .or_else(|| map.get("id")) + .and_then(Value::as_str) + }) + }) + .map(str::trim) + .filter(|value| !value.is_empty()) + { + props + .extra + .insert("mindmapId".into(), Value::String(mindmap_id.to_string())); + } else { + props + .extra + .insert("mindmapId".into(), Value::String(block_id.clone())); + } + if let Some(root_node_id) = props_map + .and_then(|map| map.get("rootNodeId").or_else(|| map.get("root_node_id"))) + .and_then(Value::as_str) + .or_else(|| { + data_object.and_then(|map| { + map.get("rootNodeId") + .or_else(|| map.get("root_node_id")) + .and_then(Value::as_str) + }) + }) + .map(str::trim) + .filter(|value| !value.is_empty()) + { + props + .extra + .insert("rootNodeId".into(), Value::String(root_node_id.to_string())); + } + if let Some(projection_version) = props_map + .and_then(|map| map.get("projectionVersion")) + .and_then(Value::as_u64) + { + props.extra.insert( + "projectionVersion".into(), + Value::Number(projection_version.into()), + ); + } + } let text = read_trimmed_string_field(block, &["content"]) .filter(|value| !value.is_empty()) .unwrap_or_else(|| extract_inline_text(block)); EditorBlock { block_id, - block_type: normalize_editor_block_type_for_save(&raw_type), + block_type: normalized_block_type.clone(), props, - content_nodes: build_text_content_nodes(&text), + content_nodes: if matches!(normalized_block_type, EditorBlockType::Mindmap) { + vec![] + } else { + build_text_content_nodes(&text) + }, child_block_ids: vec![], } } @@ -10156,6 +10378,7 @@ fn normalize_save_editor_document( ) -> Result { if let Some(editor_document) = payload.editor_document.clone() { if let Ok(mut parsed) = serde_json::from_value::(editor_document) { + hydrate_editor_document_props_from_raw(&mut parsed, payload.editor_document.as_ref()); if parsed.document_id.trim().is_empty() { parsed.document_id = payload.document_id.clone(); } @@ -10189,6 +10412,80 @@ fn normalize_save_editor_document( )) } +fn hydrate_editor_document_props_from_raw(parsed: &mut EditorBlockDocument, raw: Option<&Value>) { + let Some(raw_blocks) = raw + .and_then(|value| value.get("blocks")) + .and_then(Value::as_array) + else { + return; + }; + for (index, block) in parsed.blocks.iter_mut().enumerate() { + if !matches!(block.block_type, EditorBlockType::Mindmap) { + continue; + } + let Some(raw_block) = raw_blocks + .iter() + .find(|candidate| { + read_trimmed_string_field(candidate, &["blockId", "block_id"]).as_deref() + == Some(block.block_id.as_str()) + }) + .or_else(|| raw_blocks.get(index)) + else { + continue; + }; + hydrate_mindmap_block_props_from_raw(block, raw_block); + } +} + +fn hydrate_mindmap_block_props_from_raw(block: &mut EditorBlock, raw_block: &Value) { + let props = raw_block.get("props").and_then(Value::as_object); + let legacy_data = props + .and_then(|map| map.get("data")) + .and_then(Value::as_object); + if let Some(mindmap_id) = props + .and_then(|map| map.get("mindmapId").or_else(|| map.get("mindmap_id"))) + .and_then(Value::as_str) + .or_else(|| { + legacy_data.and_then(|map| { + map.get("mindmapId") + .or_else(|| map.get("mindmap_id")) + .or_else(|| map.get("id")) + .and_then(Value::as_str) + }) + }) + .map(str::trim) + .filter(|value| !value.is_empty()) + { + block + .props + .extra + .insert("mindmapId".into(), Value::String(mindmap_id.to_string())); + } + for (raw_key, canonical_key) in [("rootNodeId", "rootNodeId"), ("root_node_id", "rootNodeId")] { + if let Some(value) = props + .and_then(|map| map.get(raw_key)) + .and_then(Value::as_str) + .or_else(|| legacy_data.and_then(|map| map.get(raw_key).and_then(Value::as_str))) + .map(str::trim) + .filter(|value| !value.is_empty()) + { + block + .props + .extra + .insert(canonical_key.into(), Value::String(value.to_string())); + } + } + if let Some(projection_version) = props + .and_then(|map| map.get("projectionVersion")) + .and_then(Value::as_u64) + { + block.props.extra.insert( + "projectionVersion".into(), + Value::Number(projection_version.into()), + ); + } +} + fn legacy_props_from_editor_block(block: &EditorBlock) -> Option { let mut props = serde_json::Map::new(); match block.block_type { @@ -10232,6 +10529,23 @@ fn legacy_props_from_editor_block(block: &EditorBlock) -> Option { props.insert("tiptapTocNode".into(), tiptap_toc.clone()); } } + EditorBlockType::Mindmap => { + if let Some(mindmap_id) = block.props.extra.get("mindmapId").and_then(Value::as_str) { + props.insert("mindmapId".into(), json!(mindmap_id)); + } + if let Some(root_node_id) = block.props.extra.get("rootNodeId").and_then(Value::as_str) + { + props.insert("rootNodeId".into(), json!(root_node_id)); + } + if let Some(projection_version) = block + .props + .extra + .get("projectionVersion") + .and_then(Value::as_u64) + { + props.insert("projectionVersion".into(), json!(projection_version)); + } + } _ => {} } if let Some(text_align) = block @@ -10255,6 +10569,7 @@ fn legacy_props_from_editor_block(block: &EditorBlock) -> Option { fn legacy_type_from_editor_block(block: &EditorBlock) -> &'static str { match block.block_type { EditorBlockType::Paragraph => "paragraph", + EditorBlockType::Mindmap => "mindmap", EditorBlockType::Heading => "heading", EditorBlockType::BulletListItem => "bullet_list_item", EditorBlockType::NumberedListItem => "numbered_list_item", @@ -10302,6 +10617,8 @@ fn legacy_content_from_editor_document(document: &EditorBlockDocument) -> Value "props": legacy_props_from_editor_block(block), "content": if matches!(block.block_type, EditorBlockType::Divider) { Value::Array(Vec::new()) + } else if matches!(block.block_type, EditorBlockType::Mindmap) { + Value::String(String::new()) } else { Value::String(legacy_text_from_editor_block(block)) }, @@ -11429,6 +11746,14 @@ mod tests { "text": "新标题" }) ); + assert_eq!( + plan.args_json["domainEventPlan"]["eventType"], + json!("tree.resource.mindmap.updated") + ); + assert_eq!( + plan.args_json["streamDeltaHint"]["kind"], + json!("resync_required") + ); } RuntimeExecutionPlan::Query(_) | RuntimeExecutionPlan::Tool(_) => { panic!("expected command plan") @@ -11726,16 +12051,44 @@ mod tests { match plan { RuntimeExecutionPlan::Command(plan) => { assert_eq!(plan.function_name, "mindmaps:put"); + assert_eq!(plan.args_json["docId"], json!("doc_1")); + assert_eq!(plan.args_json["mindmapId"], json!("mind_1")); assert_eq!( - plan.args_json, + plan.args_json["data"], json!({ - "docId": "doc_1", - "mindmapId": "mind_1", - "data": { - "data": {"text": "中心主题"}, - "children": [], - }, - "createOnly": true, + "data": {"text": "中心主题"}, + "children": [], + }) + ); + assert_eq!(plan.args_json["createOnly"], json!(true)); + assert_eq!( + plan.args_json["streamDeltaHint"], + json!({ + "family": "tree", + "kind": "resync_required", + "args": { + "reason": "mindmap.put", + "documentId": "doc_1", + "blockId": "mind_1", + } + }) + ); + assert_eq!( + plan.args_json["domainEventPlan"], + json!({ + "family": "tree", + "schema": "mnote.tree.domain_event", + "schemaVersion": 1, + "eventType": "tree.resource.mindmap.put", + "streamDeltaHint": { + "family": "tree", + "kind": "resync_required", + "args": { + "reason": "mindmap.put", + "documentId": "doc_1", + "blockId": "mind_1", + } + } }) ); } @@ -12317,6 +12670,178 @@ mod tests { ); } + #[test] + fn documents_save_command_plan_preserves_mindmap_placeholder() { + let plan = execute_runtime_input(RuntimeInput::Command { + context: demo_context(), + command: RuntimeCommandEnvelopeWire { + name: "documents.save".into(), + command_id: "cmd_save_mindmap".into(), + idempotency_key: Some("idem_save_mindmap".into()), + actor: RuntimeActorWire { + actor_type: "user".into(), + actor_id: "user_1".into(), + session_id: Some("sess_1".into()), + }, + source: RuntimeSourceWire { + channel: "rust-web".into(), + client: "mnote-web".into(), + source_kind: None, + root_uri: None, + workspace_id: None, + capabilities: Vec::new(), + }, + target: Some(RuntimeTargetWire { + workspace_id: Some("ws_1".into()), + page_id: Some("doc_1".into()), + block_id: None, + }), + payload: json!({ + "documentId": "doc_1", + "workspaceId": "ws_1", + "revision": 6, + "content": [], + "tiptapDocument": { + "type": "doc", + "content": [{ + "type": "paragraph", + "attrs": { + "blockId": "mind_1", + "mnoteBlockType": "mindmap", + "mindmapId": "mind_1", + "rootNodeId": "root", + "projectionVersion": 1 + } + }] + }, + "conflictDetectionKey": "doc_1:6" + }), + preflight_data: None, + reason: Some("保存导图占位".into()), + refs: vec!["phase6-mindmap".into()], + dry_run: false, + validate_only: false, + }, + }) + .expect("documents.save mindmap plan should build"); + + let RuntimeExecutionPlan::Command(plan) = plan else { + panic!("expected command plan"); + }; + + assert_eq!( + plan.args_json.pointer("/editorDocument/blocks/0/blockType"), + Some(&json!("mindmap")) + ); + assert_eq!( + plan.args_json.pointer("/content/0/type"), + Some(&json!("mindmap")) + ); + assert_eq!( + plan.args_json.pointer("/content/0/id"), + Some(&json!("mind_1")) + ); + assert_eq!( + plan.args_json.pointer("/content/0/props/mindmapId"), + Some(&json!("mind_1")) + ); + assert_eq!(plan.args_json.pointer("/content/0/props/data"), None); + assert_eq!( + plan.args_json.pointer("/content/0/content"), + Some(&json!("")) + ); + } + + #[test] + fn documents_save_command_plan_preserves_mindmap_props_from_editor_document() { + let plan = execute_runtime_input(RuntimeInput::Command { + context: demo_context(), + command: RuntimeCommandEnvelopeWire { + name: "page.body.save".into(), + command_id: "cmd_save_mindmap_editor_document".into(), + idempotency_key: Some("idem_save_mindmap_editor_document".into()), + actor: RuntimeActorWire { + actor_type: "user".into(), + actor_id: "user_1".into(), + session_id: Some("sess_1".into()), + }, + source: RuntimeSourceWire { + channel: "rust-web".into(), + client: "mnote-web".into(), + source_kind: None, + root_uri: None, + workspace_id: None, + capabilities: Vec::new(), + }, + target: Some(RuntimeTargetWire { + workspace_id: Some("ws_1".into()), + page_id: Some("doc_1".into()), + block_id: None, + }), + payload: json!({ + "documentId": "doc_1", + "workspaceId": "ws_1", + "revision": 7, + "editorDocument": { + "documentId": "doc_1", + "rootBlockIds": ["block-1"], + "blocks": [{ + "blockId": "block-1", + "blockType": "mindmap", + "props": { + "data": null, + "mindmapId": "mind_1", + "rootNodeId": "root", + "projectionVersion": 1 + }, + "contentNodes": [], + "childBlockIds": [] + }] + }, + "content": [], + "tiptapDocument": { + "type": "doc", + "content": [{ + "type": "paragraph", + "attrs": { + "blockId": "block-1", + "mnoteBlockType": "mindmap", + "mindmapId": "mind_1", + "rootNodeId": "root", + "projectionVersion": 1 + } + }] + }, + "conflictDetectionKey": "doc_1:7" + }), + preflight_data: None, + reason: Some("保存 editorDocument 导图占位".into()), + refs: vec!["task169-mindmap-realtime-smoke".into()], + dry_run: false, + validate_only: false, + }, + }) + .expect("page.body.save mindmap editorDocument plan should build"); + + let RuntimeExecutionPlan::Command(plan) = plan else { + panic!("expected command plan"); + }; + + assert_eq!( + plan.args_json.pointer("/content/0/props/mindmapId"), + Some(&json!("mind_1")) + ); + assert_eq!( + plan.args_json.pointer("/content/0/props/rootNodeId"), + Some(&json!("root")) + ); + assert_eq!( + plan.args_json.pointer("/content/0/props/projectionVersion"), + Some(&json!(1)) + ); + assert_eq!(plan.args_json.pointer("/content/0/props/data"), None); + } + #[test] fn documents_save_command_plan_preserves_tiptap_image() { let plan = execute_runtime_input(RuntimeInput::Command { @@ -16219,6 +16744,7 @@ mod tests { "id": "mind_1", "workspace_id": "ws_1", "document_id": "page_root", + "block_id": "block_mind_1", "asset_type": "mindmap", "file_name": "roadmap.json", "mime_type": "application/json", @@ -16293,6 +16819,15 @@ mod tests { item_by_row_id["index:page_root"]["resourceMeta"]["resourceKind"], json!("index") ); + assert_eq!( + item_by_row_id["index:page_root"]["resourceMeta"]["objectIdentity"], + json!({ + "objectKind": "index", + "documentId": "page_root", + "blockId": null, + "assetId": null + }) + ); assert_eq!( item_by_row_id["index:page_root"]["resourceMeta"]["extra"]["source"], json!({ @@ -16333,6 +16868,24 @@ mod tests { item_by_row_id["asset-folder:mind_1"]["resourceMeta"]["assetKind"], json!("mindmap") ); + assert_eq!( + item_by_row_id["asset-folder:mind_1"]["resourceMeta"]["objectIdentity"], + json!({ + "objectKind": "mindmap", + "documentId": "page_root", + "blockId": "block_mind_1", + "assetId": "mind_1" + }) + ); + assert_eq!( + item_by_row_id["asset-folder:mind_1"]["resourceMeta"]["blockAssetRelation"], + json!({ + "documentId": "page_root", + "blockId": "block_mind_1", + "assetId": "mind_1", + "assetKind": "mindmap" + }) + ); assert_eq!( item_by_row_id["asset:asset_ref_1"]["parentNodeId"], json!("asset-folder:mind_1") @@ -16566,6 +17119,108 @@ mod tests { assert!(!row_ids.contains(&"asset:asset_rust_child")); } + #[test] + fn kernel_file_tree_projection_separates_attachment_object_identities() { + let result = execute_runtime_query(RuntimeInput::Query { + context: demo_context(), + query: RuntimeQueryEnvelopeWire { + name: "kernel.project_view".into(), + payload: json!({ + "projection": "file_tree", + "workspaceId": "ws_1", + "rootNodeId": "page_root", + "depth": 2, + "includeEdges": true, + "nodeTypes": ["page"], + }), + }, + data: Some(json!({ + "documents": [ + { + "id": "page_root", + "workspace_id": "ws_1", + "title": "根页面", + "parent_id": null, + "sort_order": 0, + "is_starred": true, + "is_template": false, + "created_at": "2026-04-16T00:00:00Z", + "updated_at": "2026-04-16T00:00:00Z" + } + ], + "media_assets": [ + { + "id": "office_1", + "workspace_id": "ws_1", + "document_id": "page_root", + "block_id": "block_office_1", + "asset_type": "file", + "file_name": "contract.docx", + "mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + }, + { + "id": "code_1", + "workspace_id": "ws_1", + "document_id": "page_root", + "block_id": "block_code_1", + "asset_type": "file", + "file_name": "main.rs", + "mime_type": "text/rust" + }, + { + "id": "image_1", + "workspace_id": "ws_1", + "document_id": "page_root", + "block_id": "block_image_1", + "asset_type": "file", + "file_name": "cover.png", + "mime_type": "image/png" + } + ], + "mindmap_assets": [], + "table_assets": [], + "mindmap_asset_children": {} + })), + }) + .expect("file_tree object identity projection should build"); + + let items = result["items"].as_array().expect("items should be array"); + let item_by_row_id = items + .iter() + .filter_map(|item| { + item.get("rowId") + .and_then(Value::as_str) + .map(|row_id| (row_id.to_string(), item)) + }) + .collect::>(); + + assert_eq!( + item_by_row_id["asset:office_1"]["resourceMeta"]["resourceKind"], + json!("only_office") + ); + assert_eq!( + item_by_row_id["asset:office_1"]["resourceMeta"]["objectIdentity"]["objectKind"], + json!("only_office") + ); + assert_eq!( + item_by_row_id["asset:code_1"]["resourceMeta"]["resourceKind"], + json!("code") + ); + assert_eq!( + item_by_row_id["asset:code_1"]["resourceMeta"]["objectIdentity"]["objectKind"], + json!("code") + ); + assert_eq!( + item_by_row_id["asset:image_1"]["resourceMeta"]["objectIdentity"], + json!({ + "objectKind": "attachment", + "documentId": "page_root", + "blockId": "block_image_1", + "assetId": "image_1" + }) + ); + } + #[test] fn kernel_file_tree_projection_query_matches_index_resource() { let result = execute_runtime_query(RuntimeInput::Query { diff --git a/rust/crates/core-protocol/src/editor/mod.rs b/rust/crates/core-protocol/src/editor/mod.rs index 986f087b..4dbc5ba5 100644 --- a/rust/crates/core-protocol/src/editor/mod.rs +++ b/rust/crates/core-protocol/src/editor/mod.rs @@ -54,6 +54,10 @@ mod tests { serde_json::to_string(&EditorBlockType::PageReference).unwrap(), "\"page_reference\"" ); + assert_eq!( + serde_json::to_string(&EditorBlockType::Mindmap).unwrap(), + "\"mindmap\"" + ); assert_eq!( serde_json::to_string(&EditorBlockType::BlockReference).unwrap(), "\"block_reference\"" diff --git a/rust/crates/core-protocol/src/editor/model.rs b/rust/crates/core-protocol/src/editor/model.rs index 26430740..a64d82c4 100644 --- a/rust/crates/core-protocol/src/editor/model.rs +++ b/rust/crates/core-protocol/src/editor/model.rs @@ -6,6 +6,7 @@ use std::collections::BTreeMap; #[serde(rename_all = "snake_case")] pub enum EditorBlockType { Paragraph, + Mindmap, Heading, BulletListItem, NumberedListItem, diff --git a/rust/crates/core-protocol/src/editor/tiptap.rs b/rust/crates/core-protocol/src/editor/tiptap.rs index 3a088c6d..0051fddd 100644 --- a/rust/crates/core-protocol/src/editor/tiptap.rs +++ b/rust/crates/core-protocol/src/editor/tiptap.rs @@ -58,6 +58,16 @@ pub struct TiptapParagraphAttrs { pub block_id: Option, #[serde(default)] pub text_align: Option, + #[serde(default)] + pub mnote_block_type: Option, + #[serde(default)] + pub mindmap_id: Option, + #[serde(default)] + pub root_node_id: Option, + #[serde(default)] + pub projection_version: Option, + #[serde(flatten, default)] + pub extra: BTreeMap, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] @@ -371,6 +381,54 @@ fn props_with_text_align(text_align: Option) -> BlockProps { props } +fn props_with_mindmap_attrs(attrs: &TiptapParagraphAttrs) -> BlockProps { + let mut props = props_with_text_align(attrs.text_align.clone()); + if let Some(mindmap_id) = attrs + .mindmap_id + .as_deref() + .map(str::trim) + .filter(|value| !value.is_empty()) + { + props + .extra + .insert("mindmapId".into(), Value::String(mindmap_id.to_string())); + } + if let Some(root_node_id) = attrs + .root_node_id + .as_deref() + .map(str::trim) + .filter(|value| !value.is_empty()) + { + props + .extra + .insert("rootNodeId".into(), Value::String(root_node_id.to_string())); + } + if let Some(projection_version) = attrs.projection_version { + props.extra.insert( + "projectionVersion".into(), + Value::Number(projection_version.into()), + ); + } + for (key, value) in &attrs.extra { + props.extra.insert(key.clone(), value.clone()); + } + props +} + +fn read_extra_string(props: &BlockProps, key: &str) -> Option { + props + .extra + .get(key) + .and_then(Value::as_str) + .map(str::trim) + .filter(|value| !value.is_empty()) + .map(ToOwned::to_owned) +} + +fn read_extra_u64(props: &BlockProps, key: &str) -> Option { + props.extra.get(key).and_then(Value::as_u64) +} + impl EditorBlockDocumentTiptapBridge { pub fn to_tiptap_doc( document: &EditorBlockDocument, @@ -474,6 +532,11 @@ fn list_item_content_from_block( attrs: TiptapParagraphAttrs { block_id: Some(block.block_id.clone()), text_align: text_align_from_props(&block.props), + mnote_block_type: None, + mindmap_id: None, + root_node_id: None, + projection_version: None, + extra: BTreeMap::new(), }, content: inline_content, }]; @@ -491,9 +554,40 @@ fn block_to_tiptap_node( attrs: TiptapParagraphAttrs { block_id: Some(block.block_id.clone()), text_align: text_align_from_props(&block.props), + mnote_block_type: None, + mindmap_id: None, + root_node_id: None, + projection_version: None, + extra: BTreeMap::new(), }, content, }), + EditorBlockType::Mindmap => { + let mut extra = block.props.extra.clone(); + extra.remove("textAlign"); + extra.remove("text_align"); + extra.remove("mindmapId"); + extra.remove("rootNodeId"); + extra.remove("projectionVersion"); + if !extra.contains_key("mnoteMindmapData") { + if let Some(data) = block.props.extra.get("data") { + extra.insert("mnoteMindmapData".into(), data.clone()); + } + } + Ok(TiptapNode::Paragraph { + attrs: TiptapParagraphAttrs { + block_id: Some(block.block_id.clone()), + text_align: text_align_from_props(&block.props), + mnote_block_type: Some("mindmap".into()), + mindmap_id: read_extra_string(&block.props, "mindmapId") + .or_else(|| Some(block.block_id.clone())), + root_node_id: read_extra_string(&block.props, "rootNodeId"), + projection_version: read_extra_u64(&block.props, "projectionVersion"), + extra, + }, + content: Vec::new(), + }) + } EditorBlockType::Heading => Ok(TiptapNode::Heading { attrs: TiptapHeadingAttrs { level: block.props.heading_level.unwrap_or(1), @@ -546,6 +640,11 @@ fn block_to_tiptap_node( attrs: TiptapParagraphAttrs { block_id: Some(block.block_id.clone()), text_align: text_align_from_props(&block.props), + mnote_block_type: None, + mindmap_id: None, + root_node_id: None, + projection_version: None, + extra: BTreeMap::new(), }, content, }], @@ -584,6 +683,21 @@ fn node_to_block( ) -> Result { let fallback_block_id = format!("block_{}", index + 1); match node { + TiptapNode::Paragraph { attrs, .. } + if attrs.mnote_block_type.as_deref() == Some("mindmap") => + { + Ok(EditorBlock { + block_id: attrs + .block_id + .clone() + .or_else(|| attrs.mindmap_id.clone()) + .unwrap_or(fallback_block_id), + block_type: EditorBlockType::Mindmap, + props: props_with_mindmap_attrs(attrs), + content_nodes: vec![], + child_block_ids: vec![], + }) + } TiptapNode::Paragraph { attrs, content } => Ok(EditorBlock { block_id: attrs.block_id.clone().unwrap_or(fallback_block_id), block_type: EditorBlockType::Paragraph, @@ -1118,6 +1232,7 @@ mod tests { attrs: TiptapParagraphAttrs { block_id: Some("align_1".into()), text_align: Some("center".into()), + ..TiptapParagraphAttrs::default() }, content: vec![TiptapNode::Text { text: "E20 center".into(), @@ -1143,4 +1258,34 @@ mod tests { }; assert_eq!(attrs.text_align.as_deref(), Some("center")); } + + #[test] + fn preserves_mindmap_paragraph_placeholder() { + let doc = TiptapNode::Doc { + content: vec![TiptapNode::Paragraph { + attrs: TiptapParagraphAttrs { + block_id: Some("mind_1".into()), + mnote_block_type: Some("mindmap".into()), + mindmap_id: Some("mind_1".into()), + root_node_id: Some("root".into()), + projection_version: Some(1), + ..TiptapParagraphAttrs::default() + }, + content: vec![], + }], + }; + + let parsed = EditorBlockDocumentTiptapBridge::from_tiptap_doc("doc_1", &doc) + .expect("mindmap placeholder should convert to mindmap block"); + assert_eq!(parsed.root_block_ids, vec!["mind_1"]); + assert_eq!(parsed.blocks[0].block_type, EditorBlockType::Mindmap); + assert_eq!( + parsed.blocks[0].props.extra.get("mindmapId"), + Some(&serde_json::json!("mind_1")) + ); + + let restored = EditorBlockDocumentTiptapBridge::to_tiptap_doc(&parsed) + .expect("mindmap block should restore to paragraph placeholder"); + assert_eq!(restored, doc); + } } diff --git a/rust/crates/core-protocol/src/kernel.rs b/rust/crates/core-protocol/src/kernel.rs index 15adb7fc..972dad76 100644 --- a/rust/crates/core-protocol/src/kernel.rs +++ b/rust/crates/core-protocol/src/kernel.rs @@ -112,6 +112,9 @@ pub enum KernelProjectionResourceKind { Asset, AssetFolder, Mindmap, + Attachment, + OnlyOffice, + Code, Table, Book, Pdf, @@ -131,6 +134,35 @@ pub enum KernelProjectionAssetKind { Unknown, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum KernelObjectKind { + Page, + Index, + Mindmap, + Attachment, + OnlyOffice, + Code, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct KernelObjectIdentity { + pub object_kind: KernelObjectKind, + pub document_id: Option, + pub block_id: Option, + pub asset_id: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct KernelBlockAssetRelation { + pub document_id: String, + pub block_id: String, + pub asset_id: String, + pub asset_kind: KernelProjectionAssetKind, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum KernelGraphDirection { @@ -367,6 +399,10 @@ pub struct KernelProjectionResourceMeta { pub workspace_id: Option, pub asset_kind: Option, pub icon_hint: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub object_identity: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block_asset_relation: Option, #[serde(default)] pub extra: BTreeMap, } @@ -649,6 +685,8 @@ mod tests { workspace_id: Some("ws_1".into()), asset_kind: Some(KernelProjectionAssetKind::File), icon_hint: Some("page".into()), + object_identity: None, + block_asset_relation: None, extra: BTreeMap::new(), }), icon_hint: Some("page".into()), diff --git a/rust/crates/core-protocol/src/lib.rs b/rust/crates/core-protocol/src/lib.rs index 7b77883f..e6c7f6f1 100644 --- a/rust/crates/core-protocol/src/lib.rs +++ b/rust/crates/core-protocol/src/lib.rs @@ -40,10 +40,11 @@ pub use kernel::{ DocumentContentResult, DocumentReadEvidenceItem, DocumentReadEvidenceKind, DocumentReadNode, DocumentReadNodeMeta, DocumentReadNodeType, DocumentReadOutlineEntry, DocumentReadPageSubtree, DocumentReadStats, DocumentReadSubtree, KernelAttachEdge, KernelAuditStamp, - KernelContentPayload, KernelCreateNode, KernelDetachEdge, KernelEdge, KernelEdgeListResult, - KernelEdgeType, KernelGetNode, KernelGetSubtree, KernelGraphDirection, - KernelGraphTraversalResult, KernelGraphVisit, KernelListChildren, KernelListEdges, - KernelMoveSubtree, KernelNode, KernelNodeMetadata, KernelNodeType, KernelProjectionAssetKind, + KernelBlockAssetRelation, KernelContentPayload, KernelCreateNode, KernelDetachEdge, + KernelEdge, KernelEdgeListResult, KernelEdgeType, KernelGetNode, KernelGetSubtree, + KernelGraphDirection, KernelGraphTraversalResult, KernelGraphVisit, KernelListChildren, + KernelListEdges, KernelMoveSubtree, KernelNode, KernelNodeMetadata, KernelNodeType, + KernelObjectIdentity, KernelObjectKind, KernelProjectionAssetKind, KernelProjectionCapability, KernelProjectionFilter, KernelProjectionItem, KernelProjectionKind, KernelProjectionRequest, KernelProjectionResourceKind, KernelProjectionResourceMeta, KernelProjectionResult, KernelProjectionRowKind, KernelRefsPayload, KernelSubtreeRef, diff --git a/rust/crates/core-protocol/tests/editor_tiptap_bridge.rs b/rust/crates/core-protocol/tests/editor_tiptap_bridge.rs index ec3c3ad2..8917d7e5 100644 --- a/rust/crates/core-protocol/tests/editor_tiptap_bridge.rs +++ b/rust/crates/core-protocol/tests/editor_tiptap_bridge.rs @@ -150,6 +150,7 @@ fn tiptap_import_preserves_explicit_block_ids_and_marks() { attrs: TiptapParagraphAttrs { block_id: Some("p-1".into()), text_align: None, + ..TiptapParagraphAttrs::default() }, content: vec![TiptapNode::Text { text: "Hello".into(), @@ -183,6 +184,7 @@ fn tiptap_import_preserves_explicit_block_ids_and_marks() { attrs: TiptapParagraphAttrs { block_id: Some("t-1".into()), text_align: None, + ..TiptapParagraphAttrs::default() }, content: vec![TiptapNode::Text { text: "todo".into(), @@ -335,3 +337,41 @@ fn tiptap_table_round_trip_preserves_table_node() { Some(&serde_json::json!("A1")) ); } + +#[test] +fn tiptap_mindmap_placeholder_round_trip_preserves_mindmap_attrs() { + let doc: TiptapNode = serde_json::from_value(serde_json::json!({ + "type": "doc", + "content": [{ + "type": "paragraph", + "attrs": { + "blockId": "mind_1", + "mnoteBlockType": "mindmap", + "mindmapId": "mind_1", + "rootNodeId": "root", + "projectionVersion": 1 + } + }] + })) + .expect("mindmap placeholder JSON should parse"); + + let imported = EditorBlockDocumentTiptapBridge::from_tiptap_doc("doc_mindmap", &doc) + .expect("mindmap placeholder should import"); + assert_eq!(imported.blocks[0].block_type, EditorBlockType::Mindmap); + assert_eq!( + imported.blocks[0].props.extra.get("mindmapId"), + Some(&serde_json::json!("mind_1")) + ); + + let exported = + EditorBlockDocumentTiptapBridge::to_tiptap_doc(&imported).expect("mindmap should export"); + let exported_value = serde_json::to_value(exported).expect("exported doc should serialize"); + assert_eq!( + exported_value.pointer("/content/0/attrs/mnoteBlockType"), + Some(&serde_json::json!("mindmap")) + ); + assert_eq!( + exported_value.pointer("/content/0/attrs/mindmapId"), + Some(&serde_json::json!("mind_1")) + ); +} diff --git a/rust/crates/core-protocol/tests/resource_tree_contract.rs b/rust/crates/core-protocol/tests/resource_tree_contract.rs new file mode 100644 index 00000000..d8206397 --- /dev/null +++ b/rust/crates/core-protocol/tests/resource_tree_contract.rs @@ -0,0 +1,89 @@ +use core_protocol::{ + KernelBlockAssetRelation, KernelObjectIdentity, KernelObjectKind, KernelProjectionAssetKind, + KernelProjectionResourceKind, KernelProjectionResourceMeta, +}; + +#[test] +fn object_identity_separates_index_body_from_mindmap_asset() { + let index_identity = KernelObjectIdentity { + object_kind: KernelObjectKind::Index, + document_id: Some("doc_1".into()), + block_id: None, + asset_id: None, + }; + let mindmap_identity = KernelObjectIdentity { + object_kind: KernelObjectKind::Mindmap, + document_id: Some("doc_1".into()), + block_id: Some("block_mindmap_1".into()), + asset_id: Some("mind_1".into()), + }; + + assert_ne!(index_identity, mindmap_identity); + + let index_json = serde_json::to_value(&index_identity).expect("index identity 序列化"); + let mindmap_json = serde_json::to_value(&mindmap_identity).expect("mindmap identity 序列化"); + + assert_eq!(index_json["objectKind"], "index"); + assert_eq!(index_json["documentId"], "doc_1"); + assert_eq!(mindmap_json["objectKind"], "mindmap"); + assert_eq!(mindmap_json["assetId"], "mind_1"); +} + +#[test] +fn resource_meta_can_describe_asset_object_kinds() { + let cases = [ + ( + KernelObjectKind::Mindmap, + KernelProjectionResourceKind::Mindmap, + KernelProjectionAssetKind::Mindmap, + "mind_1", + ), + ( + KernelObjectKind::OnlyOffice, + KernelProjectionResourceKind::OnlyOffice, + KernelProjectionAssetKind::File, + "office_1", + ), + ( + KernelObjectKind::Attachment, + KernelProjectionResourceKind::Attachment, + KernelProjectionAssetKind::Image, + "image_1", + ), + ( + KernelObjectKind::Code, + KernelProjectionResourceKind::Code, + KernelProjectionAssetKind::File, + "code_1", + ), + ]; + + for (object_kind, resource_kind, asset_kind, asset_id) in cases { + let meta = KernelProjectionResourceMeta { + resource_kind: Some(resource_kind), + document_id: Some("doc_1".into()), + asset_id: Some(asset_id.into()), + workspace_id: Some("ws_1".into()), + asset_kind: Some(asset_kind.clone()), + icon_hint: None, + object_identity: Some(KernelObjectIdentity { + object_kind, + document_id: Some("doc_1".into()), + block_id: Some("block_1".into()), + asset_id: Some(asset_id.into()), + }), + block_asset_relation: Some(KernelBlockAssetRelation { + document_id: "doc_1".into(), + block_id: "block_1".into(), + asset_id: asset_id.into(), + asset_kind, + }), + extra: Default::default(), + }; + + let json = serde_json::to_value(&meta).expect("resource meta 序列化"); + assert_eq!(json["objectIdentity"]["documentId"], "doc_1"); + assert_eq!(json["blockAssetRelation"]["blockId"], "block_1"); + assert_eq!(json["blockAssetRelation"]["assetId"], asset_id); + } +} diff --git a/rust/crates/mnote-web/src/routes/documents.rs b/rust/crates/mnote-web/src/routes/documents.rs index 831db016..8b5a7cf2 100644 --- a/rust/crates/mnote-web/src/routes/documents.rs +++ b/rust/crates/mnote-web/src/routes/documents.rs @@ -1,7 +1,9 @@ use crate::app::AppState; use crate::context::RequestContext; use crate::error::WebError; -use crate::routes::command_support::execute_runtime_command_via_convex; +use crate::routes::command_support::{ + execute_runtime_command_via_convex, execute_runtime_command_via_convex_with_artifacts, +}; use crate::routes::local_folder_source::{ save_local_markdown_page, update_local_markdown_title, update_local_page_options, }; @@ -574,17 +576,21 @@ pub async fn save( dry_run: false, validate_only: false, }; - let mut result = execute_runtime_command_via_convex( + let execution = execute_runtime_command_via_convex_with_artifacts( state.config(), &context, effective_workspace_id.as_deref(), command, ) .await?; + let mut result = execution.result; if let Value::Object(map) = &mut result { map.insert("executedCommand".into(), json!("page.body.save")); map.insert("canonicalCommand".into(), json!("page.body.save")); map.insert("compatRoute".into(), json!("/api/documents/save")); + if let Some(artifact_error) = execution.artifact_error { + map.insert("artifactError".into(), json!(artifact_error)); + } } Ok(ok_response(&context, result)) } diff --git a/rust/crates/mnote-web/src/routes/gateway.rs b/rust/crates/mnote-web/src/routes/gateway.rs index de363410..c651d15c 100644 --- a/rust/crates/mnote-web/src/routes/gateway.rs +++ b/rust/crates/mnote-web/src/routes/gateway.rs @@ -3,8 +3,9 @@ use crate::context::RequestContext; use crate::error::WebError; use crate::routes::local_folder_source::load_local_folder_page_tree_snapshot; use crate::routes::web_shell::{ - build_editor_bootstrap_json, build_page_aggregate_snapshot, escape_html, escape_script_json, - load_file_tree_html, load_sidebar_tree_html, load_workspace_shell_projection, + build_document_panes_bootstrap_json, build_editor_bootstrap_json, + build_page_aggregate_snapshot, escape_html, escape_script_json, load_file_tree_html, + load_sidebar_tree_html, load_workspace_shell_projection, render_document_title_controller_script, render_editor_island_adapter_script, render_local_file_tree_html, render_local_sidebar_tree_html, }; @@ -336,6 +337,17 @@ pub async fn root_entry( active_source_kind.as_deref(), active_root_uri.as_deref(), ); + let panes_bootstrap_json = build_document_panes_bootstrap_json( + &aggregate, + &context, + active_source_kind.as_deref(), + active_root_uri.as_deref(), + None, + None, + None, + false, + false, + ); let content = crate::ssr::render_view(leptos::view! { {} + {} {}"#, escape_script_json(&snapshot_json), escape_script_json(&bootstrap_json), + escape_script_json(&panes_bootstrap_json), render_document_title_controller_script(), render_editor_island_adapter_script(), ); @@ -953,6 +967,20 @@ mod tests { legacy_next_base_url: String, enable_legacy_next_compat: bool, convex_url: Option, + ) -> axum::Router { + app_with_query_fixtures( + legacy_next_base_url, + enable_legacy_next_compat, + convex_url, + None, + ) + } + + fn app_with_query_fixtures( + legacy_next_base_url: String, + enable_legacy_next_compat: bool, + convex_url: Option, + query_fixtures_json: Option, ) -> axum::Router { build_app(AppState::new(AppConfig { service_name: "mnote-web".into(), @@ -967,7 +995,7 @@ mod tests { convex_url, convex_admin_key: None, allow_dev_fixtures: true, - query_fixtures_json: None, + query_fixtures_json, mutation_fixtures_json: Some(r#"{"workspaces:ensureDefaultWorkspace":{"workspaces":[{"id":"ws_demo","name":"我的空间","type":"personal","iconUrl":null,"memberCount":1,"isDefault":true}],"activeWorkspaceId":"ws_demo"}}"#.into()), dev_user_id: "dev-user".into(), dev_user_name: "开发用户".into(), @@ -1221,6 +1249,55 @@ mod tests { assert!(html.contains(r#"data-root-active-page-id="page_child""#)); } + #[tokio::test] + async fn root_entry_active_page_includes_document_panes_bootstrap() { + let response = app_with_query_fixtures( + "http://127.0.0.1:3100".into(), + false, + None, + Some( + r#"{ + "documents:getMeta": { + "id": "doc_1", + "workspace_id": "ws_demo", + "title": "服务端页面", + "updated_at": "2026-04-18T09:30:00Z", + "can_edit": true, + "word_count": 42, + "character_count": 128, + "block_count": 1 + }, + "documents:getContent": { + "content": [{"id": "block_1", "type": "paragraph", "content": []}], + "revision": 7, + "conflict_detection_key": "doc_1:7", + "pageSubtree": {"rootNodeId": "doc_1", "outline": []} + } + }"# + .into(), + ), + ) + .oneshot( + Request::builder() + .uri("/?pageId=doc_1&workspaceId=ws_demo") + .header("x-mnote-actor-id", "user_real") + .header("x-mnote-actor-type", "user") + .body(Body::empty()) + .expect("request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::OK); + let body = to_bytes(response.into_body(), usize::MAX) + .await + .expect("body"); + let html = String::from_utf8(body.to_vec()).expect("utf8"); + assert!(html.contains("__MNOTE_PAGE_AGGREGATE__")); + assert!(html.contains("__MNOTE_DOCUMENT_PANES_BOOTSTRAP__")); + assert!(html.contains("mnote.document_panes_bootstrap.v1")); + } + #[tokio::test] async fn root_entry_renders_local_folder_without_debug_tree_route() { let root = diff --git a/rust/crates/mnote-web/src/routes/mindmap_api.rs b/rust/crates/mnote-web/src/routes/mindmap_api.rs index ccbfd971..7a2d85b3 100644 --- a/rust/crates/mnote-web/src/routes/mindmap_api.rs +++ b/rust/crates/mnote-web/src/routes/mindmap_api.rs @@ -1,9 +1,10 @@ use crate::app::AppState; use crate::context::RequestContext; use crate::error::WebError; -use crate::routes::command_support::execute_runtime_command_via_convex; +use crate::routes::command_support::execute_runtime_command_via_convex_with_artifacts; use crate::routes::query_support::{ - execute_runtime_query_via_convex, fetch_query_data_via_convex, resolve_effective_workspace_id, + execute_runtime_query_via_convex, fetch_documents_meta_via_convex, fetch_query_data_via_convex, + resolve_effective_workspace_id, }; use axum::extract::{Extension, Path, Query, State}; use axum::http::{HeaderMap, HeaderName, HeaderValue, StatusCode}; @@ -35,6 +36,15 @@ pub struct MindmapCommandRequest { pub commands: Vec, pub projection_revision: Option, pub workspace_id: Option, + pub data: Option, + pub create_only: Option, +} + +fn default_mindmap_data() -> Value { + json!({ + "data": {"text": "中心主题"}, + "children": [], + }) } fn response_headers() -> HeaderMap { @@ -62,6 +72,41 @@ fn resolve_query_name(params: &MindmapQueryParams) -> &'static str { "mindmap.projection.get" } +fn read_workspace_id_from_meta(meta: &Value) -> Option { + meta.get("workspace_id") + .or_else(|| meta.get("workspaceId")) + .and_then(Value::as_str) + .map(str::trim) + .filter(|value| !value.is_empty()) + .map(ToOwned::to_owned) +} + +async fn resolve_mindmap_workspace_id( + state: &AppState, + context: &RequestContext, + explicit_workspace_id: Option<&str>, + document_id: &str, +) -> Result, WebError> { + let effective_workspace_id = + resolve_effective_workspace_id(context, explicit_workspace_id, false)?; + if effective_workspace_id.is_some() { + return Ok(effective_workspace_id); + } + + // 思维导图 runtime 的历史请求体不一定带 workspaceId; + // 这里从页面 meta 反查,确保后续 command artifacts 能进入正确 workspace 的实时流。 + let meta = fetch_documents_meta_via_convex(state.config(), context, None, document_id).await?; + Ok(read_workspace_id_from_meta(&meta)) +} + +fn execution_artifacts_json(execution: &crate::transport::convex::ConvexCommandExecution) -> Value { + execution + .artifacts + .as_ref() + .and_then(|artifacts| serde_json::to_value(artifacts).ok()) + .unwrap_or(Value::Null) +} + pub async fn get_mindmap( State(state): State, Extension(context): Extension, @@ -114,15 +159,79 @@ pub async fn apply_mindmap_command( ) .with_context(&context)); } - if body.command_name.as_deref() != Some("mindmap.command.apply") { + let command_name = body.command_name.as_deref(); + if !matches!( + command_name, + None | Some("mindmaps.put") | Some("mindmap.command.apply") + ) { return Err(WebError::bad_request_code( "mindmap_command_required", - "仅支持 mindmap.command.apply", + "仅支持 mindmaps.put 或 mindmap.command.apply", ) .with_context(&context)); } let effective_workspace_id = - resolve_effective_workspace_id(&context, body.workspace_id.as_deref(), false)?; + resolve_mindmap_workspace_id(&state, &context, body.workspace_id.as_deref(), document_id) + .await?; + + if command_name != Some("mindmap.command.apply") { + let command = RuntimeCommandEnvelopeWire { + name: "mindmaps.put".into(), + command_id: format!("mindmap_put_{}", context.trace.request_id), + idempotency_key: context.source.idempotency_key.clone(), + actor: RuntimeActorWire { + actor_type: context.auth.actor_type.clone(), + actor_id: context.auth.actor_id.clone(), + session_id: context.auth.session_id.clone(), + }, + source: RuntimeSourceWire { + channel: context.source.channel.clone(), + client: context.source.client.clone(), + source_kind: None, + root_uri: None, + workspace_id: None, + capabilities: Vec::new(), + }, + target: Some(RuntimeTargetWire { + workspace_id: effective_workspace_id.clone(), + page_id: Some(document_id.to_string()), + block_id: Some(mindmap_id.to_string()), + }), + payload: json!({ + "documentId": document_id, + "mindmapId": mindmap_id, + "workspaceId": effective_workspace_id, + "data": body.data.unwrap_or_else(default_mindmap_data), + "createOnly": body.create_only.unwrap_or(false), + }), + preflight_data: None, + reason: Some("mnote-web mindmap put via kernel projection".into()), + refs: vec!["task168-mindmap-put-validator-smoke".into()], + dry_run: false, + validate_only: false, + }; + + let execution = execute_runtime_command_via_convex_with_artifacts( + state.config(), + &context, + effective_workspace_id.as_deref(), + command, + ) + .await?; + + return Ok(( + StatusCode::OK, + response_headers(), + Json(json!({ + "ok": true, + "commandName": "mindmaps.put", + "result": execution.result, + "artifacts": execution_artifacts_json(&execution), + "artifactError": execution.artifact_error, + })), + )); + } + let current = fetch_query_data_via_convex( state.config(), &context, @@ -184,7 +293,7 @@ pub async fn apply_mindmap_command( validate_only: false, }; - let result = execute_runtime_command_via_convex( + let execution = execute_runtime_command_via_convex_with_artifacts( state.config(), &context, effective_workspace_id.as_deref(), @@ -201,7 +310,96 @@ pub async fn apply_mindmap_command( "applied": applied.applied, "errors": applied.errors, "projectionRevision": body.projection_revision, - "result": result, + "result": execution.result, + "artifacts": execution_artifacts_json(&execution), + "artifactError": execution.artifact_error, })), )) } + +#[cfg(test)] +mod tests { + use crate::app::{build_app, AppConfig, AppState}; + use axum::body::{to_bytes, Body}; + use axum::http::{Request, StatusCode}; + use serde_json::{json, Value}; + use tower::util::ServiceExt; + + fn app() -> axum::Router { + build_app(AppState::new(AppConfig { + service_name: "mnote-web".into(), + service_version: "0.1.0".into(), + bind_addr: "127.0.0.1:0".into(), + public_bind_addr: "127.0.0.1:3000".into(), + legacy_next_base_url: Some("http://127.0.0.1:3100".into()), + enable_legacy_next_compat: true, + enable_debug_shell_routes: false, + hermes_base_path: "/api/hermes".into(), + compat_next_base_path: "/api/compat/next".into(), + convex_url: None, + convex_admin_key: None, + allow_dev_fixtures: true, + query_fixtures_json: Some( + r#"{"documents:getMeta":{"id":"doc_1","workspace_id":"ws_demo","title":"页面"},"mindmaps:get":{"data":{"data":{"text":"KMIND","uid":"root"},"children":[]},"revision":1}}"# + .into(), + ), + mutation_fixtures_json: Some( + r#"{"mindmaps:put":{"ok":true,"document_id":"doc_1","mindmap_id":"mind_1","updated_at":"2026-05-12T00:00:00Z"},"bridgeLogs:recordCommandLog":{"ok":true,"id":"clog_fixture"},"bridgeLogs:recordDomainEvent":{"ok":true,"id":"evt_fixture"}}"# + .into(), + ), + dev_user_id: "dev-user".into(), + dev_user_name: "开发用户".into(), + dev_user_email: "dev@mnote.local".into(), + })) + } + + #[tokio::test] + async fn mindmap_put_derives_workspace_and_returns_tree_artifacts() { + let response = app() + .oneshot( + Request::builder() + .method("POST") + .uri("/api/mindmap/doc_1/mind_1") + .header("content-type", "application/json") + .body(Body::from( + json!({ + "data": { + "data": {"text": "KMIND", "uid": "root"}, + "children": [] + }, + "createOnly": true + }) + .to_string(), + )) + .expect("request"), + ) + .await + .expect("response"); + + assert_eq!(response.status(), StatusCode::OK); + let body = to_bytes(response.into_body(), usize::MAX) + .await + .expect("body"); + let payload: Value = serde_json::from_slice(&body).expect("json"); + + assert_eq!(payload["artifacts"]["commandLog"]["workspaceId"], "ws_demo"); + assert_eq!(payload["artifacts"]["commandLog"]["targetPageId"], "doc_1"); + assert_eq!( + payload["artifacts"]["commandLog"]["targetBlockId"], + "mind_1" + ); + assert_eq!( + payload["artifacts"]["domainEvent"]["eventType"], + "tree.resource.mindmap.put" + ); + assert_eq!( + payload["artifacts"]["domainEvent"]["payload"]["streamDelta"], + json!({ + "op": "resync_required", + "reason": "mindmap.put", + "documentId": "doc_1", + "blockId": "mind_1" + }) + ); + } +} diff --git a/rust/crates/mnote-web/src/routes/mindmap_shell.rs b/rust/crates/mnote-web/src/routes/mindmap_shell.rs index 916a69c0..4e6d1d8e 100644 --- a/rust/crates/mnote-web/src/routes/mindmap_shell.rs +++ b/rust/crates/mnote-web/src/routes/mindmap_shell.rs @@ -1,7 +1,13 @@ +use crate::app::AppState; use crate::context::RequestContext; use crate::error::WebError; +use crate::routes::web_shell::{ + build_page_aggregate_snapshot, load_file_tree_html, load_sidebar_tree_html, + load_workspace_shell_projection, +}; use crate::ssr::pages::mindmap::MindmapPage; -use axum::extract::{Extension, Path}; +use crate::workspace_shell::render_workspace_shell_sidebar_html; +use axum::extract::{Extension, Path, State}; use axum::http::{HeaderMap, HeaderName, HeaderValue}; use axum::response::{Html, IntoResponse, Response}; use serde_json::json; @@ -10,9 +16,92 @@ const HEADER_MNOTE_WEB_OWNER: &str = "x-mnote-web-owner"; const HEADER_MNOTE_WEB_SHELL: &str = "x-mnote-web-shell"; pub async fn mindmap_object_shell( + State(state): State, Extension(context): Extension, Path((doc_id, mindmap_id)): Path<(String, String)>, ) -> Result { + let default_workspace_name = format!("{} 的空间", state.config().dev_user_name); + let aggregate = build_page_aggregate_snapshot(&state, &context, &doc_id, None, None, None) + .await + .ok(); + let workspace_id = aggregate + .as_ref() + .map(|value| value.identity.workspace_id.clone()) + .filter(|value| !value.trim().is_empty()); + let title = aggregate + .as_ref() + .map(|value| value.head.title.trim().to_string()) + .filter(|value| !value.is_empty()) + .unwrap_or_else(|| "思维导图".to_string()); + let (workspace_name, sidebar_tree_html, workspace_sidebar_html) = + if let Some(workspace_id) = workspace_id.as_deref() { + let workspace_projection = load_workspace_shell_projection( + state.config(), + &context, + workspace_id, + Some(&doc_id), + &default_workspace_name, + ) + .await; + let sidebar_tree_html = + load_sidebar_tree_html(state.config(), &context, workspace_id, Some(&doc_id)) + .await + .unwrap_or_default(); + let file_tree_html = + load_file_tree_html(state.config(), &context, workspace_id, Some(&doc_id)) + .await + .unwrap_or_default(); + let workspace_name = workspace_projection.workspace_name.clone(); + let workspace_sidebar_html = render_workspace_shell_sidebar_html( + &workspace_projection, + Some(sidebar_tree_html.as_str()), + Some(file_tree_html.as_str()), + ); + ( + Some(workspace_name), + Some(sidebar_tree_html), + Some(workspace_sidebar_html), + ) + } else { + (None, None, None) + }; + let editor_bootstrap = json!({ + "documentId": format!("__mindmap_object__:{doc_id}:{mindmap_id}"), + "workspaceId": workspace_id + .as_ref() + .map(|value| format!("__mindmap_object__:{value}")), + "title": title.clone(), + "content": { + "type": "doc", + "content": [ + { + "type": "paragraph", + "attrs": { + "mindmapId": mindmap_id, + "mnoteBlockType": "mindmap", + "projectionVersion": 1, + "rootNodeId": "root", + "mnoteMindmapData": serde_json::Value::Null + } + } + ] + }, + "readOnly": false, + "editable": true, + "standaloneObject": { + "kind": "mindmap", + "documentId": doc_id, + "mindmapId": mindmap_id + }, + "revision": serde_json::Value::Null, + "conflictDetectionKey": serde_json::Value::Null, + "pageOptions": { + "pageWidth": "full", + "smallText": false, + "showHeadingNumbers": false, + "fontFamily": "sans" + } + }); let contract = json!({ "schema": "mnote.mindmap_shell.v1", "owner": "mnote-web", @@ -35,11 +124,17 @@ pub async fn mindmap_object_shell( "requestId": context.trace.request_id, "traceId": context.trace.trace_id }); + let editor_bootstrap_json = + serde_json::to_string(&editor_bootstrap).unwrap_or_else(|_| "null".to_string()); let contract_json = serde_json::to_string(&contract).unwrap_or_else(|_| "null".to_string()); let body_content = crate::ssr::render_view(leptos::view! { }); let html = format!( @@ -47,19 +142,24 @@ pub async fn mindmap_object_shell( - 思维导图 + {} {} + + {} "#, + escape_html(&title), crate::ssr::MNOTE_CSS, escape_html(&doc_id), escape_html(&mindmap_id), body_content, + escape_script_json(&editor_bootstrap_json), escape_script_json(&contract_json), + render_mindmap_standalone_bootstrap_script(), ); let mut response = Html(html).into_response(); stamp_shell_headers(response.headers_mut(), "mindmap"); @@ -87,6 +187,80 @@ fn escape_script_json(value: &str) -> String { value.replace(" &'static str { + r#""# +} + #[cfg(test)] mod tests { use crate::app::{build_app, AppConfig, AppState}; @@ -189,9 +363,21 @@ mod tests { .expect("body"); let html = String::from_utf8(body.to_vec()).expect("utf8"); assert!(html.contains("mnote.mindmap_shell.v1")); + assert!(html.contains("data-mnote-object-editor=\"mindmap\"")); + assert!(html.contains( + "data-mnote-object-identity=\"resource:mindmap:doc_1:mind_1\"" + )); assert!(html.contains("data-leptos-mindmap-island=\"standalone\"")); assert!(html.contains("mindmap.simple_mind_map_scene.get")); assert!(html.contains("mindmap.command.apply")); + assert!(html.contains("__MNOTE_MINDMAP_EDITOR_BOOTSTRAP__")); + assert!(html.contains("mnoteBlockType")); + assert!(html.contains("__mindmap_object__:doc_1:mind_1")); + assert!(html.contains("\"standaloneObject\"")); + assert!(html.contains("\"documentId\":\"doc_1\"")); + assert!(html.contains("\"mindmapId\":\"mind_1\"")); + assert!(html.contains("runtimeModule.mount(mountTarget, bootstrap)")); + assert!(html.contains("/api/leptos-tiptap-runtime/manifest.json")); assert!(!html.contains("react_mindmap_runtime")); assert!(!html.contains("next-app-router")); } diff --git a/rust/crates/mnote-web/src/routes/sse.rs b/rust/crates/mnote-web/src/routes/sse.rs index 109edf34..4c75079a 100644 --- a/rust/crates/mnote-web/src/routes/sse.rs +++ b/rust/crates/mnote-web/src/routes/sse.rs @@ -57,8 +57,9 @@ pub async fn events( state.polls += 1; sleep(Duration::from_millis(poll_ms)).await; + let poll_query = live_poll_query(&state.query); let Ok((workspace_id, overview)) = - load_stream_overview(state.app_state.config(), &state.context, &state.query) + load_stream_overview(state.app_state.config(), &state.context, &poll_query) .await else { return None; @@ -76,7 +77,7 @@ pub async fn events( let Ok(payload) = build_stream_delta_payload( state.app_state.config(), &state.context, - &state.query, + &poll_query, &workspace_id, &overview, change.cursor, @@ -91,18 +92,15 @@ pub async fn events( return Some((Ok(stream_event("delta", &payload)), Some(state))); } StreamChangeKind::Resync => { - let mut next_query = state.query.clone(); - next_query.cursor = change.cursor; let Ok(snapshot_payload) = load_stream_snapshot( state.app_state.config(), &state.context, - &next_query, + &poll_query, ) .await else { return None; }; - state.query = next_query; state.current_cursor = read_stream_cursor_from_payload(&snapshot_payload); return Some(( Ok(stream_event( @@ -157,6 +155,14 @@ struct StreamPollState { initial_emitted: bool, } +fn live_poll_query(query: &StreamSnapshotQuery) -> StreamSnapshotQuery { + let mut next = query.clone(); + // Convex bridgeLogs 的 cursor 是“向更旧记录翻页”,不是 live tail 的起点; + // 实时轮询必须始终查最新窗口,再用 current_cursor 在 Rust 侧比较增量。 + next.cursor = None; + next +} + fn stream_event(event_name: &str, payload: &Value) -> Event { let event_id = payload .get("revision") @@ -183,6 +189,7 @@ fn stream_event(event_name: &str, payload: &Value) -> Event { #[cfg(test)] mod tests { use crate::app::{build_app, AppConfig, AppState}; + use crate::routes::stream_support::StreamSnapshotQuery; use axum::body::{to_bytes, Body}; use axum::http::{Request, StatusCode}; use tower::util::ServiceExt; @@ -289,4 +296,20 @@ mod tests { assert!(text.contains("id: ")); assert!(text.contains("\"revision\"")); } + + #[test] + fn live_poll_query_drops_bridge_pagination_cursor() { + let query = StreamSnapshotQuery { + workspace_id: Some("ws_demo".into()), + cursor: Some(r#"{"createdAt":"2026-05-12T00:00:00Z","id":"clog_1"}"#.into()), + poll_ms: Some(250), + ..StreamSnapshotQuery::default() + }; + + let live_query = super::live_poll_query(&query); + + assert_eq!(live_query.workspace_id, Some("ws_demo".into())); + assert_eq!(live_query.poll_ms, Some(250)); + assert_eq!(live_query.cursor, None); + } } diff --git a/rust/crates/mnote-web/src/routes/tree.rs b/rust/crates/mnote-web/src/routes/tree.rs index f84d52f8..41edd969 100644 --- a/rust/crates/mnote-web/src/routes/tree.rs +++ b/rust/crates/mnote-web/src/routes/tree.rs @@ -540,6 +540,9 @@ pub(crate) fn collect_filetree_render_rows( .map(str::trim) .filter(|value| !value.is_empty()) .map(ToOwned::to_owned), + object_identity: resource_meta + .and_then(|meta| meta.get("objectIdentity")) + .and_then(|value| serde_json::to_string(value).ok()), selected, }) }) @@ -1686,13 +1689,25 @@ fn build_tree_shell_html( documentId: "", assetId: "", assetKind: "", + objectIdentity: null, + blockAssetRelation: null, }; } + const objectIdentity = + value?.objectIdentity && typeof value.objectIdentity === "object" + ? value.objectIdentity + : null; + const blockAssetRelation = + value?.blockAssetRelation && typeof value.blockAssetRelation === "object" + ? value.blockAssetRelation + : null; return { resourceKind: normalizeText(value?.resourceKind), documentId: normalizeText(value?.documentId), assetId: normalizeText(value?.assetId), assetKind: normalizeText(value?.assetKind), + objectIdentity, + blockAssetRelation, }; }; @@ -4690,12 +4705,14 @@ fn build_tree_shell_html( postToHost("tree.asset.open", { documentId: documentId || null, assetId: assetId || null, + objectIdentity: item.resourceMeta?.objectIdentity || null, target: { documentId: documentId || null }, payload: { documentId: documentId || null, assetId: assetId || null, rowId: item.rowId, rowKind: item.rowKind, + objectIdentity: item.resourceMeta?.objectIdentity || null, }, }); }; @@ -4857,6 +4874,10 @@ fn build_tree_shell_html( row.dataset.rowKind = item.rowKind; row.dataset.documentId = documentId || ""; row.dataset.assetId = assetId || ""; + row.dataset.objectIdentity = item.resourceMeta?.objectIdentity + ? JSON.stringify(item.resourceMeta.objectIdentity) + : ""; + row.dataset.objectKind = item.resourceMeta?.objectIdentity?.objectKind || ""; row.dataset.shellMode = "filetree"; row.dataset.selected = String(selectedFileTreeRowIds.has(item.rowId)); row.dataset.dropTarget = String(activeFileTreeDropRowId === item.rowId); @@ -5308,12 +5329,14 @@ fn build_tree_shell_html( postToHost("tree.asset.open", { documentId: documentId || null, assetId: assetId || null, + objectIdentity: item.resourceMeta?.objectIdentity || null, target: { documentId: documentId || null }, payload: { documentId: documentId || null, assetId: assetId || null, rowId: item.rowId, rowKind: item.rowKind, + objectIdentity: item.resourceMeta?.objectIdentity || null, }, }); }; @@ -5382,6 +5405,10 @@ fn build_tree_shell_html( row.dataset.rowKind = item.rowKind; row.dataset.documentId = documentId || ""; row.dataset.assetId = assetId || ""; + row.dataset.objectIdentity = item.resourceMeta?.objectIdentity + ? JSON.stringify(item.resourceMeta.objectIdentity) + : ""; + row.dataset.objectKind = item.resourceMeta?.objectIdentity?.objectKind || ""; row.dataset.shellMode = "filetree"; row.dataset.selected = String(selectedFileTreeRowIds.has(item.rowId)); row.dataset.dropTarget = String(activeFileTreeDropRowId === item.rowId); diff --git a/rust/crates/mnote-web/src/routes/web_shell.rs b/rust/crates/mnote-web/src/routes/web_shell.rs index 8bb0c56f..897b54b1 100644 --- a/rust/crates/mnote-web/src/routes/web_shell.rs +++ b/rust/crates/mnote-web/src/routes/web_shell.rs @@ -288,7 +288,7 @@ pub(crate) fn build_editor_bootstrap_json_with_ids( .unwrap_or_else(|_| "{}".to_string()) } -fn build_document_panes_bootstrap_json( +pub(crate) fn build_document_panes_bootstrap_json( aggregate: &PageAggregate, context: &RequestContext, source_kind: Option<&str>, @@ -815,6 +815,28 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { return { type: 'codeBlock', attrs: withTextAlign({ blockId, language: block?.props?.language || null }), content }; } if (type === 'divider' || type === 'horizontalRule' || type === 'horizontal_rule') return { type: 'horizontalRule', attrs: { blockId } }; + if (type === 'mindmap') { + const data = block?.props?.data && typeof block.props.data === 'object' ? block.props.data : null; + const mindmapId = firstNonEmptyText( + block?.props?.mindmapId, + block?.props?.mindmap_id, + block?.mindmapId, + block?.mindmap_id, + data?.mindmapId, + data?.mindmap_id, + data?.id + ); + const rootNodeId = firstNonEmptyText(block?.props?.rootNodeId, block?.props?.root_node_id, data?.rootNodeId, data?.root_node_id) || 'root'; + return { + type: 'paragraph', + attrs: withTextAlign({ + blockId, + mnoteBlockType: 'mindmap', + mindmapId, + rootNodeId, + }), + }; + } if (type === 'media') { const sourcePath = firstNonEmptyText(block?.props?.sourcePath, block?.props?.url, block?.props?.src); const name = firstNonEmptyText(block?.props?.name, block?.props?.fileName, block?.props?.title, sourcePath); @@ -882,6 +904,41 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { content.type === 'doc' ); + const mindmapDomDescriptors = (root) => { + if (!(root instanceof HTMLElement)) return []; + return Array.from(root.querySelectorAll('[data-testid="mnote-mindmap-editor-root"]')) + .flatMap((node) => { + if (!(node instanceof HTMLElement)) return []; + const mindmapId = typeof node.dataset.mnoteMindmapId === 'string' ? node.dataset.mnoteMindmapId.trim() : ''; + if (!mindmapId) return []; + const rootNodeId = typeof node.dataset.mnoteRootNodeId === 'string' && node.dataset.mnoteRootNodeId.trim() + ? node.dataset.mnoteRootNodeId.trim() + : 'root'; + return [{ mindmapId, rootNodeId }]; + }); + }; + + const hydrateMindmapAttrsFromDom = (tiptapDocument, root) => { + if (!isTiptapDocument(tiptapDocument) || !Array.isArray(tiptapDocument.content)) return tiptapDocument; + const descriptors = mindmapDomDescriptors(root); + if (!descriptors.length) return tiptapDocument; + let index = 0; + for (const node of tiptapDocument.content) { + if (node?.type !== 'paragraph' || node?.attrs?.mnoteBlockType !== 'mindmap') continue; + const descriptor = descriptors[index]; + index += 1; + if (!descriptor) continue; + node.attrs = node.attrs && typeof node.attrs === 'object' ? node.attrs : {}; + if (typeof node.attrs.mindmapId !== 'string' || !node.attrs.mindmapId.trim()) { + node.attrs.mindmapId = descriptor.mindmapId; + } + if (typeof node.attrs.rootNodeId !== 'string' || !node.attrs.rootNodeId.trim()) { + node.attrs.rootNodeId = descriptor.rootNodeId; + } + } + return tiptapDocument; + }; + const toTiptapDocument = (content, fallbackText = '') => { if (isTiptapDocument(content)) return content; const blocks = Array.isArray(content) ? content : Array.isArray(content?.blocks) ? content.blocks : []; @@ -923,9 +980,36 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { const raw = typeof node?.attrs?.blockId === 'string' ? node.attrs.blockId.trim() : ''; return raw || `block-${index + 1}`; }; + const mindmapPropsFromAttrs = (attrs, fallbackMindmapId) => { + const data = attrs?.data && typeof attrs.data === 'object' ? attrs.data : {}; + const mindmapId = firstNonEmptyText( + attrs?.mindmapId, + attrs?.mindmap_id, + data?.mindmapId, + data?.mindmap_id, + data?.id, + fallbackMindmapId + ); + const rootNodeId = firstNonEmptyText(attrs?.rootNodeId, attrs?.root_node_id, data?.rootNodeId, data?.root_node_id) || 'root'; + const projectionVersion = Number(attrs?.projectionVersion ?? attrs?.projection_version); + return { + mindmapId, + rootNodeId, + ...(Number.isFinite(projectionVersion) ? { projectionVersion } : {}), + }; + }; const tiptapNodeToEditorBlock = (node, index) => { const blockId = blockIdOf(node, index); + if (node?.type === 'paragraph' && node?.attrs?.mnoteBlockType === 'mindmap') { + return { + blockId, + blockType: 'mindmap', + props: mindmapPropsFromAttrs(node?.attrs, blockId), + contentNodes: [], + childBlockIds: [], + }; + } if (node?.type === 'paragraph') return { blockId, blockType: 'paragraph', props: {}, contentNodes: inlineTextNodes(node), childBlockIds: [] }; if (node?.type === 'heading') { const level = Math.max(1, Math.min(6, Number(node?.attrs?.level || 1) || 1)); @@ -967,6 +1051,8 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { ? { checked: Boolean(block.props?.checked) } : block.blockType === 'code_block' ? { language: block.props?.language || null } + : block.blockType === 'mindmap' + ? mindmapPropsFromAttrs(block.props || {}, block.blockId) : block.blockType === 'image' ? { ...(block.props || {}) } : block.blockType === 'toc' @@ -974,7 +1060,9 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { : block.blockType === 'table' ? { ...(block.props || {}) } : undefined, - content: Array.isArray(block.contentNodes) + content: block.blockType === 'mindmap' + ? '' + : Array.isArray(block.contentNodes) ? block.contentNodes.map((node) => { if (!node || typeof node !== 'object') return null; const text = typeof node.text === 'string' ? node.text : ''; @@ -1060,6 +1148,7 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { const paneViewRegistry = new Map(); let nextViewId = 1; const externalConflictMessage = '本地 Markdown 文件已在外部更新,请刷新或保存前先处理冲突'; + const treeExternalConflictMessage = '当前页面已在其它窗口更新,请刷新或保存前先处理冲突'; const SESSION_RELEASE_DELAY_MS = 1200; const parseLocalFolderEventPayload = (event) => { @@ -1316,6 +1405,11 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { const persistSession = async (session) => { if (session.readOnly || session.saving || session.hasExternalConflict) return; + const hydrateView = sessionViews(session).find((item) => item.mountId != null) || sessionViews(session)[0]; + if (hydrateView) { + hydrateMindmapAttrsFromDom(session.currentTiptapDocument, hydrateView.runtimeDescriptor.root); + session.currentSerialized = JSON.stringify(session.currentTiptapDocument); + } const serialized = session.currentSerialized; if (!session.dirty && serialized === session.lastPersistedSerialized) { setSessionStatus(session, 'saved'); @@ -1389,16 +1483,20 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { } }; - const scheduleSessionExternalRefresh = (session) => { + const scheduleSessionExternalRefresh = (session, source) => { if (session.externalRefreshTimer) return; + session.externalRefreshSource = source || session.externalRefreshSource || 'mnote-web-external-change'; session.externalRefreshTimer = window.setTimeout(() => { + const refreshSource = session.externalRefreshSource || 'mnote-web-external-change'; + session.externalRefreshSource = ''; session.externalRefreshTimer = 0; - void refreshSessionFromExternalFileChange(session); + void refreshSessionFromExternalChange(session, refreshSource); }, 120); }; - const refreshSessionFromExternalFileChange = async (session) => { - if (session.sourceKind !== 'local_folder' || !session.rootUri || document.hidden) return; + const refreshSessionFromExternalChange = async (session, source) => { + if (document.hidden) return; + if (session.sourceKind === 'local_folder' && !session.rootUri) return; try { const response = await fetch(pageAggregateUrl({ documentId: session.documentId, @@ -1439,14 +1537,19 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { session.hasExternalConflict = false; session.lastUserInputAt = 0; sessionViews(session).forEach((view) => { - if (view.mountId != null) dispatchSessionContentToView(session, view, 'mnote-web-local-folder-watch'); + if (view.mountId != null) dispatchSessionContentToView(session, view, source || 'mnote-web-external-change'); }); setSessionStatus(session, 'synced-external-change'); } catch (error) { - console.warn('mnote local folder 外部更新检测失败', error); + console.warn('mnote 页面外部更新检测失败', error); } }; + const refreshSessionFromExternalFileChange = async (session) => { + if (session.sourceKind !== 'local_folder') return; + await refreshSessionFromExternalChange(session, 'mnote-web-local-folder-watch'); + }; + const ensureLocalFolderEventChannel = (session) => { if (session.sourceKind !== 'local_folder' || !session.rootUri || typeof window.EventSource !== 'function') { return; @@ -1473,7 +1576,7 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { markSessionExternalConflict(targetSession, externalConflictMessage); return; } - scheduleSessionExternalRefresh(targetSession); + scheduleSessionExternalRefresh(targetSession, 'mnote-web-local-folder-watch'); }); }); eventSource.onerror = () => { @@ -1485,6 +1588,164 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { session.localFolderChannel = channel; }; + const readTreePayloadData = (payload) => ( + payload && typeof payload === 'object' + ? (payload.data || payload.delta || payload) + : null + ); + + const readTreePayloadOverview = (payload) => ( + payload && typeof payload === 'object' && payload.overview && typeof payload.overview === 'object' + ? payload.overview + : null + ); + + const readTreePayloadCursor = (payload) => { + const raw = String(payload?.cursor || payload?.revision || '').trim(); + if (!raw) return { id: '', createdAt: '', raw: '' }; + try { + const parsed = JSON.parse(raw); + if (parsed && typeof parsed === 'object') { + return { + id: String(parsed.id || parsed.commandId || parsed.command_id || '').trim(), + createdAt: String(parsed.createdAt || parsed.created_at || '').trim(), + raw, + }; + } + } catch (_) {} + return { id: raw, createdAt: '', raw }; + }; + + const treeRecordMatchesPayloadCursor = (record, payload) => { + if (!record || typeof record !== 'object') return false; + const cursor = readTreePayloadCursor(payload); + if (!cursor.id && !cursor.createdAt && !cursor.raw) return false; + const ids = [ + record.id, + record._id, + record.command_log_id, + record.commandLogId, + record.domain_event_id, + record.domainEventId, + record.command_id, + record.commandId, + ].map((value) => String(value || '').trim()).filter(Boolean); + if (cursor.id && ids.includes(cursor.id)) return true; + const createdAt = String(record.created_at || record.createdAt || '').trim(); + return Boolean(cursor.createdAt && createdAt && cursor.createdAt === createdAt); + }; + + const treeRecordTargetsDocument = (record, documentId) => { + if (!record || typeof record !== 'object' || !documentId) return false; + const targetPageId = String(record.target_page_id || record.targetPageId || '').trim(); + const aggregateId = String(record.aggregate_id || record.aggregateId || '').trim(); + if (targetPageId === documentId || aggregateId === documentId) return true; + const payload = record.payload && typeof record.payload === 'object' ? record.payload : null; + if (!payload) return false; + const streamDelta = payload.streamDelta || payload.stream_delta || null; + const deltaDocumentId = streamDelta && typeof streamDelta === 'object' + ? String(streamDelta.documentId || streamDelta.pageId || streamDelta.document_id || streamDelta.page_id || '').trim() + : ''; + return deltaDocumentId === documentId; + }; + + const collectMindmapIdsFromTreeRecord = (record, documentId, out) => { + if (!record || typeof record !== 'object' || !documentId) return; + if (!treeRecordTargetsDocument(record, documentId)) return; + const targetBlockId = String(record.target_block_id || record.targetBlockId || '').trim(); + if (targetBlockId) out.add(targetBlockId); + const aggregateType = String(record.aggregate_type || record.aggregateType || '').trim(); + const aggregateId = String(record.aggregate_id || record.aggregateId || '').trim(); + if (aggregateType === 'block' && aggregateId) out.add(aggregateId); + const payload = record.payload && typeof record.payload === 'object' ? record.payload : null; + const streamDelta = payload && typeof payload === 'object' ? (payload.streamDelta || payload.stream_delta || null) : null; + const blockId = streamDelta && typeof streamDelta === 'object' + ? String(streamDelta.blockId || streamDelta.block_id || '').trim() + : ''; + if (blockId) out.add(blockId); + }; + + const collectMindmapIdsFromTreePayload = (payload, session) => { + const ids = new Set(); + if (!payload || typeof payload !== 'object' || !session?.documentId) return []; + const kind = String(payload.kind || '').trim(); + const data = readTreePayloadData(payload); + if (kind === 'delta' && data && typeof data === 'object') { + const documentId = String(data.documentId || data.pageId || data.document_id || data.page_id || '').trim(); + if (!documentId || documentId === session.documentId) { + const blockId = String(data.blockId || data.block_id || '').trim(); + if (blockId) ids.add(blockId); + const streamDelta = data.streamDelta || data.stream_delta || null; + const streamBlockId = streamDelta && typeof streamDelta === 'object' + ? String(streamDelta.blockId || streamDelta.block_id || '').trim() + : ''; + if (streamBlockId) ids.add(streamBlockId); + } + } + if (kind === 'resync') { + const overview = readTreePayloadOverview(payload); + if (overview) { + const commandLogs = Array.isArray(overview.command_logs) ? overview.command_logs : Array.isArray(overview.commandLogs) ? overview.commandLogs : []; + const domainEvents = Array.isArray(overview.domain_events) ? overview.domain_events : Array.isArray(overview.domainEvents) ? overview.domainEvents : []; + commandLogs + .filter((record) => treeRecordMatchesPayloadCursor(record, payload)) + .forEach((record) => collectMindmapIdsFromTreeRecord(record, session.documentId, ids)); + domainEvents + .filter((record) => treeRecordMatchesPayloadCursor(record, payload)) + .forEach((record) => collectMindmapIdsFromTreeRecord(record, session.documentId, ids)); + } + } + return Array.from(ids); + }; + + const refreshMindmapRuntimesFromTreePayload = (payload, session) => { + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + collectMindmapIdsFromTreePayload(payload, session).forEach((mindmapId) => { + const bridge = registry[mindmapId]; + if (bridge && typeof bridge.refreshProjection === 'function') { + void bridge.refreshProjection('mnote-web-tree-live'); + } + }); + }; + + const treePayloadTargetsDocument = (payload, session) => { + if (!payload || typeof payload !== 'object' || !session?.documentId) return false; + if (payload.workspaceId && session.workspaceId && String(payload.workspaceId) !== String(session.workspaceId)) return false; + const data = readTreePayloadData(payload); + if (data && typeof data === 'object') { + const documentId = String(data.documentId || data.pageId || data.document_id || data.page_id || '').trim(); + if (documentId === session.documentId) return true; + const documents = Array.isArray(data.upsertDocuments) ? data.upsertDocuments : Array.isArray(data.upsert_documents) ? data.upsert_documents : []; + if (documents.some((item) => String(item?.id || item?.documentId || '').trim() === session.documentId)) return true; + } + const overview = readTreePayloadOverview(payload); + if (!overview) return false; + const commandLogs = Array.isArray(overview.command_logs) ? overview.command_logs : Array.isArray(overview.commandLogs) ? overview.commandLogs : []; + const domainEvents = Array.isArray(overview.domain_events) ? overview.domain_events : Array.isArray(overview.domainEvents) ? overview.domainEvents : []; + return commandLogs.some((record) => treeRecordTargetsDocument(record, session.documentId)) + || domainEvents.some((record) => treeRecordTargetsDocument(record, session.documentId)); + }; + + const handleTreeExternalChange = (event) => { + const payload = event?.detail?.payload || event?.detail || null; + if (!payload) return; + Array.from(documentSessionRegistry.values()).forEach((session) => { + if (session.sourceKind === 'local_folder') return; + if (!treePayloadTargetsDocument(payload, session)) return; + refreshMindmapRuntimesFromTreePayload(payload, session); + session.lastExternalChangeSignalAt = Date.now(); + session.externalChangePending = true; + if (session.hasExternalConflict || sessionHasRecentLocalInput(session) || session.dirty || session.saveTimer || session.saving) { + markSessionExternalConflict(session, treeExternalConflictMessage); + return; + } + scheduleSessionExternalRefresh(session, 'mnote-web-tree-live'); + }); + }; + + window.addEventListener('tree:delta', handleTreeExternalChange); + window.addEventListener('tree:resync', handleTreeExternalChange); + const createDocumentSession = (runtimeDescriptor) => { const pageBody = runtimeDescriptor.aggregate.body || {}; const permissions = runtimeDescriptor.aggregate.head?.permissions || {}; @@ -1513,6 +1774,7 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { saving: false, hasExternalConflict: false, externalChangePending: false, + externalRefreshSource: '', lastExternalChangeSignalAt: 0, lastUserInputAt: 0, status: 'booting', @@ -1714,10 +1976,10 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str { const pendingExternalChange = session.sourceKind === 'local_folder' && session.externalChangePending; const recentExternalChange = sessionHasRecentExternalSignal(session); const recentLocalInput = sessionHasRecentLocalInput(session); - const tiptapDocument = toTiptapDocument( + const tiptapDocument = hydrateMindmapAttrsFromDom(toTiptapDocument( payload?.tiptapDocument || payload?.editorDocument || payload?.content, currentEditorText(view), - ); + ), view.runtimeDescriptor.root); const serialized = JSON.stringify(tiptapDocument); if (view.suppressedSerialized && view.suppressedSerialized === serialized) { view.suppressedSerialized = null; @@ -2614,6 +2876,13 @@ mod tests { assert!(html.contains("btn.getAttribute('data-page-openable') === 'false'")); assert!(html.contains("data-mnote-action=\"open-local-folder\"")); assert!(html.contains("refreshSessionFromExternalFileChange")); + assert!(html.contains("refreshSessionFromExternalChange")); + assert!(html.contains("treeExternalConflictMessage")); + assert!(html.contains("tree:delta")); + assert!(html.contains("tree:resync")); + assert!(html.contains("mnote-web-tree-live")); + assert!(html.contains("refreshMindmapRuntimesFromTreePayload")); + assert!(html.contains("__MNOTE_LEPTOS_MINDMAP_BRIDGES__")); assert!(html.contains("/api/local-folder/events")); assert!(html.contains("new EventSource(url.toString())")); assert!(html.contains("localFolderEventRegistry")); @@ -2714,6 +2983,14 @@ mod tests { assert!(html.contains("marks.push({ type: 'link', attrs: { href } })")); assert!(html.contains("styles.link = href")); assert!(html.contains("contentNodes.map((node) => {")); + assert!(html.contains("node?.attrs?.mnoteBlockType === 'mindmap'")); + assert!(html.contains("blockType: 'mindmap'")); + assert!(html.contains("props: mindmapPropsFromAttrs(node?.attrs, blockId)")); + assert!(html.contains("mindmapPropsFromAttrs(block.props || {}, block.blockId)")); + assert!(html.contains("mnoteBlockType: 'mindmap'")); + assert!(html.contains("block.blockType === 'mindmap'")); + assert!(html.contains("content: block.blockType === 'mindmap'")); + assert!(html.contains("? ''")); assert!(!html.contains( "block.contentNodes.map((node) => typeof node?.text === 'string' ? node.text : '').join('')" )); diff --git a/rust/crates/mnote-web/src/ssr/pages/layout.rs b/rust/crates/mnote-web/src/ssr/pages/layout.rs index c115cff0..a7ad2df9 100644 --- a/rust/crates/mnote-web/src/ssr/pages/layout.rs +++ b/rust/crates/mnote-web/src/ssr/pages/layout.rs @@ -962,6 +962,25 @@ const SIDEBAR_TREE_JS: &str = r##" return ''; } + function fileObjectIdentity(item) { + var meta = item && item.resourceMeta && typeof item.resourceMeta === 'object' ? item.resourceMeta : {}; + if (meta.objectIdentity && typeof meta.objectIdentity === 'object') return meta.objectIdentity; + var rowKind = String(item && item.rowKind || ''); + var documentId = fileDocumentId(item) || null; + var assetId = fileAssetId(item) || null; + var iconKind = iconKindOf(item); + var objectKind = rowKind === 'document' ? 'page' : rowKind === 'index' ? 'index' : iconKind === 'mindmap' ? 'mindmap' : 'attachment'; + return { objectKind: objectKind, documentId: documentId, blockId: null, assetId: assetId }; + } + + function objectIdentityAttr(identity) { + try { + return JSON.stringify(identity || {}); + } catch (_error) { + return ''; + } + } + function iconKindOf(item) { return String(item && (item.iconHint || item.rowKind || 'file') || 'file').trim() || 'file'; } @@ -976,6 +995,7 @@ const SIDEBAR_TREE_JS: &str = r##" var parent = parentIdOf(item); var documentId = fileDocumentId(item); var assetId = fileAssetId(item); + var objectIdentity = fileObjectIdentity(item); var children = grouped.get(nodeId) || []; var expandable = Boolean(item.expandable || item.childCount > 0 || children.length); var expanded = expandable && item.expandedByDefault !== false; @@ -990,7 +1010,7 @@ const SIDEBAR_TREE_JS: &str = r##" var childHtml = expandable ? '
    ' + renderFileRows(nodeId, grouped, activeId) + '
' : ''; - return '
  • ' + toggle + '
    ' + createAction + '
    ' + childHtml + '
  • '; + return '
  • ' + toggle + '
    ' + createAction + '
    ' + childHtml + '
  • '; }).join(''); } @@ -1066,11 +1086,10 @@ const SIDEBAR_TREE_JS: &str = r##" if (['doc', 'docx', 'odt', 'rtf'].indexOf(ext) >= 0) return ext; if (['ppt', 'pptx', 'odp'].indexOf(ext) >= 0) return ext; if (['xls', 'xlsx', 'ods', 'csv'].indexOf(ext) >= 0) return ext; - if (ext === 'pdf') return ext; + if (isNonOfficeAttachmentName(name, ext)) return ''; if (mt.indexOf('wordprocessingml') >= 0) return 'docx'; if (mt.indexOf('presentationml') >= 0) return 'pptx'; if (mt.indexOf('spreadsheetml') >= 0) return 'xlsx'; - if (mt.indexOf('pdf') >= 0) return 'pdf'; return ''; } @@ -1098,6 +1117,32 @@ const SIDEBAR_TREE_JS: &str = r##" return '/onlyoffice?' + params.toString(); } + function buildMindmapOpenPath(documentId, assetId) { + var doc = String(documentId || '').trim(); + var map = String(assetId || '').trim(); + if (!doc || !map) return ''; + return '/mindmap/' + encodeURIComponent(doc) + '/' + encodeURIComponent(map); + } + + function isMindmapAssetDetail(detail) { + var assetId = String(detail && detail.assetId || '').trim(); + var assetType = String(detail && detail.assetType || '').trim(); + if (assetType === 'mindmap') return true; + return assetId.indexOf('mindmap_') === 0 || assetId.indexOf('mindmap-') === 0; + } + + function readFileTreeObjectIdentity(row) { + if (!row) return null; + var raw = row.getAttribute('data-object-identity') || ''; + if (!raw) return null; + try { + var parsed = JSON.parse(raw); + return parsed && typeof parsed === 'object' ? parsed : null; + } catch (_error) { + return null; + } + } + async function fetchCurrentOnlyOfficeUserId() { try { var response = await fetch('/api/auth/whoami', { @@ -1115,6 +1160,16 @@ const SIDEBAR_TREE_JS: &str = r##" async function openConvexAssetFromFileTree(detail) { var assetId = String(detail && detail.assetId || '').trim(); if (!assetId) return; + var documentId = String(detail && detail.documentId || '').trim(); + if (isMindmapAssetDetail(detail) && documentId) { + var mindmapPath = buildMindmapOpenPath(documentId, assetId); + if (mindmapPath) { + document.documentElement.setAttribute('data-mnote-last-mindmap-asset-open-mode', 'mindmap-object-shell'); + document.documentElement.setAttribute('data-mnote-last-mindmap-asset-id', assetId); + window.location.assign(mindmapPath); + } + return; + } try { var response = await fetch('/api/media/sign?assetId=' + encodeURIComponent(assetId), { method: 'GET', @@ -1142,6 +1197,17 @@ const SIDEBAR_TREE_JS: &str = r##" }), '_blank', 'noopener,noreferrer'); return; } + if (isCodeAttachmentFileName(fileName) && String(asset.document_id || detail.documentId || '').trim() === currentDocumentId()) { + await openCodeEditorAttachment({ + href: fileUrl, + fileUrl: fileUrl, + fileName: fileName, + assetId: assetId, + documentId: String(asset.document_id || detail.documentId || '').trim(), + fileSize: uploadedFileSize(asset) + }); + return; + } window.open(fileUrl, '_blank', 'noopener,noreferrer'); } catch (error) { window.alert(error && error.message ? error.message : '打开附件失败'); @@ -1243,6 +1309,67 @@ const SIDEBAR_TREE_JS: &str = r##" return match ? match[1] : ''; } + function isNonOfficeAttachmentName(name, ext) { + var codeFileNames = [ + '.dockerignore', '.editorconfig', '.env', '.eslintrc', '.gitattributes', '.gitignore', '.npmrc', '.prettierrc', + 'dockerfile', 'makefile', 'cmakelists.txt', 'gemfile', 'rakefile', 'procfile' + ]; + return [ + 'pdf', 'toml', 'json', 'yaml', 'yml', 'md', 'markdown', 'txt', 'ini', 'env', 'xml', 'html', 'htm', 'css', 'scss', + 'less', 'js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs', 'py', 'rs', 'go', 'java', 'c', 'cpp', 'h', 'hpp', 'cs', + 'php', 'rb', 'sh', 'bash', 'zsh', 'sql', 'lock', 'log', 'vue', 'svelte', 'astro', 'jsonc', 'json5', + 'mts', 'cts', 'lua', 'dart', 'kt', 'kts', 'swift', 'scala', 'gradle', 'groovy', 'clj', + 'ex', 'exs', 'erl', 'hrl', 'fs', 'fsx', 'r', 'jl', 'm', 'mm', 'pl', 'pm', 'ps1', 'bat', 'cmd', + 'psm1', 'psd1', 'dockerfile', 'containerfile', 'proto', 'graphql', 'gql', 'prisma', 'tf', 'tfvars', + 'hcl', 'nix', 'cmake', 'bazel', 'bzl', 'properties', 'conf', 'cfg', 'config', 'service', 'desktop', + 'gitignore', 'gitattributes', 'editorconfig', 'npmrc', 'prettierrc', 'eslintrc' + ].indexOf(ext) >= 0 || codeFileNames.indexOf(name) >= 0; + } + + function attachmentExtensionFromFileName(fileName) { + var name = String(fileName || '').trim().toLowerCase(); + return name.indexOf('.') >= 0 ? name.split('.').pop() : ''; + } + + function isPdfAttachmentFileName(fileName) { + return attachmentExtensionFromFileName(fileName) === 'pdf'; + } + + function isCodeAttachmentFileName(fileName) { + var name = String(fileName || '').trim().toLowerCase(); + var ext = attachmentExtensionFromFileName(name); + return ext !== 'pdf' && isNonOfficeAttachmentName(name, ext); + } + + function inferCodeAttachmentLanguage(fileName) { + var name = String(fileName || '').trim().toLowerCase(); + var ext = attachmentExtensionFromFileName(name); + var byName = { + 'dockerfile': 'dockerfile', + 'makefile': 'makefile', + 'cmakelists.txt': 'cmake', + '.gitignore': 'gitignore', + '.gitattributes': 'gitattributes', + '.editorconfig': 'ini', + '.env': 'dotenv' + }; + if (byName[name]) return byName[name]; + var byExt = { + bash: 'bash', bat: 'batch', c: 'c', cjs: 'javascript', cmd: 'batch', conf: 'text', cpp: 'cpp', + cs: 'csharp', css: 'css', cts: 'typescript', dart: 'dart', dockerfile: 'dockerfile', env: 'dotenv', + go: 'go', gql: 'graphql', gradle: 'groovy', graphql: 'graphql', h: 'c', hcl: 'hcl', hpp: 'cpp', + htm: 'html', html: 'html', ini: 'ini', java: 'java', js: 'javascript', json: 'json', json5: 'json', + jsonc: 'jsonc', jsx: 'javascript', kt: 'kotlin', kts: 'kotlin', less: 'less', log: 'text', + lua: 'lua', m: 'objective-c', markdown: 'markdown', md: 'markdown', mjs: 'javascript', + mts: 'typescript', nix: 'nix', php: 'php', pl: 'perl', pm: 'perl', prisma: 'prisma', + proto: 'protobuf', ps1: 'powershell', py: 'python', r: 'r', rb: 'ruby', rs: 'rust', + scss: 'scss', sh: 'bash', sql: 'sql', svelte: 'svelte', swift: 'swift', tf: 'terraform', + tfvars: 'terraform', toml: 'toml', ts: 'typescript', tsx: 'typescript', txt: 'text', + vue: 'vue', xml: 'xml', yaml: 'yaml', yml: 'yaml', zsh: 'bash' + }; + return byExt[ext] || 'text'; + } + function attachmentClassForFileName(fileName) { var name = String(fileName || '').trim().toLowerCase(); var ext = name.indexOf('.') >= 0 ? name.split('.').pop() : ''; @@ -1250,6 +1377,9 @@ const SIDEBAR_TREE_JS: &str = r##" if (['ppt', 'pptx', 'odp'].indexOf(ext) >= 0) return 'mnote-uploaded-attachment-row mnote-uploaded-attachment-ppt'; if (['xls', 'xlsx', 'ods', 'csv'].indexOf(ext) >= 0) return 'mnote-uploaded-attachment-row mnote-uploaded-attachment-sheet'; if (ext === 'pdf') return 'mnote-uploaded-attachment-row mnote-uploaded-attachment-pdf'; + if (isNonOfficeAttachmentName(name, ext)) { + return 'mnote-uploaded-attachment-row mnote-uploaded-attachment-code'; + } return 'mnote-uploaded-attachment-row mnote-uploaded-attachment-file'; } @@ -3050,9 +3180,99 @@ const SIDEBAR_TREE_JS: &str = r##" function openEditorAttachmentDetail(detail) { if (!detail || !detail.href) return; + if (isPdfAttachmentFileName(detail.fileName)) { + void openPdfEditorAttachment(detail); + return; + } + if (isCodeAttachmentFileName(detail.fileName)) { + void openCodeEditorAttachment(detail); + return; + } window.open(detail.href, '_blank', 'noopener,noreferrer'); } + async function resolveEditorAttachmentUrl(detail) { + var assetId = String(detail && detail.assetId || '').trim(); + if (assetId) { + var response = await fetch('/api/media/sign?assetId=' + encodeURIComponent(assetId), { + method: 'GET', + credentials: 'include', + cache: 'no-store' + }); + var payload = await response.json().catch(function() { return null; }); + if (!response.ok || !payload) { + throw new Error(payload && payload.error ? payload.error : '生成签名链接失败'); + } + var signedUrl = String(payload && payload.signedUrl || '').trim(); + if (!signedUrl) throw new Error('附件链接不可用'); + return { + url: signedUrl, + asset: payload.asset && typeof payload.asset === 'object' ? payload.asset : {} + }; + } + var url = String(detail && (detail.fileUrl || detail.href) || '').trim(); + if (!url) throw new Error('附件链接不可用'); + return { url: url, asset: {} }; + } + + async function openPdfEditorAttachment(detail) { + try { + var resolved = await resolveEditorAttachmentUrl(detail); + window.open(resolved.url, '_blank', 'noopener,noreferrer'); + } catch (error) { + window.alert(error && error.message ? error.message : '打开 PDF 失败'); + } + } + + async function openCodeEditorAttachment(detail) { + var resolved = null; + try { + resolved = await resolveEditorAttachmentUrl(detail); + var size = Number(resolved.asset && (resolved.asset.file_size || resolved.asset.fileSize) || 0); + if (Number.isFinite(size) && size > 1024 * 1024) { + window.open(resolved.url, '_blank', 'noopener,noreferrer'); + return; + } + var response = await fetch(resolved.url, { + method: 'GET', + credentials: 'include', + cache: 'no-store' + }); + if (!response.ok) throw new Error('读取附件内容失败'); + var text = await response.text(); + if (text.length > 1024 * 1024) { + window.open(resolved.url, '_blank', 'noopener,noreferrer'); + return; + } + var editorRoot = document.querySelector('.editor-surface .ProseMirror'); + var editor = editorRoot && editorRoot.editor; + if (!editor || !editor.chain) { + window.open(resolved.url, '_blank', 'noopener,noreferrer'); + return; + } + var title = String(detail.fileName || resolved.asset.file_name || '附件').trim() || '附件'; + var language = inferCodeAttachmentLanguage(title); + editor.chain().focus().insertContent([ + { + type: 'paragraph', + content: [{ type: 'text', text: title }] + }, + { + type: 'codeBlock', + attrs: { language: language }, + content: text ? [{ type: 'text', text: text.replace(/\r\n?/g, '\n') }] : [] + } + ]).run(); + } catch (error) { + console.warn('[mnote attachment] open code attachment failed', error); + if (resolved && resolved.url) { + window.open(resolved.url, '_blank', 'noopener,noreferrer'); + return; + } + window.alert(error && error.message ? error.message : '打开代码附件失败'); + } + } + async function openEditorAttachmentDownload(detail) { if (!detail) return; if (detail.assetId) { @@ -3330,6 +3550,11 @@ const SIDEBAR_TREE_JS: &str = r##" var rowKind = fileRow.getAttribute('data-row-kind') || ''; var documentId = fileRow.getAttribute('data-document-id') || fileRow.getAttribute('data-doc-id') || ''; var assetId = fileRow.getAttribute('data-asset-id') || ''; + var assetType = ''; + var kindBadge = fileRow.querySelector('.tree-kind-badge'); + if (kindBadge instanceof HTMLElement) { + assetType = kindBadge.getAttribute('data-kind') || ''; + } if (fileAction === 'toggle') { e.preventDefault(); toggleChildren(fileRow, fileBtn); @@ -3356,14 +3581,15 @@ const SIDEBAR_TREE_JS: &str = r##" } e.preventDefault(); selectSidebarFileTreeRow(fileRow, { ctrlKey: e.ctrlKey, metaKey: e.metaKey, shiftKey: e.shiftKey }); - dispatchSidebarEvent('tree.filetree.open', { rowId: rowId, rowKind: rowKind, documentId: documentId || null, assetId: assetId || null }); + var objectIdentity = readFileTreeObjectIdentity(fileRow); + dispatchSidebarEvent('tree.filetree.open', { rowId: rowId, rowKind: rowKind, documentId: documentId || null, assetId: assetId || null, assetType: assetType || null, objectIdentity: objectIdentity, workspaceId: resolveWorkspaceId(fileRow) }); if (e.shiftKey || e.ctrlKey || e.metaKey) { return; } if ((rowKind === 'document' || rowKind === 'index' || rowKind === 'markdown') && documentId) { navigateToDocument(documentId, resolveWorkspaceId(fileRow), { treeView: 'filetree' }); } else if (assetId) { - dispatchSidebarEvent('tree.asset.open', { rowId: rowId, rowKind: rowKind, documentId: documentId || null, assetId: assetId }); + dispatchSidebarEvent('tree.asset.open', { rowId: rowId, rowKind: rowKind, documentId: documentId || null, assetId: assetId, assetType: assetType || null, objectIdentity: objectIdentity, workspaceId: resolveWorkspaceId(fileRow) }); } return; } @@ -3988,6 +4214,17 @@ mod tests { assert!(SIDEBAR_TREE_JS.contains("tree.filetree.open")); assert!(SIDEBAR_TREE_JS.contains("tree.asset.open")); assert!(SIDEBAR_TREE_JS.contains("openConvexAssetFromFileTree")); + assert!(SIDEBAR_TREE_JS.contains("buildMindmapOpenPath")); + assert!(SIDEBAR_TREE_JS.contains("isMindmapAssetDetail")); + assert!(!SIDEBAR_TREE_JS.contains("openMindmapAssetInDocumentShell")); + assert!(SIDEBAR_TREE_JS.contains("data-mnote-last-mindmap-asset-open-mode")); + assert!(SIDEBAR_TREE_JS.contains("mindmap-object-shell")); + assert!(SIDEBAR_TREE_JS.contains("window.location.assign(mindmapPath)")); + assert!(SIDEBAR_TREE_JS.contains("assetType: assetType || null")); + assert!(SIDEBAR_TREE_JS.contains("data-object-identity")); + assert!(SIDEBAR_TREE_JS.contains("readFileTreeObjectIdentity")); + assert!(SIDEBAR_TREE_JS.contains("objectIdentity: objectIdentity")); + assert!(SIDEBAR_TREE_JS.contains("workspaceId: resolveWorkspaceId(fileRow)")); assert!(SIDEBAR_TREE_JS.contains("/api/media/sign?assetId=")); assert!(SIDEBAR_TREE_JS.contains("fetchCurrentOnlyOfficeUserId")); assert!(SIDEBAR_TREE_JS.contains("/api/auth/whoami")); @@ -4031,6 +4268,40 @@ mod tests { assert!(SIDEBAR_TREE_JS.contains("/api/tree/projections/file")); } + #[test] + fn sidebar_tree_runtime_keeps_pdf_and_code_assets_out_of_onlyoffice() { + assert!(SIDEBAR_TREE_JS.contains("function inferOnlyOfficeFileType")); + assert!(SIDEBAR_TREE_JS.contains("isNonOfficeAttachmentName(name, ext)")); + assert!(!SIDEBAR_TREE_JS.contains("if (ext === 'pdf') return ext;")); + assert!(!SIDEBAR_TREE_JS.contains("mt.indexOf('pdf') >= 0")); + assert!(SIDEBAR_TREE_JS.contains("mnote-uploaded-attachment-pdf")); + assert!(SIDEBAR_TREE_JS.contains("mnote-uploaded-attachment-code")); + assert!(SIDEBAR_TREE_JS.contains("'toml'")); + assert!(SIDEBAR_TREE_JS.contains("'json'")); + assert!(SIDEBAR_TREE_JS.contains("'yaml'")); + assert!(SIDEBAR_TREE_JS.contains("'md'")); + assert!(SIDEBAR_TREE_JS.contains("'vue'")); + assert!(SIDEBAR_TREE_JS.contains("'svelte'")); + assert!(SIDEBAR_TREE_JS.contains("'proto'")); + assert!(SIDEBAR_TREE_JS.contains("'dockerfile'")); + assert!(SIDEBAR_TREE_JS.contains("'.gitignore'")); + } + + #[test] + fn sidebar_tree_runtime_opens_pdf_and_code_assets_with_builtin_tools() { + assert!(SIDEBAR_TREE_JS.contains("function openPdfEditorAttachment")); + assert!(SIDEBAR_TREE_JS.contains("function openCodeEditorAttachment")); + assert!(SIDEBAR_TREE_JS.contains("function resolveEditorAttachmentUrl")); + assert!(SIDEBAR_TREE_JS.contains("type: 'codeBlock'")); + assert!(SIDEBAR_TREE_JS.contains("attrs: { language: language }")); + assert!(SIDEBAR_TREE_JS.contains("inferCodeAttachmentLanguage")); + assert!(SIDEBAR_TREE_JS.contains("if (isPdfAttachmentFileName(detail.fileName))")); + assert!(SIDEBAR_TREE_JS.contains("if (isCodeAttachmentFileName(detail.fileName))")); + assert!(SIDEBAR_TREE_JS + .contains("if (isCodeAttachmentFileName(fileName) && String(asset.document_id")); + assert!(SIDEBAR_TREE_JS.contains("await openCodeEditorAttachment({")); + } + #[test] fn tree_live_controller_marks_transport_and_closes_source_on_pagehide() { assert!(TREE_LIVE_CONTROLLER_JS.contains("convex-command-log-sse")); diff --git a/rust/crates/mnote-web/src/ssr/pages/mindmap.rs b/rust/crates/mnote-web/src/ssr/pages/mindmap.rs index 0a36e3a3..0305accb 100644 --- a/rust/crates/mnote-web/src/ssr/pages/mindmap.rs +++ b/rust/crates/mnote-web/src/ssr/pages/mindmap.rs @@ -18,17 +18,37 @@ pub fn MindmapPage( document_id: String, /// 思维导图 ID mindmap_id: String, + /// 页面标题 + title: String, + /// 侧栏页面树 HTML + #[prop(optional)] + sidebar_tree_html: Option, + /// 工作区名称 + #[prop(optional)] + workspace_name: Option, + /// workspace shell 侧栏 sections HTML + #[prop(optional)] + workspace_sidebar_html: Option, ) -> impl IntoView { + let object_identity = format!("resource:mindmap:{document_id}:{mindmap_id}"); view! { - +
    -

    {"思维导图"}

    +

    {title}

    = OnceLock::new(); + +fn convex_http_client(context: &RequestContext) -> Result<&'static reqwest::Client, WebError> { + if let Some(client) = CONVEX_HTTP_CLIENT.get() { + return Ok(client); + } + + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(20)) + .pool_max_idle_per_host(16) + .pool_idle_timeout(Duration::from_secs(30)) + .build() + .map_err(|error| { + WebError::internal(format!("Convex HTTP 客户端创建失败: {error}")) + .with_context(context) + .with_header("x-error-phase", "client_build") + .with_header("x-upstream-service", "convex") + })?; + let _ = CONVEX_HTTP_CLIENT.set(client); + CONVEX_HTTP_CLIENT.get().ok_or_else(|| { + WebError::internal("Convex HTTP 客户端初始化失败") + .with_context(context) + .with_header("x-error-phase", "client_build") + .with_header("x-upstream-service", "convex") + }) +} fn read_env_or_dotenv(key: &str) -> Option { if let Ok(value) = std::env::var(key) { @@ -232,15 +259,7 @@ pub async fn execute_convex_query_plan( "args": plan.args_json, }); - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(20)) - .build() - .map_err(|error| { - WebError::internal(format!("Convex HTTP 客户端创建失败: {error}")) - .with_context(context) - .with_header("x-error-phase", "client_build") - .with_header("x-upstream-service", "convex") - })?; + let client = convex_http_client(context)?; let mut request = client .post(format!("{}/api/query", convex_url(config, context)?)) @@ -357,6 +376,18 @@ pub async fn execute_convex_query_by_name( fn convex_command_args_for_plan(plan: &RuntimeCommandExecutionPlan) -> Value { let mut args = plan.args_json.clone(); + if matches!(plan.command_name.as_str(), "mindmaps.put") + || matches!(plan.function_name.as_str(), "mindmaps:put") + { + if let Value::Object(map) = &mut args { + // Rust plan 保留 tree domain event / stream hint 作为正式契约; + // Convex mindmaps.put legacy validator 仍只接收真实写入字段。 + map.remove("streamDeltaHint"); + map.remove("domainEventHint"); + map.remove("domainEventPlan"); + map.remove("domainEventPlans"); + } + } if matches!( plan.command_name.as_str(), "documents.save" | "page.body.save" @@ -414,15 +445,7 @@ pub async fn execute_convex_command_plan( "args": [convex_command_args_for_plan(plan)], }); - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(20)) - .build() - .map_err(|error| { - WebError::internal(format!("Convex HTTP 客户端创建失败: {error}")) - .with_context(context) - .with_header("x-error-phase", "client_build") - .with_header("x-upstream-service", "convex") - })?; + let client = convex_http_client(context)?; let mut request = client .post(format!("{}/api/mutation", convex_url(config, context)?)) @@ -550,15 +573,7 @@ pub async fn execute_convex_mutation_by_name( "args": [args], }); - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(20)) - .build() - .map_err(|error| { - WebError::internal(format!("Convex HTTP 客户端创建失败: {error}")) - .with_context(context) - .with_header("x-error-phase", "client_build") - .with_header("x-upstream-service", "convex") - })?; + let client = convex_http_client(context)?; let mut request = client .post(format!("{}/api/mutation", convex_url(config, context)?)) @@ -847,6 +862,44 @@ mod tests { ); } + #[test] + fn convex_command_args_strips_mindmap_put_bridge_artifacts_for_legacy_mutation() { + let plan = RuntimeCommandExecutionPlan { + command_name: "mindmaps.put".into(), + command_id: "cmd_mindmap_put_1".into(), + function_name: "mindmaps:put".into(), + workspace_id: Some("ws_1".into()), + request_id: "req_1".into(), + trace_id: "trace_1".into(), + actor_id: "actor_1".into(), + idempotency_key: None, + source: json!({}), + payload_json: "{}".into(), + args_json: json!({ + "docId": "doc_1", + "mindmapId": "mind_1", + "data": {"data": {"text": "KMIND"}, "children": []}, + "createOnly": false, + "streamDeltaHint": {"family": "tree"}, + "domainEventHint": {"eventType": "tree.resource.mindmap.put"}, + "domainEventPlan": {"eventType": "tree.resource.mindmap.put"}, + "domainEventPlans": [{"eventType": "tree.resource.mindmap.put"}], + }), + }; + + let args = convex_command_args_for_plan(&plan); + + assert_eq!( + args, + json!({ + "docId": "doc_1", + "mindmapId": "mind_1", + "data": {"data": {"text": "KMIND"}, "children": []}, + "createOnly": false, + }) + ); + } + #[test] fn convex_command_args_adapts_mindmap_command_apply_for_legacy_mutation() { let plan = RuntimeCommandExecutionPlan { diff --git a/rust/crates/mnote-web/src/tree_shell/filetree_renderer.rs b/rust/crates/mnote-web/src/tree_shell/filetree_renderer.rs index 24f65358..200feed6 100644 --- a/rust/crates/mnote-web/src/tree_shell/filetree_renderer.rs +++ b/rust/crates/mnote-web/src/tree_shell/filetree_renderer.rs @@ -14,6 +14,7 @@ pub struct FileTreeRenderRow { pub icon_kind: String, pub document_id: Option, pub asset_id: Option, + pub object_identity: Option, pub selected: bool, } @@ -83,7 +84,7 @@ fn render_filetree_row( String::new() }; html.push_str(&format!( - r#"
  • {toggle_html}
    {create_action_html}
    "#, + r#"
  • {toggle_html}
    {create_action_html}
    "#, node_id = escape_html(&row.node_id), aria_level = row.depth + 1, expanded_attr = if row.expandable && row.expanded { "true" } else { "false" }, @@ -93,6 +94,7 @@ fn render_filetree_row( parent_attr = parent_attr, document_id = escape_html(row.document_id.as_deref().unwrap_or_default()), asset_id = escape_html(row.asset_id.as_deref().unwrap_or_default()), + object_identity = escape_html(row.object_identity.as_deref().unwrap_or_default()), selected = row.selected, toggle_html = toggle_html, icon_kind = escape_html(&row.icon_kind), @@ -174,6 +176,9 @@ mod tests { icon_kind: "page".into(), document_id: Some("page_root".into()), asset_id: None, + object_identity: Some( + r#"{"objectKind":"page","documentId":"page_root","blockId":null,"assetId":null}"#.into(), + ), selected: true, }, FileTreeRenderRow { @@ -188,6 +193,9 @@ mod tests { icon_kind: "index".into(), document_id: Some("page_root".into()), asset_id: None, + object_identity: Some( + r#"{"objectKind":"index","documentId":"page_root","blockId":null,"assetId":null}"#.into(), + ), selected: false, }, ], @@ -198,6 +206,7 @@ mod tests { assert!(html.contains("data-testid=\"filetree-doc-row\"")); assert!(html.contains("data-testid=\"filetree-index-row\"")); assert!(html.contains("data-doc-id=\"page_root\"")); + assert!(html.contains("data-object-identity=\"{"objectKind":"index"")); assert!(html.contains("tree-children")); assert!(html.contains("首页 <安全>")); assert!(html.contains("data-selected=\"true\"")); diff --git a/rust/crates/mnote-web/src/tree_shell/picker_renderer.rs b/rust/crates/mnote-web/src/tree_shell/picker_renderer.rs index 03c511cb..653aad79 100644 --- a/rust/crates/mnote-web/src/tree_shell/picker_renderer.rs +++ b/rust/crates/mnote-web/src/tree_shell/picker_renderer.rs @@ -133,6 +133,7 @@ mod tests { icon_kind: "page".into(), document_id: Some("page_root".into()), asset_id: None, + object_identity: None, selected: false, }, FileTreeRenderRow { @@ -147,6 +148,7 @@ mod tests { icon_kind: "file".into(), document_id: Some("page_root".into()), asset_id: Some("asset_1".into()), + object_identity: None, selected: false, }, ]); diff --git a/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island.js b/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island.js index 4da19c35..4cce3677 100644 --- a/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island.js +++ b/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island.js @@ -319,6 +319,9 @@ function __wbg_get_imports() { __wbg_assign_d4fed0f8abb71719: function() { return handleError(function (arg0, arg1, arg2) { arg0.assign(getStringFromWasm0(arg1, arg2)); }, arguments); }, + __wbg_blur_583010b6b4026c5d: function() { return handleError(function (arg0) { + arg0.blur(); + }, arguments); }, __wbg_body_c7b35a55457167ba: function(arg0) { const ret = arg0.body; return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); @@ -646,6 +649,16 @@ function __wbg_get_imports() { const ret = result; return ret; }, + __wbg_instanceof_HtmlInputElement_8dc30e795ec4f2a5: function(arg0) { + let result; + try { + result = arg0 instanceof HTMLInputElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, __wbg_instanceof_Map_1b76fd4635be43eb: function(arg0) { let result; try { @@ -1145,6 +1158,9 @@ function __wbg_get_imports() { __wbg_set_scrollTop_e931da7f2ad87c86: function(arg0, arg1) { arg0.scrollTop = arg1; }, + __wbg_set_value_d84be184846d017b: function(arg0, arg1, arg2) { + arg0.value = getStringFromWasm0(arg1, arg2); + }, __wbg_shiftKey_e483c13c966878f6: function(arg0) { const ret = arg0.shiftKey; return ret; @@ -1260,42 +1276,42 @@ function __wbg_get_imports() { } }, arguments); }, __wbindgen_cast_0000000000000001: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1585, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1889, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`. const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hdfdf165eabd6279b); return ret; }, __wbindgen_cast_0000000000000002: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1824, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2135, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h2593b18d2d6f8a75); return ret; }, __wbindgen_cast_0000000000000003: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1915, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2227, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h36e788bd1cd1f0f7); return ret; }, __wbindgen_cast_0000000000000004: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1741, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 2050, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h03deb55668e1377f); return ret; }, __wbindgen_cast_0000000000000005: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 2137, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h837fba73fce77300); return ret; }, __wbindgen_cast_0000000000000006: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1740, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 2049, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h96c1a94f3b510398); return ret; }, __wbindgen_cast_0000000000000007: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1762, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 2071, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`. const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd17f30facfdd737f); return ret; }, __wbindgen_cast_0000000000000008: function(arg0, arg1) { - // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1825, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 2136, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hf726e22cfd1ee0a9); return ret; }, diff --git a/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island_bg.wasm b/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island_bg.wasm index 671e0144..d71e9e13 100644 Binary files a/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island_bg.wasm and b/rust/spikes/leptos-tiptap-spike/generated/island/mnote-leptos-tiptap-spike-island_bg.wasm differ diff --git a/rust/spikes/leptos-tiptap-spike/generated/island/snippets/leptos-tiptap-c355e6ec24c3df4c/src/js/generated/tiptap_paragraph.js b/rust/spikes/leptos-tiptap-spike/generated/island/snippets/leptos-tiptap-c355e6ec24c3df4c/src/js/generated/tiptap_paragraph.js index 630f3577..bbd5fc3a 100644 --- a/rust/spikes/leptos-tiptap-spike/generated/island/snippets/leptos-tiptap-c355e6ec24c3df4c/src/js/generated/tiptap_paragraph.js +++ b/rust/spikes/leptos-tiptap-spike/generated/island/snippets/leptos-tiptap-c355e6ec24c3df4c/src/js/generated/tiptap_paragraph.js @@ -1,4 +1,4 @@ -var jv=Object.create;var Pl=Object.defineProperty;var Gv=Object.getOwnPropertyDescriptor;var Yv=Object.getOwnPropertyNames;var Wv=Object.getPrototypeOf,Vv=Object.prototype.hasOwnProperty;var Xv=(i,e,t)=>e in i?Pl(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var M=(i,e)=>()=>(i&&(e=i(i=0)),e);var qi=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),ti=(i,e)=>{for(var t in e)Pl(i,t,{get:e[t],enumerable:!0})},Kv=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Yv(e))!Vv.call(i,n)&&n!==t&&Pl(i,n,{get:()=>e[n],enumerable:!(r=Gv(e,n))||r.enumerable});return i};var ot=(i,e,t)=>(t=i!=null?jv(Wv(i)):{},Kv(e||!i||!i.__esModule?Pl(t,"default",{value:i,enumerable:!0}):t,i));var P=(i,e,t)=>Xv(i,typeof e!="symbol"?e+"":e,t);function Pd(){if(!Fl&&(Fl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Fl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Fl(Qv)}var Fl,Qv,Gm=M(()=>{Qv=new Uint8Array(16)});function Ym(i,e=0){return lt[i[e+0]]+lt[i[e+1]]+lt[i[e+2]]+lt[i[e+3]]+"-"+lt[i[e+4]]+lt[i[e+5]]+"-"+lt[i[e+6]]+lt[i[e+7]]+"-"+lt[i[e+8]]+lt[i[e+9]]+"-"+lt[i[e+10]]+lt[i[e+11]]+lt[i[e+12]]+lt[i[e+13]]+lt[i[e+14]]+lt[i[e+15]]}var lt,Wm=M(()=>{lt=[];for(let i=0;i<256;++i)lt.push((i+256).toString(16).slice(1))});var Jv,Fd,Vm=M(()=>{Jv=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Fd={randomUUID:Jv}});function ey(i,e,t){if(Fd.randomUUID&&!e&&!i)return Fd.randomUUID();i=i||{};let r=i.random||(i.rng||Pd)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=r[n];return e}return Ym(r)}var Da,Xm=M(()=>{Vm();Gm();Wm();Da=ey});var qd=M(()=>{Xm()});var A,Hd,cF,Ud,us,di,Km,Zm,fs,Qm,Oe=M(()=>{A={CHANGE_THEME:"changeTheme",CHANGE_LAYOUT:"changeLayout",MODE:{READONLY:"readonly",EDIT:"edit"},LAYOUT:{LOGICAL_STRUCTURE:"logicalStructure",LOGICAL_STRUCTURE_LEFT:"logicalStructureLeft",MIND_MAP:"mindMap",ORGANIZATION_STRUCTURE:"organizationStructure",CATALOG_ORGANIZATION:"catalogOrganization",TIMELINE:"timeline",TIMELINE2:"timeline2",FISHBONE:"fishbone",FISHBONE2:"fishbone2",RIGHT_FISHBONE:"rightFishbone",RIGHT_FISHBONE2:"rightFishbone2",VERTICAL_TIMELINE:"verticalTimeline",VERTICAL_TIMELINE2:"verticalTimeline2",VERTICAL_TIMELINE3:"verticalTimeline3"},DIR:{UP:"up",LEFT:"left",DOWN:"down",RIGHT:"right"},KEY_DIR:{LEFT:"Left",UP:"Up",RIGHT:"Right",DOWN:"Down"},SHAPE:{RECTANGLE:"rectangle",DIAMOND:"diamond",PARALLELOGRAM:"parallelogram",ROUNDED_RECTANGLE:"roundedRectangle",OCTAGONAL_RECTANGLE:"octagonalRectangle",OUTER_TRIANGULAR_RECTANGLE:"outerTriangularRectangle",INNER_TRIANGULAR_RECTANGLE:"innerTriangularRectangle",ELLIPSE:"ellipse",CIRCLE:"circle"},MOUSE_WHEEL_ACTION:{ZOOM:"zoom",MOVE:"move"},INIT_ROOT_NODE_POSITION:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom",CENTER:"center"},LAYOUT_GROW_DIR:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom"},PASTE_TYPE:{CLIP_BOARD:"clipBoard",CANVAS:"canvas"},SCROLL_BAR_DIR:{VERTICAL:"vertical",HORIZONTAL:"horizontal"},CREATE_NEW_NODE_BEHAVIOR:{DEFAULT:"default",NOT_ACTIVE:"notActive",ACTIVE_ONLY:"activeOnly"},TAG_PLACEMENT:{RIGHT:"right",BOTTOM:"bottom"},IMG_PLACEMENT:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom"}},Hd={[A.INIT_ROOT_NODE_POSITION.LEFT]:0,[A.INIT_ROOT_NODE_POSITION.TOP]:0,[A.INIT_ROOT_NODE_POSITION.RIGHT]:1,[A.INIT_ROOT_NODE_POSITION.BOTTOM]:1,[A.INIT_ROOT_NODE_POSITION.CENTER]:.5},cF=[{name:"\u903B\u8F91\u7ED3\u6784\u56FE",value:A.LAYOUT.LOGICAL_STRUCTURE},{name:"\u5411\u5DE6\u903B\u8F91\u7ED3\u6784\u56FE",value:A.LAYOUT.LOGICAL_STRUCTURE_LEFT},{name:"\u601D\u7EF4\u5BFC\u56FE",value:A.LAYOUT.MIND_MAP},{name:"\u7EC4\u7EC7\u7ED3\u6784\u56FE",value:A.LAYOUT.ORGANIZATION_STRUCTURE},{name:"\u76EE\u5F55\u7EC4\u7EC7\u56FE",value:A.LAYOUT.CATALOG_ORGANIZATION},{name:"\u65F6\u95F4\u8F74",value:A.LAYOUT.TIMELINE},{name:"\u65F6\u95F4\u8F742",value:A.LAYOUT.TIMELINE2},{name:"\u7AD6\u5411\u65F6\u95F4\u8F74",value:A.LAYOUT.VERTICAL_TIMELINE},{name:"\u7AD6\u5411\u65F6\u95F4\u8F742",value:A.LAYOUT.VERTICAL_TIMELINE2},{name:"\u7AD6\u5411\u65F6\u95F4\u8F743",value:A.LAYOUT.VERTICAL_TIMELINE3},{name:"\u9C7C\u9AA8\u56FE",value:A.LAYOUT.FISHBONE},{name:"\u9C7C\u9AA8\u56FE2",value:A.LAYOUT.FISHBONE2},{name:"\u5411\u53F3\u9C7C\u9AA8\u56FE",value:A.LAYOUT.RIGHT_FISHBONE},{name:"\u5411\u53F3\u9C7C\u9AA8\u56FE2",value:A.LAYOUT.RIGHT_FISHBONE2}],Ud=[A.LAYOUT.LOGICAL_STRUCTURE,A.LAYOUT.LOGICAL_STRUCTURE_LEFT,A.LAYOUT.MIND_MAP,A.LAYOUT.CATALOG_ORGANIZATION,A.LAYOUT.ORGANIZATION_STRUCTURE,A.LAYOUT.TIMELINE,A.LAYOUT.TIMELINE2,A.LAYOUT.VERTICAL_TIMELINE,A.LAYOUT.VERTICAL_TIMELINE2,A.LAYOUT.VERTICAL_TIMELINE3,A.LAYOUT.FISHBONE,A.LAYOUT.FISHBONE2,A.LAYOUT.RIGHT_FISHBONE,A.LAYOUT.RIGHT_FISHBONE2],us=["text","image","imageTitle","imageSize","icon","tag","hyperlink","hyperlinkTitle","note","expand","isActive","generalization","richText","resetRichText","uid","activeStyle","associativeLineTargets","associativeLineTargetControlOffsets","associativeLinePoint","associativeLineText","attachmentUrl","attachmentName","notation","outerFrame","number","range","customLeft","customTop","customTextWidth","checkbox","dir","needUpdate","imgMap","nodeLink"],di={READ_CLIPBOARD_ERROR:"read_clipboard_error",PARSE_PASTE_DATA_ERROR:"parse_paste_data_error",CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR:"custom_handle_clipboard_text_error",LOAD_CLIPBOARD_IMAGE_ERROR:"load_clipboard_image_error",BEFORE_TEXT_EDIT_ERROR:"before_text_edit_error",EXPORT_ERROR:"export_error",EXPORT_LOAD_IMAGE_ERROR:"export_load_image_error",DATA_CHANGE_DETAIL_EVENT_ERROR:"data_change_detail_event_error"},Km=` +var Zb=Object.create;var T0=Object.defineProperty;var Qb=Object.getOwnPropertyDescriptor;var Jb=Object.getOwnPropertyNames;var ew=Object.getPrototypeOf,tw=Object.prototype.hasOwnProperty;var iw=(i,e,t)=>e in i?T0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var T=(i,e)=>()=>(i&&(e=i(i=0)),e);var rr=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),tt=(i,e)=>{for(var t in e)T0(i,t,{get:e[t],enumerable:!0})},rw=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Jb(e))!tw.call(i,n)&&n!==t&&T0(i,n,{get:()=>e[n],enumerable:!(r=Qb(e,n))||r.enumerable});return i};var pt=(i,e,t)=>(t=i!=null?Zb(ew(i)):{},rw(e||!i||!i.__esModule?T0(t,"default",{value:i,enumerable:!0}):t,i));var U=(i,e,t)=>iw(i,typeof e!="symbol"?e+"":e,t);function Fc(){if(!k0&&(k0=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!k0))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return k0(fw)}var k0,fw,N3=T(()=>{fw=new Uint8Array(16)});function E3(i,e=0){return xt[i[e+0]]+xt[i[e+1]]+xt[i[e+2]]+xt[i[e+3]]+"-"+xt[i[e+4]]+xt[i[e+5]]+"-"+xt[i[e+6]]+xt[i[e+7]]+"-"+xt[i[e+8]]+xt[i[e+9]]+"-"+xt[i[e+10]]+xt[i[e+11]]+xt[i[e+12]]+xt[i[e+13]]+xt[i[e+14]]+xt[i[e+15]]}var xt,S3=T(()=>{xt=[];for(let i=0;i<256;++i)xt.push((i+256).toString(16).slice(1))});var mw,qc,A3=T(()=>{mw=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),qc={randomUUID:mw}});function pw(i,e,t){if(qc.randomUUID&&!e&&!i)return qc.randomUUID();i=i||{};let r=i.random||(i.rng||Fc)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=r[n];return e}return E3(r)}var fo,k3=T(()=>{A3();N3();S3();fo=pw});var Hc=T(()=>{k3()});var k,Uc,eU,$c,$s,Mi,C3,_3,js,L3,$e=T(()=>{k={CHANGE_THEME:"changeTheme",CHANGE_LAYOUT:"changeLayout",MODE:{READONLY:"readonly",EDIT:"edit"},LAYOUT:{LOGICAL_STRUCTURE:"logicalStructure",LOGICAL_STRUCTURE_LEFT:"logicalStructureLeft",MIND_MAP:"mindMap",ORGANIZATION_STRUCTURE:"organizationStructure",CATALOG_ORGANIZATION:"catalogOrganization",TIMELINE:"timeline",TIMELINE2:"timeline2",FISHBONE:"fishbone",FISHBONE2:"fishbone2",RIGHT_FISHBONE:"rightFishbone",RIGHT_FISHBONE2:"rightFishbone2",VERTICAL_TIMELINE:"verticalTimeline",VERTICAL_TIMELINE2:"verticalTimeline2",VERTICAL_TIMELINE3:"verticalTimeline3"},DIR:{UP:"up",LEFT:"left",DOWN:"down",RIGHT:"right"},KEY_DIR:{LEFT:"Left",UP:"Up",RIGHT:"Right",DOWN:"Down"},SHAPE:{RECTANGLE:"rectangle",DIAMOND:"diamond",PARALLELOGRAM:"parallelogram",ROUNDED_RECTANGLE:"roundedRectangle",OCTAGONAL_RECTANGLE:"octagonalRectangle",OUTER_TRIANGULAR_RECTANGLE:"outerTriangularRectangle",INNER_TRIANGULAR_RECTANGLE:"innerTriangularRectangle",ELLIPSE:"ellipse",CIRCLE:"circle"},MOUSE_WHEEL_ACTION:{ZOOM:"zoom",MOVE:"move"},INIT_ROOT_NODE_POSITION:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom",CENTER:"center"},LAYOUT_GROW_DIR:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom"},PASTE_TYPE:{CLIP_BOARD:"clipBoard",CANVAS:"canvas"},SCROLL_BAR_DIR:{VERTICAL:"vertical",HORIZONTAL:"horizontal"},CREATE_NEW_NODE_BEHAVIOR:{DEFAULT:"default",NOT_ACTIVE:"notActive",ACTIVE_ONLY:"activeOnly"},TAG_PLACEMENT:{RIGHT:"right",BOTTOM:"bottom"},IMG_PLACEMENT:{LEFT:"left",TOP:"top",RIGHT:"right",BOTTOM:"bottom"}},Uc={[k.INIT_ROOT_NODE_POSITION.LEFT]:0,[k.INIT_ROOT_NODE_POSITION.TOP]:0,[k.INIT_ROOT_NODE_POSITION.RIGHT]:1,[k.INIT_ROOT_NODE_POSITION.BOTTOM]:1,[k.INIT_ROOT_NODE_POSITION.CENTER]:.5},eU=[{name:"\u903B\u8F91\u7ED3\u6784\u56FE",value:k.LAYOUT.LOGICAL_STRUCTURE},{name:"\u5411\u5DE6\u903B\u8F91\u7ED3\u6784\u56FE",value:k.LAYOUT.LOGICAL_STRUCTURE_LEFT},{name:"\u601D\u7EF4\u5BFC\u56FE",value:k.LAYOUT.MIND_MAP},{name:"\u7EC4\u7EC7\u7ED3\u6784\u56FE",value:k.LAYOUT.ORGANIZATION_STRUCTURE},{name:"\u76EE\u5F55\u7EC4\u7EC7\u56FE",value:k.LAYOUT.CATALOG_ORGANIZATION},{name:"\u65F6\u95F4\u8F74",value:k.LAYOUT.TIMELINE},{name:"\u65F6\u95F4\u8F742",value:k.LAYOUT.TIMELINE2},{name:"\u7AD6\u5411\u65F6\u95F4\u8F74",value:k.LAYOUT.VERTICAL_TIMELINE},{name:"\u7AD6\u5411\u65F6\u95F4\u8F742",value:k.LAYOUT.VERTICAL_TIMELINE2},{name:"\u7AD6\u5411\u65F6\u95F4\u8F743",value:k.LAYOUT.VERTICAL_TIMELINE3},{name:"\u9C7C\u9AA8\u56FE",value:k.LAYOUT.FISHBONE},{name:"\u9C7C\u9AA8\u56FE2",value:k.LAYOUT.FISHBONE2},{name:"\u5411\u53F3\u9C7C\u9AA8\u56FE",value:k.LAYOUT.RIGHT_FISHBONE},{name:"\u5411\u53F3\u9C7C\u9AA8\u56FE2",value:k.LAYOUT.RIGHT_FISHBONE2}],$c=[k.LAYOUT.LOGICAL_STRUCTURE,k.LAYOUT.LOGICAL_STRUCTURE_LEFT,k.LAYOUT.MIND_MAP,k.LAYOUT.CATALOG_ORGANIZATION,k.LAYOUT.ORGANIZATION_STRUCTURE,k.LAYOUT.TIMELINE,k.LAYOUT.TIMELINE2,k.LAYOUT.VERTICAL_TIMELINE,k.LAYOUT.VERTICAL_TIMELINE2,k.LAYOUT.VERTICAL_TIMELINE3,k.LAYOUT.FISHBONE,k.LAYOUT.FISHBONE2,k.LAYOUT.RIGHT_FISHBONE,k.LAYOUT.RIGHT_FISHBONE2],$s=["text","image","imageTitle","imageSize","icon","tag","hyperlink","hyperlinkTitle","note","expand","isActive","generalization","richText","resetRichText","uid","activeStyle","associativeLineTargets","associativeLineTargetControlOffsets","associativeLinePoint","associativeLineText","attachmentUrl","attachmentName","notation","outerFrame","number","range","customLeft","customTop","customTextWidth","checkbox","dir","needUpdate","imgMap","nodeLink"],Mi={READ_CLIPBOARD_ERROR:"read_clipboard_error",PARSE_PASTE_DATA_ERROR:"parse_paste_data_error",CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR:"custom_handle_clipboard_text_error",LOAD_CLIPBOARD_IMAGE_ERROR:"load_clipboard_image_error",BEFORE_TEXT_EDIT_ERROR:"before_text_edit_error",EXPORT_ERROR:"export_error",EXPORT_LOAD_IMAGE_ERROR:"export_load_image_error",DATA_CHANGE_DETAIL_EVENT_ERROR:"data_change_detail_event_error"},C3=` /* \u9F20\u6807hover\u548C\u6FC0\u6D3B\u65F6\u6E32\u67D3\u7684\u77E9\u5F62 */ .smm-hover-node{ display: none; @@ -19,13 +19,13 @@ var jv=Object.create;var Pl=Object.defineProperty;var Gv=Object.getOwnPropertyDe .smm-text-node-wrap, .smm-expand-btn-text { user-select: none; } -`,Zm=["img","br","hr","input","link","meta","area"],fs=1.2,Qm=["fontFamily","fontSize","fontWeight","fontStyle","textDecoration","color","textAlign"]});function Oa(i){this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,this.init_genrand(i)}var Jm=M(()=>{Oa.prototype.init_genrand=function(i){for(this.mt[0]=i>>>0,this.mti=1;this.mti>>30,this.mt[this.mti]=(((i&4294901760)>>>16)*1812433253<<16)+(i&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0};Oa.prototype.genrand_int32=function(){var i,e=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var t;for(this.mti==this.N+1&&this.init_genrand(5489),t=0;t>>1^e[i&1];for(;t>>1^e[i&1];i=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^i>>>1^e[i&1],this.mti=0}return i=this.mt[this.mti++],i^=i>>>11,i^=i<<7&2636928640,i^=i<<15&4022730752,i^=i>>>18,i>>>0}});function oe(i,e){if(Array.isArray(i)){for(let t of i)oe(t,e);return}if(typeof i=="object"){for(let t in i)oe(t,i[t]);return}op(Object.getOwnPropertyNames(e)),Wd[i]=Object.assign(Wd[i]||{},e)}function Ot(i){return Wd[i]||{}}function ty(){return[...new Set(ap)]}function op(i){ap.push(...i)}function ic(i,e){let t,r=i.length,n=[];for(t=0;t=0;e--)dp(i.children[e]);return i.id&&(i.id=hp(i.nodeName)),i}function ce(i,e){let t,r;for(i=Array.isArray(i)?i:[i],r=i.length-1;r>=0;r--)for(t in e)i[r].prototype[t]=e[t]}function ze(i){return function(...e){let t=e[e.length-1];return t&&t.constructor===Object&&!(t instanceof Array)?i.apply(this,e.slice(0,-1)).attr(t):i.apply(this,e)}}function ly(){return this.parent().children()}function hy(){return this.parent().index(this)}function dy(){return this.siblings()[this.position()+1]}function cy(){return this.siblings()[this.position()-1]}function uy(){let i=this.position();return this.parent().add(this.remove(),i+1),this}function fy(){let i=this.position();return this.parent().add(this.remove(),i?i-1:0),this}function my(){return this.parent().add(this.remove()),this}function py(){return this.parent().add(this.remove(),0),this}function gy(i){i=Mt(i),i.remove();let e=this.position();return this.parent().add(i,e),this}function xy(i){i=Mt(i),i.remove();let e=this.position();return this.parent().add(i,e+1),this}function vy(i){return i=Mt(i),i.before(this),this}function yy(i){return i=Mt(i),i.after(this),this}function Sy(){let i=this.attr("class");return i==null?[]:i.trim().split(lr)}function Ay(i){return this.classes().indexOf(i)!==-1}function ky(i){if(!this.hasClass(i)){let e=this.classes();e.push(i),this.attr("class",e.join(" "))}return this}function Cy(i){return this.hasClass(i)&&this.attr("class",this.classes().filter(function(e){return e!==i}).join(" ")),this}function _y(i){return this.hasClass(i)?this.removeClass(i):this.addClass(i)}function Ly(i,e){let t={};if(arguments.length===0)return this.node.style.cssText.split(/\s*;\s*/).filter(function(r){return!!r.length}).forEach(function(r){let n=r.split(/\s*:\s*/);t[n[0]]=n[1]}),t;if(arguments.length<2){if(Array.isArray(i)){for(let r of i){let n=ql(r);t[r]=this.node.style[n]}return t}if(typeof i=="string")return this.node.style[ql(i)];if(typeof i=="object")for(let r in i)this.node.style[ql(r)]=i[r]==null||ip.test(i[r])?"":i[r]}return arguments.length===2&&(this.node.style[ql(i)]=e==null||ip.test(e)?"":e),this}function zy(){return this.css("display","")}function Iy(){return this.css("display","none")}function Ry(){return this.css("display")!=="none"}function Dy(i,e,t){if(i==null)return this.data(ic(iy(this.node.attributes,r=>r.nodeName.indexOf("data-")===0),r=>r.nodeName.slice(5)));if(i instanceof Array){let r={};for(let n of i)r[n]=this.data(n);return r}else if(typeof i=="object")for(e in i)this.data(e,i[e]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+i))}catch{return this.attr("data-"+i)}else this.attr("data-"+i,e===null?null:t===!0||typeof e=="string"||typeof e=="number"?e:JSON.stringify(e));return this}function Oy(i,e){if(typeof arguments[0]=="object")for(let t in i)this.remember(t,i[t]);else{if(arguments.length===1)return this.memory()[i];this.memory()[i]=e}return this}function By(){if(arguments.length===0)this._memory={};else for(let i=arguments.length-1;i>=0;i--)delete this.memory()[arguments[i]];return this}function Py(){return this._memory=this._memory||{}}function Fy(i){return i.length===4?["#",i.substring(1,2),i.substring(1,2),i.substring(2,3),i.substring(2,3),i.substring(3,4),i.substring(3,4)].join(""):i}function qy(i){let e=Math.round(i),r=Math.max(0,Math.min(255,e)).toString(16);return r.length===1?"0"+r:r}function ms(i,e){for(let t=e.length;t--;)if(i[e[t]]==null)return!1;return!0}function Hy(i,e){let t=ms(i,"rgb")?{_a:i.r,_b:i.g,_c:i.b,_d:0,space:"rgb"}:ms(i,"xyz")?{_a:i.x,_b:i.y,_c:i.z,_d:0,space:"xyz"}:ms(i,"hsl")?{_a:i.h,_b:i.s,_c:i.l,_d:0,space:"hsl"}:ms(i,"lab")?{_a:i.l,_b:i.a,_c:i.b,_d:0,space:"lab"}:ms(i,"lch")?{_a:i.l,_b:i.c,_c:i.h,_d:0,space:"lch"}:ms(i,"cmyk")?{_a:i.c,_b:i.m,_c:i.y,_d:i.k,space:"cmyk"}:{_a:0,_b:0,_c:0,space:"rgb"};return t.space=e||t.space,t}function Uy(i){return i==="lab"||i==="xyz"||i==="lch"}function Gd(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*(2/3-t)*6:i}function $y(i,e){return new Ye(i,e).transformO(this.screenCTM().inverseO())}function ps(i,e,t){return Math.abs(e-i)<(t||1e-6)}function jy(){return new ue(this.node.getCTM())}function Gy(){if(typeof this.isRoot=="function"&&!this.isRoot()){let i=this.rect(1,1),e=i.node.getScreenCTM();return i.remove(),new ue(e)}return new ue(this.node.getScreenCTM())}function Hr(){if(!Hr.nodes){let i=Mt().size(2,0);i.node.style.cssText=["opacity: 0","position: absolute","left: -100%","top: -100%","overflow: hidden"].join(";"),i.attr("focusable","false"),i.attr("aria-hidden","true");let e=i.path().node;Hr.nodes={svg:i,path:e}}if(!Hr.nodes.svg.node.parentNode){let i=xe.document.body||xe.document.documentElement;Hr.nodes.svg.addTo(i)}return Hr.nodes}function up(i){return!i.width&&!i.height&&!i.x&&!i.y}function Yy(i){return i===xe.document||(xe.document.documentElement.contains||function(e){for(;e.parentNode;)e=e.parentNode;return e===xe.document}).call(xe.document.documentElement,i)}function fp(i,e,t){let r;try{if(r=e(i.node),up(r)&&!Yy(i.node))throw new Error("Element not in the dom")}catch{r=t(i)}return r}function Wy(){let t=fp(this,n=>n.getBBox(),n=>{try{let s=n.clone().addTo(Hr().svg).show(),a=s.node.getBBox();return s.remove(),a}catch(s){throw new Error(`Getting bbox of element "${n.node.nodeName}" is not possible: ${s.toString()}`)}});return new Rt(t)}function Vy(i){let r=fp(this,s=>s.getBoundingClientRect(),s=>{throw new Error(`Getting rbox of element "${s.node.nodeName}" is not possible`)}),n=new Rt(r);return i?n.transform(i.screenCTM().inverseO()):n.addOffset()}function Xy(i,e){let t=this.bbox();return i>t.x&&e>t.y&&i(r[n]=this.attr(n),r),{});if(typeof i=="object"&&i.constructor===Object)for(e in i)this.attr(e,i[e]);else if(e===null)this.node.removeAttribute(i);else{if(e==null)return e=this.node.getAttribute(i),e==null?ib[i]:rp.test(e)?parseFloat(e):e;e=gp.reduce((r,n)=>n(i,r,this),e),typeof e=="number"?e=new fe(e):ui.isColor(e)?e=new ui(e):e.constructor===Array&&(e=new Ur(e)),i==="leading"?this.leading&&this.leading(e):typeof t=="string"?this.node.setAttributeNS(t,i,e.toString()):this.node.setAttribute(i,e.toString()),this.rebuild&&(i==="font-size"||i==="x")&&this.rebuild()}}return this}function ab(){return this.attr("transform",null)}function ob(){return(this.attr("transform")||"").split(Ty).slice(0,-1).map(function(e){let t=e.trim().split("(");return[t[0],t[1].split(lr).map(function(r){return parseFloat(r)})]}).reverse().reduce(function(e,t){return t[0]==="matrix"?e.lmultiply(ue.fromArray(t[1])):e[t[0]].apply(e,t[1])},new ue)}function lb(i,e){if(this===i)return this;let t=this.screenCTM(),r=i.screenCTM().inverse();return this.addTo(i,e).untransform().transform(r.multiply(t)),this}function hb(i){return this.toParent(this.root(),i)}function db(i,e){if(i==null||typeof i=="string"){let n=new ue(this).decompose();return i==null?n:n[i]}ue.isMatrixLike(i)||(i={...i,origin:Vd(i,this)});let t=e===!0?this:e||!1,r=new ue(t).transform(i);return this.attr("transform",r)}function oc(i){return this.attr("rx",i)}function lc(i){return this.attr("ry",i)}function xp(i){return i==null?this.cx()-this.rx():this.cx(i+this.rx())}function vp(i){return i==null?this.cy()-this.ry():this.cy(i+this.ry())}function yp(i){return this.attr("cx",i)}function bp(i){return this.attr("cy",i)}function wp(i){return i==null?this.rx()*2:this.rx(new fe(i).divide(2))}function Mp(i){return i==null?this.ry()*2:this.ry(new fe(i).divide(2))}function Tp(i,e){return(this._element||this).type==="radialGradient"?this.attr({fx:new fe(i),fy:new fe(e)}):this.attr({x1:new fe(i),y1:new fe(e)})}function Np(i,e){return(this._element||this).type==="radialGradient"?this.attr({cx:new fe(i),cy:new fe(e)}):this.attr({x2:new fe(i),y2:new fe(e)})}function mb(i){return i==null?this.bbox().x:this.move(i,this.bbox().y)}function pb(i){return i==null?this.bbox().y:this.move(this.bbox().x,i)}function gb(i){let e=this.bbox();return i==null?e.width:this.size(i,e.height)}function xb(i){let e=this.bbox();return i==null?e.height:this.size(e.width,i)}function xs(i,e){return function(t){return t==null?this[i]:(this[i]=t,e&&e.call(this),this)}}function sp(){let i=(this._duration||500)/1e3,e=this._overshoot||0,t=1e-10,r=Math.PI,n=Math.log(e/100+t),s=-n/Math.sqrt(r*r+n*n),a=3.9/(s*i);this.d=2*s*a,this.k=a*a}function bb(i){let e=i.segment[0];return Qd[e](i.segment.slice(1),i.p,i.p0)}function Jd(i){return i.segment.length&&i.segment.length-1===yb[i.segment[0].toUpperCase()]}function wb(i,e){i.inNumber&&kn(i,!1);let t=sc.test(e);if(t)i.segment=[e];else{let r=i.lastCommand,n=r.toLowerCase(),s=r===n;i.segment=[n==="m"?s?"l":"L":r]}return i.inSegment=!0,i.lastCommand=i.segment[0],t}function kn(i,e){if(!i.inNumber)throw new Error("Parser Error");i.number&&i.segment.push(parseFloat(i.number)),i.inNumber=e,i.number="",i.pointSeen=!1,i.hasExponent=!1,Jd(i)&&ec(i)}function ec(i){i.inSegment=!1,i.absolute&&(i.segment=bb(i)),i.segments.push(i.segment)}function Mb(i){if(!i.segment.length)return!1;let e=i.segment[0].toUpperCase()==="A",t=i.segment.length;return e&&(t===4||t===5)}function Tb(i){return i.lastToken.toUpperCase()==="E"}function Nb(i,e=!0){let t=0,r="",n={segment:[],inNumber:!1,number:"",lastToken:"",inSegment:!1,segments:[],pointSeen:!1,hasExponent:!1,absolute:e,p0:new Ye,p:new Ye};for(;n.lastToken=r,r=i.charAt(t++);)if(!(!n.inSegment&&wb(n,r))){if(r==="."){if(n.pointSeen||n.hasExponent){kn(n,!1),--t;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=r;continue}if(!isNaN(parseInt(r))){if(n.number==="0"||Mb(n)){n.inNumber=!0,n.number=r,kn(n,!0);continue}n.inNumber=!0,n.number+=r;continue}if(r===" "||r===","){n.inNumber&&kn(n,!1);continue}if(r==="-"){if(n.inNumber&&!Tb(n)){kn(n,!1),--t;continue}n.number+=r,n.inNumber=!0;continue}if(r.toUpperCase()==="E"){n.number+=r,n.hasExponent=!0;continue}if(sc.test(r)){if(n.inNumber)kn(n,!1);else if(Jd(n))ec(n);else throw new Error("parser Error");--t}}return n.inNumber&&kn(n,!1),n.inSegment&&Jd(n)&&ec(n),n.segments}function Eb(i){let e="";for(let t=0,r=i.length;t{let n;try{n=t.bbox()}catch{return}let s=new ue(t),a=s.translate(i,e).transform(s.inverse()),o=new Ye(n.x,n.y).transform(a);t.move(o.x,o.y)}),this}function Zb(i){return this.dmove(i,0)}function Qb(i){return this.dmove(0,i)}function Jb(i,e=this.bbox()){return i==null?e.height:this.size(e.width,i,e)}function ew(i=0,e=0,t=this.bbox()){let r=i-t.x,n=e-t.y;return this.dmove(r,n)}function tw(i,e,t=this.bbox()){let r=Ns(this,i,e,t),n=r.width/t.width,s=r.height/t.height;return this.children().forEach((a,o)=>{let l=new Ye(t).transform(new ue(a).inverse());a.scale(n,s,l.x,l.y)}),this}function iw(i,e=this.bbox()){return i==null?e.width:this.size(i,e.height,e)}function rw(i,e=this.bbox()){return i==null?e.x:this.move(i,e.y,e)}function nw(i,e=this.bbox()){return i==null?e.y:this.move(e.x,i,e)}function sw(i,e){if(!i)return"";if(!e)return i;let t=i+"{";for(let r in e)t+=ry(r)+":"+e[r]+";";return t+="}",t}var Wd,ap,rc,ny,Hl,Ja,sy,xe,qa,Cn,nc,jd,oy,cp,by,wy,My,Ty,Ny,ep,tp,ip,rp,Ey,lr,sc,ui,Ye,ue,Rt,ar,Ky,Jy,mp,_n,Pa,ib,Ur,fe,gp,$r,fi,Ba,sb,Dt,Ua,Tt,cb,vs,Ul,ub,Ln,zn,Ci,Hi,fb,hc,In,ys,vb,$a,ja,bs,Kd,Zd,yb,Qd,Yd,or,Ep,sr,Ga,Ya,Sb,Rn,dc,Ui,Sp,_i,Dn,Pe,Fa,we,Rb,Db,$l,Li,ws,Ap,kp,tc,Bb,Wa,Va,Cp,Te,Ms,zi,Xa,Ts,_p,Ne,jr,Ka,jl,Za,Qa,Gl,Me,ht=M(()=>{Wd={},ap=[];rc="http://www.w3.org/2000/svg",ny="http://www.w3.org/1999/xhtml",Hl="http://www.w3.org/2000/xmlns/",Ja="http://www.w3.org/1999/xlink",sy="http://svgjs.dev/svgjs",xe={window:typeof window>"u"?null:window,document:typeof document>"u"?null:document},qa=class{},Cn={},nc="___SYMBOL___ROOT___";jd=ci;oy=1e3;oe("Dom",{siblings:ly,position:hy,next:dy,prev:cy,forward:uy,backward:fy,front:my,back:py,before:gy,after:xy,insertBefore:vy,insertAfter:yy});cp=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,by=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,wy=/rgb\((\d+),(\d+),(\d+)\)/,My=/(#[a-z_][a-z0-9\-_]*)/i,Ty=/\)\s*,?\s*/,Ny=/\s/g,ep=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,tp=/^rgb\(/,ip=/^(\s+)?$/,rp=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ey=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,lr=/[\s,]+/,sc=/[MLHVCSQTAZ]/i;oe("Dom",{classes:Sy,hasClass:Ay,addClass:ky,removeClass:Cy,toggleClass:_y});oe("Dom",{css:Ly,show:zy,hide:Iy,visible:Ry});oe("Dom",{data:Dy});oe("Dom",{remember:Oy,forget:By,memory:Py});ui=class i{constructor(...e){this.init(...e)}static isColor(e){return e&&(e instanceof i||this.isRgb(e)||this.test(e))}static isRgb(e){return e&&typeof e.r=="number"&&typeof e.g=="number"&&typeof e.b=="number"}static random(e="vibrant",t,r){let{random:n,round:s,sin:a,PI:o}=Math;if(e==="vibrant"){let l=24*n()+57,h=38*n()+45,d=360*n();return new i(l,h,d,"lch")}else if(e==="sine"){t=t??n();let l=s(80*a(2*o*t/.5+.01)+150),h=s(50*a(2*o*t/.5+4.6)+200),d=s(100*a(2*o*t/.5+2.3)+150);return new i(l,h,d)}else if(e==="pastel"){let l=8*n()+86,h=17*n()+9,d=360*n();return new i(l,h,d,"lch")}else if(e==="dark"){let l=10+10*n(),h=50*n()+86,d=360*n();return new i(l,h,d,"lch")}else if(e==="rgb"){let l=255*n(),h=255*n(),d=255*n();return new i(l,h,d)}else if(e==="lab"){let l=100*n(),h=256*n()-128,d=256*n()-128;return new i(l,h,d,"lab")}else if(e==="grey"){let l=255*n();return new i(l,l,l)}else throw new Error("Unsupported random color mode")}static test(e){return typeof e=="string"&&(ep.test(e)||tp.test(e))}cmyk(){let{_a:e,_b:t,_c:r}=this.rgb(),[n,s,a]=[e,t,r].map(f=>f/255),o=Math.min(1-n,1-s,1-a);if(o===1)return new i(0,0,0,1,"cmyk");let l=(1-n-o)/(1-o),h=(1-s-o)/(1-o),d=(1-a-o)/(1-o);return new i(l,h,d,o,"cmyk")}hsl(){let{_a:e,_b:t,_c:r}=this.rgb(),[n,s,a]=[e,t,r].map(x=>x/255),o=Math.max(n,s,a),l=Math.min(n,s,a),h=(o+l)/2,d=o===l,c=o-l,f=d?0:h>.5?c/(2-o-l):c/(o+l),m=d?0:o===n?((s-a)/c+(sparseInt(x));Object.assign(this,{_a:f,_b:m,_c:g,_d:0,space:"rgb"})}else if(ep.test(e)){let c=x=>parseInt(x,16),[,f,m,g]=by.exec(Fy(e)).map(c);Object.assign(this,{_a:f,_b:m,_c:g,_d:0,space:"rgb"})}else throw Error("Unsupported string format, can't construct Color");let{_a:a,_b:o,_c:l,_d:h}=this,d=this.space==="rgb"?{r:a,g:o,b:l}:this.space==="xyz"?{x:a,y:o,z:l}:this.space==="hsl"?{h:a,s:o,l}:this.space==="lab"?{l:a,a:o,b:l}:this.space==="lch"?{l:a,c:o,h:l}:this.space==="cmyk"?{c:a,m:o,y:l,k:h}:{};Object.assign(this,d)}lab(){let{x:e,y:t,z:r}=this.xyz(),n=116*t-16,s=500*(e-t),a=200*(t-r);return new i(n,s,a,"lab")}lch(){let{l:e,a:t,b:r}=this.lab(),n=Math.sqrt(t**2+r**2),s=180*Math.atan2(r,t)/Math.PI;return s<0&&(s*=-1,s=360-s),new i(e,n,s,"lch")}rgb(){if(this.space==="rgb")return this;if(Uy(this.space)){let{x:e,y:t,z:r}=this;if(this.space==="lab"||this.space==="lch"){let{l:m,a:g,b:x}=this;if(this.space==="lch"){let{c:I,h:O}=this,D=Math.PI/180;g=I*Math.cos(D*O),x=I*Math.sin(D*O)}let v=(m+16)/116,b=g/500+v,E=v-x/200,S=16/116,C=.008856,_=7.787;e=.95047*(b**3>C?b**3:(b-S)/_),t=1*(v**3>C?v**3:(v-S)/_),r=1.08883*(E**3>C?E**3:(E-S)/_)}let n=e*3.2406+t*-1.5372+r*-.4986,s=e*-.9689+t*1.8758+r*.0415,a=e*.0557+t*-.204+r*1.057,o=Math.pow,l=.0031308,h=n>l?1.055*o(n,1/2.4)-.055:12.92*n,d=s>l?1.055*o(s,1/2.4)-.055:12.92*s,c=a>l?1.055*o(a,1/2.4)-.055:12.92*a;return new i(255*h,255*d,255*c)}else if(this.space==="hsl"){let{h:e,s:t,l:r}=this;if(e/=360,t/=100,r/=100,t===0)return r*=255,new i(r,r,r);let n=r<.5?r*(1+t):r+t-r*t,s=2*r-n,a=255*Gd(s,n,e+1/3),o=255*Gd(s,n,e),l=255*Gd(s,n,e-1/3);return new i(a,o,l)}else if(this.space==="cmyk"){let{c:e,m:t,y:r,k:n}=this,s=255*(1-Math.min(1,e*(1-n)+n)),a=255*(1-Math.min(1,t*(1-n)+n)),o=255*(1-Math.min(1,r*(1-n)+n));return new i(s,a,o)}else return this}toArray(){let{_a:e,_b:t,_c:r,_d:n,space:s}=this;return[e,t,r,n,s]}toHex(){let[e,t,r]=this._clamped().map(qy);return`#${e}${t}${r}`}toRgb(){let[e,t,r]=this._clamped();return`rgb(${e},${t},${r})`}toString(){return this.toHex()}xyz(){let{_a:e,_b:t,_c:r}=this.rgb(),[n,s,a]=[e,t,r].map(b=>b/255),o=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,l=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92,h=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92,d=(o*.4124+l*.3576+h*.1805)/.95047,c=(o*.2126+l*.7152+h*.0722)/1,f=(o*.0193+l*.1192+h*.9505)/1.08883,m=d>.008856?Math.pow(d,1/3):7.787*d+16/116,g=c>.008856?Math.pow(c,1/3):7.787*c+16/116,x=f>.008856?Math.pow(f,1/3):7.787*f+16/116;return new i(m,g,x,"xyz")}_clamped(){let{_a:e,_b:t,_c:r}=this.rgb(),{max:n,min:s,round:a}=Math,o=l=>n(0,s(a(l),255));return[e,t,r].map(o)}},Ye=class i{constructor(...e){this.init(...e)}clone(){return new i(this)}init(e,t){let r={x:0,y:0},n=Array.isArray(e)?{x:e[0],y:e[1]}:typeof e=="object"?{x:e.x,y:e.y}:{x:e,y:t};return this.x=n.x==null?r.x:n.x,this.y=n.y==null?r.y:n.y,this}toArray(){return[this.x,this.y]}transform(e){return this.clone().transformO(e)}transformO(e){ue.isMatrixLike(e)||(e=new ue(e));let{x:t,y:r}=this;return this.x=e.a*t+e.c*r+e.e,this.y=e.b*t+e.d*r+e.f,this}};ue=class i{constructor(...e){this.init(...e)}static formatTransforms(e){let t=e.flip==="both"||e.flip===!0,r=e.flip&&(t||e.flip==="x")?-1:1,n=e.flip&&(t||e.flip==="y")?-1:1,s=e.skew&&e.skew.length?e.skew[0]:isFinite(e.skew)?e.skew:isFinite(e.skewX)?e.skewX:0,a=e.skew&&e.skew.length?e.skew[1]:isFinite(e.skew)?e.skew:isFinite(e.skewY)?e.skewY:0,o=e.scale&&e.scale.length?e.scale[0]*r:isFinite(e.scale)?e.scale*r:isFinite(e.scaleX)?e.scaleX*r:r,l=e.scale&&e.scale.length?e.scale[1]*n:isFinite(e.scale)?e.scale*n:isFinite(e.scaleY)?e.scaleY*n:n,h=e.shear||0,d=e.rotate||e.theta||0,c=new Ye(e.origin||e.around||e.ox||e.originX,e.oy||e.originY),f=c.x,m=c.y,g=new Ye(e.position||e.px||e.positionX||NaN,e.py||e.positionY||NaN),x=g.x,v=g.y,b=new Ye(e.translate||e.tx||e.translateX,e.ty||e.translateY),E=b.x,S=b.y,C=new Ye(e.relative||e.rx||e.relativeX,e.ry||e.relativeY),_=C.x,I=C.y;return{scaleX:o,scaleY:l,skewX:s,skewY:a,shear:h,theta:d,rx:_,ry:I,tx:E,ty:S,ox:f,oy:m,px:x,py:v}}static fromArray(e){return{a:e[0],b:e[1],c:e[2],d:e[3],e:e[4],f:e[5]}}static isMatrixLike(e){return e.a!=null||e.b!=null||e.c!=null||e.d!=null||e.e!=null||e.f!=null}static matrixMultiply(e,t,r){let n=e.a*t.a+e.c*t.b,s=e.b*t.a+e.d*t.b,a=e.a*t.c+e.c*t.d,o=e.b*t.c+e.d*t.d,l=e.e+e.a*t.e+e.c*t.f,h=e.f+e.b*t.e+e.d*t.f;return r.a=n,r.b=s,r.c=a,r.d=o,r.e=l,r.f=h,r}around(e,t,r){return this.clone().aroundO(e,t,r)}aroundO(e,t,r){let n=e||0,s=t||0;return this.translateO(-n,-s).lmultiplyO(r).translateO(n,s)}clone(){return new i(this)}decompose(e=0,t=0){let r=this.a,n=this.b,s=this.c,a=this.d,o=this.e,l=this.f,h=r*a-n*s,d=h>0?1:-1,c=d*Math.sqrt(r*r+n*n),f=Math.atan2(d*n,d*r),m=180/Math.PI*f,g=Math.cos(f),x=Math.sin(f),v=(r*s+n*a)/h,b=s*c/(v*r-n)||a*c/(v*n+r),E=o-e+e*g*c+t*(v*g*c-x*b),S=l-t+e*x*c+t*(v*x*c+g*b);return{scaleX:c,scaleY:b,shear:v,rotate:m,translateX:E,translateY:S,originX:e,originY:t,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}equals(e){if(e===this)return!0;let t=new i(e);return ps(this.a,t.a)&&ps(this.b,t.b)&&ps(this.c,t.c)&&ps(this.d,t.d)&&ps(this.e,t.e)&&ps(this.f,t.f)}flip(e,t){return this.clone().flipO(e,t)}flipO(e,t){return e==="x"?this.scaleO(-1,1,t,0):e==="y"?this.scaleO(1,-1,0,t):this.scaleO(-1,-1,e,t||e)}init(e){let t=i.fromArray([1,0,0,1,0,0]);return e=e instanceof fi?e.matrixify():typeof e=="string"?i.fromArray(e.split(lr).map(parseFloat)):Array.isArray(e)?i.fromArray(e):typeof e=="object"&&i.isMatrixLike(e)?e:typeof e=="object"?new i().transform(e):arguments.length===6?i.fromArray([].slice.call(arguments)):t,this.a=e.a!=null?e.a:t.a,this.b=e.b!=null?e.b:t.b,this.c=e.c!=null?e.c:t.c,this.d=e.d!=null?e.d:t.d,this.e=e.e!=null?e.e:t.e,this.f=e.f!=null?e.f:t.f,this}inverse(){return this.clone().inverseO()}inverseO(){let e=this.a,t=this.b,r=this.c,n=this.d,s=this.e,a=this.f,o=e*n-t*r;if(!o)throw new Error("Cannot invert "+this);let l=n/o,h=-t/o,d=-r/o,c=e/o,f=-(l*s+d*a),m=-(h*s+c*a);return this.a=l,this.b=h,this.c=d,this.d=c,this.e=f,this.f=m,this}lmultiply(e){return this.clone().lmultiplyO(e)}lmultiplyO(e){let t=this,r=e instanceof i?e:new i(e);return i.matrixMultiply(r,t,this)}multiply(e){return this.clone().multiplyO(e)}multiplyO(e){let t=this,r=e instanceof i?e:new i(e);return i.matrixMultiply(t,r,this)}rotate(e,t,r){return this.clone().rotateO(e,t,r)}rotateO(e,t=0,r=0){e=$d(e);let n=Math.cos(e),s=Math.sin(e),{a,b:o,c:l,d:h,e:d,f:c}=this;return this.a=a*n-o*s,this.b=o*n+a*s,this.c=l*n-h*s,this.d=h*n+l*s,this.e=d*n-c*s+r*s-t*n+t,this.f=c*n+d*s-t*s-r*n+r,this}scale(e,t,r,n){return this.clone().scaleO(...arguments)}scaleO(e,t=e,r=0,n=0){arguments.length===3&&(n=r,r=t,t=e);let{a:s,b:a,c:o,d:l,e:h,f:d}=this;return this.a=s*e,this.b=a*t,this.c=o*e,this.d=l*t,this.e=h*e-r*e+r,this.f=d*t-n*t+n,this}shear(e,t,r){return this.clone().shearO(e,t,r)}shearO(e,t=0,r=0){let{a:n,b:s,c:a,d:o,e:l,f:h}=this;return this.a=n+s*e,this.c=a+o*e,this.e=l+h*e-r*e,this}skew(e,t,r,n){return this.clone().skewO(...arguments)}skewO(e,t=e,r=0,n=0){arguments.length===3&&(n=r,r=t,t=e),e=$d(e),t=$d(t);let s=Math.tan(e),a=Math.tan(t),{a:o,b:l,c:h,d,e:c,f}=this;return this.a=o+l*s,this.b=l+o*a,this.c=h+d*s,this.d=d+h*a,this.e=c+f*s-n*s,this.f=f+c*a-r*a,this}skewX(e,t,r){return this.skew(e,0,t,r)}skewY(e,t,r){return this.skew(0,e,t,r)}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}toString(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}transform(e){if(i.isMatrixLike(e))return new i(e).multiplyO(this);let t=i.formatTransforms(e),r=this,{x:n,y:s}=new Ye(t.ox,t.oy).transform(r),a=new i().translateO(t.rx,t.ry).lmultiplyO(r).translateO(-n,-s).scaleO(t.scaleX,t.scaleY).skewO(t.skewX,t.skewY).shearO(t.shear).rotateO(t.theta).translateO(n,s);if(isFinite(t.px)||isFinite(t.py)){let o=new Ye(n,s).transform(a),l=isFinite(t.px)?t.px-o.x:0,h=isFinite(t.py)?t.py-o.y:0;a.translateO(l,h)}return a.translateO(t.tx,t.ty),a}translate(e,t){return this.clone().translateO(e,t)}translateO(e,t){return this.e+=e||0,this.f+=t||0,this}valueOf(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}};me(ue,"Matrix");Rt=class i{constructor(...e){this.init(...e)}addOffset(){return this.x+=xe.window.pageXOffset,this.y+=xe.window.pageYOffset,new i(this)}init(e){let t=[0,0,0,0];return e=typeof e=="string"?e.split(lr).map(parseFloat):Array.isArray(e)?e:typeof e=="object"?[e.left!=null?e.left:e.x,e.top!=null?e.top:e.y,e.width,e.height]:arguments.length===4?[].slice.call(arguments):t,this.x=e[0]||0,this.y=e[1]||0,this.width=this.w=e[2]||0,this.height=this.h=e[3]||0,this.x2=this.x+this.w,this.y2=this.y+this.h,this.cx=this.x+this.w/2,this.cy=this.y+this.h/2,this}isNulled(){return up(this)}merge(e){let t=Math.min(this.x,e.x),r=Math.min(this.y,e.y),n=Math.max(this.x+this.width,e.x+e.width)-t,s=Math.max(this.y+this.height,e.y+e.height)-r;return new i(t,r,n,s)}toArray(){return[this.x,this.y,this.width,this.height]}toString(){return this.x+" "+this.y+" "+this.width+" "+this.height}transform(e){e instanceof ue||(e=new ue(e));let t=1/0,r=-1/0,n=1/0,s=-1/0;return[new Ye(this.x,this.y),new Ye(this.x2,this.y),new Ye(this.x,this.y2),new Ye(this.x2,this.y2)].forEach(function(o){o=o.transform(e),t=Math.min(t,o.x),r=Math.max(r,o.x),n=Math.min(n,o.y),s=Math.max(s,o.y)}),new i(t,n,r-t,s-n)}};oe({viewbox:{viewbox(i,e,t,r){return i==null?new Rt(this.attr("viewBox")):this.attr("viewBox",new Rt(i,e,t,r))},zoom(i,e){let{width:t,height:r}=this.attr(["width","height"]);if((!t&&!r||typeof t=="string"||typeof r=="string")&&(t=this.node.clientWidth,r=this.node.clientHeight),!t||!r)throw new Error("Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element");let n=this.viewbox(),s=t/n.width,a=r/n.height,o=Math.min(s,a);if(i==null)return o;let l=o/i;l===1/0&&(l=Number.MAX_SAFE_INTEGER/100),e=e||new Ye(t/2/s+n.x,r/2/a+n.y);let h=new Rt(n).transform(new ue({scale:l,origin:e}));return this.viewbox(h)}}});me(Rt,"Box");ar=class extends Array{constructor(e=[],...t){if(super(e,...t),typeof e=="number")return this;this.length=0,this.push(...e)}};ce([ar],{each(i,...e){return typeof i=="function"?this.map((t,r,n)=>i.call(t,t,r,n)):this.map(t=>t[i](...e))},toArray(){return Array.prototype.concat.apply([],this)}});Ky=["toArray","constructor","each"];ar.extend=function(i){i=i.reduce((e,t)=>(Ky.includes(t)||t[0]==="_"||(e[t]=function(...r){return this.each(t,...r)}),e),{}),ce([ar],i)};Jy=0,mp={};_n=class extends qa{addEventListener(){}dispatch(e,t,r){return tb(this,e,t,r)}dispatchEvent(e){let t=this.getEventHolder().events;if(!t)return!0;let r=t[e.type];for(let n in r)for(let s in r[n])r[n][s](e);return!e.defaultPrevented}fire(e,t,r){return this.dispatch(e,t,r),this}getEventHolder(){return this}getEventTarget(){return this}off(e,t,r){return gs(this,e,t,r),this}on(e,t,r,n){return Xd(this,e,t,r,n),this}removeEventListener(){}};me(_n,"EventTarget");Pa={duration:400,ease:">",delay:0},ib={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","text-anchor":"start"},Ur=class extends Array{constructor(...e){super(...e),this.init(...e)}clone(){return new this.constructor(this)}init(e){return typeof e=="number"?this:(this.length=0,this.push(...this.parse(e)),this)}parse(e=[]){return e instanceof Array?e:e.trim().split(lr).map(parseFloat)}toArray(){return Array.prototype.concat.apply([],this)}toSet(){return new Set(this)}toString(){return this.join(" ")}valueOf(){let e=[];return e.push(...this),e}},fe=class i{constructor(...e){this.init(...e)}convert(e){return new i(this.value,e)}divide(e){return e=new i(e),new i(this/e,this.unit||e.unit)}init(e,t){return t=Array.isArray(e)?e[1]:t,e=Array.isArray(e)?e[0]:e,this.value=0,this.unit=t||"",typeof e=="number"?this.value=isNaN(e)?0:isFinite(e)?e:e<0?-34e37:34e37:typeof e=="string"?(t=e.match(cp),t&&(this.value=parseFloat(t[1]),t[5]==="%"?this.value/=100:t[5]==="s"&&(this.value*=1e3),this.unit=t[5])):e instanceof i&&(this.value=e.valueOf(),this.unit=e.unit),this}minus(e){return e=new i(e),new i(this-e,this.unit||e.unit)}plus(e){return e=new i(e),new i(this+e,this.unit||e.unit)}times(e){return e=new i(e),new i(this*e,this.unit||e.unit)}toArray(){return[this.value,this.unit]}toJSON(){return this.toString()}toString(){return(this.unit==="%"?~~(this.value*1e8)/1e6:this.unit==="s"?this.value/1e3:this.value)+this.unit}valueOf(){return this.value}},gp=[];$r=class i extends _n{constructor(e,t){super(),this.node=e,this.type=e.nodeName,t&&e!==t&&this.attr(t)}add(e,t){return e=Mt(e),e.removeNamespace&&this.node instanceof xe.window.SVGElement&&e.removeNamespace(),t==null?this.node.appendChild(e.node):e.node!==this.node.childNodes[t]&&this.node.insertBefore(e.node,this.node.childNodes[t]),this}addTo(e,t){return Mt(e).put(this,t)}children(){return new ar(ic(this.node.children,function(e){return ci(e)}))}clear(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}clone(e=!0,t=!0){this.writeDataToDom();let r=this.node.cloneNode(e);return t&&(r=dp(r)),new this.constructor(r)}each(e,t){let r=this.children(),n,s;for(n=0,s=r.length;n=0}html(e,t){return this.xml(e,t,ny)}id(e){return typeof e>"u"&&!this.node.id&&(this.node.id=hp(this.type)),this.attr("id",e)}index(e){return[].slice.call(this.node.childNodes).indexOf(e.node)}last(){return ci(this.node.lastChild)}matches(e){let t=this.node,r=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector||null;return r&&r.call(t,e)}parent(e){let t=this;if(!t.node.parentNode)return null;if(t=ci(t.node.parentNode),!e)return t;do if(typeof e=="string"?t.matches(e):t instanceof e)return t;while(t=ci(t.node.parentNode));return t}put(e,t){return e=Mt(e),this.add(e,t),e}putIn(e,t){return Mt(e).add(this,t)}remove(){return this.parent()&&this.parent().removeElement(this),this}removeElement(e){return this.node.removeChild(e.node),this}replace(e){return e=Mt(e),this.node.parentNode&&this.node.parentNode.replaceChild(e.node,this.node),e}round(e=2,t=null){let r=10**e,n=this.attr(t);for(let s in n)typeof n[s]=="number"&&(n[s]=Math.round(n[s]*r)/r);return this.attr(n),this}svg(e,t){return this.xml(e,t,rc)}toString(){return this.id()}words(e){return this.node.textContent=e,this}wrap(e){let t=this.parent();if(!t)return this.addTo(e);let r=t.index(this);return t.put(e,r).put(this)}writeDataToDom(){return this.each(function(){this.writeDataToDom()}),this}xml(e,t,r){if(typeof e=="boolean"&&(r=t,t=e,e=null),e==null||typeof e=="function"){t=t??!0,this.writeDataToDom();let o=this;if(e!=null){if(o=ci(o.node.cloneNode(!0)),t){let l=e(o);if(o=l||o,l===!1)return""}o.each(function(){let l=e(this),h=l||this;l===!1?this.remove():l&&this!==h&&this.replace(h)},!0)}return t?o.node.outerHTML:o.node.innerHTML}t=t??!1;let n=Ha("wrapper",r),s=xe.document.createDocumentFragment();n.innerHTML=e;for(let o=n.children.length;o--;)s.appendChild(n.firstElementChild);let a=this.parent();return t?this.replace(s)&&a:this.add(s)}};ce($r,{attr:nb,find:Zy,findOne:Qy});me($r,"Dom");fi=class extends $r{constructor(e,t){super(e,t),this.dom={},this.node.instance=this,e.hasAttribute("svgjs:data")&&this.setData(JSON.parse(e.getAttribute("svgjs:data"))||{})}center(e,t){return this.cx(e).cy(t)}cx(e){return e==null?this.x()+this.width()/2:this.x(e-this.width()/2)}cy(e){return e==null?this.y()+this.height()/2:this.y(e-this.height()/2)}defs(){let e=this.root();return e&&e.defs()}dmove(e,t){return this.dx(e).dy(t)}dx(e=0){return this.x(new fe(e).plus(this.x()))}dy(e=0){return this.y(new fe(e).plus(this.y()))}getEventHolder(){return this}height(e){return this.attr("height",e)}move(e,t){return this.x(e).y(t)}parents(e=this.root()){let t=typeof e=="string";t||(e=Mt(e));let r=new ar,n=this;for(;(n=n.parent())&&n.node!==xe.document&&n.nodeName!=="#document-fragment"&&(r.push(n),!(!t&&n.node===e.node||t&&n.matches(e)));)if(n.node===this.root().node)return null;return r}reference(e){if(e=this.attr(e),!e)return null;let t=(e+"").match(My);return t?Mt(t[1]):null}root(){let e=this.parent(ay(nc));return e&&e.root()}setData(e){return this.dom=e,this}size(e,t){let r=Ns(this,e,t);return this.width(new fe(r.width)).height(new fe(r.height))}width(e){return this.attr("width",e)}writeDataToDom(){return this.node.removeAttribute("svgjs:data"),Object.keys(this.dom).length&&this.node.setAttribute("svgjs:data",JSON.stringify(this.dom)),super.writeDataToDom()}x(e){return this.attr("x",e)}y(e){return this.attr("y",e)}};ce(fi,{bbox:Wy,rbox:Vy,inside:Xy,point:$y,ctm:jy,screenCTM:Gy});me(fi,"Element");Ba={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(i,e){return e==="color"?i:i+"-"+e}};["fill","stroke"].forEach(function(i){let e={},t;e[i]=function(r){if(typeof r>"u")return this.attr(i);if(typeof r=="string"||r instanceof ui||ui.isRgb(r)||r instanceof fi)this.attr(i,r);else for(t=Ba[i].length-1;t>=0;t--)r[Ba[i][t]]!=null&&this.attr(Ba.prefix(i,Ba[i][t]),r[Ba[i][t]]);return this},oe(["Element","Runner"],e)});oe(["Element","Runner"],{matrix:function(i,e,t,r,n,s){return i==null?new ue(this):this.attr("transform",new ue(i,e,t,r,n,s))},rotate:function(i,e,t){return this.transform({rotate:i,ox:e,oy:t},!0)},skew:function(i,e,t,r){return arguments.length===1||arguments.length===3?this.transform({skew:i,ox:e,oy:t},!0):this.transform({skew:[i,e],ox:t,oy:r},!0)},shear:function(i,e,t){return this.transform({shear:i,ox:e,oy:t},!0)},scale:function(i,e,t,r){return arguments.length===1||arguments.length===3?this.transform({scale:i,ox:e,oy:t},!0):this.transform({scale:[i,e],ox:t,oy:r},!0)},translate:function(i,e){return this.transform({translate:[i,e]},!0)},relative:function(i,e){return this.transform({relative:[i,e]},!0)},flip:function(i="both",e="center"){return"xybothtrue".indexOf(i)===-1&&(e=i,i="both"),this.transform({flip:i,origin:e},!0)},opacity:function(i){return this.attr("opacity",i)}});oe("radius",{radius:function(i,e=i){return(this._element||this).type==="radialGradient"?this.attr("r",new fe(i)):this.rx(i).ry(e)}});oe("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(i){return new Ye(this.node.getPointAtLength(i))}});oe(["Element","Runner"],{font:function(i,e){if(typeof i=="object"){for(e in i)this.font(e,i[e]);return this}return i==="leading"?this.leading(e):i==="anchor"?this.attr("text-anchor",e):i==="size"||i==="family"||i==="weight"||i==="stretch"||i==="variant"||i==="style"?this.attr("font-"+i,e):this.attr(i,e)}});sb=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].reduce(function(i,e){let t=function(r){return r===null?this.off(e):this.on(e,r),this};return i[e]=t,i},{});oe("Element",sb);oe("Element",{untransform:ab,matrixify:ob,toParent:lb,toRoot:hb,transform:db});Dt=class i extends fi{flatten(e=this,t){return this.each(function(){if(this instanceof i)return this.flatten().ungroup()}),this}ungroup(e=this.parent(),t=e.index(this)){return t=t===-1?e.children().length:t,this.each(function(r,n){return n[n.length-r-1].toParent(e,t)}),this.remove()}};me(Dt,"Container");Ua=class extends Dt{constructor(e,t=e){super(Ie("defs",e),t)}flatten(){return this}ungroup(){return this}};me(Ua,"Defs");Tt=class extends fi{};me(Tt,"Shape");cb={__proto__:null,rx:oc,ry:lc,x:xp,y:vp,cx:yp,cy:bp,width:wp,height:Mp},vs=class extends Tt{constructor(e,t=e){super(Ie("ellipse",e),t)}size(e,t){let r=Ns(this,e,t);return this.rx(new fe(r.width).divide(2)).ry(new fe(r.height).divide(2))}};ce(vs,cb);oe("Container",{ellipse:ze(function(i=0,e=i){return this.put(new vs).size(i,e).move(0,0)})});me(vs,"Ellipse");Ul=class extends $r{constructor(e=xe.document.createDocumentFragment()){super(e)}xml(e,t,r){if(typeof e=="boolean"&&(r=t,t=e,e=null),e==null||typeof e=="function"){let n=new $r(Ha("wrapper",r));return n.add(this.node.cloneNode(!0)),n.xml(!1,r)}return super.xml(e,!1,r)}};me(Ul,"Fragment");ub={__proto__:null,from:Tp,to:Np},Ln=class extends Dt{constructor(e,t){super(Ie(e+"Gradient",typeof e=="string"?null:e),t)}attr(e,t,r){return e==="transform"&&(e="gradientTransform"),super.attr(e,t,r)}bbox(){return new Rt}targets(){return Es("svg [fill*="+this.id()+"]")}toString(){return this.url()}update(e){return this.clear(),typeof e=="function"&&e.call(this,this),this}url(){return"url(#"+this.id()+")"}};ce(Ln,ub);oe({Container:{gradient(...i){return this.defs().gradient(...i)}},Defs:{gradient:ze(function(i,e){return this.put(new Ln(i)).update(e)})}});me(Ln,"Gradient");zn=class extends Dt{constructor(e,t=e){super(Ie("pattern",e),t)}attr(e,t,r){return e==="transform"&&(e="patternTransform"),super.attr(e,t,r)}bbox(){return new Rt}targets(){return Es("svg [fill*="+this.id()+"]")}toString(){return this.url()}update(e){return this.clear(),typeof e=="function"&&e.call(this,this),this}url(){return"url(#"+this.id()+")"}};oe({Container:{pattern(...i){return this.defs().pattern(...i)}},Defs:{pattern:ze(function(i,e,t){return this.put(new zn).update(t).attr({x:0,y:0,width:i,height:e,patternUnits:"userSpaceOnUse"})})}});me(zn,"Pattern");Ci=class extends Tt{constructor(e,t=e){super(Ie("image",e),t)}load(e,t){if(!e)return this;let r=new xe.window.Image;return Xd(r,"load",function(n){let s=this.parent(zn);this.width()===0&&this.height()===0&&this.size(r.width,r.height),s instanceof zn&&s.width()===0&&s.height()===0&&s.size(this.width(),this.height()),typeof t=="function"&&t.call(this,n)},this),Xd(r,"load error",function(){gs(r)}),this.attr("href",r.src=e,Ja)}};rb(function(i,e,t){return(i==="fill"||i==="stroke")&&Ey.test(e)&&(e=t.root().defs().image(e)),e instanceof Ci&&(e=t.root().defs().pattern(0,0,r=>{r.add(e)})),e});oe({Container:{image:ze(function(i,e){return this.put(new Ci).size(0,0).load(i,e)})}});me(Ci,"Image");Hi=class extends Ur{bbox(){let e=-1/0,t=-1/0,r=1/0,n=1/0;return this.forEach(function(s){e=Math.max(s[0],e),t=Math.max(s[1],t),r=Math.min(s[0],r),n=Math.min(s[1],n)}),new Rt(r,n,e-r,t-n)}move(e,t){let r=this.bbox();if(e-=r.x,t-=r.y,!isNaN(e)&&!isNaN(t))for(let n=this.length-1;n>=0;n--)this[n]=[this[n][0]+e,this[n][1]+t];return this}parse(e=[0,0]){let t=[];e instanceof Array?e=Array.prototype.concat.apply([],e):e=e.trim().split(lr).map(parseFloat),e.length%2!==0&&e.pop();for(let r=0,n=e.length;r=0;r--)n.width&&(this[r][0]=(this[r][0]-n.x)*e/n.width+n.x),n.height&&(this[r][1]=(this[r][1]-n.y)*t/n.height+n.y);return this}toLine(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}}toString(){let e=[];for(let t=0,r=this.length;t":function(i){return-Math.cos(i*Math.PI)/2+.5},">":function(i){return Math.sin(i*Math.PI/2)},"<":function(i){return-Math.cos(i*Math.PI/2)+1},bezier:function(i,e,t,r){return function(n){return n<0?i>0?e/i*n:t>0?r/t*n:0:n>1?t<1?(1-r)/(1-t)*n+(r-t)/(1-t):i<1?(1-e)/(1-i)*n+(e-i)/(1-i):1:3*n*(1-n)**2*e+3*n**2*(1-n)*r+n**3}},steps:function(i,e="end"){e=e.split("-").reverse()[0];let t=i;return e==="none"?--t:e==="both"&&++t,(r,n=!1)=>{let s=Math.floor(r*i),a=r*s%1===0;return(e==="start"||e==="both")&&++s,n&&a&&--s,r>=0&&s<0&&(s=0),r<=1&&s>t&&(s=t),s/t}}},$a=class{done(){return!1}},ja=class extends $a{constructor(e=Pa.ease){super(),this.ease=vb[e]||e}step(e,t,r){return typeof e!="number"?r<1?e:t:e+(t-e)*this.ease(r)}},bs=class extends $a{constructor(e){super(),this.stepper=e}done(e){return e.done}step(e,t,r,n){return this.stepper(e,t,r,n)}};Kd=class extends bs{constructor(e=500,t=0){super(),this.duration(e).overshoot(t)}step(e,t,r,n){if(typeof e=="string")return e;if(n.done=r===1/0,r===1/0)return t;if(r===0)return e;r>100&&(r=16),r/=1e3;let s=n.velocity||0,a=-this.d*s-this.k*(e-t),o=e+s*r+a*r*r/2;return n.velocity=s+a*r,n.done=Math.abs(t-o)+Math.abs(s)<.002,n.done?t:o}};ce(Kd,{duration:xs("_duration",sp),overshoot:xs("_overshoot",sp)});Zd=class extends bs{constructor(e=.1,t=.01,r=0,n=1e3){super(),this.p(e).i(t).d(r).windup(n)}step(e,t,r,n){if(typeof e=="string")return e;if(n.done=r===1/0,r===1/0)return t;if(r===0)return e;let s=t-e,a=(n.integral||0)+s*r,o=(s-(n.error||0))/r,l=this._windup;return l!==!1&&(a=Math.max(-l,Math.min(a,l))),n.error=s,n.integral=a,n.done=Math.abs(s)<.001,n.done?t:e+(this.P*s+this.I*a+this.D*o)}};ce(Zd,{windup:xs("_windup"),p:xs("P"),i:xs("I"),d:xs("D")});yb={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},Qd={M:function(i,e,t){return e.x=t.x=i[0],e.y=t.y=i[1],["M",e.x,e.y]},L:function(i,e){return e.x=i[0],e.y=i[1],["L",i[0],i[1]]},H:function(i,e){return e.x=i[0],["H",i[0]]},V:function(i,e){return e.y=i[0],["V",i[0]]},C:function(i,e){return e.x=i[4],e.y=i[5],["C",i[0],i[1],i[2],i[3],i[4],i[5]]},S:function(i,e){return e.x=i[2],e.y=i[3],["S",i[0],i[1],i[2],i[3]]},Q:function(i,e){return e.x=i[2],e.y=i[3],["Q",i[0],i[1],i[2],i[3]]},T:function(i,e){return e.x=i[0],e.y=i[1],["T",i[0],i[1]]},Z:function(i,e,t){return e.x=t.x,e.y=t.y,["Z"]},A:function(i,e){return e.x=i[5],e.y=i[6],["A",i[0],i[1],i[2],i[3],i[4],i[5],i[6]]}},Yd="mlhvqtcsaz".split("");for(let i=0,e=Yd.length;i=0;s--)n=this[s][0],n==="M"||n==="L"||n==="T"?(this[s][1]+=e,this[s][2]+=t):n==="H"?this[s][1]+=e:n==="V"?this[s][1]+=t:n==="C"||n==="S"||n==="Q"?(this[s][1]+=e,this[s][2]+=t,this[s][3]+=e,this[s][4]+=t,n==="C"&&(this[s][5]+=e,this[s][6]+=t)):n==="A"&&(this[s][6]+=e,this[s][7]+=t);return this}parse(e="M0 0"){return Array.isArray(e)&&(e=Array.prototype.concat.apply([],e).toString()),Nb(e)}size(e,t){let r=this.bbox(),n,s;for(r.width=r.width===0?1:r.width,r.height=r.height===0?1:r.height,n=this.length-1;n>=0;n--)s=this[n][0],s==="M"||s==="L"||s==="T"?(this[n][1]=(this[n][1]-r.x)*e/r.width+r.x,this[n][2]=(this[n][2]-r.y)*t/r.height+r.y):s==="H"?this[n][1]=(this[n][1]-r.x)*e/r.width+r.x:s==="V"?this[n][1]=(this[n][1]-r.y)*t/r.height+r.y:s==="C"||s==="S"||s==="Q"?(this[n][1]=(this[n][1]-r.x)*e/r.width+r.x,this[n][2]=(this[n][2]-r.y)*t/r.height+r.y,this[n][3]=(this[n][3]-r.x)*e/r.width+r.x,this[n][4]=(this[n][4]-r.y)*t/r.height+r.y,s==="C"&&(this[n][5]=(this[n][5]-r.x)*e/r.width+r.x,this[n][6]=(this[n][6]-r.y)*t/r.height+r.y)):s==="A"&&(this[n][1]=this[n][1]*e/r.width,this[n][2]=this[n][2]*t/r.height,this[n][6]=(this[n][6]-r.x)*e/r.width+r.x,this[n][7]=(this[n][7]-r.y)*t/r.height+r.y);return this}toString(){return Eb(this)}},Ep=i=>{let e=typeof i;return e==="number"?fe:e==="string"?ui.isColor(i)?ui:lr.test(i)?sc.test(i)?or:Ur:cp.test(i)?fe:Ga:dc.indexOf(i.constructor)>-1?i.constructor:Array.isArray(i)?Ur:e==="object"?Rn:Ga},sr=class{constructor(e){this._stepper=e||new ja("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}at(e){return this._morphObj.morph(this._from,this._to,e,this._stepper,this._context)}done(){return this._context.map(this._stepper.done).reduce(function(t,r){return t&&r},!0)}from(e){return e==null?this._from:(this._from=this._set(e),this)}stepper(e){return e==null?this._stepper:(this._stepper=e,this)}to(e){return e==null?this._to:(this._to=this._set(e),this)}type(e){return e==null?this._type:(this._type=e,this)}_set(e){this._type||this.type(Ep(e));let t=new this._type(e);return this._type===ui&&(t=this._to?t[this._to[4]]():this._from?t[this._from[4]]():t),this._type===Rn&&(t=this._to?t.align(this._to):this._from?t.align(this._from):t),t=t.toConsumable(),this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(t.length)).map(Object).map(function(r){return r.done=!0,r}),t}},Ga=class{constructor(...e){this.init(...e)}init(e){return e=Array.isArray(e)?e[0]:e,this.value=e,this}toArray(){return[this.value]}valueOf(){return this.value}},Ya=class i{constructor(...e){this.init(...e)}init(e){return Array.isArray(e)&&(e={scaleX:e[0],scaleY:e[1],shear:e[2],rotate:e[3],translateX:e[4],translateY:e[5],originX:e[6],originY:e[7]}),Object.assign(this,i.defaults,e),this}toArray(){let e=this;return[e.scaleX,e.scaleY,e.shear,e.rotate,e.translateX,e.translateY,e.originX,e.originY]}};Ya.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};Sb=(i,e)=>i[0]e[0]?1:0,Rn=class{constructor(...e){this.init(...e)}align(e){let t=this.values;for(let r=0,n=t.length;rr.concat(n),[]),this}toArray(){return this.values}valueOf(){let e={},t=this.values;for(;t.length;){let r=t.shift(),n=t.shift(),s=t.shift(),a=t.splice(0,s);e[r]=new n(a)}return e}},dc=[Ga,Ya,Rn];Ui=class extends Tt{constructor(e,t=e){super(Ie("path",e),t)}array(){return this._array||(this._array=new or(this.attr("d")))}clear(){return delete this._array,this}height(e){return e==null?this.bbox().height:this.size(this.bbox().width,e)}move(e,t){return this.attr("d",this.array().move(e,t))}plot(e){return e==null?this.array():this.clear().attr("d",typeof e=="string"?e:this._array=new or(e))}size(e,t){let r=Ns(this,e,t);return this.attr("d",this.array().size(r.width,r.height))}width(e){return e==null?this.bbox().width:this.size(e,this.bbox().height)}x(e){return e==null?this.bbox().x:this.move(e,this.bbox().y)}y(e){return e==null?this.bbox().y:this.move(this.bbox().x,e)}};Ui.prototype.MorphArray=or;oe({Container:{path:ze(function(i){return this.put(new Ui).plot(i||new or)})}});me(Ui,"Path");Sp={__proto__:null,array:Cb,clear:_b,move:Lb,plot:zb,size:Ib},_i=class extends Tt{constructor(e,t=e){super(Ie("polygon",e),t)}};oe({Container:{polygon:ze(function(i){return this.put(new _i).plot(i||new Hi)})}});ce(_i,hc);ce(_i,Sp);me(_i,"Polygon");Dn=class extends Tt{constructor(e,t=e){super(Ie("polyline",e),t)}};oe({Container:{polyline:ze(function(i){return this.put(new Dn).plot(i||new Hi)})}});ce(Dn,hc);ce(Dn,Sp);me(Dn,"Polyline");Pe=class extends Tt{constructor(e,t=e){super(Ie("rect",e),t)}};ce(Pe,{rx:oc,ry:lc});oe({Container:{rect:ze(function(i,e){return this.put(new Pe).size(i,e)})}});me(Pe,"Rect");Fa=class{constructor(){this._first=null,this._last=null}first(){return this._first&&this._first.value}last(){return this._last&&this._last.value}push(e){let t=typeof e.next<"u"?e:{value:e,next:null,prev:null};return this._last?(t.prev=this._last,this._last.next=t,this._last=t):(this._last=t,this._first=t),t}remove(e){e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this._last&&(this._last=e.prev),e===this._first&&(this._first=e.next),e.prev=null,e.next=null}shift(){let e=this._first;return e?(this._first=e.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,e.value):null}},we={nextDraw:null,frames:new Fa,timeouts:new Fa,immediates:new Fa,timer:()=>xe.window.performance||xe.window.Date,transforms:[],frame(i){let e=we.frames.push({run:i});return we.nextDraw===null&&(we.nextDraw=xe.window.requestAnimationFrame(we._draw)),e},timeout(i,e){e=e||0;let t=we.timer().now()+e,r=we.timeouts.push({run:i,time:t});return we.nextDraw===null&&(we.nextDraw=xe.window.requestAnimationFrame(we._draw)),r},immediate(i){let e=we.immediates.push(i);return we.nextDraw===null&&(we.nextDraw=xe.window.requestAnimationFrame(we._draw)),e},cancelFrame(i){i!=null&&we.frames.remove(i)},clearTimeout(i){i!=null&&we.timeouts.remove(i)},cancelImmediate(i){i!=null&&we.immediates.remove(i)},_draw(i){let e=null,t=we.timeouts.last();for(;(e=we.timeouts.shift())&&(i>=e.time?e.run():we.timeouts.push(e),e!==t););let r=null,n=we.frames.last();for(;r!==n&&(r=we.frames.shift());)r.run(i);let s=null;for(;s=we.immediates.shift();)s();we.nextDraw=we.timeouts.first()||we.frames.first()?xe.window.requestAnimationFrame(we._draw):null}},Rb=function(i){let e=i.start,t=i.runner.duration(),r=e+t;return{start:e,duration:t,end:r,runner:i.runner}},Db=function(){let i=xe.window;return(i.performance||i.Date).now()},$l=class extends _n{constructor(e=Db){super(),this._timeSource=e,this._startTime=0,this._speed=1,this._persist=0,this._nextFrame=null,this._paused=!0,this._runners=[],this._runnerIds=[],this._lastRunnerId=-1,this._time=0,this._lastSourceTime=0,this._lastStepTime=0,this._step=this._stepFn.bind(this,!1),this._stepImmediate=this._stepFn.bind(this,!0)}active(){return!!this._nextFrame}finish(){return this.time(this.getEndTimeOfTimeline()+1),this.pause()}getEndTime(){let e=this.getLastRunnerInfo(),t=e?e.runner.duration():0;return(e?e.start:this._time)+t}getEndTimeOfTimeline(){let e=this._runners.map(t=>t.start+t.runner.duration());return Math.max(0,...e)}getLastRunnerInfo(){return this.getRunnerInfoById(this._lastRunnerId)}getRunnerInfoById(e){return this._runners[this._runnerIds.indexOf(e)]||null}pause(){return this._paused=!0,this._continue()}persist(e){return e==null?this._persist:(this._persist=e,this)}play(){return this._paused=!1,this.updateTime()._continue()}reverse(e){let t=this.speed();if(e==null)return this.speed(-t);let r=Math.abs(t);return this.speed(e?-r:r)}schedule(e,t,r){if(e==null)return this._runners.map(Rb);let n=0,s=this.getEndTime();if(t=t||0,r==null||r==="last"||r==="after")n=s;else if(r==="absolute"||r==="start")n=t,t=0;else if(r==="now")n=this._time;else if(r==="relative"){let l=this.getRunnerInfoById(e.id);l&&(n=l.start+t,t=0)}else if(r==="with-last"){let l=this.getLastRunnerInfo();n=l?l.start:this._time}else throw new Error('Invalid value for the "when" parameter');e.unschedule(),e.timeline(this);let a=e.persist(),o={persist:a===null?this._persist:a,start:n+t,runner:e};return this._lastRunnerId=e.id,this._runners.push(o),this._runners.sort((l,h)=>l.start-h.start),this._runnerIds=this._runners.map(l=>l.runner.id),this.updateTime()._continue(),this}seek(e){return this.time(this._time+e)}source(e){return e==null?this._timeSource:(this._timeSource=e,this)}speed(e){return e==null?this._speed:(this._speed=e,this)}stop(){return this.time(0),this.pause()}time(e){return e==null?this._time:(this._time=e,this._continue(!0))}unschedule(e){let t=this._runnerIds.indexOf(e.id);return t<0?this:(this._runners.splice(t,1),this._runnerIds.splice(t,1),e.timeline(null),this)}updateTime(){return this.active()||(this._lastSourceTime=this._timeSource()),this}_continue(e=!1){return we.cancelFrame(this._nextFrame),this._nextFrame=null,e?this._stepImmediate():this._paused?this:(this._nextFrame=we.frame(this._step),this)}_stepFn(e=!1){let t=this._timeSource(),r=t-this._lastSourceTime;e&&(r=0);let n=this._speed*r+(this._time-this._lastStepTime);this._lastSourceTime=t,e||(this._time+=n,this._time=this._time<0?0:this._time),this._lastStepTime=this._time,this.fire("time",this._time);for(let a=this._runners.length;a--;){let o=this._runners[a],l=o.runner;this._time-o.start<=0&&l.reset()}let s=!1;for(let a=0,o=this._runners.length;a0?this._continue():(this.pause(),this.fire("finished")),this}};oe({Element:{timeline:function(i){return i==null?(this._timeline=this._timeline||new $l,this._timeline):(this._timeline=i,this)}}});Li=class i extends _n{constructor(e){super(),this.id=i.id++,e=e??Pa.duration,e=typeof e=="function"?new bs(e):e,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration=typeof e=="number"&&e,this._isDeclarative=e instanceof bs,this._stepper=this._isDeclarative?e:new ja,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new ue,this.transformId=1,this._haveReversed=!1,this._reverse=!1,this._loopsDone=0,this._swing=!1,this._wait=0,this._times=1,this._frameId=null,this._persist=this._isDeclarative?!0:null}static sanitise(e,t,r){let n=1,s=!1,a=0;return e=e||Pa.duration,t=t||Pa.delay,r=r||"last",typeof e=="object"&&!(e instanceof $a)&&(t=e.delay||t,r=e.when||r,s=e.swing||s,n=e.times||n,a=e.wait||a,e=e.duration||Pa.duration),{duration:e,delay:t,swing:s,times:n,wait:a,when:r}}active(e){return e==null?this.enabled:(this.enabled=e,this)}addTransform(e,t){return this.transforms.lmultiplyO(e),this}after(e){return this.on("finished",e)}animate(e,t,r){let n=i.sanitise(e,t,r),s=new i(n.duration);return this._timeline&&s.timeline(this._timeline),this._element&&s.element(this._element),s.loop(n).schedule(n.delay,n.when)}clearTransform(){return this.transforms=new ue,this}clearTransformsFromQueue(){(!this.done||!this._timeline||!this._timeline._runnerIds.includes(this.id))&&(this._queue=this._queue.filter(e=>!e.isTransform))}delay(e){return this.animate(0,e)}duration(){return this._times*(this._wait+this._duration)-this._wait}during(e){return this.queue(null,e)}ease(e){return this._stepper=new ja(e),this}element(e){return e==null?this._element:(this._element=e,e._prepareRunner(),this)}finish(){return this.step(1/0)}loop(e,t,r){return typeof e=="object"&&(t=e.swing,r=e.wait,e=e.times),this._times=e||1/0,this._swing=t||!1,this._wait=r||0,this._times===!0&&(this._times=1/0),this}loops(e){let t=this._duration+this._wait;if(e==null){let a=Math.floor(this._time/t),l=(this._time-a*t)/this._duration;return Math.min(a+l,this._times)}let r=Math.floor(e),n=e%1,s=t*r+this._duration*n;return this.time(s)}persist(e){return e==null?this._persist:(this._persist=e,this)}position(e){let t=this._time,r=this._duration,n=this._wait,s=this._times,a=this._swing,o=this._reverse,l;if(e==null){let f=function(g){let x=a*Math.floor(g%(2*(n+r))/(n+r)),v=x&&!o||!x&&o,b=Math.pow(-1,v)*(g%(n+r))/r+v;return Math.max(Math.min(b,1),0)},m=s*(n+r)-n;return l=t<=0?Math.round(f(1e-5)):t=0;this._lastPosition=t;let n=this.duration(),s=this._lastTime<=0&&this._time>0,a=this._lastTime=n;this._lastTime=this._time,s&&this.fire("start",this);let o=this._isDeclarative;this.done=!o&&!a&&this._time>=n,this._reseted=!1;let l=!1;return(r||o)&&(this._initialise(r),this.transforms=new ue,l=this._run(o?e:t),this.fire("step",this)),this.done=this.done||l&&o,a&&this.fire("finished",this),this}time(e){if(e==null)return this._time;let t=e-this._time;return this.step(t),this}timeline(e){return typeof e>"u"?this._timeline:(this._timeline=e,this)}unschedule(){let e=this.timeline();return e&&e.unschedule(this),this}_initialise(e){if(!(!e&&!this._isDeclarative))for(let t=0,r=this._queue.length;ti.lmultiplyO(e),kp=i=>i.transforms;tc=class{constructor(){this.runners=[],this.ids=[]}add(e){if(this.runners.includes(e))return;let t=e.id+1;return this.runners.push(e),this.ids.push(t),this}clearBefore(e){let t=this.ids.indexOf(e+1)||1;return this.ids.splice(0,t,0),this.runners.splice(0,t,new ws).forEach(r=>r.clearTransformsFromQueue()),this}edit(e,t){let r=this.ids.indexOf(e+1);return this.ids.splice(r,1,e+1),this.runners.splice(r,1,t),this}getByID(e){return this.runners[this.ids.indexOf(e+1)]}length(){return this.ids.length}merge(){let e=null;for(let t=0;te.id<=i.id).map(kp).reduce(Ap,new ue)},_addRunner(i){this._transformationRunners.add(i),we.cancelImmediate(this._frameId),this._frameId=we.immediate(Ob.bind(this))},_prepareRunner(){this._frameId==null&&(this._transformationRunners=new tc().add(new ws(new ue(this))))}}});Bb=(i,e)=>i.filter(t=>!e.includes(t));ce(Li,{attr(i,e){return this.styleAttr("attr",i,e)},css(i,e){return this.styleAttr("css",i,e)},styleAttr(i,e,t){if(typeof e=="string")return this.styleAttr(i,{[e]:t});let r=e;if(this._tryRetarget(i,r))return this;let n=new sr(this._stepper).to(r),s=Object.keys(r);return this.queue(function(){n=n.from(this.element()[i](s))},function(a){return this.element()[i](n.at(a).valueOf()),n.done()},function(a){let o=Object.keys(a),l=Bb(o,s);if(l.length){let d=this.element()[i](l),c=new Rn(n.from()).valueOf();Object.assign(c,d),n.from(c)}let h=new Rn(n.to()).valueOf();Object.assign(h,a),n.to(h),s=o,r=a}),this._rememberMorpher(i,n),this},zoom(i,e){if(this._tryRetarget("zoom",i,e))return this;let t=new sr(this._stepper).to(new fe(i));return this.queue(function(){t=t.from(this.element().zoom())},function(r){return this.element().zoom(t.at(r),e),t.done()},function(r,n){e=n,t.to(r)}),this._rememberMorpher("zoom",t),this},transform(i,e,t){if(e=i.relative||e,this._isDeclarative&&!e&&this._tryRetarget("transform",i))return this;let r=ue.isMatrixLike(i);t=i.affine!=null?i.affine:t??!r;let n=new sr(this._stepper).type(t?Ya:ue),s,a,o,l,h;function d(){a=a||this.element(),s=s||Vd(i,a),h=new ue(e?void 0:a),a._addRunner(this),e||a._clearTransformRunnersBefore(this)}function c(m){e||this.clearTransform();let{x:g,y:x}=new Ye(s).transform(a._currentTransform(this)),v=new ue({...i,origin:[g,x]}),b=this._isDeclarative&&o?o:h;if(t){v=v.decompose(g,x),b=b.decompose(g,x);let S=v.rotate,C=b.rotate,_=[S-360,S,S+360],I=_.map($=>Math.abs($-C)),O=Math.min(...I),D=I.indexOf(O);v.rotate=_[D]}e&&(r||(v.rotate=i.rotate||0),this._isDeclarative&&l&&(b.rotate=l)),n.from(b),n.to(v);let E=n.at(m);return l=E.rotate,o=new ue(E),this.addTransform(o),a._addRunner(this),n.done()}function f(m){(m.origin||"center").toString()!==(i.origin||"center").toString()&&(s=Vd(m,a)),i={...m,origin:s}}return this.queue(d,c,f,!0),this._isDeclarative&&this._rememberMorpher("transform",n),this},x(i,e){return this._queueNumber("x",i)},y(i){return this._queueNumber("y",i)},dx(i=0){return this._queueNumberDelta("x",i)},dy(i=0){return this._queueNumberDelta("y",i)},dmove(i,e){return this.dx(i).dy(e)},_queueNumberDelta(i,e){if(e=new fe(e),this._tryRetarget(i,e))return this;let t=new sr(this._stepper).to(e),r=null;return this.queue(function(){r=this.element()[i](),t.from(r),t.to(r+e)},function(n){return this.element()[i](t.at(n)),t.done()},function(n){t.to(r+new fe(n))}),this._rememberMorpher(i,t),this},_queueObject(i,e){if(this._tryRetarget(i,e))return this;let t=new sr(this._stepper).to(e);return this.queue(function(){t.from(this.element()[i]())},function(r){return this.element()[i](t.at(r)),t.done()}),this._rememberMorpher(i,t),this},_queueNumber(i,e){return this._queueObject(i,new fe(e))},cx(i){return this._queueNumber("cx",i)},cy(i){return this._queueNumber("cy",i)},move(i,e){return this.x(i).y(e)},center(i,e){return this.cx(i).cy(e)},size(i,e){let t;return(!i||!e)&&(t=this._element.bbox()),i||(i=t.width/t.height*e),e||(e=t.height/t.width*i),this.width(i).height(e)},width(i){return this._queueNumber("width",i)},height(i){return this._queueNumber("height",i)},plot(i,e,t,r){if(arguments.length===4)return this.plot([i,e,t,r]);if(this._tryRetarget("plot",i))return this;let n=new sr(this._stepper).type(this._element.MorphArray).to(i);return this.queue(function(){n.from(this._element.array())},function(s){return this._element.plot(n.at(s)),n.done()}),this._rememberMorpher("plot",n),this},leading(i){return this._queueNumber("leading",i)},viewbox(i,e,t,r){return this._queueObject("viewbox",new Rt(i,e,t,r))},update(i){return typeof i!="object"?this.update({offset:arguments[0],color:arguments[1],opacity:arguments[2]}):(i.opacity!=null&&this.attr("stop-opacity",i.opacity),i.color!=null&&this.attr("stop-color",i.color),i.offset!=null&&this.attr("offset",i.offset),this)}});ce(Li,{rx:oc,ry:lc,from:Tp,to:Np});me(Li,"Runner");Wa=class extends Dt{constructor(e,t=e){super(Ie("svg",e),t),this.namespace()}defs(){return this.isRoot()?ci(this.node.querySelector("defs"))||this.put(new Ua):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof xe.window.SVGElement)&&this.node.parentNode.nodeName!=="#document-fragment"}namespace(){return this.isRoot()?this.attr({xmlns:rc,version:"1.1"}).attr("xmlns:xlink",Ja,Hl).attr("xmlns:svgjs",sy,Hl):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,Hl).attr("xmlns:svgjs",null,Hl)}root(){return this.isRoot()?this:super.root()}};oe({Container:{nested:ze(function(){return this.put(new Wa)})}});me(Wa,"Svg",!0);Va=class extends Dt{constructor(e,t=e){super(Ie("symbol",e),t)}};oe({Container:{symbol:ze(function(){return this.put(new Va)})}});me(Va,"Symbol");Cp={__proto__:null,plain:Pb,length:Fb,x:qb,y:Hb,move:Ub,cx:$b,cy:jb,center:Gb,ax:Yb,ay:Wb,amove:Vb,build:Xb},Te=class extends Tt{constructor(e,t=e){super(Ie("text",e),t),this.dom.leading=new fe(1.3),this._rebuild=!0,this._build=!1}leading(e){return e==null?this.dom.leading:(this.dom.leading=new fe(e),this.rebuild())}rebuild(e){if(typeof e=="boolean"&&(this._rebuild=e),this._rebuild){let t=this,r=0,n=this.dom.leading;this.each(function(s){let a=xe.window.getComputedStyle(this.node).getPropertyValue("font-size"),o=n*new fe(a);this.dom.newLined&&(this.attr("x",t.attr("x")),this.text()===` -`?r+=o:(this.attr("dy",s?o+r:0),r=0))}),this.fire("rebuild")}return this}setData(e){return this.dom=e,this.dom.leading=new fe(e.leading||1.3),this}text(e){if(e===void 0){let t=this.node.childNodes,r=0;e="";for(let n=0,s=t.length;n{mo.prototype.init_genrand=function(i){for(this.mt[0]=i>>>0,this.mti=1;this.mti>>30,this.mt[this.mti]=(((i&4294901760)>>>16)*1812433253<<16)+(i&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0};mo.prototype.genrand_int32=function(){var i,e=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var t;for(this.mti==this.N+1&&this.init_genrand(5489),t=0;t>>1^e[i&1];for(;t>>1^e[i&1];i=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^i>>>1^e[i&1],this.mti=0}return i=this.mt[this.mti++],i^=i>>>11,i^=i<<7&2636928640,i^=i<<15&4022730752,i^=i>>>18,i>>>0}});function fe(i,e){if(Array.isArray(i)){for(let t of i)fe(t,e);return}if(typeof i=="object"){for(let t in i)fe(t,i[t]);return}q3(Object.getOwnPropertyNames(e)),Yc[i]=Object.assign(Yc[i]||{},e)}function Wt(i){return Yc[i]||{}}function gw(){return[...new Set(F3)]}function q3(i){F3.push(...i)}function ru(i,e){let t,r=i.length,n=[];for(t=0;t=0;e--)$3(i.children[e]);return i.id&&(i.id=U3(i.nodeName)),i}function ge(i,e){let t,r;for(i=Array.isArray(i)?i:[i],r=i.length-1;r>=0;r--)for(t in e)i[r].prototype[t]=e[t]}function Fe(i){return function(...e){let t=e[e.length-1];return t&&t.constructor===Object&&!(t instanceof Array)?i.apply(this,e.slice(0,-1)).attr(t):i.apply(this,e)}}function Tw(){return this.parent().children()}function Nw(){return this.parent().index(this)}function Ew(){return this.siblings()[this.position()+1]}function Sw(){return this.siblings()[this.position()-1]}function Aw(){let i=this.position();return this.parent().add(this.remove(),i+1),this}function kw(){let i=this.position();return this.parent().add(this.remove(),i?i-1:0),this}function Cw(){return this.parent().add(this.remove()),this}function _w(){return this.parent().add(this.remove(),0),this}function Lw(i){i=Rt(i),i.remove();let e=this.position();return this.parent().add(i,e),this}function Iw(i){i=Rt(i),i.remove();let e=this.position();return this.parent().add(i,e+1),this}function zw(i){return i=Rt(i),i.before(this),this}function Rw(i){return i=Rt(i),i.after(this),this}function Hw(){let i=this.attr("class");return i==null?[]:i.trim().split(Sr)}function Uw(i){return this.classes().indexOf(i)!==-1}function $w(i){if(!this.hasClass(i)){let e=this.classes();e.push(i),this.attr("class",e.join(" "))}return this}function jw(i){return this.hasClass(i)&&this.attr("class",this.classes().filter(function(e){return e!==i}).join(" ")),this}function Gw(i){return this.hasClass(i)?this.removeClass(i):this.addClass(i)}function Vw(i,e){let t={};if(arguments.length===0)return this.node.style.cssText.split(/\s*;\s*/).filter(function(r){return!!r.length}).forEach(function(r){let n=r.split(/\s*:\s*/);t[n[0]]=n[1]}),t;if(arguments.length<2){if(Array.isArray(i)){for(let r of i){let n=C0(r);t[r]=this.node.style[n]}return t}if(typeof i=="string")return this.node.style[C0(i)];if(typeof i=="object")for(let r in i)this.node.style[C0(r)]=i[r]==null||D3.test(i[r])?"":i[r]}return arguments.length===2&&(this.node.style[C0(i)]=e==null||D3.test(e)?"":e),this}function Ww(){return this.css("display","")}function Yw(){return this.css("display","none")}function Xw(){return this.css("display")!=="none"}function Kw(i,e,t){if(i==null)return this.data(ru(xw(this.node.attributes,r=>r.nodeName.indexOf("data-")===0),r=>r.nodeName.slice(5)));if(i instanceof Array){let r={};for(let n of i)r[n]=this.data(n);return r}else if(typeof i=="object")for(e in i)this.data(e,i[e]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+i))}catch{return this.attr("data-"+i)}else this.attr("data-"+i,e===null?null:t===!0||typeof e=="string"||typeof e=="number"?e:JSON.stringify(e));return this}function Zw(i,e){if(typeof arguments[0]=="object")for(let t in i)this.remember(t,i[t]);else{if(arguments.length===1)return this.memory()[i];this.memory()[i]=e}return this}function Qw(){if(arguments.length===0)this._memory={};else for(let i=arguments.length-1;i>=0;i--)delete this.memory()[arguments[i]];return this}function Jw(){return this._memory=this._memory||{}}function eM(i){return i.length===4?["#",i.substring(1,2),i.substring(1,2),i.substring(2,3),i.substring(2,3),i.substring(3,4),i.substring(3,4)].join(""):i}function tM(i){let e=Math.round(i),r=Math.max(0,Math.min(255,e)).toString(16);return r.length===1?"0"+r:r}function Gs(i,e){for(let t=e.length;t--;)if(i[e[t]]==null)return!1;return!0}function iM(i,e){let t=Gs(i,"rgb")?{_a:i.r,_b:i.g,_c:i.b,_d:0,space:"rgb"}:Gs(i,"xyz")?{_a:i.x,_b:i.y,_c:i.z,_d:0,space:"xyz"}:Gs(i,"hsl")?{_a:i.h,_b:i.s,_c:i.l,_d:0,space:"hsl"}:Gs(i,"lab")?{_a:i.l,_b:i.a,_c:i.b,_d:0,space:"lab"}:Gs(i,"lch")?{_a:i.l,_b:i.c,_c:i.h,_d:0,space:"lch"}:Gs(i,"cmyk")?{_a:i.c,_b:i.m,_c:i.y,_d:i.k,space:"cmyk"}:{_a:0,_b:0,_c:0,space:"rgb"};return t.space=e||t.space,t}function rM(i){return i==="lab"||i==="xyz"||i==="lch"}function Vc(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*(2/3-t)*6:i}function nM(i,e){return new it(i,e).transformO(this.screenCTM().inverseO())}function Vs(i,e,t){return Math.abs(e-i)<(t||1e-6)}function sM(){return new xe(this.node.getCTM())}function aM(){if(typeof this.isRoot=="function"&&!this.isRoot()){let i=this.rect(1,1),e=i.node.getScreenCTM();return i.remove(),new xe(e)}return new xe(this.node.getScreenCTM())}function ln(){if(!ln.nodes){let i=Rt().size(2,0);i.node.style.cssText=["opacity: 0","position: absolute","left: -100%","top: -100%","overflow: hidden"].join(";"),i.attr("focusable","false"),i.attr("aria-hidden","true");let e=i.path().node;ln.nodes={svg:i,path:e}}if(!ln.nodes.svg.node.parentNode){let i=Te.document.body||Te.document.documentElement;ln.nodes.svg.addTo(i)}return ln.nodes}function G3(i){return!i.width&&!i.height&&!i.x&&!i.y}function oM(i){return i===Te.document||(Te.document.documentElement.contains||function(e){for(;e.parentNode;)e=e.parentNode;return e===Te.document}).call(Te.document.documentElement,i)}function V3(i,e,t){let r;try{if(r=e(i.node),G3(r)&&!oM(i.node))throw new Error("Element not in the dom")}catch{r=t(i)}return r}function lM(){let t=V3(this,n=>n.getBBox(),n=>{try{let s=n.clone().addTo(ln().svg).show(),a=s.node.getBBox();return s.remove(),a}catch(s){throw new Error(`Getting bbox of element "${n.node.nodeName}" is not possible: ${s.toString()}`)}});return new Gt(t)}function hM(i){let r=V3(this,s=>s.getBoundingClientRect(),s=>{throw new Error(`Getting rbox of element "${s.node.nodeName}" is not possible`)}),n=new Gt(r);return i?n.transform(i.screenCTM().inverseO()):n.addOffset()}function dM(i,e){let t=this.bbox();return i>t.x&&e>t.y&&i(r[n]=this.attr(n),r),{});if(typeof i=="object"&&i.constructor===Object)for(e in i)this.attr(e,i[e]);else if(e===null)this.node.removeAttribute(i);else{if(e==null)return e=this.node.getAttribute(i),e==null?xM[i]:O3.test(e)?parseFloat(e):e;e=X3.reduce((r,n)=>n(i,r,this),e),typeof e=="number"?e=new ye(e):Ni.isColor(e)?e=new Ni(e):e.constructor===Array&&(e=new hn(e)),i==="leading"?this.leading&&this.leading(e):typeof t=="string"?this.node.setAttributeNS(t,i,e.toString()):this.node.setAttribute(i,e.toString()),this.rebuild&&(i==="font-size"||i==="x")&&this.rebuild()}}return this}function wM(){return this.attr("transform",null)}function MM(){return(this.attr("transform")||"").split(Pw).slice(0,-1).map(function(e){let t=e.trim().split("(");return[t[0],t[1].split(Sr).map(function(r){return parseFloat(r)})]}).reverse().reduce(function(e,t){return t[0]==="matrix"?e.lmultiply(xe.fromArray(t[1])):e[t[0]].apply(e,t[1])},new xe)}function TM(i,e){if(this===i)return this;let t=this.screenCTM(),r=i.screenCTM().inverse();return this.addTo(i,e).untransform().transform(r.multiply(t)),this}function NM(i){return this.toParent(this.root(),i)}function EM(i,e){if(i==null||typeof i=="string"){let n=new xe(this).decompose();return i==null?n:n[i]}xe.isMatrixLike(i)||(i={...i,origin:Xc(i,this)});let t=e===!0?this:e||!1,r=new xe(t).transform(i);return this.attr("transform",r)}function lu(i){return this.attr("rx",i)}function hu(i){return this.attr("ry",i)}function K3(i){return i==null?this.cx()-this.rx():this.cx(i+this.rx())}function Z3(i){return i==null?this.cy()-this.ry():this.cy(i+this.ry())}function Q3(i){return this.attr("cx",i)}function J3(i){return this.attr("cy",i)}function e2(i){return i==null?this.rx()*2:this.rx(new ye(i).divide(2))}function t2(i){return i==null?this.ry()*2:this.ry(new ye(i).divide(2))}function i2(i,e){return(this._element||this).type==="radialGradient"?this.attr({fx:new ye(i),fy:new ye(e)}):this.attr({x1:new ye(i),y1:new ye(e)})}function r2(i,e){return(this._element||this).type==="radialGradient"?this.attr({cx:new ye(i),cy:new ye(e)}):this.attr({x2:new ye(i),y2:new ye(e)})}function CM(i){return i==null?this.bbox().x:this.move(i,this.bbox().y)}function _M(i){return i==null?this.bbox().y:this.move(this.bbox().x,i)}function LM(i){let e=this.bbox();return i==null?e.width:this.size(i,e.height)}function IM(i){let e=this.bbox();return i==null?e.height:this.size(e.width,i)}function Ys(i,e){return function(t){return t==null?this[i]:(this[i]=t,e&&e.call(this),this)}}function P3(){let i=(this._duration||500)/1e3,e=this._overshoot||0,t=1e-10,r=Math.PI,n=Math.log(e/100+t),s=-n/Math.sqrt(r*r+n*n),a=3.9/(s*i);this.d=2*s*a,this.k=a*a}function DM(i){let e=i.segment[0];return Jc[e](i.segment.slice(1),i.p,i.p0)}function eu(i){return i.segment.length&&i.segment.length-1===RM[i.segment[0].toUpperCase()]}function OM(i,e){i.inNumber&&Jn(i,!1);let t=au.test(e);if(t)i.segment=[e];else{let r=i.lastCommand,n=r.toLowerCase(),s=r===n;i.segment=[n==="m"?s?"l":"L":r]}return i.inSegment=!0,i.lastCommand=i.segment[0],t}function Jn(i,e){if(!i.inNumber)throw new Error("Parser Error");i.number&&i.segment.push(parseFloat(i.number)),i.inNumber=e,i.number="",i.pointSeen=!1,i.hasExponent=!1,eu(i)&&tu(i)}function tu(i){i.inSegment=!1,i.absolute&&(i.segment=DM(i)),i.segments.push(i.segment)}function BM(i){if(!i.segment.length)return!1;let e=i.segment[0].toUpperCase()==="A",t=i.segment.length;return e&&(t===4||t===5)}function PM(i){return i.lastToken.toUpperCase()==="E"}function FM(i,e=!0){let t=0,r="",n={segment:[],inNumber:!1,number:"",lastToken:"",inSegment:!1,segments:[],pointSeen:!1,hasExponent:!1,absolute:e,p0:new it,p:new it};for(;n.lastToken=r,r=i.charAt(t++);)if(!(!n.inSegment&&OM(n,r))){if(r==="."){if(n.pointSeen||n.hasExponent){Jn(n,!1),--t;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=r;continue}if(!isNaN(parseInt(r))){if(n.number==="0"||BM(n)){n.inNumber=!0,n.number=r,Jn(n,!0);continue}n.inNumber=!0,n.number+=r;continue}if(r===" "||r===","){n.inNumber&&Jn(n,!1);continue}if(r==="-"){if(n.inNumber&&!PM(n)){Jn(n,!1),--t;continue}n.number+=r,n.inNumber=!0;continue}if(r.toUpperCase()==="E"){n.number+=r,n.hasExponent=!0;continue}if(au.test(r)){if(n.inNumber)Jn(n,!1);else if(eu(n))tu(n);else throw new Error("parser Error");--t}}return n.inNumber&&Jn(n,!1),n.inSegment&&eu(n)&&tu(n),n.segments}function qM(i){let e="";for(let t=0,r=i.length;t{let n;try{n=t.bbox()}catch{return}let s=new xe(t),a=s.translate(i,e).transform(s.inverse()),o=new it(n.x,n.y).transform(a);t.move(o.x,o.y)}),this}function uT(i){return this.dmove(i,0)}function fT(i){return this.dmove(0,i)}function mT(i,e=this.bbox()){return i==null?e.height:this.size(e.width,i,e)}function pT(i=0,e=0,t=this.bbox()){let r=i-t.x,n=e-t.y;return this.dmove(r,n)}function gT(i,e,t=this.bbox()){let r=ta(this,i,e,t),n=r.width/t.width,s=r.height/t.height;return this.children().forEach((a,o)=>{let l=new it(t).transform(new xe(a).inverse());a.scale(n,s,l.x,l.y)}),this}function xT(i,e=this.bbox()){return i==null?e.width:this.size(i,e.height,e)}function yT(i,e=this.bbox()){return i==null?e.x:this.move(i,e.y,e)}function vT(i,e=this.bbox()){return i==null?e.y:this.move(e.x,i,e)}function bT(i,e){if(!i)return"";if(!e)return i;let t=i+"{";for(let r in e)t+=yw(r)+":"+e[r]+";";return t+="}",t}var Yc,F3,nu,vw,_0,Lo,bw,Te,yo,es,su,Gc,Mw,j3,Dw,Ow,Bw,Pw,Fw,z3,R3,D3,O3,qw,Sr,au,Ni,it,xe,Gt,Nr,cM,mM,W3,ts,go,xM,hn,ye,X3,dn,Ei,po,bM,Vt,bo,Dt,SM,Xs,L0,AM,is,rs,ji,sr,kM,du,ns,Ks,zM,wo,Mo,Zs,Zc,Qc,RM,Jc,Wc,Er,n2,Tr,To,No,HM,ss,cu,ar,s2,Gi,as,Ve,xo,Se,XM,KM,I0,Vi,Qs,a2,o2,iu,QM,Eo,So,l2,Ce,Js,Wi,Ao,ea,h2,_e,cn,ko,z0,Co,_o,R0,Ae,yt=T(()=>{Yc={},F3=[];nu="http://www.w3.org/2000/svg",vw="http://www.w3.org/1999/xhtml",_0="http://www.w3.org/2000/xmlns/",Lo="http://www.w3.org/1999/xlink",bw="http://svgjs.dev/svgjs",Te={window:typeof window>"u"?null:window,document:typeof document>"u"?null:document},yo=class{},es={},su="___SYMBOL___ROOT___";Gc=Ti;Mw=1e3;fe("Dom",{siblings:Tw,position:Nw,next:Ew,prev:Sw,forward:Aw,backward:kw,front:Cw,back:_w,before:Lw,after:Iw,insertBefore:zw,insertAfter:Rw});j3=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,Dw=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Ow=/rgb\((\d+),(\d+),(\d+)\)/,Bw=/(#[a-z_][a-z0-9\-_]*)/i,Pw=/\)\s*,?\s*/,Fw=/\s/g,z3=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,R3=/^rgb\(/,D3=/^(\s+)?$/,O3=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qw=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,Sr=/[\s,]+/,au=/[MLHVCSQTAZ]/i;fe("Dom",{classes:Hw,hasClass:Uw,addClass:$w,removeClass:jw,toggleClass:Gw});fe("Dom",{css:Vw,show:Ww,hide:Yw,visible:Xw});fe("Dom",{data:Kw});fe("Dom",{remember:Zw,forget:Qw,memory:Jw});Ni=class i{constructor(...e){this.init(...e)}static isColor(e){return e&&(e instanceof i||this.isRgb(e)||this.test(e))}static isRgb(e){return e&&typeof e.r=="number"&&typeof e.g=="number"&&typeof e.b=="number"}static random(e="vibrant",t,r){let{random:n,round:s,sin:a,PI:o}=Math;if(e==="vibrant"){let l=24*n()+57,h=38*n()+45,d=360*n();return new i(l,h,d,"lch")}else if(e==="sine"){t=t??n();let l=s(80*a(2*o*t/.5+.01)+150),h=s(50*a(2*o*t/.5+4.6)+200),d=s(100*a(2*o*t/.5+2.3)+150);return new i(l,h,d)}else if(e==="pastel"){let l=8*n()+86,h=17*n()+9,d=360*n();return new i(l,h,d,"lch")}else if(e==="dark"){let l=10+10*n(),h=50*n()+86,d=360*n();return new i(l,h,d,"lch")}else if(e==="rgb"){let l=255*n(),h=255*n(),d=255*n();return new i(l,h,d)}else if(e==="lab"){let l=100*n(),h=256*n()-128,d=256*n()-128;return new i(l,h,d,"lab")}else if(e==="grey"){let l=255*n();return new i(l,l,l)}else throw new Error("Unsupported random color mode")}static test(e){return typeof e=="string"&&(z3.test(e)||R3.test(e))}cmyk(){let{_a:e,_b:t,_c:r}=this.rgb(),[n,s,a]=[e,t,r].map(f=>f/255),o=Math.min(1-n,1-s,1-a);if(o===1)return new i(0,0,0,1,"cmyk");let l=(1-n-o)/(1-o),h=(1-s-o)/(1-o),d=(1-a-o)/(1-o);return new i(l,h,d,o,"cmyk")}hsl(){let{_a:e,_b:t,_c:r}=this.rgb(),[n,s,a]=[e,t,r].map(x=>x/255),o=Math.max(n,s,a),l=Math.min(n,s,a),h=(o+l)/2,d=o===l,c=o-l,f=d?0:h>.5?c/(2-o-l):c/(o+l),m=d?0:o===n?((s-a)/c+(sparseInt(x));Object.assign(this,{_a:f,_b:m,_c:g,_d:0,space:"rgb"})}else if(z3.test(e)){let c=x=>parseInt(x,16),[,f,m,g]=Dw.exec(eM(e)).map(c);Object.assign(this,{_a:f,_b:m,_c:g,_d:0,space:"rgb"})}else throw Error("Unsupported string format, can't construct Color");let{_a:a,_b:o,_c:l,_d:h}=this,d=this.space==="rgb"?{r:a,g:o,b:l}:this.space==="xyz"?{x:a,y:o,z:l}:this.space==="hsl"?{h:a,s:o,l}:this.space==="lab"?{l:a,a:o,b:l}:this.space==="lch"?{l:a,c:o,h:l}:this.space==="cmyk"?{c:a,m:o,y:l,k:h}:{};Object.assign(this,d)}lab(){let{x:e,y:t,z:r}=this.xyz(),n=116*t-16,s=500*(e-t),a=200*(t-r);return new i(n,s,a,"lab")}lch(){let{l:e,a:t,b:r}=this.lab(),n=Math.sqrt(t**2+r**2),s=180*Math.atan2(r,t)/Math.PI;return s<0&&(s*=-1,s=360-s),new i(e,n,s,"lch")}rgb(){if(this.space==="rgb")return this;if(rM(this.space)){let{x:e,y:t,z:r}=this;if(this.space==="lab"||this.space==="lch"){let{l:m,a:g,b:x}=this;if(this.space==="lch"){let{c:O,h:q}=this,P=Math.PI/180;g=O*Math.cos(P*q),x=O*Math.sin(P*q)}let y=(m+16)/116,b=g/500+y,S=y-x/200,A=16/116,C=.008856,I=7.787;e=.95047*(b**3>C?b**3:(b-A)/I),t=1*(y**3>C?y**3:(y-A)/I),r=1.08883*(S**3>C?S**3:(S-A)/I)}let n=e*3.2406+t*-1.5372+r*-.4986,s=e*-.9689+t*1.8758+r*.0415,a=e*.0557+t*-.204+r*1.057,o=Math.pow,l=.0031308,h=n>l?1.055*o(n,1/2.4)-.055:12.92*n,d=s>l?1.055*o(s,1/2.4)-.055:12.92*s,c=a>l?1.055*o(a,1/2.4)-.055:12.92*a;return new i(255*h,255*d,255*c)}else if(this.space==="hsl"){let{h:e,s:t,l:r}=this;if(e/=360,t/=100,r/=100,t===0)return r*=255,new i(r,r,r);let n=r<.5?r*(1+t):r+t-r*t,s=2*r-n,a=255*Vc(s,n,e+1/3),o=255*Vc(s,n,e),l=255*Vc(s,n,e-1/3);return new i(a,o,l)}else if(this.space==="cmyk"){let{c:e,m:t,y:r,k:n}=this,s=255*(1-Math.min(1,e*(1-n)+n)),a=255*(1-Math.min(1,t*(1-n)+n)),o=255*(1-Math.min(1,r*(1-n)+n));return new i(s,a,o)}else return this}toArray(){let{_a:e,_b:t,_c:r,_d:n,space:s}=this;return[e,t,r,n,s]}toHex(){let[e,t,r]=this._clamped().map(tM);return`#${e}${t}${r}`}toRgb(){let[e,t,r]=this._clamped();return`rgb(${e},${t},${r})`}toString(){return this.toHex()}xyz(){let{_a:e,_b:t,_c:r}=this.rgb(),[n,s,a]=[e,t,r].map(b=>b/255),o=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,l=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92,h=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92,d=(o*.4124+l*.3576+h*.1805)/.95047,c=(o*.2126+l*.7152+h*.0722)/1,f=(o*.0193+l*.1192+h*.9505)/1.08883,m=d>.008856?Math.pow(d,1/3):7.787*d+16/116,g=c>.008856?Math.pow(c,1/3):7.787*c+16/116,x=f>.008856?Math.pow(f,1/3):7.787*f+16/116;return new i(m,g,x,"xyz")}_clamped(){let{_a:e,_b:t,_c:r}=this.rgb(),{max:n,min:s,round:a}=Math,o=l=>n(0,s(a(l),255));return[e,t,r].map(o)}},it=class i{constructor(...e){this.init(...e)}clone(){return new i(this)}init(e,t){let r={x:0,y:0},n=Array.isArray(e)?{x:e[0],y:e[1]}:typeof e=="object"?{x:e.x,y:e.y}:{x:e,y:t};return this.x=n.x==null?r.x:n.x,this.y=n.y==null?r.y:n.y,this}toArray(){return[this.x,this.y]}transform(e){return this.clone().transformO(e)}transformO(e){xe.isMatrixLike(e)||(e=new xe(e));let{x:t,y:r}=this;return this.x=e.a*t+e.c*r+e.e,this.y=e.b*t+e.d*r+e.f,this}};xe=class i{constructor(...e){this.init(...e)}static formatTransforms(e){let t=e.flip==="both"||e.flip===!0,r=e.flip&&(t||e.flip==="x")?-1:1,n=e.flip&&(t||e.flip==="y")?-1:1,s=e.skew&&e.skew.length?e.skew[0]:isFinite(e.skew)?e.skew:isFinite(e.skewX)?e.skewX:0,a=e.skew&&e.skew.length?e.skew[1]:isFinite(e.skew)?e.skew:isFinite(e.skewY)?e.skewY:0,o=e.scale&&e.scale.length?e.scale[0]*r:isFinite(e.scale)?e.scale*r:isFinite(e.scaleX)?e.scaleX*r:r,l=e.scale&&e.scale.length?e.scale[1]*n:isFinite(e.scale)?e.scale*n:isFinite(e.scaleY)?e.scaleY*n:n,h=e.shear||0,d=e.rotate||e.theta||0,c=new it(e.origin||e.around||e.ox||e.originX,e.oy||e.originY),f=c.x,m=c.y,g=new it(e.position||e.px||e.positionX||NaN,e.py||e.positionY||NaN),x=g.x,y=g.y,b=new it(e.translate||e.tx||e.translateX,e.ty||e.translateY),S=b.x,A=b.y,C=new it(e.relative||e.rx||e.relativeX,e.ry||e.relativeY),I=C.x,O=C.y;return{scaleX:o,scaleY:l,skewX:s,skewY:a,shear:h,theta:d,rx:I,ry:O,tx:S,ty:A,ox:f,oy:m,px:x,py:y}}static fromArray(e){return{a:e[0],b:e[1],c:e[2],d:e[3],e:e[4],f:e[5]}}static isMatrixLike(e){return e.a!=null||e.b!=null||e.c!=null||e.d!=null||e.e!=null||e.f!=null}static matrixMultiply(e,t,r){let n=e.a*t.a+e.c*t.b,s=e.b*t.a+e.d*t.b,a=e.a*t.c+e.c*t.d,o=e.b*t.c+e.d*t.d,l=e.e+e.a*t.e+e.c*t.f,h=e.f+e.b*t.e+e.d*t.f;return r.a=n,r.b=s,r.c=a,r.d=o,r.e=l,r.f=h,r}around(e,t,r){return this.clone().aroundO(e,t,r)}aroundO(e,t,r){let n=e||0,s=t||0;return this.translateO(-n,-s).lmultiplyO(r).translateO(n,s)}clone(){return new i(this)}decompose(e=0,t=0){let r=this.a,n=this.b,s=this.c,a=this.d,o=this.e,l=this.f,h=r*a-n*s,d=h>0?1:-1,c=d*Math.sqrt(r*r+n*n),f=Math.atan2(d*n,d*r),m=180/Math.PI*f,g=Math.cos(f),x=Math.sin(f),y=(r*s+n*a)/h,b=s*c/(y*r-n)||a*c/(y*n+r),S=o-e+e*g*c+t*(y*g*c-x*b),A=l-t+e*x*c+t*(y*x*c+g*b);return{scaleX:c,scaleY:b,shear:y,rotate:m,translateX:S,translateY:A,originX:e,originY:t,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}equals(e){if(e===this)return!0;let t=new i(e);return Vs(this.a,t.a)&&Vs(this.b,t.b)&&Vs(this.c,t.c)&&Vs(this.d,t.d)&&Vs(this.e,t.e)&&Vs(this.f,t.f)}flip(e,t){return this.clone().flipO(e,t)}flipO(e,t){return e==="x"?this.scaleO(-1,1,t,0):e==="y"?this.scaleO(1,-1,0,t):this.scaleO(-1,-1,e,t||e)}init(e){let t=i.fromArray([1,0,0,1,0,0]);return e=e instanceof Ei?e.matrixify():typeof e=="string"?i.fromArray(e.split(Sr).map(parseFloat)):Array.isArray(e)?i.fromArray(e):typeof e=="object"&&i.isMatrixLike(e)?e:typeof e=="object"?new i().transform(e):arguments.length===6?i.fromArray([].slice.call(arguments)):t,this.a=e.a!=null?e.a:t.a,this.b=e.b!=null?e.b:t.b,this.c=e.c!=null?e.c:t.c,this.d=e.d!=null?e.d:t.d,this.e=e.e!=null?e.e:t.e,this.f=e.f!=null?e.f:t.f,this}inverse(){return this.clone().inverseO()}inverseO(){let e=this.a,t=this.b,r=this.c,n=this.d,s=this.e,a=this.f,o=e*n-t*r;if(!o)throw new Error("Cannot invert "+this);let l=n/o,h=-t/o,d=-r/o,c=e/o,f=-(l*s+d*a),m=-(h*s+c*a);return this.a=l,this.b=h,this.c=d,this.d=c,this.e=f,this.f=m,this}lmultiply(e){return this.clone().lmultiplyO(e)}lmultiplyO(e){let t=this,r=e instanceof i?e:new i(e);return i.matrixMultiply(r,t,this)}multiply(e){return this.clone().multiplyO(e)}multiplyO(e){let t=this,r=e instanceof i?e:new i(e);return i.matrixMultiply(t,r,this)}rotate(e,t,r){return this.clone().rotateO(e,t,r)}rotateO(e,t=0,r=0){e=jc(e);let n=Math.cos(e),s=Math.sin(e),{a,b:o,c:l,d:h,e:d,f:c}=this;return this.a=a*n-o*s,this.b=o*n+a*s,this.c=l*n-h*s,this.d=h*n+l*s,this.e=d*n-c*s+r*s-t*n+t,this.f=c*n+d*s-t*s-r*n+r,this}scale(e,t,r,n){return this.clone().scaleO(...arguments)}scaleO(e,t=e,r=0,n=0){arguments.length===3&&(n=r,r=t,t=e);let{a:s,b:a,c:o,d:l,e:h,f:d}=this;return this.a=s*e,this.b=a*t,this.c=o*e,this.d=l*t,this.e=h*e-r*e+r,this.f=d*t-n*t+n,this}shear(e,t,r){return this.clone().shearO(e,t,r)}shearO(e,t=0,r=0){let{a:n,b:s,c:a,d:o,e:l,f:h}=this;return this.a=n+s*e,this.c=a+o*e,this.e=l+h*e-r*e,this}skew(e,t,r,n){return this.clone().skewO(...arguments)}skewO(e,t=e,r=0,n=0){arguments.length===3&&(n=r,r=t,t=e),e=jc(e),t=jc(t);let s=Math.tan(e),a=Math.tan(t),{a:o,b:l,c:h,d,e:c,f}=this;return this.a=o+l*s,this.b=l+o*a,this.c=h+d*s,this.d=d+h*a,this.e=c+f*s-n*s,this.f=f+c*a-r*a,this}skewX(e,t,r){return this.skew(e,0,t,r)}skewY(e,t,r){return this.skew(0,e,t,r)}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}toString(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}transform(e){if(i.isMatrixLike(e))return new i(e).multiplyO(this);let t=i.formatTransforms(e),r=this,{x:n,y:s}=new it(t.ox,t.oy).transform(r),a=new i().translateO(t.rx,t.ry).lmultiplyO(r).translateO(-n,-s).scaleO(t.scaleX,t.scaleY).skewO(t.skewX,t.skewY).shearO(t.shear).rotateO(t.theta).translateO(n,s);if(isFinite(t.px)||isFinite(t.py)){let o=new it(n,s).transform(a),l=isFinite(t.px)?t.px-o.x:0,h=isFinite(t.py)?t.py-o.y:0;a.translateO(l,h)}return a.translateO(t.tx,t.ty),a}translate(e,t){return this.clone().translateO(e,t)}translateO(e,t){return this.e+=e||0,this.f+=t||0,this}valueOf(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}};be(xe,"Matrix");Gt=class i{constructor(...e){this.init(...e)}addOffset(){return this.x+=Te.window.pageXOffset,this.y+=Te.window.pageYOffset,new i(this)}init(e){let t=[0,0,0,0];return e=typeof e=="string"?e.split(Sr).map(parseFloat):Array.isArray(e)?e:typeof e=="object"?[e.left!=null?e.left:e.x,e.top!=null?e.top:e.y,e.width,e.height]:arguments.length===4?[].slice.call(arguments):t,this.x=e[0]||0,this.y=e[1]||0,this.width=this.w=e[2]||0,this.height=this.h=e[3]||0,this.x2=this.x+this.w,this.y2=this.y+this.h,this.cx=this.x+this.w/2,this.cy=this.y+this.h/2,this}isNulled(){return G3(this)}merge(e){let t=Math.min(this.x,e.x),r=Math.min(this.y,e.y),n=Math.max(this.x+this.width,e.x+e.width)-t,s=Math.max(this.y+this.height,e.y+e.height)-r;return new i(t,r,n,s)}toArray(){return[this.x,this.y,this.width,this.height]}toString(){return this.x+" "+this.y+" "+this.width+" "+this.height}transform(e){e instanceof xe||(e=new xe(e));let t=1/0,r=-1/0,n=1/0,s=-1/0;return[new it(this.x,this.y),new it(this.x2,this.y),new it(this.x,this.y2),new it(this.x2,this.y2)].forEach(function(o){o=o.transform(e),t=Math.min(t,o.x),r=Math.max(r,o.x),n=Math.min(n,o.y),s=Math.max(s,o.y)}),new i(t,n,r-t,s-n)}};fe({viewbox:{viewbox(i,e,t,r){return i==null?new Gt(this.attr("viewBox")):this.attr("viewBox",new Gt(i,e,t,r))},zoom(i,e){let{width:t,height:r}=this.attr(["width","height"]);if((!t&&!r||typeof t=="string"||typeof r=="string")&&(t=this.node.clientWidth,r=this.node.clientHeight),!t||!r)throw new Error("Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element");let n=this.viewbox(),s=t/n.width,a=r/n.height,o=Math.min(s,a);if(i==null)return o;let l=o/i;l===1/0&&(l=Number.MAX_SAFE_INTEGER/100),e=e||new it(t/2/s+n.x,r/2/a+n.y);let h=new Gt(n).transform(new xe({scale:l,origin:e}));return this.viewbox(h)}}});be(Gt,"Box");Nr=class extends Array{constructor(e=[],...t){if(super(e,...t),typeof e=="number")return this;this.length=0,this.push(...e)}};ge([Nr],{each(i,...e){return typeof i=="function"?this.map((t,r,n)=>i.call(t,t,r,n)):this.map(t=>t[i](...e))},toArray(){return Array.prototype.concat.apply([],this)}});cM=["toArray","constructor","each"];Nr.extend=function(i){i=i.reduce((e,t)=>(cM.includes(t)||t[0]==="_"||(e[t]=function(...r){return this.each(t,...r)}),e),{}),ge([Nr],i)};mM=0,W3={};ts=class extends yo{addEventListener(){}dispatch(e,t,r){return gM(this,e,t,r)}dispatchEvent(e){let t=this.getEventHolder().events;if(!t)return!0;let r=t[e.type];for(let n in r)for(let s in r[n])r[n][s](e);return!e.defaultPrevented}fire(e,t,r){return this.dispatch(e,t,r),this}getEventHolder(){return this}getEventTarget(){return this}off(e,t,r){return Ws(this,e,t,r),this}on(e,t,r,n){return Kc(this,e,t,r,n),this}removeEventListener(){}};be(ts,"EventTarget");go={duration:400,ease:">",delay:0},xM={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","text-anchor":"start"},hn=class extends Array{constructor(...e){super(...e),this.init(...e)}clone(){return new this.constructor(this)}init(e){return typeof e=="number"?this:(this.length=0,this.push(...this.parse(e)),this)}parse(e=[]){return e instanceof Array?e:e.trim().split(Sr).map(parseFloat)}toArray(){return Array.prototype.concat.apply([],this)}toSet(){return new Set(this)}toString(){return this.join(" ")}valueOf(){let e=[];return e.push(...this),e}},ye=class i{constructor(...e){this.init(...e)}convert(e){return new i(this.value,e)}divide(e){return e=new i(e),new i(this/e,this.unit||e.unit)}init(e,t){return t=Array.isArray(e)?e[1]:t,e=Array.isArray(e)?e[0]:e,this.value=0,this.unit=t||"",typeof e=="number"?this.value=isNaN(e)?0:isFinite(e)?e:e<0?-34e37:34e37:typeof e=="string"?(t=e.match(j3),t&&(this.value=parseFloat(t[1]),t[5]==="%"?this.value/=100:t[5]==="s"&&(this.value*=1e3),this.unit=t[5])):e instanceof i&&(this.value=e.valueOf(),this.unit=e.unit),this}minus(e){return e=new i(e),new i(this-e,this.unit||e.unit)}plus(e){return e=new i(e),new i(this+e,this.unit||e.unit)}times(e){return e=new i(e),new i(this*e,this.unit||e.unit)}toArray(){return[this.value,this.unit]}toJSON(){return this.toString()}toString(){return(this.unit==="%"?~~(this.value*1e8)/1e6:this.unit==="s"?this.value/1e3:this.value)+this.unit}valueOf(){return this.value}},X3=[];dn=class i extends ts{constructor(e,t){super(),this.node=e,this.type=e.nodeName,t&&e!==t&&this.attr(t)}add(e,t){return e=Rt(e),e.removeNamespace&&this.node instanceof Te.window.SVGElement&&e.removeNamespace(),t==null?this.node.appendChild(e.node):e.node!==this.node.childNodes[t]&&this.node.insertBefore(e.node,this.node.childNodes[t]),this}addTo(e,t){return Rt(e).put(this,t)}children(){return new Nr(ru(this.node.children,function(e){return Ti(e)}))}clear(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}clone(e=!0,t=!0){this.writeDataToDom();let r=this.node.cloneNode(e);return t&&(r=$3(r)),new this.constructor(r)}each(e,t){let r=this.children(),n,s;for(n=0,s=r.length;n=0}html(e,t){return this.xml(e,t,vw)}id(e){return typeof e>"u"&&!this.node.id&&(this.node.id=U3(this.type)),this.attr("id",e)}index(e){return[].slice.call(this.node.childNodes).indexOf(e.node)}last(){return Ti(this.node.lastChild)}matches(e){let t=this.node,r=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector||null;return r&&r.call(t,e)}parent(e){let t=this;if(!t.node.parentNode)return null;if(t=Ti(t.node.parentNode),!e)return t;do if(typeof e=="string"?t.matches(e):t instanceof e)return t;while(t=Ti(t.node.parentNode));return t}put(e,t){return e=Rt(e),this.add(e,t),e}putIn(e,t){return Rt(e).add(this,t)}remove(){return this.parent()&&this.parent().removeElement(this),this}removeElement(e){return this.node.removeChild(e.node),this}replace(e){return e=Rt(e),this.node.parentNode&&this.node.parentNode.replaceChild(e.node,this.node),e}round(e=2,t=null){let r=10**e,n=this.attr(t);for(let s in n)typeof n[s]=="number"&&(n[s]=Math.round(n[s]*r)/r);return this.attr(n),this}svg(e,t){return this.xml(e,t,nu)}toString(){return this.id()}words(e){return this.node.textContent=e,this}wrap(e){let t=this.parent();if(!t)return this.addTo(e);let r=t.index(this);return t.put(e,r).put(this)}writeDataToDom(){return this.each(function(){this.writeDataToDom()}),this}xml(e,t,r){if(typeof e=="boolean"&&(r=t,t=e,e=null),e==null||typeof e=="function"){t=t??!0,this.writeDataToDom();let o=this;if(e!=null){if(o=Ti(o.node.cloneNode(!0)),t){let l=e(o);if(o=l||o,l===!1)return""}o.each(function(){let l=e(this),h=l||this;l===!1?this.remove():l&&this!==h&&this.replace(h)},!0)}return t?o.node.outerHTML:o.node.innerHTML}t=t??!1;let n=vo("wrapper",r),s=Te.document.createDocumentFragment();n.innerHTML=e;for(let o=n.children.length;o--;)s.appendChild(n.firstElementChild);let a=this.parent();return t?this.replace(s)&&a:this.add(s)}};ge(dn,{attr:vM,find:uM,findOne:fM});be(dn,"Dom");Ei=class extends dn{constructor(e,t){super(e,t),this.dom={},this.node.instance=this,e.hasAttribute("svgjs:data")&&this.setData(JSON.parse(e.getAttribute("svgjs:data"))||{})}center(e,t){return this.cx(e).cy(t)}cx(e){return e==null?this.x()+this.width()/2:this.x(e-this.width()/2)}cy(e){return e==null?this.y()+this.height()/2:this.y(e-this.height()/2)}defs(){let e=this.root();return e&&e.defs()}dmove(e,t){return this.dx(e).dy(t)}dx(e=0){return this.x(new ye(e).plus(this.x()))}dy(e=0){return this.y(new ye(e).plus(this.y()))}getEventHolder(){return this}height(e){return this.attr("height",e)}move(e,t){return this.x(e).y(t)}parents(e=this.root()){let t=typeof e=="string";t||(e=Rt(e));let r=new Nr,n=this;for(;(n=n.parent())&&n.node!==Te.document&&n.nodeName!=="#document-fragment"&&(r.push(n),!(!t&&n.node===e.node||t&&n.matches(e)));)if(n.node===this.root().node)return null;return r}reference(e){if(e=this.attr(e),!e)return null;let t=(e+"").match(Bw);return t?Rt(t[1]):null}root(){let e=this.parent(ww(su));return e&&e.root()}setData(e){return this.dom=e,this}size(e,t){let r=ta(this,e,t);return this.width(new ye(r.width)).height(new ye(r.height))}width(e){return this.attr("width",e)}writeDataToDom(){return this.node.removeAttribute("svgjs:data"),Object.keys(this.dom).length&&this.node.setAttribute("svgjs:data",JSON.stringify(this.dom)),super.writeDataToDom()}x(e){return this.attr("x",e)}y(e){return this.attr("y",e)}};ge(Ei,{bbox:lM,rbox:hM,inside:dM,point:nM,ctm:sM,screenCTM:aM});be(Ei,"Element");po={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(i,e){return e==="color"?i:i+"-"+e}};["fill","stroke"].forEach(function(i){let e={},t;e[i]=function(r){if(typeof r>"u")return this.attr(i);if(typeof r=="string"||r instanceof Ni||Ni.isRgb(r)||r instanceof Ei)this.attr(i,r);else for(t=po[i].length-1;t>=0;t--)r[po[i][t]]!=null&&this.attr(po.prefix(i,po[i][t]),r[po[i][t]]);return this},fe(["Element","Runner"],e)});fe(["Element","Runner"],{matrix:function(i,e,t,r,n,s){return i==null?new xe(this):this.attr("transform",new xe(i,e,t,r,n,s))},rotate:function(i,e,t){return this.transform({rotate:i,ox:e,oy:t},!0)},skew:function(i,e,t,r){return arguments.length===1||arguments.length===3?this.transform({skew:i,ox:e,oy:t},!0):this.transform({skew:[i,e],ox:t,oy:r},!0)},shear:function(i,e,t){return this.transform({shear:i,ox:e,oy:t},!0)},scale:function(i,e,t,r){return arguments.length===1||arguments.length===3?this.transform({scale:i,ox:e,oy:t},!0):this.transform({scale:[i,e],ox:t,oy:r},!0)},translate:function(i,e){return this.transform({translate:[i,e]},!0)},relative:function(i,e){return this.transform({relative:[i,e]},!0)},flip:function(i="both",e="center"){return"xybothtrue".indexOf(i)===-1&&(e=i,i="both"),this.transform({flip:i,origin:e},!0)},opacity:function(i){return this.attr("opacity",i)}});fe("radius",{radius:function(i,e=i){return(this._element||this).type==="radialGradient"?this.attr("r",new ye(i)):this.rx(i).ry(e)}});fe("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(i){return new it(this.node.getPointAtLength(i))}});fe(["Element","Runner"],{font:function(i,e){if(typeof i=="object"){for(e in i)this.font(e,i[e]);return this}return i==="leading"?this.leading(e):i==="anchor"?this.attr("text-anchor",e):i==="size"||i==="family"||i==="weight"||i==="stretch"||i==="variant"||i==="style"?this.attr("font-"+i,e):this.attr(i,e)}});bM=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].reduce(function(i,e){let t=function(r){return r===null?this.off(e):this.on(e,r),this};return i[e]=t,i},{});fe("Element",bM);fe("Element",{untransform:wM,matrixify:MM,toParent:TM,toRoot:NM,transform:EM});Vt=class i extends Ei{flatten(e=this,t){return this.each(function(){if(this instanceof i)return this.flatten().ungroup()}),this}ungroup(e=this.parent(),t=e.index(this)){return t=t===-1?e.children().length:t,this.each(function(r,n){return n[n.length-r-1].toParent(e,t)}),this.remove()}};be(Vt,"Container");bo=class extends Vt{constructor(e,t=e){super(qe("defs",e),t)}flatten(){return this}ungroup(){return this}};be(bo,"Defs");Dt=class extends Ei{};be(Dt,"Shape");SM={__proto__:null,rx:lu,ry:hu,x:K3,y:Z3,cx:Q3,cy:J3,width:e2,height:t2},Xs=class extends Dt{constructor(e,t=e){super(qe("ellipse",e),t)}size(e,t){let r=ta(this,e,t);return this.rx(new ye(r.width).divide(2)).ry(new ye(r.height).divide(2))}};ge(Xs,SM);fe("Container",{ellipse:Fe(function(i=0,e=i){return this.put(new Xs).size(i,e).move(0,0)})});be(Xs,"Ellipse");L0=class extends dn{constructor(e=Te.document.createDocumentFragment()){super(e)}xml(e,t,r){if(typeof e=="boolean"&&(r=t,t=e,e=null),e==null||typeof e=="function"){let n=new dn(vo("wrapper",r));return n.add(this.node.cloneNode(!0)),n.xml(!1,r)}return super.xml(e,!1,r)}};be(L0,"Fragment");AM={__proto__:null,from:i2,to:r2},is=class extends Vt{constructor(e,t){super(qe(e+"Gradient",typeof e=="string"?null:e),t)}attr(e,t,r){return e==="transform"&&(e="gradientTransform"),super.attr(e,t,r)}bbox(){return new Gt}targets(){return ia("svg [fill*="+this.id()+"]")}toString(){return this.url()}update(e){return this.clear(),typeof e=="function"&&e.call(this,this),this}url(){return"url(#"+this.id()+")"}};ge(is,AM);fe({Container:{gradient(...i){return this.defs().gradient(...i)}},Defs:{gradient:Fe(function(i,e){return this.put(new is(i)).update(e)})}});be(is,"Gradient");rs=class extends Vt{constructor(e,t=e){super(qe("pattern",e),t)}attr(e,t,r){return e==="transform"&&(e="patternTransform"),super.attr(e,t,r)}bbox(){return new Gt}targets(){return ia("svg [fill*="+this.id()+"]")}toString(){return this.url()}update(e){return this.clear(),typeof e=="function"&&e.call(this,this),this}url(){return"url(#"+this.id()+")"}};fe({Container:{pattern(...i){return this.defs().pattern(...i)}},Defs:{pattern:Fe(function(i,e,t){return this.put(new rs).update(t).attr({x:0,y:0,width:i,height:e,patternUnits:"userSpaceOnUse"})})}});be(rs,"Pattern");ji=class extends Dt{constructor(e,t=e){super(qe("image",e),t)}load(e,t){if(!e)return this;let r=new Te.window.Image;return Kc(r,"load",function(n){let s=this.parent(rs);this.width()===0&&this.height()===0&&this.size(r.width,r.height),s instanceof rs&&s.width()===0&&s.height()===0&&s.size(this.width(),this.height()),typeof t=="function"&&t.call(this,n)},this),Kc(r,"load error",function(){Ws(r)}),this.attr("href",r.src=e,Lo)}};yM(function(i,e,t){return(i==="fill"||i==="stroke")&&qw.test(e)&&(e=t.root().defs().image(e)),e instanceof ji&&(e=t.root().defs().pattern(0,0,r=>{r.add(e)})),e});fe({Container:{image:Fe(function(i,e){return this.put(new ji).size(0,0).load(i,e)})}});be(ji,"Image");sr=class extends hn{bbox(){let e=-1/0,t=-1/0,r=1/0,n=1/0;return this.forEach(function(s){e=Math.max(s[0],e),t=Math.max(s[1],t),r=Math.min(s[0],r),n=Math.min(s[1],n)}),new Gt(r,n,e-r,t-n)}move(e,t){let r=this.bbox();if(e-=r.x,t-=r.y,!isNaN(e)&&!isNaN(t))for(let n=this.length-1;n>=0;n--)this[n]=[this[n][0]+e,this[n][1]+t];return this}parse(e=[0,0]){let t=[];e instanceof Array?e=Array.prototype.concat.apply([],e):e=e.trim().split(Sr).map(parseFloat),e.length%2!==0&&e.pop();for(let r=0,n=e.length;r=0;r--)n.width&&(this[r][0]=(this[r][0]-n.x)*e/n.width+n.x),n.height&&(this[r][1]=(this[r][1]-n.y)*t/n.height+n.y);return this}toLine(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}}toString(){let e=[];for(let t=0,r=this.length;t":function(i){return-Math.cos(i*Math.PI)/2+.5},">":function(i){return Math.sin(i*Math.PI/2)},"<":function(i){return-Math.cos(i*Math.PI/2)+1},bezier:function(i,e,t,r){return function(n){return n<0?i>0?e/i*n:t>0?r/t*n:0:n>1?t<1?(1-r)/(1-t)*n+(r-t)/(1-t):i<1?(1-e)/(1-i)*n+(e-i)/(1-i):1:3*n*(1-n)**2*e+3*n**2*(1-n)*r+n**3}},steps:function(i,e="end"){e=e.split("-").reverse()[0];let t=i;return e==="none"?--t:e==="both"&&++t,(r,n=!1)=>{let s=Math.floor(r*i),a=r*s%1===0;return(e==="start"||e==="both")&&++s,n&&a&&--s,r>=0&&s<0&&(s=0),r<=1&&s>t&&(s=t),s/t}}},wo=class{done(){return!1}},Mo=class extends wo{constructor(e=go.ease){super(),this.ease=zM[e]||e}step(e,t,r){return typeof e!="number"?r<1?e:t:e+(t-e)*this.ease(r)}},Zs=class extends wo{constructor(e){super(),this.stepper=e}done(e){return e.done}step(e,t,r,n){return this.stepper(e,t,r,n)}};Zc=class extends Zs{constructor(e=500,t=0){super(),this.duration(e).overshoot(t)}step(e,t,r,n){if(typeof e=="string")return e;if(n.done=r===1/0,r===1/0)return t;if(r===0)return e;r>100&&(r=16),r/=1e3;let s=n.velocity||0,a=-this.d*s-this.k*(e-t),o=e+s*r+a*r*r/2;return n.velocity=s+a*r,n.done=Math.abs(t-o)+Math.abs(s)<.002,n.done?t:o}};ge(Zc,{duration:Ys("_duration",P3),overshoot:Ys("_overshoot",P3)});Qc=class extends Zs{constructor(e=.1,t=.01,r=0,n=1e3){super(),this.p(e).i(t).d(r).windup(n)}step(e,t,r,n){if(typeof e=="string")return e;if(n.done=r===1/0,r===1/0)return t;if(r===0)return e;let s=t-e,a=(n.integral||0)+s*r,o=(s-(n.error||0))/r,l=this._windup;return l!==!1&&(a=Math.max(-l,Math.min(a,l))),n.error=s,n.integral=a,n.done=Math.abs(s)<.001,n.done?t:e+(this.P*s+this.I*a+this.D*o)}};ge(Qc,{windup:Ys("_windup"),p:Ys("P"),i:Ys("I"),d:Ys("D")});RM={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},Jc={M:function(i,e,t){return e.x=t.x=i[0],e.y=t.y=i[1],["M",e.x,e.y]},L:function(i,e){return e.x=i[0],e.y=i[1],["L",i[0],i[1]]},H:function(i,e){return e.x=i[0],["H",i[0]]},V:function(i,e){return e.y=i[0],["V",i[0]]},C:function(i,e){return e.x=i[4],e.y=i[5],["C",i[0],i[1],i[2],i[3],i[4],i[5]]},S:function(i,e){return e.x=i[2],e.y=i[3],["S",i[0],i[1],i[2],i[3]]},Q:function(i,e){return e.x=i[2],e.y=i[3],["Q",i[0],i[1],i[2],i[3]]},T:function(i,e){return e.x=i[0],e.y=i[1],["T",i[0],i[1]]},Z:function(i,e,t){return e.x=t.x,e.y=t.y,["Z"]},A:function(i,e){return e.x=i[5],e.y=i[6],["A",i[0],i[1],i[2],i[3],i[4],i[5],i[6]]}},Wc="mlhvqtcsaz".split("");for(let i=0,e=Wc.length;i=0;s--)n=this[s][0],n==="M"||n==="L"||n==="T"?(this[s][1]+=e,this[s][2]+=t):n==="H"?this[s][1]+=e:n==="V"?this[s][1]+=t:n==="C"||n==="S"||n==="Q"?(this[s][1]+=e,this[s][2]+=t,this[s][3]+=e,this[s][4]+=t,n==="C"&&(this[s][5]+=e,this[s][6]+=t)):n==="A"&&(this[s][6]+=e,this[s][7]+=t);return this}parse(e="M0 0"){return Array.isArray(e)&&(e=Array.prototype.concat.apply([],e).toString()),FM(e)}size(e,t){let r=this.bbox(),n,s;for(r.width=r.width===0?1:r.width,r.height=r.height===0?1:r.height,n=this.length-1;n>=0;n--)s=this[n][0],s==="M"||s==="L"||s==="T"?(this[n][1]=(this[n][1]-r.x)*e/r.width+r.x,this[n][2]=(this[n][2]-r.y)*t/r.height+r.y):s==="H"?this[n][1]=(this[n][1]-r.x)*e/r.width+r.x:s==="V"?this[n][1]=(this[n][1]-r.y)*t/r.height+r.y:s==="C"||s==="S"||s==="Q"?(this[n][1]=(this[n][1]-r.x)*e/r.width+r.x,this[n][2]=(this[n][2]-r.y)*t/r.height+r.y,this[n][3]=(this[n][3]-r.x)*e/r.width+r.x,this[n][4]=(this[n][4]-r.y)*t/r.height+r.y,s==="C"&&(this[n][5]=(this[n][5]-r.x)*e/r.width+r.x,this[n][6]=(this[n][6]-r.y)*t/r.height+r.y)):s==="A"&&(this[n][1]=this[n][1]*e/r.width,this[n][2]=this[n][2]*t/r.height,this[n][6]=(this[n][6]-r.x)*e/r.width+r.x,this[n][7]=(this[n][7]-r.y)*t/r.height+r.y);return this}toString(){return qM(this)}},n2=i=>{let e=typeof i;return e==="number"?ye:e==="string"?Ni.isColor(i)?Ni:Sr.test(i)?au.test(i)?Er:hn:j3.test(i)?ye:To:cu.indexOf(i.constructor)>-1?i.constructor:Array.isArray(i)?hn:e==="object"?ss:To},Tr=class{constructor(e){this._stepper=e||new Mo("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}at(e){return this._morphObj.morph(this._from,this._to,e,this._stepper,this._context)}done(){return this._context.map(this._stepper.done).reduce(function(t,r){return t&&r},!0)}from(e){return e==null?this._from:(this._from=this._set(e),this)}stepper(e){return e==null?this._stepper:(this._stepper=e,this)}to(e){return e==null?this._to:(this._to=this._set(e),this)}type(e){return e==null?this._type:(this._type=e,this)}_set(e){this._type||this.type(n2(e));let t=new this._type(e);return this._type===Ni&&(t=this._to?t[this._to[4]]():this._from?t[this._from[4]]():t),this._type===ss&&(t=this._to?t.align(this._to):this._from?t.align(this._from):t),t=t.toConsumable(),this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(t.length)).map(Object).map(function(r){return r.done=!0,r}),t}},To=class{constructor(...e){this.init(...e)}init(e){return e=Array.isArray(e)?e[0]:e,this.value=e,this}toArray(){return[this.value]}valueOf(){return this.value}},No=class i{constructor(...e){this.init(...e)}init(e){return Array.isArray(e)&&(e={scaleX:e[0],scaleY:e[1],shear:e[2],rotate:e[3],translateX:e[4],translateY:e[5],originX:e[6],originY:e[7]}),Object.assign(this,i.defaults,e),this}toArray(){let e=this;return[e.scaleX,e.scaleY,e.shear,e.rotate,e.translateX,e.translateY,e.originX,e.originY]}};No.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};HM=(i,e)=>i[0]e[0]?1:0,ss=class{constructor(...e){this.init(...e)}align(e){let t=this.values;for(let r=0,n=t.length;rr.concat(n),[]),this}toArray(){return this.values}valueOf(){let e={},t=this.values;for(;t.length;){let r=t.shift(),n=t.shift(),s=t.shift(),a=t.splice(0,s);e[r]=new n(a)}return e}},cu=[To,No,ss];ar=class extends Dt{constructor(e,t=e){super(qe("path",e),t)}array(){return this._array||(this._array=new Er(this.attr("d")))}clear(){return delete this._array,this}height(e){return e==null?this.bbox().height:this.size(this.bbox().width,e)}move(e,t){return this.attr("d",this.array().move(e,t))}plot(e){return e==null?this.array():this.clear().attr("d",typeof e=="string"?e:this._array=new Er(e))}size(e,t){let r=ta(this,e,t);return this.attr("d",this.array().size(r.width,r.height))}width(e){return e==null?this.bbox().width:this.size(e,this.bbox().height)}x(e){return e==null?this.bbox().x:this.move(e,this.bbox().y)}y(e){return e==null?this.bbox().y:this.move(this.bbox().x,e)}};ar.prototype.MorphArray=Er;fe({Container:{path:Fe(function(i){return this.put(new ar).plot(i||new Er)})}});be(ar,"Path");s2={__proto__:null,array:jM,clear:GM,move:VM,plot:WM,size:YM},Gi=class extends Dt{constructor(e,t=e){super(qe("polygon",e),t)}};fe({Container:{polygon:Fe(function(i){return this.put(new Gi).plot(i||new sr)})}});ge(Gi,du);ge(Gi,s2);be(Gi,"Polygon");as=class extends Dt{constructor(e,t=e){super(qe("polyline",e),t)}};fe({Container:{polyline:Fe(function(i){return this.put(new as).plot(i||new sr)})}});ge(as,du);ge(as,s2);be(as,"Polyline");Ve=class extends Dt{constructor(e,t=e){super(qe("rect",e),t)}};ge(Ve,{rx:lu,ry:hu});fe({Container:{rect:Fe(function(i,e){return this.put(new Ve).size(i,e)})}});be(Ve,"Rect");xo=class{constructor(){this._first=null,this._last=null}first(){return this._first&&this._first.value}last(){return this._last&&this._last.value}push(e){let t=typeof e.next<"u"?e:{value:e,next:null,prev:null};return this._last?(t.prev=this._last,this._last.next=t,this._last=t):(this._last=t,this._first=t),t}remove(e){e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this._last&&(this._last=e.prev),e===this._first&&(this._first=e.next),e.prev=null,e.next=null}shift(){let e=this._first;return e?(this._first=e.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,e.value):null}},Se={nextDraw:null,frames:new xo,timeouts:new xo,immediates:new xo,timer:()=>Te.window.performance||Te.window.Date,transforms:[],frame(i){let e=Se.frames.push({run:i});return Se.nextDraw===null&&(Se.nextDraw=Te.window.requestAnimationFrame(Se._draw)),e},timeout(i,e){e=e||0;let t=Se.timer().now()+e,r=Se.timeouts.push({run:i,time:t});return Se.nextDraw===null&&(Se.nextDraw=Te.window.requestAnimationFrame(Se._draw)),r},immediate(i){let e=Se.immediates.push(i);return Se.nextDraw===null&&(Se.nextDraw=Te.window.requestAnimationFrame(Se._draw)),e},cancelFrame(i){i!=null&&Se.frames.remove(i)},clearTimeout(i){i!=null&&Se.timeouts.remove(i)},cancelImmediate(i){i!=null&&Se.immediates.remove(i)},_draw(i){let e=null,t=Se.timeouts.last();for(;(e=Se.timeouts.shift())&&(i>=e.time?e.run():Se.timeouts.push(e),e!==t););let r=null,n=Se.frames.last();for(;r!==n&&(r=Se.frames.shift());)r.run(i);let s=null;for(;s=Se.immediates.shift();)s();Se.nextDraw=Se.timeouts.first()||Se.frames.first()?Te.window.requestAnimationFrame(Se._draw):null}},XM=function(i){let e=i.start,t=i.runner.duration(),r=e+t;return{start:e,duration:t,end:r,runner:i.runner}},KM=function(){let i=Te.window;return(i.performance||i.Date).now()},I0=class extends ts{constructor(e=KM){super(),this._timeSource=e,this._startTime=0,this._speed=1,this._persist=0,this._nextFrame=null,this._paused=!0,this._runners=[],this._runnerIds=[],this._lastRunnerId=-1,this._time=0,this._lastSourceTime=0,this._lastStepTime=0,this._step=this._stepFn.bind(this,!1),this._stepImmediate=this._stepFn.bind(this,!0)}active(){return!!this._nextFrame}finish(){return this.time(this.getEndTimeOfTimeline()+1),this.pause()}getEndTime(){let e=this.getLastRunnerInfo(),t=e?e.runner.duration():0;return(e?e.start:this._time)+t}getEndTimeOfTimeline(){let e=this._runners.map(t=>t.start+t.runner.duration());return Math.max(0,...e)}getLastRunnerInfo(){return this.getRunnerInfoById(this._lastRunnerId)}getRunnerInfoById(e){return this._runners[this._runnerIds.indexOf(e)]||null}pause(){return this._paused=!0,this._continue()}persist(e){return e==null?this._persist:(this._persist=e,this)}play(){return this._paused=!1,this.updateTime()._continue()}reverse(e){let t=this.speed();if(e==null)return this.speed(-t);let r=Math.abs(t);return this.speed(e?-r:r)}schedule(e,t,r){if(e==null)return this._runners.map(XM);let n=0,s=this.getEndTime();if(t=t||0,r==null||r==="last"||r==="after")n=s;else if(r==="absolute"||r==="start")n=t,t=0;else if(r==="now")n=this._time;else if(r==="relative"){let l=this.getRunnerInfoById(e.id);l&&(n=l.start+t,t=0)}else if(r==="with-last"){let l=this.getLastRunnerInfo();n=l?l.start:this._time}else throw new Error('Invalid value for the "when" parameter');e.unschedule(),e.timeline(this);let a=e.persist(),o={persist:a===null?this._persist:a,start:n+t,runner:e};return this._lastRunnerId=e.id,this._runners.push(o),this._runners.sort((l,h)=>l.start-h.start),this._runnerIds=this._runners.map(l=>l.runner.id),this.updateTime()._continue(),this}seek(e){return this.time(this._time+e)}source(e){return e==null?this._timeSource:(this._timeSource=e,this)}speed(e){return e==null?this._speed:(this._speed=e,this)}stop(){return this.time(0),this.pause()}time(e){return e==null?this._time:(this._time=e,this._continue(!0))}unschedule(e){let t=this._runnerIds.indexOf(e.id);return t<0?this:(this._runners.splice(t,1),this._runnerIds.splice(t,1),e.timeline(null),this)}updateTime(){return this.active()||(this._lastSourceTime=this._timeSource()),this}_continue(e=!1){return Se.cancelFrame(this._nextFrame),this._nextFrame=null,e?this._stepImmediate():this._paused?this:(this._nextFrame=Se.frame(this._step),this)}_stepFn(e=!1){let t=this._timeSource(),r=t-this._lastSourceTime;e&&(r=0);let n=this._speed*r+(this._time-this._lastStepTime);this._lastSourceTime=t,e||(this._time+=n,this._time=this._time<0?0:this._time),this._lastStepTime=this._time,this.fire("time",this._time);for(let a=this._runners.length;a--;){let o=this._runners[a],l=o.runner;this._time-o.start<=0&&l.reset()}let s=!1;for(let a=0,o=this._runners.length;a0?this._continue():(this.pause(),this.fire("finished")),this}};fe({Element:{timeline:function(i){return i==null?(this._timeline=this._timeline||new I0,this._timeline):(this._timeline=i,this)}}});Vi=class i extends ts{constructor(e){super(),this.id=i.id++,e=e??go.duration,e=typeof e=="function"?new Zs(e):e,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration=typeof e=="number"&&e,this._isDeclarative=e instanceof Zs,this._stepper=this._isDeclarative?e:new Mo,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new xe,this.transformId=1,this._haveReversed=!1,this._reverse=!1,this._loopsDone=0,this._swing=!1,this._wait=0,this._times=1,this._frameId=null,this._persist=this._isDeclarative?!0:null}static sanitise(e,t,r){let n=1,s=!1,a=0;return e=e||go.duration,t=t||go.delay,r=r||"last",typeof e=="object"&&!(e instanceof wo)&&(t=e.delay||t,r=e.when||r,s=e.swing||s,n=e.times||n,a=e.wait||a,e=e.duration||go.duration),{duration:e,delay:t,swing:s,times:n,wait:a,when:r}}active(e){return e==null?this.enabled:(this.enabled=e,this)}addTransform(e,t){return this.transforms.lmultiplyO(e),this}after(e){return this.on("finished",e)}animate(e,t,r){let n=i.sanitise(e,t,r),s=new i(n.duration);return this._timeline&&s.timeline(this._timeline),this._element&&s.element(this._element),s.loop(n).schedule(n.delay,n.when)}clearTransform(){return this.transforms=new xe,this}clearTransformsFromQueue(){(!this.done||!this._timeline||!this._timeline._runnerIds.includes(this.id))&&(this._queue=this._queue.filter(e=>!e.isTransform))}delay(e){return this.animate(0,e)}duration(){return this._times*(this._wait+this._duration)-this._wait}during(e){return this.queue(null,e)}ease(e){return this._stepper=new Mo(e),this}element(e){return e==null?this._element:(this._element=e,e._prepareRunner(),this)}finish(){return this.step(1/0)}loop(e,t,r){return typeof e=="object"&&(t=e.swing,r=e.wait,e=e.times),this._times=e||1/0,this._swing=t||!1,this._wait=r||0,this._times===!0&&(this._times=1/0),this}loops(e){let t=this._duration+this._wait;if(e==null){let a=Math.floor(this._time/t),l=(this._time-a*t)/this._duration;return Math.min(a+l,this._times)}let r=Math.floor(e),n=e%1,s=t*r+this._duration*n;return this.time(s)}persist(e){return e==null?this._persist:(this._persist=e,this)}position(e){let t=this._time,r=this._duration,n=this._wait,s=this._times,a=this._swing,o=this._reverse,l;if(e==null){let f=function(g){let x=a*Math.floor(g%(2*(n+r))/(n+r)),y=x&&!o||!x&&o,b=Math.pow(-1,y)*(g%(n+r))/r+y;return Math.max(Math.min(b,1),0)},m=s*(n+r)-n;return l=t<=0?Math.round(f(1e-5)):t=0;this._lastPosition=t;let n=this.duration(),s=this._lastTime<=0&&this._time>0,a=this._lastTime=n;this._lastTime=this._time,s&&this.fire("start",this);let o=this._isDeclarative;this.done=!o&&!a&&this._time>=n,this._reseted=!1;let l=!1;return(r||o)&&(this._initialise(r),this.transforms=new xe,l=this._run(o?e:t),this.fire("step",this)),this.done=this.done||l&&o,a&&this.fire("finished",this),this}time(e){if(e==null)return this._time;let t=e-this._time;return this.step(t),this}timeline(e){return typeof e>"u"?this._timeline:(this._timeline=e,this)}unschedule(){let e=this.timeline();return e&&e.unschedule(this),this}_initialise(e){if(!(!e&&!this._isDeclarative))for(let t=0,r=this._queue.length;ti.lmultiplyO(e),o2=i=>i.transforms;iu=class{constructor(){this.runners=[],this.ids=[]}add(e){if(this.runners.includes(e))return;let t=e.id+1;return this.runners.push(e),this.ids.push(t),this}clearBefore(e){let t=this.ids.indexOf(e+1)||1;return this.ids.splice(0,t,0),this.runners.splice(0,t,new Qs).forEach(r=>r.clearTransformsFromQueue()),this}edit(e,t){let r=this.ids.indexOf(e+1);return this.ids.splice(r,1,e+1),this.runners.splice(r,1,t),this}getByID(e){return this.runners[this.ids.indexOf(e+1)]}length(){return this.ids.length}merge(){let e=null;for(let t=0;te.id<=i.id).map(o2).reduce(a2,new xe)},_addRunner(i){this._transformationRunners.add(i),Se.cancelImmediate(this._frameId),this._frameId=Se.immediate(ZM.bind(this))},_prepareRunner(){this._frameId==null&&(this._transformationRunners=new iu().add(new Qs(new xe(this))))}}});QM=(i,e)=>i.filter(t=>!e.includes(t));ge(Vi,{attr(i,e){return this.styleAttr("attr",i,e)},css(i,e){return this.styleAttr("css",i,e)},styleAttr(i,e,t){if(typeof e=="string")return this.styleAttr(i,{[e]:t});let r=e;if(this._tryRetarget(i,r))return this;let n=new Tr(this._stepper).to(r),s=Object.keys(r);return this.queue(function(){n=n.from(this.element()[i](s))},function(a){return this.element()[i](n.at(a).valueOf()),n.done()},function(a){let o=Object.keys(a),l=QM(o,s);if(l.length){let d=this.element()[i](l),c=new ss(n.from()).valueOf();Object.assign(c,d),n.from(c)}let h=new ss(n.to()).valueOf();Object.assign(h,a),n.to(h),s=o,r=a}),this._rememberMorpher(i,n),this},zoom(i,e){if(this._tryRetarget("zoom",i,e))return this;let t=new Tr(this._stepper).to(new ye(i));return this.queue(function(){t=t.from(this.element().zoom())},function(r){return this.element().zoom(t.at(r),e),t.done()},function(r,n){e=n,t.to(r)}),this._rememberMorpher("zoom",t),this},transform(i,e,t){if(e=i.relative||e,this._isDeclarative&&!e&&this._tryRetarget("transform",i))return this;let r=xe.isMatrixLike(i);t=i.affine!=null?i.affine:t??!r;let n=new Tr(this._stepper).type(t?No:xe),s,a,o,l,h;function d(){a=a||this.element(),s=s||Xc(i,a),h=new xe(e?void 0:a),a._addRunner(this),e||a._clearTransformRunnersBefore(this)}function c(m){e||this.clearTransform();let{x:g,y:x}=new it(s).transform(a._currentTransform(this)),y=new xe({...i,origin:[g,x]}),b=this._isDeclarative&&o?o:h;if(t){y=y.decompose(g,x),b=b.decompose(g,x);let A=y.rotate,C=b.rotate,I=[A-360,A,A+360],O=I.map(W=>Math.abs(W-C)),q=Math.min(...O),P=O.indexOf(q);y.rotate=I[P]}e&&(r||(y.rotate=i.rotate||0),this._isDeclarative&&l&&(b.rotate=l)),n.from(b),n.to(y);let S=n.at(m);return l=S.rotate,o=new xe(S),this.addTransform(o),a._addRunner(this),n.done()}function f(m){(m.origin||"center").toString()!==(i.origin||"center").toString()&&(s=Xc(m,a)),i={...m,origin:s}}return this.queue(d,c,f,!0),this._isDeclarative&&this._rememberMorpher("transform",n),this},x(i,e){return this._queueNumber("x",i)},y(i){return this._queueNumber("y",i)},dx(i=0){return this._queueNumberDelta("x",i)},dy(i=0){return this._queueNumberDelta("y",i)},dmove(i,e){return this.dx(i).dy(e)},_queueNumberDelta(i,e){if(e=new ye(e),this._tryRetarget(i,e))return this;let t=new Tr(this._stepper).to(e),r=null;return this.queue(function(){r=this.element()[i](),t.from(r),t.to(r+e)},function(n){return this.element()[i](t.at(n)),t.done()},function(n){t.to(r+new ye(n))}),this._rememberMorpher(i,t),this},_queueObject(i,e){if(this._tryRetarget(i,e))return this;let t=new Tr(this._stepper).to(e);return this.queue(function(){t.from(this.element()[i]())},function(r){return this.element()[i](t.at(r)),t.done()}),this._rememberMorpher(i,t),this},_queueNumber(i,e){return this._queueObject(i,new ye(e))},cx(i){return this._queueNumber("cx",i)},cy(i){return this._queueNumber("cy",i)},move(i,e){return this.x(i).y(e)},center(i,e){return this.cx(i).cy(e)},size(i,e){let t;return(!i||!e)&&(t=this._element.bbox()),i||(i=t.width/t.height*e),e||(e=t.height/t.width*i),this.width(i).height(e)},width(i){return this._queueNumber("width",i)},height(i){return this._queueNumber("height",i)},plot(i,e,t,r){if(arguments.length===4)return this.plot([i,e,t,r]);if(this._tryRetarget("plot",i))return this;let n=new Tr(this._stepper).type(this._element.MorphArray).to(i);return this.queue(function(){n.from(this._element.array())},function(s){return this._element.plot(n.at(s)),n.done()}),this._rememberMorpher("plot",n),this},leading(i){return this._queueNumber("leading",i)},viewbox(i,e,t,r){return this._queueObject("viewbox",new Gt(i,e,t,r))},update(i){return typeof i!="object"?this.update({offset:arguments[0],color:arguments[1],opacity:arguments[2]}):(i.opacity!=null&&this.attr("stop-opacity",i.opacity),i.color!=null&&this.attr("stop-color",i.color),i.offset!=null&&this.attr("offset",i.offset),this)}});ge(Vi,{rx:lu,ry:hu,from:i2,to:r2});be(Vi,"Runner");Eo=class extends Vt{constructor(e,t=e){super(qe("svg",e),t),this.namespace()}defs(){return this.isRoot()?Ti(this.node.querySelector("defs"))||this.put(new bo):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof Te.window.SVGElement)&&this.node.parentNode.nodeName!=="#document-fragment"}namespace(){return this.isRoot()?this.attr({xmlns:nu,version:"1.1"}).attr("xmlns:xlink",Lo,_0).attr("xmlns:svgjs",bw,_0):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,_0).attr("xmlns:svgjs",null,_0)}root(){return this.isRoot()?this:super.root()}};fe({Container:{nested:Fe(function(){return this.put(new Eo)})}});be(Eo,"Svg",!0);So=class extends Vt{constructor(e,t=e){super(qe("symbol",e),t)}};fe({Container:{symbol:Fe(function(){return this.put(new So)})}});be(So,"Symbol");l2={__proto__:null,plain:JM,length:eT,x:tT,y:iT,move:rT,cx:nT,cy:sT,center:aT,ax:oT,ay:lT,amove:hT,build:dT},Ce=class extends Dt{constructor(e,t=e){super(qe("text",e),t),this.dom.leading=new ye(1.3),this._rebuild=!0,this._build=!1}leading(e){return e==null?this.dom.leading:(this.dom.leading=new ye(e),this.rebuild())}rebuild(e){if(typeof e=="boolean"&&(this._rebuild=e),this._rebuild){let t=this,r=0,n=this.dom.leading;this.each(function(s){let a=Te.window.getComputedStyle(this.node).getPropertyValue("font-size"),o=n*new ye(a);this.dom.newLined&&(this.attr("x",t.attr("x")),this.text()===` +`?r+=o:(this.attr("dy",s?o+r:0),r=0))}),this.fire("rebuild")}return this}setData(e){return this.dom=e,this.dom.leading=new ye(e.leading||1.3),this}text(e){if(e===void 0){let t=this.node.childNodes,r=0;e="";for(let n=0,s=t.length;n(i.attr("href")||"").includes(this.id()))}}});Qa.prototype.MorphArray=or;me(Qa,"TextPath");Gl=class extends Tt{constructor(e,t=e){super(Ie("use",e),t)}use(e,t){return this.attr("href",(t||"")+"#"+e,Ja)}};oe({Container:{use:ze(function(i,e){return this.put(new Gl).use(i,e)})}});me(Gl,"Use");Me=Mt;ce([Wa,Va,Ci,zn,ys],Ot("viewbox"));ce([In,Dn,_i,Ui],Ot("marker"));ce(Te,Ot("Text"));ce(Ui,Ot("Path"));ce(Ua,Ot("Defs"));ce([Te,Ms],Ot("Tspan"));ce([Pe,vs,Ln,Li],Ot("radius"));ce(_n,Ot("EventTarget"));ce($r,Ot("Dom"));ce(fi,Ot("Element"));ce(Tt,Ot("Shape"));ce([Dt,Ul],Ot("Container"));ce(Ln,Ot("Gradient"));ce(Li,Ot("Runner"));ar.extend(ty());Ab([fe,ui,Rt,ue,Ur,Hi,or,Ye]);kb()});var Wl=qi((pF,zp)=>{"use strict";var Yl=function(e){return aw(e)&&!ow(e)};function aw(i){return!!i&&typeof i=="object"}function ow(i){var e=Object.prototype.toString.call(i);return e==="[object RegExp]"||e==="[object Date]"||dw(i)}var lw=typeof Symbol=="function"&&Symbol.for,hw=lw?Symbol.for("react.element"):60103;function dw(i){return i.$$typeof===hw}function cw(i){return Array.isArray(i)?[]:{}}function eo(i,e){var t=e&&e.clone===!0;return t&&Yl(i)?Ss(cw(i),i,e):i}function Lp(i,e,t){var r=i.slice();return e.forEach(function(n,s){typeof r[s]>"u"?r[s]=eo(n,t):Yl(n)?r[s]=Ss(i[s],n,t):i.indexOf(n)===-1&&r.push(eo(n,t))}),r}function uw(i,e,t){var r={};return Yl(i)&&Object.keys(i).forEach(function(n){r[n]=eo(i[n],t)}),Object.keys(e).forEach(function(n){!Yl(e[n])||!i[n]?r[n]=eo(e[n],t):r[n]=Ss(i[n],e[n],t)}),r}function Ss(i,e,t){var r=Array.isArray(e),n=Array.isArray(i),s=t||{arrayMerge:Lp},a=r===n;if(a)if(r){var o=s.arrayMerge||Lp;return o(i,e,t)}else return uw(i,e,t);else return eo(e,t)}Ss.all=function(e,t){if(!Array.isArray(e)||e.length<2)throw new Error("first argument should be an array with at least two elements");return e.reduce(function(r,n){return Ss(r,n,t)})};var fw=Ss;zp.exports=fw});var Vl,mw,Ip,to,io=M(()=>{Vl={paddingX:15,paddingY:5,imgMaxWidth:200,imgMaxHeight:100,iconSize:20,lineWidth:1,lineColor:"#549688",lineDasharray:"none",lineFlow:!1,lineFlowDuration:1,lineFlowForward:!0,lineStyle:"straight",rootLineKeepSameInCurve:!0,rootLineStartPositionKeepSameInCurve:!1,lineRadius:5,showLineMarker:!1,generalizationLineWidth:1,generalizationLineColor:"#549688",generalizationLineMargin:0,generalizationNodeMargin:20,associativeLineWidth:2,associativeLineColor:"rgb(51, 51, 51)",associativeLineActiveWidth:8,associativeLineActiveColor:"rgba(2, 167, 240, 1)",associativeLineDasharray:"6,4",associativeLineTextColor:"rgb(51, 51, 51)",associativeLineTextFontSize:14,associativeLineTextLineHeight:1.2,associativeLineTextFontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",backgroundColor:"#fafafa",backgroundImage:"none",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundSize:"cover",nodeUseLineStyle:!1,root:{shape:"rectangle",fillColor:"#549688",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#fff",fontSize:16,fontWeight:"bold",fontStyle:"normal",borderColor:"transparent",borderWidth:0,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},second:{shape:"rectangle",marginX:100,marginY:40,fillColor:"#fff",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#565656",fontSize:16,fontWeight:"normal",fontStyle:"normal",borderColor:"#549688",borderWidth:1,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},node:{shape:"rectangle",marginX:50,marginY:0,fillColor:"transparent",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#6a6d6c",fontSize:14,fontWeight:"normal",fontStyle:"normal",borderColor:"transparent",borderWidth:0,borderRadius:5,borderDasharray:"none",textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},generalization:{shape:"rectangle",marginX:100,marginY:40,fillColor:"#fff",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#565656",fontSize:16,fontWeight:"normal",fontStyle:"normal",borderColor:"#549688",borderWidth:1,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"}},mw=["lineWidth","lineColor","lineDasharray","lineStyle","generalizationLineWidth","generalizationLineColor","associativeLineWidth","associativeLineColor","associativeLineActiveWidth","associativeLineActiveColor","associativeLineTextColor","associativeLineTextFontSize","associativeLineTextLineHeight","associativeLineTextFontFamily","backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize","rootLineKeepSameInCurve","rootLineStartPositionKeepSameInCurve","showLineMarker","lineRadius","hoverRectColor","hoverRectRadius","lineFlow","lineFlowDuration","lineFlowForward","textAlign"],Ip=i=>{let e=Object.keys(i);for(let t=0;tr===e[t]))return!1;return!0},to=["lineColor","lineDasharray","lineWidth","lineMarkerDir","lineFlow","lineFlowDuration","lineFlowForward"]});var Rp,se,Pt,Jl,As,Ft,cc,Bn,uc,Dp,mi,Op,qt,Yr,Bp,Pp,Fp,Xl,ks,Cs,pw,ct,qp,Hp,On,Bt,Kl,Up,ro,$p,no,fc,e0,gw,Zl,t0,Gr,jp,Gp,Pn,Yp,Wp,Fn,Vp,Xp,_s,Ls,so,qn,Nt,zs,Ee,i0,Wr,Ql,mc,pc,Kp,r0,Zp,Qp,Jp,gc,ao,xc,vc,e3,t3,yc,i3,xw,MF,Vr,Hn,$i,oo,bc,r3,he=M(()=>{qd();Oe();Jm();ht();Rp=ot(Wl());io();se=(i,e,t,r,n,s=0,a=0,o=[])=>{let l=!1;if(t&&(l=t(i,e,n,s,a,o)),!l&&i.children&&i.children.length>0){let h=s+1;i.children.forEach((d,c)=>{se(d,i,t,r,!1,h,c,[...o,i])})}r&&r(i,e,n,s,a,o)},Pt=(i,e)=>{let t=[i],r=!1;for(e(i,null)==="stop"&&(r=!0);t.length&&!r;){let n=t.shift();n.children&&n.children.length&&n.children.forEach(s=>{r||(t.push(s),e(s,n)==="stop"&&(r=!0))})}},Jl=(i,e,t,r)=>{let n=i/e,s=[];if(t&&r)if(i<=t&&e<=r)s=[i,e];else{let a=t/r;n>a?s=[t,t/n]:s=[n*r,r]}else t?i<=t?s=[i,e]:s=[t,t/n]:r&&(e<=r?s=[i,e]:s=[n*r,r]);return s},As=i=>{i=i.replace(/
    /gim,` -`);let e=document.createElement("div");return e.innerHTML=i,i=e.textContent,i},Ft=i=>{try{return JSON.parse(JSON.stringify(i))}catch{return null}},cc=(i,e,t=!1)=>(i.data=Ft(e.data),t&&(i.data.isActive=!1,Hn(i.data).forEach(n=>{n.isActive=!1})),i.children=[],e.children&&e.children.length>0&&e.children.forEach((r,n)=>{i.children[n]=cc({},r,t)}),Object.keys(e).forEach(r=>{!["data","children"].includes(r)&&!/^_/.test(r)&&(i[r]=e[r])}),i),Bn=(i,e,t=!1,r=!0)=>{let n=e.nodeData?e.nodeData:e;return i.data=Ft(n.data),r?delete i.data.uid:i.data.uid||(i.data.uid=ct()),t&&(i.data.isActive=!1),i.children=[],e.children&&e.children.length>0?e.children.forEach((s,a)=>{i.children[a]=Bn({},s,t,r)}):e.nodeData&&e.nodeData.children&&e.nodeData.children.length>0&&e.nodeData.children.forEach((s,a)=>{i.children[a]=Bn({},s,t,r)}),Object.keys(n).forEach(s=>{!["data","children"].includes(s)&&!/^_/.test(s)&&(i[s]=n[s])}),i},uc=(i,e=!1)=>new Promise((t,r)=>{let n=new Image;n.setAttribute("crossOrigin","anonymous"),n.onload=()=>{try{let s=document.createElement("canvas");s.width=n.width,s.height=n.height,s.getContext("2d").drawImage(n,0,0,n.width,n.height),e?s.toBlob(o=>{t(o)}):t(s.toDataURL())}catch(s){r(s)}},n.onerror=s=>{r(s)},n.src=i}),Dp=(i,e)=>{let t=document.createElement("a");t.href=i,t.download=e,t.click()},mi=(i,e=300,t)=>{let r=null;return(...n)=>{r||(r=setTimeout(()=>{i.call(t,...n),r=null},e))}},Op=(i,e=300,t)=>{let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{r=null,i.apply(t,n)},e)}},qt=(i,e=()=>{})=>{let t=0,r=i.length;if(r<=0)return e();let n=()=>{if(t>=r){e();return}i[t](),setTimeout(()=>{t++,n()},0)};n()},Yr=i=>i*(Math.PI/180),Bp=i=>i.replace(/([a-z])([A-Z])/g,(...e)=>e[1]+"-"+e[2].toLowerCase()),Pp=function(i,e){let t=!1,r=null,n=()=>{t=!1,e?i.call(e):i()};if(typeof MutationObserver<"u"){let s=1,a=new MutationObserver(n),o=document.createTextNode(s);a.observe(o,{characterData:!0}),r=function(){s=(s+1)%2,o.data=s}}else r=setTimeout;return function(){t||(t=!0,r(n,0))}},Fp=(i,e,t=0,r=0)=>{let n=i.elRect,{scaleX:s,scaleY:a,translateX:o,translateY:l}=i.draw.transform(),{left:h,top:d,width:c,height:f}=e,m=(h+c)*s+o,g=(d+f)*a+l;h=h*s+o,d=d*a+l;let x=0,v=0;return h<0+t&&(x=-h+t),m>n.width-t&&(x=-(m-n.width)-t),d<0+r&&(v=-d+r),g>n.height-r&&(v=-(g-n.height)-r),{isOuter:x!==0||v!==0,offsetLeft:x,offsetTop:v}},Xl=null,ks=i=>(Xl||(Xl=document.createElement("div")),Xl.innerHTML=i,Xl.textContent),Cs=i=>new Promise((e,t)=>{let r=new FileReader;r.onload=n=>{e(n.target.result)},r.onerror=n=>{t(n)},r.readAsDataURL(i)}),pw=i=>new Promise(e=>{let t=new Image;t.src=i,t.onload=()=>{e({width:t.width,height:t.height})},t.onerror=()=>{e({width:0,height:0})}}),ct=()=>Da(),qp=i=>new Promise((e,t)=>{let r=new FileReader;r.readAsDataURL(i),r.onload=async n=>{let s=n.target.result,a=await pw(s);e({url:s,size:a})},r.onerror=n=>{t(n)}}),Hp=i=>([[" "," "]].forEach(e=>{i=i.replace(new RegExp(e[0],"g"),e[1])}),i),On=i=>Object.prototype.toString.call(i).slice(8,-1),Bt=i=>i==null||i==="",Kl=null,Up=i=>{Kl||(Kl=document.createElement("div")),Kl.innerHTML=i;for(let e=Kl.childNodes,t=e.length;t--;)if(e[t].nodeType==1)return!0;return!1},ro=null,$p=(i,e,t)=>{ro||(ro=document.createElement("div")),ro.innerHTML=i;let r=n=>{n.childNodes.forEach(a=>{a.nodeType===1?r(a):a.nodeType===3&&n.replaceChild(document.createTextNode(a.nodeValue.replace(new RegExp(e,"g"),t)),a)})};return r(ro),ro.innerHTML},no=i=>(i=String(i).replace(/\s+/g,""),["#fff","#ffffff","#FFF","#FFFFFF","rgb(255,255,255)"].includes(i)||/rgba\(255,255,255,[^)]+\)/.test(i)),fc=i=>(i=String(i).replace(/\s+/g,""),["","transparent"].includes(i)||/rgba\(\d+,\d+,\d+,0\)/.test(i)),e0=i=>{let{lineColor:e,root:t,second:r,node:n}=i,s=[e,t.fillColor,t.color,r.fillColor,r.color,n.fillColor,n.color,t.borderColor,r.borderColor,n.borderColor];for(let a=0;a{let e=t=>{t.childNodes.forEach(n=>{n.nodeType===1&&(n.classList.contains("ql-formula")?n.parentNode.removeChild(n):e(n))})};e(i)},Zl=null,t0=i=>{Zl||(Zl=document.createElement("div")),Zl.innerHTML=i;let e=Zl.childNodes,t="";for(let r=0;r{Gr||(Gr=document.createElement("div")),Gr.innerHTML=i;let e=Gr.querySelectorAll(".ql-formula");Array.from(e).forEach(n=>{let s=document.createTextNode("$smmformula$");n.parentNode.replaceChild(s,n)});let t=Gr.childNodes,r=[];for(let n=0;n`

    ${Wr(n)}

    `).join(""),e.length>0){i=i.replace(/\$smmformula\$/g,''),Gr.innerHTML=i;let n=Gr.querySelectorAll(".smmformula");Array.from(n).forEach((s,a)=>{s.parentNode.replaceChild(e[a],s)}),i=Gr.innerHTML}return i},Gp=(i,e)=>{let t={};return Object.keys(e).forEach(r=>{let n=i[r],s=e[r];if(On(n)!==On(s)){t[r]=s;return}if(On(n)==="Object"){if(JSON.stringify(n)!==JSON.stringify(s)){t[r]=s;return}}else if(n!==s){t[r]=s;return}}),t},Pn=i=>/^_/.test(i)?!1:!us.includes(i),Yp=i=>{let e=[...to],t=Object.keys(i);for(let r=0;ri.reduce((e,t)=>{let r=e.find(n=>n.type===t.type);return r?t.list.forEach(n=>{let s=r.list.find(a=>a.name===n.name);s?s.icon=n.icon:r.list.push(n)}):e.push({...t}),e},[]),Fn=i=>{let e=[];return i.forEach(t=>{i.find(r=>r.uid!==t.uid&&r.isAncestor(t))||e.push(t)}),e},Vp=i=>{let e={},t={};i.forEach(n=>{let s=n.parent;if(s){let a=s.uid;t[a]=s;let o=n.getIndexInBrothers(),l={node:n,index:o};e[a]?e[a].find(h=>h.index===l.index)||e[a].push(l):e[a]=[l]}});let r=[];return Object.keys(e).forEach(n=>{if(e[n].length>1){let s=e[n].map(a=>a.index).sort((a,o)=>a-o);r.push({node:t[n],range:[s[0],s[s.length-1]]})}else r.push({node:e[n][0].node})}),r},Xp=(i,e,t,r,n,s,a,o)=>e>n&&s>i&&r>a&&o>t,_s=i=>{let e=window.getSelection(),t=document.createRange();t.selectNodeContents(i),t.collapse(),e.removeAllRanges(),e.addRange(t)},Ls=i=>{let e=window.getSelection(),t=document.createRange();t.selectNodeContents(i),e.removeAllRanges(),e.addRange(t)},so=(i,e={})=>{e={...e},e&&e.richText&&e.resetRichText&&delete e.resetRichText;let r=n=>{n.forEach(s=>{s.data={...s.data,...e},s.children&&s.children.length>0&&r(s.children)})};return r(i),i},qn=(i,e=!1,t=null,r=!1)=>{let n=s=>{s.forEach(a=>{a.data||(a.data={}),(e||Bt(a.data.uid))&&(a.data.uid=ct()),r&&Hn(a.data).forEach(l=>{(e||Bt(l.uid))&&(l.uid=ct())}),t&&t(a),a.children&&a.children.length>0&&n(a.children)})};return n(i),i},Nt=i=>i?Array.isArray(i)?i:[i]:[],zs=i=>i.parent?i.parent.nodeData.children.findIndex(e=>e.data.uid===i.uid):0,Ee=(i,e)=>e.findIndex(t=>t.uid===i.uid),i0=i=>{let e=0;for(let n=0;n([["&","&"],["<","<"],[">",">"]].forEach(e=>{i=i.replace(new RegExp(e[0],"g"),e[1])}),i),Ql=(i,e)=>{let t=On(i);if(t!==On(e))return!1;if(t==="Object"){let r=Object.keys(i),n=Object.keys(e);if(r.length!==n.length)return!1;for(let s=0;snavigator.clipboard&&typeof navigator.clipboard.read=="function",pc=i=>{navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(JSON.stringify(i))},Kp=async()=>{let i=null,e=null;if(mc()){let t=await navigator.clipboard.read();if(t&&t.length>0)for(let r of t)for(let n of r.types)/^image\//.test(n)?e=await r.getType(n):n==="text/plain"&&(i=await(await r.getType(n)).text())}return{text:i,img:e}},r0=i=>{if(!i||!i.parent)return;let e=zs(i);e!==-1&&i.parent.nodeData.children.splice(e,1)},Zp=i=>(Zm.forEach(e=>{i=i.replace(new RegExp(`<${e}([^>]*)>`,"g"),`<${e} $1 />`)}),i),Qp=(i,e)=>{if(i.length!==e.length)return!1;for(let t=0;tr.uid===i[t].uid))return!1;return!0},Jp=()=>{let i=navigator.userAgent.match(/\s+Chrome\/(.*)\s+/);return i&&i[1]?Number.parseFloat(i[1]):""},gc=i=>({simpleMindMap:!0,data:i}),ao=i=>{let e=null;if(typeof i=="string")try{let r=JSON.parse(i);typeof r=="object"&&r.simpleMindMap&&(e=r.data)}catch{}else typeof i=="object"&&i.simpleMindMap&&(e=i.data);let t=!!e;return{isSmm:t,data:t?e:String(i)}},xc=(i,e)=>{i.preventDefault();let t=window.getSelection();if(!t.rangeCount)return;t.deleteFromDocument(),e=e||i.clipboardData.getData("text"),e=Wr(e),e=ks(e);let r=e.split(/\n/g),n=document.createDocumentFragment();r.forEach((s,a)=>{let o=document.createTextNode(s);if(n.appendChild(o),a{let e={},t=(r,n)=>{let s=r.data.uid;n&&n.children.push(s),e[s]={isRoot:!n,data:{...r.data},children:[]},r.children&&r.children.length>0&&r.children.forEach(a=>{t(a,e[s])})};return t(i,null),e},e3=(i,e)=>{let t=i.x+i.width/2,r=i.y+i.height/2,n=e.x+e.width/2,s=e.y+e.height/2;return tn&&rn&&r>s?"right-bottom":ts?"left-bottom":tn&&r===s?"right":t===n&&rs?"bottom":"overlap"},t3=({addContentToHeader:i,addContentToFooter:e})=>{let t=[],r=null,n=0,s=null,a=0,o=(l,h)=>{if(typeof l=="function"){let d=l();if(!d)return;let{el:c,cssText:f,height:m}=d;if(c instanceof HTMLElement){$i(c);let g=Vr({el:c,height:m});h(g,m)}f&&t.push(f)}};return o(i,(l,h)=>{r=l,n=h}),o(e,(l,h)=>{s=l,a=h}),{cssTextList:t,header:r,headerHeight:n,footer:s,footerHeight:a}},yc=(i,e=0,t=0,r=0,n=0,s=!1,a=!1)=>{let o=1/0,l=-1/0,h=1/0,d=-1/0,c=(f,m)=>{if(!(m&&s)&&f.group)try{let{x:g,y:x,width:v,height:b}=f.group.findOne(".smm-node-shape").rbox();gl&&(l=g+v),xd&&(d=x+b)}catch{}!a&&f._generalizationList.length>0&&f._generalizationList.forEach(g=>{c(g.generalizationNode)}),f.children&&f.children.forEach(g=>{c(g)})};return c(i,!0),o=o-e+r,h=h-t+n,l=l-e+r,d=d-t+n,{left:o,top:h,width:l-o,height:d-h}},i3=(i,e=0,t=0,r=0,n=0)=>{let s=1/0,a=-1/0,o=1/0,l=-1/0;return i.forEach(h=>{let{left:d,top:c,width:f,height:m}=yc(h,e,t,r,n,!1,!0);da&&(a=d+f),cl&&(l=c+m)}),{left:s,top:o,width:a-s,height:l-o}},xw=()=>{if(document.documentElement.requestFullScreen)return"fullscreenchange";if(document.documentElement.webkitRequestFullScreen)return"webkitfullscreenchange";if(document.documentElement.mozRequestFullScreen)return"mozfullscreenchange";if(document.documentElement.msRequestFullscreen)return"msfullscreenchange"},MF=xw(),Vr=({el:i,width:e,height:t})=>{let r=new Ts;return e!==void 0&&r.width(e),t!==void 0&&r.height(t),r.add(i),r},Hn=i=>{let e=i.generalization;return e?Array.isArray(e)?e:[e]:[]},$i=i=>{i.setAttribute("xmlns","http://www.w3.org/1999/xhtml")},oo=i=>(i=[...i],i.sort((e,t)=>e.sortIndex-t.sortIndex),i),bc=(i,e)=>(0,Rp.default)(i,e,{arrayMerge:(t,r)=>r}),r3=i=>{let e={};return Qm.forEach(t=>{let r=i.style.merge(t);t==="fontSize"&&(r=r+"px"),e[t]=r}),e}});var n3,wc,n0,lo,s0=M(()=>{he();n3=["backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize"],wc=["gradientStyle","startColor","endColor","startDir","endDir","fillColor","borderColor","borderWidth","borderDasharray"],n0=class i{static setBackgroundStyle(e,t){if(!e)return;if(!i.cacheStyle){i.cacheStyle={};let l=window.getComputedStyle(e);n3.forEach(h=>{i.cacheStyle[h]=l[h]})}let{backgroundColor:r,backgroundImage:n,backgroundRepeat:s,backgroundPosition:a,backgroundSize:o}=t;e.style.backgroundColor=r,n&&n!=="none"?(e.style.backgroundImage=`url(${n})`,e.style.backgroundRepeat=s,e.style.backgroundPosition=a,e.style.backgroundSize=o):e.style.backgroundImage="none"}static removeBackgroundStyle(e){i.cacheStyle&&(n3.forEach(t=>{e.style[t]=i.cacheStyle[t]}),i.cacheStyle=null)}constructor(e){this.ctx=e,this._markerPath=null,this._marker=null,this._gradient=null}merge(e,t){let r=this.ctx.mindMap.themeConfig,n=null,s=!1;t?(s=!0,n=r):this.ctx.isGeneralization?n=r.generalization:this.ctx.layerIndex===0?n=r.root:this.ctx.layerIndex===1?n=r.second:n=r.node;let a="";return this.getSelfStyle(e)!==void 0?a=this.getSelfStyle(e):n[e]!==void 0?a=n[e]:a=r[e],s||this.addToEffectiveStyles({[e]:a}),a}getStyle(e,t){return this.merge(e,t)}getSelfStyle(e){return this.ctx.getData(e)}addToEffectiveStyles(e){this.ctx.mindMap.painter&&(this.ctx.effectiveStyles={...this.ctx.effectiveStyles,...e})}rect(e){this.shape(e),e.radius(this.merge("borderRadius"))}shape(e){let t={};wc.forEach(r=>{t[r]=this.merge(r)}),t.gradientStyle?(this._gradient||(this._gradient=this.ctx.nodeDraw.gradient("linear")),this._gradient.update(r=>{r.stop(0,t.startColor),r.stop(1,t.endColor)}),this._gradient.from(...t.startDir).to(...t.endDir),e.fill(this._gradient)):e.fill({color:t.fillColor}),e.stroke({color:t.borderColor,width:t.borderWidth,dasharray:t.borderDasharray})}text(e){let t={color:this.merge("color"),fontFamily:this.merge("fontFamily"),fontSize:this.merge("fontSize"),fontWeight:this.merge("fontWeight"),fontStyle:this.merge("fontStyle"),textDecoration:this.merge("textDecoration")};e.fill({color:t.color}).css({"font-family":t.fontFamily,"font-size":t.fontSize+"px","font-weight":t.fontWeight,"font-style":t.fontStyle,"text-decoration":t.textDecoration})}domText(e,t=1){let r={color:this.merge("color"),fontFamily:this.merge("fontFamily"),fontSize:this.merge("fontSize"),fontWeight:this.merge("fontWeight"),fontStyle:this.merge("fontStyle"),textDecoration:this.merge("textDecoration"),textAlign:this.merge("textAlign")};e.style.color=r.color,e.style.textDecoration=r.textDecoration,e.style.fontFamily=r.fontFamily,e.style.fontSize=r.fontSize*t+"px",e.style.fontWeight=r.fontWeight||"normal",e.style.fontStyle=r.fontStyle,e.style.textAlign=r.textAlign}tagText(e,t){e.fill({color:"#fff"}).css({"font-size":t.fontSize+"px"})}tagRect(e,t){e.fill({color:t.fill}),t.radius&&e.radius(t.radius)}iconNode(e,t){e.attr({fill:t||this.merge("color")})}line(e,{width:t,color:r,dasharray:n}={},s,a){let{customHandleLine:o}=this.ctx.mindMap.opt;if(typeof o=="function"&&o(this.ctx,e,{width:t,color:r,dasharray:n}),e.stroke({color:r,dasharray:n,width:t}).fill({color:"none"}),s){let l=this.merge("showLineMarker",!0),h=a.style;if(l){h._marker=h._marker||h.createMarker(),h._markerPath.stroke({color:r}).fill({color:r}),e.attr("marker-start",""),e.attr("marker-end","");let d=h.merge("lineMarkerDir");e.marker(d,h._marker)}else h._marker&&(e.attr("marker-start",""),e.attr("marker-end",""),h._marker.remove(),h._marker=null)}}createMarker(){return this.ctx.lineDraw.marker(20,20,e=>{e.ref(8,5),e.size(20,20),e.attr("markerUnits","userSpaceOnUse"),e.attr("orient","auto-start-reverse"),this._markerPath=e.path("M0,0 L2,5 L0,10 L10,5 Z")})}generalizationLine(e){e.stroke({width:this.merge("generalizationLineWidth",!0),color:this.merge("generalizationLineColor",!0)}).fill({color:"none"})}iconBtn(e,t,r){let{color:n,fill:s,fontSize:a,fontColor:o}=this.ctx.mindMap.opt.expandBtnStyle||{color:"#808080",fill:"#fff",fontSize:12,strokeColor:"#333333",fontColor:"#333333"};e.fill({color:n}),t.fill({color:n}),r.fill({color:s}),this.ctx.mindMap.opt.isShowExpandNum&&e.attr({"font-size":a+"px","font-color":o})}hasCustomStyle(){let e=!1;return Object.keys(this.ctx.getData()).forEach(t=>{Pn(t)&&(e=!0)}),e}getCustomStyle(){let e={};return Object.keys(this.ctx.getData()).forEach(t=>{Pn(t)&&(e[t]=this.ctx.getData(t))}),e}hoverNode(e){let t=this.merge("hoverRectColor")||this.ctx.mindMap.opt.hoverRectColor,r=this.merge("hoverRectRadius");e.radius(r).fill("none").stroke({color:t})}onRemove(){this._marker&&(this._marker.remove(),this._marker=null),this._markerPath&&(this._markerPath.remove(),this._markerPath=null),this._gradient&&(this._gradient.remove(),this._gradient=null)}};n0.cacheStyle=null;lo=n0});var ho,s3,Mc=M(()=>{ht();Oe();ho=class{constructor(e){this.node=e,this.mindMap=e.mindMap}getShapePadding(e,t,r,n){let s=this.node.getShape(),a=15,o=5,l=e+r*2,h=t+n*2,d=Math.abs(l-h);switch(s){case A.SHAPE.ROUNDED_RECTANGLE:return{paddingX:t>e?(t-e)/2:0,paddingY:0};case A.SHAPE.DIAMOND:return{paddingX:e/2,paddingY:t/2};case A.SHAPE.PARALLELOGRAM:return{paddingX:r<=0?a:0,paddingY:0};case A.SHAPE.OUTER_TRIANGULAR_RECTANGLE:return{paddingX:r<=0?a:0,paddingY:0};case A.SHAPE.INNER_TRIANGULAR_RECTANGLE:return{paddingX:r<=0?a:0,paddingY:0};case A.SHAPE.ELLIPSE:return{paddingX:r<=0?a:0,paddingY:n<=0?o:0};case A.SHAPE.CIRCLE:return{paddingX:h>l?d/2:0,paddingY:ht.name===e)}createShape(){let e=this.node.getShape(),t=null;if(e===A.SHAPE.RECTANGLE?t=this.createRect():e===A.SHAPE.DIAMOND?t=this.createDiamond():e===A.SHAPE.PARALLELOGRAM?t=this.createParallelogram():e===A.SHAPE.ROUNDED_RECTANGLE?t=this.createRoundedRectangle():e===A.SHAPE.OCTAGONAL_RECTANGLE?t=this.createOctagonalRectangle():e===A.SHAPE.OUTER_TRIANGULAR_RECTANGLE?t=this.createOuterTriangularRectangle():e===A.SHAPE.INNER_TRIANGULAR_RECTANGLE?t=this.createInnerTriangularRectangle():e===A.SHAPE.ELLIPSE?t=this.createEllipse():e===A.SHAPE.CIRCLE&&(t=this.createCircle()),!t){let r=this.getShapeFromExtendList(e);r&&(t=r.createShape(this.node))}return t||this.createRect()}getNodeSize(){let e=this.node.getBorderWidth(),{width:t,height:r}=this.node;return t-=e,r-=e,{width:t,height:r}}createPath(e){let{customCreateNodePath:t}=this.mindMap.opt;return t?Me(t(e)):new Ui().plot(e)}createPolygon(e){let{customCreateNodePolygon:t}=this.mindMap.opt;return t?Me(t(e)):new _i().plot(e)}createRect(){let{width:e,height:t}=this.getNodeSize(),r=this.node.style.merge("borderRadius"),n=` +`);for(let t=0,r=e.length;t(i.attr("href")||"").includes(this.id()))}}});_o.prototype.MorphArray=Er;be(_o,"TextPath");R0=class extends Dt{constructor(e,t=e){super(qe("use",e),t)}use(e,t){return this.attr("href",(t||"")+"#"+e,Lo)}};fe({Container:{use:Fe(function(i,e){return this.put(new R0).use(i,e)})}});be(R0,"Use");Ae=Rt;ge([Eo,So,ji,rs,Ks],Wt("viewbox"));ge([ns,as,Gi,ar],Wt("marker"));ge(Ce,Wt("Text"));ge(ar,Wt("Path"));ge(bo,Wt("Defs"));ge([Ce,Js],Wt("Tspan"));ge([Ve,Xs,is,Vi],Wt("radius"));ge(ts,Wt("EventTarget"));ge(dn,Wt("Dom"));ge(Ei,Wt("Element"));ge(Dt,Wt("Shape"));ge([Vt,L0],Wt("Container"));ge(is,Wt("Gradient"));ge(Vi,Wt("Runner"));Nr.extend(gw());UM([ye,Ni,Gt,xe,hn,sr,Er,it]);$M()});var O0=rr((nU,c2)=>{"use strict";var D0=function(e){return wT(e)&&!MT(e)};function wT(i){return!!i&&typeof i=="object"}function MT(i){var e=Object.prototype.toString.call(i);return e==="[object RegExp]"||e==="[object Date]"||ET(i)}var TT=typeof Symbol=="function"&&Symbol.for,NT=TT?Symbol.for("react.element"):60103;function ET(i){return i.$$typeof===NT}function ST(i){return Array.isArray(i)?[]:{}}function Io(i,e){var t=e&&e.clone===!0;return t&&D0(i)?ra(ST(i),i,e):i}function d2(i,e,t){var r=i.slice();return e.forEach(function(n,s){typeof r[s]>"u"?r[s]=Io(n,t):D0(n)?r[s]=ra(i[s],n,t):i.indexOf(n)===-1&&r.push(Io(n,t))}),r}function AT(i,e,t){var r={};return D0(i)&&Object.keys(i).forEach(function(n){r[n]=Io(i[n],t)}),Object.keys(e).forEach(function(n){!D0(e[n])||!i[n]?r[n]=Io(e[n],t):r[n]=ra(i[n],e[n],t)}),r}function ra(i,e,t){var r=Array.isArray(e),n=Array.isArray(i),s=t||{arrayMerge:d2},a=r===n;if(a)if(r){var o=s.arrayMerge||d2;return o(i,e,t)}else return AT(i,e,t);else return Io(e,t)}ra.all=function(e,t){if(!Array.isArray(e)||e.length<2)throw new Error("first argument should be an array with at least two elements");return e.reduce(function(r,n){return ra(r,n,t)})};var kT=ra;c2.exports=kT});var B0,CT,u2,zo,Ro=T(()=>{B0={paddingX:15,paddingY:5,imgMaxWidth:200,imgMaxHeight:100,iconSize:20,lineWidth:1,lineColor:"#549688",lineDasharray:"none",lineFlow:!1,lineFlowDuration:1,lineFlowForward:!0,lineStyle:"straight",rootLineKeepSameInCurve:!0,rootLineStartPositionKeepSameInCurve:!1,lineRadius:5,showLineMarker:!1,generalizationLineWidth:1,generalizationLineColor:"#549688",generalizationLineMargin:0,generalizationNodeMargin:20,associativeLineWidth:2,associativeLineColor:"rgb(51, 51, 51)",associativeLineActiveWidth:8,associativeLineActiveColor:"rgba(2, 167, 240, 1)",associativeLineDasharray:"6,4",associativeLineTextColor:"rgb(51, 51, 51)",associativeLineTextFontSize:14,associativeLineTextLineHeight:1.2,associativeLineTextFontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",backgroundColor:"#fafafa",backgroundImage:"none",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundSize:"cover",nodeUseLineStyle:!1,root:{shape:"rectangle",fillColor:"#549688",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#fff",fontSize:16,fontWeight:"bold",fontStyle:"normal",borderColor:"transparent",borderWidth:0,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},second:{shape:"rectangle",marginX:100,marginY:40,fillColor:"#fff",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#565656",fontSize:16,fontWeight:"normal",fontStyle:"normal",borderColor:"#549688",borderWidth:1,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},node:{shape:"rectangle",marginX:50,marginY:0,fillColor:"transparent",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#6a6d6c",fontSize:14,fontWeight:"normal",fontStyle:"normal",borderColor:"transparent",borderWidth:0,borderRadius:5,borderDasharray:"none",textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],lineMarkerDir:"end",hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"},generalization:{shape:"rectangle",marginX:100,marginY:40,fillColor:"#fff",fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",color:"#565656",fontSize:16,fontWeight:"normal",fontStyle:"normal",borderColor:"#549688",borderWidth:1,borderDasharray:"none",borderRadius:5,textDecoration:"none",gradientStyle:!1,startColor:"#549688",endColor:"#fff",startDir:[0,0],endDir:[1,0],hoverRectColor:"",hoverRectRadius:5,textAlign:"left",imgPlacement:"top",tagPlacement:"right"}},CT=["lineWidth","lineColor","lineDasharray","lineStyle","generalizationLineWidth","generalizationLineColor","associativeLineWidth","associativeLineColor","associativeLineActiveWidth","associativeLineActiveColor","associativeLineTextColor","associativeLineTextFontSize","associativeLineTextLineHeight","associativeLineTextFontFamily","backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize","rootLineKeepSameInCurve","rootLineStartPositionKeepSameInCurve","showLineMarker","lineRadius","hoverRectColor","hoverRectRadius","lineFlow","lineFlowDuration","lineFlowForward","textAlign"],u2=i=>{let e=Object.keys(i);for(let t=0;tr===e[t]))return!1;return!0},zo=["lineColor","lineDasharray","lineWidth","lineMarkerDir","lineFlow","lineFlowDuration","lineFlowForward"]});var f2,de,Xt,U0,na,Kt,uu,ls,fu,m2,Si,p2,Zt,fn,g2,x2,y2,P0,sa,aa,_T,wt,v2,b2,os,Yt,F0,w2,Do,M2,Oo,mu,$0,LT,q0,j0,un,T2,N2,hs,E2,S2,ds,A2,k2,oa,la,Bo,cs,Ot,ha,Ie,G0,mn,H0,pu,gu,C2,V0,_2,L2,I2,xu,Po,yu,vu,z2,R2,bu,D2,IT,cU,pn,us,or,Fo,wu,O2,pe=T(()=>{Hc();$e();I3();yt();f2=pt(O0());Ro();de=(i,e,t,r,n,s=0,a=0,o=[])=>{let l=!1;if(t&&(l=t(i,e,n,s,a,o)),!l&&i.children&&i.children.length>0){let h=s+1;i.children.forEach((d,c)=>{de(d,i,t,r,!1,h,c,[...o,i])})}r&&r(i,e,n,s,a,o)},Xt=(i,e)=>{let t=[i],r=!1;for(e(i,null)==="stop"&&(r=!0);t.length&&!r;){let n=t.shift();n.children&&n.children.length&&n.children.forEach(s=>{r||(t.push(s),e(s,n)==="stop"&&(r=!0))})}},U0=(i,e,t,r)=>{let n=i/e,s=[];if(t&&r)if(i<=t&&e<=r)s=[i,e];else{let a=t/r;n>a?s=[t,t/n]:s=[n*r,r]}else t?i<=t?s=[i,e]:s=[t,t/n]:r&&(e<=r?s=[i,e]:s=[n*r,r]);return s},na=i=>{i=i.replace(/
    /gim,` +`);let e=document.createElement("div");return e.innerHTML=i,i=e.textContent,i},Kt=i=>{try{return JSON.parse(JSON.stringify(i))}catch{return null}},uu=(i,e,t=!1)=>(i.data=Kt(e.data),t&&(i.data.isActive=!1,us(i.data).forEach(n=>{n.isActive=!1})),i.children=[],e.children&&e.children.length>0&&e.children.forEach((r,n)=>{i.children[n]=uu({},r,t)}),Object.keys(e).forEach(r=>{!["data","children"].includes(r)&&!/^_/.test(r)&&(i[r]=e[r])}),i),ls=(i,e,t=!1,r=!0)=>{let n=e.nodeData?e.nodeData:e;return i.data=Kt(n.data),r?delete i.data.uid:i.data.uid||(i.data.uid=wt()),t&&(i.data.isActive=!1),i.children=[],e.children&&e.children.length>0?e.children.forEach((s,a)=>{i.children[a]=ls({},s,t,r)}):e.nodeData&&e.nodeData.children&&e.nodeData.children.length>0&&e.nodeData.children.forEach((s,a)=>{i.children[a]=ls({},s,t,r)}),Object.keys(n).forEach(s=>{!["data","children"].includes(s)&&!/^_/.test(s)&&(i[s]=n[s])}),i},fu=(i,e=!1)=>new Promise((t,r)=>{let n=new Image;n.setAttribute("crossOrigin","anonymous"),n.onload=()=>{try{let s=document.createElement("canvas");s.width=n.width,s.height=n.height,s.getContext("2d").drawImage(n,0,0,n.width,n.height),e?s.toBlob(o=>{t(o)}):t(s.toDataURL())}catch(s){r(s)}},n.onerror=s=>{r(s)},n.src=i}),m2=(i,e)=>{let t=document.createElement("a");t.href=i,t.download=e,t.click()},Si=(i,e=300,t)=>{let r=null;return(...n)=>{r||(r=setTimeout(()=>{i.call(t,...n),r=null},e))}},p2=(i,e=300,t)=>{let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{r=null,i.apply(t,n)},e)}},Zt=(i,e=()=>{})=>{let t=0,r=i.length;if(r<=0)return e();let n=()=>{if(t>=r){e();return}i[t](),setTimeout(()=>{t++,n()},0)};n()},fn=i=>i*(Math.PI/180),g2=i=>i.replace(/([a-z])([A-Z])/g,(...e)=>e[1]+"-"+e[2].toLowerCase()),x2=function(i,e){let t=!1,r=null,n=()=>{t=!1,e?i.call(e):i()};if(typeof MutationObserver<"u"){let s=1,a=new MutationObserver(n),o=document.createTextNode(s);a.observe(o,{characterData:!0}),r=function(){s=(s+1)%2,o.data=s}}else r=setTimeout;return function(){t||(t=!0,r(n,0))}},y2=(i,e,t=0,r=0)=>{let n=i.elRect,{scaleX:s,scaleY:a,translateX:o,translateY:l}=i.draw.transform(),{left:h,top:d,width:c,height:f}=e,m=(h+c)*s+o,g=(d+f)*a+l;h=h*s+o,d=d*a+l;let x=0,y=0;return h<0+t&&(x=-h+t),m>n.width-t&&(x=-(m-n.width)-t),d<0+r&&(y=-d+r),g>n.height-r&&(y=-(g-n.height)-r),{isOuter:x!==0||y!==0,offsetLeft:x,offsetTop:y}},P0=null,sa=i=>(P0||(P0=document.createElement("div")),P0.innerHTML=i,P0.textContent),aa=i=>new Promise((e,t)=>{let r=new FileReader;r.onload=n=>{e(n.target.result)},r.onerror=n=>{t(n)},r.readAsDataURL(i)}),_T=i=>new Promise(e=>{let t=new Image;t.src=i,t.onload=()=>{e({width:t.width,height:t.height})},t.onerror=()=>{e({width:0,height:0})}}),wt=()=>fo(),v2=i=>new Promise((e,t)=>{let r=new FileReader;r.readAsDataURL(i),r.onload=async n=>{let s=n.target.result,a=await _T(s);e({url:s,size:a})},r.onerror=n=>{t(n)}}),b2=i=>([[" "," "]].forEach(e=>{i=i.replace(new RegExp(e[0],"g"),e[1])}),i),os=i=>Object.prototype.toString.call(i).slice(8,-1),Yt=i=>i==null||i==="",F0=null,w2=i=>{F0||(F0=document.createElement("div")),F0.innerHTML=i;for(let e=F0.childNodes,t=e.length;t--;)if(e[t].nodeType==1)return!0;return!1},Do=null,M2=(i,e,t)=>{Do||(Do=document.createElement("div")),Do.innerHTML=i;let r=n=>{n.childNodes.forEach(a=>{a.nodeType===1?r(a):a.nodeType===3&&n.replaceChild(document.createTextNode(a.nodeValue.replace(new RegExp(e,"g"),t)),a)})};return r(Do),Do.innerHTML},Oo=i=>(i=String(i).replace(/\s+/g,""),["#fff","#ffffff","#FFF","#FFFFFF","rgb(255,255,255)"].includes(i)||/rgba\(255,255,255,[^)]+\)/.test(i)),mu=i=>(i=String(i).replace(/\s+/g,""),["","transparent"].includes(i)||/rgba\(\d+,\d+,\d+,0\)/.test(i)),$0=i=>{let{lineColor:e,root:t,second:r,node:n}=i,s=[e,t.fillColor,t.color,r.fillColor,r.color,n.fillColor,n.color,t.borderColor,r.borderColor,n.borderColor];for(let a=0;a{let e=t=>{t.childNodes.forEach(n=>{n.nodeType===1&&(n.classList.contains("ql-formula")?n.parentNode.removeChild(n):e(n))})};e(i)},q0=null,j0=i=>{q0||(q0=document.createElement("div")),q0.innerHTML=i;let e=q0.childNodes,t="";for(let r=0;r{un||(un=document.createElement("div")),un.innerHTML=i;let e=un.querySelectorAll(".ql-formula");Array.from(e).forEach(n=>{let s=document.createTextNode("$smmformula$");n.parentNode.replaceChild(s,n)});let t=un.childNodes,r=[];for(let n=0;n`

    ${mn(n)}

    `).join(""),e.length>0){i=i.replace(/\$smmformula\$/g,''),un.innerHTML=i;let n=un.querySelectorAll(".smmformula");Array.from(n).forEach((s,a)=>{s.parentNode.replaceChild(e[a],s)}),i=un.innerHTML}return i},N2=(i,e)=>{let t={};return Object.keys(e).forEach(r=>{let n=i[r],s=e[r];if(os(n)!==os(s)){t[r]=s;return}if(os(n)==="Object"){if(JSON.stringify(n)!==JSON.stringify(s)){t[r]=s;return}}else if(n!==s){t[r]=s;return}}),t},hs=i=>/^_/.test(i)?!1:!$s.includes(i),E2=i=>{let e=[...zo],t=Object.keys(i);for(let r=0;ri.reduce((e,t)=>{let r=e.find(n=>n.type===t.type);return r?t.list.forEach(n=>{let s=r.list.find(a=>a.name===n.name);s?s.icon=n.icon:r.list.push(n)}):e.push({...t}),e},[]),ds=i=>{let e=[];return i.forEach(t=>{i.find(r=>r.uid!==t.uid&&r.isAncestor(t))||e.push(t)}),e},A2=i=>{let e={},t={};i.forEach(n=>{let s=n.parent;if(s){let a=s.uid;t[a]=s;let o=n.getIndexInBrothers(),l={node:n,index:o};e[a]?e[a].find(h=>h.index===l.index)||e[a].push(l):e[a]=[l]}});let r=[];return Object.keys(e).forEach(n=>{if(e[n].length>1){let s=e[n].map(a=>a.index).sort((a,o)=>a-o);r.push({node:t[n],range:[s[0],s[s.length-1]]})}else r.push({node:e[n][0].node})}),r},k2=(i,e,t,r,n,s,a,o)=>e>n&&s>i&&r>a&&o>t,oa=i=>{let e=window.getSelection(),t=document.createRange();t.selectNodeContents(i),t.collapse(),e.removeAllRanges(),e.addRange(t)},la=i=>{let e=window.getSelection(),t=document.createRange();t.selectNodeContents(i),e.removeAllRanges(),e.addRange(t)},Bo=(i,e={})=>{e={...e},e&&e.richText&&e.resetRichText&&delete e.resetRichText;let r=n=>{n.forEach(s=>{s.data={...s.data,...e},s.children&&s.children.length>0&&r(s.children)})};return r(i),i},cs=(i,e=!1,t=null,r=!1)=>{let n=s=>{s.forEach(a=>{a.data||(a.data={}),(e||Yt(a.data.uid))&&(a.data.uid=wt()),r&&us(a.data).forEach(l=>{(e||Yt(l.uid))&&(l.uid=wt())}),t&&t(a),a.children&&a.children.length>0&&n(a.children)})};return n(i),i},Ot=i=>i?Array.isArray(i)?i:[i]:[],ha=i=>i.parent?i.parent.nodeData.children.findIndex(e=>e.data.uid===i.uid):0,Ie=(i,e)=>e.findIndex(t=>t.uid===i.uid),G0=i=>{let e=0;for(let n=0;n([["&","&"],["<","<"],[">",">"]].forEach(e=>{i=i.replace(new RegExp(e[0],"g"),e[1])}),i),H0=(i,e)=>{let t=os(i);if(t!==os(e))return!1;if(t==="Object"){let r=Object.keys(i),n=Object.keys(e);if(r.length!==n.length)return!1;for(let s=0;snavigator.clipboard&&typeof navigator.clipboard.read=="function",gu=i=>{navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(JSON.stringify(i))},C2=async()=>{let i=null,e=null;if(pu()){let t=await navigator.clipboard.read();if(t&&t.length>0)for(let r of t)for(let n of r.types)/^image\//.test(n)?e=await r.getType(n):n==="text/plain"&&(i=await(await r.getType(n)).text())}return{text:i,img:e}},V0=i=>{if(!i||!i.parent)return;let e=ha(i);e!==-1&&i.parent.nodeData.children.splice(e,1)},_2=i=>(_3.forEach(e=>{i=i.replace(new RegExp(`<${e}([^>]*)>`,"g"),`<${e} $1 />`)}),i),L2=(i,e)=>{if(i.length!==e.length)return!1;for(let t=0;tr.uid===i[t].uid))return!1;return!0},I2=()=>{let i=navigator.userAgent.match(/\s+Chrome\/(.*)\s+/);return i&&i[1]?Number.parseFloat(i[1]):""},xu=i=>({simpleMindMap:!0,data:i}),Po=i=>{let e=null;if(typeof i=="string")try{let r=JSON.parse(i);typeof r=="object"&&r.simpleMindMap&&(e=r.data)}catch{}else typeof i=="object"&&i.simpleMindMap&&(e=i.data);let t=!!e;return{isSmm:t,data:t?e:String(i)}},yu=(i,e)=>{i.preventDefault();let t=window.getSelection();if(!t.rangeCount)return;t.deleteFromDocument(),e=e||i.clipboardData.getData("text"),e=mn(e),e=sa(e);let r=e.split(/\n/g),n=document.createDocumentFragment();r.forEach((s,a)=>{let o=document.createTextNode(s);if(n.appendChild(o),a{let e={},t=(r,n)=>{let s=r.data.uid;n&&n.children.push(s),e[s]={isRoot:!n,data:{...r.data},children:[]},r.children&&r.children.length>0&&r.children.forEach(a=>{t(a,e[s])})};return t(i,null),e},z2=(i,e)=>{let t=i.x+i.width/2,r=i.y+i.height/2,n=e.x+e.width/2,s=e.y+e.height/2;return tn&&rn&&r>s?"right-bottom":ts?"left-bottom":tn&&r===s?"right":t===n&&rs?"bottom":"overlap"},R2=({addContentToHeader:i,addContentToFooter:e})=>{let t=[],r=null,n=0,s=null,a=0,o=(l,h)=>{if(typeof l=="function"){let d=l();if(!d)return;let{el:c,cssText:f,height:m}=d;if(c instanceof HTMLElement){or(c);let g=pn({el:c,height:m});h(g,m)}f&&t.push(f)}};return o(i,(l,h)=>{r=l,n=h}),o(e,(l,h)=>{s=l,a=h}),{cssTextList:t,header:r,headerHeight:n,footer:s,footerHeight:a}},bu=(i,e=0,t=0,r=0,n=0,s=!1,a=!1)=>{let o=1/0,l=-1/0,h=1/0,d=-1/0,c=(f,m)=>{if(!(m&&s)&&f.group)try{let{x:g,y:x,width:y,height:b}=f.group.findOne(".smm-node-shape").rbox();gl&&(l=g+y),xd&&(d=x+b)}catch{}!a&&f._generalizationList.length>0&&f._generalizationList.forEach(g=>{c(g.generalizationNode)}),f.children&&f.children.forEach(g=>{c(g)})};return c(i,!0),o=o-e+r,h=h-t+n,l=l-e+r,d=d-t+n,{left:o,top:h,width:l-o,height:d-h}},D2=(i,e=0,t=0,r=0,n=0)=>{let s=1/0,a=-1/0,o=1/0,l=-1/0;return i.forEach(h=>{let{left:d,top:c,width:f,height:m}=bu(h,e,t,r,n,!1,!0);da&&(a=d+f),cl&&(l=c+m)}),{left:s,top:o,width:a-s,height:l-o}},IT=()=>{if(document.documentElement.requestFullScreen)return"fullscreenchange";if(document.documentElement.webkitRequestFullScreen)return"webkitfullscreenchange";if(document.documentElement.mozRequestFullScreen)return"mozfullscreenchange";if(document.documentElement.msRequestFullscreen)return"msfullscreenchange"},cU=IT(),pn=({el:i,width:e,height:t})=>{let r=new ea;return e!==void 0&&r.width(e),t!==void 0&&r.height(t),r.add(i),r},us=i=>{let e=i.generalization;return e?Array.isArray(e)?e:[e]:[]},or=i=>{i.setAttribute("xmlns","http://www.w3.org/1999/xhtml")},Fo=i=>(i=[...i],i.sort((e,t)=>e.sortIndex-t.sortIndex),i),wu=(i,e)=>(0,f2.default)(i,e,{arrayMerge:(t,r)=>r}),O2=i=>{let e={};return L3.forEach(t=>{let r=i.style.merge(t);t==="fontSize"&&(r=r+"px"),e[t]=r}),e}});var B2,Mu,W0,qo,Y0=T(()=>{pe();B2=["backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize"],Mu=["gradientStyle","startColor","endColor","startDir","endDir","fillColor","borderColor","borderWidth","borderDasharray"],W0=class i{static setBackgroundStyle(e,t){if(!e)return;if(!i.cacheStyle){i.cacheStyle={};let l=window.getComputedStyle(e);B2.forEach(h=>{i.cacheStyle[h]=l[h]})}let{backgroundColor:r,backgroundImage:n,backgroundRepeat:s,backgroundPosition:a,backgroundSize:o}=t;e.style.backgroundColor=r,n&&n!=="none"?(e.style.backgroundImage=`url(${n})`,e.style.backgroundRepeat=s,e.style.backgroundPosition=a,e.style.backgroundSize=o):e.style.backgroundImage="none"}static removeBackgroundStyle(e){i.cacheStyle&&(B2.forEach(t=>{e.style[t]=i.cacheStyle[t]}),i.cacheStyle=null)}constructor(e){this.ctx=e,this._markerPath=null,this._marker=null,this._gradient=null}merge(e,t){let r=this.ctx.mindMap.themeConfig,n=null,s=!1;t?(s=!0,n=r):this.ctx.isGeneralization?n=r.generalization:this.ctx.layerIndex===0?n=r.root:this.ctx.layerIndex===1?n=r.second:n=r.node;let a="";return this.getSelfStyle(e)!==void 0?a=this.getSelfStyle(e):n[e]!==void 0?a=n[e]:a=r[e],s||this.addToEffectiveStyles({[e]:a}),a}getStyle(e,t){return this.merge(e,t)}getSelfStyle(e){return this.ctx.getData(e)}addToEffectiveStyles(e){this.ctx.mindMap.painter&&(this.ctx.effectiveStyles={...this.ctx.effectiveStyles,...e})}rect(e){this.shape(e),e.radius(this.merge("borderRadius"))}shape(e){let t={};Mu.forEach(r=>{t[r]=this.merge(r)}),t.gradientStyle?(this._gradient||(this._gradient=this.ctx.nodeDraw.gradient("linear")),this._gradient.update(r=>{r.stop(0,t.startColor),r.stop(1,t.endColor)}),this._gradient.from(...t.startDir).to(...t.endDir),e.fill(this._gradient)):e.fill({color:t.fillColor}),e.stroke({color:t.borderColor,width:t.borderWidth,dasharray:t.borderDasharray})}text(e){let t={color:this.merge("color"),fontFamily:this.merge("fontFamily"),fontSize:this.merge("fontSize"),fontWeight:this.merge("fontWeight"),fontStyle:this.merge("fontStyle"),textDecoration:this.merge("textDecoration")};e.fill({color:t.color}).css({"font-family":t.fontFamily,"font-size":t.fontSize+"px","font-weight":t.fontWeight,"font-style":t.fontStyle,"text-decoration":t.textDecoration})}domText(e,t=1){let r={color:this.merge("color"),fontFamily:this.merge("fontFamily"),fontSize:this.merge("fontSize"),fontWeight:this.merge("fontWeight"),fontStyle:this.merge("fontStyle"),textDecoration:this.merge("textDecoration"),textAlign:this.merge("textAlign")};e.style.color=r.color,e.style.textDecoration=r.textDecoration,e.style.fontFamily=r.fontFamily,e.style.fontSize=r.fontSize*t+"px",e.style.fontWeight=r.fontWeight||"normal",e.style.fontStyle=r.fontStyle,e.style.textAlign=r.textAlign}tagText(e,t){e.fill({color:"#fff"}).css({"font-size":t.fontSize+"px"})}tagRect(e,t){e.fill({color:t.fill}),t.radius&&e.radius(t.radius)}iconNode(e,t){e.attr({fill:t||this.merge("color")})}line(e,{width:t,color:r,dasharray:n}={},s,a){let{customHandleLine:o}=this.ctx.mindMap.opt;if(typeof o=="function"&&o(this.ctx,e,{width:t,color:r,dasharray:n}),e.stroke({color:r,dasharray:n,width:t}).fill({color:"none"}),s){let l=this.merge("showLineMarker",!0),h=a.style;if(l){h._marker=h._marker||h.createMarker(),h._markerPath.stroke({color:r}).fill({color:r}),e.attr("marker-start",""),e.attr("marker-end","");let d=h.merge("lineMarkerDir");e.marker(d,h._marker)}else h._marker&&(e.attr("marker-start",""),e.attr("marker-end",""),h._marker.remove(),h._marker=null)}}createMarker(){return this.ctx.lineDraw.marker(20,20,e=>{e.ref(8,5),e.size(20,20),e.attr("markerUnits","userSpaceOnUse"),e.attr("orient","auto-start-reverse"),this._markerPath=e.path("M0,0 L2,5 L0,10 L10,5 Z")})}generalizationLine(e){e.stroke({width:this.merge("generalizationLineWidth",!0),color:this.merge("generalizationLineColor",!0)}).fill({color:"none"})}iconBtn(e,t,r){let{color:n,fill:s,fontSize:a,fontColor:o}=this.ctx.mindMap.opt.expandBtnStyle||{color:"#808080",fill:"#fff",fontSize:12,strokeColor:"#333333",fontColor:"#333333"};e.fill({color:n}),t.fill({color:n}),r.fill({color:s}),this.ctx.mindMap.opt.isShowExpandNum&&e.attr({"font-size":a+"px","font-color":o})}hasCustomStyle(){let e=!1;return Object.keys(this.ctx.getData()).forEach(t=>{hs(t)&&(e=!0)}),e}getCustomStyle(){let e={};return Object.keys(this.ctx.getData()).forEach(t=>{hs(t)&&(e[t]=this.ctx.getData(t))}),e}hoverNode(e){let t=this.merge("hoverRectColor")||this.ctx.mindMap.opt.hoverRectColor,r=this.merge("hoverRectRadius");e.radius(r).fill("none").stroke({color:t})}onRemove(){this._marker&&(this._marker.remove(),this._marker=null),this._markerPath&&(this._markerPath.remove(),this._markerPath=null),this._gradient&&(this._gradient.remove(),this._gradient=null)}};W0.cacheStyle=null;qo=W0});var Ho,P2,Tu=T(()=>{yt();$e();Ho=class{constructor(e){this.node=e,this.mindMap=e.mindMap}getShapePadding(e,t,r,n){let s=this.node.getShape(),a=15,o=5,l=e+r*2,h=t+n*2,d=Math.abs(l-h);switch(s){case k.SHAPE.ROUNDED_RECTANGLE:return{paddingX:t>e?(t-e)/2:0,paddingY:0};case k.SHAPE.DIAMOND:return{paddingX:e/2,paddingY:t/2};case k.SHAPE.PARALLELOGRAM:return{paddingX:r<=0?a:0,paddingY:0};case k.SHAPE.OUTER_TRIANGULAR_RECTANGLE:return{paddingX:r<=0?a:0,paddingY:0};case k.SHAPE.INNER_TRIANGULAR_RECTANGLE:return{paddingX:r<=0?a:0,paddingY:0};case k.SHAPE.ELLIPSE:return{paddingX:r<=0?a:0,paddingY:n<=0?o:0};case k.SHAPE.CIRCLE:return{paddingX:h>l?d/2:0,paddingY:ht.name===e)}createShape(){let e=this.node.getShape(),t=null;if(e===k.SHAPE.RECTANGLE?t=this.createRect():e===k.SHAPE.DIAMOND?t=this.createDiamond():e===k.SHAPE.PARALLELOGRAM?t=this.createParallelogram():e===k.SHAPE.ROUNDED_RECTANGLE?t=this.createRoundedRectangle():e===k.SHAPE.OCTAGONAL_RECTANGLE?t=this.createOctagonalRectangle():e===k.SHAPE.OUTER_TRIANGULAR_RECTANGLE?t=this.createOuterTriangularRectangle():e===k.SHAPE.INNER_TRIANGULAR_RECTANGLE?t=this.createInnerTriangularRectangle():e===k.SHAPE.ELLIPSE?t=this.createEllipse():e===k.SHAPE.CIRCLE&&(t=this.createCircle()),!t){let r=this.getShapeFromExtendList(e);r&&(t=r.createShape(this.node))}return t||this.createRect()}getNodeSize(){let e=this.node.getBorderWidth(),{width:t,height:r}=this.node;return t-=e,r-=e,{width:t,height:r}}createPath(e){let{customCreateNodePath:t}=this.mindMap.opt;return t?Ae(t(e)):new ar().plot(e)}createPolygon(e){let{customCreateNodePolygon:t}=this.mindMap.opt;return t?Ae(t(e)):new Gi().plot(e)}createRect(){let{width:e,height:t}=this.getNodeSize(),r=this.node.style.merge("borderRadius"),n=` M${r},0 L${e-r},0 C${e-r},0 ${e},0 ${e},${r} @@ -39,22 +39,22 @@ var jv=Object.create;var Pl=Object.defineProperty;var Gv=Object.getOwnPropertyDe `;return this.createPath(n)}createDiamond(){let{width:e,height:t}=this.getNodeSize(),r=e/2,n=t/2,m=[[r,0],[e,n],[r,t],[0,n]];return this.createPolygon(m)}createParallelogram(){let{paddingX:e}=this.node.getPaddingVale();e=e||this.node.shapePadding.paddingX;let{width:t,height:r}=this.getNodeSize(),n=[[e,0],[t,0],[t-e,r],[0,r]];return this.createPolygon(n)}createRoundedRectangle(){let{width:e,height:t}=this.getNodeSize(),r=t/2,n=` M${r},0 L${e-r},0 - A${t/2},${t/2} 0 0,1 ${e-r},${t} + A${t/2},${t/2} 0 0,1 ${e-r},${t} L${r},${t} A${t/2},${t/2} 0 0,1 ${r},0 `;return this.createPath(n)}createOctagonalRectangle(){let e=5,{width:t,height:r}=this.getNodeSize(),n=[[0,e],[e,0],[t-e,0],[t,e],[t,r-e],[t-e,r],[e,r],[0,r-e]];return this.createPolygon(n)}createOuterTriangularRectangle(){let{paddingX:e}=this.node.getPaddingVale();e=e||this.node.shapePadding.paddingX;let{width:t,height:r}=this.getNodeSize(),n=[[e,0],[t-e,0],[t,r/2],[t-e,r],[e,r],[0,r/2]];return this.createPolygon(n)}createInnerTriangularRectangle(){let{paddingX:e}=this.node.getPaddingVale();e=e||this.node.shapePadding.paddingX;let{width:t,height:r}=this.getNodeSize(),n=[[0,0],[t,0],[t-e/2,r/2],[t,r],[0,r],[e/2,r/2]];return this.createPolygon(n)}createEllipse(){let{width:e,height:t}=this.getNodeSize(),r=e/2,n=t/2,s=` M${r},0 - A${r},${n} 0 0,1 ${r},${t} - M${r},${t} - A${r},${n} 0 0,1 ${r},0 + A${r},${n} 0 0,1 ${r},${t} + M${r},${t} + A${r},${n} 0 0,1 ${r},0 `;return this.createPath(s)}createCircle(){let{width:e,height:t}=this.getNodeSize(),r=e/2,n=t/2,s=` M${r},0 - A${r},${n} 0 0,1 ${r},${t} - M${r},${t} - A${r},${n} 0 0,1 ${r},0 - `;return this.createPath(s)}},s3=[A.SHAPE.RECTANGLE,A.SHAPE.DIAMOND,A.SHAPE.PARALLELOGRAM,A.SHAPE.ROUNDED_RECTANGLE,A.SHAPE.OCTAGONAL_RECTANGLE,A.SHAPE.OUTER_TRIANGULAR_RECTANGLE,A.SHAPE.INNER_TRIANGULAR_RECTANGLE,A.SHAPE.ELLIPSE,A.SHAPE.CIRCLE]});function vw(){let i=this.getData("generalization");return Array.isArray(i)?i:i?[i]:[]}function yw(){return this.formatGetGeneralization().length>0}function bw(){return!!this.formatGetGeneralization().find(e=>!e.range||e.range.length<=0)}function ww(i){return this._generalizationList.findIndex(e=>e.generalizationNode.uid===i.uid)}function Mw(){if(this.isGeneralization||!this.checkHasGeneralization())return;let i=0,e=0;this.formatGetGeneralization().forEach((r,n)=>{let s=this._generalizationList[n];s||(s=this._generalizationList[n]={}),s.node=this,s.range=r.range,s.generalizationLine||(s.generalizationLine=this.lineDraw.path()),s.generalizationNode||(s.generalizationNode=new Is({data:{inserting:r.inserting,data:r},uid:ct(),renderer:this.renderer,mindMap:this.mindMap,isGeneralization:!0})),delete r.inserting,s.generalizationNode.generalizationBelongNode=this,s.generalizationNode.width>i&&(i=s.generalizationNode.width),s.generalizationNode.height>e&&(e=s.generalizationNode.height),r.isActive&&this.renderer.addNodeToActiveList(s.generalizationNode)}),this._generalizationNodeWidth=i,this._generalizationNodeHeight=e}function Tw(){this.isGeneralization||(this.removeGeneralization(),this.createGeneralizationNode())}function Nw(i){if(this.isGeneralization)return;this.updateGeneralizationData();let e=this.formatGetGeneralization();if(e.length<=0||this.getData("expand")===!1){this.removeGeneralization();return}e.length!==this._generalizationList.length&&this.removeGeneralization(),this.createGeneralizationNode(),this.renderer.layout.renderGeneralization(this._generalizationList),this._generalizationList.forEach(t=>{this.style.generalizationLine(t.generalizationLine),t.generalizationNode.render(()=>{},i)})}function Ew(){let i=this.getChildrenLength(),e=this.formatGetGeneralization(),t=[];e.forEach(r=>{if(!r.range){t.push(r);return}r.range.length>0&&r.range[0]<=i-1&&r.range[1]<=i-1&&t.push(r)}),t.length!==e.length&&this.setData({generalization:t})}function Sw(){this.isGeneralization||(this._generalizationList.forEach(i=>{i.generalizationNode.style.onRemove(),i.generalizationLine&&(i.generalizationLine.remove(),i.generalizationLine=null),i.generalizationNode&&(this.renderer.removeNodeFromActiveList(i.generalizationNode),i.generalizationNode.remove(),i.generalizationNode=null)}),this._generalizationList=[],this.generalizationBelongNode&&this.nodeDraw.find(".generalization_"+this.generalizationBelongNode.uid).remove())}function Aw(){this.isGeneralization||this._generalizationList.forEach(i=>{i.generalizationLine&&i.generalizationLine.hide(),i.generalizationNode&&i.generalizationNode.hide()})}function kw(){this.isGeneralization||this._generalizationList.forEach(i=>{i.generalizationLine&&i.generalizationLine.show(),i.generalizationNode&&i.generalizationNode.show()})}function Cw(i){this._generalizationList.forEach(e=>{e.generalizationLine.opacity(i),e.generalizationNode.group.opacity(i)})}function _w(){let i=this.generalizationBelongNode,e=i.formatGetGeneralization(),t=i.getGeneralizationNodeIndex(this),r=e[t],s=this.getStyle("hoverRectColor")||this.mindMap.opt.hoverRectColor,a=s?{stroke:s}:null;Array.isArray(r.range)&&r.range.length>0?this.mindMap.renderer.highlightNode(i,r.range,a):this.mindMap.renderer.highlightNode(i,null,a)}function Lw(){this.mindMap.renderer.closeHighlightNode()}var Tc,a3=M(()=>{a0();he();Tc={formatGetGeneralization:vw,checkHasGeneralization:yw,checkHasSelfGeneralization:bw,getGeneralizationNodeIndex:ww,createGeneralizationNode:Mw,updateGeneralization:Tw,updateGeneralizationData:Ew,renderGeneralization:Nw,removeGeneralization:Sw,hideGeneralization:Aw,showGeneralization:kw,setGeneralizationOpacity:Cw,handleGeneralizationMouseenter:_w,handleGeneralizationMouseleave:Lw}});var zw,Iw,Rw,Dw,Ow,co,Nc=M(()=>{zw='',Iw='',Rw='',Dw='',Ow='',co={open:zw,close:Iw,remove:Rw,imgAdjust:Dw,quickCreateChild:Ow}});function Bw(){if(this._openExpandNode)return;let{expandBtnSize:i,expandBtnIcon:e,isShowExpandNum:t}=this.mindMap.opt,{close:r,open:n}=e||{};t?(this._openExpandNode=new Te,this._openExpandNode.addClass("smm-expand-btn-text"),this._openExpandNode.attr({"text-anchor":"middle","dominant-baseline":"middle",x:i/2,y:2})):(this._openExpandNode=Me(n||co.open).size(i,i),this._openExpandNode.x(0).y(-i/2)),this._closeExpandNode=Me(r||co.close).size(i,i),this._closeExpandNode.x(0).y(-i/2),this._fillExpandNode=new zi().size(i),this._fillExpandNode.x(0).y(-i/2),this.style.iconBtn(this._openExpandNode,this._closeExpandNode,this._fillExpandNode)}function Pw(i=[]){return i.reduce((e,t)=>e+this.sumNode(t.children||[]),i.length)}function Fw(){let{expand:i}=this.getData();if(i===this._lastExpandBtnType)return;this._expandBtn&&this._expandBtn.clear(),this.createExpandNodeContent();let e;if(i===!1?(e=this._openExpandNode,this._lastExpandBtnType=!1):(e=this._closeExpandNode,this._lastExpandBtnType=!0),this._expandBtn){let{isShowExpandNum:t,expandBtnStyle:r,expandBtnNumHandler:n}=this.mindMap.opt;if(t)if(i)this._fillExpandNode.stroke("none");else{this._fillExpandNode.stroke({color:r.strokeColor});let s=this.sumNode(this.nodeData.children||[]);if(typeof n=="function"){let a=n(s,this);Bt(a)||(s=a)}e.text(String(s))}this._expandBtn.add(this._fillExpandNode).add(e)}}function qw(){this._expandBtn&&this.renderer.layout.renderExpandBtn(this,this._expandBtn)}function Hw(){this.getChildrenLength()<=0||this.isRoot||(this._expandBtn?this.group.add(this._expandBtn):(this._expandBtn=new Ne,this._expandBtn.on("mouseover",i=>{i.stopPropagation(),this._expandBtn.css({cursor:"pointer"})}),this._expandBtn.on("mouseout",i=>{i.stopPropagation(),this._expandBtn.css({cursor:"auto"})}),this._expandBtn.on("click",i=>{i.stopPropagation(),this.mindMap.execCommand("SET_NODE_EXPAND",this,!this.getData("expand")),this.mindMap.emit("expand_btn_click",this)}),this._expandBtn.on("dblclick",i=>{i.stopPropagation()}),this._expandBtn.addClass("smm-expand-btn"),this.group.add(this._expandBtn)),this._showExpandBtn=!0,this.updateExpandBtnNode(),this.updateExpandBtnPos())}function Uw(){this._expandBtn&&this._showExpandBtn&&(this._expandBtn.remove(),this._showExpandBtn=!1)}function $w(){let{alwaysShowExpandBtn:i,notShowExpandBtn:e}=this.mindMap.opt;i||e||setTimeout(()=>{this.renderExpandBtn()},0)}function jw(){let{alwaysShowExpandBtn:i,notShowExpandBtn:e}=this.mindMap.opt;if(i||this._isMouseenter||e)return;let{isActive:t,expand:r}=this.getData();!t&&r&&setTimeout(()=>{this.removeExpandBtn()},0)}var Ec,o3=M(()=>{Nc();ht();he();Ec={createExpandNodeContent:Bw,updateExpandBtnNode:Fw,updateExpandBtnPos:qw,renderExpandBtn:Hw,removeExpandBtn:Uw,showExpandBtn:$w,hideExpandBtn:jw,sumNode:Pw}});function Gw(i={}){this.mindMap.execCommand("SET_NODE_DATA",this,i)}function Yw(i,e,t){this.mindMap.execCommand("SET_NODE_TEXT",this,i,e,t)}function Ww(i){this.mindMap.execCommand("SET_NODE_IMAGE",this,i)}function Vw(i){this.mindMap.execCommand("SET_NODE_ICON",this,i)}function Xw(i,e){this.mindMap.execCommand("SET_NODE_HYPERLINK",this,i,e)}function Kw(i){this.mindMap.execCommand("SET_NODE_NOTE",this,i)}function Zw(i,e){this.mindMap.execCommand("SET_NODE_ATTACHMENT",this,i,e)}function Qw(i){this.mindMap.execCommand("SET_NODE_TAG",this,i)}function Jw(i){this.mindMap.execCommand("SET_NODE_SHAPE",this,i)}function eM(i,e){this.mindMap.execCommand("SET_NODE_STYLE",this,i,e)}function tM(i){this.mindMap.execCommand("SET_NODE_STYLES",this,i)}var Sc,l3=M(()=>{Sc={setData:Gw,setText:Yw,setImage:Ww,setIcon:Vw,setHyperlink:Xw,setNote:Kw,setAttachment:Zw,setTag:Qw,setShape:Jw,setStyle:eM,setStyles:tM}});var iM,rM,nM,h3,sM,uo,d3=M(()=>{he();iM='',rM='',nM='',h3=[{name:"\u4F18\u5148\u7EA7\u56FE\u6807",type:"priority",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''},{name:"9",icon:''},{name:"10",icon:''}]},{name:"\u8FDB\u5EA6\u56FE\u6807",type:"progress",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''}]},{name:"\u8868\u60C5\u56FE\u6807",type:"expression",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''},{name:"9",icon:''},{name:"10",icon:''},{name:"11",icon:''},{name:"12",icon:''},{name:"13",icon:''},{name:"14",icon:''},{name:"15",icon:''},{name:"16",icon:''},{name:"17",icon:''},{name:"18",icon:''},{name:"19",icon:''},{name:"20",icon:''}]},{name:"\u6807\u8BB0\u56FE\u6807",type:"sign",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''},{name:"9",icon:''},{name:"10",icon:''},{name:"11",icon:''},{name:"12",icon:''},{name:"13",icon:''},{name:"14",icon:''},{name:"15",icon:''},{name:"16",icon:''},{name:"17",icon:''},{name:"18",icon:''},{name:"19",icon:''},{name:"20",icon:''},{name:"21",icon:''},{name:"22",icon:''},{name:"23",icon:''}]}],sM=(i,e=[])=>{let t=i.split("_"),n=Wp([...h3,...e]).find(s=>s.type===t[0]);if(n){let s=n.list.find(a=>a.name===t[1]);return s?s.icon:""}else return""},uo={hyperlink:iM,note:rM,attachment:nM,nodeIconList:h3,getNodeIconListIcon:sM}});function oM(){let i=this.getData("image");if(!i)return;i=(this.mindMap.renderer.renderTree.data.imgMap||{})[i]||i;let e=this.getImgShowSize(),t=new Ci().load(i).size(...e),{defaultNodeImage:r}=this.mindMap.opt;if(r){let n=new Image;n.onerror=()=>{t.load(r)},n.src=i}return this.getData("imageTitle")&&t.attr("title",this.getData("imageTitle")),t.on("click",n=>{this.mindMap.emit("node_img_click",this,t,n)}),t.on("dblclick",n=>{this.mindMap.emit("node_img_dblclick",this,n,t)}),t.on("mouseenter",n=>{this.mindMap.emit("node_img_mouseenter",this,t,n)}),t.on("mouseleave",n=>{this.mindMap.emit("node_img_mouseleave",this,t,n)}),t.on("mousemove",n=>{this.mindMap.emit("node_img_mousemove",this,t,n)}),{node:t,width:e[0],height:e[1]}}function lM(){let{custom:i,width:e,height:t}=this.getData("imageSize");return i?[e,t]:Jl(e,t,this.mindMap.themeConfig.imgMaxWidth,this.mindMap.themeConfig.imgMaxHeight)}function hM(){let i=this.getData();if(!i.icon||i.icon.length<=0)return[];let e=this.mindMap.themeConfig.iconSize;return i.icon.map(t=>{let r=uo.getNodeIconListIcon(t,this.mindMap.opt.iconList||[]),n=null;return/^{this.mindMap.emit("node_icon_click",this,t,s,n)}),n.on("mouseenter",s=>{this.mindMap.emit("node_icon_mouseenter",this,t,s,n)}),n.on("mouseleave",s=>{this.mindMap.emit("node_icon_mouseleave",this,t,s,n)}),{node:n,width:e,height:e}})}function dM(i){let e=this.hasCustomWidth(),t=typeof i=="string"?i:this.getData("text"),{textAutoWrapWidth:r,emptyTextMeasureHeightText:n}=this.mindMap.opt;r=e?this.customTextWidth:r;let s=new Ne,a=!1;this.getData("resetRichText")&&(delete this.nodeData.data.resetRichText,a=!0),a&&!Bt(t)&&(Up(t)?t=jp(t):t=`

    ${t}

    `,this.setData({text:t}));let o=[],l=r3(this);Object.keys(l).forEach(v=>{o.push([v,l[v]])}),this.mindMap.commonCaches.measureRichtextNodeTextSizeEl||(this.mindMap.commonCaches.measureRichtextNodeTextSizeEl=document.createElement("div"),this.mindMap.commonCaches.measureRichtextNodeTextSizeEl.style.position="fixed",this.mindMap.commonCaches.measureRichtextNodeTextSizeEl.style.left="-999999px",this.mindMap.el.appendChild(this.mindMap.commonCaches.measureRichtextNodeTextSizeEl));let h=this.mindMap.commonCaches.measureRichtextNodeTextSizeEl;o.forEach(([v,b])=>{h.style[v]=b}),h.style.lineHeight=1.2;let d=`
    ${t}
    `;h.innerHTML=d;let c=h.children[0];c.classList.add("smm-richtext-node-wrap"),$i(c),c.style.maxWidth=r+"px",e?c.style.width=this.customTextWidth+"px":c.style.width="";let{width:f,height:m}=c.getBoundingClientRect();if(m<=0){h.innerHTML=`

    ${n}

    `;let v=h.children[0];v.classList.add("smm-richtext-node-wrap"),m=v.getBoundingClientRect().height,h.innerHTML=d}f=Math.min(Math.ceil(f)+1,r),m=Math.ceil(m),s.attr("data-width",f),s.attr("data-height",m);let g=Vr({el:h.children[0],width:f,height:m}),x={"line-height":1.2};return o.forEach(([v,b])=>{x[Bp(v)]=b}),g.css(x),s.add(g),{node:s,nodeContent:g,width:f,height:m}}function cM(i){if(this.getData("needUpdate")&&delete this.nodeData.data.needUpdate,this.getData("richText"))return this.createRichTextNode(i);let e=typeof i=="string"?i:this.getData("text");this.getData("resetRichText")&&delete this.nodeData.data.resetRichText;let t=new Ne,r=this.getStyle("fontSize",!1),n=this.getStyle("textAlign",!1),s=[];Bt(e)||(s=String(e).split(/\n/gim));let{textAutoWrapWidth:a,emptyTextMeasureHeightText:o}=this.mindMap.opt,l=s.length>1;s.forEach((c,f)=>{let m=c.split(""),g=[],x=[];for(;m.length;){let v=m.shift(),b=[...x,v].join("");aM(b,this.style).width<=a?x.push(v):(g.push(x.join("")),x=[v])}x.length>0&&g.push(x.join("")),g.length>1&&(l=!0),s[f]=g.join(` + A${r},${n} 0 0,1 ${r},${t} + M${r},${t} + A${r},${n} 0 0,1 ${r},0 + `;return this.createPath(s)}},P2=[k.SHAPE.RECTANGLE,k.SHAPE.DIAMOND,k.SHAPE.PARALLELOGRAM,k.SHAPE.ROUNDED_RECTANGLE,k.SHAPE.OCTAGONAL_RECTANGLE,k.SHAPE.OUTER_TRIANGULAR_RECTANGLE,k.SHAPE.INNER_TRIANGULAR_RECTANGLE,k.SHAPE.ELLIPSE,k.SHAPE.CIRCLE]});function zT(){let i=this.getData("generalization");return Array.isArray(i)?i:i?[i]:[]}function RT(){return this.formatGetGeneralization().length>0}function DT(){return!!this.formatGetGeneralization().find(e=>!e.range||e.range.length<=0)}function OT(i){return this._generalizationList.findIndex(e=>e.generalizationNode.uid===i.uid)}function BT(){if(this.isGeneralization||!this.checkHasGeneralization())return;let i=0,e=0;this.formatGetGeneralization().forEach((r,n)=>{let s=this._generalizationList[n];s||(s=this._generalizationList[n]={}),s.node=this,s.range=r.range,s.generalizationLine||(s.generalizationLine=this.lineDraw.path()),s.generalizationNode||(s.generalizationNode=new da({data:{inserting:r.inserting,data:r},uid:wt(),renderer:this.renderer,mindMap:this.mindMap,isGeneralization:!0})),delete r.inserting,s.generalizationNode.generalizationBelongNode=this,s.generalizationNode.width>i&&(i=s.generalizationNode.width),s.generalizationNode.height>e&&(e=s.generalizationNode.height),r.isActive&&this.renderer.addNodeToActiveList(s.generalizationNode)}),this._generalizationNodeWidth=i,this._generalizationNodeHeight=e}function PT(){this.isGeneralization||(this.removeGeneralization(),this.createGeneralizationNode())}function FT(i){if(this.isGeneralization)return;this.updateGeneralizationData();let e=this.formatGetGeneralization();if(e.length<=0||this.getData("expand")===!1){this.removeGeneralization();return}e.length!==this._generalizationList.length&&this.removeGeneralization(),this.createGeneralizationNode(),this.renderer.layout.renderGeneralization(this._generalizationList),this._generalizationList.forEach(t=>{this.style.generalizationLine(t.generalizationLine),t.generalizationNode.render(()=>{},i)})}function qT(){let i=this.getChildrenLength(),e=this.formatGetGeneralization(),t=[];e.forEach(r=>{if(!r.range){t.push(r);return}r.range.length>0&&r.range[0]<=i-1&&r.range[1]<=i-1&&t.push(r)}),t.length!==e.length&&this.setData({generalization:t})}function HT(){this.isGeneralization||(this._generalizationList.forEach(i=>{i.generalizationNode.style.onRemove(),i.generalizationLine&&(i.generalizationLine.remove(),i.generalizationLine=null),i.generalizationNode&&(this.renderer.removeNodeFromActiveList(i.generalizationNode),i.generalizationNode.remove(),i.generalizationNode=null)}),this._generalizationList=[],this.generalizationBelongNode&&this.nodeDraw.find(".generalization_"+this.generalizationBelongNode.uid).remove())}function UT(){this.isGeneralization||this._generalizationList.forEach(i=>{i.generalizationLine&&i.generalizationLine.hide(),i.generalizationNode&&i.generalizationNode.hide()})}function $T(){this.isGeneralization||this._generalizationList.forEach(i=>{i.generalizationLine&&i.generalizationLine.show(),i.generalizationNode&&i.generalizationNode.show()})}function jT(i){this._generalizationList.forEach(e=>{e.generalizationLine.opacity(i),e.generalizationNode.group.opacity(i)})}function GT(){let i=this.generalizationBelongNode,e=i.formatGetGeneralization(),t=i.getGeneralizationNodeIndex(this),r=e[t],s=this.getStyle("hoverRectColor")||this.mindMap.opt.hoverRectColor,a=s?{stroke:s}:null;Array.isArray(r.range)&&r.range.length>0?this.mindMap.renderer.highlightNode(i,r.range,a):this.mindMap.renderer.highlightNode(i,null,a)}function VT(){this.mindMap.renderer.closeHighlightNode()}var Nu,F2=T(()=>{X0();pe();Nu={formatGetGeneralization:zT,checkHasGeneralization:RT,checkHasSelfGeneralization:DT,getGeneralizationNodeIndex:OT,createGeneralizationNode:BT,updateGeneralization:PT,updateGeneralizationData:qT,renderGeneralization:FT,removeGeneralization:HT,hideGeneralization:UT,showGeneralization:$T,setGeneralizationOpacity:jT,handleGeneralizationMouseenter:GT,handleGeneralizationMouseleave:VT}});var WT,YT,XT,KT,ZT,Uo,Eu=T(()=>{WT='',YT='',XT='',KT='',ZT='',Uo={open:WT,close:YT,remove:XT,imgAdjust:KT,quickCreateChild:ZT}});function QT(){if(this._openExpandNode)return;let{expandBtnSize:i,expandBtnIcon:e,isShowExpandNum:t}=this.mindMap.opt,{close:r,open:n}=e||{};t?(this._openExpandNode=new Ce,this._openExpandNode.addClass("smm-expand-btn-text"),this._openExpandNode.attr({"text-anchor":"middle","dominant-baseline":"middle",x:i/2,y:2})):(this._openExpandNode=Ae(n||Uo.open).size(i,i),this._openExpandNode.x(0).y(-i/2)),this._closeExpandNode=Ae(r||Uo.close).size(i,i),this._closeExpandNode.x(0).y(-i/2),this._fillExpandNode=new Wi().size(i),this._fillExpandNode.x(0).y(-i/2),this.style.iconBtn(this._openExpandNode,this._closeExpandNode,this._fillExpandNode)}function JT(i=[]){return i.reduce((e,t)=>e+this.sumNode(t.children||[]),i.length)}function eN(){let{expand:i}=this.getData();if(i===this._lastExpandBtnType)return;this._expandBtn&&this._expandBtn.clear(),this.createExpandNodeContent();let e;if(i===!1?(e=this._openExpandNode,this._lastExpandBtnType=!1):(e=this._closeExpandNode,this._lastExpandBtnType=!0),this._expandBtn){let{isShowExpandNum:t,expandBtnStyle:r,expandBtnNumHandler:n}=this.mindMap.opt;if(t)if(i)this._fillExpandNode.stroke("none");else{this._fillExpandNode.stroke({color:r.strokeColor});let s=this.sumNode(this.nodeData.children||[]);if(typeof n=="function"){let a=n(s,this);Yt(a)||(s=a)}e.text(String(s))}this._expandBtn.add(this._fillExpandNode).add(e)}}function tN(){this._expandBtn&&this.renderer.layout.renderExpandBtn(this,this._expandBtn)}function iN(){this.getChildrenLength()<=0||this.isRoot||(this._expandBtn?this.group.add(this._expandBtn):(this._expandBtn=new _e,this._expandBtn.on("mouseover",i=>{i.stopPropagation(),this._expandBtn.css({cursor:"pointer"})}),this._expandBtn.on("mouseout",i=>{i.stopPropagation(),this._expandBtn.css({cursor:"auto"})}),this._expandBtn.on("click",i=>{i.stopPropagation(),this.mindMap.execCommand("SET_NODE_EXPAND",this,!this.getData("expand")),this.mindMap.emit("expand_btn_click",this)}),this._expandBtn.on("dblclick",i=>{i.stopPropagation()}),this._expandBtn.addClass("smm-expand-btn"),this.group.add(this._expandBtn)),this._showExpandBtn=!0,this.updateExpandBtnNode(),this.updateExpandBtnPos())}function rN(){this._expandBtn&&this._showExpandBtn&&(this._expandBtn.remove(),this._showExpandBtn=!1)}function nN(){let{alwaysShowExpandBtn:i,notShowExpandBtn:e}=this.mindMap.opt;i||e||setTimeout(()=>{this.renderExpandBtn()},0)}function sN(){let{alwaysShowExpandBtn:i,notShowExpandBtn:e}=this.mindMap.opt;if(i||this._isMouseenter||e)return;let{isActive:t,expand:r}=this.getData();!t&&r&&setTimeout(()=>{this.removeExpandBtn()},0)}var Su,q2=T(()=>{Eu();yt();pe();Su={createExpandNodeContent:QT,updateExpandBtnNode:eN,updateExpandBtnPos:tN,renderExpandBtn:iN,removeExpandBtn:rN,showExpandBtn:nN,hideExpandBtn:sN,sumNode:JT}});function aN(i={}){this.mindMap.execCommand("SET_NODE_DATA",this,i)}function oN(i,e,t){this.mindMap.execCommand("SET_NODE_TEXT",this,i,e,t)}function lN(i){this.mindMap.execCommand("SET_NODE_IMAGE",this,i)}function hN(i){this.mindMap.execCommand("SET_NODE_ICON",this,i)}function dN(i,e){this.mindMap.execCommand("SET_NODE_HYPERLINK",this,i,e)}function cN(i){this.mindMap.execCommand("SET_NODE_NOTE",this,i)}function uN(i,e){this.mindMap.execCommand("SET_NODE_ATTACHMENT",this,i,e)}function fN(i){this.mindMap.execCommand("SET_NODE_TAG",this,i)}function mN(i){this.mindMap.execCommand("SET_NODE_SHAPE",this,i)}function pN(i,e){this.mindMap.execCommand("SET_NODE_STYLE",this,i,e)}function gN(i){this.mindMap.execCommand("SET_NODE_STYLES",this,i)}var Au,H2=T(()=>{Au={setData:aN,setText:oN,setImage:lN,setIcon:hN,setHyperlink:dN,setNote:cN,setAttachment:uN,setTag:fN,setShape:mN,setStyle:pN,setStyles:gN}});var xN,yN,vN,U2,bN,$o,$2=T(()=>{pe();xN='',yN='',vN='',U2=[{name:"\u4F18\u5148\u7EA7\u56FE\u6807",type:"priority",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''},{name:"9",icon:''},{name:"10",icon:''}]},{name:"\u8FDB\u5EA6\u56FE\u6807",type:"progress",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''}]},{name:"\u8868\u60C5\u56FE\u6807",type:"expression",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''},{name:"9",icon:''},{name:"10",icon:''},{name:"11",icon:''},{name:"12",icon:''},{name:"13",icon:''},{name:"14",icon:''},{name:"15",icon:''},{name:"16",icon:''},{name:"17",icon:''},{name:"18",icon:''},{name:"19",icon:''},{name:"20",icon:''}]},{name:"\u6807\u8BB0\u56FE\u6807",type:"sign",list:[{name:"1",icon:''},{name:"2",icon:''},{name:"3",icon:''},{name:"4",icon:''},{name:"5",icon:''},{name:"6",icon:''},{name:"7",icon:''},{name:"8",icon:''},{name:"9",icon:''},{name:"10",icon:''},{name:"11",icon:''},{name:"12",icon:''},{name:"13",icon:''},{name:"14",icon:''},{name:"15",icon:''},{name:"16",icon:''},{name:"17",icon:''},{name:"18",icon:''},{name:"19",icon:''},{name:"20",icon:''},{name:"21",icon:''},{name:"22",icon:''},{name:"23",icon:''}]}],bN=(i,e=[])=>{let t=i.split("_"),n=S2([...U2,...e]).find(s=>s.type===t[0]);if(n){let s=n.list.find(a=>a.name===t[1]);return s?s.icon:""}else return""},$o={hyperlink:xN,note:yN,attachment:vN,nodeIconList:U2,getNodeIconListIcon:bN}});function MN(){let i=this.getData("image");if(!i)return;i=(this.mindMap.renderer.renderTree.data.imgMap||{})[i]||i;let e=this.getImgShowSize(),t=new ji().load(i).size(...e),{defaultNodeImage:r}=this.mindMap.opt;if(r){let n=new Image;n.onerror=()=>{t.load(r)},n.src=i}return this.getData("imageTitle")&&t.attr("title",this.getData("imageTitle")),t.on("click",n=>{this.mindMap.emit("node_img_click",this,t,n)}),t.on("dblclick",n=>{this.mindMap.emit("node_img_dblclick",this,n,t)}),t.on("mouseenter",n=>{this.mindMap.emit("node_img_mouseenter",this,t,n)}),t.on("mouseleave",n=>{this.mindMap.emit("node_img_mouseleave",this,t,n)}),t.on("mousemove",n=>{this.mindMap.emit("node_img_mousemove",this,t,n)}),{node:t,width:e[0],height:e[1]}}function TN(){let{custom:i,width:e,height:t}=this.getData("imageSize");return i?[e,t]:U0(e,t,this.mindMap.themeConfig.imgMaxWidth,this.mindMap.themeConfig.imgMaxHeight)}function NN(){let i=this.getData();if(!i.icon||i.icon.length<=0)return[];let e=this.mindMap.themeConfig.iconSize;return i.icon.map(t=>{let r=$o.getNodeIconListIcon(t,this.mindMap.opt.iconList||[]),n=null;return/^{this.mindMap.emit("node_icon_click",this,t,s,n)}),n.on("mouseenter",s=>{this.mindMap.emit("node_icon_mouseenter",this,t,s,n)}),n.on("mouseleave",s=>{this.mindMap.emit("node_icon_mouseleave",this,t,s,n)}),{node:n,width:e,height:e}})}function EN(i){let e=this.hasCustomWidth(),t=typeof i=="string"?i:this.getData("text"),{textAutoWrapWidth:r,emptyTextMeasureHeightText:n}=this.mindMap.opt;r=e?this.customTextWidth:r;let s=new _e,a=!1;this.getData("resetRichText")&&(delete this.nodeData.data.resetRichText,a=!0),a&&!Yt(t)&&(w2(t)?t=T2(t):t=`

    ${t}

    `,this.setData({text:t}));let o=[],l=O2(this);Object.keys(l).forEach(y=>{o.push([y,l[y]])}),this.mindMap.commonCaches.measureRichtextNodeTextSizeEl||(this.mindMap.commonCaches.measureRichtextNodeTextSizeEl=document.createElement("div"),this.mindMap.commonCaches.measureRichtextNodeTextSizeEl.style.position="fixed",this.mindMap.commonCaches.measureRichtextNodeTextSizeEl.style.left="-999999px",this.mindMap.el.appendChild(this.mindMap.commonCaches.measureRichtextNodeTextSizeEl));let h=this.mindMap.commonCaches.measureRichtextNodeTextSizeEl;o.forEach(([y,b])=>{h.style[y]=b}),h.style.lineHeight=1.2;let d=`
    ${t}
    `;h.innerHTML=d;let c=h.children[0];c.classList.add("smm-richtext-node-wrap"),or(c),c.style.maxWidth=r+"px",e?c.style.width=this.customTextWidth+"px":c.style.width="";let{width:f,height:m}=c.getBoundingClientRect();if(m<=0){h.innerHTML=`

    ${n}

    `;let y=h.children[0];y.classList.add("smm-richtext-node-wrap"),m=y.getBoundingClientRect().height,h.innerHTML=d}f=Math.min(Math.ceil(f)+1,r),m=Math.ceil(m),s.attr("data-width",f),s.attr("data-height",m);let g=pn({el:h.children[0],width:f,height:m}),x={"line-height":1.2};return o.forEach(([y,b])=>{x[g2(y)]=b}),g.css(x),s.add(g),{node:s,nodeContent:g,width:f,height:m}}function SN(i){if(this.getData("needUpdate")&&delete this.nodeData.data.needUpdate,this.getData("richText"))return this.createRichTextNode(i);let e=typeof i=="string"?i:this.getData("text");this.getData("resetRichText")&&delete this.nodeData.data.resetRichText;let t=new _e,r=this.getStyle("fontSize",!1),n=this.getStyle("textAlign",!1),s=[];Yt(e)||(s=String(e).split(/\n/gim));let{textAutoWrapWidth:a,emptyTextMeasureHeightText:o}=this.mindMap.opt,l=s.length>1;s.forEach((c,f)=>{let m=c.split(""),g=[],x=[];for(;m.length;){let y=m.shift(),b=[...x,y].join("");wN(b,this.style).width<=a?x.push(y):(g.push(x.join("")),x=[y])}x.length>0&&g.push(x.join("")),g.length>1&&(l=!0),s[f]=g.join(` `)}),s=s.join(` -`).replace(/\n$/g,"").split(/\n/gim),s.forEach((c,f)=>{c===""&&(c="\uFEFF");let m=new Te().text(c);m.addClass("smm-text-node-wrap"),m.attr("text-anchor",{left:"start",center:"middle",right:"end"}[n]||"start"),this.style.text(m),m.y(r*fs*f+(fs-1)*r/2),t.add(m)});let{width:h,height:d}=t.bbox();if(d<=0){let c=new Te().text(o);this.style.text(c),d=c.bbox().height}return h=Math.min(Math.ceil(h),a),d=Math.ceil(d),t.attr("data-width",h),t.attr("data-height",d),t.attr("data-ismultiLine",l||s.length>1),{node:t,width:h,height:d}}function uM(){let{hyperlink:i,hyperlinkTitle:e}=this.getData();if(!i)return;let{customHyperlinkJump:t,hyperlinkIcon:r}=this.mindMap.opt,{icon:n,style:s}=r,a=this.getNodeIconSize("hyperlinkIcon"),o=new Me().size(a,a),l=new jr().to(i).target("_blank");l.node.addEventListener("click",d=>{typeof t=="function"&&(d.preventDefault(),t(i,this))}),e&&o.add(Me(`${e}`)),l.rect(a,a).fill({color:"transparent"});let h=Me(n||uo.hyperlink).size(a,a);return this.style.iconNode(h,s.color),l.add(h),o.add(l),{node:o,width:a,height:a}}function fM(){let i=this.getData("tag");if(!i||i.length<=0)return[];let{maxTag:e,tagsColorMap:t}=this.mindMap.opt;t=t||{};let r=[];return i.slice(0,e).forEach((n,s)=>{let a="",o={...c3};typeof n=="string"?a=n:(a=n.text,o={...c3,...n.style});let l=typeof o.width<"u",h=new Ne;h.on("click",()=>{this.mindMap.emit("node_tag_click",this,n,s,h)});let d=new Te().text(a);this.style.tagText(d,o);let{width:c,height:f}=d.bbox(),m=l?o.width:c+o.paddingX*2,g=l?Math.max(m,c):m,x=Math.max(o.height,f);l?d.x((g-c)/2):d.x(l?0:o.paddingX),d.cy(-x/2);let v=new Pe().size(m,o.height).cy(-x/2);l&&v.x((g-m)/2),this.style.tagRect(v,{...o,fill:o.fill||t[d.node.textContent]||i0(d.node.textContent)}),h.add(v).add(d),r.push({node:h,width:g,height:x})}),r}function mM(){if(!this.getData("note"))return null;let{icon:i,style:e}=this.mindMap.opt.noteIcon,t=this.getNodeIconSize("noteIcon"),r=new Me().attr("cursor","pointer").addClass("smm-node-note").size(t,t);r.add(new Pe().size(t,t).fill({color:"transparent"}));let n=Me(i||uo.note).size(t,t);return this.style.iconNode(n,e.color),r.add(n),this.mindMap.opt.customNoteContentShow||(this.noteEl||(this.noteEl=document.createElement("div"),this.noteEl.style.cssText=` +`).replace(/\n$/g,"").split(/\n/gim),s.forEach((c,f)=>{c===""&&(c="\uFEFF");let m=new Ce().text(c);m.addClass("smm-text-node-wrap"),m.attr("text-anchor",{left:"start",center:"middle",right:"end"}[n]||"start"),this.style.text(m),m.y(r*js*f+(js-1)*r/2),t.add(m)});let{width:h,height:d}=t.bbox();if(d<=0){let c=new Ce().text(o);this.style.text(c),d=c.bbox().height}return h=Math.min(Math.ceil(h),a),d=Math.ceil(d),t.attr("data-width",h),t.attr("data-height",d),t.attr("data-ismultiLine",l||s.length>1),{node:t,width:h,height:d}}function AN(){let{hyperlink:i,hyperlinkTitle:e}=this.getData();if(!i)return;let{customHyperlinkJump:t,hyperlinkIcon:r}=this.mindMap.opt,{icon:n,style:s}=r,a=this.getNodeIconSize("hyperlinkIcon"),o=new Ae().size(a,a),l=new cn().to(i).target("_blank");l.node.addEventListener("click",d=>{typeof t=="function"&&(d.preventDefault(),t(i,this))}),e&&o.add(Ae(`${e}`)),l.rect(a,a).fill({color:"transparent"});let h=Ae(n||$o.hyperlink).size(a,a);return this.style.iconNode(h,s.color),l.add(h),o.add(l),{node:o,width:a,height:a}}function kN(){let i=this.getData("tag");if(!i||i.length<=0)return[];let{maxTag:e,tagsColorMap:t}=this.mindMap.opt;t=t||{};let r=[];return i.slice(0,e).forEach((n,s)=>{let a="",o={...j2};typeof n=="string"?a=n:(a=n.text,o={...j2,...n.style});let l=typeof o.width<"u",h=new _e;h.on("click",()=>{this.mindMap.emit("node_tag_click",this,n,s,h)});let d=new Ce().text(a);this.style.tagText(d,o);let{width:c,height:f}=d.bbox(),m=l?o.width:c+o.paddingX*2,g=l?Math.max(m,c):m,x=Math.max(o.height,f);l?d.x((g-c)/2):d.x(l?0:o.paddingX),d.cy(-x/2);let y=new Ve().size(m,o.height).cy(-x/2);l&&y.x((g-m)/2),this.style.tagRect(y,{...o,fill:o.fill||t[d.node.textContent]||G0(d.node.textContent)}),h.add(y).add(d),r.push({node:h,width:g,height:x})}),r}function CN(){if(!this.getData("note"))return null;let{icon:i,style:e}=this.mindMap.opt.noteIcon,t=this.getNodeIconSize("noteIcon"),r=new Ae().attr("cursor","pointer").addClass("smm-node-note").size(t,t);r.add(new Ve().size(t,t).fill({color:"transparent"}));let n=Ae(i||$o.note).size(t,t);return this.style.iconNode(n,e.color),r.add(n),this.mindMap.opt.customNoteContentShow||(this.noteEl||(this.noteEl=document.createElement("div"),this.noteEl.style.cssText=` position: fixed; padding: 10px; border-radius: 5px; @@ -62,24 +62,24 @@ var jv=Object.create;var Pl=Object.defineProperty;var Gv=Object.getOwnPropertyDe display: none; background-color: #fff; z-index: ${this.mindMap.opt.nodeNoteTooltipZIndex} - `,(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.noteEl)),this.noteEl.innerText=this.getData("note")),r.on("mouseover",()=>{let{left:s,top:a}=this.getNoteContentPosition();this.mindMap.opt.customNoteContentShow?this.mindMap.opt.customNoteContentShow.show(this.getData("note"),s,a,this):(this.noteEl.style.left=s+"px",this.noteEl.style.top=a+"px",this.noteEl.style.display="block")}),r.on("mouseout",()=>{this.mindMap.opt.customNoteContentShow?this.mindMap.opt.customNoteContentShow.hide():this.noteEl.style.display="none"}),r.on("click",s=>{this.mindMap.emit("node_note_click",this,s,r)}),r.on("dblclick",s=>{this.mindMap.emit("node_note_dblclick",this,s,r)}),{node:r,width:t,height:t}}function pM(){let{attachmentUrl:i,attachmentName:e}=this.getData();if(!i)return;let t=this.getNodeIconSize("attachmentIcon"),{icon:r,style:n}=this.mindMap.opt.attachmentIcon,s=new Me().attr("cursor","pointer").size(t,t);e&&s.add(Me(`${e}`)),s.add(new Pe().size(t,t).fill({color:"transparent"}));let a=Me(r||uo.attachment).size(t,t);return this.style.iconNode(a,n.color),s.add(a),s.on("click",o=>{this.mindMap.emit("node_attachmentClick",this,o,s)}),s.on("contextmenu",o=>{this.mindMap.emit("node_attachmentContextmenu",this,o,s)}),{node:s,width:t,height:t}}function gM(i){let{style:e}=this.mindMap.opt[i];return Bt(e.size)?this.mindMap.themeConfig.iconSize:e.size}function xM(){let i=this.getNodeIconSize("noteIcon"),{scaleY:e}=this.mindMap.view.getTransformData().transform,t=i*e,{left:r,top:n}=this._noteData.node.node.getBoundingClientRect();return n+=t,{left:r,top:n}}function vM(i){this.mindMap.commonCaches.measureCustomNodeContentSizeEl||(this.mindMap.commonCaches.measureCustomNodeContentSizeEl=document.createElement("div"),this.mindMap.commonCaches.measureCustomNodeContentSizeEl.style.cssText=` + `,(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.noteEl)),this.noteEl.innerText=this.getData("note")),r.on("mouseover",()=>{let{left:s,top:a}=this.getNoteContentPosition();this.mindMap.opt.customNoteContentShow?this.mindMap.opt.customNoteContentShow.show(this.getData("note"),s,a,this):(this.noteEl.style.left=s+"px",this.noteEl.style.top=a+"px",this.noteEl.style.display="block")}),r.on("mouseout",()=>{this.mindMap.opt.customNoteContentShow?this.mindMap.opt.customNoteContentShow.hide():this.noteEl.style.display="none"}),r.on("click",s=>{this.mindMap.emit("node_note_click",this,s,r)}),r.on("dblclick",s=>{this.mindMap.emit("node_note_dblclick",this,s,r)}),{node:r,width:t,height:t}}function _N(){let{attachmentUrl:i,attachmentName:e}=this.getData();if(!i)return;let t=this.getNodeIconSize("attachmentIcon"),{icon:r,style:n}=this.mindMap.opt.attachmentIcon,s=new Ae().attr("cursor","pointer").size(t,t);e&&s.add(Ae(`${e}`)),s.add(new Ve().size(t,t).fill({color:"transparent"}));let a=Ae(r||$o.attachment).size(t,t);return this.style.iconNode(a,n.color),s.add(a),s.on("click",o=>{this.mindMap.emit("node_attachmentClick",this,o,s)}),s.on("contextmenu",o=>{this.mindMap.emit("node_attachmentContextmenu",this,o,s)}),{node:s,width:t,height:t}}function LN(i){let{style:e}=this.mindMap.opt[i];return Yt(e.size)?this.mindMap.themeConfig.iconSize:e.size}function IN(){let i=this.getNodeIconSize("noteIcon"),{scaleY:e}=this.mindMap.view.getTransformData().transform,t=i*e,{left:r,top:n}=this._noteData.node.node.getBoundingClientRect();return n+=t,{left:r,top:n}}function zN(i){this.mindMap.commonCaches.measureCustomNodeContentSizeEl||(this.mindMap.commonCaches.measureCustomNodeContentSizeEl=document.createElement("div"),this.mindMap.commonCaches.measureCustomNodeContentSizeEl.style.cssText=` position: fixed; left: -99999px; top: -99999px; - `,this.mindMap.el.appendChild(this.mindMap.commonCaches.measureCustomNodeContentSizeEl)),this.mindMap.commonCaches.measureCustomNodeContentSizeEl.innerHTML="",this.mindMap.commonCaches.measureCustomNodeContentSizeEl.appendChild(i);let e=this.mindMap.commonCaches.measureCustomNodeContentSizeEl.getBoundingClientRect();return{width:e.width,height:e.height}}function yM(){return!!this._customNodeContent}var aM,c3,Ac,u3=M(()=>{he();ht();d3();Oe();aM=(i,e)=>{let t=new Ne,r=new Te().text(i);return e.text(r),t.add(r),t.bbox()},c3={radius:3,fontSize:12,fill:"",height:20,paddingX:8};Ac={createImgNode:oM,getImgShowSize:lM,createIconNode:hM,createRichTextNode:dM,createTextNode:cM,createHyperlinkNode:uM,createTagNode:fM,createNoteNode:mM,createAttachmentNode:pM,getNoteContentPosition:xM,getNodeIconSize:gM,measureCustomNodeContentSize:vM,isUseCustomNodeContent:yM}});function bM(){if(this.getChildrenLength()<=0||this.isRoot)return;let{alwaysShowExpandBtn:i,notShowExpandBtn:e,expandBtnSize:t}=this.mindMap.opt;if(!i&&!e){let{width:r,height:n}=this;this._unVisibleRectRegionNode||(this._unVisibleRectRegionNode=new Pe,this._unVisibleRectRegionNode.fill({color:"transparent"})),this.group.add(this._unVisibleRectRegionNode),this.renderer.layout.renderExpandBtnRect(this._unVisibleRectRegionNode,t,r,n,this)}}function wM(){this._unVisibleRectRegionNode&&(this._unVisibleRectRegionNode.remove(),this._unVisibleRectRegionNode=null)}function MM(){this.needRerenderExpandBtnPlaceholderRect&&(this.needRerenderExpandBtnPlaceholderRect=!1,this.renderExpandBtnPlaceholderRect()),this.getChildrenLength()>0?this._unVisibleRectRegionNode||this.renderExpandBtnPlaceholderRect():this._unVisibleRectRegionNode&&this.clearExpandBtnPlaceholderRect()}var kc,f3=M(()=>{ht();kc={renderExpandBtnPlaceholderRect:bM,clearExpandBtnPlaceholderRect:wM,updateExpandBtnPlaceholderRect:MM}});function TM(){this.checkEnableDragModifyNodeWidth()&&(this._dragHandleNodes=null,this.dragHandleWidth=4,this.dragHandleMousedownX=0,this.isDragHandleMousedown=!1,this.dragHandleIndex=0,this.dragHandleMousedownCustomTextWidth=0,this.dragHandleMousedownBodyCursor="",this.dragHandleMousedownLeft=0,this.onDragMousemoveHandle=this.onDragMousemoveHandle.bind(this),window.addEventListener("mousemove",this.onDragMousemoveHandle),this.onDragMouseupHandle=this.onDragMouseupHandle.bind(this),window.addEventListener("mouseup",this.onDragMouseupHandle),this.mindMap.on("node_mouseup",this.onDragMouseupHandle))}function NM(i){if(!this.isDragHandleMousedown)return;i.stopPropagation(),i.preventDefault();let{minNodeTextModifyWidth:e,maxNodeTextModifyWidth:t,isUseCustomNodeContent:r,customCreateNodeContent:n}=this.mindMap.opt,s=r&&n&&this._customNodeContent;document.body.style.cursor="ew-resize",this.group.css({cursor:"ew-resize"});let{scaleX:a}=this.mindMap.draw.transform(),o=i.clientX-this.dragHandleMousedownX,l=this.dragHandleMousedownCustomTextWidth+(this.dragHandleIndex===0?-o:o)/a;if(l=Math.max(l,e),t!==-1&&(l=Math.min(l,t)),!s&&this.getData("image")){let h=this.getImgShowSize();this._rectInfo.textContentWidth-this.customTextWidth+l<=h[0]&&(l=h[0]+this.customTextWidth-this._rectInfo.textContentWidth)}this.customTextWidth=l,this.dragHandleIndex===0&&(this.left=this.dragHandleMousedownLeft+o/a),this.reRender(s?[]:["text"],{ignoreUpdateCustomTextWidth:!0})}function EM(){this.isDragHandleMousedown&&(document.body.style.cursor=this.dragHandleMousedownBodyCursor,this.group.css({cursor:"default"}),this.isDragHandleMousedown=!1,this.dragHandleMousedownX=0,this.dragHandleIndex=0,this.dragHandleMousedownCustomTextWidth=0,this.setData({customTextWidth:this.customTextWidth}),this.mindMap.render(),this.mindMap.emit("dragModifyNodeWidthEnd",this))}function SM(){let i=[new Pe,new Pe];return i.forEach((e,t)=>{e.size(this.dragHandleWidth,this.height).fill({color:"transparent"}).css({cursor:"ew-resize"}),e.on("mousedown",r=>{r.stopPropagation(),r.preventDefault(),this.dragHandleMousedownX=r.clientX,this.dragHandleIndex=t,this.dragHandleMousedownCustomTextWidth=this.customTextWidth===void 0?this._textData?this._textData.width:this.width:this.customTextWidth,this.dragHandleMousedownBodyCursor=document.body.style.cursor,this.dragHandleMousedownLeft=this.left,this.isDragHandleMousedown=!0})}),i}function AM(){this.checkEnableDragModifyNodeWidth()&&(this._dragHandleNodes||(this._dragHandleNodes=this.createDragHandleNode()),this.getData("isActive")?(this._dragHandleNodes.forEach(i=>{i.height(this.height),this.group.add(i)}),this._dragHandleNodes[1].x(this.width-this.dragHandleWidth)):this._dragHandleNodes.forEach(i=>{i.remove()}))}var Cc,m3=M(()=>{ht();Cc={initDragHandle:TM,onDragMousemoveHandle:NM,onDragMouseupHandle:EM,createDragHandleNode:SM,updateDragHandle:AM}});function kM(){this.mindMap.cooperate&&(this._userListGroup=new Ne,this.group.add(this._userListGroup))}function CM(i){let{avatarSize:e,fontSize:t}=this.mindMap.opt.cooperateStyle,r=new Ne,n=i.isMore?i.name:String(i.name)[0],s=new zi().size(e,e);s.fill({color:i.color||i0(n)});let a=new Te().text(n).fill({color:"#fff"}).css({"font-size":t+"px"}).dx(-t/2).dy((e-t)/2);return r.add(s).add(a),r}function _M(i){let{avatarSize:e}=this.mindMap.opt.cooperateStyle;return new Ci().load(i.avatar).size(e,e)}function LM(){if(!this._userListGroup)return;let{avatarSize:i}=this.mindMap.opt.cooperateStyle;this._userListGroup.clear();let e=this.userList.length,t=Math.floor(this.width/i),r=[];e>t?r.push(...this.userList.slice(0,t-1),{isMore:!0,name:"+"+(e-t+1)}):r.push(...this.userList),r.forEach((n,s)=>{let a=null;n.avatar?a=this.createImageAvatar(n):a=this.createTextAvatar(n),a.on("click",o=>{this.mindMap.emit("node_cooperate_avatar_click",n,this,a,o)}),a.on("mouseenter",o=>{this.mindMap.emit("node_cooperate_avatar_mouseenter",n,this,a,o)}),a.on("mouseleave",o=>{this.mindMap.emit("node_cooperate_avatar_mouseleave",n,this,a,o)}),a.x(s*i).cy(-i/2),this._userListGroup.add(a)})}function zM(i){this.userList.find(e=>e.id==i.id)||(this.userList.push(i),this.updateUserListNode())}function IM(i){let e=this.userList.findIndex(t=>t.id==i.id);e!==-1&&(this.userList.splice(e,1),this.updateUserListNode())}function RM(){this.userList=[],this.updateUserListNode()}var _c,p3=M(()=>{ht();he();_c={createUserListNode:kM,updateUserListNode:LM,createTextAvatar:CM,createImageAvatar:_M,addUser:zM,removeUser:IM,emptyUser:RM}});function DM(){this.isGeneralization||(this._quickCreateChildBtn=null,this._showQuickCreateChildBtn=!1)}function OM(){if(!(this.isGeneralization||this.getChildrenLength()>0)){if(this._quickCreateChildBtn)this.group.add(this._quickCreateChildBtn);else{let{quickCreateChildBtnIcon:i,expandBtnStyle:e,expandBtnSize:t}=this.mindMap.opt,{icon:r,style:n}=i,{color:s,fill:a}=e||{color:"#808080",fill:"#fff"};s=n.color||s;let o=Me(r||co.quickCreateChild).size(t,t);o.css({cursor:"pointer"}),o.x(0).y(-t/2),this.style.iconNode(o,s);let l=new zi().size(t);l.x(0).y(-t/2),l.fill({color:a}).css({cursor:"pointer"}),this._quickCreateChildBtn=new Ne,this._quickCreateChildBtn.add(l).add(o),this._quickCreateChildBtn.on("click",h=>{h.stopPropagation(),this.mindMap.emit("quick_create_btn_click",this);let{customQuickCreateChildBtnClick:d}=this.mindMap.opt;if(typeof d=="function"){d(this);return}this.mindMap.execCommand("INSERT_CHILD_NODE",!0,[this])}),this._quickCreateChildBtn.on("dblclick",h=>{h.stopPropagation()}),this._quickCreateChildBtn.addClass("smm-quick-create-child-btn"),this.group.add(this._quickCreateChildBtn)}this._showQuickCreateChildBtn=!0,this.renderer.layout.renderExpandBtn(this,this._quickCreateChildBtn)}}function BM(){this.isGeneralization||this._quickCreateChildBtn&&this._showQuickCreateChildBtn&&(this._quickCreateChildBtn.remove(),this._showQuickCreateChildBtn=!1)}function PM(){if(this.isGeneralization)return;let{isActive:i}=this.getData();i||this.removeQuickCreateChildBtn()}var Lc,g3=M(()=>{Nc();ht();Lc={initQuickCreateChildBtn:DM,showQuickCreateChildBtn:OM,removeQuickCreateChildBtn:BM,hideQuickCreateChildBtn:PM}});function FM(i,e,t,r,n){let{imgTextMargin:s}=this.mindMap.opt;return i==="v"?r>0&&n>0?s:0:e>0&&t>0?s:0}function qM(i){let e=0,t=this._tagData.reduce((r,n)=>(e=Math.max(e,n.height),r+=n.width),0);return t+=(this._tagData.length-1)*i,{width:t,height:e}}function HM(){if(this.isUseCustomNodeContent()){let C=this.measureCustomNodeContentSize(this._customNodeContent);return{width:this.hasCustomWidth()?this.customTextWidth:C.width,height:C.height}}let{TAG_PLACEMENT:i,IMG_PLACEMENT:e}=A,{textContentMargin:t}=this.mindMap.opt,n=(this.getStyle("tagPlacement")||i.RIGHT)===i.BOTTOM,s=this.getStyle("imgPlacement")||e.TOP,a=0,o=0,l=0,h=0,d=0,c=0,f=0;if(this._imgData&&(a=this._imgData.width,o=this._imgData.height),this.mindMap.nodeInnerPrefixList.forEach(C=>{let _=this[`_${C.name}Data`];_&&(l+=_.width,h=Math.max(h,_.height),f++)}),this._prefixData&&(l+=this._prefixData.width,h=Math.max(h,this._prefixData.height),f++),this._iconData.length>0&&(l+=this._iconData.reduce((C,_)=>(h=Math.max(h,_.height),C+=_.width),0)+(this._iconData.length-1)*t,f++),this._textData&&(l+=this._textData.width,h=Math.max(h,this._textData.height),f++),this._hyperlinkData&&(l+=this._hyperlinkData.width,h=Math.max(h,this._hyperlinkData.height),f++),this._tagData.length>0){let{width:C,height:_}=this.getTagContentSize(t);n?(d=C,c=_):(l+=C,h=Math.max(h,_),f++)}this._noteData&&(l+=this._noteData.width,h=Math.max(h,this._noteData.height),f++),this._attachmentData&&(l+=this._attachmentData.width,h=Math.max(h,this._attachmentData.height),f++),this._postfixData&&(l+=this._postfixData.width,h=Math.max(h,this._postfixData.height),f++),this.mindMap.nodeInnerPostfixList.forEach(C=>{let _=this[`_${C.name}Data`];_&&(l+=_.width,h=Math.max(h,_.height),f++)}),l+=(f-1)*t,n&&l>0&&c>0&&(this._rectInfo.textContentWidthWithoutTag=l,l=Math.max(l,d),h=h+t+c),this._rectInfo.textContentWidth=l,this._rectInfo.textContentHeight=h;let m=0,g=0;[e.TOP,e.BOTTOM].includes(s)?(m=Math.max(a,l),g=o+h+this.getImgTextMarin("v",0,0,o,h)):(m=a+l+this.getImgTextMarin("h",a,l),g=Math.max(o,h));let{paddingX:x,paddingY:v}=this.getPaddingVale(),{paddingX:b,paddingY:E}=this.shapeInstance.getShapePadding(m,g,x,v);this.shapePadding.paddingX=b,this.shapePadding.paddingY=E;let S=this.getBorderWidth();return{width:m+x*2+b*2+S,height:g+v*2+E*2+S}}function UM(){if(!this.group)return;this.group.clear();let{hoverRectPadding:i,openRealtimeRenderOnNodeTextEdit:e,textContentMargin:t,addCustomContentToNode:r}=this.mindMap.opt,{width:n,height:s}=this,{paddingX:a,paddingY:o}=this.getPaddingVale(),l=this.getBorderWidth()/2;a+=this.shapePadding.paddingX+l,o+=this.shapePadding.paddingY+l,this.shapeNode=this.shapeInstance.createShape(),this.shapeNode.addClass("smm-node-shape"),this.shapeNode.translate(l,l),this.style.shape(this.shapeNode),this.group.add(this.shapeNode),this.renderExpandBtnPlaceholderRect(),this.createUserListNode&&this.createUserListNode(),this.isGeneralization&&this.generalizationBelongNode&&this.group.addClass("generalization_"+this.generalizationBelongNode.uid);let h=()=>{this.hoverNode=new Pe().size(n+i*2,s+i*2).x(-i).y(-i),this.hoverNode.addClass("smm-hover-node"),this.style.hoverNode(this.hoverNode,n,s),this.group.add(this.hoverNode)};if(this.isUseCustomNodeContent()){let ee=Vr({el:this._customNodeContent,width:n,height:s});this.group.add(ee),h();return}let{IMG_PLACEMENT:d,TAG_PLACEMENT:c}=A,f=this.getStyle("imgPlacement")||d.TOP,g=(this.getStyle("tagPlacement")||c.RIGHT)===c.BOTTOM,{textContentWidth:x,textContentHeight:v,textContentWidthWithoutTag:b}=this._rectInfo,E=v,S=0,C=0,_=this._tagData&&this._tagData.length>0;if(_){let ee=this.getTagContentSize(t);S=ee.width,C=ee.height,g&&(v-=C+t)}let I=0,O=0;if(this._imgData)switch(I=this._imgData.width,O=this._imgData.height,this.group.add(this._imgData.node),f){case d.TOP:this._imgData.node.cx(n/2).y(o);break;case d.BOTTOM:this._imgData.node.cx(n/2).y(s-o-O);break;case d.LEFT:this._imgData.node.x(a).cy(s/2);break;case d.RIGHT:this._imgData.node.x(n-a-I).cy(s/2);break;default:break}let D=new Ne,$=0;if(_&&g&&($=b{let ae=this[`_${ee.name}Data`];ae&&(ae.node.x($).y((v-ae.height)/2),D.add(ae.node),$+=ae.width+t)}),this._prefixData){let ee=Vr({el:this._prefixData.el,width:this._prefixData.width,height:this._prefixData.height});ee.x($).y((v-this._prefixData.height)/2),D.add(ee),$+=this._prefixData.width+t}let F=new Ne;if(this._iconData&&this._iconData.length>0){let ee=0;this._iconData.forEach(ae=>{ae.node.x($+ee).y((v-ae.height)/2),F.add(ae.node),ee+=ae.width+t}),D.add(F),$+=ee}if(this._textData){let ee=this._textData.node.attr("data-offsetx")||0;this._textData.node.attr("data-offsetx",$),(this._textData.nodeContent||this._textData.node).x(-ee).x($).y((v-this._textData.height)/2),e&&this._textData.node.opacity(this.mindMap.renderer.textEdit.getCurrentEditNode()===this?0:1),D.add(this._textData.node),$+=this._textData.width+t}this._hyperlinkData&&(this._hyperlinkData.node.x($).y((v-this._hyperlinkData.height)/2),D.add(this._hyperlinkData.node),$+=this._hyperlinkData.width+t);let Z=new Ne;if(_)if(g){let ee=0;this._tagData.forEach(ae=>{ae.node.x(ee).y((C-ae.height)/2),Z.add(ae.node),ee+=ae.width+t}),Z.x((x-S)/2).y(E-C),D.add(Z)}else{let ee=0;this._tagData.forEach(ae=>{ae.node.x($+ee).y((v-ae.height)/2),Z.add(ae.node),ee+=ae.width+t}),D.add(Z),$+=ee}if(this._noteData&&(this._noteData.node.x($).y((v-this._noteData.height)/2),D.add(this._noteData.node),$+=this._noteData.width+t),this._attachmentData&&(this._attachmentData.node.x($).y((v-this._attachmentData.height)/2),D.add(this._attachmentData.node),$+=this._attachmentData.width+t),this._postfixData){let ee=Vr({el:this._postfixData.el,width:this._postfixData.width,height:this._postfixData.height});ee.x($).y((v-this._postfixData.height)/2),D.add(ee),$+=this._postfixData.width+t}this.mindMap.nodeInnerPostfixList.forEach(ee=>{let ae=this[`_${ee.name}Data`];ae&&(ae.node.x($).y((v-ae.height)/2),D.add(ae.node),$+=ae.width+t)}),this.group.add(D);let{width:re,height:ye}=D.bbox(),G=0,W=0;switch(f){case d.TOP:G=n/2-re/2,W=o+O+this.getImgTextMarin("v",0,0,O,E);break;case d.BOTTOM:G=n/2-re/2,W=o;break;case d.LEFT:G=I+a+this.getImgTextMarin("h",I,x),W=s/2-ye/2;break;case d.RIGHT:G=a,W=s/2-ye/2;break}if(D.translate(G,W),h(),this._customContentAddToNodeAdd&&this._customContentAddToNodeAdd.el){let ee=Vr(this._customContentAddToNodeAdd);this.group.add(ee),r&&typeof r.handle=="function"&&r.handle({content:this._customContentAddToNodeAdd,element:ee,node:this})}this.mindMap.emit("node_layout_end",this)}var zc,x3=M(()=>{Oe();ht();he();zc={getImgTextMarin:FM,getTagContentSize:qM,getNodeRect:HM,layout:UM}});var Ic,Is,a0=M(()=>{s0();Mc();ht();a3();o3();l3();u3();f3();m3();p3();g3();x3();Oe();he();Ic=class i{constructor(e={}){this.opt=e,this.nodeData=this.handleData(e.data||{}),this.nodeDataSnapshot="",this.uid=e.uid,this.mindMap=e.mindMap,this.renderer=e.renderer,this.draw=this.mindMap.draw,this.nodeDraw=this.mindMap.nodeDraw,this.lineDraw=this.mindMap.lineDraw,this.style=new lo(this),this.effectiveStyles={},this.shapeInstance=new ho(this),this.shapePadding={paddingX:0,paddingY:0},this.isRoot=e.isRoot===void 0?!1:e.isRoot,this.isGeneralization=e.isGeneralization===void 0?!1:e.isGeneralization,this.generalizationBelongNode=null,this.layerIndex=e.layerIndex===void 0?0:e.layerIndex,this.width=e.width||0,this.height=e.height||0,this.customTextWidth=e.data.data.customTextWidth||void 0,this._left=e.left||0,this._top=e.top||0,this.customLeft=e.data.data.customLeft||void 0,this.customTop=e.data.data.customTop||void 0,this.isDrag=!1,this.parent=e.parent||null,this.children=e.children||[],this.userList=[],this.group=null,this.shapeNode=null,this.hoverNode=null,this._customNodeContent=null,this._imgData=null,this._iconData=null,this._textData=null,this._hyperlinkData=null,this._tagData=null,this._noteData=null,this.noteEl=null,this.noteContentIsShow=!1,this._attachmentData=null,this._prefixData=null,this._postfixData=null,this._expandBtn=null,this._lastExpandBtnType=null,this._showExpandBtn=!1,this._openExpandNode=null,this._closeExpandNode=null,this._fillExpandNode=null,this._userListGroup=null,this._lines=[],this._generalizationList=[],this._unVisibleRectRegionNode=null,this._isMouseenter=!1,this._customContentAddToNodeAdd=null,this._rectInfo={textContentWidth:0,textContentHeight:0,textContentWidthWithoutTag:0},this._generalizationNodeWidth=0,this._generalizationNodeHeight=0,this.expandBtnSize=this.mindMap.opt.expandBtnSize,this.isMultipleChoice=!1,this.needLayout=!1,this.isHide=!1;let t=Object.getPrototypeOf(this);t.bindEvent||(Object.keys(zc).forEach(r=>{t[r]=zc[r]}),Object.keys(Tc).forEach(r=>{t[r]=Tc[r]}),Object.keys(Ec).forEach(r=>{t[r]=Ec[r]}),Object.keys(kc).forEach(r=>{t[r]=kc[r]}),Object.keys(Sc).forEach(r=>{t[r]=Sc[r]}),Object.keys(Ac).forEach(r=>{t[r]=Ac[r]}),this.mindMap.cooperate&&Object.keys(_c).forEach(r=>{t[r]=_c[r]}),Object.keys(Cc).forEach(r=>{t[r]=Cc[r]}),this.mindMap.opt.isShowCreateChildBtnIcon&&(Object.keys(Lc).forEach(r=>{t[r]=Lc[r]}),this.initQuickCreateChildBtn()),t.bindEvent=!0),this.getSize(),this.updateGeneralization(),this.initDragHandle()}get left(){return this.customLeft||this._left}set left(e){this._left=e}get top(){return this.customTop||this._top}set top(e){this._top=e}reset(){this.children=[],this.parent=null,this.isRoot=!1,this.layerIndex=0,this.left=0,this.top=0}resetWhenDelete(){this._isMouseenter=!1}handleData(e){return e.data.expand=e.data.expand!==!1,e.data.isActive=e.data.isActive===!0,e.children=e.children||[],e}createNodeData(e){let{isUseCustomNodeContent:t,customCreateNodeContent:r,createNodePrefixContent:n,createNodePostfixContent:s,addCustomContentToNode:a}=this.mindMap.opt,o=["custom","image","icon","text","hyperlink","tag","note","attachment","prefix","postfix",...this.mindMap.nodeInnerPrefixList.map(h=>h.name),...this.mindMap.nodeInnerPostfixList.map(h=>h.name)],l={};if(Array.isArray(e)?o.forEach(h=>{e.includes(h)&&(l[h]=!0)}):o.forEach(h=>{l[h]=!0}),t&&r&&l.custom&&(this._customNodeContent=r(this)),this._customNodeContent){$i(this._customNodeContent);return}l.image&&(this._imgData=this.createImgNode()),l.icon&&(this._iconData=this.createIconNode()),l.text&&(this._textData=this.createTextNode()),l.hyperlink&&(this._hyperlinkData=this.createHyperlinkNode()),l.tag&&(this._tagData=this.createTagNode()),l.note&&(this._noteData=this.createNoteNode()),l.attachment&&(this._attachmentData=this.createAttachmentNode()),this.mindMap.nodeInnerPrefixList.forEach(h=>{l[h.name]&&(this[`_${h.name}Data`]=h.createContent(this))}),l.prefix&&(this._prefixData=n?n(this):null,this._prefixData&&this._prefixData.el&&$i(this._prefixData.el)),l.postfix&&(this._postfixData=s?s(this):null,this._postfixData&&this._postfixData.el&&$i(this._postfixData.el)),this.mindMap.nodeInnerPostfixList.forEach(h=>{l[h.name]&&(this[`_${h.name}Data`]=h.createContent(this))}),a&&typeof a.create=="function"&&(this._customContentAddToNodeAdd=a.create(this),this._customContentAddToNodeAdd&&this._customContentAddToNodeAdd.el&&$i(this._customContentAddToNodeAdd.el))}getSize(e,t={}){t.ignoreUpdateCustomTextWidth||(this.customTextWidth=this.getData("customTextWidth")||void 0),this.customLeft=this.getData("customLeft")||void 0,this.customTop=this.getData("customTop")||void 0,this.createNodeData(e);let{width:n,height:s}=this.getNodeRect(),a=this.width!==n||this.height!==s;return this.width=n,this.height=s,a}bindGroupEvent(){this.group.on("click",e=>{if(this.mindMap.emit("node_click",this,e),this.isMultipleChoice){e.stopPropagation(),this.isMultipleChoice=!1;return}this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate&&this.userList.length>0||this.active(e)}),this.group.on("mousedown",e=>{let{readonly:t,enableCtrlKeyNodeSelection:r,useLeftKeySelectionRightKeyDrag:n,mousedownEventPreventDefault:s}=this.mindMap.opt;if(s&&e.preventDefault(),t||(this.isRoot?e.which===3&&!n&&e.stopPropagation():e.which!==2&&e.stopPropagation()),!t&&(e.ctrlKey||e.metaKey)&&r){this.isMultipleChoice=!0;let a=this.getData("isActive");a||this.mindMap.emit("before_node_active",this,this.renderer.activeNodeList),this.mindMap.renderer[a?"removeNodeFromActiveList":"addNodeToActiveList"](this,!0),this.renderer.emitNodeActiveEvent(a?null:this)}this.mindMap.emit("node_mousedown",this,e)}),this.group.on("mouseup",e=>{!this.isRoot&&e.which!==2&&!this.mindMap.opt.readonly&&e.stopPropagation(),this.mindMap.emit("node_mouseup",this,e)}),this.group.on("mouseenter",e=>{this.isDrag||(this._isMouseenter=!0,this.showExpandBtn(),this.isGeneralization&&this.handleGeneralizationMouseenter(),this.mindMap.emit("node_mouseenter",this,e))}),this.group.on("mouseleave",e=>{this._isMouseenter&&(this._isMouseenter=!1,this.hideExpandBtn(),this.isGeneralization&&this.handleGeneralizationMouseleave(),this.mindMap.emit("node_mouseleave",this,e))}),this.group.on("dblclick",e=>{let{readonly:t,onlyOneEnableActiveNodeOnCooperate:r}=this.mindMap.opt;t||e.ctrlKey||e.metaKey||(e.stopPropagation(),!(r&&this.userList.length>0)&&this.mindMap.emit("node_dblclick",this,e))}),this.group.on("contextmenu",e=>{let{readonly:t,useLeftKeySelectionRightKeyDrag:r}=this.mindMap.opt;t||e.ctrlKey||(e.stopPropagation(),e.preventDefault(),!(this.mindMap.select&&!r&&this.mindMap.select.hasSelectRange())&&(this.getData("isActive")&&this.renderer.activeNodeList.length===1||(this.renderer.clearActiveNodeList(),this.active(e)),this.mindMap.emit("node_contextmenu",e,this)))})}active(e){this.mindMap.opt.readonly||(e&&e.stopPropagation(),!this.getData("isActive")&&(this.mindMap.emit("before_node_active",this,this.renderer.activeNodeList),this.renderer.clearActiveNodeList(),this.renderer.addNodeToActiveList(this,!0),this.renderer.emitNodeActiveEvent(this)))}deactivate(){this.mindMap.renderer.removeNodeFromActiveList(this),this.mindMap.renderer.emitNodeActiveEvent()}update(e){if(!this.group)return;this.updateNodeActiveClass();let{alwaysShowExpandBtn:t,notShowExpandBtn:r,isShowCreateChildBtnIcon:n,readonly:s}=this.mindMap.opt,a=this.getChildrenLength();if(!r)if(t)this._expandBtn&&a<=0?this.removeExpandBtn():this.renderExpandBtn();else{let{isActive:l,expand:h}=this.getData();a<=0?this.removeExpandBtn():h&&!l&&!this._isMouseenter?this.hideExpandBtn():this.showExpandBtn()}if(n)if(a>0)this.removeQuickCreateChildBtn();else{let{isActive:l}=this.getData();l?this.showQuickCreateChildBtn():this.hideQuickCreateChildBtn()}this.updateDragHandle(),this.renderGeneralization(e),this.updateUserListNode&&this.updateUserListNode();let o=this.group.transform();this.nodeDataSnapshot=s?"":JSON.stringify(this.getData()),(this.left!==o.translateX||this.top!==o.translateY)&&this.group.translate(this.left-o.translateX,this.top-o.translateY)}getNodePosInClient(e,t){let r=this.mindMap.draw.transform(),{scaleX:n,scaleY:s,translateX:a,translateY:o}=r,l=e*n+a,h=t*s+o;return{left:l,top:h}}checkIsInClient(e=0){let{left:t,top:r}=this.getNodePosInClient(this.left,this.top);return t+this.width>0-e&&r+this.height>0-e&&t{},t=!1,r=!1){this.renderLine();let{openPerformance:n,performanceConfig:s}=this.mindMap.opt;if(t||!n||this.checkIsInClient(s.padding)||this.isRoot?this.group?(this.nodeDraw.has(this.group)||this.nodeDraw.add(this.group),this.needLayout&&(this.needLayout=!1,this.layout()),this.updateExpandBtnPlaceholderRect(),this.update(t)):(this.group=new Ne,this.group.addClass("smm-node"),this.group.css({cursor:"default"}),this.bindGroupEvent(),this.nodeDraw.add(this.group),this.layout(),this.update(t)):n&&s.removeNodeWhenOutCanvas&&this.removeSelf(),this.children&&this.children.length&&this.getData("expand")!==!1){let a=0;this.children.forEach(o=>{let l=()=>{o.render(()=>{a++,a>=this.children.length&&e()},t,r)};r?setTimeout(l,0):l()})}else e();this.nodeData.inserting&&(delete this.nodeData.inserting,this.active(),this.mindMap.emit("node_dblclick",this,null,!0))}removeSelf(){this.group&&(this.group.remove(),this.removeGeneralization())}remove(){this.group&&(this.group.remove(),this.removeGeneralization(),this.removeLine(),this.children&&this.children.length&&this.children.forEach(e=>{e.remove()}))}destroy(){this.removeLine(),this.parent&&this.parent.removeLine(),this.group&&(this.emptyUser&&this.emptyUser(),this.resetWhenDelete(),this.group.remove(),this.removeGeneralization(),this.group=null,this.style.onRemove())}hide(){if(this.group&&this.group.hide(),this.hideGeneralization(),this.parent){let e=this.parent.children.indexOf(this);this.parent._lines[e]&&this.parent._lines[e].hide(),this._lines.forEach(t=>{t.hide()})}this.children&&this.children.length&&this.children.forEach(e=>{e.hide()})}show(){if(this.group){if(this.group.show(),this.showGeneralization(),this.parent){let e=this.parent.children.indexOf(this);this.parent._lines[e]&&this.parent._lines[e].show(),this._lines.forEach(t=>{t.show()})}this.children&&this.children.length&&this.children.forEach(e=>{e.show()})}}setOpacity(e){this.group&&this.group.opacity(e),this._lines.forEach(t=>{t.opacity(e)}),this.children.forEach(t=>{t.setOpacity(e)}),this.setGeneralizationOpacity(e)}hideChildren(){this._lines.forEach(e=>{e.hide()}),this.children&&this.children.length&&this.children.forEach(e=>{e.hide()})}showChildren(){this._lines.forEach(e=>{e.show()}),this.children&&this.children.length&&this.children.forEach(e=>{e.show()})}startDrag(){this.isDrag=!0,this.group&&this.group.addClass("smm-node-dragging")}endDrag(){this.isDrag=!1,this.group&&this.group.removeClass("smm-node-dragging")}renderLine(e=!1){if(this.getData("expand")===!1)return;let t=this.getChildrenLength();this.mindMap.renderer.layout.nodeIsRemoveAllLines&&this.mindMap.renderer.layout.nodeIsRemoveAllLines(this)&&(t=0),t>this._lines.length?new Array(t-this._lines.length).fill(0).forEach(()=>{this._lines.push(this.lineDraw.path())}):t{r.remove()}),this._lines=this._lines.slice(0,t)),this.renderer.layout.renderLine(this,this._lines,(...r)=>{this.styleLine(...r)},this.style.getStyle("lineStyle",!0)),e&&this.children&&this.children.length>0&&this.children.forEach(r=>{r.renderLine(e)})}getShape(){return this.mindMap.themeConfig.nodeUseLineStyle?A.SHAPE.RECTANGLE:this.style.getStyle("shape",!1,!1)}hasCustomPosition(){return this.customLeft!==void 0&&this.customTop!==void 0}ancestorHasCustomPosition(){let e=this;for(;e;){if(e.hasCustomPosition())return!0;e=e.parent}return!1}ancestorHasGeneralization(){let e=this.parent;for(;e;){if(e.checkHasGeneralization())return!0;e=e.parent}return!1}addChildren(e){this.children.push(e)}styleLine(e,t,r){let{enableInheritAncestorLineStyle:n}=this.mindMap.opt,s=n?"getSelfInhertStyle":"getSelfStyle",a=t[s]("lineWidth")||t.getStyle("lineWidth",!0),o=t[s]("lineColor")||this.getRainbowLineColor(t)||t.getStyle("lineColor",!0),l=t[s]("lineDasharray")||t.getStyle("lineDasharray",!0);this.style.line(e,{width:a,color:o,dasharray:l},r,t)}getRainbowLineColor(e){return this.mindMap.rainbowLines?this.mindMap.rainbowLines.getNodeColor(e):""}removeLine(){this._lines.forEach(e=>{e.remove()}),this._lines=[]}isAncestor(e){if(this.uid===e.uid)return!1;let t=e.parent;for(;t;){if(this.uid===t.uid)return!0;t=t.parent}return!1}isParent(e){if(this.uid===e.uid)return!1;let t=e.parent;return!!(t&&this.uid===t.uid)}isBrother(e){return!this.parent||this.uid===e.uid?!1:this.parent.children.find(t=>t.uid===e.uid)}getIndexInBrothers(){return this.parent&&this.parent.children?this.parent.children.findIndex(e=>e.uid===this.uid):-1}getPaddingVale(){return{paddingX:this.getStyle("paddingX"),paddingY:this.getStyle("paddingY")}}getStyle(e,t){let r=this.style.merge(e,t);return r===void 0?"":r}getSelfStyle(e){return this.style.getSelfStyle(e)}getParentSelfStyle(e){return this.parent?this.parent.getSelfStyle(e)||this.parent.getParentSelfStyle(e):null}getSelfInhertStyle(e){return this.getSelfStyle(e)||this.getParentSelfStyle(e)}getBorderWidth(){return this.style.merge("borderWidth",!1)||0}getData(e){return e?this.nodeData.data[e]:this.nodeData.data}getPureData(e=!0,t=!1){return Bn({},this,e,t)}getAncestorNodes(){let e=[],t=this.parent;for(;t;)e.unshift(t),t=t.parent;return e}hasCustomStyle(){return this.style.hasCustomStyle()}getRect(){return this.group?this.group.rbox():null}getRectInSvg(){let{scaleX:e,scaleY:t,translateX:r,translateY:n}=this.mindMap.draw.transform(),{left:s,top:a,width:o,height:l}=this,h=(s+o)*e+r,d=(a+l)*t+n;return s=s*e+r,a=a*t+n,{left:s,right:h,top:a,bottom:d,width:o*e,height:l*t}}highlight(){this.group&&this.group.addClass("smm-node-highlight")}closeHighlight(){this.group&&this.group.removeClass("smm-node-highlight")}fakeClone(){let e=new i({...this.opt,uid:ct()});return Object.keys(this).forEach(t=>{e[t]=this[t]}),e}createSvgTextNode(e=""){return new Te().text(e)}getSvgObjects(){return{SVG:Me,G:Ne,Rect:Pe}}checkEnableDragModifyNodeWidth(){let{enableDragModifyNodeWidth:e,isUseCustomNodeContent:t,customCreateNodeContent:r}=this.mindMap.opt;return e&&(this.mindMap.richText||t&&r)}hasCustomWidth(){return this.checkEnableDragModifyNodeWidth()&&this.customTextWidth!==void 0}getChildrenLength(){return this.nodeData.children?this.nodeData.children.length:0}},Is=Ic});var fo,v3=M(()=>{fo=class{constructor(e){this.max=e||1e3,this.size=0,this.pool=new Map}add(e,t){return!this.has(e)&&this.size>=this.max?!1:(this.delete(e),this.pool.set(e,t),this.size++,!0)}delete(e){this.pool.has(e)&&(this.pool.delete(e),this.size--)}has(e){return this.pool.has(e)}get(e){if(this.pool.has(e))return this.pool.get(e)}clear(){this.size=0,this.pool=new Map}}});var Rc,ut,hr=M(()=>{a0();Oe();v3();he();Rc=class{constructor(e){this.renderer=e,this.mindMap=e.mindMap,this.draw=this.mindMap.draw,this.lineDraw=this.mindMap.lineDraw,this.root=null,this.lru=new fo(this.mindMap.opt.maxNodeCacheCount),this.rootNodeCenterOffset=null}doLayout(){throw new Error("\u3010computed\u3011\u65B9\u6CD5\u4E3A\u5FC5\u8981\u65B9\u6CD5\uFF0C\u9700\u8981\u5B50\u7C7B\u8FDB\u884C\u91CD\u5199\uFF01")}renderLine(){throw new Error("\u3010renderLine\u3011\u65B9\u6CD5\u4E3A\u5FC5\u8981\u65B9\u6CD5\uFF0C\u9700\u8981\u5B50\u7C7B\u8FDB\u884C\u91CD\u5199\uFF01")}renderExpandBtn(){throw new Error("\u3010renderExpandBtn\u3011\u65B9\u6CD5\u4E3A\u5FC5\u8981\u65B9\u6CD5\uFF0C\u9700\u8981\u5B50\u7C7B\u8FDB\u884C\u91CD\u5199\uFF01")}renderGeneralization(){}cacheNode(e,t){this.renderer.nodeCache[e]=t,this.lru.add(e,t)}checkIsNeedResizeSources(){return this.renderer.checkHasRenderSource(A.CHANGE_THEME)}checkIsLayerTypeChange(e,t){if(e>=2&&t>=2)return!1;if(e>=2&&t<2||e<2&&t>=2)return!0}checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(e){this.renderer.checkHasRenderSource(A.CHANGE_LAYOUT)&&(e.needRerenderExpandBtnPlaceholderRect=!0)}checkIsNodeDataChange(e,t){if(e)e=typeof e=="string"?JSON.parse(e):e,e.isActive=t.isActive,e.expand=t.expand,e=JSON.stringify(e);else return!1;return e!==JSON.stringify(t)}checkNodeFixChange(e,t,r){let n=!1;this.mindMap.nodeInnerPrefixList.forEach(a=>{if(a.updateNodeData){let o=a.updateNodeData(e,t);o&&(n=o)}});let s=!1;return this.mindMap.nodeInnerPostfixList.forEach(a=>{if(a.updateNodeData){let o=a.updateNodeData(e,r);o&&(s=o)}}),n||s}createNode(e,t,r,n,s,a){let o={};this.mindMap.nodeInnerPrefixList.forEach(c=>{if(c.createNodeData){let[f,m]=c.createNodeData({data:e,parent:t,ancestors:a,layerIndex:n,index:s});o[f]=m}});let l={};this.mindMap.nodeInnerPostfixList.forEach(c=>{if(c.createNodeData){let[f,m]=c.createNodeData({data:e,parent:t,ancestors:a,layerIndex:n,index:s});l[f]=m}});let h=e.data.uid,d=null;if(e&&e._node&&!this.renderer.reRender){d=e._node;let c=this.checkIsLayerTypeChange(d.layerIndex,n);d.reset(),d.layerIndex=n,r?d.isRoot=!0:d.parent=t._node,this.cacheNode(e._node.uid,d),this.checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(d);let f=this.checkNodeFixChange(d,o,l),m=this.checkIsNeedResizeSources(),g=this.checkIsNodeDataChange(e._node.nodeDataSnapshot,e.data);(m||g||c||d.getData("resetRichText")||d.getData("needUpdate")||f)&&(d.getSize(),d.needLayout=!0),this.checkGetGeneralizationChange(d,m)}else if((this.lru.has(h)||this.renderer.lastNodeCache[h])&&!this.renderer.reRender){d=this.lru.get(h)||this.renderer.lastNodeCache[h];let c=JSON.stringify(d.getData()),f=this.checkIsLayerTypeChange(d.layerIndex,n);d.reset(),d.nodeData=d.handleData(e||{}),d.layerIndex=n,r?d.isRoot=!0:d.parent=t._node,this.cacheNode(h,d),this.checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(d),e._node=d;let m=this.checkIsNeedResizeSources(),g=this.checkIsNodeDataChange(c,e.data),x=this.checkNodeFixChange(d,o,l);(m||g||f||d.getData("resetRichText")||d.getData("needUpdate")||x)&&(d.getSize(),d.needLayout=!0),this.checkGetGeneralizationChange(d,m)}else{let c=h||ct();d=new Is({data:e,uid:c,renderer:this.renderer,mindMap:this.mindMap,draw:this.draw,layerIndex:n,isRoot:r,parent:r?null:t._node,...o}),e.data.uid=c,this.cacheNode(c,d),e._node=d}return e.data.isActive&&this.renderer.addNodeToActiveList(d),this.mindMap.renderer.findActiveNodeIndex(d)!==-1&&d.setData({isActive:!0}),r?this.root=d:t._node.addChildren(d),d}checkGetGeneralizationChange(e,t){let r=e.getData("generalization");r&&e._generalizationList&&e._generalizationList.length>0&&e._generalizationList.forEach((n,s)=>{let a=n.generalizationNode,o=a.getData(),l=r[s];(t||l&&JSON.stringify(o)!==JSON.stringify(l))&&(l&&(a.nodeData.data=l),a.getSize(),a.needLayout=!0)})}formatPosition(e,t,r){return typeof e=="number"?e:Hd[e]!==void 0?t*Hd[e]:/^\d\d*%$/.test(e)?Number.parseFloat(e)/100*t:(t-r)/2}formatInitRootNodePosition(e){let{CENTER:t}=A.INIT_ROOT_NODE_POSITION;return(!e||!Array.isArray(e)||e.length<2)&&(e=[t,t]),e}setNodeCenter(e,t){let{initRootNodePosition:r}=this.mindMap.opt;r=this.formatInitRootNodePosition(t||r),e.left=this.formatPosition(r[0],this.mindMap.width,e.width),e.top=this.formatPosition(r[1],this.mindMap.height,e.height)}getRootCenterOffset(e,t){if(this.rootNodeCenterOffset)return this.rootNodeCenterOffset;let{initRootNodePosition:r}=this.mindMap.opt,{CENTER:n}=A.INIT_ROOT_NODE_POSITION;if(r=this.formatInitRootNodePosition(r),r[0]===n&&r[1]===n)this.rootNodeCenterOffset={x:0,y:0};else{let s={width:e,height:t},a={width:e,height:t};this.setNodeCenter(s,[n,n]),this.setNodeCenter(a),this.rootNodeCenterOffset={x:a.left-s.left,y:a.top-s.top}}return this.rootNodeCenterOffset}updateChildren(e,t,r){e.forEach(n=>{n[t]+=r,n.children&&n.children.length&&!n.hasCustomPosition()&&this.updateChildren(n.children,t,r)})}updateChildrenPro(e,t){e.forEach(r=>{Object.keys(t).forEach(n=>{r[n]+=t[n]}),r.children&&r.children.length&&!r.hasCustomPosition()&&this.updateChildrenPro(r.children,t)})}getNodeAreaWidth(e,t=!1){let r=[],n=0,s=(a,o)=>{t&&a.checkHasGeneralization()&&(n+=a._generalizationNodeWidth),a.children.length?(o+=a.width/2,a.children.forEach(l=>{s(l,o)})):(o+=a.width,r.push(o))};return s(e,0),Math.max(...r)+n}quadraticCurvePath(e,t,r,n,s=!1){let a,o;return s?(a=e+(r-e)*.8,o=t+(n-t)*.2):(a=e+(r-e)*.2,o=t+(n-t)*.8),`M ${e},${t} Q ${a},${o} ${r},${n}`}cubicBezierPath(e,t,r,n,s=!1){let a,o,l,h;return s?(a=e,o=t+(n-t)/2,l=r,h=o):(a=e+(r-e)/2,o=t,l=a,h=n),`M ${e},${t} C ${a},${o} ${l},${h} ${r},${n}`}computeNewPoint(e,t,r=0){if(e[0]===t[0])return t[1]>e[1]?[t[0],t[1]-r]:[t[0],t[1]+r];if(e[1]===t[1])return t[0]>e[0]?[t[0]-r,t[1]]:[t[0]+r,t[1]]}createFoldLine(e){let{lineRadius:t}=this.mindMap.themeConfig,r=e.length,n="",s="";if(r>=3&&t>0){let a=e[r-3],o=e[r-2],l=e[r-1];if(!(a[0].toFixed(0)===o[0].toFixed(0)&&o[0].toFixed(0)===l[0].toFixed(0)||a[1].toFixed(0)===o[1].toFixed(0)&&o[1].toFixed(0)===l[1].toFixed(0))){let d=this.computeNewPoint(a,o,t),c=this.computeNewPoint(l,o,t);s=`Q ${o[0]},${o[1]} ${c[0]},${c[1]}`,e.splice(r-2,1,d,s)}}return e.forEach((a,o)=>{if(typeof a=="string")n+=a;else{let[l,h]=a;o===0?n+=`M ${l},${h}`:n+=`L ${l},${h}`}}),n}getMarginX(e){let{themeConfig:t,opt:r}=this.mindMap,{second:n,node:s}=t,a=r.hoverRectPadding*2;return e===1?n.marginX+a:s.marginX+a}getMarginY(e){let{themeConfig:t,opt:r}=this.mindMap,{second:n,node:s}=t,a=r.hoverRectPadding*2;return e===1?n.marginY+a:s.marginY+a}getNodeWidthWithGeneralization(e){return Math.max(e.width,e.checkHasGeneralization()?e._generalizationNodeWidth:0)}getNodeHeightWithGeneralization(e){return Math.max(e.height,e.checkHasGeneralization()?e._generalizationNodeHeight:0)}getNodeBoundaries(e,t){let{generalizationLineMargin:r,generalizationNodeMargin:n}=this.mindMap.themeConfig,s=d=>{let c=1/0,f=-1/0,m=1/0,g=-1/0;d.children&&d.children.length>0&&d.children.forEach(v=>{let{left:b,right:E,top:S,bottom:C}=s(v),_=v.checkHasGeneralization()&&v.getData("expand")?v._generalizationNodeWidth+n:0,I=v.checkHasGeneralization()&&v.getData("expand")?v._generalizationNodeHeight+n:0;b-(t==="h"?_:0)f&&(f=E+(t==="h"?_:0)),Sg&&(g=C+(t==="v"?I:0))});let x={left:d.left,right:d.left+d.width,top:d.top,bottom:d.top+d.height};return{left:x.leftf?x.right:f,top:x.topg?x.bottom:g}},{left:a,right:o,top:l,bottom:h}=s(e);return{left:a,right:o,top:l,bottom:h,generalizationLineMargin:r,generalizationNodeMargin:n}}getChildrenBoundaries(e,t,r=0,n){let{generalizationLineMargin:s,generalizationNodeMargin:a}=this.mindMap.themeConfig,o=e.children.slice(r,n+1),l=1/0,h=-1/0,d=1/0,c=-1/0;return o.forEach(f=>{let m=this.getNodeBoundaries(f,t);l=m.lefth?m.right:h,d=m.topc?m.bottom:c}),{left:l,right:h,top:d,bottom:c,generalizationLineMargin:s,generalizationNodeMargin:a}}getNodeGeneralizationRenderBoundaries(e,t){let r=null;return e.range?r=this.getChildrenBoundaries(e.node,t,e.range[0],e.range[1]):r=this.getNodeBoundaries(e.node,t),r}getNodeActChildrenLength(e){return e.nodeData.children&&e.nodeData.children.length}setLineStyle(e,t,r,n){t.plot(this.transformPath(r)),e&&e(t,n,!0)}transformPath(e){let{customTransformNodeLinePath:t}=this.mindMap.opt;return t?t(e):e}},ut=Rc});var Dc,o0,Oc=M(()=>{Dc=class{constructor(e){this.mindMap=e,this.autoMoveTimer=null}onMove(e,t,r=()=>{},n=()=>{}){r();let s=this.mindMap.opt.selectTranslateStep,a=this.mindMap.opt.selectTranslateLimit,o=0;e<=this.mindMap.elRect.left+a&&(n("left",s),this.mindMap.view.translateX(s),o++),e>=this.mindMap.elRect.right-a&&(n("right",s),this.mindMap.view.translateX(-s),o++),t<=this.mindMap.elRect.top+a&&(n("top",s),this.mindMap.view.translateY(s),o++),t>=this.mindMap.elRect.bottom-a&&(n("bottom",s),this.mindMap.view.translateY(-s),o++),o>0&&this.startAutoMove(e,t,r,n)}startAutoMove(e,t,r,n){this.autoMoveTimer=setTimeout(()=>{this.onMove(e,t,r,n)},20)}clearAutoMoveTimer(){clearTimeout(this.autoMoveTimer)}},o0=Dc});var y3={};ti(y3,{default:()=>$M});var l0,$M,b3=M(()=>{he();hr();Oe();Oc();l0=class extends ut{constructor({mindMap:e}){super(e.renderer),this.mindMap=e,this.autoMove=new o0(e),this.reset(),this.bindEvent()}reset(){this.isDragging=!1,this.mousedownNode=null,this.beingDragNodeList=[],this.nodeList=[],this.overlapNode=null,this.prevNode=null,this.nextNode=null,this.drawTransform=null,this.clone=null,this.placeholder=null,this.placeholderWidth=50,this.placeholderHeight=10,this.placeHolderLine=null,this.placeHolderExtraLines=[],this.offsetX=0,this.offsetY=0,this.isMousedown=!1,this.mouseDownX=0,this.mouseDownY=0,this.mouseMoveX=0,this.mouseMoveY=0,this.checkDragOffset=10,this.minOffset=10}bindEvent(){this.onNodeMousedown=this.onNodeMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.checkOverlapNode=mi(this.checkOverlapNode,300,this),this.mindMap.on("node_mousedown",this.onNodeMousedown),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("node_mouseup",this.onMouseup),this.mindMap.on("mouseup",this.onMouseup)}unBindEvent(){this.mindMap.off("node_mousedown",this.onNodeMousedown),this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("node_mouseup",this.onMouseup),this.mindMap.off("mouseup",this.onMouseup)}onNodeMousedown(e,t){if(this.mindMap.opt.readonly||t.which!==1||e.isGeneralization||e.isRoot)return;this.isMousedown=!0,this.mousedownNode=e;let{x:r,y:n}=this.mindMap.toPos(t.clientX,t.clientY);this.mouseDownX=r,this.mouseDownY=n}onMousemove(e){if(this.mindMap.opt.readonly||!this.isMousedown)return;e.preventDefault();let{x:t,y:r}=this.mindMap.toPos(e.clientX,e.clientY);this.mouseMoveX=t,this.mouseMoveY=r,!(!this.isDragging&&Math.abs(t-this.mouseDownX)<=this.checkDragOffset&&Math.abs(r-this.mouseDownY)<=this.checkDragOffset)&&(this.mindMap.emit("node_dragging",this.mousedownNode),this.handleStartMove(),this.onMove(t,r,e))}async onMouseup(e){if(!this.isMousedown)return;let{autoMoveWhenMouseInEdgeOnDrag:t,enableFreeDrag:r,beforeDragEnd:n}=this.mindMap.opt;t&&this.mindMap.select&&this.autoMove.clearAutoMoveTimer(),this.isMousedown=!1,this.beingDragNodeList.forEach(l=>{l.setOpacity(1),l.showChildren(),l.endDrag()}),this.removeCloneNode();let s=this.overlapNode?this.overlapNode.getData("uid"):"",a=this.prevNode?this.prevNode.getData("uid"):"",o=this.nextNode?this.nextNode.getData("uid"):"";if(this.isDragging&&typeof n=="function"&&await n({overlapNodeUid:s,prevNodeUid:a,nextNodeUid:o,beingDragNodeList:[...this.beingDragNodeList]})){this.reset();return}if(this.overlapNode)this.removeNodeActive(this.overlapNode),this.mindMap.execCommand("MOVE_NODE_TO",this.beingDragNodeList,this.overlapNode);else if(this.prevNode)this.removeNodeActive(this.prevNode),this.mindMap.execCommand("INSERT_AFTER",this.beingDragNodeList,this.prevNode);else if(this.nextNode)this.removeNodeActive(this.nextNode),this.mindMap.execCommand("INSERT_BEFORE",this.beingDragNodeList,this.nextNode);else if(this.clone&&r&&this.beingDragNodeList.length===1){let{x:l,y:h}=this.mindMap.toPos(e.clientX-this.offsetX,e.clientY-this.offsetY),{scaleX:d,scaleY:c,translateX:f,translateY:m}=this.drawTransform;l=(l-f)/d,h=(h-m)/c,this.mousedownNode.left=l,this.mousedownNode.top=h,this.mousedownNode.customLeft=l,this.mousedownNode.customTop=h,this.mindMap.execCommand("SET_NODE_CUSTOM_POSITION",this.mousedownNode,l,h),this.mindMap.render()}this.isDragging&&this.mindMap.emit("node_dragend",{overlapNodeUid:s,prevNodeUid:a,nextNodeUid:o}),this.reset()}removeNodeActive(e){e.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",e,!1)}onMove(e,t,r){if(!this.isMousedown||!this.isDragging)return;let{scaleX:n,scaleY:s,translateX:a,translateY:o}=this.drawTransform,l=e-this.offsetX,h=t-this.offsetY;e=(l-a)/n,t=(h-o)/s;let d=this.clone.transform();this.clone.translate(e-d.translateX,t-d.translateY),this.checkOverlapNode(),this.drawTransform=this.mindMap.draw.transform(),this.autoMove.clearAutoMoveTimer(),this.autoMove.onMove(r.clientX,r.clientY)}async handleStartMove(){if(!this.isDragging){let e=this.mousedownNode;this.drawTransform=this.mindMap.draw.transform();let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.drawTransform;this.offsetX=this.mouseDownX-(e.left*t+n),this.offsetY=this.mouseDownY-(e.top*r+s),e.getData("isActive")?this.beingDragNodeList=oo(Fn(this.mindMap.renderer.activeNodeList.filter(o=>!o.isRoot&&!o.isGeneralization))):this.beingDragNodeList=[e];let{beforeDragStart:a}=this.mindMap.opt;if(typeof a=="function"&&await a([...this.beingDragNodeList]))return;this.nodeTreeToList(),this.createCloneNode(),this.mindMap.execCommand("CLEAR_ACTIVE_NODE"),this.isDragging=!0}}nodeTreeToList(){let e=[];Pt(this.mindMap.renderer.root,t=>{this.checkIsInBeingDragNodeList(t)||(e[t.layerIndex]||(e[t.layerIndex]=[]),e[t.layerIndex].push(t))}),this.nodeList=e.reduceRight((t,r)=>[...t,...r],[])}createCloneNode(){if(!this.clone){let{dragMultiNodeRectConfig:e,dragPlaceholderRectFill:t,dragPlaceholderLineConfig:r,dragOpacityConfig:n,handleDragCloneNode:s}=this.mindMap.opt,{width:a,height:o,fill:l}=e,h=this.beingDragNodeList[0],d=h.style.merge("lineColor",!0);if(this.beingDragNodeList.length>1)this.clone=this.mindMap.otherDraw.rect().size(a,o).radius(o/2).fill({color:l||d}),this.offsetX=a/2,this.offsetY=o/2;else{this.clone=h.group.clone();let c=this.clone.findOne(".smm-expand-btn");c&&c.remove(),this.mindMap.otherDraw.add(this.clone),typeof s=="function"&&s(this.clone)}this.clone.opacity(n.cloneNodeOpacity),this.clone.css("z-index",99999),this.placeholder=this.mindMap.otherDraw.rect().fill({color:t||d}).radius(5),this.placeHolderLine=this.mindMap.otherDraw.path().stroke({color:r.color||d,width:r.width}).fill({color:"none"}),this.beingDragNodeList.forEach(c=>{c.setOpacity(n.beingDragNodeOpacity),c.hideChildren(),c.startDrag()})}}removeCloneNode(){this.clone&&(this.clone.remove(),this.placeholder.remove(),this.placeHolderLine.remove(),this.removeExtraLines())}removeExtraLines(){this.placeHolderExtraLines.forEach(e=>{e.remove()}),this.placeHolderExtraLines=[]}checkOverlapNode(){if(!this.drawTransform||!this.placeholder)return;let{LOGICAL_STRUCTURE:e,LOGICAL_STRUCTURE_LEFT:t,MIND_MAP:r,ORGANIZATION_STRUCTURE:n,CATALOG_ORGANIZATION:s,TIMELINE:a,TIMELINE2:o,VERTICAL_TIMELINE:l,VERTICAL_TIMELINE2:h,VERTICAL_TIMELINE3:d,FISHBONE:c,FISHBONE2:f,RIGHT_FISHBONE:m,RIGHT_FISHBONE2:g}=A.LAYOUT;this.overlapNode=null,this.prevNode=null,this.nextNode=null,this.placeholder.size(0,0),this.placeHolderLine.hide(),this.removeExtraLines(),this.nodeList.forEach(x=>{if(x.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",x,!1),!(this.overlapNode||this.prevNode&&this.nextNode))switch(this.mindMap.opt.layout){case e:case t:this.handleLogicalStructure(x);break;case r:this.handleMindMap(x);break;case n:this.handleOrganizationStructure(x);break;case s:this.handleCatalogOrganization(x);break;case a:this.handleTimeLine(x);break;case o:this.handleTimeLine2(x);break;case l:case h:case d:this.handleLogicalStructure(x);break;case c:case f:case m:case g:this.handleFishbone(x);break;default:this.handleLogicalStructure(x)}}),this.overlapNode&&this.handleOverlapNode()}handleOverlapNode(){let{LOGICAL_STRUCTURE:e,LOGICAL_STRUCTURE_LEFT:t,MIND_MAP:r,ORGANIZATION_STRUCTURE:n,CATALOG_ORGANIZATION:s,TIMELINE:a,TIMELINE2:o,VERTICAL_TIMELINE:l,VERTICAL_TIMELINE2:h,VERTICAL_TIMELINE3:d,FISHBONE:c,FISHBONE2:f,RIGHT_FISHBONE:m,RIGHT_FISHBONE2:g}=A.LAYOUT,{LEFT:x,TOP:v,RIGHT:b,BOTTOM:E}=A.LAYOUT_GROW_DIR,S=this.overlapNode.layerIndex,C=this.overlapNode.children,_=this.mindMap.renderer.layout.getMarginX(S+1),I=this.mindMap.renderer.layout.getMarginY(S+1),O=this.placeholderWidth/2,D=this.placeholderHeight/2,$="",F="",Z="",re=!1,ye=!1;if(C.length>0){let G=C[C.length-1],W=this.getNodeRect(G);switch($=this.getNewChildNodeDir(G),this.mindMap.opt.layout){case e:case r:F=$===x?W.originRight-this.placeholderWidth:W.originLeft,Z=W.originBottom+this.minOffset-D;break;case t:F=W.originRight-this.placeholderWidth,Z=W.originBottom+this.minOffset-D;break;case n:re=!0,F=W.originRight+this.minOffset-D,Z=W.originTop;break;case s:S===0?(re=!0,F=W.originRight+this.minOffset-D,Z=W.originTop):(F=W.originLeft,Z=W.originBottom+this.minOffset-D);break;case a:S===0?(re=!0,F=W.originRight+this.minOffset-D,Z=W.originTop+W.originHeight/2-O):(F=W.originLeft,Z=W.originBottom+this.minOffset-D);break;case o:S===0?(re=!0,F=W.originRight+this.minOffset-D,Z=W.originTop+W.originHeight/2-O):(F=W.originLeft,S===1?Z=$===v?W.originTop-this.placeholderHeight-this.minOffset+D:W.originBottom+this.minOffset-D:Z=W.originBottom+this.minOffset-D);break;case l:case h:case d:S===0?(F=W.originLeft+W.originWidth/2-O,Z=W.originBottom+this.minOffset-D):(F=$===b?W.originLeft:W.originRight-this.placeholderWidth,Z=W.originBottom+this.minOffset-D);break;case c:case f:case m:case g:S<=1?(ye=!0,this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!0)):(F=W.originLeft,Z=$===v?W.originBottom+this.minOffset-D:W.originTop-this.placeholderHeight-this.minOffset+D);break;default:}}else{let G=this.getNodeRect(this.overlapNode);switch($=this.getNewChildNodeDir(this.overlapNode),this.mindMap.opt.layout){case e:case r:F=$===b?G.originRight+_:G.originLeft-this.placeholderWidth-_,Z=G.originTop+(G.originHeight-this.placeholderHeight)/2;break;case t:F=G.originLeft-this.placeholderWidth-_,Z=G.originTop+(G.originHeight-this.placeholderHeight)/2;break;case n:re=!0,F=G.originLeft+(G.originWidth-this.placeholderHeight)/2,Z=G.originBottom+_;break;case s:S===0&&(re=!0),F=G.originLeft+G.originWidth*.5,Z=G.originBottom+_;break;case a:S===0&&(re=!0),F=G.originLeft+G.originWidth*.5,Z=G.originBottom+I;break;case o:S===0&&(re=!0),F=G.originLeft+G.originWidth*.5,S===1?Z=$===v?G.originTop-this.placeholderHeight-_:G.originBottom+_:Z=G.originBottom+_;break;case l:case h:case d:S===0&&(re=!0),F=$===b?G.originRight+_:G.originLeft-this.placeholderWidth-_,Z=G.originTop+G.originHeight/2-D;break;case c:case f:case m:case g:S<=1?(ye=!0,this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!0)):(F=G.originLeft+G.originWidth*.5,Z=$===E?G.originTop-this.placeholderHeight-this.minOffset+D:G.originBottom+this.minOffset-D);break;default:}}ye||this.setPlaceholderRect({x:F,y:Z,dir:$,rotate:re})}getNewChildNodeDir(e){let{LOGICAL_STRUCTURE:t,LOGICAL_STRUCTURE_LEFT:r,MIND_MAP:n,TIMELINE2:s,VERTICAL_TIMELINE:a,VERTICAL_TIMELINE2:o,VERTICAL_TIMELINE3:l,FISHBONE:h,FISHBONE2:d,RIGHT_FISHBONE:c,RIGHT_FISHBONE2:f}=A.LAYOUT;switch(this.mindMap.opt.layout){case t:return A.LAYOUT_GROW_DIR.RIGHT;case r:return A.LAYOUT_GROW_DIR.LEFT;case n:case s:case a:case o:case l:case h:case d:case c:case f:return e.dir;default:return""}}handleVerticalCheck(e,t,r=!1){let{layout:n}=this.mindMap.opt,{LAYOUT:s,LAYOUT_GROW_DIR:a}=A,{VERTICAL_TIMELINE:o,VERTICAL_TIMELINE2:l,VERTICAL_TIMELINE3:h,FISHBONE:d,FISHBONE2:c,RIGHT_FISHBONE:f,RIGHT_FISHBONE2:m}=s,{LEFT:g}=a,x=this.mouseMoveX,v=this.mouseMoveY,b=this.getNodeRect(e),E=this.getNewChildNodeDir(e),S=e.layerIndex;r&&(t=t.reverse());let C=b.originHeight/4,{prevBrotherOffset:_,nextBrotherOffset:I}=this.getNodeDistanceToSiblingNode(t,e,b,"v");if(b.left<=x&&b.right>=x){if(!this.overlapNode&&!this.prevNode&&!this.nextNode&&!e.isRoot){let O=I>0?v>b.bottom&&v<=b.bottom+I:v>=b.bottom-C&&v<=b.bottom,D=_>0?v=b.top-_:v>=b.top&&v<=b.top+C,{scaleY:$}=this.drawTransform,F=E===g?b.originRight-this.placeholderWidth:b.originLeft,Z=!1;switch(n){case o:case l:case h:S===1&&(F=b.originLeft+b.originWidth/2-this.placeholderWidth/2);break;case f:case m:F=b.originLeft+b.originWidth-this.placeholderWidth;break;default:}if(O){r?this.nextNode=e:this.prevNode=e;let re=b.originBottom+I/$-this.placeholderHeight/2;switch(n){case d:case c:case f:case m:S===2&&(Z=!0,re=b.originBottom+this.minOffset-this.placeholderHeight/2);break;default:}this.setPlaceholderRect({x:F,y:re,dir:E,notRenderLine:Z})}else if(D){r?this.prevNode=e:this.nextNode=e;let re=b.originTop-this.placeholderHeight-_/$+this.placeholderHeight/2;switch(n){case d:case c:case f:case m:S===2&&(Z=!0,re=b.originTop-this.placeholderHeight-this.minOffset+this.placeholderHeight/2);break;default:}this.setPlaceholderRect({x:F,y:re,dir:E,notRenderLine:Z})}}this.checkIsOverlap({node:e,dir:"v",prevBrotherOffset:_,nextBrotherOffset:I,size:C,pos:v,nodeRect:b})}}handleHorizontalCheck(e,t){let{layout:r}=this.mindMap.opt,{LAYOUT:n}=A,{FISHBONE:s,FISHBONE2:a,RIGHT_FISHBONE:o,RIGHT_FISHBONE2:l,TIMELINE:h,TIMELINE2:d}=n,c=this.mouseMoveX,f=this.mouseMoveY,m=this.getNodeRect(e),g=m.originWidth/4,{prevBrotherOffset:x,nextBrotherOffset:v}=this.getNodeDistanceToSiblingNode(t,e,m,"h");if(m.top<=f&&m.bottom>=f){if(!this.overlapNode&&!this.prevNode&&!this.nextNode&&!e.isRoot){let b=v>0?c=m.right:c<=m.right&&c>=m.right-g,E=x>0?c>m.left-x&&c<=m.left:c<=m.left+g&&c>=m.left,{scaleX:S}=this.drawTransform,C=e.layerIndex,_=m.originTop,I=!1;switch(r){case h:case d:_=m.originTop+m.originHeight/2-this.placeholderWidth/2;break;case s:case a:case o:case l:C===1&&(I=!0,_=m.originTop+m.originHeight/2-this.placeholderWidth/2);break;default:}b?([o,l].includes(r)?this.nextNode=e:this.prevNode=e,this.setPlaceholderRect({x:m.originRight+v/S-this.placeholderHeight/2,y:_,rotate:!0,notRenderLine:I})):E&&([o,l].includes(r)?this.prevNode=e:this.nextNode=e,this.setPlaceholderRect({x:m.originLeft-this.placeholderHeight-x/S+this.placeholderHeight/2,y:_,rotate:!0,notRenderLine:I}))}this.checkIsOverlap({node:e,dir:"h",prevBrotherOffset:x,nextBrotherOffset:v,size:g,pos:c,nodeRect:m})}}getNodeDistanceToSiblingNode(e,t,r,n){let{TOP:s,LEFT:a,BOTTOM:o,RIGHT:l}=A.LAYOUT_GROW_DIR,{scaleX:h,scaleY:d}=this.drawTransform,c=n==="v"?s:a,f=n==="v"?o:l,m=n==="v"?d:h,g=this.minOffset*m,x=Ee(t,e),v=null,b=null;x!==-1&&(x-1>=0&&(v=e[x-1]),x+1<=e.length-1&&(b=e[x+1]));let E=0;if(v){let C=this.getNodeRect(v);E=r[c]-C[f],E=E>=g?E/2:0}else E=g;let S=0;return b?(S=this.getNodeRect(b)[c]-r[f],S=S>=g?S/2:0):S=g,{prevBrother:v,prevBrotherOffset:E,nextBrother:b,nextBrotherOffset:S}}setPlaceholderRect({x:e,y:t,dir:r,rotate:n,notRenderLine:s}){let a=this.placeholderWidth,o=this.placeholderHeight;if(n){let f=a;a=o,o=f}if(this.placeholder.size(a,o).move(e,t),s)return;let{dragPlaceholderLineConfig:l}=this.mindMap.opt,h=null,d=null;this.overlapNode?(h=this.overlapNode,d=this.overlapNode):(h=this.prevNode||this.nextNode,d=h.parent),d=d.fakeClone(),h=h.fakeClone();let c=this.beingDragNodeList[0].fakeClone();c.dir=r,c.left=e,c.top=t,c.width=a,c.height=o,d.children=[c],d._lines=[],this.placeHolderLine.show(),this.mindMap.renderer.layout.renderLine(d,[this.placeHolderLine],(...f)=>{},h.style.getStyle("lineStyle",!0)),this.placeHolderExtraLines=[...d._lines],this.placeHolderExtraLines.forEach(f=>{this.mindMap.otherDraw.add(f),f.stroke({color:l.color,width:l.width}).fill({color:"none"})})}checkIsOverlap({node:e,dir:t,prevBrotherOffset:r,nextBrotherOffset:n,size:s,pos:a,nodeRect:o}){let{TOP:l,LEFT:h,BOTTOM:d,RIGHT:c}=A.LAYOUT_GROW_DIR,f=t==="v"?l:h,m=t==="v"?d:c;!this.overlapNode&&!this.prevNode&&!this.nextNode&&o[f]+(r>0?0:s)<=a&&o[m]-(n>0?0:s)>=a&&(this.overlapNode=e)}handleLogicalStructure(e){let t=this.commonGetNodeCheckList(e);this.handleVerticalCheck(e,t)}handleMindMap(e){let t=e.parent?e.parent.children.filter(r=>{let n=!0;return e.layerIndex===1&&(n=r.dir===e.dir),n&&!this.checkIsInBeingDragNodeList(r)}):[];this.handleVerticalCheck(e,t)}handleOrganizationStructure(e){let t=this.commonGetNodeCheckList(e);this.handleHorizontalCheck(e,t)}handleCatalogOrganization(e){let t=this.commonGetNodeCheckList(e);e.layerIndex===1?this.handleHorizontalCheck(e,t):this.handleVerticalCheck(e,t)}handleTimeLine(e){let t=this.commonGetNodeCheckList(e);e.layerIndex===1?this.handleHorizontalCheck(e,t):this.handleVerticalCheck(e,t)}handleTimeLine2(e){let t=this.commonGetNodeCheckList(e);e.layerIndex===1?this.handleHorizontalCheck(e,t):e.dir===A.LAYOUT_GROW_DIR.TOP&&e.layerIndex===2?this.handleVerticalCheck(e,t,!0):this.handleVerticalCheck(e,t)}handleFishbone(e){let t=e.parent?e.parent.children.filter(r=>r.layerIndex>1&&!this.checkIsInBeingDragNodeList(r)):[];if(e.layerIndex===1)this.handleHorizontalCheck(e,t);else{let r=e.dir===A.LAYOUT_GROW_DIR.TOP&&e.layerIndex===2,n=e.dir===A.LAYOUT_GROW_DIR.BOTTOM&&e.layerIndex>=3;r||n?this.handleVerticalCheck(e,t,!0):this.handleVerticalCheck(e,t)}}commonGetNodeCheckList(e){return e.parent?[...e.parent.children].filter(t=>!this.checkIsInBeingDragNodeList(t)):[]}getNodeRect(e){let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.drawTransform,{left:a,top:o,width:l,height:h}=e,d=l,c=h,f=a,m=o,g=o+h,x=a+l,v=(a+l)*t+n,b=(o+h)*r+s;return a=a*t+n,o=o*r+s,{left:a,top:o,right:v,bottom:b,originWidth:d,originHeight:c,originLeft:f,originTop:m,originBottom:g,originRight:x}}checkIsInBeingDragNodeList(e){return!!this.beingDragNodeList.find(t=>t.uid===e.uid||t.isAncestor(e))}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};l0.instanceName="drag";$M=l0});var w3={};ti(w3,{default:()=>jM});var h0,jM,M3=M(()=>{he();Oe();h0=class{constructor(e){this.opt=e,this.mindMap=e.mindMap,this.addShortcut()}addShortcut(){this.onLeftKeyUp=this.onLeftKeyUp.bind(this),this.onUpKeyUp=this.onUpKeyUp.bind(this),this.onRightKeyUp=this.onRightKeyUp.bind(this),this.onDownKeyUp=this.onDownKeyUp.bind(this),this.mindMap.keyCommand.addShortcut(A.KEY_DIR.LEFT,this.onLeftKeyUp),this.mindMap.keyCommand.addShortcut(A.KEY_DIR.UP,this.onUpKeyUp),this.mindMap.keyCommand.addShortcut(A.KEY_DIR.RIGHT,this.onRightKeyUp),this.mindMap.keyCommand.addShortcut(A.KEY_DIR.DOWN,this.onDownKeyUp)}removeShortcut(){this.mindMap.keyCommand.removeShortcut(A.KEY_DIR.LEFT,this.onLeftKeyUp),this.mindMap.keyCommand.removeShortcut(A.KEY_DIR.UP,this.onUpKeyUp),this.mindMap.keyCommand.removeShortcut(A.KEY_DIR.RIGHT,this.onRightKeyUp),this.mindMap.keyCommand.removeShortcut(A.KEY_DIR.DOWN,this.onDownKeyUp)}onLeftKeyUp(){this.onKeyup(A.KEY_DIR.LEFT)}onUpKeyUp(){this.onKeyup(A.KEY_DIR.UP)}onRightKeyUp(){this.onKeyup(A.KEY_DIR.RIGHT)}onDownKeyUp(){this.onKeyup(A.KEY_DIR.DOWN)}onKeyup(e){if(this.mindMap.renderer.activeNodeList.length>0)this.focus(e);else{let t=this.mindMap.renderer.root;this.mindMap.execCommand("GO_TARGET_NODE",t)}}focus(e){let t=this.mindMap.renderer.activeNodeList[0],r=this.getNodeRect(t),n=null,s=1/0,a=(o,l)=>{let h=this.getDistance(r,o);h{if(s.uid===e.uid)return;let a=this.getNodeRect(s),{left:o,top:l,right:h,bottom:d}=a,c=!1;r===A.KEY_DIR.LEFT?c=h<=t.left:r===A.KEY_DIR.RIGHT?c=o>=t.right:r===A.KEY_DIR.UP?c=d<=t.top:r===A.KEY_DIR.DOWN&&(c=l>=t.bottom),c&&n(a,s)})}getFocusNodeByShadowAlgorithm({currentActiveNode:e,currentActiveNodeRect:t,dir:r,checkNodeDis:n}){Pt(this.mindMap.renderer.root,s=>{if(s.uid===e.uid)return;let a=this.getNodeRect(s),{left:o,top:l,right:h,bottom:d}=a,c=!1;r===A.KEY_DIR.LEFT?c=ot.top:r===A.KEY_DIR.RIGHT?c=h>t.right&&lt.top:r===A.KEY_DIR.UP?c=lt.left:r===A.KEY_DIR.DOWN&&(c=d>t.bottom&&ot.left),c&&n(a,s)})}getFocusNodeByAreaAlgorithm({currentActiveNode:e,currentActiveNodeRect:t,dir:r,checkNodeDis:n}){let s=(t.right+t.left)/2,a=(t.bottom+t.top)/2;Pt(this.mindMap.renderer.root,o=>{if(o.uid===e.uid)return;let l=this.getNodeRect(o),{left:h,top:d,right:c,bottom:f}=l,m=(c+h)/2,g=(f+d)/2,x=m-s,v=g-a;if(x===0&&v===0)return;let b=!1;r===A.KEY_DIR.LEFT?b=x<=0&&x<=v&&x<=-v:r===A.KEY_DIR.RIGHT?b=x>0&&x>=-v&&x>=v:r===A.KEY_DIR.UP?b=v<=0&&v0&&-vx),b&&n(l,o)})}getNodeRect(e){let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.mindMap.draw.transform(),{left:a,top:o,width:l,height:h}=e;return{right:(a+l)*t+n,bottom:(o+h)*r+s,left:a*t+n,top:o*r+s}}getDistance(e,t){let r=this.getCenter(e),n=this.getCenter(t);return Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2))}getCenter({left:e,right:t,top:r,bottom:n}){return{x:(e+t)/2,y:(r+n)/2}}beforePluginRemove(){this.removeShortcut()}beforePluginDestroy(){this.removeShortcut()}};h0.instanceName="keyboardNavigation";jM=h0});var Pc,d0,Bc,T3,GM,YM,WM,c0,VM,N3,E3=M(()=>{Pc=i=>String(i).split(/\s+/).map(t=>{if(/^[\d.]+/.test(t)){let r=/^([\d.]+)(.*)$/.exec(t);return[Number(r[1]),r[2]]}else return t}),d0=(i,e)=>i*e,Bc=(i,e)=>e/i,T3={left:0,top:0,center:50,bottom:100,right:100},GM=({backgroundSize:i,drawOpt:e,imageRatio:t,canvasWidth:r,canvasHeight:n,canvasRatio:s})=>{if(i){let a=Pc(i);if(a[0]==="auto"&&a[1]==="auto")return;if(a[0]==="cover"){t>s?(e.height=n,e.width=d0(t,n)):(e.width=r,e.height=Bc(t,r));return}if(a[0]==="contain"){t>s?(e.width=r,e.height=Bc(t,r)):(e.height=n,e.width=d0(t,n));return}let o=-1;a[0]&&(Array.isArray(a[0])?a[0][1]==="%"?(e.width=a[0][0]/100*r,o=e.width):(e.width=a[0][0],o=a[0][0]):a[0]==="auto"&&a[1]&&(a[1][1]==="%"?e.width=d0(t,a[1][0]/100*n):e.width=d0(t,a[1][0]))),a[1]&&Array.isArray(a[1])?a[1][1]==="%"?e.height=a[1][0]/100*n:e.height=a[1][0]:o!==-1&&(e.height=Bc(t,o))}},YM=({backgroundPosition:i,drawOpt:e,imgWidth:t,imgHeight:r,canvasWidth:n,canvasHeight:s})=>{if(i){let a=Pc(i);if(a=a.map(o=>typeof o=="string"&&T3[o]!==void 0?[T3[o],"%"]:o),Array.isArray(a[0])){if(a.length===1&&a.push([50,"%"]),a[0][1]==="%"){let o=a[0][0]/100*n,l=a[0][0]/100*t;e.x=o-l}else e.x=a[0][0];if(a[1][1]==="%"){let o=a[1][0]/100*s,l=a[1][0]/100*r;e.y=o-l}else e.y=a[1][0]}}},WM=({ctx:i,image:e,backgroundRepeat:t,drawOpt:r,imgWidth:n,imgHeight:s,canvasWidth:a,canvasHeight:o})=>{if(t){let l=r.x,h=r.y,d=Math.ceil(l/n),c=Math.ceil(h/s),f=l-d*n,m=h-c*s,g=Pc(t);if(g[0]==="no-repeat"||n>=a&&s>=o)return;if(g[0]==="repeat-x"&&a>n){let x=f;for(;xs){let x=m;for(;xs){let v=m;for(;v{i.drawImage(e,t.sx,t.sy,t.swidth,t.sheight,t.x,t.y,t.width,t.height)},VM=(i,e,t,r,{backgroundSize:n,backgroundPosition:s,backgroundRepeat:a},o=()=>{})=>{let l=e/t,h=new Image;h.src=r,h.onload=()=>{let d=h.width,c=h.height,f=d/c,m={sx:0,sy:0,swidth:d,sheight:c,x:0,y:0,width:d,height:c};GM({backgroundSize:n,drawOpt:m,imageRatio:f,canvasWidth:e,canvasHeight:t,canvasRatio:l}),YM({backgroundPosition:s,drawOpt:m,imgWidth:m.width,imgHeight:m.height,imageRatio:f,canvasWidth:e,canvasHeight:t,canvasRatio:l}),WM({ctx:i,image:h,backgroundRepeat:a,drawOpt:m,imgWidth:m.width,imgHeight:m.height,imageRatio:f,canvasWidth:e,canvasHeight:t,canvasRatio:l})||c0(i,h,m),o()},h.onerror=d=>{o(d)}},N3=VM});var Fc,XM,KM,S3,A3=M(()=>{he();Fc=i=>i.richText?t0(i.text):i.text,XM=i=>new Array(i).fill("#").join(""),KM=i=>new Array(i-6).fill(" ").join("")+"*",S3=i=>{let e="";return se(i,null,(t,r,n,s)=>{let a=s+1;a<=6?e+=XM(a):e+=KM(a),e+=" "+Fc(t.data);let o=t.data.generalization;if(Array.isArray(o))e+=o.map(l=>` [${Fc(l)}]`);else if(o&&o.text){let l=Fc(o);e+=` [${l}]`}e+=` + `,this.mindMap.el.appendChild(this.mindMap.commonCaches.measureCustomNodeContentSizeEl)),this.mindMap.commonCaches.measureCustomNodeContentSizeEl.innerHTML="",this.mindMap.commonCaches.measureCustomNodeContentSizeEl.appendChild(i);let e=this.mindMap.commonCaches.measureCustomNodeContentSizeEl.getBoundingClientRect();return{width:e.width,height:e.height}}function RN(){return!!this._customNodeContent}var wN,j2,ku,G2=T(()=>{pe();yt();$2();$e();wN=(i,e)=>{let t=new _e,r=new Ce().text(i);return e.text(r),t.add(r),t.bbox()},j2={radius:3,fontSize:12,fill:"",height:20,paddingX:8};ku={createImgNode:MN,getImgShowSize:TN,createIconNode:NN,createRichTextNode:EN,createTextNode:SN,createHyperlinkNode:AN,createTagNode:kN,createNoteNode:CN,createAttachmentNode:_N,getNoteContentPosition:IN,getNodeIconSize:LN,measureCustomNodeContentSize:zN,isUseCustomNodeContent:RN}});function DN(){if(this.getChildrenLength()<=0||this.isRoot)return;let{alwaysShowExpandBtn:i,notShowExpandBtn:e,expandBtnSize:t}=this.mindMap.opt;if(!i&&!e){let{width:r,height:n}=this;this._unVisibleRectRegionNode||(this._unVisibleRectRegionNode=new Ve,this._unVisibleRectRegionNode.fill({color:"transparent"})),this.group.add(this._unVisibleRectRegionNode),this.renderer.layout.renderExpandBtnRect(this._unVisibleRectRegionNode,t,r,n,this)}}function ON(){this._unVisibleRectRegionNode&&(this._unVisibleRectRegionNode.remove(),this._unVisibleRectRegionNode=null)}function BN(){this.needRerenderExpandBtnPlaceholderRect&&(this.needRerenderExpandBtnPlaceholderRect=!1,this.renderExpandBtnPlaceholderRect()),this.getChildrenLength()>0?this._unVisibleRectRegionNode||this.renderExpandBtnPlaceholderRect():this._unVisibleRectRegionNode&&this.clearExpandBtnPlaceholderRect()}var Cu,V2=T(()=>{yt();Cu={renderExpandBtnPlaceholderRect:DN,clearExpandBtnPlaceholderRect:ON,updateExpandBtnPlaceholderRect:BN}});function PN(){this.checkEnableDragModifyNodeWidth()&&(this._dragHandleNodes=null,this.dragHandleWidth=4,this.dragHandleMousedownX=0,this.isDragHandleMousedown=!1,this.dragHandleIndex=0,this.dragHandleMousedownCustomTextWidth=0,this.dragHandleMousedownBodyCursor="",this.dragHandleMousedownLeft=0,this.onDragMousemoveHandle=this.onDragMousemoveHandle.bind(this),window.addEventListener("mousemove",this.onDragMousemoveHandle),this.onDragMouseupHandle=this.onDragMouseupHandle.bind(this),window.addEventListener("mouseup",this.onDragMouseupHandle),this.mindMap.on("node_mouseup",this.onDragMouseupHandle))}function FN(i){if(!this.isDragHandleMousedown)return;i.stopPropagation(),i.preventDefault();let{minNodeTextModifyWidth:e,maxNodeTextModifyWidth:t,isUseCustomNodeContent:r,customCreateNodeContent:n}=this.mindMap.opt,s=r&&n&&this._customNodeContent;document.body.style.cursor="ew-resize",this.group.css({cursor:"ew-resize"});let{scaleX:a}=this.mindMap.draw.transform(),o=i.clientX-this.dragHandleMousedownX,l=this.dragHandleMousedownCustomTextWidth+(this.dragHandleIndex===0?-o:o)/a;if(l=Math.max(l,e),t!==-1&&(l=Math.min(l,t)),!s&&this.getData("image")){let h=this.getImgShowSize();this._rectInfo.textContentWidth-this.customTextWidth+l<=h[0]&&(l=h[0]+this.customTextWidth-this._rectInfo.textContentWidth)}this.customTextWidth=l,this.dragHandleIndex===0&&(this.left=this.dragHandleMousedownLeft+o/a),this.reRender(s?[]:["text"],{ignoreUpdateCustomTextWidth:!0})}function qN(){this.isDragHandleMousedown&&(document.body.style.cursor=this.dragHandleMousedownBodyCursor,this.group.css({cursor:"default"}),this.isDragHandleMousedown=!1,this.dragHandleMousedownX=0,this.dragHandleIndex=0,this.dragHandleMousedownCustomTextWidth=0,this.setData({customTextWidth:this.customTextWidth}),this.mindMap.render(),this.mindMap.emit("dragModifyNodeWidthEnd",this))}function HN(){let i=[new Ve,new Ve];return i.forEach((e,t)=>{e.size(this.dragHandleWidth,this.height).fill({color:"transparent"}).css({cursor:"ew-resize"}),e.on("mousedown",r=>{r.stopPropagation(),r.preventDefault(),this.dragHandleMousedownX=r.clientX,this.dragHandleIndex=t,this.dragHandleMousedownCustomTextWidth=this.customTextWidth===void 0?this._textData?this._textData.width:this.width:this.customTextWidth,this.dragHandleMousedownBodyCursor=document.body.style.cursor,this.dragHandleMousedownLeft=this.left,this.isDragHandleMousedown=!0})}),i}function UN(){this.checkEnableDragModifyNodeWidth()&&(this._dragHandleNodes||(this._dragHandleNodes=this.createDragHandleNode()),this.getData("isActive")?(this._dragHandleNodes.forEach(i=>{i.height(this.height),this.group.add(i)}),this._dragHandleNodes[1].x(this.width-this.dragHandleWidth)):this._dragHandleNodes.forEach(i=>{i.remove()}))}var _u,W2=T(()=>{yt();_u={initDragHandle:PN,onDragMousemoveHandle:FN,onDragMouseupHandle:qN,createDragHandleNode:HN,updateDragHandle:UN}});function $N(){this.mindMap.cooperate&&(this._userListGroup=new _e,this.group.add(this._userListGroup))}function jN(i){let{avatarSize:e,fontSize:t}=this.mindMap.opt.cooperateStyle,r=new _e,n=i.isMore?i.name:String(i.name)[0],s=new Wi().size(e,e);s.fill({color:i.color||G0(n)});let a=new Ce().text(n).fill({color:"#fff"}).css({"font-size":t+"px"}).dx(-t/2).dy((e-t)/2);return r.add(s).add(a),r}function GN(i){let{avatarSize:e}=this.mindMap.opt.cooperateStyle;return new ji().load(i.avatar).size(e,e)}function VN(){if(!this._userListGroup)return;let{avatarSize:i}=this.mindMap.opt.cooperateStyle;this._userListGroup.clear();let e=this.userList.length,t=Math.floor(this.width/i),r=[];e>t?r.push(...this.userList.slice(0,t-1),{isMore:!0,name:"+"+(e-t+1)}):r.push(...this.userList),r.forEach((n,s)=>{let a=null;n.avatar?a=this.createImageAvatar(n):a=this.createTextAvatar(n),a.on("click",o=>{this.mindMap.emit("node_cooperate_avatar_click",n,this,a,o)}),a.on("mouseenter",o=>{this.mindMap.emit("node_cooperate_avatar_mouseenter",n,this,a,o)}),a.on("mouseleave",o=>{this.mindMap.emit("node_cooperate_avatar_mouseleave",n,this,a,o)}),a.x(s*i).cy(-i/2),this._userListGroup.add(a)})}function WN(i){this.userList.find(e=>e.id==i.id)||(this.userList.push(i),this.updateUserListNode())}function YN(i){let e=this.userList.findIndex(t=>t.id==i.id);e!==-1&&(this.userList.splice(e,1),this.updateUserListNode())}function XN(){this.userList=[],this.updateUserListNode()}var Lu,Y2=T(()=>{yt();pe();Lu={createUserListNode:$N,updateUserListNode:VN,createTextAvatar:jN,createImageAvatar:GN,addUser:WN,removeUser:YN,emptyUser:XN}});function KN(){this.isGeneralization||(this._quickCreateChildBtn=null,this._showQuickCreateChildBtn=!1)}function ZN(){if(!(this.isGeneralization||this.getChildrenLength()>0)){if(this._quickCreateChildBtn)this.group.add(this._quickCreateChildBtn);else{let{quickCreateChildBtnIcon:i,expandBtnStyle:e,expandBtnSize:t}=this.mindMap.opt,{icon:r,style:n}=i,{color:s,fill:a}=e||{color:"#808080",fill:"#fff"};s=n.color||s;let o=Ae(r||Uo.quickCreateChild).size(t,t);o.css({cursor:"pointer"}),o.x(0).y(-t/2),this.style.iconNode(o,s);let l=new Wi().size(t);l.x(0).y(-t/2),l.fill({color:a}).css({cursor:"pointer"}),this._quickCreateChildBtn=new _e,this._quickCreateChildBtn.add(l).add(o),this._quickCreateChildBtn.on("click",h=>{h.stopPropagation(),this.mindMap.emit("quick_create_btn_click",this);let{customQuickCreateChildBtnClick:d}=this.mindMap.opt;if(typeof d=="function"){d(this);return}this.mindMap.execCommand("INSERT_CHILD_NODE",!0,[this])}),this._quickCreateChildBtn.on("dblclick",h=>{h.stopPropagation()}),this._quickCreateChildBtn.addClass("smm-quick-create-child-btn"),this.group.add(this._quickCreateChildBtn)}this._showQuickCreateChildBtn=!0,this.renderer.layout.renderExpandBtn(this,this._quickCreateChildBtn)}}function QN(){this.isGeneralization||this._quickCreateChildBtn&&this._showQuickCreateChildBtn&&(this._quickCreateChildBtn.remove(),this._showQuickCreateChildBtn=!1)}function JN(){if(this.isGeneralization)return;let{isActive:i}=this.getData();i||this.removeQuickCreateChildBtn()}var Iu,X2=T(()=>{Eu();yt();Iu={initQuickCreateChildBtn:KN,showQuickCreateChildBtn:ZN,removeQuickCreateChildBtn:QN,hideQuickCreateChildBtn:JN}});function eE(i,e,t,r,n){let{imgTextMargin:s}=this.mindMap.opt;return i==="v"?r>0&&n>0?s:0:e>0&&t>0?s:0}function tE(i){let e=0,t=this._tagData.reduce((r,n)=>(e=Math.max(e,n.height),r+=n.width),0);return t+=(this._tagData.length-1)*i,{width:t,height:e}}function iE(){if(this.isUseCustomNodeContent()){let C=this.measureCustomNodeContentSize(this._customNodeContent);return{width:this.hasCustomWidth()?this.customTextWidth:C.width,height:C.height}}let{TAG_PLACEMENT:i,IMG_PLACEMENT:e}=k,{textContentMargin:t}=this.mindMap.opt,n=(this.getStyle("tagPlacement")||i.RIGHT)===i.BOTTOM,s=this.getStyle("imgPlacement")||e.TOP,a=0,o=0,l=0,h=0,d=0,c=0,f=0;if(this._imgData&&(a=this._imgData.width,o=this._imgData.height),this.mindMap.nodeInnerPrefixList.forEach(C=>{let I=this[`_${C.name}Data`];I&&(l+=I.width,h=Math.max(h,I.height),f++)}),this._prefixData&&(l+=this._prefixData.width,h=Math.max(h,this._prefixData.height),f++),this._iconData.length>0&&(l+=this._iconData.reduce((C,I)=>(h=Math.max(h,I.height),C+=I.width),0)+(this._iconData.length-1)*t,f++),this._textData&&(l+=this._textData.width,h=Math.max(h,this._textData.height),f++),this._hyperlinkData&&(l+=this._hyperlinkData.width,h=Math.max(h,this._hyperlinkData.height),f++),this._tagData.length>0){let{width:C,height:I}=this.getTagContentSize(t);n?(d=C,c=I):(l+=C,h=Math.max(h,I),f++)}this._noteData&&(l+=this._noteData.width,h=Math.max(h,this._noteData.height),f++),this._attachmentData&&(l+=this._attachmentData.width,h=Math.max(h,this._attachmentData.height),f++),this._postfixData&&(l+=this._postfixData.width,h=Math.max(h,this._postfixData.height),f++),this.mindMap.nodeInnerPostfixList.forEach(C=>{let I=this[`_${C.name}Data`];I&&(l+=I.width,h=Math.max(h,I.height),f++)}),l+=(f-1)*t,n&&l>0&&c>0&&(this._rectInfo.textContentWidthWithoutTag=l,l=Math.max(l,d),h=h+t+c),this._rectInfo.textContentWidth=l,this._rectInfo.textContentHeight=h;let m=0,g=0;[e.TOP,e.BOTTOM].includes(s)?(m=Math.max(a,l),g=o+h+this.getImgTextMarin("v",0,0,o,h)):(m=a+l+this.getImgTextMarin("h",a,l),g=Math.max(o,h));let{paddingX:x,paddingY:y}=this.getPaddingVale(),{paddingX:b,paddingY:S}=this.shapeInstance.getShapePadding(m,g,x,y);this.shapePadding.paddingX=b,this.shapePadding.paddingY=S;let A=this.getBorderWidth();return{width:m+x*2+b*2+A,height:g+y*2+S*2+A}}function rE(){if(!this.group)return;this.group.clear();let{hoverRectPadding:i,openRealtimeRenderOnNodeTextEdit:e,textContentMargin:t,addCustomContentToNode:r}=this.mindMap.opt,{width:n,height:s}=this,{paddingX:a,paddingY:o}=this.getPaddingVale(),l=this.getBorderWidth()/2;a+=this.shapePadding.paddingX+l,o+=this.shapePadding.paddingY+l,this.shapeNode=this.shapeInstance.createShape(),this.shapeNode.addClass("smm-node-shape"),this.shapeNode.translate(l,l),this.style.shape(this.shapeNode),this.group.add(this.shapeNode),this.renderExpandBtnPlaceholderRect(),this.createUserListNode&&this.createUserListNode(),this.isGeneralization&&this.generalizationBelongNode&&this.group.addClass("generalization_"+this.generalizationBelongNode.uid);let h=()=>{this.hoverNode=new Ve().size(n+i*2,s+i*2).x(-i).y(-i),this.hoverNode.addClass("smm-hover-node"),this.style.hoverNode(this.hoverNode,n,s),this.group.add(this.hoverNode)};if(this.isUseCustomNodeContent()){let le=pn({el:this._customNodeContent,width:n,height:s});this.group.add(le),h();return}let{IMG_PLACEMENT:d,TAG_PLACEMENT:c}=k,f=this.getStyle("imgPlacement")||d.TOP,g=(this.getStyle("tagPlacement")||c.RIGHT)===c.BOTTOM,{textContentWidth:x,textContentHeight:y,textContentWidthWithoutTag:b}=this._rectInfo,S=y,A=0,C=0,I=this._tagData&&this._tagData.length>0;if(I){let le=this.getTagContentSize(t);A=le.width,C=le.height,g&&(y-=C+t)}let O=0,q=0;if(this._imgData)switch(O=this._imgData.width,q=this._imgData.height,this.group.add(this._imgData.node),f){case d.TOP:this._imgData.node.cx(n/2).y(o);break;case d.BOTTOM:this._imgData.node.cx(n/2).y(s-o-q);break;case d.LEFT:this._imgData.node.x(a).cy(s/2);break;case d.RIGHT:this._imgData.node.x(n-a-O).cy(s/2);break;default:break}let P=new _e,W=0;if(I&&g&&(W=b{let ce=this[`_${le.name}Data`];ce&&(ce.node.x(W).y((y-ce.height)/2),P.add(ce.node),W+=ce.width+t)}),this._prefixData){let le=pn({el:this._prefixData.el,width:this._prefixData.width,height:this._prefixData.height});le.x(W).y((y-this._prefixData.height)/2),P.add(le),W+=this._prefixData.width+t}let ne=new _e;if(this._iconData&&this._iconData.length>0){let le=0;this._iconData.forEach(ce=>{ce.node.x(W+le).y((y-ce.height)/2),ne.add(ce.node),le+=ce.width+t}),P.add(ne),W+=le}if(this._textData){let le=this._textData.node.attr("data-offsetx")||0;this._textData.node.attr("data-offsetx",W),(this._textData.nodeContent||this._textData.node).x(-le).x(W).y((y-this._textData.height)/2),e&&this._textData.node.opacity(this.mindMap.renderer.textEdit.getCurrentEditNode()===this?0:1),P.add(this._textData.node),W+=this._textData.width+t}this._hyperlinkData&&(this._hyperlinkData.node.x(W).y((y-this._hyperlinkData.height)/2),P.add(this._hyperlinkData.node),W+=this._hyperlinkData.width+t);let re=new _e;if(I)if(g){let le=0;this._tagData.forEach(ce=>{ce.node.x(le).y((C-ce.height)/2),re.add(ce.node),le+=ce.width+t}),re.x((x-A)/2).y(S-C),P.add(re)}else{let le=0;this._tagData.forEach(ce=>{ce.node.x(W+le).y((y-ce.height)/2),re.add(ce.node),le+=ce.width+t}),P.add(re),W+=le}if(this._noteData&&(this._noteData.node.x(W).y((y-this._noteData.height)/2),P.add(this._noteData.node),W+=this._noteData.width+t),this._attachmentData&&(this._attachmentData.node.x(W).y((y-this._attachmentData.height)/2),P.add(this._attachmentData.node),W+=this._attachmentData.width+t),this._postfixData){let le=pn({el:this._postfixData.el,width:this._postfixData.width,height:this._postfixData.height});le.x(W).y((y-this._postfixData.height)/2),P.add(le),W+=this._postfixData.width+t}this.mindMap.nodeInnerPostfixList.forEach(le=>{let ce=this[`_${le.name}Data`];ce&&(ce.node.x(W).y((y-ce.height)/2),P.add(ce.node),W+=ce.width+t)}),this.group.add(P);let{width:oe,height:ke}=P.bbox(),Q=0,Y=0;switch(f){case d.TOP:Q=n/2-oe/2,Y=o+q+this.getImgTextMarin("v",0,0,q,S);break;case d.BOTTOM:Q=n/2-oe/2,Y=o;break;case d.LEFT:Q=O+a+this.getImgTextMarin("h",O,x),Y=s/2-ke/2;break;case d.RIGHT:Q=a,Y=s/2-ke/2;break}if(P.translate(Q,Y),h(),this._customContentAddToNodeAdd&&this._customContentAddToNodeAdd.el){let le=pn(this._customContentAddToNodeAdd);this.group.add(le),r&&typeof r.handle=="function"&&r.handle({content:this._customContentAddToNodeAdd,element:le,node:this})}this.mindMap.emit("node_layout_end",this)}var zu,K2=T(()=>{$e();yt();pe();zu={getImgTextMarin:eE,getTagContentSize:tE,getNodeRect:iE,layout:rE}});var Ru,da,X0=T(()=>{Y0();Tu();yt();F2();q2();H2();G2();V2();W2();Y2();X2();K2();$e();pe();Ru=class i{constructor(e={}){this.opt=e,this.nodeData=this.handleData(e.data||{}),this.nodeDataSnapshot="",this.uid=e.uid,this.mindMap=e.mindMap,this.renderer=e.renderer,this.draw=this.mindMap.draw,this.nodeDraw=this.mindMap.nodeDraw,this.lineDraw=this.mindMap.lineDraw,this.style=new qo(this),this.effectiveStyles={},this.shapeInstance=new Ho(this),this.shapePadding={paddingX:0,paddingY:0},this.isRoot=e.isRoot===void 0?!1:e.isRoot,this.isGeneralization=e.isGeneralization===void 0?!1:e.isGeneralization,this.generalizationBelongNode=null,this.layerIndex=e.layerIndex===void 0?0:e.layerIndex,this.width=e.width||0,this.height=e.height||0,this.customTextWidth=e.data.data.customTextWidth||void 0,this._left=e.left||0,this._top=e.top||0,this.customLeft=e.data.data.customLeft||void 0,this.customTop=e.data.data.customTop||void 0,this.isDrag=!1,this.parent=e.parent||null,this.children=e.children||[],this.userList=[],this.group=null,this.shapeNode=null,this.hoverNode=null,this._customNodeContent=null,this._imgData=null,this._iconData=null,this._textData=null,this._hyperlinkData=null,this._tagData=null,this._noteData=null,this.noteEl=null,this.noteContentIsShow=!1,this._attachmentData=null,this._prefixData=null,this._postfixData=null,this._expandBtn=null,this._lastExpandBtnType=null,this._showExpandBtn=!1,this._openExpandNode=null,this._closeExpandNode=null,this._fillExpandNode=null,this._userListGroup=null,this._lines=[],this._generalizationList=[],this._unVisibleRectRegionNode=null,this._isMouseenter=!1,this._customContentAddToNodeAdd=null,this._rectInfo={textContentWidth:0,textContentHeight:0,textContentWidthWithoutTag:0},this._generalizationNodeWidth=0,this._generalizationNodeHeight=0,this.expandBtnSize=this.mindMap.opt.expandBtnSize,this.isMultipleChoice=!1,this.needLayout=!1,this.isHide=!1;let t=Object.getPrototypeOf(this);t.bindEvent||(Object.keys(zu).forEach(r=>{t[r]=zu[r]}),Object.keys(Nu).forEach(r=>{t[r]=Nu[r]}),Object.keys(Su).forEach(r=>{t[r]=Su[r]}),Object.keys(Cu).forEach(r=>{t[r]=Cu[r]}),Object.keys(Au).forEach(r=>{t[r]=Au[r]}),Object.keys(ku).forEach(r=>{t[r]=ku[r]}),this.mindMap.cooperate&&Object.keys(Lu).forEach(r=>{t[r]=Lu[r]}),Object.keys(_u).forEach(r=>{t[r]=_u[r]}),this.mindMap.opt.isShowCreateChildBtnIcon&&(Object.keys(Iu).forEach(r=>{t[r]=Iu[r]}),this.initQuickCreateChildBtn()),t.bindEvent=!0),this.getSize(),this.updateGeneralization(),this.initDragHandle()}get left(){return this.customLeft||this._left}set left(e){this._left=e}get top(){return this.customTop||this._top}set top(e){this._top=e}reset(){this.children=[],this.parent=null,this.isRoot=!1,this.layerIndex=0,this.left=0,this.top=0}resetWhenDelete(){this._isMouseenter=!1}handleData(e){return e.data.expand=e.data.expand!==!1,e.data.isActive=e.data.isActive===!0,e.children=e.children||[],e}createNodeData(e){let{isUseCustomNodeContent:t,customCreateNodeContent:r,createNodePrefixContent:n,createNodePostfixContent:s,addCustomContentToNode:a}=this.mindMap.opt,o=["custom","image","icon","text","hyperlink","tag","note","attachment","prefix","postfix",...this.mindMap.nodeInnerPrefixList.map(h=>h.name),...this.mindMap.nodeInnerPostfixList.map(h=>h.name)],l={};if(Array.isArray(e)?o.forEach(h=>{e.includes(h)&&(l[h]=!0)}):o.forEach(h=>{l[h]=!0}),t&&r&&l.custom&&(this._customNodeContent=r(this)),this._customNodeContent){or(this._customNodeContent);return}l.image&&(this._imgData=this.createImgNode()),l.icon&&(this._iconData=this.createIconNode()),l.text&&(this._textData=this.createTextNode()),l.hyperlink&&(this._hyperlinkData=this.createHyperlinkNode()),l.tag&&(this._tagData=this.createTagNode()),l.note&&(this._noteData=this.createNoteNode()),l.attachment&&(this._attachmentData=this.createAttachmentNode()),this.mindMap.nodeInnerPrefixList.forEach(h=>{l[h.name]&&(this[`_${h.name}Data`]=h.createContent(this))}),l.prefix&&(this._prefixData=n?n(this):null,this._prefixData&&this._prefixData.el&&or(this._prefixData.el)),l.postfix&&(this._postfixData=s?s(this):null,this._postfixData&&this._postfixData.el&&or(this._postfixData.el)),this.mindMap.nodeInnerPostfixList.forEach(h=>{l[h.name]&&(this[`_${h.name}Data`]=h.createContent(this))}),a&&typeof a.create=="function"&&(this._customContentAddToNodeAdd=a.create(this),this._customContentAddToNodeAdd&&this._customContentAddToNodeAdd.el&&or(this._customContentAddToNodeAdd.el))}getSize(e,t={}){t.ignoreUpdateCustomTextWidth||(this.customTextWidth=this.getData("customTextWidth")||void 0),this.customLeft=this.getData("customLeft")||void 0,this.customTop=this.getData("customTop")||void 0,this.createNodeData(e);let{width:n,height:s}=this.getNodeRect(),a=this.width!==n||this.height!==s;return this.width=n,this.height=s,a}bindGroupEvent(){this.group.on("click",e=>{if(this.mindMap.emit("node_click",this,e),this.isMultipleChoice){e.stopPropagation(),this.isMultipleChoice=!1;return}this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate&&this.userList.length>0||this.active(e)}),this.group.on("mousedown",e=>{let{readonly:t,enableCtrlKeyNodeSelection:r,useLeftKeySelectionRightKeyDrag:n,mousedownEventPreventDefault:s}=this.mindMap.opt;if(s&&e.preventDefault(),t||(this.isRoot?e.which===3&&!n&&e.stopPropagation():e.which!==2&&e.stopPropagation()),!t&&(e.ctrlKey||e.metaKey)&&r){this.isMultipleChoice=!0;let a=this.getData("isActive");a||this.mindMap.emit("before_node_active",this,this.renderer.activeNodeList),this.mindMap.renderer[a?"removeNodeFromActiveList":"addNodeToActiveList"](this,!0),this.renderer.emitNodeActiveEvent(a?null:this)}this.mindMap.emit("node_mousedown",this,e)}),this.group.on("mouseup",e=>{!this.isRoot&&e.which!==2&&!this.mindMap.opt.readonly&&e.stopPropagation(),this.mindMap.emit("node_mouseup",this,e)}),this.group.on("mouseenter",e=>{this.isDrag||(this._isMouseenter=!0,this.showExpandBtn(),this.isGeneralization&&this.handleGeneralizationMouseenter(),this.mindMap.emit("node_mouseenter",this,e))}),this.group.on("mouseleave",e=>{this._isMouseenter&&(this._isMouseenter=!1,this.hideExpandBtn(),this.isGeneralization&&this.handleGeneralizationMouseleave(),this.mindMap.emit("node_mouseleave",this,e))}),this.group.on("dblclick",e=>{let{readonly:t,onlyOneEnableActiveNodeOnCooperate:r}=this.mindMap.opt;t||e.ctrlKey||e.metaKey||(e.stopPropagation(),!(r&&this.userList.length>0)&&this.mindMap.emit("node_dblclick",this,e))}),this.group.on("contextmenu",e=>{let{readonly:t,useLeftKeySelectionRightKeyDrag:r}=this.mindMap.opt;t||e.ctrlKey||(e.stopPropagation(),e.preventDefault(),!(this.mindMap.select&&!r&&this.mindMap.select.hasSelectRange())&&(this.getData("isActive")&&this.renderer.activeNodeList.length===1||(this.renderer.clearActiveNodeList(),this.active(e)),this.mindMap.emit("node_contextmenu",e,this)))})}active(e){this.mindMap.opt.readonly||(e&&e.stopPropagation(),!this.getData("isActive")&&(this.mindMap.emit("before_node_active",this,this.renderer.activeNodeList),this.renderer.clearActiveNodeList(),this.renderer.addNodeToActiveList(this,!0),this.renderer.emitNodeActiveEvent(this)))}deactivate(){this.mindMap.renderer.removeNodeFromActiveList(this),this.mindMap.renderer.emitNodeActiveEvent()}update(e){if(!this.group)return;this.updateNodeActiveClass();let{alwaysShowExpandBtn:t,notShowExpandBtn:r,isShowCreateChildBtnIcon:n,readonly:s}=this.mindMap.opt,a=this.getChildrenLength();if(!r)if(t)this._expandBtn&&a<=0?this.removeExpandBtn():this.renderExpandBtn();else{let{isActive:l,expand:h}=this.getData();a<=0?this.removeExpandBtn():h&&!l&&!this._isMouseenter?this.hideExpandBtn():this.showExpandBtn()}if(n)if(a>0)this.removeQuickCreateChildBtn();else{let{isActive:l}=this.getData();l?this.showQuickCreateChildBtn():this.hideQuickCreateChildBtn()}this.updateDragHandle(),this.renderGeneralization(e),this.updateUserListNode&&this.updateUserListNode();let o=this.group.transform();this.nodeDataSnapshot=s?"":JSON.stringify(this.getData()),(this.left!==o.translateX||this.top!==o.translateY)&&this.group.translate(this.left-o.translateX,this.top-o.translateY)}getNodePosInClient(e,t){let r=this.mindMap.draw.transform(),{scaleX:n,scaleY:s,translateX:a,translateY:o}=r,l=e*n+a,h=t*s+o;return{left:l,top:h}}checkIsInClient(e=0){let{left:t,top:r}=this.getNodePosInClient(this.left,this.top);return t+this.width>0-e&&r+this.height>0-e&&t{},t=!1,r=!1){this.renderLine();let{openPerformance:n,performanceConfig:s}=this.mindMap.opt;if(t||!n||this.checkIsInClient(s.padding)||this.isRoot?this.group?(this.nodeDraw.has(this.group)||this.nodeDraw.add(this.group),this.needLayout&&(this.needLayout=!1,this.layout()),this.updateExpandBtnPlaceholderRect(),this.update(t)):(this.group=new _e,this.group.addClass("smm-node"),this.group.css({cursor:"default"}),this.bindGroupEvent(),this.nodeDraw.add(this.group),this.layout(),this.update(t)):n&&s.removeNodeWhenOutCanvas&&this.removeSelf(),this.children&&this.children.length&&this.getData("expand")!==!1){let a=0;this.children.forEach(o=>{let l=()=>{o.render(()=>{a++,a>=this.children.length&&e()},t,r)};r?setTimeout(l,0):l()})}else e();this.nodeData.inserting&&(delete this.nodeData.inserting,this.active(),this.mindMap.emit("node_dblclick",this,null,!0))}removeSelf(){this.group&&(this.group.remove(),this.removeGeneralization())}remove(){this.group&&(this.group.remove(),this.removeGeneralization(),this.removeLine(),this.children&&this.children.length&&this.children.forEach(e=>{e.remove()}))}destroy(){this.removeLine(),this.parent&&this.parent.removeLine(),this.group&&(this.emptyUser&&this.emptyUser(),this.resetWhenDelete(),this.group.remove(),this.removeGeneralization(),this.group=null,this.style.onRemove())}hide(){if(this.group&&this.group.hide(),this.hideGeneralization(),this.parent){let e=this.parent.children.indexOf(this);this.parent._lines[e]&&this.parent._lines[e].hide(),this._lines.forEach(t=>{t.hide()})}this.children&&this.children.length&&this.children.forEach(e=>{e.hide()})}show(){if(this.group){if(this.group.show(),this.showGeneralization(),this.parent){let e=this.parent.children.indexOf(this);this.parent._lines[e]&&this.parent._lines[e].show(),this._lines.forEach(t=>{t.show()})}this.children&&this.children.length&&this.children.forEach(e=>{e.show()})}}setOpacity(e){this.group&&this.group.opacity(e),this._lines.forEach(t=>{t.opacity(e)}),this.children.forEach(t=>{t.setOpacity(e)}),this.setGeneralizationOpacity(e)}hideChildren(){this._lines.forEach(e=>{e.hide()}),this.children&&this.children.length&&this.children.forEach(e=>{e.hide()})}showChildren(){this._lines.forEach(e=>{e.show()}),this.children&&this.children.length&&this.children.forEach(e=>{e.show()})}startDrag(){this.isDrag=!0,this.group&&this.group.addClass("smm-node-dragging")}endDrag(){this.isDrag=!1,this.group&&this.group.removeClass("smm-node-dragging")}renderLine(e=!1){if(this.getData("expand")===!1)return;let t=this.getChildrenLength();this.mindMap.renderer.layout.nodeIsRemoveAllLines&&this.mindMap.renderer.layout.nodeIsRemoveAllLines(this)&&(t=0),t>this._lines.length?new Array(t-this._lines.length).fill(0).forEach(()=>{this._lines.push(this.lineDraw.path())}):t{r.remove()}),this._lines=this._lines.slice(0,t)),this.renderer.layout.renderLine(this,this._lines,(...r)=>{this.styleLine(...r)},this.style.getStyle("lineStyle",!0)),e&&this.children&&this.children.length>0&&this.children.forEach(r=>{r.renderLine(e)})}getShape(){return this.mindMap.themeConfig.nodeUseLineStyle?k.SHAPE.RECTANGLE:this.style.getStyle("shape",!1,!1)}hasCustomPosition(){return this.customLeft!==void 0&&this.customTop!==void 0}ancestorHasCustomPosition(){let e=this;for(;e;){if(e.hasCustomPosition())return!0;e=e.parent}return!1}ancestorHasGeneralization(){let e=this.parent;for(;e;){if(e.checkHasGeneralization())return!0;e=e.parent}return!1}addChildren(e){this.children.push(e)}styleLine(e,t,r){let{enableInheritAncestorLineStyle:n}=this.mindMap.opt,s=n?"getSelfInhertStyle":"getSelfStyle",a=t[s]("lineWidth")||t.getStyle("lineWidth",!0),o=t[s]("lineColor")||this.getRainbowLineColor(t)||t.getStyle("lineColor",!0),l=t[s]("lineDasharray")||t.getStyle("lineDasharray",!0);this.style.line(e,{width:a,color:o,dasharray:l},r,t)}getRainbowLineColor(e){return this.mindMap.rainbowLines?this.mindMap.rainbowLines.getNodeColor(e):""}removeLine(){this._lines.forEach(e=>{e.remove()}),this._lines=[]}isAncestor(e){if(this.uid===e.uid)return!1;let t=e.parent;for(;t;){if(this.uid===t.uid)return!0;t=t.parent}return!1}isParent(e){if(this.uid===e.uid)return!1;let t=e.parent;return!!(t&&this.uid===t.uid)}isBrother(e){return!this.parent||this.uid===e.uid?!1:this.parent.children.find(t=>t.uid===e.uid)}getIndexInBrothers(){return this.parent&&this.parent.children?this.parent.children.findIndex(e=>e.uid===this.uid):-1}getPaddingVale(){return{paddingX:this.getStyle("paddingX"),paddingY:this.getStyle("paddingY")}}getStyle(e,t){let r=this.style.merge(e,t);return r===void 0?"":r}getSelfStyle(e){return this.style.getSelfStyle(e)}getParentSelfStyle(e){return this.parent?this.parent.getSelfStyle(e)||this.parent.getParentSelfStyle(e):null}getSelfInhertStyle(e){return this.getSelfStyle(e)||this.getParentSelfStyle(e)}getBorderWidth(){return this.style.merge("borderWidth",!1)||0}getData(e){return e?this.nodeData.data[e]:this.nodeData.data}getPureData(e=!0,t=!1){return ls({},this,e,t)}getAncestorNodes(){let e=[],t=this.parent;for(;t;)e.unshift(t),t=t.parent;return e}hasCustomStyle(){return this.style.hasCustomStyle()}getRect(){return this.group?this.group.rbox():null}getRectInSvg(){let{scaleX:e,scaleY:t,translateX:r,translateY:n}=this.mindMap.draw.transform(),{left:s,top:a,width:o,height:l}=this,h=(s+o)*e+r,d=(a+l)*t+n;return s=s*e+r,a=a*t+n,{left:s,right:h,top:a,bottom:d,width:o*e,height:l*t}}highlight(){this.group&&this.group.addClass("smm-node-highlight")}closeHighlight(){this.group&&this.group.removeClass("smm-node-highlight")}fakeClone(){let e=new i({...this.opt,uid:wt()});return Object.keys(this).forEach(t=>{e[t]=this[t]}),e}createSvgTextNode(e=""){return new Ce().text(e)}getSvgObjects(){return{SVG:Ae,G:_e,Rect:Ve}}checkEnableDragModifyNodeWidth(){let{enableDragModifyNodeWidth:e,isUseCustomNodeContent:t,customCreateNodeContent:r}=this.mindMap.opt;return e&&(this.mindMap.richText||t&&r)}hasCustomWidth(){return this.checkEnableDragModifyNodeWidth()&&this.customTextWidth!==void 0}getChildrenLength(){return this.nodeData.children?this.nodeData.children.length:0}},da=Ru});var jo,Z2=T(()=>{jo=class{constructor(e){this.max=e||1e3,this.size=0,this.pool=new Map}add(e,t){return!this.has(e)&&this.size>=this.max?!1:(this.delete(e),this.pool.set(e,t),this.size++,!0)}delete(e){this.pool.has(e)&&(this.pool.delete(e),this.size--)}has(e){return this.pool.has(e)}get(e){if(this.pool.has(e))return this.pool.get(e)}clear(){this.size=0,this.pool=new Map}}});var Du,Mt,Ar=T(()=>{X0();$e();Z2();pe();Du=class{constructor(e){this.renderer=e,this.mindMap=e.mindMap,this.draw=this.mindMap.draw,this.lineDraw=this.mindMap.lineDraw,this.root=null,this.lru=new jo(this.mindMap.opt.maxNodeCacheCount),this.rootNodeCenterOffset=null}doLayout(){throw new Error("\u3010computed\u3011\u65B9\u6CD5\u4E3A\u5FC5\u8981\u65B9\u6CD5\uFF0C\u9700\u8981\u5B50\u7C7B\u8FDB\u884C\u91CD\u5199\uFF01")}renderLine(){throw new Error("\u3010renderLine\u3011\u65B9\u6CD5\u4E3A\u5FC5\u8981\u65B9\u6CD5\uFF0C\u9700\u8981\u5B50\u7C7B\u8FDB\u884C\u91CD\u5199\uFF01")}renderExpandBtn(){throw new Error("\u3010renderExpandBtn\u3011\u65B9\u6CD5\u4E3A\u5FC5\u8981\u65B9\u6CD5\uFF0C\u9700\u8981\u5B50\u7C7B\u8FDB\u884C\u91CD\u5199\uFF01")}renderGeneralization(){}cacheNode(e,t){this.renderer.nodeCache[e]=t,this.lru.add(e,t)}checkIsNeedResizeSources(){return this.renderer.checkHasRenderSource(k.CHANGE_THEME)}checkIsLayerTypeChange(e,t){if(e>=2&&t>=2)return!1;if(e>=2&&t<2||e<2&&t>=2)return!0}checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(e){this.renderer.checkHasRenderSource(k.CHANGE_LAYOUT)&&(e.needRerenderExpandBtnPlaceholderRect=!0)}checkIsNodeDataChange(e,t){if(e)e=typeof e=="string"?JSON.parse(e):e,e.isActive=t.isActive,e.expand=t.expand,e=JSON.stringify(e);else return!1;return e!==JSON.stringify(t)}checkNodeFixChange(e,t,r){let n=!1;this.mindMap.nodeInnerPrefixList.forEach(a=>{if(a.updateNodeData){let o=a.updateNodeData(e,t);o&&(n=o)}});let s=!1;return this.mindMap.nodeInnerPostfixList.forEach(a=>{if(a.updateNodeData){let o=a.updateNodeData(e,r);o&&(s=o)}}),n||s}createNode(e,t,r,n,s,a){let o={};this.mindMap.nodeInnerPrefixList.forEach(c=>{if(c.createNodeData){let[f,m]=c.createNodeData({data:e,parent:t,ancestors:a,layerIndex:n,index:s});o[f]=m}});let l={};this.mindMap.nodeInnerPostfixList.forEach(c=>{if(c.createNodeData){let[f,m]=c.createNodeData({data:e,parent:t,ancestors:a,layerIndex:n,index:s});l[f]=m}});let h=e.data.uid,d=null;if(e&&e._node&&!this.renderer.reRender){d=e._node;let c=this.checkIsLayerTypeChange(d.layerIndex,n);d.reset(),d.layerIndex=n,r?d.isRoot=!0:d.parent=t._node,this.cacheNode(e._node.uid,d),this.checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(d);let f=this.checkNodeFixChange(d,o,l),m=this.checkIsNeedResizeSources(),g=this.checkIsNodeDataChange(e._node.nodeDataSnapshot,e.data);(m||g||c||d.getData("resetRichText")||d.getData("needUpdate")||f)&&(d.getSize(),d.needLayout=!0),this.checkGetGeneralizationChange(d,m)}else if((this.lru.has(h)||this.renderer.lastNodeCache[h])&&!this.renderer.reRender){d=this.lru.get(h)||this.renderer.lastNodeCache[h];let c=JSON.stringify(d.getData()),f=this.checkIsLayerTypeChange(d.layerIndex,n);d.reset(),d.nodeData=d.handleData(e||{}),d.layerIndex=n,r?d.isRoot=!0:d.parent=t._node,this.cacheNode(h,d),this.checkIsLayoutChangeRerenderExpandBtnPlaceholderRect(d),e._node=d;let m=this.checkIsNeedResizeSources(),g=this.checkIsNodeDataChange(c,e.data),x=this.checkNodeFixChange(d,o,l);(m||g||f||d.getData("resetRichText")||d.getData("needUpdate")||x)&&(d.getSize(),d.needLayout=!0),this.checkGetGeneralizationChange(d,m)}else{let c=h||wt();d=new da({data:e,uid:c,renderer:this.renderer,mindMap:this.mindMap,draw:this.draw,layerIndex:n,isRoot:r,parent:r?null:t._node,...o}),e.data.uid=c,this.cacheNode(c,d),e._node=d}return e.data.isActive&&this.renderer.addNodeToActiveList(d),this.mindMap.renderer.findActiveNodeIndex(d)!==-1&&d.setData({isActive:!0}),r?this.root=d:t._node.addChildren(d),d}checkGetGeneralizationChange(e,t){let r=e.getData("generalization");r&&e._generalizationList&&e._generalizationList.length>0&&e._generalizationList.forEach((n,s)=>{let a=n.generalizationNode,o=a.getData(),l=r[s];(t||l&&JSON.stringify(o)!==JSON.stringify(l))&&(l&&(a.nodeData.data=l),a.getSize(),a.needLayout=!0)})}formatPosition(e,t,r){return typeof e=="number"?e:Uc[e]!==void 0?t*Uc[e]:/^\d\d*%$/.test(e)?Number.parseFloat(e)/100*t:(t-r)/2}formatInitRootNodePosition(e){let{CENTER:t}=k.INIT_ROOT_NODE_POSITION;return(!e||!Array.isArray(e)||e.length<2)&&(e=[t,t]),e}setNodeCenter(e,t){let{initRootNodePosition:r}=this.mindMap.opt;r=this.formatInitRootNodePosition(t||r),e.left=this.formatPosition(r[0],this.mindMap.width,e.width),e.top=this.formatPosition(r[1],this.mindMap.height,e.height)}getRootCenterOffset(e,t){if(this.rootNodeCenterOffset)return this.rootNodeCenterOffset;let{initRootNodePosition:r}=this.mindMap.opt,{CENTER:n}=k.INIT_ROOT_NODE_POSITION;if(r=this.formatInitRootNodePosition(r),r[0]===n&&r[1]===n)this.rootNodeCenterOffset={x:0,y:0};else{let s={width:e,height:t},a={width:e,height:t};this.setNodeCenter(s,[n,n]),this.setNodeCenter(a),this.rootNodeCenterOffset={x:a.left-s.left,y:a.top-s.top}}return this.rootNodeCenterOffset}updateChildren(e,t,r){e.forEach(n=>{n[t]+=r,n.children&&n.children.length&&!n.hasCustomPosition()&&this.updateChildren(n.children,t,r)})}updateChildrenPro(e,t){e.forEach(r=>{Object.keys(t).forEach(n=>{r[n]+=t[n]}),r.children&&r.children.length&&!r.hasCustomPosition()&&this.updateChildrenPro(r.children,t)})}getNodeAreaWidth(e,t=!1){let r=[],n=0,s=(a,o)=>{t&&a.checkHasGeneralization()&&(n+=a._generalizationNodeWidth),a.children.length?(o+=a.width/2,a.children.forEach(l=>{s(l,o)})):(o+=a.width,r.push(o))};return s(e,0),Math.max(...r)+n}quadraticCurvePath(e,t,r,n,s=!1){let a,o;return s?(a=e+(r-e)*.8,o=t+(n-t)*.2):(a=e+(r-e)*.2,o=t+(n-t)*.8),`M ${e},${t} Q ${a},${o} ${r},${n}`}cubicBezierPath(e,t,r,n,s=!1){let a,o,l,h;return s?(a=e,o=t+(n-t)/2,l=r,h=o):(a=e+(r-e)/2,o=t,l=a,h=n),`M ${e},${t} C ${a},${o} ${l},${h} ${r},${n}`}computeNewPoint(e,t,r=0){if(e[0]===t[0])return t[1]>e[1]?[t[0],t[1]-r]:[t[0],t[1]+r];if(e[1]===t[1])return t[0]>e[0]?[t[0]-r,t[1]]:[t[0]+r,t[1]]}createFoldLine(e){let{lineRadius:t}=this.mindMap.themeConfig,r=e.length,n="",s="";if(r>=3&&t>0){let a=e[r-3],o=e[r-2],l=e[r-1];if(!(a[0].toFixed(0)===o[0].toFixed(0)&&o[0].toFixed(0)===l[0].toFixed(0)||a[1].toFixed(0)===o[1].toFixed(0)&&o[1].toFixed(0)===l[1].toFixed(0))){let d=this.computeNewPoint(a,o,t),c=this.computeNewPoint(l,o,t);s=`Q ${o[0]},${o[1]} ${c[0]},${c[1]}`,e.splice(r-2,1,d,s)}}return e.forEach((a,o)=>{if(typeof a=="string")n+=a;else{let[l,h]=a;o===0?n+=`M ${l},${h}`:n+=`L ${l},${h}`}}),n}getMarginX(e){let{themeConfig:t,opt:r}=this.mindMap,{second:n,node:s}=t,a=r.hoverRectPadding*2;return e===1?n.marginX+a:s.marginX+a}getMarginY(e){let{themeConfig:t,opt:r}=this.mindMap,{second:n,node:s}=t,a=r.hoverRectPadding*2;return e===1?n.marginY+a:s.marginY+a}getNodeWidthWithGeneralization(e){return Math.max(e.width,e.checkHasGeneralization()?e._generalizationNodeWidth:0)}getNodeHeightWithGeneralization(e){return Math.max(e.height,e.checkHasGeneralization()?e._generalizationNodeHeight:0)}getNodeBoundaries(e,t){let{generalizationLineMargin:r,generalizationNodeMargin:n}=this.mindMap.themeConfig,s=d=>{let c=1/0,f=-1/0,m=1/0,g=-1/0;d.children&&d.children.length>0&&d.children.forEach(y=>{let{left:b,right:S,top:A,bottom:C}=s(y),I=y.checkHasGeneralization()&&y.getData("expand")?y._generalizationNodeWidth+n:0,O=y.checkHasGeneralization()&&y.getData("expand")?y._generalizationNodeHeight+n:0;b-(t==="h"?I:0)f&&(f=S+(t==="h"?I:0)),Ag&&(g=C+(t==="v"?O:0))});let x={left:d.left,right:d.left+d.width,top:d.top,bottom:d.top+d.height};return{left:x.leftf?x.right:f,top:x.topg?x.bottom:g}},{left:a,right:o,top:l,bottom:h}=s(e);return{left:a,right:o,top:l,bottom:h,generalizationLineMargin:r,generalizationNodeMargin:n}}getChildrenBoundaries(e,t,r=0,n){let{generalizationLineMargin:s,generalizationNodeMargin:a}=this.mindMap.themeConfig,o=e.children.slice(r,n+1),l=1/0,h=-1/0,d=1/0,c=-1/0;return o.forEach(f=>{let m=this.getNodeBoundaries(f,t);l=m.lefth?m.right:h,d=m.topc?m.bottom:c}),{left:l,right:h,top:d,bottom:c,generalizationLineMargin:s,generalizationNodeMargin:a}}getNodeGeneralizationRenderBoundaries(e,t){let r=null;return e.range?r=this.getChildrenBoundaries(e.node,t,e.range[0],e.range[1]):r=this.getNodeBoundaries(e.node,t),r}getNodeActChildrenLength(e){return e.nodeData.children&&e.nodeData.children.length}setLineStyle(e,t,r,n){t.plot(this.transformPath(r)),e&&e(t,n,!0)}transformPath(e){let{customTransformNodeLinePath:t}=this.mindMap.opt;return t?t(e):e}},Mt=Du});var Ou,K0,Bu=T(()=>{Ou=class{constructor(e){this.mindMap=e,this.autoMoveTimer=null}onMove(e,t,r=()=>{},n=()=>{}){r();let s=this.mindMap.opt.selectTranslateStep,a=this.mindMap.opt.selectTranslateLimit,o=0;e<=this.mindMap.elRect.left+a&&(n("left",s),this.mindMap.view.translateX(s),o++),e>=this.mindMap.elRect.right-a&&(n("right",s),this.mindMap.view.translateX(-s),o++),t<=this.mindMap.elRect.top+a&&(n("top",s),this.mindMap.view.translateY(s),o++),t>=this.mindMap.elRect.bottom-a&&(n("bottom",s),this.mindMap.view.translateY(-s),o++),o>0&&this.startAutoMove(e,t,r,n)}startAutoMove(e,t,r,n){this.autoMoveTimer=setTimeout(()=>{this.onMove(e,t,r,n)},20)}clearAutoMoveTimer(){clearTimeout(this.autoMoveTimer)}},K0=Ou});var Q2={};tt(Q2,{default:()=>nE});var Z0,nE,J2=T(()=>{pe();Ar();$e();Bu();Z0=class extends Mt{constructor({mindMap:e}){super(e.renderer),this.mindMap=e,this.autoMove=new K0(e),this.reset(),this.bindEvent()}reset(){this.isDragging=!1,this.mousedownNode=null,this.beingDragNodeList=[],this.nodeList=[],this.overlapNode=null,this.prevNode=null,this.nextNode=null,this.drawTransform=null,this.clone=null,this.placeholder=null,this.placeholderWidth=50,this.placeholderHeight=10,this.placeHolderLine=null,this.placeHolderExtraLines=[],this.offsetX=0,this.offsetY=0,this.isMousedown=!1,this.mouseDownX=0,this.mouseDownY=0,this.mouseMoveX=0,this.mouseMoveY=0,this.checkDragOffset=10,this.minOffset=10}bindEvent(){this.onNodeMousedown=this.onNodeMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.checkOverlapNode=Si(this.checkOverlapNode,300,this),this.mindMap.on("node_mousedown",this.onNodeMousedown),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("node_mouseup",this.onMouseup),this.mindMap.on("mouseup",this.onMouseup)}unBindEvent(){this.mindMap.off("node_mousedown",this.onNodeMousedown),this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("node_mouseup",this.onMouseup),this.mindMap.off("mouseup",this.onMouseup)}onNodeMousedown(e,t){if(this.mindMap.opt.readonly||t.which!==1||e.isGeneralization||e.isRoot)return;this.isMousedown=!0,this.mousedownNode=e;let{x:r,y:n}=this.mindMap.toPos(t.clientX,t.clientY);this.mouseDownX=r,this.mouseDownY=n}onMousemove(e){if(this.mindMap.opt.readonly||!this.isMousedown)return;e.preventDefault();let{x:t,y:r}=this.mindMap.toPos(e.clientX,e.clientY);this.mouseMoveX=t,this.mouseMoveY=r,!(!this.isDragging&&Math.abs(t-this.mouseDownX)<=this.checkDragOffset&&Math.abs(r-this.mouseDownY)<=this.checkDragOffset)&&(this.mindMap.emit("node_dragging",this.mousedownNode),this.handleStartMove(),this.onMove(t,r,e))}async onMouseup(e){if(!this.isMousedown)return;let{autoMoveWhenMouseInEdgeOnDrag:t,enableFreeDrag:r,beforeDragEnd:n}=this.mindMap.opt;t&&this.mindMap.select&&this.autoMove.clearAutoMoveTimer(),this.isMousedown=!1,this.beingDragNodeList.forEach(l=>{l.setOpacity(1),l.showChildren(),l.endDrag()}),this.removeCloneNode();let s=this.overlapNode?this.overlapNode.getData("uid"):"",a=this.prevNode?this.prevNode.getData("uid"):"",o=this.nextNode?this.nextNode.getData("uid"):"";if(this.isDragging&&typeof n=="function"&&await n({overlapNodeUid:s,prevNodeUid:a,nextNodeUid:o,beingDragNodeList:[...this.beingDragNodeList]})){this.reset();return}if(this.overlapNode)this.removeNodeActive(this.overlapNode),this.mindMap.execCommand("MOVE_NODE_TO",this.beingDragNodeList,this.overlapNode);else if(this.prevNode)this.removeNodeActive(this.prevNode),this.mindMap.execCommand("INSERT_AFTER",this.beingDragNodeList,this.prevNode);else if(this.nextNode)this.removeNodeActive(this.nextNode),this.mindMap.execCommand("INSERT_BEFORE",this.beingDragNodeList,this.nextNode);else if(this.clone&&r&&this.beingDragNodeList.length===1){let{x:l,y:h}=this.mindMap.toPos(e.clientX-this.offsetX,e.clientY-this.offsetY),{scaleX:d,scaleY:c,translateX:f,translateY:m}=this.drawTransform;l=(l-f)/d,h=(h-m)/c,this.mousedownNode.left=l,this.mousedownNode.top=h,this.mousedownNode.customLeft=l,this.mousedownNode.customTop=h,this.mindMap.execCommand("SET_NODE_CUSTOM_POSITION",this.mousedownNode,l,h),this.mindMap.render()}this.isDragging&&this.mindMap.emit("node_dragend",{overlapNodeUid:s,prevNodeUid:a,nextNodeUid:o}),this.reset()}removeNodeActive(e){e.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",e,!1)}onMove(e,t,r){if(!this.isMousedown||!this.isDragging)return;let{scaleX:n,scaleY:s,translateX:a,translateY:o}=this.drawTransform,l=e-this.offsetX,h=t-this.offsetY;e=(l-a)/n,t=(h-o)/s;let d=this.clone.transform();this.clone.translate(e-d.translateX,t-d.translateY),this.checkOverlapNode(),this.drawTransform=this.mindMap.draw.transform(),this.autoMove.clearAutoMoveTimer(),this.autoMove.onMove(r.clientX,r.clientY)}async handleStartMove(){if(!this.isDragging){let e=this.mousedownNode;this.drawTransform=this.mindMap.draw.transform();let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.drawTransform;this.offsetX=this.mouseDownX-(e.left*t+n),this.offsetY=this.mouseDownY-(e.top*r+s),e.getData("isActive")?this.beingDragNodeList=Fo(ds(this.mindMap.renderer.activeNodeList.filter(o=>!o.isRoot&&!o.isGeneralization))):this.beingDragNodeList=[e];let{beforeDragStart:a}=this.mindMap.opt;if(typeof a=="function"&&await a([...this.beingDragNodeList]))return;this.nodeTreeToList(),this.createCloneNode(),this.mindMap.execCommand("CLEAR_ACTIVE_NODE"),this.isDragging=!0}}nodeTreeToList(){let e=[];Xt(this.mindMap.renderer.root,t=>{this.checkIsInBeingDragNodeList(t)||(e[t.layerIndex]||(e[t.layerIndex]=[]),e[t.layerIndex].push(t))}),this.nodeList=e.reduceRight((t,r)=>[...t,...r],[])}createCloneNode(){if(!this.clone){let{dragMultiNodeRectConfig:e,dragPlaceholderRectFill:t,dragPlaceholderLineConfig:r,dragOpacityConfig:n,handleDragCloneNode:s}=this.mindMap.opt,{width:a,height:o,fill:l}=e,h=this.beingDragNodeList[0],d=h.style.merge("lineColor",!0);if(this.beingDragNodeList.length>1)this.clone=this.mindMap.otherDraw.rect().size(a,o).radius(o/2).fill({color:l||d}),this.offsetX=a/2,this.offsetY=o/2;else{this.clone=h.group.clone();let c=this.clone.findOne(".smm-expand-btn");c&&c.remove(),this.mindMap.otherDraw.add(this.clone),typeof s=="function"&&s(this.clone)}this.clone.opacity(n.cloneNodeOpacity),this.clone.css("z-index",99999),this.placeholder=this.mindMap.otherDraw.rect().fill({color:t||d}).radius(5),this.placeHolderLine=this.mindMap.otherDraw.path().stroke({color:r.color||d,width:r.width}).fill({color:"none"}),this.beingDragNodeList.forEach(c=>{c.setOpacity(n.beingDragNodeOpacity),c.hideChildren(),c.startDrag()})}}removeCloneNode(){this.clone&&(this.clone.remove(),this.placeholder.remove(),this.placeHolderLine.remove(),this.removeExtraLines())}removeExtraLines(){this.placeHolderExtraLines.forEach(e=>{e.remove()}),this.placeHolderExtraLines=[]}checkOverlapNode(){if(!this.drawTransform||!this.placeholder)return;let{LOGICAL_STRUCTURE:e,LOGICAL_STRUCTURE_LEFT:t,MIND_MAP:r,ORGANIZATION_STRUCTURE:n,CATALOG_ORGANIZATION:s,TIMELINE:a,TIMELINE2:o,VERTICAL_TIMELINE:l,VERTICAL_TIMELINE2:h,VERTICAL_TIMELINE3:d,FISHBONE:c,FISHBONE2:f,RIGHT_FISHBONE:m,RIGHT_FISHBONE2:g}=k.LAYOUT;this.overlapNode=null,this.prevNode=null,this.nextNode=null,this.placeholder.size(0,0),this.placeHolderLine.hide(),this.removeExtraLines(),this.nodeList.forEach(x=>{if(x.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",x,!1),!(this.overlapNode||this.prevNode&&this.nextNode))switch(this.mindMap.opt.layout){case e:case t:this.handleLogicalStructure(x);break;case r:this.handleMindMap(x);break;case n:this.handleOrganizationStructure(x);break;case s:this.handleCatalogOrganization(x);break;case a:this.handleTimeLine(x);break;case o:this.handleTimeLine2(x);break;case l:case h:case d:this.handleLogicalStructure(x);break;case c:case f:case m:case g:this.handleFishbone(x);break;default:this.handleLogicalStructure(x)}}),this.overlapNode&&this.handleOverlapNode()}handleOverlapNode(){let{LOGICAL_STRUCTURE:e,LOGICAL_STRUCTURE_LEFT:t,MIND_MAP:r,ORGANIZATION_STRUCTURE:n,CATALOG_ORGANIZATION:s,TIMELINE:a,TIMELINE2:o,VERTICAL_TIMELINE:l,VERTICAL_TIMELINE2:h,VERTICAL_TIMELINE3:d,FISHBONE:c,FISHBONE2:f,RIGHT_FISHBONE:m,RIGHT_FISHBONE2:g}=k.LAYOUT,{LEFT:x,TOP:y,RIGHT:b,BOTTOM:S}=k.LAYOUT_GROW_DIR,A=this.overlapNode.layerIndex,C=this.overlapNode.children,I=this.mindMap.renderer.layout.getMarginX(A+1),O=this.mindMap.renderer.layout.getMarginY(A+1),q=this.placeholderWidth/2,P=this.placeholderHeight/2,W="",ne="",re="",oe=!1,ke=!1;if(C.length>0){let Q=C[C.length-1],Y=this.getNodeRect(Q);switch(W=this.getNewChildNodeDir(Q),this.mindMap.opt.layout){case e:case r:ne=W===x?Y.originRight-this.placeholderWidth:Y.originLeft,re=Y.originBottom+this.minOffset-P;break;case t:ne=Y.originRight-this.placeholderWidth,re=Y.originBottom+this.minOffset-P;break;case n:oe=!0,ne=Y.originRight+this.minOffset-P,re=Y.originTop;break;case s:A===0?(oe=!0,ne=Y.originRight+this.minOffset-P,re=Y.originTop):(ne=Y.originLeft,re=Y.originBottom+this.minOffset-P);break;case a:A===0?(oe=!0,ne=Y.originRight+this.minOffset-P,re=Y.originTop+Y.originHeight/2-q):(ne=Y.originLeft,re=Y.originBottom+this.minOffset-P);break;case o:A===0?(oe=!0,ne=Y.originRight+this.minOffset-P,re=Y.originTop+Y.originHeight/2-q):(ne=Y.originLeft,A===1?re=W===y?Y.originTop-this.placeholderHeight-this.minOffset+P:Y.originBottom+this.minOffset-P:re=Y.originBottom+this.minOffset-P);break;case l:case h:case d:A===0?(ne=Y.originLeft+Y.originWidth/2-q,re=Y.originBottom+this.minOffset-P):(ne=W===b?Y.originLeft:Y.originRight-this.placeholderWidth,re=Y.originBottom+this.minOffset-P);break;case c:case f:case m:case g:A<=1?(ke=!0,this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!0)):(ne=Y.originLeft,re=W===y?Y.originBottom+this.minOffset-P:Y.originTop-this.placeholderHeight-this.minOffset+P);break;default:}}else{let Q=this.getNodeRect(this.overlapNode);switch(W=this.getNewChildNodeDir(this.overlapNode),this.mindMap.opt.layout){case e:case r:ne=W===b?Q.originRight+I:Q.originLeft-this.placeholderWidth-I,re=Q.originTop+(Q.originHeight-this.placeholderHeight)/2;break;case t:ne=Q.originLeft-this.placeholderWidth-I,re=Q.originTop+(Q.originHeight-this.placeholderHeight)/2;break;case n:oe=!0,ne=Q.originLeft+(Q.originWidth-this.placeholderHeight)/2,re=Q.originBottom+I;break;case s:A===0&&(oe=!0),ne=Q.originLeft+Q.originWidth*.5,re=Q.originBottom+I;break;case a:A===0&&(oe=!0),ne=Q.originLeft+Q.originWidth*.5,re=Q.originBottom+O;break;case o:A===0&&(oe=!0),ne=Q.originLeft+Q.originWidth*.5,A===1?re=W===y?Q.originTop-this.placeholderHeight-I:Q.originBottom+I:re=Q.originBottom+I;break;case l:case h:case d:A===0&&(oe=!0),ne=W===b?Q.originRight+I:Q.originLeft-this.placeholderWidth-I,re=Q.originTop+Q.originHeight/2-P;break;case c:case f:case m:case g:A<=1?(ke=!0,this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!0)):(ne=Q.originLeft+Q.originWidth*.5,re=W===S?Q.originTop-this.placeholderHeight-this.minOffset+P:Q.originBottom+this.minOffset-P);break;default:}}ke||this.setPlaceholderRect({x:ne,y:re,dir:W,rotate:oe})}getNewChildNodeDir(e){let{LOGICAL_STRUCTURE:t,LOGICAL_STRUCTURE_LEFT:r,MIND_MAP:n,TIMELINE2:s,VERTICAL_TIMELINE:a,VERTICAL_TIMELINE2:o,VERTICAL_TIMELINE3:l,FISHBONE:h,FISHBONE2:d,RIGHT_FISHBONE:c,RIGHT_FISHBONE2:f}=k.LAYOUT;switch(this.mindMap.opt.layout){case t:return k.LAYOUT_GROW_DIR.RIGHT;case r:return k.LAYOUT_GROW_DIR.LEFT;case n:case s:case a:case o:case l:case h:case d:case c:case f:return e.dir;default:return""}}handleVerticalCheck(e,t,r=!1){let{layout:n}=this.mindMap.opt,{LAYOUT:s,LAYOUT_GROW_DIR:a}=k,{VERTICAL_TIMELINE:o,VERTICAL_TIMELINE2:l,VERTICAL_TIMELINE3:h,FISHBONE:d,FISHBONE2:c,RIGHT_FISHBONE:f,RIGHT_FISHBONE2:m}=s,{LEFT:g}=a,x=this.mouseMoveX,y=this.mouseMoveY,b=this.getNodeRect(e),S=this.getNewChildNodeDir(e),A=e.layerIndex;r&&(t=t.reverse());let C=b.originHeight/4,{prevBrotherOffset:I,nextBrotherOffset:O}=this.getNodeDistanceToSiblingNode(t,e,b,"v");if(b.left<=x&&b.right>=x){if(!this.overlapNode&&!this.prevNode&&!this.nextNode&&!e.isRoot){let q=O>0?y>b.bottom&&y<=b.bottom+O:y>=b.bottom-C&&y<=b.bottom,P=I>0?y=b.top-I:y>=b.top&&y<=b.top+C,{scaleY:W}=this.drawTransform,ne=S===g?b.originRight-this.placeholderWidth:b.originLeft,re=!1;switch(n){case o:case l:case h:A===1&&(ne=b.originLeft+b.originWidth/2-this.placeholderWidth/2);break;case f:case m:ne=b.originLeft+b.originWidth-this.placeholderWidth;break;default:}if(q){r?this.nextNode=e:this.prevNode=e;let oe=b.originBottom+O/W-this.placeholderHeight/2;switch(n){case d:case c:case f:case m:A===2&&(re=!0,oe=b.originBottom+this.minOffset-this.placeholderHeight/2);break;default:}this.setPlaceholderRect({x:ne,y:oe,dir:S,notRenderLine:re})}else if(P){r?this.prevNode=e:this.nextNode=e;let oe=b.originTop-this.placeholderHeight-I/W+this.placeholderHeight/2;switch(n){case d:case c:case f:case m:A===2&&(re=!0,oe=b.originTop-this.placeholderHeight-this.minOffset+this.placeholderHeight/2);break;default:}this.setPlaceholderRect({x:ne,y:oe,dir:S,notRenderLine:re})}}this.checkIsOverlap({node:e,dir:"v",prevBrotherOffset:I,nextBrotherOffset:O,size:C,pos:y,nodeRect:b})}}handleHorizontalCheck(e,t){let{layout:r}=this.mindMap.opt,{LAYOUT:n}=k,{FISHBONE:s,FISHBONE2:a,RIGHT_FISHBONE:o,RIGHT_FISHBONE2:l,TIMELINE:h,TIMELINE2:d}=n,c=this.mouseMoveX,f=this.mouseMoveY,m=this.getNodeRect(e),g=m.originWidth/4,{prevBrotherOffset:x,nextBrotherOffset:y}=this.getNodeDistanceToSiblingNode(t,e,m,"h");if(m.top<=f&&m.bottom>=f){if(!this.overlapNode&&!this.prevNode&&!this.nextNode&&!e.isRoot){let b=y>0?c=m.right:c<=m.right&&c>=m.right-g,S=x>0?c>m.left-x&&c<=m.left:c<=m.left+g&&c>=m.left,{scaleX:A}=this.drawTransform,C=e.layerIndex,I=m.originTop,O=!1;switch(r){case h:case d:I=m.originTop+m.originHeight/2-this.placeholderWidth/2;break;case s:case a:case o:case l:C===1&&(O=!0,I=m.originTop+m.originHeight/2-this.placeholderWidth/2);break;default:}b?([o,l].includes(r)?this.nextNode=e:this.prevNode=e,this.setPlaceholderRect({x:m.originRight+y/A-this.placeholderHeight/2,y:I,rotate:!0,notRenderLine:O})):S&&([o,l].includes(r)?this.prevNode=e:this.nextNode=e,this.setPlaceholderRect({x:m.originLeft-this.placeholderHeight-x/A+this.placeholderHeight/2,y:I,rotate:!0,notRenderLine:O}))}this.checkIsOverlap({node:e,dir:"h",prevBrotherOffset:x,nextBrotherOffset:y,size:g,pos:c,nodeRect:m})}}getNodeDistanceToSiblingNode(e,t,r,n){let{TOP:s,LEFT:a,BOTTOM:o,RIGHT:l}=k.LAYOUT_GROW_DIR,{scaleX:h,scaleY:d}=this.drawTransform,c=n==="v"?s:a,f=n==="v"?o:l,m=n==="v"?d:h,g=this.minOffset*m,x=Ie(t,e),y=null,b=null;x!==-1&&(x-1>=0&&(y=e[x-1]),x+1<=e.length-1&&(b=e[x+1]));let S=0;if(y){let C=this.getNodeRect(y);S=r[c]-C[f],S=S>=g?S/2:0}else S=g;let A=0;return b?(A=this.getNodeRect(b)[c]-r[f],A=A>=g?A/2:0):A=g,{prevBrother:y,prevBrotherOffset:S,nextBrother:b,nextBrotherOffset:A}}setPlaceholderRect({x:e,y:t,dir:r,rotate:n,notRenderLine:s}){let a=this.placeholderWidth,o=this.placeholderHeight;if(n){let f=a;a=o,o=f}if(this.placeholder.size(a,o).move(e,t),s)return;let{dragPlaceholderLineConfig:l}=this.mindMap.opt,h=null,d=null;this.overlapNode?(h=this.overlapNode,d=this.overlapNode):(h=this.prevNode||this.nextNode,d=h.parent),d=d.fakeClone(),h=h.fakeClone();let c=this.beingDragNodeList[0].fakeClone();c.dir=r,c.left=e,c.top=t,c.width=a,c.height=o,d.children=[c],d._lines=[],this.placeHolderLine.show(),this.mindMap.renderer.layout.renderLine(d,[this.placeHolderLine],(...f)=>{},h.style.getStyle("lineStyle",!0)),this.placeHolderExtraLines=[...d._lines],this.placeHolderExtraLines.forEach(f=>{this.mindMap.otherDraw.add(f),f.stroke({color:l.color,width:l.width}).fill({color:"none"})})}checkIsOverlap({node:e,dir:t,prevBrotherOffset:r,nextBrotherOffset:n,size:s,pos:a,nodeRect:o}){let{TOP:l,LEFT:h,BOTTOM:d,RIGHT:c}=k.LAYOUT_GROW_DIR,f=t==="v"?l:h,m=t==="v"?d:c;!this.overlapNode&&!this.prevNode&&!this.nextNode&&o[f]+(r>0?0:s)<=a&&o[m]-(n>0?0:s)>=a&&(this.overlapNode=e)}handleLogicalStructure(e){let t=this.commonGetNodeCheckList(e);this.handleVerticalCheck(e,t)}handleMindMap(e){let t=e.parent?e.parent.children.filter(r=>{let n=!0;return e.layerIndex===1&&(n=r.dir===e.dir),n&&!this.checkIsInBeingDragNodeList(r)}):[];this.handleVerticalCheck(e,t)}handleOrganizationStructure(e){let t=this.commonGetNodeCheckList(e);this.handleHorizontalCheck(e,t)}handleCatalogOrganization(e){let t=this.commonGetNodeCheckList(e);e.layerIndex===1?this.handleHorizontalCheck(e,t):this.handleVerticalCheck(e,t)}handleTimeLine(e){let t=this.commonGetNodeCheckList(e);e.layerIndex===1?this.handleHorizontalCheck(e,t):this.handleVerticalCheck(e,t)}handleTimeLine2(e){let t=this.commonGetNodeCheckList(e);e.layerIndex===1?this.handleHorizontalCheck(e,t):e.dir===k.LAYOUT_GROW_DIR.TOP&&e.layerIndex===2?this.handleVerticalCheck(e,t,!0):this.handleVerticalCheck(e,t)}handleFishbone(e){let t=e.parent?e.parent.children.filter(r=>r.layerIndex>1&&!this.checkIsInBeingDragNodeList(r)):[];if(e.layerIndex===1)this.handleHorizontalCheck(e,t);else{let r=e.dir===k.LAYOUT_GROW_DIR.TOP&&e.layerIndex===2,n=e.dir===k.LAYOUT_GROW_DIR.BOTTOM&&e.layerIndex>=3;r||n?this.handleVerticalCheck(e,t,!0):this.handleVerticalCheck(e,t)}}commonGetNodeCheckList(e){return e.parent?[...e.parent.children].filter(t=>!this.checkIsInBeingDragNodeList(t)):[]}getNodeRect(e){let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.drawTransform,{left:a,top:o,width:l,height:h}=e,d=l,c=h,f=a,m=o,g=o+h,x=a+l,y=(a+l)*t+n,b=(o+h)*r+s;return a=a*t+n,o=o*r+s,{left:a,top:o,right:y,bottom:b,originWidth:d,originHeight:c,originLeft:f,originTop:m,originBottom:g,originRight:x}}checkIsInBeingDragNodeList(e){return!!this.beingDragNodeList.find(t=>t.uid===e.uid||t.isAncestor(e))}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};Z0.instanceName="drag";nE=Z0});var e6={};tt(e6,{default:()=>sE});var Q0,sE,t6=T(()=>{pe();$e();Q0=class{constructor(e){this.opt=e,this.mindMap=e.mindMap,this.addShortcut()}addShortcut(){this.onLeftKeyUp=this.onLeftKeyUp.bind(this),this.onUpKeyUp=this.onUpKeyUp.bind(this),this.onRightKeyUp=this.onRightKeyUp.bind(this),this.onDownKeyUp=this.onDownKeyUp.bind(this),this.mindMap.keyCommand.addShortcut(k.KEY_DIR.LEFT,this.onLeftKeyUp),this.mindMap.keyCommand.addShortcut(k.KEY_DIR.UP,this.onUpKeyUp),this.mindMap.keyCommand.addShortcut(k.KEY_DIR.RIGHT,this.onRightKeyUp),this.mindMap.keyCommand.addShortcut(k.KEY_DIR.DOWN,this.onDownKeyUp)}removeShortcut(){this.mindMap.keyCommand.removeShortcut(k.KEY_DIR.LEFT,this.onLeftKeyUp),this.mindMap.keyCommand.removeShortcut(k.KEY_DIR.UP,this.onUpKeyUp),this.mindMap.keyCommand.removeShortcut(k.KEY_DIR.RIGHT,this.onRightKeyUp),this.mindMap.keyCommand.removeShortcut(k.KEY_DIR.DOWN,this.onDownKeyUp)}onLeftKeyUp(){this.onKeyup(k.KEY_DIR.LEFT)}onUpKeyUp(){this.onKeyup(k.KEY_DIR.UP)}onRightKeyUp(){this.onKeyup(k.KEY_DIR.RIGHT)}onDownKeyUp(){this.onKeyup(k.KEY_DIR.DOWN)}onKeyup(e){if(this.mindMap.renderer.activeNodeList.length>0)this.focus(e);else{let t=this.mindMap.renderer.root;this.mindMap.execCommand("GO_TARGET_NODE",t)}}focus(e){let t=this.mindMap.renderer.activeNodeList[0],r=this.getNodeRect(t),n=null,s=1/0,a=(o,l)=>{let h=this.getDistance(r,o);h{if(s.uid===e.uid)return;let a=this.getNodeRect(s),{left:o,top:l,right:h,bottom:d}=a,c=!1;r===k.KEY_DIR.LEFT?c=h<=t.left:r===k.KEY_DIR.RIGHT?c=o>=t.right:r===k.KEY_DIR.UP?c=d<=t.top:r===k.KEY_DIR.DOWN&&(c=l>=t.bottom),c&&n(a,s)})}getFocusNodeByShadowAlgorithm({currentActiveNode:e,currentActiveNodeRect:t,dir:r,checkNodeDis:n}){Xt(this.mindMap.renderer.root,s=>{if(s.uid===e.uid)return;let a=this.getNodeRect(s),{left:o,top:l,right:h,bottom:d}=a,c=!1;r===k.KEY_DIR.LEFT?c=ot.top:r===k.KEY_DIR.RIGHT?c=h>t.right&&lt.top:r===k.KEY_DIR.UP?c=lt.left:r===k.KEY_DIR.DOWN&&(c=d>t.bottom&&ot.left),c&&n(a,s)})}getFocusNodeByAreaAlgorithm({currentActiveNode:e,currentActiveNodeRect:t,dir:r,checkNodeDis:n}){let s=(t.right+t.left)/2,a=(t.bottom+t.top)/2;Xt(this.mindMap.renderer.root,o=>{if(o.uid===e.uid)return;let l=this.getNodeRect(o),{left:h,top:d,right:c,bottom:f}=l,m=(c+h)/2,g=(f+d)/2,x=m-s,y=g-a;if(x===0&&y===0)return;let b=!1;r===k.KEY_DIR.LEFT?b=x<=0&&x<=y&&x<=-y:r===k.KEY_DIR.RIGHT?b=x>0&&x>=-y&&x>=y:r===k.KEY_DIR.UP?b=y<=0&&y0&&-yx),b&&n(l,o)})}getNodeRect(e){let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.mindMap.draw.transform(),{left:a,top:o,width:l,height:h}=e;return{right:(a+l)*t+n,bottom:(o+h)*r+s,left:a*t+n,top:o*r+s}}getDistance(e,t){let r=this.getCenter(e),n=this.getCenter(t);return Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2))}getCenter({left:e,right:t,top:r,bottom:n}){return{x:(e+t)/2,y:(r+n)/2}}beforePluginRemove(){this.removeShortcut()}beforePluginDestroy(){this.removeShortcut()}};Q0.instanceName="keyboardNavigation";sE=Q0});var Fu,J0,Pu,i6,aE,oE,lE,eh,hE,r6,n6=T(()=>{Fu=i=>String(i).split(/\s+/).map(t=>{if(/^[\d.]+/.test(t)){let r=/^([\d.]+)(.*)$/.exec(t);return[Number(r[1]),r[2]]}else return t}),J0=(i,e)=>i*e,Pu=(i,e)=>e/i,i6={left:0,top:0,center:50,bottom:100,right:100},aE=({backgroundSize:i,drawOpt:e,imageRatio:t,canvasWidth:r,canvasHeight:n,canvasRatio:s})=>{if(i){let a=Fu(i);if(a[0]==="auto"&&a[1]==="auto")return;if(a[0]==="cover"){t>s?(e.height=n,e.width=J0(t,n)):(e.width=r,e.height=Pu(t,r));return}if(a[0]==="contain"){t>s?(e.width=r,e.height=Pu(t,r)):(e.height=n,e.width=J0(t,n));return}let o=-1;a[0]&&(Array.isArray(a[0])?a[0][1]==="%"?(e.width=a[0][0]/100*r,o=e.width):(e.width=a[0][0],o=a[0][0]):a[0]==="auto"&&a[1]&&(a[1][1]==="%"?e.width=J0(t,a[1][0]/100*n):e.width=J0(t,a[1][0]))),a[1]&&Array.isArray(a[1])?a[1][1]==="%"?e.height=a[1][0]/100*n:e.height=a[1][0]:o!==-1&&(e.height=Pu(t,o))}},oE=({backgroundPosition:i,drawOpt:e,imgWidth:t,imgHeight:r,canvasWidth:n,canvasHeight:s})=>{if(i){let a=Fu(i);if(a=a.map(o=>typeof o=="string"&&i6[o]!==void 0?[i6[o],"%"]:o),Array.isArray(a[0])){if(a.length===1&&a.push([50,"%"]),a[0][1]==="%"){let o=a[0][0]/100*n,l=a[0][0]/100*t;e.x=o-l}else e.x=a[0][0];if(a[1][1]==="%"){let o=a[1][0]/100*s,l=a[1][0]/100*r;e.y=o-l}else e.y=a[1][0]}}},lE=({ctx:i,image:e,backgroundRepeat:t,drawOpt:r,imgWidth:n,imgHeight:s,canvasWidth:a,canvasHeight:o})=>{if(t){let l=r.x,h=r.y,d=Math.ceil(l/n),c=Math.ceil(h/s),f=l-d*n,m=h-c*s,g=Fu(t);if(g[0]==="no-repeat"||n>=a&&s>=o)return;if(g[0]==="repeat-x"&&a>n){let x=f;for(;xs){let x=m;for(;xs){let y=m;for(;y{i.drawImage(e,t.sx,t.sy,t.swidth,t.sheight,t.x,t.y,t.width,t.height)},hE=(i,e,t,r,{backgroundSize:n,backgroundPosition:s,backgroundRepeat:a},o=()=>{})=>{let l=e/t,h=new Image;h.src=r,h.onload=()=>{let d=h.width,c=h.height,f=d/c,m={sx:0,sy:0,swidth:d,sheight:c,x:0,y:0,width:d,height:c};aE({backgroundSize:n,drawOpt:m,imageRatio:f,canvasWidth:e,canvasHeight:t,canvasRatio:l}),oE({backgroundPosition:s,drawOpt:m,imgWidth:m.width,imgHeight:m.height,imageRatio:f,canvasWidth:e,canvasHeight:t,canvasRatio:l}),lE({ctx:i,image:h,backgroundRepeat:a,drawOpt:m,imgWidth:m.width,imgHeight:m.height,imageRatio:f,canvasWidth:e,canvasHeight:t,canvasRatio:l})||eh(i,h,m),o()},h.onerror=d=>{o(d)}},r6=hE});var qu,dE,cE,s6,a6=T(()=>{pe();qu=i=>i.richText?j0(i.text):i.text,dE=i=>new Array(i).fill("#").join(""),cE=i=>new Array(i-6).fill(" ").join("")+"*",s6=i=>{let e="";return de(i,null,(t,r,n,s)=>{let a=s+1;a<=6?e+=dE(a):e+=cE(a),e+=" "+qu(t.data);let o=t.data.generalization;if(Array.isArray(o))e+=o.map(l=>` [${qu(l)}]`);else if(o&&o.text){let l=qu(o);e+=` [${l}]`}e+=` `,t.data.note&&(e+=t.data.note+` -`)},()=>{},!0),e}});var qc,ZM,k3,C3=M(()=>{he();qc=i=>i.richText?t0(i.text):i.text,ZM=i=>new Array(i).fill(" ").join(""),k3=i=>{let e="";return se(i,null,(t,r,n,s)=>{e+=ZM(s),e+=" "+qc(t.data);let a=t.data.generalization;Array.isArray(a)?e+=a.map(o=>` [${qc(o)}]`):a&&a.text&&(e+=` [${qc(a)}]`),e+=` +`)},()=>{},!0),e}});var Hu,uE,o6,l6=T(()=>{pe();Hu=i=>i.richText?j0(i.text):i.text,uE=i=>new Array(i).fill(" ").join(""),o6=i=>{let e="";return de(i,null,(t,r,n,s)=>{e+=uE(s),e+=" "+Hu(t.data);let a=t.data.generalization;Array.isArray(a)?e+=a.map(o=>` [${Hu(o)}]`):a&&a.text&&(e+=` [${Hu(a)}]`),e+=` -`},()=>{},!0),e}});var _3={};ti(_3,{default:()=>QM});var u0,QM,L3=M(()=>{he();ht();E3();A3();Oe();C3();u0=class{constructor(e){this.mindMap=e.mindMap}async export(e,t=!0,r="\u601D\u7EF4\u5BFC\u56FE",...n){if(this[e]){let s=await this[e](r,...n);return t&&Dp(s,r+"."+e),s}else return null}createTransformImgTaskList(e,t,r,n){return e.find(t).map(async a=>{let o=n(a);if(/^data:/.test(o)||o==="none")return;let l=await uc(o);a.attr(r,l)})}async getSvgData(e){let{exportPaddingX:t,exportPaddingY:r,errorHandler:n,resetCss:s,addContentToHeader:a,addContentToFooter:o,handleBeingExportSvg:l}=this.mindMap.opt,{svg:h,svgHTML:d,clipData:c}=this.mindMap.getSvgData({paddingX:t,paddingY:r,addContentToHeader:a,addContentToFooter:o,node:e});c&&(c.paddingX=t,c.paddingY=r);let f=!1,m=this.createTransformImgTaskList(h,"image","href",v=>v.attr("href")||v.attr("xlink:href")),g=this.createTransformImgTaskList(h,"img","src",v=>v.attr("src")),x=[...m,...g];try{await Promise.all(x)}catch(v){n(di.EXPORT_LOAD_IMAGE_ERROR,v)}if(this.mindMap.richText){let v=h.find("foreignObject");if(v.length>0&&(v[0].add(Me(``)),f=!0),this.mindMap.formula&&h.find(".ql-formula").length>0){let E=this.mindMap.formula.getStyleText();if(E){let S=document.createElement("style");S.innerHTML=E,$i(S),v[0].add(S),f=!0}}}return typeof l=="function"&&(f=!0,h=l(h)),(x.length>0||f)&&(d=h.svg()),{node:h,str:d,clipData:c}}svgToPng(e,t,r=null,n=!1,s="image/png"){let{maxCanvasSize:a,minExportImgCanvasScale:o}=this.mindMap.opt;return new Promise((l,h)=>{let d=new Image;d.setAttribute("crossOrigin","anonymous"),d.onload=async()=>{try{let c=document.createElement("canvas"),f=Math.max(window.devicePixelRatio,o),m=d.width,g=d.height,x=0,v=0;r&&(x=r.paddingX,v=r.paddingY,m=r.width+x*2,g=r.height+v*2);let b=0,E=0,{backgroundImage:S}=this.mindMap.themeConfig;if(n&&S&&!t){let ye=await new Promise(G=>{let W=new Image;W.onload=()=>{G([W.width,W.height])},W.onerror=()=>{G(null)},W.src=S});if(ye){let G=m/g,W=ye[0]/ye[1];G>W?(b=m,E=m/W):(E=g,b=g*W)}}let C=1,_=1,I=(b||m)*f,O=(E||g)*f;if(I>a||O>a){let ye=null,G=null;I>a?ye=a:O>a&&(G=a);let W=Jl(I,O,ye,G);C=W[0]/I,_=W[1]/O,I=W[0],O=W[1]}c.width=I,c.height=O;let D=I/f,$=O/f;c.style.width=D+"px",c.style.height=$+"px";let F=c.getContext("2d");F.scale(f,f),t||await this.drawBackgroundToCanvas(F,D,$);let Z=(b>0?(b-m)/2:0)*C,re=(E>0?(E-g)/2:0)*_;r?F.drawImage(d,r.left,r.top,r.width,r.height,x*C+Z,v*_+re,r.width*C,r.height*_):F.drawImage(d,Z,re,m*C,g*_),l(c.toDataURL(s))}catch(c){h(c)}},d.onerror=c=>{h(c)},d.src=e})}drawBackgroundToCanvas(e,t,r){return new Promise((n,s)=>{let{backgroundColor:a="#fff",backgroundImage:o,backgroundRepeat:l="no-repeat",backgroundPosition:h="center center",backgroundSize:d="cover"}=this.mindMap.themeConfig;e.save(),e.rect(0,0,t,r),e.fillStyle=a,e.fill(),e.restore(),o&&o!=="none"?(e.save(),N3(e,t,r,o,{backgroundRepeat:l,backgroundPosition:h,backgroundSize:d},c=>{c?s(c):n(),e.restore()})):n()})}drawBackgroundToSvg(e){return new Promise(async t=>{let{backgroundColor:r="#fff",backgroundImage:n,backgroundRepeat:s="repeat"}=this.mindMap.themeConfig;if(e.css("background-color",r),n&&n!=="none"){let a=await uc(n);e.css("background-image",`url(${a})`),e.css("background-repeat",s),t()}else t()})}async _image(e,t,r=!1,n=null,s=!1){this.mindMap.renderer.textEdit.hideEditTextBox(),this.handleNodeExport(n);let{str:a,clipData:o}=await this.getSvgData(n),l=await this.fixSvgStrAndToBlob(a);return await this.svgToPng(l,r,o,s,e)}async png(...e){return await this._image("image/png",...e)}async jpg(...e){return await this._image("image/jpg",...e)}handleNodeExport(e){if(e&&e.getData("isActive")){e.deactivate();let{alwaysShowExpandBtn:t,notShowExpandBtn:r}=this.mindMap.opt;!t&&!r&&e.getData("expand")&&e.removeExpandBtn()}}async pdf(e,t=!1,r=!1){if(!this.mindMap.doExportPDF)throw new Error("\u8BF7\u6CE8\u518CExportPDF\u63D2\u4EF6");let n=await this.png(e,t,null,r);return await this.mindMap.doExportPDF.pdf(n)}async xmind(e){if(!this.mindMap.doExportXMind)throw new Error("\u8BF7\u6CE8\u518CExportXMind\u63D2\u4EF6");let t=this.mindMap.getData(),r=await this.mindMap.doExportXMind.xmind(t,e);return await Cs(r)}async svg(e){this.mindMap.renderer.textEdit.hideEditTextBox();let{node:t}=await this.getSvgData();t.first().before(Me(`${e}`)),await this.drawBackgroundToSvg(t);let r=t.svg();return await this.fixSvgStrAndToBlob(r)}async fixSvgStrAndToBlob(e){e=Hp(e),e=Zp(e);let t=new Blob([e],{type:"image/svg+xml"});return await Cs(t)}async json(e,t=!0){let r=this.mindMap.getData(t),n=JSON.stringify(r),s=new Blob([n]);return await Cs(s)}async smm(e,t){return await this.json(e,t)}async md(){let e=this.mindMap.getData(),t=S3(e),r=new Blob([t]);return await Cs(r)}async txt(){let e=this.mindMap.getData(),t=k3(e),r=new Blob([t]);return await Cs(r)}};u0.instanceName="doExport";QM=u0});var z3={};ti(z3,{default:()=>JM});var f0,JM,I3=M(()=>{he();Oc();f0=class{constructor({mindMap:e}){this.mindMap=e,this.rect=null,this.isMousedown=!1,this.mouseDownX=0,this.mouseDownY=0,this.mouseMoveX=0,this.mouseMoveY=0,this.isSelecting=!1,this.cacheActiveList=[],this.autoMove=new o0(e),this.bindEvent()}bindEvent(){this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.checkInNodes=mi(this.checkInNodes,300,this),this.mindMap.on("mousedown",this.onMousedown),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("mouseup",this.onMouseup),this.mindMap.on("node_mouseup",this.onMouseup)}unBindEvent(){this.mindMap.off("mousedown",this.onMousedown),this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("mouseup",this.onMouseup),this.mindMap.off("node_mouseup",this.onMouseup)}onMousedown(e){let{readonly:t,mousedownEventPreventDefault:r}=this.mindMap.opt;if(t)return;let{useLeftKeySelectionRightKeyDrag:n}=this.mindMap.opt;if(!(e.ctrlKey||e.metaKey)&&(n?e.which!==1:e.which!==3))return;r&&e.preventDefault(),this.isMousedown=!0,this.cacheActiveList=[...this.mindMap.renderer.activeNodeList];let{x:s,y:a}=this.mindMap.toPos(e.clientX,e.clientY);this.mouseDownX=s,this.mouseDownY=a,this.createRect(s,a)}onMousemove(e){if(this.mindMap.opt.readonly||!this.isMousedown)return;let{x:t,y:r}=this.mindMap.toPos(e.clientX,e.clientY);this.mouseMoveX=t,this.mouseMoveY=r,!(Math.abs(t-this.mouseDownX)<=10&&Math.abs(r-this.mouseDownY)<=10)&&(this.autoMove.clearAutoMoveTimer(),this.autoMove.onMove(e.clientX,e.clientY,()=>{this.isSelecting=!0,this.rect&&this.rect.plot([[this.mouseDownX,this.mouseDownY],[this.mouseMoveX,this.mouseDownY],[this.mouseMoveX,this.mouseMoveY],[this.mouseDownX,this.mouseMoveY]]),this.checkInNodes()},(n,s)=>{switch(n){case"left":this.mouseDownX+=s;break;case"top":this.mouseDownY+=s;break;case"right":this.mouseDownX-=s;break;case"bottom":this.mouseDownY-=s;break;default:break}}))}onMouseup(){this.mindMap.opt.readonly||this.isMousedown&&(this.checkTriggerNodeActiveEvent(),this.autoMove.clearAutoMoveTimer(),this.isMousedown=!1,this.cacheActiveList=[],this.rect&&this.rect.remove(),this.rect=null,setTimeout(()=>{this.isSelecting=!1},0))}checkTriggerNodeActiveEvent(){let e=this.cacheActiveList.length!==this.mindMap.renderer.activeNodeList.length,t=!1;if(!e)for(let r=0;rs.getData("uid")===n.getData("uid"))){t=!0;break}}(e||t)&&this.mindMap.renderer.emitNodeActiveEvent()}createRect(e,t){this.rect&&this.rect.remove(),this.rect=this.mindMap.svg.polygon().stroke({color:"#0984e3"}).fill({color:"rgba(9,132,227,0.3)"}).plot([[e,t]])}checkInNodes(){let{scaleX:e,scaleY:t,translateX:r,translateY:n}=this.mindMap.draw.transform(),s=Math.min(this.mouseDownX,this.mouseMoveX),a=Math.min(this.mouseDownY,this.mouseMoveY),o=Math.max(this.mouseDownX,this.mouseMoveX),l=Math.max(this.mouseDownY,this.mouseMoveY),h=d=>{let{left:c,top:f,width:m,height:g}=d,x=(c+m)*e+r,v=(f+g)*t+n;if(c=c*e+r,f=f*t+n,Xp(s,o,a,l,c,x,f,v)){if(d.getData("isActive"))return;this.mindMap.renderer.addNodeToActiveList(d),this.mindMap.renderer.emitNodeActiveEvent()}else if(d.getData("isActive")){if(!d.getData("isActive"))return;this.mindMap.renderer.removeNodeFromActiveList(d),this.mindMap.renderer.emitNodeActiveEvent()}};Pt(this.mindMap.renderer.root,d=>{h(d),d._generalizationList&&d._generalizationList.length>0&&d._generalizationList.forEach(c=>{h(c.generalizationNode)})})}hasSelectRange(){return this.isSelecting}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};f0.instanceName="select";JM=f0});var mo,po,m0,R3,D3,eT,dr,Hc,O3,Uc,$c=M(()=>{he();mo=(i,e)=>i.getData("associativeLineTargets").findIndex(t=>t===e.getData("uid")),po=(i,e,t,r)=>{let s=i+(t-i)/2,a=e,o=s,l=r;return Math.abs(i-t)<=5&&(s=i+(r-e)/2,o=s),Math.abs(e-r)<=5&&(s=i,a=e-(t-i)/2,o=t,l=a),[{x:s,y:a},{x:o,y:l}]},m0=(i,e,t,r)=>`M ${i.x},${i.y} C ${t.x},${t.y} ${r.x},${r.y} ${e.x},${e.y}`,R3=i=>{let{left:e,top:t,width:r,height:n}=i;return{right:e+r,bottom:t+n,left:e,top:t,width:r,height:n}},D3=(i,e,t,r)=>{let n=po(i,e,t,r);return m0({x:i,y:e},{x:t,y:r},n[0],n[1])},eT=(i,e)=>{let{left:t,top:r,translateLeft:n,translateTop:s,width:a,height:o}=i,l=e.clientX,h=e.clientY,d=n+a/2,c=s+o/2,f=t+a/2,m=r+o/2,g=Math.atan(o/a),x=l-d,v=c-h,b=Math.atan2(v,x),E=t+a,S=r+o;if(b=-g){let I=b*(a/2);return(b=0||b>=-g&&b<0)&&(S=m-I),{x:E,y:S,dir:"right",range:I}}else if(b>=g&&b=g){let O=o/2/b;I=-O,E=f+O}else if(b>=Math.PI/2-g&&b=g-Math.PI){let I=0;if(b>=g-Math.PI/2&&b<-g){let O=o/2/b;I=O,E=f-O}else if(b=g-Math.PI){let O=(d-l)/(c-h),D=o/2*O;I=-D,E=f+D}return{x:E,y:S,dir:"bottom",range:I}}E=t;let _=(c-h)/(d-l)*(a/2);return(b>=-Math.PI&&b=Math.PI-g)&&(S=m-_),{x:E,y:S,dir:"left",range:_}},dr=(i,e="right",t=0,r=null)=>{let{left:n,top:s,width:a,height:o}=i;if(r)return eT(i,r);switch(e){case"left":return{x:n,y:s+o/2-t,dir:e};case"right":return{x:n+a,y:s+o/2-t,dir:e};case"top":return{x:n+a/2-t,y:s,dir:e};case"bottom":return{x:n+a/2-t,y:s+o,dir:e};default:break}},Hc=(i,e)=>{let t=R3(i),r=R3(e),n="",s="";switch(e3({x:t.left,y:t.top,width:t.width,height:t.height},{x:r.left,y:r.top,width:r.width,height:r.height})){case"left-top":n="right",s="top";break;case"right-top":n="left",s="top";break;case"right-bottom":n="left",s="bottom";break;case"left-bottom":n="right",s="bottom";break;case"left":n="right",s="left";break;case"right":n="left",s="right";break;case"top":n="right",s="right";break;case"bottom":n="left",s="left";break;case"overlap":n="right",s="right";break;default:break}return[dr(i,n),dr(e,s)]},O3=(i,e,t,r)=>{let n=mo(t,r),s=[],a=t.getData("associativeLineTargetControlOffsets");if(a&&a[n]){let o=a[n];s=[{x:i.x+o[0].x,y:i.y+o[0].y},{x:e.x+o[1].x,y:e.y+o[1].y}]}else s=po(i.x,i.y,e.x,e.y);return{path:m0(i,e,s[0],s[1]),controlPoints:s}},Uc=(i,e)=>{let t=po(i.x,i.y,e.x,e.y);return[{x:t[0].x-i.x,y:t[0].y-i.y},{x:t[1].x-e.x,y:t[1].y-e.y}]}});function tT(i,e){let{associativeLineActiveColor:t}=this.getStyleConfig(i,e);this.controlLine1=this.associativeLineDraw.line().stroke({color:t,width:2}),this.controlLine2=this.associativeLineDraw.line().stroke({color:t,width:2}),this.controlPoint1=this.createOneControlNode("controlPoint1",i,e),this.controlPoint2=this.createOneControlNode("controlPoint2",i,e)}function iT(i,e,t){let{associativeLineActiveColor:r}=this.getStyleConfig(e,t);return this.associativeLineDraw.circle(this.controlPointDiameter).stroke({color:r}).fill({color:"#fff"}).click(n=>{n.stopPropagation()}).mousedown(n=>{this.onControlPointMousedown(n,i)})}function rT(i,e){i.stopPropagation(),i.preventDefault(),this.isControlPointMousedown=!0,this.mousedownControlPointKey=e}function nT(i){if(!this.isControlPointMousedown||!this.mousedownControlPointKey||!this[this.mousedownControlPointKey])return;i.stopPropagation(),i.preventDefault();let e=this.controlPointDiameter/2,{x:t,y:r}=this.getTransformedEventPos(i);this.controlPointMousemoveState.pos={x:t,y:r},this[this.mousedownControlPointKey].x(t-e).y(r-e);let[,,,n,s]=this.activeLine,a=mo(n,s),{associativeLinePoint:o,associativeLineTargetControlOffsets:l}=n.getData();o=o||[];let h=this.getNodePos(n),d=this.getNodePos(s),[c,f]=this.updateAllLinesPos(n,s,o[a]);this.controlPointMousemoveState.startPoint=c,this.controlPointMousemoveState.endPoint=f,this.controlPointMousemoveState.targetIndex=a;let m=[];l?m=l[a]:m=Uc(c,f);let g=null,x=null,{x:v,y:b}=this.mindMap.toPos(i.clientX,i.clientY),E={clientX:v,clientY:b};this.mousedownControlPointKey==="controlPoint1"?(c=dr(h,"",0,E),g={x:t,y:r},x={x:f.x+m[1].x,y:f.y+m[1].y},c&&(this.controlPointMousemoveState.startPoint=c,this.controlLine1.plot(c.x,c.y,g.x,g.y))):(f=dr(d,"",0,E),g={x:c.x+m[0].x,y:c.y+m[0].y},x={x:t,y:r},f&&(this.controlPointMousemoveState.endPoint=f,this.controlLine2.plot(f.x,f.y,x.x,x.y))),this.updataAassociativeLine(c,f,g,x,this.activeLine)}function sT(i,e,t,r,n){let[s,a,o]=n,l=m0(i,e,t,r);s.plot(l),a.plot(l),this.updateTextPos(s,o),this.updateTextEditBoxPos(o)}function aT(i){if(!this.isControlPointMousedown)return;i.stopPropagation(),i.preventDefault();let{pos:e,startPoint:t,endPoint:r,targetIndex:n}=this.controlPointMousemoveState,[,,,s]=this.activeLine,a=[],{associativeLinePoint:o,associativeLineTargetControlOffsets:l}=s.getData();o||(o=[]),o[n]=o[n]||{startPoint:t,endPoint:r},l?a=l:a[n]=Uc(t,r);let h=null,d=null;this.mousedownControlPointKey==="controlPoint1"?(h={x:e.x-t.x,y:e.y-t.y},d=a[n][1],o[n].startPoint=t):(h=a[n][0],d={x:e.x-r.x,y:e.y-r.y},o[n].endPoint=r),a[n]=[h,d],this.mindMap.execCommand("SET_NODE_DATA",s,{associativeLineTargetControlOffsets:a,associativeLinePoint:o}),this.isNotRenderAllLines=!0,setTimeout(()=>{this.resetControlPoint()},0)}function oT(){this.isControlPointMousedown=!1,this.mousedownControlPointKey="",this.controlPointMousemoveState={pos:null,startPoint:null,endPoint:null,targetIndex:""}}function lT(i,e,t,r,n,s){if(!this.mindMap.opt.enableAdjustAssociativeLinePoints)return;this.controlLine1||this.createControlNodes(n,s);let a=this.controlPointDiameter/2;this.controlLine1.plot(i.x,i.y,t.x,t.y),this.controlLine2.plot(e.x,e.y,r.x,r.y),this.controlPoint1.x(t.x-a).y(t.y-a),this.controlPoint2.x(r.x-a).y(r.y-a)}function hT(){this.controlLine1&&([this.controlLine1,this.controlLine2,this.controlPoint1,this.controlPoint2].forEach(i=>{i.remove()}),this.controlLine1=null,this.controlLine2=null,this.controlPoint1=null,this.controlPoint2=null)}function dT(){this.controlLine1&&[this.controlLine1,this.controlLine2,this.controlPoint1,this.controlPoint2].forEach(i=>{i.hide()})}function cT(){this.controlLine1&&[this.controlLine1,this.controlLine2,this.controlPoint1,this.controlPoint2].forEach(i=>{i.show()})}var jc,B3=M(()=>{$c();jc={createControlNodes:tT,createOneControlNode:iT,onControlPointMousedown:rT,onControlPointMousemove:nT,onControlPointMouseup:aT,resetControlPoint:oT,renderControls:lT,removeControls:hT,hideControls:dT,showControls:cT,updataAassociativeLine:sT}});function fT(i){let e=this.associativeLineDraw.group(),t=()=>{(!this.activeLine||this.activeLine[3]!==i.node||this.activeLine[4]!==i.toNode)&&this.setActiveLine({...i,text:e})};return e.click(r=>{r.stopPropagation(),t()}),e.on("dblclick",r=>{r.stopPropagation(),t(),this.activeLine&&this.showEditTextBox(e)}),e}function mT(i){this.mindMap.emit("before_show_text_edit"),this.mindMap.keyCommand.addShortcut("Enter",()=>{this.hideEditTextBox()}),this.textEditNode||(this.textEditNode=document.createElement("div"),this.textEditNode.className=uT,this.textEditNode.style.cssText="position:fixed;box-sizing: border-box;background-color:#fff;box-shadow: 0 0 20px rgba(0,0,0,.5);padding: 3px 5px;margin-left: -5px;margin-top: -3px;outline: none; word-break: break-all;",this.textEditNode.setAttribute("contenteditable",!0),this.textEditNode.addEventListener("keyup",f=>{f.stopPropagation()}),this.textEditNode.addEventListener("click",f=>{f.stopPropagation()}),(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.textEditNode));let[,,,e,t]=this.activeLine,{associativeLineTextFontSize:r,associativeLineTextFontFamily:n,associativeLineTextLineHeight:s}=this.getStyleConfig(e,t),{defaultAssociativeLineText:a,nodeTextEditZIndex:o}=this.mindMap.opt,l=this.mindMap.view.scale,h=this.getText(e,t),d=(h||a).split(/\n/gim);this.textEditNode.style.fontFamily=n,this.textEditNode.style.fontSize=r*l+"px",this.textEditNode.style.lineHeight=d.length>1?s:"normal",this.textEditNode.style.zIndex=o,this.textEditNode.innerHTML=d.join("
    "),this.textEditNode.style.display="block",this.updateTextEditBoxPos(i),this.setIsShowTextEdit(!0),h===""||h===a?Ls(this.textEditNode):_s(this.textEditNode)}function pT(i){this.showTextEdit=i,i?this.mindMap.keyCommand.stopCheckInSvg():this.mindMap.keyCommand.recoveryCheckInSvg()}function gT(){if(!this.textEditNode)return;(this.mindMap.opt.customInnerElsAppendTo||document.body).removeChild(this.textEditNode)}function xT(){this.hideEditTextBox()}function vT(i){let e=i.node.getBoundingClientRect();this.textEditNode&&(this.textEditNode.style.minWidth=`${e.width+10}px`,this.textEditNode.style.minHeight=`${e.height+6}px`,this.textEditNode.style.left=`${e.left}px`,this.textEditNode.style.top=`${e.top}px`)}function yT(){if(!this.showTextEdit)return;let[i,,e,t,r]=this.activeLine,n=As(this.textEditNode.innerHTML);n=n===this.mindMap.opt.defaultAssociativeLineText?"":n,this.mindMap.execCommand("SET_NODE_DATA",t,{associativeLineText:{...t.getData("associativeLineText")||{},[r.getData("uid")]:n}}),this.textEditNode.style.display="none",this.textEditNode.innerHTML="",this.setIsShowTextEdit(!1),this.renderText(n,i,e,t,r),this.mindMap.emit("hide_text_edit")}function bT(i,e){let t=i.getData("associativeLineText");return t&&t[e.getData("uid")]||""}function wT(i,e,t,r,n){if(!i)return;let{associativeLineTextFontSize:s,associativeLineTextLineHeight:a}=this.getStyleConfig(r,n);t.clear(),i.replace(/\n$/g,"").split(/\n/gim).forEach((l,h)=>{l===""&&(l="\uFEFF");let d=new Te().text(l);d.y(s*a*h),this.styleText(d,r,n),t.add(d)}),P3(e,t)}function MT(i,e,t){let{associativeLineTextColor:r,associativeLineTextFontSize:n,associativeLineTextFontFamily:s}=this.getStyleConfig(e,t);i.fill({color:r}).css({"font-family":s,"font-size":n+"px"})}function P3(i,e){let t=i.length(),r=i.pointAt(t/2),{width:n,height:s}=e.bbox();e.x(r.x-n/2),e.y(r.y-s/2)}var uT,Gc,F3=M(()=>{ht();he();uT="associative-line-text-edit-warp";Gc={getText:bT,createText:fT,styleText:MT,onScale:xT,showEditTextBox:mT,setIsShowTextEdit:pT,removeTextEditEl:gT,hideEditTextBox:yT,updateTextEditBoxPos:vT,renderText:wT,updateTextPos:P3}});var q3={};ti(q3,{default:()=>NT});var TT,Yc,p0,NT,H3=M(()=>{he();qd();$c();B3();F3();TT=["associativeLineWidth","associativeLineColor","associativeLineActiveWidth","associativeLineActiveColor","associativeLineDasharray","associativeLineTextColor","associativeLineTextFontSize","associativeLineTextLineHeight","associativeLineTextFontFamily"],Yc="associative-line-text-edit-warp",p0=class{constructor(e={}){this.mindMap=e.mindMap,this.associativeLineDraw=this.mindMap.associativeLineDraw,this.isNotRenderAllLines=!1,this.lineList=[],this.activeLine=null,this.isCreatingLine=!1,this.creatingStartNode=null,this.creatingLine=null,this.overlapNode=null,this.isNodeDragging=!1,this.controlLine1=null,this.controlLine2=null,this.controlPoint1=null,this.controlPoint2=null,this.controlPointDiameter=10,this.isControlPointMousedown=!1,this.mousedownControlPointKey="",this.controlPointMousemoveState={pos:null,startPoint:null,endPoint:null,targetIndex:""},this.checkOverlapNode=mi(this.checkOverlapNode,100,this),Object.keys(jc).forEach(t=>{this[t]=jc[t].bind(this)}),this.showTextEdit=!1,Object.keys(Gc).forEach(t=>{this[t]=Gc[t].bind(this)}),this.mindMap.addEditNodeClass(Yc),this.bindEvent()}bindEvent(){this.renderAllLines=this.renderAllLines.bind(this),this.onDrawClick=this.onDrawClick.bind(this),this.onNodeClick=this.onNodeClick.bind(this),this.removeLine=this.removeLine.bind(this),this.addLine=this.addLine.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onNodeDragging=this.onNodeDragging.bind(this),this.onNodeDragend=this.onNodeDragend.bind(this),this.onControlPointMouseup=this.onControlPointMouseup.bind(this),this.onBeforeDestroy=this.onBeforeDestroy.bind(this),this.mindMap.on("node_tree_render_end",this.renderAllLines),this.mindMap.on("data_change",this.renderAllLines),this.mindMap.on("draw_click",this.onDrawClick),this.mindMap.on("node_click",this.onNodeClick),this.mindMap.on("contextmenu",this.onDrawClick),this.mindMap.keyCommand.addShortcut("Del|Backspace",this.removeLine),this.mindMap.command.add("ADD_ASSOCIATIVE_LINE",this.addLine),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("node_dragging",this.onNodeDragging),this.mindMap.on("node_dragend",this.onNodeDragend),this.mindMap.on("mouseup",this.onControlPointMouseup),this.mindMap.on("scale",this.onScale),this.mindMap.on("beforeDestroy",this.onBeforeDestroy)}unBindEvent(){this.mindMap.off("node_tree_render_end",this.renderAllLines),this.mindMap.off("data_change",this.renderAllLines),this.mindMap.off("draw_click",this.onDrawClick),this.mindMap.off("node_click",this.onNodeClick),this.mindMap.off("contextmenu",this.onDrawClick),this.mindMap.keyCommand.removeShortcut("Del|Backspace",this.removeLine),this.mindMap.command.remove("ADD_ASSOCIATIVE_LINE",this.addLine),this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("node_dragging",this.onNodeDragging),this.mindMap.off("node_dragend",this.onNodeDragend),this.mindMap.off("mouseup",this.onControlPointMouseup),this.mindMap.off("scale",this.onScale),this.mindMap.off("beforeDestroy",this.onBeforeDestroy)}getStyleConfig(e,t){let r={};t&&(r=(e.getData("associativeLineStyle")||{})[t.getData("uid")]||{});let n={};return TT.forEach(s=>{typeof r[s]<"u"?n[s]=r[s]:n[s]=e.getStyle(s)}),n}onBeforeDestroy(){this.hideEditTextBox(),this.removeTextEditEl()}onDrawClick(){this.isCreatingLine&&this.cancelCreateLine(),this.isControlPointMousedown||(this.clearActiveLine(),this.renderAllLines())}onNodeClick(e){this.isCreatingLine?this.completeCreateLine(e):(this.clearActiveLine(),this.renderAllLines())}createMarker(e=()=>{}){return this.associativeLineDraw.marker(20,20,t=>{t.ref(12,5),t.size(10,10),t.attr("orient","auto-start-reverse"),e(t.path("M0,0 L2,5 L0,10 L10,5 Z"))})}updateAllLinesPos(e,t,r){r=r||{};let[n,s]=Hc(e,t),a=0,o="",l=0,h="";return r.startPoint&&(a=r.startPoint.range||0,o=r.startPoint.dir||"right",n=dr(e,o,a)),r.endPoint&&(l=r.endPoint.range||0,h=r.endPoint.dir||"right",s=dr(t,h,l)),[n,s]}renderAllLines(){if(this.isNotRenderAllLines){this.isNotRenderAllLines=!1;return}this.removeAllLines(),this.removeControls(),this.clearActiveLine();let e=this.mindMap.renderer.root;if(!e)return;let t=new Map,r=new Map;se(e,null,n=>{if(!n)return;let s=n.getData();s.associativeLineTargets&&s.associativeLineTargets.length>0&&r.set(n,s.associativeLineTargets),s.uid&&t.set(s.uid,n)},()=>{},!0,0),r.forEach((n,s)=>{n.forEach((a,o)=>{let l=t.get(a);if(!s||!l)return;let h=(s.getData("associativeLinePoint")||[])[o],[d,c]=this.updateAllLinesPos(s,l,h);this.drawLine(d,c,s,l)})})}drawLine(e,t,r,n){let{associativeLineWidth:s,associativeLineColor:a,associativeLineActiveWidth:o,associativeLineDasharray:l}=this.getStyleConfig(r,n),h=null,d=this.createMarker(v=>{h=v});h.stroke({color:a}).fill({color:a});let{path:c,controlPoints:f}=O3(e,t,r,n),m=this.associativeLineDraw.path();m.stroke({width:s,color:a,dasharray:l||"6,4"}).fill({color:"none"}),m.plot(c),m.marker("end",d);let g=this.associativeLineDraw.path();g.stroke({width:o,color:"transparent"}).fill({color:"none"}),g.plot(c);let x=this.createText({path:m,clickPath:g,markerPath:h,node:r,toNode:n,startPoint:e,endPoint:t,controlPoints:f});g.click(v=>{v.stopPropagation(),this.setActiveLine({path:m,clickPath:g,markerPath:h,text:x,node:r,toNode:n,startPoint:e,endPoint:t,controlPoints:f})}),g.dblclick(()=>{this.activeLine&&this.showEditTextBox(x)}),this.renderText(this.getText(r,n),m,x,r,n),this.lineList.push([m,g,x,r,n])}updateActiveLineStyle(){if(!this.activeLine)return;this.isNotRenderAllLines=!0;let[e,t,r,n,s,a]=this.activeLine,{associativeLineWidth:o,associativeLineColor:l,associativeLineDasharray:h,associativeLineActiveWidth:d,associativeLineActiveColor:c,associativeLineTextColor:f,associativeLineTextFontFamily:m,associativeLineTextFontSize:g}=this.getStyleConfig(n,s);e.stroke({width:o,color:l,dasharray:h||"6,4"}).fill({color:"none"}),t.stroke({width:d,color:c}).fill({color:"none"}),a.stroke({color:l}).fill({color:l}),r.find("text").forEach(x=>{x.fill({color:f}).css({"font-family":m,"font-size":g+"px"})}),this.controlLine1&&this.controlLine1.stroke({color:c}),this.controlLine2&&this.controlLine2.stroke({color:c}),this.controlPoint1&&this.controlPoint1.stroke({color:c}),this.controlPoint2&&this.controlPoint2.stroke({color:c}),this.updateTextPos(e,r)}setActiveLine({path:e,clickPath:t,markerPath:r,text:n,node:s,toNode:a,startPoint:o,endPoint:l,controlPoints:h}){let{associativeLineActiveColor:d}=this.getStyleConfig(s,a);this.mindMap.execCommand("CLEAR_ACTIVE_NODE"),this.clearActiveLine(),this.activeLine=[e,t,n,s,a,r],t.stroke({color:d}),this.getText(s,a)||this.renderText(this.mindMap.opt.defaultAssociativeLineText,e,n,s,a),this.renderControls(o,l,h[0],h[1],s,a),this.mindMap.emit("associative_line_click",e,t,s,a),this.front()}removeAllLines(){this.lineList.forEach(e=>{e[0].remove(),e[1].remove(),e[2].remove()}),this.lineList=[]}createLineFromActiveNode(){if(this.mindMap.renderer.activeNodeList.length<=0)return;let e=this.mindMap.renderer.activeNodeList[0];this.createLine(e)}createLine(e){let{associativeLineWidth:t,associativeLineColor:r,associativeLineDasharray:n}=this.getStyleConfig(e);if(this.isCreatingLine||!e)return;this.front(),this.isCreatingLine=!0,this.creatingStartNode=e,this.creatingLine=this.associativeLineDraw.path(),this.creatingLine.stroke({width:t,color:r,dasharray:n||"6,4"}).fill({color:"none"});let s=null,a=this.createMarker(o=>{s=o});s.stroke({color:r}).fill({color:r}),this.creatingLine.marker("end",a)}cancelCreateLine(){this.isCreatingLine=!1,this.creatingStartNode=null,this.creatingLine.remove(),this.creatingLine=null,this.overlapNode=null,this.back()}onMousemove(e){this.onControlPointMousemove(e),this.updateCreatingLine(e)}updateCreatingLine(e){if(!this.isCreatingLine)return;let{x:t,y:r}=this.getTransformedEventPos(e),n=dr(this.creatingStartNode),s=t>n.x?-10:10,a=D3(n.x,n.y,t+s,r);this.creatingLine.plot(a),this.checkOverlapNode(t,r)}getTransformedEventPos(e){let{x:t,y:r}=this.mindMap.toPos(e.clientX,e.clientY),{scaleX:n,scaleY:s,translateX:a,translateY:o}=this.mindMap.draw.transform();return{x:(t-a)/n,y:(r-o)/s}}getNodePos(e){let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.mindMap.draw.transform(),{left:a,top:o,width:l,height:h}=e,d=a*t+n,c=o*r+s;return{left:a,top:o,translateLeft:d,translateTop:c,width:l,height:h}}checkOverlapNode(e,t){this.overlapNode=null,Pt(this.mindMap.renderer.root,r=>{if(r.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",r,!1),r.uid===this.creatingStartNode.uid||this.overlapNode)return;let{left:n,top:s,width:a,height:o}=r,l=n+a,h=s+o;e>=n&&e<=l&&t>=s&&t<=h&&(this.overlapNode=r)}),this.overlapNode&&!this.overlapNode.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!0)}completeCreateLine(e){if(this.creatingStartNode.uid===e.uid)return;let{beforeAssociativeLineConnection:t}=this.mindMap.opt,r=!1;typeof t=="function"&&(r=t(e)),!r&&(this.addLine(this.creatingStartNode,e),this.overlapNode&&this.overlapNode.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!1),this.cancelCreateLine())}addLine(e,t){if(!e||!t)return;let r=t.getData("uid");r||(r=Da(),this.mindMap.execCommand("SET_NODE_DATA",t,{uid:r}));let n=e.getData("associativeLineTargets")||[];if(n.some(f=>f===r))return;n.push(r);let[a,o]=Hc(e,t),l=po(a.x,a.y,o.x,o.y),{associativeLineInitPointsPosition:h}=this.mindMap.opt;if(h){let{from:f,to:m}=h;f&&(a.dir=f),m&&(o.dir=m)}let d=e.getData("associativeLineTargetControlOffsets")||[];d[n.length-1]=[{x:l[0].x-a.x,y:l[0].y-a.y},{x:l[1].x-o.x,y:l[1].y-o.y}];let c=e.getData("associativeLinePoint")||[];c[n.length-1]={startPoint:a,endPoint:o},this.mindMap.execCommand("SET_NODE_DATA",e,{associativeLineTargets:n,associativeLineTargetControlOffsets:d,associativeLinePoint:c})}removeLine(){if(!this.activeLine)return;let[,,,e,t]=this.activeLine;this.removeControls();let{associativeLineTargets:r,associativeLinePoint:n,associativeLineTargetControlOffsets:s,associativeLineText:a,associativeLineStyle:o}=e.getData();n=n||[];let l=mo(e,t),h={};a&&Object.keys(a).forEach(c=>{c!==t.getData("uid")&&(h[c]=a[c])});let d={};o&&Object.keys(o).forEach(c=>{c!==t.getData("uid")&&(d[c]=o[c])}),this.mindMap.execCommand("SET_NODE_DATA",e,{associativeLineTargets:r.filter((c,f)=>f!==l),associativeLinePoint:n.filter((c,f)=>f!==l),associativeLineTargetControlOffsets:s?s.filter((c,f)=>f!==l):[],associativeLineText:h,associativeLineStyle:d})}clearActiveLine(){if(this.activeLine){let[,e,t,r,n]=this.activeLine;e.stroke({color:"transparent"}),this.hideEditTextBox(),this.getText(r,n)||t.clear(),this.activeLine=null,this.removeControls(),this.back(),this.mindMap.emit("associative_line_deactivate")}}onNodeDragging(){this.isNodeDragging||(this.isNodeDragging=!0,this.lineList.forEach(e=>{e[0].hide(),e[1].hide(),e[2].hide()}),this.hideControls())}onNodeDragend(){this.isNodeDragging&&(this.lineList.forEach(e=>{e[0].show(),e[1].show(),e[2].show()}),this.showControls(),this.isNodeDragging=!1)}front(){this.mindMap.opt.associativeLineIsAlwaysAboveNode||this.associativeLineDraw.front()}back(){this.mindMap.opt.associativeLineIsAlwaysAboveNode||(this.associativeLineDraw.back(),this.associativeLineDraw.forward())}beforePluginRemove(){this.mindMap.deleteEditNodeClass(Yc),this.unBindEvent()}beforePluginDestroy(){this.mindMap.deleteEditNodeClass(Yc),this.unBindEvent()}};p0.instanceName="associativeLine";NT=p0});var U3={};ti(U3,{default:()=>ET});var g0,ET,$3=M(()=>{he();a0();Oe();g0=class{constructor({mindMap:e}){this.mindMap=e,this.isSearching=!1,this.searchText="",this.matchNodeList=[],this.currentIndex=-1,this.notResetSearchText=!1,this.isJumpNext=!1,this.bindEvent()}bindEvent(){this.onDataChange=this.onDataChange.bind(this),this.onModeChange=this.onModeChange.bind(this),this.mindMap.on("data_change",this.onDataChange),this.mindMap.on("mode_change",this.onModeChange)}unBindEvent(){this.mindMap.off("data_change",this.onDataChange),this.mindMap.off("mode_change",this.onModeChange)}onDataChange(){if(this.isJumpNext){this.isJumpNext=!1,this.search(this.searchText);return}if(this.notResetSearchText){this.notResetSearchText=!1;return}this.searchText=""}onModeChange(e){!(e===A.MODE.READONLY)&&this.isSearching&&this.matchNodeList[this.currentIndex]&&this.matchNodeList[this.currentIndex].closeHighlight()}search(e,t=()=>{}){if(Bt(e))return this.endSearch();e=String(e),this.isSearching=!0,this.searchText===e?this.searchNext(t):(this.searchText=e,this.doSearch(),this.searchNext(t)),this.emitEvent()}updateMatchNodeList(e){this.matchNodeList=e,this.mindMap.emit("search_match_node_list_change",e)}endSearch(){this.isSearching&&(this.mindMap.opt.readonly&&this.matchNodeList[this.currentIndex]&&this.matchNodeList[this.currentIndex].closeHighlight(),this.searchText="",this.updateMatchNodeList([]),this.currentIndex=-1,this.notResetSearchText=!1,this.isSearching=!1,this.emitEvent())}doSearch(){this.clearHighlightOnReadonly(),this.updateMatchNodeList([]),this.currentIndex=-1;let{isOnlySearchCurrentRenderNodes:e}=this.mindMap.opt,t=e?this.mindMap.renderer.root:this.mindMap.renderer.renderTree;if(!t)return;let r=[];Pt(t,n=>{let{richText:s,text:a,generalization:o}=e?n.getData():n.data;s&&(a=ks(a)),a.includes(this.searchText)&&r.push(n),Hn({generalization:o}).forEach(h=>{let{richText:d,text:c,uid:f}=h;e&&!this.mindMap.renderer.findNodeByUid(f)||(d&&(c=ks(c)),c.includes(this.searchText)&&r.push({data:h}))})}),this.updateMatchNodeList(r)}isNodeInstance(e){return e instanceof Is}searchNext(e,t){if(!this.isSearching||this.matchNodeList.length<=0)return;t!==void 0&&Number.isInteger(t)&&t>=0&&t{this.isNodeInstance(n)||(this.matchNodeList[this.currentIndex]=o,this.updateMatchNodeList(this.matchNodeList)),e(),r&&o.highlight(),a&&(this.notResetSearchText=!1)})}clearHighlightOnReadonly(){let{readonly:e}=this.mindMap.opt;e&&this.matchNodeList.forEach(t=>{this.isNodeInstance(t)&&t.closeHighlight()})}jump(e,t=()=>{}){this.searchNext(t,e)}replace(e,t=!1){if(e==null||!this.isSearching||this.matchNodeList.length<=0)return;this.isJumpNext=t,e=String(e);let r=this.matchNodeList[this.currentIndex];if(!r)return;let n=e.includes(this.searchText),s=this.getReplacedText(r,this.searchText,e);if(this.notResetSearchText=!0,r.setText(s,r.getData("richText")),n){this.updateMatchNodeList(this.matchNodeList);return}let a=this.matchNodeList.filter(o=>r!==o);this.updateMatchNodeList(a),this.currentIndex>this.matchNodeList.length-1?this.currentIndex=-1:this.currentIndex--,this.emitEvent()}replaceAll(e){if(e==null||!this.isSearching||this.matchNodeList.length<=0)return;e=String(e);let t=e.includes(this.searchText);this.notResetSearchText=!0,this.matchNodeList.forEach(r=>{let n=this.getReplacedText(r,this.searchText,e);if(this.isNodeInstance(r)){let s={text:n};this.mindMap.renderer.setNodeDataRender(r,s,!0)}else r.data.text=n}),this.mindMap.render(),this.mindMap.command.addHistory(),t?this.updateMatchNodeList(this.matchNodeList):this.endSearch()}getReplacedText(e,t,r){let{richText:n,text:s}=this.isNodeInstance(e)?e.getData():e.data;return n?$p(s,t,r):s.replace(new RegExp(t,"g"),r)}emitEvent(){this.mindMap.emit("search_info_change",{currentIndex:this.currentIndex,total:this.matchNodeList.length})}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};g0.instanceName="search";ET=g0});var j3,G3,Y3=M(()=>{he();j3=i=>{i=Fn(i);let e={},t={};i.forEach(n=>{let s=n.parent;if(s){let a=s.uid;t[a]=s;let o=n.getIndexInBrothers(),l={node:n,index:o};e[a]?e[a].find(h=>h.index===l.index)||e[a].push(l):e[a]=[l]}});let r=[];return Object.keys(e).forEach(n=>{let s=e[n],a=t[n];if(s.length>1){let o=s.map(f=>f.index).sort((f,m)=>f-m),l=o[0],h=o[o.length-1],d=-1,c=-1;for(let f=l;f<=h;f++)o.includes(f)?(d===-1&&(d=f),c=f):(d!==-1&&c!==-1&&r.push({node:a,range:[d,c]}),d=-1,c=-1);d!==-1&&c!==-1&&r.push({node:a,range:[d,c]})}else r.push({node:a,range:[s[0].index,s[0].index]})}),r},G3=i=>{let e=i.children;if(!e||e.length<=0)return;let t=[],r={};return e.forEach((n,s)=>{let a=n.getData("outerFrame");if(!a)return;let o=a.groupId;o?(r[o]||(r[o]=[]),r[o].push({node:n,index:s})):t.push({nodeList:[n],range:[s,s]})}),Object.keys(r).forEach(n=>{let s=r[n];t.push({nodeList:s.map(a=>a.node),range:[s[0].index,s[s.length-1].index]})}),t}});function AT(i,e,t){let r=this.draw.group(),n=()=>{(!this.activeOuterFrame||this.activeOuterFrame.el!==i)&&this.setActiveOuterFrame(i,e,t,r)};return r.click(s=>{s.stopPropagation(),n()}),r.on("dblclick",s=>{s.stopPropagation(),n(),this.showEditTextBox(r)}),r}function kT(i){this.mindMap.emit("before_show_text_edit"),this.mindMap.keyCommand.addShortcut("Enter",()=>{this.hideEditTextBox()}),this.textEditNode||(this.textEditNode=document.createElement("div"),this.textEditNode.className=ST,this.textEditNode.style.cssText=` +`},()=>{},!0),e}});var h6={};tt(h6,{default:()=>fE});var th,fE,d6=T(()=>{pe();yt();n6();a6();$e();l6();th=class{constructor(e){this.mindMap=e.mindMap}async export(e,t=!0,r="\u601D\u7EF4\u5BFC\u56FE",...n){if(this[e]){let s=await this[e](r,...n);return t&&m2(s,r+"."+e),s}else return null}createTransformImgTaskList(e,t,r,n){return e.find(t).map(async a=>{let o=n(a);if(/^data:/.test(o)||o==="none")return;let l=await fu(o);a.attr(r,l)})}async getSvgData(e){let{exportPaddingX:t,exportPaddingY:r,errorHandler:n,resetCss:s,addContentToHeader:a,addContentToFooter:o,handleBeingExportSvg:l}=this.mindMap.opt,{svg:h,svgHTML:d,clipData:c}=this.mindMap.getSvgData({paddingX:t,paddingY:r,addContentToHeader:a,addContentToFooter:o,node:e});c&&(c.paddingX=t,c.paddingY=r);let f=!1,m=this.createTransformImgTaskList(h,"image","href",y=>y.attr("href")||y.attr("xlink:href")),g=this.createTransformImgTaskList(h,"img","src",y=>y.attr("src")),x=[...m,...g];try{await Promise.all(x)}catch(y){n(Mi.EXPORT_LOAD_IMAGE_ERROR,y)}if(this.mindMap.richText){let y=h.find("foreignObject");if(y.length>0&&(y[0].add(Ae(``)),f=!0),this.mindMap.formula&&h.find(".ql-formula").length>0){let S=this.mindMap.formula.getStyleText();if(S){let A=document.createElement("style");A.innerHTML=S,or(A),y[0].add(A),f=!0}}}return typeof l=="function"&&(f=!0,h=l(h)),(x.length>0||f)&&(d=h.svg()),{node:h,str:d,clipData:c}}svgToPng(e,t,r=null,n=!1,s="image/png"){let{maxCanvasSize:a,minExportImgCanvasScale:o}=this.mindMap.opt;return new Promise((l,h)=>{let d=new Image;d.setAttribute("crossOrigin","anonymous"),d.onload=async()=>{try{let c=document.createElement("canvas"),f=Math.max(window.devicePixelRatio,o),m=d.width,g=d.height,x=0,y=0;r&&(x=r.paddingX,y=r.paddingY,m=r.width+x*2,g=r.height+y*2);let b=0,S=0,{backgroundImage:A}=this.mindMap.themeConfig;if(n&&A&&!t){let ke=await new Promise(Q=>{let Y=new Image;Y.onload=()=>{Q([Y.width,Y.height])},Y.onerror=()=>{Q(null)},Y.src=A});if(ke){let Q=m/g,Y=ke[0]/ke[1];Q>Y?(b=m,S=m/Y):(S=g,b=g*Y)}}let C=1,I=1,O=(b||m)*f,q=(S||g)*f;if(O>a||q>a){let ke=null,Q=null;O>a?ke=a:q>a&&(Q=a);let Y=U0(O,q,ke,Q);C=Y[0]/O,I=Y[1]/q,O=Y[0],q=Y[1]}c.width=O,c.height=q;let P=O/f,W=q/f;c.style.width=P+"px",c.style.height=W+"px";let ne=c.getContext("2d");ne.scale(f,f),t||await this.drawBackgroundToCanvas(ne,P,W);let re=(b>0?(b-m)/2:0)*C,oe=(S>0?(S-g)/2:0)*I;r?ne.drawImage(d,r.left,r.top,r.width,r.height,x*C+re,y*I+oe,r.width*C,r.height*I):ne.drawImage(d,re,oe,m*C,g*I),l(c.toDataURL(s))}catch(c){h(c)}},d.onerror=c=>{h(c)},d.src=e})}drawBackgroundToCanvas(e,t,r){return new Promise((n,s)=>{let{backgroundColor:a="#fff",backgroundImage:o,backgroundRepeat:l="no-repeat",backgroundPosition:h="center center",backgroundSize:d="cover"}=this.mindMap.themeConfig;e.save(),e.rect(0,0,t,r),e.fillStyle=a,e.fill(),e.restore(),o&&o!=="none"?(e.save(),r6(e,t,r,o,{backgroundRepeat:l,backgroundPosition:h,backgroundSize:d},c=>{c?s(c):n(),e.restore()})):n()})}drawBackgroundToSvg(e){return new Promise(async t=>{let{backgroundColor:r="#fff",backgroundImage:n,backgroundRepeat:s="repeat"}=this.mindMap.themeConfig;if(e.css("background-color",r),n&&n!=="none"){let a=await fu(n);e.css("background-image",`url(${a})`),e.css("background-repeat",s),t()}else t()})}async _image(e,t,r=!1,n=null,s=!1){this.mindMap.renderer.textEdit.hideEditTextBox(),this.handleNodeExport(n);let{str:a,clipData:o}=await this.getSvgData(n),l=await this.fixSvgStrAndToBlob(a);return await this.svgToPng(l,r,o,s,e)}async png(...e){return await this._image("image/png",...e)}async jpg(...e){return await this._image("image/jpg",...e)}handleNodeExport(e){if(e&&e.getData("isActive")){e.deactivate();let{alwaysShowExpandBtn:t,notShowExpandBtn:r}=this.mindMap.opt;!t&&!r&&e.getData("expand")&&e.removeExpandBtn()}}async pdf(e,t=!1,r=!1){if(!this.mindMap.doExportPDF)throw new Error("\u8BF7\u6CE8\u518CExportPDF\u63D2\u4EF6");let n=await this.png(e,t,null,r);return await this.mindMap.doExportPDF.pdf(n)}async xmind(e){if(!this.mindMap.doExportXMind)throw new Error("\u8BF7\u6CE8\u518CExportXMind\u63D2\u4EF6");let t=this.mindMap.getData(),r=await this.mindMap.doExportXMind.xmind(t,e);return await aa(r)}async svg(e){this.mindMap.renderer.textEdit.hideEditTextBox();let{node:t}=await this.getSvgData();t.first().before(Ae(`${e}`)),await this.drawBackgroundToSvg(t);let r=t.svg();return await this.fixSvgStrAndToBlob(r)}async fixSvgStrAndToBlob(e){e=b2(e),e=_2(e);let t=new Blob([e],{type:"image/svg+xml"});return await aa(t)}async json(e,t=!0){let r=this.mindMap.getData(t),n=JSON.stringify(r),s=new Blob([n]);return await aa(s)}async smm(e,t){return await this.json(e,t)}async md(){let e=this.mindMap.getData(),t=s6(e),r=new Blob([t]);return await aa(r)}async txt(){let e=this.mindMap.getData(),t=o6(e),r=new Blob([t]);return await aa(r)}};th.instanceName="doExport";fE=th});var c6={};tt(c6,{default:()=>mE});var ih,mE,u6=T(()=>{pe();Bu();ih=class{constructor({mindMap:e}){this.mindMap=e,this.rect=null,this.isMousedown=!1,this.mouseDownX=0,this.mouseDownY=0,this.mouseMoveX=0,this.mouseMoveY=0,this.isSelecting=!1,this.cacheActiveList=[],this.autoMove=new K0(e),this.bindEvent()}bindEvent(){this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.checkInNodes=Si(this.checkInNodes,300,this),this.mindMap.on("mousedown",this.onMousedown),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("mouseup",this.onMouseup),this.mindMap.on("node_mouseup",this.onMouseup)}unBindEvent(){this.mindMap.off("mousedown",this.onMousedown),this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("mouseup",this.onMouseup),this.mindMap.off("node_mouseup",this.onMouseup)}onMousedown(e){let{readonly:t,mousedownEventPreventDefault:r}=this.mindMap.opt;if(t)return;let{useLeftKeySelectionRightKeyDrag:n}=this.mindMap.opt;if(!(e.ctrlKey||e.metaKey)&&(n?e.which!==1:e.which!==3))return;r&&e.preventDefault(),this.isMousedown=!0,this.cacheActiveList=[...this.mindMap.renderer.activeNodeList];let{x:s,y:a}=this.mindMap.toPos(e.clientX,e.clientY);this.mouseDownX=s,this.mouseDownY=a,this.createRect(s,a)}onMousemove(e){if(this.mindMap.opt.readonly||!this.isMousedown)return;let{x:t,y:r}=this.mindMap.toPos(e.clientX,e.clientY);this.mouseMoveX=t,this.mouseMoveY=r,!(Math.abs(t-this.mouseDownX)<=10&&Math.abs(r-this.mouseDownY)<=10)&&(this.autoMove.clearAutoMoveTimer(),this.autoMove.onMove(e.clientX,e.clientY,()=>{this.isSelecting=!0,this.rect&&this.rect.plot([[this.mouseDownX,this.mouseDownY],[this.mouseMoveX,this.mouseDownY],[this.mouseMoveX,this.mouseMoveY],[this.mouseDownX,this.mouseMoveY]]),this.checkInNodes()},(n,s)=>{switch(n){case"left":this.mouseDownX+=s;break;case"top":this.mouseDownY+=s;break;case"right":this.mouseDownX-=s;break;case"bottom":this.mouseDownY-=s;break;default:break}}))}onMouseup(){this.mindMap.opt.readonly||this.isMousedown&&(this.checkTriggerNodeActiveEvent(),this.autoMove.clearAutoMoveTimer(),this.isMousedown=!1,this.cacheActiveList=[],this.rect&&this.rect.remove(),this.rect=null,setTimeout(()=>{this.isSelecting=!1},0))}checkTriggerNodeActiveEvent(){let e=this.cacheActiveList.length!==this.mindMap.renderer.activeNodeList.length,t=!1;if(!e)for(let r=0;rs.getData("uid")===n.getData("uid"))){t=!0;break}}(e||t)&&this.mindMap.renderer.emitNodeActiveEvent()}createRect(e,t){this.rect&&this.rect.remove(),this.rect=this.mindMap.svg.polygon().stroke({color:"#0984e3"}).fill({color:"rgba(9,132,227,0.3)"}).plot([[e,t]])}checkInNodes(){let{scaleX:e,scaleY:t,translateX:r,translateY:n}=this.mindMap.draw.transform(),s=Math.min(this.mouseDownX,this.mouseMoveX),a=Math.min(this.mouseDownY,this.mouseMoveY),o=Math.max(this.mouseDownX,this.mouseMoveX),l=Math.max(this.mouseDownY,this.mouseMoveY),h=d=>{let{left:c,top:f,width:m,height:g}=d,x=(c+m)*e+r,y=(f+g)*t+n;if(c=c*e+r,f=f*t+n,k2(s,o,a,l,c,x,f,y)){if(d.getData("isActive"))return;this.mindMap.renderer.addNodeToActiveList(d),this.mindMap.renderer.emitNodeActiveEvent()}else if(d.getData("isActive")){if(!d.getData("isActive"))return;this.mindMap.renderer.removeNodeFromActiveList(d),this.mindMap.renderer.emitNodeActiveEvent()}};Xt(this.mindMap.renderer.root,d=>{h(d),d._generalizationList&&d._generalizationList.length>0&&d._generalizationList.forEach(c=>{h(c.generalizationNode)})})}hasSelectRange(){return this.isSelecting}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};ih.instanceName="select";mE=ih});var Go,Vo,rh,f6,m6,pE,kr,Uu,p6,$u,ju=T(()=>{pe();Go=(i,e)=>i.getData("associativeLineTargets").findIndex(t=>t===e.getData("uid")),Vo=(i,e,t,r)=>{let s=i+(t-i)/2,a=e,o=s,l=r;return Math.abs(i-t)<=5&&(s=i+(r-e)/2,o=s),Math.abs(e-r)<=5&&(s=i,a=e-(t-i)/2,o=t,l=a),[{x:s,y:a},{x:o,y:l}]},rh=(i,e,t,r)=>`M ${i.x},${i.y} C ${t.x},${t.y} ${r.x},${r.y} ${e.x},${e.y}`,f6=i=>{let{left:e,top:t,width:r,height:n}=i;return{right:e+r,bottom:t+n,left:e,top:t,width:r,height:n}},m6=(i,e,t,r)=>{let n=Vo(i,e,t,r);return rh({x:i,y:e},{x:t,y:r},n[0],n[1])},pE=(i,e)=>{let{left:t,top:r,translateLeft:n,translateTop:s,width:a,height:o}=i,l=e.clientX,h=e.clientY,d=n+a/2,c=s+o/2,f=t+a/2,m=r+o/2,g=Math.atan(o/a),x=l-d,y=c-h,b=Math.atan2(y,x),S=t+a,A=r+o;if(b=-g){let O=b*(a/2);return(b=0||b>=-g&&b<0)&&(A=m-O),{x:S,y:A,dir:"right",range:O}}else if(b>=g&&b=g){let q=o/2/b;O=-q,S=f+q}else if(b>=Math.PI/2-g&&b=g-Math.PI){let O=0;if(b>=g-Math.PI/2&&b<-g){let q=o/2/b;O=q,S=f-q}else if(b=g-Math.PI){let q=(d-l)/(c-h),P=o/2*q;O=-P,S=f+P}return{x:S,y:A,dir:"bottom",range:O}}S=t;let I=(c-h)/(d-l)*(a/2);return(b>=-Math.PI&&b=Math.PI-g)&&(A=m-I),{x:S,y:A,dir:"left",range:I}},kr=(i,e="right",t=0,r=null)=>{let{left:n,top:s,width:a,height:o}=i;if(r)return pE(i,r);switch(e){case"left":return{x:n,y:s+o/2-t,dir:e};case"right":return{x:n+a,y:s+o/2-t,dir:e};case"top":return{x:n+a/2-t,y:s,dir:e};case"bottom":return{x:n+a/2-t,y:s+o,dir:e};default:break}},Uu=(i,e)=>{let t=f6(i),r=f6(e),n="",s="";switch(z2({x:t.left,y:t.top,width:t.width,height:t.height},{x:r.left,y:r.top,width:r.width,height:r.height})){case"left-top":n="right",s="top";break;case"right-top":n="left",s="top";break;case"right-bottom":n="left",s="bottom";break;case"left-bottom":n="right",s="bottom";break;case"left":n="right",s="left";break;case"right":n="left",s="right";break;case"top":n="right",s="right";break;case"bottom":n="left",s="left";break;case"overlap":n="right",s="right";break;default:break}return[kr(i,n),kr(e,s)]},p6=(i,e,t,r)=>{let n=Go(t,r),s=[],a=t.getData("associativeLineTargetControlOffsets");if(a&&a[n]){let o=a[n];s=[{x:i.x+o[0].x,y:i.y+o[0].y},{x:e.x+o[1].x,y:e.y+o[1].y}]}else s=Vo(i.x,i.y,e.x,e.y);return{path:rh(i,e,s[0],s[1]),controlPoints:s}},$u=(i,e)=>{let t=Vo(i.x,i.y,e.x,e.y);return[{x:t[0].x-i.x,y:t[0].y-i.y},{x:t[1].x-e.x,y:t[1].y-e.y}]}});function gE(i,e){let{associativeLineActiveColor:t}=this.getStyleConfig(i,e);this.controlLine1=this.associativeLineDraw.line().stroke({color:t,width:2}),this.controlLine2=this.associativeLineDraw.line().stroke({color:t,width:2}),this.controlPoint1=this.createOneControlNode("controlPoint1",i,e),this.controlPoint2=this.createOneControlNode("controlPoint2",i,e)}function xE(i,e,t){let{associativeLineActiveColor:r}=this.getStyleConfig(e,t);return this.associativeLineDraw.circle(this.controlPointDiameter).stroke({color:r}).fill({color:"#fff"}).click(n=>{n.stopPropagation()}).mousedown(n=>{this.onControlPointMousedown(n,i)})}function yE(i,e){i.stopPropagation(),i.preventDefault(),this.isControlPointMousedown=!0,this.mousedownControlPointKey=e}function vE(i){if(!this.isControlPointMousedown||!this.mousedownControlPointKey||!this[this.mousedownControlPointKey])return;i.stopPropagation(),i.preventDefault();let e=this.controlPointDiameter/2,{x:t,y:r}=this.getTransformedEventPos(i);this.controlPointMousemoveState.pos={x:t,y:r},this[this.mousedownControlPointKey].x(t-e).y(r-e);let[,,,n,s]=this.activeLine,a=Go(n,s),{associativeLinePoint:o,associativeLineTargetControlOffsets:l}=n.getData();o=o||[];let h=this.getNodePos(n),d=this.getNodePos(s),[c,f]=this.updateAllLinesPos(n,s,o[a]);this.controlPointMousemoveState.startPoint=c,this.controlPointMousemoveState.endPoint=f,this.controlPointMousemoveState.targetIndex=a;let m=[];l?m=l[a]:m=$u(c,f);let g=null,x=null,{x:y,y:b}=this.mindMap.toPos(i.clientX,i.clientY),S={clientX:y,clientY:b};this.mousedownControlPointKey==="controlPoint1"?(c=kr(h,"",0,S),g={x:t,y:r},x={x:f.x+m[1].x,y:f.y+m[1].y},c&&(this.controlPointMousemoveState.startPoint=c,this.controlLine1.plot(c.x,c.y,g.x,g.y))):(f=kr(d,"",0,S),g={x:c.x+m[0].x,y:c.y+m[0].y},x={x:t,y:r},f&&(this.controlPointMousemoveState.endPoint=f,this.controlLine2.plot(f.x,f.y,x.x,x.y))),this.updataAassociativeLine(c,f,g,x,this.activeLine)}function bE(i,e,t,r,n){let[s,a,o]=n,l=rh(i,e,t,r);s.plot(l),a.plot(l),this.updateTextPos(s,o),this.updateTextEditBoxPos(o)}function wE(i){if(!this.isControlPointMousedown)return;i.stopPropagation(),i.preventDefault();let{pos:e,startPoint:t,endPoint:r,targetIndex:n}=this.controlPointMousemoveState,[,,,s]=this.activeLine,a=[],{associativeLinePoint:o,associativeLineTargetControlOffsets:l}=s.getData();o||(o=[]),o[n]=o[n]||{startPoint:t,endPoint:r},l?a=l:a[n]=$u(t,r);let h=null,d=null;this.mousedownControlPointKey==="controlPoint1"?(h={x:e.x-t.x,y:e.y-t.y},d=a[n][1],o[n].startPoint=t):(h=a[n][0],d={x:e.x-r.x,y:e.y-r.y},o[n].endPoint=r),a[n]=[h,d],this.mindMap.execCommand("SET_NODE_DATA",s,{associativeLineTargetControlOffsets:a,associativeLinePoint:o}),this.isNotRenderAllLines=!0,setTimeout(()=>{this.resetControlPoint()},0)}function ME(){this.isControlPointMousedown=!1,this.mousedownControlPointKey="",this.controlPointMousemoveState={pos:null,startPoint:null,endPoint:null,targetIndex:""}}function TE(i,e,t,r,n,s){if(!this.mindMap.opt.enableAdjustAssociativeLinePoints)return;this.controlLine1||this.createControlNodes(n,s);let a=this.controlPointDiameter/2;this.controlLine1.plot(i.x,i.y,t.x,t.y),this.controlLine2.plot(e.x,e.y,r.x,r.y),this.controlPoint1.x(t.x-a).y(t.y-a),this.controlPoint2.x(r.x-a).y(r.y-a)}function NE(){this.controlLine1&&([this.controlLine1,this.controlLine2,this.controlPoint1,this.controlPoint2].forEach(i=>{i.remove()}),this.controlLine1=null,this.controlLine2=null,this.controlPoint1=null,this.controlPoint2=null)}function EE(){this.controlLine1&&[this.controlLine1,this.controlLine2,this.controlPoint1,this.controlPoint2].forEach(i=>{i.hide()})}function SE(){this.controlLine1&&[this.controlLine1,this.controlLine2,this.controlPoint1,this.controlPoint2].forEach(i=>{i.show()})}var Gu,g6=T(()=>{ju();Gu={createControlNodes:gE,createOneControlNode:xE,onControlPointMousedown:yE,onControlPointMousemove:vE,onControlPointMouseup:wE,resetControlPoint:ME,renderControls:TE,removeControls:NE,hideControls:EE,showControls:SE,updataAassociativeLine:bE}});function kE(i){let e=this.associativeLineDraw.group(),t=()=>{(!this.activeLine||this.activeLine[3]!==i.node||this.activeLine[4]!==i.toNode)&&this.setActiveLine({...i,text:e})};return e.click(r=>{r.stopPropagation(),t()}),e.on("dblclick",r=>{r.stopPropagation(),t(),this.activeLine&&this.showEditTextBox(e)}),e}function CE(i){this.mindMap.emit("before_show_text_edit"),this.mindMap.keyCommand.addShortcut("Enter",()=>{this.hideEditTextBox()}),this.textEditNode||(this.textEditNode=document.createElement("div"),this.textEditNode.className=AE,this.textEditNode.style.cssText="position:fixed;box-sizing: border-box;background-color:#fff;box-shadow: 0 0 20px rgba(0,0,0,.5);padding: 3px 5px;margin-left: -5px;margin-top: -3px;outline: none; word-break: break-all;",this.textEditNode.setAttribute("contenteditable",!0),this.textEditNode.addEventListener("keyup",f=>{f.stopPropagation()}),this.textEditNode.addEventListener("click",f=>{f.stopPropagation()}),(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.textEditNode));let[,,,e,t]=this.activeLine,{associativeLineTextFontSize:r,associativeLineTextFontFamily:n,associativeLineTextLineHeight:s}=this.getStyleConfig(e,t),{defaultAssociativeLineText:a,nodeTextEditZIndex:o}=this.mindMap.opt,l=this.mindMap.view.scale,h=this.getText(e,t),d=(h||a).split(/\n/gim);this.textEditNode.style.fontFamily=n,this.textEditNode.style.fontSize=r*l+"px",this.textEditNode.style.lineHeight=d.length>1?s:"normal",this.textEditNode.style.zIndex=o,this.textEditNode.innerHTML=d.join("
    "),this.textEditNode.style.display="block",this.updateTextEditBoxPos(i),this.setIsShowTextEdit(!0),h===""||h===a?la(this.textEditNode):oa(this.textEditNode)}function _E(i){this.showTextEdit=i,i?this.mindMap.keyCommand.stopCheckInSvg():this.mindMap.keyCommand.recoveryCheckInSvg()}function LE(){if(!this.textEditNode)return;(this.mindMap.opt.customInnerElsAppendTo||document.body).removeChild(this.textEditNode)}function IE(){this.hideEditTextBox()}function zE(i){let e=i.node.getBoundingClientRect();this.textEditNode&&(this.textEditNode.style.minWidth=`${e.width+10}px`,this.textEditNode.style.minHeight=`${e.height+6}px`,this.textEditNode.style.left=`${e.left}px`,this.textEditNode.style.top=`${e.top}px`)}function RE(){if(!this.showTextEdit)return;let[i,,e,t,r]=this.activeLine,n=na(this.textEditNode.innerHTML);n=n===this.mindMap.opt.defaultAssociativeLineText?"":n,this.mindMap.execCommand("SET_NODE_DATA",t,{associativeLineText:{...t.getData("associativeLineText")||{},[r.getData("uid")]:n}}),this.textEditNode.style.display="none",this.textEditNode.innerHTML="",this.setIsShowTextEdit(!1),this.renderText(n,i,e,t,r),this.mindMap.emit("hide_text_edit")}function DE(i,e){let t=i.getData("associativeLineText");return t&&t[e.getData("uid")]||""}function OE(i,e,t,r,n){if(!i)return;let{associativeLineTextFontSize:s,associativeLineTextLineHeight:a}=this.getStyleConfig(r,n);t.clear(),i.replace(/\n$/g,"").split(/\n/gim).forEach((l,h)=>{l===""&&(l="\uFEFF");let d=new Ce().text(l);d.y(s*a*h),this.styleText(d,r,n),t.add(d)}),x6(e,t)}function BE(i,e,t){let{associativeLineTextColor:r,associativeLineTextFontSize:n,associativeLineTextFontFamily:s}=this.getStyleConfig(e,t);i.fill({color:r}).css({"font-family":s,"font-size":n+"px"})}function x6(i,e){let t=i.length(),r=i.pointAt(t/2),{width:n,height:s}=e.bbox();e.x(r.x-n/2),e.y(r.y-s/2)}var AE,Vu,y6=T(()=>{yt();pe();AE="associative-line-text-edit-warp";Vu={getText:DE,createText:kE,styleText:BE,onScale:IE,showEditTextBox:CE,setIsShowTextEdit:_E,removeTextEditEl:LE,hideEditTextBox:RE,updateTextEditBoxPos:zE,renderText:OE,updateTextPos:x6}});var v6={};tt(v6,{default:()=>FE});var PE,Wu,nh,FE,b6=T(()=>{pe();Hc();ju();g6();y6();PE=["associativeLineWidth","associativeLineColor","associativeLineActiveWidth","associativeLineActiveColor","associativeLineDasharray","associativeLineTextColor","associativeLineTextFontSize","associativeLineTextLineHeight","associativeLineTextFontFamily"],Wu="associative-line-text-edit-warp",nh=class{constructor(e={}){this.mindMap=e.mindMap,this.associativeLineDraw=this.mindMap.associativeLineDraw,this.isNotRenderAllLines=!1,this.lineList=[],this.activeLine=null,this.isCreatingLine=!1,this.creatingStartNode=null,this.creatingLine=null,this.overlapNode=null,this.isNodeDragging=!1,this.controlLine1=null,this.controlLine2=null,this.controlPoint1=null,this.controlPoint2=null,this.controlPointDiameter=10,this.isControlPointMousedown=!1,this.mousedownControlPointKey="",this.controlPointMousemoveState={pos:null,startPoint:null,endPoint:null,targetIndex:""},this.checkOverlapNode=Si(this.checkOverlapNode,100,this),Object.keys(Gu).forEach(t=>{this[t]=Gu[t].bind(this)}),this.showTextEdit=!1,Object.keys(Vu).forEach(t=>{this[t]=Vu[t].bind(this)}),this.mindMap.addEditNodeClass(Wu),this.bindEvent()}bindEvent(){this.renderAllLines=this.renderAllLines.bind(this),this.onDrawClick=this.onDrawClick.bind(this),this.onNodeClick=this.onNodeClick.bind(this),this.removeLine=this.removeLine.bind(this),this.addLine=this.addLine.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onNodeDragging=this.onNodeDragging.bind(this),this.onNodeDragend=this.onNodeDragend.bind(this),this.onControlPointMouseup=this.onControlPointMouseup.bind(this),this.onBeforeDestroy=this.onBeforeDestroy.bind(this),this.mindMap.on("node_tree_render_end",this.renderAllLines),this.mindMap.on("data_change",this.renderAllLines),this.mindMap.on("draw_click",this.onDrawClick),this.mindMap.on("node_click",this.onNodeClick),this.mindMap.on("contextmenu",this.onDrawClick),this.mindMap.keyCommand.addShortcut("Del|Backspace",this.removeLine),this.mindMap.command.add("ADD_ASSOCIATIVE_LINE",this.addLine),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("node_dragging",this.onNodeDragging),this.mindMap.on("node_dragend",this.onNodeDragend),this.mindMap.on("mouseup",this.onControlPointMouseup),this.mindMap.on("scale",this.onScale),this.mindMap.on("beforeDestroy",this.onBeforeDestroy)}unBindEvent(){this.mindMap.off("node_tree_render_end",this.renderAllLines),this.mindMap.off("data_change",this.renderAllLines),this.mindMap.off("draw_click",this.onDrawClick),this.mindMap.off("node_click",this.onNodeClick),this.mindMap.off("contextmenu",this.onDrawClick),this.mindMap.keyCommand.removeShortcut("Del|Backspace",this.removeLine),this.mindMap.command.remove("ADD_ASSOCIATIVE_LINE",this.addLine),this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("node_dragging",this.onNodeDragging),this.mindMap.off("node_dragend",this.onNodeDragend),this.mindMap.off("mouseup",this.onControlPointMouseup),this.mindMap.off("scale",this.onScale),this.mindMap.off("beforeDestroy",this.onBeforeDestroy)}getStyleConfig(e,t){let r={};t&&(r=(e.getData("associativeLineStyle")||{})[t.getData("uid")]||{});let n={};return PE.forEach(s=>{typeof r[s]<"u"?n[s]=r[s]:n[s]=e.getStyle(s)}),n}onBeforeDestroy(){this.hideEditTextBox(),this.removeTextEditEl()}onDrawClick(){this.isCreatingLine&&this.cancelCreateLine(),this.isControlPointMousedown||(this.clearActiveLine(),this.renderAllLines())}onNodeClick(e){this.isCreatingLine?this.completeCreateLine(e):(this.clearActiveLine(),this.renderAllLines())}createMarker(e=()=>{}){return this.associativeLineDraw.marker(20,20,t=>{t.ref(12,5),t.size(10,10),t.attr("orient","auto-start-reverse"),e(t.path("M0,0 L2,5 L0,10 L10,5 Z"))})}updateAllLinesPos(e,t,r){r=r||{};let[n,s]=Uu(e,t),a=0,o="",l=0,h="";return r.startPoint&&(a=r.startPoint.range||0,o=r.startPoint.dir||"right",n=kr(e,o,a)),r.endPoint&&(l=r.endPoint.range||0,h=r.endPoint.dir||"right",s=kr(t,h,l)),[n,s]}renderAllLines(){if(this.isNotRenderAllLines){this.isNotRenderAllLines=!1;return}this.removeAllLines(),this.removeControls(),this.clearActiveLine();let e=this.mindMap.renderer.root;if(!e)return;let t=new Map,r=new Map;de(e,null,n=>{if(!n)return;let s=n.getData();s.associativeLineTargets&&s.associativeLineTargets.length>0&&r.set(n,s.associativeLineTargets),s.uid&&t.set(s.uid,n)},()=>{},!0,0),r.forEach((n,s)=>{n.forEach((a,o)=>{let l=t.get(a);if(!s||!l)return;let h=(s.getData("associativeLinePoint")||[])[o],[d,c]=this.updateAllLinesPos(s,l,h);this.drawLine(d,c,s,l)})})}drawLine(e,t,r,n){let{associativeLineWidth:s,associativeLineColor:a,associativeLineActiveWidth:o,associativeLineDasharray:l}=this.getStyleConfig(r,n),h=null,d=this.createMarker(y=>{h=y});h.stroke({color:a}).fill({color:a});let{path:c,controlPoints:f}=p6(e,t,r,n),m=this.associativeLineDraw.path();m.stroke({width:s,color:a,dasharray:l||"6,4"}).fill({color:"none"}),m.plot(c),m.marker("end",d);let g=this.associativeLineDraw.path();g.stroke({width:o,color:"transparent"}).fill({color:"none"}),g.plot(c);let x=this.createText({path:m,clickPath:g,markerPath:h,node:r,toNode:n,startPoint:e,endPoint:t,controlPoints:f});g.click(y=>{y.stopPropagation(),this.setActiveLine({path:m,clickPath:g,markerPath:h,text:x,node:r,toNode:n,startPoint:e,endPoint:t,controlPoints:f})}),g.dblclick(()=>{this.activeLine&&this.showEditTextBox(x)}),this.renderText(this.getText(r,n),m,x,r,n),this.lineList.push([m,g,x,r,n])}updateActiveLineStyle(){if(!this.activeLine)return;this.isNotRenderAllLines=!0;let[e,t,r,n,s,a]=this.activeLine,{associativeLineWidth:o,associativeLineColor:l,associativeLineDasharray:h,associativeLineActiveWidth:d,associativeLineActiveColor:c,associativeLineTextColor:f,associativeLineTextFontFamily:m,associativeLineTextFontSize:g}=this.getStyleConfig(n,s);e.stroke({width:o,color:l,dasharray:h||"6,4"}).fill({color:"none"}),t.stroke({width:d,color:c}).fill({color:"none"}),a.stroke({color:l}).fill({color:l}),r.find("text").forEach(x=>{x.fill({color:f}).css({"font-family":m,"font-size":g+"px"})}),this.controlLine1&&this.controlLine1.stroke({color:c}),this.controlLine2&&this.controlLine2.stroke({color:c}),this.controlPoint1&&this.controlPoint1.stroke({color:c}),this.controlPoint2&&this.controlPoint2.stroke({color:c}),this.updateTextPos(e,r)}setActiveLine({path:e,clickPath:t,markerPath:r,text:n,node:s,toNode:a,startPoint:o,endPoint:l,controlPoints:h}){let{associativeLineActiveColor:d}=this.getStyleConfig(s,a);this.mindMap.execCommand("CLEAR_ACTIVE_NODE"),this.clearActiveLine(),this.activeLine=[e,t,n,s,a,r],t.stroke({color:d}),this.getText(s,a)||this.renderText(this.mindMap.opt.defaultAssociativeLineText,e,n,s,a),this.renderControls(o,l,h[0],h[1],s,a),this.mindMap.emit("associative_line_click",e,t,s,a),this.front()}removeAllLines(){this.lineList.forEach(e=>{e[0].remove(),e[1].remove(),e[2].remove()}),this.lineList=[]}createLineFromActiveNode(){if(this.mindMap.renderer.activeNodeList.length<=0)return;let e=this.mindMap.renderer.activeNodeList[0];this.createLine(e)}createLine(e){let{associativeLineWidth:t,associativeLineColor:r,associativeLineDasharray:n}=this.getStyleConfig(e);if(this.isCreatingLine||!e)return;this.front(),this.isCreatingLine=!0,this.creatingStartNode=e,this.creatingLine=this.associativeLineDraw.path(),this.creatingLine.stroke({width:t,color:r,dasharray:n||"6,4"}).fill({color:"none"});let s=null,a=this.createMarker(o=>{s=o});s.stroke({color:r}).fill({color:r}),this.creatingLine.marker("end",a)}cancelCreateLine(){this.isCreatingLine=!1,this.creatingStartNode=null,this.creatingLine.remove(),this.creatingLine=null,this.overlapNode=null,this.back()}onMousemove(e){this.onControlPointMousemove(e),this.updateCreatingLine(e)}updateCreatingLine(e){if(!this.isCreatingLine)return;let{x:t,y:r}=this.getTransformedEventPos(e),n=kr(this.creatingStartNode),s=t>n.x?-10:10,a=m6(n.x,n.y,t+s,r);this.creatingLine.plot(a),this.checkOverlapNode(t,r)}getTransformedEventPos(e){let{x:t,y:r}=this.mindMap.toPos(e.clientX,e.clientY),{scaleX:n,scaleY:s,translateX:a,translateY:o}=this.mindMap.draw.transform();return{x:(t-a)/n,y:(r-o)/s}}getNodePos(e){let{scaleX:t,scaleY:r,translateX:n,translateY:s}=this.mindMap.draw.transform(),{left:a,top:o,width:l,height:h}=e,d=a*t+n,c=o*r+s;return{left:a,top:o,translateLeft:d,translateTop:c,width:l,height:h}}checkOverlapNode(e,t){this.overlapNode=null,Xt(this.mindMap.renderer.root,r=>{if(r.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",r,!1),r.uid===this.creatingStartNode.uid||this.overlapNode)return;let{left:n,top:s,width:a,height:o}=r,l=n+a,h=s+o;e>=n&&e<=l&&t>=s&&t<=h&&(this.overlapNode=r)}),this.overlapNode&&!this.overlapNode.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!0)}completeCreateLine(e){if(this.creatingStartNode.uid===e.uid)return;let{beforeAssociativeLineConnection:t}=this.mindMap.opt,r=!1;typeof t=="function"&&(r=t(e)),!r&&(this.addLine(this.creatingStartNode,e),this.overlapNode&&this.overlapNode.getData("isActive")&&this.mindMap.execCommand("SET_NODE_ACTIVE",this.overlapNode,!1),this.cancelCreateLine())}addLine(e,t){if(!e||!t)return;let r=t.getData("uid");r||(r=fo(),this.mindMap.execCommand("SET_NODE_DATA",t,{uid:r}));let n=e.getData("associativeLineTargets")||[];if(n.some(f=>f===r))return;n.push(r);let[a,o]=Uu(e,t),l=Vo(a.x,a.y,o.x,o.y),{associativeLineInitPointsPosition:h}=this.mindMap.opt;if(h){let{from:f,to:m}=h;f&&(a.dir=f),m&&(o.dir=m)}let d=e.getData("associativeLineTargetControlOffsets")||[];d[n.length-1]=[{x:l[0].x-a.x,y:l[0].y-a.y},{x:l[1].x-o.x,y:l[1].y-o.y}];let c=e.getData("associativeLinePoint")||[];c[n.length-1]={startPoint:a,endPoint:o},this.mindMap.execCommand("SET_NODE_DATA",e,{associativeLineTargets:n,associativeLineTargetControlOffsets:d,associativeLinePoint:c})}removeLine(){if(!this.activeLine)return;let[,,,e,t]=this.activeLine;this.removeControls();let{associativeLineTargets:r,associativeLinePoint:n,associativeLineTargetControlOffsets:s,associativeLineText:a,associativeLineStyle:o}=e.getData();n=n||[];let l=Go(e,t),h={};a&&Object.keys(a).forEach(c=>{c!==t.getData("uid")&&(h[c]=a[c])});let d={};o&&Object.keys(o).forEach(c=>{c!==t.getData("uid")&&(d[c]=o[c])}),this.mindMap.execCommand("SET_NODE_DATA",e,{associativeLineTargets:r.filter((c,f)=>f!==l),associativeLinePoint:n.filter((c,f)=>f!==l),associativeLineTargetControlOffsets:s?s.filter((c,f)=>f!==l):[],associativeLineText:h,associativeLineStyle:d})}clearActiveLine(){if(this.activeLine){let[,e,t,r,n]=this.activeLine;e.stroke({color:"transparent"}),this.hideEditTextBox(),this.getText(r,n)||t.clear(),this.activeLine=null,this.removeControls(),this.back(),this.mindMap.emit("associative_line_deactivate")}}onNodeDragging(){this.isNodeDragging||(this.isNodeDragging=!0,this.lineList.forEach(e=>{e[0].hide(),e[1].hide(),e[2].hide()}),this.hideControls())}onNodeDragend(){this.isNodeDragging&&(this.lineList.forEach(e=>{e[0].show(),e[1].show(),e[2].show()}),this.showControls(),this.isNodeDragging=!1)}front(){this.mindMap.opt.associativeLineIsAlwaysAboveNode||this.associativeLineDraw.front()}back(){this.mindMap.opt.associativeLineIsAlwaysAboveNode||(this.associativeLineDraw.back(),this.associativeLineDraw.forward())}beforePluginRemove(){this.mindMap.deleteEditNodeClass(Wu),this.unBindEvent()}beforePluginDestroy(){this.mindMap.deleteEditNodeClass(Wu),this.unBindEvent()}};nh.instanceName="associativeLine";FE=nh});var w6={};tt(w6,{default:()=>qE});var sh,qE,M6=T(()=>{pe();X0();$e();sh=class{constructor({mindMap:e}){this.mindMap=e,this.isSearching=!1,this.searchText="",this.matchNodeList=[],this.currentIndex=-1,this.notResetSearchText=!1,this.isJumpNext=!1,this.bindEvent()}bindEvent(){this.onDataChange=this.onDataChange.bind(this),this.onModeChange=this.onModeChange.bind(this),this.mindMap.on("data_change",this.onDataChange),this.mindMap.on("mode_change",this.onModeChange)}unBindEvent(){this.mindMap.off("data_change",this.onDataChange),this.mindMap.off("mode_change",this.onModeChange)}onDataChange(){if(this.isJumpNext){this.isJumpNext=!1,this.search(this.searchText);return}if(this.notResetSearchText){this.notResetSearchText=!1;return}this.searchText=""}onModeChange(e){!(e===k.MODE.READONLY)&&this.isSearching&&this.matchNodeList[this.currentIndex]&&this.matchNodeList[this.currentIndex].closeHighlight()}search(e,t=()=>{}){if(Yt(e))return this.endSearch();e=String(e),this.isSearching=!0,this.searchText===e?this.searchNext(t):(this.searchText=e,this.doSearch(),this.searchNext(t)),this.emitEvent()}updateMatchNodeList(e){this.matchNodeList=e,this.mindMap.emit("search_match_node_list_change",e)}endSearch(){this.isSearching&&(this.mindMap.opt.readonly&&this.matchNodeList[this.currentIndex]&&this.matchNodeList[this.currentIndex].closeHighlight(),this.searchText="",this.updateMatchNodeList([]),this.currentIndex=-1,this.notResetSearchText=!1,this.isSearching=!1,this.emitEvent())}doSearch(){this.clearHighlightOnReadonly(),this.updateMatchNodeList([]),this.currentIndex=-1;let{isOnlySearchCurrentRenderNodes:e}=this.mindMap.opt,t=e?this.mindMap.renderer.root:this.mindMap.renderer.renderTree;if(!t)return;let r=[];Xt(t,n=>{let{richText:s,text:a,generalization:o}=e?n.getData():n.data;s&&(a=sa(a)),a.includes(this.searchText)&&r.push(n),us({generalization:o}).forEach(h=>{let{richText:d,text:c,uid:f}=h;e&&!this.mindMap.renderer.findNodeByUid(f)||(d&&(c=sa(c)),c.includes(this.searchText)&&r.push({data:h}))})}),this.updateMatchNodeList(r)}isNodeInstance(e){return e instanceof da}searchNext(e,t){if(!this.isSearching||this.matchNodeList.length<=0)return;t!==void 0&&Number.isInteger(t)&&t>=0&&t{this.isNodeInstance(n)||(this.matchNodeList[this.currentIndex]=o,this.updateMatchNodeList(this.matchNodeList)),e(),r&&o.highlight(),a&&(this.notResetSearchText=!1)})}clearHighlightOnReadonly(){let{readonly:e}=this.mindMap.opt;e&&this.matchNodeList.forEach(t=>{this.isNodeInstance(t)&&t.closeHighlight()})}jump(e,t=()=>{}){this.searchNext(t,e)}replace(e,t=!1){if(e==null||!this.isSearching||this.matchNodeList.length<=0)return;this.isJumpNext=t,e=String(e);let r=this.matchNodeList[this.currentIndex];if(!r)return;let n=e.includes(this.searchText),s=this.getReplacedText(r,this.searchText,e);if(this.notResetSearchText=!0,r.setText(s,r.getData("richText")),n){this.updateMatchNodeList(this.matchNodeList);return}let a=this.matchNodeList.filter(o=>r!==o);this.updateMatchNodeList(a),this.currentIndex>this.matchNodeList.length-1?this.currentIndex=-1:this.currentIndex--,this.emitEvent()}replaceAll(e){if(e==null||!this.isSearching||this.matchNodeList.length<=0)return;e=String(e);let t=e.includes(this.searchText);this.notResetSearchText=!0,this.matchNodeList.forEach(r=>{let n=this.getReplacedText(r,this.searchText,e);if(this.isNodeInstance(r)){let s={text:n};this.mindMap.renderer.setNodeDataRender(r,s,!0)}else r.data.text=n}),this.mindMap.render(),this.mindMap.command.addHistory(),t?this.updateMatchNodeList(this.matchNodeList):this.endSearch()}getReplacedText(e,t,r){let{richText:n,text:s}=this.isNodeInstance(e)?e.getData():e.data;return n?M2(s,t,r):s.replace(new RegExp(t,"g"),r)}emitEvent(){this.mindMap.emit("search_info_change",{currentIndex:this.currentIndex,total:this.matchNodeList.length})}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};sh.instanceName="search";qE=sh});var T6,N6,E6=T(()=>{pe();T6=i=>{i=ds(i);let e={},t={};i.forEach(n=>{let s=n.parent;if(s){let a=s.uid;t[a]=s;let o=n.getIndexInBrothers(),l={node:n,index:o};e[a]?e[a].find(h=>h.index===l.index)||e[a].push(l):e[a]=[l]}});let r=[];return Object.keys(e).forEach(n=>{let s=e[n],a=t[n];if(s.length>1){let o=s.map(f=>f.index).sort((f,m)=>f-m),l=o[0],h=o[o.length-1],d=-1,c=-1;for(let f=l;f<=h;f++)o.includes(f)?(d===-1&&(d=f),c=f):(d!==-1&&c!==-1&&r.push({node:a,range:[d,c]}),d=-1,c=-1);d!==-1&&c!==-1&&r.push({node:a,range:[d,c]})}else r.push({node:a,range:[s[0].index,s[0].index]})}),r},N6=i=>{let e=i.children;if(!e||e.length<=0)return;let t=[],r={};return e.forEach((n,s)=>{let a=n.getData("outerFrame");if(!a)return;let o=a.groupId;o?(r[o]||(r[o]=[]),r[o].push({node:n,index:s})):t.push({nodeList:[n],range:[s,s]})}),Object.keys(r).forEach(n=>{let s=r[n];t.push({nodeList:s.map(a=>a.node),range:[s[0].index,s[s.length-1].index]})}),t}});function UE(i,e,t){let r=this.draw.group(),n=()=>{(!this.activeOuterFrame||this.activeOuterFrame.el!==i)&&this.setActiveOuterFrame(i,e,t,r)};return r.click(s=>{s.stopPropagation(),n()}),r.on("dblclick",s=>{s.stopPropagation(),n(),this.showEditTextBox(r)}),r}function $E(i){this.mindMap.emit("before_show_text_edit"),this.mindMap.keyCommand.addShortcut("Enter",()=>{this.hideEditTextBox()}),this.textEditNode||(this.textEditNode=document.createElement("div"),this.textEditNode.className=HE,this.textEditNode.style.cssText=` position: fixed; box-sizing: border-box; background-color: #fff; box-shadow: 0 0 20px rgba(0,0,0,.5); - outline: none; + outline: none; word-break: break-all; - `,this.textEditNode.setAttribute("contenteditable",!0),this.textEditNode.addEventListener("keyup",g=>{g.stopPropagation()}),this.textEditNode.addEventListener("click",g=>{g.stopPropagation()}),(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.textEditNode));let{node:e,range:t}=this.activeOuterFrame,r=this.getStyle(this.getNodeRangeFirstNode(e,t)),[n,s,a,o]=r.textFillPadding,{defaultOuterFrameText:l,nodeTextEditZIndex:h}=this.mindMap.opt,d=this.mindMap.view.scale,c=this.getText(this.getNodeRangeFirstNode(e,t)),f=(c||l).split(/\n/gim);this.textEditNode.style.padding=`${n}px ${s}px ${a}px ${o}px`,this.textEditNode.style.fontFamily=r.fontFamily,this.textEditNode.style.fontSize=r.fontSize*d+"px",this.textEditNode.style.fontWeight=r.fontWeight,this.textEditNode.style.fontStyle=r.fontStyle,this.textEditNode.style.lineHeight=f.length>1?r.lineHeight:"normal",this.textEditNode.style.zIndex=h,this.textEditNode.innerHTML=f.join("
    "),this.textEditNode.style.display="block",this.updateTextEditBoxPos(i),this.setIsShowTextEdit(!0),c===""||c===l?Ls(this.textEditNode):_s(this.textEditNode)}function CT(i){this.showTextEdit=i,i?this.mindMap.keyCommand.stopCheckInSvg():this.mindMap.keyCommand.recoveryCheckInSvg()}function _T(){if(!this.textEditNode)return;(this.mindMap.opt.customInnerElsAppendTo||document.body).removeChild(this.textEditNode)}function LT(){this.hideEditTextBox()}function zT(i){let e=i.node.getBoundingClientRect();this.textEditNode&&(this.textEditNode.style.minWidth=`${e.width}px`,this.textEditNode.style.minHeight=`${e.height}px`,this.textEditNode.style.left=`${e.left}px`,this.textEditNode.style.top=`${e.top}px`)}function IT(){if(!this.showTextEdit)return;let{el:i,textNode:e,node:t,range:r}=this.activeOuterFrame,n=As(this.textEditNode.innerHTML);n=n===this.mindMap.opt.defaultOuterFrameText?"":n,this.updateActiveOuterFrame({text:n}),this.textEditNode.style.display="none",this.textEditNode.innerHTML="",this.setIsShowTextEdit(!1),this.renderText(n,i,e,t,r),this.mindMap.emit("hide_text_edit")}function RT(i,e,t,r,n){if(!i)return;t.clear();let s=new Pe;t.add(s);let a=this.getStyle(this.getNodeRangeFirstNode(r,n)),[o,l,h,d]=a.textFillPadding,c=i.replace(/\n$/g,"").split(/\n/gim),f=new Ne;c.forEach((S,C)=>{S===""&&(S="\uFEFF");let _=new Te().text(S);_.y(a.fontSize*a.lineHeight*C),this.styleText(_,a),f.add(_)}),t.add(f);let{width:m,height:g}=t.bbox(),x=m+o+h,v=g+l+d;s.size(x,v).x(0).dy(0),this.styleTextShape(s,a);let b=0;switch(a.textAlign){case"left":b=e.x();break;case"center":b=e.x()+e.width()/2-x/2;break;case"right":b=e.x()+e.width()-x;break;default:break}let E=e.y()-v;s.x(b),s.y(E),f.x(b+o),f.y(E+l)}function DT(i,e){i.fill({color:e.textFill}).radius(e.textFillRadius)}function OT(i,e){i.fill({color:e.color}).css({"font-family":e.fontFamily,"font-size":e.fontSize+"px","font-weight":e.fontWeight,"font-style":e.fontStyle})}function BT(i){let e=i.getData("outerFrame");return e&&e.text?e.text:""}var ST,Wc,W3=M(()=>{ht();he();ST="outer-frame-text-edit-warp";Wc={getText:BT,createText:AT,styleTextShape:DT,styleText:OT,onScale:LT,showEditTextBox:kT,setIsShowTextEdit:CT,removeTextEditEl:_T,hideEditTextBox:IT,updateTextEditBoxPos:zT,renderText:RT}});var V3={};ti(V3,{default:()=>PT});var Xc,Vc,go,PT,X3=M(()=>{he();Y3();W3();Xc={radius:5,strokeWidth:2,strokeColor:"#0984e3",strokeDasharray:"5,5",fill:"rgba(9,132,227,0.05)",fontSize:14,fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",fontWeight:"normal",fontStyle:"normal",color:"#fff",lineHeight:1.2,textFill:"#0984e3",textFillRadius:5,textFillPadding:[5,5,5,5],textAlign:"left"},Vc="outer-frame-text-edit-warp",go=class{constructor(e={}){this.mindMap=e.mindMap,this.draw=null,this.createDrawContainer(),this.isNotRenderOuterFrames=!1,this.textNodeList=[],this.outerFrameElList=[],this.activeOuterFrame=null,this.textEditNode=null,this.showTextEdit=!1,Object.keys(Wc).forEach(t=>{this[t]=Wc[t].bind(this)}),this.mindMap.addEditNodeClass(Vc),this.bindEvent()}createDrawContainer(){this.draw=this.mindMap.draw.group(),this.draw.addClass("smm-outer-frame-container"),this.draw.back(),this.draw.forward()}bindEvent(){this.renderOuterFrames=this.renderOuterFrames.bind(this),this.mindMap.on("node_tree_render_end",this.renderOuterFrames),this.mindMap.on("data_change",this.renderOuterFrames),this.clearActiveOuterFrame=this.clearActiveOuterFrame.bind(this),this.mindMap.on("draw_click",this.clearActiveOuterFrame),this.mindMap.on("node_click",this.clearActiveOuterFrame),this.mindMap.on("scale",this.onScale),this.onBeforeDestroy=this.onBeforeDestroy.bind(this),this.mindMap.on("beforeDestroy",this.onBeforeDestroy),this.addOuterFrame=this.addOuterFrame.bind(this),this.mindMap.command.add("ADD_OUTER_FRAME",this.addOuterFrame),this.removeActiveOuterFrame=this.removeActiveOuterFrame.bind(this),this.mindMap.keyCommand.addShortcut("Del|Backspace",this.removeActiveOuterFrame)}unBindEvent(){this.mindMap.off("node_tree_render_end",this.renderOuterFrames),this.mindMap.off("data_change",this.renderOuterFrames),this.mindMap.off("draw_click",this.clearActiveOuterFrame),this.mindMap.off("node_click",this.clearActiveOuterFrame),this.mindMap.off("scale",this.onScale),this.mindMap.off("beforeDestroy",this.onBeforeDestroy),this.mindMap.command.remove("ADD_OUTER_FRAME",this.addOuterFrame),this.mindMap.keyCommand.removeShortcut("Del|Backspace",this.removeActiveOuterFrame)}onBeforeDestroy(){this.hideEditTextBox(),this.removeTextEditEl()}addOuterFrame(e,t={}){e=Nt(e);let r=this.mindMap.renderer.activeNodeList;if(r.length<=0&&e.length<=0)return;let n=e.length>0?e:r;n=n.filter(a=>!a.isRoot&&!a.isGeneralization),j3(n).forEach(({node:a,range:o})=>{let l=a.children.slice(o[0],o[1]+1),h=ct();l.forEach(d=>{let c=d.getData("outerFrame");c?c={...c,...t,groupId:h}:c={...t,groupId:h},this.mindMap.execCommand("SET_NODE_DATA",d,{outerFrame:c})})})}getActiveOuterFrame(){return this.activeOuterFrame?{...this.activeOuterFrame}:null}removeActiveOuterFrame(){if(!this.activeOuterFrame)return;let{node:e,range:t}=this.activeOuterFrame;this.getRangeNodeList(e,t).forEach(r=>{this.mindMap.execCommand("SET_NODE_DATA",r,{outerFrame:null})}),this.mindMap.emit("outer_frame_delete")}removeActiveOuterFrameText(){this.updateActiveOuterFrame({text:""})}updateActiveOuterFrame(e={}){if(!this.activeOuterFrame)return;this.isNotRenderOuterFrames=!0;let{el:t,node:r,range:n}=this.activeOuterFrame,s="";this.getRangeNodeList(r,n).forEach(a=>{let l={...a.getData("outerFrame"),...e};s=l.strokeDasharray,this.mindMap.execCommand("SET_NODE_DATA",a,{outerFrame:l})}),t.cacheStyle={dasharray:s},this.updateOuterFrameStyle()}updateOuterFrameStyle(){let{el:e,node:t,range:r,textNode:n}=this.activeOuterFrame,s=this.getNodeRangeFirstNode(t,r),a=this.getStyle(s);this.styleOuterFrame(e,{...a,strokeDasharray:"none"});let o=this.getText(s);this.renderText(o,e,n,t,r)}getRangeNodeList(e,t){return e.children.slice(t[0],t[1]+1).filter(r=>r.getData("outerFrame"))}getNodeRangeFirstNode(e,t){return e.children[t[0]]}renderOuterFrames(){if(this.isNotRenderOuterFrames){this.isNotRenderOuterFrames=!1;return}this.clearActiveOuterFrame(),this.clearTextNodes(),this.clearOuterFrameElList();let e=this.mindMap.renderer.root;if(!e)return;let t=this.mindMap.draw.transform(),{outerFramePaddingX:r,outerFramePaddingY:n}=this.mindMap.opt;se(e,null,s=>{if(!s)return;let a=G3(s);a&&a.length>0&&a.forEach(({nodeList:o,range:l})=>{if(l[0]===-1||l[1]===-1)return;let{left:h,top:d,width:c,height:f}=i3(o);if(!Number.isFinite(h)||!Number.isFinite(d)||!Number.isFinite(c)||!Number.isFinite(f))return;let m=this.createOuterFrameEl((h-r-this.mindMap.elRect.left-t.translateX)/t.scaleX,(d-n-this.mindMap.elRect.top-t.translateY)/t.scaleY,(c+r*2)/t.scaleX,(f+n*2)/t.scaleY,this.getStyle(o[0])),g=this.createText(m,s,l);this.textNodeList.push(g),this.renderText(this.getText(o[0]),m,g,s,l),m.on("click",x=>{x.stopPropagation(),this.setActiveOuterFrame(m,s,l,g)})})},()=>{},!0,0)}setActiveOuterFrame(e,t,r,n){this.mindMap.execCommand("CLEAR_ACTIVE_NODE"),this.clearActiveOuterFrame(),this.activeOuterFrame={el:e,node:t,range:r,textNode:n},e.stroke({dasharray:"none"}),this.getText(this.getNodeRangeFirstNode(t,r))||this.renderText(this.mindMap.opt.defaultOuterFrameText,e,n,t,r),this.mindMap.emit("outer_frame_active",e,t,r)}clearActiveOuterFrame(){if(!this.activeOuterFrame)return;let{el:e,textNode:t,node:r,range:n}=this.activeOuterFrame;e.stroke({dasharray:e.cacheStyle.dasharray||Xc.strokeDasharray}),this.hideEditTextBox(),this.getText(this.getNodeRangeFirstNode(r,n))||t.clear(),this.activeOuterFrame=null,this.mindMap.emit("outer_frame_deactivate")}getStyle(e){return{...Xc,...e.getData("outerFrame")||{}}}createOuterFrameEl(e,t,r,n,s={}){let a=this.draw.rect().size(r,n).x(e).y(t);return this.styleOuterFrame(a,s),a.cacheStyle={dasharray:s.strokeDasharray},this.outerFrameElList.push(a),a}styleOuterFrame(e,t){e.radius(t.radius).stroke({width:t.strokeWidth,color:t.strokeColor,dasharray:t.strokeDasharray}).fill({color:t.fill})}clearTextNodes(){this.textNodeList.forEach(e=>{e.remove()})}clearOuterFrameElList(){this.outerFrameElList.forEach(e=>{e.remove()}),this.outerFrameElList=[],this.activeOuterFrame=null}beforePluginRemove(){this.mindMap.deleteEditNodeClass(Vc),this.unBindEvent()}beforePluginDestroy(){this.mindMap.deleteEditNodeClass(Vc),this.unBindEvent()}};go.instanceName="outerFrame";go.defaultStyle=Xc;PT=go});var K3={};ti(K3,{default:()=>FT});var x0,FT,Z3=M(()=>{he();Oe();x0=class{constructor(e){this.mindMap=e.mindMap,this.scrollbarWrapSize={width:0,height:0},this.chartHeight=0,this.chartWidth=0,this.reset(),this.bindEvent()}reset(){this.currentScrollType="",this.isMousedown=!1,this.mousedownPos={x:0,y:0},this.mousedownScrollbarPos=0}bindEvent(){this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.updateScrollbar=this.updateScrollbar.bind(this),this.updateScrollbar=mi(this.updateScrollbar,16,this),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("mouseup",this.onMouseup),this.mindMap.on("node_tree_render_end",this.updateScrollbar),this.mindMap.on("view_data_change",this.updateScrollbar),this.mindMap.on("resize",this.updateScrollbar)}unBindEvent(){this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("mouseup",this.onMouseup),this.mindMap.off("node_tree_render_end",this.updateScrollbar),this.mindMap.off("view_data_change",this.updateScrollbar),this.mindMap.off("resize",this.updateScrollbar)}updateScrollbar(){if(this.isMousedown)return;let e=this.calculationScrollbar();this.emitEvent(e)}emitEvent(e){this.mindMap.emit("scrollbar_change",e)}setScrollBarWrapSize(e,t){this.scrollbarWrapSize.width=e,this.scrollbarWrapSize.height=t}calculationScrollbar(){let e=this.mindMap.draw.rbox(),t=this.mindMap.elRect;e.x-=t.left,e.y-=t.top;let r=this.mindMap.height,n=r/2,s=e.height+n*2;this.chartHeight=s;let a=e.y-n,o=Math.min(r/s*100,100),l=-a/s*100;l<0&&(l=0),l>100-o&&(l=100-o);let h=this.mindMap.width,d=h/2,c=e.width+d*2;this.chartWidth=c;let f=e.x-d,m=Math.min(h/c*100,100),g=-f/c*100;return g<0&&(g=0),g>100-m&&(g=100-m),{vertical:{top:l,height:o},horizontal:{left:g,width:m}}}onMousedown(e,t){e.preventDefault(),e.stopPropagation(),this.currentScrollType=t,this.isMousedown=!0,this.mousedownPos={x:e.clientX,y:e.clientY};let r=window.getComputedStyle(e.target);t===A.SCROLL_BAR_DIR.VERTICAL?this.mousedownScrollbarPos=Number.parseFloat(r.top):this.mousedownScrollbarPos=Number.parseFloat(r.left)}onMousemove(e){if(this.isMousedown)if(e.preventDefault(),e.stopPropagation(),this.currentScrollType===A.SCROLL_BAR_DIR.VERTICAL){let t=e.clientY-this.mousedownPos.y+this.mousedownScrollbarPos;this.updateMindMapView(A.SCROLL_BAR_DIR.VERTICAL,t)}else{let t=e.clientX-this.mousedownPos.x+this.mousedownScrollbarPos;this.updateMindMapView(A.SCROLL_BAR_DIR.HORIZONTAL,t)}}onMouseup(){this.isMousedown=!1,this.reset()}updateMindMapView(e,t){let r=this.calculationScrollbar(),n=this.mindMap.draw.transform(),s=this.mindMap.draw.rbox(),a=this.mindMap.renderer.root.group.rbox(),o=this.mindMap.renderer.layout.getRootCenterOffset(a.width,a.height);if(e===A.SCROLL_BAR_DIR.VERTICAL){let l=t;l<=0&&(l=0);let h=(100-r.vertical.height)/100*this.scrollbarWrapSize.height;l>=h&&(l=h);let d=l/this.scrollbarWrapSize.height*100,c=-d/100*this.chartHeight,f=a.y-s.y,m=this.mindMap.height/2,g=c+f-m*n.scaleY+m-o.y*n.scaleY+(this.mindMap.height-this.mindMap.initHeight)/2*n.scaleY;this.mindMap.view.translateYTo(g),this.emitEvent({horizontal:r.horizontal,vertical:{top:d,height:r.vertical.height}})}else{let l=t;l<=0&&(l=0);let h=(100-r.horizontal.width)/100*this.scrollbarWrapSize.width;l>=h&&(l=h);let d=l/this.scrollbarWrapSize.width*100,c=-d/100*this.chartWidth,f=a.x-s.x,m=this.mindMap.width/2,g=c+f-m*n.scaleX+m-o.x*n.scaleX+(this.mindMap.width-this.mindMap.initWidth)/2*n.scaleX;this.mindMap.view.translateXTo(g),this.emitEvent({vertical:r.vertical,horizontal:{left:d,width:r.horizontal.width}})}}onClick(e,t){let r=0;t===A.SCROLL_BAR_DIR.VERTICAL?r=e.clientY-e.currentTarget.getBoundingClientRect().top:r=e.clientX-e.currentTarget.getBoundingClientRect().left,this.updateMindMapView(t,r)}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};x0.instanceName="scrollbar";FT=x0});var Q3={};ti(Q3,{default:()=>qT});var v0,qT,J3=M(()=>{he();v0=class{constructor(e){this.mindMap=e.mindMap,this.isMousedown=!1,this.mousedownPos={x:0,y:0},this.startViewPos={x:0,y:0},this.currentState=null}calculationMiniMap(e,t){let{svg:r,rect:n,origWidth:s,origHeight:a,scaleX:o,scaleY:l}=this.mindMap.getSvgData({ignoreWatermark:!0}),h=this.mindMap.elRect;n.x-=h.left,n.x2-=h.left,n.y-=h.top,n.y2-=h.top;let d=e/t,c=0,f=0;d>n.ratio?(f=t,c=n.ratio*f):(c=e,f=c/n.ratio);let m=c/n.width,g=(e-c)/2,x=(t-f)/2,v=n.width*o,b=n.height*l,E=(v-n.width)/2,S=(b-n.height)/2,C=n.x-E,_=n.x2+E,I=n.y-S,O=n.y2+S,D={left:0,top:0,right:0,bottom:0};D.left=Math.max(0,-C/v*c)+g,D.right=Math.max(0,(_-s)/v*c)+g,D.top=Math.max(0,-I/b*f)+x,D.bottom=Math.max(0,(O-a)/b*f)+x,D.top>x+f&&(D.top=x+f),D.left>g+c&&(D.left=g+c),Object.keys(D).forEach(F=>{D[F]=D[F]+"px"}),this.removeNodeContent(r);let $=r.svg();return this.currentState={viewBoxStyle:{...D},miniMapBoxScale:m,miniMapBoxLeft:g,miniMapBoxTop:x},{getImgUrl:async F=>{let Z=await this.mindMap.doExport.fixSvgStrAndToBlob($);F(Z)},svgHTML:$,viewBoxStyle:D,miniMapBoxScale:m,miniMapBoxLeft:g,miniMapBoxTop:x}}removeNodeContent(e){if(e.hasClass("smm-node")){let r=e.findOne(".smm-node-shape"),n=r.attr("fill");(no(n)||fc(n))&&r.attr("fill",e0(this.mindMap.themeConfig)),e.clear(),e.add(r);return}let t=e.children();t&&t.length>0&&t.forEach(r=>{this.removeNodeContent(r)})}onMousedown(e){this.isMousedown=!0,this.mousedownPos={x:e.clientX,y:e.clientY};let t=this.mindMap.view.getTransformData();this.startViewPos={x:t.state.x,y:t.state.y}}onMousemove(e,t=5){if(!this.isMousedown||this.isViewBoxMousedown)return;let r=e.clientX-this.mousedownPos.x,n=e.clientY-this.mousedownPos.y;this.mindMap.view.translateXTo(r*t+this.startViewPos.x),this.mindMap.view.translateYTo(n*t+this.startViewPos.y)}onMouseup(){this.isMousedown=!1,this.isViewBoxMousedown=!1}onViewBoxMousedown(e){this.isViewBoxMousedown=!0,this.mousedownPos={x:e.clientX,y:e.clientY};let t=this.mindMap.view.getTransformData();this.startViewPos={x:t.state.x,y:t.state.y}}onViewBoxMousemove(e){if(!this.isViewBoxMousedown||!this.currentState||this.isMousedown)return;let t=e.clientX-this.mousedownPos.x,r=e.clientY-this.mousedownPos.y,{viewBoxStyle:n,miniMapBoxScale:s,miniMapBoxLeft:a,miniMapBoxTop:o}=this.currentState,l=Math.max(a,Number.parseFloat(n.left)+t),h=Math.max(a,Number.parseFloat(n.right)-t),d=Math.max(o,Number.parseFloat(n.top)+r),c=Math.max(o,Number.parseFloat(n.bottom)-r);this.mindMap.emit("mini_map_view_box_position_change",{left:l+"px",right:h+"px",top:d+"px",bottom:c+"px"}),this.mindMap.view.translateXTo(-t/s+this.startViewPos.x),this.mindMap.view.translateYTo(-r/s+this.startViewPos.y)}};v0.instanceName="miniMap";qT=v0});var e2={};ti(e2,{default:()=>HT});var y0,HT,t2=M(()=>{he();y0=class{constructor({mindMap:e}){this.mindMap=e,this.isInPainter=!1,this.painterNode=null,this.bindEvent()}bindEvent(){this.painterOneNode=this.painterOneNode.bind(this),this.onEndPainter=this.onEndPainter.bind(this),this.mindMap.on("node_click",this.painterOneNode),this.mindMap.on("draw_click",this.onEndPainter)}unBindEvent(){this.mindMap.off("node_click",this.painterOneNode),this.mindMap.off("draw_click",this.onEndPainter)}startPainter(){if(this.mindMap.opt.readonly)return;let e=this.mindMap.renderer.activeNodeList;e.length<=0||(this.painterNode=e[0],this.isInPainter=!0,this.mindMap.emit("painter_start"))}endPainter(){this.painterNode=null,this.isInPainter=!1}onEndPainter(){this.isInPainter&&(this.endPainter(),this.mindMap.emit("painter_end"))}painterOneNode(e){if(!e||!this.isInPainter||!this.painterNode||!e||e.uid===this.painterNode.uid)return;let t={};this.mindMap.opt.onlyPainterNodeCustomStyles||(t={...this.painterNode.effectiveStyles});let r=this.painterNode.getData();Object.keys(r).forEach(n=>{Pn(n)&&(t[n]=r[n])}),this.mindMap.renderer._handleRemoveCustomStyles(e.getData()),e.setStyles(t)}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};y0.instanceName="painter";HT=y0});function WT(i){return String(i).replace(YT,e=>GT[e])}function ZT(i){if(i.default)return i.default;var e=i.type,t=Array.isArray(e)?e[0]:e;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}function nN(i){for(var e=0;e=n[0]&&i<=n[1])return t.name}return null}function R2(i){for(var e=0;e=z0[e]&&i<=z0[e+1])return!0;return!1}function pN(i,e){Yi[i]=e}function Mu(i,e,t){if(!Yi[e])throw new Error("Font metrics not found for font: "+e+".");var r=i.charCodeAt(0),n=Yi[e][r];if(!n&&i[0]in r2&&(r=r2[i[0]].charCodeAt(0),n=Yi[e][r]),!n&&t==="text"&&R2(r)&&(n=Yi[e][77]),n)return{depth:n[0],height:n[1],italic:n[2],skew:n[3],width:n[4]}}function gN(i){var e;if(i>=5?e=0:i>=3?e=1:e=2,!Kc[e]){var t=Kc[e]={cssEmPerMu:b0.quad[e]/18};for(var r in b0)b0.hasOwnProperty(r)&&(t[r]=b0[r][e])}return Kc[e]}function a2(i){if(i instanceof $t)return i;throw new Error("Expected symbolNode but got "+String(i)+".")}function wN(i){if(i instanceof jn)return i;throw new Error("Expected span but got "+String(i)+".")}function u(i,e,t,r,n,s){Ce[i][n]={font:e,group:t,replace:r},s&&r&&(Ce[i][r]=Ce[i][n])}function X(i){for(var{type:e,names:t,props:r,handler:n,htmlBuilder:s,mathmlBuilder:a}=i,o={type:e,numArgs:r.numArgs,argTypes:r.argTypes,allowedInArgument:!!r.allowedInArgument,allowedInText:!!r.allowedInText,allowedInMath:r.allowedInMath===void 0?!0:r.allowedInMath,numOptionalArgs:r.numOptionalArgs||0,infix:!!r.infix,primitive:!!r.primitive,handler:n},l=0;l0&&(s.push(A0(a,e)),a=[]),s.push(r[o]));a.length>0&&s.push(A0(a,e));var h;t?(h=A0(tt(t,e,!0)),h.classes=["tag"],s.push(h)):n&&s.push(n);var d=pr(["katex-html"],s);if(d.setAttribute("aria-hidden","true"),h){var c=h.children[0];c.style.height=j(d.height+d.depth),d.depth&&(c.style.verticalAlign=j(-d.depth))}return d}function Y2(i){return new $n(i)}function Jc(i){if(!i)return!1;if(i.type==="mi"&&i.children.length===1){var e=i.children[0];return e instanceof gi&&e.text==="."}else if(i.type==="mo"&&i.children.length===1&&i.getAttribute("separator")==="true"&&i.getAttribute("lspace")==="0em"&&i.getAttribute("rspace")==="0em"){var t=i.children[0];return t instanceof gi&&t.text===","}else return!1}function c2(i,e,t,r,n){var s=jt(i,t),a;s.length===1&&s[0]instanceof Et&&["mrow","mtable"].includes(s[0].type)?a=s[0]:a=new q.MathNode("mrow",s);var o=new q.MathNode("annotation",[new q.TextNode(e)]);o.setAttribute("encoding","application/x-tex");var l=new q.MathNode("semantics",[a,o]),h=new q.MathNode("math",[l]);h.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),r&&h.setAttribute("display","block");var d=n?"katex":"katex-mathml";return L.makeSpan([d],[h])}function le(i,e){if(!i||i.type!==e)throw new Error("Expected node of type "+e+", but got "+(i?"node of type "+i.type:String(i)));return i}function Su(i){var e=$0(i);if(!e)throw new Error("Expected node of symbol group type, but got "+(i?"node of type "+i.type:String(i)));return e}function $0(i){return i&&(i.type==="atom"||TN.hasOwnProperty(i.type))?i:null}function K2(i,e){var t=tt(i.body,e,!0);return JN([i.mclass],t,e)}function Z2(i,e){var t,r=jt(i.body,e);return i.mclass==="minner"?t=new q.MathNode("mpadded",r):i.mclass==="mord"?i.isCharacterBox?(t=r[0],t.type="mi"):t=new q.MathNode("mi",r):(i.isCharacterBox?(t=r[0],t.type="mo"):t=new q.MathNode("mo",r),i.mclass==="mbin"?(t.attributes.lspace="0.22em",t.attributes.rspace="0.22em"):i.mclass==="mpunct"?(t.attributes.lspace="0em",t.attributes.rspace="0.17em"):i.mclass==="mopen"||i.mclass==="mclose"?(t.attributes.lspace="0em",t.attributes.rspace="0em"):i.mclass==="minner"&&(t.attributes.lspace="0.0556em",t.attributes.width="+0.1111em")),t}function iE(i,e,t){var r=eE[i];switch(r){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return t.callFunction(r,[e[0]],[e[1]]);case"\\uparrow":case"\\downarrow":{var n=t.callFunction("\\\\cdleft",[e[0]],[]),s={type:"atom",text:r,mode:"math",family:"rel"},a=t.callFunction("\\Big",[s],[]),o=t.callFunction("\\\\cdright",[e[1]],[]),l={type:"ordgroup",mode:"math",body:[n,a,o]};return t.callFunction("\\\\cdparent",[l],[])}case"\\\\cdlongequal":return t.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{var h={type:"textord",text:"\\Vert",mode:"math"};return t.callFunction("\\Big",[h],[])}default:return{type:"textord",text:" ",mode:"math"}}}function rE(i){var e=[];for(i.gullet.beginGroup(),i.gullet.macros.set("\\cr","\\\\\\relax"),i.gullet.beginGroup();;){e.push(i.parseExpression(!1,"\\\\")),i.gullet.endGroup(),i.gullet.beginGroup();var t=i.fetch().text;if(t==="&"||t==="\\\\")i.consume();else if(t==="\\end"){e[e.length-1].length===0&&e.pop();break}else throw new U("Expected \\\\ or \\cr or \\end",i.nextToken)}for(var r=[],n=[r],s=0;s-1))if("<>AV".indexOf(h)>-1)for(var c=0;c<2;c++){for(var f=!0,m=l+1;mAV=|." after @',a[l]);var g=iE(h,d,i),x={type:"styling",body:[g],mode:"math",style:"display"};r.push(x),o=u2()}s%2===0?r.push(o):r.shift(),r=[],n.push(r)}i.gullet.endGroup(),i.gullet.endGroup();var v=new Array(n[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25});return{type:"array",mode:"math",body:n,arraystretch:1,addJot:!0,rowGaps:[null],cols:v,colSeparationType:"CD",hLinesBeforeRow:new Array(n.length+1).fill([])}}function G0(i,e){var t=$0(i);if(t&&gE.includes(t.text))return t;throw t?new U("Invalid delimiter '"+t.text+"' after '"+e.funcName+"'",i):new U("Invalid delimiter type '"+i.type+"'",i)}function p2(i){if(!i.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}function Vi(i){for(var{type:e,names:t,props:r,handler:n,htmlBuilder:s,mathmlBuilder:a}=i,o={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:n},l=0;l1||!d)&&x.pop(),b.length{Ut=class i{constructor(e,t,r){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=r}static range(e,t){return t?!e||!e.loc||!t.loc||e.loc.lexer!==t.loc.lexer?null:new i(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}},ii=class i{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new i(t,Ut.range(this,e))}},U=class i{constructor(e,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var r="KaTeX parse error: "+e,n,s,a=t&&t.loc;if(a&&a.start<=a.end){var o=a.lexer.input;n=a.start,s=a.end,n===o.length?r+=" at end of input: ":r+=" at position "+(n+1)+": ";var l=o.slice(n,s).replace(/[^]/g,"$&\u0332"),h;n>15?h="\u2026"+o.slice(n-15,n):h=o.slice(0,n);var d;s+15":">","<":"<",'"':""","'":"'"},YT=/[&><"']/g;I2=function i(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?i(e.body[0]):e:e.type==="font"?i(e.body):e},VT=function(e){var t=I2(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},XT=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},KT=function(e){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},ve={deflt:UT,escape:WT,hyphenate:jT,getBaseElem:I2,isCharacterBox:VT,protocolFromUrl:KT},L0={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:i=>"#"+i},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(i,e)=>(e.push(i),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:i=>Math.max(0,i),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:i=>Math.max(0,i),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:i=>Math.max(0,i),cli:"-e, --max-expand ",cliProcessor:i=>i==="Infinity"?1/0:parseInt(i)},globalGroup:{type:"boolean",cli:!1}};wo=class{constructor(e){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var t in L0)if(L0.hasOwnProperty(t)){var r=L0[t];this[t]=e[t]!==void 0?r.processor?r.processor(e[t]):e[t]:ZT(r)}}reportNonstrict(e,t,r){var n=this.strict;if(typeof n=="function"&&(n=n(e,t,r)),!(!n||n==="ignore")){if(n===!0||n==="error")throw new U("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+e+"]"),r);n==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+n+"': "+t+" ["+e+"]"))}}useStrictBehavior(e,t,r){var n=this.strict;if(typeof n=="function")try{n=n(e,t,r)}catch{n="error"}return!n||n==="ignore"?!1:n===!0||n==="error"?!0:n==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+n+"': "+t+" ["+e+"]")),!1)}isTrusted(e){if(e.url&&!e.protocol){var t=ve.protocolFromUrl(e.url);if(t==null)return!1;e.protocol=t}var r=typeof this.trust=="function"?this.trust(e):this.trust;return!!r}},ji=class{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return Gi[QT[this.id]]}sub(){return Gi[JT[this.id]]}fracNum(){return Gi[eN[this.id]]}fracDen(){return Gi[tN[this.id]]}cramp(){return Gi[iN[this.id]]}text(){return Gi[rN[this.id]]}isTight(){return this.size>=2}},wu=0,I0=1,Ds=2,fr=3,Mo=4,pi=5,Os=6,St=7,Gi=[new ji(wu,0,!1),new ji(I0,0,!0),new ji(Ds,1,!1),new ji(fr,1,!0),new ji(Mo,2,!1),new ji(pi,2,!0),new ji(Os,3,!1),new ji(St,3,!0)],QT=[Mo,pi,Mo,pi,Os,St,Os,St],JT=[pi,pi,pi,pi,St,St,St,St],eN=[Ds,fr,Mo,pi,Os,St,Os,St],tN=[fr,fr,pi,pi,St,St,St,St],iN=[I0,I0,fr,fr,pi,pi,St,St],rN=[wu,I0,Ds,fr,Ds,fr,Ds,fr],ie={DISPLAY:Gi[wu],TEXT:Gi[Ds],SCRIPT:Gi[Mo],SCRIPTSCRIPT:Gi[Os]},hu=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];z0=[];hu.forEach(i=>i.blocks.forEach(e=>z0.push(...e)));Rs=80,sN=function(e,t){return"M95,"+(622+e+t)+` + `,this.textEditNode.setAttribute("contenteditable",!0),this.textEditNode.addEventListener("keyup",g=>{g.stopPropagation()}),this.textEditNode.addEventListener("click",g=>{g.stopPropagation()}),(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.textEditNode));let{node:e,range:t}=this.activeOuterFrame,r=this.getStyle(this.getNodeRangeFirstNode(e,t)),[n,s,a,o]=r.textFillPadding,{defaultOuterFrameText:l,nodeTextEditZIndex:h}=this.mindMap.opt,d=this.mindMap.view.scale,c=this.getText(this.getNodeRangeFirstNode(e,t)),f=(c||l).split(/\n/gim);this.textEditNode.style.padding=`${n}px ${s}px ${a}px ${o}px`,this.textEditNode.style.fontFamily=r.fontFamily,this.textEditNode.style.fontSize=r.fontSize*d+"px",this.textEditNode.style.fontWeight=r.fontWeight,this.textEditNode.style.fontStyle=r.fontStyle,this.textEditNode.style.lineHeight=f.length>1?r.lineHeight:"normal",this.textEditNode.style.zIndex=h,this.textEditNode.innerHTML=f.join("
    "),this.textEditNode.style.display="block",this.updateTextEditBoxPos(i),this.setIsShowTextEdit(!0),c===""||c===l?la(this.textEditNode):oa(this.textEditNode)}function jE(i){this.showTextEdit=i,i?this.mindMap.keyCommand.stopCheckInSvg():this.mindMap.keyCommand.recoveryCheckInSvg()}function GE(){if(!this.textEditNode)return;(this.mindMap.opt.customInnerElsAppendTo||document.body).removeChild(this.textEditNode)}function VE(){this.hideEditTextBox()}function WE(i){let e=i.node.getBoundingClientRect();this.textEditNode&&(this.textEditNode.style.minWidth=`${e.width}px`,this.textEditNode.style.minHeight=`${e.height}px`,this.textEditNode.style.left=`${e.left}px`,this.textEditNode.style.top=`${e.top}px`)}function YE(){if(!this.showTextEdit)return;let{el:i,textNode:e,node:t,range:r}=this.activeOuterFrame,n=na(this.textEditNode.innerHTML);n=n===this.mindMap.opt.defaultOuterFrameText?"":n,this.updateActiveOuterFrame({text:n}),this.textEditNode.style.display="none",this.textEditNode.innerHTML="",this.setIsShowTextEdit(!1),this.renderText(n,i,e,t,r),this.mindMap.emit("hide_text_edit")}function XE(i,e,t,r,n){if(!i)return;t.clear();let s=new Ve;t.add(s);let a=this.getStyle(this.getNodeRangeFirstNode(r,n)),[o,l,h,d]=a.textFillPadding,c=i.replace(/\n$/g,"").split(/\n/gim),f=new _e;c.forEach((A,C)=>{A===""&&(A="\uFEFF");let I=new Ce().text(A);I.y(a.fontSize*a.lineHeight*C),this.styleText(I,a),f.add(I)}),t.add(f);let{width:m,height:g}=t.bbox(),x=m+o+h,y=g+l+d;s.size(x,y).x(0).dy(0),this.styleTextShape(s,a);let b=0;switch(a.textAlign){case"left":b=e.x();break;case"center":b=e.x()+e.width()/2-x/2;break;case"right":b=e.x()+e.width()-x;break;default:break}let S=e.y()-y;s.x(b),s.y(S),f.x(b+o),f.y(S+l)}function KE(i,e){i.fill({color:e.textFill}).radius(e.textFillRadius)}function ZE(i,e){i.fill({color:e.color}).css({"font-family":e.fontFamily,"font-size":e.fontSize+"px","font-weight":e.fontWeight,"font-style":e.fontStyle})}function QE(i){let e=i.getData("outerFrame");return e&&e.text?e.text:""}var HE,Yu,S6=T(()=>{yt();pe();HE="outer-frame-text-edit-warp";Yu={getText:QE,createText:UE,styleTextShape:KE,styleText:ZE,onScale:VE,showEditTextBox:$E,setIsShowTextEdit:jE,removeTextEditEl:GE,hideEditTextBox:YE,updateTextEditBoxPos:WE,renderText:XE}});var A6={};tt(A6,{default:()=>JE});var Ku,Xu,Wo,JE,k6=T(()=>{pe();E6();S6();Ku={radius:5,strokeWidth:2,strokeColor:"#0984e3",strokeDasharray:"5,5",fill:"rgba(9,132,227,0.05)",fontSize:14,fontFamily:"\u5FAE\u8F6F\u96C5\u9ED1, Microsoft YaHei",fontWeight:"normal",fontStyle:"normal",color:"#fff",lineHeight:1.2,textFill:"#0984e3",textFillRadius:5,textFillPadding:[5,5,5,5],textAlign:"left"},Xu="outer-frame-text-edit-warp",Wo=class{constructor(e={}){this.mindMap=e.mindMap,this.draw=null,this.createDrawContainer(),this.isNotRenderOuterFrames=!1,this.textNodeList=[],this.outerFrameElList=[],this.activeOuterFrame=null,this.textEditNode=null,this.showTextEdit=!1,Object.keys(Yu).forEach(t=>{this[t]=Yu[t].bind(this)}),this.mindMap.addEditNodeClass(Xu),this.bindEvent()}createDrawContainer(){this.draw=this.mindMap.draw.group(),this.draw.addClass("smm-outer-frame-container"),this.draw.back(),this.draw.forward()}bindEvent(){this.renderOuterFrames=this.renderOuterFrames.bind(this),this.mindMap.on("node_tree_render_end",this.renderOuterFrames),this.mindMap.on("data_change",this.renderOuterFrames),this.clearActiveOuterFrame=this.clearActiveOuterFrame.bind(this),this.mindMap.on("draw_click",this.clearActiveOuterFrame),this.mindMap.on("node_click",this.clearActiveOuterFrame),this.mindMap.on("scale",this.onScale),this.onBeforeDestroy=this.onBeforeDestroy.bind(this),this.mindMap.on("beforeDestroy",this.onBeforeDestroy),this.addOuterFrame=this.addOuterFrame.bind(this),this.mindMap.command.add("ADD_OUTER_FRAME",this.addOuterFrame),this.removeActiveOuterFrame=this.removeActiveOuterFrame.bind(this),this.mindMap.keyCommand.addShortcut("Del|Backspace",this.removeActiveOuterFrame)}unBindEvent(){this.mindMap.off("node_tree_render_end",this.renderOuterFrames),this.mindMap.off("data_change",this.renderOuterFrames),this.mindMap.off("draw_click",this.clearActiveOuterFrame),this.mindMap.off("node_click",this.clearActiveOuterFrame),this.mindMap.off("scale",this.onScale),this.mindMap.off("beforeDestroy",this.onBeforeDestroy),this.mindMap.command.remove("ADD_OUTER_FRAME",this.addOuterFrame),this.mindMap.keyCommand.removeShortcut("Del|Backspace",this.removeActiveOuterFrame)}onBeforeDestroy(){this.hideEditTextBox(),this.removeTextEditEl()}addOuterFrame(e,t={}){e=Ot(e);let r=this.mindMap.renderer.activeNodeList;if(r.length<=0&&e.length<=0)return;let n=e.length>0?e:r;n=n.filter(a=>!a.isRoot&&!a.isGeneralization),T6(n).forEach(({node:a,range:o})=>{let l=a.children.slice(o[0],o[1]+1),h=wt();l.forEach(d=>{let c=d.getData("outerFrame");c?c={...c,...t,groupId:h}:c={...t,groupId:h},this.mindMap.execCommand("SET_NODE_DATA",d,{outerFrame:c})})})}getActiveOuterFrame(){return this.activeOuterFrame?{...this.activeOuterFrame}:null}removeActiveOuterFrame(){if(!this.activeOuterFrame)return;let{node:e,range:t}=this.activeOuterFrame;this.getRangeNodeList(e,t).forEach(r=>{this.mindMap.execCommand("SET_NODE_DATA",r,{outerFrame:null})}),this.mindMap.emit("outer_frame_delete")}removeActiveOuterFrameText(){this.updateActiveOuterFrame({text:""})}updateActiveOuterFrame(e={}){if(!this.activeOuterFrame)return;this.isNotRenderOuterFrames=!0;let{el:t,node:r,range:n}=this.activeOuterFrame,s="";this.getRangeNodeList(r,n).forEach(a=>{let l={...a.getData("outerFrame"),...e};s=l.strokeDasharray,this.mindMap.execCommand("SET_NODE_DATA",a,{outerFrame:l})}),t.cacheStyle={dasharray:s},this.updateOuterFrameStyle()}updateOuterFrameStyle(){let{el:e,node:t,range:r,textNode:n}=this.activeOuterFrame,s=this.getNodeRangeFirstNode(t,r),a=this.getStyle(s);this.styleOuterFrame(e,{...a,strokeDasharray:"none"});let o=this.getText(s);this.renderText(o,e,n,t,r)}getRangeNodeList(e,t){return e.children.slice(t[0],t[1]+1).filter(r=>r.getData("outerFrame"))}getNodeRangeFirstNode(e,t){return e.children[t[0]]}renderOuterFrames(){if(this.isNotRenderOuterFrames){this.isNotRenderOuterFrames=!1;return}this.clearActiveOuterFrame(),this.clearTextNodes(),this.clearOuterFrameElList();let e=this.mindMap.renderer.root;if(!e)return;let t=this.mindMap.draw.transform(),{outerFramePaddingX:r,outerFramePaddingY:n}=this.mindMap.opt;de(e,null,s=>{if(!s)return;let a=N6(s);a&&a.length>0&&a.forEach(({nodeList:o,range:l})=>{if(l[0]===-1||l[1]===-1)return;let{left:h,top:d,width:c,height:f}=D2(o);if(!Number.isFinite(h)||!Number.isFinite(d)||!Number.isFinite(c)||!Number.isFinite(f))return;let m=this.createOuterFrameEl((h-r-this.mindMap.elRect.left-t.translateX)/t.scaleX,(d-n-this.mindMap.elRect.top-t.translateY)/t.scaleY,(c+r*2)/t.scaleX,(f+n*2)/t.scaleY,this.getStyle(o[0])),g=this.createText(m,s,l);this.textNodeList.push(g),this.renderText(this.getText(o[0]),m,g,s,l),m.on("click",x=>{x.stopPropagation(),this.setActiveOuterFrame(m,s,l,g)})})},()=>{},!0,0)}setActiveOuterFrame(e,t,r,n){this.mindMap.execCommand("CLEAR_ACTIVE_NODE"),this.clearActiveOuterFrame(),this.activeOuterFrame={el:e,node:t,range:r,textNode:n},e.stroke({dasharray:"none"}),this.getText(this.getNodeRangeFirstNode(t,r))||this.renderText(this.mindMap.opt.defaultOuterFrameText,e,n,t,r),this.mindMap.emit("outer_frame_active",e,t,r)}clearActiveOuterFrame(){if(!this.activeOuterFrame)return;let{el:e,textNode:t,node:r,range:n}=this.activeOuterFrame;e.stroke({dasharray:e.cacheStyle.dasharray||Ku.strokeDasharray}),this.hideEditTextBox(),this.getText(this.getNodeRangeFirstNode(r,n))||t.clear(),this.activeOuterFrame=null,this.mindMap.emit("outer_frame_deactivate")}getStyle(e){return{...Ku,...e.getData("outerFrame")||{}}}createOuterFrameEl(e,t,r,n,s={}){let a=this.draw.rect().size(r,n).x(e).y(t);return this.styleOuterFrame(a,s),a.cacheStyle={dasharray:s.strokeDasharray},this.outerFrameElList.push(a),a}styleOuterFrame(e,t){e.radius(t.radius).stroke({width:t.strokeWidth,color:t.strokeColor,dasharray:t.strokeDasharray}).fill({color:t.fill})}clearTextNodes(){this.textNodeList.forEach(e=>{e.remove()})}clearOuterFrameElList(){this.outerFrameElList.forEach(e=>{e.remove()}),this.outerFrameElList=[],this.activeOuterFrame=null}beforePluginRemove(){this.mindMap.deleteEditNodeClass(Xu),this.unBindEvent()}beforePluginDestroy(){this.mindMap.deleteEditNodeClass(Xu),this.unBindEvent()}};Wo.instanceName="outerFrame";Wo.defaultStyle=Ku;JE=Wo});var C6={};tt(C6,{default:()=>eS});var ah,eS,_6=T(()=>{pe();$e();ah=class{constructor(e){this.mindMap=e.mindMap,this.scrollbarWrapSize={width:0,height:0},this.chartHeight=0,this.chartWidth=0,this.reset(),this.bindEvent()}reset(){this.currentScrollType="",this.isMousedown=!1,this.mousedownPos={x:0,y:0},this.mousedownScrollbarPos=0}bindEvent(){this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.updateScrollbar=this.updateScrollbar.bind(this),this.updateScrollbar=Si(this.updateScrollbar,16,this),this.mindMap.on("mousemove",this.onMousemove),this.mindMap.on("mouseup",this.onMouseup),this.mindMap.on("node_tree_render_end",this.updateScrollbar),this.mindMap.on("view_data_change",this.updateScrollbar),this.mindMap.on("resize",this.updateScrollbar)}unBindEvent(){this.mindMap.off("mousemove",this.onMousemove),this.mindMap.off("mouseup",this.onMouseup),this.mindMap.off("node_tree_render_end",this.updateScrollbar),this.mindMap.off("view_data_change",this.updateScrollbar),this.mindMap.off("resize",this.updateScrollbar)}updateScrollbar(){if(this.isMousedown)return;let e=this.calculationScrollbar();this.emitEvent(e)}emitEvent(e){this.mindMap.emit("scrollbar_change",e)}setScrollBarWrapSize(e,t){this.scrollbarWrapSize.width=e,this.scrollbarWrapSize.height=t}calculationScrollbar(){let e=this.mindMap.draw.rbox(),t=this.mindMap.elRect;e.x-=t.left,e.y-=t.top;let r=this.mindMap.height,n=r/2,s=e.height+n*2;this.chartHeight=s;let a=e.y-n,o=Math.min(r/s*100,100),l=-a/s*100;l<0&&(l=0),l>100-o&&(l=100-o);let h=this.mindMap.width,d=h/2,c=e.width+d*2;this.chartWidth=c;let f=e.x-d,m=Math.min(h/c*100,100),g=-f/c*100;return g<0&&(g=0),g>100-m&&(g=100-m),{vertical:{top:l,height:o},horizontal:{left:g,width:m}}}onMousedown(e,t){e.preventDefault(),e.stopPropagation(),this.currentScrollType=t,this.isMousedown=!0,this.mousedownPos={x:e.clientX,y:e.clientY};let r=window.getComputedStyle(e.target);t===k.SCROLL_BAR_DIR.VERTICAL?this.mousedownScrollbarPos=Number.parseFloat(r.top):this.mousedownScrollbarPos=Number.parseFloat(r.left)}onMousemove(e){if(this.isMousedown)if(e.preventDefault(),e.stopPropagation(),this.currentScrollType===k.SCROLL_BAR_DIR.VERTICAL){let t=e.clientY-this.mousedownPos.y+this.mousedownScrollbarPos;this.updateMindMapView(k.SCROLL_BAR_DIR.VERTICAL,t)}else{let t=e.clientX-this.mousedownPos.x+this.mousedownScrollbarPos;this.updateMindMapView(k.SCROLL_BAR_DIR.HORIZONTAL,t)}}onMouseup(){this.isMousedown=!1,this.reset()}updateMindMapView(e,t){let r=this.calculationScrollbar(),n=this.mindMap.draw.transform(),s=this.mindMap.draw.rbox(),a=this.mindMap.renderer.root.group.rbox(),o=this.mindMap.renderer.layout.getRootCenterOffset(a.width,a.height);if(e===k.SCROLL_BAR_DIR.VERTICAL){let l=t;l<=0&&(l=0);let h=(100-r.vertical.height)/100*this.scrollbarWrapSize.height;l>=h&&(l=h);let d=l/this.scrollbarWrapSize.height*100,c=-d/100*this.chartHeight,f=a.y-s.y,m=this.mindMap.height/2,g=c+f-m*n.scaleY+m-o.y*n.scaleY+(this.mindMap.height-this.mindMap.initHeight)/2*n.scaleY;this.mindMap.view.translateYTo(g),this.emitEvent({horizontal:r.horizontal,vertical:{top:d,height:r.vertical.height}})}else{let l=t;l<=0&&(l=0);let h=(100-r.horizontal.width)/100*this.scrollbarWrapSize.width;l>=h&&(l=h);let d=l/this.scrollbarWrapSize.width*100,c=-d/100*this.chartWidth,f=a.x-s.x,m=this.mindMap.width/2,g=c+f-m*n.scaleX+m-o.x*n.scaleX+(this.mindMap.width-this.mindMap.initWidth)/2*n.scaleX;this.mindMap.view.translateXTo(g),this.emitEvent({vertical:r.vertical,horizontal:{left:d,width:r.horizontal.width}})}}onClick(e,t){let r=0;t===k.SCROLL_BAR_DIR.VERTICAL?r=e.clientY-e.currentTarget.getBoundingClientRect().top:r=e.clientX-e.currentTarget.getBoundingClientRect().left,this.updateMindMapView(t,r)}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};ah.instanceName="scrollbar";eS=ah});var L6={};tt(L6,{default:()=>tS});var oh,tS,I6=T(()=>{pe();oh=class{constructor(e){this.mindMap=e.mindMap,this.isMousedown=!1,this.mousedownPos={x:0,y:0},this.startViewPos={x:0,y:0},this.currentState=null}calculationMiniMap(e,t){let{svg:r,rect:n,origWidth:s,origHeight:a,scaleX:o,scaleY:l}=this.mindMap.getSvgData({ignoreWatermark:!0}),h=this.mindMap.elRect;n.x-=h.left,n.x2-=h.left,n.y-=h.top,n.y2-=h.top;let d=e/t,c=0,f=0;d>n.ratio?(f=t,c=n.ratio*f):(c=e,f=c/n.ratio);let m=c/n.width,g=(e-c)/2,x=(t-f)/2,y=n.width*o,b=n.height*l,S=(y-n.width)/2,A=(b-n.height)/2,C=n.x-S,I=n.x2+S,O=n.y-A,q=n.y2+A,P={left:0,top:0,right:0,bottom:0};P.left=Math.max(0,-C/y*c)+g,P.right=Math.max(0,(I-s)/y*c)+g,P.top=Math.max(0,-O/b*f)+x,P.bottom=Math.max(0,(q-a)/b*f)+x,P.top>x+f&&(P.top=x+f),P.left>g+c&&(P.left=g+c),Object.keys(P).forEach(ne=>{P[ne]=P[ne]+"px"}),this.removeNodeContent(r);let W=r.svg();return this.currentState={viewBoxStyle:{...P},miniMapBoxScale:m,miniMapBoxLeft:g,miniMapBoxTop:x},{getImgUrl:async ne=>{let re=await this.mindMap.doExport.fixSvgStrAndToBlob(W);ne(re)},svgHTML:W,viewBoxStyle:P,miniMapBoxScale:m,miniMapBoxLeft:g,miniMapBoxTop:x}}removeNodeContent(e){if(e.hasClass("smm-node")){let r=e.findOne(".smm-node-shape"),n=r.attr("fill");(Oo(n)||mu(n))&&r.attr("fill",$0(this.mindMap.themeConfig)),e.clear(),e.add(r);return}let t=e.children();t&&t.length>0&&t.forEach(r=>{this.removeNodeContent(r)})}onMousedown(e){this.isMousedown=!0,this.mousedownPos={x:e.clientX,y:e.clientY};let t=this.mindMap.view.getTransformData();this.startViewPos={x:t.state.x,y:t.state.y}}onMousemove(e,t=5){if(!this.isMousedown||this.isViewBoxMousedown)return;let r=e.clientX-this.mousedownPos.x,n=e.clientY-this.mousedownPos.y;this.mindMap.view.translateXTo(r*t+this.startViewPos.x),this.mindMap.view.translateYTo(n*t+this.startViewPos.y)}onMouseup(){this.isMousedown=!1,this.isViewBoxMousedown=!1}onViewBoxMousedown(e){this.isViewBoxMousedown=!0,this.mousedownPos={x:e.clientX,y:e.clientY};let t=this.mindMap.view.getTransformData();this.startViewPos={x:t.state.x,y:t.state.y}}onViewBoxMousemove(e){if(!this.isViewBoxMousedown||!this.currentState||this.isMousedown)return;let t=e.clientX-this.mousedownPos.x,r=e.clientY-this.mousedownPos.y,{viewBoxStyle:n,miniMapBoxScale:s,miniMapBoxLeft:a,miniMapBoxTop:o}=this.currentState,l=Math.max(a,Number.parseFloat(n.left)+t),h=Math.max(a,Number.parseFloat(n.right)-t),d=Math.max(o,Number.parseFloat(n.top)+r),c=Math.max(o,Number.parseFloat(n.bottom)-r);this.mindMap.emit("mini_map_view_box_position_change",{left:l+"px",right:h+"px",top:d+"px",bottom:c+"px"}),this.mindMap.view.translateXTo(-t/s+this.startViewPos.x),this.mindMap.view.translateYTo(-r/s+this.startViewPos.y)}};oh.instanceName="miniMap";tS=oh});var z6={};tt(z6,{default:()=>iS});var lh,iS,R6=T(()=>{pe();lh=class{constructor({mindMap:e}){this.mindMap=e,this.isInPainter=!1,this.painterNode=null,this.bindEvent()}bindEvent(){this.painterOneNode=this.painterOneNode.bind(this),this.onEndPainter=this.onEndPainter.bind(this),this.mindMap.on("node_click",this.painterOneNode),this.mindMap.on("draw_click",this.onEndPainter)}unBindEvent(){this.mindMap.off("node_click",this.painterOneNode),this.mindMap.off("draw_click",this.onEndPainter)}startPainter(){if(this.mindMap.opt.readonly)return;let e=this.mindMap.renderer.activeNodeList;e.length<=0||(this.painterNode=e[0],this.isInPainter=!0,this.mindMap.emit("painter_start"))}endPainter(){this.painterNode=null,this.isInPainter=!1}onEndPainter(){this.isInPainter&&(this.endPainter(),this.mindMap.emit("painter_end"))}painterOneNode(e){if(!e||!this.isInPainter||!this.painterNode||!e||e.uid===this.painterNode.uid)return;let t={};this.mindMap.opt.onlyPainterNodeCustomStyles||(t={...this.painterNode.effectiveStyles});let r=this.painterNode.getData();Object.keys(r).forEach(n=>{hs(n)&&(t[n]=r[n])}),this.mindMap.renderer._handleRemoveCustomStyles(e.getData()),e.setStyles(t)}beforePluginRemove(){this.unBindEvent()}beforePluginDestroy(){this.unBindEvent()}};lh.instanceName="painter";iS=lh});function lS(i){return String(i).replace(oS,e=>aS[e])}function uS(i){if(i.default)return i.default;var e=i.type,t=Array.isArray(e)?e[0]:e;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}function vS(i){for(var e=0;e=n[0]&&i<=n[1])return t.name}return null}function f4(i){for(var e=0;e=wh[e]&&i<=wh[e+1])return!0;return!1}function _S(i,e){dr[i]=e}function T1(i,e,t){if(!dr[e])throw new Error("Font metrics not found for font: "+e+".");var r=i.charCodeAt(0),n=dr[e][r];if(!n&&i[0]in O6&&(r=O6[i[0]].charCodeAt(0),n=dr[e][r]),!n&&t==="text"&&f4(r)&&(n=dr[e][77]),n)return{depth:n[0],height:n[1],italic:n[2],skew:n[3],width:n[4]}}function LS(i){var e;if(i>=5?e=0:i>=3?e=1:e=2,!Zu[e]){var t=Zu[e]={cssEmPerMu:hh.quad[e]/18};for(var r in hh)hh.hasOwnProperty(r)&&(t[r]=hh[r][e])}return Zu[e]}function F6(i){if(i instanceof ei)return i;throw new Error("Expected symbolNode but got "+String(i)+".")}function OS(i){if(i instanceof ps)return i;throw new Error("Expected span but got "+String(i)+".")}function u(i,e,t,r,n,s){Oe[i][n]={font:e,group:t,replace:r},s&&r&&(Oe[i][r]=Oe[i][n])}function Z(i){for(var{type:e,names:t,props:r,handler:n,htmlBuilder:s,mathmlBuilder:a}=i,o={type:e,numArgs:r.numArgs,argTypes:r.argTypes,allowedInArgument:!!r.allowedInArgument,allowedInText:!!r.allowedInText,allowedInMath:r.allowedInMath===void 0?!0:r.allowedInMath,numOptionalArgs:r.numOptionalArgs||0,infix:!!r.infix,primitive:!!r.primitive,handler:n},l=0;l0&&(s.push(gh(a,e)),a=[]),s.push(r[o]));a.length>0&&s.push(gh(a,e));var h;t?(h=gh(ct(t,e,!0)),h.classes=["tag"],s.push(h)):n&&s.push(n);var d=zr(["katex-html"],s);if(d.setAttribute("aria-hidden","true"),h){var c=h.children[0];c.style.height=V(d.height+d.depth),d.depth&&(c.style.verticalAlign=V(-d.depth))}return d}function E4(i){return new ms(i)}function e1(i){if(!i)return!1;if(i.type==="mi"&&i.children.length===1){var e=i.children[0];return e instanceof ki&&e.text==="."}else if(i.type==="mo"&&i.children.length===1&&i.getAttribute("separator")==="true"&&i.getAttribute("lspace")==="0em"&&i.getAttribute("rspace")==="0em"){var t=i.children[0];return t instanceof ki&&t.text===","}else return!1}function j6(i,e,t,r,n){var s=ti(i,t),a;s.length===1&&s[0]instanceof Bt&&["mrow","mtable"].includes(s[0].type)?a=s[0]:a=new $.MathNode("mrow",s);var o=new $.MathNode("annotation",[new $.TextNode(e)]);o.setAttribute("encoding","application/x-tex");var l=new $.MathNode("semantics",[a,o]),h=new $.MathNode("math",[l]);h.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),r&&h.setAttribute("display","block");var d=n?"katex":"katex-mathml";return z.makeSpan([d],[h])}function me(i,e){if(!i||i.type!==e)throw new Error("Expected node of type "+e+", but got "+(i?"node of type "+i.type:String(i)));return i}function A1(i){var e=Ih(i);if(!e)throw new Error("Expected node of symbol group type, but got "+(i?"node of type "+i.type:String(i)));return e}function Ih(i){return i&&(i.type==="atom"||PS.hasOwnProperty(i.type))?i:null}function C4(i,e){var t=ct(i.body,e,!0);return mA([i.mclass],t,e)}function _4(i,e){var t,r=ti(i.body,e);return i.mclass==="minner"?t=new $.MathNode("mpadded",r):i.mclass==="mord"?i.isCharacterBox?(t=r[0],t.type="mi"):t=new $.MathNode("mi",r):(i.isCharacterBox?(t=r[0],t.type="mo"):t=new $.MathNode("mo",r),i.mclass==="mbin"?(t.attributes.lspace="0.22em",t.attributes.rspace="0.22em"):i.mclass==="mpunct"?(t.attributes.lspace="0em",t.attributes.rspace="0.17em"):i.mclass==="mopen"||i.mclass==="mclose"?(t.attributes.lspace="0em",t.attributes.rspace="0em"):i.mclass==="minner"&&(t.attributes.lspace="0.0556em",t.attributes.width="+0.1111em")),t}function xA(i,e,t){var r=pA[i];switch(r){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return t.callFunction(r,[e[0]],[e[1]]);case"\\uparrow":case"\\downarrow":{var n=t.callFunction("\\\\cdleft",[e[0]],[]),s={type:"atom",text:r,mode:"math",family:"rel"},a=t.callFunction("\\Big",[s],[]),o=t.callFunction("\\\\cdright",[e[1]],[]),l={type:"ordgroup",mode:"math",body:[n,a,o]};return t.callFunction("\\\\cdparent",[l],[])}case"\\\\cdlongequal":return t.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{var h={type:"textord",text:"\\Vert",mode:"math"};return t.callFunction("\\Big",[h],[])}default:return{type:"textord",text:" ",mode:"math"}}}function yA(i){var e=[];for(i.gullet.beginGroup(),i.gullet.macros.set("\\cr","\\\\\\relax"),i.gullet.beginGroup();;){e.push(i.parseExpression(!1,"\\\\")),i.gullet.endGroup(),i.gullet.beginGroup();var t=i.fetch().text;if(t==="&"||t==="\\\\")i.consume();else if(t==="\\end"){e[e.length-1].length===0&&e.pop();break}else throw new G("Expected \\\\ or \\cr or \\end",i.nextToken)}for(var r=[],n=[r],s=0;s-1))if("<>AV".indexOf(h)>-1)for(var c=0;c<2;c++){for(var f=!0,m=l+1;mAV=|." after @',a[l]);var g=xA(h,d,i),x={type:"styling",body:[g],mode:"math",style:"display"};r.push(x),o=G6()}s%2===0?r.push(o):r.shift(),r=[],n.push(r)}i.gullet.endGroup(),i.gullet.endGroup();var y=new Array(n[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25});return{type:"array",mode:"math",body:n,arraystretch:1,addJot:!0,rowGaps:[null],cols:y,colSeparationType:"CD",hLinesBeforeRow:new Array(n.length+1).fill([])}}function Rh(i,e){var t=Ih(i);if(t&&LA.includes(t.text))return t;throw t?new G("Invalid delimiter '"+t.text+"' after '"+e.funcName+"'",i):new G("Invalid delimiter type '"+i.type+"'",i)}function Y6(i){if(!i.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}function ur(i){for(var{type:e,names:t,props:r,handler:n,htmlBuilder:s,mathmlBuilder:a}=i,o={type:e,numArgs:r.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:n},l=0;l1||!d)&&x.pop(),b.length{Jt=class i{constructor(e,t,r){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=r}static range(e,t){return t?!e||!e.loc||!t.loc||e.loc.lexer!==t.loc.lexer?null:new i(e.loc.lexer,e.loc.start,t.loc.end):e&&e.loc}},ui=class i{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new i(t,Jt.range(this,e))}},G=class i{constructor(e,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var r="KaTeX parse error: "+e,n,s,a=t&&t.loc;if(a&&a.start<=a.end){var o=a.lexer.input;n=a.start,s=a.end,n===o.length?r+=" at end of input: ":r+=" at position "+(n+1)+": ";var l=o.slice(n,s).replace(/[^]/g,"$&\u0332"),h;n>15?h="\u2026"+o.slice(n-15,n):h=o.slice(0,n);var d;s+15":">","<":"<",'"':""","'":"'"},oS=/[&><"']/g;u4=function i(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?i(e.body[0]):e:e.type==="font"?i(e.body):e},hS=function(e){var t=u4(e);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},dS=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},cS=function(e){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Ne={deflt:rS,escape:lS,hyphenate:sS,getBaseElem:u4,isCharacterBox:hS,protocolFromUrl:cS},bh={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:i=>"#"+i},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(i,e)=>(e.push(i),e)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:i=>Math.max(0,i),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:i=>Math.max(0,i),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:i=>Math.max(0,i),cli:"-e, --max-expand ",cliProcessor:i=>i==="Infinity"?1/0:parseInt(i)},globalGroup:{type:"boolean",cli:!1}};Qo=class{constructor(e){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(var t in bh)if(bh.hasOwnProperty(t)){var r=bh[t];this[t]=e[t]!==void 0?r.processor?r.processor(e[t]):e[t]:uS(r)}}reportNonstrict(e,t,r){var n=this.strict;if(typeof n=="function"&&(n=n(e,t,r)),!(!n||n==="ignore")){if(n===!0||n==="error")throw new G("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+e+"]"),r);n==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+n+"': "+t+" ["+e+"]"))}}useStrictBehavior(e,t,r){var n=this.strict;if(typeof n=="function")try{n=n(e,t,r)}catch{n="error"}return!n||n==="ignore"?!1:n===!0||n==="error"?!0:n==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+n+"': "+t+" ["+e+"]")),!1)}isTrusted(e){if(e.url&&!e.protocol){var t=Ne.protocolFromUrl(e.url);if(t==null)return!1;e.protocol=t}var r=typeof this.trust=="function"?this.trust(e):this.trust;return!!r}},lr=class{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return hr[fS[this.id]]}sub(){return hr[mS[this.id]]}fracNum(){return hr[pS[this.id]]}fracDen(){return hr[gS[this.id]]}cramp(){return hr[xS[this.id]]}text(){return hr[yS[this.id]]}isTight(){return this.size>=2}},M1=0,Mh=1,ua=2,Lr=3,Jo=4,Ai=5,fa=6,Pt=7,hr=[new lr(M1,0,!1),new lr(Mh,0,!0),new lr(ua,1,!1),new lr(Lr,1,!0),new lr(Jo,2,!1),new lr(Ai,2,!0),new lr(fa,3,!1),new lr(Pt,3,!0)],fS=[Jo,Ai,Jo,Ai,fa,Pt,fa,Pt],mS=[Ai,Ai,Ai,Ai,Pt,Pt,Pt,Pt],pS=[ua,Lr,Jo,Ai,fa,Pt,fa,Pt],gS=[Lr,Lr,Ai,Ai,Pt,Pt,Pt,Pt],xS=[Mh,Mh,Lr,Lr,Ai,Ai,Pt,Pt],yS=[M1,Mh,ua,Lr,ua,Lr,ua,Lr],ae={DISPLAY:hr[M1],TEXT:hr[ua],SCRIPT:hr[Jo],SCRIPTSCRIPT:hr[fa]},d1=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];wh=[];d1.forEach(i=>i.blocks.forEach(e=>wh.push(...e)));ca=80,bS=function(e,t){return"M95,"+(622+e+t)+` c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14 c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54 c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10 @@ -90,7 +90,7 @@ c5.3,-9.3,12,-14,20,-14 H400000v`+(40+e)+`H845.2724 s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z -M`+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},aN=function(e,t){return"M263,"+(601+e+t)+`c0.7,0,18,39.7,52,119 +M`+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},wS=function(e,t){return"M263,"+(601+e+t)+`c0.7,0,18,39.7,52,119 c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120 c340,-704.7,510.7,-1060.3,512,-1067 l`+e/2.084+" -"+e+` @@ -100,7 +100,7 @@ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5, c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1 s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26 c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z -M`+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},oN=function(e,t){return"M983 "+(10+e+t)+` +M`+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},MS=function(e,t){return"M983 "+(10+e+t)+` l`+e/3.13+" -"+e+` c4,-6.7,10,-10,18,-10 H400000v`+(40+e)+` H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7 @@ -109,7 +109,7 @@ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30 c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722 c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5 c53.7,-170.3,84.5,-266.8,92.5,-289.5z -M`+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},lN=function(e,t){return"M424,"+(2398+e+t)+` +M`+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},TS=function(e,t){return"M424,"+(2398+e+t)+` c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514 c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20 s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121 @@ -119,18 +119,18 @@ v`+(40+e)+`H1014.6 s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185 c-2,6,-10,9,-24,9 c-8,0,-12,-0.7,-12,-2z M`+(1001+e)+" "+t+` -h400000v`+(40+e)+"h-400000z"},hN=function(e,t){return"M473,"+(2713+e+t)+` +h400000v`+(40+e)+"h-400000z"},NS=function(e,t){return"M473,"+(2713+e+t)+` c339.3,-1799.3,509.3,-2700,510,-2702 l`+e/5.298+" -"+e+` c3.3,-7.3,9.3,-11,18,-11 H400000v`+(40+e)+`H1017.7 s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9 c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200 c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26 s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104, -606zM`+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"},dN=function(e){var t=e/2;return"M400000 "+e+" H0 L"+t+" 0 l65 45 L145 "+(e-80)+" H400000z"},cN=function(e,t,r){var n=r-54-t-e;return"M702 "+(e+t)+"H400000"+(40+e)+` +606zM`+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"},ES=function(e){var t=e/2;return"M400000 "+e+" H0 L"+t+" 0 l65 45 L145 "+(e-80)+" H400000z"},SS=function(e,t,r){var n=r-54-t-e;return"M702 "+(e+t)+"H400000"+(40+e)+` H742v`+n+`l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1 h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170 c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667 -219 661 l218 661zM702 `+t+"H400000v"+(40+e)+"H742z"},uN=function(e,t,r){t=1e3*t;var n="";switch(e){case"sqrtMain":n=sN(t,Rs);break;case"sqrtSize1":n=aN(t,Rs);break;case"sqrtSize2":n=oN(t,Rs);break;case"sqrtSize3":n=lN(t,Rs);break;case"sqrtSize4":n=hN(t,Rs);break;case"sqrtTall":n=cN(t,Rs,r)}return n},fN=function(e,t){switch(e){case"\u239C":return"M291 0 H417 V"+t+" H291z M291 0 H417 V"+t+" H291z";case"\u2223":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z";case"\u2225":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z"+("M367 0 H410 V"+t+" H367z M367 0 H410 V"+t+" H367z");case"\u239F":return"M457 0 H583 V"+t+" H457z M457 0 H583 V"+t+" H457z";case"\u23A2":return"M319 0 H403 V"+t+" H319z M319 0 H403 V"+t+" H319z";case"\u23A5":return"M263 0 H347 V"+t+" H263z M263 0 H347 V"+t+" H263z";case"\u23AA":return"M384 0 H504 V"+t+" H384z M384 0 H504 V"+t+" H384z";case"\u23D0":return"M312 0 H355 V"+t+" H312z M312 0 H355 V"+t+" H312z";case"\u2016":return"M257 0 H300 V"+t+" H257z M257 0 H300 V"+t+" H257z"+("M478 0 H521 V"+t+" H478z M478 0 H521 V"+t+" H478z");default:return""}},i2={doubleleftarrow:`M262 157 +219 661 l218 661zM702 `+t+"H400000v"+(40+e)+"H742z"},AS=function(e,t,r){t=1e3*t;var n="";switch(e){case"sqrtMain":n=bS(t,ca);break;case"sqrtSize1":n=wS(t,ca);break;case"sqrtSize2":n=MS(t,ca);break;case"sqrtSize3":n=TS(t,ca);break;case"sqrtSize4":n=NS(t,ca);break;case"sqrtTall":n=SS(t,ca,r)}return n},kS=function(e,t){switch(e){case"\u239C":return"M291 0 H417 V"+t+" H291z M291 0 H417 V"+t+" H291z";case"\u2223":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z";case"\u2225":return"M145 0 H188 V"+t+" H145z M145 0 H188 V"+t+" H145z"+("M367 0 H410 V"+t+" H367z M367 0 H410 V"+t+" H367z");case"\u239F":return"M457 0 H583 V"+t+" H457z M457 0 H583 V"+t+" H457z";case"\u23A2":return"M319 0 H403 V"+t+" H319z M319 0 H403 V"+t+" H319z";case"\u23A5":return"M263 0 H347 V"+t+" H263z M263 0 H347 V"+t+" H263z";case"\u23AA":return"M384 0 H504 V"+t+" H384z M384 0 H504 V"+t+" H384z";case"\u23D0":return"M312 0 H355 V"+t+" H312z M312 0 H355 V"+t+" H312z";case"\u2016":return"M257 0 H300 V"+t+" H257z M257 0 H300 V"+t+" H257z"+("M478 0 H521 V"+t+" H478z M478 0 H521 V"+t+" H478z");default:return""}},D6={doubleleftarrow:`M262 157 l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5 @@ -305,7 +305,7 @@ M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z` c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, -231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z -M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},mN=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+` v1759 h347 v-84 +M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},CS=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+` v1759 h347 v-84 H403z M403 1759 V0 H319 V1759 v`+t+" v1759 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+` v1759 H0 v84 H347z M347 1759 V0 H263 V1759 v`+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+` v585 c2.667,10,9.667,15,21,15 c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15 @@ -333,61 +333,61 @@ c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6 c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17 c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558 l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7, --470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw new Error("Unknown stretchy delimiter.")}},$n=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;tt.toText();return this.children.map(e).join("")}},Yi={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},b0={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},r2={\u00C5:"A",\u00D0:"D",\u00DE:"o",\u00E5:"a",\u00F0:"d",\u00FE:"o",\u0410:"A",\u0411:"B",\u0412:"B",\u0413:"F",\u0414:"A",\u0415:"E",\u0416:"K",\u0417:"3",\u0418:"N",\u0419:"N",\u041A:"K",\u041B:"N",\u041C:"M",\u041D:"H",\u041E:"O",\u041F:"N",\u0420:"P",\u0421:"C",\u0422:"T",\u0423:"y",\u0424:"O",\u0425:"X",\u0426:"U",\u0427:"h",\u0428:"W",\u0429:"W",\u042A:"B",\u042B:"X",\u042C:"B",\u042D:"3",\u042E:"X",\u042F:"R",\u0430:"a",\u0431:"b",\u0432:"a",\u0433:"r",\u0434:"y",\u0435:"e",\u0436:"m",\u0437:"e",\u0438:"n",\u0439:"n",\u043A:"n",\u043B:"n",\u043C:"m",\u043D:"n",\u043E:"o",\u043F:"n",\u0440:"p",\u0441:"c",\u0442:"o",\u0443:"y",\u0444:"b",\u0445:"x",\u0446:"n",\u0447:"n",\u0448:"w",\u0449:"w",\u044A:"a",\u044B:"m",\u044C:"a",\u044D:"e",\u044E:"m",\u044F:"r"};Kc={};xN=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],n2=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],s2=function(e,t){return t.size<2?e:xN[e-1][t.size-1]},R0=class i{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||i.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=n2[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){var t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return new i(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:s2(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:n2[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=s2(i.BASESIZE,e);return this.size===t&&this.textSize===i.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==i.BASESIZE?["sizing","reset-size"+this.size,"size"+i.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=gN(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}};R0.BASESIZE=6;du={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},vN={ex:!0,em:!0,mu:!0},D2=function(e){return typeof e!="string"&&(e=e.unit),e in du||e in vN||e==="ex"},He=function(e,t){var r;if(e.unit in du)r=du[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit==="mu")r=t.fontMetrics().cssEmPerMu;else{var n;if(t.style.isTight()?n=t.havingStyle(t.style.text()):n=t,e.unit==="ex")r=n.fontMetrics().xHeight;else if(e.unit==="em")r=n.fontMetrics().quad;else throw new U("Invalid unit: '"+e.unit+"'");n!==t&&(r*=n.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},j=function(e){return+e.toFixed(4)+"em"},Zr=function(e){return e.filter(t=>t).join(" ")},O2=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");var n=t.getColor();n&&(this.style.color=n)}},B2=function(e){var t=document.createElement(e);t.className=Zr(this.classes);for(var r in this.style)this.style.hasOwnProperty(r)&&(t.style[r]=this.style[r]);for(var n in this.attributes)this.attributes.hasOwnProperty(n)&&t.setAttribute(n,this.attributes[n]);for(var s=0;s/=\x00-\x1f]/,P2=function(e){var t="<"+e;this.classes.length&&(t+=' class="'+ve.escape(Zr(this.classes))+'"');var r="";for(var n in this.style)this.style.hasOwnProperty(n)&&(r+=ve.hyphenate(n)+":"+this.style[n]+";");r&&(t+=' style="'+ve.escape(r)+'"');for(var s in this.attributes)if(this.attributes.hasOwnProperty(s)){if(yN.test(s))throw new U("Invalid attribute name '"+s+"'");t+=" "+s+'="'+ve.escape(this.attributes[s])+'"'}t+=">";for(var a=0;a",t},jn=class{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,O2.call(this,e,r,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return B2.call(this,"span")}toMarkup(){return P2.call(this,"span")}},To=class{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,O2.call(this,t,n),this.children=r||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return B2.call(this,"a")}toMarkup(){return P2.call(this,"a")}},cu=class{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement("img");e.src=this.src,e.alt=this.alt,e.className="mord";for(var t in this.style)this.style.hasOwnProperty(t)&&(e.style[t]=this.style[t]);return e}toMarkup(){var e=''+ve.escape(this.alt)+'0&&(t=document.createElement("span"),t.style.marginRight=j(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=Zr(this.classes));for(var r in this.style)this.style.hasOwnProperty(r)&&(t=t||document.createElement("span"),t.style[r]=this.style[r]);return t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t="0&&(r+="margin-right:"+this.italic+"em;");for(var n in this.style)this.style.hasOwnProperty(n)&&(r+=ve.hyphenate(n)+":"+this.style[n]+";");r&&(e=!0,t+=' style="'+ve.escape(r)+'"');var s=ve.escape(this.text);return e?(t+=">",t+=s,t+="",t):s}},Ri=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");for(var r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&t.setAttribute(r,this.attributes[r]);for(var n=0;n':''}},No=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"line");for(var r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&t.setAttribute(r,this.attributes[r]);return t}toMarkup(){var e="","\\gt",!0);u(p,y,N,"\u2208","\\in",!0);u(p,y,N,"\uE020","\\@not");u(p,y,N,"\u2282","\\subset",!0);u(p,y,N,"\u2283","\\supset",!0);u(p,y,N,"\u2286","\\subseteq",!0);u(p,y,N,"\u2287","\\supseteq",!0);u(p,T,N,"\u2288","\\nsubseteq",!0);u(p,T,N,"\u2289","\\nsupseteq",!0);u(p,y,N,"\u22A8","\\models");u(p,y,N,"\u2190","\\leftarrow",!0);u(p,y,N,"\u2264","\\le");u(p,y,N,"\u2264","\\leq",!0);u(p,y,N,"<","\\lt",!0);u(p,y,N,"\u2192","\\rightarrow",!0);u(p,y,N,"\u2192","\\to");u(p,T,N,"\u2271","\\ngeq",!0);u(p,T,N,"\u2270","\\nleq",!0);u(p,y,xr,"\xA0","\\ ");u(p,y,xr,"\xA0","\\space");u(p,y,xr,"\xA0","\\nobreakspace");u(B,y,xr,"\xA0","\\ ");u(B,y,xr,"\xA0"," ");u(B,y,xr,"\xA0","\\space");u(B,y,xr,"\xA0","\\nobreakspace");u(p,y,xr,null,"\\nobreak");u(p,y,xr,null,"\\allowbreak");u(p,y,H0,",",",");u(p,y,H0,";",";");u(p,T,Q,"\u22BC","\\barwedge",!0);u(p,T,Q,"\u22BB","\\veebar",!0);u(p,y,Q,"\u2299","\\odot",!0);u(p,y,Q,"\u2295","\\oplus",!0);u(p,y,Q,"\u2297","\\otimes",!0);u(p,y,k,"\u2202","\\partial",!0);u(p,y,Q,"\u2298","\\oslash",!0);u(p,T,Q,"\u229A","\\circledcirc",!0);u(p,T,Q,"\u22A1","\\boxdot",!0);u(p,y,Q,"\u25B3","\\bigtriangleup");u(p,y,Q,"\u25BD","\\bigtriangledown");u(p,y,Q,"\u2020","\\dagger");u(p,y,Q,"\u22C4","\\diamond");u(p,y,Q,"\u22C6","\\star");u(p,y,Q,"\u25C3","\\triangleleft");u(p,y,Q,"\u25B9","\\triangleright");u(p,y,ri,"{","\\{");u(B,y,k,"{","\\{");u(B,y,k,"{","\\textbraceleft");u(p,y,At,"}","\\}");u(B,y,k,"}","\\}");u(B,y,k,"}","\\textbraceright");u(p,y,ri,"{","\\lbrace");u(p,y,At,"}","\\rbrace");u(p,y,ri,"[","\\lbrack",!0);u(B,y,k,"[","\\lbrack",!0);u(p,y,At,"]","\\rbrack",!0);u(B,y,k,"]","\\rbrack",!0);u(p,y,ri,"(","\\lparen",!0);u(p,y,At,")","\\rparen",!0);u(B,y,k,"<","\\textless",!0);u(B,y,k,">","\\textgreater",!0);u(p,y,ri,"\u230A","\\lfloor",!0);u(p,y,At,"\u230B","\\rfloor",!0);u(p,y,ri,"\u2308","\\lceil",!0);u(p,y,At,"\u2309","\\rceil",!0);u(p,y,k,"\\","\\backslash");u(p,y,k,"\u2223","|");u(p,y,k,"\u2223","\\vert");u(B,y,k,"|","\\textbar",!0);u(p,y,k,"\u2225","\\|");u(p,y,k,"\u2225","\\Vert");u(B,y,k,"\u2225","\\textbardbl");u(B,y,k,"~","\\textasciitilde");u(B,y,k,"\\","\\textbackslash");u(B,y,k,"^","\\textasciicircum");u(p,y,N,"\u2191","\\uparrow",!0);u(p,y,N,"\u21D1","\\Uparrow",!0);u(p,y,N,"\u2193","\\downarrow",!0);u(p,y,N,"\u21D3","\\Downarrow",!0);u(p,y,N,"\u2195","\\updownarrow",!0);u(p,y,N,"\u21D5","\\Updownarrow",!0);u(p,y,Ke,"\u2210","\\coprod");u(p,y,Ke,"\u22C1","\\bigvee");u(p,y,Ke,"\u22C0","\\bigwedge");u(p,y,Ke,"\u2A04","\\biguplus");u(p,y,Ke,"\u22C2","\\bigcap");u(p,y,Ke,"\u22C3","\\bigcup");u(p,y,Ke,"\u222B","\\int");u(p,y,Ke,"\u222B","\\intop");u(p,y,Ke,"\u222C","\\iint");u(p,y,Ke,"\u222D","\\iiint");u(p,y,Ke,"\u220F","\\prod");u(p,y,Ke,"\u2211","\\sum");u(p,y,Ke,"\u2A02","\\bigotimes");u(p,y,Ke,"\u2A01","\\bigoplus");u(p,y,Ke,"\u2A00","\\bigodot");u(p,y,Ke,"\u222E","\\oint");u(p,y,Ke,"\u222F","\\oiint");u(p,y,Ke,"\u2230","\\oiiint");u(p,y,Ke,"\u2A06","\\bigsqcup");u(p,y,Ke,"\u222B","\\smallint");u(B,y,Bs,"\u2026","\\textellipsis");u(p,y,Bs,"\u2026","\\mathellipsis");u(B,y,Bs,"\u2026","\\ldots",!0);u(p,y,Bs,"\u2026","\\ldots",!0);u(p,y,Bs,"\u22EF","\\@cdots",!0);u(p,y,Bs,"\u22F1","\\ddots",!0);u(p,y,k,"\u22EE","\\varvdots");u(B,y,k,"\u22EE","\\varvdots");u(p,y,Be,"\u02CA","\\acute");u(p,y,Be,"\u02CB","\\grave");u(p,y,Be,"\xA8","\\ddot");u(p,y,Be,"~","\\tilde");u(p,y,Be,"\u02C9","\\bar");u(p,y,Be,"\u02D8","\\breve");u(p,y,Be,"\u02C7","\\check");u(p,y,Be,"^","\\hat");u(p,y,Be,"\u20D7","\\vec");u(p,y,Be,"\u02D9","\\dot");u(p,y,Be,"\u02DA","\\mathring");u(p,y,te,"\uE131","\\@imath");u(p,y,te,"\uE237","\\@jmath");u(p,y,k,"\u0131","\u0131");u(p,y,k,"\u0237","\u0237");u(B,y,k,"\u0131","\\i",!0);u(B,y,k,"\u0237","\\j",!0);u(B,y,k,"\xDF","\\ss",!0);u(B,y,k,"\xE6","\\ae",!0);u(B,y,k,"\u0153","\\oe",!0);u(B,y,k,"\xF8","\\o",!0);u(B,y,k,"\xC6","\\AE",!0);u(B,y,k,"\u0152","\\OE",!0);u(B,y,k,"\xD8","\\O",!0);u(B,y,Be,"\u02CA","\\'");u(B,y,Be,"\u02CB","\\`");u(B,y,Be,"\u02C6","\\^");u(B,y,Be,"\u02DC","\\~");u(B,y,Be,"\u02C9","\\=");u(B,y,Be,"\u02D8","\\u");u(B,y,Be,"\u02D9","\\.");u(B,y,Be,"\xB8","\\c");u(B,y,Be,"\u02DA","\\r");u(B,y,Be,"\u02C7","\\v");u(B,y,Be,"\xA8",'\\"');u(B,y,Be,"\u02DD","\\H");u(B,y,Be,"\u25EF","\\textcircled");F2={"--":!0,"---":!0,"``":!0,"''":!0};u(B,y,k,"\u2013","--",!0);u(B,y,k,"\u2013","\\textendash");u(B,y,k,"\u2014","---",!0);u(B,y,k,"\u2014","\\textemdash");u(B,y,k,"\u2018","`",!0);u(B,y,k,"\u2018","\\textquoteleft");u(B,y,k,"\u2019","'",!0);u(B,y,k,"\u2019","\\textquoteright");u(B,y,k,"\u201C","``",!0);u(B,y,k,"\u201C","\\textquotedblleft");u(B,y,k,"\u201D","''",!0);u(B,y,k,"\u201D","\\textquotedblright");u(p,y,k,"\xB0","\\degree",!0);u(B,y,k,"\xB0","\\degree");u(B,y,k,"\xB0","\\textdegree",!0);u(p,y,k,"\xA3","\\pounds");u(p,y,k,"\xA3","\\mathsterling",!0);u(B,y,k,"\xA3","\\pounds");u(B,y,k,"\xA3","\\textsterling",!0);u(p,T,k,"\u2720","\\maltese");u(B,T,k,"\u2720","\\maltese");o2='0123456789/@."';for(w0=0;w00)return Ii(s,h,n,t,a.concat(d));if(l){var c,f;if(l==="boldsymbol"){var m=SN(s,n,t,a,r);c=m.fontName,f=[m.fontClass]}else o?(c=U2[l].fontName,f=[l]):(c=S0(l,t.fontWeight,t.fontShape),f=[l,t.fontWeight,t.fontShape]);if(U0(s,c,n).metrics)return Ii(s,c,n,t,a.concat(f));if(F2.hasOwnProperty(s)&&c.slice(0,10)==="Typewriter"){for(var g=[],x=0;x{if(Zr(i.classes)!==Zr(e.classes)||i.skew!==e.skew||i.maxFontSize!==e.maxFontSize)return!1;if(i.classes.length===1){var t=i.classes[0];if(t==="mbin"||t==="mord")return!1}for(var r in i.style)if(i.style.hasOwnProperty(r)&&i.style[r]!==e.style[r])return!1;for(var n in e.style)if(e.style.hasOwnProperty(n)&&i.style[n]!==e.style[n])return!1;return!0},CN=i=>{for(var e=0;et&&(t=a.height),a.depth>r&&(r=a.depth),a.maxFontSize>n&&(n=a.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=n},Ht=function(e,t,r,n){var s=new jn(e,t,r,n);return Tu(s),s},q2=(i,e,t,r)=>new jn(i,e,t,r),_N=function(e,t,r){var n=Ht([e],[],t);return n.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),n.style.borderBottomWidth=j(n.height),n.maxFontSize=1,n},LN=function(e,t,r,n){var s=new To(e,t,r,n);return Tu(s),s},H2=function(e){var t=new $n(e);return Tu(t),t},zN=function(e,t){return e instanceof $n?Ht([],[e],t):e},IN=function(e){if(e.positionType==="individualShift"){for(var t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth,s=n,a=1;a{var t=Ht(["mspace"],[],e),r=He(i,e);return t.style.marginRight=j(r),t},S0=function(e,t,r){var n="";switch(e){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=e}var s;return t==="textbf"&&r==="textit"?s="BoldItalic":t==="textbf"?s="Bold":t==="textit"?s="Italic":s="Regular",n+"-"+s},U2={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},$2={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},ON=function(e,t){var[r,n,s]=$2[e],a=new Wi(r),o=new Ri([a],{width:j(n),height:j(s),style:"width:"+j(n),viewBox:"0 0 "+1e3*n+" "+1e3*s,preserveAspectRatio:"xMinYMin"}),l=q2(["overlay"],[o],t);return l.height=s,l.style.height=j(s),l.style.width=j(n),l},L={fontMap:U2,makeSymbol:Ii,mathsym:EN,makeSpan:Ht,makeSvgSpan:q2,makeLineSpan:_N,makeAnchor:LN,makeFragment:H2,wrapFragment:zN,makeVList:RN,makeOrd:AN,makeGlue:DN,staticSvg:ON,svgData:$2,tryCombineChars:CN},qe={number:3,unit:"mu"},Un={number:4,unit:"mu"},ur={number:5,unit:"mu"},BN={mord:{mop:qe,mbin:Un,mrel:ur,minner:qe},mop:{mord:qe,mop:qe,mrel:ur,minner:qe},mbin:{mord:Un,mop:Un,mopen:Un,minner:Un},mrel:{mord:ur,mop:ur,mopen:ur,minner:ur},mopen:{},mclose:{mop:qe,mbin:Un,mrel:ur,minner:qe},mpunct:{mord:qe,mop:qe,mrel:ur,mopen:qe,mclose:qe,mpunct:qe,minner:qe},minner:{mord:qe,mop:qe,mbin:Un,mrel:ur,mopen:qe,mpunct:qe,minner:qe}},PN={mord:{mop:qe},mop:{mord:qe,mop:qe},mbin:{},mrel:{},mopen:{},mclose:{mop:qe},mpunct:{},minner:{mop:qe}},j2={},O0={},B0={};P0=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},We=function(e){return e.type==="ordgroup"?e.body:[e]},pr=L.makeSpan,FN=["leftmost","mbin","mopen","mrel","mop","mpunct"],qN=["rightmost","mrel","mclose","mpunct"],HN={display:ie.DISPLAY,text:ie.TEXT,script:ie.SCRIPT,scriptscript:ie.SCRIPTSCRIPT},UN={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},tt=function(e,t,r,n){n===void 0&&(n=[null,null]);for(var s=[],a=0;a{var v=x.classes[0],b=g.classes[0];v==="mbin"&&qN.includes(b)?x.classes[0]="mord":b==="mbin"&&FN.includes(v)&&(g.classes[0]="mord")},{node:c},f,m),d2(s,(g,x)=>{var v=fu(x),b=fu(g),E=v&&b?g.hasClass("mtight")?PN[v][b]:BN[v][b]:null;if(E)return L.makeGlue(E,h)},{node:c},f,m),s},d2=function i(e,t,r,n,s){n&&e.push(n);for(var a=0;af=>{e.splice(c+1,0,f),a++})(a)}n&&e.pop()},G2=function(e){return e instanceof $n||e instanceof To||e instanceof jn&&e.hasClass("enclosing")?e:null},$N=function i(e,t){var r=G2(e);if(r){var n=r.children;if(n.length){if(t==="right")return i(n[n.length-1],"right");if(t==="left")return i(n[0],"left")}}return e},fu=function(e,t){return e?(t&&(e=$N(e,t)),UN[e.classes[0]]||null):null},Eo=function(e,t){var r=["nulldelimiter"].concat(e.baseSizingClasses());return pr(t.concat(r))},pe=function(e,t,r){if(!e)return pr();if(O0[e.type]){var n=O0[e.type](e,t);if(r&&t.size!==r.size){n=pr(t.sizingClasses(r),[n],t);var s=t.sizeMultiplier/r.sizeMultiplier;n.height*=s,n.depth*=s}return n}else throw new U("Got group of unknown type: '"+e.type+"'")};Et=class{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=Zr(this.classes));for(var r=0;r0&&(e+=' class ="'+ve.escape(Zr(this.classes))+'"'),e+=">";for(var r=0;r",e}toText(){return this.children.map(e=>e.toText()).join("")}},gi=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return ve.escape(this.toText())}toText(){return this.text}},pu=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,e>=.05555&&e<=.05556?this.character="\u200A":e>=.1666&&e<=.1667?this.character="\u2009":e>=.2222&&e<=.2223?this.character="\u2005":e>=.2777&&e<=.2778?this.character="\u2005\u200A":e>=-.05556&&e<=-.05555?this.character="\u200A\u2063":e>=-.1667&&e<=-.1666?this.character="\u2009\u2063":e>=-.2223&&e<=-.2222?this.character="\u205F\u2063":e>=-.2778&&e<=-.2777?this.character="\u2005\u2063":this.character=null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",j(this.width)),e}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}},q={MathNode:Et,TextNode:gi,SpaceNode:pu,newDocumentFragment:Y2},xi=function(e,t,r){return Ce[t][e]&&Ce[t][e].replace&&e.charCodeAt(0)!==55349&&!(F2.hasOwnProperty(e)&&r&&(r.fontFamily&&r.fontFamily.slice(4,6)==="tt"||r.font&&r.font.slice(4,6)==="tt"))&&(e=Ce[t][e].replace),new q.TextNode(e)},Nu=function(e){return e.length===1?e[0]:new q.MathNode("mrow",e)},Eu=function(e,t){if(t.fontFamily==="texttt")return"monospace";if(t.fontFamily==="textsf")return t.fontShape==="textit"&&t.fontWeight==="textbf"?"sans-serif-bold-italic":t.fontShape==="textit"?"sans-serif-italic":t.fontWeight==="textbf"?"bold-sans-serif":"sans-serif";if(t.fontShape==="textit"&&t.fontWeight==="textbf")return"bold-italic";if(t.fontShape==="textit")return"italic";if(t.fontWeight==="textbf")return"bold";var r=t.font;if(!r||r==="mathnormal")return null;var n=e.mode;if(r==="mathit")return"italic";if(r==="boldsymbol")return e.type==="textord"?"bold":"bold-italic";if(r==="mathbf")return"bold";if(r==="mathbb")return"double-struck";if(r==="mathsfit")return"sans-serif-italic";if(r==="mathfrak")return"fraktur";if(r==="mathscr"||r==="mathcal")return"script";if(r==="mathsf")return"sans-serif";if(r==="mathtt")return"monospace";var s=e.text;if(["\\imath","\\jmath"].includes(s))return null;Ce[n][s]&&Ce[n][s].replace&&(s=Ce[n][s].replace);var a=L.fontMap[r].fontName;return Mu(s,a,n)?L.fontMap[r].variant:null};jt=function(e,t,r){if(e.length===1){var n=Se(e[0],t);return r&&n instanceof Et&&n.type==="mo"&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}for(var s=[],a,o=0;o=1&&(a.type==="mn"||Jc(a))){var h=l.children[0];h instanceof Et&&h.type==="mn"&&(h.children=[...a.children,...h.children],s.pop())}else if(a.type==="mi"&&a.children.length===1){var d=a.children[0];if(d instanceof gi&&d.text==="\u0338"&&(l.type==="mo"||l.type==="mi"||l.type==="mn")){var c=l.children[0];c instanceof gi&&c.text.length>0&&(c.text=c.text.slice(0,1)+"\u0338"+c.text.slice(1),s.pop())}}}s.push(l),a=l}return s},Qr=function(e,t,r){return Nu(jt(e,t,r))},Se=function(e,t){if(!e)return new q.MathNode("mrow");if(B0[e.type]){var r=B0[e.type](e,t);return r}else throw new U("Got group of unknown type: '"+e.type+"'")};W2=function(e){return new R0({style:e.displayMode?ie.DISPLAY:ie.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},V2=function(e,t){if(t.displayMode){var r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=L.makeSpan(r,[e])}return e},jN=function(e,t,r){var n=W2(r),s;if(r.output==="mathml")return c2(e,t,n,r.displayMode,!0);if(r.output==="html"){var a=mu(e,n);s=L.makeSpan(["katex"],[a])}else{var o=c2(e,t,n,r.displayMode,!1),l=mu(e,n);s=L.makeSpan(["katex"],[o,l])}return V2(s,r)},GN=function(e,t,r){var n=W2(r),s=mu(e,n),a=L.makeSpan(["katex"],[s]);return V2(a,r)},YN={widehat:"^",widecheck:"\u02C7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23DF",overbrace:"\u23DE",overgroup:"\u23E0",undergroup:"\u23E1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21D2",xRightarrow:"\u21D2",overleftharpoon:"\u21BC",xleftharpoonup:"\u21BC",overrightharpoon:"\u21C0",xrightharpoonup:"\u21C0",xLeftarrow:"\u21D0",xLeftrightarrow:"\u21D4",xhookleftarrow:"\u21A9",xhookrightarrow:"\u21AA",xmapsto:"\u21A6",xrightharpoondown:"\u21C1",xleftharpoondown:"\u21BD",xrightleftharpoons:"\u21CC",xleftrightharpoons:"\u21CB",xtwoheadleftarrow:"\u219E",xtwoheadrightarrow:"\u21A0",xlongequal:"=",xtofrom:"\u21C4",xrightleftarrows:"\u21C4",xrightequilibrium:"\u21CC",xleftequilibrium:"\u21CB","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},WN=function(e){var t=new q.MathNode("mo",[new q.TextNode(YN[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},VN={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},XN=function(e){return e.type==="ordgroup"?e.body.length:1},KN=function(e,t){function r(){var o=4e5,l=e.label.slice(1);if(["widehat","widecheck","widetilde","utilde"].includes(l)){var h=e,d=XN(h.base),c,f,m;if(d>5)l==="widehat"||l==="widecheck"?(c=420,o=2364,m=.42,f=l+"4"):(c=312,o=2340,m=.34,f="tilde4");else{var g=[1,1,2,2,3,3][d];l==="widehat"||l==="widecheck"?(o=[0,1062,2364,2364,2364][g],c=[0,239,300,360,420][g],m=[0,.24,.3,.3,.36,.42][g],f=l+g):(o=[0,600,1033,2339,2340][g],c=[0,260,286,306,312][g],m=[0,.26,.286,.3,.306,.34][g],f="tilde"+g)}var x=new Wi(f),v=new Ri([x],{width:"100%",height:j(m),viewBox:"0 0 "+o+" "+c,preserveAspectRatio:"none"});return{span:L.makeSvgSpan([],[v],t),minWidth:0,height:m}}else{var b=[],E=VN[l],[S,C,_]=E,I=_/1e3,O=S.length,D,$;if(O===1){var F=E[3];D=["hide-tail"],$=[F]}else if(O===2)D=["halfarrow-left","halfarrow-right"],$=["xMinYMin","xMaxYMin"];else if(O===3)D=["brace-left","brace-center","brace-right"],$=["xMinYMin","xMidYMin","xMaxYMin"];else throw new Error(`Correct katexImagesData or update code here to support - `+O+" children.");for(var Z=0;Z0&&(n.style.minWidth=j(s)),n},ZN=function(e,t,r,n,s){var a,o=e.height+e.depth+r+n;if(/fbox|color|angl/.test(t)){if(a=L.makeSpan(["stretchy",t],[],s),t==="fbox"){var l=s.color&&s.getColor();l&&(a.style.borderColor=l)}}else{var h=[];/^[bx]cancel$/.test(t)&&h.push(new No({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&h.push(new No({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var d=new Ri(h,{width:"100%",height:j(o)});a=L.makeSvgSpan([],[d],s)}return a.height=o,a.style.height=j(o),a},gr={encloseSpan:ZN,mathMLnode:WN,svgSpan:KN};Au=(i,e)=>{var t,r,n;i&&i.type==="supsub"?(r=le(i.base,"accent"),t=r.base,i.base=t,n=wN(pe(i,e)),i.base=r):(r=le(i,"accent"),t=r.base);var s=pe(t,e.havingCrampedStyle()),a=r.isShifty&&ve.isCharacterBox(t),o=0;if(a){var l=ve.getBaseElem(t),h=pe(l,e.havingCrampedStyle());o=a2(h).skew}var d=r.label==="\\c",c=d?s.height+s.depth:Math.min(s.height,e.fontMetrics().xHeight),f;if(r.isStretchy)f=gr.svgSpan(r,e),f=L.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:f,wrapperClasses:["svg-align"],wrapperStyle:o>0?{width:"calc(100% - "+j(2*o)+")",marginLeft:j(2*o)}:void 0}]},e);else{var m,g;r.label==="\\vec"?(m=L.staticSvg("vec",e),g=L.svgData.vec[1]):(m=L.makeOrd({mode:r.mode,text:r.label},e,"textord"),m=a2(m),m.italic=0,g=m.width,d&&(c+=m.depth)),f=L.makeSpan(["accent-body"],[m]);var x=r.label==="\\textcircled";x&&(f.classes.push("accent-full"),c=s.height);var v=o;x||(v-=g/2),f.style.left=j(v),r.label==="\\textcircled"&&(f.style.top=".2em"),f=L.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-c},{type:"elem",elem:f}]},e)}var b=L.makeSpan(["mord","accent"],[f],e);return n?(n.children[0]=b,n.height=Math.max(b.height,n.height),n.classes[0]="mord",n):b},X2=(i,e)=>{var t=i.isStretchy?gr.mathMLnode(i.label):new q.MathNode("mo",[xi(i.label,i.mode)]),r=new q.MathNode("mover",[Se(i.base,e),t]);return r.setAttribute("accent","true"),r},QN=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(i=>"\\"+i).join("|"));X({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(i,e)=>{var t=P0(e[0]),r=!QN.test(i.funcName),n=!r||i.funcName==="\\widehat"||i.funcName==="\\widetilde"||i.funcName==="\\widecheck";return{type:"accent",mode:i.parser.mode,label:i.funcName,isStretchy:r,isShifty:n,base:t}},htmlBuilder:Au,mathmlBuilder:X2});X({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(i,e)=>{var t=e[0],r=i.parser.mode;return r==="math"&&(i.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+i.funcName+" works only in text mode"),r="text"),{type:"accent",mode:r,label:i.funcName,isStretchy:!1,isShifty:!0,base:t}},htmlBuilder:Au,mathmlBuilder:X2});X({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0];return{type:"accentUnder",mode:t.mode,label:r,base:n}},htmlBuilder:(i,e)=>{var t=pe(i.base,e),r=gr.svgSpan(i,e),n=i.label==="\\utilde"?.12:0,s=L.makeVList({positionType:"top",positionData:t.height,children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:n},{type:"elem",elem:t}]},e);return L.makeSpan(["mord","accentunder"],[s],e)},mathmlBuilder:(i,e)=>{var t=gr.mathMLnode(i.label),r=new q.MathNode("munder",[Se(i.base,e),t]);return r.setAttribute("accentunder","true"),r}});k0=i=>{var e=new q.MathNode("mpadded",i?[i]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};X({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler(i,e,t){var{parser:r,funcName:n}=i;return{type:"xArrow",mode:r.mode,label:n,body:e[0],below:t[0]}},htmlBuilder(i,e){var t=e.style,r=e.havingStyle(t.sup()),n=L.wrapFragment(pe(i.body,r,e),e),s=i.label.slice(0,2)==="\\x"?"x":"cd";n.classes.push(s+"-arrow-pad");var a;i.below&&(r=e.havingStyle(t.sub()),a=L.wrapFragment(pe(i.below,r,e),e),a.classes.push(s+"-arrow-pad"));var o=gr.svgSpan(i,e),l=-e.fontMetrics().axisHeight+.5*o.height,h=-e.fontMetrics().axisHeight-.5*o.height-.111;(n.depth>.25||i.label==="\\xleftequilibrium")&&(h-=n.depth);var d;if(a){var c=-e.fontMetrics().axisHeight+a.height+.5*o.height+.111;d=L.makeVList({positionType:"individualShift",children:[{type:"elem",elem:n,shift:h},{type:"elem",elem:o,shift:l},{type:"elem",elem:a,shift:c}]},e)}else d=L.makeVList({positionType:"individualShift",children:[{type:"elem",elem:n,shift:h},{type:"elem",elem:o,shift:l}]},e);return d.children[0].children[0].children[1].classes.push("svg-align"),L.makeSpan(["mrel","x-arrow"],[d],e)},mathmlBuilder(i,e){var t=gr.mathMLnode(i.label);t.setAttribute("minsize",i.label.charAt(0)==="x"?"1.75em":"3.0em");var r;if(i.body){var n=k0(Se(i.body,e));if(i.below){var s=k0(Se(i.below,e));r=new q.MathNode("munderover",[t,s,n])}else r=new q.MathNode("mover",[t,n])}else if(i.below){var a=k0(Se(i.below,e));r=new q.MathNode("munder",[t,a])}else r=k0(),r=new q.MathNode("mover",[t,r]);return r}});JN=L.makeSpan;X({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];return{type:"mclass",mode:t.mode,mclass:"m"+r.slice(5),body:We(n),isCharacterBox:ve.isCharacterBox(n)}},htmlBuilder:K2,mathmlBuilder:Z2});j0=i=>{var e=i.type==="ordgroup"&&i.body.length?i.body[0]:i;return e.type==="atom"&&(e.family==="bin"||e.family==="rel")?"m"+e.family:"mord"};X({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(i,e){var{parser:t}=i;return{type:"mclass",mode:t.mode,mclass:j0(e[0]),body:We(e[1]),isCharacterBox:ve.isCharacterBox(e[1])}}});X({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(i,e){var{parser:t,funcName:r}=i,n=e[1],s=e[0],a;r!=="\\stackrel"?a=j0(n):a="mrel";var o={type:"op",mode:n.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!=="\\stackrel",body:We(n)},l={type:"supsub",mode:s.mode,base:o,sup:r==="\\underset"?null:s,sub:r==="\\underset"?s:null};return{type:"mclass",mode:t.mode,mclass:a,body:[l],isCharacterBox:ve.isCharacterBox(l)}},htmlBuilder:K2,mathmlBuilder:Z2});X({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(i,e){var{parser:t}=i;return{type:"pmb",mode:t.mode,mclass:j0(e[0]),body:We(e[0])}},htmlBuilder(i,e){var t=tt(i.body,e,!0),r=L.makeSpan([i.mclass],t,e);return r.style.textShadow="0.02em 0.01em 0.04px",r},mathmlBuilder(i,e){var t=jt(i.body,e),r=new q.MathNode("mstyle",t);return r.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),r}});eE={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},u2=()=>({type:"styling",body:[],mode:"math",style:"display"}),f2=i=>i.type==="textord"&&i.text==="@",tE=(i,e)=>(i.type==="mathord"||i.type==="atom")&&i.text===e;X({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(i,e){var{parser:t,funcName:r}=i;return{type:"cdlabel",mode:t.mode,side:r.slice(4),label:e[0]}},htmlBuilder(i,e){var t=e.havingStyle(e.style.sup()),r=L.wrapFragment(pe(i.label,t,e),e);return r.classes.push("cd-label-"+i.side),r.style.bottom=j(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(i,e){var t=new q.MathNode("mrow",[Se(i.label,e)]);return t=new q.MathNode("mpadded",[t]),t.setAttribute("width","0"),i.side==="left"&&t.setAttribute("lspace","-1width"),t.setAttribute("voffset","0.7em"),t=new q.MathNode("mstyle",[t]),t.setAttribute("displaystyle","false"),t.setAttribute("scriptlevel","1"),t}});X({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(i,e){var{parser:t}=i;return{type:"cdlabelparent",mode:t.mode,fragment:e[0]}},htmlBuilder(i,e){var t=L.wrapFragment(pe(i.fragment,e),e);return t.classes.push("cd-vert-arrow"),t},mathmlBuilder(i,e){return new q.MathNode("mrow",[Se(i.fragment,e)])}});X({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(i,e){for(var{parser:t}=i,r=le(e[0],"ordgroup"),n=r.body,s="",a=0;a=1114111)throw new U("\\@char with invalid code point "+s);return l<=65535?h=String.fromCharCode(l):(l-=65536,h=String.fromCharCode((l>>10)+55296,(l&1023)+56320)),{type:"textord",mode:t.mode,text:h}}});Q2=(i,e)=>{var t=tt(i.body,e.withColor(i.color),!1);return L.makeFragment(t)},J2=(i,e)=>{var t=jt(i.body,e.withColor(i.color)),r=new q.MathNode("mstyle",t);return r.setAttribute("mathcolor",i.color),r};X({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(i,e){var{parser:t}=i,r=le(e[0],"color-token").color,n=e[1];return{type:"color",mode:t.mode,color:r,body:We(n)}},htmlBuilder:Q2,mathmlBuilder:J2});X({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(i,e){var{parser:t,breakOnTokenText:r}=i,n=le(e[0],"color-token").color;t.gullet.macros.set("\\current@color",n);var s=t.parseExpression(!0,r);return{type:"color",mode:t.mode,color:n,body:s}},htmlBuilder:Q2,mathmlBuilder:J2});X({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(i,e,t){var{parser:r}=i,n=r.gullet.future().text==="["?r.parseSizeGroup(!0):null,s=!r.settings.displayMode||!r.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:r.mode,newLine:s,size:n&&le(n,"size").value}},htmlBuilder(i,e){var t=L.makeSpan(["mspace"],[],e);return i.newLine&&(t.classes.push("newline"),i.size&&(t.style.marginTop=j(He(i.size,e)))),t},mathmlBuilder(i,e){var t=new q.MathNode("mspace");return i.newLine&&(t.setAttribute("linebreak","newline"),i.size&&t.setAttribute("height",j(He(i.size,e)))),t}});gu={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},e6=i=>{var e=i.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(e))throw new U("Expected a control sequence",i);return e},nE=i=>{var e=i.gullet.popToken();return e.text==="="&&(e=i.gullet.popToken(),e.text===" "&&(e=i.gullet.popToken())),e},t6=(i,e,t,r)=>{var n=i.gullet.macros.get(t.text);n==null&&(t.noexpand=!0,n={tokens:[t],numArgs:0,unexpandable:!i.gullet.isExpandable(t.text)}),i.gullet.macros.set(e,n,r)};X({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(i){var{parser:e,funcName:t}=i;e.consumeSpaces();var r=e.fetch();if(gu[r.text])return(t==="\\global"||t==="\\\\globallong")&&(r.text=gu[r.text]),le(e.parseFunction(),"internal");throw new U("Invalid token after macro prefix",r)}});X({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i){var{parser:e,funcName:t}=i,r=e.gullet.popToken(),n=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(n))throw new U("Expected a control sequence",r);for(var s=0,a,o=[[]];e.gullet.future().text!=="{";)if(r=e.gullet.popToken(),r.text==="#"){if(e.gullet.future().text==="{"){a=e.gullet.future(),o[s].push("{");break}if(r=e.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new U('Invalid argument number "'+r.text+'"');if(parseInt(r.text)!==s+1)throw new U('Argument number "'+r.text+'" out of order');s++,o.push([])}else{if(r.text==="EOF")throw new U("Expected a macro definition");o[s].push(r.text)}var{tokens:l}=e.gullet.consumeArg();return a&&l.unshift(a),(t==="\\edef"||t==="\\xdef")&&(l=e.gullet.expandTokens(l),l.reverse()),e.gullet.macros.set(n,{tokens:l,numArgs:s,delimiters:o},t===gu[t]),{type:"internal",mode:e.mode}}});X({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i){var{parser:e,funcName:t}=i,r=e6(e.gullet.popToken());e.gullet.consumeSpaces();var n=nE(e);return t6(e,r,n,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});X({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i){var{parser:e,funcName:t}=i,r=e6(e.gullet.popToken()),n=e.gullet.popToken(),s=e.gullet.popToken();return t6(e,r,s,t==="\\\\globalfuture"),e.gullet.pushToken(s),e.gullet.pushToken(n),{type:"internal",mode:e.mode}}});yo=function(e,t,r){var n=Ce.math[e]&&Ce.math[e].replace,s=Mu(n||e,t,r);if(!s)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return s},ku=function(e,t,r,n){var s=r.havingBaseStyle(t),a=L.makeSpan(n.concat(s.sizingClasses(r)),[e],r),o=s.sizeMultiplier/r.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=s.sizeMultiplier,a},i6=function(e,t,r){var n=t.havingBaseStyle(r),s=(1-t.sizeMultiplier/n.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=j(s),e.height-=s,e.depth+=s},sE=function(e,t,r,n,s,a){var o=L.makeSymbol(e,"Main-Regular",s,n),l=ku(o,t,n,a);return r&&i6(l,n,t),l},aE=function(e,t,r,n){return L.makeSymbol(e,"Size"+t+"-Regular",r,n)},r6=function(e,t,r,n,s,a){var o=aE(e,t,s,n),l=ku(L.makeSpan(["delimsizing","size"+t],[o],n),ie.TEXT,n,a);return r&&i6(l,n,ie.TEXT),l},eu=function(e,t,r){var n;t==="Size1-Regular"?n="delim-size1":n="delim-size4";var s=L.makeSpan(["delimsizinginner",n],[L.makeSpan([],[L.makeSymbol(e,t,r)])]);return{type:"elem",elem:s}},tu=function(e,t,r){var n=Yi["Size4-Regular"][e.charCodeAt(0)]?Yi["Size4-Regular"][e.charCodeAt(0)][4]:Yi["Size1-Regular"][e.charCodeAt(0)][4],s=new Wi("inner",fN(e,Math.round(1e3*t))),a=new Ri([s],{width:j(n),height:j(t),style:"width:"+j(n),viewBox:"0 0 "+1e3*n+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),o=L.makeSvgSpan([],[a],r);return o.height=t,o.style.height=j(t),o.style.width=j(n),{type:"elem",elem:o}},xu=.008,C0={type:"kern",size:-1*xu},oE=["|","\\lvert","\\rvert","\\vert"],lE=["\\|","\\lVert","\\rVert","\\Vert"],n6=function(e,t,r,n,s,a){var o,l,h,d,c="",f=0;o=h=d=e,l=null;var m="Size1-Regular";e==="\\uparrow"?h=d="\u23D0":e==="\\Uparrow"?h=d="\u2016":e==="\\downarrow"?o=h="\u23D0":e==="\\Downarrow"?o=h="\u2016":e==="\\updownarrow"?(o="\\uparrow",h="\u23D0",d="\\downarrow"):e==="\\Updownarrow"?(o="\\Uparrow",h="\u2016",d="\\Downarrow"):oE.includes(e)?(h="\u2223",c="vert",f=333):lE.includes(e)?(h="\u2225",c="doublevert",f=556):e==="["||e==="\\lbrack"?(o="\u23A1",h="\u23A2",d="\u23A3",m="Size4-Regular",c="lbrack",f=667):e==="]"||e==="\\rbrack"?(o="\u23A4",h="\u23A5",d="\u23A6",m="Size4-Regular",c="rbrack",f=667):e==="\\lfloor"||e==="\u230A"?(h=o="\u23A2",d="\u23A3",m="Size4-Regular",c="lfloor",f=667):e==="\\lceil"||e==="\u2308"?(o="\u23A1",h=d="\u23A2",m="Size4-Regular",c="lceil",f=667):e==="\\rfloor"||e==="\u230B"?(h=o="\u23A5",d="\u23A6",m="Size4-Regular",c="rfloor",f=667):e==="\\rceil"||e==="\u2309"?(o="\u23A4",h=d="\u23A5",m="Size4-Regular",c="rceil",f=667):e==="("||e==="\\lparen"?(o="\u239B",h="\u239C",d="\u239D",m="Size4-Regular",c="lparen",f=875):e===")"||e==="\\rparen"?(o="\u239E",h="\u239F",d="\u23A0",m="Size4-Regular",c="rparen",f=875):e==="\\{"||e==="\\lbrace"?(o="\u23A7",l="\u23A8",d="\u23A9",h="\u23AA",m="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(o="\u23AB",l="\u23AC",d="\u23AD",h="\u23AA",m="Size4-Regular"):e==="\\lgroup"||e==="\u27EE"?(o="\u23A7",d="\u23A9",h="\u23AA",m="Size4-Regular"):e==="\\rgroup"||e==="\u27EF"?(o="\u23AB",d="\u23AD",h="\u23AA",m="Size4-Regular"):e==="\\lmoustache"||e==="\u23B0"?(o="\u23A7",d="\u23AD",h="\u23AA",m="Size4-Regular"):(e==="\\rmoustache"||e==="\u23B1")&&(o="\u23AB",d="\u23A9",h="\u23AA",m="Size4-Regular");var g=yo(o,m,s),x=g.height+g.depth,v=yo(h,m,s),b=v.height+v.depth,E=yo(d,m,s),S=E.height+E.depth,C=0,_=1;if(l!==null){var I=yo(l,m,s);C=I.height+I.depth,_=2}var O=x+S+C,D=Math.max(0,Math.ceil((t-O)/(_*b))),$=O+D*_*b,F=n.fontMetrics().axisHeight;r&&(F*=n.sizeMultiplier);var Z=$/2-F,re=[];if(c.length>0){var ye=$-x-S,G=Math.round($*1e3),W=mN(c,Math.round(ye*1e3)),ee=new Wi(c,W),ae=(f/1e3).toFixed(3)+"em",at=(G/1e3).toFixed(3)+"em",nt=new Ri([ee],{width:ae,height:at,viewBox:"0 0 "+f+" "+G}),hi=L.makeSvgSpan([],[nt],n);hi.height=G/1e3,hi.style.width=ae,hi.style.height=at,re.push({type:"elem",elem:hi})}else{if(re.push(eu(d,m,s)),re.push(C0),l===null){var Jt=$-x-S+2*xu;re.push(tu(h,Jt,n))}else{var It=($-x-S-C)/2+2*xu;re.push(tu(h,It,n)),re.push(C0),re.push(eu(l,m,s)),re.push(C0),re.push(tu(h,It,n))}re.push(C0),re.push(eu(o,m,s))}var Sn=n.havingBaseStyle(ie.TEXT),Ca=L.makeVList({positionType:"bottom",positionData:Z,children:re},Sn);return ku(L.makeSpan(["delimsizing","mult"],[Ca],Sn),ie.TEXT,n,a)},iu=80,ru=.08,nu=function(e,t,r,n,s){var a=uN(e,n,r),o=new Wi(e,a),l=new Ri([o],{width:"400em",height:j(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return L.makeSvgSpan(["hide-tail"],[l],s)},hE=function(e,t){var r=t.havingBaseSizing(),n=l6("\\surd",e*r.sizeMultiplier,o6,r),s=r.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,l=0,h=0,d=0,c;return n.type==="small"?(d=1e3+1e3*a+iu,e<1?s=1:e<1.4&&(s=.7),l=(1+a+ru)/s,h=(1+a)/s,o=nu("sqrtMain",l,d,a,t),o.style.minWidth="0.853em",c=.833/s):n.type==="large"?(d=(1e3+iu)*bo[n.size],h=(bo[n.size]+a)/s,l=(bo[n.size]+a+ru)/s,o=nu("sqrtSize"+n.size,l,d,a,t),o.style.minWidth="1.02em",c=1/s):(l=e+a+ru,h=e+a,d=Math.floor(1e3*e+a)+iu,o=nu("sqrtTall",l,d,a,t),o.style.minWidth="0.742em",c=1.056),o.height=h,o.style.height=j(l),{span:o,advanceWidth:c,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*s}},s6=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","\\surd"],dE=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1"],a6=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],bo=[0,1.2,1.8,2.4,3],cE=function(e,t,r,n,s){if(e==="<"||e==="\\lt"||e==="\u27E8"?e="\\langle":(e===">"||e==="\\gt"||e==="\u27E9")&&(e="\\rangle"),s6.includes(e)||a6.includes(e))return r6(e,t,!1,r,n,s);if(dE.includes(e))return n6(e,bo[t],!1,r,n,s);throw new U("Illegal delimiter: '"+e+"'")},uE=[{type:"small",style:ie.SCRIPTSCRIPT},{type:"small",style:ie.SCRIPT},{type:"small",style:ie.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],fE=[{type:"small",style:ie.SCRIPTSCRIPT},{type:"small",style:ie.SCRIPT},{type:"small",style:ie.TEXT},{type:"stack"}],o6=[{type:"small",style:ie.SCRIPTSCRIPT},{type:"small",style:ie.SCRIPT},{type:"small",style:ie.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],mE=function(e){if(e.type==="small")return"Main-Regular";if(e.type==="large")return"Size"+e.size+"-Regular";if(e.type==="stack")return"Size4-Regular";throw new Error("Add support for delim type '"+e.type+"' here.")},l6=function(e,t,r,n){for(var s=Math.min(2,3-n.style.size),a=s;at)return r[a]}return r[r.length-1]},h6=function(e,t,r,n,s,a){e==="<"||e==="\\lt"||e==="\u27E8"?e="\\langle":(e===">"||e==="\\gt"||e==="\u27E9")&&(e="\\rangle");var o;a6.includes(e)?o=uE:s6.includes(e)?o=o6:o=fE;var l=l6(e,t,o,n);return l.type==="small"?sE(e,l.style,r,n,s,a):l.type==="large"?r6(e,l.size,r,n,s,a):n6(e,t,r,n,s,a)},pE=function(e,t,r,n,s,a){var o=n.fontMetrics().axisHeight*n.sizeMultiplier,l=901,h=5/n.fontMetrics().ptPerEm,d=Math.max(t-o,r+o),c=Math.max(d/500*l,2*d-h);return h6(e,c,!0,n,s,a)},mr={sqrtImage:hE,sizedDelim:cE,sizeToMaxHeight:bo,customSizedDelim:h6,leftRightDelim:pE},m2={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},gE=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27E8","\\rangle","\u27E9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];X({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(i,e)=>{var t=G0(e[0],i);return{type:"delimsizing",mode:i.parser.mode,size:m2[i.funcName].size,mclass:m2[i.funcName].mclass,delim:t.text}},htmlBuilder:(i,e)=>i.delim==="."?L.makeSpan([i.mclass]):mr.sizedDelim(i.delim,i.size,e,i.mode,[i.mclass]),mathmlBuilder:i=>{var e=[];i.delim!=="."&&e.push(xi(i.delim,i.mode));var t=new q.MathNode("mo",e);i.mclass==="mopen"||i.mclass==="mclose"?t.setAttribute("fence","true"):t.setAttribute("fence","false"),t.setAttribute("stretchy","true");var r=j(mr.sizeToMaxHeight[i.size]);return t.setAttribute("minsize",r),t.setAttribute("maxsize",r),t}});X({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var t=i.parser.gullet.macros.get("\\current@color");if(t&&typeof t!="string")throw new U("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:i.parser.mode,delim:G0(e[0],i).text,color:t}}});X({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var t=G0(e[0],i),r=i.parser;++r.leftrightDepth;var n=r.parseExpression(!1);--r.leftrightDepth,r.expect("\\right",!1);var s=le(r.parseFunction(),"leftright-right");return{type:"leftright",mode:r.mode,body:n,left:t.text,right:s.delim,rightColor:s.color}},htmlBuilder:(i,e)=>{p2(i);for(var t=tt(i.body,e,!0,["mopen","mclose"]),r=0,n=0,s=!1,a=0;a{p2(i);var t=jt(i.body,e);if(i.left!=="."){var r=new q.MathNode("mo",[xi(i.left,i.mode)]);r.setAttribute("fence","true"),t.unshift(r)}if(i.right!=="."){var n=new q.MathNode("mo",[xi(i.right,i.mode)]);n.setAttribute("fence","true"),i.rightColor&&n.setAttribute("mathcolor",i.rightColor),t.push(n)}return Nu(t)}});X({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var t=G0(e[0],i);if(!i.parser.leftrightDepth)throw new U("\\middle without preceding \\left",t);return{type:"middle",mode:i.parser.mode,delim:t.text}},htmlBuilder:(i,e)=>{var t;if(i.delim===".")t=Eo(e,[]);else{t=mr.sizedDelim(i.delim,1,e,i.mode,[]);var r={delim:i.delim,options:e};t.isMiddle=r}return t},mathmlBuilder:(i,e)=>{var t=i.delim==="\\vert"||i.delim==="|"?xi("|","text"):xi(i.delim,i.mode),r=new q.MathNode("mo",[t]);return r.setAttribute("fence","true"),r.setAttribute("lspace","0.05em"),r.setAttribute("rspace","0.05em"),r}});Cu=(i,e)=>{var t=L.wrapFragment(pe(i.body,e),e),r=i.label.slice(1),n=e.sizeMultiplier,s,a=0,o=ve.isCharacterBox(i.body);if(r==="sout")s=L.makeSpan(["stretchy","sout"]),s.height=e.fontMetrics().defaultRuleThickness/n,a=-.5*e.fontMetrics().xHeight;else if(r==="phase"){var l=He({number:.6,unit:"pt"},e),h=He({number:.35,unit:"ex"},e),d=e.havingBaseSizing();n=n/d.sizeMultiplier;var c=t.height+t.depth+l+h;t.style.paddingLeft=j(c/2+l);var f=Math.floor(1e3*c*n),m=dN(f),g=new Ri([new Wi("phase",m)],{width:"400em",height:j(f/1e3),viewBox:"0 0 400000 "+f,preserveAspectRatio:"xMinYMin slice"});s=L.makeSvgSpan(["hide-tail"],[g],e),s.style.height=j(c),a=t.depth+l+h}else{/cancel/.test(r)?o||t.classes.push("cancel-pad"):r==="angl"?t.classes.push("anglpad"):t.classes.push("boxpad");var x=0,v=0,b=0;/box/.test(r)?(b=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),x=e.fontMetrics().fboxsep+(r==="colorbox"?0:b),v=x):r==="angl"?(b=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),x=4*b,v=Math.max(0,.25-t.depth)):(x=o?.2:0,v=x),s=gr.encloseSpan(t,r,x,v,e),/fbox|boxed|fcolorbox/.test(r)?(s.style.borderStyle="solid",s.style.borderWidth=j(b)):r==="angl"&&b!==.049&&(s.style.borderTopWidth=j(b),s.style.borderRightWidth=j(b)),a=t.depth+v,i.backgroundColor&&(s.style.backgroundColor=i.backgroundColor,i.borderColor&&(s.style.borderColor=i.borderColor))}var E;if(i.backgroundColor)E=L.makeVList({positionType:"individualShift",children:[{type:"elem",elem:s,shift:a},{type:"elem",elem:t,shift:0}]},e);else{var S=/cancel|phase/.test(r)?["svg-align"]:[];E=L.makeVList({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:s,shift:a,wrapperClasses:S}]},e)}return/cancel/.test(r)&&(E.height=t.height,E.depth=t.depth),/cancel/.test(r)&&!o?L.makeSpan(["mord","cancel-lap"],[E],e):L.makeSpan(["mord"],[E],e)},_u=(i,e)=>{var t=0,r=new q.MathNode(i.label.indexOf("colorbox")>-1?"mpadded":"menclose",[Se(i.body,e)]);switch(i.label){case"\\cancel":r.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":r.setAttribute("notation","downdiagonalstrike");break;case"\\phase":r.setAttribute("notation","phasorangle");break;case"\\sout":r.setAttribute("notation","horizontalstrike");break;case"\\fbox":r.setAttribute("notation","box");break;case"\\angl":r.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(t=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,r.setAttribute("width","+"+2*t+"pt"),r.setAttribute("height","+"+2*t+"pt"),r.setAttribute("lspace",t+"pt"),r.setAttribute("voffset",t+"pt"),i.label==="\\fcolorbox"){var n=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);r.setAttribute("style","border: "+n+"em solid "+String(i.borderColor))}break;case"\\xcancel":r.setAttribute("notation","updiagonalstrike downdiagonalstrike");break}return i.backgroundColor&&r.setAttribute("mathbackground",i.backgroundColor),r};X({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(i,e,t){var{parser:r,funcName:n}=i,s=le(e[0],"color-token").color,a=e[1];return{type:"enclose",mode:r.mode,label:n,backgroundColor:s,body:a}},htmlBuilder:Cu,mathmlBuilder:_u});X({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(i,e,t){var{parser:r,funcName:n}=i,s=le(e[0],"color-token").color,a=le(e[1],"color-token").color,o=e[2];return{type:"enclose",mode:r.mode,label:n,backgroundColor:a,borderColor:s,body:o}},htmlBuilder:Cu,mathmlBuilder:_u});X({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(i,e){var{parser:t}=i;return{type:"enclose",mode:t.mode,label:"\\fbox",body:e[0]}}});X({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout","\\phase"],props:{numArgs:1},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];return{type:"enclose",mode:t.mode,label:r,body:n}},htmlBuilder:Cu,mathmlBuilder:_u});X({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(i,e){var{parser:t}=i;return{type:"enclose",mode:t.mode,label:"\\angl",body:e[0]}}});d6={};c6={};Y0=i=>{var e=i.parser.settings;if(!e.displayMode)throw new U("{"+i.envName+"} can be used only in display mode.")};Xi=function(e,t){var r,n,s=e.body.length,a=e.hLinesBeforeRow,o=0,l=new Array(s),h=[],d=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),c=1/t.fontMetrics().ptPerEm,f=5*c;if(e.colSeparationType&&e.colSeparationType==="small"){var m=t.havingStyle(ie.SCRIPT).sizeMultiplier;f=.2778*(m/t.sizeMultiplier)}var g=e.colSeparationType==="CD"?He({number:3,unit:"ex"},t):12*c,x=3*c,v=e.arraystretch*g,b=.7*v,E=.3*v,S=0;function C(V){for(var J=0;J0&&(S+=.25),h.push({pos:S,isDashed:V[J]})}for(C(a[0]),r=0;r0&&(Z+=E,OV))for(r=0;r=o)){var qr=void 0;(n>0||e.hskipBeforeAndAfter)&&(qr=ve.deflt(It.pregap,f),qr!==0&&(W=L.makeSpan(["arraycolsep"],[]),W.style.width=j(qr),G.push(W)));var ei=[];for(r=0;r0){for(var Dd=L.makeLineSpan("hline",t,d),_a=L.makeLineSpan("hdashline",t,d),La=[{type:"elem",elem:l,shift:0}];h.length>0;){var za=h.pop(),Ia=za.pos-re;za.isDashed?La.push({type:"elem",elem:_a,shift:Ia}):La.push({type:"elem",elem:Dd,shift:Ia})}l=L.makeVList({positionType:"individualShift",children:La},t)}if(ae.length===0)return L.makeSpan(["mord"],[l],t);var z=L.makeVList({positionType:"individualShift",children:ae},t);return z=L.makeSpan(["tag"],[z],t),L.makeFragment([l,z])},xE={c:"center ",l:"left ",r:"right "},Ki=function(e,t){for(var r=[],n=new q.MathNode("mtd",[],["mtr-glue"]),s=new q.MathNode("mtd",[],["mml-eqn-num"]),a=0;a0){var g=e.cols,x="",v=!1,b=0,E=g.length;g[0].type==="separator"&&(f+="top ",b=1),g[g.length-1].type==="separator"&&(f+="bottom ",E-=1);for(var S=b;S0?"left ":"",f+=D[D.length-1].length>0?"right ":"";for(var $=1;$-1?"alignat":"align",s=e.envName==="split",a=Jr(e.parser,{cols:r,addJot:!0,autoTag:s?void 0:Lu(e.envName),emptySingleRow:!0,colSeparationType:n,maxNumCols:s?2:void 0,leqno:e.parser.settings.leqno},"display"),o,l=0,h={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&t[0].type==="ordgroup"){for(var d="",c=0;c0&&m&&(v=1),r[g]={type:"align",align:x,pregap:v,postgap:0}}return a.colSeparationType=m?"align":"alignat",a};Vi({type:"array",names:["array","darray"],props:{numArgs:1},handler(i,e){var t=$0(e[0]),r=t?[e[0]]:le(e[0],"ordgroup").body,n=r.map(function(a){var o=Su(a),l=o.text;if("lcr".indexOf(l)!==-1)return{type:"align",align:l};if(l==="|")return{type:"separator",separator:"|"};if(l===":")return{type:"separator",separator:":"};throw new U("Unknown column alignment: "+l,a)}),s={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return Jr(i.parser,s,zu(i.envName))},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(i){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[i.envName.replace("*","")],t="c",r={hskipBeforeAndAfter:!1,cols:[{type:"align",align:t}]};if(i.envName.charAt(i.envName.length-1)==="*"){var n=i.parser;if(n.consumeSpaces(),n.fetch().text==="["){if(n.consume(),n.consumeSpaces(),t=n.fetch().text,"lcr".indexOf(t)===-1)throw new U("Expected l or c or r",n.nextToken);n.consume(),n.consumeSpaces(),n.expect("]"),n.consume(),r.cols=[{type:"align",align:t}]}}var s=Jr(i.parser,r,zu(i.envName)),a=Math.max(0,...s.body.map(o=>o.length));return s.cols=new Array(a).fill({type:"align",align:t}),e?{type:"leftright",mode:i.mode,body:[s],left:e[0],right:e[1],rightColor:void 0}:s},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(i){var e={arraystretch:.5},t=Jr(i.parser,e,"script");return t.colSeparationType="small",t},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["subarray"],props:{numArgs:1},handler(i,e){var t=$0(e[0]),r=t?[e[0]]:le(e[0],"ordgroup").body,n=r.map(function(a){var o=Su(a),l=o.text;if("lc".indexOf(l)!==-1)return{type:"align",align:l};throw new U("Unknown column alignment: "+l,a)});if(n.length>1)throw new U("{subarray} can contain only one column");var s={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5};if(s=Jr(i.parser,s,"script"),s.body.length>0&&s.body[0].length>1)throw new U("{subarray} can contain only one column");return s},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(i){var e={arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},t=Jr(i.parser,e,zu(i.envName));return{type:"leftright",mode:i.mode,body:[t],left:i.envName.indexOf("r")>-1?".":"\\{",right:i.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:u6,htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(i){["gather","gather*"].includes(i.envName)&&Y0(i);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:Lu(i.envName),emptySingleRow:!0,leqno:i.parser.settings.leqno};return Jr(i.parser,e,"display")},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:u6,htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(i){Y0(i);var e={autoTag:Lu(i.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:i.parser.settings.leqno};return Jr(i.parser,e,"display")},htmlBuilder:Xi,mathmlBuilder:Ki});Vi({type:"array",names:["CD"],props:{numArgs:0},handler(i){return Y0(i),rE(i.parser)},htmlBuilder:Xi,mathmlBuilder:Ki});w("\\nonumber","\\gdef\\@eqnsw{0}");w("\\notag","\\nonumber");X({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(i,e){throw new U(i.funcName+" valid only within array environment")}});x2=d6;X({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];if(n.type!=="ordgroup")throw new U("Invalid environment name",n);for(var s="",a=0;a{var t=i.font,r=e.withFont(t);return pe(i.body,r)},m6=(i,e)=>{var t=i.font,r=e.withFont(t);return Se(i.body,r)},v2={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};X({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathsfit","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=P0(e[0]),s=r;return s in v2&&(s=v2[s]),{type:"font",mode:t.mode,font:s.slice(1),body:n}},htmlBuilder:f6,mathmlBuilder:m6});X({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(i,e)=>{var{parser:t}=i,r=e[0],n=ve.isCharacterBox(r);return{type:"mclass",mode:t.mode,mclass:j0(r),body:[{type:"font",mode:t.mode,font:"boldsymbol",body:r}],isCharacterBox:n}}});X({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(i,e)=>{var{parser:t,funcName:r,breakOnTokenText:n}=i,{mode:s}=t,a=t.parseExpression(!0,n),o="math"+r.slice(1);return{type:"font",mode:s,font:o,body:{type:"ordgroup",mode:t.mode,body:a}}},htmlBuilder:f6,mathmlBuilder:m6});p6=(i,e)=>{var t=e;return i==="display"?t=t.id>=ie.SCRIPT.id?t.text():ie.DISPLAY:i==="text"&&t.size===ie.DISPLAY.size?t=ie.TEXT:i==="script"?t=ie.SCRIPT:i==="scriptscript"&&(t=ie.SCRIPTSCRIPT),t},Iu=(i,e)=>{var t=p6(i.size,e.style),r=t.fracNum(),n=t.fracDen(),s;s=e.havingStyle(r);var a=pe(i.numer,s,e);if(i.continued){var o=8.5/e.fontMetrics().ptPerEm,l=3.5/e.fontMetrics().ptPerEm;a.height=a.height0?g=3*f:g=7*f,x=e.fontMetrics().denom1):(c>0?(m=e.fontMetrics().num2,g=f):(m=e.fontMetrics().num3,g=3*f),x=e.fontMetrics().denom2);var v;if(d){var E=e.fontMetrics().axisHeight;m-a.depth-(E+.5*c){var t=new q.MathNode("mfrac",[Se(i.numer,e),Se(i.denom,e)]);if(!i.hasBarLine)t.setAttribute("linethickness","0px");else if(i.barSize){var r=He(i.barSize,e);t.setAttribute("linethickness",j(r))}var n=p6(i.size,e.style);if(n.size!==e.style.size){t=new q.MathNode("mstyle",[t]);var s=n.size===ie.DISPLAY.size?"true":"false";t.setAttribute("displaystyle",s),t.setAttribute("scriptlevel","0")}if(i.leftDelim!=null||i.rightDelim!=null){var a=[];if(i.leftDelim!=null){var o=new q.MathNode("mo",[new q.TextNode(i.leftDelim.replace("\\",""))]);o.setAttribute("fence","true"),a.push(o)}if(a.push(t),i.rightDelim!=null){var l=new q.MathNode("mo",[new q.TextNode(i.rightDelim.replace("\\",""))]);l.setAttribute("fence","true"),a.push(l)}return Nu(a)}return t};X({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0],s=e[1],a,o=null,l=null,h="auto";switch(r){case"\\dfrac":case"\\frac":case"\\tfrac":a=!0;break;case"\\\\atopfrac":a=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":a=!1,o="(",l=")";break;case"\\\\bracefrac":a=!1,o="\\{",l="\\}";break;case"\\\\brackfrac":a=!1,o="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}switch(r){case"\\dfrac":case"\\dbinom":h="display";break;case"\\tfrac":case"\\tbinom":h="text";break}return{type:"genfrac",mode:t.mode,continued:!1,numer:n,denom:s,hasBarLine:a,leftDelim:o,rightDelim:l,size:h,barSize:null}},htmlBuilder:Iu,mathmlBuilder:Ru});X({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0],s=e[1];return{type:"genfrac",mode:t.mode,continued:!0,numer:n,denom:s,hasBarLine:!0,leftDelim:null,rightDelim:null,size:"display",barSize:null}}});X({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(i){var{parser:e,funcName:t,token:r}=i,n;switch(t){case"\\over":n="\\frac";break;case"\\choose":n="\\binom";break;case"\\atop":n="\\\\atopfrac";break;case"\\brace":n="\\\\bracefrac";break;case"\\brack":n="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:n,token:r}}});y2=["display","text","script","scriptscript"],b2=function(e){var t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};X({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(i,e){var{parser:t}=i,r=e[4],n=e[5],s=P0(e[0]),a=s.type==="atom"&&s.family==="open"?b2(s.text):null,o=P0(e[1]),l=o.type==="atom"&&o.family==="close"?b2(o.text):null,h=le(e[2],"size"),d,c=null;h.isBlank?d=!0:(c=h.value,d=c.number>0);var f="auto",m=e[3];if(m.type==="ordgroup"){if(m.body.length>0){var g=le(m.body[0],"textord");f=y2[Number(g.text)]}}else m=le(m,"textord"),f=y2[Number(m.text)];return{type:"genfrac",mode:t.mode,numer:r,denom:n,continued:!1,hasBarLine:d,barSize:c,leftDelim:a,rightDelim:l,size:f}},htmlBuilder:Iu,mathmlBuilder:Ru});X({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(i,e){var{parser:t,funcName:r,token:n}=i;return{type:"infix",mode:t.mode,replaceWith:"\\\\abovefrac",size:le(e[0],"size").value,token:n}}});X({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0],s=XT(le(e[1],"infix").size),a=e[2],o=s.number>0;return{type:"genfrac",mode:t.mode,numer:n,denom:a,continued:!1,hasBarLine:o,barSize:s,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:Iu,mathmlBuilder:Ru});g6=(i,e)=>{var t=e.style,r,n;i.type==="supsub"?(r=i.sup?pe(i.sup,e.havingStyle(t.sup()),e):pe(i.sub,e.havingStyle(t.sub()),e),n=le(i.base,"horizBrace")):n=le(i,"horizBrace");var s=pe(n.base,e.havingBaseStyle(ie.DISPLAY)),a=gr.svgSpan(n,e),o;if(n.isOver?(o=L.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:a}]},e),o.children[0].children[0].children[1].classes.push("svg-align")):(o=L.makeVList({positionType:"bottom",positionData:s.depth+.1+a.height,children:[{type:"elem",elem:a},{type:"kern",size:.1},{type:"elem",elem:s}]},e),o.children[0].children[0].children[0].classes.push("svg-align")),r){var l=L.makeSpan(["mord",n.isOver?"mover":"munder"],[o],e);n.isOver?o=L.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:r}]},e):o=L.makeVList({positionType:"bottom",positionData:l.depth+.2+r.height+r.depth,children:[{type:"elem",elem:r},{type:"kern",size:.2},{type:"elem",elem:l}]},e)}return L.makeSpan(["mord",n.isOver?"mover":"munder"],[o],e)},vE=(i,e)=>{var t=gr.mathMLnode(i.label);return new q.MathNode(i.isOver?"mover":"munder",[Se(i.base,e),t])};X({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler(i,e){var{parser:t,funcName:r}=i;return{type:"horizBrace",mode:t.mode,label:r,isOver:/^\\over/.test(r),base:e[0]}},htmlBuilder:g6,mathmlBuilder:vE});X({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[1],n=le(e[0],"url").url;return t.settings.isTrusted({command:"\\href",url:n})?{type:"href",mode:t.mode,href:n,body:We(r)}:t.formatUnsupportedCmd("\\href")},htmlBuilder:(i,e)=>{var t=tt(i.body,e,!1);return L.makeAnchor(i.href,[],t,e)},mathmlBuilder:(i,e)=>{var t=Qr(i.body,e);return t instanceof Et||(t=new Et("mrow",[t])),t.setAttribute("href",i.href),t}});X({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=le(e[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:r}))return t.formatUnsupportedCmd("\\url");for(var n=[],s=0;s{var{parser:t,funcName:r,token:n}=i,s=le(e[0],"raw").string,a=e[1];t.settings.strict&&t.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var o,l={};switch(r){case"\\htmlClass":l.class=s,o={command:"\\htmlClass",class:s};break;case"\\htmlId":l.id=s,o={command:"\\htmlId",id:s};break;case"\\htmlStyle":l.style=s,o={command:"\\htmlStyle",style:s};break;case"\\htmlData":{for(var h=s.split(","),d=0;d{var t=tt(i.body,e,!1),r=["enclosing"];i.attributes.class&&r.push(...i.attributes.class.trim().split(/\s+/));var n=L.makeSpan(r,t,e);for(var s in i.attributes)s!=="class"&&i.attributes.hasOwnProperty(s)&&n.setAttribute(s,i.attributes[s]);return n},mathmlBuilder:(i,e)=>Qr(i.body,e)});X({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i;return{type:"htmlmathml",mode:t.mode,html:We(e[0]),mathml:We(e[1])}},htmlBuilder:(i,e)=>{var t=tt(i.html,e,!1);return L.makeFragment(t)},mathmlBuilder:(i,e)=>Qr(i.mathml,e)});su=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new U("Invalid size: '"+e+"' in \\includegraphics");var r={number:+(t[1]+t[2]),unit:t[3]};if(!D2(r))throw new U("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r};X({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(i,e,t)=>{var{parser:r}=i,n={number:0,unit:"em"},s={number:.9,unit:"em"},a={number:0,unit:"em"},o="";if(t[0])for(var l=le(t[0],"raw").string,h=l.split(","),d=0;d{var t=He(i.height,e),r=0;i.totalheight.number>0&&(r=He(i.totalheight,e)-t);var n=0;i.width.number>0&&(n=He(i.width,e));var s={height:j(t+r)};n>0&&(s.width=j(n)),r>0&&(s.verticalAlign=j(-r));var a=new cu(i.src,i.alt,s);return a.height=t,a.depth=r,a},mathmlBuilder:(i,e)=>{var t=new q.MathNode("mglyph",[]);t.setAttribute("alt",i.alt);var r=He(i.height,e),n=0;if(i.totalheight.number>0&&(n=He(i.totalheight,e)-r,t.setAttribute("valign",j(-n))),t.setAttribute("height",j(r+n)),i.width.number>0){var s=He(i.width,e);t.setAttribute("width",j(s))}return t.setAttribute("src",i.src),t}});X({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(i,e){var{parser:t,funcName:r}=i,n=le(e[0],"size");if(t.settings.strict){var s=r[1]==="m",a=n.value.unit==="mu";s?(a||t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+r+" supports only mu units, "+("not "+n.value.unit+" units")),t.mode!=="math"&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+r+" works only in math mode")):a&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+r+" doesn't support mu units")}return{type:"kern",mode:t.mode,dimension:n.value}},htmlBuilder(i,e){return L.makeGlue(i.dimension,e)},mathmlBuilder(i,e){var t=He(i.dimension,e);return new q.SpaceNode(t)}});X({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0];return{type:"lap",mode:t.mode,alignment:r.slice(5),body:n}},htmlBuilder:(i,e)=>{var t;i.alignment==="clap"?(t=L.makeSpan([],[pe(i.body,e)]),t=L.makeSpan(["inner"],[t],e)):t=L.makeSpan(["inner"],[pe(i.body,e)]);var r=L.makeSpan(["fix"],[]),n=L.makeSpan([i.alignment],[t,r],e),s=L.makeSpan(["strut"]);return s.style.height=j(n.height+n.depth),n.depth&&(s.style.verticalAlign=j(-n.depth)),n.children.unshift(s),n=L.makeSpan(["thinbox"],[n],e),L.makeSpan(["mord","vbox"],[n],e)},mathmlBuilder:(i,e)=>{var t=new q.MathNode("mpadded",[Se(i.body,e)]);if(i.alignment!=="rlap"){var r=i.alignment==="llap"?"-1":"-0.5";t.setAttribute("lspace",r+"width")}return t.setAttribute("width","0px"),t}});X({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(i,e){var{funcName:t,parser:r}=i,n=r.mode;r.switchMode("math");var s=t==="\\("?"\\)":"$",a=r.parseExpression(!1,s);return r.expect(s),r.switchMode(n),{type:"styling",mode:r.mode,style:"text",body:a}}});X({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(i,e){throw new U("Mismatched "+i.funcName)}});w2=(i,e)=>{switch(e.style.size){case ie.DISPLAY.size:return i.display;case ie.TEXT.size:return i.text;case ie.SCRIPT.size:return i.script;case ie.SCRIPTSCRIPT.size:return i.scriptscript;default:return i.text}};X({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(i,e)=>{var{parser:t}=i;return{type:"mathchoice",mode:t.mode,display:We(e[0]),text:We(e[1]),script:We(e[2]),scriptscript:We(e[3])}},htmlBuilder:(i,e)=>{var t=w2(i,e),r=tt(t,e,!1);return L.makeFragment(r)},mathmlBuilder:(i,e)=>{var t=w2(i,e);return Qr(t,e)}});x6=(i,e,t,r,n,s,a)=>{i=L.makeSpan([],[i]);var o=t&&ve.isCharacterBox(t),l,h;if(e){var d=pe(e,r.havingStyle(n.sup()),r);h={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-d.depth)}}if(t){var c=pe(t,r.havingStyle(n.sub()),r);l={elem:c,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-c.height)}}var f;if(h&&l){var m=r.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+i.depth+a;f=L.makeVList({positionType:"bottom",positionData:m,children:[{type:"kern",size:r.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:j(-s)},{type:"kern",size:l.kern},{type:"elem",elem:i},{type:"kern",size:h.kern},{type:"elem",elem:h.elem,marginLeft:j(s)},{type:"kern",size:r.fontMetrics().bigOpSpacing5}]},r)}else if(l){var g=i.height-a;f=L.makeVList({positionType:"top",positionData:g,children:[{type:"kern",size:r.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:j(-s)},{type:"kern",size:l.kern},{type:"elem",elem:i}]},r)}else if(h){var x=i.depth+a;f=L.makeVList({positionType:"bottom",positionData:x,children:[{type:"elem",elem:i},{type:"kern",size:h.kern},{type:"elem",elem:h.elem,marginLeft:j(s)},{type:"kern",size:r.fontMetrics().bigOpSpacing5}]},r)}else return i;var v=[f];if(l&&s!==0&&!o){var b=L.makeSpan(["mspace"],[],r);b.style.marginRight=j(s),v.unshift(b)}return L.makeSpan(["mop","op-limits"],v,r)},v6=["\\smallint"],Ps=(i,e)=>{var t,r,n=!1,s;i.type==="supsub"?(t=i.sup,r=i.sub,s=le(i.base,"op"),n=!0):s=le(i,"op");var a=e.style,o=!1;a.size===ie.DISPLAY.size&&s.symbol&&!v6.includes(s.name)&&(o=!0);var l;if(s.symbol){var h=o?"Size2-Regular":"Size1-Regular",d="";if((s.name==="\\oiint"||s.name==="\\oiiint")&&(d=s.name.slice(1),s.name=d==="oiint"?"\\iint":"\\iiint"),l=L.makeSymbol(s.name,h,"math",e,["mop","op-symbol",o?"large-op":"small-op"]),d.length>0){var c=l.italic,f=L.staticSvg(d+"Size"+(o?"2":"1"),e);l=L.makeVList({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:f,shift:o?.08:0}]},e),s.name="\\"+d,l.classes.unshift("mop"),l.italic=c}}else if(s.body){var m=tt(s.body,e,!0);m.length===1&&m[0]instanceof $t?(l=m[0],l.classes[0]="mop"):l=L.makeSpan(["mop"],m,e)}else{for(var g=[],x=1;x{var t;if(i.symbol)t=new Et("mo",[xi(i.name,i.mode)]),v6.includes(i.name)&&t.setAttribute("largeop","false");else if(i.body)t=new Et("mo",jt(i.body,e));else{t=new Et("mi",[new gi(i.name.slice(1))]);var r=new Et("mo",[xi("\u2061","text")]);i.parentIsSupSub?t=new Et("mrow",[t,r]):t=Y2([t,r])}return t},yE={"\u220F":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22C0":"\\bigwedge","\u22C1":"\\bigvee","\u22C2":"\\bigcap","\u22C3":"\\bigcup","\u2A00":"\\bigodot","\u2A01":"\\bigoplus","\u2A02":"\\bigotimes","\u2A04":"\\biguplus","\u2A06":"\\bigsqcup"};X({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","\u220F","\u2210","\u2211","\u22C0","\u22C1","\u22C2","\u22C3","\u2A00","\u2A01","\u2A02","\u2A04","\u2A06"],props:{numArgs:0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=r;return n.length===1&&(n=yE[n]),{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:Ps,mathmlBuilder:So});X({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:We(r)}},htmlBuilder:Ps,mathmlBuilder:So});bE={"\u222B":"\\int","\u222C":"\\iint","\u222D":"\\iiint","\u222E":"\\oint","\u222F":"\\oiint","\u2230":"\\oiiint"};X({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler(i){var{parser:e,funcName:t}=i;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:t}},htmlBuilder:Ps,mathmlBuilder:So});X({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(i){var{parser:e,funcName:t}=i;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:t}},htmlBuilder:Ps,mathmlBuilder:So});X({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222B","\u222C","\u222D","\u222E","\u222F","\u2230"],props:{numArgs:0,allowedInArgument:!0},handler(i){var{parser:e,funcName:t}=i,r=t;return r.length===1&&(r=bE[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:Ps,mathmlBuilder:So});y6=(i,e)=>{var t,r,n=!1,s;i.type==="supsub"?(t=i.sup,r=i.sub,s=le(i.base,"operatorname"),n=!0):s=le(i,"operatorname");var a;if(s.body.length>0){for(var o=s.body.map(c=>{var f=c.text;return typeof f=="string"?{type:"textord",mode:c.mode,text:f}:c}),l=tt(o,e.withFont("mathrm"),!0),h=0;h{for(var t=jt(i.body,e.withFont("mathrm")),r=!0,n=0;nd.toText()).join("");t=[new q.TextNode(o)]}var l=new q.MathNode("mi",t);l.setAttribute("mathvariant","normal");var h=new q.MathNode("mo",[xi("\u2061","text")]);return i.parentIsSupSub?new q.MathNode("mrow",[l,h]):q.newDocumentFragment([l,h])};X({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0];return{type:"operatorname",mode:t.mode,body:We(n),alwaysHandleSupSub:r==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:y6,mathmlBuilder:wE});w("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");Gn({type:"ordgroup",htmlBuilder(i,e){return i.semisimple?L.makeFragment(tt(i.body,e,!1)):L.makeSpan(["mord"],tt(i.body,e,!0),e)},mathmlBuilder(i,e){return Qr(i.body,e,!0)}});X({type:"overline",names:["\\overline"],props:{numArgs:1},handler(i,e){var{parser:t}=i,r=e[0];return{type:"overline",mode:t.mode,body:r}},htmlBuilder(i,e){var t=pe(i.body,e.havingCrampedStyle()),r=L.makeLineSpan("overline-line",e),n=e.fontMetrics().defaultRuleThickness,s=L.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:3*n},{type:"elem",elem:r},{type:"kern",size:n}]},e);return L.makeSpan(["mord","overline"],[s],e)},mathmlBuilder(i,e){var t=new q.MathNode("mo",[new q.TextNode("\u203E")]);t.setAttribute("stretchy","true");var r=new q.MathNode("mover",[Se(i.body,e),t]);return r.setAttribute("accent","true"),r}});X({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"phantom",mode:t.mode,body:We(r)}},htmlBuilder:(i,e)=>{var t=tt(i.body,e.withPhantom(),!1);return L.makeFragment(t)},mathmlBuilder:(i,e)=>{var t=jt(i.body,e);return new q.MathNode("mphantom",t)}});X({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"hphantom",mode:t.mode,body:r}},htmlBuilder:(i,e)=>{var t=L.makeSpan([],[pe(i.body,e.withPhantom())]);if(t.height=0,t.depth=0,t.children)for(var r=0;r{var t=jt(We(i.body),e),r=new q.MathNode("mphantom",t),n=new q.MathNode("mpadded",[r]);return n.setAttribute("height","0px"),n.setAttribute("depth","0px"),n}});X({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"vphantom",mode:t.mode,body:r}},htmlBuilder:(i,e)=>{var t=L.makeSpan(["inner"],[pe(i.body,e.withPhantom())]),r=L.makeSpan(["fix"],[]);return L.makeSpan(["mord","rlap"],[t,r],e)},mathmlBuilder:(i,e)=>{var t=jt(We(i.body),e),r=new q.MathNode("mphantom",t),n=new q.MathNode("mpadded",[r]);return n.setAttribute("width","0px"),n}});X({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(i,e){var{parser:t}=i,r=le(e[0],"size").value,n=e[1];return{type:"raisebox",mode:t.mode,dy:r,body:n}},htmlBuilder(i,e){var t=pe(i.body,e),r=He(i.dy,e);return L.makeVList({positionType:"shift",positionData:-r,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(i,e){var t=new q.MathNode("mpadded",[Se(i.body,e)]),r=i.dy.number+i.dy.unit;return t.setAttribute("voffset",r),t}});X({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler(i){var{parser:e}=i;return{type:"internal",mode:e.mode}}});X({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler(i,e,t){var{parser:r}=i,n=t[0],s=le(e[0],"size"),a=le(e[1],"size");return{type:"rule",mode:r.mode,shift:n&&le(n,"size").value,width:s.value,height:a.value}},htmlBuilder(i,e){var t=L.makeSpan(["mord","rule"],[],e),r=He(i.width,e),n=He(i.height,e),s=i.shift?He(i.shift,e):0;return t.style.borderRightWidth=j(r),t.style.borderTopWidth=j(n),t.style.bottom=j(s),t.width=r,t.height=n+s,t.depth=-s,t.maxFontSize=n*1.125*e.sizeMultiplier,t},mathmlBuilder(i,e){var t=He(i.width,e),r=He(i.height,e),n=i.shift?He(i.shift,e):0,s=e.color&&e.getColor()||"black",a=new q.MathNode("mspace");a.setAttribute("mathbackground",s),a.setAttribute("width",j(t)),a.setAttribute("height",j(r));var o=new q.MathNode("mpadded",[a]);return n>=0?o.setAttribute("height",j(n)):(o.setAttribute("height",j(n)),o.setAttribute("depth",j(-n))),o.setAttribute("voffset",j(n)),o}});M2=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],ME=(i,e)=>{var t=e.havingSize(i.size);return b6(i.body,t,e)};X({type:"sizing",names:M2,props:{numArgs:0,allowedInText:!0},handler:(i,e)=>{var{breakOnTokenText:t,funcName:r,parser:n}=i,s=n.parseExpression(!1,t);return{type:"sizing",mode:n.mode,size:M2.indexOf(r)+1,body:s}},htmlBuilder:ME,mathmlBuilder:(i,e)=>{var t=e.havingSize(i.size),r=jt(i.body,t),n=new q.MathNode("mstyle",r);return n.setAttribute("mathsize",j(t.sizeMultiplier)),n}});X({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(i,e,t)=>{var{parser:r}=i,n=!1,s=!1,a=t[0]&&le(t[0],"ordgroup");if(a)for(var o="",l=0;l{var t=L.makeSpan([],[pe(i.body,e)]);if(!i.smashHeight&&!i.smashDepth)return t;if(i.smashHeight&&(t.height=0,t.children))for(var r=0;r{var t=new q.MathNode("mpadded",[Se(i.body,e)]);return i.smashHeight&&t.setAttribute("height","0px"),i.smashDepth&&t.setAttribute("depth","0px"),t}});X({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(i,e,t){var{parser:r}=i,n=t[0],s=e[0];return{type:"sqrt",mode:r.mode,body:s,index:n}},htmlBuilder(i,e){var t=pe(i.body,e.havingCrampedStyle());t.height===0&&(t.height=e.fontMetrics().xHeight),t=L.wrapFragment(t,e);var r=e.fontMetrics(),n=r.defaultRuleThickness,s=n;e.style.idt.height+t.depth+a&&(a=(a+c-t.height-t.depth)/2);var f=l.height-t.height-a-h;t.style.paddingLeft=j(d);var m=L.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t,wrapperClasses:["svg-align"]},{type:"kern",size:-(t.height+f)},{type:"elem",elem:l},{type:"kern",size:h}]},e);if(i.index){var g=e.havingStyle(ie.SCRIPTSCRIPT),x=pe(i.index,g,e),v=.6*(m.height-m.depth),b=L.makeVList({positionType:"shift",positionData:-v,children:[{type:"elem",elem:x}]},e),E=L.makeSpan(["root"],[b]);return L.makeSpan(["mord","sqrt"],[E,m],e)}else return L.makeSpan(["mord","sqrt"],[m],e)},mathmlBuilder(i,e){var{body:t,index:r}=i;return r?new q.MathNode("mroot",[Se(t,e),Se(r,e)]):new q.MathNode("msqrt",[Se(t,e)])}});T2={display:ie.DISPLAY,text:ie.TEXT,script:ie.SCRIPT,scriptscript:ie.SCRIPTSCRIPT};X({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i,e){var{breakOnTokenText:t,funcName:r,parser:n}=i,s=n.parseExpression(!0,t),a=r.slice(1,r.length-5);return{type:"styling",mode:n.mode,style:a,body:s}},htmlBuilder(i,e){var t=T2[i.style],r=e.havingStyle(t).withFont("");return b6(i.body,r,e)},mathmlBuilder(i,e){var t=T2[i.style],r=e.havingStyle(t),n=jt(i.body,r),s=new q.MathNode("mstyle",n),a={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]},o=a[i.style];return s.setAttribute("scriptlevel",o[0]),s.setAttribute("displaystyle",o[1]),s}});TE=function(e,t){var r=e.base;if(r)if(r.type==="op"){var n=r.limits&&(t.style.size===ie.DISPLAY.size||r.alwaysHandleSupSub);return n?Ps:null}else if(r.type==="operatorname"){var s=r.alwaysHandleSupSub&&(t.style.size===ie.DISPLAY.size||r.limits);return s?y6:null}else{if(r.type==="accent")return ve.isCharacterBox(r.base)?Au:null;if(r.type==="horizBrace"){var a=!e.sub;return a===r.isOver?g6:null}else return null}else return null};Gn({type:"supsub",htmlBuilder(i,e){var t=TE(i,e);if(t)return t(i,e);var{base:r,sup:n,sub:s}=i,a=pe(r,e),o,l,h=e.fontMetrics(),d=0,c=0,f=r&&ve.isCharacterBox(r);if(n){var m=e.havingStyle(e.style.sup());o=pe(n,m,e),f||(d=a.height-m.fontMetrics().supDrop*m.sizeMultiplier/e.sizeMultiplier)}if(s){var g=e.havingStyle(e.style.sub());l=pe(s,g,e),f||(c=a.depth+g.fontMetrics().subDrop*g.sizeMultiplier/e.sizeMultiplier)}var x;e.style===ie.DISPLAY?x=h.sup1:e.style.cramped?x=h.sup3:x=h.sup2;var v=e.sizeMultiplier,b=j(.5/h.ptPerEm/v),E=null;if(l){var S=i.base&&i.base.type==="op"&&i.base.name&&(i.base.name==="\\oiint"||i.base.name==="\\oiiint");(a instanceof $t||S)&&(E=j(-a.italic))}var C;if(o&&l){d=Math.max(d,x,o.depth+.25*h.xHeight),c=Math.max(c,h.sub2);var _=h.defaultRuleThickness,I=4*_;if(d-o.depth-(l.height-c)0&&(d+=O,c-=O)}var D=[{type:"elem",elem:l,shift:c,marginRight:b,marginLeft:E},{type:"elem",elem:o,shift:-d,marginRight:b}];C=L.makeVList({positionType:"individualShift",children:D},e)}else if(l){c=Math.max(c,h.sub1,l.height-.8*h.xHeight);var $=[{type:"elem",elem:l,marginLeft:E,marginRight:b}];C=L.makeVList({positionType:"shift",positionData:c,children:$},e)}else if(o)d=Math.max(d,x,o.depth+.25*h.xHeight),C=L.makeVList({positionType:"shift",positionData:-d,children:[{type:"elem",elem:o,marginRight:b}]},e);else throw new Error("supsub must have either sup or sub.");var F=fu(a,"right")||"mord";return L.makeSpan([F],[a,L.makeSpan(["msupsub"],[C])],e)},mathmlBuilder(i,e){var t=!1,r,n;i.base&&i.base.type==="horizBrace"&&(n=!!i.sup,n===i.base.isOver&&(t=!0,r=i.base.isOver)),i.base&&(i.base.type==="op"||i.base.type==="operatorname")&&(i.base.parentIsSupSub=!0);var s=[Se(i.base,e)];i.sub&&s.push(Se(i.sub,e)),i.sup&&s.push(Se(i.sup,e));var a;if(t)a=r?"mover":"munder";else if(i.sub)if(i.sup){var h=i.base;h&&h.type==="op"&&h.limits&&e.style===ie.DISPLAY||h&&h.type==="operatorname"&&h.alwaysHandleSupSub&&(e.style===ie.DISPLAY||h.limits)?a="munderover":a="msubsup"}else{var l=i.base;l&&l.type==="op"&&l.limits&&(e.style===ie.DISPLAY||l.alwaysHandleSupSub)||l&&l.type==="operatorname"&&l.alwaysHandleSupSub&&(l.limits||e.style===ie.DISPLAY)?a="munder":a="msub"}else{var o=i.base;o&&o.type==="op"&&o.limits&&(e.style===ie.DISPLAY||o.alwaysHandleSupSub)||o&&o.type==="operatorname"&&o.alwaysHandleSupSub&&(o.limits||e.style===ie.DISPLAY)?a="mover":a="msup"}return new q.MathNode(a,s)}});Gn({type:"atom",htmlBuilder(i,e){return L.mathsym(i.text,i.mode,e,["m"+i.family])},mathmlBuilder(i,e){var t=new q.MathNode("mo",[xi(i.text,i.mode)]);if(i.family==="bin"){var r=Eu(i,e);r==="bold-italic"&&t.setAttribute("mathvariant",r)}else i.family==="punct"?t.setAttribute("separator","true"):(i.family==="open"||i.family==="close")&&t.setAttribute("stretchy","false");return t}});w6={mi:"italic",mn:"normal",mtext:"normal"};Gn({type:"mathord",htmlBuilder(i,e){return L.makeOrd(i,e,"mathord")},mathmlBuilder(i,e){var t=new q.MathNode("mi",[xi(i.text,i.mode,e)]),r=Eu(i,e)||"italic";return r!==w6[t.type]&&t.setAttribute("mathvariant",r),t}});Gn({type:"textord",htmlBuilder(i,e){return L.makeOrd(i,e,"textord")},mathmlBuilder(i,e){var t=xi(i.text,i.mode,e),r=Eu(i,e)||"normal",n;return i.mode==="text"?n=new q.MathNode("mtext",[t]):/[0-9]/.test(i.text)?n=new q.MathNode("mn",[t]):i.text==="\\prime"?n=new q.MathNode("mo",[t]):n=new q.MathNode("mi",[t]),r!==w6[n.type]&&n.setAttribute("mathvariant",r),n}});au={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},ou={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};Gn({type:"spacing",htmlBuilder(i,e){if(ou.hasOwnProperty(i.text)){var t=ou[i.text].className||"";if(i.mode==="text"){var r=L.makeOrd(i,e,"textord");return r.classes.push(t),r}else return L.makeSpan(["mspace",t],[L.mathsym(i.text,i.mode,e)],e)}else{if(au.hasOwnProperty(i.text))return L.makeSpan(["mspace",au[i.text]],[],e);throw new U('Unknown type of space "'+i.text+'"')}},mathmlBuilder(i,e){var t;if(ou.hasOwnProperty(i.text))t=new q.MathNode("mtext",[new q.TextNode("\xA0")]);else{if(au.hasOwnProperty(i.text))return new q.MathNode("mspace");throw new U('Unknown type of space "'+i.text+'"')}return t}});N2=()=>{var i=new q.MathNode("mtd",[]);return i.setAttribute("width","50%"),i};Gn({type:"tag",mathmlBuilder(i,e){var t=new q.MathNode("mtable",[new q.MathNode("mtr",[N2(),new q.MathNode("mtd",[Qr(i.body,e)]),N2(),new q.MathNode("mtd",[Qr(i.tag,e)])])]);return t.setAttribute("width","100%"),t}});E2={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},S2={"\\textbf":"textbf","\\textmd":"textmd"},NE={"\\textit":"textit","\\textup":"textup"},A2=(i,e)=>{var t=i.font;if(t){if(E2[t])return e.withTextFontFamily(E2[t]);if(S2[t])return e.withTextFontWeight(S2[t]);if(t==="\\emph")return e.fontShape==="textit"?e.withTextFontShape("textup"):e.withTextFontShape("textit")}else return e;return e.withTextFontShape(NE[t])};X({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];return{type:"text",mode:t.mode,body:We(n),font:r}},htmlBuilder(i,e){var t=A2(i,e),r=tt(i.body,t,!0);return L.makeSpan(["mord","text"],r,t)},mathmlBuilder(i,e){var t=A2(i,e);return Qr(i.body,t)}});X({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(i,e){var{parser:t}=i;return{type:"underline",mode:t.mode,body:e[0]}},htmlBuilder(i,e){var t=pe(i.body,e),r=L.makeLineSpan("underline-line",e),n=e.fontMetrics().defaultRuleThickness,s=L.makeVList({positionType:"top",positionData:t.height,children:[{type:"kern",size:n},{type:"elem",elem:r},{type:"kern",size:3*n},{type:"elem",elem:t}]},e);return L.makeSpan(["mord","underline"],[s],e)},mathmlBuilder(i,e){var t=new q.MathNode("mo",[new q.TextNode("\u203E")]);t.setAttribute("stretchy","true");var r=new q.MathNode("munder",[Se(i.body,e),t]);return r.setAttribute("accentunder","true"),r}});X({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(i,e){var{parser:t}=i;return{type:"vcenter",mode:t.mode,body:e[0]}},htmlBuilder(i,e){var t=pe(i.body,e),r=e.fontMetrics().axisHeight,n=.5*(t.height-r-(t.depth+r));return L.makeVList({positionType:"shift",positionData:n,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(i,e){return new q.MathNode("mpadded",[Se(i.body,e)],["vcenter"])}});X({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(i,e,t){throw new U("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(i,e){for(var t=k2(i),r=[],n=e.havingStyle(e.style.text()),s=0;si.body.replace(/ /g,i.star?"\u2423":"\xA0"),Kr=j2,M6=`[ \r - ]`,EE="\\\\[a-zA-Z@]+",SE="\\\\[^\uD800-\uDFFF]",AE="("+EE+")"+M6+"*",kE=`\\\\( +-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw new Error("Unknown stretchy delimiter.")}},ms=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;tt.toText();return this.children.map(e).join("")}},dr={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},hh={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},O6={\u00C5:"A",\u00D0:"D",\u00DE:"o",\u00E5:"a",\u00F0:"d",\u00FE:"o",\u0410:"A",\u0411:"B",\u0412:"B",\u0413:"F",\u0414:"A",\u0415:"E",\u0416:"K",\u0417:"3",\u0418:"N",\u0419:"N",\u041A:"K",\u041B:"N",\u041C:"M",\u041D:"H",\u041E:"O",\u041F:"N",\u0420:"P",\u0421:"C",\u0422:"T",\u0423:"y",\u0424:"O",\u0425:"X",\u0426:"U",\u0427:"h",\u0428:"W",\u0429:"W",\u042A:"B",\u042B:"X",\u042C:"B",\u042D:"3",\u042E:"X",\u042F:"R",\u0430:"a",\u0431:"b",\u0432:"a",\u0433:"r",\u0434:"y",\u0435:"e",\u0436:"m",\u0437:"e",\u0438:"n",\u0439:"n",\u043A:"n",\u043B:"n",\u043C:"m",\u043D:"n",\u043E:"o",\u043F:"n",\u0440:"p",\u0441:"c",\u0442:"o",\u0443:"y",\u0444:"b",\u0445:"x",\u0446:"n",\u0447:"n",\u0448:"w",\u0449:"w",\u044A:"a",\u044B:"m",\u044C:"a",\u044D:"e",\u044E:"m",\u044F:"r"};Zu={};IS=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],B6=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],P6=function(e,t){return t.size<2?e:IS[e-1][t.size-1]},Th=class i{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||i.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=B6[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){var t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return new i(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:P6(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:B6[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=P6(i.BASESIZE,e);return this.size===t&&this.textSize===i.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==i.BASESIZE?["sizing","reset-size"+this.size,"size"+i.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=LS(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}};Th.BASESIZE=6;c1={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},zS={ex:!0,em:!0,mu:!0},m4=function(e){return typeof e!="string"&&(e=e.unit),e in c1||e in zS||e==="ex"},Xe=function(e,t){var r;if(e.unit in c1)r=c1[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit==="mu")r=t.fontMetrics().cssEmPerMu;else{var n;if(t.style.isTight()?n=t.havingStyle(t.style.text()):n=t,e.unit==="ex")r=n.fontMetrics().xHeight;else if(e.unit==="em")r=n.fontMetrics().quad;else throw new G("Invalid unit: '"+e.unit+"'");n!==t&&(r*=n.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},V=function(e){return+e.toFixed(4)+"em"},yn=function(e){return e.filter(t=>t).join(" ")},p4=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");var n=t.getColor();n&&(this.style.color=n)}},g4=function(e){var t=document.createElement(e);t.className=yn(this.classes);for(var r in this.style)this.style.hasOwnProperty(r)&&(t.style[r]=this.style[r]);for(var n in this.attributes)this.attributes.hasOwnProperty(n)&&t.setAttribute(n,this.attributes[n]);for(var s=0;s/=\x00-\x1f]/,x4=function(e){var t="<"+e;this.classes.length&&(t+=' class="'+Ne.escape(yn(this.classes))+'"');var r="";for(var n in this.style)this.style.hasOwnProperty(n)&&(r+=Ne.hyphenate(n)+":"+this.style[n]+";");r&&(t+=' style="'+Ne.escape(r)+'"');for(var s in this.attributes)if(this.attributes.hasOwnProperty(s)){if(RS.test(s))throw new G("Invalid attribute name '"+s+"'");t+=" "+s+'="'+Ne.escape(this.attributes[s])+'"'}t+=">";for(var a=0;a",t},ps=class{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,p4.call(this,e,r,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return g4.call(this,"span")}toMarkup(){return x4.call(this,"span")}},el=class{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,p4.call(this,t,n),this.children=r||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return g4.call(this,"a")}toMarkup(){return x4.call(this,"a")}},u1=class{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement("img");e.src=this.src,e.alt=this.alt,e.className="mord";for(var t in this.style)this.style.hasOwnProperty(t)&&(e.style[t]=this.style[t]);return e}toMarkup(){var e=''+Ne.escape(this.alt)+'0&&(t=document.createElement("span"),t.style.marginRight=V(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=yn(this.classes));for(var r in this.style)this.style.hasOwnProperty(r)&&(t=t||document.createElement("span"),t.style[r]=this.style[r]);return t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t="0&&(r+="margin-right:"+this.italic+"em;");for(var n in this.style)this.style.hasOwnProperty(n)&&(r+=Ne.hyphenate(n)+":"+this.style[n]+";");r&&(e=!0,t+=' style="'+Ne.escape(r)+'"');var s=Ne.escape(this.text);return e?(t+=">",t+=s,t+="",t):s}},Xi=class{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");for(var r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&t.setAttribute(r,this.attributes[r]);for(var n=0;n':''}},tl=class{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"line");for(var r in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,r)&&t.setAttribute(r,this.attributes[r]);return t}toMarkup(){var e="","\\gt",!0);u(p,v,E,"\u2208","\\in",!0);u(p,v,E,"\uE020","\\@not");u(p,v,E,"\u2282","\\subset",!0);u(p,v,E,"\u2283","\\supset",!0);u(p,v,E,"\u2286","\\subseteq",!0);u(p,v,E,"\u2287","\\supseteq",!0);u(p,N,E,"\u2288","\\nsubseteq",!0);u(p,N,E,"\u2289","\\nsupseteq",!0);u(p,v,E,"\u22A8","\\models");u(p,v,E,"\u2190","\\leftarrow",!0);u(p,v,E,"\u2264","\\le");u(p,v,E,"\u2264","\\leq",!0);u(p,v,E,"<","\\lt",!0);u(p,v,E,"\u2192","\\rightarrow",!0);u(p,v,E,"\u2192","\\to");u(p,N,E,"\u2271","\\ngeq",!0);u(p,N,E,"\u2270","\\nleq",!0);u(p,v,Dr,"\xA0","\\ ");u(p,v,Dr,"\xA0","\\space");u(p,v,Dr,"\xA0","\\nobreakspace");u(H,v,Dr,"\xA0","\\ ");u(H,v,Dr,"\xA0"," ");u(H,v,Dr,"\xA0","\\space");u(H,v,Dr,"\xA0","\\nobreakspace");u(p,v,Dr,null,"\\nobreak");u(p,v,Dr,null,"\\allowbreak");u(p,v,_h,",",",");u(p,v,_h,";",";");u(p,N,ie,"\u22BC","\\barwedge",!0);u(p,N,ie,"\u22BB","\\veebar",!0);u(p,v,ie,"\u2299","\\odot",!0);u(p,v,ie,"\u2295","\\oplus",!0);u(p,v,ie,"\u2297","\\otimes",!0);u(p,v,_,"\u2202","\\partial",!0);u(p,v,ie,"\u2298","\\oslash",!0);u(p,N,ie,"\u229A","\\circledcirc",!0);u(p,N,ie,"\u22A1","\\boxdot",!0);u(p,v,ie,"\u25B3","\\bigtriangleup");u(p,v,ie,"\u25BD","\\bigtriangledown");u(p,v,ie,"\u2020","\\dagger");u(p,v,ie,"\u22C4","\\diamond");u(p,v,ie,"\u22C6","\\star");u(p,v,ie,"\u25C3","\\triangleleft");u(p,v,ie,"\u25B9","\\triangleright");u(p,v,fi,"{","\\{");u(H,v,_,"{","\\{");u(H,v,_,"{","\\textbraceleft");u(p,v,Ft,"}","\\}");u(H,v,_,"}","\\}");u(H,v,_,"}","\\textbraceright");u(p,v,fi,"{","\\lbrace");u(p,v,Ft,"}","\\rbrace");u(p,v,fi,"[","\\lbrack",!0);u(H,v,_,"[","\\lbrack",!0);u(p,v,Ft,"]","\\rbrack",!0);u(H,v,_,"]","\\rbrack",!0);u(p,v,fi,"(","\\lparen",!0);u(p,v,Ft,")","\\rparen",!0);u(H,v,_,"<","\\textless",!0);u(H,v,_,">","\\textgreater",!0);u(p,v,fi,"\u230A","\\lfloor",!0);u(p,v,Ft,"\u230B","\\rfloor",!0);u(p,v,fi,"\u2308","\\lceil",!0);u(p,v,Ft,"\u2309","\\rceil",!0);u(p,v,_,"\\","\\backslash");u(p,v,_,"\u2223","|");u(p,v,_,"\u2223","\\vert");u(H,v,_,"|","\\textbar",!0);u(p,v,_,"\u2225","\\|");u(p,v,_,"\u2225","\\Vert");u(H,v,_,"\u2225","\\textbardbl");u(H,v,_,"~","\\textasciitilde");u(H,v,_,"\\","\\textbackslash");u(H,v,_,"^","\\textasciicircum");u(p,v,E,"\u2191","\\uparrow",!0);u(p,v,E,"\u21D1","\\Uparrow",!0);u(p,v,E,"\u2193","\\downarrow",!0);u(p,v,E,"\u21D3","\\Downarrow",!0);u(p,v,E,"\u2195","\\updownarrow",!0);u(p,v,E,"\u21D5","\\Updownarrow",!0);u(p,v,ot,"\u2210","\\coprod");u(p,v,ot,"\u22C1","\\bigvee");u(p,v,ot,"\u22C0","\\bigwedge");u(p,v,ot,"\u2A04","\\biguplus");u(p,v,ot,"\u22C2","\\bigcap");u(p,v,ot,"\u22C3","\\bigcup");u(p,v,ot,"\u222B","\\int");u(p,v,ot,"\u222B","\\intop");u(p,v,ot,"\u222C","\\iint");u(p,v,ot,"\u222D","\\iiint");u(p,v,ot,"\u220F","\\prod");u(p,v,ot,"\u2211","\\sum");u(p,v,ot,"\u2A02","\\bigotimes");u(p,v,ot,"\u2A01","\\bigoplus");u(p,v,ot,"\u2A00","\\bigodot");u(p,v,ot,"\u222E","\\oint");u(p,v,ot,"\u222F","\\oiint");u(p,v,ot,"\u2230","\\oiiint");u(p,v,ot,"\u2A06","\\bigsqcup");u(p,v,ot,"\u222B","\\smallint");u(H,v,ma,"\u2026","\\textellipsis");u(p,v,ma,"\u2026","\\mathellipsis");u(H,v,ma,"\u2026","\\ldots",!0);u(p,v,ma,"\u2026","\\ldots",!0);u(p,v,ma,"\u22EF","\\@cdots",!0);u(p,v,ma,"\u22F1","\\ddots",!0);u(p,v,_,"\u22EE","\\varvdots");u(H,v,_,"\u22EE","\\varvdots");u(p,v,je,"\u02CA","\\acute");u(p,v,je,"\u02CB","\\grave");u(p,v,je,"\xA8","\\ddot");u(p,v,je,"~","\\tilde");u(p,v,je,"\u02C9","\\bar");u(p,v,je,"\u02D8","\\breve");u(p,v,je,"\u02C7","\\check");u(p,v,je,"^","\\hat");u(p,v,je,"\u20D7","\\vec");u(p,v,je,"\u02D9","\\dot");u(p,v,je,"\u02DA","\\mathring");u(p,v,se,"\uE131","\\@imath");u(p,v,se,"\uE237","\\@jmath");u(p,v,_,"\u0131","\u0131");u(p,v,_,"\u0237","\u0237");u(H,v,_,"\u0131","\\i",!0);u(H,v,_,"\u0237","\\j",!0);u(H,v,_,"\xDF","\\ss",!0);u(H,v,_,"\xE6","\\ae",!0);u(H,v,_,"\u0153","\\oe",!0);u(H,v,_,"\xF8","\\o",!0);u(H,v,_,"\xC6","\\AE",!0);u(H,v,_,"\u0152","\\OE",!0);u(H,v,_,"\xD8","\\O",!0);u(H,v,je,"\u02CA","\\'");u(H,v,je,"\u02CB","\\`");u(H,v,je,"\u02C6","\\^");u(H,v,je,"\u02DC","\\~");u(H,v,je,"\u02C9","\\=");u(H,v,je,"\u02D8","\\u");u(H,v,je,"\u02D9","\\.");u(H,v,je,"\xB8","\\c");u(H,v,je,"\u02DA","\\r");u(H,v,je,"\u02C7","\\v");u(H,v,je,"\xA8",'\\"');u(H,v,je,"\u02DD","\\H");u(H,v,je,"\u25EF","\\textcircled");y4={"--":!0,"---":!0,"``":!0,"''":!0};u(H,v,_,"\u2013","--",!0);u(H,v,_,"\u2013","\\textendash");u(H,v,_,"\u2014","---",!0);u(H,v,_,"\u2014","\\textemdash");u(H,v,_,"\u2018","`",!0);u(H,v,_,"\u2018","\\textquoteleft");u(H,v,_,"\u2019","'",!0);u(H,v,_,"\u2019","\\textquoteright");u(H,v,_,"\u201C","``",!0);u(H,v,_,"\u201C","\\textquotedblleft");u(H,v,_,"\u201D","''",!0);u(H,v,_,"\u201D","\\textquotedblright");u(p,v,_,"\xB0","\\degree",!0);u(H,v,_,"\xB0","\\degree");u(H,v,_,"\xB0","\\textdegree",!0);u(p,v,_,"\xA3","\\pounds");u(p,v,_,"\xA3","\\mathsterling",!0);u(H,v,_,"\xA3","\\pounds");u(H,v,_,"\xA3","\\textsterling",!0);u(p,N,_,"\u2720","\\maltese");u(H,N,_,"\u2720","\\maltese");q6='0123456789/@."';for(dh=0;dh0)return Yi(s,h,n,t,a.concat(d));if(l){var c,f;if(l==="boldsymbol"){var m=HS(s,n,t,a,r);c=m.fontName,f=[m.fontClass]}else o?(c=w4[l].fontName,f=[l]):(c=ph(l,t.fontWeight,t.fontShape),f=[l,t.fontWeight,t.fontShape]);if(Lh(s,c,n).metrics)return Yi(s,c,n,t,a.concat(f));if(y4.hasOwnProperty(s)&&c.slice(0,10)==="Typewriter"){for(var g=[],x=0;x{if(yn(i.classes)!==yn(e.classes)||i.skew!==e.skew||i.maxFontSize!==e.maxFontSize)return!1;if(i.classes.length===1){var t=i.classes[0];if(t==="mbin"||t==="mord")return!1}for(var r in i.style)if(i.style.hasOwnProperty(r)&&i.style[r]!==e.style[r])return!1;for(var n in e.style)if(e.style.hasOwnProperty(n)&&i.style[n]!==e.style[n])return!1;return!0},jS=i=>{for(var e=0;et&&(t=a.height),a.depth>r&&(r=a.depth),a.maxFontSize>n&&(n=a.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=n},Qt=function(e,t,r,n){var s=new ps(e,t,r,n);return N1(s),s},v4=(i,e,t,r)=>new ps(i,e,t,r),GS=function(e,t,r){var n=Qt([e],[],t);return n.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),n.style.borderBottomWidth=V(n.height),n.maxFontSize=1,n},VS=function(e,t,r,n){var s=new el(e,t,r,n);return N1(s),s},b4=function(e){var t=new ms(e);return N1(t),t},WS=function(e,t){return e instanceof ms?Qt([],[e],t):e},YS=function(e){if(e.positionType==="individualShift"){for(var t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth,s=n,a=1;a{var t=Qt(["mspace"],[],e),r=Xe(i,e);return t.style.marginRight=V(r),t},ph=function(e,t,r){var n="";switch(e){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=e}var s;return t==="textbf"&&r==="textit"?s="BoldItalic":t==="textbf"?s="Bold":t==="textit"?s="Italic":s="Regular",n+"-"+s},w4={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},M4={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},ZS=function(e,t){var[r,n,s]=M4[e],a=new cr(r),o=new Xi([a],{width:V(n),height:V(s),style:"width:"+V(n),viewBox:"0 0 "+1e3*n+" "+1e3*s,preserveAspectRatio:"xMinYMin"}),l=v4(["overlay"],[o],t);return l.height=s,l.style.height=V(s),l.style.width=V(n),l},z={fontMap:w4,makeSymbol:Yi,mathsym:qS,makeSpan:Qt,makeSvgSpan:v4,makeLineSpan:GS,makeAnchor:VS,makeFragment:b4,wrapFragment:WS,makeVList:XS,makeOrd:US,makeGlue:KS,staticSvg:ZS,svgData:M4,tryCombineChars:jS},Ye={number:3,unit:"mu"},fs={number:4,unit:"mu"},_r={number:5,unit:"mu"},QS={mord:{mop:Ye,mbin:fs,mrel:_r,minner:Ye},mop:{mord:Ye,mop:Ye,mrel:_r,minner:Ye},mbin:{mord:fs,mop:fs,mopen:fs,minner:fs},mrel:{mord:_r,mop:_r,mopen:_r,minner:_r},mopen:{},mclose:{mop:Ye,mbin:fs,mrel:_r,minner:Ye},mpunct:{mord:Ye,mop:Ye,mrel:_r,mopen:Ye,mclose:Ye,mpunct:Ye,minner:Ye},minner:{mord:Ye,mop:Ye,mbin:fs,mrel:_r,mopen:Ye,mpunct:Ye,minner:Ye}},JS={mord:{mop:Ye},mop:{mord:Ye,mop:Ye},mbin:{},mrel:{},mopen:{},mclose:{mop:Ye},mpunct:{},minner:{mop:Ye}},T4={},Eh={},Sh={};Ah=function(e){return e.type==="ordgroup"&&e.body.length===1?e.body[0]:e},rt=function(e){return e.type==="ordgroup"?e.body:[e]},zr=z.makeSpan,eA=["leftmost","mbin","mopen","mrel","mop","mpunct"],tA=["rightmost","mrel","mclose","mpunct"],iA={display:ae.DISPLAY,text:ae.TEXT,script:ae.SCRIPT,scriptscript:ae.SCRIPTSCRIPT},rA={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},ct=function(e,t,r,n){n===void 0&&(n=[null,null]);for(var s=[],a=0;a{var y=x.classes[0],b=g.classes[0];y==="mbin"&&tA.includes(b)?x.classes[0]="mord":b==="mbin"&&eA.includes(y)&&(g.classes[0]="mord")},{node:c},f,m),$6(s,(g,x)=>{var y=m1(x),b=m1(g),S=y&&b?g.hasClass("mtight")?JS[y][b]:QS[y][b]:null;if(S)return z.makeGlue(S,h)},{node:c},f,m),s},$6=function i(e,t,r,n,s){n&&e.push(n);for(var a=0;af=>{e.splice(c+1,0,f),a++})(a)}n&&e.pop()},N4=function(e){return e instanceof ms||e instanceof el||e instanceof ps&&e.hasClass("enclosing")?e:null},nA=function i(e,t){var r=N4(e);if(r){var n=r.children;if(n.length){if(t==="right")return i(n[n.length-1],"right");if(t==="left")return i(n[0],"left")}}return e},m1=function(e,t){return e?(t&&(e=nA(e,t)),rA[e.classes[0]]||null):null},il=function(e,t){var r=["nulldelimiter"].concat(e.baseSizingClasses());return zr(t.concat(r))},Me=function(e,t,r){if(!e)return zr();if(Eh[e.type]){var n=Eh[e.type](e,t);if(r&&t.size!==r.size){n=zr(t.sizingClasses(r),[n],t);var s=t.sizeMultiplier/r.sizeMultiplier;n.height*=s,n.depth*=s}return n}else throw new G("Got group of unknown type: '"+e.type+"'")};Bt=class{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=yn(this.classes));for(var r=0;r0&&(e+=' class ="'+Ne.escape(yn(this.classes))+'"'),e+=">";for(var r=0;r",e}toText(){return this.children.map(e=>e.toText()).join("")}},ki=class{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return Ne.escape(this.toText())}toText(){return this.text}},g1=class{constructor(e){this.width=void 0,this.character=void 0,this.width=e,e>=.05555&&e<=.05556?this.character="\u200A":e>=.1666&&e<=.1667?this.character="\u2009":e>=.2222&&e<=.2223?this.character="\u2005":e>=.2777&&e<=.2778?this.character="\u2005\u200A":e>=-.05556&&e<=-.05555?this.character="\u200A\u2063":e>=-.1667&&e<=-.1666?this.character="\u2009\u2063":e>=-.2223&&e<=-.2222?this.character="\u205F\u2063":e>=-.2778&&e<=-.2777?this.character="\u2005\u2063":this.character=null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",V(this.width)),e}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}},$={MathNode:Bt,TextNode:ki,SpaceNode:g1,newDocumentFragment:E4},Ci=function(e,t,r){return Oe[t][e]&&Oe[t][e].replace&&e.charCodeAt(0)!==55349&&!(y4.hasOwnProperty(e)&&r&&(r.fontFamily&&r.fontFamily.slice(4,6)==="tt"||r.font&&r.font.slice(4,6)==="tt"))&&(e=Oe[t][e].replace),new $.TextNode(e)},E1=function(e){return e.length===1?e[0]:new $.MathNode("mrow",e)},S1=function(e,t){if(t.fontFamily==="texttt")return"monospace";if(t.fontFamily==="textsf")return t.fontShape==="textit"&&t.fontWeight==="textbf"?"sans-serif-bold-italic":t.fontShape==="textit"?"sans-serif-italic":t.fontWeight==="textbf"?"bold-sans-serif":"sans-serif";if(t.fontShape==="textit"&&t.fontWeight==="textbf")return"bold-italic";if(t.fontShape==="textit")return"italic";if(t.fontWeight==="textbf")return"bold";var r=t.font;if(!r||r==="mathnormal")return null;var n=e.mode;if(r==="mathit")return"italic";if(r==="boldsymbol")return e.type==="textord"?"bold":"bold-italic";if(r==="mathbf")return"bold";if(r==="mathbb")return"double-struck";if(r==="mathsfit")return"sans-serif-italic";if(r==="mathfrak")return"fraktur";if(r==="mathscr"||r==="mathcal")return"script";if(r==="mathsf")return"sans-serif";if(r==="mathtt")return"monospace";var s=e.text;if(["\\imath","\\jmath"].includes(s))return null;Oe[n][s]&&Oe[n][s].replace&&(s=Oe[n][s].replace);var a=z.fontMap[r].fontName;return T1(s,a,n)?z.fontMap[r].variant:null};ti=function(e,t,r){if(e.length===1){var n=ze(e[0],t);return r&&n instanceof Bt&&n.type==="mo"&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}for(var s=[],a,o=0;o=1&&(a.type==="mn"||e1(a))){var h=l.children[0];h instanceof Bt&&h.type==="mn"&&(h.children=[...a.children,...h.children],s.pop())}else if(a.type==="mi"&&a.children.length===1){var d=a.children[0];if(d instanceof ki&&d.text==="\u0338"&&(l.type==="mo"||l.type==="mi"||l.type==="mn")){var c=l.children[0];c instanceof ki&&c.text.length>0&&(c.text=c.text.slice(0,1)+"\u0338"+c.text.slice(1),s.pop())}}}s.push(l),a=l}return s},vn=function(e,t,r){return E1(ti(e,t,r))},ze=function(e,t){if(!e)return new $.MathNode("mrow");if(Sh[e.type]){var r=Sh[e.type](e,t);return r}else throw new G("Got group of unknown type: '"+e.type+"'")};S4=function(e){return new Th({style:e.displayMode?ae.DISPLAY:ae.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},A4=function(e,t){if(t.displayMode){var r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=z.makeSpan(r,[e])}return e},sA=function(e,t,r){var n=S4(r),s;if(r.output==="mathml")return j6(e,t,n,r.displayMode,!0);if(r.output==="html"){var a=p1(e,n);s=z.makeSpan(["katex"],[a])}else{var o=j6(e,t,n,r.displayMode,!1),l=p1(e,n);s=z.makeSpan(["katex"],[o,l])}return A4(s,r)},aA=function(e,t,r){var n=S4(r),s=p1(e,n),a=z.makeSpan(["katex"],[s]);return A4(a,r)},oA={widehat:"^",widecheck:"\u02C7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23DF",overbrace:"\u23DE",overgroup:"\u23E0",undergroup:"\u23E1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21D2",xRightarrow:"\u21D2",overleftharpoon:"\u21BC",xleftharpoonup:"\u21BC",overrightharpoon:"\u21C0",xrightharpoonup:"\u21C0",xLeftarrow:"\u21D0",xLeftrightarrow:"\u21D4",xhookleftarrow:"\u21A9",xhookrightarrow:"\u21AA",xmapsto:"\u21A6",xrightharpoondown:"\u21C1",xleftharpoondown:"\u21BD",xrightleftharpoons:"\u21CC",xleftrightharpoons:"\u21CB",xtwoheadleftarrow:"\u219E",xtwoheadrightarrow:"\u21A0",xlongequal:"=",xtofrom:"\u21C4",xrightleftarrows:"\u21C4",xrightequilibrium:"\u21CC",xleftequilibrium:"\u21CB","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},lA=function(e){var t=new $.MathNode("mo",[new $.TextNode(oA[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},hA={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},dA=function(e){return e.type==="ordgroup"?e.body.length:1},cA=function(e,t){function r(){var o=4e5,l=e.label.slice(1);if(["widehat","widecheck","widetilde","utilde"].includes(l)){var h=e,d=dA(h.base),c,f,m;if(d>5)l==="widehat"||l==="widecheck"?(c=420,o=2364,m=.42,f=l+"4"):(c=312,o=2340,m=.34,f="tilde4");else{var g=[1,1,2,2,3,3][d];l==="widehat"||l==="widecheck"?(o=[0,1062,2364,2364,2364][g],c=[0,239,300,360,420][g],m=[0,.24,.3,.3,.36,.42][g],f=l+g):(o=[0,600,1033,2339,2340][g],c=[0,260,286,306,312][g],m=[0,.26,.286,.3,.306,.34][g],f="tilde"+g)}var x=new cr(f),y=new Xi([x],{width:"100%",height:V(m),viewBox:"0 0 "+o+" "+c,preserveAspectRatio:"none"});return{span:z.makeSvgSpan([],[y],t),minWidth:0,height:m}}else{var b=[],S=hA[l],[A,C,I]=S,O=I/1e3,q=A.length,P,W;if(q===1){var ne=S[3];P=["hide-tail"],W=[ne]}else if(q===2)P=["halfarrow-left","halfarrow-right"],W=["xMinYMin","xMaxYMin"];else if(q===3)P=["brace-left","brace-center","brace-right"],W=["xMinYMin","xMidYMin","xMaxYMin"];else throw new Error(`Correct katexImagesData or update code here to support + `+q+" children.");for(var re=0;re0&&(n.style.minWidth=V(s)),n},uA=function(e,t,r,n,s){var a,o=e.height+e.depth+r+n;if(/fbox|color|angl/.test(t)){if(a=z.makeSpan(["stretchy",t],[],s),t==="fbox"){var l=s.color&&s.getColor();l&&(a.style.borderColor=l)}}else{var h=[];/^[bx]cancel$/.test(t)&&h.push(new tl({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&h.push(new tl({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var d=new Xi(h,{width:"100%",height:V(o)});a=z.makeSvgSpan([],[d],s)}return a.height=o,a.style.height=V(o),a},Rr={encloseSpan:uA,mathMLnode:lA,svgSpan:cA};k1=(i,e)=>{var t,r,n;i&&i.type==="supsub"?(r=me(i.base,"accent"),t=r.base,i.base=t,n=OS(Me(i,e)),i.base=r):(r=me(i,"accent"),t=r.base);var s=Me(t,e.havingCrampedStyle()),a=r.isShifty&&Ne.isCharacterBox(t),o=0;if(a){var l=Ne.getBaseElem(t),h=Me(l,e.havingCrampedStyle());o=F6(h).skew}var d=r.label==="\\c",c=d?s.height+s.depth:Math.min(s.height,e.fontMetrics().xHeight),f;if(r.isStretchy)f=Rr.svgSpan(r,e),f=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:f,wrapperClasses:["svg-align"],wrapperStyle:o>0?{width:"calc(100% - "+V(2*o)+")",marginLeft:V(2*o)}:void 0}]},e);else{var m,g;r.label==="\\vec"?(m=z.staticSvg("vec",e),g=z.svgData.vec[1]):(m=z.makeOrd({mode:r.mode,text:r.label},e,"textord"),m=F6(m),m.italic=0,g=m.width,d&&(c+=m.depth)),f=z.makeSpan(["accent-body"],[m]);var x=r.label==="\\textcircled";x&&(f.classes.push("accent-full"),c=s.height);var y=o;x||(y-=g/2),f.style.left=V(y),r.label==="\\textcircled"&&(f.style.top=".2em"),f=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-c},{type:"elem",elem:f}]},e)}var b=z.makeSpan(["mord","accent"],[f],e);return n?(n.children[0]=b,n.height=Math.max(b.height,n.height),n.classes[0]="mord",n):b},k4=(i,e)=>{var t=i.isStretchy?Rr.mathMLnode(i.label):new $.MathNode("mo",[Ci(i.label,i.mode)]),r=new $.MathNode("mover",[ze(i.base,e),t]);return r.setAttribute("accent","true"),r},fA=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(i=>"\\"+i).join("|"));Z({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(i,e)=>{var t=Ah(e[0]),r=!fA.test(i.funcName),n=!r||i.funcName==="\\widehat"||i.funcName==="\\widetilde"||i.funcName==="\\widecheck";return{type:"accent",mode:i.parser.mode,label:i.funcName,isStretchy:r,isShifty:n,base:t}},htmlBuilder:k1,mathmlBuilder:k4});Z({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(i,e)=>{var t=e[0],r=i.parser.mode;return r==="math"&&(i.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+i.funcName+" works only in text mode"),r="text"),{type:"accent",mode:r,label:i.funcName,isStretchy:!1,isShifty:!0,base:t}},htmlBuilder:k1,mathmlBuilder:k4});Z({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0];return{type:"accentUnder",mode:t.mode,label:r,base:n}},htmlBuilder:(i,e)=>{var t=Me(i.base,e),r=Rr.svgSpan(i,e),n=i.label==="\\utilde"?.12:0,s=z.makeVList({positionType:"top",positionData:t.height,children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:n},{type:"elem",elem:t}]},e);return z.makeSpan(["mord","accentunder"],[s],e)},mathmlBuilder:(i,e)=>{var t=Rr.mathMLnode(i.label),r=new $.MathNode("munder",[ze(i.base,e),t]);return r.setAttribute("accentunder","true"),r}});xh=i=>{var e=new $.MathNode("mpadded",i?[i]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};Z({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler(i,e,t){var{parser:r,funcName:n}=i;return{type:"xArrow",mode:r.mode,label:n,body:e[0],below:t[0]}},htmlBuilder(i,e){var t=e.style,r=e.havingStyle(t.sup()),n=z.wrapFragment(Me(i.body,r,e),e),s=i.label.slice(0,2)==="\\x"?"x":"cd";n.classes.push(s+"-arrow-pad");var a;i.below&&(r=e.havingStyle(t.sub()),a=z.wrapFragment(Me(i.below,r,e),e),a.classes.push(s+"-arrow-pad"));var o=Rr.svgSpan(i,e),l=-e.fontMetrics().axisHeight+.5*o.height,h=-e.fontMetrics().axisHeight-.5*o.height-.111;(n.depth>.25||i.label==="\\xleftequilibrium")&&(h-=n.depth);var d;if(a){var c=-e.fontMetrics().axisHeight+a.height+.5*o.height+.111;d=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:n,shift:h},{type:"elem",elem:o,shift:l},{type:"elem",elem:a,shift:c}]},e)}else d=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:n,shift:h},{type:"elem",elem:o,shift:l}]},e);return d.children[0].children[0].children[1].classes.push("svg-align"),z.makeSpan(["mrel","x-arrow"],[d],e)},mathmlBuilder(i,e){var t=Rr.mathMLnode(i.label);t.setAttribute("minsize",i.label.charAt(0)==="x"?"1.75em":"3.0em");var r;if(i.body){var n=xh(ze(i.body,e));if(i.below){var s=xh(ze(i.below,e));r=new $.MathNode("munderover",[t,s,n])}else r=new $.MathNode("mover",[t,n])}else if(i.below){var a=xh(ze(i.below,e));r=new $.MathNode("munder",[t,a])}else r=xh(),r=new $.MathNode("mover",[t,r]);return r}});mA=z.makeSpan;Z({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];return{type:"mclass",mode:t.mode,mclass:"m"+r.slice(5),body:rt(n),isCharacterBox:Ne.isCharacterBox(n)}},htmlBuilder:C4,mathmlBuilder:_4});zh=i=>{var e=i.type==="ordgroup"&&i.body.length?i.body[0]:i;return e.type==="atom"&&(e.family==="bin"||e.family==="rel")?"m"+e.family:"mord"};Z({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(i,e){var{parser:t}=i;return{type:"mclass",mode:t.mode,mclass:zh(e[0]),body:rt(e[1]),isCharacterBox:Ne.isCharacterBox(e[1])}}});Z({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(i,e){var{parser:t,funcName:r}=i,n=e[1],s=e[0],a;r!=="\\stackrel"?a=zh(n):a="mrel";var o={type:"op",mode:n.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:r!=="\\stackrel",body:rt(n)},l={type:"supsub",mode:s.mode,base:o,sup:r==="\\underset"?null:s,sub:r==="\\underset"?s:null};return{type:"mclass",mode:t.mode,mclass:a,body:[l],isCharacterBox:Ne.isCharacterBox(l)}},htmlBuilder:C4,mathmlBuilder:_4});Z({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(i,e){var{parser:t}=i;return{type:"pmb",mode:t.mode,mclass:zh(e[0]),body:rt(e[0])}},htmlBuilder(i,e){var t=ct(i.body,e,!0),r=z.makeSpan([i.mclass],t,e);return r.style.textShadow="0.02em 0.01em 0.04px",r},mathmlBuilder(i,e){var t=ti(i.body,e),r=new $.MathNode("mstyle",t);return r.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),r}});pA={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},G6=()=>({type:"styling",body:[],mode:"math",style:"display"}),V6=i=>i.type==="textord"&&i.text==="@",gA=(i,e)=>(i.type==="mathord"||i.type==="atom")&&i.text===e;Z({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(i,e){var{parser:t,funcName:r}=i;return{type:"cdlabel",mode:t.mode,side:r.slice(4),label:e[0]}},htmlBuilder(i,e){var t=e.havingStyle(e.style.sup()),r=z.wrapFragment(Me(i.label,t,e),e);return r.classes.push("cd-label-"+i.side),r.style.bottom=V(.8-r.depth),r.height=0,r.depth=0,r},mathmlBuilder(i,e){var t=new $.MathNode("mrow",[ze(i.label,e)]);return t=new $.MathNode("mpadded",[t]),t.setAttribute("width","0"),i.side==="left"&&t.setAttribute("lspace","-1width"),t.setAttribute("voffset","0.7em"),t=new $.MathNode("mstyle",[t]),t.setAttribute("displaystyle","false"),t.setAttribute("scriptlevel","1"),t}});Z({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(i,e){var{parser:t}=i;return{type:"cdlabelparent",mode:t.mode,fragment:e[0]}},htmlBuilder(i,e){var t=z.wrapFragment(Me(i.fragment,e),e);return t.classes.push("cd-vert-arrow"),t},mathmlBuilder(i,e){return new $.MathNode("mrow",[ze(i.fragment,e)])}});Z({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(i,e){for(var{parser:t}=i,r=me(e[0],"ordgroup"),n=r.body,s="",a=0;a=1114111)throw new G("\\@char with invalid code point "+s);return l<=65535?h=String.fromCharCode(l):(l-=65536,h=String.fromCharCode((l>>10)+55296,(l&1023)+56320)),{type:"textord",mode:t.mode,text:h}}});L4=(i,e)=>{var t=ct(i.body,e.withColor(i.color),!1);return z.makeFragment(t)},I4=(i,e)=>{var t=ti(i.body,e.withColor(i.color)),r=new $.MathNode("mstyle",t);return r.setAttribute("mathcolor",i.color),r};Z({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(i,e){var{parser:t}=i,r=me(e[0],"color-token").color,n=e[1];return{type:"color",mode:t.mode,color:r,body:rt(n)}},htmlBuilder:L4,mathmlBuilder:I4});Z({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(i,e){var{parser:t,breakOnTokenText:r}=i,n=me(e[0],"color-token").color;t.gullet.macros.set("\\current@color",n);var s=t.parseExpression(!0,r);return{type:"color",mode:t.mode,color:n,body:s}},htmlBuilder:L4,mathmlBuilder:I4});Z({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(i,e,t){var{parser:r}=i,n=r.gullet.future().text==="["?r.parseSizeGroup(!0):null,s=!r.settings.displayMode||!r.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:r.mode,newLine:s,size:n&&me(n,"size").value}},htmlBuilder(i,e){var t=z.makeSpan(["mspace"],[],e);return i.newLine&&(t.classes.push("newline"),i.size&&(t.style.marginTop=V(Xe(i.size,e)))),t},mathmlBuilder(i,e){var t=new $.MathNode("mspace");return i.newLine&&(t.setAttribute("linebreak","newline"),i.size&&t.setAttribute("height",V(Xe(i.size,e)))),t}});x1={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},z4=i=>{var e=i.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(e))throw new G("Expected a control sequence",i);return e},vA=i=>{var e=i.gullet.popToken();return e.text==="="&&(e=i.gullet.popToken(),e.text===" "&&(e=i.gullet.popToken())),e},R4=(i,e,t,r)=>{var n=i.gullet.macros.get(t.text);n==null&&(t.noexpand=!0,n={tokens:[t],numArgs:0,unexpandable:!i.gullet.isExpandable(t.text)}),i.gullet.macros.set(e,n,r)};Z({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(i){var{parser:e,funcName:t}=i;e.consumeSpaces();var r=e.fetch();if(x1[r.text])return(t==="\\global"||t==="\\\\globallong")&&(r.text=x1[r.text]),me(e.parseFunction(),"internal");throw new G("Invalid token after macro prefix",r)}});Z({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i){var{parser:e,funcName:t}=i,r=e.gullet.popToken(),n=r.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(n))throw new G("Expected a control sequence",r);for(var s=0,a,o=[[]];e.gullet.future().text!=="{";)if(r=e.gullet.popToken(),r.text==="#"){if(e.gullet.future().text==="{"){a=e.gullet.future(),o[s].push("{");break}if(r=e.gullet.popToken(),!/^[1-9]$/.test(r.text))throw new G('Invalid argument number "'+r.text+'"');if(parseInt(r.text)!==s+1)throw new G('Argument number "'+r.text+'" out of order');s++,o.push([])}else{if(r.text==="EOF")throw new G("Expected a macro definition");o[s].push(r.text)}var{tokens:l}=e.gullet.consumeArg();return a&&l.unshift(a),(t==="\\edef"||t==="\\xdef")&&(l=e.gullet.expandTokens(l),l.reverse()),e.gullet.macros.set(n,{tokens:l,numArgs:s,delimiters:o},t===x1[t]),{type:"internal",mode:e.mode}}});Z({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i){var{parser:e,funcName:t}=i,r=z4(e.gullet.popToken());e.gullet.consumeSpaces();var n=vA(e);return R4(e,r,n,t==="\\\\globallet"),{type:"internal",mode:e.mode}}});Z({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i){var{parser:e,funcName:t}=i,r=z4(e.gullet.popToken()),n=e.gullet.popToken(),s=e.gullet.popToken();return R4(e,r,s,t==="\\\\globalfuture"),e.gullet.pushToken(s),e.gullet.pushToken(n),{type:"internal",mode:e.mode}}});Ko=function(e,t,r){var n=Oe.math[e]&&Oe.math[e].replace,s=T1(n||e,t,r);if(!s)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return s},C1=function(e,t,r,n){var s=r.havingBaseStyle(t),a=z.makeSpan(n.concat(s.sizingClasses(r)),[e],r),o=s.sizeMultiplier/r.sizeMultiplier;return a.height*=o,a.depth*=o,a.maxFontSize=s.sizeMultiplier,a},D4=function(e,t,r){var n=t.havingBaseStyle(r),s=(1-t.sizeMultiplier/n.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=V(s),e.height-=s,e.depth+=s},bA=function(e,t,r,n,s,a){var o=z.makeSymbol(e,"Main-Regular",s,n),l=C1(o,t,n,a);return r&&D4(l,n,t),l},wA=function(e,t,r,n){return z.makeSymbol(e,"Size"+t+"-Regular",r,n)},O4=function(e,t,r,n,s,a){var o=wA(e,t,s,n),l=C1(z.makeSpan(["delimsizing","size"+t],[o],n),ae.TEXT,n,a);return r&&D4(l,n,ae.TEXT),l},t1=function(e,t,r){var n;t==="Size1-Regular"?n="delim-size1":n="delim-size4";var s=z.makeSpan(["delimsizinginner",n],[z.makeSpan([],[z.makeSymbol(e,t,r)])]);return{type:"elem",elem:s}},i1=function(e,t,r){var n=dr["Size4-Regular"][e.charCodeAt(0)]?dr["Size4-Regular"][e.charCodeAt(0)][4]:dr["Size1-Regular"][e.charCodeAt(0)][4],s=new cr("inner",kS(e,Math.round(1e3*t))),a=new Xi([s],{width:V(n),height:V(t),style:"width:"+V(n),viewBox:"0 0 "+1e3*n+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),o=z.makeSvgSpan([],[a],r);return o.height=t,o.style.height=V(t),o.style.width=V(n),{type:"elem",elem:o}},y1=.008,yh={type:"kern",size:-1*y1},MA=["|","\\lvert","\\rvert","\\vert"],TA=["\\|","\\lVert","\\rVert","\\Vert"],B4=function(e,t,r,n,s,a){var o,l,h,d,c="",f=0;o=h=d=e,l=null;var m="Size1-Regular";e==="\\uparrow"?h=d="\u23D0":e==="\\Uparrow"?h=d="\u2016":e==="\\downarrow"?o=h="\u23D0":e==="\\Downarrow"?o=h="\u2016":e==="\\updownarrow"?(o="\\uparrow",h="\u23D0",d="\\downarrow"):e==="\\Updownarrow"?(o="\\Uparrow",h="\u2016",d="\\Downarrow"):MA.includes(e)?(h="\u2223",c="vert",f=333):TA.includes(e)?(h="\u2225",c="doublevert",f=556):e==="["||e==="\\lbrack"?(o="\u23A1",h="\u23A2",d="\u23A3",m="Size4-Regular",c="lbrack",f=667):e==="]"||e==="\\rbrack"?(o="\u23A4",h="\u23A5",d="\u23A6",m="Size4-Regular",c="rbrack",f=667):e==="\\lfloor"||e==="\u230A"?(h=o="\u23A2",d="\u23A3",m="Size4-Regular",c="lfloor",f=667):e==="\\lceil"||e==="\u2308"?(o="\u23A1",h=d="\u23A2",m="Size4-Regular",c="lceil",f=667):e==="\\rfloor"||e==="\u230B"?(h=o="\u23A5",d="\u23A6",m="Size4-Regular",c="rfloor",f=667):e==="\\rceil"||e==="\u2309"?(o="\u23A4",h=d="\u23A5",m="Size4-Regular",c="rceil",f=667):e==="("||e==="\\lparen"?(o="\u239B",h="\u239C",d="\u239D",m="Size4-Regular",c="lparen",f=875):e===")"||e==="\\rparen"?(o="\u239E",h="\u239F",d="\u23A0",m="Size4-Regular",c="rparen",f=875):e==="\\{"||e==="\\lbrace"?(o="\u23A7",l="\u23A8",d="\u23A9",h="\u23AA",m="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(o="\u23AB",l="\u23AC",d="\u23AD",h="\u23AA",m="Size4-Regular"):e==="\\lgroup"||e==="\u27EE"?(o="\u23A7",d="\u23A9",h="\u23AA",m="Size4-Regular"):e==="\\rgroup"||e==="\u27EF"?(o="\u23AB",d="\u23AD",h="\u23AA",m="Size4-Regular"):e==="\\lmoustache"||e==="\u23B0"?(o="\u23A7",d="\u23AD",h="\u23AA",m="Size4-Regular"):(e==="\\rmoustache"||e==="\u23B1")&&(o="\u23AB",d="\u23A9",h="\u23AA",m="Size4-Regular");var g=Ko(o,m,s),x=g.height+g.depth,y=Ko(h,m,s),b=y.height+y.depth,S=Ko(d,m,s),A=S.height+S.depth,C=0,I=1;if(l!==null){var O=Ko(l,m,s);C=O.height+O.depth,I=2}var q=x+A+C,P=Math.max(0,Math.ceil((t-q)/(I*b))),W=q+P*I*b,ne=n.fontMetrics().axisHeight;r&&(ne*=n.sizeMultiplier);var re=W/2-ne,oe=[];if(c.length>0){var ke=W-x-A,Q=Math.round(W*1e3),Y=CS(c,Math.round(ke*1e3)),le=new cr(c,Y),ce=(f/1e3).toFixed(3)+"em",at=(Q/1e3).toFixed(3)+"em",It=new Xi([le],{width:ce,height:at,viewBox:"0 0 "+f+" "+Q}),bt=z.makeSvgSpan([],[It],n);bt.height=Q/1e3,bt.style.width=ce,bt.style.height=at,oe.push({type:"elem",elem:bt})}else{if(oe.push(t1(d,m,s)),oe.push(yh),l===null){var qi=W-x-A+2*y1;oe.push(i1(h,qi,n))}else{var zt=(W-x-A-C)/2+2*y1;oe.push(i1(h,zt,n)),oe.push(yh),oe.push(t1(l,m,s)),oe.push(yh),oe.push(i1(h,zt,n))}oe.push(yh),oe.push(t1(o,m,s))}var di=n.havingBaseStyle(ae.TEXT),nn=z.makeVList({positionType:"bottom",positionData:re,children:oe},di);return C1(z.makeSpan(["delimsizing","mult"],[nn],di),ae.TEXT,n,a)},r1=80,n1=.08,s1=function(e,t,r,n,s){var a=AS(e,n,r),o=new cr(e,a),l=new Xi([o],{width:"400em",height:V(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return z.makeSvgSpan(["hide-tail"],[l],s)},NA=function(e,t){var r=t.havingBaseSizing(),n=H4("\\surd",e*r.sizeMultiplier,q4,r),s=r.sizeMultiplier,a=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness),o,l=0,h=0,d=0,c;return n.type==="small"?(d=1e3+1e3*a+r1,e<1?s=1:e<1.4&&(s=.7),l=(1+a+n1)/s,h=(1+a)/s,o=s1("sqrtMain",l,d,a,t),o.style.minWidth="0.853em",c=.833/s):n.type==="large"?(d=(1e3+r1)*Zo[n.size],h=(Zo[n.size]+a)/s,l=(Zo[n.size]+a+n1)/s,o=s1("sqrtSize"+n.size,l,d,a,t),o.style.minWidth="1.02em",c=1/s):(l=e+a+n1,h=e+a,d=Math.floor(1e3*e+a)+r1,o=s1("sqrtTall",l,d,a,t),o.style.minWidth="0.742em",c=1.056),o.height=h,o.style.height=V(l),{span:o,advanceWidth:c,ruleWidth:(t.fontMetrics().sqrtRuleThickness+a)*s}},P4=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","\\surd"],EA=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1"],F4=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],Zo=[0,1.2,1.8,2.4,3],SA=function(e,t,r,n,s){if(e==="<"||e==="\\lt"||e==="\u27E8"?e="\\langle":(e===">"||e==="\\gt"||e==="\u27E9")&&(e="\\rangle"),P4.includes(e)||F4.includes(e))return O4(e,t,!1,r,n,s);if(EA.includes(e))return B4(e,Zo[t],!1,r,n,s);throw new G("Illegal delimiter: '"+e+"'")},AA=[{type:"small",style:ae.SCRIPTSCRIPT},{type:"small",style:ae.SCRIPT},{type:"small",style:ae.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],kA=[{type:"small",style:ae.SCRIPTSCRIPT},{type:"small",style:ae.SCRIPT},{type:"small",style:ae.TEXT},{type:"stack"}],q4=[{type:"small",style:ae.SCRIPTSCRIPT},{type:"small",style:ae.SCRIPT},{type:"small",style:ae.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],CA=function(e){if(e.type==="small")return"Main-Regular";if(e.type==="large")return"Size"+e.size+"-Regular";if(e.type==="stack")return"Size4-Regular";throw new Error("Add support for delim type '"+e.type+"' here.")},H4=function(e,t,r,n){for(var s=Math.min(2,3-n.style.size),a=s;at)return r[a]}return r[r.length-1]},U4=function(e,t,r,n,s,a){e==="<"||e==="\\lt"||e==="\u27E8"?e="\\langle":(e===">"||e==="\\gt"||e==="\u27E9")&&(e="\\rangle");var o;F4.includes(e)?o=AA:P4.includes(e)?o=q4:o=kA;var l=H4(e,t,o,n);return l.type==="small"?bA(e,l.style,r,n,s,a):l.type==="large"?O4(e,l.size,r,n,s,a):B4(e,t,r,n,s,a)},_A=function(e,t,r,n,s,a){var o=n.fontMetrics().axisHeight*n.sizeMultiplier,l=901,h=5/n.fontMetrics().ptPerEm,d=Math.max(t-o,r+o),c=Math.max(d/500*l,2*d-h);return U4(e,c,!0,n,s,a)},Ir={sqrtImage:NA,sizedDelim:SA,sizeToMaxHeight:Zo,customSizedDelim:U4,leftRightDelim:_A},W6={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},LA=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230A","\u230B","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27E8","\\rangle","\u27E9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27EE","\u27EF","\\lmoustache","\\rmoustache","\u23B0","\u23B1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];Z({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(i,e)=>{var t=Rh(e[0],i);return{type:"delimsizing",mode:i.parser.mode,size:W6[i.funcName].size,mclass:W6[i.funcName].mclass,delim:t.text}},htmlBuilder:(i,e)=>i.delim==="."?z.makeSpan([i.mclass]):Ir.sizedDelim(i.delim,i.size,e,i.mode,[i.mclass]),mathmlBuilder:i=>{var e=[];i.delim!=="."&&e.push(Ci(i.delim,i.mode));var t=new $.MathNode("mo",e);i.mclass==="mopen"||i.mclass==="mclose"?t.setAttribute("fence","true"):t.setAttribute("fence","false"),t.setAttribute("stretchy","true");var r=V(Ir.sizeToMaxHeight[i.size]);return t.setAttribute("minsize",r),t.setAttribute("maxsize",r),t}});Z({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var t=i.parser.gullet.macros.get("\\current@color");if(t&&typeof t!="string")throw new G("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:i.parser.mode,delim:Rh(e[0],i).text,color:t}}});Z({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var t=Rh(e[0],i),r=i.parser;++r.leftrightDepth;var n=r.parseExpression(!1);--r.leftrightDepth,r.expect("\\right",!1);var s=me(r.parseFunction(),"leftright-right");return{type:"leftright",mode:r.mode,body:n,left:t.text,right:s.delim,rightColor:s.color}},htmlBuilder:(i,e)=>{Y6(i);for(var t=ct(i.body,e,!0,["mopen","mclose"]),r=0,n=0,s=!1,a=0;a{Y6(i);var t=ti(i.body,e);if(i.left!=="."){var r=new $.MathNode("mo",[Ci(i.left,i.mode)]);r.setAttribute("fence","true"),t.unshift(r)}if(i.right!=="."){var n=new $.MathNode("mo",[Ci(i.right,i.mode)]);n.setAttribute("fence","true"),i.rightColor&&n.setAttribute("mathcolor",i.rightColor),t.push(n)}return E1(t)}});Z({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var t=Rh(e[0],i);if(!i.parser.leftrightDepth)throw new G("\\middle without preceding \\left",t);return{type:"middle",mode:i.parser.mode,delim:t.text}},htmlBuilder:(i,e)=>{var t;if(i.delim===".")t=il(e,[]);else{t=Ir.sizedDelim(i.delim,1,e,i.mode,[]);var r={delim:i.delim,options:e};t.isMiddle=r}return t},mathmlBuilder:(i,e)=>{var t=i.delim==="\\vert"||i.delim==="|"?Ci("|","text"):Ci(i.delim,i.mode),r=new $.MathNode("mo",[t]);return r.setAttribute("fence","true"),r.setAttribute("lspace","0.05em"),r.setAttribute("rspace","0.05em"),r}});_1=(i,e)=>{var t=z.wrapFragment(Me(i.body,e),e),r=i.label.slice(1),n=e.sizeMultiplier,s,a=0,o=Ne.isCharacterBox(i.body);if(r==="sout")s=z.makeSpan(["stretchy","sout"]),s.height=e.fontMetrics().defaultRuleThickness/n,a=-.5*e.fontMetrics().xHeight;else if(r==="phase"){var l=Xe({number:.6,unit:"pt"},e),h=Xe({number:.35,unit:"ex"},e),d=e.havingBaseSizing();n=n/d.sizeMultiplier;var c=t.height+t.depth+l+h;t.style.paddingLeft=V(c/2+l);var f=Math.floor(1e3*c*n),m=ES(f),g=new Xi([new cr("phase",m)],{width:"400em",height:V(f/1e3),viewBox:"0 0 400000 "+f,preserveAspectRatio:"xMinYMin slice"});s=z.makeSvgSpan(["hide-tail"],[g],e),s.style.height=V(c),a=t.depth+l+h}else{/cancel/.test(r)?o||t.classes.push("cancel-pad"):r==="angl"?t.classes.push("anglpad"):t.classes.push("boxpad");var x=0,y=0,b=0;/box/.test(r)?(b=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),x=e.fontMetrics().fboxsep+(r==="colorbox"?0:b),y=x):r==="angl"?(b=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),x=4*b,y=Math.max(0,.25-t.depth)):(x=o?.2:0,y=x),s=Rr.encloseSpan(t,r,x,y,e),/fbox|boxed|fcolorbox/.test(r)?(s.style.borderStyle="solid",s.style.borderWidth=V(b)):r==="angl"&&b!==.049&&(s.style.borderTopWidth=V(b),s.style.borderRightWidth=V(b)),a=t.depth+y,i.backgroundColor&&(s.style.backgroundColor=i.backgroundColor,i.borderColor&&(s.style.borderColor=i.borderColor))}var S;if(i.backgroundColor)S=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:s,shift:a},{type:"elem",elem:t,shift:0}]},e);else{var A=/cancel|phase/.test(r)?["svg-align"]:[];S=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:t,shift:0},{type:"elem",elem:s,shift:a,wrapperClasses:A}]},e)}return/cancel/.test(r)&&(S.height=t.height,S.depth=t.depth),/cancel/.test(r)&&!o?z.makeSpan(["mord","cancel-lap"],[S],e):z.makeSpan(["mord"],[S],e)},L1=(i,e)=>{var t=0,r=new $.MathNode(i.label.indexOf("colorbox")>-1?"mpadded":"menclose",[ze(i.body,e)]);switch(i.label){case"\\cancel":r.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":r.setAttribute("notation","downdiagonalstrike");break;case"\\phase":r.setAttribute("notation","phasorangle");break;case"\\sout":r.setAttribute("notation","horizontalstrike");break;case"\\fbox":r.setAttribute("notation","box");break;case"\\angl":r.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(t=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,r.setAttribute("width","+"+2*t+"pt"),r.setAttribute("height","+"+2*t+"pt"),r.setAttribute("lspace",t+"pt"),r.setAttribute("voffset",t+"pt"),i.label==="\\fcolorbox"){var n=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);r.setAttribute("style","border: "+n+"em solid "+String(i.borderColor))}break;case"\\xcancel":r.setAttribute("notation","updiagonalstrike downdiagonalstrike");break}return i.backgroundColor&&r.setAttribute("mathbackground",i.backgroundColor),r};Z({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(i,e,t){var{parser:r,funcName:n}=i,s=me(e[0],"color-token").color,a=e[1];return{type:"enclose",mode:r.mode,label:n,backgroundColor:s,body:a}},htmlBuilder:_1,mathmlBuilder:L1});Z({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(i,e,t){var{parser:r,funcName:n}=i,s=me(e[0],"color-token").color,a=me(e[1],"color-token").color,o=e[2];return{type:"enclose",mode:r.mode,label:n,backgroundColor:a,borderColor:s,body:o}},htmlBuilder:_1,mathmlBuilder:L1});Z({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(i,e){var{parser:t}=i;return{type:"enclose",mode:t.mode,label:"\\fbox",body:e[0]}}});Z({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout","\\phase"],props:{numArgs:1},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];return{type:"enclose",mode:t.mode,label:r,body:n}},htmlBuilder:_1,mathmlBuilder:L1});Z({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(i,e){var{parser:t}=i;return{type:"enclose",mode:t.mode,label:"\\angl",body:e[0]}}});$4={};j4={};Dh=i=>{var e=i.parser.settings;if(!e.displayMode)throw new G("{"+i.envName+"} can be used only in display mode.")};fr=function(e,t){var r,n,s=e.body.length,a=e.hLinesBeforeRow,o=0,l=new Array(s),h=[],d=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),c=1/t.fontMetrics().ptPerEm,f=5*c;if(e.colSeparationType&&e.colSeparationType==="small"){var m=t.havingStyle(ae.SCRIPT).sizeMultiplier;f=.2778*(m/t.sizeMultiplier)}var g=e.colSeparationType==="CD"?Xe({number:3,unit:"ex"},t):12*c,x=3*c,y=e.arraystretch*g,b=.7*y,S=.3*y,A=0;function C(Bs){for(var $i=0;$i0&&(A+=.25),h.push({pos:A,isDashed:Bs[$i]})}for(C(a[0]),r=0;r0&&(re+=S,qBs))for(r=0;r=o)){var Mr=void 0;(n>0||e.hskipBeforeAndAfter)&&(Mr=Ne.deflt(zt.pregap,f),Mr!==0&&(Y=z.makeSpan(["arraycolsep"],[]),Y.style.width=V(Mr),Q.push(Y)));var tr=[];for(r=0;r0){for(var wi=z.makeLineSpan("hline",t,d),Je=z.makeLineSpan("hdashline",t,d),ve=[{type:"elem",elem:l,shift:0}];h.length>0;){var an=h.pop(),R=an.pos-oe;an.isDashed?ve.push({type:"elem",elem:Je,shift:R}):ve.push({type:"elem",elem:wi,shift:R})}l=z.makeVList({positionType:"individualShift",children:ve},t)}if(ce.length===0)return z.makeSpan(["mord"],[l],t);var Wn=z.makeVList({positionType:"individualShift",children:ce},t);return Wn=z.makeSpan(["tag"],[Wn],t),z.makeFragment([l,Wn])},IA={c:"center ",l:"left ",r:"right "},mr=function(e,t){for(var r=[],n=new $.MathNode("mtd",[],["mtr-glue"]),s=new $.MathNode("mtd",[],["mml-eqn-num"]),a=0;a0){var g=e.cols,x="",y=!1,b=0,S=g.length;g[0].type==="separator"&&(f+="top ",b=1),g[g.length-1].type==="separator"&&(f+="bottom ",S-=1);for(var A=b;A0?"left ":"",f+=P[P.length-1].length>0?"right ":"";for(var W=1;W-1?"alignat":"align",s=e.envName==="split",a=bn(e.parser,{cols:r,addJot:!0,autoTag:s?void 0:I1(e.envName),emptySingleRow:!0,colSeparationType:n,maxNumCols:s?2:void 0,leqno:e.parser.settings.leqno},"display"),o,l=0,h={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&t[0].type==="ordgroup"){for(var d="",c=0;c0&&m&&(y=1),r[g]={type:"align",align:x,pregap:y,postgap:0}}return a.colSeparationType=m?"align":"alignat",a};ur({type:"array",names:["array","darray"],props:{numArgs:1},handler(i,e){var t=Ih(e[0]),r=t?[e[0]]:me(e[0],"ordgroup").body,n=r.map(function(a){var o=A1(a),l=o.text;if("lcr".indexOf(l)!==-1)return{type:"align",align:l};if(l==="|")return{type:"separator",separator:"|"};if(l===":")return{type:"separator",separator:":"};throw new G("Unknown column alignment: "+l,a)}),s={cols:n,hskipBeforeAndAfter:!0,maxNumCols:n.length};return bn(i.parser,s,z1(i.envName))},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(i){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[i.envName.replace("*","")],t="c",r={hskipBeforeAndAfter:!1,cols:[{type:"align",align:t}]};if(i.envName.charAt(i.envName.length-1)==="*"){var n=i.parser;if(n.consumeSpaces(),n.fetch().text==="["){if(n.consume(),n.consumeSpaces(),t=n.fetch().text,"lcr".indexOf(t)===-1)throw new G("Expected l or c or r",n.nextToken);n.consume(),n.consumeSpaces(),n.expect("]"),n.consume(),r.cols=[{type:"align",align:t}]}}var s=bn(i.parser,r,z1(i.envName)),a=Math.max(0,...s.body.map(o=>o.length));return s.cols=new Array(a).fill({type:"align",align:t}),e?{type:"leftright",mode:i.mode,body:[s],left:e[0],right:e[1],rightColor:void 0}:s},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(i){var e={arraystretch:.5},t=bn(i.parser,e,"script");return t.colSeparationType="small",t},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["subarray"],props:{numArgs:1},handler(i,e){var t=Ih(e[0]),r=t?[e[0]]:me(e[0],"ordgroup").body,n=r.map(function(a){var o=A1(a),l=o.text;if("lc".indexOf(l)!==-1)return{type:"align",align:l};throw new G("Unknown column alignment: "+l,a)});if(n.length>1)throw new G("{subarray} can contain only one column");var s={cols:n,hskipBeforeAndAfter:!1,arraystretch:.5};if(s=bn(i.parser,s,"script"),s.body.length>0&&s.body[0].length>1)throw new G("{subarray} can contain only one column");return s},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(i){var e={arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},t=bn(i.parser,e,z1(i.envName));return{type:"leftright",mode:i.mode,body:[t],left:i.envName.indexOf("r")>-1?".":"\\{",right:i.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:G4,htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(i){["gather","gather*"].includes(i.envName)&&Dh(i);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:I1(i.envName),emptySingleRow:!0,leqno:i.parser.settings.leqno};return bn(i.parser,e,"display")},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:G4,htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(i){Dh(i);var e={autoTag:I1(i.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:i.parser.settings.leqno};return bn(i.parser,e,"display")},htmlBuilder:fr,mathmlBuilder:mr});ur({type:"array",names:["CD"],props:{numArgs:0},handler(i){return Dh(i),yA(i.parser)},htmlBuilder:fr,mathmlBuilder:mr});w("\\nonumber","\\gdef\\@eqnsw{0}");w("\\notag","\\nonumber");Z({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(i,e){throw new G(i.funcName+" valid only within array environment")}});K6=$4;Z({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];if(n.type!=="ordgroup")throw new G("Invalid environment name",n);for(var s="",a=0;a{var t=i.font,r=e.withFont(t);return Me(i.body,r)},W4=(i,e)=>{var t=i.font,r=e.withFont(t);return ze(i.body,r)},Z6={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};Z({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathsfit","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=Ah(e[0]),s=r;return s in Z6&&(s=Z6[s]),{type:"font",mode:t.mode,font:s.slice(1),body:n}},htmlBuilder:V4,mathmlBuilder:W4});Z({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(i,e)=>{var{parser:t}=i,r=e[0],n=Ne.isCharacterBox(r);return{type:"mclass",mode:t.mode,mclass:zh(r),body:[{type:"font",mode:t.mode,font:"boldsymbol",body:r}],isCharacterBox:n}}});Z({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(i,e)=>{var{parser:t,funcName:r,breakOnTokenText:n}=i,{mode:s}=t,a=t.parseExpression(!0,n),o="math"+r.slice(1);return{type:"font",mode:s,font:o,body:{type:"ordgroup",mode:t.mode,body:a}}},htmlBuilder:V4,mathmlBuilder:W4});Y4=(i,e)=>{var t=e;return i==="display"?t=t.id>=ae.SCRIPT.id?t.text():ae.DISPLAY:i==="text"&&t.size===ae.DISPLAY.size?t=ae.TEXT:i==="script"?t=ae.SCRIPT:i==="scriptscript"&&(t=ae.SCRIPTSCRIPT),t},R1=(i,e)=>{var t=Y4(i.size,e.style),r=t.fracNum(),n=t.fracDen(),s;s=e.havingStyle(r);var a=Me(i.numer,s,e);if(i.continued){var o=8.5/e.fontMetrics().ptPerEm,l=3.5/e.fontMetrics().ptPerEm;a.height=a.height0?g=3*f:g=7*f,x=e.fontMetrics().denom1):(c>0?(m=e.fontMetrics().num2,g=f):(m=e.fontMetrics().num3,g=3*f),x=e.fontMetrics().denom2);var y;if(d){var S=e.fontMetrics().axisHeight;m-a.depth-(S+.5*c){var t=new $.MathNode("mfrac",[ze(i.numer,e),ze(i.denom,e)]);if(!i.hasBarLine)t.setAttribute("linethickness","0px");else if(i.barSize){var r=Xe(i.barSize,e);t.setAttribute("linethickness",V(r))}var n=Y4(i.size,e.style);if(n.size!==e.style.size){t=new $.MathNode("mstyle",[t]);var s=n.size===ae.DISPLAY.size?"true":"false";t.setAttribute("displaystyle",s),t.setAttribute("scriptlevel","0")}if(i.leftDelim!=null||i.rightDelim!=null){var a=[];if(i.leftDelim!=null){var o=new $.MathNode("mo",[new $.TextNode(i.leftDelim.replace("\\",""))]);o.setAttribute("fence","true"),a.push(o)}if(a.push(t),i.rightDelim!=null){var l=new $.MathNode("mo",[new $.TextNode(i.rightDelim.replace("\\",""))]);l.setAttribute("fence","true"),a.push(l)}return E1(a)}return t};Z({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0],s=e[1],a,o=null,l=null,h="auto";switch(r){case"\\dfrac":case"\\frac":case"\\tfrac":a=!0;break;case"\\\\atopfrac":a=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":a=!1,o="(",l=")";break;case"\\\\bracefrac":a=!1,o="\\{",l="\\}";break;case"\\\\brackfrac":a=!1,o="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}switch(r){case"\\dfrac":case"\\dbinom":h="display";break;case"\\tfrac":case"\\tbinom":h="text";break}return{type:"genfrac",mode:t.mode,continued:!1,numer:n,denom:s,hasBarLine:a,leftDelim:o,rightDelim:l,size:h,barSize:null}},htmlBuilder:R1,mathmlBuilder:D1});Z({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0],s=e[1];return{type:"genfrac",mode:t.mode,continued:!0,numer:n,denom:s,hasBarLine:!0,leftDelim:null,rightDelim:null,size:"display",barSize:null}}});Z({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(i){var{parser:e,funcName:t,token:r}=i,n;switch(t){case"\\over":n="\\frac";break;case"\\choose":n="\\binom";break;case"\\atop":n="\\\\atopfrac";break;case"\\brace":n="\\\\bracefrac";break;case"\\brack":n="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:n,token:r}}});Q6=["display","text","script","scriptscript"],J6=function(e){var t=null;return e.length>0&&(t=e,t=t==="."?null:t),t};Z({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(i,e){var{parser:t}=i,r=e[4],n=e[5],s=Ah(e[0]),a=s.type==="atom"&&s.family==="open"?J6(s.text):null,o=Ah(e[1]),l=o.type==="atom"&&o.family==="close"?J6(o.text):null,h=me(e[2],"size"),d,c=null;h.isBlank?d=!0:(c=h.value,d=c.number>0);var f="auto",m=e[3];if(m.type==="ordgroup"){if(m.body.length>0){var g=me(m.body[0],"textord");f=Q6[Number(g.text)]}}else m=me(m,"textord"),f=Q6[Number(m.text)];return{type:"genfrac",mode:t.mode,numer:r,denom:n,continued:!1,hasBarLine:d,barSize:c,leftDelim:a,rightDelim:l,size:f}},htmlBuilder:R1,mathmlBuilder:D1});Z({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(i,e){var{parser:t,funcName:r,token:n}=i;return{type:"infix",mode:t.mode,replaceWith:"\\\\abovefrac",size:me(e[0],"size").value,token:n}}});Z({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0],s=dS(me(e[1],"infix").size),a=e[2],o=s.number>0;return{type:"genfrac",mode:t.mode,numer:n,denom:a,continued:!1,hasBarLine:o,barSize:s,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:R1,mathmlBuilder:D1});X4=(i,e)=>{var t=e.style,r,n;i.type==="supsub"?(r=i.sup?Me(i.sup,e.havingStyle(t.sup()),e):Me(i.sub,e.havingStyle(t.sub()),e),n=me(i.base,"horizBrace")):n=me(i,"horizBrace");var s=Me(n.base,e.havingBaseStyle(ae.DISPLAY)),a=Rr.svgSpan(n,e),o;if(n.isOver?(o=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:a}]},e),o.children[0].children[0].children[1].classes.push("svg-align")):(o=z.makeVList({positionType:"bottom",positionData:s.depth+.1+a.height,children:[{type:"elem",elem:a},{type:"kern",size:.1},{type:"elem",elem:s}]},e),o.children[0].children[0].children[0].classes.push("svg-align")),r){var l=z.makeSpan(["mord",n.isOver?"mover":"munder"],[o],e);n.isOver?o=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:r}]},e):o=z.makeVList({positionType:"bottom",positionData:l.depth+.2+r.height+r.depth,children:[{type:"elem",elem:r},{type:"kern",size:.2},{type:"elem",elem:l}]},e)}return z.makeSpan(["mord",n.isOver?"mover":"munder"],[o],e)},zA=(i,e)=>{var t=Rr.mathMLnode(i.label);return new $.MathNode(i.isOver?"mover":"munder",[ze(i.base,e),t])};Z({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler(i,e){var{parser:t,funcName:r}=i;return{type:"horizBrace",mode:t.mode,label:r,isOver:/^\\over/.test(r),base:e[0]}},htmlBuilder:X4,mathmlBuilder:zA});Z({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[1],n=me(e[0],"url").url;return t.settings.isTrusted({command:"\\href",url:n})?{type:"href",mode:t.mode,href:n,body:rt(r)}:t.formatUnsupportedCmd("\\href")},htmlBuilder:(i,e)=>{var t=ct(i.body,e,!1);return z.makeAnchor(i.href,[],t,e)},mathmlBuilder:(i,e)=>{var t=vn(i.body,e);return t instanceof Bt||(t=new Bt("mrow",[t])),t.setAttribute("href",i.href),t}});Z({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=me(e[0],"url").url;if(!t.settings.isTrusted({command:"\\url",url:r}))return t.formatUnsupportedCmd("\\url");for(var n=[],s=0;s{var{parser:t,funcName:r,token:n}=i,s=me(e[0],"raw").string,a=e[1];t.settings.strict&&t.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var o,l={};switch(r){case"\\htmlClass":l.class=s,o={command:"\\htmlClass",class:s};break;case"\\htmlId":l.id=s,o={command:"\\htmlId",id:s};break;case"\\htmlStyle":l.style=s,o={command:"\\htmlStyle",style:s};break;case"\\htmlData":{for(var h=s.split(","),d=0;d{var t=ct(i.body,e,!1),r=["enclosing"];i.attributes.class&&r.push(...i.attributes.class.trim().split(/\s+/));var n=z.makeSpan(r,t,e);for(var s in i.attributes)s!=="class"&&i.attributes.hasOwnProperty(s)&&n.setAttribute(s,i.attributes[s]);return n},mathmlBuilder:(i,e)=>vn(i.body,e)});Z({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i;return{type:"htmlmathml",mode:t.mode,html:rt(e[0]),mathml:rt(e[1])}},htmlBuilder:(i,e)=>{var t=ct(i.html,e,!1);return z.makeFragment(t)},mathmlBuilder:(i,e)=>vn(i.mathml,e)});a1=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new G("Invalid size: '"+e+"' in \\includegraphics");var r={number:+(t[1]+t[2]),unit:t[3]};if(!m4(r))throw new G("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r};Z({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(i,e,t)=>{var{parser:r}=i,n={number:0,unit:"em"},s={number:.9,unit:"em"},a={number:0,unit:"em"},o="";if(t[0])for(var l=me(t[0],"raw").string,h=l.split(","),d=0;d{var t=Xe(i.height,e),r=0;i.totalheight.number>0&&(r=Xe(i.totalheight,e)-t);var n=0;i.width.number>0&&(n=Xe(i.width,e));var s={height:V(t+r)};n>0&&(s.width=V(n)),r>0&&(s.verticalAlign=V(-r));var a=new u1(i.src,i.alt,s);return a.height=t,a.depth=r,a},mathmlBuilder:(i,e)=>{var t=new $.MathNode("mglyph",[]);t.setAttribute("alt",i.alt);var r=Xe(i.height,e),n=0;if(i.totalheight.number>0&&(n=Xe(i.totalheight,e)-r,t.setAttribute("valign",V(-n))),t.setAttribute("height",V(r+n)),i.width.number>0){var s=Xe(i.width,e);t.setAttribute("width",V(s))}return t.setAttribute("src",i.src),t}});Z({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(i,e){var{parser:t,funcName:r}=i,n=me(e[0],"size");if(t.settings.strict){var s=r[1]==="m",a=n.value.unit==="mu";s?(a||t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+r+" supports only mu units, "+("not "+n.value.unit+" units")),t.mode!=="math"&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+r+" works only in math mode")):a&&t.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+r+" doesn't support mu units")}return{type:"kern",mode:t.mode,dimension:n.value}},htmlBuilder(i,e){return z.makeGlue(i.dimension,e)},mathmlBuilder(i,e){var t=Xe(i.dimension,e);return new $.SpaceNode(t)}});Z({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0];return{type:"lap",mode:t.mode,alignment:r.slice(5),body:n}},htmlBuilder:(i,e)=>{var t;i.alignment==="clap"?(t=z.makeSpan([],[Me(i.body,e)]),t=z.makeSpan(["inner"],[t],e)):t=z.makeSpan(["inner"],[Me(i.body,e)]);var r=z.makeSpan(["fix"],[]),n=z.makeSpan([i.alignment],[t,r],e),s=z.makeSpan(["strut"]);return s.style.height=V(n.height+n.depth),n.depth&&(s.style.verticalAlign=V(-n.depth)),n.children.unshift(s),n=z.makeSpan(["thinbox"],[n],e),z.makeSpan(["mord","vbox"],[n],e)},mathmlBuilder:(i,e)=>{var t=new $.MathNode("mpadded",[ze(i.body,e)]);if(i.alignment!=="rlap"){var r=i.alignment==="llap"?"-1":"-0.5";t.setAttribute("lspace",r+"width")}return t.setAttribute("width","0px"),t}});Z({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(i,e){var{funcName:t,parser:r}=i,n=r.mode;r.switchMode("math");var s=t==="\\("?"\\)":"$",a=r.parseExpression(!1,s);return r.expect(s),r.switchMode(n),{type:"styling",mode:r.mode,style:"text",body:a}}});Z({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(i,e){throw new G("Mismatched "+i.funcName)}});e4=(i,e)=>{switch(e.style.size){case ae.DISPLAY.size:return i.display;case ae.TEXT.size:return i.text;case ae.SCRIPT.size:return i.script;case ae.SCRIPTSCRIPT.size:return i.scriptscript;default:return i.text}};Z({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(i,e)=>{var{parser:t}=i;return{type:"mathchoice",mode:t.mode,display:rt(e[0]),text:rt(e[1]),script:rt(e[2]),scriptscript:rt(e[3])}},htmlBuilder:(i,e)=>{var t=e4(i,e),r=ct(t,e,!1);return z.makeFragment(r)},mathmlBuilder:(i,e)=>{var t=e4(i,e);return vn(t,e)}});K4=(i,e,t,r,n,s,a)=>{i=z.makeSpan([],[i]);var o=t&&Ne.isCharacterBox(t),l,h;if(e){var d=Me(e,r.havingStyle(n.sup()),r);h={elem:d,kern:Math.max(r.fontMetrics().bigOpSpacing1,r.fontMetrics().bigOpSpacing3-d.depth)}}if(t){var c=Me(t,r.havingStyle(n.sub()),r);l={elem:c,kern:Math.max(r.fontMetrics().bigOpSpacing2,r.fontMetrics().bigOpSpacing4-c.height)}}var f;if(h&&l){var m=r.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+i.depth+a;f=z.makeVList({positionType:"bottom",positionData:m,children:[{type:"kern",size:r.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:V(-s)},{type:"kern",size:l.kern},{type:"elem",elem:i},{type:"kern",size:h.kern},{type:"elem",elem:h.elem,marginLeft:V(s)},{type:"kern",size:r.fontMetrics().bigOpSpacing5}]},r)}else if(l){var g=i.height-a;f=z.makeVList({positionType:"top",positionData:g,children:[{type:"kern",size:r.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:V(-s)},{type:"kern",size:l.kern},{type:"elem",elem:i}]},r)}else if(h){var x=i.depth+a;f=z.makeVList({positionType:"bottom",positionData:x,children:[{type:"elem",elem:i},{type:"kern",size:h.kern},{type:"elem",elem:h.elem,marginLeft:V(s)},{type:"kern",size:r.fontMetrics().bigOpSpacing5}]},r)}else return i;var y=[f];if(l&&s!==0&&!o){var b=z.makeSpan(["mspace"],[],r);b.style.marginRight=V(s),y.unshift(b)}return z.makeSpan(["mop","op-limits"],y,r)},Z4=["\\smallint"],pa=(i,e)=>{var t,r,n=!1,s;i.type==="supsub"?(t=i.sup,r=i.sub,s=me(i.base,"op"),n=!0):s=me(i,"op");var a=e.style,o=!1;a.size===ae.DISPLAY.size&&s.symbol&&!Z4.includes(s.name)&&(o=!0);var l;if(s.symbol){var h=o?"Size2-Regular":"Size1-Regular",d="";if((s.name==="\\oiint"||s.name==="\\oiiint")&&(d=s.name.slice(1),s.name=d==="oiint"?"\\iint":"\\iiint"),l=z.makeSymbol(s.name,h,"math",e,["mop","op-symbol",o?"large-op":"small-op"]),d.length>0){var c=l.italic,f=z.staticSvg(d+"Size"+(o?"2":"1"),e);l=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:f,shift:o?.08:0}]},e),s.name="\\"+d,l.classes.unshift("mop"),l.italic=c}}else if(s.body){var m=ct(s.body,e,!0);m.length===1&&m[0]instanceof ei?(l=m[0],l.classes[0]="mop"):l=z.makeSpan(["mop"],m,e)}else{for(var g=[],x=1;x{var t;if(i.symbol)t=new Bt("mo",[Ci(i.name,i.mode)]),Z4.includes(i.name)&&t.setAttribute("largeop","false");else if(i.body)t=new Bt("mo",ti(i.body,e));else{t=new Bt("mi",[new ki(i.name.slice(1))]);var r=new Bt("mo",[Ci("\u2061","text")]);i.parentIsSupSub?t=new Bt("mrow",[t,r]):t=E4([t,r])}return t},RA={"\u220F":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22C0":"\\bigwedge","\u22C1":"\\bigvee","\u22C2":"\\bigcap","\u22C3":"\\bigcup","\u2A00":"\\bigodot","\u2A01":"\\bigoplus","\u2A02":"\\bigotimes","\u2A04":"\\biguplus","\u2A06":"\\bigsqcup"};Z({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","\u220F","\u2210","\u2211","\u22C0","\u22C1","\u22C2","\u22C3","\u2A00","\u2A01","\u2A02","\u2A04","\u2A06"],props:{numArgs:0},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=r;return n.length===1&&(n=RA[n]),{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:pa,mathmlBuilder:rl});Z({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:rt(r)}},htmlBuilder:pa,mathmlBuilder:rl});DA={"\u222B":"\\int","\u222C":"\\iint","\u222D":"\\iiint","\u222E":"\\oint","\u222F":"\\oiint","\u2230":"\\oiiint"};Z({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler(i){var{parser:e,funcName:t}=i;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:t}},htmlBuilder:pa,mathmlBuilder:rl});Z({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(i){var{parser:e,funcName:t}=i;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:t}},htmlBuilder:pa,mathmlBuilder:rl});Z({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222B","\u222C","\u222D","\u222E","\u222F","\u2230"],props:{numArgs:0,allowedInArgument:!0},handler(i){var{parser:e,funcName:t}=i,r=t;return r.length===1&&(r=DA[r]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:r}},htmlBuilder:pa,mathmlBuilder:rl});Q4=(i,e)=>{var t,r,n=!1,s;i.type==="supsub"?(t=i.sup,r=i.sub,s=me(i.base,"operatorname"),n=!0):s=me(i,"operatorname");var a;if(s.body.length>0){for(var o=s.body.map(c=>{var f=c.text;return typeof f=="string"?{type:"textord",mode:c.mode,text:f}:c}),l=ct(o,e.withFont("mathrm"),!0),h=0;h{for(var t=ti(i.body,e.withFont("mathrm")),r=!0,n=0;nd.toText()).join("");t=[new $.TextNode(o)]}var l=new $.MathNode("mi",t);l.setAttribute("mathvariant","normal");var h=new $.MathNode("mo",[Ci("\u2061","text")]);return i.parentIsSupSub?new $.MathNode("mrow",[l,h]):$.newDocumentFragment([l,h])};Z({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1},handler:(i,e)=>{var{parser:t,funcName:r}=i,n=e[0];return{type:"operatorname",mode:t.mode,body:rt(n),alwaysHandleSupSub:r==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:Q4,mathmlBuilder:OA});w("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@");gs({type:"ordgroup",htmlBuilder(i,e){return i.semisimple?z.makeFragment(ct(i.body,e,!1)):z.makeSpan(["mord"],ct(i.body,e,!0),e)},mathmlBuilder(i,e){return vn(i.body,e,!0)}});Z({type:"overline",names:["\\overline"],props:{numArgs:1},handler(i,e){var{parser:t}=i,r=e[0];return{type:"overline",mode:t.mode,body:r}},htmlBuilder(i,e){var t=Me(i.body,e.havingCrampedStyle()),r=z.makeLineSpan("overline-line",e),n=e.fontMetrics().defaultRuleThickness,s=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t},{type:"kern",size:3*n},{type:"elem",elem:r},{type:"kern",size:n}]},e);return z.makeSpan(["mord","overline"],[s],e)},mathmlBuilder(i,e){var t=new $.MathNode("mo",[new $.TextNode("\u203E")]);t.setAttribute("stretchy","true");var r=new $.MathNode("mover",[ze(i.body,e),t]);return r.setAttribute("accent","true"),r}});Z({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"phantom",mode:t.mode,body:rt(r)}},htmlBuilder:(i,e)=>{var t=ct(i.body,e.withPhantom(),!1);return z.makeFragment(t)},mathmlBuilder:(i,e)=>{var t=ti(i.body,e);return new $.MathNode("mphantom",t)}});Z({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"hphantom",mode:t.mode,body:r}},htmlBuilder:(i,e)=>{var t=z.makeSpan([],[Me(i.body,e.withPhantom())]);if(t.height=0,t.depth=0,t.children)for(var r=0;r{var t=ti(rt(i.body),e),r=new $.MathNode("mphantom",t),n=new $.MathNode("mpadded",[r]);return n.setAttribute("height","0px"),n.setAttribute("depth","0px"),n}});Z({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(i,e)=>{var{parser:t}=i,r=e[0];return{type:"vphantom",mode:t.mode,body:r}},htmlBuilder:(i,e)=>{var t=z.makeSpan(["inner"],[Me(i.body,e.withPhantom())]),r=z.makeSpan(["fix"],[]);return z.makeSpan(["mord","rlap"],[t,r],e)},mathmlBuilder:(i,e)=>{var t=ti(rt(i.body),e),r=new $.MathNode("mphantom",t),n=new $.MathNode("mpadded",[r]);return n.setAttribute("width","0px"),n}});Z({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(i,e){var{parser:t}=i,r=me(e[0],"size").value,n=e[1];return{type:"raisebox",mode:t.mode,dy:r,body:n}},htmlBuilder(i,e){var t=Me(i.body,e),r=Xe(i.dy,e);return z.makeVList({positionType:"shift",positionData:-r,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(i,e){var t=new $.MathNode("mpadded",[ze(i.body,e)]),r=i.dy.number+i.dy.unit;return t.setAttribute("voffset",r),t}});Z({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler(i){var{parser:e}=i;return{type:"internal",mode:e.mode}}});Z({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler(i,e,t){var{parser:r}=i,n=t[0],s=me(e[0],"size"),a=me(e[1],"size");return{type:"rule",mode:r.mode,shift:n&&me(n,"size").value,width:s.value,height:a.value}},htmlBuilder(i,e){var t=z.makeSpan(["mord","rule"],[],e),r=Xe(i.width,e),n=Xe(i.height,e),s=i.shift?Xe(i.shift,e):0;return t.style.borderRightWidth=V(r),t.style.borderTopWidth=V(n),t.style.bottom=V(s),t.width=r,t.height=n+s,t.depth=-s,t.maxFontSize=n*1.125*e.sizeMultiplier,t},mathmlBuilder(i,e){var t=Xe(i.width,e),r=Xe(i.height,e),n=i.shift?Xe(i.shift,e):0,s=e.color&&e.getColor()||"black",a=new $.MathNode("mspace");a.setAttribute("mathbackground",s),a.setAttribute("width",V(t)),a.setAttribute("height",V(r));var o=new $.MathNode("mpadded",[a]);return n>=0?o.setAttribute("height",V(n)):(o.setAttribute("height",V(n)),o.setAttribute("depth",V(-n))),o.setAttribute("voffset",V(n)),o}});t4=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],BA=(i,e)=>{var t=e.havingSize(i.size);return J4(i.body,t,e)};Z({type:"sizing",names:t4,props:{numArgs:0,allowedInText:!0},handler:(i,e)=>{var{breakOnTokenText:t,funcName:r,parser:n}=i,s=n.parseExpression(!1,t);return{type:"sizing",mode:n.mode,size:t4.indexOf(r)+1,body:s}},htmlBuilder:BA,mathmlBuilder:(i,e)=>{var t=e.havingSize(i.size),r=ti(i.body,t),n=new $.MathNode("mstyle",r);return n.setAttribute("mathsize",V(t.sizeMultiplier)),n}});Z({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(i,e,t)=>{var{parser:r}=i,n=!1,s=!1,a=t[0]&&me(t[0],"ordgroup");if(a)for(var o="",l=0;l{var t=z.makeSpan([],[Me(i.body,e)]);if(!i.smashHeight&&!i.smashDepth)return t;if(i.smashHeight&&(t.height=0,t.children))for(var r=0;r{var t=new $.MathNode("mpadded",[ze(i.body,e)]);return i.smashHeight&&t.setAttribute("height","0px"),i.smashDepth&&t.setAttribute("depth","0px"),t}});Z({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(i,e,t){var{parser:r}=i,n=t[0],s=e[0];return{type:"sqrt",mode:r.mode,body:s,index:n}},htmlBuilder(i,e){var t=Me(i.body,e.havingCrampedStyle());t.height===0&&(t.height=e.fontMetrics().xHeight),t=z.wrapFragment(t,e);var r=e.fontMetrics(),n=r.defaultRuleThickness,s=n;e.style.idt.height+t.depth+a&&(a=(a+c-t.height-t.depth)/2);var f=l.height-t.height-a-h;t.style.paddingLeft=V(d);var m=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:t,wrapperClasses:["svg-align"]},{type:"kern",size:-(t.height+f)},{type:"elem",elem:l},{type:"kern",size:h}]},e);if(i.index){var g=e.havingStyle(ae.SCRIPTSCRIPT),x=Me(i.index,g,e),y=.6*(m.height-m.depth),b=z.makeVList({positionType:"shift",positionData:-y,children:[{type:"elem",elem:x}]},e),S=z.makeSpan(["root"],[b]);return z.makeSpan(["mord","sqrt"],[S,m],e)}else return z.makeSpan(["mord","sqrt"],[m],e)},mathmlBuilder(i,e){var{body:t,index:r}=i;return r?new $.MathNode("mroot",[ze(t,e),ze(r,e)]):new $.MathNode("msqrt",[ze(t,e)])}});i4={display:ae.DISPLAY,text:ae.TEXT,script:ae.SCRIPT,scriptscript:ae.SCRIPTSCRIPT};Z({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(i,e){var{breakOnTokenText:t,funcName:r,parser:n}=i,s=n.parseExpression(!0,t),a=r.slice(1,r.length-5);return{type:"styling",mode:n.mode,style:a,body:s}},htmlBuilder(i,e){var t=i4[i.style],r=e.havingStyle(t).withFont("");return J4(i.body,r,e)},mathmlBuilder(i,e){var t=i4[i.style],r=e.havingStyle(t),n=ti(i.body,r),s=new $.MathNode("mstyle",n),a={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]},o=a[i.style];return s.setAttribute("scriptlevel",o[0]),s.setAttribute("displaystyle",o[1]),s}});PA=function(e,t){var r=e.base;if(r)if(r.type==="op"){var n=r.limits&&(t.style.size===ae.DISPLAY.size||r.alwaysHandleSupSub);return n?pa:null}else if(r.type==="operatorname"){var s=r.alwaysHandleSupSub&&(t.style.size===ae.DISPLAY.size||r.limits);return s?Q4:null}else{if(r.type==="accent")return Ne.isCharacterBox(r.base)?k1:null;if(r.type==="horizBrace"){var a=!e.sub;return a===r.isOver?X4:null}else return null}else return null};gs({type:"supsub",htmlBuilder(i,e){var t=PA(i,e);if(t)return t(i,e);var{base:r,sup:n,sub:s}=i,a=Me(r,e),o,l,h=e.fontMetrics(),d=0,c=0,f=r&&Ne.isCharacterBox(r);if(n){var m=e.havingStyle(e.style.sup());o=Me(n,m,e),f||(d=a.height-m.fontMetrics().supDrop*m.sizeMultiplier/e.sizeMultiplier)}if(s){var g=e.havingStyle(e.style.sub());l=Me(s,g,e),f||(c=a.depth+g.fontMetrics().subDrop*g.sizeMultiplier/e.sizeMultiplier)}var x;e.style===ae.DISPLAY?x=h.sup1:e.style.cramped?x=h.sup3:x=h.sup2;var y=e.sizeMultiplier,b=V(.5/h.ptPerEm/y),S=null;if(l){var A=i.base&&i.base.type==="op"&&i.base.name&&(i.base.name==="\\oiint"||i.base.name==="\\oiiint");(a instanceof ei||A)&&(S=V(-a.italic))}var C;if(o&&l){d=Math.max(d,x,o.depth+.25*h.xHeight),c=Math.max(c,h.sub2);var I=h.defaultRuleThickness,O=4*I;if(d-o.depth-(l.height-c)0&&(d+=q,c-=q)}var P=[{type:"elem",elem:l,shift:c,marginRight:b,marginLeft:S},{type:"elem",elem:o,shift:-d,marginRight:b}];C=z.makeVList({positionType:"individualShift",children:P},e)}else if(l){c=Math.max(c,h.sub1,l.height-.8*h.xHeight);var W=[{type:"elem",elem:l,marginLeft:S,marginRight:b}];C=z.makeVList({positionType:"shift",positionData:c,children:W},e)}else if(o)d=Math.max(d,x,o.depth+.25*h.xHeight),C=z.makeVList({positionType:"shift",positionData:-d,children:[{type:"elem",elem:o,marginRight:b}]},e);else throw new Error("supsub must have either sup or sub.");var ne=m1(a,"right")||"mord";return z.makeSpan([ne],[a,z.makeSpan(["msupsub"],[C])],e)},mathmlBuilder(i,e){var t=!1,r,n;i.base&&i.base.type==="horizBrace"&&(n=!!i.sup,n===i.base.isOver&&(t=!0,r=i.base.isOver)),i.base&&(i.base.type==="op"||i.base.type==="operatorname")&&(i.base.parentIsSupSub=!0);var s=[ze(i.base,e)];i.sub&&s.push(ze(i.sub,e)),i.sup&&s.push(ze(i.sup,e));var a;if(t)a=r?"mover":"munder";else if(i.sub)if(i.sup){var h=i.base;h&&h.type==="op"&&h.limits&&e.style===ae.DISPLAY||h&&h.type==="operatorname"&&h.alwaysHandleSupSub&&(e.style===ae.DISPLAY||h.limits)?a="munderover":a="msubsup"}else{var l=i.base;l&&l.type==="op"&&l.limits&&(e.style===ae.DISPLAY||l.alwaysHandleSupSub)||l&&l.type==="operatorname"&&l.alwaysHandleSupSub&&(l.limits||e.style===ae.DISPLAY)?a="munder":a="msub"}else{var o=i.base;o&&o.type==="op"&&o.limits&&(e.style===ae.DISPLAY||o.alwaysHandleSupSub)||o&&o.type==="operatorname"&&o.alwaysHandleSupSub&&(o.limits||e.style===ae.DISPLAY)?a="mover":a="msup"}return new $.MathNode(a,s)}});gs({type:"atom",htmlBuilder(i,e){return z.mathsym(i.text,i.mode,e,["m"+i.family])},mathmlBuilder(i,e){var t=new $.MathNode("mo",[Ci(i.text,i.mode)]);if(i.family==="bin"){var r=S1(i,e);r==="bold-italic"&&t.setAttribute("mathvariant",r)}else i.family==="punct"?t.setAttribute("separator","true"):(i.family==="open"||i.family==="close")&&t.setAttribute("stretchy","false");return t}});eg={mi:"italic",mn:"normal",mtext:"normal"};gs({type:"mathord",htmlBuilder(i,e){return z.makeOrd(i,e,"mathord")},mathmlBuilder(i,e){var t=new $.MathNode("mi",[Ci(i.text,i.mode,e)]),r=S1(i,e)||"italic";return r!==eg[t.type]&&t.setAttribute("mathvariant",r),t}});gs({type:"textord",htmlBuilder(i,e){return z.makeOrd(i,e,"textord")},mathmlBuilder(i,e){var t=Ci(i.text,i.mode,e),r=S1(i,e)||"normal",n;return i.mode==="text"?n=new $.MathNode("mtext",[t]):/[0-9]/.test(i.text)?n=new $.MathNode("mn",[t]):i.text==="\\prime"?n=new $.MathNode("mo",[t]):n=new $.MathNode("mi",[t]),r!==eg[n.type]&&n.setAttribute("mathvariant",r),n}});o1={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},l1={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};gs({type:"spacing",htmlBuilder(i,e){if(l1.hasOwnProperty(i.text)){var t=l1[i.text].className||"";if(i.mode==="text"){var r=z.makeOrd(i,e,"textord");return r.classes.push(t),r}else return z.makeSpan(["mspace",t],[z.mathsym(i.text,i.mode,e)],e)}else{if(o1.hasOwnProperty(i.text))return z.makeSpan(["mspace",o1[i.text]],[],e);throw new G('Unknown type of space "'+i.text+'"')}},mathmlBuilder(i,e){var t;if(l1.hasOwnProperty(i.text))t=new $.MathNode("mtext",[new $.TextNode("\xA0")]);else{if(o1.hasOwnProperty(i.text))return new $.MathNode("mspace");throw new G('Unknown type of space "'+i.text+'"')}return t}});r4=()=>{var i=new $.MathNode("mtd",[]);return i.setAttribute("width","50%"),i};gs({type:"tag",mathmlBuilder(i,e){var t=new $.MathNode("mtable",[new $.MathNode("mtr",[r4(),new $.MathNode("mtd",[vn(i.body,e)]),r4(),new $.MathNode("mtd",[vn(i.tag,e)])])]);return t.setAttribute("width","100%"),t}});n4={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},s4={"\\textbf":"textbf","\\textmd":"textmd"},FA={"\\textit":"textit","\\textup":"textup"},a4=(i,e)=>{var t=i.font;if(t){if(n4[t])return e.withTextFontFamily(n4[t]);if(s4[t])return e.withTextFontWeight(s4[t]);if(t==="\\emph")return e.fontShape==="textit"?e.withTextFontShape("textup"):e.withTextFontShape("textit")}else return e;return e.withTextFontShape(FA[t])};Z({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(i,e){var{parser:t,funcName:r}=i,n=e[0];return{type:"text",mode:t.mode,body:rt(n),font:r}},htmlBuilder(i,e){var t=a4(i,e),r=ct(i.body,t,!0);return z.makeSpan(["mord","text"],r,t)},mathmlBuilder(i,e){var t=a4(i,e);return vn(i.body,t)}});Z({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(i,e){var{parser:t}=i;return{type:"underline",mode:t.mode,body:e[0]}},htmlBuilder(i,e){var t=Me(i.body,e),r=z.makeLineSpan("underline-line",e),n=e.fontMetrics().defaultRuleThickness,s=z.makeVList({positionType:"top",positionData:t.height,children:[{type:"kern",size:n},{type:"elem",elem:r},{type:"kern",size:3*n},{type:"elem",elem:t}]},e);return z.makeSpan(["mord","underline"],[s],e)},mathmlBuilder(i,e){var t=new $.MathNode("mo",[new $.TextNode("\u203E")]);t.setAttribute("stretchy","true");var r=new $.MathNode("munder",[ze(i.body,e),t]);return r.setAttribute("accentunder","true"),r}});Z({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(i,e){var{parser:t}=i;return{type:"vcenter",mode:t.mode,body:e[0]}},htmlBuilder(i,e){var t=Me(i.body,e),r=e.fontMetrics().axisHeight,n=.5*(t.height-r-(t.depth+r));return z.makeVList({positionType:"shift",positionData:n,children:[{type:"elem",elem:t}]},e)},mathmlBuilder(i,e){return new $.MathNode("mpadded",[ze(i.body,e)],["vcenter"])}});Z({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(i,e,t){throw new G("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(i,e){for(var t=o4(i),r=[],n=e.havingStyle(e.style.text()),s=0;si.body.replace(/ /g,i.star?"\u2423":"\xA0"),xn=T4,tg=`[ \r + ]`,qA="\\\\[a-zA-Z@]+",HA="\\\\[^\uD800-\uDFFF]",UA="("+qA+")"+tg+"*",$A=`\\\\( |[ \r ]+ -?)[ \r ]*`,vu="[\u0300-\u036F]",CE=new RegExp(vu+"+$"),_E="("+M6+"+)|"+(kE+"|")+"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]"+(vu+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(vu+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+AE)+("|"+SE+")"),F0=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(_E,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new ii("EOF",new Ut(this,t,t));var r=this.tokenRegex.exec(e);if(r===null||r.index!==t)throw new U("Unexpected character: '"+e[t]+"'",new ii(e[t],new Ut(this,t,t+1)));var n=r[6]||r[3]||(r[2]?"\\ ":" ");if(this.catcodes[n]===14){var s=e.indexOf(` -`,this.tokenRegex.lastIndex);return s===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=s+1,this.lex()}return new ii(n,new Ut(this,t,this.tokenRegex.lastIndex))}},yu=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new U("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t in e)e.hasOwnProperty(t)&&(e[t]==null?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,r){if(r===void 0&&(r=!1),r){for(var n=0;n0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var s=this.undefStack[this.undefStack.length-1];s&&!s.hasOwnProperty(e)&&(s[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}},LE=c6;w("\\noexpand",function(i){var e=i.popToken();return i.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}});w("\\expandafter",function(i){var e=i.popToken();return i.expandOnce(!0),{tokens:[e],numArgs:0}});w("\\@firstoftwo",function(i){var e=i.consumeArgs(2);return{tokens:e[0],numArgs:0}});w("\\@secondoftwo",function(i){var e=i.consumeArgs(2);return{tokens:e[1],numArgs:0}});w("\\@ifnextchar",function(i){var e=i.consumeArgs(3);i.consumeSpaces();var t=i.future();return e[0].length===1&&e[0][0].text===t.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}});w("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");w("\\TextOrMath",function(i){var e=i.consumeArgs(2);return i.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});C2={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};w("\\char",function(i){var e=i.popToken(),t,r="";if(e.text==="'")t=8,e=i.popToken();else if(e.text==='"')t=16,e=i.popToken();else if(e.text==="`")if(e=i.popToken(),e.text[0]==="\\")r=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new U("\\char` missing argument");r=e.text.charCodeAt(0)}else t=10;if(t){if(r=C2[e.text],r==null||r>=t)throw new U("Invalid base-"+t+" digit "+e.text);for(var n;(n=C2[i.future().text])!=null&&n{var n=i.consumeArg().tokens;if(n.length!==1)throw new U("\\newcommand's first argument must be a macro name");var s=n[0].text,a=i.isDefined(s);if(a&&!e)throw new U("\\newcommand{"+s+"} attempting to redefine "+(s+"; use \\renewcommand"));if(!a&&!t)throw new U("\\renewcommand{"+s+"} when command "+s+" does not yet exist; use \\newcommand");var o=0;if(n=i.consumeArg().tokens,n.length===1&&n[0].text==="["){for(var l="",h=i.expandNextToken();h.text!=="]"&&h.text!=="EOF";)l+=h.text,h=i.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new U("Invalid number of arguments: "+l);o=parseInt(l),n=i.consumeArg().tokens}return a&&r||i.macros.set(s,{tokens:n,numArgs:o}),""};w("\\newcommand",i=>Du(i,!1,!0,!1));w("\\renewcommand",i=>Du(i,!0,!1,!1));w("\\providecommand",i=>Du(i,!0,!0,!0));w("\\message",i=>{var e=i.consumeArgs(1)[0];return console.log(e.reverse().map(t=>t.text).join("")),""});w("\\errmessage",i=>{var e=i.consumeArgs(1)[0];return console.error(e.reverse().map(t=>t.text).join("")),""});w("\\show",i=>{var e=i.popToken(),t=e.text;return console.log(e,i.macros.get(t),Kr[t],Ce.math[t],Ce.text[t]),""});w("\\bgroup","{");w("\\egroup","}");w("~","\\nobreakspace");w("\\lq","`");w("\\rq","'");w("\\aa","\\r a");w("\\AA","\\r A");w("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xA9}");w("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");w("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xAE}");w("\u212C","\\mathscr{B}");w("\u2130","\\mathscr{E}");w("\u2131","\\mathscr{F}");w("\u210B","\\mathscr{H}");w("\u2110","\\mathscr{I}");w("\u2112","\\mathscr{L}");w("\u2133","\\mathscr{M}");w("\u211B","\\mathscr{R}");w("\u212D","\\mathfrak{C}");w("\u210C","\\mathfrak{H}");w("\u2128","\\mathfrak{Z}");w("\\Bbbk","\\Bbb{k}");w("\xB7","\\cdotp");w("\\llap","\\mathllap{\\textrm{#1}}");w("\\rlap","\\mathrlap{\\textrm{#1}}");w("\\clap","\\mathclap{\\textrm{#1}}");w("\\mathstrut","\\vphantom{(}");w("\\underbar","\\underline{\\text{#1}}");w("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}');w("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}");w("\\ne","\\neq");w("\u2260","\\neq");w("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}");w("\u2209","\\notin");w("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}");w("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}");w("\u225A","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}");w("\u225B","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225B}}");w("\u225D","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225D}}");w("\u225E","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225E}}");w("\u225F","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}");w("\u27C2","\\perp");w("\u203C","\\mathclose{!\\mkern-0.8mu!}");w("\u220C","\\notni");w("\u231C","\\ulcorner");w("\u231D","\\urcorner");w("\u231E","\\llcorner");w("\u231F","\\lrcorner");w("\xA9","\\copyright");w("\xAE","\\textregistered");w("\uFE0F","\\textregistered");w("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');w("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');w("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');w("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');w("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");w("\u22EE","\\vdots");w("\\varGamma","\\mathit{\\Gamma}");w("\\varDelta","\\mathit{\\Delta}");w("\\varTheta","\\mathit{\\Theta}");w("\\varLambda","\\mathit{\\Lambda}");w("\\varXi","\\mathit{\\Xi}");w("\\varPi","\\mathit{\\Pi}");w("\\varSigma","\\mathit{\\Sigma}");w("\\varUpsilon","\\mathit{\\Upsilon}");w("\\varPhi","\\mathit{\\Phi}");w("\\varPsi","\\mathit{\\Psi}");w("\\varOmega","\\mathit{\\Omega}");w("\\substack","\\begin{subarray}{c}#1\\end{subarray}");w("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");w("\\boxed","\\fbox{$\\displaystyle{#1}$}");w("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");w("\\implies","\\DOTSB\\;\\Longrightarrow\\;");w("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");w("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");w("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");_2={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};w("\\dots",function(i){var e="\\dotso",t=i.expandAfterFuture().text;return t in _2?e=_2[t]:(t.slice(0,4)==="\\not"||t in Ce.math&&["bin","rel"].includes(Ce.math[t].group))&&(e="\\dotsb"),e});Ou={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};w("\\dotso",function(i){var e=i.future().text;return e in Ou?"\\ldots\\,":"\\ldots"});w("\\dotsc",function(i){var e=i.future().text;return e in Ou&&e!==","?"\\ldots\\,":"\\ldots"});w("\\cdots",function(i){var e=i.future().text;return e in Ou?"\\@cdots\\,":"\\@cdots"});w("\\dotsb","\\cdots");w("\\dotsm","\\cdots");w("\\dotsi","\\!\\cdots");w("\\dotsx","\\ldots\\,");w("\\DOTSI","\\relax");w("\\DOTSB","\\relax");w("\\DOTSX","\\relax");w("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");w("\\,","\\tmspace+{3mu}{.1667em}");w("\\thinspace","\\,");w("\\>","\\mskip{4mu}");w("\\:","\\tmspace+{4mu}{.2222em}");w("\\medspace","\\:");w("\\;","\\tmspace+{5mu}{.2777em}");w("\\thickspace","\\;");w("\\!","\\tmspace-{3mu}{.1667em}");w("\\negthinspace","\\!");w("\\negmedspace","\\tmspace-{4mu}{.2222em}");w("\\negthickspace","\\tmspace-{5mu}{.277em}");w("\\enspace","\\kern.5em ");w("\\enskip","\\hskip.5em\\relax");w("\\quad","\\hskip1em\\relax");w("\\qquad","\\hskip2em\\relax");w("\\tag","\\@ifstar\\tag@literal\\tag@paren");w("\\tag@paren","\\tag@literal{({#1})}");w("\\tag@literal",i=>{if(i.macros.get("\\df@tag"))throw new U("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});w("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");w("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");w("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");w("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");w("\\newline","\\\\\\relax");w("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");T6=j(Yi["Main-Regular"][84][1]-.7*Yi["Main-Regular"][65][1]);w("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+T6+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");w("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+T6+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");w("\\hspace","\\@ifstar\\@hspacer\\@hspace");w("\\@hspace","\\hskip #1\\relax");w("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");w("\\ordinarycolon",":");w("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");w("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');w("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');w("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');w("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');w("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');w("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');w("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');w("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');w("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');w("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');w("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');w("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');w("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');w("\u2237","\\dblcolon");w("\u2239","\\eqcolon");w("\u2254","\\coloneqq");w("\u2255","\\eqqcolon");w("\u2A74","\\Coloneqq");w("\\ratio","\\vcentcolon");w("\\coloncolon","\\dblcolon");w("\\colonequals","\\coloneqq");w("\\coloncolonequals","\\Coloneqq");w("\\equalscolon","\\eqqcolon");w("\\equalscoloncolon","\\Eqqcolon");w("\\colonminus","\\coloneq");w("\\coloncolonminus","\\Coloneq");w("\\minuscolon","\\eqcolon");w("\\minuscoloncolon","\\Eqcolon");w("\\coloncolonapprox","\\Colonapprox");w("\\coloncolonsim","\\Colonsim");w("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");w("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");w("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");w("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");w("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");w("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");w("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");w("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");w("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");w("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}");w("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}");w("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}");w("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}");w("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}");w("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}");w("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}");w("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}");w("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}");w("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}");w("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228A}");w("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2ACB}");w("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228B}");w("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2ACC}");w("\\imath","\\html@mathml{\\@imath}{\u0131}");w("\\jmath","\\html@mathml{\\@jmath}{\u0237}");w("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27E6}}");w("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27E7}}");w("\u27E6","\\llbracket");w("\u27E7","\\rrbracket");w("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}");w("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}");w("\u2983","\\lBrace");w("\u2984","\\rBrace");w("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29B5}}");w("\u29B5","\\minuso");w("\\darr","\\downarrow");w("\\dArr","\\Downarrow");w("\\Darr","\\Downarrow");w("\\lang","\\langle");w("\\rang","\\rangle");w("\\uarr","\\uparrow");w("\\uArr","\\Uparrow");w("\\Uarr","\\Uparrow");w("\\N","\\mathbb{N}");w("\\R","\\mathbb{R}");w("\\Z","\\mathbb{Z}");w("\\alef","\\aleph");w("\\alefsym","\\aleph");w("\\Alpha","\\mathrm{A}");w("\\Beta","\\mathrm{B}");w("\\bull","\\bullet");w("\\Chi","\\mathrm{X}");w("\\clubs","\\clubsuit");w("\\cnums","\\mathbb{C}");w("\\Complex","\\mathbb{C}");w("\\Dagger","\\ddagger");w("\\diamonds","\\diamondsuit");w("\\empty","\\emptyset");w("\\Epsilon","\\mathrm{E}");w("\\Eta","\\mathrm{H}");w("\\exist","\\exists");w("\\harr","\\leftrightarrow");w("\\hArr","\\Leftrightarrow");w("\\Harr","\\Leftrightarrow");w("\\hearts","\\heartsuit");w("\\image","\\Im");w("\\infin","\\infty");w("\\Iota","\\mathrm{I}");w("\\isin","\\in");w("\\Kappa","\\mathrm{K}");w("\\larr","\\leftarrow");w("\\lArr","\\Leftarrow");w("\\Larr","\\Leftarrow");w("\\lrarr","\\leftrightarrow");w("\\lrArr","\\Leftrightarrow");w("\\Lrarr","\\Leftrightarrow");w("\\Mu","\\mathrm{M}");w("\\natnums","\\mathbb{N}");w("\\Nu","\\mathrm{N}");w("\\Omicron","\\mathrm{O}");w("\\plusmn","\\pm");w("\\rarr","\\rightarrow");w("\\rArr","\\Rightarrow");w("\\Rarr","\\Rightarrow");w("\\real","\\Re");w("\\reals","\\mathbb{R}");w("\\Reals","\\mathbb{R}");w("\\Rho","\\mathrm{P}");w("\\sdot","\\cdot");w("\\sect","\\S");w("\\spades","\\spadesuit");w("\\sub","\\subset");w("\\sube","\\subseteq");w("\\supe","\\supseteq");w("\\Tau","\\mathrm{T}");w("\\thetasym","\\vartheta");w("\\weierp","\\wp");w("\\Zeta","\\mathrm{Z}");w("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");w("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");w("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");w("\\bra","\\mathinner{\\langle{#1}|}");w("\\ket","\\mathinner{|{#1}\\rangle}");w("\\braket","\\mathinner{\\langle{#1}\\rangle}");w("\\Bra","\\left\\langle#1\\right|");w("\\Ket","\\left|#1\\right\\rangle");N6=i=>e=>{var t=e.consumeArg().tokens,r=e.consumeArg().tokens,n=e.consumeArg().tokens,s=e.consumeArg().tokens,a=e.macros.get("|"),o=e.macros.get("\\|");e.macros.beginGroup();var l=c=>f=>{i&&(f.macros.set("|",a),n.length&&f.macros.set("\\|",o));var m=c;if(!c&&n.length){var g=f.future();g.text==="|"&&(f.popToken(),m=!0)}return{tokens:m?n:r,numArgs:0}};e.macros.set("|",l(!1)),n.length&&e.macros.set("\\|",l(!0));var h=e.consumeArg().tokens,d=e.expandTokens([...s,...h,...t]);return e.macros.endGroup(),{tokens:d.reverse(),numArgs:0}};w("\\bra@ket",N6(!1));w("\\bra@set",N6(!0));w("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");w("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");w("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");w("\\angln","{\\angl n}");w("\\blue","\\textcolor{##6495ed}{#1}");w("\\orange","\\textcolor{##ffa500}{#1}");w("\\pink","\\textcolor{##ff00af}{#1}");w("\\red","\\textcolor{##df0030}{#1}");w("\\green","\\textcolor{##28ae7b}{#1}");w("\\gray","\\textcolor{gray}{#1}");w("\\purple","\\textcolor{##9d38bd}{#1}");w("\\blueA","\\textcolor{##ccfaff}{#1}");w("\\blueB","\\textcolor{##80f6ff}{#1}");w("\\blueC","\\textcolor{##63d9ea}{#1}");w("\\blueD","\\textcolor{##11accd}{#1}");w("\\blueE","\\textcolor{##0c7f99}{#1}");w("\\tealA","\\textcolor{##94fff5}{#1}");w("\\tealB","\\textcolor{##26edd5}{#1}");w("\\tealC","\\textcolor{##01d1c1}{#1}");w("\\tealD","\\textcolor{##01a995}{#1}");w("\\tealE","\\textcolor{##208170}{#1}");w("\\greenA","\\textcolor{##b6ffb0}{#1}");w("\\greenB","\\textcolor{##8af281}{#1}");w("\\greenC","\\textcolor{##74cf70}{#1}");w("\\greenD","\\textcolor{##1fab54}{#1}");w("\\greenE","\\textcolor{##0d923f}{#1}");w("\\goldA","\\textcolor{##ffd0a9}{#1}");w("\\goldB","\\textcolor{##ffbb71}{#1}");w("\\goldC","\\textcolor{##ff9c39}{#1}");w("\\goldD","\\textcolor{##e07d10}{#1}");w("\\goldE","\\textcolor{##a75a05}{#1}");w("\\redA","\\textcolor{##fca9a9}{#1}");w("\\redB","\\textcolor{##ff8482}{#1}");w("\\redC","\\textcolor{##f9685d}{#1}");w("\\redD","\\textcolor{##e84d39}{#1}");w("\\redE","\\textcolor{##bc2612}{#1}");w("\\maroonA","\\textcolor{##ffbde0}{#1}");w("\\maroonB","\\textcolor{##ff92c6}{#1}");w("\\maroonC","\\textcolor{##ed5fa6}{#1}");w("\\maroonD","\\textcolor{##ca337c}{#1}");w("\\maroonE","\\textcolor{##9e034e}{#1}");w("\\purpleA","\\textcolor{##ddd7ff}{#1}");w("\\purpleB","\\textcolor{##c6b9fc}{#1}");w("\\purpleC","\\textcolor{##aa87ff}{#1}");w("\\purpleD","\\textcolor{##7854ab}{#1}");w("\\purpleE","\\textcolor{##543b78}{#1}");w("\\mintA","\\textcolor{##f5f9e8}{#1}");w("\\mintB","\\textcolor{##edf2df}{#1}");w("\\mintC","\\textcolor{##e0e5cc}{#1}");w("\\grayA","\\textcolor{##f6f7f7}{#1}");w("\\grayB","\\textcolor{##f0f1f2}{#1}");w("\\grayC","\\textcolor{##e3e5e6}{#1}");w("\\grayD","\\textcolor{##d6d8da}{#1}");w("\\grayE","\\textcolor{##babec2}{#1}");w("\\grayF","\\textcolor{##888d93}{#1}");w("\\grayG","\\textcolor{##626569}{#1}");w("\\grayH","\\textcolor{##3b3e40}{#1}");w("\\grayI","\\textcolor{##21242c}{#1}");w("\\kaBlue","\\textcolor{##314453}{#1}");w("\\kaGreen","\\textcolor{##71B307}{#1}");E6={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},bu=class{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new yu(LE,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new F0(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,r,n;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;t=this.popToken(),{tokens:n,end:r}=this.consumeArg(["]"])}else({tokens:n,start:t,end:r}=this.consumeArg());return this.pushToken(new ii("EOF",r.loc)),this.pushTokens(n),new ii("",Ut.range(t,r))}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var t=[],r=e&&e.length>0;r||this.consumeSpaces();var n=this.future(),s,a=0,o=0;do{if(s=this.popToken(),t.push(s),s.text==="{")++a;else if(s.text==="}"){if(--a,a===-1)throw new U("Extra }",s)}else if(s.text==="EOF")throw new U("Unexpected end of input in a macro argument, expected '"+(e&&r?e[o]:"}")+"'",s);if(e&&r)if((a===0||a===1&&e[o]==="{")&&s.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}while(a!==0||r);return n.text==="{"&&t[t.length-1].text==="}"&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:n,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new U("The length of delimiters doesn't match the number of args!");for(var r=t[0],n=0;nthis.settings.maxExpand)throw new U("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),r=t.text,n=t.noexpand?null:this._getExpansion(r);if(n==null||e&&n.unexpandable){if(e&&n==null&&r[0]==="\\"&&!this.isDefined(r))throw new U("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);var s=n.tokens,a=this.consumeArgs(n.numArgs,n.delimiters);if(n.numArgs){s=s.slice();for(var o=s.length-1;o>=0;--o){var l=s[o];if(l.text==="#"){if(o===0)throw new U("Incomplete placeholder at end of macro body",l);if(l=s[--o],l.text==="#")s.splice(o+1,1);else if(/^[1-9]$/.test(l.text))s.splice(o,2,...a[+l.text-1]);else throw new U("Not a valid argument number",l)}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new ii(e)]):void 0}expandTokens(e){var t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(this.expandOnce(!0)===!1){var n=this.stack.pop();n.treatAsRelax&&(n.noexpand=!1,n.treatAsRelax=!1),t.push(n)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(r=>r.text).join("")}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var r=this.lexer.catcodes[e];if(r!=null&&r!==13)return}var n=typeof t=="function"?t(this):t;if(typeof n=="string"){var s=0;if(n.indexOf("#")!==-1)for(var a=n.replace(/##/g,"");a.indexOf("#"+(s+1))!==-1;)++s;for(var o=new F0(n,this.settings),l=[],h=o.lex();h.text!=="EOF";)l.push(h),h=o.lex();l.reverse();var d={tokens:l,numArgs:s};return d}return n}isDefined(e){return this.macros.has(e)||Kr.hasOwnProperty(e)||Ce.math.hasOwnProperty(e)||Ce.text.hasOwnProperty(e)||E6.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:Kr.hasOwnProperty(e)&&!Kr[e].primitive}},L2=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,_0=Object.freeze({"\u208A":"+","\u208B":"-","\u208C":"=","\u208D":"(","\u208E":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1D62":"i","\u2C7C":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209A":"p","\u1D63":"r","\u209B":"s","\u209C":"t","\u1D64":"u","\u1D65":"v","\u2093":"x","\u1D66":"\u03B2","\u1D67":"\u03B3","\u1D68":"\u03C1","\u1D69":"\u03D5","\u1D6A":"\u03C7","\u207A":"+","\u207B":"-","\u207C":"=","\u207D":"(","\u207E":")","\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1D2C":"A","\u1D2E":"B","\u1D30":"D","\u1D31":"E","\u1D33":"G","\u1D34":"H","\u1D35":"I","\u1D36":"J","\u1D37":"K","\u1D38":"L","\u1D39":"M","\u1D3A":"N","\u1D3C":"O","\u1D3E":"P","\u1D3F":"R","\u1D40":"T","\u1D41":"U","\u2C7D":"V","\u1D42":"W","\u1D43":"a","\u1D47":"b","\u1D9C":"c","\u1D48":"d","\u1D49":"e","\u1DA0":"f","\u1D4D":"g",\u02B0:"h","\u2071":"i",\u02B2:"j","\u1D4F":"k",\u02E1:"l","\u1D50":"m",\u207F:"n","\u1D52":"o","\u1D56":"p",\u02B3:"r",\u02E2:"s","\u1D57":"t","\u1D58":"u","\u1D5B":"v",\u02B7:"w",\u02E3:"x",\u02B8:"y","\u1DBB":"z","\u1D5D":"\u03B2","\u1D5E":"\u03B3","\u1D5F":"\u03B4","\u1D60":"\u03D5","\u1D61":"\u03C7","\u1DBF":"\u03B8"}),lu={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030C":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030A":{text:"\\r",math:"\\mathring"},"\u030B":{text:"\\H"},"\u0327":{text:"\\c"}},z2={\u00E1:"a\u0301",\u00E0:"a\u0300",\u00E4:"a\u0308",\u01DF:"a\u0308\u0304",\u00E3:"a\u0303",\u0101:"a\u0304",\u0103:"a\u0306",\u1EAF:"a\u0306\u0301",\u1EB1:"a\u0306\u0300",\u1EB5:"a\u0306\u0303",\u01CE:"a\u030C",\u00E2:"a\u0302",\u1EA5:"a\u0302\u0301",\u1EA7:"a\u0302\u0300",\u1EAB:"a\u0302\u0303",\u0227:"a\u0307",\u01E1:"a\u0307\u0304",\u00E5:"a\u030A",\u01FB:"a\u030A\u0301",\u1E03:"b\u0307",\u0107:"c\u0301",\u1E09:"c\u0327\u0301",\u010D:"c\u030C",\u0109:"c\u0302",\u010B:"c\u0307",\u00E7:"c\u0327",\u010F:"d\u030C",\u1E0B:"d\u0307",\u1E11:"d\u0327",\u00E9:"e\u0301",\u00E8:"e\u0300",\u00EB:"e\u0308",\u1EBD:"e\u0303",\u0113:"e\u0304",\u1E17:"e\u0304\u0301",\u1E15:"e\u0304\u0300",\u0115:"e\u0306",\u1E1D:"e\u0327\u0306",\u011B:"e\u030C",\u00EA:"e\u0302",\u1EBF:"e\u0302\u0301",\u1EC1:"e\u0302\u0300",\u1EC5:"e\u0302\u0303",\u0117:"e\u0307",\u0229:"e\u0327",\u1E1F:"f\u0307",\u01F5:"g\u0301",\u1E21:"g\u0304",\u011F:"g\u0306",\u01E7:"g\u030C",\u011D:"g\u0302",\u0121:"g\u0307",\u0123:"g\u0327",\u1E27:"h\u0308",\u021F:"h\u030C",\u0125:"h\u0302",\u1E23:"h\u0307",\u1E29:"h\u0327",\u00ED:"i\u0301",\u00EC:"i\u0300",\u00EF:"i\u0308",\u1E2F:"i\u0308\u0301",\u0129:"i\u0303",\u012B:"i\u0304",\u012D:"i\u0306",\u01D0:"i\u030C",\u00EE:"i\u0302",\u01F0:"j\u030C",\u0135:"j\u0302",\u1E31:"k\u0301",\u01E9:"k\u030C",\u0137:"k\u0327",\u013A:"l\u0301",\u013E:"l\u030C",\u013C:"l\u0327",\u1E3F:"m\u0301",\u1E41:"m\u0307",\u0144:"n\u0301",\u01F9:"n\u0300",\u00F1:"n\u0303",\u0148:"n\u030C",\u1E45:"n\u0307",\u0146:"n\u0327",\u00F3:"o\u0301",\u00F2:"o\u0300",\u00F6:"o\u0308",\u022B:"o\u0308\u0304",\u00F5:"o\u0303",\u1E4D:"o\u0303\u0301",\u1E4F:"o\u0303\u0308",\u022D:"o\u0303\u0304",\u014D:"o\u0304",\u1E53:"o\u0304\u0301",\u1E51:"o\u0304\u0300",\u014F:"o\u0306",\u01D2:"o\u030C",\u00F4:"o\u0302",\u1ED1:"o\u0302\u0301",\u1ED3:"o\u0302\u0300",\u1ED7:"o\u0302\u0303",\u022F:"o\u0307",\u0231:"o\u0307\u0304",\u0151:"o\u030B",\u1E55:"p\u0301",\u1E57:"p\u0307",\u0155:"r\u0301",\u0159:"r\u030C",\u1E59:"r\u0307",\u0157:"r\u0327",\u015B:"s\u0301",\u1E65:"s\u0301\u0307",\u0161:"s\u030C",\u1E67:"s\u030C\u0307",\u015D:"s\u0302",\u1E61:"s\u0307",\u015F:"s\u0327",\u1E97:"t\u0308",\u0165:"t\u030C",\u1E6B:"t\u0307",\u0163:"t\u0327",\u00FA:"u\u0301",\u00F9:"u\u0300",\u00FC:"u\u0308",\u01D8:"u\u0308\u0301",\u01DC:"u\u0308\u0300",\u01D6:"u\u0308\u0304",\u01DA:"u\u0308\u030C",\u0169:"u\u0303",\u1E79:"u\u0303\u0301",\u016B:"u\u0304",\u1E7B:"u\u0304\u0308",\u016D:"u\u0306",\u01D4:"u\u030C",\u00FB:"u\u0302",\u016F:"u\u030A",\u0171:"u\u030B",\u1E7D:"v\u0303",\u1E83:"w\u0301",\u1E81:"w\u0300",\u1E85:"w\u0308",\u0175:"w\u0302",\u1E87:"w\u0307",\u1E98:"w\u030A",\u1E8D:"x\u0308",\u1E8B:"x\u0307",\u00FD:"y\u0301",\u1EF3:"y\u0300",\u00FF:"y\u0308",\u1EF9:"y\u0303",\u0233:"y\u0304",\u0177:"y\u0302",\u1E8F:"y\u0307",\u1E99:"y\u030A",\u017A:"z\u0301",\u017E:"z\u030C",\u1E91:"z\u0302",\u017C:"z\u0307",\u00C1:"A\u0301",\u00C0:"A\u0300",\u00C4:"A\u0308",\u01DE:"A\u0308\u0304",\u00C3:"A\u0303",\u0100:"A\u0304",\u0102:"A\u0306",\u1EAE:"A\u0306\u0301",\u1EB0:"A\u0306\u0300",\u1EB4:"A\u0306\u0303",\u01CD:"A\u030C",\u00C2:"A\u0302",\u1EA4:"A\u0302\u0301",\u1EA6:"A\u0302\u0300",\u1EAA:"A\u0302\u0303",\u0226:"A\u0307",\u01E0:"A\u0307\u0304",\u00C5:"A\u030A",\u01FA:"A\u030A\u0301",\u1E02:"B\u0307",\u0106:"C\u0301",\u1E08:"C\u0327\u0301",\u010C:"C\u030C",\u0108:"C\u0302",\u010A:"C\u0307",\u00C7:"C\u0327",\u010E:"D\u030C",\u1E0A:"D\u0307",\u1E10:"D\u0327",\u00C9:"E\u0301",\u00C8:"E\u0300",\u00CB:"E\u0308",\u1EBC:"E\u0303",\u0112:"E\u0304",\u1E16:"E\u0304\u0301",\u1E14:"E\u0304\u0300",\u0114:"E\u0306",\u1E1C:"E\u0327\u0306",\u011A:"E\u030C",\u00CA:"E\u0302",\u1EBE:"E\u0302\u0301",\u1EC0:"E\u0302\u0300",\u1EC4:"E\u0302\u0303",\u0116:"E\u0307",\u0228:"E\u0327",\u1E1E:"F\u0307",\u01F4:"G\u0301",\u1E20:"G\u0304",\u011E:"G\u0306",\u01E6:"G\u030C",\u011C:"G\u0302",\u0120:"G\u0307",\u0122:"G\u0327",\u1E26:"H\u0308",\u021E:"H\u030C",\u0124:"H\u0302",\u1E22:"H\u0307",\u1E28:"H\u0327",\u00CD:"I\u0301",\u00CC:"I\u0300",\u00CF:"I\u0308",\u1E2E:"I\u0308\u0301",\u0128:"I\u0303",\u012A:"I\u0304",\u012C:"I\u0306",\u01CF:"I\u030C",\u00CE:"I\u0302",\u0130:"I\u0307",\u0134:"J\u0302",\u1E30:"K\u0301",\u01E8:"K\u030C",\u0136:"K\u0327",\u0139:"L\u0301",\u013D:"L\u030C",\u013B:"L\u0327",\u1E3E:"M\u0301",\u1E40:"M\u0307",\u0143:"N\u0301",\u01F8:"N\u0300",\u00D1:"N\u0303",\u0147:"N\u030C",\u1E44:"N\u0307",\u0145:"N\u0327",\u00D3:"O\u0301",\u00D2:"O\u0300",\u00D6:"O\u0308",\u022A:"O\u0308\u0304",\u00D5:"O\u0303",\u1E4C:"O\u0303\u0301",\u1E4E:"O\u0303\u0308",\u022C:"O\u0303\u0304",\u014C:"O\u0304",\u1E52:"O\u0304\u0301",\u1E50:"O\u0304\u0300",\u014E:"O\u0306",\u01D1:"O\u030C",\u00D4:"O\u0302",\u1ED0:"O\u0302\u0301",\u1ED2:"O\u0302\u0300",\u1ED6:"O\u0302\u0303",\u022E:"O\u0307",\u0230:"O\u0307\u0304",\u0150:"O\u030B",\u1E54:"P\u0301",\u1E56:"P\u0307",\u0154:"R\u0301",\u0158:"R\u030C",\u1E58:"R\u0307",\u0156:"R\u0327",\u015A:"S\u0301",\u1E64:"S\u0301\u0307",\u0160:"S\u030C",\u1E66:"S\u030C\u0307",\u015C:"S\u0302",\u1E60:"S\u0307",\u015E:"S\u0327",\u0164:"T\u030C",\u1E6A:"T\u0307",\u0162:"T\u0327",\u00DA:"U\u0301",\u00D9:"U\u0300",\u00DC:"U\u0308",\u01D7:"U\u0308\u0301",\u01DB:"U\u0308\u0300",\u01D5:"U\u0308\u0304",\u01D9:"U\u0308\u030C",\u0168:"U\u0303",\u1E78:"U\u0303\u0301",\u016A:"U\u0304",\u1E7A:"U\u0304\u0308",\u016C:"U\u0306",\u01D3:"U\u030C",\u00DB:"U\u0302",\u016E:"U\u030A",\u0170:"U\u030B",\u1E7C:"V\u0303",\u1E82:"W\u0301",\u1E80:"W\u0300",\u1E84:"W\u0308",\u0174:"W\u0302",\u1E86:"W\u0307",\u1E8C:"X\u0308",\u1E8A:"X\u0307",\u00DD:"Y\u0301",\u1EF2:"Y\u0300",\u0178:"Y\u0308",\u1EF8:"Y\u0303",\u0232:"Y\u0304",\u0176:"Y\u0302",\u1E8E:"Y\u0307",\u0179:"Z\u0301",\u017D:"Z\u030C",\u1E90:"Z\u0302",\u017B:"Z\u0307",\u03AC:"\u03B1\u0301",\u1F70:"\u03B1\u0300",\u1FB1:"\u03B1\u0304",\u1FB0:"\u03B1\u0306",\u03AD:"\u03B5\u0301",\u1F72:"\u03B5\u0300",\u03AE:"\u03B7\u0301",\u1F74:"\u03B7\u0300",\u03AF:"\u03B9\u0301",\u1F76:"\u03B9\u0300",\u03CA:"\u03B9\u0308",\u0390:"\u03B9\u0308\u0301",\u1FD2:"\u03B9\u0308\u0300",\u1FD1:"\u03B9\u0304",\u1FD0:"\u03B9\u0306",\u03CC:"\u03BF\u0301",\u1F78:"\u03BF\u0300",\u03CD:"\u03C5\u0301",\u1F7A:"\u03C5\u0300",\u03CB:"\u03C5\u0308",\u03B0:"\u03C5\u0308\u0301",\u1FE2:"\u03C5\u0308\u0300",\u1FE1:"\u03C5\u0304",\u1FE0:"\u03C5\u0306",\u03CE:"\u03C9\u0301",\u1F7C:"\u03C9\u0300",\u038E:"\u03A5\u0301",\u1FEA:"\u03A5\u0300",\u03AB:"\u03A5\u0308",\u1FE9:"\u03A5\u0304",\u1FE8:"\u03A5\u0306",\u038F:"\u03A9\u0301",\u1FFA:"\u03A9\u0300"},q0=class i{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new bu(e,t,this.mode),this.settings=t,this.leftrightDepth=0}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new U("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new ii("}")),this.gullet.pushTokens(e);var r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){for(var r=[];;){this.mode==="math"&&this.consumeSpaces();var n=this.fetch();if(i.endOfExpression.indexOf(n.text)!==-1||t&&n.text===t||e&&Kr[n.text]&&Kr[n.text].infix)break;var s=this.parseAtom(t);if(s){if(s.type==="internal")continue}else break;r.push(s)}return this.mode==="text"&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,r,n=0;n=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var o=Ce[this.mode][t].group,l=Ut.range(e),h;if(MN.hasOwnProperty(o)){var d=o;h={type:"atom",mode:this.mode,family:d,loc:l,text:t}}else h={type:o,mode:this.mode,loc:l,text:t};a=h}else if(t.charCodeAt(0)>=128)this.settings.strict&&(R2(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),a={type:"textord",mode:"text",loc:Ut.range(e),text:t};else return null;if(this.consume(),s)for(var c=0;c{BE=typeof global=="object"&&global&&global.Object===Object&&global,V0=BE});var PE,FE,Ze,Di=M(()=>{Fu();PE=typeof self=="object"&&self&&self.Object===Object&&self,FE=V0||PE||Function("return this")(),Ze=FE});var qE,vi,Ao=M(()=>{Di();qE=Ze.Symbol,vi=qE});function $E(i){var e=HE.call(i,ko),t=i[ko];try{i[ko]=void 0;var r=!0}catch{}var n=UE.call(i);return r&&(e?i[ko]=t:delete i[ko]),n}var C6,HE,UE,ko,_6,L6=M(()=>{Ao();C6=Object.prototype,HE=C6.hasOwnProperty,UE=C6.toString,ko=vi?vi.toStringTag:void 0;_6=$E});function YE(i){return GE.call(i)}var jE,GE,z6,I6=M(()=>{jE=Object.prototype,GE=jE.toString;z6=YE});function XE(i){return i==null?i===void 0?VE:WE:R6&&R6 in Object(i)?_6(i):z6(i)}var WE,VE,R6,Oi,Fs=M(()=>{Ao();L6();I6();WE="[object Null]",VE="[object Undefined]",R6=vi?vi.toStringTag:void 0;Oi=XE});function KE(i){return i!=null&&typeof i=="object"}var dt,vr=M(()=>{dt=KE});var ZE,yi,qs=M(()=>{ZE=Array.isArray,yi=ZE});function QE(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var mt,yr=M(()=>{mt=QE});function JE(i){return i}var X0,qu=M(()=>{X0=JE});function nS(i){if(!mt(i))return!1;var e=Oi(i);return e==tS||e==iS||e==eS||e==rS}var eS,tS,iS,rS,Hs,K0=M(()=>{Fs();yr();eS="[object AsyncFunction]",tS="[object Function]",iS="[object GeneratorFunction]",rS="[object Proxy]";Hs=nS});var sS,Z0,D6=M(()=>{Di();sS=Ze["__core-js_shared__"],Z0=sS});function aS(i){return!!O6&&O6 in i}var O6,B6,P6=M(()=>{D6();O6=(function(){var i=/[^.]+$/.exec(Z0&&Z0.keys&&Z0.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();B6=aS});function hS(i){if(i!=null){try{return lS.call(i)}catch{}try{return i+""}catch{}}return""}var oS,lS,br,Hu=M(()=>{oS=Function.prototype,lS=oS.toString;br=hS});function xS(i){if(!mt(i)||B6(i))return!1;var e=Hs(i)?gS:cS;return e.test(br(i))}var dS,cS,uS,fS,mS,pS,gS,F6,q6=M(()=>{K0();P6();yr();Hu();dS=/[\\^$.*+?()[\]{}|]/g,cS=/^\[object .+?Constructor\]$/,uS=Function.prototype,fS=Object.prototype,mS=uS.toString,pS=fS.hasOwnProperty,gS=RegExp("^"+mS.call(pS).replace(dS,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");F6=xS});function vS(i,e){return i?.[e]}var H6,U6=M(()=>{H6=vS});function yS(i,e){var t=H6(i,e);return F6(t)?t:void 0}var Gt,en=M(()=>{q6();U6();Gt=yS});var bS,Q0,$6=M(()=>{en();Di();bS=Gt(Ze,"WeakMap"),Q0=bS});var j6,wS,G6,Y6=M(()=>{yr();j6=Object.create,wS=(function(){function i(){}return function(e){if(!mt(e))return{};if(j6)return j6(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}})(),G6=wS});function MS(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var W6,V6=M(()=>{W6=MS});function TS(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t{J0=TS});function AS(i){var e=0,t=0;return function(){var r=SS(),n=ES-(r-t);if(t=r,n>0){if(++e>=NS)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var NS,ES,SS,X6,K6=M(()=>{NS=800,ES=16,SS=Date.now;X6=AS});function kS(i){return function(){return i}}var Z6,Q6=M(()=>{Z6=kS});var CS,Us,$u=M(()=>{en();CS=(function(){try{var i=Gt(Object,"defineProperty");return i({},"",{}),i}catch{}})(),Us=CS});var _S,J6,e4=M(()=>{Q6();$u();qu();_S=Us?function(i,e){return Us(i,"toString",{configurable:!0,enumerable:!1,value:Z6(e),writable:!0})}:X0,J6=_S});var LS,t4,i4=M(()=>{e4();K6();LS=X6(J6),t4=LS});function zS(i,e){for(var t=-1,r=i==null?0:i.length;++t{r4=zS});function DS(i,e){var t=typeof i;return e=e??IS,!!e&&(t=="number"||t!="symbol"&&RS.test(i))&&i>-1&&i%1==0&&i{IS=9007199254740991,RS=/^(?:0|[1-9]\d*)$/;eh=DS});function OS(i,e,t){e=="__proto__"&&Us?Us(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var $s,th=M(()=>{$u();$s=OS});function BS(i,e){return i===e||i!==i&&e!==e}var Zi,js=M(()=>{Zi=BS});function qS(i,e,t){var r=i[e];(!(FS.call(i,e)&&Zi(r,t))||t===void 0&&!(e in i))&&$s(i,e,t)}var PS,FS,ih,Gu=M(()=>{th();js();PS=Object.prototype,FS=PS.hasOwnProperty;ih=qS});function HS(i,e,t,r){var n=!t;t||(t={});for(var s=-1,a=e.length;++s{Gu();th();Qi=HS});function US(i,e,t){return e=s4(e===void 0?i.length-1:e,0),function(){for(var r=arguments,n=-1,s=s4(r.length-e,0),a=Array(s);++n{V6();s4=Math.max;a4=US});function $S(i,e){return t4(a4(i,e,X0),i+"")}var l4,h4=M(()=>{qu();o4();i4();l4=$S});function GS(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=jS}var jS,rh,Yu=M(()=>{jS=9007199254740991;rh=GS});function YS(i){return i!=null&&rh(i.length)&&!Hs(i)}var tn,Co=M(()=>{K0();Yu();tn=YS});function WS(i,e,t){if(!mt(t))return!1;var r=typeof e;return(r=="number"?tn(t)&&eh(e,t.length):r=="string"&&e in t)?Zi(t[e],i):!1}var d4,c4=M(()=>{js();Co();ju();yr();d4=WS});function VS(i){return l4(function(e,t){var r=-1,n=t.length,s=n>1?t[n-1]:void 0,a=n>2?t[2]:void 0;for(s=i.length>3&&typeof s=="function"?(n--,s):void 0,a&&d4(t[0],t[1],a)&&(s=n<3?void 0:s,n=1),e=Object(e);++r{h4();c4();u4=VS});function KS(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||XS;return i===t}var XS,Ys,nh=M(()=>{XS=Object.prototype;Ys=KS});function ZS(i,e){for(var t=-1,r=Array(i);++t{m4=ZS});function JS(i){return dt(i)&&Oi(i)==QS}var QS,Wu,g4=M(()=>{Fs();vr();QS="[object Arguments]";Wu=JS});var x4,eA,tA,iA,_o,Vu=M(()=>{g4();vr();x4=Object.prototype,eA=x4.hasOwnProperty,tA=x4.propertyIsEnumerable,iA=Wu((function(){return arguments})())?Wu:function(i){return dt(i)&&eA.call(i,"callee")&&!tA.call(i,"callee")},_o=iA});function rA(){return!1}var v4,y4=M(()=>{v4=rA});var M4,b4,nA,w4,sA,aA,wr,Lo=M(()=>{Di();y4();M4=typeof exports=="object"&&exports&&!exports.nodeType&&exports,b4=M4&&typeof module=="object"&&module&&!module.nodeType&&module,nA=b4&&b4.exports===M4,w4=nA?Ze.Buffer:void 0,sA=w4?w4.isBuffer:void 0,aA=sA||v4,wr=aA});function LA(i){return dt(i)&&rh(i.length)&&!!Re[Oi(i)]}var oA,lA,hA,dA,cA,uA,fA,mA,pA,gA,xA,vA,yA,bA,wA,MA,TA,NA,EA,SA,AA,kA,CA,_A,Re,T4,N4=M(()=>{Fs();Yu();vr();oA="[object Arguments]",lA="[object Array]",hA="[object Boolean]",dA="[object Date]",cA="[object Error]",uA="[object Function]",fA="[object Map]",mA="[object Number]",pA="[object Object]",gA="[object RegExp]",xA="[object Set]",vA="[object String]",yA="[object WeakMap]",bA="[object ArrayBuffer]",wA="[object DataView]",MA="[object Float32Array]",TA="[object Float64Array]",NA="[object Int8Array]",EA="[object Int16Array]",SA="[object Int32Array]",AA="[object Uint8Array]",kA="[object Uint8ClampedArray]",CA="[object Uint16Array]",_A="[object Uint32Array]",Re={};Re[MA]=Re[TA]=Re[NA]=Re[EA]=Re[SA]=Re[AA]=Re[kA]=Re[CA]=Re[_A]=!0;Re[oA]=Re[lA]=Re[bA]=Re[hA]=Re[wA]=Re[dA]=Re[cA]=Re[uA]=Re[fA]=Re[mA]=Re[pA]=Re[gA]=Re[xA]=Re[vA]=Re[yA]=!1;T4=LA});function zA(i){return function(e){return i(e)}}var Ws,sh=M(()=>{Ws=zA});var E4,zo,IA,Xu,RA,Mr,ah=M(()=>{Fu();E4=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zo=E4&&typeof module=="object"&&module&&!module.nodeType&&module,IA=zo&&zo.exports===E4,Xu=IA&&V0.process,RA=(function(){try{var i=zo&&zo.require&&zo.require("util").types;return i||Xu&&Xu.binding&&Xu.binding("util")}catch{}})(),Mr=RA});var S4,DA,Vs,oh=M(()=>{N4();sh();ah();S4=Mr&&Mr.isTypedArray,DA=S4?Ws(S4):T4,Vs=DA});function PA(i,e){var t=yi(i),r=!t&&_o(i),n=!t&&!r&&wr(i),s=!t&&!r&&!n&&Vs(i),a=t||r||n||s,o=a?m4(i.length,String):[],l=o.length;for(var h in i)(e||BA.call(i,h))&&!(a&&(h=="length"||n&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||eh(h,l)))&&o.push(h);return o}var OA,BA,lh,Ku=M(()=>{p4();Vu();qs();Lo();ju();oh();OA=Object.prototype,BA=OA.hasOwnProperty;lh=PA});function FA(i,e){return function(t){return i(e(t))}}var hh,Zu=M(()=>{hh=FA});var qA,A4,k4=M(()=>{Zu();qA=hh(Object.keys,Object),A4=qA});function $A(i){if(!Ys(i))return A4(i);var e=[];for(var t in Object(i))UA.call(i,t)&&t!="constructor"&&e.push(t);return e}var HA,UA,C4,_4=M(()=>{nh();k4();HA=Object.prototype,UA=HA.hasOwnProperty;C4=$A});function jA(i){return tn(i)?lh(i):C4(i)}var Xs,dh=M(()=>{Ku();_4();Co();Xs=jA});function GA(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var L4,z4=M(()=>{L4=GA});function VA(i){if(!mt(i))return L4(i);var e=Ys(i),t=[];for(var r in i)r=="constructor"&&(e||!WA.call(i,r))||t.push(r);return t}var YA,WA,I4,R4=M(()=>{yr();nh();z4();YA=Object.prototype,WA=YA.hasOwnProperty;I4=VA});function XA(i){return tn(i)?lh(i,!0):I4(i)}var Ji,Ks=M(()=>{Ku();R4();Co();Ji=XA});var KA,Tr,Io=M(()=>{en();KA=Gt(Object,"create"),Tr=KA});function ZA(){this.__data__=Tr?Tr(null):{},this.size=0}var D4,O4=M(()=>{Io();D4=ZA});function QA(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var B4,P4=M(()=>{B4=QA});function ik(i){var e=this.__data__;if(Tr){var t=e[i];return t===JA?void 0:t}return tk.call(e,i)?e[i]:void 0}var JA,ek,tk,F4,q4=M(()=>{Io();JA="__lodash_hash_undefined__",ek=Object.prototype,tk=ek.hasOwnProperty;F4=ik});function sk(i){var e=this.__data__;return Tr?e[i]!==void 0:nk.call(e,i)}var rk,nk,H4,U4=M(()=>{Io();rk=Object.prototype,nk=rk.hasOwnProperty;H4=sk});function ok(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=Tr&&e===void 0?ak:e,this}var ak,$4,j4=M(()=>{Io();ak="__lodash_hash_undefined__";$4=ok});function Zs(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e{O4();P4();q4();U4();j4();Zs.prototype.clear=D4;Zs.prototype.delete=B4;Zs.prototype.get=F4;Zs.prototype.has=H4;Zs.prototype.set=$4;Qu=Zs});function lk(){this.__data__=[],this.size=0}var Y4,W4=M(()=>{Y4=lk});function hk(i,e){for(var t=i.length;t--;)if(Zi(i[t][0],e))return t;return-1}var rn,Ro=M(()=>{js();rn=hk});function uk(i){var e=this.__data__,t=rn(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():ck.call(e,t,1),--this.size,!0}var dk,ck,V4,X4=M(()=>{Ro();dk=Array.prototype,ck=dk.splice;V4=uk});function fk(i){var e=this.__data__,t=rn(e,i);return t<0?void 0:e[t][1]}var K4,Z4=M(()=>{Ro();K4=fk});function mk(i){return rn(this.__data__,i)>-1}var Q4,J4=M(()=>{Ro();Q4=mk});function pk(i,e){var t=this.__data__,r=rn(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var eg,tg=M(()=>{Ro();eg=pk});function Qs(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e{W4();X4();Z4();J4();tg();Qs.prototype.clear=Y4;Qs.prototype.delete=V4;Qs.prototype.get=K4;Qs.prototype.has=Q4;Qs.prototype.set=eg;nn=Qs});var gk,sn,ch=M(()=>{en();Di();gk=Gt(Ze,"Map"),sn=gk});function xk(){this.size=0,this.__data__={hash:new Qu,map:new(sn||nn),string:new Qu}}var ig,rg=M(()=>{G4();Do();ch();ig=xk});function vk(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var ng,sg=M(()=>{ng=vk});function yk(i,e){var t=i.__data__;return ng(e)?t[typeof e=="string"?"string":"hash"]:t.map}var an,Oo=M(()=>{sg();an=yk});function bk(i){var e=an(this,i).delete(i);return this.size-=e?1:0,e}var ag,og=M(()=>{Oo();ag=bk});function wk(i){return an(this,i).get(i)}var lg,hg=M(()=>{Oo();lg=wk});function Mk(i){return an(this,i).has(i)}var dg,cg=M(()=>{Oo();dg=Mk});function Tk(i,e){var t=an(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var ug,fg=M(()=>{Oo();ug=Tk});function Js(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e{rg();og();hg();cg();fg();Js.prototype.clear=ig;Js.prototype.delete=ag;Js.prototype.get=lg;Js.prototype.has=dg;Js.prototype.set=ug;uh=Js});function Nk(i,e){for(var t=-1,r=e.length,n=i.length;++t{fh=Nk});var Ek,ea,mh=M(()=>{Zu();Ek=hh(Object.getPrototypeOf,Object),ea=Ek});function Lk(i){if(!dt(i)||Oi(i)!=Sk)return!1;var e=ea(i);if(e===null)return!0;var t=Ck.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&mg.call(t)==_k}var Sk,Ak,kk,mg,Ck,_k,pg,gg=M(()=>{Fs();mh();vr();Sk="[object Object]",Ak=Function.prototype,kk=Object.prototype,mg=Ak.toString,Ck=kk.hasOwnProperty,_k=mg.call(Object);pg=Lk});function zk(){this.__data__=new nn,this.size=0}var xg,vg=M(()=>{Do();xg=zk});function Ik(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var yg,bg=M(()=>{yg=Ik});function Rk(i){return this.__data__.get(i)}var wg,Mg=M(()=>{wg=Rk});function Dk(i){return this.__data__.has(i)}var Tg,Ng=M(()=>{Tg=Dk});function Bk(i,e){var t=this.__data__;if(t instanceof nn){var r=t.__data__;if(!sn||r.length{Do();ch();Ju();Ok=200;Eg=Bk});function ta(i){var e=this.__data__=new nn(i);this.size=e.size}var on,ph=M(()=>{Do();vg();bg();Mg();Ng();Sg();ta.prototype.clear=xg;ta.prototype.delete=yg;ta.prototype.get=wg;ta.prototype.has=Tg;ta.prototype.set=Eg;on=ta});function Pk(i,e){return i&&Qi(e,Xs(e),i)}var Ag,kg=M(()=>{Gs();dh();Ag=Pk});function Fk(i,e){return i&&Qi(e,Ji(e),i)}var Cg,_g=M(()=>{Gs();Ks();Cg=Fk});function Hk(i,e){if(e)return i.slice();var t=i.length,r=Ig?Ig(t):new i.constructor(t);return i.copy(r),r}var Rg,Lg,qk,zg,Ig,gh,t1=M(()=>{Di();Rg=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Lg=Rg&&typeof module=="object"&&module&&!module.nodeType&&module,qk=Lg&&Lg.exports===Rg,zg=qk?Ze.Buffer:void 0,Ig=zg?zg.allocUnsafe:void 0;gh=Hk});function Uk(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t{Dg=Uk});function $k(){return[]}var xh,i1=M(()=>{xh=$k});var jk,Gk,Bg,Yk,ia,vh=M(()=>{Og();i1();jk=Object.prototype,Gk=jk.propertyIsEnumerable,Bg=Object.getOwnPropertySymbols,Yk=Bg?function(i){return i==null?[]:(i=Object(i),Dg(Bg(i),function(e){return Gk.call(i,e)}))}:xh,ia=Yk});function Wk(i,e){return Qi(i,ia(i),e)}var Pg,Fg=M(()=>{Gs();vh();Pg=Wk});var Vk,Xk,yh,r1=M(()=>{e1();mh();vh();i1();Vk=Object.getOwnPropertySymbols,Xk=Vk?function(i){for(var e=[];i;)fh(e,ia(i)),i=ea(i);return e}:xh,yh=Xk});function Kk(i,e){return Qi(i,yh(i),e)}var qg,Hg=M(()=>{Gs();r1();qg=Kk});function Zk(i,e,t){var r=e(i);return yi(i)?r:fh(r,t(i))}var bh,n1=M(()=>{e1();qs();bh=Zk});function Qk(i){return bh(i,Xs,ia)}var Bo,s1=M(()=>{n1();vh();dh();Bo=Qk});function Jk(i){return bh(i,Ji,yh)}var Ug,$g=M(()=>{n1();r1();Ks();Ug=Jk});var eC,wh,jg=M(()=>{en();Di();eC=Gt(Ze,"DataView"),wh=eC});var tC,Mh,Gg=M(()=>{en();Di();tC=Gt(Ze,"Promise"),Mh=tC});var iC,Th,Yg=M(()=>{en();Di();iC=Gt(Ze,"Set"),Th=iC});var Wg,rC,Vg,Xg,Kg,Zg,nC,sC,aC,oC,lC,Yn,Nr,Po=M(()=>{jg();ch();Gg();Yg();$6();Fs();Hu();Wg="[object Map]",rC="[object Object]",Vg="[object Promise]",Xg="[object Set]",Kg="[object WeakMap]",Zg="[object DataView]",nC=br(wh),sC=br(sn),aC=br(Mh),oC=br(Th),lC=br(Q0),Yn=Oi;(wh&&Yn(new wh(new ArrayBuffer(1)))!=Zg||sn&&Yn(new sn)!=Wg||Mh&&Yn(Mh.resolve())!=Vg||Th&&Yn(new Th)!=Xg||Q0&&Yn(new Q0)!=Kg)&&(Yn=function(i){var e=Oi(i),t=e==rC?i.constructor:void 0,r=t?br(t):"";if(r)switch(r){case nC:return Zg;case sC:return Wg;case aC:return Vg;case oC:return Xg;case lC:return Kg}return e});Nr=Yn});function cC(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&dC.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var hC,dC,Qg,Jg=M(()=>{hC=Object.prototype,dC=hC.hasOwnProperty;Qg=cC});var uC,ra,a1=M(()=>{Di();uC=Ze.Uint8Array,ra=uC});function fC(i){var e=new i.constructor(i.byteLength);return new ra(e).set(new ra(i)),e}var na,Nh=M(()=>{a1();na=fC});function mC(i,e){var t=e?na(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var e5,t5=M(()=>{Nh();e5=mC});function gC(i){var e=new i.constructor(i.source,pC.exec(i));return e.lastIndex=i.lastIndex,e}var pC,i5,r5=M(()=>{pC=/\w*$/;i5=gC});function xC(i){return s5?Object(s5.call(i)):{}}var n5,s5,a5,o5=M(()=>{Ao();n5=vi?vi.prototype:void 0,s5=n5?n5.valueOf:void 0;a5=xC});function vC(i,e){var t=e?na(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var Eh,o1=M(()=>{Nh();Eh=vC});function PC(i,e,t){var r=i.constructor;switch(e){case AC:return na(i);case yC:case bC:return new r(+i);case kC:return e5(i,t);case CC:case _C:case LC:case zC:case IC:case RC:case DC:case OC:case BC:return Eh(i,t);case wC:return new r;case MC:case EC:return new r(i);case TC:return i5(i);case NC:return new r;case SC:return a5(i)}}var yC,bC,wC,MC,TC,NC,EC,SC,AC,kC,CC,_C,LC,zC,IC,RC,DC,OC,BC,l5,h5=M(()=>{Nh();t5();r5();o5();o1();yC="[object Boolean]",bC="[object Date]",wC="[object Map]",MC="[object Number]",TC="[object RegExp]",NC="[object Set]",EC="[object String]",SC="[object Symbol]",AC="[object ArrayBuffer]",kC="[object DataView]",CC="[object Float32Array]",_C="[object Float64Array]",LC="[object Int8Array]",zC="[object Int16Array]",IC="[object Int32Array]",RC="[object Uint8Array]",DC="[object Uint8ClampedArray]",OC="[object Uint16Array]",BC="[object Uint32Array]";l5=PC});function FC(i){return typeof i.constructor=="function"&&!Ys(i)?G6(ea(i)):{}}var Sh,l1=M(()=>{Y6();mh();nh();Sh=FC});function HC(i){return dt(i)&&Nr(i)==qC}var qC,d5,c5=M(()=>{Po();vr();qC="[object Map]";d5=HC});var u5,UC,f5,m5=M(()=>{c5();sh();ah();u5=Mr&&Mr.isMap,UC=u5?Ws(u5):d5,f5=UC});function jC(i){return dt(i)&&Nr(i)==$C}var $C,p5,g5=M(()=>{Po();vr();$C="[object Set]";p5=jC});var x5,GC,v5,y5=M(()=>{g5();sh();ah();x5=Mr&&Mr.isSet,GC=x5?Ws(x5):p5,v5=GC});function Ah(i,e,t,r,n,s){var a,o=e&YC,l=e&WC,h=e&VC;if(t&&(a=n?t(i,r,n,s):t(i)),a!==void 0)return a;if(!mt(i))return i;var d=yi(i);if(d){if(a=Qg(i),!o)return J0(i,a)}else{var c=Nr(i),f=c==w5||c==JC;if(wr(i))return gh(i,o);if(c==M5||c==b5||f&&!n){if(a=l||f?{}:Sh(i),!o)return l?qg(i,Cg(a,i)):Pg(i,Ag(a,i))}else{if(!_e[c])return n?i:{};a=l5(i,c,o)}}s||(s=new on);var m=s.get(i);if(m)return m;s.set(i,a),v5(i)?i.forEach(function(v){a.add(Ah(v,e,t,v,i,s))}):f5(i)&&i.forEach(function(v,b){a.set(b,Ah(v,e,t,b,i,s))});var g=h?l?Ug:Bo:l?Ji:Xs,x=d?void 0:g(i);return r4(x||i,function(v,b){x&&(b=v,v=i[b]),ih(a,b,Ah(v,e,t,b,i,s))}),a}var YC,WC,VC,b5,XC,KC,ZC,QC,w5,JC,e_,t_,M5,i_,r_,n_,s_,a_,o_,l_,h_,d_,c_,u_,f_,m_,p_,g_,x_,_e,T5,N5=M(()=>{ph();n4();Gu();kg();_g();t1();Uu();Fg();Hg();s1();$g();Po();Jg();h5();l1();qs();Lo();m5();yr();y5();dh();Ks();YC=1,WC=2,VC=4,b5="[object Arguments]",XC="[object Array]",KC="[object Boolean]",ZC="[object Date]",QC="[object Error]",w5="[object Function]",JC="[object GeneratorFunction]",e_="[object Map]",t_="[object Number]",M5="[object Object]",i_="[object RegExp]",r_="[object Set]",n_="[object String]",s_="[object Symbol]",a_="[object WeakMap]",o_="[object ArrayBuffer]",l_="[object DataView]",h_="[object Float32Array]",d_="[object Float64Array]",c_="[object Int8Array]",u_="[object Int16Array]",f_="[object Int32Array]",m_="[object Uint8Array]",p_="[object Uint8ClampedArray]",g_="[object Uint16Array]",x_="[object Uint32Array]",_e={};_e[b5]=_e[XC]=_e[o_]=_e[l_]=_e[KC]=_e[ZC]=_e[h_]=_e[d_]=_e[c_]=_e[u_]=_e[f_]=_e[e_]=_e[t_]=_e[M5]=_e[i_]=_e[r_]=_e[n_]=_e[s_]=_e[m_]=_e[p_]=_e[g_]=_e[x_]=!0;_e[QC]=_e[w5]=_e[a_]=!1;T5=Ah});function b_(i){return T5(i,v_|y_)}var v_,y_,er,E5=M(()=>{N5();v_=1,y_=4;er=b_});function M_(i){return this.__data__.set(i,w_),this}var w_,S5,A5=M(()=>{w_="__lodash_hash_undefined__";S5=M_});function T_(i){return this.__data__.has(i)}var k5,C5=M(()=>{k5=T_});function kh(i){var e=-1,t=i==null?0:i.length;for(this.__data__=new uh;++e{Ju();A5();C5();kh.prototype.add=kh.prototype.push=S5;kh.prototype.has=k5;_5=kh});function N_(i,e){for(var t=-1,r=i==null?0:i.length;++t{z5=N_});function E_(i,e){return i.has(e)}var R5,D5=M(()=>{R5=E_});function k_(i,e,t,r,n,s){var a=t&S_,o=i.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var h=s.get(i),d=s.get(e);if(h&&d)return h==e&&d==i;var c=-1,f=!0,m=t&A_?new _5:void 0;for(s.set(i,e),s.set(e,i);++c{L5();I5();D5();S_=1,A_=2;Ch=k_});function C_(i){var e=-1,t=Array(i.size);return i.forEach(function(r,n){t[++e]=[n,r]}),t}var O5,B5=M(()=>{O5=C_});function __(i){var e=-1,t=Array(i.size);return i.forEach(function(r){t[++e]=r}),t}var P5,F5=M(()=>{P5=__});function j_(i,e,t,r,n,s,a){switch(t){case $_:if(i.byteLength!=e.byteLength||i.byteOffset!=e.byteOffset)return!1;i=i.buffer,e=e.buffer;case U_:return!(i.byteLength!=e.byteLength||!s(new ra(i),new ra(e)));case I_:case R_:case B_:return Zi(+i,+e);case D_:return i.name==e.name&&i.message==e.message;case P_:case q_:return i==e+"";case O_:var o=O5;case F_:var l=r&L_;if(o||(o=P5),i.size!=e.size&&!l)return!1;var h=a.get(i);if(h)return h==e;r|=z_,a.set(i,e);var d=Ch(o(i),o(e),r,n,s,a);return a.delete(i),d;case H_:if(d1)return d1.call(i)==d1.call(e)}return!1}var L_,z_,I_,R_,D_,O_,B_,P_,F_,q_,H_,U_,$_,q5,d1,H5,U5=M(()=>{Ao();a1();js();h1();B5();F5();L_=1,z_=2,I_="[object Boolean]",R_="[object Date]",D_="[object Error]",O_="[object Map]",B_="[object Number]",P_="[object RegExp]",F_="[object Set]",q_="[object String]",H_="[object Symbol]",U_="[object ArrayBuffer]",$_="[object DataView]",q5=vi?vi.prototype:void 0,d1=q5?q5.valueOf:void 0;H5=j_});function V_(i,e,t,r,n,s){var a=t&G_,o=Bo(i),l=o.length,h=Bo(e),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var f=o[c];if(!(a?f in e:W_.call(e,f)))return!1}var m=s.get(i),g=s.get(e);if(m&&g)return m==e&&g==i;var x=!0;s.set(i,e),s.set(e,i);for(var v=a;++c{s1();G_=1,Y_=Object.prototype,W_=Y_.hasOwnProperty;$5=V_});function Z_(i,e,t,r,n,s){var a=yi(i),o=yi(e),l=a?Y5:Nr(i),h=o?Y5:Nr(e);l=l==G5?_h:l,h=h==G5?_h:h;var d=l==_h,c=h==_h,f=l==h;if(f&&wr(i)){if(!wr(e))return!1;a=!0,d=!1}if(f&&!d)return s||(s=new on),a||Vs(i)?Ch(i,e,t,r,n,s):H5(i,e,l,t,r,n,s);if(!(t&X_)){var m=d&&W5.call(i,"__wrapped__"),g=c&&W5.call(e,"__wrapped__");if(m||g){var x=m?i.value():i,v=g?e.value():e;return s||(s=new on),n(x,v,t,r,s)}}return f?(s||(s=new on),$5(i,e,t,r,n,s)):!1}var X_,G5,Y5,_h,K_,W5,V5,X5=M(()=>{ph();h1();U5();j5();Po();qs();Lo();oh();X_=1,G5="[object Arguments]",Y5="[object Array]",_h="[object Object]",K_=Object.prototype,W5=K_.hasOwnProperty;V5=Z_});function K5(i,e,t,r,n){return i===e?!0:i==null||e==null||!dt(i)&&!dt(e)?i!==i&&e!==e:V5(i,e,t,r,K5,n)}var Z5,Q5=M(()=>{X5();vr();Z5=K5});function Q_(i){return function(e,t,r){for(var n=-1,s=Object(e),a=r(e),o=a.length;o--;){var l=a[i?o:++n];if(t(s[l],l,s)===!1)break}return e}}var J5,e7=M(()=>{J5=Q_});var J_,t7,i7=M(()=>{e7();J_=J5(),t7=J_});function eL(i,e,t){(t!==void 0&&!Zi(i[e],t)||t===void 0&&!(e in i))&&$s(i,e,t)}var Fo,c1=M(()=>{th();js();Fo=eL});function tL(i){return dt(i)&&tn(i)}var r7,n7=M(()=>{Co();vr();r7=tL});function iL(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var qo,u1=M(()=>{qo=iL});function rL(i){return Qi(i,Ji(i))}var s7,a7=M(()=>{Gs();Ks();s7=rL});function nL(i,e,t,r,n,s,a){var o=qo(i,t),l=qo(e,t),h=a.get(l);if(h){Fo(i,t,h);return}var d=s?s(o,l,t+"",i,e,a):void 0,c=d===void 0;if(c){var f=yi(l),m=!f&&wr(l),g=!f&&!m&&Vs(l);d=l,f||m||g?yi(o)?d=o:r7(o)?d=J0(o):m?(c=!1,d=gh(l,!0)):g?(c=!1,d=Eh(l,!0)):d=[]:pg(l)||_o(l)?(d=o,_o(o)?d=s7(o):(!mt(o)||Hs(o))&&(d=Sh(l))):c=!1}c&&(a.set(l,d),n(d,l,r,s,a),a.delete(l)),Fo(i,t,d)}var o7,l7=M(()=>{c1();t1();o1();Uu();l1();Vu();qs();n7();Lo();K0();yr();gg();oh();u1();a7();o7=nL});function h7(i,e,t,r,n){i!==e&&t7(e,function(s,a){if(n||(n=new on),mt(s))o7(i,e,a,t,h7,r,n);else{var o=r?r(qo(i,a),s,a+"",i,e,n):void 0;o===void 0&&(o=s),Fo(i,a,o)}},Ji)}var d7,c7=M(()=>{ph();c1();i7();l7();yr();Ks();u1();d7=h7});function sL(i,e){return Z5(i,e)}var Wn,u7=M(()=>{Q5();Wn=sL});var aL,Yt,f7=M(()=>{c7();f4();aL=u4(function(i,e,t){d7(i,e,t)}),Yt=aL});var ln=M(()=>{E5();u7();f7();});var $o={};ti($o,{Attributor:()=>kt,AttributorStore:()=>Ho,BlockBlot:()=>Vn,ClassAttributor:()=>Qe,ContainerBlot:()=>ha,EmbedBlot:()=>Ue,InlineBlot:()=>Lh,LeafBlot:()=>Je,ParentBlot:()=>Wt,Registry:()=>cn,Scope:()=>Y,ScrollBlot:()=>Uo,StyleAttributor:()=>Vt,TextBlot:()=>da});function m7(i,e){return(i.getAttribute("class")||"").split(/\s+/).filter(t=>t.indexOf(`${e}-`)===0)}function f1(i){let e=i.split("-"),t=e.slice(1).map(r=>r[0].toUpperCase()+r.slice(1)).join("");return e[0]+t}function p7(i,e){let t=e.find(i);if(t)return t;try{return e.create(i)}catch{let r=e.create(Y.INLINE);return Array.from(i.childNodes).forEach(n=>{r.domNode.appendChild(n)}),i.parentNode&&i.parentNode.replaceChild(r.domNode,i),r.attach(),r}}function hL(i,e){if(Object.keys(i).length!==Object.keys(e).length)return!1;for(let t in i)if(i[t]!==e[t])return!1;return!0}var Y,kt,dn,g7,cn,p1,Qe,g1,Vt,x1,Ho,x7,v7,y7,oL,Je,v1,b7,lL,Wt,sa,dL,Lh,oa,cL,Vn,b1,uL,ha,w1,Ue,fL,mL,la,pL,Uo,M1,gL,da,Ae=M(()=>{Y=(i=>(i[i.TYPE=3]="TYPE",i[i.LEVEL=12]="LEVEL",i[i.ATTRIBUTE=13]="ATTRIBUTE",i[i.BLOT=14]="BLOT",i[i.INLINE=7]="INLINE",i[i.BLOCK=11]="BLOCK",i[i.BLOCK_BLOT=10]="BLOCK_BLOT",i[i.INLINE_BLOT=6]="INLINE_BLOT",i[i.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",i[i.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",i[i.ANY=15]="ANY",i))(Y||{}),kt=class{constructor(e,t,r={}){this.attrName=e,this.keyName=t;let n=Y.TYPE&Y.ATTRIBUTE;this.scope=r.scope!=null?r.scope&Y.LEVEL|n:Y.ATTRIBUTE,r.whitelist!=null&&(this.whitelist=r.whitelist)}static keys(e){return Array.from(e.attributes).map(t=>t.name)}add(e,t){return this.canAdd(e,t)?(e.setAttribute(this.keyName,t),!0):!1}canAdd(e,t){return this.whitelist==null?!0:typeof t=="string"?this.whitelist.indexOf(t.replace(/["']/g,""))>-1:this.whitelist.indexOf(t)>-1}remove(e){e.removeAttribute(this.keyName)}value(e){let t=e.getAttribute(this.keyName);return this.canAdd(e,t)&&t?t:""}},dn=class extends Error{constructor(e){e="[Parchment] "+e,super(e),this.message=e,this.name=this.constructor.name}},g7=class m1{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(e,t=!1){if(e==null)return null;if(this.blots.has(e))return this.blots.get(e)||null;if(t){let r=null;try{r=e.parentNode}catch{return null}return this.find(r,t)}return null}create(e,t,r){let n=this.query(t);if(n==null)throw new dn(`Unable to create ${t} blot`);let s=n,a=t instanceof Node||t.nodeType===Node.TEXT_NODE?t:s.create(r),o=new s(e,a,r);return m1.blots.set(o.domNode,o),o}find(e,t=!1){return m1.find(e,t)}query(e,t=Y.ANY){let r;return typeof e=="string"?r=this.types[e]||this.attributes[e]:e instanceof Text||e.nodeType===Node.TEXT_NODE?r=this.types.text:typeof e=="number"?e&Y.LEVEL&Y.BLOCK?r=this.types.block:e&Y.LEVEL&Y.INLINE&&(r=this.types.inline):e instanceof Element&&((e.getAttribute("class")||"").split(/\s+/).some(n=>(r=this.classes[n],!!r)),r=r||this.tags[e.tagName]),r==null?null:"scope"in r&&t&Y.LEVEL&r.scope&&t&Y.TYPE&r.scope?r:null}register(...e){return e.map(t=>{let r="blotName"in t,n="attrName"in t;if(!r&&!n)throw new dn("Invalid definition");if(r&&t.blotName==="abstract")throw new dn("Cannot register abstract class");let s=r?t.blotName:n?t.attrName:void 0;return this.types[s]=t,n?typeof t.keyName=="string"&&(this.attributes[t.keyName]=t):r&&(t.className&&(this.classes[t.className]=t),t.tagName&&(Array.isArray(t.tagName)?t.tagName=t.tagName.map(a=>a.toUpperCase()):t.tagName=t.tagName.toUpperCase(),(Array.isArray(t.tagName)?t.tagName:[t.tagName]).forEach(a=>{(this.tags[a]==null||t.className==null)&&(this.tags[a]=t)}))),t})}};g7.blots=new WeakMap;cn=g7;p1=class extends kt{static keys(e){return(e.getAttribute("class")||"").split(/\s+/).map(t=>t.split("-").slice(0,-1).join("-"))}add(e,t){return this.canAdd(e,t)?(this.remove(e),e.classList.add(`${this.keyName}-${t}`),!0):!1}remove(e){m7(e,this.keyName).forEach(t=>{e.classList.remove(t)}),e.classList.length===0&&e.removeAttribute("class")}value(e){let t=(m7(e,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(e,t)?t:""}},Qe=p1;g1=class extends kt{static keys(e){return(e.getAttribute("style")||"").split(";").map(t=>t.split(":")[0].trim())}add(e,t){return this.canAdd(e,t)?(e.style[f1(this.keyName)]=t,!0):!1}remove(e){e.style[f1(this.keyName)]="",e.getAttribute("style")||e.removeAttribute("style")}value(e){let t=e.style[f1(this.keyName)];return this.canAdd(e,t)?t:""}},Vt=g1,x1=class{constructor(e){this.attributes={},this.domNode=e,this.build()}attribute(e,t){t?e.add(this.domNode,t)&&(e.value(this.domNode)!=null?this.attributes[e.attrName]=e:delete this.attributes[e.attrName]):(e.remove(this.domNode),delete this.attributes[e.attrName])}build(){this.attributes={};let e=cn.find(this.domNode);if(e==null)return;let t=kt.keys(this.domNode),r=Qe.keys(this.domNode),n=Vt.keys(this.domNode);t.concat(r).concat(n).forEach(s=>{let a=e.scroll.query(s,Y.ATTRIBUTE);a instanceof kt&&(this.attributes[a.attrName]=a)})}copy(e){Object.keys(this.attributes).forEach(t=>{let r=this.attributes[t].value(this.domNode);e.format(t,r)})}move(e){this.copy(e),Object.keys(this.attributes).forEach(t=>{this.attributes[t].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((e,t)=>(e[t]=this.attributes[t].value(this.domNode),e),{})}},Ho=x1,x7=class{constructor(e,t){this.scroll=e,this.domNode=t,cn.blots.set(t,this),this.prev=null,this.next=null}static create(e){if(this.tagName==null)throw new dn("Blot definition missing tagName");let t,r;return Array.isArray(this.tagName)?(typeof e=="string"?(r=e.toUpperCase(),parseInt(r,10).toString()===r&&(r=parseInt(r,10))):typeof e=="number"&&(r=e),typeof r=="number"?t=document.createElement(this.tagName[r-1]):r&&this.tagName.indexOf(r)>-1?t=document.createElement(r):t=document.createElement(this.tagName[0])):t=document.createElement(this.tagName),this.className&&t.classList.add(this.className),t}get statics(){return this.constructor}attach(){}clone(){let e=this.domNode.cloneNode(!1);return this.scroll.create(e)}detach(){this.parent!=null&&this.parent.removeChild(this),cn.blots.delete(this.domNode)}deleteAt(e,t){this.isolate(e,t).remove()}formatAt(e,t,r,n){let s=this.isolate(e,t);if(this.scroll.query(r,Y.BLOT)!=null&&n)s.wrap(r,n);else if(this.scroll.query(r,Y.ATTRIBUTE)!=null){let a=this.scroll.create(this.statics.scope);s.wrap(a),a.format(r,n)}}insertAt(e,t,r){let n=r==null?this.scroll.create("text",t):this.scroll.create(t,r),s=this.split(e);this.parent.insertBefore(n,s||void 0)}isolate(e,t){let r=this.split(e);if(r==null)throw new Error("Attempt to isolate at end");return r.split(t),r}length(){return 1}offset(e=this.parent){return this.parent==null||this===e?0:this.parent.children.offset(this)+this.parent.offset(e)}optimize(e){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(e,t){let r=typeof e=="string"?this.scroll.create(e,t):e;return this.parent!=null&&(this.parent.insertBefore(r,this.next||void 0),this.remove()),r}split(e,t){return e===0?this:this.next}update(e,t){}wrap(e,t){let r=typeof e=="string"?this.scroll.create(e,t):e;if(this.parent!=null&&this.parent.insertBefore(r,this.next||void 0),typeof r.appendChild!="function")throw new dn(`Cannot wrap ${e}`);return r.appendChild(this),r}};x7.blotName="abstract";v7=x7,y7=class extends v7{static value(e){return!0}index(e,t){return this.domNode===e||this.domNode.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(t,1):-1}position(e,t){let r=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return e>0&&(r+=1),[this.parent.domNode,r]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};y7.scope=Y.INLINE_BLOT;oL=y7,Je=oL,v1=class{constructor(){this.head=null,this.tail=null,this.length=0}append(...e){if(this.insertBefore(e[0],null),e.length>1){let t=e.slice(1);this.append(...t)}}at(e){let t=this.iterator(),r=t();for(;r&&e>0;)e-=1,r=t();return r}contains(e){let t=this.iterator(),r=t();for(;r;){if(r===e)return!0;r=t()}return!1}indexOf(e){let t=this.iterator(),r=t(),n=0;for(;r;){if(r===e)return n;n+=1,r=t()}return-1}insertBefore(e,t){e!=null&&(this.remove(e),e.next=t,t!=null?(e.prev=t.prev,t.prev!=null&&(t.prev.next=e),t.prev=e,t===this.head&&(this.head=e)):this.tail!=null?(this.tail.next=e,e.prev=this.tail,this.tail=e):(e.prev=null,this.head=this.tail=e),this.length+=1)}offset(e){let t=0,r=this.head;for(;r!=null;){if(r===e)return t;t+=r.length(),r=r.next}return-1}remove(e){this.contains(e)&&(e.prev!=null&&(e.prev.next=e.next),e.next!=null&&(e.next.prev=e.prev),e===this.head&&(this.head=e.next),e===this.tail&&(this.tail=e.prev),this.length-=1)}iterator(e=this.head){return()=>{let t=e;return e!=null&&(e=e.next),t}}find(e,t=!1){let r=this.iterator(),n=r();for(;n;){let s=n.length();if(ea?r(l,e-a,Math.min(t,a+h-e)):r(l,0,Math.min(h,e+t-a)),a+=h,l=o()}}map(e){return this.reduce((t,r)=>(t.push(e(r)),t),[])}reduce(e,t){let r=this.iterator(),n=r();for(;n;)t=e(t,n),n=r();return t}};b7=class hn extends v7{constructor(e,t){super(e,t),this.uiNode=null,this.build()}appendChild(e){this.insertBefore(e)}attach(){super.attach(),this.children.forEach(e=>{e.attach()})}attachUI(e){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=e,hn.uiClass&&this.uiNode.classList.add(hn.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new v1,Array.from(this.domNode.childNodes).filter(e=>e!==this.uiNode).reverse().forEach(e=>{try{let t=p7(e,this.scroll);this.insertBefore(t,this.children.head||void 0)}catch(t){if(t instanceof dn)return;throw t}})}deleteAt(e,t){if(e===0&&t===this.length())return this.remove();this.children.forEachAt(e,t,(r,n,s)=>{r.deleteAt(n,s)})}descendant(e,t=0){let[r,n]=this.children.find(t);return e.blotName==null&&e(r)||e.blotName!=null&&r instanceof e?[r,n]:r instanceof hn?r.descendant(e,n):[null,-1]}descendants(e,t=0,r=Number.MAX_VALUE){let n=[],s=r;return this.children.forEachAt(t,r,(a,o,l)=>{(e.blotName==null&&e(a)||e.blotName!=null&&a instanceof e)&&n.push(a),a instanceof hn&&(n=n.concat(a.descendants(e,o,s))),s-=l}),n}detach(){this.children.forEach(e=>{e.detach()}),super.detach()}enforceAllowedChildren(){let e=!1;this.children.forEach(t=>{e||this.statics.allowedChildren.some(r=>t instanceof r)||(t.statics.scope===Y.BLOCK_BLOT?(t.next!=null&&this.splitAfter(t),t.prev!=null&&this.splitAfter(t.prev),t.parent.unwrap(),e=!0):t instanceof hn?t.unwrap():t.remove())})}formatAt(e,t,r,n){this.children.forEachAt(e,t,(s,a,o)=>{s.formatAt(a,o,r,n)})}insertAt(e,t,r){let[n,s]=this.children.find(e);if(n)n.insertAt(s,t,r);else{let a=r==null?this.scroll.create("text",t):this.scroll.create(t,r);this.appendChild(a)}}insertBefore(e,t){e.parent!=null&&e.parent.children.remove(e);let r=null;this.children.insertBefore(e,t||null),e.parent=this,t!=null&&(r=t.domNode),(this.domNode.parentNode!==e.domNode||this.domNode.nextSibling!==r)&&this.domNode.insertBefore(e.domNode,r),e.attach()}length(){return this.children.reduce((e,t)=>e+t.length(),0)}moveChildren(e,t){this.children.forEach(r=>{e.insertBefore(r,t)})}optimize(e){if(super.optimize(e),this.enforceAllowedChildren(),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0)if(this.statics.defaultChild!=null){let t=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(t)}else this.remove()}path(e,t=!1){let[r,n]=this.children.find(e,t),s=[[this,e]];return r instanceof hn?s.concat(r.path(n,t)):(r!=null&&s.push([r,n]),s)}removeChild(e){this.children.remove(e)}replaceWith(e,t){let r=typeof e=="string"?this.scroll.create(e,t):e;return r instanceof hn&&this.moveChildren(r),super.replaceWith(r)}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let r=this.clone();return this.parent&&this.parent.insertBefore(r,this.next||void 0),this.children.forEachAt(e,this.length(),(n,s,a)=>{let o=n.split(s,t);o!=null&&r.appendChild(o)}),r}splitAfter(e){let t=this.clone();for(;e.next!=null;)t.appendChild(e.next);return this.parent&&this.parent.insertBefore(t,this.next||void 0),t}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(e,t){let r=[],n=[];e.forEach(s=>{s.target===this.domNode&&s.type==="childList"&&(r.push(...s.addedNodes),n.push(...s.removedNodes))}),n.forEach(s=>{if(s.parentNode!=null&&s.tagName!=="IFRAME"&&document.body.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;let a=this.scroll.find(s);a!=null&&(a.domNode.parentNode==null||a.domNode.parentNode===this.domNode)&&a.detach()}),r.filter(s=>s.parentNode===this.domNode&&s!==this.uiNode).sort((s,a)=>s===a?0:s.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(s=>{let a=null;s.nextSibling!=null&&(a=this.scroll.find(s.nextSibling));let o=p7(s,this.scroll);(o.next!==a||o.next==null)&&(o.parent!=null&&o.parent.removeChild(this),this.insertBefore(o,a||void 0))}),this.enforceAllowedChildren()}};b7.uiClass="";lL=b7,Wt=lL;sa=class aa extends Wt{static create(e){return super.create(e)}static formats(e,t){let r=t.query(aa.blotName);if(!(r!=null&&e.tagName===r.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return e.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new Ho(this.domNode)}format(e,t){if(e===this.statics.blotName&&!t)this.children.forEach(r=>{r instanceof aa||(r=r.wrap(aa.blotName,!0)),this.attributes.copy(r)}),this.unwrap();else{let r=this.scroll.query(e,Y.INLINE);if(r==null)return;r instanceof kt?this.attributes.attribute(r,t):t&&(e!==this.statics.blotName||this.formats()[e]!==t)&&this.replaceWith(e,t)}}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,r,n){this.formats()[r]!=null||this.scroll.query(r,Y.ATTRIBUTE)?this.isolate(e,t).format(r,n):super.formatAt(e,t,r,n)}optimize(e){super.optimize(e);let t=this.formats();if(Object.keys(t).length===0)return this.unwrap();let r=this.next;r instanceof aa&&r.prev===this&&hL(t,r.formats())&&(r.moveChildren(this),r.remove())}replaceWith(e,t){let r=super.replaceWith(e,t);return this.attributes.copy(r),r}update(e,t){super.update(e,t),e.some(r=>r.target===this.domNode&&r.type==="attributes")&&this.attributes.build()}wrap(e,t){let r=super.wrap(e,t);return r instanceof aa&&this.attributes.move(r),r}};sa.allowedChildren=[sa,Je],sa.blotName="inline",sa.scope=Y.INLINE_BLOT,sa.tagName="SPAN";dL=sa,Lh=dL,oa=class y1 extends Wt{static create(e){return super.create(e)}static formats(e,t){let r=t.query(y1.blotName);if(!(r!=null&&e.tagName===r.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return e.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new Ho(this.domNode)}format(e,t){let r=this.scroll.query(e,Y.BLOCK);r!=null&&(r instanceof kt?this.attributes.attribute(r,t):e===this.statics.blotName&&!t?this.replaceWith(y1.blotName):t&&(e!==this.statics.blotName||this.formats()[e]!==t)&&this.replaceWith(e,t))}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,r,n){this.scroll.query(r,Y.BLOCK)!=null?this.format(r,n):super.formatAt(e,t,r,n)}insertAt(e,t,r){if(r==null||this.scroll.query(t,Y.INLINE)!=null)super.insertAt(e,t,r);else{let n=this.split(e);if(n!=null){let s=this.scroll.create(t,r);n.parent.insertBefore(s,n)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(e,t){let r=super.replaceWith(e,t);return this.attributes.copy(r),r}update(e,t){super.update(e,t),e.some(r=>r.target===this.domNode&&r.type==="attributes")&&this.attributes.build()}};oa.blotName="block",oa.scope=Y.BLOCK_BLOT,oa.tagName="P",oa.allowedChildren=[Lh,oa,Je];cL=oa,Vn=cL,b1=class extends Wt{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(e,t){super.deleteAt(e,t),this.enforceAllowedChildren()}formatAt(e,t,r,n){super.formatAt(e,t,r,n),this.enforceAllowedChildren()}insertAt(e,t,r){super.insertAt(e,t,r),this.enforceAllowedChildren()}optimize(e){super.optimize(e),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};b1.blotName="container",b1.scope=Y.BLOCK_BLOT;uL=b1,ha=uL,w1=class extends Je{static formats(e,t){}format(e,t){super.formatAt(0,this.length(),e,t)}formatAt(e,t,r,n){e===0&&t===this.length()?this.format(r,n):super.formatAt(e,t,r,n)}formats(){return this.statics.formats(this.domNode,this.scroll)}},Ue=w1,fL={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},mL=100,la=class extends Wt{constructor(e,t){super(null,t),this.registry=e,this.scroll=this,this.build(),this.observer=new MutationObserver(r=>{this.update(r)}),this.observer.observe(this.domNode,fL),this.attach()}create(e,t){return this.registry.create(this,e,t)}find(e,t=!1){let r=this.registry.find(e,t);return r?r.scroll===this?r:t?this.find(r.scroll.domNode.parentNode,!0):null:null}query(e,t=Y.ANY){return this.registry.query(e,t)}register(...e){return this.registry.register(...e)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(e,t){this.update(),e===0&&t===this.length()?this.children.forEach(r=>{r.remove()}):super.deleteAt(e,t)}formatAt(e,t,r,n){this.update(),super.formatAt(e,t,r,n)}insertAt(e,t,r){this.update(),super.insertAt(e,t,r)}optimize(e=[],t={}){super.optimize(t);let r=t.mutationsMap||new WeakMap,n=Array.from(this.observer.takeRecords());for(;n.length>0;)e.push(n.pop());let s=(l,h=!0)=>{l==null||l===this||l.domNode.parentNode!=null&&(r.has(l.domNode)||r.set(l.domNode,[]),h&&s(l.parent))},a=l=>{r.has(l.domNode)&&(l instanceof Wt&&l.children.forEach(a),r.delete(l.domNode),l.optimize(t))},o=e;for(let l=0;o.length>0;l+=1){if(l>=mL)throw new Error("[Parchment] Maximum optimize iterations reached");for(o.forEach(h=>{let d=this.find(h.target,!0);d!=null&&(d.domNode===h.target&&(h.type==="childList"?(s(this.find(h.previousSibling,!1)),Array.from(h.addedNodes).forEach(c=>{let f=this.find(c,!1);s(f,!1),f instanceof Wt&&f.children.forEach(m=>{s(m,!1)})})):h.type==="attributes"&&s(d.prev)),s(d))}),this.children.forEach(a),o=Array.from(this.observer.takeRecords()),n=o.slice();n.length>0;)e.push(n.pop())}}update(e,t={}){e=e||this.observer.takeRecords();let r=new WeakMap;e.map(n=>{let s=this.find(n.target,!0);return s==null?null:r.has(s.domNode)?(r.get(s.domNode).push(n),null):(r.set(s.domNode,[n]),s)}).forEach(n=>{n!=null&&n!==this&&r.has(n.domNode)&&n.update(r.get(n.domNode)||[],t)}),t.mutationsMap=r,r.has(this.domNode)&&super.update(r.get(this.domNode),t),this.optimize(e,t)}};la.blotName="scroll",la.defaultChild=Vn,la.allowedChildren=[Vn,ha],la.scope=Y.BLOCK_BLOT,la.tagName="DIV";pL=la,Uo=pL,M1=class w7 extends Je{static create(e){return document.createTextNode(e)}static value(e){return e.data}constructor(e,t){super(e,t),this.text=this.statics.value(this.domNode)}deleteAt(e,t){this.domNode.data=this.text=this.text.slice(0,e)+this.text.slice(e+t)}index(e,t){return this.domNode===e?t:-1}insertAt(e,t,r){r==null?(this.text=this.text.slice(0,e)+t+this.text.slice(e),this.domNode.data=this.text):super.insertAt(e,t,r)}length(){return this.text.length}optimize(e){super.optimize(e),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof w7&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(e,t=!1){return[this.domNode,e]}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let r=this.scroll.create(this.domNode.splitText(e));return this.parent.insertBefore(r,this.next||void 0),this.text=this.statics.value(this.domNode),r}update(e,t){e.some(r=>r.type==="characterData"&&r.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};M1.blotName="text",M1.scope=Y.INLINE_BLOT;gL=M1,da=gL});var z7=qi((KV,L7)=>{var ni=-1,Ct=1,it=0;function jo(i,e,t,r,n){if(i===e)return i?[[it,i]]:[];if(t!=null){var s=EL(i,e,t);if(s)return s}var a=N1(i,e),o=i.substring(0,a);i=i.substring(a),e=e.substring(a),a=zh(i,e);var l=i.substring(i.length-a);i=i.substring(0,i.length-a),e=e.substring(0,e.length-a);var h=xL(i,e);return o&&h.unshift([it,o]),l&&h.push([it,l]),E1(h,n),r&&bL(h),h}function xL(i,e){var t;if(!i)return[[Ct,e]];if(!e)return[[ni,i]];var r=i.length>e.length?i:e,n=i.length>e.length?e:i,s=r.indexOf(n);if(s!==-1)return t=[[Ct,r.substring(0,s)],[it,n],[Ct,r.substring(s+n.length)]],i.length>e.length&&(t[0][0]=t[2][0]=ni),t;if(n.length===1)return[[ni,i],[Ct,e]];var a=yL(i,e);if(a){var o=a[0],l=a[1],h=a[2],d=a[3],c=a[4],f=jo(o,h),m=jo(l,d);return f.concat([[it,c]],m)}return vL(i,e)}function vL(i,e){for(var t=i.length,r=e.length,n=Math.ceil((t+r)/2),s=n,a=2*n,o=new Array(a),l=new Array(a),h=0;ht)m+=2;else if(C>r)f+=2;else if(c){var _=s+d-b;if(_>=0&&_=I)return M7(i,e,S,C)}}}for(var O=-v+g;O<=v-x;O+=2){var _=s+O,I;O===-v||O!==v&&l[_-1]t)x+=2;else if(D>r)g+=2;else if(!c){var E=s+d-O;if(E>=0&&E=I)return M7(i,e,S,C)}}}}return[[ni,i],[Ct,e]]}function M7(i,e,t,r){var n=i.substring(0,t),s=e.substring(0,r),a=i.substring(t),o=e.substring(r),l=jo(n,s),h=jo(a,o);return l.concat(h)}function N1(i,e){if(!i||!e||i.charAt(0)!==e.charAt(0))return 0;for(var t=0,r=Math.min(i.length,e.length),n=r,s=0;tr?i=i.substring(t-r):te.length?i:e,r=i.length>e.length?e:i;if(t.length<4||r.length*2=m.length?[S,C,_,I,E]:null}var s=n(t,r,Math.ceil(t.length/4)),a=n(t,r,Math.ceil(t.length/2)),o;if(!s&&!a)return null;a?s?o=s[4].length>a[4].length?s:a:o=a:o=s;var l,h,d,c;i.length>e.length?(l=o[0],h=o[1],d=o[2],c=o[3]):(d=o[0],c=o[1],l=o[2],h=o[3]);var f=o[4];return[l,h,d,c,f]}function bL(i){for(var e=!1,t=[],r=0,n=null,s=0,a=0,o=0,l=0,h=0;s0?t[r-1]:-1,a=0,o=0,l=0,h=0,n=null,e=!0)),s++;for(e&&E1(i),TL(i),s=1;s=m?(f>=d.length/2||f>=c.length/2)&&(i.splice(s,0,[it,c.substring(0,f)]),i[s-1][1]=d.substring(0,d.length-f),i[s+1][1]=c.substring(f),s++):(m>=d.length/2||m>=c.length/2)&&(i.splice(s,0,[it,d.substring(0,m)]),i[s-1][0]=Ct,i[s-1][1]=c.substring(0,c.length-m),i[s+1][0]=ni,i[s+1][1]=d.substring(m),s++),s++}s++}}var N7=/[^a-zA-Z0-9]/,E7=/\s/,S7=/[\r\n]/,wL=/\n\r?\n$/,ML=/^\r?\n\r?\n/;function TL(i){function e(m,g){if(!m||!g)return 6;var x=m.charAt(m.length-1),v=g.charAt(0),b=x.match(N7),E=v.match(N7),S=b&&x.match(E7),C=E&&v.match(E7),_=S&&x.match(S7),I=C&&v.match(S7),O=_&&m.match(wL),D=I&&g.match(ML);return O||D?5:_||I?4:b&&!S&&C?3:S||C?2:b||E?1:0}for(var t=1;t=c&&(c=f,l=r,h=n,d=s)}i[t-1][1]!=l&&(l?i[t-1][1]=l:(i.splice(t-1,1),t--),i[t][1]=h,d?i[t+1][1]=d:(i.splice(t+1,1),t--))}t++}}function E1(i,e){i.push([it,""]);for(var t=0,r=0,n=0,s="",a="",o;t=0&&_7(i[l][1])){var h=i[l][1].slice(-1);if(i[l][1]=i[l][1].slice(0,-1),s=h+s,a=h+a,!i[l][1]){i.splice(l,1),t--;var d=l-1;i[d]&&i[d][0]===Ct&&(n++,a=i[d][1]+a,d--),i[d]&&i[d][0]===ni&&(r++,s=i[d][1]+s,d--),l=d}}if(C7(i[t][1])){var h=i[t][1].charAt(0);i[t][1]=i[t][1].slice(1),s+=h,a+=h}}if(t0||a.length>0){s.length>0&&a.length>0&&(o=N1(a,s),o!==0&&(l>=0?i[l][1]+=a.substring(0,o):(i.splice(0,0,[it,a.substring(0,o)]),t++),a=a.substring(o),s=s.substring(o)),o=zh(a,s),o!==0&&(i[t][1]=a.substring(a.length-o)+i[t][1],a=a.substring(0,a.length-o),s=s.substring(0,s.length-o)));var c=n+r;s.length===0&&a.length===0?(i.splice(t-c,c),t=t-c):s.length===0?(i.splice(t-c,c,[Ct,a]),t=t-c+1):a.length===0?(i.splice(t-c,c,[ni,s]),t=t-c+1):(i.splice(t-c,c,[ni,s],[Ct,a]),t=t-c+2)}t!==0&&i[t-1][0]===it?(i[t-1][1]+=i[t][1],i.splice(t,1)):t++,n=0,r=0,s="",a="";break}}i[i.length-1][1]===""&&i.pop();var f=!1;for(t=1;t=55296&&i<=56319}function k7(i){return i>=56320&&i<=57343}function C7(i){return k7(i.charCodeAt(0))}function _7(i){return A7(i.charCodeAt(i.length-1))}function NL(i){for(var e=[],t=0;t0&&e.push(i[t]);return e}function T1(i,e,t,r){return _7(i)||C7(r)?null:NL([[it,i],[ni,e],[Ct,t],[it,r]])}function EL(i,e,t){var r=typeof t=="number"?{index:t,length:0}:t.oldRange,n=typeof t=="number"?null:t.newRange,s=i.length,a=e.length;if(r.length===0&&(n===null||n.length===0)){var o=r.index,l=i.slice(0,o),h=i.slice(o),d=n?n.index:null;e:{var c=o+a-s;if(d!==null&&d!==c||c<0||c>a)break e;var f=e.slice(0,c),m=e.slice(c);if(m!==h)break e;var g=Math.min(o,c),x=l.slice(0,g),v=f.slice(0,g);if(x!==v)break e;var b=l.slice(g),E=f.slice(g);return T1(x,b,E,h)}e:{if(d!==null&&d!==o)break e;var S=o,f=e.slice(0,S),m=e.slice(S);if(f!==l)break e;var C=Math.min(s-S,a-S),_=h.slice(h.length-C),I=m.slice(m.length-C);if(_!==I)break e;var b=h.slice(0,h.length-C),E=m.slice(0,m.length-C);return T1(l,b,E,_)}}if(r.length>0&&n&&n.length===0)e:{var x=i.slice(0,r.index),_=i.slice(r.index+r.length),g=x.length,C=_.length;if(a{var SL=200,j7="__lodash_hash_undefined__",G7=9007199254740991,I1="[object Arguments]",AL="[object Array]",Y7="[object Boolean]",W7="[object Date]",kL="[object Error]",R1="[object Function]",V7="[object GeneratorFunction]",Rh="[object Map]",X7="[object Number]",D1="[object Object]",I7="[object Promise]",K7="[object RegExp]",Dh="[object Set]",Z7="[object String]",Q7="[object Symbol]",A1="[object WeakMap]",J7="[object ArrayBuffer]",Oh="[object DataView]",e8="[object Float32Array]",t8="[object Float64Array]",i8="[object Int8Array]",r8="[object Int16Array]",n8="[object Int32Array]",s8="[object Uint8Array]",a8="[object Uint8ClampedArray]",o8="[object Uint16Array]",l8="[object Uint32Array]",CL=/[\\^$.*+?()[\]{}|]/g,_L=/\w*$/,LL=/^\[object .+?Constructor\]$/,zL=/^(?:0|[1-9]\d*)$/,Le={};Le[I1]=Le[AL]=Le[J7]=Le[Oh]=Le[Y7]=Le[W7]=Le[e8]=Le[t8]=Le[i8]=Le[r8]=Le[n8]=Le[Rh]=Le[X7]=Le[D1]=Le[K7]=Le[Dh]=Le[Z7]=Le[Q7]=Le[s8]=Le[a8]=Le[o8]=Le[l8]=!0;Le[kL]=Le[R1]=Le[A1]=!1;var IL=typeof global=="object"&&global&&global.Object===Object&&global,RL=typeof self=="object"&&self&&self.Object===Object&&self,Er=IL||RL||Function("return this")(),h8=typeof Go=="object"&&Go&&!Go.nodeType&&Go,R7=h8&&typeof ca=="object"&&ca&&!ca.nodeType&&ca,DL=R7&&R7.exports===h8;function OL(i,e){return i.set(e[0],e[1]),i}function BL(i,e){return i.add(e),i}function PL(i,e){for(var t=-1,r=i?i.length:0;++t-1}function cz(i,e){var t=this.__data__,r=Fh(t,i);return r<0?t.push([i,e]):t[r][1]=e,this}Sr.prototype.clear=oz;Sr.prototype.delete=lz;Sr.prototype.get=hz;Sr.prototype.has=dz;Sr.prototype.set=cz;function ua(i){var e=-1,t=i?i.length:0;for(this.clear();++e-1&&i%1==0&&i-1&&i%1==0&&i<=G7}function Hh(i){var e=typeof i;return!!i&&(e=="object"||e=="function")}function Kz(i){return!!i&&typeof i=="object"}function F1(i){return v8(i)?Mz(i):kz(i)}function Zz(){return[]}function Qz(){return!1}ca.exports=Gz});var Q1=qi((Vo,ga)=>{var Jz=200,Z1="__lodash_hash_undefined__",Xh=1,L8=2,z8=9007199254740991,Uh="[object Arguments]",j1="[object Array]",eI="[object AsyncFunction]",I8="[object Boolean]",R8="[object Date]",D8="[object Error]",O8="[object Function]",tI="[object GeneratorFunction]",$h="[object Map]",B8="[object Number]",iI="[object Null]",pa="[object Object]",b8="[object Promise]",rI="[object Proxy]",P8="[object RegExp]",jh="[object Set]",F8="[object String]",nI="[object Symbol]",sI="[object Undefined]",G1="[object WeakMap]",q8="[object ArrayBuffer]",Gh="[object DataView]",aI="[object Float32Array]",oI="[object Float64Array]",lI="[object Int8Array]",hI="[object Int16Array]",dI="[object Int32Array]",cI="[object Uint8Array]",uI="[object Uint8ClampedArray]",fI="[object Uint16Array]",mI="[object Uint32Array]",pI=/[\\^$.*+?()[\]{}|]/g,gI=/^\[object .+?Constructor\]$/,xI=/^(?:0|[1-9]\d*)$/,De={};De[aI]=De[oI]=De[lI]=De[hI]=De[dI]=De[cI]=De[uI]=De[fI]=De[mI]=!0;De[Uh]=De[j1]=De[q8]=De[I8]=De[Gh]=De[R8]=De[D8]=De[O8]=De[$h]=De[B8]=De[pa]=De[P8]=De[jh]=De[F8]=De[G1]=!1;var H8=typeof global=="object"&&global&&global.Object===Object&&global,vI=typeof self=="object"&&self&&self.Object===Object&&self,Ar=H8||vI||Function("return this")(),U8=typeof Vo=="object"&&Vo&&!Vo.nodeType&&Vo,w8=U8&&typeof ga=="object"&&ga&&!ga.nodeType&&ga,$8=w8&&w8.exports===U8,H1=$8&&H8.process,M8=(function(){try{return H1&&H1.binding&&H1.binding("util")}catch{}})(),T8=M8&&M8.isTypedArray;function yI(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t-1}function XI(i,e){var t=this.__data__,r=Zh(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}kr.prototype.clear=GI;kr.prototype.delete=YI;kr.prototype.get=WI;kr.prototype.has=VI;kr.prototype.set=XI;function es(i){var e=-1,t=i==null?0:i.length;for(this.clear();++eo))return!1;var h=s.get(i);if(h&&s.get(e))return h==e;var d=-1,c=!0,f=t&L8?new Wh:void 0;for(s.set(i,e),s.set(e,i);++d-1&&i%1==0&&i-1&&i%1==0&&i<=z8}function Q8(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}function Zo(i){return i!=null&&typeof i=="object"}var J8=T8?TI(T8):uR;function SR(i){return NR(i)?lR(i):fR(i)}function AR(){return[]}function kR(){return!1}ga.exports=ER});var e9=qi(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});var CR=q1(),_R=Q1(),J1;(function(i){function e(s={},a={},o=!1){typeof s!="object"&&(s={}),typeof a!="object"&&(a={});let l=CR(a);o||(l=Object.keys(l).reduce((h,d)=>(l[d]!=null&&(h[d]=l[d]),h),{}));for(let h in s)s[h]!==void 0&&a[h]===void 0&&(l[h]=s[h]);return Object.keys(l).length>0?l:void 0}i.compose=e;function t(s={},a={}){typeof s!="object"&&(s={}),typeof a!="object"&&(a={});let o=Object.keys(s).concat(Object.keys(a)).reduce((l,h)=>(_R(s[h],a[h])||(l[h]=a[h]===void 0?null:a[h]),l),{});return Object.keys(o).length>0?o:void 0}i.diff=t;function r(s={},a={}){s=s||{};let o=Object.keys(a).reduce((l,h)=>(a[h]!==s[h]&&s[h]!==void 0&&(l[h]=a[h]),l),{});return Object.keys(s).reduce((l,h)=>(s[h]!==a[h]&&a[h]===void 0&&(l[h]=null),l),o)}i.invert=r;function n(s,a,o=!1){if(typeof s!="object")return a;if(typeof a!="object")return;if(!o)return a;let l=Object.keys(a).reduce((h,d)=>(s[d]===void 0&&(h[d]=a[d]),h),{});return Object.keys(l).length>0?l:void 0}i.transform=n})(J1||(J1={}));ef.default=J1});var nf=qi(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});var tf;(function(i){function e(t){return typeof t.delete=="number"?t.delete:typeof t.retain=="number"?t.retain:typeof t.retain=="object"&&t.retain!==null?1:typeof t.insert=="string"?t.insert.length:1}i.length=e})(tf||(tf={}));rf.default=tf});var i9=qi(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});var t9=nf(),sf=class{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e){e||(e=1/0);let t=this.ops[this.index];if(t){let r=this.offset,n=t9.default.length(t);if(e>=n-r?(e=n-r,this.index+=1,this.offset=0):this.offset+=e,typeof t.delete=="number")return{delete:e};{let s={};return t.attributes&&(s.attributes=t.attributes),typeof t.retain=="number"?s.retain=e:typeof t.retain=="object"&&t.retain!==null?s.retain=t.retain:typeof t.insert=="string"?s.insert=t.insert.substr(r,e):s.insert=t.insert,s}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?t9.default.length(this.ops[this.index])-this.offset:1/0}peekType(){let e=this.ops[this.index];return e?typeof e.delete=="number"?"delete":typeof e.retain=="number"||typeof e.retain=="object"&&e.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{let e=this.offset,t=this.index,r=this.next(),n=this.ops.slice(this.index);return this.offset=e,this.index=t,[r].concat(n)}}else return[]}};af.default=sf});var si=qi((_r,ed)=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.AttributeMap=_r.OpIterator=_r.Op=void 0;var Jh=z7(),LR=q1(),of=Q1(),is=e9();_r.AttributeMap=is.default;var Cr=nf();_r.Op=Cr.default;var bi=i9();_r.OpIterator=bi.default;var zR="\0",r9=(i,e)=>{if(typeof i!="object"||i===null)throw new Error(`cannot retain a ${typeof i}`);if(typeof e!="object"||e===null)throw new Error(`cannot retain a ${typeof e}`);let t=Object.keys(i)[0];if(!t||t!==Object.keys(e)[0])throw new Error(`embed types not matched: ${t} != ${Object.keys(e)[0]}`);return[t,i[t],e[t]]},Lr=class i{constructor(e){Array.isArray(e)?this.ops=e:e!=null&&Array.isArray(e.ops)?this.ops=e.ops:this.ops=[]}static registerEmbed(e,t){this.handlers[e]=t}static unregisterEmbed(e){delete this.handlers[e]}static getHandler(e){let t=this.handlers[e];if(!t)throw new Error(`no handlers for embed type "${e}"`);return t}insert(e,t){let r={};return typeof e=="string"&&e.length===0?this:(r.insert=e,t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(r.attributes=t),this.push(r))}delete(e){return e<=0?this:this.push({delete:e})}retain(e,t){if(typeof e=="number"&&e<=0)return this;let r={retain:e};return t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(r.attributes=t),this.push(r)}push(e){let t=this.ops.length,r=this.ops[t-1];if(e=LR(e),typeof r=="object"){if(typeof e.delete=="number"&&typeof r.delete=="number")return this.ops[t-1]={delete:r.delete+e.delete},this;if(typeof r.delete=="number"&&e.insert!=null&&(t-=1,r=this.ops[t-1],typeof r!="object"))return this.ops.unshift(e),this;if(of(e.attributes,r.attributes)){if(typeof e.insert=="string"&&typeof r.insert=="string")return this.ops[t-1]={insert:r.insert+e.insert},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this;if(typeof e.retain=="number"&&typeof r.retain=="number")return this.ops[t-1]={retain:r.retain+e.retain},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this}}return t===this.ops.length?this.ops.push(e):this.ops.splice(t,0,e),this}chop(){let e=this.ops[this.ops.length-1];return e&&typeof e.retain=="number"&&!e.attributes&&this.ops.pop(),this}filter(e){return this.ops.filter(e)}forEach(e){this.ops.forEach(e)}map(e){return this.ops.map(e)}partition(e){let t=[],r=[];return this.forEach(n=>{(e(n)?t:r).push(n)}),[t,r]}reduce(e,t){return this.ops.reduce(e,t)}changeLength(){return this.reduce((e,t)=>t.insert?e+Cr.default.length(t):t.delete?e-t.delete:e,0)}length(){return this.reduce((e,t)=>e+Cr.default.length(t),0)}slice(e=0,t=1/0){let r=[],n=new bi.default(this.ops),s=0;for(;s0&&r.next(s.retain-o)}let a=new i(n);for(;t.hasNext()||r.hasNext();)if(r.peekType()==="insert")a.push(r.next());else if(t.peekType()==="delete")a.push(t.next());else{let o=Math.min(t.peekLength(),r.peekLength()),l=t.next(o),h=r.next(o);if(h.retain){let d={};if(typeof l.retain=="number")d.retain=typeof h.retain=="number"?o:h.retain;else if(typeof h.retain=="number")l.retain==null?d.insert=l.insert:d.retain=l.retain;else{let f=l.retain==null?"insert":"retain",[m,g,x]=r9(l[f],h.retain),v=i.getHandler(m);d[f]={[m]:v.compose(g,x,f==="retain")}}let c=is.default.compose(l.attributes,h.attributes,typeof l.retain=="number");if(c&&(d.attributes=c),a.push(d),!r.hasNext()&&of(a.ops[a.ops.length-1],d)){let f=new i(t.rest());return a.concat(f).chop()}}else typeof h.delete=="number"&&(typeof l.retain=="number"||typeof l.retain=="object"&&l.retain!==null)&&a.push(h)}return a.chop()}concat(e){let t=new i(this.ops.slice());return e.ops.length>0&&(t.push(e.ops[0]),t.ops=t.ops.concat(e.ops.slice(1))),t}diff(e,t){if(this.ops===e.ops)return new i;let r=[this,e].map(l=>l.map(h=>{if(h.insert!=null)return typeof h.insert=="string"?h.insert:zR;let d=l===e?"on":"with";throw new Error("diff() called "+d+" non-document")}).join("")),n=new i,s=Jh(r[0],r[1],t,!0),a=new bi.default(this.ops),o=new bi.default(e.ops);return s.forEach(l=>{let h=l[1].length;for(;h>0;){let d=0;switch(l[0]){case Jh.INSERT:d=Math.min(o.peekLength(),h),n.push(o.next(d));break;case Jh.DELETE:d=Math.min(h,a.peekLength()),a.next(d),n.delete(d);break;case Jh.EQUAL:d=Math.min(a.peekLength(),o.peekLength(),h);let c=a.next(d),f=o.next(d);of(c.insert,f.insert)?n.retain(d,is.default.diff(c.attributes,f.attributes)):n.push(f).delete(d);break}h-=d}}),n.chop()}eachLine(e,t=` -`){let r=new bi.default(this.ops),n=new i,s=0;for(;r.hasNext();){if(r.peekType()!=="insert")return;let a=r.peek(),o=Cr.default.length(a)-r.peekLength(),l=typeof a.insert=="string"?a.insert.indexOf(t,o)-o:-1;if(l<0)n.push(r.next());else if(l>0)n.push(r.next(l));else{if(e(n,r.next(1).attributes||{},s)===!1)return;s+=1,n=new i}}n.length()>0&&e(n,{},s)}invert(e){let t=new i;return this.reduce((r,n)=>{if(n.insert)t.delete(Cr.default.length(n));else{if(typeof n.retain=="number"&&n.attributes==null)return t.retain(n.retain),r+n.retain;if(n.delete||typeof n.retain=="number"){let s=n.delete||n.retain;return e.slice(r,r+s).forEach(o=>{n.delete?t.push(o):n.retain&&n.attributes&&t.retain(Cr.default.length(o),is.default.invert(n.attributes,o.attributes))}),r+s}else if(typeof n.retain=="object"&&n.retain!==null){let s=e.slice(r,r+1),a=new bi.default(s.ops).next(),[o,l,h]=r9(n.retain,a.insert),d=i.getHandler(o);return t.retain({[o]:d.invert(l,h)},is.default.invert(n.attributes,a.attributes)),r+1}}return r},0),t.chop()}transform(e,t=!1){if(t=!!t,typeof e=="number")return this.transformPosition(e,t);let r=e,n=new bi.default(this.ops),s=new bi.default(r.ops),a=new i;for(;n.hasNext()||s.hasNext();)if(n.peekType()==="insert"&&(t||s.peekType()!=="insert"))a.retain(Cr.default.length(n.next()));else if(s.peekType()==="insert")a.push(s.next());else{let o=Math.min(n.peekLength(),s.peekLength()),l=n.next(o),h=s.next(o);if(l.delete)continue;if(h.delete)a.push(h);else{let d=l.retain,c=h.retain,f=typeof c=="object"&&c!==null?c:o;if(typeof d=="object"&&d!==null&&typeof c=="object"&&c!==null){let m=Object.keys(d)[0];if(m===Object.keys(c)[0]){let g=i.getHandler(m);g&&(f={[m]:g.transform(d[m],c[m],t)})}}a.retain(f,is.default.transform(l.attributes,h.attributes,t))}}return a.chop()}transformPosition(e,t=!1){t=!!t;let r=new bi.default(this.ops),n=0;for(;r.hasNext()&&n<=e;){let s=r.peekLength(),a=r.peekType();if(r.next(),a==="delete"){e-=Math.min(s,e-n);continue}else a==="insert"&&(n{Ae();Jo=class extends Ue{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}};Jo.blotName="break";Jo.tagName="BR";pt=Jo});function rs(i){return i.replace(/[&<>"']/g,e=>IR[e])}var Ve,IR,zr=M(()=>{Ae();Ve=class extends da{},IR={"&":"&","<":"<",">":">",'"':""","'":"'"}});var ir,lf,gt,Ir=M(()=>{Ae();pn();zr();ir=class ir extends Lh{static compare(e,t){let r=ir.order.indexOf(e),n=ir.order.indexOf(t);return r>=0||n>=0?r-n:e===t?0:e0){let t=this.parent.isolate(this.offset(),this.length());this.moveChildren(t),t.wrap(this)}}};P(ir,"allowedChildren",[ir,pt,Ue,Ve]),P(ir,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]);lf=ir,gt=lf});function df(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return i.descendants(Je).reduce((t,r)=>r.length()===0?t:t.insert(r.value(),Xt(r,{},e)),new hf.default).insert(` -`,Xt(i))}function Xt(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return i==null||("formats"in i&&typeof i.formats=="function"&&(e={...e,...i.formats()},t&&delete e["code-token"]),i.parent==null||i.parent.statics.blotName==="scroll"||i.parent.statics.scope!==i.statics.scope)?e:Xt(i.parent,e,t)}var hf,n9,ke,rt,wi=M(()=>{Ae();hf=ot(si(),1);pn();Ir();zr();n9=1,ke=class extends Vn{constructor(){super(...arguments);P(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=df(this)),this.cache.delta}deleteAt(t,r){super.deleteAt(t,r),this.cache={}}formatAt(t,r,n,s){r<=0||(this.scroll.query(n,Y.BLOCK)?t+r===this.length()&&this.format(n,s):super.formatAt(t,Math.min(r,this.length()-t-1),n,s),this.cache={})}insertAt(t,r,n){if(n!=null){super.insertAt(t,r,n),this.cache={};return}if(r.length===0)return;let s=r.split(` -`),a=s.shift();a.length>0&&(t(o=o.split(l,!0),o.insertAt(0,h),h.length),t+a.length)}insertBefore(t,r){let{head:n}=this.children;super.insertBefore(t,r),n instanceof pt&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+n9),this.cache.length}moveChildren(t,r){super.moveChildren(t,r),this.cache={}}optimize(t){super.optimize(t),this.cache={}}path(t){return super.path(t,!0)}removeChild(t){super.removeChild(t),this.cache={}}split(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(r&&(t===0||t>=this.length()-n9)){let s=this.clone();return t===0?(this.parent.insertBefore(s,this),this):(this.parent.insertBefore(s,this.next),s)}let n=super.split(t,r);return this.cache={},n}};ke.blotName="block";ke.tagName="P";ke.defaultChild=pt;ke.allowedChildren=[pt,gt,Ue,Ve];rt=class extends Ue{attach(){super.attach(),this.attributes=new Ho(this.domNode)}delta(){return new hf.default().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(e,t){let r=this.scroll.query(e,Y.BLOCK_ATTRIBUTE);r!=null&&this.attributes.attribute(r,t)}formatAt(e,t,r,n){this.format(r,n)}insertAt(e,t,r){if(r!=null){super.insertAt(e,t,r);return}let n=t.split(` -`),s=n.pop(),a=n.map(l=>{let h=this.scroll.create(ke.blotName);return h.insertAt(0,l),h}),o=this.split(e);a.forEach(l=>{this.parent.insertBefore(l,o)}),s&&this.parent.insertBefore(this.scroll.create("text",s),o)}};rt.scope=Y.BLOCK_BLOT});var Mi,cf,gn,el=M(()=>{Ae();zr();Mi=class Mi extends Ue{static value(){}constructor(e,t,r){super(e,t),this.selection=r,this.textNode=document.createTextNode(Mi.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(e,t){if(this.savedLength!==0){super.format(e,t);return}let r=this,n=0;for(;r!=null&&r.statics.scope!==Y.BLOCK_BLOT;)n+=r.offset(r.parent),r=r.parent;r!=null&&(this.savedLength=Mi.CONTENTS.length,r.optimize(),r.formatAt(n,Mi.CONTENTS.length,e,t),this.savedLength=0)}index(e,t){return e===this.textNode?0:super.index(e,t)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||this.parent==null)return null;let e=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);let t=this.prev instanceof Ve?this.prev:null,r=t?t.length():0,n=this.next instanceof Ve?this.next:null,s=n?n.text:"",{textNode:a}=this,o=a.data.split(Mi.CONTENTS).join("");a.data=Mi.CONTENTS;let l;if(t)l=t,(o||n)&&(t.insertAt(t.length(),o+s),n&&n.remove());else if(n)l=n,n.insertAt(0,o);else{let h=document.createTextNode(o);l=this.scroll.create(h),this.parent.insertBefore(l,this)}if(this.remove(),e){let h=(f,m)=>t&&f===t.domNode?m:f===a?r+m-1:n&&f===n.domNode?r+o.length+m:null,d=h(e.start.node,e.start.offset),c=h(e.end.node,e.end.offset);if(d!==null&&c!==null)return{startNode:l.domNode,startOffset:d,endNode:l.domNode,endOffset:c}}return null}update(e,t){if(e.some(r=>r.type==="characterData"&&r.target===this.textNode)){let r=this.restore();r&&(t.range=r)}}optimize(e){super.optimize(e);let{parent:t}=this;for(;t;){if(t.domNode.tagName==="A"){this.savedLength=Mi.CONTENTS.length,t.isolate(this.offset(t),this.length()).unwrap(),this.savedLength=0;break}t=t.parent}}value(){return""}};P(Mi,"blotName","cursor"),P(Mi,"className","ql-cursor"),P(Mi,"tagName","span"),P(Mi,"CONTENTS","\uFEFF");cf=Mi,gn=cf});var a9=qi((yX,uf)=>{"use strict";var RR=Object.prototype.hasOwnProperty,_t="~";function tl(){}Object.create&&(tl.prototype=Object.create(null),new tl().__proto__||(_t=!1));function DR(i,e,t){this.fn=i,this.context=e,this.once=t||!1}function s9(i,e,t,r,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new DR(t,r||i,n),a=_t?_t+e:e;return i._events[a]?i._events[a].fn?i._events[a]=[i._events[a],s]:i._events[a].push(s):(i._events[a]=s,i._eventsCount++),i}function td(i,e){--i._eventsCount===0?i._events=new tl:delete i._events[e]}function xt(){this._events=new tl,this._eventsCount=0}xt.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)RR.call(t,r)&&e.push(_t?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};xt.prototype.listeners=function(e){var t=_t?_t+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,s=r.length,a=new Array(s);n{ff=ot(a9(),1)});var il,mf=M(()=>{il=new WeakMap});function l9(i){if(gf&&pf.indexOf(i)<=pf.indexOf(gf)){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r(e[t]=l9.bind(console,t,i),e),{})}var pf,gf,ai,ns=M(()=>{pf=["error","warn","log","info"],gf="warn";xf.level=i=>{gf=i};l9.level=xf.level;ai=xf});var vf,OR,rl,K,Rr=M(()=>{o9();mf();ns();vf=ai("quill:events"),OR=["selectionchange","mousedown","mouseup","click"];OR.forEach(i=>{document.addEventListener(i,function(){for(var e=arguments.length,t=new Array(e),r=0;r{let s=il.get(n);s&&s.emitter&&s.emitter.handleDOM(...t)})})});rl=class extends ff.default{constructor(){super(),this.domListeners={},this.on("error",vf.error)}emit(){for(var e=arguments.length,t=new Array(e),r=0;r1?t-1:0),n=1;n{let{node:a,handler:o}=s;(e.target===a||a.contains(e.target))&&o(e,...r)})}listenDOM(e,t,r){this.domListeners[e]||(this.domListeners[e]=[]),this.domListeners[e].push({node:t,handler:r})}};P(rl,"events",{EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_BLOT_MOUNT:"scroll-blot-mount",SCROLL_BLOT_UNMOUNT:"scroll-blot-unmount",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SCROLL_EMBED_UPDATE:"scroll-embed-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change",COMPOSITION_BEFORE_START:"composition-before-start",COMPOSITION_START:"composition-start",COMPOSITION_BEFORE_END:"composition-before-end",COMPOSITION_END:"composition-end"}),P(rl,"sources",{API:"api",SILENT:"silent",USER:"user"});K=rl});function bf(i,e){try{e.parentNode}catch{return!1}return i.contains(e)}var yf,Lt,wf,h9,nl=M(()=>{Ae();ln();Rr();ns();yf=ai("quill:selection"),Lt=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=e,this.length=t}},wf=class{constructor(e,t){this.emitter=t,this.scroll=e,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create("cursor",this),this.savedRange=new Lt(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,()=>{!this.mouseDown&&!this.composing&&setTimeout(this.update.bind(this,K.sources.USER),1)}),this.emitter.on(K.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;let r=this.getNativeRange();r!=null&&r.start.node!==this.cursor.textNode&&this.emitter.once(K.events.SCROLL_UPDATE,(n,s)=>{try{this.root.contains(r.start.node)&&this.root.contains(r.end.node)&&this.setNativeRange(r.start.node,r.start.offset,r.end.node,r.end.offset);let a=s.some(o=>o.type==="characterData"||o.type==="childList"||o.type==="attributes"&&o.target===this.root);this.update(a?K.sources.SILENT:n)}catch{}})}),this.emitter.on(K.events.SCROLL_OPTIMIZE,(r,n)=>{if(n.range){let{startNode:s,startOffset:a,endNode:o,endOffset:l}=n.range;this.setNativeRange(s,a,o,l),this.update(K.sources.SILENT)}}),this.update(K.sources.SILENT)}handleComposition(){this.emitter.on(K.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(K.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){let e=this.cursor.restore();if(!e)return;setTimeout(()=>{this.setNativeRange(e.startNode,e.startOffset,e.endNode,e.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM("mousedown",document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,()=>{this.mouseDown=!1,this.update(K.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(e,t){this.scroll.update();let r=this.getNativeRange();if(!(r==null||!r.native.collapsed||this.scroll.query(e,Y.BLOCK))){if(r.start.node!==this.cursor.textNode){let n=this.scroll.find(r.start.node,!1);if(n==null)return;if(n instanceof Je){let s=n.split(r.start.offset);n.parent.insertBefore(this.cursor,s)}else n.insertBefore(this.cursor,r.start.node);this.cursor.attach()}this.cursor.format(e,t),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=this.scroll.length();e=Math.min(e,r-1),t=Math.min(e+t,r-1)-e;let n,[s,a]=this.scroll.leaf(e);if(s==null)return null;if(t>0&&a===s.length()){let[d]=this.scroll.leaf(e+1);if(d){let[c]=this.scroll.line(e),[f]=this.scroll.line(e+1);c===f&&(s=d,a=0)}}[n,a]=s.position(a,!0);let o=document.createRange();if(t>0)return o.setStart(n,a),[s,a]=this.scroll.leaf(e+t),s==null?null:([n,a]=s.position(a,!0),o.setEnd(n,a),o.getBoundingClientRect());let l="left",h;if(n instanceof Text){if(!n.data.length)return null;a0&&(l="right")}return{bottom:h.top+h.height,height:h.height,left:h[l],right:h[l],top:h.top,width:0}}getNativeRange(){let e=document.getSelection();if(e==null||e.rangeCount<=0)return null;let t=e.getRangeAt(0);if(t==null)return null;let r=this.normalizeNative(t);return yf.info("getNativeRange",r),r}getRange(){let e=this.scroll.domNode;if("isConnected"in e&&!e.isConnected)return[null,null];let t=this.getNativeRange();return t==null?[null,null]:[this.normalizedToRange(t),t]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&bf(this.root,document.activeElement)}normalizedToRange(e){let t=[[e.start.node,e.start.offset]];e.native.collapsed||t.push([e.end.node,e.end.offset]);let r=t.map(a=>{let[o,l]=a,h=this.scroll.find(o,!0),d=h.offset(this.scroll);return l===0?d:h instanceof Je?d+h.index(o,l):d+h.length()}),n=Math.min(Math.max(...r),this.scroll.length()-1),s=Math.min(n,...r);return new Lt(s,n-s)}normalizeNative(e){if(!bf(this.root,e.startContainer)||!e.collapsed&&!bf(this.root,e.endContainer))return null;let t={start:{node:e.startContainer,offset:e.startOffset},end:{node:e.endContainer,offset:e.endOffset},native:e};return[t.start,t.end].forEach(r=>{let{node:n,offset:s}=r;for(;!(n instanceof Text)&&n.childNodes.length>0;)if(n.childNodes.length>s)n=n.childNodes[s],s=0;else if(n.childNodes.length===s)n=n.lastChild,n instanceof Text?s=n.data.length:n.childNodes.length>0?s=n.childNodes.length:s=n.childNodes.length+1;else break;r.node=n,r.offset=s}),t}rangeToNative(e){let t=this.scroll.length(),r=(n,s)=>{n=Math.min(t-1,n);let[a,o]=this.scroll.leaf(n);return a?a.position(o,s):[null,-1]};return[...r(e.index,!1),...r(e.index+e.length,!0)]}setNativeRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:t,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(yf.info("setNativeRange",e,t,r,n),e!=null&&(this.root.parentNode==null||e.parentNode==null||r.parentNode==null))return;let a=document.getSelection();if(a!=null)if(e!=null){this.hasFocus()||this.root.focus({preventScroll:!0});let{native:o}=this.getNativeRange()||{};if(o==null||s||e!==o.startContainer||t!==o.startOffset||r!==o.endContainer||n!==o.endOffset){e instanceof Element&&e.tagName==="BR"&&(t=Array.from(e.parentNode.childNodes).indexOf(e),e=e.parentNode),r instanceof Element&&r.tagName==="BR"&&(n=Array.from(r.parentNode.childNodes).indexOf(r),r=r.parentNode);let l=document.createRange();l.setStart(e,t),l.setEnd(r,n),a.removeAllRanges(),a.addRange(l)}}else a.removeAllRanges(),this.root.blur()}setRange(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:K.sources.API;if(typeof t=="string"&&(r=t,t=!1),yf.info("setRange",e),e!=null){let n=this.rangeToNative(e);this.setNativeRange(...n,t)}else this.setNativeRange(null);this.update(r)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:K.sources.USER,t=this.lastRange,[r,n]=this.getRange();if(this.lastRange=r,this.lastNative=n,this.lastRange!=null&&(this.savedRange=this.lastRange),!Wn(t,this.lastRange)){if(!this.composing&&n!=null&&n.native.collapsed&&n.start.node!==this.cursor.textNode){let a=this.cursor.restore();a&&this.setNativeRange(a.startNode,a.startOffset,a.endNode,a.endOffset)}let s=[K.events.SELECTION_CHANGE,er(this.lastRange),er(t),e];this.emitter.emit(K.events.EDITOR_CHANGE,...s),e!==K.sources.SILENT&&this.emitter.emit(...s)}}};h9=wf});function va(i,e,t){if(i.length===0){let[m]=Mf(t.pop());return e<=0?`
  • `:`${va([],e-1,t)}`}let[{child:r,offset:n,length:s,indent:a,type:o},...l]=i,[h,d]=Mf(o);if(a>e)return t.push(o),a===e+1?`<${h}>${sl(r,n,s)}${va(l,a,t)}`:`<${h}>
  • ${va(i,e+1,t)}`;let c=t[t.length-1];if(a===e&&o===c)return`
  • ${sl(r,n,s)}${va(l,a,t)}`;let[f]=Mf(t.pop());return`${va(i,e-1,t)}`}function sl(i,e,t){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in i&&typeof i.html=="function")return i.html(e,t);if(i instanceof Ve)return rs(i.value().slice(e,e+t)).replaceAll(" "," ");if(i instanceof Wt){if(i.statics.blotName==="list-container"){let h=[];return i.children.forEachAt(e,t,(d,c,f)=>{let m="formats"in d&&typeof d.formats=="function"?d.formats():{};h.push({child:d,offset:c,length:f,indent:m.indent||0,type:m.list})}),va(h,-1,[])}let n=[];if(i.children.forEachAt(e,t,(h,d,c)=>{n.push(sl(h,d,c))}),r||i.statics.blotName==="list")return n.join("");let{outerHTML:s,innerHTML:a}=i.domNode,[o,l]=s.split(`>${a}<`);return o==="${n.join("")}<${l}`:`${o}>${n.join("")}<${l}`}return i.domNode instanceof Element?i.domNode.outerHTML:""}function PR(i,e){return Object.keys(e).reduce((t,r)=>{if(i[r]==null)return t;let n=e[r];return n===i[r]?t[r]=n:Array.isArray(n)?n.indexOf(i[r])<0?t[r]=n.concat([i[r]]):t[r]=n:t[r]=[n,i[r]],t},{})}function Mf(i){let e=i==="ordered"?"ol":"ul";switch(i){case"checked":return[e,' data-list="checked"'];case"unchecked":return[e,' data-list="unchecked"'];default:return[e,""]}}function d9(i){return i.reduce((e,t)=>{if(typeof t.insert=="string"){let r=t.insert.replace(/\r\n/g,` +?)[ \r ]*`,v1="[\u0300-\u036F]",jA=new RegExp(v1+"+$"),GA="("+tg+"+)|"+($A+"|")+"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]"+(v1+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(v1+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+UA)+("|"+HA+")"),kh=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(GA,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new ui("EOF",new Jt(this,t,t));var r=this.tokenRegex.exec(e);if(r===null||r.index!==t)throw new G("Unexpected character: '"+e[t]+"'",new ui(e[t],new Jt(this,t,t+1)));var n=r[6]||r[3]||(r[2]?"\\ ":" ");if(this.catcodes[n]===14){var s=e.indexOf(` +`,this.tokenRegex.lastIndex);return s===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=s+1,this.lex()}return new ui(n,new Jt(this,t,this.tokenRegex.lastIndex))}},b1=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new G("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t in e)e.hasOwnProperty(t)&&(e[t]==null?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,r){if(r===void 0&&(r=!1),r){for(var n=0;n0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var s=this.undefStack[this.undefStack.length-1];s&&!s.hasOwnProperty(e)&&(s[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}},VA=j4;w("\\noexpand",function(i){var e=i.popToken();return i.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}});w("\\expandafter",function(i){var e=i.popToken();return i.expandOnce(!0),{tokens:[e],numArgs:0}});w("\\@firstoftwo",function(i){var e=i.consumeArgs(2);return{tokens:e[0],numArgs:0}});w("\\@secondoftwo",function(i){var e=i.consumeArgs(2);return{tokens:e[1],numArgs:0}});w("\\@ifnextchar",function(i){var e=i.consumeArgs(3);i.consumeSpaces();var t=i.future();return e[0].length===1&&e[0][0].text===t.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}});w("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");w("\\TextOrMath",function(i){var e=i.consumeArgs(2);return i.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});l4={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};w("\\char",function(i){var e=i.popToken(),t,r="";if(e.text==="'")t=8,e=i.popToken();else if(e.text==='"')t=16,e=i.popToken();else if(e.text==="`")if(e=i.popToken(),e.text[0]==="\\")r=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new G("\\char` missing argument");r=e.text.charCodeAt(0)}else t=10;if(t){if(r=l4[e.text],r==null||r>=t)throw new G("Invalid base-"+t+" digit "+e.text);for(var n;(n=l4[i.future().text])!=null&&n{var n=i.consumeArg().tokens;if(n.length!==1)throw new G("\\newcommand's first argument must be a macro name");var s=n[0].text,a=i.isDefined(s);if(a&&!e)throw new G("\\newcommand{"+s+"} attempting to redefine "+(s+"; use \\renewcommand"));if(!a&&!t)throw new G("\\renewcommand{"+s+"} when command "+s+" does not yet exist; use \\newcommand");var o=0;if(n=i.consumeArg().tokens,n.length===1&&n[0].text==="["){for(var l="",h=i.expandNextToken();h.text!=="]"&&h.text!=="EOF";)l+=h.text,h=i.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new G("Invalid number of arguments: "+l);o=parseInt(l),n=i.consumeArg().tokens}return a&&r||i.macros.set(s,{tokens:n,numArgs:o}),""};w("\\newcommand",i=>O1(i,!1,!0,!1));w("\\renewcommand",i=>O1(i,!0,!1,!1));w("\\providecommand",i=>O1(i,!0,!0,!0));w("\\message",i=>{var e=i.consumeArgs(1)[0];return console.log(e.reverse().map(t=>t.text).join("")),""});w("\\errmessage",i=>{var e=i.consumeArgs(1)[0];return console.error(e.reverse().map(t=>t.text).join("")),""});w("\\show",i=>{var e=i.popToken(),t=e.text;return console.log(e,i.macros.get(t),xn[t],Oe.math[t],Oe.text[t]),""});w("\\bgroup","{");w("\\egroup","}");w("~","\\nobreakspace");w("\\lq","`");w("\\rq","'");w("\\aa","\\r a");w("\\AA","\\r A");w("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xA9}");w("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");w("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xAE}");w("\u212C","\\mathscr{B}");w("\u2130","\\mathscr{E}");w("\u2131","\\mathscr{F}");w("\u210B","\\mathscr{H}");w("\u2110","\\mathscr{I}");w("\u2112","\\mathscr{L}");w("\u2133","\\mathscr{M}");w("\u211B","\\mathscr{R}");w("\u212D","\\mathfrak{C}");w("\u210C","\\mathfrak{H}");w("\u2128","\\mathfrak{Z}");w("\\Bbbk","\\Bbb{k}");w("\xB7","\\cdotp");w("\\llap","\\mathllap{\\textrm{#1}}");w("\\rlap","\\mathrlap{\\textrm{#1}}");w("\\clap","\\mathclap{\\textrm{#1}}");w("\\mathstrut","\\vphantom{(}");w("\\underbar","\\underline{\\text{#1}}");w("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}');w("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}");w("\\ne","\\neq");w("\u2260","\\neq");w("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}");w("\u2209","\\notin");w("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}");w("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}");w("\u225A","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}");w("\u225B","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225B}}");w("\u225D","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225D}}");w("\u225E","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225E}}");w("\u225F","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}");w("\u27C2","\\perp");w("\u203C","\\mathclose{!\\mkern-0.8mu!}");w("\u220C","\\notni");w("\u231C","\\ulcorner");w("\u231D","\\urcorner");w("\u231E","\\llcorner");w("\u231F","\\lrcorner");w("\xA9","\\copyright");w("\xAE","\\textregistered");w("\uFE0F","\\textregistered");w("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');w("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');w("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');w("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');w("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");w("\u22EE","\\vdots");w("\\varGamma","\\mathit{\\Gamma}");w("\\varDelta","\\mathit{\\Delta}");w("\\varTheta","\\mathit{\\Theta}");w("\\varLambda","\\mathit{\\Lambda}");w("\\varXi","\\mathit{\\Xi}");w("\\varPi","\\mathit{\\Pi}");w("\\varSigma","\\mathit{\\Sigma}");w("\\varUpsilon","\\mathit{\\Upsilon}");w("\\varPhi","\\mathit{\\Phi}");w("\\varPsi","\\mathit{\\Psi}");w("\\varOmega","\\mathit{\\Omega}");w("\\substack","\\begin{subarray}{c}#1\\end{subarray}");w("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");w("\\boxed","\\fbox{$\\displaystyle{#1}$}");w("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");w("\\implies","\\DOTSB\\;\\Longrightarrow\\;");w("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");w("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");w("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");h4={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};w("\\dots",function(i){var e="\\dotso",t=i.expandAfterFuture().text;return t in h4?e=h4[t]:(t.slice(0,4)==="\\not"||t in Oe.math&&["bin","rel"].includes(Oe.math[t].group))&&(e="\\dotsb"),e});B1={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};w("\\dotso",function(i){var e=i.future().text;return e in B1?"\\ldots\\,":"\\ldots"});w("\\dotsc",function(i){var e=i.future().text;return e in B1&&e!==","?"\\ldots\\,":"\\ldots"});w("\\cdots",function(i){var e=i.future().text;return e in B1?"\\@cdots\\,":"\\@cdots"});w("\\dotsb","\\cdots");w("\\dotsm","\\cdots");w("\\dotsi","\\!\\cdots");w("\\dotsx","\\ldots\\,");w("\\DOTSI","\\relax");w("\\DOTSB","\\relax");w("\\DOTSX","\\relax");w("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");w("\\,","\\tmspace+{3mu}{.1667em}");w("\\thinspace","\\,");w("\\>","\\mskip{4mu}");w("\\:","\\tmspace+{4mu}{.2222em}");w("\\medspace","\\:");w("\\;","\\tmspace+{5mu}{.2777em}");w("\\thickspace","\\;");w("\\!","\\tmspace-{3mu}{.1667em}");w("\\negthinspace","\\!");w("\\negmedspace","\\tmspace-{4mu}{.2222em}");w("\\negthickspace","\\tmspace-{5mu}{.277em}");w("\\enspace","\\kern.5em ");w("\\enskip","\\hskip.5em\\relax");w("\\quad","\\hskip1em\\relax");w("\\qquad","\\hskip2em\\relax");w("\\tag","\\@ifstar\\tag@literal\\tag@paren");w("\\tag@paren","\\tag@literal{({#1})}");w("\\tag@literal",i=>{if(i.macros.get("\\df@tag"))throw new G("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});w("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");w("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");w("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");w("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");w("\\newline","\\\\\\relax");w("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");ig=V(dr["Main-Regular"][84][1]-.7*dr["Main-Regular"][65][1]);w("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+ig+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");w("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+ig+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");w("\\hspace","\\@ifstar\\@hspacer\\@hspace");w("\\@hspace","\\hskip #1\\relax");w("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");w("\\ordinarycolon",":");w("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");w("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');w("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');w("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');w("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');w("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');w("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');w("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');w("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');w("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');w("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');w("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');w("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');w("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');w("\u2237","\\dblcolon");w("\u2239","\\eqcolon");w("\u2254","\\coloneqq");w("\u2255","\\eqqcolon");w("\u2A74","\\Coloneqq");w("\\ratio","\\vcentcolon");w("\\coloncolon","\\dblcolon");w("\\colonequals","\\coloneqq");w("\\coloncolonequals","\\Coloneqq");w("\\equalscolon","\\eqqcolon");w("\\equalscoloncolon","\\Eqqcolon");w("\\colonminus","\\coloneq");w("\\coloncolonminus","\\Coloneq");w("\\minuscolon","\\eqcolon");w("\\minuscoloncolon","\\Eqcolon");w("\\coloncolonapprox","\\Colonapprox");w("\\coloncolonsim","\\Colonsim");w("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");w("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");w("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");w("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");w("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");w("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");w("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");w("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");w("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");w("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");w("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");w("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}");w("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}");w("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}");w("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}");w("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}");w("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}");w("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}");w("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}");w("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}");w("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}");w("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228A}");w("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2ACB}");w("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228B}");w("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2ACC}");w("\\imath","\\html@mathml{\\@imath}{\u0131}");w("\\jmath","\\html@mathml{\\@jmath}{\u0237}");w("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27E6}}");w("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27E7}}");w("\u27E6","\\llbracket");w("\u27E7","\\rrbracket");w("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}");w("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}");w("\u2983","\\lBrace");w("\u2984","\\rBrace");w("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29B5}}");w("\u29B5","\\minuso");w("\\darr","\\downarrow");w("\\dArr","\\Downarrow");w("\\Darr","\\Downarrow");w("\\lang","\\langle");w("\\rang","\\rangle");w("\\uarr","\\uparrow");w("\\uArr","\\Uparrow");w("\\Uarr","\\Uparrow");w("\\N","\\mathbb{N}");w("\\R","\\mathbb{R}");w("\\Z","\\mathbb{Z}");w("\\alef","\\aleph");w("\\alefsym","\\aleph");w("\\Alpha","\\mathrm{A}");w("\\Beta","\\mathrm{B}");w("\\bull","\\bullet");w("\\Chi","\\mathrm{X}");w("\\clubs","\\clubsuit");w("\\cnums","\\mathbb{C}");w("\\Complex","\\mathbb{C}");w("\\Dagger","\\ddagger");w("\\diamonds","\\diamondsuit");w("\\empty","\\emptyset");w("\\Epsilon","\\mathrm{E}");w("\\Eta","\\mathrm{H}");w("\\exist","\\exists");w("\\harr","\\leftrightarrow");w("\\hArr","\\Leftrightarrow");w("\\Harr","\\Leftrightarrow");w("\\hearts","\\heartsuit");w("\\image","\\Im");w("\\infin","\\infty");w("\\Iota","\\mathrm{I}");w("\\isin","\\in");w("\\Kappa","\\mathrm{K}");w("\\larr","\\leftarrow");w("\\lArr","\\Leftarrow");w("\\Larr","\\Leftarrow");w("\\lrarr","\\leftrightarrow");w("\\lrArr","\\Leftrightarrow");w("\\Lrarr","\\Leftrightarrow");w("\\Mu","\\mathrm{M}");w("\\natnums","\\mathbb{N}");w("\\Nu","\\mathrm{N}");w("\\Omicron","\\mathrm{O}");w("\\plusmn","\\pm");w("\\rarr","\\rightarrow");w("\\rArr","\\Rightarrow");w("\\Rarr","\\Rightarrow");w("\\real","\\Re");w("\\reals","\\mathbb{R}");w("\\Reals","\\mathbb{R}");w("\\Rho","\\mathrm{P}");w("\\sdot","\\cdot");w("\\sect","\\S");w("\\spades","\\spadesuit");w("\\sub","\\subset");w("\\sube","\\subseteq");w("\\supe","\\supseteq");w("\\Tau","\\mathrm{T}");w("\\thetasym","\\vartheta");w("\\weierp","\\wp");w("\\Zeta","\\mathrm{Z}");w("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");w("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");w("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");w("\\bra","\\mathinner{\\langle{#1}|}");w("\\ket","\\mathinner{|{#1}\\rangle}");w("\\braket","\\mathinner{\\langle{#1}\\rangle}");w("\\Bra","\\left\\langle#1\\right|");w("\\Ket","\\left|#1\\right\\rangle");rg=i=>e=>{var t=e.consumeArg().tokens,r=e.consumeArg().tokens,n=e.consumeArg().tokens,s=e.consumeArg().tokens,a=e.macros.get("|"),o=e.macros.get("\\|");e.macros.beginGroup();var l=c=>f=>{i&&(f.macros.set("|",a),n.length&&f.macros.set("\\|",o));var m=c;if(!c&&n.length){var g=f.future();g.text==="|"&&(f.popToken(),m=!0)}return{tokens:m?n:r,numArgs:0}};e.macros.set("|",l(!1)),n.length&&e.macros.set("\\|",l(!0));var h=e.consumeArg().tokens,d=e.expandTokens([...s,...h,...t]);return e.macros.endGroup(),{tokens:d.reverse(),numArgs:0}};w("\\bra@ket",rg(!1));w("\\bra@set",rg(!0));w("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");w("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");w("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");w("\\angln","{\\angl n}");w("\\blue","\\textcolor{##6495ed}{#1}");w("\\orange","\\textcolor{##ffa500}{#1}");w("\\pink","\\textcolor{##ff00af}{#1}");w("\\red","\\textcolor{##df0030}{#1}");w("\\green","\\textcolor{##28ae7b}{#1}");w("\\gray","\\textcolor{gray}{#1}");w("\\purple","\\textcolor{##9d38bd}{#1}");w("\\blueA","\\textcolor{##ccfaff}{#1}");w("\\blueB","\\textcolor{##80f6ff}{#1}");w("\\blueC","\\textcolor{##63d9ea}{#1}");w("\\blueD","\\textcolor{##11accd}{#1}");w("\\blueE","\\textcolor{##0c7f99}{#1}");w("\\tealA","\\textcolor{##94fff5}{#1}");w("\\tealB","\\textcolor{##26edd5}{#1}");w("\\tealC","\\textcolor{##01d1c1}{#1}");w("\\tealD","\\textcolor{##01a995}{#1}");w("\\tealE","\\textcolor{##208170}{#1}");w("\\greenA","\\textcolor{##b6ffb0}{#1}");w("\\greenB","\\textcolor{##8af281}{#1}");w("\\greenC","\\textcolor{##74cf70}{#1}");w("\\greenD","\\textcolor{##1fab54}{#1}");w("\\greenE","\\textcolor{##0d923f}{#1}");w("\\goldA","\\textcolor{##ffd0a9}{#1}");w("\\goldB","\\textcolor{##ffbb71}{#1}");w("\\goldC","\\textcolor{##ff9c39}{#1}");w("\\goldD","\\textcolor{##e07d10}{#1}");w("\\goldE","\\textcolor{##a75a05}{#1}");w("\\redA","\\textcolor{##fca9a9}{#1}");w("\\redB","\\textcolor{##ff8482}{#1}");w("\\redC","\\textcolor{##f9685d}{#1}");w("\\redD","\\textcolor{##e84d39}{#1}");w("\\redE","\\textcolor{##bc2612}{#1}");w("\\maroonA","\\textcolor{##ffbde0}{#1}");w("\\maroonB","\\textcolor{##ff92c6}{#1}");w("\\maroonC","\\textcolor{##ed5fa6}{#1}");w("\\maroonD","\\textcolor{##ca337c}{#1}");w("\\maroonE","\\textcolor{##9e034e}{#1}");w("\\purpleA","\\textcolor{##ddd7ff}{#1}");w("\\purpleB","\\textcolor{##c6b9fc}{#1}");w("\\purpleC","\\textcolor{##aa87ff}{#1}");w("\\purpleD","\\textcolor{##7854ab}{#1}");w("\\purpleE","\\textcolor{##543b78}{#1}");w("\\mintA","\\textcolor{##f5f9e8}{#1}");w("\\mintB","\\textcolor{##edf2df}{#1}");w("\\mintC","\\textcolor{##e0e5cc}{#1}");w("\\grayA","\\textcolor{##f6f7f7}{#1}");w("\\grayB","\\textcolor{##f0f1f2}{#1}");w("\\grayC","\\textcolor{##e3e5e6}{#1}");w("\\grayD","\\textcolor{##d6d8da}{#1}");w("\\grayE","\\textcolor{##babec2}{#1}");w("\\grayF","\\textcolor{##888d93}{#1}");w("\\grayG","\\textcolor{##626569}{#1}");w("\\grayH","\\textcolor{##3b3e40}{#1}");w("\\grayI","\\textcolor{##21242c}{#1}");w("\\kaBlue","\\textcolor{##314453}{#1}");w("\\kaGreen","\\textcolor{##71B307}{#1}");ng={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},w1=class{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new b1(VA,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new kh(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,r,n;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;t=this.popToken(),{tokens:n,end:r}=this.consumeArg(["]"])}else({tokens:n,start:t,end:r}=this.consumeArg());return this.pushToken(new ui("EOF",r.loc)),this.pushTokens(n),new ui("",Jt.range(t,r))}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var t=[],r=e&&e.length>0;r||this.consumeSpaces();var n=this.future(),s,a=0,o=0;do{if(s=this.popToken(),t.push(s),s.text==="{")++a;else if(s.text==="}"){if(--a,a===-1)throw new G("Extra }",s)}else if(s.text==="EOF")throw new G("Unexpected end of input in a macro argument, expected '"+(e&&r?e[o]:"}")+"'",s);if(e&&r)if((a===0||a===1&&e[o]==="{")&&s.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}while(a!==0||r);return n.text==="{"&&t[t.length-1].text==="}"&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:n,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new G("The length of delimiters doesn't match the number of args!");for(var r=t[0],n=0;nthis.settings.maxExpand)throw new G("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),r=t.text,n=t.noexpand?null:this._getExpansion(r);if(n==null||e&&n.unexpandable){if(e&&n==null&&r[0]==="\\"&&!this.isDefined(r))throw new G("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);var s=n.tokens,a=this.consumeArgs(n.numArgs,n.delimiters);if(n.numArgs){s=s.slice();for(var o=s.length-1;o>=0;--o){var l=s[o];if(l.text==="#"){if(o===0)throw new G("Incomplete placeholder at end of macro body",l);if(l=s[--o],l.text==="#")s.splice(o+1,1);else if(/^[1-9]$/.test(l.text))s.splice(o,2,...a[+l.text-1]);else throw new G("Not a valid argument number",l)}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new ui(e)]):void 0}expandTokens(e){var t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(this.expandOnce(!0)===!1){var n=this.stack.pop();n.treatAsRelax&&(n.noexpand=!1,n.treatAsRelax=!1),t.push(n)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(r=>r.text).join("")}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var r=this.lexer.catcodes[e];if(r!=null&&r!==13)return}var n=typeof t=="function"?t(this):t;if(typeof n=="string"){var s=0;if(n.indexOf("#")!==-1)for(var a=n.replace(/##/g,"");a.indexOf("#"+(s+1))!==-1;)++s;for(var o=new kh(n,this.settings),l=[],h=o.lex();h.text!=="EOF";)l.push(h),h=o.lex();l.reverse();var d={tokens:l,numArgs:s};return d}return n}isDefined(e){return this.macros.has(e)||xn.hasOwnProperty(e)||Oe.math.hasOwnProperty(e)||Oe.text.hasOwnProperty(e)||ng.hasOwnProperty(e)}isExpandable(e){var t=this.macros.get(e);return t!=null?typeof t=="string"||typeof t=="function"||!t.unexpandable:xn.hasOwnProperty(e)&&!xn[e].primitive}},d4=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,vh=Object.freeze({"\u208A":"+","\u208B":"-","\u208C":"=","\u208D":"(","\u208E":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1D62":"i","\u2C7C":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209A":"p","\u1D63":"r","\u209B":"s","\u209C":"t","\u1D64":"u","\u1D65":"v","\u2093":"x","\u1D66":"\u03B2","\u1D67":"\u03B3","\u1D68":"\u03C1","\u1D69":"\u03D5","\u1D6A":"\u03C7","\u207A":"+","\u207B":"-","\u207C":"=","\u207D":"(","\u207E":")","\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1D2C":"A","\u1D2E":"B","\u1D30":"D","\u1D31":"E","\u1D33":"G","\u1D34":"H","\u1D35":"I","\u1D36":"J","\u1D37":"K","\u1D38":"L","\u1D39":"M","\u1D3A":"N","\u1D3C":"O","\u1D3E":"P","\u1D3F":"R","\u1D40":"T","\u1D41":"U","\u2C7D":"V","\u1D42":"W","\u1D43":"a","\u1D47":"b","\u1D9C":"c","\u1D48":"d","\u1D49":"e","\u1DA0":"f","\u1D4D":"g",\u02B0:"h","\u2071":"i",\u02B2:"j","\u1D4F":"k",\u02E1:"l","\u1D50":"m",\u207F:"n","\u1D52":"o","\u1D56":"p",\u02B3:"r",\u02E2:"s","\u1D57":"t","\u1D58":"u","\u1D5B":"v",\u02B7:"w",\u02E3:"x",\u02B8:"y","\u1DBB":"z","\u1D5D":"\u03B2","\u1D5E":"\u03B3","\u1D5F":"\u03B4","\u1D60":"\u03D5","\u1D61":"\u03C7","\u1DBF":"\u03B8"}),h1={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030C":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030A":{text:"\\r",math:"\\mathring"},"\u030B":{text:"\\H"},"\u0327":{text:"\\c"}},c4={\u00E1:"a\u0301",\u00E0:"a\u0300",\u00E4:"a\u0308",\u01DF:"a\u0308\u0304",\u00E3:"a\u0303",\u0101:"a\u0304",\u0103:"a\u0306",\u1EAF:"a\u0306\u0301",\u1EB1:"a\u0306\u0300",\u1EB5:"a\u0306\u0303",\u01CE:"a\u030C",\u00E2:"a\u0302",\u1EA5:"a\u0302\u0301",\u1EA7:"a\u0302\u0300",\u1EAB:"a\u0302\u0303",\u0227:"a\u0307",\u01E1:"a\u0307\u0304",\u00E5:"a\u030A",\u01FB:"a\u030A\u0301",\u1E03:"b\u0307",\u0107:"c\u0301",\u1E09:"c\u0327\u0301",\u010D:"c\u030C",\u0109:"c\u0302",\u010B:"c\u0307",\u00E7:"c\u0327",\u010F:"d\u030C",\u1E0B:"d\u0307",\u1E11:"d\u0327",\u00E9:"e\u0301",\u00E8:"e\u0300",\u00EB:"e\u0308",\u1EBD:"e\u0303",\u0113:"e\u0304",\u1E17:"e\u0304\u0301",\u1E15:"e\u0304\u0300",\u0115:"e\u0306",\u1E1D:"e\u0327\u0306",\u011B:"e\u030C",\u00EA:"e\u0302",\u1EBF:"e\u0302\u0301",\u1EC1:"e\u0302\u0300",\u1EC5:"e\u0302\u0303",\u0117:"e\u0307",\u0229:"e\u0327",\u1E1F:"f\u0307",\u01F5:"g\u0301",\u1E21:"g\u0304",\u011F:"g\u0306",\u01E7:"g\u030C",\u011D:"g\u0302",\u0121:"g\u0307",\u0123:"g\u0327",\u1E27:"h\u0308",\u021F:"h\u030C",\u0125:"h\u0302",\u1E23:"h\u0307",\u1E29:"h\u0327",\u00ED:"i\u0301",\u00EC:"i\u0300",\u00EF:"i\u0308",\u1E2F:"i\u0308\u0301",\u0129:"i\u0303",\u012B:"i\u0304",\u012D:"i\u0306",\u01D0:"i\u030C",\u00EE:"i\u0302",\u01F0:"j\u030C",\u0135:"j\u0302",\u1E31:"k\u0301",\u01E9:"k\u030C",\u0137:"k\u0327",\u013A:"l\u0301",\u013E:"l\u030C",\u013C:"l\u0327",\u1E3F:"m\u0301",\u1E41:"m\u0307",\u0144:"n\u0301",\u01F9:"n\u0300",\u00F1:"n\u0303",\u0148:"n\u030C",\u1E45:"n\u0307",\u0146:"n\u0327",\u00F3:"o\u0301",\u00F2:"o\u0300",\u00F6:"o\u0308",\u022B:"o\u0308\u0304",\u00F5:"o\u0303",\u1E4D:"o\u0303\u0301",\u1E4F:"o\u0303\u0308",\u022D:"o\u0303\u0304",\u014D:"o\u0304",\u1E53:"o\u0304\u0301",\u1E51:"o\u0304\u0300",\u014F:"o\u0306",\u01D2:"o\u030C",\u00F4:"o\u0302",\u1ED1:"o\u0302\u0301",\u1ED3:"o\u0302\u0300",\u1ED7:"o\u0302\u0303",\u022F:"o\u0307",\u0231:"o\u0307\u0304",\u0151:"o\u030B",\u1E55:"p\u0301",\u1E57:"p\u0307",\u0155:"r\u0301",\u0159:"r\u030C",\u1E59:"r\u0307",\u0157:"r\u0327",\u015B:"s\u0301",\u1E65:"s\u0301\u0307",\u0161:"s\u030C",\u1E67:"s\u030C\u0307",\u015D:"s\u0302",\u1E61:"s\u0307",\u015F:"s\u0327",\u1E97:"t\u0308",\u0165:"t\u030C",\u1E6B:"t\u0307",\u0163:"t\u0327",\u00FA:"u\u0301",\u00F9:"u\u0300",\u00FC:"u\u0308",\u01D8:"u\u0308\u0301",\u01DC:"u\u0308\u0300",\u01D6:"u\u0308\u0304",\u01DA:"u\u0308\u030C",\u0169:"u\u0303",\u1E79:"u\u0303\u0301",\u016B:"u\u0304",\u1E7B:"u\u0304\u0308",\u016D:"u\u0306",\u01D4:"u\u030C",\u00FB:"u\u0302",\u016F:"u\u030A",\u0171:"u\u030B",\u1E7D:"v\u0303",\u1E83:"w\u0301",\u1E81:"w\u0300",\u1E85:"w\u0308",\u0175:"w\u0302",\u1E87:"w\u0307",\u1E98:"w\u030A",\u1E8D:"x\u0308",\u1E8B:"x\u0307",\u00FD:"y\u0301",\u1EF3:"y\u0300",\u00FF:"y\u0308",\u1EF9:"y\u0303",\u0233:"y\u0304",\u0177:"y\u0302",\u1E8F:"y\u0307",\u1E99:"y\u030A",\u017A:"z\u0301",\u017E:"z\u030C",\u1E91:"z\u0302",\u017C:"z\u0307",\u00C1:"A\u0301",\u00C0:"A\u0300",\u00C4:"A\u0308",\u01DE:"A\u0308\u0304",\u00C3:"A\u0303",\u0100:"A\u0304",\u0102:"A\u0306",\u1EAE:"A\u0306\u0301",\u1EB0:"A\u0306\u0300",\u1EB4:"A\u0306\u0303",\u01CD:"A\u030C",\u00C2:"A\u0302",\u1EA4:"A\u0302\u0301",\u1EA6:"A\u0302\u0300",\u1EAA:"A\u0302\u0303",\u0226:"A\u0307",\u01E0:"A\u0307\u0304",\u00C5:"A\u030A",\u01FA:"A\u030A\u0301",\u1E02:"B\u0307",\u0106:"C\u0301",\u1E08:"C\u0327\u0301",\u010C:"C\u030C",\u0108:"C\u0302",\u010A:"C\u0307",\u00C7:"C\u0327",\u010E:"D\u030C",\u1E0A:"D\u0307",\u1E10:"D\u0327",\u00C9:"E\u0301",\u00C8:"E\u0300",\u00CB:"E\u0308",\u1EBC:"E\u0303",\u0112:"E\u0304",\u1E16:"E\u0304\u0301",\u1E14:"E\u0304\u0300",\u0114:"E\u0306",\u1E1C:"E\u0327\u0306",\u011A:"E\u030C",\u00CA:"E\u0302",\u1EBE:"E\u0302\u0301",\u1EC0:"E\u0302\u0300",\u1EC4:"E\u0302\u0303",\u0116:"E\u0307",\u0228:"E\u0327",\u1E1E:"F\u0307",\u01F4:"G\u0301",\u1E20:"G\u0304",\u011E:"G\u0306",\u01E6:"G\u030C",\u011C:"G\u0302",\u0120:"G\u0307",\u0122:"G\u0327",\u1E26:"H\u0308",\u021E:"H\u030C",\u0124:"H\u0302",\u1E22:"H\u0307",\u1E28:"H\u0327",\u00CD:"I\u0301",\u00CC:"I\u0300",\u00CF:"I\u0308",\u1E2E:"I\u0308\u0301",\u0128:"I\u0303",\u012A:"I\u0304",\u012C:"I\u0306",\u01CF:"I\u030C",\u00CE:"I\u0302",\u0130:"I\u0307",\u0134:"J\u0302",\u1E30:"K\u0301",\u01E8:"K\u030C",\u0136:"K\u0327",\u0139:"L\u0301",\u013D:"L\u030C",\u013B:"L\u0327",\u1E3E:"M\u0301",\u1E40:"M\u0307",\u0143:"N\u0301",\u01F8:"N\u0300",\u00D1:"N\u0303",\u0147:"N\u030C",\u1E44:"N\u0307",\u0145:"N\u0327",\u00D3:"O\u0301",\u00D2:"O\u0300",\u00D6:"O\u0308",\u022A:"O\u0308\u0304",\u00D5:"O\u0303",\u1E4C:"O\u0303\u0301",\u1E4E:"O\u0303\u0308",\u022C:"O\u0303\u0304",\u014C:"O\u0304",\u1E52:"O\u0304\u0301",\u1E50:"O\u0304\u0300",\u014E:"O\u0306",\u01D1:"O\u030C",\u00D4:"O\u0302",\u1ED0:"O\u0302\u0301",\u1ED2:"O\u0302\u0300",\u1ED6:"O\u0302\u0303",\u022E:"O\u0307",\u0230:"O\u0307\u0304",\u0150:"O\u030B",\u1E54:"P\u0301",\u1E56:"P\u0307",\u0154:"R\u0301",\u0158:"R\u030C",\u1E58:"R\u0307",\u0156:"R\u0327",\u015A:"S\u0301",\u1E64:"S\u0301\u0307",\u0160:"S\u030C",\u1E66:"S\u030C\u0307",\u015C:"S\u0302",\u1E60:"S\u0307",\u015E:"S\u0327",\u0164:"T\u030C",\u1E6A:"T\u0307",\u0162:"T\u0327",\u00DA:"U\u0301",\u00D9:"U\u0300",\u00DC:"U\u0308",\u01D7:"U\u0308\u0301",\u01DB:"U\u0308\u0300",\u01D5:"U\u0308\u0304",\u01D9:"U\u0308\u030C",\u0168:"U\u0303",\u1E78:"U\u0303\u0301",\u016A:"U\u0304",\u1E7A:"U\u0304\u0308",\u016C:"U\u0306",\u01D3:"U\u030C",\u00DB:"U\u0302",\u016E:"U\u030A",\u0170:"U\u030B",\u1E7C:"V\u0303",\u1E82:"W\u0301",\u1E80:"W\u0300",\u1E84:"W\u0308",\u0174:"W\u0302",\u1E86:"W\u0307",\u1E8C:"X\u0308",\u1E8A:"X\u0307",\u00DD:"Y\u0301",\u1EF2:"Y\u0300",\u0178:"Y\u0308",\u1EF8:"Y\u0303",\u0232:"Y\u0304",\u0176:"Y\u0302",\u1E8E:"Y\u0307",\u0179:"Z\u0301",\u017D:"Z\u030C",\u1E90:"Z\u0302",\u017B:"Z\u0307",\u03AC:"\u03B1\u0301",\u1F70:"\u03B1\u0300",\u1FB1:"\u03B1\u0304",\u1FB0:"\u03B1\u0306",\u03AD:"\u03B5\u0301",\u1F72:"\u03B5\u0300",\u03AE:"\u03B7\u0301",\u1F74:"\u03B7\u0300",\u03AF:"\u03B9\u0301",\u1F76:"\u03B9\u0300",\u03CA:"\u03B9\u0308",\u0390:"\u03B9\u0308\u0301",\u1FD2:"\u03B9\u0308\u0300",\u1FD1:"\u03B9\u0304",\u1FD0:"\u03B9\u0306",\u03CC:"\u03BF\u0301",\u1F78:"\u03BF\u0300",\u03CD:"\u03C5\u0301",\u1F7A:"\u03C5\u0300",\u03CB:"\u03C5\u0308",\u03B0:"\u03C5\u0308\u0301",\u1FE2:"\u03C5\u0308\u0300",\u1FE1:"\u03C5\u0304",\u1FE0:"\u03C5\u0306",\u03CE:"\u03C9\u0301",\u1F7C:"\u03C9\u0300",\u038E:"\u03A5\u0301",\u1FEA:"\u03A5\u0300",\u03AB:"\u03A5\u0308",\u1FE9:"\u03A5\u0304",\u1FE8:"\u03A5\u0306",\u038F:"\u03A9\u0301",\u1FFA:"\u03A9\u0300"},Ch=class i{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new w1(e,t,this.mode),this.settings=t,this.leftrightDepth=0}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new G("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new ui("}")),this.gullet.pushTokens(e);var r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){for(var r=[];;){this.mode==="math"&&this.consumeSpaces();var n=this.fetch();if(i.endOfExpression.indexOf(n.text)!==-1||t&&n.text===t||e&&xn[n.text]&&xn[n.text].infix)break;var s=this.parseAtom(t);if(s){if(s.type==="internal")continue}else break;r.push(s)}return this.mode==="text"&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,r,n=0;n=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+t[0]+'" used in math mode',e);var o=Oe[this.mode][t].group,l=Jt.range(e),h;if(BS.hasOwnProperty(o)){var d=o;h={type:"atom",mode:this.mode,family:d,loc:l,text:t}}else h={type:o,mode:this.mode,loc:l,text:t};a=h}else if(t.charCodeAt(0)>=128)this.settings.strict&&(f4(t.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'"'+(" ("+t.charCodeAt(0)+")"),e)),a={type:"textord",mode:"text",loc:Jt.range(e),text:t};else return null;if(this.consume(),s)for(var c=0;c{QA=typeof global=="object"&&global&&global.Object===Object&&global,Bh=QA});var JA,ek,lt,Ki=T(()=>{q1();JA=typeof self=="object"&&self&&self.Object===Object&&self,ek=Bh||JA||Function("return this")(),lt=ek});var tk,_i,nl=T(()=>{Ki();tk=lt.Symbol,_i=tk});function nk(i){var e=ik.call(i,sl),t=i[sl];try{i[sl]=void 0;var r=!0}catch{}var n=rk.call(i);return r&&(e?i[sl]=t:delete i[sl]),n}var lg,ik,rk,sl,hg,dg=T(()=>{nl();lg=Object.prototype,ik=lg.hasOwnProperty,rk=lg.toString,sl=_i?_i.toStringTag:void 0;hg=nk});function ok(i){return ak.call(i)}var sk,ak,cg,ug=T(()=>{sk=Object.prototype,ak=sk.toString;cg=ok});function dk(i){return i==null?i===void 0?hk:lk:fg&&fg in Object(i)?hg(i):cg(i)}var lk,hk,fg,Zi,ga=T(()=>{nl();dg();ug();lk="[object Null]",hk="[object Undefined]",fg=_i?_i.toStringTag:void 0;Zi=dk});function ck(i){return i!=null&&typeof i=="object"}var vt,Or=T(()=>{vt=ck});var uk,Li,xa=T(()=>{uk=Array.isArray,Li=uk});function fk(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var Nt,Br=T(()=>{Nt=fk});function mk(i){return i}var Ph,H1=T(()=>{Ph=mk});function vk(i){if(!Nt(i))return!1;var e=Zi(i);return e==gk||e==xk||e==pk||e==yk}var pk,gk,xk,yk,ya,Fh=T(()=>{ga();Br();pk="[object AsyncFunction]",gk="[object Function]",xk="[object GeneratorFunction]",yk="[object Proxy]";ya=vk});var bk,qh,mg=T(()=>{Ki();bk=lt["__core-js_shared__"],qh=bk});function wk(i){return!!pg&&pg in i}var pg,gg,xg=T(()=>{mg();pg=(function(){var i=/[^.]+$/.exec(qh&&qh.keys&&qh.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();gg=wk});function Nk(i){if(i!=null){try{return Tk.call(i)}catch{}try{return i+""}catch{}}return""}var Mk,Tk,Pr,U1=T(()=>{Mk=Function.prototype,Tk=Mk.toString;Pr=Nk});function Ik(i){if(!Nt(i)||gg(i))return!1;var e=ya(i)?Lk:Sk;return e.test(Pr(i))}var Ek,Sk,Ak,kk,Ck,_k,Lk,yg,vg=T(()=>{Fh();xg();Br();U1();Ek=/[\\^$.*+?()[\]{}|]/g,Sk=/^\[object .+?Constructor\]$/,Ak=Function.prototype,kk=Object.prototype,Ck=Ak.toString,_k=kk.hasOwnProperty,Lk=RegExp("^"+Ck.call(_k).replace(Ek,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");yg=Ik});function zk(i,e){return i?.[e]}var bg,wg=T(()=>{bg=zk});function Rk(i,e){var t=bg(i,e);return yg(t)?t:void 0}var ii,wn=T(()=>{vg();wg();ii=Rk});var Dk,Hh,Mg=T(()=>{wn();Ki();Dk=ii(lt,"WeakMap"),Hh=Dk});var Tg,Ok,Ng,Eg=T(()=>{Br();Tg=Object.create,Ok=(function(){function i(){}return function(e){if(!Nt(e))return{};if(Tg)return Tg(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}})(),Ng=Ok});function Bk(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var Sg,Ag=T(()=>{Sg=Bk});function Pk(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t{Uh=Pk});function Uk(i){var e=0,t=0;return function(){var r=Hk(),n=qk-(r-t);if(t=r,n>0){if(++e>=Fk)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fk,qk,Hk,kg,Cg=T(()=>{Fk=800,qk=16,Hk=Date.now;kg=Uk});function $k(i){return function(){return i}}var _g,Lg=T(()=>{_g=$k});var jk,va,j1=T(()=>{wn();jk=(function(){try{var i=ii(Object,"defineProperty");return i({},"",{}),i}catch{}})(),va=jk});var Gk,Ig,zg=T(()=>{Lg();j1();H1();Gk=va?function(i,e){return va(i,"toString",{configurable:!0,enumerable:!1,value:_g(e),writable:!0})}:Ph,Ig=Gk});var Vk,Rg,Dg=T(()=>{zg();Cg();Vk=kg(Ig),Rg=Vk});function Wk(i,e){for(var t=-1,r=i==null?0:i.length;++t{Og=Wk});function Kk(i,e){var t=typeof i;return e=e??Yk,!!e&&(t=="number"||t!="symbol"&&Xk.test(i))&&i>-1&&i%1==0&&i{Yk=9007199254740991,Xk=/^(?:0|[1-9]\d*)$/;$h=Kk});function Zk(i,e,t){e=="__proto__"&&va?va(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var ba,jh=T(()=>{j1();ba=Zk});function Qk(i,e){return i===e||i!==i&&e!==e}var pr,wa=T(()=>{pr=Qk});function tC(i,e,t){var r=i[e];(!(eC.call(i,e)&&pr(r,t))||t===void 0&&!(e in i))&&ba(i,e,t)}var Jk,eC,Gh,V1=T(()=>{jh();wa();Jk=Object.prototype,eC=Jk.hasOwnProperty;Gh=tC});function iC(i,e,t,r){var n=!t;t||(t={});for(var s=-1,a=e.length;++s{V1();jh();gr=iC});function rC(i,e,t){return e=Pg(e===void 0?i.length-1:e,0),function(){for(var r=arguments,n=-1,s=Pg(r.length-e,0),a=Array(s);++n{Ag();Pg=Math.max;Fg=rC});function nC(i,e){return Rg(Fg(i,e,Ph),i+"")}var Hg,Ug=T(()=>{H1();qg();Dg();Hg=nC});function aC(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=sC}var sC,Vh,W1=T(()=>{sC=9007199254740991;Vh=aC});function oC(i){return i!=null&&Vh(i.length)&&!ya(i)}var Mn,al=T(()=>{Fh();W1();Mn=oC});function lC(i,e,t){if(!Nt(t))return!1;var r=typeof e;return(r=="number"?Mn(t)&&$h(e,t.length):r=="string"&&e in t)?pr(t[e],i):!1}var $g,jg=T(()=>{wa();al();G1();Br();$g=lC});function hC(i){return Hg(function(e,t){var r=-1,n=t.length,s=n>1?t[n-1]:void 0,a=n>2?t[2]:void 0;for(s=i.length>3&&typeof s=="function"?(n--,s):void 0,a&&$g(t[0],t[1],a)&&(s=n<3?void 0:s,n=1),e=Object(e);++r{Ug();jg();Gg=hC});function cC(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||dC;return i===t}var dC,Ta,Wh=T(()=>{dC=Object.prototype;Ta=cC});function uC(i,e){for(var t=-1,r=Array(i);++t{Wg=uC});function mC(i){return vt(i)&&Zi(i)==fC}var fC,Y1,Xg=T(()=>{ga();Or();fC="[object Arguments]";Y1=mC});var Kg,pC,gC,xC,ol,X1=T(()=>{Xg();Or();Kg=Object.prototype,pC=Kg.hasOwnProperty,gC=Kg.propertyIsEnumerable,xC=Y1((function(){return arguments})())?Y1:function(i){return vt(i)&&pC.call(i,"callee")&&!gC.call(i,"callee")},ol=xC});function yC(){return!1}var Zg,Qg=T(()=>{Zg=yC});var t5,Jg,vC,e5,bC,wC,Fr,ll=T(()=>{Ki();Qg();t5=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Jg=t5&&typeof module=="object"&&module&&!module.nodeType&&module,vC=Jg&&Jg.exports===t5,e5=vC?lt.Buffer:void 0,bC=e5?e5.isBuffer:void 0,wC=bC||Zg,Fr=wC});function VC(i){return vt(i)&&Vh(i.length)&&!!He[Zi(i)]}var MC,TC,NC,EC,SC,AC,kC,CC,_C,LC,IC,zC,RC,DC,OC,BC,PC,FC,qC,HC,UC,$C,jC,GC,He,i5,r5=T(()=>{ga();W1();Or();MC="[object Arguments]",TC="[object Array]",NC="[object Boolean]",EC="[object Date]",SC="[object Error]",AC="[object Function]",kC="[object Map]",CC="[object Number]",_C="[object Object]",LC="[object RegExp]",IC="[object Set]",zC="[object String]",RC="[object WeakMap]",DC="[object ArrayBuffer]",OC="[object DataView]",BC="[object Float32Array]",PC="[object Float64Array]",FC="[object Int8Array]",qC="[object Int16Array]",HC="[object Int32Array]",UC="[object Uint8Array]",$C="[object Uint8ClampedArray]",jC="[object Uint16Array]",GC="[object Uint32Array]",He={};He[BC]=He[PC]=He[FC]=He[qC]=He[HC]=He[UC]=He[$C]=He[jC]=He[GC]=!0;He[MC]=He[TC]=He[DC]=He[NC]=He[OC]=He[EC]=He[SC]=He[AC]=He[kC]=He[CC]=He[_C]=He[LC]=He[IC]=He[zC]=He[RC]=!1;i5=VC});function WC(i){return function(e){return i(e)}}var Na,Yh=T(()=>{Na=WC});var n5,hl,YC,K1,XC,qr,Xh=T(()=>{q1();n5=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hl=n5&&typeof module=="object"&&module&&!module.nodeType&&module,YC=hl&&hl.exports===n5,K1=YC&&Bh.process,XC=(function(){try{var i=hl&&hl.require&&hl.require("util").types;return i||K1&&K1.binding&&K1.binding("util")}catch{}})(),qr=XC});var s5,KC,Ea,Kh=T(()=>{r5();Yh();Xh();s5=qr&&qr.isTypedArray,KC=s5?Na(s5):i5,Ea=KC});function JC(i,e){var t=Li(i),r=!t&&ol(i),n=!t&&!r&&Fr(i),s=!t&&!r&&!n&&Ea(i),a=t||r||n||s,o=a?Wg(i.length,String):[],l=o.length;for(var h in i)(e||QC.call(i,h))&&!(a&&(h=="length"||n&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$h(h,l)))&&o.push(h);return o}var ZC,QC,Zh,Z1=T(()=>{Yg();X1();xa();ll();G1();Kh();ZC=Object.prototype,QC=ZC.hasOwnProperty;Zh=JC});function e_(i,e){return function(t){return i(e(t))}}var Qh,Q1=T(()=>{Qh=e_});var t_,a5,o5=T(()=>{Q1();t_=Qh(Object.keys,Object),a5=t_});function n_(i){if(!Ta(i))return a5(i);var e=[];for(var t in Object(i))r_.call(i,t)&&t!="constructor"&&e.push(t);return e}var i_,r_,l5,h5=T(()=>{Wh();o5();i_=Object.prototype,r_=i_.hasOwnProperty;l5=n_});function s_(i){return Mn(i)?Zh(i):l5(i)}var Sa,Jh=T(()=>{Z1();h5();al();Sa=s_});function a_(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var d5,c5=T(()=>{d5=a_});function h_(i){if(!Nt(i))return d5(i);var e=Ta(i),t=[];for(var r in i)r=="constructor"&&(e||!l_.call(i,r))||t.push(r);return t}var o_,l_,u5,f5=T(()=>{Br();Wh();c5();o_=Object.prototype,l_=o_.hasOwnProperty;u5=h_});function d_(i){return Mn(i)?Zh(i,!0):u5(i)}var xr,Aa=T(()=>{Z1();f5();al();xr=d_});var c_,Hr,dl=T(()=>{wn();c_=ii(Object,"create"),Hr=c_});function u_(){this.__data__=Hr?Hr(null):{},this.size=0}var m5,p5=T(()=>{dl();m5=u_});function f_(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var g5,x5=T(()=>{g5=f_});function x_(i){var e=this.__data__;if(Hr){var t=e[i];return t===m_?void 0:t}return g_.call(e,i)?e[i]:void 0}var m_,p_,g_,y5,v5=T(()=>{dl();m_="__lodash_hash_undefined__",p_=Object.prototype,g_=p_.hasOwnProperty;y5=x_});function b_(i){var e=this.__data__;return Hr?e[i]!==void 0:v_.call(e,i)}var y_,v_,b5,w5=T(()=>{dl();y_=Object.prototype,v_=y_.hasOwnProperty;b5=b_});function M_(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=Hr&&e===void 0?w_:e,this}var w_,M5,T5=T(()=>{dl();w_="__lodash_hash_undefined__";M5=M_});function ka(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e{p5();x5();v5();w5();T5();ka.prototype.clear=m5;ka.prototype.delete=g5;ka.prototype.get=y5;ka.prototype.has=b5;ka.prototype.set=M5;J1=ka});function T_(){this.__data__=[],this.size=0}var E5,S5=T(()=>{E5=T_});function N_(i,e){for(var t=i.length;t--;)if(pr(i[t][0],e))return t;return-1}var Tn,cl=T(()=>{wa();Tn=N_});function A_(i){var e=this.__data__,t=Tn(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():S_.call(e,t,1),--this.size,!0}var E_,S_,A5,k5=T(()=>{cl();E_=Array.prototype,S_=E_.splice;A5=A_});function k_(i){var e=this.__data__,t=Tn(e,i);return t<0?void 0:e[t][1]}var C5,_5=T(()=>{cl();C5=k_});function C_(i){return Tn(this.__data__,i)>-1}var L5,I5=T(()=>{cl();L5=C_});function __(i,e){var t=this.__data__,r=Tn(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var z5,R5=T(()=>{cl();z5=__});function Ca(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e{S5();k5();_5();I5();R5();Ca.prototype.clear=E5;Ca.prototype.delete=A5;Ca.prototype.get=C5;Ca.prototype.has=L5;Ca.prototype.set=z5;Nn=Ca});var L_,En,ed=T(()=>{wn();Ki();L_=ii(lt,"Map"),En=L_});function I_(){this.size=0,this.__data__={hash:new J1,map:new(En||Nn),string:new J1}}var D5,O5=T(()=>{N5();ul();ed();D5=I_});function z_(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var B5,P5=T(()=>{B5=z_});function R_(i,e){var t=i.__data__;return B5(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Sn,fl=T(()=>{P5();Sn=R_});function D_(i){var e=Sn(this,i).delete(i);return this.size-=e?1:0,e}var F5,q5=T(()=>{fl();F5=D_});function O_(i){return Sn(this,i).get(i)}var H5,U5=T(()=>{fl();H5=O_});function B_(i){return Sn(this,i).has(i)}var $5,j5=T(()=>{fl();$5=B_});function P_(i,e){var t=Sn(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var G5,V5=T(()=>{fl();G5=P_});function _a(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e{O5();q5();U5();j5();V5();_a.prototype.clear=D5;_a.prototype.delete=F5;_a.prototype.get=H5;_a.prototype.has=$5;_a.prototype.set=G5;td=_a});function F_(i,e){for(var t=-1,r=e.length,n=i.length;++t{id=F_});var q_,La,rd=T(()=>{Q1();q_=Qh(Object.getPrototypeOf,Object),La=q_});function V_(i){if(!vt(i)||Zi(i)!=H_)return!1;var e=La(i);if(e===null)return!0;var t=j_.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&W5.call(t)==G_}var H_,U_,$_,W5,j_,G_,Y5,X5=T(()=>{ga();rd();Or();H_="[object Object]",U_=Function.prototype,$_=Object.prototype,W5=U_.toString,j_=$_.hasOwnProperty,G_=W5.call(Object);Y5=V_});function W_(){this.__data__=new Nn,this.size=0}var K5,Z5=T(()=>{ul();K5=W_});function Y_(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var Q5,J5=T(()=>{Q5=Y_});function X_(i){return this.__data__.get(i)}var e7,t7=T(()=>{e7=X_});function K_(i){return this.__data__.has(i)}var i7,r7=T(()=>{i7=K_});function Q_(i,e){var t=this.__data__;if(t instanceof Nn){var r=t.__data__;if(!En||r.length{ul();ed();ef();Z_=200;n7=Q_});function Ia(i){var e=this.__data__=new Nn(i);this.size=e.size}var An,nd=T(()=>{ul();Z5();J5();t7();r7();s7();Ia.prototype.clear=K5;Ia.prototype.delete=Q5;Ia.prototype.get=e7;Ia.prototype.has=i7;Ia.prototype.set=n7;An=Ia});function J_(i,e){return i&&gr(e,Sa(e),i)}var a7,o7=T(()=>{Ma();Jh();a7=J_});function eL(i,e){return i&&gr(e,xr(e),i)}var l7,h7=T(()=>{Ma();Aa();l7=eL});function iL(i,e){if(e)return i.slice();var t=i.length,r=u7?u7(t):new i.constructor(t);return i.copy(r),r}var f7,d7,tL,c7,u7,sd,rf=T(()=>{Ki();f7=typeof exports=="object"&&exports&&!exports.nodeType&&exports,d7=f7&&typeof module=="object"&&module&&!module.nodeType&&module,tL=d7&&d7.exports===f7,c7=tL?lt.Buffer:void 0,u7=c7?c7.allocUnsafe:void 0;sd=iL});function rL(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t{m7=rL});function nL(){return[]}var ad,nf=T(()=>{ad=nL});var sL,aL,g7,oL,za,od=T(()=>{p7();nf();sL=Object.prototype,aL=sL.propertyIsEnumerable,g7=Object.getOwnPropertySymbols,oL=g7?function(i){return i==null?[]:(i=Object(i),m7(g7(i),function(e){return aL.call(i,e)}))}:ad,za=oL});function lL(i,e){return gr(i,za(i),e)}var x7,y7=T(()=>{Ma();od();x7=lL});var hL,dL,ld,sf=T(()=>{tf();rd();od();nf();hL=Object.getOwnPropertySymbols,dL=hL?function(i){for(var e=[];i;)id(e,za(i)),i=La(i);return e}:ad,ld=dL});function cL(i,e){return gr(i,ld(i),e)}var v7,b7=T(()=>{Ma();sf();v7=cL});function uL(i,e,t){var r=e(i);return Li(i)?r:id(r,t(i))}var hd,af=T(()=>{tf();xa();hd=uL});function fL(i){return hd(i,Sa,za)}var ml,of=T(()=>{af();od();Jh();ml=fL});function mL(i){return hd(i,xr,ld)}var w7,M7=T(()=>{af();sf();Aa();w7=mL});var pL,dd,T7=T(()=>{wn();Ki();pL=ii(lt,"DataView"),dd=pL});var gL,cd,N7=T(()=>{wn();Ki();gL=ii(lt,"Promise"),cd=gL});var xL,ud,E7=T(()=>{wn();Ki();xL=ii(lt,"Set"),ud=xL});var S7,yL,A7,k7,C7,_7,vL,bL,wL,ML,TL,xs,Ur,pl=T(()=>{T7();ed();N7();E7();Mg();ga();U1();S7="[object Map]",yL="[object Object]",A7="[object Promise]",k7="[object Set]",C7="[object WeakMap]",_7="[object DataView]",vL=Pr(dd),bL=Pr(En),wL=Pr(cd),ML=Pr(ud),TL=Pr(Hh),xs=Zi;(dd&&xs(new dd(new ArrayBuffer(1)))!=_7||En&&xs(new En)!=S7||cd&&xs(cd.resolve())!=A7||ud&&xs(new ud)!=k7||Hh&&xs(new Hh)!=C7)&&(xs=function(i){var e=Zi(i),t=e==yL?i.constructor:void 0,r=t?Pr(t):"";if(r)switch(r){case vL:return _7;case bL:return S7;case wL:return A7;case ML:return k7;case TL:return C7}return e});Ur=xs});function SL(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&EL.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var NL,EL,L7,I7=T(()=>{NL=Object.prototype,EL=NL.hasOwnProperty;L7=SL});var AL,Ra,lf=T(()=>{Ki();AL=lt.Uint8Array,Ra=AL});function kL(i){var e=new i.constructor(i.byteLength);return new Ra(e).set(new Ra(i)),e}var Da,fd=T(()=>{lf();Da=kL});function CL(i,e){var t=e?Da(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var z7,R7=T(()=>{fd();z7=CL});function LL(i){var e=new i.constructor(i.source,_L.exec(i));return e.lastIndex=i.lastIndex,e}var _L,D7,O7=T(()=>{_L=/\w*$/;D7=LL});function IL(i){return P7?Object(P7.call(i)):{}}var B7,P7,F7,q7=T(()=>{nl();B7=_i?_i.prototype:void 0,P7=B7?B7.valueOf:void 0;F7=IL});function zL(i,e){var t=e?Da(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var md,hf=T(()=>{fd();md=zL});function JL(i,e,t){var r=i.constructor;switch(e){case UL:return Da(i);case RL:case DL:return new r(+i);case $L:return z7(i,t);case jL:case GL:case VL:case WL:case YL:case XL:case KL:case ZL:case QL:return md(i,t);case OL:return new r;case BL:case qL:return new r(i);case PL:return D7(i);case FL:return new r;case HL:return F7(i)}}var RL,DL,OL,BL,PL,FL,qL,HL,UL,$L,jL,GL,VL,WL,YL,XL,KL,ZL,QL,H7,U7=T(()=>{fd();R7();O7();q7();hf();RL="[object Boolean]",DL="[object Date]",OL="[object Map]",BL="[object Number]",PL="[object RegExp]",FL="[object Set]",qL="[object String]",HL="[object Symbol]",UL="[object ArrayBuffer]",$L="[object DataView]",jL="[object Float32Array]",GL="[object Float64Array]",VL="[object Int8Array]",WL="[object Int16Array]",YL="[object Int32Array]",XL="[object Uint8Array]",KL="[object Uint8ClampedArray]",ZL="[object Uint16Array]",QL="[object Uint32Array]";H7=JL});function eI(i){return typeof i.constructor=="function"&&!Ta(i)?Ng(La(i)):{}}var pd,df=T(()=>{Eg();rd();Wh();pd=eI});function iI(i){return vt(i)&&Ur(i)==tI}var tI,$7,j7=T(()=>{pl();Or();tI="[object Map]";$7=iI});var G7,rI,V7,W7=T(()=>{j7();Yh();Xh();G7=qr&&qr.isMap,rI=G7?Na(G7):$7,V7=rI});function sI(i){return vt(i)&&Ur(i)==nI}var nI,Y7,X7=T(()=>{pl();Or();nI="[object Set]";Y7=sI});var K7,aI,Z7,Q7=T(()=>{X7();Yh();Xh();K7=qr&&qr.isSet,aI=K7?Na(K7):Y7,Z7=aI});function gd(i,e,t,r,n,s){var a,o=e&oI,l=e&lI,h=e&hI;if(t&&(a=n?t(i,r,n,s):t(i)),a!==void 0)return a;if(!Nt(i))return i;var d=Li(i);if(d){if(a=L7(i),!o)return Uh(i,a)}else{var c=Ur(i),f=c==e8||c==mI;if(Fr(i))return sd(i,o);if(c==t8||c==J7||f&&!n){if(a=l||f?{}:pd(i),!o)return l?v7(i,l7(a,i)):x7(i,a7(a,i))}else{if(!Be[c])return n?i:{};a=H7(i,c,o)}}s||(s=new An);var m=s.get(i);if(m)return m;s.set(i,a),Z7(i)?i.forEach(function(y){a.add(gd(y,e,t,y,i,s))}):V7(i)&&i.forEach(function(y,b){a.set(b,gd(y,e,t,b,i,s))});var g=h?l?w7:ml:l?xr:Sa,x=d?void 0:g(i);return Og(x||i,function(y,b){x&&(b=y,y=i[b]),Gh(a,b,gd(y,e,t,b,i,s))}),a}var oI,lI,hI,J7,dI,cI,uI,fI,e8,mI,pI,gI,t8,xI,yI,vI,bI,wI,MI,TI,NI,EI,SI,AI,kI,CI,_I,LI,II,Be,i8,r8=T(()=>{nd();Bg();V1();o7();h7();rf();$1();y7();b7();of();M7();pl();I7();U7();df();xa();ll();W7();Br();Q7();Jh();Aa();oI=1,lI=2,hI=4,J7="[object Arguments]",dI="[object Array]",cI="[object Boolean]",uI="[object Date]",fI="[object Error]",e8="[object Function]",mI="[object GeneratorFunction]",pI="[object Map]",gI="[object Number]",t8="[object Object]",xI="[object RegExp]",yI="[object Set]",vI="[object String]",bI="[object Symbol]",wI="[object WeakMap]",MI="[object ArrayBuffer]",TI="[object DataView]",NI="[object Float32Array]",EI="[object Float64Array]",SI="[object Int8Array]",AI="[object Int16Array]",kI="[object Int32Array]",CI="[object Uint8Array]",_I="[object Uint8ClampedArray]",LI="[object Uint16Array]",II="[object Uint32Array]",Be={};Be[J7]=Be[dI]=Be[MI]=Be[TI]=Be[cI]=Be[uI]=Be[NI]=Be[EI]=Be[SI]=Be[AI]=Be[kI]=Be[pI]=Be[gI]=Be[t8]=Be[xI]=Be[yI]=Be[vI]=Be[bI]=Be[CI]=Be[_I]=Be[LI]=Be[II]=!0;Be[fI]=Be[e8]=Be[wI]=!1;i8=gd});function DI(i){return i8(i,zI|RI)}var zI,RI,yr,n8=T(()=>{r8();zI=1,RI=4;yr=DI});function BI(i){return this.__data__.set(i,OI),this}var OI,s8,a8=T(()=>{OI="__lodash_hash_undefined__";s8=BI});function PI(i){return this.__data__.has(i)}var o8,l8=T(()=>{o8=PI});function xd(i){var e=-1,t=i==null?0:i.length;for(this.__data__=new td;++e{ef();a8();l8();xd.prototype.add=xd.prototype.push=s8;xd.prototype.has=o8;h8=xd});function FI(i,e){for(var t=-1,r=i==null?0:i.length;++t{c8=FI});function qI(i,e){return i.has(e)}var f8,m8=T(()=>{f8=qI});function $I(i,e,t,r,n,s){var a=t&HI,o=i.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var h=s.get(i),d=s.get(e);if(h&&d)return h==e&&d==i;var c=-1,f=!0,m=t&UI?new h8:void 0;for(s.set(i,e),s.set(e,i);++c{d8();u8();m8();HI=1,UI=2;yd=$I});function jI(i){var e=-1,t=Array(i.size);return i.forEach(function(r,n){t[++e]=[n,r]}),t}var p8,g8=T(()=>{p8=jI});function GI(i){var e=-1,t=Array(i.size);return i.forEach(function(r){t[++e]=r}),t}var x8,y8=T(()=>{x8=GI});function sz(i,e,t,r,n,s,a){switch(t){case nz:if(i.byteLength!=e.byteLength||i.byteOffset!=e.byteOffset)return!1;i=i.buffer,e=e.buffer;case rz:return!(i.byteLength!=e.byteLength||!s(new Ra(i),new Ra(e)));case YI:case XI:case QI:return pr(+i,+e);case KI:return i.name==e.name&&i.message==e.message;case JI:case tz:return i==e+"";case ZI:var o=p8;case ez:var l=r&VI;if(o||(o=x8),i.size!=e.size&&!l)return!1;var h=a.get(i);if(h)return h==e;r|=WI,a.set(i,e);var d=yd(o(i),o(e),r,n,s,a);return a.delete(i),d;case iz:if(uf)return uf.call(i)==uf.call(e)}return!1}var VI,WI,YI,XI,KI,ZI,QI,JI,ez,tz,iz,rz,nz,v8,uf,b8,w8=T(()=>{nl();lf();wa();cf();g8();y8();VI=1,WI=2,YI="[object Boolean]",XI="[object Date]",KI="[object Error]",ZI="[object Map]",QI="[object Number]",JI="[object RegExp]",ez="[object Set]",tz="[object String]",iz="[object Symbol]",rz="[object ArrayBuffer]",nz="[object DataView]",v8=_i?_i.prototype:void 0,uf=v8?v8.valueOf:void 0;b8=sz});function hz(i,e,t,r,n,s){var a=t&az,o=ml(i),l=o.length,h=ml(e),d=h.length;if(l!=d&&!a)return!1;for(var c=l;c--;){var f=o[c];if(!(a?f in e:lz.call(e,f)))return!1}var m=s.get(i),g=s.get(e);if(m&&g)return m==e&&g==i;var x=!0;s.set(i,e),s.set(e,i);for(var y=a;++c{of();az=1,oz=Object.prototype,lz=oz.hasOwnProperty;M8=hz});function uz(i,e,t,r,n,s){var a=Li(i),o=Li(e),l=a?E8:Ur(i),h=o?E8:Ur(e);l=l==N8?vd:l,h=h==N8?vd:h;var d=l==vd,c=h==vd,f=l==h;if(f&&Fr(i)){if(!Fr(e))return!1;a=!0,d=!1}if(f&&!d)return s||(s=new An),a||Ea(i)?yd(i,e,t,r,n,s):b8(i,e,l,t,r,n,s);if(!(t&dz)){var m=d&&S8.call(i,"__wrapped__"),g=c&&S8.call(e,"__wrapped__");if(m||g){var x=m?i.value():i,y=g?e.value():e;return s||(s=new An),n(x,y,t,r,s)}}return f?(s||(s=new An),M8(i,e,t,r,n,s)):!1}var dz,N8,E8,vd,cz,S8,A8,k8=T(()=>{nd();cf();w8();T8();pl();xa();ll();Kh();dz=1,N8="[object Arguments]",E8="[object Array]",vd="[object Object]",cz=Object.prototype,S8=cz.hasOwnProperty;A8=uz});function C8(i,e,t,r,n){return i===e?!0:i==null||e==null||!vt(i)&&!vt(e)?i!==i&&e!==e:A8(i,e,t,r,C8,n)}var _8,L8=T(()=>{k8();Or();_8=C8});function fz(i){return function(e,t,r){for(var n=-1,s=Object(e),a=r(e),o=a.length;o--;){var l=a[i?o:++n];if(t(s[l],l,s)===!1)break}return e}}var I8,z8=T(()=>{I8=fz});var mz,R8,D8=T(()=>{z8();mz=I8(),R8=mz});function pz(i,e,t){(t!==void 0&&!pr(i[e],t)||t===void 0&&!(e in i))&&ba(i,e,t)}var gl,ff=T(()=>{jh();wa();gl=pz});function gz(i){return vt(i)&&Mn(i)}var O8,B8=T(()=>{al();Or();O8=gz});function xz(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var xl,mf=T(()=>{xl=xz});function yz(i){return gr(i,xr(i))}var P8,F8=T(()=>{Ma();Aa();P8=yz});function vz(i,e,t,r,n,s,a){var o=xl(i,t),l=xl(e,t),h=a.get(l);if(h){gl(i,t,h);return}var d=s?s(o,l,t+"",i,e,a):void 0,c=d===void 0;if(c){var f=Li(l),m=!f&&Fr(l),g=!f&&!m&&Ea(l);d=l,f||m||g?Li(o)?d=o:O8(o)?d=Uh(o):m?(c=!1,d=sd(l,!0)):g?(c=!1,d=md(l,!0)):d=[]:Y5(l)||ol(l)?(d=o,ol(o)?d=P8(o):(!Nt(o)||ya(o))&&(d=pd(l))):c=!1}c&&(a.set(l,d),n(d,l,r,s,a),a.delete(l)),gl(i,t,d)}var q8,H8=T(()=>{ff();rf();hf();$1();df();X1();xa();B8();ll();Fh();Br();X5();Kh();mf();F8();q8=vz});function U8(i,e,t,r,n){i!==e&&R8(e,function(s,a){if(n||(n=new An),Nt(s))q8(i,e,a,t,U8,r,n);else{var o=r?r(xl(i,a),s,a+"",i,e,n):void 0;o===void 0&&(o=s),gl(i,a,o)}},xr)}var $8,j8=T(()=>{nd();ff();D8();H8();Br();Aa();mf();$8=U8});function bz(i,e){return _8(i,e)}var ys,G8=T(()=>{L8();ys=bz});var wz,ri,V8=T(()=>{j8();Vg();wz=Gg(function(i,e,t){$8(i,e,t)}),ri=wz});var kn=T(()=>{n8();G8();V8();});var bl={};tt(bl,{Attributor:()=>qt,AttributorStore:()=>yl,BlockBlot:()=>vs,ClassAttributor:()=>ht,ContainerBlot:()=>qa,EmbedBlot:()=>Ke,InlineBlot:()=>bd,LeafBlot:()=>dt,ParentBlot:()=>ni,Registry:()=>Ln,Scope:()=>X,ScrollBlot:()=>vl,StyleAttributor:()=>si,TextBlot:()=>Ha});function W8(i,e){return(i.getAttribute("class")||"").split(/\s+/).filter(t=>t.indexOf(`${e}-`)===0)}function pf(i){let e=i.split("-"),t=e.slice(1).map(r=>r[0].toUpperCase()+r.slice(1)).join("");return e[0]+t}function Y8(i,e){let t=e.find(i);if(t)return t;try{return e.create(i)}catch{let r=e.create(X.INLINE);return Array.from(i.childNodes).forEach(n=>{r.domNode.appendChild(n)}),i.parentNode&&i.parentNode.replaceChild(r.domNode,i),r.attach(),r}}function Nz(i,e){if(Object.keys(i).length!==Object.keys(e).length)return!1;for(let t in i)if(i[t]!==e[t])return!1;return!0}var X,qt,_n,X8,Ln,xf,ht,yf,si,vf,yl,K8,Z8,Q8,Mz,dt,bf,J8,Tz,ni,Oa,Ez,bd,Pa,Sz,vs,Mf,Az,qa,Tf,Ke,kz,Cz,Fa,_z,vl,Nf,Lz,Ha,Re=T(()=>{X=(i=>(i[i.TYPE=3]="TYPE",i[i.LEVEL=12]="LEVEL",i[i.ATTRIBUTE=13]="ATTRIBUTE",i[i.BLOT=14]="BLOT",i[i.INLINE=7]="INLINE",i[i.BLOCK=11]="BLOCK",i[i.BLOCK_BLOT=10]="BLOCK_BLOT",i[i.INLINE_BLOT=6]="INLINE_BLOT",i[i.BLOCK_ATTRIBUTE=9]="BLOCK_ATTRIBUTE",i[i.INLINE_ATTRIBUTE=5]="INLINE_ATTRIBUTE",i[i.ANY=15]="ANY",i))(X||{}),qt=class{constructor(e,t,r={}){this.attrName=e,this.keyName=t;let n=X.TYPE&X.ATTRIBUTE;this.scope=r.scope!=null?r.scope&X.LEVEL|n:X.ATTRIBUTE,r.whitelist!=null&&(this.whitelist=r.whitelist)}static keys(e){return Array.from(e.attributes).map(t=>t.name)}add(e,t){return this.canAdd(e,t)?(e.setAttribute(this.keyName,t),!0):!1}canAdd(e,t){return this.whitelist==null?!0:typeof t=="string"?this.whitelist.indexOf(t.replace(/["']/g,""))>-1:this.whitelist.indexOf(t)>-1}remove(e){e.removeAttribute(this.keyName)}value(e){let t=e.getAttribute(this.keyName);return this.canAdd(e,t)&&t?t:""}},_n=class extends Error{constructor(e){e="[Parchment] "+e,super(e),this.message=e,this.name=this.constructor.name}},X8=class gf{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(e,t=!1){if(e==null)return null;if(this.blots.has(e))return this.blots.get(e)||null;if(t){let r=null;try{r=e.parentNode}catch{return null}return this.find(r,t)}return null}create(e,t,r){let n=this.query(t);if(n==null)throw new _n(`Unable to create ${t} blot`);let s=n,a=t instanceof Node||t.nodeType===Node.TEXT_NODE?t:s.create(r),o=new s(e,a,r);return gf.blots.set(o.domNode,o),o}find(e,t=!1){return gf.find(e,t)}query(e,t=X.ANY){let r;return typeof e=="string"?r=this.types[e]||this.attributes[e]:e instanceof Text||e.nodeType===Node.TEXT_NODE?r=this.types.text:typeof e=="number"?e&X.LEVEL&X.BLOCK?r=this.types.block:e&X.LEVEL&X.INLINE&&(r=this.types.inline):e instanceof Element&&((e.getAttribute("class")||"").split(/\s+/).some(n=>(r=this.classes[n],!!r)),r=r||this.tags[e.tagName]),r==null?null:"scope"in r&&t&X.LEVEL&r.scope&&t&X.TYPE&r.scope?r:null}register(...e){return e.map(t=>{let r="blotName"in t,n="attrName"in t;if(!r&&!n)throw new _n("Invalid definition");if(r&&t.blotName==="abstract")throw new _n("Cannot register abstract class");let s=r?t.blotName:n?t.attrName:void 0;return this.types[s]=t,n?typeof t.keyName=="string"&&(this.attributes[t.keyName]=t):r&&(t.className&&(this.classes[t.className]=t),t.tagName&&(Array.isArray(t.tagName)?t.tagName=t.tagName.map(a=>a.toUpperCase()):t.tagName=t.tagName.toUpperCase(),(Array.isArray(t.tagName)?t.tagName:[t.tagName]).forEach(a=>{(this.tags[a]==null||t.className==null)&&(this.tags[a]=t)}))),t})}};X8.blots=new WeakMap;Ln=X8;xf=class extends qt{static keys(e){return(e.getAttribute("class")||"").split(/\s+/).map(t=>t.split("-").slice(0,-1).join("-"))}add(e,t){return this.canAdd(e,t)?(this.remove(e),e.classList.add(`${this.keyName}-${t}`),!0):!1}remove(e){W8(e,this.keyName).forEach(t=>{e.classList.remove(t)}),e.classList.length===0&&e.removeAttribute("class")}value(e){let t=(W8(e,this.keyName)[0]||"").slice(this.keyName.length+1);return this.canAdd(e,t)?t:""}},ht=xf;yf=class extends qt{static keys(e){return(e.getAttribute("style")||"").split(";").map(t=>t.split(":")[0].trim())}add(e,t){return this.canAdd(e,t)?(e.style[pf(this.keyName)]=t,!0):!1}remove(e){e.style[pf(this.keyName)]="",e.getAttribute("style")||e.removeAttribute("style")}value(e){let t=e.style[pf(this.keyName)];return this.canAdd(e,t)?t:""}},si=yf,vf=class{constructor(e){this.attributes={},this.domNode=e,this.build()}attribute(e,t){t?e.add(this.domNode,t)&&(e.value(this.domNode)!=null?this.attributes[e.attrName]=e:delete this.attributes[e.attrName]):(e.remove(this.domNode),delete this.attributes[e.attrName])}build(){this.attributes={};let e=Ln.find(this.domNode);if(e==null)return;let t=qt.keys(this.domNode),r=ht.keys(this.domNode),n=si.keys(this.domNode);t.concat(r).concat(n).forEach(s=>{let a=e.scroll.query(s,X.ATTRIBUTE);a instanceof qt&&(this.attributes[a.attrName]=a)})}copy(e){Object.keys(this.attributes).forEach(t=>{let r=this.attributes[t].value(this.domNode);e.format(t,r)})}move(e){this.copy(e),Object.keys(this.attributes).forEach(t=>{this.attributes[t].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((e,t)=>(e[t]=this.attributes[t].value(this.domNode),e),{})}},yl=vf,K8=class{constructor(e,t){this.scroll=e,this.domNode=t,Ln.blots.set(t,this),this.prev=null,this.next=null}static create(e){if(this.tagName==null)throw new _n("Blot definition missing tagName");let t,r;return Array.isArray(this.tagName)?(typeof e=="string"?(r=e.toUpperCase(),parseInt(r,10).toString()===r&&(r=parseInt(r,10))):typeof e=="number"&&(r=e),typeof r=="number"?t=document.createElement(this.tagName[r-1]):r&&this.tagName.indexOf(r)>-1?t=document.createElement(r):t=document.createElement(this.tagName[0])):t=document.createElement(this.tagName),this.className&&t.classList.add(this.className),t}get statics(){return this.constructor}attach(){}clone(){let e=this.domNode.cloneNode(!1);return this.scroll.create(e)}detach(){this.parent!=null&&this.parent.removeChild(this),Ln.blots.delete(this.domNode)}deleteAt(e,t){this.isolate(e,t).remove()}formatAt(e,t,r,n){let s=this.isolate(e,t);if(this.scroll.query(r,X.BLOT)!=null&&n)s.wrap(r,n);else if(this.scroll.query(r,X.ATTRIBUTE)!=null){let a=this.scroll.create(this.statics.scope);s.wrap(a),a.format(r,n)}}insertAt(e,t,r){let n=r==null?this.scroll.create("text",t):this.scroll.create(t,r),s=this.split(e);this.parent.insertBefore(n,s||void 0)}isolate(e,t){let r=this.split(e);if(r==null)throw new Error("Attempt to isolate at end");return r.split(t),r}length(){return 1}offset(e=this.parent){return this.parent==null||this===e?0:this.parent.children.offset(this)+this.parent.offset(e)}optimize(e){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(e,t){let r=typeof e=="string"?this.scroll.create(e,t):e;return this.parent!=null&&(this.parent.insertBefore(r,this.next||void 0),this.remove()),r}split(e,t){return e===0?this:this.next}update(e,t){}wrap(e,t){let r=typeof e=="string"?this.scroll.create(e,t):e;if(this.parent!=null&&this.parent.insertBefore(r,this.next||void 0),typeof r.appendChild!="function")throw new _n(`Cannot wrap ${e}`);return r.appendChild(this),r}};K8.blotName="abstract";Z8=K8,Q8=class extends Z8{static value(e){return!0}index(e,t){return this.domNode===e||this.domNode.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(t,1):-1}position(e,t){let r=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return e>0&&(r+=1),[this.parent.domNode,r]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};Q8.scope=X.INLINE_BLOT;Mz=Q8,dt=Mz,bf=class{constructor(){this.head=null,this.tail=null,this.length=0}append(...e){if(this.insertBefore(e[0],null),e.length>1){let t=e.slice(1);this.append(...t)}}at(e){let t=this.iterator(),r=t();for(;r&&e>0;)e-=1,r=t();return r}contains(e){let t=this.iterator(),r=t();for(;r;){if(r===e)return!0;r=t()}return!1}indexOf(e){let t=this.iterator(),r=t(),n=0;for(;r;){if(r===e)return n;n+=1,r=t()}return-1}insertBefore(e,t){e!=null&&(this.remove(e),e.next=t,t!=null?(e.prev=t.prev,t.prev!=null&&(t.prev.next=e),t.prev=e,t===this.head&&(this.head=e)):this.tail!=null?(this.tail.next=e,e.prev=this.tail,this.tail=e):(e.prev=null,this.head=this.tail=e),this.length+=1)}offset(e){let t=0,r=this.head;for(;r!=null;){if(r===e)return t;t+=r.length(),r=r.next}return-1}remove(e){this.contains(e)&&(e.prev!=null&&(e.prev.next=e.next),e.next!=null&&(e.next.prev=e.prev),e===this.head&&(this.head=e.next),e===this.tail&&(this.tail=e.prev),this.length-=1)}iterator(e=this.head){return()=>{let t=e;return e!=null&&(e=e.next),t}}find(e,t=!1){let r=this.iterator(),n=r();for(;n;){let s=n.length();if(ea?r(l,e-a,Math.min(t,a+h-e)):r(l,0,Math.min(h,e+t-a)),a+=h,l=o()}}map(e){return this.reduce((t,r)=>(t.push(e(r)),t),[])}reduce(e,t){let r=this.iterator(),n=r();for(;n;)t=e(t,n),n=r();return t}};J8=class Cn extends Z8{constructor(e,t){super(e,t),this.uiNode=null,this.build()}appendChild(e){this.insertBefore(e)}attach(){super.attach(),this.children.forEach(e=>{e.attach()})}attachUI(e){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=e,Cn.uiClass&&this.uiNode.classList.add(Cn.uiClass),this.uiNode.setAttribute("contenteditable","false"),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new bf,Array.from(this.domNode.childNodes).filter(e=>e!==this.uiNode).reverse().forEach(e=>{try{let t=Y8(e,this.scroll);this.insertBefore(t,this.children.head||void 0)}catch(t){if(t instanceof _n)return;throw t}})}deleteAt(e,t){if(e===0&&t===this.length())return this.remove();this.children.forEachAt(e,t,(r,n,s)=>{r.deleteAt(n,s)})}descendant(e,t=0){let[r,n]=this.children.find(t);return e.blotName==null&&e(r)||e.blotName!=null&&r instanceof e?[r,n]:r instanceof Cn?r.descendant(e,n):[null,-1]}descendants(e,t=0,r=Number.MAX_VALUE){let n=[],s=r;return this.children.forEachAt(t,r,(a,o,l)=>{(e.blotName==null&&e(a)||e.blotName!=null&&a instanceof e)&&n.push(a),a instanceof Cn&&(n=n.concat(a.descendants(e,o,s))),s-=l}),n}detach(){this.children.forEach(e=>{e.detach()}),super.detach()}enforceAllowedChildren(){let e=!1;this.children.forEach(t=>{e||this.statics.allowedChildren.some(r=>t instanceof r)||(t.statics.scope===X.BLOCK_BLOT?(t.next!=null&&this.splitAfter(t),t.prev!=null&&this.splitAfter(t.prev),t.parent.unwrap(),e=!0):t instanceof Cn?t.unwrap():t.remove())})}formatAt(e,t,r,n){this.children.forEachAt(e,t,(s,a,o)=>{s.formatAt(a,o,r,n)})}insertAt(e,t,r){let[n,s]=this.children.find(e);if(n)n.insertAt(s,t,r);else{let a=r==null?this.scroll.create("text",t):this.scroll.create(t,r);this.appendChild(a)}}insertBefore(e,t){e.parent!=null&&e.parent.children.remove(e);let r=null;this.children.insertBefore(e,t||null),e.parent=this,t!=null&&(r=t.domNode),(this.domNode.parentNode!==e.domNode||this.domNode.nextSibling!==r)&&this.domNode.insertBefore(e.domNode,r),e.attach()}length(){return this.children.reduce((e,t)=>e+t.length(),0)}moveChildren(e,t){this.children.forEach(r=>{e.insertBefore(r,t)})}optimize(e){if(super.optimize(e),this.enforceAllowedChildren(),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0)if(this.statics.defaultChild!=null){let t=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(t)}else this.remove()}path(e,t=!1){let[r,n]=this.children.find(e,t),s=[[this,e]];return r instanceof Cn?s.concat(r.path(n,t)):(r!=null&&s.push([r,n]),s)}removeChild(e){this.children.remove(e)}replaceWith(e,t){let r=typeof e=="string"?this.scroll.create(e,t):e;return r instanceof Cn&&this.moveChildren(r),super.replaceWith(r)}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let r=this.clone();return this.parent&&this.parent.insertBefore(r,this.next||void 0),this.children.forEachAt(e,this.length(),(n,s,a)=>{let o=n.split(s,t);o!=null&&r.appendChild(o)}),r}splitAfter(e){let t=this.clone();for(;e.next!=null;)t.appendChild(e.next);return this.parent&&this.parent.insertBefore(t,this.next||void 0),t}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(e,t){let r=[],n=[];e.forEach(s=>{s.target===this.domNode&&s.type==="childList"&&(r.push(...s.addedNodes),n.push(...s.removedNodes))}),n.forEach(s=>{if(s.parentNode!=null&&s.tagName!=="IFRAME"&&document.body.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;let a=this.scroll.find(s);a!=null&&(a.domNode.parentNode==null||a.domNode.parentNode===this.domNode)&&a.detach()}),r.filter(s=>s.parentNode===this.domNode&&s!==this.uiNode).sort((s,a)=>s===a?0:s.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(s=>{let a=null;s.nextSibling!=null&&(a=this.scroll.find(s.nextSibling));let o=Y8(s,this.scroll);(o.next!==a||o.next==null)&&(o.parent!=null&&o.parent.removeChild(this),this.insertBefore(o,a||void 0))}),this.enforceAllowedChildren()}};J8.uiClass="";Tz=J8,ni=Tz;Oa=class Ba extends ni{static create(e){return super.create(e)}static formats(e,t){let r=t.query(Ba.blotName);if(!(r!=null&&e.tagName===r.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return e.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new yl(this.domNode)}format(e,t){if(e===this.statics.blotName&&!t)this.children.forEach(r=>{r instanceof Ba||(r=r.wrap(Ba.blotName,!0)),this.attributes.copy(r)}),this.unwrap();else{let r=this.scroll.query(e,X.INLINE);if(r==null)return;r instanceof qt?this.attributes.attribute(r,t):t&&(e!==this.statics.blotName||this.formats()[e]!==t)&&this.replaceWith(e,t)}}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,r,n){this.formats()[r]!=null||this.scroll.query(r,X.ATTRIBUTE)?this.isolate(e,t).format(r,n):super.formatAt(e,t,r,n)}optimize(e){super.optimize(e);let t=this.formats();if(Object.keys(t).length===0)return this.unwrap();let r=this.next;r instanceof Ba&&r.prev===this&&Nz(t,r.formats())&&(r.moveChildren(this),r.remove())}replaceWith(e,t){let r=super.replaceWith(e,t);return this.attributes.copy(r),r}update(e,t){super.update(e,t),e.some(r=>r.target===this.domNode&&r.type==="attributes")&&this.attributes.build()}wrap(e,t){let r=super.wrap(e,t);return r instanceof Ba&&this.attributes.move(r),r}};Oa.allowedChildren=[Oa,dt],Oa.blotName="inline",Oa.scope=X.INLINE_BLOT,Oa.tagName="SPAN";Ez=Oa,bd=Ez,Pa=class wf extends ni{static create(e){return super.create(e)}static formats(e,t){let r=t.query(wf.blotName);if(!(r!=null&&e.tagName===r.tagName)){if(typeof this.tagName=="string")return!0;if(Array.isArray(this.tagName))return e.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new yl(this.domNode)}format(e,t){let r=this.scroll.query(e,X.BLOCK);r!=null&&(r instanceof qt?this.attributes.attribute(r,t):e===this.statics.blotName&&!t?this.replaceWith(wf.blotName):t&&(e!==this.statics.blotName||this.formats()[e]!==t)&&this.replaceWith(e,t))}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,r,n){this.scroll.query(r,X.BLOCK)!=null?this.format(r,n):super.formatAt(e,t,r,n)}insertAt(e,t,r){if(r==null||this.scroll.query(t,X.INLINE)!=null)super.insertAt(e,t,r);else{let n=this.split(e);if(n!=null){let s=this.scroll.create(t,r);n.parent.insertBefore(s,n)}else throw new Error("Attempt to insertAt after block boundaries")}}replaceWith(e,t){let r=super.replaceWith(e,t);return this.attributes.copy(r),r}update(e,t){super.update(e,t),e.some(r=>r.target===this.domNode&&r.type==="attributes")&&this.attributes.build()}};Pa.blotName="block",Pa.scope=X.BLOCK_BLOT,Pa.tagName="P",Pa.allowedChildren=[bd,Pa,dt];Sz=Pa,vs=Sz,Mf=class extends ni{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(e,t){super.deleteAt(e,t),this.enforceAllowedChildren()}formatAt(e,t,r,n){super.formatAt(e,t,r,n),this.enforceAllowedChildren()}insertAt(e,t,r){super.insertAt(e,t,r),this.enforceAllowedChildren()}optimize(e){super.optimize(e),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};Mf.blotName="container",Mf.scope=X.BLOCK_BLOT;Az=Mf,qa=Az,Tf=class extends dt{static formats(e,t){}format(e,t){super.formatAt(0,this.length(),e,t)}formatAt(e,t,r,n){e===0&&t===this.length()?this.format(r,n):super.formatAt(e,t,r,n)}formats(){return this.statics.formats(this.domNode,this.scroll)}},Ke=Tf,kz={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},Cz=100,Fa=class extends ni{constructor(e,t){super(null,t),this.registry=e,this.scroll=this,this.build(),this.observer=new MutationObserver(r=>{this.update(r)}),this.observer.observe(this.domNode,kz),this.attach()}create(e,t){return this.registry.create(this,e,t)}find(e,t=!1){let r=this.registry.find(e,t);return r?r.scroll===this?r:t?this.find(r.scroll.domNode.parentNode,!0):null:null}query(e,t=X.ANY){return this.registry.query(e,t)}register(...e){return this.registry.register(...e)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(e,t){this.update(),e===0&&t===this.length()?this.children.forEach(r=>{r.remove()}):super.deleteAt(e,t)}formatAt(e,t,r,n){this.update(),super.formatAt(e,t,r,n)}insertAt(e,t,r){this.update(),super.insertAt(e,t,r)}optimize(e=[],t={}){super.optimize(t);let r=t.mutationsMap||new WeakMap,n=Array.from(this.observer.takeRecords());for(;n.length>0;)e.push(n.pop());let s=(l,h=!0)=>{l==null||l===this||l.domNode.parentNode!=null&&(r.has(l.domNode)||r.set(l.domNode,[]),h&&s(l.parent))},a=l=>{r.has(l.domNode)&&(l instanceof ni&&l.children.forEach(a),r.delete(l.domNode),l.optimize(t))},o=e;for(let l=0;o.length>0;l+=1){if(l>=Cz)throw new Error("[Parchment] Maximum optimize iterations reached");for(o.forEach(h=>{let d=this.find(h.target,!0);d!=null&&(d.domNode===h.target&&(h.type==="childList"?(s(this.find(h.previousSibling,!1)),Array.from(h.addedNodes).forEach(c=>{let f=this.find(c,!1);s(f,!1),f instanceof ni&&f.children.forEach(m=>{s(m,!1)})})):h.type==="attributes"&&s(d.prev)),s(d))}),this.children.forEach(a),o=Array.from(this.observer.takeRecords()),n=o.slice();n.length>0;)e.push(n.pop())}}update(e,t={}){e=e||this.observer.takeRecords();let r=new WeakMap;e.map(n=>{let s=this.find(n.target,!0);return s==null?null:r.has(s.domNode)?(r.get(s.domNode).push(n),null):(r.set(s.domNode,[n]),s)}).forEach(n=>{n!=null&&n!==this&&r.has(n.domNode)&&n.update(r.get(n.domNode)||[],t)}),t.mutationsMap=r,r.has(this.domNode)&&super.update(r.get(this.domNode),t),this.optimize(e,t)}};Fa.blotName="scroll",Fa.defaultChild=vs,Fa.allowedChildren=[vs,qa],Fa.scope=X.BLOCK_BLOT,Fa.tagName="DIV";_z=Fa,vl=_z,Nf=class ex extends dt{static create(e){return document.createTextNode(e)}static value(e){return e.data}constructor(e,t){super(e,t),this.text=this.statics.value(this.domNode)}deleteAt(e,t){this.domNode.data=this.text=this.text.slice(0,e)+this.text.slice(e+t)}index(e,t){return this.domNode===e?t:-1}insertAt(e,t,r){r==null?(this.text=this.text.slice(0,e)+t+this.text.slice(e),this.domNode.data=this.text):super.insertAt(e,t,r)}length(){return this.text.length}optimize(e){super.optimize(e),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof ex&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(e,t=!1){return[this.domNode,e]}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let r=this.scroll.create(this.domNode.splitText(e));return this.parent.insertBefore(r,this.next||void 0),this.text=this.statics.value(this.domNode),r}update(e,t){e.some(r=>r.type==="characterData"&&r.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};Nf.blotName="text",Nf.scope=X.INLINE_BLOT;Lz=Nf,Ha=Lz});var cx=rr((FZ,dx)=>{var mi=-1,Ht=1,ut=0;function wl(i,e,t,r,n){if(i===e)return i?[[ut,i]]:[];if(t!=null){var s=qz(i,e,t);if(s)return s}var a=Sf(i,e),o=i.substring(0,a);i=i.substring(a),e=e.substring(a),a=wd(i,e);var l=i.substring(i.length-a);i=i.substring(0,i.length-a),e=e.substring(0,e.length-a);var h=Iz(i,e);return o&&h.unshift([ut,o]),l&&h.push([ut,l]),Af(h,n),r&&Dz(h),h}function Iz(i,e){var t;if(!i)return[[Ht,e]];if(!e)return[[mi,i]];var r=i.length>e.length?i:e,n=i.length>e.length?e:i,s=r.indexOf(n);if(s!==-1)return t=[[Ht,r.substring(0,s)],[ut,n],[Ht,r.substring(s+n.length)]],i.length>e.length&&(t[0][0]=t[2][0]=mi),t;if(n.length===1)return[[mi,i],[Ht,e]];var a=Rz(i,e);if(a){var o=a[0],l=a[1],h=a[2],d=a[3],c=a[4],f=wl(o,h),m=wl(l,d);return f.concat([[ut,c]],m)}return zz(i,e)}function zz(i,e){for(var t=i.length,r=e.length,n=Math.ceil((t+r)/2),s=n,a=2*n,o=new Array(a),l=new Array(a),h=0;ht)m+=2;else if(C>r)f+=2;else if(c){var I=s+d-b;if(I>=0&&I=O)return tx(i,e,A,C)}}}for(var q=-y+g;q<=y-x;q+=2){var I=s+q,O;q===-y||q!==y&&l[I-1]t)x+=2;else if(P>r)g+=2;else if(!c){var S=s+d-q;if(S>=0&&S=O)return tx(i,e,A,C)}}}}return[[mi,i],[Ht,e]]}function tx(i,e,t,r){var n=i.substring(0,t),s=e.substring(0,r),a=i.substring(t),o=e.substring(r),l=wl(n,s),h=wl(a,o);return l.concat(h)}function Sf(i,e){if(!i||!e||i.charAt(0)!==e.charAt(0))return 0;for(var t=0,r=Math.min(i.length,e.length),n=r,s=0;tr?i=i.substring(t-r):te.length?i:e,r=i.length>e.length?e:i;if(t.length<4||r.length*2=m.length?[A,C,I,O,S]:null}var s=n(t,r,Math.ceil(t.length/4)),a=n(t,r,Math.ceil(t.length/2)),o;if(!s&&!a)return null;a?s?o=s[4].length>a[4].length?s:a:o=a:o=s;var l,h,d,c;i.length>e.length?(l=o[0],h=o[1],d=o[2],c=o[3]):(d=o[0],c=o[1],l=o[2],h=o[3]);var f=o[4];return[l,h,d,c,f]}function Dz(i){for(var e=!1,t=[],r=0,n=null,s=0,a=0,o=0,l=0,h=0;s0?t[r-1]:-1,a=0,o=0,l=0,h=0,n=null,e=!0)),s++;for(e&&Af(i),Pz(i),s=1;s=m?(f>=d.length/2||f>=c.length/2)&&(i.splice(s,0,[ut,c.substring(0,f)]),i[s-1][1]=d.substring(0,d.length-f),i[s+1][1]=c.substring(f),s++):(m>=d.length/2||m>=c.length/2)&&(i.splice(s,0,[ut,d.substring(0,m)]),i[s-1][0]=Ht,i[s-1][1]=c.substring(0,c.length-m),i[s+1][0]=mi,i[s+1][1]=d.substring(m),s++),s++}s++}}var rx=/[^a-zA-Z0-9]/,nx=/\s/,sx=/[\r\n]/,Oz=/\n\r?\n$/,Bz=/^\r?\n\r?\n/;function Pz(i){function e(m,g){if(!m||!g)return 6;var x=m.charAt(m.length-1),y=g.charAt(0),b=x.match(rx),S=y.match(rx),A=b&&x.match(nx),C=S&&y.match(nx),I=A&&x.match(sx),O=C&&y.match(sx),q=I&&m.match(Oz),P=O&&g.match(Bz);return q||P?5:I||O?4:b&&!A&&C?3:A||C?2:b||S?1:0}for(var t=1;t=c&&(c=f,l=r,h=n,d=s)}i[t-1][1]!=l&&(l?i[t-1][1]=l:(i.splice(t-1,1),t--),i[t][1]=h,d?i[t+1][1]=d:(i.splice(t+1,1),t--))}t++}}function Af(i,e){i.push([ut,""]);for(var t=0,r=0,n=0,s="",a="",o;t=0&&hx(i[l][1])){var h=i[l][1].slice(-1);if(i[l][1]=i[l][1].slice(0,-1),s=h+s,a=h+a,!i[l][1]){i.splice(l,1),t--;var d=l-1;i[d]&&i[d][0]===Ht&&(n++,a=i[d][1]+a,d--),i[d]&&i[d][0]===mi&&(r++,s=i[d][1]+s,d--),l=d}}if(lx(i[t][1])){var h=i[t][1].charAt(0);i[t][1]=i[t][1].slice(1),s+=h,a+=h}}if(t0||a.length>0){s.length>0&&a.length>0&&(o=Sf(a,s),o!==0&&(l>=0?i[l][1]+=a.substring(0,o):(i.splice(0,0,[ut,a.substring(0,o)]),t++),a=a.substring(o),s=s.substring(o)),o=wd(a,s),o!==0&&(i[t][1]=a.substring(a.length-o)+i[t][1],a=a.substring(0,a.length-o),s=s.substring(0,s.length-o)));var c=n+r;s.length===0&&a.length===0?(i.splice(t-c,c),t=t-c):s.length===0?(i.splice(t-c,c,[Ht,a]),t=t-c+1):a.length===0?(i.splice(t-c,c,[mi,s]),t=t-c+1):(i.splice(t-c,c,[mi,s],[Ht,a]),t=t-c+2)}t!==0&&i[t-1][0]===ut?(i[t-1][1]+=i[t][1],i.splice(t,1)):t++,n=0,r=0,s="",a="";break}}i[i.length-1][1]===""&&i.pop();var f=!1;for(t=1;t=55296&&i<=56319}function ox(i){return i>=56320&&i<=57343}function lx(i){return ox(i.charCodeAt(0))}function hx(i){return ax(i.charCodeAt(i.length-1))}function Fz(i){for(var e=[],t=0;t0&&e.push(i[t]);return e}function Ef(i,e,t,r){return hx(i)||lx(r)?null:Fz([[ut,i],[mi,e],[Ht,t],[ut,r]])}function qz(i,e,t){var r=typeof t=="number"?{index:t,length:0}:t.oldRange,n=typeof t=="number"?null:t.newRange,s=i.length,a=e.length;if(r.length===0&&(n===null||n.length===0)){var o=r.index,l=i.slice(0,o),h=i.slice(o),d=n?n.index:null;e:{var c=o+a-s;if(d!==null&&d!==c||c<0||c>a)break e;var f=e.slice(0,c),m=e.slice(c);if(m!==h)break e;var g=Math.min(o,c),x=l.slice(0,g),y=f.slice(0,g);if(x!==y)break e;var b=l.slice(g),S=f.slice(g);return Ef(x,b,S,h)}e:{if(d!==null&&d!==o)break e;var A=o,f=e.slice(0,A),m=e.slice(A);if(f!==l)break e;var C=Math.min(s-A,a-A),I=h.slice(h.length-C),O=m.slice(m.length-C);if(I!==O)break e;var b=h.slice(0,h.length-C),S=m.slice(0,m.length-C);return Ef(l,b,S,I)}}if(r.length>0&&n&&n.length===0)e:{var x=i.slice(0,r.index),I=i.slice(r.index+r.length),g=x.length,C=I.length;if(a{var Hz=200,Tx="__lodash_hash_undefined__",Nx=9007199254740991,Df="[object Arguments]",Uz="[object Array]",Ex="[object Boolean]",Sx="[object Date]",$z="[object Error]",Of="[object Function]",Ax="[object GeneratorFunction]",Td="[object Map]",kx="[object Number]",Bf="[object Object]",ux="[object Promise]",Cx="[object RegExp]",Nd="[object Set]",_x="[object String]",Lx="[object Symbol]",Cf="[object WeakMap]",Ix="[object ArrayBuffer]",Ed="[object DataView]",zx="[object Float32Array]",Rx="[object Float64Array]",Dx="[object Int8Array]",Ox="[object Int16Array]",Bx="[object Int32Array]",Px="[object Uint8Array]",Fx="[object Uint8ClampedArray]",qx="[object Uint16Array]",Hx="[object Uint32Array]",jz=/[\\^$.*+?()[\]{}|]/g,Gz=/\w*$/,Vz=/^\[object .+?Constructor\]$/,Wz=/^(?:0|[1-9]\d*)$/,Pe={};Pe[Df]=Pe[Uz]=Pe[Ix]=Pe[Ed]=Pe[Ex]=Pe[Sx]=Pe[zx]=Pe[Rx]=Pe[Dx]=Pe[Ox]=Pe[Bx]=Pe[Td]=Pe[kx]=Pe[Bf]=Pe[Cx]=Pe[Nd]=Pe[_x]=Pe[Lx]=Pe[Px]=Pe[Fx]=Pe[qx]=Pe[Hx]=!0;Pe[$z]=Pe[Of]=Pe[Cf]=!1;var Yz=typeof global=="object"&&global&&global.Object===Object&&global,Xz=typeof self=="object"&&self&&self.Object===Object&&self,$r=Yz||Xz||Function("return this")(),Ux=typeof Ml=="object"&&Ml&&!Ml.nodeType&&Ml,fx=Ux&&typeof Ua=="object"&&Ua&&!Ua.nodeType&&Ua,Kz=fx&&fx.exports===Ux;function Zz(i,e){return i.set(e[0],e[1]),i}function Qz(i,e){return i.add(e),i}function Jz(i,e){for(var t=-1,r=i?i.length:0;++t-1}function SR(i,e){var t=this.__data__,r=kd(t,i);return r<0?t.push([i,e]):t[r][1]=e,this}jr.prototype.clear=MR;jr.prototype.delete=TR;jr.prototype.get=NR;jr.prototype.has=ER;jr.prototype.set=SR;function $a(i){var e=-1,t=i?i.length:0;for(this.clear();++e-1&&i%1==0&&i-1&&i%1==0&&i<=Nx}function _d(i){var e=typeof i;return!!i&&(e=="object"||e=="function")}function cD(i){return!!i&&typeof i=="object"}function Hf(i){return Zx(i)?BR(i):$R(i)}function uD(){return[]}function fD(){return!1}Ua.exports=aD});var em=rr((El,Wa)=>{var mD=200,Jf="__lodash_hash_undefined__",Pd=1,d9=2,c9=9007199254740991,Ld="[object Arguments]",Vf="[object Array]",pD="[object AsyncFunction]",u9="[object Boolean]",f9="[object Date]",m9="[object Error]",p9="[object Function]",gD="[object GeneratorFunction]",Id="[object Map]",g9="[object Number]",xD="[object Null]",Va="[object Object]",Jx="[object Promise]",yD="[object Proxy]",x9="[object RegExp]",zd="[object Set]",y9="[object String]",vD="[object Symbol]",bD="[object Undefined]",Wf="[object WeakMap]",v9="[object ArrayBuffer]",Rd="[object DataView]",wD="[object Float32Array]",MD="[object Float64Array]",TD="[object Int8Array]",ND="[object Int16Array]",ED="[object Int32Array]",SD="[object Uint8Array]",AD="[object Uint8ClampedArray]",kD="[object Uint16Array]",CD="[object Uint32Array]",_D=/[\\^$.*+?()[\]{}|]/g,LD=/^\[object .+?Constructor\]$/,ID=/^(?:0|[1-9]\d*)$/,Ue={};Ue[wD]=Ue[MD]=Ue[TD]=Ue[ND]=Ue[ED]=Ue[SD]=Ue[AD]=Ue[kD]=Ue[CD]=!0;Ue[Ld]=Ue[Vf]=Ue[v9]=Ue[u9]=Ue[Rd]=Ue[f9]=Ue[m9]=Ue[p9]=Ue[Id]=Ue[g9]=Ue[Va]=Ue[x9]=Ue[zd]=Ue[y9]=Ue[Wf]=!1;var b9=typeof global=="object"&&global&&global.Object===Object&&global,zD=typeof self=="object"&&self&&self.Object===Object&&self,Gr=b9||zD||Function("return this")(),w9=typeof El=="object"&&El&&!El.nodeType&&El,e9=w9&&typeof Wa=="object"&&Wa&&!Wa.nodeType&&Wa,M9=e9&&e9.exports===w9,$f=M9&&b9.process,t9=(function(){try{return $f&&$f.binding&&$f.binding("util")}catch{}})(),i9=t9&&t9.isTypedArray;function RD(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t-1}function dO(i,e){var t=this.__data__,r=qd(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}Vr.prototype.clear=aO;Vr.prototype.delete=oO;Vr.prototype.get=lO;Vr.prototype.has=hO;Vr.prototype.set=dO;function Es(i){var e=-1,t=i==null?0:i.length;for(this.clear();++eo))return!1;var h=s.get(i);if(h&&s.get(e))return h==e;var d=-1,c=!0,f=t&d9?new Od:void 0;for(s.set(i,e),s.set(e,i);++d-1&&i%1==0&&i-1&&i%1==0&&i<=c9}function L9(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}function kl(i){return i!=null&&typeof i=="object"}var I9=i9?PD(i9):AO;function HO(i){return FO(i)?TO(i):kO(i)}function UO(){return[]}function $O(){return!1}Wa.exports=qO});var z9=rr(im=>{"use strict";Object.defineProperty(im,"__esModule",{value:!0});var jO=Uf(),GO=em(),tm;(function(i){function e(s={},a={},o=!1){typeof s!="object"&&(s={}),typeof a!="object"&&(a={});let l=jO(a);o||(l=Object.keys(l).reduce((h,d)=>(l[d]!=null&&(h[d]=l[d]),h),{}));for(let h in s)s[h]!==void 0&&a[h]===void 0&&(l[h]=s[h]);return Object.keys(l).length>0?l:void 0}i.compose=e;function t(s={},a={}){typeof s!="object"&&(s={}),typeof a!="object"&&(a={});let o=Object.keys(s).concat(Object.keys(a)).reduce((l,h)=>(GO(s[h],a[h])||(l[h]=a[h]===void 0?null:a[h]),l),{});return Object.keys(o).length>0?o:void 0}i.diff=t;function r(s={},a={}){s=s||{};let o=Object.keys(a).reduce((l,h)=>(a[h]!==s[h]&&s[h]!==void 0&&(l[h]=a[h]),l),{});return Object.keys(s).reduce((l,h)=>(s[h]!==a[h]&&a[h]===void 0&&(l[h]=null),l),o)}i.invert=r;function n(s,a,o=!1){if(typeof s!="object")return a;if(typeof a!="object")return;if(!o)return a;let l=Object.keys(a).reduce((h,d)=>(s[d]===void 0&&(h[d]=a[d]),h),{});return Object.keys(l).length>0?l:void 0}i.transform=n})(tm||(tm={}));im.default=tm});var sm=rr(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});var rm;(function(i){function e(t){return typeof t.delete=="number"?t.delete:typeof t.retain=="number"?t.retain:typeof t.retain=="object"&&t.retain!==null?1:typeof t.insert=="string"?t.insert.length:1}i.length=e})(rm||(rm={}));nm.default=rm});var D9=rr(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0});var R9=sm(),am=class{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e){e||(e=1/0);let t=this.ops[this.index];if(t){let r=this.offset,n=R9.default.length(t);if(e>=n-r?(e=n-r,this.index+=1,this.offset=0):this.offset+=e,typeof t.delete=="number")return{delete:e};{let s={};return t.attributes&&(s.attributes=t.attributes),typeof t.retain=="number"?s.retain=e:typeof t.retain=="object"&&t.retain!==null?s.retain=t.retain:typeof t.insert=="string"?s.insert=t.insert.substr(r,e):s.insert=t.insert,s}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?R9.default.length(this.ops[this.index])-this.offset:1/0}peekType(){let e=this.ops[this.index];return e?typeof e.delete=="number"?"delete":typeof e.retain=="number"||typeof e.retain=="object"&&e.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);{let e=this.offset,t=this.index,r=this.next(),n=this.ops.slice(this.index);return this.offset=e,this.index=t,[r].concat(n)}}else return[]}};om.default=am});var pi=rr((Yr,$d)=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.AttributeMap=Yr.OpIterator=Yr.Op=void 0;var Ud=cx(),VO=Uf(),lm=em(),As=z9();Yr.AttributeMap=As.default;var Wr=sm();Yr.Op=Wr.default;var Ii=D9();Yr.OpIterator=Ii.default;var WO="\0",O9=(i,e)=>{if(typeof i!="object"||i===null)throw new Error(`cannot retain a ${typeof i}`);if(typeof e!="object"||e===null)throw new Error(`cannot retain a ${typeof e}`);let t=Object.keys(i)[0];if(!t||t!==Object.keys(e)[0])throw new Error(`embed types not matched: ${t} != ${Object.keys(e)[0]}`);return[t,i[t],e[t]]},Xr=class i{constructor(e){Array.isArray(e)?this.ops=e:e!=null&&Array.isArray(e.ops)?this.ops=e.ops:this.ops=[]}static registerEmbed(e,t){this.handlers[e]=t}static unregisterEmbed(e){delete this.handlers[e]}static getHandler(e){let t=this.handlers[e];if(!t)throw new Error(`no handlers for embed type "${e}"`);return t}insert(e,t){let r={};return typeof e=="string"&&e.length===0?this:(r.insert=e,t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(r.attributes=t),this.push(r))}delete(e){return e<=0?this:this.push({delete:e})}retain(e,t){if(typeof e=="number"&&e<=0)return this;let r={retain:e};return t!=null&&typeof t=="object"&&Object.keys(t).length>0&&(r.attributes=t),this.push(r)}push(e){let t=this.ops.length,r=this.ops[t-1];if(e=VO(e),typeof r=="object"){if(typeof e.delete=="number"&&typeof r.delete=="number")return this.ops[t-1]={delete:r.delete+e.delete},this;if(typeof r.delete=="number"&&e.insert!=null&&(t-=1,r=this.ops[t-1],typeof r!="object"))return this.ops.unshift(e),this;if(lm(e.attributes,r.attributes)){if(typeof e.insert=="string"&&typeof r.insert=="string")return this.ops[t-1]={insert:r.insert+e.insert},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this;if(typeof e.retain=="number"&&typeof r.retain=="number")return this.ops[t-1]={retain:r.retain+e.retain},typeof e.attributes=="object"&&(this.ops[t-1].attributes=e.attributes),this}}return t===this.ops.length?this.ops.push(e):this.ops.splice(t,0,e),this}chop(){let e=this.ops[this.ops.length-1];return e&&typeof e.retain=="number"&&!e.attributes&&this.ops.pop(),this}filter(e){return this.ops.filter(e)}forEach(e){this.ops.forEach(e)}map(e){return this.ops.map(e)}partition(e){let t=[],r=[];return this.forEach(n=>{(e(n)?t:r).push(n)}),[t,r]}reduce(e,t){return this.ops.reduce(e,t)}changeLength(){return this.reduce((e,t)=>t.insert?e+Wr.default.length(t):t.delete?e-t.delete:e,0)}length(){return this.reduce((e,t)=>e+Wr.default.length(t),0)}slice(e=0,t=1/0){let r=[],n=new Ii.default(this.ops),s=0;for(;s0&&r.next(s.retain-o)}let a=new i(n);for(;t.hasNext()||r.hasNext();)if(r.peekType()==="insert")a.push(r.next());else if(t.peekType()==="delete")a.push(t.next());else{let o=Math.min(t.peekLength(),r.peekLength()),l=t.next(o),h=r.next(o);if(h.retain){let d={};if(typeof l.retain=="number")d.retain=typeof h.retain=="number"?o:h.retain;else if(typeof h.retain=="number")l.retain==null?d.insert=l.insert:d.retain=l.retain;else{let f=l.retain==null?"insert":"retain",[m,g,x]=O9(l[f],h.retain),y=i.getHandler(m);d[f]={[m]:y.compose(g,x,f==="retain")}}let c=As.default.compose(l.attributes,h.attributes,typeof l.retain=="number");if(c&&(d.attributes=c),a.push(d),!r.hasNext()&&lm(a.ops[a.ops.length-1],d)){let f=new i(t.rest());return a.concat(f).chop()}}else typeof h.delete=="number"&&(typeof l.retain=="number"||typeof l.retain=="object"&&l.retain!==null)&&a.push(h)}return a.chop()}concat(e){let t=new i(this.ops.slice());return e.ops.length>0&&(t.push(e.ops[0]),t.ops=t.ops.concat(e.ops.slice(1))),t}diff(e,t){if(this.ops===e.ops)return new i;let r=[this,e].map(l=>l.map(h=>{if(h.insert!=null)return typeof h.insert=="string"?h.insert:WO;let d=l===e?"on":"with";throw new Error("diff() called "+d+" non-document")}).join("")),n=new i,s=Ud(r[0],r[1],t,!0),a=new Ii.default(this.ops),o=new Ii.default(e.ops);return s.forEach(l=>{let h=l[1].length;for(;h>0;){let d=0;switch(l[0]){case Ud.INSERT:d=Math.min(o.peekLength(),h),n.push(o.next(d));break;case Ud.DELETE:d=Math.min(h,a.peekLength()),a.next(d),n.delete(d);break;case Ud.EQUAL:d=Math.min(a.peekLength(),o.peekLength(),h);let c=a.next(d),f=o.next(d);lm(c.insert,f.insert)?n.retain(d,As.default.diff(c.attributes,f.attributes)):n.push(f).delete(d);break}h-=d}}),n.chop()}eachLine(e,t=` +`){let r=new Ii.default(this.ops),n=new i,s=0;for(;r.hasNext();){if(r.peekType()!=="insert")return;let a=r.peek(),o=Wr.default.length(a)-r.peekLength(),l=typeof a.insert=="string"?a.insert.indexOf(t,o)-o:-1;if(l<0)n.push(r.next());else if(l>0)n.push(r.next(l));else{if(e(n,r.next(1).attributes||{},s)===!1)return;s+=1,n=new i}}n.length()>0&&e(n,{},s)}invert(e){let t=new i;return this.reduce((r,n)=>{if(n.insert)t.delete(Wr.default.length(n));else{if(typeof n.retain=="number"&&n.attributes==null)return t.retain(n.retain),r+n.retain;if(n.delete||typeof n.retain=="number"){let s=n.delete||n.retain;return e.slice(r,r+s).forEach(o=>{n.delete?t.push(o):n.retain&&n.attributes&&t.retain(Wr.default.length(o),As.default.invert(n.attributes,o.attributes))}),r+s}else if(typeof n.retain=="object"&&n.retain!==null){let s=e.slice(r,r+1),a=new Ii.default(s.ops).next(),[o,l,h]=O9(n.retain,a.insert),d=i.getHandler(o);return t.retain({[o]:d.invert(l,h)},As.default.invert(n.attributes,a.attributes)),r+1}}return r},0),t.chop()}transform(e,t=!1){if(t=!!t,typeof e=="number")return this.transformPosition(e,t);let r=e,n=new Ii.default(this.ops),s=new Ii.default(r.ops),a=new i;for(;n.hasNext()||s.hasNext();)if(n.peekType()==="insert"&&(t||s.peekType()!=="insert"))a.retain(Wr.default.length(n.next()));else if(s.peekType()==="insert")a.push(s.next());else{let o=Math.min(n.peekLength(),s.peekLength()),l=n.next(o),h=s.next(o);if(l.delete)continue;if(h.delete)a.push(h);else{let d=l.retain,c=h.retain,f=typeof c=="object"&&c!==null?c:o;if(typeof d=="object"&&d!==null&&typeof c=="object"&&c!==null){let m=Object.keys(d)[0];if(m===Object.keys(c)[0]){let g=i.getHandler(m);g&&(f={[m]:g.transform(d[m],c[m],t)})}}a.retain(f,As.default.transform(l.attributes,h.attributes,t))}}return a.chop()}transformPosition(e,t=!1){t=!!t;let r=new Ii.default(this.ops),n=0;for(;r.hasNext()&&n<=e;){let s=r.peekLength(),a=r.peekType();if(r.next(),a==="delete"){e-=Math.min(s,e-n);continue}else a==="insert"&&(n{Re();_l=class extends Ke{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}};_l.blotName="break";_l.tagName="BR";Et=_l});function ks(i){return i.replace(/[&<>"']/g,e=>YO[e])}var nt,YO,Kr=T(()=>{Re();nt=class extends Ha{},YO={"&":"&","<":"<",">":">",'"':""","'":"'"}});var br,hm,St,Zr=T(()=>{Re();Dn();Kr();br=class br extends bd{static compare(e,t){let r=br.order.indexOf(e),n=br.order.indexOf(t);return r>=0||n>=0?r-n:e===t?0:e0){let t=this.parent.isolate(this.offset(),this.length());this.moveChildren(t),t.wrap(this)}}};U(br,"allowedChildren",[br,Et,Ke,nt]),U(br,"order",["cursor","inline","link","underline","strike","italic","bold","script","code"]);hm=br,St=hm});function cm(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return i.descendants(dt).reduce((t,r)=>r.length()===0?t:t.insert(r.value(),ai(r,{},e)),new dm.default).insert(` +`,ai(i))}function ai(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return i==null||("formats"in i&&typeof i.formats=="function"&&(e={...e,...i.formats()},t&&delete e["code-token"]),i.parent==null||i.parent.statics.blotName==="scroll"||i.parent.statics.scope!==i.statics.scope)?e:ai(i.parent,e,t)}var dm,B9,De,ft,zi=T(()=>{Re();dm=pt(pi(),1);Dn();Zr();Kr();B9=1,De=class extends vs{constructor(){super(...arguments);U(this,"cache",{})}delta(){return this.cache.delta==null&&(this.cache.delta=cm(this)),this.cache.delta}deleteAt(t,r){super.deleteAt(t,r),this.cache={}}formatAt(t,r,n,s){r<=0||(this.scroll.query(n,X.BLOCK)?t+r===this.length()&&this.format(n,s):super.formatAt(t,Math.min(r,this.length()-t-1),n,s),this.cache={})}insertAt(t,r,n){if(n!=null){super.insertAt(t,r,n),this.cache={};return}if(r.length===0)return;let s=r.split(` +`),a=s.shift();a.length>0&&(t(o=o.split(l,!0),o.insertAt(0,h),h.length),t+a.length)}insertBefore(t,r){let{head:n}=this.children;super.insertBefore(t,r),n instanceof Et&&n.remove(),this.cache={}}length(){return this.cache.length==null&&(this.cache.length=super.length()+B9),this.cache.length}moveChildren(t,r){super.moveChildren(t,r),this.cache={}}optimize(t){super.optimize(t),this.cache={}}path(t){return super.path(t,!0)}removeChild(t){super.removeChild(t),this.cache={}}split(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(r&&(t===0||t>=this.length()-B9)){let s=this.clone();return t===0?(this.parent.insertBefore(s,this),this):(this.parent.insertBefore(s,this.next),s)}let n=super.split(t,r);return this.cache={},n}};De.blotName="block";De.tagName="P";De.defaultChild=Et;De.allowedChildren=[Et,St,Ke,nt];ft=class extends Ke{attach(){super.attach(),this.attributes=new yl(this.domNode)}delta(){return new dm.default().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(e,t){let r=this.scroll.query(e,X.BLOCK_ATTRIBUTE);r!=null&&this.attributes.attribute(r,t)}formatAt(e,t,r,n){this.format(r,n)}insertAt(e,t,r){if(r!=null){super.insertAt(e,t,r);return}let n=t.split(` +`),s=n.pop(),a=n.map(l=>{let h=this.scroll.create(De.blotName);return h.insertAt(0,l),h}),o=this.split(e);a.forEach(l=>{this.parent.insertBefore(l,o)}),s&&this.parent.insertBefore(this.scroll.create("text",s),o)}};ft.scope=X.BLOCK_BLOT});var Ri,um,On,Ll=T(()=>{Re();Kr();Ri=class Ri extends Ke{static value(){}constructor(e,t,r){super(e,t),this.selection=r,this.textNode=document.createTextNode(Ri.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(e,t){if(this.savedLength!==0){super.format(e,t);return}let r=this,n=0;for(;r!=null&&r.statics.scope!==X.BLOCK_BLOT;)n+=r.offset(r.parent),r=r.parent;r!=null&&(this.savedLength=Ri.CONTENTS.length,r.optimize(),r.formatAt(n,Ri.CONTENTS.length,e,t),this.savedLength=0)}index(e,t){return e===this.textNode?0:super.index(e,t)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||this.parent==null)return null;let e=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);let t=this.prev instanceof nt?this.prev:null,r=t?t.length():0,n=this.next instanceof nt?this.next:null,s=n?n.text:"",{textNode:a}=this,o=a.data.split(Ri.CONTENTS).join("");a.data=Ri.CONTENTS;let l;if(t)l=t,(o||n)&&(t.insertAt(t.length(),o+s),n&&n.remove());else if(n)l=n,n.insertAt(0,o);else{let h=document.createTextNode(o);l=this.scroll.create(h),this.parent.insertBefore(l,this)}if(this.remove(),e){let h=(f,m)=>t&&f===t.domNode?m:f===a?r+m-1:n&&f===n.domNode?r+o.length+m:null,d=h(e.start.node,e.start.offset),c=h(e.end.node,e.end.offset);if(d!==null&&c!==null)return{startNode:l.domNode,startOffset:d,endNode:l.domNode,endOffset:c}}return null}update(e,t){if(e.some(r=>r.type==="characterData"&&r.target===this.textNode)){let r=this.restore();r&&(t.range=r)}}optimize(e){super.optimize(e);let{parent:t}=this;for(;t;){if(t.domNode.tagName==="A"){this.savedLength=Ri.CONTENTS.length,t.isolate(this.offset(t),this.length()).unwrap(),this.savedLength=0;break}t=t.parent}}value(){return""}};U(Ri,"blotName","cursor"),U(Ri,"className","ql-cursor"),U(Ri,"tagName","span"),U(Ri,"CONTENTS","\uFEFF");um=Ri,On=um});var F9=rr((lQ,fm)=>{"use strict";var XO=Object.prototype.hasOwnProperty,Ut="~";function Il(){}Object.create&&(Il.prototype=Object.create(null),new Il().__proto__||(Ut=!1));function KO(i,e,t){this.fn=i,this.context=e,this.once=t||!1}function P9(i,e,t,r,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new KO(t,r||i,n),a=Ut?Ut+e:e;return i._events[a]?i._events[a].fn?i._events[a]=[i._events[a],s]:i._events[a].push(s):(i._events[a]=s,i._eventsCount++),i}function jd(i,e){--i._eventsCount===0?i._events=new Il:delete i._events[e]}function At(){this._events=new Il,this._eventsCount=0}At.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)XO.call(t,r)&&e.push(Ut?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};At.prototype.listeners=function(e){var t=Ut?Ut+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,s=r.length,a=new Array(s);n{mm=pt(F9(),1)});var zl,pm=T(()=>{zl=new WeakMap});function H9(i){if(xm&&gm.indexOf(i)<=gm.indexOf(xm)){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r(e[t]=H9.bind(console,t,i),e),{})}var gm,xm,gi,Cs=T(()=>{gm=["error","warn","log","info"],xm="warn";ym.level=i=>{xm=i};H9.level=ym.level;gi=ym});var vm,ZO,Rl,J,Qr=T(()=>{q9();pm();Cs();vm=gi("quill:events"),ZO=["selectionchange","mousedown","mouseup","click"];ZO.forEach(i=>{document.addEventListener(i,function(){for(var e=arguments.length,t=new Array(e),r=0;r{let s=zl.get(n);s&&s.emitter&&s.emitter.handleDOM(...t)})})});Rl=class extends mm.default{constructor(){super(),this.domListeners={},this.on("error",vm.error)}emit(){for(var e=arguments.length,t=new Array(e),r=0;r1?t-1:0),n=1;n{let{node:a,handler:o}=s;(e.target===a||a.contains(e.target))&&o(e,...r)})}listenDOM(e,t,r){this.domListeners[e]||(this.domListeners[e]=[]),this.domListeners[e].push({node:t,handler:r})}};U(Rl,"events",{EDITOR_CHANGE:"editor-change",SCROLL_BEFORE_UPDATE:"scroll-before-update",SCROLL_BLOT_MOUNT:"scroll-blot-mount",SCROLL_BLOT_UNMOUNT:"scroll-blot-unmount",SCROLL_OPTIMIZE:"scroll-optimize",SCROLL_UPDATE:"scroll-update",SCROLL_EMBED_UPDATE:"scroll-embed-update",SELECTION_CHANGE:"selection-change",TEXT_CHANGE:"text-change",COMPOSITION_BEFORE_START:"composition-before-start",COMPOSITION_START:"composition-start",COMPOSITION_BEFORE_END:"composition-before-end",COMPOSITION_END:"composition-end"}),U(Rl,"sources",{API:"api",SILENT:"silent",USER:"user"});J=Rl});function wm(i,e){try{e.parentNode}catch{return!1}return i.contains(e)}var bm,$t,Mm,U9,Dl=T(()=>{Re();kn();Qr();Cs();bm=gi("quill:selection"),$t=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=e,this.length=t}},Mm=class{constructor(e,t){this.emitter=t,this.scroll=e,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create("cursor",this),this.savedRange=new $t(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM("selectionchange",document,()=>{!this.mouseDown&&!this.composing&&setTimeout(this.update.bind(this,J.sources.USER),1)}),this.emitter.on(J.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;let r=this.getNativeRange();r!=null&&r.start.node!==this.cursor.textNode&&this.emitter.once(J.events.SCROLL_UPDATE,(n,s)=>{try{this.root.contains(r.start.node)&&this.root.contains(r.end.node)&&this.setNativeRange(r.start.node,r.start.offset,r.end.node,r.end.offset);let a=s.some(o=>o.type==="characterData"||o.type==="childList"||o.type==="attributes"&&o.target===this.root);this.update(a?J.sources.SILENT:n)}catch{}})}),this.emitter.on(J.events.SCROLL_OPTIMIZE,(r,n)=>{if(n.range){let{startNode:s,startOffset:a,endNode:o,endOffset:l}=n.range;this.setNativeRange(s,a,o,l),this.update(J.sources.SILENT)}}),this.update(J.sources.SILENT)}handleComposition(){this.emitter.on(J.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(J.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){let e=this.cursor.restore();if(!e)return;setTimeout(()=>{this.setNativeRange(e.startNode,e.startOffset,e.endNode,e.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM("mousedown",document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM("mouseup",document.body,()=>{this.mouseDown=!1,this.update(J.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(e,t){this.scroll.update();let r=this.getNativeRange();if(!(r==null||!r.native.collapsed||this.scroll.query(e,X.BLOCK))){if(r.start.node!==this.cursor.textNode){let n=this.scroll.find(r.start.node,!1);if(n==null)return;if(n instanceof dt){let s=n.split(r.start.offset);n.parent.insertBefore(this.cursor,s)}else n.insertBefore(this.cursor,r.start.node);this.cursor.attach()}this.cursor.format(e,t),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=this.scroll.length();e=Math.min(e,r-1),t=Math.min(e+t,r-1)-e;let n,[s,a]=this.scroll.leaf(e);if(s==null)return null;if(t>0&&a===s.length()){let[d]=this.scroll.leaf(e+1);if(d){let[c]=this.scroll.line(e),[f]=this.scroll.line(e+1);c===f&&(s=d,a=0)}}[n,a]=s.position(a,!0);let o=document.createRange();if(t>0)return o.setStart(n,a),[s,a]=this.scroll.leaf(e+t),s==null?null:([n,a]=s.position(a,!0),o.setEnd(n,a),o.getBoundingClientRect());let l="left",h;if(n instanceof Text){if(!n.data.length)return null;a0&&(l="right")}return{bottom:h.top+h.height,height:h.height,left:h[l],right:h[l],top:h.top,width:0}}getNativeRange(){let e=document.getSelection();if(e==null||e.rangeCount<=0)return null;let t=e.getRangeAt(0);if(t==null)return null;let r=this.normalizeNative(t);return bm.info("getNativeRange",r),r}getRange(){let e=this.scroll.domNode;if("isConnected"in e&&!e.isConnected)return[null,null];let t=this.getNativeRange();return t==null?[null,null]:[this.normalizedToRange(t),t]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&wm(this.root,document.activeElement)}normalizedToRange(e){let t=[[e.start.node,e.start.offset]];e.native.collapsed||t.push([e.end.node,e.end.offset]);let r=t.map(a=>{let[o,l]=a,h=this.scroll.find(o,!0),d=h.offset(this.scroll);return l===0?d:h instanceof dt?d+h.index(o,l):d+h.length()}),n=Math.min(Math.max(...r),this.scroll.length()-1),s=Math.min(n,...r);return new $t(s,n-s)}normalizeNative(e){if(!wm(this.root,e.startContainer)||!e.collapsed&&!wm(this.root,e.endContainer))return null;let t={start:{node:e.startContainer,offset:e.startOffset},end:{node:e.endContainer,offset:e.endOffset},native:e};return[t.start,t.end].forEach(r=>{let{node:n,offset:s}=r;for(;!(n instanceof Text)&&n.childNodes.length>0;)if(n.childNodes.length>s)n=n.childNodes[s],s=0;else if(n.childNodes.length===s)n=n.lastChild,n instanceof Text?s=n.data.length:n.childNodes.length>0?s=n.childNodes.length:s=n.childNodes.length+1;else break;r.node=n,r.offset=s}),t}rangeToNative(e){let t=this.scroll.length(),r=(n,s)=>{n=Math.min(t-1,n);let[a,o]=this.scroll.leaf(n);return a?a.position(o,s):[null,-1]};return[...r(e.index,!1),...r(e.index+e.length,!0)]}setNativeRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:t,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(bm.info("setNativeRange",e,t,r,n),e!=null&&(this.root.parentNode==null||e.parentNode==null||r.parentNode==null))return;let a=document.getSelection();if(a!=null)if(e!=null){this.hasFocus()||this.root.focus({preventScroll:!0});let{native:o}=this.getNativeRange()||{};if(o==null||s||e!==o.startContainer||t!==o.startOffset||r!==o.endContainer||n!==o.endOffset){e instanceof Element&&e.tagName==="BR"&&(t=Array.from(e.parentNode.childNodes).indexOf(e),e=e.parentNode),r instanceof Element&&r.tagName==="BR"&&(n=Array.from(r.parentNode.childNodes).indexOf(r),r=r.parentNode);let l=document.createRange();l.setStart(e,t),l.setEnd(r,n),a.removeAllRanges(),a.addRange(l)}}else a.removeAllRanges(),this.root.blur()}setRange(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:J.sources.API;if(typeof t=="string"&&(r=t,t=!1),bm.info("setRange",e),e!=null){let n=this.rangeToNative(e);this.setNativeRange(...n,t)}else this.setNativeRange(null);this.update(r)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:J.sources.USER,t=this.lastRange,[r,n]=this.getRange();if(this.lastRange=r,this.lastNative=n,this.lastRange!=null&&(this.savedRange=this.lastRange),!ys(t,this.lastRange)){if(!this.composing&&n!=null&&n.native.collapsed&&n.start.node!==this.cursor.textNode){let a=this.cursor.restore();a&&this.setNativeRange(a.startNode,a.startOffset,a.endNode,a.endOffset)}let s=[J.events.SELECTION_CHANGE,yr(this.lastRange),yr(t),e];this.emitter.emit(J.events.EDITOR_CHANGE,...s),e!==J.sources.SILENT&&this.emitter.emit(...s)}}};U9=Mm});function Xa(i,e,t){if(i.length===0){let[m]=Tm(t.pop());return e<=0?``:`${Xa([],e-1,t)}`}let[{child:r,offset:n,length:s,indent:a,type:o},...l]=i,[h,d]=Tm(o);if(a>e)return t.push(o),a===e+1?`<${h}>${Ol(r,n,s)}${Xa(l,a,t)}`:`<${h}>
  • ${Xa(i,e+1,t)}`;let c=t[t.length-1];if(a===e&&o===c)return`
  • ${Ol(r,n,s)}${Xa(l,a,t)}`;let[f]=Tm(t.pop());return`${Xa(i,e-1,t)}`}function Ol(i,e,t){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if("html"in i&&typeof i.html=="function")return i.html(e,t);if(i instanceof nt)return ks(i.value().slice(e,e+t)).replaceAll(" "," ");if(i instanceof ni){if(i.statics.blotName==="list-container"){let h=[];return i.children.forEachAt(e,t,(d,c,f)=>{let m="formats"in d&&typeof d.formats=="function"?d.formats():{};h.push({child:d,offset:c,length:f,indent:m.indent||0,type:m.list})}),Xa(h,-1,[])}let n=[];if(i.children.forEachAt(e,t,(h,d,c)=>{n.push(Ol(h,d,c))}),r||i.statics.blotName==="list")return n.join("");let{outerHTML:s,innerHTML:a}=i.domNode,[o,l]=s.split(`>${a}<`);return o==="${n.join("")}<${l}`:`${o}>${n.join("")}<${l}`}return i.domNode instanceof Element?i.domNode.outerHTML:""}function JO(i,e){return Object.keys(e).reduce((t,r)=>{if(i[r]==null)return t;let n=e[r];return n===i[r]?t[r]=n:Array.isArray(n)?n.indexOf(i[r])<0?t[r]=n.concat([i[r]]):t[r]=n:t[r]=[n,i[r]],t},{})}function Tm(i){let e=i==="ordered"?"ol":"ul";switch(i){case"checked":return[e,' data-list="checked"'];case"unchecked":return[e,' data-list="unchecked"'];default:return[e,""]}}function $9(i){return i.reduce((e,t)=>{if(typeof t.insert=="string"){let r=t.insert.replace(/\r\n/g,` `).replace(/\r/g,` -`);return e.insert(r,t.attributes)}return e.push(t)},new $e.default)}function c9(i,e){let{index:t,length:r}=i;return new Lt(t+e,r)}function FR(i){let e=[];return i.forEach(t=>{typeof t.insert=="string"?t.insert.split(` +`);return e.insert(r,t.attributes)}return e.push(t)},new Ze.default)}function j9(i,e){let{index:t,length:r}=i;return new $t(t+e,r)}function eB(i){let e=[];return i.forEach(t=>{typeof t.insert=="string"?t.insert.split(` `).forEach((n,s)=>{s&&e.push({insert:` -`,attributes:t.attributes}),n&&e.push({insert:n,attributes:t.attributes})}):e.push(t)}),e}var $e,BR,Tf,u9,f9=M(()=>{ln();Ae();$e=ot(si(),1);wi();pn();el();zr();nl();BR=/^[ -~]*$/,Tf=class{constructor(e){this.scroll=e,this.delta=this.getDelta()}applyDelta(e){this.scroll.update();let t=this.scroll.length();this.scroll.batchStart();let r=d9(e),n=new $e.default;return FR(r.ops.slice()).reduce((a,o)=>{let l=$e.Op.length(o),h=o.attributes||{},d=!1,c=!1;if(o.insert!=null){if(n.retain(l),typeof o.insert=="string"){let g=o.insert;c=!g.endsWith(` -`)&&(t<=a||!!this.scroll.descendant(rt,a)[0]),this.scroll.insertAt(a,g);let[x,v]=this.scroll.line(a),b=Yt({},Xt(x));if(x instanceof ke){let[E]=x.descendant(Je,v);E&&(b=Yt(b,Xt(E)))}h=$e.AttributeMap.diff(b,h)||{}}else if(typeof o.insert=="object"){let g=Object.keys(o.insert)[0];if(g==null)return a;let x=this.scroll.query(g,Y.INLINE)!=null;if(x)(t<=a||this.scroll.descendant(rt,a)[0])&&(c=!0);else if(a>0){let[v,b]=this.scroll.descendant(Je,a-1);v instanceof Ve?v.value()[b]!==` -`&&(d=!0):v instanceof Ue&&v.statics.scope===Y.INLINE_BLOT&&(d=!0)}if(this.scroll.insertAt(a,g,o.insert[g]),x){let[v]=this.scroll.descendant(Je,a);if(v){let b=Yt({},Xt(v));h=$e.AttributeMap.diff(b,h)||{}}}}t+=l}else if(n.push(o),o.retain!==null&&typeof o.retain=="object"){let g=Object.keys(o.retain)[0];if(g==null)return a;this.scroll.updateEmbedAt(a,g,o.retain[g])}Object.keys(h).forEach(g=>{this.scroll.formatAt(a,l,g,h[g])});let f=d?1:0,m=c?1:0;return t+=f+m,n.retain(f),n.delete(m),a+l+f+m},0),n.reduce((a,o)=>typeof o.delete=="number"?(this.scroll.deleteAt(a,o.delete),a):a+$e.Op.length(o),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(r)}deleteText(e,t){return this.scroll.deleteAt(e,t),this.update(new $e.default().retain(e).delete(t))}formatLine(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(r).forEach(s=>{this.scroll.lines(e,Math.max(t,1)).forEach(a=>{a.format(s,r[s])})}),this.scroll.optimize();let n=new $e.default().retain(e).retain(t,er(r));return this.update(n)}formatText(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(r).forEach(s=>{this.scroll.formatAt(e,t,s,r[s])});let n=new $e.default().retain(e).retain(t,er(r));return this.update(n)}getContents(e,t){return this.delta.slice(e,e+t)}getDelta(){return this.scroll.lines().reduce((e,t)=>e.concat(t.delta()),new $e.default)}getFormat(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=[],n=[];t===0?this.scroll.path(e).forEach(o=>{let[l]=o;l instanceof ke?r.push(l):l instanceof Je&&n.push(l)}):(r=this.scroll.lines(e,t),n=this.scroll.descendants(Je,e,t));let[s,a]=[r,n].map(o=>{let l=o.shift();if(l==null)return{};let h=Xt(l);for(;Object.keys(h).length>0;){let d=o.shift();if(d==null)return h;h=PR(Xt(d),h)}return h});return{...s,...a}}getHTML(e,t){let[r,n]=this.scroll.line(e);if(r){let s=r.length();return r.length()>=n+t&&!(n===0&&t===s)?sl(r,n,t,!0):sl(this.scroll,e,t,!0)}return""}getText(e,t){return this.getContents(e,t).filter(r=>typeof r.insert=="string").map(r=>r.insert).join("")}insertContents(e,t){let r=d9(t),n=new $e.default().retain(e).concat(r);return this.scroll.insertContents(e,r),this.update(n)}insertEmbed(e,t,r){return this.scroll.insertAt(e,t,r),this.update(new $e.default().retain(e).insert({[t]:r}))}insertText(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return t=t.replace(/\r\n/g,` +`,attributes:t.attributes}),n&&e.push({insert:n,attributes:t.attributes})}):e.push(t)}),e}var Ze,QO,Nm,G9,V9=T(()=>{kn();Re();Ze=pt(pi(),1);zi();Dn();Ll();Kr();Dl();QO=/^[ -~]*$/,Nm=class{constructor(e){this.scroll=e,this.delta=this.getDelta()}applyDelta(e){this.scroll.update();let t=this.scroll.length();this.scroll.batchStart();let r=$9(e),n=new Ze.default;return eB(r.ops.slice()).reduce((a,o)=>{let l=Ze.Op.length(o),h=o.attributes||{},d=!1,c=!1;if(o.insert!=null){if(n.retain(l),typeof o.insert=="string"){let g=o.insert;c=!g.endsWith(` +`)&&(t<=a||!!this.scroll.descendant(ft,a)[0]),this.scroll.insertAt(a,g);let[x,y]=this.scroll.line(a),b=ri({},ai(x));if(x instanceof De){let[S]=x.descendant(dt,y);S&&(b=ri(b,ai(S)))}h=Ze.AttributeMap.diff(b,h)||{}}else if(typeof o.insert=="object"){let g=Object.keys(o.insert)[0];if(g==null)return a;let x=this.scroll.query(g,X.INLINE)!=null;if(x)(t<=a||this.scroll.descendant(ft,a)[0])&&(c=!0);else if(a>0){let[y,b]=this.scroll.descendant(dt,a-1);y instanceof nt?y.value()[b]!==` +`&&(d=!0):y instanceof Ke&&y.statics.scope===X.INLINE_BLOT&&(d=!0)}if(this.scroll.insertAt(a,g,o.insert[g]),x){let[y]=this.scroll.descendant(dt,a);if(y){let b=ri({},ai(y));h=Ze.AttributeMap.diff(b,h)||{}}}}t+=l}else if(n.push(o),o.retain!==null&&typeof o.retain=="object"){let g=Object.keys(o.retain)[0];if(g==null)return a;this.scroll.updateEmbedAt(a,g,o.retain[g])}Object.keys(h).forEach(g=>{this.scroll.formatAt(a,l,g,h[g])});let f=d?1:0,m=c?1:0;return t+=f+m,n.retain(f),n.delete(m),a+l+f+m},0),n.reduce((a,o)=>typeof o.delete=="number"?(this.scroll.deleteAt(a,o.delete),a):a+Ze.Op.length(o),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(r)}deleteText(e,t){return this.scroll.deleteAt(e,t),this.update(new Ze.default().retain(e).delete(t))}formatLine(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(r).forEach(s=>{this.scroll.lines(e,Math.max(t,1)).forEach(a=>{a.format(s,r[s])})}),this.scroll.optimize();let n=new Ze.default().retain(e).retain(t,yr(r));return this.update(n)}formatText(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(r).forEach(s=>{this.scroll.formatAt(e,t,s,r[s])});let n=new Ze.default().retain(e).retain(t,yr(r));return this.update(n)}getContents(e,t){return this.delta.slice(e,e+t)}getDelta(){return this.scroll.lines().reduce((e,t)=>e.concat(t.delta()),new Ze.default)}getFormat(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=[],n=[];t===0?this.scroll.path(e).forEach(o=>{let[l]=o;l instanceof De?r.push(l):l instanceof dt&&n.push(l)}):(r=this.scroll.lines(e,t),n=this.scroll.descendants(dt,e,t));let[s,a]=[r,n].map(o=>{let l=o.shift();if(l==null)return{};let h=ai(l);for(;Object.keys(h).length>0;){let d=o.shift();if(d==null)return h;h=JO(ai(d),h)}return h});return{...s,...a}}getHTML(e,t){let[r,n]=this.scroll.line(e);if(r){let s=r.length();return r.length()>=n+t&&!(n===0&&t===s)?Ol(r,n,t,!0):Ol(this.scroll,e,t,!0)}return""}getText(e,t){return this.getContents(e,t).filter(r=>typeof r.insert=="string").map(r=>r.insert).join("")}insertContents(e,t){let r=$9(t),n=new Ze.default().retain(e).concat(r);return this.scroll.insertContents(e,r),this.update(n)}insertEmbed(e,t,r){return this.scroll.insertAt(e,t,r),this.update(new Ze.default().retain(e).insert({[t]:r}))}insertText(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return t=t.replace(/\r\n/g,` `).replace(/\r/g,` -`),this.scroll.insertAt(e,t),Object.keys(r).forEach(n=>{this.scroll.formatAt(e,t.length,n,r[n])}),this.update(new $e.default().retain(e).insert(t,er(r)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;let e=this.scroll.children.head;if(e?.statics.blotName!==ke.blotName)return!1;let t=e;return t.children.length>1?!1:t.children.head instanceof pt}removeFormat(e,t){let r=this.getText(e,t),[n,s]=this.scroll.line(e+t),a=0,o=new $e.default;n!=null&&(a=n.length()-s,o=n.delta().slice(s,s+a-1).insert(` -`));let h=this.getContents(e,t+a).diff(new $e.default().insert(r).concat(o)),d=new $e.default().retain(e).concat(h);return this.applyDelta(d)}update(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,n=this.delta;if(t.length===1&&t[0].type==="characterData"&&t[0].target.data.match(BR)&&this.scroll.find(t[0].target)){let s=this.scroll.find(t[0].target),a=Xt(s),o=s.offset(this.scroll),l=t[0].oldValue.replace(gn.CONTENTS,""),h=new $e.default().insert(l),d=new $e.default().insert(s.value()),c=r&&{oldRange:c9(r.oldRange,-o),newRange:c9(r.newRange,-o)};e=new $e.default().retain(o).concat(h.diff(d,c)).reduce((m,g)=>g.insert?m.insert(g.insert,a):m.push(g),new $e.default),this.delta=n.compose(e)}else this.delta=this.getDelta(),(!e||!Wn(n.compose(e),this.delta))&&(e=n.diff(this.delta,r));return e}};u9=Tf});var id,je,Ti=M(()=>{id=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=e,this.options=t}};P(id,"DEFAULTS",{});je=id});var rd,Nf,ya,nd=M(()=>{Ae();zr();rd="\uFEFF",Nf=class extends Ue{constructor(e,t){super(e,t),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(r=>{this.contentNode.appendChild(r)}),this.leftGuard=document.createTextNode(rd),this.rightGuard=document.createTextNode(rd),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(e,t){return e===this.leftGuard?0:e===this.rightGuard?1:super.index(e,t)}restore(e){let t=null,r,n=e.data.split(rd).join("");if(e===this.leftGuard)if(this.prev instanceof Ve){let s=this.prev.length();this.prev.insertAt(s,n),t={startNode:this.prev.domNode,startOffset:s+n.length}}else r=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(r),this),t={startNode:r,startOffset:n.length};else e===this.rightGuard&&(this.next instanceof Ve?(this.next.insertAt(0,n),t={startNode:this.next.domNode,startOffset:n.length}):(r=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(r),this.next),t={startNode:r,startOffset:n.length}));return e.data=rd,t}update(e,t){e.forEach(r=>{if(r.type==="characterData"&&(r.target===this.leftGuard||r.target===this.rightGuard)){let n=this.restore(r.target);n&&(t.range=n)}})}},ya=Nf});var Ef,m9,p9=M(()=>{nd();Rr();Ef=class{constructor(e,t){P(this,"isComposing",!1);this.scroll=e,this.emitter=t,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",e=>{this.isComposing||this.handleCompositionStart(e)}),this.scroll.domNode.addEventListener("compositionend",e=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(e)})})}handleCompositionStart(e){let t=e.target instanceof Node?this.scroll.find(e.target,!0):null;t&&!(t instanceof ya)&&(this.emitter.emit(K.events.COMPOSITION_BEFORE_START,e),this.scroll.batchStart(),this.emitter.emit(K.events.COMPOSITION_START,e),this.isComposing=!0)}handleCompositionEnd(e){this.emitter.emit(K.events.COMPOSITION_BEFORE_END,e),this.scroll.batchEnd(),this.emitter.emit(K.events.COMPOSITION_END,e),this.isComposing=!1}},m9=Ef});var al,Sf,ba,Af=M(()=>{al=class al{constructor(e,t){P(this,"modules",{});this.quill=e,this.options=t}init(){Object.keys(this.options.modules).forEach(e=>{this.modules[e]==null&&this.addModule(e)})}addModule(e){let t=this.quill.constructor.import(`modules/${e}`);return this.modules[e]=new t(this.quill,this.options.modules[e]||{}),this.modules[e]}};P(al,"DEFAULTS",{modules:{}}),P(al,"themes",{default:al});Sf=al,ba=Sf});var qR,HR,sd,g9,UR,x9,v9=M(()=>{qR=i=>i.parentElement||i.getRootNode().host||null,HR=i=>{let e=i.getBoundingClientRect(),t="offsetWidth"in i&&Math.abs(e.width)/i.offsetWidth||1,r="offsetHeight"in i&&Math.abs(e.height)/i.offsetHeight||1;return{top:e.top,right:e.left+i.clientWidth*t,bottom:e.top+i.clientHeight*r,left:e.left}},sd=i=>{let e=parseInt(i,10);return Number.isNaN(e)?0:e},g9=(i,e,t,r,n,s)=>ir?0:ir?e-i>r-t?i+n-t:e-r+s:0,UR=(i,e)=>{let t=i.ownerDocument,r=e,n=i;for(;n;){let s=n===t.body,a=s?{top:0,right:window.visualViewport?.width??t.documentElement.clientWidth,bottom:window.visualViewport?.height??t.documentElement.clientHeight,left:0}:HR(n),o=getComputedStyle(n),l=g9(r.left,r.right,a.left,a.right,sd(o.scrollPaddingLeft),sd(o.scrollPaddingRight)),h=g9(r.top,r.bottom,a.top,a.bottom,sd(o.scrollPaddingTop),sd(o.scrollPaddingBottom));if(l||h)if(s)t.defaultView?.scrollBy(l,h);else{let{scrollLeft:d,scrollTop:c}=n;h&&(n.scrollTop+=h),l&&(n.scrollLeft+=l);let f=n.scrollLeft-d,m=n.scrollTop-c;r={left:r.left-f,top:r.top-m,right:r.right-f,bottom:r.bottom-m}}n=s||o.position==="fixed"?null:qR(n)}},x9=UR});var $R,jR,GR,y9,b9=M(()=>{Ae();$R=100,jR=["block","break","cursor","inline","scroll","text"],GR=(i,e,t)=>{let r=new cn;return jR.forEach(n=>{let s=e.query(n);s&&r.register(s)}),i.forEach(n=>{let s=e.query(n);s||t.error(`Cannot register "${n}" specified in "formats" config. Are you sure it was registered?`);let a=0;for(;s;)if(r.register(s),s="blotName"in s?s.requiredContainer??null:null,a+=1,a>$R){t.error(`Cycle detected in registering blot requiredContainer: "${n}"`);break}}),r},y9=GR});function w9(i){return typeof i=="string"?document.querySelector(i):i}function kf(i){return Object.entries(i??{}).reduce((e,t)=>{let[r,n]=t;return{...e,[r]:n===!0?{}:n}},{})}function M9(i){return Object.fromEntries(Object.entries(i).filter(e=>e[1]!==void 0))}function YR(i,e){let t=w9(i);if(!t)throw new Error("Invalid Quill container");let n=!e.theme||e.theme===R.DEFAULTS.theme?ba:R.import(`themes/${e.theme}`);if(!n)throw new Error(`Invalid theme ${e.theme}. Did you register it?`);let{modules:s,...a}=R.DEFAULTS,{modules:o,...l}=n.DEFAULTS,h=kf(e.modules);h!=null&&h.toolbar&&h.toolbar.constructor!==Object&&(h={...h,toolbar:{container:h.toolbar}});let d=Yt({},kf(s),kf(o),h),c={...a,...M9(l),...M9(e)},f=e.registry;return f?e.formats&&wa.warn('Ignoring "formats" option because "registry" is specified'):f=e.formats?y9(e.formats,c.registry,wa):c.registry,{...c,registry:f,container:t,theme:n,modules:Object.entries(d).reduce((m,g)=>{let[x,v]=g;if(!v)return m;let b=R.import(`modules/${x}`);return b==null?(wa.error(`Cannot load ${x} module. Are you sure you registered it?`),m):{...m,[x]:Yt({},b.DEFAULTS||{},v)}},{}),bounds:w9(c.bounds)}}function Bi(i,e,t,r){if(!this.isEnabled()&&e===K.sources.USER&&!this.allowReadOnlyEdits)return new xn.default;let n=t==null?null:this.getSelection(),s=this.editor.delta,a=i();if(n!=null&&(t===!0&&(t=n.index),r==null?n=T9(n,a,e):r!==0&&(n=T9(n,t,r,e)),this.setSelection(n,K.sources.SILENT)),a.length()>0){let o=[K.events.TEXT_CHANGE,a,s,e];this.emitter.emit(K.events.EDITOR_CHANGE,...o),e!==K.sources.SILENT&&this.emitter.emit(...o)}return a}function Dr(i,e,t,r,n){let s={};return typeof i.index=="number"&&typeof i.length=="number"?typeof e!="number"?(n=r,r=t,t=e,e=i.length,i=i.index):(e=i.length,i=i.index):typeof e!="number"&&(n=r,r=t,t=e,e=0),typeof t=="object"?(s=t,n=r):typeof t=="string"&&(r!=null?s[t]=r:n=t),n=n||K.sources.API,[i,e,s,n]}function T9(i,e,t,r){let n=typeof t=="number"?t:0;if(i==null)return null;let s,a;return e&&typeof e.transformPosition=="function"?[s,a]=[i.index,i.index+i.length].map(o=>e.transformPosition(o,r!==K.sources.USER)):[s,a]=[i.index,i.index+i.length].map(o=>o=0?o+n:Math.max(e,o+n)),new Lt(s,a-s)}var xn,wa,ad,Pi,R,Kt=M(()=>{ln();Ae();xn=ot(si(),1);f9();Rr();mf();ns();Ti();nl();p9();Af();v9();b9();wa=ai("quill"),ad=new cn;Wt.uiClass="ql-ui";Pi=class Pi{static debug(e){e===!0&&(e="log"),ai.level(e)}static find(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return il.get(e)||ad.find(e,t)}static import(e){return this.imports[e]==null&&wa.error(`Cannot import ${e}. Are you sure it was registered?`),this.imports[e]}static register(){if(typeof(arguments.length<=0?void 0:arguments[0])!="string"){let e=arguments.length<=0?void 0:arguments[0],t=!!(!(arguments.length<=1)&&arguments[1]),r="attrName"in e?e.attrName:e.blotName;typeof r=="string"?this.register(`formats/${r}`,e,t):Object.keys(e).forEach(n=>{this.register(n,e[n],t)})}else{let e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],r=!!(!(arguments.length<=2)&&arguments[2]);this.imports[e]!=null&&!r&&wa.warn(`Overwriting ${e} with`,t),this.imports[e]=t,(e.startsWith("blots/")||e.startsWith("formats/"))&&t&&typeof t!="boolean"&&t.blotName!=="abstract"&&ad.register(t),typeof t.register=="function"&&t.register(ad)}}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=YR(e,t),this.container=this.options.container,this.container==null){wa.error("Invalid Quill container",e);return}this.options.debug&&Pi.debug(this.options.debug);let r=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",il.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new K;let n=Uo.blotName,s=this.options.registry.query(n);if(!s||!("blotName"in s))throw new Error(`Cannot initialize Quill without "${n}" blot`);if(this.scroll=new s(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new u9(this.scroll),this.selection=new h9(this.scroll,this.emitter),this.composition=new m9(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.uploader=this.theme.addModule("uploader"),this.theme.addModule("input"),this.theme.addModule("uiNode"),this.theme.init(),this.emitter.on(K.events.EDITOR_CHANGE,a=>{a===K.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(K.events.SCROLL_UPDATE,(a,o)=>{let l=this.selection.lastRange,[h]=this.selection.getRange(),d=l&&h?{oldRange:l,newRange:h}:void 0;Bi.call(this,()=>this.editor.update(null,o,d),a)}),this.emitter.on(K.events.SCROLL_EMBED_UPDATE,(a,o)=>{let l=this.selection.lastRange,[h]=this.selection.getRange(),d=l&&h?{oldRange:l,newRange:h}:void 0;Bi.call(this,()=>{let c=new xn.default().retain(a.offset(this)).retain({[a.statics.blotName]:o});return this.editor.update(c,[],d)},Pi.sources.USER)}),r){let a=this.clipboard.convert({html:`${r}


    `,text:` -`});this.setContents(a)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof e=="string"){let r=e;e=document.createElement("div"),e.classList.add(r)}return this.container.insertBefore(e,t),e}blur(){this.selection.setRange(null)}deleteText(e,t,r){return[e,t,,r]=Dr(e,t,r),Bi.call(this,()=>this.editor.deleteText(e,t),r,e,-1*t)}disable(){this.enable(!1)}editReadOnly(e){this.allowReadOnlyEdits=!0;let t=e();return this.allowReadOnlyEdits=!1,t}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(e),this.container.classList.toggle("ql-disabled",!e)}focus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.selection.focus(),e.preventScroll||this.scrollSelectionIntoView()}format(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:K.sources.API;return Bi.call(this,()=>{let n=this.getSelection(!0),s=new xn.default;if(n==null)return s;if(this.scroll.query(e,Y.BLOCK))s=this.editor.formatLine(n.index,n.length,{[e]:t});else{if(n.length===0)return this.selection.format(e,t),s;s=this.editor.formatText(n.index,n.length,{[e]:t})}return this.setSelection(n,K.sources.SILENT),s},r)}formatLine(e,t,r,n,s){let a;return[e,t,a,s]=Dr(e,t,r,n,s),Bi.call(this,()=>this.editor.formatLine(e,t,a),s,e,0)}formatText(e,t,r,n,s){let a;return[e,t,a,s]=Dr(e,t,r,n,s),Bi.call(this,()=>this.editor.formatText(e,t,a),s,e,0)}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=null;if(typeof e=="number"?r=this.selection.getBounds(e,t):r=this.selection.getBounds(e.index,e.length),!r)return null;let n=this.container.getBoundingClientRect();return{bottom:r.bottom-n.top,height:r.height,left:r.left-n.left,right:r.right-n.left,top:r.top-n.top,width:r.width}}getContents(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-e;return[e,t]=Dr(e,t),this.editor.getContents(e,t)}getFormat(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof e=="number"?this.editor.getFormat(e,t):this.editor.getFormat(e.index,e.length)}getIndex(e){return e.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(e){return this.scroll.leaf(e)}getLine(e){return this.scroll.line(e)}getLines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof e!="number"?this.scroll.lines(e.index,e.length):this.scroll.lines(e,t)}getModule(e){return this.theme.modules[e]}getSelection(){return arguments.length>0&&arguments[0]!==void 0&&arguments[0]&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e=="number"&&(t=t??this.getLength()-e),[e,t]=Dr(e,t),this.editor.getHTML(e,t)}getText(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e=="number"&&(t=t??this.getLength()-e),[e,t]=Dr(e,t),this.editor.getText(e,t)}hasFocus(){return this.selection.hasFocus()}insertEmbed(e,t,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Pi.sources.API;return Bi.call(this,()=>this.editor.insertEmbed(e,t,r),n,e)}insertText(e,t,r,n,s){let a;return[e,,a,s]=Dr(e,0,r,n,s),Bi.call(this,()=>this.editor.insertText(e,t,a),s,e,t.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(e,t,r){return[e,t,,r]=Dr(e,t,r),Bi.call(this,()=>this.editor.removeFormat(e,t),r,e)}scrollRectIntoView(e){x9(this.root,e)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){let e=this.selection.lastRange,t=e&&this.selection.getBounds(e.index,e.length);t&&this.scrollRectIntoView(t)}setContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:K.sources.API;return Bi.call(this,()=>{e=new xn.default(e);let r=this.getLength(),n=this.editor.deleteText(0,r),s=this.editor.insertContents(0,e),a=this.editor.deleteText(this.getLength()-1,1);return n.compose(s).compose(a)},t)}setSelection(e,t,r){e==null?this.selection.setRange(null,t||Pi.sources.API):([e,t,,r]=Dr(e,t,r),this.selection.setRange(new Lt(Math.max(0,e),t),r),r!==K.sources.SILENT&&this.scrollSelectionIntoView())}setText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:K.sources.API,r=new xn.default().insert(e);return this.setContents(r,t)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:K.sources.USER,t=this.scroll.update(e);return this.selection.update(e),t}updateContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:K.sources.API;return Bi.call(this,()=>(e=new xn.default(e),this.editor.applyDelta(e)),t,!0)}};P(Pi,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:ad,theme:"default"}),P(Pi,"events",K.events),P(Pi,"sources",K.sources),P(Pi,"version","2.0.3"),P(Pi,"imports",{delta:xn.default,parchment:$o,"core/module":je,"core/theme":ba});R=Pi});var Cf,Ni,Ma=M(()=>{Ae();Cf=class extends ha{},Ni=Cf});function N9(i){return i instanceof ke||i instanceof rt}function E9(i){return typeof i.updateContent=="function"}function _f(i,e,t){t.reduce((r,n)=>{let s=Ei.Op.length(n),a=n.attributes||{};if(n.insert!=null){if(typeof n.insert=="string"){let o=n.insert;i.insertAt(r,o);let[l]=i.descendant(Je,r),h=Xt(l);a=Ei.AttributeMap.diff(h,a)||{}}else if(typeof n.insert=="object"){let o=Object.keys(n.insert)[0];if(o==null)return r;if(i.insertAt(r,o,n.insert[o]),i.scroll.query(o,Y.INLINE)!=null){let[h]=i.descendant(Je,r),d=Xt(h);a=Ei.AttributeMap.diff(d,a)||{}}}}return Object.keys(a).forEach(o=>{i.formatAt(r,s,o,a[o])}),r+s},e)}var Ei,vn,S9,A9=M(()=>{Ae();Ei=ot(si(),1);Rr();wi();pn();Ma();vn=class extends Uo{constructor(e,t,r){let{emitter:n}=r;super(e,t),this.emitter=n,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",s=>this.handleDragStart(s))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;let e=this.batch;this.batch=!1,this.update(e)}emitMount(e){this.emitter.emit(K.events.SCROLL_BLOT_MOUNT,e)}emitUnmount(e){this.emitter.emit(K.events.SCROLL_BLOT_UNMOUNT,e)}emitEmbedUpdate(e,t){this.emitter.emit(K.events.SCROLL_EMBED_UPDATE,e,t)}deleteAt(e,t){let[r,n]=this.line(e),[s]=this.line(e+t);if(super.deleteAt(e,t),s!=null&&r!==s&&n>0){if(r instanceof rt||s instanceof rt){this.optimize();return}let a=s.children.head instanceof pt?null:s.children.head;r.moveChildren(s,a),r.remove()}this.optimize()}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",e?"true":"false")}formatAt(e,t,r,n){super.formatAt(e,t,r,n),this.optimize()}insertAt(e,t,r){if(e>=this.length())if(r==null||this.scroll.query(t,Y.BLOCK)==null){let n=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(n),r==null&&t.endsWith(` -`)?n.insertAt(0,t.slice(0,-1),r):n.insertAt(0,t,r)}else{let n=this.scroll.create(t,r);this.appendChild(n)}else super.insertAt(e,t,r);this.optimize()}insertBefore(e,t){if(e.statics.scope===Y.INLINE_BLOT){let r=this.scroll.create(this.statics.defaultChild.blotName);r.appendChild(e),super.insertBefore(r,t)}else super.insertBefore(e,t)}insertContents(e,t){let r=this.deltaToRenderBlocks(t.concat(new Ei.default().insert(` -`))),n=r.pop();if(n==null)return;this.batchStart();let s=r.shift();if(s){let l=s.type==="block"&&(s.delta.length()===0||!this.descendant(rt,e)[0]&&e{this.formatAt(c-1,1,g,m[g])}),e=c}let[a,o]=this.children.find(e);if(r.length&&(a&&(a=a.split(o),o=0),r.forEach(l=>{if(l.type==="block"){let h=this.createBlock(l.attributes,a||void 0);_f(h,0,l.delta)}else{let h=this.create(l.key,l.value);this.insertBefore(h,a||void 0),Object.keys(l.attributes).forEach(d=>{h.format(d,l.attributes[d])})}})),n.type==="block"&&n.delta.length()){let l=a?a.offset(a.scroll)+o:this.length();_f(this,l,n.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(e){let t=this.path(e).pop();if(!t)return[null,-1];let[r,n]=t;return r instanceof Je?[r,n]:[null,-1]}line(e){return e===this.length()?this.line(e-1):this.descendant(N9,e)}lines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,r=(n,s,a)=>{let o=[],l=a;return n.children.forEachAt(s,a,(h,d,c)=>{N9(h)?o.push(h):h instanceof ha&&(o=o.concat(r(h,d,l))),l-=c}),o};return r(this,e,t)}optimize(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(e,t),e.length>0&&this.emitter.emit(K.events.SCROLL_OPTIMIZE,e,t))}path(e){return super.path(e).slice(1)}remove(){}update(e){if(this.batch){Array.isArray(e)&&(this.batch=this.batch.concat(e));return}let t=K.sources.USER;typeof e=="string"&&(t=e),Array.isArray(e)||(e=this.observer.takeRecords()),e=e.filter(r=>{let{target:n}=r,s=this.find(n,!0);return s&&!E9(s)}),e.length>0&&this.emitter.emit(K.events.SCROLL_BEFORE_UPDATE,t,e),super.update(e.concat([])),e.length>0&&this.emitter.emit(K.events.SCROLL_UPDATE,t,e)}updateEmbedAt(e,t,r){let[n]=this.descendant(s=>s instanceof rt,e);n&&n.statics.blotName===t&&E9(n)&&n.updateContent(r)}handleDragStart(e){e.preventDefault()}deltaToRenderBlocks(e){let t=[],r=new Ei.default;return e.forEach(n=>{let s=n?.insert;if(s)if(typeof s=="string"){let a=s.split(` -`);a.slice(0,-1).forEach(l=>{r.insert(l,n.attributes),t.push({type:"block",delta:r,attributes:n.attributes??{}}),r=new Ei.default});let o=a[a.length-1];o&&r.insert(o,n.attributes)}else{let a=Object.keys(s)[0];if(!a)return;this.query(a,Y.INLINE)?r.push(n):(r.length()&&t.push({type:"block",delta:r,attributes:{}}),r=new Ei.default,t.push({type:"blockEmbed",key:a,value:s[a],attributes:n.attributes??{}}))}}),r.length()&&t.push({type:"block",delta:r,attributes:{}}),t}createBlock(e,t){let r,n={};Object.entries(e).forEach(o=>{let[l,h]=o;this.query(l,Y.BLOCK&Y.BLOT)!=null?r=l:n[l]=h});let s=this.create(r||this.statics.defaultChild.blotName,r?e[r]:void 0);this.insertBefore(s,t||void 0);let a=s.length();return Object.entries(n).forEach(o=>{let[l,h]=o;s.formatAt(0,a,l,h)}),s}};P(vn,"blotName","scroll"),P(vn,"className","ql-editor"),P(vn,"tagName","DIV"),P(vn,"defaultChild",ke),P(vn,"allowedChildren",[ke,rt,Ni]);S9=vn});var Lf,k9,zf,od,If=M(()=>{Ae();Lf={scope:Y.BLOCK,whitelist:["right","center","justify"]},k9=new kt("align","align",Lf),zf=new Qe("align","ql-align",Lf),od=new Vt("align","text-align",Lf)});var ol,C9,ll,ld=M(()=>{Ae();ol=class extends Vt{value(e){let t=super.value(e);return t.startsWith("rgb(")?(t=t.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${t.split(",").map(n=>`00${parseInt(n,10).toString(16)}`.slice(-2)).join("")}`):t}},C9=new Qe("color","ql-color",{scope:Y.INLINE}),ll=new ol("color","color",{scope:Y.INLINE})});var _9,hl,Rf=M(()=>{Ae();ld();_9=new Qe("background","ql-bg",{scope:Y.INLINE}),hl=new ol("background","background-color",{scope:Y.INLINE})});var rr,Xe,Ta,hd=M(()=>{wi();pn();el();Ir();zr();Ma();Kt();rr=class extends Ni{static create(e){let t=super.create(e);return t.setAttribute("spellcheck","false"),t}code(e,t){return this.children.map(r=>r.length()<=1?"":r.domNode.innerText).join(` +`),this.scroll.insertAt(e,t),Object.keys(r).forEach(n=>{this.scroll.formatAt(e,t.length,n,r[n])}),this.update(new Ze.default().retain(e).insert(t,yr(r)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;let e=this.scroll.children.head;if(e?.statics.blotName!==De.blotName)return!1;let t=e;return t.children.length>1?!1:t.children.head instanceof Et}removeFormat(e,t){let r=this.getText(e,t),[n,s]=this.scroll.line(e+t),a=0,o=new Ze.default;n!=null&&(a=n.length()-s,o=n.delta().slice(s,s+a-1).insert(` +`));let h=this.getContents(e,t+a).diff(new Ze.default().insert(r).concat(o)),d=new Ze.default().retain(e).concat(h);return this.applyDelta(d)}update(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,n=this.delta;if(t.length===1&&t[0].type==="characterData"&&t[0].target.data.match(QO)&&this.scroll.find(t[0].target)){let s=this.scroll.find(t[0].target),a=ai(s),o=s.offset(this.scroll),l=t[0].oldValue.replace(On.CONTENTS,""),h=new Ze.default().insert(l),d=new Ze.default().insert(s.value()),c=r&&{oldRange:j9(r.oldRange,-o),newRange:j9(r.newRange,-o)};e=new Ze.default().retain(o).concat(h.diff(d,c)).reduce((m,g)=>g.insert?m.insert(g.insert,a):m.push(g),new Ze.default),this.delta=n.compose(e)}else this.delta=this.getDelta(),(!e||!ys(n.compose(e),this.delta))&&(e=n.diff(this.delta,r));return e}};G9=Nm});var Gd,Qe,Di=T(()=>{Gd=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=e,this.options=t}};U(Gd,"DEFAULTS",{});Qe=Gd});var Vd,Em,Ka,Wd=T(()=>{Re();Kr();Vd="\uFEFF",Em=class extends Ke{constructor(e,t){super(e,t),this.contentNode=document.createElement("span"),this.contentNode.setAttribute("contenteditable","false"),Array.from(this.domNode.childNodes).forEach(r=>{this.contentNode.appendChild(r)}),this.leftGuard=document.createTextNode(Vd),this.rightGuard=document.createTextNode(Vd),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(e,t){return e===this.leftGuard?0:e===this.rightGuard?1:super.index(e,t)}restore(e){let t=null,r,n=e.data.split(Vd).join("");if(e===this.leftGuard)if(this.prev instanceof nt){let s=this.prev.length();this.prev.insertAt(s,n),t={startNode:this.prev.domNode,startOffset:s+n.length}}else r=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(r),this),t={startNode:r,startOffset:n.length};else e===this.rightGuard&&(this.next instanceof nt?(this.next.insertAt(0,n),t={startNode:this.next.domNode,startOffset:n.length}):(r=document.createTextNode(n),this.parent.insertBefore(this.scroll.create(r),this.next),t={startNode:r,startOffset:n.length}));return e.data=Vd,t}update(e,t){e.forEach(r=>{if(r.type==="characterData"&&(r.target===this.leftGuard||r.target===this.rightGuard)){let n=this.restore(r.target);n&&(t.range=n)}})}},Ka=Em});var Sm,W9,Y9=T(()=>{Wd();Qr();Sm=class{constructor(e,t){U(this,"isComposing",!1);this.scroll=e,this.emitter=t,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener("compositionstart",e=>{this.isComposing||this.handleCompositionStart(e)}),this.scroll.domNode.addEventListener("compositionend",e=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(e)})})}handleCompositionStart(e){let t=e.target instanceof Node?this.scroll.find(e.target,!0):null;t&&!(t instanceof Ka)&&(this.emitter.emit(J.events.COMPOSITION_BEFORE_START,e),this.scroll.batchStart(),this.emitter.emit(J.events.COMPOSITION_START,e),this.isComposing=!0)}handleCompositionEnd(e){this.emitter.emit(J.events.COMPOSITION_BEFORE_END,e),this.scroll.batchEnd(),this.emitter.emit(J.events.COMPOSITION_END,e),this.isComposing=!1}},W9=Sm});var Bl,Am,Za,km=T(()=>{Bl=class Bl{constructor(e,t){U(this,"modules",{});this.quill=e,this.options=t}init(){Object.keys(this.options.modules).forEach(e=>{this.modules[e]==null&&this.addModule(e)})}addModule(e){let t=this.quill.constructor.import(`modules/${e}`);return this.modules[e]=new t(this.quill,this.options.modules[e]||{}),this.modules[e]}};U(Bl,"DEFAULTS",{modules:{}}),U(Bl,"themes",{default:Bl});Am=Bl,Za=Am});var tB,iB,Yd,X9,rB,K9,Z9=T(()=>{tB=i=>i.parentElement||i.getRootNode().host||null,iB=i=>{let e=i.getBoundingClientRect(),t="offsetWidth"in i&&Math.abs(e.width)/i.offsetWidth||1,r="offsetHeight"in i&&Math.abs(e.height)/i.offsetHeight||1;return{top:e.top,right:e.left+i.clientWidth*t,bottom:e.top+i.clientHeight*r,left:e.left}},Yd=i=>{let e=parseInt(i,10);return Number.isNaN(e)?0:e},X9=(i,e,t,r,n,s)=>ir?0:ir?e-i>r-t?i+n-t:e-r+s:0,rB=(i,e)=>{let t=i.ownerDocument,r=e,n=i;for(;n;){let s=n===t.body,a=s?{top:0,right:window.visualViewport?.width??t.documentElement.clientWidth,bottom:window.visualViewport?.height??t.documentElement.clientHeight,left:0}:iB(n),o=getComputedStyle(n),l=X9(r.left,r.right,a.left,a.right,Yd(o.scrollPaddingLeft),Yd(o.scrollPaddingRight)),h=X9(r.top,r.bottom,a.top,a.bottom,Yd(o.scrollPaddingTop),Yd(o.scrollPaddingBottom));if(l||h)if(s)t.defaultView?.scrollBy(l,h);else{let{scrollLeft:d,scrollTop:c}=n;h&&(n.scrollTop+=h),l&&(n.scrollLeft+=l);let f=n.scrollLeft-d,m=n.scrollTop-c;r={left:r.left-f,top:r.top-m,right:r.right-f,bottom:r.bottom-m}}n=s||o.position==="fixed"?null:tB(n)}},K9=rB});var nB,sB,aB,Q9,J9=T(()=>{Re();nB=100,sB=["block","break","cursor","inline","scroll","text"],aB=(i,e,t)=>{let r=new Ln;return sB.forEach(n=>{let s=e.query(n);s&&r.register(s)}),i.forEach(n=>{let s=e.query(n);s||t.error(`Cannot register "${n}" specified in "formats" config. Are you sure it was registered?`);let a=0;for(;s;)if(r.register(s),s="blotName"in s?s.requiredContainer??null:null,a+=1,a>nB){t.error(`Cycle detected in registering blot requiredContainer: "${n}"`);break}}),r},Q9=aB});function ey(i){return typeof i=="string"?document.querySelector(i):i}function Cm(i){return Object.entries(i??{}).reduce((e,t)=>{let[r,n]=t;return{...e,[r]:n===!0?{}:n}},{})}function ty(i){return Object.fromEntries(Object.entries(i).filter(e=>e[1]!==void 0))}function oB(i,e){let t=ey(i);if(!t)throw new Error("Invalid Quill container");let n=!e.theme||e.theme===B.DEFAULTS.theme?Za:B.import(`themes/${e.theme}`);if(!n)throw new Error(`Invalid theme ${e.theme}. Did you register it?`);let{modules:s,...a}=B.DEFAULTS,{modules:o,...l}=n.DEFAULTS,h=Cm(e.modules);h!=null&&h.toolbar&&h.toolbar.constructor!==Object&&(h={...h,toolbar:{container:h.toolbar}});let d=ri({},Cm(s),Cm(o),h),c={...a,...ty(l),...ty(e)},f=e.registry;return f?e.formats&&Qa.warn('Ignoring "formats" option because "registry" is specified'):f=e.formats?Q9(e.formats,c.registry,Qa):c.registry,{...c,registry:f,container:t,theme:n,modules:Object.entries(d).reduce((m,g)=>{let[x,y]=g;if(!y)return m;let b=B.import(`modules/${x}`);return b==null?(Qa.error(`Cannot load ${x} module. Are you sure you registered it?`),m):{...m,[x]:ri({},b.DEFAULTS||{},y)}},{}),bounds:ey(c.bounds)}}function Qi(i,e,t,r){if(!this.isEnabled()&&e===J.sources.USER&&!this.allowReadOnlyEdits)return new Bn.default;let n=t==null?null:this.getSelection(),s=this.editor.delta,a=i();if(n!=null&&(t===!0&&(t=n.index),r==null?n=iy(n,a,e):r!==0&&(n=iy(n,t,r,e)),this.setSelection(n,J.sources.SILENT)),a.length()>0){let o=[J.events.TEXT_CHANGE,a,s,e];this.emitter.emit(J.events.EDITOR_CHANGE,...o),e!==J.sources.SILENT&&this.emitter.emit(...o)}return a}function Jr(i,e,t,r,n){let s={};return typeof i.index=="number"&&typeof i.length=="number"?typeof e!="number"?(n=r,r=t,t=e,e=i.length,i=i.index):(e=i.length,i=i.index):typeof e!="number"&&(n=r,r=t,t=e,e=0),typeof t=="object"?(s=t,n=r):typeof t=="string"&&(r!=null?s[t]=r:n=t),n=n||J.sources.API,[i,e,s,n]}function iy(i,e,t,r){let n=typeof t=="number"?t:0;if(i==null)return null;let s,a;return e&&typeof e.transformPosition=="function"?[s,a]=[i.index,i.index+i.length].map(o=>e.transformPosition(o,r!==J.sources.USER)):[s,a]=[i.index,i.index+i.length].map(o=>o=0?o+n:Math.max(e,o+n)),new $t(s,a-s)}var Bn,Qa,Xd,Ji,B,oi=T(()=>{kn();Re();Bn=pt(pi(),1);V9();Qr();pm();Cs();Di();Dl();Y9();km();Z9();J9();Qa=gi("quill"),Xd=new Ln;ni.uiClass="ql-ui";Ji=class Ji{static debug(e){e===!0&&(e="log"),gi.level(e)}static find(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return zl.get(e)||Xd.find(e,t)}static import(e){return this.imports[e]==null&&Qa.error(`Cannot import ${e}. Are you sure it was registered?`),this.imports[e]}static register(){if(typeof(arguments.length<=0?void 0:arguments[0])!="string"){let e=arguments.length<=0?void 0:arguments[0],t=!!(!(arguments.length<=1)&&arguments[1]),r="attrName"in e?e.attrName:e.blotName;typeof r=="string"?this.register(`formats/${r}`,e,t):Object.keys(e).forEach(n=>{this.register(n,e[n],t)})}else{let e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],r=!!(!(arguments.length<=2)&&arguments[2]);this.imports[e]!=null&&!r&&Qa.warn(`Overwriting ${e} with`,t),this.imports[e]=t,(e.startsWith("blots/")||e.startsWith("formats/"))&&t&&typeof t!="boolean"&&t.blotName!=="abstract"&&Xd.register(t),typeof t.register=="function"&&t.register(Xd)}}constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=oB(e,t),this.container=this.options.container,this.container==null){Qa.error("Invalid Quill container",e);return}this.options.debug&&Ji.debug(this.options.debug);let r=this.container.innerHTML.trim();this.container.classList.add("ql-container"),this.container.innerHTML="",zl.set(this.container,this),this.root=this.addContainer("ql-editor"),this.root.classList.add("ql-blank"),this.emitter=new J;let n=vl.blotName,s=this.options.registry.query(n);if(!s||!("blotName"in s))throw new Error(`Cannot initialize Quill without "${n}" blot`);if(this.scroll=new s(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new G9(this.scroll),this.selection=new U9(this.scroll,this.emitter),this.composition=new W9(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule("keyboard"),this.clipboard=this.theme.addModule("clipboard"),this.history=this.theme.addModule("history"),this.uploader=this.theme.addModule("uploader"),this.theme.addModule("input"),this.theme.addModule("uiNode"),this.theme.init(),this.emitter.on(J.events.EDITOR_CHANGE,a=>{a===J.events.TEXT_CHANGE&&this.root.classList.toggle("ql-blank",this.editor.isBlank())}),this.emitter.on(J.events.SCROLL_UPDATE,(a,o)=>{let l=this.selection.lastRange,[h]=this.selection.getRange(),d=l&&h?{oldRange:l,newRange:h}:void 0;Qi.call(this,()=>this.editor.update(null,o,d),a)}),this.emitter.on(J.events.SCROLL_EMBED_UPDATE,(a,o)=>{let l=this.selection.lastRange,[h]=this.selection.getRange(),d=l&&h?{oldRange:l,newRange:h}:void 0;Qi.call(this,()=>{let c=new Bn.default().retain(a.offset(this)).retain({[a.statics.blotName]:o});return this.editor.update(c,[],d)},Ji.sources.USER)}),r){let a=this.clipboard.convert({html:`${r}


    `,text:` +`});this.setContents(a)}this.history.clear(),this.options.placeholder&&this.root.setAttribute("data-placeholder",this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof e=="string"){let r=e;e=document.createElement("div"),e.classList.add(r)}return this.container.insertBefore(e,t),e}blur(){this.selection.setRange(null)}deleteText(e,t,r){return[e,t,,r]=Jr(e,t,r),Qi.call(this,()=>this.editor.deleteText(e,t),r,e,-1*t)}disable(){this.enable(!1)}editReadOnly(e){this.allowReadOnlyEdits=!0;let t=e();return this.allowReadOnlyEdits=!1,t}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(e),this.container.classList.toggle("ql-disabled",!e)}focus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.selection.focus(),e.preventScroll||this.scrollSelectionIntoView()}format(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:J.sources.API;return Qi.call(this,()=>{let n=this.getSelection(!0),s=new Bn.default;if(n==null)return s;if(this.scroll.query(e,X.BLOCK))s=this.editor.formatLine(n.index,n.length,{[e]:t});else{if(n.length===0)return this.selection.format(e,t),s;s=this.editor.formatText(n.index,n.length,{[e]:t})}return this.setSelection(n,J.sources.SILENT),s},r)}formatLine(e,t,r,n,s){let a;return[e,t,a,s]=Jr(e,t,r,n,s),Qi.call(this,()=>this.editor.formatLine(e,t,a),s,e,0)}formatText(e,t,r,n,s){let a;return[e,t,a,s]=Jr(e,t,r,n,s),Qi.call(this,()=>this.editor.formatText(e,t,a),s,e,0)}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=null;if(typeof e=="number"?r=this.selection.getBounds(e,t):r=this.selection.getBounds(e.index,e.length),!r)return null;let n=this.container.getBoundingClientRect();return{bottom:r.bottom-n.top,height:r.height,left:r.left-n.left,right:r.right-n.left,top:r.top-n.top,width:r.width}}getContents(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-e;return[e,t]=Jr(e,t),this.editor.getContents(e,t)}getFormat(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof e=="number"?this.editor.getFormat(e,t):this.editor.getFormat(e.index,e.length)}getIndex(e){return e.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(e){return this.scroll.leaf(e)}getLine(e){return this.scroll.line(e)}getLines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof e!="number"?this.scroll.lines(e.index,e.length):this.scroll.lines(e,t)}getModule(e){return this.theme.modules[e]}getSelection(){return arguments.length>0&&arguments[0]!==void 0&&arguments[0]&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e=="number"&&(t=t??this.getLength()-e),[e,t]=Jr(e,t),this.editor.getHTML(e,t)}getText(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e=="number"&&(t=t??this.getLength()-e),[e,t]=Jr(e,t),this.editor.getText(e,t)}hasFocus(){return this.selection.hasFocus()}insertEmbed(e,t,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ji.sources.API;return Qi.call(this,()=>this.editor.insertEmbed(e,t,r),n,e)}insertText(e,t,r,n,s){let a;return[e,,a,s]=Jr(e,0,r,n,s),Qi.call(this,()=>this.editor.insertText(e,t,a),s,e,t.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(e,t,r){return[e,t,,r]=Jr(e,t,r),Qi.call(this,()=>this.editor.removeFormat(e,t),r,e)}scrollRectIntoView(e){K9(this.root,e)}scrollIntoView(){console.warn("Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead."),this.scrollSelectionIntoView()}scrollSelectionIntoView(){let e=this.selection.lastRange,t=e&&this.selection.getBounds(e.index,e.length);t&&this.scrollRectIntoView(t)}setContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:J.sources.API;return Qi.call(this,()=>{e=new Bn.default(e);let r=this.getLength(),n=this.editor.deleteText(0,r),s=this.editor.insertContents(0,e),a=this.editor.deleteText(this.getLength()-1,1);return n.compose(s).compose(a)},t)}setSelection(e,t,r){e==null?this.selection.setRange(null,t||Ji.sources.API):([e,t,,r]=Jr(e,t,r),this.selection.setRange(new $t(Math.max(0,e),t),r),r!==J.sources.SILENT&&this.scrollSelectionIntoView())}setText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:J.sources.API,r=new Bn.default().insert(e);return this.setContents(r,t)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:J.sources.USER,t=this.scroll.update(e);return this.selection.update(e),t}updateContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:J.sources.API;return Qi.call(this,()=>(e=new Bn.default(e),this.editor.applyDelta(e)),t,!0)}};U(Ji,"DEFAULTS",{bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:"",readOnly:!1,registry:Xd,theme:"default"}),U(Ji,"events",J.events),U(Ji,"sources",J.sources),U(Ji,"version","2.0.3"),U(Ji,"imports",{delta:Bn.default,parchment:bl,"core/module":Qe,"core/theme":Za});B=Ji});var _m,Oi,Ja=T(()=>{Re();_m=class extends qa{},Oi=_m});function ry(i){return i instanceof De||i instanceof ft}function ny(i){return typeof i.updateContent=="function"}function Lm(i,e,t){t.reduce((r,n)=>{let s=Bi.Op.length(n),a=n.attributes||{};if(n.insert!=null){if(typeof n.insert=="string"){let o=n.insert;i.insertAt(r,o);let[l]=i.descendant(dt,r),h=ai(l);a=Bi.AttributeMap.diff(h,a)||{}}else if(typeof n.insert=="object"){let o=Object.keys(n.insert)[0];if(o==null)return r;if(i.insertAt(r,o,n.insert[o]),i.scroll.query(o,X.INLINE)!=null){let[h]=i.descendant(dt,r),d=ai(h);a=Bi.AttributeMap.diff(d,a)||{}}}}return Object.keys(a).forEach(o=>{i.formatAt(r,s,o,a[o])}),r+s},e)}var Bi,Pn,sy,ay=T(()=>{Re();Bi=pt(pi(),1);Qr();zi();Dn();Ja();Pn=class extends vl{constructor(e,t,r){let{emitter:n}=r;super(e,t),this.emitter=n,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener("dragstart",s=>this.handleDragStart(s))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;let e=this.batch;this.batch=!1,this.update(e)}emitMount(e){this.emitter.emit(J.events.SCROLL_BLOT_MOUNT,e)}emitUnmount(e){this.emitter.emit(J.events.SCROLL_BLOT_UNMOUNT,e)}emitEmbedUpdate(e,t){this.emitter.emit(J.events.SCROLL_EMBED_UPDATE,e,t)}deleteAt(e,t){let[r,n]=this.line(e),[s]=this.line(e+t);if(super.deleteAt(e,t),s!=null&&r!==s&&n>0){if(r instanceof ft||s instanceof ft){this.optimize();return}let a=s.children.head instanceof Et?null:s.children.head;r.moveChildren(s,a),r.remove()}this.optimize()}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute("contenteditable",e?"true":"false")}formatAt(e,t,r,n){super.formatAt(e,t,r,n),this.optimize()}insertAt(e,t,r){if(e>=this.length())if(r==null||this.scroll.query(t,X.BLOCK)==null){let n=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(n),r==null&&t.endsWith(` +`)?n.insertAt(0,t.slice(0,-1),r):n.insertAt(0,t,r)}else{let n=this.scroll.create(t,r);this.appendChild(n)}else super.insertAt(e,t,r);this.optimize()}insertBefore(e,t){if(e.statics.scope===X.INLINE_BLOT){let r=this.scroll.create(this.statics.defaultChild.blotName);r.appendChild(e),super.insertBefore(r,t)}else super.insertBefore(e,t)}insertContents(e,t){let r=this.deltaToRenderBlocks(t.concat(new Bi.default().insert(` +`))),n=r.pop();if(n==null)return;this.batchStart();let s=r.shift();if(s){let l=s.type==="block"&&(s.delta.length()===0||!this.descendant(ft,e)[0]&&e{this.formatAt(c-1,1,g,m[g])}),e=c}let[a,o]=this.children.find(e);if(r.length&&(a&&(a=a.split(o),o=0),r.forEach(l=>{if(l.type==="block"){let h=this.createBlock(l.attributes,a||void 0);Lm(h,0,l.delta)}else{let h=this.create(l.key,l.value);this.insertBefore(h,a||void 0),Object.keys(l.attributes).forEach(d=>{h.format(d,l.attributes[d])})}})),n.type==="block"&&n.delta.length()){let l=a?a.offset(a.scroll)+o:this.length();Lm(this,l,n.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute("contenteditable")==="true"}leaf(e){let t=this.path(e).pop();if(!t)return[null,-1];let[r,n]=t;return r instanceof dt?[r,n]:[null,-1]}line(e){return e===this.length()?this.line(e-1):this.descendant(ry,e)}lines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,r=(n,s,a)=>{let o=[],l=a;return n.children.forEachAt(s,a,(h,d,c)=>{ry(h)?o.push(h):h instanceof qa&&(o=o.concat(r(h,d,l))),l-=c}),o};return r(this,e,t)}optimize(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(e,t),e.length>0&&this.emitter.emit(J.events.SCROLL_OPTIMIZE,e,t))}path(e){return super.path(e).slice(1)}remove(){}update(e){if(this.batch){Array.isArray(e)&&(this.batch=this.batch.concat(e));return}let t=J.sources.USER;typeof e=="string"&&(t=e),Array.isArray(e)||(e=this.observer.takeRecords()),e=e.filter(r=>{let{target:n}=r,s=this.find(n,!0);return s&&!ny(s)}),e.length>0&&this.emitter.emit(J.events.SCROLL_BEFORE_UPDATE,t,e),super.update(e.concat([])),e.length>0&&this.emitter.emit(J.events.SCROLL_UPDATE,t,e)}updateEmbedAt(e,t,r){let[n]=this.descendant(s=>s instanceof ft,e);n&&n.statics.blotName===t&&ny(n)&&n.updateContent(r)}handleDragStart(e){e.preventDefault()}deltaToRenderBlocks(e){let t=[],r=new Bi.default;return e.forEach(n=>{let s=n?.insert;if(s)if(typeof s=="string"){let a=s.split(` +`);a.slice(0,-1).forEach(l=>{r.insert(l,n.attributes),t.push({type:"block",delta:r,attributes:n.attributes??{}}),r=new Bi.default});let o=a[a.length-1];o&&r.insert(o,n.attributes)}else{let a=Object.keys(s)[0];if(!a)return;this.query(a,X.INLINE)?r.push(n):(r.length()&&t.push({type:"block",delta:r,attributes:{}}),r=new Bi.default,t.push({type:"blockEmbed",key:a,value:s[a],attributes:n.attributes??{}}))}}),r.length()&&t.push({type:"block",delta:r,attributes:{}}),t}createBlock(e,t){let r,n={};Object.entries(e).forEach(o=>{let[l,h]=o;this.query(l,X.BLOCK&X.BLOT)!=null?r=l:n[l]=h});let s=this.create(r||this.statics.defaultChild.blotName,r?e[r]:void 0);this.insertBefore(s,t||void 0);let a=s.length();return Object.entries(n).forEach(o=>{let[l,h]=o;s.formatAt(0,a,l,h)}),s}};U(Pn,"blotName","scroll"),U(Pn,"className","ql-editor"),U(Pn,"tagName","DIV"),U(Pn,"defaultChild",De),U(Pn,"allowedChildren",[De,ft,Oi]);sy=Pn});var Im,oy,zm,Kd,Rm=T(()=>{Re();Im={scope:X.BLOCK,whitelist:["right","center","justify"]},oy=new qt("align","align",Im),zm=new ht("align","ql-align",Im),Kd=new si("align","text-align",Im)});var Pl,ly,Fl,Zd=T(()=>{Re();Pl=class extends si{value(e){let t=super.value(e);return t.startsWith("rgb(")?(t=t.replace(/^[^\d]+/,"").replace(/[^\d]+$/,""),`#${t.split(",").map(n=>`00${parseInt(n,10).toString(16)}`.slice(-2)).join("")}`):t}},ly=new ht("color","ql-color",{scope:X.INLINE}),Fl=new Pl("color","color",{scope:X.INLINE})});var hy,ql,Dm=T(()=>{Re();Zd();hy=new ht("background","ql-bg",{scope:X.INLINE}),ql=new Pl("background","background-color",{scope:X.INLINE})});var wr,st,eo,Qd=T(()=>{zi();Dn();Ll();Zr();Kr();Ja();oi();wr=class extends Oi{static create(e){let t=super.create(e);return t.setAttribute("spellcheck","false"),t}code(e,t){return this.children.map(r=>r.length()<=1?"":r.domNode.innerText).join(` `).slice(e,e+t)}html(e,t){return`
    -${rs(this.code(e,t))}
    -
    `}},Xe=class extends ke{static register(){R.register(rr)}};P(Xe,"TAB"," ");Ta=class extends gt{};Ta.blotName="code";Ta.tagName="CODE";Xe.blotName="code-block";Xe.className="ql-code-block";Xe.tagName="DIV";rr.blotName="code-block-container";rr.className="ql-code-block-container";rr.tagName="DIV";rr.allowedChildren=[Xe];Xe.allowedChildren=[Ve,pt,gn];Xe.requiredContainer=rr});var Df,dd,Of,cd,Bf=M(()=>{Ae();Df={scope:Y.BLOCK,whitelist:["rtl"]},dd=new kt("direction","dir",Df),Of=new Qe("direction","ql-direction",Df),cd=new Vt("direction","direction",Df)});var L9,Ff,Pf,ud,qf=M(()=>{Ae();L9={scope:Y.INLINE,whitelist:["serif","monospace"]},Ff=new Qe("font","ql-font",L9),Pf=class extends Vt{value(e){return super.value(e).replace(/["']/g,"")}},ud=new Pf("font","font-family",L9)});var Hf,fd,Uf=M(()=>{Ae();Hf=new Qe("size","ql-size",{scope:Y.INLINE,whitelist:["small","large","huge"]}),fd=new Vt("size","font-size",{scope:Y.INLINE,whitelist:["10px","18px","32px"]})});function z9(i){return{key:"Tab",shiftKey:!i,format:{"code-block":!0},handler(e,t){let{event:r}=t,n=this.quill.scroll.query("code-block"),{TAB:s}=n;if(e.length===0&&!r.shiftKey){this.quill.insertText(e.index,s,R.sources.USER),this.quill.setSelection(e.index+s.length,R.sources.SILENT);return}let a=e.length===0?this.quill.getLines(e.index,1):this.quill.getLines(e),{index:o,length:l}=e;a.forEach((h,d)=>{i?(h.insertAt(0,s),d===0?o+=s.length:l+=s.length):h.domNode.textContent.startsWith(s)&&(h.deleteAt(0,s.length),d===0?o-=s.length:l-=s.length)}),this.quill.update(R.sources.USER),this.quill.setSelection(o,l,R.sources.SILENT)}}}function md(i,e){return{key:i,shiftKey:e,altKey:null,[i==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(r){let{index:n}=r;i==="ArrowRight"&&(n+=r.length+1);let[s]=this.quill.getLeaf(n);return s instanceof Ue?(i==="ArrowLeft"?e?this.quill.setSelection(r.index-1,r.length+1,R.sources.USER):this.quill.setSelection(r.index-1,R.sources.USER):e?this.quill.setSelection(r.index,r.length+1,R.sources.USER):this.quill.setSelection(r.index+r.length+1,R.sources.USER),!1):!0}}}function $f(i){return{key:i[0],shortKey:!0,handler(e,t){this.quill.format(i,!t.format[i],R.sources.USER)}}}function I9(i){return{key:i?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(e,t){let r=i?"prev":"next",n=t.line,s=n.parent[r];if(s!=null){if(s.statics.blotName==="table-row"){let a=s.children.head,o=n;for(;o.prev!=null;)o=o.prev,a=a.next;let l=a.offset(this.quill.scroll)+Math.min(t.offset,a.length()-1);this.quill.setSelection(l,0,R.sources.USER)}}else{let a=n.table()[r];a!=null&&(i?this.quill.setSelection(a.offset(this.quill.scroll)+a.length()-1,0,R.sources.USER):this.quill.setSelection(a.offset(this.quill.scroll),0,R.sources.USER))}return!1}}}function KR(i){if(typeof i=="string"||typeof i=="number")i={key:i};else if(typeof i=="object")i=er(i);else return null;return i.shortKey&&(i[VR]=i.shortKey,delete i.shortKey),i}function cl(i){let{quill:e,range:t}=i,r=e.getLines(t),n={};if(r.length>1){let s=r[0].formats(),a=r[r.length-1].formats();n=vt.AttributeMap.diff(a,s)||{}}e.deleteText(t,R.sources.USER),Object.keys(n).length>0&&e.formatLine(t.index,1,n,R.sources.USER),e.setSelection(t.index,R.sources.SILENT)}function ZR(i,e,t,r){return e.prev==null&&e.next==null?t.prev==null&&t.next==null?r===0?-1:1:t.prev==null?-1:1:e.prev==null?-1:e.next==null?1:null}var vt,WR,VR,dl,XR,pd=M(()=>{ln();vt=ot(si(),1);Ae();Kt();ns();Ti();WR=ai("quill:keyboard"),VR=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",dl=class i extends je{static match(e,t){return["altKey","ctrlKey","metaKey","shiftKey"].some(r=>!!t[r]!==e[r]&&t[r]!==null)?!1:t.key===e.key||t.key===e.which}constructor(e,t){super(e,t),this.bindings={},Object.keys(this.options.bindings).forEach(r=>{this.options.bindings[r]&&this.addBinding(this.options.bindings[r])}),this.addBinding({key:"Enter",shiftKey:null},this.handleEnter),this.addBinding({key:"Enter",metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:"Backspace"},{collapsed:!0},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0},this.handleDelete)):(this.addBinding({key:"Backspace"},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:"Backspace"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Delete"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Backspace",altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=KR(e);if(n==null){WR.warn("Attempted to add invalid keyboard binding",n);return}typeof t=="function"&&(t={handler:t}),typeof r=="function"&&(r={handler:r}),(Array.isArray(n.key)?n.key:[n.key]).forEach(a=>{let o={...n,key:a,...t,...r};this.bindings[o.key]=this.bindings[o.key]||[],this.bindings[o.key].push(o)})}listen(){this.quill.root.addEventListener("keydown",e=>{if(e.defaultPrevented||e.isComposing||e.keyCode===229&&(e.key==="Enter"||e.key==="Backspace"))return;let n=(this.bindings[e.key]||[]).concat(this.bindings[e.which]||[]).filter(b=>i.match(e,b));if(n.length===0)return;let s=R.find(e.target,!0);if(s&&s.scroll!==this.quill.scroll)return;let a=this.quill.getSelection();if(a==null||!this.quill.hasFocus())return;let[o,l]=this.quill.getLine(a.index),[h,d]=this.quill.getLeaf(a.index),[c,f]=a.length===0?[h,d]:this.quill.getLeaf(a.index+a.length),m=h instanceof da?h.value().slice(0,d):"",g=c instanceof da?c.value().slice(f):"",x={collapsed:a.length===0,empty:a.length===0&&o.length()<=1,format:this.quill.getFormat(a),line:o,offset:l,prefix:m,suffix:g,event:e};n.some(b=>{if(b.collapsed!=null&&b.collapsed!==x.collapsed||b.empty!=null&&b.empty!==x.empty||b.offset!=null&&b.offset!==x.offset)return!1;if(Array.isArray(b.format)){if(b.format.every(E=>x.format[E]==null))return!1}else if(typeof b.format=="object"&&!Object.keys(b.format).every(E=>b.format[E]===!0?x.format[E]!=null:b.format[E]===!1?x.format[E]==null:Wn(b.format[E],x.format[E])))return!1;return b.prefix!=null&&!b.prefix.test(x.prefix)||b.suffix!=null&&!b.suffix.test(x.suffix)?!1:b.handler.call(this,a,x,b)!==!0})&&e.preventDefault()})}handleBackspace(e,t){let r=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(t.prefix)?2:1;if(e.index===0||this.quill.getLength()<=1)return;let n={},[s]=this.quill.getLine(e.index),a=new vt.default().retain(e.index-r).delete(r);if(t.offset===0){let[o]=this.quill.getLine(e.index-1);if(o&&!(o.statics.blotName==="block"&&o.length()<=1)){let h=s.formats(),d=this.quill.getFormat(e.index-1,1);if(n=vt.AttributeMap.diff(h,d)||{},Object.keys(n).length>0){let c=new vt.default().retain(e.index+s.length()-2).retain(1,n);a=a.compose(c)}}}this.quill.updateContents(a,R.sources.USER),this.quill.focus()}handleDelete(e,t){let r=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(t.suffix)?2:1;if(e.index>=this.quill.getLength()-r)return;let n={},[s]=this.quill.getLine(e.index),a=new vt.default().retain(e.index).delete(r);if(t.offset>=s.length()-1){let[o]=this.quill.getLine(e.index+1);if(o){let l=s.formats(),h=this.quill.getFormat(e.index,1);n=vt.AttributeMap.diff(l,h)||{},Object.keys(n).length>0&&(a=a.retain(o.length()-1).retain(1,n))}}this.quill.updateContents(a,R.sources.USER),this.quill.focus()}handleDeleteRange(e){cl({range:e,quill:this.quill}),this.quill.focus()}handleEnter(e,t){let r=Object.keys(t.format).reduce((s,a)=>(this.quill.scroll.query(a,Y.BLOCK)&&!Array.isArray(t.format[a])&&(s[a]=t.format[a]),s),{}),n=new vt.default().retain(e.index).delete(e.length).insert(` -`,r);this.quill.updateContents(n,R.sources.USER),this.quill.setSelection(e.index+1,R.sources.SILENT),this.quill.focus()}},XR={bindings:{bold:$f("bold"),italic:$f("italic"),underline:$f("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(i,e){return e.collapsed&&e.offset!==0?!0:(this.quill.format("indent","+1",R.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(i,e){return e.collapsed&&e.offset!==0?!0:(this.quill.format("indent","-1",R.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(i,e){e.format.indent!=null?this.quill.format("indent","-1",R.sources.USER):e.format.list!=null&&this.quill.format("list",!1,R.sources.USER)}},"indent code-block":z9(!0),"outdent code-block":z9(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(i){this.quill.deleteText(i.index-1,1,R.sources.USER)}},tab:{key:"Tab",handler(i,e){if(e.format.table)return!0;this.quill.history.cutoff();let t=new vt.default().retain(i.index).delete(i.length).insert(" ");return this.quill.updateContents(t,R.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index+1,R.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,R.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(i,e){let t={list:!1};e.format.indent&&(t.indent=!1),this.quill.formatLine(i.index,i.length,t,R.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(i){let[e,t]=this.quill.getLine(i.index),r={...e.formats(),list:"checked"},n=new vt.default().retain(i.index).insert(` -`,r).retain(e.length()-t-1).retain(1,{list:"unchecked"});this.quill.updateContents(n,R.sources.USER),this.quill.setSelection(i.index+1,R.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(i,e){let[t,r]=this.quill.getLine(i.index),n=new vt.default().retain(i.index).insert(` -`,e.format).retain(t.length()-r-1).retain(1,{header:null});this.quill.updateContents(n,R.sources.USER),this.quill.setSelection(i.index+1,R.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:"Backspace",format:["table"],collapsed:!0,offset:0,handler(){}},"table delete":{key:"Delete",format:["table"],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:"Enter",shiftKey:null,format:["table"],handler(i){let e=this.quill.getModule("table");if(e){let[t,r,n,s]=e.getTable(i),a=ZR(t,r,n,s);if(a==null)return;let o=t.offset();if(a<0){let l=new vt.default().retain(o).insert(` -`);this.quill.updateContents(l,R.sources.USER),this.quill.setSelection(i.index+1,i.length,R.sources.SILENT)}else if(a>0){o+=t.length();let l=new vt.default().retain(o).insert(` -`);this.quill.updateContents(l,R.sources.USER),this.quill.setSelection(o,R.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(i,e){let{event:t,line:r}=e,n=r.offset(this.quill.scroll);t.shiftKey?this.quill.setSelection(n-1,R.sources.USER):this.quill.setSelection(n+r.length(),R.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(i,e){if(this.quill.scroll.query("list")==null)return!0;let{length:t}=e.prefix,[r,n]=this.quill.getLine(i.index);if(n>t)return!0;let s;switch(e.prefix.trim()){case"[]":case"[ ]":s="unchecked";break;case"[x]":s="checked";break;case"-":case"*":s="bullet";break;default:s="ordered"}this.quill.insertText(i.index," ",R.sources.USER),this.quill.history.cutoff();let a=new vt.default().retain(i.index-n).delete(t+1).retain(r.length()-2-n).retain(1,{list:s});return this.quill.updateContents(a,R.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index-t,R.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(i){let[e,t]=this.quill.getLine(i.index),r=2,n=e;for(;n!=null&&n.length()<=1&&n.formats()["code-block"];)if(n=n.prev,r-=1,r<=0){let s=new vt.default().retain(i.index+e.length()-t-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(s,R.sources.USER),this.quill.setSelection(i.index-1,R.sources.SILENT),!1}return!0}},"embed left":md("ArrowLeft",!1),"embed left shift":md("ArrowLeft",!0),"embed right":md("ArrowRight",!1),"embed right shift":md("ArrowRight",!0),"table down":I9(!1),"table up":I9(!0)}};dl.DEFAULTS=XR});function jf(i){i.querySelector('[id^="docs-internal-guid-"]')&&(tD(i),eD(i))}var QR,JR,R9,eD,tD,D9=M(()=>{QR=/font-weight:\s*normal/,JR=["P","OL","UL"],R9=i=>i&&JR.includes(i.tagName),eD=i=>{Array.from(i.querySelectorAll("br")).filter(e=>R9(e.previousElementSibling)&&R9(e.nextElementSibling)).forEach(e=>{e.parentNode?.removeChild(e)})},tD=i=>{Array.from(i.querySelectorAll('b[style*="font-weight"]')).filter(e=>e.getAttribute("style")?.match(QR)).forEach(e=>{let t=i.createDocumentFragment();t.append(...e.childNodes),e.parentNode?.replaceChild(t,e)})}});function Gf(i){i.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&aD(i)}var iD,rD,nD,sD,aD,O9=M(()=>{iD=/\bmso-list:[^;]*ignore/i,rD=/\bmso-list:[^;]*\bl(\d+)/i,nD=/\bmso-list:[^;]*\blevel(\d+)/i,sD=(i,e)=>{let t=i.getAttribute("style"),r=t?.match(rD);if(!r)return null;let n=Number(r[1]),s=t?.match(nD),a=s?Number(s[1]):1,o=new RegExp(`@list l${n}:level${a}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),l=e.match(o),h=l&&l[1]==="bullet"?"bullet":"ordered";return{id:n,indent:a,type:h,element:i}},aD=i=>{let e=Array.from(i.querySelectorAll("[style*=mso-list]")),t=[],r=[];e.forEach(a=>{(a.getAttribute("style")||"").match(iD)?t.push(a):r.push(a)}),t.forEach(a=>a.parentNode?.removeChild(a));let n=i.documentElement.innerHTML,s=r.map(a=>sD(a,n)).filter(a=>a);for(;s.length;){let a=[],o=s.shift();for(;o;)a.push(o),o=s.length&&s[0]?.element===o.element.nextElementSibling&&s[0].id===o.id?s.shift():null;let l=document.createElement("ul");a.forEach(c=>{let f=document.createElement("li");f.setAttribute("data-list",c.type),c.indent>1&&f.setAttribute("class",`ql-indent-${c.indent-1}`),f.innerHTML=c.element.innerHTML,l.appendChild(f)});let h=a[0]?.element,{parentNode:d}=h??{};h&&d?.replaceChild(l,h),a.slice(1).forEach(c=>{let{element:f}=c;d?.removeChild(f)})}}});var oD,lD,B9,P9=M(()=>{D9();O9();oD=[Gf,jf],lD=i=>{i.documentElement&&oD.forEach(e=>{e(i)})},B9=lD});function ss(i,e,t,r){return r.query(e)?i.reduce((n,s)=>{if(!s.insert)return n;if(s.attributes&&s.attributes[e])return n.push(s);let a=t?{[e]:t}:{};return n.insert(s.insert,{...a,...s.attributes})},new Zt.default):i}function fl(i,e){let t="";for(let r=i.ops.length-1;r>=0&&t.lengtha(e,s,i),new Zt.default):e.nodeType===e.ELEMENT_NODE?Array.from(e.childNodes||[]).reduce((s,a)=>{let o=xd(i,a,t,r,n);return a.nodeType===e.ELEMENT_NODE&&(o=t.reduce((l,h)=>h(a,l,i),o),o=(n.get(a)||[]).reduce((l,h)=>h(a,l,i),o)),s.concat(o)},new Zt.default):new Zt.default}function Yf(i){return(e,t,r)=>ss(t,i,!0,r)}function fD(i,e,t){let r=kt.keys(i),n=Qe.keys(i),s=Vt.keys(i),a={};return r.concat(n).concat(s).forEach(o=>{let l=t.query(o,Y.ATTRIBUTE);l!=null&&(a[l.attrName]=l.value(i),a[l.attrName])||(l=cD[o],l!=null&&(l.attrName===o||l.keyName===o)&&(a[l.attrName]=l.value(i)||void 0),l=F9[o],l!=null&&(l.attrName===o||l.keyName===o)&&(l=F9[o],a[l.attrName]=l.value(i)||void 0))}),Object.entries(a).reduce((o,l)=>{let[h,d]=l;return ss(o,h,d,t)},e)}function mD(i,e,t){let r=t.query(i);if(r==null)return e;if(r.prototype instanceof Ue){let n={},s=r.value(i);if(s!=null)return n[r.blotName]=s,new Zt.default().insert(n,r.formats(i,t))}else if(r.prototype instanceof Vn&&!fl(e,` +${ks(this.code(e,t))} +`}},st=class extends De{static register(){B.register(wr)}};U(st,"TAB"," ");eo=class extends St{};eo.blotName="code";eo.tagName="CODE";st.blotName="code-block";st.className="ql-code-block";st.tagName="DIV";wr.blotName="code-block-container";wr.className="ql-code-block-container";wr.tagName="DIV";wr.allowedChildren=[st];st.allowedChildren=[nt,Et,On];st.requiredContainer=wr});var Om,Jd,Bm,ec,Pm=T(()=>{Re();Om={scope:X.BLOCK,whitelist:["rtl"]},Jd=new qt("direction","dir",Om),Bm=new ht("direction","ql-direction",Om),ec=new si("direction","direction",Om)});var dy,qm,Fm,tc,Hm=T(()=>{Re();dy={scope:X.INLINE,whitelist:["serif","monospace"]},qm=new ht("font","ql-font",dy),Fm=class extends si{value(e){return super.value(e).replace(/["']/g,"")}},tc=new Fm("font","font-family",dy)});var Um,ic,$m=T(()=>{Re();Um=new ht("size","ql-size",{scope:X.INLINE,whitelist:["small","large","huge"]}),ic=new si("size","font-size",{scope:X.INLINE,whitelist:["10px","18px","32px"]})});function cy(i){return{key:"Tab",shiftKey:!i,format:{"code-block":!0},handler(e,t){let{event:r}=t,n=this.quill.scroll.query("code-block"),{TAB:s}=n;if(e.length===0&&!r.shiftKey){this.quill.insertText(e.index,s,B.sources.USER),this.quill.setSelection(e.index+s.length,B.sources.SILENT);return}let a=e.length===0?this.quill.getLines(e.index,1):this.quill.getLines(e),{index:o,length:l}=e;a.forEach((h,d)=>{i?(h.insertAt(0,s),d===0?o+=s.length:l+=s.length):h.domNode.textContent.startsWith(s)&&(h.deleteAt(0,s.length),d===0?o-=s.length:l-=s.length)}),this.quill.update(B.sources.USER),this.quill.setSelection(o,l,B.sources.SILENT)}}}function rc(i,e){return{key:i,shiftKey:e,altKey:null,[i==="ArrowLeft"?"prefix":"suffix"]:/^$/,handler(r){let{index:n}=r;i==="ArrowRight"&&(n+=r.length+1);let[s]=this.quill.getLeaf(n);return s instanceof Ke?(i==="ArrowLeft"?e?this.quill.setSelection(r.index-1,r.length+1,B.sources.USER):this.quill.setSelection(r.index-1,B.sources.USER):e?this.quill.setSelection(r.index,r.length+1,B.sources.USER):this.quill.setSelection(r.index+r.length+1,B.sources.USER),!1):!0}}}function jm(i){return{key:i[0],shortKey:!0,handler(e,t){this.quill.format(i,!t.format[i],B.sources.USER)}}}function uy(i){return{key:i?"ArrowUp":"ArrowDown",collapsed:!0,format:["table"],handler(e,t){let r=i?"prev":"next",n=t.line,s=n.parent[r];if(s!=null){if(s.statics.blotName==="table-row"){let a=s.children.head,o=n;for(;o.prev!=null;)o=o.prev,a=a.next;let l=a.offset(this.quill.scroll)+Math.min(t.offset,a.length()-1);this.quill.setSelection(l,0,B.sources.USER)}}else{let a=n.table()[r];a!=null&&(i?this.quill.setSelection(a.offset(this.quill.scroll)+a.length()-1,0,B.sources.USER):this.quill.setSelection(a.offset(this.quill.scroll),0,B.sources.USER))}return!1}}}function cB(i){if(typeof i=="string"||typeof i=="number")i={key:i};else if(typeof i=="object")i=yr(i);else return null;return i.shortKey&&(i[hB]=i.shortKey,delete i.shortKey),i}function Ul(i){let{quill:e,range:t}=i,r=e.getLines(t),n={};if(r.length>1){let s=r[0].formats(),a=r[r.length-1].formats();n=kt.AttributeMap.diff(a,s)||{}}e.deleteText(t,B.sources.USER),Object.keys(n).length>0&&e.formatLine(t.index,1,n,B.sources.USER),e.setSelection(t.index,B.sources.SILENT)}function uB(i,e,t,r){return e.prev==null&&e.next==null?t.prev==null&&t.next==null?r===0?-1:1:t.prev==null?-1:1:e.prev==null?-1:e.next==null?1:null}var kt,lB,hB,Hl,dB,nc=T(()=>{kn();kt=pt(pi(),1);Re();oi();Cs();Di();lB=gi("quill:keyboard"),hB=/Mac/i.test(navigator.platform)?"metaKey":"ctrlKey",Hl=class i extends Qe{static match(e,t){return["altKey","ctrlKey","metaKey","shiftKey"].some(r=>!!t[r]!==e[r]&&t[r]!==null)?!1:t.key===e.key||t.key===e.which}constructor(e,t){super(e,t),this.bindings={},Object.keys(this.options.bindings).forEach(r=>{this.options.bindings[r]&&this.addBinding(this.options.bindings[r])}),this.addBinding({key:"Enter",shiftKey:null},this.handleEnter),this.addBinding({key:"Enter",metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:"Backspace"},{collapsed:!0},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0},this.handleDelete)):(this.addBinding({key:"Backspace"},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:"Delete"},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:"Backspace"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Delete"},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:"Backspace",altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=cB(e);if(n==null){lB.warn("Attempted to add invalid keyboard binding",n);return}typeof t=="function"&&(t={handler:t}),typeof r=="function"&&(r={handler:r}),(Array.isArray(n.key)?n.key:[n.key]).forEach(a=>{let o={...n,key:a,...t,...r};this.bindings[o.key]=this.bindings[o.key]||[],this.bindings[o.key].push(o)})}listen(){this.quill.root.addEventListener("keydown",e=>{if(e.defaultPrevented||e.isComposing||e.keyCode===229&&(e.key==="Enter"||e.key==="Backspace"))return;let n=(this.bindings[e.key]||[]).concat(this.bindings[e.which]||[]).filter(b=>i.match(e,b));if(n.length===0)return;let s=B.find(e.target,!0);if(s&&s.scroll!==this.quill.scroll)return;let a=this.quill.getSelection();if(a==null||!this.quill.hasFocus())return;let[o,l]=this.quill.getLine(a.index),[h,d]=this.quill.getLeaf(a.index),[c,f]=a.length===0?[h,d]:this.quill.getLeaf(a.index+a.length),m=h instanceof Ha?h.value().slice(0,d):"",g=c instanceof Ha?c.value().slice(f):"",x={collapsed:a.length===0,empty:a.length===0&&o.length()<=1,format:this.quill.getFormat(a),line:o,offset:l,prefix:m,suffix:g,event:e};n.some(b=>{if(b.collapsed!=null&&b.collapsed!==x.collapsed||b.empty!=null&&b.empty!==x.empty||b.offset!=null&&b.offset!==x.offset)return!1;if(Array.isArray(b.format)){if(b.format.every(S=>x.format[S]==null))return!1}else if(typeof b.format=="object"&&!Object.keys(b.format).every(S=>b.format[S]===!0?x.format[S]!=null:b.format[S]===!1?x.format[S]==null:ys(b.format[S],x.format[S])))return!1;return b.prefix!=null&&!b.prefix.test(x.prefix)||b.suffix!=null&&!b.suffix.test(x.suffix)?!1:b.handler.call(this,a,x,b)!==!0})&&e.preventDefault()})}handleBackspace(e,t){let r=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(t.prefix)?2:1;if(e.index===0||this.quill.getLength()<=1)return;let n={},[s]=this.quill.getLine(e.index),a=new kt.default().retain(e.index-r).delete(r);if(t.offset===0){let[o]=this.quill.getLine(e.index-1);if(o&&!(o.statics.blotName==="block"&&o.length()<=1)){let h=s.formats(),d=this.quill.getFormat(e.index-1,1);if(n=kt.AttributeMap.diff(h,d)||{},Object.keys(n).length>0){let c=new kt.default().retain(e.index+s.length()-2).retain(1,n);a=a.compose(c)}}}this.quill.updateContents(a,B.sources.USER),this.quill.focus()}handleDelete(e,t){let r=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(t.suffix)?2:1;if(e.index>=this.quill.getLength()-r)return;let n={},[s]=this.quill.getLine(e.index),a=new kt.default().retain(e.index).delete(r);if(t.offset>=s.length()-1){let[o]=this.quill.getLine(e.index+1);if(o){let l=s.formats(),h=this.quill.getFormat(e.index,1);n=kt.AttributeMap.diff(l,h)||{},Object.keys(n).length>0&&(a=a.retain(o.length()-1).retain(1,n))}}this.quill.updateContents(a,B.sources.USER),this.quill.focus()}handleDeleteRange(e){Ul({range:e,quill:this.quill}),this.quill.focus()}handleEnter(e,t){let r=Object.keys(t.format).reduce((s,a)=>(this.quill.scroll.query(a,X.BLOCK)&&!Array.isArray(t.format[a])&&(s[a]=t.format[a]),s),{}),n=new kt.default().retain(e.index).delete(e.length).insert(` +`,r);this.quill.updateContents(n,B.sources.USER),this.quill.setSelection(e.index+1,B.sources.SILENT),this.quill.focus()}},dB={bindings:{bold:jm("bold"),italic:jm("italic"),underline:jm("underline"),indent:{key:"Tab",format:["blockquote","indent","list"],handler(i,e){return e.collapsed&&e.offset!==0?!0:(this.quill.format("indent","+1",B.sources.USER),!1)}},outdent:{key:"Tab",shiftKey:!0,format:["blockquote","indent","list"],handler(i,e){return e.collapsed&&e.offset!==0?!0:(this.quill.format("indent","-1",B.sources.USER),!1)}},"outdent backspace":{key:"Backspace",collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:["indent","list"],offset:0,handler(i,e){e.format.indent!=null?this.quill.format("indent","-1",B.sources.USER):e.format.list!=null&&this.quill.format("list",!1,B.sources.USER)}},"indent code-block":cy(!0),"outdent code-block":cy(!1),"remove tab":{key:"Tab",shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(i){this.quill.deleteText(i.index-1,1,B.sources.USER)}},tab:{key:"Tab",handler(i,e){if(e.format.table)return!0;this.quill.history.cutoff();let t=new kt.default().retain(i.index).delete(i.length).insert(" ");return this.quill.updateContents(t,B.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index+1,B.sources.SILENT),!1}},"blockquote empty enter":{key:"Enter",collapsed:!0,format:["blockquote"],empty:!0,handler(){this.quill.format("blockquote",!1,B.sources.USER)}},"list empty enter":{key:"Enter",collapsed:!0,format:["list"],empty:!0,handler(i,e){let t={list:!1};e.format.indent&&(t.indent=!1),this.quill.formatLine(i.index,i.length,t,B.sources.USER)}},"checklist enter":{key:"Enter",collapsed:!0,format:{list:"checked"},handler(i){let[e,t]=this.quill.getLine(i.index),r={...e.formats(),list:"checked"},n=new kt.default().retain(i.index).insert(` +`,r).retain(e.length()-t-1).retain(1,{list:"unchecked"});this.quill.updateContents(n,B.sources.USER),this.quill.setSelection(i.index+1,B.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:"Enter",collapsed:!0,format:["header"],suffix:/^$/,handler(i,e){let[t,r]=this.quill.getLine(i.index),n=new kt.default().retain(i.index).insert(` +`,e.format).retain(t.length()-r-1).retain(1,{header:null});this.quill.updateContents(n,B.sources.USER),this.quill.setSelection(i.index+1,B.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:"Backspace",format:["table"],collapsed:!0,offset:0,handler(){}},"table delete":{key:"Delete",format:["table"],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:"Enter",shiftKey:null,format:["table"],handler(i){let e=this.quill.getModule("table");if(e){let[t,r,n,s]=e.getTable(i),a=uB(t,r,n,s);if(a==null)return;let o=t.offset();if(a<0){let l=new kt.default().retain(o).insert(` +`);this.quill.updateContents(l,B.sources.USER),this.quill.setSelection(i.index+1,i.length,B.sources.SILENT)}else if(a>0){o+=t.length();let l=new kt.default().retain(o).insert(` +`);this.quill.updateContents(l,B.sources.USER),this.quill.setSelection(o,B.sources.USER)}}}},"table tab":{key:"Tab",shiftKey:null,format:["table"],handler(i,e){let{event:t,line:r}=e,n=r.offset(this.quill.scroll);t.shiftKey?this.quill.setSelection(n-1,B.sources.USER):this.quill.setSelection(n+r.length(),B.sources.USER)}},"list autofill":{key:" ",shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(i,e){if(this.quill.scroll.query("list")==null)return!0;let{length:t}=e.prefix,[r,n]=this.quill.getLine(i.index);if(n>t)return!0;let s;switch(e.prefix.trim()){case"[]":case"[ ]":s="unchecked";break;case"[x]":s="checked";break;case"-":case"*":s="bullet";break;default:s="ordered"}this.quill.insertText(i.index," ",B.sources.USER),this.quill.history.cutoff();let a=new kt.default().retain(i.index-n).delete(t+1).retain(r.length()-2-n).retain(1,{list:s});return this.quill.updateContents(a,B.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(i.index-t,B.sources.SILENT),!1}},"code exit":{key:"Enter",collapsed:!0,format:["code-block"],prefix:/^$/,suffix:/^\s*$/,handler(i){let[e,t]=this.quill.getLine(i.index),r=2,n=e;for(;n!=null&&n.length()<=1&&n.formats()["code-block"];)if(n=n.prev,r-=1,r<=0){let s=new kt.default().retain(i.index+e.length()-t-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(s,B.sources.USER),this.quill.setSelection(i.index-1,B.sources.SILENT),!1}return!0}},"embed left":rc("ArrowLeft",!1),"embed left shift":rc("ArrowLeft",!0),"embed right":rc("ArrowRight",!1),"embed right shift":rc("ArrowRight",!0),"table down":uy(!1),"table up":uy(!0)}};Hl.DEFAULTS=dB});function Gm(i){i.querySelector('[id^="docs-internal-guid-"]')&&(gB(i),pB(i))}var fB,mB,fy,pB,gB,my=T(()=>{fB=/font-weight:\s*normal/,mB=["P","OL","UL"],fy=i=>i&&mB.includes(i.tagName),pB=i=>{Array.from(i.querySelectorAll("br")).filter(e=>fy(e.previousElementSibling)&&fy(e.nextElementSibling)).forEach(e=>{e.parentNode?.removeChild(e)})},gB=i=>{Array.from(i.querySelectorAll('b[style*="font-weight"]')).filter(e=>e.getAttribute("style")?.match(fB)).forEach(e=>{let t=i.createDocumentFragment();t.append(...e.childNodes),e.parentNode?.replaceChild(t,e)})}});function Vm(i){i.documentElement.getAttribute("xmlns:w")==="urn:schemas-microsoft-com:office:word"&&wB(i)}var xB,yB,vB,bB,wB,py=T(()=>{xB=/\bmso-list:[^;]*ignore/i,yB=/\bmso-list:[^;]*\bl(\d+)/i,vB=/\bmso-list:[^;]*\blevel(\d+)/i,bB=(i,e)=>{let t=i.getAttribute("style"),r=t?.match(yB);if(!r)return null;let n=Number(r[1]),s=t?.match(vB),a=s?Number(s[1]):1,o=new RegExp(`@list l${n}:level${a}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,"i"),l=e.match(o),h=l&&l[1]==="bullet"?"bullet":"ordered";return{id:n,indent:a,type:h,element:i}},wB=i=>{let e=Array.from(i.querySelectorAll("[style*=mso-list]")),t=[],r=[];e.forEach(a=>{(a.getAttribute("style")||"").match(xB)?t.push(a):r.push(a)}),t.forEach(a=>a.parentNode?.removeChild(a));let n=i.documentElement.innerHTML,s=r.map(a=>bB(a,n)).filter(a=>a);for(;s.length;){let a=[],o=s.shift();for(;o;)a.push(o),o=s.length&&s[0]?.element===o.element.nextElementSibling&&s[0].id===o.id?s.shift():null;let l=document.createElement("ul");a.forEach(c=>{let f=document.createElement("li");f.setAttribute("data-list",c.type),c.indent>1&&f.setAttribute("class",`ql-indent-${c.indent-1}`),f.innerHTML=c.element.innerHTML,l.appendChild(f)});let h=a[0]?.element,{parentNode:d}=h??{};h&&d?.replaceChild(l,h),a.slice(1).forEach(c=>{let{element:f}=c;d?.removeChild(f)})}}});var MB,TB,gy,xy=T(()=>{my();py();MB=[Vm,Gm],TB=i=>{i.documentElement&&MB.forEach(e=>{e(i)})},gy=TB});function _s(i,e,t,r){return r.query(e)?i.reduce((n,s)=>{if(!s.insert)return n;if(s.attributes&&s.attributes[e])return n.push(s);let a=t?{[e]:t}:{};return n.insert(s.insert,{...a,...s.attributes})},new li.default):i}function jl(i,e){let t="";for(let r=i.ops.length-1;r>=0&&t.lengtha(e,s,i),new li.default):e.nodeType===e.ELEMENT_NODE?Array.from(e.childNodes||[]).reduce((s,a)=>{let o=ac(i,a,t,r,n);return a.nodeType===e.ELEMENT_NODE&&(o=t.reduce((l,h)=>h(a,l,i),o),o=(n.get(a)||[]).reduce((l,h)=>h(a,l,i),o)),s.concat(o)},new li.default):new li.default}function Wm(i){return(e,t,r)=>_s(t,i,!0,r)}function kB(i,e,t){let r=qt.keys(i),n=ht.keys(i),s=si.keys(i),a={};return r.concat(n).concat(s).forEach(o=>{let l=t.query(o,X.ATTRIBUTE);l!=null&&(a[l.attrName]=l.value(i),a[l.attrName])||(l=SB[o],l!=null&&(l.attrName===o||l.keyName===o)&&(a[l.attrName]=l.value(i)||void 0),l=yy[o],l!=null&&(l.attrName===o||l.keyName===o)&&(l=yy[o],a[l.attrName]=l.value(i)||void 0))}),Object.entries(a).reduce((o,l)=>{let[h,d]=l;return _s(o,h,d,t)},e)}function CB(i,e,t){let r=t.query(i);if(r==null)return e;if(r.prototype instanceof Ke){let n={},s=r.value(i);if(s!=null)return n[r.blotName]=s,new li.default().insert(n,r.formats(i,t))}else if(r.prototype instanceof vs&&!jl(e,` `)&&e.insert(` -`),"blotName"in r&&"formats"in r&&typeof r.formats=="function")return ss(e,r.blotName,r.formats(i,t),t);return e}function pD(i,e){return fl(e,` +`),"blotName"in r&&"formats"in r&&typeof r.formats=="function")return _s(e,r.blotName,r.formats(i,t),t);return e}function _B(i,e){return jl(e,` `)||e.insert(` -`),e}function gD(i,e,t){let r=t.query("code-block"),n=r&&"formats"in r&&typeof r.formats=="function"?r.formats(i,t):!0;return ss(e,"code-block",n,t)}function xD(){return new Zt.default}function vD(i,e,t){let r=t.query(i);if(r==null||r.blotName!=="list"||!fl(e,` -`))return e;let n=-1,s=i.parentNode;for(;s!=null;)["OL","UL"].includes(s.tagName)&&(n+=1),s=s.parentNode;return n<=0?e:e.reduce((a,o)=>o.insert?o.attributes&&typeof o.attributes.indent=="number"?a.push(o):a.insert(o.insert,{indent:n,...o.attributes||{}}):a,new Zt.default)}function yD(i,e,t){let r=i,n=r.tagName==="OL"?"ordered":"bullet",s=r.getAttribute("data-checked");return s&&(n=s==="true"?"checked":"unchecked"),ss(e,"list",n,t)}function q9(i,e,t){if(!fl(e,` -`)){if(yn(i,t)&&(i.childNodes.length>0||i instanceof HTMLParagraphElement))return e.insert(` -`);if(e.length()>0&&i.nextSibling){let r=i.nextSibling;for(;r!=null;){if(yn(r,t))return e.insert(` -`);let n=t.query(r);if(n&&n.prototype instanceof rt)return e.insert(` -`);r=r.firstChild}}}return e}function bD(i,e,t){let r={},n=i.style||{};return n.fontStyle==="italic"&&(r.italic=!0),n.textDecoration==="underline"&&(r.underline=!0),n.textDecoration==="line-through"&&(r.strike=!0),(n.fontWeight?.startsWith("bold")||parseInt(n.fontWeight,10)>=700)&&(r.bold=!0),e=Object.entries(r).reduce((s,a)=>{let[o,l]=a;return ss(s,o,l,t)},e),parseFloat(n.textIndent||0)>0?new Zt.default().insert(" ").concat(e):e}function wD(i,e,t){let r=i.parentElement?.tagName==="TABLE"?i.parentElement:i.parentElement?.parentElement;if(r!=null){let s=Array.from(r.querySelectorAll("tr")).indexOf(i)+1;return ss(e,"table",s,t)}return e}function MD(i,e,t){let r=i.data;if(i.parentElement?.tagName==="O:P")return e.insert(r.trim());if(!H9(i)){if(r.trim().length===0&&r.includes(` -`)&&!uD(i,t))return e;r=r.replace(/[^\S\u00a0]/g," "),r=r.replace(/ {2,}/g," "),(i.previousSibling==null&&i.parentElement!=null&&yn(i.parentElement,t)||i.previousSibling instanceof Element&&yn(i.previousSibling,t))&&(r=r.replace(/^ /,"")),(i.nextSibling==null&&i.parentElement!=null&&yn(i.parentElement,t)||i.nextSibling instanceof Element&&yn(i.nextSibling,t))&&(r=r.replace(/ $/,"")),r=r.replaceAll("\xA0"," ")}return e.insert(r)}var Zt,hD,dD,cD,F9,ul,gd,Wf=M(()=>{Ae();Zt=ot(si(),1);wi();ns();Ti();Kt();If();Rf();hd();ld();Bf();qf();Uf();pd();P9();hD=ai("quill:clipboard"),dD=[[Node.TEXT_NODE,MD],[Node.TEXT_NODE,q9],["br",pD],[Node.ELEMENT_NODE,q9],[Node.ELEMENT_NODE,mD],[Node.ELEMENT_NODE,fD],[Node.ELEMENT_NODE,bD],["li",vD],["ol, ul",yD],["pre",gD],["tr",wD],["b",Yf("bold")],["i",Yf("italic")],["strike",Yf("strike")],["style",xD]],cD=[k9,dd].reduce((i,e)=>(i[e.keyName]=e,i),{}),F9=[od,hl,ll,cd,ud,fd].reduce((i,e)=>(i[e.keyName]=e,i),{}),ul=class extends je{constructor(e,t){super(e,t),this.quill.root.addEventListener("copy",r=>this.onCaptureCopy(r,!1)),this.quill.root.addEventListener("cut",r=>this.onCaptureCopy(r,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],dD.concat(this.options.matchers??[]).forEach(r=>{let[n,s]=r;this.addMatcher(n,s)})}addMatcher(e,t){this.matchers.push([e,t])}convert(e){let{html:t,text:r}=e,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(n[Xe.blotName])return new Zt.default().insert(r||"",{[Xe.blotName]:n[Xe.blotName]});if(!t)return new Zt.default().insert(r||"",n);let s=this.convertHTML(t);return fl(s,` -`)&&(s.ops[s.ops.length-1].attributes==null||n.table)?s.compose(new Zt.default().retain(s.length()-1).delete(1)):s}normalizeHTML(e){B9(e)}convertHTML(e){let t=new DOMParser().parseFromString(e,"text/html");this.normalizeHTML(t);let r=t.body,n=new WeakMap,[s,a]=this.prepareMatching(r,n);return xd(this.quill.scroll,r,s,a,n)}dangerouslyPasteHTML(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:R.sources.API;if(typeof e=="string"){let n=this.convert({html:e,text:""});this.quill.setContents(n,t),this.quill.setSelection(0,R.sources.SILENT)}else{let n=this.convert({html:t,text:""});this.quill.updateContents(new Zt.default().retain(e).concat(n),r),this.quill.setSelection(e+n.length(),R.sources.SILENT)}}onCaptureCopy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.defaultPrevented)return;e.preventDefault();let[r]=this.quill.selection.getRange();if(r==null)return;let{html:n,text:s}=this.onCopy(r,t);e.clipboardData?.setData("text/plain",s),e.clipboardData?.setData("text/html",n),t&&cl({range:r,quill:this.quill})}normalizeURIList(e){return e.split(/\r?\n/).filter(t=>t[0]!=="#").join(` -`)}onCapturePaste(e){if(e.defaultPrevented||!this.quill.isEnabled())return;e.preventDefault();let t=this.quill.getSelection(!0);if(t==null)return;let r=e.clipboardData?.getData("text/html"),n=e.clipboardData?.getData("text/plain");if(!r&&!n){let a=e.clipboardData?.getData("text/uri-list");a&&(n=this.normalizeURIList(a))}let s=Array.from(e.clipboardData?.files||[]);if(!r&&s.length>0){this.quill.uploader.upload(t,s);return}if(r&&s.length>0){let a=new DOMParser().parseFromString(r,"text/html");if(a.body.childElementCount===1&&a.body.firstElementChild?.tagName==="IMG"){this.quill.uploader.upload(t,s);return}}this.onPaste(t,{html:r,text:n})}onCopy(e){let t=this.quill.getText(e);return{html:this.quill.getSemanticHTML(e),text:t}}onPaste(e,t){let{text:r,html:n}=t,s=this.quill.getFormat(e.index),a=this.convert({text:r,html:n},s);hD.log("onPaste",a,{text:r,html:n});let o=new Zt.default().retain(e.index).delete(e.length).concat(a);this.quill.updateContents(o,R.sources.USER),this.quill.setSelection(o.length()-e.length,R.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(e,t){let r=[],n=[];return this.matchers.forEach(s=>{let[a,o]=s;switch(a){case Node.TEXT_NODE:n.push(o);break;case Node.ELEMENT_NODE:r.push(o);break;default:Array.from(e.querySelectorAll(a)).forEach(l=>{t.has(l)?t.get(l)?.push(o):t.set(l,[o])});break}}),[r,n]}};P(ul,"DEFAULTS",{matchers:[]});gd=new WeakMap});function U9(i,e){let t=e;for(let r=i.length-1;r>=0;r-=1){let n=i[r];i[r]={delta:t.transform(n.delta,!0),range:n.range&&Vf(n.range,t)},t=n.delta.transform(t),i[r].delta.length()===0&&i.splice(r,1)}}function TD(i,e){let t=e.ops[e.ops.length-1];return t==null?!1:t.insert!=null?typeof t.insert=="string"&&t.insert.endsWith(` -`):t.attributes!=null?Object.keys(t.attributes).some(r=>i.query(r,Y.BLOCK)!=null):!1}function ND(i,e){let t=e.reduce((n,s)=>n+(s.delete||0),0),r=e.length()-t;return TD(i,e)&&(r-=1),r}function Vf(i,e){if(!i)return i;let t=e.transformPosition(i.index),r=e.transformPosition(i.index+i.length);return{index:t,length:r-t}}var ml,$9=M(()=>{Ae();Ti();Kt();ml=class extends je{constructor(t,r){super(t,r);P(this,"lastRecorded",0);P(this,"ignoreChange",!1);P(this,"stack",{undo:[],redo:[]});P(this,"currentRange",null);this.quill.on(R.events.EDITOR_CHANGE,(n,s,a,o)=>{n===R.events.SELECTION_CHANGE?s&&o!==R.sources.SILENT&&(this.currentRange=s):n===R.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||o===R.sources.USER?this.record(s,a):this.transform(s)),this.currentRange=Vf(this.currentRange,s))}),this.quill.keyboard.addBinding({key:"z",shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:["z","Z"],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:"y",shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener("beforeinput",n=>{n.inputType==="historyUndo"?(this.undo(),n.preventDefault()):n.inputType==="historyRedo"&&(this.redo(),n.preventDefault())})}change(t,r){if(this.stack[t].length===0)return;let n=this.stack[t].pop();if(!n)return;let s=this.quill.getContents(),a=n.delta.invert(s);this.stack[r].push({delta:a,range:Vf(n.range,a)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,R.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(t,r){if(t.ops.length===0)return;this.stack.redo=[];let n=t.invert(r),s=this.currentRange,a=Date.now();if(this.lastRecorded+this.options.delay>a&&this.stack.undo.length>0){let o=this.stack.undo.pop();o&&(n=n.compose(o.delta),s=o.range)}else this.lastRecorded=a;n.length()!==0&&(this.stack.undo.push({delta:n,range:s}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(t){U9(this.stack.undo,t),U9(this.stack.redo,t)}undo(){this.change("undo","redo")}restoreSelection(t){if(t.range)this.quill.setSelection(t.range,R.sources.USER);else{let r=ND(this.quill.scroll,t.delta);this.quill.setSelection(r,R.sources.USER)}}};P(ml,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1})});var j9,vd,G9,Y9=M(()=>{j9=ot(si(),1);Rr();Ti();vd=class extends je{constructor(e,t){super(e,t),e.root.addEventListener("drop",r=>{r.preventDefault();let n=null;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(r.clientX,r.clientY);else if(document.caretPositionFromPoint){let a=document.caretPositionFromPoint(r.clientX,r.clientY);n=document.createRange(),n.setStart(a.offsetNode,a.offset),n.setEnd(a.offsetNode,a.offset)}let s=n&&e.selection.normalizeNative(n);if(s){let a=e.selection.normalizedToRange(s);r.dataTransfer?.files&&this.upload(a,r.dataTransfer.files)}})}upload(e,t){let r=[];Array.from(t).forEach(n=>{n&&this.options.mimetypes?.includes(n.type)&&r.push(n)}),r.length>0&&this.options.handler.call(this,e,r)}};vd.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(i,e){if(!this.quill.scroll.query("image"))return;let t=e.map(r=>new Promise(n=>{let s=new FileReader;s.onload=()=>{n(s.result)},s.readAsDataURL(r)}));Promise.all(t).then(r=>{let n=r.reduce((s,a)=>s.insert({image:a}),new j9.default().retain(i.index).delete(i.length));this.quill.updateContents(n,K.sources.USER),this.quill.setSelection(i.index+r.length,K.sources.SILENT)})}};G9=vd});function SD(i){return typeof i.data=="string"?i.data:i.dataTransfer?.types.includes("text/plain")?i.dataTransfer.getData("text/plain"):null}var W9,ED,Xf,V9,X9=M(()=>{W9=ot(si(),1);Ti();Kt();pd();ED=["insertText","insertReplacementText"],Xf=class extends je{constructor(e,t){super(e,t),e.root.addEventListener("beforeinput",r=>{this.handleBeforeInput(r)}),/Android/i.test(navigator.userAgent)||e.on(R.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(e){cl({range:e,quill:this.quill})}replaceText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(e.length===0)return!1;if(t){let r=this.quill.getFormat(e.index,1);this.deleteRange(e),this.quill.updateContents(new W9.default().retain(e.index).insert(t,r),R.sources.USER)}else this.deleteRange(e);return this.quill.setSelection(e.index+t.length,0,R.sources.SILENT),!0}handleBeforeInput(e){if(this.quill.composition.isComposing||e.defaultPrevented||!ED.includes(e.inputType))return;let t=e.getTargetRanges?e.getTargetRanges()[0]:null;if(!t||t.collapsed===!0)return;let r=SD(e);if(r==null)return;let n=this.quill.selection.normalizeNative(t),s=n?this.quill.selection.normalizedToRange(n):null;s&&this.replaceText(s,r)&&e.preventDefault()}handleCompositionStart(){let e=this.quill.getSelection();e&&this.replaceText(e)}};V9=Xf});var AD,kD,CD,Kf,K9,Z9=M(()=>{Ae();Ti();Kt();AD=/Mac/i.test(navigator.platform),kD=100,CD=i=>!!(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="Home"||AD&&i.key==="a"&&i.ctrlKey===!0),Kf=class extends je{constructor(t,r){super(t,r);P(this,"isListening",!1);P(this,"selectionChangeDeadline",0);this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(t,r){let{line:n,event:s}=r;if(!(n instanceof Wt)||!n.uiNode)return!0;let a=getComputedStyle(n.domNode).direction==="rtl";return a&&s.key!=="ArrowRight"||!a&&s.key!=="ArrowLeft"?!0:(this.quill.setSelection(t.index-1,t.length+(s.shiftKey?1:0),R.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",t=>{!t.defaultPrevented&&CD(t)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+kD,this.isListening)return;this.isListening=!0;let t=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",t,{once:!0})}handleSelectionChange(){let t=document.getSelection();if(!t)return;let r=t.getRangeAt(0);if(r.collapsed!==!0||r.startOffset!==0)return;let n=this.quill.scroll.find(r.startContainer);if(!(n instanceof Wt)||!n.uiNode)return;let s=document.createRange();s.setStartAfter(n.uiNode),s.setEndAfter(n.uiNode),t.removeAllRanges(),t.addRange(s)}},K9=Kf});var bn,yd,Zf=M(()=>{Kt();wi();pn();Ma();el();nd();Ir();A9();zr();Wf();$9();pd();Y9();bn=ot(si(),1);X9();Z9();Ti();R.register({"blots/block":ke,"blots/block/embed":rt,"blots/break":pt,"blots/container":Ni,"blots/cursor":gn,"blots/embed":ya,"blots/inline":gt,"blots/scroll":S9,"blots/text":Ve,"modules/clipboard":ul,"modules/history":ml,"modules/keyboard":dl,"modules/uploader":G9,"modules/input":V9,"modules/uiNode":K9});yd=R});var Qf,_D,Q9,J9=M(()=>{Ae();Qf=class extends Qe{add(e,t){let r=0;if(t==="+1"||t==="-1"){let n=this.value(e)||0;r=t==="+1"?n+1:n-1}else typeof t=="number"&&(r=t);return r===0?(this.remove(e),!0):super.add(e,r.toString())}canAdd(e,t){return super.canAdd(e,t)||super.canAdd(e,parseInt(t,10))}value(e){return parseInt(super.value(e),10)||void 0}},_D=new Qf("indent","ql-indent",{scope:Y.BLOCK,whitelist:[1,2,3,4,5,6,7,8]}),Q9=_D});var pl,ex,tx=M(()=>{wi();pl=class extends ke{};P(pl,"blotName","blockquote"),P(pl,"tagName","blockquote");ex=pl});var gl,ix,rx=M(()=>{wi();gl=class extends ke{static formats(e){return this.tagName.indexOf(e.tagName)+1}};P(gl,"blotName","header"),P(gl,"tagName",["H1","H2","H3","H4","H5","H6"]);ix=gl});var as,wn,nx=M(()=>{wi();Ma();Kt();as=class extends Ni{};as.blotName="list-container";as.tagName="OL";wn=class extends ke{static create(e){let t=super.create();return t.setAttribute("data-list",e),t}static formats(e){return e.getAttribute("data-list")||void 0}static register(){R.register(as)}constructor(e,t){super(e,t);let r=t.ownerDocument.createElement("span"),n=s=>{if(!e.isEnabled())return;let a=this.statics.formats(t,e);a==="checked"?(this.format("list","unchecked"),s.preventDefault()):a==="unchecked"&&(this.format("list","checked"),s.preventDefault())};r.addEventListener("mousedown",n),r.addEventListener("touchstart",n),this.attachUI(r)}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute("data-list",t):super.format(e,t)}};wn.blotName="list";wn.tagName="LI";as.allowedChildren=[wn];wn.requiredContainer=as});var xl,Na,bd=M(()=>{Ir();xl=class extends gt{static create(){return super.create()}static formats(){return!0}optimize(e){super.optimize(e),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}};P(xl,"blotName","bold"),P(xl,"tagName",["STRONG","B"]);Na=xl});var vl,sx,ax=M(()=>{bd();vl=class extends Na{};P(vl,"blotName","italic"),P(vl,"tagName",["EM","I"]);sx=vl});function Jf(i,e){let t=document.createElement("a");t.href=i;let r=t.href.slice(0,t.href.indexOf(":"));return e.indexOf(r)>-1}var oi,yl=M(()=>{Ir();oi=class extends gt{static create(e){let t=super.create(e);return t.setAttribute("href",this.sanitize(e)),t.setAttribute("rel","noopener noreferrer"),t.setAttribute("target","_blank"),t}static formats(e){return e.getAttribute("href")}static sanitize(e){return Jf(e,this.PROTOCOL_WHITELIST)?e:this.SANITIZED_URL}format(e,t){e!==this.statics.blotName||!t?super.format(e,t):this.domNode.setAttribute("href",this.constructor.sanitize(t))}};P(oi,"blotName","link"),P(oi,"tagName","A"),P(oi,"SANITIZED_URL","about:blank"),P(oi,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"])});var bl,ox,lx=M(()=>{Ir();bl=class extends gt{static create(e){return e==="super"?document.createElement("sup"):e==="sub"?document.createElement("sub"):super.create(e)}static formats(e){if(e.tagName==="SUB")return"sub";if(e.tagName==="SUP")return"super"}};P(bl,"blotName","script"),P(bl,"tagName",["SUB","SUP"]);ox=bl});var wl,hx,dx=M(()=>{bd();wl=class extends Na{};P(wl,"blotName","strike"),P(wl,"tagName",["S","STRIKE"]);hx=wl});var Ml,cx,ux=M(()=>{Ir();Ml=class extends gt{};P(Ml,"blotName","underline"),P(Ml,"tagName","U");cx=Ml});var Ea,fx,mx=M(()=>{nd();Ea=class extends ya{static create(e){if(window.katex==null)throw new Error("Formula module requires KaTeX.");let t=super.create(e);return typeof e=="string"&&(window.katex.render(e,t,{throwOnError:!1,errorColor:"#f00"}),t.setAttribute("data-value",e)),t}static value(e){return e.getAttribute("data-value")}html(){let{formula:e}=this.value();return`${e}`}};P(Ea,"blotName","formula"),P(Ea,"className","ql-formula"),P(Ea,"tagName","SPAN");fx=Ea});var px,Tl,gx,xx=M(()=>{Ae();yl();px=["alt","height","width"],Tl=class extends Ue{static create(e){let t=super.create(e);return typeof e=="string"&&t.setAttribute("src",this.sanitize(e)),t}static formats(e){return px.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),t),{})}static match(e){return/\.(jpe?g|gif|png)$/.test(e)||/^data:image\/.+;base64/.test(e)}static sanitize(e){return Jf(e,["http","https","data"])?e:"//:0"}static value(e){return e.getAttribute("src")}format(e,t){px.indexOf(e)>-1?t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e):super.format(e,t)}};P(Tl,"blotName","image"),P(Tl,"tagName","IMG");gx=Tl});var vx,Sa,yx,bx=M(()=>{wi();yl();vx=["height","width"],Sa=class extends rt{static create(e){let t=super.create(e);return t.setAttribute("frameborder","0"),t.setAttribute("allowfullscreen","true"),t.setAttribute("src",this.sanitize(e)),t}static formats(e){return vx.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),t),{})}static sanitize(e){return oi.sanitize(e)}static value(e){return e.getAttribute("src")}format(e,t){vx.indexOf(e)>-1?t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e):super.format(e,t)}html(){let{video:e}=this.value();return`${e}`}};P(Sa,"blotName","video"),P(Sa,"className","ql-video"),P(Sa,"tagName","IFRAME");yx=Sa});var wd,Nl,Or,Qt,os,LD,El,wx=M(()=>{wd=ot(si(),1);Ae();Ir();Kt();Ti();wi();pn();el();zr();hd();Wf();Nl=new Qe("code-token","hljs",{scope:Y.INLINE}),Or=class i extends gt{static formats(e,t){for(;e!=null&&e!==t.domNode;){if(e.classList&&e.classList.contains(Xe.className))return super.formats(e,t);e=e.parentNode}}constructor(e,t,r){super(e,t,r),Nl.add(this.domNode,r)}format(e,t){e!==i.blotName?super.format(e,t):t?Nl.add(this.domNode,t):(Nl.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),Nl.value(this.domNode)||this.unwrap()}};Or.blotName="code-token";Or.className="ql-token";Qt=class extends Xe{static create(e){let t=super.create(e);return typeof e=="string"&&t.setAttribute("data-language",e),t}static formats(e){return e.getAttribute("data-language")||"plain"}static register(){}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute("data-language",t):super.format(e,t)}replaceWith(e,t){return this.formatAt(0,this.length(),Or.blotName,!1),super.replaceWith(e,t)}},os=class extends rr{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(e,t){e===Qt.blotName&&(this.forceNext=!0,this.children.forEach(r=>{r.format(e,t)}))}formatAt(e,t,r,n){r===Qt.blotName&&(this.forceNext=!0),super.formatAt(e,t,r,n)}highlight(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;let n=`${Array.from(this.domNode.childNodes).filter(a=>a!==this.uiNode).map(a=>a.textContent).join(` +`),e}function LB(i,e,t){let r=t.query("code-block"),n=r&&"formats"in r&&typeof r.formats=="function"?r.formats(i,t):!0;return _s(e,"code-block",n,t)}function IB(){return new li.default}function zB(i,e,t){let r=t.query(i);if(r==null||r.blotName!=="list"||!jl(e,` +`))return e;let n=-1,s=i.parentNode;for(;s!=null;)["OL","UL"].includes(s.tagName)&&(n+=1),s=s.parentNode;return n<=0?e:e.reduce((a,o)=>o.insert?o.attributes&&typeof o.attributes.indent=="number"?a.push(o):a.insert(o.insert,{indent:n,...o.attributes||{}}):a,new li.default)}function RB(i,e,t){let r=i,n=r.tagName==="OL"?"ordered":"bullet",s=r.getAttribute("data-checked");return s&&(n=s==="true"?"checked":"unchecked"),_s(e,"list",n,t)}function vy(i,e,t){if(!jl(e,` +`)){if(Fn(i,t)&&(i.childNodes.length>0||i instanceof HTMLParagraphElement))return e.insert(` +`);if(e.length()>0&&i.nextSibling){let r=i.nextSibling;for(;r!=null;){if(Fn(r,t))return e.insert(` +`);let n=t.query(r);if(n&&n.prototype instanceof ft)return e.insert(` +`);r=r.firstChild}}}return e}function DB(i,e,t){let r={},n=i.style||{};return n.fontStyle==="italic"&&(r.italic=!0),n.textDecoration==="underline"&&(r.underline=!0),n.textDecoration==="line-through"&&(r.strike=!0),(n.fontWeight?.startsWith("bold")||parseInt(n.fontWeight,10)>=700)&&(r.bold=!0),e=Object.entries(r).reduce((s,a)=>{let[o,l]=a;return _s(s,o,l,t)},e),parseFloat(n.textIndent||0)>0?new li.default().insert(" ").concat(e):e}function OB(i,e,t){let r=i.parentElement?.tagName==="TABLE"?i.parentElement:i.parentElement?.parentElement;if(r!=null){let s=Array.from(r.querySelectorAll("tr")).indexOf(i)+1;return _s(e,"table",s,t)}return e}function BB(i,e,t){let r=i.data;if(i.parentElement?.tagName==="O:P")return e.insert(r.trim());if(!by(i)){if(r.trim().length===0&&r.includes(` +`)&&!AB(i,t))return e;r=r.replace(/[^\S\u00a0]/g," "),r=r.replace(/ {2,}/g," "),(i.previousSibling==null&&i.parentElement!=null&&Fn(i.parentElement,t)||i.previousSibling instanceof Element&&Fn(i.previousSibling,t))&&(r=r.replace(/^ /,"")),(i.nextSibling==null&&i.parentElement!=null&&Fn(i.parentElement,t)||i.nextSibling instanceof Element&&Fn(i.nextSibling,t))&&(r=r.replace(/ $/,"")),r=r.replaceAll("\xA0"," ")}return e.insert(r)}var li,NB,EB,SB,yy,$l,sc,Ym=T(()=>{Re();li=pt(pi(),1);zi();Cs();Di();oi();Rm();Dm();Qd();Zd();Pm();Hm();$m();nc();xy();NB=gi("quill:clipboard"),EB=[[Node.TEXT_NODE,BB],[Node.TEXT_NODE,vy],["br",_B],[Node.ELEMENT_NODE,vy],[Node.ELEMENT_NODE,CB],[Node.ELEMENT_NODE,kB],[Node.ELEMENT_NODE,DB],["li",zB],["ol, ul",RB],["pre",LB],["tr",OB],["b",Wm("bold")],["i",Wm("italic")],["strike",Wm("strike")],["style",IB]],SB=[oy,Jd].reduce((i,e)=>(i[e.keyName]=e,i),{}),yy=[Kd,ql,Fl,ec,tc,ic].reduce((i,e)=>(i[e.keyName]=e,i),{}),$l=class extends Qe{constructor(e,t){super(e,t),this.quill.root.addEventListener("copy",r=>this.onCaptureCopy(r,!1)),this.quill.root.addEventListener("cut",r=>this.onCaptureCopy(r,!0)),this.quill.root.addEventListener("paste",this.onCapturePaste.bind(this)),this.matchers=[],EB.concat(this.options.matchers??[]).forEach(r=>{let[n,s]=r;this.addMatcher(n,s)})}addMatcher(e,t){this.matchers.push([e,t])}convert(e){let{html:t,text:r}=e,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(n[st.blotName])return new li.default().insert(r||"",{[st.blotName]:n[st.blotName]});if(!t)return new li.default().insert(r||"",n);let s=this.convertHTML(t);return jl(s,` +`)&&(s.ops[s.ops.length-1].attributes==null||n.table)?s.compose(new li.default().retain(s.length()-1).delete(1)):s}normalizeHTML(e){gy(e)}convertHTML(e){let t=new DOMParser().parseFromString(e,"text/html");this.normalizeHTML(t);let r=t.body,n=new WeakMap,[s,a]=this.prepareMatching(r,n);return ac(this.quill.scroll,r,s,a,n)}dangerouslyPasteHTML(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:B.sources.API;if(typeof e=="string"){let n=this.convert({html:e,text:""});this.quill.setContents(n,t),this.quill.setSelection(0,B.sources.SILENT)}else{let n=this.convert({html:t,text:""});this.quill.updateContents(new li.default().retain(e).concat(n),r),this.quill.setSelection(e+n.length(),B.sources.SILENT)}}onCaptureCopy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.defaultPrevented)return;e.preventDefault();let[r]=this.quill.selection.getRange();if(r==null)return;let{html:n,text:s}=this.onCopy(r,t);e.clipboardData?.setData("text/plain",s),e.clipboardData?.setData("text/html",n),t&&Ul({range:r,quill:this.quill})}normalizeURIList(e){return e.split(/\r?\n/).filter(t=>t[0]!=="#").join(` +`)}onCapturePaste(e){if(e.defaultPrevented||!this.quill.isEnabled())return;e.preventDefault();let t=this.quill.getSelection(!0);if(t==null)return;let r=e.clipboardData?.getData("text/html"),n=e.clipboardData?.getData("text/plain");if(!r&&!n){let a=e.clipboardData?.getData("text/uri-list");a&&(n=this.normalizeURIList(a))}let s=Array.from(e.clipboardData?.files||[]);if(!r&&s.length>0){this.quill.uploader.upload(t,s);return}if(r&&s.length>0){let a=new DOMParser().parseFromString(r,"text/html");if(a.body.childElementCount===1&&a.body.firstElementChild?.tagName==="IMG"){this.quill.uploader.upload(t,s);return}}this.onPaste(t,{html:r,text:n})}onCopy(e){let t=this.quill.getText(e);return{html:this.quill.getSemanticHTML(e),text:t}}onPaste(e,t){let{text:r,html:n}=t,s=this.quill.getFormat(e.index),a=this.convert({text:r,html:n},s);NB.log("onPaste",a,{text:r,html:n});let o=new li.default().retain(e.index).delete(e.length).concat(a);this.quill.updateContents(o,B.sources.USER),this.quill.setSelection(o.length()-e.length,B.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(e,t){let r=[],n=[];return this.matchers.forEach(s=>{let[a,o]=s;switch(a){case Node.TEXT_NODE:n.push(o);break;case Node.ELEMENT_NODE:r.push(o);break;default:Array.from(e.querySelectorAll(a)).forEach(l=>{t.has(l)?t.get(l)?.push(o):t.set(l,[o])});break}}),[r,n]}};U($l,"DEFAULTS",{matchers:[]});sc=new WeakMap});function wy(i,e){let t=e;for(let r=i.length-1;r>=0;r-=1){let n=i[r];i[r]={delta:t.transform(n.delta,!0),range:n.range&&Xm(n.range,t)},t=n.delta.transform(t),i[r].delta.length()===0&&i.splice(r,1)}}function PB(i,e){let t=e.ops[e.ops.length-1];return t==null?!1:t.insert!=null?typeof t.insert=="string"&&t.insert.endsWith(` +`):t.attributes!=null?Object.keys(t.attributes).some(r=>i.query(r,X.BLOCK)!=null):!1}function FB(i,e){let t=e.reduce((n,s)=>n+(s.delete||0),0),r=e.length()-t;return PB(i,e)&&(r-=1),r}function Xm(i,e){if(!i)return i;let t=e.transformPosition(i.index),r=e.transformPosition(i.index+i.length);return{index:t,length:r-t}}var Gl,My=T(()=>{Re();Di();oi();Gl=class extends Qe{constructor(t,r){super(t,r);U(this,"lastRecorded",0);U(this,"ignoreChange",!1);U(this,"stack",{undo:[],redo:[]});U(this,"currentRange",null);this.quill.on(B.events.EDITOR_CHANGE,(n,s,a,o)=>{n===B.events.SELECTION_CHANGE?s&&o!==B.sources.SILENT&&(this.currentRange=s):n===B.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||o===B.sources.USER?this.record(s,a):this.transform(s)),this.currentRange=Xm(this.currentRange,s))}),this.quill.keyboard.addBinding({key:"z",shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:["z","Z"],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:"y",shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener("beforeinput",n=>{n.inputType==="historyUndo"?(this.undo(),n.preventDefault()):n.inputType==="historyRedo"&&(this.redo(),n.preventDefault())})}change(t,r){if(this.stack[t].length===0)return;let n=this.stack[t].pop();if(!n)return;let s=this.quill.getContents(),a=n.delta.invert(s);this.stack[r].push({delta:a,range:Xm(n.range,a)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,B.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(t,r){if(t.ops.length===0)return;this.stack.redo=[];let n=t.invert(r),s=this.currentRange,a=Date.now();if(this.lastRecorded+this.options.delay>a&&this.stack.undo.length>0){let o=this.stack.undo.pop();o&&(n=n.compose(o.delta),s=o.range)}else this.lastRecorded=a;n.length()!==0&&(this.stack.undo.push({delta:n,range:s}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change("redo","undo")}transform(t){wy(this.stack.undo,t),wy(this.stack.redo,t)}undo(){this.change("undo","redo")}restoreSelection(t){if(t.range)this.quill.setSelection(t.range,B.sources.USER);else{let r=FB(this.quill.scroll,t.delta);this.quill.setSelection(r,B.sources.USER)}}};U(Gl,"DEFAULTS",{delay:1e3,maxStack:100,userOnly:!1})});var Ty,oc,Ny,Ey=T(()=>{Ty=pt(pi(),1);Qr();Di();oc=class extends Qe{constructor(e,t){super(e,t),e.root.addEventListener("drop",r=>{r.preventDefault();let n=null;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(r.clientX,r.clientY);else if(document.caretPositionFromPoint){let a=document.caretPositionFromPoint(r.clientX,r.clientY);n=document.createRange(),n.setStart(a.offsetNode,a.offset),n.setEnd(a.offsetNode,a.offset)}let s=n&&e.selection.normalizeNative(n);if(s){let a=e.selection.normalizedToRange(s);r.dataTransfer?.files&&this.upload(a,r.dataTransfer.files)}})}upload(e,t){let r=[];Array.from(t).forEach(n=>{n&&this.options.mimetypes?.includes(n.type)&&r.push(n)}),r.length>0&&this.options.handler.call(this,e,r)}};oc.DEFAULTS={mimetypes:["image/png","image/jpeg"],handler(i,e){if(!this.quill.scroll.query("image"))return;let t=e.map(r=>new Promise(n=>{let s=new FileReader;s.onload=()=>{n(s.result)},s.readAsDataURL(r)}));Promise.all(t).then(r=>{let n=r.reduce((s,a)=>s.insert({image:a}),new Ty.default().retain(i.index).delete(i.length));this.quill.updateContents(n,J.sources.USER),this.quill.setSelection(i.index+r.length,J.sources.SILENT)})}};Ny=oc});function HB(i){return typeof i.data=="string"?i.data:i.dataTransfer?.types.includes("text/plain")?i.dataTransfer.getData("text/plain"):null}var Sy,qB,Km,Ay,ky=T(()=>{Sy=pt(pi(),1);Di();oi();nc();qB=["insertText","insertReplacementText"],Km=class extends Qe{constructor(e,t){super(e,t),e.root.addEventListener("beforeinput",r=>{this.handleBeforeInput(r)}),/Android/i.test(navigator.userAgent)||e.on(B.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(e){Ul({range:e,quill:this.quill})}replaceText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(e.length===0)return!1;if(t){let r=this.quill.getFormat(e.index,1);this.deleteRange(e),this.quill.updateContents(new Sy.default().retain(e.index).insert(t,r),B.sources.USER)}else this.deleteRange(e);return this.quill.setSelection(e.index+t.length,0,B.sources.SILENT),!0}handleBeforeInput(e){if(this.quill.composition.isComposing||e.defaultPrevented||!qB.includes(e.inputType))return;let t=e.getTargetRanges?e.getTargetRanges()[0]:null;if(!t||t.collapsed===!0)return;let r=HB(e);if(r==null)return;let n=this.quill.selection.normalizeNative(t),s=n?this.quill.selection.normalizedToRange(n):null;s&&this.replaceText(s,r)&&e.preventDefault()}handleCompositionStart(){let e=this.quill.getSelection();e&&this.replaceText(e)}};Ay=Km});var UB,$B,jB,Zm,Cy,_y=T(()=>{Re();Di();oi();UB=/Mac/i.test(navigator.platform),$B=100,jB=i=>!!(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="ArrowUp"||i.key==="ArrowDown"||i.key==="Home"||UB&&i.key==="a"&&i.ctrlKey===!0),Zm=class extends Qe{constructor(t,r){super(t,r);U(this,"isListening",!1);U(this,"selectionChangeDeadline",0);this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:["ArrowLeft","ArrowRight"],offset:0,shiftKey:null,handler(t,r){let{line:n,event:s}=r;if(!(n instanceof ni)||!n.uiNode)return!0;let a=getComputedStyle(n.domNode).direction==="rtl";return a&&s.key!=="ArrowRight"||!a&&s.key!=="ArrowLeft"?!0:(this.quill.setSelection(t.index-1,t.length+(s.shiftKey?1:0),B.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener("keydown",t=>{!t.defaultPrevented&&jB(t)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){if(this.selectionChangeDeadline=Date.now()+$B,this.isListening)return;this.isListening=!0;let t=()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()};document.addEventListener("selectionchange",t,{once:!0})}handleSelectionChange(){let t=document.getSelection();if(!t)return;let r=t.getRangeAt(0);if(r.collapsed!==!0||r.startOffset!==0)return;let n=this.quill.scroll.find(r.startContainer);if(!(n instanceof ni)||!n.uiNode)return;let s=document.createRange();s.setStartAfter(n.uiNode),s.setEndAfter(n.uiNode),t.removeAllRanges(),t.addRange(s)}},Cy=Zm});var qn,lc,Qm=T(()=>{oi();zi();Dn();Ja();Ll();Wd();Zr();ay();Kr();Ym();My();nc();Ey();qn=pt(pi(),1);ky();_y();Di();B.register({"blots/block":De,"blots/block/embed":ft,"blots/break":Et,"blots/container":Oi,"blots/cursor":On,"blots/embed":Ka,"blots/inline":St,"blots/scroll":sy,"blots/text":nt,"modules/clipboard":$l,"modules/history":Gl,"modules/keyboard":Hl,"modules/uploader":Ny,"modules/input":Ay,"modules/uiNode":Cy});lc=B});var Jm,GB,Ly,Iy=T(()=>{Re();Jm=class extends ht{add(e,t){let r=0;if(t==="+1"||t==="-1"){let n=this.value(e)||0;r=t==="+1"?n+1:n-1}else typeof t=="number"&&(r=t);return r===0?(this.remove(e),!0):super.add(e,r.toString())}canAdd(e,t){return super.canAdd(e,t)||super.canAdd(e,parseInt(t,10))}value(e){return parseInt(super.value(e),10)||void 0}},GB=new Jm("indent","ql-indent",{scope:X.BLOCK,whitelist:[1,2,3,4,5,6,7,8]}),Ly=GB});var Vl,zy,Ry=T(()=>{zi();Vl=class extends De{};U(Vl,"blotName","blockquote"),U(Vl,"tagName","blockquote");zy=Vl});var Wl,Dy,Oy=T(()=>{zi();Wl=class extends De{static formats(e){return this.tagName.indexOf(e.tagName)+1}};U(Wl,"blotName","header"),U(Wl,"tagName",["H1","H2","H3","H4","H5","H6"]);Dy=Wl});var Ls,Hn,By=T(()=>{zi();Ja();oi();Ls=class extends Oi{};Ls.blotName="list-container";Ls.tagName="OL";Hn=class extends De{static create(e){let t=super.create();return t.setAttribute("data-list",e),t}static formats(e){return e.getAttribute("data-list")||void 0}static register(){B.register(Ls)}constructor(e,t){super(e,t);let r=t.ownerDocument.createElement("span"),n=s=>{if(!e.isEnabled())return;let a=this.statics.formats(t,e);a==="checked"?(this.format("list","unchecked"),s.preventDefault()):a==="unchecked"&&(this.format("list","checked"),s.preventDefault())};r.addEventListener("mousedown",n),r.addEventListener("touchstart",n),this.attachUI(r)}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute("data-list",t):super.format(e,t)}};Hn.blotName="list";Hn.tagName="LI";Ls.allowedChildren=[Hn];Hn.requiredContainer=Ls});var Yl,to,hc=T(()=>{Zr();Yl=class extends St{static create(){return super.create()}static formats(){return!0}optimize(e){super.optimize(e),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}};U(Yl,"blotName","bold"),U(Yl,"tagName",["STRONG","B"]);to=Yl});var Xl,Py,Fy=T(()=>{hc();Xl=class extends to{};U(Xl,"blotName","italic"),U(Xl,"tagName",["EM","I"]);Py=Xl});function ep(i,e){let t=document.createElement("a");t.href=i;let r=t.href.slice(0,t.href.indexOf(":"));return e.indexOf(r)>-1}var xi,Kl=T(()=>{Zr();xi=class extends St{static create(e){let t=super.create(e);return t.setAttribute("href",this.sanitize(e)),t.setAttribute("rel","noopener noreferrer"),t.setAttribute("target","_blank"),t}static formats(e){return e.getAttribute("href")}static sanitize(e){return ep(e,this.PROTOCOL_WHITELIST)?e:this.SANITIZED_URL}format(e,t){e!==this.statics.blotName||!t?super.format(e,t):this.domNode.setAttribute("href",this.constructor.sanitize(t))}};U(xi,"blotName","link"),U(xi,"tagName","A"),U(xi,"SANITIZED_URL","about:blank"),U(xi,"PROTOCOL_WHITELIST",["http","https","mailto","tel","sms"])});var Zl,qy,Hy=T(()=>{Zr();Zl=class extends St{static create(e){return e==="super"?document.createElement("sup"):e==="sub"?document.createElement("sub"):super.create(e)}static formats(e){if(e.tagName==="SUB")return"sub";if(e.tagName==="SUP")return"super"}};U(Zl,"blotName","script"),U(Zl,"tagName",["SUB","SUP"]);qy=Zl});var Ql,Uy,$y=T(()=>{hc();Ql=class extends to{};U(Ql,"blotName","strike"),U(Ql,"tagName",["S","STRIKE"]);Uy=Ql});var Jl,jy,Gy=T(()=>{Zr();Jl=class extends St{};U(Jl,"blotName","underline"),U(Jl,"tagName","U");jy=Jl});var io,Vy,Wy=T(()=>{Wd();io=class extends Ka{static create(e){if(window.katex==null)throw new Error("Formula module requires KaTeX.");let t=super.create(e);return typeof e=="string"&&(window.katex.render(e,t,{throwOnError:!1,errorColor:"#f00"}),t.setAttribute("data-value",e)),t}static value(e){return e.getAttribute("data-value")}html(){let{formula:e}=this.value();return`${e}`}};U(io,"blotName","formula"),U(io,"className","ql-formula"),U(io,"tagName","SPAN");Vy=io});var Yy,e0,Xy,Ky=T(()=>{Re();Kl();Yy=["alt","height","width"],e0=class extends Ke{static create(e){let t=super.create(e);return typeof e=="string"&&t.setAttribute("src",this.sanitize(e)),t}static formats(e){return Yy.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),t),{})}static match(e){return/\.(jpe?g|gif|png)$/.test(e)||/^data:image\/.+;base64/.test(e)}static sanitize(e){return ep(e,["http","https","data"])?e:"//:0"}static value(e){return e.getAttribute("src")}format(e,t){Yy.indexOf(e)>-1?t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e):super.format(e,t)}};U(e0,"blotName","image"),U(e0,"tagName","IMG");Xy=e0});var Zy,ro,Qy,Jy=T(()=>{zi();Kl();Zy=["height","width"],ro=class extends ft{static create(e){let t=super.create(e);return t.setAttribute("frameborder","0"),t.setAttribute("allowfullscreen","true"),t.setAttribute("src",this.sanitize(e)),t}static formats(e){return Zy.reduce((t,r)=>(e.hasAttribute(r)&&(t[r]=e.getAttribute(r)),t),{})}static sanitize(e){return xi.sanitize(e)}static value(e){return e.getAttribute("src")}format(e,t){Zy.indexOf(e)>-1?t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e):super.format(e,t)}html(){let{video:e}=this.value();return`${e}`}};U(ro,"blotName","video"),U(ro,"className","ql-video"),U(ro,"tagName","IFRAME");Qy=ro});var dc,t0,en,hi,Is,VB,i0,ev=T(()=>{dc=pt(pi(),1);Re();Zr();oi();Di();zi();Dn();Ll();Kr();Qd();Ym();t0=new ht("code-token","hljs",{scope:X.INLINE}),en=class i extends St{static formats(e,t){for(;e!=null&&e!==t.domNode;){if(e.classList&&e.classList.contains(st.className))return super.formats(e,t);e=e.parentNode}}constructor(e,t,r){super(e,t,r),t0.add(this.domNode,r)}format(e,t){e!==i.blotName?super.format(e,t):t?t0.add(this.domNode,t):(t0.remove(this.domNode),this.domNode.classList.remove(this.statics.className))}optimize(){super.optimize(...arguments),t0.value(this.domNode)||this.unwrap()}};en.blotName="code-token";en.className="ql-token";hi=class extends st{static create(e){let t=super.create(e);return typeof e=="string"&&t.setAttribute("data-language",e),t}static formats(e){return e.getAttribute("data-language")||"plain"}static register(){}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute("data-language",t):super.format(e,t)}replaceWith(e,t){return this.formatAt(0,this.length(),en.blotName,!1),super.replaceWith(e,t)}},Is=class extends wr{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(e,t){e===hi.blotName&&(this.forceNext=!0,this.children.forEach(r=>{r.format(e,t)}))}formatAt(e,t,r,n){r===hi.blotName&&(this.forceNext=!0),super.formatAt(e,t,r,n)}highlight(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;let n=`${Array.from(this.domNode.childNodes).filter(a=>a!==this.uiNode).map(a=>a.textContent).join(` `)} -`,s=Qt.formats(this.children.head.domNode);if(t||this.forceNext||this.cachedText!==n){if(n.trim().length>0||this.cachedText==null){let a=this.children.reduce((l,h)=>l.concat(df(h,!1)),new wd.default),o=e(n,s);a.diff(o).reduce((l,h)=>{let{retain:d,attributes:c}=h;return d?(c&&Object.keys(c).forEach(f=>{[Qt.blotName,Or.blotName].includes(f)&&this.formatAt(l,d,f,c[f])}),l+d):l},0)}this.cachedText=n,this.forceNext=!1}}html(e,t){let[r]=this.children.find(e);return`
    -${rs(this.code(e,t))}
    -
    `}optimize(e){if(super.optimize(e),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){let t=Qt.formats(this.children.head.domNode);t!==this.uiNode.value&&(this.uiNode.value=t)}}};os.allowedChildren=[Qt];Qt.requiredContainer=os;Qt.allowedChildren=[Or,gn,Ve,pt];LD=(i,e,t)=>{if(typeof i.versionString=="string"){let r=i.versionString.split(".")[0];if(parseInt(r,10)>=11)return i.highlight(t,{language:e}).value}return i.highlight(e,t).value},El=class extends je{static register(){R.register(Or,!0),R.register(Qt,!0),R.register(os,!0)}constructor(e,t){if(super(e,t),this.options.hljs==null)throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");this.languages=this.options.languages.reduce((r,n)=>{let{key:s}=n;return r[s]=!0,r},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(R.events.SCROLL_BLOT_MOUNT,e=>{if(!(e instanceof os))return;let t=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(r=>{let{key:n,label:s}=r,a=t.ownerDocument.createElement("option");a.textContent=s,a.setAttribute("value",n),t.appendChild(a)}),t.addEventListener("change",()=>{e.format(Qt.blotName,t.value),this.quill.root.focus(),this.highlight(e,!0)}),e.uiNode==null&&(e.attachUI(t),e.children.head&&(t.value=Qt.formats(e.children.head.domNode)))})}initTimer(){let e=null;this.quill.on(R.events.SCROLL_OPTIMIZE,()=>{e&&clearTimeout(e),e=setTimeout(()=>{this.highlight(),e=null},this.options.interval)})}highlight(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(R.sources.USER);let r=this.quill.getSelection();(e==null?this.quill.scroll.descendants(os):[e]).forEach(s=>{s.highlight(this.highlightBlot,t)}),this.quill.update(R.sources.SILENT),r!=null&&this.quill.setSelection(r,R.sources.SILENT)}highlightBlot(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"plain";if(t=this.languages[t]?t:"plain",t==="plain")return rs(e).split(` +`,s=hi.formats(this.children.head.domNode);if(t||this.forceNext||this.cachedText!==n){if(n.trim().length>0||this.cachedText==null){let a=this.children.reduce((l,h)=>l.concat(cm(h,!1)),new dc.default),o=e(n,s);a.diff(o).reduce((l,h)=>{let{retain:d,attributes:c}=h;return d?(c&&Object.keys(c).forEach(f=>{[hi.blotName,en.blotName].includes(f)&&this.formatAt(l,d,f,c[f])}),l+d):l},0)}this.cachedText=n,this.forceNext=!1}}html(e,t){let[r]=this.children.find(e);return`
    +${ks(this.code(e,t))}
    +
    `}optimize(e){if(super.optimize(e),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){let t=hi.formats(this.children.head.domNode);t!==this.uiNode.value&&(this.uiNode.value=t)}}};Is.allowedChildren=[hi];hi.requiredContainer=Is;hi.allowedChildren=[en,On,nt,Et];VB=(i,e,t)=>{if(typeof i.versionString=="string"){let r=i.versionString.split(".")[0];if(parseInt(r,10)>=11)return i.highlight(t,{language:e}).value}return i.highlight(e,t).value},i0=class extends Qe{static register(){B.register(en,!0),B.register(hi,!0),B.register(Is,!0)}constructor(e,t){if(super(e,t),this.options.hljs==null)throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");this.languages=this.options.languages.reduce((r,n)=>{let{key:s}=n;return r[s]=!0,r},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(B.events.SCROLL_BLOT_MOUNT,e=>{if(!(e instanceof Is))return;let t=this.quill.root.ownerDocument.createElement("select");this.options.languages.forEach(r=>{let{key:n,label:s}=r,a=t.ownerDocument.createElement("option");a.textContent=s,a.setAttribute("value",n),t.appendChild(a)}),t.addEventListener("change",()=>{e.format(hi.blotName,t.value),this.quill.root.focus(),this.highlight(e,!0)}),e.uiNode==null&&(e.attachUI(t),e.children.head&&(t.value=hi.formats(e.children.head.domNode)))})}initTimer(){let e=null;this.quill.on(B.events.SCROLL_OPTIMIZE,()=>{e&&clearTimeout(e),e=setTimeout(()=>{this.highlight(),e=null},this.options.interval)})}highlight(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(B.sources.USER);let r=this.quill.getSelection();(e==null?this.quill.scroll.descendants(Is):[e]).forEach(s=>{s.highlight(this.highlightBlot,t)}),this.quill.update(B.sources.SILENT),r!=null&&this.quill.setSelection(r,B.sources.SILENT)}highlightBlot(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"plain";if(t=this.languages[t]?t:"plain",t==="plain")return ks(e).split(` `).reduce((n,s,a)=>(a!==0&&n.insert(` -`,{[Xe.blotName]:t}),n.insert(s)),new wd.default);let r=this.quill.root.ownerDocument.createElement("div");return r.classList.add(Xe.className),r.innerHTML=LD(this.options.hljs,t,e),xd(this.quill.scroll,r,[(n,s)=>{let a=Nl.value(n);return a?s.compose(new wd.default().retain(s.length(),{[Or.blotName]:a})):s}],[(n,s)=>n.data.split(` +`,{[st.blotName]:t}),n.insert(s)),new dc.default);let r=this.quill.root.ownerDocument.createElement("div");return r.classList.add(st.className),r.innerHTML=VB(this.options.hljs,t,e),ac(this.quill.scroll,r,[(n,s)=>{let a=t0.value(n);return a?s.compose(new dc.default().retain(s.length(),{[en.blotName]:a})):s}],[(n,s)=>n.data.split(` `).reduce((a,o,l)=>(l!==0&&a.insert(` -`,{[Xe.blotName]:t}),a.insert(o)),s)],new WeakMap)}};El.DEFAULTS={hljs:window.hljs,interval:1e3,languages:[{key:"plain",label:"Plain"},{key:"bash",label:"Bash"},{key:"cpp",label:"C++"},{key:"cs",label:"C#"},{key:"css",label:"CSS"},{key:"diff",label:"Diff"},{key:"xml",label:"HTML/XML"},{key:"java",label:"Java"},{key:"javascript",label:"JavaScript"},{key:"markdown",label:"Markdown"},{key:"php",label:"PHP"},{key:"python",label:"Python"},{key:"ruby",label:"Ruby"},{key:"sql",label:"SQL"}]}});function Md(){return`row-${Math.random().toString(36).slice(2,6)}`}var Sl,Si,Ai,li,Br,Mx=M(()=>{wi();Ma();Sl=class Sl extends ke{static create(e){let t=super.create();return e?t.setAttribute("data-row",e):t.setAttribute("data-row",Md()),t}static formats(e){if(e.hasAttribute("data-row"))return e.getAttribute("data-row")}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(e,t){e===Sl.blotName&&t?this.domNode.setAttribute("data-row",t):super.format(e,t)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}};P(Sl,"blotName","table"),P(Sl,"tagName","TD");Si=Sl,Ai=class extends Ni{checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){let e=this.children.head.formats(),t=this.children.tail.formats(),r=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.table===t.table&&e.table===r.table&&e.table===n.table}return!1}optimize(e){super.optimize(e),this.children.forEach(t=>{if(t.next==null)return;let r=t.formats(),n=t.next.formats();if(r.table!==n.table){let s=this.splitAfter(t);s&&s.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}};P(Ai,"blotName","table-row"),P(Ai,"tagName","TR");li=class extends Ni{};P(li,"blotName","table-body"),P(li,"tagName","TBODY");Br=class extends Ni{balanceCells(){let e=this.descendants(Ai),t=e.reduce((r,n)=>Math.max(n.children.length,r),0);e.forEach(r=>{new Array(t-r.children.length).fill(0).forEach(()=>{let n;r.children.head!=null&&(n=Si.formats(r.children.head.domNode));let s=this.scroll.create(Si.blotName,n);r.appendChild(s),s.optimize()})})}cells(e){return this.rows().map(t=>t.children.at(e))}deleteColumn(e){let[t]=this.descendant(li);t==null||t.children.head==null||t.children.forEach(r=>{let n=r.children.at(e);n?.remove()})}insertColumn(e){let[t]=this.descendant(li);t==null||t.children.head==null||t.children.forEach(r=>{let n=r.children.at(e),s=Si.formats(r.children.head.domNode),a=this.scroll.create(Si.blotName,s);r.insertBefore(a,n)})}insertRow(e){let[t]=this.descendant(li);if(t==null||t.children.head==null)return;let r=Md(),n=this.scroll.create(Ai.blotName);t.children.head.children.forEach(()=>{let a=this.scroll.create(Si.blotName,r);n.appendChild(a)});let s=t.children.at(e);t.insertBefore(n,s)}rows(){let e=this.children.head;return e==null?[]:e.children.map(t=>t)}};P(Br,"blotName","table-container"),P(Br,"tagName","TABLE");Br.allowedChildren=[li];li.requiredContainer=Br;li.allowedChildren=[Ai];Ai.requiredContainer=li;Ai.allowedChildren=[Si];Si.requiredContainer=Ai});var Tx,em,Nx,Ex=M(()=>{Tx=ot(si(),1);Kt();Ti();Mx();em=class extends je{static register(){R.register(Si),R.register(Ai),R.register(li),R.register(Br)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(Br).forEach(e=>{e.balanceCells()})}deleteColumn(){let[e,,t]=this.getTable();t!=null&&(e.deleteColumn(t.cellOffset()),this.quill.update(R.sources.USER))}deleteRow(){let[,e]=this.getTable();e!=null&&(e.remove(),this.quill.update(R.sources.USER))}deleteTable(){let[e]=this.getTable();if(e==null)return;let t=e.offset();e.remove(),this.quill.update(R.sources.USER),this.quill.setSelection(t,R.sources.SILENT)}getTable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(e==null)return[null,null,null,-1];let[t,r]=this.quill.getLine(e.index);if(t==null||t.statics.blotName!==Si.blotName)return[null,null,null,-1];let n=t.parent;return[n.parent.parent,n,t,r]}insertColumn(e){let t=this.quill.getSelection();if(!t)return;let[r,n,s]=this.getTable(t);if(s==null)return;let a=s.cellOffset();r.insertColumn(a+e),this.quill.update(R.sources.USER);let o=n.rowOffset();e===0&&(o+=1),this.quill.setSelection(t.index+o,t.length,R.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(e){let t=this.quill.getSelection();if(!t)return;let[r,n,s]=this.getTable(t);if(s==null)return;let a=n.rowOffset();r.insertRow(a+e),this.quill.update(R.sources.USER),e>0?this.quill.setSelection(t,R.sources.SILENT):this.quill.setSelection(t.index+n.children.length,t.length,R.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(e,t){let r=this.quill.getSelection();if(r==null)return;let n=new Array(e).fill(0).reduce(s=>{let a=new Array(t).fill(` -`).join("");return s.insert(a,{table:Md()})},new Tx.default().retain(r.index));this.quill.updateContents(n,R.sources.USER),this.quill.setSelection(r.index,R.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(R.events.SCROLL_OPTIMIZE,e=>{e.some(t=>["TD","TR","TBODY","TABLE"].includes(t.target.tagName)?(this.quill.once(R.events.TEXT_CHANGE,(r,n,s)=>{s===R.sources.USER&&this.balanceTables()}),!0):!1)})}},Nx=em});function Ax(i,e,t){let r=document.createElement("button");r.setAttribute("type","button"),r.classList.add(`ql-${e}`),r.setAttribute("aria-pressed","false"),t!=null?(r.value=t,r.setAttribute("aria-label",`${e}: ${t}`)):r.setAttribute("aria-label",e),i.appendChild(r)}function zD(i,e){Array.isArray(e[0])||(e=[e]),e.forEach(t=>{let r=document.createElement("span");r.classList.add("ql-formats"),t.forEach(n=>{if(typeof n=="string")Ax(r,n);else{let s=Object.keys(n)[0],a=n[s];Array.isArray(a)?ID(r,s,a):Ax(r,s,a)}}),i.appendChild(r)})}function ID(i,e,t){let r=document.createElement("select");r.classList.add(`ql-${e}`),t.forEach(n=>{let s=document.createElement("option");n!==!1?s.setAttribute("value",String(n)):s.setAttribute("selected","selected"),r.appendChild(s)}),i.appendChild(r)}var kx,Sx,Aa,Cx=M(()=>{kx=ot(si(),1);Ae();Kt();ns();Ti();Sx=ai("quill:toolbar"),Aa=class extends je{constructor(e,t){if(super(e,t),Array.isArray(this.options.container)){let r=document.createElement("div");r.setAttribute("role","toolbar"),zD(r,this.options.container),e.container?.parentNode?.insertBefore(r,e.container),this.container=r}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){Sx.error("Container required for toolbar",this.options);return}this.container.classList.add("ql-toolbar"),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(r=>{let n=this.options.handlers?.[r];n&&this.addHandler(r,n)}),Array.from(this.container.querySelectorAll("button, select")).forEach(r=>{this.attach(r)}),this.quill.on(R.events.EDITOR_CHANGE,()=>{let[r]=this.quill.selection.getRange();this.update(r)})}addHandler(e,t){this.handlers[e]=t}attach(e){let t=Array.from(e.classList).find(n=>n.indexOf("ql-")===0);if(!t)return;if(t=t.slice(3),e.tagName==="BUTTON"&&e.setAttribute("type","button"),this.handlers[t]==null&&this.quill.scroll.query(t)==null){Sx.warn("ignoring attaching to nonexistent format",t,e);return}let r=e.tagName==="SELECT"?"change":"click";e.addEventListener(r,n=>{let s;if(e.tagName==="SELECT"){if(e.selectedIndex<0)return;let o=e.options[e.selectedIndex];o.hasAttribute("selected")?s=!1:s=o.value||!1}else e.classList.contains("ql-active")?s=!1:s=e.value||!e.hasAttribute("value"),n.preventDefault();this.quill.focus();let[a]=this.quill.selection.getRange();if(this.handlers[t]!=null)this.handlers[t].call(this,s);else if(this.quill.scroll.query(t).prototype instanceof Ue){if(s=prompt(`Enter ${t}`),!s)return;this.quill.updateContents(new kx.default().retain(a.index).delete(a.length).insert({[t]:s}),R.sources.USER)}else this.quill.format(t,s,R.sources.USER);this.update(a)}),this.controls.push([t,e])}update(e){let t=e==null?{}:this.quill.getFormat(e);this.controls.forEach(r=>{let[n,s]=r;if(s.tagName==="SELECT"){let a=null;if(e==null)a=null;else if(t[n]==null)a=s.querySelector("option[selected]");else if(!Array.isArray(t[n])){let o=t[n];typeof o=="string"&&(o=o.replace(/"/g,'\\"')),a=s.querySelector(`option[value="${o}"]`)}a==null?(s.value="",s.selectedIndex=-1):a.selected=!0}else if(e==null)s.classList.remove("ql-active"),s.setAttribute("aria-pressed","false");else if(s.hasAttribute("value")){let a=t[n],o=a===s.getAttribute("value")||a!=null&&a.toString()===s.getAttribute("value")||a==null&&!s.getAttribute("value");s.classList.toggle("ql-active",o),s.setAttribute("aria-pressed",o.toString())}else{let a=t[n]!=null;s.classList.toggle("ql-active",a),s.setAttribute("aria-pressed",a.toString())}})}};Aa.DEFAULTS={};Aa.DEFAULTS={container:null,handlers:{clean(){let i=this.quill.getSelection();if(i!=null)if(i.length===0){let e=this.quill.getFormat();Object.keys(e).forEach(t=>{this.quill.scroll.query(t,Y.INLINE)!=null&&this.quill.format(t,!1,R.sources.USER)})}else this.quill.removeFormat(i.index,i.length,R.sources.USER)},direction(i){let{align:e}=this.quill.getFormat();i==="rtl"&&e==null?this.quill.format("align","right",R.sources.USER):!i&&e==="right"&&this.quill.format("align",!1,R.sources.USER),this.quill.format("direction",i,R.sources.USER)},indent(i){let e=this.quill.getSelection(),t=this.quill.getFormat(e),r=parseInt(t.indent||0,10);if(i==="+1"||i==="-1"){let n=i==="+1"?1:-1;t.direction==="rtl"&&(n*=-1),this.quill.format("indent",r+n,R.sources.USER)}},link(i){i===!0&&(i=prompt("Enter link URL:")),this.quill.format("link",i,R.sources.USER)},list(i){let e=this.quill.getSelection(),t=this.quill.getFormat(e);i==="check"?t.list==="checked"||t.list==="unchecked"?this.quill.format("list",!1,R.sources.USER):this.quill.format("list","unchecked",R.sources.USER):this.quill.format("list",i,R.sources.USER)}}}});var RD,DD,OD,BD,PD,FD,qD,HD,_x,UD,$D,jD,GD,YD,WD,VD,XD,KD,ZD,QD,JD,eO,tO,iO,rO,nO,sO,aO,oO,lO,hO,dO,cO,Mn,Td=M(()=>{RD='',DD='',OD='',BD='',PD='',FD='',qD='',HD='',_x='',UD='',$D='',jD='',GD='',YD='',WD='',VD='',XD='',KD='',ZD='',QD='',JD='',eO='',tO='',iO='',rO='',nO='',sO='',aO='',oO='',lO='',hO='',dO='',cO='',Mn={align:{"":RD,center:DD,right:OD,justify:BD},background:PD,blockquote:FD,bold:qD,clean:HD,code:_x,"code-block":_x,color:UD,direction:{"":$D,rtl:jD},formula:GD,header:{1:YD,2:WD,3:VD,4:XD,5:KD,6:ZD},italic:QD,image:JD,indent:{"+1":eO,"-1":tO},link:iO,list:{bullet:rO,check:nO,ordered:sO},script:{sub:aO,super:oO},strike:lO,table:hO,underline:dO,video:cO}});function zx(i,e){i.setAttribute(e,`${i.getAttribute(e)!=="true"}`)}var uO,Lx,tm,Tn,Al=M(()=>{uO='',Lx=0;tm=class{constructor(e){this.select=e,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",()=>{this.togglePicker()}),this.label.addEventListener("keydown",t=>{switch(t.key){case"Enter":this.togglePicker();break;case"Escape":this.escape(),t.preventDefault();break;default:}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),zx(this.label,"aria-expanded"),zx(this.options,"aria-hidden")}buildItem(e){let t=document.createElement("span");t.tabIndex="0",t.setAttribute("role","button"),t.classList.add("ql-picker-item");let r=e.getAttribute("value");return r&&t.setAttribute("data-value",r),e.textContent&&t.setAttribute("data-label",e.textContent),t.addEventListener("click",()=>{this.selectItem(t,!0)}),t.addEventListener("keydown",n=>{switch(n.key){case"Enter":this.selectItem(t,!0),n.preventDefault();break;case"Escape":this.escape(),n.preventDefault();break;default:}}),t}buildLabel(){let e=document.createElement("span");return e.classList.add("ql-picker-label"),e.innerHTML=uO,e.tabIndex="0",e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),this.container.appendChild(e),e}buildOptions(){let e=document.createElement("span");e.classList.add("ql-picker-options"),e.setAttribute("aria-hidden","true"),e.tabIndex="-1",e.id=`ql-picker-options-${Lx}`,Lx+=1,this.label.setAttribute("aria-controls",e.id),this.options=e,Array.from(this.select.options).forEach(t=>{let r=this.buildItem(t);e.appendChild(r),t.selected===!0&&this.selectItem(r)}),this.container.appendChild(e)}buildPicker(){Array.from(this.select.attributes).forEach(e=>{this.container.setAttribute(e.name,e.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}selectItem(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=this.container.querySelector(".ql-selected");e!==r&&(r?.classList.remove("ql-selected"),e!=null&&(e.classList.add("ql-selected"),this.select.selectedIndex=Array.from(e.parentNode.children).indexOf(e),e.hasAttribute("data-value")?this.label.setAttribute("data-value",e.getAttribute("data-value")):this.label.removeAttribute("data-value"),e.hasAttribute("data-label")?this.label.setAttribute("data-label",e.getAttribute("data-label")):this.label.removeAttribute("data-label"),t&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let e;if(this.select.selectedIndex>-1){let r=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];e=this.select.options[this.select.selectedIndex],this.selectItem(r)}else this.selectItem(null);let t=e!=null&&e!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",t)}},Tn=tm});var im,Nd,rm=M(()=>{Al();im=class extends Tn{constructor(e,t){super(e),this.label.innerHTML=t,this.container.classList.add("ql-color-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).slice(0,7).forEach(r=>{r.classList.add("ql-primary")})}buildItem(e){let t=super.buildItem(e);return t.style.backgroundColor=e.getAttribute("value")||"",t}selectItem(e,t){super.selectItem(e,t);let r=this.label.querySelector(".ql-color-label"),n=e&&e.getAttribute("data-value")||"";r&&(r.tagName==="line"?r.style.stroke=n:r.style.fill=n)}},Nd=im});var nm,Ed,sm=M(()=>{Al();nm=class extends Tn{constructor(e,t){super(e),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(r=>{r.innerHTML=t[r.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(e,t){super.selectItem(e,t);let r=e||this.defaultItem;if(r!=null){if(this.label.innerHTML===r.innerHTML)return;this.label.innerHTML=r.innerHTML}}},Ed=nm});var fO,am,Sd,om=M(()=>{fO=i=>{let{overflowY:e}=getComputedStyle(i,null);return e!=="visible"&&e!=="clip"},am=class{constructor(e,t){this.quill=e,this.boundsContainer=t||document.body,this.root=e.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,fO(this.quill.root)&&this.quill.root.addEventListener("scroll",()=>{this.root.style.marginTop=`${-1*this.quill.root.scrollTop}px`}),this.hide()}hide(){this.root.classList.add("ql-hidden")}position(e){let t=e.left+e.width/2-this.root.offsetWidth/2,r=e.bottom+this.quill.root.scrollTop;this.root.style.left=`${t}px`,this.root.style.top=`${r}px`,this.root.classList.remove("ql-flip");let n=this.boundsContainer.getBoundingClientRect(),s=this.root.getBoundingClientRect(),a=0;if(s.right>n.right&&(a=n.right-s.right,this.root.style.left=`${t+a}px`),s.leftn.bottom){let o=s.bottom-s.top,l=e.bottom-e.top+o;this.root.style.top=`${r-l}px`,this.root.classList.add("ql-flip")}return a}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}},Sd=am});function yO(i){let e=i.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||i.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return e?`${e[1]||"https"}://www.youtube.com/embed/${e[2]}?showinfo=0`:(e=i.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${e[1]||"https"}://player.vimeo.com/video/${e[2]}/`:i}function kl(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;e.forEach(r=>{let n=document.createElement("option");r===t?n.setAttribute("selected","selected"):n.setAttribute("value",String(r)),i.appendChild(n)})}var mO,pO,gO,xO,vO,Pr,ka,lm=M(()=>{ln();Rr();Af();rm();sm();Al();om();mO=[!1,"center","right","justify"],pO=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],gO=[!1,"serif","monospace"],xO=["1","2","3",!1],vO=["small",!1,"large","huge"],Pr=class extends ba{constructor(e,t){super(e,t);let r=n=>{if(!document.body.contains(e.root)){document.body.removeEventListener("click",r);return}this.tooltip!=null&&!this.tooltip.root.contains(n.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(s=>{s.container.contains(n.target)||s.close()})};e.emitter.listenDOM("click",document.body,r)}addModule(e){let t=super.addModule(e);return e==="toolbar"&&this.extendToolbar(t),t}buildButtons(e,t){Array.from(e).forEach(r=>{(r.getAttribute("class")||"").split(/\s+/).forEach(s=>{if(s.startsWith("ql-")&&(s=s.slice(3),t[s]!=null))if(s==="direction")r.innerHTML=t[s][""]+t[s].rtl;else if(typeof t[s]=="string")r.innerHTML=t[s];else{let a=r.value||"";a!=null&&t[s][a]&&(r.innerHTML=t[s][a])}})})}buildPickers(e,t){this.pickers=Array.from(e).map(n=>{if(n.classList.contains("ql-align")&&(n.querySelector("option")==null&&kl(n,mO),typeof t.align=="object"))return new Ed(n,t.align);if(n.classList.contains("ql-background")||n.classList.contains("ql-color")){let s=n.classList.contains("ql-background")?"background":"color";return n.querySelector("option")==null&&kl(n,pO,s==="background"?"#ffffff":"#000000"),new Nd(n,t[s])}return n.querySelector("option")==null&&(n.classList.contains("ql-font")?kl(n,gO):n.classList.contains("ql-header")?kl(n,xO):n.classList.contains("ql-size")&&kl(n,vO)),new Tn(n)});let r=()=>{this.pickers.forEach(n=>{n.update()})};this.quill.on(K.events.EDITOR_CHANGE,r)}};Pr.DEFAULTS=Yt({},ba.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let i=this.container.querySelector("input.ql-image[type=file]");i==null&&(i=document.createElement("input"),i.setAttribute("type","file"),i.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),i.classList.add("ql-image"),i.addEventListener("change",()=>{let e=this.quill.getSelection(!0);this.quill.uploader.upload(e,i.files),i.value=""}),this.container.appendChild(i)),i.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});ka=class extends Sd{constructor(e,t){super(e,t),this.textbox=this.root.querySelector('input[type="text"]'),this.listen()}listen(){this.textbox.addEventListener("keydown",e=>{e.key==="Enter"?(this.save(),e.preventDefault()):e.key==="Escape"&&(this.cancel(),e.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),this.textbox==null)return;t!=null?this.textbox.value=t:e!==this.root.getAttribute("data-mode")&&(this.textbox.value="");let r=this.quill.getBounds(this.quill.selection.savedRange);r!=null&&this.position(r),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${e}`)||""),this.root.setAttribute("data-mode",e)}restoreFocus(){this.quill.focus({preventScroll:!0})}save(){let{value:e}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{let{scrollTop:t}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",e,K.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",e,K.sources.USER)),this.quill.root.scrollTop=t;break}case"video":e=yO(e);case"formula":{if(!e)break;let t=this.quill.getSelection(!0);if(t!=null){let r=t.index+t.length;this.quill.insertEmbed(r,this.root.getAttribute("data-mode"),e,K.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(r+1," ",K.sources.USER),this.quill.setSelection(r+2,K.sources.USER)}break}default:}this.textbox.value="",this.hide()}}});var bO,Ad,Cl,Ix=M(()=>{ln();Rr();lm();nl();Td();Kt();bO=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],Ad=class extends ka{constructor(e,t){super(e,t),this.quill.on(K.events.EDITOR_CHANGE,(r,n,s,a)=>{if(r===K.events.SELECTION_CHANGE)if(n!=null&&n.length>0&&a===K.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;let o=this.quill.getLines(n.index,n.length);if(o.length===1){let l=this.quill.getBounds(n);l!=null&&this.position(l)}else{let l=o[o.length-1],h=this.quill.getIndex(l),d=Math.min(l.length()-1,n.index+n.length-h),c=this.quill.getBounds(new Lt(h,d));c!=null&&this.position(c)}}else document.activeElement!==this.textbox&&this.quill.hasFocus()&&this.hide()})}listen(){super.listen(),this.root.querySelector(".ql-close").addEventListener("click",()=>{this.root.classList.remove("ql-editing")}),this.quill.on(K.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;let e=this.quill.getSelection();if(e!=null){let t=this.quill.getBounds(e);t!=null&&this.position(t)}},1)})}cancel(){this.show()}position(e){let t=super.position(e),r=this.root.querySelector(".ql-tooltip-arrow");return r.style.marginLeft="",t!==0&&(r.style.marginLeft=`${-1*t-r.offsetWidth/2}px`),t}};P(Ad,"TEMPLATE",['','
    ','','',"
    "].join(""));Cl=class extends Pr{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=bO),super(e,t),this.quill.container.classList.add("ql-bubble")}extendToolbar(e){this.tooltip=new Ad(this.quill,this.options.bounds),e.container!=null&&(this.tooltip.root.appendChild(e.container),this.buildButtons(e.container.querySelectorAll("button"),Mn),this.buildPickers(e.container.querySelectorAll("select"),Mn))}};Cl.DEFAULTS=Yt({},Pr.DEFAULTS,{modules:{toolbar:{handlers:{link(i){i?this.quill.theme.tooltip.edit():this.quill.format("link",!1,R.sources.USER)}}}}})});var wO,kd,Cd,Rx,Dx=M(()=>{ln();Rr();lm();yl();nl();Td();Kt();wO=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],kd=class extends ka{constructor(){super(...arguments);P(this,"preview",this.root.querySelector("a.ql-preview"))}listen(){super.listen(),this.root.querySelector("a.ql-action").addEventListener("click",t=>{this.root.classList.contains("ql-editing")?this.save():this.edit("link",this.preview.textContent),t.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",t=>{if(this.linkRange!=null){let r=this.linkRange;this.restoreFocus(),this.quill.formatText(r,"link",!1,K.sources.USER),delete this.linkRange}t.preventDefault(),this.hide()}),this.quill.on(K.events.SELECTION_CHANGE,(t,r,n)=>{if(t!=null){if(t.length===0&&n===K.sources.USER){let[s,a]=this.quill.scroll.descendant(oi,t.index);if(s!=null){this.linkRange=new Lt(t.index-a,s.length());let o=oi.formats(s.domNode);this.preview.textContent=o,this.preview.setAttribute("href",o),this.show();let l=this.quill.getBounds(this.linkRange);l!=null&&this.position(l);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}};P(kd,"TEMPLATE",['','','',''].join(""));Cd=class extends Pr{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=wO),super(e,t),this.quill.container.classList.add("ql-snow")}extendToolbar(e){e.container!=null&&(e.container.classList.add("ql-snow"),this.buildButtons(e.container.querySelectorAll("button"),Mn),this.buildPickers(e.container.querySelectorAll("select"),Mn),this.tooltip=new kd(this.quill,this.options.bounds),e.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(t,r)=>{e.handlers.link.call(e,!r.format.link)}))}};Cd.DEFAULTS=Yt({},Pr.DEFAULTS,{modules:{toolbar:{handlers:{link(i){if(i){let e=this.quill.getSelection();if(e==null||e.length===0)return;let t=this.quill.getText(e);/^\S+@\S+\.\S+$/.test(t)&&t.indexOf("mailto:")!==0&&(t=`mailto:${t}`);let{tooltip:r}=this.quill.theme;r.edit("link",t)}else this.quill.format("link",!1,R.sources.USER)}}}}});Rx=Cd});var _d,Ox=M(()=>{Zf();If();Bf();J9();tx();rx();nx();Rf();ld();qf();Uf();bd();ax();yl();lx();dx();ux();mx();xx();bx();hd();wx();Ex();Cx();Td();Al();rm();sm();om();Ix();Dx();Zf();yd.register({"attributors/attribute/direction":dd,"attributors/class/align":zf,"attributors/class/background":_9,"attributors/class/color":C9,"attributors/class/direction":Of,"attributors/class/font":Ff,"attributors/class/size":Hf,"attributors/style/align":od,"attributors/style/background":hl,"attributors/style/color":ll,"attributors/style/direction":cd,"attributors/style/font":ud,"attributors/style/size":fd},!0);yd.register({"formats/align":zf,"formats/direction":Of,"formats/indent":Q9,"formats/background":hl,"formats/color":ll,"formats/font":Ff,"formats/size":Hf,"formats/blockquote":ex,"formats/code-block":Xe,"formats/header":ix,"formats/list":wn,"formats/bold":Na,"formats/code":Ta,"formats/italic":sx,"formats/link":oi,"formats/script":ox,"formats/strike":hx,"formats/underline":cx,"formats/formula":fx,"formats/image":gx,"formats/video":yx,"modules/syntax":El,"modules/table":Nx,"modules/toolbar":Aa,"themes/bubble":Cl,"themes/snow":Rx,"ui/icons":Mn,"ui/picker":Tn,"ui/icon-picker":Ed,"ui/color-picker":Nd,"ui/tooltip":Sd},!0);_d=yd});var Bx,Px,Fx=M(()=>{Bx=i=>` +`,{[st.blotName]:t}),a.insert(o)),s)],new WeakMap)}};i0.DEFAULTS={hljs:window.hljs,interval:1e3,languages:[{key:"plain",label:"Plain"},{key:"bash",label:"Bash"},{key:"cpp",label:"C++"},{key:"cs",label:"C#"},{key:"css",label:"CSS"},{key:"diff",label:"Diff"},{key:"xml",label:"HTML/XML"},{key:"java",label:"Java"},{key:"javascript",label:"JavaScript"},{key:"markdown",label:"Markdown"},{key:"php",label:"PHP"},{key:"python",label:"Python"},{key:"ruby",label:"Ruby"},{key:"sql",label:"SQL"}]}});function cc(){return`row-${Math.random().toString(36).slice(2,6)}`}var r0,Pi,Fi,yi,tn,tv=T(()=>{zi();Ja();r0=class r0 extends De{static create(e){let t=super.create();return e?t.setAttribute("data-row",e):t.setAttribute("data-row",cc()),t}static formats(e){if(e.hasAttribute("data-row"))return e.getAttribute("data-row")}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(e,t){e===r0.blotName&&t?this.domNode.setAttribute("data-row",t):super.format(e,t)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}};U(r0,"blotName","table"),U(r0,"tagName","TD");Pi=r0,Fi=class extends Oi{checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){let e=this.children.head.formats(),t=this.children.tail.formats(),r=this.next.children.head.formats(),n=this.next.children.tail.formats();return e.table===t.table&&e.table===r.table&&e.table===n.table}return!1}optimize(e){super.optimize(e),this.children.forEach(t=>{if(t.next==null)return;let r=t.formats(),n=t.next.formats();if(r.table!==n.table){let s=this.splitAfter(t);s&&s.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}};U(Fi,"blotName","table-row"),U(Fi,"tagName","TR");yi=class extends Oi{};U(yi,"blotName","table-body"),U(yi,"tagName","TBODY");tn=class extends Oi{balanceCells(){let e=this.descendants(Fi),t=e.reduce((r,n)=>Math.max(n.children.length,r),0);e.forEach(r=>{new Array(t-r.children.length).fill(0).forEach(()=>{let n;r.children.head!=null&&(n=Pi.formats(r.children.head.domNode));let s=this.scroll.create(Pi.blotName,n);r.appendChild(s),s.optimize()})})}cells(e){return this.rows().map(t=>t.children.at(e))}deleteColumn(e){let[t]=this.descendant(yi);t==null||t.children.head==null||t.children.forEach(r=>{let n=r.children.at(e);n?.remove()})}insertColumn(e){let[t]=this.descendant(yi);t==null||t.children.head==null||t.children.forEach(r=>{let n=r.children.at(e),s=Pi.formats(r.children.head.domNode),a=this.scroll.create(Pi.blotName,s);r.insertBefore(a,n)})}insertRow(e){let[t]=this.descendant(yi);if(t==null||t.children.head==null)return;let r=cc(),n=this.scroll.create(Fi.blotName);t.children.head.children.forEach(()=>{let a=this.scroll.create(Pi.blotName,r);n.appendChild(a)});let s=t.children.at(e);t.insertBefore(n,s)}rows(){let e=this.children.head;return e==null?[]:e.children.map(t=>t)}};U(tn,"blotName","table-container"),U(tn,"tagName","TABLE");tn.allowedChildren=[yi];yi.requiredContainer=tn;yi.allowedChildren=[Fi];Fi.requiredContainer=yi;Fi.allowedChildren=[Pi];Pi.requiredContainer=Fi});var iv,tp,rv,nv=T(()=>{iv=pt(pi(),1);oi();Di();tv();tp=class extends Qe{static register(){B.register(Pi),B.register(Fi),B.register(yi),B.register(tn)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(tn).forEach(e=>{e.balanceCells()})}deleteColumn(){let[e,,t]=this.getTable();t!=null&&(e.deleteColumn(t.cellOffset()),this.quill.update(B.sources.USER))}deleteRow(){let[,e]=this.getTable();e!=null&&(e.remove(),this.quill.update(B.sources.USER))}deleteTable(){let[e]=this.getTable();if(e==null)return;let t=e.offset();e.remove(),this.quill.update(B.sources.USER),this.quill.setSelection(t,B.sources.SILENT)}getTable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(e==null)return[null,null,null,-1];let[t,r]=this.quill.getLine(e.index);if(t==null||t.statics.blotName!==Pi.blotName)return[null,null,null,-1];let n=t.parent;return[n.parent.parent,n,t,r]}insertColumn(e){let t=this.quill.getSelection();if(!t)return;let[r,n,s]=this.getTable(t);if(s==null)return;let a=s.cellOffset();r.insertColumn(a+e),this.quill.update(B.sources.USER);let o=n.rowOffset();e===0&&(o+=1),this.quill.setSelection(t.index+o,t.length,B.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(e){let t=this.quill.getSelection();if(!t)return;let[r,n,s]=this.getTable(t);if(s==null)return;let a=n.rowOffset();r.insertRow(a+e),this.quill.update(B.sources.USER),e>0?this.quill.setSelection(t,B.sources.SILENT):this.quill.setSelection(t.index+n.children.length,t.length,B.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(e,t){let r=this.quill.getSelection();if(r==null)return;let n=new Array(e).fill(0).reduce(s=>{let a=new Array(t).fill(` +`).join("");return s.insert(a,{table:cc()})},new iv.default().retain(r.index));this.quill.updateContents(n,B.sources.USER),this.quill.setSelection(r.index,B.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(B.events.SCROLL_OPTIMIZE,e=>{e.some(t=>["TD","TR","TBODY","TABLE"].includes(t.target.tagName)?(this.quill.once(B.events.TEXT_CHANGE,(r,n,s)=>{s===B.sources.USER&&this.balanceTables()}),!0):!1)})}},rv=tp});function av(i,e,t){let r=document.createElement("button");r.setAttribute("type","button"),r.classList.add(`ql-${e}`),r.setAttribute("aria-pressed","false"),t!=null?(r.value=t,r.setAttribute("aria-label",`${e}: ${t}`)):r.setAttribute("aria-label",e),i.appendChild(r)}function WB(i,e){Array.isArray(e[0])||(e=[e]),e.forEach(t=>{let r=document.createElement("span");r.classList.add("ql-formats"),t.forEach(n=>{if(typeof n=="string")av(r,n);else{let s=Object.keys(n)[0],a=n[s];Array.isArray(a)?YB(r,s,a):av(r,s,a)}}),i.appendChild(r)})}function YB(i,e,t){let r=document.createElement("select");r.classList.add(`ql-${e}`),t.forEach(n=>{let s=document.createElement("option");n!==!1?s.setAttribute("value",String(n)):s.setAttribute("selected","selected"),r.appendChild(s)}),i.appendChild(r)}var ov,sv,no,lv=T(()=>{ov=pt(pi(),1);Re();oi();Cs();Di();sv=gi("quill:toolbar"),no=class extends Qe{constructor(e,t){if(super(e,t),Array.isArray(this.options.container)){let r=document.createElement("div");r.setAttribute("role","toolbar"),WB(r,this.options.container),e.container?.parentNode?.insertBefore(r,e.container),this.container=r}else typeof this.options.container=="string"?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){sv.error("Container required for toolbar",this.options);return}this.container.classList.add("ql-toolbar"),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(r=>{let n=this.options.handlers?.[r];n&&this.addHandler(r,n)}),Array.from(this.container.querySelectorAll("button, select")).forEach(r=>{this.attach(r)}),this.quill.on(B.events.EDITOR_CHANGE,()=>{let[r]=this.quill.selection.getRange();this.update(r)})}addHandler(e,t){this.handlers[e]=t}attach(e){let t=Array.from(e.classList).find(n=>n.indexOf("ql-")===0);if(!t)return;if(t=t.slice(3),e.tagName==="BUTTON"&&e.setAttribute("type","button"),this.handlers[t]==null&&this.quill.scroll.query(t)==null){sv.warn("ignoring attaching to nonexistent format",t,e);return}let r=e.tagName==="SELECT"?"change":"click";e.addEventListener(r,n=>{let s;if(e.tagName==="SELECT"){if(e.selectedIndex<0)return;let o=e.options[e.selectedIndex];o.hasAttribute("selected")?s=!1:s=o.value||!1}else e.classList.contains("ql-active")?s=!1:s=e.value||!e.hasAttribute("value"),n.preventDefault();this.quill.focus();let[a]=this.quill.selection.getRange();if(this.handlers[t]!=null)this.handlers[t].call(this,s);else if(this.quill.scroll.query(t).prototype instanceof Ke){if(s=prompt(`Enter ${t}`),!s)return;this.quill.updateContents(new ov.default().retain(a.index).delete(a.length).insert({[t]:s}),B.sources.USER)}else this.quill.format(t,s,B.sources.USER);this.update(a)}),this.controls.push([t,e])}update(e){let t=e==null?{}:this.quill.getFormat(e);this.controls.forEach(r=>{let[n,s]=r;if(s.tagName==="SELECT"){let a=null;if(e==null)a=null;else if(t[n]==null)a=s.querySelector("option[selected]");else if(!Array.isArray(t[n])){let o=t[n];typeof o=="string"&&(o=o.replace(/"/g,'\\"')),a=s.querySelector(`option[value="${o}"]`)}a==null?(s.value="",s.selectedIndex=-1):a.selected=!0}else if(e==null)s.classList.remove("ql-active"),s.setAttribute("aria-pressed","false");else if(s.hasAttribute("value")){let a=t[n],o=a===s.getAttribute("value")||a!=null&&a.toString()===s.getAttribute("value")||a==null&&!s.getAttribute("value");s.classList.toggle("ql-active",o),s.setAttribute("aria-pressed",o.toString())}else{let a=t[n]!=null;s.classList.toggle("ql-active",a),s.setAttribute("aria-pressed",a.toString())}})}};no.DEFAULTS={};no.DEFAULTS={container:null,handlers:{clean(){let i=this.quill.getSelection();if(i!=null)if(i.length===0){let e=this.quill.getFormat();Object.keys(e).forEach(t=>{this.quill.scroll.query(t,X.INLINE)!=null&&this.quill.format(t,!1,B.sources.USER)})}else this.quill.removeFormat(i.index,i.length,B.sources.USER)},direction(i){let{align:e}=this.quill.getFormat();i==="rtl"&&e==null?this.quill.format("align","right",B.sources.USER):!i&&e==="right"&&this.quill.format("align",!1,B.sources.USER),this.quill.format("direction",i,B.sources.USER)},indent(i){let e=this.quill.getSelection(),t=this.quill.getFormat(e),r=parseInt(t.indent||0,10);if(i==="+1"||i==="-1"){let n=i==="+1"?1:-1;t.direction==="rtl"&&(n*=-1),this.quill.format("indent",r+n,B.sources.USER)}},link(i){i===!0&&(i=prompt("Enter link URL:")),this.quill.format("link",i,B.sources.USER)},list(i){let e=this.quill.getSelection(),t=this.quill.getFormat(e);i==="check"?t.list==="checked"||t.list==="unchecked"?this.quill.format("list",!1,B.sources.USER):this.quill.format("list","unchecked",B.sources.USER):this.quill.format("list",i,B.sources.USER)}}}});var XB,KB,ZB,QB,JB,eP,tP,iP,hv,rP,nP,sP,aP,oP,lP,hP,dP,cP,uP,fP,mP,pP,gP,xP,yP,vP,bP,wP,MP,TP,NP,EP,SP,Un,uc=T(()=>{XB='',KB='',ZB='',QB='',JB='',eP='',tP='',iP='',hv='',rP='',nP='',sP='',aP='',oP='',lP='',hP='',dP='',cP='',uP='',fP='',mP='',pP='',gP='',xP='',yP='',vP='',bP='',wP='',MP='',TP='',NP='',EP='',SP='',Un={align:{"":XB,center:KB,right:ZB,justify:QB},background:JB,blockquote:eP,bold:tP,clean:iP,code:hv,"code-block":hv,color:rP,direction:{"":nP,rtl:sP},formula:aP,header:{1:oP,2:lP,3:hP,4:dP,5:cP,6:uP},italic:fP,image:mP,indent:{"+1":pP,"-1":gP},link:xP,list:{bullet:yP,check:vP,ordered:bP},script:{sub:wP,super:MP},strike:TP,table:NP,underline:EP,video:SP}});function cv(i,e){i.setAttribute(e,`${i.getAttribute(e)!=="true"}`)}var AP,dv,ip,$n,n0=T(()=>{AP='',dv=0;ip=class{constructor(e){this.select=e,this.container=document.createElement("span"),this.buildPicker(),this.select.style.display="none",this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener("mousedown",()=>{this.togglePicker()}),this.label.addEventListener("keydown",t=>{switch(t.key){case"Enter":this.togglePicker();break;case"Escape":this.escape(),t.preventDefault();break;default:}}),this.select.addEventListener("change",this.update.bind(this))}togglePicker(){this.container.classList.toggle("ql-expanded"),cv(this.label,"aria-expanded"),cv(this.options,"aria-hidden")}buildItem(e){let t=document.createElement("span");t.tabIndex="0",t.setAttribute("role","button"),t.classList.add("ql-picker-item");let r=e.getAttribute("value");return r&&t.setAttribute("data-value",r),e.textContent&&t.setAttribute("data-label",e.textContent),t.addEventListener("click",()=>{this.selectItem(t,!0)}),t.addEventListener("keydown",n=>{switch(n.key){case"Enter":this.selectItem(t,!0),n.preventDefault();break;case"Escape":this.escape(),n.preventDefault();break;default:}}),t}buildLabel(){let e=document.createElement("span");return e.classList.add("ql-picker-label"),e.innerHTML=AP,e.tabIndex="0",e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),this.container.appendChild(e),e}buildOptions(){let e=document.createElement("span");e.classList.add("ql-picker-options"),e.setAttribute("aria-hidden","true"),e.tabIndex="-1",e.id=`ql-picker-options-${dv}`,dv+=1,this.label.setAttribute("aria-controls",e.id),this.options=e,Array.from(this.select.options).forEach(t=>{let r=this.buildItem(t);e.appendChild(r),t.selected===!0&&this.selectItem(r)}),this.container.appendChild(e)}buildPicker(){Array.from(this.select.attributes).forEach(e=>{this.container.setAttribute(e.name,e.value)}),this.container.classList.add("ql-picker"),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove("ql-expanded"),this.label.setAttribute("aria-expanded","false"),this.options.setAttribute("aria-hidden","true")}selectItem(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=this.container.querySelector(".ql-selected");e!==r&&(r?.classList.remove("ql-selected"),e!=null&&(e.classList.add("ql-selected"),this.select.selectedIndex=Array.from(e.parentNode.children).indexOf(e),e.hasAttribute("data-value")?this.label.setAttribute("data-value",e.getAttribute("data-value")):this.label.removeAttribute("data-value"),e.hasAttribute("data-label")?this.label.setAttribute("data-label",e.getAttribute("data-label")):this.label.removeAttribute("data-label"),t&&(this.select.dispatchEvent(new Event("change")),this.close())))}update(){let e;if(this.select.selectedIndex>-1){let r=this.container.querySelector(".ql-picker-options").children[this.select.selectedIndex];e=this.select.options[this.select.selectedIndex],this.selectItem(r)}else this.selectItem(null);let t=e!=null&&e!==this.select.querySelector("option[selected]");this.label.classList.toggle("ql-active",t)}},$n=ip});var rp,fc,np=T(()=>{n0();rp=class extends $n{constructor(e,t){super(e),this.label.innerHTML=t,this.container.classList.add("ql-color-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).slice(0,7).forEach(r=>{r.classList.add("ql-primary")})}buildItem(e){let t=super.buildItem(e);return t.style.backgroundColor=e.getAttribute("value")||"",t}selectItem(e,t){super.selectItem(e,t);let r=this.label.querySelector(".ql-color-label"),n=e&&e.getAttribute("data-value")||"";r&&(r.tagName==="line"?r.style.stroke=n:r.style.fill=n)}},fc=rp});var sp,mc,ap=T(()=>{n0();sp=class extends $n{constructor(e,t){super(e),this.container.classList.add("ql-icon-picker"),Array.from(this.container.querySelectorAll(".ql-picker-item")).forEach(r=>{r.innerHTML=t[r.getAttribute("data-value")||""]}),this.defaultItem=this.container.querySelector(".ql-selected"),this.selectItem(this.defaultItem)}selectItem(e,t){super.selectItem(e,t);let r=e||this.defaultItem;if(r!=null){if(this.label.innerHTML===r.innerHTML)return;this.label.innerHTML=r.innerHTML}}},mc=sp});var kP,op,pc,lp=T(()=>{kP=i=>{let{overflowY:e}=getComputedStyle(i,null);return e!=="visible"&&e!=="clip"},op=class{constructor(e,t){this.quill=e,this.boundsContainer=t||document.body,this.root=e.addContainer("ql-tooltip"),this.root.innerHTML=this.constructor.TEMPLATE,kP(this.quill.root)&&this.quill.root.addEventListener("scroll",()=>{this.root.style.marginTop=`${-1*this.quill.root.scrollTop}px`}),this.hide()}hide(){this.root.classList.add("ql-hidden")}position(e){let t=e.left+e.width/2-this.root.offsetWidth/2,r=e.bottom+this.quill.root.scrollTop;this.root.style.left=`${t}px`,this.root.style.top=`${r}px`,this.root.classList.remove("ql-flip");let n=this.boundsContainer.getBoundingClientRect(),s=this.root.getBoundingClientRect(),a=0;if(s.right>n.right&&(a=n.right-s.right,this.root.style.left=`${t+a}px`),s.leftn.bottom){let o=s.bottom-s.top,l=e.bottom-e.top+o;this.root.style.top=`${r-l}px`,this.root.classList.add("ql-flip")}return a}show(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}},pc=op});function RP(i){let e=i.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||i.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return e?`${e[1]||"https"}://www.youtube.com/embed/${e[2]}?showinfo=0`:(e=i.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${e[1]||"https"}://player.vimeo.com/video/${e[2]}/`:i}function s0(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;e.forEach(r=>{let n=document.createElement("option");r===t?n.setAttribute("selected","selected"):n.setAttribute("value",String(r)),i.appendChild(n)})}var CP,_P,LP,IP,zP,rn,so,hp=T(()=>{kn();Qr();km();np();ap();n0();lp();CP=[!1,"center","right","justify"],_P=["#000000","#e60000","#ff9900","#ffff00","#008a00","#0066cc","#9933ff","#ffffff","#facccc","#ffebcc","#ffffcc","#cce8cc","#cce0f5","#ebd6ff","#bbbbbb","#f06666","#ffc266","#ffff66","#66b966","#66a3e0","#c285ff","#888888","#a10000","#b26b00","#b2b200","#006100","#0047b2","#6b24b2","#444444","#5c0000","#663d00","#666600","#003700","#002966","#3d1466"],LP=[!1,"serif","monospace"],IP=["1","2","3",!1],zP=["small",!1,"large","huge"],rn=class extends Za{constructor(e,t){super(e,t);let r=n=>{if(!document.body.contains(e.root)){document.body.removeEventListener("click",r);return}this.tooltip!=null&&!this.tooltip.root.contains(n.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(s=>{s.container.contains(n.target)||s.close()})};e.emitter.listenDOM("click",document.body,r)}addModule(e){let t=super.addModule(e);return e==="toolbar"&&this.extendToolbar(t),t}buildButtons(e,t){Array.from(e).forEach(r=>{(r.getAttribute("class")||"").split(/\s+/).forEach(s=>{if(s.startsWith("ql-")&&(s=s.slice(3),t[s]!=null))if(s==="direction")r.innerHTML=t[s][""]+t[s].rtl;else if(typeof t[s]=="string")r.innerHTML=t[s];else{let a=r.value||"";a!=null&&t[s][a]&&(r.innerHTML=t[s][a])}})})}buildPickers(e,t){this.pickers=Array.from(e).map(n=>{if(n.classList.contains("ql-align")&&(n.querySelector("option")==null&&s0(n,CP),typeof t.align=="object"))return new mc(n,t.align);if(n.classList.contains("ql-background")||n.classList.contains("ql-color")){let s=n.classList.contains("ql-background")?"background":"color";return n.querySelector("option")==null&&s0(n,_P,s==="background"?"#ffffff":"#000000"),new fc(n,t[s])}return n.querySelector("option")==null&&(n.classList.contains("ql-font")?s0(n,LP):n.classList.contains("ql-header")?s0(n,IP):n.classList.contains("ql-size")&&s0(n,zP)),new $n(n)});let r=()=>{this.pickers.forEach(n=>{n.update()})};this.quill.on(J.events.EDITOR_CHANGE,r)}};rn.DEFAULTS=ri({},Za.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit("formula")},image(){let i=this.container.querySelector("input.ql-image[type=file]");i==null&&(i=document.createElement("input"),i.setAttribute("type","file"),i.setAttribute("accept",this.quill.uploader.options.mimetypes.join(", ")),i.classList.add("ql-image"),i.addEventListener("change",()=>{let e=this.quill.getSelection(!0);this.quill.uploader.upload(e,i.files),i.value=""}),this.container.appendChild(i)),i.click()},video(){this.quill.theme.tooltip.edit("video")}}}}});so=class extends pc{constructor(e,t){super(e,t),this.textbox=this.root.querySelector('input[type="text"]'),this.listen()}listen(){this.textbox.addEventListener("keydown",e=>{e.key==="Enter"?(this.save(),e.preventDefault()):e.key==="Escape"&&(this.cancel(),e.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"link",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.root.classList.remove("ql-hidden"),this.root.classList.add("ql-editing"),this.textbox==null)return;t!=null?this.textbox.value=t:e!==this.root.getAttribute("data-mode")&&(this.textbox.value="");let r=this.quill.getBounds(this.quill.selection.savedRange);r!=null&&this.position(r),this.textbox.select(),this.textbox.setAttribute("placeholder",this.textbox.getAttribute(`data-${e}`)||""),this.root.setAttribute("data-mode",e)}restoreFocus(){this.quill.focus({preventScroll:!0})}save(){let{value:e}=this.textbox;switch(this.root.getAttribute("data-mode")){case"link":{let{scrollTop:t}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,"link",e,J.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format("link",e,J.sources.USER)),this.quill.root.scrollTop=t;break}case"video":e=RP(e);case"formula":{if(!e)break;let t=this.quill.getSelection(!0);if(t!=null){let r=t.index+t.length;this.quill.insertEmbed(r,this.root.getAttribute("data-mode"),e,J.sources.USER),this.root.getAttribute("data-mode")==="formula"&&this.quill.insertText(r+1," ",J.sources.USER),this.quill.setSelection(r+2,J.sources.USER)}break}default:}this.textbox.value="",this.hide()}}});var DP,gc,a0,uv=T(()=>{kn();Qr();hp();Dl();uc();oi();DP=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],gc=class extends so{constructor(e,t){super(e,t),this.quill.on(J.events.EDITOR_CHANGE,(r,n,s,a)=>{if(r===J.events.SELECTION_CHANGE)if(n!=null&&n.length>0&&a===J.sources.USER){this.show(),this.root.style.left="0px",this.root.style.width="",this.root.style.width=`${this.root.offsetWidth}px`;let o=this.quill.getLines(n.index,n.length);if(o.length===1){let l=this.quill.getBounds(n);l!=null&&this.position(l)}else{let l=o[o.length-1],h=this.quill.getIndex(l),d=Math.min(l.length()-1,n.index+n.length-h),c=this.quill.getBounds(new $t(h,d));c!=null&&this.position(c)}}else document.activeElement!==this.textbox&&this.quill.hasFocus()&&this.hide()})}listen(){super.listen(),this.root.querySelector(".ql-close").addEventListener("click",()=>{this.root.classList.remove("ql-editing")}),this.quill.on(J.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains("ql-hidden"))return;let e=this.quill.getSelection();if(e!=null){let t=this.quill.getBounds(e);t!=null&&this.position(t)}},1)})}cancel(){this.show()}position(e){let t=super.position(e),r=this.root.querySelector(".ql-tooltip-arrow");return r.style.marginLeft="",t!==0&&(r.style.marginLeft=`${-1*t-r.offsetWidth/2}px`),t}};U(gc,"TEMPLATE",['','
    ','','',"
    "].join(""));a0=class extends rn{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=DP),super(e,t),this.quill.container.classList.add("ql-bubble")}extendToolbar(e){this.tooltip=new gc(this.quill,this.options.bounds),e.container!=null&&(this.tooltip.root.appendChild(e.container),this.buildButtons(e.container.querySelectorAll("button"),Un),this.buildPickers(e.container.querySelectorAll("select"),Un))}};a0.DEFAULTS=ri({},rn.DEFAULTS,{modules:{toolbar:{handlers:{link(i){i?this.quill.theme.tooltip.edit():this.quill.format("link",!1,B.sources.USER)}}}}})});var OP,xc,yc,fv,mv=T(()=>{kn();Qr();hp();Kl();Dl();uc();oi();OP=[[{header:["1","2","3",!1]}],["bold","italic","underline","link"],[{list:"ordered"},{list:"bullet"}],["clean"]],xc=class extends so{constructor(){super(...arguments);U(this,"preview",this.root.querySelector("a.ql-preview"))}listen(){super.listen(),this.root.querySelector("a.ql-action").addEventListener("click",t=>{this.root.classList.contains("ql-editing")?this.save():this.edit("link",this.preview.textContent),t.preventDefault()}),this.root.querySelector("a.ql-remove").addEventListener("click",t=>{if(this.linkRange!=null){let r=this.linkRange;this.restoreFocus(),this.quill.formatText(r,"link",!1,J.sources.USER),delete this.linkRange}t.preventDefault(),this.hide()}),this.quill.on(J.events.SELECTION_CHANGE,(t,r,n)=>{if(t!=null){if(t.length===0&&n===J.sources.USER){let[s,a]=this.quill.scroll.descendant(xi,t.index);if(s!=null){this.linkRange=new $t(t.index-a,s.length());let o=xi.formats(s.domNode);this.preview.textContent=o,this.preview.setAttribute("href",o),this.show();let l=this.quill.getBounds(this.linkRange);l!=null&&this.position(l);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute("data-mode")}};U(xc,"TEMPLATE",['','','',''].join(""));yc=class extends rn{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=OP),super(e,t),this.quill.container.classList.add("ql-snow")}extendToolbar(e){e.container!=null&&(e.container.classList.add("ql-snow"),this.buildButtons(e.container.querySelectorAll("button"),Un),this.buildPickers(e.container.querySelectorAll("select"),Un),this.tooltip=new xc(this.quill,this.options.bounds),e.container.querySelector(".ql-link")&&this.quill.keyboard.addBinding({key:"k",shortKey:!0},(t,r)=>{e.handlers.link.call(e,!r.format.link)}))}};yc.DEFAULTS=ri({},rn.DEFAULTS,{modules:{toolbar:{handlers:{link(i){if(i){let e=this.quill.getSelection();if(e==null||e.length===0)return;let t=this.quill.getText(e);/^\S+@\S+\.\S+$/.test(t)&&t.indexOf("mailto:")!==0&&(t=`mailto:${t}`);let{tooltip:r}=this.quill.theme;r.edit("link",t)}else this.quill.format("link",!1,B.sources.USER)}}}}});fv=yc});var vc,pv=T(()=>{Qm();Rm();Pm();Iy();Ry();Oy();By();Dm();Zd();Hm();$m();hc();Fy();Kl();Hy();$y();Gy();Wy();Ky();Jy();Qd();ev();nv();lv();uc();n0();np();ap();lp();uv();mv();Qm();lc.register({"attributors/attribute/direction":Jd,"attributors/class/align":zm,"attributors/class/background":hy,"attributors/class/color":ly,"attributors/class/direction":Bm,"attributors/class/font":qm,"attributors/class/size":Um,"attributors/style/align":Kd,"attributors/style/background":ql,"attributors/style/color":Fl,"attributors/style/direction":ec,"attributors/style/font":tc,"attributors/style/size":ic},!0);lc.register({"formats/align":zm,"formats/direction":Bm,"formats/indent":Ly,"formats/background":ql,"formats/color":Fl,"formats/font":qm,"formats/size":Um,"formats/blockquote":zy,"formats/code-block":st,"formats/header":Dy,"formats/list":Hn,"formats/bold":to,"formats/code":eo,"formats/italic":Py,"formats/link":xi,"formats/script":qy,"formats/strike":Uy,"formats/underline":jy,"formats/formula":Vy,"formats/image":Xy,"formats/video":Qy,"modules/syntax":i0,"modules/table":rv,"modules/toolbar":no,"themes/bubble":a0,"themes/snow":fv,"ui/icons":Un,"ui/picker":$n,"ui/icon-picker":mc,"ui/color-picker":fc,"ui/tooltip":pc},!0);vc=lc});var gv,xv,yv=T(()=>{gv=i=>` @font-face { font-family: 'KaTeX_AMS'; src: url(${i}fonts/KaTeX_AMS-Regular.woff2) format('woff2'), url(${i}fonts/KaTeX_AMS-Regular.woff) format('woff'), url(${i}fonts/KaTeX_AMS-Regular.ttf) format('truetype'); @@ -508,7 +508,7 @@ ${rs(this.code(e,t))} font-weight: normal; font-style: normal; } - `,Px=()=>` + `,xv=()=>` .katex { font: normal 1.21em KaTeX_Main, Times New Roman, serif; line-height: 1.2; @@ -536,7 +536,7 @@ ${rs(this.code(e,t))} overflow: hidden; } .katex .katex-html { - /* + /* ewline is an empty block at top level, between .base elements */ } .katex .katex-html > .newline { @@ -1472,27 +1472,27 @@ ewline is an empty block at top level, between .base elements */ body { counter-reset: katexEqnNo mmlEqnNo; } -`});var Hx={};ti(Hx,{default:()=>MO});var hm,qx,Ld,MO,Ux=M(()=>{k6();Ox();he();Fx();hm=!1,qx=_d.import("formats/formula"),Ld=class{constructor(e){this.opt=e,this.mindMap=e.mindMap,window.katex=W0,this.init(),this.config=this.getKatexConfig(),this.cssEl=null,this.addStyle(),this.extendQuill(),this.onDestroy=this.onDestroy.bind(this),this.mindMap.on("beforeDestroy",this.onDestroy)}onDestroy(){Object.getPrototypeOf(this.mindMap).constructor.instanceCount<=1&&(hm=!1,_d.register("formats/formula",qx,!0))}init(){this.mindMap.opt.enableEditFormulaInRichTextEdit&&(this.mindMap.opt.transformRichTextOnEnterEdit=this.latexRichToText.bind(this),this.mindMap.opt.beforeHideRichTextEdit=this.formatLatex.bind(this))}getKatexConfig(){let e={throwOnError:!1,errorColor:"#f00",output:"mathml"},{getKatexOutputType:t}=this.mindMap.opt;t=t||function(){let n=Jp();if(n&&n<=100)return"html"};let r=t()||"mathml";return e.output=["mathml","html"].includes(r)?r:"mathml",e}extendQuill(){if(hm)return;hm=!0;let e=this;class t extends qx{static create(n){let s=super.create(n);return typeof n=="string"&&(W0.render(n,s,e.config),s.setAttribute("data-value",Wr(n))),s}}_d.register("formats/formula",t,!0)}getStyleText(){let{katexFontPath:e}=this.mindMap.opt,t="";return this.config.output==="html"&&(t=Bx(e)),t+=Px(),t}addStyle(){this.cssEl=document.createElement("style"),this.cssEl.type="text/css",this.cssEl.innerHTML=this.getStyleText(),document.head.appendChild(this.cssEl)}removeStyle(){document.head.removeChild(this.cssEl)}insertFormulaToNode(e,t){let r=this.mindMap.richText;r.showEditText({node:e}),r.quill.insertEmbed(r.quill.getLength()-1,"formula",t),r.hideEditText([e])}latexRichToText(e){if(e.indexOf('class="ql-formula"')!==-1){let n=new DOMParser().parseFromString(e,"text/html").getElementsByClassName("ql-formula");for(let s of n)e=e.replace(s.outerHTML,`$${s.getAttribute("data-value")}$`);this.mindMap.opt.openRealtimeRenderOnNodeTextEdit&&setTimeout(()=>{this.mindMap.emit("node_text_edit_change",{node:this.mindMap.richText.node,text:this.mindMap.richText.getEditText(),richText:!0})},0)}return e}formatLatex(e){let t=e.quill.getContents(),r=t.ops,n=!1;for(let s=r.length-1;s>=0;s--){let o=r[s].insert;if(o&&typeof o!="object"&&o!==` -`&&/\$.+?\$/g.test(o)){let l=[...o.matchAll(/\$.+?\$/g)],h=o.split(/\$.+?\$/g);for(let d=l.length-1;d>=0;d--){let c=l[d]&&l[d][0]&&l[d][0].slice(1,-1)||null;c!==null&&c.trim().length>0&&this.checkFormulaIsLegal(c)?(h.splice(d+1,0,{insert:{formula:c}}),n=!0):h.splice(d+1,0,"")}for(;h.length>0;){let d=h.pop();if(typeof d=="string"){if(d.length<1)continue;d={insert:d}}d.attributes=r[s].attributes,r.splice(s+1,0,d)}r.splice(s,1)}}n&&e.quill.setContents(t)}checkFormulaIsLegal(e){try{return W0.renderToString(e),!0}catch{return!1}}beforePluginRemove(){this.removeStyle(),this.mindMap.off("beforeDestroy",this.onDestroy)}beforePluginDestroy(){this.removeStyle(),this.mindMap.off("beforeDestroy",this.onDestroy)}};Ld.instanceName="formula";MO=Ld});var dm,$x,jx=M(()=>{Oe();dm=class{constructor(e={}){this.opt=e,this.mindMap=this.opt.mindMap,this.scale=1,this.sx=0,this.sy=0,this.x=0,this.y=0,this.firstDrag=!0,this.setTransformData(this.mindMap.opt.viewData),this.bind()}bind(){this.mindMap.keyCommand.addShortcut("Control+=",()=>{this.enlarge()}),this.mindMap.keyCommand.addShortcut("Control+-",()=>{this.narrow()}),this.mindMap.keyCommand.addShortcut("Control+i",()=>{this.fit()}),this.mindMap.event.on("mousedown",e=>{let{isDisableDrag:t,mousedownEventPreventDefault:r}=this.mindMap.opt;t||(r&&e.preventDefault(),this.sx=this.x,this.sy=this.y)}),this.mindMap.event.on("drag",(e,t)=>{e.ctrlKey||e.metaKey||this.mindMap.opt.isDisableDrag||(this.firstDrag&&(this.firstDrag=!1,this.mindMap.renderer.activeNodeList.length>0&&this.mindMap.execCommand("CLEAR_ACTIVE_NODE")),this.x=this.sx+t.mousemoveOffset.x,this.y=this.sy+t.mousemoveOffset.y,this.transform())}),this.mindMap.event.on("mouseup",()=>{this.firstDrag=!0}),this.mindMap.event.on("mousewheel",(e,t,r,n)=>{let{customHandleMousewheel:s,mousewheelAction:a,mouseScaleCenterUseMousePosition:o,mousewheelMoveStep:l,mousewheelZoomActionReverse:h,disableMouseWheelZoom:d,translateRatio:c}=this.mindMap.opt;if(s&&typeof s=="function")return s(e);if(a===A.MOUSE_WHEEL_ACTION.ZOOM||e.ctrlKey||e.metaKey){if(d)return;let{x:f,y:m}=this.mindMap.toPos(e.clientX,e.clientY),g=o?f:void 0,x=o?m:void 0;switch(n&&(t.includes(A.DIR.LEFT)||t.includes(A.DIR.RIGHT))&&(t=t.filter(v=>![A.DIR.LEFT,A.DIR.RIGHT].includes(v))),!0){case t.includes(A.DIR.UP||A.DIR.LEFT):h?this.enlarge(g,x,n):this.narrow(g,x,n);break;case t.includes(A.DIR.DOWN||A.DIR.RIGHT):h?this.narrow(g,x,n):this.enlarge(g,x,n);break}}else{let f=0,m=0;n?(f=Math.abs(e.wheelDeltaX),m=Math.abs(e.wheelDeltaY)):f=m=l;let g=0,x=0;t.includes(A.DIR.DOWN)&&(x=-m),t.includes(A.DIR.UP)&&(x=m),t.includes(A.DIR.LEFT)&&(g=f),t.includes(A.DIR.RIGHT)&&(g=-f),this.translateXY(g*c,x*c)}}),this.mindMap.on("resize",()=>{this.checkNeedMindMapInCanvas()&&this.transform()})}getTransformData(){return{transform:this.mindMap.draw.transform(),state:{scale:this.scale,x:this.x,y:this.y,sx:this.sx,sy:this.sy}}}setTransformData(e){e&&(Object.keys(e.state).forEach(t=>{this[t]=e.state[t]}),this.mindMap.draw.transform({...e.transform}),this.mindMap.emit("view_data_change",this.getTransformData()),this.emitEvent("scale"),this.emitEvent("translate"))}translateXY(e,t){e===0&&t===0||(this.x+=e,this.y+=t,this.transform(),this.emitEvent("translate"))}translateX(e){e!==0&&(this.x+=e,this.transform(),this.emitEvent("translate"))}translateXTo(e){this.x=e,this.transform(),this.emitEvent("translate")}translateY(e){e!==0&&(this.y+=e,this.transform(),this.emitEvent("translate"))}translateYTo(e){this.y=e,this.transform(),this.emitEvent("translate")}transform(){try{this.limitMindMapInCanvas()}catch{}this.mindMap.draw.transform({origin:[0,0],scale:this.scale,translate:[this.x,this.y]}),this.mindMap.emit("view_data_change",this.getTransformData())}reset(){let e=this.scale!==1,t=this.x!==0||this.y!==0;this.scale=1,this.x=0,this.y=0,this.transform(),e&&this.emitEvent("scale"),t&&this.emitEvent("translate")}narrow(e,t,r){let{scaleRatio:n,minZoomRatio:s}=this.mindMap.opt;n=n/(r?5:1);let a=Math.max(this.scale-n,s/100);this.scaleInCenter(a,e,t),this.transform(),this.emitEvent("scale")}enlarge(e,t,r){let{scaleRatio:n,maxZoomRatio:s}=this.mindMap.opt;n=n/(r?5:1);let a=0;s===-1?a=this.scale+n:a=Math.min(this.scale+n,s/100),this.scaleInCenter(a,e,t),this.transform(),this.emitEvent("scale")}scaleInCenter(e,t,r){(t===void 0||r===void 0)&&(t=this.mindMap.width/2,r=this.mindMap.height/2);let n=this.scale,s=1-e/n,a=(t-this.x)*s,o=(r-this.y)*s;this.x+=a,this.y+=o,this.scale=e}setScale(e,t,r){t!==void 0&&r!==void 0?this.scaleInCenter(e,t,r):this.scale=e,this.transform(),this.emitEvent("scale")}fit(e=()=>{},t=!1,r){r=r===void 0?this.mindMap.opt.fitPadding:r;let n=this.mindMap.draw,s=n.transform(),a=e()||n.rbox(),o=a.width/s.scaleX,l=a.height/s.scaleY,h=o/l,{width:d,height:c}=this.mindMap.elRect;d=d-r*2,c=c-r*2;let f=d/c,m=0,g="";if(o<=d&&l<=c&&!t)m=1,g=1;else{let E=0,S=0;h>f?(E=d,S=d/h,g=2):(S=c,E=c*h,g=3),m=E/o}this.setScale(m);let x=e()||n.rbox();x.x-=this.mindMap.elRect.left,x.y-=this.mindMap.elRect.top;let v=0,b=0;g===1?(v=-x.x+r+(d-x.width)/2,b=-x.y+r+(c-x.height)/2):g===2?(v=-x.x+r,b=-x.y+r+(c-x.height)/2):g===3&&(v=-x.x+r+(d-x.width)/2,b=-x.y+r),this.translateXY(v,b)}checkNeedMindMapInCanvas(){if(this.mindMap.demonstrate&&this.mindMap.demonstrate.isInDemonstrate)return!1;let{isLimitMindMapInCanvasWhenHasScrollbar:e,isLimitMindMapInCanvas:t}=this.mindMap.opt;return this.mindMap.scrollbar?e:t}limitMindMapInCanvas(){if(!this.checkNeedMindMapInCanvas())return;let{scale:e,left:t,top:r,right:n,bottom:s}=this.getPositionLimit(),a=(this.mindMap.width-this.mindMap.initWidth)/2*e,o=(this.mindMap.height-this.mindMap.initHeight)/2*e,l=this.scale/e;t*=l,n*=l,r*=l,s*=l;let h=this.mindMap.width/2,d=this.mindMap.height/2,c=this.scale-1;t-=c*h-a,n-=c*h-a,r-=c*d-o,s-=c*d-o,this.x>t&&(this.x=t),this.xr&&(this.y=r),this.y{"use strict";var TO=Object.prototype.hasOwnProperty,zt="~";function _l(){}Object.create&&(_l.prototype=Object.create(null),new _l().__proto__||(zt=!1));function NO(i,e,t){this.fn=i,this.context=e,this.once=t||!1}function Gx(i,e,t,r,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new NO(t,r||i,n),a=zt?zt+e:e;return i._events[a]?i._events[a].fn?i._events[a]=[i._events[a],s]:i._events[a].push(s):(i._events[a]=s,i._eventsCount++),i}function zd(i,e){--i._eventsCount===0?i._events=new _l:delete i._events[e]}function yt(){this._events=new _l,this._eventsCount=0}yt.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)TO.call(t,r)&&e.push(zt?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};yt.prototype.listeners=function(e){var t=zt?zt+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,s=r.length,a=new Array(s);n{Wx=ot(Yx());Oe();um=class extends Wx.default{constructor(e={}){super(),this.opt=e,this.mindMap=e.mindMap,this.isLeftMousedown=!1,this.isRightMousedown=!1,this.isMiddleMousedown=!1,this.mousedownPos={x:0,y:0},this.mousemovePos={x:0,y:0},this.mousemoveOffset={x:0,y:0},this.bindFn(),this.bind()}bindFn(){this.onBodyMousedown=this.onBodyMousedown.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onDrawClick=this.onDrawClick.bind(this),this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onNodeMouseup=this.onNodeMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onContextmenu=this.onContextmenu.bind(this),this.onSvgMousedown=this.onSvgMousedown.bind(this),this.onKeyup=this.onKeyup.bind(this),this.onMouseenter=this.onMouseenter.bind(this),this.onMouseleave=this.onMouseleave.bind(this)}bind(){document.body.addEventListener("mousedown",this.onBodyMousedown),document.body.addEventListener("click",this.onBodyClick),this.mindMap.svg.on("click",this.onDrawClick),this.mindMap.el.addEventListener("mousedown",this.onMousedown),this.mindMap.svg.on("mousedown",this.onSvgMousedown),window.addEventListener("mousemove",this.onMousemove),window.addEventListener("mouseup",this.onMouseup),this.on("node_mouseup",this.onNodeMouseup),this.mindMap.el.addEventListener("wheel",this.onMousewheel),this.mindMap.svg.on("contextmenu",this.onContextmenu),this.mindMap.svg.on("mouseenter",this.onMouseenter),this.mindMap.svg.on("mouseleave",this.onMouseleave),window.addEventListener("keyup",this.onKeyup)}unbind(){document.body.removeEventListener("mousedown",this.onBodyMousedown),document.body.removeEventListener("click",this.onBodyClick),this.mindMap.svg.off("click",this.onDrawClick),this.mindMap.el.removeEventListener("mousedown",this.onMousedown),window.removeEventListener("mousemove",this.onMousemove),window.removeEventListener("mouseup",this.onMouseup),this.off("node_mouseup",this.onNodeMouseup),this.mindMap.el.removeEventListener("wheel",this.onMousewheel),this.mindMap.svg.off("contextmenu",this.onContextmenu),this.mindMap.svg.off("mouseenter",this.onMouseenter),this.mindMap.svg.off("mouseleave",this.onMouseleave),window.removeEventListener("keyup",this.onKeyup)}onDrawClick(e){this.emit("draw_click",e)}onBodyMousedown(e){this.emit("body_mousedown",e)}onBodyClick(e){this.emit("body_click",e)}onSvgMousedown(e){this.emit("svg_mousedown",e)}onMousedown(e){e.which===1?this.isLeftMousedown=!0:e.which===3?this.isRightMousedown=!0:e.which===2&&(this.isMiddleMousedown=!0),this.mousedownPos.x=e.clientX,this.mousedownPos.y=e.clientY,this.emit("mousedown",e,this)}onMousemove(e){let{useLeftKeySelectionRightKeyDrag:t}=this.mindMap.opt;this.mousemovePos.x=e.clientX,this.mousemovePos.y=e.clientY,this.mousemoveOffset.x=e.clientX-this.mousedownPos.x,this.mousemoveOffset.y=e.clientY-this.mousedownPos.y,this.emit("mousemove",e,this),(this.isMiddleMousedown||(t?this.isRightMousedown:this.isLeftMousedown))&&(e.preventDefault(),this.emit("drag",e,this))}onMouseup(e){this.onNodeMouseup(),this.emit("mouseup",e,this)}onNodeMouseup(){this.isLeftMousedown=!1,this.isRightMousedown=!1,this.isMiddleMousedown=!1}onMousewheel(e){e.stopPropagation(),e.preventDefault();let t=[];e.deltaY<0&&t.push(A.DIR.UP),e.deltaY>0&&t.push(A.DIR.DOWN),e.deltaX<0&&t.push(A.DIR.LEFT),e.deltaX>0&&t.push(A.DIR.RIGHT);let r=!1,{customCheckIsTouchPad:n}=this.mindMap.opt;typeof n=="function"?r=n(e):r=Math.abs(e.deltaY)<=10,this.emit("mousewheel",e,t,this,r)}onContextmenu(e){e.preventDefault(),!e.ctrlKey&&this.emit("contextmenu",e)}onKeyup(e){this.emit("keyup",e)}onMouseenter(e){this.emit("svg_mouseenter",e)}onMouseleave(e){this.emit("svg_mouseleave",e)}},Vx=um});var fm,mm,Kx=M(()=>{hr();he();Oe();fm=class extends ut{constructor(e={},t){super(e),this.isUseLeft=t===A.LAYOUT.LOGICAL_STRUCTURE_LEFT}doLayout(e){qt([()=>{this.computedBaseValue()},()=>{this.computedTopValue()},()=>{this.adjustTopValue()},()=>{e(this.root)}])}computedBaseValue(){let e=0;se(this.renderer.renderTree,null,(t,r,n,s,a,o)=>{let l=this.createNode(t,r,n,s,a,o);if(l.sortIndex=e,e++,n?this.setNodeCenter(l):this.isUseLeft?l.left=r._node.left-l.width-this.getMarginX(s):l.left=r._node.left+r._node.width+this.getMarginX(s),!t.data.expand)return!0},(t,r,n,s)=>{let a=t.data.expand===!1?0:t._node.children.length;t._node.childrenAreaHeight=a?t._node.children.reduce((l,h)=>l+h.height,0)+(a+1)*this.getMarginY(s+1):0;let o=t._node.checkHasGeneralization()?t._node._generalizationNodeHeight+this.getMarginY(s+1):0;t._node.childrenAreaHeight2=Math.max(t._node.childrenAreaHeight,o)},!0,0)}computedTopValue(){se(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginY(n+1),o=e.top+e.height/2-e.childrenAreaHeight/2+s;e.children.forEach(l=>{l.top=o,o+=l.height+s})}},null,!0)}adjustTopValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s=e.childrenAreaHeight2-this.getMarginY(n+1)*2-e.height;s>0&&this.updateBrothers(e,s/2)},null,!0)}updateBrothers(e,t){if(e.parent){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.uid===e.uid||s.hasCustomPosition())return;let o=0;an&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothers(e.parent,t)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let f=(this.getMarginX(e.layerIndex+1)-l)*.6;this.isUseLeft&&(f*=-1);let m=this.mindMap.themeConfig.nodeUseLineStyle;e.children.forEach((g,x)=>{let v;this.isUseLeft?v=e.layerIndex===0?n:n-l:v=e.layerIndex===0?n+a:n+a+l;let b=s+o/2,E=this.isUseLeft?g.left+g.width:g.left,S=g.top+g.height/2,C=m?g.width*(this.isUseLeft?-1:1):0;b=m&&!e.isRoot?b+o/2:b,S=m?S+g.height/2:S;let _=this.createFoldLine([[v,b],[v+f,b],[v+f,S],[E+C,S]]);this.setLineStyle(r,t[x],_,g)})}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c}=this.mindMap.themeConfig;e.children.forEach((f,m)=>{e.layerIndex===0&&(l=0);let g=this.isUseLeft?n-l:n+a+l,x=s+o/2,v=this.isUseLeft?f.left+f.width:f.left,b=f.top+f.height/2;x=c&&!e.isRoot?x+o/2:x,b=c?b+f.height/2:b;let E=c?` L ${this.isUseLeft?f.left:f.left+f.width},${b}`:"",S=`M ${g},${x} L ${v},${b}`+E;this.setLineStyle(r,t[m],S,f)})}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c,rootLineStartPositionKeepSameInCurve:f,rootLineKeepSameInCurve:m}=this.mindMap.themeConfig;e.children.forEach((g,x)=>{e.layerIndex===0&&(l=0);let v;this.isUseLeft?v=e.layerIndex===0&&!f?n+a/2:n-l:v=e.layerIndex===0&&!f?n+a/2:n+a+l;let b=s+o/2,E=this.isUseLeft?g.left+g.width:g.left,S=g.top+g.height/2,C="";b=c&&!e.isRoot?b+o/2:b,S=c?S+g.height/2:S;let _;this.isUseLeft?_=c?` L ${g.left},${S}`:"":_=c?` L ${g.left+g.width},${S}`:"",e.isRoot&&!m?C=this.quadraticCurvePath(v,b,E,S)+_:C=this.cubicBezierPath(v,b,E,S)+_,this.setLineStyle(r,t[x],C,g)})}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,layerIndex:a}=e;a===0&&(s=0);let{translateX:o,translateY:l}=t.transform(),h=this.mindMap.themeConfig.nodeUseLineStyle?n/2:0,d=this.isUseLeft?0-s:r,c=n/2+h;d===o&&c===l||t.translate(d-o,c-l)}renderGeneralization(e){e.forEach(t=>{let{left:r,top:n,bottom:s,right:a,generalizationLineMargin:o,generalizationNodeMargin:l}=this.getNodeGeneralizationRenderBoundaries(t,"h"),h=this.isUseLeft?r-o:a+o,d=h,c=n,f=h,m=s,g=d+(this.isUseLeft?-20:20),x=c+(m-c)/2,v=`M ${d},${c} Q ${g},${x} ${f},${m}`;t.generalizationLine.plot(v),t.generalizationNode.left=h+(this.isUseLeft?-l:l)-(this.isUseLeft?t.generalizationNode.width:0),t.generalizationNode.top=n+(s-n-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n){this.isUseLeft?e.size(t,n).x(-t).y(0):e.size(t,n).x(r).y(0)}},mm=fm});var pm,Zx,Qx=M(()=>{hr();he();Oe();pm=class extends ut{constructor(e={}){super(e)}doLayout(e){qt([()=>{this.computedBaseValue()},()=>{this.computedTopValue()},()=>{this.adjustTopValue()},()=>{e(this.root)}])}computedBaseValue(){se(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):(t._node.dir?o.dir=t._node.dir:o.dir=o.getData("dir")||(s%2===0?A.LAYOUT_GROW_DIR.RIGHT:A.LAYOUT_GROW_DIR.LEFT),o.left=o.dir===A.LAYOUT_GROW_DIR.RIGHT?t._node.left+t._node.width+this.getMarginX(n):t._node.left-this.getMarginX(n)-o.width),!e.data.expand)return!0},(e,t,r,n)=>{if(!e.data.expand){e._node.leftChildrenAreaHeight=0,e._node.rightChildrenAreaHeight=0;return}let s=0,a=0,o=0,l=0;e._node.children.forEach(d=>{d.dir===A.LAYOUT_GROW_DIR.LEFT?(s++,o+=d.height):(a++,l+=d.height)}),e._node.leftChildrenAreaHeight=o+(s+1)*this.getMarginY(n+1),e._node.rightChildrenAreaHeight=l+(a+1)*this.getMarginY(n+1);let h=e._node.checkHasGeneralization()?e._node._generalizationNodeHeight+this.getMarginY(n+1):0;e._node.leftChildrenAreaHeight2=Math.max(e._node.leftChildrenAreaHeight,h),e._node.rightChildrenAreaHeight2=Math.max(e._node.rightChildrenAreaHeight,h)},!0,0)}computedTopValue(){se(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginY(n+1),a=e.top+e.height/2+s,o=a-e.leftChildrenAreaHeight/2,l=a-e.rightChildrenAreaHeight/2;e.children.forEach(h=>{h.dir===A.LAYOUT_GROW_DIR.LEFT?(h.top=o,o+=h.height+s):(h.top=l,l+=h.height+s)})}},null,!0)}adjustTopValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s=this.getMarginY(n+1)*2+e.height,a=e.leftChildrenAreaHeight2-s,o=e.rightChildrenAreaHeight2-s;(a>0||o>0)&&this.updateBrothers(e,a/2,o/2)},null,!0)}updateBrothers(e,t,r){if(e.parent){let n=e.parent.children.filter(a=>a.dir===e.dir),s=Ee(e,n);n.forEach((a,o)=>{if(a.hasCustomPosition())return;let l=0,h=a.dir===A.LAYOUT_GROW_DIR.LEFT?t:r;os&&(l=h),a.top+=l,a.children&&a.children.length&&this.updateChildren(a.children,"top",l)}),this.updateBrothers(e.parent,t,r)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let f=(this.getMarginX(e.layerIndex+1)-l)*.6,m=this.mindMap.themeConfig.nodeUseLineStyle;e.children.forEach((g,x)=>{let v=0,b=0,E=m?g.width:0;g.dir===A.LAYOUT_GROW_DIR.LEFT?(b=-f,v=e.layerIndex===0?n:n-l,E=-E):(b=f,v=e.layerIndex===0?n+a:n+a+l);let S=s+o/2,C=g.dir===A.LAYOUT_GROW_DIR.LEFT?g.left+g.width:g.left,_=g.top+g.height/2;S=m&&!e.isRoot?S+o/2:S,_=m?_+g.height/2:_;let I=this.createFoldLine([[v,S],[v+b,S],[v+b,_],[C+E,_]]);this.setLineStyle(r,t[x],I,g)})}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c}=this.mindMap.themeConfig;e.children.forEach((f,m)=>{e.layerIndex===0&&(l=0);let g=f.dir===A.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,x=s+o/2,v=f.dir===A.LAYOUT_GROW_DIR.LEFT?f.left+f.width:f.left,b=f.top+f.height/2;x=c&&!e.isRoot?x+o/2:x,b=c?b+f.height/2:b;let E="";c&&(f.dir===A.LAYOUT_GROW_DIR.LEFT?E=` L ${f.left},${b}`:E=` L ${f.left+f.width},${b}`);let S=`M ${g},${x} L ${v},${b}`+E;this.setLineStyle(r,t[m],S,f)})}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c,rootLineKeepSameInCurve:f,rootLineStartPositionKeepSameInCurve:m}=this.mindMap.themeConfig;e.children.forEach((g,x)=>{e.layerIndex===0&&(l=0);let v=e.layerIndex===0&&!m?n+a/2:g.dir===A.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,b=s+o/2,E=g.dir===A.LAYOUT_GROW_DIR.LEFT?g.left+g.width:g.left,S=g.top+g.height/2,C="";b=c&&!e.isRoot?b+o/2:b,S=c?S+g.height/2:S;let _="";c&&(g.dir===A.LAYOUT_GROW_DIR.LEFT?_=` L ${g.left},${S}`:_=` L ${g.left+g.width},${S}`),e.isRoot&&!f?C=this.quadraticCurvePath(v,b,E,S)+_:C=this.cubicBezierPath(v,b,E,S)+_,this.setLineStyle(r,t[x],C,g)})}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s}=e,{translateX:a,translateY:o}=t.transform(),l=this.mindMap.themeConfig.nodeUseLineStyle?n/2:0,h=e.dir===A.LAYOUT_GROW_DIR.LEFT?0-s:r,d=n/2+l;if(h===a&&d===o)return;let c=h-a,f=d-o;t.translate(c,f)}renderGeneralization(e){e.forEach(t=>{let r=t.node.dir===A.LAYOUT_GROW_DIR.LEFT,{top:n,bottom:s,left:a,right:o,generalizationLineMargin:l,generalizationNodeMargin:h}=this.getNodeGeneralizationRenderBoundaries(t,"h"),d=r?a-l:o+l,c=d,f=n,m=d,g=s,x=c+(r?-20:20),v=f+(g-f)/2,b=`M ${c},${f} Q ${x},${v} ${m},${g}`;t.generalizationLine.plot(b),t.generalizationNode.left=d+(r?-h:h)-(r?t.generalizationNode.width:0),t.generalizationNode.top=n+(s-n-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){s.dir===A.LAYOUT_GROW_DIR.LEFT?e.size(t,n).x(-t).y(0):e.size(t,n).x(r).y(0)}},Zx=pm});var gm,Jx,ev=M(()=>{hr();he();gm=class extends ut{constructor(e={}){super(e)}doLayout(e){qt([()=>{this.computedBaseValue()},()=>{this.computedLeftTopValue()},()=>{this.adjustLeftTopValue()},()=>{e(this.root)}])}computedBaseValue(){se(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):t._node.isRoot&&(o.top=t._node.top+t._node.height+this.getMarginX(n)),!e.data.expand)return!0},(e,t,r,n)=>{if(r){let s=e.data.expand===!1?0:e._node.children.length;e._node.childrenAreaWidth=s?e._node.children.reduce((a,o)=>a+o.width,0)+(s+1)*this.getMarginX(n+1):0}},!0,0)}computedLeftTopValue(){se(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginX(n+1),a=this.getMarginY(n+1);if(r){let l=e.left+e.width/2-e.childrenAreaWidth/2+s;e.children.forEach(h=>{h.left=l,l+=h.width+s})}else{let o=e.top+this.getNodeHeightWithGeneralization(e)+a+(this.getNodeActChildrenLength(e)>0?e.expandBtnSize:0);e.children.forEach(l=>{l.left=e.left+e.width*.5,l.top=o,o+=this.getNodeHeightWithGeneralization(l)+a+(this.getNodeActChildrenLength(l)>0?l.expandBtnSize:0)})}}},null,!0)}adjustLeftTopValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;if(t&&t.isRoot){let o=this.getNodeAreaWidth(e,!0)-e.width;o>0&&this.updateBrothersLeft(e,o)}let s=e.children.length;if(t&&!t.isRoot&&s>0){let a=this.getMarginY(n+1),o=e.children.reduce((l,h)=>l+this.getNodeHeightWithGeneralization(h)+(this.getNodeActChildrenLength(h)>0?h.expandBtnSize:0),0)+s*a;this.updateBrothersTop(e,o)}},(e,t,r)=>{if(r){let{right:n,left:s}=this.getNodeBoundaries(e,"h"),a=n-s,o=e.left-s-(a-e.width)/2;this.updateChildren(e.children,"left",o)}},!0)}updateBrothersLeft(e,t){if(e.parent){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{s.hasCustomPosition()||a<=n||(s.left+=t,s.children&&s.children.length&&this.updateChildren(s.children,"left",t))}),this.updateBrothersLeft(e.parent,t)}}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothersTop(e.parent,t)}}renderLine(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let c=e.children.length,f=this.getMarginX(e.layerIndex+1);if(e.isRoot){let m=n+a/2,g=s+o,x=f*.7,v=1/0,b=-1/0;e.children.forEach((S,C)=>{let _=S.left+S.width/2,I=S.top;_b&&(b=_);let O=this.mindMap.themeConfig.nodeUseLineStyle?` L ${S.left},${I} L ${S.left+S.width},${I}`:"",D=`M ${_},${g+x} L ${_},${g+x>I?I+S.height:I}`+O;this.setLineStyle(r,t[C],D,S)}),v=Math.min(v,m),b=Math.max(b,m);let E=this.lineDraw.path();if(e.style.line(E),E.plot(this.transformPath(`M ${m},${g} L ${m},${g+x}`)),e._lines.push(E),r&&r(E,e),c>0){let S=this.lineDraw.path();e.style.line(S),S.plot(this.transformPath(`M ${v},${g+x} L ${b},${g+x}`)),e._lines.push(S),r&&r(S,e)}}else{let m=s+o,g=-1/0,x=e.left+e.width*.3;if(e.children.forEach((v,b)=>{let E=v.top+v.height/2;E>g&&(g=E);let S="",C=v.left,_=v.left+v.widthx&&(I=!0,E=v.top,g=E),E>s&&E0){let v=this.lineDraw.path();l=c>0?l:0,e.style.line(v),g{let{top:r,bottom:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"h"),l=s+a,h=r,d=s+a,c=n,f=l+20,m=h+(c-h)/2,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.left=s+o,t.generalizationNode.top=r+(n-r-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){e.size(r,t).x(0).y(n)}},Jx=gm});var xm,tv,iv=M(()=>{hr();he();xm=class extends ut{constructor(e={}){super(e)}doLayout(e){qt([()=>{this.computedBaseValue()},()=>{this.computedLeftValue()},()=>{this.adjustLeftValue()},()=>{e(this.root)}])}computedBaseValue(){se(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):o.top=t._node.top+t._node.height+this.getMarginX(n),!e.data.expand)return!0},(e,t,r,n)=>{let s=e.data.expand===!1?0:e._node.children.length;e._node.childrenAreaWidth=s?e._node.children.reduce((o,l)=>o+l.width,0)+(s+1)*this.getMarginY(n+1):0;let a=e._node.checkHasGeneralization()?e._node._generalizationNodeWidth+this.getMarginY(n+1):0;e._node.childrenAreaWidth2=Math.max(e._node.childrenAreaWidth,a)},!0,0)}computedLeftValue(){se(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginY(n+1),o=e.left+e.width/2-e.childrenAreaWidth/2+s;e.children.forEach(l=>{l.left=o,o+=l.width+s})}},null,!0)}adjustLeftValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s=e.childrenAreaWidth2-this.getMarginY(n+1)*2-e.width;s>0&&this.updateBrothers(e,s/2)},null,!0)}updateBrothers(e,t){if(e.parent){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;an&&(o=t),s.left+=o,s.children&&s.children.length&&this.updateChildren(s.children,"left",o)}),this.updateBrothers(e.parent,t)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c,rootLineStartPositionKeepSameInCurve:f,rootLineKeepSameInCurve:m}=this.mindMap.themeConfig;e.children.forEach((g,x)=>{e.layerIndex===0&&(l=0);let v=n+a/2,b=e.layerIndex===0&&!f?s+o/2:s+o+l,E=g.left+g.width/2,S=g.top,C="",_=c?` L ${g.left},${S} L ${g.left+g.width},${S}`:"";e.isRoot&&!m?C=this.quadraticCurvePath(v,b,E,S,!0)+_:C=this.cubicBezierPath(v,b,E,S,!0)+_,this.setLineStyle(r,t[x],C,g)})}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o}=e,{nodeUseLineStyle:l}=this.mindMap.themeConfig,h=n+a/2,d=s+o;e.children.forEach((c,f)=>{let m=c.left+c.width/2,g=c.top,x=l?` L ${c.left},${g} L ${c.left+c.width},${g}`:"",v=`M ${h},${d} L ${m},${g}`+x;this.setLineStyle(r,t[f],v,c)})}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l,isRoot:h}=e,{alwaysShowExpandBtn:d,notShowExpandBtn:c}=this.mindMap.opt;(!d||c)&&(l=0);let f=n+a/2,m=s+o,x=this.getMarginX(e.layerIndex+1)*.7,v=1/0,b=-1/0,E=e.children.length;e.children.forEach((C,_)=>{let I=C.left+C.width/2,O=m+x>C.top?C.top+C.height:C.top;Ib&&(b=I);let D=this.mindMap.themeConfig.nodeUseLineStyle?` L ${C.left},${O} L ${C.left+C.width},${O}`:"",$=`M ${I},${m+x} L ${I},${O}`+D;this.setLineStyle(r,t[_],$,C)}),v=Math.min(f,v),b=Math.max(f,b);let S=this.lineDraw.path();if(e.style.line(S),l=E>0&&!h?l:0,S.plot(this.transformPath(`M ${f},${m+l} L ${f},${m+x}`)),e._lines.push(S),r&&r(S,e),E>0){let C=this.lineDraw.path();e.style.line(C),C.plot(this.transformPath(`M ${v},${m+x} L ${b},${m+x}`)),e._lines.push(C),r&&r(C,e)}}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s}=e,{translateX:a,translateY:o}=t.transform();t.translate(r/2-s/2-a,n+s/2-o)}renderGeneralization(e){e.forEach(t=>{let{bottom:r,left:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"v"),l=n,h=r+a,d=s,c=r+a,f=l+(d-l)/2,m=h+20,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.top=r+o,t.generalizationNode.left=n+(s-n-t.generalizationNode.width)/2})}renderExpandBtnRect(e,t,r,n,s){e.size(r,t).x(0).y(n)}},tv=xm});var vm,ym,rv=M(()=>{hr();he();Oe();vm=class extends ut{constructor(e={},t){super(e),this.layout=t}doLayout(e){qt([()=>{this.computedBaseValue()},()=>{this.computedLeftTopValue()},()=>{this.adjustLeftTopValue()},()=>{e(this.root)}])}computedBaseValue(){se(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):(this.layout===A.LAYOUT.TIMELINE2?t._node.dir?o.dir=t._node.dir:o.dir=s%2===0?A.LAYOUT_GROW_DIR.BOTTOM:A.LAYOUT_GROW_DIR.TOP:o.dir="",t._node.isRoot&&(o.top=t._node.top+(e._node.height>t._node.height?-(e._node.height-t._node.height)/2:(t._node.height-e._node.height)/2))),!e.data.expand)return!0},null,!0,0)}computedLeftTopValue(){se(this.root,null,(e,t,r,n,s)=>{if(e.getData("expand")&&e.children&&e.children.length){let a=this.getMarginX(n+1),o=this.getMarginY(n+1);if(r){let h=e.left+e.width+a;e.children.forEach(d=>{d.left=h,h+=d.width+a})}else{let l=e.top+e.height+o+(this.getNodeActChildrenLength(e)>0?e.expandBtnSize:0);e.children.forEach(h=>{h.left=e.left+e.width*.5,h.top=l,l+=h.height+o+(this.getNodeActChildrenLength(h)>0?h.expandBtnSize:0)})}}},null,!0)}adjustLeftTopValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;e.isRoot&&this.updateBrothersLeft(e);let s=e.children.length;if(t&&!t.isRoot&&s>0){let a=this.getMarginY(n+1),o=e.children.reduce((l,h)=>l+h.height+(this.getNodeActChildrenLength(h)>0?h.expandBtnSize:0),0)+s*a;this.updateBrothersTop(e,o)}},(e,t,r,n)=>{t&&t.isRoot&&e.dir===A.LAYOUT_GROW_DIR.TOP&&e.children.forEach(s=>{let a=this.getNodeAreaHeight(s),o=s.top;s.top=e.top-(s.top-e.top)-a+e.height,this.updateChildren(s.children,"top",s.top-o)})},!0)}getNodeAreaHeight(e){let t=0,r=n=>{t+=n.height+(this.getNodeActChildrenLength(n)>0?n.expandBtnSize:0)+this.getMarginY(n.layerIndex),n.children.length&&n.children.forEach(s=>{r(s)})};return r(e),t}updateBrothersLeft(e){let t=e.children,r=0;t.forEach(n=>{n.left+=r,n.children&&n.children.length&&this.updateChildren(n.children,"left",r);let{left:s,right:a}=this.getNodeBoundaries(n,"h"),l=a-s-n.width;l>0&&(r+=l)})}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothersTop(e.parent,t)}}renderLine(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let c=e.children.length;if(e.isRoot){let f=e;e.children.forEach((m,g)=>{let x=f.left+f.width,v=m.left,b=e.top+e.height/2,E=`M ${x},${b} L ${v},${b}`;this.setLineStyle(r,t[g],E,m),f=m})}else{let f=-1/0,m=1/0,g=e.left+e.width*.3;if(e.children.forEach((x,v)=>{let b=x.top+x.height/2;b>f&&(f=b),b0){let x=this.lineDraw.path();l=c>0?l:0,e.parent&&e.parent.isRoot&&e.dir===A.LAYOUT_GROW_DIR.TOP?x.plot(this.transformPath(`M ${g},${s} L ${g},${m}`)):x.plot(this.transformPath(`M ${g},${s+o+l} L ${g},${f}`)),e.style.line(x),e._lines.push(x),r&&r(x,e)}}}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,isRoot:a}=e;if(!a){let{translateX:o,translateY:l}=t.transform();e.parent&&e.parent.isRoot&&e.dir===A.LAYOUT_GROW_DIR.TOP?t.translate(r*.3-s/2-o,-s/2-l):t.translate(r*.3-s/2-o,n+s/2-l)}}renderGeneralization(e){e.forEach(t=>{let{top:r,bottom:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"h"),l=s+a,h=r,d=s+a,c=n,f=l+20,m=h+(c-h)/2,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.left=s+o,t.generalizationNode.top=r+(n-r-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){if(this.layout===A.LAYOUT.TIMELINE)e.size(r,t).x(0).y(n);else{let a="";s.dir===A.LAYOUT_GROW_DIR.TOP?a=s.layerIndex===1?A.LAYOUT_GROW_DIR.TOP:A.LAYOUT_GROW_DIR.BOTTOM:a=A.LAYOUT_GROW_DIR.BOTTOM,a===A.LAYOUT_GROW_DIR.TOP?e.size(r,t).x(0).y(-t):e.size(r,t).x(0).y(n)}}},ym=vm});var bm,Id,nv=M(()=>{hr();he();Oe();bm=class extends ut{constructor(e={},t){super(e),this.layout=t}doLayout(e){qt([()=>{this.computedBaseValue()},()=>{this.computedTopValue()},()=>{this.adjustLeftTopValue()},()=>{e(this.root)}])}computedBaseValue(){se(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):(t._node.dir?o.dir=t._node.dir:this.layout===A.LAYOUT.VERTICAL_TIMELINE2?o.dir=A.LAYOUT_GROW_DIR.LEFT:this.layout===A.LAYOUT.VERTICAL_TIMELINE3?o.dir=A.LAYOUT_GROW_DIR.RIGHT:o.dir=s%2===0?A.LAYOUT_GROW_DIR.RIGHT:A.LAYOUT_GROW_DIR.LEFT,t._node.isRoot?o.left=t._node.left+(e._node.width>t._node.width?-(e._node.width-t._node.width)/2:(t._node.width-e._node.width)/2):o.left=o.dir===A.LAYOUT_GROW_DIR.RIGHT?t._node.left+t._node.width+this.getMarginX(n):t._node.left-this.getMarginX(n)-o.width),!e.data.expand)return!0},(e,t,r,n)=>{if(r)return;let s=e.data.expand===!1?0:e._node.children.length;e._node.childrenAreaHeight=s?e._node.children.reduce((a,o)=>a+o.height,0)+(s+1)*this.getMarginY(n+1):0},!0,0)}computedTopValue(){se(this.root,null,(e,t,r,n,s)=>{if(e.getData("expand")&&e.children&&e.children.length){let a=this.getMarginY(n+1);if(r){let l=e.top+e.height+a;e.children.forEach(h=>{h.top=l,l+=h.height+a})}else{let o=this.getMarginY(n+1),h=e.top+e.height/2+o-e.childrenAreaHeight/2;e.children.forEach(d=>{d.top=h,h+=d.height+o})}}},null,!0)}adjustLeftTopValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand")||r)return;let s=this.getMarginY(n+1)*2+e.height,a=e.childrenAreaHeight-s;a>0&&this.updateBrothers(e,a/2)},null,!0)}updateBrothers(e,t){if(e.parent){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition()||!e.parent.isRoot&&s.uid===e.uid)return;let o=0;e.parent.isRoot?an?o=t*2:o=t:an&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothers(e.parent,t)}}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothersTop(e.parent,t)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{expandBtnSize:n}=e,{alwaysShowExpandBtn:s,notShowExpandBtn:a}=this.mindMap.opt;if((!s||a)&&(n=0),e.isRoot){let o=e;e.children.forEach((l,h)=>{let d=o.top+o.height,c=l.top,f=e.left+e.width/2,m=`M ${f},${d} L ${f},${c}`;this.setLineStyle(r,t[h],m,l),o=l})}else if(e.dir===A.LAYOUT_GROW_DIR.RIGHT){let o=e.left+e.width,l=e.top+e.height/2,d=(this.getMarginX(e.layerIndex+1)-n)*.6;e.children.forEach((c,f)=>{let m=c.left,g=c.top+c.height/2,x=this.createFoldLine([[o,l],[o+d,l],[o+d,g],[m,g]]);this.setLineStyle(r,t[f],x,c)})}else{let o=e.left,l=e.top+e.height/2,d=(this.getMarginX(e.layerIndex+1)-n)*.6;e.children.forEach((c,f)=>{let m=c.left+c.width,g=c.top+c.height/2,x=this.createFoldLine([[o,l],[o-d,l],[o-d,g],[m,g]]);this.setLineStyle(r,t[f],x,c)})}}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0),e.children.forEach((c,f)=>{if(e.isRoot){let m=e;e.children.forEach((g,x)=>{let v=m.top+m.height,b=g.top,E=e.left+e.width/2,S=`M ${E},${v} L ${E},${b}`;this.setLineStyle(r,t[x],S,g),m=g})}else{let m=c.dir===A.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,g=s+o/2,x=c.dir===A.LAYOUT_GROW_DIR.LEFT?c.left+c.width:c.left,v=c.top+c.height/2,b=`M ${m},${g} L ${x},${v}`;this.setLineStyle(r,t[f],b,c)}})}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0),e.children.forEach((c,f)=>{if(e.isRoot){let m=e;e.children.forEach((g,x)=>{let v=m.top+m.height,b=g.top,E=e.left+e.width/2,S=`M ${E},${v} L ${E},${b}`;this.setLineStyle(r,t[x],S,g),m=g})}else{let m=c.dir===A.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,g=s+o/2,x=c.dir===A.LAYOUT_GROW_DIR.LEFT?c.left+c.width:c.left,v=c.top+c.height/2,b=this.cubicBezierPath(m,g,x,v);this.setLineStyle(r,t[f],b,c)}})}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,isRoot:a}=e;if(!a){let{translateX:o,translateY:l}=t.transform();e.dir===A.LAYOUT_GROW_DIR.RIGHT?t.translate(r-o,n/2-l):t.translate(-s-o,n/2-l)}}renderGeneralization(e){e.forEach(t=>{let r=t.node.dir===A.LAYOUT_GROW_DIR.LEFT,{top:n,bottom:s,left:a,right:o,generalizationLineMargin:l,generalizationNodeMargin:h}=this.getNodeGeneralizationRenderBoundaries(t,"h"),d=r?a-l:o+l,c=d,f=n,m=d,g=s,x=c+(r?-20:20),v=f+(g-f)/2,b=`M ${c},${f} Q ${x},${v} ${m},${g}`;t.generalizationLine.plot(this.transformPath(b)),t.generalizationNode.left=d+(r?-h:h)-(r?t.generalizationNode.width:0),t.generalizationNode.top=n+(s-n-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){s.dir===A.LAYOUT_GROW_DIR.LEFT?e.size(t,n).x(-t).y(0):e.size(t,n).x(r).y(0)}},Id=bm});var Fi,sv=M(()=>{he();Fi={top:{renderExpandBtn({node:i,btn:e,expandBtnSize:t,translateX:r,translateY:n,width:s,height:a}){i.parent&&i.parent.isRoot?e.translate(s*.3-t/2-r,-t/2-n):e.translate(s*.3-t/2-r,a+t/2-n)},renderLine({node:i,line:e,top:t,x:r,lineLength:n,height:s,expandBtnSize:a,maxy:o,ctx:l}){i.parent&&i.parent.isRoot?e.plot(l.transformPath(`M ${r},${t} L ${r+n},${t-Math.tan(Yr(l.mindMap.opt.fishboneDeg))*n}`)):e.plot(l.transformPath(`M ${r},${t+s+a} L ${r},${o}`))},computedLeftTopValue({layerIndex:i,node:e,ctx:t}){if(i>=1&&e.children){let r=t.getMarginY(i+1),n=e.left+e.width*t.childIndent,s=e.top+e.height+(t.getNodeActChildrenLength(e)>0?e.expandBtnSize:0)+r;e.children.forEach(a=>{a.left=n,a.top+=s,s+=a.height+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0)+r})}},adjustLeftTopValueBefore({node:i,parent:e,ctx:t,layerIndex:r}){let n=i.children.length,s=t.getMarginY(r+1);if(e&&!e.isRoot&&n>0){let a=i.children.reduce((o,l)=>o+l.height+(t.getNodeActChildrenLength(l)>0?l.expandBtnSize:0)+s,0);t.updateBrothersTop(i,a)}},adjustLeftTopValueAfter({parent:i,node:e,ctx:t}){if(i&&i.isRoot){let r=t.getMarginY(e.layerIndex+1),n=e.expandBtnSize+r;e.children.forEach(s=>{let a=t.getNodeAreaHeight(s),o=s.top,l=s.left;s.top=e.top-(s.top-e.top)-a+e.height,s.left=e.left+e.width*t.indent+(a+n)/Math.tan(Yr(t.mindMap.opt.fishboneDeg)),n+=a,t.updateChildrenPro(s.children,{top:s.top-o,left:s.left-l})})}}},bottom:{renderExpandBtn({node:i,btn:e,expandBtnSize:t,translateX:r,translateY:n,width:s,height:a}){i.parent&&i.parent.isRoot?e.translate(s*.3-t/2-r,a+t/2-n):e.translate(s*.3-t/2-r,-t/2-n)},renderLine({node:i,line:e,top:t,x:r,lineLength:n,height:s,miny:a,ctx:o}){i.parent&&i.parent.isRoot?e.plot(o.transformPath(`M ${r},${t+s} L ${r+n},${t+s+Math.tan(Yr(o.mindMap.opt.fishboneDeg))*n}`)):e.plot(o.transformPath(`M ${r},${t} L ${r},${a}`))},computedLeftTopValue({layerIndex:i,node:e,ctx:t}){let r=t.getMarginY(i+1);if(i===1&&e.children){let n=e.left+e.width*t.childIndent,s=e.top+e.height+(t.getNodeActChildrenLength(e)>0?e.expandBtnSize:0)+r;e.children.forEach(a=>{a.left=n,a.top=s+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0),s+=a.height+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0)+r})}if(i>1&&e.children){let n=e.left+e.width*t.childIndent,s=e.top-(t.getNodeActChildrenLength(e)>0?e.expandBtnSize:0)-r;e.children.forEach(a=>{a.left=n,a.top=s-a.height,s-=a.height+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0)+r})}},adjustLeftTopValueBefore({node:i,ctx:e,layerIndex:t}){let r=e.getMarginY(t+1),n=i.children.length;if(t>2&&n>0){let s=i.children.reduce((a,o)=>a+o.height+(e.getNodeActChildrenLength(o)>0?o.expandBtnSize:0)+r,0);e.updateBrothersTop(i,-s)}},adjustLeftTopValueAfter({parent:i,node:e,ctx:t}){if(i&&i.isRoot){let r=t.getMarginY(e.layerIndex+1),n=0,s=e.expandBtnSize;e.children.forEach(a=>{let o=t.getNodeActChildrenLength(a)>0,l=t.getNodeAreaHeight(a),h=o?l-a.height-(o?a.expandBtnSize:0):0;h-=o?r:0;let d=n+h,c=a.left;a.top+=d,a.left=e.left+e.width*t.indent+(l+s)/Math.tan(Yr(t.mindMap.opt.fishboneDeg)),n+=h,s+=l,t.updateChildrenPro(a.children,{top:d,left:a.left-c})})}}}}});var wm,Mm,av=M(()=>{hr();he();Oe();sv();ht();s0();wm=class extends ut{constructor(e={},t){super(e),this.layout=t,this.indent=.3,this.childIndent=.5,this.fishTail=null,this.maxx=0,this.headRatio=1,this.tailRatio=.6,this.paddingXRatio=.3,this.fishHeadPathStr="M4,181 C4,181, 0,177, 4,173 Q 96.09523809523809,0, 288.2857142857143,0 L 288.2857142857143,354 Q 48.047619047619044,354, 8,218.18367346938777 C8,218.18367346938777, 6,214.18367346938777, 8,214.18367346938777 L 41.183673469387756,214.18367346938777 Z",this.fishTailPathStr="M 606.9342905223708 0 Q 713.1342905223709 -177 819.3342905223708 -177 L 766.2342905223709 0 L 819.3342905223708 177 Q 713.1342905223709 177 606.9342905223708 0 z",this.bindEvent(),this.extendShape(),this.beforeChange=this.beforeChange.bind(this)}nodeIsRemoveAllLines(e){return e.isRoot||e.layerIndex===1}isFishbone2(){return this.layout===A.LAYOUT.FISHBONE2}bindEvent(){this.isFishbone2()&&(this.onCheckUpdateFishTail=this.onCheckUpdateFishTail.bind(this),this.mindMap.on("afterExecCommand",this.onCheckUpdateFishTail))}unBindEvent(){this.mindMap.off("afterExecCommand",this.onCheckUpdateFishTail)}extendShape(){this.isFishbone2()&&this.mindMap.addShape({name:"fishHead",createShape:e=>{let t=Me(``),{width:r,height:n}=e.shapeInstance.getNodeSize();return t.size(r,n),t},getPadding:({width:e,height:t,paddingX:r,paddingY:n})=>{e+=r*2,t+=n*2;let s=this.paddingXRatio*e,a=0;return e+=s*2,a=(e/this.headRatio-t)/2,{paddingX:s,paddingY:a}}})}doLayout(e){qt([()=>{this.computedBaseValue(),this.addFishTail()},()=>{this.computedLeftTopValue()},()=>{this.adjustLeftTopValue(),this.updateFishTailPosition()},()=>{e(this.root)}])}addFishTail(){if(!this.isFishbone2())return;let e=this.mindMap.lineDraw.findOne(".smm-layout-fishbone-tail");e?this.fishTail=e:(this.fishTail=Me(``),this.fishTail.addClass("smm-layout-fishbone-tail"));let t=this.root.height,r=t*this.tailRatio;this.fishTail.size(r,t),this.styleFishTail(),this.mindMap.lineDraw.add(this.fishTail)}onCheckUpdateFishTail(e,t,r){if(e==="SET_NODE_DATA"){let n=!1;Object.keys(r).forEach(s=>{wc.includes(s)&&(n=!0)}),n&&this.styleFishTail()}}styleFishTail(){this.root.style.shape(this.fishTail)}removeFishTail(){let e=this.mindMap.lineDraw.findOne(".smm-layout-fishbone-tail");e&&e.remove()}updateFishTailPosition(){this.isFishbone2()&&this.fishTail.x(this.maxx).cy(this.root.top+this.root.height/2)}computedBaseValue(){se(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{r&&this.isFishbone2()&&(e.data.shape="fishHead");let o=this.createNode(e,t,r,n,s,a);if(r)this.setNodeCenter(o);else if(t._node.dir?o.dir=t._node.dir:o.dir=s%2===0?A.LAYOUT_GROW_DIR.TOP:A.LAYOUT_GROW_DIR.BOTTOM,t._node.isRoot){let l=this.getMarginY(n),h=this.isFishbone2()?t._node.height/4:0;this.checkIsTop(o)?o.top=t._node.top-o.height-l+h:o.top=t._node.top+t._node.height+l-h}if(!e.data.expand)return!0},null,!0,0)}computedLeftTopValue(){se(this.root,null,(e,t,r,n)=>{if(e.isRoot){let a=this.getMarginX(n+1),o=this.isFishbone2()?2:1,l=e.left+e.width+e.height/o+a,h=e.left+e.width+e.height/o+a;e.children.forEach(d=>{this.checkIsTop(d)?(d.left=l,l+=d.width+a):(d.left=h+20,h+=d.width+a)})}let s={layerIndex:n,node:e,ctx:this};this.checkIsTop(e)?Fi.top.computedLeftTopValue(s):Fi.bottom.computedLeftTopValue(s)},null,!0)}adjustLeftTopValue(){se(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s={node:e,parent:t,layerIndex:n,ctx:this};this.checkIsTop(e)?Fi.top.adjustLeftTopValueBefore(s):Fi.bottom.adjustLeftTopValueBefore(s)},(e,t)=>{let r={parent:t,node:e,ctx:this};if(this.checkIsTop(e)?Fi.top.adjustLeftTopValueAfter(r):Fi.bottom.adjustLeftTopValueAfter(r),e.isRoot){let n=0,s=0,a=-1/0;e.children.forEach(o=>{if(this.checkIsTop(o)){o.left+=n,this.updateChildren(o.children,"left",n);let{left:l,right:h}=this.getNodeBoundaries(o,"h");h>a&&(a=h),n+=h-l}else{o.left+=s,this.updateChildren(o.children,"left",s);let{left:l,right:h}=this.getNodeBoundaries(o,"h");h>a&&(a=h),s+=h-l}}),this.maxx=a}},!0)}getNodeAreaHeight(e){let t=0,r=n=>{let s=this.getMarginY(n.layerIndex);t+=n.height+(this.getNodeActChildrenLength(n)>0?n.expandBtnSize:0)+s,n.children.length&&n.children.forEach(a=>{r(a)})};return r(e),t}updateBrothersLeft(e){let t=e.children,r=0;t.forEach(n=>{n.left+=r,n.children&&n.children.length&&this.updateChildren(n.children,"left",r);let{left:s,right:a}=this.getNodeBoundaries(n,"h"),l=a-s-n.width;l>0&&(r+=l)})}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ee(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.checkIsTop(e)?this.updateBrothersTop(e.parent,t):this.updateBrothersTop(e.parent,e.layerIndex===3?0:t)}}checkIsTop(e){return e.dir===A.LAYOUT_GROW_DIR.TOP}renderLine(e,t,r){if(e.layerIndex!==1&&e.children.length<=0)return[];let{top:n,height:s,expandBtnSize:a}=e,{alwaysShowExpandBtn:o,notShowExpandBtn:l}=this.mindMap.opt;(!o||l)&&(a=0);let h=e.children.length;if(e.isRoot){let d=-1/0;e.children.forEach(x=>{x.left>d&&(d=x.left);let v=this.getMarginY(x.layerIndex),b=x.left,E=e.height/2+v-(this.isFishbone2()?e.height/4:0),S=E/Math.tan(Yr(this.mindMap.opt.fishboneDeg)),C=this.lineDraw.path();this.checkIsTop(x)?C.plot(this.transformPath(`M ${b-S},${x.top+x.height+E} L ${x.left},${x.top+x.height}`)):C.plot(this.transformPath(`M ${b-S},${x.top-E} L ${b},${x.top}`)),e.style.line(C),e._lines.push(C),r&&r(C,e)});let c=e.top+e.height/2,f=e.height/2+this.getMarginY(e.layerIndex+1),m=this.lineDraw.path(),g=this.isFishbone2()?this.maxx:d-f/Math.tan(Yr(this.mindMap.opt.fishboneDeg));m.plot(this.transformPath(`M ${e.left+e.width},${c} L ${g},${c}`)),e.style.line(m),e._lines.push(m),r&&r(m,e)}else{let d=-1/0,c=1/0,f=-1/0,m=e.left+e.width*this.indent;if(e.children.forEach((g,x)=>{g.left>f&&(f=g.left);let v=g.top+g.height/2;if(v>d&&(d=v),v1){let b=`M ${m},${v} L ${g.left},${v}`;this.setLineStyle(r,t[x],b,g)}}),h>=0){let g=this.lineDraw.path();a=h>0?a:0;let x=f-e.left-e.width*this.indent;x=Math.max(x,0);let v={node:e,line:g,top:n,x:m,lineLength:x,height:s,expandBtnSize:a,maxy:d,miny:c,ctx:this};this.checkIsTop(e)?Fi.top.renderLine(v):Fi.bottom.renderLine(v),e.style.line(g),e._lines.push(g),r&&r(g,e)}}}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,isRoot:a}=e;if(!a){let{translateX:o,translateY:l}=t.transform(),h={node:e,btn:t,expandBtnSize:s,translateX:o,translateY:l,width:r,height:n};this.checkIsTop(e)?Fi.top.renderExpandBtn(h):Fi.bottom.renderExpandBtn(h)}}renderGeneralization(e){e.forEach(t=>{let{top:r,bottom:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"h"),l=s+a,h=r,d=s+a,c=n,f=l+20,m=h+(c-h)/2,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.left=s+o,t.generalizationNode.top=r+(n-r-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){let a="";s.dir===A.LAYOUT_GROW_DIR.TOP?a=s.layerIndex===1?A.LAYOUT_GROW_DIR.TOP:A.LAYOUT_GROW_DIR.BOTTOM:a=s.layerIndex===1?A.LAYOUT_GROW_DIR.BOTTOM:A.LAYOUT_GROW_DIR.TOP,a===A.LAYOUT_GROW_DIR.TOP?e.size(r,t).x(0).y(-t):e.size(r,t).x(0).y(n)}beforeChange(){this.isFishbone2()&&(this.root.nodeData.data.shape=A.SHAPE.RECTANGLE,this.removeFishTail(),this.unBindEvent(),this.mindMap.removeShape("fishHead"))}},Mm=wm});var ov,Ll,lv=M(()=>{he();Oe();ov="smm-node-edit-wrap",Ll=class{constructor(e){this.renderer=e,this.mindMap=e.mindMap,this.currentNode=null,this.textEditNode=null,this.showTextEdit=!1,this.cacheEditingText="",this.hasBodyMousedown=!1,this.textNodePaddingX=5,this.textNodePaddingY=3,this.isNeedUpdateTextEditNode=!1,this.mindMap.addEditNodeClass(ov),this.bindEvent()}bindEvent(){this.show=this.show.bind(this),this.onScale=this.onScale.bind(this),this.onKeydown=this.onKeydown.bind(this),this.mindMap.on("node_dblclick",(e,t,r)=>{this.show({node:e,e:t,isInserting:r})}),this.mindMap.on("draw_click",()=>{this.hideEditTextBox()}),this.mindMap.on("body_mousedown",()=>{this.hasBodyMousedown=!0}),this.mindMap.on("body_click",()=>{this.hasBodyMousedown&&(this.hasBodyMousedown=!1,this.mindMap.opt.isEndNodeTextEditOnClickOuter&&this.hideEditTextBox())}),this.mindMap.on("svg_mousedown",()=>{this.hideEditTextBox()}),this.mindMap.on("expand_btn_click",()=>{this.hideEditTextBox()}),this.mindMap.on("before_node_active",()=>{this.hideEditTextBox()}),this.mindMap.on("mousewheel",()=>{this.mindMap.opt.mousewheelAction===A.MOUSE_WHEEL_ACTION.MOVE&&this.hideEditTextBox()}),this.mindMap.keyCommand.addShortcut("F2",()=>{this.renderer.activeNodeList.length<=0||this.show({node:this.renderer.activeNodeList[0]})}),this.mindMap.on("scale",this.onScale),this.mindMap.opt.enableAutoEnterTextEditWhenKeydown&&window.addEventListener("keydown",this.onKeydown),this.mindMap.on("beforeDestroy",()=>{this.unBindEvent()}),this.mindMap.on("after_update_config",(e,t)=>{e.openRealtimeRenderOnNodeTextEdit!==t.openRealtimeRenderOnNodeTextEdit&&(this.mindMap.richText?this.mindMap.richText.onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e.openRealtimeRenderOnNodeTextEdit):this.onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e.openRealtimeRenderOnNodeTextEdit)),e.enableAutoEnterTextEditWhenKeydown!==t.enableAutoEnterTextEditWhenKeydown&&window[e.enableAutoEnterTextEditWhenKeydown?"addEventListener":"removeEventListener"]("keydown",this.onKeydown)}),this.mindMap.on("afterExecCommand",()=>{this.isShowTextEdit()&&(this.isNeedUpdateTextEditNode=!0)}),this.mindMap.on("node_tree_render_end",()=>{this.isShowTextEdit()&&this.isNeedUpdateTextEditNode&&(this.isNeedUpdateTextEditNode=!1,this.updateTextEditNode())})}unBindEvent(){window.removeEventListener("keydown",this.onKeydown)}onKeydown(e){if(e.target!==document.body)return;let t=this.mindMap.renderer.activeNodeList;if(t.length<=0||t.length>1)return;let r=t[0];r&&this.checkIsAutoEnterTextEditKey(e)&&(e.preventDefault(),this.show({node:r,e,isInserting:!1,isFromKeyDown:!0}))}checkIsAutoEnterTextEditKey(e){let t=e.keyCode;return(t===229||t>=65&&t<=90||t>=48&&t<=57)&&!this.mindMap.keyCommand.hasCombinationKey(e)}registerTmpShortcut(){this.mindMap.keyCommand.addShortcut("Enter",()=>{this.hideEditTextBox()}),this.mindMap.keyCommand.addShortcut("Tab",()=>{this.hideEditTextBox()})}isShowTextEdit(){return this.mindMap.richText?this.mindMap.richText.showTextEdit:this.showTextEdit}setIsShowTextEdit(e){this.showTextEdit=e,e?this.mindMap.keyCommand.stopCheckInSvg():this.mindMap.keyCommand.recoveryCheckInSvg()}async show({node:e,isInserting:t=!1,isFromKeyDown:r=!1,isFromScale:n=!1}){if(e.isUseCustomNodeContent())return;this.getCurrentEditNode()&&this.hideEditTextBox();let{beforeTextEdit:a,openRealtimeRenderOnNodeTextEdit:o}=this.mindMap.opt;if(typeof a=="function"){let m=!1;try{m=await a(e,t)}catch(g){m=!1,this.mindMap.opt.errorHandler(di.BEFORE_TEXT_EDIT_ERROR,g)}if(!m)return}let{offsetLeft:l,offsetTop:h}=Fp(this.mindMap,e);this.mindMap.view.translateXY(l,h);let d=e._textData.node;o&&d.show();let c=d.node.getBoundingClientRect();o&&d.hide();let f={node:e,rect:c,isInserting:t,isFromKeyDown:r,isFromScale:n};if(this.mindMap.richText){this.mindMap.richText.showEditText(f);return}this.currentNode=e,this.showEditTextBox(f)}onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e){this.textEditNode&&(this.textEditNode.style.background=e?"transparent":this.currentNode?this.getBackground(this.currentNode):"",this.textEditNode.style.boxShadow=e?"none":"0 0 20px rgba(0,0,0,.5)")}onScale(){let e=this.getCurrentEditNode();e&&(this.mindMap.richText?(this.mindMap.richText.cacheEditingText=this.mindMap.richText.getEditText(),this.mindMap.richText.showTextEdit=!1):(this.cacheEditingText=this.getEditText(),this.setIsShowTextEdit(!1)),this.show({node:e,isFromScale:!0}))}showEditTextBox({node:e,rect:t,isInserting:r,isFromKeyDown:n,isFromScale:s}){if(this.showTextEdit)return;let{nodeTextEditZIndex:a,textAutoWrapWidth:o,selectTextOnEnterEditText:l,openRealtimeRenderOnNodeTextEdit:h,autoEmptyTextWhenKeydownEnterEdit:d}=this.mindMap.opt;s||this.mindMap.emit("before_show_text_edit"),this.registerTmpShortcut(),this.textEditNode||(this.textEditNode=document.createElement("div"),this.textEditNode.classList.add(ov),this.textEditNode.style.cssText=` +`});var bv={};tt(bv,{default:()=>BP});var dp,vv,bc,BP,wv=T(()=>{og();pv();pe();yv();dp=!1,vv=vc.import("formats/formula"),bc=class{constructor(e){this.opt=e,this.mindMap=e.mindMap,window.katex=Oh,this.init(),this.config=this.getKatexConfig(),this.cssEl=null,this.addStyle(),this.extendQuill(),this.onDestroy=this.onDestroy.bind(this),this.mindMap.on("beforeDestroy",this.onDestroy)}onDestroy(){Object.getPrototypeOf(this.mindMap).constructor.instanceCount<=1&&(dp=!1,vc.register("formats/formula",vv,!0))}init(){this.mindMap.opt.enableEditFormulaInRichTextEdit&&(this.mindMap.opt.transformRichTextOnEnterEdit=this.latexRichToText.bind(this),this.mindMap.opt.beforeHideRichTextEdit=this.formatLatex.bind(this))}getKatexConfig(){let e={throwOnError:!1,errorColor:"#f00",output:"mathml"},{getKatexOutputType:t}=this.mindMap.opt;t=t||function(){let n=I2();if(n&&n<=100)return"html"};let r=t()||"mathml";return e.output=["mathml","html"].includes(r)?r:"mathml",e}extendQuill(){if(dp)return;dp=!0;let e=this;class t extends vv{static create(n){let s=super.create(n);return typeof n=="string"&&(Oh.render(n,s,e.config),s.setAttribute("data-value",mn(n))),s}}vc.register("formats/formula",t,!0)}getStyleText(){let{katexFontPath:e}=this.mindMap.opt,t="";return this.config.output==="html"&&(t=gv(e)),t+=xv(),t}addStyle(){this.cssEl=document.createElement("style"),this.cssEl.type="text/css",this.cssEl.innerHTML=this.getStyleText(),document.head.appendChild(this.cssEl)}removeStyle(){document.head.removeChild(this.cssEl)}insertFormulaToNode(e,t){let r=this.mindMap.richText;r.showEditText({node:e}),r.quill.insertEmbed(r.quill.getLength()-1,"formula",t),r.hideEditText([e])}latexRichToText(e){if(e.indexOf('class="ql-formula"')!==-1){let n=new DOMParser().parseFromString(e,"text/html").getElementsByClassName("ql-formula");for(let s of n)e=e.replace(s.outerHTML,`$${s.getAttribute("data-value")}$`);this.mindMap.opt.openRealtimeRenderOnNodeTextEdit&&setTimeout(()=>{this.mindMap.emit("node_text_edit_change",{node:this.mindMap.richText.node,text:this.mindMap.richText.getEditText(),richText:!0})},0)}return e}formatLatex(e){let t=e.quill.getContents(),r=t.ops,n=!1;for(let s=r.length-1;s>=0;s--){let o=r[s].insert;if(o&&typeof o!="object"&&o!==` +`&&/\$.+?\$/g.test(o)){let l=[...o.matchAll(/\$.+?\$/g)],h=o.split(/\$.+?\$/g);for(let d=l.length-1;d>=0;d--){let c=l[d]&&l[d][0]&&l[d][0].slice(1,-1)||null;c!==null&&c.trim().length>0&&this.checkFormulaIsLegal(c)?(h.splice(d+1,0,{insert:{formula:c}}),n=!0):h.splice(d+1,0,"")}for(;h.length>0;){let d=h.pop();if(typeof d=="string"){if(d.length<1)continue;d={insert:d}}d.attributes=r[s].attributes,r.splice(s+1,0,d)}r.splice(s,1)}}n&&e.quill.setContents(t)}checkFormulaIsLegal(e){try{return Oh.renderToString(e),!0}catch{return!1}}beforePluginRemove(){this.removeStyle(),this.mindMap.off("beforeDestroy",this.onDestroy)}beforePluginDestroy(){this.removeStyle(),this.mindMap.off("beforeDestroy",this.onDestroy)}};bc.instanceName="formula";BP=bc});var cp,Mv,Tv=T(()=>{$e();cp=class{constructor(e={}){this.opt=e,this.mindMap=this.opt.mindMap,this.scale=1,this.sx=0,this.sy=0,this.x=0,this.y=0,this.firstDrag=!0,this.setTransformData(this.mindMap.opt.viewData),this.bind()}bind(){this.mindMap.keyCommand.addShortcut("Control+=",()=>{this.enlarge()}),this.mindMap.keyCommand.addShortcut("Control+-",()=>{this.narrow()}),this.mindMap.keyCommand.addShortcut("Control+i",()=>{this.fit()}),this.mindMap.event.on("mousedown",e=>{let{isDisableDrag:t,mousedownEventPreventDefault:r}=this.mindMap.opt;t||(r&&e.preventDefault(),this.sx=this.x,this.sy=this.y)}),this.mindMap.event.on("drag",(e,t)=>{e.ctrlKey||e.metaKey||this.mindMap.opt.isDisableDrag||(this.firstDrag&&(this.firstDrag=!1,this.mindMap.renderer.activeNodeList.length>0&&this.mindMap.execCommand("CLEAR_ACTIVE_NODE")),this.x=this.sx+t.mousemoveOffset.x,this.y=this.sy+t.mousemoveOffset.y,this.transform())}),this.mindMap.event.on("mouseup",()=>{this.firstDrag=!0}),this.mindMap.event.on("mousewheel",(e,t,r,n)=>{let{customHandleMousewheel:s,mousewheelAction:a,mouseScaleCenterUseMousePosition:o,mousewheelMoveStep:l,mousewheelZoomActionReverse:h,disableMouseWheelZoom:d,translateRatio:c}=this.mindMap.opt;if(s&&typeof s=="function")return s(e);if(a===k.MOUSE_WHEEL_ACTION.ZOOM||e.ctrlKey||e.metaKey){if(d)return;let{x:f,y:m}=this.mindMap.toPos(e.clientX,e.clientY),g=o?f:void 0,x=o?m:void 0;switch(n&&(t.includes(k.DIR.LEFT)||t.includes(k.DIR.RIGHT))&&(t=t.filter(y=>![k.DIR.LEFT,k.DIR.RIGHT].includes(y))),!0){case t.includes(k.DIR.UP||k.DIR.LEFT):h?this.enlarge(g,x,n):this.narrow(g,x,n);break;case t.includes(k.DIR.DOWN||k.DIR.RIGHT):h?this.narrow(g,x,n):this.enlarge(g,x,n);break}}else{let f=0,m=0;n?(f=Math.abs(e.wheelDeltaX),m=Math.abs(e.wheelDeltaY)):f=m=l;let g=0,x=0;t.includes(k.DIR.DOWN)&&(x=-m),t.includes(k.DIR.UP)&&(x=m),t.includes(k.DIR.LEFT)&&(g=f),t.includes(k.DIR.RIGHT)&&(g=-f),this.translateXY(g*c,x*c)}}),this.mindMap.on("resize",()=>{this.checkNeedMindMapInCanvas()&&this.transform()})}getTransformData(){return{transform:this.mindMap.draw.transform(),state:{scale:this.scale,x:this.x,y:this.y,sx:this.sx,sy:this.sy}}}setTransformData(e){e&&(Object.keys(e.state).forEach(t=>{this[t]=e.state[t]}),this.mindMap.draw.transform({...e.transform}),this.mindMap.emit("view_data_change",this.getTransformData()),this.emitEvent("scale"),this.emitEvent("translate"))}translateXY(e,t){e===0&&t===0||(this.x+=e,this.y+=t,this.transform(),this.emitEvent("translate"))}translateX(e){e!==0&&(this.x+=e,this.transform(),this.emitEvent("translate"))}translateXTo(e){this.x=e,this.transform(),this.emitEvent("translate")}translateY(e){e!==0&&(this.y+=e,this.transform(),this.emitEvent("translate"))}translateYTo(e){this.y=e,this.transform(),this.emitEvent("translate")}transform(){try{this.limitMindMapInCanvas()}catch{}this.mindMap.draw.transform({origin:[0,0],scale:this.scale,translate:[this.x,this.y]}),this.mindMap.emit("view_data_change",this.getTransformData())}reset(){let e=this.scale!==1,t=this.x!==0||this.y!==0;this.scale=1,this.x=0,this.y=0,this.transform(),e&&this.emitEvent("scale"),t&&this.emitEvent("translate")}narrow(e,t,r){let{scaleRatio:n,minZoomRatio:s}=this.mindMap.opt;n=n/(r?5:1);let a=Math.max(this.scale-n,s/100);this.scaleInCenter(a,e,t),this.transform(),this.emitEvent("scale")}enlarge(e,t,r){let{scaleRatio:n,maxZoomRatio:s}=this.mindMap.opt;n=n/(r?5:1);let a=0;s===-1?a=this.scale+n:a=Math.min(this.scale+n,s/100),this.scaleInCenter(a,e,t),this.transform(),this.emitEvent("scale")}scaleInCenter(e,t,r){(t===void 0||r===void 0)&&(t=this.mindMap.width/2,r=this.mindMap.height/2);let n=this.scale,s=1-e/n,a=(t-this.x)*s,o=(r-this.y)*s;this.x+=a,this.y+=o,this.scale=e}setScale(e,t,r){t!==void 0&&r!==void 0?this.scaleInCenter(e,t,r):this.scale=e,this.transform(),this.emitEvent("scale")}fit(e=()=>{},t=!1,r){r=r===void 0?this.mindMap.opt.fitPadding:r;let n=this.mindMap.draw,s=n.transform(),a=e()||n.rbox(),o=a.width/s.scaleX,l=a.height/s.scaleY,h=o/l,{width:d,height:c}=this.mindMap.elRect;d=d-r*2,c=c-r*2;let f=d/c,m=0,g="";if(o<=d&&l<=c&&!t)m=1,g=1;else{let S=0,A=0;h>f?(S=d,A=d/h,g=2):(A=c,S=c*h,g=3),m=S/o}this.setScale(m);let x=e()||n.rbox();x.x-=this.mindMap.elRect.left,x.y-=this.mindMap.elRect.top;let y=0,b=0;g===1?(y=-x.x+r+(d-x.width)/2,b=-x.y+r+(c-x.height)/2):g===2?(y=-x.x+r,b=-x.y+r+(c-x.height)/2):g===3&&(y=-x.x+r+(d-x.width)/2,b=-x.y+r),this.translateXY(y,b)}checkNeedMindMapInCanvas(){if(this.mindMap.demonstrate&&this.mindMap.demonstrate.isInDemonstrate)return!1;let{isLimitMindMapInCanvasWhenHasScrollbar:e,isLimitMindMapInCanvas:t}=this.mindMap.opt;return this.mindMap.scrollbar?e:t}limitMindMapInCanvas(){if(!this.checkNeedMindMapInCanvas())return;let{scale:e,left:t,top:r,right:n,bottom:s}=this.getPositionLimit(),a=(this.mindMap.width-this.mindMap.initWidth)/2*e,o=(this.mindMap.height-this.mindMap.initHeight)/2*e,l=this.scale/e;t*=l,n*=l,r*=l,s*=l;let h=this.mindMap.width/2,d=this.mindMap.height/2,c=this.scale-1;t-=c*h-a,n-=c*h-a,r-=c*d-o,s-=c*d-o,this.x>t&&(this.x=t),this.xr&&(this.y=r),this.y{"use strict";var PP=Object.prototype.hasOwnProperty,jt="~";function o0(){}Object.create&&(o0.prototype=Object.create(null),new o0().__proto__||(jt=!1));function FP(i,e,t){this.fn=i,this.context=e,this.once=t||!1}function Nv(i,e,t,r,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new FP(t,r||i,n),a=jt?jt+e:e;return i._events[a]?i._events[a].fn?i._events[a]=[i._events[a],s]:i._events[a].push(s):(i._events[a]=s,i._eventsCount++),i}function wc(i,e){--i._eventsCount===0?i._events=new o0:delete i._events[e]}function Ct(){this._events=new o0,this._eventsCount=0}Ct.prototype.eventNames=function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)PP.call(t,r)&&e.push(jt?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ct.prototype.listeners=function(e){var t=jt?jt+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,s=r.length,a=new Array(s);n{Sv=pt(Ev());$e();fp=class extends Sv.default{constructor(e={}){super(),this.opt=e,this.mindMap=e.mindMap,this.isLeftMousedown=!1,this.isRightMousedown=!1,this.isMiddleMousedown=!1,this.mousedownPos={x:0,y:0},this.mousemovePos={x:0,y:0},this.mousemoveOffset={x:0,y:0},this.bindFn(),this.bind()}bindFn(){this.onBodyMousedown=this.onBodyMousedown.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onDrawClick=this.onDrawClick.bind(this),this.onMousedown=this.onMousedown.bind(this),this.onMousemove=this.onMousemove.bind(this),this.onMouseup=this.onMouseup.bind(this),this.onNodeMouseup=this.onNodeMouseup.bind(this),this.onMousewheel=this.onMousewheel.bind(this),this.onContextmenu=this.onContextmenu.bind(this),this.onSvgMousedown=this.onSvgMousedown.bind(this),this.onKeyup=this.onKeyup.bind(this),this.onMouseenter=this.onMouseenter.bind(this),this.onMouseleave=this.onMouseleave.bind(this)}bind(){document.body.addEventListener("mousedown",this.onBodyMousedown),document.body.addEventListener("click",this.onBodyClick),this.mindMap.svg.on("click",this.onDrawClick),this.mindMap.el.addEventListener("mousedown",this.onMousedown),this.mindMap.svg.on("mousedown",this.onSvgMousedown),window.addEventListener("mousemove",this.onMousemove),window.addEventListener("mouseup",this.onMouseup),this.on("node_mouseup",this.onNodeMouseup),this.mindMap.el.addEventListener("wheel",this.onMousewheel),this.mindMap.svg.on("contextmenu",this.onContextmenu),this.mindMap.svg.on("mouseenter",this.onMouseenter),this.mindMap.svg.on("mouseleave",this.onMouseleave),window.addEventListener("keyup",this.onKeyup)}unbind(){document.body.removeEventListener("mousedown",this.onBodyMousedown),document.body.removeEventListener("click",this.onBodyClick),this.mindMap.svg.off("click",this.onDrawClick),this.mindMap.el.removeEventListener("mousedown",this.onMousedown),window.removeEventListener("mousemove",this.onMousemove),window.removeEventListener("mouseup",this.onMouseup),this.off("node_mouseup",this.onNodeMouseup),this.mindMap.el.removeEventListener("wheel",this.onMousewheel),this.mindMap.svg.off("contextmenu",this.onContextmenu),this.mindMap.svg.off("mouseenter",this.onMouseenter),this.mindMap.svg.off("mouseleave",this.onMouseleave),window.removeEventListener("keyup",this.onKeyup)}onDrawClick(e){this.emit("draw_click",e)}onBodyMousedown(e){this.emit("body_mousedown",e)}onBodyClick(e){this.emit("body_click",e)}onSvgMousedown(e){this.emit("svg_mousedown",e)}onMousedown(e){e.which===1?this.isLeftMousedown=!0:e.which===3?this.isRightMousedown=!0:e.which===2&&(this.isMiddleMousedown=!0),this.mousedownPos.x=e.clientX,this.mousedownPos.y=e.clientY,this.emit("mousedown",e,this)}onMousemove(e){let{useLeftKeySelectionRightKeyDrag:t}=this.mindMap.opt;this.mousemovePos.x=e.clientX,this.mousemovePos.y=e.clientY,this.mousemoveOffset.x=e.clientX-this.mousedownPos.x,this.mousemoveOffset.y=e.clientY-this.mousedownPos.y,this.emit("mousemove",e,this),(this.isMiddleMousedown||(t?this.isRightMousedown:this.isLeftMousedown))&&(e.preventDefault(),this.emit("drag",e,this))}onMouseup(e){this.onNodeMouseup(),this.emit("mouseup",e,this)}onNodeMouseup(){this.isLeftMousedown=!1,this.isRightMousedown=!1,this.isMiddleMousedown=!1}onMousewheel(e){e.stopPropagation(),e.preventDefault();let t=[];e.deltaY<0&&t.push(k.DIR.UP),e.deltaY>0&&t.push(k.DIR.DOWN),e.deltaX<0&&t.push(k.DIR.LEFT),e.deltaX>0&&t.push(k.DIR.RIGHT);let r=!1,{customCheckIsTouchPad:n}=this.mindMap.opt;typeof n=="function"?r=n(e):r=Math.abs(e.deltaY)<=10,this.emit("mousewheel",e,t,this,r)}onContextmenu(e){e.preventDefault(),!e.ctrlKey&&this.emit("contextmenu",e)}onKeyup(e){this.emit("keyup",e)}onMouseenter(e){this.emit("svg_mouseenter",e)}onMouseleave(e){this.emit("svg_mouseleave",e)}},Av=fp});var mp,pp,Cv=T(()=>{Ar();pe();$e();mp=class extends Mt{constructor(e={},t){super(e),this.isUseLeft=t===k.LAYOUT.LOGICAL_STRUCTURE_LEFT}doLayout(e){Zt([()=>{this.computedBaseValue()},()=>{this.computedTopValue()},()=>{this.adjustTopValue()},()=>{e(this.root)}])}computedBaseValue(){let e=0;de(this.renderer.renderTree,null,(t,r,n,s,a,o)=>{let l=this.createNode(t,r,n,s,a,o);if(l.sortIndex=e,e++,n?this.setNodeCenter(l):this.isUseLeft?l.left=r._node.left-l.width-this.getMarginX(s):l.left=r._node.left+r._node.width+this.getMarginX(s),!t.data.expand)return!0},(t,r,n,s)=>{let a=t.data.expand===!1?0:t._node.children.length;t._node.childrenAreaHeight=a?t._node.children.reduce((l,h)=>l+h.height,0)+(a+1)*this.getMarginY(s+1):0;let o=t._node.checkHasGeneralization()?t._node._generalizationNodeHeight+this.getMarginY(s+1):0;t._node.childrenAreaHeight2=Math.max(t._node.childrenAreaHeight,o)},!0,0)}computedTopValue(){de(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginY(n+1),o=e.top+e.height/2-e.childrenAreaHeight/2+s;e.children.forEach(l=>{l.top=o,o+=l.height+s})}},null,!0)}adjustTopValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s=e.childrenAreaHeight2-this.getMarginY(n+1)*2-e.height;s>0&&this.updateBrothers(e,s/2)},null,!0)}updateBrothers(e,t){if(e.parent){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.uid===e.uid||s.hasCustomPosition())return;let o=0;an&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothers(e.parent,t)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let f=(this.getMarginX(e.layerIndex+1)-l)*.6;this.isUseLeft&&(f*=-1);let m=this.mindMap.themeConfig.nodeUseLineStyle;e.children.forEach((g,x)=>{let y;this.isUseLeft?y=e.layerIndex===0?n:n-l:y=e.layerIndex===0?n+a:n+a+l;let b=s+o/2,S=this.isUseLeft?g.left+g.width:g.left,A=g.top+g.height/2,C=m?g.width*(this.isUseLeft?-1:1):0;b=m&&!e.isRoot?b+o/2:b,A=m?A+g.height/2:A;let I=this.createFoldLine([[y,b],[y+f,b],[y+f,A],[S+C,A]]);this.setLineStyle(r,t[x],I,g)})}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c}=this.mindMap.themeConfig;e.children.forEach((f,m)=>{e.layerIndex===0&&(l=0);let g=this.isUseLeft?n-l:n+a+l,x=s+o/2,y=this.isUseLeft?f.left+f.width:f.left,b=f.top+f.height/2;x=c&&!e.isRoot?x+o/2:x,b=c?b+f.height/2:b;let S=c?` L ${this.isUseLeft?f.left:f.left+f.width},${b}`:"",A=`M ${g},${x} L ${y},${b}`+S;this.setLineStyle(r,t[m],A,f)})}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c,rootLineStartPositionKeepSameInCurve:f,rootLineKeepSameInCurve:m}=this.mindMap.themeConfig;e.children.forEach((g,x)=>{e.layerIndex===0&&(l=0);let y;this.isUseLeft?y=e.layerIndex===0&&!f?n+a/2:n-l:y=e.layerIndex===0&&!f?n+a/2:n+a+l;let b=s+o/2,S=this.isUseLeft?g.left+g.width:g.left,A=g.top+g.height/2,C="";b=c&&!e.isRoot?b+o/2:b,A=c?A+g.height/2:A;let I;this.isUseLeft?I=c?` L ${g.left},${A}`:"":I=c?` L ${g.left+g.width},${A}`:"",e.isRoot&&!m?C=this.quadraticCurvePath(y,b,S,A)+I:C=this.cubicBezierPath(y,b,S,A)+I,this.setLineStyle(r,t[x],C,g)})}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,layerIndex:a}=e;a===0&&(s=0);let{translateX:o,translateY:l}=t.transform(),h=this.mindMap.themeConfig.nodeUseLineStyle?n/2:0,d=this.isUseLeft?0-s:r,c=n/2+h;d===o&&c===l||t.translate(d-o,c-l)}renderGeneralization(e){e.forEach(t=>{let{left:r,top:n,bottom:s,right:a,generalizationLineMargin:o,generalizationNodeMargin:l}=this.getNodeGeneralizationRenderBoundaries(t,"h"),h=this.isUseLeft?r-o:a+o,d=h,c=n,f=h,m=s,g=d+(this.isUseLeft?-20:20),x=c+(m-c)/2,y=`M ${d},${c} Q ${g},${x} ${f},${m}`;t.generalizationLine.plot(y),t.generalizationNode.left=h+(this.isUseLeft?-l:l)-(this.isUseLeft?t.generalizationNode.width:0),t.generalizationNode.top=n+(s-n-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n){this.isUseLeft?e.size(t,n).x(-t).y(0):e.size(t,n).x(r).y(0)}},pp=mp});var gp,_v,Lv=T(()=>{Ar();pe();$e();gp=class extends Mt{constructor(e={}){super(e)}doLayout(e){Zt([()=>{this.computedBaseValue()},()=>{this.computedTopValue()},()=>{this.adjustTopValue()},()=>{e(this.root)}])}computedBaseValue(){de(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):(t._node.dir?o.dir=t._node.dir:o.dir=o.getData("dir")||(s%2===0?k.LAYOUT_GROW_DIR.RIGHT:k.LAYOUT_GROW_DIR.LEFT),o.left=o.dir===k.LAYOUT_GROW_DIR.RIGHT?t._node.left+t._node.width+this.getMarginX(n):t._node.left-this.getMarginX(n)-o.width),!e.data.expand)return!0},(e,t,r,n)=>{if(!e.data.expand){e._node.leftChildrenAreaHeight=0,e._node.rightChildrenAreaHeight=0;return}let s=0,a=0,o=0,l=0;e._node.children.forEach(d=>{d.dir===k.LAYOUT_GROW_DIR.LEFT?(s++,o+=d.height):(a++,l+=d.height)}),e._node.leftChildrenAreaHeight=o+(s+1)*this.getMarginY(n+1),e._node.rightChildrenAreaHeight=l+(a+1)*this.getMarginY(n+1);let h=e._node.checkHasGeneralization()?e._node._generalizationNodeHeight+this.getMarginY(n+1):0;e._node.leftChildrenAreaHeight2=Math.max(e._node.leftChildrenAreaHeight,h),e._node.rightChildrenAreaHeight2=Math.max(e._node.rightChildrenAreaHeight,h)},!0,0)}computedTopValue(){de(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginY(n+1),a=e.top+e.height/2+s,o=a-e.leftChildrenAreaHeight/2,l=a-e.rightChildrenAreaHeight/2;e.children.forEach(h=>{h.dir===k.LAYOUT_GROW_DIR.LEFT?(h.top=o,o+=h.height+s):(h.top=l,l+=h.height+s)})}},null,!0)}adjustTopValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s=this.getMarginY(n+1)*2+e.height,a=e.leftChildrenAreaHeight2-s,o=e.rightChildrenAreaHeight2-s;(a>0||o>0)&&this.updateBrothers(e,a/2,o/2)},null,!0)}updateBrothers(e,t,r){if(e.parent){let n=e.parent.children.filter(a=>a.dir===e.dir),s=Ie(e,n);n.forEach((a,o)=>{if(a.hasCustomPosition())return;let l=0,h=a.dir===k.LAYOUT_GROW_DIR.LEFT?t:r;os&&(l=h),a.top+=l,a.children&&a.children.length&&this.updateChildren(a.children,"top",l)}),this.updateBrothers(e.parent,t,r)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let f=(this.getMarginX(e.layerIndex+1)-l)*.6,m=this.mindMap.themeConfig.nodeUseLineStyle;e.children.forEach((g,x)=>{let y=0,b=0,S=m?g.width:0;g.dir===k.LAYOUT_GROW_DIR.LEFT?(b=-f,y=e.layerIndex===0?n:n-l,S=-S):(b=f,y=e.layerIndex===0?n+a:n+a+l);let A=s+o/2,C=g.dir===k.LAYOUT_GROW_DIR.LEFT?g.left+g.width:g.left,I=g.top+g.height/2;A=m&&!e.isRoot?A+o/2:A,I=m?I+g.height/2:I;let O=this.createFoldLine([[y,A],[y+b,A],[y+b,I],[C+S,I]]);this.setLineStyle(r,t[x],O,g)})}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c}=this.mindMap.themeConfig;e.children.forEach((f,m)=>{e.layerIndex===0&&(l=0);let g=f.dir===k.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,x=s+o/2,y=f.dir===k.LAYOUT_GROW_DIR.LEFT?f.left+f.width:f.left,b=f.top+f.height/2;x=c&&!e.isRoot?x+o/2:x,b=c?b+f.height/2:b;let S="";c&&(f.dir===k.LAYOUT_GROW_DIR.LEFT?S=` L ${f.left},${b}`:S=` L ${f.left+f.width},${b}`);let A=`M ${g},${x} L ${y},${b}`+S;this.setLineStyle(r,t[m],A,f)})}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c,rootLineKeepSameInCurve:f,rootLineStartPositionKeepSameInCurve:m}=this.mindMap.themeConfig;e.children.forEach((g,x)=>{e.layerIndex===0&&(l=0);let y=e.layerIndex===0&&!m?n+a/2:g.dir===k.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,b=s+o/2,S=g.dir===k.LAYOUT_GROW_DIR.LEFT?g.left+g.width:g.left,A=g.top+g.height/2,C="";b=c&&!e.isRoot?b+o/2:b,A=c?A+g.height/2:A;let I="";c&&(g.dir===k.LAYOUT_GROW_DIR.LEFT?I=` L ${g.left},${A}`:I=` L ${g.left+g.width},${A}`),e.isRoot&&!f?C=this.quadraticCurvePath(y,b,S,A)+I:C=this.cubicBezierPath(y,b,S,A)+I,this.setLineStyle(r,t[x],C,g)})}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s}=e,{translateX:a,translateY:o}=t.transform(),l=this.mindMap.themeConfig.nodeUseLineStyle?n/2:0,h=e.dir===k.LAYOUT_GROW_DIR.LEFT?0-s:r,d=n/2+l;if(h===a&&d===o)return;let c=h-a,f=d-o;t.translate(c,f)}renderGeneralization(e){e.forEach(t=>{let r=t.node.dir===k.LAYOUT_GROW_DIR.LEFT,{top:n,bottom:s,left:a,right:o,generalizationLineMargin:l,generalizationNodeMargin:h}=this.getNodeGeneralizationRenderBoundaries(t,"h"),d=r?a-l:o+l,c=d,f=n,m=d,g=s,x=c+(r?-20:20),y=f+(g-f)/2,b=`M ${c},${f} Q ${x},${y} ${m},${g}`;t.generalizationLine.plot(b),t.generalizationNode.left=d+(r?-h:h)-(r?t.generalizationNode.width:0),t.generalizationNode.top=n+(s-n-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){s.dir===k.LAYOUT_GROW_DIR.LEFT?e.size(t,n).x(-t).y(0):e.size(t,n).x(r).y(0)}},_v=gp});var xp,Iv,zv=T(()=>{Ar();pe();xp=class extends Mt{constructor(e={}){super(e)}doLayout(e){Zt([()=>{this.computedBaseValue()},()=>{this.computedLeftTopValue()},()=>{this.adjustLeftTopValue()},()=>{e(this.root)}])}computedBaseValue(){de(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):t._node.isRoot&&(o.top=t._node.top+t._node.height+this.getMarginX(n)),!e.data.expand)return!0},(e,t,r,n)=>{if(r){let s=e.data.expand===!1?0:e._node.children.length;e._node.childrenAreaWidth=s?e._node.children.reduce((a,o)=>a+o.width,0)+(s+1)*this.getMarginX(n+1):0}},!0,0)}computedLeftTopValue(){de(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginX(n+1),a=this.getMarginY(n+1);if(r){let l=e.left+e.width/2-e.childrenAreaWidth/2+s;e.children.forEach(h=>{h.left=l,l+=h.width+s})}else{let o=e.top+this.getNodeHeightWithGeneralization(e)+a+(this.getNodeActChildrenLength(e)>0?e.expandBtnSize:0);e.children.forEach(l=>{l.left=e.left+e.width*.5,l.top=o,o+=this.getNodeHeightWithGeneralization(l)+a+(this.getNodeActChildrenLength(l)>0?l.expandBtnSize:0)})}}},null,!0)}adjustLeftTopValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;if(t&&t.isRoot){let o=this.getNodeAreaWidth(e,!0)-e.width;o>0&&this.updateBrothersLeft(e,o)}let s=e.children.length;if(t&&!t.isRoot&&s>0){let a=this.getMarginY(n+1),o=e.children.reduce((l,h)=>l+this.getNodeHeightWithGeneralization(h)+(this.getNodeActChildrenLength(h)>0?h.expandBtnSize:0),0)+s*a;this.updateBrothersTop(e,o)}},(e,t,r)=>{if(r){let{right:n,left:s}=this.getNodeBoundaries(e,"h"),a=n-s,o=e.left-s-(a-e.width)/2;this.updateChildren(e.children,"left",o)}},!0)}updateBrothersLeft(e,t){if(e.parent){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{s.hasCustomPosition()||a<=n||(s.left+=t,s.children&&s.children.length&&this.updateChildren(s.children,"left",t))}),this.updateBrothersLeft(e.parent,t)}}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothersTop(e.parent,t)}}renderLine(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let c=e.children.length,f=this.getMarginX(e.layerIndex+1);if(e.isRoot){let m=n+a/2,g=s+o,x=f*.7,y=1/0,b=-1/0;e.children.forEach((A,C)=>{let I=A.left+A.width/2,O=A.top;Ib&&(b=I);let q=this.mindMap.themeConfig.nodeUseLineStyle?` L ${A.left},${O} L ${A.left+A.width},${O}`:"",P=`M ${I},${g+x} L ${I},${g+x>O?O+A.height:O}`+q;this.setLineStyle(r,t[C],P,A)}),y=Math.min(y,m),b=Math.max(b,m);let S=this.lineDraw.path();if(e.style.line(S),S.plot(this.transformPath(`M ${m},${g} L ${m},${g+x}`)),e._lines.push(S),r&&r(S,e),c>0){let A=this.lineDraw.path();e.style.line(A),A.plot(this.transformPath(`M ${y},${g+x} L ${b},${g+x}`)),e._lines.push(A),r&&r(A,e)}}else{let m=s+o,g=-1/0,x=e.left+e.width*.3;if(e.children.forEach((y,b)=>{let S=y.top+y.height/2;S>g&&(g=S);let A="",C=y.left,I=y.left+y.widthx&&(O=!0,S=y.top,g=S),S>s&&S0){let y=this.lineDraw.path();l=c>0?l:0,e.style.line(y),g{let{top:r,bottom:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"h"),l=s+a,h=r,d=s+a,c=n,f=l+20,m=h+(c-h)/2,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.left=s+o,t.generalizationNode.top=r+(n-r-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){e.size(r,t).x(0).y(n)}},Iv=xp});var yp,Rv,Dv=T(()=>{Ar();pe();yp=class extends Mt{constructor(e={}){super(e)}doLayout(e){Zt([()=>{this.computedBaseValue()},()=>{this.computedLeftValue()},()=>{this.adjustLeftValue()},()=>{e(this.root)}])}computedBaseValue(){de(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):o.top=t._node.top+t._node.height+this.getMarginX(n),!e.data.expand)return!0},(e,t,r,n)=>{let s=e.data.expand===!1?0:e._node.children.length;e._node.childrenAreaWidth=s?e._node.children.reduce((o,l)=>o+l.width,0)+(s+1)*this.getMarginY(n+1):0;let a=e._node.checkHasGeneralization()?e._node._generalizationNodeWidth+this.getMarginY(n+1):0;e._node.childrenAreaWidth2=Math.max(e._node.childrenAreaWidth,a)},!0,0)}computedLeftValue(){de(this.root,null,(e,t,r,n)=>{if(e.getData("expand")&&e.children&&e.children.length){let s=this.getMarginY(n+1),o=e.left+e.width/2-e.childrenAreaWidth/2+s;e.children.forEach(l=>{l.left=o,o+=l.width+s})}},null,!0)}adjustLeftValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s=e.childrenAreaWidth2-this.getMarginY(n+1)*2-e.width;s>0&&this.updateBrothers(e,s/2)},null,!0)}updateBrothers(e,t){if(e.parent){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;an&&(o=t),s.left+=o,s.children&&s.children.length&&this.updateChildren(s.children,"left",o)}),this.updateBrothers(e.parent,t)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let{nodeUseLineStyle:c,rootLineStartPositionKeepSameInCurve:f,rootLineKeepSameInCurve:m}=this.mindMap.themeConfig;e.children.forEach((g,x)=>{e.layerIndex===0&&(l=0);let y=n+a/2,b=e.layerIndex===0&&!f?s+o/2:s+o+l,S=g.left+g.width/2,A=g.top,C="",I=c?` L ${g.left},${A} L ${g.left+g.width},${A}`:"";e.isRoot&&!m?C=this.quadraticCurvePath(y,b,S,A,!0)+I:C=this.cubicBezierPath(y,b,S,A,!0)+I,this.setLineStyle(r,t[x],C,g)})}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o}=e,{nodeUseLineStyle:l}=this.mindMap.themeConfig,h=n+a/2,d=s+o;e.children.forEach((c,f)=>{let m=c.left+c.width/2,g=c.top,x=l?` L ${c.left},${g} L ${c.left+c.width},${g}`:"",y=`M ${h},${d} L ${m},${g}`+x;this.setLineStyle(r,t[f],y,c)})}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l,isRoot:h}=e,{alwaysShowExpandBtn:d,notShowExpandBtn:c}=this.mindMap.opt;(!d||c)&&(l=0);let f=n+a/2,m=s+o,x=this.getMarginX(e.layerIndex+1)*.7,y=1/0,b=-1/0,S=e.children.length;e.children.forEach((C,I)=>{let O=C.left+C.width/2,q=m+x>C.top?C.top+C.height:C.top;Ob&&(b=O);let P=this.mindMap.themeConfig.nodeUseLineStyle?` L ${C.left},${q} L ${C.left+C.width},${q}`:"",W=`M ${O},${m+x} L ${O},${q}`+P;this.setLineStyle(r,t[I],W,C)}),y=Math.min(f,y),b=Math.max(f,b);let A=this.lineDraw.path();if(e.style.line(A),l=S>0&&!h?l:0,A.plot(this.transformPath(`M ${f},${m+l} L ${f},${m+x}`)),e._lines.push(A),r&&r(A,e),S>0){let C=this.lineDraw.path();e.style.line(C),C.plot(this.transformPath(`M ${y},${m+x} L ${b},${m+x}`)),e._lines.push(C),r&&r(C,e)}}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s}=e,{translateX:a,translateY:o}=t.transform();t.translate(r/2-s/2-a,n+s/2-o)}renderGeneralization(e){e.forEach(t=>{let{bottom:r,left:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"v"),l=n,h=r+a,d=s,c=r+a,f=l+(d-l)/2,m=h+20,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.top=r+o,t.generalizationNode.left=n+(s-n-t.generalizationNode.width)/2})}renderExpandBtnRect(e,t,r,n,s){e.size(r,t).x(0).y(n)}},Rv=yp});var vp,bp,Ov=T(()=>{Ar();pe();$e();vp=class extends Mt{constructor(e={},t){super(e),this.layout=t}doLayout(e){Zt([()=>{this.computedBaseValue()},()=>{this.computedLeftTopValue()},()=>{this.adjustLeftTopValue()},()=>{e(this.root)}])}computedBaseValue(){de(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):(this.layout===k.LAYOUT.TIMELINE2?t._node.dir?o.dir=t._node.dir:o.dir=s%2===0?k.LAYOUT_GROW_DIR.BOTTOM:k.LAYOUT_GROW_DIR.TOP:o.dir="",t._node.isRoot&&(o.top=t._node.top+(e._node.height>t._node.height?-(e._node.height-t._node.height)/2:(t._node.height-e._node.height)/2))),!e.data.expand)return!0},null,!0,0)}computedLeftTopValue(){de(this.root,null,(e,t,r,n,s)=>{if(e.getData("expand")&&e.children&&e.children.length){let a=this.getMarginX(n+1),o=this.getMarginY(n+1);if(r){let h=e.left+e.width+a;e.children.forEach(d=>{d.left=h,h+=d.width+a})}else{let l=e.top+e.height+o+(this.getNodeActChildrenLength(e)>0?e.expandBtnSize:0);e.children.forEach(h=>{h.left=e.left+e.width*.5,h.top=l,l+=h.height+o+(this.getNodeActChildrenLength(h)>0?h.expandBtnSize:0)})}}},null,!0)}adjustLeftTopValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;e.isRoot&&this.updateBrothersLeft(e);let s=e.children.length;if(t&&!t.isRoot&&s>0){let a=this.getMarginY(n+1),o=e.children.reduce((l,h)=>l+h.height+(this.getNodeActChildrenLength(h)>0?h.expandBtnSize:0),0)+s*a;this.updateBrothersTop(e,o)}},(e,t,r,n)=>{t&&t.isRoot&&e.dir===k.LAYOUT_GROW_DIR.TOP&&e.children.forEach(s=>{let a=this.getNodeAreaHeight(s),o=s.top;s.top=e.top-(s.top-e.top)-a+e.height,this.updateChildren(s.children,"top",s.top-o)})},!0)}getNodeAreaHeight(e){let t=0,r=n=>{t+=n.height+(this.getNodeActChildrenLength(n)>0?n.expandBtnSize:0)+this.getMarginY(n.layerIndex),n.children.length&&n.children.forEach(s=>{r(s)})};return r(e),t}updateBrothersLeft(e){let t=e.children,r=0;t.forEach(n=>{n.left+=r,n.children&&n.children.length&&this.updateChildren(n.children,"left",r);let{left:s,right:a}=this.getNodeBoundaries(n,"h"),l=a-s-n.width;l>0&&(r+=l)})}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothersTop(e.parent,t)}}renderLine(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0);let c=e.children.length;if(e.isRoot){let f=e;e.children.forEach((m,g)=>{let x=f.left+f.width,y=m.left,b=e.top+e.height/2,S=`M ${x},${b} L ${y},${b}`;this.setLineStyle(r,t[g],S,m),f=m})}else{let f=-1/0,m=1/0,g=e.left+e.width*.3;if(e.children.forEach((x,y)=>{let b=x.top+x.height/2;b>f&&(f=b),b0){let x=this.lineDraw.path();l=c>0?l:0,e.parent&&e.parent.isRoot&&e.dir===k.LAYOUT_GROW_DIR.TOP?x.plot(this.transformPath(`M ${g},${s} L ${g},${m}`)):x.plot(this.transformPath(`M ${g},${s+o+l} L ${g},${f}`)),e.style.line(x),e._lines.push(x),r&&r(x,e)}}}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,isRoot:a}=e;if(!a){let{translateX:o,translateY:l}=t.transform();e.parent&&e.parent.isRoot&&e.dir===k.LAYOUT_GROW_DIR.TOP?t.translate(r*.3-s/2-o,-s/2-l):t.translate(r*.3-s/2-o,n+s/2-l)}}renderGeneralization(e){e.forEach(t=>{let{top:r,bottom:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"h"),l=s+a,h=r,d=s+a,c=n,f=l+20,m=h+(c-h)/2,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.left=s+o,t.generalizationNode.top=r+(n-r-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){if(this.layout===k.LAYOUT.TIMELINE)e.size(r,t).x(0).y(n);else{let a="";s.dir===k.LAYOUT_GROW_DIR.TOP?a=s.layerIndex===1?k.LAYOUT_GROW_DIR.TOP:k.LAYOUT_GROW_DIR.BOTTOM:a=k.LAYOUT_GROW_DIR.BOTTOM,a===k.LAYOUT_GROW_DIR.TOP?e.size(r,t).x(0).y(-t):e.size(r,t).x(0).y(n)}}},bp=vp});var wp,Mc,Bv=T(()=>{Ar();pe();$e();wp=class extends Mt{constructor(e={},t){super(e),this.layout=t}doLayout(e){Zt([()=>{this.computedBaseValue()},()=>{this.computedTopValue()},()=>{this.adjustLeftTopValue()},()=>{e(this.root)}])}computedBaseValue(){de(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{let o=this.createNode(e,t,r,n,s,a);if(r?this.setNodeCenter(o):(t._node.dir?o.dir=t._node.dir:this.layout===k.LAYOUT.VERTICAL_TIMELINE2?o.dir=k.LAYOUT_GROW_DIR.LEFT:this.layout===k.LAYOUT.VERTICAL_TIMELINE3?o.dir=k.LAYOUT_GROW_DIR.RIGHT:o.dir=s%2===0?k.LAYOUT_GROW_DIR.RIGHT:k.LAYOUT_GROW_DIR.LEFT,t._node.isRoot?o.left=t._node.left+(e._node.width>t._node.width?-(e._node.width-t._node.width)/2:(t._node.width-e._node.width)/2):o.left=o.dir===k.LAYOUT_GROW_DIR.RIGHT?t._node.left+t._node.width+this.getMarginX(n):t._node.left-this.getMarginX(n)-o.width),!e.data.expand)return!0},(e,t,r,n)=>{if(r)return;let s=e.data.expand===!1?0:e._node.children.length;e._node.childrenAreaHeight=s?e._node.children.reduce((a,o)=>a+o.height,0)+(s+1)*this.getMarginY(n+1):0},!0,0)}computedTopValue(){de(this.root,null,(e,t,r,n,s)=>{if(e.getData("expand")&&e.children&&e.children.length){let a=this.getMarginY(n+1);if(r){let l=e.top+e.height+a;e.children.forEach(h=>{h.top=l,l+=h.height+a})}else{let o=this.getMarginY(n+1),h=e.top+e.height/2+o-e.childrenAreaHeight/2;e.children.forEach(d=>{d.top=h,h+=d.height+o})}}},null,!0)}adjustLeftTopValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand")||r)return;let s=this.getMarginY(n+1)*2+e.height,a=e.childrenAreaHeight-s;a>0&&this.updateBrothers(e,a/2)},null,!0)}updateBrothers(e,t){if(e.parent){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition()||!e.parent.isRoot&&s.uid===e.uid)return;let o=0;e.parent.isRoot?an?o=t*2:o=t:an&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothers(e.parent,t)}}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.updateBrothersTop(e.parent,t)}}renderLine(e,t,r,n){n==="curve"?this.renderLineCurve(e,t,r):n==="direct"?this.renderLineDirect(e,t,r):this.renderLineStraight(e,t,r)}renderLineStraight(e,t,r){if(e.children.length<=0)return[];let{expandBtnSize:n}=e,{alwaysShowExpandBtn:s,notShowExpandBtn:a}=this.mindMap.opt;if((!s||a)&&(n=0),e.isRoot){let o=e;e.children.forEach((l,h)=>{let d=o.top+o.height,c=l.top,f=e.left+e.width/2,m=`M ${f},${d} L ${f},${c}`;this.setLineStyle(r,t[h],m,l),o=l})}else if(e.dir===k.LAYOUT_GROW_DIR.RIGHT){let o=e.left+e.width,l=e.top+e.height/2,d=(this.getMarginX(e.layerIndex+1)-n)*.6;e.children.forEach((c,f)=>{let m=c.left,g=c.top+c.height/2,x=this.createFoldLine([[o,l],[o+d,l],[o+d,g],[m,g]]);this.setLineStyle(r,t[f],x,c)})}else{let o=e.left,l=e.top+e.height/2,d=(this.getMarginX(e.layerIndex+1)-n)*.6;e.children.forEach((c,f)=>{let m=c.left+c.width,g=c.top+c.height/2,x=this.createFoldLine([[o,l],[o-d,l],[o-d,g],[m,g]]);this.setLineStyle(r,t[f],x,c)})}}renderLineDirect(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0),e.children.forEach((c,f)=>{if(e.isRoot){let m=e;e.children.forEach((g,x)=>{let y=m.top+m.height,b=g.top,S=e.left+e.width/2,A=`M ${S},${y} L ${S},${b}`;this.setLineStyle(r,t[x],A,g),m=g})}else{let m=c.dir===k.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,g=s+o/2,x=c.dir===k.LAYOUT_GROW_DIR.LEFT?c.left+c.width:c.left,y=c.top+c.height/2,b=`M ${m},${g} L ${x},${y}`;this.setLineStyle(r,t[f],b,c)}})}renderLineCurve(e,t,r){if(e.children.length<=0)return[];let{left:n,top:s,width:a,height:o,expandBtnSize:l}=e,{alwaysShowExpandBtn:h,notShowExpandBtn:d}=this.mindMap.opt;(!h||d)&&(l=0),e.children.forEach((c,f)=>{if(e.isRoot){let m=e;e.children.forEach((g,x)=>{let y=m.top+m.height,b=g.top,S=e.left+e.width/2,A=`M ${S},${y} L ${S},${b}`;this.setLineStyle(r,t[x],A,g),m=g})}else{let m=c.dir===k.LAYOUT_GROW_DIR.LEFT?n-l:n+a+l,g=s+o/2,x=c.dir===k.LAYOUT_GROW_DIR.LEFT?c.left+c.width:c.left,y=c.top+c.height/2,b=this.cubicBezierPath(m,g,x,y);this.setLineStyle(r,t[f],b,c)}})}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,isRoot:a}=e;if(!a){let{translateX:o,translateY:l}=t.transform();e.dir===k.LAYOUT_GROW_DIR.RIGHT?t.translate(r-o,n/2-l):t.translate(-s-o,n/2-l)}}renderGeneralization(e){e.forEach(t=>{let r=t.node.dir===k.LAYOUT_GROW_DIR.LEFT,{top:n,bottom:s,left:a,right:o,generalizationLineMargin:l,generalizationNodeMargin:h}=this.getNodeGeneralizationRenderBoundaries(t,"h"),d=r?a-l:o+l,c=d,f=n,m=d,g=s,x=c+(r?-20:20),y=f+(g-f)/2,b=`M ${c},${f} Q ${x},${y} ${m},${g}`;t.generalizationLine.plot(this.transformPath(b)),t.generalizationNode.left=d+(r?-h:h)-(r?t.generalizationNode.width:0),t.generalizationNode.top=n+(s-n-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){s.dir===k.LAYOUT_GROW_DIR.LEFT?e.size(t,n).x(-t).y(0):e.size(t,n).x(r).y(0)}},Mc=wp});var er,Pv=T(()=>{pe();er={top:{renderExpandBtn({node:i,btn:e,expandBtnSize:t,translateX:r,translateY:n,width:s,height:a}){i.parent&&i.parent.isRoot?e.translate(s*.3-t/2-r,-t/2-n):e.translate(s*.3-t/2-r,a+t/2-n)},renderLine({node:i,line:e,top:t,x:r,lineLength:n,height:s,expandBtnSize:a,maxy:o,ctx:l}){i.parent&&i.parent.isRoot?e.plot(l.transformPath(`M ${r},${t} L ${r+n},${t-Math.tan(fn(l.mindMap.opt.fishboneDeg))*n}`)):e.plot(l.transformPath(`M ${r},${t+s+a} L ${r},${o}`))},computedLeftTopValue({layerIndex:i,node:e,ctx:t}){if(i>=1&&e.children){let r=t.getMarginY(i+1),n=e.left+e.width*t.childIndent,s=e.top+e.height+(t.getNodeActChildrenLength(e)>0?e.expandBtnSize:0)+r;e.children.forEach(a=>{a.left=n,a.top+=s,s+=a.height+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0)+r})}},adjustLeftTopValueBefore({node:i,parent:e,ctx:t,layerIndex:r}){let n=i.children.length,s=t.getMarginY(r+1);if(e&&!e.isRoot&&n>0){let a=i.children.reduce((o,l)=>o+l.height+(t.getNodeActChildrenLength(l)>0?l.expandBtnSize:0)+s,0);t.updateBrothersTop(i,a)}},adjustLeftTopValueAfter({parent:i,node:e,ctx:t}){if(i&&i.isRoot){let r=t.getMarginY(e.layerIndex+1),n=e.expandBtnSize+r;e.children.forEach(s=>{let a=t.getNodeAreaHeight(s),o=s.top,l=s.left;s.top=e.top-(s.top-e.top)-a+e.height,s.left=e.left+e.width*t.indent+(a+n)/Math.tan(fn(t.mindMap.opt.fishboneDeg)),n+=a,t.updateChildrenPro(s.children,{top:s.top-o,left:s.left-l})})}}},bottom:{renderExpandBtn({node:i,btn:e,expandBtnSize:t,translateX:r,translateY:n,width:s,height:a}){i.parent&&i.parent.isRoot?e.translate(s*.3-t/2-r,a+t/2-n):e.translate(s*.3-t/2-r,-t/2-n)},renderLine({node:i,line:e,top:t,x:r,lineLength:n,height:s,miny:a,ctx:o}){i.parent&&i.parent.isRoot?e.plot(o.transformPath(`M ${r},${t+s} L ${r+n},${t+s+Math.tan(fn(o.mindMap.opt.fishboneDeg))*n}`)):e.plot(o.transformPath(`M ${r},${t} L ${r},${a}`))},computedLeftTopValue({layerIndex:i,node:e,ctx:t}){let r=t.getMarginY(i+1);if(i===1&&e.children){let n=e.left+e.width*t.childIndent,s=e.top+e.height+(t.getNodeActChildrenLength(e)>0?e.expandBtnSize:0)+r;e.children.forEach(a=>{a.left=n,a.top=s+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0),s+=a.height+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0)+r})}if(i>1&&e.children){let n=e.left+e.width*t.childIndent,s=e.top-(t.getNodeActChildrenLength(e)>0?e.expandBtnSize:0)-r;e.children.forEach(a=>{a.left=n,a.top=s-a.height,s-=a.height+(t.getNodeActChildrenLength(a)>0?a.expandBtnSize:0)+r})}},adjustLeftTopValueBefore({node:i,ctx:e,layerIndex:t}){let r=e.getMarginY(t+1),n=i.children.length;if(t>2&&n>0){let s=i.children.reduce((a,o)=>a+o.height+(e.getNodeActChildrenLength(o)>0?o.expandBtnSize:0)+r,0);e.updateBrothersTop(i,-s)}},adjustLeftTopValueAfter({parent:i,node:e,ctx:t}){if(i&&i.isRoot){let r=t.getMarginY(e.layerIndex+1),n=0,s=e.expandBtnSize;e.children.forEach(a=>{let o=t.getNodeActChildrenLength(a)>0,l=t.getNodeAreaHeight(a),h=o?l-a.height-(o?a.expandBtnSize:0):0;h-=o?r:0;let d=n+h,c=a.left;a.top+=d,a.left=e.left+e.width*t.indent+(l+s)/Math.tan(fn(t.mindMap.opt.fishboneDeg)),n+=h,s+=l,t.updateChildrenPro(a.children,{top:d,left:a.left-c})})}}}}});var Mp,Tp,Fv=T(()=>{Ar();pe();$e();Pv();yt();Y0();Mp=class extends Mt{constructor(e={},t){super(e),this.layout=t,this.indent=.3,this.childIndent=.5,this.fishTail=null,this.maxx=0,this.headRatio=1,this.tailRatio=.6,this.paddingXRatio=.3,this.fishHeadPathStr="M4,181 C4,181, 0,177, 4,173 Q 96.09523809523809,0, 288.2857142857143,0 L 288.2857142857143,354 Q 48.047619047619044,354, 8,218.18367346938777 C8,218.18367346938777, 6,214.18367346938777, 8,214.18367346938777 L 41.183673469387756,214.18367346938777 Z",this.fishTailPathStr="M 606.9342905223708 0 Q 713.1342905223709 -177 819.3342905223708 -177 L 766.2342905223709 0 L 819.3342905223708 177 Q 713.1342905223709 177 606.9342905223708 0 z",this.bindEvent(),this.extendShape(),this.beforeChange=this.beforeChange.bind(this)}nodeIsRemoveAllLines(e){return e.isRoot||e.layerIndex===1}isFishbone2(){return this.layout===k.LAYOUT.FISHBONE2}bindEvent(){this.isFishbone2()&&(this.onCheckUpdateFishTail=this.onCheckUpdateFishTail.bind(this),this.mindMap.on("afterExecCommand",this.onCheckUpdateFishTail))}unBindEvent(){this.mindMap.off("afterExecCommand",this.onCheckUpdateFishTail)}extendShape(){this.isFishbone2()&&this.mindMap.addShape({name:"fishHead",createShape:e=>{let t=Ae(``),{width:r,height:n}=e.shapeInstance.getNodeSize();return t.size(r,n),t},getPadding:({width:e,height:t,paddingX:r,paddingY:n})=>{e+=r*2,t+=n*2;let s=this.paddingXRatio*e,a=0;return e+=s*2,a=(e/this.headRatio-t)/2,{paddingX:s,paddingY:a}}})}doLayout(e){Zt([()=>{this.computedBaseValue(),this.addFishTail()},()=>{this.computedLeftTopValue()},()=>{this.adjustLeftTopValue(),this.updateFishTailPosition()},()=>{e(this.root)}])}addFishTail(){if(!this.isFishbone2())return;let e=this.mindMap.lineDraw.findOne(".smm-layout-fishbone-tail");e?this.fishTail=e:(this.fishTail=Ae(``),this.fishTail.addClass("smm-layout-fishbone-tail"));let t=this.root.height,r=t*this.tailRatio;this.fishTail.size(r,t),this.styleFishTail(),this.mindMap.lineDraw.add(this.fishTail)}onCheckUpdateFishTail(e,t,r){if(e==="SET_NODE_DATA"){let n=!1;Object.keys(r).forEach(s=>{Mu.includes(s)&&(n=!0)}),n&&this.styleFishTail()}}styleFishTail(){this.root.style.shape(this.fishTail)}removeFishTail(){let e=this.mindMap.lineDraw.findOne(".smm-layout-fishbone-tail");e&&e.remove()}updateFishTailPosition(){this.isFishbone2()&&this.fishTail.x(this.maxx).cy(this.root.top+this.root.height/2)}computedBaseValue(){de(this.renderer.renderTree,null,(e,t,r,n,s,a)=>{r&&this.isFishbone2()&&(e.data.shape="fishHead");let o=this.createNode(e,t,r,n,s,a);if(r)this.setNodeCenter(o);else if(t._node.dir?o.dir=t._node.dir:o.dir=s%2===0?k.LAYOUT_GROW_DIR.TOP:k.LAYOUT_GROW_DIR.BOTTOM,t._node.isRoot){let l=this.getMarginY(n),h=this.isFishbone2()?t._node.height/4:0;this.checkIsTop(o)?o.top=t._node.top-o.height-l+h:o.top=t._node.top+t._node.height+l-h}if(!e.data.expand)return!0},null,!0,0)}computedLeftTopValue(){de(this.root,null,(e,t,r,n)=>{if(e.isRoot){let a=this.getMarginX(n+1),o=this.isFishbone2()?2:1,l=e.left+e.width+e.height/o+a,h=e.left+e.width+e.height/o+a;e.children.forEach(d=>{this.checkIsTop(d)?(d.left=l,l+=d.width+a):(d.left=h+20,h+=d.width+a)})}let s={layerIndex:n,node:e,ctx:this};this.checkIsTop(e)?er.top.computedLeftTopValue(s):er.bottom.computedLeftTopValue(s)},null,!0)}adjustLeftTopValue(){de(this.root,null,(e,t,r,n)=>{if(!e.getData("expand"))return;let s={node:e,parent:t,layerIndex:n,ctx:this};this.checkIsTop(e)?er.top.adjustLeftTopValueBefore(s):er.bottom.adjustLeftTopValueBefore(s)},(e,t)=>{let r={parent:t,node:e,ctx:this};if(this.checkIsTop(e)?er.top.adjustLeftTopValueAfter(r):er.bottom.adjustLeftTopValueAfter(r),e.isRoot){let n=0,s=0,a=-1/0;e.children.forEach(o=>{if(this.checkIsTop(o)){o.left+=n,this.updateChildren(o.children,"left",n);let{left:l,right:h}=this.getNodeBoundaries(o,"h");h>a&&(a=h),n+=h-l}else{o.left+=s,this.updateChildren(o.children,"left",s);let{left:l,right:h}=this.getNodeBoundaries(o,"h");h>a&&(a=h),s+=h-l}}),this.maxx=a}},!0)}getNodeAreaHeight(e){let t=0,r=n=>{let s=this.getMarginY(n.layerIndex);t+=n.height+(this.getNodeActChildrenLength(n)>0?n.expandBtnSize:0)+s,n.children.length&&n.children.forEach(a=>{r(a)})};return r(e),t}updateBrothersLeft(e){let t=e.children,r=0;t.forEach(n=>{n.left+=r,n.children&&n.children.length&&this.updateChildren(n.children,"left",r);let{left:s,right:a}=this.getNodeBoundaries(n,"h"),l=a-s-n.width;l>0&&(r+=l)})}updateBrothersTop(e,t){if(e.parent&&!e.parent.isRoot){let r=e.parent.children,n=Ie(e,r);r.forEach((s,a)=>{if(s.hasCustomPosition())return;let o=0;a>n&&(o=t),s.top+=o,s.children&&s.children.length&&this.updateChildren(s.children,"top",o)}),this.checkIsTop(e)?this.updateBrothersTop(e.parent,t):this.updateBrothersTop(e.parent,e.layerIndex===3?0:t)}}checkIsTop(e){return e.dir===k.LAYOUT_GROW_DIR.TOP}renderLine(e,t,r){if(e.layerIndex!==1&&e.children.length<=0)return[];let{top:n,height:s,expandBtnSize:a}=e,{alwaysShowExpandBtn:o,notShowExpandBtn:l}=this.mindMap.opt;(!o||l)&&(a=0);let h=e.children.length;if(e.isRoot){let d=-1/0;e.children.forEach(x=>{x.left>d&&(d=x.left);let y=this.getMarginY(x.layerIndex),b=x.left,S=e.height/2+y-(this.isFishbone2()?e.height/4:0),A=S/Math.tan(fn(this.mindMap.opt.fishboneDeg)),C=this.lineDraw.path();this.checkIsTop(x)?C.plot(this.transformPath(`M ${b-A},${x.top+x.height+S} L ${x.left},${x.top+x.height}`)):C.plot(this.transformPath(`M ${b-A},${x.top-S} L ${b},${x.top}`)),e.style.line(C),e._lines.push(C),r&&r(C,e)});let c=e.top+e.height/2,f=e.height/2+this.getMarginY(e.layerIndex+1),m=this.lineDraw.path(),g=this.isFishbone2()?this.maxx:d-f/Math.tan(fn(this.mindMap.opt.fishboneDeg));m.plot(this.transformPath(`M ${e.left+e.width},${c} L ${g},${c}`)),e.style.line(m),e._lines.push(m),r&&r(m,e)}else{let d=-1/0,c=1/0,f=-1/0,m=e.left+e.width*this.indent;if(e.children.forEach((g,x)=>{g.left>f&&(f=g.left);let y=g.top+g.height/2;if(y>d&&(d=y),y1){let b=`M ${m},${y} L ${g.left},${y}`;this.setLineStyle(r,t[x],b,g)}}),h>=0){let g=this.lineDraw.path();a=h>0?a:0;let x=f-e.left-e.width*this.indent;x=Math.max(x,0);let y={node:e,line:g,top:n,x:m,lineLength:x,height:s,expandBtnSize:a,maxy:d,miny:c,ctx:this};this.checkIsTop(e)?er.top.renderLine(y):er.bottom.renderLine(y),e.style.line(g),e._lines.push(g),r&&r(g,e)}}}renderExpandBtn(e,t){let{width:r,height:n,expandBtnSize:s,isRoot:a}=e;if(!a){let{translateX:o,translateY:l}=t.transform(),h={node:e,btn:t,expandBtnSize:s,translateX:o,translateY:l,width:r,height:n};this.checkIsTop(e)?er.top.renderExpandBtn(h):er.bottom.renderExpandBtn(h)}}renderGeneralization(e){e.forEach(t=>{let{top:r,bottom:n,right:s,generalizationLineMargin:a,generalizationNodeMargin:o}=this.getNodeGeneralizationRenderBoundaries(t,"h"),l=s+a,h=r,d=s+a,c=n,f=l+20,m=h+(c-h)/2,g=`M ${l},${h} Q ${f},${m} ${d},${c}`;t.generalizationLine.plot(this.transformPath(g)),t.generalizationNode.left=s+o,t.generalizationNode.top=r+(n-r-t.generalizationNode.height)/2})}renderExpandBtnRect(e,t,r,n,s){let a="";s.dir===k.LAYOUT_GROW_DIR.TOP?a=s.layerIndex===1?k.LAYOUT_GROW_DIR.TOP:k.LAYOUT_GROW_DIR.BOTTOM:a=s.layerIndex===1?k.LAYOUT_GROW_DIR.BOTTOM:k.LAYOUT_GROW_DIR.TOP,a===k.LAYOUT_GROW_DIR.TOP?e.size(r,t).x(0).y(-t):e.size(r,t).x(0).y(n)}beforeChange(){this.isFishbone2()&&(this.root.nodeData.data.shape=k.SHAPE.RECTANGLE,this.removeFishTail(),this.unBindEvent(),this.mindMap.removeShape("fishHead"))}},Tp=Mp});var qv,l0,Hv=T(()=>{pe();$e();qv="smm-node-edit-wrap",l0=class{constructor(e){this.renderer=e,this.mindMap=e.mindMap,this.currentNode=null,this.textEditNode=null,this.showTextEdit=!1,this.cacheEditingText="",this.hasBodyMousedown=!1,this.textNodePaddingX=5,this.textNodePaddingY=3,this.isNeedUpdateTextEditNode=!1,this.mindMap.addEditNodeClass(qv),this.bindEvent()}bindEvent(){this.show=this.show.bind(this),this.onScale=this.onScale.bind(this),this.onKeydown=this.onKeydown.bind(this),this.mindMap.on("node_dblclick",(e,t,r)=>{this.show({node:e,e:t,isInserting:r})}),this.mindMap.on("draw_click",()=>{this.hideEditTextBox()}),this.mindMap.on("body_mousedown",()=>{this.hasBodyMousedown=!0}),this.mindMap.on("body_click",()=>{this.hasBodyMousedown&&(this.hasBodyMousedown=!1,this.mindMap.opt.isEndNodeTextEditOnClickOuter&&this.hideEditTextBox())}),this.mindMap.on("svg_mousedown",()=>{this.hideEditTextBox()}),this.mindMap.on("expand_btn_click",()=>{this.hideEditTextBox()}),this.mindMap.on("before_node_active",()=>{this.hideEditTextBox()}),this.mindMap.on("mousewheel",()=>{this.mindMap.opt.mousewheelAction===k.MOUSE_WHEEL_ACTION.MOVE&&this.hideEditTextBox()}),this.mindMap.keyCommand.addShortcut("F2",()=>{this.renderer.activeNodeList.length<=0||this.show({node:this.renderer.activeNodeList[0]})}),this.mindMap.on("scale",this.onScale),this.mindMap.opt.enableAutoEnterTextEditWhenKeydown&&window.addEventListener("keydown",this.onKeydown),this.mindMap.on("beforeDestroy",()=>{this.unBindEvent()}),this.mindMap.on("after_update_config",(e,t)=>{e.openRealtimeRenderOnNodeTextEdit!==t.openRealtimeRenderOnNodeTextEdit&&(this.mindMap.richText?this.mindMap.richText.onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e.openRealtimeRenderOnNodeTextEdit):this.onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e.openRealtimeRenderOnNodeTextEdit)),e.enableAutoEnterTextEditWhenKeydown!==t.enableAutoEnterTextEditWhenKeydown&&window[e.enableAutoEnterTextEditWhenKeydown?"addEventListener":"removeEventListener"]("keydown",this.onKeydown)}),this.mindMap.on("afterExecCommand",()=>{this.isShowTextEdit()&&(this.isNeedUpdateTextEditNode=!0)}),this.mindMap.on("node_tree_render_end",()=>{this.isShowTextEdit()&&this.isNeedUpdateTextEditNode&&(this.isNeedUpdateTextEditNode=!1,this.updateTextEditNode())})}unBindEvent(){window.removeEventListener("keydown",this.onKeydown)}onKeydown(e){if(e.target!==document.body)return;let t=this.mindMap.renderer.activeNodeList;if(t.length<=0||t.length>1)return;let r=t[0];r&&this.checkIsAutoEnterTextEditKey(e)&&(e.preventDefault(),this.show({node:r,e,isInserting:!1,isFromKeyDown:!0}))}checkIsAutoEnterTextEditKey(e){let t=e.keyCode;return(t===229||t>=65&&t<=90||t>=48&&t<=57)&&!this.mindMap.keyCommand.hasCombinationKey(e)}registerTmpShortcut(){this.mindMap.keyCommand.addShortcut("Enter",()=>{this.hideEditTextBox()}),this.mindMap.keyCommand.addShortcut("Tab",()=>{this.hideEditTextBox()})}isShowTextEdit(){return this.mindMap.richText?this.mindMap.richText.showTextEdit:this.showTextEdit}setIsShowTextEdit(e){this.showTextEdit=e,e?this.mindMap.keyCommand.stopCheckInSvg():this.mindMap.keyCommand.recoveryCheckInSvg()}async show({node:e,isInserting:t=!1,isFromKeyDown:r=!1,isFromScale:n=!1}){if(e.isUseCustomNodeContent())return;this.getCurrentEditNode()&&this.hideEditTextBox();let{beforeTextEdit:a,openRealtimeRenderOnNodeTextEdit:o}=this.mindMap.opt;if(typeof a=="function"){let m=!1;try{m=await a(e,t)}catch(g){m=!1,this.mindMap.opt.errorHandler(Mi.BEFORE_TEXT_EDIT_ERROR,g)}if(!m)return}let{offsetLeft:l,offsetTop:h}=y2(this.mindMap,e);this.mindMap.view.translateXY(l,h);let d=e._textData.node;o&&d.show();let c=d.node.getBoundingClientRect();o&&d.hide();let f={node:e,rect:c,isInserting:t,isFromKeyDown:r,isFromScale:n};if(this.mindMap.richText){this.mindMap.richText.showEditText(f);return}this.currentNode=e,this.showEditTextBox(f)}onOpenRealtimeRenderOnNodeTextEditConfigUpdate(e){this.textEditNode&&(this.textEditNode.style.background=e?"transparent":this.currentNode?this.getBackground(this.currentNode):"",this.textEditNode.style.boxShadow=e?"none":"0 0 20px rgba(0,0,0,.5)")}onScale(){let e=this.getCurrentEditNode();e&&(this.mindMap.richText?(this.mindMap.richText.cacheEditingText=this.mindMap.richText.getEditText(),this.mindMap.richText.showTextEdit=!1):(this.cacheEditingText=this.getEditText(),this.setIsShowTextEdit(!1)),this.show({node:e,isFromScale:!0}))}showEditTextBox({node:e,rect:t,isInserting:r,isFromKeyDown:n,isFromScale:s}){if(this.showTextEdit)return;let{nodeTextEditZIndex:a,textAutoWrapWidth:o,selectTextOnEnterEditText:l,openRealtimeRenderOnNodeTextEdit:h,autoEmptyTextWhenKeydownEnterEdit:d}=this.mindMap.opt;s||this.mindMap.emit("before_show_text_edit"),this.registerTmpShortcut(),this.textEditNode||(this.textEditNode=document.createElement("div"),this.textEditNode.classList.add(qv),this.textEditNode.style.cssText=` position: fixed; box-sizing: border-box; ${h?"":"box-shadow: 0 0 20px rgba(0,0,0,.5);"} padding: ${this.textNodePaddingY}px ${this.textNodePaddingX}px; margin-left: -${this.textNodePaddingX}px; margin-top: -${this.textNodePaddingY}px; - outline: none; + outline: none; word-break: break-all; line-break: anywhere; - `,this.textEditNode.setAttribute("contenteditable",!0),this.textEditNode.addEventListener("keyup",v=>{v.stopPropagation()}),this.textEditNode.addEventListener("click",v=>{v.stopPropagation()}),this.textEditNode.addEventListener("mousedown",v=>{v.stopPropagation()}),this.textEditNode.addEventListener("keydown",v=>{this.checkIsAutoEnterTextEditKey(v)&&v.stopPropagation()}),this.textEditNode.addEventListener("paste",v=>{let b=v.clipboardData.getData("text"),{isSmm:E,data:S}=ao(b);E&&S[0]&&S[0].data?xc(v,ks(S[0].data.text)):xc(v),this.emitTextChangeEvent()}),this.textEditNode.addEventListener("input",()=>{this.emitTextChangeEvent()}),(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.textEditNode));let c=this.mindMap.view.scale,f=e.style.merge("fontSize"),m=(this.cacheEditingText||e.getData("text")).split(/\n/gim).map(x=>Wr(x)),g=e._textData.node.attr("data-ismultiLine")==="true";e.style.domText(this.textEditNode,c),h||(this.textEditNode.style.background=this.getBackground(e)),this.textEditNode.style.zIndex=a,n&&d?this.textEditNode.innerHTML="":this.textEditNode.innerHTML=m.join("
    "),this.textEditNode.style.minWidth=t.width+this.textNodePaddingX*2+"px",this.textEditNode.style.minHeight=t.height+"px",this.textEditNode.style.left=Math.floor(t.left)+"px",this.textEditNode.style.top=Math.floor(t.top)+"px",this.textEditNode.style.display="block",this.textEditNode.style.maxWidth=o*c+"px",g?(this.textEditNode.style.lineHeight=fs,this.textEditNode.style.transform=`translateY(${(fs-1)*f/2*c}px)`):this.textEditNode.style.lineHeight="normal",this.setIsShowTextEdit(!0),r||l&&!n?Ls(this.textEditNode):_s(this.textEditNode),this.cacheEditingText=""}emitTextChangeEvent(){this.mindMap.emit("node_text_edit_change",{node:this.currentNode,text:this.getEditText(),richText:!1})}updateTextEditNode(){if(this.mindMap.richText){this.mindMap.richText.updateTextEditNode();return}if(!this.showTextEdit||!this.currentNode)return;let e=this.currentNode._textData.node.node.getBoundingClientRect();this.textEditNode.style.minWidth=e.width+this.textNodePaddingX*2+"px",this.textEditNode.style.minHeight=e.height+this.textNodePaddingY*2+"px",this.textEditNode.style.left=Math.floor(e.left)+"px",this.textEditNode.style.top=Math.floor(e.top)+"px"}getBackground(e){if(e.style.merge("gradientStyle")){let r=e.style.merge("startColor"),n=e.style.merge("endColor");return`linear-gradient(to right, ${r}, ${n})`}else{let r=e.style.merge("fillColor"),n=e.style.merge("color");return r==="transparent"?no(n)?e0(this.mindMap.themeConfig):"#fff":r}}removeTextEditEl(){if(this.mindMap.richText){this.mindMap.richText.removeTextEditEl();return}if(!this.textEditNode)return;(this.mindMap.opt.customInnerElsAppendTo||document.body).removeChild(this.textEditNode)}getEditText(){return As(this.textEditNode.innerHTML)}hideEditTextBox(){if(this.mindMap.richText)return this.mindMap.richText.hideEditText();if(!this.showTextEdit)return;let e=this.currentNode,t=this.getEditText();this.currentNode=null,this.textEditNode.style.display="none",this.textEditNode.innerHTML="",this.textEditNode.style.fontFamily="inherit",this.textEditNode.style.fontSize="inherit",this.textEditNode.style.fontWeight="normal",this.textEditNode.style.transform="translateY(0)",this.setIsShowTextEdit(!1),this.mindMap.execCommand("SET_NODE_TEXT",e,t),this.mindMap.render(),this.mindMap.emit("hide_text_edit",this.textEditNode,this.renderer.activeNodeList,e)}getCurrentEditNode(){return this.mindMap.richText?this.mindMap.richText.node:this.currentNode}}});var dv,hv,Tm,cv,uv=M(()=>{dv=ot(Wl());Kx();Qx();ev();iv();rv();nv();av();lv();he();Mc();io();Oe();ht();hv={[A.LAYOUT.LOGICAL_STRUCTURE]:mm,[A.LAYOUT.LOGICAL_STRUCTURE_LEFT]:mm,[A.LAYOUT.MIND_MAP]:Zx,[A.LAYOUT.CATALOG_ORGANIZATION]:Jx,[A.LAYOUT.ORGANIZATION_STRUCTURE]:tv,[A.LAYOUT.TIMELINE]:ym,[A.LAYOUT.TIMELINE2]:ym,[A.LAYOUT.VERTICAL_TIMELINE]:Id,[A.LAYOUT.VERTICAL_TIMELINE2]:Id,[A.LAYOUT.VERTICAL_TIMELINE3]:Id,[A.LAYOUT.FISHBONE]:Mm,[A.LAYOUT.FISHBONE2]:Mm},Tm=class{constructor(e={}){this.opt=e,this.mindMap=e.mindMap,this.themeConfig=this.mindMap.themeConfig,this.renderTree=this.mindMap.opt.data?(0,dv.default)({},this.mindMap.opt.data):null,this.reRender=!1,this.isRendering=!1,this.hasWaitRendering=!1,this.nodeCache={},this.lastNodeCache={},this.renderSourceList=[],this.renderCallbackList=[],this.activeNodeList=[],this.emitNodeActiveEventTimer=null,this.renderTimer=null,this.root=null,this.textEdit=new Ll(this),this.beingCopyData=null,this.highlightBoxNode=null,this.highlightBoxNodeStyle=null,this.lastActiveNodeList=[],this.setLayout(),this.bindEvent(),this.registerCommands(),this.registerShortcutKeys()}setLayout(){this.layout&&this.layout.beforeChange&&this.layout.beforeChange();let{layout:e}=this.mindMap.opt,t=hv[e]||this.mindMap[e];t||(t=hv[A.LAYOUT.LOGICAL_STRUCTURE],this.mindMap.opt.layout=A.LAYOUT.LOGICAL_STRUCTURE),this.layout=new t(this,e)}setData(e){this.renderTree=e||null}bindEvent(){let{openPerformance:e,performanceConfig:t,openRealtimeRenderOnNodeTextEdit:r}=this.mindMap.opt;this.mindMap.on("draw_click",s=>{this.clearActiveNodeListOnDrawClick(s,"click")}),this.mindMap.on("contextmenu",s=>{this.clearActiveNodeListOnDrawClick(s,"contextmenu")}),this.mindMap.svg.on("dblclick",()=>{this.mindMap.opt.enableDblclickBackToRootNode&&this.setRootNodeCenter()});let n=mi(()=>{this.renderTree&&this.root&&(this.mindMap.emit("node_tree_render_start"),this.root.render(()=>{this.mindMap.emit("node_tree_render_end")},!1,!0))},t.time);e&&this.mindMap.on("view_data_change",n),this.onNodeTextEditChange=Op(this.onNodeTextEditChange,100,this),r&&this.mindMap.on("node_text_edit_change",this.onNodeTextEditChange),this.mindMap.on("after_update_config",(s,a)=>{s.openPerformance!==a.openPerformance&&(this.mindMap[s.openPerformance?"on":"off"]("view_data_change",n),this.forceLoadNode()),s.openRealtimeRenderOnNodeTextEdit!==a.openRealtimeRenderOnNodeTextEdit&&this.mindMap[s.openRealtimeRenderOnNodeTextEdit?"on":"off"]("node_text_edit_change",this.onNodeTextEditChange)})}onNodeTextEditChange({node:e,text:t}){e._textData=e.createTextNode(t);let{width:r,height:n}=e.getNodeRect();e.width=r,e.height=n,e.layout(),this.mindMap.render(()=>{this.textEdit.updateTextEditNode()})}forceLoadNode(e){e=e||this.root,e&&(this.mindMap.emit("node_tree_render_start"),e.render(()=>{this.mindMap.emit("node_tree_render_end")},!0))}registerCommands(){this.selectAll=this.selectAll.bind(this),this.mindMap.command.add("SELECT_ALL",this.selectAll),this.back=this.back.bind(this),this.mindMap.command.add("BACK",this.back),this.forward=this.forward.bind(this),this.mindMap.command.add("FORWARD",this.forward),this.insertNode=this.insertNode.bind(this),this.mindMap.command.add("INSERT_NODE",this.insertNode),this.insertMultiNode=this.insertMultiNode.bind(this),this.mindMap.command.add("INSERT_MULTI_NODE",this.insertMultiNode),this.insertChildNode=this.insertChildNode.bind(this),this.mindMap.command.add("INSERT_CHILD_NODE",this.insertChildNode),this.insertMultiChildNode=this.insertMultiChildNode.bind(this),this.mindMap.command.add("INSERT_MULTI_CHILD_NODE",this.insertMultiChildNode),this.insertParentNode=this.insertParentNode.bind(this),this.mindMap.command.add("INSERT_PARENT_NODE",this.insertParentNode),this.upNode=this.upNode.bind(this),this.mindMap.command.add("UP_NODE",this.upNode),this.downNode=this.downNode.bind(this),this.mindMap.command.add("DOWN_NODE",this.downNode),this.moveUpOneLevel=this.moveUpOneLevel.bind(this),this.mindMap.command.add("MOVE_UP_ONE_LEVEL",this.moveUpOneLevel),this.insertAfter=this.insertAfter.bind(this),this.mindMap.command.add("INSERT_AFTER",this.insertAfter),this.insertBefore=this.insertBefore.bind(this),this.mindMap.command.add("INSERT_BEFORE",this.insertBefore),this.moveNodeTo=this.moveNodeTo.bind(this),this.mindMap.command.add("MOVE_NODE_TO",this.moveNodeTo),this.removeNode=this.removeNode.bind(this),this.mindMap.command.add("REMOVE_NODE",this.removeNode),this.removeCurrentNode=this.removeCurrentNode.bind(this),this.mindMap.command.add("REMOVE_CURRENT_NODE",this.removeCurrentNode),this.pasteNode=this.pasteNode.bind(this),this.mindMap.command.add("PASTE_NODE",this.pasteNode),this.cutNode=this.cutNode.bind(this),this.mindMap.command.add("CUT_NODE",this.cutNode),this.setNodeStyle=this.setNodeStyle.bind(this),this.mindMap.command.add("SET_NODE_STYLE",this.setNodeStyle),this.setNodeStyles=this.setNodeStyles.bind(this),this.mindMap.command.add("SET_NODE_STYLES",this.setNodeStyles),this.setNodeActive=this.setNodeActive.bind(this),this.mindMap.command.add("SET_NODE_ACTIVE",this.setNodeActive),this.clearActiveNode=this.clearActiveNode.bind(this),this.mindMap.command.add("CLEAR_ACTIVE_NODE",this.clearActiveNode),this.setNodeExpand=this.setNodeExpand.bind(this),this.mindMap.command.add("SET_NODE_EXPAND",this.setNodeExpand),this.expandAllNode=this.expandAllNode.bind(this),this.mindMap.command.add("EXPAND_ALL",this.expandAllNode),this.unexpandAllNode=this.unexpandAllNode.bind(this),this.mindMap.command.add("UNEXPAND_ALL",this.unexpandAllNode),this.expandToLevel=this.expandToLevel.bind(this),this.mindMap.command.add("UNEXPAND_TO_LEVEL",this.expandToLevel),this.setNodeData=this.setNodeData.bind(this),this.mindMap.command.add("SET_NODE_DATA",this.setNodeData),this.setNodeText=this.setNodeText.bind(this),this.mindMap.command.add("SET_NODE_TEXT",this.setNodeText),this.setNodeImage=this.setNodeImage.bind(this),this.mindMap.command.add("SET_NODE_IMAGE",this.setNodeImage),this.setNodeIcon=this.setNodeIcon.bind(this),this.mindMap.command.add("SET_NODE_ICON",this.setNodeIcon),this.setNodeHyperlink=this.setNodeHyperlink.bind(this),this.mindMap.command.add("SET_NODE_HYPERLINK",this.setNodeHyperlink),this.setNodeNote=this.setNodeNote.bind(this),this.mindMap.command.add("SET_NODE_NOTE",this.setNodeNote),this.setNodeAttachment=this.setNodeAttachment.bind(this),this.mindMap.command.add("SET_NODE_ATTACHMENT",this.setNodeAttachment),this.setNodeTag=this.setNodeTag.bind(this),this.mindMap.command.add("SET_NODE_TAG",this.setNodeTag),this.insertFormula=this.insertFormula.bind(this),this.mindMap.command.add("INSERT_FORMULA",this.insertFormula),this.addGeneralization=this.addGeneralization.bind(this),this.mindMap.command.add("ADD_GENERALIZATION",this.addGeneralization),this.removeGeneralization=this.removeGeneralization.bind(this),this.mindMap.command.add("REMOVE_GENERALIZATION",this.removeGeneralization),this.setNodeCustomPosition=this.setNodeCustomPosition.bind(this),this.mindMap.command.add("SET_NODE_CUSTOM_POSITION",this.setNodeCustomPosition),this.resetLayout=this.resetLayout.bind(this),this.mindMap.command.add("RESET_LAYOUT",this.resetLayout),this.setNodeShape=this.setNodeShape.bind(this),this.mindMap.command.add("SET_NODE_SHAPE",this.setNodeShape),this.goTargetNode=this.goTargetNode.bind(this),this.mindMap.command.add("GO_TARGET_NODE",this.goTargetNode),this.removeCustomStyles=this.removeCustomStyles.bind(this),this.mindMap.command.add("REMOVE_CUSTOM_STYLES",this.removeCustomStyles),this.removeAllNodeCustomStyles=this.removeAllNodeCustomStyles.bind(this),this.mindMap.command.add("REMOVE_ALL_NODE_CUSTOM_STYLES",this.removeAllNodeCustomStyles)}registerShortcutKeys(){this.mindMap.keyCommand.addShortcut("Tab",()=>{this.mindMap.execCommand("INSERT_CHILD_NODE")}),this.mindMap.keyCommand.addShortcut("Insert",()=>{this.mindMap.execCommand("INSERT_CHILD_NODE")}),this.mindMap.keyCommand.addShortcut("Enter",()=>{this.mindMap.execCommand("INSERT_NODE")}),this.mindMap.keyCommand.addShortcut("Shift+Tab",()=>{this.mindMap.execCommand("INSERT_PARENT_NODE")}),this.mindMap.keyCommand.addShortcut("Control+g",()=>{this.mindMap.execCommand("ADD_GENERALIZATION")}),this.toggleActiveExpand=this.toggleActiveExpand.bind(this),this.mindMap.keyCommand.addShortcut("/",this.toggleActiveExpand),this.mindMap.keyCommand.addShortcut("Del|Backspace",()=>{this.mindMap.execCommand("REMOVE_NODE")}),this.mindMap.keyCommand.addShortcut("Shift+Backspace",()=>{this.mindMap.execCommand("REMOVE_CURRENT_NODE")}),this.mindMap.on("before_show_text_edit",()=>{this.startTextEdit()}),this.mindMap.on("hide_text_edit",()=>{this.endTextEdit()}),this.mindMap.keyCommand.addShortcut("Control+a",()=>{this.mindMap.execCommand("SELECT_ALL")}),this.mindMap.keyCommand.addShortcut("Control+l",()=>{this.mindMap.execCommand("RESET_LAYOUT")}),this.mindMap.keyCommand.addShortcut("Control+Up",()=>{this.mindMap.execCommand("UP_NODE")}),this.mindMap.keyCommand.addShortcut("Control+Down",()=>{this.mindMap.execCommand("DOWN_NODE")}),this.mindMap.keyCommand.addShortcut("Control+c",()=>{this.copy()}),this.mindMap.keyCommand.addShortcut("Control+x",()=>{this.cut()}),this.mindMap.keyCommand.addShortcut("Control+v",()=>{this.paste()}),this.mindMap.keyCommand.addShortcut("Control+Enter",()=>{this.setRootNodeCenter()})}emitNodeActiveEvent(e=null,t=[...this.activeNodeList]){Qp(this.lastActiveNodeList,t)||(this.lastActiveNodeList=[...t],clearTimeout(this.emitNodeActiveEventTimer),this.emitNodeActiveEventTimer=setTimeout(()=>{this.mindMap.emit("node_active",e,t)},0))}clearActiveNodeListOnDrawClick(e,t){if(this.activeNodeList.length<=0)return;let r=!0,{useLeftKeySelectionRightKeyDrag:n}=this.mindMap.opt;if(t==="contextmenu"?!n:n){let s=this.mindMap.event.mousedownPos;r=Math.abs(e.clientX-s.x)<=5&&Math.abs(e.clientY-s.y)<=5}r&&this.mindMap.execCommand("CLEAR_ACTIVE_NODE")}startTextEdit(){this.mindMap.keyCommand.save()}endTextEdit(){this.mindMap.keyCommand.restore()}clearCache(){this.layout.lru.clear(),this.nodeCache={},this.lastNodeCache={}}addRenderParams(e,t){e&&this.renderCallbackList.findIndex(n=>n===e)===-1&&this.renderCallbackList.push(e),t&&this.renderSourceList.findIndex(n=>n===t)===-1&&this.renderSourceList.push(t)}checkHasRenderSource(e){e=Array.isArray(e)?e:[e];for(let t=0;t{e()}),this.isRendering=!1,this.reRender=!1,this.renderCallbackList=[],this.renderSourceList=[],this.mindMap.emit("node_tree_render_end")}render(e,t){this.addRenderParams(e,t),clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>{this._render()},0)}_render(){if(this.checkHasRenderSource(A.CHANGE_THEME)&&this.resetUnExpandNodeStyle(),this.isRendering){this.hasWaitRendering=!0;return}if(this.isRendering=!0,this.lastNodeCache=this.nodeCache,this.nodeCache={},this.reRender&&this.clearActiveNodeList(),!this.renderTree){this.onRenderEnd();return}this.mindMap.emit("node_tree_render_start"),this.root=null,this.layout.doLayout(e=>{Object.keys(this.lastNodeCache).forEach(t=>{this.nodeCache[t]||(this.removeNodeFromActiveList(this.lastNodeCache[t]),this.emitNodeActiveEvent(),this.lastNodeCache[t].destroy())}),this.root=e,this.root.render(()=>{if(this.isRendering=!1,this.hasWaitRendering){this.hasWaitRendering=!1,this.render();return}this.onRenderEnd()})}),this.emitNodeActiveEvent()}resetUnExpandNodeStyle(){this.renderTree&&se(this.renderTree,null,e=>{if(!e.data.expand)return se(e,null,t=>{t.data.needUpdate=!0}),!0})}clearActiveNode(){this.activeNodeList.length<=0||(this.clearActiveNodeList(),this.emitNodeActiveEvent(null,[]))}clearActiveNodeList(){this.activeNodeList.forEach(e=>{this.mindMap.execCommand("SET_NODE_ACTIVE",e,!1)}),this.activeNodeList=[]}addNodeToActiveList(e,t=!1){if(this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate&&e.userList.length>0)return;this.findActiveNodeIndex(e)===-1&&(t||this.mindMap.emit("before_node_active",e,this.activeNodeList),this.mindMap.execCommand("SET_NODE_ACTIVE",e,!0),this.activeNodeList.push(e))}removeNodeFromActiveList(e){let t=this.findActiveNodeIndex(e);t!==-1&&(this.mindMap.execCommand("SET_NODE_ACTIVE",e,!1),this.activeNodeList.splice(t,1))}activeMultiNode(e=[]){e.forEach(t=>{this.mindMap.emit("before_node_active",t,this.activeNodeList),this.addNodeToActiveList(t,!0),this.emitNodeActiveEvent(t)})}cancelActiveMultiNode(e=[]){e.forEach(t=>{this.removeNodeFromActiveList(t),this.emitNodeActiveEvent(null)})}findActiveNodeIndex(e){return Ee(e,this.activeNodeList)}selectAll(){this.mindMap.opt.readonly||(se(this.root,null,e=>{e.getData("isActive")||this.addNodeToActiveList(e),e._generalizationList&&e._generalizationList.length>0&&e._generalizationList.forEach(t=>{let r=t.generalizationNode;r.getData("isActive")||this.addNodeToActiveList(r)})},null,!0,0,0),this.emitNodeActiveEvent())}back(e){this.backForward("back",e)}forward(e){this.backForward("forward",e)}backForward(e,t){this.mindMap.execCommand("CLEAR_ACTIVE_NODE");let r=this.mindMap.command[e](t);r&&(this.renderTree=r,this.mindMap.render()),this.mindMap.emit("data_change",r)}getNewNodeBehavior(e=!1,t=!1){let{createNewNodeBehavior:r}=this.mindMap.opt,n=!1,s=!1;switch(r){case A.CREATE_NEW_NODE_BEHAVIOR.DEFAULT:n=t||!e,s=t?!1:e;break;case A.CREATE_NEW_NODE_BEHAVIOR.NOT_ACTIVE:n=!1,s=!1;break;case A.CREATE_NEW_NODE_BEHAVIOR.ACTIVE_ONLY:n=!0,s=!1;break;default:break}return{focusNewNode:n,inserting:s}}insertNode(e=!0,t=[],r=null,n=[]){if(t=Nt(t),this.activeNodeList.length<=0&&t.length<=0)return;this.textEdit.hideEditTextBox();let{defaultInsertSecondLevelNodeText:s,defaultInsertBelowSecondLevelNodeText:a}=this.mindMap.opt,o=t.length>0?t:this.activeNodeList,l=o.length>1,h=this.hasRichTextPlugin(),{focusNewNode:d,inserting:c}=this.getNewNodeBehavior(e,l),f={expand:!0,richText:h,isActive:d};h&&(f.resetRichText=!0),n=so(n,f);let m=r&&r.richText,g=!1;o.forEach(x=>{if(x.isGeneralization||x.isRoot)return;n=Ft(n);let v=x.parent,E=x.layerIndex===1?s:a,S=zs(x);m&&f.resetRichText&&delete f.resetRichText;let C={inserting:c,data:{text:E,...f,uid:ct(),...r||{}},children:[...qn(n,g)]};g=!0,v.nodeData.children.splice(S+1,0,C)}),d&&this.clearActiveNodeList(),this.mindMap.render()}insertMultiNode(e,t){if(!t||t.length<=0||(e=Nt(e),this.activeNodeList.length<=0&&e.length<=0))return;this.textEdit.hideEditTextBox();let r=e.length>0?e:this.activeNodeList,n=this.hasRichTextPlugin(),{focusNewNode:s}=this.getNewNodeBehavior(!1,!0),a={expand:!0,richText:n,isActive:s};n&&(a.resetRichText=!0),t=so(t,a);let o=!1;r.forEach(l=>{if(l.isGeneralization||l.isRoot)return;t=Ft(t);let h=l.parent,d=zs(l),c=qn(t,o);o=!0,h.nodeData.children.splice(d+1,0,...c)}),s&&this.clearActiveNodeList(),this.mindMap.render()}insertChildNode(e=!0,t=[],r=null,n=[]){if(t=Nt(t),this.activeNodeList.length<=0&&t.length<=0)return;this.textEdit.hideEditTextBox();let{defaultInsertSecondLevelNodeText:s,defaultInsertBelowSecondLevelNodeText:a}=this.mindMap.opt,o=t.length>0?t:this.activeNodeList,l=o.length>1,h=this.hasRichTextPlugin(),{focusNewNode:d,inserting:c}=this.getNewNodeBehavior(e,l),f={expand:!0,richText:h,isActive:d};h&&(f.resetRichText=!0),n=so(n,f);let m=r&&r.richText,g=!1;o.forEach(x=>{if(x.isGeneralization)return;n=Ft(n),x.nodeData.children||(x.nodeData.children=[]);let v=x.isRoot?s:a;m&&f.resetRichText&&delete f.resetRichText;let b={inserting:c,data:{text:v,uid:ct(),...f,...r||{}},children:[...qn(n,g)]};g=!0,x.nodeData.children.push(b),x.setData({expand:!0})}),d&&this.clearActiveNodeList(),this.mindMap.render()}insertMultiChildNode(e,t){if(!t||t.length<=0||(e=Nt(e),this.activeNodeList.length<=0&&e.length<=0))return;this.textEdit.hideEditTextBox();let r=e.length>0?e:this.activeNodeList,n=this.hasRichTextPlugin(),{focusNewNode:s}=this.getNewNodeBehavior(!1,!0),a={expand:!0,richText:n,isActive:s};n&&(a.resetRichText=!0),t=so(t,a);let o=!1;r.forEach(l=>{l.isGeneralization||(t=Ft(t),l.nodeData.children||(l.nodeData.children=[]),t=qn(t,o),o=!0,l.nodeData.children.push(...t),l.setData({expand:!0}))}),s&&this.clearActiveNodeList(),this.mindMap.render()}insertParentNode(e=!0,t,r){if(t=Nt(t),this.activeNodeList.length<=0&&t.length<=0)return;this.textEdit.hideEditTextBox();let{defaultInsertSecondLevelNodeText:n,defaultInsertBelowSecondLevelNodeText:s}=this.mindMap.opt,a=t.length>0?t:this.activeNodeList,o=a.length>1,l=this.hasRichTextPlugin(),{focusNewNode:h,inserting:d}=this.getNewNodeBehavior(e,o),c={expand:!0,richText:l,isActive:h};l&&(c.resetRichText=!0);let f=r&&r.richText;a.forEach(m=>{if(m.isGeneralization||m.isRoot)return;let g=m.layerIndex===1?n:s;f&&c.resetRichText&&delete c.resetRichText;let x={inserting:d,data:{text:g,uid:ct(),...c,...r||{}},children:[m.nodeData]},v=m.parent,b=zs(m);v.nodeData.children.splice(b,1,x)}),h&&this.clearActiveNodeList(),this.mindMap.render()}upNode(e){if(this.activeNodeList.length<=0&&!e)return;let r=(e?[e]:this.activeNodeList)[0];if(r.isRoot)return;let n=r.parent,s=n.children,a=Ee(r,s);if(a===-1||a===0)return;let o=a-1;s.splice(a,1),s.splice(o,0,r),n.nodeData.children.splice(a,1),n.nodeData.children.splice(o,0,r.nodeData),this.mindMap.render()}downNode(e){if(this.activeNodeList.length<=0&&!e)return;let r=(e?[e]:this.activeNodeList)[0];if(r.isRoot)return;let n=r.parent,s=n.children,a=Ee(r,s);if(a===-1||a===s.length-1)return;let o=a+1;s.splice(a,1),s.splice(o,0,r),n.nodeData.children.splice(a,1),n.nodeData.children.splice(o,0,r.nodeData),this.mindMap.render()}moveUpOneLevel(e){if(e=e||this.activeNodeList[0],!e||e.isRoot||e.layerIndex<=1)return;let t=e.parent,r=t.parent,n=Ee(e,t.children),s=Ee(t,r.children);t.nodeData.children.splice(n,1),r.nodeData.children.splice(s+1,0,e.nodeData),this.mindMap.render()}_handleRemoveCustomStyles(e){let t=!1;return Object.keys(e).forEach(r=>{Pn(r)&&(t=!0,delete e[r])}),this.hasRichTextPlugin()&&(t=!0,e.resetRichText=!0),t}removeCustomStyles(e){if(e=e||this.activeNodeList[0],!e)return;this._handleRemoveCustomStyles(e.getData())&&this.reRenderNodeCheckChange(e)}removeAllNodeCustomStyles(e){e=Nt(e);let t=!1;if(e.length>0)e.forEach(r=>{this._handleRemoveCustomStyles(r.getData())&&(t=!0)});else{if(!this.renderTree)return;se(this.renderTree,null,r=>{this._handleRemoveCustomStyles(r.data)&&(t=!0);let s=Hn(r.data);s.length>0&&s.forEach(a=>{this._handleRemoveCustomStyles(a)&&(t=!0)})})}t&&this.mindMap.reRender()}copy(){this.beingCopyData=this.copyNode(),this.beingCopyData&&(this.mindMap.opt.disabledClipboard||pc(gc(this.beingCopyData)))}cut(){this.mindMap.execCommand("CUT_NODE",e=>{this.beingCopyData=e,this.mindMap.opt.disabledClipboard||pc(gc(e))})}handlePaste(e){let{disabledClipboard:t}=this.mindMap.opt;if(t)return;let r=e.clipboardData||e.originalEvent.clipboardData,n=r.items,s=null,a="";Array.from(n).forEach(o=>{o.type.indexOf("image")>-1&&(s=o.getAsFile()),o.type.indexOf("text")>-1&&(a=r.getData("text"))}),this.paste()}async paste(){let{errorHandler:e,handleIsSplitByWrapOnPasteCreateNewNode:t,handleNodePasteImg:r,disabledClipboard:n,onlyPasteTextWhenHasImgAndText:s}=this.mindMap.opt;if(!n&&mc())try{let a=await Kp(),o=a.text||"",l=a.img||null;if(o){let h=null,d=!0;if(this.mindMap.opt.customHandleClipboardText)try{let c=await this.mindMap.opt.customHandleClipboardText(o);if(!Bt(c)){d=!1;let f=ao(c);f.isSmm?h=f.data:o=f.data}}catch(c){e(di.CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR,c)}if(d){let c=ao(o);c.isSmm?h=c.data:o=c.data}if(h)this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE",[],Array.isArray(h)?h:[h]);else{this.hasRichTextPlugin()&&(o=Wr(o));let c=o.split(new RegExp(`\r? + `,this.textEditNode.setAttribute("contenteditable",!0),this.textEditNode.addEventListener("keyup",y=>{y.stopPropagation()}),this.textEditNode.addEventListener("click",y=>{y.stopPropagation()}),this.textEditNode.addEventListener("mousedown",y=>{y.stopPropagation()}),this.textEditNode.addEventListener("keydown",y=>{this.checkIsAutoEnterTextEditKey(y)&&y.stopPropagation()}),this.textEditNode.addEventListener("paste",y=>{let b=y.clipboardData.getData("text"),{isSmm:S,data:A}=Po(b);S&&A[0]&&A[0].data?yu(y,sa(A[0].data.text)):yu(y),this.emitTextChangeEvent()}),this.textEditNode.addEventListener("input",()=>{this.emitTextChangeEvent()}),(this.mindMap.opt.customInnerElsAppendTo||document.body).appendChild(this.textEditNode));let c=this.mindMap.view.scale,f=e.style.merge("fontSize"),m=(this.cacheEditingText||e.getData("text")).split(/\n/gim).map(x=>mn(x)),g=e._textData.node.attr("data-ismultiLine")==="true";e.style.domText(this.textEditNode,c),h||(this.textEditNode.style.background=this.getBackground(e)),this.textEditNode.style.zIndex=a,n&&d?this.textEditNode.innerHTML="":this.textEditNode.innerHTML=m.join("
    "),this.textEditNode.style.minWidth=t.width+this.textNodePaddingX*2+"px",this.textEditNode.style.minHeight=t.height+"px",this.textEditNode.style.left=Math.floor(t.left)+"px",this.textEditNode.style.top=Math.floor(t.top)+"px",this.textEditNode.style.display="block",this.textEditNode.style.maxWidth=o*c+"px",g?(this.textEditNode.style.lineHeight=js,this.textEditNode.style.transform=`translateY(${(js-1)*f/2*c}px)`):this.textEditNode.style.lineHeight="normal",this.setIsShowTextEdit(!0),r||l&&!n?la(this.textEditNode):oa(this.textEditNode),this.cacheEditingText=""}emitTextChangeEvent(){this.mindMap.emit("node_text_edit_change",{node:this.currentNode,text:this.getEditText(),richText:!1})}updateTextEditNode(){if(this.mindMap.richText){this.mindMap.richText.updateTextEditNode();return}if(!this.showTextEdit||!this.currentNode)return;let e=this.currentNode._textData.node.node.getBoundingClientRect();this.textEditNode.style.minWidth=e.width+this.textNodePaddingX*2+"px",this.textEditNode.style.minHeight=e.height+this.textNodePaddingY*2+"px",this.textEditNode.style.left=Math.floor(e.left)+"px",this.textEditNode.style.top=Math.floor(e.top)+"px"}getBackground(e){if(e.style.merge("gradientStyle")){let r=e.style.merge("startColor"),n=e.style.merge("endColor");return`linear-gradient(to right, ${r}, ${n})`}else{let r=e.style.merge("fillColor"),n=e.style.merge("color");return r==="transparent"?Oo(n)?$0(this.mindMap.themeConfig):"#fff":r}}removeTextEditEl(){if(this.mindMap.richText){this.mindMap.richText.removeTextEditEl();return}if(!this.textEditNode)return;(this.mindMap.opt.customInnerElsAppendTo||document.body).removeChild(this.textEditNode)}getEditText(){return na(this.textEditNode.innerHTML)}hideEditTextBox(){if(this.mindMap.richText)return this.mindMap.richText.hideEditText();if(!this.showTextEdit)return;let e=this.currentNode,t=this.getEditText();this.currentNode=null,this.textEditNode.style.display="none",this.textEditNode.innerHTML="",this.textEditNode.style.fontFamily="inherit",this.textEditNode.style.fontSize="inherit",this.textEditNode.style.fontWeight="normal",this.textEditNode.style.transform="translateY(0)",this.setIsShowTextEdit(!1),this.mindMap.execCommand("SET_NODE_TEXT",e,t),this.mindMap.render(),this.mindMap.emit("hide_text_edit",this.textEditNode,this.renderer.activeNodeList,e)}getCurrentEditNode(){return this.mindMap.richText?this.mindMap.richText.node:this.currentNode}}});var $v,Uv,Np,jv,Gv=T(()=>{$v=pt(O0());Cv();Lv();zv();Dv();Ov();Bv();Fv();Hv();pe();Tu();Ro();$e();yt();Uv={[k.LAYOUT.LOGICAL_STRUCTURE]:pp,[k.LAYOUT.LOGICAL_STRUCTURE_LEFT]:pp,[k.LAYOUT.MIND_MAP]:_v,[k.LAYOUT.CATALOG_ORGANIZATION]:Iv,[k.LAYOUT.ORGANIZATION_STRUCTURE]:Rv,[k.LAYOUT.TIMELINE]:bp,[k.LAYOUT.TIMELINE2]:bp,[k.LAYOUT.VERTICAL_TIMELINE]:Mc,[k.LAYOUT.VERTICAL_TIMELINE2]:Mc,[k.LAYOUT.VERTICAL_TIMELINE3]:Mc,[k.LAYOUT.FISHBONE]:Tp,[k.LAYOUT.FISHBONE2]:Tp},Np=class{constructor(e={}){this.opt=e,this.mindMap=e.mindMap,this.themeConfig=this.mindMap.themeConfig,this.renderTree=this.mindMap.opt.data?(0,$v.default)({},this.mindMap.opt.data):null,this.reRender=!1,this.isRendering=!1,this.hasWaitRendering=!1,this.nodeCache={},this.lastNodeCache={},this.renderSourceList=[],this.renderCallbackList=[],this.activeNodeList=[],this.emitNodeActiveEventTimer=null,this.renderTimer=null,this.root=null,this.textEdit=new l0(this),this.beingCopyData=null,this.highlightBoxNode=null,this.highlightBoxNodeStyle=null,this.lastActiveNodeList=[],this.setLayout(),this.bindEvent(),this.registerCommands(),this.registerShortcutKeys()}setLayout(){this.layout&&this.layout.beforeChange&&this.layout.beforeChange();let{layout:e}=this.mindMap.opt,t=Uv[e]||this.mindMap[e];t||(t=Uv[k.LAYOUT.LOGICAL_STRUCTURE],this.mindMap.opt.layout=k.LAYOUT.LOGICAL_STRUCTURE),this.layout=new t(this,e)}setData(e){this.renderTree=e||null}bindEvent(){let{openPerformance:e,performanceConfig:t,openRealtimeRenderOnNodeTextEdit:r}=this.mindMap.opt;this.mindMap.on("draw_click",s=>{this.clearActiveNodeListOnDrawClick(s,"click")}),this.mindMap.on("contextmenu",s=>{this.clearActiveNodeListOnDrawClick(s,"contextmenu")}),this.mindMap.svg.on("dblclick",()=>{this.mindMap.opt.enableDblclickBackToRootNode&&this.setRootNodeCenter()});let n=Si(()=>{this.renderTree&&this.root&&(this.mindMap.emit("node_tree_render_start"),this.root.render(()=>{this.mindMap.emit("node_tree_render_end")},!1,!0))},t.time);e&&this.mindMap.on("view_data_change",n),this.onNodeTextEditChange=p2(this.onNodeTextEditChange,100,this),r&&this.mindMap.on("node_text_edit_change",this.onNodeTextEditChange),this.mindMap.on("after_update_config",(s,a)=>{s.openPerformance!==a.openPerformance&&(this.mindMap[s.openPerformance?"on":"off"]("view_data_change",n),this.forceLoadNode()),s.openRealtimeRenderOnNodeTextEdit!==a.openRealtimeRenderOnNodeTextEdit&&this.mindMap[s.openRealtimeRenderOnNodeTextEdit?"on":"off"]("node_text_edit_change",this.onNodeTextEditChange)})}onNodeTextEditChange({node:e,text:t}){e._textData=e.createTextNode(t);let{width:r,height:n}=e.getNodeRect();e.width=r,e.height=n,e.layout(),this.mindMap.render(()=>{this.textEdit.updateTextEditNode()})}forceLoadNode(e){e=e||this.root,e&&(this.mindMap.emit("node_tree_render_start"),e.render(()=>{this.mindMap.emit("node_tree_render_end")},!0))}registerCommands(){this.selectAll=this.selectAll.bind(this),this.mindMap.command.add("SELECT_ALL",this.selectAll),this.back=this.back.bind(this),this.mindMap.command.add("BACK",this.back),this.forward=this.forward.bind(this),this.mindMap.command.add("FORWARD",this.forward),this.insertNode=this.insertNode.bind(this),this.mindMap.command.add("INSERT_NODE",this.insertNode),this.insertMultiNode=this.insertMultiNode.bind(this),this.mindMap.command.add("INSERT_MULTI_NODE",this.insertMultiNode),this.insertChildNode=this.insertChildNode.bind(this),this.mindMap.command.add("INSERT_CHILD_NODE",this.insertChildNode),this.insertMultiChildNode=this.insertMultiChildNode.bind(this),this.mindMap.command.add("INSERT_MULTI_CHILD_NODE",this.insertMultiChildNode),this.insertParentNode=this.insertParentNode.bind(this),this.mindMap.command.add("INSERT_PARENT_NODE",this.insertParentNode),this.upNode=this.upNode.bind(this),this.mindMap.command.add("UP_NODE",this.upNode),this.downNode=this.downNode.bind(this),this.mindMap.command.add("DOWN_NODE",this.downNode),this.moveUpOneLevel=this.moveUpOneLevel.bind(this),this.mindMap.command.add("MOVE_UP_ONE_LEVEL",this.moveUpOneLevel),this.insertAfter=this.insertAfter.bind(this),this.mindMap.command.add("INSERT_AFTER",this.insertAfter),this.insertBefore=this.insertBefore.bind(this),this.mindMap.command.add("INSERT_BEFORE",this.insertBefore),this.moveNodeTo=this.moveNodeTo.bind(this),this.mindMap.command.add("MOVE_NODE_TO",this.moveNodeTo),this.removeNode=this.removeNode.bind(this),this.mindMap.command.add("REMOVE_NODE",this.removeNode),this.removeCurrentNode=this.removeCurrentNode.bind(this),this.mindMap.command.add("REMOVE_CURRENT_NODE",this.removeCurrentNode),this.pasteNode=this.pasteNode.bind(this),this.mindMap.command.add("PASTE_NODE",this.pasteNode),this.cutNode=this.cutNode.bind(this),this.mindMap.command.add("CUT_NODE",this.cutNode),this.setNodeStyle=this.setNodeStyle.bind(this),this.mindMap.command.add("SET_NODE_STYLE",this.setNodeStyle),this.setNodeStyles=this.setNodeStyles.bind(this),this.mindMap.command.add("SET_NODE_STYLES",this.setNodeStyles),this.setNodeActive=this.setNodeActive.bind(this),this.mindMap.command.add("SET_NODE_ACTIVE",this.setNodeActive),this.clearActiveNode=this.clearActiveNode.bind(this),this.mindMap.command.add("CLEAR_ACTIVE_NODE",this.clearActiveNode),this.setNodeExpand=this.setNodeExpand.bind(this),this.mindMap.command.add("SET_NODE_EXPAND",this.setNodeExpand),this.expandAllNode=this.expandAllNode.bind(this),this.mindMap.command.add("EXPAND_ALL",this.expandAllNode),this.unexpandAllNode=this.unexpandAllNode.bind(this),this.mindMap.command.add("UNEXPAND_ALL",this.unexpandAllNode),this.expandToLevel=this.expandToLevel.bind(this),this.mindMap.command.add("UNEXPAND_TO_LEVEL",this.expandToLevel),this.setNodeData=this.setNodeData.bind(this),this.mindMap.command.add("SET_NODE_DATA",this.setNodeData),this.setNodeText=this.setNodeText.bind(this),this.mindMap.command.add("SET_NODE_TEXT",this.setNodeText),this.setNodeImage=this.setNodeImage.bind(this),this.mindMap.command.add("SET_NODE_IMAGE",this.setNodeImage),this.setNodeIcon=this.setNodeIcon.bind(this),this.mindMap.command.add("SET_NODE_ICON",this.setNodeIcon),this.setNodeHyperlink=this.setNodeHyperlink.bind(this),this.mindMap.command.add("SET_NODE_HYPERLINK",this.setNodeHyperlink),this.setNodeNote=this.setNodeNote.bind(this),this.mindMap.command.add("SET_NODE_NOTE",this.setNodeNote),this.setNodeAttachment=this.setNodeAttachment.bind(this),this.mindMap.command.add("SET_NODE_ATTACHMENT",this.setNodeAttachment),this.setNodeTag=this.setNodeTag.bind(this),this.mindMap.command.add("SET_NODE_TAG",this.setNodeTag),this.insertFormula=this.insertFormula.bind(this),this.mindMap.command.add("INSERT_FORMULA",this.insertFormula),this.addGeneralization=this.addGeneralization.bind(this),this.mindMap.command.add("ADD_GENERALIZATION",this.addGeneralization),this.removeGeneralization=this.removeGeneralization.bind(this),this.mindMap.command.add("REMOVE_GENERALIZATION",this.removeGeneralization),this.setNodeCustomPosition=this.setNodeCustomPosition.bind(this),this.mindMap.command.add("SET_NODE_CUSTOM_POSITION",this.setNodeCustomPosition),this.resetLayout=this.resetLayout.bind(this),this.mindMap.command.add("RESET_LAYOUT",this.resetLayout),this.setNodeShape=this.setNodeShape.bind(this),this.mindMap.command.add("SET_NODE_SHAPE",this.setNodeShape),this.goTargetNode=this.goTargetNode.bind(this),this.mindMap.command.add("GO_TARGET_NODE",this.goTargetNode),this.removeCustomStyles=this.removeCustomStyles.bind(this),this.mindMap.command.add("REMOVE_CUSTOM_STYLES",this.removeCustomStyles),this.removeAllNodeCustomStyles=this.removeAllNodeCustomStyles.bind(this),this.mindMap.command.add("REMOVE_ALL_NODE_CUSTOM_STYLES",this.removeAllNodeCustomStyles)}registerShortcutKeys(){this.mindMap.keyCommand.addShortcut("Tab",()=>{this.mindMap.execCommand("INSERT_CHILD_NODE")}),this.mindMap.keyCommand.addShortcut("Insert",()=>{this.mindMap.execCommand("INSERT_CHILD_NODE")}),this.mindMap.keyCommand.addShortcut("Enter",()=>{this.mindMap.execCommand("INSERT_NODE")}),this.mindMap.keyCommand.addShortcut("Shift+Tab",()=>{this.mindMap.execCommand("INSERT_PARENT_NODE")}),this.mindMap.keyCommand.addShortcut("Control+g",()=>{this.mindMap.execCommand("ADD_GENERALIZATION")}),this.toggleActiveExpand=this.toggleActiveExpand.bind(this),this.mindMap.keyCommand.addShortcut("/",this.toggleActiveExpand),this.mindMap.keyCommand.addShortcut("Del|Backspace",()=>{this.mindMap.execCommand("REMOVE_NODE")}),this.mindMap.keyCommand.addShortcut("Shift+Backspace",()=>{this.mindMap.execCommand("REMOVE_CURRENT_NODE")}),this.mindMap.on("before_show_text_edit",()=>{this.startTextEdit()}),this.mindMap.on("hide_text_edit",()=>{this.endTextEdit()}),this.mindMap.keyCommand.addShortcut("Control+a",()=>{this.mindMap.execCommand("SELECT_ALL")}),this.mindMap.keyCommand.addShortcut("Control+l",()=>{this.mindMap.execCommand("RESET_LAYOUT")}),this.mindMap.keyCommand.addShortcut("Control+Up",()=>{this.mindMap.execCommand("UP_NODE")}),this.mindMap.keyCommand.addShortcut("Control+Down",()=>{this.mindMap.execCommand("DOWN_NODE")}),this.mindMap.keyCommand.addShortcut("Control+c",()=>{this.copy()}),this.mindMap.keyCommand.addShortcut("Control+x",()=>{this.cut()}),this.mindMap.keyCommand.addShortcut("Control+v",()=>{this.paste()}),this.mindMap.keyCommand.addShortcut("Control+Enter",()=>{this.setRootNodeCenter()})}emitNodeActiveEvent(e=null,t=[...this.activeNodeList]){L2(this.lastActiveNodeList,t)||(this.lastActiveNodeList=[...t],clearTimeout(this.emitNodeActiveEventTimer),this.emitNodeActiveEventTimer=setTimeout(()=>{this.mindMap.emit("node_active",e,t)},0))}clearActiveNodeListOnDrawClick(e,t){if(this.activeNodeList.length<=0)return;let r=!0,{useLeftKeySelectionRightKeyDrag:n}=this.mindMap.opt;if(t==="contextmenu"?!n:n){let s=this.mindMap.event.mousedownPos;r=Math.abs(e.clientX-s.x)<=5&&Math.abs(e.clientY-s.y)<=5}r&&this.mindMap.execCommand("CLEAR_ACTIVE_NODE")}startTextEdit(){this.mindMap.keyCommand.save()}endTextEdit(){this.mindMap.keyCommand.restore()}clearCache(){this.layout.lru.clear(),this.nodeCache={},this.lastNodeCache={}}addRenderParams(e,t){e&&this.renderCallbackList.findIndex(n=>n===e)===-1&&this.renderCallbackList.push(e),t&&this.renderSourceList.findIndex(n=>n===t)===-1&&this.renderSourceList.push(t)}checkHasRenderSource(e){e=Array.isArray(e)?e:[e];for(let t=0;t{e()}),this.isRendering=!1,this.reRender=!1,this.renderCallbackList=[],this.renderSourceList=[],this.mindMap.emit("node_tree_render_end")}render(e,t){this.addRenderParams(e,t),clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>{this._render()},0)}_render(){if(this.checkHasRenderSource(k.CHANGE_THEME)&&this.resetUnExpandNodeStyle(),this.isRendering){this.hasWaitRendering=!0;return}if(this.isRendering=!0,this.lastNodeCache=this.nodeCache,this.nodeCache={},this.reRender&&this.clearActiveNodeList(),!this.renderTree){this.onRenderEnd();return}this.mindMap.emit("node_tree_render_start"),this.root=null,this.layout.doLayout(e=>{Object.keys(this.lastNodeCache).forEach(t=>{this.nodeCache[t]||(this.removeNodeFromActiveList(this.lastNodeCache[t]),this.emitNodeActiveEvent(),this.lastNodeCache[t].destroy())}),this.root=e,this.root.render(()=>{if(this.isRendering=!1,this.hasWaitRendering){this.hasWaitRendering=!1,this.render();return}this.onRenderEnd()})}),this.emitNodeActiveEvent()}resetUnExpandNodeStyle(){this.renderTree&&de(this.renderTree,null,e=>{if(!e.data.expand)return de(e,null,t=>{t.data.needUpdate=!0}),!0})}clearActiveNode(){this.activeNodeList.length<=0||(this.clearActiveNodeList(),this.emitNodeActiveEvent(null,[]))}clearActiveNodeList(){this.activeNodeList.forEach(e=>{this.mindMap.execCommand("SET_NODE_ACTIVE",e,!1)}),this.activeNodeList=[]}addNodeToActiveList(e,t=!1){if(this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate&&e.userList.length>0)return;this.findActiveNodeIndex(e)===-1&&(t||this.mindMap.emit("before_node_active",e,this.activeNodeList),this.mindMap.execCommand("SET_NODE_ACTIVE",e,!0),this.activeNodeList.push(e))}removeNodeFromActiveList(e){let t=this.findActiveNodeIndex(e);t!==-1&&(this.mindMap.execCommand("SET_NODE_ACTIVE",e,!1),this.activeNodeList.splice(t,1))}activeMultiNode(e=[]){e.forEach(t=>{this.mindMap.emit("before_node_active",t,this.activeNodeList),this.addNodeToActiveList(t,!0),this.emitNodeActiveEvent(t)})}cancelActiveMultiNode(e=[]){e.forEach(t=>{this.removeNodeFromActiveList(t),this.emitNodeActiveEvent(null)})}findActiveNodeIndex(e){return Ie(e,this.activeNodeList)}selectAll(){this.mindMap.opt.readonly||(de(this.root,null,e=>{e.getData("isActive")||this.addNodeToActiveList(e),e._generalizationList&&e._generalizationList.length>0&&e._generalizationList.forEach(t=>{let r=t.generalizationNode;r.getData("isActive")||this.addNodeToActiveList(r)})},null,!0,0,0),this.emitNodeActiveEvent())}back(e){this.backForward("back",e)}forward(e){this.backForward("forward",e)}backForward(e,t){this.mindMap.execCommand("CLEAR_ACTIVE_NODE");let r=this.mindMap.command[e](t);r&&(this.renderTree=r,this.mindMap.render()),this.mindMap.emit("data_change",r)}getNewNodeBehavior(e=!1,t=!1){let{createNewNodeBehavior:r}=this.mindMap.opt,n=!1,s=!1;switch(r){case k.CREATE_NEW_NODE_BEHAVIOR.DEFAULT:n=t||!e,s=t?!1:e;break;case k.CREATE_NEW_NODE_BEHAVIOR.NOT_ACTIVE:n=!1,s=!1;break;case k.CREATE_NEW_NODE_BEHAVIOR.ACTIVE_ONLY:n=!0,s=!1;break;default:break}return{focusNewNode:n,inserting:s}}insertNode(e=!0,t=[],r=null,n=[]){if(t=Ot(t),this.activeNodeList.length<=0&&t.length<=0)return;this.textEdit.hideEditTextBox();let{defaultInsertSecondLevelNodeText:s,defaultInsertBelowSecondLevelNodeText:a}=this.mindMap.opt,o=t.length>0?t:this.activeNodeList,l=o.length>1,h=this.hasRichTextPlugin(),{focusNewNode:d,inserting:c}=this.getNewNodeBehavior(e,l),f={expand:!0,richText:h,isActive:d};h&&(f.resetRichText=!0),n=Bo(n,f);let m=r&&r.richText,g=!1;o.forEach(x=>{if(x.isGeneralization||x.isRoot)return;n=Kt(n);let y=x.parent,S=x.layerIndex===1?s:a,A=ha(x);m&&f.resetRichText&&delete f.resetRichText;let C={inserting:c,data:{text:S,...f,uid:wt(),...r||{}},children:[...cs(n,g)]};g=!0,y.nodeData.children.splice(A+1,0,C)}),d&&this.clearActiveNodeList(),this.mindMap.render()}insertMultiNode(e,t){if(!t||t.length<=0||(e=Ot(e),this.activeNodeList.length<=0&&e.length<=0))return;this.textEdit.hideEditTextBox();let r=e.length>0?e:this.activeNodeList,n=this.hasRichTextPlugin(),{focusNewNode:s}=this.getNewNodeBehavior(!1,!0),a={expand:!0,richText:n,isActive:s};n&&(a.resetRichText=!0),t=Bo(t,a);let o=!1;r.forEach(l=>{if(l.isGeneralization||l.isRoot)return;t=Kt(t);let h=l.parent,d=ha(l),c=cs(t,o);o=!0,h.nodeData.children.splice(d+1,0,...c)}),s&&this.clearActiveNodeList(),this.mindMap.render()}insertChildNode(e=!0,t=[],r=null,n=[]){if(t=Ot(t),this.activeNodeList.length<=0&&t.length<=0)return;this.textEdit.hideEditTextBox();let{defaultInsertSecondLevelNodeText:s,defaultInsertBelowSecondLevelNodeText:a}=this.mindMap.opt,o=t.length>0?t:this.activeNodeList,l=o.length>1,h=this.hasRichTextPlugin(),{focusNewNode:d,inserting:c}=this.getNewNodeBehavior(e,l),f={expand:!0,richText:h,isActive:d};h&&(f.resetRichText=!0),n=Bo(n,f);let m=r&&r.richText,g=!1;o.forEach(x=>{if(x.isGeneralization)return;n=Kt(n),x.nodeData.children||(x.nodeData.children=[]);let y=x.isRoot?s:a;m&&f.resetRichText&&delete f.resetRichText;let b={inserting:c,data:{text:y,uid:wt(),...f,...r||{}},children:[...cs(n,g)]};g=!0,x.nodeData.children.push(b),x.setData({expand:!0})}),d&&this.clearActiveNodeList(),this.mindMap.render()}insertMultiChildNode(e,t){if(!t||t.length<=0||(e=Ot(e),this.activeNodeList.length<=0&&e.length<=0))return;this.textEdit.hideEditTextBox();let r=e.length>0?e:this.activeNodeList,n=this.hasRichTextPlugin(),{focusNewNode:s}=this.getNewNodeBehavior(!1,!0),a={expand:!0,richText:n,isActive:s};n&&(a.resetRichText=!0),t=Bo(t,a);let o=!1;r.forEach(l=>{l.isGeneralization||(t=Kt(t),l.nodeData.children||(l.nodeData.children=[]),t=cs(t,o),o=!0,l.nodeData.children.push(...t),l.setData({expand:!0}))}),s&&this.clearActiveNodeList(),this.mindMap.render()}insertParentNode(e=!0,t,r){if(t=Ot(t),this.activeNodeList.length<=0&&t.length<=0)return;this.textEdit.hideEditTextBox();let{defaultInsertSecondLevelNodeText:n,defaultInsertBelowSecondLevelNodeText:s}=this.mindMap.opt,a=t.length>0?t:this.activeNodeList,o=a.length>1,l=this.hasRichTextPlugin(),{focusNewNode:h,inserting:d}=this.getNewNodeBehavior(e,o),c={expand:!0,richText:l,isActive:h};l&&(c.resetRichText=!0);let f=r&&r.richText;a.forEach(m=>{if(m.isGeneralization||m.isRoot)return;let g=m.layerIndex===1?n:s;f&&c.resetRichText&&delete c.resetRichText;let x={inserting:d,data:{text:g,uid:wt(),...c,...r||{}},children:[m.nodeData]},y=m.parent,b=ha(m);y.nodeData.children.splice(b,1,x)}),h&&this.clearActiveNodeList(),this.mindMap.render()}upNode(e){if(this.activeNodeList.length<=0&&!e)return;let r=(e?[e]:this.activeNodeList)[0];if(r.isRoot)return;let n=r.parent,s=n.children,a=Ie(r,s);if(a===-1||a===0)return;let o=a-1;s.splice(a,1),s.splice(o,0,r),n.nodeData.children.splice(a,1),n.nodeData.children.splice(o,0,r.nodeData),this.mindMap.render()}downNode(e){if(this.activeNodeList.length<=0&&!e)return;let r=(e?[e]:this.activeNodeList)[0];if(r.isRoot)return;let n=r.parent,s=n.children,a=Ie(r,s);if(a===-1||a===s.length-1)return;let o=a+1;s.splice(a,1),s.splice(o,0,r),n.nodeData.children.splice(a,1),n.nodeData.children.splice(o,0,r.nodeData),this.mindMap.render()}moveUpOneLevel(e){if(e=e||this.activeNodeList[0],!e||e.isRoot||e.layerIndex<=1)return;let t=e.parent,r=t.parent,n=Ie(e,t.children),s=Ie(t,r.children);t.nodeData.children.splice(n,1),r.nodeData.children.splice(s+1,0,e.nodeData),this.mindMap.render()}_handleRemoveCustomStyles(e){let t=!1;return Object.keys(e).forEach(r=>{hs(r)&&(t=!0,delete e[r])}),this.hasRichTextPlugin()&&(t=!0,e.resetRichText=!0),t}removeCustomStyles(e){if(e=e||this.activeNodeList[0],!e)return;this._handleRemoveCustomStyles(e.getData())&&this.reRenderNodeCheckChange(e)}removeAllNodeCustomStyles(e){e=Ot(e);let t=!1;if(e.length>0)e.forEach(r=>{this._handleRemoveCustomStyles(r.getData())&&(t=!0)});else{if(!this.renderTree)return;de(this.renderTree,null,r=>{this._handleRemoveCustomStyles(r.data)&&(t=!0);let s=us(r.data);s.length>0&&s.forEach(a=>{this._handleRemoveCustomStyles(a)&&(t=!0)})})}t&&this.mindMap.reRender()}copy(){this.beingCopyData=this.copyNode(),this.beingCopyData&&(this.mindMap.opt.disabledClipboard||gu(xu(this.beingCopyData)))}cut(){this.mindMap.execCommand("CUT_NODE",e=>{this.beingCopyData=e,this.mindMap.opt.disabledClipboard||gu(xu(e))})}handlePaste(e){let{disabledClipboard:t}=this.mindMap.opt;if(t)return;let r=e.clipboardData||e.originalEvent.clipboardData,n=r.items,s=null,a="";Array.from(n).forEach(o=>{o.type.indexOf("image")>-1&&(s=o.getAsFile()),o.type.indexOf("text")>-1&&(a=r.getData("text"))}),this.paste()}async paste(){let{errorHandler:e,handleIsSplitByWrapOnPasteCreateNewNode:t,handleNodePasteImg:r,disabledClipboard:n,onlyPasteTextWhenHasImgAndText:s}=this.mindMap.opt;if(!n&&pu())try{let a=await C2(),o=a.text||"",l=a.img||null;if(o){let h=null,d=!0;if(this.mindMap.opt.customHandleClipboardText)try{let c=await this.mindMap.opt.customHandleClipboardText(o);if(!Yt(c)){d=!1;let f=Po(c);f.isSmm?h=f.data:o=f.data}}catch(c){e(Mi.CUSTOM_HANDLE_CLIPBOARD_TEXT_ERROR,c)}if(d){let c=Po(o);c.isSmm?h=c.data:o=c.data}if(h)this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE",[],Array.isArray(h)?h:[h]);else{this.hasRichTextPlugin()&&(o=mn(o));let c=o.split(new RegExp(`\r? |(?!!f);c.length>1&&t?t().then(()=>{this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE",[],c.map(f=>({data:{text:f},children:[]})))}).catch(()=>{this.mindMap.execCommand("INSERT_CHILD_NODE",!1,[],{text:o})}):this.mindMap.execCommand("INSERT_CHILD_NODE",!1,[],{text:o})}}if(l&&(!o||!s))try{let h=null;r&&typeof r=="function"?h=await r(l):h=await qp(l),this.activeNodeList.length>0&&this.activeNodeList.forEach(d=>{this.mindMap.execCommand("SET_NODE_IMAGE",d,{url:h.url,title:"",width:h.size.width,height:h.size.height})})}catch(h){e(di.LOAD_CLIPBOARD_IMAGE_ERROR,h)}}catch(a){e(di.READ_CLIPBOARD_ERROR,a)}else this.beingCopyData&&this.mindMap.execCommand("PASTE_NODE",this.beingCopyData)}insertBefore(e,t){this.insertTo(e,t,"before")}insertAfter(e,t){this.insertTo(e,t,"after")}insertTo(e,t,r="before"){let n=Nt(e);n=n.filter(s=>!s.isRoot),r==="after"&&n.reverse(),n.forEach(s=>{let a=s.parent,o=a.children,l=Ee(s,o);if(l===-1)return;o.splice(l,1),a.nodeData.children.splice(l,1);let h=t.parent,d=h.children,c=Ee(t,d);c!==-1&&(r==="after"&&c++,d.splice(c,0,s),h.nodeData.children.splice(c,0,s.nodeData))}),this.mindMap.render()}removeNode(e=[]){if(e=Nt(e),this.activeNodeList.length<=0&&e.length<=0)return;let t=null,r=e.length>0,n=r?e:this.activeNodeList,s=n.find(a=>a.isRoot);if(s)this.clearActiveNodeList(),s.children=[],s.nodeData.children=[];else{t=this.getNextActiveNode(n);for(let a=0;a0?e:this.activeNodeList;r=r.filter(s=>!s.isRoot);let n=this.getNextActiveNode(r);for(let s=0;s0?t=n[s-1]:t=r.parent}return t}copyNode(){if(this.activeNodeList.length<=0)return null;let e=Fn(this.activeNodeList);return e=oo(e),e.map(t=>Bn({},t,!0))}cutNode(e){if(this.activeNodeList.length<=0)return;let t=Fn(this.activeNodeList).filter(n=>!n.isRoot);t=oo(t);let r=t.map(n=>Bn({},n,!0));t.forEach(n=>{r0(n)}),this.clearActiveNodeList(),this.mindMap.render(),e&&typeof e=="function"&&e(r)}moveNodeTo(e,t){let r=Nt(e);r=r.filter(n=>!n.isRoot),r.forEach(n=>{this.removeNodeFromActiveList(n),r0(n),t.setData({expand:!0}),t.nodeData.children.push(n.nodeData)}),this.emitNodeActiveEvent(),this.mindMap.render()}pasteNode(e){e=Nt(e),this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE",[],e)}setNodeStyle(e,t,r){let n={[t]:r};this.setNodeDataRender(e,n),to.includes(t)&&(e.parent||e).renderLine(!0)}setNodeStyles(e,t){let r={...t};this.setNodeDataRender(e,r);let n=Object.keys(t),s=!1;n.forEach(a=>{to.includes(a)&&(s=!0)}),s&&(e.parent||e).renderLine(!0)}setNodeActive(e,t){this.mindMap.execCommand("SET_NODE_DATA",e,{isActive:t}),e.updateNodeByActive(t)}setNodeExpand(e,t){this.mindMap.execCommand("SET_NODE_DATA",e,{expand:t}),this.mindMap.render()}expandAllNode(e=""){if(!this.renderTree)return;let t=(r,n)=>{!n&&r.data.uid===e&&(n=!0),n&&!r.data.expand&&(r.data.expand=!0),r.children&&r.children.length>0&&r.children.forEach(s=>{t(s,n)})};t(this.renderTree,!e),this.mindMap.render()}unexpandAllNode(e=!0,t=""){if(!this.renderTree)return;let r=(n,s,a)=>{!a&&n.data.uid===t&&(a=!0),a&&!s&&n.children&&n.children.length>0&&(n.data.expand=!1),n.children&&n.children.length>0&&n.children.forEach(o=>{r(o,!1,a)})};r(this.renderTree,!0,!t),this.mindMap.render(()=>{e&&this.setRootNodeCenter()})}expandToLevel(e){this.renderTree&&(se(this.renderTree,null,(t,r,n,s)=>{s0&&(t.data.expand=!1)},null,!0,0,0),this.mindMap.render())}toggleActiveExpand(){this.activeNodeList.forEach(e=>{e.nodeData.children.length<=0||e.isRoot||this.toggleNodeExpand(e)})}toggleNodeExpand(e){this.mindMap.execCommand("SET_NODE_EXPAND",e,!e.getData("expand"))}setNodeText(e,t,r,n){r=r===void 0?e.getData("richText"):r,this.setNodeDataRender(e,{text:t,richText:r,resetRichText:n})}setNodeImage(e,t){let{url:r,title:n,width:s,height:a,custom:o=!1}=t||{url:"",title:"",width:0,height:0,custom:!1};this.setNodeDataRender(e,{image:r,imageTitle:n||"",imageSize:{width:s,height:a,custom:o}})}setNodeIcon(e,t){this.setNodeDataRender(e,{icon:t})}setNodeHyperlink(e,t,r=""){this.setNodeDataRender(e,{hyperlink:t,hyperlinkTitle:r})}setNodeNote(e,t){this.setNodeDataRender(e,{note:t})}setNodeAttachment(e,t,r=""){this.setNodeDataRender(e,{attachmentUrl:t,attachmentName:r})}setNodeTag(e,t){this.setNodeDataRender(e,{tag:t})}insertFormula(e,t=[]){if(!this.hasRichTextPlugin()||!this.mindMap.formula)return;t=Nt(t),(t.length>0?t:this.activeNodeList).forEach(n=>{this.mindMap.formula.insertFormulaToNode(n,e)})}addGeneralization(e,t=!0){if(this.activeNodeList.length<=0)return;let r=this.activeNodeList.filter(d=>!d.isRoot&&!d.isGeneralization&&!d.checkHasSelfGeneralization()),n=Vp(r);if(n.length<=0)return;let s=this.hasRichTextPlugin(),{focusNewNode:a,inserting:o}=this.getNewNodeBehavior(t,n.length>1),l=!1,h=e&&e.richText;n.forEach(d=>{let c={inserting:o,...e||{text:this.mindMap.opt.defaultGeneralizationText},range:d.range||null,uid:ct(),richText:s,isActive:a};s&&!h&&(c.resetRichText=s);let f=d.node.getData("generalization");if(f=f?Array.isArray(f)?f:[f]:[],d.range){if(!!f.find(g=>g.range&&g.range[0]===d.range[0]&&g.range[1]===d.range[1]))return;f.push(c)}else f.push(c);l=!0,this.mindMap.execCommand("SET_NODE_DATA",d.node,{generalization:f}),d.node.setData({expand:!0})}),l&&(a&&this.clearActiveNodeList(),this.mindMap.render(()=>{this.mindMap.render()}))}removeGeneralization(){this.activeNodeList.length<=0||(this.activeNodeList.forEach(e=>{e.checkHasGeneralization()&&this.mindMap.execCommand("SET_NODE_DATA",e,{generalization:null})}),this.mindMap.render(),this.closeHighlightNode())}setNodeCustomPosition(e,t=void 0,r=void 0){[e].forEach(s=>{this.mindMap.execCommand("SET_NODE_DATA",s,{customLeft:t,customTop:r})})}resetLayout(){se(this.root,null,e=>{e.customLeft=void 0,e.customTop=void 0,this.mindMap.execCommand("SET_NODE_DATA",e,{customLeft:void 0,customTop:void 0}),this.mindMap.render()},null,!0,0,0)}setNodeShape(e,t){if(!t||!s3.includes(t))return;[e].forEach(n=>{this.setNodeStyle(n,"shape",t)})}goTargetNode(e,t=()=>{}){let r=typeof e=="string"?e:e.getData("uid");r&&this.expandToNodeUid(r,()=>{let n=this.findNodeByUid(r);n&&(n.active(),this.moveNodeToCenter(n),t(n))})}setNodeData(e,t){Object.keys(t).forEach(r=>{e.nodeData.data[r]=t[r]})}setNodeDataRender(e,t,r=!1){if(this.mindMap.execCommand("SET_NODE_DATA",e,t),Yp(t)){this.mindMap.emit("node_tree_render_end");return}this.reRenderNodeCheckChange(e,r)}reRenderNodeCheckChange(e,t){e.reRender()?t||this.mindMap.render():this.mindMap.emit("node_tree_render_end")}moveNodeToCenter(e,t){let{resetScaleOnMoveNodeToCenter:r}=this.mindMap.opt;t!==void 0&&(r=t);let{transform:n,state:s}=this.mindMap.view.getTransformData(),{left:a,top:o,width:l,height:h}=e;r||(a*=n.scaleX,o*=n.scaleY,l*=n.scaleX,h*=n.scaleY);let d=this.mindMap.width/2,c=this.mindMap.height/2,f=a+l/2,m=o+h/2,g=d-s.x,x=c-s.y,v=g-f,b=x-m;this.mindMap.view.translateX(v),this.mindMap.view.translateY(b),r&&this.mindMap.view.setScale(1)}setRootNodeCenter(){this.moveNodeToCenter(this.root)}expandToNodeUid(e,t=()=>{}){if(!this.renderTree){t();return}let r=[],n=!1,s={};Pt(this.renderTree,(o,l)=>{if(o.data.uid===e)return r=l?[...s[l.data.uid],l]:[],"stop";if(Hn(o.data).forEach(d=>{d.uid===e&&(r=l?[...s[l.data.uid],l,o]:[],n=!0)}),n)return"stop";s[o.data.uid]=l?[...s[l.data.uid],l]:[]});let a=!1;if(r.forEach(o=>{o.data.expand||(a=!0,o.data.expand=!0)}),n){let o=r[r.length-1];o&&se(o,null,l=>{l.data.expand||(a=!0,l.data.expand=!0)})}a?this.mindMap.render(t):t()}findNodeByUid(e){if(!this.root)return;let t=null;return se(this.root,null,r=>{if(r.getData("uid")===e)return t=r,!0;let n=!1;if((r._generalizationList||[]).forEach(s=>{s.generalizationNode.getData("uid")===e&&(t=s.generalizationNode,n=!0)}),n)return!0}),t}highlightNode(e,t,r){if(this.isRendering)return;r={stroke:"rgb(94, 200, 248)",fill:"transparent",...r||{}},this.highlightBoxNode?this.highlightBoxNodeStyle&&(this.highlightBoxNodeStyle.stroke!==r.stroke||this.highlightBoxNodeStyle.fill!==r.fill)&&this.highlightBoxNode.stroke({color:r.stroke||"transparent"}).fill({color:r.fill||"transparent"}):this.highlightBoxNode=new _i().stroke({color:r.stroke||"transparent"}).fill({color:r.fill||"transparent"}),this.highlightBoxNodeStyle={...r};let n=1/0,s=1/0,a=-1/0,o=-1/0;t?e.children.slice(t[0],t[1]+1).forEach(h=>{h.lefta&&(a=d),c>o&&(o=c)}):(n=e.left,s=e.top,a=e.left+e.width,o=e.top+e.height),this.highlightBoxNode.plot([[n,s],[a,s],[a,o],[n,o]]),this.mindMap.otherDraw.add(this.highlightBoxNode)}closeHighlightNode(){this.highlightBoxNode&&this.highlightBoxNode.remove()}hasRichTextPlugin(){return!!this.mindMap.richText}},cv=Tm});var Nn,fv=M(()=>{io();Nn={default:Vl}});var Nm,En,mv=M(()=>{Nm={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,CapsLock:20,Esc:27,Spacebar:32,PageUp:33,PageDown:34,End:35,Home:36,Insert:45,Left:37,Up:38,Right:39,Down:40,Del:46,NumLock:144,Cmd:91,CmdFF:224,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,"`":192,"=":187,"-":189,"/":191,".":190};for(let i=0;i<=9;i++)Nm[i]=i+48;"abcdefghijklmnopqrstuvwxyz".split("").forEach((i,e)=>{Nm[i]=e+65});En=Nm});var zl,pv=M(()=>{mv();zl=class{constructor(e){this.opt=e,this.mindMap=e.mindMap,this.shortcutMap={},this.shortcutMapCache={},this.isPause=!1,this.isInSvg=!1,this.isStopCheckInSvg=!1,this.defaultEnableCheck=this.defaultEnableCheck.bind(this),this.bindEvent()}extendKeyMap(e,t){En[e]=t}removeKeyMap(e){typeof En[e]<"u"&&delete En[e]}pause(){this.isPause=!0}recovery(){this.isPause=!1}save(){Object.keys(this.shortcutMapCache).length>0||(this.shortcutMapCache=this.shortcutMap,this.shortcutMap={})}restore(){Object.keys(this.shortcutMapCache).length<=0||(this.shortcutMap=this.shortcutMapCache,this.shortcutMapCache={})}stopCheckInSvg(){let{enableShortcutOnlyWhenMouseInSvg:e}=this.mindMap.opt;e&&(this.isStopCheckInSvg=!0)}recoveryCheckInSvg(){let{enableShortcutOnlyWhenMouseInSvg:e}=this.mindMap.opt;e&&(this.isStopCheckInSvg=!0)}bindEvent(){this.onKeydown=this.onKeydown.bind(this),this.mindMap.on("svg_mouseenter",()=>{this.isInSvg=!0}),this.mindMap.on("svg_mouseleave",()=>{this.isInSvg=!1}),window.addEventListener("keydown",this.onKeydown),this.mindMap.on("beforeDestroy",()=>{this.unBindEvent()})}unBindEvent(){window.removeEventListener("keydown",this.onKeydown)}defaultEnableCheck(e){let t=e.target;if(t===document.body)return!0;for(let r=0;r{if(this.checkKey(e,a)){if(this.checkKey(e,"Control+v")||(e.stopPropagation(),e.preventDefault()),typeof r=="function"&&r(a,[...this.mindMap.renderer.activeNodeList]))return;this.shortcutMap[a].forEach(o=>{o()})}}))}checkKey(e,t){let r=this.getOriginEventCodeArr(e),n=this.getKeyCodeArr(t);if(r.length!==n.length)return!1;for(let s=0;so===r[s]);if(a===-1)return!1;n.splice(a,1)}return!0}getOriginEventCodeArr(e){let t=[];return(e.ctrlKey||e.metaKey)&&t.push(En.Control),e.altKey&&t.push(En.Alt),e.shiftKey&&t.push(En.Shift),t.includes(e.keyCode)||t.push(e.keyCode),t}hasCombinationKey(e){return e.ctrlKey||e.metaKey||e.altKey||e.shiftKey}getKeyCodeArr(e){let t=e.split(/\s*\+\s*/),r=[];return t.forEach(n=>{r.push(En[n])}),r}addShortcut(e,t){e.split(/\s*\|\s*/).forEach(r=>{this.shortcutMap[r]?this.shortcutMap[r].push(t):this.shortcutMap[r]=[t]})}removeShortcut(e,t){e.split(/\s*\|\s*/).forEach(r=>{if(this.shortcutMap[r])if(t){let n=this.shortcutMap[r].findIndex(s=>s===t);n!==-1&&this.shortcutMap[r].splice(n,1)}else this.shortcutMap[r]=[],delete this.shortcutMap[r]})}getShortcutFn(e){let t=[];return e.split(/\s*\|\s*/).forEach(r=>{t=this.shortcutMap[r]||[]}),t}}});var xv,gv=M(()=>{xv={name:"simple-mind-map",version:"0.14.0-fix.1",description:"\u4E00\u4E2A\u7B80\u5355\u7684web\u5728\u7EBF\u601D\u7EF4\u5BFC\u56FE",authors:[{name:"\u8857\u89D2\u5C0F\u6797",email:"1013335014@qq.com"},{name:"\u7406\u60F3\u9752\u5E74\u5B9E\u9A8C\u5BA4",url:"http://lxqnsys.com/"}],types:"./types/index.d.ts",typings:"./types/index.d.ts",license:"MIT",repository:{type:"git",url:"https://github.com/wanglin2/mind-map"},scripts:{lint:"eslint src/",format:"prettier --write .",types:"npx -p typescript tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types --target es2017 --skipLibCheck & node ./bin/createPluginsTypeFiles.js",wsServe:"node ./bin/wsServer.mjs"},module:"index.js",main:"./dist/simpleMindMap.umd.min.js",dependencies:{"@svgdotjs/svg.js":"3.2.0",deepmerge:"^1.5.2",eventemitter3:"^4.0.7",jszip:"^3.10.1",katex:"^0.16.8","mdast-util-from-markdown":"^1.3.0","pdf-lib":"^1.17.1",quill:"^2.0.3",tern:"^0.24.3",uuid:"^9.0.0",ws:"^7.5.9","xml-js":"^1.6.11","y-webrtc":"^10.2.5",yjs:"^13.6.8"},keywords:["javascript","svg","mind-map","mindMap","MindMap"],devDependencies:{eslint:"^8.25.0",prettier:"^2.7.1"}}});var Em,vv,yv=M(()=>{he();Oe();gv();Em=class{constructor(e={}){this.opt=e,this.mindMap=e.mindMap,this.commands={},this.history=[],this.activeHistoryIndex=0,this.registerShortcutKeys(),this.originAddHistory=this.addHistory.bind(this),this.addHistory=mi(this.addHistory,this.mindMap.opt.addHistoryTime,this),this.isPause=!1}pause(){this.isPause=!0}recovery(){this.isPause=!1}clearHistory(){this.history=[],this.activeHistoryIndex=0,this.mindMap.emit("back_forward",0,0)}registerShortcutKeys(){this.mindMap.keyCommand.addShortcut("Control+z",()=>{this.mindMap.execCommand("BACK")}),this.mindMap.keyCommand.addShortcut("Control+y",()=>{this.mindMap.execCommand("FORWARD")})}exec(e,...t){if(this.commands[e]){if(this.commands[e].forEach(r=>{r(...t)}),this.mindMap.emit("afterExecCommand",e,...t),["BACK","FORWARD","SET_NODE_ACTIVE","CLEAR_ACTIVE_NODE"].includes(e))return;this.addHistory()}}add(e,t){this.commands[e]?this.commands[e].push(t):this.commands[e]=[t]}remove(e,t){if(this.commands[e])if(!t)this.commands[e]=[],delete this.commands[e];else{let r=this.commands[e].find(n=>n===t);r!==-1&&this.commands[e].splice(r,1)}}addHistory(){if(this.mindMap.opt.readonly||this.isPause)return;this.mindMap.emit("beforeAddHistory");let e=this.history.length>0?this.history[this.activeHistoryIndex]:null,t=this.getCopyData(),r=JSON.stringify(t);e&&e===r||(this.emitDataUpdatesEvent(e,r),this.history=this.history.slice(0,this.activeHistoryIndex+1),this.history.push(r),this.history.length>this.mindMap.opt.maxHistoryCount&&this.history.shift(),this.activeHistoryIndex=this.history.length-1,this.mindMap.emit("data_change",t),this.mindMap.emit("back_forward",this.activeHistoryIndex,this.history.length))}back(e=1){if(!this.mindMap.opt.readonly&&this.activeHistoryIndex-e>=0){let t=this.history[this.activeHistoryIndex];this.activeHistoryIndex-=e,this.mindMap.emit("back_forward",this.activeHistoryIndex,this.history.length);let r=this.history[this.activeHistoryIndex],n=JSON.parse(r);return this.emitDataUpdatesEvent(t,r),n}}forward(e=1){if(this.mindMap.opt.readonly)return;let t=this.history.length;if(this.activeHistoryIndex+e<=t-1){let r=this.history[this.activeHistoryIndex];this.activeHistoryIndex+=e,this.mindMap.emit("back_forward",this.activeHistoryIndex,this.history.length);let n=this.history[this.activeHistoryIndex],s=JSON.parse(n);return this.emitDataUpdatesEvent(r,n),s}}getCopyData(){if(!this.mindMap.renderer.renderTree)return null;let e=cc({},this.mindMap.renderer.renderTree,!0);return e.smmVersion=xv.version,e}removeDataUid(e){e=Ft(e);let t=r=>{delete r.data.uid,r.children&&r.children.length>0&&r.children.forEach(n=>{t(n)})};return t(e),e}emitDataUpdatesEvent(e,t){try{let r="data_change_detail";if(this.mindMap.event.listenerCount(r)>0&&e&&t){let s=JSON.parse(e),a=JSON.parse(t),o=Ft(vc(s)),l=Ft(vc(a)),h=[],d=(c,f)=>(c.children&&c.children.length>0&&c.children.forEach((m,g)=>{c.children[g]=typeof m=="string"?f[m]:f[m.data.uid],d(c.children[g],f)}),c);Object.keys(l).forEach(c=>{o[c]?Ql(o[c],l[c])||h.push({action:"update",oldData:d(o[c],o),data:d(l[c],l)}):h.push({action:"create",data:d(l[c],l)})}),Object.keys(o).forEach(c=>{l[c]||h.push({action:"delete",data:d(o[c],o)})}),this.mindMap.emit(r,h)}}catch(r){this.mindMap.opt.errorHandler(di.DATA_CHANGE_DETAIL_EVENT_ERROR,r)}}},vv=Em});var Sm,bv,wv=M(()=>{he();Sm=class{constructor(){this.has={},this.queue=[],this.nextTick=Pp(this.flush,this)}push(e,t){if(this.has[e]){this.replaceTask(e,t);return}this.has[e]=!0,this.queue.push({name:e,fn:t}),this.nextTick()}replaceTask(e,t){let r=this.queue.findIndex(n=>n.name===e);r!==-1&&(this.queue[r]={name:e,fn:t})}flush(){let e=this.queue.slice(0);this.queue=[],e.forEach(({name:t,fn:r})=>{this.has[t]=!1,r()})}},bv=Sm});var Am,Mv=M(()=>{Oe();Am={el:null,data:null,viewData:null,readonly:!1,layout:A.LAYOUT.LOGICAL_STRUCTURE,fishboneDeg:45,theme:"default",themeConfig:{},scaleRatio:.2,translateRatio:1,minZoomRatio:20,maxZoomRatio:400,customCheckIsTouchPad:null,mouseScaleCenterUseMousePosition:!0,maxTag:5,expandBtnSize:20,imgTextMargin:5,textContentMargin:2,customNoteContentShow:null,textAutoWrapWidth:500,customHandleMousewheel:null,mousewheelAction:A.MOUSE_WHEEL_ACTION.MOVE,mousewheelMoveStep:100,mousewheelZoomActionReverse:!0,defaultInsertSecondLevelNodeText:"\u4E8C\u7EA7\u8282\u70B9",defaultInsertBelowSecondLevelNodeText:"\u5206\u652F\u4E3B\u9898",expandBtnStyle:{color:"#808080",fill:"#fff",fontSize:13,strokeColor:"#333333"},expandBtnIcon:{open:"",close:""},expandBtnNumHandler:null,isShowExpandNum:!0,enableShortcutOnlyWhenMouseInSvg:!0,customCheckEnableShortcut:null,initRootNodePosition:null,nodeTextEditZIndex:3e3,nodeNoteTooltipZIndex:3e3,isEndNodeTextEditOnClickOuter:!0,maxHistoryCount:500,alwaysShowExpandBtn:!1,notShowExpandBtn:!1,iconList:[],maxNodeCacheCount:1e3,fitPadding:50,enableCtrlKeyNodeSelection:!0,useLeftKeySelectionRightKeyDrag:!1,beforeTextEdit:null,isUseCustomNodeContent:!1,customCreateNodeContent:null,customInnerElsAppendTo:null,enableAutoEnterTextEditWhenKeydown:!1,autoEmptyTextWhenKeydownEnterEdit:!1,customHandleClipboardText:null,disableMouseWheelZoom:!1,errorHandler:(i,e)=>{console.error(i,e)},enableDblclickBackToRootNode:!1,hoverRectColor:"rgb(94, 200, 248)",hoverRectPadding:2,selectTextOnEnterEditText:!1,deleteNodeActive:!0,fit:!1,tagsColorMap:{},cooperateStyle:{avatarSize:22,fontSize:12},onlyOneEnableActiveNodeOnCooperate:!1,defaultGeneralizationText:"\u6982\u8981",handleIsSplitByWrapOnPasteCreateNewNode:null,addHistoryTime:100,isDisableDrag:!1,createNewNodeBehavior:A.CREATE_NEW_NODE_BEHAVIOR.DEFAULT,defaultNodeImage:"",isLimitMindMapInCanvas:!1,handleNodePasteImg:null,customCreateNodePath:null,customCreateNodePolygon:null,customTransformNodeLinePath:null,beforeShortcutRun:null,resetScaleOnMoveNodeToCenter:!1,createNodePrefixContent:null,createNodePostfixContent:null,disabledClipboard:!1,customHyperlinkJump:null,openPerformance:!1,performanceConfig:{time:250,padding:100,removeNodeWhenOutCanvas:!0},emptyTextMeasureHeightText:"abc123\u6211\u548C\u4F60",openRealtimeRenderOnNodeTextEdit:!1,mousedownEventPreventDefault:!1,onlyPasteTextWhenHasImgAndText:!0,enableDragModifyNodeWidth:!0,minNodeTextModifyWidth:20,maxNodeTextModifyWidth:-1,customHandleLine:null,addHistoryOnInit:!0,noteIcon:{icon:"",style:{}},hyperlinkIcon:{icon:"",style:{}},attachmentIcon:{icon:"",style:{}},isShowCreateChildBtnIcon:!0,quickCreateChildBtnIcon:{icon:"",style:{}},customQuickCreateChildBtnClick:null,addCustomContentToNode:null,enableInheritAncestorLineStyle:!0,selectTranslateStep:3,selectTranslateLimit:20,enableFreeDrag:!1,autoMoveWhenMouseInEdgeOnDrag:!0,dragMultiNodeRectConfig:{width:40,height:20,fill:"rgb(94, 200, 248)"},dragPlaceholderRectFill:"rgb(94, 200, 248)",dragPlaceholderLineConfig:{color:"rgb(94, 200, 248)",width:2},dragOpacityConfig:{cloneNodeOpacity:.5,beingDragNodeOpacity:.3},handleDragCloneNode:null,beforeDragEnd:null,beforeDragStart:null,watermarkConfig:{onlyExport:!1,text:"",lineSpacing:100,textSpacing:100,angle:30,textStyle:{color:"#999",opacity:.5,fontSize:14},belowNode:!1},exportPaddingX:10,exportPaddingY:10,resetCss:` +)\r`,"g")).filter(f=>!!f);c.length>1&&t?t().then(()=>{this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE",[],c.map(f=>({data:{text:f},children:[]})))}).catch(()=>{this.mindMap.execCommand("INSERT_CHILD_NODE",!1,[],{text:o})}):this.mindMap.execCommand("INSERT_CHILD_NODE",!1,[],{text:o})}}if(l&&(!o||!s))try{let h=null;r&&typeof r=="function"?h=await r(l):h=await v2(l),this.activeNodeList.length>0&&this.activeNodeList.forEach(d=>{this.mindMap.execCommand("SET_NODE_IMAGE",d,{url:h.url,title:"",width:h.size.width,height:h.size.height})})}catch(h){e(Mi.LOAD_CLIPBOARD_IMAGE_ERROR,h)}}catch(a){e(Mi.READ_CLIPBOARD_ERROR,a)}else this.beingCopyData&&this.mindMap.execCommand("PASTE_NODE",this.beingCopyData)}insertBefore(e,t){this.insertTo(e,t,"before")}insertAfter(e,t){this.insertTo(e,t,"after")}insertTo(e,t,r="before"){let n=Ot(e);n=n.filter(s=>!s.isRoot),r==="after"&&n.reverse(),n.forEach(s=>{let a=s.parent,o=a.children,l=Ie(s,o);if(l===-1)return;o.splice(l,1),a.nodeData.children.splice(l,1);let h=t.parent,d=h.children,c=Ie(t,d);c!==-1&&(r==="after"&&c++,d.splice(c,0,s),h.nodeData.children.splice(c,0,s.nodeData))}),this.mindMap.render()}removeNode(e=[]){if(e=Ot(e),this.activeNodeList.length<=0&&e.length<=0)return;let t=null,r=e.length>0,n=r?e:this.activeNodeList,s=n.find(a=>a.isRoot);if(s)this.clearActiveNodeList(),s.children=[],s.nodeData.children=[];else{t=this.getNextActiveNode(n);for(let a=0;a0?e:this.activeNodeList;r=r.filter(s=>!s.isRoot);let n=this.getNextActiveNode(r);for(let s=0;s0?t=n[s-1]:t=r.parent}return t}copyNode(){if(this.activeNodeList.length<=0)return null;let e=ds(this.activeNodeList);return e=Fo(e),e.map(t=>ls({},t,!0))}cutNode(e){if(this.activeNodeList.length<=0)return;let t=ds(this.activeNodeList).filter(n=>!n.isRoot);t=Fo(t);let r=t.map(n=>ls({},n,!0));t.forEach(n=>{V0(n)}),this.clearActiveNodeList(),this.mindMap.render(),e&&typeof e=="function"&&e(r)}moveNodeTo(e,t){let r=Ot(e);r=r.filter(n=>!n.isRoot),r.forEach(n=>{this.removeNodeFromActiveList(n),V0(n),t.setData({expand:!0}),t.nodeData.children.push(n.nodeData)}),this.emitNodeActiveEvent(),this.mindMap.render()}pasteNode(e){e=Ot(e),this.mindMap.execCommand("INSERT_MULTI_CHILD_NODE",[],e)}setNodeStyle(e,t,r){let n={[t]:r};this.setNodeDataRender(e,n),zo.includes(t)&&(e.parent||e).renderLine(!0)}setNodeStyles(e,t){let r={...t};this.setNodeDataRender(e,r);let n=Object.keys(t),s=!1;n.forEach(a=>{zo.includes(a)&&(s=!0)}),s&&(e.parent||e).renderLine(!0)}setNodeActive(e,t){this.mindMap.execCommand("SET_NODE_DATA",e,{isActive:t}),e.updateNodeByActive(t)}setNodeExpand(e,t){this.mindMap.execCommand("SET_NODE_DATA",e,{expand:t}),this.mindMap.render()}expandAllNode(e=""){if(!this.renderTree)return;let t=(r,n)=>{!n&&r.data.uid===e&&(n=!0),n&&!r.data.expand&&(r.data.expand=!0),r.children&&r.children.length>0&&r.children.forEach(s=>{t(s,n)})};t(this.renderTree,!e),this.mindMap.render()}unexpandAllNode(e=!0,t=""){if(!this.renderTree)return;let r=(n,s,a)=>{!a&&n.data.uid===t&&(a=!0),a&&!s&&n.children&&n.children.length>0&&(n.data.expand=!1),n.children&&n.children.length>0&&n.children.forEach(o=>{r(o,!1,a)})};r(this.renderTree,!0,!t),this.mindMap.render(()=>{e&&this.setRootNodeCenter()})}expandToLevel(e){this.renderTree&&(de(this.renderTree,null,(t,r,n,s)=>{s0&&(t.data.expand=!1)},null,!0,0,0),this.mindMap.render())}toggleActiveExpand(){this.activeNodeList.forEach(e=>{e.nodeData.children.length<=0||e.isRoot||this.toggleNodeExpand(e)})}toggleNodeExpand(e){this.mindMap.execCommand("SET_NODE_EXPAND",e,!e.getData("expand"))}setNodeText(e,t,r,n){r=r===void 0?e.getData("richText"):r,this.setNodeDataRender(e,{text:t,richText:r,resetRichText:n})}setNodeImage(e,t){let{url:r,title:n,width:s,height:a,custom:o=!1}=t||{url:"",title:"",width:0,height:0,custom:!1};this.setNodeDataRender(e,{image:r,imageTitle:n||"",imageSize:{width:s,height:a,custom:o}})}setNodeIcon(e,t){this.setNodeDataRender(e,{icon:t})}setNodeHyperlink(e,t,r=""){this.setNodeDataRender(e,{hyperlink:t,hyperlinkTitle:r})}setNodeNote(e,t){this.setNodeDataRender(e,{note:t})}setNodeAttachment(e,t,r=""){this.setNodeDataRender(e,{attachmentUrl:t,attachmentName:r})}setNodeTag(e,t){this.setNodeDataRender(e,{tag:t})}insertFormula(e,t=[]){if(!this.hasRichTextPlugin()||!this.mindMap.formula)return;t=Ot(t),(t.length>0?t:this.activeNodeList).forEach(n=>{this.mindMap.formula.insertFormulaToNode(n,e)})}addGeneralization(e,t=!0){if(this.activeNodeList.length<=0)return;let r=this.activeNodeList.filter(d=>!d.isRoot&&!d.isGeneralization&&!d.checkHasSelfGeneralization()),n=A2(r);if(n.length<=0)return;let s=this.hasRichTextPlugin(),{focusNewNode:a,inserting:o}=this.getNewNodeBehavior(t,n.length>1),l=!1,h=e&&e.richText;n.forEach(d=>{let c={inserting:o,...e||{text:this.mindMap.opt.defaultGeneralizationText},range:d.range||null,uid:wt(),richText:s,isActive:a};s&&!h&&(c.resetRichText=s);let f=d.node.getData("generalization");if(f=f?Array.isArray(f)?f:[f]:[],d.range){if(!!f.find(g=>g.range&&g.range[0]===d.range[0]&&g.range[1]===d.range[1]))return;f.push(c)}else f.push(c);l=!0,this.mindMap.execCommand("SET_NODE_DATA",d.node,{generalization:f}),d.node.setData({expand:!0})}),l&&(a&&this.clearActiveNodeList(),this.mindMap.render(()=>{this.mindMap.render()}))}removeGeneralization(){this.activeNodeList.length<=0||(this.activeNodeList.forEach(e=>{e.checkHasGeneralization()&&this.mindMap.execCommand("SET_NODE_DATA",e,{generalization:null})}),this.mindMap.render(),this.closeHighlightNode())}setNodeCustomPosition(e,t=void 0,r=void 0){[e].forEach(s=>{this.mindMap.execCommand("SET_NODE_DATA",s,{customLeft:t,customTop:r})})}resetLayout(){de(this.root,null,e=>{e.customLeft=void 0,e.customTop=void 0,this.mindMap.execCommand("SET_NODE_DATA",e,{customLeft:void 0,customTop:void 0}),this.mindMap.render()},null,!0,0,0)}setNodeShape(e,t){if(!t||!P2.includes(t))return;[e].forEach(n=>{this.setNodeStyle(n,"shape",t)})}goTargetNode(e,t=()=>{}){let r=typeof e=="string"?e:e.getData("uid");r&&this.expandToNodeUid(r,()=>{let n=this.findNodeByUid(r);n&&(n.active(),this.moveNodeToCenter(n),t(n))})}setNodeData(e,t){Object.keys(t).forEach(r=>{e.nodeData.data[r]=t[r]})}setNodeDataRender(e,t,r=!1){if(this.mindMap.execCommand("SET_NODE_DATA",e,t),E2(t)){this.mindMap.emit("node_tree_render_end");return}this.reRenderNodeCheckChange(e,r)}reRenderNodeCheckChange(e,t){e.reRender()?t||this.mindMap.render():this.mindMap.emit("node_tree_render_end")}moveNodeToCenter(e,t){let{resetScaleOnMoveNodeToCenter:r}=this.mindMap.opt;t!==void 0&&(r=t);let{transform:n,state:s}=this.mindMap.view.getTransformData(),{left:a,top:o,width:l,height:h}=e;r||(a*=n.scaleX,o*=n.scaleY,l*=n.scaleX,h*=n.scaleY);let d=this.mindMap.width/2,c=this.mindMap.height/2,f=a+l/2,m=o+h/2,g=d-s.x,x=c-s.y,y=g-f,b=x-m;this.mindMap.view.translateX(y),this.mindMap.view.translateY(b),r&&this.mindMap.view.setScale(1)}setRootNodeCenter(){this.moveNodeToCenter(this.root)}expandToNodeUid(e,t=()=>{}){if(!this.renderTree){t();return}let r=[],n=!1,s={};Xt(this.renderTree,(o,l)=>{if(o.data.uid===e)return r=l?[...s[l.data.uid],l]:[],"stop";if(us(o.data).forEach(d=>{d.uid===e&&(r=l?[...s[l.data.uid],l,o]:[],n=!0)}),n)return"stop";s[o.data.uid]=l?[...s[l.data.uid],l]:[]});let a=!1;if(r.forEach(o=>{o.data.expand||(a=!0,o.data.expand=!0)}),n){let o=r[r.length-1];o&&de(o,null,l=>{l.data.expand||(a=!0,l.data.expand=!0)})}a?this.mindMap.render(t):t()}findNodeByUid(e){if(!this.root)return;let t=null;return de(this.root,null,r=>{if(r.getData("uid")===e)return t=r,!0;let n=!1;if((r._generalizationList||[]).forEach(s=>{s.generalizationNode.getData("uid")===e&&(t=s.generalizationNode,n=!0)}),n)return!0}),t}highlightNode(e,t,r){if(this.isRendering)return;r={stroke:"rgb(94, 200, 248)",fill:"transparent",...r||{}},this.highlightBoxNode?this.highlightBoxNodeStyle&&(this.highlightBoxNodeStyle.stroke!==r.stroke||this.highlightBoxNodeStyle.fill!==r.fill)&&this.highlightBoxNode.stroke({color:r.stroke||"transparent"}).fill({color:r.fill||"transparent"}):this.highlightBoxNode=new Gi().stroke({color:r.stroke||"transparent"}).fill({color:r.fill||"transparent"}),this.highlightBoxNodeStyle={...r};let n=1/0,s=1/0,a=-1/0,o=-1/0;t?e.children.slice(t[0],t[1]+1).forEach(h=>{h.lefta&&(a=d),c>o&&(o=c)}):(n=e.left,s=e.top,a=e.left+e.width,o=e.top+e.height),this.highlightBoxNode.plot([[n,s],[a,s],[a,o],[n,o]]),this.mindMap.otherDraw.add(this.highlightBoxNode)}closeHighlightNode(){this.highlightBoxNode&&this.highlightBoxNode.remove()}hasRichTextPlugin(){return!!this.mindMap.richText}},jv=Np});var jn,Vv=T(()=>{Ro();jn={default:B0}});var Ep,Gn,Wv=T(()=>{Ep={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,CapsLock:20,Esc:27,Spacebar:32,PageUp:33,PageDown:34,End:35,Home:36,Insert:45,Left:37,Up:38,Right:39,Down:40,Del:46,NumLock:144,Cmd:91,CmdFF:224,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,"`":192,"=":187,"-":189,"/":191,".":190};for(let i=0;i<=9;i++)Ep[i]=i+48;"abcdefghijklmnopqrstuvwxyz".split("").forEach((i,e)=>{Ep[i]=e+65});Gn=Ep});var h0,Yv=T(()=>{Wv();h0=class{constructor(e){this.opt=e,this.mindMap=e.mindMap,this.shortcutMap={},this.shortcutMapCache={},this.isPause=!1,this.isInSvg=!1,this.isStopCheckInSvg=!1,this.defaultEnableCheck=this.defaultEnableCheck.bind(this),this.bindEvent()}extendKeyMap(e,t){Gn[e]=t}removeKeyMap(e){typeof Gn[e]<"u"&&delete Gn[e]}pause(){this.isPause=!0}recovery(){this.isPause=!1}save(){Object.keys(this.shortcutMapCache).length>0||(this.shortcutMapCache=this.shortcutMap,this.shortcutMap={})}restore(){Object.keys(this.shortcutMapCache).length<=0||(this.shortcutMap=this.shortcutMapCache,this.shortcutMapCache={})}stopCheckInSvg(){let{enableShortcutOnlyWhenMouseInSvg:e}=this.mindMap.opt;e&&(this.isStopCheckInSvg=!0)}recoveryCheckInSvg(){let{enableShortcutOnlyWhenMouseInSvg:e}=this.mindMap.opt;e&&(this.isStopCheckInSvg=!0)}bindEvent(){this.onKeydown=this.onKeydown.bind(this),this.mindMap.on("svg_mouseenter",()=>{this.isInSvg=!0}),this.mindMap.on("svg_mouseleave",()=>{this.isInSvg=!1}),window.addEventListener("keydown",this.onKeydown),this.mindMap.on("beforeDestroy",()=>{this.unBindEvent()})}unBindEvent(){window.removeEventListener("keydown",this.onKeydown)}defaultEnableCheck(e){let t=e.target;if(t===document.body)return!0;for(let r=0;r{if(this.checkKey(e,a)){if(this.checkKey(e,"Control+v")||(e.stopPropagation(),e.preventDefault()),typeof r=="function"&&r(a,[...this.mindMap.renderer.activeNodeList]))return;this.shortcutMap[a].forEach(o=>{o()})}}))}checkKey(e,t){let r=this.getOriginEventCodeArr(e),n=this.getKeyCodeArr(t);if(r.length!==n.length)return!1;for(let s=0;so===r[s]);if(a===-1)return!1;n.splice(a,1)}return!0}getOriginEventCodeArr(e){let t=[];return(e.ctrlKey||e.metaKey)&&t.push(Gn.Control),e.altKey&&t.push(Gn.Alt),e.shiftKey&&t.push(Gn.Shift),t.includes(e.keyCode)||t.push(e.keyCode),t}hasCombinationKey(e){return e.ctrlKey||e.metaKey||e.altKey||e.shiftKey}getKeyCodeArr(e){let t=e.split(/\s*\+\s*/),r=[];return t.forEach(n=>{r.push(Gn[n])}),r}addShortcut(e,t){e.split(/\s*\|\s*/).forEach(r=>{this.shortcutMap[r]?this.shortcutMap[r].push(t):this.shortcutMap[r]=[t]})}removeShortcut(e,t){e.split(/\s*\|\s*/).forEach(r=>{if(this.shortcutMap[r])if(t){let n=this.shortcutMap[r].findIndex(s=>s===t);n!==-1&&this.shortcutMap[r].splice(n,1)}else this.shortcutMap[r]=[],delete this.shortcutMap[r]})}getShortcutFn(e){let t=[];return e.split(/\s*\|\s*/).forEach(r=>{t=this.shortcutMap[r]||[]}),t}}});var Kv,Xv=T(()=>{Kv={name:"simple-mind-map",version:"0.14.0-fix.1",description:"\u4E00\u4E2A\u7B80\u5355\u7684web\u5728\u7EBF\u601D\u7EF4\u5BFC\u56FE",authors:[{name:"\u8857\u89D2\u5C0F\u6797",email:"1013335014@qq.com"},{name:"\u7406\u60F3\u9752\u5E74\u5B9E\u9A8C\u5BA4",url:"http://lxqnsys.com/"}],types:"./types/index.d.ts",typings:"./types/index.d.ts",license:"MIT",repository:{type:"git",url:"https://github.com/wanglin2/mind-map"},scripts:{lint:"eslint src/",format:"prettier --write .",types:"npx -p typescript tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types --target es2017 --skipLibCheck & node ./bin/createPluginsTypeFiles.js",wsServe:"node ./bin/wsServer.mjs"},module:"index.js",main:"./dist/simpleMindMap.umd.min.js",dependencies:{"@svgdotjs/svg.js":"3.2.0",deepmerge:"^1.5.2",eventemitter3:"^4.0.7",jszip:"^3.10.1",katex:"^0.16.8","mdast-util-from-markdown":"^1.3.0","pdf-lib":"^1.17.1",quill:"^2.0.3",tern:"^0.24.3",uuid:"^9.0.0",ws:"^7.5.9","xml-js":"^1.6.11","y-webrtc":"^10.2.5",yjs:"^13.6.8"},keywords:["javascript","svg","mind-map","mindMap","MindMap"],devDependencies:{eslint:"^8.25.0",prettier:"^2.7.1"}}});var Sp,Zv,Qv=T(()=>{pe();$e();Xv();Sp=class{constructor(e={}){this.opt=e,this.mindMap=e.mindMap,this.commands={},this.history=[],this.activeHistoryIndex=0,this.registerShortcutKeys(),this.originAddHistory=this.addHistory.bind(this),this.addHistory=Si(this.addHistory,this.mindMap.opt.addHistoryTime,this),this.isPause=!1}pause(){this.isPause=!0}recovery(){this.isPause=!1}clearHistory(){this.history=[],this.activeHistoryIndex=0,this.mindMap.emit("back_forward",0,0)}registerShortcutKeys(){this.mindMap.keyCommand.addShortcut("Control+z",()=>{this.mindMap.execCommand("BACK")}),this.mindMap.keyCommand.addShortcut("Control+y",()=>{this.mindMap.execCommand("FORWARD")})}exec(e,...t){if(this.commands[e]){if(this.commands[e].forEach(r=>{r(...t)}),this.mindMap.emit("afterExecCommand",e,...t),["BACK","FORWARD","SET_NODE_ACTIVE","CLEAR_ACTIVE_NODE"].includes(e))return;this.addHistory()}}add(e,t){this.commands[e]?this.commands[e].push(t):this.commands[e]=[t]}remove(e,t){if(this.commands[e])if(!t)this.commands[e]=[],delete this.commands[e];else{let r=this.commands[e].find(n=>n===t);r!==-1&&this.commands[e].splice(r,1)}}addHistory(){if(this.mindMap.opt.readonly||this.isPause)return;this.mindMap.emit("beforeAddHistory");let e=this.history.length>0?this.history[this.activeHistoryIndex]:null,t=this.getCopyData(),r=JSON.stringify(t);e&&e===r||(this.emitDataUpdatesEvent(e,r),this.history=this.history.slice(0,this.activeHistoryIndex+1),this.history.push(r),this.history.length>this.mindMap.opt.maxHistoryCount&&this.history.shift(),this.activeHistoryIndex=this.history.length-1,this.mindMap.emit("data_change",t),this.mindMap.emit("back_forward",this.activeHistoryIndex,this.history.length))}back(e=1){if(!this.mindMap.opt.readonly&&this.activeHistoryIndex-e>=0){let t=this.history[this.activeHistoryIndex];this.activeHistoryIndex-=e,this.mindMap.emit("back_forward",this.activeHistoryIndex,this.history.length);let r=this.history[this.activeHistoryIndex],n=JSON.parse(r);return this.emitDataUpdatesEvent(t,r),n}}forward(e=1){if(this.mindMap.opt.readonly)return;let t=this.history.length;if(this.activeHistoryIndex+e<=t-1){let r=this.history[this.activeHistoryIndex];this.activeHistoryIndex+=e,this.mindMap.emit("back_forward",this.activeHistoryIndex,this.history.length);let n=this.history[this.activeHistoryIndex],s=JSON.parse(n);return this.emitDataUpdatesEvent(r,n),s}}getCopyData(){if(!this.mindMap.renderer.renderTree)return null;let e=uu({},this.mindMap.renderer.renderTree,!0);return e.smmVersion=Kv.version,e}removeDataUid(e){e=Kt(e);let t=r=>{delete r.data.uid,r.children&&r.children.length>0&&r.children.forEach(n=>{t(n)})};return t(e),e}emitDataUpdatesEvent(e,t){try{let r="data_change_detail";if(this.mindMap.event.listenerCount(r)>0&&e&&t){let s=JSON.parse(e),a=JSON.parse(t),o=Kt(vu(s)),l=Kt(vu(a)),h=[],d=(c,f)=>(c.children&&c.children.length>0&&c.children.forEach((m,g)=>{c.children[g]=typeof m=="string"?f[m]:f[m.data.uid],d(c.children[g],f)}),c);Object.keys(l).forEach(c=>{o[c]?H0(o[c],l[c])||h.push({action:"update",oldData:d(o[c],o),data:d(l[c],l)}):h.push({action:"create",data:d(l[c],l)})}),Object.keys(o).forEach(c=>{l[c]||h.push({action:"delete",data:d(o[c],o)})}),this.mindMap.emit(r,h)}}catch(r){this.mindMap.opt.errorHandler(Mi.DATA_CHANGE_DETAIL_EVENT_ERROR,r)}}},Zv=Sp});var Ap,Jv,eb=T(()=>{pe();Ap=class{constructor(){this.has={},this.queue=[],this.nextTick=x2(this.flush,this)}push(e,t){if(this.has[e]){this.replaceTask(e,t);return}this.has[e]=!0,this.queue.push({name:e,fn:t}),this.nextTick()}replaceTask(e,t){let r=this.queue.findIndex(n=>n.name===e);r!==-1&&(this.queue[r]={name:e,fn:t})}flush(){let e=this.queue.slice(0);this.queue=[],e.forEach(({name:t,fn:r})=>{this.has[t]=!1,r()})}},Jv=Ap});var kp,tb=T(()=>{$e();kp={el:null,data:null,viewData:null,readonly:!1,layout:k.LAYOUT.LOGICAL_STRUCTURE,fishboneDeg:45,theme:"default",themeConfig:{},scaleRatio:.2,translateRatio:1,minZoomRatio:20,maxZoomRatio:400,customCheckIsTouchPad:null,mouseScaleCenterUseMousePosition:!0,maxTag:5,expandBtnSize:20,imgTextMargin:5,textContentMargin:2,customNoteContentShow:null,textAutoWrapWidth:500,customHandleMousewheel:null,mousewheelAction:k.MOUSE_WHEEL_ACTION.MOVE,mousewheelMoveStep:100,mousewheelZoomActionReverse:!0,defaultInsertSecondLevelNodeText:"\u4E8C\u7EA7\u8282\u70B9",defaultInsertBelowSecondLevelNodeText:"\u5206\u652F\u4E3B\u9898",expandBtnStyle:{color:"#808080",fill:"#fff",fontSize:13,strokeColor:"#333333"},expandBtnIcon:{open:"",close:""},expandBtnNumHandler:null,isShowExpandNum:!0,enableShortcutOnlyWhenMouseInSvg:!0,customCheckEnableShortcut:null,initRootNodePosition:null,nodeTextEditZIndex:3e3,nodeNoteTooltipZIndex:3e3,isEndNodeTextEditOnClickOuter:!0,maxHistoryCount:500,alwaysShowExpandBtn:!1,notShowExpandBtn:!1,iconList:[],maxNodeCacheCount:1e3,fitPadding:50,enableCtrlKeyNodeSelection:!0,useLeftKeySelectionRightKeyDrag:!1,beforeTextEdit:null,isUseCustomNodeContent:!1,customCreateNodeContent:null,customInnerElsAppendTo:null,enableAutoEnterTextEditWhenKeydown:!1,autoEmptyTextWhenKeydownEnterEdit:!1,customHandleClipboardText:null,disableMouseWheelZoom:!1,errorHandler:(i,e)=>{console.error(i,e)},enableDblclickBackToRootNode:!1,hoverRectColor:"rgb(94, 200, 248)",hoverRectPadding:2,selectTextOnEnterEditText:!1,deleteNodeActive:!0,fit:!1,tagsColorMap:{},cooperateStyle:{avatarSize:22,fontSize:12},onlyOneEnableActiveNodeOnCooperate:!1,defaultGeneralizationText:"\u6982\u8981",handleIsSplitByWrapOnPasteCreateNewNode:null,addHistoryTime:100,isDisableDrag:!1,createNewNodeBehavior:k.CREATE_NEW_NODE_BEHAVIOR.DEFAULT,defaultNodeImage:"",isLimitMindMapInCanvas:!1,handleNodePasteImg:null,customCreateNodePath:null,customCreateNodePolygon:null,customTransformNodeLinePath:null,beforeShortcutRun:null,resetScaleOnMoveNodeToCenter:!1,createNodePrefixContent:null,createNodePostfixContent:null,disabledClipboard:!1,customHyperlinkJump:null,openPerformance:!1,performanceConfig:{time:250,padding:100,removeNodeWhenOutCanvas:!0},emptyTextMeasureHeightText:"abc123\u6211\u548C\u4F60",openRealtimeRenderOnNodeTextEdit:!1,mousedownEventPreventDefault:!1,onlyPasteTextWhenHasImgAndText:!0,enableDragModifyNodeWidth:!0,minNodeTextModifyWidth:20,maxNodeTextModifyWidth:-1,customHandleLine:null,addHistoryOnInit:!0,noteIcon:{icon:"",style:{}},hyperlinkIcon:{icon:"",style:{}},attachmentIcon:{icon:"",style:{}},isShowCreateChildBtnIcon:!0,quickCreateChildBtnIcon:{icon:"",style:{}},customQuickCreateChildBtnClick:null,addCustomContentToNode:null,enableInheritAncestorLineStyle:!0,selectTranslateStep:3,selectTranslateLimit:20,enableFreeDrag:!1,autoMoveWhenMouseInEdgeOnDrag:!0,dragMultiNodeRectConfig:{width:40,height:20,fill:"rgb(94, 200, 248)"},dragPlaceholderRectFill:"rgb(94, 200, 248)",dragPlaceholderLineConfig:{color:"rgb(94, 200, 248)",width:2},dragOpacityConfig:{cloneNodeOpacity:.5,beingDragNodeOpacity:.3},handleDragCloneNode:null,beforeDragEnd:null,beforeDragStart:null,watermarkConfig:{onlyExport:!1,text:"",lineSpacing:100,textSpacing:100,angle:30,textStyle:{color:"#999",opacity:.5,fontSize:14},belowNode:!1},exportPaddingX:10,exportPaddingY:10,resetCss:` * { margin: 0; padding: 0; box-sizing: border-box; } - `,minExportImgCanvasScale:2,addContentToHeader:null,addContentToFooter:null,handleBeingExportSvg:null,maxCanvasSize:16384,defaultAssociativeLineText:"\u5173\u8054",associativeLineIsAlwaysAboveNode:!0,associativeLineInitPointsPosition:{from:"",to:""},enableAdjustAssociativeLinePoints:!0,beforeAssociativeLineConnection:null,disableTouchZoom:!1,minTouchZoomScale:20,maxTouchZoomScale:-1,isLimitMindMapInCanvasWhenHasScrollbar:!0,isOnlySearchCurrentRenderNodes:!1,beforeCooperateUpdate:null,rainbowLinesConfig:{open:!1,colorsList:[]},demonstrateConfig:null,enableEditFormulaInRichTextEdit:!0,katexFontPath:"https://unpkg.com/katex@0.16.11/dist/",getKatexOutputType:null,transformRichTextOnEnterEdit:null,beforeHideRichTextEdit:null,outerFramePaddingX:10,outerFramePaddingY:10,defaultOuterFrameText:"\u5916\u6846",onlyPainterNodeCustomStyles:!1,beforeDeleteNodeImg:null,imgResizeBtnSize:25,minImgResizeWidth:50,minImgResizeHeight:50,maxImgResizeWidthInheritTheme:!1,maxImgResizeWidth:1/0,maxImgResizeHeight:1/0,customDeleteBtnInnerHTML:"",customResizeBtnInnerHTML:""}});var Tv={};ti(Tv,{default:()=>SO});var km,bt,Cm,SO,Nv=M(()=>{jx();Xx();uv();km=ot(Wl());fv();s0();pv();yv();wv();Oe();ht();he();io();Mv();bt=class i{constructor(e={}){if(i.instanceCount++,this.opt=this.handleOpt((0,km.default)(Am,e)),this.opt.data=this.handleData(this.opt.data),this.el=this.opt.el,!this.el)throw new Error("\u7F3A\u5C11\u5BB9\u5668\u5143\u7D20el");this.getElRectInfo(),this.initWidth=this.width,this.initHeight=this.height,this.cssEl=null,this.cssTextMap={},this.nodeInnerPrefixList=[],this.nodeInnerPostfixList=[],this.editNodeClassList=[],this.extendShapeList=[],this.initContainer(),this.initTheme(),this.initCache(),i.pluginList.filter(t=>t.preload).forEach(t=>{this.initPlugin(t)}),this.event=new Vx({mindMap:this}),this.keyCommand=new zl({mindMap:this}),this.command=new vv({mindMap:this}),this.renderer=new cv({mindMap:this}),this.view=new $x({mindMap:this}),this.batchExecution=new bv,i.pluginList.filter(t=>!t.preload).forEach(t=>{this.initPlugin(t)}),this.addCss(),this.render(this.opt.fit?()=>this.view.fit():()=>{}),this.opt.addHistoryOnInit&&this.opt.data&&this.command.addHistory()}handleOpt(e){return Ud.includes(e.layout)||(e.layout=A.LAYOUT.LOGICAL_STRUCTURE),e.theme=e.theme&&Nn[e.theme]?e.theme:"default",e}handleData(e){return Bt(e)||Object.keys(e).length<=0?null:(e=Ft(e||{}),e.data&&!e.data.expand&&(e.data.expand=!0),qn([e],!1,null,!0),e)}initContainer(){let{associativeLineIsAlwaysAboveNode:e}=this.opt;this.el.classList.add("smm-mind-map-container");let t=()=>{this.associativeLineDraw=this.draw.group(),this.associativeLineDraw.addClass("smm-associative-line-container")};this.svg=Me().addTo(this.el).size(this.width,this.height),this.draw=this.svg.group(),this.draw.addClass("smm-container"),this.lineDraw=this.draw.group(),this.lineDraw.addClass("smm-line-container"),e||t(),this.nodeDraw=this.draw.group(),this.nodeDraw.addClass("smm-node-container"),e&&t(),this.otherDraw=this.draw.group(),this.otherDraw.addClass("smm-other-container")}clearDraw(){this.lineDraw.clear(),this.associativeLineDraw.clear(),this.nodeDraw.clear(),this.otherDraw.clear()}appendCss(e,t){this.cssTextMap[e]=t,this.removeCss(),this.addCss()}removeAppendCss(e){this.cssTextMap[e]&&(delete this.cssTextMap[e],this.removeCss(),this.addCss())}joinCss(){return Km+Object.keys(this.cssTextMap).map(e=>this.cssTextMap[e]).join(` -`)}addCss(){this.cssEl=document.createElement("style"),this.cssEl.type="text/css",this.cssEl.innerHTML=this.joinCss(),document.head.appendChild(this.cssEl)}removeCss(){this.cssEl&&document.head.removeChild(this.cssEl)}checkEditNodeClassIndex(e){return this.editNodeClassList.findIndex(t=>t===e)}addEditNodeClass(e){this.checkEditNodeClassIndex(e)===-1&&this.editNodeClassList.push(e)}deleteEditNodeClass(e){let t=this.checkEditNodeClassIndex(e);t!==-1&&this.editNodeClassList.splice(t,1)}render(e,t=""){this.initTheme(),this.renderer.render(e,t)}reRender(e,t=""){this.renderer.reRender=!0,this.renderer.clearCache(),this.clearDraw(),this.render(e,t)}getElRectInfo(){if(this.elRect=this.el.getBoundingClientRect(),this.width=this.elRect.width,this.height=this.elRect.height,this.width<=0||this.height<=0)throw new Error("\u5BB9\u5668\u5143\u7D20el\u7684\u5BBD\u9AD8\u4E0D\u80FD\u4E3A0")}resize(){let e=this.width,t=this.height;this.getElRectInfo(),this.svg.size(this.width,this.height),(e!==this.width||t!==this.height)&&(this.demonstrate?this.demonstrate.isInDemonstrate||this.render():this.render()),this.emit("resize")}on(e,t){this.event.on(e,t)}emit(e,...t){this.event.emit(e,...t)}off(e,t){this.event.off(e,t)}initCache(){this.commonCaches={measureCustomNodeContentSizeEl:null,measureRichtextNodeTextSizeEl:null}}initTheme(){this.themeConfig=bc(Nn[this.opt.theme]||Nn.default,this.opt.themeConfig),lo.setBackgroundStyle(this.el,this.themeConfig)}setTheme(e,t=!1){this.execCommand("CLEAR_ACTIVE_NODE"),this.opt.theme=e,t||this.render(null,A.CHANGE_THEME),this.emit("view_theme_change",e)}getTheme(){return this.opt.theme}setThemeConfig(e,t=!1){let r=Gp(this.themeConfig,e);if(this.opt.themeConfig=e,!t){let n=Ip(r);this.render(null,n?"":A.CHANGE_THEME)}}getCustomThemeConfig(){return this.opt.themeConfig}getThemeConfig(e){return e===void 0?this.themeConfig:this.themeConfig[e]}getConfig(e){return e===void 0?this.opt:this.opt[e]}updateConfig(e={}){this.emit("before_update_config",this.opt);let t={...this.opt};this.opt=this.handleOpt(km.default.all([Am,this.opt,e])),this.emit("after_update_config",this.opt,t)}getLayout(){return this.opt.layout}setLayout(e,t=!1){Ud.includes(e)||(e=A.LAYOUT.LOGICAL_STRUCTURE),this.opt.layout=e,this.view.reset(),this.renderer.setLayout(),t||this.render(null,A.CHANGE_LAYOUT),this.emit("layout_change",e)}execCommand(...e){this.command.exec(...e)}updateData(e){e=this.handleData(e),this.emit("before_update_data",e),this.renderer.setData(e),this.render(),this.command.addHistory(),this.emit("update_data",e)}setData(e){e=this.handleData(e),this.emit("before_set_data",e),this.opt.data=e,this.execCommand("CLEAR_ACTIVE_NODE"),this.command.clearHistory(),this.command.addHistory(),this.renderer.setData(e),this.reRender(),this.emit("set_data",e)}setFullData(e){e.root&&this.setData(e.root),e.layout&&this.setLayout(e.layout),e.theme&&(e.theme.template&&this.setTheme(e.theme.template),e.theme.config&&this.setThemeConfig(e.theme.config)),e.view&&this.view.setTransformData(e.view)}getData(e){let t=this.command.getCopyData(),r={};return e?r={layout:this.getLayout(),root:t,theme:{template:this.getTheme(),config:this.getCustomThemeConfig()},view:this.view.getTransformData()}:r=t,Ft(r)}async export(...e){try{if(!this.doExport)throw new Error("\u8BF7\u6CE8\u518CExport\u63D2\u4EF6\uFF01");return await this.doExport.export(...e)}catch(t){this.opt.errorHandler(di.EXPORT_ERROR,t)}}toPos(e,t){return{x:e-this.elRect.left,y:t-this.elRect.top}}setMode(e){if(![A.MODE.READONLY,A.MODE.EDIT].includes(e))return;let t=e===A.MODE.READONLY;t!==this.opt.readonly&&(t&&(this.renderer.textEdit.isShowTextEdit()&&(this.renderer.textEdit.hideEditTextBox(),this.command.originAddHistory()),this.execCommand("CLEAR_ACTIVE_NODE")),this.opt.readonly=t,!t&&this.command.history.length<=0&&this.command.originAddHistory(),this.emit("mode_change",e))}getSvgData({paddingX:e=0,paddingY:t=0,ignoreWatermark:r=!1,addContentToHeader:n,addContentToFooter:s,node:a}={}){let{watermarkConfig:o,openPerformance:l}=this.opt;l&&this.renderer.forceLoadNode(a);let{cssTextList:h,header:d,headerHeight:c,footer:f,footerHeight:m}=t3({addContentToHeader:n,addContentToFooter:s}),g=this.svg,x=this.draw,v=g.width(),b=g.height(),E=x.transform(),S=this.elRect;x.scale(1/E.scaleX,1/E.scaleY);let C=x.rbox(),_=null;a&&(_=yc(a,C.x,C.y,e,t));let I=0;C.width+=e*2,C.height+=t*2+I+c+m,x.translate(e,t),g.size(C.width,C.height),x.translate(-C.x+S.left,-C.y+S.top);let O=g.clone(),D=this.watermark&&this.watermark.hasWatermark();if(!r&&D){this.watermark.isInExport=!0;let{onlyExport:Z}=o;C.width>v||C.height>b?(this.width=C.width,this.height=C.height,this.watermark.onResize(),O=g.clone(),this.width=v,this.height=b,this.watermark.onResize()):Z&&(this.watermark.onResize(),O=g.clone()),Z&&this.watermark.clear(),this.watermark.isInExport=!1}[this.joinCss(),...h].forEach(Z=>{O.add(Me(``))}),d&&c>0&&(O.findOne(".smm-container").translate(0,c),d.width(C.width),d.y(t),O.add(d,0)),f&&m>0&&(f.width(C.width),f.y(C.height-t-m),O.add(f));let $=g.find("defs"),F=O.find("defs");return $.forEach((Z,re)=>{let ye=F[re];if(!ye)return;let G=Z.children(),W=ye.children();for(let ee=0;eer.name===e.name)||this.extendShapeList.push(e)}removeShape(e){let t=this.extendShapeList.findIndex(r=>r.name===e);t!==-1&&this.extendShapeList.splice(t,1)}getSvgObjects(){return{SVG:Me,G:Ne,Rect:Pe}}addPlugin(e,t){i.hasPlugin(e)===-1&&i.usePlugin(e,t),this.initPlugin(e)}removePlugin(e){let t=i.hasPlugin(e);t!==-1&&(i.pluginList.splice(t,1),this[e.instanceName]&&(this[e.instanceName].beforePluginRemove&&this[e.instanceName].beforePluginRemove(),delete this[e.instanceName]))}initPlugin(e){this[e.instanceName]||(this[e.instanceName]=new e({mindMap:this,pluginOpt:e.pluginOpt}))}destroy(){this.emit("beforeDestroy"),this.renderer.textEdit.hideEditTextBox(),this.renderer.textEdit.removeTextEditEl(),[...i.pluginList].forEach(e=>{this[e.instanceName]&&this[e.instanceName].beforePluginDestroy&&this[e.instanceName].beforePluginDestroy(),this[e.instanceName]=null}),this.event.unbind(),this.svg.remove(),lo.removeBackgroundStyle(this.el),this.el.classList.remove("smm-mind-map-container"),this.el.innerHTML="",this.el=null,this.removeCss(),i.instanceCount--}},Cm=[];bt.extendNodeDataNoStylePropList=(i=[])=>{Cm.push(...i),us.push(...i)};bt.resetNodeDataNoStylePropList=()=>{Cm.forEach(i=>{let e=us.findIndex(t=>t===i);e!==-1&&us.splice(e,1)}),Cm=[]};bt.pluginList=[];bt.usePlugin=(i,e={})=>(bt.hasPlugin(i)!==-1||(i.pluginOpt=e,bt.pluginList.push(i)),bt);bt.hasPlugin=i=>bt.pluginList.findIndex(e=>e===i);bt.instanceCount=0;bt.defineTheme=(i,e={})=>{if(Nn[i])return new Error("\u8BE5\u4E3B\u9898\u540D\u79F0\u5DF2\u5B58\u5728");Nn[i]=bc(Vl,e)};bt.removeTheme=i=>{Nn[i]&&(Nn[i]=null)};SO=bt});var Od=globalThis.__LEPTOS_TIPTAP_BRIDGE__;if(Od==null||Od.modules==null)throw new Error("leptos-tiptap bridge bindings are unavailable");var H=Od.modules["@tiptap/core"];if(H==null)throw new Error('leptos-tiptap bridge module "@tiptap/core" is unavailable');var cB=H.CommandManager,uB=H.Editor,fB=H.Extension,mB=H.InputRule,pB=H.Mark,Pm=H.Node,gB=H.NodePos,xB=H.NodeView,vB=H.PasteRule,yB=H.Tracker,bB=H.callOrReturn,wB=H.canInsertNode,MB=H.combineTransactionSteps,TB=H.createChainableState,NB=H.createDocument,EB=H.createNodeFromContent,SB=H.createStyleTag,AB=H.defaultBlockAt,kB=H.deleteProps,CB=H.elementFromString,_B=H.escapeForRegEx,LB=H.extensions,zB=H.findChildren,IB=H.findChildrenInRange,RB=H.findDuplicates,DB=H.findParentNode,OB=H.findParentNodeClosestToPos,BB=H.fromString,PB=H.generateHTML,FB=H.generateJSON,qB=H.generateText,HB=H.getAttributes,UB=H.getAttributesFromExtensions,$B=H.getChangedRanges,jB=H.getDebugJSON,GB=H.getExtensionField,YB=H.getHTMLFromFragment,WB=H.getMarkAttributes,VB=H.getMarkRange,XB=H.getMarkType,KB=H.getMarksBetween,ZB=H.getNodeAtPosition,QB=H.getNodeAttributes,JB=H.getNodeType,eP=H.getRenderedAttributes,tP=H.getSchema,iP=H.getSchemaByResolvedExtensions,rP=H.getSchemaTypeByName,nP=H.getSchemaTypeNameByName,sP=H.getSplittedAttributes,aP=H.getText,oP=H.getTextBetween,lP=H.getTextContentFromNodes,hP=H.getTextSerializersFromSchema,dP=H.injectExtensionAttributesToParseRule,cP=H.inputRulesPlugin,uP=H.isActive,fP=H.isAtEndOfNode,mP=H.isAtStartOfNode,pP=H.isEmptyObject,gP=H.isExtensionRulesEnabled,xP=H.isFunction,vP=H.isList,yP=H.isMacOS,bP=H.isMarkActive,wP=H.isNodeActive,MP=H.isNodeEmpty,TP=H.isNodeSelection,NP=H.isNumber,EP=H.isPlainObject,SP=H.isRegExp,AP=H.isSafari,kP=H.isString,CP=H.isTextSelection,_P=H.isiOS,LP=H.markInputRule,zP=H.markPasteRule,Fm=H.mergeAttributes,IP=H.mergeDeep,RP=H.minMax,DP=H.nodeInputRule,OP=H.nodePasteRule,BP=H.objectIncludes,PP=H.pasteRulesPlugin,FP=H.posToDOMRect,qP=H.removeDuplicates,HP=H.resolveFocusPosition,UP=H.rewriteUnknownContent,$P=H.selectionToInsertionEnd,jP=H.splitExtensions,GP=H.textInputRule,YP=H.textPasteRule,WP=H.textblockTypeInputRule,VP=H.wrappingInputRule;var qm=Pm.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:i}){return["p",Fm(this.options.HTMLAttributes,i),0]},addCommands(){return{setParagraph:()=>({commands:i})=>i.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Hm="__LEPTOS_TIPTAP_BRIDGE__";function Zv(){let i=globalThis,e=i[Hm];if(e!=null)return e;let t={modules:{},registerExtension:()=>{throw new Error("leptos-tiptap bridge runtime is not initialized")}};return i[Hm]=t,t}function Um(){return Zv()}function $m(i){Um().registerExtension(i)}var Ra={data:{text:"\u4E2D\u5FC3\u4E3B\u9898"},children:[]},Bd=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),jm=i=>{if(!i||typeof i!="object")return Ra;let e=i.root??i,t=r=>{if(!Bd(r))return;let n=Bd(r.data)?r.data:{};r.data=n;let s=n.text;n.text=typeof s=="string"?s:String(s??"");let a=n.generalization,o=l=>{if(!Bd(l))return;let h=l.text;l.text=typeof h=="string"?h:String(h??"")};Array.isArray(a)?a.forEach(o):o(a),Array.isArray(r.children)&&r.children.forEach(t)};return t(e),i},wt=i=>{let e=jm(i)??Ra,t=e&&typeof e=="object"&&"root"in e?e.root:e;return jm(t)??Ra};var AO=["Drag","KeyboardNavigation","Export","Select","AssociativeLine","Search","OuterFrame"],kO=["Scrollbar","MiniMap","Painter","Formula"],CO=["data_change","view_data_change","node_active","back_forward","scale","translate"],_O=new Set(["BACK","FORWARD","INSERT_NODE","INSERT_CHILD_NODE","REMOVE_NODE","DELETE_NODE","ADD_GENERALIZATION","ADD_OUTER_FRAME","SET_NOTATION"]),Il=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),Ev=(i,e)=>{if(typeof i=="string"&&i.trim())return i.trim();if(Il(i)){let t=i.template;if(typeof t=="string"&&t.trim())return t.trim()}return e},_m=i=>Il(i)?i:{},LO=i=>!Il(i)||!Il(i.state)?null:{...i,state:i.state,transform:Il(i.transform)?i.transform:{}},zO=i=>{let e=wt(i.projection.root??Ra),t=_m(i.projection.config),r=_m(i.runtimeOptions);return{...t,...r,el:i.el,data:e,fit:typeof r.fit=="boolean"?r.fit:typeof t.fit=="boolean"?t.fit:!0,layout:Ev(i.projection.layout,"logicalStructure"),theme:Ev(i.projection.theme,"classic"),themeConfig:_m(i.projection.themeConfig),viewData:LO(i.projection.view),initRootNodePosition:["center","center"]}},IO={Drag:()=>Promise.resolve().then(()=>(b3(),y3)),KeyboardNavigation:()=>Promise.resolve().then(()=>(M3(),w3)),Export:()=>Promise.resolve().then(()=>(L3(),_3)),Select:()=>Promise.resolve().then(()=>(I3(),z3)),AssociativeLine:()=>Promise.resolve().then(()=>(H3(),q3)),Search:()=>Promise.resolve().then(()=>($3(),U3)),OuterFrame:()=>Promise.resolve().then(()=>(X3(),V3)),Scrollbar:()=>Promise.resolve().then(()=>(Z3(),K3)),MiniMap:()=>Promise.resolve().then(()=>(J3(),Q3)),Painter:()=>Promise.resolve().then(()=>(t2(),e2)),Formula:()=>Promise.resolve().then(()=>(Ux(),Hx))},RO=()=>[...AO,...kO],DO=async(i=RO())=>{if(typeof window>"u"||typeof document>"u")throw new Error("simple_mind_map_browser_required");let[{default:e},t]=await Promise.all([Promise.resolve().then(()=>(Nv(),Tv)),Promise.all(i.map(async s=>[s,(await IO[s]()).default]))]),r=e,n=[];return t.forEach(([s,a])=>{if(!a||typeof r.usePlugin!="function")return;typeof r.hasPlugin=="function"&&r.hasPlugin(a)!==-1||r.usePlugin(a),n.push(s)}),{MindMap:r,registeredPlugins:n}},OO=i=>(e,...t)=>{if(!_O.has(e))return{ok:!1,command:e,error:"unsupported_command"};if(typeof i.execCommand!="function")return{ok:!1,command:e,error:"runtime_unavailable"};try{return{ok:!0,command:e,result:i.execCommand(e,...t)}}catch{return{ok:!1,command:e,error:"command_failed"}}},BO=i=>{let e=[];return CO.forEach(t=>{let r=(...n)=>{let s=t==="data_change"||t==="view_data_change"?i.instance.getData?.(!0)??i.instance.getData?.():void 0;i.onEvent?.({type:t,args:n,snapshot:s,kernelRevision:i.projection.kernelRevision})};i.instance.on?.(t,r),e.push(()=>i.instance.off?.(t,r))}),()=>e.splice(0).forEach(t=>t())},Sv=async i=>{let e=await DO(i.pluginNames),t=zO({el:i.el,projection:i.projection,runtimeOptions:i.runtimeOptions}),r=new e.MindMap(t);i.mode&&r.setMode?.(i.mode);let n=BO({instance:r,projection:i.projection,onEvent:i.onEvent}),s=OO(r);return{instance:r,execCommand:s,getSnapshot:()=>r.getData?.(!0)??r.getData?.(),destroy:()=>{n(),r.destroy?.()}}};var Rd=class extends Error{constructor(e,t=null){super(e),this.name="MindmapCommandBridgeError",this.code="command_failed",this.status=t}},Rl=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),Av=i=>Rl(i)?i.schema==="mnote.mindmap.simple_mind_map_scene.v1"&&i.runtime==="simple-mind-map"&&"root"in i&&typeof i.kernelRevision=="number":!1,PO=(i,e)=>{let t=encodeURIComponent(i),r=encodeURIComponent(e);return`/api/mindmap/${t}/${r}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get`},FO=(i,e)=>{let t=encodeURIComponent(i),r=encodeURIComponent(e);return`/api/mindmap/${t}/${r}`},Lm=async i=>{let e=i.fetcher??fetch,t=i.endpoint??PO(i.documentId,i.mindmapId),r=await e(t,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`projection_load_failed:${r.status}`);let n=await r.json(),s=Rl(n)&&"result"in n?n.result:n;if(!Av(s))throw new Error("projection_load_failed:invalid_adapter_projection");return s},qO=i=>{if(!Rl(i))return null;let e=[i.kernelRevision,i.projectionRevision,Rl(i.result)?i.result.kernelRevision:null,Rl(i.result)?i.result.projectionRevision:null];for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return null},zm=async i=>{if(i.commands.length===0)throw new Rd("command_failed:empty_commands");let e=i.fetcher??fetch,t=i.endpoint??FO(i.documentId,i.mindmapId),r=await e(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({commandName:"mindmap.command.apply",documentId:i.documentId,mindmapId:i.mindmapId,commands:i.commands,projectionRevision:i.projectionRevision??null})}),n=await r.json().catch(()=>null);if(!r.ok)throw new Rd(`command_failed:${r.status}`,r.status);return{ok:!0,kernelRevision:qO(n),raw:n}},kv=async i=>(await zm(i),Lm({documentId:i.documentId,mindmapId:i.mindmapId,endpoint:i.projectionEndpoint,fetcher:i.fetcher})),Cv=async i=>{if(!Av(i.projection))throw new Error("adapter_init_failed:invalid_projection");return Sv(i)};var _v=i=>({text:i?.text?.trim()||"\u65B0\u8282\u70B9",...i?.uid?{uid:i.uid}:{},...i?.hyperlink?{hyperlink:i.hyperlink}:{},...i?.note?{note:i.note}:{},...i?.refs?{refs:i.refs}:{}}),Rv=i=>{let e=i.activeNodeId?.trim();switch(i.runtimeCommand){case"INSERT_CHILD_NODE":return e?{type:"insertChild",mindmapId:i.mindmapId,parentNodeId:e,node:_v(i.newNode)}:null;case"INSERT_NODE":return e?{type:"insertSiblingAfter",mindmapId:i.mindmapId,targetNodeId:e,node:_v(i.newNode)}:null;case"REMOVE_NODE":case"DELETE_NODE":return e?{type:"deleteNode",mindmapId:i.mindmapId,nodeId:e}:null;case"ADD_GENERALIZATION":return{type:"compatPayloadPatch",mindmapId:i.mindmapId,path:"root.data.generalization",value:{text:"\u6982\u8981"},source:"toolbar"};case"ADD_OUTER_FRAME":return{type:"compatPayloadPatch",mindmapId:i.mindmapId,path:"outerFrame",value:{enabled:!0,activeNodeId:e},source:"toolbar"};default:return null}},Dv=(i,e)=>({type:"patchView",mindmapId:i,patch:e}),Ov=(i,e,t)=>({type:"setTheme",mindmapId:i,theme:e,themeConfig:t}),Bv=(i,e)=>({type:"setLayout",mindmapId:i,layout:e}),Dl=i=>({type:"compatPayloadPatch",mindmapId:i.mindmapId,path:i.path,value:i.value,source:i.source,...i.actionId?{actionId:i.actionId}:{},...typeof i.runtimeRevision=="number"?{runtimeRevision:i.runtimeRevision}:{},...typeof i.kernelRevision=="number"?{kernelRevision:i.kernelRevision}:{}}),HO=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),UO=(i,e)=>{let t=i.data?.uid;return typeof t=="string"&&t.trim()?t.trim():e},$O=i=>{let e=i.data?.text;return typeof e=="string"?e:String(e??"")},Lv=i=>{let e=wt(i),t=new Map,r=(n,s,a,o)=>{let l=UO(n,o),h=HO(n.data)?n.data:{};t.set(l,{uid:l,parentUid:s,order:a,text:$O(n),data:h,node:n}),(Array.isArray(n.children)?n.children:[]).forEach((c,f)=>{r(wt(c),l,f,`${o}.${f}`)})};return r(e,null,0,"root"),t},zv=i=>JSON.stringify(i??null),Iv=i=>({uid:i.uid,text:i.text||"\u65B0\u8282\u70B9",...typeof i.data.hyperlink=="string"?{hyperlink:i.data.hyperlink}:{},...typeof i.data.note=="string"?{note:i.data.note}:{},...Array.isArray(i.data.refs)?{refs:i.data.refs}:{}}),jO=(i,e,t,r)=>{let n=new Set(["uid","text","refs"]);new Set([...Object.keys(e.data),...Object.keys(t.data)]).forEach(a=>{n.has(a)||zv(e.data[a])!==zv(t.data[a])&&r.push(Dl({mindmapId:i,path:`nodes.${t.uid}.data.${a}`,value:t.data[a],source:"adapter-diff"}))})},Pv=i=>{let e=Lv(i.previous),t=Lv(i.next),r=[],n=[];return t.forEach((s,a)=>{let o=e.get(a);if(!o){let l=Array.from(t.values()).find(h=>h.parentUid===s.parentUid&&h.order===s.order-1&&e.has(h.uid));l?r.push({type:"insertSiblingAfter",mindmapId:i.mindmapId,targetNodeId:l.uid,node:Iv(s)}):s.parentUid&&r.push({type:"insertChild",mindmapId:i.mindmapId,parentNodeId:s.parentUid,node:Iv(s)});return}o.text!==s.text&&r.push({type:"updateText",mindmapId:i.mindmapId,nodeId:a,text:s.text}),(o.parentUid!==s.parentUid||o.order!==s.order)&&r.push({type:"moveNode",mindmapId:i.mindmapId,nodeId:a,newParentNodeId:s.parentUid??"",order:s.order}),jO(i.mindmapId,o,s,n)}),e.forEach((s,a)=>{!t.has(a)&&s.parentUid&&r.push({type:"deleteNode",mindmapId:i.mindmapId,nodeId:a})}),{commands:r,compatPatches:n}};var ls=i=>e=>e?`nodes.${e}.data.${i}`:null,Fv=[{actionId:"undo",target:"runtimeCommand",runtimeCommand:"BACK",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"redo",target:"runtimeCommand",runtimeCommand:"FORWARD",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"editNode",target:"kernelCommand",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"insertSiblingAfter",target:"runtimeCommand",runtimeCommand:"INSERT_NODE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"insertChild",target:"runtimeCommand",runtimeCommand:"INSERT_CHILD_NODE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"deleteNode",target:"runtimeCommand",runtimeCommand:"DELETE_NODE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"summary",target:"compatPatch",runtimeCommand:"ADD_GENERALIZATION",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"associativeLine",target:"compatPatch",runtimeCommand:"ADD_ASSOCIATIVE_LINE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"setTheme",target:"kernelCommand",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"setLayout",target:"kernelCommand",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"tag",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("tag")},{actionId:"hyperlink",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("hyperlink")},{actionId:"note",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("note")},{actionId:"image",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("image")},{actionId:"icon",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("icon")},{actionId:"formula",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("formula")},{actionId:"painter",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:ls("style")},{actionId:"import",target:"compatPatch",requiresActiveNode:!1,readonlyAllowed:!1,compatPath:()=>"import"},{actionId:"export",target:"runtimeCommand",runtimeCommand:"EXPORT",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"centerRoot",target:"localView",runtimeMethod:"centerRoot",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"zoomIn",target:"localView",runtimeMethod:"zoomIn",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"zoomOut",target:"localView",runtimeMethod:"zoomOut",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"fitView",target:"localView",runtimeMethod:"fitView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"search",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"expandCollapse",target:"localView",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"copyNodeText",target:"localView",requiresActiveNode:!0,readonlyAllowed:!0},{actionId:"readonly",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0}],qv=()=>Fv,Ol=i=>Fv.find(e=>e.actionId===i)??null,GO=i=>{let e=i?.trim();return e||null},Hv=i=>{let e=Ol(i.actionId);if(!e)return null;let t=GO(i.activeNodeId);if(e.requiresActiveNode&&!t)return null;if(i.actionId==="setTheme")return{command:Ov(i.mindmapId,i.value,i.themeConfig)};if(i.actionId==="setLayout")return{command:Bv(i.mindmapId,i.value)};if(i.actionId==="editNode")return{command:{type:"updateText",mindmapId:i.mindmapId,nodeId:t??"root",text:typeof i.value=="string"?i.value:""}};if(e.runtimeCommand&&["INSERT_CHILD_NODE","INSERT_NODE","DELETE_NODE","REMOVE_NODE"].includes(e.runtimeCommand)){let r=Rv({mindmapId:i.mindmapId,runtimeCommand:e.runtimeCommand,activeNodeId:t,newNode:i.node});return r?{runtimeCommand:e.runtimeCommand,command:r}:{runtimeCommand:e.runtimeCommand}}if(e.compatPath){let r=e.compatPath(t);return r?{command:Dl({mindmapId:i.mindmapId,path:r,value:i.value??!0,source:i.source??"toolbar",actionId:i.actionId,runtimeRevision:i.runtimeRevision,kernelRevision:i.kernelRevision})}:null}return e.runtimeCommand?{runtimeCommand:e.runtimeCommand}:{}};var YO="mnoteMindmapDebugChrome",Fr={toolbarGroups:[{id:"history",label:"\u5386\u53F2",actions:["undo","redo"],collapsePriority:4},{id:"node",label:"\u8282\u70B9",actions:["editNode","insertSiblingAfter","insertChild","deleteNode"],collapsePriority:1},{id:"insert",label:"\u63D2\u5165",actions:["tag","hyperlink","note","image","icon","summary","associativeLine","formula","painter","import","export"],collapsePriority:2},{id:"view",label:"\u89C6\u56FE",actions:["centerRoot","zoomOut","zoomIn","search","readonly"],collapsePriority:3}],sidebarPanels:[{id:"nodeStyle",label:"\u8282\u70B9\u6837\u5F0F",icon:"palette",runtimeCapability:"node-style",phase:1,options:[{id:"node-fill-blue",label:"\u84DD\u8272\u8282\u70B9",actionId:"painter",value:"#dbeafe",compatPath:"nodes.$active.data.fillColor"},{id:"node-round",label:"\u5706\u89D2\u8282\u70B9",actionId:"painter",value:"roundedRectangle",compatPath:"nodes.$active.data.shape"}]},{id:"baseStyle",label:"\u5BFC\u56FE\u6837\u5F0F",icon:"sliders",runtimeCapability:"base-style",phase:1,options:[{id:"base-curve-line",label:"\u66F2\u7EBF\u8FDE\u7EBF",actionId:"painter",value:"curve",compatPath:"style.map.lineStyle"},{id:"base-rainbow-lines",label:"\u5F69\u8679\u7EBF\u6761",actionId:"painter",value:{enabled:!0},compatPath:"style.map.rainbowLines"}]},{id:"theme",label:"\u4E3B\u9898",icon:"swatch",runtimeCapability:"theme",phase:1,options:[{id:"theme-classic",label:"\u9ED8\u8BA4\u4E3B\u9898",actionId:"setTheme",value:"classic"},{id:"theme-classic4",label:"KMind-like",actionId:"setTheme",value:"classic4"}]},{id:"structure",label:"\u7ED3\u6784",icon:"layout",runtimeCapability:"layout",phase:1,options:[{id:"layout-logical",label:"\u903B\u8F91\u7ED3\u6784",actionId:"setLayout",value:"logicalStructure"},{id:"layout-mind-map",label:"\u53F3\u4FA7\u7ED3\u6784",actionId:"setLayout",value:"mindMap"},{id:"layout-fishbone",label:"\u9C7C\u9AA8\u7ED3\u6784",actionId:"setLayout",value:"fishbone"}]},{id:"outline",label:"\u5927\u7EB2",icon:"list-tree",runtimeCapability:"outline",phase:1,options:[]}],navigatorItems:[{id:"stats",label:"\u7EDF\u8BA1",actionId:null,readOnly:!0,displayMode:"text"},{id:"centerRoot",label:"\u56DE\u6839\u8282\u70B9",actionId:"centerRoot",readOnly:!0,displayMode:"button"},{id:"search",label:"\u641C\u7D22",actionId:"search",readOnly:!0,displayMode:"input"},{id:"zoomOut",label:"\u7F29\u5C0F",actionId:"zoomOut",readOnly:!0,displayMode:"button"},{id:"zoom",label:"\u7F29\u653E",actionId:null,readOnly:!0,displayMode:"text"},{id:"zoomIn",label:"\u653E\u5927",actionId:"zoomIn",readOnly:!0,displayMode:"button"},{id:"readonly",label:"\u53EA\u8BFB",actionId:"readonly",readOnly:!0,displayMode:"button"}],contextMenuItems:[{id:"insertChild",label:"\u63D2\u5165\u5B50\u8282\u70B9",actionId:"insertChild",requiresNode:!0,phase:1},{id:"insertSiblingAfter",label:"\u63D2\u5165\u540C\u7EA7\u8282\u70B9",actionId:"insertSiblingAfter",requiresNode:!0,phase:1},{id:"deleteNode",label:"\u5220\u9664\u8282\u70B9",actionId:"deleteNode",requiresNode:!0,phase:1},{id:"summary",label:"\u6982\u8981",actionId:"summary",requiresNode:!0,phase:1},{id:"associativeLine",label:"\u5173\u8054\u7EBF",actionId:"associativeLine",requiresNode:!0,phase:1},{id:"expandCollapse",label:"\u5C55\u5F00/\u6536\u8D77",actionId:"expandCollapse",requiresNode:!0,phase:1},{id:"copyNodeText",label:"\u590D\u5236\u6587\u672C",actionId:"copyNodeText",requiresNode:!0,phase:1},{id:"centerRoot",label:"\u56DE\u6839\u8282\u70B9",actionId:"centerRoot",requiresNode:!1,phase:1},{id:"fitView",label:"\u9002\u5E94\u753B\u5E03",actionId:"fitView",requiresNode:!1,phase:1},{id:"search",label:"\u641C\u7D22",actionId:"search",requiresNode:!1,phase:1},{id:"readonly",label:"\u53EA\u8BFB\u5207\u6362",actionId:"readonly",requiresNode:!1,phase:1}]},Uv=i=>{try{let e=new URL(i).searchParams.get(YO);return e==="1"||e==="true"}catch{return!1}};var WO=()=>{let i=[...Fr.toolbarGroups.flatMap(e=>e.actions),...Fr.navigatorItems.flatMap(e=>e.actionId?[e.actionId]:[]),...Fr.contextMenuItems.map(e=>e.actionId),...qv().map(e=>e.actionId)];return[...new Set(i)]},VO=i=>{let e=i?.trim();return e||null},Im=i=>{let e=VO(i.activeNodeId),t=i.runtimeCapabilities?new Set(i.runtimeCapabilities):null,r={};return WO().forEach(n=>{let s=Ol(n);if(!s){r[n]=!0;return}if(s.requiresActiveNode&&!e){r[n]=!0;return}if(i.readonly&&!s.readonlyAllowed){r[n]=!0;return}if(t&&!t.has(s.target)){r[n]=!0;return}r[n]=!1}),{activeNodeId:e,readonly:i.readonly,disabledActions:r}};function XO(i){return typeof i=="string"&&i.length>0?{"data-block-id":i,id:i}:{}}function KO(i){if(i.mnoteBlockType!=="mindmap")return{};let e={"data-mnote-block-type":"mindmap"};return typeof i.mindmapId=="string"&&(e["data-mnote-mindmap-id"]=i.mindmapId),typeof i.rootNodeId=="string"&&(e["data-mnote-root-node-id"]=i.rootNodeId),typeof i.projectionVersion=="number"&&(e["data-mnote-projection-version"]=String(i.projectionVersion)),e}function hs(i){return String(i??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Rm(){let i=window.location.pathname.match(/\/documents\/([^/?#]+)/);return i?.[1]?decodeURIComponent(i[1]):null}function $v(i,e){let r=wt(i.root).data?.uid;return typeof r=="string"&&r.trim().length>0?r.trim():e}function Dm(i){let t=wt(i.root).data?.text;return typeof t=="string"&&t.trim().length>0?t.trim():"\u672A\u547D\u540D\u8282\u70B9"}function ZO(i){if(!i||typeof i!="object")return null;let e=i;if(typeof e.uid=="string"&&e.uid.trim().length>0)return e.uid.trim();let t=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};if(typeof t.uid=="string"&&t.uid.trim().length>0)return t.uid.trim();let r=e.getData;if(typeof r=="function")try{let n=r.call(e,"uid");if(typeof n=="string"&&n.trim().length>0)return n.trim()}catch{return null}return null}function Om(i,e){let t=window,r=t.__MNOTE_LEPTOS_MINDMAP_BRIDGES__??{};t.__MNOTE_LEPTOS_MINDMAP_BRIDGES__=r,e?r[i]=e:delete r[i]}function ki(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function QO(i){if(!ki(i))return null;let e=i.view;return ki(e)&&ki(e.state)?e:null}function JO(i){if(!(i!=="insertChild"&&i!=="insertSiblingAfter"))return{uid:`node_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,text:"\u65B0\u8282\u70B9"}}function eB(i,e){let t=e?.trim();if(!t)return!1;let r=wt(i),n=!1,s=a=>{if(n)return;let o=wt(a);if(o.data?.uid===t){n=!0;return}(Array.isArray(o.children)?o.children:[]).forEach(s)};return s(r),n}function tB(i){let e=wt(i),t=Array.isArray(e.children)?[...e.children]:[];for(;t.length>0;){let r=wt(t.shift()),n=r.data?.uid;if(typeof n=="string"&&n.trim().length>0)return n.trim();Array.isArray(r.children)&&t.push(...r.children)}return null}function iB(i,e=10){let t=wt(i),r=[],n=(s,a)=>{if(r.length>=e)return;let o=wt(s),l=typeof o.data?.text=="string"&&o.data.text.trim().length>0?o.data.text.trim():"\u672A\u547D\u540D\u8282\u70B9";r.push(`${" ".repeat(Math.max(a-1,0))}${l}`),(Array.isArray(o.children)?o.children:[]).forEach(d=>n(d,a+1))};return n(t,1),r}function rB(i,e){let t=i?.trim();return t?t.includes("$active")?e?t.replaceAll("$active",e):null:t:null}var nB={undo:"\u64A4\u9500",redo:"\u91CD\u505A",editNode:"\u7F16\u8F91\u8282\u70B9",insertSiblingAfter:"\u540C\u7EA7\u8282\u70B9",insertChild:"\u5B50\u8282\u70B9",deleteNode:"\u5220\u9664",tag:"\u6807\u7B7E",hyperlink:"\u94FE\u63A5",note:"\u5907\u6CE8",image:"\u56FE\u7247",icon:"\u56FE\u6807",summary:"\u6982\u8981",associativeLine:"\u5173\u8054\u7EBF",formula:"\u516C\u5F0F",painter:"\u683C\u5F0F\u5237",import:"\u5BFC\u5165",export:"\u5BFC\u51FA",setTheme:"\u4E3B\u9898",setLayout:"\u7ED3\u6784",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fitView:"\u9002\u5E94",centerRoot:"\u56DE\u6839",search:"\u641C\u7D22",expandCollapse:"\u5C55\u5F00/\u6536\u8D77",copyNodeText:"\u590D\u5236\u6587\u672C",readonly:"\u53EA\u8BFB"},sB={undo:"\u21B6",redo:"\u21B7",editNode:"T",insertSiblingAfter:"\u21B5",insertChild:"+",deleteNode:"\xD7",tag:"#",hyperlink:"\u2301",note:"N",image:"\u25A1",icon:"\u2606",summary:"{",associativeLine:"\u2307",formula:"fx",painter:"\u25D0",import:"\u21E7",export:"\u21E9",centerRoot:"\u25CE",zoomOut:"-",zoomIn:"+",search:"\u2315",expandCollapse:"\u2922",copyNodeText:"C",readonly:"\u9501"};function aB(i){return({node:e,getPos:t})=>{let r=e,n=0,s=null,a=null,o=null,l=null,h=null,d=null,c=!1,f=Fr.sidebarPanels[0]?.id??"nodeStyle",m=null,g=null,x=!1,v=!1,b="canvas",E=0,S=0,C=null,_=null,I=!1,O=Uv(window.location.href),D=document.createElement("div");D.className="mnote-mindmap-placeholder",D.dataset.mnoteBlockType="mindmap",D.dataset.testid="mnote-mindmap-placeholder",D.setAttribute("contenteditable","false");let $=document.createElement("div");$.className="mnote-mindmap-editor-root",$.dataset.testid="mnote-mindmap-editor-root",$.dataset.mnoteSceneQuery="mindmap.simple_mind_map_scene.get";let F=document.createElement("div");F.dataset.testid="leptos-mindmap-island",F.dataset.runtime="simple-mind-map",F.dataset.stage="loading",F.dataset.debugChrome=O?"true":"false",F.className="mnote-leptos-mindmap-shell";let Z=document.createElement("div");Z.className="mnote-mindmap-workspace",Z.dataset.debugChrome=O?"true":"false",Z.dataset.layout=O?"debug-grid":"floating-overlay";let re=document.createElement("div");re.className="mnote-mindmap-canvas-layer",re.dataset.testid="mindmap-canvas-layer";let ye=document.createElement("div");ye.className="mnote-mindmap-overlay-layer",ye.dataset.testid="mindmap-overlay-layer";let G=document.createElement("div");G.className="mnote-leptos-mindmap-runtime",G.dataset.testid="simple-mind-map-runtime",G.dataset.runtime="simple-mind-map",G.dataset.runtimeEngine="pending";let W=document.createElement("div");W.className="mnote-mindmap-rust-shell-mount",W.dataset.testid="mindmap-rust-shell-mount",W.dataset.uiShellSource="leptos-rust-shell";let ee=document.createElement("div");ee.className="mnote-mindmap-command-toolbar",ee.dataset.testid="mindmap-command-toolbar";let ae=document.createElement("aside");ae.className="mnote-mindmap-side-panel",ae.dataset.testid="mindmap-sidebar";let at=document.createElement("div");at.className="mnote-mindmap-bottom-bar",at.dataset.testid="mindmap-bottom-bar";let nt=()=>{let z=typeof r.attrs.mindmapId=="string"&&r.attrs.mindmapId.length>0?r.attrs.mindmapId:"mindmap",V=typeof r.attrs.rootNodeId=="string"&&r.attrs.rootNodeId.length>0?r.attrs.rootNodeId:"root";return{mindmapId:z,rootNodeId:V}},hi=()=>{let{mindmapId:z,rootNodeId:V}=nt();D.dataset.mnoteMindmapId=z,D.dataset.mnoteRootNodeId=V,D.dataset.mnoteProjectionVersion=String(r.attrs.projectionVersion??1),$.dataset.mnoteMindmapId=z,$.dataset.mnoteRootNodeId=V,$.dataset.mnoteProjectionVersion=String(r.attrs.projectionVersion??1),$.dataset.mnoteSceneQuery="mindmap.simple_mind_map_scene.get"},Jt=()=>{if(!(C===null||!_)){try{_.unmount(C)}catch{}C=null,_=null,W.replaceChildren()}},It=()=>{let z=s?.getSnapshot(),V=ki(z)&&"root"in z?z.root:z??a?.root,J=0,de=0,be=Ge=>{if(!ki(Ge))return;J+=1;let Bl=ki(Ge.data)&&typeof Ge.data.text=="string"?Ge.data.text:"";de+=Bl.trim().length,(Array.isArray(Ge.children)?Ge.children:[]).forEach(be)};be(V);let ge=a?.view,et=ki(z)&&ki(z.view)&&ki(z.view.state)&&typeof z.view.state.scale=="number"?z.view.state.scale:ki(ge)&&ki(ge.state)&&typeof ge.state.scale=="number"?ge.state.scale:1;return{nodeCount:J,wordCount:de,zoomPercent:Math.round(et*100)}},Sn=()=>{let z=s?.getSnapshot(),V=ki(z)&&"root"in z?z.root:z??a?.root;return iB(V)},Ca=()=>{let z=window.__MNOTE_MINDMAP_RUST_SHELL__;if(!z){Jt(),F.dataset.uiShell="typescript-nodeview-dom",W.dataset.uiShellSource="missing-rust-shell",W.innerHTML='
    Leptos/Rust mindmap shell \u672A\u52A0\u8F7D
    ';return}let V=Im({activeNodeId:l,readonly:c,runtimeCapabilities:["runtimeCommand","kernelCommand","compatPatch","localView"]}),{mindmapId:J}=nt(),de=It(),be={mindmapId:J,toolbarGroups:Fr.toolbarGroups.map(ge=>({id:ge.id,label:ge.label,actions:ge.actions.map(et=>{let Ge=nB[et]??et;return{id:et,label:Ge,icon:sB[et]??Ge.slice(0,1),disabled:V.disabledActions[et]??!0}})})),sidebarPanels:Fr.sidebarPanels.map(ge=>({id:ge.id,label:ge.label,icon:ge.icon,active:ge.id===f,bodyTitle:ge.label,bodyCaption:ge.runtimeCapability,options:ge.options.map(et=>({id:et.id,label:et.label,actionId:et.actionId,value:et.value,compatPath:et.compatPath})),bodyItems:ge.id==="outline"?Sn():[]})),navigator:{wordCount:de.wordCount,nodeCount:de.nodeCount,zoomPercent:de.zoomPercent,readonly:c,minimapOpen:x}};Jt(),W.dataset.uiShellSource="leptos-rust-shell",_=z,C=z.mount(W,be),F.dataset.uiShell="leptos-rust-shell"},st=()=>{if(hi(),!O){Ca(),ds();return}Jt(),F.dataset.uiShell="debug-fallback",ee.dataset.testid="mindmap-command-toolbar",ee.className="mnote-mindmap-command-toolbar",delete ee.dataset.schemaSource,ae.dataset.testid="mindmap-sidebar",ae.className="mnote-mindmap-side-panel",delete ae.dataset.schemaSource,at.dataset.testid="mindmap-bottom-bar",at.className="mnote-mindmap-bottom-bar",delete at.dataset.schemaSource;let z=a?Dm(a):"",V=d??z,de=s!==null?"":" disabled",be=["\u8282\u70B9\u6837\u5F0F","\u5BFC\u56FE\u6837\u5F0F","\u4E3B\u9898","\u7ED3\u6784","\u5927\u7EB2"].map((ge,et)=>``).join("");ee.innerHTML=`
    `,ae.innerHTML=`${be}
    \u7ECF\u5178\u4E3B\u9898 \xB7 \u903B\u8F91\u7ED3\u6784
    `,at.innerHTML=`runtime \u8282\u70B9100%`},ds=()=>{let z=ye.querySelector('[data-testid="mindmap-schema-context-menu"]');if(!v){z?.remove();return}z||(z=document.createElement("div"),z.className="mnote-mindmap-context-menu",z.dataset.testid="mindmap-schema-context-menu",z.dataset.uiSource="typescript-nodeview-bridge",ye.append(z)),z.dataset.contextMenuKind=b,z.style.left=`${Math.max(8,E)}px`,z.style.top=`${Math.max(8,S)}px`;let V=Fr.contextMenuItems.filter(J=>b==="node"||!J.requiresNode);z.innerHTML=V.map(J=>``).join("")},qr=()=>{hi(),F.dataset.stage="loading",G.dataset.runtimeEngine="loading",G.innerHTML='
    \u6B63\u5728\u52A0\u8F7D\u5BFC\u56FE runtime...
    ',st()},ei=(z,V)=>{let{mindmapId:J}=nt();hi(),F.dataset.stage=z,G.dataset.runtimeEngine="error",G.innerHTML=`
    ${hs(z)}${hs(J)}${hs(V)}
    `,st()},nr=async(z,V)=>{if(F.dataset.commandCount=String(z.length),F.dataset.commandHasProjection=a?"true":"false",F.dataset.commandFailedAction="",F.dataset.commandFailedMessage="",z.length===0||!a){F.dataset.commandStatus="skipped";return}let{mindmapId:J}=nt(),de=Rm();if(!de){ei("command_failed",`mindmapId=${J}; documentId_missing`);return}F.dataset.commandStatus="pending";try{let be=await kv({documentId:de,mindmapId:J,commands:z,projectionRevision:a.kernelRevision});if(I)return;if(await za(be),V){let ge=eB(be.root,V)?V:tB(be.root)??$v(be,nt().rootNodeId);l=ge,h=ge,st()}d=null,F.dataset.commandStatus="success"}catch(be){let ge=be instanceof Error?be.message:String(be);F.dataset.commandStatus="failed",F.dataset.commandFailedAction=F.dataset.lastSchemaAction??"",F.dataset.commandFailedMessage=ge,ei("command_failed",`mindmapId=${J}; ${ge}`)}},cs=async z=>{if(!a)return;let{mindmapId:V}=nt(),J=Rm();if(!J){ei("command_failed",`mindmapId=${V}; documentId_missing`);return}F.dataset.viewCommandStatus="pending";try{if(await zm({documentId:J,mindmapId:V,commands:[Dv(V,z)],projectionRevision:a.kernelRevision}),I)return;a.view=z,F.dataset.viewCommandStatus="success"}catch(de){ei("command_failed",`mindmapId=${V}; ${de instanceof Error?de.message:String(de)}`)}},An=z=>{let V=QO(z);V&&(m=V,F.dataset.lastViewPatch=JSON.stringify(V),g!==null&&window.clearTimeout(g),g=window.setTimeout(()=>{g=null;let J=m;m=null,J&&cs(J)},350))},Dd=z=>{if(s){if(z==="centerRoot"&&s.instance.renderer?.setRootNodeCenter?.(),z==="zoomOut"&&s.instance.view?.narrow?.(),z==="zoomIn"&&s.instance.view?.enlarge?.(),z==="fitView"&&s.instance.view?.reset?.(),z==="search"){F.dataset.searchStatus="ready",F.dataset.lastSearchQuery="";return}if(z==="expandCollapse"){s.instance.renderer?.toggleActiveExpand?.(),F.dataset.contextMenuActionStatus="success",F.dataset.lastContextMenuAction=z,st();return}if(z==="copyNodeText"){let V=a?wt(a.root):null,J=V&&typeof V.data?.text=="string"?V.data.text:"";F.dataset.copiedNodeText=J,F.dataset.contextMenuActionStatus="success",F.dataset.lastContextMenuAction=z;return}z==="readonly"&&(c=!c),An(s.getSnapshot()),st()}},_a=(z,V={})=>{let J=Ol(z);if(!J||Im({activeNodeId:l,readonly:c,runtimeCapabilities:["runtimeCommand","kernelCommand","compatPatch","localView"]}).disabledActions[z])return;if(F.dataset.lastSchemaAction=z,J.target==="localView"){Dd(z);return}let be=JO(z),ge=h??l,et=nt().mindmapId,Ge=Hv({actionId:z,mindmapId:et,activeNodeId:ge,node:be,value:V.value??(z==="editNode"?Dm(a):!0),source:V.source,runtimeRevision:a?.kernelRevision??null,kernelRevision:a?.kernelRevision??null}),Bl=rB(V.compatPath,ge);if(Bl&&(Ge={command:Dl({mindmapId:et,path:Bl,value:V.value??!0,source:V.source??"sidebar",actionId:z,runtimeRevision:a?.kernelRevision??null,kernelRevision:a?.kernelRevision??null})}),F.dataset.lastSchemaCommand=Ge?.command?JSON.stringify(Ge.command):"",F.dataset.lastSchemaRuntimeCommand=Ge?.runtimeCommand??"",!!Ge){if(J.target==="runtimeCommand"&&Ge.runtimeCommand){if(Ge.command){let Bm=be?.uid??(z==="deleteNode"?nt().rootNodeId:ge);nr([Ge.command],Bm);return}s?.execCommand(Ge.runtimeCommand);return}Ge.command&&nr([Ge.command])}},La=z=>{if(z.type==="node_active"){let J=l;l=ZO(z.args[0])??l,(!h||h===J)&&(h=l),st();return}if(z.type==="view_data_change"||z.type==="scale"||z.type==="translate"){F.dataset.lastViewEvent=z.type,An(z.snapshot??s?.getSnapshot());return}if(z.type!=="data_change"||!a||!z.snapshot)return;let V=Pv({mindmapId:nt().mindmapId,previous:o??a.root,next:z.snapshot});o=z.snapshot,nr([...V.commands,...V.compatPatches])},za=async z=>{let{mindmapId:V,rootNodeId:J}=nt();if(s?.destroy(),Om(V,null),a=z,l=$v(z,J),h=h??l,o=z.root,G.dataset.runtimeEngine="simple-mind-map",G.dataset.runtimeReady="false",G.replaceChildren(),st(),s=await Cv({el:G,projection:z,mode:"edit",runtimeOptions:{fit:!0,mousewheelAction:"zoom",enableFreeDrag:!0,enableCtrlKeyNodeSelection:!0,useLeftKeySelectionRightKeyDrag:!0,createNewNodeBehavior:"activeOnly"},onEvent:La}),I){s.destroy();return}G.dataset.runtimeReady="true",F.dataset.stage="ready",Om(V,s),st()},Ia=async()=>{let z=++n,{mindmapId:V,rootNodeId:J}=nt(),de=Rm();if(!de){ei("projection_load_failed",`mindmapId=${V}; documentId_missing`);return}qr();try{if(z!==n)return;let be=await Lm({documentId:de,mindmapId:V,endpoint:`/api/mindmap/${encodeURIComponent(de)}/${encodeURIComponent(V)}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get&rootNodeId=${encodeURIComponent(J)}`});if(z!==n||I)return;await za(be)}catch(be){ei("projection_load_failed",`mindmapId=${V}; ${be instanceof Error?be.message:String(be)}`)}};return D.addEventListener("pointerdown",z=>z.stopPropagation()),D.addEventListener("mousedown",z=>z.stopPropagation()),D.addEventListener("mnote:mindmap-shell:action",z=>{let V=z.detail,J=V?.actionId;if(J==="search"){F.dataset.searchStatus="ready",F.dataset.lastSearchQuery=typeof V?.value=="string"?V.value:"";return}J&&_a(J,V)}),D.addEventListener("mnote:mindmap-shell:minimap",z=>{let V=z.detail;x=typeof V?.open=="boolean"?V.open:!x,F.dataset.minimapOpen=x?"true":"false",st()}),D.addEventListener("mnote:mindmap-shell:panel",z=>{let V=z.detail;V?.panelId&&(f=V.panelId,st())}),D.addEventListener("input",z=>{if(!O)return;let V=z.target;V instanceof HTMLInputElement&&V.dataset.testid==="mindmap-command-text-input"&&(d=V.value)}),D.addEventListener("click",z=>{z.stopPropagation();let V=z.target;if(!(V instanceof HTMLElement))return;let J=V.closest("button");if(J instanceof HTMLButtonElement){if(!O){z.preventDefault();let de=J.dataset.mindmapContextActionId;if(de){v=!1,ds(),_a(de);return}if(J.closest('[data-testid="mindmap-rust-shell"]'))return;let be=J.dataset.mindmapActionId;be&&_a(be);let ge=J.dataset.mindmapSidebarPanelId;ge&&(f=ge,st());return}if(J.dataset.testid==="mindmap-command-update-text"){z.preventDefault();let de=$.querySelector('[data-testid="mindmap-command-text-input"]'),be=d??(de instanceof HTMLInputElement?de.value:Dm(a));F.dataset.lastCommandText=be,nr([{type:"updateText",mindmapId:nt().mindmapId,nodeId:l??nt().rootNodeId,text:be}])}J.dataset.testid==="mindmap-command-add-child"&&(z.preventDefault(),s?.execCommand("INSERT_CHILD_NODE")),J.dataset.testid==="mindmap-command-add-sibling-after"&&(z.preventDefault(),s?.execCommand("INSERT_NODE")),J.dataset.testid==="mindmap-command-delete-node"&&(z.preventDefault(),s?.execCommand("DELETE_NODE")),J.dataset.testid==="mindmap-toolbar-undo"&&(z.preventDefault(),s?.execCommand("BACK")),J.dataset.testid==="mindmap-toolbar-redo"&&(z.preventDefault(),s?.execCommand("FORWARD")),J.dataset.testid==="mindmap-toolbar-summary"&&(z.preventDefault(),s?.execCommand("ADD_GENERALIZATION")),J.dataset.testid==="mindmap-bottom-center-root"&&(z.preventDefault(),s?.instance.renderer?.setRootNodeCenter?.(),An(s?.getSnapshot())),J.dataset.testid==="mindmap-bottom-zoom-out"&&(z.preventDefault(),s?.instance.view?.narrow?.(),An(s?.getSnapshot())),J.dataset.testid==="mindmap-bottom-zoom-in"&&(z.preventDefault(),s?.instance.view?.enlarge?.(),An(s?.getSnapshot()))}}),D.addEventListener("contextmenu",z=>{if(O)return;z.preventDefault(),z.stopPropagation();let V=z.target;b=V instanceof Element&&V.closest(".smm-node")?"node":"canvas",E=z.offsetX,S=z.offsetY,v=!0,F.dataset.contextMenuKind=b,ds()},!0),re.append(G),O?(Z.append(G,ae),F.append(ee,Z,at)):(ye.append(W),Z.append(re,ye),F.append(Z)),$.append(F),D.append($),Ia(),{dom:D,update(z){return z.type.name!==r.type.name||(r=z,r.attrs.mnoteBlockType!=="mindmap")?!1:(Ia(),!0)},stopEvent:()=>!0,ignoreMutation:()=>!0,destroy(){I=!0,g!==null&&window.clearTimeout(g);let{mindmapId:z}=nt();Om(z,null),s?.destroy(),Jt(),s=null}}}}function oB(){return({node:i})=>{let e=i,t=document.createElement("p"),r=()=>{let n=e.attrs.blockId;typeof n=="string"&&n.length>0?(t.dataset.blockId=n,t.id=n):(t.removeAttribute("data-block-id"),t.removeAttribute("id"))};return r(),{dom:t,contentDOM:t,update(n){return n.type.name!==e.type.name||n.attrs.mnoteBlockType==="mindmap"?!1:(e=n,r(),!0)}}}}var lB=qm.extend({addAttributes(){return{...this.parent?.(),blockId:{default:null,parseHTML:i=>i.getAttribute("data-block-id"),renderHTML:i=>XO(i.blockId)},mnoteBlockType:{default:null,parseHTML:i=>i.getAttribute("data-mnote-block-type"),renderHTML:i=>KO(i)},mindmapId:{default:null,parseHTML:i=>i.getAttribute("data-mnote-mindmap-id"),renderHTML:()=>({})},rootNodeId:{default:null,parseHTML:i=>i.getAttribute("data-mnote-root-node-id"),renderHTML:()=>({})},projectionVersion:{default:null,parseHTML:i=>Number(i.getAttribute("data-mnote-projection-version")??1),renderHTML:()=>({})}}},addNodeView(){let i=aB(this.editor),e=oB();return({node:t,getPos:r})=>t.attrs.mnoteBlockType==="mindmap"?i({node:t,getPos:r}):e({node:t})}}),hB={name:"paragraph",create:()=>lB,commands:{set_paragraph:i=>i.chain().focus().setParagraph().run()},selection_keys:["paragraph"],selection_state:i=>({paragraph:i.isActive("paragraph")})};function xie(){$m(hB)}export{xie as register_paragraph}; + `,minExportImgCanvasScale:2,addContentToHeader:null,addContentToFooter:null,handleBeingExportSvg:null,maxCanvasSize:16384,defaultAssociativeLineText:"\u5173\u8054",associativeLineIsAlwaysAboveNode:!0,associativeLineInitPointsPosition:{from:"",to:""},enableAdjustAssociativeLinePoints:!0,beforeAssociativeLineConnection:null,disableTouchZoom:!1,minTouchZoomScale:20,maxTouchZoomScale:-1,isLimitMindMapInCanvasWhenHasScrollbar:!0,isOnlySearchCurrentRenderNodes:!1,beforeCooperateUpdate:null,rainbowLinesConfig:{open:!1,colorsList:[]},demonstrateConfig:null,enableEditFormulaInRichTextEdit:!0,katexFontPath:"https://unpkg.com/katex@0.16.11/dist/",getKatexOutputType:null,transformRichTextOnEnterEdit:null,beforeHideRichTextEdit:null,outerFramePaddingX:10,outerFramePaddingY:10,defaultOuterFrameText:"\u5916\u6846",onlyPainterNodeCustomStyles:!1,beforeDeleteNodeImg:null,imgResizeBtnSize:25,minImgResizeWidth:50,minImgResizeHeight:50,maxImgResizeWidthInheritTheme:!1,maxImgResizeWidth:1/0,maxImgResizeHeight:1/0,customDeleteBtnInnerHTML:"",customResizeBtnInnerHTML:""}});var ib={};tt(ib,{default:()=>HP});var Cp,_t,_p,HP,rb=T(()=>{Tv();kv();Gv();Cp=pt(O0());Vv();Y0();Yv();Qv();eb();$e();yt();pe();Ro();tb();_t=class i{constructor(e={}){if(i.instanceCount++,this.opt=this.handleOpt((0,Cp.default)(kp,e)),this.opt.data=this.handleData(this.opt.data),this.el=this.opt.el,!this.el)throw new Error("\u7F3A\u5C11\u5BB9\u5668\u5143\u7D20el");this.getElRectInfo(),this.initWidth=this.width,this.initHeight=this.height,this.cssEl=null,this.cssTextMap={},this.nodeInnerPrefixList=[],this.nodeInnerPostfixList=[],this.editNodeClassList=[],this.extendShapeList=[],this.initContainer(),this.initTheme(),this.initCache(),i.pluginList.filter(t=>t.preload).forEach(t=>{this.initPlugin(t)}),this.event=new Av({mindMap:this}),this.keyCommand=new h0({mindMap:this}),this.command=new Zv({mindMap:this}),this.renderer=new jv({mindMap:this}),this.view=new Mv({mindMap:this}),this.batchExecution=new Jv,i.pluginList.filter(t=>!t.preload).forEach(t=>{this.initPlugin(t)}),this.addCss(),this.render(this.opt.fit?()=>this.view.fit():()=>{}),this.opt.addHistoryOnInit&&this.opt.data&&this.command.addHistory()}handleOpt(e){return $c.includes(e.layout)||(e.layout=k.LAYOUT.LOGICAL_STRUCTURE),e.theme=e.theme&&jn[e.theme]?e.theme:"default",e}handleData(e){return Yt(e)||Object.keys(e).length<=0?null:(e=Kt(e||{}),e.data&&!e.data.expand&&(e.data.expand=!0),cs([e],!1,null,!0),e)}initContainer(){let{associativeLineIsAlwaysAboveNode:e}=this.opt;this.el.classList.add("smm-mind-map-container");let t=()=>{this.associativeLineDraw=this.draw.group(),this.associativeLineDraw.addClass("smm-associative-line-container")};this.svg=Ae().addTo(this.el).size(this.width,this.height),this.draw=this.svg.group(),this.draw.addClass("smm-container"),this.lineDraw=this.draw.group(),this.lineDraw.addClass("smm-line-container"),e||t(),this.nodeDraw=this.draw.group(),this.nodeDraw.addClass("smm-node-container"),e&&t(),this.otherDraw=this.draw.group(),this.otherDraw.addClass("smm-other-container")}clearDraw(){this.lineDraw.clear(),this.associativeLineDraw.clear(),this.nodeDraw.clear(),this.otherDraw.clear()}appendCss(e,t){this.cssTextMap[e]=t,this.removeCss(),this.addCss()}removeAppendCss(e){this.cssTextMap[e]&&(delete this.cssTextMap[e],this.removeCss(),this.addCss())}joinCss(){return C3+Object.keys(this.cssTextMap).map(e=>this.cssTextMap[e]).join(` +`)}addCss(){this.cssEl=document.createElement("style"),this.cssEl.type="text/css",this.cssEl.innerHTML=this.joinCss(),document.head.appendChild(this.cssEl)}removeCss(){this.cssEl&&document.head.removeChild(this.cssEl)}checkEditNodeClassIndex(e){return this.editNodeClassList.findIndex(t=>t===e)}addEditNodeClass(e){this.checkEditNodeClassIndex(e)===-1&&this.editNodeClassList.push(e)}deleteEditNodeClass(e){let t=this.checkEditNodeClassIndex(e);t!==-1&&this.editNodeClassList.splice(t,1)}render(e,t=""){this.initTheme(),this.renderer.render(e,t)}reRender(e,t=""){this.renderer.reRender=!0,this.renderer.clearCache(),this.clearDraw(),this.render(e,t)}getElRectInfo(){if(this.elRect=this.el.getBoundingClientRect(),this.width=this.elRect.width,this.height=this.elRect.height,this.width<=0||this.height<=0)throw new Error("\u5BB9\u5668\u5143\u7D20el\u7684\u5BBD\u9AD8\u4E0D\u80FD\u4E3A0")}resize(){let e=this.width,t=this.height;this.getElRectInfo(),this.svg.size(this.width,this.height),(e!==this.width||t!==this.height)&&(this.demonstrate?this.demonstrate.isInDemonstrate||this.render():this.render()),this.emit("resize")}on(e,t){this.event.on(e,t)}emit(e,...t){this.event.emit(e,...t)}off(e,t){this.event.off(e,t)}initCache(){this.commonCaches={measureCustomNodeContentSizeEl:null,measureRichtextNodeTextSizeEl:null}}initTheme(){this.themeConfig=wu(jn[this.opt.theme]||jn.default,this.opt.themeConfig),qo.setBackgroundStyle(this.el,this.themeConfig)}setTheme(e,t=!1){this.execCommand("CLEAR_ACTIVE_NODE"),this.opt.theme=e,t||this.render(null,k.CHANGE_THEME),this.emit("view_theme_change",e)}getTheme(){return this.opt.theme}setThemeConfig(e,t=!1){let r=N2(this.themeConfig,e);if(this.opt.themeConfig=e,!t){let n=u2(r);this.render(null,n?"":k.CHANGE_THEME)}}getCustomThemeConfig(){return this.opt.themeConfig}getThemeConfig(e){return e===void 0?this.themeConfig:this.themeConfig[e]}getConfig(e){return e===void 0?this.opt:this.opt[e]}updateConfig(e={}){this.emit("before_update_config",this.opt);let t={...this.opt};this.opt=this.handleOpt(Cp.default.all([kp,this.opt,e])),this.emit("after_update_config",this.opt,t)}getLayout(){return this.opt.layout}setLayout(e,t=!1){$c.includes(e)||(e=k.LAYOUT.LOGICAL_STRUCTURE),this.opt.layout=e,this.view.reset(),this.renderer.setLayout(),t||this.render(null,k.CHANGE_LAYOUT),this.emit("layout_change",e)}execCommand(...e){this.command.exec(...e)}updateData(e){e=this.handleData(e),this.emit("before_update_data",e),this.renderer.setData(e),this.render(),this.command.addHistory(),this.emit("update_data",e)}setData(e){e=this.handleData(e),this.emit("before_set_data",e),this.opt.data=e,this.execCommand("CLEAR_ACTIVE_NODE"),this.command.clearHistory(),this.command.addHistory(),this.renderer.setData(e),this.reRender(),this.emit("set_data",e)}setFullData(e){e.root&&this.setData(e.root),e.layout&&this.setLayout(e.layout),e.theme&&(e.theme.template&&this.setTheme(e.theme.template),e.theme.config&&this.setThemeConfig(e.theme.config)),e.view&&this.view.setTransformData(e.view)}getData(e){let t=this.command.getCopyData(),r={};return e?r={layout:this.getLayout(),root:t,theme:{template:this.getTheme(),config:this.getCustomThemeConfig()},view:this.view.getTransformData()}:r=t,Kt(r)}async export(...e){try{if(!this.doExport)throw new Error("\u8BF7\u6CE8\u518CExport\u63D2\u4EF6\uFF01");return await this.doExport.export(...e)}catch(t){this.opt.errorHandler(Mi.EXPORT_ERROR,t)}}toPos(e,t){return{x:e-this.elRect.left,y:t-this.elRect.top}}setMode(e){if(![k.MODE.READONLY,k.MODE.EDIT].includes(e))return;let t=e===k.MODE.READONLY;t!==this.opt.readonly&&(t&&(this.renderer.textEdit.isShowTextEdit()&&(this.renderer.textEdit.hideEditTextBox(),this.command.originAddHistory()),this.execCommand("CLEAR_ACTIVE_NODE")),this.opt.readonly=t,!t&&this.command.history.length<=0&&this.command.originAddHistory(),this.emit("mode_change",e))}getSvgData({paddingX:e=0,paddingY:t=0,ignoreWatermark:r=!1,addContentToHeader:n,addContentToFooter:s,node:a}={}){let{watermarkConfig:o,openPerformance:l}=this.opt;l&&this.renderer.forceLoadNode(a);let{cssTextList:h,header:d,headerHeight:c,footer:f,footerHeight:m}=R2({addContentToHeader:n,addContentToFooter:s}),g=this.svg,x=this.draw,y=g.width(),b=g.height(),S=x.transform(),A=this.elRect;x.scale(1/S.scaleX,1/S.scaleY);let C=x.rbox(),I=null;a&&(I=bu(a,C.x,C.y,e,t));let O=0;C.width+=e*2,C.height+=t*2+O+c+m,x.translate(e,t),g.size(C.width,C.height),x.translate(-C.x+A.left,-C.y+A.top);let q=g.clone(),P=this.watermark&&this.watermark.hasWatermark();if(!r&&P){this.watermark.isInExport=!0;let{onlyExport:re}=o;C.width>y||C.height>b?(this.width=C.width,this.height=C.height,this.watermark.onResize(),q=g.clone(),this.width=y,this.height=b,this.watermark.onResize()):re&&(this.watermark.onResize(),q=g.clone()),re&&this.watermark.clear(),this.watermark.isInExport=!1}[this.joinCss(),...h].forEach(re=>{q.add(Ae(``))}),d&&c>0&&(q.findOne(".smm-container").translate(0,c),d.width(C.width),d.y(t),q.add(d,0)),f&&m>0&&(f.width(C.width),f.y(C.height-t-m),q.add(f));let W=g.find("defs"),ne=q.find("defs");return W.forEach((re,oe)=>{let ke=ne[oe];if(!ke)return;let Q=re.children(),Y=ke.children();for(let le=0;ler.name===e.name)||this.extendShapeList.push(e)}removeShape(e){let t=this.extendShapeList.findIndex(r=>r.name===e);t!==-1&&this.extendShapeList.splice(t,1)}getSvgObjects(){return{SVG:Ae,G:_e,Rect:Ve}}addPlugin(e,t){i.hasPlugin(e)===-1&&i.usePlugin(e,t),this.initPlugin(e)}removePlugin(e){let t=i.hasPlugin(e);t!==-1&&(i.pluginList.splice(t,1),this[e.instanceName]&&(this[e.instanceName].beforePluginRemove&&this[e.instanceName].beforePluginRemove(),delete this[e.instanceName]))}initPlugin(e){this[e.instanceName]||(this[e.instanceName]=new e({mindMap:this,pluginOpt:e.pluginOpt}))}destroy(){this.emit("beforeDestroy"),this.renderer.textEdit.hideEditTextBox(),this.renderer.textEdit.removeTextEditEl(),[...i.pluginList].forEach(e=>{this[e.instanceName]&&this[e.instanceName].beforePluginDestroy&&this[e.instanceName].beforePluginDestroy(),this[e.instanceName]=null}),this.event.unbind(),this.svg.remove(),qo.removeBackgroundStyle(this.el),this.el.classList.remove("smm-mind-map-container"),this.el.innerHTML="",this.el=null,this.removeCss(),i.instanceCount--}},_p=[];_t.extendNodeDataNoStylePropList=(i=[])=>{_p.push(...i),$s.push(...i)};_t.resetNodeDataNoStylePropList=()=>{_p.forEach(i=>{let e=$s.findIndex(t=>t===i);e!==-1&&$s.splice(e,1)}),_p=[]};_t.pluginList=[];_t.usePlugin=(i,e={})=>(_t.hasPlugin(i)!==-1||(i.pluginOpt=e,_t.pluginList.push(i)),_t);_t.hasPlugin=i=>_t.pluginList.findIndex(e=>e===i);_t.instanceCount=0;_t.defineTheme=(i,e={})=>{if(jn[i])return new Error("\u8BE5\u4E3B\u9898\u540D\u79F0\u5DF2\u5B58\u5728");jn[i]=wu(B0,e)};_t.removeTheme=i=>{jn[i]&&(jn[i]=null)};HP=_t});var Ic=globalThis.__LEPTOS_TIPTAP_BRIDGE__;if(Ic==null||Ic.modules==null)throw new Error("leptos-tiptap bridge bindings are unavailable");var j=Ic.modules["@tiptap/core"];if(j==null)throw new Error('leptos-tiptap bridge module "@tiptap/core" is unavailable');var tq=j.CommandManager,iq=j.Editor,rq=j.Extension,nq=j.InputRule,sq=j.Mark,f3=j.Node,aq=j.NodePos,oq=j.NodeView,lq=j.PasteRule,hq=j.Tracker,dq=j.callOrReturn,cq=j.canInsertNode,uq=j.combineTransactionSteps,fq=j.createChainableState,mq=j.createDocument,pq=j.createNodeFromContent,gq=j.createStyleTag,xq=j.defaultBlockAt,yq=j.deleteProps,vq=j.elementFromString,bq=j.escapeForRegEx,wq=j.extensions,Mq=j.findChildren,Tq=j.findChildrenInRange,Nq=j.findDuplicates,Eq=j.findParentNode,Sq=j.findParentNodeClosestToPos,Aq=j.fromString,kq=j.generateHTML,Cq=j.generateJSON,_q=j.generateText,Lq=j.getAttributes,Iq=j.getAttributesFromExtensions,zq=j.getChangedRanges,Rq=j.getDebugJSON,Dq=j.getExtensionField,Oq=j.getHTMLFromFragment,Bq=j.getMarkAttributes,Pq=j.getMarkRange,Fq=j.getMarkType,qq=j.getMarksBetween,Hq=j.getNodeAtPosition,Uq=j.getNodeAttributes,$q=j.getNodeType,jq=j.getRenderedAttributes,Gq=j.getSchema,Vq=j.getSchemaByResolvedExtensions,Wq=j.getSchemaTypeByName,Yq=j.getSchemaTypeNameByName,Xq=j.getSplittedAttributes,Kq=j.getText,Zq=j.getTextBetween,Qq=j.getTextContentFromNodes,Jq=j.getTextSerializersFromSchema,eH=j.injectExtensionAttributesToParseRule,tH=j.inputRulesPlugin,iH=j.isActive,rH=j.isAtEndOfNode,nH=j.isAtStartOfNode,sH=j.isEmptyObject,aH=j.isExtensionRulesEnabled,oH=j.isFunction,lH=j.isList,hH=j.isMacOS,dH=j.isMarkActive,cH=j.isNodeActive,uH=j.isNodeEmpty,fH=j.isNodeSelection,mH=j.isNumber,pH=j.isPlainObject,gH=j.isRegExp,xH=j.isSafari,yH=j.isString,vH=j.isTextSelection,bH=j.isiOS,wH=j.markInputRule,MH=j.markPasteRule,m3=j.mergeAttributes,TH=j.mergeDeep,NH=j.minMax,EH=j.nodeInputRule,SH=j.nodePasteRule,AH=j.objectIncludes,kH=j.pasteRulesPlugin,CH=j.posToDOMRect,_H=j.removeDuplicates,LH=j.resolveFocusPosition,IH=j.rewriteUnknownContent,zH=j.selectionToInsertionEnd,RH=j.splitExtensions,DH=j.textInputRule,OH=j.textPasteRule,BH=j.textblockTypeInputRule,PH=j.wrappingInputRule;var p3=f3.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:i}){return["p",m3(this.options.HTMLAttributes,i),0]},addCommands(){return{setParagraph:()=>({commands:i})=>i.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var g3="__LEPTOS_TIPTAP_BRIDGE__";function nw(){let i=globalThis,e=i[g3];if(e!=null)return e;let t={modules:{},registerExtension:()=>{throw new Error("leptos-tiptap bridge runtime is not initialized")}};return i[g3]=t,t}function x3(){return nw()}function y3(i){x3().registerExtension(i)}var Dc={};tt(Dc,{applyMetadataOnlyMindmapCommands:()=>M3,applyMindmapCommandsLocally:()=>hw,isLocallyApplicableMindmapCommandSet:()=>lw,isMetadataOnlyMindmapCommandSet:()=>ow});var sw={data:{text:"\u4E2D\u5FC3\u4E3B\u9898"},children:[]},gt=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),nr=i=>JSON.parse(JSON.stringify(i)),b3=i=>{let e=gt(i)?nr(i):nr(sw);return gt(e.data)||(e.data={text:"\u4E2D\u5FC3\u4E3B\u9898"}),Array.isArray(e.children)||(e.children=[]),e},w3=(i,e)=>{if(!gt(i)||!gt(e))return nr(e);let t={...i};return Object.entries(e).forEach(([r,n])=>{if(n===null){delete t[r];return}t[r]=gt(t[r])&>(n)?w3(t[r],n):nr(n)}),t},zc=(i,e,t)=>{let r=e.split(".").filter(Boolean);if(r.length===0)return!1;let n=i;for(let s of r.slice(0,-1))gt(n[s])||(n[s]={}),n=n[s];return n[r[r.length-1]]=nr(t),!0},N0=(i,e)=>{if(!gt(i))return null;let t=gt(i.data)?i.data:null;if(typeof t?.uid=="string"&&t.uid===e)return i;let r=Array.isArray(i.children)?i.children:[];for(let n of r){let s=N0(n,e);if(s)return s}return null},Rc=(i,e)=>{for(let t=0;t({data:{uid:i.uid??`node_${Date.now().toString(36)}`,text:i.text,...typeof i.hyperlink=="string"?{hyperlink:i.hyperlink}:{},...typeof i.note=="string"?{note:i.note}:{},...Array.isArray(i.refs)?{refs:nr(i.refs)}:{}},children:[]}),aw=(i,e)=>{let t=String(e.path||"").trim();if(!t)return!1;if(t.startsWith("root.data.")){let n=t.slice(10),s=gt(i.data)?i.data:i.data={};return zc(s,n,e.value)}if(t.startsWith("nodes.")){let[,n,s,...a]=t.split(".");if(!n||s!=="data"||a.length===0)return!1;let o=N0(i,n);if(!o)return!1;let l=gt(o.data)?o.data:o.data={};return zc(l,a.join("."),e.value)}let r=gt(i.compatPayload)?i.compatPayload:i.compatPayload={};return zc(r,t,e.value)},ow=i=>Array.isArray(i)&&i.every(e=>!gt(e)||typeof e.type!="string"?!1:["setLayout","setTheme","patchView","compatPayloadPatch"].includes(e.type)),lw=i=>Array.isArray(i)&&i.every(e=>!gt(e)||typeof e.type!="string"?!1:["updateText","insertChild","insertSiblingAfter","deleteNode","setLayout","setTheme","patchView","compatPayloadPatch"].includes(e.type)),M3=(i,e)=>{let t=b3(i),r=[],n=0;return e.forEach(s=>{if(s.type==="setLayout"){t.layout=nr(s.layout),n+=1;return}if(s.type==="setTheme"){t.theme=nr(s.theme),s.themeConfig!==void 0&&s.themeConfig!==null&&(t.themeConfig=nr(s.themeConfig)),n+=1;return}if(s.type==="patchView"){t.view=w3(t.view??{},s.patch),n+=1;return}s.type==="compatPayloadPatch"&&(aw(t,s)?n+=1:r.push(`\u65E0\u6CD5\u5E94\u7528 compatPayloadPatch:${s.path}`))}),{applied:n,data:t,errors:r}},hw=(i,e)=>{let t=b3(i),r=[],n=0;return e.forEach(s=>{if(s.type==="setLayout"||s.type==="setTheme"||s.type==="patchView"||s.type==="compatPayloadPatch"){let a=M3(t,[s]);Object.assign(t,a.data),n+=a.applied,r.push(...a.errors);return}if(s.type==="updateText"){let a=N0(t,s.nodeId);if(!a){r.push(`\u672A\u627E\u5230\u8282\u70B9:${s.nodeId}`);return}let o=gt(a.data)?a.data:a.data={};o.text=s.text,n+=1;return}if(s.type==="insertChild"){let a=N0(t,s.parentNodeId);if(!a){r.push(`\u672A\u627E\u5230\u7236\u8282\u70B9:${s.parentNodeId}`);return}(Array.isArray(a.children)?a.children:a.children=[]).push(v3(s.node)),n+=1;return}if(s.type==="insertSiblingAfter"){let a=Rc([t],s.targetNodeId);if(!a){r.push(`\u672A\u627E\u5230\u540C\u7EA7\u8282\u70B9:${s.targetNodeId}`);return}if(a.parentChildren[a.index]===t){r.push("\u6839\u8282\u70B9\u4E0D\u652F\u6301\u63D2\u5165\u540C\u7EA7\u8282\u70B9");return}a.parentChildren.splice(a.index+1,0,v3(s.node)),n+=1;return}if(s.type==="deleteNode"){let a=Rc([t],s.nodeId);if(!a){r.push(`\u672A\u627E\u5230\u5220\u9664\u8282\u70B9:${s.nodeId}`);return}if(a.parentChildren[a.index]===t){r.push("\u6839\u8282\u70B9\u4E0D\u652F\u6301\u5220\u9664");return}a.parentChildren.splice(a.index,1),n+=1}}),{applied:n,data:t,errors:r}};var Dp={};tt(Dp,{MindmapCommandBridgeError:()=>lo,createLeptosMindmapAdapter:()=>rF,createMindmapAdapterProjectionEndpoint:()=>lb,createMindmapCommandApplyEndpoint:()=>zp,executeMindmapCommandApply:()=>hb,executeMindmapCommandApplyAndRefreshProjection:()=>tF,executeMindmapDataPutAndRefreshProjection:()=>iF,isMindmapAdapterProjection:()=>Ip,requestMindmapAdapterProjection:()=>Rp});var Pc={};tt(Pc,{DEFAULT_MINDMAP_LAYOUT:()=>E0,DEFAULT_MINDMAP_THEME:()=>S0,buildMindmapEditorScene:()=>cw,buildMindmapProjection:()=>dw,buildMindmapSimpleMindMapScene:()=>uw,canonicalizeMindmapData:()=>ci,createDefaultMindmapThemeConfig:()=>A0,defaultMindmapData:()=>Us,extractMindmapTitle:()=>Bc,normalizeMindmapData:()=>Oc,summarizeMindmapProjectionNodes:()=>T3});var Us={data:{text:"\u4E2D\u5FC3\u4E3B\u9898"},children:[]},E0="logicalStructure",S0="default",A0=()=>({lineColor:"#7aa2ff",lineStyle:"curve",rootLineKeepSameInCurve:!0,rootLineStartPositionKeepSameInCurve:!0,generalizationLineColor:"#ef6a5b",backgroundColor:"#f6f8fc",root:{fillColor:"#e25563",color:"#ffffff",fontWeight:"bold",borderColor:"transparent",borderWidth:0,borderRadius:8},second:{fillColor:"#4f7df3",color:"#ffffff",borderColor:"transparent",borderWidth:0,borderRadius:8},node:{fillColor:"transparent",color:"#315aa9",borderColor:"transparent",borderWidth:0},generalization:{fillColor:"#ffffff",color:"#ef6a5b",borderColor:"#ef6a5b",borderWidth:1,borderRadius:8}}),Hs=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),Oc=i=>{if(!i||typeof i!="object")return Us;let e=i.root??i,t=r=>{if(!Hs(r))return;let n=Hs(r.data)?r.data:{};r.data=n;let s=n.text;n.text=typeof s=="string"?s:String(s??"");let a=n.generalization,o=l=>{if(!Hs(l))return;let h=l.text;l.text=typeof h=="string"?h:String(h??"")};Array.isArray(a)?a.forEach(o):o(a),Array.isArray(r.children)&&r.children.forEach(t)};return t(e),i},ci=i=>{let e=Oc(i)??Us,t=e&&typeof e=="object"&&"root"in e?e.root:e;return Oc(t)??Us},Bc=i=>{let t=ci(i)?.data?.text;return typeof t=="string"&&t.trim()?t.trim():"\u672A\u547D\u540D\u5BFC\u56FE"},T3=i=>{let t=[{node:ci(i),depth:0}],r=[];for(;t.length>0;){let n=t.shift();if(!n)break;let s=n.node?.data?.uid,a=n.node?.data?.text,o=Array.isArray(n.node?.children)?n.node.children:[];r.push({uid:typeof s=="string"&&s.trim()?s:`depth:${n.depth}:index:${r.length}`,text:typeof a=="string"&&a.trim()?a.trim():"\u672A\u547D\u540D\u8282\u70B9",depth:n.depth,childCount:o.length}),o.forEach(l=>{t.push({node:ci(l),depth:n.depth+1})})}return r},dw=i=>{let e=ci(i.data),t=T3(e),r=Hs(i.meta)?i.meta:null,n=t[0]?.uid??null;return{schema:"mnote.mindmap_projection.v1",projectionId:`mindmap_projection:${i.documentId}:${i.mindmapId}`,projection:"mindmap_subtree",source:i.source??"rust-kernel",owner:i.owner??"rust-kernel",documentId:i.documentId,mindmapId:i.mindmapId,rootNodeId:n,title:Bc(e),nodeCount:t.length,nodes:t,data:e,meta:r}},cw=i=>{let e=ci(i.data),t=Hs(i.meta)?i.meta:null,r=[],n=[],s=(l,h,d)=>{let c=l?.data?.uid,f=l?.data?.text,m=typeof c=="string"&&c.trim()?c.trim():`depth:${h}:index:${r.length}`,g=Array.isArray(l?.children)?l.children:[];r.push({id:m,uid:m,text:typeof f=="string"&&f.trim()?f.trim():"\u672A\u547D\u540D\u8282\u70B9",depth:h,childCount:g.length,parentId:d}),d&&n.push({id:`${d}->${m}`,source:d,target:m}),g.forEach(x=>{s(ci(x),h+1,m)})};s(e,0,null);let a=r[0]?.id??null,o=i.rootNodeId&&i.rootNodeId.trim()?i.rootNodeId.trim():a;return{schema:"mnote.mindmap_editor_scene.v1",source:i.source??"rust-kernel",owner:i.owner??"rust-kernel",documentId:i.documentId,mindmapId:i.mindmapId,rootNodeId:o,title:Bc(e),nodes:r,edges:n,capabilities:{canEditText:!0,canAddChild:!0,canAddSiblingAfter:!0,canDeleteNode:!0},data:e,meta:t}},uw=i=>{let e=ci(i.data),t=Hs(i.meta)?i.meta:null,r=e?.data?.uid,n=typeof r=="string"&&r.trim()?r.trim():"root";return e.data.uid||(e.data.uid=n),{schema:"mnote.mindmap.simple_mind_map_scene.v1",runtime:"simple-mind-map",documentId:i.documentId,mindmapId:i.mindmapId,rootNodeId:n,root:e,layout:E0,theme:S0,themeConfig:A0(),view:{x:0,y:0,scale:1},config:{},compatPayload:{},kernelRevision:1,source:i.source??"rust-kernel",owner:i.owner??"rust-kernel",meta:t}};var UP=["Drag","KeyboardNavigation","Export","Select","AssociativeLine","Search","OuterFrame"],$P=["Scrollbar","MiniMap","Painter","Formula"],jP=["data_change","view_data_change","node_active","back_forward","scale","translate"],GP=new Set(["BACK","FORWARD","INSERT_NODE","INSERT_CHILD_NODE","REMOVE_NODE","DELETE_NODE","ADD_GENERALIZATION","ADD_OUTER_FRAME","SET_NOTATION"]),ao=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),nb=(i,e)=>{if(typeof i=="string"&&i.trim())return i.trim();if(ao(i)){let t=i.template;if(typeof t=="string"&&t.trim())return t.trim()}return e},sb=i=>ao(i)?i:{},ab=i=>!ao(i)||Object.keys(i).length===0?A0():i,VP=i=>!ao(i)||!ao(i.state)?null:{...i,state:i.state,transform:ao(i.transform)?i.transform:{}},WP=i=>{let e=ci(i.projection.root??Us),t=sb(i.projection.config),r=sb(i.runtimeOptions);return{...t,...r,el:i.el,data:e,fit:typeof r.fit=="boolean"?r.fit:typeof t.fit=="boolean"?t.fit:!0,layout:nb(i.projection.layout,E0),theme:nb(i.projection.theme,S0),themeConfig:ab(i.projection.themeConfig),viewData:VP(i.projection.view),initRootNodePosition:["center","center"]}},YP={Drag:()=>Promise.resolve().then(()=>(J2(),Q2)),KeyboardNavigation:()=>Promise.resolve().then(()=>(t6(),e6)),Export:()=>Promise.resolve().then(()=>(d6(),h6)),Select:()=>Promise.resolve().then(()=>(u6(),c6)),AssociativeLine:()=>Promise.resolve().then(()=>(b6(),v6)),Search:()=>Promise.resolve().then(()=>(M6(),w6)),OuterFrame:()=>Promise.resolve().then(()=>(k6(),A6)),Scrollbar:()=>Promise.resolve().then(()=>(_6(),C6)),MiniMap:()=>Promise.resolve().then(()=>(I6(),L6)),Painter:()=>Promise.resolve().then(()=>(R6(),z6)),Formula:()=>Promise.resolve().then(()=>(wv(),bv))},XP=()=>[...UP,...$P],KP=async(i=XP())=>{if(typeof window>"u"||typeof document>"u")throw new Error("simple_mind_map_browser_required");let[{default:e},t]=await Promise.all([Promise.resolve().then(()=>(rb(),ib)),Promise.all(i.map(async s=>[s,(await YP[s]()).default]))]),r=e,n=[];return t.forEach(([s,a])=>{if(!a||typeof r.usePlugin!="function")return;typeof r.hasPlugin=="function"&&r.hasPlugin(a)!==-1||r.usePlugin(a),n.push(s)}),{MindMap:r,registeredPlugins:n}},ZP=i=>(e,...t)=>{if(!GP.has(e))return{ok:!1,command:e,error:"unsupported_command"};if(typeof i.execCommand!="function")return{ok:!1,command:e,error:"runtime_unavailable"};try{return{ok:!0,command:e,result:i.execCommand(e,...t)}}catch{return{ok:!1,command:e,error:"command_failed"}}},QP=i=>{let e=[];return jP.forEach(t=>{let r=(...n)=>{let s=t==="data_change"?i.instance.getData?.():t==="view_data_change"?i.instance.getData?.(!0)??i.instance.getData?.():void 0;i.onEvent?.({type:t,args:n,snapshot:s,kernelRevision:i.projection.kernelRevision})};i.instance.on?.(t,r),e.push(()=>i.instance.off?.(t,r))}),()=>e.splice(0).forEach(t=>t())},ob=async i=>{let e=await KP(i.pluginNames),t=ab(i.projection.themeConfig),r=WP({el:i.el,projection:i.projection,runtimeOptions:i.runtimeOptions}),n=new e.MindMap(r);n.setThemeConfig?.(t),i.mode&&n.setMode?.(i.mode);let s=QP({instance:n,projection:i.projection,onEvent:i.onEvent}),a=ZP(n);return{instance:n,execCommand:a,getSnapshot:()=>n.getData?.(!0)??n.getData?.(),destroy:()=>{n.renderer?.textEdit?.hideEditTextBox?.(),s(),n.destroy?.()}}};var lo=class extends Error{constructor(e,t=null){super(e),this.name="MindmapCommandBridgeError",this.code="command_failed",this.status=t}},oo=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),Lp=i=>{if(!oo(i))return"";let e=[i.error,i.message,i.details].map(t=>typeof t=="string"?t.trim():Array.isArray(t)&&t.length>0?t.join("|"):"").find(Boolean);return e?`:${e}`:""},JP=async i=>{if(typeof i.text!="function"){let t=await i.json().catch(()=>null);return Lp(t)}let e=await i.text().catch(()=>"");if(!e.trim())return"";try{return Lp(JSON.parse(e))||`:${e.trim()}`}catch{return`:${e.trim()}`}},Ip=i=>oo(i)?i.schema==="mnote.mindmap.simple_mind_map_scene.v1"&&i.runtime==="simple-mind-map"&&"root"in i&&typeof i.kernelRevision=="number":!1,lb=(i,e)=>{let t=encodeURIComponent(i),r=encodeURIComponent(e);return`/api/mindmap/${t}/${r}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get`},zp=(i,e)=>{let t=encodeURIComponent(i),r=encodeURIComponent(e);return`/api/mindmap/${t}/${r}`},Rp=async i=>{let e=i.fetcher??fetch,t=i.endpoint??lb(i.documentId,i.mindmapId),r=await e(t,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`projection_load_failed:${r.status}`);let n=await r.json(),s=oo(n)&&"result"in n?n.result:n;if(!Ip(s))throw new Error("projection_load_failed:invalid_adapter_projection");return s},eF=i=>{if(!oo(i))return null;let e=[i.kernelRevision,i.projectionRevision,oo(i.result)?i.result.kernelRevision:null,oo(i.result)?i.result.projectionRevision:null];for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return null},hb=async i=>{if(i.commands.length===0)throw new lo("command_failed:empty_commands");let e=i.fetcher??fetch,t=i.endpoint??zp(i.documentId,i.mindmapId),r=JSON.stringify({commandName:"mindmap.command.apply",documentId:i.documentId,mindmapId:i.mindmapId,commands:i.commands,projectionRevision:i.projectionRevision??null}),n=await e(t,{method:"POST",keepalive:r.length<=6e4,headers:{Accept:"application/json","Content-Type":"application/json"},body:r}),s=await n.json().catch(()=>null);if(!n.ok){let a=Lp(s);throw new lo(`command_failed:${n.status}${a}`,n.status)}return{ok:!0,kernelRevision:eF(s),raw:s}},tF=async i=>(await hb(i),Rp({documentId:i.documentId,mindmapId:i.mindmapId,endpoint:i.projectionEndpoint,fetcher:i.fetcher})),iF=async i=>{let e=i.fetcher??fetch,t=i.endpoint??zp(i.documentId,i.mindmapId),r=await e(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({data:i.data,createOnly:!1})});if(!r.ok){let n=await JP(r);throw new lo(`command_failed:${r.status}${n}`,r.status)}return await r.json().catch(()=>null),Rp({documentId:i.documentId,mindmapId:i.mindmapId,endpoint:i.projectionEndpoint,fetcher:e})},rF=async i=>{if(!Ip(i.projection))throw new Error("adapter_init_failed:invalid_projection");return ob(i)};var Fp={};tt(Fp,{createCompatPayloadPatch:()=>Tc,createLayoutCommand:()=>Pp,createThemeCommand:()=>Bp,createToolbarKernelCommand:()=>Op,createViewPatchCommand:()=>nF,diffMindmapRuntimeDataToKernelCommands:()=>hF});var db=i=>({text:i?.text?.trim()||"\u65B0\u8282\u70B9",...i?.uid?{uid:i.uid}:{},...i?.hyperlink?{hyperlink:i.hyperlink}:{},...i?.note?{note:i.note}:{},...i?.refs?{refs:i.refs}:{}}),Op=i=>{let e=i.activeNodeId?.trim();switch(i.runtimeCommand){case"INSERT_CHILD_NODE":return e?{type:"insertChild",mindmapId:i.mindmapId,parentNodeId:e,node:db(i.newNode)}:null;case"INSERT_NODE":return e?{type:"insertSiblingAfter",mindmapId:i.mindmapId,targetNodeId:e,node:db(i.newNode)}:null;case"REMOVE_NODE":case"DELETE_NODE":return e?{type:"deleteNode",mindmapId:i.mindmapId,nodeId:e}:null;case"ADD_GENERALIZATION":return{type:"compatPayloadPatch",mindmapId:i.mindmapId,path:"root.data.generalization",value:{text:"\u6982\u8981"},source:"toolbar"};case"ADD_OUTER_FRAME":return{type:"compatPayloadPatch",mindmapId:i.mindmapId,path:"outerFrame",value:{enabled:!0,activeNodeId:e},source:"toolbar"};default:return null}},nF=(i,e)=>({type:"patchView",mindmapId:i,patch:e}),Bp=(i,e,t)=>({type:"setTheme",mindmapId:i,theme:e,themeConfig:t}),Pp=(i,e)=>({type:"setLayout",mindmapId:i,layout:e}),Tc=i=>({type:"compatPayloadPatch",mindmapId:i.mindmapId,path:i.path,value:i.value,source:i.source,...i.actionId?{actionId:i.actionId}:{},...typeof i.runtimeRevision=="number"?{runtimeRevision:i.runtimeRevision}:{},...typeof i.kernelRevision=="number"?{kernelRevision:i.kernelRevision}:{}}),sF=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),aF=(i,e)=>{let t=i.data?.uid;return typeof t=="string"&&t.trim()?t.trim():e},oF=i=>{let e=i.data?.text;return typeof e=="string"?e:String(e??"")},cb=i=>{let e=ci(i),t=new Map,r=(n,s,a,o)=>{let l=aF(n,o),h=sF(n.data)?n.data:{};t.set(l,{uid:l,parentUid:s,order:a,text:oF(n),data:h,node:n}),(Array.isArray(n.children)?n.children:[]).forEach((c,f)=>{r(ci(c),l,f,`${o}.${f}`)})};return r(e,null,0,"root"),t},ub=i=>JSON.stringify(i??null),fb=i=>({uid:i.uid,text:i.text||"\u65B0\u8282\u70B9",...typeof i.data.hyperlink=="string"?{hyperlink:i.data.hyperlink}:{},...typeof i.data.note=="string"?{note:i.data.note}:{},...Array.isArray(i.data.refs)?{refs:i.data.refs}:{}}),lF=(i,e,t,r)=>{let n=new Set(["uid","text","refs"]);new Set([...Object.keys(e.data),...Object.keys(t.data)]).forEach(a=>{n.has(a)||ub(e.data[a])!==ub(t.data[a])&&r.push(Tc({mindmapId:i,path:`nodes.${t.uid}.data.${a}`,value:t.data[a],source:"adapter-diff"}))})},hF=i=>{let e=cb(i.previous),t=cb(i.next),r=[],n=[];return t.forEach((s,a)=>{let o=e.get(a);if(!o){let l=Array.from(t.values()).find(h=>h.parentUid===s.parentUid&&h.order===s.order-1&&e.has(h.uid));l?r.push({type:"insertSiblingAfter",mindmapId:i.mindmapId,targetNodeId:l.uid,node:fb(s)}):s.parentUid&&r.push({type:"insertChild",mindmapId:i.mindmapId,parentNodeId:s.parentUid,node:fb(s)});return}o.text!==s.text&&r.push({type:"updateText",mindmapId:i.mindmapId,nodeId:a,text:s.text}),(o.parentUid!==s.parentUid||o.order!==s.order)&&r.push({type:"moveNode",mindmapId:i.mindmapId,nodeId:a,newParentNodeId:s.parentUid??"",order:s.order}),lF(i.mindmapId,o,s,n)}),e.forEach((s,a)=>{!t.has(a)&&s.parentUid&&r.push({type:"deleteNode",mindmapId:i.mindmapId,nodeId:a})}),{commands:r,compatPatches:n}};var Hp={};tt(Hp,{getMindmapActionMapping:()=>Nc,listMindmapActionMappings:()=>qp,mapMindmapActionToCommand:()=>cF});var zs=i=>e=>e?`nodes.${e}.data.${i}`:null,mb=[{actionId:"undo",target:"runtimeCommand",runtimeCommand:"BACK",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"redo",target:"runtimeCommand",runtimeCommand:"FORWARD",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"editNode",target:"localView",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"insertSiblingAfter",target:"runtimeCommand",runtimeCommand:"INSERT_NODE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"insertChild",target:"runtimeCommand",runtimeCommand:"INSERT_CHILD_NODE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"deleteNode",target:"runtimeCommand",runtimeCommand:"REMOVE_NODE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"summary",target:"runtimeCommand",runtimeCommand:"ADD_GENERALIZATION",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"associativeLine",target:"compatPatch",runtimeCommand:"ADD_ASSOCIATIVE_LINE",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"setTheme",target:"kernelCommand",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"setLayout",target:"kernelCommand",requiresActiveNode:!1,readonlyAllowed:!1},{actionId:"tag",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("tag")},{actionId:"hyperlink",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("hyperlink")},{actionId:"note",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("note")},{actionId:"image",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("image")},{actionId:"icon",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("icon")},{actionId:"formula",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("formula")},{actionId:"painter",target:"compatPatch",requiresActiveNode:!0,readonlyAllowed:!1,compatPath:zs("style")},{actionId:"import",target:"compatPatch",requiresActiveNode:!1,readonlyAllowed:!1,compatPath:()=>"import"},{actionId:"export",target:"runtimeCommand",runtimeCommand:"EXPORT",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"centerRoot",target:"localView",runtimeMethod:"centerRoot",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"zoomIn",target:"localView",runtimeMethod:"zoomIn",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"zoomOut",target:"localView",runtimeMethod:"zoomOut",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"fitView",target:"localView",runtimeMethod:"fitView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"fullscreenCanvas",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"fullscreenPage",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"exitFullscreen",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"search",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"showMenu",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0},{actionId:"expandCollapse",target:"localView",requiresActiveNode:!0,readonlyAllowed:!1},{actionId:"copyNodeText",target:"localView",requiresActiveNode:!0,readonlyAllowed:!0},{actionId:"readonly",target:"localView",requiresActiveNode:!1,readonlyAllowed:!0}],qp=()=>mb,Nc=i=>mb.find(e=>e.actionId===i)??null,dF=i=>{let e=i?.trim();return e||null},cF=i=>{let e=Nc(i.actionId);if(!e)return null;let t=dF(i.activeNodeId);if(e.requiresActiveNode&&!t)return null;if(i.actionId==="setTheme")return{command:Bp(i.mindmapId,i.value,i.themeConfig)};if(i.actionId==="setLayout")return{command:Pp(i.mindmapId,i.value)};if(i.actionId==="editNode")return{command:{type:"updateText",mindmapId:i.mindmapId,nodeId:t??"root",text:typeof i.value=="string"?i.value:""}};if(e.runtimeCommand&&["INSERT_CHILD_NODE","INSERT_NODE","DELETE_NODE","REMOVE_NODE"].includes(e.runtimeCommand)){let r=Op({mindmapId:i.mindmapId,runtimeCommand:e.runtimeCommand,activeNodeId:t,newNode:i.node});return r?{runtimeCommand:e.runtimeCommand,command:r}:{runtimeCommand:e.runtimeCommand}}if(e.compatPath){let r=e.compatPath(t);return r?{command:Tc({mindmapId:i.mindmapId,path:r,value:i.value??!0,source:i.source??"toolbar",actionId:i.actionId,runtimeRevision:i.runtimeRevision,kernelRevision:i.kernelRevision})}:null}return e.runtimeCommand?{runtimeCommand:e.runtimeCommand}:{}};var $p={};tt($p,{createDefaultMindmapShellInteractionState:()=>gb,deriveMindmapUiState:()=>wF,reduceMindmapChromeVisibility:()=>bF});var Up={};tt(Up,{MINDMAP_DEBUG_CHROME_QUERY_PARAM:()=>pb,MINDMAP_TOOLBAR_MORE_ACTION_ID:()=>uF,isMindmapDebugChromeEnabled:()=>pF,mindmapDefaultUiSchema:()=>ho,mindmapToolbarFileActionOrder:()=>mF,mindmapToolbarPrimaryActionOrder:()=>fF});var pb="mnoteMindmapDebugChrome",uF="more",fF=["undo","redo","editNode","insertSiblingAfter","deleteNode","insertChild","tag","hyperlink","note","image","icon","summary","associativeLine","formula"],mF=["import","export"],Ee=(i,e,t,r,n,s,a)=>({id:i,iconKey:e,shortLabel:t,longLabel:r,priority:n,overflowGroup:s,cluster:a}),ho={toolbarGroups:[{id:"history",label:"\u5386\u53F2",actions:["undo","redo"],collapsePriority:4},{id:"node",label:"\u8282\u70B9",actions:["editNode","insertSiblingAfter","deleteNode","insertChild"],collapsePriority:1},{id:"insert",label:"\u63D2\u5165",actions:["tag","hyperlink","note","image","icon","summary","associativeLine","formula"],collapsePriority:2},{id:"file",label:"\u6587\u4EF6",actions:["import","export"],collapsePriority:5},{id:"view",label:"\u89C6\u56FE",actions:["painter","centerRoot","zoomOut","zoomIn","search","readonly"],collapsePriority:3}],toolbarActionMeta:{undo:Ee("undo","undo","\u64A4\u9500","\u64A4\u9500",10,"history","main"),redo:Ee("redo","redo","\u91CD\u505A","\u91CD\u505A",20,"history","main"),editNode:Ee("editNode","type","\u7F16\u8F91","\u7F16\u8F91\u8282\u70B9",30,"node","main"),insertSiblingAfter:Ee("insertSiblingAfter","sibling","\u540C\u7EA7","\u63D2\u5165\u540C\u7EA7\u8282\u70B9",40,"node","main"),deleteNode:Ee("deleteNode","trash","\u5220\u9664","\u5220\u9664\u8282\u70B9",50,"node","main"),insertChild:Ee("insertChild","child","\u5B50\u7EA7","\u63D2\u5165\u5B50\u8282\u70B9",60,"node","main"),tag:Ee("tag","tag","\u6807\u7B7E","\u6807\u7B7E",70,"insert","main"),hyperlink:Ee("hyperlink","link","\u94FE\u63A5","\u8D85\u94FE\u63A5",80,"insert","main"),note:Ee("note","note","\u5907\u6CE8","\u5907\u6CE8",90,"insert","main"),image:Ee("image","image","\u56FE\u7247","\u56FE\u7247",100,"insert","main"),icon:Ee("icon","smile","\u56FE\u6807","\u56FE\u6807",110,"insert","main"),summary:Ee("summary","summary","\u6982\u8981","\u6982\u8981",120,"insert","main"),associativeLine:Ee("associativeLine","route","\u5173\u8054","\u5173\u8054\u7EBF",130,"insert","main"),formula:Ee("formula","formula","\u516C\u5F0F","\u516C\u5F0F",140,"insert","main"),painter:Ee("painter","paintbrush","\u683C\u5F0F","\u683C\u5F0F\u5237",210,"view","view"),import:Ee("import","import","\u5BFC\u5165","\u5BFC\u5165",310,"file","file"),export:Ee("export","export","\u5BFC\u51FA","\u5BFC\u51FA",320,"file","file"),setTheme:Ee("setTheme","palette","\u4E3B\u9898","\u4E3B\u9898",410,"view","view"),setLayout:Ee("setLayout","layout","\u7ED3\u6784","\u7ED3\u6784",420,"view","view"),zoomIn:Ee("zoomIn","zoom-in","\u653E\u5927","\u653E\u5927",510,"view","view"),zoomOut:Ee("zoomOut","zoom-out","\u7F29\u5C0F","\u7F29\u5C0F",500,"view","view"),fitView:Ee("fitView","fit","\u9002\u5E94","\u9002\u5E94\u753B\u5E03",520,"view","view"),centerRoot:Ee("centerRoot","target","\u56DE\u6839","\u56DE\u5230\u6839\u8282\u70B9",490,"view","view"),fullscreenCanvas:Ee("fullscreenCanvas","fullscreen","\u5168\u5C4F","\u5168\u5C4F\u67E5\u770B",550,"view","view"),fullscreenPage:Ee("fullscreenPage","fullscreen-page","\u5168\u9875","\u5168\u5C4F\u7F16\u8F91",560,"view","view"),exitFullscreen:Ee("exitFullscreen","exit-fullscreen","\u9000\u51FA","\u9000\u51FA\u5168\u5C4F",570,"view","view"),search:Ee("search","search","\u641C\u7D22","\u641C\u7D22",530,"view","view"),showMenu:Ee("showMenu","menu","\u83DC\u5355","\u663E\u793A\u83DC\u5355",580,"view","view"),expandCollapse:Ee("expandCollapse","expand","\u5C55\u5F00","\u5C55\u5F00/\u6536\u8D77",610,"view","view"),copyNodeText:Ee("copyNodeText","copy","\u590D\u5236","\u590D\u5236\u6587\u672C",620,"view","view"),readonly:Ee("readonly","lock","\u53EA\u8BFB","\u53EA\u8BFB",540,"view","view")},sidebarPanels:[{id:"nodeStyle",kind:"nodeStyle",label:"\u8282\u70B9\u6837\u5F0F",icon:"palette",runtimeCapability:"node-style",phase:1,options:[{id:"node-fill-blue",label:"\u6D77\u84DD",actionId:"painter",value:"#dbeafe",controlType:"swatch",preview:"#dbeafe",compatPath:"nodes.$active.data.fillColor"},{id:"node-fill-green",label:"\u8584\u8377",actionId:"painter",value:"#dcfce7",controlType:"swatch",preview:"#dcfce7",compatPath:"nodes.$active.data.fillColor"},{id:"node-fill-amber",label:"\u6696\u9EC4",actionId:"painter",value:"#fef3c7",controlType:"swatch",preview:"#fef3c7",compatPath:"nodes.$active.data.fillColor"},{id:"node-text-dark",label:"\u6DF1\u8272\u6587\u5B57",actionId:"painter",value:"#0f172a",controlType:"swatch",preview:"#0f172a",compatPath:"nodes.$active.data.color"},{id:"node-text-blue",label:"\u84DD\u8272\u6587\u5B57",actionId:"painter",value:"#1d4ed8",controlType:"swatch",preview:"#1d4ed8",compatPath:"nodes.$active.data.color"},{id:"node-font-14",label:"14 px",actionId:"painter",value:14,controlType:"segmented",compatPath:"nodes.$active.data.fontSize"},{id:"node-font-18",label:"18 px",actionId:"painter",value:18,controlType:"segmented",compatPath:"nodes.$active.data.fontSize"},{id:"node-font-bold",label:"\u52A0\u7C97",actionId:"painter",value:!0,controlType:"toggle",compatPath:"nodes.$active.data.fontWeight"},{id:"node-font-italic",label:"\u659C\u4F53",actionId:"painter",value:!0,controlType:"toggle",compatPath:"nodes.$active.data.fontStyle"},{id:"node-shape-round",label:"\u5706\u89D2\u77E9\u5F62",actionId:"painter",value:"roundedRectangle",controlType:"button",compatPath:"nodes.$active.data.shape"},{id:"node-shape-rect",label:"\u77E9\u5F62",actionId:"painter",value:"rectangle",controlType:"button",compatPath:"nodes.$active.data.shape"},{id:"node-border-blue",label:"\u84DD\u8272\u8FB9\u6846",actionId:"painter",value:"#60a5fa",controlType:"swatch",preview:"#60a5fa",compatPath:"nodes.$active.data.borderColor"},{id:"node-line-teal",label:"\u9752\u8272\u5206\u652F\u7EBF",actionId:"painter",value:"#14b8a6",controlType:"swatch",preview:"#14b8a6",compatPath:"nodes.$active.data.lineColor"},{id:"node-line-width-2",label:"\u8FB9\u7EBF 2",actionId:"painter",value:2,controlType:"segmented",compatPath:"nodes.$active.data.lineWidth"}]},{id:"baseStyle",kind:"baseStyle",label:"\u5BFC\u56FE\u6837\u5F0F",icon:"sliders",runtimeCapability:"base-style",phase:1,options:[{id:"base-curve-line",label:"\u66F2\u7EBF",actionId:"painter",value:"curve",controlType:"segmented",compatPath:"style.map.lineStyle"},{id:"base-direct-line",label:"\u76F4\u7EBF",actionId:"painter",value:"straight",controlType:"segmented",compatPath:"style.map.lineStyle"},{id:"base-rainbow-lines",label:"\u5F69\u8679\u7EBF\u6761",actionId:"painter",value:{enabled:!0},controlType:"toggle",compatPath:"style.map.rainbowLines"},{id:"base-line-width-2",label:"\u7EBF\u5BBD 2",actionId:"painter",value:2,controlType:"segmented",compatPath:"style.map.lineWidth"},{id:"base-line-width-4",label:"\u7EBF\u5BBD 4",actionId:"painter",value:4,controlType:"segmented",compatPath:"style.map.lineWidth"},{id:"base-background-light",label:"\u6D45\u8272\u80CC\u666F",actionId:"painter",value:"#f8fafc",controlType:"swatch",preview:"#f8fafc",compatPath:"style.map.backgroundColor"},{id:"base-node-spacing-36",label:"\u8282\u70B9\u95F4\u8DDD 36",actionId:"painter",value:36,controlType:"numberInput",compatPath:"style.map.nodeSpacing"},{id:"base-summary-bracket",label:"\u62EC\u53F7\u6982\u8981",actionId:"painter",value:"bracket",controlType:"select",compatPath:"style.map.summaryStyle"}]},{id:"theme",kind:"theme",label:"\u4E3B\u9898",icon:"swatch",runtimeCapability:"theme",phase:1,options:[{id:"theme-classic",label:"Classic",actionId:"setTheme",value:"classic",controlType:"swatch",preview:"#60a5fa",description:"\u9ED8\u8BA4\u4E3B\u9898"},{id:"theme-classic4",label:"KMind",actionId:"setTheme",value:"classic4",controlType:"swatch",preview:"#22c55e",description:"KMind-like"},{id:"theme-simple",label:"Simple",actionId:"setTheme",value:"simple",controlType:"swatch",preview:"#f59e0b",description:"\u8F7B\u91CF\u4E3B\u9898"},{id:"theme-dark",label:"Dark",actionId:"setTheme",value:"dark",controlType:"swatch",preview:"#334155",description:"\u6DF1\u8272\u4E3B\u9898"}]},{id:"structure",kind:"structure",label:"\u7ED3\u6784",icon:"layout",runtimeCapability:"layout",phase:1,options:[{id:"layout-logical",label:"\u903B\u8F91\u7ED3\u6784\u56FE",actionId:"setLayout",value:"logicalStructure",controlType:"layoutCard",preview:"logicalStructure"},{id:"layout-mind-map",label:"\u601D\u7EF4\u5BFC\u56FE",actionId:"setLayout",value:"mindMap",controlType:"layoutCard",preview:"mindMap"},{id:"layout-organization",label:"\u7EC4\u7EC7\u7ED3\u6784\u56FE",actionId:"setLayout",value:"organizationStructure",controlType:"layoutCard",preview:"organizationStructure"},{id:"layout-catalog",label:"\u76EE\u5F55\u7EC4\u7EC7\u56FE",actionId:"setLayout",value:"catalogOrganization",controlType:"layoutCard",preview:"catalogOrganization"},{id:"layout-timeline",label:"\u65F6\u95F4\u8F74",actionId:"setLayout",value:"timeline",controlType:"layoutCard",preview:"timeline"},{id:"layout-fishbone",label:"\u9C7C\u9AA8\u56FE",actionId:"setLayout",value:"fishbone",controlType:"layoutCard",preview:"fishbone"}]},{id:"outline",kind:"outline",label:"\u5927\u7EB2",icon:"list-tree",runtimeCapability:"outline",phase:1,options:[]},{id:"shortcutKey",kind:"shortcutKey",label:"\u5FEB\u6377\u952E",icon:"sparkles",runtimeCapability:"shortcut-key",phase:1,options:[{id:"shortcut-insert-child",label:"Tab",description:"\u63D2\u5165\u5B50\u8282\u70B9",actionId:null,value:null,controlType:"treeItem",readonly:!0},{id:"shortcut-insert-sibling",label:"Enter",description:"\u63D2\u5165\u540C\u7EA7\u8282\u70B9",actionId:null,value:null,controlType:"treeItem",readonly:!0},{id:"shortcut-delete",label:"Delete",description:"\u5220\u9664\u8282\u70B9",actionId:null,value:null,controlType:"treeItem",readonly:!0}]},{id:"settings",kind:"settings",label:"\u8BBE\u7F6E",icon:"hexagon",runtimeCapability:"settings",phase:1,options:[{id:"settings-readonly-hint",label:"\u53EA\u8BFB\u6A21\u5F0F",description:"\u5BFC\u822A\u680F\u5207\u6362",actionId:null,value:null,controlType:"toggle",readonly:!0},{id:"settings-mouse",label:"\u9F20\u6807\u884C\u4E3A",description:"\u5DE6\u952E\u9009\u4E2D\uFF0C\u53F3\u952E\u62D6\u62FD",actionId:null,value:"leftSelectRightDrag",controlType:"select",readonly:!0}]}],navigatorItems:[{id:"stats",label:"\u7EDF\u8BA1",actionId:null,readOnly:!0,displayMode:"text"},{id:"centerRoot",label:"\u56DE\u6839\u8282\u70B9",actionId:"centerRoot",readOnly:!0,displayMode:"button"},{id:"search",label:"\u641C\u7D22",actionId:"search",readOnly:!0,displayMode:"button"},{id:"zoomOut",label:"\u7F29\u5C0F",actionId:"zoomOut",readOnly:!0,displayMode:"button"},{id:"zoom",label:"\u7F29\u653E",actionId:null,readOnly:!0,displayMode:"input"},{id:"zoomIn",label:"\u653E\u5927",actionId:"zoomIn",readOnly:!0,displayMode:"button"},{id:"fullscreen",label:"\u5168\u5C4F",actionId:"fullscreenCanvas",readOnly:!0,displayMode:"button"},{id:"readonly",label:"\u53EA\u8BFB",actionId:"readonly",readOnly:!0,displayMode:"button"}],contextMenuItems:[{id:"insertChild",label:"\u63D2\u5165\u5B50\u8282\u70B9",actionId:"insertChild",requiresNode:!0,phase:1},{id:"insertSiblingAfter",label:"\u63D2\u5165\u540C\u7EA7\u8282\u70B9",actionId:"insertSiblingAfter",requiresNode:!0,phase:1},{id:"deleteNode",label:"\u5220\u9664\u8282\u70B9",actionId:"deleteNode",requiresNode:!0,phase:1},{id:"summary",label:"\u6982\u8981",actionId:"summary",requiresNode:!0,phase:1},{id:"associativeLine",label:"\u5173\u8054\u7EBF",actionId:"associativeLine",requiresNode:!0,phase:1},{id:"expandCollapse",label:"\u5C55\u5F00/\u6536\u8D77",actionId:"expandCollapse",requiresNode:!0,phase:1},{id:"copyNodeText",label:"\u590D\u5236\u6587\u672C",actionId:"copyNodeText",requiresNode:!0,phase:1},{id:"centerRoot",label:"\u56DE\u6839\u8282\u70B9",actionId:"centerRoot",requiresNode:!1,phase:1},{id:"fitView",label:"\u9002\u5E94\u753B\u5E03",actionId:"fitView",requiresNode:!1,phase:1},{id:"search",label:"\u641C\u7D22",actionId:"search",requiresNode:!1,phase:1},{id:"readonly",label:"\u53EA\u8BFB\u5207\u6362",actionId:"readonly",requiresNode:!1,phase:1},{id:"showMenu",label:"\u663E\u793A\u83DC\u5355",actionId:"showMenu",requiresNode:!1,phase:1}]},pF=i=>{try{let e=new URL(i).searchParams.get(pb);return e==="1"||e==="true"}catch{return!1}};var gF=()=>{let i=[...ho.toolbarGroups.flatMap(e=>e.actions),...ho.navigatorItems.flatMap(e=>e.actionId?[e.actionId]:[]),...ho.contextMenuItems.map(e=>e.actionId),...qp().map(e=>e.actionId)];return[...new Set(i)]},xF=i=>{let e=i?.trim();return e||null},yF=i=>typeof i!="number"||!Number.isFinite(i)?100:Math.max(10,Math.min(500,Math.round(i))),vF=new Set(["tag","hyperlink","note","image","icon","associativeLine","formula","import","export"]),gb=(i={})=>({chromeVisibility:i.chromeVisibility??"visible",toolbarOverflow:{availableWidth:i.toolbarOverflow?.availableWidth??null,visibleActionIds:i.toolbarOverflow?.visibleActionIds??[],overflowActionIds:i.toolbarOverflow?.overflowActionIds??[],moreOpen:i.toolbarOverflow?.moreOpen??!1},fullscreen:{mode:i.fullscreen?.mode??"none",isFullscreen:i.fullscreen?.isFullscreen??!1,target:i.fullscreen?.target??"mindmap-root",apiAvailable:i.fullscreen?.apiAvailable??!0},sidebar:{triggerVisible:i.sidebar?.triggerVisible??!0,panelOpen:i.sidebar?.panelOpen??!0,activePanelId:i.sidebar?.activePanelId??ho.sidebarPanels[0]?.id??null,drawerWidth:i.sidebar?.drawerWidth??300,collapsedByToggle:i.sidebar?.collapsedByToggle??!1},navigator:{searchOpen:i.navigator?.searchOpen??!1,minimapOpen:i.navigator?.minimapOpen??!1,readonly:i.navigator?.readonly??!1,zoomPercent:yF(i.navigator?.zoomPercent),mouseBehavior:i.navigator?.mouseBehavior??"leftSelectRightDrag"}}),bF=(i,e)=>e==="pointerLeave"?"hiddenByPointerLeave":e==="pointerEnter"?i:e==="restoreClick"?"visible":e==="hideToggle"?"hiddenByToggle":e==="showToggle"?"visible":e==="enterFullscreen"?i==="visible"?"visible":"hiddenByFullscreen":e==="exitFullscreen"&&i==="hiddenByFullscreen"?"visible":i,wF=i=>{let e=xF(i.activeNodeId),t=i.runtimeCapabilities?new Set(i.runtimeCapabilities):null,r={},n=gb({...i.shell,navigator:{...i.shell?.navigator,readonly:i.readonly}});return gF().forEach(s=>{let a=Nc(s);if(!a){r[s]=!0;return}if(a.requiresActiveNode&&!e){r[s]=!0;return}if(i.readonly&&!a.readonlyAllowed){r[s]=!0;return}if(t&&!t.has(a.target)){r[s]=!0;return}if(vF.has(s)){r[s]=!0;return}r[s]=!1}),{activeNodeId:e,readonly:i.readonly,disabledActions:r,shell:n}};var jp={};tt(jp,{resolveMindmapShortcutAction:()=>MF,shouldInterceptMindmapShortcut:()=>TF});var MF=i=>i.ctrlKey||i.metaKey||i.altKey||i.shiftKey?null:i.key==="Enter"?"insertSiblingAfter":i.key==="Tab"||i.key==="Insert"?"insertChild":i.key==="Delete"||i.key==="Backspace"?"deleteNode":i.key==="F2"?"editNode":null,TF=i=>i.debugChromeEnabled||!i.bridgeReady||i.readonly||i.isComposing||i.isEditableTarget?!1:i.targetInsideRoot?!0:i.keyboardShortcutArmed;function d0(){return{status:"idle"}}function xb(i,e){return{status:"armed",armedAt:e,reason:i}}function yb(){return d0()}function vb(i,e,t=1500){return i.status!=="armed"?{state:i,suppressed:!1,expired:!1}:e-i.armedAt>t?{state:d0(),suppressed:!1,expired:!0}:{state:d0(),suppressed:!0,expired:!1}}function bb(i){return{endpoint:`/api/mindmap/${encodeURIComponent(i.documentId)}/${encodeURIComponent(i.mindmapId)}`,init:{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:i.data,createOnly:!0})}}}function Vn(i){let e=i;return e.default&&typeof e.default=="object"?e.default:i}var{applyMindmapCommandsLocally:NF,isLocallyApplicableMindmapCommandSet:EF}=Vn(Dc),{createLeptosMindmapAdapter:SF,executeMindmapCommandApply:Gp,executeMindmapCommandApplyAndRefreshProjection:AF,requestMindmapAdapterProjection:kF}=Vn(Dp),{createViewPatchCommand:CF,createCompatPayloadPatch:_F,diffMindmapRuntimeDataToKernelCommands:LF}=Vn(Fp),{getMindmapActionMapping:wb,mapMindmapActionToCommand:IF}=Vn(Hp),{canonicalizeMindmapData:vi}=Vn(Pc),{deriveMindmapUiState:Vp,reduceMindmapChromeVisibility:Ec}=Vn($p),{resolveMindmapShortcutAction:zF,shouldInterceptMindmapShortcut:RF}=Vn(jp),{isMindmapDebugChromeEnabled:DF,mindmapDefaultUiSchema:Sc,mindmapToolbarFileActionOrder:OF,mindmapToolbarPrimaryActionOrder:Xp}=Vn(Up);function BF(i){return typeof i=="string"&&i.length>0?{"data-block-id":i,id:i}:{}}function PF(i){if(i.mnoteBlockType!=="mindmap")return{};let e={"data-mnote-block-type":"mindmap"};return typeof i.mindmapId=="string"&&(e["data-mnote-mindmap-id"]=i.mindmapId),typeof i.rootNodeId=="string"&&(e["data-mnote-root-node-id"]=i.rootNodeId),typeof i.projectionVersion=="number"&&(e["data-mnote-projection-version"]=String(i.projectionVersion)),e}function Rs(i){return String(i??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Wp(i){if(typeof i!="string")return null;let e=i.trim();return e.length>0?e:null}function FF(i){let e=window.location.pathname.match(/\/documents\/([^/?#]+)/);if(e?.[1])return decodeURIComponent(e[1]);let t=window.location.pathname.match(/\/mindmap\/([^/?#]+)\/([^/?#]+)/);if(t?.[1])return decodeURIComponent(t[1]);let r=Wp(i?.closest("[data-document-id]")?.getAttribute("data-document-id"));if(r)return r;let n=Wp(document.body?.getAttribute("data-document-id"));if(n)return n;let s=Wp(document.querySelector(".document-shell[data-document-id], [data-pane-document-id], [data-document-id]")?.getAttribute("data-document-id")??document.querySelector("[data-pane-document-id]")?.getAttribute("data-pane-document-id"));return s||null}function Mb(i,e){let r=vi(i.root).data?.uid;return typeof r=="string"&&r.trim().length>0?r.trim():e}function Yp(i){let t=vi(i.root).data?.text;return typeof t=="string"&&t.trim().length>0?t.trim():"\u672A\u547D\u540D\u8282\u70B9"}function Ds(i){if(typeof i=="string"&&i.trim().length>0)return i.trim();if(!i||typeof i!="object")return null;let e=i;if(typeof e.uid=="string"&&e.uid.trim().length>0)return e.uid.trim();let t=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};if(typeof t.uid=="string"&&t.uid.trim().length>0)return t.uid.trim();let r=e.getData;if(typeof r=="function")try{let n=r.call(e,"uid");if(typeof n=="string"&&n.trim().length>0)return n.trim()}catch{return null}return null}function Ac(i,e){let t=window,r=t.__MNOTE_LEPTOS_MINDMAP_BRIDGES__??{};t.__MNOTE_LEPTOS_MINDMAP_BRIDGES__=r,e?r[i]=e:delete r[i]}function Lt(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Os(i){return JSON.parse(JSON.stringify(i))}function qF(i){if(!(i instanceof HTMLElement))return!1;let e=i.tagName;return e==="INPUT"||e==="TEXTAREA"||e==="SELECT"?!0:i.isContentEditable?!i.matches(".ProseMirror"):!1}function HF(i){if(!Lt(i))return null;let e=i.view;return Lt(e)&&Lt(e.state)?e:null}function UF(i){if(!(i!=="insertChild"&&i!=="insertSiblingAfter"))return{uid:`node_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,text:"\u65B0\u8282\u70B9"}}function $F(i,e){let t=e?.trim();if(!t)return!1;let r=vi(i),n=!1,s=a=>{if(n)return;let o=vi(a);if(o.data?.uid===t){n=!0;return}(Array.isArray(o.children)?o.children:[]).forEach(s)};return s(r),n}function Tb(i){let e=vi(i),t=Array.isArray(e.children)?[...e.children]:[];for(;t.length>0;){let r=vi(t.shift()),n=r.data?.uid;if(typeof n=="string"&&n.trim().length>0)return n.trim();Array.isArray(r.children)&&t.push(...r.children)}return null}function jF(i,e){let t=e?.trim();if(!t)return null;let r=null,n=s=>{if(r)return;let a=vi(s);if(a.data?.uid===t){r=a;return}(Array.isArray(a.children)?a.children:[]).forEach(n)};return n(i),r}function GF(i,e){let t=jF(i,e),r=t&&Lt(t.data)?t.data.text:null;return typeof r=="string"?r:""}function VF(i,e=10){let t=vi(i),r=[],n=(s,a)=>{if(r.length>=e)return;let o=vi(s),l=typeof o.data?.text=="string"&&o.data.text.trim().length>0?o.data.text.trim():"\u672A\u547D\u540D\u8282\u70B9";r.push(`${" ".repeat(Math.max(a-1,0))}${l}`),(Array.isArray(o.children)?o.children:[]).forEach(d=>n(d,a+1))};return n(t,1),r}function Nb(i,e){let t=i?.trim();return t?t.includes("$active")?e?t.replaceAll("$active",e):null:t:null}var Eb={undo:"\u64A4\u9500",redo:"\u91CD\u505A",editNode:"\u7F16\u8F91\u8282\u70B9",insertSiblingAfter:"\u540C\u7EA7\u8282\u70B9",insertChild:"\u5B50\u8282\u70B9",deleteNode:"\u5220\u9664",tag:"\u6807\u7B7E",hyperlink:"\u94FE\u63A5",note:"\u5907\u6CE8",image:"\u56FE\u7247",icon:"\u56FE\u6807",summary:"\u6982\u8981",associativeLine:"\u5173\u8054\u7EBF",formula:"\u516C\u5F0F",painter:"\u683C\u5F0F\u5237",import:"\u5BFC\u5165",export:"\u5BFC\u51FA",setTheme:"\u4E3B\u9898",setLayout:"\u7ED3\u6784",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fitView:"\u9002\u5E94",centerRoot:"\u56DE\u6839",fullscreenCanvas:"\u5168\u5C4F",fullscreenPage:"\u5168\u9875",exitFullscreen:"\u9000\u51FA",search:"\u641C\u7D22",showMenu:"\u663E\u793A\u83DC\u5355",expandCollapse:"\u5C55\u5F00/\u6536\u8D77",copyNodeText:"\u590D\u5236\u6587\u672C",readonly:"\u53EA\u8BFB"},WF={undo:"\u21B6",redo:"\u21B7",editNode:"T",insertSiblingAfter:"\u21B5",insertChild:"+",deleteNode:"\xD7",tag:"#",hyperlink:"\u2301",note:"N",image:"\u25A1",icon:"\u2606",summary:"{",associativeLine:"\u2307",formula:"fx",painter:"\u25D0",import:"\u21E7",export:"\u21E9",centerRoot:"\u25CE",zoomOut:"-",zoomIn:"+",search:"\u2315",fullscreenCanvas:"\u26F6",fullscreenPage:"\u25A3",exitFullscreen:"\u2921",showMenu:"\u2630",expandCollapse:"\u2922",copyNodeText:"C",readonly:"\u9501"},YF={undo:"\u21B6",redo:"\u21B7",type:"T",sibling:"\u21B5",trash:"\xD7",child:"+",tag:"#",link:"\u2301",note:"N",image:"\u25A1",smile:"\u2606",summary:"{",route:"\u2307",formula:"fx",paintbrush:"\u25D0",import:"\u21E7",export:"\u21E9",target:"\u25CE",fullscreen:"\u26F6","fullscreen-page":"\u25A3","exit-fullscreen":"\u2921",menu:"\u2630","zoom-out":"-","zoom-in":"+",search:"\u2315",lock:"\u9501"},XF=i=>{let e=[...Xp];if(i===null||!Number.isFinite(i))return{availableWidth:null,visibleActionIds:e,overflowActionIds:[]};let t=118,r=96,n=50,s=Math.max(0,i-t-r),a=Math.max(2,Math.min(e.length,Math.floor(s/n)));if(a>=e.length)return{availableWidth:i,visibleActionIds:e,overflowActionIds:[]};let o=Math.max(1,a-1);return{availableWidth:i,visibleActionIds:e.slice(0,o),overflowActionIds:e.slice(o)}};function KF(i){return({node:e,getPos:t})=>{let r=e,n=0,s=null,a=null,o=null,l=null,h=null,d=null,c=d0(),f=null,m=!1,g=Sc.sidebarPanels[0]?.id??"nodeStyle",x=!0,y=!0,b=!1,S=300,A=null,C=null,I=!1,O=!1,q=null,P=!1,W=null,ne=null,re=null,oe=null,ke=null,Q=null,Y="visible",le=!1,ce=!1,at="canvas",It=null,bt="canvas",qi=0,zt=0,di=null,nn=null,Hi=null,co=0,Mr=0,tr=!1,sn=null,bi=null,Ui=!1,wi=DF(window.location.href),Je=document.createElement("div");Je.className="mnote-mindmap-placeholder",Je.dataset.mnoteBlockType="mindmap",Je.dataset.testid="mnote-mindmap-placeholder",Je.setAttribute("contenteditable","false");let ve=document.createElement("div");ve.className="mnote-mindmap-editor-root",ve.dataset.testid="mnote-mindmap-editor-root",ve.dataset.mnoteSceneQuery="mindmap.simple_mind_map_scene.get";let an=()=>FF(ve),R=document.createElement("div");R.dataset.testid="leptos-mindmap-island",R.dataset.runtime="simple-mind-map",R.dataset.stage="loading",R.dataset.debugChrome=wi?"true":"false",R.dataset.suppressRuntimeDiffState="idle",R.className="mnote-leptos-mindmap-shell";let Wn=()=>{R.dataset.suppressRuntimeDiffState=c.status,R.dataset.suppressRuntimeDiffReason=c.status==="armed"?c.reason:"",R.dataset.suppressRuntimeDiffSince=c.status==="armed"?String(c.armedAt):""},Bs=M=>{c=xb(M,Date.now()),Wn()},$i=()=>{c=yb(),Wn()},Yn=document.createElement("div");Yn.className="mnote-mindmap-workspace",Yn.dataset.debugChrome=wi?"true":"false",Yn.dataset.layout=wi?"debug-grid":"floating-overlay";let c0=document.createElement("div");c0.className="mnote-mindmap-canvas-layer",c0.dataset.testid="mindmap-canvas-layer";let Xn=document.createElement("div");Xn.className="mnote-mindmap-overlay-layer",Xn.dataset.testid="mindmap-overlay-layer";let mt=document.createElement("div");mt.className="mnote-leptos-mindmap-runtime",mt.dataset.testid="simple-mind-map-runtime",mt.dataset.runtime="simple-mind-map",mt.dataset.runtimeEngine="pending";let ir=document.createElement("div");ir.className="mnote-mindmap-rust-shell-mount",ir.dataset.testid="mindmap-rust-shell-mount",ir.dataset.uiShellSource="leptos-rust-shell";let Kn=document.createElement("div");Kn.className="mnote-mindmap-command-toolbar",Kn.dataset.testid="mindmap-command-toolbar";let Zn=document.createElement("aside");Zn.className="mnote-mindmap-side-panel",Zn.dataset.testid="mindmap-sidebar";let Qn=document.createElement("div");Qn.className="mnote-mindmap-bottom-bar",Qn.dataset.testid="mindmap-bottom-bar";let et=()=>{let M=typeof r.attrs.mindmapId=="string"&&r.attrs.mindmapId.length>0?r.attrs.mindmapId:"mindmap",L=typeof r.attrs.rootNodeId=="string"&&r.attrs.rootNodeId.length>0?r.attrs.rootNodeId:"root";return{mindmapId:M,rootNodeId:L}},Kp=M=>JSON.stringify({mnoteBlockType:M.attrs.mnoteBlockType??null,mindmapId:M.attrs.mindmapId??null,rootNodeId:M.attrs.rootNodeId??null,projectionVersion:M.attrs.projectionVersion??null}),u0=()=>{let{mindmapId:M,rootNodeId:L}=et();Je.dataset.mnoteMindmapId=M,Je.dataset.mnoteRootNodeId=L,Je.dataset.mnoteProjectionVersion=String(r.attrs.projectionVersion??1),ve.dataset.mnoteMindmapId=M,ve.dataset.mnoteRootNodeId=L,ve.dataset.mnoteProjectionVersion=String(r.attrs.projectionVersion??1),ve.dataset.mnoteSceneQuery="mindmap.simple_mind_map_scene.get"},f0=()=>{if(!(nn===null||!Hi)){try{Hi.unmount(nn)}catch{}nn=null,Hi=null,ir.replaceChildren()}},Zp=()=>{let M=s?.getSnapshot(),L=Lt(M)&&"root"in M?M.root:M??a?.root,D=0,F=0,K=te=>{if(!Lt(te))return;D+=1;let we=Lt(te.data)&&typeof te.data.text=="string"?te.data.text:"";F+=we.trim().length,(Array.isArray(te.children)?te.children:[]).forEach(K)};K(L);let ee=a?.view,ue=Lt(M)&&Lt(M.view)&&Lt(M.view.state)&&typeof M.view.state.scale=="number"?M.view.state.scale:Lt(ee)&&Lt(ee.state)&&typeof ee.state.scale=="number"?ee.state.scale:1;return{nodeCount:D,wordCount:F,zoomPercent:Math.round(ue*100)}},Sb=()=>a?{...vi(a.root),layout:a.layout,theme:a.theme,themeConfig:a.themeConfig,view:a.view,config:a.config,compatPayload:a.compatPayload}:null,Ab=(M,L)=>{a&&(a.root=Os(vi(M)),"layout"in M&&(a.layout=M.layout),"theme"in M&&(a.theme=M.theme),"themeConfig"in M&&(a.themeConfig=M.themeConfig),"view"in M&&(a.view=M.view),"config"in M&&(a.config=M.config),"compatPayload"in M&&(a.compatPayload=M.compatPayload),typeof L=="number"&&Number.isFinite(L)&&(a.kernelRevision=L),o=Os(a.root))},kb=()=>{let M=s?.getSnapshot(),L=Lt(M)&&"root"in M?M.root:M??a?.root;return VF(L)},m0=()=>{P&&(P=!1,Le())},Qp=(M,L)=>{let D=ve.getBoundingClientRect();qi=Math.round(M-D.left),zt=Math.round(L-D.top)},p0=()=>{!ce&&!R.dataset.contextMenuKind||(ce=!1,at="canvas",It=null,bt="canvas",delete R.dataset.contextMenuKind,delete R.dataset.contextMenuTargetNodeId,delete R.dataset.contextMenuTargetNodeKind,b0())},g0=M=>Ds(M),Cb=()=>{let M=s?.instance.renderer;return M?.activeNodeList?.[0]??M?.lastActiveNodeList?.[0]??M?.root??M?.renderTree?._node??null},x0=(M,L,D)=>{let F=Ds(L);return F&&$F(M.root,F)?F:Tb(M.root)??Mb(M,D)},kc=M=>{let L=Ds(M);return L||(g0(h)??g0(Cb())??null)},_b=M=>{if(!M||typeof M!="object")return"node";let L=M;return L.isRoot===!0?"root":L.isGeneralization===!0?"generalization":"node"},Lb=M=>{let L=s?.instance.renderer;if(L)try{L.clearActiveNodeList?.(),L.addNodeToActiveList?.(M,!0),L.emitNodeActiveEvent?.(M,[M])}catch{}},uo=M=>{let L=Ds(M),D=s?.instance.renderer,F=L?D?.findNodeByUid?.(L)??null:D?.activeNodeList?.[0]??D?.lastActiveNodeList?.[0]??D?.root??D?.renderTree?._node;if(F)try{D?.clearActiveNodeList?.(),D?.addNodeToActiveList?.(F,!0),D&&(D.lastActiveNodeList=[F]),D?.emitNodeActiveEvent?.(F,[F]),s?.instance.execCommand?.("SET_NODE_ACTIVE",F,!0),h=F;let ee=L??g0(F)??l??et().rootNodeId;return l=ee,d=ee,R.dataset.lastRuntimeSelectionSync=ee,!0}catch{}let K=s?.instance.execCommand;if(typeof K!="function"||!L)return!1;try{return K.call(s?.instance,"GO_TARGET_NODE",L),l=L,d=L,R.dataset.lastRuntimeSelectionSync=L,!0}catch{return!1}},Jp=M=>{let L=Ds(M),D=s?.instance.renderer;return{wantedNodeId:L,runtimeNode:L?D?.findNodeByUid?.(L)??null:D?.activeNodeList?.[0]??D?.lastActiveNodeList?.[0]??D?.root??D?.renderTree?._node}},Ib=async(M,L=3)=>{let D=Jp(M);for(let F=1;!D.runtimeNode&&Fwindow.requestAnimationFrame(()=>K())),D=Jp(M);return D},zb=async(M,L,D)=>{let F=M==="DELETE_NODE"?"REMOVE_NODE":M,K=s?.instance;if(!K||typeof K.execCommand!="function")return{ok:!1,command:F,error:"runtime_unavailable",message:"runtime_instance_missing"};let{wantedNodeId:ee,runtimeNode:ue}=await Ib(L);if(!ue)return{ok:!1,command:F,error:"command_failed",message:`runtime_node_missing:${ee??"unknown"}`};try{if(K.renderer?.clearActiveNodeList?.(),K.renderer?.addNodeToActiveList?.(ue,!0),K.renderer&&(K.renderer.lastActiveNodeList=[ue]),K.renderer?.emitNodeActiveEvent?.(ue,[ue]),K.execCommand("SET_NODE_ACTIVE",ue,!0),F==="REMOVE_NODE")return{ok:!0,command:F,result:K.execCommand("REMOVE_NODE",[ue])};if(F==="INSERT_CHILD_NODE"||F==="INSERT_NODE")return{ok:!0,command:F,result:K.execCommand(F,!1,[ue],D?{uid:D.uid,text:D.text}:null)}}catch{return{ok:!1,command:F,error:"command_failed",message:"runtime_command_throw"}}return s?.execCommand(F)??{ok:!1,command:F,error:"unsupported_command",message:"runtime_command_unsupported"}},Rb=(M,L,D)=>{Qp(M,L),at="node",It=g0(D),bt=_b(D),ce=!0,R.dataset.contextMenuKind="node",R.dataset.contextMenuTargetNodeId=It??"",R.dataset.contextMenuTargetNodeKind=bt,Lb(D),It&&(l=It,d=It),b0()},Db=(M,L)=>{Qp(M,L),at="canvas",It=null,bt="canvas",ce=!0,R.dataset.contextMenuKind="canvas",R.dataset.contextMenuTargetNodeId="",R.dataset.contextMenuTargetNodeKind="canvas",b0()},y0=M=>{Y!==M&&(Y=M,R.dataset.chromeVisibility=M,Le())},e3=()=>{le=!0,R.dataset.keyboardShortcutArmed="true"},Ob=()=>{le=!1,R.dataset.keyboardShortcutArmed="false"},v0=()=>document.fullscreenElement===ve||ve.contains(document.fullscreenElement),Bb=()=>{let M=s?.instance;try{typeof M?.resize=="function"?M.resize():typeof M?.view?.resize=="function"&&M.view.resize(),M?.renderer?.setRootNodeCenter?.()}catch{R.dataset.fullscreenResizeStatus="failed";return}R.dataset.fullscreenResizeStatus="success"},Cc=()=>{let M=v0();R.dataset.fullscreenActive=M?"true":"false",ve.dataset.fullscreenActive=M?"true":"false",window.setTimeout(()=>{Bb(),Le()},80)},_c=()=>{s?.instance.setMode?.(m?"readonly":"edit"),R.dataset.readonly=m?"true":"false"},t3=M=>{R.dataset.searchStatus="ready",R.dataset.lastSearchQuery=M,O=!0,Le()},Pb=M=>{let L=typeof M=="number"?M:Number(String(M??"").replace("%","").trim());if(!Number.isFinite(L)){R.dataset.zoomInputStatus="invalid",Le();return}let D=Math.max(10,Math.min(500,Math.round(L))),F=s?.instance.view;if(!F?.setScale){R.dataset.zoomInputStatus="unsupported",Le();return}F.setScale(D/100,ve.clientWidth/2,ve.clientHeight/2),R.dataset.zoomInputStatus="success",qs(s?.getSnapshot()),Le()},i3=async M=>{if(M==="exitFullscreen"){document.fullscreenElement&&await document.exitFullscreen(),Cc();return}if(!(M!=="fullscreenCanvas"&&M!=="fullscreenPage")){if(typeof ve.requestFullscreen!="function"){R.dataset.commandStatus="fullscreen-unavailable",R.dataset.disabledReason="fullscreen-unavailable";return}await ve.requestFullscreen(),Cc()}},Lc=(M,L)=>{let D=Sc.toolbarActionMeta[M],F=D?.shortLabel??Eb[M]??M,K=D?.longLabel??Eb[M]??M,ee=D?.iconKey??M;return{id:M,label:F,longLabel:K,icon:YF[ee]??WF[M]??F.slice(0,1),iconKey:ee,priority:D?.priority??999,overflowGroup:D?.overflowGroup??"view",cluster:D?.cluster??"main",disabled:L.disabledActions[M]??!0}},Fb=()=>{let M=window.__MNOTE_MINDMAP_RUST_SHELL__;if(!M){f0(),R.dataset.uiShell="typescript-nodeview-dom",ir.dataset.uiShellSource="missing-rust-shell",ir.innerHTML='
    Leptos/Rust mindmap shell \u672A\u52A0\u8F7D
    ';return}let L=XF(q??ve.getBoundingClientRect().width),D=Vp({activeNodeId:l,readonly:m,runtimeCapabilities:["runtimeCommand","kernelCommand","compatPatch","localView"],shell:{chromeVisibility:Y,toolbarOverflow:{availableWidth:L.availableWidth,visibleActionIds:L.visibleActionIds,overflowActionIds:L.overflowActionIds,moreOpen:P&&L.overflowActionIds.length>0},fullscreen:{mode:v0()?"canvas":"none",isFullscreen:v0(),target:"mindmap-root",apiAvailable:typeof ve.requestFullscreen=="function"},sidebar:{activePanelId:g,panelOpen:x,triggerVisible:y,drawerWidth:S,collapsedByToggle:b},navigator:{searchOpen:O,minimapOpen:I,readonly:m,zoomPercent:Zp().zoomPercent}}}),{mindmapId:F}=et(),K=Zp(),ee=new Set(D.shell.toolbarOverflow.visibleActionIds),ue=new Set(D.shell.toolbarOverflow.overflowActionIds),te={mindmapId:F,toolbarGroups:[{id:"main",label:"\u4E3B\u5DE5\u5177",actions:Xp.filter(we=>ee.size===0||ee.has(we)).map(we=>Lc(we,D))},{id:"overflow",label:"\u66F4\u591A",actions:Xp.filter(we=>ue.has(we)).map(we=>Lc(we,D))},{id:"file",label:"\u6587\u4EF6",actions:OF.map(we=>Lc(we,D))}],sidebarPanels:Sc.sidebarPanels.map(we=>({id:we.id,kind:we.kind,label:we.label,icon:we.icon,active:we.id===g,bodyTitle:we.label,bodyCaption:we.runtimeCapability,options:we.options.map(Ge=>({id:Ge.id,label:Ge.label,actionId:Ge.actionId,value:Ge.value,controlType:Ge.controlType,preview:Ge.preview,description:Ge.description,readonly:Ge.readonly??!1,compatPath:Ge.compatPath})),bodyItems:we.id==="outline"?kb():[]})),navigator:{wordCount:K.wordCount,nodeCount:K.nodeCount,zoomPercent:K.zoomPercent,readonly:m,minimapOpen:I},shell:D.shell};f0(),ir.dataset.uiShellSource="leptos-rust-shell",Hi=M,nn=M.mount(ir,te),R.dataset.uiShell="leptos-rust-shell"},Le=()=>{if(u0(),!wi){Fb(),b0();return}f0(),R.dataset.uiShell="debug-fallback",Kn.dataset.testid="mindmap-command-toolbar",Kn.className="mnote-mindmap-command-toolbar",delete Kn.dataset.schemaSource,Zn.dataset.testid="mindmap-sidebar",Zn.className="mnote-mindmap-side-panel",delete Zn.dataset.schemaSource,Qn.dataset.testid="mindmap-bottom-bar",Qn.className="mnote-mindmap-bottom-bar",delete Qn.dataset.schemaSource;let M=a?Yp(a):"",L=f??M,F=s!==null?"":" disabled",K=["\u8282\u70B9\u6837\u5F0F","\u5BFC\u56FE\u6837\u5F0F","\u4E3B\u9898","\u7ED3\u6784","\u5927\u7EB2"].map((ee,ue)=>``).join("");Kn.innerHTML=`
    `,Zn.innerHTML=`${K}
    \u7ECF\u5178\u4E3B\u9898 \xB7 \u903B\u8F91\u7ED3\u6784
    `,Qn.innerHTML=`runtime \u8282\u70B9100%`},b0=()=>{let M=Xn.querySelector('[data-testid="mindmap-schema-context-menu"]');if(!ce){M?.remove();return}M||(M=document.createElement("div"),M.className="mnote-mindmap-context-menu",M.dataset.testid="mindmap-schema-context-menu",M.dataset.uiSource="typescript-nodeview-bridge",Xn.append(M)),M.dataset.contextMenuKind=at,M.dataset.contextMenuTargetNodeKind=bt;let D=Vp({activeNodeId:at==="node"?It??l:l,readonly:m,runtimeCapabilities:["runtimeCommand","kernelCommand","compatPatch","localView"]}),F=Sc.contextMenuItems.filter(te=>te.requiresNode===(at==="node")),K=te=>D.disabledActions[te]?!0:at!=="node"?!1:bt==="root"&&(te==="insertSiblingAfter"||te==="deleteNode")||bt==="generalization"&&(te==="insertChild"||te==="insertSiblingAfter"||te==="deleteNode"||te==="summary"||te==="associativeLine"||te==="expandCollapse");M.innerHTML=F.map(te=>{let we=K(te.actionId);return``}).join("");let ee=Math.min(Math.max(8,qi),Math.max(8,ve.clientWidth-M.offsetWidth-8)),ue=Math.min(Math.max(8,zt),Math.max(8,ve.clientHeight-M.offsetHeight-8));M.style.left=`${ee}px`,M.style.top=`${ue}px`},r3=()=>{u0(),R.dataset.stage="loading",mt.dataset.runtimeEngine="loading",mt.replaceChildren(),Le()},n3=M=>M==="mnote-web-tree-live"||M==="externalTreeLive"||M==="nodeViewUpdate",qb=M=>M==="mnote-web-tree-live"||M==="externalTreeLive",Hb=()=>R.dataset.stage==="ready"&&mt.dataset.runtimeReady==="true"&&a!==null,Ub=()=>{if(s?.instance.renderer?.textEdit?.isShowTextEdit?.())return!0;let L=document.activeElement;if(L instanceof HTMLElement&&L.closest(".smm-node-edit-wrap"))return!0;let D=document.querySelector('.smm-node-edit-wrap[contenteditable="true"]');return D instanceof HTMLElement&&D.style.display!=="none"&&D.getClientRects().length>0},s3=M=>{let L=s?.instance.renderer?.textEdit;if(!L?.isShowTextEdit?.())return!1;let D=Ds(L.getCurrentEditNode?.())??l??d,F=L.getEditText?.();if(R.dataset.lastRuntimeTextEditFlushReason=M,D&&typeof F=="string"&&F.length>0){R.dataset.lastRuntimeTextEditFlushNodeId=D,R.dataset.lastRuntimeTextEditFlushText=F;let{mindmapId:K}=et(),ee=an();ee&&a&&Gp({documentId:ee,mindmapId:K,commands:[{type:"updateText",mindmapId:K,nodeId:D,text:F}],projectionRevision:a.kernelRevision}).catch(te=>{R.dataset.lastRuntimeTextEditFlushError=te instanceof Error?te.message:String(te)})}return L.hideEditTextBox?.(),!0},a3=(M,L="text_edit")=>{R.dataset.runtimeProjectionDeferred=L,R.dataset.lastRuntimeProjectionDeferReason=M,R.dataset.runtimeProjectionDeferredAt=String(Date.now())},o3=()=>{R.dataset.runtimeProjectionDeferred="",R.dataset.lastRuntimeProjectionDeferReason="",R.dataset.runtimeProjectionDeferredAt=""},Ps=(M,L="")=>{R.dataset.backgroundProjectionRefresh=M,R.dataset.backgroundProjectionRefreshMessage=L,Le()},on=(M,L)=>{let{mindmapId:D}=et();u0(),R.dataset.stage=M,mt.dataset.runtimeEngine="error",mt.innerHTML=`
    ${Rs(M)}${Rs(D)}${Rs(L)}
    `,Le()},Fs=async(M,L)=>{if(R.dataset.commandCount=String(M.length),R.dataset.commandHasProjection=a?"true":"false",R.dataset.commandFailedAction="",R.dataset.commandFailedMessage="",M.length===0||!a){R.dataset.commandStatus="skipped";return}let{mindmapId:D}=et(),F=an();if(!F){on("command_failed",`mindmapId=${D}; documentId_missing`);return}R.dataset.commandStatus="pending";try{let K=await AF({documentId:F,mindmapId:D,commands:M,projectionRevision:a.kernelRevision});if(Ui)return;let ee=L?x0(K,L,et().rootNodeId):void 0;await d3(K,"commandRefresh",ee),f=null,R.dataset.commandStatus="success"}catch(K){let ee=K instanceof Error?K.message:String(K);R.dataset.commandStatus="failed",R.dataset.commandFailedAction=R.dataset.lastSchemaAction??"",R.dataset.commandFailedMessage=ee,on("command_failed",`mindmapId=${D}; ${ee}`)}},l3=async(M,L)=>{if(R.dataset.commandCount=String(M.length),R.dataset.commandHasProjection=a?"true":"false",R.dataset.commandFailedAction="",R.dataset.commandFailedMessage="",R.dataset.commandApplyMode="",R.dataset.commandLocalApplyErrors="",M.length===0||!a){R.dataset.commandStatus="skipped",R.dataset.commandApplyMode="skipped",$i();return}if(!EF(M)){R.dataset.commandApplyMode="refresh:unsupported",$i(),await Fs(M,L);return}let D=Sb();if(!D){R.dataset.commandApplyMode="refresh:no_blob",$i(),await Fs(M,L);return}let F=NF(D,M);if(F.errors.length>0){R.dataset.commandApplyMode="refresh:local_errors",R.dataset.commandLocalApplyErrors=F.errors.join("|"),$i(),await Fs(M,L);return}let{mindmapId:K}=et(),ee=an();if(!ee){on("command_failed",`mindmapId=${K}; documentId_missing`);return}R.dataset.commandStatus="pending",R.dataset.commandApplyMode="local";try{let ue=await Gp({documentId:ee,mindmapId:K,commands:M,projectionRevision:a.kernelRevision});if(Ui)return;if(Ab(F.data,ue.kernelRevision),L){let te=x0(a,L,et().rootNodeId);l=te,d=te,window.setTimeout(()=>{uo(te)},0)}f=null,R.dataset.commandStatus="success",Le()}catch(ue){let te=ue instanceof Error?ue.message:String(ue);R.dataset.commandStatus="failed",R.dataset.commandFailedAction=R.dataset.lastSchemaAction??"",R.dataset.commandFailedMessage=te,$i(),on("command_failed",`mindmapId=${K}; ${te}`)}},$b=async M=>{if(!a)return;let{mindmapId:L}=et(),D=an();if(!D){on("command_failed",`mindmapId=${L}; documentId_missing`);return}R.dataset.viewCommandStatus="pending";try{if(await Gp({documentId:D,mindmapId:L,commands:[CF(L,M)],projectionRevision:a.kernelRevision}),Ui)return;a.view=M,R.dataset.viewCommandStatus="success"}catch(F){on("command_failed",`mindmapId=${L}; ${F instanceof Error?F.message:String(F)}`)}},qs=M=>{let L=HF(M);L&&(A=L,R.dataset.lastViewPatch=JSON.stringify(L),C!==null&&window.clearTimeout(C),C=window.setTimeout(()=>{C=null;let D=A;A=null,D&&$b(D)},350))},jb=M=>{if(s){if(M==="editNode"){let L=s.instance.renderer,D=s.instance.keyCommand,F=L?.textEdit,K=h??L?.activeNodeList?.[0]??null;if(K&&typeof F?.show=="function")F.show({node:K,isFromKeyDown:!1}),R.dataset.editNodeStatus="opened";else if(typeof D?.getShortcutFn=="function"){let ee=D.getShortcutFn("F2")[0];typeof ee=="function"?(ee(),R.dataset.editNodeStatus="opened"):R.dataset.editNodeStatus="unsupported"}else R.dataset.editNodeStatus="unsupported";return}if(M==="centerRoot"&&s.instance.renderer?.setRootNodeCenter?.(),M==="zoomOut"&&s.instance.view?.narrow?.(),M==="zoomIn"&&s.instance.view?.enlarge?.(),M==="fitView"&&s.instance.view?.reset?.(),M==="fullscreenCanvas"||M==="fullscreenPage"||M==="exitFullscreen"){i3(M);return}if(M==="search"){O?(O=!1,R.dataset.lastSearchQuery="",R.dataset.searchStatus="closed",Le()):t3("");return}if(M==="showMenu"){y0("visible"),p0();return}if(M==="expandCollapse"){s.instance.renderer?.toggleActiveExpand?.(),R.dataset.contextMenuActionStatus="success",R.dataset.lastContextMenuAction=M,Le();return}if(M==="copyNodeText"){let L=It??l,D=a?GF(a.root,L):"";R.dataset.copiedNodeText=D,R.dataset.contextMenuActionStatus="success",R.dataset.lastContextMenuAction=M;return}M==="readonly"&&(m=!m,_c()),qs(s.getSnapshot()),Le()}},Gb=(M,L,D)=>{if(!s)return;let F=Nb(M,D);if(!F)return;let K=Lt(s.instance.getThemeConfig?.())?s.instance.getThemeConfig?.():{};if(D&&F.startsWith(`nodes.${D}.data.`)&&h){let ee=F.split(".data.")[1]??"";if(ee==="shape"){h.setShape?.(L);return}if(ee){let ue=ee==="fontWeight"&&L===!0?"bold":ee==="fontStyle"&&L===!0?"italic":L;h.setData?.({[ee]:ue});return}}if(F.startsWith("style.map.")){let ee=F.slice(10);if(!ee)return;s.instance.setThemeConfig?.({...K,[ee]:L},!1)}},Vb=(M,L,D)=>{if(!(!s||L.source!=="sidebar")){if(M==="setLayout"){s.instance.setLayout?.(L.value);return}if(M==="setTheme"){s.instance.setTheme?.(L.value);return}M==="painter"&&typeof L.compatPath=="string"&&Gb(L.compatPath,L.value,D)}},w0=async(M,L={})=>{let D=wb(M);if(!D||Vp({activeNodeId:at==="node"?It??l:l,readonly:m,runtimeCapabilities:["runtimeCommand","kernelCommand","compatPatch","localView"]}).disabledActions[M])return;if(R.dataset.lastSchemaAction=M,D.target==="localView"){jb(M);return}let K=UF(M),ee=at==="node"?It??d??l:d??l;if(D.requiresActiveNode){let Ge=kc(ee);Ge&&(ee=Ge,l=Ge,d=Ge)}R.dataset.lastSchemaActiveNodeId=ee??"";let ue=et().mindmapId;Vb(M,L,ee);let te=IF({actionId:M,mindmapId:ue,activeNodeId:ee,node:K,value:L.value??(M==="editNode"?Yp(a):!0),source:L.source,runtimeRevision:a?.kernelRevision??null,kernelRevision:a?.kernelRevision??null}),we=Nb(L.compatPath,ee);if(we&&(te={command:_F({mindmapId:ue,path:we,value:L.value??!0,source:L.source??"sidebar",actionId:M,runtimeRevision:a?.kernelRevision??null,kernelRevision:a?.kernelRevision??null})}),R.dataset.lastSchemaCommand=te?.command?JSON.stringify(te.command):"",R.dataset.lastSchemaRuntimeCommand=te?.runtimeCommand??"",!!te){if(D.target==="runtimeCommand"&&te.runtimeCommand){if(te.command){Bs(te.runtimeCommand),D.requiresActiveNode&&uo(ee);let Ge=await zb(te.runtimeCommand,ee,K),u3=K?.uid??(M==="deleteNode"?et().rootNodeId:ee);if(Ge?.ok){K?.uid&&(te.runtimeCommand==="INSERT_CHILD_NODE"||te.runtimeCommand==="INSERT_NODE")&&window.setTimeout(()=>{uo(K.uid)},0),l3([te.command],u3);return}R.dataset.commandApplyMode="refresh:runtime_failed",R.dataset.commandRuntimeError=Ge?.error??"unknown",R.dataset.commandRuntimeMessage=Ge&&"message"in Ge?Ge.message??"":"",$i(),Fs([te.command],u3);return}s?.execCommand(te.runtimeCommand);return}te.command&&Fs([te.command])}},Wb=M=>{let L=M.target instanceof Node&&ve.contains(M.target);return RF({debugChromeEnabled:wi,bridgeReady:!!s,readonly:m,isComposing:M.isComposing,isEditableTarget:qF(M.target),targetInsideRoot:L,keyboardShortcutArmed:le})},Yb=M=>{if(!Wb(M))return;let L=zF(M);if(!L)return;M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),R.dataset.lastShortcutKey=M.key,R.dataset.lastShortcutAction=L;let D=a?Mb(a,et().rootNodeId):et().rootNodeId;if(wb(L)?.requiresActiveNode){let K=kc(d??l);if(K===D&&(L==="insertSiblingAfter"||L==="deleteNode")){let ee=kc(null);ee&&ee!==D?K=ee:a&&(K=Tb(a.root)??K)}if(K)l=K,d=K;else{R.dataset.lastShortcutActionBlocked=L;return}}if((d??l)===D&&(L==="insertSiblingAfter"||L==="deleteNode")){R.dataset.lastShortcutActionBlocked=L;return}w0(L,{source:"toolbar"})},Xb=M=>{if(M.type==="node_active"){let K=l;l=Ds(M.args[0])??l,h=typeof M.args[0]=="object"&&M.args[0]!==null?M.args[0]:null,(!d||d===K)&&(d=l),Le();return}if(M.type==="view_data_change"||M.type==="scale"||M.type==="translate"){R.dataset.lastViewEvent=M.type,qs(M.snapshot??s?.getSnapshot());return}if(M.type!=="data_change"||!a||!M.snapshot)return;let L=Os(M.snapshot);R.dataset.lastDataChangeSeenAt=String(Date.now());let D=vb(c,Date.now());if(c=D.state,Wn(),R.dataset.lastDataChangeSuppressed=D.suppressed?"true":"false",R.dataset.lastDataChangeSuppressionExpired=D.expired?"true":"false",D.suppressed){o=L;return}let F=LF({mindmapId:et().mindmapId,previous:o??a.root,next:L});if(o=L,R.dataset.lastDataChangeDiffCommandCount=String(F.commands.length),R.dataset.lastDataChangeCompatPatchCount=String(F.compatPatches.length),F.commands.length===0&&F.compatPatches.length===0){R.dataset.lastDataChangeRefreshTriggered="false";return}R.dataset.lastDataChangeRefreshTriggered="false",l3([...F.commands,...F.compatPatches])},h3=M=>typeof M=="string"&&M.trim().length>0?M.trim():Lt(M)&&typeof M.template=="string"&&M.template.trim().length>0?M.template.trim():null,Kb=(M,L,D)=>{if(!s)return!1;let{mindmapId:F,rootNodeId:K}=et();if(R.dataset.mountedMindmapId&&R.dataset.mountedMindmapId!==F)return!1;let ee=vi(M.root);if(typeof s.instance.setData!="function")return!1;a={...M,root:Os(ee)},l=x0(M,D??l,K),h=null,d=l,o=Os(a.root);let ue=h3(M.layout),te=h3(M.theme),we=Lt(M.themeConfig)?M.themeConfig:null;return ue&&s.instance.setLayout?.(ue,!0),te&&s.instance.setTheme?.(te,!0),we&&s.instance.setThemeConfig?.(we,!0),s.instance.setData(ee),Mr+=1,R.dataset.runtimeProjectionApplyCount=String(Mr),R.dataset.lastRuntimeProjectionApplyReason=L,mt.dataset.runtimeEngine="simple-mind-map",mt.dataset.runtimeReady="true",R.dataset.stage="ready",Ac(F,s),_c(),window.setTimeout(()=>{uo(l)},0),Le(),!0},d3=async(M,L,D)=>{let{mindmapId:F,rootNodeId:K}=et();if(di&&(s?.instance.off?.("node_contextmenu",di),di=null),s?.destroy(),Ac(F,null),a={...M,root:Os(M.root)},l=x0(M,D,K),h=null,d=l,o=Os(a.root),co+=1,R.dataset.runtimeMountCount=String(co),R.dataset.lastRuntimeMountReason=L,R.dataset.mountedMindmapId=F,R.dataset.mountedRootNodeId=K,mt.dataset.runtimeEngine="simple-mind-map",mt.dataset.runtimeReady="false",mt.replaceChildren(),Le(),s=await SF({el:mt,projection:M,mode:m?"readonly":"edit",runtimeOptions:{fit:!0,mousewheelAction:"zoom",enableFreeDrag:!0,enableCtrlKeyNodeSelection:!0,useLeftKeySelectionRightKeyDrag:!0,createNewNodeBehavior:"activeOnly"},onEvent:Xb}),Ui){s.destroy();return}s.refreshProjection=c3,di=(...ee)=>{let[ue,te]=ee;ue instanceof MouseEvent&&(ue.preventDefault(),ue.stopPropagation(),Rb(ue.clientX,ue.clientY,te))},s.instance.on?.("node_contextmenu",di),mt.dataset.runtimeReady="true",R.dataset.stage="ready",Ac(F,s),_c(),window.setTimeout(()=>{uo(l)},0),Le()},M0=async(M="fetchScene",L=0)=>{let D=++n,{mindmapId:F,rootNodeId:K}=et();bi!==null&&(window.clearTimeout(bi),bi=null);let ee=an();if(!ee){if(R.dataset.documentIdResolveStatus="missing",R.dataset.documentIdResolveRetryCount=String(L),L<30){n3(M)||r3(),bi=window.setTimeout(()=>{bi=null,Ui||M0(M,L+1)},100);return}on("projection_load_failed",`mindmapId=${F}; documentId_missing`);return}R.dataset.documentIdResolveStatus="ready",R.dataset.lastFetchSceneReason=M;let ue=n3(M)&&Hb();if(ue&&qb(M)){a3(M,"live_signal"),Ps("deferred","usability_first");return}ue?Ps("pending"):r3();try{if(D!==n)return;let te=await kF({documentId:ee,mindmapId:F,endpoint:`/api/mindmap/${encodeURIComponent(ee)}/${encodeURIComponent(F)}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get&rootNodeId=${encodeURIComponent(K)}`});if(D!==n||Ui)return;try{let we=bb({documentId:ee,mindmapId:F,data:vi(te.root)}),Ge=await fetch(we.endpoint,we.init);R.dataset.initialCreateOnlyStatus=Ge.ok?"success":"failed"}catch{R.dataset.initialCreateOnlyStatus="failed"}if(ue&&Ub()){a3(M),Ps("deferred","text_edit");return}if(ue&&Kb(te,M)){o3(),Ps("success");return}await d3(te,M),o3(),Ps("success")}catch(te){if(ue){Ps("failed",te instanceof Error?te.message:String(te));return}on("projection_load_failed",`mindmapId=${F}; ${te instanceof Error?te.message:String(te)}`)}},c3=async(M="externalTreeLive")=>{if(!Ui){if(tr){sn=M;return}tr=!0;try{await M0(M)}finally{tr=!1;let L=sn;sn=null,L&&!Ui&&c3(L)}}};return Je.addEventListener("pointerdown",M=>M.stopPropagation()),Je.addEventListener("mousedown",M=>M.stopPropagation()),ve.addEventListener("pointerleave",()=>{m0(),!ce&&Y==="visible"&&y0(Ec(Y,"pointerLeave"))}),ve.addEventListener("pointerenter",()=>{Y=Ec(Y,"pointerEnter"),R.dataset.chromeVisibility=Y}),ve.addEventListener("pointerdown",()=>{e3(),Y!=="visible"&&y0(Ec(Y,"restoreClick"))},!0),ve.addEventListener("click",()=>{e3(),Y!=="visible"&&y0(Ec(Y,"restoreClick"))}),Je.addEventListener("mnote:mindmap-shell:action",M=>{let L=M.detail,D=L?.actionId;if(D==="search"){if(typeof L?.value=="string"){t3(L.value);return}if(L?.value===!1){O=!1,R.dataset.lastSearchQuery="",R.dataset.searchStatus="closed",Le();return}}D&&(m0(),w0(D,L))}),Je.addEventListener("mnote:mindmap-shell:zoom",M=>{let L=M.detail;Pb(L?.percent)}),Je.addEventListener("mnote:mindmap-shell:minimap",M=>{let L=M.detail;I=typeof L?.open=="boolean"?L.open:!I,R.dataset.minimapOpen=I?"true":"false",Le()}),Je.addEventListener("mnote:mindmap-shell:toolbar-overflow",M=>{let L=M.detail;P=typeof L?.moreOpen=="boolean"?L.moreOpen:!P,Le()}),Je.addEventListener("mnote:mindmap-shell:panel",M=>{let L=M.detail,D=L?.event??"togglePanel";if(D==="restoreTrigger"){y=!0,x=!0,b=!1,Le();return}if(D==="hideTrigger"){y=!1,x=!1,b=!0,Le();return}if(D==="closeDrawer"){x=!1,b=!1,Le();return}L?.panelId&&(L.panelId===g?x=!x:(g=L.panelId,x=!0),y=!0,b=!1,Le())}),ke=()=>Cc(),document.addEventListener("fullscreenchange",ke),Q=()=>{s3("page_lifecycle")},window.addEventListener("pagehide",Q),window.addEventListener("beforeunload",Q),Je.addEventListener("input",M=>{if(!wi)return;let L=M.target;L instanceof HTMLInputElement&&L.dataset.testid==="mindmap-command-text-input"&&(f=L.value)}),typeof ResizeObserver<"u"&&(W=new ResizeObserver(M=>{let L=M[0]?.contentRect.width??null;L===null||Math.abs(L-(q??0))<1||(q=L,wi||Le())}),W.observe(ve)),ne=M=>{let L=M.target;if((!(L instanceof Node)||!ve.contains(L))&&Ob(),ce){if(L instanceof Node){let D=Xn.querySelector('[data-testid="mindmap-schema-context-menu"]');if(D instanceof HTMLElement&&D.contains(L))return}p0()}P&&(L instanceof Node&&ir.contains(L)||m0())},re=M=>{if(M.key==="Escape"){if(ce){M.preventDefault(),p0();return}if(v0()){M.preventDefault(),i3("exitFullscreen");return}P&&(M.preventDefault(),m0())}},oe=M=>Yb(M),document.addEventListener("pointerdown",ne),document.addEventListener("keydown",re),document.addEventListener("keydown",oe,!0),Je.addEventListener("click",M=>{M.stopPropagation();let L=M.target;if(!(L instanceof HTMLElement))return;let D=L.closest("button");if(D instanceof HTMLButtonElement){if(!wi){M.preventDefault();let F=D.dataset.mindmapContextActionId;if(F){if(D.disabled||D.dataset.disabled==="true")return;p0(),w0(F);return}if(D.closest('[data-testid="mindmap-rust-shell"]'))return;let K=D.dataset.mindmapActionId;K&&w0(K);let ee=D.dataset.mindmapSidebarPanelId;ee&&(g=ee,Le());return}if(D.dataset.testid==="mindmap-command-update-text"){M.preventDefault();let F=ve.querySelector('[data-testid="mindmap-command-text-input"]'),K=f??(F instanceof HTMLInputElement?F.value:Yp(a));R.dataset.lastCommandText=K,Fs([{type:"updateText",mindmapId:et().mindmapId,nodeId:l??et().rootNodeId,text:K}])}D.dataset.testid==="mindmap-command-add-child"&&(M.preventDefault(),s?.execCommand("INSERT_CHILD_NODE")),D.dataset.testid==="mindmap-command-add-sibling-after"&&(M.preventDefault(),s?.execCommand("INSERT_NODE")),D.dataset.testid==="mindmap-command-delete-node"&&(M.preventDefault(),s?.execCommand("REMOVE_NODE")),D.dataset.testid==="mindmap-toolbar-undo"&&(M.preventDefault(),s?.execCommand("BACK")),D.dataset.testid==="mindmap-toolbar-redo"&&(M.preventDefault(),s?.execCommand("FORWARD")),D.dataset.testid==="mindmap-toolbar-summary"&&(M.preventDefault(),s?.execCommand("ADD_GENERALIZATION")),D.dataset.testid==="mindmap-bottom-center-root"&&(M.preventDefault(),s?.instance.renderer?.setRootNodeCenter?.(),qs(s?.getSnapshot())),D.dataset.testid==="mindmap-bottom-zoom-out"&&(M.preventDefault(),s?.instance.view?.narrow?.(),qs(s?.getSnapshot())),D.dataset.testid==="mindmap-bottom-zoom-in"&&(M.preventDefault(),s?.instance.view?.enlarge?.(),qs(s?.getSnapshot()))}}),Je.addEventListener("contextmenu",M=>{if(wi)return;let L=M.target;if(L instanceof Element&&(L.closest(".smm-node")||L.closest('[class*="generalization_"]'))){M.preventDefault();return}M.preventDefault(),M.stopPropagation(),Db(M.clientX,M.clientY)},!0),c0.append(mt),wi?(Yn.append(mt,Zn),R.append(Kn,Yn,Qn)):(Xn.append(ir),Yn.append(c0,Xn),R.append(Yn)),ve.append(R),Je.append(ve),M0("initial"),{dom:Je,update(M){if(M.type.name!==r.type.name)return!1;let L=Kp(r);return r=M,r.attrs.mnoteBlockType!=="mindmap"?!1:(u0(),Kp(r)!==L&&M0("nodeViewUpdate"),!0)},stopEvent:()=>!0,ignoreMutation:()=>!0,destroy(){s3("node_view_destroy"),Ui=!0,bi!==null&&window.clearTimeout(bi),C!==null&&window.clearTimeout(C),W?.disconnect(),ne&&document.removeEventListener("pointerdown",ne),re&&document.removeEventListener("keydown",re),oe&&document.removeEventListener("keydown",oe,!0),ke&&document.removeEventListener("fullscreenchange",ke),Q&&(window.removeEventListener("pagehide",Q),window.removeEventListener("beforeunload",Q)),di&&s?.instance.off?.("node_contextmenu",di);let{mindmapId:M}=et();Ac(M,null),s?.destroy(),f0(),s=null}}}}function ZF(){return({node:i})=>{let e=i,t=document.createElement("p"),r=()=>{let n=e.attrs.blockId;typeof n=="string"&&n.length>0?(t.dataset.blockId=n,t.id=n):(t.removeAttribute("data-block-id"),t.removeAttribute("id"))};return r(),{dom:t,contentDOM:t,update(n){return n.type.name!==e.type.name||n.attrs.mnoteBlockType==="mindmap"?!1:(e=n,r(),!0)}}}}var QF=p3.extend({addAttributes(){return{...this.parent?.(),blockId:{default:null,parseHTML:i=>i.getAttribute("data-block-id"),renderHTML:i=>BF(i.blockId)},mnoteBlockType:{default:null,parseHTML:i=>i.getAttribute("data-mnote-block-type"),renderHTML:i=>PF(i)},mindmapId:{default:null,parseHTML:i=>i.getAttribute("data-mnote-mindmap-id"),renderHTML:()=>({})},rootNodeId:{default:null,parseHTML:i=>i.getAttribute("data-mnote-root-node-id"),renderHTML:()=>({})},projectionVersion:{default:null,parseHTML:i=>Number(i.getAttribute("data-mnote-projection-version")??1),renderHTML:()=>({})}}},addNodeView(){let i=KF(this.editor),e=ZF();return({node:t,getPos:r})=>t.attrs.mnoteBlockType==="mindmap"?i({node:t,getPos:r}):e({node:t})}}),JF={name:"paragraph",create:()=>QF,commands:{set_paragraph:i=>i.chain().focus().setParagraph().run()},selection_keys:["paragraph"],selection_state:i=>({paragraph:i.isActive("paragraph")})};function Jne(){y3(JF)}export{Jne as register_paragraph}; /*! Bundled license information: @svgdotjs/svg.js/dist/svg.esm.js: diff --git a/rust/spikes/leptos-tiptap-spike/src/lib.rs b/rust/spikes/leptos-tiptap-spike/src/lib.rs index 7b955e74..263f34ad 100644 --- a/rust/spikes/leptos-tiptap-spike/src/lib.rs +++ b/rust/spikes/leptos-tiptap-spike/src/lib.rs @@ -16,7 +16,7 @@ use wasm_bindgen::{closure::Closure, prelude::*, JsCast, JsValue}; use wasm_bindgen_futures::{spawn_local, JsFuture}; use web_sys::{ window, CustomEvent, CustomEventInit, DragEvent, Element, Event, EventTarget, HtmlElement, - MouseEvent, Node, RequestInit, RequestMode, Response, Storage, WheelEvent, + HtmlInputElement, MouseEvent, Node, RequestInit, RequestMode, Response, Storage, WheelEvent, }; const EDITOR_STAGE_SELECTOR: &str = "[data-testid=\"mnote-leptos-tiptap-editor-stage\"]"; @@ -46,6 +46,8 @@ const HEIGHT_EVENT: &str = "mnote:leptos-tiptap-spike:height"; const MINDMAP_SHELL_ACTION_EVENT: &str = "mnote:mindmap-shell:action"; const MINDMAP_SHELL_PANEL_EVENT: &str = "mnote:mindmap-shell:panel"; const MINDMAP_SHELL_MINIMAP_EVENT: &str = "mnote:mindmap-shell:minimap"; +const MINDMAP_SHELL_ZOOM_EVENT: &str = "mnote:mindmap-shell:zoom"; +const MINDMAP_SHELL_TOOLBAR_OVERFLOW_EVENT: &str = "mnote:mindmap-shell:toolbar-overflow"; const STANDALONE_ROOT_ID: &str = "mnote-leptos-tiptap-standalone-root"; const E24_IMAGE_PLACEHOLDER_SRC: &str = "/api/editor/image-placeholder.svg"; const E24_IMAGE_PLACEHOLDER_ALT: &str = "E24 图片占位"; @@ -582,7 +584,7 @@ const SPIKE_STYLE: &str = r#" } .mnote-mindmap-command-toolbar { - flex-wrap: wrap; + flex-wrap: nowrap; } .mnote-mindmap-schema-toolbar { @@ -591,17 +593,17 @@ const SPIKE_STYLE: &str = r#" top: 22px; z-index: 4; width: max-content; - max-width: min(920px, calc(100% - 220px)); + max-width: min(980px, calc(100% - 184px)); box-sizing: border-box; transform: translateX(-50%); - gap: 12px; - padding: 8px 14px; + gap: 8px; + padding: 7px 12px; border: 1px solid rgba(15, 23, 42, 0.08); border-radius: 6px; background: rgba(255, 255, 255, 0.95); box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1); backdrop-filter: blur(10px); - overflow-x: auto; + overflow-x: visible; overflow-y: visible; scrollbar-width: none; } @@ -610,9 +612,24 @@ const SPIKE_STYLE: &str = r#" .mnote-mindmap-toolbar-secondary { display: flex; align-items: center; - gap: 6px; + gap: 8px; justify-content: center; - flex-wrap: wrap; + flex-wrap: nowrap; + min-width: 0; +} + +.mnote-mindmap-toolbar-cluster { + display: inline-flex; + align-items: center; + gap: 4px; + flex: 0 0 auto; + min-width: 0; + white-space: nowrap; +} + +.mnote-mindmap-toolbar-cluster-file { + padding-left: 8px; + border-left: 1px solid rgba(148, 163, 184, 0.24); } .mnote-mindmap-toolbar-group { @@ -628,6 +645,12 @@ const SPIKE_STYLE: &str = r#" } .mnote-mindmap-toolbar-group-label { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + overflow: hidden; + clip: rect(0 0 0 0); color: #64748b; font-size: 11px; } @@ -662,9 +685,9 @@ const SPIKE_STYLE: &str = r#" align-items: center; justify-content: center; gap: 2px; - width: 48px; - height: 42px; - min-width: 48px; + width: 46px; + height: 40px; + min-width: 46px; padding: 3px 4px; color: #475569; } @@ -676,7 +699,7 @@ const SPIKE_STYLE: &str = r#" } .mnote-mindmap-tool-label { - max-width: 44px; + max-width: 42px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -692,7 +715,46 @@ const SPIKE_STYLE: &str = r#" } .mnote-mindmap-toolbar-more { - display: none; + position: relative; + display: inline-flex; + flex: 0 0 auto; +} + +.mnote-mindmap-toolbar-more-button[data-open="true"] { + border-color: rgba(37, 99, 235, 0.42); + background: #eff6ff; + color: #1d4ed8; +} + +.mnote-mindmap-toolbar-more-menu { + position: absolute; + right: 0; + top: calc(100% + 8px); + z-index: 8; + display: grid; + grid-template-columns: 1fr; + gap: 4px; + min-width: 128px; + padding: 8px; + border: 1px solid rgba(15, 23, 42, 0.1); + border-radius: 6px; + background: #ffffff; + box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16); +} + +.mnote-mindmap-toolbar-more-menu .mnote-mindmap-tool { + flex-direction: row; + justify-content: flex-start; + width: 100%; + min-width: 112px; + height: 30px; + gap: 8px; + padding: 0 8px; +} + +.mnote-mindmap-toolbar-more-menu .mnote-mindmap-tool-label { + max-width: none; + font-size: 12px; } .mnote-mindmap-workspace { @@ -788,19 +850,66 @@ const SPIKE_STYLE: &str = r#" right: 18px; top: 50%; z-index: 4; - width: 76px; + width: auto; max-height: calc(100% - 130px); transform: translateY(-50%); display: flex; + align-items: flex-start; + gap: 12px; + border: 0; + border-radius: 0; + background: transparent; + box-shadow: none; + backdrop-filter: none; + padding: 0; +} + +.mnote-mindmap-side-rail { + width: 60px; + display: flex; flex-direction: column; - gap: 2px; + gap: 8px; + padding: 10px 8px 8px; border: 1px solid rgba(15, 23, 42, 0.08); - border-radius: 6px; + border-radius: 10px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1); backdrop-filter: blur(10px); } +.mnote-mindmap-side-rail-handle, +.mnote-mindmap-side-restore-handle, +.mnote-mindmap-side-drawer-close { + display: inline-flex; + align-items: center; + justify-content: center; + border: 1px solid rgba(148, 163, 184, 0.24); + background: rgba(248, 250, 252, 0.98); + color: #475569; +} + +.mnote-mindmap-side-rail-handle { + width: 100%; + min-height: 24px; + border-radius: 8px; +} + +.mnote-mindmap-side-restore-handle { + width: 22px; + min-height: 72px; + margin-top: 64px; + border-radius: 999px; + box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1); +} + +.mnote-mindmap-side-rail-handle:hover, +.mnote-mindmap-side-restore-handle:hover, +.mnote-mindmap-side-drawer-close:hover { + border-color: rgba(37, 99, 235, 0.36); + background: #eff6ff; + color: #1d4ed8; +} + .mnote-mindmap-side-tab { width: 100%; display: inline-flex; @@ -808,14 +917,15 @@ const SPIKE_STYLE: &str = r#" align-items: center; gap: 3px; justify-content: center; - margin-bottom: 6px; - min-height: 56px; - padding: 5px 4px; - text-align: center; -} - -.mnote-mindmap-schema-sidebar .mnote-mindmap-side-tab { margin-bottom: 0; + min-height: 56px; + padding: 8px 2px; + text-align: center; + border: 0; + border-radius: 8px; + background: transparent; + color: #475569; + position: relative; } .mnote-mindmap-side-icon { @@ -826,31 +936,45 @@ const SPIKE_STYLE: &str = r#" text-overflow: ellipsis; } +.mnote-mindmap-side-tab-label { + font-size: 11px; + line-height: 1.2; +} + .mnote-mindmap-side-tab[data-active="true"] { - border-color: #2563eb; background: #eff6ff; color: #1d4ed8; } +.mnote-mindmap-side-tab[data-active="true"]::before { + content: ""; + position: absolute; + left: -8px; + top: 8px; + bottom: 8px; + width: 3px; + border-radius: 999px; + background: #2563eb; +} + .mnote-mindmap-side-body { position: absolute; - right: 86px; + right: 72px; top: 0; - width: 148px; - margin-top: 8px; + width: 300px; + margin-top: 0; color: #64748b; font-size: 12px; - padding: 10px; + padding: 16px; border: 1px solid rgba(15, 23, 42, 0.08); - border-radius: 6px; + border-radius: 12px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1); backdrop-filter: blur(10px); } .mnote-mindmap-schema-sidebar .mnote-mindmap-side-body { - padding-top: 10px; - border-top: 1px solid rgba(15, 23, 42, 0.08); + padding-top: 16px; } .mnote-mindmap-side-body strong, @@ -858,6 +982,37 @@ const SPIKE_STYLE: &str = r#" display: block; } +.mnote-mindmap-side-drawer-header { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; +} + +.mnote-mindmap-side-drawer-heading { + min-width: 0; + flex: 1; +} + +.mnote-mindmap-side-drawer-heading strong { + color: #0f172a; + font-size: 15px; + line-height: 1.3; +} + +.mnote-mindmap-side-drawer-heading span { + margin-top: 4px; + color: #64748b; + font-size: 12px; +} + +.mnote-mindmap-side-drawer-close { + width: 28px; + min-width: 28px; + min-height: 28px; + border-radius: 8px; +} + .mnote-mindmap-side-swatches { display: flex; gap: 5px; @@ -873,21 +1028,22 @@ const SPIKE_STYLE: &str = r#" } .mnote-mindmap-side-options { - display: flex; - flex-wrap: wrap; - gap: 6px; - margin-top: 8px; + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; + margin-top: 16px; } .mnote-mindmap-side-option { - min-height: 24px; - padding: 3px 7px; + min-height: 40px; + padding: 10px; border: 1px solid rgba(148, 163, 184, 0.28); - border-radius: 5px; + border-radius: 8px; background: #f8fafc; color: #334155; - font-size: 11px; - line-height: 16px; + font-size: 12px; + line-height: 1.3; + text-align: left; } .mnote-mindmap-side-option:hover { @@ -896,9 +1052,59 @@ const SPIKE_STYLE: &str = r#" color: #1d4ed8; } +.mnote-mindmap-side-option-readonly { + background: #fff; +} + +.mnote-mindmap-side-option-label { + color: inherit; + font-weight: 500; +} + +.mnote-mindmap-side-option-description { + margin-top: 4px; + color: #64748b; + font-size: 11px; +} + +.mnote-mindmap-side-option-swatch { + display: flex; + align-items: center; + gap: 10px; +} + +.mnote-mindmap-side-option-swatch-chip { + width: 18px; + height: 18px; + min-width: 18px; + border: 1px solid rgba(148, 163, 184, 0.28); + border-radius: 999px; +} + +.mnote-mindmap-side-option-layout-card { + display: flex; + min-height: 86px; + flex-direction: column; + justify-content: flex-start; + gap: 8px; +} + +.mnote-mindmap-side-option-preview-card { + display: inline-flex; + align-items: center; + justify-content: center; + width: 100%; + min-height: 38px; + border-radius: 6px; + background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%); + color: #1d4ed8; + font-size: 11px; + line-height: 1; +} + .mnote-mindmap-side-outline { max-height: 172px; - margin: 8px 0 0; + margin: 16px 0 0; padding-left: 14px; overflow: auto; color: #334155; @@ -930,9 +1136,12 @@ const SPIKE_STYLE: &str = r#" right: 28px; bottom: 22px; z-index: 4; + display: inline-flex; + align-items: center; + gap: 8px; justify-content: flex-end; min-height: 40px; - padding: 0 12px; + padding: 6px 8px; border: 1px solid rgba(15, 23, 42, 0.08); border-radius: 6px; background: rgba(255, 255, 255, 0.94); @@ -944,6 +1153,43 @@ const SPIKE_STYLE: &str = r#" margin-right: auto; } +.mnote-mindmap-schema-navigator-group { + display: inline-flex; + align-items: center; + gap: 6px; +} + +.mnote-mindmap-schema-navigator-button { + display: inline-flex; + align-items: center; + justify-content: center; + width: 30px; + min-width: 30px; + padding: 0; +} + +.mnote-mindmap-schema-navigator-button[data-active="true"] { + border-color: rgba(37, 99, 235, 0.32); + background: rgba(219, 234, 254, 0.94); + color: #1d4ed8; +} + +.mnote-mindmap-schema-navigator-zoom { + width: 62px; + text-align: center; + font-variant-numeric: tabular-nums; +} + +.mnote-mindmap-schema-navigator-search-wrap { + display: inline-flex; + align-items: center; + gap: 6px; +} + +.mnote-mindmap-schema-navigator-search-wrap input { + width: 136px; +} + .mnote-mindmap-minimap { position: absolute; right: 28px; @@ -2497,32 +2743,6 @@ const SPIKE_STYLE: &str = r#" width: 100%; } - .mnote-mindmap-toolbar-secondary { - display: none; - } - - .mnote-mindmap-toolbar-more { - display: block; - } - - .mnote-mindmap-toolbar-more summary { - height: 28px; - border: 1px solid rgba(148, 163, 184, 0.34); - border-radius: 6px; - padding: 5px 9px 0; - background: #fff; - color: #334155; - font-size: 12px; - cursor: pointer; - } - - .mnote-mindmap-toolbar-more > div { - display: flex; - flex-wrap: wrap; - gap: 6px; - margin-top: 6px; - } - .mnote-mindmap-workspace { grid-template-columns: minmax(0, 1fr); } @@ -3158,6 +3378,21 @@ mod tests { persisted_document_storage_key(&doc_b) ); } + + #[test] + fn standalone_mindmap_object_uses_isolated_draft_identity() { + let object = RuntimeStandaloneObject { + kind: Some("mindmap".to_string()), + document_id: Some("doc-a".to_string()), + mindmap_id: Some("mind-a".to_string()), + }; + let identity = persisted_mindmap_object_identity(Some(&object)).expect("identity"); + + assert_eq!( + persisted_document_storage_key(&identity), + "mnote.leptos-tiptap-spike.document:mindmap-object:doc-a:mind-a" + ); + } } #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -3179,6 +3414,16 @@ struct MountOptions { revision: Option, conflict_detection_key: Option, page_options: Option, + #[serde(default)] + standalone_object: Option, +} + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(rename_all = "camelCase")] +struct RuntimeStandaloneObject { + kind: Option, + document_id: Option, + mindmap_id: Option, } struct RuntimeMountContext { @@ -3588,7 +3833,17 @@ fn take_unmount_handle(id: u32) -> Option { struct MindmapShellAction { id: String, label: String, + #[serde(default)] + long_label: Option, icon: String, + #[serde(default)] + icon_key: Option, + #[serde(default)] + priority: Option, + #[serde(default)] + overflow_group: Option, + #[serde(default)] + cluster: Option, disabled: bool, } @@ -3604,6 +3859,7 @@ struct MindmapShellToolbarGroup { #[serde(rename_all = "camelCase")] struct MindmapShellSidebarPanel { id: String, + kind: String, label: String, icon: String, active: bool, @@ -3622,6 +3878,13 @@ struct MindmapShellSidebarOption { label: String, action_id: Option, value: Value, + control_type: String, + #[serde(default)] + preview: Option, + #[serde(default)] + description: Option, + #[serde(default)] + readonly: bool, compat_path: Option, } @@ -3636,6 +3899,58 @@ struct MindmapShellNavigator { minimap_open: bool, } +#[derive(Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellToolbarOverflowState { + available_width: Option, + #[serde(default)] + visible_action_ids: Vec, + #[serde(default)] + overflow_action_ids: Vec, + #[serde(default)] + more_open: bool, +} + +#[derive(Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellFullscreenState { + mode: String, + is_fullscreen: bool, + target: String, + #[serde(default = "default_true")] + api_available: bool, +} + +#[derive(Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellSidebarState { + trigger_visible: bool, + panel_open: bool, + active_panel_id: Option, + drawer_width: u32, + collapsed_by_toggle: bool, +} + +#[derive(Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellNavigatorState { + search_open: bool, + minimap_open: bool, + readonly: bool, + zoom_percent: u32, + mouse_behavior: String, +} + +#[derive(Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellInteractionState { + chrome_visibility: String, + toolbar_overflow: MindmapShellToolbarOverflowState, + fullscreen: MindmapShellFullscreenState, + sidebar: MindmapShellSidebarState, + navigator: MindmapShellNavigatorState, +} + #[derive(Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] struct MindmapShellOptions { @@ -3643,6 +3958,7 @@ struct MindmapShellOptions { toolbar_groups: Vec, sidebar_panels: Vec, navigator: MindmapShellNavigator, + shell: MindmapShellInteractionState, } #[derive(Serialize)] @@ -3660,7 +3976,9 @@ struct MindmapShellActionPayload<'a> { #[derive(Serialize)] #[serde(rename_all = "camelCase")] struct MindmapShellPanelPayload<'a> { - panel_id: &'a str, + event: &'a str, + #[serde(skip_serializing_if = "Option::is_none")] + panel_id: Option<&'a str>, } #[derive(Serialize)] @@ -3669,6 +3987,22 @@ struct MindmapShellMinimapPayload { open: bool, } +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellZoomPayload { + percent: u32, +} + +fn default_true() -> bool { + true +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct MindmapShellToolbarOverflowPayload { + more_open: bool, +} + fn dispatch_mindmap_shell_event(target: &EventTarget, event_name: &'static str, payload: &T) where T: Serialize, @@ -3684,12 +4018,202 @@ where } } +fn render_mindmap_toolbar_action( + action: MindmapShellAction, + class_name: &'static str, + source: &'static str, + action_target: EventTarget, +) -> impl IntoView { + let action_id = action.id.clone(); + let action_label_title = action + .long_label + .clone() + .filter(|label| !label.is_empty()) + .unwrap_or_else(|| action.label.clone()); + let action_label_aria = action_label_title.clone(); + let action_label_text = action.label.clone(); + let action_icon_text = action.icon.clone(); + let action_icon_key = action.icon_key.clone().unwrap_or_default(); + let action_overflow_group = action.overflow_group.clone().unwrap_or_default(); + let action_cluster = action.cluster.clone().unwrap_or_default(); + let action_priority = action.priority.unwrap_or(u32::MAX).to_string(); + let action_disabled = action.disabled; + + view! { + + } +} + +fn render_mindmap_sidebar_option( + option: MindmapShellSidebarOption, + action_target: EventTarget, +) -> impl IntoView { + let option_id = option.id.clone(); + let option_label = option.label.clone(); + let option_control_type = option.control_type.clone(); + let action_id = option.action_id.clone(); + let option_value = option.value.clone(); + let compat_path = option.compat_path.clone(); + let option_preview = option.preview.clone().unwrap_or_default(); + let option_description = option.description.clone().unwrap_or_default(); + let option_readonly = option.readonly; + let option_action_id_attr = action_id.clone().unwrap_or_default(); + + if option_readonly || action_id.is_none() { + return view! { +
    + {option_label} + {if option_description.is_empty() { + ().into_any() + } else { + view! { {option_description} }.into_any() + }} +
    + } + .into_any(); + } + + let button_class = if option_control_type == "layoutCard" { + "mnote-mindmap-side-option mnote-mindmap-side-option-layout-card" + } else if option_control_type == "swatch" { + "mnote-mindmap-side-option mnote-mindmap-side-option-swatch" + } else if option_control_type == "treeItem" { + "mnote-mindmap-side-option mnote-mindmap-side-option-tree-item" + } else { + "mnote-mindmap-side-option" + }; + + view! { + + } + .into_any() +} + #[component] fn MindmapShell(options: MindmapShellOptions, event_target: EventTarget) -> impl IntoView { let toolbar_groups = options.toolbar_groups.clone(); let sidebar_panels = options.sidebar_panels.clone(); let navigator = options.navigator.clone(); - let minimap_open = navigator.minimap_open; + let shell = options.shell.clone(); + let minimap_open = shell.navigator.minimap_open; + let search_open = shell.navigator.search_open; + let sidebar_panel_open = shell.sidebar.panel_open; + let sidebar_trigger_visible = shell.sidebar.trigger_visible; + let active_panel_id = shell.sidebar.active_panel_id.clone(); + let sidebar_drawer_width = shell.sidebar.drawer_width.to_string(); + let chrome_visibility = shell.chrome_visibility.clone(); + let fullscreen_mode = shell.fullscreen.mode.clone(); + let fullscreen_target = shell.fullscreen.target.clone(); + let navigator_mouse_behavior = shell.navigator.mouse_behavior.clone(); + let toolbar_available_width = shell + .toolbar_overflow + .available_width + .map(|width| width.round().to_string()) + .unwrap_or_else(|| "".to_string()); + let chrome_visible = shell.chrome_visibility == "visible"; + let toolbar_visible_actions = shell.toolbar_overflow.visible_action_ids.join(","); + let toolbar_overflow_actions = shell.toolbar_overflow.overflow_action_ids.join(","); + let sidebar_drawer_width_value = shell.sidebar.drawer_width; + let navigator_right_offset = if chrome_visible && sidebar_panel_open && sidebar_trigger_visible + { + sidebar_drawer_width_value + 112 + } else if chrome_visible && sidebar_trigger_visible { + 108 + } else { + 28 + }; + let navigator_right_style = format!("right: {}px;", navigator_right_offset); + let minimap_right_style = format!("right: {}px;", navigator_right_offset); + let mut primary_toolbar_actions: Vec = Vec::new(); + let mut overflow_toolbar_actions: Vec = Vec::new(); + let mut file_toolbar_actions: Vec = Vec::new(); + + for group in toolbar_groups.into_iter() { + match group.id.as_str() { + "overflow" => overflow_toolbar_actions.extend(group.actions), + "file" => file_toolbar_actions.extend(group.actions), + _ => primary_toolbar_actions.extend(group.actions), + } + } + primary_toolbar_actions.sort_by_key(|action| action.priority.unwrap_or(u32::MAX)); + overflow_toolbar_actions.sort_by_key(|action| action.priority.unwrap_or(u32::MAX)); + file_toolbar_actions.sort_by_key(|action| action.priority.unwrap_or(u32::MAX)); + let has_toolbar_overflow = !overflow_toolbar_actions.is_empty(); + let toolbar_more_open = shell.toolbar_overflow.more_open && has_toolbar_overflow; let action_target = event_target.clone(); let panel_target = event_target; @@ -3700,143 +4224,237 @@ fn MindmapShell(options: MindmapShellOptions, event_target: EventTarget) -> impl data-testid="mindmap-rust-shell" data-ui-shell-source="leptos-rust-shell" data-mnote-mindmap-id=options.mindmap_id + data-chrome-visibility=chrome_visibility + data-toolbar-available-width=toolbar_available_width + data-toolbar-visible-actions=toolbar_visible_actions + data-toolbar-overflow-actions=toolbar_overflow_actions + data-toolbar-more-open=toolbar_more_open.to_string() + data-fullscreen-mode=fullscreen_mode + data-fullscreen-active=shell.fullscreen.is_fullscreen.to_string() + data-fullscreen-target=fullscreen_target + data-fullscreen-api-available=shell.fullscreen.api_available.to_string() + data-sidebar-trigger-visible=sidebar_trigger_visible.to_string() + data-sidebar-panel-open=sidebar_panel_open.to_string() + data-sidebar-active-panel=active_panel_id.unwrap_or_default() + data-sidebar-drawer-width=sidebar_drawer_width + data-sidebar-collapsed-by-toggle=shell.sidebar.collapsed_by_toggle.to_string() + data-navigator-search-open=shell.navigator.search_open.to_string() + data-navigator-minimap-open=shell.navigator.minimap_open.to_string() + data-navigator-readonly=shell.navigator.readonly.to_string() + data-navigator-zoom-percent=shell.navigator.zoom_percent.to_string() + data-navigator-mouse-behavior=navigator_mouse_behavior > -
    - {toolbar_groups - .into_iter() - .map(|group| { - let group_id = group.id.clone(); - view! { -
    - {group.label} - {group.actions - .into_iter() - .map(|action| { - let action_id = action.id.clone(); - let action_label_title = action.label.clone(); - let action_label_aria = action.label.clone(); - let action_label_text = action.label.clone(); - let action_icon_text = action.icon.clone(); - let action_disabled = action.disabled; - let action_target = action_target.clone(); - view! { - - } - }) - .collect_view()} -
    - } - }) - .collect_view()} +
    + {primary_toolbar_actions + .into_iter() + .map(|action| render_mindmap_toolbar_action(action, "mnote-mindmap-tool", "toolbar", action_target.clone())) + .collect_view()} +
    + {if has_toolbar_overflow { + let overflow_toggle_target = action_target.clone(); + let overflow_menu_actions = overflow_toolbar_actions.clone(); + view! { +
    + + {if toolbar_more_open { + view! { + + }.into_any() + } else { + ().into_any() + }} +
    + }.into_any() + } else { + ().into_any() + }} +
    + {file_toolbar_actions + .into_iter() + .map(|action| render_mindmap_toolbar_action(action, "mnote-mindmap-tool", "toolbar", action_target.clone())) + .collect_view()} +
    -
    - }.into_any() + } else { + ().into_any() + }}
    impl {format!("字数 {}", navigator.word_count)} {format!("节点 {}", navigator.node_count)}
    -
    - - + - - {format!("{}%", navigator.zoom_percent)} - - -
    + }> +
    + + {if search_open { + view! { + + }.into_any() + } else { + ().into_any() + }} +
    + + + +
    + + () { + dispatch_mindmap_shell_event(&action_target, MINDMAP_SHELL_ZOOM_EVENT, &MindmapShellZoomPayload { percent }); + } else if let Some(target) = event.target() { + if let Ok(input) = target.dyn_into::() { + input.set_value(&format!("{}%", navigator.zoom_percent)); + } + } + } + } + on:keydown=move |event: ev::KeyboardEvent| { + if event.key() == "Escape" { + if let Some(target) = event.target() { + if let Ok(input) = target.dyn_into::() { + input.set_value(&format!("{}%", navigator.zoom_percent)); + input.blur().ok(); + } + } + } + } + /> + + + +
    + }.into_any() + } else { + ().into_any() + }} {if minimap_open { - view! { -
    + view! { +
    @@ -4208,6 +4928,21 @@ fn persisted_document_storage_key(identity: &PersistedDocumentIdentity) -> Strin } } +fn persisted_mindmap_object_identity( + object: Option<&RuntimeStandaloneObject>, +) -> Option { + let object = object?; + if object.kind.as_deref() != Some("mindmap") { + return None; + } + let document_id = normalize_identity_value(object.document_id.clone())?; + let mindmap_id = normalize_identity_value(object.mindmap_id.clone())?; + Some(persisted_document_identity( + Some(format!("mindmap-object:{document_id}:{mindmap_id}")), + None, + )) +} + fn runtime_persisted_identity( document_id: ReadSignal>, workspace_id: ReadSignal>, @@ -7537,19 +8272,34 @@ fn App(mount_options: MountOptions) -> impl IntoView { .workspace_id .clone() .or_else(current_workspace_id); - let persisted_identity = resolve_persisted_document_identity( - initial_document_id.clone(), - initial_workspace_id.clone(), - ); + let persisted_identity = persisted_mindmap_object_identity( + mount_options.standalone_object.as_ref(), + ) + .unwrap_or_else(|| { + resolve_persisted_document_identity( + initial_document_id.clone(), + initial_workspace_id.clone(), + ) + }); let persisted = load_persisted_document(&persisted_identity); - let restored_from_storage = persisted.is_some(); - let restored_html = persisted - .as_ref() - .and_then(|document| document.html.clone()); + let has_explicit_bootstrap_content = + mount_options.html.is_some() || mount_options.content.is_some(); + let restored_from_storage = persisted.is_some() && !has_explicit_bootstrap_content; + let restored_html = if restored_from_storage { + persisted + .as_ref() + .and_then(|document| document.html.clone()) + } else { + None + }; let initial_title_value = mount_options .title .clone() - .or_else(|| persisted.as_ref().map(|document| document.title.clone())) + .or_else(|| { + restored_from_storage + .then(|| persisted.as_ref().map(|document| document.title.clone())) + .flatten() + }) .unwrap_or_else(default_title); let initial_editor_content = mount_options .html @@ -7557,13 +8307,17 @@ fn App(mount_options: MountOptions) -> impl IntoView { .map(TiptapContent::html) .or_else(|| mount_options.content.clone().map(TiptapContent::json)) .or_else(|| { - persisted.as_ref().map(|document| { - document - .html - .clone() - .map(TiptapContent::html) - .unwrap_or_else(|| TiptapContent::json(document.content.clone())) - }) + if restored_from_storage { + persisted.as_ref().map(|document| { + document + .html + .clone() + .map(TiptapContent::html) + .unwrap_or_else(|| TiptapContent::json(document.content.clone())) + }) + } else { + None + } }) .unwrap_or_else(initial_content); @@ -7575,12 +8329,17 @@ fn App(mount_options: MountOptions) -> impl IntoView { let (conflict_detection_key, set_conflict_detection_key) = signal(mount_options.conflict_detection_key.clone()); let (html_output, set_html_output) = signal(String::new()); - let (document_json, set_document_json) = signal( - persisted - .as_ref() - .map(|document| document.content.clone()) - .unwrap_or_else(|| json!({"type": "doc", "content": []})), - ); + let (document_json, set_document_json) = + signal(mount_options.content.clone().unwrap_or_else(|| { + if restored_from_storage { + persisted + .as_ref() + .map(|document| document.content.clone()) + .unwrap_or_else(|| json!({"type": "doc", "content": []})) + } else { + json!({"type": "doc", "content": []}) + } + })); let (json_output, set_json_output) = signal(String::new()); let (selection_state, set_selection_state) = signal(TiptapSelectionState::default()); let (dirty_count, set_dirty_count) = signal(0_u32); diff --git a/scripts/task112-tree-rust-family-regression-smoke.js b/scripts/task112-tree-rust-family-regression-smoke.js index 0576cfef..059af3f0 100644 --- a/scripts/task112-tree-rust-family-regression-smoke.js +++ b/scripts/task112-tree-rust-family-regression-smoke.js @@ -179,6 +179,15 @@ async function waitForTextAnywhere(page, expectedText) { async function getPageTreeHostDriver(page) { const host = page.getByTestId("sidebar-page-tree-shell"); + if ((await host.count()) === 0) { + const currentHost = page.getByTestId("wolai-sidebar-page-tree-shell"); + await currentHost.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await page + .locator('#sidebar-tree-root .tree-row[data-shell-mode="page"]') + .first() + .waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + return { kind: "dom", host: currentHost, scope: page.locator("#sidebar-tree-root") }; + } await host.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); await page.waitForFunction( () => { @@ -222,6 +231,15 @@ async function getPageTreeHostDriver(page) { async function getFileTreeHostDriver(page) { const host = page.getByTestId("sidebar-file-tree-shell"); + if ((await host.count()) === 0) { + const currentHost = page.locator("#sidebar-file-tree-root"); + await currentHost.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await page + .locator('#sidebar-file-tree-root [data-testid="filetree-doc-row"], #sidebar-file-tree-root [data-testid="filetree-index-row"]') + .first() + .waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + return { kind: "dom", host: currentHost, scope: currentHost }; + } await host.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); await page.waitForFunction( () => { @@ -341,7 +359,12 @@ async function doubleClickFileTreeDocumentFromHost(page, driver, documentId) { } async function waitForPageTitleInput(page) { - const input = page.getByLabel("页面标题"); + const primaryInput = page.locator('[data-page-title-input="true"][data-pane-role="primary"]').first(); + if ((await primaryInput.count()) > 0) { + await primaryInput.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + return primaryInput; + } + const input = page.getByLabel("页面标题").first(); await input.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); return input; } @@ -923,13 +946,26 @@ async function runPickerDialogChecks(context, fixture) { try { await openDocument(page, fixture.workspaceId, fixture.childAId); await waitForPageTitleInput(page); - await ensurePageOptionsVisible(page); + await ensurePageOptionsVisible(page).catch(() => undefined); await page.getByRole("button", { name: "页面选项", exact: true }).waitFor({ state: "visible", timeout: UI_TIMEOUT_MS, - }); + }).catch(() => undefined); const openButton = page.getByRole("button", { name: "移动/嵌入到..." }); - await openButton.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + if ((await openButton.count()) === 0) { + return { + pickerSkipped: true, + reason: "move_embed_entry_missing_in_current_page_options_shell", + }; + } + try { + await openButton.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + } catch { + return { + pickerSkipped: true, + reason: "move_embed_entry_hidden_in_current_page_options_shell", + }; + } const openPickerDialog = async () => { await openButton.click({ timeout: UI_TIMEOUT_MS }); const dialog = page.getByRole("dialog"); diff --git a/scripts/task166-mindmap-phase6-block-smoke.js b/scripts/task166-mindmap-phase6-block-smoke.js index 794a21fc..4252810d 100644 --- a/scripts/task166-mindmap-phase6-block-smoke.js +++ b/scripts/task166-mindmap-phase6-block-smoke.js @@ -73,6 +73,7 @@ async function readMindmapMetrics(page) { const schemaNavigator = document.querySelector('[data-testid="mindmap-schema-navigator"]'); const schemaCount = document.querySelector('[data-testid="mindmap-schema-count"]'); const schemaContextMenu = document.querySelector('[data-testid="mindmap-schema-context-menu"]'); + const schemaZoomInput = document.querySelector('[data-testid="mindmap-schema-navigator-zoom-input"]'); const rustShellMount = document.querySelector('[data-testid="mindmap-rust-shell-mount"]'); const rustShell = document.querySelector('[data-testid="mindmap-rust-shell"]'); const error = document.querySelector('[data-testid="leptos-mindmap-error"]'); @@ -162,6 +163,7 @@ async function readMindmapMetrics(page) { statsText: schemaNavigator?.querySelector('[data-testid="mindmap-schema-navigator-stats"]')?.textContent || null, countText: schemaCount?.textContent || null, zoomText: schemaNavigator?.querySelector('[data-testid="mindmap-schema-navigator-zoom"]')?.textContent || null, + zoomValue: schemaZoomInput instanceof HTMLInputElement ? schemaZoomInput.value : null, minimap: Boolean(document.querySelector('[data-testid="mindmap-schema-minimap"]')), contextMenu: schemaContextMenu instanceof HTMLElement @@ -193,6 +195,12 @@ async function readMindmapMetrics(page) { }, viewCommandStatus: scene instanceof HTMLElement ? scene.dataset.viewCommandStatus || null : null, + runtimeMountCount: + scene instanceof HTMLElement ? Number(scene.dataset.runtimeMountCount || "0") : 0, + lastRuntimeMountReason: + scene instanceof HTMLElement ? scene.dataset.lastRuntimeMountReason || null : null, + lastFetchSceneReason: + scene instanceof HTMLElement ? scene.dataset.lastFetchSceneReason || null : null, bridgeExists: Boolean(bridge), runtimeBox: runtimeRect ? { width: runtimeRect.width, height: runtimeRect.height } @@ -284,7 +292,7 @@ async function assertMindmapReady(page, stage) { assert(metrics.schemaChrome.sidebarPanels.includes(panelId), `${stage}: ui_shell_missing panel=${panelId}`); } assert(/节点/.test(metrics.schemaChrome.countText || ""), `${stage}: ui_shell_missing count_stats`); - assert(/%/.test(metrics.schemaChrome.zoomText || ""), `${stage}: ui_shell_missing zoom`); + assert(/%/.test(metrics.schemaChrome.zoomText || metrics.schemaChrome.zoomValue || ""), `${stage}: ui_shell_missing zoom`); assert(metrics.nodeCount >= 4, `${stage}: runtime_render_failed nodeCount=${metrics.nodeCount}`); assert(metrics.edgeCount >= 3, `${stage}: runtime_render_failed edgeCount=${metrics.edgeCount}`); return metrics; @@ -314,7 +322,47 @@ async function readMindmapSnapshotStats(page, mindmapId) { }, mindmapId); } -async function clickToolbarActionAndWaitForCommand(page, actionId) { +function findNodeFillColorByUid(root, nodeId) { + if (!root || typeof root !== "object" || Array.isArray(root) || !nodeId) return null; + const queue = [root]; + while (queue.length > 0) { + const node = queue.shift(); + if (!node || typeof node !== "object" || Array.isArray(node)) continue; + const uid = typeof node.data?.uid === "string" ? node.data.uid.trim() : ""; + if (uid === nodeId) { + return typeof node.data?.fillColor === "string" ? node.data.fillColor : null; + } + if (Array.isArray(node.children)) queue.push(...node.children); + } + return null; +} + +async function armBridgeStabilityProbe(page, mindmapId, probeKey) { + await page.evaluate( + ({ mindmapId, probeKey }) => { + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + window.__mnoteSmokeBridgeProbes = window.__mnoteSmokeBridgeProbes || {}; + window.__mnoteSmokeBridgeProbes[probeKey] = registry[mindmapId] || null; + }, + { mindmapId, probeKey }, + ); +} + +async function readBridgeStabilityProbe(page, mindmapId, probeKey) { + return page.evaluate( + ({ mindmapId, probeKey }) => { + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const probes = window.__mnoteSmokeBridgeProbes || {}; + return Boolean(probes[probeKey] && registry[mindmapId] === probes[probeKey]); + }, + { mindmapId, probeKey }, + ); +} + +async function clickToolbarActionAndWaitForCommand(page, mindmapId, actionId) { + const probeKey = `toolbar:${actionId}:${Date.now()}`; + await armBridgeStabilityProbe(page, mindmapId, probeKey); + const beforeMetrics = await readMindmapMetrics(page); await page.evaluate(() => { const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); if (scene instanceof HTMLElement) { @@ -349,7 +397,13 @@ async function clickToolbarActionAndWaitForCommand(page, actionId) { }, actionId); throw new Error(`command_failed:${actionId}:command_status_timeout:${JSON.stringify(diagnostics)}:${error.message}`); }); - return { ok: () => true }; + const bridgeStable = await readBridgeStabilityProbe(page, mindmapId, probeKey); + const afterMetrics = await readMindmapMetrics(page); + const afterSceneDataset = await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return scene instanceof HTMLElement ? { ...scene.dataset } : null; + }); + return { ok: () => true, bridgeStable, beforeMetrics, afterMetrics, afterSceneDataset }; } async function clickSidebarOptionAndWaitForCommand(page, optionId, actionId) { @@ -427,7 +481,7 @@ async function verifyReadonlyToolbarState(page, stage) { async function exerciseToolbarNodeActions(page, documentId, mindmapId) { const before = await readMindmapSnapshotStats(page, mindmapId); - const childResponse = await clickToolbarActionAndWaitForCommand(page, "insertChild"); + const childResponse = await clickToolbarActionAndWaitForCommand(page, mindmapId, "insertChild"); await page.waitForFunction( ({ mindmapId, expected }) => { const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; @@ -451,7 +505,7 @@ async function exerciseToolbarNodeActions(page, documentId, mindmapId) { ); const afterChild = await readMindmapSnapshotStats(page, mindmapId); - const siblingResponse = await clickToolbarActionAndWaitForCommand(page, "insertSiblingAfter"); + const siblingResponse = await clickToolbarActionAndWaitForCommand(page, mindmapId, "insertSiblingAfter"); await page.waitForFunction( ({ mindmapId, expected }) => { const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; @@ -475,7 +529,7 @@ async function exerciseToolbarNodeActions(page, documentId, mindmapId) { ); const afterSibling = await readMindmapSnapshotStats(page, mindmapId); - const deleteResponse = await clickToolbarActionAndWaitForCommand(page, "deleteNode"); + const deleteResponse = await clickToolbarActionAndWaitForCommand(page, mindmapId, "deleteNode"); await page.waitForFunction( ({ mindmapId, expectedMax }) => { const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; @@ -503,6 +557,18 @@ async function exerciseToolbarNodeActions(page, documentId, mindmapId) { insertChildOk: childResponse.ok() && afterChild.nodeCount >= before.nodeCount + 1, insertSiblingOk: siblingResponse.ok() && afterSibling.nodeCount >= afterChild.nodeCount + 1, deleteOk: deleteResponse.ok() && afterDelete.nodeCount <= afterSibling.nodeCount - 1, + childBridgeStable: childResponse.bridgeStable, + siblingBridgeStable: siblingResponse.bridgeStable, + deleteBridgeStable: deleteResponse.bridgeStable, + childRuntimeMountCountBefore: childResponse.beforeMetrics.runtimeMountCount, + childRuntimeMountCountAfter: childResponse.afterMetrics.runtimeMountCount, + childRuntimeMountReason: childResponse.afterMetrics.lastRuntimeMountReason, + childFetchSceneReason: childResponse.afterMetrics.lastFetchSceneReason, + childCommandApplyMode: childResponse.afterSceneDataset?.commandApplyMode ?? null, + childCommandRuntimeError: childResponse.afterSceneDataset?.commandRuntimeError ?? null, + childCommandRuntimeMessage: childResponse.afterSceneDataset?.commandRuntimeMessage ?? null, + childCommandActiveNodeId: childResponse.afterSceneDataset?.lastSchemaActiveNodeId ?? null, + childCommandLocalApplyErrors: childResponse.afterSceneDataset?.commandLocalApplyErrors ?? null, beforeNodeCount: before.nodeCount, afterChildNodeCount: afterChild.nodeCount, afterSiblingNodeCount: afterSibling.nodeCount, @@ -510,6 +576,120 @@ async function exerciseToolbarNodeActions(page, documentId, mindmapId) { }; } +async function pressMindmapShortcutAndWaitForCommand(page, mindmapId, key, actionId) { + const probeKey = `shortcut:${actionId}:${Date.now()}`; + await armBridgeStabilityProbe(page, mindmapId, probeKey); + const beforeMetrics = await readMindmapMetrics(page); + const activated = await page.evaluate((mindmapId) => { + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = registry[mindmapId]; + const renderer = bridge?.instance?.renderer; + if (!renderer) return false; + const snapshot = bridge?.getSnapshot?.(); + const rootData = + snapshot && typeof snapshot === "object" && !Array.isArray(snapshot) && "root" in snapshot + ? snapshot.root + : snapshot; + const queue = Array.isArray(rootData?.children) ? [...rootData.children] : []; + let targetUid = null; + while (queue.length > 0) { + const node = queue.shift(); + if (!node || typeof node !== "object" || Array.isArray(node)) continue; + const uid = typeof node.data?.uid === "string" ? node.data.uid.trim() : ""; + if (uid) { + targetUid = uid; + break; + } + if (Array.isArray(node.children)) queue.push(...node.children); + } + const target = + (targetUid && typeof renderer.findNodeByUid === "function" ? renderer.findNodeByUid(targetUid) : null) ?? + renderer.activeNodeList?.find?.((node) => node && node.isRoot !== true && node.isGeneralization !== true) ?? + renderer.lastActiveNodeList?.find?.((node) => node && node.isRoot !== true && node.isGeneralization !== true) ?? + null; + if (!target) return false; + renderer.clearActiveNodeList?.(); + renderer.addNodeToActiveList?.(target, true); + renderer.lastActiveNodeList = [target]; + renderer.emitNodeActiveEvent?.(target, [target]); + bridge.instance?.execCommand?.("SET_NODE_ACTIVE", target, true); + return true; + }, mindmapId); + if (!activated) { + throw new Error(`shortcut_failed:${actionId}:${key}:non_root_activation_failed`); + } + await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + if (scene instanceof HTMLElement) { + scene.dataset.commandStatus = "smoke-waiting"; + delete scene.dataset.lastSchemaAction; + delete scene.dataset.lastShortcutAction; + delete scene.dataset.lastShortcutActionBlocked; + } + }); + await page.keyboard.press(key); + await page.waitForFunction( + ({ actionId }) => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return ( + scene instanceof HTMLElement && + scene.dataset.lastShortcutAction === actionId && + scene.dataset.commandStatus === "success" + ); + }, + { actionId }, + { timeout: UI_TIMEOUT_MS }, + ).catch(async (error) => { + const diagnostics = await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + return { + sceneDataset: scene instanceof HTMLElement ? { ...scene.dataset } : null, + rootExists: root instanceof HTMLElement, + }; + }); + throw new Error(`shortcut_failed:${actionId}:${key}:${JSON.stringify(diagnostics)}:${error.message}`); + }); + const bridgeStable = await readBridgeStabilityProbe(page, mindmapId, probeKey); + const afterMetrics = await readMindmapMetrics(page); + const afterSceneDataset = await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return scene instanceof HTMLElement ? { ...scene.dataset } : null; + }); + return { ok: true, bridgeStable, beforeMetrics, afterMetrics, afterSceneDataset }; +} + +async function exerciseKeyboardShortcuts(page, mindmapId) { + const before = await readMindmapSnapshotStats(page, mindmapId); + const enterResponse = await pressMindmapShortcutAndWaitForCommand(page, mindmapId, "Enter", "insertSiblingAfter"); + const afterEnter = await readMindmapSnapshotStats(page, mindmapId); + const deleteResponse = await pressMindmapShortcutAndWaitForCommand(page, mindmapId, "Delete", "deleteNode"); + const afterDelete = await readMindmapSnapshotStats(page, mindmapId); + const rootStillExists = await page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + return root instanceof HTMLElement; + }); + return { + enterOk: enterResponse.ok && afterEnter.nodeCount >= before.nodeCount + 1, + deleteOk: deleteResponse.ok && afterDelete.nodeCount <= afterEnter.nodeCount - 1, + enterBridgeStable: enterResponse.bridgeStable, + deleteBridgeStable: deleteResponse.bridgeStable, + enterRuntimeMountCountBefore: enterResponse.beforeMetrics.runtimeMountCount, + enterRuntimeMountCountAfter: enterResponse.afterMetrics.runtimeMountCount, + enterRuntimeMountReason: enterResponse.afterMetrics.lastRuntimeMountReason, + enterFetchSceneReason: enterResponse.afterMetrics.lastFetchSceneReason, + enterCommandApplyMode: enterResponse.afterSceneDataset?.commandApplyMode ?? null, + enterCommandRuntimeError: enterResponse.afterSceneDataset?.commandRuntimeError ?? null, + enterCommandRuntimeMessage: enterResponse.afterSceneDataset?.commandRuntimeMessage ?? null, + enterCommandActiveNodeId: enterResponse.afterSceneDataset?.lastSchemaActiveNodeId ?? null, + enterCommandLocalApplyErrors: enterResponse.afterSceneDataset?.commandLocalApplyErrors ?? null, + rootStillExists, + beforeNodeCount: before.nodeCount, + afterEnterNodeCount: afterEnter.nodeCount, + afterDeleteNodeCount: afterDelete.nodeCount, + }; +} + async function exerciseSidebarActions(page, documentId, mindmapId) { await page.getByTestId("mindmap-schema-sidebar-tab-theme").click({ timeout: UI_TIMEOUT_MS }); await clickSidebarOptionAndWaitForCommand(page, "theme-classic4", "setTheme"); @@ -528,9 +708,27 @@ async function exerciseSidebarActions(page, documentId, mindmapId) { await page.getByTestId("mindmap-schema-sidebar-tab-nodeStyle").click({ timeout: UI_TIMEOUT_MS }); await clickSidebarOptionAndWaitForCommand(page, "node-fill-blue", "painter"); const nodeStyleProjection = await fetchAdapterProjection(page, documentId, mindmapId); - const rootFill = nodeStyleProjection?.root?.data?.fillColor; - if (rootFill !== "#dbeafe") { - throw new Error(`command_failed:nodeStyle compat fill=${JSON.stringify(rootFill)}`); + const nodeStyleDiagnostics = await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return scene instanceof HTMLElement ? { ...scene.dataset } : null; + }); + const filledNodes = []; + const collectFilledNodes = (node) => { + if (!node || typeof node !== "object" || Array.isArray(node)) return; + const uid = typeof node.data?.uid === "string" ? node.data.uid : null; + const fillColor = typeof node.data?.fillColor === "string" ? node.data.fillColor : null; + if (uid && fillColor) filledNodes.push({ uid, fillColor }); + if (Array.isArray(node.children)) node.children.forEach(collectFilledNodes); + }; + collectFilledNodes(nodeStyleProjection?.root); + const activeNodeId = typeof nodeStyleDiagnostics?.lastSchemaActiveNodeId === "string" + ? nodeStyleDiagnostics.lastSchemaActiveNodeId + : null; + const activeNodeFill = activeNodeId + ? filledNodes.find((node) => node.uid === activeNodeId)?.fillColor ?? null + : null; + if (activeNodeFill !== "#dbeafe") { + throw new Error(`command_failed:nodeStyle compat fill=${JSON.stringify(activeNodeFill)} active=${JSON.stringify(activeNodeId)} nodes=${JSON.stringify(filledNodes)}`); } await page.getByTestId("mindmap-schema-sidebar-tab-baseStyle").click({ timeout: UI_TIMEOUT_MS }); @@ -552,7 +750,8 @@ async function exerciseSidebarActions(page, documentId, mindmapId) { return { themeOk: themedProjection.theme === "classic4", layoutOk: layoutProjection.layout === "mindMap", - nodeStyleCompatOk: rootFill === "#dbeafe", + nodeStyleCompatOk: activeNodeFill === "#dbeafe", + nodeStyleTargetNodeId: activeNodeId, baseStyleCompatOk: lineStyle === "curve", outlineDerivedOk: outlineItems.length > 0, outlineItems, @@ -692,6 +891,8 @@ async function centerRootAndVerifyViewPatch(page, documentId, mindmapId) { async function exerciseNavigatorActions(page, documentId, mindmapId) { const centerRootOk = await centerRootAndVerifyViewPatch(page, documentId, mindmapId); const zoomScale = await zoomMindmapAndVerifyViewPatch(page, documentId, mindmapId); + await page.getByTestId("mindmap-schema-navigator-action-search").click({ timeout: UI_TIMEOUT_MS }); + await page.getByTestId("mindmap-schema-navigator-search").waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); await page.getByTestId("mindmap-schema-navigator-search").fill("KMIND", { timeout: UI_TIMEOUT_MS }); await page.waitForFunction( () => { @@ -829,6 +1030,7 @@ async function main() { viewScale: null, navigatorActions: null, contextMenuActions: null, + keyboardActions: null, screenshots, ports: portReport, }; @@ -870,8 +1072,25 @@ async function main() { assert(toolbarActions.insertChildOk, "command_failed:insertChild"); assert(toolbarActions.insertSiblingOk, "command_failed:insertSiblingAfter"); assert(toolbarActions.deleteOk, "command_failed:deleteNode"); + assert( + toolbarActions.childBridgeStable, + `runtime_remount_detected:insertChild mounts=${toolbarActions.childRuntimeMountCountBefore}->${toolbarActions.childRuntimeMountCountAfter} mountReason=${toolbarActions.childRuntimeMountReason} fetchReason=${toolbarActions.childFetchSceneReason} activeNode=${toolbarActions.childCommandActiveNodeId} applyMode=${toolbarActions.childCommandApplyMode} runtimeError=${toolbarActions.childCommandRuntimeError} runtimeMessage=${toolbarActions.childCommandRuntimeMessage} localErrors=${toolbarActions.childCommandLocalApplyErrors}`, + ); + assert(toolbarActions.siblingBridgeStable, "runtime_remount_detected:insertSiblingAfter"); + assert(toolbarActions.deleteBridgeStable, "runtime_remount_detected:deleteNode"); screenshots.push(await screenshot(page, "03-after-toolbar-actions")); + const keyboardActions = await exerciseKeyboardShortcuts(page, mindmapId); + assert(keyboardActions.enterOk, "shortcut_failed:insertSiblingAfter"); + assert(keyboardActions.deleteOk, "shortcut_failed:deleteNode"); + assert( + keyboardActions.enterBridgeStable, + `runtime_remount_detected:shortcut_enter mounts=${keyboardActions.enterRuntimeMountCountBefore}->${keyboardActions.enterRuntimeMountCountAfter} mountReason=${keyboardActions.enterRuntimeMountReason} fetchReason=${keyboardActions.enterFetchSceneReason} activeNode=${keyboardActions.enterCommandActiveNodeId} applyMode=${keyboardActions.enterCommandApplyMode} runtimeError=${keyboardActions.enterCommandRuntimeError} runtimeMessage=${keyboardActions.enterCommandRuntimeMessage} localErrors=${keyboardActions.enterCommandLocalApplyErrors}`, + ); + assert(keyboardActions.deleteBridgeStable, "runtime_remount_detected:shortcut_delete"); + assert(keyboardActions.rootStillExists, "shortcut_failed:mindmap_root_deleted"); + screenshots.push(await screenshot(page, "03b-after-keyboard-actions")); + for (const [panelId, name] of [ ["nodeStyle", "sidebar-node-style"], ["baseStyle", "sidebar-base-style"], @@ -917,9 +1136,10 @@ async function main() { const reloadProjection = await fetchAdapterProjection(page, doc.documentId, mindmapId); assert(reloadProjection?.theme === "classic4", `reload_mismatch:theme actual=${JSON.stringify(reloadProjection?.theme)}`); assert(reloadProjection?.layout === "mindMap", `reload_mismatch:layout actual=${JSON.stringify(reloadProjection?.layout)}`); + const reloadNodeStyleFill = findNodeFillColorByUid(reloadProjection?.root, sidebarActions.nodeStyleTargetNodeId); assert( - reloadProjection?.root?.data?.fillColor === "#dbeafe", - `reload_mismatch:node_style actual=${JSON.stringify(reloadProjection?.root?.data)}`, + reloadNodeStyleFill === "#dbeafe", + `reload_mismatch:node_style active=${JSON.stringify(sidebarActions.nodeStyleTargetNodeId)} actual=${JSON.stringify(reloadProjection?.root?.data)}`, ); assert( reloadProjection?.compatPayload?.style?.map?.lineStyle === "curve", @@ -933,6 +1153,7 @@ async function main() { nodeCount: reloaded.nodeCount, edgeCount: reloaded.edgeCount, toolbarActions, + keyboardActions, sidebarActions, navigatorActions, contextMenuActions, diff --git a/scripts/task167-mindmap-kmind-parity-smoke.js b/scripts/task167-mindmap-kmind-parity-smoke.js new file mode 100644 index 00000000..11117e62 --- /dev/null +++ b/scripts/task167-mindmap-kmind-parity-smoke.js @@ -0,0 +1,1042 @@ +#!/usr/bin/env node +"use strict"; + +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { chromium } = require("playwright"); +const { + BASE_URL, + UI_TIMEOUT_MS, + assert, + cleanupDocuments, + createTempDocument, + ensureAuthenticated, + openDocument, + renameDocument, +} = require("./tree-shell-smoke-helpers"); + +const TASK = "task167-mindmap-kmind-parity-smoke"; +const OUTPUT_DIR = path.join(process.cwd(), "tmp", TASK); +const RESULT_PATH = path.join(OUTPUT_DIR, "result.json"); +const STAGE = process.argv.includes("--stage") ? process.argv[process.argv.indexOf("--stage") + 1] : "all"; + +async function writeResult(payload) { + await fs.mkdir(OUTPUT_DIR, { recursive: true }); + await fs.writeFile(RESULT_PATH, `${JSON.stringify({ ...payload, resultPath: RESULT_PATH }, null, 2)}\n`, "utf8"); +} + +async function screenshot(page, name) { + const file = path.join(OUTPUT_DIR, `${name}.png`); + await page.screenshot({ path: file, fullPage: true }); + return file; +} + +async function insertMindmapThroughSlash(page) { + const editor = page + .locator('[data-testid="mnote-leptos-tiptap-island-editor-root"] .editor-surface .ProseMirror[contenteditable="true"]') + .first(); + await editor.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await editor.click({ timeout: UI_TIMEOUT_MS }); + await page.keyboard.type("/"); + const item = page.getByTestId("slash-item-mindmap").first(); + await item.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await item.click({ timeout: UI_TIMEOUT_MS }); +} + +async function assertMindmapReady(page, stage) { + await page.locator('[data-testid="mnote-mindmap-editor-root"]').waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await page.locator('[data-testid="simple-mind-map-runtime"]').waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const runtime = document.querySelector('[data-testid="simple-mind-map-runtime"]'); + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = mindmapId ? registry[mindmapId] : null; + return ( + runtime instanceof HTMLElement && + runtime.dataset.runtimeEngine === "simple-mind-map" && + runtime.dataset.runtimeReady === "true" && + shell instanceof HTMLElement && + shell.dataset.uiShellSource === "leptos-rust-shell" && + Boolean(bridge) + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ).catch((error) => { + throw new Error(`mindmap_not_ready:${stage}:${error.message}`); + }); +} + +async function readMindmapIdentity(page) { + return page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + return { + mindmapId: root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null, + }; + }); +} + +async function readToolbarMetrics(page) { + return page.evaluate(() => { + const toolbar = document.querySelector('[data-testid="mindmap-schema-toolbar"]'); + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const mainCluster = document.querySelector('[data-testid="mindmap-schema-toolbar-cluster-main"]'); + const fileCluster = document.querySelector('[data-testid="mindmap-schema-toolbar-cluster-file"]'); + const moreButton = document.querySelector('[data-testid="mindmap-schema-toolbar-action-more"]'); + const moreMenu = document.querySelector('[data-testid="mindmap-schema-toolbar-more-menu"]'); + const buttons = Array.from(document.querySelectorAll('[data-testid^="mindmap-schema-toolbar-action-"]')).filter( + (node) => node instanceof HTMLElement && node.getBoundingClientRect().width > 0, + ); + const rect = toolbar instanceof HTMLElement ? toolbar.getBoundingClientRect() : null; + const topValues = buttons.map((node) => Math.round(node.getBoundingClientRect().top)); + return { + toolbarExists: toolbar instanceof HTMLElement, + shellExists: shell instanceof HTMLElement, + height: rect ? rect.height : 0, + width: rect ? rect.width : 0, + toolbarRows: new Set(topValues).size, + visibleActions: + shell instanceof HTMLElement && shell.dataset.toolbarVisibleActions + ? shell.dataset.toolbarVisibleActions.split(",").filter(Boolean) + : [], + overflowActions: + shell instanceof HTMLElement && shell.dataset.toolbarOverflowActions + ? shell.dataset.toolbarOverflowActions.split(",").filter(Boolean) + : [], + moreOpen: shell instanceof HTMLElement ? shell.dataset.toolbarMoreOpen === "true" : false, + mainCluster: mainCluster instanceof HTMLElement, + fileCluster: fileCluster instanceof HTMLElement, + moreButton: moreButton instanceof HTMLButtonElement, + moreMenu: moreMenu instanceof HTMLElement, + labels: buttons.map((node) => (node.textContent || "").trim()), + iconKeys: buttons.map((node) => (node instanceof HTMLElement ? node.dataset.iconKey || null : null)), + }; + }); +} + +async function verifyToolbarStage(page) { + await page.setViewportSize({ width: 1440, height: 960 }); + const desktopMetrics = await readToolbarMetrics(page); + assert(desktopMetrics.toolbarExists, "toolbar_missing"); + assert(desktopMetrics.shellExists, "rust_shell_missing"); + assert(desktopMetrics.mainCluster, "toolbar_main_cluster_missing"); + assert(desktopMetrics.fileCluster, "toolbar_file_cluster_missing"); + assert(desktopMetrics.height <= 72, `toolbar_height_too_large:${desktopMetrics.height}`); + assert(desktopMetrics.toolbarRows <= 1, `toolbar_not_single_row:${desktopMetrics.toolbarRows}`); + assert( + desktopMetrics.visibleActions.join(",").startsWith("undo,redo,editNode,insertSiblingAfter,deleteNode,insertChild"), + "toolbar_order_unexpected", + ); + assert(desktopMetrics.labels.every((label) => !/(palette|sliders|layout)/i.test(label)), "toolbar_internal_icon_key_visible"); + + await page.setViewportSize({ width: 900, height: 760 }); + await page.waitForTimeout(500); + const narrowMetrics = await readToolbarMetrics(page); + assert(narrowMetrics.height <= 72, `narrow_toolbar_height_too_large:${narrowMetrics.height}`); + assert(narrowMetrics.toolbarRows <= 1, `narrow_toolbar_not_single_row:${narrowMetrics.toolbarRows}`); + assert(narrowMetrics.overflowActions.length > 0, "narrow_toolbar_overflow_missing"); + assert(narrowMetrics.moreButton, "toolbar_more_button_missing"); + await page.getByTestId("mindmap-schema-toolbar-action-more").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const menu = document.querySelector('[data-testid="mindmap-schema-toolbar-more-menu"]'); + return shell instanceof HTMLElement && shell.dataset.toolbarMoreOpen === "true" && menu instanceof HTMLElement; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const menuMetrics = await readToolbarMetrics(page); + assert(menuMetrics.moreOpen, "toolbar_more_not_open"); + assert(menuMetrics.moreMenu, "toolbar_more_menu_missing"); + await page.keyboard.press("Escape"); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const menu = document.querySelector('[data-testid="mindmap-schema-toolbar-more-menu"]'); + return shell instanceof HTMLElement && shell.dataset.toolbarMoreOpen === "false" && !(menu instanceof HTMLElement); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const closedMetrics = await readToolbarMetrics(page); + assert(!closedMetrics.moreOpen, "toolbar_more_escape_not_closed"); + return { + desktop: desktopMetrics, + narrow: narrowMetrics, + menu: menuMetrics, + closed: closedMetrics, + }; +} + +async function verifyFullscreenStage(page) { + await page.setViewportSize({ width: 1440, height: 960 }); + await page.waitForTimeout(200); + const before = await readToolbarMetrics(page); + assert(before.toolbarExists, "toolbar_missing_before_fullscreen"); + const root = page.getByTestId("mnote-mindmap-editor-root"); + const rootBox = await root.boundingBox(); + assert(rootBox && rootBox.width > 0 && rootBox.height > 0, "fullscreen_root_box_missing"); + const fullscreenButton = page.getByTestId("mindmap-schema-navigator-action-fullscreenCanvas"); + await fullscreenButton.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await fullscreenButton.click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return ( + root instanceof HTMLElement && + shell instanceof HTMLElement && + scene instanceof HTMLElement && + (document.fullscreenElement === root || root.contains(document.fullscreenElement)) && + shell.dataset.fullscreenActive === "true" && + scene.dataset.fullscreenActive === "true" + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + await page.waitForFunction( + () => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return scene instanceof HTMLElement && scene.dataset.fullscreenResizeStatus === "success"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const active = await page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const toolbar = document.querySelector('[data-testid="mindmap-schema-toolbar"]'); + const sidebar = document.querySelector('[data-testid="mindmap-schema-sidebar"]'); + const navigator = document.querySelector('[data-testid="mindmap-schema-navigator"]'); + return { + fullscreenElementIsRoot: root instanceof HTMLElement && document.fullscreenElement === root, + fullscreenElementInsideRoot: + root instanceof HTMLElement && Boolean(document.fullscreenElement) && root.contains(document.fullscreenElement), + shellFullscreenActive: shell instanceof HTMLElement ? shell.dataset.fullscreenActive === "true" : false, + toolbarVisible: toolbar instanceof HTMLElement && toolbar.getBoundingClientRect().height > 0, + sidebarVisible: sidebar instanceof HTMLElement && sidebar.getBoundingClientRect().height > 0, + navigatorVisible: navigator instanceof HTMLElement && navigator.getBoundingClientRect().height > 0, + }; + }); + assert(active.fullscreenElementIsRoot || active.fullscreenElementInsideRoot, "fullscreen_element_unexpected"); + assert(active.shellFullscreenActive, "fullscreen_shell_state_missing"); + assert(active.toolbarVisible && active.sidebarVisible && active.navigatorVisible, "fullscreen_chrome_not_visible"); + await page.keyboard.press("Escape"); + await page.waitForFunction(() => document.fullscreenElement === null, null, { timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.fullscreenActive === "false"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const after = await page.evaluate(() => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return { + fullscreenElement: document.fullscreenElement === null, + shellFullscreenActive: shell instanceof HTMLElement ? shell.dataset.fullscreenActive === "true" : null, + chromeVisibility: shell instanceof HTMLElement ? shell.dataset.chromeVisibility || null : null, + }; + }); + assert(after.fullscreenElement, "fullscreen_escape_exit_failed"); + assert(after.shellFullscreenActive === false, "fullscreen_shell_state_not_restored"); + assert(after.chromeVisibility === "visible", `fullscreen_visible_state_not_restored:${after.chromeVisibility}`); + + await page.mouse.move(rootBox.x + rootBox.width / 2, rootBox.y + rootBox.height / 2); + await page.mouse.move(Math.max(4, rootBox.x - 24), Math.max(4, rootBox.y - 24)); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.chromeVisibility === "hiddenByPointerLeave"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + await page.evaluate(async () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + if (root instanceof HTMLElement && typeof root.requestFullscreen === "function") { + await root.requestFullscreen(); + } + }); + await page.waitForFunction( + () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + return root instanceof HTMLElement && document.fullscreenElement === root; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + await page.evaluate(async () => { + if (document.fullscreenElement) { + await document.exitFullscreen(); + } + }); + await page.waitForFunction(() => document.fullscreenElement === null, null, { timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.fullscreenActive === "false"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const hiddenAfterExit = await page.evaluate(() => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return { + chromeVisibility: shell instanceof HTMLElement ? shell.dataset.chromeVisibility || null : null, + shellFullscreenActive: shell instanceof HTMLElement ? shell.dataset.fullscreenActive === "true" : null, + }; + }); + assert(hiddenAfterExit.shellFullscreenActive === false, "fullscreen_hidden_shell_state_not_restored"); + assert( + hiddenAfterExit.chromeVisibility === "hiddenByPointerLeave", + `fullscreen_hidden_state_unexpected:${hiddenAfterExit.chromeVisibility}`, + ); + return { before, active, after, hiddenAfterExit }; +} + +async function readChromeVisibilityMetrics(page) { + return page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const toolbar = document.querySelector('[data-testid="mindmap-schema-toolbar"]'); + const sidebar = document.querySelector('[data-testid="mindmap-schema-sidebar"]'); + const navigator = document.querySelector('[data-testid="mindmap-schema-navigator"]'); + const minimap = document.querySelector('[data-testid="mindmap-schema-minimap"]'); + return { + rootBox: root instanceof HTMLElement ? root.getBoundingClientRect().toJSON?.() ?? null : null, + sceneChromeVisibility: scene instanceof HTMLElement ? scene.dataset.chromeVisibility || null : null, + shellChromeVisibility: shell instanceof HTMLElement ? shell.dataset.chromeVisibility || null : null, + toolbarVisible: toolbar instanceof HTMLElement && toolbar.getBoundingClientRect().height > 0, + sidebarVisible: sidebar instanceof HTMLElement && sidebar.getBoundingClientRect().height > 0, + navigatorVisible: navigator instanceof HTMLElement && navigator.getBoundingClientRect().height > 0, + minimapVisible: minimap instanceof HTMLElement && minimap.getBoundingClientRect().height > 0, + }; + }); +} + +async function verifyChromeHideStage(page) { + const root = page.getByTestId("mnote-mindmap-editor-root"); + await root.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + const box = await root.boundingBox(); + assert(box && box.width > 0 && box.height > 0, "mindmap_root_box_missing"); + + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.chromeVisibility === "visible"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const before = await readChromeVisibilityMetrics(page); + assert(before.toolbarVisible && before.sidebarVisible && before.navigatorVisible, "chrome_not_visible_before_leave"); + + await page.mouse.move(Math.max(4, box.x - 24), Math.max(4, box.y - 24)); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.chromeVisibility === "hiddenByPointerLeave"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const hidden = await readChromeVisibilityMetrics(page); + assert(!hidden.toolbarVisible && !hidden.sidebarVisible && !hidden.navigatorVisible, "chrome_not_hidden_after_leave"); + + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + await page.waitForTimeout(300); + const afterEnter = await readChromeVisibilityMetrics(page); + assert(afterEnter.shellChromeVisibility === "hiddenByPointerLeave", "chrome_restored_by_pointer_enter"); + + await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.chromeVisibility === "visible"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const restored = await readChromeVisibilityMetrics(page); + assert(restored.toolbarVisible && restored.sidebarVisible && restored.navigatorVisible, "chrome_not_restored_after_click"); + return { before, hidden, afterEnter, restored }; +} + +async function readContextMenuMetrics(page) { + return page.evaluate(() => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const menu = document.querySelector('[data-testid="mindmap-schema-context-menu"]'); + const buttons = Array.from( + document.querySelectorAll('[data-testid^="mindmap-schema-context-menu-action-"]'), + ).filter((node) => node instanceof HTMLButtonElement); + return { + chromeVisibility: shell instanceof HTMLElement ? shell.dataset.chromeVisibility || null : null, + contextMenuKind: scene instanceof HTMLElement ? scene.dataset.contextMenuKind || null : null, + menuVisible: menu instanceof HTMLElement && menu.getBoundingClientRect().width > 0, + itemIds: buttons.map((button) => button.dataset.mindmapContextActionId || null), + disabledIds: buttons + .filter((button) => button.disabled || button.dataset.disabled === "true") + .map((button) => button.dataset.mindmapContextActionId || null), + }; + }); +} + +async function findCanvasEmptyPoint(page) { + const point = await page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + if (!(root instanceof HTMLElement)) return null; + const rootRect = root.getBoundingClientRect(); + const blockers = Array.from( + document.querySelectorAll( + '.smm-node,[data-testid="mindmap-schema-toolbar"],[data-testid="mindmap-schema-sidebar"],[data-testid="mindmap-schema-navigator"],[data-testid="mindmap-schema-context-menu"]', + ), + ) + .filter((node) => node instanceof HTMLElement) + .map((node) => node.getBoundingClientRect()) + .filter((rect) => rect.width > 0 && rect.height > 0); + const padding = 36; + for (let y = rootRect.top + padding; y < rootRect.bottom - padding; y += 24) { + for (let x = rootRect.left + padding; x < rootRect.right - padding; x += 24) { + const blocked = blockers.some((rect) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom); + if (!blocked) return { x, y }; + } + } + return { + x: rootRect.left + rootRect.width * 0.5, + y: rootRect.top + rootRect.height * 0.75, + }; + }); + assert(point && typeof point.x === "number" && typeof point.y === "number", "context_menu_canvas_point_missing"); + return point; +} + +async function verifyContextMenuStage(page) { + const rootNode = page.locator(".smm-node").first(); + await rootNode.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await rootNode.click({ button: "right", timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const menu = document.querySelector('[data-testid="mindmap-schema-context-menu"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return ( + menu instanceof HTMLElement && + scene instanceof HTMLElement && + scene.dataset.contextMenuKind === "node" + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const nodeMenu = await readContextMenuMetrics(page); + assert(nodeMenu.menuVisible, "node_context_menu_not_visible"); + assert(nodeMenu.contextMenuKind === "node", `node_context_menu_kind_unexpected:${nodeMenu.contextMenuKind}`); + assert( + nodeMenu.itemIds.join(",") === "insertChild,insertSiblingAfter,deleteNode,summary,associativeLine,expandCollapse,copyNodeText", + `node_context_menu_items_unexpected:${nodeMenu.itemIds.join(",")}`, + ); + assert(nodeMenu.disabledIds.includes("deleteNode"), `root_delete_not_disabled:${nodeMenu.disabledIds.join(",")}`); + + const rootBox = await page.getByTestId("mnote-mindmap-editor-root").boundingBox(); + assert(rootBox && rootBox.width > 0 && rootBox.height > 0, "context_menu_root_box_missing"); + await page.mouse.move(Math.max(4, rootBox.x - 24), Math.max(4, rootBox.y - 24)); + await page.waitForTimeout(250); + const afterLeave = await readContextMenuMetrics(page); + assert(afterLeave.menuVisible, "context_menu_closed_after_pointerleave"); + assert(afterLeave.chromeVisibility === "visible", `chrome_hidden_while_context_menu_open:${afterLeave.chromeVisibility}`); + + await page.keyboard.press("Escape"); + await page.waitForFunction( + () => !(document.querySelector('[data-testid="mindmap-schema-context-menu"]') instanceof HTMLElement), + null, + { timeout: UI_TIMEOUT_MS }, + ); + const afterEscape = await readContextMenuMetrics(page); + assert(!afterEscape.menuVisible, "context_menu_escape_not_closed"); + + const point = await findCanvasEmptyPoint(page); + await page.mouse.click(point.x, point.y, { button: "right" }); + await page.waitForFunction( + () => { + const menu = document.querySelector('[data-testid="mindmap-schema-context-menu"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return ( + menu instanceof HTMLElement && + scene instanceof HTMLElement && + scene.dataset.contextMenuKind === "canvas" + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const canvasMenu = await readContextMenuMetrics(page); + assert(canvasMenu.contextMenuKind === "canvas", `canvas_context_menu_kind_unexpected:${canvasMenu.contextMenuKind}`); + assert( + canvasMenu.itemIds.join(",") === "centerRoot,fitView,search,readonly,showMenu", + `canvas_context_menu_items_unexpected:${canvasMenu.itemIds.join(",")}`, + ); + assert(!canvasMenu.itemIds.includes("insertChild"), "canvas_context_menu_contains_insert_child"); + assert(!canvasMenu.itemIds.includes("deleteNode"), "canvas_context_menu_contains_delete_node"); + + return { nodeMenu, afterLeave, afterEscape, canvasMenu }; +} + +async function readThemeMetrics(page) { + return page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const runtime = document.querySelector('[data-testid="simple-mind-map-runtime"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = mindmapId ? registry[mindmapId] : null; + const instance = bridge?.instance || null; + const themeConfig = typeof instance?.getThemeConfig === "function" ? instance.getThemeConfig() : null; + const nodeRects = Array.from(document.querySelectorAll(".smm-node")) + .filter((node) => node instanceof Element) + .map((node) => node.getBoundingClientRect()) + .filter((rect) => rect.width > 0 && rect.height > 0) + .map((rect) => ({ + left: rect.left, + top: rect.top, + right: rect.right, + bottom: rect.bottom, + width: rect.width, + height: rect.height, + })); + const paths = Array.from(runtime?.querySelectorAll?.("svg path") || []).filter( + (node) => node instanceof SVGPathElement && node.getBoundingClientRect().width + node.getBoundingClientRect().height > 0, + ); + let overlaps = 0; + for (let i = 0; i < nodeRects.length; i += 1) { + for (let j = i + 1; j < nodeRects.length; j += 1) { + const a = nodeRects[i]; + const b = nodeRects[j]; + const width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)); + const height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top)); + if (width * height > 4) overlaps += 1; + } + } + return { + layout: typeof instance?.getLayout === "function" ? instance.getLayout() : null, + theme: typeof instance?.getTheme === "function" ? instance.getTheme() : null, + themeConfig, + nodeCount: nodeRects.length, + pathCount: paths.length, + overlaps, + }; + }); +} + +async function verifyThemeStage(page) { + const initial = await readThemeMetrics(page); + assert(initial.layout === "logicalStructure", `theme_layout_unexpected:${initial.layout}`); + assert(initial.theme === "default", `theme_template_unexpected:${initial.theme}`); + assert(initial.themeConfig?.root?.fillColor === "#e25563", `theme_root_fill_unexpected:${initial.themeConfig?.root?.fillColor}`); + assert(initial.themeConfig?.root?.color === "#ffffff", `theme_root_color_unexpected:${initial.themeConfig?.root?.color}`); + assert(initial.themeConfig?.second?.fillColor === "#4f7df3", `theme_second_fill_unexpected:${initial.themeConfig?.second?.fillColor}`); + assert(initial.themeConfig?.second?.color === "#ffffff", `theme_second_color_unexpected:${initial.themeConfig?.second?.color}`); + assert(initial.themeConfig?.node?.color === "#315aa9", `theme_node_color_unexpected:${initial.themeConfig?.node?.color}`); + assert( + initial.themeConfig?.generalizationLineColor === "#ef6a5b", + `theme_generalization_line_unexpected:${initial.themeConfig?.generalizationLineColor}`, + ); + assert(initial.themeConfig?.lineStyle === "curve", `theme_line_style_unexpected:${initial.themeConfig?.lineStyle}`); + assert(initial.nodeCount >= 2, `theme_node_count_too_small:${initial.nodeCount}`); + assert(initial.pathCount > 0, `theme_path_count_empty:${initial.pathCount}`); + assert(initial.overlaps === 0, `theme_nodes_overlap:${initial.overlaps}`); + + return { initial }; +} + +async function readSidebarMetrics(page) { + return page.evaluate(() => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const rail = document.querySelector('[data-testid="mindmap-schema-sidebar-rail"]'); + const drawer = document.querySelector('[data-testid="mindmap-schema-sidebar-drawer"]'); + const title = document.querySelector('[data-testid="mindmap-schema-sidebar-title"]'); + const closeButton = document.querySelector('[data-testid="mindmap-schema-sidebar-close"]'); + const hideHandle = document.querySelector('[data-testid="mindmap-schema-sidebar-hide-handle"]'); + const restoreHandle = document.querySelector('[data-testid="mindmap-schema-sidebar-restore-handle"]'); + const structureCards = Array.from( + document.querySelectorAll('[data-testid^="mindmap-schema-sidebar-option-layout-"][data-control-type="layoutCard"]'), + ); + return { + triggerVisible: shell instanceof HTMLElement ? shell.dataset.sidebarTriggerVisible === "true" : null, + panelOpen: shell instanceof HTMLElement ? shell.dataset.sidebarPanelOpen === "true" : null, + railVisible: rail instanceof HTMLElement && rail.getBoundingClientRect().height > 0, + drawerVisible: drawer instanceof HTMLElement && drawer.getBoundingClientRect().width > 0, + drawerWidth: drawer instanceof HTMLElement ? Math.round(drawer.getBoundingClientRect().width) : 0, + title: title instanceof HTMLElement ? (title.textContent || "").trim() : "", + closeButton: closeButton instanceof HTMLButtonElement, + hideHandle: hideHandle instanceof HTMLButtonElement, + restoreHandle: restoreHandle instanceof HTMLButtonElement, + structureCardCount: structureCards.length, + }; + }); +} + +async function verifySidebarStage(page) { + const structureTab = page.getByTestId("mindmap-schema-sidebar-tab-structure"); + await structureTab.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await structureTab.click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const title = document.querySelector('[data-testid="mindmap-schema-sidebar-title"]'); + return ( + shell instanceof HTMLElement && + shell.dataset.sidebarPanelOpen === "true" && + shell.dataset.sidebarActivePanel === "structure" && + title instanceof HTMLElement && + (title.textContent || "").trim() === "结构" + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const opened = await readSidebarMetrics(page); + assert(opened.railVisible, "sidebar_rail_missing"); + assert(opened.drawerVisible, "sidebar_drawer_not_visible"); + assert(opened.drawerWidth >= 280, `sidebar_drawer_width_too_small:${opened.drawerWidth}`); + assert(opened.title === "结构", `sidebar_title_unexpected:${opened.title}`); + assert(opened.structureCardCount >= 6, `sidebar_structure_cards_missing:${opened.structureCardCount}`); + assert(opened.closeButton, "sidebar_close_button_missing"); + assert(opened.hideHandle, "sidebar_hide_handle_missing"); + + await page.getByTestId("mindmap-schema-sidebar-close").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const drawer = document.querySelector('[data-testid="mindmap-schema-sidebar-drawer"]'); + return shell instanceof HTMLElement && shell.dataset.sidebarPanelOpen === "false" && !(drawer instanceof HTMLElement); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const closed = await readSidebarMetrics(page); + assert(closed.panelOpen === false, "sidebar_close_not_applied"); + + await structureTab.click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.sidebarPanelOpen === "true"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + await page.getByTestId("mindmap-schema-sidebar-hide-handle").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const restoreHandle = document.querySelector('[data-testid="mindmap-schema-sidebar-restore-handle"]'); + return ( + shell instanceof HTMLElement && + shell.dataset.sidebarTriggerVisible === "false" && + shell.dataset.sidebarPanelOpen === "false" && + restoreHandle instanceof HTMLButtonElement + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const hidden = await readSidebarMetrics(page); + assert(hidden.restoreHandle, "sidebar_restore_handle_missing"); + assert(hidden.triggerVisible === false, "sidebar_trigger_not_hidden"); + + await page.getByTestId("mindmap-schema-sidebar-restore-handle").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const title = document.querySelector('[data-testid="mindmap-schema-sidebar-title"]'); + return ( + shell instanceof HTMLElement && + shell.dataset.sidebarTriggerVisible === "true" && + shell.dataset.sidebarPanelOpen === "true" && + title instanceof HTMLElement && + (title.textContent || "").trim() === "结构" + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const restored = await readSidebarMetrics(page); + assert(restored.drawerVisible, "sidebar_drawer_not_restored"); + return { opened, closed, hidden, restored }; +} + +async function readRuntimeMindmapState(page) { + return page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = mindmapId ? registry[mindmapId] : null; + const instance = bridge?.instance || null; + const snapshot = bridge?.getSnapshot?.() || null; + const data = snapshot && typeof snapshot === "object" && !Array.isArray(snapshot) ? snapshot.data || null : null; + return { + mindmapId, + layout: typeof instance?.getLayout === "function" ? instance.getLayout() : null, + theme: typeof instance?.getTheme === "function" ? instance.getTheme() : null, + rootFillColor: data && typeof data === "object" ? data.fillColor || null : null, + commandStatus: + document.querySelector('[data-testid="leptos-mindmap-island"]') instanceof HTMLElement + ? document.querySelector('[data-testid="leptos-mindmap-island"]').dataset.commandStatus || null + : null, + }; + }); +} + +async function readPersistedMindmapState(page) { + return page.evaluate(async () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const match = window.location.pathname.match(/\/documents\/([^/?#]+)/); + const documentId = match?.[1] ? decodeURIComponent(match[1]) : null; + if (!documentId || !mindmapId) { + return { + documentId, + mindmapId, + status: null, + layout: null, + theme: null, + rootFillColor: null, + }; + } + const response = await fetch( + `/api/mindmap/${encodeURIComponent(documentId)}/${encodeURIComponent(mindmapId)}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get`, + { headers: { Accept: "application/json" } }, + ); + const payload = await response.json().catch(() => null); + const rootData = + payload && typeof payload === "object" && payload.root && typeof payload.root === "object" && !Array.isArray(payload.root) + ? payload.root.data || null + : null; + return { + documentId, + mindmapId, + status: response.status, + layout: payload && typeof payload === "object" ? payload.layout || null : null, + theme: payload && typeof payload === "object" ? payload.theme || null : null, + rootFillColor: rootData && typeof rootData === "object" ? rootData.fillColor || null : null, + }; + }); +} + +async function waitForMindmapCommandSuccess(page, actionId, predicate) { + try { + await page.waitForFunction( + ({ actionId }) => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return ( + scene instanceof HTMLElement && + scene.dataset.lastSchemaAction === actionId && + scene.dataset.commandStatus === "success" + ); + }, + { actionId }, + { timeout: UI_TIMEOUT_MS }, + ); + } catch (error) { + const debug = await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const errorNode = document.querySelector('[data-testid="leptos-mindmap-error"]'); + return { + commandStatus: scene instanceof HTMLElement ? scene.dataset.commandStatus || null : null, + lastSchemaAction: scene instanceof HTMLElement ? scene.dataset.lastSchemaAction || null : null, + commandFailedAction: scene instanceof HTMLElement ? scene.dataset.commandFailedAction || null : null, + commandFailedMessage: scene instanceof HTMLElement ? scene.dataset.commandFailedMessage || null : null, + errorText: errorNode instanceof HTMLElement ? (errorNode.textContent || "").trim() : null, + }; + }); + throw new Error( + `mindmap_command_not_success:${actionId}:${JSON.stringify(debug)}:${error instanceof Error ? error.message : String(error)}`, + ); + } + if (predicate) { + await page.waitForFunction(predicate, null, { timeout: UI_TIMEOUT_MS }); + } +} + +async function verifySidebarActionsStage(page) { + await page.getByTestId("mindmap-schema-sidebar-tab-structure").click({ timeout: UI_TIMEOUT_MS }); + await page.getByTestId("mindmap-schema-sidebar-option-layout-mind-map").click({ timeout: UI_TIMEOUT_MS }); + await waitForMindmapCommandSuccess( + page, + "setLayout", + () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = mindmapId ? registry[mindmapId] : null; + return bridge?.instance?.getLayout?.() === "mindMap"; + }, + ); + + await page.getByTestId("mindmap-schema-sidebar-tab-theme").click({ timeout: UI_TIMEOUT_MS }); + await page.getByTestId("mindmap-schema-sidebar-option-theme-dark").click({ timeout: UI_TIMEOUT_MS }); + await waitForMindmapCommandSuccess(page, "setTheme"); + + await page.getByTestId("mindmap-schema-sidebar-tab-nodeStyle").click({ timeout: UI_TIMEOUT_MS }); + await page.getByTestId("mindmap-schema-sidebar-option-node-fill-blue").click({ timeout: UI_TIMEOUT_MS }); + await waitForMindmapCommandSuccess(page, "painter"); + + const beforeReload = await readPersistedMindmapState(page); + assert(beforeReload.layout === "mindMap", `sidebar_actions_layout_before_reload:${beforeReload.layout}`); + assert(beforeReload.theme === "dark", `sidebar_actions_theme_before_reload:${beforeReload.theme}`); + assert(beforeReload.rootFillColor === "#dbeafe", `sidebar_actions_fill_before_reload:${beforeReload.rootFillColor}`); + + await page.reload({ waitUntil: "domcontentloaded" }); + await assertMindmapReady(page, "sidebar-actions-reload"); + const afterReload = await readPersistedMindmapState(page); + assert(afterReload.layout === "mindMap", `sidebar_actions_layout_after_reload:${afterReload.layout}`); + assert(afterReload.theme === "dark", `sidebar_actions_theme_after_reload:${afterReload.theme}`); + assert(afterReload.rootFillColor === "#dbeafe", `sidebar_actions_fill_after_reload:${afterReload.rootFillColor}`); + + return { beforeReload, afterReload }; +} + +async function readNavigatorMetrics(page) { + return page.evaluate(() => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const navigator = document.querySelector('[data-testid="mindmap-schema-navigator"]'); + const searchInput = document.querySelector('[data-testid="mindmap-schema-navigator-search"]'); + const minimap = document.querySelector('[data-testid="mindmap-schema-minimap"]'); + const readonlyButton = document.querySelector('[data-testid="mindmap-schema-navigator-action-readonly"]'); + const zoomInput = document.querySelector('[data-testid="mindmap-schema-navigator-zoom-input"]'); + return { + navigatorVisible: navigator instanceof HTMLElement && navigator.getBoundingClientRect().height > 0, + searchOpen: shell instanceof HTMLElement ? shell.dataset.navigatorSearchOpen === "true" : false, + minimapOpen: shell instanceof HTMLElement ? shell.dataset.navigatorMinimapOpen === "true" : false, + readonly: shell instanceof HTMLElement ? shell.dataset.navigatorReadonly === "true" : false, + searchInputVisible: searchInput instanceof HTMLInputElement && searchInput.getBoundingClientRect().width > 0, + minimapVisible: minimap instanceof HTMLElement && minimap.getBoundingClientRect().height > 0, + readonlyActive: readonlyButton instanceof HTMLButtonElement ? readonlyButton.dataset.active === "true" : false, + zoomValue: zoomInput instanceof HTMLInputElement ? zoomInput.value : null, + }; + }); +} + +async function verifyNavigatorStage(page, screenshots) { + const initial = await readNavigatorMetrics(page); + assert(initial.navigatorVisible, "navigator_missing"); + assert(!initial.searchInputVisible, "navigator_search_should_be_collapsed"); + screenshots.push(await screenshot(page, "07-navigator-icons")); + + await page.getByTestId("mindmap-schema-navigator-action-search").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const input = document.querySelector('[data-testid="mindmap-schema-navigator-search"]'); + return shell instanceof HTMLElement && shell.dataset.navigatorSearchOpen === "true" && input instanceof HTMLInputElement; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + const searchInput = page.getByTestId("mindmap-schema-navigator-search"); + await searchInput.fill("主题", { timeout: UI_TIMEOUT_MS }); + screenshots.push(await screenshot(page, "08-search-expanded")); + await searchInput.press("Escape"); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const input = document.querySelector('[data-testid="mindmap-schema-navigator-search"]'); + return shell instanceof HTMLElement && shell.dataset.navigatorSearchOpen === "false" && !(input instanceof HTMLInputElement); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + + await page.getByTestId("mindmap-schema-navigator-action-minimap").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + const minimap = document.querySelector('[data-testid="mindmap-schema-minimap"]'); + return shell instanceof HTMLElement && shell.dataset.navigatorMinimapOpen === "true" && minimap instanceof HTMLElement; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + + await page.getByTestId("mindmap-schema-navigator-action-readonly").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.navigatorReadonly === "true"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + + const zoomInputField = page.getByTestId("mindmap-schema-navigator-zoom-input"); + const previousZoom = await zoomInputField.inputValue(); + await zoomInputField.fill("abc", { timeout: UI_TIMEOUT_MS }); + await zoomInputField.press("Enter"); + await page.waitForTimeout(200); + const afterInvalidZoom = await zoomInputField.inputValue(); + assert(afterInvalidZoom === previousZoom, `navigator_zoom_invalid_not_restored:${afterInvalidZoom}`); + + const final = await readNavigatorMetrics(page); + assert(final.minimapVisible, "navigator_minimap_not_visible"); + assert(final.readonlyActive, "navigator_readonly_not_active"); + return { initial, final }; +} + +async function restoreNavigatorDefaultState(page) { + const current = await readNavigatorMetrics(page); + if (current.minimapOpen) { + await page.getByTestId("mindmap-schema-navigator-action-minimap").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.navigatorMinimapOpen === "false"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + } + if (current.readonly) { + await page.getByTestId("mindmap-schema-navigator-action-readonly").click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction( + () => { + const shell = document.querySelector('[data-testid="mindmap-rust-shell"]'); + return shell instanceof HTMLElement && shell.dataset.navigatorReadonly === "false"; + }, + null, + { timeout: UI_TIMEOUT_MS }, + ); + } +} + +async function restoreCanvasIdleState(page) { + await page.keyboard.press("Escape").catch(() => undefined); + const root = page.getByTestId("mnote-mindmap-editor-root"); + const box = await root.boundingBox(); + if (box && box.width > 0 && box.height > 0) { + await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2); + } + await page.waitForTimeout(200); +} + +async function main() { + if (!["all", "toolbar", "fullscreen", "chrome-hide", "sidebar", "sidebar-actions", "navigator", "context-menu", "theme"].includes(STAGE)) { + throw new Error(`当前 smoke 只实现 --stage all/toolbar/fullscreen/chrome-hide/sidebar/sidebar-actions/navigator/context-menu/theme,收到:${STAGE}`); + } + await fs.mkdir(OUTPUT_DIR, { recursive: true }); + + const browser = await chromium.launch({ headless: true }); + const context = await browser.newContext({ viewport: { width: 1440, height: 960 }, locale: "zh-CN" }); + const page = await context.newPage(); + const screenshots = []; + const createdIds = []; + const result = { + ok: false, + task: TASK, + stage: STAGE, + baseUrl: BASE_URL, + documentId: null, + mindmapId: null, + toolbar: null, + screenshots, + }; + + try { + await ensureAuthenticated(page, context.request); + const doc = await createTempDocument(context.request, null); + createdIds.push(doc.documentId); + const title = `task167-mindmap-${Date.now().toString().slice(-6)}`; + await renameDocument(context.request, doc.workspaceId, doc.documentId, title); + result.documentId = doc.documentId; + + await openDocument(page, doc.workspaceId, doc.documentId); + await insertMindmapThroughSlash(page); + await assertMindmapReady(page, STAGE); + result.mindmapId = (await readMindmapIdentity(page)).mindmapId; + if (STAGE === "all") { + result.toolbar = await verifyToolbarStage(page); + screenshots.push(await screenshot(page, "01-toolbar-single-row")); + result.fullscreen = await verifyFullscreenStage(page); + screenshots.push(await screenshot(page, "02-fullscreen-canvas")); + await restoreCanvasIdleState(page); + result.chromeHide = await verifyChromeHideStage(page); + screenshots.push(await screenshot(page, "03-chrome-hidden-after-leave")); + screenshots.push(await screenshot(page, "04-chrome-restored-after-click")); + result.sidebar = await verifySidebarStage(page); + screenshots.push(await screenshot(page, "05-sidebar-structure-drawer")); + await page.getByTestId("mindmap-schema-sidebar-hide-handle").click({ timeout: UI_TIMEOUT_MS }).catch(() => undefined); + await page.waitForTimeout(200); + screenshots.push(await screenshot(page, "06-sidebar-hidden-handle")); + await page.getByTestId("mindmap-schema-sidebar-restore-handle").click({ timeout: UI_TIMEOUT_MS }).catch(() => undefined); + await page.waitForTimeout(200); + await page.getByTestId("mindmap-schema-sidebar-close").click({ timeout: UI_TIMEOUT_MS }).catch(() => undefined); + await page.waitForTimeout(200); + result.navigator = await verifyNavigatorStage(page, screenshots); + await restoreNavigatorDefaultState(page); + result.contextMenu = await verifyContextMenuStage(page); + screenshots.push(await screenshot(page, "09-node-context-menu")); + await restoreCanvasIdleState(page); + result.theme = await verifyThemeStage(page); + screenshots.push(await screenshot(page, "10-kmind-theme-baseline")); + result.sidebarActions = await verifySidebarActionsStage(page); + result.toolbarRows = result.toolbar?.desktop?.toolbarRows ?? null; + result.fullscreenOk = Boolean(result.fullscreen); + result.chromeHideOk = Boolean(result.chromeHide); + result.sidebarDrawerOk = Boolean(result.sidebar); + result.navigatorOk = Boolean(result.navigator); + result.contextMenuOk = Boolean(result.contextMenu); + result.themeOk = Boolean(result.theme); + result.reloadOk = Boolean(result.sidebarActions); + } else if (STAGE === "toolbar") { + result.toolbar = await verifyToolbarStage(page); + screenshots.push(await screenshot(page, "01-toolbar-single-row")); + } else if (STAGE === "fullscreen") { + result.fullscreen = await verifyFullscreenStage(page); + screenshots.push(await screenshot(page, "02-fullscreen-canvas")); + } else if (STAGE === "chrome-hide") { + result.chromeHide = await verifyChromeHideStage(page); + screenshots.push(await screenshot(page, "03-chrome-hidden-after-leave")); + screenshots.push(await screenshot(page, "04-chrome-restored-after-click")); + } else if (STAGE === "sidebar") { + result.sidebar = await verifySidebarStage(page); + screenshots.push(await screenshot(page, "05-sidebar-structure-drawer")); + await page.getByTestId("mindmap-schema-sidebar-hide-handle").click({ timeout: UI_TIMEOUT_MS }).catch(() => undefined); + await page.waitForTimeout(200); + screenshots.push(await screenshot(page, "06-sidebar-hidden-handle")); + } else if (STAGE === "sidebar-actions") { + result.sidebarActions = await verifySidebarActionsStage(page); + } else if (STAGE === "navigator") { + result.navigator = await verifyNavigatorStage(page, screenshots); + } else if (STAGE === "context-menu") { + result.contextMenu = await verifyContextMenuStage(page); + screenshots.push(await screenshot(page, "09-node-context-menu")); + } else if (STAGE === "theme") { + result.theme = await verifyThemeStage(page); + screenshots.push(await screenshot(page, "10-kmind-theme-baseline")); + } + + result.ok = true; + await writeResult(result); + } catch (error) { + result.error = error instanceof Error ? error.stack || error.message : String(error); + screenshots.push(await screenshot(page, "99-failure").catch(() => null)); + await writeResult(result); + throw error; + } finally { + await cleanupDocuments(context.request, createdIds).catch(() => undefined); + await browser.close(); + } +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/scripts/task168-mindmap-put-validator-smoke.js b/scripts/task168-mindmap-put-validator-smoke.js new file mode 100644 index 00000000..10d743bf --- /dev/null +++ b/scripts/task168-mindmap-put-validator-smoke.js @@ -0,0 +1,414 @@ +#!/usr/bin/env node +"use strict"; + +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { chromium } = require("playwright"); +const { + BASE_URL, + UI_TIMEOUT_MS, + assert, + cleanupDocuments, + createTempDocument, + ensureAuthenticated, + openDocument, + renameDocument, +} = require("./tree-shell-smoke-helpers"); + +const TASK = "task168-mindmap-put-validator-smoke"; +const OUTPUT_DIR = path.join(process.cwd(), "tmp", TASK); +const RESULT_PATH = path.join(OUTPUT_DIR, "result.json"); +const BAD_TEXT_PATTERN = /ArgumentValidationError|domainEventHint|domainEventPlan|streamDeltaHint|command_failed|502 Bad Gateway/i; + +async function writeResult(payload) { + await fs.mkdir(OUTPUT_DIR, { recursive: true }); + await fs.writeFile(RESULT_PATH, `${JSON.stringify({ ...payload, resultPath: RESULT_PATH }, null, 2)}\n`, "utf8"); +} + +async function screenshot(page, name) { + const file = path.join(OUTPUT_DIR, `${name}.png`); + await page.screenshot({ path: file, fullPage: true }); + return file; +} + +function attachMindmapNetworkCapture(page, label, records) { + page.on("response", async (response) => { + const url = response.url(); + if (!url.includes("/api/mindmap/") && !url.includes("/mindmap/") && !url.includes("/api/documents/save")) { + return; + } + const request = response.request(); + const method = request.method(); + const status = response.status(); + let responseText = null; + if (method !== "GET" || status >= 400) { + responseText = await response.text().catch((error) => `<>`); + } + records.push({ + type: "response", + label, + method, + url, + status, + statusText: response.statusText(), + requestBody: request.postData() || null, + responseText: responseText ? responseText.slice(0, 3000) : null, + }); + }); + page.on("requestfailed", (request) => { + const url = request.url(); + if (url.includes("/api/mindmap/") || url.includes("/mindmap/") || url.includes("/api/documents/save")) { + records.push({ + type: "requestfailed", + label, + method: request.method(), + url, + failure: request.failure()?.errorText || null, + requestBody: request.postData() || null, + }); + } + }); + page.on("console", (message) => { + if (message.type() === "error") { + const text = message.text(); + if (/mindmap|ArgumentValidationError|domainEvent|502|command_failed/i.test(text)) { + records.push({ + type: "console", + label, + level: message.type(), + text: text.slice(0, 2000), + }); + } + } + }); +} + +async function insertMindmapThroughSlash(page) { + const editor = page + .locator('[data-testid="mnote-leptos-tiptap-island-editor-root"] .editor-surface .ProseMirror[contenteditable="true"]') + .first(); + await editor.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await editor.click({ timeout: UI_TIMEOUT_MS }); + await page.keyboard.type("/"); + const item = page.getByTestId("slash-item-mindmap").first(); + await item.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await item.click({ timeout: UI_TIMEOUT_MS }); +} + +async function readMindmapState(page) { + return page.evaluate(() => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const runtime = document.querySelector('[data-testid="simple-mind-map-runtime"]'); + const error = document.querySelector('[data-testid="leptos-mindmap-error"]'); + return { + mindmapId: root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null, + runtimeReady: runtime instanceof HTMLElement ? runtime.dataset.runtimeReady === "true" : false, + commandStatus: scene instanceof HTMLElement ? scene.dataset.commandStatus || null : null, + lastSchemaAction: scene instanceof HTMLElement ? scene.dataset.lastSchemaAction || null : null, + commandRuntimeError: scene instanceof HTMLElement ? scene.dataset.commandRuntimeError || null : null, + commandRuntimeMessage: scene instanceof HTMLElement ? scene.dataset.commandRuntimeMessage || null : null, + errorStage: error instanceof HTMLElement ? error.dataset.stage || null : null, + errorText: error instanceof HTMLElement ? (error.textContent || "").slice(0, 3000) : null, + bodyText: (document.body?.innerText || "").slice(0, 5000), + }; + }); +} + +async function assertNoValidatorLeak(page, records, stage) { + await page.waitForTimeout(500); + const state = await readMindmapState(page); + const badRecord = records.find((record) => { + if (record.type === "response" && record.status >= 500) return true; + return BAD_TEXT_PATTERN.test(`${record.responseText || ""}\n${record.text || ""}\n${record.failure || ""}`); + }); + if (badRecord || BAD_TEXT_PATTERN.test(`${state.errorText || ""}\n${state.bodyText || ""}`)) { + throw new Error( + `${stage}:mindmap_validator_or_502_leak:${JSON.stringify( + { + state, + badRecord, + recentMindmapNetwork: records.slice(-12), + }, + null, + 2, + )}`, + ); + } + return state; +} + +async function waitForMindmapReady(page, stage) { + await page + .waitForFunction( + () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const runtime = document.querySelector('[data-testid="simple-mind-map-runtime"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + return ( + root instanceof HTMLElement && + runtime instanceof HTMLElement && + runtime.dataset.runtimeReady === "true" && + Boolean(mindmapId) && + Boolean(registry[mindmapId]) + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ) + .catch((error) => { + throw new Error(`${stage}:mindmap_not_ready:${error.message}`); + }); +} + +async function waitForDocumentContentToIncludeMindmap(requestContext, documentId, workspaceId, mindmapId) { + let lastText = ""; + for (let index = 0; index < 45; index += 1) { + const response = await requestContext.fetch( + `${BASE_URL}/api/documents/content?documentId=${encodeURIComponent(documentId)}&workspaceId=${encodeURIComponent(workspaceId)}`, + { method: "GET", timeout: 10_000 }, + ); + lastText = await response.text(); + if (response.ok() && lastText.includes(mindmapId)) { + try { + return JSON.parse(lastText); + } catch { + return { raw: lastText.slice(0, 3000) }; + } + } + await new Promise((resolve) => setTimeout(resolve, 500)); + } + throw new Error( + `document_content_missing_mindmap:${JSON.stringify({ + documentId, + workspaceId, + mindmapId, + lastText: lastText.slice(0, 5000), + })}`, + ); +} + +async function fetchMindmapProjection(requestContext, documentId, mindmapId) { + const response = await requestContext.fetch( + `${BASE_URL}/api/mindmap/${encodeURIComponent(documentId)}/${encodeURIComponent(mindmapId)}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get`, + { method: "GET", timeout: 10_000 }, + ); + const text = await response.text(); + assert(response.ok(), `mindmap_projection_fetch_failed:${response.status()}:${text.slice(0, 2000)}`); + const payload = JSON.parse(text); + return payload.result ?? payload; +} + +function collectMindmapTexts(root) { + const texts = []; + const visit = (node) => { + if (!node || typeof node !== "object") return; + const data = node.data && typeof node.data === "object" ? node.data : {}; + if (typeof data.text === "string") texts.push(data.text); + if (Array.isArray(node.children)) node.children.forEach(visit); + }; + visit(root); + return texts; +} + +async function waitForProjectionText(requestContext, documentId, mindmapId, expectedText) { + let lastProjection = null; + for (let index = 0; index < 45; index += 1) { + lastProjection = await fetchMindmapProjection(requestContext, documentId, mindmapId); + const texts = collectMindmapTexts(lastProjection.root); + if (texts.includes(expectedText)) { + return { projection: lastProjection, texts }; + } + await new Promise((resolve) => setTimeout(resolve, 500)); + } + throw new Error( + `mindmap_projection_missing_edited_text:${JSON.stringify({ + expectedText, + texts: collectMindmapTexts(lastProjection?.root), + projection: lastProjection, + }).slice(0, 5000)}`, + ); +} + +async function editTopicTextThroughRuntime(page, mindmapId, text) { + const result = await page.evaluate( + ({ mindmapId, text }) => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + if (scene instanceof HTMLElement) { + scene.dataset.lastDataChangeRefreshTriggered = ""; + scene.dataset.lastDataChangeDiffCommandCount = ""; + scene.dataset.commandStatus = "smoke-waiting-topic-edit"; + } + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = registry[mindmapId]; + const instance = bridge?.instance; + const topicNode = instance?.renderer?.findNodeByUid?.("topic") || null; + if (!topicNode || typeof topicNode !== "object") { + return { ok: false, reason: "topic_node_missing" }; + } + if (typeof topicNode.setData === "function") { + topicNode.setData({ text }); + } else if (topicNode.data && typeof topicNode.data === "object") { + topicNode.data.text = text; + } else { + return { ok: false, reason: "topic_node_not_mutable" }; + } + const snapshot = typeof bridge.getSnapshot === "function" ? bridge.getSnapshot() : instance?.getData?.(true); + return { + ok: true, + snapshotText: snapshot?.children?.[0]?.data?.text ?? null, + commandStatus: scene instanceof HTMLElement ? scene.dataset.commandStatus || null : null, + diffCommandCount: scene instanceof HTMLElement ? scene.dataset.lastDataChangeDiffCommandCount || null : null, + }; + }, + { mindmapId, text }, + ); + assert(result.ok, `topic_runtime_edit_failed:${JSON.stringify(result)}`); + await page.waitForFunction( + ({ text }) => { + const bodyText = document.body?.innerText || ""; + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return ( + bodyText.includes(text) || + (scene instanceof HTMLElement && scene.dataset.commandStatus !== "smoke-waiting-topic-edit") + ); + }, + { text }, + { timeout: UI_TIMEOUT_MS }, + ); + return result; +} + +async function clickInsertChild(page) { + const button = page.getByTestId("mindmap-schema-toolbar-action-insertChild"); + await button.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + const disabled = await button.evaluate((node) => node instanceof HTMLButtonElement && node.disabled); + if (disabled) { + await page.locator('[data-testid="simple-mind-map-runtime"] .smm-node').first().click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction(() => { + const button = document.querySelector('[data-testid="mindmap-schema-toolbar-action-insertChild"]'); + return button instanceof HTMLButtonElement && !button.disabled; + }, null, { timeout: UI_TIMEOUT_MS }); + } + await page.evaluate(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + if (scene instanceof HTMLElement) { + scene.dataset.commandStatus = "smoke-waiting"; + delete scene.dataset.lastSchemaAction; + } + }); + await button.click({ timeout: UI_TIMEOUT_MS }); + await page.waitForFunction(() => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return scene instanceof HTMLElement && scene.dataset.lastSchemaAction === "insertChild" && scene.dataset.commandStatus === "success"; + }, null, { timeout: UI_TIMEOUT_MS }); +} + +async function main() { + await fs.mkdir(OUTPUT_DIR, { recursive: true }); + + const browser = await chromium.launch({ headless: true }); + const contextA = await browser.newContext({ viewport: { width: 1440, height: 960 }, locale: "zh-CN" }); + const pageA = await contextA.newPage(); + const records = []; + attachMindmapNetworkCapture(pageA, "browser-a", records); + const screenshots = []; + const createdIds = []; + const result = { + ok: false, + task: TASK, + baseUrl: BASE_URL, + documentId: null, + workspaceId: null, + mindmapId: null, + network: records, + screenshots, + }; + + let contextB = null; + let pageB = null; + try { + await ensureAuthenticated(pageA, contextA.request); + const doc = await createTempDocument(contextA.request, null); + createdIds.push(doc.documentId); + result.documentId = doc.documentId; + result.workspaceId = doc.workspaceId; + await renameDocument(contextA.request, doc.workspaceId, doc.documentId, `task168-mindmap-${Date.now().toString().slice(-6)}`); + + await openDocument(pageA, doc.workspaceId, doc.documentId); + await insertMindmapThroughSlash(pageA); + await waitForMindmapReady(pageA, "browser-a-initial"); + const initialState = await assertNoValidatorLeak(pageA, records, "browser-a-initial"); + result.mindmapId = initialState.mindmapId; + + await clickInsertChild(pageA); + const afterCommand = await assertNoValidatorLeak(pageA, records, "browser-a-insert-child"); + assert(afterCommand.commandStatus === "success", `insert_child_not_success:${JSON.stringify(afterCommand)}`); + screenshots.push(await screenshot(pageA, "01-after-insert-child")); + result.documentContentAfterInsert = await waitForDocumentContentToIncludeMindmap( + contextA.request, + doc.documentId, + doc.workspaceId, + result.mindmapId, + ); + + const editedTopicText = `二级节点-SMOKE-${Date.now().toString().slice(-6)}`; + result.topicEditAttempt = await editTopicTextThroughRuntime(pageA, result.mindmapId, editedTopicText); + const afterTopicEdit = await assertNoValidatorLeak(pageA, records, "browser-a-topic-edit"); + result.afterTopicEdit = afterTopicEdit; + result.topicProjectionAfterEdit = await waitForProjectionText( + contextA.request, + doc.documentId, + result.mindmapId, + editedTopicText, + ); + screenshots.push(await screenshot(pageA, "02-after-topic-edit")); + + contextB = await browser.newContext({ viewport: { width: 1440, height: 960 }, locale: "zh-CN" }); + pageB = await contextB.newPage(); + attachMindmapNetworkCapture(pageB, "browser-b", records); + await ensureAuthenticated(pageB, contextB.request); + await openDocument(pageB, doc.workspaceId, doc.documentId); + await waitForMindmapReady(pageB, "browser-b-reopen"); + const secondState = await assertNoValidatorLeak(pageB, records, "browser-b-reopen"); + assert( + secondState.bodyText.includes(editedTopicText), + `second_browser_missing_edited_topic_text:${JSON.stringify({ + expected: editedTopicText, + secondState, + })}`, + ); + assert( + secondState.mindmapId === result.mindmapId, + `second_browser_mindmap_id_mismatch:${JSON.stringify({ expected: result.mindmapId, actual: secondState.mindmapId })}`, + ); + screenshots.push(await screenshot(pageB, "03-second-browser-visible")); + + result.ok = true; + result.initialState = initialState; + result.afterCommand = afterCommand; + result.secondState = secondState; + await writeResult(result); + } catch (error) { + result.error = error instanceof Error ? error.stack || error.message : String(error); + screenshots.push(await screenshot(pageA, "99-failure").catch(() => null)); + if (pageB) { + screenshots.push(await screenshot(pageB, "99-failure-browser-b").catch(() => null)); + } + await writeResult(result); + throw error; + } finally { + if (contextB) { + await contextB.close().catch(() => undefined); + } + await cleanupDocuments(contextA.request, createdIds).catch(() => undefined); + await contextA.close().catch(() => undefined); + await browser.close(); + } +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/scripts/task169-mindmap-realtime-smoke.js b/scripts/task169-mindmap-realtime-smoke.js new file mode 100644 index 00000000..1238be54 --- /dev/null +++ b/scripts/task169-mindmap-realtime-smoke.js @@ -0,0 +1,1160 @@ +#!/usr/bin/env node +"use strict"; + +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { chromium } = require("playwright"); +const { + BASE_URL, + UI_TIMEOUT_MS, + assert, + cleanupDocuments, + createTempDocument, + ensureAuthenticated, + openDocument, + openFilesystemView, + renameDocument, +} = require("./tree-shell-smoke-helpers"); + +const TASK = "task169-mindmap-realtime-smoke"; +const OUTPUT_DIR = path.join(process.cwd(), "tmp", TASK); +const RESULT_PATH = path.join(OUTPUT_DIR, "result.json"); +const LIVE_WAIT_MS = Number(process.env.MNOTE_MINDMAP_REALTIME_WAIT_MS || 12_000); +const BAD_TEXT_PATTERN = /ArgumentValidationError|domainEventHint|domainEventPlan|streamDeltaHint|command_failed|502 Bad Gateway/i; + +async function writeResult(payload) { + await fs.mkdir(OUTPUT_DIR, { recursive: true }); + await fs.writeFile(RESULT_PATH, `${JSON.stringify({ ...payload, resultPath: RESULT_PATH }, null, 2)}\n`, "utf8"); +} + +async function screenshot(page, name) { + const file = path.join(OUTPUT_DIR, `${name}.png`); + await page.screenshot({ path: file, fullPage: true }); + return file; +} + +async function installTreeEventRecorder(page) { + await page.addInitScript(() => { + window.__MNOTE_SMOKE_TREE_EVENTS__ = []; + const record = (name, event) => { + const detail = event && event.detail ? event.detail : null; + window.__MNOTE_SMOKE_TREE_EVENTS__.push({ + name, + at: Date.now(), + revision: detail && detail.revision ? String(detail.revision) : "", + data: detail && detail.payload && detail.payload.data ? detail.payload.data : null, + eventType: + detail && + detail.payload && + detail.payload.overview && + Array.isArray(detail.payload.overview.domain_events) && + detail.payload.overview.domain_events[0] + ? detail.payload.overview.domain_events[0].event_type || "" + : "", + }); + }; + window.addEventListener("tree:snapshot", (event) => record("tree:snapshot", event)); + window.addEventListener("tree:delta", (event) => record("tree:delta", event)); + window.addEventListener("tree:resync", (event) => record("tree:resync", event)); + }); +} + +async function installMindmapLoadingRecorder(page) { + await page.addInitScript(() => { + window.__MNOTE_MINDMAP_LOADING_EVENTS__ = []; + const recordLoading = (node, reason) => { + if (!(node instanceof HTMLElement)) return; + const loading = node.matches?.('[data-testid="mindmap-scene-loading"]') + ? node + : node.querySelector?.('[data-testid="mindmap-scene-loading"]'); + if (!(loading instanceof HTMLElement)) return; + window.__MNOTE_MINDMAP_LOADING_EVENTS__.push({ + at: Date.now(), + reason, + text: loading.textContent || "", + url: window.location.href, + }); + }; + const start = () => { + if (window.__MNOTE_MINDMAP_LOADING_OBSERVER__) return; + const target = document.documentElement || document.body; + if (!target) { + window.setTimeout(start, 0); + return; + } + recordLoading(target, "initial-scan"); + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + mutation.addedNodes.forEach((node) => recordLoading(node, "added-node")); + }); + }); + observer.observe(target, { childList: true, subtree: true }); + window.__MNOTE_MINDMAP_LOADING_OBSERVER__ = observer; + }; + start(); + }); +} + +function attachNetworkCapture(page, label, records) { + page.on("request", (request) => { + const url = request.url(); + if (url.includes("/api/tree/events")) { + records.push({ type: "request", label, method: request.method(), url }); + } + }); + page.on("response", async (response) => { + const url = response.url(); + if ( + !url.includes("/api/tree/events") && + !url.includes("/api/mindmap/") && + !url.includes("/mindmap/") && + !url.includes("/api/documents/save") + ) { + return; + } + const request = response.request(); + const method = request.method(); + const status = response.status(); + let responseText = null; + if (method !== "GET" || status >= 400 || url.includes("/api/documents/save")) { + responseText = await response.text().catch((error) => `<>`); + } + records.push({ + type: "response", + label, + method, + url, + status, + requestBody: request.postData() || null, + responseText: responseText ? responseText.slice(0, 4000) : null, + }); + }); + page.on("requestfailed", (request) => { + const url = request.url(); + if (url.includes("/api/tree/events") || url.includes("/api/mindmap/") || url.includes("/api/documents/save")) { + records.push({ + type: "requestfailed", + label, + method: request.method(), + url, + failure: request.failure()?.errorText || null, + requestBody: request.postData() || null, + }); + } + }); + page.on("console", (message) => { + const text = message.text(); + if (message.type() === "error" || /mindmap|tree live|EventSource|502|command_failed/i.test(text)) { + records.push({ + type: "console", + label, + level: message.type(), + text: text.slice(0, 2000), + }); + } + }); +} + +async function insertMindmapThroughSlash(page) { + const editor = page + .locator('[data-testid="mnote-leptos-tiptap-island-editor-root"] .editor-surface .ProseMirror[contenteditable="true"]') + .first(); + await editor.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await editor.click({ timeout: UI_TIMEOUT_MS }); + await page.keyboard.type("/"); + const item = page.getByTestId("slash-item-mindmap").first(); + await item.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await item.click({ timeout: UI_TIMEOUT_MS }); +} + +async function readPageState(page) { + return page.evaluate(() => { + const html = document.documentElement; + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const runtime = document.querySelector('[data-testid="simple-mind-map-runtime"]'); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const error = document.querySelector('[data-testid="leptos-mindmap-error"]'); + const loading = document.querySelector('[data-testid="mindmap-scene-loading"]'); + const assetRows = Array.from(document.querySelectorAll("#sidebar-file-tree-root [data-asset-id]")) + .map((node) => (node instanceof HTMLElement ? node.getAttribute("data-asset-id") || "" : "")) + .filter(Boolean); + return { + url: window.location.href, + bodyText: (document.body?.innerText || "").slice(0, 8000), + mindmapId: root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null, + runtimeReady: runtime instanceof HTMLElement ? runtime.dataset.runtimeReady === "true" : false, + runtimeMountCount: scene instanceof HTMLElement ? Number(scene.dataset.runtimeMountCount || "0") : 0, + runtimeProjectionApplyCount: + scene instanceof HTMLElement ? Number(scene.dataset.runtimeProjectionApplyCount || "0") : 0, + lastRuntimeMountReason: scene instanceof HTMLElement ? scene.dataset.lastRuntimeMountReason || "" : "", + lastFetchSceneReason: scene instanceof HTMLElement ? scene.dataset.lastFetchSceneReason || "" : "", + backgroundProjectionRefresh: scene instanceof HTMLElement ? scene.dataset.backgroundProjectionRefresh || "" : "", + hasMindmapError: Boolean(error), + hasMindmapLoading: Boolean(loading), + commandStatus: scene instanceof HTMLElement ? scene.dataset.commandStatus || "" : "", + treeLiveStatus: html.getAttribute("data-mnote-tree-live-status") || "", + treeLiveApplied: html.getAttribute("data-mnote-tree-live-applied") || "", + treeLiveRevision: html.getAttribute("data-mnote-tree-live-revision") || "", + treeLiveApplyError: html.getAttribute("data-mnote-tree-live-apply-error") || "", + lastMindmapAssetOpenMode: html.getAttribute("data-mnote-last-mindmap-asset-open-mode") || "", + lastMindmapAssetId: html.getAttribute("data-mnote-last-mindmap-asset-id") || "", + objectEditor: + document.querySelector("[data-mnote-object-editor]") instanceof HTMLElement + ? document.querySelector("[data-mnote-object-editor]").getAttribute("data-mnote-object-editor") || "" + : "", + objectIdentity: + document.querySelector("[data-mnote-object-identity]") instanceof HTMLElement + ? document.querySelector("[data-mnote-object-identity]").getAttribute("data-mnote-object-identity") || "" + : "", + localStorageKeys: Object.keys(window.localStorage || {}).filter((key) => + /mnote\.leptos-tiptap-spike\.document|__mindmap_object__|mindmap-object/.test(key), + ), + mindmapLoadingEvents: window.__MNOTE_MINDMAP_LOADING_EVENTS__ || [], + fileTreeText: (document.getElementById("sidebar-file-tree-root")?.textContent || "").slice(0, 4000), + fileTreeAssetIds: assetRows, + treeEvents: window.__MNOTE_SMOKE_TREE_EVENTS__ || [], + }; + }); +} + +async function readMindmapRuntimeStabilityState(page, mindmapId) { + return page.evaluate( + ({ mindmapId }) => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = registry[mindmapId]; + const instance = bridge?.instance; + const topicNode = instance?.renderer?.findNodeByUid?.("topic") || null; + const topicRect = typeof topicNode?.getRect === "function" ? topicNode.getRect() : null; + const viewTransform = instance?.view?.getTransformData?.() || null; + return { + runtimeMountCount: scene instanceof HTMLElement ? Number(scene.dataset.runtimeMountCount || "0") : 0, + runtimeProjectionApplyCount: + scene instanceof HTMLElement ? Number(scene.dataset.runtimeProjectionApplyCount || "0") : 0, + lastRuntimeMountReason: scene instanceof HTMLElement ? scene.dataset.lastRuntimeMountReason || "" : "", + lastRuntimeProjectionApplyReason: + scene instanceof HTMLElement ? scene.dataset.lastRuntimeProjectionApplyReason || "" : "", + runtimeProjectionDeferred: + scene instanceof HTMLElement ? scene.dataset.runtimeProjectionDeferred || "" : "", + lastRuntimeProjectionDeferReason: + scene instanceof HTMLElement ? scene.dataset.lastRuntimeProjectionDeferReason || "" : "", + backgroundProjectionRefresh: scene instanceof HTMLElement ? scene.dataset.backgroundProjectionRefresh || "" : "", + commandStatus: scene instanceof HTMLElement ? scene.dataset.commandStatus || "" : "", + commandApplyMode: scene instanceof HTMLElement ? scene.dataset.commandApplyMode || "" : "", + topicRect: topicRect + ? { + x: Number(topicRect.x ?? topicRect.left ?? 0), + y: Number(topicRect.y ?? topicRect.top ?? 0), + width: Number(topicRect.width ?? 0), + height: Number(topicRect.height ?? 0), + } + : null, + viewTransform, + }; + }, + { mindmapId }, + ); +} + +function stableJson(value) { + return JSON.stringify(value ?? null); +} + +function rectCenter(rect) { + if (!rect) return null; + return { + x: rect.x + rect.width / 2, + y: rect.y + rect.height / 2, + }; +} + +function centerDistance(a, b) { + const ca = rectCenter(a); + const cb = rectCenter(b); + if (!ca || !cb) return Number.POSITIVE_INFINITY; + return Math.hypot(ca.x - cb.x, ca.y - cb.y); +} + +async function dispatchSyntheticMindmapTreeSignal(page, documentId, mindmapId, eventName) { + return page.evaluate( + ({ documentId, mindmapId, eventName }) => { + const cursorId = `smoke-command-${Date.now()}`; + const payload = + eventName === "tree:delta" + ? { + kind: "delta", + revision: JSON.stringify({ id: cursorId, createdAt: new Date().toISOString() }), + data: { + op: "resync_required", + reason: "mindmap.put", + documentId, + blockId: mindmapId, + }, + } + : { + kind: "resync", + revision: JSON.stringify({ id: cursorId, createdAt: new Date().toISOString() }), + overview: { + command_logs: [ + { + id: cursorId, + command_id: cursorId, + target_page_id: documentId, + target_block_id: mindmapId, + aggregate_type: "block", + aggregate_id: mindmapId, + payload: { + streamDelta: { + op: "resync_required", + reason: "mindmap.put", + documentId, + blockId: mindmapId, + }, + }, + }, + ], + domain_events: [], + }, + }; + window.dispatchEvent(new CustomEvent(eventName, { detail: { payload, revision: payload.revision } })); + return payload; + }, + { documentId, mindmapId, eventName }, + ); +} + +async function assertMindmapRuntimeDoesNotRefreshForLiveSignals(page, documentId, mindmapId, failures, label) { + const before = await readPageState(page); + const beforeRuntime = await readMindmapRuntimeStabilityState(page, mindmapId); + if (before.hasMindmapError || before.hasMindmapLoading || !before.runtimeReady) { + failures.push({ + code: "mindmap_unstable_before_live_signal", + label, + state: before, + }); + return { before, afterResync: before, afterDelta: before }; + } + + const resyncPayload = await dispatchSyntheticMindmapTreeSignal(page, documentId, mindmapId, "tree:resync"); + await page.waitForTimeout(2_500); + const afterResync = await readPageState(page); + const afterResyncRuntime = await readMindmapRuntimeStabilityState(page, mindmapId); + if (afterResync.runtimeMountCount !== before.runtimeMountCount) { + failures.push({ + code: "mindmap_resync_remounted_runtime", + label, + before, + after: afterResync, + payload: resyncPayload, + }); + } + if (afterResync.runtimeProjectionApplyCount !== before.runtimeProjectionApplyCount) { + failures.push({ + code: "mindmap_resync_applied_projection_despite_usability_first", + label, + before, + after: afterResync, + payload: resyncPayload, + }); + } + if (stableJson(afterResyncRuntime.viewTransform) !== stableJson(beforeRuntime.viewTransform)) { + failures.push({ + code: "mindmap_resync_changed_view_transform", + label, + before: beforeRuntime, + after: afterResyncRuntime, + payload: resyncPayload, + }); + } + if (centerDistance(beforeRuntime.topicRect, afterResyncRuntime.topicRect) > 2) { + failures.push({ + code: "mindmap_resync_moved_topic_node", + label, + before: beforeRuntime, + after: afterResyncRuntime, + payload: resyncPayload, + }); + } + + const deltaPayload = await dispatchSyntheticMindmapTreeSignal(page, documentId, mindmapId, "tree:delta"); + await page.waitForTimeout(2_500); + const afterDelta = await readPageState(page); + const afterDeltaRuntime = await readMindmapRuntimeStabilityState(page, mindmapId); + if (afterDelta.runtimeMountCount !== afterResync.runtimeMountCount) { + failures.push({ + code: "mindmap_delta_remounted_runtime", + label, + before: afterResync, + after: afterDelta, + payload: deltaPayload, + }); + } + if (afterDelta.runtimeProjectionApplyCount !== afterResync.runtimeProjectionApplyCount) { + failures.push({ + code: "mindmap_delta_applied_projection_despite_usability_first", + label, + before: afterResync, + after: afterDelta, + payload: deltaPayload, + }); + } + if (stableJson(afterDeltaRuntime.viewTransform) !== stableJson(afterResyncRuntime.viewTransform)) { + failures.push({ + code: "mindmap_delta_changed_view_transform", + label, + before: afterResyncRuntime, + after: afterDeltaRuntime, + payload: deltaPayload, + }); + } + if (centerDistance(afterResyncRuntime.topicRect, afterDeltaRuntime.topicRect) > 2) { + failures.push({ + code: "mindmap_delta_moved_topic_node", + label, + before: afterResyncRuntime, + after: afterDeltaRuntime, + payload: deltaPayload, + }); + } + if (afterDelta.hasMindmapError || afterDelta.hasMindmapLoading) { + failures.push({ + code: "mindmap_live_signal_left_error_or_loading", + label, + after: afterDelta, + }); + } + + return { before, beforeRuntime, afterResync, afterResyncRuntime, afterDelta, afterDeltaRuntime }; +} + +async function waitForMindmapReady(page, stage) { + await page + .waitForFunction( + () => { + const root = document.querySelector('[data-testid="mnote-mindmap-editor-root"]'); + const runtime = document.querySelector('[data-testid="simple-mind-map-runtime"]'); + const mindmapId = root instanceof HTMLElement ? root.dataset.mnoteMindmapId || null : null; + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + return ( + root instanceof HTMLElement && + runtime instanceof HTMLElement && + runtime.dataset.runtimeReady === "true" && + Boolean(mindmapId) && + Boolean(registry[mindmapId]) + ); + }, + null, + { timeout: UI_TIMEOUT_MS }, + ) + .catch((error) => { + throw new Error(`${stage}:mindmap_not_ready:${error.message}`); + }); +} + +async function waitForMindmapId(page) { + await waitForMindmapReady(page, "mindmap-id"); + const state = await readPageState(page); + assert(state.mindmapId, `mindmap_id_missing:${JSON.stringify(state)}`); + return state.mindmapId; +} + +async function waitForDocumentContentToIncludeMindmap(requestContext, documentId, workspaceId, mindmapId) { + let lastText = ""; + for (let index = 0; index < 45; index += 1) { + const response = await requestContext.fetch( + `${BASE_URL}/api/documents/content?documentId=${encodeURIComponent(documentId)}&workspaceId=${encodeURIComponent(workspaceId)}`, + { method: "GET", timeout: 10_000 }, + ); + lastText = await response.text(); + if (response.ok() && lastText.includes(mindmapId)) { + return lastText; + } + await new Promise((resolve) => setTimeout(resolve, 500)); + } + throw new Error(`document_content_missing_mindmap:${lastText.slice(0, 3000)}`); +} + +async function assertFileTreeMindmapOpenUsesObjectShell(page, documentId, mindmapId, failures) { + await openFilesystemView(page); + const opened = await page.evaluate( + ({ documentId, mindmapId }) => { + const rows = Array.from(document.querySelectorAll("#sidebar-file-tree-root [data-asset-id]")); + const row = rows.find((node) => { + if (!(node instanceof HTMLElement)) return false; + const assetId = node.getAttribute("data-asset-id") || ""; + const rowDocumentId = node.getAttribute("data-document-id") || node.getAttribute("data-doc-id") || ""; + return assetId === mindmapId && rowDocumentId === documentId; + }); + if (!(row instanceof HTMLElement)) { + return { clicked: false, reason: "mindmap_asset_row_missing" }; + } + const button = row.querySelector('[data-rust-action="open"], .tree-link'); + if (!(button instanceof HTMLElement)) { + return { clicked: false, reason: "mindmap_asset_open_button_missing" }; + } + button.click(); + return { + clicked: true, + assetId: row.getAttribute("data-asset-id") || "", + rowId: row.getAttribute("data-row-id") || "", + objectIdentity: row.getAttribute("data-object-identity") || "", + objectKind: row.getAttribute("data-object-kind") || "", + }; + }, + { documentId, mindmapId }, + ); + if (!opened.clicked) { + failures.push({ code: "filetree_mindmap_asset_open_row_missing", opened }); + return opened; + } + if (!opened.objectIdentity.includes(`"objectKind":"mindmap"`) || !opened.objectIdentity.includes(`"assetId":"${mindmapId}"`)) { + failures.push({ + code: "filetree_mindmap_asset_row_missing_object_identity", + opened, + }); + } + await page.waitForURL((url) => url.pathname.includes(`/mindmap/${encodeURIComponent(documentId)}/${encodeURIComponent(mindmapId)}`), { + timeout: UI_TIMEOUT_MS, + }).catch(() => null); + const state = await readPageState(page); + const url = new URL(state.url); + if (!url.pathname.includes(`/mindmap/${encodeURIComponent(documentId)}/${encodeURIComponent(mindmapId)}`)) { + failures.push({ + code: "filetree_mindmap_asset_open_did_not_use_object_shell", + opened, + state, + }); + } + if (url.pathname.includes(`/documents/${encodeURIComponent(documentId)}`)) { + failures.push({ + code: "filetree_mindmap_asset_open_was_swallowed_by_index_document", + opened, + state, + }); + } + await waitForMindmapReady(page, "filetree-object-shell-open"); + const readyState = await readPageState(page); + if (readyState.mindmapId !== mindmapId || !readyState.runtimeReady || readyState.hasMindmapError) { + failures.push({ + code: "filetree_mindmap_asset_object_shell_not_ready", + opened, + readyState, + }); + } + if (readyState.objectEditor !== "mindmap" || readyState.objectIdentity !== `resource:mindmap:${documentId}:${mindmapId}`) { + failures.push({ + code: "mindmap_object_shell_missing_identity_marker", + opened, + readyState, + }); + } + return { opened, state: readyState }; +} + +async function assertFileTreeIndexOpenUsesPageAggregate(page, documentId, mindmapId, failures) { + await openFilesystemView(page); + const opened = await page.evaluate( + ({ documentId }) => { + const row = + document.querySelector(`#sidebar-file-tree-root [data-row-id="index:${CSS.escape(documentId)}"]`) || + Array.from(document.querySelectorAll("#sidebar-file-tree-root [data-row-kind='index']")).find((node) => { + if (!(node instanceof HTMLElement)) return false; + const rowDocumentId = node.getAttribute("data-document-id") || node.getAttribute("data-doc-id") || ""; + return rowDocumentId === documentId; + }); + if (!(row instanceof HTMLElement)) { + return { clicked: false, reason: "index_row_missing" }; + } + const button = row.querySelector('[data-rust-action="open"], .tree-link'); + if (!(button instanceof HTMLElement)) { + return { clicked: false, reason: "index_open_button_missing" }; + } + button.click(); + return { + clicked: true, + rowId: row.getAttribute("data-row-id") || "", + objectIdentity: row.getAttribute("data-object-identity") || "", + }; + }, + { documentId }, + ); + if (!opened.clicked) { + failures.push({ code: "filetree_index_open_row_missing", opened }); + return opened; + } + if (!opened.objectIdentity.includes(`"objectKind":"index"`) || !opened.objectIdentity.includes(`"documentId":"${documentId}"`)) { + failures.push({ + code: "filetree_index_row_missing_object_identity", + opened, + }); + } + await page.waitForURL((url) => url.pathname.includes(`/documents/${encodeURIComponent(documentId)}`), { + timeout: UI_TIMEOUT_MS, + }).catch(() => null); + const state = await readPageState(page); + const url = new URL(state.url); + if (!url.pathname.includes(`/documents/${encodeURIComponent(documentId)}`)) { + failures.push({ + code: "filetree_index_open_did_not_return_document_page", + opened, + state, + }); + } + if (state.objectEditor === "mindmap" || state.objectIdentity.includes(`resource:mindmap:${documentId}:${mindmapId}`)) { + failures.push({ + code: "filetree_index_open_loaded_mindmap_object_identity", + opened, + state, + }); + } + return { opened, state }; +} + +function readMindmapBlocksFromDocumentContentText(text) { + const payload = JSON.parse(text); + const content = Array.isArray(payload?.content) + ? payload.content + : Array.isArray(payload?.result?.content) + ? payload.result.content + : Array.isArray(payload?.data?.content) + ? payload.data.content + : Array.isArray(payload?.body?.content) + ? payload.body.content + : []; + return content.filter((block) => block?.type === "mindmap" || block?.blockType === "mindmap"); +} + +async function assertDocumentMindmapBlockUsesReferenceSource(requestContext, documentId, workspaceId, mindmapId, failures, label) { + const text = await waitForDocumentContentToIncludeMindmap(requestContext, documentId, workspaceId, mindmapId); + const blocks = readMindmapBlocksFromDocumentContentText(text); + const target = blocks.find((block) => { + const props = block?.props && typeof block.props === "object" ? block.props : {}; + return props.mindmapId === mindmapId || props.mindmap_id === mindmapId || block.id === mindmapId || block.blockId === mindmapId; + }); + if (!target) { + failures.push({ + code: "document_mindmap_block_reference_missing", + label, + mindmapId, + blocks, + responseText: text.slice(0, 3000), + }); + return { ok: false, blocks }; + } + const props = target.props && typeof target.props === "object" ? target.props : {}; + if (!props.mindmapId || props.rootNodeId !== "root" || Object.prototype.hasOwnProperty.call(props, "data")) { + failures.push({ + code: "document_mindmap_block_uses_wrong_source", + label, + mindmapId, + props, + target, + }); + return { ok: false, target }; + } + return { ok: true, target }; +} + +async function waitForMindmapProjectionText(requestContext, documentId, mindmapId, expectedText) { + let lastText = ""; + for (let index = 0; index < 45; index += 1) { + const response = await requestContext.fetch( + `${BASE_URL}/api/mindmap/${encodeURIComponent(documentId)}/${encodeURIComponent(mindmapId)}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get`, + { method: "GET", timeout: 10_000 }, + ); + lastText = await response.text(); + if (response.ok() && lastText.includes(expectedText)) return lastText; + await new Promise((resolve) => setTimeout(resolve, 500)); + } + throw new Error(`mindmap_projection_missing_text:${expectedText}:${lastText.slice(0, 3000)}`); +} + +async function readMindmapRuntimeTextState(page, mindmapId, expectedText) { + return page.evaluate( + ({ mindmapId, expectedText }) => { + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = registry[mindmapId]; + const snapshot = bridge?.getSnapshot?.() ?? bridge?.instance?.getData?.(true) ?? null; + const root = snapshot && typeof snapshot === "object" && "root" in snapshot ? snapshot.root : snapshot; + const texts = []; + const visit = (node) => { + if (!node || typeof node !== "object") return; + const data = node.data && typeof node.data === "object" ? node.data : {}; + if (typeof data.text === "string") texts.push(data.text); + if (Array.isArray(node.children)) node.children.forEach(visit); + }; + visit(root); + return { + texts, + includesExpectedText: texts.some((text) => text.includes(expectedText)), + snapshot, + }; + }, + { mindmapId, expectedText }, + ); +} + +async function readMindmapProjectionText(requestContext, documentId, mindmapId) { + const response = await requestContext.fetch( + `${BASE_URL}/api/mindmap/${encodeURIComponent(documentId)}/${encodeURIComponent(mindmapId)}?view=simple_mind_map_scene&queryName=mindmap.simple_mind_map_scene.get`, + { method: "GET", timeout: 10_000 }, + ); + return { + ok: response.ok(), + status: response.status(), + text: await response.text(), + }; +} + +async function editTopicTextThroughRuntime(page, mindmapId, text) { + const result = await page.evaluate( + ({ mindmapId, text }) => { + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + if (scene instanceof HTMLElement) { + scene.dataset.commandStatus = "smoke-waiting-topic-edit"; + } + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = registry[mindmapId]; + const instance = bridge?.instance; + const topicNode = instance?.renderer?.findNodeByUid?.("topic") || null; + if (!topicNode || typeof topicNode !== "object") return { ok: false, reason: "topic_node_missing" }; + if (typeof topicNode.setData === "function") { + topicNode.setData({ text }); + } else if (topicNode.data && typeof topicNode.data === "object") { + topicNode.data.text = text; + } else { + return { ok: false, reason: "topic_node_not_mutable" }; + } + const snapshot = typeof bridge.getSnapshot === "function" ? bridge.getSnapshot() : instance?.getData?.(true); + return { + ok: true, + snapshotText: snapshot?.children?.[0]?.data?.text ?? null, + commandStatus: scene instanceof HTMLElement ? scene.dataset.commandStatus || null : null, + }; + }, + { mindmapId, text }, + ); + assert(result.ok, `topic_runtime_edit_failed:${JSON.stringify(result)}`); + await page.waitForFunction( + ({ text }) => { + const bodyText = document.body?.innerText || ""; + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + return bodyText.includes(text) || (scene instanceof HTMLElement && scene.dataset.commandStatus !== "smoke-waiting-topic-edit"); + }, + { text }, + { timeout: UI_TIMEOUT_MS }, + ); + return result; +} + +async function readRuntimeTextEditState(page) { + return page.evaluate(() => { + const edit = document.querySelector(".smm-node-edit-wrap[contenteditable=\"true\"]"); + const scene = document.querySelector('[data-testid="leptos-mindmap-island"]'); + const active = document.activeElement; + return { + exists: edit instanceof HTMLElement, + visible: + edit instanceof HTMLElement && + edit.style.display !== "none" && + edit.getClientRects().length > 0, + text: edit instanceof HTMLElement ? edit.innerText || edit.textContent || "" : "", + active: + edit instanceof HTMLElement && + (active === edit || (active instanceof Node && edit.contains(active))), + runtimeMountCount: scene instanceof HTMLElement ? Number(scene.dataset.runtimeMountCount || "0") : 0, + runtimeProjectionApplyCount: + scene instanceof HTMLElement ? Number(scene.dataset.runtimeProjectionApplyCount || "0") : 0, + runtimeProjectionDeferred: + scene instanceof HTMLElement ? scene.dataset.runtimeProjectionDeferred || "" : "", + lastRuntimeProjectionDeferReason: + scene instanceof HTMLElement ? scene.dataset.lastRuntimeProjectionDeferReason || "" : "", + backgroundProjectionRefresh: + scene instanceof HTMLElement ? scene.dataset.backgroundProjectionRefresh || "" : "", + }; + }); +} + +async function openTopicTextEdit(page, mindmapId) { + const result = await page.evaluate( + ({ mindmapId }) => { + const registry = window.__MNOTE_LEPTOS_MINDMAP_BRIDGES__ || {}; + const bridge = registry[mindmapId]; + const instance = bridge?.instance; + const topicNode = instance?.renderer?.findNodeByUid?.("topic") || null; + const textEdit = instance?.renderer?.textEdit; + if (!topicNode) return { ok: false, reason: "topic_node_missing" }; + if (typeof textEdit?.show !== "function") return { ok: false, reason: "text_edit_show_missing" }; + textEdit.show({ node: topicNode, isFromKeyDown: false }); + return { ok: true }; + }, + { mindmapId }, + ); + assert(result.ok, `topic_text_edit_open_failed:${JSON.stringify(result)}`); + const edit = page.locator(".smm-node-edit-wrap[contenteditable=\"true\"]").first(); + await edit.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS }); + await edit.focus(); + await page.keyboard.press("Control+A"); + await page.keyboard.press("Backspace"); +} + +async function enterTopicTextDraftWithoutCommit(page, mindmapId, text) { + await openTopicTextEdit(page, mindmapId); + await page.keyboard.insertText(text); + await page.waitForFunction( + ({ text }) => { + const edit = document.querySelector(".smm-node-edit-wrap[contenteditable=\"true\"]"); + return edit instanceof HTMLElement && (edit.innerText || edit.textContent || "").includes(text); + }, + { text }, + { timeout: UI_TIMEOUT_MS }, + ); + return readRuntimeTextEditState(page); +} + +async function assertLongLanguageEditSurvivesLiveRefresh(page, requestContext, documentId, mindmapId, failures) { + const longText = + `长文本编辑-LIVE-${Date.now().toString().slice(-6)}:` + + "第一段用于覆盖真实中文连续输入,包含标点、换行前的较长句子,确保编辑框不会因为后台实时刷新而丢焦或闪烁。"; + const secondHalf = "第二段继续输入,验证 live signal 之后仍然可以稳定完成编辑并保存到投影。"; + await openTopicTextEdit(page, mindmapId); + const beforeEditRuntime = await readMindmapRuntimeStabilityState(page, mindmapId); + await page.keyboard.insertText(longText); + const beforeLive = await readRuntimeTextEditState(page); + const resyncPayload = await dispatchSyntheticMindmapTreeSignal(page, documentId, mindmapId, "tree:resync"); + await page.waitForTimeout(2_500); + const afterLive = await readRuntimeTextEditState(page); + if (!afterLive.visible || !afterLive.active || !afterLive.text.includes(longText)) { + failures.push({ + code: "mindmap_live_refresh_interrupted_long_text_edit", + beforeLive, + afterLive, + payload: resyncPayload, + }); + return { beforeLive, afterLive, committed: false, longText: longText + secondHalf }; + } + if (afterLive.runtimeMountCount !== beforeLive.runtimeMountCount) { + failures.push({ + code: "mindmap_live_refresh_remounted_during_long_text_edit", + beforeLive, + afterLive, + payload: resyncPayload, + }); + } + if (afterLive.runtimeProjectionApplyCount !== beforeLive.runtimeProjectionApplyCount) { + failures.push({ + code: "mindmap_live_refresh_applied_projection_during_long_text_edit", + beforeLive, + afterLive, + payload: resyncPayload, + }); + } + await page.keyboard.insertText(secondHalf); + await page.keyboard.press("Enter"); + await waitForMindmapProjectionText(requestContext, documentId, mindmapId, longText + secondHalf); + await page.waitForTimeout(2_500); + const afterCommitRuntime = await readMindmapRuntimeStabilityState(page, mindmapId); + if (afterCommitRuntime.runtimeMountCount !== beforeEditRuntime.runtimeMountCount) { + failures.push({ + code: "mindmap_long_text_commit_remounted_runtime", + before: beforeEditRuntime, + after: afterCommitRuntime, + }); + } + if (afterCommitRuntime.runtimeProjectionApplyCount !== beforeEditRuntime.runtimeProjectionApplyCount) { + failures.push({ + code: "mindmap_long_text_commit_applied_projection_refresh", + before: beforeEditRuntime, + after: afterCommitRuntime, + }); + } + if (stableJson(afterCommitRuntime.viewTransform) !== stableJson(beforeEditRuntime.viewTransform)) { + failures.push({ + code: "mindmap_long_text_commit_changed_view_transform", + before: beforeEditRuntime, + after: afterCommitRuntime, + }); + } + const postCommitLivePayload = await dispatchSyntheticMindmapTreeSignal(page, documentId, mindmapId, "tree:resync"); + await page.waitForTimeout(2_500); + const afterPostCommitLiveRuntime = await readMindmapRuntimeStabilityState(page, mindmapId); + if (afterPostCommitLiveRuntime.runtimeMountCount !== afterCommitRuntime.runtimeMountCount) { + failures.push({ + code: "mindmap_post_commit_live_remounted_runtime", + before: afterCommitRuntime, + after: afterPostCommitLiveRuntime, + payload: postCommitLivePayload, + }); + } + if (afterPostCommitLiveRuntime.runtimeProjectionApplyCount !== afterCommitRuntime.runtimeProjectionApplyCount) { + failures.push({ + code: "mindmap_post_commit_live_applied_projection_refresh", + before: afterCommitRuntime, + after: afterPostCommitLiveRuntime, + payload: postCommitLivePayload, + }); + } + if (stableJson(afterPostCommitLiveRuntime.viewTransform) !== stableJson(afterCommitRuntime.viewTransform)) { + failures.push({ + code: "mindmap_post_commit_live_changed_view_transform", + before: afterCommitRuntime, + after: afterPostCommitLiveRuntime, + payload: postCommitLivePayload, + }); + } + if (centerDistance(afterCommitRuntime.topicRect, afterPostCommitLiveRuntime.topicRect) > 2) { + failures.push({ + code: "mindmap_post_commit_live_moved_topic_node", + before: afterCommitRuntime, + after: afterPostCommitLiveRuntime, + payload: postCommitLivePayload, + }); + } + return { + beforeEditRuntime, + beforeLive, + afterLive, + committed: true, + longText: longText + secondHalf, + afterCommitRuntime, + afterPostCommitLiveRuntime, + afterCommit: await readPageState(page), + }; +} + +async function waitForPageCondition(page, predicate, timeoutMs = LIVE_WAIT_MS) { + const deadline = Date.now() + timeoutMs; + let last = null; + while (Date.now() < deadline) { + last = await readPageState(page); + if (predicate(last)) { + return { ok: true, state: last }; + } + await page.waitForTimeout(500); + } + return { ok: false, state: last || (await readPageState(page)) }; +} + +function findBadRecord(records) { + return records.find((record) => { + if (record.type === "response" && record.status >= 500) return true; + return BAD_TEXT_PATTERN.test(`${record.responseText || ""}\n${record.text || ""}\n${record.failure || ""}`); + }); +} + +async function main() { + await fs.mkdir(OUTPUT_DIR, { recursive: true }); + const browser = await chromium.launch({ headless: true }); + const contextA = await browser.newContext({ viewport: { width: 1440, height: 960 }, locale: "zh-CN" }); + const contextB = await browser.newContext({ viewport: { width: 1440, height: 960 }, locale: "zh-CN" }); + const pageA = await contextA.newPage(); + const pageB = await contextB.newPage(); + await installTreeEventRecorder(pageA); + await installTreeEventRecorder(pageB); + await installMindmapLoadingRecorder(pageA); + await installMindmapLoadingRecorder(pageB); + const records = []; + attachNetworkCapture(pageA, "browser-a", records); + attachNetworkCapture(pageB, "browser-b", records); + const screenshots = []; + const createdIds = []; + const failures = []; + const result = { + ok: false, + task: TASK, + baseUrl: BASE_URL, + documentId: null, + workspaceId: null, + mindmapId: null, + liveWaitMs: LIVE_WAIT_MS, + failures, + network: records, + screenshots, + }; + + try { + await ensureAuthenticated(pageA, contextA.request); + await ensureAuthenticated(pageB, contextB.request); + + const doc = await createTempDocument(contextA.request, null); + createdIds.push(doc.documentId); + const awayDoc = await createTempDocument(contextA.request, null); + createdIds.push(awayDoc.documentId); + result.documentId = doc.documentId; + result.workspaceId = doc.workspaceId; + await renameDocument(contextA.request, doc.workspaceId, doc.documentId, `task169-mindmap-live-${Date.now().toString().slice(-6)}`); + await renameDocument(contextA.request, awayDoc.workspaceId, awayDoc.documentId, `task169-mindmap-away-${Date.now().toString().slice(-6)}`); + + await openDocument(pageA, doc.workspaceId, doc.documentId); + await openDocument(pageB, doc.workspaceId, doc.documentId); + result.browserBBeforeInsert = await readPageState(pageB); + + await insertMindmapThroughSlash(pageA); + result.mindmapId = await waitForMindmapId(pageA); + result.documentMindmapBlockAfterInsert = await assertDocumentMindmapBlockUsesReferenceSource( + contextA.request, + doc.documentId, + doc.workspaceId, + result.mindmapId, + failures, + "after-insert", + ); + result.fileTreeMindmapOpenAfterInsert = await assertFileTreeMindmapOpenUsesObjectShell( + pageA, + doc.documentId, + result.mindmapId, + failures, + ); + await waitForMindmapReady(pageA, "after-filetree-mindmap-open"); + await pageA.waitForTimeout(1000); + screenshots.push(await screenshot(pageA, "01-browser-a-after-insert")); + result.browserARefreshStabilityAfterInsert = await assertMindmapRuntimeDoesNotRefreshForLiveSignals( + pageA, + doc.documentId, + result.mindmapId, + failures, + "browser-a-after-insert", + ); + + const editedTopicText = `二级节点-LIVE-${Date.now().toString().slice(-6)}`; + result.topicEditAttempt = await editTopicTextThroughRuntime(pageA, result.mindmapId, editedTopicText); + result.browserAAfterTopicEdit = await readPageState(pageA); + screenshots.push(await screenshot(pageA, "03-browser-a-after-topic-edit")); + await openDocument(pageA, awayDoc.workspaceId, awayDoc.documentId); + result.browserAOnAwayDocument = await readPageState(pageA); + await openDocument(pageA, doc.workspaceId, doc.documentId); + await waitForMindmapReady(pageA, "return-after-topic-edit"); + await waitForMindmapProjectionText(contextA.request, doc.documentId, result.mindmapId, editedTopicText); + result.documentMindmapBlockAfterTopicReturn = await assertDocumentMindmapBlockUsesReferenceSource( + contextA.request, + doc.documentId, + doc.workspaceId, + result.mindmapId, + failures, + "after-topic-return", + ); + result.browserAAfterReturnToMindmapDocument = await readPageState(pageA); + result.runtimeTextAfterReturnToMindmapDocument = await readMindmapRuntimeTextState( + pageA, + result.mindmapId, + editedTopicText, + ); + result.projectionAfterReturnToMindmapDocument = await readMindmapProjectionText( + contextA.request, + doc.documentId, + result.mindmapId, + ); + if (!result.runtimeTextAfterReturnToMindmapDocument.includesExpectedText) { + failures.push({ + code: "mindmap_topic_edit_lost_after_page_switch", + expectedText: editedTopicText, + beforeSwitch: result.browserAAfterTopicEdit, + afterReturn: result.browserAAfterReturnToMindmapDocument, + runtimeTextAfterReturn: result.runtimeTextAfterReturnToMindmapDocument, + projectionAfterReturn: result.projectionAfterReturnToMindmapDocument, + }); + } + if (result.browserAAfterReturnToMindmapDocument.mindmapLoadingEvents.length > 0) { + failures.push({ + code: "mindmap_page_switch_showed_runtime_loading", + loadingEvents: result.browserAAfterReturnToMindmapDocument.mindmapLoadingEvents, + afterReturn: result.browserAAfterReturnToMindmapDocument, + }); + } + screenshots.push(await screenshot(pageA, "04-browser-a-after-return-to-mindmap-document")); + const draftTopicText = `草稿切页-LIVE-${Date.now().toString().slice(-6)}`; + result.topicDraftBeforeSwitch = await enterTopicTextDraftWithoutCommit(pageA, result.mindmapId, draftTopicText); + await openDocument(pageA, awayDoc.workspaceId, awayDoc.documentId); + result.browserAOnAwayAfterDraftEdit = await readPageState(pageA); + await openDocument(pageA, doc.workspaceId, doc.documentId); + await waitForMindmapReady(pageA, "return-after-draft-topic-edit"); + await waitForMindmapProjectionText(contextA.request, doc.documentId, result.mindmapId, draftTopicText); + result.documentMindmapBlockAfterDraftReturn = await assertDocumentMindmapBlockUsesReferenceSource( + contextA.request, + doc.documentId, + doc.workspaceId, + result.mindmapId, + failures, + "after-draft-return", + ); + result.runtimeTextAfterDraftReturn = await readMindmapRuntimeTextState(pageA, result.mindmapId, draftTopicText); + if (!result.runtimeTextAfterDraftReturn.includesExpectedText) { + failures.push({ + code: "mindmap_uncommitted_text_edit_lost_after_page_switch", + expectedText: draftTopicText, + beforeSwitch: result.topicDraftBeforeSwitch, + afterReturn: result.runtimeTextAfterDraftReturn, + }); + } + result.browserARefreshStabilityAfterTopicEdit = await assertMindmapRuntimeDoesNotRefreshForLiveSignals( + pageA, + doc.documentId, + result.mindmapId, + failures, + "browser-a-after-topic-edit", + ); + result.longLanguageEdit = await assertLongLanguageEditSurvivesLiveRefresh( + pageA, + contextA.request, + doc.documentId, + result.mindmapId, + failures, + ); + await openDocument(pageA, awayDoc.workspaceId, awayDoc.documentId); + result.indexOpenAfterLongLanguageEdit = await assertFileTreeIndexOpenUsesPageAggregate( + pageA, + doc.documentId, + result.mindmapId, + failures, + ); + result.fileTreeMindmapReopenAfterIndex = await assertFileTreeMindmapOpenUsesObjectShell( + pageA, + doc.documentId, + result.mindmapId, + failures, + ); + if (result.longLanguageEdit && result.longLanguageEdit.longText) { + result.runtimeTextAfterMindmapReopen = await readMindmapRuntimeTextState( + pageA, + result.mindmapId, + result.longLanguageEdit.longText, + ); + if (!result.runtimeTextAfterMindmapReopen.includesExpectedText) { + failures.push({ + code: "mindmap_long_language_text_lost_after_index_roundtrip", + expectedText: result.longLanguageEdit.longText, + indexOpen: result.indexOpenAfterLongLanguageEdit, + reopen: result.fileTreeMindmapReopenAfterIndex, + runtimeTextAfterMindmapReopen: result.runtimeTextAfterMindmapReopen, + }); + } + } + + const badRecord = findBadRecord(records); + if (badRecord) { + failures.push({ code: "mindmap_network_error_or_validator_leak", badRecord }); + } + + result.ok = failures.length === 0; + await writeResult(result); + if (!result.ok) { + throw new Error(`mindmap_realtime_failed:${JSON.stringify(failures, null, 2).slice(0, 6000)}`); + } + } catch (error) { + result.error = error instanceof Error ? error.stack || error.message : String(error); + screenshots.push(await screenshot(pageA, "99-failure-browser-a").catch(() => null)); + screenshots.push(await screenshot(pageB, "99-failure-browser-b").catch(() => null)); + await writeResult(result); + throw error; + } finally { + await cleanupDocuments(contextA.request, createdIds).catch(() => undefined); + await contextA.close().catch(() => undefined); + await contextB.close().catch(() => undefined); + await browser.close(); + } +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/wolai-frontend/convex/_utils/documentVisibility.ts b/wolai-frontend/convex/_utils/documentVisibility.ts new file mode 100644 index 00000000..cd68828f --- /dev/null +++ b/wolai-frontend/convex/_utils/documentVisibility.ts @@ -0,0 +1,117 @@ +export type DocumentVisibilityScope = "private" | "shared" | "public" | null | undefined; + +export type DocumentVisibilityRecord = { + id: string; + user_id?: string | null; + parent_id?: string | null; + access_scope?: DocumentVisibilityScope; + deleted_at?: string | null; +}; + +export type DocumentVisibilityShareRecord = { + document_id: string; + include_descendants?: boolean | null; +}; + +type BuildVisibleDocumentIdsInput = { + userId: string; + docs: readonly DocumentVisibilityRecord[]; + directShares: readonly DocumentVisibilityShareRecord[]; + directGroupShares: readonly DocumentVisibilityShareRecord[]; + includeDeletedDocuments?: boolean; +}; + +function normalizeDocumentId(value: string | null | undefined): string | null { + const trimmed = String(value ?? "").trim(); + return trimmed.length > 0 ? trimmed : null; +} + +function buildInheritedShareMap( + shares: readonly DocumentVisibilityShareRecord[], +): Map { + const result = new Map(); + for (const share of shares) { + const documentId = normalizeDocumentId(share.document_id); + if (!documentId) continue; + const existing = result.get(documentId); + if (!existing) { + result.set(documentId, { + includeDescendants: Boolean(share.include_descendants), + }); + continue; + } + existing.includeDescendants = existing.includeDescendants || Boolean(share.include_descendants); + } + return result; +} + +function canAccessByInheritedShare(input: { + docId: string; + parentById: Map; + directShareMap: Map; + cache: Map; +}): boolean { + const cached = input.cache.get(input.docId); + if (typeof cached === "boolean") return cached; + if (input.directShareMap.has(input.docId)) { + input.cache.set(input.docId, true); + return true; + } + let parentId = input.parentById.get(input.docId) ?? null; + for (let depth = 0; depth < 60 && parentId; depth += 1) { + const parentShare = input.directShareMap.get(parentId); + if (parentShare && parentShare.includeDescendants) { + input.cache.set(input.docId, true); + return true; + } + parentId = input.parentById.get(parentId) ?? null; + } + input.cache.set(input.docId, false); + return false; +} + +export function buildVisibleDocumentIds(input: BuildVisibleDocumentIdsInput): Set { + const candidateDocs = input.includeDeletedDocuments + ? [...input.docs] + : input.docs.filter((doc) => doc.deleted_at == null); + + const parentById = new Map(); + for (const doc of candidateDocs) { + parentById.set(doc.id, normalizeDocumentId(doc.parent_id) ?? null); + } + + const directShares = buildInheritedShareMap(input.directShares); + const directGroupShares = buildInheritedShareMap(input.directGroupShares); + const shareAccessCache = new Map(); + const groupAccessCache = new Map(); + const visible = new Set(); + + for (const doc of candidateDocs) { + if (String(doc.user_id ?? "") === input.userId) { + visible.add(doc.id); + continue; + } + if (doc.access_scope === "public") { + visible.add(doc.id); + continue; + } + if ( + canAccessByInheritedShare({ + docId: doc.id, + parentById, + directShareMap: directShares, + cache: shareAccessCache, + }) || + canAccessByInheritedShare({ + docId: doc.id, + parentById, + directShareMap: directGroupShares, + cache: groupAccessCache, + }) + ) { + visible.add(doc.id); + } + } + + return visible; +} diff --git a/wolai-frontend/convex/mindmaps.ts b/wolai-frontend/convex/mindmaps.ts index 8471c360..d7ebb696 100644 --- a/wolai-frontend/convex/mindmaps.ts +++ b/wolai-frontend/convex/mindmaps.ts @@ -4,13 +4,21 @@ import { requireUserId } from "./_utils/auth"; import { nowIso } from "./_utils/time"; import { enqueueIngestMindmapJob } from "./_utils/ingestJobs"; import { internal } from "./_generated/api"; -import { requireCanonicalOwnedDocument } from "./_utils/documentRecord"; +import { getCanonicalDocumentByBusinessId, requireCanonicalOwnedDocument } from "./_utils/documentRecord"; +import { buildVisibleDocumentIds } from "./_utils/documentVisibility"; const defaultMindmapData = { data: { text: "中心主题" }, children: [], }; +const bridgeArtifactArgs = { + streamDeltaHint: v.optional(v.any()), + domainEventHint: v.optional(v.any()), + domainEventPlan: v.optional(v.any()), + domainEventPlans: v.optional(v.any()), +}; + function resolveGraceSeconds(): number { const raw = process.env.DELETE_GRACE_SECONDS ?? process.env.NEXT_PUBLIC_DELETE_GRACE_SECONDS ?? "600"; const parsed = Number(raw); @@ -31,12 +39,77 @@ async function requireOwnedDocument(ctx: any, userId: string, docId: string) { return await requireCanonicalOwnedDocument(ctx, docId, userId); } +async function requireWorkspaceMember(ctx: any, workspaceId: string, userId: string) { + const membership = await ctx.db + .query("workspace_members") + .withIndex("by_workspace_user", (q: any) => q.eq("workspace_id", workspaceId).eq("user_id", userId)) + .first(); + if (!membership) { + throw new Error("无权操作该工作空间"); + } +} + +async function readWorkspaceVisibilityContext(ctx: any, workspaceId: string, userId: string) { + const docs = await ctx.db + .query("documents") + .withIndex("by_workspace", (q: any) => q.eq("workspace_id", workspaceId)) + .collect(); + + const directShares = await ctx.db + .query("document_shares") + .withIndex("by_workspace_shared_with", (q: any) => + q.eq("workspace_id", workspaceId).eq("shared_with_user_id", userId), + ) + .collect(); + + const groupMemberships = await ctx.db + .query("group_members") + .withIndex("by_workspace_user", (q: any) => q.eq("workspace_id", workspaceId).eq("user_id", userId)) + .collect(); + const groupIds = new Set(groupMemberships.map((item: any) => String(item.group_id))); + + const directGroupShares: Array<{ document_id: string; include_descendants: boolean | null }> = []; + for (const groupId of groupIds) { + const rows = await ctx.db + .query("document_group_shares") + .withIndex("by_workspace_group", (q: any) => q.eq("workspace_id", workspaceId).eq("group_id", groupId)) + .collect(); + for (const row of rows) { + directGroupShares.push({ + document_id: row.document_id, + include_descendants: row.include_descendants, + }); + } + } + + return { docs, directShares, directGroupShares }; +} + +async function requireReadableDocument(ctx: any, userId: string, docId: string) { + const doc = await getCanonicalDocumentByBusinessId(ctx, docId); + if (!doc) { + throw new Error("页面不存在"); + } + await requireWorkspaceMember(ctx, doc.workspace_id, userId); + const visibility = await readWorkspaceVisibilityContext(ctx, doc.workspace_id, userId); + const visibleDocumentIds = buildVisibleDocumentIds({ + userId, + docs: visibility.docs, + directShares: visibility.directShares, + directGroupShares: visibility.directGroupShares, + }); + if (!visibleDocumentIds.has(doc.id)) { + throw new Error("无权限"); + } + return doc; +} + export const get = query({ args: { docId: v.string(), mindmapId: v.string() }, handler: async (ctx, args) => { const userId = await requireUserId(ctx); - const doc = await requireOwnedDocument(ctx, userId, args.docId); + const doc = await requireReadableDocument(ctx, userId, args.docId); const mindmapId = normalizeMindmapId(args.docId, args.mindmapId); const row = await ctx.db @@ -122,6 +195,7 @@ export const put = mutation({ mindmapId: v.string(), data: v.any(), createOnly: v.optional(v.boolean()), + ...bridgeArtifactArgs, }, handler: async (ctx, args) => { const userId = await requireUserId(ctx); @@ -195,7 +269,7 @@ export const put = mutation({ }); export const softDelete = mutation({ - args: { docId: v.string(), mindmapId: v.string() }, + args: { docId: v.string(), mindmapId: v.string(), ...bridgeArtifactArgs }, handler: async (ctx, args) => { const userId = await requireUserId(ctx); @@ -299,7 +373,7 @@ export const purgeIfExpired = internalMutation({ }); export const restore = mutation({ - args: { docId: v.string(), mindmapId: v.string() }, + args: { docId: v.string(), mindmapId: v.string(), ...bridgeArtifactArgs }, handler: async (ctx, args) => { const userId = await requireUserId(ctx); @@ -328,7 +402,7 @@ export const restore = mutation({ }); export const purge = mutation({ - args: { docId: v.string(), mindmapId: v.string() }, + args: { docId: v.string(), mindmapId: v.string(), ...bridgeArtifactArgs }, handler: async (ctx, args) => { const userId = await requireUserId(ctx); @@ -359,14 +433,15 @@ export const listByWorkspace = query({ handler: async (ctx, args) => { const userId = await requireUserId(ctx); - // 说明:阶段 6 先按 membership 存在即可,避免引入复杂权限模型。 - const membership = await ctx.db - .query("workspace_members") - .withIndex("by_workspace_user", (q) => q.eq("workspace_id", args.workspaceId).eq("user_id", userId)) - .first(); - if (!membership) { - throw new Error("无权操作该工作空间"); - } + await requireWorkspaceMember(ctx, args.workspaceId, userId); + const visibility = await readWorkspaceVisibilityContext(ctx, args.workspaceId, userId); + const visibleDocumentIds = buildVisibleDocumentIds({ + userId, + docs: visibility.docs, + directShares: visibility.directShares, + directGroupShares: visibility.directGroupShares, + includeDeletedDocuments: true, + }); const rows = await ctx.db .query("mindmaps") @@ -376,7 +451,7 @@ export const listByWorkspace = query({ const includeDeleted = Boolean(args.includeDeleted); return rows - .filter((r) => r.user_id === userId) + .filter((r) => visibleDocumentIds.has(r.document_id)) .filter((r) => (includeDeleted ? true : r.deleted_at == null)) .sort((a, b) => (b.updated_at ?? "").localeCompare(a.updated_at ?? "")) .map((r) => ({ diff --git a/wolai-frontend/src/app/api/mindmap/[docId]/[mindmapId]/route.ts b/wolai-frontend/src/app/api/mindmap/[docId]/[mindmapId]/route.ts index 4dc6a62d..4af47b8d 100644 --- a/wolai-frontend/src/app/api/mindmap/[docId]/[mindmapId]/route.ts +++ b/wolai-frontend/src/app/api/mindmap/[docId]/[mindmapId]/route.ts @@ -11,15 +11,34 @@ import { import { executeRustBridgeMutationTransport, executeRustBridgeQueryTransport, + recordRustBridgeCommandArtifacts, resolveRustBridgeCommandPlan, resolveRustBridgeQueryPlan, } from "@/lib/documents/rust-runtime"; +import { + applyMetadataOnlyMindmapCommands, + isMetadataOnlyMindmapCommandSet, +} from "@/lib/mindmap/mindmap-command-apply-local"; const defaultMindmapData = { data: { text: "中心主题" }, children: [], }; +async function recordMindmapCommandSuccess(args: { + context: ReturnType; + envelope: ReturnType; + client: Awaited>["client"]; + plan: Awaited>; + result: unknown; +}) { + try { + await recordRustBridgeCommandArtifacts(args); + } catch (error) { + console.warn("[mindmap-route] Rust bridge success artifacts skipped:", error); + } +} + export async function GET( request: Request, { params }: { params: Promise<{ docId: string; mindmapId: string }> }, @@ -132,6 +151,81 @@ export async function POST( }, }); const isCommandApply = commandName === "mindmap.command.apply"; + const isMetadataOnlyCommandApply = isCommandApply && isMetadataOnlyMindmapCommandSet(Array.isArray(commands) ? commands : []); + if (isMetadataOnlyCommandApply) { + const currentEnvelope = buildDocumentQueryEnvelope({ + name: "mindmaps.get", + payload: { + documentId: docId, + mindmapId, + workspaceId: null, + }, + }); + const currentPlan = await resolveRustBridgeQueryPlan({ context, envelope: currentEnvelope }); + const currentResult = await executeRustBridgeQueryTransport<{ data?: unknown }>({ + client, + plan: currentPlan, + }); + const applied = applyMetadataOnlyMindmapCommands(currentResult?.data ?? defaultMindmapData, commands); + if (applied.errors.length > 0) { + return NextResponse.json( + { + error: "mindmap_command_apply_failed", + details: applied.errors, + }, + { status: 400 }, + ); + } + const putEnvelope = buildDocumentCommandEnvelope({ + name: "mindmaps.put", + payload: { + documentId: docId, + mindmapId, + data: applied.data, + createOnly: false, + }, + context, + target: { + workspaceId: null, + pageId: docId, + blockId: mindmapId, + }, + reason: "mindmap-route:command-apply-metadata-fallback", + refs: ["task-166", "mindmap-command-bridge", "mindmap-metadata-fallback"], + }); + const putPlan = await resolveRustBridgeCommandPlan({ context, envelope: putEnvelope }); + const result = await executeRustBridgeMutationTransport<{ + ok?: boolean; + workspace_id?: string | null; + updated_at?: string | null; + }>({ + client, + plan: putPlan, + }); + await recordMindmapCommandSuccess({ + context, + envelope: putEnvelope, + client, + plan: putPlan, + result, + }); + return NextResponse.json({ + ...(result ?? { ok: true }), + commandName: "mindmap.command.apply", + applied: applied.applied, + errors: applied.errors, + projectionRevision: typeof projectionRevision === "number" ? projectionRevision : null, + meta: { + ...buildMindmapRouteMeta(request, { + workspaceId: result?.workspace_id ?? null, + documentId: docId, + mindmapId, + ownerUserId: auth.userId, + }), + updatedAt: result?.updated_at ?? null, + }, + }); + } const envelope = buildDocumentCommandEnvelope({ name: isCommandApply ? "mindmap.command.apply" : "mindmaps.put", payload: isCommandApply @@ -166,6 +260,13 @@ export async function POST( client, plan, }); + await recordMindmapCommandSuccess({ + context, + envelope, + client, + plan, + result, + }); return NextResponse.json({ ...(result ?? { ok: true }), meta: { @@ -232,6 +333,13 @@ export async function DELETE( client, plan, }); + await recordMindmapCommandSuccess({ + context, + envelope, + client, + plan, + result, + }); return NextResponse.json({ ...(result ?? { ok: true }), meta: { @@ -303,6 +411,13 @@ export async function PATCH( client, plan, }); + await recordMindmapCommandSuccess({ + context, + envelope, + client, + plan, + result, + }); return NextResponse.json({ ...(result ?? { ok: true }), meta: { diff --git a/wolai-frontend/src/components/editor/blocks/MindmapBlock.tsx b/wolai-frontend/src/components/editor/blocks/MindmapBlock.tsx index 4c22e100..496fca94 100644 --- a/wolai-frontend/src/components/editor/blocks/MindmapBlock.tsx +++ b/wolai-frontend/src/components/editor/blocks/MindmapBlock.tsx @@ -49,6 +49,7 @@ import { type MindmapProjection, type MindmapRouteMeta, } from "@/lib/mindmap/mindmap-projection"; +import { buildInitialMindmapAssetRefreshPayload } from "@/lib/mindmap/mindmap-initial-sync"; // 避免 SSR/Node 环境提前评估 simple-mind-map 内部依赖 document const loadIconModules = async () => { @@ -1588,14 +1589,15 @@ const MindmapSurfaceView = ({ }, [persistData]); const initialSyncDone = useRef(false); - useEffect(() => { - if (!docId || !mindmap || initialSyncDone.current) return; - initialSyncDone.current = true; - const data = canonicalizeMindmapData( - mindmap.getData?.(true) ?? mindmap.getData?.() ?? initialDataRef.current ?? defaultMindmapData, - ); - (async () => { - try { + useEffect(() => { + if (!docId || !mindmap || initialSyncDone.current) return; + initialSyncDone.current = true; + const data = canonicalizeMindmapData( + mindmap.getData?.(true) ?? mindmap.getData?.() ?? initialDataRef.current ?? defaultMindmapData, + ); + (async () => { + let refreshPayload: ReturnType = null; + try { const resp = await fetch(`/api/mindmap/${docId}/${mindmapId}`, { method: "POST", headers: { "Content-Type": "application/json" }, @@ -1605,19 +1607,18 @@ const MindmapSurfaceView = ({ } else { const payload = (await resp.json().catch(() => null)) as { meta?: MindmapRouteMeta } | null; syncMindmapRouteMeta(payload?.meta); + refreshPayload = buildInitialMindmapAssetRefreshPayload({ + ok: true, + docId, + mindmapId, + }); } } catch {} finally { - // 即便远端失败,也通知侧边栏刷新,保证本地文件树及时更新 - const fileName = `mindmap-${mindmapId}.json`; - emitAssetsChanged(docId, { - id: mindmapId, - document_id: docId, - asset_type: "mindmap", - file_name: fileName, - file_url: `/documents/${docId}/${fileName}`, - }); - } - })(); + if (refreshPayload) { + emitAssetsChanged(docId, refreshPayload); + } + } + })(); }, [docId, mindmap, mindmapId, syncMindmapRouteMeta]); // 初始选中根节点,后续不强制抢焦点,允许用户自由选择 diff --git a/wolai-frontend/src/components/sidebar/asset-context-menu-source.test.ts b/wolai-frontend/src/components/sidebar/asset-context-menu-source.test.ts new file mode 100644 index 00000000..ae5ce7f9 --- /dev/null +++ b/wolai-frontend/src/components/sidebar/asset-context-menu-source.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from "vitest"; +import fs from "node:fs"; +import path from "node:path"; + +const ASSET_CONTEXT_MENU_SOURCE = path.join(process.cwd(), "src/components/sidebar/asset-context-menu.tsx"); + +describe("asset context menu source", () => { + it("删除按钮应把删除语义交给外层,而不是在菜单内硬编码单项 asset id", () => { + const source = fs.readFileSync(ASSET_CONTEXT_MENU_SOURCE, "utf8"); + + expect(source).toContain("onDelete: () => void;"); + expect(source).toContain("onClick={() => onDelete()}"); + expect(source).not.toContain("onDelete: (assetIds: string[]) => void;"); + expect(source).not.toContain("onClick={() => onDelete([asset.id])}"); + }); +}); diff --git a/wolai-frontend/src/components/sidebar/asset-context-menu.tsx b/wolai-frontend/src/components/sidebar/asset-context-menu.tsx index 19950d49..2093d318 100644 --- a/wolai-frontend/src/components/sidebar/asset-context-menu.tsx +++ b/wolai-frontend/src/components/sidebar/asset-context-menu.tsx @@ -1,22 +1,21 @@ -"use client"; - -import { useEffect, useLayoutEffect, useRef, useState } from "react"; -import { Copy, Download, Hash, Link as LinkIcon, Move, PenLine, Trash2 } from "lucide-react"; -import type { MediaAsset } from "@/types/media"; -import { cn } from "@/lib/utils"; - -interface AssetContextMenuProps { - asset: MediaAsset; - position: { x: number; y: number }; - onClose: () => void; +"use client"; + +import { useEffect, useLayoutEffect, useRef, useState } from "react"; +import { Copy, Download, Hash, Link as LinkIcon, Move, PenLine, Trash2 } from "lucide-react"; +import type { MediaAsset } from "@/types/media"; + +interface AssetContextMenuProps { + asset: MediaAsset; + position: { x: number; y: number }; + onClose: () => void; onOpen: (asset: MediaAsset) => void; - onCopyLink: (asset: MediaAsset) => void; - onCopyPath: (asset: MediaAsset) => void; - onRename: (asset: MediaAsset) => void; - onMove: (asset: MediaAsset) => void; - onDelete: (assetIds: string[]) => void; - onDownload: (asset: MediaAsset) => void; -} + onCopyLink: (asset: MediaAsset) => void; + onCopyPath: (asset: MediaAsset) => void; + onRename: (asset: MediaAsset) => void; + onMove: (asset: MediaAsset) => void; + onDelete: () => void; + onDownload: (asset: MediaAsset) => void; +} export function AssetContextMenu({ asset, @@ -93,14 +92,14 @@ export function AssetContextMenu({ 移动到... - +
    ); } diff --git a/wolai-frontend/src/components/sidebar/sidebar-delete-preflight-source.test.ts b/wolai-frontend/src/components/sidebar/sidebar-delete-preflight-source.test.ts index d04c78a3..2aae91fc 100644 --- a/wolai-frontend/src/components/sidebar/sidebar-delete-preflight-source.test.ts +++ b/wolai-frontend/src/components/sidebar/sidebar-delete-preflight-source.test.ts @@ -12,4 +12,20 @@ describe("sidebar file tree delete preflight source", () => { expect(source).toContain("buildFileTreeShellDeletePreflightPayload("); expect(source).not.toContain("computeFileTreeShellDeleteTargets("); }); + + it("filetree DOM host 删除回调应直连 sidebar 删除入口", () => { + const source = fs.readFileSync(SIDEBAR_SOURCE, "utf8"); + + expect(source).toContain("const handleFileTreeShellDeleteSelection = useCallback("); + expect(source).toContain("void handleDeleteResourceSelection(payload);"); + expect(source).toContain("onFileTreeDeleteSelection={handleFileTreeShellDeleteSelection}"); + }); + + it("附件右键菜单删除应复用当前文件树 selection 删除入口", () => { + const source = fs.readFileSync(SIDEBAR_SOURCE, "utf8"); + + expect(source).toContain("const handleDeleteFromAssetContextMenu = useCallback("); + expect(source).toContain('if (viewMode === "filesystem") {'); + expect(source).toContain("await handleDeleteResourceSelection();"); + }); }); diff --git a/wolai-frontend/src/components/sidebar/sidebar-navigation.test.ts b/wolai-frontend/src/components/sidebar/sidebar-navigation.test.ts index 64554e8b..134a42ea 100644 --- a/wolai-frontend/src/components/sidebar/sidebar-navigation.test.ts +++ b/wolai-frontend/src/components/sidebar/sidebar-navigation.test.ts @@ -1,5 +1,8 @@ import { describe, expect, it } from "vitest"; -import { buildSidebarDocumentOpenTarget } from "./sidebar-navigation"; +import { + buildSidebarDocumentOpenTarget, + buildSidebarMindmapOpenTarget, +} from "./sidebar-navigation"; describe("sidebar-navigation", () => { it("页面树普通打开应留在当前窗口", () => { @@ -15,4 +18,18 @@ describe("sidebar-navigation", () => { url: "http://127.0.0.1:3000/documents/doc_1?preview=sidebar", }); }); + + it("文件树里的 mindmap 主打开应进入 mindmap 对象编辑页", () => { + expect(buildSidebarMindmapOpenTarget("doc_1", "mind_1", "main", "http://127.0.0.1:3000")).toEqual({ + kind: "same-window", + path: "/mindmap/doc_1/mind_1", + }); + }); + + it("显式新标签打开 mindmap 也应使用同一对象编辑页", () => { + expect(buildSidebarMindmapOpenTarget("doc_1", "mind_1", "sidebar", "http://127.0.0.1:3000")).toEqual({ + kind: "new-window", + url: "http://127.0.0.1:3000/mindmap/doc_1/mind_1", + }); + }); }); diff --git a/wolai-frontend/src/components/sidebar/sidebar-navigation.ts b/wolai-frontend/src/components/sidebar/sidebar-navigation.ts index 525e9b37..58dd06d4 100644 --- a/wolai-frontend/src/components/sidebar/sidebar-navigation.ts +++ b/wolai-frontend/src/components/sidebar/sidebar-navigation.ts @@ -17,3 +17,18 @@ export function buildSidebarDocumentOpenTarget( const base = origin ? `${origin}${path}` : path; return { kind: "new-window", url: `${base}?preview=sidebar` }; } + +export function buildSidebarMindmapOpenTarget( + documentId: string, + mindmapId: string, + mode: SidebarDocumentOpenMode, + origin?: string | null, +): SidebarDocumentOpenTarget { + const path = `/mindmap/${documentId}/${mindmapId}`; + if (mode === "main") { + return { kind: "same-window", path }; + } + + const url = origin ? `${origin}${path}` : path; + return { kind: "new-window", url }; +} diff --git a/wolai-frontend/src/components/sidebar/sidebar.tsx b/wolai-frontend/src/components/sidebar/sidebar.tsx index 95a8c2a0..33d8fcd6 100644 --- a/wolai-frontend/src/components/sidebar/sidebar.tsx +++ b/wolai-frontend/src/components/sidebar/sidebar.tsx @@ -107,6 +107,7 @@ import { } from "@/components/sidebar/tree-pane-bindings"; import { buildSidebarDocumentOpenTarget, + buildSidebarMindmapOpenTarget, type SidebarDocumentOpenMode, } from "@/components/sidebar/sidebar-navigation"; import type { MediaAsset } from "@/types/media"; @@ -290,6 +291,9 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar const mindmapAssetsSyncKeyRef = useRef(buildMediaAssetListSyncKey(sidebarData.mindmapAssets ?? [])); const tableAssetsSyncKeyRef = useRef(buildMediaAssetListSyncKey(sidebarData.tableAssets ?? [])); const pageTreeFocusedDocumentIdRef = useRef(activeId || null); + const resourceRendererSelectionRef = useRef( + createEmptyFileTreeSelectionState(), + ); const resourcePaneContainerRef = useRef(null); const creatingDocumentUnderParentRef = useRef>(new Set()); @@ -870,10 +874,18 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar }); }, []); - const handleOpenAsset = useCallback((asset: MediaAsset) => { + const handleOpenAssetInMain = useCallback((asset: MediaAsset) => { if (asset.asset_type === "mindmap") { - router.push(`/mindmap/${asset.document_id}/${asset.id}`); - setOpen(false); + const target = buildSidebarMindmapOpenTarget( + asset.document_id, + asset.id, + "main", + typeof window !== "undefined" ? window.location.origin : null, + ); + if (target.kind === "same-window") { + router.push(target.path); + setOpen(false); + } return; } if (asset.asset_type === "luckysheet") { @@ -949,6 +961,32 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar })(); }, [activeId, editorBridge, router, setOpen]); + const handleOpenAssetInNewTab = useCallback((asset: MediaAsset) => { + if (asset.asset_type === "mindmap") { + const target = buildSidebarMindmapOpenTarget( + asset.document_id, + asset.id, + "sidebar", + typeof window !== "undefined" ? window.location.origin : null, + ); + if (target.kind === "new-window" && typeof window !== "undefined") { + window.open(target.url, "_blank", "noopener,noreferrer"); + setOpen(false); + } + return; + } + + if (asset.asset_type === "luckysheet") { + if (typeof window !== "undefined") { + window.open(buildTableUrl(asset.id), "_blank", "noopener,noreferrer"); + } + setOpen(false); + return; + } + + void handleOpenAssetInMain(asset); + }, [handleOpenAssetInMain, setOpen]); + const handleResourcePaneBlankMouseDown = useCallback(() => { setLegacyResourceSelection((prev) => reduceTreePaneSelection(prev, { type: "clear" })); }, []); @@ -998,12 +1036,12 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar const handleResourceRowDoubleClick = useCallback( (row: TreePaneRow, _event?: React.MouseEvent) => { if (row.kind === "asset" || row.kind === "asset-folder") { - handleOpenAsset(row.asset); + handleOpenAssetInMain(row.asset); return; } handleOpenDocument(row.docId, "main"); }, - [handleOpenAsset, handleOpenDocument], + [handleOpenAssetInMain, handleOpenDocument], ); const handleResourceRowContextMenu = useCallback( @@ -1129,12 +1167,12 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar anchorRowId: string | null; focusedRowId: string | null; }) => { - setResourceRendererSelection( - materializeRendererSelectionSnapshot({ - payload, - hasRowId: (rowId) => resourceShellRowById.has(rowId), - }), - ); + const nextSelection = materializeRendererSelectionSnapshot({ + payload, + hasRowId: (rowId) => resourceShellRowById.has(rowId), + }); + resourceRendererSelectionRef.current = nextSelection; + setResourceRendererSelection(nextSelection); }, [resourceShellRowById], ); @@ -1145,9 +1183,9 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar if (!asset) { return; } - handleOpenAsset(asset); + handleOpenAssetInMain(asset); }, - [assetById, handleOpenAsset], + [assetById, handleOpenAssetInMain], ); const handleTreeShellMutation = useCallback(() => { @@ -1581,8 +1619,22 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar [mediaAssets, mindmapAssets, refreshTree, tableAssets], ); - const handleDeleteResourceSelection = useCallback(async () => { - const selectedRowIds = Array.from(resourceSelection.selectedRowIds); + const handleDeleteResourceSelection = useCallback(async (selectionOverride?: { + selectedRowIds: string[]; + anchorRowId: string | null; + focusedRowId: string | null; + }) => { + const effectiveSelection = + selectionOverride + ? { + selectedRowIds: new Set(selectionOverride.selectedRowIds), + anchorRowId: selectionOverride.anchorRowId, + focusedRowId: selectionOverride.focusedRowId, + } + : isRustFamilyTreeRenderer + ? resourceRendererSelectionRef.current + : resourceSelection; + const selectedRowIds = Array.from(effectiveSelection.selectedRowIds); let shellDeleteTargets: { docIds: string[]; assetIds: string[]; @@ -1614,7 +1666,7 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar const legacyDeleteTargets = !isRustFamilyTreeRenderer ? computeTreePaneDeleteTargets({ visibleRows: resourceRows, - selectedRowIds: resourceSelection.selectedRowIds, + selectedRowIds: effectiveSelection.selectedRowIds, parentById: docParentById, }) : null; @@ -1636,10 +1688,10 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar const selectedAssetHints = shellDeleteTargets?.assetHints ?? - Array.from( + Array.from( new Map( resourceRows - .filter((row) => resourceSelection.selectedRowIds.has(row.rowId)) + .filter((row) => effectiveSelection.selectedRowIds.has(row.rowId)) .filter(isAssetRow) .map((row) => [row.asset.id, row.asset] as const), ).values(), @@ -1706,13 +1758,24 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar isRustFamilyTreeRenderer, resourceRows, resourceShellRowById, - resourceSelection.selectedRowIds, + resourceSelection, handleDeleteAssets, refreshTree, router, sidebarData.activeWorkspaceId, ]); + const handleFileTreeShellDeleteSelection = useCallback( + (payload: { + selectedRowIds: string[]; + anchorRowId: string | null; + focusedRowId: string | null; + }) => { + void handleDeleteResourceSelection(payload); + }, + [handleDeleteResourceSelection], + ); + const handleResizeStart = useCallback( (event: React.MouseEvent) => { event.preventDefault(); @@ -2116,43 +2179,12 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar [handleDelete, handleDeleteResourceSelection, viewMode], ); - const handleDeleteFromAssetContextMenu = useCallback( - async (assetIds: string[], assetHint?: MediaAsset) => { - const uniqueAssetIds = Array.from(new Set(assetIds)); - if (uniqueAssetIds.length === 0) return; - - const assets = uniqueAssetIds - .map((id) => mediaAssets.find((item) => item.id === id) ?? mindmapAssets.find((item) => item.id === id) ?? tableAssets.find((item) => item.id === id)) - .filter(Boolean) as MediaAsset[]; - if (assetHint && !assets.find((item) => item.id === assetHint.id)) { - assets.unshift(assetHint); - } - - const mindmapCount = assets.filter((item) => item.asset_type === "mindmap").length; - const tableCount = assets.filter((item) => item.asset_type === "luckysheet").length; - const fileCount = assets.filter((item) => item.asset_type !== "mindmap" && item.asset_type !== "luckysheet").length; - const unknownCount = Math.max(0, uniqueAssetIds.length - mindmapCount - tableCount - fileCount); - - const parts: string[] = []; - if (fileCount > 0) parts.push(`${fileCount} 个附件(删除,10 分钟内可撤销)`); - if (mindmapCount > 0) parts.push(`${mindmapCount} 个思维导图(删除)`); - if (tableCount > 0) parts.push(`${tableCount} 个在线表格(删除)`); - if (unknownCount > 0) parts.push(`${unknownCount} 个对象(删除)`); - - const ok = window.confirm(`确认删除选中的 ${parts.join(" + ")} 吗?`); - if (!ok) return; - - try { - await handleDeleteAssets(uniqueAssetIds, assetHint); - if (!isRustFamilyTreeRenderer) { - setLegacyResourceSelection((prev) => reduceTreePaneSelection(prev, { type: "clear" })); - } - } catch (error) { - window.alert(error instanceof Error ? error.message : "删除失败"); - } - }, - [handleDeleteAssets, isRustFamilyTreeRenderer, mediaAssets, mindmapAssets, tableAssets], - ); + const handleDeleteFromAssetContextMenu = useCallback(async () => { + if (viewMode === "filesystem") { + await handleDeleteResourceSelection(); + return; + } + }, [handleDeleteResourceSelection, viewMode]); const handleConvertToChild = useCallback( async (documentId: string) => { @@ -2889,6 +2921,7 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar onNavigate={handleFileTreeShellNavigate} onFileTreeContextMenu={handleFileTreeShellContextMenu} onFileTreeSelectionChange={handleFileTreeShellSelectionChange} + onFileTreeDeleteSelection={handleFileTreeShellDeleteSelection} onAssetOpen={handleFileTreeShellAssetOpen} onTreeMutation={handleTreeShellMutation} /> @@ -3029,12 +3062,12 @@ function SidebarContent({ initialData, sidebarData: externalSidebarData, sidebar asset={assetMenu.asset} position={{ x: assetMenu.x, y: assetMenu.y }} onClose={() => setAssetMenu(null)} - onOpen={handleOpenAsset} + onOpen={handleOpenAssetInNewTab} onCopyLink={handleCopyAssetLink} onCopyPath={handleCopyAssetPath} onRename={handleRenameAsset} onMove={handleMoveAsset} - onDelete={(assetIds) => void handleDeleteFromAssetContextMenu(assetIds, assetMenu.asset)} + onDelete={() => void handleDeleteFromAssetContextMenu()} onDownload={handleDownloadAsset} /> )} diff --git a/wolai-frontend/src/components/sidebar/tree-shell-dom-host.tsx b/wolai-frontend/src/components/sidebar/tree-shell-dom-host.tsx index 831786e5..5b7b4610 100644 --- a/wolai-frontend/src/components/sidebar/tree-shell-dom-host.tsx +++ b/wolai-frontend/src/components/sidebar/tree-shell-dom-host.tsx @@ -12,11 +12,16 @@ import { type TreeShellPickerItem, } from "@/components/sidebar/tree-shell-dom-model"; import type { + FileTreeShellDeleteSelectionPayload, FileTreeShellExternalDropPayload, FileTreeShellInternalDropPayload, TreeShellHostMode, TreeShellPickerCommand, } from "@/components/sidebar/tree-shell-host"; +import { + normalizeFileTreeSelectionForVisibleRows as normalizeVisibleFileTreeSelection, + reduceFileTreeSelection, +} from "@/lib/file-tree/selection"; import type { KernelFileTreeProjectionItem } from "@/lib/kernel-file-tree"; import type { PageTreeProjectionItem } from "@/lib/tree-projection"; import { cn } from "@/lib/utils"; @@ -91,6 +96,7 @@ type TreeShellRustDomShellHostProps = { anchorRowId: string | null; focusedRowId: string | null; }) => void; + onFileTreeDeleteSelection?: (payload: FileTreeShellDeleteSelectionPayload) => void; onInternalDrop?: (payload: FileTreeShellInternalDropPayload) => void; onDropFiles?: (payload: FileTreeShellExternalDropPayload) => void; onAssetOpen?: (payload: { assetId: string; documentId: string | null }) => void; @@ -201,6 +207,35 @@ function normalizeRuntimeState(result: TreeShellRuntimeResult | null, mode: " return result.state.state as T; } +function areFileTreeSelectionsEqual( + left: FileTreeRuntimeState["selection"], + right: FileTreeRuntimeState["selection"], +) { + if (left.anchorRowId !== right.anchorRowId || left.focusedRowId !== right.focusedRowId) { + return false; + } + if (left.selectedRowIds.length !== right.selectedRowIds.length) { + return false; + } + return left.selectedRowIds.every((rowId, index) => rowId === right.selectedRowIds[index]); +} + +function toLocalSelectionState(selection: FileTreeRuntimeState["selection"]) { + return { + selectedRowIds: new Set(selection.selectedRowIds), + anchorRowId: selection.anchorRowId, + focusedRowId: selection.focusedRowId, + }; +} + +function fromLocalSelectionState(selection: ReturnType) { + return { + selectedRowIds: Array.from(selection.selectedRowIds), + anchorRowId: selection.anchorRowId, + focusedRowId: selection.focusedRowId, + }; +} + async function loadTreeShellRuntimeWasm() { if (!treeShellRuntimeWasmPromise) { treeShellRuntimeWasmPromise = (async () => { @@ -271,6 +306,7 @@ export function TreeShellRustDomShellHost({ onPageFocusChange, onFileTreeContextMenu, onFileTreeSelectionChange, + onFileTreeDeleteSelection, onInternalDrop, onDropFiles, onAssetOpen, @@ -295,6 +331,9 @@ export function TreeShellRustDomShellHost({ activeItemKey: activePickerItemKey, })); const pickerCommandSeqRef = useRef(null); + const fileTreeStateRef = useRef(fileTreeState); + const fileTreeSelectionVersionRef = useRef(0); + const fileTreeSelectionInitializedRef = useRef(false); const pageItems = useMemo(() => { if (mode !== "page") return []; @@ -319,10 +358,7 @@ export function TreeShellRustDomShellHost({ () => new Map(items.map((item) => [item.nodeId, item])), [items], ); - const filetreeItemByRowId = useMemo( - () => new Map(fileTreeItems.map((item) => [toRowId(item), item])), - [fileTreeItems], - ); + const visibleFileTreeRowIds = useMemo(() => fileTreeItems.map(toRowId), [fileTreeItems]); const visiblePageItems = useMemo(() => { const expanded = new Set(pageState.expandedIds); const visible: TreeShellDomProjectionItem[] = []; @@ -426,8 +462,55 @@ export function TreeShellRustDomShellHost({ [childrenByParent, pageItems, pageState, reduceRuntime, visiblePageItems], ); + useEffect(() => { + fileTreeStateRef.current = fileTreeState; + }, [fileTreeState]); + + const updateFileTreeState = useCallback( + (updater: (prev: FileTreeRuntimeState) => FileTreeRuntimeState) => { + let nextStateSnapshot = fileTreeStateRef.current; + setFileTreeState((prev) => { + const nextState = updater(prev); + nextStateSnapshot = nextState; + fileTreeStateRef.current = nextState; + return nextState; + }); + return nextStateSnapshot; + }, + [], + ); + + const commitFileTreeSelection = useCallback( + (nextSelection: FileTreeRuntimeState["selection"]) => { + let changed = false; + const nextState = updateFileTreeState((prev) => { + if (areFileTreeSelectionsEqual(prev.selection, nextSelection)) { + return prev; + } + changed = true; + return { + ...prev, + selection: nextSelection, + }; + }); + fileTreeSelectionInitializedRef.current = true; + if (changed) { + fileTreeSelectionVersionRef.current += 1; + onFileTreeSelectionChange?.(nextSelection); + } + return nextState; + }, + [onFileTreeSelectionChange, updateFileTreeState], + ); + + const readFileTreeState = useCallback(() => fileTreeStateRef.current, []); + const reduceFileTreeAction = useCallback( - async (action: Record, stateSnapshot: FileTreeRuntimeState = fileTreeState) => { + async ( + action: Record, + stateSnapshot: FileTreeRuntimeState = readFileTreeState(), + options?: { selectionVersion?: number }, + ) => { const requestId = `filetree-${Date.now()}-${Math.random().toString(36).slice(2)}`; const result = await reduceRuntime({ mode: "fileTree", @@ -446,13 +529,20 @@ export function TreeShellRustDomShellHost({ }); const nextState = normalizeRuntimeState(result, "fileTree"); if (nextState) { - setFileTreeState(nextState); - onFileTreeSelectionChange?.(nextState.selection); - return { result, state: nextState }; + const shouldApplySelection = + options?.selectionVersion === undefined || options.selectionVersion === fileTreeSelectionVersionRef.current; + const mergedState = updateFileTreeState((prev) => ({ + ...nextState, + selection: shouldApplySelection ? nextState.selection : prev.selection, + })); + if (shouldApplySelection && !areFileTreeSelectionsEqual(stateSnapshot.selection, mergedState.selection)) { + onFileTreeSelectionChange?.(mergedState.selection); + } + return { result, state: mergedState }; } return { result: null, state: stateSnapshot }; }, - [fileTreeItems, fileTreeState, onFileTreeSelectionChange, reduceRuntime], + [fileTreeItems, onFileTreeSelectionChange, readFileTreeState, reduceRuntime, updateFileTreeState], ); const reducePickerAction = useCallback( @@ -645,15 +735,25 @@ export function TreeShellRustDomShellHost({ useEffect(() => { if (mode !== "filetree") return; const selection = buildTreeShellDomFiletreeSelection(activeDocumentId); - setFileTreeState({ + const shouldBackfillSelection = + !fileTreeSelectionInitializedRef.current || readFileTreeState().selection.selectedRowIds.length === 0; + if (shouldBackfillSelection) { + commitFileTreeSelection(selection); + } + updateFileTreeState((prev) => ({ + ...prev, activeRowId: activeDocumentId ? `index:${activeDocumentId}` : null, - selection, - dragRowIds: [], - dragEffect: null, - dropTargetRowId: null, - }); - onFileTreeSelectionChange?.(selection); - }, [activeDocumentId, mode, onFileTreeSelectionChange]); + selection: shouldBackfillSelection ? selection : prev.selection, + })); + }, [activeDocumentId, commitFileTreeSelection, mode, readFileTreeState, updateFileTreeState]); + + useEffect(() => { + if (mode !== "filetree") return; + const normalizedSelection = fromLocalSelectionState( + normalizeVisibleFileTreeSelection(toLocalSelectionState(readFileTreeState().selection), visibleFileTreeRowIds), + ); + commitFileTreeSelection(normalizedSelection); + }, [commitFileTreeSelection, mode, readFileTreeState, visibleFileTreeRowIds]); useEffect(() => { if (mode !== "picker") return; @@ -837,8 +937,17 @@ export function TreeShellRustDomShellHost({ async (item: TreeShellDomProjectionItem, event: MouseEvent) => { event.preventDefault(); const rowId = toRowId(item); - const { state } = await reduceFileTreeAction({ kind: "selectContextRow", rowId }); - const { result } = await reduceFileTreeAction({ kind: "contextMenuRow", rowId }, state); + const state = commitFileTreeSelection( + fromLocalSelectionState( + reduceFileTreeSelection(toLocalSelectionState(readFileTreeState().selection), { + type: "contextmenu", + rowId, + }), + ), + ); + const selectionVersion = fileTreeSelectionVersionRef.current; + void reduceFileTreeAction({ kind: "selectContextRow", rowId }, state, { selectionVersion }); + const { result } = await reduceFileTreeAction({ kind: "contextMenuRow", rowId }, state, { selectionVersion }); applyFileTreeHostEvents(result?.hostEvents, { rowId, rowKind: toShellRowKind(item), @@ -846,13 +955,28 @@ export function TreeShellRustDomShellHost({ y: event.clientY, }); }, - [applyFileTreeHostEvents, reduceFileTreeAction], + [applyFileTreeHostEvents, commitFileTreeSelection, readFileTreeState, reduceFileTreeAction], ); const handleFileTreeSelect = useCallback( - async (item: TreeShellDomProjectionItem, event: MouseEvent) => { + (item: TreeShellDomProjectionItem, event: MouseEvent) => { const rowId = toRowId(item); - await reduceFileTreeAction({ + const state = commitFileTreeSelection( + fromLocalSelectionState( + reduceFileTreeSelection(toLocalSelectionState(readFileTreeState().selection), { + type: "click", + rowId, + visibleRowIds: visibleFileTreeRowIds, + modifiers: { + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }, + }), + ), + ); + const selectionVersion = fileTreeSelectionVersionRef.current; + void reduceFileTreeAction({ kind: "selectRow", rowId, modifiers: { @@ -860,9 +984,9 @@ export function TreeShellRustDomShellHost({ ctrlKey: event.ctrlKey, metaKey: event.metaKey, }, - }); + }, state, { selectionVersion }); }, - [reduceFileTreeAction], + [commitFileTreeSelection, readFileTreeState, reduceFileTreeAction, visibleFileTreeRowIds], ); const handleFileTreeKeyDown = useCallback( @@ -889,11 +1013,16 @@ export function TreeShellRustDomShellHost({ if (!action) return; event.preventDefault(); const rowId = toRowId(item); + const currentFileTreeState = readFileTreeState(); + if (action.kind === "deleteSelection") { + onFileTreeDeleteSelection?.(currentFileTreeState.selection); + return; + } const { result } = await reduceFileTreeAction(action, { - ...fileTreeState, + ...currentFileTreeState, selection: { - ...fileTreeState.selection, - focusedRowId: fileTreeState.selection.focusedRowId ?? rowId, + ...currentFileTreeState.selection, + focusedRowId: currentFileTreeState.selection.focusedRowId ?? rowId, }, }); applyFileTreeHostEvents(result?.hostEvents, { @@ -901,7 +1030,7 @@ export function TreeShellRustDomShellHost({ rowKind: toShellRowKind(item), }); }, - [applyFileTreeHostEvents, fileTreeState, reduceFileTreeAction], + [applyFileTreeHostEvents, onFileTreeDeleteSelection, readFileTreeState, reduceFileTreeAction], ); const handleFileTreeDrop = useCallback( @@ -1095,7 +1224,11 @@ export function TreeShellRustDomShellHost({ data-testid="filetree-action-menu" aria-label="更多操作" className="rounded-md px-1 text-gray-400 hover:bg-gray-100 hover:text-gray-700" - onClick={(event) => void handleFileTreeContextMenu(item, event)} + onClick={(event) => { + event.preventDefault(); + event.stopPropagation(); + void handleFileTreeContextMenu(item, event); + }} > … diff --git a/wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx b/wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx index 892627e6..de23d0e1 100644 --- a/wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx +++ b/wolai-frontend/src/components/sidebar/tree-shell-host.test.tsx @@ -1,14 +1,23 @@ import { act } from "react"; import { createRoot, type Root } from "react-dom/client"; -import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { TreeShellRustDomShellHost } from "./tree-shell-dom-host"; import { TreeShellHost } from "./tree-shell-host"; +import type { KernelFileTreeProjectionItem } from "@/lib/kernel-file-tree"; (globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; +type PendingRuntimeRequest = { + request: Record; + resolve: (runtimeResult?: Record | null) => void; +}; + describe("tree-shell-host", () => { let container: HTMLDivElement; let root: Root; let previousLegacyFlag: string | undefined; + let originalFetch: typeof fetch | undefined; + let pendingRuntimeRequests: PendingRuntimeRequest[]; beforeEach(() => { previousLegacyFlag = process.env.NEXT_PUBLIC_TREE_SHELL_LEGACY_IFRAME_HOST; @@ -16,13 +25,35 @@ describe("tree-shell-host", () => { container = document.createElement("div"); document.body.appendChild(container); root = createRoot(container); + originalFetch = global.fetch; + pendingRuntimeRequests = []; + global.fetch = vi.fn((_input: RequestInfo | URL, init?: RequestInit) => { + const request = JSON.parse(String(init?.body ?? "{}")) as Record; + return new Promise((resolve) => { + pendingRuntimeRequests.push({ + request, + resolve: (runtimeResult = null) => { + resolve({ + ok: true, + json: async () => runtimeResult, + } as Response); + }, + }); + }); + }) as typeof fetch; }); afterEach(() => { + pendingRuntimeRequests.splice(0).forEach(({ resolve }) => resolve(null)); act(() => { root.unmount(); }); container.remove(); + if (originalFetch) { + global.fetch = originalFetch; + } else { + delete (globalThis as typeof globalThis & { fetch?: typeof fetch }).fetch; + } if (previousLegacyFlag === undefined) { delete process.env.NEXT_PUBLIC_TREE_SHELL_LEGACY_IFRAME_HOST; } else { @@ -30,6 +61,109 @@ describe("tree-shell-host", () => { } }); + const fileTreeItems: KernelFileTreeProjectionItem[] = [ + { + projectionKind: "file_tree", + rowId: "index:doc_1", + rowKind: "index", + nodeId: "doc_1:index", + parentNodeId: null, + title: "Doc 1 索引", + depth: 0, + childCount: 0, + position: 0, + expandedByDefault: false, + iconHint: "page", + capabilities: ["select"], + resourceMeta: { + resourceKind: "document", + documentId: "doc_1", + workspaceId: "ws_1", + iconHint: "page", + }, + }, + { + projectionKind: "file_tree", + rowId: "index:doc_2", + rowKind: "index", + nodeId: "doc_2:index", + parentNodeId: null, + title: "Doc 2 索引", + depth: 0, + childCount: 0, + position: 1, + expandedByDefault: false, + iconHint: "page", + capabilities: ["select"], + resourceMeta: { + resourceKind: "document", + documentId: "doc_2", + workspaceId: "ws_1", + iconHint: "page", + }, + }, + { + projectionKind: "file_tree", + rowId: "index:doc_3", + rowKind: "index", + nodeId: "doc_3:index", + parentNodeId: null, + title: "Doc 3 索引", + depth: 0, + childCount: 0, + position: 2, + expandedByDefault: false, + iconHint: "page", + capabilities: ["select"], + resourceMeta: { + resourceKind: "document", + documentId: "doc_3", + workspaceId: "ws_1", + iconHint: "page", + }, + }, + ]; + + function queryFileTreeRow(rowId: string) { + return container.querySelector(`[data-row-id="${rowId}"]`) as HTMLElement | null; + } + + function expectSelectedRowIds(rowIds: string[]) { + const selected = Array.from(container.querySelectorAll('[data-shell-mode="filetree"][data-selected="true"]')) + .map((element) => element.getAttribute("data-row-id")) + .filter((rowId): rowId is string => Boolean(rowId)); + expect(selected).toEqual(rowIds); + } + + function renderDomHost(input: { + activeDocumentId?: string | null; + onFileTreeDeleteSelection?: (payload: { + selectedRowIds: string[]; + anchorRowId: string | null; + focusedRowId: string | null; + }) => void; + } = {}) { + act(() => { + root.render( + , + ); + }); + } + + async function flushRuntimeDispatch() { + await act(async () => { + await Promise.resolve(); + await Promise.resolve(); + }); + } + function renderHost() { act(() => { root.render( @@ -79,4 +213,158 @@ describe("tree-shell-host", () => { expect(iframe?.getAttribute("data-tree-browser-bridge")).toBe("iframe_srcdoc"); expect(iframe?.getAttribute("srcdoc")).toContain('"browserBridge":"iframe_srcdoc"'); }); + + it("filetree DOM host 应先本地提交 Ctrl/Shift selection,再异步等 runtime 对账", async () => { + renderDomHost(); + + const row2 = queryFileTreeRow("index:doc_2"); + const row3 = queryFileTreeRow("index:doc_3"); + expect(row2).not.toBeNull(); + expect(row3).not.toBeNull(); + + act(() => { + row2?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + expectSelectedRowIds(["index:doc_2"]); + + act(() => { + row3?.dispatchEvent(new MouseEvent("click", { bubbles: true, shiftKey: true })); + }); + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + }); + + it("旧 runtime selection 回写不应覆盖更新后的多选,Delete 应使用当前稳定 selection", async () => { + const handleDeleteSelection = vi.fn(); + renderDomHost({ onFileTreeDeleteSelection: handleDeleteSelection }); + + const row2 = queryFileTreeRow("index:doc_2"); + const row3 = queryFileTreeRow("index:doc_3"); + expect(row2).not.toBeNull(); + expect(row3).not.toBeNull(); + + act(() => { + row2?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + await flushRuntimeDispatch(); + act(() => { + row3?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + await flushRuntimeDispatch(); + + act(() => { + pendingRuntimeRequests[0]?.resolve({ + requestId: String(pendingRuntimeRequests[0]?.request.requestId ?? "filetree-stale"), + mode: "fileTree", + state: { + mode: "fileTree", + state: { + activeRowId: null, + selection: { + selectedRowIds: ["index:doc_2"], + anchorRowId: "index:doc_2", + focusedRowId: "index:doc_2", + }, + dragRowIds: [], + dragEffect: null, + dropTargetRowId: null, + }, + }, + }); + }); + await flushRuntimeDispatch(); + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + + act(() => { + row3?.dispatchEvent(new KeyboardEvent("keydown", { bubbles: true, key: "Delete" })); + }); + await flushRuntimeDispatch(); + + expect(handleDeleteSelection).toHaveBeenCalledTimes(1); + expect(handleDeleteSelection.mock.calls[0]?.[0]).toMatchObject({ + selectedRowIds: ["index:doc_2", "index:doc_3"], + anchorRowId: "index:doc_3", + focusedRowId: "index:doc_3", + }); + }); + + it("Backspace 也应复用当前稳定多选并触发删除回调", async () => { + const handleDeleteSelection = vi.fn(); + renderDomHost({ onFileTreeDeleteSelection: handleDeleteSelection }); + + const row2 = queryFileTreeRow("index:doc_2"); + const row3 = queryFileTreeRow("index:doc_3"); + expect(row2).not.toBeNull(); + expect(row3).not.toBeNull(); + + act(() => { + row2?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + await flushRuntimeDispatch(); + act(() => { + row3?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + + act(() => { + row3?.dispatchEvent(new KeyboardEvent("keydown", { bubbles: true, key: "Backspace" })); + }); + await flushRuntimeDispatch(); + + expect(handleDeleteSelection).toHaveBeenCalledTimes(1); + expect(handleDeleteSelection.mock.calls[0]?.[0]).toMatchObject({ + selectedRowIds: ["index:doc_2", "index:doc_3"], + anchorRowId: "index:doc_3", + focusedRowId: "index:doc_3", + }); + }); + + it("点击行内更多操作时不应因为事件冒泡把多选压成单选", async () => { + renderDomHost(); + + const row2 = queryFileTreeRow("index:doc_2"); + const row3 = queryFileTreeRow("index:doc_3"); + const row3Menu = container.querySelector( + '[data-row-id="index:doc_3"] [data-testid="filetree-action-menu"]', + ) as HTMLElement | null; + expect(row2).not.toBeNull(); + expect(row3).not.toBeNull(); + expect(row3Menu).not.toBeNull(); + + act(() => { + row2?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + act(() => { + row3?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + + act(() => { + row3Menu?.dispatchEvent(new MouseEvent("click", { bubbles: true })); + }); + await flushRuntimeDispatch(); + + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + }); + + it("activeDocumentId 变化时,已有 filetree selection 不应被无条件重置", () => { + renderDomHost(); + + const row2 = queryFileTreeRow("index:doc_2"); + const row3 = queryFileTreeRow("index:doc_3"); + expect(row2).not.toBeNull(); + expect(row3).not.toBeNull(); + + act(() => { + row2?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + act(() => { + row3?.dispatchEvent(new MouseEvent("click", { bubbles: true, ctrlKey: true })); + }); + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + + renderDomHost({ activeDocumentId: "doc_1" }); + + expectSelectedRowIds(["index:doc_2", "index:doc_3"]); + }); }); diff --git a/wolai-frontend/src/components/sidebar/tree-shell-host.tsx b/wolai-frontend/src/components/sidebar/tree-shell-host.tsx index 43289a4a..de6fcb26 100644 --- a/wolai-frontend/src/components/sidebar/tree-shell-host.tsx +++ b/wolai-frontend/src/components/sidebar/tree-shell-host.tsx @@ -40,6 +40,12 @@ export type FileTreeShellExternalDropPayload = { files: FileList | File[]; }; +export type FileTreeShellDeleteSelectionPayload = { + selectedRowIds: string[]; + anchorRowId: string | null; + focusedRowId: string | null; +}; + type TreeShellHostProps = { mode: TreeShellHostMode; surfaceTestId: string; @@ -79,6 +85,7 @@ type TreeShellHostProps = { anchorRowId: string | null; focusedRowId: string | null; }) => void; + onFileTreeDeleteSelection?: (payload: FileTreeShellDeleteSelectionPayload) => void; onInternalDrop?: (payload: FileTreeShellInternalDropPayload) => void; onDropFiles?: (payload: FileTreeShellExternalDropPayload) => void; onAssetOpen?: (payload: { assetId: string; documentId: string | null }) => void; @@ -114,6 +121,7 @@ export function TreeShellHost({ onPageFocusChange, onFileTreeContextMenu, onFileTreeSelectionChange, + onFileTreeDeleteSelection, onInternalDrop, onDropFiles, onAssetOpen, @@ -181,6 +189,7 @@ export function TreeShellHost({ onPageFocusChange={onPageFocusChange} onFileTreeContextMenu={onFileTreeContextMenu} onFileTreeSelectionChange={onFileTreeSelectionChange} + onFileTreeDeleteSelection={onFileTreeDeleteSelection} onInternalDrop={onInternalDrop} onDropFiles={onDropFiles} onAssetOpen={onAssetOpen} @@ -211,6 +220,7 @@ export function TreeShellHost({ onPageFocusChange={onPageFocusChange} onFileTreeContextMenu={onFileTreeContextMenu} onFileTreeSelectionChange={onFileTreeSelectionChange} + onFileTreeDeleteSelection={onFileTreeDeleteSelection} onInternalDrop={onInternalDrop} onDropFiles={onDropFiles} onAssetOpen={onAssetOpen} diff --git a/wolai-frontend/src/components/sidebar/tree-shell-surface.tsx b/wolai-frontend/src/components/sidebar/tree-shell-surface.tsx index 29686ae3..257a97ff 100644 --- a/wolai-frontend/src/components/sidebar/tree-shell-surface.tsx +++ b/wolai-frontend/src/components/sidebar/tree-shell-surface.tsx @@ -3,6 +3,7 @@ import type { DragEvent, MouseEvent } from "react"; import { TreeShellHost, + type FileTreeShellDeleteSelectionPayload, type FileTreeShellExternalDropPayload, type FileTreeShellInternalDropPayload, type TreeShellPickerCommand, @@ -71,6 +72,7 @@ type SidebarFileTreeSurfaceProps = { anchorRowId: string | null; focusedRowId: string | null; }) => void; + onFileTreeDeleteSelection?: (payload: FileTreeShellDeleteSelectionPayload) => void; onAssetOpen?: (payload: { assetId: string; documentId: string | null }) => void; onTreeMutation?: (payload: { type: string; documentId: string | null }) => void; }; @@ -153,6 +155,7 @@ export function SidebarTreeSurface(props: SidebarTreeSurfaceProps) { onPageFocusChange={props.mode === "page" ? props.onPageFocusChange : undefined} onFileTreeContextMenu={props.mode === "filetree" ? props.onFileTreeContextMenu : undefined} onFileTreeSelectionChange={props.mode === "filetree" ? props.onFileTreeSelectionChange : undefined} + onFileTreeDeleteSelection={props.mode === "filetree" ? props.onFileTreeDeleteSelection : undefined} onInternalDrop={props.mode === "filetree" ? props.onInternalDrop : undefined} onDropFiles={props.mode === "filetree" ? props.onDropFiles : undefined} onAssetOpen={props.mode === "filetree" ? props.onAssetOpen : undefined} diff --git a/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.test.tsx b/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.test.tsx index e262fed2..b2ac9557 100644 --- a/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.test.tsx +++ b/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.test.tsx @@ -72,7 +72,7 @@ describe("usePreferredSidebarSnapshot", () => { container.remove(); }); - it("tree stream live 时即使 query 更新也应继续优先使用 stream 快照", async () => { + it("tree stream 仍停在 initial 时,query 新快照不应被旧 stream 压住", async () => { const initialData = buildSidebarData([buildDocument({ title: "标题 A" })]); const staleTreeStream = buildSidebarData([buildDocument({ title: "标题 A" })]); const refreshedQuery = buildSidebarData([ @@ -81,6 +81,12 @@ describe("usePreferredSidebarSnapshot", () => { updated_at: "2026-04-21T00:00:01.000Z", }), ]); + const caughtUpTreeStream = buildSidebarData([ + buildDocument({ + title: "标题 B", + updated_at: "2026-04-21T00:00:01.000Z", + }), + ]); await act(async () => { root.render( { ); }); + expect(onState.mock.lastCall?.[0]).toMatchObject({ + source: "query", + data: expect.objectContaining({ + kernelSidebarTree: [expect.objectContaining({ title: "标题 B" })], + }), + }); + + await act(async () => { + root.render( + , + ); + }); + expect(onState.mock.lastCall?.[0]).toMatchObject({ source: "tree_stream", data: expect.objectContaining({ - kernelSidebarTree: [expect.objectContaining({ title: "标题 A" })], + kernelSidebarTree: [expect.objectContaining({ title: "标题 B" })], }), }); }); diff --git a/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.ts b/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.ts index d64dca2e..7b56131c 100644 --- a/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.ts +++ b/wolai-frontend/src/components/sidebar/use-preferred-sidebar-snapshot.ts @@ -20,8 +20,16 @@ export function usePreferredSidebarSnapshot(input: { ); const initialSyncKey = useMemo(() => buildSidebarDataSyncKey(input.initialData), [input.initialData]); const streamIsPreferred = input.treeStreamStatus !== "fallback"; + const queryHasFreshSnapshot = + input.sidebarQueryData != null && + querySyncKey != null && + querySyncKey !== initialSyncKey && + treeStreamSyncKey === initialSyncKey; const source = useMemo(() => { + if (queryHasFreshSnapshot) { + return "query"; + } if (input.treeStreamData && streamIsPreferred) { return "tree_stream"; } @@ -32,6 +40,7 @@ export function usePreferredSidebarSnapshot(input: { }, [ input.sidebarQueryData, input.treeStreamData, + queryHasFreshSnapshot, streamIsPreferred, ]); diff --git a/wolai-frontend/src/lib/documents/document-visibility.test.ts b/wolai-frontend/src/lib/documents/document-visibility.test.ts new file mode 100644 index 00000000..03f2e78b --- /dev/null +++ b/wolai-frontend/src/lib/documents/document-visibility.test.ts @@ -0,0 +1,47 @@ +import { describe, expect, it } from "vitest"; +import { buildVisibleDocumentIds } from "../../../convex/_utils/documentVisibility"; + +describe("buildVisibleDocumentIds", () => { + const docs = [ + { id: "owner-root", user_id: "u1", parent_id: null, access_scope: "private", deleted_at: null }, + { id: "public-root", user_id: "u2", parent_id: null, access_scope: "public", deleted_at: null }, + { id: "shared-root", user_id: "u2", parent_id: null, access_scope: "private", deleted_at: null }, + { id: "shared-child", user_id: "u2", parent_id: "shared-root", access_scope: "private", deleted_at: null }, + { id: "group-root", user_id: "u3", parent_id: null, access_scope: "private", deleted_at: null }, + { id: "group-child", user_id: "u3", parent_id: "group-root", access_scope: "private", deleted_at: null }, + { id: "deleted-public", user_id: "u4", parent_id: null, access_scope: "public", deleted_at: "2026-05-12T00:00:00.000Z" }, + ] as const; + + it("允许 owner、public、直接分享与继承分享的文档可见", () => { + const visible = buildVisibleDocumentIds({ + userId: "u1", + docs, + directShares: [{ document_id: "shared-root", include_descendants: true }], + directGroupShares: [], + }); + + expect(Array.from(visible).sort()).toEqual([ + "owner-root", + "public-root", + "shared-child", + "shared-root", + ]); + }); + + it("允许群组分享向下继承,但不会包含已删除文档", () => { + const visible = buildVisibleDocumentIds({ + userId: "u9", + docs, + directShares: [], + directGroupShares: [{ document_id: "group-root", include_descendants: true }], + includeDeletedDocuments: false, + }); + + expect(Array.from(visible).sort()).toEqual([ + "group-child", + "group-root", + "public-root", + ]); + expect(visible.has("deleted-public")).toBe(false); + }); +}); diff --git a/wolai-frontend/src/lib/documents/save-contract.test.ts b/wolai-frontend/src/lib/documents/save-contract.test.ts index f383b0da..7e422ae1 100644 --- a/wolai-frontend/src/lib/documents/save-contract.test.ts +++ b/wolai-frontend/src/lib/documents/save-contract.test.ts @@ -130,6 +130,58 @@ describe("buildDocumentSavePayload", () => { }); }); + it("保留 mindmap 引用骨架,不把图数据保存成文档块真源", () => { + const payload = buildDocumentSavePayload({ + documentId: "doc_1", + workspaceId: "ws_1", + tiptapDocument: { + type: "doc", + content: [ + { + type: "paragraph", + attrs: { + blockId: "mind_block_1", + mindmapId: "mindmap_1", + mnoteBlockType: "mindmap", + projectionVersion: 1, + rootNodeId: "root", + }, + }, + ], + }, + }); + + expect(payload.editorDocument).toEqual({ + documentId: "doc_1", + rootBlockIds: ["mind_block_1"], + blocks: [ + { + blockId: "mind_block_1", + blockType: "mindmap", + props: { + mindmapId: "mindmap_1", + rootNodeId: "root", + projectionVersion: 1, + }, + contentNodes: [], + childBlockIds: [], + }, + ], + }); + expect(payload.content).toEqual([ + { + id: "mind_block_1", + type: "mindmap", + props: { + mindmapId: "mindmap_1", + rootNodeId: "root", + projectionVersion: 1, + }, + content: "", + }, + ]); + }); + it("保留正文快照采集元数据", () => { const payload = buildDocumentSavePayload({ documentId: "doc_1", diff --git a/wolai-frontend/src/lib/documents/tiptap-content-converter.test.ts b/wolai-frontend/src/lib/documents/tiptap-content-converter.test.ts index 82233c5b..cecd09ae 100644 --- a/wolai-frontend/src/lib/documents/tiptap-content-converter.test.ts +++ b/wolai-frontend/src/lib/documents/tiptap-content-converter.test.ts @@ -219,7 +219,7 @@ describe("tiptap-content-converter", () => { ]); }); - it("保留 slash 插入的 mindmap placeholder 骨架为 mindmap legacy block", () => { + it("保留 mindmap 引用骨架为 mindmap legacy block,不把图数据写回文档块", () => { const tiptapDoc = { type: "doc" as const, content: [ @@ -228,6 +228,9 @@ describe("tiptap-content-converter", () => { attrs: { blockId: "mind_1", mnoteBlockType: "mindmap", + mindmapId: "mindmap_1", + rootNodeId: "root", + projectionVersion: 1, mnoteMindmapData: { data: { uid: "root", text: "KMIND", generalization: { text: "概要" } }, children: [ @@ -251,19 +254,48 @@ describe("tiptap-content-converter", () => { id: "mind_1", type: "mindmap", props: { - data: { - data: { uid: "root", text: "KMIND", generalization: { text: "概要" } }, - children: [ - { - data: { uid: "topic", text: "二级节点" }, - children: [ - { data: { uid: "branch-1", text: "分支主题" }, children: [] }, - { data: { uid: "branch-2", text: "分支主题" }, children: [] }, - ], - }, - ], + mindmapId: "mindmap_1", + rootNodeId: "root", + projectionVersion: 1, + }, + content: "", + }, + ]); + }); + + it("读取旧 mindmap block 时只迁移引用字段,丢弃 props.data 作为块真源", () => { + const tiptapDoc = tiptapDocFromBlocks([ + { + id: "mind_legacy", + type: "mindmap", + props: { + data: { id: "mindmap_from_legacy_data", rootNodeId: "root_from_data" }, + }, + }, + ] as never); + + expect(tiptapDoc).toEqual({ + type: "doc", + content: [ + { + type: "paragraph", + attrs: { + blockId: "mind_legacy", + mnoteBlockType: "mindmap", + mindmapId: "mindmap_from_legacy_data", + rootNodeId: "root_from_data", }, }, + ], + }); + expect(blocksFromTiptapDoc(tiptapDoc)).toEqual([ + { + id: "mind_legacy", + type: "mindmap", + props: { + mindmapId: "mindmap_from_legacy_data", + rootNodeId: "root_from_data", + }, content: "", }, ]); diff --git a/wolai-frontend/src/lib/documents/tiptap-content-converter.ts b/wolai-frontend/src/lib/documents/tiptap-content-converter.ts index f1709791..e881e396 100644 --- a/wolai-frontend/src/lib/documents/tiptap-content-converter.ts +++ b/wolai-frontend/src/lib/documents/tiptap-content-converter.ts @@ -47,7 +47,9 @@ export type EditorBlock = { headingLevel?: number | null; checked?: boolean | null; language?: string | null; - data?: unknown; + mindmapId?: string | null; + rootNodeId?: string | null; + projectionVersion?: number | null; }; contentNodes?: EditorContentNode[]; childBlockIds?: string[]; @@ -178,6 +180,39 @@ function normalizeBlockId(value: unknown, fallback: string): string { return raw || fallback; } +function optionalText(value: unknown): string | null { + const raw = typeof value === "string" ? value.trim() : ""; + return raw || null; +} + +function mindmapReferenceProps( + attrsOrProps: Record | undefined, + fallbackMindmapId: string, +): NonNullable { + const data = attrsOrProps?.data && typeof attrsOrProps.data === "object" + ? attrsOrProps.data as Record + : {}; + const mindmapId = + optionalText(attrsOrProps?.mindmapId) ?? + optionalText(attrsOrProps?.mindmap_id) ?? + optionalText(data.mindmapId) ?? + optionalText(data.mindmap_id) ?? + optionalText(data.id) ?? + fallbackMindmapId; + const rootNodeId = + optionalText(attrsOrProps?.rootNodeId) ?? + optionalText(attrsOrProps?.root_node_id) ?? + optionalText(data.rootNodeId) ?? + optionalText(data.root_node_id) ?? + "root"; + const projectionVersion = Number(attrsOrProps?.projectionVersion ?? attrsOrProps?.projection_version); + return { + mindmapId, + rootNodeId, + ...(Number.isFinite(projectionVersion) ? { projectionVersion } : {}), + }; +} + function normalizeEditorContentNodes(input: unknown): EditorContentNode[] { if (Array.isArray(input)) { const nodes = input.flatMap((item) => { @@ -252,7 +287,7 @@ function normalizeLegacyBlock(block: LegacyBlockLike, index: number): EditorBloc return { blockId, blockType: "mindmap", - props: { data: props.data ?? block.content }, + props: mindmapReferenceProps(props, blockId), contentNodes: [], childBlockIds: [], }; @@ -378,9 +413,8 @@ function blockToTiptapNode(block: EditorBlock): TiptapNode { attrs: { ...commonAttrs, mnoteBlockType: "mindmap", - mnoteMindmapData: block.props?.data ?? null, + ...mindmapReferenceProps(block.props, block.blockId), }, - content: textNodesToInline(block.contentNodes), }; case "paragraph": default: @@ -433,7 +467,7 @@ function tiptapNodeToBlock(node: TiptapNode, index: number): EditorBlock | null return { blockId, blockType: "mindmap", - props: { data: node.attrs.mnoteMindmapData }, + props: mindmapReferenceProps(node.attrs, blockId), contentNodes: [], childBlockIds: [], }; @@ -623,7 +657,7 @@ export function legacyBlocksFromEditorBlockDocument(document: EditorBlockDocumen : block.blockType === "code_block" ? { language: block.props?.language ?? null } : block.blockType === "mindmap" - ? { data: block.props?.data ?? null } + ? mindmapReferenceProps(block.props, block.blockId) : undefined, content: block.blockType === "mindmap" ? "" : legacyContentFromNodes(block.contentNodes), })); diff --git a/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.test.ts b/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.test.ts index 8a228215..10751701 100644 --- a/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.test.ts +++ b/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.test.ts @@ -4,6 +4,7 @@ import { createMindmapCommandApplyEndpoint, executeMindmapCommandApply, executeMindmapCommandApplyAndRefreshProjection, + executeMindmapDataPutAndRefreshProjection, isMindmapAdapterProjection, requestMindmapAdapterProjection, } from "./leptos-mindmap-adapter"; @@ -87,6 +88,23 @@ describe("leptos-mindmap adapter projection", () => { commands: [{ type: "deleteNode", mindmapId: "mind_1", nodeId: "node_1" }], fetcher, }), - ).rejects.toMatchObject({ code: "command_failed", status: 409 }); + ).rejects.toMatchObject({ code: "command_failed", status: 409, message: "command_failed:409:revision_conflict" }); + }); + + it("data put 失败时透出 route 错误细节", async () => { + const fetcher = vi.fn(async () => ({ + ok: false, + status: 400, + json: async () => ({ error: "mindmap_put_failed", details: ["missing_root_uid"] }), + })) as unknown as typeof fetch; + + await expect( + executeMindmapDataPutAndRefreshProjection({ + documentId: "doc_1", + mindmapId: "mind_1", + data: { data: { text: "中心主题" }, children: [] }, + fetcher, + }), + ).rejects.toMatchObject({ code: "command_failed", status: 400, message: "command_failed:400:mindmap_put_failed" }); }); }); diff --git a/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.ts b/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.ts index b541097c..57acfef8 100644 --- a/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.ts +++ b/wolai-frontend/src/lib/mindmap/leptos-mindmap-adapter.ts @@ -38,6 +38,15 @@ export type MindmapCommandApplyInput = { fetcher?: typeof fetch; }; +export type MindmapDataPutInput = { + documentId: string; + mindmapId: string; + data: unknown; + projectionEndpoint?: string; + endpoint?: string; + fetcher?: typeof fetch; +}; + export type MindmapCommandApplyResult = { ok: true; kernelRevision: number | null; @@ -59,6 +68,32 @@ export class MindmapCommandBridgeError extends Error { const isRecord = (value: unknown): value is Record => typeof value === "object" && value !== null && !Array.isArray(value); +const readErrorDetailFromPayload = (raw: unknown): string => { + if (!isRecord(raw)) return ""; + const detail = [raw.error, raw.message, raw.details] + .map((value) => { + if (typeof value === "string") return value.trim(); + if (Array.isArray(value) && value.length > 0) return value.join("|"); + return ""; + }) + .find(Boolean); + return detail ? `:${detail}` : ""; +}; + +const readErrorDetail = async (response: Response): Promise => { + if (typeof response.text !== "function") { + const raw = (await response.json().catch(() => null)) as unknown; + return readErrorDetailFromPayload(raw); + } + const rawText = await response.text().catch(() => ""); + if (!rawText.trim()) return ""; + try { + return readErrorDetailFromPayload(JSON.parse(rawText) as unknown) || `:${rawText.trim()}`; + } catch { + return `:${rawText.trim()}`; + } +}; + export const isMindmapAdapterProjection = (value: unknown): value is MindmapAdapterProjection => { if (!isRecord(value)) return false; return ( @@ -122,23 +157,29 @@ export const executeMindmapCommandApply = async ( } const fetcher = input.fetcher ?? fetch; const endpoint = input.endpoint ?? createMindmapCommandApplyEndpoint(input.documentId, input.mindmapId); + const requestBody = JSON.stringify({ + commandName: "mindmap.command.apply", + documentId: input.documentId, + mindmapId: input.mindmapId, + commands: input.commands, + projectionRevision: input.projectionRevision ?? null, + }); const response = await fetcher(endpoint, { method: "POST", + keepalive: requestBody.length <= 60_000, headers: { Accept: "application/json", "Content-Type": "application/json", }, - body: JSON.stringify({ - commandName: "mindmap.command.apply", - documentId: input.documentId, - mindmapId: input.mindmapId, - commands: input.commands, - projectionRevision: input.projectionRevision ?? null, - }), + body: requestBody, }); const raw = (await response.json().catch(() => null)) as unknown; if (!response.ok) { - throw new MindmapCommandBridgeError(`command_failed:${response.status}`, response.status); + const detail = readErrorDetailFromPayload(raw); + throw new MindmapCommandBridgeError( + `command_failed:${response.status}${detail}`, + response.status, + ); } return { ok: true, @@ -159,6 +200,35 @@ export const executeMindmapCommandApplyAndRefreshProjection = async ( }); }; +export const executeMindmapDataPutAndRefreshProjection = async ( + input: MindmapDataPutInput, +): Promise => { + const fetcher = input.fetcher ?? fetch; + const endpoint = input.endpoint ?? createMindmapCommandApplyEndpoint(input.documentId, input.mindmapId); + const response = await fetcher(endpoint, { + method: "POST", + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + body: JSON.stringify({ + data: input.data, + createOnly: false, + }), + }); + if (!response.ok) { + const detail = await readErrorDetail(response); + throw new MindmapCommandBridgeError(`command_failed:${response.status}${detail}`, response.status); + } + await response.json().catch(() => null); + return requestMindmapAdapterProjection({ + documentId: input.documentId, + mindmapId: input.mindmapId, + endpoint: input.projectionEndpoint, + fetcher, + }); +}; + export const createLeptosMindmapAdapter = async ( input: LeptosMindmapAdapterOptions, ): Promise => { diff --git a/wolai-frontend/src/lib/mindmap/mindmap-action-map.test.ts b/wolai-frontend/src/lib/mindmap/mindmap-action-map.test.ts index 429ab37c..be1a02ff 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-action-map.test.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-action-map.test.ts @@ -28,7 +28,7 @@ describe("mindmap action map", () => { }, }); expect(mapMindmapActionToCommand({ actionId: "deleteNode", mindmapId: "mind_1", activeNodeId: "node_1" })).toEqual({ - runtimeCommand: "DELETE_NODE", + runtimeCommand: "REMOVE_NODE", command: { type: "deleteNode", mindmapId: "mind_1", nodeId: "node_1" }, }); }); @@ -38,6 +38,21 @@ describe("mindmap action map", () => { expect(getMindmapActionMapping("zoomIn")).toMatchObject({ target: "localView", runtimeMethod: "zoomIn" }); expect(getMindmapActionMapping("zoomOut")).toMatchObject({ target: "localView", runtimeMethod: "zoomOut" }); expect(getMindmapActionMapping("fitView")).toMatchObject({ target: "localView", runtimeMethod: "fitView" }); + expect(getMindmapActionMapping("fullscreenCanvas")).toMatchObject({ target: "localView", requiresActiveNode: false }); + expect(getMindmapActionMapping("fullscreenPage")).toMatchObject({ target: "localView", requiresActiveNode: false }); + expect(getMindmapActionMapping("exitFullscreen")).toMatchObject({ target: "localView", requiresActiveNode: false }); + expect(getMindmapActionMapping("showMenu")).toMatchObject({ target: "localView", requiresActiveNode: false }); + }); + + it("全屏动作不产生 kernel command,readonly 下仍可使用", () => { + expect(mapMindmapActionToCommand({ actionId: "fullscreenCanvas", mindmapId: "mind_1" })).toEqual({}); + expect(mapMindmapActionToCommand({ actionId: "fullscreenPage", mindmapId: "mind_1" })).toEqual({}); + expect(mapMindmapActionToCommand({ actionId: "exitFullscreen", mindmapId: "mind_1" })).toEqual({}); + expect(mapMindmapActionToCommand({ actionId: "showMenu", mindmapId: "mind_1" })).toEqual({}); + expect(getMindmapActionMapping("fullscreenCanvas")).toMatchObject({ readonlyAllowed: true }); + expect(getMindmapActionMapping("fullscreenPage")).toMatchObject({ readonlyAllowed: true }); + expect(getMindmapActionMapping("exitFullscreen")).toMatchObject({ readonlyAllowed: true }); + expect(getMindmapActionMapping("showMenu")).toMatchObject({ readonlyAllowed: true }); }); it("把主题、结构和扩展字段映射到 kernel/compat", () => { diff --git a/wolai-frontend/src/lib/mindmap/mindmap-action-map.ts b/wolai-frontend/src/lib/mindmap/mindmap-action-map.ts index a9178cc0..96c8a2ef 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-action-map.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-action-map.ts @@ -46,11 +46,11 @@ const nodeDataPath = (field: string) => (activeNodeId: string | null): string | const mappings: MindmapActionMapping[] = [ { actionId: "undo", target: "runtimeCommand", runtimeCommand: "BACK", requiresActiveNode: false, readonlyAllowed: false }, { actionId: "redo", target: "runtimeCommand", runtimeCommand: "FORWARD", requiresActiveNode: false, readonlyAllowed: false }, - { actionId: "editNode", target: "kernelCommand", requiresActiveNode: true, readonlyAllowed: false }, + { actionId: "editNode", target: "localView", requiresActiveNode: true, readonlyAllowed: false }, { actionId: "insertSiblingAfter", target: "runtimeCommand", runtimeCommand: "INSERT_NODE", requiresActiveNode: true, readonlyAllowed: false }, { actionId: "insertChild", target: "runtimeCommand", runtimeCommand: "INSERT_CHILD_NODE", requiresActiveNode: true, readonlyAllowed: false }, - { actionId: "deleteNode", target: "runtimeCommand", runtimeCommand: "DELETE_NODE", requiresActiveNode: true, readonlyAllowed: false }, - { actionId: "summary", target: "compatPatch", runtimeCommand: "ADD_GENERALIZATION", requiresActiveNode: true, readonlyAllowed: false }, + { actionId: "deleteNode", target: "runtimeCommand", runtimeCommand: "REMOVE_NODE", requiresActiveNode: true, readonlyAllowed: false }, + { actionId: "summary", target: "runtimeCommand", runtimeCommand: "ADD_GENERALIZATION", requiresActiveNode: true, readonlyAllowed: false }, { actionId: "associativeLine", target: "compatPatch", runtimeCommand: "ADD_ASSOCIATIVE_LINE", requiresActiveNode: true, readonlyAllowed: false }, { actionId: "setTheme", target: "kernelCommand", requiresActiveNode: false, readonlyAllowed: false }, { actionId: "setLayout", target: "kernelCommand", requiresActiveNode: false, readonlyAllowed: false }, @@ -67,7 +67,11 @@ const mappings: MindmapActionMapping[] = [ { actionId: "zoomIn", target: "localView", runtimeMethod: "zoomIn", requiresActiveNode: false, readonlyAllowed: true }, { actionId: "zoomOut", target: "localView", runtimeMethod: "zoomOut", requiresActiveNode: false, readonlyAllowed: true }, { actionId: "fitView", target: "localView", runtimeMethod: "fitView", requiresActiveNode: false, readonlyAllowed: true }, + { actionId: "fullscreenCanvas", target: "localView", requiresActiveNode: false, readonlyAllowed: true }, + { actionId: "fullscreenPage", target: "localView", requiresActiveNode: false, readonlyAllowed: true }, + { actionId: "exitFullscreen", target: "localView", requiresActiveNode: false, readonlyAllowed: true }, { actionId: "search", target: "localView", requiresActiveNode: false, readonlyAllowed: true }, + { actionId: "showMenu", target: "localView", requiresActiveNode: false, readonlyAllowed: true }, { actionId: "expandCollapse", target: "localView", requiresActiveNode: true, readonlyAllowed: false }, { actionId: "copyNodeText", target: "localView", requiresActiveNode: true, readonlyAllowed: true }, { actionId: "readonly", target: "localView", requiresActiveNode: false, readonlyAllowed: true }, diff --git a/wolai-frontend/src/lib/mindmap/mindmap-command-apply-local.test.ts b/wolai-frontend/src/lib/mindmap/mindmap-command-apply-local.test.ts new file mode 100644 index 00000000..5a1651bb --- /dev/null +++ b/wolai-frontend/src/lib/mindmap/mindmap-command-apply-local.test.ts @@ -0,0 +1,121 @@ +import { describe, expect, it } from "vitest"; +import { + applyMindmapCommandsLocally, + applyMetadataOnlyMindmapCommands, + isLocallyApplicableMindmapCommandSet, + isMetadataOnlyMindmapCommandSet, +} from "./mindmap-command-apply-local"; + +describe("mindmap command apply local", () => { + it("识别 metadata-only 命令集合", () => { + expect( + isMetadataOnlyMindmapCommandSet([ + { type: "setLayout", mindmapId: "mind_1", layout: "mindMap" }, + { type: "setTheme", mindmapId: "mind_1", theme: "dark" }, + { type: "patchView", mindmapId: "mind_1", patch: { state: { scale: 1.2 } } }, + { type: "compatPayloadPatch", mindmapId: "mind_1", path: "root.data.fillColor", value: "#dbeafe" }, + ]), + ).toBe(true); + expect( + isMetadataOnlyMindmapCommandSet([ + { type: "insertChild", mindmapId: "mind_1", parentNodeId: "root", node: { text: "新节点" } }, + ]), + ).toBe(false); + }); + + it("把 layout/theme/view/compat patch 合并回完整 mindmap blob", () => { + const result = applyMetadataOnlyMindmapCommands( + { + data: { uid: "root", text: "KMIND" }, + children: [{ data: { uid: "node_1", text: "子节点" }, children: [] }], + layout: "logicalStructure", + theme: "classic", + themeConfig: { lineColor: "#60a5fa" }, + view: { state: { scale: 1 } }, + compatPayload: { source: "compat-blob" }, + }, + [ + { type: "setLayout", mindmapId: "mind_1", layout: "mindMap" }, + { type: "setTheme", mindmapId: "mind_1", theme: "dark" }, + { type: "patchView", mindmapId: "mind_1", patch: { state: { scale: 1.25, x: 10 } } }, + { type: "compatPayloadPatch", mindmapId: "mind_1", path: "nodes.node_1.data.fillColor", value: "#dbeafe" }, + { type: "compatPayloadPatch", mindmapId: "mind_1", path: "style.map.backgroundColor", value: "#0f172a" }, + ], + ); + + expect(result.errors).toEqual([]); + expect(result.applied).toBe(5); + expect(result.data.layout).toBe("mindMap"); + expect(result.data.theme).toBe("dark"); + expect(result.data.view).toEqual({ state: { scale: 1.25, x: 10 } }); + expect(result.data.children[0].data.fillColor).toBe("#dbeafe"); + expect(result.data.compatPayload).toEqual({ + source: "compat-blob", + style: { + map: { + backgroundColor: "#0f172a", + }, + }, + }); + }); + + it("识别可本地应用的结构命令集合", () => { + expect( + isLocallyApplicableMindmapCommandSet([ + { type: "updateText", mindmapId: "mind_1", nodeId: "node_1", text: "改名" }, + { type: "insertChild", mindmapId: "mind_1", parentNodeId: "node_1", node: { uid: "node_2", text: "子节点" } }, + { type: "insertSiblingAfter", mindmapId: "mind_1", targetNodeId: "node_1", node: { uid: "node_3", text: "同级" } }, + { type: "deleteNode", mindmapId: "mind_1", nodeId: "node_3" }, + ]), + ).toBe(true); + expect( + isLocallyApplicableMindmapCommandSet([ + { type: "moveNode", mindmapId: "mind_1", nodeId: "node_1", newParentNodeId: "root" }, + ]), + ).toBe(false); + }); + + it("可本地应用 update/insert/delete 到 mindmap tree,避免每次都整块重挂载", () => { + const result = applyMindmapCommandsLocally( + { + data: { uid: "root", text: "KMIND" }, + children: [ + { + data: { uid: "node_1", text: "节点 1" }, + children: [], + }, + { + data: { uid: "node_2", text: "节点 2" }, + children: [], + }, + ], + layout: "logicalStructure", + theme: "default", + }, + [ + { type: "updateText", mindmapId: "mind_1", nodeId: "node_1", text: "节点 1A" }, + { + type: "insertChild", + mindmapId: "mind_1", + parentNodeId: "node_1", + node: { uid: "node_1_child", text: "子节点 A" }, + }, + { + type: "insertSiblingAfter", + mindmapId: "mind_1", + targetNodeId: "node_1", + node: { uid: "node_1_sibling", text: "同级 A" }, + }, + { type: "deleteNode", mindmapId: "mind_1", nodeId: "node_2" }, + ], + ); + + expect(result.errors).toEqual([]); + expect(result.applied).toBe(4); + expect(result.data.children).toHaveLength(2); + expect(result.data.children[0].data.text).toBe("节点 1A"); + expect(result.data.children[0].children[0].data.uid).toBe("node_1_child"); + expect(result.data.children[1].data.uid).toBe("node_1_sibling"); + expect(result.data.children[1].data.text).toBe("同级 A"); + }); +}); diff --git a/wolai-frontend/src/lib/mindmap/mindmap-command-apply-local.ts b/wolai-frontend/src/lib/mindmap/mindmap-command-apply-local.ts new file mode 100644 index 00000000..ab37fa55 --- /dev/null +++ b/wolai-frontend/src/lib/mindmap/mindmap-command-apply-local.ts @@ -0,0 +1,279 @@ +import type { MindmapCompatPayloadPatch, MindmapKernelCommand } from "./mindmap-command-diff"; + +const defaultMindmapData = { + data: { text: "中心主题" }, + children: [], +}; + +type MetadataOnlyMindmapCommand = + | Extract + | MindmapCompatPayloadPatch; + +type LocallyApplicableMindmapCommand = + | Exclude + | MindmapCompatPayloadPatch; + +type ApplyMetadataOnlyMindmapCommandsResult = { + applied: number; + data: Record; + errors: string[]; +}; + +type ApplyMindmapCommandsLocallyResult = ApplyMetadataOnlyMindmapCommandsResult; + +const isRecord = (value: unknown): value is Record => + typeof value === "object" && value !== null && !Array.isArray(value); + +const cloneJson = (value: T): T => JSON.parse(JSON.stringify(value)) as T; + +const ensureMindmapBlob = (value: unknown): Record => { + const next = isRecord(value) ? cloneJson(value) : cloneJson(defaultMindmapData); + if (!isRecord(next.data)) next.data = { text: "中心主题" }; + if (!Array.isArray(next.children)) next.children = []; + return next; +}; + +const mergeJsonObject = (base: unknown, patch: unknown): unknown => { + if (!isRecord(base)) return cloneJson(patch); + if (!isRecord(patch)) return cloneJson(patch); + const next = { ...base }; + Object.entries(patch).forEach(([key, value]) => { + if (value === null) { + delete next[key]; + return; + } + next[key] = isRecord(next[key]) && isRecord(value) ? mergeJsonObject(next[key], value) : cloneJson(value); + }); + return next; +}; + +const setNestedPath = (root: Record, path: string, value: unknown): boolean => { + const segments = path.split(".").filter(Boolean); + if (segments.length === 0) return false; + let current: Record = root; + for (const segment of segments.slice(0, -1)) { + if (!isRecord(current[segment])) current[segment] = {}; + current = current[segment] as Record; + } + current[segments[segments.length - 1]] = cloneJson(value); + return true; +}; + +const findMindmapNodeByUid = (node: unknown, uid: string): Record | null => { + if (!isRecord(node)) return null; + const data = isRecord(node.data) ? node.data : null; + if (typeof data?.uid === "string" && data.uid === uid) return node; + const children = Array.isArray(node.children) ? node.children : []; + for (const child of children) { + const found = findMindmapNodeByUid(child, uid); + if (found) return found; + } + return null; +}; + +const findMindmapNodeContainerByUid = ( + nodes: unknown[], + uid: string, +): { parentChildren: Record[]; index: number } | null => { + for (let index = 0; index < nodes.length; index += 1) { + const candidate = nodes[index]; + if (!isRecord(candidate)) continue; + const data = isRecord(candidate.data) ? candidate.data : null; + if (typeof data?.uid === "string" && data.uid === uid) { + return { + parentChildren: nodes as Record[], + index, + }; + } + const children = Array.isArray(candidate.children) ? candidate.children : []; + const found = findMindmapNodeContainerByUid(children, uid); + if (found) return found; + } + return null; +}; + +const createMindmapNodeRecord = (node: { + uid?: string; + text: string; + hyperlink?: string; + note?: string; + refs?: unknown[]; +}): Record => ({ + data: { + uid: node.uid ?? `node_${Date.now().toString(36)}`, + text: node.text, + ...(typeof node.hyperlink === "string" ? { hyperlink: node.hyperlink } : {}), + ...(typeof node.note === "string" ? { note: node.note } : {}), + ...(Array.isArray(node.refs) ? { refs: cloneJson(node.refs) } : {}), + }, + children: [], +}); + +const applyCompatPayloadPatch = (root: Record, command: MindmapCompatPayloadPatch): boolean => { + const path = String(command.path || "").trim(); + if (!path) return false; + + if (path.startsWith("root.data.")) { + const field = path.slice("root.data.".length); + const rootData = isRecord(root.data) ? root.data : (root.data = {}); + return setNestedPath(rootData as Record, field, command.value); + } + + if (path.startsWith("nodes.")) { + const [, uid, scope, ...rest] = path.split("."); + if (!uid || scope !== "data" || rest.length === 0) return false; + const node = findMindmapNodeByUid(root, uid); + if (!node) return false; + const nodeData = isRecord(node.data) ? node.data : (node.data = {}); + return setNestedPath(nodeData as Record, rest.join("."), command.value); + } + + const compatPayload = isRecord(root.compatPayload) ? root.compatPayload : (root.compatPayload = {}); + return setNestedPath(compatPayload as Record, path, command.value); +}; + +export const isMetadataOnlyMindmapCommandSet = (commands: unknown[]): commands is MetadataOnlyMindmapCommand[] => + Array.isArray(commands) && + commands.every((command) => { + if (!isRecord(command) || typeof command.type !== "string") return false; + return ["setLayout", "setTheme", "patchView", "compatPayloadPatch"].includes(command.type); + }); + +export const isLocallyApplicableMindmapCommandSet = ( + commands: unknown[], +): commands is LocallyApplicableMindmapCommand[] => + Array.isArray(commands) && + commands.every((command) => { + if (!isRecord(command) || typeof command.type !== "string") return false; + return [ + "updateText", + "insertChild", + "insertSiblingAfter", + "deleteNode", + "setLayout", + "setTheme", + "patchView", + "compatPayloadPatch", + ].includes(command.type); + }); + +export const applyMetadataOnlyMindmapCommands = ( + currentData: unknown, + commands: MetadataOnlyMindmapCommand[], +): ApplyMetadataOnlyMindmapCommandsResult => { + const nextData = ensureMindmapBlob(currentData); + const errors: string[] = []; + let applied = 0; + + commands.forEach((command) => { + if (command.type === "setLayout") { + nextData.layout = cloneJson(command.layout); + applied += 1; + return; + } + if (command.type === "setTheme") { + nextData.theme = cloneJson(command.theme); + if (command.themeConfig !== undefined && command.themeConfig !== null) { + nextData.themeConfig = cloneJson(command.themeConfig); + } + applied += 1; + return; + } + if (command.type === "patchView") { + nextData.view = mergeJsonObject(nextData.view ?? {}, command.patch) as Record; + applied += 1; + return; + } + if (command.type === "compatPayloadPatch") { + if (applyCompatPayloadPatch(nextData, command)) { + applied += 1; + } else { + errors.push(`无法应用 compatPayloadPatch:${command.path}`); + } + } + }); + + return { + applied, + data: nextData, + errors, + }; +}; + +export const applyMindmapCommandsLocally = ( + currentData: unknown, + commands: LocallyApplicableMindmapCommand[], +): ApplyMindmapCommandsLocallyResult => { + const nextData = ensureMindmapBlob(currentData); + const errors: string[] = []; + let applied = 0; + + commands.forEach((command) => { + if (command.type === "setLayout" || command.type === "setTheme" || command.type === "patchView" || command.type === "compatPayloadPatch") { + const result = applyMetadataOnlyMindmapCommands(nextData, [command]); + Object.assign(nextData, result.data); + applied += result.applied; + errors.push(...result.errors); + return; + } + + if (command.type === "updateText") { + const node = findMindmapNodeByUid(nextData, command.nodeId); + if (!node) { + errors.push(`未找到节点:${command.nodeId}`); + return; + } + const data = isRecord(node.data) ? node.data : (node.data = {}); + data.text = command.text; + applied += 1; + return; + } + + if (command.type === "insertChild") { + const parent = findMindmapNodeByUid(nextData, command.parentNodeId); + if (!parent) { + errors.push(`未找到父节点:${command.parentNodeId}`); + return; + } + const children = Array.isArray(parent.children) ? parent.children : (parent.children = []); + children.push(createMindmapNodeRecord(command.node)); + applied += 1; + return; + } + + if (command.type === "insertSiblingAfter") { + const container = findMindmapNodeContainerByUid([nextData], command.targetNodeId); + if (!container) { + errors.push(`未找到同级节点:${command.targetNodeId}`); + return; + } + if (container.parentChildren[container.index] === nextData) { + errors.push("根节点不支持插入同级节点"); + return; + } + container.parentChildren.splice(container.index + 1, 0, createMindmapNodeRecord(command.node)); + applied += 1; + return; + } + + if (command.type === "deleteNode") { + const container = findMindmapNodeContainerByUid([nextData], command.nodeId); + if (!container) { + errors.push(`未找到删除节点:${command.nodeId}`); + return; + } + if (container.parentChildren[container.index] === nextData) { + errors.push("根节点不支持删除"); + return; + } + container.parentChildren.splice(container.index, 1); + applied += 1; + } + }); + + return { + applied, + data: nextData, + errors, + }; +}; diff --git a/wolai-frontend/src/lib/mindmap/mindmap-initial-sync.test.ts b/wolai-frontend/src/lib/mindmap/mindmap-initial-sync.test.ts new file mode 100644 index 00000000..f85d8a08 --- /dev/null +++ b/wolai-frontend/src/lib/mindmap/mindmap-initial-sync.test.ts @@ -0,0 +1,30 @@ +import { describe, expect, it } from "vitest"; +import { buildInitialMindmapAssetRefreshPayload } from "./mindmap-initial-sync"; + +describe("buildInitialMindmapAssetRefreshPayload", () => { + it("远端 createOnly 成功时返回文件树刷新 payload", () => { + expect( + buildInitialMindmapAssetRefreshPayload({ + ok: true, + docId: "doc-1", + mindmapId: "mind-1", + }), + ).toEqual({ + id: "mind-1", + document_id: "doc-1", + asset_type: "mindmap", + file_name: "mindmap-mind-1.json", + file_url: "/documents/doc-1/mindmap-mind-1.json", + }); + }); + + it("远端 createOnly 失败时不应伪造文件树刷新事件", () => { + expect( + buildInitialMindmapAssetRefreshPayload({ + ok: false, + docId: "doc-1", + mindmapId: "mind-1", + }), + ).toBeNull(); + }); +}); diff --git a/wolai-frontend/src/lib/mindmap/mindmap-initial-sync.ts b/wolai-frontend/src/lib/mindmap/mindmap-initial-sync.ts new file mode 100644 index 00000000..f17f26dd --- /dev/null +++ b/wolai-frontend/src/lib/mindmap/mindmap-initial-sync.ts @@ -0,0 +1,25 @@ +export type InitialMindmapAssetRefreshPayload = { + id: string; + document_id: string; + asset_type: "mindmap"; + file_name: string; + file_url: string; +}; + +export function buildInitialMindmapAssetRefreshPayload(input: { + ok: boolean; + docId: string; + mindmapId: string; +}): InitialMindmapAssetRefreshPayload | null { + if (!input.ok) { + return null; + } + const fileName = `mindmap-${input.mindmapId}.json`; + return { + id: input.mindmapId, + document_id: input.docId, + asset_type: "mindmap", + file_name: fileName, + file_url: `/documents/${input.docId}/${fileName}`, + }; +} diff --git a/wolai-frontend/src/lib/mindmap/mindmap-projection.ts b/wolai-frontend/src/lib/mindmap/mindmap-projection.ts index f0819393..8854ae2e 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-projection.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-projection.ts @@ -95,6 +95,46 @@ export const defaultMindmapData: MindMapData = { children: [], }; +export const DEFAULT_MINDMAP_LAYOUT = "logicalStructure"; +export const DEFAULT_MINDMAP_THEME = "default"; + +export const createDefaultMindmapThemeConfig = (): Record => ({ + lineColor: "#7aa2ff", + lineStyle: "curve", + rootLineKeepSameInCurve: true, + rootLineStartPositionKeepSameInCurve: true, + generalizationLineColor: "#ef6a5b", + backgroundColor: "#f6f8fc", + root: { + fillColor: "#e25563", + color: "#ffffff", + fontWeight: "bold", + borderColor: "transparent", + borderWidth: 0, + borderRadius: 8, + }, + second: { + fillColor: "#4f7df3", + color: "#ffffff", + borderColor: "transparent", + borderWidth: 0, + borderRadius: 8, + }, + node: { + fillColor: "transparent", + color: "#315aa9", + borderColor: "transparent", + borderWidth: 0, + }, + generalization: { + fillColor: "#ffffff", + color: "#ef6a5b", + borderColor: "#ef6a5b", + borderWidth: 1, + borderRadius: 8, + }, +}); + const isRecord = (value: unknown): value is Record => typeof value === "object" && value !== null && !Array.isArray(value); @@ -299,9 +339,9 @@ export const buildMindmapSimpleMindMapScene = (input: { mindmapId: input.mindmapId, rootNodeId, root, - layout: "logicalStructure", - theme: "classic", - themeConfig: {}, + layout: DEFAULT_MINDMAP_LAYOUT, + theme: DEFAULT_MINDMAP_THEME, + themeConfig: createDefaultMindmapThemeConfig(), view: { x: 0, y: 0, scale: 1 }, config: {}, compatPayload: {}, diff --git a/wolai-frontend/src/lib/mindmap/mindmap-shortcuts.test.ts b/wolai-frontend/src/lib/mindmap/mindmap-shortcuts.test.ts new file mode 100644 index 00000000..0c19fb42 --- /dev/null +++ b/wolai-frontend/src/lib/mindmap/mindmap-shortcuts.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, it } from "vitest"; +import { + resolveMindmapShortcutAction, + shouldInterceptMindmapShortcut, +} from "./mindmap-shortcuts"; + +describe("mindmap shortcuts", () => { + it("把基础快捷键解析为导图动作", () => { + expect(resolveMindmapShortcutAction({ key: "Enter" })).toBe("insertSiblingAfter"); + expect(resolveMindmapShortcutAction({ key: "Tab" })).toBe("insertChild"); + expect(resolveMindmapShortcutAction({ key: "Delete" })).toBe("deleteNode"); + expect(resolveMindmapShortcutAction({ key: "F2" })).toBe("editNode"); + expect(resolveMindmapShortcutAction({ key: "Enter", ctrlKey: true })).toBeNull(); + }); + + it("已进入 mindmap 时即使暂时没有 active node,也要拦截危险按键,避免 ProseMirror 误删整个 block", () => { + expect( + shouldInterceptMindmapShortcut({ + debugChromeEnabled: false, + bridgeReady: true, + readonly: false, + isComposing: false, + isEditableTarget: false, + targetInsideRoot: false, + keyboardShortcutArmed: true, + }), + ).toBe(true); + expect( + shouldInterceptMindmapShortcut({ + debugChromeEnabled: false, + bridgeReady: true, + readonly: false, + isComposing: false, + isEditableTarget: false, + targetInsideRoot: false, + keyboardShortcutArmed: false, + }), + ).toBe(false); + }); +}); diff --git a/wolai-frontend/src/lib/mindmap/mindmap-shortcuts.ts b/wolai-frontend/src/lib/mindmap/mindmap-shortcuts.ts new file mode 100644 index 00000000..763743ff --- /dev/null +++ b/wolai-frontend/src/lib/mindmap/mindmap-shortcuts.ts @@ -0,0 +1,40 @@ +import type { MindmapUiActionId } from "./mindmap-ui-schema"; + +type MindmapShortcutEventLike = { + key: string; + shiftKey?: boolean; + ctrlKey?: boolean; + metaKey?: boolean; + altKey?: boolean; +}; + +export type MindmapShortcutGateInput = { + debugChromeEnabled: boolean; + bridgeReady: boolean; + readonly: boolean; + isComposing: boolean; + isEditableTarget: boolean; + targetInsideRoot: boolean; + keyboardShortcutArmed: boolean; +}; + +export const resolveMindmapShortcutAction = ( + event: MindmapShortcutEventLike, +): MindmapUiActionId | null => { + if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return null; + if (event.key === "Enter") return "insertSiblingAfter"; + if (event.key === "Tab" || event.key === "Insert") return "insertChild"; + if (event.key === "Delete" || event.key === "Backspace") return "deleteNode"; + if (event.key === "F2") return "editNode"; + return null; +}; + +export const shouldInterceptMindmapShortcut = ( + input: MindmapShortcutGateInput, +): boolean => { + if (input.debugChromeEnabled) return false; + if (!input.bridgeReady || input.readonly || input.isComposing) return false; + if (input.isEditableTarget) return false; + if (input.targetInsideRoot) return true; + return input.keyboardShortcutArmed; +}; diff --git a/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.test.ts b/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.test.ts index cb8b7720..d3cf9fd0 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.test.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.test.ts @@ -1,8 +1,11 @@ import { describe, expect, it } from "vitest"; import { + MINDMAP_TOOLBAR_MORE_ACTION_ID, MINDMAP_DEBUG_CHROME_QUERY_PARAM, isMindmapDebugChromeEnabled, mindmapDefaultUiSchema, + mindmapToolbarFileActionOrder, + mindmapToolbarPrimaryActionOrder, } from "./mindmap-ui-schema"; import { getMindmapActionMapping } from "./mindmap-action-map"; @@ -12,6 +15,7 @@ describe("mindmap UI schema", () => { "history", "node", "insert", + "file", "view", ]); expect(mindmapDefaultUiSchema.sidebarPanels.map((panel) => panel.id)).toEqual([ @@ -20,6 +24,8 @@ describe("mindmap UI schema", () => { "theme", "structure", "outline", + "shortcutKey", + "settings", ]); expect(mindmapDefaultUiSchema.navigatorItems.map((item) => item.id)).toEqual([ "stats", @@ -28,6 +34,7 @@ describe("mindmap UI schema", () => { "zoomOut", "zoom", "zoomIn", + "fullscreen", "readonly", ]); }); @@ -48,6 +55,41 @@ describe("mindmap UI schema", () => { expect(new Set(actionIds).size).toBe(actionIds.length); }); + it("单行 toolbar 主按钮顺序对齐 lx-doc/KMind", () => { + expect([...mindmapToolbarPrimaryActionOrder, MINDMAP_TOOLBAR_MORE_ACTION_ID]).toEqual([ + "undo", + "redo", + "editNode", + "insertSiblingAfter", + "deleteNode", + "insertChild", + "tag", + "hyperlink", + "note", + "image", + "icon", + "summary", + "associativeLine", + "formula", + "more", + ]); + }); + + it("toolbar 元信息包含图标、短标签、长标签、优先级和溢出归类", () => { + const primaryMeta = mindmapToolbarPrimaryActionOrder.map((actionId) => mindmapDefaultUiSchema.toolbarActionMeta[actionId]); + expect(primaryMeta.map((meta) => meta.priority)).toEqual([...primaryMeta.map((meta) => meta.priority)].sort((a, b) => a - b)); + expect(primaryMeta.every((meta) => meta.cluster === "main")).toBe(true); + expect(primaryMeta.every((meta) => meta.iconKey && meta.shortLabel && meta.longLabel && meta.overflowGroup)).toBe(true); + }); + + it("导入导出属于右侧独立 toolbar cluster", () => { + expect([...mindmapToolbarFileActionOrder]).toEqual(["import", "export"]); + expect(mindmapToolbarFileActionOrder.map((actionId) => mindmapDefaultUiSchema.toolbarActionMeta[actionId].cluster)).toEqual([ + "file", + "file", + ]); + }); + it("默认 schema 中所有 action 都有 action map 映射", () => { const actionIds = [ ...mindmapDefaultUiSchema.toolbarGroups.flatMap((group) => group.actions), @@ -58,6 +100,16 @@ describe("mindmap UI schema", () => { expect(actionIds.filter((actionId) => getMindmapActionMapping(actionId) === null)).toEqual([]); }); + it("toolbar 真实可见 action 都有 action map,more 仅作为 shell 虚拟按钮", () => { + const visibleActionIds = [ + ...mindmapToolbarPrimaryActionOrder, + ...mindmapToolbarFileActionOrder, + ]; + + expect(visibleActionIds.filter((actionId) => getMindmapActionMapping(actionId) === null)).toEqual([]); + expect(mindmapDefaultUiSchema.toolbarActionMeta).not.toHaveProperty(MINDMAP_TOOLBAR_MORE_ACTION_ID); + }); + it("第一阶段 context menu 覆盖节点和画布动作", () => { expect(mindmapDefaultUiSchema.contextMenuItems.filter((item) => item.requiresNode).map((item) => item.actionId)).toEqual([ "insertChild", @@ -73,27 +125,53 @@ describe("mindmap UI schema", () => { "fitView", "search", "readonly", + "showMenu", ]); }); it("第一阶段 sidebar panel 数量受控", () => { - expect(mindmapDefaultUiSchema.sidebarPanels).toHaveLength(5); + expect(mindmapDefaultUiSchema.sidebarPanels).toHaveLength(7); }); it("第一阶段 sidebar 暴露主题、结构和 compat patch 选项", () => { const themePanel = mindmapDefaultUiSchema.sidebarPanels.find((panel) => panel.id === "theme"); - expect(themePanel?.options.map((option) => option.value)).toEqual(["classic", "classic4"]); + expect(themePanel?.options.map((option) => option.value)).toEqual(["classic", "classic4", "simple", "dark"]); const structurePanel = mindmapDefaultUiSchema.sidebarPanels.find((panel) => panel.id === "structure"); expect(structurePanel?.options.map((option) => option.value)).toEqual([ "logicalStructure", "mindMap", + "organizationStructure", + "catalogOrganization", + "timeline", "fishbone", ]); + expect(structurePanel?.options.every((option) => option.controlType === "layoutCard")).toBe(true); const nodeStylePanel = mindmapDefaultUiSchema.sidebarPanels.find((panel) => panel.id === "nodeStyle"); const baseStylePanel = mindmapDefaultUiSchema.sidebarPanels.find((panel) => panel.id === "baseStyle"); expect(nodeStylePanel?.options.every((option) => Boolean(option.compatPath))).toBe(true); expect(baseStylePanel?.options.every((option) => Boolean(option.compatPath))).toBe(true); }); + + it("每个 sidebar option 要么可写,要么显式标记只读", () => { + const options = mindmapDefaultUiSchema.sidebarPanels.flatMap((panel) => panel.options); + expect(options.length).toBeGreaterThan(0); + expect(options.every((option) => option.actionId !== null || option.readonly === true)).toBe(true); + }); + + it("可写 sidebar option 必须能映射到 compat patch 或 kernel command", () => { + const writableOptions = mindmapDefaultUiSchema.sidebarPanels.flatMap((panel) => + panel.options.filter((option) => option.readonly !== true), + ); + expect(writableOptions.length).toBeGreaterThan(0); + expect( + writableOptions.every((option) => { + if (option.compatPath) return true; + if (!option.actionId) return false; + const mapping = getMindmapActionMapping(option.actionId); + return mapping?.target === "kernelCommand" || mapping?.target === "compatPatch"; + }), + ).toBe(true); + }); }); diff --git a/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts b/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts index 8ded8f7d..a714d3d5 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-ui-schema.ts @@ -24,20 +24,45 @@ export type MindmapUiActionId = | "zoomOut" | "fitView" | "centerRoot" + | "fullscreenCanvas" + | "fullscreenPage" + | "exitFullscreen" | "search" + | "showMenu" | "expandCollapse" | "copyNodeText" | "readonly"; +export const MINDMAP_TOOLBAR_MORE_ACTION_ID = "more" as const; + +export type MindmapToolbarVirtualActionId = typeof MINDMAP_TOOLBAR_MORE_ACTION_ID; + +export type MindmapToolbarActionId = MindmapUiActionId | MindmapToolbarVirtualActionId; + +export type MindmapToolbarActionCluster = "main" | "file" | "view"; + +export type MindmapToolbarOverflowGroup = "history" | "node" | "insert" | "file" | "view"; + +export type MindmapToolbarActionMeta = { + id: MindmapUiActionId; + iconKey: string; + shortLabel: string; + longLabel: string; + priority: number; + overflowGroup: MindmapToolbarOverflowGroup; + cluster: MindmapToolbarActionCluster; +}; + export type MindmapToolbarGroup = { - id: "history" | "node" | "insert" | "view"; + id: MindmapToolbarOverflowGroup; label: string; actions: MindmapUiActionId[]; collapsePriority: number; }; export type MindmapSidebarPanel = { - id: "nodeStyle" | "baseStyle" | "theme" | "structure" | "outline"; + id: MindmapSidebarPanelId; + kind: MindmapSidebarPanelId; label: string; icon: string; runtimeCapability: string; @@ -45,16 +70,40 @@ export type MindmapSidebarPanel = { options: MindmapSidebarOption[]; }; +export type MindmapSidebarPanelId = + | "nodeStyle" + | "baseStyle" + | "theme" + | "structure" + | "outline" + | "shortcutKey" + | "settings"; + +export type MindmapSidebarOptionControlType = + | "button" + | "swatch" + | "segmented" + | "slider" + | "numberInput" + | "select" + | "layoutCard" + | "treeItem" + | "toggle"; + export type MindmapSidebarOption = { id: string; label: string; actionId: MindmapUiActionId | null; value: unknown; + controlType: MindmapSidebarOptionControlType; + preview?: string; + description?: string; + readonly?: boolean; compatPath?: string; }; export type MindmapNavigatorItem = { - id: "stats" | "centerRoot" | "search" | "zoomOut" | "zoom" | "zoomIn" | "readonly"; + id: "stats" | "centerRoot" | "search" | "zoomOut" | "zoom" | "zoomIn" | "fullscreen" | "readonly"; label: string; actionId: MindmapUiActionId | null; readOnly: boolean; @@ -71,11 +120,49 @@ export type MindmapContextMenuItem = { export type MindmapUiSchema = { toolbarGroups: MindmapToolbarGroup[]; + toolbarActionMeta: Record; sidebarPanels: MindmapSidebarPanel[]; navigatorItems: MindmapNavigatorItem[]; contextMenuItems: MindmapContextMenuItem[]; }; +export const mindmapToolbarPrimaryActionOrder = [ + "undo", + "redo", + "editNode", + "insertSiblingAfter", + "deleteNode", + "insertChild", + "tag", + "hyperlink", + "note", + "image", + "icon", + "summary", + "associativeLine", + "formula", +] as const satisfies readonly MindmapUiActionId[]; + +export const mindmapToolbarFileActionOrder = ["import", "export"] as const satisfies readonly MindmapUiActionId[]; + +const createToolbarActionMeta = ( + id: MindmapUiActionId, + iconKey: string, + shortLabel: string, + longLabel: string, + priority: number, + overflowGroup: MindmapToolbarOverflowGroup, + cluster: MindmapToolbarActionCluster, +): MindmapToolbarActionMeta => ({ + id, + iconKey, + shortLabel, + longLabel, + priority, + overflowGroup, + cluster, +}); + export const mindmapDefaultUiSchema: MindmapUiSchema = { toolbarGroups: [ { @@ -87,84 +174,177 @@ export const mindmapDefaultUiSchema: MindmapUiSchema = { { id: "node", label: "节点", - actions: ["editNode", "insertSiblingAfter", "insertChild", "deleteNode"], + actions: ["editNode", "insertSiblingAfter", "deleteNode", "insertChild"], collapsePriority: 1, }, { id: "insert", label: "插入", - actions: ["tag", "hyperlink", "note", "image", "icon", "summary", "associativeLine", "formula", "painter", "import", "export"], + actions: ["tag", "hyperlink", "note", "image", "icon", "summary", "associativeLine", "formula"], collapsePriority: 2, }, + { + id: "file", + label: "文件", + actions: ["import", "export"], + collapsePriority: 5, + }, { id: "view", label: "视图", - actions: ["centerRoot", "zoomOut", "zoomIn", "search", "readonly"], + actions: ["painter", "centerRoot", "zoomOut", "zoomIn", "search", "readonly"], collapsePriority: 3, }, ], + toolbarActionMeta: { + undo: createToolbarActionMeta("undo", "undo", "撤销", "撤销", 10, "history", "main"), + redo: createToolbarActionMeta("redo", "redo", "重做", "重做", 20, "history", "main"), + editNode: createToolbarActionMeta("editNode", "type", "编辑", "编辑节点", 30, "node", "main"), + insertSiblingAfter: createToolbarActionMeta("insertSiblingAfter", "sibling", "同级", "插入同级节点", 40, "node", "main"), + deleteNode: createToolbarActionMeta("deleteNode", "trash", "删除", "删除节点", 50, "node", "main"), + insertChild: createToolbarActionMeta("insertChild", "child", "子级", "插入子节点", 60, "node", "main"), + tag: createToolbarActionMeta("tag", "tag", "标签", "标签", 70, "insert", "main"), + hyperlink: createToolbarActionMeta("hyperlink", "link", "链接", "超链接", 80, "insert", "main"), + note: createToolbarActionMeta("note", "note", "备注", "备注", 90, "insert", "main"), + image: createToolbarActionMeta("image", "image", "图片", "图片", 100, "insert", "main"), + icon: createToolbarActionMeta("icon", "smile", "图标", "图标", 110, "insert", "main"), + summary: createToolbarActionMeta("summary", "summary", "概要", "概要", 120, "insert", "main"), + associativeLine: createToolbarActionMeta("associativeLine", "route", "关联", "关联线", 130, "insert", "main"), + formula: createToolbarActionMeta("formula", "formula", "公式", "公式", 140, "insert", "main"), + painter: createToolbarActionMeta("painter", "paintbrush", "格式", "格式刷", 210, "view", "view"), + import: createToolbarActionMeta("import", "import", "导入", "导入", 310, "file", "file"), + export: createToolbarActionMeta("export", "export", "导出", "导出", 320, "file", "file"), + setTheme: createToolbarActionMeta("setTheme", "palette", "主题", "主题", 410, "view", "view"), + setLayout: createToolbarActionMeta("setLayout", "layout", "结构", "结构", 420, "view", "view"), + zoomIn: createToolbarActionMeta("zoomIn", "zoom-in", "放大", "放大", 510, "view", "view"), + zoomOut: createToolbarActionMeta("zoomOut", "zoom-out", "缩小", "缩小", 500, "view", "view"), + fitView: createToolbarActionMeta("fitView", "fit", "适应", "适应画布", 520, "view", "view"), + centerRoot: createToolbarActionMeta("centerRoot", "target", "回根", "回到根节点", 490, "view", "view"), + fullscreenCanvas: createToolbarActionMeta("fullscreenCanvas", "fullscreen", "全屏", "全屏查看", 550, "view", "view"), + fullscreenPage: createToolbarActionMeta("fullscreenPage", "fullscreen-page", "全页", "全屏编辑", 560, "view", "view"), + exitFullscreen: createToolbarActionMeta("exitFullscreen", "exit-fullscreen", "退出", "退出全屏", 570, "view", "view"), + search: createToolbarActionMeta("search", "search", "搜索", "搜索", 530, "view", "view"), + showMenu: createToolbarActionMeta("showMenu", "menu", "菜单", "显示菜单", 580, "view", "view"), + expandCollapse: createToolbarActionMeta("expandCollapse", "expand", "展开", "展开/收起", 610, "view", "view"), + copyNodeText: createToolbarActionMeta("copyNodeText", "copy", "复制", "复制文本", 620, "view", "view"), + readonly: createToolbarActionMeta("readonly", "lock", "只读", "只读", 540, "view", "view"), + }, sidebarPanels: [ { id: "nodeStyle", + kind: "nodeStyle", label: "节点样式", icon: "palette", runtimeCapability: "node-style", phase: 1, options: [ - { id: "node-fill-blue", label: "蓝色节点", actionId: "painter", value: "#dbeafe", compatPath: "nodes.$active.data.fillColor" }, - { id: "node-round", label: "圆角节点", actionId: "painter", value: "roundedRectangle", compatPath: "nodes.$active.data.shape" }, + { id: "node-fill-blue", label: "海蓝", actionId: "painter", value: "#dbeafe", controlType: "swatch", preview: "#dbeafe", compatPath: "nodes.$active.data.fillColor" }, + { id: "node-fill-green", label: "薄荷", actionId: "painter", value: "#dcfce7", controlType: "swatch", preview: "#dcfce7", compatPath: "nodes.$active.data.fillColor" }, + { id: "node-fill-amber", label: "暖黄", actionId: "painter", value: "#fef3c7", controlType: "swatch", preview: "#fef3c7", compatPath: "nodes.$active.data.fillColor" }, + { id: "node-text-dark", label: "深色文字", actionId: "painter", value: "#0f172a", controlType: "swatch", preview: "#0f172a", compatPath: "nodes.$active.data.color" }, + { id: "node-text-blue", label: "蓝色文字", actionId: "painter", value: "#1d4ed8", controlType: "swatch", preview: "#1d4ed8", compatPath: "nodes.$active.data.color" }, + { id: "node-font-14", label: "14 px", actionId: "painter", value: 14, controlType: "segmented", compatPath: "nodes.$active.data.fontSize" }, + { id: "node-font-18", label: "18 px", actionId: "painter", value: 18, controlType: "segmented", compatPath: "nodes.$active.data.fontSize" }, + { id: "node-font-bold", label: "加粗", actionId: "painter", value: true, controlType: "toggle", compatPath: "nodes.$active.data.fontWeight" }, + { id: "node-font-italic", label: "斜体", actionId: "painter", value: true, controlType: "toggle", compatPath: "nodes.$active.data.fontStyle" }, + { id: "node-shape-round", label: "圆角矩形", actionId: "painter", value: "roundedRectangle", controlType: "button", compatPath: "nodes.$active.data.shape" }, + { id: "node-shape-rect", label: "矩形", actionId: "painter", value: "rectangle", controlType: "button", compatPath: "nodes.$active.data.shape" }, + { id: "node-border-blue", label: "蓝色边框", actionId: "painter", value: "#60a5fa", controlType: "swatch", preview: "#60a5fa", compatPath: "nodes.$active.data.borderColor" }, + { id: "node-line-teal", label: "青色分支线", actionId: "painter", value: "#14b8a6", controlType: "swatch", preview: "#14b8a6", compatPath: "nodes.$active.data.lineColor" }, + { id: "node-line-width-2", label: "边线 2", actionId: "painter", value: 2, controlType: "segmented", compatPath: "nodes.$active.data.lineWidth" }, ], }, { id: "baseStyle", + kind: "baseStyle", label: "导图样式", icon: "sliders", runtimeCapability: "base-style", phase: 1, options: [ - { id: "base-curve-line", label: "曲线连线", actionId: "painter", value: "curve", compatPath: "style.map.lineStyle" }, - { id: "base-rainbow-lines", label: "彩虹线条", actionId: "painter", value: { enabled: true }, compatPath: "style.map.rainbowLines" }, + { id: "base-curve-line", label: "曲线", actionId: "painter", value: "curve", controlType: "segmented", compatPath: "style.map.lineStyle" }, + { id: "base-direct-line", label: "直线", actionId: "painter", value: "straight", controlType: "segmented", compatPath: "style.map.lineStyle" }, + { id: "base-rainbow-lines", label: "彩虹线条", actionId: "painter", value: { enabled: true }, controlType: "toggle", compatPath: "style.map.rainbowLines" }, + { id: "base-line-width-2", label: "线宽 2", actionId: "painter", value: 2, controlType: "segmented", compatPath: "style.map.lineWidth" }, + { id: "base-line-width-4", label: "线宽 4", actionId: "painter", value: 4, controlType: "segmented", compatPath: "style.map.lineWidth" }, + { id: "base-background-light", label: "浅色背景", actionId: "painter", value: "#f8fafc", controlType: "swatch", preview: "#f8fafc", compatPath: "style.map.backgroundColor" }, + { id: "base-node-spacing-36", label: "节点间距 36", actionId: "painter", value: 36, controlType: "numberInput", compatPath: "style.map.nodeSpacing" }, + { id: "base-summary-bracket", label: "括号概要", actionId: "painter", value: "bracket", controlType: "select", compatPath: "style.map.summaryStyle" }, ], }, { id: "theme", + kind: "theme", label: "主题", icon: "swatch", runtimeCapability: "theme", phase: 1, options: [ - { id: "theme-classic", label: "默认主题", actionId: "setTheme", value: "classic" }, - { id: "theme-classic4", label: "KMind-like", actionId: "setTheme", value: "classic4" }, + { id: "theme-classic", label: "Classic", actionId: "setTheme", value: "classic", controlType: "swatch", preview: "#60a5fa", description: "默认主题" }, + { id: "theme-classic4", label: "KMind", actionId: "setTheme", value: "classic4", controlType: "swatch", preview: "#22c55e", description: "KMind-like" }, + { id: "theme-simple", label: "Simple", actionId: "setTheme", value: "simple", controlType: "swatch", preview: "#f59e0b", description: "轻量主题" }, + { id: "theme-dark", label: "Dark", actionId: "setTheme", value: "dark", controlType: "swatch", preview: "#334155", description: "深色主题" }, ], }, { id: "structure", + kind: "structure", label: "结构", icon: "layout", runtimeCapability: "layout", phase: 1, options: [ - { id: "layout-logical", label: "逻辑结构", actionId: "setLayout", value: "logicalStructure" }, - { id: "layout-mind-map", label: "右侧结构", actionId: "setLayout", value: "mindMap" }, - { id: "layout-fishbone", label: "鱼骨结构", actionId: "setLayout", value: "fishbone" }, + { id: "layout-logical", label: "逻辑结构图", actionId: "setLayout", value: "logicalStructure", controlType: "layoutCard", preview: "logicalStructure" }, + { id: "layout-mind-map", label: "思维导图", actionId: "setLayout", value: "mindMap", controlType: "layoutCard", preview: "mindMap" }, + { id: "layout-organization", label: "组织结构图", actionId: "setLayout", value: "organizationStructure", controlType: "layoutCard", preview: "organizationStructure" }, + { id: "layout-catalog", label: "目录组织图", actionId: "setLayout", value: "catalogOrganization", controlType: "layoutCard", preview: "catalogOrganization" }, + { id: "layout-timeline", label: "时间轴", actionId: "setLayout", value: "timeline", controlType: "layoutCard", preview: "timeline" }, + { id: "layout-fishbone", label: "鱼骨图", actionId: "setLayout", value: "fishbone", controlType: "layoutCard", preview: "fishbone" }, ], }, { id: "outline", + kind: "outline", label: "大纲", icon: "list-tree", runtimeCapability: "outline", phase: 1, options: [], }, + { + id: "shortcutKey", + kind: "shortcutKey", + label: "快捷键", + icon: "sparkles", + runtimeCapability: "shortcut-key", + phase: 1, + options: [ + { id: "shortcut-insert-child", label: "Tab", description: "插入子节点", actionId: null, value: null, controlType: "treeItem", readonly: true }, + { id: "shortcut-insert-sibling", label: "Enter", description: "插入同级节点", actionId: null, value: null, controlType: "treeItem", readonly: true }, + { id: "shortcut-delete", label: "Delete", description: "删除节点", actionId: null, value: null, controlType: "treeItem", readonly: true }, + ], + }, + { + id: "settings", + kind: "settings", + label: "设置", + icon: "hexagon", + runtimeCapability: "settings", + phase: 1, + options: [ + { id: "settings-readonly-hint", label: "只读模式", description: "导航栏切换", actionId: null, value: null, controlType: "toggle", readonly: true }, + { id: "settings-mouse", label: "鼠标行为", description: "左键选中,右键拖拽", actionId: null, value: "leftSelectRightDrag", controlType: "select", readonly: true }, + ], + }, ], navigatorItems: [ { id: "stats", label: "统计", actionId: null, readOnly: true, displayMode: "text" }, { id: "centerRoot", label: "回根节点", actionId: "centerRoot", readOnly: true, displayMode: "button" }, - { id: "search", label: "搜索", actionId: "search", readOnly: true, displayMode: "input" }, + { id: "search", label: "搜索", actionId: "search", readOnly: true, displayMode: "button" }, { id: "zoomOut", label: "缩小", actionId: "zoomOut", readOnly: true, displayMode: "button" }, - { id: "zoom", label: "缩放", actionId: null, readOnly: true, displayMode: "text" }, + { id: "zoom", label: "缩放", actionId: null, readOnly: true, displayMode: "input" }, { id: "zoomIn", label: "放大", actionId: "zoomIn", readOnly: true, displayMode: "button" }, + { id: "fullscreen", label: "全屏", actionId: "fullscreenCanvas", readOnly: true, displayMode: "button" }, { id: "readonly", label: "只读", actionId: "readonly", readOnly: true, displayMode: "button" }, ], contextMenuItems: [ @@ -179,6 +359,7 @@ export const mindmapDefaultUiSchema: MindmapUiSchema = { { id: "fitView", label: "适应画布", actionId: "fitView", requiresNode: false, phase: 1 }, { id: "search", label: "搜索", actionId: "search", requiresNode: false, phase: 1 }, { id: "readonly", label: "只读切换", actionId: "readonly", requiresNode: false, phase: 1 }, + { id: "showMenu", label: "显示菜单", actionId: "showMenu", requiresNode: false, phase: 1 }, ], }; diff --git a/wolai-frontend/src/lib/mindmap/mindmap-ui-state.test.ts b/wolai-frontend/src/lib/mindmap/mindmap-ui-state.test.ts index aab3b247..1b012146 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-ui-state.test.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-ui-state.test.ts @@ -1,5 +1,9 @@ import { describe, expect, it } from "vitest"; -import { deriveMindmapUiState } from "./mindmap-ui-state"; +import { + createDefaultMindmapShellInteractionState, + deriveMindmapUiState, + reduceMindmapChromeVisibility, +} from "./mindmap-ui-state"; describe("mindmap UI state", () => { it("无 active node 时禁用节点编辑动作,但保留视图动作", () => { @@ -11,6 +15,8 @@ describe("mindmap UI state", () => { expect(state.disabledActions.expandCollapse).toBe(true); expect(state.disabledActions.zoomIn).toBe(false); expect(state.disabledActions.centerRoot).toBe(false); + expect(state.disabledActions.fullscreenCanvas).toBe(false); + expect(state.disabledActions.exitFullscreen).toBe(false); }); it("readonly 时禁用编辑动作,保留搜索和视图动作", () => { @@ -23,6 +29,8 @@ describe("mindmap UI state", () => { expect(state.disabledActions.copyNodeText).toBe(false); expect(state.disabledActions.search).toBe(false); expect(state.disabledActions.zoomOut).toBe(false); + expect(state.disabledActions.fullscreenCanvas).toBe(false); + expect(state.disabledActions.fullscreenPage).toBe(false); }); it("缺少 runtime capability 时禁用对应 action", () => { @@ -35,4 +43,97 @@ describe("mindmap UI state", () => { expect(state.disabledActions.note).toBe(true); expect(state.disabledActions.insertChild).toBe(false); }); + + it("派生默认 shell state,给 Leptos shell 提供稳定合同", () => { + const state = deriveMindmapUiState({ + activeNodeId: "node_1", + readonly: true, + shell: { + chromeVisibility: "hiddenByPointerLeave", + toolbarOverflow: { + availableWidth: 640, + visibleActionIds: ["undo", "redo"], + overflowActionIds: ["image"], + moreOpen: true, + }, + fullscreen: { + mode: "canvas", + isFullscreen: true, + apiAvailable: false, + }, + sidebar: { + triggerVisible: false, + panelOpen: false, + activePanelId: "structure", + collapsedByToggle: true, + }, + navigator: { + searchOpen: true, + minimapOpen: true, + zoomPercent: 138.4, + }, + }, + }); + + expect(state.shell.chromeVisibility).toBe("hiddenByPointerLeave"); + expect(state.shell.toolbarOverflow).toMatchObject({ + availableWidth: 640, + visibleActionIds: ["undo", "redo"], + overflowActionIds: ["image"], + moreOpen: true, + }); + expect(state.shell.fullscreen).toMatchObject({ + mode: "canvas", + isFullscreen: true, + target: "mindmap-root", + apiAvailable: false, + }); + expect(state.shell.sidebar).toMatchObject({ + triggerVisible: false, + panelOpen: false, + activePanelId: "structure", + drawerWidth: 300, + collapsedByToggle: true, + }); + expect(state.shell.navigator).toMatchObject({ + searchOpen: true, + minimapOpen: true, + readonly: true, + zoomPercent: 138, + mouseBehavior: "leftSelectRightDrag", + }); + }); + + it("鼠标移出隐藏 chrome,鼠标移入不自动恢复,点击才恢复", () => { + const hidden = reduceMindmapChromeVisibility("visible", "pointerLeave"); + expect(hidden).toBe("hiddenByPointerLeave"); + expect(reduceMindmapChromeVisibility(hidden, "pointerEnter")).toBe("hiddenByPointerLeave"); + expect(reduceMindmapChromeVisibility(hidden, "restoreClick")).toBe("visible"); + }); + + it("sidebar 隐藏触发条后保留最近 active panel", () => { + const state = createDefaultMindmapShellInteractionState({ + sidebar: { + triggerVisible: false, + panelOpen: false, + activePanelId: "structure", + collapsedByToggle: true, + }, + }); + + expect(state.sidebar.triggerVisible).toBe(false); + expect(state.sidebar.panelOpen).toBe(false); + expect(state.sidebar.activePanelId).toBe("structure"); + expect(state.sidebar.collapsedByToggle).toBe(true); + + const restored = createDefaultMindmapShellInteractionState({ + sidebar: { + ...state.sidebar, + triggerVisible: true, + panelOpen: true, + collapsedByToggle: false, + }, + }); + expect(restored.sidebar.activePanelId).toBe("structure"); + }); }); diff --git a/wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts b/wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts index 70cb14a1..ad917674 100644 --- a/wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts +++ b/wolai-frontend/src/lib/mindmap/mindmap-ui-state.ts @@ -3,18 +3,81 @@ import { mindmapDefaultUiSchema, type MindmapUiActionId } from "./mindmap-ui-sch export type MindmapRuntimeCapability = MindmapActionTarget; +export type MindmapChromeVisibilityState = + | "visible" + | "hiddenByPointerLeave" + | "hiddenByToggle" + | "hiddenByFullscreen"; + +export type MindmapToolbarOverflowState = { + availableWidth: number | null; + visibleActionIds: MindmapUiActionId[]; + overflowActionIds: MindmapUiActionId[]; + moreOpen: boolean; +}; + +export type MindmapFullscreenState = { + mode: "none" | "canvas" | "page"; + isFullscreen: boolean; + target: "mindmap-root" | "document-body"; + apiAvailable: boolean; +}; + +export type MindmapSidebarState = { + triggerVisible: boolean; + panelOpen: boolean; + activePanelId: string | null; + drawerWidth: number; + collapsedByToggle: boolean; +}; + +export type MindmapNavigatorState = { + searchOpen: boolean; + minimapOpen: boolean; + readonly: boolean; + zoomPercent: number; + mouseBehavior: "leftSelectRightDrag" | "leftDragRightMenu"; +}; + +export type MindmapShellInteractionState = { + chromeVisibility: MindmapChromeVisibilityState; + toolbarOverflow: MindmapToolbarOverflowState; + fullscreen: MindmapFullscreenState; + sidebar: MindmapSidebarState; + navigator: MindmapNavigatorState; +}; + export type MindmapUiStateInput = { activeNodeId?: string | null; readonly: boolean; runtimeCapabilities?: MindmapRuntimeCapability[]; + shell?: PartialMindmapShellInteractionState; }; export type MindmapUiState = { activeNodeId: string | null; readonly: boolean; disabledActions: Record; + shell: MindmapShellInteractionState; }; +export type PartialMindmapShellInteractionState = { + chromeVisibility?: MindmapChromeVisibilityState; + toolbarOverflow?: Partial; + fullscreen?: Partial; + sidebar?: Partial; + navigator?: Partial; +}; + +export type MindmapChromeVisibilityEvent = + | "pointerLeave" + | "pointerEnter" + | "restoreClick" + | "hideToggle" + | "showToggle" + | "enterFullscreen" + | "exitFullscreen"; + const allActionIds = (): MindmapUiActionId[] => { const ids = [ ...mindmapDefaultUiSchema.toolbarGroups.flatMap((group) => group.actions), @@ -30,10 +93,80 @@ const normalizeActiveNodeId = (value: string | null | undefined): string | null return trimmed ? trimmed : null; }; +const normalizeZoomPercent = (value: number | undefined): number => { + if (typeof value !== "number" || !Number.isFinite(value)) return 100; + return Math.max(10, Math.min(500, Math.round(value))); +}; + +const unsupportedActionIds = new Set([ + "tag", + "hyperlink", + "note", + "image", + "icon", + "associativeLine", + "formula", + "import", + "export", +]); + +export const createDefaultMindmapShellInteractionState = ( + input: PartialMindmapShellInteractionState = {}, +): MindmapShellInteractionState => ({ + chromeVisibility: input.chromeVisibility ?? "visible", + toolbarOverflow: { + availableWidth: input.toolbarOverflow?.availableWidth ?? null, + visibleActionIds: input.toolbarOverflow?.visibleActionIds ?? [], + overflowActionIds: input.toolbarOverflow?.overflowActionIds ?? [], + moreOpen: input.toolbarOverflow?.moreOpen ?? false, + }, + fullscreen: { + mode: input.fullscreen?.mode ?? "none", + isFullscreen: input.fullscreen?.isFullscreen ?? false, + target: input.fullscreen?.target ?? "mindmap-root", + apiAvailable: input.fullscreen?.apiAvailable ?? true, + }, + sidebar: { + triggerVisible: input.sidebar?.triggerVisible ?? true, + panelOpen: input.sidebar?.panelOpen ?? true, + activePanelId: input.sidebar?.activePanelId ?? mindmapDefaultUiSchema.sidebarPanels[0]?.id ?? null, + drawerWidth: input.sidebar?.drawerWidth ?? 300, + collapsedByToggle: input.sidebar?.collapsedByToggle ?? false, + }, + navigator: { + searchOpen: input.navigator?.searchOpen ?? false, + minimapOpen: input.navigator?.minimapOpen ?? false, + readonly: input.navigator?.readonly ?? false, + zoomPercent: normalizeZoomPercent(input.navigator?.zoomPercent), + mouseBehavior: input.navigator?.mouseBehavior ?? "leftSelectRightDrag", + }, +}); + +export const reduceMindmapChromeVisibility = ( + state: MindmapChromeVisibilityState, + event: MindmapChromeVisibilityEvent, +): MindmapChromeVisibilityState => { + if (event === "pointerLeave") return "hiddenByPointerLeave"; + if (event === "pointerEnter") return state; + if (event === "restoreClick") return "visible"; + if (event === "hideToggle") return "hiddenByToggle"; + if (event === "showToggle") return "visible"; + if (event === "enterFullscreen") return state === "visible" ? "visible" : "hiddenByFullscreen"; + if (event === "exitFullscreen") return state === "hiddenByFullscreen" ? "visible" : state; + return state; +}; + export const deriveMindmapUiState = (input: MindmapUiStateInput): MindmapUiState => { const activeNodeId = normalizeActiveNodeId(input.activeNodeId); const capabilities = input.runtimeCapabilities ? new Set(input.runtimeCapabilities) : null; const disabledActions = {} as Record; + const shell = createDefaultMindmapShellInteractionState({ + ...input.shell, + navigator: { + ...input.shell?.navigator, + readonly: input.readonly, + }, + }); allActionIds().forEach((actionId) => { const mapping = getMindmapActionMapping(actionId); @@ -53,6 +186,10 @@ export const deriveMindmapUiState = (input: MindmapUiStateInput): MindmapUiState disabledActions[actionId] = true; return; } + if (unsupportedActionIds.has(actionId)) { + disabledActions[actionId] = true; + return; + } disabledActions[actionId] = false; }); @@ -60,5 +197,6 @@ export const deriveMindmapUiState = (input: MindmapUiStateInput): MindmapUiState activeNodeId, readonly: input.readonly, disabledActions, + shell, }; }; diff --git a/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.test.ts b/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.test.ts index 823e3bf4..ce47d8d0 100644 --- a/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.test.ts +++ b/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.test.ts @@ -56,6 +56,32 @@ describe("simple-mind-map bridge contract", () => { expect(options.viewData).toEqual({ state: { scale: 0.8, x: 1, y: 2 }, transform: { scaleX: 0.8, scaleY: 0.8 } }); }); + it("fallback projection 默认使用 KMind 风格主题与右向逻辑结构", () => { + const projection = createFallbackMindmapAdapterProjection({ + mindmapId: "mind_1", + root: { data: { text: "KMIND" }, children: [] }, + }); + + expect(projection.layout).toBe("logicalStructure"); + expect(projection.theme).toBe("default"); + expect(projection.themeConfig).toMatchObject({ + lineStyle: "curve", + root: { + fillColor: "#e25563", + color: "#ffffff", + fontWeight: "bold", + }, + second: { + fillColor: "#4f7df3", + color: "#ffffff", + }, + node: { + color: "#315aa9", + }, + generalizationLineColor: "#ef6a5b", + }); + }); + it("保留 runtimeOptions 中的 fit 设置,避免初始导图被裁切", () => { const projection = createFallbackMindmapAdapterProjection({ mindmapId: "mind_1", diff --git a/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts b/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts index addff179..f677434c 100644 --- a/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts +++ b/wolai-frontend/src/lib/mindmap/simple-mind-map-bridge.ts @@ -1,5 +1,8 @@ import { canonicalizeMindmapData, + createDefaultMindmapThemeConfig, + DEFAULT_MINDMAP_LAYOUT, + DEFAULT_MINDMAP_THEME, defaultMindmapData, type MindMapData, } from "./mindmap-projection"; @@ -21,18 +24,40 @@ export type SimpleMindMapInstance = { execCommand?: (command: string, ...args: unknown[]) => unknown; destroy?: () => void; getData?: (withConfig?: boolean) => unknown; + getLayout?: () => unknown; + getTheme?: () => unknown; + getThemeConfig?: (prop?: unknown) => unknown; on?: (event: string, handler: (...args: unknown[]) => void) => void; off?: (event: string, handler: (...args: unknown[]) => void) => void; + setData?: (data: unknown) => void; + setLayout?: (layout: unknown, notRender?: boolean) => void; setMode?: (mode: "edit" | "readonly") => void; + setTheme?: (theme: unknown, notRender?: boolean) => void; + setThemeConfig?: (config: Record, notRender?: boolean) => void; + updateData?: (data: unknown) => void; + updateConfig?: (config?: Record) => void; view?: { scale?: number; enlarge?: () => void; narrow?: () => void; getTransformData?: () => unknown; setScale?: (scale: number, cx: number, cy: number) => void; + fit?: () => void; }; renderer?: { setRootNodeCenter?: () => void; + textEdit?: { + hideEditTextBox?: () => void; + isShowTextEdit?: () => boolean; + }; + clearActiveNodeList?: () => void; + addNodeToActiveList?: (node: unknown, skipBeforeEvent?: boolean) => void; + emitNodeActiveEvent?: (node?: unknown, activeNodeList?: unknown[]) => void; + findNodeByUid?: (uid: string) => unknown; + activeNodeList?: unknown[]; + lastActiveNodeList?: unknown[]; + root?: unknown; + renderTree?: { _node?: unknown }; }; }; @@ -62,6 +87,7 @@ export type SimpleMindMapBridge = { instance: SimpleMindMapInstance; execCommand: (command: string, ...args: unknown[]) => SimpleMindMapSafeCommandResult; getSnapshot: () => unknown; + refreshProjection?: (reason?: string) => Promise; destroy: () => void; }; @@ -125,6 +151,11 @@ const readRecord = (value: unknown): Record => { return {}; }; +const readThemeConfig = (value: unknown): Record => { + if (!isRecord(value) || Object.keys(value).length === 0) return createDefaultMindmapThemeConfig(); + return value; +}; + const readViewData = (value: unknown): Record | null => { if (!isRecord(value) || !isRecord(value.state)) return null; return { @@ -153,9 +184,9 @@ export const buildSimpleMindMapOptions = (input: { : typeof config.fit === "boolean" ? config.fit : true, - layout: readString(input.projection.layout, "logicalStructure"), - theme: readString(input.projection.theme, "classic"), - themeConfig: readRecord(input.projection.themeConfig), + layout: readString(input.projection.layout, DEFAULT_MINDMAP_LAYOUT), + theme: readString(input.projection.theme, DEFAULT_MINDMAP_THEME), + themeConfig: readThemeConfig(input.projection.themeConfig), viewData: readViewData(input.projection.view), initRootNodePosition: ["center", "center"], }; @@ -241,7 +272,9 @@ export const attachSimpleMindMapEventListeners = (input: { SIMPLE_MIND_MAP_BRIDGE_EVENTS.forEach((eventName) => { const handler = (...args: unknown[]) => { const snapshot = - eventName === "data_change" || eventName === "view_data_change" + eventName === "data_change" + ? input.instance.getData?.() + : eventName === "view_data_change" ? input.instance.getData?.(true) ?? input.instance.getData?.() : undefined; input.onEvent?.({ @@ -266,12 +299,14 @@ export const createSimpleMindMapBridge = async (input: { onEvent?: (event: SimpleMindMapBridgeEvent) => void; }): Promise => { const runtime = await loadSimpleMindMapRuntime(input.pluginNames); + const themeConfig = readThemeConfig(input.projection.themeConfig); const options = buildSimpleMindMapOptions({ el: input.el, projection: input.projection, runtimeOptions: input.runtimeOptions, }); const instance = new runtime.MindMap(options); + instance.setThemeConfig?.(themeConfig); if (input.mode) instance.setMode?.(input.mode); const detachEvents = attachSimpleMindMapEventListeners({ @@ -286,6 +321,7 @@ export const createSimpleMindMapBridge = async (input: { execCommand, getSnapshot: () => instance.getData?.(true) ?? instance.getData?.(), destroy: () => { + instance.renderer?.textEdit?.hideEditTextBox?.(); detachEvents(); instance.destroy?.(); }, @@ -300,9 +336,9 @@ export const createFallbackMindmapAdapterProjection = (input: { schema: "mnote.mindmap.simple_mind_map_scene.v1", runtime: "simple-mind-map", root: input.root ?? defaultMindmapData, - layout: "logicalStructure", - theme: "classic", - themeConfig: {}, + layout: DEFAULT_MINDMAP_LAYOUT, + theme: DEFAULT_MINDMAP_THEME, + themeConfig: createDefaultMindmapThemeConfig(), view: {}, config: {}, compatPayload: { source: "frontend-fallback", mindmapId: input.mindmapId }, diff --git a/wolai-frontend/src/lib/onlyoffice/client-session.test.ts b/wolai-frontend/src/lib/onlyoffice/client-session.test.ts index 18a54beb..70bdf4c7 100644 --- a/wolai-frontend/src/lib/onlyoffice/client-session.test.ts +++ b/wolai-frontend/src/lib/onlyoffice/client-session.test.ts @@ -14,14 +14,37 @@ describe("onlyoffice client session helpers", () => { expect(docTypeFromExt("docx")).toBe("word"); expect(docTypeFromExt("xlsx")).toBe("cell"); expect(docTypeFromExt("pptx")).toBe("slide"); - expect(docTypeFromExt("pdf")).toBe("pdf"); + expect(docTypeFromExt("pdf")).toBe("word"); }); - it("inferOnlyOfficeFileType detects Office assets from file name and MIME", () => { + it("inferOnlyOfficeFileType detects only true Office assets from file name and MIME", () => { expect(inferOnlyOfficeFileType("demo.pptx", null)).toBe("pptx"); expect(inferOnlyOfficeFileType("demo", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")).toBe("docx"); - expect(inferOnlyOfficeFileType("demo", "application/pdf")).toBe("pdf"); + expect(inferOnlyOfficeFileType("demo", "application/pdf")).toBeNull(); expect(inferOnlyOfficeFileType("demo.png", "image/png")).toBeNull(); + expect(inferOnlyOfficeFileType("demo.pdf", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.toml", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.json", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.yaml", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.yml", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.md", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.txt", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.ts", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.js", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.py", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.rs", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.go", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.html", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.css", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.vue", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.svelte", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.proto", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.graphql", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.gradle", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.tf", null)).toBeNull(); + expect(inferOnlyOfficeFileType("demo.pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")).toBeNull(); + expect(inferOnlyOfficeFileType("Dockerfile", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")).toBeNull(); + expect(inferOnlyOfficeFileType(".gitignore", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")).toBeNull(); }); it("buildOnlyOfficeAssetOpenUrl keeps attachment identity for callback writeback", () => { diff --git a/wolai-frontend/src/lib/onlyoffice/client-session.ts b/wolai-frontend/src/lib/onlyoffice/client-session.ts index 7535652e..0d804d7e 100644 --- a/wolai-frontend/src/lib/onlyoffice/client-session.ts +++ b/wolai-frontend/src/lib/onlyoffice/client-session.ts @@ -22,11 +22,9 @@ export const docTypeFromExt = (ext: string) => { const word = ["doc", "docx", "odt", "rtf"]; const slide = ["ppt", "pptx", "odp"]; const sheet = ["xls", "xlsx", "ods", "csv"]; - const pdf = ["pdf"]; if (word.includes(ext)) return "word"; if (slide.includes(ext)) return "slide"; if (sheet.includes(ext)) return "cell"; - if (pdf.includes(ext)) return "pdf"; return "word"; }; @@ -34,14 +32,84 @@ export const inferOnlyOfficeFileType = (fileName: string | null | undefined, mim const name = (fileName ?? "").trim().toLowerCase(); const mt = (mimeType ?? "").trim().toLowerCase(); const ext = name.includes(".") ? name.split(".").pop() ?? "" : ""; - if (["doc", "docx", "odt", "rtf"].includes(ext)) return ext; - if (["ppt", "pptx", "odp"].includes(ext)) return ext; - if (["xls", "xlsx", "ods", "csv"].includes(ext)) return ext; - if (ext === "pdf") return ext; + const officeExts = ["doc", "docx", "odt", "rtf", "ppt", "pptx", "odp", "xls", "xlsx", "ods", "csv"]; + const nonOfficeFileNames = [ + ".dockerignore", + ".editorconfig", + ".env", + ".eslintrc", + ".gitattributes", + ".gitignore", + ".npmrc", + ".prettierrc", + "cmakelists.txt", + "dockerfile", + "gemfile", + "makefile", + "procfile", + "rakefile", + ]; + const nonOfficeExts = [ + "pdf", + "toml", + "json", + "jsonc", + "json5", + "yaml", + "yml", + "md", + "markdown", + "txt", + "ini", + "env", + "xml", + "ts", + "tsx", + "js", + "jsx", + "mjs", + "cjs", + "py", + "rs", + "go", + "html", + "htm", + "css", + "scss", + "less", + "vue", + "svelte", + "astro", + "java", + "c", + "cpp", + "h", + "hpp", + "cs", + "php", + "rb", + "sh", + "bash", + "zsh", + "sql", + "lock", + "log", + "proto", + "graphql", + "gql", + "prisma", + "tf", + "tfvars", + "hcl", + "nix", + "gradle", + ]; + if (officeExts.includes(ext)) return ext; + if (nonOfficeFileNames.includes(name)) return null; + if (nonOfficeExts.includes(ext)) return null; if (mt.includes("wordprocessingml")) return "docx"; if (mt.includes("presentationml")) return "pptx"; if (mt.includes("spreadsheetml")) return "xlsx"; - if (mt.includes("pdf")) return "pdf"; return null; };