@fgbg/mdocs 0.8.18 → 0.8.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +1 -1
  2. package/agent-skills/changelog/SKILL.md +7 -1
  3. package/agent-skills/index.json +1 -1
  4. package/dist/web/assets/{AgentChatPanel-DHy3KgSW.js → AgentChatPanel-CLKeiDeR.js} +1 -1
  5. package/dist/web/assets/{AiWriteWorkbench-Ce_OaED4.js → AiWriteWorkbench-Ecp214S5.js} +1 -1
  6. package/dist/web/assets/DiagramEditor-BTRe45TX-DzJEhM4C.js +2 -0
  7. package/dist/web/assets/{DocumentEditor-B2H3rHSg.js → DocumentEditor-NPbbAape.js} +1 -1
  8. package/dist/web/assets/{MergeView-Cy4Pi3Je.js → MergeView-BnWbq08U.js} +1 -1
  9. package/dist/web/assets/{PlaygroundPage-hHfIzPO5.js → PlaygroundPage-BSGipUkC.js} +1 -1
  10. package/dist/web/assets/{SettingsPage-BRAPdqW9.js → SettingsPage-OklrFCx7.js} +1 -1
  11. package/dist/web/assets/{Toolbar-DPkTtGNL.js → Toolbar-DjPuWk5G.js} +1 -1
  12. package/dist/web/assets/{VisitorPickerModal-CJ0K2gj8.js → VisitorPickerModal-BUS-cOq0.js} +1 -1
  13. package/dist/web/assets/{copy-DCKasK29.js → copy-hWOco_4c.js} +1 -1
  14. package/dist/web/assets/{diagram-BJFhx-27.js → diagram-gfUK8OHx.js} +332 -332
  15. package/dist/web/assets/{editor-BBXgdU3Q.js → editor-ONzd_YnO.js} +1 -1
  16. package/dist/web/assets/{history-BQkmetJ0.js → history-AMIEbyMc.js} +1 -1
  17. package/dist/web/assets/{index-CA7lpALZ.js → index-C46BU1-j.js} +3 -3
  18. package/dist/web/assets/meta2d-C8Z4cn-d.js +110 -0
  19. package/dist/web/assets/meta2dEngine-BD2XbzaV-D7hJ1H1g.js +1 -0
  20. package/dist/web/assets/{motion-D-I76zAi.js → motion-C4pN8CfU.js} +1 -1
  21. package/dist/web/assets/{plus-B2rZTPWV.js → plus-CnKbiP8x.js} +1 -1
  22. package/dist/web/assets/react-B7vrA7AR.js +2126 -0
  23. package/dist/web/assets/{ui-C3xtW1w8.js → ui-DxdLi_28.js} +3 -3
  24. package/dist/web/index.html +3 -3
  25. package/package.json +2 -2
  26. package/dist/web/assets/react-CQByW0Rg.js +0 -2236
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  面向个人开发者与小团队:产品内 **智能助手 + 帮写**,外部 **CLI / Skills** 接入 Cursor / Claude;SQLite + 本地文件,**无账户**即可协作。
6
6
 
