@fgbg/mdocs 1.3.31 → 1.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/agent-skills/changelog/SKILL.md +6 -0
- package/dist/server/agent/Agent/run.js +2 -2
- package/dist/server/agent/Agent/run.js.map +1 -1
- package/dist/server/agent/Agent/system-prompt.js +7 -5
- package/dist/server/agent/Agent/system-prompt.js.map +1 -1
- package/dist/server/agent/Agent/tool-call-ui.js +1 -0
- package/dist/server/agent/Agent/tool-call-ui.js.map +1 -1
- package/dist/server/agent/Agent/tool-ui-effects.js +28 -7
- package/dist/server/agent/Agent/tool-ui-effects.js.map +1 -1
- package/dist/server/agent/Agent/tools-registry.js +2 -2
- package/dist/server/agent/Agent/tools-registry.js.map +1 -1
- package/dist/server/agent/Agent/tools-registry.test.js +1 -1
- package/dist/server/agent/Agent/tools-registry.test.js.map +1 -1
- package/dist/server/agent/Agent/tools-template.js +3 -2
- package/dist/server/agent/Agent/tools-template.js.map +1 -1
- package/dist/server/agent/Agent/tools-thinking.js +33 -0
- package/dist/server/agent/Agent/tools-thinking.js.map +1 -0
- package/dist/server/agent/Config/config.js +31 -0
- package/dist/server/agent/Config/config.js.map +1 -1
- package/dist/server/db/repositories/agent-model-config.repo.js +6 -4
- package/dist/server/db/repositories/agent-model-config.repo.js.map +1 -1
- package/dist/server/db/schema.js +10 -0
- package/dist/server/db/schema.js.map +1 -1
- package/dist/server/routes/agent.routes.js +1 -0
- package/dist/server/routes/agent.routes.js.map +1 -1
- package/dist/web/assets/{AgentChatPanel-e1h0rqbg.js → AgentChatPanel-BJ49TwV5.js} +2 -2
- package/dist/web/assets/{AiWriteWorkbench-Dq0aCk5c.js → AiWriteWorkbench-B7MnIKzJ.js} +1 -1
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-DHC7qgkW.js → DiagramEditor-NtNY3sZL-D12WH5JY.js} +1 -1
- package/dist/web/assets/{DocChrome-7KIXAHsE.js → DocChrome-CjNrjXnZ.js} +1 -1
- package/dist/web/assets/{DocumentEditor-CmIk_VBn.js → DocumentEditor-BcktjJUV.js} +1 -1
- package/dist/web/assets/{HtmlEditor-REIKOoam.js → HtmlEditor-D-H5FPUP.js} +1 -1
- package/dist/web/assets/{MergeView-DCgxAslc.js → MergeView-a2_gRrrh.js} +1 -1
- package/dist/web/assets/{PlaygroundPage-Cz9TMo7h.js → PlaygroundPage-BXmSDi40.js} +1 -1
- package/dist/web/assets/SettingsPage-xJkP4WaU.js +21 -0
- package/dist/web/assets/{SheetEditor-Bkxxf3ly.js → SheetEditor-BV3loL4j.js} +1 -1
- package/dist/web/assets/{Toolbar-ClbpubYi.js → Toolbar-Caimz2EG.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-D4xmZbNY.js → VisitorPickerModal-BiMxEHCX.js} +1 -1
- package/dist/web/assets/{check-CuLfkkz7.js → check-IPzs2Va9.js} +1 -1
- package/dist/web/assets/{copy-CjAdouag.js → copy-Bp0JPDN6.js} +1 -1
- package/dist/web/assets/{index-DAhW-QRN.js → index-DHKGh7I3.js} +2 -2
- package/dist/web/assets/{italic-cqqPz-_Q.js → italic-BOhgURiY.js} +1 -1
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-CNHknbe2.js → meta2dEngine-BD2XbzaV-Bjx9jCbC.js} +1 -1
- package/dist/web/assets/{plus-DkLh2brQ.js → plus-BMAfiGed.js} +1 -1
- package/dist/web/assets/{react-Dj2vqPq5.js → react-BiN5Ertc.js} +3 -3
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/SettingsPage-DsLbUPt-.js +0 -21
package/dist/web/assets/{meta2dEngine-BD2XbzaV-CNHknbe2.js → meta2dEngine-BD2XbzaV-Bjx9jCbC.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as D,W as _}from"./react-
|
|
1
|
+
import{T as D,W as _}from"./react-BiN5Ertc.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-DP4Vt_ZE.js";import"./react-vendor-BVS1XoFi.js";import"./editor-DBWWidi3.js";import"./ui-CEFkTVnG.js";import"./motion-BAXVQJfN.js";import"./diagram-BF8g9yg4.js";import"./index-DHKGh7I3.js";import"./plus-BMAfiGed.js";import"./copy-Bp0JPDN6.js";import"./check-IPzs2Va9.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,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/scss-OYdSNvt2.js","assets/vue-DVfSmUF7.js","assets/typescript-BPQ3VLAy.js","assets/json-Cp-IABpG.js","assets/svelte-DZMnMd3x.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-BGX7qA9Y.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/shellscript-Yzrsuije.js","assets/lua-BaeVxFsk.js","assets/yaml-Buea-lGh.js","assets/php-Dhbhpdrm.js","assets/shellsession-BADoaaVG.js","assets/nginx-BpAMiNFr.js","assets/meta2dEngine-BD2XbzaV-
|
|
2
|
-
var x7=Object.defineProperty;var k7=(e,t,n)=>t in e?x7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>k7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,af as w7,ag as v7,ah as S7,ai as Dn,aj as Xh,ak as Em,al as C7,j as O,b as Pi,am as _7,an as E7,ao as T7,ap as A7,z as M7,C as Jh,aq as N7,ar as D7,as as I7,at as L7}from"./react-vendor-BVS1XoFi.js";import{P as ze,e as Yh,A as ru,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Bi,$ as ce,O as Ln,G as pr,d as gs,l as gd,z as Sn,r as gt,v as nb,B as je,X as Fn,T as rb,M as Il,L as Ai,W as ml,f as hi,g as bs,h as So,C as Zh,Y as ib,y as Pt,i as Ll,H as Xe,j as F7,t as O7,m as Lo,J as bn,o as sb,R as fi,S as iu,Q as Zn,q as ob,s as z7,u as Aa,x as mt,E as R7,D as yc,I as P7,K as B7,_ as $7,N as su,U as bd,Z as ys,a0 as Co,a1 as Tt,a2 as ab,a3 as yn,a4 as j7,a5 as q7,a6 as Hr,a7 as Li,a8 as Fl,a9 as _n,aa as yd,ab as H7,ac as ub,ad as xd,ae as kd,af as _o,V as hn,ag as lb,ah as Qh,ai as U7,aj as cb,ak as W7,al as K7,am as V7,an as G7,ao as hb,ap as Qn,aq as X7,ar as jr,as as qn,at as xs,au as Tm,av as Am,aw as J7,ax as Y7,ay as Z7,az as Q7,aA as Ma,aB as fb,aC as db,aD as aa,aE as Na,aF as ou,aG as ek,aH as ef,aI as Mm,aJ as tk,aK as nk,aL as pb,aM as rk,aN as ik,aO as sk,aP as wd,aQ as Rr,aR as Eo,aS as vd,aT as ma,aU as fs,aV as Da,aW as tf,aX as Nm,aY as ga,aZ as gl,a_ as Ol,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as ck,b4 as Pr,b5 as hk,b6 as fk,b7 as dk,b8 as Dm,b9 as bl,ba as Im,bb as pk,bc as mk,bd as gk,be as bk,bf as ks,bg as Lm,bh as nf,bi as yk,bj as xk,bk as kk,bl as wk,bm as Fm,bn as ii,bo as Ia,bp as rf,bq as vk,br as ua,bs as mb,bt as gb,bu as bb,bv as yb,bw as xb,bx as Sk,by as Ck,bz as Sd,bA as kb,bB as _k,bC as Ek,bD as Cd,bE as Tk,bF as sf,bG as wb,bH as vb,bI as Ak,bJ as Mk,bK as Ju,bL as Sb,bM as Nk,bN as Dk,bO as Ik,bP as Cb,bQ as Lk,bR as Fk,bS as _b,bT as zl,bU as Ok,bV as zk,bW as Rk}from"./editor-DBWWidi3.js";import{as as tt,at,au as Pk,av as La,aw as Bk,ax as Rl,ay as $k,az as wi,aA as Zo,aB as jk,aC as qk,aD as Hk,aE as Uk,aF as Wk,aG as Kk,aH as Vk,aI as Gk,ad as _d,aJ as Xk,aK as It,ac as qr,aL as of,aM as Fa,aN as Ue,aO as Pl,aP as Eb,aQ as Jk,aR as zn,aS as Yk,aT as Zk,aU as Qk,aV as au,aW as Ed,aX as af,aY as Bl,aZ as Tb,a_ as ew,a$ as Om,b0 as tw,b1 as nw,t as uf,b2 as Ab,b3 as rw,b4 as iw,b5 as Mb,b6 as Nb,b7 as sw}from"./ui-CEFkTVnG.js";import{i as B0,j as ow,k as aw,l as uw,n as zm,e as Qo,s as lw,y as cw,h as Rm,m as Pm,r as hw,u as fw,v as dw,o as pw,w as mw,x as Db}from"./diagram-BF8g9yg4.js";import{o as xn,bc as gw,aY as Td,aK as bw}from"./index-
|
|
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-Bjx9jCbC.js","assets/meta2d-DP4Vt_ZE.js","assets/react-vendor-BVS1XoFi.js","assets/editor-DBWWidi3.js","assets/ui-CEFkTVnG.js","assets/motion-BAXVQJfN.js","assets/diagram-BF8g9yg4.js","assets/index-DHKGh7I3.js","assets/index-C1Mc0Svw.css","assets/plus-BMAfiGed.js","assets/copy-Bp0JPDN6.js","assets/check-IPzs2Va9.js","assets/DiagramEditor-NtNY3sZL-D12WH5JY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var x7=Object.defineProperty;var k7=(e,t,n)=>t in e?x7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mn=(e,t,n)=>k7(e,typeof t!="symbol"?t+"":t,n);import{B as eb,_ as Oe,r as E,af as w7,ag as v7,ah as S7,ai as Dn,aj as Xh,ak as Em,al as C7,j as O,b as Pi,am as _7,an as E7,ao as T7,ap as A7,z as M7,C as Jh,aq as N7,ar as D7,as as I7,at as L7}from"./react-vendor-BVS1XoFi.js";import{P as ze,e as Yh,A as ru,a as Ut,b as tb,w as de,c as fn,k as Cn,n as lt,F as Wr,p as Bi,$ as ce,O as Ln,G as pr,d as gs,l as gd,z as Sn,r as gt,v as nb,B as je,X as Fn,T as rb,M as Il,L as Ai,W as ml,f as hi,g as bs,h as So,C as Zh,Y as ib,y as Pt,i as Ll,H as Xe,j as F7,t as O7,m as Lo,J as bn,o as sb,R as fi,S as iu,Q as Zn,q as ob,s as z7,u as Aa,x as mt,E as R7,D as yc,I as P7,K as B7,_ as $7,N as su,U as bd,Z as ys,a0 as Co,a1 as Tt,a2 as ab,a3 as yn,a4 as j7,a5 as q7,a6 as Hr,a7 as Li,a8 as Fl,a9 as _n,aa as yd,ab as H7,ac as ub,ad as xd,ae as kd,af as _o,V as hn,ag as lb,ah as Qh,ai as U7,aj as cb,ak as W7,al as K7,am as V7,an as G7,ao as hb,ap as Qn,aq as X7,ar as jr,as as qn,at as xs,au as Tm,av as Am,aw as J7,ax as Y7,ay as Z7,az as Q7,aA as Ma,aB as fb,aC as db,aD as aa,aE as Na,aF as ou,aG as ek,aH as ef,aI as Mm,aJ as tk,aK as nk,aL as pb,aM as rk,aN as ik,aO as sk,aP as wd,aQ as Rr,aR as Eo,aS as vd,aT as ma,aU as fs,aV as Da,aW as tf,aX as Nm,aY as ga,aZ as gl,a_ as Ol,a$ as ok,b0 as ak,b1 as uk,b2 as lk,b3 as ck,b4 as Pr,b5 as hk,b6 as fk,b7 as dk,b8 as Dm,b9 as bl,ba as Im,bb as pk,bc as mk,bd as gk,be as bk,bf as ks,bg as Lm,bh as nf,bi as yk,bj as xk,bk as kk,bl as wk,bm as Fm,bn as ii,bo as Ia,bp as rf,bq as vk,br as ua,bs as mb,bt as gb,bu as bb,bv as yb,bw as xb,bx as Sk,by as Ck,bz as Sd,bA as kb,bB as _k,bC as Ek,bD as Cd,bE as Tk,bF as sf,bG as wb,bH as vb,bI as Ak,bJ as Mk,bK as Ju,bL as Sb,bM as Nk,bN as Dk,bO as Ik,bP as Cb,bQ as Lk,bR as Fk,bS as _b,bT as zl,bU as Ok,bV as zk,bW as Rk}from"./editor-DBWWidi3.js";import{as as tt,at,au as Pk,av as La,aw as Bk,ax as Rl,ay as $k,az as wi,aA as Zo,aB as jk,aC as qk,aD as Hk,aE as Uk,aF as Wk,aG as Kk,aH as Vk,aI as Gk,ad as _d,aJ as Xk,aK as It,ac as qr,aL as of,aM as Fa,aN as Ue,aO as Pl,aP as Eb,aQ as Jk,aR as zn,aS as Yk,aT as Zk,aU as Qk,aV as au,aW as Ed,aX as af,aY as Bl,aZ as Tb,a_ as ew,a$ as Om,b0 as tw,b1 as nw,t as uf,b2 as Ab,b3 as rw,b4 as iw,b5 as Mb,b6 as Nb,b7 as sw}from"./ui-CEFkTVnG.js";import{i as B0,j as ow,k as aw,l as uw,n as zm,e as Qo,s as lw,y as cw,h as Rm,m as Pm,r as hw,u as fw,v as dw,o as pw,w as mw,x as Db}from"./diagram-BF8g9yg4.js";import{o as xn,bc as gw,aY as Td,aK as bw}from"./index-DHKGh7I3.js";import{P as Bm}from"./plus-BMAfiGed.js";import{a as yw,C as xw}from"./copy-Bp0JPDN6.js";import{C as kw}from"./check-IPzs2Va9.js";/**
|
|
3
3
|
* @license lucide-react v0.562.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -1729,7 +1729,7 @@ ${this.__markdown}
|
|
|
1729
1729
|
## 分支 2`,style:{border:"none",flex:1,fontFamily:"monospace",fontSize:14,lineHeight:1.6,outline:"none",padding:16,resize:"none"},value:r})]}),O.jsx("div",{style:{display:"flex",flexDirection:"column",width:"50%"},children:O.jsx(Wx,{markdown:r})})]})]})}function Oq({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(Fq,{markdown:s,onClose:()=>i(!1),onSave:a})}):O.jsxs("div",{className:e,style:{margin:"8px 0",position:"relative"},children:[O.jsxs("div",{style:{bottom:8,display:"flex",gap:4,position:"absolute",right:8,zIndex:10},children:[O.jsx("button",{onClick:()=>i(!0),style:{background:"rgba(0,0,0,0.5)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:12,padding:"4px 8px"},type:"button",children:"编辑"}),O.jsx("button",{onClick:o,style:{background:"rgba(255,77,79,0.7)",border:"none",borderRadius:4,color:"#fff",cursor:"pointer",fontSize:12,padding:"4px 8px"},type:"button",children:"删除"})]}),O.jsx("div",{style:{border:"1px solid #f0f0f0",borderRadius:8,height:350},children:O.jsx(Wx,{markdown:s})})]})}function yU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((s,o)=>O.jsx(Oq,{className:e,editor:o,node:s}),[e]),i=E.useRef(!1);return i.current||(i.current=!0,n.registerPlugin(Lq,{decorator:r,theme:t})),null}const zq=lt("INSERT_MATH_COMMAND"),Kx=lt("UPDATE_MATH_COMMAND"),Nl=lt("SELECT_MATH_SIDE_COMMAND");function Rq(e){return gt(e.registerCommand(zq,t=>{const{code:n}=t;return e.update(()=>{const r=cu(n);_n([r]),qn(r.getParentOrThrow())&&xs(r,hn).selectEnd()}),!0},Fn),e.registerCommand(Kx,t=>{const{code:n,key:r}=t;return e.update(()=>{const i=ze(r);i&&(i.updateCode(n),i.selectNext())}),!0},Fn),e.registerCommand(Nl,t=>{const{key:n,prev:r}=t;return e.update(()=>{const i=ze(n);i&&(r?i.selectPrevious():i.selectNext())}),!0},Fn))}function Pq(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 Bq=(wo=class extends zt{constructor(t,n){super(),this.kernel=t,this.config=n,this.logger=Qe("plugin","math"),t.registerNodes([xa,Fi]),n!=null&&n.theme&&t.registerThemes(n==null?void 0:n.theme),this.registerDecorator(t,xa.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null),this.registerDecorator(t,Fi.getType(),(r,i)=>n!=null&&n.decorator?n.decorator(r,i):null)}onInit(t){this.register(Rq(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(!Pq(i))return;const s=cu(i);this.logger.debug("Math node inserted:",s),n.insertBefore(s),n.setTextContent(""),n.select()},trigger:"$",type:"text-match"}),t==null||t.registerMarkdownShortCut({regExp:/^(\$\$)$/,replace:(n,r,i,s)=>{const o=wc();s||n.getNextSibling()?n.replace(o):n.insertBefore(o);const a=bn();a.add(o.getKey()),je(a)},trigger:"enter",type:"element"}),t==null||t.registerMarkdownWriter(xa.getType(),(n,r)=>(n.appendLine(r.getTextContent()),!0)),t==null||t.registerMarkdownWriter(Fi.getType(),(n,r)=>(n.appendLine(r.getTextContent()),!0)),t==null||t.registerMarkdownReader("inlineMath",n=>ke.createElementNode("math",{code:n.value,version:1})),t==null||t.registerMarkdownReader("math",n=>ke.createElementNode("mathBlock",{code:n.value,version:1}))}},wo.pluginName="MathPlugin",wo),Vx=E.memo(({children:e,isBlockMode:t,mathDOM:n,onFocus:r,prev:i})=>{const s=E.useRef(null),[o,a]=E.useState(void 0),u=E.useRef(void 0),l=E.useCallback(m=>{const y=typeof m=="number"?Math.round(m):void 0;u.current!==y&&(u.current=y,a(y))},[]),h=E.useCallback(()=>{if(!t){l(void 0);return}const m=n==null?void 0:n.closest('[contenteditable="true"]');m&&l(m.getBoundingClientRect().width)},[t,n,l]),d=E.useCallback(()=>Zc({callback:()=>{!s.current||!n||(r==null||r(),h())},floating:s.current,placement:t?"bottom-start":"bottom",reference:n}),[t,n,r,h]),g=E.useCallback(()=>{n&&d()},[n,d]);return E.useEffect(()=>{if(!n||!s.current)return;const m=s.current,y=new ResizeObserver(()=>{h()});y.observe(m);let w=null;return t&&(w=n.closest('[contenteditable="true"]'),w&&y.observe(w)),d(),window.addEventListener("resize",d),()=>{y.disconnect(),window.removeEventListener("resize",d)}},[n,i,t,d]),E.useEffect(()=>{n||!s.current||tu(s.current)},[n]),O.jsx(au,{arrow:!1,content:O.jsx(It,{className:zi.mathEditor,"data-math-editor-container":!0,style:o?{width:o}:void 0,children:e}),open:!!n,placement:t?"bottomLeft":"bottom",styles:{content:{borderRadius:"6px",padding:0}},children:O.jsx("span",{className:zi.mathEditorAnchor,onClick:g,ref:s})})});Vx.displayName="MathEditorContainer";Hb();const Gx=E.memo(({focusRef:e,mathNode:t,onArrowLeft:n,onArrowRight:r,onCancel:i,onDelete:s,onSubmit:o,onValidationChange:a,onValueChange:u,value:l})=>{const h=nr(),d=E.useRef(null),[g,m]=E.useState("");E.useEffect(()=>{e==null||e(d.current)},[e]),E.useEffect(()=>{if(!t)return;if(!l.trim()){m(""),a==null||a(!0);return}const w=setTimeout(()=>{try{tw(l,{displayMode:!0,throwOnError:!0}),m(""),a==null||a(!0)}catch(_){m(_ instanceof Error?_.message:"LaTeX Parse Error"),a==null||a(!1)}},50);return()=>clearTimeout(w)},[l,t,a]);const y=E.useCallback(w=>{if(t){if(ob(w,qb)&&w.key==="Enter"){w.preventDefault(),o();return}if(w.key==="Escape"){w.preventDefault(),i();return}if(w.key==="Backspace"&&!l.trim()){w.preventDefault(),s();return}w.key==="ArrowLeft"&&w.currentTarget.selectionStart===0&&(w.preventDefault(),n()),w.key==="ArrowRight"&&w.currentTarget.selectionStart===w.currentTarget.value.length&&(w.preventDefault(),r())}},[t,o,i,s,n,r,l]);return O.jsxs(O.Fragment,{children:[O.jsx(nw,{autoFocus:!0,autoSize:{maxRows:6,minRows:1},className:zi.mathEditorTextArea,onChange:w=>{u(w.target.value)},onKeyDown:y,placeholder:`${h("math.placeholder")}...`,ref:d,resize:!1,value:l,variant:"borderless"}),g&&O.jsx(It,{className:zi.mathEditorFooter,horizontal:!0,paddingBlock:4,paddingInline:12,width:"100%",children:O.jsx(qr,{fontSize:13,type:"danger",children:g})}),O.jsx(It,{className:zi.mathEditorFooter,horizontal:!0,justify:"flex-end",padding:4,width:"100%",children:O.jsxs(Pl,{onClick:w=>{w.preventDefault(),o()},size:"small",type:"text",variant:"filled",children:[h("confirm"),O.jsx(Eb,{compact:!0,keys:"mod+enter",variant:"borderless"})]})})]})});Gx.displayName="MathEditorContent";kr();const $q=E.memo(({renderComp:e})=>{const t=E.useRef(null),n=E.useRef(!1),[r,i]=E.useState(null),[s,o]=E.useState(""),a=E.useRef(""),u=E.useRef(!0),[l,h]=E.useState(null),[d,g]=E.useState(!1),[m,y]=E.useState(!1),[w,_]=E.useState(!1),[v]=_t();E.useEffect(()=>{if(!r||!u.current)return;const z=setTimeout(()=>{const V=v.getLexicalEditor();if(V&&!n.current){const X=r.code;if(s&&X&&X===s)return;n.current=!0,V.update(()=>{if(V.getEditorState().read(()=>V.getElementByKey(r.getKey()))){const ee=r.getWritable();ee.__code=s}}),setTimeout(()=>{n.current=!1},50)}},50);return()=>clearTimeout(z)},[s,r,v]);const M=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();if(z){const V=u.current?s:a.current;z.dispatchCommand(Kx,{code:V,key:r.getKey()})}},[v,r,s]),T=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&(z.dispatchCommand(Nl,{key:r.getKey(),prev:!1}),z.focus())},[r,v]),D=E.useCallback(()=>{if(!r)return;const z=v.getLexicalEditor();z&&z.update(()=>{r.remove()})},[r,v]),R=E.useCallback(()=>{r&&v.dispatchCommand(Nl,{key:r.getKey(),prev:!0})},[r,v]),F=E.useCallback(()=>{r&&v.dispatchCommand(Nl,{key:r.getKey(),prev:!1})},[r,v]),j=E.useCallback(()=>{var z,V,X,ee;(z=t.current)==null||z.focus(),d&&((ee=(X=(V=t.current)==null?void 0:V.resizableTextArea)==null?void 0:X.textArea)==null||ee.setSelectionRange(0,0))},[d]),K=E.useCallback(z=>{t.current=z},[]);br(z=>gt(z.registerUpdateListener(({prevEditorState:V})=>{if(n.current)return;const X=z.getEditorState().read(()=>{const ee=ce();if(!Ln(ee))return!1;const Q=ee.getNodes()[0];if(!x3(Q))return!1;const ae=r&&r.getKey()===Q.getKey();return i(Q),!ae&&Q.code!==s&&(o(Q.code),a.current=Q.code,u.current=!0),h(z.getElementByKey(Q.getKey())),y(Q instanceof Fi),Q});if(X){const ee=V.read(()=>{const Q=V._selection;return de(Q)?Q.anchor.key:!1});z.getEditorState().read(()=>{const Q=ee?ze(ee):null;Q&&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(Gx,{focusRef:K,mathNode:r,onArrowLeft:R,onArrowRight:F,onCancel:T,onDelete:D,onSubmit:M,onValidationChange:z=>{u.current=z,z&&(a.current=s)},onValueChange:o,value:s});return E.useEffect(()=>{if(!w)return;const z=V=>{const X=V.target;X&&(Array.from(document.querySelectorAll("[data-math-editor-container]")).some(ee=>ee&&ee.contains(X))||T())};return document.addEventListener("mousedown",z),document.addEventListener("touchstart",z),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("touchstart",z)}},[w,T]),e?O.jsx(O.Fragment,{children:e({children:O.jsx("div",{"data-math-editor-container":!0,children:U}),open:w})}):O.jsx(Yc,{children:O.jsx(Vx,{isBlockMode:m,mathDOM:l,onFocus:j,prev:d,children:U})})}),jq=({mathBlock:e})=>{const t=nr(),n=O.jsx(qr,{as:"span",className:at("katex",zi.mathPlaceholder),fontSize:e?"1.2em":"1em",type:"secondary",children:t("math.placeholder")});return e?O.jsx(af,{padding:18,width:"100%",children:n}):n};Ot();const qq=Qe("plugin","math"),Hq=({editor:e,node:t,className:n})=>{const r=E.useRef(null),[i,s,o]=zo(t.getKey()),[a,u]=E.useState(!1),l=t instanceof Fi;return E.useEffect(()=>{r.current&&t.code&&Yk.render(t.code,r.current,{displayMode:t instanceof Fi,throwOnError:!1})},[t.code]),E.useEffect(()=>{const h=e.getElementByKey(t.getKey());if(h){const d=setTimeout(()=>{a?(Ut(h,"editing"),ua(h,"selected")):i?(Ut(h,"selected"),ua(h,"editing")):(ua(h,"selected"),ua(h,"editing"))},10);return()=>clearTimeout(d)}},[i,a,e,t]),br(h=>h.registerUpdateListener(()=>{h.getEditorState().read(()=>{const d=ce();if(!Ln(d)){u(!1);return}const g=d.getNodes()[0];if(!x3(g)){u(!1);return}g.getKey()===t.getKey()?u(!0):u(!1)})}),[t]),O.jsx("span",{className:n,onClick:E.useCallback(h=>{qq.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(jq,{mathBlock:l})})},Uq=({className:e,renderComp:t,theme:n})=>{const[r]=_t();return E.useLayoutEffect(()=>{r.registerPlugin(Vi),r.registerPlugin(Bq,{decorator:(i,s)=>O.jsx(Hq,{className:e,editor:s,node:i}),theme:n||zi})},[r,e,n,zi]),O.jsx($q,{renderComp:t})};Uq.displayName="ReactMathPlugin";var Gs=class Dl extends Wr{static getType(){return"meta2d"}static clone(t){return new Dl(t.__diagram,t.__svg,t.__key,t.__autoOpenEditor)}static importJSON(t){return new Dl(t.diagram,t.svg)}constructor(t="",n="",r,i=!1){super(r),this.__diagram=t,this.__svg=n,this.__autoOpenEditor=i}clearAutoOpenEditor(){const t=this.getWritable();t.__autoOpenEditor=!1}createDOM(t){const n=document.createElement("div");return Ut(n,t.theme.meta2d??"editor-meta2d"),n}decorate(t){var r;const n=(r=Hi(t))==null?void 0:r.getDecorator(Dl.getType());return n?typeof n=="function"?n(this,t):{queryDOM:n.queryDOM,render:n.render(this,t)}:null}exportJSON(){return{...super.exportJSON(),diagram:this.__diagram,svg:this.__svg}}getTextContent(){return`---meta2d---
|
|
1730
1730
|
${this.__diagram}
|
|
1731
1731
|
---/meta2d---
|
|
1732
|
-
`}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Xx(e="",t="",n){return Cn(new Gs(e,t,void 0,(n==null?void 0:n.autoOpenEditor)??!1))}function H4(e){return e instanceof Gs}const Wq=lt("INSERT_META2D_COMMAND");function Kq(e){return e.registerCommand(Wq,t=>(e.update(()=>{var n;_n([Xx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Cl,(t==null?void 0:t.svg)!==void 0&&t.svg.trim()!==""?t.svg:nc,{autoOpenEditor:(t==null?void 0:t.autoOpenEditor)??!0})])}),!0),Tt)}rn();Bt();const Vq=/^---meta2d---$/i,Gq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Xq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Jq=(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(Kq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:Vq,replace:n=>{const r=Xx(Cl,nc,{autoOpenEditor:!0});n.replace(r);const i=bn();i.add(r.getKey()),je(i)},trigger:"enter",type:"element"}),t.registerMarkdownWriter(Gs.getType(),(n,r)=>{const i=r;return n.appendLine("---meta2d---"),n.appendLine(i.__diagram||Cl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Xq(n).match(Gq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Cl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:yD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Yq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-CNHknbe2.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Zq(e){return(await Yq()).generateSvgFromDiagram(e)}function Qq(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 eH({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),Zq(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:Qq(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 tH=E.memo(eH),nH=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-DHC7qgkW.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function rH({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(tH,{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(nH,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function xU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(rH,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Jq,{decorator:r,theme:t})},[r,n,t]),null}const Jx=E.createContext(null),iH=({children:e,defaultVisible:t=!0})=>{const[n,r]=E.useState(t),i=E.useCallback(()=>r(o=>!o),[]),s=E.useMemo(()=>({setVisible:r,toggle:i,visible:n}),[i,n]);return O.jsx(Jx.Provider,{value:s,children:e})};iH.displayName="OutlineProvider";function Y1(){return E.useContext(Jx)}function kU(){const e=Y1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function sH(e){const t=Y1(),n=(e==null?void 0:e.visible)!==void 0&&(e==null?void 0:e.onVisibleChange)!==void 0;return E.useMemo(()=>n&&(e!=null&&e.onVisibleChange)?{ready:!0,toggle:()=>e.onVisibleChange(!e.visible),visible:e.visible}:t?{ready:!0,toggle:t.toggle,visible:t.visible}:{ready:!1},[e==null?void 0:e.onVisibleChange,e==null?void 0:e.visible,t,n])}kr();const wU=({editor:e,visible:t})=>{const n=Y1(),r=E.useMemo(()=>t!==void 0?t:(n==null?void 0:n.visible)??!0,[t,n==null?void 0:n.visible]),[i,s]=E.useState([]),o=E.useCallback(()=>{const u=[],l=Sn(),h=d=>{for(const g of d){if(_o(g)){const m=g.getTextContent().trim();m&&u.push({key:g.getKey(),level:parseInt(g.getTag()[1],10),text:m})}if(fn(g)){const m=g.getChildren();m.length>0&&h(m)}}};h(l.getChildren()),s(u)},[]);E.useEffect(()=>{const u=e.getLexicalEditor();let l=Fo;const h=d=>(l=d.registerUpdateListener(({editorState:g})=>{g.read(o)}),d.getEditorState().read(o),l);return u?h(u):(e.on("initialized",h),()=>{l(),e.off("initialized",h)})},[e,o]);const a=E.useCallback(u=>{const l=e.getLexicalEditor();l&&(l.update(()=>{const h=bn();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))]})},oH="Hide outline",aH="Show outline",uH="outline";function vU(e){const{collapseTitle:t=oH,expandTitle:n=aH,onVisibleChange:r,visible:i}=e??{},s=sH(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:uH,label:a?t:n,onClick:o}},[t,n,s])}kr();function lH(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 cH(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 hH(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 fH(e,t,n){const r=new Set(n?n.getNodes():[]);lH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,cH(e,i)):(i.highlighted=!1,hH(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 dH(){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 pH(e){const t=e.getLastDescendant();Pt(t)?t.select():fn(t)?t.selectEnd():t!==null&&t.selectNext()}function V4(e){return e.getEditorState().read(()=>{const t=ce();if(de(t)||fi(t)){const[n]=Cb(t.anchor);if(hi(n))return n.getBackgroundColor()}return null})}const Yx=E.memo(({editor:e,tableCellNode:t,cellMerge:n,children:r})=>{const[i,s]=E.useState(t),[o,a]=E.useState({columns:1,rows:1}),[u,l]=E.useState(!1),[h,d]=E.useState(!1),[,g]=E.useState(()=>V4(e)||""),m=nr();E.useEffect(()=>e.registerMutationListener(nf,K=>{K.get(i.getKey())==="updated"&&(e.getEditorState().read(()=>{s(i.getLatest())}),g(V4(e)||""))},{skipInitialization:!0}),[e,i]),E.useEffect(()=>{e.getEditorState().read(()=>{const K=ce();if(fi(K)){const U=K4(K);a(K4(K)),l(U.columns>1||U.rows>1)}d(dH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Ia(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=rf(U);z!==null&&z.$clearHighlight(),K.markDirty(),s(i.getLatest())}je(null)})},[e,i]),w=()=>{e.update(()=>{const K=ce();if(!fi(K))return;const U=Lk(K.getNodes().filter(hi));U&&pH(U)})},_=()=>{e.update(()=>{Fk()})},v=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.rows;U++)wb(K)})},[e,o.rows]),M=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.columns;U++)vb(K)})},[e,o.columns]),T=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Mk()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Cd(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.ROW;for(let ee=0;ee<z[U].length;ee++){const Q=z[U][ee];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.COLUMN;for(const ee of z){const Q=ee[U];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.COLUMN)))}y()})},[e,i,y]);return O.jsx(Ed,{menu:{items:E.useMemo(()=>[{icon: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:bw,key:"table-insert-column-before",label:m("table.insertColumnLeft",{count:o.columns}),onClick:()=>M(!1)},{icon:zb,key:"table-insert-column-after",label:m("table.insertColumnRight",{count:o.columns}),onClick:()=>M(!0)},{type:"divider"},{icon: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})});Yx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
|
|
1732
|
+
`}isInline(){return!1}updateDiagram(t,n){const r=this.getWritable();r.__diagram=t,r.__svg=n}updateDOM(){return!1}};function Xx(e="",t="",n){return Cn(new Gs(e,t,void 0,(n==null?void 0:n.autoOpenEditor)??!1))}function H4(e){return e instanceof Gs}const Wq=lt("INSERT_META2D_COMMAND");function Kq(e){return e.registerCommand(Wq,t=>(e.update(()=>{var n;_n([Xx(((n=t==null?void 0:t.diagram)==null?void 0:n.trim())||Cl,(t==null?void 0:t.svg)!==void 0&&t.svg.trim()!==""?t.svg:nc,{autoOpenEditor:(t==null?void 0:t.autoOpenEditor)??!0})])}),!0),Tt)}rn();Bt();const Vq=/^---meta2d---$/i,Gq=/---meta2d---(\\n?)([\S\s]*?)\n?---\/meta2d---/i;function Xq(e){return(e.children||[]).map(t=>"value"in t&&typeof t.value=="string"?t.value:"").join("")}var vo;const Jq=(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(Kq(t)),this.registerMarkdown()}registerMarkdown(){const t=this.kernel.requireService(Lt);t&&(t.registerMarkdownShortCut({regExp:Vq,replace:n=>{const r=Xx(Cl,nc,{autoOpenEditor:!0});n.replace(r);const i=bn();i.add(r.getKey()),je(i)},trigger:"enter",type:"element"}),t.registerMarkdownWriter(Gs.getType(),(n,r)=>{const i=r;return n.appendLine("---meta2d---"),n.appendLine(i.__diagram||Cl),n.appendLine("---/meta2d---"),!0}),t.registerMarkdownReader("paragraph",n=>{var s;const r=Xq(n).match(Gq);if(!r)return!1;const i=((s=r[2])==null?void 0:s.trim())||Cl;return ke.createTypeNode(Gs.getType(),{diagram:i,svg:yD(i)})},1))}},vo.pluginName="Meta2dPlugin",vo);let U4=null;function Yq(){return U4??(U4=Oe(()=>import("./meta2dEngine-BD2XbzaV-Bjx9jCbC.js"),__vite__mapDeps([23,24,25,26,27,28,29,30,31,32,33,34]))),U4}async function Zq(e){return(await Yq()).generateSvgFromDiagram(e)}function Qq(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 eH({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),Zq(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:Qq(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 tH=E.memo(eH),nH=E.lazy(async()=>({default:(await Oe(async()=>{const{DiagramEditor:e}=await import("./DiagramEditor-NtNY3sZL-D12WH5JY.js");return{DiagramEditor:e}},__vite__mapDeps([35,25,23,24,26,27,28,29,30,31,32,33,34]))).DiagramEditor}));function rH({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(tH,{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(nH,{diagram:s,onClose:()=>i(!1),onSave:u})})]})}function xU({className:e,theme:t}){const[n]=_t(),r=E.useCallback((i,s)=>O.jsx(rH,{className:e,editor:s,node:i}),[e]);return E.useLayoutEffect(()=>{n.registerPlugin(Jq,{decorator:r,theme:t})},[r,n,t]),null}const Jx=E.createContext(null),iH=({children:e,defaultVisible:t=!0})=>{const[n,r]=E.useState(t),i=E.useCallback(()=>r(o=>!o),[]),s=E.useMemo(()=>({setVisible:r,toggle:i,visible:n}),[i,n]);return O.jsx(Jx.Provider,{value:s,children:e})};iH.displayName="OutlineProvider";function Y1(){return E.useContext(Jx)}function kU(){const e=Y1();if(!e)throw new Error("useOutlineVisibility must be used within <OutlineProvider>.");return e}function sH(e){const t=Y1(),n=(e==null?void 0:e.visible)!==void 0&&(e==null?void 0:e.onVisibleChange)!==void 0;return E.useMemo(()=>n&&(e!=null&&e.onVisibleChange)?{ready:!0,toggle:()=>e.onVisibleChange(!e.visible),visible:e.visible}:t?{ready:!0,toggle:t.toggle,visible:t.visible}:{ready:!1},[e==null?void 0:e.onVisibleChange,e==null?void 0:e.visible,t,n])}kr();const wU=({editor:e,visible:t})=>{const n=Y1(),r=E.useMemo(()=>t!==void 0?t:(n==null?void 0:n.visible)??!0,[t,n==null?void 0:n.visible]),[i,s]=E.useState([]),o=E.useCallback(()=>{const u=[],l=Sn(),h=d=>{for(const g of d){if(_o(g)){const m=g.getTextContent().trim();m&&u.push({key:g.getKey(),level:parseInt(g.getTag()[1],10),text:m})}if(fn(g)){const m=g.getChildren();m.length>0&&h(m)}}};h(l.getChildren()),s(u)},[]);E.useEffect(()=>{const u=e.getLexicalEditor();let l=Fo;const h=d=>(l=d.registerUpdateListener(({editorState:g})=>{g.read(o)}),d.getEditorState().read(o),l);return u?h(u):(e.on("initialized",h),()=>{l(),e.off("initialized",h)})},[e,o]);const a=E.useCallback(u=>{const l=e.getLexicalEditor();l&&(l.update(()=>{const h=bn();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))]})},oH="Hide outline",aH="Show outline",uH="outline";function vU(e){const{collapseTitle:t=oH,expandTitle:n=aH,onVisibleChange:r,visible:i}=e??{},s=sH(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:uH,label:a?t:n,onClick:o}},[t,n,s])}kr();function lH(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 cH(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 hH(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 fH(e,t,n){const r=new Set(n?n.getNodes():[]);lH(t,(i,s)=>{const o=i.elem;r.has(s)?(i.highlighted=!0,cH(e,i)):(i.highlighted=!1,hH(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 dH(){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 pH(e){const t=e.getLastDescendant();Pt(t)?t.select():fn(t)?t.selectEnd():t!==null&&t.selectNext()}function V4(e){return e.getEditorState().read(()=>{const t=ce();if(de(t)||fi(t)){const[n]=Cb(t.anchor);if(hi(n))return n.getBackgroundColor()}return null})}const Yx=E.memo(({editor:e,tableCellNode:t,cellMerge:n,children:r})=>{const[i,s]=E.useState(t),[o,a]=E.useState({columns:1,rows:1}),[u,l]=E.useState(!1),[h,d]=E.useState(!1),[,g]=E.useState(()=>V4(e)||""),m=nr();E.useEffect(()=>e.registerMutationListener(nf,K=>{K.get(i.getKey())==="updated"&&(e.getEditorState().read(()=>{s(i.getLatest())}),g(V4(e)||""))},{skipInitialization:!0}),[e,i]),E.useEffect(()=>{e.getEditorState().read(()=>{const K=ce();if(fi(K)){const U=K4(K);a(K4(K)),l(U.columns>1||U.rows>1)}d(dH())})},[e]);const y=E.useCallback(()=>{e.update(()=>{if(i.isAttached()){const K=ii(i),U=Ia(K,e.getElementByKey(K.getKey()));if(U===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const z=rf(U);z!==null&&z.$clearHighlight(),K.markDirty(),s(i.getLatest())}je(null)})},[e,i]),w=()=>{e.update(()=>{const K=ce();if(!fi(K))return;const U=Lk(K.getNodes().filter(hi));U&&pH(U)})},_=()=>{e.update(()=>{Fk()})},v=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.rows;U++)wb(K)})},[e,o.rows]),M=E.useCallback(K=>{e.update(()=>{for(let U=0;U<o.columns;U++)vb(K)})},[e,o.columns]),T=E.useCallback(()=>{e.update(()=>{Ak()})},[e]),D=E.useCallback(()=>{e.update(()=>{ii(i).remove(),y()})},[e,i,y]),R=E.useCallback(()=>{e.update(()=>{Mk()})},[e]),F=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Cd(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.ROW;for(let ee=0;ee<z[U].length;ee++){const Q=z[U][ee];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.ROW)))}y()})},[e,i,y]),j=E.useCallback(()=>{e.update(()=>{const K=ii(i),U=Sb(i),[z]=sf(K,null,null),V=new Set,X=i.getHeaderStyles()^Ju.COLUMN;for(const ee of z){const Q=ee[U];Q!=null&&Q.cell&&(V.has(Q.cell)||(V.add(Q.cell),Q.cell.setHeaderStyles(X,Ju.COLUMN)))}y()})},[e,i,y]);return O.jsx(Ed,{menu:{items:E.useMemo(()=>[{icon: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:bw,key:"table-insert-column-before",label:m("table.insertColumnLeft",{count:o.columns}),onClick:()=>M(!1)},{icon:zb,key:"table-insert-column-after",label:m("table.insertColumnRight",{count:o.columns}),onClick:()=>M(!0)},{type:"divider"},{icon: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})});Yx.displayName="TableActionMenu";const G4=tt(({css:e})=>({actionIcon:e`
|
|
1733
1733
|
transform: translateX(2px);
|
|
1734
1734
|
`,root:e`
|
|
1735
1735
|
will-change: transform;
|
package/dist/web/index.html
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
opacity: 0.65;
|
|
28
28
|
}
|
|
29
29
|
</style>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-DHKGh7I3.js"></script>
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BVS1XoFi.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/assets/motion-BAXVQJfN.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/ui-CEFkTVnG.js">
|
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{r as t,j as e}from"./react-vendor-BVS1XoFi.js";import{o as De,c as ce,$ as Ks,a0 as Os,V as Us,l as re,a1 as $s,a2 as Vs,a3 as ee,a4 as Ue,a5 as _s,a6 as Ws,a7 as qs,a as Gs,d as Xe,a8 as us,a9 as hs,aa as Hs,ab as Js,ac as Zs,ad as Qs,ae as Ys,af as ps,ag as Be,ah as Xs,ai as et,aj as st,X as tt,ak as at,al as nt,f as gs,am as it,an as ct,ao as lt,ap as ot,aq as rt,ar as fs,as as dt,at as mt,au as ut,av as ht,aw as pt,ax as gt,ay as ft,az as xs,aA as xt,aB as yt,aC as bt,aD as jt,aE as Nt,S as vt,aF as kt,aG as St,aH as wt,aI as Ct,aJ as Dt,aK as It,aL as es,U as Tt,aM as At,aN as Mt,aO as Pt,r as Et,j as Rt,aP as Ft,k as zt,m as Lt}from"./index-DAhW-QRN.js";import{V as ys,a as Bt,M as ss,U as Kt}from"./VisitorPickerModal-D4xmZbNY.js";import{C as Ot}from"./check-CuLfkkz7.js";import{ai as Ke,aj as Ut,ak as $t,al as Vt,am as _t,an as Wt,ao as ts,ap as qt,aq as as}from"./ui-CEFkTVnG.js";import"./diagram-BF8g9yg4.js";import"./motion-BAXVQJfN.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 Gt=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Ht=De("cloud-upload",Gt);/**
|
|
7
|
-
* @license lucide-react v0.562.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Jt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Zt=De("layout-grid",Jt);/**
|
|
12
|
-
* @license lucide-react v0.562.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Qt=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]],Yt=De("scan-search",Qt);/**
|
|
17
|
-
* @license lucide-react v0.562.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Xt=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ea=De("sparkles",Xt);function sa({draft:a,onClose:s,onSuccess:p}){const{t:u,lang:y}=ce(),[R,f]=t.useState([]),[S,N]=t.useState(a.domainId??""),[h,w]=t.useState([]),[A,I]=t.useState(""),[c,v]=t.useState(`${a.displayName||"untitled"}_recovered.md`),[g,x]=t.useState(!1),[D,L]=t.useState(null),b=t.useRef(null),B=t.useRef(!0);t.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]),t.useEffect(()=>{Ks().then(k=>{B.current&&f(k)})},[]),t.useEffect(()=>{S&&(w([]),I(""),Os(S).then(k=>{B.current&&w(k)}).catch(()=>{B.current&&w([])}))},[S]),t.useEffect(()=>{const k=window.setTimeout(()=>{var E;return(E=b.current)==null?void 0:E.focus()},0);return()=>window.clearTimeout(k)},[]),t.useEffect(()=>{const k=E=>{E.key==="Escape"&&s()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[s]);function K(k,E){for(const C of k){if(C.type==="folder"&&C.path===E)return C.documentId;if(C.type==="folder"){const F=K(C.children,E);if(F)return F}}return null}async function z(k){k.preventDefault(),x(!0),L(null);const E=c.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\-.]/g,""),C=E.endsWith(".md")?E:E+".md",F=C.replace(/\.md$/i,"");try{const m=A?`${A}/${C}`:C,d=A?K(h,A)??void 0:void 0;await Vs({fileName:C,displayName:F,content:a.content,domainId:S,parentId:d}),p()}catch(m){L(ee(u,m))}finally{x(!1)}}return e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:k=>{k.target===k.currentTarget&&!g&&s()},children:e.jsxs("div",{className:"mdocs-dialog card mdocs-recovery-dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:u("recoverDraft")}),e.jsx("p",{className:"muted",children:u("recoverDraftDesc",{name:a.displayName||u("unknownTitle")})}),e.jsxs("form",{onSubmit:z,className:"mdocs-dialog-form",children:[e.jsxs("label",{className:"mdocs-dialog-label",children:[u("domainLabel"),R.length>0&&e.jsx(Us,{domains:R,value:S,onChange:N,onDomainsChange:f,ariaLabel:u("domainLabel"),localizeName:k=>re(k,y,u)})]}),e.jsxs("label",{className:"mdocs-dialog-label mdocs-recovery-tree-label",children:[u("recoverTargetFolder"),e.jsx("div",{className:"mdocs-recovery-tree",children:e.jsx($s,{nodes:h,activeDocumentId:null,selectedParentPath:A,onOpen:()=>{},onOpenFolder:k=>I(k),onContextMenu:()=>{},onDeselect:()=>I("")})})]}),e.jsxs("label",{className:"mdocs-dialog-label",children:[u("fileNameLabel"),e.jsx("input",{ref:b,value:c,onChange:k=>v(k.target.value),placeholder:"recovered.md",maxLength:200,disabled:g})]}),D&&e.jsx("div",{className:"mdocs-dialog-error",children:D}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>!g&&s(),disabled:g,children:u("cancel")}),e.jsx("button",{type:"submit",className:"primary",disabled:g,children:u(g?"creating":"create")})]})]})]})})}function ta({onPublish:a,onClose:s,onCountChange:p,onRecover:u}){const{t:y}=ce(),[R,f]=t.useState([]),[S,N]=t.useState(new Set),[h,w]=t.useState(!1),[A,I]=t.useState(null),[c,v]=t.useState(null),[g,x]=t.useState(null),D=t.useRef(null),L=t.useRef(!0);t.useEffect(()=>(L.current=!0,Ue().then(d=>{if(!L.current)return;const j=d.filter(T=>!T.published);f(j),p==null||p(j.length)}),()=>{L.current=!1,D.current&&(clearTimeout(D.current),D.current=null)}),[]),t.useEffect(()=>{const d=j=>{j.key==="Escape"&&s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]);const b=t.useCallback((d,j)=>{x({message:d,type:j}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>x(null),3e3)},[]);async function B(d){await Ws(d),N(j=>new Set(j).add(d));try{await a(d),f(j=>{const T=j.filter($=>$.documentId!==d);return p==null||p(T.length),T}),b(y("published"),"success")}catch(j){j instanceof qs||b(y("publishFailed"),"error");const T=await Gs(d);T&&f($=>$.map(_=>_.documentId===d?T:_))}finally{N(j=>{const T=new Set(j);return T.delete(d),T})}}async function K(d){I(null),await Xe(d),f(j=>{const T=j.filter($=>$.documentId!==d);return p==null||p(T.length),T}),b(y("draftDeleted"),"success")}function z(d){const j=R.find(T=>T.documentId===d);j&&v(j)}function k(d){v(null),Xe(d),f(j=>{const T=j.filter($=>$.documentId!==d);return p==null||p(T.length),T}),u==null||u(R.find(j=>j.documentId===d)),b(y("published"),"success")}async function E(){w(!0);let d=0,j=0;for(const _ of R)try{await a(_.documentId),d++}catch{j++}const $=(await Ue()).filter(_=>!_.published);f($),p==null||p($.length),j===0?b(y("publishAll"),"success"):b(`${d} published, ${j} failed`,"error"),w(!1)}const C=d=>new Date(d).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),F=d=>_s(y,d,d.publishError??"UNKNOWN"),m=R;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:[y("unpublishedDrafts"),m.length>0&&e.jsx("span",{className:"mdocs-drawer-count-badge",children:m.length})]}),e.jsx("span",{className:"mdocs-drawer-subtitle",children:y("draftCount",{count:String(m.length)})})]}),e.jsx("button",{type:"button",className:"mdocs-drawer-close-btn",onClick:s,"aria-label":y("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:y("draftsEmptyState")})]}):e.jsx("div",{className:"mdocs-drawer-items",children:m.map(d=>{const j=!!d.publishError;return e.jsxs("div",{className:j?"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:d.displayName||y("unknownTitle")}),j?e.jsxs("span",{className:"mdocs-drawer-item-error",children:[C(d.publishErrorAt)," · ",F(d)]}):e.jsxs("span",{className:"mdocs-drawer-item-meta",children:[C(d.updatedAt)," · ",y("localSnapshot")]})]}),e.jsxs("div",{className:"mdocs-drawer-item-actions",children:[j?e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:h,onClick:()=>z(d.documentId),children:y("recoverDraft")}):e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:S.has(d.documentId)||h,onClick:()=>void B(d.documentId),children:S.has(d.documentId)?y("publishing"):y("publish")}),e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-danger",disabled:h,onClick:()=>I(d.documentId),children:y("delete")})]})]},d.documentId)})})}),e.jsxs("footer",{className:"mdocs-drawer-footer",children:[e.jsx("button",{type:"button",onClick:s,children:y("close")}),e.jsx("button",{type:"button",className:"primary",disabled:m.length===0||h,onClick:()=>void E(),children:h?y("publishing"):`${y("publishAll")} (${m.length})`})]}),g&&e.jsx("div",{className:"mdocs-drawer-toast mdocs-drawer-toast--"+g.type,role:"status",children:g.message})]}),A&&e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&I(null)},children:e.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:y("delete")}),e.jsx("p",{className:"muted",children:y("confirmDeleteDraft")}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>I(null),children:y("cancel")}),e.jsx("button",{type:"button",className:"danger",onClick:()=>void K(A),children:y("delete")})]})]})}),c&&e.jsx(sa,{draft:c,onClose:()=>v(null),onSuccess:()=>k(c.documentId)})]})}function aa(){const{t:a,lang:s}=ce(),p=us(),u=t.useRef(!1),[y,R]=t.useState([]),[f,S]=t.useState(!1),[N,h]=t.useState(""),[w,A]=t.useState("restricted"),[I,c]=t.useState(!1),[v,g]=t.useState(null),[x,D]=t.useState(null),[L,b]=t.useState(""),[B,K]=t.useState(""),[z,k]=t.useState("all"),[E,C]=t.useState(null);t.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const F=t.useCallback(async()=>{S(!0),g(null);try{const i=await hs();if(!u.current)return;R(i)}catch(i){if(!u.current)return;g(ee(a,i))}finally{u.current&&S(!1)}},[a]);t.useEffect(()=>{F()},[F]);async function m(i){if(i.preventDefault(),!N.trim()){g(a("domainNameRequired"));return}c(!0),g(null);try{if(await Ys({domainName:N.trim(),permission:w}),!u.current)return;h(""),A("restricted"),await F()}catch(r){if(!u.current)return;g(ee(a,r))}finally{u.current&&c(!1)}}async function d(i){if(L.trim()){g(null);try{if(await Qs(i,L.trim()),!u.current)return;D(null),C(null),await F()}catch(r){if(!u.current)return;g(ee(a,r))}}}function j(i){D(i.domainId),b(i.domainName),C(null)}function T(){D(null),C(null)}async function $(i,r){g(null);try{if(await Zs(i,r),!u.current)return;C(null),await F()}catch(O){if(!u.current)return;g(ee(a,O))}}async function _(i){if(window.confirm(a("deleteDomainConfirmDetail",{name:i.domainName,count:String(i.docCount)}))){g(null);try{if(await Js(i.domainId),!u.current)return;await F()}catch(r){if(!u.current)return;g(ee(a,r))}}}const Q=t.useCallback(i=>Hs(i,a),[a]),Z=t.useCallback(i=>re(i.domainName,s,a),[s,a]),Y=t.useMemo(()=>{const i=B.trim().toLowerCase();return y.filter(r=>z!=="all"&&r.permission!==z?!1:i?re(r.domainName,s,a).toLowerCase().includes(i)||r.domainName.toLowerCase().includes(i):!0)},[y,B,z,s,a]),G=t.useCallback((i,r)=>{const O=Q(i.permission);return r?`${O} ${a("domainTypeBuiltinSuffix")}`:O},[Q,a]);return{domains:y,loadingDomains:f,domainError:v,newDomainName:N,setNewDomainName:h,newDomainPermission:w,setNewDomainPermission:A,creating:I,handleCreateDomain:m,renamingId:x,setRenamingId:D,renameDraft:L,setRenameDraft:b,startRename:j,cancelRename:T,handleRename:d,changeTypeForId:E,setChangeTypeForId:C,handlePermissionChange:$,handleDelete:_,domainSearch:B,setDomainSearch:K,domainFilter:z,setDomainFilter:k,filteredDomains:Y,visitorId:p,plabel:Q,localizeDomain:Z,domainTypeLabel:G}}const ns={private:0,restricted:1,public:2};function is(a){return Object.prototype.hasOwnProperty.call(ns,a)?ns[a]:null}function cs(a,s){const p=is(a),u=is(s);return p===null||u===null?"invalid":u>p?"upgrade":u<p?"downgrade":"same"}function na(){const{t:a}=ce(),s=aa(),[p,u]=t.useState([]),[y,R]=t.useState(null),[f,S]=t.useState(""),N=t.useRef(null),[h,w]=t.useState(null),A=t.useCallback(async()=>{try{const c=await ps();u(c)}catch{u([])}},[]);t.useEffect(()=>{A()},[A]),t.useEffect(()=>{if(!s.changeTypeForId)return;const c=v=>{var g;(g=N.current)!=null&&g.contains(v.target)||s.setChangeTypeForId(null)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s.changeTypeForId,s.setChangeTypeForId]);async function I(c){R(null);try{const v=await nt(c.domainId);w({domainId:c.domainId,creatorVisitorId:c.creatorVisitorId,initialIds:v.map(g=>g.visitorId),memberRows:v})}catch(v){R({kind:"err",text:translateError(a,v)})}}return e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:a("domainManagement")})}),e.jsx("p",{className:"mdocs-domain-mgmt-restricted-hint",children:a("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:a("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:a("domainName")}),e.jsx("input",{value:s.newDomainName,onChange:c=>s.setNewDomainName(c.target.value),placeholder:a("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:a("domainPermission")}),e.jsx("div",{className:"mdocs-domain-mgmt-type-radios",children:Be.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?a("creating"):a("create")})]})]}),y&&e.jsx("div",{className:"mdocs-settings-card",style:{color:y.kind==="ok"?"var(--mdocs-success, #0a7)":"var(--mdocs-danger)"},children:e.jsx("span",{className:"mdocs-settings-item-desc",children:y.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:a("domainSearchPlaceholder"),className:"mdocs-domain-mgmt-search","aria-label":a("domainSearchPlaceholder")}),e.jsx("div",{className:"mdocs-domain-mgmt-filters",role:"group","aria-label":a("domainPermission"),children:["all",...Be].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"?a("domainFilterAll"):s.plabel(c)},c))})]}),s.loadingDomains?e.jsx("div",{className:"mdocs-settings-card",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:a("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:a("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:a("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:a("domainColName")}),e.jsx("th",{scope:"col",children:a("domainColType")}),e.jsx("th",{scope:"col",className:"mdocs-domain-table-num",children:a("domainColDocCount")}),e.jsx("th",{scope:"col",children:a("domainColActions")})]})}),e.jsx("tbody",{children:s.filteredDomains.map(c=>{const v=Xs(c,s.visitorId),g=et(c.domainId),x=st(c),D=cs(c.permission,"public")==="upgrade",L=D?x?a("domainTooltipTypeLocked"):void 0:a("domainPermissionAlreadyTop");return e.jsxs("tr",{className:g?"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:b=>s.setRenameDraft(b.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:a("save")}),e.jsx("button",{type:"button",onClick:s.cancelRename,children:a("cancel")})]}):e.jsxs("div",{className:"mdocs-domain-table-name-cell",children:[e.jsx("span",{className:"mdocs-domain-table-name",children:s.localizeDomain(c)}),g&&e.jsx("span",{className:"mdocs-domain-badge-builtin",children:a("domainBuiltIn")}),!v&&!g&&e.jsx("span",{className:"mdocs-domain-badge-shared",children:a("shared")})]})}),e.jsx("td",{children:e.jsx("span",{className:"mdocs-domain-table-type",title:L,children:e.jsx("span",{className:"mdocs-domain-permission-badge","data-permission":c.permission,children:s.domainTypeLabel(c,g)})})}),e.jsx("td",{className:"mdocs-domain-table-num",children:c.docCount}),e.jsxs("td",{className:"mdocs-domain-table-actions",children:[g&&e.jsx("span",{className:"mdocs-domain-not-modifiable",children:a("domainNotModifiable")}),!g&&!v&&e.jsx("span",{className:"mdocs-domain-not-creator-inline",children:a("domainNotCreator")}),!g&&v&&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":a("domainChangeType"),children:Be.map(b=>{const K=cs(c.permission,b)==="downgrade";return e.jsx("span",{title:K?a("domainPermissionNoDowngrade"):void 0,children:e.jsx("button",{type:"button",role:"radio","aria-checked":f===b,className:f===b?"active":"",disabled:K,onClick:()=>S(b),children:s.plabel(b)})},b)})}),e.jsx("button",{type:"button",className:"mdocs-domain-type-icon confirm","aria-label":a("save"),disabled:f===""||f===c.permission,onClick:()=>{f&&f!==c.permission&&s.handlePermissionChange(c.domainId,f)},children:e.jsx(Ot,{size:14,strokeWidth:2.5})}),e.jsx("button",{type:"button",className:"mdocs-domain-type-icon cancel","aria-label":a("cancel"),onClick:()=>s.setChangeTypeForId(null),children:e.jsx(tt,{size:14,strokeWidth:2.5})})]}),!g&&v&&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 I(c),children:a("domainMembersManageButton")}),e.jsx("button",{type:"button",className:"mdocs-domain-action",title:x?a("domainLocked"):void 0,onClick:()=>{s.setChangeTypeForId(null),s.startRename(c)},disabled:x,children:a("rename")}),e.jsx("button",{type:"button",className:"mdocs-domain-action",title:L,onClick:()=>{s.setRenamingId(null),S(c.permission),s.setChangeTypeForId(c.domainId)},disabled:!D,children:a("domainChangeType")}),e.jsx("button",{type:"button",className:"mdocs-domain-action mdocs-domain-action--danger",title:x?a("domainLocked"):void 0,onClick:()=>void s.handleDelete(c),disabled:x,children:a("deleteDomain")})]})]})]},c.domainId)})})]})})]}),e.jsx(ys,{open:h!==null,title:a("domainMembersPickerTitle"),initialSelectedIds:(h==null?void 0:h.initialIds)??[],lockedIds:h?[h.creatorVisitorId]:[],seedMembers:h==null?void 0:h.memberRows,templates:p,onClose:()=>w(null),onConfirm:async c=>{h&&(await at(h.domainId,c),R({kind:"ok",text:a("domainMembersSaved",{count:String(c.length)})}))}})]})}function ls(a){return a.length<=6?a:`${a.slice(0,6)}…`}function ia(){const{t:a}=ce(),s=t.useRef(!0),[p,u]=t.useState([]),[y,R]=t.useState(!0),[f,S]=t.useState(null),[N,h]=t.useState(1),[w,A]=t.useState(null),[I,c]=t.useState(""),[v,g]=t.useState([]),[x,D]=t.useState(!1),[L,b]=t.useState(null),[B,K]=t.useState(!1),z=us(),[k,E]=t.useState([]),[C,F]=t.useState("idle"),[m,d]=t.useState("");t.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),t.useEffect(()=>{F("loading"),gs().then(o=>{s.current&&(E(o),F("ok"))}).catch(()=>{s.current&&F("err")})},[]);const j=t.useMemo(()=>{const o=new Map;for(const P of k)o.set(P.visitorId,P.visitorName);return o},[k]),T=t.useCallback(async()=>{R(!0),b(null);try{const o=await ps();s.current&&u(o)}catch(o){s.current&&b(ee(a,o))}finally{s.current&&R(!1)}},[a]);t.useEffect(()=>{T()},[T]);const $=t.useMemo(()=>v.map(o=>{const P=k.find(W=>W.visitorId===o);return{visitorId:o,name:P?P.visitorName:a("visitorPickerUnknownVisitor"),muted:!P}}),[v,k,a]);function _(o){g(P=>P.includes(o)?P.filter(W=>W!==o):[...P,o])}const Q=N===1?I.trim().length>0:N===2?v.length>0:!0;function Z(){if(!(N>=3)){if(!Q){K(!0);return}K(!1),h(N+1),d("")}}function Y(){N<=1||(K(!1),h(N-1))}function G(){S(null),A(null),c(""),g(z?[z]:[]),b(null),h(1),d(""),K(!1)}function i(o){S(null),A(o.id),c(o.displayName);const P=z&&!o.visitorIds.includes(z)?[...o.visitorIds,z]:[...o.visitorIds];g(P),b(null),h(1),d(""),K(!1)}async function r(){if(!(!I.trim()||v.length===0)){D(!0),b(null);try{if(w===null?await it({displayName:I.trim(),visitorIds:v}):await ct(w,{displayName:I.trim(),visitorIds:v}),!s.current)return;G(),await T()}catch(o){if(!s.current)return;b(ee(a,o))}finally{s.current&&D(!1)}}}async function O(o){D(!0),b(null);try{if(await lt(o),!s.current)return;S(null),w===o&&G(),await T()}catch(P){if(!s.current)return;b(ee(a,P))}finally{s.current&&D(!1)}}const V=[{key:1,label:a("memberTemplateStepName")},{key:2,label:a("memberTemplateStepMembers")},{key:3,label:a("memberTemplateStepSave")}],U=`${(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:a(w!==null?"memberTemplateUpdate":"memberTemplateFormNew")}),w!==null&&e.jsx("button",{type:"button",className:"secondary",onClick:G,style:{fontSize:12},children:a("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:U}})}),e.jsx("div",{className:"mdocs-wizard-progress-steps",children:V.map(o=>{const P=N===o.key,W=N>o.key;return e.jsxs("div",{className:"mdocs-wizard-step-indicator",children:[e.jsx("div",{className:`mdocs-wizard-step-circle${P?" current":""}${W?" done":""}`,children:W?"✓":o.key}),e.jsx("span",{className:`mdocs-wizard-step-label${P?" current":""}${W?" done":""}`,children:o.label})]},o.key)})})]}),L&&e.jsx("div",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)",marginBottom:12,marginTop:12},children:L}),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:I,onChange:o=>c(o.target.value),placeholder:a("memberTemplateNamePlaceholder"),maxLength:200,disabled:x,autoFocus:!0,"aria-invalid":B&&!I.trim()}),B&&!I.trim()&&e.jsx("p",{className:"mdocs-wizard-hint",style:{color:"var(--mdocs-danger)"},children:a("domainNameRequired")})]}),N===2&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx(Bt,{visitors:k,loadState:C,searchFilter:m,onSearchChange:d,selectedIds:new Set(v),onToggle:_,selectedRows:$,myVisitorId:z}),e.jsx("p",{className:`mdocs-wizard-hint${B&&v.length===0?" danger":""}`,children:"💡 "+a("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:a("memberTemplateNameLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:I})]}),e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:a("memberTemplateIdsLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:a("memberTemplateSelectedSummary",{count:String(v.length)})})]}),v.length>0&&e.jsxs("div",{className:"mdocs-wizard-preview-tags",children:[v.slice(0,15).map(o=>e.jsx("span",{className:"mdocs-wizard-preview-tag",children:ls(o)},o)),v.length>15&&e.jsxs("span",{className:"mdocs-wizard-preview-tag mdocs-wizard-preview-tag-more",children:["+",v.length-15]})]})]})}),e.jsxs("div",{className:"mdocs-wizard-footer",children:[e.jsxs("button",{type:"button",className:"secondary",onClick:Y,children:["← ",a("memberTemplateWizardBack")]}),N<3?e.jsxs("button",{type:"button",className:"primary",onClick:Z,children:[a("memberTemplateWizardNext")," →"]}):e.jsx("button",{type:"button",className:"primary",onClick:()=>void r(),children:a(x?"saving":w===null?"memberTemplateCreate":"memberTemplateUpdate")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:a("memberTemplateSavedList")}),y?e.jsx("span",{className:"mdocs-settings-item-desc",children:a("loading")}):p.length===0?e.jsxs("div",{className:"mdocs-member-template-empty",children:[e.jsx("span",{className:"mdocs-settings-item-desc",children:a("memberTemplateEmpty")}),w===null&&e.jsx("button",{type:"button",className:"primary",onClick:G,children:a("memberTemplateEmptyAction")})]}):e.jsx("ul",{className:"mdocs-member-template-list",children:p.map(o=>e.jsx("li",{className:"mdocs-member-template-row",children:f===o.id?e.jsxs("div",{className:"mdocs-member-template-confirm-row",children:[e.jsx("span",{className:"mdocs-member-template-confirm-text",children:a("memberTemplateConfirmDeleteDesc",{name:o.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 O(o.id),children:a(x?"saving":"memberTemplateConfirmDeleteSubmit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>S(null),children:a("memberTemplateConfirmDeleteCancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-member-template-row-head",children:[e.jsx("strong",{children:o.displayName}),e.jsx("span",{className:"mdocs-settings-item-desc",children:a("memberTemplateCount",{count:String(o.visitorIds.length)})}),o.visitorIds.length>0&&e.jsx("div",{className:"mdocs-member-template-tags mdocs-member-template-tags-scroll",children:o.visitorIds.map(P=>e.jsx("span",{className:"mdocs-member-template-tag",children:j.get(P)??ls(P)},P))})]}),e.jsxs("div",{className:"mdocs-member-template-row-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>i(o),children:a("edit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>S(o.id),children:a("memberTemplateDelete")})]})]})},o.id))})]})]})]})}const ca=[{value:"deepseek-flash",label:"deepseek-flash(V4.1 Flash)"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro(将路由至 Flash)"}],la=[{value:"openai-completions",label:"OpenAI 兼容"},{value:"anthropic-messages",label:"Anthropic 兼容"}];function oa(a,s,p){return a==="deepseek"?"Deepseek":s||p}function os(a){return`${oa(a.kind,a.providerId,a.name)} · ${a.modelId} · ${a.name}`}function ra(){const{t:a}=ce(),s=t.useRef(!0),[p,u]=t.useState(""),[y,R]=t.useState([]),[f,S]=t.useState(null),[N,h]=t.useState(null),[w,A]=t.useState("deepseek"),[I,c]=t.useState(""),[v,g]=t.useState(""),[x,D]=t.useState(""),[L,b]=t.useState("openai-completions"),[B,K]=t.useState("deepseek-flash"),[z,k]=t.useState(1e6),[E,C]=t.useState(""),[F,m]=t.useState(!1),[d,j]=t.useState(null),[T,$]=t.useState(!1),[_,Q]=t.useState(!0),[Z,Y]=t.useState(!1),[G,i]=t.useState(null),[r,O]=t.useState(!1),[V,U]=t.useState(!1),[o,P]=t.useState(!1),[W,se]=t.useState(null),[ae,ne]=t.useState(null),te=t.useRef(!1);t.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]);const le=t.useCallback(async()=>{const l=await ot();if(s.current)return R(l),l},[]);function ie(){h(null),A("deepseek"),c(""),g(""),D(""),b("openai-completions"),K("deepseek-flash"),k(1e6),C(""),m(!1),j(null),$(!1),U(!1),P(!1),i(null),O(!1)}function ye(l){h(l.id),A(l.kind),c(l.name),g(l.providerId??""),D(l.baseUrl),b(l.apiType);const J=l.modelId.trim(),Ne=new Set(["deepseek-flash","deepseek-v4-flash","deepseek-v4-flash-vision-exp","deepseek-v4.1-flash","deepseek-v4.1-flash-expires-on-0910"]);K(l.kind==="deepseek"?J==="deepseek-v4-pro"?"deepseek-v4-pro":Ne.has(J)?"deepseek-flash":J||"deepseek-flash":J),k(l.contextWindow||1e6),m(l.hasApiKey),j(l.apiKeyMasked),C(""),$(l.isDefault)}t.useEffect(()=>{(async()=>{try{const l=await rt();if(!s.current)return;u(l.visitorName);const J=await le();if(!s.current||!J)return;J.length===0&&(ie(),S("create"))}catch(l){if(!s.current)return;i(l instanceof Error?l.message:String(l)),S("create")}finally{s.current&&Q(!1)}})()},[le]);function be(){ie(),S("create")}function Ie(l){ye(l),S("edit"),O(!1),i(null)}function ue(){ie(),S(null)}async function Te(l){if(!(l.isDefault||ae)){ne(l.id),i(null);try{await dt(l.id),await le()}catch(J){if(!s.current)return;i(J instanceof Error?J.message:String(J))}finally{s.current&&ne(null)}}}async function je(){if(W){Y(!0),i(null);try{await ut(W.id);const l=await le();if(!s.current)return;f==="edit"&&N===W.id&&ue(),((l==null?void 0:l.length)??0)===0&&(ie(),S("create"))}catch(l){if(!s.current)return;i(l instanceof Error?l.message:String(l))}finally{s.current&&(Y(!1),se(null))}}}async function de(){Y(!0),i(null),O(!1);try{const l=w==="custom"?{...f==="edit"&&N?{id:N}:{},...f==="create"&&T?{isDefault:!0}:{},kind:w,baseUrl:x,modelId:B,providerId:v.trim()||void 0,apiType:L,name:I,contextWindow:z,...E.trim()?{apiKey:E.trim()}:{}}:{...f==="edit"&&N?{id:N}:{},...f==="create"&&T?{isDefault:!0}:{},kind:w,modelId:B,name:I,contextWindow:z,...E.trim()?{apiKey:E.trim()}:{}};if(await mt(l),!s.current)return;await le(),O(!0),S(null),ie()}catch(l){if(!s.current)return;i(l instanceof Error?l.message:String(l))}finally{s.current&&Y(!1)}}const Ae=f!==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:a("agentConfig")}),_?null:e.jsx("button",{type:"button",className:"secondary",onClick:be,children:"添加配置"})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[!_&&y.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:y.map(l=>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:l.isDefault,disabled:ae!==null,onChange:()=>void Te(l)}),e.jsx("span",{children:l.isDefault?"默认":"设为默认"})]}),e.jsxs("div",{className:"mdocs-agent-config-item-main",children:[e.jsx("strong",{children:os(l)}),l.kind==="custom"?e.jsx("span",{className:"mdocs-agent-badge",children:"自定义"}):null,e.jsx("p",{className:"mdocs-agent-config-item-meta",children:l.hasApiKey?`Key ${l.apiKeyMasked??"已配置"}`:"未配置 Key"})]}),e.jsxs("div",{className:"mdocs-agent-config-item-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Ie(l),children:a("edit")}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>se(l),children:"删除"})]})]},l.id))}),r?e.jsx("p",{className:"mdocs-agent-config-ok",children:a("saved")}):null,G?e.jsx("p",{className:"mdocs-agent-config-error",children:G}):null]}):null,Ae?e.jsxs("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:[e.jsxs("p",{className:"mdocs-agent-config-lead",children:[f==="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":w==="deepseek",className:w==="deepseek"?"active":"",onClick:()=>A("deepseek"),children:"Deepseek"}),e.jsx("button",{type:"button",role:"tab","aria-selected":w==="custom",className:w==="custom"?"active":"",onClick:()=>A("custom"),children:"自定义"})]}),w==="deepseek"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:a("agentConfigModel")}),e.jsx(ss,{options:[...ca],value:B,onChange:K})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:a("agentConfigApiKey")}),e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:V?"text":"password",value:E,onChange:l=>C(l.target.value),placeholder:F?a("agentConfigApiKeyConfigured").replace("{{masked}}",d??"…"):a("agentConfigApiKeyPlaceholder"),autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":a(V?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>U(l=>!l),children:V?"隐藏":"显示"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"API 地址"}),e.jsx("input",{type:"url",value:x,onChange:l=>{const J=l.target.value;if(D(J),te.current)return;J.toLowerCase().includes("anthropic")?b("anthropic-messages"):b("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:B,onChange:l=>K(l.target.value),placeholder:"模型名称,如 gpt-4o",className:"mdocs-agent-mono"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:a("agentConfigApiKey")}),e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:V?"text":"password",value:E,onChange:l=>C(l.target.value),placeholder:F?a("agentConfigApiKeyConfigured").replace("{{masked}}",d??"…"):"粘贴 API Key",autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":a(V?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>U(l=>!l),children:V?"隐藏":"显示"})]})]})]}),e.jsxs("details",{className:"mdocs-agent-advanced",open:o,onToggle:l=>P(l.target.open),children:[e.jsx("summary",{children:"高级选项"}),w==="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:v,onChange:l=>g(l.target.value),placeholder:"不填则自动从 API 地址提取域名"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"API 协议"}),e.jsx(ss,{options:[...la],value:L,onChange:l=>{te.current=!0,b(l)}})]})]}):null,e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:a("agentConfigName")}),e.jsx("input",{type:"text",value:I,onChange:l=>c(l.target.value),placeholder:a("agentConfigNameDefault").replace("{{name}}",p||"…")})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:a("agentConfigContextWindow")}),e.jsx("input",{type:"number",min:1e3,max:2e6,step:1e3,value:z,onChange:l=>k(Number(l.target.value)||1e6)}),e.jsx("p",{className:"mdocs-agent-field-hint",children:a("agentConfigContextWindowDesc")})]})]}),f==="create"&&y.length>0?e.jsxs("label",{className:"mdocs-agent-config-default-check",children:[e.jsx("input",{type:"checkbox",checked:T,onChange:l=>$(l.target.checked)}),e.jsx("span",{children:"保存后设为默认配置"})]}):null,G?e.jsx("p",{className:"mdocs-agent-config-error",children:G}):null,e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void de(),disabled:Z,children:a(Z?"saving":"save")}),y.length>0?e.jsx("button",{type:"button",className:"secondary",onClick:ue,disabled:Z,children:a("cancel")}):null]})]})]}):_?e.jsx("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:e.jsx("p",{className:"mdocs-agent-config-muted",children:a("loading")})}):null]}),W?e.jsx(fs,{title:"删除配置",message:`确定删除「${os(W)}」?${W.isDefault&&y.length>1?" 删除后将自动把另一条设为默认。":""}`,confirmLabel:"删除",cancelLabel:a("cancel"),onConfirm:()=>void je(),onCancel:()=>se(null)}):null]})}const da=/^[A-Za-z0-9_]+$/;function Oe(a){return da.test(a.trim())}function ma(){const a=t.useRef(!0),[s,p]=t.useState([]),[u,y]=t.useState(!0),[R,f]=t.useState(null),[S,N]=t.useState(null),[h,w]=t.useState(!1),[A,I]=t.useState(""),[c,v]=t.useState(""),[g,x]=t.useState(""),[D,L]=t.useState(!1);t.useEffect(()=>(a.current=!0,()=>{a.current=!1}),[]);async function b(){y(!0),f(null);try{const m=await ht();if(!a.current)return;p(m)}catch(m){if(!a.current)return;f(m instanceof Error?m.message:String(m))}finally{a.current&&y(!1)}}t.useEffect(()=>{b()},[]);function B(){w(!0),N(null),I(""),v(""),x(""),f(null)}function K(m){w(!1),N(m.id),I(m.name),v(m.description),x(m.body),f(null)}function z(){w(!1),N(null),I(""),v(""),x("")}async function k(){const m=A.trim();if(!Oe(m)){f("名称仅允许英文、数字、下划线");return}if(!g.trim()){f("正文不能为空");return}L(!0),f(null);try{if(h?await pt({name:m,description:c,body:g}):S&&await gt(S,{name:m,description:c,body:g}),!a.current)return;z(),await b()}catch(d){if(!a.current)return;f(d instanceof Error?d.message:String(d))}finally{a.current&&L(!1)}}async function E(m){if(window.confirm("删除该 Skill?已引用的历史轮次将跳过缺失项。")){f(null);try{if(await ft(m),!a.current)return;S===m&&z(),await b()}catch(d){if(!a.current)return;f(d instanceof Error?d.message:String(d))}}}const C=h||S!==null,F=!A.trim()||Oe(A);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",!u&&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:B,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:"私人提示词宏。名称对本账号唯一,仅英文、数字、下划线;智能助手 / 帮写里按名称引用。"}),R?e.jsx("p",{className:"mdocs-agent-skills-error",children:R}):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:h?"新建 Skill":"编辑 Skill"})}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"名称"}),e.jsx("input",{type:"text",value:A,onChange:m=>I(m.target.value),maxLength:64,spellCheck:!1,autoComplete:"off",placeholder:"e.g. weekly_report",className:F?void 0:"mdocs-agent-skills-input-invalid"}),F?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=>v(m.target.value),maxLength:200,placeholder:"一句话说明用途"})]}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:g,onChange:m=>x(m.target.value),rows:10,placeholder:"写入 Agent 应遵守的步骤与约束…"})]}),e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void k(),disabled:D||!F||!A.trim()||!g.trim(),children:D?"保存中…":"保存"}),e.jsx("button",{type:"button",className:"secondary",onClick:z,disabled:D,children:"取消"})]})]}):null,u?e.jsx("p",{className:"mdocs-settings-item-desc",children:"加载中…"}):null,!u&&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:B,children:"新建第一个"})]}):null,!u&&s.length>0?e.jsx("ul",{className:"mdocs-agent-skills-list",children:s.map(m=>{const d=Oe(m.name),j=S===m.id;return e.jsxs("li",{className:"mdocs-agent-skills-item"+(j?" 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}),d?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:()=>K(m),disabled:C&&!j,children:"编辑"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>void E(m.id),disabled:C,children:"删除"})]})]},m.id)})}):null]})})]})}const ua={algorithm:$t.defaultAlgorithm,token:{colorPrimary:"#4CAF50",colorLink:"#4CAF50",colorInfo:"#4CAF50",colorSuccess:"#66BB6A",colorBgBase:"#ffffff",colorBgContainer:"#ffffff",colorText:"#212121",colorTextSecondary:"#616161",colorBorder:"#E0E0E0",colorFillSecondary:"#E8F5E9",borderRadius:8,fontFamily:"inherit"},components:{Table:{headerBg:"#F5F5F5",headerColor:"#212121",rowHoverBg:"#E8F5E9",borderColor:"#E0E0E0"},Button:{primaryShadow:"none"},Tag:{defaultBg:"#F5F5F5",defaultColor:"#616161"}}};function rs(a,s){if(!a)return"—";const p=new Date(a);return Number.isNaN(p.getTime())?"—":p.toLocaleString(s==="zh"?"zh-CN":"en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function ha(a){const{t:s,lang:p}=ce(),[u,y]=t.useState(!1),[R,f]=t.useState(!1),[S,N]=t.useState(!1),[h,w]=t.useState([]),[A,I]=t.useState([]),[c,v]=t.useState(null),[g,x]=t.useState(null),[D,L]=t.useState(""),[b,B]=t.useState("keyword"),[K,z]=t.useState(null),[k,E]=t.useState(!1),C=t.useRef(0),[F,m]=t.useState({current:1,pageSize:20}),[d,j]=t.useState(0);async function T(){y(!0),x(null);try{const i=await xt();N(i.modelReady),w(i.items),I([]),j(i.items.length),m(r=>({...r,current:1}))}catch(i){x(ee(s,i)||s("embeddingIndexLoadFailed"))}finally{y(!1)}}t.useEffect(()=>{T()},[]);const $=t.useMemo(()=>{const i=new Map;for(const r of h)i.has(r.domainId)||i.set(r.domainId,re(r.domainName,p,s));return Array.from(i.entries()).map(([r,O])=>({text:O,value:r}))},[h,p,s]),_=t.useMemo(()=>{const i=D.trim().toLowerCase();return i?h.filter(r=>(r.displayName||"").toLowerCase().includes(i)||(r.relativePath||"").toLowerCase().includes(i)||r.documentId.toLowerCase().includes(i)):h},[h,D]),Q=b==="semantic"&&!!D.trim();t.useEffect(()=>{if(b!=="semantic")return;const i=D.trim();if(!i){C.current+=1,z(null);return}const r=++C.current;E(!0);const O=window.setTimeout(()=>{(async()=>{try{const V=await xs({query:i,mode:"semantic",topN:50});if(r!==C.current)return;const U=new Map(h.map(o=>[o.documentId,o]));z(V.results.map(o=>{const P=U.get(o.documentId);return P?{...P,snippet:o.snippet}:{documentId:o.documentId,displayName:o.displayName,relativePath:o.relativePath,domainId:o.domainId,domainName:o.domainId,documentUpdatedAt:o.updatedAt,chunkCount:0,chunkUnknown:!0,embeddingUpdatedAt:null,snippet:o.snippet}}))}catch{r===C.current&&z([])}finally{r===C.current&&E(!1)}})()},300);return()=>window.clearTimeout(O)},[b,D,h]);const Z=Q?K??[]:_;t.useEffect(()=>{j(Z.length),m(i=>({...i,current:1}))},[Z.length,b]);const Y=t.useMemo(()=>[{title:s("myDocumentsColTitle"),dataIndex:"displayName",key:"displayName",ellipsis:!0,sorter:(i,r)=>(i.displayName||i.relativePath).localeCompare(r.displayName||r.relativePath,p==="zh"?"zh":"en"),render:(i,r)=>e.jsxs("div",{style:{minWidth:0},children:[e.jsx("button",{type:"button",className:"mdocs-linkish",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontWeight:500,color:"inherit",textAlign:"left"},onClick:()=>a.onOpenDocument(r.documentId),children:r.displayName||r.relativePath||"Untitled"}),r.snippet&&e.jsx("div",{className:"mdocs-embedding-index-snippet",title:r.snippet,children:r.snippet})]})},{title:s("myDocumentsColDomain"),dataIndex:"domainId",key:"domainId",width:160,ellipsis:!0,filters:$,onFilter:(i,r)=>r.domainId===i,sorter:(i,r)=>re(i.domainName,p,s).localeCompare(re(r.domainName,p,s),p==="zh"?"zh":"en"),render:(i,r)=>re(r.domainName,p,s)},{title:s("embeddingIndexColDocUpdated"),dataIndex:"documentUpdatedAt",key:"documentUpdatedAt",width:160,sorter:(i,r)=>new Date(i.documentUpdatedAt).getTime()-new Date(r.documentUpdatedAt).getTime(),defaultSortOrder:"descend",render:i=>rs(i,p)},{title:s("embeddingIndexColStatus"),dataIndex:"chunkCount",key:"buildStatus",width:140,filters:[{text:s("embeddingIndexFilterBuilt"),value:"built"},{text:s("embeddingIndexFilterMissing"),value:"missing"}],onFilter:(i,r)=>i==="built"?r.chunkCount>0:r.chunkCount===0,sorter:(i,r)=>i.chunkCount-r.chunkCount,render:(i,r)=>r.chunkUnknown?e.jsx(Ke,{color:"success",children:s("embeddingIndexStatusBuiltUnknown")}):i>0?e.jsx(Ke,{color:"success",children:s("embeddingIndexStatusReady",{chunks:String(i)})}):e.jsx(Ke,{children:s("embeddingIndexStatusMissing")})},{title:s("embeddingIndexColBuiltAt"),dataIndex:"embeddingUpdatedAt",key:"embeddingUpdatedAt",width:160,sorter:(i,r)=>{const O=i.embeddingUpdatedAt?new Date(i.embeddingUpdatedAt).getTime():0,V=r.embeddingUpdatedAt?new Date(r.embeddingUpdatedAt).getTime():0;return O-V},render:i=>rs(i,p)}],[$,p,a,s]);async function G(){const i=A.map(String);if(i.length!==0){f(!0),v(null),x(null);try{const r=await yt(i);N(r.modelReady),v(s("embeddingIndexRebuildResult",{ok:String(r.ok.length),skipped:String(r.skipped.length),failed:String(r.failed.length)})),await T()}catch(r){x(ee(s,r)||s("embeddingIndexRebuildFailed"))}finally{f(!1)}}}return e.jsx(Ut,{theme:ua,children:e.jsxs("div",{className:"mdocs-settings mdocs-embedding-index",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("embeddingIndex")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("p",{className:"muted",style:{marginTop:0},children:s("embeddingIndexDesc")}),e.jsxs("p",{style:{margin:"0 0 12px",fontSize:13},children:[s("embeddingIndexModel"),":"," ",e.jsx("strong",{children:s(S?"embeddingIndexModelReady":"embeddingIndexModelPending")})]}),e.jsxs(Vt,{wrap:!0,style:{marginBottom:12},children:[e.jsx(_t,{value:b,"aria-label":s("myDocumentsSearchMode"),onChange:i=>B(i),options:[{label:s("myDocumentsModeKeyword"),value:"keyword"},{label:s("myDocumentsModeSemantic"),value:"semantic"}]}),e.jsx(Wt.Search,{allowClear:!0,placeholder:s(b==="semantic"?"embeddingIndexSearchSemanticPlaceholder":"embeddingIndexSearchPlaceholder"),"aria-label":s(b==="semantic"?"embeddingIndexSearchSemanticPlaceholder":"embeddingIndexSearchPlaceholder"),value:D,onChange:i=>L(i.target.value),style:{width:240},disabled:u||R}),e.jsx(ts,{onClick:()=>void T(),disabled:u||R,children:s("embeddingIndexRefresh")}),e.jsx(ts,{type:"primary",onClick:()=>void G(),disabled:R||A.length===0,loading:R,children:s("embeddingIndexRebuildSelected",{count:String(A.length)})})]}),c&&e.jsx("p",{style:{fontSize:13,color:"var(--mdocs-text-muted)"},children:c}),g&&e.jsx("p",{className:"mdocs-doc-search-error",style:{marginBottom:8},children:g}),Q&&!S&&e.jsx("p",{className:"muted",style:{margin:"0 0 8px",fontSize:13},children:s("myDocumentsSemanticNotReady")}),(()=>{const i=Number(F.pageSize)||20,r=Number(F.current)||1,O=d,V=Math.max(1,Math.ceil(O/i)||1);return e.jsx(qt,{size:"small",rowKey:"documentId",loading:u||Q&&k,columns:Y,dataSource:Z,rowSelection:{selectedRowKeys:A,onChange:U=>I(U)},pagination:{current:r,pageSize:i,total:O,showSizeChanger:!1,showQuickJumper:!1,showTotal:(U,o)=>s("embeddingIndexPageTotal",{from:String(o[0]??0),to:String(o[1]??0),total:String(U)})},onChange:(U,o,P,W)=>{const se=U.pageSize??i,ae=W.currentDataSource.length,ne=Math.max(1,Math.ceil(ae/se)||1);let te=U.current??1;te>ne&&(te=ne),j(ae),m({current:te,pageSize:se})},locale:{emptyText:D.trim()?s("myDocumentsNoMatch"):s("embeddingIndexEmpty"),filterReset:s("embeddingIndexFilterReset"),filterConfirm:s("embeddingIndexFilterOk")},scroll:{x:900},footer:()=>e.jsxs("div",{className:"mdocs-embedding-index-pager",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"flex-end",gap:10},children:[e.jsx("span",{style:{fontSize:13},children:s("embeddingIndexPageSize")}),e.jsx(as,{size:"small",min:5,max:200,step:5,value:i,controls:!0,changeOnWheel:!0,disabled:u||R,"aria-label":s("embeddingIndexPageSize"),onChange:U=>{if(U==null||!Number.isFinite(Number(U)))return;const o=Math.min(200,Math.max(5,Math.floor(Number(U))));m({current:1,pageSize:o})}}),e.jsx("span",{style:{fontSize:13},children:s("embeddingIndexGoPage")}),e.jsx(as,{size:"small",min:1,max:V,step:1,value:Math.min(r,V),controls:!0,changeOnWheel:!0,disabled:u||R||O===0,"aria-label":s("embeddingIndexGoPage"),onChange:U=>{if(U==null||!Number.isFinite(Number(U)))return;const o=Math.min(V,Math.max(1,Math.floor(Number(U))));m(P=>({...P,current:o}))}}),e.jsxs("span",{style:{fontSize:13,color:"var(--mdocs-text-muted)"},children:["/ ",V]})]})})})()]})]})})}function ds(a,s){const p=localStorage.getItem(a);return p===null?s:p==="true"}function Ce(a){const s=new Date(a);if(Number.isNaN(s.getTime()))return"—";const p=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0");return`${s.getFullYear()}-${p}-${u}`}const ms=[{id:"general",labelKey:"general",keywords:["设置","语言","settings","language"],Icon:Nt},{id:"bookmarks",labelKey:"bookmarkTitle",keywords:["收藏","bookmark","star"],Icon:vt},{id:"myDocuments",labelKey:"myDocuments",keywords:["文章","文档","documents","articles"],Icon:kt},{id:"embeddingIndex",labelKey:"embeddingIndex",keywords:["语义","索引","embedding","vector","检索"],Icon:Yt},{id:"domainManagement",labelKey:"domainManagement",keywords:["域","工作空间","workspace","domain"],Icon:Zt},{id:"memberTemplates",labelKey:"memberTemplates",keywords:["成员","模板","members","template","邀请"],Icon:Kt},{id:"agentConfig",labelKey:"agentConfig",keywords:["ai","助手","模型","agent","llm","deepseek"],Icon:ea},{id:"savePublish",labelKey:"saveAndPublish",keywords:["草稿","发布","同步","draft","publish","sync"],Icon:Ht}];function Na(a){const{t:s,lang:p,setLang:u}=ce(),{onBack:y,onPublishDraft:R}=a,f=bt(),[S,N]=t.useState(!1);jt(f,()=>N(!0),{open:S,onClose:()=>N(!1)});const h=t.useRef(!0);t.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]),t.useEffect(()=>{f||N(!1)},[f]);const[w,A]=t.useState(()=>ds("mdocs.autoPublish",!1)),[I,c]=t.useState(()=>ds("mdocs.autoEdit",!0)),[v,g]=t.useState(!1),[x,D]=t.useState("general"),[L,b]=t.useState("");function B(n){D(n),f&&N(!1)}const K=t.useMemo(()=>{const n=L.trim().toLowerCase();return n?ms.filter(M=>s(M.labelKey).toLowerCase().includes(n)?!0:M.keywords.some(q=>q.toLowerCase().includes(n))):ms},[L,s]),z=s(x==="general"?"general":x==="bookmarks"?"bookmarkTitle":x==="myDocuments"?"myDocuments":x==="embeddingIndex"?"embeddingIndex":x==="domainManagement"?"domainManagement":x==="memberTemplates"?"memberTemplates":x==="agentConfig"?"agentConfig":"saveAndPublish"),[k,E]=t.useState([]),[C,F]=t.useState(!0),[m,d]=t.useState(null),[j,T]=t.useState(!1),[$,_]=t.useState(!1),[Q,Z]=t.useState(!1),[Y,G]=t.useState(!1),[i,r]=t.useState(null),[O,V]=t.useState(!1),[U,o]=t.useState(!1),[P,W]=t.useState(!1),[se,ae]=t.useState(""),[ne,te]=t.useState(!1),[le,ie]=t.useState(!1),[ye,be]=t.useState(0),[Ie,ue]=t.useState([]),[Te,je]=t.useState(!1),[de,Ae]=t.useState(""),[l,J]=t.useState([]),[Ne,$e]=t.useState(!1),[ve,bs]=t.useState(""),[he,js]=t.useState("auto"),[ke,Me]=t.useState(null),[Ve,Pe]=t.useState(!0),[me,Ns]=t.useState(0),[_e,We]=t.useState("1"),[qe,vs]=t.useState(0),[pe,ks]=t.useState(""),[Ee,Ss]=t.useState(""),[Se,ws]=t.useState(""),[Cs,Ds]=t.useState(null),[Is,Ts]=t.useState([]),we=t.useRef(0),Re=20,ge=ke!==null,[Ge,As]=t.useState([]),[Ms,Fe]=t.useState(!1),[ze,He]=t.useState(null),[Le,Je]=t.useState(new Map);t.useEffect(()=>{localStorage.setItem("mdocs.autoPublish",String(w))},[w]),t.useEffect(()=>{localStorage.setItem("mdocs.autoEdit",String(I))},[I]),t.useEffect(()=>{x==="savePublish"&&Ue().then(n=>{h.current&&be(n.filter(M=>!M.published).length)})},[x]),t.useEffect(()=>{x==="bookmarks"&&Ps(),x==="myDocuments"&&(xe(),gs().then(n=>{h.current&&Ts(n)}).catch(()=>{}))},[x,pe,Ee,Se]),t.useEffect(()=>{if(x!=="myDocuments")return;const n=ve.trim();if(!n){we.current+=1,Me(null),Pe(!0);return}const M=++we.current,H=window.setTimeout(()=>{(async()=>{try{const q=await xs({query:n,mode:he,domainId:pe||void 0,topN:50});if(!h.current||M!==we.current)return;Me(q.results),Pe(q.modelReady)}catch{if(!h.current||M!==we.current)return;Me([]),Pe(!0)}})()},300);return()=>window.clearTimeout(H)},[x,ve,he,pe]),t.useEffect(()=>{Ze()},[]),t.useEffect(()=>{hs().then(n=>{h.current&&As(n)}).catch(()=>{})},[]);const fe=new Map(Ge.map(n=>[n.domainId,n.domainName]));async function Ze(){try{F(!0);const n=await St();if(!h.current)return;E(n)}catch{}finally{h.current&&F(!1)}}async function Ps(){try{je(!0);const n=await wt();if(!h.current)return;ue(n)}catch{}finally{h.current&&je(!1)}}async function xe(n=0){try{$e(!0);const M=await Ct({offset:n*Re,limit:Re,domainId:pe||void 0,creatorVisitorId:Ee||void 0,groupBy:Se||void 0});if(!h.current)return;J(M.items),Ds(M.groups??null),vs(M.total),Ns(n),We(String(n+1))}catch{}finally{h.current&&$e(!1)}}async function Es(n){try{await Et(n),ue(M=>M.filter(H=>H.documentId!==n))}catch{}}function Rs(){if(k.some(M=>!M.revoked)){_(!0);return}Qe()}async function Qe(){try{T(!0);const n=await Ft();d({token:n.token,name:n.name}),await Ze()}finally{T(!1)}}async function Fs(){try{W(!0);const n=await Mt();r(n.recoveryCode)}finally{W(!1)}}async function zs(n){n.preventDefault();const M=se.trim();if(!(M&&M.length<4))try{te(!0),await Pt(M),ae(""),ie(!0),setTimeout(()=>ie(!1),3e3)}finally{te(!1)}}async function Ls(n){He(n);try{const M=await Rt(n),H=new Map;M.forEach(q=>{H.set(q.visitorId,q.permission)}),Je(H)}catch{Je(new Map)}Fe(!0)}async function Bs(n){if(ze)try{const M=new Set(n.map(q=>q.visitorId)),H=new Set(Le.keys());for(const q of H)M.has(q)||await zt(ze,q);for(const q of n)await Lt(ze,q.visitorId,q.permission);await xe()}finally{Fe(!1),He(null)}}const Ye=Ie.filter(n=>{if(!de.trim())return!0;const M=de.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(M)||(n.ownerVisitorName||"").toLowerCase().includes(M)||(n.domainId||"").toLowerCase().includes(M)}),oe=Math.ceil(qe/Re);return e.jsxs("div",{className:"mdocs-layout"+(f?" mdocs-layout--reader mdocs-layout--settings":""),children:[f&&S?e.jsx("button",{type:"button",className:"mdocs-mobile-nav-scrim","aria-label":s("collapseSidebar"),onClick:()=>N(!1)}):null,e.jsxs("aside",{className:"mdocs-sidebar"+(f?S?" 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:Dt,alt:s("brand"),className:"mdocs-brand-logo"}),e.jsx("span",{children:s("brand")})]}),f?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(It,{size:18})}):null]}),e.jsx("div",{className:"mdocs-config-nav-search",children:e.jsxs("div",{className:"mdocs-config-nav-search-inner",children:[e.jsx(es,{size:14,strokeWidth:1.75,"aria-hidden":!0}),e.jsx("input",{type:"search",value:L,onChange:n=>b(n.target.value),placeholder:s("settingsNavSearch"),"aria-label":s("settingsNavSearch")})]})}),e.jsx("nav",{className:"mdocs-config-tree",children:K.length===0?e.jsx("div",{className:"mdocs-config-nav-empty",children:s("settingsNavNoMatch")}):K.map(n=>{const M=n.Icon,H=x===n.id;return e.jsxs("div",{className:"mdocs-config-item"+(H?" active":""),onClick:()=>B(n.id),children:[e.jsx(M,{size:16,strokeWidth:1.75,"aria-hidden":!0}),e.jsx("span",{children:s(n.labelKey)})]},n.id)})}),e.jsx("footer",{className:"mdocs-settings-sidebar-footer",onClick:y,children:s("backToDocs")})]}),e.jsxs("main",{className:"mdocs-main",children:[f?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(Tt,{size:18,strokeWidth:1.75})}),e.jsx("span",{className:"mdocs-settings-mobile-bar-title",children:z})]}):null,At(),x==="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:p==="en"?"active":"",onClick:()=>u("en"),children:"EN"}),e.jsx("span",{children:"/"}),e.jsx("button",{type:"button",className:p==="zh"?"active":"",onClick:()=>u("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"+(I?" active":""),role:"switch","aria-checked":I,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")}),!C&&k.length>0&&e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8,fontSize:"0.85em",opacity:.8},children:k.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:Rs,disabled:j||C,children:j?"…":k.some(n=>!n.revoked)?s("cliTokenReset"):s("cliTokenCreate")})]}),m&&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:m.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(m.token),G(!1),Z(!0),window.setTimeout(()=>Z(!1),2e3)}catch{Z(!1),G(!0),window.setTimeout(()=>G(!1),3e3)}})()},children:s(Q?"cliTokenCopied":"cliTokenCopy")}),e.jsx("button",{type:"button",onClick:()=>d(null),children:s("close")})]}),Q&&e.jsxs("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:["✓ ",s("cliTokenCopied")]}),Y&&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:P,children:P?"…":"生成恢复码"})]}),i&&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:i})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(i),o(!1),V(!0),window.setTimeout(()=>V(!1),2e3)}catch{V(!1),o(!0),window.setTimeout(()=>o(!1),3e3)}})()},children:O?"已复制":"复制恢复码"}),e.jsx("button",{type:"button",onClick:()=>r(null),children:s("close")})]}),O&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:"✓ 已复制到剪贴板"}),U&&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:zs,style:{marginTop:12},children:[e.jsx("input",{type:"password",placeholder:"输入新密码(至少 4 位,留空则清除密码)",value:se,onChange:n=>ae(n.target.value),minLength:0,style:{marginBottom:8}}),le&&e.jsx("div",{style:{color:"#4caf50",marginBottom:8,fontSize:"0.875rem"},children:"✓ 密码设置成功"}),e.jsx("button",{type:"submit",className:"secondary",disabled:ne,children:ne?"设置中…":"保存密码"})]})]})]})]}):x==="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:de,onChange:n=>Ae(n.target.value)}),Te?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:Ye.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(de?"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:Ye.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>a.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:n.isDeleted?e.jsx("span",{style:{opacity:.5,fontStyle:"italic"},children:"已删除"}):fe.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:()=>Es(n.documentId),children:s("bookmarkRemove")})})]},n.documentId))})]})})})]})]}):x==="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(es,{size:16,strokeWidth:2,"aria-hidden":"true"}),e.jsx("input",{type:"text",placeholder:"搜索文章…",value:ve,onChange:n=>bs(n.target.value)})]}),e.jsxs("select",{className:"mdocs-my-docs-select",value:pe,"aria-label":s("myDocumentsFilterDomain"),onChange:n=>ks(n.target.value),children:[e.jsx("option",{value:"",children:s("myDocumentsFilterAllDomains")}),Ge.map(n=>e.jsx("option",{value:n.domainId,children:fe.get(n.domainId)||n.domainName},n.domainId))]}),e.jsxs("select",{className:"mdocs-my-docs-select",value:he,"aria-label":s("myDocumentsSearchMode"),onChange:n=>js(n.target.value),children:[e.jsx("option",{value:"auto",children:s("myDocumentsModeAuto")}),e.jsx("option",{value:"keyword",children:s("myDocumentsModeKeyword")}),e.jsx("option",{value:"semantic",children:s("myDocumentsModeSemantic")})]}),!ge&&e.jsxs("select",{className:"mdocs-my-docs-select",value:Ee,"aria-label":s("myDocumentsFilterCreator"),onChange:n=>Ss(n.target.value),children:[e.jsx("option",{value:"",children:s("myDocumentsFilterAllCreators")}),Is.map(n=>e.jsx("option",{value:n.visitorId,children:n.visitorName},n.visitorId))]}),!ge&&e.jsxs("select",{className:"mdocs-my-docs-select",value:Se,"aria-label":s("myDocumentsGroupBy"),onChange:n=>ws(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&&!ge?e.jsx("div",{className:"mdocs-my-docs-empty",children:s("loading")}):ge?e.jsx(e.Fragment,{children:ke.length===0?e.jsx("div",{className:"mdocs-my-docs-empty",children:s(he==="semantic"&&!Ve?"myDocumentsSemanticNotReady":"myDocumentsNoMatch")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-my-docs-search-meta",children:[s("myDocumentsResultCount",{count:String(ke.length)}),he==="semantic"&&!Ve?` · ${s("myDocumentsSemanticNotReadyShort")}`:""]}),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:ke.map(n=>e.jsxs("tr",{children:[e.jsx("td",{className:"mdocs-my-docs-title",onClick:()=>a.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:fe.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:n.ownerVisitorName||"—"}),e.jsx("td",{className:"mdocs-my-docs-date",children:Ce(n.updatedAt)}),e.jsx("td",{className:"mdocs-my-docs-date",children:n.createdAt?Ce(n.createdAt):"—"}),e.jsx("td",{className:"mdocs-my-docs-actions",children:e.jsx("button",{type:"button",className:"primary small",onClick:()=>a.onOpenDocument(n.documentId),children:s("bookmarkOpen")})})]},n.documentId))})]})})]})}):e.jsxs(e.Fragment,{children:[l.length===0?e.jsx("div",{className:"mdocs-my-docs-empty",children:s(ve?"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:(Cs??[{key:"",items:l}]).flatMap(n=>{var q;const M=n.key?e.jsx("tr",{className:"mdocs-my-docs-group",children:e.jsx("td",{colSpan:6,children:Se==="domain"?fe.get(n.key)||n.key:((q=n.items[0])==null?void 0:q.creatorName)||n.key})},`group-${n.key}`):null,H=n.items.map(X=>e.jsxs("tr",{children:[e.jsx("td",{className:"mdocs-my-docs-title",onClick:()=>a.onOpenDocument(X.documentId),children:X.displayName||X.relativePath||"Untitled"}),e.jsx("td",{children:fe.get(X.domainId||"")||X.domainId||"—"}),e.jsx("td",{children:X.creatorName||X.creatorVisitorId||"—"}),e.jsx("td",{className:"mdocs-my-docs-date",children:Ce(X.updatedAt)}),e.jsx("td",{className:"mdocs-my-docs-date",children:Ce(X.createdAt)}),e.jsxs("td",{className:"mdocs-my-docs-actions",children:[e.jsx("button",{type:"button",className:"ghost small",onClick:()=>Ls(X.documentId),children:s("docInfoInviteMember")}),e.jsx("button",{type:"button",className:"primary small",onClick:()=>a.onOpenDocument(X.documentId),children:s("bookmarkOpen")})]})]},X.documentId));return M?[M,...H]:H})})]})}),!ge&&e.jsxs("div",{className:"mdocs-my-docs-footer",children:[e.jsx("span",{className:"mdocs-settings-page-info",children:s("myDocumentsPageInfo",{current:String(oe>0?me+1:0),total:String(oe),count:String(qe)})}),oe>1&&e.jsxs("form",{className:"mdocs-my-docs-jump",onSubmit:n=>{n.preventDefault();const M=Number.parseInt(_e,10);if(!Number.isFinite(M))return;const H=Math.min(Math.max(M,1),oe)-1;H!==me&&xe(H)},children:[e.jsx("span",{children:s("myDocumentsJumpTo")}),e.jsx("input",{type:"number",inputMode:"numeric",min:1,max:oe,"aria-label":s("myDocumentsJumpTo"),value:_e,onChange:n=>We(n.target.value)}),e.jsx("button",{type:"submit",className:"secondary small",children:s("myDocumentsJump")})]}),oe>1&&e.jsxs("div",{className:"mdocs-settings-pagination",children:[e.jsx("button",{type:"button",className:"secondary small",disabled:me<=0,onClick:()=>xe(me-1),children:s("myDocumentsPrev")}),e.jsx("button",{type:"button",className:"secondary small",disabled:me>=oe-1,onClick:()=>xe(me+1),children:s("myDocumentsNext")})]})]})]})]})]}):x==="embeddingIndex"?e.jsx(ha,{onOpenDocument:a.onOpenDocument}):x==="domainManagement"?e.jsx(na,{}):x==="memberTemplates"?e.jsx(ia,{}):x==="agentConfig"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx(ra,{}),e.jsx(ma,{})]}):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:y,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"+(w?" active":""),role:"switch","aria-checked":w,onClick:()=>A(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),ye>0?e.jsxs("button",{className:"mdocs-settings-card mdocs-settings-draft-link",onClick:()=>g(!0),children:[e.jsxs("span",{className:"mdocs-settings-draft-link-text",children:["📄 ",s("viewDrafts")," (",ye,")"]}),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")})})]})]}),v&&e.jsx(ta,{onPublish:R,onClose:()=>g(!1),onCountChange:be,onRecover:a.onRecoverDraft})]}),$&&e.jsx(fs,{title:s("cliToken"),message:s("cliTokenResetConfirm"),confirmLabel:s("cliTokenReset"),cancelLabel:s("cancel"),busy:j,onConfirm:()=>{_(!1),Qe()},onCancel:()=>_(!1)}),e.jsx(ys,{open:Ms,title:s("docInfoInviteMember"),initialSelectedIds:[...Le.keys()],initialPermissions:Le,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:s("invitePermissionRead")},{value:"edit",label:s("invitePermissionEdit")}],onClose:()=>Fe(!1),onConfirm:n=>{Bs(n)}})]})}export{Na as SettingsPage};
|