specleaf 1.1.3 → 1.2.0
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 +49 -3
- package/lib/assets/ui.js +1 -1
- package/lib/cli.js +151 -9
- package/package.json +2 -1
- package/skills/specleaf/SKILL.md +41 -0
- package/skills/specleaf/agents/openai.yaml +4 -0
package/README.md
CHANGED
|
@@ -23,6 +23,50 @@ npx specleaf ./openapi.yaml
|
|
|
23
23
|
|
|
24
24
|
安装包已包含编译后的 CLI 和界面资源。用户安装与运行均不需要 Vite、React、TypeScript 或前端构建步骤,支持 `--ignore-scripts` 安装。
|
|
25
25
|
|
|
26
|
+
已安装的用户可按安装方式升级到最新版本:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# 全局升级
|
|
30
|
+
npm install -g specleaf@latest
|
|
31
|
+
|
|
32
|
+
# 项目内升级(在项目目录执行)
|
|
33
|
+
npm install -D specleaf@latest
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 安装 Agent skill
|
|
37
|
+
|
|
38
|
+
SpecLeaf **1.2.0+** 随 npm 包提供同一份 `specleaf` skill,可安装给 Codex、Claude Code 和 OpenCode,让 Agent 按自然语言请求选择本地契约、生成或更新离线 HTML,并定位生成失败。
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# 安装到当前目录,支持三个工具;也可用 npx specleaf install skill
|
|
42
|
+
specleaf install skill
|
|
43
|
+
|
|
44
|
+
# 只安装给指定工具;--agent 可重复,也可用逗号分隔
|
|
45
|
+
specleaf install skill --agent codex
|
|
46
|
+
specleaf install skill --agent claude,opencode
|
|
47
|
+
|
|
48
|
+
# 安装到用户目录,供所有项目使用
|
|
49
|
+
specleaf install skill --global
|
|
50
|
+
|
|
51
|
+
# 更新已有且内容不同的 skill 文件,保留其他文件
|
|
52
|
+
specleaf install skill --force
|
|
53
|
+
specleaf install skill --help
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
默认安装范围为**调用目录**,可在目标项目根目录执行;不会自动切换到 Git 根目录。`--global` 使用当前用户的主目录:
|
|
57
|
+
|
|
58
|
+
| 工具 | 项目安装 | 用户安装(`--global`) |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| Codex | `.agents/skills/specleaf/` | `~/.agents/skills/specleaf/` |
|
|
61
|
+
| Claude Code | `.claude/skills/specleaf/` | `~/.claude/skills/specleaf/` |
|
|
62
|
+
| OpenCode | `.agents/skills/specleaf/` | `~/.agents/skills/specleaf/` |
|
|
63
|
+
|
|
64
|
+
OpenCode 使用其支持的 `.agents/skills` 兼容目录,与 Codex 共用一份安装。目录约定见 [Codex 官方文档](https://learn.chatgpt.com/docs/build-skills#where-codex-loads-local-skills)、[Claude Code 官方文档](https://code.claude.com/docs/en/skills#choose-where-skills-load)、[OpenCode 官方文档](https://opencode.ai/docs/skills/#place-files)。
|
|
65
|
+
|
|
66
|
+
安装直接复制包内 skill,无需联网,也不要求三个 Agent 工具已安装。重复安装时跳过内容相同的文件;已有文件内容不同时,先报告冲突且不写入任何目标,使用 `--force` 可更新随包提供的文件。额外文件会保留;安装路径中的符号链接及非预期文件类型会被拒绝。`specleaf.json` 记录安装时的 CLI 版本,供 Agent 在需要临时调用 npm 包时固定版本。通过 npx 首次获取 SpecLeaf 仍可能需要联网。
|
|
67
|
+
|
|
68
|
+
安装后可在 Agent 中请求“把 docs/apis 下的接口契约生成为离线 HTML”。Codex 可通过 `$specleaf` 显式调用,Claude Code 可通过 `/specleaf` 调用;未发现新增 skill 时重新打开会话。skill 聚焦已有契约的生成、更新和错误诊断,生成时源契约只读。
|
|
69
|
+
|
|
26
70
|
## 生成单个 HTML
|
|
27
71
|
|
|
28
72
|
以下命令用于已经安装的 CLI:
|
|
@@ -133,14 +177,14 @@ npm pack
|
|
|
133
177
|
mkdir ../specleaf-consumer
|
|
134
178
|
cd ../specleaf-consumer
|
|
135
179
|
npm init -y
|
|
136
|
-
npm install --omit=dev --ignore-scripts ../specleaf/specleaf-1.
|
|
180
|
+
npm install --omit=dev --ignore-scripts ../specleaf/specleaf-1.2.0.tgz
|
|
137
181
|
npm exec -- specleaf ../specleaf/examples/minimal.json -o ./api.html
|
|
138
182
|
npx specleaf --version
|
|
139
183
|
```
|
|
140
184
|
|
|
141
185
|
把上面的 `../specleaf` 替换为实际源码目录。`npm run test:package` 自动在临时独立目录执行真实 `npm pack`、生产依赖安装、npm scripts、npm exec、npx 临时安装和临时全局安装,再验收文件保护、错误退出与特殊字符。验收后自动删除临时目录,不修改系统全局安装。
|
|
142
186
|
|
|
143
|
-
`build:package` 只生成 `lib/cli.js` 和 `lib/assets/`;`files`
|
|
187
|
+
`build:package` 只生成 `lib/cli.js` 和 `lib/assets/`;`files` 白名单分发这些产物、`skills/specleaf/`、README、LICENSE 和 npm 必需的包元信息。公开接口为 `specleaf` CLI,包含 HTML 生成及 `install skill` 子命令。
|
|
144
188
|
|
|
145
189
|
## 阅读功能
|
|
146
190
|
|
|
@@ -180,7 +224,7 @@ paths:
|
|
|
180
224
|
|
|
181
225
|
当前 Operation 的标准字段 `deprecated: true` 优先显示“已弃用”,即使 `x-api-status` 是其他值,也只显示一个状态徽标。否则只识别表中的小写字符串;缺失、未知值、大小写不符或类型错误时均不显示状态标记。状态不从文档根级、路径或 tag 继承,也不映射其他工具的状态字段。
|
|
182
226
|
|
|
183
|
-
|
|
227
|
+
接口状态在详情页标题区域展示,“操作策略”不再重复展示 `x-api-status`。状态解析只用于展示,导出的合并契约保留原值,不自动补写 `deprecated`。`x-design-status` 仍表示设计状态,在操作策略中展示;文档根级的 `x-contract-status` 仍用于概览中的契约状态说明,两者均不作为接口状态来源。
|
|
184
228
|
|
|
185
229
|
`examples/openapi.yaml` 演示五种状态,`examples/minimal.json` 演示未指定接口状态的契约。
|
|
186
230
|
|
|
@@ -223,12 +267,14 @@ build/serialize.ts HTML JSON 数据块的安全序列化
|
|
|
223
267
|
build/package.ts 预编译 ESM CLI、通用 IIFE、CSS 和图标
|
|
224
268
|
build/generate.ts 读取包内资源、HTML 内嵌与原子写入
|
|
225
269
|
build/cli.ts specleaf 命令、帮助和版本
|
|
270
|
+
build/skills.ts skill 安装、目标目录选择及已有文件保护
|
|
226
271
|
build/build.ts 默认生产构建
|
|
227
272
|
src/lib/openapi.ts 引用、接口、Schema、示例和 cURL 处理
|
|
228
273
|
src/lib/documentation.ts 模块集合类型、标题与模块路由
|
|
229
274
|
src/components.tsx 字段树、参数表、Markdown、示例与复制
|
|
230
275
|
src/App.tsx 目录、概览与接口详情
|
|
231
276
|
examples/ 独立 YAML、JSON 和跨文件模型示例
|
|
277
|
+
skills/specleaf/ 随 npm 包分发的跨工具 skill
|
|
232
278
|
tests/ 单元、命令及浏览器测试
|
|
233
279
|
```
|
|
234
280
|
|
package/lib/assets/ui.js
CHANGED
|
@@ -40,4 +40,4 @@ Error generating stack: `+e.message+`
|
|
|
40
40
|
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=Wc(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}ll.peek=ul;function ll(e){return e.value||``}function ul(){return`<`}dl.peek=fl;function dl(e,t,n,r){let i=zc(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function fl(){return`!`}pl.peek=ml;function pl(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function ml(){return`!`}hl.peek=gl;function hl(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function gl(){return"`"}function _l(e,t){let n=Dn(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}vl.peek=yl;function vl(e,t,n,r){let i=zc(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(_l(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`),u=n.containerPhrasing(e,{before:l,after:`](`,...o.current()});l+=o.move(u),c(),l+=o.move(`](`);let d=/[\0- \u007F]/.test(e.url),f=r.before.charAt(r.before.length-1),p=e.title||void 0;if(!p&&!d&&(f===`
|
|
41
41
|
`||f===`\r`)){let e=0;for(;e<u.length&&u.charCodeAt(e)!==93;)e+=u.charCodeAt(e)===92?2:1;u.charCodeAt(e+1)===58&&(p=``)}return!e.url&&typeof p==`string`||d?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:typeof p==`string`?` `:`)`,...o.current()}))),c(),typeof p==`string`&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(p,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function yl(e,t,n){return _l(e,n)?`<`:`[`}bl.peek=xl;function bl(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function xl(){return`[`}function Sl(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Cl(e){let t=Sl(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function wl(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Tl(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function El(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?wl(n):Sl(n),s=e.ordered?o===`.`?`)`:`.`:Cl(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),Tl(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Dl(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ol(e,t,n,r){let i=Dl(n),a=n.bulletCurrent||Sl(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function kl(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function Al(e,t,n,r){if(!e.children.some(function(e){return Oc(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function jl(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ml.attention=Nl,Ml.peek=Pl;function Ml(e,t,n,r){let i=n.enter(`phrasing`),a=rl([tl(e,Nl,n,n.createTracker(r))],r.before,r.after);return i(),a}function Nl(e,t){return{construct:`strong`,markers:jl(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function Pl(e,t,n){return n.options.strong||`*`}function Fl(e,t,n,r){let i=t?t.children:[],a=n.indexStack[n.indexStack.length-1];return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function Il(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Ll(e,t,n){let r=(Tl(n)+(n.options.ruleSpaces?` `:``)).repeat(Il(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Rl={blockquote:kc,break:Nc,code:Lc,definition:Bc,emphasis:il,hardBreak:Nc,heading:cl,html:ll,image:dl,imageReference:pl,inlineCode:hl,link:vl,linkReference:bl,list:El,listItem:Ol,paragraph:kl,root:Al,strong:Ml,text:Fl,thematicBreak:Ll};function zl(){return{enter:{table:Bl,tableData:Wl,tableHeader:Wl,tableRow:Hl},exit:{codeText:Gl,table:Vl,tableData:Ul,tableHeader:Ul,tableRow:Ul}}}function Bl(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Vl(e){this.exit(e),this.data.inTable=void 0}function Hl(e){this.enter({type:`tableRow`,children:[]},e)}function Ul(e){this.exit(e)}function Wl(e){this.enter({type:`tableCell`,children:[]},e)}function Gl(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Kl));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Kl(e,t){return t===`|`?t:e}function ql(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
42
42
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
43
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Tc(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Rl.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Jl(){return{exit:{taskListCheckValueChecked:Xl,taskListCheckValueUnchecked:Xl,paragraph:Zl}}}function Yl(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Ql}}}function Xl(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Zl(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Ql(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Rl.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function $l(){return[Hs(),fc(),_c(),zl(),Jl()]}function eu(e){return{extensions:[Us(),pc(e),vc(),ql(e),Yl()]}}var tu={tokenize:mu,partial:!0},nu={tokenize:hu,partial:!0},ru={tokenize:gu,partial:!0},iu={tokenize:_u,partial:!0},G={tokenize:vu,partial:!0},au={name:`wwwAutolink`,tokenize:fu,previous:yu},ou={name:`protocolAutolink`,tokenize:pu,previous:bu},su={name:`emailAutolink`,tokenize:du,previous:xu},cu={};function lu(){return{text:cu}}for(var uu=48;uu<123;)cu[uu]=su,uu++,uu===58?uu=65:uu===91&&(uu=97);cu[43]=su,cu[45]=su,cu[46]=su,cu[95]=su,cu[72]=[su,ou],cu[104]=[su,ou],cu[87]=[su,au],cu[119]=[su,au];function du(e,t,n){let r=this,i,a;return o;function o(t){return!Su(t)||!xu.call(r,r.previous)||Cu(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Su(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(G,u,l)(t):t===45||t===95||Vn(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&I(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function fu(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!yu.call(r,r.previous)||Cu(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(tu,e.attempt(nu,e.attempt(ru,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function pu(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&bu.call(r,r.previous)&&!Cu(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(I(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Un(t)||R(t)||Jn(t)||qn(t)?n(t):e.attempt(nu,e.attempt(ru,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function mu(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function hu(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(iu,c,s)(t):t===null||R(t)||Jn(t)||t!==45&&qn(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function gu(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(iu,t,a)(o):o===null||R(o)||Jn(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function _u(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||R(o)||Jn(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||R(e)||Jn(e)?t(e):r(e)}function a(e){return I(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):I(t)?(e.consume(t),o):n(t)}}function vu(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Vn(e)?n(e):t(e)}}function yu(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||R(e)}function bu(e){return!I(e)}function xu(e){return!(e===47||Su(e))}function Su(e){return e===43||e===45||e===46||e===95||Vn(e)}function Cu(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var wu={tokenize:Mu,partial:!0};function Tu(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:ku,continuation:{tokenize:Au},exit:ju}},text:{91:{name:`gfmFootnoteCall`,tokenize:Ou},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Eu,resolveTo:Du}}}}function Eu(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Bn(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Du(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Ou(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||R(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Bn(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return R(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function ku(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||R(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Bn(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return R(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),B(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Au(e,t,n){return e.check(mr,t,e.attempt(wu,t,n))}function ju(e){e.exit(`gfmFootnoteDefinition`)}function Mu(e,t,n){let r=this;return B(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Nu(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Nn(o,o.length,0,sr(s,e.slice(r+1,n),t)),Nn(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Nn(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=or(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=or(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Pu=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Fu(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Fu(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Iu(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Lu(){return{flow:{null:{name:`table`,tokenize:Ru,resolveAll:zu}}}}function Ru(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?ee:c;return a===ee&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):L(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):z(t)?B(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||R(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,z(t)?B(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return z(t)?B(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||L(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return z(t)?B(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||L(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function ee(t){return e.enter(`tableRow`),S(t)}function S(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),S):n===null||L(n)?(e.exit(`tableRow`),t(n)):z(n)?B(e,S,`whitespace`)(n):(e.enter(`data`),C(n))}function C(t){return t===null||t===124||R(t)?(e.exit(`data`),S(t)):(e.consume(t),t===92?w:C)}function w(t){return t===92||t===124?(e.consume(t),C):C(t)}}function zu(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Pu;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Vu(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Bu(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Bu(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Bu(f,t,o,i,n,d)):(o[0]=o[1],d=Bu(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Vu(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Iu(t.events,n))}return e}function Bu(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Hu(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Hu(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Hu(t.events,n[2]),a=Hu(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Hu(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Vu(e,t,n,r,i){let a=[],o=Hu(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Hu(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Uu={name:`tasklistCheck`,tokenize:Gu};function Wu(){return{text:{91:Uu}}}function Gu(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return R(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return L(r)?t(r):z(r)?e.check({tokenize:Ku},t,n)(r):n(r)}}function Ku(e,t,n){return B(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function qu(e){return In([lu(),Tu(),Nu(e),Lu(),Wu()])}var Ju={};function Yu(e){let t=this,n=e||Ju,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(qu(n)),a.push($l()),o.push(eu(n))}function Xu({children:e}){return e?(0,W.jsx)(`div`,{className:`markdown`,children:(0,W.jsx)(ks,{remarkPlugins:[Yu],components:{a:({node:e,...t})=>(0,W.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`}),img:({src:e,alt:t})=>(0,W.jsxs)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`image-link`,children:[`[图片] `,t||e]})},children:e})}):null}function Zu({value:e,label:t=`复制`,iconOnly:n=!1}){let[r,i]=(0,x.useState)(`idle`),a=(0,x.useRef)(void 0),o=(0,x.useRef)(null),s=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>clearTimeout(a.current),[]),(0,x.useEffect)(()=>{r===`error`&&(o.current?.showModal(),s.current?.focus(),s.current?.select())},[r]);async function c(){clearTimeout(a.current);let t=!1;try{navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{}if(!t){let n=document.activeElement,r=document.createElement(`textarea`);r.value=e,r.style.position=`fixed`,r.style.top=`0`,r.style.left=`0`,r.style.opacity=`0`,document.body.append(r);try{r.focus({preventScroll:!0}),r.select(),t=document.execCommand(`copy`)}catch{}finally{r.remove(),n?.focus({preventScroll:!0})}}i(t?`copied`:`error`),t&&(a.current=setTimeout(()=>i(`idle`),2200))}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{type:`button`,className:`copy-button ${n?`icon-only`:``}`,onClick:c,title:t,"aria-label":t,children:[r===`copied`?(0,W.jsx)(E,{size:14}):(0,W.jsx)(oe,{size:14}),(!n||r!==`idle`)&&(0,W.jsx)(`span`,{role:`status`,children:r===`copied`?`已复制`:r===`error`?`复制失败`:t})]}),r===`error`&&(0,W.jsxs)(`dialog`,{ref:o,className:`copy-dialog`,"aria-label":`手动复制`,onClose:()=>i(`idle`),children:[(0,W.jsx)(`h2`,{children:`手动复制`}),(0,W.jsx)(`p`,{children:`浏览器未允许自动复制。请选择下方文本,按 ⌘C / Ctrl+C 复制。`}),(0,W.jsx)(`textarea`,{ref:s,"aria-label":`待复制文本`,readOnly:!0,value:e}),(0,W.jsx)(`button`,{className:`primary-button`,onClick:()=>o.current?.close(),children:`关闭`})]})]})}function Qu({value:e,label:t=`JSON`,copyLabel:n}){let r=e.split(/("(?:\\.|[^"\\])*"\s*:|"(?:\\.|[^"\\])*"|\b(?:true|false|null)\b|-?\b\d+(?:\.\d+)?\b)/g);return(0,W.jsxs)(`div`,{className:`code-block`,children:[(0,W.jsxs)(`div`,{className:`code-toolbar`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(ue,{size:14}),` `,t]}),(0,W.jsx)(Zu,{value:e,label:n||`复制示例`})]}),(0,W.jsx)(`pre`,{tabIndex:0,children:(0,W.jsx)(`code`,{children:r.map((e,t)=>(0,W.jsx)(`span`,{className:e.startsWith(`"`)?e.endsWith(`:`)?`code-key`:`code-string`:/^(true|false|null|-?\d)/.test(e)?`code-value`:void 0,children:e},t))})})]})}function $u(e){return typeof e==`string`?e:JSON.stringify(e)}function K({document:e,schema:t}){return(0,W.jsxs)(`div`,{className:`schema-table`,role:`table`,"aria-label":`数据模型字段`,children:[(0,W.jsxs)(`div`,{className:`schema-head`,role:`row`,children:[(0,W.jsx)(`span`,{role:`columnheader`,children:`字段名称`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`类型`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`必填`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`说明与约束`})]}),(0,W.jsx)(q,{document:e,schema:t,name:`根节点`,depth:0,required:!1,initialOpen:!0})]})}function q({document:e,schema:t,name:n,required:r,depth:i,initialOpen:a=!1}){let[o,s]=(0,x.useState)(a),c=Fe(e,t),l=we(c.schema),u=c.references[0],d=c.recursiveReferences.length>0,f=i>=32?[]:Le(e,c.schema),p=ze(e,c.schema),m=Be(e,c.schema),h=u?decodeURIComponent(u.split(`/`).at(-1)).replace(/~1/g,`/`).replace(/~0/g,`~`):void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`schema-row ${i===0?`schema-root`:``}`,role:`row`,children:[(0,W.jsxs)(`div`,{role:`cell`,className:`field-name`,style:{paddingLeft:Math.min(i,6)*16+12},children:[f.length?(0,W.jsx)(`button`,{type:`button`,className:`expand-field`,onClick:()=>s(!o),"aria-expanded":o,"aria-label":`${o?`收起`:`展开`} ${n}`,children:(0,W.jsx)(ne,{size:14,className:o?`rotated`:``})}):(0,W.jsx)(`span`,{className:`field-spacer`}),(0,W.jsx)(`code`,{title:n,children:n})]}),(0,W.jsxs)(`div`,{role:`cell`,className:`field-type`,children:[(0,W.jsx)(`code`,{children:Ie(e,c.schema)}),h&&(0,W.jsxs)(`span`,{title:u,children:[`↗ `,h]})]}),(0,W.jsx)(`div`,{role:`cell`,children:r?(0,W.jsx)(`span`,{className:`required`,children:`必填`}):(0,W.jsx)(`span`,{className:`optional`,children:`—`})}),(0,W.jsxs)(`div`,{role:`cell`,className:`field-description`,children:[l.title&&(0,W.jsx)(`strong`,{children:l.title}),(0,W.jsx)(Xu,{children:l.description}),d&&(0,W.jsxs)(`span`,{className:`reference-note`,children:[`递归引用 · `,c.recursiveReferences.join(`、`)]}),i>=32&&(0,W.jsx)(`span`,{className:`reference-note`,children:`已达到展示深度上限`}),m.length>0&&(0,W.jsx)(`div`,{className:`constraint-summary`,children:m.map(([e,t])=>(0,W.jsxs)(`span`,{children:[e,`:`,(0,W.jsx)(`code`,{children:$u(t)})]},e))}),p.length>0&&(0,W.jsxs)(`details`,{className:`constraint-details`,children:[(0,W.jsx)(`summary`,{children:`详细校验规则`}),(0,W.jsx)(`div`,{className:`constraints`,children:p.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{children:[e,`:`]}),(0,W.jsx)(`code`,{children:$u(t)})]},e))})]}),c.combinationConstraints.length>0&&(0,W.jsxs)(`details`,{className:`constraint-details`,children:[(0,W.jsx)(`summary`,{children:`组合约束`}),c.notices.map(e=>(0,W.jsx)(`p`,{children:e},e)),(0,W.jsx)(`div`,{className:`constraints`,children:c.combinationConstraints.map((e,t)=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{children:[`来源 `,t+1,`:`]}),(0,W.jsx)(`code`,{children:JSON.stringify(e,null,2)})]},t))})]}),!l.title&&!l.description&&!p.length&&!d&&!c.notices.length&&(0,W.jsx)(`span`,{className:`muted`,children:`—`})]})]}),o&&f.map((t,n)=>(0,W.jsx)(q,{...t,document:e,depth:i+1},`${t.name}-${n}`))]})}function J({document:e,content:t,operation:n}){let r=Object.keys(t),[i,a]=(0,x.useState)(r[0]||``),[o,s]=(0,x.useState)(0),[c,l]=(0,x.useState)(`example`),u=r.includes(i)?i:r[0],d=A(e,t[u]),f=Ve(e,d),p=f[o]??f[0],m=p&&k(p,`value`);return(0,W.jsxs)(`div`,{className:`media-panel`,children:[r.length>0&&(0,W.jsxs)(`div`,{className:`media-controls`,children:[(0,W.jsxs)(`label`,{children:[`媒体类型`,(0,W.jsx)(`select`,{"aria-label":n?`请求媒体类型`:`响应媒体类型`,value:u,onChange:e=>{a(e.target.value),s(0)},children:r.map(e=>(0,W.jsx)(`option`,{children:e},e))})]}),(0,W.jsx)(`span`,{className:`source-note`,children:`以契约定义为准`})]}),k(d,`schema`)&&(0,W.jsx)(K,{document:e,schema:d.schema}),d.encoding&&(0,W.jsx)(X,{title:`编码规则 · encoding`,value:d.encoding}),(0,W.jsxs)(`div`,{className:`example-heading`,children:[(0,W.jsxs)(`div`,{className:`small-tabs`,children:[(0,W.jsx)(`button`,{type:`button`,className:c===`example`?`active`:``,onClick:()=>l(`example`),children:`原始示例`}),n&&(0,W.jsx)(`button`,{type:`button`,className:c===`curl`?`active`:``,onClick:()=>l(`curl`),children:`cURL`})]}),f.length>0&&(0,W.jsx)(`select`,{"aria-label":n?`请求示例`:`响应示例`,value:Math.min(o,f.length-1),onChange:e=>s(Number(e.target.value)),children:f.map((e,t)=>(0,W.jsx)(`option`,{value:t,children:e.name},t))})]}),c===`curl`&&n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Qu,{label:`cURL · 请求模板`,copyLabel:`复制 cURL`,value:We(e,n,u,p)}),(0,W.jsx)(`p`,{className:`helper-text`,children:`使用契约中的服务地址;相对地址及花括号占位符需按实际部署和凭据替换。此处仅复制,不发送请求。`})]}):(0,W.jsxs)(W.Fragment,{children:[p?.description&&(0,W.jsx)(Xu,{children:p.description}),m?(0,W.jsx)(Qu,{value:He(p.value,u),label:u||`原始示例`}):p?.externalValue?(0,W.jsxs)(`div`,{className:`empty-note`,children:[(0,W.jsx)(ge,{size:16}),(0,W.jsxs)(`span`,{children:[`契约使用外部示例(未加载):`,(0,W.jsx)(`code`,{children:p.externalValue})]})]}):(0,W.jsxs)(`div`,{className:`empty-note`,children:[(0,W.jsx)(ue,{size:17}),(0,W.jsx)(`span`,{children:`契约未提供原始示例`})]})]})]})}function Y({document:e,parameters:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`schema-table`,role:`table`,"aria-label":`参数字段`,children:[(0,W.jsxs)(`div`,{className:`schema-head`,role:`row`,children:[(0,W.jsx)(`span`,{role:`columnheader`,children:`参数名称`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`类型`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`必填`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`说明与约束`})]}),t.map(t=>(0,W.jsx)(q,{document:e,name:t.name,required:t.in===`path`||!!t.required,depth:0,schema:{allOf:[t.schema??Object.values(we(t.content))[0]?.schema,{...t.description?{description:t.description}:{},...t.deprecated?{deprecated:!0}:{}}]}},`${t.in}:${t.name}`))]}),t.map(t=>(0,W.jsxs)(`div`,{children:[[`style`,`explode`,`allowEmptyValue`,`allowReserved`].some(e=>k(t,e))&&(0,W.jsxs)(`div`,{className:`parameter-serialization`,children:[(0,W.jsx)(`code`,{children:t.name}),[`style`,`explode`,`allowEmptyValue`,`allowReserved`].filter(e=>k(t,e)).map(e=>(0,W.jsxs)(`span`,{children:[e,`: `,(0,W.jsx)(`code`,{children:String(t[e])})]},e))]}),(k(t,`example`)||t.examples)&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsxs)(`summary`,{children:[t.name,` · 参数示例`]}),(0,W.jsx)(J,{document:e,content:{"application/json":t}})]}),t.content&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsxs)(`summary`,{children:[t.name,` · 参数内容`]}),(0,W.jsx)(J,{document:e,content:t.content})]})]},t.name))]})}function X({title:e,value:t}){return(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:e}),(0,W.jsx)(Qu,{value:He(t)})]})}function ed({id:e,title:t,subtitle:n,children:r,badge:i}){return(0,W.jsxs)(`section`,{id:e,className:`doc-section`,children:[(0,W.jsxs)(`div`,{className:`section-heading`,children:[(0,W.jsx)(`h2`,{children:t}),i,n&&(0,W.jsx)(`span`,{children:n})]}),r]})}var td=()=>new Set([]),nd=[me,be,se,he,ce,ie,de,pe],rd=[[`introduction`,`文档概览`],[`quickstart`,`开始使用`],[`groups`,`接口分组`],[`conventions`,`通用约定`]],id=[[`description`,`接口说明`],[`authentication`,`身份认证`],[`parameters`,`请求参数`],[`request`,`请求体与示例`],[`responses`,`返回响应`],[`policies`,`操作策略`]];function ad(){let[e,t]=(0,x.useState)(window.location.hash);(0,x.useEffect)(()=>{let e=()=>t(window.location.hash);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let n=Ge(Ce)?Ce:void 0,r=qe(e,n?.modules),i=n?.modules.find(e=>e.id===r.moduleId),a=n?i?.document??{info:{title:n.title},paths:{}}:Ce;return(0,W.jsx)(od,{document:a,title:n?.title??a.info.title,modules:n?.modules,moduleId:i?.id,route:r})}function od({document:e,title:t,modules:n,moduleId:r,route:i}){let a=(0,x.useMemo)(()=>j(e),[e]),o=(0,x.useMemo)(()=>De(e,a),[e,a]),s=Ke(r??n?.[0]?.id),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(td),[m,h]=(0,x.useState)(td),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(`introduction`),[b,ee]=(0,x.useState)(()=>window.matchMedia(`(max-width: 800px)`).matches),S=(0,x.useRef)(null),E=!i.invalid&&(!n||r!==void 0)?a.find(e=>e.id===i.operationId):void 0,oe=i.invalid||!!n&&r===void 0||i.operationId!==void 0&&!E,se=oe?[]:E?id:rd,ce=(0,x.useMemo)(()=>n?n.map(e=>{let t=j(e.document);return{moduleId:e.id,document:e.document,operations:t,tags:De(e.document,t)}}):[{moduleId:void 0,document:e,operations:a,tags:o}],[n,e,a,o]),le=(0,x.useMemo)(()=>ce.map(e=>({...e,operations:e.operations.filter(t=>Ae(t,c,u,n?`${e.moduleId} ${e.document.info.title}`:``))})),[ce,c,u,n]),ue=ce.reduce((e,t)=>e+t.operations.length,0),fe=le.reduce((e,t)=>e+t.operations.length,0),pe=!!c.trim()||!!u;(0,x.useEffect)(()=>{let e=window.matchMedia(`(max-width: 800px)`),t=()=>ee(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,x.useEffect)(()=>{let e=()=>{_(!1),window.scrollTo(0,0),window.document.getElementById(`main`)?.focus({preventScroll:!0})};window.addEventListener(`hashchange`,e);let t=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),_(!0),S.current?.focus()),e.key===`Escape`&&_(!1)};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`keydown`,t)}},[]),(0,x.useEffect)(()=>{window.document.title=E?`${E.definition.summary||E.path} · ${e.info.title}`:`${e.info.title} · API 文档`,E&&(n?h(e=>new Set([...e].filter(e=>!E.tags.some(t=>e===JSON.stringify([r,t]))))):p(e=>new Set([...e,...E.tags])))},[E,e,n,r]),(0,x.useEffect)(()=>{let e=0,t=()=>{let e=(window.document.querySelector(`.topbar`)?.getBoundingClientRect().height||66)+32,t=se[0]?.[0]||``;for(let[n]of se){let r=window.document.getElementById(n);r&&r.getBoundingClientRect().top<=e&&(t=n)}window.scrollY>0&&window.innerHeight+window.scrollY>=window.document.documentElement.scrollHeight-2&&(t=se.at(-1)?.[0]||t),y(t)},n=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(t)};return t(),window.addEventListener(`scroll`,n,{passive:!0}),window.addEventListener(`resize`,n),()=>{cancelAnimationFrame(e),window.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n)}},[E,oe,e]),(0,x.useEffect)(()=>{if(!g)return;let e=window.document.body.style.overflow;window.matchMedia(`(max-width: 800px)`).matches&&(window.document.body.style.overflow=`hidden`);let t=window.document.querySelector(`.sidebar`),n=e=>{if(e.key!==`Tab`||!window.matchMedia(`(max-width: 800px)`).matches||!t)return;let n=[...t.querySelectorAll(`button, a, input, select`)].filter(e=>e.offsetParent!==null),r=n[0],i=n.at(-1);e.shiftKey&&window.document.activeElement===r&&(e.preventDefault(),i?.focus()),!e.shiftKey&&window.document.activeElement===i&&(e.preventDefault(),r?.focus())};return S.current?.focus(),window.addEventListener(`keydown`,n),()=>{window.document.body.style.overflow=e,window.removeEventListener(`keydown`,n),t?.contains(window.document.activeElement)&&window.document.querySelector(`.mobile-menu`)?.focus()}},[g]);function me(e,t){let r=n?JSON.stringify([t,e]):e;(n?h:p)(e=>{let t=new Set(e);return t.has(r)?t.delete(r):t.add(r),t})}function ge(e){l(``),d(``),n?h(t=>{let n=new Set(t);return n.delete(JSON.stringify([r,e])),n}):p(t=>new Set(t).add(e));let t=a.find(t=>t.tags.includes(e));t&&(window.location.hash=Oe(t,r))}function Se(){let t=URL.createObjectURL(new Blob([He(e)],{type:`application/json`})),n=window.document.createElement(`a`);n.href=t,n.download=r===void 0?`openapi.json`:`openapi-${encodeURIComponent(r)}.json`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3)}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`a`,{className:`skip-link`,href:`#main`,onClick:e=>{e.preventDefault(),window.document.getElementById(`main`)?.focus({preventScroll:!0})},children:`跳转到正文`}),(0,W.jsxs)(`header`,{className:`topbar`,children:[(0,W.jsx)(`button`,{className:`mobile-menu icon-button`,"aria-label":`打开接口目录`,onClick:()=>_(!0),children:(0,W.jsx)(ve,{size:21})}),(0,W.jsxs)(`a`,{className:`brand`,href:s,children:[(0,W.jsx)(`span`,{className:`brand-symbol`,children:(0,W.jsx)(ie,{size:23,strokeWidth:2.5})}),(0,W.jsx)(`span`,{className:`brand-name`,title:t,children:t})]}),(0,W.jsxs)(`nav`,{className:`top-nav`,"aria-label":`主导航`,children:[(0,W.jsx)(`a`,{className:`active`,href:s,children:`API 文档`}),(0,W.jsxs)(`button`,{onClick:Se,disabled:!!n&&r===void 0,title:n?`导出当前模块:${e.info.title}`:void 0,children:[(0,W.jsx)(C,{size:15}),` 导出 OpenAPI`]})]}),(0,W.jsxs)(`div`,{className:`header-right`,children:[(0,W.jsxs)(`span`,{className:`version-pill`,children:[(0,W.jsx)(`span`,{}),e.info.version||`未指定版本`]}),(0,W.jsx)(`a`,{className:`help-link`,href:s,"aria-label":`文档概览`,children:(0,W.jsx)(re,{size:19})})]})]}),g&&(0,W.jsx)(`button`,{className:`drawer-backdrop`,"aria-label":`关闭接口目录`,onClick:()=>_(!1)}),(0,W.jsxs)(`aside`,{className:`sidebar ${g?`drawer-open`:``}`,"aria-label":`接口目录`,inert:b&&!g,children:[(0,W.jsxs)(`div`,{className:`sidebar-tools`,children:[(0,W.jsxs)(`div`,{className:`workspace-label`,children:[(0,W.jsx)(`span`,{className:`workspace-icon`,children:(0,W.jsx)(he,{size:17})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:t}),(0,W.jsx)(`span`,{children:n?`${n.length} 个模块 · ${ue} 个接口`:`接口参考手册`})]}),(0,W.jsx)(`button`,{className:`close-drawer icon-button`,onClick:()=>_(!1),"aria-label":`关闭目录`,children:(0,W.jsx)(xe,{size:19})}),(0,W.jsx)(te,{size:14,className:`desktop-chevron`})]}),n&&(0,W.jsx)(`p`,{className:`search-scope`,children:`搜索范围:全部模块`}),(0,W.jsxs)(`div`,{className:`search-box`,children:[(0,W.jsx)(ye,{size:16}),(0,W.jsx)(`input`,{ref:S,"aria-label":`搜索接口`,placeholder:n?`搜索全部模块、接口或路径`:`搜索接口、路径或关键词`,value:c,onChange:e=>l(e.target.value)}),c?(0,W.jsx)(`button`,{className:`icon-button`,"aria-label":`清空搜索`,onClick:()=>l(``),children:(0,W.jsx)(xe,{size:14})}):(0,W.jsxs)(`kbd`,{children:[(0,W.jsx)(ae,{size:10}),` K`]})]}),(0,W.jsxs)(`div`,{className:`method-filter`,children:[(0,W.jsx)(_e,{size:13}),(0,W.jsxs)(`select`,{"aria-label":`筛选请求方法`,value:u,onChange:e=>d(e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`全部请求方法`}),D.map(e=>(0,W.jsx)(`option`,{value:e,children:e.toUpperCase()},e))]}),(0,W.jsxs)(`span`,{children:[fe,` 个接口`]})]})]}),(0,W.jsxs)(`nav`,{className:`sidebar-scroll`,"aria-label":`接口分组`,children:[!n&&(0,W.jsxs)(`a`,{className:`overview-link ${!E&&!oe?`selected`:``}`,href:s,onClick:()=>_(!1),children:[(0,W.jsx)(T,{size:17}),`文档概览`,(0,W.jsx)(ne,{size:14})]}),(0,W.jsxs)(`div`,{className:`nav-caption`,children:[`接口目录 `,(0,W.jsx)(`span`,{children:n?`${n.length} 个模块`:`${o.length} 个分组`})]}),le.map(e=>{if(pe&&!e.operations.length)return null;let t=(0,W.jsx)(sd,{tags:e.tags,operations:e.operations,moduleId:e.moduleId,selected:r===e.moduleId?E:void 0,isOpen:t=>pe||(n?!m.has(JSON.stringify([e.moduleId,t])):f.has(t)),filtering:pe,onToggle:t=>me(t,e.moduleId),onNavigate:()=>_(!1)});return n?(0,W.jsxs)(`section`,{className:`module-group`,"aria-label":`模块 ${e.moduleId} · ${e.document.info.title}`,children:[(0,W.jsxs)(`a`,{className:`module-heading ${r===e.moduleId?`current-module`:``}`,href:Ke(e.moduleId),"aria-current":r===e.moduleId&&!E&&!oe?`page`:void 0,"aria-label":`模块概览:${e.moduleId} · ${e.document.info.title}`,onClick:()=>_(!1),children:[(0,W.jsx)(he,{size:16}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.document.info.title}),(0,W.jsx)(`small`,{title:e.moduleId,children:e.moduleId})]}),(0,W.jsx)(`span`,{className:`group-count`,children:e.operations.length})]}),t,!e.operations.length&&(0,W.jsx)(`div`,{className:`module-empty`,children:`该模块暂无接口定义`})]},e.moduleId):(0,W.jsx)(`div`,{children:t},`single`)}),ue===0?(0,W.jsxs)(`div`,{className:`search-empty`,children:[(0,W.jsx)(de,{size:25}),(0,W.jsx)(`strong`,{children:n?`当前项目暂无接口定义`:`当前契约暂无接口定义`})]}):fe===0&&(0,W.jsxs)(`div`,{className:`search-empty`,children:[(0,W.jsx)(ye,{size:25}),(0,W.jsx)(`strong`,{children:`没有找到相关接口`}),(0,W.jsx)(`span`,{children:`试试其他关键词或请求方法`}),(0,W.jsx)(`button`,{onClick:()=>{l(``),d(``)},children:`清除筛选`})]})]}),(0,W.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,W.jsx)(`span`,{className:`status-dot`}),`契约驱动 · 静态文档`,(0,W.jsxs)(`span`,{children:[`OAS `,e.openapi]})]})]}),(0,W.jsxs)(`div`,{className:`page-shell`,children:[(0,W.jsxs)(`main`,{id:`main`,tabIndex:-1,children:[(0,W.jsxs)(`div`,{className:`breadcrumb`,children:[(0,W.jsx)(`span`,{children:`开发者文档`}),(0,W.jsx)(ne,{size:13}),(0,W.jsx)(`span`,{children:`API 文档`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ne,{size:13}),(0,W.jsx)(`span`,{children:r??`无效模块`})]}),E&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ne,{size:13}),(0,W.jsx)(`span`,{children:E.tags[0]})]})]}),oe?(0,W.jsxs)(`div`,{className:`not-found`,children:[(0,W.jsx)(de,{size:40}),(0,W.jsx)(`h1`,{children:n&&r===void 0?`未找到该模块`:`未找到该接口`}),(0,W.jsxs)(`p`,{children:[`链接无效,或对应的`,n&&r===void 0?`模块`:`接口`,`已在契约更新后移除。`]}),(0,W.jsxs)(`a`,{href:s,children:[`返回文档概览 `,(0,W.jsx)(w,{size:15})]})]}):E?(0,W.jsx)(hd,{document:e,operation:E,moduleId:r},JSON.stringify([r,E.id])):(0,W.jsx)(cd,{document:e,operations:a,tags:o,moduleId:r,onOpenTag:ge,onDownload:Se},r),(0,W.jsxs)(`footer`,{className:`page-footer`,children:[(0,W.jsxs)(`span`,{children:[e.info.title,` · API Reference`]}),(0,W.jsxs)(`span`,{children:[`基于 OpenAPI `,e.openapi,(0,W.jsx)(`span`,{className:`footer-dot`,children:`·`}),`版本 `,e.info.version||`未指定`]})]})]}),(0,W.jsxs)(`aside`,{className:`page-outline`,"aria-label":`本页目录`,children:[(0,W.jsx)(`span`,{children:`本页目录`}),se.map(([e,t])=>(0,W.jsx)(`button`,{className:v===e?`current`:``,"aria-current":v===e?`location`:void 0,onClick:()=>window.document.getElementById(e)?.scrollIntoView({behavior:`smooth`}),children:t},e)),(0,W.jsxs)(`div`,{className:`outline-note`,children:[(0,W.jsx)(be,{size:19}),(0,W.jsx)(`strong`,{children:`以接口契约为准`}),(0,W.jsx)(`p`,{children:`字段、示例与操作策略均来自当前版本的 API 契约。`})]})]})]})]})}function sd({tags:e,operations:t,moduleId:n,selected:r,isOpen:i,filtering:a,onToggle:o,onNavigate:s}){return e.map(e=>{let c=t.filter(t=>t.tags.includes(e));if(a&&!c.length)return null;let l=i(e);return(0,W.jsxs)(`div`,{className:`nav-group`,children:[(0,W.jsxs)(`button`,{className:`group-toggle`,onClick:()=>o(e),"aria-expanded":l,children:[(0,W.jsx)(ne,{size:13,className:l?`rotated`:``}),(0,W.jsx)(fe,{size:15}),(0,W.jsx)(`span`,{title:e,children:e}),(0,W.jsx)(`span`,{className:`group-count`,children:c.length})]}),l&&(0,W.jsx)(`div`,{className:`group-operations`,children:c.map(e=>{let t=Te(e.definition);return(0,W.jsxs)(`a`,{href:Oe(e,n),className:`operation-link ${r?.id===e.id?`selected`:``}`,onClick:s,"aria-current":r?.id===e.id?`page`:void 0,title:`${e.method.toUpperCase()} ${e.path}`,children:[(0,W.jsx)(`span`,{className:`method method-${e.method}`,children:e.method.toUpperCase()}),(0,W.jsx)(`span`,{className:`operation-link-title`,children:e.definition.summary||e.path}),t&&(0,W.jsx)(`span`,{className:`api-status-dot api-status-${t}`,role:`img`,"aria-label":`接口状态:${O[t]}`,title:`接口状态:${O[t]}`})]},e.id)})})]},e)})}function cd({document:e,operations:t,tags:n,moduleId:r,onOpenTag:i,onDownload:a}){let o=t[0];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{id:`introduction`,className:`overview-hero`,children:[(0,W.jsxs)(`div`,{className:`eyebrow`,children:[(0,W.jsx)(`span`,{}),` API REFERENCE `,(0,W.jsx)(`span`,{className:`hero-badge`,children:`中文文档`})]}),(0,W.jsxs)(`h1`,{children:[e.info.title,(0,W.jsx)(`span`,{className:`heading-mark`,children:`.`})]}),e.info.summary&&(0,W.jsx)(`p`,{className:`hero-lead`,children:e.info.summary}),(0,W.jsx)(Xu,{children:e.info.description}),(0,W.jsxs)(`div`,{className:`hero-actions`,children:[(0,W.jsxs)(`button`,{className:`primary-button`,disabled:!t.length,onClick:()=>o&&i(o.tags[0]),children:[(0,W.jsx)(T,{size:16}),`浏览接口`,(0,W.jsx)(w,{size:16})]}),(0,W.jsxs)(`button`,{className:`secondary-button`,onClick:a,children:[(0,W.jsx)(C,{size:16}),`导出 OpenAPI`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(E,{size:13}),` YAML / JSON 契约`]})]})]}),(0,W.jsxs)(`div`,{className:`stats-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`stat-icon purple`,children:(0,W.jsx)(ie,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[t.length,(0,W.jsx)(`small`,{children:`个`})]}),(0,W.jsx)(`span`,{children:`接口定义`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`stat-icon blue`,children:(0,W.jsx)(fe,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[n.length,(0,W.jsx)(`small`,{children:`个`})]}),(0,W.jsx)(`span`,{children:`接口分组`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`stat-icon green`,children:(0,W.jsx)(be,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.openapi}),(0,W.jsx)(`span`,{children:`OpenAPI 规范`})]})]})]}),(0,W.jsx)(ed,{id:`quickstart`,title:`开始使用`,subtitle:`三步了解你的第一个接口`,children:(0,W.jsxs)(`div`,{className:`getting-started`,children:[(0,W.jsxs)(`div`,{className:`start-steps`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`01`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`找到需要的接口`}),(0,W.jsx)(`p`,{children:`按业务目录浏览,或使用关键词与请求方法筛选。`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`02`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`了解参数与鉴权`}),(0,W.jsx)(`p`,{children:`查看字段约束、身份凭据及接口的操作策略。`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`03`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`复制示例,开始集成`}),(0,W.jsx)(`p`,{children:`使用原始示例或 cURL 模板,替换实际服务地址。`})]})]})]}),(0,W.jsxs)(`div`,{className:`start-example`,children:[(0,W.jsxs)(`div`,{className:`example-caption`,children:[(0,W.jsx)(`span`,{className:`status-dot`}),o?`从第一个接口开始`:`接口示例`]}),o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Qu,{value:We(e,o),label:`cURL`,copyLabel:`复制 cURL`}),(0,W.jsxs)(`a`,{href:Oe(o,r),children:[`查看 `,o.definition.summary||o.path,(0,W.jsx)(w,{size:14})]})]}):(0,W.jsx)(`p`,{children:`当前契约暂无接口定义。`})]})]})}),(0,W.jsx)(ed,{id:`groups`,title:`接口分组`,subtitle:`按业务领域探索全部能力`,badge:(0,W.jsx)(`span`,{className:`count-badge`,children:n.length}),children:(0,W.jsx)(`div`,{className:`group-cards`,children:n.map((n,r)=>{let a=nd[r%nd.length],o=t.filter(e=>e.tags.includes(n)).length,s=(e.tags||[]).find(e=>e.name===n);return(0,W.jsxs)(`div`,{className:`group-card`,children:[(0,W.jsx)(`span`,{className:`group-card-icon tone-${r%4}`,children:(0,W.jsx)(a,{size:21})}),(0,W.jsxs)(`div`,{className:`group-card-copy`,children:[(0,W.jsx)(`button`,{className:`group-card-title`,onClick:()=>i(n),disabled:!o,children:n}),(0,W.jsx)(Xu,{children:s?.description||`查看该分组的接口定义`}),(0,W.jsxs)(`small`,{children:[o,` 个接口`]})]}),(0,W.jsx)(w,{size:16})]},n)})})}),(0,W.jsxs)(ed,{id:`conventions`,title:`通用约定`,children:[(0,W.jsxs)(`div`,{className:`convention-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(ce,{size:20}),(0,W.jsx)(`h3`,{children:`服务地址`}),(e.servers||[]).length?e.servers.map((e,t)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`code`,{children:e.url}),(0,W.jsx)(Xu,{children:e.description}),e.variables&&(0,W.jsx)(X,{title:`服务地址变量`,value:e.variables})]},t)):(0,W.jsx)(`p`,{children:`契约未指定服务地址,请使用实际部署地址。`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(be,{size:20}),(0,W.jsx)(`h3`,{children:`身份与权限`}),(0,W.jsx)(`p`,{children:`每个接口单独展示鉴权方式、权限范围、限流与审计要求。公开接口会标记为「无需鉴权」。`})]})]}),e[`x-contract-status`]&&(0,W.jsxs)(`div`,{className:`info-callout`,children:[(0,W.jsx)(re,{size:17}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`契约与实际可用范围`}),(0,W.jsx)(`p`,{children:`当前契约状态如下,接口实际可用范围请结合后端实现和部署确认。`}),(0,W.jsx)(X,{title:`契约状态 · x-contract-status`,value:e[`x-contract-status`]})]})]})]})]})}function ld({document:e,operation:t}){let n=t.definition.security??e.security??[];return n.length?(0,W.jsxs)(`div`,{className:`authentication`,children:[(0,W.jsx)(`p`,{className:`helper-text`,children:`以下方案满足任意一组即可;同组内的凭据需要同时提供。`}),n.map((t,n)=>(0,W.jsxs)(`div`,{className:`auth-option`,children:[(0,W.jsxs)(`span`,{className:`auth-option-label`,children:[`方案 `,n+1]}),Object.keys(t).length===0?(0,W.jsx)(`span`,{children:`允许匿名访问`}):Object.entries(t).map(([t,n])=>{let r=A(e,e.components?.securitySchemes?.[t]);return(0,W.jsxs)(`div`,{className:`auth-scheme`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(me,{size:15}),(0,W.jsx)(`strong`,{children:t}),(0,W.jsxs)(`code`,{children:[r.type||`未定义`,r.scheme?` / ${r.scheme}`:``]})]}),(0,W.jsx)(Xu,{children:r.description}),r.name&&(0,W.jsxs)(`p`,{children:[`传入位置:`,(0,W.jsx)(`code`,{children:r.in}),` · 参数名:`,(0,W.jsx)(`code`,{children:r.name})]}),r.bearerFormat&&(0,W.jsxs)(`p`,{children:[`凭据格式:`,(0,W.jsx)(`code`,{children:r.bearerFormat})]}),n.length>0&&(0,W.jsxs)(`p`,{children:[`所需范围:`,(0,W.jsx)(`code`,{children:n.join(`, `)})]}),r.flows&&(0,W.jsx)(X,{title:`OAuth 流程 · flows`,value:r.flows}),r.openIdConnectUrl&&(0,W.jsxs)(`p`,{children:[`发现地址:`,(0,W.jsx)(`code`,{children:r.openIdConnectUrl})]})]},t)})]},n))]}):(0,W.jsxs)(`div`,{className:`auth-public`,children:[(0,W.jsx)(be,{size:18}),(0,W.jsx)(`strong`,{children:`无需鉴权`}),(0,W.jsx)(`span`,{children:`该接口未要求身份凭据`})]})}function ud({document:e,operation:t}){let n=we(t.definition.responses),r=Object.keys(n),[i,a]=(0,x.useState)(r[0]),o=A(e,n[i]),s=Object.entries(we(o.headers)).map(([t,n])=>({...A(e,n),name:t,in:`header`}));return r.length?(0,W.jsxs)(`div`,{className:`response-panel`,children:[(0,W.jsx)(`div`,{className:`status-tabs`,role:`tablist`,"aria-label":`响应状态码`,children:r.map(e=>(0,W.jsxs)(`button`,{role:`tab`,"aria-selected":i===e,className:i===e?`active`:``,onClick:()=>a(e),children:[(0,W.jsx)(`span`,{className:`response-dot ${/^[23]/.test(e)?`success`:/^[45]/.test(e)?`error`:``}`}),e]},e))}),(0,W.jsxs)(`div`,{role:`tabpanel`,"aria-label":`${i} 响应`,children:[(0,W.jsxs)(`div`,{className:`response-description`,children:[(0,W.jsx)(`span`,{className:`response-code ${/^[23]/.test(i)?`success`:``}`,children:i}),(0,W.jsx)(Xu,{children:o.description})]}),s.length>0&&(0,W.jsxs)(`details`,{className:`response-headers`,children:[(0,W.jsxs)(`summary`,{children:[`响应头 `,(0,W.jsx)(`span`,{children:s.length})]}),(0,W.jsx)(Y,{document:e,parameters:s})]}),o.content&&Object.keys(o.content).length?(0,W.jsx)(J,{document:e,content:o.content},i):(0,W.jsx)(`div`,{className:`empty-note`,children:`该响应未定义响应体`}),o.links&&(0,W.jsx)(X,{title:`关联接口 · links`,value:o.links})]},i)]}):(0,W.jsx)(`div`,{className:`empty-note`,children:`契约未定义响应`})}var dd={"x-permissions":`访问权限`,"x-rate-limit":`请求限流`,"x-idempotency":`幂等策略`,"x-audit":`审计要求`,"x-sensitive-fields":`敏感字段`,"x-api-status":`接口状态`,"x-design-status":`设计状态`},fd={permission:`权限标识`,roles:`允许角色`,scope:`作用范围`,window_seconds:`窗口秒数`,principal_limit:`主体请求上限`,ip_limit:`IP 请求上限`,key:`限流键`,failure_policy:`失败策略`,shared_across_sessions:`跨会话共享`,required:`是否必需`,retention:`保留策略`,conflict:`冲突处理`,recovery:`恢复方式`,reason_required:`是否需要原因`,events:`审计事件`,secrets:`凭据处理`,request_or_response:`涉及字段`,logging:`日志规则`};function pd(e){return e===!0?`是`:e===!1?`否`:e===null?`空值`:Array.isArray(e)&&e.length===0?`无`:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function md({definition:e}){let t=Object.entries(e).filter(([e])=>e.startsWith(`x-`));return t.length?(0,W.jsx)(`div`,{className:`policy-grid`,children:t.map(([e,t])=>(0,W.jsxs)(`details`,{className:`policy-card`,open:e!==`x-design-status`,children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsx)(`span`,{children:dd[e]||`扩展说明`}),(0,W.jsx)(`code`,{children:e}),(0,W.jsx)(te,{size:14})]}),typeof t==`object`&&t&&!Array.isArray(t)?(0,W.jsx)(`dl`,{children:Object.entries(t).map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`dt`,{children:[fd[e]||e,(0,W.jsx)(`code`,{children:e})]}),(0,W.jsx)(`dd`,{children:pd(t)})]},e))}):(0,W.jsx)(`p`,{children:pd(t)})]},e))}):(0,W.jsx)(`div`,{className:`empty-note`,children:`契约未定义扩展操作策略`})}function hd({document:e,operation:t,moduleId:n}){let r=t.definition,i=Te(r),a=A(e,r.requestBody),o=new URL(Oe(t,n),window.location.href).href,s=[`path`,`query`,`header`,`cookie`].map(e=>({location:e,values:t.parameters.filter(t=>t.in===e)})).filter(e=>e.values.length);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{id:`description`,className:`operation-header`,children:[(0,W.jsxs)(`div`,{className:`eyebrow`,children:[t.tags[0],(0,W.jsx)(ne,{size:12}),(0,W.jsx)(`span`,{children:r.operationId||`接口详情`})]}),(0,W.jsxs)(`div`,{className:`title-row`,children:[(0,W.jsx)(`h1`,{children:r.summary||t.path}),(0,W.jsx)(Zu,{value:o,label:`复制链接`})]}),(0,W.jsxs)(`div`,{className:`operation-badges`,children:[(0,W.jsxs)(`span`,{className:`doc-badge`,children:[(0,W.jsx)(de,{size:12}),`接口文档`]}),i&&(0,W.jsx)(`span`,{className:`api-status-badge api-status-${i}`,children:O[i]}),t.tags.map(e=>(0,W.jsx)(`span`,{className:`tag-badge`,children:e},e))]}),(0,W.jsxs)(`div`,{className:`endpoint-bar`,children:[(0,W.jsx)(`span`,{className:`method method-${t.method}`,children:t.method.toUpperCase()}),(0,W.jsx)(`code`,{children:t.path}),(0,W.jsx)(Zu,{value:t.path,label:`复制路径`,iconOnly:!0})]}),(0,W.jsx)(Xu,{children:r.description}),r.externalDocs&&(0,W.jsxs)(`a`,{className:`external-doc-link`,href:r.externalDocs.url,target:`_blank`,rel:`noreferrer`,children:[r.externalDocs.description||`相关文档`,(0,W.jsx)(le,{size:13})]}),t.servers.length>0&&(0,W.jsxs)(`div`,{className:`server-line`,children:[(0,W.jsx)(ce,{size:13}),(0,W.jsx)(`span`,{children:`服务地址`}),t.servers.map((e,t)=>(0,W.jsx)(`code`,{children:e.url},t))]})]}),(0,W.jsx)(ed,{id:`authentication`,title:`身份认证`,children:(0,W.jsx)(ld,{document:e,operation:t})}),(0,W.jsx)(ed,{id:`parameters`,title:`请求参数`,badge:(0,W.jsx)(`span`,{className:`count-badge`,children:t.parameters.length}),children:s.length?s.map(t=>(0,W.jsxs)(`div`,{className:`parameter-group`,children:[(0,W.jsxs)(`h3`,{children:[(0,W.jsx)(`span`,{children:t.location[0].toUpperCase()+t.location.slice(1)}),` 参数`,` `,(0,W.jsx)(`span`,{className:`muted`,children:t.values.length})]}),(0,W.jsx)(Y,{document:e,parameters:t.values})]},t.location)):(0,W.jsx)(`div`,{className:`empty-note`,children:`该接口未定义 Path / Query / Header / Cookie 参数`})}),(0,W.jsx)(ed,{id:`request`,title:`请求体与示例`,badge:a.required?(0,W.jsx)(`span`,{className:`required`,children:`必填`}):void 0,children:r.requestBody?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Xu,{children:a.description}),(0,W.jsx)(J,{document:e,content:a.content||{},operation:t})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`helper-text`,children:`该接口未定义请求体。以下为根据接口定义生成的请求模板。`}),(0,W.jsx)(Qu,{value:We(e,t),label:`cURL · 请求模板`,copyLabel:`复制 cURL`}),(0,W.jsx)(`p`,{className:`helper-text`,children:`请按实际部署替换相对服务地址及花括号中的参数与凭据。`})]})}),(0,W.jsx)(ed,{id:`responses`,title:`返回响应`,subtitle:`状态码、响应模型与原始示例`,children:(0,W.jsx)(ud,{document:e,operation:t})}),(0,W.jsx)(ed,{id:`policies`,title:`操作策略`,subtitle:`保留扩展字段原名,便于对照契约`,children:(0,W.jsx)(md,{definition:r})}),(0,W.jsxs)(`div`,{className:`end-note`,children:[(0,W.jsx)(E,{size:15}),`已展示该接口的全部主要定义`,(0,W.jsxs)(`span`,{children:[`OpenAPI `,e.openapi]})]})]})}(0,Se.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(x.StrictMode,{children:(0,W.jsx)(ad,{})}))})();
|
|
43
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Tc(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Rl.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Jl(){return{exit:{taskListCheckValueChecked:Xl,taskListCheckValueUnchecked:Xl,paragraph:Zl}}}function Yl(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Ql}}}function Xl(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Zl(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Ql(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Rl.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function $l(){return[Hs(),fc(),_c(),zl(),Jl()]}function eu(e){return{extensions:[Us(),pc(e),vc(),ql(e),Yl()]}}var tu={tokenize:mu,partial:!0},nu={tokenize:hu,partial:!0},ru={tokenize:gu,partial:!0},iu={tokenize:_u,partial:!0},G={tokenize:vu,partial:!0},au={name:`wwwAutolink`,tokenize:fu,previous:yu},ou={name:`protocolAutolink`,tokenize:pu,previous:bu},su={name:`emailAutolink`,tokenize:du,previous:xu},cu={};function lu(){return{text:cu}}for(var uu=48;uu<123;)cu[uu]=su,uu++,uu===58?uu=65:uu===91&&(uu=97);cu[43]=su,cu[45]=su,cu[46]=su,cu[95]=su,cu[72]=[su,ou],cu[104]=[su,ou],cu[87]=[su,au],cu[119]=[su,au];function du(e,t,n){let r=this,i,a;return o;function o(t){return!Su(t)||!xu.call(r,r.previous)||Cu(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Su(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(G,u,l)(t):t===45||t===95||Vn(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&I(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function fu(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!yu.call(r,r.previous)||Cu(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(tu,e.attempt(nu,e.attempt(ru,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function pu(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&bu.call(r,r.previous)&&!Cu(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(I(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Un(t)||R(t)||Jn(t)||qn(t)?n(t):e.attempt(nu,e.attempt(ru,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function mu(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function hu(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(iu,c,s)(t):t===null||R(t)||Jn(t)||t!==45&&qn(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function gu(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(iu,t,a)(o):o===null||R(o)||Jn(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function _u(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||R(o)||Jn(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||R(e)||Jn(e)?t(e):r(e)}function a(e){return I(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):I(t)?(e.consume(t),o):n(t)}}function vu(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Vn(e)?n(e):t(e)}}function yu(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||R(e)}function bu(e){return!I(e)}function xu(e){return!(e===47||Su(e))}function Su(e){return e===43||e===45||e===46||e===95||Vn(e)}function Cu(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var wu={tokenize:Mu,partial:!0};function Tu(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:ku,continuation:{tokenize:Au},exit:ju}},text:{91:{name:`gfmFootnoteCall`,tokenize:Ou},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Eu,resolveTo:Du}}}}function Eu(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Bn(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Du(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Ou(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||R(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Bn(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return R(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function ku(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||R(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Bn(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return R(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),B(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Au(e,t,n){return e.check(mr,t,e.attempt(wu,t,n))}function ju(e){e.exit(`gfmFootnoteDefinition`)}function Mu(e,t,n){let r=this;return B(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Nu(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Nn(o,o.length,0,sr(s,e.slice(r+1,n),t)),Nn(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Nn(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=or(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=or(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Pu=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Fu(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Fu(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Iu(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Lu(){return{flow:{null:{name:`table`,tokenize:Ru,resolveAll:zu}}}}function Ru(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?ee:c;return a===ee&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):L(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):z(t)?B(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||R(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,z(t)?B(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return z(t)?B(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||L(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return z(t)?B(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||L(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function ee(t){return e.enter(`tableRow`),S(t)}function S(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),S):n===null||L(n)?(e.exit(`tableRow`),t(n)):z(n)?B(e,S,`whitespace`)(n):(e.enter(`data`),C(n))}function C(t){return t===null||t===124||R(t)?(e.exit(`data`),S(t)):(e.consume(t),t===92?w:C)}function w(t){return t===92||t===124?(e.consume(t),C):C(t)}}function zu(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Pu;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Vu(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Bu(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Bu(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Bu(f,t,o,i,n,d)):(o[0]=o[1],d=Bu(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Vu(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Iu(t.events,n))}return e}function Bu(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Hu(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Hu(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Hu(t.events,n[2]),a=Hu(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Hu(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Vu(e,t,n,r,i){let a=[],o=Hu(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Hu(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Uu={name:`tasklistCheck`,tokenize:Gu};function Wu(){return{text:{91:Uu}}}function Gu(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return R(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return L(r)?t(r):z(r)?e.check({tokenize:Ku},t,n)(r):n(r)}}function Ku(e,t,n){return B(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function qu(e){return In([lu(),Tu(),Nu(e),Lu(),Wu()])}var Ju={};function Yu(e){let t=this,n=e||Ju,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(qu(n)),a.push($l()),o.push(eu(n))}function Xu({children:e}){return e?(0,W.jsx)(`div`,{className:`markdown`,children:(0,W.jsx)(ks,{remarkPlugins:[Yu],components:{a:({node:e,...t})=>(0,W.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`}),img:({src:e,alt:t})=>(0,W.jsxs)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`image-link`,children:[`[图片] `,t||e]})},children:e})}):null}function Zu({value:e,label:t=`复制`,iconOnly:n=!1}){let[r,i]=(0,x.useState)(`idle`),a=(0,x.useRef)(void 0),o=(0,x.useRef)(null),s=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>clearTimeout(a.current),[]),(0,x.useEffect)(()=>{r===`error`&&(o.current?.showModal(),s.current?.focus(),s.current?.select())},[r]);async function c(){clearTimeout(a.current);let t=!1;try{navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{}if(!t){let n=document.activeElement,r=document.createElement(`textarea`);r.value=e,r.style.position=`fixed`,r.style.top=`0`,r.style.left=`0`,r.style.opacity=`0`,document.body.append(r);try{r.focus({preventScroll:!0}),r.select(),t=document.execCommand(`copy`)}catch{}finally{r.remove(),n?.focus({preventScroll:!0})}}i(t?`copied`:`error`),t&&(a.current=setTimeout(()=>i(`idle`),2200))}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{type:`button`,className:`copy-button ${n?`icon-only`:``}`,onClick:c,title:t,"aria-label":t,children:[r===`copied`?(0,W.jsx)(E,{size:14}):(0,W.jsx)(oe,{size:14}),(!n||r!==`idle`)&&(0,W.jsx)(`span`,{role:`status`,children:r===`copied`?`已复制`:r===`error`?`复制失败`:t})]}),r===`error`&&(0,W.jsxs)(`dialog`,{ref:o,className:`copy-dialog`,"aria-label":`手动复制`,onClose:()=>i(`idle`),children:[(0,W.jsx)(`h2`,{children:`手动复制`}),(0,W.jsx)(`p`,{children:`浏览器未允许自动复制。请选择下方文本,按 ⌘C / Ctrl+C 复制。`}),(0,W.jsx)(`textarea`,{ref:s,"aria-label":`待复制文本`,readOnly:!0,value:e}),(0,W.jsx)(`button`,{className:`primary-button`,onClick:()=>o.current?.close(),children:`关闭`})]})]})}function Qu({value:e,label:t=`JSON`,copyLabel:n}){let r=e.split(/("(?:\\.|[^"\\])*"\s*:|"(?:\\.|[^"\\])*"|\b(?:true|false|null)\b|-?\b\d+(?:\.\d+)?\b)/g);return(0,W.jsxs)(`div`,{className:`code-block`,children:[(0,W.jsxs)(`div`,{className:`code-toolbar`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(ue,{size:14}),` `,t]}),(0,W.jsx)(Zu,{value:e,label:n||`复制示例`})]}),(0,W.jsx)(`pre`,{tabIndex:0,children:(0,W.jsx)(`code`,{children:r.map((e,t)=>(0,W.jsx)(`span`,{className:e.startsWith(`"`)?e.endsWith(`:`)?`code-key`:`code-string`:/^(true|false|null|-?\d)/.test(e)?`code-value`:void 0,children:e},t))})})]})}function $u(e){return typeof e==`string`?e:JSON.stringify(e)}function K({document:e,schema:t}){return(0,W.jsxs)(`div`,{className:`schema-table`,role:`table`,"aria-label":`数据模型字段`,children:[(0,W.jsxs)(`div`,{className:`schema-head`,role:`row`,children:[(0,W.jsx)(`span`,{role:`columnheader`,children:`字段名称`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`类型`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`必填`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`说明与约束`})]}),(0,W.jsx)(q,{document:e,schema:t,name:`根节点`,depth:0,required:!1,initialOpen:!0})]})}function q({document:e,schema:t,name:n,required:r,depth:i,initialOpen:a=!1}){let[o,s]=(0,x.useState)(a),c=Fe(e,t),l=we(c.schema),u=c.references[0],d=c.recursiveReferences.length>0,f=i>=32?[]:Le(e,c.schema),p=ze(e,c.schema),m=Be(e,c.schema),h=u?decodeURIComponent(u.split(`/`).at(-1)).replace(/~1/g,`/`).replace(/~0/g,`~`):void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`schema-row ${i===0?`schema-root`:``}`,role:`row`,children:[(0,W.jsxs)(`div`,{role:`cell`,className:`field-name`,style:{paddingLeft:Math.min(i,6)*16+12},children:[f.length?(0,W.jsx)(`button`,{type:`button`,className:`expand-field`,onClick:()=>s(!o),"aria-expanded":o,"aria-label":`${o?`收起`:`展开`} ${n}`,children:(0,W.jsx)(ne,{size:14,className:o?`rotated`:``})}):(0,W.jsx)(`span`,{className:`field-spacer`}),(0,W.jsx)(`code`,{title:n,children:n})]}),(0,W.jsxs)(`div`,{role:`cell`,className:`field-type`,children:[(0,W.jsx)(`code`,{children:Ie(e,c.schema)}),h&&(0,W.jsxs)(`span`,{title:u,children:[`↗ `,h]})]}),(0,W.jsx)(`div`,{role:`cell`,children:r?(0,W.jsx)(`span`,{className:`required`,children:`必填`}):(0,W.jsx)(`span`,{className:`optional`,children:`—`})}),(0,W.jsxs)(`div`,{role:`cell`,className:`field-description`,children:[l.title&&(0,W.jsx)(`strong`,{children:l.title}),(0,W.jsx)(Xu,{children:l.description}),d&&(0,W.jsxs)(`span`,{className:`reference-note`,children:[`递归引用 · `,c.recursiveReferences.join(`、`)]}),i>=32&&(0,W.jsx)(`span`,{className:`reference-note`,children:`已达到展示深度上限`}),m.length>0&&(0,W.jsx)(`div`,{className:`constraint-summary`,children:m.map(([e,t])=>(0,W.jsxs)(`span`,{children:[e,`:`,(0,W.jsx)(`code`,{children:$u(t)})]},e))}),p.length>0&&(0,W.jsxs)(`details`,{className:`constraint-details`,children:[(0,W.jsx)(`summary`,{children:`详细校验规则`}),(0,W.jsx)(`div`,{className:`constraints`,children:p.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{children:[e,`:`]}),(0,W.jsx)(`code`,{children:$u(t)})]},e))})]}),c.combinationConstraints.length>0&&(0,W.jsxs)(`details`,{className:`constraint-details`,children:[(0,W.jsx)(`summary`,{children:`组合约束`}),c.notices.map(e=>(0,W.jsx)(`p`,{children:e},e)),(0,W.jsx)(`div`,{className:`constraints`,children:c.combinationConstraints.map((e,t)=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{children:[`来源 `,t+1,`:`]}),(0,W.jsx)(`code`,{children:JSON.stringify(e,null,2)})]},t))})]}),!l.title&&!l.description&&!p.length&&!d&&!c.notices.length&&(0,W.jsx)(`span`,{className:`muted`,children:`—`})]})]}),o&&f.map((t,n)=>(0,W.jsx)(q,{...t,document:e,depth:i+1},`${t.name}-${n}`))]})}function J({document:e,content:t,operation:n}){let r=Object.keys(t),[i,a]=(0,x.useState)(r[0]||``),[o,s]=(0,x.useState)(0),[c,l]=(0,x.useState)(`example`),u=r.includes(i)?i:r[0],d=A(e,t[u]),f=Ve(e,d),p=f[o]??f[0],m=p&&k(p,`value`);return(0,W.jsxs)(`div`,{className:`media-panel`,children:[r.length>0&&(0,W.jsxs)(`div`,{className:`media-controls`,children:[(0,W.jsxs)(`label`,{children:[`媒体类型`,(0,W.jsx)(`select`,{"aria-label":n?`请求媒体类型`:`响应媒体类型`,value:u,onChange:e=>{a(e.target.value),s(0)},children:r.map(e=>(0,W.jsx)(`option`,{children:e},e))})]}),(0,W.jsx)(`span`,{className:`source-note`,children:`以契约定义为准`})]}),k(d,`schema`)&&(0,W.jsx)(K,{document:e,schema:d.schema}),d.encoding&&(0,W.jsx)(X,{title:`编码规则 · encoding`,value:d.encoding}),(0,W.jsxs)(`div`,{className:`example-heading`,children:[(0,W.jsxs)(`div`,{className:`small-tabs`,children:[(0,W.jsx)(`button`,{type:`button`,className:c===`example`?`active`:``,onClick:()=>l(`example`),children:`原始示例`}),n&&(0,W.jsx)(`button`,{type:`button`,className:c===`curl`?`active`:``,onClick:()=>l(`curl`),children:`cURL`})]}),f.length>0&&(0,W.jsx)(`select`,{"aria-label":n?`请求示例`:`响应示例`,value:Math.min(o,f.length-1),onChange:e=>s(Number(e.target.value)),children:f.map((e,t)=>(0,W.jsx)(`option`,{value:t,children:e.name},t))})]}),c===`curl`&&n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Qu,{label:`cURL · 请求模板`,copyLabel:`复制 cURL`,value:We(e,n,u,p)}),(0,W.jsx)(`p`,{className:`helper-text`,children:`使用契约中的服务地址;相对地址及花括号占位符需按实际部署和凭据替换。此处仅复制,不发送请求。`})]}):(0,W.jsxs)(W.Fragment,{children:[p?.description&&(0,W.jsx)(Xu,{children:p.description}),m?(0,W.jsx)(Qu,{value:He(p.value,u),label:u||`原始示例`}):p?.externalValue?(0,W.jsxs)(`div`,{className:`empty-note`,children:[(0,W.jsx)(ge,{size:16}),(0,W.jsxs)(`span`,{children:[`契约使用外部示例(未加载):`,(0,W.jsx)(`code`,{children:p.externalValue})]})]}):(0,W.jsxs)(`div`,{className:`empty-note`,children:[(0,W.jsx)(ue,{size:17}),(0,W.jsx)(`span`,{children:`契约未提供原始示例`})]})]})]})}function Y({document:e,parameters:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`schema-table`,role:`table`,"aria-label":`参数字段`,children:[(0,W.jsxs)(`div`,{className:`schema-head`,role:`row`,children:[(0,W.jsx)(`span`,{role:`columnheader`,children:`参数名称`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`类型`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`必填`}),(0,W.jsx)(`span`,{role:`columnheader`,children:`说明与约束`})]}),t.map(t=>(0,W.jsx)(q,{document:e,name:t.name,required:t.in===`path`||!!t.required,depth:0,schema:{allOf:[t.schema??Object.values(we(t.content))[0]?.schema,{...t.description?{description:t.description}:{},...t.deprecated?{deprecated:!0}:{}}]}},`${t.in}:${t.name}`))]}),t.map(t=>(0,W.jsxs)(`div`,{children:[[`style`,`explode`,`allowEmptyValue`,`allowReserved`].some(e=>k(t,e))&&(0,W.jsxs)(`div`,{className:`parameter-serialization`,children:[(0,W.jsx)(`code`,{children:t.name}),[`style`,`explode`,`allowEmptyValue`,`allowReserved`].filter(e=>k(t,e)).map(e=>(0,W.jsxs)(`span`,{children:[e,`: `,(0,W.jsx)(`code`,{children:String(t[e])})]},e))]}),(k(t,`example`)||t.examples)&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsxs)(`summary`,{children:[t.name,` · 参数示例`]}),(0,W.jsx)(J,{document:e,content:{"application/json":t}})]}),t.content&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsxs)(`summary`,{children:[t.name,` · 参数内容`]}),(0,W.jsx)(J,{document:e,content:t.content})]})]},t.name))]})}function X({title:e,value:t}){return(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:e}),(0,W.jsx)(Qu,{value:He(t)})]})}function ed({id:e,title:t,subtitle:n,children:r,badge:i}){return(0,W.jsxs)(`section`,{id:e,className:`doc-section`,children:[(0,W.jsxs)(`div`,{className:`section-heading`,children:[(0,W.jsx)(`h2`,{children:t}),i,n&&(0,W.jsx)(`span`,{children:n})]}),r]})}var td=()=>new Set([]),nd=[me,be,se,he,ce,ie,de,pe],rd=[[`introduction`,`文档概览`],[`quickstart`,`开始使用`],[`groups`,`接口分组`],[`conventions`,`通用约定`]],id=[[`description`,`接口说明`],[`authentication`,`身份认证`],[`parameters`,`请求参数`],[`request`,`请求体与示例`],[`responses`,`返回响应`],[`policies`,`操作策略`]];function ad(){let[e,t]=(0,x.useState)(window.location.hash);(0,x.useEffect)(()=>{let e=()=>t(window.location.hash);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let n=Ge(Ce)?Ce:void 0,r=qe(e,n?.modules),i=n?.modules.find(e=>e.id===r.moduleId),a=n?i?.document??{info:{title:n.title},paths:{}}:Ce;return(0,W.jsx)(od,{document:a,title:n?.title??a.info.title,modules:n?.modules,moduleId:i?.id,route:r})}function od({document:e,title:t,modules:n,moduleId:r,route:i}){let a=(0,x.useMemo)(()=>j(e),[e]),o=(0,x.useMemo)(()=>De(e,a),[e,a]),s=Ke(r??n?.[0]?.id),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(td),[m,h]=(0,x.useState)(td),[g,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(`introduction`),[b,ee]=(0,x.useState)(()=>window.matchMedia(`(max-width: 800px)`).matches),S=(0,x.useRef)(null),E=!i.invalid&&(!n||r!==void 0)?a.find(e=>e.id===i.operationId):void 0,oe=i.invalid||!!n&&r===void 0||i.operationId!==void 0&&!E,se=oe?[]:E?id:rd,ce=(0,x.useMemo)(()=>n?n.map(e=>{let t=j(e.document);return{moduleId:e.id,document:e.document,operations:t,tags:De(e.document,t)}}):[{moduleId:void 0,document:e,operations:a,tags:o}],[n,e,a,o]),le=(0,x.useMemo)(()=>ce.map(e=>({...e,operations:e.operations.filter(t=>Ae(t,c,u,n?`${e.moduleId} ${e.document.info.title}`:``))})),[ce,c,u,n]),ue=ce.reduce((e,t)=>e+t.operations.length,0),fe=le.reduce((e,t)=>e+t.operations.length,0),pe=!!c.trim()||!!u;(0,x.useEffect)(()=>{let e=window.matchMedia(`(max-width: 800px)`),t=()=>ee(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,x.useEffect)(()=>{let e=()=>{_(!1),window.scrollTo(0,0),window.document.getElementById(`main`)?.focus({preventScroll:!0})};window.addEventListener(`hashchange`,e);let t=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),_(!0),S.current?.focus()),e.key===`Escape`&&_(!1)};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`keydown`,t)}},[]),(0,x.useEffect)(()=>{window.document.title=E?`${E.definition.summary||E.path} · ${e.info.title}`:`${e.info.title} · API 文档`,E&&(n?h(e=>new Set([...e].filter(e=>!E.tags.some(t=>e===JSON.stringify([r,t]))))):p(e=>new Set([...e,...E.tags])))},[E,e,n,r]),(0,x.useEffect)(()=>{let e=0,t=()=>{let e=(window.document.querySelector(`.topbar`)?.getBoundingClientRect().height||66)+32,t=se[0]?.[0]||``;for(let[n]of se){let r=window.document.getElementById(n);r&&r.getBoundingClientRect().top<=e&&(t=n)}window.scrollY>0&&window.innerHeight+window.scrollY>=window.document.documentElement.scrollHeight-2&&(t=se.at(-1)?.[0]||t),y(t)},n=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(t)};return t(),window.addEventListener(`scroll`,n,{passive:!0}),window.addEventListener(`resize`,n),()=>{cancelAnimationFrame(e),window.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n)}},[E,oe,e]),(0,x.useEffect)(()=>{if(!g)return;let e=window.document.body.style.overflow;window.matchMedia(`(max-width: 800px)`).matches&&(window.document.body.style.overflow=`hidden`);let t=window.document.querySelector(`.sidebar`),n=e=>{if(e.key!==`Tab`||!window.matchMedia(`(max-width: 800px)`).matches||!t)return;let n=[...t.querySelectorAll(`button, a, input, select`)].filter(e=>e.offsetParent!==null),r=n[0],i=n.at(-1);e.shiftKey&&window.document.activeElement===r&&(e.preventDefault(),i?.focus()),!e.shiftKey&&window.document.activeElement===i&&(e.preventDefault(),r?.focus())};return S.current?.focus(),window.addEventListener(`keydown`,n),()=>{window.document.body.style.overflow=e,window.removeEventListener(`keydown`,n),t?.contains(window.document.activeElement)&&window.document.querySelector(`.mobile-menu`)?.focus()}},[g]);function me(e,t){let r=n?JSON.stringify([t,e]):e;(n?h:p)(e=>{let t=new Set(e);return t.has(r)?t.delete(r):t.add(r),t})}function ge(e){l(``),d(``),n?h(t=>{let n=new Set(t);return n.delete(JSON.stringify([r,e])),n}):p(t=>new Set(t).add(e));let t=a.find(t=>t.tags.includes(e));t&&(window.location.hash=Oe(t,r))}function Se(){let t=URL.createObjectURL(new Blob([He(e)],{type:`application/json`})),n=window.document.createElement(`a`);n.href=t,n.download=r===void 0?`openapi.json`:`openapi-${encodeURIComponent(r)}.json`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1e3)}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`a`,{className:`skip-link`,href:`#main`,onClick:e=>{e.preventDefault(),window.document.getElementById(`main`)?.focus({preventScroll:!0})},children:`跳转到正文`}),(0,W.jsxs)(`header`,{className:`topbar`,children:[(0,W.jsx)(`button`,{className:`mobile-menu icon-button`,"aria-label":`打开接口目录`,onClick:()=>_(!0),children:(0,W.jsx)(ve,{size:21})}),(0,W.jsxs)(`a`,{className:`brand`,href:s,children:[(0,W.jsx)(`span`,{className:`brand-symbol`,children:(0,W.jsx)(ie,{size:23,strokeWidth:2.5})}),(0,W.jsx)(`span`,{className:`brand-name`,title:t,children:t})]}),(0,W.jsxs)(`nav`,{className:`top-nav`,"aria-label":`主导航`,children:[(0,W.jsx)(`a`,{className:`active`,href:s,children:`API 文档`}),(0,W.jsxs)(`button`,{onClick:Se,disabled:!!n&&r===void 0,title:n?`导出当前模块:${e.info.title}`:void 0,children:[(0,W.jsx)(C,{size:15}),` 导出 OpenAPI`]})]}),(0,W.jsxs)(`div`,{className:`header-right`,children:[(0,W.jsxs)(`span`,{className:`version-pill`,children:[(0,W.jsx)(`span`,{}),e.info.version||`未指定版本`]}),(0,W.jsx)(`a`,{className:`help-link`,href:s,"aria-label":`文档概览`,children:(0,W.jsx)(re,{size:19})})]})]}),g&&(0,W.jsx)(`button`,{className:`drawer-backdrop`,"aria-label":`关闭接口目录`,onClick:()=>_(!1)}),(0,W.jsxs)(`aside`,{className:`sidebar ${g?`drawer-open`:``}`,"aria-label":`接口目录`,inert:b&&!g,children:[(0,W.jsxs)(`div`,{className:`sidebar-tools`,children:[(0,W.jsxs)(`div`,{className:`workspace-label`,children:[(0,W.jsx)(`span`,{className:`workspace-icon`,children:(0,W.jsx)(he,{size:17})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:t}),(0,W.jsx)(`span`,{children:n?`${n.length} 个模块 · ${ue} 个接口`:`接口参考手册`})]}),(0,W.jsx)(`button`,{className:`close-drawer icon-button`,onClick:()=>_(!1),"aria-label":`关闭目录`,children:(0,W.jsx)(xe,{size:19})}),(0,W.jsx)(te,{size:14,className:`desktop-chevron`})]}),n&&(0,W.jsx)(`p`,{className:`search-scope`,children:`搜索范围:全部模块`}),(0,W.jsxs)(`div`,{className:`search-box`,children:[(0,W.jsx)(ye,{size:16}),(0,W.jsx)(`input`,{ref:S,"aria-label":`搜索接口`,placeholder:n?`搜索全部模块、接口或路径`:`搜索接口、路径或关键词`,value:c,onChange:e=>l(e.target.value)}),c?(0,W.jsx)(`button`,{className:`icon-button`,"aria-label":`清空搜索`,onClick:()=>l(``),children:(0,W.jsx)(xe,{size:14})}):(0,W.jsxs)(`kbd`,{children:[(0,W.jsx)(ae,{size:10}),` K`]})]}),(0,W.jsxs)(`div`,{className:`method-filter`,children:[(0,W.jsx)(_e,{size:13}),(0,W.jsxs)(`select`,{"aria-label":`筛选请求方法`,value:u,onChange:e=>d(e.target.value),children:[(0,W.jsx)(`option`,{value:``,children:`全部请求方法`}),D.map(e=>(0,W.jsx)(`option`,{value:e,children:e.toUpperCase()},e))]}),(0,W.jsxs)(`span`,{children:[fe,` 个接口`]})]})]}),(0,W.jsxs)(`nav`,{className:`sidebar-scroll`,"aria-label":`接口分组`,children:[!n&&(0,W.jsxs)(`a`,{className:`overview-link ${!E&&!oe?`selected`:``}`,href:s,onClick:()=>_(!1),children:[(0,W.jsx)(T,{size:17}),`文档概览`,(0,W.jsx)(ne,{size:14})]}),(0,W.jsxs)(`div`,{className:`nav-caption`,children:[`接口目录 `,(0,W.jsx)(`span`,{children:n?`${n.length} 个模块`:`${o.length} 个分组`})]}),le.map(e=>{if(pe&&!e.operations.length)return null;let t=(0,W.jsx)(sd,{tags:e.tags,operations:e.operations,moduleId:e.moduleId,selected:r===e.moduleId?E:void 0,isOpen:t=>pe||(n?!m.has(JSON.stringify([e.moduleId,t])):f.has(t)),filtering:pe,onToggle:t=>me(t,e.moduleId),onNavigate:()=>_(!1)});return n?(0,W.jsxs)(`section`,{className:`module-group`,"aria-label":`模块 ${e.moduleId} · ${e.document.info.title}`,children:[(0,W.jsxs)(`a`,{className:`module-heading ${r===e.moduleId?`current-module`:``}`,href:Ke(e.moduleId),"aria-current":r===e.moduleId&&!E&&!oe?`page`:void 0,"aria-label":`模块概览:${e.moduleId} · ${e.document.info.title}`,onClick:()=>_(!1),children:[(0,W.jsx)(he,{size:16}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.document.info.title}),(0,W.jsx)(`small`,{title:e.moduleId,children:e.moduleId})]}),(0,W.jsx)(`span`,{className:`group-count`,children:e.operations.length})]}),t,!e.operations.length&&(0,W.jsx)(`div`,{className:`module-empty`,children:`该模块暂无接口定义`})]},e.moduleId):(0,W.jsx)(`div`,{children:t},`single`)}),ue===0?(0,W.jsxs)(`div`,{className:`search-empty`,children:[(0,W.jsx)(de,{size:25}),(0,W.jsx)(`strong`,{children:n?`当前项目暂无接口定义`:`当前契约暂无接口定义`})]}):fe===0&&(0,W.jsxs)(`div`,{className:`search-empty`,children:[(0,W.jsx)(ye,{size:25}),(0,W.jsx)(`strong`,{children:`没有找到相关接口`}),(0,W.jsx)(`span`,{children:`试试其他关键词或请求方法`}),(0,W.jsx)(`button`,{onClick:()=>{l(``),d(``)},children:`清除筛选`})]})]}),(0,W.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,W.jsx)(`span`,{className:`status-dot`}),`契约驱动 · 静态文档`,(0,W.jsxs)(`span`,{children:[`OAS `,e.openapi]})]})]}),(0,W.jsxs)(`div`,{className:`page-shell`,children:[(0,W.jsxs)(`main`,{id:`main`,tabIndex:-1,children:[(0,W.jsxs)(`div`,{className:`breadcrumb`,children:[(0,W.jsx)(`span`,{children:`开发者文档`}),(0,W.jsx)(ne,{size:13}),(0,W.jsx)(`span`,{children:`API 文档`}),n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ne,{size:13}),(0,W.jsx)(`span`,{children:r??`无效模块`})]}),E&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ne,{size:13}),(0,W.jsx)(`span`,{children:E.tags[0]})]})]}),oe?(0,W.jsxs)(`div`,{className:`not-found`,children:[(0,W.jsx)(de,{size:40}),(0,W.jsx)(`h1`,{children:n&&r===void 0?`未找到该模块`:`未找到该接口`}),(0,W.jsxs)(`p`,{children:[`链接无效,或对应的`,n&&r===void 0?`模块`:`接口`,`已在契约更新后移除。`]}),(0,W.jsxs)(`a`,{href:s,children:[`返回文档概览 `,(0,W.jsx)(w,{size:15})]})]}):E?(0,W.jsx)(hd,{document:e,operation:E,moduleId:r},JSON.stringify([r,E.id])):(0,W.jsx)(cd,{document:e,operations:a,tags:o,moduleId:r,onOpenTag:ge,onDownload:Se},r),(0,W.jsxs)(`footer`,{className:`page-footer`,children:[(0,W.jsxs)(`span`,{children:[e.info.title,` · API Reference`]}),(0,W.jsxs)(`span`,{children:[`基于 OpenAPI `,e.openapi,(0,W.jsx)(`span`,{className:`footer-dot`,children:`·`}),`版本 `,e.info.version||`未指定`]})]})]}),(0,W.jsxs)(`aside`,{className:`page-outline`,"aria-label":`本页目录`,children:[(0,W.jsx)(`span`,{children:`本页目录`}),se.map(([e,t])=>(0,W.jsx)(`button`,{className:v===e?`current`:``,"aria-current":v===e?`location`:void 0,onClick:()=>window.document.getElementById(e)?.scrollIntoView({behavior:`smooth`}),children:t},e)),(0,W.jsxs)(`div`,{className:`outline-note`,children:[(0,W.jsx)(be,{size:19}),(0,W.jsx)(`strong`,{children:`以接口契约为准`}),(0,W.jsx)(`p`,{children:`字段、示例与操作策略均来自当前版本的 API 契约。`})]})]})]})]})}function sd({tags:e,operations:t,moduleId:n,selected:r,isOpen:i,filtering:a,onToggle:o,onNavigate:s}){return e.map(e=>{let c=t.filter(t=>t.tags.includes(e));if(a&&!c.length)return null;let l=i(e);return(0,W.jsxs)(`div`,{className:`nav-group`,children:[(0,W.jsxs)(`button`,{className:`group-toggle`,onClick:()=>o(e),"aria-expanded":l,children:[(0,W.jsx)(ne,{size:13,className:l?`rotated`:``}),(0,W.jsx)(fe,{size:15}),(0,W.jsx)(`span`,{title:e,children:e}),(0,W.jsx)(`span`,{className:`group-count`,children:c.length})]}),l&&(0,W.jsx)(`div`,{className:`group-operations`,children:c.map(e=>{let t=Te(e.definition);return(0,W.jsxs)(`a`,{href:Oe(e,n),className:`operation-link ${r?.id===e.id?`selected`:``}`,onClick:s,"aria-current":r?.id===e.id?`page`:void 0,title:`${e.method.toUpperCase()} ${e.path}`,children:[(0,W.jsx)(`span`,{className:`method method-${e.method}`,children:e.method.toUpperCase()}),(0,W.jsx)(`span`,{className:`operation-link-title`,children:e.definition.summary||e.path}),t&&(0,W.jsx)(`span`,{className:`api-status-dot api-status-${t}`,role:`img`,"aria-label":`接口状态:${O[t]}`,title:`接口状态:${O[t]}`})]},e.id)})})]},e)})}function cd({document:e,operations:t,tags:n,moduleId:r,onOpenTag:i,onDownload:a}){let o=t[0];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{id:`introduction`,className:`overview-hero`,children:[(0,W.jsxs)(`div`,{className:`eyebrow`,children:[(0,W.jsx)(`span`,{}),` API REFERENCE `,(0,W.jsx)(`span`,{className:`hero-badge`,children:`中文文档`})]}),(0,W.jsxs)(`h1`,{children:[e.info.title,(0,W.jsx)(`span`,{className:`heading-mark`,children:`.`})]}),e.info.summary&&(0,W.jsx)(`p`,{className:`hero-lead`,children:e.info.summary}),(0,W.jsx)(Xu,{children:e.info.description}),(0,W.jsxs)(`div`,{className:`hero-actions`,children:[(0,W.jsxs)(`button`,{className:`primary-button`,disabled:!t.length,onClick:()=>o&&i(o.tags[0]),children:[(0,W.jsx)(T,{size:16}),`浏览接口`,(0,W.jsx)(w,{size:16})]}),(0,W.jsxs)(`button`,{className:`secondary-button`,onClick:a,children:[(0,W.jsx)(C,{size:16}),`导出 OpenAPI`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(E,{size:13}),` YAML / JSON 契约`]})]})]}),(0,W.jsxs)(`div`,{className:`stats-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`stat-icon purple`,children:(0,W.jsx)(ie,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[t.length,(0,W.jsx)(`small`,{children:`个`})]}),(0,W.jsx)(`span`,{children:`接口定义`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`stat-icon blue`,children:(0,W.jsx)(fe,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[n.length,(0,W.jsx)(`small`,{children:`个`})]}),(0,W.jsx)(`span`,{children:`接口分组`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`stat-icon green`,children:(0,W.jsx)(be,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.openapi}),(0,W.jsx)(`span`,{children:`OpenAPI 规范`})]})]})]}),(0,W.jsx)(ed,{id:`quickstart`,title:`开始使用`,subtitle:`三步了解你的第一个接口`,children:(0,W.jsxs)(`div`,{className:`getting-started`,children:[(0,W.jsxs)(`div`,{className:`start-steps`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`01`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`找到需要的接口`}),(0,W.jsx)(`p`,{children:`按业务目录浏览,或使用关键词与请求方法筛选。`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`02`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`了解参数与鉴权`}),(0,W.jsx)(`p`,{children:`查看字段约束、身份凭据及接口的操作策略。`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`03`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`复制示例,开始集成`}),(0,W.jsx)(`p`,{children:`使用原始示例或 cURL 模板,替换实际服务地址。`})]})]})]}),(0,W.jsxs)(`div`,{className:`start-example`,children:[(0,W.jsxs)(`div`,{className:`example-caption`,children:[(0,W.jsx)(`span`,{className:`status-dot`}),o?`从第一个接口开始`:`接口示例`]}),o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Qu,{value:We(e,o),label:`cURL`,copyLabel:`复制 cURL`}),(0,W.jsxs)(`a`,{href:Oe(o,r),children:[`查看 `,o.definition.summary||o.path,(0,W.jsx)(w,{size:14})]})]}):(0,W.jsx)(`p`,{children:`当前契约暂无接口定义。`})]})]})}),(0,W.jsx)(ed,{id:`groups`,title:`接口分组`,subtitle:`按业务领域探索全部能力`,badge:(0,W.jsx)(`span`,{className:`count-badge`,children:n.length}),children:(0,W.jsx)(`div`,{className:`group-cards`,children:n.map((n,r)=>{let a=nd[r%nd.length],o=t.filter(e=>e.tags.includes(n)).length,s=(e.tags||[]).find(e=>e.name===n);return(0,W.jsxs)(`div`,{className:`group-card`,children:[(0,W.jsx)(`span`,{className:`group-card-icon tone-${r%4}`,children:(0,W.jsx)(a,{size:21})}),(0,W.jsxs)(`div`,{className:`group-card-copy`,children:[(0,W.jsx)(`button`,{className:`group-card-title`,onClick:()=>i(n),disabled:!o,children:n}),(0,W.jsx)(Xu,{children:s?.description||`查看该分组的接口定义`}),(0,W.jsxs)(`small`,{children:[o,` 个接口`]})]}),(0,W.jsx)(w,{size:16})]},n)})})}),(0,W.jsxs)(ed,{id:`conventions`,title:`通用约定`,children:[(0,W.jsxs)(`div`,{className:`convention-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(ce,{size:20}),(0,W.jsx)(`h3`,{children:`服务地址`}),(e.servers||[]).length?e.servers.map((e,t)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`code`,{children:e.url}),(0,W.jsx)(Xu,{children:e.description}),e.variables&&(0,W.jsx)(X,{title:`服务地址变量`,value:e.variables})]},t)):(0,W.jsx)(`p`,{children:`契约未指定服务地址,请使用实际部署地址。`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(be,{size:20}),(0,W.jsx)(`h3`,{children:`身份与权限`}),(0,W.jsx)(`p`,{children:`每个接口单独展示鉴权方式、权限范围、限流与审计要求。公开接口会标记为「无需鉴权」。`})]})]}),e[`x-contract-status`]&&(0,W.jsxs)(`div`,{className:`info-callout`,children:[(0,W.jsx)(re,{size:17}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`契约与实际可用范围`}),(0,W.jsx)(`p`,{children:`当前契约状态如下,接口实际可用范围请结合后端实现和部署确认。`}),(0,W.jsx)(X,{title:`契约状态 · x-contract-status`,value:e[`x-contract-status`]})]})]})]})]})}function ld({document:e,operation:t}){let n=t.definition.security??e.security??[];return n.length?(0,W.jsxs)(`div`,{className:`authentication`,children:[(0,W.jsx)(`p`,{className:`helper-text`,children:`以下方案满足任意一组即可;同组内的凭据需要同时提供。`}),n.map((t,n)=>(0,W.jsxs)(`div`,{className:`auth-option`,children:[(0,W.jsxs)(`span`,{className:`auth-option-label`,children:[`方案 `,n+1]}),Object.keys(t).length===0?(0,W.jsx)(`span`,{children:`允许匿名访问`}):Object.entries(t).map(([t,n])=>{let r=A(e,e.components?.securitySchemes?.[t]);return(0,W.jsxs)(`div`,{className:`auth-scheme`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(me,{size:15}),(0,W.jsx)(`strong`,{children:t}),(0,W.jsxs)(`code`,{children:[r.type||`未定义`,r.scheme?` / ${r.scheme}`:``]})]}),(0,W.jsx)(Xu,{children:r.description}),r.name&&(0,W.jsxs)(`p`,{children:[`传入位置:`,(0,W.jsx)(`code`,{children:r.in}),` · 参数名:`,(0,W.jsx)(`code`,{children:r.name})]}),r.bearerFormat&&(0,W.jsxs)(`p`,{children:[`凭据格式:`,(0,W.jsx)(`code`,{children:r.bearerFormat})]}),n.length>0&&(0,W.jsxs)(`p`,{children:[`所需范围:`,(0,W.jsx)(`code`,{children:n.join(`, `)})]}),r.flows&&(0,W.jsx)(X,{title:`OAuth 流程 · flows`,value:r.flows}),r.openIdConnectUrl&&(0,W.jsxs)(`p`,{children:[`发现地址:`,(0,W.jsx)(`code`,{children:r.openIdConnectUrl})]})]},t)})]},n))]}):(0,W.jsxs)(`div`,{className:`auth-public`,children:[(0,W.jsx)(be,{size:18}),(0,W.jsx)(`strong`,{children:`无需鉴权`}),(0,W.jsx)(`span`,{children:`该接口未要求身份凭据`})]})}function ud({document:e,operation:t}){let n=we(t.definition.responses),r=Object.keys(n),[i,a]=(0,x.useState)(r[0]),o=A(e,n[i]),s=Object.entries(we(o.headers)).map(([t,n])=>({...A(e,n),name:t,in:`header`}));return r.length?(0,W.jsxs)(`div`,{className:`response-panel`,children:[(0,W.jsx)(`div`,{className:`status-tabs`,role:`tablist`,"aria-label":`响应状态码`,children:r.map(e=>(0,W.jsxs)(`button`,{role:`tab`,"aria-selected":i===e,className:i===e?`active`:``,onClick:()=>a(e),children:[(0,W.jsx)(`span`,{className:`response-dot ${/^[23]/.test(e)?`success`:/^[45]/.test(e)?`error`:``}`}),e]},e))}),(0,W.jsxs)(`div`,{role:`tabpanel`,"aria-label":`${i} 响应`,children:[(0,W.jsxs)(`div`,{className:`response-description`,children:[(0,W.jsx)(`span`,{className:`response-code ${/^[23]/.test(i)?`success`:``}`,children:i}),(0,W.jsx)(Xu,{children:o.description})]}),s.length>0&&(0,W.jsxs)(`details`,{className:`response-headers`,children:[(0,W.jsxs)(`summary`,{children:[`响应头 `,(0,W.jsx)(`span`,{children:s.length})]}),(0,W.jsx)(Y,{document:e,parameters:s})]}),o.content&&Object.keys(o.content).length?(0,W.jsx)(J,{document:e,content:o.content},i):(0,W.jsx)(`div`,{className:`empty-note`,children:`该响应未定义响应体`}),o.links&&(0,W.jsx)(X,{title:`关联接口 · links`,value:o.links})]},i)]}):(0,W.jsx)(`div`,{className:`empty-note`,children:`契约未定义响应`})}var dd={"x-permissions":`访问权限`,"x-rate-limit":`请求限流`,"x-idempotency":`幂等策略`,"x-audit":`审计要求`,"x-sensitive-fields":`敏感字段`,"x-design-status":`设计状态`},fd={permission:`权限标识`,roles:`允许角色`,scope:`作用范围`,window_seconds:`窗口秒数`,principal_limit:`主体请求上限`,ip_limit:`IP 请求上限`,key:`限流键`,failure_policy:`失败策略`,shared_across_sessions:`跨会话共享`,required:`是否必需`,retention:`保留策略`,conflict:`冲突处理`,recovery:`恢复方式`,reason_required:`是否需要原因`,events:`审计事件`,secrets:`凭据处理`,request_or_response:`涉及字段`,logging:`日志规则`};function pd(e){return e===!0?`是`:e===!1?`否`:e===null?`空值`:Array.isArray(e)&&e.length===0?`无`:typeof e==`object`?JSON.stringify(e,null,2):String(e)}function md({definition:e}){let t=Object.entries(e).filter(([e])=>e.startsWith(`x-`)&&e!==`x-api-status`);return t.length?(0,W.jsx)(`div`,{className:`policy-grid`,children:t.map(([e,t])=>(0,W.jsxs)(`details`,{className:`policy-card`,open:e!==`x-design-status`,children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsx)(`span`,{children:dd[e]||`扩展说明`}),(0,W.jsx)(`code`,{children:e}),(0,W.jsx)(te,{size:14})]}),typeof t==`object`&&t&&!Array.isArray(t)?(0,W.jsx)(`dl`,{children:Object.entries(t).map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`dt`,{children:[fd[e]||e,(0,W.jsx)(`code`,{children:e})]}),(0,W.jsx)(`dd`,{children:pd(t)})]},e))}):(0,W.jsx)(`p`,{children:pd(t)})]},e))}):(0,W.jsx)(`div`,{className:`empty-note`,children:`契约未定义扩展操作策略`})}function hd({document:e,operation:t,moduleId:n}){let r=t.definition,i=Te(r),a=A(e,r.requestBody),o=new URL(Oe(t,n),window.location.href).href,s=[`path`,`query`,`header`,`cookie`].map(e=>({location:e,values:t.parameters.filter(t=>t.in===e)})).filter(e=>e.values.length);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{id:`description`,className:`operation-header`,children:[(0,W.jsxs)(`div`,{className:`eyebrow`,children:[t.tags[0],(0,W.jsx)(ne,{size:12}),(0,W.jsx)(`span`,{children:r.operationId||`接口详情`})]}),(0,W.jsxs)(`div`,{className:`title-row`,children:[(0,W.jsx)(`h1`,{children:r.summary||t.path}),(0,W.jsx)(Zu,{value:o,label:`复制链接`})]}),(0,W.jsxs)(`div`,{className:`operation-badges`,children:[(0,W.jsxs)(`span`,{className:`doc-badge`,children:[(0,W.jsx)(de,{size:12}),`接口文档`]}),i&&(0,W.jsx)(`span`,{className:`api-status-badge api-status-${i}`,children:O[i]}),t.tags.map(e=>(0,W.jsx)(`span`,{className:`tag-badge`,children:e},e))]}),(0,W.jsxs)(`div`,{className:`endpoint-bar`,children:[(0,W.jsx)(`span`,{className:`method method-${t.method}`,children:t.method.toUpperCase()}),(0,W.jsx)(`code`,{children:t.path}),(0,W.jsx)(Zu,{value:t.path,label:`复制路径`,iconOnly:!0})]}),(0,W.jsx)(Xu,{children:r.description}),r.externalDocs&&(0,W.jsxs)(`a`,{className:`external-doc-link`,href:r.externalDocs.url,target:`_blank`,rel:`noreferrer`,children:[r.externalDocs.description||`相关文档`,(0,W.jsx)(le,{size:13})]}),t.servers.length>0&&(0,W.jsxs)(`div`,{className:`server-line`,children:[(0,W.jsx)(ce,{size:13}),(0,W.jsx)(`span`,{children:`服务地址`}),t.servers.map((e,t)=>(0,W.jsx)(`code`,{children:e.url},t))]})]}),(0,W.jsx)(ed,{id:`authentication`,title:`身份认证`,children:(0,W.jsx)(ld,{document:e,operation:t})}),(0,W.jsx)(ed,{id:`parameters`,title:`请求参数`,badge:(0,W.jsx)(`span`,{className:`count-badge`,children:t.parameters.length}),children:s.length?s.map(t=>(0,W.jsxs)(`div`,{className:`parameter-group`,children:[(0,W.jsxs)(`h3`,{children:[(0,W.jsx)(`span`,{children:t.location[0].toUpperCase()+t.location.slice(1)}),` 参数`,` `,(0,W.jsx)(`span`,{className:`muted`,children:t.values.length})]}),(0,W.jsx)(Y,{document:e,parameters:t.values})]},t.location)):(0,W.jsx)(`div`,{className:`empty-note`,children:`该接口未定义 Path / Query / Header / Cookie 参数`})}),(0,W.jsx)(ed,{id:`request`,title:`请求体与示例`,badge:a.required?(0,W.jsx)(`span`,{className:`required`,children:`必填`}):void 0,children:r.requestBody?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Xu,{children:a.description}),(0,W.jsx)(J,{document:e,content:a.content||{},operation:t})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`helper-text`,children:`该接口未定义请求体。以下为根据接口定义生成的请求模板。`}),(0,W.jsx)(Qu,{value:We(e,t),label:`cURL · 请求模板`,copyLabel:`复制 cURL`}),(0,W.jsx)(`p`,{className:`helper-text`,children:`请按实际部署替换相对服务地址及花括号中的参数与凭据。`})]})}),(0,W.jsx)(ed,{id:`responses`,title:`返回响应`,subtitle:`状态码、响应模型与原始示例`,children:(0,W.jsx)(ud,{document:e,operation:t})}),(0,W.jsx)(ed,{id:`policies`,title:`操作策略`,subtitle:`保留扩展字段原名,便于对照契约`,children:(0,W.jsx)(md,{definition:r})}),(0,W.jsxs)(`div`,{className:`end-note`,children:[(0,W.jsx)(E,{size:15}),`已展示该接口的全部主要定义`,(0,W.jsxs)(`span`,{children:[`OpenAPI `,e.openapi]})]})]})}(0,Se.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(x.StrictMode,{children:(0,W.jsx)(ad,{})}))})();
|
package/lib/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { lstat, mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import $RefParser, { getJsonSchemaRefParserDefaultOptions } from "@apidevtools/json-schema-ref-parser";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { homedir } from "node:os";
|
|
7
8
|
// src/lib/openapi.ts
|
|
8
9
|
var pointerEscape = (value) => value.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
9
10
|
// build/references.ts
|
|
@@ -309,8 +310,132 @@ async function generate(input, destination) {
|
|
|
309
310
|
if (temporary) await rm(temporary, { force: true });
|
|
310
311
|
}
|
|
311
312
|
}
|
|
313
|
+
// build/skills.ts
|
|
314
|
+
var skillAgents = [
|
|
315
|
+
"codex",
|
|
316
|
+
"claude",
|
|
317
|
+
"opencode"
|
|
318
|
+
];
|
|
319
|
+
var skillHelp = `用法:specleaf install skill [选项]
|
|
320
|
+
|
|
321
|
+
安装随包提供的 specleaf skill,默认面向 Codex、Claude Code 和 OpenCode。
|
|
322
|
+
默认安装到调用目录;--global 安装到用户目录。安装过程无需联网。
|
|
323
|
+
Codex 与 OpenCode 共用 .agents/skills/specleaf,Claude Code 使用 .claude/skills/specleaf。
|
|
324
|
+
|
|
325
|
+
选项:
|
|
326
|
+
--agent <名称> 选择 codex、claude、opencode 或 all;可重复或用逗号分隔
|
|
327
|
+
-g, --global 安装到用户目录,供所有项目使用
|
|
328
|
+
--force 替换内容不同的 skill 文件,保留其他文件
|
|
329
|
+
-h, --help 显示帮助
|
|
330
|
+
`;
|
|
331
|
+
function parseSkillArguments(args) {
|
|
332
|
+
const options = {
|
|
333
|
+
agents: [],
|
|
334
|
+
global: false,
|
|
335
|
+
force: false
|
|
336
|
+
};
|
|
337
|
+
for (let index = 0; index < args.length; index++) {
|
|
338
|
+
const argument = args[index];
|
|
339
|
+
if (argument === "--help" || argument === "-h") return {
|
|
340
|
+
...options,
|
|
341
|
+
help: true
|
|
342
|
+
};
|
|
343
|
+
if (argument === "--global" || argument === "-g") options.global = true;
|
|
344
|
+
else if (argument === "--force") options.force = true;
|
|
345
|
+
else if (argument === "--agent" || argument.startsWith("--agent=")) {
|
|
346
|
+
const value = argument === "--agent" ? args[++index] : argument.slice(8);
|
|
347
|
+
if (!value || value.startsWith("-")) throw new Error("--agent 缺少工具名称。");
|
|
348
|
+
for (const name of value.split(",").map((name) => name.trim())) if (name === "all") options.agents.push(...skillAgents);
|
|
349
|
+
else if (skillAgents.includes(name)) options.agents.push(name);
|
|
350
|
+
else throw new Error(`未知工具:${name || "(空)"}。支持 codex、claude、opencode 或 all。`);
|
|
351
|
+
} else throw new Error(`未知 skill 安装参数:${argument}`);
|
|
352
|
+
}
|
|
353
|
+
options.agents = options.agents.length ? [...new Set(options.agents)] : [...skillAgents];
|
|
354
|
+
return options;
|
|
355
|
+
}
|
|
356
|
+
var skillDirectories = {
|
|
357
|
+
codex: ".agents",
|
|
358
|
+
claude: ".claude",
|
|
359
|
+
opencode: ".agents"
|
|
360
|
+
};
|
|
361
|
+
var statIfPresent = (path) => lstat(path).catch((error) => {
|
|
362
|
+
if (error.code !== "ENOENT") throw error;
|
|
363
|
+
});
|
|
364
|
+
async function readSkillFiles(directory, prefix = "") {
|
|
365
|
+
const files = /* @__PURE__ */ new Map();
|
|
366
|
+
const entries = await readdir(join(directory, prefix), { withFileTypes: true });
|
|
367
|
+
for (const entry of entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
368
|
+
const path = join(prefix, entry.name);
|
|
369
|
+
if (entry.isDirectory()) for (const [name, content] of await readSkillFiles(directory, path)) files.set(name, content);
|
|
370
|
+
else if (entry.isFile()) files.set(path, await readFile(join(directory, path)));
|
|
371
|
+
else throw new Error(`skill 资源必须为普通文件或目录:${join(directory, path)}`);
|
|
372
|
+
}
|
|
373
|
+
return files;
|
|
374
|
+
}
|
|
375
|
+
async function checkDirectories(base, relative) {
|
|
376
|
+
let path = base;
|
|
377
|
+
for (const part of relative.split(sep)) {
|
|
378
|
+
if (!part || part === ".") continue;
|
|
379
|
+
path = join(path, part);
|
|
380
|
+
const existing = await statIfPresent(path);
|
|
381
|
+
if (existing && (!existing.isDirectory() || existing.isSymbolicLink())) throw new Error(`skill 安装目录不能是符号链接或非目录:${path}`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
async function installSkill(options, context) {
|
|
385
|
+
const files = await readSkillFiles(fileURLToPath(new URL("../skills/specleaf/", import.meta.url)));
|
|
386
|
+
const { version } = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
387
|
+
files.set("specleaf.json", Buffer.from(`${JSON.stringify({ version }, null, 2)}\n`));
|
|
388
|
+
const base = resolve(options.global ? context.homeDirectory ?? homedir() : context.cwd);
|
|
389
|
+
const targets = /* @__PURE__ */ new Map();
|
|
390
|
+
for (const agent of options.agents) {
|
|
391
|
+
const relative = join(skillDirectories[agent], "skills", "specleaf");
|
|
392
|
+
targets.set(relative, [...targets.get(relative) ?? [], agent]);
|
|
393
|
+
}
|
|
394
|
+
const plans = [];
|
|
395
|
+
for (const [relative, agents] of targets) {
|
|
396
|
+
await checkDirectories(base, relative);
|
|
397
|
+
const directory = join(base, relative);
|
|
398
|
+
const changes = [];
|
|
399
|
+
let hasFiles = false;
|
|
400
|
+
for (const [name, content] of files) {
|
|
401
|
+
await checkDirectories(base, join(relative, dirname(name)));
|
|
402
|
+
const path = join(directory, name);
|
|
403
|
+
const existing = await statIfPresent(path);
|
|
404
|
+
if (existing) {
|
|
405
|
+
if (!existing.isFile() || existing.isSymbolicLink()) throw new Error(`skill 文件不能是符号链接或非普通文件:${path}`);
|
|
406
|
+
hasFiles = true;
|
|
407
|
+
if ((await readFile(path)).equals(content)) continue;
|
|
408
|
+
if (!options.force) throw new Error(`已有 skill 文件内容不同:${path}\n使用 --force 替换 skill 文件;其他文件会保留。`);
|
|
409
|
+
}
|
|
410
|
+
changes.push({
|
|
411
|
+
path,
|
|
412
|
+
content
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
plans.push({
|
|
416
|
+
result: {
|
|
417
|
+
agents,
|
|
418
|
+
directory,
|
|
419
|
+
status: changes.length ? hasFiles ? "updated" : "installed" : "unchanged"
|
|
420
|
+
},
|
|
421
|
+
changes
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
for (const { changes } of plans) for (const { path, content } of changes) {
|
|
425
|
+
await mkdir(dirname(path), { recursive: true });
|
|
426
|
+
const temporary = join(dirname(path), `.${basename(path)}.${randomUUID()}.tmp`);
|
|
427
|
+
try {
|
|
428
|
+
await writeFile(temporary, content, { flag: "wx" });
|
|
429
|
+
await rename(temporary, path);
|
|
430
|
+
} finally {
|
|
431
|
+
await rm(temporary, { force: true });
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return plans.map(({ result }) => result);
|
|
435
|
+
}
|
|
312
436
|
// build/cli.ts
|
|
313
437
|
var help = `用法:specleaf <input> [-o <output.html>]
|
|
438
|
+
specleaf install skill [--agent <名称>] [--global] [--force]
|
|
314
439
|
|
|
315
440
|
把本地 OpenAPI 3.0 / 3.1 YAML / JSON 文件或模块目录转为单个离线 HTML。
|
|
316
441
|
目录递归发现 openapi.yaml、openapi.yml、openapi.json,各模块独立浏览。
|
|
@@ -320,6 +445,8 @@ var help = `用法:specleaf <input> [-o <output.html>]
|
|
|
320
445
|
-o, --output <文件> 指定输出文件
|
|
321
446
|
-h, --help 显示帮助
|
|
322
447
|
-v, --version 显示版本
|
|
448
|
+
|
|
449
|
+
运行 specleaf install skill --help 查看 Codex、Claude Code、OpenCode 的 skill 安装用法。
|
|
323
450
|
`;
|
|
324
451
|
function parseArguments(args) {
|
|
325
452
|
let input;
|
|
@@ -357,15 +484,30 @@ function parseArguments(args) {
|
|
|
357
484
|
};
|
|
358
485
|
}
|
|
359
486
|
try {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const
|
|
364
|
-
process.stdout.write(
|
|
487
|
+
const argv = process.argv.slice(2);
|
|
488
|
+
const cwd = fileURLToPath(import.meta.url) === resolve(projectRoot, "build/cli.ts") && process.env.npm_lifecycle_event === "generate" ? process.env.INIT_CWD || process.cwd() : process.cwd();
|
|
489
|
+
if (argv[0] === "install" && argv[1] === "skill") {
|
|
490
|
+
const options = parseSkillArguments(argv.slice(2));
|
|
491
|
+
if (options.help) process.stdout.write(skillHelp);
|
|
492
|
+
else {
|
|
493
|
+
const labels = {
|
|
494
|
+
installed: "已安装",
|
|
495
|
+
updated: "已更新",
|
|
496
|
+
unchanged: "已是相同内容,跳过"
|
|
497
|
+
};
|
|
498
|
+
for (const result of await installSkill(options, { cwd })) process.stdout.write(`${labels[result.status]} specleaf skill(${result.agents.join("、")}):${result.directory}\n`);
|
|
499
|
+
process.stdout.write("可在对应工具的下一轮会话中使用 specleaf skill;若未显示,请重新打开会话。\n");
|
|
500
|
+
}
|
|
365
501
|
} else {
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
502
|
+
const args = parseArguments(argv);
|
|
503
|
+
if (args.help) process.stdout.write(help);
|
|
504
|
+
else if (args.version) {
|
|
505
|
+
const { version } = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
506
|
+
process.stdout.write(`${version}\n`);
|
|
507
|
+
} else {
|
|
508
|
+
const output = await generate(contractEntry(cwd, args.input), resolve(cwd, args.output));
|
|
509
|
+
process.stdout.write(`已生成离线 HTML:${output}\n`);
|
|
510
|
+
}
|
|
369
511
|
}
|
|
370
512
|
} catch (error) {
|
|
371
513
|
process.stderr.write(`错误:${error.message}\n运行 specleaf --help 查看用法。\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specleaf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "将本地 OpenAPI 3.0 / 3.1 YAML / JSON 文件或模块目录转为按模块分组、离线阅读的单文件 HTML 文档。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"lib/cli.js",
|
|
20
20
|
"lib/assets/",
|
|
21
|
+
"skills/specleaf/",
|
|
21
22
|
"README.md",
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: specleaf
|
|
3
|
+
description: 将本地 OpenAPI 契约生成为 SpecLeaf 单文件离线 HTML 文档。用于生成、更新、汇总 API 文档,或诊断 SpecLeaf 生成失败。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SpecLeaf
|
|
7
|
+
|
|
8
|
+
将现有 OpenAPI 3.0 / 3.1 YAML / JSON 文件或模块目录转换为可离线阅读的 HTML。沿用项目现有契约,生成时保持入口及引用文件只读。
|
|
9
|
+
|
|
10
|
+
## 选择输入和输出
|
|
11
|
+
|
|
12
|
+
- 优先使用用户指定路径,其次检查项目已有文档命令和约定,再在相关目录中寻找入口。区分包含 `openapi`、`info`、`paths` 的契约与被引用的模型片段。存在多个无明确关系的候选时,澄清生成范围。
|
|
13
|
+
- 单个契约使用文件输入;汇总多个模块使用其公共目录。目录模式递归识别准确命名的 `openapi.yaml`、`openapi.yml`、`openapi.json`,同一目录只能有一个入口。跳过隐藏目录、`node_modules`、`dist`、`build`、`coverage` 及目录符号链接。
|
|
14
|
+
- 各模块保留独立版本、服务地址、鉴权和引用作用域;无需手动合并契约或重命名同名模型。
|
|
15
|
+
- 输出遵循用户路径或项目约定;没有约定时可用 `./openapi.html`,显式传入 `-o`。已有文件时确认它是本任务要更新的产物,避免覆盖无关文件。
|
|
16
|
+
|
|
17
|
+
## 调用 CLI
|
|
18
|
+
|
|
19
|
+
需要 Node.js 22.19.0+。优先复用项目已有文档命令或已安装的 `specleaf`:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
specleaf "./docs/apis" -o "./docs/api.html"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
输入、输出相对调用目录解析;`$ref` 相对包含它的文件解析。不要切换到 skill 目录执行生成。
|
|
26
|
+
|
|
27
|
+
若只有项目内安装的 CLI,可通过 `npm exec --offline -- specleaf` 调用。若 CLI 不可用,读取本 skill 同目录安装记录 `specleaf.json` 的 `version`,用该版本执行 `npx --yes specleaf@版本 输入 -o 输出`,替换其中的版本和路径。没有安装记录时,先核实可用版本。获取 npm 包可能需要联网,应遵循当前环境的网络权限;包与依赖齐备后,本地生成无需联网。
|
|
28
|
+
|
|
29
|
+
## 处理失败
|
|
30
|
+
|
|
31
|
+
- 缺失引用:根据报错的来源文件和 JSON Pointer 检查相对路径、目标文件和目标字段。
|
|
32
|
+
- 重复入口:报告具体目录及候选入口,不擅自删除或重命名契约。
|
|
33
|
+
- 无模块入口:检查范围和入口命名,避免将模型目录作为模块集合。
|
|
34
|
+
- 远程入口、远程 `$ref`、Swagger 2.0 不受支持;说明限制和所需的本地 OpenAPI 3.0 / 3.1 输入。
|
|
35
|
+
- 输出与入口或引用文件冲突时更换输出路径。修复契约内容应属于用户请求的范围,不能为生成成功编造接口、字段或示例。
|
|
36
|
+
|
|
37
|
+
## 验收与交付
|
|
38
|
+
|
|
39
|
+
确认命令退出码为零、输出 HTML 存在且非空。需要浏览器验收且环境具备条件时,检查标题、搜索和接口导航;只在实际验证后报告这些结果。
|
|
40
|
+
|
|
41
|
+
交付 HTML 文件链接、输入范围、使用版本和可复现命令。产物包含脚本、样式和契约,可以单独复制并在浏览器离线打开。页面仅供阅读,不执行接口请求。生成成功表示完成解析与渲染,不代表完整的 OpenAPI / JSON Schema 语义校验。
|