@wsxjs/wsx-press 0.0.22 → 0.0.24
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/dist/client.cjs +1 -1
- package/dist/client.js +521 -501
- package/dist/node.cjs +41 -41
- package/dist/node.js +529 -518
- package/package.json +7 -7
- package/src/client/components/DocPage.wsx +32 -16
- package/src/client/components/DocSidebar.css +98 -3
- package/src/client/components/DocSidebar.wsx +17 -2
- package/src/client/components/DocTOC.wsx +9 -3
- package/src/node/metadata.ts +30 -3
- package/src/types.ts +2 -0
package/dist/client.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@wsxjs/wsx-core"),oe=require("./index-C1_yVVPT.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=Ce(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,d,_){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,C,v,m,p){function j(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,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";C?(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 g=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)(h=x(H.call(K,g,k),"class decorators","return"))&&(g=h);else{var A,F;k.static=q,k.private=C,C?a===2?A=function(l){return j(l),s.value}:(a<4&&(A=f(s,"get",j)),a!==3&&(F=f(s,"set",j))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:C?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof g=="object"&&g)(h=x(g.get,"accessor.get"))&&(s.get=h),(h=x(g.set,"accessor.set"))&&(s.set=h),(h=x(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(g,(v?"field":"method")+" decorators","return")&&(v?E.push(g):s[b]=g)}}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||(C?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)),g}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 C(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],j=m[2],h=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=j+"/"+D;if(!L&&!h){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: "+j);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,h?"#"+j:Ce(j),p,n,D?R=R||[]:a=a||[],$,D,h,L,p===1,D&&h?I:u)}}return C(a),C(R),$}(t,e,d,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 Ce(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.createLogger("DocPage"),Y={data:null,promise:null};async function je(t,e={},r=1e4){var f;const o=new AbortController,d=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(d),w}catch(w){if(clearTimeout(d),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 je("/.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,d]=this.useState("markdown","");Object.defineProperty(this,"markdown",{get:o,set:d,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(){var e;(e=super.onConnected)==null||e.call(this),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(){var e;(e=super.onDisconnected)==null||e.call(this),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 je(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 d=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 _=d[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,d,_){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,C,v,m,p){function j(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,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";C?(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 g=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)(h=x(H.call(K,g,k),"class decorators","return"))&&(g=h);else{var A,F;k.static=q,k.private=C,C?a===2?A=function(l){return j(l),s.value}:(a<4&&(A=f(s,"get",j)),a!==3&&(F=f(s,"set",j))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:C?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof g=="object"&&g)(h=x(g.get,"accessor.get"))&&(s.get=h),(h=x(g.set,"accessor.set"))&&(s.set=h),(h=x(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(g,(v?"field":"method")+" decorators","return")&&(v?E.push(g):s[b]=g)}}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||(C?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)),g}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 C(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],j=m[2],h=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=j+"/"+D;if(!L&&!h){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: "+j);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,h?"#"+j:Oe(j),p,n,D?R=R||[]:a=a||[],$,D,h,L,p===1,D&&h?I:u)}}return C(a),C(R),$}(t,e,d,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.createLogger("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[d,_]=this.useState("isOpen",!1);Object.defineProperty(this,"isOpen",{get:d,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(){var e;(e=super.onConnected)==null||e.call(this);try{const r=await he();this.fuse=new ae(r.documents,r.options)}catch(r){ne.error("Failed to load search index",r)}}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 d=[];for(const[w,x]of o)d.length===0||d[d.length-1][1]<w?d.push([w,x+1]):d[d.length-1][1]=Math.max(d[d.length-1][1],x+1);const _=[];let f=0;for(const[w,x]of d){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,d=(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"},d?this.highlightTextNodes(e.item.title,[d]):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,d,_){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,C,v,m,p){function j(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,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";C?(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 g=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)(h=x(H.call(K,g,k),"class decorators","return"))&&(g=h);else{var A,F;k.static=q,k.private=C,C?a===2?A=function(l){return j(l),s.value}:(a<4&&(A=f(s,"get",j)),a!==3&&(F=f(s,"set",j))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:C?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof g=="object"&&g)(h=x(g.get,"accessor.get"))&&(s.get=h),(h=x(g.set,"accessor.set"))&&(s.set=h),(h=x(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(g,(v?"field":"method")+" decorators","return")&&(v?E.push(g):s[b]=g)}}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||(C?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)),g}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 C(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],j=m[2],h=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=j+"/"+D;if(!L&&!h){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: "+j);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,h?"#"+j:Te(j),p,n,D?R=R||[]:a=a||[],$,D,h,L,p===1,D&&h?I:u)}}return C(a),C(R),$}(t,e,d,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(){var e;(e=super.onConnected)==null||e.call(this),requestAnimationFrame(()=>{if(this.connected){const r=this.querySelector(".doc-layout-sidebar");r&&!this.sidebarInstance&&(this.sidebarInstance=document.createElement("wsx-doc-sidebar"),r.appendChild(this.sidebarInstance));const o=this.querySelector(".doc-layout-main");o&&!this.docPageInstance&&(this.docPageInstance=document.createElement("wsx-doc-page"),o.appendChild(this.docPageInstance));const d=this.querySelector(".doc-layout-toc");d&&!this.tocInstance&&(this.tocInstance=document.createElement("wsx-doc-toc"),d.appendChild(this.tocInstance))}})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),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,d,_){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,C,v,m,p){function j(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,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";C?(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 g=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)(h=x(H.call(K,g,k),"class decorators","return"))&&(g=h);else{var A,F;k.static=q,k.private=C,C?a===2?A=function(l){return j(l),s.value}:(a<4&&(A=f(s,"get",j)),a!==3&&(F=f(s,"set",j))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:C?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof g=="object"&&g)(h=x(g.get,"accessor.get"))&&(s.get=h),(h=x(g.set,"accessor.set"))&&(s.set=h),(h=x(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(g,(v?"field":"method")+" decorators","return")&&(v?E.push(g):s[b]=g)}}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||(C?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)),g}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 C(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],j=m[2],h=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=j+"/"+D;if(!L&&!h){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: "+j);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,h?"#"+j:Ae(j),p,n,D?R=R||[]:a=a||[],$,D,h,L,p===1,D&&h?I:u)}}return C(a),C(R),$}(t,e,d,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.createLogger("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[d,_]=this.useState("isLoading",!0);Object.defineProperty(this,"isLoading",{get:d,set:_,enumerable:!0,configurable:!0})}async onConnected(){var e;(e=super.onConnected)==null||e.call(this),await this.loadMetadata(),this.routeChangeUnsubscribe=te.RouterUtils.onRouteChange(()=>{this.updateCurrentRoute()}),this.updateCurrentRoute()}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),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 d=o.category||"other";e[d]||(e[d]=[]),e[d].push(o)}),Object.keys(e).sort().forEach(o=>{e[o].sort((d,_)=>d.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(d=>y.jsx("li",{key:d.route,class:"doc-sidebar-item"},y.jsx("a",{href:d.route,class:`doc-sidebar-link ${this.isCurrentDoc(d.route)?"active":""}`,onClick:_=>this.handleDocClick(d.route,_)},d.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,d,_){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,C,v,m,p){function j(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,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";C?(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 g=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)(h=x(H.call(K,g,k),"class decorators","return"))&&(g=h);else{var A,F;k.static=q,k.private=C,C?a===2?A=function(l){return j(l),s.value}:(a<4&&(A=f(s,"get",j)),a!==3&&(F=f(s,"set",j))):(A=function(l){return l[n]},(a<2||a===4)&&(F=function(l,O){l[n]=O}));var W=k.access={has:C?p.bind():function(l){return n in l}};if(A&&(W.get=A),F&&(W.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],k),m){if(typeof g=="object"&&g)(h=x(g.get,"accessor.get"))&&(s.get=h),(h=x(g.set,"accessor.set"))&&(s.set=h),(h=x(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else x(g,(v?"field":"method")+" decorators","return")&&(v?E.push(g):s[b]=g)}}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||(C?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)),g}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 C(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],j=m[2],h=m.length>3,S=16&p,D=!!(8&p),L=(p&=7)==0,s=j+"/"+D;if(!L&&!h){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: "+j);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,S,h?"#"+j:Fe(j),p,n,D?R=R||[]:a=a||[],$,D,h,L,p===1,D&&h?I:u)}}return C(a),C(R),$}(t,e,d,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.createLogger("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",(d,_)=>{_.preventDefault();const f=this.headingElements.get(d);f&&(f.scrollIntoView({behavior:"smooth",block:"start"}),window.history.replaceState(null,"",`#${d}`))});let e=this.reactive([]);Object.defineProperty(this,"items",{get:()=>e,set:d=>{e=d!==null&&typeof d<"u"&&(Array.isArray(d)||typeof d=="object")?this.reactive(d):d,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(){var e;(e=super.onConnected)==null||e.call(this),await this.loadTOC(),this.routeChangeUnsubscribe=te.RouterUtils.onRouteChange(()=>{this.loadTOC()})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),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}`,d=await ct();this.items=d[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 d=((f=o.textContent)==null?void 0:f.trim())||"";if(!d)return;const _=this.generateId(d);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,d)=>{const _=o.boundingClientRect.top,f=d.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:d=>this.handleTOCClick(e.id,d)},e.text),o&&y.jsx("ul",{class:"doc-toc-list doc-toc-sublist"},e.children.map(d=>this.renderTOCItem(d))))}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();
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@wsxjs/wsx-core"),oe=require("./index-C1_yVVPT.cjs");require("@wsxjs/wsx-marked-components");const re=require("@wsxjs/wsx-router"),ee=require("./index.cjs"),ne=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 J(t,e,r){return(e=Ce(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ue(t,e,r,n,u,C){function f(i,c,d){return function(o,a){return d&&d(o),i[c].call(o,a)}}function w(i,c){for(var d=0;d<i.length;d++)i[d].call(c);return c}function v(i,c,d,o){if(typeof i!="function"&&(o||i!==void 0))throw new TypeError(c+" must "+(d||"be")+" a function"+(o?"":" or undefined"));return i}function U(i,c,d,o,a,T,R,_,z,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,D=c[0],k=c[3],I=!_;if(!I){d||Array.isArray(D)||(D=[D]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(x||m?s={get:le(function(){return k(this)},o,"get"),set:function(l){c[4](this,l)}}:s[b]=k,x||le(s[b],o,a===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,o))}for(var g=i,q=D.length-1;q>=0;q-=d?2:1){var H=D[q],K=d?D[q-1]:void 0,W={},$={kind:["field","accessor","method","getter","setter","class"][a],name:o,metadata:T,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(O,"An initializer","be",!0),R.push(O)}).bind(null,W)};try{if(I)(h=v(H.call(K,g,$),"class decorators","return"))&&(g=h);else{var A,F;$.static=z,$.private=j,j?a===2?A=function(l){return S(l),s.value}:(a<4&&(A=f(s,"get",S)),a!==3&&(F=f(s,"set",S))):(A=function(l){return l[o]},(a<2||a===4)&&(F=function(l,O){l[o]=O}));var B=$.access={has:j?p.bind():function(l){return o in l}};if(A&&(B.get=A),F&&(B.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof g=="object"&&g)(h=v(g.get,"accessor.get"))&&(s.get=h),(h=v(g.set,"accessor.set"))&&(s.set=h),(h=v(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(g,(x?"field":"method")+" decorators","return")&&(x?E.push(g):s[b]=g)}}finally{W.v=!0}}return(x||m)&&_.push(function(l,O){for(var N=E.length-1;N>=0;N--)O=E[N].call(l,O);return O}),x||I||(j?m?_.push(f(s,"get"),f(s,"set")):_.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,o,s)),g}function L(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=C[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(M??null),X=function(i,c,d,o){var a,T,R=[],_=function(b){return Me(b)===i},z=new Map;function j(b){b&&R.push(w.bind(null,b))}for(var x=0;x<c.length;x++){var m=c[x];if(Array.isArray(m)){var p=m[1],S=m[2],h=m.length>3,D=16&p,k=!!(8&p),I=(p&=7)==0,s=S+"/"+k;if(!I&&!h){var E=z.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: "+S);z.set(s,!(p>2)||p)}U(k?i:i.prototype,m,D,h?"#"+S:Ce(S),p,o,k?T=T||[]:a=a||[],R,k,h,I,p===1,k&&h?_:d)}}return j(a),j(T),R}(t,e,u,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],n,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Ce(t){var e=Ne(t,"string");return typeof e=="symbol"?e:e+""}function Ne(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;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 Me(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 Y=oe.createLogger("DocPage"),G={data:null,promise:null};async function je(t,e={},r=1e4){var f;const n=new AbortController,u=setTimeout(()=>n.abort(),r);let C;if(e.signal){const w=new AbortController;e.signal.aborted?w.abort():e.signal.addEventListener("abort",()=>{w.abort()}),n.signal.addEventListener("abort",()=>{w.abort()}),C=w.signal}else C=n.signal;try{const w=await fetch(t,{...e,signal:C});return clearTimeout(u),w}catch(w){if(clearTimeout(u),w instanceof Error&&w.name==="AbortError"){const v=n.signal.aborted;throw((f=e.signal)==null?void 0:f.aborted)?new Error("Request was cancelled"):v?new Error(`Request timeout after ${r}ms`):new Error("Request was aborted")}throw w}}async function He(){return G.data?G.data:(G.promise||(G.promise=(async()=>{try{const t=await je("/.wsx-press/docs-meta.json",{},5e3);if(!t.ok)throw new Error(`Failed to load metadata: ${t.statusText}`);const e=await t.json();return G.data=e,G.promise=null,e}catch(t){throw G.promise=null,t}})()),G.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"}),J(this,"_autoStyles",ce),J(this,"loadingState",void 0),J(this,"markdown",void 0),J(this,"metadata",void 0),J(this,"error",void 0),J(this,"currentLoadingPath",null),J(this,"routeChangeUnsubscribe",null),J(this,"loadingAbortController",null),J(this,"isLoading",!1),J(this,"visibilityChangeHandler",null),Y.debug("DocPage initialized");const[e,r]=this.useState("loadingState","idle");Object.defineProperty(this,"loadingState",{get:e,set:r,enumerable:!0,configurable:!0});const[n,u]=this.useState("markdown","");Object.defineProperty(this,"markdown",{get:n,set:u,enumerable:!0,configurable:!0});const[C,f]=this.useState("metadata",null);Object.defineProperty(this,"metadata",{get:C,set:f,enumerable:!0,configurable:!0});const[w,v]=this.useState("error",null);Object.defineProperty(this,"error",{get:w,set:v,enumerable:!0,configurable:!0})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),this.routeChangeUnsubscribe=re.RouterUtils.onRouteChange(()=>{this.cancelLoading(),this.loadDocument()}),this.visibilityChangeHandler=()=>{document.hidden?this.cancelLoading():this.loadingState==="loading"&&this.currentLoadingPath&&(Y.debug("Tab became visible, reloading document"),this.loadDocument())},document.addEventListener("visibilitychange",this.visibilityChangeHandler),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.loadDocument()})})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),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,n){e==="params"&&this.loadDocument()}async fetchWithTimeout(e,r={},n=1e4){return je(e,r,n)}async loadDocument(){this.cancelLoading();try{this.loadingAbortController=new AbortController;const e=re.RouterUtils.getCurrentRoute();let r;if(e.path.startsWith("/docs/"))r=e.path.slice(6);else{const v=e.params;if(v.category&&v.page)r=`${v.category}/${v.page}`;else{if(Y.warn("Invalid document path:",{path:e.path,params:v}),Object.keys(v).length===0){Y.debug("Route params not yet initialized, keeping idle state"),this.loadingState="idle";return}this.loadingState="error",this.error=new ee.DocumentLoadError("Invalid document path: path must start with /docs/","INVALID_PARAMS");return}}if(!r||r.trim()===""){Y.warn("Empty document path:",{path:e.path}),this.loadingState="error",this.error=new ee.DocumentLoadError("Document path is empty","INVALID_PARAMS");return}this.currentLoadingPath=r,this.isLoading=!0,this.loadingState="loading",this.markdown="",this.error=null,this.metadata=null;const n=await He();if(this.currentLoadingPath!==r||this.loadingAbortController.signal.aborted){Y.debug(`Document switched after metadata, ignoring result for ${r}`),this.isLoading=!1,this.loadingState="idle";return}const u=n[r];if(!u){if(this.currentLoadingPath!==r||this.loadingAbortController.signal.aborted){this.isLoading=!1,this.loadingState="idle";return}this.loadingState="error",this.error=new ee.DocumentLoadError(`Document not found: ${r}`,"NOT_FOUND"),this.isLoading=!1;return}this.metadata=u;const C=`/docs/${r}.md`,f=await this.fetchWithTimeout(C,{signal:this.loadingAbortController.signal},1e4);if(this.currentLoadingPath!==r||this.loadingAbortController.signal.aborted){Y.debug(`Document switched during fetch, ignoring result for ${r}`),this.isLoading=!1,this.loadingState="idle";return}if(!f.ok){f.status===404?(this.loadingState="error",this.error=new ee.DocumentLoadError(`Document file not found: ${C}`,"NOT_FOUND")):(this.loadingState="error",this.error=new ee.DocumentLoadError(`Failed to load document: ${f.statusText}`,"NETWORK_ERROR",{status:f.status})),this.isLoading=!1;return}const w=await f.text();if(this.currentLoadingPath!==r||this.loadingAbortController.signal.aborted){Y.debug(`Document switched after fetch, ignoring result for ${r}`),this.isLoading=!1,this.loadingState="idle";return}this.markdown=w,this.loadingState="success",this.isLoading=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.connected&&this.scheduleRerender()})})}catch(e){if(this.isLoading=!1,e instanceof Error&&e.name==="AbortError"){Y.debug("Document loading was cancelled"),this.currentLoadingPath&&(this.loadingState="idle",this.currentLoadingPath=null);return}if(!this.currentLoadingPath){this.loadingState="error",this.error=new ee.DocumentLoadError(`Failed to load document: ${e instanceof Error?e.message:String(e)}`,"NETWORK_ERROR",e),Y.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 ee.DocumentLoadError(`Failed to load document: ${e instanceof Error?e.message:String(e)}`,"NETWORK_ERROR",e),Y.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 de=".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,ke;function Q(t,e,r){return(e=Ee(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function We(t,e,r,n,u,C){function f(i,c,d){return function(o,a){return d&&d(o),i[c].call(o,a)}}function w(i,c){for(var d=0;d<i.length;d++)i[d].call(c);return c}function v(i,c,d,o){if(typeof i!="function"&&(o||i!==void 0))throw new TypeError(c+" must "+(d||"be")+" a function"+(o?"":" or undefined"));return i}function U(i,c,d,o,a,T,R,_,z,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,D=c[0],k=c[3],I=!_;if(!I){d||Array.isArray(D)||(D=[D]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(x||m?s={get:ue(function(){return k(this)},o,"get"),set:function(l){c[4](this,l)}}:s[b]=k,x||ue(s[b],o,a===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,o))}for(var g=i,q=D.length-1;q>=0;q-=d?2:1){var H=D[q],K=d?D[q-1]:void 0,W={},$={kind:["field","accessor","method","getter","setter","class"][a],name:o,metadata:T,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(O,"An initializer","be",!0),R.push(O)}).bind(null,W)};try{if(I)(h=v(H.call(K,g,$),"class decorators","return"))&&(g=h);else{var A,F;$.static=z,$.private=j,j?a===2?A=function(l){return S(l),s.value}:(a<4&&(A=f(s,"get",S)),a!==3&&(F=f(s,"set",S))):(A=function(l){return l[o]},(a<2||a===4)&&(F=function(l,O){l[o]=O}));var B=$.access={has:j?p.bind():function(l){return o in l}};if(A&&(B.get=A),F&&(B.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof g=="object"&&g)(h=v(g.get,"accessor.get"))&&(s.get=h),(h=v(g.set,"accessor.set"))&&(s.set=h),(h=v(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(g,(x?"field":"method")+" decorators","return")&&(x?E.push(g):s[b]=g)}}finally{W.v=!0}}return(x||m)&&_.push(function(l,O){for(var N=E.length-1;N>=0;N--)O=E[N].call(l,O);return O}),x||I||(j?m?_.push(f(s,"get"),f(s,"set")):_.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,o,s)),g}function L(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=C[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(M??null),X=function(i,c,d,o){var a,T,R=[],_=function(b){return Ye(b)===i},z=new Map;function j(b){b&&R.push(w.bind(null,b))}for(var x=0;x<c.length;x++){var m=c[x];if(Array.isArray(m)){var p=m[1],S=m[2],h=m.length>3,D=16&p,k=!!(8&p),I=(p&=7)==0,s=S+"/"+k;if(!I&&!h){var E=z.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: "+S);z.set(s,!(p>2)||p)}U(k?i:i.prototype,m,D,h?"#"+S:Ee(S),p,o,k?T=T||[]:a=a||[],R,k,h,I,p===1,k&&h?_:d)}}return j(a),j(T),R}(t,e,u,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],n,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Ee(t){var e=Be(t,"string");return typeof e=="symbol"?e:e+""}function Be(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function ue(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 ae=oe.createLogger("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)}ke=[y.autoRegister({tagName:"wsx-doc-search"})];exports.DocSearch=void 0;class Ge extends y.LightComponent{constructor(){super({styles:de,styleName:"wsx-doc-search"}),Q(this,"_autoStyles",de),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",L=>{const M=L.target;if(this.query=M.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",L=>{if(!(!this.isOpen||this.results.length===0))switch(L.key){case"ArrowDown":L.preventDefault(),this.selectedIndex=Math.min(this.selectedIndex+1,this.results.length-1);break;case"ArrowUp":L.preventDefault(),this.selectedIndex=Math.max(this.selectedIndex-1,-1);break;case"Enter":L.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":L.preventDefault(),this.isOpen=!1,this.query="",this.results=[],this.selectedIndex=-1;break}}),ae.info("DocSearch initialized");const[e,r]=this.useState("query","");Object.defineProperty(this,"query",{get:e,set:r,enumerable:!0,configurable:!0});let n=this.reactive([]);Object.defineProperty(this,"results",{get:()=>n,set:L=>{n=L!==null&&typeof L<"u"&&(Array.isArray(L)||typeof L=="object")?this.reactive(L):L,this.scheduleRerender()},enumerable:!0,configurable:!0});const[u,C]=this.useState("isOpen",!1);Object.defineProperty(this,"isOpen",{get:u,set:C,enumerable:!0,configurable:!0});const[f,w]=this.useState("isLoading",!1);Object.defineProperty(this,"isLoading",{get:f,set:w,enumerable:!0,configurable:!0});const[v,U]=this.useState("selectedIndex",-1);Object.defineProperty(this,"selectedIndex",{get:v,set:U,enumerable:!0,configurable:!0})}async onConnected(){var e;(e=super.onConnected)==null||e.call(this);try{const r=await he();this.fuse=new ne(r.documents,r.options)}catch(r){ae.error("Failed to load search index",r)}}async performSearch(){if(!this.fuse)try{this.isLoading=!0;const r=await he();this.fuse=new ne(r.documents,r.options)}catch(r){ae.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 n=[];for(const w of r)w.indices&&n.push(...w.indices);n.sort((w,v)=>w[0]-v[0]);const u=[];for(const[w,v]of n)u.length===0||u[u.length-1][1]<w?u.push([w,v+1]):u[u.length-1][1]=Math.max(u[u.length-1][1],v+1);const C=[];let f=0;for(const[w,v]of u){w>f&&C.push(e.substring(f,w));const U=document.createElement("mark");U.textContent=e.substring(w,v),C.push(U),f=v}return f<e.length&&C.push(e.substring(f)),C}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 n=r===this.selectedIndex,u=(f=e.matches)==null?void 0:f.find(v=>v.key==="title"),C=(w=e.matches)==null?void 0:w.find(v=>v.key==="content");return y.jsx("div",{key:e.item.id,class:`search-result ${n?"selected":""}`,onClick:()=>this.selectResult(e),onMouseEnter:()=>{this.selectedIndex=r}},y.jsx("div",{class:"result-title"},u?this.highlightTextNodes(e.item.title,[u]):e.item.title),y.jsx("div",{class:"result-category"},e.item.category),C&&y.jsx("div",{class:"result-snippet"},this.highlightTextNodes(e.item.content.substring(0,100),[C])))})),this.isOpen&&this.query.trim()&&this.results.length===0&&!this.isLoading&&y.jsx("div",{class:"search-no-results"},"未找到匹配的文档"))}}Se=Ge;[exports.DocSearch,De]=We(Se,[],ke,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 Oe;let _e,Ie;function se(t,e,r){return(e=Le(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Je(t,e,r,n,u,C){function f(i,c,d){return function(o,a){return d&&d(o),i[c].call(o,a)}}function w(i,c){for(var d=0;d<i.length;d++)i[d].call(c);return c}function v(i,c,d,o){if(typeof i!="function"&&(o||i!==void 0))throw new TypeError(c+" must "+(d||"be")+" a function"+(o?"":" or undefined"));return i}function U(i,c,d,o,a,T,R,_,z,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,D=c[0],k=c[3],I=!_;if(!I){d||Array.isArray(D)||(D=[D]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(x||m?s={get:fe(function(){return k(this)},o,"get"),set:function(l){c[4](this,l)}}:s[b]=k,x||fe(s[b],o,a===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,o))}for(var g=i,q=D.length-1;q>=0;q-=d?2:1){var H=D[q],K=d?D[q-1]:void 0,W={},$={kind:["field","accessor","method","getter","setter","class"][a],name:o,metadata:T,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(O,"An initializer","be",!0),R.push(O)}).bind(null,W)};try{if(I)(h=v(H.call(K,g,$),"class decorators","return"))&&(g=h);else{var A,F;$.static=z,$.private=j,j?a===2?A=function(l){return S(l),s.value}:(a<4&&(A=f(s,"get",S)),a!==3&&(F=f(s,"set",S))):(A=function(l){return l[o]},(a<2||a===4)&&(F=function(l,O){l[o]=O}));var B=$.access={has:j?p.bind():function(l){return o in l}};if(A&&(B.get=A),F&&(B.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof g=="object"&&g)(h=v(g.get,"accessor.get"))&&(s.get=h),(h=v(g.set,"accessor.set"))&&(s.set=h),(h=v(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(g,(x?"field":"method")+" decorators","return")&&(x?E.push(g):s[b]=g)}}finally{W.v=!0}}return(x||m)&&_.push(function(l,O){for(var N=E.length-1;N>=0;N--)O=E[N].call(l,O);return O}),x||I||(j?m?_.push(f(s,"get"),f(s,"set")):_.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,o,s)),g}function L(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=C[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(M??null),X=function(i,c,d,o){var a,T,R=[],_=function(b){return Xe(b)===i},z=new Map;function j(b){b&&R.push(w.bind(null,b))}for(var x=0;x<c.length;x++){var m=c[x];if(Array.isArray(m)){var p=m[1],S=m[2],h=m.length>3,D=16&p,k=!!(8&p),I=(p&=7)==0,s=S+"/"+k;if(!I&&!h){var E=z.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: "+S);z.set(s,!(p>2)||p)}U(k?i:i.prototype,m,D,h?"#"+S:Le(S),p,o,k?T=T||[]:a=a||[],R,k,h,I,p===1,k&&h?_:d)}}return j(a),j(T),R}(t,e,u,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],n,t.name,5,P,i),P),w.bind(null,i,t)]}}}function Le(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 n=r.call(t,e);if(typeof n!="object")return n;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}Ie=[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(){var e;(e=super.onConnected)==null||e.call(this),requestAnimationFrame(()=>{if(this.connected){const r=this.querySelector(".doc-layout-sidebar");r&&!this.sidebarInstance&&(this.sidebarInstance=document.createElement("wsx-doc-sidebar"),r.appendChild(this.sidebarInstance));const n=this.querySelector(".doc-layout-main");n&&!this.docPageInstance&&(this.docPageInstance=document.createElement("wsx-doc-page"),n.appendChild(this.docPageInstance));const u=this.querySelector(".doc-layout-toc");u&&!this.tocInstance&&(this.tocInstance=document.createElement("wsx-doc-toc"),u.appendChild(this.tocInstance))}})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),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"}))}}Oe=Ze;[exports.DocLayout,_e]=Je(Oe,[],Ie,0,void 0,y.LightComponent).c;_e();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)}.light wsx-doc-sidebar,[data-theme=light] wsx-doc-sidebar{background:var(--wsx-press-sidebar-bg, #f9fafb);border-right-color:var(--wsx-press-border, #e5e7eb)}.dark wsx-doc-sidebar,[data-theme=dark] wsx-doc-sidebar{background:var(--wsx-press-sidebar-bg, #1f2937);border-right-color:var(--wsx-press-border, #374151)}@media (prefers-color-scheme: dark){html:not(.light):not([data-theme=light]) wsx-doc-sidebar{background:var(--wsx-press-sidebar-bg, #1f2937);border-right-color:var(--wsx-press-border, #374151)}}.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}.light .doc-sidebar-category-title,[data-theme=light] .doc-sidebar-category-title{color:var(--wsx-press-text-secondary, #6b7280)}.dark .doc-sidebar-category-title,[data-theme=dark] .doc-sidebar-category-title{color:var(--wsx-press-text-secondary, #9ca3af)}@media (prefers-color-scheme: dark){html:not(.light):not([data-theme=light]) .doc-sidebar-category-title{color:var(--wsx-press-text-secondary, #9ca3af)}}.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, #fef2f2);color:var(--wsx-press-sidebar-active-color, #dc2626);border-left-color:var(--wsx-press-sidebar-active-color, #dc2626);font-weight:500}.light .doc-sidebar-link,[data-theme=light] .doc-sidebar-link{color:var(--wsx-press-text-primary, #111827)}.light .doc-sidebar-link:hover,[data-theme=light] .doc-sidebar-link:hover{background:var(--wsx-press-sidebar-hover-bg, #f3f4f6);color:var(--wsx-press-text-primary, #111827)}.light .doc-sidebar-link.active,[data-theme=light] .doc-sidebar-link.active{background:var(--wsx-press-sidebar-active-bg, #fef2f2);color:var(--wsx-press-sidebar-active-color, #dc2626);border-left-color:var(--wsx-press-sidebar-active-color, #dc2626)}.dark .doc-sidebar-link,[data-theme=dark] .doc-sidebar-link{color:var(--wsx-press-text-primary, #e5e7eb)}.dark .doc-sidebar-link:hover,[data-theme=dark] .doc-sidebar-link:hover{background:var(--wsx-press-sidebar-hover-bg, #374151);color:var(--wsx-press-text-primary, #f3f4f6)}.dark .doc-sidebar-link.active,[data-theme=dark] .doc-sidebar-link.active{background:var(--wsx-press-sidebar-active-bg, rgba(220, 38, 38, .15));color:var(--wsx-press-sidebar-active-color, #f87171);border-left-color:var(--wsx-press-sidebar-active-color, #f87171)}@media (prefers-color-scheme: dark){html:not(.light):not([data-theme=light]) .doc-sidebar-link{color:var(--wsx-press-text-primary, #e5e7eb)}html:not(.light):not([data-theme=light]) .doc-sidebar-link:hover{background:var(--wsx-press-sidebar-hover-bg, #374151);color:var(--wsx-press-text-primary, #f3f4f6)}html:not(.light):not([data-theme=light]) .doc-sidebar-link.active{background:var(--wsx-press-sidebar-active-bg, rgba(220, 38, 38, .15));color:var(--wsx-press-sidebar-active-color, #f87171);border-left-color:var(--wsx-press-sidebar-active-color, #f87171)}}@media (max-width: 1024px){wsx-doc-sidebar{width:240px;min-width:240px}}@media (max-width: 768px){wsx-doc-sidebar{display:none}}";var Te;let Re,$e;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,n,u,C){function f(i,c,d){return function(o,a){return d&&d(o),i[c].call(o,a)}}function w(i,c){for(var d=0;d<i.length;d++)i[d].call(c);return c}function v(i,c,d,o){if(typeof i!="function"&&(o||i!==void 0))throw new TypeError(c+" must "+(d||"be")+" a function"+(o?"":" or undefined"));return i}function U(i,c,d,o,a,T,R,_,z,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,D=c[0],k=c[3],I=!_;if(!I){d||Array.isArray(D)||(D=[D]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(x||m?s={get:pe(function(){return k(this)},o,"get"),set:function(l){c[4](this,l)}}:s[b]=k,x||pe(s[b],o,a===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,o))}for(var g=i,q=D.length-1;q>=0;q-=d?2:1){var H=D[q],K=d?D[q-1]:void 0,W={},$={kind:["field","accessor","method","getter","setter","class"][a],name:o,metadata:T,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(O,"An initializer","be",!0),R.push(O)}).bind(null,W)};try{if(I)(h=v(H.call(K,g,$),"class decorators","return"))&&(g=h);else{var A,F;$.static=z,$.private=j,j?a===2?A=function(l){return S(l),s.value}:(a<4&&(A=f(s,"get",S)),a!==3&&(F=f(s,"set",S))):(A=function(l){return l[o]},(a<2||a===4)&&(F=function(l,O){l[o]=O}));var B=$.access={has:j?p.bind():function(l){return o in l}};if(A&&(B.get=A),F&&(B.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof g=="object"&&g)(h=v(g.get,"accessor.get"))&&(s.get=h),(h=v(g.set,"accessor.set"))&&(s.set=h),(h=v(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(g,(x?"field":"method")+" decorators","return")&&(x?E.push(g):s[b]=g)}}finally{W.v=!0}}return(x||m)&&_.push(function(l,O){for(var N=E.length-1;N>=0;N--)O=E[N].call(l,O);return O}),x||I||(j?m?_.push(f(s,"get"),f(s,"set")):_.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,o,s)),g}function L(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=C[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(M??null),X=function(i,c,d,o){var a,T,R=[],_=function(b){return tt(b)===i},z=new Map;function j(b){b&&R.push(w.bind(null,b))}for(var x=0;x<c.length;x++){var m=c[x];if(Array.isArray(m)){var p=m[1],S=m[2],h=m.length>3,D=16&p,k=!!(8&p),I=(p&=7)==0,s=S+"/"+k;if(!I&&!h){var E=z.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: "+S);z.set(s,!(p>2)||p)}U(k?i:i.prototype,m,D,h?"#"+S:Ae(S),p,o,k?T=T||[]:a=a||[],R,k,h,I,p===1,k&&h?_:d)}}return j(a),j(T),R}(t,e,u,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],n,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 n=r.call(t,e);if(typeof n!="object")return n;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.createLogger("DocSidebar");$e=[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(),re.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,n]=this.useState("currentRoute","");Object.defineProperty(this,"currentRoute",{get:r,set:n,enumerable:!0,configurable:!0});const[u,C]=this.useState("isLoading",!0);Object.defineProperty(this,"isLoading",{get:u,set:C,enumerable:!0,configurable:!0})}async onConnected(){var e;(e=super.onConnected)==null||e.call(this),await this.loadMetadata(),this.routeChangeUnsubscribe=re.RouterUtils.onRouteChange(()=>{this.updateCurrentRoute()}),this.updateCurrentRoute()}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),this.routeChangeUnsubscribe&&(this.routeChangeUnsubscribe(),this.routeChangeUnsubscribe=null)}async loadMetadata(){try{if(this.isLoading=!0,G.data)this.metadata=G.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=re.RouterUtils.getCurrentRoute();this.currentRoute=e.path}organizeByCategory(){const e={};return Object.values(this.metadata).forEach(n=>{const u=n.category||"other";e[u]||(e[u]=[]),e[u].push(n)}),Object.keys(e).sort().forEach(n=>{e[n].sort((u,C)=>u.order!==void 0&&C.order!==void 0?u.order-C.order:u.order!==void 0?-1:C.order!==void 0?1:u.title.localeCompare(C.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(n=>y.jsx("div",{key:n,class:"doc-sidebar-category"},y.jsx("h3",{class:"doc-sidebar-category-title"},n),y.jsx("ul",{class:"doc-sidebar-list"},e[n].map(u=>y.jsx("li",{key:u.route,class:"doc-sidebar-item"},y.jsx("a",{href:u.route,class:`doc-sidebar-link ${this.isCurrentDoc(u.route)?"active":""}`,onClick:C=>this.handleDocClick(u.route,C)},u.title))))))))}}Te=it;[exports.DocSidebar,Re]=Ve(Te,[],$e,0,void 0,y.LightComponent).c;Re();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 ze,qe;function te(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,n,u,C){function f(i,c,d){return function(o,a){return d&&d(o),i[c].call(o,a)}}function w(i,c){for(var d=0;d<i.length;d++)i[d].call(c);return c}function v(i,c,d,o){if(typeof i!="function"&&(o||i!==void 0))throw new TypeError(c+" must "+(d||"be")+" a function"+(o?"":" or undefined"));return i}function U(i,c,d,o,a,T,R,_,z,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,D=c[0],k=c[3],I=!_;if(!I){d||Array.isArray(D)||(D=[D]);var s={},E=[],b=a===3?"get":a===4||m?"set":"value";j?(x||m?s={get:ye(function(){return k(this)},o,"get"),set:function(l){c[4](this,l)}}:s[b]=k,x||ye(s[b],o,a===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,o))}for(var g=i,q=D.length-1;q>=0;q-=d?2:1){var H=D[q],K=d?D[q-1]:void 0,W={},$={kind:["field","accessor","method","getter","setter","class"][a],name:o,metadata:T,addInitializer:(function(l,O){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(O,"An initializer","be",!0),R.push(O)}).bind(null,W)};try{if(I)(h=v(H.call(K,g,$),"class decorators","return"))&&(g=h);else{var A,F;$.static=z,$.private=j,j?a===2?A=function(l){return S(l),s.value}:(a<4&&(A=f(s,"get",S)),a!==3&&(F=f(s,"set",S))):(A=function(l){return l[o]},(a<2||a===4)&&(F=function(l,O){l[o]=O}));var B=$.access={has:j?p.bind():function(l){return o in l}};if(A&&(B.get=A),F&&(B.set=F),g=H.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof g=="object"&&g)(h=v(g.get,"accessor.get"))&&(s.get=h),(h=v(g.set,"accessor.set"))&&(s.set=h),(h=v(g.init,"accessor.init"))&&E.push(h);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(g,(x?"field":"method")+" decorators","return")&&(x?E.push(g):s[b]=g)}}finally{W.v=!0}}return(x||m)&&_.push(function(l,O){for(var N=E.length-1;N>=0;N--)O=E[N].call(l,O);return O}),x||I||(j?m?_.push(f(s,"get"),f(s,"set")):_.push(a===2?s[b]:f.call.bind(s[b])):Object.defineProperty(i,o,s)),g}function L(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=C[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(M??null),X=function(i,c,d,o){var a,T,R=[],_=function(b){return at(b)===i},z=new Map;function j(b){b&&R.push(w.bind(null,b))}for(var x=0;x<c.length;x++){var m=c[x];if(Array.isArray(m)){var p=m[1],S=m[2],h=m.length>3,D=16&p,k=!!(8&p),I=(p&=7)==0,s=S+"/"+k;if(!I&&!h){var E=z.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: "+S);z.set(s,!(p>2)||p)}U(k?i:i.prototype,m,D,h?"#"+S:Fe(S),p,o,k?T=T||[]:a=a||[],R,k,h,I,p===1,k&&h?_:d)}}return j(a),j(T),R}(t,e,u,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],n,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 n=r.call(t,e);if(typeof n!="object")return n;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 at(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 nt=oe.createLogger("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)}qe=[y.autoRegister({tagName:"wsx-doc-toc"})];exports.DocTOC=void 0;class lt extends y.LightComponent{constructor(){super({styles:be,styleName:"wsx-doc-toc"}),te(this,"_autoStyles",be),te(this,"items",void 0),te(this,"activeId",void 0),te(this,"observer",null),te(this,"headingElements",new Map),te(this,"routeChangeUnsubscribe",null),te(this,"handleTOCClick",(u,C)=>{C.preventDefault();const f=this.headingElements.get(u);f&&(f.scrollIntoView({behavior:"smooth",block:"start"}),window.history.replaceState(null,"",`#${u}`))});let e=this.reactive([]);Object.defineProperty(this,"items",{get:()=>e,set:u=>{e=u!==null&&typeof u<"u"&&(Array.isArray(u)||typeof u=="object")?this.reactive(u):u,this.scheduleRerender()},enumerable:!0,configurable:!0});const[r,n]=this.useState("activeId","");Object.defineProperty(this,"activeId",{get:r,set:n,enumerable:!0,configurable:!0})}async onConnected(){var e;(e=super.onConnected)==null||e.call(this),await this.loadTOC(),this.routeChangeUnsubscribe=re.RouterUtils.onRouteChange(()=>{this.loadTOC()})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),this.observer&&(this.observer.disconnect(),this.observer=null),this.routeChangeUnsubscribe&&(this.routeChangeUnsubscribe(),this.routeChangeUnsubscribe=null)}async loadTOC(){try{const e=re.RouterUtils.getCurrentRoute();let r;if(e.path.startsWith("/docs/"))r=e.path.slice(6);else{this.items=[];return}if(!r||r.trim()===""){this.items=[];return}const n=await ct();this.items=n[r]||[],requestAnimationFrame(()=>{this.setupHeadingIds(),this.setupScrollObserver()})}catch(e){nt.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(n=>{var f;const u=((f=n.textContent)==null?void 0:f.trim())||"";if(!u)return;const C=this.generateId(u);n instanceof HTMLElement&&(n.id=C,this.headingElements.set(C,n))})}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(n=>n.isIntersecting);r.length>0&&(r.sort((n,u)=>{const C=n.boundingClientRect.top,f=u.boundingClientRect.top;return Math.abs(C)-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,n=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:u=>this.handleTOCClick(e.id,u)},e.text),n&&y.jsx("ul",{class:"doc-toc-list doc-toc-sublist"},e.children.map(u=>this.renderTOCItem(u))))}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,ze]=st(Pe,[],qe,0,void 0,y.LightComponent).c;ze();
|