@fgbg/mdocs 1.3.23 → 1.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/agent-skills/changelog/SKILL.md +12 -0
- package/dist/server/agent/Agent/run-pi-agent.js +7 -0
- package/dist/server/agent/Agent/run-pi-agent.js.map +1 -1
- package/dist/server/agent/Agent/system-prompt.js +3 -3
- package/dist/server/agent/Agent/tool-ui-effects.js +41 -0
- package/dist/server/agent/Agent/tool-ui-effects.js.map +1 -1
- package/dist/server/agent/Agent/tools-documents.js +62 -12
- package/dist/server/agent/Agent/tools-documents.js.map +1 -1
- package/dist/server/agent/Agent/tools-overwrite.js +1 -1
- package/dist/server/agent/Agent/tools-overwrite.js.map +1 -1
- package/dist/server/agent/Agent/tools-registry.test.js +16 -0
- package/dist/server/agent/Agent/tools-registry.test.js.map +1 -1
- package/dist/server/agent/Agent/tools-sheet.js +918 -0
- package/dist/server/agent/Agent/tools-sheet.js.map +1 -0
- package/dist/server/agent/Agent/tools-sheet.test.js +202 -0
- package/dist/server/agent/Agent/tools-sheet.test.js.map +1 -0
- package/dist/server/agent/Agent/tools-template.js +4 -1
- package/dist/server/agent/Agent/tools-template.js.map +1 -1
- package/dist/server/cli/main.js +8 -4
- package/dist/server/cli/main.js.map +1 -1
- package/dist/server/cli/self-update.js +49 -20
- package/dist/server/cli/self-update.js.map +1 -1
- package/dist/server/cli/self-update.test.js +21 -2
- package/dist/server/cli/self-update.test.js.map +1 -1
- package/dist/server/documents/document.service.integration.test.js +67 -1
- package/dist/server/documents/document.service.integration.test.js.map +1 -1
- package/dist/server/documents/document.service.js +80 -5
- package/dist/server/documents/document.service.js.map +1 -1
- package/dist/server/routes/documents.routes.js +6 -2
- package/dist/server/routes/documents.routes.js.map +1 -1
- package/dist/shared/docPath.js +5 -2
- package/dist/shared/docPath.js.map +1 -1
- package/dist/shared/file-type-policy.js +15 -0
- package/dist/shared/file-type-policy.js.map +1 -1
- package/dist/shared/file-type-policy.test.js +17 -1
- package/dist/shared/file-type-policy.test.js.map +1 -1
- package/dist/shared/file-types.js +2 -0
- package/dist/shared/file-types.js.map +1 -1
- package/dist/shared/sheetDocument.js +781 -0
- package/dist/shared/sheetDocument.js.map +1 -0
- package/dist/shared/sheetDocument.test.js +179 -0
- package/dist/shared/sheetDocument.test.js.map +1 -0
- package/dist/shared/storagePath.js +15 -8
- package/dist/shared/storagePath.js.map +1 -1
- package/dist/web/assets/AgentChatPanel-TJVgAwlH.js +22 -0
- package/dist/web/assets/{AgentSkillFormCard-BokYfssA.js → AgentSkillFormCard-3ZpgH1RY.js} +3 -3
- package/dist/web/assets/{AiWriteWorkbench-BLYRPfhm.js → AiWriteWorkbench-B9HrhEmd.js} +6 -6
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-uAUfkpbp.js → DiagramEditor-NtNY3sZL-CyddeNUo.js} +1 -1
- package/dist/web/assets/DocChrome-C5syeHbQ.js +11 -0
- package/dist/web/assets/DocumentEditor-mG7hvAWj.js +1 -0
- package/dist/web/assets/HtmlEditor-DABDor1R.js +1 -0
- package/dist/web/assets/{MergeView-3RaowcU-.js → MergeView-BczHMfos.js} +4 -4
- package/dist/web/assets/PlaygroundPage-zg5tjWQs.js +8 -0
- package/dist/web/assets/SettingsPage-BU0is_e7.js +1 -0
- package/dist/web/assets/SheetEditor-4nXVP3NN.js +16 -0
- package/dist/web/assets/SheetEditor-gXD-sRv2.css +1 -0
- package/dist/web/assets/{Toolbar-D0IqMu2I.js → Toolbar-xB4u1mY1.js} +19 -29
- package/dist/web/assets/VisitorPickerModal-Djpm5bTf.js +1 -0
- package/dist/web/assets/{check-CmDfmXpb.js → check--tqH9AMO.js} +1 -1
- package/dist/web/assets/{copy-CeksexKY.js → copy-5mwMd6zK.js} +1 -1
- package/dist/web/assets/docPlainCharCount-CTaZfi-M.js +11 -0
- package/dist/web/assets/file-type-policy-C6Nun42Q.js +1 -0
- package/dist/web/assets/index-CINfyH_g.js +299 -0
- package/dist/web/assets/index-DCgILSIv.css +1 -0
- package/dist/web/assets/italic-phhei7W3.js +11 -0
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-CFDBvzS1.js → meta2dEngine-BD2XbzaV-BDjANcdr.js} +1 -1
- package/dist/web/assets/{plus-Vt2TO_HW.js → plus-BxZJ-Mya.js} +1 -1
- package/dist/web/assets/{react-zRau5ppr.js → react-8gAAnUbI.js} +5 -5
- package/dist/web/index.html +2 -2
- package/package.json +30 -21
- package/dist/web/assets/AgentChatPanel-CXCoVr71.js +0 -22
- package/dist/web/assets/DocumentEditor-C7eEw_Gh.js +0 -1
- package/dist/web/assets/HtmlEditor-B8hAvriH.js +0 -1
- package/dist/web/assets/PlaygroundPage-Bc54r4cU.js +0 -8
- package/dist/web/assets/SettingsPage-hnisLfn5.js +0 -1
- package/dist/web/assets/VisitorPickerModal-C31LXFbB.js +0 -1
- package/dist/web/assets/docPlainCharCount-D3z2Ee8P.js +0 -21
- package/dist/web/assets/file-type-policy-GUk904tm.js +0 -1
- package/dist/web/assets/index-3-Dt0Ns3.js +0 -293
- package/dist/web/assets/index-CIgmAX2Q.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/scss-OYdSNvt2.js","assets/vue-DVfSmUF7.js","assets/typescript-BPQ3VLAy.js","assets/json-Cp-IABpG.js","assets/svelte-DZMnMd3x.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-BGX7qA9Y.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/shellscript-Yzrsuije.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/php-Dhbhpdrm.js","assets/shellsession-BADoaaVG.js","assets/nginx-BpAMiNFr.js","assets/meta2dEngine-BD2XbzaV-
|
|
2
|
-
var x7=Object.defineProperty;var k7=(e,t,n)=>t in e?x7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>k7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,af as w7,ag as v7,ah as S7,ai as Dn,aj as Xh,ak as Em,al as C7,j as O,b as Pi,am as _7,an as E7,ao as T7,ap as A7,z as M7,C as Jh,aq as N7,ar as D7,as as I7,at as L7}from"./react-vendor-BVS1XoFi.js";import{P as ze,e as Yh,A as ru,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Bi,$ as ce,O as Ln,G as pr,d as gs,l as gd,z as Sn,r as gt,v as nb,B as je,X as Fn,T as rb,M as Il,L as Ai,W as ml,f as hi,g as bs,h as So,C as Zh,Y as ib,y as Pt,i as Ll,H as Xe,j as F7,t as O7,m as Lo,J as yn,o as sb,R as fi,S as iu,Q as Zn,q as ob,s as z7,u as Aa,x as mt,E as R7,D as yc,I as P7,K as B7,_ as $7,N as su,U as bd,Z as ys,a0 as Co,a1 as Tt,a2 as ab,a3 as xn,a4 as j7,a5 as q7,a6 as Hr,a7 as Li,a8 as Fl,a9 as _n,aa as yd,ab as H7,ac as ub,ad as xd,ae as kd,af as _o,V as hn,ag as lb,ah as Qh,ai as U7,aj as cb,ak as W7,al as K7,am as V7,an as G7,ao as hb,ap as Qn,aq as X7,ar as jr,as as qn,at as xs,au as Tm,av as Am,aw as J7,ax as Y7,ay as Z7,az as Q7,aA as Ma,aB as fb,aC as db,aD as aa,aE as Na,aF as ou,aG as ek,aH as ef,aI as Mm,aJ as tk,aK as nk,aL as pb,aM as rk,aN as ik,aO as sk,aP as wd,aQ as Rr,aR as Eo,aS as vd,aT as ma,aU as fs,aV as Da,aW as tf,aX as Nm,aY as ga,aZ as gl,a_ as Ol,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as ck,b4 as Pr,b5 as hk,b6 as fk,b7 as dk,b8 as Dm,b9 as bl,ba as Im,bb as pk,bc as mk,bd as gk,be as bk,bf as ks,bg as Lm,bh as nf,bi as yk,bj as xk,bk as kk,bl as wk,bm as Fm,bn as ii,bo as Ia,bp as rf,bq as vk,br as ua,bs as mb,bt as gb,bu as bb,bv as yb,bw as xb,bx as Sk,by as Ck,bz as Sd,bA as kb,bB as _k,bC as Ek,bD as Cd,bE as Tk,bF as sf,bG as wb,bH as vb,bI as Ak,bJ as Mk,bK as Ju,bL as Sb,bM as Nk,bN as Dk,bO as Ik,bP as Cb,bQ as Lk,bR as Fk,bS as _b,bT as zl,bU as Ok,bV as zk,bW as Rk}from"./editor-DBWWidi3.js";import{as as tt,at,au as Pk,av as La,aw as Bk,ax as Rl,ay as $k,az as wi,aA as Zo,aB as jk,aC as qk,aD as Hk,aE as Uk,aF as Wk,aG as Kk,aH as Vk,aI as Gk,ad as _d,aJ as Xk,aK as It,ac as qr,aL as of,aM as Fa,aN as Ue,aO as Pl,aP as Eb,aQ as Jk,aR as zn,aS as Yk,aT as Zk,aU as Qk,aV as au,aW as Ed,aX as af,aY as Bl,aZ as Tb,a_ as ew,a$ as Om,b0 as tw,b1 as nw,t as uf,b2 as Ab,b3 as rw,b4 as iw,b5 as Mb,b6 as Nb,b7 as sw}from"./ui-CEFkTVnG.js";import{i as B0,j as ow,k as aw,l as uw,n as zm,e as Qo,s as lw,y as cw,h as Rm,m as Pm,r as hw,u as fw,v as dw,o as pw,w as mw,x as Db}from"./diagram-BF8g9yg4.js";import{o as pn,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/scss-OYdSNvt2.js","assets/vue-DVfSmUF7.js","assets/typescript-BPQ3VLAy.js","assets/json-Cp-IABpG.js","assets/svelte-DZMnMd3x.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-BGX7qA9Y.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/shellscript-Yzrsuije.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/php-Dhbhpdrm.js","assets/shellsession-BADoaaVG.js","assets/nginx-BpAMiNFr.js","assets/meta2dEngine-BD2XbzaV-BDjANcdr.js","assets/meta2d-DP4Vt_ZE.js","assets/react-vendor-BVS1XoFi.js","assets/editor-DBWWidi3.js","assets/ui-CEFkTVnG.js","assets/motion-BAXVQJfN.js","assets/diagram-BF8g9yg4.js","assets/index-CINfyH_g.js","assets/index-DCgILSIv.css","assets/plus-BxZJ-Mya.js","assets/check--tqH9AMO.js","assets/copy-5mwMd6zK.js","assets/DiagramEditor-NtNY3sZL-CyddeNUo.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var x7=Object.defineProperty;var k7=(e,t,n)=>t in e?x7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>k7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,af as w7,ag as v7,ah as S7,ai as Dn,aj as Xh,ak as Em,al as C7,j as O,b as Pi,am as _7,an as E7,ao as T7,ap as A7,z as M7,C as Jh,aq as N7,ar as D7,as as I7,at as L7}from"./react-vendor-BVS1XoFi.js";import{P as ze,e as Yh,A as ru,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Bi,$ as ce,O as Ln,G as pr,d as gs,l as gd,z as Sn,r as gt,v as nb,B as je,X as Fn,T as rb,M as Il,L as Ai,W as ml,f as hi,g as bs,h as So,C as Zh,Y as ib,y as Pt,i as Ll,H as Xe,j as F7,t as O7,m as Lo,J as yn,o as sb,R as fi,S as iu,Q as Zn,q as ob,s as z7,u as Aa,x as mt,E as R7,D as yc,I as P7,K as B7,_ as $7,N as su,U as bd,Z as ys,a0 as Co,a1 as Tt,a2 as ab,a3 as xn,a4 as j7,a5 as q7,a6 as Hr,a7 as Li,a8 as Fl,a9 as _n,aa as yd,ab as H7,ac as ub,ad as xd,ae as kd,af as _o,V as hn,ag as lb,ah as Qh,ai as U7,aj as cb,ak as W7,al as K7,am as V7,an as G7,ao as hb,ap as Qn,aq as X7,ar as jr,as as qn,at as xs,au as Tm,av as Am,aw as J7,ax as Y7,ay as Z7,az as Q7,aA as Ma,aB as fb,aC as db,aD as aa,aE as Na,aF as ou,aG as ek,aH as ef,aI as Mm,aJ as tk,aK as nk,aL as pb,aM as rk,aN as ik,aO as sk,aP as wd,aQ as Rr,aR as Eo,aS as vd,aT as ma,aU as fs,aV as Da,aW as tf,aX as Nm,aY as ga,aZ as gl,a_ as Ol,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as ck,b4 as Pr,b5 as hk,b6 as fk,b7 as dk,b8 as Dm,b9 as bl,ba as Im,bb as pk,bc as mk,bd as gk,be as bk,bf as ks,bg as Lm,bh as nf,bi as yk,bj as xk,bk as kk,bl as wk,bm as Fm,bn as ii,bo as Ia,bp as rf,bq as vk,br as ua,bs as mb,bt as gb,bu as bb,bv as yb,bw as xb,bx as Sk,by as Ck,bz as Sd,bA as kb,bB as _k,bC as Ek,bD as Cd,bE as Tk,bF as sf,bG as wb,bH as vb,bI as Ak,bJ as Mk,bK as Ju,bL as Sb,bM as Nk,bN as Dk,bO as Ik,bP as Cb,bQ as Lk,bR as Fk,bS as _b,bT as zl,bU as Ok,bV as zk,bW as Rk}from"./editor-DBWWidi3.js";import{as as tt,at,au as Pk,av as La,aw as Bk,ax as Rl,ay as $k,az as wi,aA as Zo,aB as jk,aC as qk,aD as Hk,aE as Uk,aF as Wk,aG as Kk,aH as Vk,aI as Gk,ad as _d,aJ as Xk,aK as It,ac as qr,aL as of,aM as Fa,aN as Ue,aO as Pl,aP as Eb,aQ as Jk,aR as zn,aS as Yk,aT as Zk,aU as Qk,aV as au,aW as Ed,aX as af,aY as Bl,aZ as Tb,a_ as ew,a$ as Om,b0 as tw,b1 as nw,t as uf,b2 as Ab,b3 as rw,b4 as iw,b5 as Mb,b6 as Nb,b7 as sw}from"./ui-CEFkTVnG.js";import{i as B0,j as ow,k as aw,l as uw,n as zm,e as Qo,s as lw,y as cw,h as Rm,m as Pm,r as hw,u as fw,v as dw,o as pw,w as mw,x as Db}from"./diagram-BF8g9yg4.js";import{o as pn,b7 as gw,b8 as Td,aI as bw}from"./index-CINfyH_g.js";import{P as Bm}from"./plus-BxZJ-Mya.js";import{C as yw}from"./check--tqH9AMO.js";import{C as xw}from"./copy-5mwMd6zK.js";/**
|
|
3
3
|
* @license lucide-react v0.562.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -355,7 +355,7 @@ $$
|
|
|
355
355
|
`,inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:n,inlineMath:r}};function n(s,o,a,u){const l=s.value||"",h=a.createTracker(u),d="$".repeat(Math.max(t6(l,"$")+1,2)),g=a.enter("mathFlow");let m=h.move(d);if(s.meta){const y=a.enter("mathFlowMeta");m+=h.move(a.safe(s.meta,{after:`
|
|
356
356
|
`,before:m,encode:["$"],...h.current()})),y()}return m+=h.move(`
|
|
357
357
|
`),l&&(m+=h.move(l+`
|
|
358
|
-
`)),m+=h.move(d),g(),m}function r(s,o,a){let u=s.value||"",l=1;for(t||l++;new RegExp("(^|[^$])"+"\\$".repeat(l)+"([^$]|$)").test(u);)l++;const h="$".repeat(l);/[^ \r\n]/.test(u)&&(/^[ \r\n]/.test(u)&&/[ \r\n]$/.test(u)||/^\$|\$$/.test(u))&&(u=" "+u+" ");let d=-1;for(;++d<a.unsafe.length;){const g=a.unsafe[d];if(!g.atBreak)continue;const m=a.compilePattern(g);let y;for(;y=m.exec(u);){let w=y.index;u.codePointAt(w)===10&&u.codePointAt(w-1)===13&&w--,u=u.slice(0,w)+" "+u.slice(y.index+1)}}return h+u+h}function i(){return"$"}}const lM={tokenize:cM,concrete:!0,name:"mathFlow"},Wg={tokenize:hM,partial:!0};function cM(e,t,n){const r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return a;function a(M){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),u(M)}function u(M){return M===36?(e.consume(M),o++,u):o<2?n(M):(e.exit("mathFlowFenceSequence"),Ke(e,l,"whitespace")(M))}function l(M){return M===null||ve(M)?d(M):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(M))}function h(M){return M===null||ve(M)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(M)):M===36?n(M):(e.consume(M),h)}function d(M){return e.exit("mathFlowFence"),r.interrupt?t(M):e.attempt(Wg,g,_)(M)}function g(M){return e.attempt({tokenize:v,partial:!0},_,m)(M)}function m(M){return(s?Ke(e,y,"linePrefix",s+1):y)(M)}function y(M){return M===null?_(M):ve(M)?e.attempt(Wg,g,_)(M):(e.enter("mathFlowValue"),w(M))}function w(M){return M===null||ve(M)?(e.exit("mathFlowValue"),y(M)):(e.consume(M),w)}function _(M){return e.exit("mathFlow"),t(M)}function v(M,T,D){let R=0;return Ke(M,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function F(U){return M.enter("mathFlowFence"),M.enter("mathFlowFenceSequence"),j(U)}function j(U){return U===36?(R++,M.consume(U),j):R<o?D(U):(M.exit("mathFlowFenceSequence"),Ke(M,K,"whitespace")(U))}function K(U){return U===null||ve(U)?(M.exit("mathFlowFence"),T(U)):D(U)}}}function hM(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function fM(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),{tokenize:n,resolve:dM,previous:pM,name:"mathText"};function n(r,i,s){let o=0,a,u;return l;function l(y){return r.enter("mathText"),r.enter("mathTextSequence"),h(y)}function h(y){return y===36?(r.consume(y),o++,h):o<2&&!t?s(y):(r.exit("mathTextSequence"),d(y))}function d(y){return y===null?s(y):y===36?(u=r.enter("mathTextSequence"),a=0,m(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),d):ve(y)?(r.enter("lineEnding"),r.consume(y),r.exit("lineEnding"),d):(r.enter("mathTextData"),g(y))}function g(y){return y===null||y===32||y===36||ve(y)?(r.exit("mathTextData"),d(y)):(r.consume(y),g)}function m(y){return y===36?(r.consume(y),a++,m):a===o?(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",g(y))}}}function dM(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function pM(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function mM(e){return{flow:{36:lM},text:{36:fM(e)}}}const gM={};function bM(e){const t=this,n=e||gM,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mM(n)),s.push(aM()),o.push(uM(n))}const Zl=Qe("plugin","markdown"),yM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function xM(e){const t=e.replace(/^<\/?/,"").replace(/\/?>$/,"").trim(),n=/^([A-Za-z][\w-]*)/.exec(t);return n?n[1].toLowerCase():""}var kM=class{constructor(e){this.root=e,this.stack=[]}push(e){this.stack.push(e)}get isReadingHTML(){return this.stack.length>0}get last(){return this.stack.at(-1)}pop(){return this.stack.pop()}};function Kg(e,t){return e!=="paragraph"?t:Array.isArray(t)?{...ke.createParagraph(),children:t}:t.type!=="paragraph"?{...ke.createParagraph(),children:[t]}:t}function Ff(e,t,n,r={}){switch(e.type){case"text":return ke.createTextNode(e.value);default:{let i=[];if("children"in e&&Array.isArray(e.children)){let s=[];for(i=e.children.reduce((o,a,u)=>{if(a.type==="html"){if(a.value.startsWith("<!--")&&a.value.endsWith("-->"))return o;const l=xM(a.value),h=a.value.startsWith("</");if(!l)return o;if(yM.has(l)){const g=r.html;if(Array.isArray(g))for(const m of g){const y=m(a,[],u);if(y)return o.push(y),o}else if(typeof g=="function"){const m=g(a,[],u);if(m)return o.push(m),o}return o}if(h){const g=n.pop();if(s.pop(),(g==null?void 0:g.tag)!==l)return Zl.warn("HTML tag mismatch:",l),g&&o.push(ke.createTextNode(g.node.value),...g.children.flat().filter(Boolean)||[]),o.push(ke.createTextNode(a.value)),o;const m=r.html,y=g.children.flat().filter(Boolean)||[];if(Array.isArray(m))for(const w of m){const _=w(g.node,y,u);if(_)return o.push(_),o}else if(typeof m=="function"){const w=m(g.node,y,u);if(w)return o.push(w),o}return g&&o.push(...g.children),o}const d={children:[],index:u,isEndTag:h,node:a,tag:l};return s.push(d),n.push(d),o}if(s.length>0){const l=n.last;return l&&l.children.push(Ff(a,u,n,r)),o}return o.push(Ff(a,u,n,r)),o},[]).filter(Boolean).flat();s.length>0;){const o=s.shift();n.pop(),i.push(ke.createTextNode(o==null?void 0:o.node.value),...o.children.flat()),i=i.flat()}}if(r[e.type]){const s=r[e.type];if(Array.isArray(s))for(const o of s){const a=o(e,i,t);if(a)return Kg(e.type,a)}else if(typeof s=="function"){const o=s(e,i,t);if(o)return Kg(e.type,o)}}return e.type==="paragraph"?{...ke.createParagraph(),children:i}:i||null}}}function wM(e){const t=n=>typeof n=="function"||Array.isArray(n)&&n.length>0;t(e.root)||(e.root=(n,r)=>({...ke.createRootNode(),children:r})),t(e.paragraph)||(e.paragraph=(n,r)=>({...ke.createParagraph(),children:r})),t(e.heading)||(e.heading=(n,r)=>{const i=`h${Math.min(Math.max(n.depth,1),6)}`;return ke.createElementNode("heading",{children:r,direction:"ltr",format:"",indent:0,tag:i})})}function Yd(e,t={}){const n=[];let r=e;const i=/---markmap---(\n?)([\S\s]*?)\n?---\/markmap---/g;let s,o=0;for(;(s=i.exec(e))!==null;){const d=`|||MARKMAP_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"markmap"}),r=r.replace(s[0],d),o++}const a=/---meta2d---(\n?)([\S\s]*?)\n?---\/meta2d---/g;for(;(s=a.exec(e))!==null;){const d=`|||META2D_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"meta2d"}),r=r.replace(s[0],d),o++}const u=g6().use(wv).use(bM).use([[M6,{singleTilde:!1}]]).parse(r);Zl.debug("Parsed MDAST:",u);const l=new kM(u);wM(t);const h=Ff(u,0,l,t);if(n.length>0){const d=m=>{if(m.type==="text"&&typeof m.text=="string"){const y=[];let w=m.text,_=!1;for(const v of n){const M=w.indexOf(v.placeholder);if(M!==-1){_=!0,M>0&&y.push({...m,text:w.slice(0,Math.max(0,M))}),y.push({type:v.type,[v.type==="markmap"?"markdown":"diagram"]:v.content,version:1});const T=w.slice(Math.max(0,M+v.placeholder.length));if(T){const D=d({...m,text:T});Array.isArray(D)?y.push(...D):y.push(D)}break}}return _?y:m}if(m.children&&Array.isArray(m.children)){const y=[];for(const w of m.children){const _=d(w);Array.isArray(_)?y.push(..._):y.push(_)}if(m.children=y.filter(Boolean),m.type==="paragraph"&&m.children.length===1&&(m.children[0].type==="markmap"||m.children[0].type==="meta2d"))return m.children[0]}return m},g=[];for(const m of h.children){const y=d(m);Array.isArray(y)?g.push(...y):g.push(y)}h.children=g.filter(Boolean)}return h}function Vg(e){return Pt(e)&&!e.hasFormat("code")}function N6(e,t,n,r,i){for(let s=0;s<i;s++)if(e[t+s]!==n[r+s])return!1;return!0}const Gg=/[!-/:-@[-`{-~\s]/;function Xg(e,t,n){const r=n.length;for(let i=t;i>=r;i--){const s=i-r;if(N6(e,s,n,0,r)&&e[s+r]!==" ")return s}return-1}function Jg(e,t){const n={};for(const r of e){const i=t(r);i&&(n[i]?n[i].push(r):n[i]=[r])}return n}let D6=/[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~\u00A1\u2010-\u2027-]/;try{D6=new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]","u")}catch{}function vM(e){return D6.test(e)}function SM(e){if(de(e)&&e.isCollapsed()){const t=e.anchor;let n=null;const r=tk(t,"previous");if(r)if(nk(r))n=r.origin;else{const i=pb(r,rk(Sn(),"next").getFlipped());for(const s of i)if(Pt(s.origin)){n=s.origin;break}else if(fn(s.origin)&&!s.origin.isInline())break}if(n&&Pt(n)){const i=n.getFormat(),s=n.getStyle();(e.format!==i||e.style!==s)&&(e.format=i,e.style=s,e.dirty=!0)}}}function CM(e,t,n){e.dispatchCommand(ek,{nodes:t,selection:n})||(n.insertNodes(t),SM(n))}function _M(e){const t={};if(!e)return t;const n=e.split(";");for(const r of n)if(r!==""){const[i,s]=r.split(/:([^]+)/);i&&s&&(t[i.trim()]=s.trim())}return t}const EM=new Map;function TM(e){const t=e.getStyle(),n=_M(t);EM.set(t,n)}function I6(e){const t=[];for(const n of e){const r=X7(n);Pt(r)&&TM(r),t.push(r)}return t}function AM(e,t,n){CM(e,I6(t.children),n)}function L6(e){return e===null?!1:qn(e)||Hr(e)||So(e)}function MM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,trigger:a}of r){const u=s.match(o);if(i===a&&u&&u[0].length===(i==="enter"||u[0].endsWith(" ")?n:n-1))return!0}return!1}function NM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,replace:a,trigger:u}of r){const l=s.match(o);if(i===u&&l&&l[0].length===(i==="enter"||l[0].endsWith(" ")?n:n-1)){const h=t.getNextSiblings(),[d,g]=t.splitText(n);if(a(e,g?[g,...h]:h,l,!1)!==!1)return d.remove(),!0}}return!1}function DM(e,t,n){let r=e.getTextContent();const i=n[r[t-1]];if(!i)return!1;t<r.length&&(r=r.slice(0,t));for(const s of i){if(!s.replace||!s.regExp)continue;const o=r.match(s.regExp);if(o===null)continue;const a=o.index||0,u=a+o[0].length;let l;return a===0?[l]=e.splitText(u):[,l]=e.splitText(a,u),l.selectNext(0,0),s.replace(l,o),!0}return!1}function IM(e,t,n){const r=e.getTextContent(),i=t-1,s=r[i],o=n[s];if(!o)return!1;for(const a of o){const{tag:u}=a,l=u.length,h=i-l+1;if(l>1&&!N6(r,h,u,0,l)||r[h-1]===" ")continue;const d=r[i+1];if(a.intraword===!1&&d&&!Gg.test(d))continue;const g=e;let m=g,y=Xg(r,h,u),w=m;for(;y<0&&(w=w.getPreviousSibling())&&!Qn(w);)if(Pt(w)){if(w.hasFormat("code"))continue;const K=w.getTextContent();m=w,y=Xg(K,K.length,u)}if(y<0||m===g&&y+l===h)continue;const _=m.getTextContent();if(y>0&&_[y-1]===s)continue;const v=_[y-1];if(a.intraword===!1&&v&&!Gg.test(v))continue;const M=g.getTextContent(),T=M.slice(0,h)+M.slice(i+1);g.setTextContent(T);const D=m===g?T:_;m.setTextContent(D.slice(0,y)+D.slice(y+l));const R=ce(),F=Lo();je(F);const j=i-l*(m===g?2:1)+1;if(F.anchor.set(m.__key,y,"text"),F.focus.set(g.__key,j,"text"),a.process){if(a.process(F)===!1){const K=ze(m.__key),U=ze(g.__key);Pt(K)&&K.setTextContent(_),U!==K&&Pt(U)&&U.setTextContent(M),je(e.selectEnd());continue}return!0}else if(a.format){for(const K of a.format)F.hasFormat(K)||F.formatText(K);F.anchor.set(F.focus.key,F.focus.offset,F.focus.type);for(const K of a.format)F.hasFormat(K)&&F.toggleFormat(K);de(R)&&(F.format=R.format)}else{je(R);continue}return!0}return!1}Ot();const Lt=uu("MarkdownShortCutService");var LM=class{constructor(e){this.kernel=e,this.elementTransformers=[],this.textFormatTransformers=[],this.textMatchTransformers=[],this.logger=Qe("service","markdown"),this._markdownWriters={},this._markdownReaders=[{},{},{}],this._textFormatTransformersByTrigger=null,this._textMatchTransformersByTrigger=null}get markdownWriters(){return this._markdownWriters}get markdownReaders(){return this._markdownReaders.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]||(e[n]=[]);const r=e[n],i=t[n];r.push(...i)}),e),{})}get textMatchTransformersByTrigger(){return this._textMatchTransformersByTrigger||(this._textMatchTransformersByTrigger=Jg(this.textMatchTransformers,({trigger:e})=>e)),this._textMatchTransformersByTrigger}get textFormatTransformersByTrigger(){return this._textFormatTransformersByTrigger||(this._textFormatTransformersByTrigger=Jg(this.textFormatTransformers,({tag:e})=>e.at(-1))),this._textFormatTransformersByTrigger}registerMarkdownShortCut(e){switch(e.type){case"element":this.elementTransformers.push(e);break;case"text-format":this.textFormatTransformers.push(e);break;case"text-match":this.textMatchTransformers.push(e);break;default:throw new Error(`Unknown transformer type: ${e}`)}}registerMarkdownShortCuts(e){for(const t of e)this.registerMarkdownShortCut(t)}testTransformers(e,t,n,r){if(MM(e,t,n,this.elementTransformers,r))return!0;if(r==="enter"){const i=t.getTextContent(),s=i[n-1],o=this.textMatchTransformersByTrigger[s];if(o){const a=n<i.length?i.slice(0,n):i;for(const u of o)if(u.regExp&&u.regExp.test(a))return!0}}return!1}runTransformers(e,t,n,r){return!!(NM(e,t,n,this.elementTransformers,r)||DM(t,n,this.textMatchTransformersByTrigger)||IM(t,n,this.textFormatTransformersByTrigger))}registerMarkdownWriter(e,t){var n;if(!this._markdownWriters[e]){this._markdownWriters[e]=t;return}if((n=this.kernel)!=null&&n.isHotReloadMode()){this.logger.warn(`🔄 Hot reload: markdown writer "${e}"`),this._markdownWriters[e]=t;return}throw new Error(`Markdown writer for type "${e}" is already registered.`)}registerMarkdownReader(e,t,n=2){var r;this._markdownReaders[n][e]||(this._markdownReaders[n][e]=[]),this._markdownReaders[n]&&((r=this._markdownReaders[n][e])==null||r.push(t))}parseMarkdownToLexical(e){return Yd(e,this.markdownReaders)}insertIRootNode(e,t,n){AM(e,t,n)}};function hU(e=0){if(typeof window>"u"||typeof document>"u")return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0).getBoundingClientRect();if(n.height===0&&n.width===0){const i=t.focusNode;if(i){const s=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;s&&s.scrollIntoView({behavior:"smooth",block:"center"})}return}const r=n.top+n.height/2-window.innerHeight/2+e;window.scrollBy({behavior:"smooth",top:r})}function FM(e){if(!(e instanceof HTMLElement)||e.scrollHeight<=e.clientHeight+1)return!1;const t=window.getComputedStyle(e).overflowY||e.style.overflowY||e.style.overflow;return t==="auto"||t==="scroll"||t==="overlay"}function OM(){var n;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).getBoundingClientRect();if(t.width===0&&t.height===0){const r=e.focusNode;return r?((n=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)==null?void 0:n.getBoundingClientRect())??null:null}return t}function zM(e=96){if(typeof window>"u"||typeof document>"u")return;const t=OM();if(!t)return;let n=document.activeElement;if(n instanceof Element)for(;n&&n!==document.body&&n!==document.documentElement;){if(FM(n)){const r=n.getBoundingClientRect(),i=r.bottom-e;t.bottom>i&&(n.scrollTop+=t.bottom-i);const s=r.top+Math.min(48,e/2);t.top<s&&(n.scrollTop-=s-t.top)}n=n.parentElement}}lu();var RM=class extends Nd{read(e,t,n){let r;typeof t=="string"?r=JSON.parse(t):r=t;const i=s=>{for(let o=0;o<s.children.length;o++){const a=s.children[o];"children"in a&&Array.isArray(a.children)&&i(a),a.type==="text"&&"format"in a&&typeof a.format=="number"&&(a.format&Mm)>0&&(s.children[o]={children:[{...a,format:a.format&~Mm}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},s.children.splice(o+1,0,df))}};i(r.root),e.setEditorState(e.parseEditorState({root:r.root}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var r,i,s;const n=ce();if(!n)return null;if(de(n)){const o=n.getNodes(),a=o.length-1,u=n.anchor,l=n.focus,h=u.isBefore(l),d=o[0],g=o[a],[m,y]=ab(n);let w=[];const _=[];for(let v=0;v<o.length;v++){const M=o[v];if(fn(M)){const T={...M.exportJSON(),$key:M.getKey()};for(let R=0;R<_.length;R++){const F=_[R],j=ze(F.$key);M.isParentOf(j)&&(T.children.push(F),_.splice(R,1),R--)}let D=!1;for(let R=w.length-1;R>=0;R--)if((r=ze(w[R].$key))!=null&&r.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T),w.push(T)}else if(Pt(M)){const T={...M.exportJSON(),$key:M.getKey()};M===d?M===g?(u.type!=="element"||l.type!=="element"||l.offset===u.offset)&&(T.text=m<y?T.text.slice(m,y):T.text.slice(y,m)):T.text=h?T.text.slice(m):T.text.slice(y):M===g&&(T.text=h?T.text.slice(0,y):T.text.slice(0,m));let D=!1;for(let R=w.length-1;R>=0;R--)if((i=ze(w[R].$key))!=null&&i.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}else{const T={...M.exportJSON(),$key:M.getKey()};let D=!1;for(let R=w.length-1;R>=0;R--)if((s=ze(w[R].$key))!=null&&s.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}}return _}return n.getNodes().map(o=>ff(o))}):e.read(()=>({root:ff(Sn())}))}};rn();var PM=class extends Nd{read(e,t){if(typeof t!="string")throw new Error("Invalid data type "+typeof t);const n=t.split(/\n/g),r=ke.createRootNode();n.forEach(i=>{const s=ke.createParagraph();if(i){const o=ke.createTextNode(i);ke.appendChild(s,o)}ke.appendChild(r,s)}),e.setEditorState(e.parseEditorState({root:r}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{const n=ce();return n?n.getTextContent().replaceAll("\uFEFF",""):null}):e.getEditorState().read(()=>Sn().getTextContent().replaceAll("\uFEFF",""))}};kr();function BM(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function $M(e){return gt(e.registerCommand(ou,()=>{if(cb){const t=document.getSelection();if(t!=null&&t.anchorNode){const n=BM(t.anchorNode);if(n!=null&&n.hasAttribute("data-lexical-linebreak")&&n.parentElement){const r=n.parentElement;return e.update(()=>{const i=u9(r,e);i&&i.selectEnd()}),!0}}}return!1},Fn))}const jM=["color","background-color"];function qM(e){const t=e.trim();return!t||t.length>128||/["'<>\\]|url\s*\(|expression\s*\(|@import/i.test(t)?!1:/^(#[\dA-Fa-f]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[A-Za-z]+)$/.test(t)}function HM(e){if(!(e!=null&&e.trim()))return{};const t={};for(const n of e.split(";")){if(!n.trim())continue;const r=n.indexOf(":");if(r<0)continue;const i=n.slice(0,r).trim().toLowerCase(),s=n.slice(r+1).trim();jM.includes(i)&&qM(s)&&(i==="color"&&(t.color=s),i==="background-color"&&(t["background-color"]=s))}return t}function Ql(e){const t=HM(e),n=[];return t.color&&n.push(`color: ${t.color}`),t["background-color"]&&n.push(`background-color: ${t["background-color"]}`),n.join("; ")}function UM(e){if(!/^<span\b/i.test(e.trim()))return"";const t=/\bstyle\s*=\s*"([^"]*)"/i.exec(e);if(t)return Ql(t[1]);const n=/\bstyle\s*=\s*'([^']*)'/i.exec(e);return n?Ql(n[1]):""}rn();function WM(e){e.registerMarkdownReader("blockquote",(t,n)=>ke.createElementNode("quote",{children:n,direction:"ltr",format:"",indent:0,version:1})),e.registerMarkdownReader("strong",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r))),e.registerMarkdownReader("emphasis",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r))),e.registerMarkdownReader("delete",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|J7),r))),e.registerMarkdownReader("subscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Y7),r))),e.registerMarkdownReader("superscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Z7),r))),e.registerMarkdownReader("html",(t,n)=>{if(["<ins>","<u>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Q7),r));if(["<em>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r));if(["<strong>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r));if(/^<span\b/i.test(t.value.trim())){const r=UM(t.value);return r?n.map(i=>(ke.isTextNode(i)&&(i.style=Ql([i.style,r].filter(Boolean).join("; "))),i)):!1}return!1})}function F6(e){const t=e.target;if(!(t instanceof Node))return null;const n=t.nodeType===Node.TEXT_NODE?t.parentElement:t;return n!=null&&n.closest?n:null}function O6(e){const t=F6(e);return t?!!t.closest('textarea, input:not([type="hidden"]), select'):!1}function KM(e){const t=F6(e);return t?!!t.closest(".cm-editor, .cm-content, .CodeMirror"):!1}const VM=({clipboardData:e})=>{const t=e.items;for(const n of t)if(n.kind==="file")return"skip";return"next"},GM=({clipboardData:e,config:t,editor:n,event:r})=>{if(!t.pasteVSCodeAsCodeBlock)return"next";const i=e.getData("vscode-editor-data");if(!i)return"next";try{const s=JSON.parse(i),o=s.mode||s.language||"plaintext",a=e.getData("text/plain");return a?(r.preventDefault(),n.update(()=>{if(!de(ce()))return;const u=di(o,a);_n([u]);const l=yn();l.add(u.getKey()),je(l)}),"handled"):"next"}catch{return"next"}},XM=({clipboardData:e,editor:t,event:n})=>{const r=e.getData("text/plain");return r?(n.preventDefault(),t.dispatchCommand(sk,r),"handled"):"skip"};function JM(e,t){for(const n of t){const r=n(e);if(r==="handled")return!0;if(r==="skip")return!1}return!1}Es();Ot();const YM=Qe("plugin","common");function Yg(e,t,n){const r=e.getParent();let i=n,s=e;return r!==null&&(t&&n===0?(i=s.getIndexWithinParent(),s=r):!t&&n===s.getChildrenSize()&&(i=s.getIndexWithinParent()+1,s=r)),s.getChildAtIndex(t?i-1:i)}function ZM(e){if(!xn(e))return!1;const t=e.getParent();if(!mt(t))return!1;let n=t.getLastChild();do{if(Qn(n))return!1;if(n===e)return t;n=n==null?void 0:n.getPreviousSibling()}while(n!==e&&n);return n===e?t:!1}function Zg(e,t){var r;const n=e.offset;if(e.type==="element")return Yg(e.getNode(),t,n);{const i=e.getNode();if(t&&n===0||!t&&n===i.getTextContentSize()){const s=t?i.getPreviousSibling():i.getNextSibling();return s===null?Yg(i.getParentOrThrow(),t,i.getIndexWithinParent()+(t?0:1)):s}else if(!t&&ZM(i))return((r=i.getParent())==null?void 0:r.getNextSibling())||null}return null}function Qg(e,t){let n=e.getNode();for(;n!==null&&n.isInline();)n=n.getParent();if(!n)return null;let r=t?n.getPreviousSibling():n.getNextSibling();for(;!r&&!qn(n);){if(n=n.getParent(),!n)return null;r=t?n.getPreviousSibling():n.getNextSibling()}return r||null}function QM(e){const t=e.focus;return t.key==="root"&&t.offset===Sn().getChildrenSize()}function eN(e){return e.registerCommand(Il,t=>{const n=e.getEditorState().read(()=>{const r=ce();if(!de(r)||!r.isCollapsed())return!1;const i=r.anchor;if(i.offset!==0)return!1;const s=i.getNode();if(Pt(s)){if(s.getPreviousSibling())return!1;const o=s.getParentOrThrow();return _o(o)?o:!1}return _o(s)?s:!1});return n?(t.stopImmediatePropagation(),t.preventDefault(),t.stopPropagation(),e.update(()=>{const r=hn();n.replace(r,!0),r.select(0,0)}),!0):!1},Ma)}function tN(e,t,n){const{enableHotkey:r=!0}=n||{};return gt(t.registerHotkey(Nt.PasteAsPlainText,async()=>{try{const i=await navigator.clipboard.readText();e.update(()=>{const s=ce();de(s)&&s.insertText(i)})}catch(i){YM.error("❌ Failed to paste as plain text:",i)}},{enabled:r,preventDefault:!0,stopPropagation:!0}),t.registerHotkey(Nt.Bold,()=>e.dispatchCommand(aa,"bold"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Italic,()=>e.dispatchCommand(aa,"italic"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Underline,()=>e.dispatchCommand(aa,"underline"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Strikethrough,()=>e.dispatchCommand(aa,"strikethrough"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Undo,()=>e.dispatchCommand(db,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Redo,()=>e.dispatchCommand(fb,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHighCommand(ys,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0)return o[0].selectPrevious(),i.preventDefault(),!0}else if(de(s)){const o=Zg(s.focus,!0),a=o||Qg(s.focus,!0);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectEnd(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(Co,i=>{const s=ce();if(de(s)){if(!s.isCollapsed())return!1;const o=s.focus.getNode(),a=Oa(o,l=>l.getType()===ub.getType());if(!a||a.getNextSibling())return!1;const u=a.getLastChild();return!u||!Oa(o,l=>l===u)?!1:(i.preventDefault(),e.update(()=>{const l=hn();a.insertAfter(l),l.select()}),!0)}return!1},Xe),t.registerHighCommand(Co,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0){const a=o[0].getNextSibling();if(qn(a)){const u=a.getParent();if(u){const l=a.getIndexWithinParent();return u.select(l,l),i.preventDefault(),!0}}return a==null||a.selectStart(),i.preventDefault(),!0}}else if(de(s)){if(QM(s))return i.preventDefault(),!0;const o=Zg(s.focus,!1),a=o||Qg(s.focus,!1);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectStart(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(nb,i=>{var o,a;const s=ce();if(de(s)){const u=s.focus.getNode();if(fn(u)&&((o=u.getChildAtIndex(s.focus.offset))==null?void 0:o.getType())==="table")return(a=u.getChildAtIndex(s.focus.offset))==null||a.selectStart(),i.preventDefault(),!0}else if(Ln(s)){const u=s.getNodes();if(u.length>0){const l=u[0].getNextSibling();if(qn(l)){const h=l.getParent();if(h){const d=l.getIndexWithinParent();return h.select(d,d),i.preventDefault(),!0}}}}return!1},Tt))}const e2=new Set(["code","table","block-image","meta2d"]);function nN(e){let t=!1;return e.registerUpdateListener(({dirtyElements:n})=>{e.isEditable()&&(!n.has("root")&&!Array.from(n.keys()).some(r=>{var i,s;return((s=(i=e.getEditorState()._nodeMap.get(r))==null?void 0:i.getParent())==null?void 0:s.getKey())==="root"})||t||e.getEditorState().read(()=>{const r=Sn().getLastChild();return e2.has(r==null?void 0:r.getType())})&&(t=!0,queueMicrotask(()=>{e.update(()=>{const r=Sn(),i=r.getLastChild();if(e2.has(i==null?void 0:i.getType())){const s=hn();r.append(s)}t=!1})})))})}lu();var to;const rN=(to=class extends zt{constructor(t,n={}){super(),this.kernel=t,this.config=n,this.formats={bold:!0,header:!0,italic:!0,quote:!0,strikethrough:!0,subscript:!1,superscript:!1};const r=n.markdownOption??!0;typeof r=="object"?(this.formats.bold=r.bold??!0,this.formats.header=r.header??!0,this.formats.italic=r.italic??!0,this.formats.quote=r.quote??!0,this.formats.strikethrough=r.strikethrough??!0,this.formats.subscript=r.subscript??!1,this.formats.superscript=r.superscript??!1):r===!1&&(this.formats.bold=!1,this.formats.header=!1,this.formats.italic=!1,this.formats.quote=!1,this.formats.strikethrough=!1,this.formats.subscript=!1,this.formats.superscript=!1),t.registerDataSource(new RM("json")),t.registerDataSource(new PM("text")),t.registerNodes([H7,ub,Ti]),n!=null&&n.theme&&t.registerThemes({quote:n.theme.quote,text:{bold:n.theme.textBold,code:n.theme.textCode,highlight:n.theme.textHighlight,italic:n.theme.textItalic,strikethrough:n.theme.textStrikethrough,subscript:n.theme.textSubscript,superscript:n.theme.textSuperscript,underline:n.theme.textUnderline,underlineStrikethrough:n.theme.textUnderlineStrikethrough}})}registerMarkdown(t){var o;const n=t.requireService(Lt);if(!n)return;const r=(((o=this.config)==null?void 0:o.markdownOption)??!0)!==!1?`
|
|
358
|
+
`)),m+=h.move(d),g(),m}function r(s,o,a){let u=s.value||"",l=1;for(t||l++;new RegExp("(^|[^$])"+"\\$".repeat(l)+"([^$]|$)").test(u);)l++;const h="$".repeat(l);/[^ \r\n]/.test(u)&&(/^[ \r\n]/.test(u)&&/[ \r\n]$/.test(u)||/^\$|\$$/.test(u))&&(u=" "+u+" ");let d=-1;for(;++d<a.unsafe.length;){const g=a.unsafe[d];if(!g.atBreak)continue;const m=a.compilePattern(g);let y;for(;y=m.exec(u);){let w=y.index;u.codePointAt(w)===10&&u.codePointAt(w-1)===13&&w--,u=u.slice(0,w)+" "+u.slice(y.index+1)}}return h+u+h}function i(){return"$"}}const lM={tokenize:cM,concrete:!0,name:"mathFlow"},Wg={tokenize:hM,partial:!0};function cM(e,t,n){const r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return a;function a(M){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),u(M)}function u(M){return M===36?(e.consume(M),o++,u):o<2?n(M):(e.exit("mathFlowFenceSequence"),Ke(e,l,"whitespace")(M))}function l(M){return M===null||ve(M)?d(M):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(M))}function h(M){return M===null||ve(M)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(M)):M===36?n(M):(e.consume(M),h)}function d(M){return e.exit("mathFlowFence"),r.interrupt?t(M):e.attempt(Wg,g,_)(M)}function g(M){return e.attempt({tokenize:v,partial:!0},_,m)(M)}function m(M){return(s?Ke(e,y,"linePrefix",s+1):y)(M)}function y(M){return M===null?_(M):ve(M)?e.attempt(Wg,g,_)(M):(e.enter("mathFlowValue"),w(M))}function w(M){return M===null||ve(M)?(e.exit("mathFlowValue"),y(M)):(e.consume(M),w)}function _(M){return e.exit("mathFlow"),t(M)}function v(M,T,D){let R=0;return Ke(M,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function F(U){return M.enter("mathFlowFence"),M.enter("mathFlowFenceSequence"),j(U)}function j(U){return U===36?(R++,M.consume(U),j):R<o?D(U):(M.exit("mathFlowFenceSequence"),Ke(M,K,"whitespace")(U))}function K(U){return U===null||ve(U)?(M.exit("mathFlowFence"),T(U)):D(U)}}}function hM(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function fM(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),{tokenize:n,resolve:dM,previous:pM,name:"mathText"};function n(r,i,s){let o=0,a,u;return l;function l(y){return r.enter("mathText"),r.enter("mathTextSequence"),h(y)}function h(y){return y===36?(r.consume(y),o++,h):o<2&&!t?s(y):(r.exit("mathTextSequence"),d(y))}function d(y){return y===null?s(y):y===36?(u=r.enter("mathTextSequence"),a=0,m(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),d):ve(y)?(r.enter("lineEnding"),r.consume(y),r.exit("lineEnding"),d):(r.enter("mathTextData"),g(y))}function g(y){return y===null||y===32||y===36||ve(y)?(r.exit("mathTextData"),d(y)):(r.consume(y),g)}function m(y){return y===36?(r.consume(y),a++,m):a===o?(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",g(y))}}}function dM(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function pM(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function mM(e){return{flow:{36:lM},text:{36:fM(e)}}}const gM={};function bM(e){const t=this,n=e||gM,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mM(n)),s.push(aM()),o.push(uM(n))}const Zl=Qe("plugin","markdown"),yM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function xM(e){const t=e.replace(/^<\/?/,"").replace(/\/?>$/,"").trim(),n=/^([A-Za-z][\w-]*)/.exec(t);return n?n[1].toLowerCase():""}var kM=class{constructor(e){this.root=e,this.stack=[]}push(e){this.stack.push(e)}get isReadingHTML(){return this.stack.length>0}get last(){return this.stack.at(-1)}pop(){return this.stack.pop()}};function Kg(e,t){return e!=="paragraph"?t:Array.isArray(t)?{...ke.createParagraph(),children:t}:t.type!=="paragraph"?{...ke.createParagraph(),children:[t]}:t}function Ff(e,t,n,r={}){switch(e.type){case"text":return ke.createTextNode(e.value);default:{let i=[];if("children"in e&&Array.isArray(e.children)){let s=[];for(i=e.children.reduce((o,a,u)=>{if(a.type==="html"){if(a.value.startsWith("<!--")&&a.value.endsWith("-->"))return o;const l=xM(a.value),h=a.value.startsWith("</");if(!l)return o;if(yM.has(l)){const g=r.html;if(Array.isArray(g))for(const m of g){const y=m(a,[],u);if(y)return o.push(y),o}else if(typeof g=="function"){const m=g(a,[],u);if(m)return o.push(m),o}return o}if(h){const g=n.pop();if(s.pop(),(g==null?void 0:g.tag)!==l)return Zl.warn("HTML tag mismatch:",l),g&&o.push(ke.createTextNode(g.node.value),...g.children.flat().filter(Boolean)||[]),o.push(ke.createTextNode(a.value)),o;const m=r.html,y=g.children.flat().filter(Boolean)||[];if(Array.isArray(m))for(const w of m){const _=w(g.node,y,u);if(_)return o.push(_),o}else if(typeof m=="function"){const w=m(g.node,y,u);if(w)return o.push(w),o}return g&&o.push(...g.children),o}const d={children:[],index:u,isEndTag:h,node:a,tag:l};return s.push(d),n.push(d),o}if(s.length>0){const l=n.last;return l&&l.children.push(Ff(a,u,n,r)),o}return o.push(Ff(a,u,n,r)),o},[]).filter(Boolean).flat();s.length>0;){const o=s.shift();n.pop(),i.push(ke.createTextNode(o==null?void 0:o.node.value),...o.children.flat()),i=i.flat()}}if(r[e.type]){const s=r[e.type];if(Array.isArray(s))for(const o of s){const a=o(e,i,t);if(a)return Kg(e.type,a)}else if(typeof s=="function"){const o=s(e,i,t);if(o)return Kg(e.type,o)}}return e.type==="paragraph"?{...ke.createParagraph(),children:i}:i||null}}}function wM(e){const t=n=>typeof n=="function"||Array.isArray(n)&&n.length>0;t(e.root)||(e.root=(n,r)=>({...ke.createRootNode(),children:r})),t(e.paragraph)||(e.paragraph=(n,r)=>({...ke.createParagraph(),children:r})),t(e.heading)||(e.heading=(n,r)=>{const i=`h${Math.min(Math.max(n.depth,1),6)}`;return ke.createElementNode("heading",{children:r,direction:"ltr",format:"",indent:0,tag:i})})}function Yd(e,t={}){const n=[];let r=e;const i=/---markmap---(\n?)([\S\s]*?)\n?---\/markmap---/g;let s,o=0;for(;(s=i.exec(e))!==null;){const d=`|||MARKMAP_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"markmap"}),r=r.replace(s[0],d),o++}const a=/---meta2d---(\n?)([\S\s]*?)\n?---\/meta2d---/g;for(;(s=a.exec(e))!==null;){const d=`|||META2D_BLOCK_${o}|||`;n.push({content:s[2]||"",placeholder:d,type:"meta2d"}),r=r.replace(s[0],d),o++}const u=g6().use(wv).use(bM).use([[M6,{singleTilde:!1}]]).parse(r);Zl.debug("Parsed MDAST:",u);const l=new kM(u);wM(t);const h=Ff(u,0,l,t);if(n.length>0){const d=m=>{if(m.type==="text"&&typeof m.text=="string"){const y=[];let w=m.text,_=!1;for(const v of n){const M=w.indexOf(v.placeholder);if(M!==-1){_=!0,M>0&&y.push({...m,text:w.slice(0,Math.max(0,M))}),y.push({type:v.type,[v.type==="markmap"?"markdown":"diagram"]:v.content,version:1});const T=w.slice(Math.max(0,M+v.placeholder.length));if(T){const D=d({...m,text:T});Array.isArray(D)?y.push(...D):y.push(D)}break}}return _?y:m}if(m.children&&Array.isArray(m.children)){const y=[];for(const w of m.children){const _=d(w);Array.isArray(_)?y.push(..._):y.push(_)}if(m.children=y.filter(Boolean),m.type==="paragraph"&&m.children.length===1&&(m.children[0].type==="markmap"||m.children[0].type==="meta2d"))return m.children[0]}return m},g=[];for(const m of h.children){const y=d(m);Array.isArray(y)?g.push(...y):g.push(y)}h.children=g.filter(Boolean)}return h}function Vg(e){return Pt(e)&&!e.hasFormat("code")}function N6(e,t,n,r,i){for(let s=0;s<i;s++)if(e[t+s]!==n[r+s])return!1;return!0}const Gg=/[!-/:-@[-`{-~\s]/;function Xg(e,t,n){const r=n.length;for(let i=t;i>=r;i--){const s=i-r;if(N6(e,s,n,0,r)&&e[s+r]!==" ")return s}return-1}function Jg(e,t){const n={};for(const r of e){const i=t(r);i&&(n[i]?n[i].push(r):n[i]=[r])}return n}let D6=/[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~\u00A1\u2010-\u2027-]/;try{D6=new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]","u")}catch{}function vM(e){return D6.test(e)}function SM(e){if(de(e)&&e.isCollapsed()){const t=e.anchor;let n=null;const r=tk(t,"previous");if(r)if(nk(r))n=r.origin;else{const i=pb(r,rk(Sn(),"next").getFlipped());for(const s of i)if(Pt(s.origin)){n=s.origin;break}else if(fn(s.origin)&&!s.origin.isInline())break}if(n&&Pt(n)){const i=n.getFormat(),s=n.getStyle();(e.format!==i||e.style!==s)&&(e.format=i,e.style=s,e.dirty=!0)}}}function CM(e,t,n){e.dispatchCommand(ek,{nodes:t,selection:n})||(n.insertNodes(t),SM(n))}function _M(e){const t={};if(!e)return t;const n=e.split(";");for(const r of n)if(r!==""){const[i,s]=r.split(/:([^]+)/);i&&s&&(t[i.trim()]=s.trim())}return t}const EM=new Map;function TM(e){const t=e.getStyle(),n=_M(t);EM.set(t,n)}function I6(e){const t=[];for(const n of e){const r=X7(n);Pt(r)&&TM(r),t.push(r)}return t}function AM(e,t,n){CM(e,I6(t.children),n)}function L6(e){return e===null?!1:qn(e)||Hr(e)||So(e)}function MM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,trigger:a}of r){const u=s.match(o);if(i===a&&u&&u[0].length===(i==="enter"||u[0].endsWith(" ")?n:n-1))return!0}return!1}function NM(e,t,n,r,i){if(!L6(e.getParent())||e.getFirstChild()!==t)return!1;const s=t.getTextContent();if(i!=="enter"&&s[n-1]!==" ")return!1;for(const{regExp:o,replace:a,trigger:u}of r){const l=s.match(o);if(i===u&&l&&l[0].length===(i==="enter"||l[0].endsWith(" ")?n:n-1)){const h=t.getNextSiblings(),[d,g]=t.splitText(n);if(a(e,g?[g,...h]:h,l,!1)!==!1)return d.remove(),!0}}return!1}function DM(e,t,n){let r=e.getTextContent();const i=n[r[t-1]];if(!i)return!1;t<r.length&&(r=r.slice(0,t));for(const s of i){if(!s.replace||!s.regExp)continue;const o=r.match(s.regExp);if(o===null)continue;const a=o.index||0,u=a+o[0].length;let l;return a===0?[l]=e.splitText(u):[,l]=e.splitText(a,u),l.selectNext(0,0),s.replace(l,o),!0}return!1}function IM(e,t,n){const r=e.getTextContent(),i=t-1,s=r[i],o=n[s];if(!o)return!1;for(const a of o){const{tag:u}=a,l=u.length,h=i-l+1;if(l>1&&!N6(r,h,u,0,l)||r[h-1]===" ")continue;const d=r[i+1];if(a.intraword===!1&&d&&!Gg.test(d))continue;const g=e;let m=g,y=Xg(r,h,u),w=m;for(;y<0&&(w=w.getPreviousSibling())&&!Qn(w);)if(Pt(w)){if(w.hasFormat("code"))continue;const K=w.getTextContent();m=w,y=Xg(K,K.length,u)}if(y<0||m===g&&y+l===h)continue;const _=m.getTextContent();if(y>0&&_[y-1]===s)continue;const v=_[y-1];if(a.intraword===!1&&v&&!Gg.test(v))continue;const M=g.getTextContent(),T=M.slice(0,h)+M.slice(i+1);g.setTextContent(T);const D=m===g?T:_;m.setTextContent(D.slice(0,y)+D.slice(y+l));const R=ce(),F=Lo();je(F);const j=i-l*(m===g?2:1)+1;if(F.anchor.set(m.__key,y,"text"),F.focus.set(g.__key,j,"text"),a.process){if(a.process(F)===!1){const K=ze(m.__key),U=ze(g.__key);Pt(K)&&K.setTextContent(_),U!==K&&Pt(U)&&U.setTextContent(M),je(e.selectEnd());continue}return!0}else if(a.format){for(const K of a.format)F.hasFormat(K)||F.formatText(K);F.anchor.set(F.focus.key,F.focus.offset,F.focus.type);for(const K of a.format)F.hasFormat(K)&&F.toggleFormat(K);de(R)&&(F.format=R.format)}else{je(R);continue}return!0}return!1}Ot();const Lt=uu("MarkdownShortCutService");var LM=class{constructor(e){this.kernel=e,this.elementTransformers=[],this.textFormatTransformers=[],this.textMatchTransformers=[],this.logger=Qe("service","markdown"),this._markdownWriters={},this._markdownReaders=[{},{},{}],this._textFormatTransformersByTrigger=null,this._textMatchTransformersByTrigger=null}get markdownWriters(){return this._markdownWriters}get markdownReaders(){return this._markdownReaders.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]||(e[n]=[]);const r=e[n],i=t[n];r.push(...i)}),e),{})}get textMatchTransformersByTrigger(){return this._textMatchTransformersByTrigger||(this._textMatchTransformersByTrigger=Jg(this.textMatchTransformers,({trigger:e})=>e)),this._textMatchTransformersByTrigger}get textFormatTransformersByTrigger(){return this._textFormatTransformersByTrigger||(this._textFormatTransformersByTrigger=Jg(this.textFormatTransformers,({tag:e})=>e.at(-1))),this._textFormatTransformersByTrigger}registerMarkdownShortCut(e){switch(e.type){case"element":this.elementTransformers.push(e);break;case"text-format":this.textFormatTransformers.push(e);break;case"text-match":this.textMatchTransformers.push(e);break;default:throw new Error(`Unknown transformer type: ${e}`)}}registerMarkdownShortCuts(e){for(const t of e)this.registerMarkdownShortCut(t)}testTransformers(e,t,n,r){if(MM(e,t,n,this.elementTransformers,r))return!0;if(r==="enter"){const i=t.getTextContent(),s=i[n-1],o=this.textMatchTransformersByTrigger[s];if(o){const a=n<i.length?i.slice(0,n):i;for(const u of o)if(u.regExp&&u.regExp.test(a))return!0}}return!1}runTransformers(e,t,n,r){return!!(NM(e,t,n,this.elementTransformers,r)||DM(t,n,this.textMatchTransformersByTrigger)||IM(t,n,this.textFormatTransformersByTrigger))}registerMarkdownWriter(e,t){var n;if(!this._markdownWriters[e]){this._markdownWriters[e]=t;return}if((n=this.kernel)!=null&&n.isHotReloadMode()){this.logger.warn(`🔄 Hot reload: markdown writer "${e}"`),this._markdownWriters[e]=t;return}throw new Error(`Markdown writer for type "${e}" is already registered.`)}registerMarkdownReader(e,t,n=2){var r;this._markdownReaders[n][e]||(this._markdownReaders[n][e]=[]),this._markdownReaders[n]&&((r=this._markdownReaders[n][e])==null||r.push(t))}parseMarkdownToLexical(e){return Yd(e,this.markdownReaders)}insertIRootNode(e,t,n){AM(e,t,n)}};function hU(e=0){if(typeof window>"u"||typeof document>"u")return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0).getBoundingClientRect();if(n.height===0&&n.width===0){const i=t.focusNode;if(i){const s=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;s&&s.scrollIntoView({behavior:"smooth",block:"center"})}return}const r=n.top+n.height/2-window.innerHeight/2+e;window.scrollBy({behavior:"smooth",top:r})}function FM(e){if(!(e instanceof HTMLElement)||e.scrollHeight<=e.clientHeight+1)return!1;const t=window.getComputedStyle(e).overflowY||e.style.overflowY||e.style.overflow;return t==="auto"||t==="scroll"||t==="overlay"}function OM(){var n;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).getBoundingClientRect();if(t.width===0&&t.height===0){const r=e.focusNode;return r?((n=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)==null?void 0:n.getBoundingClientRect())??null:null}return t}function zM(e=96){if(typeof window>"u"||typeof document>"u")return;const t=window.getSelection();if(!t||!t.isCollapsed)return;const n=OM();if(!n)return;let r=document.activeElement;if(r instanceof Element)for(;r&&r!==document.body&&r!==document.documentElement;){if(FM(r)){const i=r.getBoundingClientRect(),s=i.bottom-e;n.bottom>s&&(r.scrollTop+=n.bottom-s);const o=i.top+Math.min(48,e/2);n.top<o&&(r.scrollTop-=o-n.top)}r=r.parentElement}}lu();var RM=class extends Nd{read(e,t,n){let r;typeof t=="string"?r=JSON.parse(t):r=t;const i=s=>{for(let o=0;o<s.children.length;o++){const a=s.children[o];"children"in a&&Array.isArray(a.children)&&i(a),a.type==="text"&&"format"in a&&typeof a.format=="number"&&(a.format&Mm)>0&&(s.children[o]={children:[{...a,format:a.format&~Mm}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},s.children.splice(o+1,0,df))}};i(r.root),e.setEditorState(e.parseEditorState({root:r.root}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var r,i,s;const n=ce();if(!n)return null;if(de(n)){const o=n.getNodes(),a=o.length-1,u=n.anchor,l=n.focus,h=u.isBefore(l),d=o[0],g=o[a],[m,y]=ab(n);let w=[];const _=[];for(let v=0;v<o.length;v++){const M=o[v];if(fn(M)){const T={...M.exportJSON(),$key:M.getKey()};for(let R=0;R<_.length;R++){const F=_[R],j=ze(F.$key);M.isParentOf(j)&&(T.children.push(F),_.splice(R,1),R--)}let D=!1;for(let R=w.length-1;R>=0;R--)if((r=ze(w[R].$key))!=null&&r.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T),w.push(T)}else if(Pt(M)){const T={...M.exportJSON(),$key:M.getKey()};M===d?M===g?(u.type!=="element"||l.type!=="element"||l.offset===u.offset)&&(T.text=m<y?T.text.slice(m,y):T.text.slice(y,m)):T.text=h?T.text.slice(m):T.text.slice(y):M===g&&(T.text=h?T.text.slice(0,y):T.text.slice(0,m));let D=!1;for(let R=w.length-1;R>=0;R--)if((i=ze(w[R].$key))!=null&&i.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}else{const T={...M.exportJSON(),$key:M.getKey()};let D=!1;for(let R=w.length-1;R>=0;R--)if((s=ze(w[R].$key))!=null&&s.isParentOf(M)){w[R].children.push(T),D=!0;break}else w.pop();D||_.push(T)}}return _}return n.getNodes().map(o=>ff(o))}):e.read(()=>({root:ff(Sn())}))}};rn();var PM=class extends Nd{read(e,t){if(typeof t!="string")throw new Error("Invalid data type "+typeof t);const n=t.split(/\n/g),r=ke.createRootNode();n.forEach(i=>{const s=ke.createParagraph();if(i){const o=ke.createTextNode(i);ke.appendChild(s,o)}ke.appendChild(r,s)}),e.setEditorState(e.parseEditorState({root:r}))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{const n=ce();return n?n.getTextContent().replaceAll("\uFEFF",""):null}):e.getEditorState().read(()=>Sn().getTextContent().replaceAll("\uFEFF",""))}};kr();function BM(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function $M(e){return gt(e.registerCommand(ou,()=>{if(cb){const t=document.getSelection();if(t!=null&&t.anchorNode){const n=BM(t.anchorNode);if(n!=null&&n.hasAttribute("data-lexical-linebreak")&&n.parentElement){const r=n.parentElement;return e.update(()=>{const i=u9(r,e);i&&i.selectEnd()}),!0}}}return!1},Fn))}const jM=["color","background-color"];function qM(e){const t=e.trim();return!t||t.length>128||/["'<>\\]|url\s*\(|expression\s*\(|@import/i.test(t)?!1:/^(#[\dA-Fa-f]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[A-Za-z]+)$/.test(t)}function HM(e){if(!(e!=null&&e.trim()))return{};const t={};for(const n of e.split(";")){if(!n.trim())continue;const r=n.indexOf(":");if(r<0)continue;const i=n.slice(0,r).trim().toLowerCase(),s=n.slice(r+1).trim();jM.includes(i)&&qM(s)&&(i==="color"&&(t.color=s),i==="background-color"&&(t["background-color"]=s))}return t}function Ql(e){const t=HM(e),n=[];return t.color&&n.push(`color: ${t.color}`),t["background-color"]&&n.push(`background-color: ${t["background-color"]}`),n.join("; ")}function UM(e){if(!/^<span\b/i.test(e.trim()))return"";const t=/\bstyle\s*=\s*"([^"]*)"/i.exec(e);if(t)return Ql(t[1]);const n=/\bstyle\s*=\s*'([^']*)'/i.exec(e);return n?Ql(n[1]):""}rn();function WM(e){e.registerMarkdownReader("blockquote",(t,n)=>ke.createElementNode("quote",{children:n,direction:"ltr",format:"",indent:0,version:1})),e.registerMarkdownReader("strong",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r))),e.registerMarkdownReader("emphasis",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r))),e.registerMarkdownReader("delete",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|J7),r))),e.registerMarkdownReader("subscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Y7),r))),e.registerMarkdownReader("superscript",(t,n)=>n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Z7),r))),e.registerMarkdownReader("html",(t,n)=>{if(["<ins>","<u>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Q7),r));if(["<em>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Am),r));if(["<strong>"].includes(t.value.toLocaleLowerCase()))return n.map(r=>(ke.isTextNode(r)&&(r.format=(r.format||0)|Tm),r));if(/^<span\b/i.test(t.value.trim())){const r=UM(t.value);return r?n.map(i=>(ke.isTextNode(i)&&(i.style=Ql([i.style,r].filter(Boolean).join("; "))),i)):!1}return!1})}function F6(e){const t=e.target;if(!(t instanceof Node))return null;const n=t.nodeType===Node.TEXT_NODE?t.parentElement:t;return n!=null&&n.closest?n:null}function O6(e){const t=F6(e);return t?!!t.closest('textarea, input:not([type="hidden"]), select'):!1}function KM(e){const t=F6(e);return t?!!t.closest(".cm-editor, .cm-content, .CodeMirror"):!1}const VM=({clipboardData:e})=>{const t=e.items;for(const n of t)if(n.kind==="file")return"skip";return"next"},GM=({clipboardData:e,config:t,editor:n,event:r})=>{if(!t.pasteVSCodeAsCodeBlock)return"next";const i=e.getData("vscode-editor-data");if(!i)return"next";try{const s=JSON.parse(i),o=s.mode||s.language||"plaintext",a=e.getData("text/plain");return a?(r.preventDefault(),n.update(()=>{if(!de(ce()))return;const u=di(o,a);_n([u]);const l=yn();l.add(u.getKey()),je(l)}),"handled"):"next"}catch{return"next"}},XM=({clipboardData:e,editor:t,event:n})=>{const r=e.getData("text/plain");return r?(n.preventDefault(),t.dispatchCommand(sk,r),"handled"):"skip"};function JM(e,t){for(const n of t){const r=n(e);if(r==="handled")return!0;if(r==="skip")return!1}return!1}Es();Ot();const YM=Qe("plugin","common");function Yg(e,t,n){const r=e.getParent();let i=n,s=e;return r!==null&&(t&&n===0?(i=s.getIndexWithinParent(),s=r):!t&&n===s.getChildrenSize()&&(i=s.getIndexWithinParent()+1,s=r)),s.getChildAtIndex(t?i-1:i)}function ZM(e){if(!xn(e))return!1;const t=e.getParent();if(!mt(t))return!1;let n=t.getLastChild();do{if(Qn(n))return!1;if(n===e)return t;n=n==null?void 0:n.getPreviousSibling()}while(n!==e&&n);return n===e?t:!1}function Zg(e,t){var r;const n=e.offset;if(e.type==="element")return Yg(e.getNode(),t,n);{const i=e.getNode();if(t&&n===0||!t&&n===i.getTextContentSize()){const s=t?i.getPreviousSibling():i.getNextSibling();return s===null?Yg(i.getParentOrThrow(),t,i.getIndexWithinParent()+(t?0:1)):s}else if(!t&&ZM(i))return((r=i.getParent())==null?void 0:r.getNextSibling())||null}return null}function Qg(e,t){let n=e.getNode();for(;n!==null&&n.isInline();)n=n.getParent();if(!n)return null;let r=t?n.getPreviousSibling():n.getNextSibling();for(;!r&&!qn(n);){if(n=n.getParent(),!n)return null;r=t?n.getPreviousSibling():n.getNextSibling()}return r||null}function QM(e){const t=e.focus;return t.key==="root"&&t.offset===Sn().getChildrenSize()}function eN(e){return e.registerCommand(Il,t=>{const n=e.getEditorState().read(()=>{const r=ce();if(!de(r)||!r.isCollapsed())return!1;const i=r.anchor;if(i.offset!==0)return!1;const s=i.getNode();if(Pt(s)){if(s.getPreviousSibling())return!1;const o=s.getParentOrThrow();return _o(o)?o:!1}return _o(s)?s:!1});return n?(t.stopImmediatePropagation(),t.preventDefault(),t.stopPropagation(),e.update(()=>{const r=hn();n.replace(r,!0),r.select(0,0)}),!0):!1},Ma)}function tN(e,t,n){const{enableHotkey:r=!0}=n||{};return gt(t.registerHotkey(Nt.PasteAsPlainText,async()=>{try{const i=await navigator.clipboard.readText();e.update(()=>{const s=ce();de(s)&&s.insertText(i)})}catch(i){YM.error("❌ Failed to paste as plain text:",i)}},{enabled:r,preventDefault:!0,stopPropagation:!0}),t.registerHotkey(Nt.Bold,()=>e.dispatchCommand(aa,"bold"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Italic,()=>e.dispatchCommand(aa,"italic"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Underline,()=>e.dispatchCommand(aa,"underline"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Strikethrough,()=>e.dispatchCommand(aa,"strikethrough"),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Undo,()=>e.dispatchCommand(db,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHotkey(Nt.Redo,()=>e.dispatchCommand(fb,void 0),{enabled:r,preventDefault:!0,stopImmediatePropagation:!0}),t.registerHighCommand(ys,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0)return o[0].selectPrevious(),i.preventDefault(),!0}else if(de(s)){const o=Zg(s.focus,!0),a=o||Qg(s.focus,!0);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectEnd(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(Co,i=>{const s=ce();if(de(s)){if(!s.isCollapsed())return!1;const o=s.focus.getNode(),a=Oa(o,l=>l.getType()===ub.getType());if(!a||a.getNextSibling())return!1;const u=a.getLastChild();return!u||!Oa(o,l=>l===u)?!1:(i.preventDefault(),e.update(()=>{const l=hn();a.insertAfter(l),l.select()}),!0)}return!1},Xe),t.registerHighCommand(Co,i=>{const s=ce();if(Ln(s)){const o=s.getNodes();if(o.length>0){const a=o[0].getNextSibling();if(qn(a)){const u=a.getParent();if(u){const l=a.getIndexWithinParent();return u.select(l,l),i.preventDefault(),!0}}return a==null||a.selectStart(),i.preventDefault(),!0}}else if(de(s)){if(QM(s))return i.preventDefault(),!0;const o=Zg(s.focus,!1),a=o||Qg(s.focus,!1);if(!i.shiftKey&&Ai(o)){const u=yn();return u.add(o.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(!i.shiftKey&&Ai(a)){const u=yn();return u.add(a.getKey()),e.update(()=>{je(u)}),i.preventDefault(),!0}else if(o&&o.getType()!=="linebreak")return o==null||o.selectStart(),i.preventDefault(),!0}return!1},Tt),t.registerHighCommand(nb,i=>{var o,a;const s=ce();if(de(s)){const u=s.focus.getNode();if(fn(u)&&((o=u.getChildAtIndex(s.focus.offset))==null?void 0:o.getType())==="table")return(a=u.getChildAtIndex(s.focus.offset))==null||a.selectStart(),i.preventDefault(),!0}else if(Ln(s)){const u=s.getNodes();if(u.length>0){const l=u[0].getNextSibling();if(qn(l)){const h=l.getParent();if(h){const d=l.getIndexWithinParent();return h.select(d,d),i.preventDefault(),!0}}}}return!1},Tt))}const e2=new Set(["code","table","block-image","meta2d"]);function nN(e){let t=!1;return e.registerUpdateListener(({dirtyElements:n})=>{e.isEditable()&&(!n.has("root")&&!Array.from(n.keys()).some(r=>{var i,s;return((s=(i=e.getEditorState()._nodeMap.get(r))==null?void 0:i.getParent())==null?void 0:s.getKey())==="root"})||t||e.getEditorState().read(()=>{const r=Sn().getLastChild();return e2.has(r==null?void 0:r.getType())})&&(t=!0,queueMicrotask(()=>{e.update(()=>{const r=Sn(),i=r.getLastChild();if(e2.has(i==null?void 0:i.getType())){const s=hn();r.append(s)}t=!1})})))})}lu();var to;const rN=(to=class extends zt{constructor(t,n={}){super(),this.kernel=t,this.config=n,this.formats={bold:!0,header:!0,italic:!0,quote:!0,strikethrough:!0,subscript:!1,superscript:!1};const r=n.markdownOption??!0;typeof r=="object"?(this.formats.bold=r.bold??!0,this.formats.header=r.header??!0,this.formats.italic=r.italic??!0,this.formats.quote=r.quote??!0,this.formats.strikethrough=r.strikethrough??!0,this.formats.subscript=r.subscript??!1,this.formats.superscript=r.superscript??!1):r===!1&&(this.formats.bold=!1,this.formats.header=!1,this.formats.italic=!1,this.formats.quote=!1,this.formats.strikethrough=!1,this.formats.subscript=!1,this.formats.superscript=!1),t.registerDataSource(new RM("json")),t.registerDataSource(new PM("text")),t.registerNodes([H7,ub,Ti]),n!=null&&n.theme&&t.registerThemes({quote:n.theme.quote,text:{bold:n.theme.textBold,code:n.theme.textCode,highlight:n.theme.textHighlight,italic:n.theme.textItalic,strikethrough:n.theme.textStrikethrough,subscript:n.theme.textSubscript,superscript:n.theme.textSuperscript,underline:n.theme.textUnderline,underlineStrikethrough:n.theme.textUnderlineStrikethrough}})}registerMarkdown(t){var o;const n=t.requireService(Lt);if(!n)return;const r=(((o=this.config)==null?void 0:o.markdownOption)??!0)!==!1?`
|
|
359
359
|
|
|
360
360
|
`:`
|
|
361
361
|
`,i=this.formats;i.quote&&n.registerMarkdownShortCut({regExp:/^>\s/,replace:(a,u,l,h)=>{if(h){const g=a.getPreviousSibling();if(So(g)){g.splice(g.getChildrenSize(),0,[xd(),...u]),a.remove();return}}const d=kd();d.append(...u),a.replace(d),h||d.select(0,0)},type:"element"}),i.header&&n.registerMarkdownShortCut({regExp:/^(#{1,6})\s/,replace:Bb((a,u)=>{const l="h"+a[1].length;return _o(u)&&u.getTag()===l?hn():lb(l)}),type:"element"});const s=[];i.bold&&s.push({format:["bold"],tag:"**",type:"text-format"},{format:["bold"],intraword:!1,tag:"__",type:"text-format"}),i.strikethrough&&s.push({format:["strikethrough"],tag:"~~",type:"text-format"}),i.italic&&s.push({format:["italic"],tag:"*",type:"text-format"},{format:["italic"],intraword:!1,tag:"_",type:"text-format"}),i.superscript&&s.push({format:["superscript"],tag:"^",type:"text-format"}),i.subscript&&s.push({format:["subscript"],tag:"~",type:"text-format"}),s.length>0&&n.registerMarkdownShortCuts(s),n.registerMarkdownWriter("paragraph",a=>{a.wrap("",r)}),i.quote&&n.registerMarkdownWriter("quote",(a,u)=>{So(u)&&a.wrap("> ",r)}),i.header&&n.registerMarkdownWriter("heading",(a,u)=>{if(_o(u))switch(u.getTag()){case"h1":a.wrap("# ",`
|
|
@@ -374,7 +374,7 @@ $$
|
|
|
374
374
|
|
|
375
375
|
`);break}}),n.registerMarkdownWriter("text",(a,u)=>{if(!Pt(u))return;const l=i.bold&&u.hasFormat("bold"),h=i.italic&&u.hasFormat("italic"),d=u.hasFormat("underline"),g=i.strikethrough&&u.hasFormat("strikethrough"),m=i.superscript&&u.hasFormat("superscript"),y=i.subscript&&u.hasFormat("subscript"),w=Ql(u.getStyle());w&&a.appendLine(`<span style="${w}">`),l&&a.appendLine("**"),g&&a.appendLine("~~"),h&&a.appendLine("_"),d&&a.appendLine("<ins>"),m&&a.appendLine("^"),y&&a.appendLine("~");const _=u.getTextContent(),v=_.match(/\s+$/);let M="";v&&(M=v[0]);const T=_.trimEnd(),D=T.at(-1);a.appendLine(T),y&&a.appendLine("~"),m&&a.appendLine("^"),d&&a.appendLine("</ins>"),h&&a.appendLine("_"),g&&a.appendLine("~~"),l&&a.appendLine("**"),w&&a.appendLine("</span>"),M?a.appendLine(M):D&&vM(D)&&a.appendLine(" ")}),n.registerMarkdownWriter("linebreak",a=>{a.appendLine(`
|
|
376
376
|
`)}),WM(n)}onInit(t){var n;this.register(t.registerUpdateListener(({tags:r})=>{r.has(Qh)||r.has(Aa)||typeof window>"u"||requestAnimationFrame(()=>{t.getRootElement()===document.activeElement&&zM(96)})})),this.register(this.kernel.registerHighCommand(yc,r=>{var o,a;if(!(r instanceof ClipboardEvent)||O6(r))return!1;const i=r.clipboardData;if(!i)return!1;this.kernel.emit("onPaste",r);const s={clipboardData:i,config:this.config,editor:t,event:r};return(o=this.config)!=null&&o.pasteVSCodeAsCodeBlock&&GM(s)==="handled"?!0:(a=this.config)!=null&&a.pasteAsPlainText?JM(s,[VM,XM]):!1},Zn)),this.registerClears(U7(t),cb?W7(t):Fo,K7(t,this.kernel.getHistoryState(),300),eN(t),tN(t,this.kernel,{enableHotkey:(n=this.config)==null?void 0:n.enableHotkey}),iC(t),$M(t),N9(t),nN(t),t.registerCommand(V7,()=>{const r=ce();if(!de(r))return!1;const{inCell:i,inTable:s}=_9(r);return i||s||E9(r)?!1:(t.update(()=>{t.dispatchCommand(G7,void 0)}),!0)},Fn)),this.registerMarkdown(this.kernel)}destroy(){super.destroy()}},to.pluginName="CommonPlugin",to),z6=()=>null;z6.displayName="ReactEditorContent";const iN=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?E.useLayoutEffect:E.useEffect;function sN(e,t){const[n,r]=E.useState(()=>{var i;return((i=e.getLexicalEditor())==null?void 0:i.getDecorators())||{}});return iN(()=>{let i=[];const s=a=>{r(a.getDecorators()),i.push(a.registerDecoratorListener(u=>{Pi.flushSync(()=>{r(u)})}))},o=e.getLexicalEditor();return o?s(o):(e.on("initialized",s),i.push(()=>{e.off("initialized",s)})),()=>{i.forEach(a=>a())}},[e]),E.useMemo(()=>{var o;const i=[],s=Object.keys(n);for(const a of s){const u=n[a],l=O.jsx(t,{onError:d=>{var g;return(g=e.getLexicalEditor())==null?void 0:g._onError(d)},children:O.jsx(E.Suspense,{fallback:null,children:"render"in u?u.render:u})}),h=(o=e.getLexicalEditor())==null?void 0:o.getElementByKey(a);h!=null&&i.push(Pi.createPortal(l,"queryDOM"in u?u.queryDOM(h):h,a))}return i},[t,n,e])}Ot();const ch=Qe("plugin","markdown"),Of=lt("INSERT_MARKDOWN_COMMAND"),oN=lt("GET_MARKDOWN_SELECTION_COMMAND");function t2(e,t){return e.slice(0,Math.max(0,t)).split(`
|
|
377
|
-
`).length}function aN(e,t){t&&e.setEditorState(t.editorState,{tag:Aa})}function n2(e){let t=e,n=t.getParent();for(;n!==null&&!qn(n);)t=n,n=t.getParent();return t}function uN(e){var r,i,s;if(e.length===0)return;let t=ce();if(!de(t)){Sn().append(...e),(r=e.at(-1))==null||r.selectEnd();return}t.isCollapsed()||t.removeText();let n=n2(t.anchor.getNode());if(n.getTextContent()!==""){if(t.insertParagraph(),t=ce(),!de(t)){Sn().append(...e),(i=e.at(-1))==null||i.selectEnd();return}n=n2(t.anchor.getNode())}for(const o of e)n.insertBefore(o);n.getTextContent()===""&&n.remove(),(s=e.at(-1))==null||s.selectEnd()}function lN(e){const t=[],n=e.getLexicalEditor();return n&&n.getEditorState().read(()=>{function r(i){Pt(i)&&i.getType()!=="cursor"&&t.push({key:i.getKey(),text:i.getTextContent()}),fn(i)&&i.getChildren().forEach(r)}r(Sn())}),t}function r2(e,t,n,r){let i=0;for(const s of t){const o=[];let a=0;const u=i;for(;a<s.text.length&&i<e.length;)e[i]===s.text[a]?(o[a]=i,i++,a++):i++;if(s.key===n){if(r<s.text.length)return o[r]??u+r;const l=s.text.length-1;return(o[l]??u+l)+1}}return 0}function cN(e,t,n){return gt(e.registerCommand(Of,r=>{const{markdown:i}=r;ch.debug("INSERT_MARKDOWN_COMMAND payload:",r),r.editorState?e.setEditorState(r.editorState,{tag:Aa}):aN(e,r.historyState);const s=e.getEditorState().read(()=>Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"")==="");return r.replaceDocument||s?(t.setDocument("markdown",i,{keepHistory:!0}),!1):(setTimeout(()=>{e.update(()=>{try{const o=Yd(i,n.markdownReaders);let a=ce();a===null&&(Sn().selectEnd(),a=ce());const u=I6(o.children);return ch.debug("INSERT_MARKDOWN_COMMAND nodes:",u),uN(u),!0}catch(o){ch.error("Failed to handle markdown paste:",o)}},{tag:j7})},0),!1)},Fn),e.registerCommand(oN,r=>{const i=t.getDocument("markdown");if(!i)return!1;const s=t.getSelection();if(!s||s.type!=="range")return!1;const o=lN(t),a=r2(i,o,s.startNodeId,s.startOffset),u=r2(i,o,s.endNodeId,s.endOffset),l=Math.min(a,u),h=Math.max(a,u);return r.onResult(t2(i,l),t2(i,h)),!1},Fn))}const Zd=uu("INodeService");var hN=class{constructor(){this.processNodeTreeHandlers=[]}registerProcessNodeTree(e){this.processNodeTreeHandlers.push(e)}processNodeTree(e){for(const t of this.processNodeTreeHandlers)t(e)}};Bt();var no;const fN=(no=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n;const r=new hN;t.registerService(Zd,r)}onInit(){}},no.pluginName="INodePlugin",no);var hh=class R6{constructor(t){this.before="",this.after="",this.children=[],this.markdownService=t}appendLine(t){this.children.push(t)}newChild(){const t=new R6(this.markdownService);return this.children.push(t),t}wrap(t,n){this.before=t,this.after=n}addProcessor(t){this.processor=t}toString(){const t=this.before+this.children.map(n=>n.toString()).join("")+this.after;return this.processor?this.processor(this.before,this.children.map(n=>n.toString()).join(""),this.after):t}processChild(t,n){const r=this.markdownService.markdownWriters[n.getType()];let i=t;fn(n)&&(i=i.newChild());let s=!1;r&&(s=r(i,n)),!s&&fn(n)&&n.getChildren().forEach(o=>this.processChild(i,o))}};rn();var dN=class extends Nd{formatMarkdown(e){try{const t=g6().use([[M6,{singleTilde:!1}]]).data("settings",{bullet:"-",emphasis:"*",fences:!0,resourceLink:!0,rule:"-",strong:"*",tightDefinitions:!0}).processSync(e);return String(t)}catch(t){return Zl.error("Failed to format markdown:",t),e}}constructor(e,t,n){super(e),this.dataType=e,this.markdownService=t,this.getService=n}read(e,t){var r,i;const n={root:Yd(t,this.markdownService.markdownReaders)};(i=(r=this.getService)==null?void 0:r.call(this,Zd))==null||i.processNodeTree(n),Zl.debug("Parsed Lexical State:",n),e.setEditorState(e.parseEditorState(n))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var u,l,h;const n=ce();if(!n)return null;const r=n.getNodes();if(de(n)){const d=r.length-1,g=n.anchor,m=n.focus,y=g.isBefore(m),w=r[0],_=r[d],[v,M]=ab(n);let T=[];const D=[];for(let U=0;U<r.length;U++){const z=r[U];if(fn(z)){const V={...z.exportJSON(),$key:z.getKey()};for(let ee=0;ee<D.length;ee++){const Q=D[ee],ae=ze(Q.$key);z.isParentOf(ae)&&(V.children.push(Q),D.splice(ee,1),ee--)}let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((u=ze(T[ee].$key))!=null&&u.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V),T.push(V)}else if(Pt(z)){const V={...z.exportJSON(),$key:z.getKey()};z===w?z===_?(g.type!=="element"||m.type!=="element"||m.offset===g.offset)&&(V.text=v<M?V.text.slice(v,M):V.text.slice(M,v)):V.text=y?V.text.slice(v):V.text.slice(M):z===_&&(V.text=y?V.text.slice(0,M):V.text.slice(0,v));let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((l=ze(T[ee].$key))!=null&&l.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}else{const V={...z.exportJSON(),$key:z.getKey()};let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((h=ze(T[ee].$key))!=null&&h.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}}const R=ke.createRootNode();if(D.some(U=>ke.isTextNode(U))){const U=ke.createParagraph();ke.appendChild(U,...D),ke.appendChild(R,U)}else ke.appendChild(R,...D);const F=e.parseEditorState({root:R}),j=F._nodeMap.get("root"),K=new hh(this.markdownService);return F.read(()=>(j.getChildren().forEach(U=>K.processChild(K,U)),this.formatMarkdown(K.toString())))}const i=ke.createRootNode();if(r.some(d=>d.isInline())){const d=ke.createParagraph();ke.appendChild(d,...r.map(g=>g.exportJSON())),ke.appendChild(i,d)}else ke.appendChild(i,...r.map(d=>d.exportJSON()));const s=e.parseEditorState({root:i}),o=s._nodeMap.get("root"),a=new hh(this.markdownService);return s.read(()=>(o.getChildren().forEach(d=>a.processChild(a,d)),a.toString()))}):e.getEditorState().read(()=>{const n=Sn(),r=new hh(this.markdownService);return n.getChildren().forEach(i=>r.processChild(r,i)),this.formatMarkdown(r.toString())})}};Bt();Ot();const pN="strong,em,b,i,h1,h2,h3,h4,h5,h6,ul,ol,table,img,blockquote,pre>code,a[href]";function mN(e){let t=0;return/^#{1,6}\s+\S+/m.test(e)&&(t+=3),/(\*\*|__)[\S\s]+?\1/.test(e)&&(t+=2),/([*_])[\S\s]+?\1/.test(e)&&(t+=1),/~~[\S\s]+?~~/.test(e)&&(t+=2),/`[^`]+`/.test(e)&&(t+=2),/^```[\w+-]*\s*$/m.test(e)&&/^```\s*$/m.test(e)&&(t+=4),/\[.+?]\s*\([^)]+\)/.test(e)&&(t+=2),/!\[.*?]\s*\([^)]+\)/.test(e)&&(t+=2),/^[*+-]\s+\S+/m.test(e)&&(t+=2),/^\d+\.\s+\S+/m.test(e)&&(t+=2),/^>\s+\S+/m.test(e)&&(t+=2),/^[*_-]{3,}\s*$/m.test(e)&&(t+=2),/^\|.*\|/.test(e)&&/^\|[:-]+\|/.test(e)&&(t+=3),t}function gN(){const e=ce();if(de(e)){let t=e.anchor.getNode();for(;t;){if(mt(t)||xn(t)||Mi(t))return!0;t=t.getParent()}return!1}return Ln(e)?e.getNodes().some(t=>mt(t)||Mi(t)):!1}var ro;const Vi=(ro=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","markdown"),this.service=new LM(t),t.registerService(Lt,this.service),this.markdownDataSource=new dN("markdown",this.service,r=>t.requireService(r)),t.registerDataSource(this.markdownDataSource)}onInit(t){this.register(t.registerUpdateListener(({tags:n,dirtyLeaves:r,editorState:i,prevEditorState:s})=>{if(n.has(z7)||n.has(Aa)||t.isComposing())return;const o=i.read(ce),a=s.read(ce);if(!de(a)||!de(o)||!o.isCollapsed()||o.is(a))return;const u=o.anchor.key,l=o.anchor.offset,h=i._nodeMap.get(u);!Pt(h)||!r.has(u)||l!==1&&l>a.anchor.offset+1||t.update(()=>{if(!Vg(h))return;const d=h.getParent();d===null||mt(d)||this.service.runTransformers(d,h,o.anchor.offset)&&this.kernel.emit("markdownTransform",{trigger:"type"})})})),this.register(t.registerCommand(R7,n=>{const r=t.getEditorState().read(()=>{const a=ce();if(!de(a)||!a.isCollapsed())return!1;const u=a.anchor.key,l=ze(u);return l?{anchorNode:l,offset:a.anchor.offset}:!1});if(!r)return!1;const{anchorNode:i,offset:s}=r;if(!Vg(i))return!1;const o=i.getParent();return o===null||mt(o)?!1:this.service.testTransformers(o,i,s,"enter")?(queueMicrotask(()=>{t.update(()=>{this.service.runTransformers(o,i,s,"enter")}),this.kernel.emit("markdownTransform",{trigger:"enter"})}),n==null||n.stopPropagation(),n==null||n.stopImmediatePropagation(),n==null||n.preventDefault(),!0):!1},Zn)),this.register(t.registerCommand(yc,n=>{var a;if(!(n instanceof ClipboardEvent)||O6(n)||KM(n)||!this.shouldHandlePasteMarkdown()||t.getEditorState().read(()=>gN()))return!1;const r=n.clipboardData;if(!r)return!1;const i=r.getData("text/plain").trimEnd().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");if(!i)return!1;const s=mN(i);if((a=this.config)!=null&&a.onPasteMarkdown&&s>=2){n.preventDefault(),n.stopPropagation();const u=this.kernel.getHistoryState().current,l=t.getEditorState(),h=l.read(()=>{const d=ce(),g=Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");return g===""?!0:de(d)&&!d.isCollapsed()&&d.getTextContent().length>=g.length-1});return Promise.resolve(this.config.onPasteMarkdown(i)).then(d=>{d?(t.dispatchCommand(Of,{editorState:l,historyState:u,markdown:i,replaceDocument:h}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:u,markdown:i,matchedPatterns:[],score:s})):(t.setEditorState(l,{tag:Aa}),setTimeout(()=>{t.update(()=>{const g=ce();de(g)&&g.insertRawText(i)})},0))}),!0}if(this.hasRichHTML(r)||/^https?:\/\/\S+$/i.test(i)||s<2||s<6)return!1;const o=this.kernel.getHistoryState().current;return setTimeout(()=>{t.dispatchCommand(Of,{historyState:o,markdown:i}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:o,markdown:i,matchedPatterns:[],score:s})},10),!1},Zn)),this.register(cN(t,this.kernel,this.service)),this.register(t.registerCommand(P7,n=>{if(!(n instanceof ClipboardEvent))return!1;const r=n.clipboardData;if(!r)return!1;const i=ce();if(!i||i.isCollapsed())return!1;const s=this.markdownDataSource.write(t,{selection:!0});return s?(n.preventDefault(),B7(r,$7(i)),r.setData("text/plain",s),r.setData("text/markdown",s),this.logger.debug("copy with text/markdown:",{markdownLength:s.length}),!0):!1},Xe))}hasRichHTML(t){const n=t.getData("text/html");return!n||/data-vscode|vscode-/i.test(n)||typeof DOMParser>"u"?!1:new DOMParser().parseFromString(n,"text/html").body.querySelectorAll(pN).length>0}shouldHandlePasteMarkdown(){var t,n;return((t=this.config)==null?void 0:t.enablePasteMarkdown)===!1?!1:((n=this.config)==null?void 0:n.autoFormatMarkdown)!==!1}},ro.pluginName="MarkdownPlugin",ro),bN=tt(({css:e,cssVar:t})=>({placeholder:e`
|
|
377
|
+
`).length}function aN(e,t){t&&e.setEditorState(t.editorState,{tag:Aa})}function n2(e){let t=e,n=t.getParent();for(;n!==null&&!qn(n);)t=n,n=t.getParent();return t}function uN(e){var r,i,s;if(e.length===0)return;let t=ce();if(!de(t)){Sn().append(...e),(r=e.at(-1))==null||r.selectEnd();return}t.isCollapsed()||t.removeText();let n=n2(t.anchor.getNode());if(n.getTextContent()!==""){if(t.insertParagraph(),t=ce(),!de(t)){Sn().append(...e),(i=e.at(-1))==null||i.selectEnd();return}n=n2(t.anchor.getNode())}for(const o of e)n.insertBefore(o);n.getTextContent()===""&&n.remove(),(s=e.at(-1))==null||s.selectEnd()}function lN(e){const t=[],n=e.getLexicalEditor();return n&&n.getEditorState().read(()=>{function r(i){Pt(i)&&i.getType()!=="cursor"&&t.push({key:i.getKey(),text:i.getTextContent()}),fn(i)&&i.getChildren().forEach(r)}r(Sn())}),t}function r2(e,t,n,r){let i=0;for(const s of t){const o=[];let a=0;const u=i;for(;a<s.text.length&&i<e.length;)e[i]===s.text[a]?(o[a]=i,i++,a++):i++;if(s.key===n){if(r<s.text.length)return o[r]??u+r;const l=s.text.length-1;return(o[l]??u+l)+1}}return 0}function cN(e,t,n){return gt(e.registerCommand(Of,r=>{const{markdown:i}=r;ch.debug("INSERT_MARKDOWN_COMMAND payload:",r),r.editorState?e.setEditorState(r.editorState,{tag:Aa}):aN(e,r.historyState);const s=e.getEditorState().read(()=>Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"")==="");return r.replaceDocument||s?(t.setDocument("markdown",i,{keepHistory:!0}),!1):(setTimeout(()=>{e.update(()=>{try{const o=Yd(i,n.markdownReaders);let a=ce();a===null&&(Sn().selectEnd(),a=ce());const u=I6(o.children);return ch.debug("INSERT_MARKDOWN_COMMAND nodes:",u),uN(u),!0}catch(o){ch.error("Failed to handle markdown paste:",o)}},{tag:j7})},0),!1)},Fn),e.registerCommand(oN,r=>{const i=t.getDocument("markdown");if(!i)return!1;const s=t.getSelection();if(!s||s.type!=="range")return!1;const o=lN(t),a=r2(i,o,s.startNodeId,s.startOffset),u=r2(i,o,s.endNodeId,s.endOffset),l=Math.min(a,u),h=Math.max(a,u);return r.onResult(t2(i,l),t2(i,h)),!1},Fn))}const Zd=uu("INodeService");var hN=class{constructor(){this.processNodeTreeHandlers=[]}registerProcessNodeTree(e){this.processNodeTreeHandlers.push(e)}processNodeTree(e){for(const t of this.processNodeTreeHandlers)t(e)}};Bt();var no;const fN=(no=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n;const r=new hN;t.registerService(Zd,r)}onInit(){}},no.pluginName="INodePlugin",no);var hh=class R6{constructor(t){this.before="",this.after="",this.children=[],this.markdownService=t}appendLine(t){this.children.push(t)}newChild(){const t=new R6(this.markdownService);return this.children.push(t),t}wrap(t,n){this.before=t,this.after=n}addProcessor(t){this.processor=t}toString(){const t=this.before+this.children.map(n=>n.toString()).join("")+this.after;return this.processor?this.processor(this.before,this.children.map(n=>n.toString()).join(""),this.after):t}processChild(t,n){const r=this.markdownService.markdownWriters[n.getType()];let i=t;fn(n)&&(i=i.newChild());let s=!1;r&&(s=r(i,n)),!s&&fn(n)&&n.getChildren().forEach(o=>this.processChild(i,o))}};rn();var dN=class extends Nd{formatMarkdown(e){try{const t=g6().use([[M6,{singleTilde:!1}]]).data("settings",{bullet:"-",emphasis:"*",fences:!0,resourceLink:!0,rule:"-",strong:"*",tightDefinitions:!0}).processSync(e);return String(t)}catch(t){return Zl.error("Failed to format markdown:",t),e}}constructor(e,t,n){super(e),this.dataType=e,this.markdownService=t,this.getService=n}read(e,t){var r,i;const n={root:Yd(t,this.markdownService.markdownReaders)};(i=(r=this.getService)==null?void 0:r.call(this,Zd))==null||i.processNodeTree(n),Zl.debug("Parsed Lexical State:",n),e.setEditorState(e.parseEditorState(n))}write(e,t){return t!=null&&t.selection?e.getEditorState().read(()=>{var u,l,h;const n=ce();if(!n)return null;const r=n.getNodes();if(de(n)){const d=r.length-1,g=n.anchor,m=n.focus,y=g.isBefore(m),w=r[0],_=r[d],[v,M]=ab(n);let T=[];const D=[];for(let U=0;U<r.length;U++){const z=r[U];if(fn(z)){const V={...z.exportJSON(),$key:z.getKey()};for(let ee=0;ee<D.length;ee++){const Q=D[ee],ae=ze(Q.$key);z.isParentOf(ae)&&(V.children.push(Q),D.splice(ee,1),ee--)}let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((u=ze(T[ee].$key))!=null&&u.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V),T.push(V)}else if(Pt(z)){const V={...z.exportJSON(),$key:z.getKey()};z===w?z===_?(g.type!=="element"||m.type!=="element"||m.offset===g.offset)&&(V.text=v<M?V.text.slice(v,M):V.text.slice(M,v)):V.text=y?V.text.slice(v):V.text.slice(M):z===_&&(V.text=y?V.text.slice(0,M):V.text.slice(0,v));let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((l=ze(T[ee].$key))!=null&&l.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}else{const V={...z.exportJSON(),$key:z.getKey()};let X=!1;for(let ee=T.length-1;ee>=0;ee--)if((h=ze(T[ee].$key))!=null&&h.isParentOf(z)){T[ee].children.push(V),X=!0;break}else T.pop();X||D.push(V)}}const R=ke.createRootNode();if(D.some(U=>ke.isTextNode(U))){const U=ke.createParagraph();ke.appendChild(U,...D),ke.appendChild(R,U)}else ke.appendChild(R,...D);const F=e.parseEditorState({root:R}),j=F._nodeMap.get("root"),K=new hh(this.markdownService);return F.read(()=>(j.getChildren().forEach(U=>K.processChild(K,U)),this.formatMarkdown(K.toString())))}const i=ke.createRootNode();if(r.some(d=>d.isInline())){const d=ke.createParagraph();ke.appendChild(d,...r.map(g=>g.exportJSON())),ke.appendChild(i,d)}else ke.appendChild(i,...r.map(d=>d.exportJSON()));const s=e.parseEditorState({root:i}),o=s._nodeMap.get("root"),a=new hh(this.markdownService);return s.read(()=>(o.getChildren().forEach(d=>a.processChild(a,d)),a.toString()))}):e.getEditorState().read(()=>{const n=Sn(),r=new hh(this.markdownService);return n.getChildren().forEach(i=>r.processChild(r,i)),this.formatMarkdown(r.toString())})}};Bt();Ot();const pN="strong,em,b,i,h1,h2,h3,h4,h5,h6,ul,ol,table,img,blockquote,pre>code,a[href]";function mN(e){let t=0;return/^#{1,6}\s+\S+/m.test(e)&&(t+=3),/(\*\*|__)[\S\s]+?\1/.test(e)&&(t+=2),/([*_])[\S\s]+?\1/.test(e)&&(t+=1),/~~[\S\s]+?~~/.test(e)&&(t+=2),/`[^`]+`/.test(e)&&(t+=2),/^```[\w+-]*\s*$/m.test(e)&&/^```\s*$/m.test(e)&&(t+=4),/\[.+?]\s*\([^)]+\)/.test(e)&&(t+=2),/!\[.*?]\s*\([^)]+\)/.test(e)&&(t+=2),/^[*+-]\s+\S+/m.test(e)&&(t+=2),/^\d+\.\s+\S+/m.test(e)&&(t+=2),/^>\s+\S+/m.test(e)&&(t+=2),/^[*_-]{3,}\s*$/m.test(e)&&(t+=2),/^\|.*\|/.test(e)&&/^\|[:-]+\|/.test(e)&&(t+=3),t}function gN(){const e=ce();if(de(e)){let t=e.anchor.getNode();for(;t;){if(mt(t)||xn(t)||Mi(t))return!0;t=t.getParent()}return!1}return Ln(e)?e.getNodes().some(t=>mt(t)||Mi(t)):!1}var ro;const Vi=(ro=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","markdown"),this.service=new LM(t),t.registerService(Lt,this.service),this.markdownDataSource=new dN("markdown",this.service,r=>t.requireService(r)),t.registerDataSource(this.markdownDataSource)}onInit(t){this.register(t.registerUpdateListener(({tags:n,dirtyLeaves:r,editorState:i,prevEditorState:s})=>{if(n.has(z7)||n.has(Aa)||t.isComposing())return;const o=i.read(ce),a=s.read(ce);if(!de(a)||!de(o)||!o.isCollapsed()||o.is(a))return;const u=o.anchor.key,l=o.anchor.offset,h=i._nodeMap.get(u);!Pt(h)||!r.has(u)||l!==1&&l>a.anchor.offset+1||t.update(()=>{if(!Vg(h))return;const d=h.getParent();d===null||mt(d)||this.service.runTransformers(d,h,o.anchor.offset)&&this.kernel.emit("markdownTransform",{trigger:"type"})})})),this.register(t.registerCommand(R7,n=>{const r=t.getEditorState().read(()=>{const a=ce();if(!de(a)||!a.isCollapsed())return!1;const u=a.anchor.key,l=ze(u);return l?{anchorNode:l,offset:a.anchor.offset}:!1});if(!r)return!1;const{anchorNode:i,offset:s}=r;if(!Vg(i))return!1;const o=i.getParent();return o===null||mt(o)?!1:this.service.testTransformers(o,i,s,"enter")?(queueMicrotask(()=>{t.update(()=>{this.service.runTransformers(o,i,s,"enter")}),this.kernel.emit("markdownTransform",{trigger:"enter"})}),n==null||n.stopPropagation(),n==null||n.stopImmediatePropagation(),n==null||n.preventDefault(),!0):!1},Zn)),this.register(t.registerCommand(yc,n=>{var a;if(!(n instanceof ClipboardEvent)||O6(n)||KM(n)||!this.shouldHandlePasteMarkdown()||t.getEditorState().read(()=>gN()))return!1;const r=n.clipboardData;if(!r)return!1;const i=r.getData("text/plain").trimEnd().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");if(!i||this.hasRichHTML(r))return!1;const s=mN(i);if((a=this.config)!=null&&a.onPasteMarkdown&&s>=2){n.preventDefault(),n.stopPropagation();const u=this.kernel.getHistoryState().current,l=t.getEditorState(),h=l.read(()=>{const d=ce(),g=Sn().getTextContent().replaceAll(/[\u200B-\u200D\u2060\uFEFF]/g,"");return g===""?!0:de(d)&&!d.isCollapsed()&&d.getTextContent().length>=g.length-1});return Promise.resolve(this.config.onPasteMarkdown(i)).then(d=>{d?(t.dispatchCommand(Of,{editorState:l,historyState:u,markdown:i,replaceDocument:h}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:u,markdown:i,matchedPatterns:[],score:s})):(t.setEditorState(l,{tag:Aa}),setTimeout(()=>{t.update(()=>{const g=ce();de(g)&&g.insertRawText(i)})},0))}),!0}if(/^https?:\/\/\S+$/i.test(i)||s<2||s<6)return!1;const o=this.kernel.getHistoryState().current;return setTimeout(()=>{t.dispatchCommand(Of,{historyState:o,markdown:i}),this.kernel.emit("markdownParse",{cacheState:t.getEditorState(),historyState:o,markdown:i,matchedPatterns:[],score:s})},10),!1},Zn)),this.register(cN(t,this.kernel,this.service)),this.register(t.registerCommand(P7,n=>{if(!(n instanceof ClipboardEvent))return!1;const r=n.clipboardData;if(!r)return!1;const i=ce();if(!i||i.isCollapsed())return!1;const s=this.markdownDataSource.write(t,{selection:!0});return s?(n.preventDefault(),B7(r,$7(i)),r.setData("text/plain",s),r.setData("text/markdown",s),this.logger.debug("copy with text/markdown:",{markdownLength:s.length}),!0):!1},Xe))}hasRichHTML(t){const n=t.getData("text/html");return!n||/data-vscode|vscode-/i.test(n)||typeof DOMParser>"u"?!1:new DOMParser().parseFromString(n,"text/html").body.querySelectorAll(pN).length>0}shouldHandlePasteMarkdown(){var t,n;return((t=this.config)==null?void 0:t.enablePasteMarkdown)===!1?!1:((n=this.config)==null?void 0:n.autoFormatMarkdown)!==!1}},ro.pluginName="MarkdownPlugin",ro),bN=tt(({css:e,cssVar:t})=>({placeholder:e`
|
|
378
378
|
pointer-events: none;
|
|
379
379
|
user-select: none;
|
|
380
380
|
|
|
@@ -1734,7 +1734,7 @@ ${this.__markdown}
|
|
|
1734
1734
|
## 分支 2`,style:{border:"none",flex:1,fontFamily:"monospace",fontSize:14,lineHeight:1.6,outline:"none",padding:16,resize:"none"},value:r})]}),O.jsx("div",{style:{display:"flex",flexDirection:"column",width:"50%"},children:O.jsx(Wx,{markdown:r})})]})]})}function zq({className:e,editor:t,node:n}){const[r,i]=E.useState(!1),s=n.__markdown;E.useLayoutEffect(()=>{const u=n.getKey();let l=!1;t.getEditorState().read(()=>{const h=ze(u);h&&j4(h)&&h.__autoOpenEditor&&(l=!0)}),l&&(i(!0),t.update(()=>{const h=ze(u);h&&j4(h)&&h.__autoOpenEditor&&h.clearAutoOpenEditor()}))},[t,n.getKey()]);const o=E.useCallback(()=>{t.update(()=>{const u=n.getLatest(),l=u.getNextSibling(),h=u.getPreviousSibling();if(u.remove(),l){l.selectStart();return}h&&h.selectEnd()})},[t,n]),a=E.useCallback(u=>{t.update(()=>{n.updateMarkdown(u)}),i(!1)},[t,n]);return r?O.jsx("div",{className:e,children:O.jsx(Oq,{markdown:s,onClose:()=>i(!1),onSave:a})}):O.jsxs("div",{className:e,style:{margin:"8px 0",position:"relative"},children:[O.jsxs("div",{style:{bottom:8,display:"flex",gap:4,position:"absolute",right:8,zIndex:10},children:[O.jsx("button",{onClick:()=>i(!0),style:{background:"rgba(0,0,0,0.5)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:12,padding:"4px 8px"},type:"button",children:"编辑"}),O.jsx("button",{onClick:o,style:{background:"rgba(255,77,79,0.7)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:12,padding:"4px 8px"},type:"button",children:"删除"})]}),O.jsx("div",{style:{border:"1px solid #f0f0f0",borderRadius:8,height:350},children:O.jsx(Wx,{markdown:s})})]})}function xU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((s,o)=>O.jsx(zq,{className:e,editor:o,node:s}),[e]),i=E.useRef(!1);return i.current||(i.current=!0,n.registerPlugin(Fq,{decorator:r,theme:t})),null}const Rq=lt("INSERT_MATH_COMMAND"),Kx=lt("UPDATE_MATH_COMMAND"),Nl=lt("SELECT_MATH_SIDE_COMMAND");function Pq(e){return gt(e.registerCommand(Rq,t=>{const{code:n}=t;return e.update(()=>{const r=cu(n);_n([r]),qn(r.getParentOrThrow())&&xs(r,hn).selectEnd()}),!0},Fn),e.registerCommand(Kx,t=>{const{code:n,key:r}=t;return e.update(()=>{const i=ze(r);i&&(i.updateCode(n),i.selectNext())}),!0},Fn),e.registerCommand(Nl,t=>{const{key:n,prev:r}=t;return e.update(()=>{const i=ze(n);i&&(r?i.selectPrevious():i.selectNext())}),!0},Fn))}function Bq(e){const t=e.trim();return t?!!(/\\[A-Za-z]/.test(t)||/[\d!()*+,/<=>^_{|}-]/.test(t)||/^[A-Za-z]$/.test(t)):!1}rn();Bt();Ot();var wo;const $q=(wo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","math"),t.registerNodes([xa,Fi]),n!=null&&n.theme&&t.registerThemes(n==null?void 0:n.theme),this.registerDecorator(t,xa.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null),this.registerDecorator(t,Fi.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Pq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t==null||t.registerMarkdownShortCut({regExp:/\$([^\s$](?:[^$]*[^\s$])?)\$\s?$/,replace:(n,r)=>{const[,i]=r;if(!Bq(i))return;const s=cu(i);this.logger.debug("Math node inserted:",s),n.insertBefore(s),n.setTextContent(""),n.select()},trigger:"$",type:"text-match"}),t==null||t.registerMarkdownShortCut({regExp:/^(\$\$)$/,replace:(n,r,i,s)=>{const o=wc();s||n.getNextSibling()?n.replace(o):n.insertBefore(o);const a=yn();a.add(o.getKey()),je(a)},trigger:"enter",type:"element"}),t==null||t.registerMarkdownWriter(xa.getType(),(n,r)=>(n.appendLine(r.getTextContent()),!0)),t==null||t.registerMarkdownWriter(Fi.getType(),(n,r)=>(n.appendLine(r.getTextContent()),!0)),t==null||t.registerMarkdownReader("inlineMath",n=>ke.createElementNode("math",{code:n.value,version:1})),t==null||t.registerMarkdownReader("math",n=>ke.createElementNode("mathBlock",{code:n.value,version:1}))}},wo.pluginName="MathPlugin",wo),Vx=E.memo(({children:e,isBlockMode:t,mathDOM:n,onFocus:r,prev:i})=>{const s=E.useRef(null),[o,a]=E.useState(void 0),u=E.useRef(void 0),l=E.useCallback(m=>{const y=typeof m=="number"?Math.round(m):void 0;u.current!==y&&(u.current=y,a(y))},[]),h=E.useCallback(()=>{if(!t){l(void 0);return}const m=n==null?void 0:n.closest('[contenteditable="true"]');m&&l(m.getBoundingClientRect().width)},[t,n,l]),d=E.useCallback(()=>Zc({callback:()=>{!s.current||!n||(r==null||r(),h())},floating:s.current,placement:t?"bottom-start":"bottom",reference:n}),[t,n,r,h]),g=E.useCallback(()=>{n&&d()},[n,d]);return E.useEffect(()=>{if(!n||!s.current)return;const m=s.current,y=new ResizeObserver(()=>{h()});y.observe(m);let w=null;return t&&(w=n.closest('[contenteditable="true"]'),w&&y.observe(w)),d(),window.addEventListener("resize",d),()=>{y.disconnect(),window.removeEventListener("resize",d)}},[n,i,t,d]),E.useEffect(()=>{n||!s.current||tu(s.current)},[n]),O.jsx(au,{arrow:!1,content:O.jsx(It,{className:zi.mathEditor,"data-math-editor-container":!0,style:o?{width:o}:void 0,children:e}),open:!!n,placement:t?"bottomLeft":"bottom",styles:{content:{borderRadius:"6px",padding:0}},children:O.jsx("span",{className:zi.mathEditorAnchor,onClick:g,ref:s})})});Vx.displayName="MathEditorContainer";Hb();const Gx=E.memo(({focusRef:e,mathNode:t,onArrowLeft:n,onArrowRight:r,onCancel:i,onDelete:s,onSubmit:o,onValidationChange:a,onValueChange:u,value:l})=>{const h=nr(),d=E.useRef(null),[g,m]=E.useState("");E.useEffect(()=>{e==null||e(d.current)},[e]),E.useEffect(()=>{if(!t)return;if(!l.trim()){m(""),a==null||a(!0);return}const w=setTimeout(()=>{try{tw(l,{displayMode:!0,throwOnError:!0}),m(""),a==null||a(!0)}catch(_){m(_ instanceof Error?_.message:"LaTeX Parse Error"),a==null||a(!1)}},50);return()=>clearTimeout(w)},[l,t,a]);const y=E.useCallback(w=>{if(t){if(ob(w,qb)&&w.key==="Enter"){w.preventDefault(),o();return}if(w.key==="Escape"){w.preventDefault(),i();return}if(w.key==="Backspace"&&!l.trim()){w.preventDefault(),s();return}w.key==="ArrowLeft"&&w.currentTarget.selectionStart===0&&(w.preventDefault(),n()),w.key==="ArrowRight"&&w.currentTarget.selectionStart===w.currentTarget.value.length&&(w.preventDefault(),r())}},[t,o,i,s,n,r,l]);return O.jsxs(O.Fragment,{children:[O.jsx(nw,{autoFocus:!0,autoSize:{maxRows:6,minRows:1},className:zi.mathEditorTextArea,onChange:w=>{u(w.target.value)},onKeyDown:y,placeholder:`${h("math.placeholder")}...`,ref:d,resize:!1,value:l,variant:"borderless"}),g&&O.jsx(It,{className:zi.mathEditorFooter,horizontal:!0,paddingBlock:4,paddingInline:12,width:"100%",children:O.jsx(qr,{fontSize:13,type:"danger",children:g})}),O.jsx(It,{className:zi.mathEditorFooter,horizontal:!0,justify:"flex-end",padding:4,width:"100%",children:O.jsxs(Pl,{onClick:w=>{w.preventDefault(),o()},size:"small",type:"text",variant:"filled",children:[h("confirm"),O.jsx(Eb,{compact:!0,keys:"mod+enter",variant:"borderless"})]})})]})});Gx.displayName="MathEditorContent";kr();const jq=E.memo(({renderComp:e})=>{const t=E.useRef(null),n=E.useRef(!1),[r,i]=E.useState(null),[s,o]=E.useState(""),a=E.useRef(""),u=E.useRef(!0),[l,h]=E.useState(null),[d,g]=E.useState(!1),[m,y]=E.useState(!1),[w,_]=E.useState(!1),[v]=_t();E.useEffect(()=>{if(!r||!u.current)return;const z=setTimeout(()=>{const V=v.getLexicalEditor();if(V&&!n.current){const X=r.code;if(s&&X&&X===s)return;n.current=!0,V.update(()=>{if(V.getEditorState().read(()=>V.getElementByKey(r.getKey()))){const ee=r.getWritable();ee.__code=s}}),setTimeout(()=>{n.current=!1},50)}},50);return()=>clearTimeout(z)},[s,r,v]);const M=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();if(z){const V=u.current?s:a.current;z.dispatchCommand(Kx,{code:V,key:r.getKey()})}},[v,r,s]),T=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&(z.dispatchCommand(Nl,{key:r.getKey(),prev:!1}),z.focus())},[r,v]),D=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&z.update(()=>{r.remove()})},[r,v]),R=E.useCallback(()=>{r&&v.dispatchCommand(Nl,{key:r.getKey(),prev:!0})},[r,v]),F=E.useCallback(()=>{r&&v.dispatchCommand(Nl,{key:r.getKey(),prev:!1})},[r,v]),j=E.useCallback(()=>{var z,V,X,ee;(z=t.current)==null||z.focus(),d&&((ee=(X=(V=t.current)==null?void 0:V.resizableTextArea)==null?void 0:X.textArea)==null||ee.setSelectionRange(0,0))},[d]),K=E.useCallback(z=>{t.current=z},[]);br(z=>gt(z.registerUpdateListener(({prevEditorState:V})=>{if(n.current)return;const X=z.getEditorState().read(()=>{const ee=ce();if(!Ln(ee))return!1;const Q=ee.getNodes()[0];if(!x3(Q))return!1;const ae=r&&r.getKey()===Q.getKey();return i(Q),!ae&&Q.code!==s&&(o(Q.code),a.current=Q.code,u.current=!0),h(z.getElementByKey(Q.getKey())),y(Q instanceof Fi),Q});if(X){const ee=V.read(()=>{const Q=V._selection;return de(Q)?Q.anchor.key:!1});z.getEditorState().read(()=>{const Q=ee?ze(ee):null;Q&&f9(Q,X)<0?g(!0):g(!1)}),_(!0)}X||(i(null),h(null),o(""),a.current="",u.current=!0,y(!1),_(!1))})),[r,s]);const U=O.jsx(Gx,{focusRef:K,mathNode:r,onArrowLeft:R,onArrowRight:F,onCancel:T,onDelete:D,onSubmit:M,onValidationChange:z=>{u.current=z,z&&(a.current=s)},onValueChange:o,value:s});return E.useEffect(()=>{if(!w)return;const z=V=>{const X=V.target;X&&(Array.from(document.querySelectorAll("[data-math-editor-container]")).some(ee=>ee&&ee.contains(X))||T())};return document.addEventListener("mousedown",z),document.addEventListener("touchstart",z),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("touchstart",z)}},[w,T]),e?O.jsx(O.Fragment,{children:e({children:O.jsx("div",{"data-math-editor-container":!0,children:U}),open:w})}):O.jsx(Yc,{children:O.jsx(Vx,{isBlockMode:m,mathDOM:l,onFocus:j,prev:d,children:U})})}),qq=({mathBlock:e})=>{const t=nr(),n=O.jsx(qr,{as:"span",className:at("katex",zi.mathPlaceholder),fontSize:e?"1.2em":"1em",type:"secondary",children:t("math.placeholder")});return e?O.jsx(af,{padding:18,width:"100%",children:n}):n};Ot();const Hq=Qe("plugin","math"),Uq=({editor:e,node:t,className:n})=>{const r=E.useRef(null),[i,s,o]=zo(t.getKey()),[a,u]=E.useState(!1),l=t instanceof Fi;return E.useEffect(()=>{r.current&&t.code&&Yk.render(t.code,r.current,{displayMode:t instanceof Fi,throwOnError:!1})},[t.code]),E.useEffect(()=>{const h=e.getElementByKey(t.getKey());if(h){const d=setTimeout(()=>{a?(Ut(h,"editing"),ua(h,"selected")):i?(Ut(h,"selected"),ua(h,"editing")):(ua(h,"selected"),ua(h,"editing"))},10);return()=>clearTimeout(d)}},[i,a,e,t]),br(h=>h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const d=ce();if(!Ln(d)){u(!1);return}const g=d.getNodes()[0];if(!x3(g)){u(!1);return}g.getKey()===t.getKey()?u(!0):u(!1)})}),[t]),O.jsx("span",{className:n,onClick:E.useCallback(h=>{Hq.debug("📊 Math click event:",h.target===r.current),h.preventDefault(),h.stopPropagation(),i&&o(),s(!0),e.focus()},[o,e,i,s]),ref:r,children:t.code?t.code:O.jsx(qq,{mathBlock:l})})},Wq=({className:e,renderComp:t,theme:n})=>{const[r]=_t();return E.useLayoutEffect(()=>{r.registerPlugin(Vi),r.registerPlugin($q,{decorator:(i,s)=>O.jsx(Uq,{className:e,editor:s,node:i}),theme:n||zi})},[r,e,n,zi]),O.jsx(jq,{renderComp:t})};Wq.displayName="ReactMathPlugin";var Gs=class Dl extends Wr{static getType(){return"meta2d"}static clone(t){return new Dl(t.__diagram,t.__svg,t.__key,t.__autoOpenEditor)}static importJSON(t){return new Dl(t.diagram,t.svg)}constructor(t="",n="",r,i=!1){super(r),this.__diagram=t,this.__svg=n,this.__autoOpenEditor=i}clearAutoOpenEditor(){const t=this.getWritable();t.__autoOpenEditor=!1}createDOM(t){const n=document.createElement("div");return Ut(n,t.theme.meta2d??"editor-meta2d"),n}decorate(t){var r;const n=(r=Hi(t))==null?void 0:r.getDecorator(Dl.getType());return n?typeof n=="function"?n(this,t):{queryDOM:n.queryDOM,render:n.render(this,t)}:null}exportJSON(){return{...super.exportJSON(),diagram:this.__diagram,svg:this.__svg}}getTextContent(){return`---meta2d---
|
|
1735
1735
|
${this.__diagram}
|
|
1736
1736
|
---/meta2d---
|
|
1737
|
-
`}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Xx(e="",t="",n){return Cn(new Gs(e,t,void 0,(n==null?void 0:n.autoOpenEditor)??!1))}function H4(e){return e instanceof Gs}const Kq=lt("INSERT_META2D_COMMAND");function Vq(e){return e.registerCommand(Kq,t=>(e.update(()=>{var n;_n([Xx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Cl,(t==null?void 0:t.svg)!==void 0&&t.svg.trim()!==""?t.svg:nc,{autoOpenEditor:(t==null?void 0:t.autoOpenEditor)??!0})])}),!0),Tt)}rn();Bt();const Gq=/^---meta2d---$/i,Xq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Jq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Yq=(vo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,t.registerNodes([Gs]),n!=null&&n.theme&&t.registerThemes(n.theme),this.registerDecorator(t,Gs.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Vq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:Gq,replace:n=>{const r=Xx(Cl,nc,{autoOpenEditor:!0});n.replace(r);const i=yn();i.add(r.getKey()),je(i)},trigger:"enter",type:"element"}),t.registerMarkdownWriter(Gs.getType(),(n,r)=>{const i=r;return n.appendLine("---meta2d---"),n.appendLine(i.__diagram||Cl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Jq(n).match(Xq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Cl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:xD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Zq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-CFDBvzS1.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Qq(e){return(await Zq()).generateSvgFromDiagram(e)}function eH(e){const t=e.trimStart();return t.startsWith("<svg")?t.replace(/^<svg\b/,'<svg style="max-width:100%;height:auto;display:block;margin:0 auto" '):e}function W4({color:e,label:t,onClick:n,title:r}){return O.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),n()},style:{alignItems:"center",background:"#fff",border:"1px solid #e5e5e5",borderRadius:6,color:e,cursor:"pointer",display:"inline-flex",height:28,justifyContent:"center",width:28},title:r,type:"button",children:t})}function tH({diagram:e,onDelete:t,onEdit:n,onSvgReady:r,svg:i}){const[s,o]=E.useState(!1),[a,u]=E.useState(null),[l,h]=E.useState(!1),[d,g]=E.useState(!1),m=E.useRef(null);return E.useEffect(()=>{u(null),g(!1)},[e]),E.useEffect(()=>{if(!e||d||s)return;if(i){m.current=e;return}let y=!0;const w=window.setTimeout(()=>{y&&(u("Preview timeout (still loading). Double-click to open editor."),g(!0),o(!1))},5e3);return o(!0),Qq(e).then(_=>{if(y){if(window.clearTimeout(w),_){m.current=e,r(_);return}u("Preview generation failed. Double-click to open editor."),g(!0)}}).finally(()=>{y&&o(!1)}),()=>{y=!1,window.clearTimeout(w)}},[e,d,r,i]),O.jsxs("div",{onDoubleClick:y=>{y.stopPropagation(),n()},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{background:"#fff",border:"1px solid #efefef",borderRadius:10,cursor:"pointer",minHeight:140,overflow:"hidden",padding:10,position:"relative"},children:[l&&!!i&&O.jsxs("div",{style:{display:"flex",gap:8,position:"absolute",right:10,top:10,zIndex:1},children:[O.jsx(W4,{color:"#1677ff",label:"✎",onClick:n,title:"Edit diagram"}),O.jsx(W4,{color:"#ff4d4f",label:"🗑",onClick:t,title:"Delete diagram"})]}),i?O.jsx("div",{style:{alignItems:"center",display:"flex",justifyContent:"center",maxHeight:400,overflow:"auto",width:"100%"},children:O.jsx("div",{dangerouslySetInnerHTML:{__html:eH(i)},style:{lineHeight:0,maxWidth:"100%",width:"100%"}})}):O.jsx("div",{style:{alignItems:"center",color:a?"#cf1322":"#999",display:"flex",justifyContent:"center",minHeight:120,textAlign:"center"},children:s?"Generating preview...":a||"Double-click to edit diagram"})]})}const nH=E.memo(tH),rH=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-uAUfkpbp.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function iH({className:e,editor:t,node:n}){const[r,i]=E.useState(!1),s=n.__diagram,o=n.__svg;E.useLayoutEffect(()=>{const l=n.getKey();let h=!1;t.getEditorState().read(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&(h=!0)}),h&&i(!0),h&&t.update(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&d.clearAutoOpenEditor()})},[t,n.getKey()]);const a=E.useCallback(()=>{t.update(()=>{const l=n.getLatest(),h=l.getNextSibling(),d=l.getPreviousSibling();if(l.remove(),h){h.selectStart();return}d&&d.selectEnd()})},[t,n]),u=E.useCallback((l,h)=>{t.update(()=>{n.updateDiagram(l,h)}),i(!1)},[t,n]);return O.jsxs("div",{className:e,style:{margin:0},children:[O.jsx(nH,{diagram:s,onDelete:a,onEdit:()=>i(!0),onSvgReady:E.useCallback(l=>{t.update(()=>{n.updateDiagram(n.__diagram,l)})},[t,n]),svg:o}),r&&O.jsx(E.Suspense,{fallback:null,children:O.jsx(rH,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function kU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(iH,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Yq,{decorator:r,theme:t})},[r,n,t]),null}const Jx=E.createContext(null),sH=({children:e,defaultVisible:t=!0})=>{const[n,r]=E.useState(t),i=E.useCallback(()=>r(o=>!o),[]),s=E.useMemo(()=>({setVisible:r,toggle:i,visible:n}),[i,n]);return O.jsx(Jx.Provider,{value:s,children:e})};sH.displayName="OutlineProvider";function Y1(){return E.useContext(Jx)}function wU(){const e=Y1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function oH(e){const t=Y1(),n=(e==null?void 0:e.visible)!==void 0&&(e==null?void 0:e.onVisibleChange)!==void 0;return E.useMemo(()=>n&&(e!=null&&e.onVisibleChange)?{ready:!0,toggle:()=>e.onVisibleChange(!e.visible),visible:e.visible}:t?{ready:!0,toggle:t.toggle,visible:t.visible}:{ready:!1},[e==null?void 0:e.onVisibleChange,e==null?void 0:e.visible,t,n])}kr();const vU=({editor:e,visible:t})=>{const n=Y1(),r=E.useMemo(()=>t!==void 0?t:(n==null?void 0:n.visible)??!0,[t,n==null?void 0:n.visible]),[i,s]=E.useState([]),o=E.useCallback(()=>{const u=[],l=Sn(),h=d=>{for(const g of d){if(_o(g)){const m=g.getTextContent().trim();m&&u.push({key:g.getKey(),level:parseInt(g.getTag()[1],10),text:m})}if(fn(g)){const m=g.getChildren();m.length>0&&h(m)}}};h(l.getChildren()),s(u)},[]);E.useEffect(()=>{const u=e.getLexicalEditor();let l=Fo;const h=d=>(l=d.registerUpdateListener(({editorState:g})=>{g.read(o)}),d.getEditorState().read(o),l);return u?h(u):(e.on("initialized",h),()=>{l(),e.off("initialized",h)})},[e,o]);const a=E.useCallback(u=>{const l=e.getLexicalEditor();l&&(l.update(()=>{const h=yn();h.add(u),je(h)}),requestAnimationFrame(()=>{const h=l.getElementByKey(u);h&&h.scrollIntoView({behavior:"smooth",block:"center"})}))},[e]);return!r||i.length===0?null:O.jsxs("div",{style:{borderLeft:"1px solid rgba(0, 0, 0, 0.08)",paddingLeft:12},children:[O.jsx("div",{style:{color:"rgba(0,0,0,0.45)",fontSize:12,fontWeight:600,marginBottom:8},children:"OUTLINE"}),i.map(u=>O.jsx("div",{onClick:()=>a(u.key),onMouseEnter:l=>{l.currentTarget.style.background="rgba(0,0,0,0.04)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},style:{borderRadius:4,color:"rgba(0,0,0,0.75)",cursor:"pointer",fontSize:13,lineHeight:"28px",overflow:"hidden",paddingLeft:(u.level-1)*16+8,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.text},u.key))]})},aH="Hide outline",uH="Show outline",lH="outline";function SU(e){const{collapseTitle:t=aH,expandTitle:n=uH,onVisibleChange:r,visible:i}=e??{},s=oH(i!==void 0&&r!==void 0?{onVisibleChange:r,visible:i}:void 0);return E.useMemo(()=>{if(!s.ready)return null;const{toggle:o,visible:a}=s;return{active:a,icon:a?zb:Ow,key:lH,label:a?t:n,onClick:o}},[t,n,s])}kr();function cH(e,t){const{domRows:n}=e;for(const[r,i]of n.entries())if(i)for(const[s,o]of i.entries()){if(!o)continue;const a=jr(o.elem);a!==null&&t(o,a,{x:s,y:r})}}function hH(e,t){const n=t.elem,r=e._config.theme;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode"),Ut(n,r.tableCellSelected)}function fH(e,t){const n=t.elem;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode");const r=e._config.theme;ua(n,r.tableCellSelected)}function dH(e,t,n){const r=new Set(n?n.getNodes():[]);cH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,hH(e,i)):(i.highlighted=!1,fH(e,i),o.getAttribute("style")||o.removeAttribute("style"))})}function K4(e){const t=e.getShape();return{columns:t.toX-t.fromX+1,rows:t.toY-t.fromY+1}}function pH(){const e=ce();if(de(e)&&!e.isCollapsed()||fi(e)&&!e.anchor.is(e.focus)||!de(e)&&!fi(e))return!1;const[t]=Cb(e.anchor);return t.__colSpan>1||t.__rowSpan>1}function mH(e){const t=e.getLastDescendant();Pt(t)?t.select():fn(t)?t.selectEnd():t!==null&&t.selectNext()}function V4(e){return e.getEditorState().read(()=>{const t=ce();if(de(t)||fi(t)){const[n]=Cb(t.anchor);if(hi(n))return n.getBackgroundColor()}return null})}const Yx=E.memo(({editor:e,tableCellNode:t,cellMerge:n,children:r})=>{const[i,s]=E.useState(t),[o,a]=E.useState({columns:1,rows:1}),[u,l]=E.useState(!1),[h,d]=E.useState(!1),[,g]=E.useState(()=>V4(e)||""),m=nr();E.useEffect(()=>e.registerMutationListener(nf,K=>{K.get(i.getKey())==="updated"&&(e.getEditorState().read(()=>{s(i.getLatest())}),g(V4(e)||""))},{skipInitialization:!0}),[e,i]),E.useEffect(()=>{e.getEditorState().read(()=>{const K=ce();if(fi(K)){const U=K4(K);a(K4(K)),l(U.columns>1||U.rows>1)}d(pH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Ia(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=rf(U);z!==null&&z.$clearHighlight(),K.markDirty(),s(i.getLatest())}je(null)})},[e,i]),w=()=>{e.update(()=>{const K=ce();if(!fi(K))return;const U=Lk(K.getNodes().filter(hi));U&&mH(U)})},_=()=>{e.update(()=>{Fk()})},v=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.rows;U++)wb(K)})},[e,o.rows]),M=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.columns;U++)vb(K)})},[e,o.columns]),T=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Mk()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Cd(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.ROW;for(let ee=0;ee<z[U].length;ee++){const Q=z[U][ee];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.COLUMN;for(const ee of z){const Q=ee[U];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.COLUMN)))}y()})},[e,i,y]);return O.jsx(Ed,{menu:{items:E.useMemo(()=>[{icon:$w,key:"table-insert-row-above",label:m("table.insertRowAbove",{count:o.rows}),onClick:()=>v(!1)},{icon:Rw,key:"table-insert-row-below",label:m("table.insertRowBelow",{count:o.rows}),onClick:()=>v(!0)},{type:"divider"},{icon:bw,key:"table-insert-column-before",label:m("table.insertColumnLeft",{count:o.columns}),onClick:()=>M(!1)},{icon:zb,key:"table-insert-column-after",label:m("table.insertColumnRight",{count:o.columns}),onClick:()=>M(!0)},{type:"divider"},{icon:Uw,key:"table-delete-columns",label:m("table.deleteColumn"),onClick:()=>R()},{icon:Kw,key:"table-delete-rows",label:m("table.deleteRow"),onClick:()=>T()},{type:"divider"},{icon:Iw,key:"table-delete",label:m("table.delete"),onClick:()=>D()}],[n,u,h,o.rows,o.columns,i.__headerState,w,_,v,M,R,T,D,F,j])},children:r})});Yx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
|
|
1737
|
+
`}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Xx(e="",t="",n){return Cn(new Gs(e,t,void 0,(n==null?void 0:n.autoOpenEditor)??!1))}function H4(e){return e instanceof Gs}const Kq=lt("INSERT_META2D_COMMAND");function Vq(e){return e.registerCommand(Kq,t=>(e.update(()=>{var n;_n([Xx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Cl,(t==null?void 0:t.svg)!==void 0&&t.svg.trim()!==""?t.svg:nc,{autoOpenEditor:(t==null?void 0:t.autoOpenEditor)??!0})])}),!0),Tt)}rn();Bt();const Gq=/^---meta2d---$/i,Xq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Jq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Yq=(vo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,t.registerNodes([Gs]),n!=null&&n.theme&&t.registerThemes(n.theme),this.registerDecorator(t,Gs.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Vq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:Gq,replace:n=>{const r=Xx(Cl,nc,{autoOpenEditor:!0});n.replace(r);const i=yn();i.add(r.getKey()),je(i)},trigger:"enter",type:"element"}),t.registerMarkdownWriter(Gs.getType(),(n,r)=>{const i=r;return n.appendLine("---meta2d---"),n.appendLine(i.__diagram||Cl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Jq(n).match(Xq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Cl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:xD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Zq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-BDjANcdr.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Qq(e){return(await Zq()).generateSvgFromDiagram(e)}function eH(e){const t=e.trimStart();return t.startsWith("<svg")?t.replace(/^<svg\b/,'<svg style="max-width:100%;height:auto;display:block;margin:0 auto" '):e}function W4({color:e,label:t,onClick:n,title:r}){return O.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),n()},style:{alignItems:"center",background:"#fff",border:"1px solid #e5e5e5",borderRadius:6,color:e,cursor:"pointer",display:"inline-flex",height:28,justifyContent:"center",width:28},title:r,type:"button",children:t})}function tH({diagram:e,onDelete:t,onEdit:n,onSvgReady:r,svg:i}){const[s,o]=E.useState(!1),[a,u]=E.useState(null),[l,h]=E.useState(!1),[d,g]=E.useState(!1),m=E.useRef(null);return E.useEffect(()=>{u(null),g(!1)},[e]),E.useEffect(()=>{if(!e||d||s)return;if(i){m.current=e;return}let y=!0;const w=window.setTimeout(()=>{y&&(u("Preview timeout (still loading). Double-click to open editor."),g(!0),o(!1))},5e3);return o(!0),Qq(e).then(_=>{if(y){if(window.clearTimeout(w),_){m.current=e,r(_);return}u("Preview generation failed. Double-click to open editor."),g(!0)}}).finally(()=>{y&&o(!1)}),()=>{y=!1,window.clearTimeout(w)}},[e,d,r,i]),O.jsxs("div",{onDoubleClick:y=>{y.stopPropagation(),n()},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{background:"#fff",border:"1px solid #efefef",borderRadius:10,cursor:"pointer",minHeight:140,overflow:"hidden",padding:10,position:"relative"},children:[l&&!!i&&O.jsxs("div",{style:{display:"flex",gap:8,position:"absolute",right:10,top:10,zIndex:1},children:[O.jsx(W4,{color:"#1677ff",label:"✎",onClick:n,title:"Edit diagram"}),O.jsx(W4,{color:"#ff4d4f",label:"🗑",onClick:t,title:"Delete diagram"})]}),i?O.jsx("div",{style:{alignItems:"center",display:"flex",justifyContent:"center",maxHeight:400,overflow:"auto",width:"100%"},children:O.jsx("div",{dangerouslySetInnerHTML:{__html:eH(i)},style:{lineHeight:0,maxWidth:"100%",width:"100%"}})}):O.jsx("div",{style:{alignItems:"center",color:a?"#cf1322":"#999",display:"flex",justifyContent:"center",minHeight:120,textAlign:"center"},children:s?"Generating preview...":a||"Double-click to edit diagram"})]})}const nH=E.memo(tH),rH=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-CyddeNUo.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function iH({className:e,editor:t,node:n}){const[r,i]=E.useState(!1),s=n.__diagram,o=n.__svg;E.useLayoutEffect(()=>{const l=n.getKey();let h=!1;t.getEditorState().read(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&(h=!0)}),h&&i(!0),h&&t.update(()=>{const d=ze(l);d&&H4(d)&&d.__autoOpenEditor&&d.clearAutoOpenEditor()})},[t,n.getKey()]);const a=E.useCallback(()=>{t.update(()=>{const l=n.getLatest(),h=l.getNextSibling(),d=l.getPreviousSibling();if(l.remove(),h){h.selectStart();return}d&&d.selectEnd()})},[t,n]),u=E.useCallback((l,h)=>{t.update(()=>{n.updateDiagram(l,h)}),i(!1)},[t,n]);return O.jsxs("div",{className:e,style:{margin:0},children:[O.jsx(nH,{diagram:s,onDelete:a,onEdit:()=>i(!0),onSvgReady:E.useCallback(l=>{t.update(()=>{n.updateDiagram(n.__diagram,l)})},[t,n]),svg:o}),r&&O.jsx(E.Suspense,{fallback:null,children:O.jsx(rH,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function kU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(iH,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Yq,{decorator:r,theme:t})},[r,n,t]),null}const Jx=E.createContext(null),sH=({children:e,defaultVisible:t=!0})=>{const[n,r]=E.useState(t),i=E.useCallback(()=>r(o=>!o),[]),s=E.useMemo(()=>({setVisible:r,toggle:i,visible:n}),[i,n]);return O.jsx(Jx.Provider,{value:s,children:e})};sH.displayName="OutlineProvider";function Y1(){return E.useContext(Jx)}function wU(){const e=Y1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function oH(e){const t=Y1(),n=(e==null?void 0:e.visible)!==void 0&&(e==null?void 0:e.onVisibleChange)!==void 0;return E.useMemo(()=>n&&(e!=null&&e.onVisibleChange)?{ready:!0,toggle:()=>e.onVisibleChange(!e.visible),visible:e.visible}:t?{ready:!0,toggle:t.toggle,visible:t.visible}:{ready:!1},[e==null?void 0:e.onVisibleChange,e==null?void 0:e.visible,t,n])}kr();const vU=({editor:e,visible:t})=>{const n=Y1(),r=E.useMemo(()=>t!==void 0?t:(n==null?void 0:n.visible)??!0,[t,n==null?void 0:n.visible]),[i,s]=E.useState([]),o=E.useCallback(()=>{const u=[],l=Sn(),h=d=>{for(const g of d){if(_o(g)){const m=g.getTextContent().trim();m&&u.push({key:g.getKey(),level:parseInt(g.getTag()[1],10),text:m})}if(fn(g)){const m=g.getChildren();m.length>0&&h(m)}}};h(l.getChildren()),s(u)},[]);E.useEffect(()=>{const u=e.getLexicalEditor();let l=Fo;const h=d=>(l=d.registerUpdateListener(({editorState:g})=>{g.read(o)}),d.getEditorState().read(o),l);return u?h(u):(e.on("initialized",h),()=>{l(),e.off("initialized",h)})},[e,o]);const a=E.useCallback(u=>{const l=e.getLexicalEditor();l&&(l.update(()=>{const h=yn();h.add(u),je(h)}),requestAnimationFrame(()=>{const h=l.getElementByKey(u);h&&h.scrollIntoView({behavior:"smooth",block:"center"})}))},[e]);return!r||i.length===0?null:O.jsxs("div",{style:{borderLeft:"1px solid rgba(0, 0, 0, 0.08)",paddingLeft:12},children:[O.jsx("div",{style:{color:"rgba(0,0,0,0.45)",fontSize:12,fontWeight:600,marginBottom:8},children:"OUTLINE"}),i.map(u=>O.jsx("div",{onClick:()=>a(u.key),onMouseEnter:l=>{l.currentTarget.style.background="rgba(0,0,0,0.04)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},style:{borderRadius:4,color:"rgba(0,0,0,0.75)",cursor:"pointer",fontSize:13,lineHeight:"28px",overflow:"hidden",paddingLeft:(u.level-1)*16+8,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.text},u.key))]})},aH="Hide outline",uH="Show outline",lH="outline";function SU(e){const{collapseTitle:t=aH,expandTitle:n=uH,onVisibleChange:r,visible:i}=e??{},s=oH(i!==void 0&&r!==void 0?{onVisibleChange:r,visible:i}:void 0);return E.useMemo(()=>{if(!s.ready)return null;const{toggle:o,visible:a}=s;return{active:a,icon:a?zb:Ow,key:lH,label:a?t:n,onClick:o}},[t,n,s])}kr();function cH(e,t){const{domRows:n}=e;for(const[r,i]of n.entries())if(i)for(const[s,o]of i.entries()){if(!o)continue;const a=jr(o.elem);a!==null&&t(o,a,{x:s,y:r})}}function hH(e,t){const n=t.elem,r=e._config.theme;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode"),Ut(n,r.tableCellSelected)}function fH(e,t){const n=t.elem;xc(hi(jr(n)),"Expected to find LexicalNode from Table Cell DOMNode");const r=e._config.theme;ua(n,r.tableCellSelected)}function dH(e,t,n){const r=new Set(n?n.getNodes():[]);cH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,hH(e,i)):(i.highlighted=!1,fH(e,i),o.getAttribute("style")||o.removeAttribute("style"))})}function K4(e){const t=e.getShape();return{columns:t.toX-t.fromX+1,rows:t.toY-t.fromY+1}}function pH(){const e=ce();if(de(e)&&!e.isCollapsed()||fi(e)&&!e.anchor.is(e.focus)||!de(e)&&!fi(e))return!1;const[t]=Cb(e.anchor);return t.__colSpan>1||t.__rowSpan>1}function mH(e){const t=e.getLastDescendant();Pt(t)?t.select():fn(t)?t.selectEnd():t!==null&&t.selectNext()}function V4(e){return e.getEditorState().read(()=>{const t=ce();if(de(t)||fi(t)){const[n]=Cb(t.anchor);if(hi(n))return n.getBackgroundColor()}return null})}const Yx=E.memo(({editor:e,tableCellNode:t,cellMerge:n,children:r})=>{const[i,s]=E.useState(t),[o,a]=E.useState({columns:1,rows:1}),[u,l]=E.useState(!1),[h,d]=E.useState(!1),[,g]=E.useState(()=>V4(e)||""),m=nr();E.useEffect(()=>e.registerMutationListener(nf,K=>{K.get(i.getKey())==="updated"&&(e.getEditorState().read(()=>{s(i.getLatest())}),g(V4(e)||""))},{skipInitialization:!0}),[e,i]),E.useEffect(()=>{e.getEditorState().read(()=>{const K=ce();if(fi(K)){const U=K4(K);a(K4(K)),l(U.columns>1||U.rows>1)}d(pH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Ia(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=rf(U);z!==null&&z.$clearHighlight(),K.markDirty(),s(i.getLatest())}je(null)})},[e,i]),w=()=>{e.update(()=>{const K=ce();if(!fi(K))return;const U=Lk(K.getNodes().filter(hi));U&&mH(U)})},_=()=>{e.update(()=>{Fk()})},v=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.rows;U++)wb(K)})},[e,o.rows]),M=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.columns;U++)vb(K)})},[e,o.columns]),T=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Mk()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Cd(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.ROW;for(let ee=0;ee<z[U].length;ee++){const Q=z[U][ee];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.COLUMN;for(const ee of z){const Q=ee[U];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.COLUMN)))}y()})},[e,i,y]);return O.jsx(Ed,{menu:{items:E.useMemo(()=>[{icon:$w,key:"table-insert-row-above",label:m("table.insertRowAbove",{count:o.rows}),onClick:()=>v(!1)},{icon:Rw,key:"table-insert-row-below",label:m("table.insertRowBelow",{count:o.rows}),onClick:()=>v(!0)},{type:"divider"},{icon:bw,key:"table-insert-column-before",label:m("table.insertColumnLeft",{count:o.columns}),onClick:()=>M(!1)},{icon:zb,key:"table-insert-column-after",label:m("table.insertColumnRight",{count:o.columns}),onClick:()=>M(!0)},{type:"divider"},{icon:Uw,key:"table-delete-columns",label:m("table.deleteColumn"),onClick:()=>R()},{icon:Kw,key:"table-delete-rows",label:m("table.deleteRow"),onClick:()=>T()},{type:"divider"},{icon:Iw,key:"table-delete",label:m("table.delete"),onClick:()=>D()}],[n,u,h,o.rows,o.columns,i.__headerState,w,_,v,M,R,T,D,F,j])},children:r})});Yx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
|
|
1738
1738
|
transform: translateX(2px);
|
|
1739
1739
|
`,root:e`
|
|
1740
1740
|
will-change: transform;
|
package/dist/web/index.html
CHANGED
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
opacity: 0.65;
|
|
28
28
|
}
|
|
29
29
|
</style>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-CINfyH_g.js"></script>
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BVS1XoFi.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/assets/motion-BAXVQJfN.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/ui-CEFkTVnG.js">
|
|
34
34
|
<link rel="modulepreload" crossorigin href="/assets/diagram-BF8g9yg4.js">
|
|
35
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
35
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DCgILSIv.css">
|
|
36
36
|
</head>
|
|
37
37
|
<body>
|
|
38
38
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgbg/mdocs",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.25",
|
|
4
4
|
"description": "A Markdown knowledge base for small teams",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,25 @@
|
|
|
14
14
|
"README.md",
|
|
15
15
|
"LICENSE"
|
|
16
16
|
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"skills:build": "node ./scripts/build-agent-skills.mjs",
|
|
19
|
+
"predev": "pnpm skills:build",
|
|
20
|
+
"prepack": "pnpm skills:build && pnpm build",
|
|
21
|
+
"dev:server": "tsx watch src/server/main.ts",
|
|
22
|
+
"dev:web": "vite",
|
|
23
|
+
"dev:web:fresh": "vite --force",
|
|
24
|
+
"dev": "pnpm dev:server & pnpm dev:web",
|
|
25
|
+
"dev:demo": "VITE_DEMO_MODE=true vite",
|
|
26
|
+
"build:web": "vite build",
|
|
27
|
+
"build:gh-pages": "VITE_DEMO_MODE=true VITE_BASE_PATH=/mdocs/ vite build",
|
|
28
|
+
"build:server": "tsc -p tsconfig.server.json",
|
|
29
|
+
"build": "pnpm build:web && pnpm build:server",
|
|
30
|
+
"start": "node dist/server/main.js",
|
|
31
|
+
"mdocs": "tsx src/server/cli/main.ts",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.web.json --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest"
|
|
35
|
+
},
|
|
17
36
|
"dependencies": {
|
|
18
37
|
"@codemirror/commands": "^6.10.3",
|
|
19
38
|
"@codemirror/language": "^6.12.3",
|
|
@@ -23,7 +42,7 @@
|
|
|
23
42
|
"@earendil-works/pi-agent-core": "^0.82.1",
|
|
24
43
|
"@earendil-works/pi-ai": "^0.82.1",
|
|
25
44
|
"@lexical/rich-text": "0.42.0",
|
|
26
|
-
"@lobehub/editor": "npm:@fgbg/lobe-editor@1.0.0-fork.
|
|
45
|
+
"@lobehub/editor": "npm:@fgbg/lobe-editor@1.0.0-fork.23",
|
|
27
46
|
"@lobehub/ui": "^5.0.0",
|
|
28
47
|
"@node-rs/jieba": "^2.0.1",
|
|
29
48
|
"@shikijs/langs": "4.0.2",
|
|
@@ -51,6 +70,14 @@
|
|
|
51
70
|
"remark-math": "^6.0.0",
|
|
52
71
|
"zod": "^3.23.8"
|
|
53
72
|
},
|
|
73
|
+
"pnpm": {
|
|
74
|
+
"onlyBuiltDependencies": [
|
|
75
|
+
"@fgbg/lobe-editor",
|
|
76
|
+
"better-sqlite3",
|
|
77
|
+
"esbuild",
|
|
78
|
+
"node-llama-cpp"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
54
81
|
"devDependencies": {
|
|
55
82
|
"@types/better-sqlite3": "^7.6.11",
|
|
56
83
|
"@types/compression": "^1.8.1",
|
|
@@ -69,23 +96,5 @@
|
|
|
69
96
|
"typescript": "^5.6.2",
|
|
70
97
|
"vite": "^5.4.8",
|
|
71
98
|
"vitest": "2.1.9"
|
|
72
|
-
},
|
|
73
|
-
"scripts": {
|
|
74
|
-
"skills:build": "node ./scripts/build-agent-skills.mjs",
|
|
75
|
-
"predev": "pnpm skills:build",
|
|
76
|
-
"dev:server": "tsx watch src/server/main.ts",
|
|
77
|
-
"dev:web": "vite",
|
|
78
|
-
"dev:web:fresh": "vite --force",
|
|
79
|
-
"dev": "pnpm dev:server & pnpm dev:web",
|
|
80
|
-
"dev:demo": "VITE_DEMO_MODE=true vite",
|
|
81
|
-
"build:web": "vite build",
|
|
82
|
-
"build:gh-pages": "VITE_DEMO_MODE=true VITE_BASE_PATH=/mdocs/ vite build",
|
|
83
|
-
"build:server": "tsc -p tsconfig.server.json",
|
|
84
|
-
"build": "pnpm build:web && pnpm build:server",
|
|
85
|
-
"start": "node dist/server/main.js",
|
|
86
|
-
"mdocs": "tsx src/server/cli/main.ts",
|
|
87
|
-
"typecheck": "tsc -p tsconfig.server.json --noEmit && tsc -p tsconfig.web.json --noEmit",
|
|
88
|
-
"test": "vitest run",
|
|
89
|
-
"test:watch": "vitest"
|
|
90
99
|
}
|
|
91
|
-
}
|
|
100
|
+
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-BF8g9yg4.js","assets/ui-CEFkTVnG.js","assets/react-vendor-BVS1XoFi.js","assets/motion-BAXVQJfN.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as i,j as e,_ as ct,b as dt}from"./react-vendor-BVS1XoFi.js";import{o as ae,N as Ke,C as ut,aq as Xe,Y as ne,ar as qe,as as mt,q as Fe,at as Pe,au as pt,av as ft,aw as ht,ax as gt,ay as xt,az as yt,aA as Ue,aB as jt,aC as kt,aD as Nt}from"./index-3-Dt0Ns3.js";import{H as bt,S as vt,A as wt,a as Ct}from"./AgentSkillFormCard-BokYfssA.js";import{C as Ye}from"./check-CmDfmXpb.js";import{C as Ge}from"./copy-CeksexKY.js";import{P as St}from"./plus-Vt2TO_HW.js";import{ar as At,ah as _t}from"./ui-CEFkTVnG.js";import"./diagram-BF8g9yg4.js";import"./motion-BAXVQJfN.js";/**
|
|
3
|
-
* @license lucide-react v0.562.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const It=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Mt=ae("maximize-2",It);/**
|
|
8
|
-
* @license lucide-react v0.562.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const Et=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Rt=ae("minimize-2",Et);/**
|
|
13
|
-
* @license lucide-react v0.562.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const $t=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Tt=ae("zoom-in",$t);/**
|
|
18
|
-
* @license lucide-react v0.562.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const zt=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Dt=ae("zoom-out",zt);function je(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(je).join(""):typeof s=="object"&&"props"in s?je((n=s.props)==null?void 0:n.children):""}function qt(s){return s?/\blanguage-mermaid\b|\bmermaid\b/i.test(s):!1}function Ft(s){const n=Array.isArray(s)?s:[s];for(const a of n){if(a==null||typeof a!="object"||!("props"in a))continue;const c=a.props;if(!(!c||!qt(c.className)))return je(c.children).replace(/\n$/,"")}return null}const Pt=.4,Bt=4,se=.2;let xe=null;function Lt(){return xe||(xe=ct(()=>import("./diagram-BF8g9yg4.js").then(s=>s.z),__vite__mapDeps([0,1,2,3])).then(s=>{const n=s.default;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",fontFamily:"ui-sans-serif, system-ui, sans-serif"}),n})),xe}const Ot=32,W=new Map;function Be(s){return W.get(s)??null}function Wt(s,n){for(W.has(s)&&W.delete(s),W.set(s,n);W.size>Ot;){const a=W.keys().next().value;if(a==null)break;W.delete(a)}}function ye(s){return Math.min(Bt,Math.max(Pt,s))}function Ht(s){const[n,a]=i.useState(1),[c,b]=i.useState({x:0,y:0}),h=i.useRef(null),[A,y]=i.useState(!1);i.useEffect(()=>{const u=I=>{I.key==="Escape"&&s.onClose()};window.addEventListener("keydown",u);const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",u),document.body.style.overflow=m}},[s.onClose]);function _(u){u.button===0&&(u.currentTarget.setPointerCapture(u.pointerId),h.current={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,originX:c.x,originY:c.y},y(!0))}function C(u){const m=h.current;!m||m.pointerId!==u.pointerId||b({x:m.originX+(u.clientX-m.startX),y:m.originY+(u.clientY-m.startY)})}function E(u){const m=h.current;if(!(!m||m.pointerId!==u.pointerId)){h.current=null,y(!1);try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}}}function N(u){u.preventDefault();const m=u.deltaY>0?-se:se;a(I=>ye(Number((I+m).toFixed(2))))}return dt.createPortal(e.jsxs("div",{className:"mdocs-agent-mermaid-float",role:"dialog","aria-modal":"true","aria-label":"Mermaid 图预览",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-backdrop","aria-label":"关闭预览",onClick:s.onClose}),e.jsxs("div",{className:"mdocs-agent-mermaid-float-chrome",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-float-tools",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u-se).toFixed(2)))),title:"缩小","aria-label":"缩小",children:e.jsx(Dt,{size:16,"aria-hidden":!0})}),e.jsxs("span",{className:"mdocs-agent-mermaid-float-scale",children:[Math.round(n*100),"%"]}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>a(u=>ye(Number((u+se).toFixed(2)))),title:"放大","aria-label":"放大",children:e.jsx(Tt,{size:16,"aria-hidden":!0})}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>{a(1),b({x:0,y:0})},title:"重置",children:"重置"}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:s.onClose,title:"关闭","aria-label":"关闭",children:e.jsx(ne,{size:16,"aria-hidden":!0})})]}),e.jsx("div",{className:A?"mdocs-agent-mermaid-float-stage is-dragging":"mdocs-agent-mermaid-float-stage",onPointerDown:_,onPointerMove:C,onPointerUp:E,onPointerCancel:E,onWheel:N,children:e.jsx("div",{className:"mdocs-agent-mermaid-float-canvas",style:{transform:`translate(calc(-50% + ${c.x}px), calc(-50% + ${c.y}px)) scale(${n})`},dangerouslySetInnerHTML:{__html:s.svg}})}),e.jsx("p",{className:"mdocs-agent-mermaid-float-hint",children:"拖动平移 · 滚轮缩放 · Esc 关闭"})]})]}),document.body)}function Kt(s){const n=i.useId().replace(/:/g,""),[a,c]=i.useState("diagram"),[b,h]=i.useState(()=>Be(s.source.trim())),[A,y]=i.useState(null),[_,C]=i.useState(!1),[E,N]=i.useState(!1),u=i.useRef(null),m=s.source.trim(),I=i.useMemo(()=>m,[m]);i.useEffect(()=>()=>{u.current!=null&&window.clearTimeout(u.current)},[]),i.useEffect(()=>{if(a!=="diagram")return;if(!I){h(null),y(null);return}const j=Be(I);if(j){h(j),y(null);return}let M=!1;const P=window.setTimeout(()=>{(async()=>{try{const F=await Lt();if(M)return;const T=`mdocs-agent-mmd-${n}-${Date.now()}`,{svg:R}=await F.render(T,I);if(M)return;Wt(I,R),h(R),y(null)}catch(F){if(M)return;h(null),y(F instanceof Error?F.message:"Mermaid 渲染失败")}})()},200);return()=>{M=!0,window.clearTimeout(P)}},[a,I,n]);async function H(){!m||!await Xe(m)||(C(!0),u.current!=null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>C(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-mermaid",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toolbar",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toggle",role:"group","aria-label":"Mermaid 显示模式",children:[e.jsxs("button",{type:"button",className:a==="diagram"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("diagram"),"aria-pressed":a==="diagram",title:"图谱",children:[e.jsx(Ke,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"图谱"})]}),e.jsxs("button",{type:"button",className:a==="code"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("code"),"aria-pressed":a==="code",title:"代码",children:[e.jsx(ut,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"代码"})]})]}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy mdocs-agent-mermaid-copy",onClick:()=>void H(),"aria-label":_?"已复制":"复制代码",title:_?"已复制":"复制",children:_?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})})]}),a==="diagram"?e.jsx("div",{className:"mdocs-agent-mermaid-diagram",children:A?e.jsxs("div",{className:"mdocs-agent-mermaid-error",role:"alert",children:[e.jsx("p",{children:"无法渲染该图,可切换到代码查看源码。"}),e.jsx("pre",{children:A})]}):b?e.jsx("div",{className:"mdocs-agent-mermaid-svg mdocs-agent-mermaid-svg-hit",role:"button",tabIndex:0,onClick:()=>N(!0),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),N(!0))},title:"点击放大预览","aria-label":"点击放大预览 Mermaid 图",children:e.jsx("span",{className:"mdocs-agent-mermaid-svg-inner",dangerouslySetInnerHTML:{__html:b}})}):e.jsx("div",{className:"mdocs-agent-mermaid-loading",children:"渲染中…"})}):e.jsx("div",{className:"mdocs-agent-panel-md-pre-wrap mdocs-agent-mermaid-code",children:e.jsx("pre",{children:s.codeChildren??e.jsx("code",{className:"language-mermaid",children:m})})}),E&&b?e.jsx(Ht,{svg:b,onClose:()=>N(!1)}):null]})}const Xt=i.memo(Kt,(s,n)=>s.source===n.source);function ke(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(ke).join(""):typeof s=="object"&&"props"in s?ke((n=s.props)==null?void 0:n.children):""}function Ut(s){const[n,a]=i.useState(!1),c=i.useRef(null),b=i.useRef(null),h=ke(s.children).replace(/\n$/,"");i.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);async function A(y){var N,u,m;y.preventDefault(),y.stopPropagation();const C=(((m=(u=(N=b.current)==null?void 0:N.querySelector("pre"))==null?void 0:u.innerText)==null?void 0:m.replace(/\n$/,""))??"")||h;!C||!await Xe(C)||(a(!0),c.current!=null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!1),1500))}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",ref:b,children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:y=>void A(y),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Ye,{size:14,"aria-hidden":!0}):e.jsx(Ge,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:s.children})]})}function Yt(s){const n=Ft(s.children);return n!=null?e.jsx(Xt,{source:n,codeChildren:s.children}):e.jsx(Ut,{children:s.children})}const Gt={pre:({children:s})=>e.jsx(Yt,{children:s})},Le=i.memo(function(n){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(At,{remarkPlugins:[_t],components:Gt,children:n.children})})}),Vt=["如何发布文档?","草稿是什么?","如何创建工作空间?"];function Oe(s,n){return n.map((a,c)=>{const b=a.skillNames&&a.skillNames.length>0?a.skillNames:a.skillIds&&a.skillIds.length>0?a.skillIds:void 0;return{id:`h-${s}-${c}-${a.role}`,role:a.role,content:a.content,skillNames:b}})}function Jt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="text"?a[a.length-1]={type:"text",text:c.text+n}:a.push({type:"text",text:n}),a}function Zt(s,n){const a=s.slice(),c=a[a.length-1];return(c==null?void 0:c.type)==="thinking"?a[a.length-1]={type:"thinking",text:c.text+n}:a.push({type:"thinking",text:n}),a}function We(s){return s!=null&&s.length?s.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Qt(s){return!!(s!=null&&s.some(n=>n.type==="thinking"&&n.text.length>0))}function es(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return"";const a=new Date;return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function He(s){if(s>=1e3){const n=s/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(s)}function ts(s){const{block:n,onResolved:a}=s,[c,b]=i.useState(""),[h,A]=i.useState(!1),[y,_]=i.useState(1),C=i.useRef(!1),E=i.useRef(a);E.current=a;const N=n.status==="open",u=i.useRef(0);i.useEffect(()=>{if(!N)return;C.current=!1;const j=new Date(n.expiresAt).getTime(),M=Date.now(),P=Math.max(j-M,1);u.current=P,_(1);const F=()=>{const R=j-Date.now(),p=Math.max(0,Math.min(1,R/P));_(p),R<=0&&!C.current&&(C.current=!0,kt(n.requestId).catch(()=>{}).finally(()=>{E.current(n.requestId,"","expired")}))};F();const T=window.setInterval(F,100);return()=>window.clearInterval(T)},[N,n.expiresAt,n.requestId]);async function m(j){const M=j.trim();if(!(!M||h||!N)){A(!0);try{await Nt(n.requestId,M),a(n.requestId,M,"selected")}catch{a(n.requestId,M,"failed")}finally{A(!1)}}}async function I(){if(!(h||!N)){A(!0),C.current=!0;try{await Ue(n.requestId),a(n.requestId,"","cancelled")}catch{a(n.requestId,"","failed")}finally{A(!1)}}}const H=Math.max(0,Math.ceil(y*u.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(N?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),N?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),N?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(y*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${y})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,N?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(j=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:h,onClick:()=>void m(j),children:j},j))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:c,disabled:h,placeholder:"或输入自己的内容…",onChange:j=>b(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),m(c))}}),e.jsx("button",{type:"button",disabled:h||!c.trim(),onClick:()=>void m(c),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:h,onClick:()=>void I(),children:"取消"})})]}):null]})}function ss(s){const b=2*Math.PI*8.75,h=Math.min(100,Math.max(0,s.percent)),A=b*(1-h/100),y=h>=90?"danger":h>=70?"warn":"ok",_=`上下文 ${h}% · 已用 ${He(s.used)} / ${He(s.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+y,"data-tooltip":_,"aria-label":_,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:A,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function ns(s){var n;for(const a of s)if(!(a.role!=="assistant"||!((n=a.blocks)!=null&&n.length))){for(const c of a.blocks)if((c.type==="choice_card"||c.type==="skill_form_card")&&c.status==="open")return!0}return!1}const ps=i.forwardRef(function(n,a){const{open:c,onClose:b,visitorName:h,anchorStyle:A,fullscreen:y,onToggleFullscreen:_,domainId:C,documentId:E,documentTitle:N,documentPath:u,graphFileId:m,graphLabel:I,onOpenDocument:H,onTreeChanged:j,onDocumentOverwritten:M,onOpenCoding:P}=n,F=((h==null?void 0:h.trim().charAt(0))||"我").toUpperCase(),[T,R]=i.useState(!1),[p,U]=i.useState(null),[Ve,Y]=i.useState(null),[z,w]=i.useState([]),[re,G]=i.useState(null),[Ne,Je]=i.useState([]),[Ze,be]=i.useState(!1),[V,J]=i.useState(""),[X,ve]=i.useState([]),[we,ie]=i.useState(!1),[v,Z]=i.useState(!1),[Ce,B]=i.useState(null),[Q,Se]=i.useState(null),[oe,O]=i.useState(!1),[L,Ae]=i.useState(!1),Qe=i.useRef(null),ee=i.useRef(null),D=i.useRef(null),_e=i.useRef(0),K=i.useRef(!0),[et,le]=i.useState(!1),ce=i.useRef(z);ce.current=z;const Ie=!!(E!=null&&E.trim())&&!we,tt=(N==null?void 0:N.trim())||"当前文档",Me=(u==null?void 0:u.trim())||"",de=!!(m!=null&&m.trim())&&!we,st=(I==null?void 0:I.trim())||"当前图谱";i.useEffect(()=>{ie(!1)},[E,m]);function Ee(t){return _e.current+=1,`${t}-${_e.current}`}const Re=120;function $e(t){return t.scrollHeight-t.scrollTop-t.clientHeight}function te(){const t=ee.current;t&&(t.scrollTop=t.scrollHeight,le(!1))}function q(){K.current&&te()}function nt(){const t=ee.current;if(!t)return;const f=$e(t);K.current=f<=48,le(f>Re)}function at(){K.current=!0,te()}i.useLayoutEffect(()=>{q();const t=ee.current;t&&le($e(t)>Re)},[z]);async function rt(){be(!0);try{const t=await ht();Je(t.sessions),re||G(t.lastOpenedSessionId)}catch{}finally{be(!1)}}async function ue(){try{const t=await ft();Se(t)}catch{}}async function Te(){try{const t=await qe();U(t),Y(null)}catch(t){U(null),Y(t instanceof Error?t.message:String(t))}}i.useEffect(()=>{var f;if(!c){R(!1),(f=D.current)==null||f.abort(),D.current=null,Z(!1);return}let t=!1;return(async()=>{try{const o=await qe();t||(U(o),Y(null))}catch(o){t||(U(null),Y(o instanceof Error?o.message:String(o)))}})(),ue(),()=>{t=!0}},[c]),i.useEffect(()=>{if(!c)return;let t=!1;return(async()=>{try{const f=await mt();if(t)return;G(f.sessionId),w(o=>o.length>0?o:Oe(f.sessionId,f.messages))}catch{}})(),()=>{t=!0}},[c]),i.useEffect(()=>{!c||!T||rt()},[c,T]);function me(){if(!L){if(ns(ce.current)){O(!0);return}O(!1),b()}}async function it(){var o;if(L)return;Ae(!0);const t=ce.current,f=[];for(const S of t)if(!(S.role!=="assistant"||!S.blocks))for(const g of S.blocks)g.type==="choice_card"&&g.status==="open"&&f.push(Ue(g.requestId).catch(()=>{})),g.type==="skill_form_card"&&g.status==="open"&&f.push(jt(g.requestId).catch(()=>{}));await Promise.all(f),(o=D.current)==null||o.abort(),w(S=>S.map(g=>g.role!=="assistant"||!g.blocks?g:{...g,blocks:g.blocks.map(x=>x.type==="choice_card"&&x.status==="open"?{...x,status:"cancelled"}:x.type==="skill_form_card"&&x.status==="open"?{...x,status:"cancelled"}:x)})),O(!1),Ae(!1),b()}const pe=i.useRef(me);pe.current=me,i.useImperativeHandle(a,()=>({requestClose:()=>pe.current()}),[]),i.useEffect(()=>{if(!c){O(!1);return}const t=f=>{if(f.key==="Escape"){if(oe){L||O(!1);return}if(T){R(!1);return}pe.current()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,T,oe,L]);async function fe(t){var x;const f=t.trim();if(!f||v)return;if(!(p!=null&&p.enabled)){B((p==null?void 0:p.reason)==="missing_api_key"?"请先配置 API Key":(p==null?void 0:p.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(x=D.current)==null||x.abort();const o=new AbortController;D.current=o;const S={id:Ee("u"),role:"user",content:f,skillNames:X.length>0?[...X]:void 0},g=Ee("a");K.current=!0,w($=>[...$,S,{id:g,role:"assistant",content:""}]),J(""),Z(!0),B(null),R(!1),requestAnimationFrame(()=>{te(),requestAnimationFrame(te)});try{let $=!1;await yt(f,{skillNames:X.length>0?X:void 0,references:{domainId:(C==null?void 0:C.trim())||void 0,documentId:!de&&Ie?E.trim():void 0,graphFileId:de?m.trim():void 0},signal:o.signal,onEvent:l=>{l.type==="text_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Jt(r.blocks??[],l.text);return{...r,blocks:d,content:We(d)}})),requestAnimationFrame(()=>q())):l.type==="thinking_delta"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=Zt(r.blocks??[],l.text);return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="sources"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=(r.blocks??[]).slice(),ge=d[d.length-1];return(ge==null?void 0:ge.type)==="sources"?d[d.length-1]={type:"sources",items:l.items}:d.push({type:"sources",items:l.items}),{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_table"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_table",title:l.title,rows:l.rows}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="document_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"document_card",documentId:l.documentId,title:l.title,path:l.path,preview:l.preview}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="tool_notice"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"tool_notice",toolName:l.toolName,text:l.text}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"choice_card",requestId:l.requestId,title:l.title,options:l.options,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="choice_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="skill_form_card"?(w(k=>k.map(r=>{if(r.id!==g)return r;const d=[...r.blocks??[],{type:"skill_form_card",requestId:l.requestId,mode:l.mode,title:l.title,currentName:l.currentName,initialName:l.initialName,initialDescription:l.initialDescription,initialBody:l.initialBody,expiresAt:l.expiresAt,status:"open"}];return{...r,blocks:d}})),requestAnimationFrame(()=>q())):l.type==="skill_form_expired"?w(k=>k.map(r=>r.id!==g||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===l.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):l.type==="tree_changed"?j==null||j():l.type==="document_overwritten"?M==null||M({documentId:l.documentId,headCommitId:l.headCommitId}):l.type==="open_coding"?P==null||P({documentId:l.documentId,displayName:l.displayName}):l.type==="context_usage"?Se({percent:l.percent,used:l.used,limit:l.limit}):l.type==="error"&&($=!0,B(l.message))}}),!o.signal.aborted&&!$&&ve([])}catch($){if(o.signal.aborted)return;B($ instanceof Error?$.message:String($))}finally{D.current===o&&(D.current=null),Z(!1)}}async function ot(){var t;if(!v){(t=D.current)==null||t.abort(),B(null),R(!1),Z(!1);try{const f=await gt();G(f.sessionId),w([]),J(""),K.current=!0,ue()}catch(f){B(f instanceof Error?f.message:String(f))}}}async function lt(t){var f;if(!v){if(t===re){R(!1);return}(f=D.current)==null||f.abort(),B(null);try{const o=await xt(t);G(o.sessionId),w(Oe(o.sessionId,o.messages)),J(""),R(!1),K.current=!0,requestAnimationFrame(()=>q()),ue()}catch(o){B(o instanceof Error?o.message:String(o))}}}function ze(t){!t||!H||H(t)}if(!c)return null;const he=(p==null?void 0:p.reason)==="missing_api_key",De=Ve??(p&&!p.enabled&&!he?p.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:Qe,className:"mdocs-agent-panel"+(y?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":y?!0:void 0,style:y?void 0:A,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:Fe,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:v,onClick:()=>void ot(),children:e.jsx(St,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(T?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>R(t=>!t),children:e.jsx(bt,{size:16,strokeWidth:1.8})}),_?e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:y?"退出全屏":"全屏","aria-label":y?"退出全屏":"全屏",onClick:_,children:y?e.jsx(Rt,{size:16,strokeWidth:1.8}):e.jsx(Mt,{size:16,strokeWidth:1.8})}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:me,children:e.jsx(ne,{size:16,strokeWidth:1.8})})]})]}),T?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:()=>R(!1),children:"返回对话"})]}),Ze?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):Ne.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:Ne.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===re?" active":""),disabled:v,onClick:()=>void lt(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:es(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsxs("div",{className:"mdocs-agent-panel-scroll-wrap",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:ee,onScroll:nt,children:z.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:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),he?e.jsx(Pe,{onConfigured:Te}):De?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:De}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Vt.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void fe(t),disabled:v||!(p!=null&&p.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:z.map(t=>{var f;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:Fe,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[t.role==="user"&&t.skillNames&&t.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",t.skillNames.length]}):null,t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((o,S)=>{var g;return o.type==="thinking"?o.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:v&&t.id===((g=z[z.length-1])==null?void 0:g.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:o.text})]},`${t.id}-th-${S}`):null:o.type==="text"?o.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Le,{children:o.text})},`${t.id}-t-${S}`):null:o.type==="sources"?o.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:["已阅读 ",o.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:o.items.map(x=>e.jsx("li",{children:e.jsx("a",{href:x.url,target:"_blank",rel:"noreferrer",children:x.name})},x.id))})]})},`${t.id}-s-${S}`):o.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:o.text})},`${t.id}-n-${S}`):o.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(ts,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="choice_card"&&d.requestId===x?{...d,status:l,selected:l==="selected"?$:d.selected}:d)}))}})},`${t.id}-ch-${S}`):o.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(vt,{block:o,onResolved:(x,$,l)=>{w(k=>k.map(r=>r.id!==t.id||!r.blocks?r:{...r,blocks:r.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===x?{...d,status:$,submittedName:$==="submitted"?l:d.submittedName}:d)}))}})},`${t.id}-sf-${S}`):o.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:x=>{x.preventDefault(),x.stopPropagation(),ze(o.documentId)},children:["《",o.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[o.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:o.path}):null,o.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:o.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${S}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[o.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:o.rows.length===0?"无结果":`${o.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:o.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:o.rows.map(x=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>ze(x.documentId),children:x.title})}),e.jsx("td",{children:x.summary||"-"})]},x.documentId))})]})})]})},`${t.id}-d-${S}`)}),v&&t.id===((f=z[z.length-1])==null?void 0:f.id)&&!We(t.blocks)&&!Qt(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(Le,{children:t.content}):v?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:F}):null]},t.id)})})}),et?e.jsxs("button",{type:"button",className:"mdocs-chat-jump-bottom",onClick:at,title:"回到底部","aria-label":"回到底部",children:[e.jsx(wt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:"置底"})]}):null]}),Ce?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Ce}):null,he&&z.length>0?e.jsx(Pe,{onConfigured:Te}):null,e.jsx(Ct,{selectedNames:X,onChange:ve,disabled:v||!(p!=null&&p.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[de?e.jsxs("div",{className:"mdocs-agent-doc-ref mdocs-agent-graph-ref",children:[e.jsx(Ke,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:st}),e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:"图谱(只读)"})]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前图谱",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):Ie?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(pt,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:tt}),Me?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:Me}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:v,onClick:()=>ie(!0),children:e.jsx(ne,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:p!=null&&p.enabled?"把你的问题告诉我…":"请先配置 API Key",value:V,disabled:v||!(p!=null&&p.enabled),onChange:t=>J(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),fe(V))}}),Q?e.jsx(ss,{percent:Q.percent,used:Q.used,limit:Q.limit}):null,e.jsx("button",{type:"button",className:v?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:v?!1:!(p!=null&&p.enabled)||!V.trim(),onClick:()=>{var t;if(v){(t=D.current)==null||t.abort();return}fe(V)},title:v?"停止":"发送","aria-label":v?"停止":"发送",children:v?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),oe?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{L||O(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:L,onClick:()=>O(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:L,onClick:()=>void it(),children:L?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ps as AgentChatPanel};
|