@wsxjs/wsx-press 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,297 @@
1
+ # @wsxjs/wsx-press
2
+
3
+ A VitePress-like documentation system built with WSXJS.
4
+
5
+ ## Features
6
+
7
+ - Markdown-based documentation with frontmatter support
8
+ - Auto-generated Table of Contents (TOC)
9
+ - Full-text search with Fuse.js
10
+ - API documentation generation with TypeDoc
11
+ - Responsive layout components
12
+ - Anchor scrolling with Unicode support (Chinese, etc.)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @wsxjs/wsx-press
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### 1. Configure Vite Plugin
23
+
24
+ ```typescript
25
+ // vite.config.ts
26
+ import { defineConfig } from "vite";
27
+ import { wsxPress } from "@wsxjs/wsx-press/node";
28
+
29
+ export default defineConfig({
30
+ plugins: [
31
+ wsxPress({
32
+ docsRoot: "./docs", // Markdown files directory
33
+ outputDir: ".wsx-press", // Generated data output (optional)
34
+ api: { // TypeDoc config (optional)
35
+ entryPoints: ["./src/index.ts"],
36
+ outputDir: "./docs/api",
37
+ },
38
+ }),
39
+ ],
40
+ });
41
+ ```
42
+
43
+ ### 2. Import Client Components
44
+
45
+ ```typescript
46
+ // main.ts
47
+ import "@wsxjs/wsx-press/client";
48
+ ```
49
+
50
+ ### 3. Use Components in HTML
51
+
52
+ ```html
53
+ <wsx-doc-layout>
54
+ <wsx-doc-sidebar slot="sidebar"></wsx-doc-sidebar>
55
+ <wsx-doc-page slot="content"></wsx-doc-page>
56
+ <wsx-doc-toc slot="toc"></wsx-doc-toc>
57
+ </wsx-doc-layout>
58
+ ```
59
+
60
+ ## Components
61
+
62
+ ### `<wsx-doc-layout>`
63
+
64
+ Main layout component with sidebar, content, and TOC slots.
65
+
66
+ ```html
67
+ <wsx-doc-layout>
68
+ <wsx-doc-sidebar slot="sidebar"></wsx-doc-sidebar>
69
+ <wsx-doc-page slot="content"></wsx-doc-page>
70
+ <wsx-doc-toc slot="toc"></wsx-doc-toc>
71
+ </wsx-doc-layout>
72
+ ```
73
+
74
+ ### `<wsx-doc-page>`
75
+
76
+ Loads and renders markdown documentation based on current route.
77
+
78
+ ```html
79
+ <wsx-doc-page></wsx-doc-page>
80
+ ```
81
+
82
+ **Features:**
83
+ - Auto-loads markdown from `/docs/{path}.md`
84
+ - Renders frontmatter metadata (title, description)
85
+ - Supports anchor scrolling with hash URLs
86
+
87
+ ### `<wsx-doc-sidebar>`
88
+
89
+ Navigation sidebar with document hierarchy.
90
+
91
+ ```html
92
+ <wsx-doc-sidebar></wsx-doc-sidebar>
93
+ ```
94
+
95
+ **Features:**
96
+ - Groups documents by category
97
+ - Highlights active document
98
+ - Supports ordering via frontmatter `order` field
99
+
100
+ ### `<wsx-doc-toc>`
101
+
102
+ Table of Contents showing current document headings.
103
+
104
+ ```html
105
+ <wsx-doc-toc></wsx-doc-toc>
106
+ ```
107
+
108
+ **Features:**
109
+ - Auto-generated from document headings
110
+ - Click to scroll to heading
111
+ - Highlights currently visible heading
112
+
113
+ ### `<wsx-doc-search>`
114
+
115
+ Full-text search component.
116
+
117
+ ```html
118
+ <wsx-doc-search></wsx-doc-search>
119
+ ```
120
+
121
+ **Features:**
122
+ - Fuzzy search with Fuse.js
123
+ - Searches title, content, and category
124
+ - Keyboard navigation support
125
+
126
+ ## Customization
127
+
128
+ ### Custom Styles
129
+
130
+ Each component has its own CSS file that can be overridden:
131
+
132
+ ```css
133
+ /* Override DocPage styles */
134
+ .doc-page {
135
+ max-width: 900px;
136
+ }
137
+
138
+ .doc-title {
139
+ color: var(--primary-color);
140
+ }
141
+
142
+ /* Override DocTOC styles */
143
+ .doc-toc {
144
+ position: sticky;
145
+ top: 80px;
146
+ }
147
+
148
+ .doc-toc-link.active {
149
+ color: var(--accent-color);
150
+ border-left-color: var(--accent-color);
151
+ }
152
+
153
+ /* Override DocSidebar styles */
154
+ .doc-sidebar {
155
+ width: 280px;
156
+ }
157
+
158
+ .doc-sidebar-link.active {
159
+ background: var(--highlight-bg);
160
+ }
161
+ ```
162
+
163
+ ### CSS Variables
164
+
165
+ Define these CSS variables to customize the theme:
166
+
167
+ ```css
168
+ :root {
169
+ --primary-color: #3498db;
170
+ --accent-color: #2ecc71;
171
+ --text-color: #333;
172
+ --bg-color: #fff;
173
+ --border-color: #eee;
174
+ --highlight-bg: rgba(52, 152, 219, 0.1);
175
+ }
176
+ ```
177
+
178
+ ### Extend Components
179
+
180
+ Import and extend the base components:
181
+
182
+ ```typescript
183
+ import { DocPage } from "@wsxjs/wsx-press/client";
184
+ import { LightComponent, autoRegister, state } from "@wsxjs/wsx-core";
185
+
186
+ @autoRegister({ tagName: "my-doc-page" })
187
+ class MyDocPage extends DocPage {
188
+ // Override methods or add new functionality
189
+ protected updated() {
190
+ super.updated();
191
+ // Custom logic after render
192
+ }
193
+ }
194
+ ```
195
+
196
+ ### Custom TOC ID Generation
197
+
198
+ The TOC uses a consistent ID generation algorithm across server and client:
199
+
200
+ ```typescript
201
+ function generateId(text: string): string {
202
+ return text
203
+ .toLowerCase()
204
+ .replace(/\s+/g, "-") // Spaces to hyphens
205
+ .replace(/[^\p{L}\p{N}\-]/gu, "") // Keep letters, numbers, hyphens (Unicode)
206
+ .replace(/-+/g, "-") // Merge multiple hyphens
207
+ .replace(/^-+|-+$/g, ""); // Trim edge hyphens
208
+ }
209
+ ```
210
+
211
+ This algorithm supports:
212
+ - Chinese characters: `基本配置` → `基本配置`
213
+ - Mixed content: `3. ESLint 配置` → `3-eslint-配置`
214
+ - ASCII text: `Getting Started` → `getting-started`
215
+
216
+ ## Document Structure
217
+
218
+ ### Frontmatter
219
+
220
+ ```markdown
221
+ ---
222
+ title: Getting Started
223
+ category: Guide
224
+ description: Learn how to get started with WSXJS
225
+ order: 1
226
+ tags:
227
+ - tutorial
228
+ - beginner
229
+ ---
230
+
231
+ # Getting Started
232
+
233
+ Your content here...
234
+ ```
235
+
236
+ ### Supported Fields
237
+
238
+ | Field | Type | Description |
239
+ |-------|------|-------------|
240
+ | `title` | string | Document title |
241
+ | `category` | string | Category for sidebar grouping |
242
+ | `description` | string | Short description |
243
+ | `order` | number | Sort order (lower = first) |
244
+ | `tags` | string[] | Tags for search/filtering |
245
+
246
+ ## Generated Files
247
+
248
+ The plugin generates these files in the output directory:
249
+
250
+ | File | Description |
251
+ |------|-------------|
252
+ | `docs-meta.json` | Document metadata (title, category, route, etc.) |
253
+ | `docs-toc.json` | Table of contents for each document |
254
+ | `search-index.json` | Search index for Fuse.js |
255
+
256
+ ## API Reference
257
+
258
+ ### Node.js Utilities
259
+
260
+ ```typescript
261
+ import {
262
+ wsxPress, // Vite plugin
263
+ scanDocsMetadata, // Scan docs directory
264
+ generateSearchIndex, // Generate search index
265
+ generateApiDocs, // Generate TypeDoc API docs
266
+ } from "@wsxjs/wsx-press/node";
267
+ ```
268
+
269
+ ### Client Components
270
+
271
+ ```typescript
272
+ import {
273
+ DocPage,
274
+ DocLayout,
275
+ DocSidebar,
276
+ DocTOC,
277
+ DocSearch,
278
+ } from "@wsxjs/wsx-press/client";
279
+ ```
280
+
281
+ ### Types
282
+
283
+ ```typescript
284
+ import type {
285
+ DocMetadata,
286
+ DocsMetaCollection,
287
+ SearchDocument,
288
+ SearchResult,
289
+ SearchIndex,
290
+ TOCItem,
291
+ LoadingState,
292
+ } from "@wsxjs/wsx-press";
293
+ ```
294
+
295
+ ## License
296
+
297
+ MIT
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-mEWJapVH.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();
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@wsxjs/wsx-core"),oe=require("./index-mEWJapVH.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 xe;let we,Ce;function G(t,e,r){return(e=je(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function He(t,e,r,d,o,w){function u(i,c,h){return function(a,n){return h&&h(a),i[c].call(a,n)}}function C(i,c){for(var h=0;h<i.length;h++)i[h].call(c);return c}function v(i,c,h,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(h||"be")+" a function"+(a?"":" or undefined"));return i}function U(i,c,h,a,n,T,R,O,q,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var g,E=c[0],D=c[3],_=!O;if(!_){h||Array.isArray(E)||(E=[E]);var s={},k=[],b=n===3?"get":n===4||m?"set":"value";j?(x||m?s={get:le(function(){return D(this)},a,"get"),set:function(l){c[4](this,l)}}:s[b]=D,x||le(s[b],a,n===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,z=E.length-1;z>=0;z-=h?2:1){var M=E[z],K=h?E[z-1]:void 0,B={},$={kind:["field","accessor","method","getter","setter","class"][n],name:a,metadata:T,addInitializer:(function(l,I){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(I,"An initializer","be",!0),R.push(I)}).bind(null,B)};try{if(_)(g=v(M.call(K,f,$),"class decorators","return"))&&(f=g);else{var A,F;$.static=q,$.private=j,j?n===2?A=function(l){return S(l),s.value}:(n<4&&(A=u(s,"get",S)),n!==3&&(F=u(s,"set",S))):(A=function(l){return l[a]},(n<2||n===4)&&(F=function(l,I){l[a]=I}));var W=$.access={has:j?p.bind():function(l){return a in l}};if(A&&(W.get=A),F&&(W.set=F),f=M.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof f=="object"&&f)(g=v(f.get,"accessor.get"))&&(s.get=g),(g=v(f.set,"accessor.set"))&&(s.set=g),(g=v(f.init,"accessor.init"))&&k.push(g);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(f,(x?"field":"method")+" decorators","return")&&(x?k.push(f):s[b]=f)}}finally{B.v=!0}}return(x||m)&&O.push(function(l,I){for(var H=k.length-1;H>=0;H--)I=k[H].call(l,I);return I}),x||_||(j?m?O.push(u(s,"get"),u(s,"set")):O.push(n===2?s[b]:u.call.bind(s[b])):Object.defineProperty(i,a,s)),f}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 N=w[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,h,a){var n,T,R=[],O=function(b){return Me(b)===i},q=new Map;function j(b){b&&R.push(C.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],g=m.length>3,E=16&p,D=!!(8&p),_=(p&=7)==0,s=S+"/"+D;if(!_&&!g){var k=q.get(s);if(k===!0||k===3&&p!==4||k===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);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,E,g?"#"+S:je(S),p,a,D?T=T||[]:n=n||[],R,D,g,_,p===1,D&&g?O:h)}}return j(n),j(T),R}(t,e,o,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],d,t.name,5,P,i),P),C.bind(null,i,t)]}}}function je(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 d=r.call(t,e);if(typeof d!="object")return d;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"),J={data:null,promise:null};async function Se(t,e={},r=1e4){var u;const d=new AbortController,o=setTimeout(()=>d.abort(),r);let w;if(e.signal){const C=new AbortController;e.signal.aborted?C.abort():e.signal.addEventListener("abort",()=>{C.abort()}),d.signal.addEventListener("abort",()=>{C.abort()}),w=C.signal}else w=d.signal;try{const C=await fetch(t,{...e,signal:w});return clearTimeout(o),C}catch(C){if(clearTimeout(o),C instanceof Error&&C.name==="AbortError"){const v=d.signal.aborted;throw((u=e.signal)==null?void 0:u.aborted)?new Error("Request was cancelled"):v?new Error(`Request timeout after ${r}ms`):new Error("Request was aborted")}throw C}}async function Ke(){return J.data?J.data:(J.promise||(J.promise=(async()=>{try{const t=await Se("/.wsx-press/docs-meta.json",{},5e3);if(!t.ok)throw new Error(`Failed to load metadata: ${t.statusText}`);const e=await t.json();return J.data=e,J.promise=null,e}catch(t){throw J.promise=null,t}})()),J.promise)}Ce=[y.autoRegister({tagName:"wsx-doc-page"})];exports.DocPage=void 0;class Be 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),G(this,"onHashChange",()=>{this.scrollToHash()}),Y.debug("DocPage initialized");const[e,r]=this.useState("loadingState","idle");Object.defineProperty(this,"loadingState",{get:e,set:r,enumerable:!0,configurable:!0});const[d,o]=this.useState("markdown","");Object.defineProperty(this,"markdown",{get:d,set:o,enumerable:!0,configurable:!0});const[w,u]=this.useState("metadata",null);Object.defineProperty(this,"metadata",{get:w,set:u,enumerable:!0,configurable:!0});const[C,v]=this.useState("error",null);Object.defineProperty(this,"error",{get:C,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()})}),window.addEventListener("hashchange",this.onHashChange)}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),window.removeEventListener("hashchange",this.onHashChange),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,d){e==="params"&&this.loadDocument()}async fetchWithTimeout(e,r={},d=1e4){return Se(e,r,d)}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 d=await Ke();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 o=d[r];if(!o){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=o;const w=`/docs/${r}.md`,u=await this.fetchWithTimeout(w,{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(!u.ok){u.status===404?(this.loadingState="error",this.error=new ee.DocumentLoadError(`Document file not found: ${w}`,"NOT_FOUND")):(this.loadingState="error",this.error=new ee.DocumentLoadError(`Failed to load document: ${u.statusText}`,"NETWORK_ERROR",{status:u.status})),this.isLoading=!1;return}const C=await u.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=C,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()})})}}scrollToHash(e=0){const o=window.location.hash;if(!o)return;const w=decodeURIComponent(o.slice(1));if(!w)return;const u=document.getElementById(w);u?(u.scrollIntoView({behavior:"smooth",block:"start"}),Y.debug(`Scrolled to anchor: ${w}`)):e<5?setTimeout(()=>{this.scrollToHash(e+1)},100):Y.warn(`Anchor element not found after 5 retries: ${w}`)}updated(){this.loadingState==="success"&&requestAnimationFrame(()=>this.scrollToHash())}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"},"请选择文档"))}}xe=Be;[exports.DocPage,we]=He(xe,[],Ce,0,void 0,y.LightComponent).c;we();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 Ee;let De,ke;function Q(t,e,r){return(e=Ie(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function We(t,e,r,d,o,w){function u(i,c,h){return function(a,n){return h&&h(a),i[c].call(a,n)}}function C(i,c){for(var h=0;h<i.length;h++)i[h].call(c);return c}function v(i,c,h,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(h||"be")+" a function"+(a?"":" or undefined"));return i}function U(i,c,h,a,n,T,R,O,q,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var g,E=c[0],D=c[3],_=!O;if(!_){h||Array.isArray(E)||(E=[E]);var s={},k=[],b=n===3?"get":n===4||m?"set":"value";j?(x||m?s={get:ue(function(){return D(this)},a,"get"),set:function(l){c[4](this,l)}}:s[b]=D,x||ue(s[b],a,n===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,z=E.length-1;z>=0;z-=h?2:1){var M=E[z],K=h?E[z-1]:void 0,B={},$={kind:["field","accessor","method","getter","setter","class"][n],name:a,metadata:T,addInitializer:(function(l,I){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(I,"An initializer","be",!0),R.push(I)}).bind(null,B)};try{if(_)(g=v(M.call(K,f,$),"class decorators","return"))&&(f=g);else{var A,F;$.static=q,$.private=j,j?n===2?A=function(l){return S(l),s.value}:(n<4&&(A=u(s,"get",S)),n!==3&&(F=u(s,"set",S))):(A=function(l){return l[a]},(n<2||n===4)&&(F=function(l,I){l[a]=I}));var W=$.access={has:j?p.bind():function(l){return a in l}};if(A&&(W.get=A),F&&(W.set=F),f=M.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof f=="object"&&f)(g=v(f.get,"accessor.get"))&&(s.get=g),(g=v(f.set,"accessor.set"))&&(s.set=g),(g=v(f.init,"accessor.init"))&&k.push(g);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(f,(x?"field":"method")+" decorators","return")&&(x?k.push(f):s[b]=f)}}finally{B.v=!0}}return(x||m)&&O.push(function(l,I){for(var H=k.length-1;H>=0;H--)I=k[H].call(l,I);return I}),x||_||(j?m?O.push(u(s,"get"),u(s,"set")):O.push(n===2?s[b]:u.call.bind(s[b])):Object.defineProperty(i,a,s)),f}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 N=w[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,h,a){var n,T,R=[],O=function(b){return Ge(b)===i},q=new Map;function j(b){b&&R.push(C.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],g=m.length>3,E=16&p,D=!!(8&p),_=(p&=7)==0,s=S+"/"+D;if(!_&&!g){var k=q.get(s);if(k===!0||k===3&&p!==4||k===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);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,E,g?"#"+S:Ie(S),p,a,D?T=T||[]:n=n||[],R,D,g,_,p===1,D&&g?O:h)}}return j(n),j(T),R}(t,e,o,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],d,t.name,5,P,i),P),C.bind(null,i,t)]}}}function Ie(t){var e=Ye(t,"string");return typeof e=="symbol"?e:e+""}function Ye(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var d=r.call(t,e);if(typeof d!="object")return d;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 Ge(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 Je 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 N=L.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",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 d=this.reactive([]);Object.defineProperty(this,"results",{get:()=>d,set:L=>{d=L!==null&&typeof L<"u"&&(Array.isArray(L)||typeof L=="object")?this.reactive(L):L,this.scheduleRerender()},enumerable:!0,configurable:!0});const[o,w]=this.useState("isOpen",!1);Object.defineProperty(this,"isOpen",{get:o,set:w,enumerable:!0,configurable:!0});const[u,C]=this.useState("isLoading",!1);Object.defineProperty(this,"isLoading",{get:u,set:C,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 d=[];for(const C of r)C.indices&&d.push(...C.indices);d.sort((C,v)=>C[0]-v[0]);const o=[];for(const[C,v]of d)o.length===0||o[o.length-1][1]<C?o.push([C,v+1]):o[o.length-1][1]=Math.max(o[o.length-1][1],v+1);const w=[];let u=0;for(const[C,v]of o){C>u&&w.push(e.substring(u,C));const U=document.createElement("mark");U.textContent=e.substring(C,v),w.push(U),u=v}return u<e.length&&w.push(e.substring(u)),w}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 u,C;const d=r===this.selectedIndex,o=(u=e.matches)==null?void 0:u.find(v=>v.key==="title"),w=(C=e.matches)==null?void 0:C.find(v=>v.key==="content");return y.jsx("div",{key:e.item.id,class:`search-result ${d?"selected":""}`,onClick:()=>this.selectResult(e),onMouseEnter:()=>{this.selectedIndex=r}},y.jsx("div",{class:"result-title"},o?this.highlightTextNodes(e.item.title,[o]):e.item.title),y.jsx("div",{class:"result-category"},e.item.category),w&&y.jsx("div",{class:"result-snippet"},this.highlightTextNodes(e.item.content.substring(0,100),[w])))})),this.isOpen&&this.query.trim()&&this.results.length===0&&!this.isLoading&&y.jsx("div",{class:"search-no-results"},"未找到匹配的文档"))}}Ee=Je;[exports.DocSearch,De]=We(Ee,[],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,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 Qe(t,e,r,d,o,w){function u(i,c,h){return function(a,n){return h&&h(a),i[c].call(a,n)}}function C(i,c){for(var h=0;h<i.length;h++)i[h].call(c);return c}function v(i,c,h,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(h||"be")+" a function"+(a?"":" or undefined"));return i}function U(i,c,h,a,n,T,R,O,q,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var g,E=c[0],D=c[3],_=!O;if(!_){h||Array.isArray(E)||(E=[E]);var s={},k=[],b=n===3?"get":n===4||m?"set":"value";j?(x||m?s={get:fe(function(){return D(this)},a,"get"),set:function(l){c[4](this,l)}}:s[b]=D,x||fe(s[b],a,n===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,z=E.length-1;z>=0;z-=h?2:1){var M=E[z],K=h?E[z-1]:void 0,B={},$={kind:["field","accessor","method","getter","setter","class"][n],name:a,metadata:T,addInitializer:(function(l,I){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(I,"An initializer","be",!0),R.push(I)}).bind(null,B)};try{if(_)(g=v(M.call(K,f,$),"class decorators","return"))&&(f=g);else{var A,F;$.static=q,$.private=j,j?n===2?A=function(l){return S(l),s.value}:(n<4&&(A=u(s,"get",S)),n!==3&&(F=u(s,"set",S))):(A=function(l){return l[a]},(n<2||n===4)&&(F=function(l,I){l[a]=I}));var W=$.access={has:j?p.bind():function(l){return a in l}};if(A&&(W.get=A),F&&(W.set=F),f=M.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof f=="object"&&f)(g=v(f.get,"accessor.get"))&&(s.get=g),(g=v(f.set,"accessor.set"))&&(s.set=g),(g=v(f.init,"accessor.init"))&&k.push(g);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(f,(x?"field":"method")+" decorators","return")&&(x?k.push(f):s[b]=f)}}finally{B.v=!0}}return(x||m)&&O.push(function(l,I){for(var H=k.length-1;H>=0;H--)I=k[H].call(l,I);return I}),x||_||(j?m?O.push(u(s,"get"),u(s,"set")):O.push(n===2?s[b]:u.call.bind(s[b])):Object.defineProperty(i,a,s)),f}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 N=w[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,h,a){var n,T,R=[],O=function(b){return Ze(b)===i},q=new Map;function j(b){b&&R.push(C.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],g=m.length>3,E=16&p,D=!!(8&p),_=(p&=7)==0,s=S+"/"+D;if(!_&&!g){var k=q.get(s);if(k===!0||k===3&&p!==4||k===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);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,E,g?"#"+S:Te(S),p,a,D?T=T||[]:n=n||[],R,D,g,_,p===1,D&&g?O:h)}}return j(n),j(T),R}(t,e,o,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],d,t.name,5,P,i),P),C.bind(null,i,t)]}}}function Te(t){var e=Xe(t,"string");return typeof e=="symbol"?e:e+""}function Xe(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var d=r.call(t,e);if(typeof d!="object")return d;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 Ze(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 Ve 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 d=this.querySelector(".doc-layout-main");d&&!this.docPageInstance&&(this.docPageInstance=document.createElement("wsx-doc-page"),d.appendChild(this.docPageInstance));const o=this.querySelector(".doc-layout-toc");o&&!this.tocInstance&&(this.tocInstance=document.createElement("wsx-doc-toc"),o.appendChild(this.tocInstance))}})}onDisconnected(){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=Ve;[exports.DocLayout,_e]=Qe(Oe,[],Le,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 Re;let $e,Ae;function ie(t,e,r){return(e=Pe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function et(t,e,r,d,o,w){function u(i,c,h){return function(a,n){return h&&h(a),i[c].call(a,n)}}function C(i,c){for(var h=0;h<i.length;h++)i[h].call(c);return c}function v(i,c,h,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(h||"be")+" a function"+(a?"":" or undefined"));return i}function U(i,c,h,a,n,T,R,O,q,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var g,E=c[0],D=c[3],_=!O;if(!_){h||Array.isArray(E)||(E=[E]);var s={},k=[],b=n===3?"get":n===4||m?"set":"value";j?(x||m?s={get:pe(function(){return D(this)},a,"get"),set:function(l){c[4](this,l)}}:s[b]=D,x||pe(s[b],a,n===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,z=E.length-1;z>=0;z-=h?2:1){var M=E[z],K=h?E[z-1]:void 0,B={},$={kind:["field","accessor","method","getter","setter","class"][n],name:a,metadata:T,addInitializer:(function(l,I){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(I,"An initializer","be",!0),R.push(I)}).bind(null,B)};try{if(_)(g=v(M.call(K,f,$),"class decorators","return"))&&(f=g);else{var A,F;$.static=q,$.private=j,j?n===2?A=function(l){return S(l),s.value}:(n<4&&(A=u(s,"get",S)),n!==3&&(F=u(s,"set",S))):(A=function(l){return l[a]},(n<2||n===4)&&(F=function(l,I){l[a]=I}));var W=$.access={has:j?p.bind():function(l){return a in l}};if(A&&(W.get=A),F&&(W.set=F),f=M.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof f=="object"&&f)(g=v(f.get,"accessor.get"))&&(s.get=g),(g=v(f.set,"accessor.set"))&&(s.set=g),(g=v(f.init,"accessor.init"))&&k.push(g);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(f,(x?"field":"method")+" decorators","return")&&(x?k.push(f):s[b]=f)}}finally{B.v=!0}}return(x||m)&&O.push(function(l,I){for(var H=k.length-1;H>=0;H--)I=k[H].call(l,I);return I}),x||_||(j?m?O.push(u(s,"get"),u(s,"set")):O.push(n===2?s[b]:u.call.bind(s[b])):Object.defineProperty(i,a,s)),f}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 N=w[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,h,a){var n,T,R=[],O=function(b){return rt(b)===i},q=new Map;function j(b){b&&R.push(C.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],g=m.length>3,E=16&p,D=!!(8&p),_=(p&=7)==0,s=S+"/"+D;if(!_&&!g){var k=q.get(s);if(k===!0||k===3&&p!==4||k===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);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,E,g?"#"+S:Pe(S),p,a,D?T=T||[]:n=n||[],R,D,g,_,p===1,D&&g?O:h)}}return j(n),j(T),R}(t,e,o,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],d,t.name,5,P,i),P),C.bind(null,i,t)]}}}function Pe(t){var e=tt(t,"string");return typeof e=="symbol"?e:e+""}function tt(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var d=r.call(t,e);if(typeof d!="object")return d;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 rt(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 it=oe.createLogger("DocSidebar");Ae=[y.autoRegister({tagName:"wsx-doc-sidebar"})];exports.DocSidebar=void 0;class st 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",(u,C)=>{C.preventDefault(),re.RouterUtils.navigate(u)});let e=this.reactive({});Object.defineProperty(this,"metadata",{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,d]=this.useState("currentRoute","");Object.defineProperty(this,"currentRoute",{get:r,set:d,enumerable:!0,configurable:!0});const[o,w]=this.useState("isLoading",!0);Object.defineProperty(this,"isLoading",{get:o,set:w,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,J.data)this.metadata=J.data;else{const e=await fetch("/.wsx-press/docs-meta.json");e.ok&&(this.metadata=await e.json())}}catch(e){it.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(d=>{const o=d.category||"other";e[o]||(e[o]=[]),e[o].push(d)}),Object.keys(e).sort().forEach(d=>{e[d].sort((o,w)=>o.order!==void 0&&w.order!==void 0?o.order-w.order:o.order!==void 0?-1:w.order!==void 0?1:o.title.localeCompare(w.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(d=>y.jsx("div",{key:d,class:"doc-sidebar-category"},y.jsx("h3",{class:"doc-sidebar-category-title"},d),y.jsx("ul",{class:"doc-sidebar-list"},e[d].map(o=>y.jsx("li",{key:o.route,class:"doc-sidebar-item"},y.jsx("a",{href:o.route,class:`doc-sidebar-link ${this.isCurrentDoc(o.route)?"active":""}`,onClick:w=>this.handleDocClick(o.route,w)},o.title))))))))}}Re=st;[exports.DocSidebar,$e]=et(Re,[],Ae,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 qe;let ze,Fe;function te(t,e,r){return(e=Ue(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ot(t,e,r,d,o,w){function u(i,c,h){return function(a,n){return h&&h(a),i[c].call(a,n)}}function C(i,c){for(var h=0;h<i.length;h++)i[h].call(c);return c}function v(i,c,h,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(h||"be")+" a function"+(a?"":" or undefined"));return i}function U(i,c,h,a,n,T,R,O,q,j,x,m,p){function S(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var g,E=c[0],D=c[3],_=!O;if(!_){h||Array.isArray(E)||(E=[E]);var s={},k=[],b=n===3?"get":n===4||m?"set":"value";j?(x||m?s={get:ye(function(){return D(this)},a,"get"),set:function(l){c[4](this,l)}}:s[b]=D,x||ye(s[b],a,n===2?"":b)):x||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,z=E.length-1;z>=0;z-=h?2:1){var M=E[z],K=h?E[z-1]:void 0,B={},$={kind:["field","accessor","method","getter","setter","class"][n],name:a,metadata:T,addInitializer:(function(l,I){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");v(I,"An initializer","be",!0),R.push(I)}).bind(null,B)};try{if(_)(g=v(M.call(K,f,$),"class decorators","return"))&&(f=g);else{var A,F;$.static=q,$.private=j,j?n===2?A=function(l){return S(l),s.value}:(n<4&&(A=u(s,"get",S)),n!==3&&(F=u(s,"set",S))):(A=function(l){return l[a]},(n<2||n===4)&&(F=function(l,I){l[a]=I}));var W=$.access={has:j?p.bind():function(l){return a in l}};if(A&&(W.get=A),F&&(W.set=F),f=M.call(K,m?{get:s.get,set:s.set}:s[b],$),m){if(typeof f=="object"&&f)(g=v(f.get,"accessor.get"))&&(s.get=g),(g=v(f.set,"accessor.set"))&&(s.set=g),(g=v(f.init,"accessor.init"))&&k.push(g);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else v(f,(x?"field":"method")+" decorators","return")&&(x?k.push(f):s[b]=f)}}finally{B.v=!0}}return(x||m)&&O.push(function(l,I){for(var H=k.length-1;H>=0;H--)I=k[H].call(l,I);return I}),x||_||(j?m?O.push(u(s,"get"),u(s,"set")):O.push(n===2?s[b]:u.call.bind(s[b])):Object.defineProperty(i,a,s)),f}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 N=w[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(N??null),X=function(i,c,h,a){var n,T,R=[],O=function(b){return nt(b)===i},q=new Map;function j(b){b&&R.push(C.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],g=m.length>3,E=16&p,D=!!(8&p),_=(p&=7)==0,s=S+"/"+D;if(!_&&!g){var k=q.get(s);if(k===!0||k===3&&p!==4||k===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);q.set(s,!(p>2)||p)}U(D?i:i.prototype,m,E,g?"#"+S:Ue(S),p,a,D?T=T||[]:n=n||[],R,D,g,_,p===1,D&&g?O:h)}}return j(n),j(T),R}(t,e,o,P);return r.length||L(t,P),{e:X,get c(){var i=[];return r.length&&[L(U(t,[r],d,t.name,5,P,i),P),C.bind(null,i,t)]}}}function Ue(t){var e=at(t,"string");return typeof e=="symbol"?e:e+""}function at(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var d=r.call(t,e);if(typeof d!="object")return d;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 ve=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)}Fe=[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",(o,w)=>{w.preventDefault();let u=this.headingElements.get(o);u||(u=document.getElementById(o),u&&this.headingElements.set(o,u)),u?(u.scrollIntoView({behavior:"smooth",block:"start"}),window.history.replaceState(null,"",`#${o}`)):ve.warn(`Heading element not found for id: ${o}`)});let e=this.reactive([]);Object.defineProperty(this,"items",{get:()=>e,set:o=>{e=o!==null&&typeof o<"u"&&(Array.isArray(o)||typeof o=="object")?this.reactive(o):o,this.scheduleRerender()},enumerable:!0,configurable:!0});const[r,d]=this.useState("activeId","");Object.defineProperty(this,"activeId",{get:r,set:d,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 d=await ct();this.items=d[r]||[],requestAnimationFrame(()=>{this.setupHeadingIds(),this.setupScrollObserver()})}catch(e){ve.error("Failed to load TOC",e),this.items=[]}}setupHeadingIds(){const e=document.querySelector(".doc-content");if(!e)return;this.headingElements.clear(),e.querySelectorAll("wsx-marked-heading").forEach(o=>{const w=o.querySelector("h1, h2, h3, h4, h5, h6");w instanceof HTMLElement&&w.id&&this.headingElements.set(w.id,w)}),e.querySelectorAll(":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6").forEach(o=>{var w;if(o instanceof HTMLElement)if(o.id)this.headingElements.set(o.id,o);else{const u=((w=o.textContent)==null?void 0:w.trim())||"";if(u){const C=this.generateId(u);o.id=C,this.headingElements.set(C,o)}}})}generateId(e){return e.toLowerCase().replace(/\s+/g,"-").replace(/[^\p{L}\p{N}-]/gu,"").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}setupScrollObserver(){"IntersectionObserver"in window&&(this.observer=new IntersectionObserver(e=>{const r=e.filter(d=>d.isIntersecting);r.length>0&&(r.sort((d,o)=>{const w=d.boundingClientRect.top,u=o.boundingClientRect.top;return Math.abs(w)-Math.abs(u)}),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,d=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:o=>this.handleTOCClick(e.id,o)},e.text),d&&y.jsx("ul",{class:"doc-toc-list doc-toc-sublist"},e.children.map(o=>this.renderTOCItem(o))))}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)))))}}qe=lt;[exports.DocTOC,ze]=ot(qe,[],Fe,0,void 0,y.LightComponent).c;ze();