7
- [文档站点](https://xuhuafeifei.github.io/mdocs-site/) · [GitHub](https://github.com/xuhuafeifei/mdocs) · [npm `@fgbg/mdocs`](https://www.npmjs.com/package/@fgbg/mdocs) · 当前版本 **0.8.18**
7
+ [文档站点](https://xuhuafeifei.github.io/mdocs-site/) · [GitHub](https://github.com/xuhuafeifei/mdocs) · [npm `@fgbg/mdocs`](https://www.npmjs.com/package/@fgbg/mdocs) · 当前版本 **0.8.19**
8
8
 
9
9
  <p align="center">
10
10
  <img src="image/site主页.png" alt="mdocs 文档站点首页" width="860" />
@@ -1,13 +1,19 @@
1
1
  ---
2
2
  id: changelog
3
3
  name: "更新日志"
4
- description: "- **首屏加速**:编辑器 / 设置 / 助手 / 帮写按需懒加载;Vite 拆分重型 vendor chunk,入口 JS 从约 6MB 降到约 134KB - **更快看到侧栏树**:启动时延后全文索引重建(默认约 15s,可用 `MDOCS_INDEX_INITIAL_DELAY_MS` 调整),减轻 HTML TTFB 被 CPU 拖慢 - **加载壳**:`index.html` 增加"
4
+ description: "- **Meta2d 按需加载**:文档没有流程图时不下载 `@meta2d`;有图 / 插入图 / 打开编辑时再加载 - **流程图属性「Text」输入**:防抖写回画布,不再每敲一字全量重绘(依赖 `@fgbg/lobe-editor@1.0.0-fork.19`) - **构建**:Vite `@meta2d` / `canvas2svg` 单独拆成 `meta2d` chunk"
5
5
  keywords: []
6
6
  source: changelog.md
7
7
  ---
8
8
 
9
9
  # 更新日志
10
10
 
11
+ ## v0.8.19
12
+
13
+ - **Meta2d 按需加载**:文档没有流程图时不下载 `@meta2d`;有图 / 插入图 / 打开编辑时再加载
14
+ - **流程图属性「Text」输入**:防抖写回画布,不再每敲一字全量重绘(依赖 `@fgbg/lobe-editor@1.0.0-fork.19`)
15
+ - **构建**:Vite 将 `@meta2d` / `canvas2svg` 单独拆成 `meta2d` chunk
16
+
11
17
  ## v0.8.18
12
18
 
13
19
  - **首屏加速**:编辑器 / 设置 / 助手 / 帮写按需懒加载;Vite 拆分重型 vendor chunk,入口 JS 从约 6MB 降到约 134KB
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "id": "changelog",
4
4
  "name": "更新日志",
5
- "description": "- **首屏加速**:编辑器 / 设置 / 助手 / 帮写按需懒加载;Vite 拆分重型 vendor chunk,入口 JS 从约 6MB 降到约 134KB - **更快看到侧栏树**:启动时延后全文索引重建(默认约 15s,可用 `MDOCS_INDEX_INITIAL_DELAY_MS` 调整),减轻 HTML TTFB 被 CPU 拖慢 - **加载壳**:`index.html` 增加",
5
+ "description": "- **Meta2d 按需加载**:文档没有流程图时不下载 `@meta2d`;有图 / 插入图 / 打开编辑时再加载 - **流程图属性「Text」输入**:防抖写回画布,不再每敲一字全量重绘(依赖 `@fgbg/lobe-editor@1.0.0-fork.19`) - **构建**:Vite `@meta2d` / `canvas2svg` 单独拆成 `meta2d` chunk",
6
6
  "keywords": [],
7
7
  "source": "changelog.md"
8
8
  },
@@ -1 +1 @@
1
- import{r as c,j as e}from"./react-vendor-BNpqFP9B.js";import{a6 as pe,a7 as he,i as te,a8 as fe,a9 as ge,aa as xe,ab as je,ac as ye,ad as Ne,ae as be,af as ke}from"./index-CA7lpALZ.js";import{P as ve}from"./plus-B2rZTPWV.js";import{H as we}from"./history-BQkmetJ0.js";import{M as Se,r as Ie}from"./ui-C3xtW1w8.js";import{C as Ae,a as Ce}from"./copy-DCKasK29.js";import"./motion-D-I76zAi.js";function G(i){var s;return i==null||typeof i=="boolean"?"":typeof i=="string"||typeof i=="number"?String(i):Array.isArray(i)?i.map(G).join(""):typeof i=="object"&&"props"in i?G((s=i.props)==null?void 0:s.children):""}function $e(i){const[s,d]=c.useState(!1),m=c.useRef(null),b=G(i.children).replace(/\n$/,"");c.useEffect(()=>()=>{m.current!=null&&window.clearTimeout(m.current)},[]);async function j(){if(b)try{await navigator.clipboard.writeText(b),d(!0),m.current!=null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>d(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void j(),"aria-label":s?"已复制":"复制代码",title:s?"已复制":"复制",children:s?e.jsx(Ae,{size:14,"aria-hidden":!0}):e.jsx(Ce,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:i.children})]})}function se(i){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(Se,{remarkPlugins:[Ie],components:{pre:({children:s})=>e.jsx($e,{children:s})},children:i.children})})}const _e=["如何发布文档?","草稿是什么?","如何创建域?"];function ne(i,s){return s.map((d,m)=>({id:`h-${i}-${m}-${d.role}`,role:d.role,content:d.content}))}function Re(i,s){const d=i.slice(),m=d[d.length-1];return(m==null?void 0:m.type)==="text"?d[d.length-1]={type:"text",text:m.text+s}:d.push({type:"text",text:s}),d}function ae(i){return i!=null&&i.length?i.filter(s=>s.type==="text").map(s=>s.text).join(""):""}function Ee(i){const s=new Date(i);if(Number.isNaN(s.getTime()))return"";const d=new Date;return s.getFullYear()===d.getFullYear()&&s.getMonth()===d.getMonth()&&s.getDate()===d.getDate()?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function re(i){if(i>=1e3){const s=i/1e3;return`${s>=10?Math.round(s):Math.round(s*10)/10}K`}return String(i)}function Me(i){const{block:s,onResolved:d}=i,[m,b]=c.useState(""),[j,S]=c.useState(!1),[k,v]=c.useState(1),M=c.useRef(!1),w=c.useRef(d);w.current=d;const h=s.status==="open",o=c.useRef(0);c.useEffect(()=>{if(!h)return;M.current=!1;const f=new Date(s.expiresAt).getTime(),y=Date.now(),g=Math.max(f-y,1);o.current=g,v(1);const R=()=>{const D=f-Date.now(),U=Math.max(0,Math.min(1,D/g));v(U),D<=0&&!M.current&&(M.current=!0,be(s.requestId).catch(()=>{}).finally(()=>{w.current(s.requestId,"","expired")}))};R();const E=window.setInterval(R,100);return()=>window.clearInterval(E)},[h,s.expiresAt,s.requestId]);async function _(f){const y=f.trim();if(!(!y||j||!h)){S(!0);try{await ke(s.requestId,y),d(s.requestId,y,"selected")}catch{d(s.requestId,y,"failed")}finally{S(!1)}}}const K=Math.max(0,Math.ceil(k*o.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(h?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:s.title}),h?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[K,"s"]}):null]}),h?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(k*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${k})`}})}):null,s.status==="selected"&&s.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",s.selected]}):null,s.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,s.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,h?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:s.options.map(f=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:j,onClick:()=>void _(f),children:f},f))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:m,disabled:j,placeholder:"或输入自己的内容…",onChange:f=>b(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),_(m))}}),e.jsx("button",{type:"button",disabled:j||!m.trim(),onClick:()=>void _(m),children:"提交"})]})]}):null]})}function De(i){const b=2*Math.PI*8.75,j=Math.min(100,Math.max(0,i.percent)),S=b*(1-j/100),k=j>=90?"danger":j>=70?"warn":"ok",v=`上下文 ${j}% · 已用 ${re(i.used)} / ${re(i.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+k,"data-tooltip":v,"aria-label":v,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:S,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function Ue(i){const{open:s,onClose:d,visitorName:m,anchorStyle:b,onOpenDocument:j,onTreeChanged:S,onDocumentOverwritten:k,onOpenCoding:v}=i,M=((m==null?void 0:m.trim().charAt(0))||"我").toUpperCase(),[w,h]=c.useState(!1),[o,_]=c.useState(null),[K,f]=c.useState(null),[y,g]=c.useState([]),[R,E]=c.useState(null),[D,U]=c.useState([]),[ie,X]=c.useState(!1),[z,T]=c.useState(""),[N,F]=c.useState(!1),[Y,I]=c.useState(null),[P,J]=c.useState(null),ce=c.useRef(null),B=c.useRef(null),A=c.useRef(null),Q=c.useRef(0),q=c.useRef(!0);function V(t){return Q.current+=1,`${t}-${Q.current}`}function le(t,u=48){return t.scrollHeight-t.scrollTop-t.clientHeight<=u}function C(){const t=B.current;!t||!q.current||(t.scrollTop=t.scrollHeight)}function oe(){const t=B.current;t&&(q.current=le(t))}async function de(){X(!0);try{const t=await xe();U(t.sessions),R||E(t.lastOpenedSessionId)}catch{}finally{X(!1)}}async function H(){try{const t=await ge();J(t)}catch{}}c.useEffect(()=>{var u;if(!s){h(!1),(u=A.current)==null||u.abort(),A.current=null,F(!1);return}let t=!1;return(async()=>{try{const n=await pe();t||(_(n),f(null))}catch(n){t||(_(null),f(n instanceof Error?n.message:String(n)))}})(),H(),()=>{t=!0}},[s]),c.useEffect(()=>{if(!s)return;let t=!1;return(async()=>{try{const u=await he();if(t)return;E(u.sessionId),g(n=>n.length>0?n:ne(u.sessionId,u.messages))}catch{}})(),()=>{t=!0}},[s]),c.useEffect(()=>{!s||!w||de()},[s,w]),c.useEffect(()=>{if(!s)return;const t=u=>{if(u.key==="Escape"){if(w){h(!1);return}d()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[s,d,w]);async function W(t){var L;const u=t.trim();if(!u||N)return;if(!(o!=null&&o.enabled)){I((o==null?void 0:o.reason)==="missing_api_key"?"请先在设置 → AI 配置 DeepSeek API Key":(o==null?void 0:o.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(L=A.current)==null||L.abort();const n=new AbortController;A.current=n;const $={id:V("u"),role:"user",content:u},p=V("a");q.current=!0,g(a=>[...a,$,{id:p,role:"assistant",content:""}]),T(""),F(!0),I(null),h(!1),requestAnimationFrame(()=>C());try{await Ne(u,{signal:n.signal,onEvent:a=>{a.type==="text_delta"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=Re(r.blocks??[],a.text);return{...r,blocks:l,content:ae(l)}})),requestAnimationFrame(()=>C())):a.type==="sources"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=(r.blocks??[]).slice(),O=l[l.length-1];return(O==null?void 0:O.type)==="sources"?l[l.length-1]={type:"sources",items:a.items}:l.push({type:"sources",items:a.items}),{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="document_table"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"document_table",title:a.title,rows:a.rows}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="document_card"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"document_card",documentId:a.documentId,title:a.title,path:a.path,preview:a.preview}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="tool_notice"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"tool_notice",toolName:a.toolName,text:a.text}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="choice_card"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"choice_card",requestId:a.requestId,title:a.title,options:a.options,expiresAt:a.expiresAt,status:"open"}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="choice_expired"?g(x=>x.map(r=>r.id!==p||!r.blocks?r:{...r,blocks:r.blocks.map(l=>l.type==="choice_card"&&l.requestId===a.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):a.type==="tree_changed"?S==null||S():a.type==="document_overwritten"?k==null||k({documentId:a.documentId,headCommitId:a.headCommitId}):a.type==="open_coding"?v==null||v({documentId:a.documentId,displayName:a.displayName}):a.type==="context_usage"?J({percent:a.percent,used:a.used,limit:a.limit}):a.type==="error"&&I(a.message)}})}catch(a){if(n.signal.aborted)return;I(a instanceof Error?a.message:String(a))}finally{A.current===n&&(A.current=null),F(!1)}}async function ue(){var t;if(!N){(t=A.current)==null||t.abort(),I(null),h(!1),F(!1);try{const u=await je();E(u.sessionId),g([]),T(""),q.current=!0,H()}catch(u){I(u instanceof Error?u.message:String(u))}}}async function me(t){var u;if(!N){if(t===R){h(!1);return}(u=A.current)==null||u.abort(),I(null);try{const n=await ye(t);E(n.sessionId),g(ne(n.sessionId,n.messages)),T(""),h(!1),q.current=!0,requestAnimationFrame(()=>C()),H()}catch(n){I(n instanceof Error?n.message:String(n))}}}function Z(t){!t||!j||j(t)}if(!s)return null;const ee=K??(o&&!o.enabled?o.reason==="missing_api_key"?"未配置 API Key:请打开设置 → AI":o.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:ce,className:"mdocs-agent-panel",role:"dialog","aria-label":"mdocs 智能助手",style:b,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:te,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:N,onClick:()=>void ue(),children:e.jsx(ve,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(w?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>h(t=>!t),children:e.jsx(we,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:d,children:e.jsx(fe,{size:16,strokeWidth:1.8})})]})]}),w?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>h(!1),children:"返回对话"})]}),ie?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):D.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:D.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===R?" active":""),disabled:N,onClick:()=>void me(t.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:Ee(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:B,onScroll:oe,children:y.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),ee?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ee}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:_e.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void W(t),disabled:N||!(o!=null&&o.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:y.map(t=>{var u;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(t.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[t.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:te,alt:""})}):null,e.jsx("div",{className:"mdocs-agent-panel-msg-bubble",children:t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((n,$)=>n.type==="text"?n.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(se,{children:n.text})},`${t.id}-t-${$}`):null:n.type==="sources"?n.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",n.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:n.items.map(p=>e.jsx("li",{children:e.jsx("a",{href:p.url,target:"_blank",rel:"noreferrer",children:p.name})},p.id))})]})},`${t.id}-s-${$}`):n.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:n.text})},`${t.id}-n-${$}`):n.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Me,{block:n,onResolved:(p,L,a)=>{g(x=>x.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(l=>l.type==="choice_card"&&l.requestId===p?{...l,status:a,selected:a==="selected"?L:l.selected}:l)}))}})},`${t.id}-ch-${$}`):n.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:p=>{p.preventDefault(),p.stopPropagation(),Z(n.documentId)},children:["《",n.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[n.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:n.path}):null,n.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:n.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${$}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[n.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:n.rows.length===0?"无结果":`${n.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:n.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:n.rows.map(p=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>Z(p.documentId),children:p.title})}),e.jsx("td",{children:p.summary||"-"})]},p.documentId))})]})})]})},`${t.id}-d-${$}`)),N&&t.id===((u=y[y.length-1])==null?void 0:u.id)&&!ae(t.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):t.content?e.jsx(se,{children:t.content}):N?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:t.content}),t.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:M}):null]},t.id)})})}),Y?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Y}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:o!=null&&o.enabled?"把你的问题告诉我…":"请先配置 API Key",value:z,disabled:N||!(o!=null&&o.enabled),onChange:t=>T(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),W(z))}}),P?e.jsx(De,{percent:P.percent,used:P.used,limit:P.limit}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-send",disabled:N||!(o!=null&&o.enabled)||!z.trim(),onClick:()=>void W(z),title:"发送",children:"↑"})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]})]})}export{Ue as AgentChatPanel};
1
+ import{r as c,j as e}from"./react-vendor-BNpqFP9B.js";import{a6 as pe,a7 as he,i as te,a8 as fe,a9 as ge,aa as xe,ab as je,ac as ye,ad as Ne,ae as be,af as ke}from"./index-C46BU1-j.js";import{P as ve}from"./plus-CnKbiP8x.js";import{H as we}from"./history-AMIEbyMc.js";import{M as Se,r as Ie}from"./ui-DxdLi_28.js";import{C as Ae,a as Ce}from"./copy-hWOco_4c.js";import"./motion-C4pN8CfU.js";function G(i){var s;return i==null||typeof i=="boolean"?"":typeof i=="string"||typeof i=="number"?String(i):Array.isArray(i)?i.map(G).join(""):typeof i=="object"&&"props"in i?G((s=i.props)==null?void 0:s.children):""}function $e(i){const[s,d]=c.useState(!1),m=c.useRef(null),b=G(i.children).replace(/\n$/,"");c.useEffect(()=>()=>{m.current!=null&&window.clearTimeout(m.current)},[]);async function j(){if(b)try{await navigator.clipboard.writeText(b),d(!0),m.current!=null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>d(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void j(),"aria-label":s?"已复制":"复制代码",title:s?"已复制":"复制",children:s?e.jsx(Ae,{size:14,"aria-hidden":!0}):e.jsx(Ce,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:i.children})]})}function se(i){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(Se,{remarkPlugins:[Ie],components:{pre:({children:s})=>e.jsx($e,{children:s})},children:i.children})})}const _e=["如何发布文档?","草稿是什么?","如何创建域?"];function ne(i,s){return s.map((d,m)=>({id:`h-${i}-${m}-${d.role}`,role:d.role,content:d.content}))}function Re(i,s){const d=i.slice(),m=d[d.length-1];return(m==null?void 0:m.type)==="text"?d[d.length-1]={type:"text",text:m.text+s}:d.push({type:"text",text:s}),d}function ae(i){return i!=null&&i.length?i.filter(s=>s.type==="text").map(s=>s.text).join(""):""}function Ee(i){const s=new Date(i);if(Number.isNaN(s.getTime()))return"";const d=new Date;return s.getFullYear()===d.getFullYear()&&s.getMonth()===d.getMonth()&&s.getDate()===d.getDate()?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function re(i){if(i>=1e3){const s=i/1e3;return`${s>=10?Math.round(s):Math.round(s*10)/10}K`}return String(i)}function Me(i){const{block:s,onResolved:d}=i,[m,b]=c.useState(""),[j,S]=c.useState(!1),[k,v]=c.useState(1),M=c.useRef(!1),w=c.useRef(d);w.current=d;const h=s.status==="open",o=c.useRef(0);c.useEffect(()=>{if(!h)return;M.current=!1;const f=new Date(s.expiresAt).getTime(),y=Date.now(),g=Math.max(f-y,1);o.current=g,v(1);const R=()=>{const D=f-Date.now(),U=Math.max(0,Math.min(1,D/g));v(U),D<=0&&!M.current&&(M.current=!0,be(s.requestId).catch(()=>{}).finally(()=>{w.current(s.requestId,"","expired")}))};R();const E=window.setInterval(R,100);return()=>window.clearInterval(E)},[h,s.expiresAt,s.requestId]);async function _(f){const y=f.trim();if(!(!y||j||!h)){S(!0);try{await ke(s.requestId,y),d(s.requestId,y,"selected")}catch{d(s.requestId,y,"failed")}finally{S(!1)}}}const K=Math.max(0,Math.ceil(k*o.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(h?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:s.title}),h?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[K,"s"]}):null]}),h?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(k*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${k})`}})}):null,s.status==="selected"&&s.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",s.selected]}):null,s.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,s.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,h?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:s.options.map(f=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:j,onClick:()=>void _(f),children:f},f))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:m,disabled:j,placeholder:"或输入自己的内容…",onChange:f=>b(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),_(m))}}),e.jsx("button",{type:"button",disabled:j||!m.trim(),onClick:()=>void _(m),children:"提交"})]})]}):null]})}function De(i){const b=2*Math.PI*8.75,j=Math.min(100,Math.max(0,i.percent)),S=b*(1-j/100),k=j>=90?"danger":j>=70?"warn":"ok",v=`上下文 ${j}% · 已用 ${re(i.used)} / ${re(i.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+k,"data-tooltip":v,"aria-label":v,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:b,strokeDashoffset:S,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function Ue(i){const{open:s,onClose:d,visitorName:m,anchorStyle:b,onOpenDocument:j,onTreeChanged:S,onDocumentOverwritten:k,onOpenCoding:v}=i,M=((m==null?void 0:m.trim().charAt(0))||"我").toUpperCase(),[w,h]=c.useState(!1),[o,_]=c.useState(null),[K,f]=c.useState(null),[y,g]=c.useState([]),[R,E]=c.useState(null),[D,U]=c.useState([]),[ie,X]=c.useState(!1),[z,T]=c.useState(""),[N,F]=c.useState(!1),[Y,I]=c.useState(null),[P,J]=c.useState(null),ce=c.useRef(null),B=c.useRef(null),A=c.useRef(null),Q=c.useRef(0),q=c.useRef(!0);function V(t){return Q.current+=1,`${t}-${Q.current}`}function le(t,u=48){return t.scrollHeight-t.scrollTop-t.clientHeight<=u}function C(){const t=B.current;!t||!q.current||(t.scrollTop=t.scrollHeight)}function oe(){const t=B.current;t&&(q.current=le(t))}async function de(){X(!0);try{const t=await xe();U(t.sessions),R||E(t.lastOpenedSessionId)}catch{}finally{X(!1)}}async function H(){try{const t=await ge();J(t)}catch{}}c.useEffect(()=>{var u;if(!s){h(!1),(u=A.current)==null||u.abort(),A.current=null,F(!1);return}let t=!1;return(async()=>{try{const n=await pe();t||(_(n),f(null))}catch(n){t||(_(null),f(n instanceof Error?n.message:String(n)))}})(),H(),()=>{t=!0}},[s]),c.useEffect(()=>{if(!s)return;let t=!1;return(async()=>{try{const u=await he();if(t)return;E(u.sessionId),g(n=>n.length>0?n:ne(u.sessionId,u.messages))}catch{}})(),()=>{t=!0}},[s]),c.useEffect(()=>{!s||!w||de()},[s,w]),c.useEffect(()=>{if(!s)return;const t=u=>{if(u.key==="Escape"){if(w){h(!1);return}d()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[s,d,w]);async function W(t){var L;const u=t.trim();if(!u||N)return;if(!(o!=null&&o.enabled)){I((o==null?void 0:o.reason)==="missing_api_key"?"请先在设置 → AI 配置 DeepSeek API Key":(o==null?void 0:o.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(L=A.current)==null||L.abort();const n=new AbortController;A.current=n;const $={id:V("u"),role:"user",content:u},p=V("a");q.current=!0,g(a=>[...a,$,{id:p,role:"assistant",content:""}]),T(""),F(!0),I(null),h(!1),requestAnimationFrame(()=>C());try{await Ne(u,{signal:n.signal,onEvent:a=>{a.type==="text_delta"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=Re(r.blocks??[],a.text);return{...r,blocks:l,content:ae(l)}})),requestAnimationFrame(()=>C())):a.type==="sources"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=(r.blocks??[]).slice(),O=l[l.length-1];return(O==null?void 0:O.type)==="sources"?l[l.length-1]={type:"sources",items:a.items}:l.push({type:"sources",items:a.items}),{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="document_table"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"document_table",title:a.title,rows:a.rows}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="document_card"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"document_card",documentId:a.documentId,title:a.title,path:a.path,preview:a.preview}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="tool_notice"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"tool_notice",toolName:a.toolName,text:a.text}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="choice_card"?(g(x=>x.map(r=>{if(r.id!==p)return r;const l=[...r.blocks??[],{type:"choice_card",requestId:a.requestId,title:a.title,options:a.options,expiresAt:a.expiresAt,status:"open"}];return{...r,blocks:l}})),requestAnimationFrame(()=>C())):a.type==="choice_expired"?g(x=>x.map(r=>r.id!==p||!r.blocks?r:{...r,blocks:r.blocks.map(l=>l.type==="choice_card"&&l.requestId===a.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):a.type==="tree_changed"?S==null||S():a.type==="document_overwritten"?k==null||k({documentId:a.documentId,headCommitId:a.headCommitId}):a.type==="open_coding"?v==null||v({documentId:a.documentId,displayName:a.displayName}):a.type==="context_usage"?J({percent:a.percent,used:a.used,limit:a.limit}):a.type==="error"&&I(a.message)}})}catch(a){if(n.signal.aborted)return;I(a instanceof Error?a.message:String(a))}finally{A.current===n&&(A.current=null),F(!1)}}async function ue(){var t;if(!N){(t=A.current)==null||t.abort(),I(null),h(!1),F(!1);try{const u=await je();E(u.sessionId),g([]),T(""),q.current=!0,H()}catch(u){I(u instanceof Error?u.message:String(u))}}}async function me(t){var u;if(!N){if(t===R){h(!1);return}(u=A.current)==null||u.abort(),I(null);try{const n=await ye(t);E(n.sessionId),g(ne(n.sessionId,n.messages)),T(""),h(!1),q.current=!0,requestAnimationFrame(()=>C()),H()}catch(n){I(n instanceof Error?n.message:String(n))}}}function Z(t){!t||!j||j(t)}if(!s)return null;const ee=K??(o&&!o.enabled?o.reason==="missing_api_key"?"未配置 API Key:请打开设置 → AI":o.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:ce,className:"mdocs-agent-panel",role:"dialog","aria-label":"mdocs 智能助手",style:b,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:te,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:N,onClick:()=>void ue(),children:e.jsx(ve,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(w?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>h(t=>!t),children:e.jsx(we,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:d,children:e.jsx(fe,{size:16,strokeWidth:1.8})})]})]}),w?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>h(!1),children:"返回对话"})]}),ie?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):D.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:D.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===R?" active":""),disabled:N,onClick:()=>void me(t.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:Ee(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:B,onScroll:oe,children:y.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),ee?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ee}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:_e.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void W(t),disabled:N||!(o!=null&&o.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:y.map(t=>{var u;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(t.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[t.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:te,alt:""})}):null,e.jsx("div",{className:"mdocs-agent-panel-msg-bubble",children:t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((n,$)=>n.type==="text"?n.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(se,{children:n.text})},`${t.id}-t-${$}`):null:n.type==="sources"?n.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",n.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:n.items.map(p=>e.jsx("li",{children:e.jsx("a",{href:p.url,target:"_blank",rel:"noreferrer",children:p.name})},p.id))})]})},`${t.id}-s-${$}`):n.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:n.text})},`${t.id}-n-${$}`):n.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Me,{block:n,onResolved:(p,L,a)=>{g(x=>x.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(l=>l.type==="choice_card"&&l.requestId===p?{...l,status:a,selected:a==="selected"?L:l.selected}:l)}))}})},`${t.id}-ch-${$}`):n.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:p=>{p.preventDefault(),p.stopPropagation(),Z(n.documentId)},children:["《",n.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[n.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:n.path}):null,n.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:n.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${$}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[n.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:n.rows.length===0?"无结果":`${n.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:n.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:n.rows.map(p=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>Z(p.documentId),children:p.title})}),e.jsx("td",{children:p.summary||"-"})]},p.documentId))})]})})]})},`${t.id}-d-${$}`)),N&&t.id===((u=y[y.length-1])==null?void 0:u.id)&&!ae(t.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):t.content?e.jsx(se,{children:t.content}):N?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:t.content}),t.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:M}):null]},t.id)})})}),Y?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Y}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:o!=null&&o.enabled?"把你的问题告诉我…":"请先配置 API Key",value:z,disabled:N||!(o!=null&&o.enabled),onChange:t=>T(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),W(z))}}),P?e.jsx(De,{percent:P.percent,used:P.used,limit:P.limit}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-send",disabled:N||!(o!=null&&o.enabled)||!z.trim(),onClick:()=>void W(z),title:"发送",children:"↑"})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]})]})}export{Ue as AgentChatPanel};
@@ -1,4 +1,4 @@
1
- import{r as u,j as n}from"./react-vendor-BNpqFP9B.js";import{a6 as ee,a7 as ne,i as te,aa as se,ag as ie,ab as ae,ac as oe,ad as le}from"./index-CA7lpALZ.js";import{P as re}from"./plus-B2rZTPWV.js";import{H as ce}from"./history-BQkmetJ0.js";import{M as de,r as ue}from"./ui-C3xtW1w8.js";import"./motion-D-I76zAi.js";function T(e){return e===""?[]:e.split(`
1
+ import{r as u,j as n}from"./react-vendor-BNpqFP9B.js";import{a6 as ee,a7 as ne,i as te,aa as se,ag as ie,ab as ae,ac as oe,ad as le}from"./index-C46BU1-j.js";import{P as re}from"./plus-CnKbiP8x.js";import{H as ce}from"./history-AMIEbyMc.js";import{M as de,r as ue}from"./ui-DxdLi_28.js";import"./motion-C4pN8CfU.js";function T(e){return e===""?[]:e.split(`
2
2
  `)}function U(e){return e.join(`
3
3
  `)}function R(e,s){const i=T(e),r=T(s),c=i.length,g=r.length,y=Array.from({length:c+1},()=>Array.from({length:g+1},()=>0));for(let j=c-1;j>=0;j--)for(let b=g-1;b>=0;b--)i[j]===r[b]?y[j][b]=y[j+1][b+1]+1:y[j][b]=Math.max(y[j+1][b],y[j][b+1]);const l=[];let p=0,h=0;for(;p<c||h<g;)if(p<c&&h<g&&i[p]===r[h])l.push({kind:"eq",oi:p,ni:h}),p++,h++;else if(h<g&&(p===c||y[p][h+1]>=y[p+1][h]))l.push({kind:"ins",oi:p,ni:h}),h++;else if(p<c)l.push({kind:"del",oi:p,ni:h}),p++;else break;const S=[];let x=0,E=0;for(;x<l.length;){if(l[x].kind==="eq"){x++;continue}const j=l[x].oi,b=l[x].ni,$=[],M=[];let a=j,f=b;for(;x<l.length&&l[x].kind!=="eq";){const w=l[x];w.kind==="del"?($.push(i[w.oi]),a=w.oi+1):(M.push(r[w.ni]),f=w.ni+1),x++}S.push({id:`h${E++}`,oldStart:j,oldEnd:a,newStart:b,newEnd:f,oldLines:$,newLines:M})}return S}function me(e,s){const i=T(e);return U([...i.slice(0,s.oldStart),...s.newLines,...i.slice(s.oldEnd)])}function he(e,s){const i=T(e);return U([...i.slice(0,s.newStart),...s.oldLines,...i.slice(s.newEnd)])}function fe(e){return e===""?[]:e.split(`
4
4
  `)}function ge(e,s){const i=fe(e),r=[];let c=0;return s.forEach((g,y)=>{g.oldStart>c&&r.push({kind:"same",lines:i.slice(c,g.oldStart),key:`s-${c}-${g.oldStart}`}),r.push({kind:"hunk",hunk:g,hunkIndex:y,key:`h-${g.id}-${y}`}),c=g.oldEnd}),c<i.length?r.push({kind:"same",lines:i.slice(c),key:`s-${c}-end`}):s.length===0&&i.length===0&&r.push({kind:"same",lines:[],key:"s-empty"}),r}function xe(e){return e.oldLines.length===0?"add":e.newLines.length===0?"del":"mod"}function ke(e){const[s,i]=u.useState(!1),[r,c]=u.useState(0),[g,y]=u.useState(null),l=u.useMemo(()=>e.proposedMd==null||e.proposedMd===e.currentMd?[]:R(e.currentMd,e.proposedMd),[e.currentMd,e.proposedMd]),p=u.useMemo(()=>ge(e.currentMd,l),[e.currentMd,l]);u.useEffect(()=>{if(l.length===0){c(0);return}c(a=>Math.min(a,l.length-1))},[l.length]);const h=!s&&l.length>0,S=g??r;function x(a){const f=me(e.currentMd,a);e.onCurrentChange(f),e.proposedMd!=null&&R(f,e.proposedMd).length===0&&e.onProposedChange(null)}function E(a){if(e.proposedMd==null)return;const f=he(e.proposedMd,a);f===e.currentMd?e.onProposedChange(null):e.onProposedChange(f)}function j(){e.proposedMd!=null&&(e.onCurrentChange(e.proposedMd),e.onProposedChange(null))}function b(){e.onProposedChange(null)}function $(a){l.length!==0&&c(f=>{const w=(f+a+l.length)%l.length,N=document.getElementById(`mdocs-ai-hunk-${w}`);return N==null||N.scrollIntoView({block:"center",behavior:"smooth"}),w})}const M=l[S]??null;return n.jsxs("div",{className:"mdocs-ai-write-md-pane",children:[n.jsxs("div",{className:"mdocs-ai-write-diff-toolbar",children:[n.jsx("span",{className:"mdocs-ai-write-diff-count",children:l.length===0?s||!e.proposedMd?"Markdown 源码(可编辑)":"与提案一致":`${l.length} 处变更`}),l.length>0?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:j,children:"全部接受"}),n.jsx("button",{type:"button",onClick:b,children:"全部拒绝"})]}):null,n.jsx("button",{type:"button",className:s?"active":"",onClick:()=>i(a=>!a),children:s?"回到 diff":"纯编辑"})]}),h?n.jsxs("div",{className:"mdocs-ai-write-inline",role:"document",children:[p.map(a=>{if(a.kind==="same")return n.jsx("pre",{className:"mdocs-ai-write-inline-same",children:a.lines.map((C,k)=>n.jsxs("div",{className:"mdocs-ai-write-line ctx",children:[n.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),n.jsx("span",{className:"mdocs-ai-write-code",children:C||" "})]},k))},a.key);const f=a.hunk,w=xe(f),N=a.hunkIndex===S;return n.jsxs("div",{id:`mdocs-ai-hunk-${a.hunkIndex}`,className:`mdocs-ai-write-inline-hunk mdocs-ai-write-inline-hunk-${w}`+(N?" is-active":""),onMouseEnter:()=>y(a.hunkIndex),onMouseLeave:()=>y(null),onClick:()=>c(a.hunkIndex),children:[n.jsxs("div",{className:"mdocs-ai-write-hunk-hover",hidden:g!==a.hunkIndex,children:[n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:C=>{C.stopPropagation(),E(f)},children:"拒绝"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:C=>{C.stopPropagation(),x(f)},children:"接受"})]}),n.jsxs("pre",{className:"mdocs-ai-write-hunk-pre",children:[f.oldLines.map((C,k)=>n.jsxs("div",{className:"mdocs-ai-write-line del",children:[n.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),n.jsx("span",{className:"mdocs-ai-write-code",children:C||" "})]},`o${k}`)),f.newLines.map((C,k)=>n.jsxs("div",{className:"mdocs-ai-write-line add",children:[n.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),n.jsx("span",{className:"mdocs-ai-write-code",children:C||" "})]},`n${k}`))]})]},a.key)}),M?n.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"变更导航",children:[n.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>$(-1),children:"↑"}),n.jsxs("span",{children:[S+1," / ",l.length]}),n.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>$(1),children:"↓"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>E(M),children:"拒绝"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>x(M),children:"接受"})]}):null]}):n.jsx("textarea",{className:"mdocs-ai-write-editor",value:e.currentMd,onChange:a=>e.onCurrentChange(a.target.value),spellCheck:!1,placeholder:`# 标题
@@ -0,0 +1,2 @@
1
+ import{Q as M,S as F,T as A,U as W,V}from"./react-B7vrA7AR.js";import{r as c,j as e}from"./react-vendor-BNpqFP9B.js";import{ensureMeta2dShapes as N,generateSvgFromMeta2d as q,generateSvgFromDiagram as I}from"./meta2dEngine-BD2XbzaV-D7hJ1H1g.js";import{M as G}from"./meta2d-C8Z4cn-d.js";import"./editor-ONzd_YnO.js";import"./ui-DxdLi_28.js";import"./motion-C4pN8CfU.js";import"./diagram-gfUK8OHx.js";import"./index-C46BU1-j.js";import"./plus-CnKbiP8x.js";import"./copy-hWOco_4c.js";let T=0;const D=new Set;function O(n){return D.add(n),()=>{D.delete(n)}}function P(){return T}function Q(){T++,D.forEach(n=>n())}function E(n){let t=null;try{const[a]=M();t=a}catch{}const l=t;if(!l)throw new Error("[useEditorLocale] No editor found. Pass an editor instance or use this hook inside an <Editor> tree.");return c.useSyncExternalStore(O,P,P),{setLocale:c.useCallback(a=>{l.setLocale(a),Q()},[l]),t:c.useCallback((a,p)=>l.t(a,p),[l])}}const X={Activity:"meta2d.palette.groups.activity",Basic:"meta2d.palette.groups.basic","Fault tree":"meta2d.palette.groups.faultTree",Flow:"meta2d.palette.groups.flow","Sequence & class":"meta2d.palette.groups.sequenceClass"};function L(n){return`meta2d.palette.${n}`}const s={background:"#fff",color:"#1f1f1f",height:60,lineWidth:1,textColor:"#1f1f1f",width:120};function Y(){return[{group:"Basic",key:"square",label:"Square",pen:{...s,height:100,name:"square",text:"",width:100}},{group:"Basic",key:"rect",label:"Rectangle",pen:{...s,name:"rectangle",text:"Rectangle"}},{group:"Basic",key:"roundRect",label:"Rounded",pen:{...s,borderRadius:.2,name:"rectangle",text:"Rounded"}},{group:"Basic",key:"circle",label:"Circle",pen:{...s,height:80,name:"circle",text:"Circle",width:80}},{group:"Basic",key:"triangle",label:"Triangle",pen:{...s,height:90,name:"triangle",text:"Triangle",width:100}},{group:"Basic",key:"diamond",label:"Diamond",pen:{...s,height:100,name:"diamond",text:"Decision",width:100}},{group:"Basic",key:"pentagon",label:"Pentagon",pen:{...s,height:100,name:"pentagon",text:"Pentagon",width:100}},{group:"Basic",key:"hexagon",label:"Hexagon",pen:{...s,height:100,name:"hexagon",text:"Hexagon",width:100}},{group:"Basic",key:"pentagram",label:"Star",pen:{...s,height:100,name:"pentagram",text:"",width:100}},{group:"Basic",key:"leftArrow",label:"Left arrow",pen:{height:60,name:"leftArrow",width:120}},{group:"Basic",key:"rightArrow",label:"Right arrow",pen:{height:60,name:"rightArrow",width:120}},{group:"Basic",key:"twowayArrow",label:"Two-way",pen:{height:60,name:"twowayArrow",width:150}},{group:"Basic",key:"cloud",label:"Cloud",pen:{height:100,name:"cloud",width:100}},{group:"Basic",key:"message",label:"Message",pen:{height:100,name:"message",textTop:-.1,width:100}},{group:"Basic",key:"file",label:"File",pen:{height:100,name:"file",width:80}},{group:"Basic",key:"cube",label:"Cube",pen:{height:100,name:"cube",width:60,z:.25}},{group:"Basic",key:"people",label:"Actor",pen:{height:100,name:"people",width:70}},{group:"Basic",key:"text",label:"Text",pen:{...s,background:"transparent",color:"transparent",height:32,name:"text",text:"text",width:120}},{group:"Basic",key:"line",label:"Line",pen:{color:"#1f1f1f",height:1,lineWidth:1,name:"line",width:160}},{group:"Flow",key:"flowTerminal",label:"Terminal",pen:{...s,borderRadius:.5,height:40,name:"rectangle",text:"Start / End",width:120}},{group:"Flow",key:"flowProcess",label:"Process",pen:{...s,height:40,name:"rectangle",text:"Process",width:120}},{group:"Flow",key:"flowDecision",label:"Decision",pen:{...s,height:60,name:"diamond",text:"Decision",width:120}},{group:"Flow",key:"flowData",label:"Data",pen:{...s,name:"flowData",offsetX:.14,text:"Data"}},{group:"Flow",key:"flowPrepare",label:"Prepare",pen:{...s,height:50,name:"hexagon",text:"Prepare",width:120}},{group:"Flow",key:"flowSubprocess",label:"Subprocess",pen:{...s,height:50,name:"flowSubprocess",text:"Subprocess",width:120}},{group:"Flow",key:"flowDb",label:"Database",pen:{...s,height:100,name:"flowDb",text:"DB",width:80}},{group:"Flow",key:"flowDocument",label:"Document",pen:{...s,height:100,name:"flowDocument",text:"Document",width:120}},{group:"Flow",key:"flowInternalStorage",label:"Int. storage",pen:{...s,height:80,name:"flowInternalStorage",text:"Internal",width:120}},{group:"Flow",key:"flowExternStorage",label:"Ext. storage",pen:{...s,height:80,name:"flowExternStorage",text:"External",width:120}},{group:"Flow",key:"flowQueue",label:"Queue",pen:{...s,height:100,name:"flowQueue",text:"Queue",width:100}},{group:"Flow",key:"flowManually",label:"Manual input",pen:{...s,height:80,name:"flowManually",text:"Manual",width:120}},{group:"Flow",key:"flowDisplay",label:"Display",pen:{...s,height:80,name:"flowDisplay",text:"Display",width:120}},{group:"Flow",key:"flowParallel",label:"Parallel",pen:{...s,height:50,name:"flowParallel",text:"Parallel",width:120}},{group:"Flow",key:"flowComment",label:"Comment",pen:{...s,height:100,name:"flowComment",text:"Note",width:100}},{group:"Activity",key:"actStart",label:"Start",pen:{background:"#555",height:30,lineWidth:0,name:"circle",text:"",width:30}},{group:"Activity",key:"actFinal",label:"Final",pen:{height:30,name:"activityFinal",width:30}},{group:"Activity",key:"actStep",label:"Action",pen:{...s,borderRadius:.25,height:50,name:"rectangle",text:"Action",width:120}},{group:"Activity",key:"actMerge",label:"Merge",pen:{...s,height:50,name:"diamond",text:"Merge",width:120}},{group:"Activity",key:"swimlaneV",label:"Swimlane V",pen:{height:500,lineTop:.08,name:"swimlaneV",text:"Swimlane",textBaseline:"top",textTop:20,width:200}},{group:"Activity",key:"swimlaneH",label:"Swimlane H",pen:{height:200,lineLeft:.08,name:"swimlaneH",text:"Swimlane",textAlign:"left",textLeft:.04,textWidth:.01,width:500}},{group:"Activity",key:"forkV",label:"Fork V",pen:{fillStyle:"#555",height:150,name:"forkV",strokeStyle:"transparent",text:"",width:10}},{group:"Activity",key:"forkH",label:"Fork H",pen:{fillStyle:"#555",height:10,name:"forkH",strokeStyle:"transparent",text:"",width:150}},{group:"Sequence & class",key:"lifeline",label:"Lifeline",pen:{height:400,name:"lifeline",text:"Object",textHeight:50,width:150}},{group:"Sequence & class",key:"sequenceFocus",label:"Activation",pen:{height:200,name:"sequenceFocus",text:"",width:12}},{group:"Sequence & class",key:"simpleClass",label:"Simple class",pen:{height:200,list:[{text:`- name: string
2
+ + setName(name: string): void`}],name:"simpleClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Sequence & class",key:"interfaceClass",label:"Class",pen:{height:200,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}],name:"interfaceClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Fault tree",key:"andGate",label:"AND gate",pen:{height:150,name:"andGate",width:100}},{group:"Fault tree",key:"orGate",label:"OR gate",pen:{height:150,name:"orGate",width:100}},{group:"Fault tree",key:"basicEvent",label:"Basic event",pen:{height:150,name:"basicEvent",width:100}},{group:"Fault tree",key:"xorGate",label:"XOR gate",pen:{height:150,name:"xorGate",width:100}},{group:"Fault tree",key:"votingGate",label:"Voting gate",pen:{height:150,name:"votingGate",width:100}}]}function z(n){return V(structuredClone(n))}function $(n){const t=new Map;for(const l of n){const a=t.get(l.group)??[];a.push(l),t.set(l.group,a)}return Array.from(t.entries())}function J({name:n}){const t={fill:"#fff",stroke:"#1f1f1f",strokeWidth:1.2};return n==="circle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("circle",{cx:"14",cy:"14",r:"10",...t})}):n==="diamond"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,14 14,25 3,14",...t})}):n==="triangle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,4 25,24 3,24",...t})}):n==="pentagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,12 21,25 7,25 3,12",...t})}):n==="hexagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"8,4 20,4 25,14 20,24 8,24 3,14",...t})}):n==="pentagram"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 17,11 26,11 18,16 21,25 14,20 7,25 10,16 2,11 11,11",...t})}):n==="line"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("line",{x1:"4",x2:"24",y1:"14",y2:"14",...t})}):n==="text"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("text",{dominantBaseline:"middle",fill:"#1f1f1f",fontSize:"14",textAnchor:"middle",x:"14",y:"15",children:"T"})}):e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("rect",{height:"14",rx:"2",width:"20",x:"4",y:"7",...t})})}function K({disabled:n,engineRef:t,item:l,t:a}){const p=()=>{const r=t.current;if(!(!r||n))try{r.canvas.addCaches=[z(l.pen)]}catch{}};return e.jsxs("div",{draggable:!n,onClick:r=>{r.stopPropagation(),p()},onDragStart:r=>{if(n){r.preventDefault();return}const g=JSON.stringify(z(l.pen));r.dataTransfer.setData("Meta2d",g),r.dataTransfer.setData("Text",g),r.dataTransfer.effectAllowed="copy"},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),p())},role:"button",style:{alignItems:"center",border:"1px solid #efefef",borderRadius:6,cursor:n?"not-allowed":"grab",display:"flex",flexDirection:"column",gap:4,justifyContent:"center",minHeight:56,opacity:n?.5:1,outline:"none",padding:6},tabIndex:n?-1:0,title:`${a(L(l.key))||l.label} — drag or click to add`,children:[e.jsx(J,{name:String(l.pen.name??"rectangle")}),e.jsx("span",{style:{fontSize:11},children:a(L(l.key))||l.label})]})}function U({disabled:n,engineRef:t}){const{t:l}=E(),a=c.useMemo(()=>$(Y()),[]);return e.jsxs("aside",{style:{borderRight:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",padding:12,touchAction:"pan-y",width:240},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:4},children:l("meta2d.palette.title")}),e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:12},children:l("meta2d.palette.hint")}),a.map(([p,r])=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:6},children:l(X[p]||p)}),e.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"repeat(2, minmax(0, 1fr))"},children:r.map(g=>e.jsx(K,{disabled:n,engineRef:t,item:g,t:l},g.key))})]},p))]})}const H={borderLeft:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",width:220},j={color:"#8c8c8c",fontSize:12,marginBottom:4},k={borderBottom:"1px solid #f0f0f0",padding:"10px 12px"},f={alignItems:"center",display:"flex",gap:6,marginBottom:6},m={background:"#fafafa",border:"1px solid #e5e5e5",borderRadius:4,fontSize:12,height:28,outline:"none",padding:"0 6px"},y={color:"#8c8c8c",fontSize:11,minWidth:22},C={background:"#fff",border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer",fontSize:11,minWidth:48,padding:"4px 8px"};function _({engine:n}){const{t}=E(),[l,a]=c.useState(null),[p,r]=c.useState(null),g=c.useRef({}),b=c.useCallback(o=>{if(!o||o.length!==1){a(null),r(null);return}const d=o[0];if((d.globalAlpha===null||d.globalAlpha===void 0)&&(d.globalAlpha=1),a(d),n)try{r(n.getPenRect(d))}catch{r(null)}},[n]),v=c.useCallback(()=>{a(null),r(null)},[]);if(c.useEffect(()=>{if(n)return n.on("active",b),n.on("inactive",v),()=>{n.off("active",b),n.off("inactive",v)}},[n,b,v]),!l||!n)return e.jsx("aside",{style:H,children:e.jsx("div",{style:{color:"#bbb",fontSize:12,padding:16,textAlign:"center"},children:t("meta2d.props.empty")})});const h=(o,d)=>{g.current[o]=d;const i={id:l.id};i[o]=d,o==="dash"&&(i.lineDash=[void 0,[5,5]][d]),n.setValue(i,{render:!0})},B=(o,d)=>{if(!p)return;const i={id:l.id};i[o]=d,n.setValue(i,{render:!0}),r(u=>u?{...u,[o]:d}:null)},w=o=>{o(n),n.render(!0)};return e.jsxs("aside",{style:H,children:[e.jsxs("div",{style:k,children:[e.jsx("div",{style:j,children:t("meta2d.props.text")}),e.jsx("div",{style:f,children:e.jsx("input",{onChange:o=>h("text",o.target.value),style:m,type:"text",value:l.text??""})})]}),e.jsxs("div",{style:k,children:[e.jsx("div",{style:{...j,marginBottom:6},children:t("meta2d.props.appearance")}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.color")}),e.jsx("input",{onChange:o=>h("color",o.target.value),style:{...m,flex:1},type:"color",value:l.color||"#1f1f1f"})]}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.bg")}),e.jsx("input",{onChange:o=>h("background",o.target.value),style:{...m,flex:1},type:"color",value:l.background||"#ffffff"})]}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.dash")}),e.jsxs("select",{onChange:o=>h("dash",Number(o.target.value)),style:{...m,flex:1},value:String(l.dash??0),children:[e.jsx("option",{value:"0",children:t("meta2d.props.solid")}),e.jsx("option",{value:"1",children:t("meta2d.props.dashLine")})]})]}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.radius")}),e.jsx("input",{max:1,min:0,onChange:o=>h("borderRadius",Number(o.target.value)),step:.01,style:{...m,flex:1},type:"range",value:String(l.borderRadius??0)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:l.borderRadius??0})]}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.alpha")}),e.jsx("input",{max:1,min:0,onChange:o=>h("globalAlpha",Number(o.target.value)),step:.01,style:{...m,flex:1},type:"range",value:String(l.globalAlpha??1)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:(l.globalAlpha??1).toFixed(2)})]})]}),e.jsxs("div",{style:k,children:[e.jsx("div",{style:{...j,marginBottom:6},children:t("meta2d.props.position")}),[["X","x"],["Y","y"],["W","width"],["H","height"]].map(([o,d])=>e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:o}),e.jsx("input",{onChange:i=>B(d,Number(i.target.value)),style:{...m,flex:1},type:"number",value:p?p[d]:0})]},d))]}),e.jsxs("div",{style:k,children:[e.jsx("div",{style:{...j,marginBottom:6},children:t("meta2d.props.textAlign")}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.h")}),e.jsxs("select",{onChange:o=>h("textAlign",o.target.value),style:{...m,flex:1},value:l.textAlign||"center",children:[e.jsx("option",{value:"left",children:t("meta2d.props.left")}),e.jsx("option",{value:"center",children:t("meta2d.props.center")}),e.jsx("option",{value:"right",children:t("meta2d.props.right")})]})]}),e.jsxs("div",{style:f,children:[e.jsx("span",{style:y,children:t("meta2d.props.v")}),e.jsxs("select",{onChange:o=>h("textBaseline",o.target.value),style:{...m,flex:1},value:l.textBaseline||"middle",children:[e.jsx("option",{value:"top",children:t("meta2d.props.topAlign")}),e.jsx("option",{value:"middle",children:t("meta2d.props.middle")}),e.jsx("option",{value:"bottom",children:t("meta2d.props.bottomAlign")})]})]})]}),e.jsxs("div",{style:k,children:[e.jsx("div",{style:{...j,marginBottom:6},children:t("meta2d.props.layer")}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.jsx("button",{onClick:()=>w(o=>o.top()),style:C,type:"button",children:t("meta2d.props.top")}),e.jsx("button",{onClick:()=>w(o=>o.up()),style:C,type:"button",children:t("meta2d.props.up")}),e.jsx("button",{onClick:()=>w(o=>o.down()),style:C,type:"button",children:t("meta2d.props.down")}),e.jsx("button",{onClick:()=>w(o=>o.bottom()),style:C,type:"button",children:t("meta2d.props.bottom")})]})]})]})}const R={background:"#fff",border:"1px solid #d9d9d9",borderRadius:6,cursor:"pointer",minWidth:68,padding:"6px 12px"},S={...R,fontSize:12,minWidth:52,padding:"4px 10px"};function Z(n){c.useEffect(()=>{const t=document.documentElement,l=document.body,a=t.style.overflow,p=l.style.overflow;return t.style.overflow="hidden",l.style.overflow="hidden",()=>{t.style.overflow=a,l.style.overflow=p}},[n])}function pe({diagram:n,onClose:t,onSave:l}){const{t:a}=E(),p=c.useRef(null),r=c.useRef(null),g=c.useRef(n),b=c.useRef(t),[v,h]=c.useState(null),[B,w]=c.useState(!1);Z(!0),c.useLayoutEffect(()=>{b.current=t}),c.useEffect(()=>{if(!p.current)return;N();const i=new G(p.current,{grid:!0,rule:!1});r.current=i,h(i);try{const x=g.current;x!=null&&x.trim()?i.open(JSON.parse(x)):i.open(F()),A(i.data()),i.render(!0)}catch{i.open(F()),A(i.data()),i.render(!0)}const u=x=>{x.key==="Escape"&&b.current()};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);try{i.destroy()}catch{}r.current=null}},[]);const o=async()=>{const i=r.current;if(i){w(!0);try{A(i.data()),i.render(!0);const u=W(i.data()),x=JSON.stringify(u);l(x,await q(i)||await I(x)||'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="100%" height="100%" fill="#fafafa" stroke="#eee"/></svg>')}finally{w(!1)}}},d=i=>{const u=r.current;u&&i(u)};return e.jsx("div",{onClick:t,style:{alignItems:"center",background:"rgb(0 0 0 / 35%)",display:"flex",inset:0,justifyContent:"center",overflow:"hidden",position:"fixed",zIndex:1e3},children:e.jsxs("div",{onClick:i=>i.stopPropagation(),onWheel:i=>i.stopPropagation(),style:{background:"#fff",borderRadius:10,boxShadow:"0 12px 30px rgb(0 0 0 / 20%)",display:"flex",flexDirection:"column",height:"86vh",maxHeight:"100%",maxWidth:"1200px",overflow:"hidden",width:"92vw"},children:[e.jsxs("div",{style:{alignItems:"center",borderBottom:"1px solid #f0f0f0",display:"flex",flexWrap:"wrap",gap:8,justifyContent:"space-between",padding:"10px 14px"},children:[e.jsx("span",{style:{fontWeight:600},children:a("meta2d.editor.title")}),e.jsxs("div",{style:{alignItems:"center",display:"flex",flexWrap:"wrap",gap:8},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.jsx("button",{onClick:()=>d(i=>i.undo()),style:S,title:`${a("meta2d.editor.undo")} (Ctrl+Z)`,type:"button",children:a("meta2d.editor.undo")}),e.jsx("button",{onClick:()=>d(i=>i.redo()),style:S,title:`${a("meta2d.editor.redo")} (Ctrl+Y)`,type:"button",children:a("meta2d.editor.redo")}),e.jsx("button",{onClick:()=>d(i=>i.delete()),style:S,title:a("meta2d.editor.delete"),type:"button",children:a("meta2d.editor.delete")}),e.jsx("button",{onClick:()=>d(i=>i.fitView(!0)),style:S,title:a("meta2d.editor.fit"),type:"button",children:a("meta2d.editor.fit")}),e.jsx("button",{onClick:()=>d(i=>{i.scale(1),i.centerView()}),style:S,title:a("meta2d.editor.zoom100"),type:"button",children:a("meta2d.editor.zoom100")})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:t,style:R,type:"button",children:a("meta2d.editor.close")}),e.jsx("button",{disabled:B,onClick:()=>void o(),style:{...R,background:"#1677ff",border:"none",color:"#fff"},type:"button",children:a(B?"meta2d.editor.saving":"meta2d.editor.save")})]})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsx(U,{engineRef:r}),e.jsx("div",{ref:p,style:{flex:1,minHeight:0,minWidth:0}}),e.jsx(_,{engine:v})]})]})})}export{pe as DiagramEditor};
@@ -1,4 +1,4 @@
1
- import{r as i,j as n}from"./react-vendor-BNpqFP9B.js";import{B as oe}from"./ui-C3xtW1w8.js";import{c as J,g as he,u as ye,a as re,d as Ne,b as Re,f as De,e as Ae,h as Pe,D as Te,F as Le,l as ce,i as Be,S as _e,M as Oe,j as ze,r as pe,k as Fe,m as V,n as He,o as Ue,p as le}from"./index-CA7lpALZ.js";import{z as We,A as qe,m as Q,n as Ve,o as $e,p as Je,r as Ge,s as Ke,t as Xe,v as Ye,x as Qe,B as Ze,R as et,a as tt,b as de,c as nt,d as at,e as it,f as st,g as ot,h as rt,i as ct,w as Z,j as lt,O as dt,E as ut,q as mt,l as ft,C as ht,D as yt}from"./react-CQByW0Rg.js";import{H as gt,a as xt,b as vt,M as bt,T as kt,S as It,W as St,N as Ct,o as wt,c as ue}from"./Toolbar-DPkTtGNL.js";import{V as jt}from"./VisitorPickerModal-CJ0K2gj8.js";import"./motion-D-I76zAi.js";import"./editor-BBXgdU3Q.js";import"./diagram-BJFhx-27.js";import"./plus-B2rZTPWV.js";import"./copy-DCKasK29.js";/**
1
+ import{r as i,j as n}from"./react-vendor-BNpqFP9B.js";import{B as oe}from"./ui-DxdLi_28.js";import{c as J,g as he,u as ye,a as re,d as Ne,b as Re,f as De,e as Ae,h as Pe,D as Te,F as Le,l as ce,i as Be,S as _e,M as Oe,j as ze,r as pe,k as Fe,m as V,n as He,o as Ue,p as le}from"./index-C46BU1-j.js";import{z as We,A as qe,m as Q,n as Ve,o as $e,p as Je,r as Ge,s as Ke,t as Xe,v as Ye,x as Qe,B as Ze,R as et,a as tt,b as de,c as nt,d as at,e as it,f as st,g as ot,h as rt,i as ct,w as Z,j as lt,O as dt,E as ut,q as mt,l as ft,C as ht,D as yt}from"./react-B7vrA7AR.js";import{H as gt,a as xt,b as vt,M as bt,T as kt,S as It,W as St,N as Ct,o as wt,c as ue}from"./Toolbar-DjPuWk5G.js";import{V as jt}from"./VisitorPickerModal-BUS-cOq0.js";import"./motion-C4pN8CfU.js";import"./editor-ONzd_YnO.js";import"./diagram-gfUK8OHx.js";import"./plus-CnKbiP8x.js";import"./copy-hWOco_4c.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as E,j as W}from"./react-vendor-BNpqFP9B.js";import{b as io,ah as js,ai as sa,aj as ra,ak as oa}from"./index-CA7lpALZ.js";import{E as la,B as aa}from"./react-CQByW0Rg.js";import"./ui-C3xtW1w8.js";import"./motion-D-I76zAi.js";import"./editor-BBXgdU3Q.js";import"./diagram-BJFhx-27.js";import"./plus-B2rZTPWV.js";import"./copy-DCKasK29.js";function hn({lexicalJson:s,onMarkdown:e,onError:t}){const[i,n]=E.useState(null),r=E.useRef(!1);return E.useEffect(()=>{r.current=!1},[s]),E.useEffect(()=>{if(!(!i||r.current))try{i.setDocument("json",s);const o=i.getDocument("markdown");typeof o=="string"&&(r.current=!0,e(o))}catch{t==null||t()}},[i,s,e,t]),W.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:W.jsx(la,{content:s,type:"json",editable:!1,onInit:n,plugins:[aa]})})}let Ln=[],no=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?no:Ln).push(t=t+s[e])})();function ha(s){if(s<768)return!1;for(let e=0,t=Ln.length;;){let i=e+t>>1;if(s<Ln[i])t=i;else if(s>=no[i])e=i+1;else return!0;if(e==t)return!1}}function Ks(s){return s>=127462&&s<=127487}const qs=8205;function ca(s,e,t=!0,i=!0){return(t?so:fa)(s,e,i)}function so(s,e,t){if(e==s.length)return e;e&&ro(s.charCodeAt(e))&&oo(s.charCodeAt(e-1))&&e--;let i=cn(s,e);for(e+=$s(i);e<s.length;){let n=cn(s,e);if(i==qs||n==qs||t&&ha(n))e+=$s(n),i=n;else if(Ks(n)){let r=0,o=e-2;for(;o>=0&&Ks(cn(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function fa(s,e,t){for(;e>0;){let i=so(s,e-2,t);if(i<e)return i;e--}return 0}function cn(s,e){let t=s.charCodeAt(e);if(!oo(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ro(i)?(t-55296<<10)+(i-56320)+65536:t}function ro(s){return s>=56320&&s<57344}function oo(s){return s>=55296&&s<56320}function $s(s){return s<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bt(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Pe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bt(this,e,t);let i=[];return this.decompose(e,t,i,0),Pe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new qt(this),r=new qt(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new lo(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ao(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new _(e):Pe.from(_.split(e,[]))}}class _ extends I{constructor(e,t=ua(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new da(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new _(Us(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Mi(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new _(l,o.length+r.length));else{let a=l.length>>1;i.push(new _(l.slice(0,a)),new _(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof _))return super.replace(e,t,i);[e,t]=Bt(this,e,t);let n=Mi(this.text,Mi(i.text,Us(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new _(n,r):Pe.from(_.split(n,[]),r)}sliceString(e,t=this.length,i=`
1
+ import{r as E,j as W}from"./react-vendor-BNpqFP9B.js";import{b as io,ah as js,ai as sa,aj as ra,ak as oa}from"./index-C46BU1-j.js";import{E as la,B as aa}from"./react-B7vrA7AR.js";import"./ui-DxdLi_28.js";import"./motion-C4pN8CfU.js";import"./editor-ONzd_YnO.js";import"./diagram-gfUK8OHx.js";import"./plus-CnKbiP8x.js";import"./copy-hWOco_4c.js";function hn({lexicalJson:s,onMarkdown:e,onError:t}){const[i,n]=E.useState(null),r=E.useRef(!1);return E.useEffect(()=>{r.current=!1},[s]),E.useEffect(()=>{if(!(!i||r.current))try{i.setDocument("json",s);const o=i.getDocument("markdown");typeof o=="string"&&(r.current=!0,e(o))}catch{t==null||t()}},[i,s,e,t]),W.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:W.jsx(la,{content:s,type:"json",editable:!1,onInit:n,plugins:[aa]})})}let Ln=[],no=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?no:Ln).push(t=t+s[e])})();function ha(s){if(s<768)return!1;for(let e=0,t=Ln.length;;){let i=e+t>>1;if(s<Ln[i])t=i;else if(s>=no[i])e=i+1;else return!0;if(e==t)return!1}}function Ks(s){return s>=127462&&s<=127487}const qs=8205;function ca(s,e,t=!0,i=!0){return(t?so:fa)(s,e,i)}function so(s,e,t){if(e==s.length)return e;e&&ro(s.charCodeAt(e))&&oo(s.charCodeAt(e-1))&&e--;let i=cn(s,e);for(e+=$s(i);e<s.length;){let n=cn(s,e);if(i==qs||n==qs||t&&ha(n))e+=$s(n),i=n;else if(Ks(n)){let r=0,o=e-2;for(;o>=0&&Ks(cn(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function fa(s,e,t){for(;e>0;){let i=so(s,e-2,t);if(i<e)return i;e--}return 0}function cn(s,e){let t=s.charCodeAt(e);if(!oo(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ro(i)?(t-55296<<10)+(i-56320)+65536:t}function ro(s){return s>=56320&&s<57344}function oo(s){return s>=55296&&s<56320}function $s(s){return s<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bt(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Pe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bt(this,e,t);let i=[];return this.decompose(e,t,i,0),Pe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new qt(this),r=new qt(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new lo(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ao(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new _(e):Pe.from(_.split(e,[]))}}class _ extends I{constructor(e,t=ua(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new da(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new _(Us(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Mi(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new _(l,o.length+r.length));else{let a=l.length>>1;i.push(new _(l.slice(0,a)),new _(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof _))return super.replace(e,t,i);[e,t]=Bt(this,e,t);let n=Mi(this.text,Mi(i.text,Us(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new _(n,r):Pe.from(_.split(n,[]),r)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=Bt(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new _(i,n)),i=[],n=-1);return n>-1&&t.push(new _(i,n)),t}}class Pe extends I{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=Bt(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Pe(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=Bt(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Pe))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let g of e)g.flatten(d);return new _(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let g;if(d.lines>r&&d instanceof Pe)for(let p of d.children)f(p);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof _&&a&&(g=c[c.length-1])instanceof _&&d.lines+g.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new _(g.text.concat(d.text),g.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Pe.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Pe(l,t)}}I.empty=new _([""],0);function ua(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Mi(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=t&&(a>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function Us(s,e,t){return Mi(s,[""],e,t)}class qt{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof _?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof _?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(n instanceof _){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof _?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class lo{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new qt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class ao{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(I.prototype[Symbol.iterator]=function(){return this.iter()},qt.prototype[Symbol.iterator]=lo.prototype[Symbol.iterator]=ao.prototype[Symbol.iterator]=function(){return this});class da{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Bt(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function le(s,e,t=!0,i=!0){return ca(s,e,t,i)}function ga(s){return s>=56320&&s<57344}function pa(s){return s>=55296&&s<56320}function ma(s,e){let t=s.charCodeAt(e);if(!pa(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ga(i)?(t-55296<<10)+(i-56320)+65536:t}function ya(s){return s<65536?1:2}const En=/\r\n?|\n/;var me=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(me||(me={}));class Ve{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){Rn(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new Ve(e)}composeDesc(e){return this.empty?e:e.empty?this:ho(this,e)}mapDesc(e,t=!1){return e.empty?this:In(this,e,t)}mapPos(e,t=-1,i=me.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>e)return r+(e-n);r+=l}else{if(i!=me.Simple&&h>=e&&(i==me.TrackDel&&n<e&&h>e||i==me.TrackBefore&&n<e||i==me.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ve(e)}static create(e){return new Ve(e)}}class Q extends Ve{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Rn(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return In(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(I.empty);i.push(o?e.slice(r,r+o):I.empty)}r+=o}return new Q(t,i)}compose(e){return this.empty?e:e.empty?this:ho(this,e,!0)}map(e,t=!1){return e.empty?this:In(this,e,t,!0)}iterChanges(e,t=!1){Rn(this,e,t)}get desc(){return Ve.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new Yt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);oe(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;oe(t,c,f),f>0&&Xe(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);oe(t,c,-1),oe(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new Q(t,i),filtered:Ve.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<t&&oe(n,t-o,-1);let f=new Q(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof Q){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=d?typeof d=="string"?I.of(d.split(i||En)):d:I.empty,p=g.length;if(f==u&&p==0)return;f<o&&a(),f>o&&oe(n,f-o,-1),oe(n,u-f,p),Xe(r,n,g),o=u}}return h(e),a(!l),l}static empty(e){return new Q(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(I.empty);i[n]=I.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new Q(t,i)}static createSet(e,t){return new Q(e,t)}}function oe(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function Xe(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(I.empty);s.push(t)}}function Rn(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=I.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,c,f),n=h,r=c}}}function In(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Yt(s),l=new Yt(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);oe(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(oe(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(oe(n,0,o.ins),r&&Xe(r,n,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;oe(n,h,a<o.i?o.ins:0),r&&a<o.i&&Xe(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?Q.createSet(n,r):Ve.create(n);throw new Error("Mismatched change set lengths")}}}function ho(s,e,t=!1){let i=[],n=t?[]:null,r=new Yt(s),o=new Yt(e);for(let l=!1;;){if(r.done&&o.done)return n?Q.createSet(i,n):Ve.create(i);if(r.ins==0)oe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)oe(i,0,o.ins,l),n&&Xe(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;oe(i,a,c,l),n&&c&&Xe(n,i,o.text)}else o.ins==-1?(oe(i,r.off?0:r.len,a,l),n&&Xe(n,i,r.textBit(a))):(oe(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&Xe(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Yt{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?I.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?I.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ct{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ct(i,n,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i){return new ct(e,t,i)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>ct.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,n){return ct.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,t,i,n,r){let o=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=t&&(r=t<e?1:-1),t<e?ct.create(t,e,48|o):ct.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function co(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let bs=0;class M{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=bs++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new M(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:xs),!!e.static,e.enables)}of(e){return new Di([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function xs(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class Di{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=bs++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Pn(f,c)){let d=i(f);if(l?!Gs(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,g=u.config.address[r];if(g!=null){let p=Ri(u,g);if(this.dependencies.every(m=>m instanceof M?u.facet(m)===f.facet(m):m instanceof ze?u.field(m,!1)==f.field(m,!1):!0)||(l?Gs(d=i(f),p,n):n(d=i(f),p)))return f.values[o]=p,0}else d=i(f);return f.values[o]=d,1}}}}function Gs(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function Pn(s,e){let t=!1;for(let i of e)$t(s,i)&1&&(t=!0);return t}function ba(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Ri(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)$t(a,h);return a.values[o]=l(a),1},update(a,h){if(!Pn(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Pn(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&xs(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const hi=M.define({static:!0});class ze{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new ze(bs++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(hi).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(hi),o=n.facet(hi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,hi.of({field:this,create:e})]}get extension(){return this}}const ht={lowest:4,low:3,default:2,high:1,highest:0};function Wt(s){return e=>new uo(e,s)}const fo={highest:Wt(ht.highest),high:Wt(ht.high),default:Wt(ht.default),low:Wt(ht.low),lowest:Wt(ht.lowest)};class uo{constructor(e,t){this.inner=e,this.prec=t}}class Yi{of(e){return new Nn(this,e)}reconfigure(e){return Yi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Nn{constructor(e,t){this.compartment=e,this.inner=t}}class Ei{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of xa(e,t,o))u instanceof ze?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],g=d[0].facet,p=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[g.id]=a.length<<1|1,xs(p,d))a.push(i.facet(g));else{let m=g.combine(d.map(y=>y.value));a.push(i&&g.compare(m,i.facet(g))?i.facet(g):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(y=>m.dynamicSlot(y)));l[g.id]=h.length<<1,h.push(m=>ba(m,g,d))}}let f=h.map(u=>u(l));return new Ei(e,o,f,l,a,r)}}function xa(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Nn&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Nn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof uo)r(o.inner,o.prec);else if(o instanceof ze)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Di)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,ht.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,ht.default),i.reduce((o,l)=>o.concat(l))}function $t(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function Ri(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const go=M.define(),Wn=M.define({combine:s=>s.some(e=>e),static:!0}),po=M.define({combine:s=>s.length?s[0]:void 0,static:!0}),mo=M.define(),yo=M.define(),bo=M.define(),xo=M.define({combine:s=>s.length?s[0]:!1});class nt{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}}class wa{of(e){return new nt(this,e)}}class ka{constructor(e){this.map=e}of(e){return new G(this,e)}}class G{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new G(this.type,t)}is(e){return this.type==e}static define(e={}){return new ka(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}G.reconfigure=G.define();G.appendConfig=G.define();class Z{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&co(i,t.newLength),r.some(l=>l.type==Z.time)||(this.annotations=r.concat(Z.time.of(Date.now())))}static create(e,t,i,n,r,o){return new Z(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Z.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Z.time=nt.define();Z.userEvent=nt.define();Z.addToHistory=nt.define();Z.remote=nt.define();function Sa(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function wo(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=Q.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:G.mapEffects(s.effects,n).concat(G.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function Hn(s,e,t){let i=e.selection,n=Ct(e.annotations);return e.userEvent&&(n=n.concat(Z.userEvent.of(e.userEvent))),{changes:e.changes instanceof Q?e.changes:Q.of(e.changes||[],t,s.facet(po)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:Ct(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function ko(s,e,t){let i=Hn(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=wo(i,Hn(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=Z.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Ca(t?va(n):n)}function va(s){let e=s.startState,t=!0;for(let n of e.facet(mo)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Sa(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=Q.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=Z.create(e,n,s.selection&&s.selection.map(r),G.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(yo);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof Z?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Z?s=r[0]:s=ko(e,Ct(r),!1)}return s}function Ca(s){let e=s.startState,t=e.facet(bo),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=wo(i,Hn(e,r,s.changes.newLength),!0))}return i==s?s:Z.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const Aa=[];function Ct(s){return s==null?Aa:Array.isArray(s)?s:[s]}var Ke=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(Ke||(Ke={}));const Ma=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Fn;try{Fn=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Da(s){if(Fn)return Fn.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Ma.test(t)))return!0}return!1}function Ta(s){return e=>{if(!/\S/.test(e))return Ke.Space;if(Da(e))return Ke.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Ke.Word;return Ke.Other}}class N{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)$t(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return $t(this,i),Ri(this,i)}update(...e){return ko(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(Yi.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(G.reconfigure)?(t=null,i=l.value):l.is(G.appendConfig)&&(t=null,i=Ct(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Ei.resolve(i,n,this),r=new N(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Wn)?e.newSelection:e.newSelection.asSingle();new N(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=Ct(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=G.mapEffects(o,c).concat(G.mapEffects(Ct(a.effects),f))}return{changes:n,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Q?e:Q.of(e,this.doc.length,this.facet(N.lineSeparator))}toText(e){return I.of(e.split(this.facet(N.lineSeparator)||En))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:($t(this,t),Ri(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof ze&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return N.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=Ei.resolve(e.extensions||[],new Map),i=e.doc instanceof I?e.doc:I.of((e.doc||"").split(t.staticFacet(N.lineSeparator)||En)),n=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return co(n,i.length),t.staticFacet(Wn)||(n=n.asSingle()),new N(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(N.tabSize)}get lineBreak(){return this.facet(N.lineSeparator)||`
@@ -1,4 +1,4 @@
1
- import{r as n,j as o,ae as C}from"./react-vendor-BNpqFP9B.js";import{u as N,E as T,R as I,a as E,b as M,c as j,d as O,e as P,f as A,g as _,h as D,i as H,w as g,j as L,k as F,l as q,I as U,m as b,n as V,o as J,p as W,q as z,r as B,s as $,t as K,v as Y,x as G,y as Z}from"./react-CQByW0Rg.js";import{m as Q,n as X,H as ee,o as te,A as k,p as oe}from"./ui-C3xtW1w8.js";import{H as re,a as ae,b as ne,M as le,T as ie,S as se,W as de,N as ce,c as R,o as me}from"./Toolbar-DPkTtGNL.js";import"./editor-BBXgdU3Q.js";import"./diagram-BJFhx-27.js";import"./index-CA7lpALZ.js";import"./motion-D-I76zAi.js";import"./plus-B2rZTPWV.js";import"./copy-DCKasK29.js";const ue=({children:h,json:r,markdown:a,collapsible:m=!1,defaultActiveKey:y=["editor","text","json"],onJSONChange:p})=>{const[f,c]=n.useState(r),s=n.useRef(r);n.useEffect(()=>{r!==s.current&&(c(r),s.current=r)},[r]);const x=n.useCallback(d=>{s.current=d,c(d)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(Q,{}),o.jsx(X,{collapsible:m,defaultActiveKey:y,items:[{children:h,key:"editor",label:"Playground"},{children:o.jsx(ee,{language:"markdown",style:{fontSize:12,padding:16},variant:"borderless",children:a}),key:"text",label:"Text Output"},{children:o.jsx(te,{language:"json",onBlur:()=>{if(r!==s.current)try{const d=JSON.parse(s.current||"");p==null||p(d)}catch(d){console.error("Invalid JSON:",d)}},onValueChange:x,value:f,variant:"borderless"}),key:"json",label:"JSON Output"}],padding:{body:0},style:{border:"none",borderRadius:0,width:"100%"},variant:"outlined"})]})},he={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Welcome to the Lobe Editor Demo!",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"In case you were wondering what the black box at the bottom is – it's the debug view, showing the current state of the editor. You can disable it by pressing on the settings control in the bottom-left of your screen and toggling the debug view setting.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"quote",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"The playground is a demo environment built with ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"@lobehub/editor",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:". Try typing in ",type:"text",version:1},{detail:0,format:1,mode:"normal",style:"",text:"some text",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:" with ",type:"text",version:1},{detail:0,format:2,mode:"normal",style:"",text:"different formats",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Visit the ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lobe Editor website",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://editor.lobehub.com"},{detail:0,format:0,mode:"normal",style:"",text:" for documentation and more information.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Check out the code on our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"GitHub repository",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://github.com/lobehub/lobe-editor",url:"https://github.com/lobehub/lobe-editor"},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:2},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://github.com/lobehub/lobe-editor/blob/master/src/react/Editor/demos/index.tsx"},{detail:0,format:0,mode:"normal",style:"",text:" can be found here.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:3},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Join our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Discover Server",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://discord.gg/AYFPHvv2jT",url:"https://discord.gg/AYFPHvv2jT"},{detail:0,format:0,mode:"normal",style:"",text:" and chat with the team.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:4}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lastly, we're constantly adding cool new features to this playground. So make sure you check back here when you next get a chance 🙂.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"import",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"{",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:"Editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"}",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"from",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-success);",text:"@lobehub/editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:";",type:"code-highlight",version:1}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript",theme:"lobe-theme"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""}],direction:"ltr",format:"",indent:0,type:"root",version:1},ye={root:he};function S(h,r){let a;const m=(...y)=>{a!==void 0&&clearTimeout(a),a=setTimeout(()=>h(...y),r)};return m.cancel=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m}window.__scrollIntoView=Z;const pe=h=>{const r=N(),a=n.useRef([]),[m,y]=n.useState(""),[p,f]=n.useState(""),c=n.useMemo(()=>S(t=>{const e=t.getDocument("markdown"),l=t.getDocument("json");f(e||""),y(JSON.stringify(l||{},null,2))},200),[]),s=n.useMemo(()=>S(t=>{r&&(console.info("handleJSONChange",t),r.setDocument("json",t))},200),[r]),x=t=>{window.editor=t,c(t)};n.useEffect(()=>()=>{for(const t of a.current)URL.revokeObjectURL(t);a.current=[],c.cancel(),s.cancel(),delete window.editor,delete window.__scrollIntoView},[c,s]);const d=n.useMemo(()=>[{icon:o.jsx(k,{avatar:"💻",size:24}),key:"bot1",label:"前端研发专家",metadata:{id:"bot1"}},{icon:o.jsx(k,{avatar:"🌍",size:24}),key:"bot2",label:"中英文互译助手",metadata:{id:"bot2"}},{icon:o.jsx(k,{avatar:"📖",size:24}),key:"bot3",label:"学术写作增强专家",metadata:{id:"bot3"}}],[]),w=n.useMemo(()=>[{icon:re,key:"h1",label:"Heading 1",onSelect:e=>{e.dispatchCommand(b,{tag:"h1"})}},{icon:ae,key:"h2",label:"Heading 2",onSelect:e=>{e.dispatchCommand(b,{tag:"h2"})}},{icon:ne,key:"h3",label:"Heading 3",onSelect:e=>{e.dispatchCommand(b,{tag:"h3"})}},{type:"divider"},{icon:le,key:"hr",label:"Hr",onSelect:e=>{e.dispatchCommand(V,{})}},{icon:ie,key:"table",label:"Table",onSelect:e=>{e.dispatchCommand(J,{columns:"3",rows:"3"})}},{icon:se,key:"tex",label:"Tex",onSelect:e=>{e.dispatchCommand(W,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>{e.focus()})}},{type:"divider"},{key:"file",label:"File",onSelect:e=>{me(l=>{for(const u of l)e.dispatchCommand(z,{file:u})})}},{key:"set-text-content",label:"SetTextContent",onSelect:e=>{e.setDocument("text",`123
1
+ import{r as n,j as o,ae as C}from"./react-vendor-BNpqFP9B.js";import{u as N,E as T,R as I,a as E,b as M,c as j,d as O,e as P,f as A,g as _,h as D,i as H,w as g,j as L,k as F,l as q,I as U,m as b,n as V,o as J,p as W,q as z,r as B,s as $,t as K,v as Y,x as G,y as Z}from"./react-B7vrA7AR.js";import{m as Q,n as X,H as ee,o as te,A as k,p as oe}from"./ui-DxdLi_28.js";import{H as re,a as ae,b as ne,M as le,T as ie,S as se,W as de,N as ce,c as R,o as me}from"./Toolbar-DjPuWk5G.js";import"./editor-ONzd_YnO.js";import"./diagram-gfUK8OHx.js";import"./index-C46BU1-j.js";import"./motion-C4pN8CfU.js";import"./plus-CnKbiP8x.js";import"./copy-hWOco_4c.js";const ue=({children:h,json:r,markdown:a,collapsible:m=!1,defaultActiveKey:y=["editor","text","json"],onJSONChange:p})=>{const[f,c]=n.useState(r),s=n.useRef(r);n.useEffect(()=>{r!==s.current&&(c(r),s.current=r)},[r]);const x=n.useCallback(d=>{s.current=d,c(d)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(Q,{}),o.jsx(X,{collapsible:m,defaultActiveKey:y,items:[{children:h,key:"editor",label:"Playground"},{children:o.jsx(ee,{language:"markdown",style:{fontSize:12,padding:16},variant:"borderless",children:a}),key:"text",label:"Text Output"},{children:o.jsx(te,{language:"json",onBlur:()=>{if(r!==s.current)try{const d=JSON.parse(s.current||"");p==null||p(d)}catch(d){console.error("Invalid JSON:",d)}},onValueChange:x,value:f,variant:"borderless"}),key:"json",label:"JSON Output"}],padding:{body:0},style:{border:"none",borderRadius:0,width:"100%"},variant:"outlined"})]})},he={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Welcome to the Lobe Editor Demo!",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"In case you were wondering what the black box at the bottom is – it's the debug view, showing the current state of the editor. You can disable it by pressing on the settings control in the bottom-left of your screen and toggling the debug view setting.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"quote",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"The playground is a demo environment built with ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"@lobehub/editor",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:". Try typing in ",type:"text",version:1},{detail:0,format:1,mode:"normal",style:"",text:"some text",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:" with ",type:"text",version:1},{detail:0,format:2,mode:"normal",style:"",text:"different formats",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Visit the ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lobe Editor website",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://editor.lobehub.com"},{detail:0,format:0,mode:"normal",style:"",text:" for documentation and more information.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Check out the code on our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"GitHub repository",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://github.com/lobehub/lobe-editor",url:"https://github.com/lobehub/lobe-editor"},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:2},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://github.com/lobehub/lobe-editor/blob/master/src/react/Editor/demos/index.tsx"},{detail:0,format:0,mode:"normal",style:"",text:" can be found here.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:3},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Join our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Discover Server",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://discord.gg/AYFPHvv2jT",url:"https://discord.gg/AYFPHvv2jT"},{detail:0,format:0,mode:"normal",style:"",text:" and chat with the team.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:4}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lastly, we're constantly adding cool new features to this playground. So make sure you check back here when you next get a chance 🙂.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"import",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"{",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:"Editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"}",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"from",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-success);",text:"@lobehub/editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:";",type:"code-highlight",version:1}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript",theme:"lobe-theme"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""}],direction:"ltr",format:"",indent:0,type:"root",version:1},ye={root:he};function S(h,r){let a;const m=(...y)=>{a!==void 0&&clearTimeout(a),a=setTimeout(()=>h(...y),r)};return m.cancel=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m}window.__scrollIntoView=Z;const pe=h=>{const r=N(),a=n.useRef([]),[m,y]=n.useState(""),[p,f]=n.useState(""),c=n.useMemo(()=>S(t=>{const e=t.getDocument("markdown"),l=t.getDocument("json");f(e||""),y(JSON.stringify(l||{},null,2))},200),[]),s=n.useMemo(()=>S(t=>{r&&(console.info("handleJSONChange",t),r.setDocument("json",t))},200),[r]),x=t=>{window.editor=t,c(t)};n.useEffect(()=>()=>{for(const t of a.current)URL.revokeObjectURL(t);a.current=[],c.cancel(),s.cancel(),delete window.editor,delete window.__scrollIntoView},[c,s]);const d=n.useMemo(()=>[{icon:o.jsx(k,{avatar:"💻",size:24}),key:"bot1",label:"前端研发专家",metadata:{id:"bot1"}},{icon:o.jsx(k,{avatar:"🌍",size:24}),key:"bot2",label:"中英文互译助手",metadata:{id:"bot2"}},{icon:o.jsx(k,{avatar:"📖",size:24}),key:"bot3",label:"学术写作增强专家",metadata:{id:"bot3"}}],[]),w=n.useMemo(()=>[{icon:re,key:"h1",label:"Heading 1",onSelect:e=>{e.dispatchCommand(b,{tag:"h1"})}},{icon:ae,key:"h2",label:"Heading 2",onSelect:e=>{e.dispatchCommand(b,{tag:"h2"})}},{icon:ne,key:"h3",label:"Heading 3",onSelect:e=>{e.dispatchCommand(b,{tag:"h3"})}},{type:"divider"},{icon:le,key:"hr",label:"Hr",onSelect:e=>{e.dispatchCommand(V,{})}},{icon:ie,key:"table",label:"Table",onSelect:e=>{e.dispatchCommand(J,{columns:"3",rows:"3"})}},{icon:se,key:"tex",label:"Tex",onSelect:e=>{e.dispatchCommand(W,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>{e.focus()})}},{type:"divider"},{key:"file",label:"File",onSelect:e=>{me(l=>{for(const u of l)e.dispatchCommand(z,{file:u})})}},{key:"set-text-content",label:"SetTextContent",onSelect:e=>{e.setDocument("text",`123
2
2
  123`),queueMicrotask(()=>{e.focus()})}},{key:"insert-link",label:"InsertLink",onSelect:e=>{e.dispatchCommand(B,{url:"https://example.com"}),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeInline",label:"InsertCodeInline",onSelect:e=>{e.dispatchCommand($,void 0),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeBlock",label:"InsertCodeBlock",onSelect:e=>{e.dispatchCommand(K,void 0),queueMicrotask(()=>{e.focus()})}},{icon:de,key:"meta2d",label:"Meta2d",onSelect:e=>{e.dispatchCommand(Y,void 0),queueMicrotask(()=>{e.focus()})}},{icon:ce,key:"markmap",label:"Markmap",onSelect:e=>{e.dispatchCommand(G,void 0),queueMicrotask(()=>{e.focus()})}}].map(e=>e.type==="divider"?e:{...e,extra:o.jsx(oe,{code:!0,fontSize:12,type:"secondary",children:e.key})}),[]);return o.jsxs(ue,{json:m,markdown:p,onJSONChange:s,...h,children:[o.jsx(R,{editor:r}),o.jsx(T,{className:"mdocs-playground-editor",content:ye,editor:r,lineEmptyPlaceholder:"Start typing here...",mentionOption:{items:d,markdownWriter:t=>{var e;return`
3
3
  <mention>${t.label}[${((e=t.metadata)==null?void 0:e.id)||t.label}]</mention>
4
4
  `},onSelect:(t,e)=>{t.dispatchCommand(U,{label:String(e.label),metadata:{id:e.key}})},searchKeys:["label"]},onInit:x,onTextChange:c,pasteVSCodeAsCodeBlock:!0,placeholder:"Type something...",plugins:[I,E,M,j,O,P,A,_,D,H,g(L,{children:o.jsx(R,{editor:r,floating:!0})}),g(F,{delay:1e3,onAutoComplete:async({input:t,afterText:e,selectionType:l,abortSignal:u})=>{console.log("Auto-complete triggered:",{afterText:e,input:t,selectionType:l});try{const v=await fetch(`${location.origin}/nodeserver/completion`,{body:JSON.stringify({prompt:`Please complete the following text: