flavor-code 1.2.11 → 1.2.14

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.
Files changed (139) hide show
  1. package/README.md +39 -35
  2. package/README.zh-CN.md +39 -35
  3. package/dist/{app-MXWPZBEU.js → app-UJAGMKD5.js} +6 -4
  4. package/dist/astgraph/db.mjs +237 -0
  5. package/dist/astgraph/extract.mjs +239 -0
  6. package/dist/astgraph/flavor-plugin.json +25 -0
  7. package/dist/astgraph/grammars.mjs +68 -0
  8. package/dist/astgraph/index.js +301 -0
  9. package/dist/astgraph/indexer.mjs +175 -0
  10. package/dist/astgraph/query.mjs +165 -0
  11. package/dist/astgraph/resolve.mjs +93 -0
  12. package/dist/astgraph/vendor/tree-sitter-javascript.wasm +0 -0
  13. package/dist/astgraph/vendor/tree-sitter-tsx.wasm +0 -0
  14. package/dist/astgraph/vendor/tree-sitter-typescript.wasm +0 -0
  15. package/dist/astgraph/vendor/tree-sitter.js +3980 -0
  16. package/dist/astgraph/vendor/tree-sitter.wasm +0 -0
  17. package/dist/astgraph/vendor/zod/LICENSE +21 -0
  18. package/dist/astgraph/vendor/zod/index.js +4 -0
  19. package/dist/astgraph/vendor/zod/locales/index.js +1 -0
  20. package/dist/astgraph/vendor/zod/locales/package.json +7 -0
  21. package/dist/astgraph/vendor/zod/package.json +135 -0
  22. package/dist/astgraph/vendor/zod/v4/classic/checks.js +1 -0
  23. package/dist/astgraph/vendor/zod/v4/classic/coerce.js +17 -0
  24. package/dist/astgraph/vendor/zod/v4/classic/compat.js +31 -0
  25. package/dist/astgraph/vendor/zod/v4/classic/errors.js +48 -0
  26. package/dist/astgraph/vendor/zod/v4/classic/external.js +20 -0
  27. package/dist/astgraph/vendor/zod/v4/classic/from-json-schema.js +599 -0
  28. package/dist/astgraph/vendor/zod/v4/classic/index.js +4 -0
  29. package/dist/astgraph/vendor/zod/v4/classic/iso.js +30 -0
  30. package/dist/astgraph/vendor/zod/v4/classic/package.json +7 -0
  31. package/dist/astgraph/vendor/zod/v4/classic/parse.js +15 -0
  32. package/dist/astgraph/vendor/zod/v4/classic/schemas.js +1395 -0
  33. package/dist/astgraph/vendor/zod/v4/core/api.js +1087 -0
  34. package/dist/astgraph/vendor/zod/v4/core/checks.js +575 -0
  35. package/dist/astgraph/vendor/zod/v4/core/core.js +78 -0
  36. package/dist/astgraph/vendor/zod/v4/core/doc.js +35 -0
  37. package/dist/astgraph/vendor/zod/v4/core/errors.js +185 -0
  38. package/dist/astgraph/vendor/zod/v4/core/index.js +16 -0
  39. package/dist/astgraph/vendor/zod/v4/core/json-schema-generator.js +95 -0
  40. package/dist/astgraph/vendor/zod/v4/core/json-schema-processors.js +601 -0
  41. package/dist/astgraph/vendor/zod/v4/core/json-schema.js +1 -0
  42. package/dist/astgraph/vendor/zod/v4/core/package.json +7 -0
  43. package/dist/astgraph/vendor/zod/v4/core/parse.js +93 -0
  44. package/dist/astgraph/vendor/zod/v4/core/regexes.js +139 -0
  45. package/dist/astgraph/vendor/zod/v4/core/registries.js +51 -0
  46. package/dist/astgraph/vendor/zod/v4/core/schemas.js +2239 -0
  47. package/dist/astgraph/vendor/zod/v4/core/standard-schema.js +1 -0
  48. package/dist/astgraph/vendor/zod/v4/core/to-json-schema.js +448 -0
  49. package/dist/astgraph/vendor/zod/v4/core/util.js +674 -0
  50. package/dist/astgraph/vendor/zod/v4/core/versions.js +5 -0
  51. package/dist/astgraph/vendor/zod/v4/index.js +3 -0
  52. package/dist/astgraph/vendor/zod/v4/locales/ar.js +106 -0
  53. package/dist/astgraph/vendor/zod/v4/locales/az.js +105 -0
  54. package/dist/astgraph/vendor/zod/v4/locales/be.js +156 -0
  55. package/dist/astgraph/vendor/zod/v4/locales/bg.js +120 -0
  56. package/dist/astgraph/vendor/zod/v4/locales/ca.js +107 -0
  57. package/dist/astgraph/vendor/zod/v4/locales/cs.js +111 -0
  58. package/dist/astgraph/vendor/zod/v4/locales/da.js +115 -0
  59. package/dist/astgraph/vendor/zod/v4/locales/de.js +108 -0
  60. package/dist/astgraph/vendor/zod/v4/locales/el.js +109 -0
  61. package/dist/astgraph/vendor/zod/v4/locales/en.js +113 -0
  62. package/dist/astgraph/vendor/zod/v4/locales/eo.js +109 -0
  63. package/dist/astgraph/vendor/zod/v4/locales/es.js +132 -0
  64. package/dist/astgraph/vendor/zod/v4/locales/fa.js +114 -0
  65. package/dist/astgraph/vendor/zod/v4/locales/fi.js +112 -0
  66. package/dist/astgraph/vendor/zod/v4/locales/fr-CA.js +107 -0
  67. package/dist/astgraph/vendor/zod/v4/locales/fr.js +125 -0
  68. package/dist/astgraph/vendor/zod/v4/locales/he.js +214 -0
  69. package/dist/astgraph/vendor/zod/v4/locales/hr.js +122 -0
  70. package/dist/astgraph/vendor/zod/v4/locales/hu.js +108 -0
  71. package/dist/astgraph/vendor/zod/v4/locales/hy.js +147 -0
  72. package/dist/astgraph/vendor/zod/v4/locales/id.js +106 -0
  73. package/dist/astgraph/vendor/zod/v4/locales/index.js +52 -0
  74. package/dist/astgraph/vendor/zod/v4/locales/is.js +109 -0
  75. package/dist/astgraph/vendor/zod/v4/locales/it.js +108 -0
  76. package/dist/astgraph/vendor/zod/v4/locales/ja.js +107 -0
  77. package/dist/astgraph/vendor/zod/v4/locales/ka.js +112 -0
  78. package/dist/astgraph/vendor/zod/v4/locales/kh.js +5 -0
  79. package/dist/astgraph/vendor/zod/v4/locales/km.js +110 -0
  80. package/dist/astgraph/vendor/zod/v4/locales/ko.js +111 -0
  81. package/dist/astgraph/vendor/zod/v4/locales/lt.js +203 -0
  82. package/dist/astgraph/vendor/zod/v4/locales/mk.js +109 -0
  83. package/dist/astgraph/vendor/zod/v4/locales/ms.js +107 -0
  84. package/dist/astgraph/vendor/zod/v4/locales/nl.js +110 -0
  85. package/dist/astgraph/vendor/zod/v4/locales/no.js +108 -0
  86. package/dist/astgraph/vendor/zod/v4/locales/ota.js +109 -0
  87. package/dist/astgraph/vendor/zod/v4/locales/package.json +7 -0
  88. package/dist/astgraph/vendor/zod/v4/locales/pl.js +109 -0
  89. package/dist/astgraph/vendor/zod/v4/locales/ps.js +114 -0
  90. package/dist/astgraph/vendor/zod/v4/locales/pt.js +108 -0
  91. package/dist/astgraph/vendor/zod/v4/locales/ro.js +119 -0
  92. package/dist/astgraph/vendor/zod/v4/locales/ru.js +156 -0
  93. package/dist/astgraph/vendor/zod/v4/locales/sl.js +109 -0
  94. package/dist/astgraph/vendor/zod/v4/locales/sv.js +110 -0
  95. package/dist/astgraph/vendor/zod/v4/locales/ta.js +110 -0
  96. package/dist/astgraph/vendor/zod/v4/locales/th.js +110 -0
  97. package/dist/astgraph/vendor/zod/v4/locales/tr.js +105 -0
  98. package/dist/astgraph/vendor/zod/v4/locales/ua.js +5 -0
  99. package/dist/astgraph/vendor/zod/v4/locales/uk.js +108 -0
  100. package/dist/astgraph/vendor/zod/v4/locales/ur.js +110 -0
  101. package/dist/astgraph/vendor/zod/v4/locales/uz.js +110 -0
  102. package/dist/astgraph/vendor/zod/v4/locales/vi.js +108 -0
  103. package/dist/astgraph/vendor/zod/v4/locales/yo.js +107 -0
  104. package/dist/astgraph/vendor/zod/v4/locales/zh-CN.js +109 -0
  105. package/dist/astgraph/vendor/zod/v4/locales/zh-TW.js +107 -0
  106. package/dist/astgraph/vendor/zod/v4/mini/checks.js +1 -0
  107. package/dist/astgraph/vendor/zod/v4/mini/coerce.js +22 -0
  108. package/dist/astgraph/vendor/zod/v4/mini/external.js +14 -0
  109. package/dist/astgraph/vendor/zod/v4/mini/index.js +3 -0
  110. package/dist/astgraph/vendor/zod/v4/mini/iso.js +34 -0
  111. package/dist/astgraph/vendor/zod/v4/mini/package.json +7 -0
  112. package/dist/astgraph/vendor/zod/v4/mini/parse.js +1 -0
  113. package/dist/astgraph/vendor/zod/v4/mini/schemas.js +961 -0
  114. package/dist/astgraph/vendor/zod/v4/package.json +7 -0
  115. package/dist/{chunk-OT5XIN6G.js → chunk-4YXDGGIC.js} +4763 -3763
  116. package/dist/{chunk-XFCJXRJ2.js → chunk-IG4Z23CL.js} +6 -0
  117. package/dist/{chunk-EY6KE7L2.js → chunk-KL6TR2KG.js} +1 -1
  118. package/dist/cli.js +5 -5
  119. package/dist/config/schema.d.ts +6 -0
  120. package/dist/desktop/main.js +5028 -4023
  121. package/dist/desktop-renderer/assets/{index-sgEm4kjf.js → index-CcD0D6x0.js} +2 -2
  122. package/dist/desktop-renderer/index.html +1 -1
  123. package/dist/evolve/loader.d.ts +21 -0
  124. package/dist/evolve/service.d.ts +37 -0
  125. package/dist/evolve/store.d.ts +91 -0
  126. package/dist/hooks/types.d.ts +5 -1
  127. package/dist/init/project.d.ts +8 -0
  128. package/dist/{load-6ZMEBHSG.js → load-GKA7P6RJ.js} +1 -1
  129. package/dist/models/structured.d.ts +14 -0
  130. package/dist/permissions/engine.d.ts +2 -0
  131. package/dist/plugins/host.d.ts +9 -0
  132. package/dist/plugins/types.d.ts +3 -2
  133. package/dist/sdk/index.js +3 -3
  134. package/dist/tools/shell.d.ts +14 -1
  135. package/dist/tools/types.d.ts +2 -0
  136. package/dist/ui/commands.d.ts +5 -2
  137. package/dist/ui/session.d.ts +5 -1
  138. package/package.json +5 -3
  139. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +303 -1
