@fgbg/mdocs 1.3.17 → 1.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +1 -1
  2. package/agent-skills/changelog/SKILL.md +14 -0
  3. package/agent-skills/index.json +1 -1
  4. package/agent-skills/usage-search/SKILL.md +14 -11
  5. package/dist/server/agent/Agent/tool-ui-effects.js +7 -1
  6. package/dist/server/agent/Agent/tool-ui-effects.js.map +1 -1
  7. package/dist/server/db/schema.js +30 -0
  8. package/dist/server/db/schema.js.map +1 -1
  9. package/dist/server/search/document-index-manager.js +33 -40
  10. package/dist/server/search/document-index-manager.js.map +1 -1
  11. package/dist/server/search/document-index-manager.test.js +194 -14
  12. package/dist/server/search/document-index-manager.test.js.map +1 -1
  13. package/dist/server/search/search.service.js +150 -42
  14. package/dist/server/search/search.service.js.map +1 -1
  15. package/dist/web/assets/{AgentChatPanel-C3c14Bo_.js → AgentChatPanel-DTj8Nz0Z.js} +2 -2
  16. package/dist/web/assets/{AgentSkillFormCard-BYUjSFe1.js → AgentSkillFormCard-DTgxybJh.js} +3 -3
  17. package/dist/web/assets/{AiWriteWorkbench-ze827qk7.js → AiWriteWorkbench-D2RzXzty.js} +3 -3
  18. package/dist/web/assets/{DiagramEditor-NtNY3sZL-Cie6NhLx.js → DiagramEditor-NtNY3sZL-B2Aeu79R.js} +1 -1
  19. package/dist/web/assets/{DocChrome-ixaNyUG9.js → DocChrome-4qmjr6wa.js} +1 -1
  20. package/dist/web/assets/{DocumentEditor-ByqPHijF.js → DocumentEditor-KEURMFDp.js} +1 -1
  21. package/dist/web/assets/{HtmlEditor-CpqCAPAr.js → HtmlEditor-jCKtKOCT.js} +1 -1
  22. package/dist/web/assets/{MergeView-D93ZHlTG.js → MergeView-eRcs-x1s.js} +2 -2
  23. package/dist/web/assets/{PlaygroundPage-CodSaeWS.js → PlaygroundPage-M7fqYn4Z.js} +1 -1
  24. package/dist/web/assets/SettingsPage-mS3g_vBq.js +1 -0
  25. package/dist/web/assets/{Toolbar-CSKpV4ua.js → Toolbar-F3tR5o7R.js} +1 -1
  26. package/dist/web/assets/{VisitorPickerModal-CqDA1S9F.js → VisitorPickerModal-CPjKg8ox.js} +1 -1
  27. package/dist/web/assets/{check-CN9m0reb.js → check-CQSGOkW1.js} +1 -1
  28. package/dist/web/assets/{copy-DFs3qk19.js → copy-BMAJ--_Y.js} +1 -1
  29. package/dist/web/assets/index-C8iEyMxp.css +1 -0
  30. package/dist/web/assets/{index-CUdIA5aE.js → index-DUu4Is5p.js} +50 -45
  31. package/dist/web/assets/{meta2dEngine-BD2XbzaV-SYn2XtSh.js → meta2dEngine-BD2XbzaV-BAZUiXoN.js} +1 -1
  32. package/dist/web/assets/{plus-QDhBbIRF.js → plus-C3uXIATM.js} +1 -1
  33. package/dist/web/assets/{react-Bf45libg.js → react-BXGUMaBS.js} +3 -3
  34. package/dist/web/index.html +2 -2
  35. package/package.json +1 -1
  36. package/dist/web/assets/SettingsPage-C8doYEbb.js +0 -6
  37. package/dist/web/assets/index-C0ujN3sT.css +0 -1
