@wsxjs/wsx-press 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/client.cjs +1 -0
- package/dist/client.js +1256 -0
- package/dist/index-ChO3PMD5.js +461 -0
- package/dist/index-uNJnOC7n.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +8 -0
- package/dist/node.cjs +47 -0
- package/dist/node.js +1708 -0
- package/package.json +90 -0
- package/src/client/components/DocLayout.css +49 -0
- package/src/client/components/DocLayout.wsx +92 -0
- package/src/client/components/DocPage.css +56 -0
- package/src/client/components/DocPage.wsx +480 -0
- package/src/client/components/DocSearch.css +113 -0
- package/src/client/components/DocSearch.wsx +328 -0
- package/src/client/components/DocSidebar.css +97 -0
- package/src/client/components/DocSidebar.wsx +173 -0
- package/src/client/components/DocTOC.css +105 -0
- package/src/client/components/DocTOC.wsx +262 -0
- package/src/client/index.ts +32 -0
- package/src/client/styles/code.css +242 -0
- package/src/client/styles/index.css +12 -0
- package/src/client/styles/reset.css +116 -0
- package/src/client/styles/theme.css +171 -0
- package/src/client/styles/typography.css +239 -0
- package/src/index.ts +26 -0
- package/src/node/index.ts +16 -0
- package/src/node/metadata.ts +113 -0
- package/src/node/plugin.ts +223 -0
- package/src/node/search.ts +53 -0
- package/src/node/toc.ts +148 -0
- package/src/node/typedoc.ts +96 -0
- package/src/types/wsx.d.ts +11 -0
- package/src/types.test.ts +118 -0
- package/src/types.ts +150 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WSXJS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@wsxjs/wsx-core"),oe=require("./index-uNJnOC7n.cjs");require("@wsxjs/wsx-marked-components");const te=require("@wsxjs/wsx-router"),re=require("./index.cjs"),ae=require("fuse.js"),ce=".wsx-doc-page{display:flex;flex-direction:column;min-height:100%}.doc-page{flex:1;padding:var(--doc-page-padding-y, 1rem) var(--doc-page-padding-x, 2rem);max-width:1200px;margin:0 auto;width:100%}.doc-loading,.doc-empty{text-align:center;padding:3rem;color:var(--wsx-press-text-secondary, #666)}.doc-error{padding:2rem;background:var(--wsx-press-error-bg, #fee);border:1px solid var(--wsx-press-error-border, #fcc);border-radius:4px;color:var(--wsx-press-error-text, #c33)}.doc-error h2{margin-top:0;color:var(--wsx-press-error-title, #a00)}.doc-header{margin-bottom:2rem;padding-bottom:1rem;border-bottom:1px solid var(--wsx-press-border, #ddd)}.doc-title{margin:0 0 .5rem;font-size:2rem;font-weight:600;color:var(--wsx-press-text-primary, #333)}.doc-description{margin:0;color:var(--wsx-press-text-secondary, #666);font-size:1.1rem}.doc-content{line-height:1.6}";var ve;let xe,we;function G(t,e,r){return(e=je(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ue(t,e,r,o,g,_){function f(i,c,u){return function(n,a){return u&&u(n),i[c].call(n,a)}}function w(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function x(i,c,u,n){if(typeof i!="function"&&(n||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(n?"":" or undefined"));return i}function U(i,c,u,n,a,R,$,I,q,j,v,m,p){function C(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var d,S=c[0],D=c[3],L=!I;if(!L){u||Array.isArray(S)||(S=[S]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(v||m?s={get:le(function(){return D(this)},n,"get"),set:function(l){c[4](this,l)}}:s[b]=D,v||le(s[b],n,a===2?"":b)):v||(s=Object.getOwnPropertyDescriptor(i,n))}for(var h=i,z=S.length-1;z>=0;z-=u?2:1){var H=S[z],K=u?S[z-1]:void 0,B={},k={kind:["field","accessor","method","getter","setter","class"][a],name:n,metadata:R,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");x(O,"An initializer","be",!0),$.push(O)}).bind(null,B)};try{if(L)(d=x(H.call(K,h,k),"class decorators","return"))&&(h=d);else{var A,F;k.static=q,k.private=j,j?a===2?A=function(l){return C(l),s.value}:(a<4&&(A=f(s,"get",C)),a!==3&&(F=f(s,"set",C))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:j?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),h=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof h=="object"&&h)(d=x(h.get,"accessor.get"))&&(s.get=d),(d=x(h.set,"accessor.set"))&&(s.set=d),(d=x(h.init,"accessor.init"))&&E.push(d);else if(h!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(h,(v?"field":"method")+" decorators","return")&&(v?E.push(h):s[b]=h)}}finally{B.v=!0}}return(v||m)&&I.push(function(l,O){for(var M=E.length-1;M>=0;M--)O=E[M].call(l,O);return O}),v||L||(j?m?I.push(f(s,"get"),f(s,"set")):I.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,n,s)),h}function T(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var N=_[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,u,n){var a,R,$=[],I=function(b){return Ne(b)===i},q=new Map;function j(b){b&&$.push(w.bind(null,b))}for(var v=0;v<c.length;v++){var m=c[v];if(Array.isArray(m)){var p=m[1],C=m[2],d=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=C+"/"+D;if(!L&&!d){var E=q.get(s);if(E===!0||E===3&&p!==4||E===4&&p!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+C);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,d?"#"+C:je(C),p,n,D?R=R||[]:a=a||[],$,D,d,L,p===1,D&&d?I:u)}}return j(a),j(R),$}(t,e,g,P);return r.length||T(t,P),{e:X,get c(){var i=[];return r.length&&[T(U(t,[r],o,t.name,5,P,i),P),w.bind(null,i,t)]}}}function je(t){var e=Me(t,"string");return typeof e=="symbol"?e:e+""}function Me(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function le(t,e,r){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:r?r+" "+e:e})}catch{}return t}function Ne(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}const J=oe.L("DocPage"),Y={data:null,promise:null};async function Ce(t,e={},r=1e4){var f;const o=new AbortController,g=setTimeout(()=>o.abort(),r);let _;if(e.signal){const w=new AbortController;e.signal.aborted?w.abort():e.signal.addEventListener("abort",()=>{w.abort()}),o.signal.addEventListener("abort",()=>{w.abort()}),_=w.signal}else _=o.signal;try{const w=await fetch(t,{...e,signal:_});return clearTimeout(g),w}catch(w){if(clearTimeout(g),w instanceof Error&&w.name==="AbortError"){const x=o.signal.aborted;throw((f=e.signal)==null?void 0:f.aborted)?new Error("Request was cancelled"):x?new Error(`Request timeout after ${r}ms`):new Error("Request was aborted")}throw w}}async function He(){return Y.data?Y.data:(Y.promise||(Y.promise=(async()=>{try{const t=await Ce("/.wsx-press/docs-meta.json",{},5e3);if(!t.ok)throw new Error(`Failed to load metadata: ${t.statusText}`);const e=await t.json();return Y.data=e,Y.promise=null,e}catch(t){throw Y.promise=null,t}})()),Y.promise)}we=[y.autoRegister({tagName:"wsx-doc-page"})];exports.DocPage=void 0;class Ke extends y.LightComponent{constructor(){super({styles:ce,styleName:"wsx-doc-page"}),G(this,"_autoStyles",ce),G(this,"loadingState",void 0),G(this,"markdown",void 0),G(this,"metadata",void 0),G(this,"error",void 0),G(this,"currentLoadingPath",null),G(this,"routeChangeUnsubscribe",null),G(this,"loadingAbortController",null),G(this,"isLoading",!1),G(this,"visibilityChangeHandler",null),J.debug("DocPage initialized");const[e,r]=this.useState("loadingState","idle");Object.defineProperty(this,"loadingState",{get:e,set:r,enumerable:!0,configurable:!0});const[o,g]=this.useState("markdown","");Object.defineProperty(this,"markdown",{get:o,set:g,enumerable:!0,configurable:!0});const[_,f]=this.useState("metadata",null);Object.defineProperty(this,"metadata",{get:_,set:f,enumerable:!0,configurable:!0});const[w,x]=this.useState("error",null);Object.defineProperty(this,"error",{get:w,set:x,enumerable:!0,configurable:!0})}onConnected(){this.routeChangeUnsubscribe=te.RouterUtils.onRouteChange(()=>{this.cancelLoading(),this.loadDocument()}),this.visibilityChangeHandler=()=>{document.hidden?this.cancelLoading():this.loadingState==="loading"&&this.currentLoadingPath&&(J.debug("Tab became visible, reloading document"),this.loadDocument())},document.addEventListener("visibilitychange",this.visibilityChangeHandler),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.loadDocument()})})}onDisconnected(){this.routeChangeUnsubscribe&&(this.routeChangeUnsubscribe(),this.routeChangeUnsubscribe=null),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.cancelLoading()}cancelLoading(){this.loadingAbortController&&(this.loadingAbortController.abort(),this.loadingAbortController=null),this.isLoading=!1,this.loadingState==="loading"&&(this.loadingState="idle"),this.currentLoadingPath=null}onAttributeChanged(e,r,o){e==="params"&&this.loadDocument()}async fetchWithTimeout(e,r={},o=1e4){return Ce(e,r,o)}async loadDocument(){this.cancelLoading();try{this.loadingAbortController=new AbortController;const e=te.RouterUtils.getCurrentRoute(),r=e.params;if(!r.category||!r.page){if(J.warn("Missing route parameters:",{params:r,routeInfo:e}),Object.keys(r).length===0){J.debug("Route params not yet initialized, keeping idle state"),this.loadingState="idle";return}this.loadingState="error",this.error=new re.DocumentLoadError("Missing route parameters: category and page are required","INVALID_PARAMS");return}const o=`${r.category}/${r.page}`;this.currentLoadingPath=o,this.isLoading=!0,this.loadingState="loading",this.markdown="",this.error=null,this.metadata=null;const g=await He();if(this.currentLoadingPath!==o||this.loadingAbortController.signal.aborted){J.debug(`Document switched after metadata, ignoring result for ${o}`),this.isLoading=!1,this.loadingState="idle";return}const _=g[o];if(!_){if(this.currentLoadingPath!==o||this.loadingAbortController.signal.aborted){this.isLoading=!1,this.loadingState="idle";return}this.loadingState="error",this.error=new re.DocumentLoadError(`Document not found: ${o}`,"NOT_FOUND"),this.isLoading=!1;return}this.metadata=_;const f=`/docs/${o}.md`,w=await this.fetchWithTimeout(f,{signal:this.loadingAbortController.signal},1e4);if(this.currentLoadingPath!==o||this.loadingAbortController.signal.aborted){J.debug(`Document switched during fetch, ignoring result for ${o}`),this.isLoading=!1,this.loadingState="idle";return}if(!w.ok){w.status===404?(this.loadingState="error",this.error=new re.DocumentLoadError(`Document file not found: ${f}`,"NOT_FOUND")):(this.loadingState="error",this.error=new re.DocumentLoadError(`Failed to load document: ${w.statusText}`,"NETWORK_ERROR",{status:w.status})),this.isLoading=!1;return}const x=await w.text();if(this.currentLoadingPath!==o||this.loadingAbortController.signal.aborted){J.debug(`Document switched after fetch, ignoring result for ${o}`),this.isLoading=!1,this.loadingState="idle";return}this.markdown=x,this.loadingState="success",this.isLoading=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.connected&&this.scheduleRerender()})})}catch(e){if(this.isLoading=!1,e instanceof Error&&e.name==="AbortError"){J.debug("Document loading was cancelled"),this.currentLoadingPath&&(this.loadingState="idle",this.currentLoadingPath=null);return}if(!this.currentLoadingPath){this.loadingState="error",this.error=new re.DocumentLoadError(`Failed to load document: ${e instanceof Error?e.message:String(e)}`,"NETWORK_ERROR",e),J.error("Failed to load document (no current path):",e);return}const r=this.currentLoadingPath;if(this.currentLoadingPath!==r){this.loadingState="idle";return}this.loadingState="error",this.error=new re.DocumentLoadError(`Failed to load document: ${e instanceof Error?e.message:String(e)}`,"NETWORK_ERROR",e),J.error("Failed to load document",e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.connected&&this.scheduleRerender()})})}}render(){var e,r;return this.loadingState==="loading"?y.jsx("div",{class:"doc-page"},y.jsx("div",{class:"doc-loading"},"加载文档中...")):this.loadingState==="error"?y.jsx("div",{class:"doc-page"},y.jsx("div",{class:"doc-error"},y.jsx("h2",null,"加载失败"),y.jsx("p",null,((e=this.error)==null?void 0:e.message)||"未知错误"),((r=this.error)==null?void 0:r.code)==="NOT_FOUND"&&y.jsx("p",null,"文档不存在,请检查路径是否正确。"))):this.loadingState==="success"&&this.markdown?y.jsx("div",{class:"doc-page"},this.metadata&&y.jsx("div",{class:"doc-header"},y.jsx("h1",{class:"doc-title"},this.metadata.title),this.metadata.description&&y.jsx("p",{class:"doc-description"},this.metadata.description)),y.jsx("div",{class:"doc-content"},y.jsx("wsx-markdown",{markdown:this.markdown}))):y.jsx("div",{class:"doc-page"},y.jsx("div",{class:"doc-empty"},"请选择文档"))}}ve=Ke;[exports.DocPage,xe]=Ue(ve,[],we,0,void 0,y.LightComponent).c;xe();const ue=".wsx-doc-search{position:relative;width:100%;max-width:600px}.search-input-wrapper{position:relative}.search-input{width:100%;padding:.75rem 1rem;font-size:1rem;border:1px solid var(--wsx-press-border, #ddd);border-radius:4px;outline:none;transition:border-color .2s}.search-input:focus{border-color:var(--wsx-press-primary, #007bff);box-shadow:0 0 0 3px var(--wsx-press-primary-alpha, rgba(0, 123, 255, .1))}.search-loading{position:absolute;right:1rem;top:50%;transform:translateY(-50%);color:var(--wsx-press-text-secondary, #666);font-size:.875rem}.search-results{position:absolute;top:100%;left:0;right:0;margin-top:.5rem;background:var(--wsx-press-bg, #fff);border:1px solid var(--wsx-press-border, #ddd);border-radius:4px;box-shadow:0 4px 6px #0000001a;max-height:400px;overflow-y:auto;z-index:1000}.search-result{padding:1rem;border-bottom:1px solid var(--wsx-press-border-light, #f0f0f0);cursor:pointer;transition:background-color .2s}.search-result:last-child{border-bottom:none}.search-result:hover,.search-result.selected{background-color:var(--wsx-press-hover-bg, #f5f5f5)}.result-title{font-weight:600;color:var(--wsx-press-text-primary, #333);margin-bottom:.25rem}.result-title mark{background-color:var(--wsx-press-highlight-bg, #ffeb3b);color:var(--wsx-press-highlight-text, #000);padding:0 2px;border-radius:2px}.result-category{font-size:.875rem;color:var(--wsx-press-text-secondary, #666);margin-bottom:.5rem}.result-snippet{font-size:.875rem;color:var(--wsx-press-text-secondary, #666);line-height:1.4}.result-snippet mark{background-color:var(--wsx-press-highlight-bg, #ffeb3b);color:var(--wsx-press-highlight-text, #000);padding:0 2px;border-radius:2px}.search-no-results{position:absolute;top:100%;left:0;right:0;margin-top:.5rem;padding:1rem;background:var(--wsx-press-bg, #fff);border:1px solid var(--wsx-press-border, #ddd);border-radius:4px;box-shadow:0 4px 6px #0000001a;text-align:center;color:var(--wsx-press-text-secondary, #666);z-index:1000}";var Se;let De,Ee;function Q(t,e,r){return(e=Oe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Be(t,e,r,o,g,_){function f(i,c,u){return function(n,a){return u&&u(n),i[c].call(n,a)}}function w(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function x(i,c,u,n){if(typeof i!="function"&&(n||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(n?"":" or undefined"));return i}function U(i,c,u,n,a,R,$,I,q,j,v,m,p){function C(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var d,S=c[0],D=c[3],L=!I;if(!L){u||Array.isArray(S)||(S=[S]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(v||m?s={get:de(function(){return D(this)},n,"get"),set:function(l){c[4](this,l)}}:s[b]=D,v||de(s[b],n,a===2?"":b)):v||(s=Object.getOwnPropertyDescriptor(i,n))}for(var h=i,z=S.length-1;z>=0;z-=u?2:1){var H=S[z],K=u?S[z-1]:void 0,B={},k={kind:["field","accessor","method","getter","setter","class"][a],name:n,metadata:R,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");x(O,"An initializer","be",!0),$.push(O)}).bind(null,B)};try{if(L)(d=x(H.call(K,h,k),"class decorators","return"))&&(h=d);else{var A,F;k.static=q,k.private=j,j?a===2?A=function(l){return C(l),s.value}:(a<4&&(A=f(s,"get",C)),a!==3&&(F=f(s,"set",C))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:j?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),h=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof h=="object"&&h)(d=x(h.get,"accessor.get"))&&(s.get=d),(d=x(h.set,"accessor.set"))&&(s.set=d),(d=x(h.init,"accessor.init"))&&E.push(d);else if(h!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(h,(v?"field":"method")+" decorators","return")&&(v?E.push(h):s[b]=h)}}finally{B.v=!0}}return(v||m)&&I.push(function(l,O){for(var M=E.length-1;M>=0;M--)O=E[M].call(l,O);return O}),v||L||(j?m?I.push(f(s,"get"),f(s,"set")):I.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,n,s)),h}function T(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var N=_[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,u,n){var a,R,$=[],I=function(b){return Ye(b)===i},q=new Map;function j(b){b&&$.push(w.bind(null,b))}for(var v=0;v<c.length;v++){var m=c[v];if(Array.isArray(m)){var p=m[1],C=m[2],d=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=C+"/"+D;if(!L&&!d){var E=q.get(s);if(E===!0||E===3&&p!==4||E===4&&p!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+C);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,d?"#"+C:Oe(C),p,n,D?R=R||[]:a=a||[],$,D,d,L,p===1,D&&d?I:u)}}return j(a),j(R),$}(t,e,g,P);return r.length||T(t,P),{e:X,get c(){var i=[];return r.length&&[T(U(t,[r],o,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Oe(t){var e=We(t,"string");return typeof e=="symbol"?e:e+""}function We(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function de(t,e,r){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:r?r+" "+e:e})}catch{}return t}function Ye(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}const ne=oe.L("DocSearch"),Z={data:null,promise:null};async function he(){return Z.data?Z.data:(Z.promise||(Z.promise=(async()=>{try{const t=await fetch("/.wsx-press/search-index.json");if(!t.ok)throw new Error(`Failed to load search index: ${t.statusText}`);const e=await t.json();return Z.data=e,Z.promise=null,e}catch(t){throw Z.promise=null,t}})()),Z.promise)}Ee=[y.autoRegister({tagName:"wsx-doc-search"})];exports.DocSearch=void 0;class Ge extends y.LightComponent{constructor(){super({styles:ue,styleName:"wsx-doc-search"}),Q(this,"_autoStyles",ue),Q(this,"query",void 0),Q(this,"results",void 0),Q(this,"isOpen",void 0),Q(this,"isLoading",void 0),Q(this,"selectedIndex",void 0),Q(this,"fuse",null),Q(this,"searchTimeout",null),Q(this,"handleInput",T=>{const N=T.target;if(this.query=N.value,this.searchTimeout!==null&&clearTimeout(this.searchTimeout),!this.query.trim()){this.results=[],this.selectedIndex=-1,this.isOpen=!1;return}this.searchTimeout=window.setTimeout(()=>{this.performSearch()},300)}),Q(this,"handleKeyDown",T=>{if(!(!this.isOpen||this.results.length===0))switch(T.key){case"ArrowDown":T.preventDefault(),this.selectedIndex=Math.min(this.selectedIndex+1,this.results.length-1);break;case"ArrowUp":T.preventDefault(),this.selectedIndex=Math.max(this.selectedIndex-1,-1);break;case"Enter":T.preventDefault(),this.selectedIndex>=0&&this.selectedIndex<this.results.length?this.selectResult(this.results[this.selectedIndex]):this.results.length>0&&this.selectResult(this.results[0]);break;case"Escape":T.preventDefault(),this.isOpen=!1,this.query="",this.results=[],this.selectedIndex=-1;break}}),ne.info("DocSearch initialized");const[e,r]=this.useState("query","");Object.defineProperty(this,"query",{get:e,set:r,enumerable:!0,configurable:!0});let o=this.reactive([]);Object.defineProperty(this,"results",{get:()=>o,set:T=>{o=T!==null&&typeof T<"u"&&(Array.isArray(T)||typeof T=="object")?this.reactive(T):T,this.scheduleRerender()},enumerable:!0,configurable:!0});const[g,_]=this.useState("isOpen",!1);Object.defineProperty(this,"isOpen",{get:g,set:_,enumerable:!0,configurable:!0});const[f,w]=this.useState("isLoading",!1);Object.defineProperty(this,"isLoading",{get:f,set:w,enumerable:!0,configurable:!0});const[x,U]=this.useState("selectedIndex",-1);Object.defineProperty(this,"selectedIndex",{get:x,set:U,enumerable:!0,configurable:!0})}async onConnected(){try{const e=await he();this.fuse=new ae(e.documents,e.options)}catch(e){ne.error("Failed to load search index",e)}}async performSearch(){if(!this.fuse)try{this.isLoading=!0;const r=await he();this.fuse=new ae(r.documents,r.options)}catch(r){ne.error("Failed to load search index",r),this.isLoading=!1;return}if(this.isLoading=!1,!this.query.trim()){this.results=[],this.isOpen=!1;return}const e=this.fuse.search(this.query.trim());this.results=e,this.isOpen=this.query.trim().length>0,this.selectedIndex=-1}selectResult(e){const r=new CustomEvent("doc-search-select",{detail:{route:e.item.route},bubbles:!0});this.dispatchEvent(r),this.isOpen=!1,this.query="",this.results=[],this.selectedIndex=-1}highlightTextNodes(e,r){if(!r||r.length===0)return[e];const o=[];for(const w of r)w.indices&&o.push(...w.indices);o.sort((w,x)=>w[0]-x[0]);const g=[];for(const[w,x]of o)g.length===0||g[g.length-1][1]<w?g.push([w,x+1]):g[g.length-1][1]=Math.max(g[g.length-1][1],x+1);const _=[];let f=0;for(const[w,x]of g){w>f&&_.push(e.substring(f,w));const U=document.createElement("mark");U.textContent=e.substring(w,x),_.push(U),f=x}return f<e.length&&_.push(e.substring(f)),_}render(){return y.jsx("div",{class:"doc-search"},y.jsx("div",{class:"search-input-wrapper"},y.jsx("input",{type:"text",class:"search-input",placeholder:"搜索文档...",value:this.query,onInput:this.handleInput,onKeyDown:this.handleKeyDown,onFocus:()=>{this.results.length>0&&(this.isOpen=!0)},"data-wsx-key":"DocSearch-input-text-1-1"}),this.isLoading&&y.jsx("div",{class:"search-loading"},"加载中...")),this.isOpen&&this.results.length>0&&y.jsx("div",{class:"search-results"},this.results.map((e,r)=>{var f,w;const o=r===this.selectedIndex,g=(f=e.matches)==null?void 0:f.find(x=>x.key==="title"),_=(w=e.matches)==null?void 0:w.find(x=>x.key==="content");return y.jsx("div",{key:e.item.id,class:`search-result ${o?"selected":""}`,onClick:()=>this.selectResult(e),onMouseEnter:()=>{this.selectedIndex=r}},y.jsx("div",{class:"result-title"},g?this.highlightTextNodes(e.item.title,[g]):e.item.title),y.jsx("div",{class:"result-category"},e.item.category),_&&y.jsx("div",{class:"result-snippet"},this.highlightTextNodes(e.item.content.substring(0,100),[_])))})),this.isOpen&&this.query.trim()&&this.results.length===0&&!this.isLoading&&y.jsx("div",{class:"search-no-results"},"未找到匹配的文档"))}}Se=Ge;[exports.DocSearch,De]=Be(Se,[],Ee,0,void 0,y.LightComponent).c;De();const ge="wsx-doc-layout{display:flex;flex-direction:row;width:100%;min-height:calc(100vh - var(--nav-height, 70px))}.doc-layout{display:flex;flex-direction:row;width:100%;max-width:1600px;margin:0 auto;gap:0}.doc-layout-sidebar{flex-shrink:0}.doc-layout-main{flex:1;min-width:0;padding:var(--doc-layout-main-padding-y, 1.5rem) var(--doc-layout-main-padding-x, 2rem);max-width:100%}.doc-layout-toc{flex-shrink:0}@media (max-width: 1280px){.doc-layout-toc{display:none}}@media (max-width: 1024px){.doc-layout-sidebar{display:none}.doc-layout-main{padding:var(--doc-layout-main-padding-y, 1.5rem)}}";var _e;let Ie,Le;function se(t,e,r){return(e=Te(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Je(t,e,r,o,g,_){function f(i,c,u){return function(n,a){return u&&u(n),i[c].call(n,a)}}function w(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function x(i,c,u,n){if(typeof i!="function"&&(n||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(n?"":" or undefined"));return i}function U(i,c,u,n,a,R,$,I,q,j,v,m,p){function C(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var d,S=c[0],D=c[3],L=!I;if(!L){u||Array.isArray(S)||(S=[S]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(v||m?s={get:fe(function(){return D(this)},n,"get"),set:function(l){c[4](this,l)}}:s[b]=D,v||fe(s[b],n,a===2?"":b)):v||(s=Object.getOwnPropertyDescriptor(i,n))}for(var h=i,z=S.length-1;z>=0;z-=u?2:1){var H=S[z],K=u?S[z-1]:void 0,B={},k={kind:["field","accessor","method","getter","setter","class"][a],name:n,metadata:R,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");x(O,"An initializer","be",!0),$.push(O)}).bind(null,B)};try{if(L)(d=x(H.call(K,h,k),"class decorators","return"))&&(h=d);else{var A,F;k.static=q,k.private=j,j?a===2?A=function(l){return C(l),s.value}:(a<4&&(A=f(s,"get",C)),a!==3&&(F=f(s,"set",C))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:j?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),h=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof h=="object"&&h)(d=x(h.get,"accessor.get"))&&(s.get=d),(d=x(h.set,"accessor.set"))&&(s.set=d),(d=x(h.init,"accessor.init"))&&E.push(d);else if(h!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(h,(v?"field":"method")+" decorators","return")&&(v?E.push(h):s[b]=h)}}finally{B.v=!0}}return(v||m)&&I.push(function(l,O){for(var M=E.length-1;M>=0;M--)O=E[M].call(l,O);return O}),v||L||(j?m?I.push(f(s,"get"),f(s,"set")):I.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,n,s)),h}function T(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var N=_[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,u,n){var a,R,$=[],I=function(b){return Xe(b)===i},q=new Map;function j(b){b&&$.push(w.bind(null,b))}for(var v=0;v<c.length;v++){var m=c[v];if(Array.isArray(m)){var p=m[1],C=m[2],d=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=C+"/"+D;if(!L&&!d){var E=q.get(s);if(E===!0||E===3&&p!==4||E===4&&p!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+C);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,d?"#"+C:Te(C),p,n,D?R=R||[]:a=a||[],$,D,d,L,p===1,D&&d?I:u)}}return j(a),j(R),$}(t,e,g,P);return r.length||T(t,P),{e:X,get c(){var i=[];return r.length&&[T(U(t,[r],o,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Te(t){var e=Qe(t,"string");return typeof e=="symbol"?e:e+""}function Qe(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function fe(t,e,r){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:r?r+" "+e:e})}catch{}return t}function Xe(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}Le=[y.autoRegister({tagName:"wsx-doc-layout"})];exports.DocLayout=void 0;class Ze extends y.LightComponent{constructor(){super({styles:ge,styleName:"wsx-doc-layout"}),se(this,"_autoStyles",ge),se(this,"sidebarInstance",null),se(this,"docPageInstance",null),se(this,"tocInstance",null)}onConnected(){requestAnimationFrame(()=>{if(this.connected){const e=this.querySelector(".doc-layout-sidebar");e&&!this.sidebarInstance&&(this.sidebarInstance=document.createElement("wsx-doc-sidebar"),e.appendChild(this.sidebarInstance));const r=this.querySelector(".doc-layout-main");r&&!this.docPageInstance&&(this.docPageInstance=document.createElement("wsx-doc-page"),r.appendChild(this.docPageInstance));const o=this.querySelector(".doc-layout-toc");o&&!this.tocInstance&&(this.tocInstance=document.createElement("wsx-doc-toc"),o.appendChild(this.tocInstance))}})}onDisconnected(){this.sidebarInstance&&(this.sidebarInstance.remove(),this.sidebarInstance=null),this.docPageInstance&&(this.docPageInstance.remove(),this.docPageInstance=null),this.tocInstance&&(this.tocInstance.remove(),this.tocInstance=null)}render(){return y.jsx("div",{class:"doc-layout"},y.jsx("aside",{class:"doc-layout-sidebar"}),y.jsx("main",{class:"doc-layout-main"}),y.jsx("aside",{class:"doc-layout-toc"}))}}_e=Ze;[exports.DocLayout,Ie]=Je(_e,[],Le,0,void 0,y.LightComponent).c;Ie();const me="wsx-doc-sidebar{display:flex;flex-direction:column;width:280px;min-width:280px;height:100%;background:var(--wsx-press-sidebar-bg, #f9fafb);border-right:1px solid var(--wsx-press-border, #e5e7eb);overflow-y:auto;position:sticky;top:70px;max-height:calc(100vh - 70px)}.doc-sidebar{display:flex;flex-direction:column;width:100%;height:100%}.doc-sidebar-loading,.doc-sidebar-empty{padding:2rem;text-align:center;color:var(--wsx-press-text-secondary, #6b7280)}.doc-sidebar-nav{padding:1.5rem 0}.doc-sidebar-category{margin-bottom:2rem}.doc-sidebar-category:last-child{margin-bottom:0}.doc-sidebar-category-title{font-size:.875rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--wsx-press-text-secondary, #6b7280);padding:.5rem 1.5rem;margin:0 0 .5rem}.doc-sidebar-list{list-style:none;margin:0;padding:0}.doc-sidebar-item{margin:0}.doc-sidebar-link{display:block;padding:.5rem 1.5rem;color:var(--wsx-press-text-primary, #111827);text-decoration:none;font-size:.875rem;line-height:1.5;transition:all .2s ease;border-left:3px solid transparent}.doc-sidebar-link:hover{background:var(--wsx-press-sidebar-hover-bg, #f3f4f6);color:var(--wsx-press-text-primary, #111827)}.doc-sidebar-link.active{background:var(--wsx-press-sidebar-active-bg, #eff6ff);color:var(--wsx-press-sidebar-active-color, #2563eb);border-left-color:var(--wsx-press-sidebar-active-color, #2563eb);font-weight:500}@media (max-width: 1024px){wsx-doc-sidebar{width:240px;min-width:240px}}@media (max-width: 768px){wsx-doc-sidebar{display:none}}";var Re;let $e,ke;function ie(t,e,r){return(e=Ae(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ve(t,e,r,o,g,_){function f(i,c,u){return function(n,a){return u&&u(n),i[c].call(n,a)}}function w(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function x(i,c,u,n){if(typeof i!="function"&&(n||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(n?"":" or undefined"));return i}function U(i,c,u,n,a,R,$,I,q,j,v,m,p){function C(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var d,S=c[0],D=c[3],L=!I;if(!L){u||Array.isArray(S)||(S=[S]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(v||m?s={get:pe(function(){return D(this)},n,"get"),set:function(l){c[4](this,l)}}:s[b]=D,v||pe(s[b],n,a===2?"":b)):v||(s=Object.getOwnPropertyDescriptor(i,n))}for(var h=i,z=S.length-1;z>=0;z-=u?2:1){var H=S[z],K=u?S[z-1]:void 0,B={},k={kind:["field","accessor","method","getter","setter","class"][a],name:n,metadata:R,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");x(O,"An initializer","be",!0),$.push(O)}).bind(null,B)};try{if(L)(d=x(H.call(K,h,k),"class decorators","return"))&&(h=d);else{var A,F;k.static=q,k.private=j,j?a===2?A=function(l){return C(l),s.value}:(a<4&&(A=f(s,"get",C)),a!==3&&(F=f(s,"set",C))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:j?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),h=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof h=="object"&&h)(d=x(h.get,"accessor.get"))&&(s.get=d),(d=x(h.set,"accessor.set"))&&(s.set=d),(d=x(h.init,"accessor.init"))&&E.push(d);else if(h!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(h,(v?"field":"method")+" decorators","return")&&(v?E.push(h):s[b]=h)}}finally{B.v=!0}}return(v||m)&&I.push(function(l,O){for(var M=E.length-1;M>=0;M--)O=E[M].call(l,O);return O}),v||L||(j?m?I.push(f(s,"get"),f(s,"set")):I.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,n,s)),h}function T(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var N=_[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,u,n){var a,R,$=[],I=function(b){return tt(b)===i},q=new Map;function j(b){b&&$.push(w.bind(null,b))}for(var v=0;v<c.length;v++){var m=c[v];if(Array.isArray(m)){var p=m[1],C=m[2],d=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=C+"/"+D;if(!L&&!d){var E=q.get(s);if(E===!0||E===3&&p!==4||E===4&&p!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+C);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,d?"#"+C:Ae(C),p,n,D?R=R||[]:a=a||[],$,D,d,L,p===1,D&&d?I:u)}}return j(a),j(R),$}(t,e,g,P);return r.length||T(t,P),{e:X,get c(){var i=[];return r.length&&[T(U(t,[r],o,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Ae(t){var e=et(t,"string");return typeof e=="symbol"?e:e+""}function et(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function pe(t,e,r){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:r?r+" "+e:e})}catch{}return t}function tt(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}const rt=oe.L("DocSidebar");ke=[y.autoRegister({tagName:"wsx-doc-sidebar"})];exports.DocSidebar=void 0;class it extends y.LightComponent{constructor(){super({styles:me,styleName:"wsx-doc-sidebar"}),ie(this,"_autoStyles",me),ie(this,"metadata",void 0),ie(this,"currentRoute",void 0),ie(this,"isLoading",void 0),ie(this,"routeChangeUnsubscribe",null),ie(this,"handleDocClick",(f,w)=>{w.preventDefault(),te.RouterUtils.navigate(f)});let e=this.reactive({});Object.defineProperty(this,"metadata",{get:()=>e,set:f=>{e=f!==null&&typeof f<"u"&&(Array.isArray(f)||typeof f=="object")?this.reactive(f):f,this.scheduleRerender()},enumerable:!0,configurable:!0});const[r,o]=this.useState("currentRoute","");Object.defineProperty(this,"currentRoute",{get:r,set:o,enumerable:!0,configurable:!0});const[g,_]=this.useState("isLoading",!0);Object.defineProperty(this,"isLoading",{get:g,set:_,enumerable:!0,configurable:!0})}async onConnected(){await this.loadMetadata(),this.routeChangeUnsubscribe=te.RouterUtils.onRouteChange(()=>{this.updateCurrentRoute()}),this.updateCurrentRoute()}onDisconnected(){this.routeChangeUnsubscribe&&(this.routeChangeUnsubscribe(),this.routeChangeUnsubscribe=null)}async loadMetadata(){try{if(this.isLoading=!0,Y.data)this.metadata=Y.data;else{const e=await fetch("/.wsx-press/docs-meta.json");e.ok&&(this.metadata=await e.json())}}catch(e){rt.error("Failed to load metadata",e)}finally{this.isLoading=!1}}updateCurrentRoute(){const e=te.RouterUtils.getCurrentRoute();this.currentRoute=e.path}organizeByCategory(){const e={};return Object.values(this.metadata).forEach(o=>{const g=o.category||"other";e[g]||(e[g]=[]),e[g].push(o)}),Object.keys(e).sort().forEach(o=>{e[o].sort((g,_)=>g.title.localeCompare(_.title))}),e}isCurrentDoc(e){return this.currentRoute===e}render(){if(this.isLoading)return y.jsx("aside",{class:"doc-sidebar"},y.jsx("div",{class:"doc-sidebar-loading"},"加载中..."));const e=this.organizeByCategory(),r=Object.keys(e);return r.length===0?y.jsx("aside",{class:"doc-sidebar"},y.jsx("div",{class:"doc-sidebar-empty"},"暂无文档")):y.jsx("aside",{class:"doc-sidebar"},y.jsx("nav",{class:"doc-sidebar-nav"},r.map(o=>y.jsx("div",{key:o,class:"doc-sidebar-category"},y.jsx("h3",{class:"doc-sidebar-category-title"},o),y.jsx("ul",{class:"doc-sidebar-list"},e[o].map(g=>y.jsx("li",{key:g.route,class:"doc-sidebar-item"},y.jsx("a",{href:g.route,class:`doc-sidebar-link ${this.isCurrentDoc(g.route)?"active":""}`,onClick:_=>this.handleDocClick(g.route,_)},g.title))))))))}}Re=it;[exports.DocSidebar,$e]=Ve(Re,[],ke,0,void 0,y.LightComponent).c;$e();const be="wsx-doc-toc{display:flex;flex-direction:column;width:240px;min-width:240px;height:100%;overflow-y:auto;position:sticky;top:70px;max-height:calc(100vh - 70px)}.doc-toc{display:flex;flex-direction:column;width:100%;padding:1.5rem 1rem}.doc-toc-empty{padding:1rem;text-align:center;color:var(--wsx-press-text-secondary, #6b7280);font-size:.875rem}.doc-toc-title{font-size:.875rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--wsx-press-text-secondary, #6b7280);margin:0 0 1rem;padding:0}.doc-toc-nav{width:100%}.doc-toc-list{list-style:none;margin:0;padding:0}.doc-toc-sublist{margin-top:.25rem;padding-left:1rem}.doc-toc-item{margin:0;line-height:1.6}.doc-toc-item-level-1{margin-bottom:.5rem}.doc-toc-item-level-2{margin-bottom:.375rem;font-size:.875rem}.doc-toc-item-level-3{margin-bottom:.25rem;font-size:.8125rem}.doc-toc-item-level-4,.doc-toc-item-level-5,.doc-toc-item-level-6{margin-bottom:.25rem;font-size:.75rem}.doc-toc-link{display:block;color:var(--wsx-press-text-secondary, #6b7280);text-decoration:none;transition:color .2s ease;border-left:2px solid transparent;padding:.25rem 0 .25rem .5rem;margin-left:-.5rem}.doc-toc-link:hover{color:var(--wsx-press-text-primary, #111827)}.doc-toc-link.active{color:var(--wsx-press-toc-active-color, #2563eb);border-left-color:var(--wsx-press-toc-active-color, #2563eb);font-weight:500}@media (max-width: 1280px){wsx-doc-toc{display:none}}";var Pe;let qe,ze;function ee(t,e,r){return(e=Fe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function st(t,e,r,o,g,_){function f(i,c,u){return function(n,a){return u&&u(n),i[c].call(n,a)}}function w(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function x(i,c,u,n){if(typeof i!="function"&&(n||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(n?"":" or undefined"));return i}function U(i,c,u,n,a,R,$,I,q,j,v,m,p){function C(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var d,S=c[0],D=c[3],L=!I;if(!L){u||Array.isArray(S)||(S=[S]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(v||m?s={get:ye(function(){return D(this)},n,"get"),set:function(l){c[4](this,l)}}:s[b]=D,v||ye(s[b],n,a===2?"":b)):v||(s=Object.getOwnPropertyDescriptor(i,n))}for(var h=i,z=S.length-1;z>=0;z-=u?2:1){var H=S[z],K=u?S[z-1]:void 0,B={},k={kind:["field","accessor","method","getter","setter","class"][a],name:n,metadata:R,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");x(O,"An initializer","be",!0),$.push(O)}).bind(null,B)};try{if(L)(d=x(H.call(K,h,k),"class decorators","return"))&&(h=d);else{var A,F;k.static=q,k.private=j,j?a===2?A=function(l){return C(l),s.value}:(a<4&&(A=f(s,"get",C)),a!==3&&(F=f(s,"set",C))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:j?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),h=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof h=="object"&&h)(d=x(h.get,"accessor.get"))&&(s.get=d),(d=x(h.set,"accessor.set"))&&(s.set=d),(d=x(h.init,"accessor.init"))&&E.push(d);else if(h!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(h,(v?"field":"method")+" decorators","return")&&(v?E.push(h):s[b]=h)}}finally{B.v=!0}}return(v||m)&&I.push(function(l,O){for(var M=E.length-1;M>=0;M--)O=E[M].call(l,O);return O}),v||L||(j?m?I.push(f(s,"get"),f(s,"set")):I.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,n,s)),h}function T(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var N=_[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,u,n){var a,R,$=[],I=function(b){return nt(b)===i},q=new Map;function j(b){b&&$.push(w.bind(null,b))}for(var v=0;v<c.length;v++){var m=c[v];if(Array.isArray(m)){var p=m[1],C=m[2],d=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=C+"/"+D;if(!L&&!d){var E=q.get(s);if(E===!0||E===3&&p!==4||E===4&&p!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+C);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,d?"#"+C:Fe(C),p,n,D?R=R||[]:a=a||[],$,D,d,L,p===1,D&&d?I:u)}}return j(a),j(R),$}(t,e,g,P);return r.length||T(t,P),{e:X,get c(){var i=[];return r.length&&[T(U(t,[r],o,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Fe(t){var e=ot(t,"string");return typeof e=="symbol"?e:e+""}function ot(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function ye(t,e,r){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:r?r+" "+e:e})}catch{}return t}function nt(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}const at=oe.L("DocTOC"),V={data:null,promise:null};async function ct(){return V.data?V.data:(V.promise||(V.promise=(async()=>{try{const t=await fetch("/.wsx-press/docs-toc.json");if(!t.ok)throw new Error(`Failed to load TOC data: ${t.statusText}`);const e=await t.json();return V.data=e,V.promise=null,e}catch(t){throw V.promise=null,t}})()),V.promise)}ze=[y.autoRegister({tagName:"wsx-doc-toc"})];exports.DocTOC=void 0;class lt extends y.LightComponent{constructor(){super({styles:be,styleName:"wsx-doc-toc"}),ee(this,"_autoStyles",be),ee(this,"items",void 0),ee(this,"activeId",void 0),ee(this,"observer",null),ee(this,"headingElements",new Map),ee(this,"routeChangeUnsubscribe",null),ee(this,"handleTOCClick",(g,_)=>{_.preventDefault();const f=this.headingElements.get(g);f&&(f.scrollIntoView({behavior:"smooth",block:"start"}),window.history.replaceState(null,"",`#${g}`))});let e=this.reactive([]);Object.defineProperty(this,"items",{get:()=>e,set:g=>{e=g!==null&&typeof g<"u"&&(Array.isArray(g)||typeof g=="object")?this.reactive(g):g,this.scheduleRerender()},enumerable:!0,configurable:!0});const[r,o]=this.useState("activeId","");Object.defineProperty(this,"activeId",{get:r,set:o,enumerable:!0,configurable:!0})}async onConnected(){await this.loadTOC(),this.routeChangeUnsubscribe=te.RouterUtils.onRouteChange(()=>{this.loadTOC()})}onDisconnected(){this.observer&&(this.observer.disconnect(),this.observer=null),this.routeChangeUnsubscribe&&(this.routeChangeUnsubscribe(),this.routeChangeUnsubscribe=null)}async loadTOC(){try{const r=te.RouterUtils.getCurrentRoute().params;if(!r.category||!r.page){this.items=[];return}const o=`${r.category}/${r.page}`,g=await ct();this.items=g[o]||[],requestAnimationFrame(()=>{this.setupHeadingIds(),this.setupScrollObserver()})}catch(e){at.error("Failed to load TOC",e),this.items=[]}}setupHeadingIds(){const e=document.querySelector(".doc-content");if(!e)return;const r=e.querySelectorAll("h1, h2, h3, h4, h5, h6, wsx-marked-heading");this.headingElements.clear(),r.forEach(o=>{var f;const g=((f=o.textContent)==null?void 0:f.trim())||"";if(!g)return;const _=this.generateId(g);o instanceof HTMLElement&&(o.id=_,this.headingElements.set(_,o))})}generateId(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}setupScrollObserver(){"IntersectionObserver"in window&&(this.observer=new IntersectionObserver(e=>{const r=e.filter(o=>o.isIntersecting);r.length>0&&(r.sort((o,g)=>{const _=o.boundingClientRect.top,f=g.boundingClientRect.top;return Math.abs(_)-Math.abs(f)}),this.activeId=r[0].target.id)},{rootMargin:"-100px 0px -80% 0px",threshold:0}),this.headingElements.forEach(e=>{var r;(r=this.observer)==null||r.observe(e)}))}renderTOCItem(e){const r=this.activeId===e.id,o=e.children.length>0;return y.jsx("li",{class:`doc-toc-item doc-toc-item-level-${e.level}`},y.jsx("a",{href:`#${e.id}`,class:`doc-toc-link ${r?"active":""}`,onClick:g=>this.handleTOCClick(e.id,g)},e.text),o&&y.jsx("ul",{class:"doc-toc-list doc-toc-sublist"},e.children.map(g=>this.renderTOCItem(g))))}render(){return this.items.length===0?y.jsx("aside",{class:"doc-toc"},y.jsx("div",{class:"doc-toc-empty"},"暂无目录")):y.jsx("aside",{class:"doc-toc"},y.jsx("h3",{class:"doc-toc-title"},"目录"),y.jsx("nav",{class:"doc-toc-nav"},y.jsx("ul",{class:"doc-toc-list"},this.items.map(e=>this.renderTOCItem(e)))))}}Pe=lt;[exports.DocTOC,qe]=st(Pe,[],ze,0,void 0,y.LightComponent).c;qe();
|