@@ -69,7 +69,7 @@ ${e}</tr>
69
69
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
70
70
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Nt(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Pt(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Nt(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Pt(e);if(i===null)return Nt(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${Nt(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Nt(e.text)}},Ut=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},Wt=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ee,this.options.renderer=this.options.renderer||new Ht,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ut}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`def`:n+=this.renderer.def(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
71
71
  `+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Gt=class{options;block;constructor(e){this.options=e||Ee}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Vt.lex:Vt.lexInline}provideParser(){return this.block?Wt.parse:Wt.parseInline}},Kt=new class{defaults=Te();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Wt;Renderer=Ht;TextRenderer=Ut;Lexer=Vt;Tokenizer=Bt;Hooks=Gt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Ht(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Bt(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Gt;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Gt.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Gt.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Vt.lex(e,t??this.defaults)}parser(e,t){return Wt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?Vt.lex:Vt.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?Wt.parse:Wt.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?Vt.lex:Vt.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Wt.parse:Wt.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
72
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Nt(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function N(e,t){return Kt.parse(e,t)}N.options=N.setOptions=function(e){return Kt.setOptions(e),N.defaults=Kt.defaults,De(N.defaults),N},N.getDefaults=Te,N.defaults=Ee,N.use=function(...e){return Kt.use(...e),N.defaults=Kt.defaults,De(N.defaults),N},N.walkTokens=function(e,t){return Kt.walkTokens(e,t)},N.parseInline=Kt.parseInline,N.Parser=Wt,N.parser=Wt.parse,N.Renderer=Ht,N.TextRenderer=Ut,N.Lexer=Vt,N.lexer=Vt.lex,N.Tokenizer=Bt,N.Hooks=Gt,N.parse=N,N.options,N.setOptions,N.use,N.walkTokens,N.parseInline,Wt.parse,Vt.lex;var qt=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),P=o(((e,t)=>{t.exports=qt()}))();function Jt(e){try{return N.lexer(e,{gfm:!0,async:!1}).filter(e=>e.type!==`html`)}catch{return[{type:`text`,raw:e,text:e}]}}function Yt({text:e}){return(0,P.jsx)(`div`,{className:`markdown-content`,children:(0,_.useMemo)(()=>Jt(e),[e]).map((e,t)=>(0,P.jsx)(Xt,{token:e},`${e.type}-${t}`))})}function Xt({token:e}){if(e.type===`space`)return null;if(e.type===`heading`){let t=e;return(0,P.jsx)(`h${Math.min(6,t.depth)}`,{children:(0,P.jsx)(Zt,{tokens:t.tokens})})}if(e.type===`paragraph`)return(0,P.jsx)(`p`,{children:(0,P.jsx)(Zt,{tokens:e.tokens??[]})});if(e.type===`code`){let t=e;return(0,P.jsxs)(`div`,{className:`markdown-code`,children:[(0,P.jsx)(`span`,{children:t.lang?.trim()||`code`}),(0,P.jsx)(`pre`,{children:(0,P.jsx)(`code`,{children:t.text})})]})}if(e.type===`blockquote`)return(0,P.jsx)(`blockquote`,{children:e.tokens.map((e,t)=>(0,P.jsx)(Xt,{token:e},t))});if(e.type===`list`){let t=e;return(0,P.jsx)(t.ordered?`ol`:`ul`,{start:t.ordered&&typeof t.start==`number`?t.start:void 0,children:t.items.map((e,t)=>(0,P.jsx)(`li`,{children:e.tokens.map((e,t)=>(0,P.jsx)(Xt,{token:e},t))},t))})}if(e.type===`hr`)return(0,P.jsx)(`hr`,{});if(e.type===`table`){let t=e;return(0,P.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsx)(`tr`,{children:t.header.map((e,t)=>(0,P.jsx)(`th`,{style:{textAlign:e.align??void 0},children:(0,P.jsx)(Zt,{tokens:e.tokens})},t))})}),(0,P.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,P.jsx)(`tr`,{children:e.map((e,n)=>(0,P.jsx)(`td`,{style:{textAlign:t.align[n]??void 0},children:(0,P.jsx)(Zt,{tokens:e.tokens})},n))},n))})]})})}return`tokens`in e&&Array.isArray(e.tokens)?(0,P.jsx)(`p`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})}):`text`in e&&typeof e.text==`string`?(0,P.jsx)(`p`,{children:e.text}):null}function Zt({tokens:e}){return(0,P.jsx)(P.Fragment,{children:e.map((e,t)=>(0,P.jsx)(Qt,{token:e},t))})}function Qt({token:e}){if(e.type===`text`){let t=e;return t.tokens?.length?(0,P.jsx)(Zt,{tokens:t.tokens}):t.text}if(e.type===`strong`)return(0,P.jsx)(`strong`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})});if(e.type===`em`)return(0,P.jsx)(`em`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})});if(e.type===`del`)return(0,P.jsx)(`del`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})});if(e.type===`codespan`)return(0,P.jsx)(`code`,{children:e.text});if(e.type===`br`)return(0,P.jsx)(`br`,{});if(e.type===`escape`)return e.text;if(e.type===`link`){let t=e;return(0,P.jsx)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,children:(0,P.jsx)(Zt,{tokens:t.tokens})})}return e.type===`image`?(0,P.jsxs)(`span`,{className:`markdown-image-label`,children:[`[图片:`,e.text,`]`]}):e.type===`html`?null:`text`in e&&typeof e.text==`string`?e.text:null}function $t(e,t,n){let r=new Map;for(let t of e)r.set(t.name,{name:t.name,kind:`command`,description:t.description});for(let e of t)r.has(e)||r.set(e,{name:e,kind:`plugin`});for(let e of n)r.has(e.name)||r.set(e.name,{name:e.name,kind:`skill`,description:e.description,source:e.source});return[...r.values()]}function en(e,t,n){if(n)return 0;let r=[...e];if(r[0]!==`/`)return 0;let i=r.findIndex(e=>/\s/u.test(e)),a=i<0?r.length:i,o=r.slice(1,a).join(``);return t.some(e=>e.name===o)?a:0}function tn(e,t,n,r,i=6){let a=[...e],o=Math.max(0,Math.min(a.length,t));if(a[0]!==`/`)return null;let s=a.findIndex(e=>/\s/u.test(e)),c=s<0?a.length:s;if(o<1||o>c)return null;let l=a.slice(1,c).join(``),u=l.toLowerCase(),d=n.filter(({name:e})=>e.toLowerCase().includes(u)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(u);return n===t.name.toLowerCase().startsWith(u)?e.name.localeCompare(t.name):n?-1:1});if(d.length===0)return null;let f=Math.max(0,Math.min(d.length-1,r)),p=Math.max(1,i);return{query:l,items:d,selectedIndex:f,windowStart:Math.max(0,Math.min(f,d.length-p))}}function nn(e,t,n){return n<=0?0:(e+t+n)%n}function rn(e,t,n){let r=[...e],i=Math.max(0,Math.min(r.length,t)),a=r.slice(i).findIndex(e=>/\s/u.test(e)),o=a<0?r.length:i+a,s=r.slice(o).join(``).replace(/^\s*/u,``),c=`/${n} `;return{text:c+s,cursor:[...c].length}}function an(e,t,n){if(t<=0)return null;let r=[...e],i=Math.min(r.length,t),a=Math.max(i,Math.min(r.length,n)),o=r.slice(i,a).join(``);return/^\s*$/u.test(o)?{text:r.slice(a).join(``),cursor:0}:null}function on(e,t){if(t.length===0)return[];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}return i}var sn={command:`命令`,plugin:`插件`,skill:`技能`},cn={command:`slash-kind-command`,plugin:`slash-kind-plugin`,skill:`slash-kind-skill`};function ln({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`slash-dropdown-backdrop`,onClick:n}),(0,P.jsxs)(`div`,{className:`slash-dropdown`,role:`listbox`,"aria-label":`命令补全`,children:[(0,P.jsxs)(`div`,{className:`slash-dropdown-header`,children:[(0,P.jsx)(`span`,{children:`可用命令`}),(0,P.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,P.jsx)(`kbd`,{children:`Tab 确认`}),(0,P.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,P.jsx)(`div`,{className:`slash-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex,i=on(n.name,e.query);return(0,P.jsxs)(`button`,{className:`slash-item${r?` slash-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n.name)},children:[(0,P.jsx)(`span`,{className:`slash-item-marker`,children:r?`›`:` `}),(0,P.jsx)(`span`,{className:cn[n.kind],children:sn[n.kind]}),(0,P.jsx)(`span`,{className:`slash-item-name`,children:un(n.name,i)}),n.description&&(0,P.jsx)(`span`,{className:`slash-item-desc`,children:n.description})]},n.name)})}),(0,P.jsx)(`div`,{className:`slash-dropdown-footer`,children:e.items.length>6&&(0,P.jsxs)(`span`,{className:`slash-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function un(e,t){if(t.length===0)return(0,P.jsx)(P.Fragment,{children:e});let n=[],r=0;for(let[i,a]of t)i>r&&n.push((0,P.jsx)(`span`,{children:e.slice(r,i)},`text-${r}`)),n.push((0,P.jsx)(`mark`,{children:e.slice(i,a)},`mark-${i}`)),r=a;return r<e.length&&n.push((0,P.jsx)(`span`,{children:e.slice(r)},`text-${r}`)),(0,P.jsx)(P.Fragment,{children:n})}function dn(e,t){if(t.length===0)return(0,P.jsx)(P.Fragment,{children:e});let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}if(i.length===0)return(0,P.jsx)(P.Fragment,{children:e});let o=[],s=0;for(let[t,n]of i)t>s&&o.push((0,P.jsx)(`span`,{children:e.slice(s,t)},`text-${s}`)),o.push((0,P.jsx)(`mark`,{children:e.slice(t,n)},`mark-${t}`)),s=n;return s<e.length&&o.push((0,P.jsx)(`span`,{children:e.slice(s)},`text-${s}`)),(0,P.jsx)(P.Fragment,{children:o})}function fn({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`mention-dropdown-backdrop`,onClick:n}),(0,P.jsxs)(`div`,{className:`mention-dropdown`,role:`listbox`,"aria-label":`文件补全`,children:[(0,P.jsxs)(`div`,{className:`mention-dropdown-header`,children:[(0,P.jsx)(`span`,{children:`项目文件`}),(0,P.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,P.jsx)(`kbd`,{children:`Tab 确认`}),(0,P.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,P.jsx)(`div`,{className:`mention-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex;return(0,P.jsxs)(`button`,{className:`mention-item${r?` mention-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n)},children:[(0,P.jsx)(`span`,{className:`mention-item-marker`,children:r?`›`:` `}),(0,P.jsx)(`span`,{className:`mention-item-icon`,children:`📄`}),(0,P.jsx)(`span`,{className:`mention-item-path`,children:dn(n,e.query)})]},n)})}),(0,P.jsx)(`div`,{className:`mention-dropdown-footer`,children:e.items.length>6&&(0,P.jsxs)(`span`,{className:`mention-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function pn(e){let t=e.replaceAll(`\\`,`/`),n=t.lastIndexOf(`/`);return n<0?e:t.slice(n+1)}function mn(e){return[...new Set(e.map(e=>e.replaceAll(`\\`,`/`)))].sort(Sn)}function hn(e,t,n,r,i=6){let a=vn(e,t);if(a===null)return null;let o=a.query.toLowerCase(),s=n.filter(e=>e.toLowerCase().includes(o)).sort((e,t)=>xn(e,o)-xn(t,o)||Sn(e,t));if(s.length===0)return null;let c=Math.max(0,Math.min(s.length-1,r)),l=Math.max(1,i),u=Math.max(0,Math.min(c,s.length-l));return{query:a.query,items:s,selectedIndex:c,windowStart:u}}function gn(e,t,n){return n<=0?0:(e+t+n)%n}function _n(e,t,n){let r=[...e],i=vn(e,t),a=Math.max(0,Math.min(r.length,t));if(i===null)return{text:e,cursor:a};let o=`@${n.replaceAll(`\\`,`/`).replaceAll(` `,`\\ `)} `,s=r.slice(0,i.start).join(``),c=r.slice(i.end).join(``).replace(/^\s*/u,``);return{text:s+o+c,cursor:[...s+o].length,span:{start:[...s].length,end:[...s+o].length}}}function vn(e,t){let n=[...e],r=Math.max(0,Math.min(n.length,t)),i=r;for(;i>0&&!yn(n,i-1);)--i;if(n[i]!==`@`||r<=i)return null;let a=r;for(;a<n.length&&!yn(n,a);)a+=1;return{start:i,end:a,query:bn(n.slice(i+1,a).join(``))}}function yn(e,t){if(!/\s/u.test(e[t]??``))return!1;let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==0}function bn(e){return e.replace(/\\(\s)/gu,`$1`)}function xn(e,t){let n=e.toLowerCase();return pn(n).startsWith(t)?0:n.startsWith(t)?1:2}function Sn(e,t){return e.localeCompare(t,`en`)}var Cn;function F(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var wn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Tn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Cn=globalThis).__zod_globalConfig??(Cn.__zod_globalConfig={});var En=globalThis.__zod_globalConfig;function Dn(e){return e&&Object.assign(En,e),En}function On(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function kn(e,t){return typeof t==`bigint`?t.toString():t}function An(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function jn(e){return e==null}function Mn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Nn(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Pn=Symbol(`evaluating`);function I(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Pn)return r===void 0&&(r=Pn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function In(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ln(e){return JSON.stringify(e)}function Rn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var zn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Bn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Vn=An(()=>{if(En.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Hn(e){if(Bn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Bn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Un(e){return Hn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Wn=new Set([`string`,`number`,`symbol`]);function Gn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Kn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function qn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Jn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Yn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Kn(e,In(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Fn(this,`shape`,e),e},checks:[]}))}function Xn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Kn(e,In(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Fn(this,`shape`,r),r},checks:[]}))}function Zn(e,t){if(!Hn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Kn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Fn(this,`shape`,n),n}}))}function Qn(e,t){if(!Hn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Kn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Fn(this,`shape`,n),n}}))}function $n(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Kn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Fn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function er(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Kn(t,In(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Fn(this,`shape`,i),i},checks:[]}))}function tr(e,t,n){return Kn(t,In(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Fn(this,`shape`,i),i}}))}function nr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function rr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ir(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ar(e){return typeof e==`string`?e:e?.message}function or(e,t,n){let r=e.message?e.message:ar(e.inst?._zod.def?.error?.(e))??ar(t?.error?.(e))??ar(n.customError?.(e))??ar(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function sr(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function cr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var lr=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,kn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ur=F(`$ZodError`,lr),dr=F(`$ZodError`,lr,{Parent:Error});function fr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function pr(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var mr=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new wn;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>or(e,a,Dn())));throw zn(t,i?.callee),t}return o.value},hr=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>or(e,a,Dn())));throw zn(t,i?.callee),t}return o.value},gr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new wn;return a.issues.length?{success:!1,error:new(e??ur)(a.issues.map(e=>or(e,i,Dn())))}:{success:!0,data:a.value}},_r=gr(dr),vr=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>or(e,i,Dn())))}:{success:!0,data:a.value}},yr=vr(dr),br=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return mr(e)(t,n,i)},xr=e=>(t,n,r)=>mr(e)(t,n,r),Sr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hr(e)(t,n,i)},Cr=e=>async(t,n,r)=>hr(e)(t,n,r),wr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return gr(e)(t,n,i)},Tr=e=>(t,n,r)=>gr(e)(t,n,r),Er=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return vr(e)(t,n,i)},Dr=e=>async(t,n,r)=>vr(e)(t,n,r),Or=/^[cC][0-9a-z]{6,}$/,kr=/^[0-9a-z]+$/,Ar=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jr=/^[0-9a-vA-V]{20}$/,Mr=/^[A-Za-z0-9]{27}$/,Nr=/^[a-zA-Z0-9_-]{21}$/,Pr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ir=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Lr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function zr(){return new RegExp(Rr,`u`)}var Br=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Hr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ur=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gr=/^[A-Za-z0-9_-]*$/,Kr=/^https?$/,qr=/^\+[1-9]\d{6,14}$/,Jr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Yr=RegExp(`^${Jr}$`);function Xr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Zr(e){return RegExp(`^${Xr(e)}$`)}function Qr(e){let t=Xr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Jr}T(?:${r})$`)}var $r=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ei=/^-?\d+$/,ti=/^-?\d+(?:\.\d+)?$/,ni=/^(?:true|false)$/i,ri=/^[^A-Z]*$/,ii=/^[^a-z]*$/,ai=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),oi={number:`number`,bigint:`bigint`,object:`date`},si=F(`$ZodCheckLessThan`,(e,t)=>{ai.init(e,t);let n=oi[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ci=F(`$ZodCheckGreaterThan`,(e,t)=>{ai.init(e,t);let n=oi[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),li=F(`$ZodCheckMultipleOf`,(e,t)=>{ai.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Nn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ui=F(`$ZodCheckNumberFormat`,(e,t)=>{ai.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Jn[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ei)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),di=F(`$ZodCheckMaxLength`,(e,t)=>{var n;ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=sr(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fi=F(`$ZodCheckMinLength`,(e,t)=>{var n;ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=sr(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pi=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=sr(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),mi=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ai.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hi=F(`$ZodCheckRegex`,(e,t)=>{mi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gi=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ri,mi.init(e,t)}),_i=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ii,mi.init(e,t)}),vi=F(`$ZodCheckIncludes`,(e,t)=>{ai.init(e,t);let n=Gn(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),yi=F(`$ZodCheckStartsWith`,(e,t)=>{ai.init(e,t);let n=RegExp(`^${Gn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bi=F(`$ZodCheckEndsWith`,(e,t)=>{ai.init(e,t);let n=RegExp(`.*${Gn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),xi=F(`$ZodCheckOverwrite`,(e,t)=>{ai.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Si=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
72
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Nt(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function N(e,t){return Kt.parse(e,t)}N.options=N.setOptions=function(e){return Kt.setOptions(e),N.defaults=Kt.defaults,De(N.defaults),N},N.getDefaults=Te,N.defaults=Ee,N.use=function(...e){return Kt.use(...e),N.defaults=Kt.defaults,De(N.defaults),N},N.walkTokens=function(e,t){return Kt.walkTokens(e,t)},N.parseInline=Kt.parseInline,N.Parser=Wt,N.parser=Wt.parse,N.Renderer=Ht,N.TextRenderer=Ut,N.Lexer=Vt,N.lexer=Vt.lex,N.Tokenizer=Bt,N.Hooks=Gt,N.parse=N,N.options,N.setOptions,N.use,N.walkTokens,N.parseInline,Wt.parse,Vt.lex;var qt=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),P=o(((e,t)=>{t.exports=qt()}))();function Jt(e){try{return N.lexer(e,{gfm:!0,async:!1}).filter(e=>e.type!==`html`)}catch{return[{type:`text`,raw:e,text:e}]}}function Yt({text:e}){return(0,P.jsx)(`div`,{className:`markdown-content`,children:(0,_.useMemo)(()=>Jt(e),[e]).map((e,t)=>(0,P.jsx)(Xt,{token:e},`${e.type}-${t}`))})}function Xt({token:e}){if(e.type===`space`)return null;if(e.type===`heading`){let t=e;return(0,P.jsx)(`h${Math.min(6,t.depth)}`,{children:(0,P.jsx)(Zt,{tokens:t.tokens})})}if(e.type===`paragraph`)return(0,P.jsx)(`p`,{children:(0,P.jsx)(Zt,{tokens:e.tokens??[]})});if(e.type===`code`){let t=e;return(0,P.jsxs)(`div`,{className:`markdown-code`,children:[(0,P.jsx)(`span`,{children:t.lang?.trim()||`code`}),(0,P.jsx)(`pre`,{children:(0,P.jsx)(`code`,{children:t.text})})]})}if(e.type===`blockquote`)return(0,P.jsx)(`blockquote`,{children:e.tokens.map((e,t)=>(0,P.jsx)(Xt,{token:e},t))});if(e.type===`list`){let t=e;return(0,P.jsx)(t.ordered?`ol`:`ul`,{start:t.ordered&&typeof t.start==`number`?t.start:void 0,children:t.items.map((e,t)=>(0,P.jsx)(`li`,{children:e.tokens.map((e,t)=>(0,P.jsx)(Xt,{token:e},t))},t))})}if(e.type===`hr`)return(0,P.jsx)(`hr`,{});if(e.type===`table`){let t=e;return(0,P.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsx)(`tr`,{children:t.header.map((e,t)=>(0,P.jsx)(`th`,{style:{textAlign:e.align??void 0},children:(0,P.jsx)(Zt,{tokens:e.tokens})},t))})}),(0,P.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,P.jsx)(`tr`,{children:e.map((e,n)=>(0,P.jsx)(`td`,{style:{textAlign:t.align[n]??void 0},children:(0,P.jsx)(Zt,{tokens:e.tokens})},n))},n))})]})})}return`tokens`in e&&Array.isArray(e.tokens)?(0,P.jsx)(`p`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})}):`text`in e&&typeof e.text==`string`?(0,P.jsx)(`p`,{children:e.text}):null}function Zt({tokens:e}){return(0,P.jsx)(P.Fragment,{children:e.map((e,t)=>(0,P.jsx)(Qt,{token:e},t))})}function Qt({token:e}){if(e.type===`text`){let t=e;return t.tokens?.length?(0,P.jsx)(Zt,{tokens:t.tokens}):t.text}if(e.type===`strong`)return(0,P.jsx)(`strong`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})});if(e.type===`em`)return(0,P.jsx)(`em`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})});if(e.type===`del`)return(0,P.jsx)(`del`,{children:(0,P.jsx)(Zt,{tokens:e.tokens})});if(e.type===`codespan`)return(0,P.jsx)(`code`,{children:e.text});if(e.type===`br`)return(0,P.jsx)(`br`,{});if(e.type===`escape`)return e.text;if(e.type===`link`){let t=e;return(0,P.jsx)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,children:(0,P.jsx)(Zt,{tokens:t.tokens})})}return e.type===`image`?(0,P.jsxs)(`span`,{className:`markdown-image-label`,children:[`[图片:`,e.text,`]`]}):e.type===`html`?null:`text`in e&&typeof e.text==`string`?e.text:null}function $t(e,t,n){let r=new Map;for(let t of e)r.set(t.name,{name:t.name,kind:`command`,description:t.description});for(let e of t)r.has(e.name)||r.set(e.name,e.description===void 0?{name:e.name,kind:`plugin`}:{name:e.name,kind:`plugin`,description:e.description});for(let e of n)r.has(e.name)||r.set(e.name,{name:e.name,kind:`skill`,description:e.description,source:e.source});return[...r.values()]}function en(e,t,n){if(n)return 0;let r=[...e];if(r[0]!==`/`)return 0;let i=r.findIndex(e=>/\s/u.test(e)),a=i<0?r.length:i,o=r.slice(1,a).join(``);return t.some(e=>e.name===o)?a:0}function tn(e,t,n,r,i=6){let a=[...e],o=Math.max(0,Math.min(a.length,t));if(a[0]!==`/`)return null;let s=a.findIndex(e=>/\s/u.test(e)),c=s<0?a.length:s;if(o<1||o>c)return null;let l=a.slice(1,c).join(``),u=l.toLowerCase(),d=n.filter(({name:e})=>e.toLowerCase().includes(u)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(u);return n===t.name.toLowerCase().startsWith(u)?e.name.localeCompare(t.name):n?-1:1});if(d.length===0)return null;let f=Math.max(0,Math.min(d.length-1,r)),p=Math.max(1,i);return{query:l,items:d,selectedIndex:f,windowStart:Math.max(0,Math.min(f,d.length-p))}}function nn(e,t,n){return n<=0?0:(e+t+n)%n}function rn(e,t,n){let r=[...e],i=Math.max(0,Math.min(r.length,t)),a=r.slice(i).findIndex(e=>/\s/u.test(e)),o=a<0?r.length:i+a,s=r.slice(o).join(``).replace(/^\s*/u,``),c=`/${n} `;return{text:c+s,cursor:[...c].length}}function an(e,t,n){if(t<=0)return null;let r=[...e],i=Math.min(r.length,t),a=Math.max(i,Math.min(r.length,n)),o=r.slice(i,a).join(``);return/^\s*$/u.test(o)?{text:r.slice(a).join(``),cursor:0}:null}function on(e,t){if(t.length===0)return[];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}return i}var sn={command:`命令`,plugin:`插件`,skill:`技能`},cn={command:`slash-kind-command`,plugin:`slash-kind-plugin`,skill:`slash-kind-skill`};function ln({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`slash-dropdown-backdrop`,onClick:n}),(0,P.jsxs)(`div`,{className:`slash-dropdown`,role:`listbox`,"aria-label":`命令补全`,children:[(0,P.jsxs)(`div`,{className:`slash-dropdown-header`,children:[(0,P.jsx)(`span`,{children:`可用命令`}),(0,P.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,P.jsx)(`kbd`,{children:`Tab 确认`}),(0,P.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,P.jsx)(`div`,{className:`slash-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex,i=on(n.name,e.query);return(0,P.jsxs)(`button`,{className:`slash-item${r?` slash-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n.name)},children:[(0,P.jsx)(`span`,{className:`slash-item-marker`,children:r?`›`:` `}),(0,P.jsx)(`span`,{className:cn[n.kind],children:sn[n.kind]}),(0,P.jsx)(`span`,{className:`slash-item-name`,children:un(n.name,i)}),n.description&&(0,P.jsx)(`span`,{className:`slash-item-desc`,children:n.description})]},n.name)})}),(0,P.jsx)(`div`,{className:`slash-dropdown-footer`,children:e.items.length>6&&(0,P.jsxs)(`span`,{className:`slash-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function un(e,t){if(t.length===0)return(0,P.jsx)(P.Fragment,{children:e});let n=[],r=0;for(let[i,a]of t)i>r&&n.push((0,P.jsx)(`span`,{children:e.slice(r,i)},`text-${r}`)),n.push((0,P.jsx)(`mark`,{children:e.slice(i,a)},`mark-${i}`)),r=a;return r<e.length&&n.push((0,P.jsx)(`span`,{children:e.slice(r)},`text-${r}`)),(0,P.jsx)(P.Fragment,{children:n})}function dn(e,t){if(t.length===0)return(0,P.jsx)(P.Fragment,{children:e});let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(;a<n.length;){let e=n.indexOf(r,a);if(e<0)break;i.push([e,e+r.length]),a=e+r.length}if(i.length===0)return(0,P.jsx)(P.Fragment,{children:e});let o=[],s=0;for(let[t,n]of i)t>s&&o.push((0,P.jsx)(`span`,{children:e.slice(s,t)},`text-${s}`)),o.push((0,P.jsx)(`mark`,{children:e.slice(t,n)},`mark-${t}`)),s=n;return s<e.length&&o.push((0,P.jsx)(`span`,{children:e.slice(s)},`text-${s}`)),(0,P.jsx)(P.Fragment,{children:o})}function fn({completion:e,onSelect:t,onDismiss:n}){let r=e.items.slice(e.windowStart,e.windowStart+6);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`mention-dropdown-backdrop`,onClick:n}),(0,P.jsxs)(`div`,{className:`mention-dropdown`,role:`listbox`,"aria-label":`文件补全`,children:[(0,P.jsxs)(`div`,{className:`mention-dropdown-header`,children:[(0,P.jsx)(`span`,{children:`项目文件`}),(0,P.jsx)(`kbd`,{children:`↑↓ 选择`}),(0,P.jsx)(`kbd`,{children:`Tab 确认`}),(0,P.jsx)(`kbd`,{children:`Esc 关闭`})]}),(0,P.jsx)(`div`,{className:`mention-dropdown-list`,children:r.map(n=>{let r=e.items.indexOf(n)===e.selectedIndex;return(0,P.jsxs)(`button`,{className:`mention-item${r?` mention-item-selected`:``}`,role:`option`,"aria-selected":r,onMouseDown:e=>{e.preventDefault(),t(n)},children:[(0,P.jsx)(`span`,{className:`mention-item-marker`,children:r?`›`:` `}),(0,P.jsx)(`span`,{className:`mention-item-icon`,children:`📄`}),(0,P.jsx)(`span`,{className:`mention-item-path`,children:dn(n,e.query)})]},n)})}),(0,P.jsx)(`div`,{className:`mention-dropdown-footer`,children:e.items.length>6&&(0,P.jsxs)(`span`,{className:`mention-count`,children:[e.selectedIndex+1,` / `,e.items.length]})})]})]})}function pn(e){let t=e.replaceAll(`\\`,`/`),n=t.lastIndexOf(`/`);return n<0?e:t.slice(n+1)}function mn(e){return[...new Set(e.map(e=>e.replaceAll(`\\`,`/`)))].sort(Sn)}function hn(e,t,n,r,i=6){let a=vn(e,t);if(a===null)return null;let o=a.query.toLowerCase(),s=n.filter(e=>e.toLowerCase().includes(o)).sort((e,t)=>xn(e,o)-xn(t,o)||Sn(e,t));if(s.length===0)return null;let c=Math.max(0,Math.min(s.length-1,r)),l=Math.max(1,i),u=Math.max(0,Math.min(c,s.length-l));return{query:a.query,items:s,selectedIndex:c,windowStart:u}}function gn(e,t,n){return n<=0?0:(e+t+n)%n}function _n(e,t,n){let r=[...e],i=vn(e,t),a=Math.max(0,Math.min(r.length,t));if(i===null)return{text:e,cursor:a};let o=`@${n.replaceAll(`\\`,`/`).replaceAll(` `,`\\ `)} `,s=r.slice(0,i.start).join(``),c=r.slice(i.end).join(``).replace(/^\s*/u,``);return{text:s+o+c,cursor:[...s+o].length,span:{start:[...s].length,end:[...s+o].length}}}function vn(e,t){let n=[...e],r=Math.max(0,Math.min(n.length,t)),i=r;for(;i>0&&!yn(n,i-1);)--i;if(n[i]!==`@`||r<=i)return null;let a=r;for(;a<n.length&&!yn(n,a);)a+=1;return{start:i,end:a,query:bn(n.slice(i+1,a).join(``))}}function yn(e,t){if(!/\s/u.test(e[t]??``))return!1;let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==0}function bn(e){return e.replace(/\\(\s)/gu,`$1`)}function xn(e,t){let n=e.toLowerCase();return pn(n).startsWith(t)?0:n.startsWith(t)?1:2}function Sn(e,t){return e.localeCompare(t,`en`)}var Cn;function F(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var wn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Tn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Cn=globalThis).__zod_globalConfig??(Cn.__zod_globalConfig={});var En=globalThis.__zod_globalConfig;function Dn(e){return e&&Object.assign(En,e),En}function On(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function kn(e,t){return typeof t==`bigint`?t.toString():t}function An(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function jn(e){return e==null}function Mn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Nn(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Pn=Symbol(`evaluating`);function I(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Pn)return r===void 0&&(r=Pn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function In(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ln(e){return JSON.stringify(e)}function Rn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var zn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Bn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Vn=An(()=>{if(En.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Hn(e){if(Bn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Bn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Un(e){return Hn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Wn=new Set([`string`,`number`,`symbol`]);function Gn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Kn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function qn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Jn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Yn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Kn(e,In(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Fn(this,`shape`,e),e},checks:[]}))}function Xn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Kn(e,In(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Fn(this,`shape`,r),r},checks:[]}))}function Zn(e,t){if(!Hn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Kn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Fn(this,`shape`,n),n}}))}function Qn(e,t){if(!Hn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Kn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Fn(this,`shape`,n),n}}))}function $n(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Kn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Fn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function er(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Kn(t,In(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Fn(this,`shape`,i),i},checks:[]}))}function tr(e,t,n){return Kn(t,In(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Fn(this,`shape`,i),i}}))}function nr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function rr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ir(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ar(e){return typeof e==`string`?e:e?.message}function or(e,t,n){let r=e.message?e.message:ar(e.inst?._zod.def?.error?.(e))??ar(t?.error?.(e))??ar(n.customError?.(e))??ar(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function sr(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function cr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var lr=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,kn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ur=F(`$ZodError`,lr),dr=F(`$ZodError`,lr,{Parent:Error});function fr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function pr(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var mr=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new wn;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>or(e,a,Dn())));throw zn(t,i?.callee),t}return o.value},hr=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>or(e,a,Dn())));throw zn(t,i?.callee),t}return o.value},gr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new wn;return a.issues.length?{success:!1,error:new(e??ur)(a.issues.map(e=>or(e,i,Dn())))}:{success:!0,data:a.value}},_r=gr(dr),vr=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>or(e,i,Dn())))}:{success:!0,data:a.value}},yr=vr(dr),br=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return mr(e)(t,n,i)},xr=e=>(t,n,r)=>mr(e)(t,n,r),Sr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hr(e)(t,n,i)},Cr=e=>async(t,n,r)=>hr(e)(t,n,r),wr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return gr(e)(t,n,i)},Tr=e=>(t,n,r)=>gr(e)(t,n,r),Er=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return vr(e)(t,n,i)},Dr=e=>async(t,n,r)=>vr(e)(t,n,r),Or=/^[cC][0-9a-z]{6,}$/,kr=/^[0-9a-z]+$/,Ar=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jr=/^[0-9a-vA-V]{20}$/,Mr=/^[A-Za-z0-9]{27}$/,Nr=/^[a-zA-Z0-9_-]{21}$/,Pr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ir=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Lr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rr=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function zr(){return new RegExp(Rr,`u`)}var Br=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Hr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ur=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gr=/^[A-Za-z0-9_-]*$/,Kr=/^https?$/,qr=/^\+[1-9]\d{6,14}$/,Jr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Yr=RegExp(`^${Jr}$`);function Xr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Zr(e){return RegExp(`^${Xr(e)}$`)}function Qr(e){let t=Xr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Jr}T(?:${r})$`)}var $r=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ei=/^-?\d+$/,ti=/^-?\d+(?:\.\d+)?$/,ni=/^(?:true|false)$/i,ri=/^[^A-Z]*$/,ii=/^[^a-z]*$/,ai=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),oi={number:`number`,bigint:`bigint`,object:`date`},si=F(`$ZodCheckLessThan`,(e,t)=>{ai.init(e,t);let n=oi[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ci=F(`$ZodCheckGreaterThan`,(e,t)=>{ai.init(e,t);let n=oi[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),li=F(`$ZodCheckMultipleOf`,(e,t)=>{ai.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Nn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ui=F(`$ZodCheckNumberFormat`,(e,t)=>{ai.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Jn[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ei)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),di=F(`$ZodCheckMaxLength`,(e,t)=>{var n;ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=sr(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fi=F(`$ZodCheckMinLength`,(e,t)=>{var n;ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=sr(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pi=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=sr(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),mi=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ai.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),hi=F(`$ZodCheckRegex`,(e,t)=>{mi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gi=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ri,mi.init(e,t)}),_i=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ii,mi.init(e,t)}),vi=F(`$ZodCheckIncludes`,(e,t)=>{ai.init(e,t);let n=Gn(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),yi=F(`$ZodCheckStartsWith`,(e,t)=>{ai.init(e,t);let n=RegExp(`^${Gn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bi=F(`$ZodCheckEndsWith`,(e,t)=>{ai.init(e,t);let n=RegExp(`.*${Gn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),xi=F(`$ZodCheckOverwrite`,(e,t)=>{ai.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Si=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
73
73
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
74
74
  `))}},Ci={major:4,minor:4,patch:3},R=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ci;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=nr(e),i;for(let a of t){if(a._zod.def.when){if(rr(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new wn;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=nr(e,t))});else{if(e.issues.length===t)continue;r||=nr(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(nr(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new wn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new wn;return o.then(e=>t(e,r,a))}return t(o,r,a)}}I(e,`~standard`,()=>({validate:t=>{try{let n=_r(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return yr(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),wi=F(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$r(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),z=F(`$ZodStringFormat`,(e,t)=>{mi.init(e,t),wi.init(e,t)}),Ti=F(`$ZodGUID`,(e,t)=>{t.pattern??=Fr,z.init(e,t)}),Ei=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ir(e)}else t.pattern??=Ir();z.init(e,t)}),Di=F(`$ZodEmail`,(e,t)=>{t.pattern??=Lr,z.init(e,t)}),Oi=F(`$ZodURL`,(e,t)=>{z.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Kr.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ki=F(`$ZodEmoji`,(e,t)=>{t.pattern??=zr(),z.init(e,t)}),Ai=F(`$ZodNanoID`,(e,t)=>{t.pattern??=Nr,z.init(e,t)}),ji=F(`$ZodCUID`,(e,t)=>{t.pattern??=Or,z.init(e,t)}),Mi=F(`$ZodCUID2`,(e,t)=>{t.pattern??=kr,z.init(e,t)}),Ni=F(`$ZodULID`,(e,t)=>{t.pattern??=Ar,z.init(e,t)}),B=F(`$ZodXID`,(e,t)=>{t.pattern??=jr,z.init(e,t)}),Pi=F(`$ZodKSUID`,(e,t)=>{t.pattern??=Mr,z.init(e,t)}),Fi=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=Qr(t),z.init(e,t)}),Ii=F(`$ZodISODate`,(e,t)=>{t.pattern??=Yr,z.init(e,t)}),Li=F(`$ZodISOTime`,(e,t)=>{t.pattern??=Zr(t),z.init(e,t)}),Ri=F(`$ZodISODuration`,(e,t)=>{t.pattern??=Pr,z.init(e,t)}),zi=F(`$ZodIPv4`,(e,t)=>{t.pattern??=Br,z.init(e,t),e._zod.bag.format=`ipv4`}),Bi=F(`$ZodIPv6`,(e,t)=>{t.pattern??=Vr,z.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Vi=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Hr,z.init(e,t)}),Hi=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ur,z.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Ui(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Wi=F(`$ZodBase64`,(e,t)=>{t.pattern??=Wr,z.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Ui(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Gi(e){if(!Gr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ui(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Ki=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=Gr,z.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Gi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),qi=F(`$ZodE164`,(e,t)=>{t.pattern??=qr,z.init(e,t)});function Ji(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Yi=F(`$ZodJWT`,(e,t)=>{z.init(e,t),e._zod.check=n=>{Ji(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Xi=F(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??ti,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Zi=F(`$ZodNumberFormat`,(e,t)=>{ui.init(e,t),Xi.init(e,t)}),Qi=F(`$ZodBoolean`,(e,t)=>{R.init(e,t),e._zod.pattern=ni,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),$i=F(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),ea=F(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ta(e,t,n){e.issues.length&&t.issues.push(...ir(n,e.issues)),t.value[n]=e.value}var na=F(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ta(t,n,e))):ta(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function ra(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ir(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function ia(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=qn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function aa(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ra(e,n,i,t,u,d))):ra(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var oa=F(`$ZodObject`,(e,t)=>{if(R.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=An(()=>ia(t));I(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Bn,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>ra(n,t,e,s,r,i))):ra(a,t,e,s,r,i)}return i?aa(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),sa=F(`$ZodObjectJIT`,(e,t)=>{oa.init(e,t);let n=e._zod.parse,r=An(()=>ia(t)),i=e=>{let t=new Si([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Ln(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Ln(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
75
75
  if (${n}.issues.length) {
@@ -132,7 +132,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
132
132
 
133
133
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Bn,s=!En.jitless,c=s&&Vn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?aa([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ca(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!nr(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>or(e,r,Dn())))}),t)}var la=F(`$ZodUnion`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),I(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),I(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Mn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ca(t,r,e,i)):ca(o,r,e,i)}}),ua=F(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,la.init(e,t);let n=e._zod.parse;I(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=An(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Bn(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),da=F(`$ZodIntersection`,(e,t)=>{R.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>pa(e,t,n)):pa(e,i,a)}});function fa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Hn(e)&&Hn(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=fa(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=fa(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function pa(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),nr(e))return e;let o=fa(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ma=F(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Hn(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>or(e,r,Dn())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ir(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ir(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ti.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>or(e,r,Dn())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ir(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ir(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ha=F(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=On(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Wn.has(typeof e)).map(e=>typeof e==`string`?Gn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ga=F(`$ZodLiteral`,(e,t)=>{if(R.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Gn(e):e?Gn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),_a=F(`$ZodTransform`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new wn;return n.value=i,n.fallback=!0,n}});function va(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ya=F(`$ZodOptional`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>va(e,r)):va(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ba=F(`$ZodExactOptional`,(e,t)=>{ya.init(e,t),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xa=F(`$ZodNullable`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.innerType._zod.optin),I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mn(e.source)}|null)$`):void 0}),I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Sa=F(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ca(e,t)):Ca(r,t)}});function Ca(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wa=F(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ta=F(`$ZodNonOptional`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ea(t,e)):Ea(i,e)}});function Ea(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Da=F(`$ZodCatch`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>or(e,n,Dn()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>or(e,n,Dn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Oa=F(`$ZodPipe`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>t.in._zod.values),I(e._zod,`optin`,()=>t.in._zod.optin),I(e._zod,`optout`,()=>t.out._zod.optout),I(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ka(e,t.in,n)):ka(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ka(e,t.out,n)):ka(r,t.out,n)}});function ka(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Aa=F(`$ZodPreprocess`,(e,t)=>{Oa.init(e,t)}),ja=F(`$ZodReadonly`,(e,t)=>{R.init(e,t),I(e._zod,`propValues`,()=>t.innerType._zod.propValues),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`optin`,()=>t.innerType?._zod?.optin),I(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ma):Ma(r)}});function Ma(e){return e.value=Object.freeze(e.value),e}var Na=F(`$ZodCustom`,(e,t)=>{ai.init(e,t),R.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Pa(t,n,r,e));Pa(i,n,r,e)}});function Pa(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(cr(e))}}var Fa,Ia=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function La(){return new Ia}(Fa=globalThis).__zod_globalRegistry??(Fa.__zod_globalRegistry=La());var Ra=globalThis.__zod_globalRegistry;function za(e,t){return new e({type:`string`,...L(t)})}function Ba(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function Va(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function Ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function Ua(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function Wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Ga(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Ka(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function qa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Ja(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Ya(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Xa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Za(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Qa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function $a(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function eo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function to(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function no(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function ro(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function io(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function ao(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function oo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function so(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function co(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function lo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function uo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function fo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function V(e,t){return new e({type:`number`,checks:[],...L(t)})}function po(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function mo(e,t){return new e({type:`boolean`,...L(t)})}function ho(e){return new e({type:`unknown`})}function go(e,t){return new e({type:`never`,...L(t)})}function _o(e,t){return new si({check:`less_than`,...L(t),value:e,inclusive:!1})}function vo(e,t){return new si({check:`less_than`,...L(t),value:e,inclusive:!0})}function yo(e,t){return new ci({check:`greater_than`,...L(t),value:e,inclusive:!1})}function bo(e,t){return new ci({check:`greater_than`,...L(t),value:e,inclusive:!0})}function xo(e,t){return new li({check:`multiple_of`,...L(t),value:e})}function So(e,t){return new di({check:`max_length`,...L(t),maximum:e})}function Co(e,t){return new fi({check:`min_length`,...L(t),minimum:e})}function wo(e,t){return new pi({check:`length_equals`,...L(t),length:e})}function To(e,t){return new hi({check:`string_format`,format:`regex`,...L(t),pattern:e})}function Eo(e){return new gi({check:`string_format`,format:`lowercase`,...L(e)})}function Do(e){return new _i({check:`string_format`,format:`uppercase`,...L(e)})}function Oo(e,t){return new vi({check:`string_format`,format:`includes`,...L(t),includes:e})}function ko(e,t){return new yi({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function Ao(e,t){return new bi({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function jo(e){return new xi({check:`overwrite`,tx:e})}function Mo(e){return jo(t=>t.normalize(e))}function No(){return jo(e=>e.trim())}function Po(){return jo(e=>e.toLowerCase())}function Fo(){return jo(e=>e.toUpperCase())}function Io(){return jo(e=>Rn(e))}function Lo(e,t,n){return new e({type:`array`,element:t,...L(n)})}function Ro(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function zo(e,t){let n=Bo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(cr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(cr(r))}},e(t.value,t)),t);return n}function Bo(e,t){let n=new ai({check:`custom`,...L(t)});return n._zod.check=e,n}function Vo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ra,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Ho(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Ho(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Go(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Uo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
134
134
 
135
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Wo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qo(t,`input`,e.processors),output:qo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Go(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Go(r.element,n);if(r.type===`set`)return Go(r.valueType,n);if(r.type===`lazy`)return Go(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Go(r.innerType,n);if(r.type===`intersection`)return Go(r.left,n)||Go(r.right,n);if(r.type===`record`||r.type===`map`)return Go(r.keyType,n)||Go(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Go(r.in,n)||Go(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Go(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Go(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Go(e,n))return!0;return!!(r.rest&&Go(r.rest,n))}return!1}var Ko=(e,t={})=>n=>{let r=Vo({...n,processors:t});return Ho(e,r),Uo(r,e),Wo(r,e)},qo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vo({...i??{},target:a,io:t,processors:n});return Ho(e,o),Uo(o,e),Wo(o,e)},Jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zo=(e,t,n,r)=>{n.type=`boolean`},Qo=(e,t,n,r)=>{n.not={}},$o=(e,t,n,r)=>{let i=e._zod.def,a=On(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},es=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},rs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ho(a.element,t,{...r,path:[...r.path,`items`]})},is=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ho(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ho(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},as=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ho(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},os=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ho(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ss=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ho(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ho(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ho(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},cs=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ls=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},us=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ds=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ho(o,t,r);let s=t.seen.get(e);s.ref=o},ms=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gs=F(`ZodISODateTime`,(e,t)=>{Fi.init(e,t),Hs.init(e,t)});function _s(e){return co(gs,e)}var vs=F(`ZodISODate`,(e,t)=>{Ii.init(e,t),Hs.init(e,t)});function ys(e){return lo(vs,e)}var bs=F(`ZodISOTime`,(e,t)=>{Li.init(e,t),Hs.init(e,t)});function xs(e){return uo(bs,e)}var Ss=F(`ZodISODuration`,(e,t)=>{Ri.init(e,t),Hs.init(e,t)});function Cs(e){return fo(Ss,e)}var ws=F(`ZodError`,(e,t)=>{ur.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>pr(e,t)},flatten:{value:t=>fr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,kn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,kn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ts=mr(ws),Es=hr(ws),Ds=gr(ws),Os=vr(ws),ks=br(ws),As=xr(ws),js=Sr(ws),Ms=Cr(ws),Ns=wr(ws),Ps=Tr(ws),Fs=Er(ws),Is=Dr(ws),Ls=new WeakMap;function Rs(e,t,n){let r=Object.getPrototypeOf(e),i=Ls.get(r);if(i||(i=new Set,Ls.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zs=F(`ZodType`,(e,t)=>(R.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qo(e,`input`),output:qo(e,`output`)}}),e.toJSONSchema=Ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ts(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ds(e,t,n),e.parseAsync=async(t,n)=>Es(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Os(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ks(e,t,n),e.decode=(t,n)=>As(e,t,n),e.encodeAsync=async(t,n)=>js(e,t,n),e.decodeAsync=async(t,n)=>Ms(e,t,n),e.safeEncode=(t,n)=>Ns(e,t,n),e.safeDecode=(t,n)=>Ps(e,t,n),e.safeEncodeAsync=async(t,n)=>Fs(e,t,n),e.safeDecodeAsync=async(t,n)=>Is(e,t,n),Rs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(In(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Kn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(el(e,t))},superRefine(e,t){return this.check(tl(e,t))},overwrite(e){return this.check(jo(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return yc(this)},or(e){return Sc([this,e])},and(e){return Ec(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Qc(this)},describe(e){let t=this.clone();return Ra.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ra.get(this);let t=this.clone();return Ra.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Ra.get(e)?.description},configurable:!0}),e)),Bs=F(`_ZodString`,(e,t)=>{wi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rs(e,`_ZodString`,{regex(...e){return this.check(To(...e))},includes(...e){return this.check(Oo(...e))},startsWith(...e){return this.check(ko(...e))},endsWith(...e){return this.check(Ao(...e))},min(...e){return this.check(Co(...e))},max(...e){return this.check(So(...e))},length(...e){return this.check(wo(...e))},nonempty(...e){return this.check(Co(1,...e))},lowercase(e){return this.check(Eo(e))},uppercase(e){return this.check(Do(e))},trim(){return this.check(No())},normalize(...e){return this.check(Mo(...e))},toLowerCase(){return this.check(Po())},toUpperCase(){return this.check(Fo())},slugify(){return this.check(Io())}})}),Vs=F(`ZodString`,(e,t)=>{wi.init(e,t),Bs.init(e,t),e.email=t=>e.check(Ba(Us,t)),e.url=t=>e.check(Ka(qs,t)),e.jwt=t=>e.check(so(cc,t)),e.emoji=t=>e.check(qa(Js,t)),e.guid=t=>e.check(Va(Ws,t)),e.uuid=t=>e.check(Ha(Gs,t)),e.uuidv4=t=>e.check(Ua(Gs,t)),e.uuidv6=t=>e.check(Wa(Gs,t)),e.uuidv7=t=>e.check(Ga(Gs,t)),e.nanoid=t=>e.check(Ja(Ys,t)),e.guid=t=>e.check(Va(Ws,t)),e.cuid=t=>e.check(Ya(Xs,t)),e.cuid2=t=>e.check(Xa(Zs,t)),e.ulid=t=>e.check(Za(Qs,t)),e.base64=t=>e.check(io(ac,t)),e.base64url=t=>e.check(ao(oc,t)),e.xid=t=>e.check(Qa($s,t)),e.ksuid=t=>e.check($a(ec,t)),e.ipv4=t=>e.check(eo(tc,t)),e.ipv6=t=>e.check(to(nc,t)),e.cidrv4=t=>e.check(no(rc,t)),e.cidrv6=t=>e.check(ro(ic,t)),e.e164=t=>e.check(oo(sc,t)),e.datetime=t=>e.check(_s(t)),e.date=t=>e.check(ys(t)),e.time=t=>e.check(xs(t)),e.duration=t=>e.check(Cs(t))});function H(e){return za(Vs,e)}var Hs=F(`ZodStringFormat`,(e,t)=>{z.init(e,t),Bs.init(e,t)}),Us=F(`ZodEmail`,(e,t)=>{Di.init(e,t),Hs.init(e,t)}),Ws=F(`ZodGUID`,(e,t)=>{Ti.init(e,t),Hs.init(e,t)}),Gs=F(`ZodUUID`,(e,t)=>{Ei.init(e,t),Hs.init(e,t)});function Ks(e){return Ha(Gs,e)}var qs=F(`ZodURL`,(e,t)=>{Oi.init(e,t),Hs.init(e,t)}),Js=F(`ZodEmoji`,(e,t)=>{ki.init(e,t),Hs.init(e,t)}),Ys=F(`ZodNanoID`,(e,t)=>{Ai.init(e,t),Hs.init(e,t)}),Xs=F(`ZodCUID`,(e,t)=>{ji.init(e,t),Hs.init(e,t)}),Zs=F(`ZodCUID2`,(e,t)=>{Mi.init(e,t),Hs.init(e,t)}),Qs=F(`ZodULID`,(e,t)=>{Ni.init(e,t),Hs.init(e,t)}),$s=F(`ZodXID`,(e,t)=>{B.init(e,t),Hs.init(e,t)}),ec=F(`ZodKSUID`,(e,t)=>{Pi.init(e,t),Hs.init(e,t)}),tc=F(`ZodIPv4`,(e,t)=>{zi.init(e,t),Hs.init(e,t)}),nc=F(`ZodIPv6`,(e,t)=>{Bi.init(e,t),Hs.init(e,t)}),rc=F(`ZodCIDRv4`,(e,t)=>{Vi.init(e,t),Hs.init(e,t)}),ic=F(`ZodCIDRv6`,(e,t)=>{Hi.init(e,t),Hs.init(e,t)}),ac=F(`ZodBase64`,(e,t)=>{Wi.init(e,t),Hs.init(e,t)}),oc=F(`ZodBase64URL`,(e,t)=>{Ki.init(e,t),Hs.init(e,t)}),sc=F(`ZodE164`,(e,t)=>{qi.init(e,t),Hs.init(e,t)}),cc=F(`ZodJWT`,(e,t)=>{Yi.init(e,t),Hs.init(e,t)}),lc=F(`ZodNumber`,(e,t)=>{Xi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),Rs(e,`ZodNumber`,{gt(e,t){return this.check(yo(e,t))},gte(e,t){return this.check(bo(e,t))},min(e,t){return this.check(bo(e,t))},lt(e,t){return this.check(_o(e,t))},lte(e,t){return this.check(vo(e,t))},max(e,t){return this.check(vo(e,t))},int(e){return this.check(dc(e))},safe(e){return this.check(dc(e))},positive(e){return this.check(yo(0,e))},nonnegative(e){return this.check(bo(0,e))},negative(e){return this.check(_o(0,e))},nonpositive(e){return this.check(vo(0,e))},multipleOf(e,t){return this.check(xo(e,t))},step(e,t){return this.check(xo(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function U(e){return V(lc,e)}var uc=F(`ZodNumberFormat`,(e,t)=>{Zi.init(e,t),lc.init(e,t)});function dc(e){return po(uc,e)}var fc=F(`ZodBoolean`,(e,t)=>{Qi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function pc(e){return mo(fc,e)}var mc=F(`ZodUnknown`,(e,t)=>{$i.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hc(){return ho(mc)}var gc=F(`ZodNever`,(e,t)=>{ea.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r)});function _c(e){return go(gc,e)}var vc=F(`ZodArray`,(e,t)=>{na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.element=t.element,Rs(e,`ZodArray`,{min(e,t){return this.check(Co(e,t))},nonempty(e){return this.check(Co(1,e))},max(e,t){return this.check(So(e,t))},length(e,t){return this.check(wo(e,t))},unwrap(){return this.element}})});function yc(e,t){return Lo(vc,e,t)}var bc=F(`ZodObject`,(e,t)=>{sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),I(e,`shape`,()=>t.shape),Rs(e,`ZodObject`,{keyof(){return Ac(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:_c()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Zn(this,e)},safeExtend(e){return Qn(this,e)},merge(e){return $n(this,e)},pick(e){return Yn(this,e)},omit(e){return Xn(this,e)},partial(...e){return er(Pc,this,e[0])},required(...e){return tr(Wc,this,e[0])}})});function W(e,t){return new bc({type:`object`,shape:e??{},...L(t)})}var xc=F(`ZodUnion`,(e,t)=>{la.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.options=t.options});function Sc(e,t){return new xc({type:`union`,options:e,...L(t)})}var Cc=F(`ZodDiscriminatedUnion`,(e,t)=>{xc.init(e,t),ua.init(e,t)});function wc(e,t,n){return new Cc({type:`union`,options:t,discriminator:e,...L(n)})}var Tc=F(`ZodIntersection`,(e,t)=>{da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Ec(e,t){return new Tc({type:`intersection`,left:e,right:t})}var Dc=F(`ZodRecord`,(e,t)=>{ma.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Oc(e,t,n){return!t||!t._zod?new Dc({type:`record`,keyType:H(),valueType:e,...L(t)}):new Dc({type:`record`,keyType:e,valueType:t,...L(n)})}var kc=F(`ZodEnum`,(e,t)=>{ha.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kc({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kc({...t,checks:[],...L(r),entries:i})}});function Ac(e,t){return new kc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var jc=F(`ZodLiteral`,(e,t)=>{ga.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new jc({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Mc=F(`ZodTransform`,(e,t)=>{_a.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(cr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(cr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Nc(e){return new Mc({type:`transform`,transform:e})}var Pc=F(`ZodOptional`,(e,t)=>{ya.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}var Ic=F(`ZodExactOptional`,(e,t)=>{ba.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}var Rc=F(`ZodNullable`,(e,t)=>{xa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}var Bc=F(`ZodDefault`,(e,t)=>{Sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Hc=F(`ZodPrefault`,(e,t)=>{wa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Wc=F(`ZodNonOptional`,(e,t)=>{Ta.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...L(t)})}var Kc=F(`ZodCatch`,(e,t)=>{Da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Jc=F(`ZodPipe`,(e,t)=>{Oa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}var Xc=F(`ZodPreprocess`,(e,t)=>{Jc.init(e,t),Aa.init(e,t)}),Zc=F(`ZodReadonly`,(e,t)=>{ja.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`readonly`,innerType:e})}var $c=F(`ZodCustom`,(e,t)=>{Na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)});function el(e,t={}){return Ro($c,e,t)}function tl(e,t){return zo(e,t)}function nl(e,t){return new Xc({type:`pipe`,in:Nc(e),out:t})}var rl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function il(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var al=nl(il,Ac(rl).default(`default`)),ol=W({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:yc(H().min(1)).max(100).optional(),maxOutputTokens:U().int().positive().optional(),claudeClient:pc().optional(),apiType:Ac([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),sl={disabled:pc().default(!1),timeoutMs:U().int().min(100).max(30*6e4).default(6e4)},cl=Sc([W({command:H().min(1),args:yc(H()).default([]),env:Oc(H(),H()).default({}),cwd:H().min(1).optional(),...sl}).strict(),W({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Oc(H(),H()).default({}),...sl}).strict()]),ll=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),ul=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);W({sleep:pc().default(!1),providers:Oc(H(),ol).default({}),mcpServers:Oc(ll,cl).default({}),skills:W({disabled:yc(ul).max(1e3).default([])}).prefault({}),agents:W({main:W({model:H()}).optional(),subagent:W({model:H()}).optional()}).optional(),maxSubagents:U().int().min(1).max(16).default(3),maxSessions:U().int().min(1).max(1e3).default(50),memory:W({enabled:pc().default(!0),autoExtract:pc().default(!0),autoExtractMinChars:U().int().min(200).max(1e5).default(200),scoreThreshold:U().int().min(0).max(12).default(9),autoStoreThreshold:U().int().min(0).max(12).default(11),ignoreStreakLimit:U().int().min(2).max(100).default(5),reviewAutoDismissSeconds:U().int().min(0).max(300).default(5),maxCandidatesPerTask:U().int().min(1).max(10).default(1),retrievalTopK:U().int().min(1).max(20).default(5),maxEntries:U().int().min(1).max(1e4).default(200),maxEntryChars:U().int().min(32).max(2e4).default(1e3),maxPromptChars:U().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:al,execution:W({mode:Ac([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:pc().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:U().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:W({showWarnings:pc().default(!1),evaluationTimeoutMs:U().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:W({main:U().int().min(10).max(500).default(80),subagent:U().int().min(10).max(200).default(40),softLimitFactor:U().min(.5).max(1).default(.8),extendBy:U().int().min(5).max(100).default(20)}).prefault({}),loop:W({maxCycles:U().int().positive().max(1e4).default(20),maxTokens:U().int().positive().max(2**53-1).default(5e5),isolation:G(`auto`).default(`auto`)}).prefault({}),context:W({windowTokens:U().int().positive().default(2e5),reservedOutputTokens:U().int().nonnegative().default(2e4),autoCompactBufferTokens:U().int().nonnegative().default(13e3),warningBufferTokens:U().int().nonnegative().default(2e4),blockingBufferTokens:U().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:U().int().nonnegative().default(5),recentTokens:U().int().nonnegative().default(1e4),recentTextMessages:U().int().nonnegative().default(5),maxRecentTokens:U().int().nonnegative().default(4e4),compactAtChars:U().int().positive().optional(),toolOutputChars:U().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:W({enabled:pc().default(!1),webhookUrl:H().url().optional()}).prefault({})});var dl=[`user`,`feedback`,`project`,`reference`],fl=32*1024,pl=64*1024,ml=1024,hl=24*1024,gl=56*1024,_l=4*1024,vl=12*1024,yl=G(1),K=Ks(),bl=H().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),xl=bl,Sl=bl,Cl=H().refine(e=>Buffer.byteLength(e,`utf8`)<=fl,`Text must not exceed ${fl} UTF-8 bytes`),wl=Cl.refine(e=>e.length>0,`Text must not be empty`),Tl=H().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=_l,`Completion evidence must not exceed ${_l} UTF-8 bytes`),El=W({version:yl,id:K,alias:xl,projectPath:H().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=ml,`Project path must not exceed ${ml} UTF-8 bytes`),connectedAt:_s(),lastSeenAt:_s()}).strict();yc(El).max(16),W({version:yl,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict();var Dl=W({version:yl,type:G(`task-event`),messageId:K,taskId:K,senderId:K,recipientId:K,status:Ac([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Cl.optional()}).strict(),Ol=W({version:yl,type:G(`delivery-receipt`),messageId:K,status:Ac([`delivered`,`duplicate`,`rejected`]),recipientIds:yc(K).max(16),error:Cl.optional()}).strict(),kl=W({palId:K,required:pc()}).strict(),Al=yc(kl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),jl=W({id:H().min(1).max(128),assigneeId:K,description:wl,dependsOn:yc(H().min(1).max(128)).max(32)}).strict(),Ml=W({version:yl,coWorkId:K,epoch:U().int().positive(),goal:wl,participants:yc(kl).min(1).max(16),tasks:yc(jl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${hl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Nl=Ac([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Pl=W({passed:pc(),evidence:Tl}).strict(),Fl=W({participantId:K,passed:pc(),detail:Tl.optional()}).strict(),Il=W({version:yl,coWorkId:K,epoch:U().int().positive(),phase:Nl,goal:wl,participants:yc(kl).min(1).max(16),integrationOwnerId:K,acceptedParticipantIds:yc(K).max(16),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),plan:Ml.nullable(),planAcceptedParticipantIds:yc(K).max(16),readyParticipantIds:yc(K).max(16),completedParticipantIds:yc(K).max(16),completionAssertions:yc(Fl).max(16),integration:Pl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${gl} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${vl} UTF-8 bytes in aggregate`})}),Ll={version:yl,requestId:K};wc(`type`,[W({...Ll,type:G(`register`),authToken:H().regex(/^[a-f0-9]{64}$/).optional(),presence:El}).strict(),W({...Ll,type:G(`heartbeat`)}).strict(),W({...Ll,type:G(`list`)}).strict(),W({...Ll,type:G(`disconnect`)}).strict(),W({...Ll,type:G(`chat`),messageId:K,target:Sl,message:wl}).strict(),W({...Ll,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict(),W({...Ll,type:G(`cowork-propose`),coWorkId:K,goal:wl,participants:Al}).strict(),W({...Ll,type:G(`cowork-accept`),coWorkId:K,epoch:U().int().positive()}).strict(),W({...Ll,type:G(`cowork-plan`),plan:Ml}).strict(),W({...Ll,type:G(`cowork-plan-accept`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-ready`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-complete`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),detail:Tl.optional()}).strict(),W({...Ll,type:G(`cowork-integration`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),evidence:Tl}).strict(),W({...Ll,type:G(`cowork-get`),coWorkId:K}).strict(),W({...Ll,type:G(`cowork-cancel`),coWorkId:K,reason:wl}).strict()]);var q=W({version:yl,type:G(`ok`),requestId:K,data:hc()}).strict(),Rl=W({version:yl,type:G(`error`),requestId:K,code:Ac([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Cl}).strict(),J=Sc([W({version:yl,type:G(`chat-event`),messageId:K,senderId:K,recipientId:K,message:wl}).strict(),Dl,Ol,W({version:yl,type:G(`cowork-event`),action:Ac([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:K,coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Il}).strict()]);wc(`type`,[q,Rl,W({version:yl,type:G(`event`),event:J}).strict()]),H().refine(e=>Buffer.byteLength(e,`utf8`)<=pl,`Control frame must not exceed ${pl} UTF-8 bytes`);var Y=`model.init.config.login.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.mcp.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work`.split(`.`),X={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`},zl={name:``,description:``,body:`# Instructions
135
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Wo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qo(t,`input`,e.processors),output:qo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Go(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Go(r.element,n);if(r.type===`set`)return Go(r.valueType,n);if(r.type===`lazy`)return Go(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Go(r.innerType,n);if(r.type===`intersection`)return Go(r.left,n)||Go(r.right,n);if(r.type===`record`||r.type===`map`)return Go(r.keyType,n)||Go(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Go(r.in,n)||Go(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Go(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Go(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Go(e,n))return!0;return!!(r.rest&&Go(r.rest,n))}return!1}var Ko=(e,t={})=>n=>{let r=Vo({...n,processors:t});return Ho(e,r),Uo(r,e),Wo(r,e)},qo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vo({...i??{},target:a,io:t,processors:n});return Ho(e,o),Uo(o,e),Wo(o,e)},Jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zo=(e,t,n,r)=>{n.type=`boolean`},Qo=(e,t,n,r)=>{n.not={}},$o=(e,t,n,r)=>{let i=e._zod.def,a=On(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},es=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},rs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ho(a.element,t,{...r,path:[...r.path,`items`]})},is=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ho(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ho(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},as=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ho(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},os=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ho(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ss=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ho(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ho(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ho(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},cs=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ls=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},us=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ds=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ho(o,t,r);let s=t.seen.get(e);s.ref=o},ms=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gs=F(`ZodISODateTime`,(e,t)=>{Fi.init(e,t),Hs.init(e,t)});function _s(e){return co(gs,e)}var vs=F(`ZodISODate`,(e,t)=>{Ii.init(e,t),Hs.init(e,t)});function ys(e){return lo(vs,e)}var bs=F(`ZodISOTime`,(e,t)=>{Li.init(e,t),Hs.init(e,t)});function xs(e){return uo(bs,e)}var Ss=F(`ZodISODuration`,(e,t)=>{Ri.init(e,t),Hs.init(e,t)});function Cs(e){return fo(Ss,e)}var ws=F(`ZodError`,(e,t)=>{ur.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>pr(e,t)},flatten:{value:t=>fr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,kn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,kn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ts=mr(ws),Es=hr(ws),Ds=gr(ws),Os=vr(ws),ks=br(ws),As=xr(ws),js=Sr(ws),Ms=Cr(ws),Ns=wr(ws),Ps=Tr(ws),Fs=Er(ws),Is=Dr(ws),Ls=new WeakMap;function Rs(e,t,n){let r=Object.getPrototypeOf(e),i=Ls.get(r);if(i||(i=new Set,Ls.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zs=F(`ZodType`,(e,t)=>(R.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qo(e,`input`),output:qo(e,`output`)}}),e.toJSONSchema=Ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ts(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ds(e,t,n),e.parseAsync=async(t,n)=>Es(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Os(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ks(e,t,n),e.decode=(t,n)=>As(e,t,n),e.encodeAsync=async(t,n)=>js(e,t,n),e.decodeAsync=async(t,n)=>Ms(e,t,n),e.safeEncode=(t,n)=>Ns(e,t,n),e.safeDecode=(t,n)=>Ps(e,t,n),e.safeEncodeAsync=async(t,n)=>Fs(e,t,n),e.safeDecodeAsync=async(t,n)=>Is(e,t,n),Rs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(In(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Kn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(el(e,t))},superRefine(e,t){return this.check(tl(e,t))},overwrite(e){return this.check(jo(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return yc(this)},or(e){return Sc([this,e])},and(e){return Ec(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Qc(this)},describe(e){let t=this.clone();return Ra.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ra.get(this);let t=this.clone();return Ra.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Ra.get(e)?.description},configurable:!0}),e)),Bs=F(`_ZodString`,(e,t)=>{wi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rs(e,`_ZodString`,{regex(...e){return this.check(To(...e))},includes(...e){return this.check(Oo(...e))},startsWith(...e){return this.check(ko(...e))},endsWith(...e){return this.check(Ao(...e))},min(...e){return this.check(Co(...e))},max(...e){return this.check(So(...e))},length(...e){return this.check(wo(...e))},nonempty(...e){return this.check(Co(1,...e))},lowercase(e){return this.check(Eo(e))},uppercase(e){return this.check(Do(e))},trim(){return this.check(No())},normalize(...e){return this.check(Mo(...e))},toLowerCase(){return this.check(Po())},toUpperCase(){return this.check(Fo())},slugify(){return this.check(Io())}})}),Vs=F(`ZodString`,(e,t)=>{wi.init(e,t),Bs.init(e,t),e.email=t=>e.check(Ba(Us,t)),e.url=t=>e.check(Ka(qs,t)),e.jwt=t=>e.check(so(cc,t)),e.emoji=t=>e.check(qa(Js,t)),e.guid=t=>e.check(Va(Ws,t)),e.uuid=t=>e.check(Ha(Gs,t)),e.uuidv4=t=>e.check(Ua(Gs,t)),e.uuidv6=t=>e.check(Wa(Gs,t)),e.uuidv7=t=>e.check(Ga(Gs,t)),e.nanoid=t=>e.check(Ja(Ys,t)),e.guid=t=>e.check(Va(Ws,t)),e.cuid=t=>e.check(Ya(Xs,t)),e.cuid2=t=>e.check(Xa(Zs,t)),e.ulid=t=>e.check(Za(Qs,t)),e.base64=t=>e.check(io(ac,t)),e.base64url=t=>e.check(ao(oc,t)),e.xid=t=>e.check(Qa($s,t)),e.ksuid=t=>e.check($a(ec,t)),e.ipv4=t=>e.check(eo(tc,t)),e.ipv6=t=>e.check(to(nc,t)),e.cidrv4=t=>e.check(no(rc,t)),e.cidrv6=t=>e.check(ro(ic,t)),e.e164=t=>e.check(oo(sc,t)),e.datetime=t=>e.check(_s(t)),e.date=t=>e.check(ys(t)),e.time=t=>e.check(xs(t)),e.duration=t=>e.check(Cs(t))});function H(e){return za(Vs,e)}var Hs=F(`ZodStringFormat`,(e,t)=>{z.init(e,t),Bs.init(e,t)}),Us=F(`ZodEmail`,(e,t)=>{Di.init(e,t),Hs.init(e,t)}),Ws=F(`ZodGUID`,(e,t)=>{Ti.init(e,t),Hs.init(e,t)}),Gs=F(`ZodUUID`,(e,t)=>{Ei.init(e,t),Hs.init(e,t)});function Ks(e){return Ha(Gs,e)}var qs=F(`ZodURL`,(e,t)=>{Oi.init(e,t),Hs.init(e,t)}),Js=F(`ZodEmoji`,(e,t)=>{ki.init(e,t),Hs.init(e,t)}),Ys=F(`ZodNanoID`,(e,t)=>{Ai.init(e,t),Hs.init(e,t)}),Xs=F(`ZodCUID`,(e,t)=>{ji.init(e,t),Hs.init(e,t)}),Zs=F(`ZodCUID2`,(e,t)=>{Mi.init(e,t),Hs.init(e,t)}),Qs=F(`ZodULID`,(e,t)=>{Ni.init(e,t),Hs.init(e,t)}),$s=F(`ZodXID`,(e,t)=>{B.init(e,t),Hs.init(e,t)}),ec=F(`ZodKSUID`,(e,t)=>{Pi.init(e,t),Hs.init(e,t)}),tc=F(`ZodIPv4`,(e,t)=>{zi.init(e,t),Hs.init(e,t)}),nc=F(`ZodIPv6`,(e,t)=>{Bi.init(e,t),Hs.init(e,t)}),rc=F(`ZodCIDRv4`,(e,t)=>{Vi.init(e,t),Hs.init(e,t)}),ic=F(`ZodCIDRv6`,(e,t)=>{Hi.init(e,t),Hs.init(e,t)}),ac=F(`ZodBase64`,(e,t)=>{Wi.init(e,t),Hs.init(e,t)}),oc=F(`ZodBase64URL`,(e,t)=>{Ki.init(e,t),Hs.init(e,t)}),sc=F(`ZodE164`,(e,t)=>{qi.init(e,t),Hs.init(e,t)}),cc=F(`ZodJWT`,(e,t)=>{Yi.init(e,t),Hs.init(e,t)}),lc=F(`ZodNumber`,(e,t)=>{Xi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),Rs(e,`ZodNumber`,{gt(e,t){return this.check(yo(e,t))},gte(e,t){return this.check(bo(e,t))},min(e,t){return this.check(bo(e,t))},lt(e,t){return this.check(_o(e,t))},lte(e,t){return this.check(vo(e,t))},max(e,t){return this.check(vo(e,t))},int(e){return this.check(dc(e))},safe(e){return this.check(dc(e))},positive(e){return this.check(yo(0,e))},nonnegative(e){return this.check(bo(0,e))},negative(e){return this.check(_o(0,e))},nonpositive(e){return this.check(vo(0,e))},multipleOf(e,t){return this.check(xo(e,t))},step(e,t){return this.check(xo(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function U(e){return V(lc,e)}var uc=F(`ZodNumberFormat`,(e,t)=>{Zi.init(e,t),lc.init(e,t)});function dc(e){return po(uc,e)}var fc=F(`ZodBoolean`,(e,t)=>{Qi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function pc(e){return mo(fc,e)}var mc=F(`ZodUnknown`,(e,t)=>{$i.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hc(){return ho(mc)}var gc=F(`ZodNever`,(e,t)=>{ea.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r)});function _c(e){return go(gc,e)}var vc=F(`ZodArray`,(e,t)=>{na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.element=t.element,Rs(e,`ZodArray`,{min(e,t){return this.check(Co(e,t))},nonempty(e){return this.check(Co(1,e))},max(e,t){return this.check(So(e,t))},length(e,t){return this.check(wo(e,t))},unwrap(){return this.element}})});function yc(e,t){return Lo(vc,e,t)}var bc=F(`ZodObject`,(e,t)=>{sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),I(e,`shape`,()=>t.shape),Rs(e,`ZodObject`,{keyof(){return Ac(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:_c()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Zn(this,e)},safeExtend(e){return Qn(this,e)},merge(e){return $n(this,e)},pick(e){return Yn(this,e)},omit(e){return Xn(this,e)},partial(...e){return er(Pc,this,e[0])},required(...e){return tr(Wc,this,e[0])}})});function W(e,t){return new bc({type:`object`,shape:e??{},...L(t)})}var xc=F(`ZodUnion`,(e,t)=>{la.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.options=t.options});function Sc(e,t){return new xc({type:`union`,options:e,...L(t)})}var Cc=F(`ZodDiscriminatedUnion`,(e,t)=>{xc.init(e,t),ua.init(e,t)});function wc(e,t,n){return new Cc({type:`union`,options:t,discriminator:e,...L(n)})}var Tc=F(`ZodIntersection`,(e,t)=>{da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Ec(e,t){return new Tc({type:`intersection`,left:e,right:t})}var Dc=F(`ZodRecord`,(e,t)=>{ma.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Oc(e,t,n){return!t||!t._zod?new Dc({type:`record`,keyType:H(),valueType:e,...L(t)}):new Dc({type:`record`,keyType:e,valueType:t,...L(n)})}var kc=F(`ZodEnum`,(e,t)=>{ha.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kc({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kc({...t,checks:[],...L(r),entries:i})}});function Ac(e,t){return new kc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var jc=F(`ZodLiteral`,(e,t)=>{ga.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new jc({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Mc=F(`ZodTransform`,(e,t)=>{_a.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(cr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(cr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Nc(e){return new Mc({type:`transform`,transform:e})}var Pc=F(`ZodOptional`,(e,t)=>{ya.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}var Ic=F(`ZodExactOptional`,(e,t)=>{ba.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}var Rc=F(`ZodNullable`,(e,t)=>{xa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}var Bc=F(`ZodDefault`,(e,t)=>{Sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Hc=F(`ZodPrefault`,(e,t)=>{wa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Wc=F(`ZodNonOptional`,(e,t)=>{Ta.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...L(t)})}var Kc=F(`ZodCatch`,(e,t)=>{Da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Jc=F(`ZodPipe`,(e,t)=>{Oa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}var Xc=F(`ZodPreprocess`,(e,t)=>{Jc.init(e,t),Aa.init(e,t)}),Zc=F(`ZodReadonly`,(e,t)=>{ja.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`readonly`,innerType:e})}var $c=F(`ZodCustom`,(e,t)=>{Na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)});function el(e,t={}){return Ro($c,e,t)}function tl(e,t){return zo(e,t)}function nl(e,t){return new Xc({type:`pipe`,in:Nc(e),out:t})}var rl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function il(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var al=nl(il,Ac(rl).default(`default`)),ol=W({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:yc(H().min(1)).max(100).optional(),maxOutputTokens:U().int().positive().optional(),claudeClient:pc().optional(),apiType:Ac([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),sl={disabled:pc().default(!1),timeoutMs:U().int().min(100).max(30*6e4).default(6e4)},cl=Sc([W({command:H().min(1),args:yc(H()).default([]),env:Oc(H(),H()).default({}),cwd:H().min(1).optional(),...sl}).strict(),W({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Oc(H(),H()).default({}),...sl}).strict()]),ll=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),ul=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);W({sleep:pc().default(!1),providers:Oc(H(),ol).default({}),mcpServers:Oc(ll,cl).default({}),skills:W({disabled:yc(ul).max(1e3).default([])}).prefault({}),agents:W({main:W({model:H()}).optional(),subagent:W({model:H()}).optional()}).optional(),maxSubagents:U().int().min(1).max(16).default(3),maxSessions:U().int().min(1).max(1e3).default(50),memory:W({enabled:pc().default(!0),autoExtract:pc().default(!0),autoExtractMinChars:U().int().min(200).max(1e5).default(200),scoreThreshold:U().int().min(0).max(12).default(9),autoStoreThreshold:U().int().min(0).max(12).default(11),ignoreStreakLimit:U().int().min(2).max(100).default(5),reviewAutoDismissSeconds:U().int().min(0).max(300).default(5),maxCandidatesPerTask:U().int().min(1).max(10).default(1),retrievalTopK:U().int().min(1).max(20).default(5),maxEntries:U().int().min(1).max(1e4).default(200),maxEntryChars:U().int().min(32).max(2e4).default(1e3),maxPromptChars:U().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:al,execution:W({mode:Ac([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:pc().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:U().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:W({showWarnings:pc().default(!1),evaluationTimeoutMs:U().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:W({main:U().int().min(10).max(500).default(80),subagent:U().int().min(10).max(200).default(40),softLimitFactor:U().min(.5).max(1).default(.8),extendBy:U().int().min(5).max(100).default(20)}).prefault({}),loop:W({maxCycles:U().int().positive().max(1e4).default(20),maxTokens:U().int().positive().max(2**53-1).default(5e5),isolation:G(`auto`).default(`auto`)}).prefault({}),context:W({windowTokens:U().int().positive().default(2e5),reservedOutputTokens:U().int().nonnegative().default(2e4),autoCompactBufferTokens:U().int().nonnegative().default(13e3),warningBufferTokens:U().int().nonnegative().default(2e4),blockingBufferTokens:U().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:U().int().nonnegative().default(5),recentTokens:U().int().nonnegative().default(1e4),recentTextMessages:U().int().nonnegative().default(5),maxRecentTokens:U().int().nonnegative().default(4e4),compactAtChars:U().int().positive().optional(),toolOutputChars:U().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:W({enabled:pc().default(!1),webhookUrl:H().url().optional()}).prefault({}),evolve:W({promptTop:U().int().min(1).max(10).default(3),minRepeats:U().int().min(2).max(100).default(2),testCommand:H().trim().min(1).default(`npm test`),testTimeoutMs:U().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var dl=[`user`,`feedback`,`project`,`reference`],fl=32*1024,pl=64*1024,ml=1024,hl=24*1024,gl=56*1024,_l=4*1024,vl=12*1024,yl=G(1),K=Ks(),bl=H().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),xl=bl,Sl=bl,Cl=H().refine(e=>Buffer.byteLength(e,`utf8`)<=fl,`Text must not exceed ${fl} UTF-8 bytes`),wl=Cl.refine(e=>e.length>0,`Text must not be empty`),Tl=H().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=_l,`Completion evidence must not exceed ${_l} UTF-8 bytes`),El=W({version:yl,id:K,alias:xl,projectPath:H().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=ml,`Project path must not exceed ${ml} UTF-8 bytes`),connectedAt:_s(),lastSeenAt:_s()}).strict();yc(El).max(16),W({version:yl,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict();var Dl=W({version:yl,type:G(`task-event`),messageId:K,taskId:K,senderId:K,recipientId:K,status:Ac([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Cl.optional()}).strict(),Ol=W({version:yl,type:G(`delivery-receipt`),messageId:K,status:Ac([`delivered`,`duplicate`,`rejected`]),recipientIds:yc(K).max(16),error:Cl.optional()}).strict(),kl=W({palId:K,required:pc()}).strict(),Al=yc(kl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),jl=W({id:H().min(1).max(128),assigneeId:K,description:wl,dependsOn:yc(H().min(1).max(128)).max(32)}).strict(),Ml=W({version:yl,coWorkId:K,epoch:U().int().positive(),goal:wl,participants:yc(kl).min(1).max(16),tasks:yc(jl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${hl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Nl=Ac([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Pl=W({passed:pc(),evidence:Tl}).strict(),Fl=W({participantId:K,passed:pc(),detail:Tl.optional()}).strict(),Il=W({version:yl,coWorkId:K,epoch:U().int().positive(),phase:Nl,goal:wl,participants:yc(kl).min(1).max(16),integrationOwnerId:K,acceptedParticipantIds:yc(K).max(16),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),plan:Ml.nullable(),planAcceptedParticipantIds:yc(K).max(16),readyParticipantIds:yc(K).max(16),completedParticipantIds:yc(K).max(16),completionAssertions:yc(Fl).max(16),integration:Pl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${gl} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${vl} UTF-8 bytes in aggregate`})}),Ll={version:yl,requestId:K};wc(`type`,[W({...Ll,type:G(`register`),authToken:H().regex(/^[a-f0-9]{64}$/).optional(),presence:El}).strict(),W({...Ll,type:G(`heartbeat`)}).strict(),W({...Ll,type:G(`list`)}).strict(),W({...Ll,type:G(`disconnect`)}).strict(),W({...Ll,type:G(`chat`),messageId:K,target:Sl,message:wl}).strict(),W({...Ll,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict(),W({...Ll,type:G(`cowork-propose`),coWorkId:K,goal:wl,participants:Al}).strict(),W({...Ll,type:G(`cowork-accept`),coWorkId:K,epoch:U().int().positive()}).strict(),W({...Ll,type:G(`cowork-plan`),plan:Ml}).strict(),W({...Ll,type:G(`cowork-plan-accept`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-ready`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-complete`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),detail:Tl.optional()}).strict(),W({...Ll,type:G(`cowork-integration`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),evidence:Tl}).strict(),W({...Ll,type:G(`cowork-get`),coWorkId:K}).strict(),W({...Ll,type:G(`cowork-cancel`),coWorkId:K,reason:wl}).strict()]);var q=W({version:yl,type:G(`ok`),requestId:K,data:hc()}).strict(),Rl=W({version:yl,type:G(`error`),requestId:K,code:Ac([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Cl}).strict(),J=Sc([W({version:yl,type:G(`chat-event`),messageId:K,senderId:K,recipientId:K,message:wl}).strict(),Dl,Ol,W({version:yl,type:G(`cowork-event`),action:Ac([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:K,coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Il}).strict()]);wc(`type`,[q,Rl,W({version:yl,type:G(`event`),event:J}).strict()]),H().refine(e=>Buffer.byteLength(e,`utf8`)<=pl,`Control frame must not exceed ${pl} UTF-8 bytes`);var Y=`model.init.config.login.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.evolve.mcp.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work`.split(`.`),X={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`},zl={name:``,description:``,body:`# Instructions
136
136
 
137
137
  Describe when and how the agent should use this skill.`,disableModelInvocation:!1};function Bl({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(zl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e.length===0?n:n.filter(t=>t.name.includes(e)||t.description.toLowerCase().includes(e))},[m,n]),b=n.filter(e=>e.enabled).length,x=c?o.name.trim().length>0||o.description.trim().length>0||o.body!==zl.body:i!==void 0&&(o.description!==i.description||o.body!==i.body||!!o.disableModelInvocation!==i.disableModelInvocation),ee=e=>t(e instanceof Error?e.message:String(e)),S=async e=>{let t=await window.flavorDesktop.listSkills();r(t);let n=e??i?.name??t[0]?.name;n!==void 0&&t.some(e=>e.name===n)?await C(n):c||(a(void 0),s(zl))},C=async e=>{try{let t=await window.flavorDesktop.getSkill(e);a(t),s({name:t.name,description:t.description,body:t.body,disableModelInvocation:t.disableModelInvocation}),l(!1),v(!1)}catch(e){ee(e)}};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listSkills().then(async t=>{e&&(r(t),t[0]!==void 0&&await C(t[0].name))}).catch(ee).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let te=()=>{l(!0),a(void 0),s(zl),v(!1)},ne=async()=>{if(!f){p(!0);try{let e=c?await window.flavorDesktop.createSkill(o):await window.flavorDesktop.updateSkill(i.name,o);l(!1),a(e),s({name:e.name,description:e.description,body:e.body,disableModelInvocation:e.disableModelInvocation}),await S(e.name)}catch(e){ee(e)}finally{p(!1)}}},re=async(e,t)=>{r(n=>n.map(n=>n.name===e.name?{...n,enabled:t}:n)),i?.name===e.name&&a({...i,enabled:t});try{await window.flavorDesktop.setSkillEnabled(e.name,t)}catch(n){r(n=>n.map(n=>n.name===e.name?{...n,enabled:!t}:n)),i?.name===e.name&&a({...i,enabled:!t}),ee(n)}},ie=async()=>{if(!(i===void 0||f)){p(!0);try{await window.flavorDesktop.deleteSkill(i.name),v(!1),a(void 0),s(zl);let e=await window.flavorDesktop.listSkills();r(e),e[0]!==void 0&&await C(e[0].name)}catch(e){ee(e)}finally{p(!1)}}};return(0,P.jsxs)(`section`,{className:`skill-workbench`,"aria-label":`技能管理`,children:[(0,P.jsxs)(`header`,{className:`skill-workbench-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{className:`skill-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`项目能力`}),(0,P.jsx)(`h1`,{children:`技能管理`})]})]}),(0,P.jsxs)(`div`,{className:`skill-health`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:b}),` / `,n.length,` 已开启`]})]})]}),(0,P.jsxs)(`div`,{className:`skill-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`skill-catalog`,children:[(0,P.jsxs)(`div`,{className:`skill-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索技能`})]}),(0,P.jsxs)(`button`,{className:`skill-create`,onClick:te,children:[(0,P.jsx)(`span`,{children:`+`}),` 新建技能`]})]}),(0,P.jsxs)(`div`,{className:`skill-list`,"aria-busy":u,children:[u&&(0,P.jsx)(`p`,{className:`skill-list-empty`,children:`正在读取技能…`}),!u&&y.length===0&&(0,P.jsxs)(`div`,{className:`skill-list-empty`,children:[(0,P.jsx)(`strong`,{children:`没有匹配的技能`}),(0,P.jsx)(`span`,{children:`创建一个项目技能,或调整搜索词。`})]}),y.map(e=>(0,P.jsxs)(`article`,{className:`skill-list-item`,"data-selected":!c&&i?.name===e.name,"data-enabled":e.enabled,children:[(0,P.jsxs)(`button`,{className:`skill-select`,onClick:()=>void C(e.name),children:[(0,P.jsx)(`span`,{className:`skill-glyph`,children:e.name.slice(0,1).toUpperCase()}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.description})]})]}),(0,P.jsxs)(`label`,{className:`skill-toggle`,title:e.enabled?`关闭后 Agent 无法读取`:`开启后 Agent 可以读取`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void re(e,t.target.checked)}),(0,P.jsx)(`span`,{})]})]},e.name))]}),(0,P.jsxs)(`p`,{className:`skill-catalog-note`,children:[`启停状态保存在 `,(0,P.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,P.jsx)(`main`,{className:`skill-editor`,children:i===void 0&&!c?(0,P.jsxs)(`div`,{className:`skill-editor-empty`,children:[(0,P.jsx)(`span`,{children:`◇`}),(0,P.jsx)(`h2`,{children:`选择或创建一个技能`}),(0,P.jsx)(`p`,{children:`技能会在任务匹配时为 Agent 注入专门的工作说明。`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`skill-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`新建项目技能`:i?.editable?`项目技能`:i?.source===`global`?`全局技能`:`插件技能`}),(0,P.jsx)(`h2`,{children:c?`定义一项新能力`:i?.name})]}),!c&&i!==void 0&&(0,P.jsxs)(`span`,{className:`skill-status`,"data-enabled":i.enabled,children:[(0,P.jsx)(`i`,{}),i.enabled?`Agent 可读取`:`已隔离`]})]}),!c&&i?.editable===!1&&(0,P.jsx)(`div`,{className:`skill-readonly-note`,children:`此技能由全局目录或插件提供,在此项目中只读。你仍可以为当前项目开启或关闭它。`}),(0,P.jsxs)(`div`,{className:`skill-form`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`名称 `,(0,P.jsx)(`small`,{children:`小写字母、数字和连字符`})]}),(0,P.jsx)(`input`,{value:o.name,disabled:!c,onChange:e=>s({...o,name:e.target.value}),placeholder:`code-review`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`描述 `,(0,P.jsx)(`small`,{children:`帮助 Agent 判断何时使用`})]}),(0,P.jsx)(`textarea`,{rows:3,value:o.description,disabled:!c&&!i?.editable,onChange:e=>s({...o,description:e.target.value}),placeholder:`在提交代码前检查正确性、安全性与可维护性`})]}),(0,P.jsxs)(`label`,{className:`skill-instructions`,children:[(0,P.jsxs)(`span`,{children:[`SKILL.md 指令 `,(0,P.jsx)(`small`,{children:`支持 Markdown`})]}),(0,P.jsx)(`textarea`,{value:o.body,disabled:!c&&!i?.editable,onChange:e=>s({...o,body:e.target.value}),spellCheck:!1})]}),(0,P.jsxs)(`label`,{className:`manual-invocation`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:!!o.disableModelInvocation,disabled:!c&&!i?.editable,onChange:e=>s({...o,disableModelInvocation:e.target.checked})}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:`仅允许手动调用`}),(0,P.jsxs)(`small`,{children:[`开启技能,但不让 Agent 自动匹配;仍可通过 /`,o.name||`skill-name`,` 调用。`]})]})]})]}),(0,P.jsxs)(`footer`,{className:`skill-editor-actions`,children:[!c&&i?.editable&&(0,P.jsx)(`button`,{className:`skill-delete`,onClick:()=>v(!0),children:`删除技能`}),c&&(0,P.jsx)(`button`,{onClick:()=>{l(!1),S()},children:`取消`}),(c||i?.editable)&&(0,P.jsx)(`button`,{className:`skill-save`,disabled:!x||f||!o.name.trim()||!o.description.trim()||!o.body.trim(),onClick:()=>void ne(),children:f?`正在保存…`:c?`创建技能`:`保存更改`})]})]})})]}),g&&i!==void 0&&(0,P.jsx)(`div`,{className:`skill-delete-layer`,children:(0,P.jsxs)(`div`,{className:`skill-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`skill-delete-title`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`删除项目技能`}),(0,P.jsxs)(`h2`,{id:`skill-delete-title`,children:[`删除“`,i.name,`”?`]}),(0,P.jsx)(`small`,{children:`技能目录及其中的资源会被永久删除,此操作无法撤销。`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:()=>v(!1),children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ie(),children:f?`正在删除…`:`删除技能`})]})]})]})})]})}var Vl={user:{label:`用户偏好`,hint:`长期稳定的角色、表达和工作偏好`},feedback:{label:`行为反馈`,hint:`希望 Agent 以后持续遵守的纠正`},project:{label:`项目约定`,hint:`不能只靠代码推导出的规则和决策`},reference:{label:`外部引用`,hint:`以后仍会用到的文档或系统入口`}},Hl={enabled:!0,path:``,entries:[]},Ul={type:`project`,content:``};function Wl({onClose:e,onError:t}){let[n,r]=(0,_.useState)(Hl),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Ul),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`all`),[y,b]=(0,_.useState)(!1),x=e=>t(e instanceof Error?e.message:String(e)),ee=(0,_.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return n.entries.filter(t=>(g===`all`||t.type===g)&&(e.length===0||t.content.toLocaleLowerCase().includes(e)||t.id.includes(e)))},[g,m,n.entries]),S=c?o.content.trim().length>0:i!==void 0&&(o.type!==i.type||o.content!==i.content),C=(e,t)=>{let n=e.entries.find(e=>e.id===t)??e.entries.find(e=>e.id===i?.id)??e.entries[0];a(n),s(n===void 0?Ul:{type:n.type,content:n.content})},te=async e=>{let t=await window.flavorDesktop.listMemory();return r(t),C(t,e),t};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listMemory().then(t=>{e&&(r(t),C(t))}).catch(x).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let ne=()=>{l(!0),a(void 0),s(Ul),b(!1)},re=e=>{l(!1),a(e),s({type:e.type,content:e.content}),b(!1)},ie=async()=>{if(!(f||o.content.trim().length===0)){p(!0);try{let e=c?await window.flavorDesktop.createMemory(o):await window.flavorDesktop.updateMemory(i.id,o);l(!1),await te(e.id)}catch(e){x(e)}finally{p(!1)}}},ae=async()=>{if(!(i===void 0||f)){p(!0);try{if(!await window.flavorDesktop.deleteMemory(i.id))throw Error(`这条记忆已不存在,请重新载入后再试。`);b(!1),a(void 0),s(Ul),await te()}catch(e){x(e)}finally{p(!1)}}};return(0,P.jsxs)(`section`,{className:`memory-workbench`,"aria-label":`长期记忆管理`,children:[(0,P.jsxs)(`header`,{className:`memory-workbench-header`,children:[(0,P.jsxs)(`div`,{className:`memory-heading`,children:[(0,P.jsx)(`button`,{className:`memory-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`项目上下文`}),(0,P.jsx)(`h1`,{children:`长期记忆`})]})]}),(0,P.jsxs)(`div`,{className:`memory-ledger-status`,"data-enabled":n.enabled,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:n.entries.length}),` 条已保存`]})]})]}),(0,P.jsxs)(`div`,{className:`memory-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`memory-catalog`,children:[(0,P.jsxs)(`div`,{className:`memory-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{"aria-label":`搜索记忆`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索记忆`})]}),(0,P.jsxs)(`button`,{className:`memory-create`,onClick:ne,disabled:!n.enabled,children:[(0,P.jsx)(`span`,{children:`+`}),` 新建记忆`]})]}),(0,P.jsxs)(`div`,{className:`memory-index`,"aria-label":`按类型筛选`,children:[(0,P.jsxs)(`button`,{"data-active":g===`all`,onClick:()=>v(`all`),children:[(0,P.jsx)(`span`,{children:`全部`}),(0,P.jsx)(`b`,{children:n.entries.length})]}),dl.map(e=>(0,P.jsxs)(`button`,{"data-type":e,"data-active":g===e,onClick:()=>v(e),children:[(0,P.jsx)(`span`,{children:Vl[e].label}),(0,P.jsx)(`b`,{children:n.entries.filter(t=>t.type===e).length})]},e))]}),(0,P.jsxs)(`div`,{className:`memory-list`,"aria-busy":u,children:[u&&(0,P.jsx)(`p`,{className:`memory-list-empty`,children:`正在读取记忆…`}),!u&&!n.enabled&&(0,P.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,P.jsx)(`strong`,{children:`长期记忆已关闭`}),(0,P.jsx)(`span`,{children:`在项目配置中将 memory.enabled 设为 true 后可维护。`})]}),!u&&n.enabled&&ee.length===0&&(0,P.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,P.jsx)(`strong`,{children:n.entries.length===0?`还没有长期记忆`:`没有匹配项`}),(0,P.jsx)(`span`,{children:n.entries.length===0?`新建一条明确、稳定、以后仍有用的信息。`:`尝试其他关键词或类型。`})]}),ee.map(e=>(0,P.jsxs)(`button`,{className:`memory-card`,"data-selected":!c&&i?.id===e.id,"data-type":e.type,onClick:()=>re(e),children:[(0,P.jsx)(`span`,{className:`memory-card-tab`,children:Vl[e.type].label}),(0,P.jsx)(`strong`,{children:e.content}),(0,P.jsx)(`code`,{children:e.id})]},e.id))]}),(0,P.jsxs)(`p`,{className:`memory-catalog-note`,children:[`存储于 `,(0,P.jsx)(`code`,{children:n.path||`.flavor/memory/MEMORY.md`})]})]}),(0,P.jsx)(`main`,{className:`memory-editor`,children:n.enabled?i===void 0&&!c?(0,P.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,P.jsx)(`span`,{children:`⌁`}),(0,P.jsx)(`h2`,{children:`建立项目的共同记忆`}),(0,P.jsx)(`p`,{children:`保存少量稳定事实。当前指令和仓库内容始终优先。`}),(0,P.jsx)(`button`,{onClick:ne,children:`新建第一条记忆`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`memory-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`新记忆`:`记忆 ${i?.id}`}),(0,P.jsx)(`h2`,{children:c?`记录一件以后仍有用的事`:Vl[o.type].label})]}),(0,P.jsx)(`span`,{className:`memory-type-seal`,"data-type":o.type,children:o.type})]}),(0,P.jsxs)(`div`,{className:`memory-priority-note`,children:[(0,P.jsx)(`span`,{children:`i`}),(0,P.jsx)(`p`,{children:`记忆是历史背景,不是强制指令。新建或修改后,从下一次模型请求开始生效。`})]}),(0,P.jsxs)(`div`,{className:`memory-form`,children:[(0,P.jsxs)(`fieldset`,{children:[(0,P.jsx)(`legend`,{children:`记忆类型`}),(0,P.jsx)(`div`,{className:`memory-type-options`,children:dl.map(e=>(0,P.jsxs)(`label`,{"data-type":e,"data-selected":o.type===e,children:[(0,P.jsx)(`input`,{type:`radio`,name:`memory-type`,value:e,checked:o.type===e,onChange:()=>s({...o,type:e})}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:Vl[e].label}),(0,P.jsx)(`small`,{children:Vl[e].hint})]})]},e))})]}),(0,P.jsxs)(`label`,{className:`memory-content-field`,children:[(0,P.jsxs)(`span`,{children:[`内容 `,(0,P.jsx)(`small`,{children:`只写一件事,避免密码、Token 和临时任务状态`})]}),(0,P.jsx)(`textarea`,{autoFocus:!0,value:o.content,maxLength:2e4,onChange:e=>s({...o,content:e.target.value}),placeholder:`例如:不要在未明确要求时创建 Git 提交。`}),(0,P.jsxs)(`em`,{children:[o.content.length,` 字符`]})]})]}),(0,P.jsxs)(`footer`,{className:`memory-editor-actions`,children:[!c&&(0,P.jsx)(`button`,{className:`memory-delete`,onClick:()=>b(!0),children:`删除记忆`}),c&&(0,P.jsx)(`button`,{onClick:()=>{l(!1),te()},children:`取消`}),(0,P.jsx)(`button`,{className:`memory-save`,disabled:!S||f||o.content.trim().length===0,onClick:()=>void ie(),children:f?`正在保存…`:c?`保存记忆`:`保存更改`})]})]}):(0,P.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,P.jsx)(`span`,{children:`⊘`}),(0,P.jsx)(`h2`,{children:`长期记忆没有启用`}),(0,P.jsx)(`p`,{children:`启用后才能读取和修改项目记忆。`})]})})]}),y&&i!==void 0&&(0,P.jsx)(`div`,{className:`memory-delete-layer`,children:(0,P.jsxs)(`div`,{className:`memory-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`memory-delete-title`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`删除长期记忆`}),(0,P.jsxs)(`h2`,{id:`memory-delete-title`,children:[`删除这条`,Vl[i.type].label,`?`]}),(0,P.jsx)(`small`,{children:i.content}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:()=>b(!1),children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ae(),children:f?`正在删除…`:`删除记忆`})]})]})]})})]})}var Gl={name:``,transport:`stdio`,enabled:!0,command:``,args:``,env:``,cwd:``,url:``,headers:``,timeoutMs:`60000`};function Kl({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Gl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``?n:n.filter(t=>t.name.toLowerCase().includes(e)||t.transport.includes(e))},[m,n]),b=async e=>{let t=await window.flavorDesktop.listMcpServers();r(t);let n=t.find(t=>t.name===e)??t.find(e=>e.name===i)??t[0];n===void 0?t.length===0&&a(void 0):(a(n.name),s(ql(n)))};(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listMcpServers().then(t=>{if(e)return;r(t);let n=t[0];n!==void 0&&(a(n.name),s(ql(n)))}).catch(n=>{e||t(eu(n))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[]);let x=e=>{l(!1),a(e.name),s(ql(e))},ee=()=>{l(!0),a(void 0),s(Gl)},S=async()=>{p(!0);try{let e=await window.flavorDesktop.saveMcpServer(c?void 0:i,Jl(o));l(!1),a(e.name),await b(e.name)}catch(e){t(eu(e))}finally{p(!1)}},C=async(e,n)=>{try{let t=await window.flavorDesktop.setMcpServerEnabled(e.name,n);r(e=>e.map(e=>e.name===t.name?t:e)),i===t.name&&s(ql(t))}catch(e){t(eu(e))}},te=async()=>{let e=g;if(e!==void 0){p(!0);try{await window.flavorDesktop.deleteMcpServer(e.name),v(void 0),l(!1),a(void 0),s(Gl),await b()}catch(e){t(eu(e))}finally{p(!1)}}},ne=n.find(e=>e.name===i);return(0,P.jsxs)(`section`,{className:`mcp-workbench`,"aria-label":`MCP 服务管理`,children:[(0,P.jsxs)(`header`,{className:`mcp-workbench-header`,children:[(0,P.jsxs)(`div`,{className:`mcp-heading`,children:[(0,P.jsx)(`button`,{className:`mcp-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`PROJECT CONNECTIONS`}),(0,P.jsx)(`h1`,{children:`MCP 服务`})]})]}),(0,P.jsxs)(`div`,{className:`mcp-health`,children:[(0,P.jsx)(`i`,{}),`项目配置 `,(0,P.jsx)(`strong`,{children:n.filter(e=>e.enabled).length}),` 已开启`]})]}),(0,P.jsxs)(`div`,{className:`mcp-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`mcp-catalog`,children:[(0,P.jsxs)(`div`,{className:`mcp-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索服务`,"aria-label":`搜索服务`})]}),(0,P.jsxs)(`button`,{className:`mcp-create`,onClick:ee,children:[(0,P.jsx)(`span`,{children:`+`}),`添加服务`]})]}),(0,P.jsx)(`div`,{className:`mcp-list`,children:u?(0,P.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,P.jsx)(`strong`,{children:`正在读取项目配置`}),(0,P.jsx)(`span`,{children:`.flavor/flavor.json`})]}):y.length===0?(0,P.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,P.jsx)(`strong`,{children:m?`没有匹配的服务`:`还没有项目 MCP 服务`}),(0,P.jsx)(`span`,{children:m?`尝试其他名称或传输类型`:`添加 stdio 或 Streamable HTTP 服务`})]}):y.map(e=>(0,P.jsxs)(`div`,{className:`mcp-list-item`,"data-selected":!c&&i===e.name,"data-transport":e.transport,"data-enabled":e.enabled,children:[(0,P.jsxs)(`button`,{className:`mcp-select`,onClick:()=>x(e),children:[(0,P.jsx)(`span`,{className:`mcp-transport-glyph`,children:e.transport===`stdio`?`>_`:`↗`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.transport===`stdio`?Ql(e.config):$l(e.config)})]})]}),(0,P.jsxs)(`label`,{className:`mcp-toggle`,title:e.enabled?`关闭服务`:`开启服务`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void C(e,t.target.checked),"aria-label":`${e.enabled?`关闭`:`开启`} ${e.name}`}),(0,P.jsx)(`span`,{})]})]},e.name))}),(0,P.jsxs)(`p`,{className:`mcp-catalog-note`,children:[`仅管理项目配置 `,(0,P.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,P.jsx)(`article`,{className:`mcp-editor`,children:c||ne!==void 0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mcp-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`NEW CONNECTION`:`SERVICE CONFIGURATION`}),(0,P.jsx)(`h2`,{children:c?`添加 MCP 服务`:i})]}),(0,P.jsx)(`span`,{className:`mcp-transport-seal`,"data-transport":o.transport,children:o.transport})]}),(0,P.jsxs)(`div`,{className:`mcp-lifecycle-note`,children:[(0,P.jsx)(`span`,{children:`↻`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`从下一个任务开始生效`}),(0,P.jsx)(`small`,{children:`现有对话不会因配置更改而中断。`})]})]}),(0,P.jsxs)(`form`,{className:`mcp-form`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,P.jsxs)(`div`,{className:`mcp-form-grid`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`服务名称 `,(0,P.jsx)(`small`,{children:`字母、数字、_ 或 -`})]}),(0,P.jsx)(`input`,{value:o.name,onChange:e=>s({...o,name:e.target.value}),required:!0,pattern:`[A-Za-z0-9_-]+`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`传输方式`}),(0,P.jsxs)(`select`,{value:o.transport,onChange:e=>s({...o,transport:e.target.value}),children:[(0,P.jsx)(`option`,{value:`stdio`,children:`stdio · 本地进程`}),(0,P.jsx)(`option`,{value:`http`,children:`HTTP · 远程服务`})]})]})]}),o.transport===`stdio`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`启动命令`}),(0,P.jsx)(`input`,{value:o.command,onChange:e=>s({...o,command:e.target.value}),placeholder:`npx`,required:!0})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`参数 `,(0,P.jsx)(`small`,{children:`每行一个参数`})]}),(0,P.jsx)(`textarea`,{rows:4,value:o.args,onChange:e=>s({...o,args:e.target.value}),placeholder:`-y
138
138
  @modelcontextprotocol/server-filesystem
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="light" />
7
7
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:* http://localhost:* ws://127.0.0.1:* ws://localhost:*; frame-src http://127.0.0.1:* http://localhost:*" />
8
8
  <title>Flavor Code</title>
9
- <script type="module" crossorigin src="./assets/index-sgEm4kjf.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-CcD0D6x0.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="./assets/index-CPxt3vFY.css">
11
11
  </head>
12
12
  <body>
@@ -0,0 +1,21 @@
1
+ export declare const PLUGIN_DIR: string;
2
+ export declare const VERSIONS_DIR: string;
3
+ /** Sanitize a tool name into a valid fix-plugin dir name (letters/digits/-). */
4
+ export declare function sanitizePluginName(tool: string): string;
5
+ export declare function fixPluginDir(workspace: string, name: string): string;
6
+ /** Scaffold a fix-plugin directory (idempotent — never overwrites existing work). */
7
+ export declare function scaffoldFixPlugin(workspace: string, name: string): Promise<string>;
8
+ export interface FixPluginVerifyReport {
9
+ ok: boolean;
10
+ /** "name@version" of the loaded plugin. */
11
+ provided: string[];
12
+ tools: string[];
13
+ commands: string[];
14
+ error?: string;
15
+ }
16
+ /** Dry-run a plugin in a shadow PluginHost sandbox. The real host is untouched. */
17
+ export declare function verifyFixPlugin(workspace: string, name: string): Promise<FixPluginVerifyReport>;
18
+ /** Copy the current plugin dir into .versions/<name>/<timestamp>/. */
19
+ export declare function snapshotFixPlugin(workspace: string, name: string): Promise<string>;
20
+ /** Restore the latest good snapshot of a plugin dir. */
21
+ export declare function revertFixPlugin(workspace: string, name: string): Promise<string>;
@@ -0,0 +1,37 @@
1
+ import { HookBus } from "../hooks/bus.js";
2
+ import { PluginHost } from "../plugins/host.js";
3
+ import type { ToolDefinition } from "../tools/types.js";
4
+ import { fixPluginDir } from "./loader.js";
5
+ import { EvolveStore, type EvolveSuggestion } from "./store.js";
6
+ export interface EvolveServiceOptions {
7
+ workspace: string;
8
+ hooks: HookBus;
9
+ /** Real host plugin loader; required only for the reload subcommand. */
10
+ pluginHost?: PluginHost;
11
+ config?: {
12
+ promptTop?: number;
13
+ minRepeats?: number;
14
+ testCommand?: string;
15
+ testTimeoutMs?: number;
16
+ };
17
+ logger?: {
18
+ warn: (message: string) => void;
19
+ /** User-visible notification (rendered as a notice in the session). */
20
+ notice?: (message: string) => void;
21
+ };
22
+ }
23
+ export interface EvolveService {
24
+ readonly store: EvolveStore;
25
+ suggestions(): Promise<EvolveSuggestion[]>;
26
+ /** Synchronous system-prompt section (cached after every capture). */
27
+ promptSection(): string | undefined;
28
+ /** Reset per-run counters; call when a loop worker starts. */
29
+ beginRun(): void;
30
+ /** Append a reflection, emit LoopEnd, and reset counters. */
31
+ endRun(reason?: string): Promise<void>;
32
+ handleCommand(args: readonly string[]): Promise<string>;
33
+ toolDefinition(): ToolDefinition<unknown>;
34
+ dispose(): void;
35
+ }
36
+ export declare function createEvolveService(options: EvolveServiceOptions): EvolveService;
37
+ export { fixPluginDir };