@@ -1 +1 @@
1
- import{T as D,W as _}from"./react-Bf45libg.js";import{r as p,a as A,b as u,c as z,i as N,M as O,C,f as k,d as q,e as L,g as V,h as j,s as B,j as G,k as H,l as J,m as W,n as K,o as Q}from"./meta2d-1-g23JOU.js";import"./react-vendor-BuABiQkA.js";import"./editor-CL03se2B.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./index-CUdIA5aE.js";import"./plus-QDhBbIRF.js";import"./check-CN9m0reb.js";import"./copy-DFs3qk19.js";let E=!1;function U(){E||(p(k()),A(q()),p(L()),u(V()),p(j()),p(B()),u(G()),z(),u(H()),u(J()),p(W()),u(K()),A(Q()),E=!0)}let F=!1;function Z(){F||(U(),F=!0)}function Y(e,r){try{e==null||e.destroy()}catch{}try{r.remove()}catch{}}function X(e){let r=e.font;Object.defineProperty(e,"font",{configurable:!0,get:()=>r,set:t=>{r=typeof t=="string"?t.replace(/(\d+(?:\.\d+)?(?:px|pt|pc|em|ex|%|in|cm|mm))\s*\/\s*(\d+(?:\.\d+)?)(?=\s|$)/,"$1/normal"):t,e.__ctx&&(e.__ctx.font=r)}})}function ee(e){typeof e.ellipse!="function"&&(e.ellipse=(r,t,n,a,s=0,o=0,m=Math.PI*2,i=!1)=>{var M;if(n<0||a<0)throw new Error("IndexSizeError: The radius provided is negative.");((M=e.__currentElement)==null?void 0:M.nodeName)!=="path"&&e.beginPath();const h=Math.PI*2,f=Math.abs(m-o),y=f>=h-1e-4||f===0,w=s*180/Math.PI,v=i?0:1,c=g=>{const l=Math.cos(g),S=Math.sin(g),b=Math.cos(s),x=Math.sin(s);return{x:r+n*l*b-a*S*x,y:t+n*l*x+a*S*b}},d=(g,l)=>{e.__addPathCommand(`A ${n} ${a} ${w} ${g} ${v} ${l.x} ${l.y}`),e.__currentPosition=l},P=c(o);if(e.moveTo(P.x,P.y),y){d(1,c(o+Math.PI)),d(1,P);return}const T=c(m);d(f>Math.PI?1:0,T)})}function $(){return new Promise(e=>{requestAnimationFrame(()=>e())})}async function I(){await $(),await $()}function R(){const e=C.default??C.C2S??C;if(typeof e=="function")return e;const r=window.C2S;return typeof r=="function"?r:null}async function te(e,r=R()){var f,y,w,v;if(!r)return console.error("[meta2d] preview failed: canvas2svg constructor missing"),"";D(e.data()),e.render(!0),await I();const t=e.store,n=(f=t==null?void 0:t.data)==null?void 0:f.pens,a=Array.isArray(n)?n.length:0,s=10,o=e.getRect();if(!o||!Number.isFinite(o.width)||!Number.isFinite(o.height)||o.width<=0||o.height<=0)return a===0?_:(console.error("[meta2d] preview failed: invalid bounds",o),"");const m={...o,x:o.x-s,y:o.y-s},i=new r(Math.ceil(o.width+s*2),Math.ceil(o.height+s*2));if(i.textBaseline="middle",i.strokeStyle=((y=t==null?void 0:t.styles)==null?void 0:y.color)||"#1f1f1f",X(i),ee(i),Array.isArray(n)&&t){for(const c of n)if(!((c==null?void 0:c.visible)===!1||!N(c,t)))try{e.renderPenRaw(i,c,m,!0)}catch(d){console.error("[meta2d] preview failed: render pen",c,d)}}const h=((v=(w=i.getSerializedSvg)==null?void 0:w.call(i))==null?void 0:v.replace(/--le5le--/g,"&#x"))??"";return h.trim()?h:a===0?_:(console.error("[meta2d] preview failed: serialized SVG is empty",{pensCount:a}),"")}async function ue(e){const r=R();if(!r)return console.error("[meta2d] preview failed: canvas2svg constructor missing"),"";Z();const t=document.createElement("div");t.style.cssText="position:fixed;left:-20000px;top:0;width:1200px;height:800px;pointer-events:none;z-index:-1;",document.body.append(t);let n=null;try{let a;try{a=JSON.parse(e)}catch(s){return console.error("[meta2d] preview failed: invalid diagram JSON",s,e),""}return n=new O(t,{background:"#fff",grid:!1,rule:!1}),D(a),n.open(a),n.render(!0),await I(),te(n,r)}catch(a){return console.error("[meta2d] preview failed: unexpected error",a),""}finally{Y(n,t)}}export{Z as ensureMeta2dShapes,ue as generateSvgFromDiagram,te as generateSvgFromMeta2d};
1
+ import{T as D,W as _}from"./react-BXGUMaBS.js";import{r as p,a as A,b as u,c as z,i as N,M as O,C,f as k,d as q,e as L,g as V,h as j,s as B,j as G,k as H,l as J,m as W,n as K,o as Q}from"./meta2d-1-g23JOU.js";import"./react-vendor-BuABiQkA.js";import"./editor-CL03se2B.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./index-DUu4Is5p.js";import"./plus-C3uXIATM.js";import"./check-CQSGOkW1.js";import"./copy-BMAJ--_Y.js";let E=!1;function U(){E||(p(k()),A(q()),p(L()),u(V()),p(j()),p(B()),u(G()),z(),u(H()),u(J()),p(W()),u(K()),A(Q()),E=!0)}let F=!1;function Z(){F||(U(),F=!0)}function Y(e,r){try{e==null||e.destroy()}catch{}try{r.remove()}catch{}}function X(e){let r=e.font;Object.defineProperty(e,"font",{configurable:!0,get:()=>r,set:t=>{r=typeof t=="string"?t.replace(/(\d+(?:\.\d+)?(?:px|pt|pc|em|ex|%|in|cm|mm))\s*\/\s*(\d+(?:\.\d+)?)(?=\s|$)/,"$1/normal"):t,e.__ctx&&(e.__ctx.font=r)}})}function ee(e){typeof e.ellipse!="function"&&(e.ellipse=(r,t,n,a,s=0,o=0,m=Math.PI*2,i=!1)=>{var M;if(n<0||a<0)throw new Error("IndexSizeError: The radius provided is negative.");((M=e.__currentElement)==null?void 0:M.nodeName)!=="path"&&e.beginPath();const h=Math.PI*2,f=Math.abs(m-o),y=f>=h-1e-4||f===0,w=s*180/Math.PI,v=i?0:1,c=g=>{const l=Math.cos(g),S=Math.sin(g),b=Math.cos(s),x=Math.sin(s);return{x:r+n*l*b-a*S*x,y:t+n*l*x+a*S*b}},d=(g,l)=>{e.__addPathCommand(`A ${n} ${a} ${w} ${g} ${v} ${l.x} ${l.y}`),e.__currentPosition=l},P=c(o);if(e.moveTo(P.x,P.y),y){d(1,c(o+Math.PI)),d(1,P);return}const T=c(m);d(f>Math.PI?1:0,T)})}function $(){return new Promise(e=>{requestAnimationFrame(()=>e())})}async function I(){await $(),await $()}function R(){const e=C.default??C.C2S??C;if(typeof e=="function")return e;const r=window.C2S;return typeof r=="function"?r:null}async function te(e,r=R()){var f,y,w,v;if(!r)return console.error("[meta2d] preview failed: canvas2svg constructor missing"),"";D(e.data()),e.render(!0),await I();const t=e.store,n=(f=t==null?void 0:t.data)==null?void 0:f.pens,a=Array.isArray(n)?n.length:0,s=10,o=e.getRect();if(!o||!Number.isFinite(o.width)||!Number.isFinite(o.height)||o.width<=0||o.height<=0)return a===0?_:(console.error("[meta2d] preview failed: invalid bounds",o),"");const m={...o,x:o.x-s,y:o.y-s},i=new r(Math.ceil(o.width+s*2),Math.ceil(o.height+s*2));if(i.textBaseline="middle",i.strokeStyle=((y=t==null?void 0:t.styles)==null?void 0:y.color)||"#1f1f1f",X(i),ee(i),Array.isArray(n)&&t){for(const c of n)if(!((c==null?void 0:c.visible)===!1||!N(c,t)))try{e.renderPenRaw(i,c,m,!0)}catch(d){console.error("[meta2d] preview failed: render pen",c,d)}}const h=((v=(w=i.getSerializedSvg)==null?void 0:w.call(i))==null?void 0:v.replace(/--le5le--/g,"&#x"))??"";return h.trim()?h:a===0?_:(console.error("[meta2d] preview failed: serialized SVG is empty",{pensCount:a}),"")}async function ue(e){const r=R();if(!r)return console.error("[meta2d] preview failed: canvas2svg constructor missing"),"";Z();const t=document.createElement("div");t.style.cssText="position:fixed;left:-20000px;top:0;width:1200px;height:800px;pointer-events:none;z-index:-1;",document.body.append(t);let n=null;try{let a;try{a=JSON.parse(e)}catch(s){return console.error("[meta2d] preview failed: invalid diagram JSON",s,e),""}return n=new O(t,{background:"#fff",grid:!1,rule:!1}),D(a),n.open(a),n.render(!0),await I(),te(n,r)}catch(a){return console.error("[meta2d] preview failed: unexpected error",a),""}finally{Y(n,t)}}export{Z as ensureMeta2dShapes,ue as generateSvgFromDiagram,te as generateSvgFromMeta2d};
@@ -1,4 +1,4 @@
1
- import{o}from"./index-CUdIA5aE.js";/**
1
+ import{o}from"./index-DUu4Is5p.js";/**
2
2
  * @license lucide-react v0.562.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -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-SYn2XtSh.js","assets/meta2d-1-g23JOU.js","assets/react-vendor-BuABiQkA.js","assets/editor-CL03se2B.js","assets/ui-CvA4pq3d.js","assets/motion-DFABYlwt.js","assets/diagram-Bk84WZto.js","assets/index-CUdIA5aE.js","assets/index-C0ujN3sT.css","assets/plus-QDhBbIRF.js","assets/check-CN9m0reb.js","assets/copy-DFs3qk19.js","assets/DiagramEditor-NtNY3sZL-Cie6NhLx.js"])))=>i.map(i=>d[i]);
2
- var y7=Object.defineProperty;var x7=(e,t,n)=>t in e?y7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>x7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,ae as k7,af as w7,ag as v7,ah as Dn,ai as Xh,aj as _m,ak as S7,j as O,b as Ri,al as C7,am as _7,an as E7,ao as T7,z as A7,C as Jh,ap as M7,aq as N7,ar as D7,as as I7}from"./react-vendor-BuABiQkA.js";import{P as ze,e as Yh,A as nu,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Pi,$ as ce,O as jn,G as pr,d as ms,l as md,z as Sn,r as gt,v as nb,B as je,X as Ln,T as rb,M as Dl,L as Ai,W as pl,f as hi,g as gs,h as So,C as Zh,Y as ib,y as Pt,i as Il,H as Xe,j as L7,t as F7,m as Lo,J as yn,o as sb,R as fi,S as ru,Q as Zn,q as ob,s as O7,u as Ll,x as mt,E as z7,D as yc,I as R7,K as P7,_ as B7,N as iu,U as gd,Z as bs,a0 as Co,a1 as Tt,a2 as ab,a3 as $7,a4 as j7,a5 as Hr,a6 as Ii,a7 as Fl,a8 as vn,a9 as _n,aa as bd,ab as q7,ac as ub,ad as yd,ae as xd,af as _o,V as hn,ag as lb,ah as H7,ai as cb,aj as U7,ak as W7,al as K7,am as V7,an as hb,ao as Qn,ap as G7,aq as jr,ar as qn,as as ys,at as Em,au as Tm,av as X7,aw as J7,ax as Y7,ay as Z7,az as Aa,aA as fb,aB as db,aC as aa,aD as Ma,aE as su,aF as Q7,aG as Qh,aH as Am,aI as ek,aJ as tk,aK as pb,aL as nk,aM as rk,aN as ik,aO as kd,aP as Rr,aQ as Eo,aR as wd,aS as ma,aT as hs,aU as Na,aV as ef,aW as Mm,aX as ga,aY as ml,aZ as Ol,a_ as sk,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as Pr,b4 as ck,b5 as hk,b6 as fk,b7 as Nm,b8 as gl,b9 as Dm,ba as dk,bb as pk,bc as mk,bd as gk,be as xs,bf as Im,bg as tf,bh as bk,bi as yk,bj as xk,bk as kk,bl as Lm,bm as ii,bn as Da,bo as nf,bp as wk,bq as ua,br as mb,bs as gb,bt as bb,bu as yb,bv as xb,bw as vk,bx as Sk,by as vd,bz as kb,bA as Ck,bB as _k,bC as Sd,bD as Ek,bE as Fm,bF as rf,bG as wb,bH as vb,bI as Tk,bJ as Ak,bK as Xu,bL as Sb,bM as Mk,bN as Nk,bO as Dk,bP as Cb,bQ as Ik,bR as Lk,bS as _b,bT as zl,bU as Fk,bV as Ok,bW as zk}from"./editor-CL03se2B.js";import{ag as tt,ah as at,ai as Rk,aj as Ia,ak as Pk,al as Rl,am as Bk,an as wi,ao as Zo,ap as $k,aq as jk,ar as qk,as as Hk,at as Uk,au as Wk,av as Kk,aw as Vk,ad as Cd,ax as Gk,ay as It,ac as qr,az as sf,aA as La,aB as Ue,aC as Pl,aD as Eb,aE as Xk,aF as On,aG as Jk,aH as Yk,aI as Zk,aJ as ou,aK as _d,aL as of,aM as Bl,aN as Tb,aO as Qk,aP as Om,aQ as ew,aR as tw,t as af,aS as Ab,aT as nw,aU as rw,aV as Mb,aW as Nb,aX as iw}from"./ui-CvA4pq3d.js";import{i as B0,j as sw,k as ow,l as aw,n as zm,e as Qo,s as uw,y as lw,h as Rm,m as Pm,r as cw,u as hw,v as fw,o as dw,w as pw,x as Db}from"./diagram-Bk84WZto.js";import{o as pn,aH as mw,aI as Ed,ah as gw}from"./index-CUdIA5aE.js";import{P as Bm}from"./plus-QDhBbIRF.js";import{C as bw}from"./check-CN9m0reb.js";import{C as yw}from"./copy-DFs3qk19.js";/**
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-BAZUiXoN.js","assets/meta2d-1-g23JOU.js","assets/react-vendor-BuABiQkA.js","assets/editor-CL03se2B.js","assets/ui-CvA4pq3d.js","assets/motion-DFABYlwt.js","assets/diagram-Bk84WZto.js","assets/index-DUu4Is5p.js","assets/index-C8iEyMxp.css","assets/plus-C3uXIATM.js","assets/check-CQSGOkW1.js","assets/copy-BMAJ--_Y.js","assets/DiagramEditor-NtNY3sZL-B2Aeu79R.js"])))=>i.map(i=>d[i]);
2
+ var y7=Object.defineProperty;var x7=(e,t,n)=>t in e?y7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>x7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,ae as k7,af as w7,ag as v7,ah as Dn,ai as Xh,aj as _m,ak as S7,j as O,b as Ri,al as C7,am as _7,an as E7,ao as T7,z as A7,C as Jh,ap as M7,aq as N7,ar as D7,as as I7}from"./react-vendor-BuABiQkA.js";import{P as ze,e as Yh,A as nu,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Pi,$ as ce,O as jn,G as pr,d as ms,l as md,z as Sn,r as gt,v as nb,B as je,X as Ln,T as rb,M as Dl,L as Ai,W as pl,f as hi,g as gs,h as So,C as Zh,Y as ib,y as Pt,i as Il,H as Xe,j as L7,t as F7,m as Lo,J as yn,o as sb,R as fi,S as ru,Q as Zn,q as ob,s as O7,u as Ll,x as mt,E as z7,D as yc,I as R7,K as P7,_ as B7,N as iu,U as gd,Z as bs,a0 as Co,a1 as Tt,a2 as ab,a3 as $7,a4 as j7,a5 as Hr,a6 as Ii,a7 as Fl,a8 as vn,a9 as _n,aa as bd,ab as q7,ac as ub,ad as yd,ae as xd,af as _o,V as hn,ag as lb,ah as H7,ai as cb,aj as U7,ak as W7,al as K7,am as V7,an as hb,ao as Qn,ap as G7,aq as jr,ar as qn,as as ys,at as Em,au as Tm,av as X7,aw as J7,ax as Y7,ay as Z7,az as Aa,aA as fb,aB as db,aC as aa,aD as Ma,aE as su,aF as Q7,aG as Qh,aH as Am,aI as ek,aJ as tk,aK as pb,aL as nk,aM as rk,aN as ik,aO as kd,aP as Rr,aQ as Eo,aR as wd,aS as ma,aT as hs,aU as Na,aV as ef,aW as Mm,aX as ga,aY as ml,aZ as Ol,a_ as sk,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as Pr,b4 as ck,b5 as hk,b6 as fk,b7 as Nm,b8 as gl,b9 as Dm,ba as dk,bb as pk,bc as mk,bd as gk,be as xs,bf as Im,bg as tf,bh as bk,bi as yk,bj as xk,bk as kk,bl as Lm,bm as ii,bn as Da,bo as nf,bp as wk,bq as ua,br as mb,bs as gb,bt as bb,bu as yb,bv as xb,bw as vk,bx as Sk,by as vd,bz as kb,bA as Ck,bB as _k,bC as Sd,bD as Ek,bE as Fm,bF as rf,bG as wb,bH as vb,bI as Tk,bJ as Ak,bK as Xu,bL as Sb,bM as Mk,bN as Nk,bO as Dk,bP as Cb,bQ as Ik,bR as Lk,bS as _b,bT as zl,bU as Fk,bV as Ok,bW as zk}from"./editor-CL03se2B.js";import{ag as tt,ah as at,ai as Rk,aj as Ia,ak as Pk,al as Rl,am as Bk,an as wi,ao as Zo,ap as $k,aq as jk,ar as qk,as as Hk,at as Uk,au as Wk,av as Kk,aw as Vk,ad as Cd,ax as Gk,ay as It,ac as qr,az as sf,aA as La,aB as Ue,aC as Pl,aD as Eb,aE as Xk,aF as On,aG as Jk,aH as Yk,aI as Zk,aJ as ou,aK as _d,aL as of,aM as Bl,aN as Tb,aO as Qk,aP as Om,aQ as ew,aR as tw,t as af,aS as Ab,aT as nw,aU as rw,aV as Mb,aW as Nb,aX as iw}from"./ui-CvA4pq3d.js";import{i as B0,j as sw,k as ow,l as aw,n as zm,e as Qo,s as uw,y as lw,h as Rm,m as Pm,r as cw,u as hw,v as fw,o as dw,w as pw,x as Db}from"./diagram-Bk84WZto.js";import{o as pn,aI as mw,aJ as Ed,ah as gw}from"./index-DUu4Is5p.js";import{P as Bm}from"./plus-C3uXIATM.js";import{C as bw}from"./check-CQSGOkW1.js";import{C as yw}from"./copy-BMAJ--_Y.js";/**
3
3
  * @license lucide-react v0.562.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -1731,7 +1731,7 @@ ${this.__markdown}
1731
1731
  ## 分支 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(Ux,{markdown:r})})]})]})}function Nq({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(Mq,{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(Ux,{markdown:s})})]})}function fU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((s,o)=>O.jsx(Nq,{className:e,editor:o,node:s}),[e]),i=E.useRef(!1);return i.current||(i.current=!0,n.registerPlugin(Aq,{decorator:r,theme:t})),null}const Dq=lt("INSERT_MATH_COMMAND"),Wx=lt("UPDATE_MATH_COMMAND"),Ml=lt("SELECT_MATH_SIDE_COMMAND");function Iq(e){return gt(e.registerCommand(Dq,t=>{const{code:n}=t;return e.update(()=>{const r=lu(n);_n([r]),qn(r.getParentOrThrow())&&ys(r,hn).selectEnd()}),!0},Ln),e.registerCommand(Wx,t=>{const{code:n,key:r}=t;return e.update(()=>{const i=ze(r);i&&(i.updateCode(n),i.selectNext())}),!0},Ln),e.registerCommand(Ml,t=>{const{key:n,prev:r}=t;return e.update(()=>{const i=ze(n);i&&(r?i.selectPrevious():i.selectNext())}),!0},Ln))}function Lq(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 Fq=(wo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","math"),t.registerNodes([xa,Li]),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,Li.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Iq(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(!Lq(i))return;const s=lu(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(Li.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),Kx=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||eu(s.current)},[n]),O.jsx(ou,{arrow:!1,content:O.jsx(It,{className:Oi.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:Oi.mathEditorAnchor,onClick:g,ref:s})})});Kx.displayName="MathEditorContainer";Hb();const Vx=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{ew(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(tw,{autoFocus:!0,autoSize:{maxRows:6,minRows:1},className:Oi.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:Oi.mathEditorFooter,horizontal:!0,paddingBlock:4,paddingInline:12,width:"100%",children:O.jsx(qr,{fontSize:13,type:"danger",children:g})}),O.jsx(It,{className:Oi.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"})]})})]})});Vx.displayName="MathEditorContent";kr();const Oq=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(Wx,{code:V,key:r.getKey()})}},[v,r,s]),T=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&(z.dispatchCommand(Ml,{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(Ml,{key:r.getKey(),prev:!0})},[r,v]),F=E.useCallback(()=>{r&&v.dispatchCommand(Ml,{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(!jn(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 Li),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&&h9(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(Vx,{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(Kx,{isBlockMode:m,mathDOM:l,onFocus:j,prev:d,children:U})})}),zq=({mathBlock:e})=>{const t=nr(),n=O.jsx(qr,{as:"span",className:at("katex",Oi.mathPlaceholder),fontSize:e?"1.2em":"1em",type:"secondary",children:t("math.placeholder")});return e?O.jsx(of,{padding:18,width:"100%",children:n}):n};Ot();const Rq=Qe("plugin","math"),Pq=({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 Li;return E.useEffect(()=>{r.current&&t.code&&Jk.render(t.code,r.current,{displayMode:t instanceof Li,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(!jn(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=>{Rq.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(zq,{mathBlock:l})})},Bq=({className:e,renderComp:t,theme:n})=>{const[r]=_t();return E.useLayoutEffect(()=>{r.registerPlugin(Ki),r.registerPlugin(Fq,{decorator:(i,s)=>O.jsx(Pq,{className:e,editor:s,node:i}),theme:n||Oi})},[r,e,n,Oi]),O.jsx(Oq,{renderComp:t})};Bq.displayName="ReactMathPlugin";var Gs=class Nl extends Wr{static getType(){return"meta2d"}static clone(t){return new Nl(t.__diagram,t.__svg,t.__key,t.__autoOpenEditor)}static importJSON(t){return new Nl(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=qi(t))==null?void 0:r.getDecorator(Nl.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---
1732
1732
  ${this.__diagram}
1733
1733
  ---/meta2d---
1734
- `}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Gx(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 $q=lt("INSERT_META2D_COMMAND");function jq(e){return e.registerCommand($q,t=>(e.update(()=>{var n;_n([Gx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Sl,(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 qq=/^---meta2d---$/i,Hq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Uq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Wq=(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(jq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:qq,replace:n=>{const r=Gx(Sl,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||Sl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Uq(n).match(Hq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Sl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:dD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Kq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-SYn2XtSh.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Vq(e){return(await Kq()).generateSvgFromDiagram(e)}function Gq(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 Xq({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),Vq(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:Gq(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 Jq=E.memo(Xq),Yq=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-Cie6NhLx.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function Zq({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(Jq,{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(Yq,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function dU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(Zq,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Wq,{decorator:r,theme:t})},[r,n,t]),null}const Xx=E.createContext(null),Qq=({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(Xx.Provider,{value:s,children:e})};Qq.displayName="OutlineProvider";function J1(){return E.useContext(Xx)}function pU(){const e=J1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function eH(e){const t=J1(),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 mU=({editor:e,visible:t})=>{const n=J1(),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))]})},tH="Hide outline",nH="Show outline",rH="outline";function gU(e){const{collapseTitle:t=tH,expandTitle:n=nH,onVisibleChange:r,visible:i}=e??{},s=eH(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:Fw,key:rH,label:a?t:n,onClick:o}},[t,n,s])}kr();function iH(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 sH(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 oH(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 aH(e,t,n){const r=new Set(n?n.getNodes():[]);iH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,sH(e,i)):(i.highlighted=!1,oH(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 uH(){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 lH(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 Jx=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(tf,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(uH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Da(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=nf(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=Ik(K.getNodes().filter(hi));U&&lH(U)})},_=()=>{e.update(()=>{Lk()})},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(()=>{Tk()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sd(i),[z]=rf(K,null,null),V=new Set,X=i.getHeaderStyles()^Xu.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,Xu.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=rf(K,null,null),V=new Set,X=i.getHeaderStyles()^Xu.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,Xu.COLUMN)))}y()})},[e,i,y]);return O.jsx(_d,{menu:{items:E.useMemo(()=>[{icon:Bw,key:"table-insert-row-above",label:m("table.insertRowAbove",{count:o.rows}),onClick:()=>v(!1)},{icon:zw,key:"table-insert-row-below",label:m("table.insertRowBelow",{count:o.rows}),onClick:()=>v(!0)},{type:"divider"},{icon:gw,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:Hw,key:"table-delete-columns",label:m("table.deleteColumn"),onClick:()=>R()},{icon:Ww,key:"table-delete-rows",label:m("table.deleteRow"),onClick:()=>T()},{type:"divider"},{icon:Dw,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})});Jx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
1734
+ `}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Gx(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 $q=lt("INSERT_META2D_COMMAND");function jq(e){return e.registerCommand($q,t=>(e.update(()=>{var n;_n([Gx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Sl,(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 qq=/^---meta2d---$/i,Hq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Uq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Wq=(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(jq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:qq,replace:n=>{const r=Gx(Sl,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||Sl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Uq(n).match(Hq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Sl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:dD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Kq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-BAZUiXoN.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Vq(e){return(await Kq()).generateSvgFromDiagram(e)}function Gq(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 Xq({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),Vq(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:Gq(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 Jq=E.memo(Xq),Yq=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-B2Aeu79R.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function Zq({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(Jq,{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(Yq,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function dU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(Zq,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Wq,{decorator:r,theme:t})},[r,n,t]),null}const Xx=E.createContext(null),Qq=({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(Xx.Provider,{value:s,children:e})};Qq.displayName="OutlineProvider";function J1(){return E.useContext(Xx)}function pU(){const e=J1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function eH(e){const t=J1(),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 mU=({editor:e,visible:t})=>{const n=J1(),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))]})},tH="Hide outline",nH="Show outline",rH="outline";function gU(e){const{collapseTitle:t=tH,expandTitle:n=nH,onVisibleChange:r,visible:i}=e??{},s=eH(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:Fw,key:rH,label:a?t:n,onClick:o}},[t,n,s])}kr();function iH(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 sH(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 oH(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 aH(e,t,n){const r=new Set(n?n.getNodes():[]);iH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,sH(e,i)):(i.highlighted=!1,oH(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 uH(){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 lH(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 Jx=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(tf,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(uH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Da(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=nf(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=Ik(K.getNodes().filter(hi));U&&lH(U)})},_=()=>{e.update(()=>{Lk()})},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(()=>{Tk()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sd(i),[z]=rf(K,null,null),V=new Set,X=i.getHeaderStyles()^Xu.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,Xu.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=rf(K,null,null),V=new Set,X=i.getHeaderStyles()^Xu.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,Xu.COLUMN)))}y()})},[e,i,y]);return O.jsx(_d,{menu:{items:E.useMemo(()=>[{icon:Bw,key:"table-insert-row-above",label:m("table.insertRowAbove",{count:o.rows}),onClick:()=>v(!1)},{icon:zw,key:"table-insert-row-below",label:m("table.insertRowBelow",{count:o.rows}),onClick:()=>v(!0)},{type:"divider"},{icon:gw,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:Hw,key:"table-delete-columns",label:m("table.deleteColumn"),onClick:()=>R()},{icon:Ww,key:"table-delete-rows",label:m("table.deleteRow"),onClick:()=>T()},{type:"divider"},{icon:Dw,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})});Jx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
1735
1735
  transform: translateX(2px);
1736
1736
  `,root:e`
1737
1737
  will-change: transform;
@@ -27,12 +27,12 @@
27
27
  opacity: 0.65;
28
28
  }
29
29
  </style>
30
- <script type="module" crossorigin src="/assets/index-CUdIA5aE.js"></script>
30
+ <script type="module" crossorigin src="/assets/index-DUu4Is5p.js"></script>
31
31
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-BuABiQkA.js">
32
32
  <link rel="modulepreload" crossorigin href="/assets/motion-DFABYlwt.js">
33
33
  <link rel="modulepreload" crossorigin href="/assets/ui-CvA4pq3d.js">
34
34
  <link rel="modulepreload" crossorigin href="/assets/diagram-Bk84WZto.js">
35
- <link rel="stylesheet" crossorigin href="/assets/index-C0ujN3sT.css">
35
+ <link rel="stylesheet" crossorigin href="/assets/index-C8iEyMxp.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.17",
3
+ "version": "1.3.18",
4
4
  "description": "A Markdown knowledge base for small teams",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +0,0 @@
1
- import{r as a,j as e}from"./react-vendor-BuABiQkA.js";import{o as bs,c as ie,t as Ns,v as vs,p as ks,l as Ae,w as ws,x as Ss,y as Q,z as Pe,A as Cs,B as Ds,G as Is,a as Ts,d as Oe,H as Ye,I as qe,J as As,K as Ps,L as Ms,O as Es,Q as Rs,T as Xe,U as Ie,V as Ls,W as Fs,X as zs,Y as Bs,Z as $s,_ as Ks,f as Qe,$ as Os,a0 as Vs,a1 as Us,a2 as Ws,a3 as _s,a4 as es,a5 as Gs,a6 as Hs,a7 as Js,a8 as Zs,a9 as Ys,aa as qs,ab as Xs,ac as Qs,ad as et,ae as st,af as tt,ag as at,ah as nt,P as it,ai as ct,aj as lt,ak as ot,r as rt,j as dt,al as mt,k as ut,m as ht}from"./index-CUdIA5aE.js";import{V as ss,a as pt,M as Ve}from"./VisitorPickerModal-CqDA1S9F.js";import{C as gt}from"./check-CN9m0reb.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";/**
2
- * @license lucide-react v0.562.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ft=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xt=bs("search",ft);function jt({draft:t,onClose:s,onSuccess:j}){const{t:d,lang:p}=ie(),[B,u]=a.useState([]),[w,N]=a.useState(t.domainId??""),[g,k]=a.useState([]),[T,S]=a.useState(""),[c,x]=a.useState(`${t.displayName||"untitled"}_recovered.md`),[o,h]=a.useState(!1),[I,A]=a.useState(null),y=a.useRef(null),M=a.useRef(!0);a.useEffect(()=>(M.current=!0,()=>{M.current=!1}),[]),a.useEffect(()=>{Ns().then(v=>{M.current&&u(v)})},[]),a.useEffect(()=>{w&&(k([]),S(""),vs(w).then(v=>{M.current&&k(v)}).catch(()=>{M.current&&k([])}))},[w]),a.useEffect(()=>{const v=window.setTimeout(()=>{var P;return(P=y.current)==null?void 0:P.focus()},0);return()=>window.clearTimeout(v)},[]),a.useEffect(()=>{const v=P=>{P.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]);function z(v,P){for(const C of v){if(C.type==="folder"&&C.path===P)return C.documentId;if(C.type==="folder"){const E=z(C.children,P);if(E)return E}}return null}async function F(v){v.preventDefault(),h(!0),A(null);const P=c.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\-.]/g,""),C=P.endsWith(".md")?P:P+".md",E=C.replace(/\.md$/i,"");try{const m=T?`${T}/${C}`:C,l=T?z(g,T)??void 0:void 0;await Ss({fileName:C,displayName:E,content:t.content,domainId:w,parentId:l}),j()}catch(m){A(Q(d,m))}finally{h(!1)}}return e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&!o&&s()},children:e.jsxs("div",{className:"mdocs-dialog card mdocs-recovery-dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:d("recoverDraft")}),e.jsx("p",{className:"muted",children:d("recoverDraftDesc",{name:t.displayName||d("unknownTitle")})}),e.jsxs("form",{onSubmit:F,className:"mdocs-dialog-form",children:[e.jsxs("label",{className:"mdocs-dialog-label",children:[d("domainLabel"),B.length>0&&e.jsx(ks,{domains:B,value:w,onChange:N,onDomainsChange:u,ariaLabel:d("domainLabel"),localizeName:v=>Ae(v,p,d)})]}),e.jsxs("label",{className:"mdocs-dialog-label mdocs-recovery-tree-label",children:[d("recoverTargetFolder"),e.jsx("div",{className:"mdocs-recovery-tree",children:e.jsx(ws,{nodes:g,activeDocumentId:null,selectedParentPath:T,onOpen:()=>{},onOpenFolder:v=>S(v),onContextMenu:()=>{},onDeselect:()=>S("")})})]}),e.jsxs("label",{className:"mdocs-dialog-label",children:[d("fileNameLabel"),e.jsx("input",{ref:y,value:c,onChange:v=>x(v.target.value),placeholder:"recovered.md",maxLength:200,disabled:o})]}),I&&e.jsx("div",{className:"mdocs-dialog-error",children:I}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>!o&&s(),disabled:o,children:d("cancel")}),e.jsx("button",{type:"submit",className:"primary",disabled:o,children:d(o?"creating":"create")})]})]})]})})}function yt({onPublish:t,onClose:s,onCountChange:j,onRecover:d}){const{t:p}=ie(),[B,u]=a.useState([]),[w,N]=a.useState(new Set),[g,k]=a.useState(!1),[T,S]=a.useState(null),[c,x]=a.useState(null),[o,h]=a.useState(null),I=a.useRef(null),A=a.useRef(!0);a.useEffect(()=>(A.current=!0,Pe().then(l=>{if(!A.current)return;const f=l.filter(D=>!D.published);u(f),j==null||j(f.length)}),()=>{A.current=!1,I.current&&(clearTimeout(I.current),I.current=null)}),[]),a.useEffect(()=>{const l=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[s]);const y=a.useCallback((l,f)=>{h({message:l,type:f}),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>h(null),3e3)},[]);async function M(l){await Ds(l),N(f=>new Set(f).add(l));try{await t(l),u(f=>{const D=f.filter($=>$.documentId!==l);return j==null||j(D.length),D}),y(p("published"),"success")}catch(f){f instanceof Is||y(p("publishFailed"),"error");const D=await Ts(l);D&&u($=>$.map(U=>U.documentId===l?D:U))}finally{N(f=>{const D=new Set(f);return D.delete(l),D})}}async function z(l){S(null),await Oe(l),u(f=>{const D=f.filter($=>$.documentId!==l);return j==null||j(D.length),D}),y(p("draftDeleted"),"success")}function F(l){const f=B.find(D=>D.documentId===l);f&&x(f)}function v(l){x(null),Oe(l),u(f=>{const D=f.filter($=>$.documentId!==l);return j==null||j(D.length),D}),d==null||d(B.find(f=>f.documentId===l)),y(p("published"),"success")}async function P(){k(!0);let l=0,f=0;for(const U of B)try{await t(U.documentId),l++}catch{f++}const $=(await Pe()).filter(U=>!U.published);u($),j==null||j($.length),f===0?y(p("publishAll"),"success"):y(`${l} published, ${f} failed`,"error"),k(!1)}const C=l=>new Date(l).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),E=l=>Cs(p,l,l.publishError??"UNKNOWN"),m=B;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-drawer-overlay",onClick:s}),e.jsxs("div",{className:"mdocs-drawer",role:"dialog","aria-modal":"true",children:[e.jsxs("header",{className:"mdocs-drawer-header",children:[e.jsxs("div",{className:"mdocs-drawer-header-text",children:[e.jsxs("h2",{className:"mdocs-drawer-title",children:[p("unpublishedDrafts"),m.length>0&&e.jsx("span",{className:"mdocs-drawer-count-badge",children:m.length})]}),e.jsx("span",{className:"mdocs-drawer-subtitle",children:p("draftCount",{count:String(m.length)})})]}),e.jsx("button",{type:"button",className:"mdocs-drawer-close-btn",onClick:s,"aria-label":p("close"),children:"×"})]}),e.jsx("div",{className:"mdocs-drawer-body",children:m.length===0?e.jsxs("div",{className:"mdocs-drawer-empty",children:[e.jsx("div",{className:"mdocs-drawer-empty-icon","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"mdocs-drawer-empty-text",children:p("draftsEmptyState")})]}):e.jsx("div",{className:"mdocs-drawer-items",children:m.map(l=>{const f=!!l.publishError;return e.jsxs("div",{className:f?"mdocs-drawer-item mdocs-drawer-item-failed":"mdocs-drawer-item",children:[e.jsx("div",{className:"mdocs-drawer-item-icon","aria-hidden":"true",children:"📄"}),e.jsxs("div",{className:"mdocs-drawer-item-info",children:[e.jsx("span",{className:"mdocs-drawer-item-name",children:l.displayName||p("unknownTitle")}),f?e.jsxs("span",{className:"mdocs-drawer-item-error",children:[C(l.publishErrorAt)," · ",E(l)]}):e.jsxs("span",{className:"mdocs-drawer-item-meta",children:[C(l.updatedAt)," · ",p("localSnapshot")]})]}),e.jsxs("div",{className:"mdocs-drawer-item-actions",children:[f?e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:g,onClick:()=>F(l.documentId),children:p("recoverDraft")}):e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:w.has(l.documentId)||g,onClick:()=>void M(l.documentId),children:w.has(l.documentId)?p("publishing"):p("publish")}),e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-danger",disabled:g,onClick:()=>S(l.documentId),children:p("delete")})]})]},l.documentId)})})}),e.jsxs("footer",{className:"mdocs-drawer-footer",children:[e.jsx("button",{type:"button",onClick:s,children:p("close")}),e.jsx("button",{type:"button",className:"primary",disabled:m.length===0||g,onClick:()=>void P(),children:g?p("publishing"):`${p("publishAll")} (${m.length})`})]}),o&&e.jsx("div",{className:"mdocs-drawer-toast mdocs-drawer-toast--"+o.type,role:"status",children:o.message})]}),T&&e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:l=>{l.target===l.currentTarget&&S(null)},children:e.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:p("delete")}),e.jsx("p",{className:"muted",children:p("confirmDeleteDraft")}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>S(null),children:p("cancel")}),e.jsx("button",{type:"button",className:"danger",onClick:()=>void z(T),children:p("delete")})]})]})}),c&&e.jsx(jt,{draft:c,onClose:()=>x(null),onSuccess:()=>v(c.documentId)})]})}function bt(){const{t,lang:s}=ie(),j=Ye(),d=a.useRef(!1),[p,B]=a.useState([]),[u,w]=a.useState(!1),[N,g]=a.useState(""),[k,T]=a.useState("restricted"),[S,c]=a.useState(!1),[x,o]=a.useState(null),[h,I]=a.useState(null),[A,y]=a.useState(""),[M,z]=a.useState(""),[F,v]=a.useState("all"),[P,C]=a.useState(null);a.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const E=a.useCallback(async()=>{w(!0),o(null);try{const b=await qe();if(!d.current)return;B(b)}catch(b){if(!d.current)return;o(Q(t,b))}finally{d.current&&w(!1)}},[t]);a.useEffect(()=>{E()},[E]);async function m(b){if(b.preventDefault(),!N.trim()){o(t("domainNameRequired"));return}c(!0),o(null);try{if(await Rs({domainName:N.trim(),permission:k}),!d.current)return;g(""),T("restricted"),await E()}catch(K){if(!d.current)return;o(Q(t,K))}finally{d.current&&c(!1)}}async function l(b){if(A.trim()){o(null);try{if(await Es(b,A.trim()),!d.current)return;I(null),C(null),await E()}catch(K){if(!d.current)return;o(Q(t,K))}}}function f(b){I(b.domainId),y(b.domainName),C(null)}function D(){I(null),C(null)}async function $(b,K){o(null);try{if(await Ms(b,K),!d.current)return;C(null),await E()}catch(W){if(!d.current)return;o(Q(t,W))}}async function U(b){if(window.confirm(t("deleteDomainConfirmDetail",{name:b.domainName,count:String(b.docCount)}))){o(null);try{if(await Ps(b.domainId),!d.current)return;await E()}catch(K){if(!d.current)return;o(Q(t,K))}}}const Z=a.useCallback(b=>As(b,t),[t]),Y=a.useCallback(b=>Ae(b.domainName,s,t),[s,t]),q=a.useMemo(()=>{const b=M.trim().toLowerCase();return p.filter(K=>F!=="all"&&K.permission!==F?!1:b?Ae(K.domainName,s,t).toLowerCase().includes(b)||K.domainName.toLowerCase().includes(b):!0)},[p,M,F,s,t]),_=a.useCallback((b,K)=>{const W=Z(b.permission);return K?`${W} ${t("domainTypeBuiltinSuffix")}`:W},[Z,t]);return{domains:p,loadingDomains:u,domainError:x,newDomainName:N,setNewDomainName:g,newDomainPermission:k,setNewDomainPermission:T,creating:S,handleCreateDomain:m,renamingId:h,setRenamingId:I,renameDraft:A,setRenameDraft:y,startRename:f,cancelRename:D,handleRename:l,changeTypeForId:P,setChangeTypeForId:C,handlePermissionChange:$,handleDelete:U,domainSearch:M,setDomainSearch:z,domainFilter:F,setDomainFilter:v,filteredDomains:q,visitorId:j,plabel:Z,localizeDomain:Y,domainTypeLabel:_}}const Ue={private:0,restricted:1,public:2};function We(t){return Object.prototype.hasOwnProperty.call(Ue,t)?Ue[t]:null}function _e(t,s){const j=We(t),d=We(s);return j===null||d===null?"invalid":d>j?"upgrade":d<j?"downgrade":"same"}function Nt(){const{t}=ie(),s=bt(),[j,d]=a.useState([]),[p,B]=a.useState(null),[u,w]=a.useState(""),N=a.useRef(null),[g,k]=a.useState(null),T=a.useCallback(async()=>{try{const c=await Xe();d(c)}catch{d([])}},[]);a.useEffect(()=>{T()},[T]),a.useEffect(()=>{if(!s.changeTypeForId)return;const c=x=>{var o;(o=N.current)!=null&&o.contains(x.target)||s.setChangeTypeForId(null)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s.changeTypeForId,s.setChangeTypeForId]);async function S(c){B(null);try{const x=await Ks(c.domainId);k({domainId:c.domainId,creatorVisitorId:c.creatorVisitorId,initialIds:x.map(o=>o.visitorId),memberRows:x})}catch(x){B({kind:"err",text:translateError(t,x)})}}return e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:t("domainManagement")})}),e.jsx("p",{className:"mdocs-domain-mgmt-restricted-hint",children:t("domainMgmtRestrictedMemberHint")}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-create",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("createDomain")}),e.jsxs("form",{onSubmit:s.handleCreateDomain,className:"mdocs-domain-mgmt-create-form",children:[e.jsxs("label",{className:"mdocs-domain-mgmt-field",children:[e.jsx("span",{className:"mdocs-domain-mgmt-label",children:t("domainName")}),e.jsx("input",{value:s.newDomainName,onChange:c=>s.setNewDomainName(c.target.value),placeholder:t("domainName"),maxLength:100,disabled:s.creating,className:"mdocs-domain-name-input"})]}),e.jsxs("fieldset",{className:"mdocs-domain-mgmt-fieldset",children:[e.jsx("legend",{className:"mdocs-domain-mgmt-label",children:t("domainPermission")}),e.jsx("div",{className:"mdocs-domain-mgmt-type-radios",children:Ie.map(c=>e.jsxs("label",{className:"mdocs-domain-mgmt-radio",children:[e.jsx("input",{type:"radio",name:"newDomainPermission",checked:s.newDomainPermission===c,onChange:()=>s.setNewDomainPermission(c),disabled:s.creating}),e.jsx("span",{children:s.plabel(c)})]},c))})]}),e.jsx("button",{type:"submit",className:"primary mdocs-domain-mgmt-submit",disabled:s.creating,children:s.creating?t("creating"):t("create")})]})]}),p&&e.jsx("div",{className:"mdocs-settings-card",style:{color:p.kind==="ok"?"var(--mdocs-success, #0a7)":"var(--mdocs-danger)"},children:e.jsx("span",{className:"mdocs-settings-item-desc",children:p.text})}),s.domainError&&e.jsx("div",{className:"mdocs-settings-card mdocs-domain-error",children:e.jsx("span",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)"},children:s.domainError})}),e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-toolbar",children:[e.jsx("input",{type:"search",value:s.domainSearch,onChange:c=>s.setDomainSearch(c.target.value),placeholder:t("domainSearchPlaceholder"),className:"mdocs-domain-mgmt-search","aria-label":t("domainSearchPlaceholder")}),e.jsx("div",{className:"mdocs-domain-mgmt-filters",role:"group","aria-label":t("domainPermission"),children:["all",...Ie].map(c=>e.jsx("button",{type:"button",className:"mdocs-domain-mgmt-filter"+(s.domainFilter===c?" active":""),"aria-pressed":s.domainFilter===c,onClick:()=>s.setDomainFilter(c),children:c==="all"?t("domainFilterAll"):s.plabel(c)},c))})]}),s.loadingDomains?e.jsx("div",{className:"mdocs-settings-card",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")})}):s.domains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("noDomains")})}):s.filteredDomains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("domainNoMatch")})}):e.jsx("div",{className:"mdocs-settings-card mdocs-domain-table-wrap",children:e.jsxs("table",{className:"mdocs-domain-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("domainColName")}),e.jsx("th",{scope:"col",children:t("domainColType")}),e.jsx("th",{scope:"col",className:"mdocs-domain-table-num",children:t("domainColDocCount")}),e.jsx("th",{scope:"col",children:t("domainColActions")})]})}),e.jsx("tbody",{children:s.filteredDomains.map(c=>{const x=Ls(c,s.visitorId),o=Fs(c.domainId),h=zs(c),I=_e(c.permission,"public")==="upgrade",A=I?h?t("domainTooltipTypeLocked"):void 0:t("domainPermissionAlreadyTop");return e.jsxs("tr",{className:o?"mdocs-domain-table-row-builtin":void 0,children:[e.jsx("td",{children:s.renamingId===c.domainId?e.jsxs("div",{className:"mdocs-domain-table-rename",children:[e.jsx("input",{value:s.renameDraft,onChange:y=>s.setRenameDraft(y.target.value),maxLength:100,autoFocus:!0,className:"mdocs-domain-name-input"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void s.handleRename(c.domainId),children:t("save")}),e.jsx("button",{type:"button",onClick:s.cancelRename,children:t("cancel")})]}):e.jsxs("div",{className:"mdocs-domain-table-name-cell",children:[e.jsx("span",{className:"mdocs-domain-table-name",children:s.localizeDomain(c)}),o&&e.jsx("span",{className:"mdocs-domain-badge-builtin",children:t("domainBuiltIn")}),!x&&!o&&e.jsx("span",{className:"mdocs-domain-badge-shared",children:t("shared")})]})}),e.jsx("td",{children:e.jsx("span",{className:"mdocs-domain-table-type",title:A,children:e.jsx("span",{className:"mdocs-domain-permission-badge","data-permission":c.permission,children:s.domainTypeLabel(c,o)})})}),e.jsx("td",{className:"mdocs-domain-table-num",children:c.docCount}),e.jsxs("td",{className:"mdocs-domain-table-actions",children:[o&&e.jsx("span",{className:"mdocs-domain-not-modifiable",children:t("domainNotModifiable")}),!o&&!x&&e.jsx("span",{className:"mdocs-domain-not-creator-inline",children:t("domainNotCreator")}),!o&&x&&s.changeTypeForId===c.domainId&&e.jsxs("div",{className:"mdocs-domain-change-type-panel",ref:N,children:[e.jsx("div",{className:"mdocs-domain-type-segment",role:"radiogroup","aria-label":t("domainChangeType"),children:Ie.map(y=>{const z=_e(c.permission,y)==="downgrade";return e.jsx("span",{title:z?t("domainPermissionNoDowngrade"):void 0,children:e.jsx("button",{type:"button",role:"radio","aria-checked":u===y,className:u===y?"active":"",disabled:z,onClick:()=>w(y),children:s.plabel(y)})},y)})}),e.jsx("button",{type:"button",className:"mdocs-domain-type-icon confirm","aria-label":t("save"),disabled:u===""||u===c.permission,onClick:()=>{u&&u!==c.permission&&s.handlePermissionChange(c.domainId,u)},children:e.jsx(gt,{size:14,strokeWidth:2.5})}),e.jsx("button",{type:"button",className:"mdocs-domain-type-icon cancel","aria-label":t("cancel"),onClick:()=>s.setChangeTypeForId(null),children:e.jsx(Bs,{size:14,strokeWidth:2.5})})]}),!o&&x&&s.renamingId!==c.domainId&&s.changeTypeForId!==c.domainId&&e.jsxs("div",{className:"mdocs-domain-action-buttons",children:[c.permission==="restricted"&&e.jsx("button",{type:"button",className:"mdocs-domain-action mdocs-domain-action--primary",onClick:()=>void S(c),children:t("domainMembersManageButton")}),e.jsx("button",{type:"button",className:"mdocs-domain-action",title:h?t("domainLocked"):void 0,onClick:()=>{s.setChangeTypeForId(null),s.startRename(c)},disabled:h,children:t("rename")}),e.jsx("button",{type:"button",className:"mdocs-domain-action",title:A,onClick:()=>{s.setRenamingId(null),w(c.permission),s.setChangeTypeForId(c.domainId)},disabled:!I,children:t("domainChangeType")}),e.jsx("button",{type:"button",className:"mdocs-domain-action mdocs-domain-action--danger",title:h?t("domainLocked"):void 0,onClick:()=>void s.handleDelete(c),disabled:h,children:t("deleteDomain")})]})]})]},c.domainId)})})]})})]}),e.jsx(ss,{open:g!==null,title:t("domainMembersPickerTitle"),initialSelectedIds:(g==null?void 0:g.initialIds)??[],lockedIds:g?[g.creatorVisitorId]:[],seedMembers:g==null?void 0:g.memberRows,templates:j,onClose:()=>k(null),onConfirm:async c=>{g&&(await $s(g.domainId,c),B({kind:"ok",text:t("domainMembersSaved",{count:String(c.length)})}))}})]})}function Ge(t){return t.length<=6?t:`${t.slice(0,6)}…`}function vt(){const{t}=ie(),s=a.useRef(!0),[j,d]=a.useState([]),[p,B]=a.useState(!0),[u,w]=a.useState(null),[N,g]=a.useState(1),[k,T]=a.useState(null),[S,c]=a.useState(""),[x,o]=a.useState([]),[h,I]=a.useState(!1),[A,y]=a.useState(null),[M,z]=a.useState(!1),F=Ye(),[v,P]=a.useState([]),[C,E]=a.useState("idle"),[m,l]=a.useState("");a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{E("loading"),Qe().then(r=>{s.current&&(P(r),E("ok"))}).catch(()=>{s.current&&E("err")})},[]);const f=a.useMemo(()=>{const r=new Map;for(const R of v)r.set(R.visitorId,R.visitorName);return r},[v]),D=a.useCallback(async()=>{B(!0),y(null);try{const r=await Xe();s.current&&d(r)}catch(r){s.current&&y(Q(t,r))}finally{s.current&&B(!1)}},[t]);a.useEffect(()=>{D()},[D]);const $=a.useMemo(()=>x.map(r=>{const R=v.find(O=>O.visitorId===r);return{visitorId:r,name:R?R.visitorName:t("visitorPickerUnknownVisitor"),muted:!R}}),[x,v,t]);function U(r){o(R=>R.includes(r)?R.filter(O=>O!==r):[...R,r])}const Z=N===1?S.trim().length>0:N===2?x.length>0:!0;function Y(){if(!(N>=3)){if(!Z){z(!0);return}z(!1),g(N+1),l("")}}function q(){N<=1||(z(!1),g(N-1))}function _(){w(null),T(null),c(""),o(F?[F]:[]),y(null),g(1),l(""),z(!1)}function b(r){w(null),T(r.id),c(r.displayName);const R=F&&!r.visitorIds.includes(F)?[...r.visitorIds,F]:[...r.visitorIds];o(R),y(null),g(1),l(""),z(!1)}async function K(){if(!(!S.trim()||x.length===0)){I(!0),y(null);try{if(k===null?await Os({displayName:S.trim(),visitorIds:x}):await Vs(k,{displayName:S.trim(),visitorIds:x}),!s.current)return;_(),await D()}catch(r){if(!s.current)return;y(Q(t,r))}finally{s.current&&I(!1)}}}async function W(r){I(!0),y(null);try{if(await Us(r),!s.current)return;w(null),k===r&&_(),await D()}catch(R){if(!s.current)return;y(Q(t,R))}finally{s.current&&I(!1)}}const X=[{key:1,label:t("memberTemplateStepName")},{key:2,label:t("memberTemplateStepMembers")},{key:3,label:t("memberTemplateStepSave")}],ee=`${(N-1)/2*100}%`;return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t(k!==null?"memberTemplateUpdate":"memberTemplateFormNew")}),k!==null&&e.jsx("button",{type:"button",className:"secondary",onClick:_,style:{fontSize:12},children:t("memberTemplateCancelEdit")})]}),e.jsxs("div",{className:"mdocs-wizard-progress",children:[e.jsx("div",{className:"mdocs-wizard-progress-track",children:e.jsx("div",{className:"mdocs-wizard-progress-fill",style:{width:ee}})}),e.jsx("div",{className:"mdocs-wizard-progress-steps",children:X.map(r=>{const R=N===r.key,O=N>r.key;return e.jsxs("div",{className:"mdocs-wizard-step-indicator",children:[e.jsx("div",{className:`mdocs-wizard-step-circle${R?" current":""}${O?" done":""}`,children:O?"✓":r.key}),e.jsx("span",{className:`mdocs-wizard-step-label${R?" current":""}${O?" done":""}`,children:r.label})]},r.key)})})]}),A&&e.jsx("div",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)",marginBottom:12,marginTop:12},children:A}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-wizard-card",children:[N===1&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx("input",{className:"mdocs-wizard-name-input",value:S,onChange:r=>c(r.target.value),placeholder:t("memberTemplateNamePlaceholder"),maxLength:200,disabled:h,autoFocus:!0,"aria-invalid":M&&!S.trim()}),M&&!S.trim()&&e.jsx("p",{className:"mdocs-wizard-hint",style:{color:"var(--mdocs-danger)"},children:t("domainNameRequired")})]}),N===2&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx(pt,{visitors:v,loadState:C,searchFilter:m,onSearchChange:l,selectedIds:new Set(x),onToggle:U,selectedRows:$,myVisitorId:F}),e.jsx("p",{className:`mdocs-wizard-hint${M&&x.length===0?" danger":""}`,children:"💡 "+t("memberTemplateStep2Hint")})]}),N===3&&e.jsx("div",{className:"mdocs-wizard-step-content",children:e.jsxs("div",{className:"mdocs-wizard-preview-card",children:[e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateNameLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:S})]}),e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateIdsLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:t("memberTemplateSelectedSummary",{count:String(x.length)})})]}),x.length>0&&e.jsxs("div",{className:"mdocs-wizard-preview-tags",children:[x.slice(0,15).map(r=>e.jsx("span",{className:"mdocs-wizard-preview-tag",children:Ge(r)},r)),x.length>15&&e.jsxs("span",{className:"mdocs-wizard-preview-tag mdocs-wizard-preview-tag-more",children:["+",x.length-15]})]})]})}),e.jsxs("div",{className:"mdocs-wizard-footer",children:[e.jsxs("button",{type:"button",className:"secondary",onClick:q,children:["← ",t("memberTemplateWizardBack")]}),N<3?e.jsxs("button",{type:"button",className:"primary",onClick:Y,children:[t("memberTemplateWizardNext")," →"]}):e.jsx("button",{type:"button",className:"primary",onClick:()=>void K(),children:t(h?"saving":k===null?"memberTemplateCreate":"memberTemplateUpdate")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("memberTemplateSavedList")}),p?e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")}):j.length===0?e.jsxs("div",{className:"mdocs-member-template-empty",children:[e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateEmpty")}),k===null&&e.jsx("button",{type:"button",className:"primary",onClick:_,children:t("memberTemplateEmptyAction")})]}):e.jsx("ul",{className:"mdocs-member-template-list",children:j.map(r=>e.jsx("li",{className:"mdocs-member-template-row",children:u===r.id?e.jsxs("div",{className:"mdocs-member-template-confirm-row",children:[e.jsx("span",{className:"mdocs-member-template-confirm-text",children:t("memberTemplateConfirmDeleteDesc",{name:r.displayName})}),e.jsxs("div",{className:"mdocs-member-template-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",style:{color:"var(--mdocs-danger)"},onClick:()=>void W(r.id),children:t(h?"saving":"memberTemplateConfirmDeleteSubmit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>w(null),children:t("memberTemplateConfirmDeleteCancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-member-template-row-head",children:[e.jsx("strong",{children:r.displayName}),e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateCount",{count:String(r.visitorIds.length)})}),r.visitorIds.length>0&&e.jsx("div",{className:"mdocs-member-template-tags mdocs-member-template-tags-scroll",children:r.visitorIds.map(R=>e.jsx("span",{className:"mdocs-member-template-tag",children:f.get(R)??Ge(R)},R))})]}),e.jsxs("div",{className:"mdocs-member-template-row-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>b(r),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>w(r.id),children:t("memberTemplateDelete")})]})]})},r.id))})]})]})]})}const kt=[{value:"deepseek-flash",label:"deepseek-flash(V4.1 Flash)"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro(将路由至 Flash)"}],wt=[{value:"openai-completions",label:"OpenAI 兼容"},{value:"anthropic-messages",label:"Anthropic 兼容"}];function St(t,s,j){return t==="deepseek"?"Deepseek":s||j}function He(t){return`${St(t.kind,t.providerId,t.name)} · ${t.modelId} · ${t.name}`}function Ct(){const{t}=ie(),s=a.useRef(!0),[j,d]=a.useState(""),[p,B]=a.useState([]),[u,w]=a.useState(null),[N,g]=a.useState(null),[k,T]=a.useState("deepseek"),[S,c]=a.useState(""),[x,o]=a.useState(""),[h,I]=a.useState(""),[A,y]=a.useState("openai-completions"),[M,z]=a.useState("deepseek-flash"),[F,v]=a.useState(1e6),[P,C]=a.useState(""),[E,m]=a.useState(!1),[l,f]=a.useState(null),[D,$]=a.useState(!1),[U,Z]=a.useState(!0),[Y,q]=a.useState(!1),[_,b]=a.useState(null),[K,W]=a.useState(!1),[X,ee]=a.useState(!1),[r,R]=a.useState(!1),[O,ce]=a.useState(null),[me,oe]=a.useState(null),re=a.useRef(!1);a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]);const se=a.useCallback(async()=>{const i=await Ws();if(s.current)return B(i),i},[]);function te(){g(null),T("deepseek"),c(""),o(""),I(""),y("openai-completions"),z("deepseek-flash"),v(1e6),C(""),m(!1),f(null),$(!1),ee(!1),R(!1),b(null),W(!1)}function ue(i){g(i.id),T(i.kind),c(i.name),o(i.providerId??""),I(i.baseUrl),y(i.apiType);const V=i.modelId.trim(),ge=new Set(["deepseek-flash","deepseek-v4-flash","deepseek-v4-flash-vision-exp","deepseek-v4.1-flash","deepseek-v4.1-flash-expires-on-0910"]);z(i.kind==="deepseek"?V==="deepseek-v4-pro"?"deepseek-v4-pro":ge.has(V)?"deepseek-flash":V||"deepseek-flash":V),v(i.contextWindow||1e6),m(i.hasApiKey),f(i.apiKeyMasked),C(""),$(i.isDefault)}a.useEffect(()=>{(async()=>{try{const i=await _s();if(!s.current)return;d(i.visitorName);const V=await se();if(!s.current||!V)return;V.length===0&&(te(),w("create"))}catch(i){if(!s.current)return;b(i instanceof Error?i.message:String(i)),w("create")}finally{s.current&&Z(!1)}})()},[se]);function je(){te(),w("create")}function he(i){ue(i),w("edit"),W(!1),b(null)}function ae(){te(),w(null)}async function ye(i){if(!(i.isDefault||me)){oe(i.id),b(null);try{await Gs(i.id),await se()}catch(V){if(!s.current)return;b(V instanceof Error?V.message:String(V))}finally{s.current&&oe(null)}}}async function pe(){if(O){q(!0),b(null);try{await Js(O.id);const i=await se();if(!s.current)return;u==="edit"&&N===O.id&&ae(),((i==null?void 0:i.length)??0)===0&&(te(),w("create"))}catch(i){if(!s.current)return;b(i instanceof Error?i.message:String(i))}finally{s.current&&(q(!1),ce(null))}}}async function be(){q(!0),b(null),W(!1);try{const i=k==="custom"?{...u==="edit"&&N?{id:N}:{},...u==="create"&&D?{isDefault:!0}:{},kind:k,baseUrl:h,modelId:M,providerId:x.trim()||void 0,apiType:A,name:S,contextWindow:F,...P.trim()?{apiKey:P.trim()}:{}}:{...u==="edit"&&N?{id:N}:{},...u==="create"&&D?{isDefault:!0}:{},kind:k,modelId:M,name:S,contextWindow:F,...P.trim()?{apiKey:P.trim()}:{}};if(await Hs(i),!s.current)return;await se(),W(!0),w(null),te()}catch(i){if(!s.current)return;b(i instanceof Error?i.message:String(i))}finally{s.current&&q(!1)}}const Ne=u!==null;return e.jsxs("div",{className:"mdocs-agent-config-panel",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t("agentConfig")}),U?null:e.jsx("button",{type:"button",className:"secondary",onClick:je,children:"添加配置"})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[!U&&p.length>0?e.jsxs("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:[e.jsx("p",{className:"mdocs-agent-config-lead",children:"选择默认配置后,智能助手与帮写将使用该模型。"}),e.jsx("ul",{className:"mdocs-agent-config-list",children:p.map(i=>e.jsxs("li",{className:"mdocs-agent-config-item",children:[e.jsxs("label",{className:"mdocs-agent-config-item-default",children:[e.jsx("input",{type:"radio",name:"agent-default-config",checked:i.isDefault,disabled:me!==null,onChange:()=>void ye(i)}),e.jsx("span",{children:i.isDefault?"默认":"设为默认"})]}),e.jsxs("div",{className:"mdocs-agent-config-item-main",children:[e.jsx("strong",{children:He(i)}),i.kind==="custom"?e.jsx("span",{className:"mdocs-agent-badge",children:"自定义"}):null,e.jsx("p",{className:"mdocs-agent-config-item-meta",children:i.hasApiKey?`Key ${i.apiKeyMasked??"已配置"}`:"未配置 Key"})]}),e.jsxs("div",{className:"mdocs-agent-config-item-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>he(i),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>ce(i),children:"删除"})]})]},i.id))}),K?e.jsx("p",{className:"mdocs-agent-config-ok",children:t("saved")}):null,_?e.jsx("p",{className:"mdocs-agent-config-error",children:_}):null]}):null,Ne?e.jsxs("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:[e.jsxs("p",{className:"mdocs-agent-config-lead",children:[u==="create"?"新建模型配置。":"编辑模型配置。","可以保存多套,勾选一条作为默认。智能助手和帮写使用默认那套。"]}),e.jsxs("div",{className:"mdocs-agent-form",children:[e.jsxs("div",{className:"mdocs-agent-kind-tabs",role:"tablist","aria-label":"配置方式",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":k==="deepseek",className:k==="deepseek"?"active":"",onClick:()=>T("deepseek"),children:"Deepseek"}),e.jsx("button",{type:"button",role:"tab","aria-selected":k==="custom",className:k==="custom"?"active":"",onClick:()=>T("custom"),children:"自定义"})]}),k==="deepseek"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigModel")}),e.jsx(Ve,{options:[...kt],value:M,onChange:z})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigApiKey")}),e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:X?"text":"password",value:P,onChange:i=>C(i.target.value),placeholder:E?t("agentConfigApiKeyConfigured").replace("{{masked}}",l??"…"):t("agentConfigApiKeyPlaceholder"),autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(X?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>ee(i=>!i),children:X?"隐藏":"显示"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"API 地址"}),e.jsx("input",{type:"url",value:h,onChange:i=>{const V=i.target.value;if(I(V),re.current)return;V.toLowerCase().includes("anthropic")?y("anthropic-messages"):y("openai-completions")},placeholder:"https://api.example.com/v1",className:"mdocs-agent-mono"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"Model ID"}),e.jsx("input",{type:"text",value:M,onChange:i=>z(i.target.value),placeholder:"模型名称,如 gpt-4o",className:"mdocs-agent-mono"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigApiKey")}),e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:X?"text":"password",value:P,onChange:i=>C(i.target.value),placeholder:E?t("agentConfigApiKeyConfigured").replace("{{masked}}",l??"…"):"粘贴 API Key",autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(X?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>ee(i=>!i),children:X?"隐藏":"显示"})]})]})]}),e.jsxs("details",{className:"mdocs-agent-advanced",open:r,onToggle:i=>R(i.target.open),children:[e.jsx("summary",{children:"高级选项"}),k==="custom"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"Provider ID(选填)"}),e.jsx("input",{type:"text",value:x,onChange:i=>o(i.target.value),placeholder:"不填则自动从 API 地址提取域名"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"API 协议"}),e.jsx(Ve,{options:[...wt],value:A,onChange:i=>{re.current=!0,y(i)}})]})]}):null,e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigName")}),e.jsx("input",{type:"text",value:S,onChange:i=>c(i.target.value),placeholder:t("agentConfigNameDefault").replace("{{name}}",j||"…")})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigContextWindow")}),e.jsx("input",{type:"number",min:1e3,max:2e6,step:1e3,value:F,onChange:i=>v(Number(i.target.value)||1e6)}),e.jsx("p",{className:"mdocs-agent-field-hint",children:t("agentConfigContextWindowDesc")})]})]}),u==="create"&&p.length>0?e.jsxs("label",{className:"mdocs-agent-config-default-check",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:i=>$(i.target.checked)}),e.jsx("span",{children:"保存后设为默认配置"})]}):null,_?e.jsx("p",{className:"mdocs-agent-config-error",children:_}):null,e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void be(),disabled:Y,children:t(Y?"saving":"save")}),p.length>0?e.jsx("button",{type:"button",className:"secondary",onClick:ae,disabled:Y,children:t("cancel")}):null]})]})]}):U?e.jsx("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:e.jsx("p",{className:"mdocs-agent-config-muted",children:t("loading")})}):null]}),O?e.jsx(es,{title:"删除配置",message:`确定删除「${He(O)}」?${O.isDefault&&p.length>1?" 删除后将自动把另一条设为默认。":""}`,confirmLabel:"删除",cancelLabel:t("cancel"),onConfirm:()=>void pe(),onCancel:()=>ce(null)}):null]})}const Dt=/^[A-Za-z0-9_]+$/;function Te(t){return Dt.test(t.trim())}function It(){const t=a.useRef(!0),[s,j]=a.useState([]),[d,p]=a.useState(!0),[B,u]=a.useState(null),[w,N]=a.useState(null),[g,k]=a.useState(!1),[T,S]=a.useState(""),[c,x]=a.useState(""),[o,h]=a.useState(""),[I,A]=a.useState(!1);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]);async function y(){p(!0),u(null);try{const m=await Zs();if(!t.current)return;j(m)}catch(m){if(!t.current)return;u(m instanceof Error?m.message:String(m))}finally{t.current&&p(!1)}}a.useEffect(()=>{y()},[]);function M(){k(!0),N(null),S(""),x(""),h(""),u(null)}function z(m){k(!1),N(m.id),S(m.name),x(m.description),h(m.body),u(null)}function F(){k(!1),N(null),S(""),x(""),h("")}async function v(){const m=T.trim();if(!Te(m)){u("名称仅允许英文、数字、下划线");return}if(!o.trim()){u("正文不能为空");return}A(!0),u(null);try{if(g?await Ys({name:m,description:c,body:o}):w&&await qs(w,{name:m,description:c,body:o}),!t.current)return;F(),await y()}catch(l){if(!t.current)return;u(l instanceof Error?l.message:String(l))}finally{t.current&&A(!1)}}async function P(m){if(window.confirm("删除该 Skill?已引用的历史轮次将跳过缺失项。")){u(null);try{if(await Xs(m),!t.current)return;w===m&&F(),await y()}catch(l){if(!t.current)return;u(l instanceof Error?l.message:String(l))}}}const C=g||w!==null,E=!T.trim()||Te(T);return e.jsxs("div",{className:"mdocs-agent-skills-panel",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsxs("h2",{className:"mdocs-settings-title",children:["Agent Skills",!d&&s.length>0?e.jsx("span",{className:"mdocs-agent-skills-count",children:s.length}):null]}),C?null:e.jsx("button",{type:"button",className:"secondary",onClick:M,children:"新建"})]}),e.jsx("div",{className:"mdocs-settings-cards",children:e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("p",{className:"mdocs-settings-item-desc mdocs-agent-skills-lead",children:"私人提示词宏。名称对本账号唯一,仅英文、数字、下划线;智能助手 / 帮写里按名称引用。"}),B?e.jsx("p",{className:"mdocs-agent-skills-error",children:B}):null,C?e.jsxs("div",{className:"mdocs-agent-skills-form",children:[e.jsx("div",{className:"mdocs-agent-skills-form-head",children:e.jsx("strong",{children:g?"新建 Skill":"编辑 Skill"})}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"名称"}),e.jsx("input",{type:"text",value:T,onChange:m=>S(m.target.value),maxLength:64,spellCheck:!1,autoComplete:"off",placeholder:"e.g. weekly_report",className:E?void 0:"mdocs-agent-skills-input-invalid"}),E?e.jsx("span",{className:"mdocs-agent-skills-hint",children:"引用与索引键,保存后按此名称使用"}):e.jsx("span",{className:"mdocs-agent-skills-hint-bad",children:"仅允许 A–Z、a–z、0–9、_"})]}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"简介(可选)"}),e.jsx("input",{type:"text",value:c,onChange:m=>x(m.target.value),maxLength:200,placeholder:"一句话说明用途"})]}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:o,onChange:m=>h(m.target.value),rows:10,placeholder:"写入 Agent 应遵守的步骤与约束…"})]}),e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void v(),disabled:I||!E||!T.trim()||!o.trim(),children:I?"保存中…":"保存"}),e.jsx("button",{type:"button",className:"secondary",onClick:F,disabled:I,children:"取消"})]})]}):null,d?e.jsx("p",{className:"mdocs-settings-item-desc",children:"加载中…"}):null,!d&&s.length===0&&!C?e.jsxs("div",{className:"mdocs-agent-skills-empty",children:[e.jsx("p",{children:"还没有 Skill"}),e.jsx("button",{type:"button",className:"secondary",onClick:M,children:"新建第一个"})]}):null,!d&&s.length>0?e.jsx("ul",{className:"mdocs-agent-skills-list",children:s.map(m=>{const l=Te(m.name),f=w===m.id;return e.jsxs("li",{className:"mdocs-agent-skills-item"+(f?" mdocs-agent-skills-item-active":""),children:[e.jsxs("div",{className:"mdocs-agent-skills-item-main",children:[e.jsxs("div",{className:"mdocs-agent-skills-item-title-row",children:[e.jsx("code",{className:"mdocs-agent-skills-name",children:m.name}),l?null:e.jsx("span",{className:"mdocs-agent-skills-badge-warn",title:"名称含非法字符,请编辑改为英文数字下划线",children:"需改名"})]}),e.jsx("span",{className:"mdocs-agent-skills-desc",children:m.description.trim()||"无简介"})]}),e.jsxs("div",{className:"mdocs-agent-skills-item-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>z(m),disabled:C&&!f,children:"编辑"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>void P(m.id),disabled:C,children:"删除"})]})]},m.id)})}):null]})})]})}function Je(t,s){const j=localStorage.getItem(t);return j===null?s:j==="true"}function Ze(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const j=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${s.getFullYear()}-${j}-${d}`}function Ft(t){const{t:s,lang:j,setLang:d}=ie(),{onBack:p,onPublishDraft:B}=t,u=Qs(),[w,N]=a.useState(!1),g=a.useRef(!0);a.useEffect(()=>(g.current=!0,()=>{g.current=!1}),[]),a.useEffect(()=>{u||N(!1)},[u]);const[k,T]=a.useState(()=>Je("mdocs.autoPublish",!1)),[S,c]=a.useState(()=>Je("mdocs.autoEdit",!0)),[x,o]=a.useState(!1),[h,I]=a.useState("general");function A(n){I(n),u&&N(!1)}const y=s(h==="general"?"general":h==="bookmarks"?"bookmarkTitle":h==="myDocuments"?"myDocuments":h==="domainManagement"?"domainManagement":h==="memberTemplates"?"memberTemplates":h==="agentConfig"?"agentConfig":"saveAndPublish"),[M,z]=a.useState([]),[F,v]=a.useState(!0),[P,C]=a.useState(null),[E,m]=a.useState(!1),[l,f]=a.useState(!1),[D,$]=a.useState(!1),[U,Z]=a.useState(!1),[Y,q]=a.useState(null),[_,b]=a.useState(!1),[K,W]=a.useState(!1),[X,ee]=a.useState(!1),[r,R]=a.useState(""),[O,ce]=a.useState(!1),[me,oe]=a.useState(!1),[re,se]=a.useState(0),[te,ue]=a.useState([]),[je,he]=a.useState(!1),[ae,ye]=a.useState(""),[pe,be]=a.useState([]),[Ne,i]=a.useState(!1),[V,ge]=a.useState(""),[le,ts]=a.useState(0),[Me,Ee]=a.useState("1"),[Re,as]=a.useState(0),[ve,ns]=a.useState(""),[ke,is]=a.useState(""),[fe,cs]=a.useState(""),[ls,os]=a.useState(null),[rs,ds]=a.useState([]),we=20,[Le,ms]=a.useState([]),[us,Se]=a.useState(!1),[Ce,Fe]=a.useState(null),[De,ze]=a.useState(new Map);a.useEffect(()=>{localStorage.setItem("mdocs.autoPublish",String(k))},[k]),a.useEffect(()=>{localStorage.setItem("mdocs.autoEdit",String(S))},[S]),a.useEffect(()=>{h==="savePublish"&&Pe().then(n=>{g.current&&se(n.filter(L=>!L.published).length)})},[h]),a.useEffect(()=>{h==="bookmarks"&&hs(),h==="myDocuments"&&(de(),Qe().then(n=>{g.current&&ds(n)}).catch(()=>{}))},[h,ve,ke,fe]),a.useEffect(()=>{Be()},[]),a.useEffect(()=>{qe().then(n=>{g.current&&ms(n)}).catch(()=>{})},[]);const xe=new Map(Le.map(n=>[n.domainId,n.domainName]));async function Be(){try{v(!0);const n=await et();if(!g.current)return;z(n)}catch{}finally{g.current&&v(!1)}}async function hs(){try{he(!0);const n=await st();if(!g.current)return;ue(n)}catch{}finally{g.current&&he(!1)}}async function de(n=0){try{i(!0);const L=await tt({offset:n*we,limit:we,domainId:ve||void 0,creatorVisitorId:ke||void 0,groupBy:fe||void 0});if(!g.current)return;be(L.items),os(L.groups??null),as(L.total),ts(n),Ee(String(n+1))}catch{}finally{g.current&&i(!1)}}async function ps(n){try{await rt(n),ue(L=>L.filter(H=>H.documentId!==n))}catch{}}function gs(){if(M.some(L=>!L.revoked)){f(!0);return}$e()}async function $e(){try{m(!0);const n=await mt();C({token:n.token,name:n.name}),await Be()}finally{m(!1)}}async function fs(){try{ee(!0);const n=await lt();q(n.recoveryCode)}finally{ee(!1)}}async function xs(n){n.preventDefault();const L=r.trim();if(!(L&&L.length<4))try{ce(!0),await ot(L),R(""),oe(!0),setTimeout(()=>oe(!1),3e3)}finally{ce(!1)}}async function js(n){Fe(n);try{const L=await dt(n),H=new Map;L.forEach(G=>{H.set(G.visitorId,G.permission)}),ze(H)}catch{ze(new Map)}Se(!0)}async function ys(n){if(Ce)try{const L=new Set(n.map(G=>G.visitorId)),H=new Set(De.keys());for(const G of H)L.has(G)||await ut(Ce,G);for(const G of n)await ht(Ce,G.visitorId,G.permission);await de()}finally{Se(!1),Fe(null)}}const Ke=te.filter(n=>{if(!ae.trim())return!0;const L=ae.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(L)||(n.ownerVisitorName||"").toLowerCase().includes(L)||(n.domainId||"").toLowerCase().includes(L)}),ne=Math.ceil(Re/we);return e.jsxs("div",{className:"mdocs-layout"+(u?" mdocs-layout--reader mdocs-layout--settings":""),children:[u&&w?e.jsx("button",{type:"button",className:"mdocs-mobile-nav-scrim","aria-label":s("collapseSidebar"),onClick:()=>N(!1)}):null,e.jsxs("aside",{className:"mdocs-sidebar"+(u?w?" mdocs-sidebar--drawer-open":" mdocs-sidebar--drawer":""),children:[e.jsxs("header",{className:"mdocs-sidebar-header",children:[e.jsxs("div",{className:"mdocs-brand",children:[e.jsx("img",{src:at,alt:s("brand"),className:"mdocs-brand-logo"}),e.jsx("span",{children:s("brand")})]}),u?e.jsx("button",{type:"button",className:"mdocs-sidebar-toggle",onClick:()=>N(!1),"aria-label":s("collapseSidebar"),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(nt,{size:18})}):null]}),e.jsxs("nav",{className:"mdocs-config-tree",children:[e.jsx("div",{className:"mdocs-config-item"+(h==="general"?" active":""),onClick:()=>A("general"),children:s("general")}),e.jsx("div",{className:"mdocs-config-item"+(h==="bookmarks"?" active":""),onClick:()=>A("bookmarks"),children:s("bookmarkTitle")}),e.jsx("div",{className:"mdocs-config-item"+(h==="myDocuments"?" active":""),onClick:()=>A("myDocuments"),children:s("myDocuments")}),e.jsx("div",{className:"mdocs-config-item"+(h==="domainManagement"?" active":""),onClick:()=>A("domainManagement"),children:s("domainManagement")}),e.jsx("div",{className:"mdocs-config-item"+(h==="memberTemplates"?" active":""),onClick:()=>A("memberTemplates"),children:s("memberTemplates")}),e.jsx("div",{className:"mdocs-config-item"+(h==="agentConfig"?" active":""),onClick:()=>A("agentConfig"),children:s("agentConfig")}),e.jsx("div",{className:"mdocs-config-item"+(h==="savePublish"?" active":""),onClick:()=>A("savePublish"),children:s("saveAndPublish")})]}),e.jsx("footer",{className:"mdocs-settings-sidebar-footer",onClick:p,children:s("backToDocs")})]}),e.jsxs("main",{className:"mdocs-main",children:[u?e.jsxs("div",{className:"mdocs-settings-mobile-bar",children:[e.jsx("button",{type:"button",className:"mdocs-reader-nav-btn",onClick:()=>N(!0),"aria-label":s("expandSidebar"),children:e.jsx(it,{size:18,strokeWidth:1.75})}),e.jsx("span",{className:"mdocs-settings-mobile-bar-title",children:y})]}):null,ct(),h==="general"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("general")})}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsx("span",{className:"mdocs-settings-item-info",children:e.jsx("span",{className:"mdocs-settings-card-title",children:s("language")})}),e.jsxs("span",{className:"mdocs-settings-lang",children:[e.jsx("button",{type:"button",className:j==="en"?"active":"",onClick:()=>d("en"),children:"EN"}),e.jsx("span",{children:"/"}),e.jsx("button",{type:"button",className:j==="zh"?"active":"",onClick:()=>d("zh"),children:"中"})]})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoEdit")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoEditDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(S?" active":""),role:"switch","aria-checked":S,onClick:()=>c(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliToken")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("cliTokenDesc")}),!F&&M.length>0&&e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8,fontSize:"0.85em",opacity:.8},children:M.map(n=>e.jsxs("span",{style:{display:"block"},children:[n.name," — ",new Date(n.createdAt).toLocaleString()," ",n.revoked?`(${s("cliTokenRevoked")})`:`(${s("cliTokenActive")})`]},n.tokenId))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:gs,disabled:E||F,children:E?"…":M.some(n=>!n.revoked)?s("cliTokenReset"):s("cliTokenCreate")})]}),P&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--ok",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliTokenGenerated")}),e.jsx("span",{className:"mdocs-settings-secret-value",children:P.token})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(P.token),Z(!1),$(!0),window.setTimeout(()=>$(!1),2e3)}catch{$(!1),Z(!0),window.setTimeout(()=>Z(!1),3e3)}})()},children:s(D?"cliTokenCopied":"cliTokenCopy")}),e.jsx("button",{type:"button",onClick:()=>C(null),children:s("close")})]}),D&&e.jsxs("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:["✓ ",s("cliTokenCopied")]}),U&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:s("cliTokenCopyFailed")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"当 Token 丢失时,可用恢复码找回身份。生成后请立即保存,仅显示一次。"})]}),e.jsx("button",{type:"button",className:"secondary",onClick:fs,disabled:X,children:X?"…":"生成恢复码"})]}),Y&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--warn",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 你的恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8},children:"请立即复制保存,关闭后不可再查看。"}),e.jsx("div",{className:"mdocs-settings-secret-code",children:Y})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(Y),W(!1),b(!0),window.setTimeout(()=>b(!1),2e3)}catch{b(!1),W(!0),window.setTimeout(()=>W(!1),3e3)}})()},children:_?"已复制":"复制恢复码"}),e.jsx("button",{type:"button",onClick:()=>q(null),children:s("close")})]}),_&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:"✓ 已复制到剪贴板"}),K&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:"复制失败,请手动选中上方内容复制"})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-item",children:e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔐 登录密码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"设置密码后,可在其他浏览器或设备用「用户名+密码」登录。"})]})}),e.jsxs("form",{onSubmit:xs,style:{marginTop:12},children:[e.jsx("input",{type:"password",placeholder:"输入新密码(至少 4 位,留空则清除密码)",value:r,onChange:n=>R(n.target.value),minLength:0,style:{marginBottom:8}}),me&&e.jsx("div",{style:{color:"#4caf50",marginBottom:8,fontSize:"0.875rem"},children:"✓ 密码设置成功"}),e.jsx("button",{type:"submit",className:"secondary",disabled:O,children:O?"设置中…":"保存密码"})]})]})]})]}):h==="bookmarks"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("bookmarkTitle")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:s("bookmarkSearch"),value:ae,onChange:n=>ye(n.target.value)}),je?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:Ke.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(ae?"bookmarkNoMatch":"bookmarkEmpty")}):e.jsx("div",{className:"mdocs-settings-table-wrap",children:e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("bookmarkColTitle")}),e.jsx("th",{children:s("bookmarkColDomain")}),e.jsx("th",{children:s("bookmarkColAuthor")}),e.jsx("th",{children:s("bookmarkColTime")}),e.jsx("th",{style:{textAlign:"right"}})]})}),e.jsx("tbody",{children:Ke.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:n.isDeleted?e.jsx("span",{style:{opacity:.5,fontStyle:"italic"},children:"已删除"}):xe.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:n.ownerVisitorName||"—"}),e.jsx("td",{children:new Date(n.bookmarkedAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>ps(n.documentId),children:s("bookmarkRemove")})})]},n.documentId))})]})})})]})]}):h==="myDocuments"?e.jsxs("div",{className:"mdocs-settings mdocs-my-docs",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("myDocuments")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-my-docs-toolbar",children:[e.jsxs("div",{className:"mdocs-my-docs-search",children:[e.jsx(xt,{size:16,strokeWidth:2,"aria-hidden":"true"}),e.jsx("input",{type:"text",placeholder:"搜索文章…",value:V,onChange:n=>ge(n.target.value)})]}),e.jsxs("select",{className:"mdocs-my-docs-select",value:ve,"aria-label":s("myDocumentsFilterDomain"),onChange:n=>ns(n.target.value),children:[e.jsx("option",{value:"",children:s("myDocumentsFilterAllDomains")}),Le.map(n=>e.jsx("option",{value:n.domainId,children:xe.get(n.domainId)||n.domainName},n.domainId))]}),e.jsxs("select",{className:"mdocs-my-docs-select",value:ke,"aria-label":s("myDocumentsFilterCreator"),onChange:n=>is(n.target.value),children:[e.jsx("option",{value:"",children:s("myDocumentsFilterAllCreators")}),rs.map(n=>e.jsx("option",{value:n.visitorId,children:n.visitorName},n.visitorId))]}),e.jsxs("select",{className:"mdocs-my-docs-select",value:fe,"aria-label":s("myDocumentsGroupBy"),onChange:n=>cs(n.target.value),children:[e.jsx("option",{value:"",children:s("myDocumentsGroupNone")}),e.jsx("option",{value:"domain",children:s("myDocumentsGroupDomain")}),e.jsx("option",{value:"creator",children:s("myDocumentsGroupCreator")})]})]}),Ne?e.jsx("div",{className:"mdocs-my-docs-empty",children:s("loading")}):e.jsxs(e.Fragment,{children:[pe.length===0?e.jsx("div",{className:"mdocs-my-docs-empty",children:s(V?"myDocumentsNoMatch":"myDocumentsEmpty")}):e.jsx("div",{className:"mdocs-settings-table-wrap",children:e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("myDocumentsColTitle")}),e.jsx("th",{children:s("myDocumentsColDomain")}),e.jsx("th",{children:s("myDocumentsColCreator")}),e.jsx("th",{children:s("myDocumentsColUpdated")}),e.jsx("th",{children:s("myDocumentsColCreated")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:(ls??[{key:"",items:pe}]).flatMap(n=>{var G;const L=n.key?e.jsx("tr",{className:"mdocs-my-docs-group",children:e.jsx("td",{colSpan:6,children:fe==="domain"?xe.get(n.key)||n.key:((G=n.items[0])==null?void 0:G.creatorName)||n.key})},`group-${n.key}`):null,H=n.items.map(J=>e.jsxs("tr",{children:[e.jsx("td",{className:"mdocs-my-docs-title",onClick:()=>t.onOpenDocument(J.documentId),children:J.displayName||J.relativePath||"Untitled"}),e.jsx("td",{children:xe.get(J.domainId||"")||J.domainId||"—"}),e.jsx("td",{children:J.creatorName||J.creatorVisitorId||"—"}),e.jsx("td",{className:"mdocs-my-docs-date",children:Ze(J.updatedAt)}),e.jsx("td",{className:"mdocs-my-docs-date",children:Ze(J.createdAt)}),e.jsxs("td",{className:"mdocs-my-docs-actions",children:[e.jsx("button",{type:"button",className:"ghost small",onClick:()=>js(J.documentId),children:s("docInfoInviteMember")}),e.jsx("button",{type:"button",className:"primary small",onClick:()=>t.onOpenDocument(J.documentId),children:s("bookmarkOpen")})]})]},J.documentId));return L?[L,...H]:H})})]})}),e.jsxs("div",{className:"mdocs-my-docs-footer",children:[e.jsx("span",{className:"mdocs-settings-page-info",children:s("myDocumentsPageInfo",{current:String(ne>0?le+1:0),total:String(ne),count:String(Re)})}),ne>1&&e.jsxs("form",{className:"mdocs-my-docs-jump",onSubmit:n=>{n.preventDefault();const L=Number.parseInt(Me,10);if(!Number.isFinite(L))return;const H=Math.min(Math.max(L,1),ne)-1;H!==le&&de(H)},children:[e.jsx("span",{children:s("myDocumentsJumpTo")}),e.jsx("input",{type:"number",inputMode:"numeric",min:1,max:ne,"aria-label":s("myDocumentsJumpTo"),value:Me,onChange:n=>Ee(n.target.value)}),e.jsx("button",{type:"submit",className:"secondary small",children:s("myDocumentsJump")})]}),ne>1&&e.jsxs("div",{className:"mdocs-settings-pagination",children:[e.jsx("button",{type:"button",className:"secondary small",disabled:le<=0,onClick:()=>de(le-1),children:s("myDocumentsPrev")}),e.jsx("button",{type:"button",className:"secondary small",disabled:le>=ne-1,onClick:()=>de(le+1),children:s("myDocumentsNext")})]})]})]})]})]}):h==="domainManagement"?e.jsx(Nt,{}):h==="memberTemplates"?e.jsx(vt,{}):h==="agentConfig"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx(Ct,{}),e.jsx(It,{})]}):e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:s("saveAndPublish")}),e.jsx("button",{type:"button",className:"secondary",onClick:p,children:s("backToDocs")})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoSave")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoSaveAlwaysOnDesc")})]}),e.jsx("span",{className:"mdocs-toggle active",role:"switch","aria-checked":"true","aria-disabled":"true",style:{opacity:.6,cursor:"not-allowed"},children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoPublish")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoPublishDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(k?" active":""),role:"switch","aria-checked":k,onClick:()=>T(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),re>0?e.jsxs("button",{className:"mdocs-settings-card mdocs-settings-draft-link",onClick:()=>o(!0),children:[e.jsxs("span",{className:"mdocs-settings-draft-link-text",children:["📄 ",s("viewDrafts")," (",re,")"]}),e.jsx("span",{className:"mdocs-settings-draft-arrow","aria-hidden":"true",children:"›"})]}):e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:s("noDrafts")})})]})]}),x&&e.jsx(yt,{onPublish:B,onClose:()=>o(!1),onCountChange:se,onRecover:t.onRecoverDraft})]}),l&&e.jsx(es,{title:s("cliToken"),message:s("cliTokenResetConfirm"),confirmLabel:s("cliTokenReset"),cancelLabel:s("cancel"),busy:E,onConfirm:()=>{f(!1),$e()},onCancel:()=>f(!1)}),e.jsx(ss,{open:us,title:s("docInfoInviteMember"),initialSelectedIds:[...De.keys()],initialPermissions:De,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:s("invitePermissionRead")},{value:"edit",label:s("invitePermissionEdit")}],onClose:()=>Se(!1),onConfirm:n=>{ys(n)}})]})}export{Ft as SettingsPage};