@kleo.so/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/dist/kleo.js +140 -0
  4. package/package.json +30 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kleo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # Kleo CLI
2
+
3
+ The Kleo CLI lets you work with your Kleo workspace from the terminal. You can read your knowledge base, swipe file, templates, posts, and agent memory, review your content strategy, and hand a full task to the Kleo agent without opening the web app.
4
+
5
+ ## How it works
6
+
7
+ The CLI is a small client for the Model Context Protocol (MCP). When you run a command, it opens a session with Kleo's own MCP server at `/api/mcp/mcp`, calls one of the tools that server exposes, and prints the result. Those tools are the same ones the web app, the WhatsApp agent, and the Claude and Cursor connectors use, so the CLI does not reimplement any of that logic. It only sends requests and formats what comes back.
8
+
9
+ Every request carries your API key as a bearer token. Because the CLI talks to the server over the network, it never touches the database or any server secret. All it needs is your key and the address of the server.
10
+
11
+ ## Requirements
12
+
13
+ You need Node.js version 18 or later. The server you connect to must have the MCP feature enabled, which means it was deployed with `NEXT_PUBLIC_ENABLE_MCP=true`.
14
+
15
+ ## Getting an API key
16
+
17
+ Sign in to Kleo, open Settings, and go to the MCP section to create a key. You can also create one by sending a POST request to `/api/mcp/keys` while signed in. A key looks like `kleo_sk_` followed by a long random string. Each key carries a read scope, a write scope, or both, and the full value is shown only once, so copy it when it appears.
18
+
19
+ Read commands such as `kb`, `swipe`, `template`, `post`, `memory`, `strategy`, and `whoami` need a key with the read scope. The `agent` command and any command that writes data need a key with both the read and write scopes. If a key is missing a scope, the server returns a clear message telling you which scope the tool requires.
20
+
21
+ ## Installing
22
+
23
+ Most people do not need to install anything. If you have Node.js, you can run the CLI straight from npm:
24
+
25
+ ```bash
26
+ npx @kleo.so/cli login --key kleo_sk_yourkey
27
+ npx @kleo.so/cli kb list
28
+ ```
29
+
30
+ If you use the CLI often, install it once so that the `kleo` command is always available:
31
+
32
+ ```bash
33
+ npm install -g @kleo.so/cli
34
+ kleo whoami
35
+ ```
36
+
37
+ If you are working inside this repository instead of the published package, run it through the local scripts. From the repository root, use `pnpm kleo <command>`. From inside the `cli` folder, use `pnpm dev <command>`.
38
+
39
+ ## Signing in
40
+
41
+ Save your key and, if needed, the server address with the `login` command. This writes a small configuration file to `~/.kleo/config.json` with permissions set so that only you can read it.
42
+
43
+ ```bash
44
+ kleo login --key kleo_sk_yourkey --url https://app.kleo.so
45
+ ```
46
+
47
+ The server address defaults to `https://app.kleo.so`. When you are pointing at a local development server, pass `--url http://localhost:3000` instead.
48
+
49
+ The CLI decides which key and address to use by checking four sources in order and taking the first one it finds. It starts with the `--key` and `--url` flags on the command line. If those are absent, it reads the `KLEO_API_KEY` and `KLEO_API_URL` environment variables. If those are also absent, it reads the configuration file written by `login`. If nothing else is set, it falls back to the default address. This means you can keep a key in the config file for everyday use and still override it for a single command with a flag or an environment variable.
50
+
51
+ ## Commands
52
+
53
+ The command reference below groups the commands by area. Angle brackets mark values you supply, and square brackets mark optional parts.
54
+
55
+ ```
56
+ Account
57
+ kleo login --key <key> [--url <url>] Save your key and server address
58
+ kleo logout Remove the saved credentials
59
+ kleo config Show the current server and a masked key
60
+ kleo whoami Show the user and profile the key acts as
61
+
62
+ Knowledge base
63
+ kleo kb list List every item with its id, title, type, and a short preview
64
+ kleo kb search <query> Search across the content of your knowledge base
65
+ kleo kb read <id> Print the full text of one item
66
+
67
+ Swipe file
68
+ kleo swipe list List every saved post
69
+ kleo swipe search <query> Search across your swipes
70
+ kleo swipe read <id> Print the full text of one swipe
71
+
72
+ Templates
73
+ kleo template list List your templates and the Kleo library
74
+ kleo template search <query> Search across your templates
75
+ kleo template read <id> Print the full text of one template
76
+
77
+ Posts
78
+ kleo post list List scheduled and published posts
79
+ kleo post read <id> Print the full content of one post
80
+
81
+ Memory
82
+ kleo memory view Show the index of what Kleo has learned about you
83
+ kleo memory search <query> Search your memory
84
+ kleo memory read <path> Read one memory file, for example voice/style.md
85
+
86
+ Strategy
87
+ kleo strategy Show your offers, audiences, content strategy, and content plan
88
+
89
+ Agent and direct tool access
90
+ kleo agent "<task>" [--chat <id>] Hand a full task to the Kleo agent
91
+ kleo tools List every tool the server exposes
92
+ kleo call <tool> [--input '<json>'] [key=value ...] Call any tool by name
93
+ ```
94
+
95
+ Several flags apply to any command. Use `--url` and `--key` to override the saved server address and key for a single run. Use `--limit` to cap how many results a list or search returns. Use `--json` to print the raw response instead of formatted text, which is useful when you pipe the output into another tool. Use `-h` or `--help` to see the built in help.
96
+
97
+ ## Examples
98
+
99
+ ```bash
100
+ kleo whoami
101
+ kleo kb search "cold outbound" --limit 3
102
+ kleo swipe read 6f1e2a90-1234-4c56-8899-aabbccddeeff
103
+ kleo memory read voice/style.md
104
+ kleo strategy --json
105
+ kleo agent "turn my latest knowledge base note on pricing into a LinkedIn post"
106
+ kleo call searchTemplates --input '{"query":"hook","limit":5}'
107
+ ```
108
+
109
+ The `agent` command runs the full Kleo agent and returns a chat id along with the result. Pass that id back with `--chat` on your next call to continue the same conversation, and you can open the same chat in the web app to keep working there.
110
+
111
+ ## Building and publishing
112
+
113
+ This section is for maintainers who publish the package. The CLI ships as a single JavaScript file. The `build.mjs` script uses esbuild to bundle the source and all of its dependencies, including the MCP SDK, into `dist/kleo.js`, and it adds a `#!/usr/bin/env node` line so the file runs directly. Because everything is bundled, the published package has no runtime dependencies and starts quickly under `npx`.
114
+
115
+ To build and publish:
116
+
117
+ ```bash
118
+ cd cli
119
+ pnpm install
120
+ pnpm build
121
+ npm pack
122
+ npm publish --access public
123
+ ```
124
+
125
+ Run `pnpm build` to produce `dist/kleo.js`, then `npm pack` if you want to inspect the tarball before you publish. The tarball contains only the built file, this README, and `package.json`. The `npm publish` step rebuilds the bundle first through the `prepublishOnly` script.
126
+
127
+ Two details are worth noting. The package name `@kleo.so/cli` assumes an npm organization that you control, so change the `name` field in `package.json` if you publish under a different scope. The command that users type is `kleo`, which comes from the `bin` field and does not depend on the package name. Remember to raise the `version` field before each publish.
package/dist/kleo.js ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'node:module';
3
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
4
+ import { dirname as __dirname_fn } from 'node:path';
5
+ const require = __createRequire(import.meta.url);
6
+ const __filename = __fileURLToPath(import.meta.url);
7
+ const __dirname = __dirname_fn(__filename);
8
+ var u_=Object.create;var bs=Object.defineProperty;var l_=Object.getOwnPropertyDescriptor;var d_=Object.getOwnPropertyNames;var p_=Object.getPrototypeOf,f_=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zs=(e,t)=>{for(var r in t)bs(e,r,{get:t[r],enumerable:!0})},m_=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d_(t))!f_.call(e,n)&&n!==r&&bs(e,n,{get:()=>t[n],enumerable:!(o=l_(t,n))||o.enumerable});return e};var su=(e,t,r)=>(r=e!=null?u_(p_(e)):{},m_(t||!e||!e.__esModule?bs(r,"default",{value:e,enumerable:!0}):r,e));var io=S(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.regexpCode=V.getEsmExportName=V.getProperty=V.safeStringify=V.stringify=V.strConcat=V.addCodeArg=V.str=V._=V.nil=V._Code=V.Name=V.IDENTIFIER=V._CodeOrName=void 0;var no=class{};V._CodeOrName=no;V.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Mt=class extends no{constructor(t){if(super(),!V.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};V.Name=Mt;var Ue=class extends no{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,o)=>`${r}${o}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,o)=>(o instanceof Mt&&(r[o.str]=(r[o.str]||0)+1),r),{})}};V._Code=Ue;V.nil=new Ue("");function Ff(e,...t){let r=[e[0]],o=0;for(;o<t.length;)Gi(r,t[o]),r.push(e[++o]);return new Ue(r)}V._=Ff;var Wi=new Ue("+");function Vf(e,...t){let r=[so(e[0])],o=0;for(;o<t.length;)r.push(Wi),Gi(r,t[o]),r.push(Wi,so(e[++o]));return A$(r),new Ue(r)}V.str=Vf;function Gi(e,t){t instanceof Ue?e.push(...t._items):t instanceof Mt?e.push(t):e.push(j$(t))}V.addCodeArg=Gi;function A$(e){let t=1;for(;t<e.length-1;){if(e[t]===Wi){let r=C$(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function C$(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Mt||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Mt))return`"${e}${t.slice(1)}`}function N$(e,t){return t.emptyStr()?e:e.emptyStr()?t:Vf`${e}${t}`}V.strConcat=N$;function j$(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:so(Array.isArray(e)?e.join(","):e)}function Z$(e){return new Ue(so(e))}V.stringify=Z$;function so(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}V.safeStringify=so;function q$(e){return typeof e=="string"&&V.IDENTIFIER.test(e)?new Ue(`.${e}`):Ff`[${e}]`}V.getProperty=q$;function M$(e){if(typeof e=="string"&&V.IDENTIFIER.test(e))return new Ue(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}V.getEsmExportName=M$;function D$(e){return new Ue(e.toString())}V.regexpCode=D$});var Xi=S(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.ValueScope=Ie.ValueScopeName=Ie.Scope=Ie.varKinds=Ie.UsedValueState=void 0;var Oe=io(),Yi=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Rn;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Rn||(Ie.UsedValueState=Rn={}));Ie.varKinds={const:new Oe.Name("const"),let:new Oe.Name("let"),var:new Oe.Name("var")};var On=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Oe.Name?t:this.name(t)}name(t){return new Oe.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,o;if(!((o=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||o===void 0)&&o.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ie.Scope=On;var In=class extends Oe.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:o}){this.value=t,this.scopePath=(0,Oe._)`.${new Oe.Name(r)}[${o}]`}};Ie.ValueScopeName=In;var U$=(0,Oe._)`\n`,Qi=class extends On{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?U$:Oe.nil}}get(){return this._scope}name(t){return new In(t,this._newName(t))}value(t,r){var o;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(t),{prefix:s}=n,i=(o=r.key)!==null&&o!==void 0?o:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,n);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,n.setValue(r,{property:s,itemIndex:u}),n}getValue(t,r){let o=this._values[t];if(o)return o.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,o=>{if(o.scopePath===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return(0,Oe._)`${t}${o.scopePath}`})}scopeCode(t=this._values,r,o){return this._reduceValues(t,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,o)}_reduceValues(t,r,o={},n){let s=Oe.nil;for(let i in t){let a=t[i];if(!a)continue;let c=o[i]=o[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Rn.Started);let l=r(u);if(l){let d=this.opts.es5?Ie.varKinds.var:Ie.varKinds.const;s=(0,Oe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=n?.(u))s=(0,Oe._)`${s}${l}${this.opts._n}`;else throw new Yi(u);c.set(u,Rn.Completed)})}return s}};Ie.ValueScope=Qi});var j=S(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.or=Z.and=Z.not=Z.CodeGen=Z.operators=Z.varKinds=Z.ValueScopeName=Z.ValueScope=Z.Scope=Z.Name=Z.regexpCode=Z.stringify=Z.getProperty=Z.nil=Z.strConcat=Z.str=Z._=void 0;var D=io(),Je=Xi(),St=io();Object.defineProperty(Z,"_",{enumerable:!0,get:function(){return St._}});Object.defineProperty(Z,"str",{enumerable:!0,get:function(){return St.str}});Object.defineProperty(Z,"strConcat",{enumerable:!0,get:function(){return St.strConcat}});Object.defineProperty(Z,"nil",{enumerable:!0,get:function(){return St.nil}});Object.defineProperty(Z,"getProperty",{enumerable:!0,get:function(){return St.getProperty}});Object.defineProperty(Z,"stringify",{enumerable:!0,get:function(){return St.stringify}});Object.defineProperty(Z,"regexpCode",{enumerable:!0,get:function(){return St.regexpCode}});Object.defineProperty(Z,"Name",{enumerable:!0,get:function(){return St.Name}});var jn=Xi();Object.defineProperty(Z,"Scope",{enumerable:!0,get:function(){return jn.Scope}});Object.defineProperty(Z,"ValueScope",{enumerable:!0,get:function(){return jn.ValueScope}});Object.defineProperty(Z,"ValueScopeName",{enumerable:!0,get:function(){return jn.ValueScopeName}});Object.defineProperty(Z,"varKinds",{enumerable:!0,get:function(){return jn.varKinds}});Z.operators={GT:new D._Code(">"),GTE:new D._Code(">="),LT:new D._Code("<"),LTE:new D._Code("<="),EQ:new D._Code("==="),NEQ:new D._Code("!=="),NOT:new D._Code("!"),OR:new D._Code("||"),AND:new D._Code("&&"),ADD:new D._Code("+")};var ut=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},ea=class extends ut{constructor(t,r,o){super(),this.varKind=t,this.name=r,this.rhs=o}render({es5:t,_n:r}){let o=t?Je.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${o} ${this.name}${n};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=gr(this.rhs,t,r)),this}get names(){return this.rhs instanceof D._CodeOrName?this.rhs.names:{}}},An=class extends ut{constructor(t,r,o){super(),this.lhs=t,this.rhs=r,this.sideEffects=o}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof D.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=gr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof D.Name?{}:{...this.lhs.names};return Nn(t,this.rhs)}},ta=class extends An{constructor(t,r,o,n){super(t,o,n),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},ra=class extends ut{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},oa=class extends ut{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},na=class extends ut{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},sa=class extends ut{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=gr(this.code,t,r),this}get names(){return this.code instanceof D._CodeOrName?this.code.names:{}}},ao=class extends ut{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,o)=>r+o.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let o=t[r].optimizeNodes();Array.isArray(o)?t.splice(r,1,...o):o?t[r]=o:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:o}=this,n=o.length;for(;n--;){let s=o[n];s.optimizeNames(t,r)||(L$(t,s.names),o.splice(n,1))}return o.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Lt(t,r.names),{})}},lt=class extends ao{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},ia=class extends ao{},hr=class extends lt{};hr.kind="else";var Dt=class e extends lt{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let o=r.optimizeNodes();r=this.else=Array.isArray(o)?new hr(o):o}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Hf(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var o;if(this.else=(o=this.else)===null||o===void 0?void 0:o.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=gr(this.condition,t,r),this}get names(){let t=super.names;return Nn(t,this.condition),this.else&&Lt(t,this.else.names),t}};Dt.kind="if";var Ut=class extends lt{};Ut.kind="for";var aa=class extends Ut{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=gr(this.iteration,t,r),this}get names(){return Lt(super.names,this.iteration.names)}},ca=class extends Ut{constructor(t,r,o,n){super(),this.varKind=t,this.name=r,this.from=o,this.to=n}render(t){let r=t.es5?Je.varKinds.var:this.varKind,{name:o,from:n,to:s}=this;return`for(${r} ${o}=${n}; ${o}<${s}; ${o}++)`+super.render(t)}get names(){let t=Nn(super.names,this.from);return Nn(t,this.to)}},Cn=class extends Ut{constructor(t,r,o,n){super(),this.loop=t,this.varKind=r,this.name=o,this.iterable=n}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=gr(this.iterable,t,r),this}get names(){return Lt(super.names,this.iterable.names)}},co=class extends lt{constructor(t,r,o){super(),this.name=t,this.args=r,this.async=o}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};co.kind="func";var uo=class extends ao{render(t){return"return "+super.render(t)}};uo.kind="return";var ua=class extends lt{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var o,n;return super.optimizeNames(t,r),(o=this.catch)===null||o===void 0||o.optimizeNames(t,r),(n=this.finally)===null||n===void 0||n.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Lt(t,this.catch.names),this.finally&&Lt(t,this.finally.names),t}},lo=class extends lt{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};lo.kind="catch";var po=class extends lt{render(t){return"finally"+super.render(t)}};po.kind="finally";var la=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
9
+ `:""},this._extScope=t,this._scope=new Je.Scope({parent:t}),this._nodes=[new ia]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let o=this._extScope.value(t,r);return(this._values[o.prefix]||(this._values[o.prefix]=new Set)).add(o),o}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,o,n){let s=this._scope.toName(r);return o!==void 0&&n&&(this._constants[s.str]=o),this._leafNode(new ea(t,s,o)),s}const(t,r,o){return this._def(Je.varKinds.const,t,r,o)}let(t,r,o){return this._def(Je.varKinds.let,t,r,o)}var(t,r,o){return this._def(Je.varKinds.var,t,r,o)}assign(t,r,o){return this._leafNode(new An(t,r,o))}add(t,r){return this._leafNode(new ta(t,Z.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==D.nil&&this._leafNode(new sa(t)),this}object(...t){let r=["{"];for(let[o,n]of t)r.length>1&&r.push(","),r.push(o),(o!==n||this.opts.es5)&&(r.push(":"),(0,D.addCodeArg)(r,n));return r.push("}"),new D._Code(r)}if(t,r,o){if(this._blockNode(new Dt(t)),r&&o)this.code(r).else().code(o).endIf();else if(r)this.code(r).endIf();else if(o)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Dt(t))}else(){return this._elseNode(new hr)}endIf(){return this._endBlockNode(Dt,hr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new aa(t),r)}forRange(t,r,o,n,s=this.opts.es5?Je.varKinds.var:Je.varKinds.let){let i=this._scope.toName(t);return this._for(new ca(s,i,r,o),()=>n(i))}forOf(t,r,o,n=Je.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof D.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,D._)`${i}.length`,a=>{this.var(s,(0,D._)`${i}[${a}]`),o(s)})}return this._for(new Cn("of",n,s,r),()=>o(s))}forIn(t,r,o,n=this.opts.es5?Je.varKinds.var:Je.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,D._)`Object.keys(${r})`,o);let s=this._scope.toName(t);return this._for(new Cn("in",n,s,r),()=>o(s))}endFor(){return this._endBlockNode(Ut)}label(t){return this._leafNode(new ra(t))}break(t){return this._leafNode(new oa(t))}return(t){let r=new uo;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(uo)}try(t,r,o){if(!r&&!o)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new ua;if(this._blockNode(n),this.code(t),r){let s=this.name("e");this._currNode=n.catch=new lo(s),r(s)}return o&&(this._currNode=n.finally=new po,this.code(o)),this._endBlockNode(lo,po)}throw(t){return this._leafNode(new na(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let o=this._nodes.length-r;if(o<0||t!==void 0&&o!==t)throw new Error(`CodeGen: wrong number of nodes: ${o} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=D.nil,o,n){return this._blockNode(new co(t,r,o)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(co)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let o=this._currNode;if(o instanceof t||r&&o instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Dt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};Z.CodeGen=la;function Lt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Nn(e,t){return t instanceof D._CodeOrName?Lt(e,t.names):e}function gr(e,t,r){if(e instanceof D.Name)return o(e);if(!n(e))return e;return new D._Code(e._items.reduce((s,i)=>(i instanceof D.Name&&(i=o(i)),i instanceof D._Code?s.push(...i._items):s.push(i),s),[]));function o(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function n(s){return s instanceof D._Code&&s._items.some(i=>i instanceof D.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function L$(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Hf(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,D._)`!${da(e)}`}Z.not=Hf;var F$=Kf(Z.operators.AND);function V$(...e){return e.reduce(F$)}Z.and=V$;var H$=Kf(Z.operators.OR);function K$(...e){return e.reduce(H$)}Z.or=K$;function Kf(e){return(t,r)=>t===D.nil?r:r===D.nil?t:(0,D._)`${da(t)} ${e} ${da(r)}`}function da(e){return e instanceof D.Name?e:(0,D._)`(${e})`}});var U=S(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.checkStrictMode=q.getErrorPath=q.Type=q.useFunc=q.setEvaluated=q.evaluatedPropsToName=q.mergeEvaluated=q.eachItem=q.unescapeJsonPointer=q.escapeJsonPointer=q.escapeFragment=q.unescapeFragment=q.schemaRefOrVal=q.schemaHasRulesButRef=q.schemaHasRules=q.checkUnknownRules=q.alwaysValidSchema=q.toHash=void 0;var G=j(),J$=io();function B$(e){let t={};for(let r of e)t[r]=!0;return t}q.toHash=B$;function W$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Wf(e,t),!Gf(t,e.self.RULES.all))}q.alwaysValidSchema=W$;function Wf(e,t=e.schema){let{opts:r,self:o}=e;if(!r.strictSchema||typeof t=="boolean")return;let n=o.RULES.keywords;for(let s in t)n[s]||Xf(e,`unknown keyword: "${s}"`)}q.checkUnknownRules=Wf;function Gf(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}q.schemaHasRules=Gf;function G$(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}q.schemaHasRulesButRef=G$;function Y$({topSchemaRef:e,schemaPath:t},r,o,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,G._)`${r}`}return(0,G._)`${e}${t}${(0,G.getProperty)(o)}`}q.schemaRefOrVal=Y$;function Q$(e){return Yf(decodeURIComponent(e))}q.unescapeFragment=Q$;function X$(e){return encodeURIComponent(fa(e))}q.escapeFragment=X$;function fa(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}q.escapeJsonPointer=fa;function Yf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}q.unescapeJsonPointer=Yf;function ew(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}q.eachItem=ew;function Jf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:o}){return(n,s,i,a)=>{let c=i===void 0?s:i instanceof G.Name?(s instanceof G.Name?e(n,s,i):t(n,s,i),i):s instanceof G.Name?(t(n,i,s),s):r(s,i);return a===G.Name&&!(c instanceof G.Name)?o(n,c):c}}q.mergeEvaluated={props:Jf({mergeNames:(e,t,r)=>e.if((0,G._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,G._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,G._)`${r} || {}`).code((0,G._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,G._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,G._)`${r} || {}`),ma(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Qf}),items:Jf({mergeNames:(e,t,r)=>e.if((0,G._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,G._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,G._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,G._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Qf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,G._)`{}`);return t!==void 0&&ma(e,r,t),r}q.evaluatedPropsToName=Qf;function ma(e,t,r){Object.keys(r).forEach(o=>e.assign((0,G._)`${t}${(0,G.getProperty)(o)}`,!0))}q.setEvaluated=ma;var Bf={};function tw(e,t){return e.scopeValue("func",{ref:t,code:Bf[t.code]||(Bf[t.code]=new J$._Code(t.code))})}q.useFunc=tw;var pa;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(pa||(q.Type=pa={}));function rw(e,t,r){if(e instanceof G.Name){let o=t===pa.Num;return r?o?(0,G._)`"[" + ${e} + "]"`:(0,G._)`"['" + ${e} + "']"`:o?(0,G._)`"/" + ${e}`:(0,G._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,G.getProperty)(e).toString():"/"+fa(e)}q.getErrorPath=rw;function Xf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}q.checkStrictMode=Xf});var dt=S(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});var $e=j(),ow={data:new $e.Name("data"),valCxt:new $e.Name("valCxt"),instancePath:new $e.Name("instancePath"),parentData:new $e.Name("parentData"),parentDataProperty:new $e.Name("parentDataProperty"),rootData:new $e.Name("rootData"),dynamicAnchors:new $e.Name("dynamicAnchors"),vErrors:new $e.Name("vErrors"),errors:new $e.Name("errors"),this:new $e.Name("this"),self:new $e.Name("self"),scope:new $e.Name("scope"),json:new $e.Name("json"),jsonPos:new $e.Name("jsonPos"),jsonLen:new $e.Name("jsonLen"),jsonPart:new $e.Name("jsonPart")};ha.default=ow});var fo=S(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.extendErrors=we.resetErrorsCount=we.reportExtraError=we.reportError=we.keyword$DataError=we.keywordError=void 0;var L=j(),Zn=U(),Se=dt();we.keywordError={message:({keyword:e})=>(0,L.str)`must pass "${e}" keyword validation`};we.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,L.str)`"${e}" keyword must be ${t} ($data)`:(0,L.str)`"${e}" keyword is invalid ($data)`};function nw(e,t=we.keywordError,r,o){let{it:n}=e,{gen:s,compositeRule:i,allErrors:a}=n,c=rm(e,t,r);o??(i||a)?em(s,c):tm(n,(0,L._)`[${c}]`)}we.reportError=nw;function sw(e,t=we.keywordError,r){let{it:o}=e,{gen:n,compositeRule:s,allErrors:i}=o,a=rm(e,t,r);em(n,a),s||i||tm(o,Se.default.vErrors)}we.reportExtraError=sw;function iw(e,t){e.assign(Se.default.errors,t),e.if((0,L._)`${Se.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,L._)`${Se.default.vErrors}.length`,t),()=>e.assign(Se.default.vErrors,null)))}we.resetErrorsCount=iw;function aw({gen:e,keyword:t,schemaValue:r,data:o,errsCount:n,it:s}){if(n===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",n,Se.default.errors,a=>{e.const(i,(0,L._)`${Se.default.vErrors}[${a}]`),e.if((0,L._)`${i}.instancePath === undefined`,()=>e.assign((0,L._)`${i}.instancePath`,(0,L.strConcat)(Se.default.instancePath,s.errorPath))),e.assign((0,L._)`${i}.schemaPath`,(0,L.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,L._)`${i}.schema`,r),e.assign((0,L._)`${i}.data`,o))})}we.extendErrors=aw;function em(e,t){let r=e.const("err",t);e.if((0,L._)`${Se.default.vErrors} === null`,()=>e.assign(Se.default.vErrors,(0,L._)`[${r}]`),(0,L._)`${Se.default.vErrors}.push(${r})`),e.code((0,L._)`${Se.default.errors}++`)}function tm(e,t){let{gen:r,validateName:o,schemaEnv:n}=e;n.$async?r.throw((0,L._)`new ${e.ValidationError}(${t})`):(r.assign((0,L._)`${o}.errors`,t),r.return(!1))}var Ft={keyword:new L.Name("keyword"),schemaPath:new L.Name("schemaPath"),params:new L.Name("params"),propertyName:new L.Name("propertyName"),message:new L.Name("message"),schema:new L.Name("schema"),parentSchema:new L.Name("parentSchema")};function rm(e,t,r){let{createErrors:o}=e.it;return o===!1?(0,L._)`{}`:cw(e,t,r)}function cw(e,t,r={}){let{gen:o,it:n}=e,s=[uw(n,r),lw(e,r)];return dw(e,t,s),o.object(...s)}function uw({errorPath:e},{instancePath:t}){let r=t?(0,L.str)`${e}${(0,Zn.getErrorPath)(t,Zn.Type.Str)}`:e;return[Se.default.instancePath,(0,L.strConcat)(Se.default.instancePath,r)]}function lw({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:o}){let n=o?t:(0,L.str)`${t}/${e}`;return r&&(n=(0,L.str)`${n}${(0,Zn.getErrorPath)(r,Zn.Type.Str)}`),[Ft.schemaPath,n]}function dw(e,{params:t,message:r},o){let{keyword:n,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;o.push([Ft.keyword,n],[Ft.params,typeof t=="function"?t(e):t||(0,L._)`{}`]),c.messages&&o.push([Ft.message,typeof r=="function"?r(e):r]),c.verbose&&o.push([Ft.schema,i],[Ft.parentSchema,(0,L._)`${l}${d}`],[Se.default.data,s]),u&&o.push([Ft.propertyName,u])}});var nm=S(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.boolOrEmptySchema=_r.topBoolOrEmptySchema=void 0;var pw=fo(),fw=j(),mw=dt(),hw={message:"boolean schema is false"};function gw(e){let{gen:t,schema:r,validateName:o}=e;r===!1?om(e,!1):typeof r=="object"&&r.$async===!0?t.return(mw.default.data):(t.assign((0,fw._)`${o}.errors`,null),t.return(!0))}_r.topBoolOrEmptySchema=gw;function _w(e,t){let{gen:r,schema:o}=e;o===!1?(r.var(t,!1),om(e)):r.var(t,!0)}_r.boolOrEmptySchema=_w;function om(e,t){let{gen:r,data:o}=e,n={gen:r,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,pw.reportError)(n,hw,void 0,t)}});var ga=S(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.getRules=yr.isJSONType=void 0;var yw=["string","number","integer","boolean","null","object","array"],vw=new Set(yw);function $w(e){return typeof e=="string"&&vw.has(e)}yr.isJSONType=$w;function ww(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}yr.getRules=ww});var _a=S(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.shouldUseRule=kt.shouldUseGroup=kt.schemaHasRulesForType=void 0;function bw({schema:e,self:t},r){let o=t.RULES.types[r];return o&&o!==!0&&sm(e,o)}kt.schemaHasRulesForType=bw;function sm(e,t){return t.rules.some(r=>im(e,r))}kt.shouldUseGroup=sm;function im(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(o=>e[o]!==void 0))}kt.shouldUseRule=im});var mo=S(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.reportTypeError=be.checkDataTypes=be.checkDataType=be.coerceAndCheckDataType=be.getJSONTypes=be.getSchemaTypes=be.DataType=void 0;var zw=ga(),xw=_a(),Sw=fo(),N=j(),am=U(),vr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(vr||(be.DataType=vr={}));function kw(e){let t=cm(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}be.getSchemaTypes=kw;function cm(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(zw.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}be.getJSONTypes=cm;function Pw(e,t){let{gen:r,data:o,opts:n}=e,s=Ew(t,n.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,xw.schemaHasRulesForType)(e,t[0]));if(i){let a=va(t,o,n.strictNumbers,vr.Wrong);r.if(a,()=>{s.length?Tw(e,t,s):$a(e)})}return i}be.coerceAndCheckDataType=Pw;var um=new Set(["string","number","integer","boolean","null"]);function Ew(e,t){return t?e.filter(r=>um.has(r)||t==="array"&&r==="array"):[]}function Tw(e,t,r){let{gen:o,data:n,opts:s}=e,i=o.let("dataType",(0,N._)`typeof ${n}`),a=o.let("coerced",(0,N._)`undefined`);s.coerceTypes==="array"&&o.if((0,N._)`${i} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>o.assign(n,(0,N._)`${n}[0]`).assign(i,(0,N._)`typeof ${n}`).if(va(t,n,s.strictNumbers),()=>o.assign(a,n))),o.if((0,N._)`${a} !== undefined`);for(let u of r)(um.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);o.else(),$a(e),o.endIf(),o.if((0,N._)`${a} !== undefined`,()=>{o.assign(n,a),Rw(e,a)});function c(u){switch(u){case"string":o.elseIf((0,N._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,N._)`"" + ${n}`).elseIf((0,N._)`${n} === null`).assign(a,(0,N._)`""`);return;case"number":o.elseIf((0,N._)`${i} == "boolean" || ${n} === null
10
+ || (${i} == "string" && ${n} && ${n} == +${n})`).assign(a,(0,N._)`+${n}`);return;case"integer":o.elseIf((0,N._)`${i} === "boolean" || ${n} === null
11
+ || (${i} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(a,(0,N._)`+${n}`);return;case"boolean":o.elseIf((0,N._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(a,!1).elseIf((0,N._)`${n} === "true" || ${n} === 1`).assign(a,!0);return;case"null":o.elseIf((0,N._)`${n} === "" || ${n} === 0 || ${n} === false`),o.assign(a,null);return;case"array":o.elseIf((0,N._)`${i} === "string" || ${i} === "number"
12
+ || ${i} === "boolean" || ${n} === null`).assign(a,(0,N._)`[${n}]`)}}}function Rw({gen:e,parentData:t,parentDataProperty:r},o){e.if((0,N._)`${t} !== undefined`,()=>e.assign((0,N._)`${t}[${r}]`,o))}function ya(e,t,r,o=vr.Correct){let n=o===vr.Correct?N.operators.EQ:N.operators.NEQ,s;switch(e){case"null":return(0,N._)`${t} ${n} null`;case"array":s=(0,N._)`Array.isArray(${t})`;break;case"object":s=(0,N._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,N._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,N._)`typeof ${t} ${n} ${e}`}return o===vr.Correct?s:(0,N.not)(s);function i(a=N.nil){return(0,N.and)((0,N._)`typeof ${t} == "number"`,a,r?(0,N._)`isFinite(${t})`:N.nil)}}be.checkDataType=ya;function va(e,t,r,o){if(e.length===1)return ya(e[0],t,r,o);let n,s=(0,am.toHash)(e);if(s.array&&s.object){let i=(0,N._)`typeof ${t} != "object"`;n=s.null?i:(0,N._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else n=N.nil;s.number&&delete s.integer;for(let i in s)n=(0,N.and)(n,ya(i,t,r,o));return n}be.checkDataTypes=va;var Ow={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,N._)`{type: ${e}}`:(0,N._)`{type: ${t}}`};function $a(e){let t=Iw(e);(0,Sw.reportError)(t,Ow)}be.reportTypeError=$a;function Iw(e){let{gen:t,data:r,schema:o}=e,n=(0,am.schemaRefOrVal)(e,o,"type");return{gen:t,keyword:"type",data:r,schema:o.type,schemaCode:n,schemaValue:n,parentSchema:o,params:{},it:e}}});var dm=S(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.assignDefaults=void 0;var $r=j(),Aw=U();function Cw(e,t){let{properties:r,items:o}=e.schema;if(t==="object"&&r)for(let n in r)lm(e,n,r[n].default);else t==="array"&&Array.isArray(o)&&o.forEach((n,s)=>lm(e,s,n.default))}qn.assignDefaults=Cw;function lm(e,t,r){let{gen:o,compositeRule:n,data:s,opts:i}=e;if(r===void 0)return;let a=(0,$r._)`${s}${(0,$r.getProperty)(t)}`;if(n){(0,Aw.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,$r._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,$r._)`${c} || ${a} === null || ${a} === ""`),o.if(c,(0,$r._)`${a} = ${(0,$r.stringify)(r)}`)}});var Le=S(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.validateUnion=J.validateArray=J.usePattern=J.callValidateCode=J.schemaProperties=J.allSchemaProperties=J.noPropertyInData=J.propertyInData=J.isOwnProperty=J.hasPropFunc=J.reportMissingProp=J.checkMissingProp=J.checkReportMissingProp=void 0;var ee=j(),wa=U(),Pt=dt(),Nw=U();function jw(e,t){let{gen:r,data:o,it:n}=e;r.if(za(r,o,t,n.opts.ownProperties),()=>{e.setParams({missingProperty:(0,ee._)`${t}`},!0),e.error()})}J.checkReportMissingProp=jw;function Zw({gen:e,data:t,it:{opts:r}},o,n){return(0,ee.or)(...o.map(s=>(0,ee.and)(za(e,t,s,r.ownProperties),(0,ee._)`${n} = ${s}`)))}J.checkMissingProp=Zw;function qw(e,t){e.setParams({missingProperty:t},!0),e.error()}J.reportMissingProp=qw;function pm(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ee._)`Object.prototype.hasOwnProperty`})}J.hasPropFunc=pm;function ba(e,t,r){return(0,ee._)`${pm(e)}.call(${t}, ${r})`}J.isOwnProperty=ba;function Mw(e,t,r,o){let n=(0,ee._)`${t}${(0,ee.getProperty)(r)} !== undefined`;return o?(0,ee._)`${n} && ${ba(e,t,r)}`:n}J.propertyInData=Mw;function za(e,t,r,o){let n=(0,ee._)`${t}${(0,ee.getProperty)(r)} === undefined`;return o?(0,ee.or)(n,(0,ee.not)(ba(e,t,r))):n}J.noPropertyInData=za;function fm(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}J.allSchemaProperties=fm;function Dw(e,t){return fm(t).filter(r=>!(0,wa.alwaysValidSchema)(e,t[r]))}J.schemaProperties=Dw;function Uw({schemaCode:e,data:t,it:{gen:r,topSchemaRef:o,schemaPath:n,errorPath:s},it:i},a,c,u){let l=u?(0,ee._)`${e}, ${t}, ${o}${n}`:t,d=[[Pt.default.instancePath,(0,ee.strConcat)(Pt.default.instancePath,s)],[Pt.default.parentData,i.parentData],[Pt.default.parentDataProperty,i.parentDataProperty],[Pt.default.rootData,Pt.default.rootData]];i.opts.dynamicRef&&d.push([Pt.default.dynamicAnchors,Pt.default.dynamicAnchors]);let f=(0,ee._)`${l}, ${r.object(...d)}`;return c!==ee.nil?(0,ee._)`${a}.call(${c}, ${f})`:(0,ee._)`${a}(${f})`}J.callValidateCode=Uw;var Lw=(0,ee._)`new RegExp`;function Fw({gen:e,it:{opts:t}},r){let o=t.unicodeRegExp?"u":"",{regExp:n}=t.code,s=n(r,o);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ee._)`${n.code==="new RegExp"?Lw:(0,Nw.useFunc)(e,n)}(${r}, ${o})`})}J.usePattern=Fw;function Vw(e){let{gen:t,data:r,keyword:o,it:n}=e,s=t.name("valid");if(n.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,ee._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:o,dataProp:u,dataPropType:wa.Type.Num},s),t.if((0,ee.not)(s),a)})}}J.validateArray=Vw;function Hw(e){let{gen:t,schema:r,keyword:o,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,wa.alwaysValidSchema)(n,c))&&!n.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:o,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,ee._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,ee.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}J.validateUnion=Hw});var gm=S(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.validateKeywordUsage=Xe.validSchemaType=Xe.funcKeywordCode=Xe.macroKeywordCode=void 0;var ke=j(),Vt=dt(),Kw=Le(),Jw=fo();function Bw(e,t){let{gen:r,keyword:o,schema:n,parentSchema:s,it:i}=e,a=t.macro.call(i.self,n,s,i),c=hm(r,o,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:ke.nil,errSchemaPath:`${i.errSchemaPath}/${o}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}Xe.macroKeywordCode=Bw;function Ww(e,t){var r;let{gen:o,keyword:n,schema:s,parentSchema:i,$data:a,it:c}=e;Yw(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=hm(o,n,u),d=o.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)_(),t.modifying&&mm(e),v(()=>e.error());else{let $=t.async?m():h();t.modifying&&mm(e),v(()=>Gw(e,$))}}function m(){let $=o.let("ruleErrs",null);return o.try(()=>_((0,ke._)`await `),k=>o.assign(d,!1).if((0,ke._)`${k} instanceof ${c.ValidationError}`,()=>o.assign($,(0,ke._)`${k}.errors`),()=>o.throw(k))),$}function h(){let $=(0,ke._)`${l}.errors`;return o.assign($,null),_(ke.nil),$}function _($=t.async?(0,ke._)`await `:ke.nil){let k=c.opts.passContext?Vt.default.this:Vt.default.self,z=!("compile"in t&&!a||t.schema===!1);o.assign(d,(0,ke._)`${$}${(0,Kw.callValidateCode)(e,l,k,z)}`,t.modifying)}function v($){var k;o.if((0,ke.not)((k=t.valid)!==null&&k!==void 0?k:d),$)}}Xe.funcKeywordCode=Ww;function mm(e){let{gen:t,data:r,it:o}=e;t.if(o.parentData,()=>t.assign(r,(0,ke._)`${o.parentData}[${o.parentDataProperty}]`))}function Gw(e,t){let{gen:r}=e;r.if((0,ke._)`Array.isArray(${t})`,()=>{r.assign(Vt.default.vErrors,(0,ke._)`${Vt.default.vErrors} === null ? ${t} : ${Vt.default.vErrors}.concat(${t})`).assign(Vt.default.errors,(0,ke._)`${Vt.default.vErrors}.length`),(0,Jw.extendErrors)(e)},()=>e.error())}function Yw({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function hm(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,ke.stringify)(r)})}function Qw(e,t,r=!1){return!t.length||t.some(o=>o==="array"?Array.isArray(e):o==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==o||r&&typeof e>"u")}Xe.validSchemaType=Qw;function Xw({schema:e,opts:t,self:r,errSchemaPath:o},n,s){if(Array.isArray(n.keyword)?!n.keyword.includes(s):n.keyword!==s)throw new Error("ajv implementation error");let i=n.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(n.validateSchema&&!n.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${o}": `+r.errorsText(n.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Xe.validateKeywordUsage=Xw});var ym=S(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.extendSubschemaMode=Et.extendSubschemaData=Et.getSubschema=void 0;var et=j(),_m=U();function eb(e,{keyword:t,schemaProp:r,schema:o,schemaPath:n,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&o!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,et._)`${e.schemaPath}${(0,et.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,et._)`${e.schemaPath}${(0,et.getProperty)(t)}${(0,et.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,_m.escapeFragment)(r)}`}}if(o!==void 0){if(n===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:o,schemaPath:n,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Et.getSubschema=eb;function tb(e,t,{dataProp:r,dataPropType:o,data:n,dataTypes:s,propertyName:i}){if(n!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,et._)`${t.data}${(0,et.getProperty)(r)}`,!0);c(f),e.errorPath=(0,et.str)`${u}${(0,_m.getErrorPath)(r,o,d.jsPropertySyntax)}`,e.parentDataProperty=(0,et._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(n!==void 0){let u=n instanceof et.Name?n:a.let("data",n,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Et.extendSubschemaData=tb;function rb(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:o,createErrors:n,allErrors:s}){o!==void 0&&(e.compositeRule=o),n!==void 0&&(e.createErrors=n),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Et.extendSubschemaMode=rb});var xa=S((JI,vm)=>{"use strict";vm.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var o,n,s;if(Array.isArray(t)){if(o=t.length,o!=r.length)return!1;for(n=o;n--!==0;)if(!e(t[n],r[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),o=s.length,o!==Object.keys(r).length)return!1;for(n=o;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[n]))return!1;for(n=o;n--!==0;){var i=s[n];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var wm=S((BI,$m)=>{"use strict";var Tt=$m.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var o=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};Mn(t,o,n,e,"",e)};Tt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Tt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Tt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Tt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Mn(e,t,r,o,n,s,i,a,c,u){if(o&&typeof o=="object"&&!Array.isArray(o)){t(o,n,s,i,a,c,u);for(var l in o){var d=o[l];if(Array.isArray(d)){if(l in Tt.arrayKeywords)for(var f=0;f<d.length;f++)Mn(e,t,r,d[f],n+"/"+l+"/"+f,s,n,l,o,f)}else if(l in Tt.propsKeywords){if(d&&typeof d=="object")for(var m in d)Mn(e,t,r,d[m],n+"/"+l+"/"+ob(m),s,n,l,o,m)}else(l in Tt.keywords||e.allKeys&&!(l in Tt.skipKeywords))&&Mn(e,t,r,d,n+"/"+l,s,n,l,o)}r(o,n,s,i,a,c,u)}}function ob(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ho=S(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.getSchemaRefs=Ae.resolveUrl=Ae.normalizeId=Ae._getFullPath=Ae.getFullPath=Ae.inlineRef=void 0;var nb=U(),sb=xa(),ib=wm(),ab=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function cb(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Sa(e):t?bm(e)<=t:!1}Ae.inlineRef=cb;var ub=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Sa(e){for(let t in e){if(ub.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Sa)||typeof r=="object"&&Sa(r))return!0}return!1}function bm(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!ab.has(r)&&(typeof e[r]=="object"&&(0,nb.eachItem)(e[r],o=>t+=bm(o)),t===1/0))return 1/0}return t}function zm(e,t="",r){r!==!1&&(t=wr(t));let o=e.parse(t);return xm(e,o)}Ae.getFullPath=zm;function xm(e,t){return e.serialize(t).split("#")[0]+"#"}Ae._getFullPath=xm;var lb=/#\/?$/;function wr(e){return e?e.replace(lb,""):""}Ae.normalizeId=wr;function db(e,t,r){return r=wr(r),e.resolve(t,r)}Ae.resolveUrl=db;var pb=/^[a-z_][-a-z0-9._]*$/i;function fb(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:o}=this.opts,n=wr(e[r]||t),s={"":n},i=zm(o,n,!1),a={},c=new Set;return ib(e,{allKeys:!0},(d,f,m,h)=>{if(h===void 0)return;let _=i+f,v=s[h];typeof d[r]=="string"&&(v=$.call(this,d[r])),k.call(this,d.$anchor),k.call(this,d.$dynamicAnchor),s[f]=v;function $(z){let P=this.opts.uriResolver.resolve;if(z=wr(v?P(v,z):z),c.has(z))throw l(z);c.add(z);let y=this.refs[z];return typeof y=="string"&&(y=this.refs[y]),typeof y=="object"?u(d,y.schema,z):z!==wr(_)&&(z[0]==="#"?(u(d,a[z],z),a[z]=d):this.refs[z]=_),z}function k(z){if(typeof z=="string"){if(!pb.test(z))throw new Error(`invalid anchor "${z}"`);$.call(this,`#${z}`)}}}),a;function u(d,f,m){if(f!==void 0&&!sb(d,f))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ae.getSchemaRefs=fb});var yo=S(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.getData=Rt.KeywordCxt=Rt.validateFunctionCode=void 0;var Tm=nm(),Sm=mo(),Pa=_a(),Dn=mo(),mb=dm(),_o=gm(),ka=ym(),T=j(),C=dt(),hb=ho(),pt=U(),go=fo();function gb(e){if(Im(e)&&(Am(e),Om(e))){vb(e);return}Rm(e,()=>(0,Tm.topBoolOrEmptySchema)(e))}Rt.validateFunctionCode=gb;function Rm({gen:e,validateName:t,schema:r,schemaEnv:o,opts:n},s){n.code.es5?e.func(t,(0,T._)`${C.default.data}, ${C.default.valCxt}`,o.$async,()=>{e.code((0,T._)`"use strict"; ${km(r,n)}`),yb(e,n),e.code(s)}):e.func(t,(0,T._)`${C.default.data}, ${_b(n)}`,o.$async,()=>e.code(km(r,n)).code(s))}function _b(e){return(0,T._)`{${C.default.instancePath}="", ${C.default.parentData}, ${C.default.parentDataProperty}, ${C.default.rootData}=${C.default.data}${e.dynamicRef?(0,T._)`, ${C.default.dynamicAnchors}={}`:T.nil}}={}`}function yb(e,t){e.if(C.default.valCxt,()=>{e.var(C.default.instancePath,(0,T._)`${C.default.valCxt}.${C.default.instancePath}`),e.var(C.default.parentData,(0,T._)`${C.default.valCxt}.${C.default.parentData}`),e.var(C.default.parentDataProperty,(0,T._)`${C.default.valCxt}.${C.default.parentDataProperty}`),e.var(C.default.rootData,(0,T._)`${C.default.valCxt}.${C.default.rootData}`),t.dynamicRef&&e.var(C.default.dynamicAnchors,(0,T._)`${C.default.valCxt}.${C.default.dynamicAnchors}`)},()=>{e.var(C.default.instancePath,(0,T._)`""`),e.var(C.default.parentData,(0,T._)`undefined`),e.var(C.default.parentDataProperty,(0,T._)`undefined`),e.var(C.default.rootData,C.default.data),t.dynamicRef&&e.var(C.default.dynamicAnchors,(0,T._)`{}`)})}function vb(e){let{schema:t,opts:r,gen:o}=e;Rm(e,()=>{r.$comment&&t.$comment&&Nm(e),xb(e),o.let(C.default.vErrors,null),o.let(C.default.errors,0),r.unevaluated&&$b(e),Cm(e),Pb(e)})}function $b(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,T._)`${r}.evaluated`),t.if((0,T._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,T._)`${e.evaluated}.props`,(0,T._)`undefined`)),t.if((0,T._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,T._)`${e.evaluated}.items`,(0,T._)`undefined`))}function km(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function wb(e,t){if(Im(e)&&(Am(e),Om(e))){bb(e,t);return}(0,Tm.boolOrEmptySchema)(e,t)}function Om({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function Im(e){return typeof e.schema!="boolean"}function bb(e,t){let{schema:r,gen:o,opts:n}=e;n.$comment&&r.$comment&&Nm(e),Sb(e),kb(e);let s=o.const("_errs",C.default.errors);Cm(e,s),o.var(t,(0,T._)`${s} === ${C.default.errors}`)}function Am(e){(0,pt.checkUnknownRules)(e),zb(e)}function Cm(e,t){if(e.opts.jtd)return Pm(e,[],!1,t);let r=(0,Sm.getSchemaTypes)(e.schema),o=(0,Sm.coerceAndCheckDataType)(e,r);Pm(e,r,!o,t)}function zb(e){let{schema:t,errSchemaPath:r,opts:o,self:n}=e;t.$ref&&o.ignoreKeywordsWithRef&&(0,pt.schemaHasRulesButRef)(t,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function xb(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,pt.checkStrictMode)(e,"default is ignored in the schema root")}function Sb(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,hb.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function kb(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Nm({gen:e,schemaEnv:t,schema:r,errSchemaPath:o,opts:n}){let s=r.$comment;if(n.$comment===!0)e.code((0,T._)`${C.default.self}.logger.log(${s})`);else if(typeof n.$comment=="function"){let i=(0,T.str)`${o}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,T._)`${C.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Pb(e){let{gen:t,schemaEnv:r,validateName:o,ValidationError:n,opts:s}=e;r.$async?t.if((0,T._)`${C.default.errors} === 0`,()=>t.return(C.default.data),()=>t.throw((0,T._)`new ${n}(${C.default.vErrors})`)):(t.assign((0,T._)`${o}.errors`,C.default.vErrors),s.unevaluated&&Eb(e),t.return((0,T._)`${C.default.errors} === 0`))}function Eb({gen:e,evaluated:t,props:r,items:o}){r instanceof T.Name&&e.assign((0,T._)`${t}.props`,r),o instanceof T.Name&&e.assign((0,T._)`${t}.items`,o)}function Pm(e,t,r,o){let{gen:n,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,pt.schemaHasRulesButRef)(s,l))){n.block(()=>Zm(e,"$ref",l.all.$ref.definition));return}c.jtd||Tb(e,t),n.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,Pa.shouldUseGroup)(s,f)&&(f.type?(n.if((0,Dn.checkDataType)(f.type,i,c.strictNumbers)),Em(e,f),t.length===1&&t[0]===f.type&&r&&(n.else(),(0,Dn.reportTypeError)(e)),n.endIf()):Em(e,f),a||n.if((0,T._)`${C.default.errors} === ${o||0}`))}}function Em(e,t){let{gen:r,schema:o,opts:{useDefaults:n}}=e;n&&(0,mb.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Pa.shouldUseRule)(o,s)&&Zm(e,s.keyword,s.definition,t.type)})}function Tb(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Rb(e,t),e.opts.allowUnionTypes||Ob(e,t),Ib(e,e.dataTypes))}function Rb(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{jm(e.dataTypes,r)||Ea(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Cb(e,t)}}function Ob(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ea(e,"use allowUnionTypes to allow union type keyword")}function Ib(e,t){let r=e.self.RULES.all;for(let o in r){let n=r[o];if(typeof n=="object"&&(0,Pa.shouldUseRule)(e.schema,n)){let{type:s}=n.definition;s.length&&!s.some(i=>Ab(t,i))&&Ea(e,`missing type "${s.join(",")}" for keyword "${o}"`)}}}function Ab(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function jm(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Cb(e,t){let r=[];for(let o of e.dataTypes)jm(t,o)?r.push(o):t.includes("integer")&&o==="number"&&r.push("integer");e.dataTypes=r}function Ea(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,pt.checkStrictMode)(e,t,e.opts.strictTypes)}var Un=class{constructor(t,r,o){if((0,_o.validateKeywordUsage)(t,r,o),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=o,this.data=t.data,this.schema=t.schema[o],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,pt.schemaRefOrVal)(t,this.schema,o,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",qm(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,_o.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${o} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",C.default.errors))}result(t,r,o){this.failResult((0,T.not)(t),r,o)}failResult(t,r,o){this.gen.if(t),o?o():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,T.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),t)})`)}error(t,r,o){if(r){this.setParams(r),this._error(t,o),this.setParams({});return}this._error(t,o)}_error(t,r){(t?go.reportExtraError:go.reportError)(this,this.def.error,r)}$dataError(){(0,go.reportError)(this,this.def.$dataError||go.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,go.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,o=T.nil){this.gen.block(()=>{this.check$data(t,o),r()})}check$data(t=T.nil,r=T.nil){if(!this.$data)return;let{gen:o,schemaCode:n,schemaType:s,def:i}=this;o.if((0,T.or)((0,T._)`${n} === undefined`,r)),t!==T.nil&&o.assign(t,!0),(s.length||i.validateSchema)&&(o.elseIf(this.invalid$data()),this.$dataError(),t!==T.nil&&o.assign(t,!1)),o.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:o,def:n,it:s}=this;return(0,T.or)(i(),a());function i(){if(o.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(o)?o:[o];return(0,T._)`${(0,Dn.checkDataTypes)(c,r,s.opts.strictNumbers,Dn.DataType.Wrong)}`}return T.nil}function a(){if(n.validateSchema){let c=t.scopeValue("validate$data",{ref:n.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(t,r){let o=(0,ka.getSubschema)(this.it,t);(0,ka.extendSubschemaData)(o,this.it,t),(0,ka.extendSubschemaMode)(o,t);let n={...this.it,...o,items:void 0,props:void 0};return wb(n,r),n}mergeEvaluated(t,r){let{it:o,gen:n}=this;o.opts.unevaluated&&(o.props!==!0&&t.props!==void 0&&(o.props=pt.mergeEvaluated.props(n,t.props,o.props,r)),o.items!==!0&&t.items!==void 0&&(o.items=pt.mergeEvaluated.items(n,t.items,o.items,r)))}mergeValidEvaluated(t,r){let{it:o,gen:n}=this;if(o.opts.unevaluated&&(o.props!==!0||o.items!==!0))return n.if(r,()=>this.mergeEvaluated(t,T.Name)),!0}};Rt.KeywordCxt=Un;function Zm(e,t,r,o){let n=new Un(e,r,t);"code"in r?r.code(n,o):n.$data&&r.validate?(0,_o.funcKeywordCode)(n,r):"macro"in r?(0,_o.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,_o.funcKeywordCode)(n,r)}var Nb=/^\/(?:[^~]|~0|~1)*$/,jb=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function qm(e,{dataLevel:t,dataNames:r,dataPathArr:o}){let n,s;if(e==="")return C.default.rootData;if(e[0]==="/"){if(!Nb.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);n=e,s=C.default.rootData}else{let u=jb.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(n=u[2],n==="#"){if(l>=t)throw new Error(c("property/index",l));return o[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!n)return s}let i=s,a=n.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,pt.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Rt.getData=qm});var Ln=S(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});var Ta=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Ra.default=Ta});var vo=S(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});var Oa=ho(),Ia=class extends Error{constructor(t,r,o,n){super(n||`can't resolve reference ${o} from id ${r}`),this.missingRef=(0,Oa.resolveUrl)(t,r,o),this.missingSchema=(0,Oa.normalizeId)((0,Oa.getFullPath)(t,this.missingRef))}};Aa.default=Ia});var Vn=S(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.resolveSchema=Fe.getCompilingSchema=Fe.resolveRef=Fe.compileSchema=Fe.SchemaEnv=void 0;var Be=j(),Zb=Ln(),Ht=dt(),We=ho(),Mm=U(),qb=yo(),br=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let o;typeof t.schema=="object"&&(o=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,We.normalizeId)(o?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=o?.$async,this.refs={}}};Fe.SchemaEnv=br;function Na(e){let t=Dm.call(this,e);if(t)return t;let r=(0,We.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:o,lines:n}=this.opts.code,{ownProperties:s}=this.opts,i=new Be.CodeGen(this.scope,{es5:o,lines:n,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:Zb.default,code:(0,Be._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Ht.default.data,parentData:Ht.default.parentData,parentDataProperty:Ht.default.parentDataProperty,dataNames:[Ht.default.data],dataPathArr:[Be.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Be.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Be.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Be._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,qb.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Ht.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let m=new Function(`${Ht.default.self}`,`${Ht.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=e.schema,m.schemaEnv=e,e.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:_}=u;m.evaluated={props:h instanceof Be.Name?void 0:h,items:_ instanceof Be.Name?void 0:_,dynamicProps:h instanceof Be.Name,dynamicItems:_ instanceof Be.Name},m.source&&(m.source.evaluated=(0,Be.stringify)(m.evaluated))}return e.validate=m,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}Fe.compileSchema=Na;function Mb(e,t,r){var o;r=(0,We.resolveUrl)(this.opts.uriResolver,t,r);let n=e.refs[r];if(n)return n;let s=Lb.call(this,e,r);if(s===void 0){let i=(o=e.localRefs)===null||o===void 0?void 0:o[r],{schemaId:a}=this.opts;i&&(s=new br({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=Db.call(this,s)}Fe.resolveRef=Mb;function Db(e){return(0,We.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Na.call(this,e)}function Dm(e){for(let t of this._compilations)if(Ub(t,e))return t}Fe.getCompilingSchema=Dm;function Ub(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Lb(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Fn.call(this,e,t)}function Fn(e,t){let r=this.opts.uriResolver.parse(t),o=(0,We._getFullPath)(this.opts.uriResolver,r),n=(0,We.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&o===n)return Ca.call(this,r,e);let s=(0,We.normalizeId)(o),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Fn.call(this,e,i);return typeof a?.schema!="object"?void 0:Ca.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Na.call(this,i),s===(0,We.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(n=(0,We.resolveUrl)(this.opts.uriResolver,n,u)),new br({schema:a,schemaId:c,root:e,baseId:n})}return Ca.call(this,r,i)}}Fe.resolveSchema=Fn;var Fb=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ca(e,{baseId:t,schema:r,root:o}){var n;if(((n=e.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Mm.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Fb.has(a)&&u&&(t=(0,We.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Mm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,We.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Fn.call(this,o,a)}let{schemaId:i}=this.opts;if(s=s||new br({schema:r,schemaId:i,root:o,baseId:t}),s.schema!==s.root.schema)return s}});var Um=S((e1,Vb)=>{Vb.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var qa=S((t1,Jm)=>{"use strict";var Hb=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Fm=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),ja=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Vm=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Kb=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Za(e){let t="",r=0,o=0;for(o=0;o<e.length;o++)if(r=e[o].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[o];break}for(o+=1;o<e.length;o++){if(r=e[o].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[o]}return t}var Jb=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Lm(e){return e.length=0,!0}function Bb(e,t,r){if(e.length){let o=Za(e);if(o!=="")t.push(o);else return r.error=!0,!1;e.length=0}return!0}function Wb(e){let t=0,r={error:!1,address:"",zone:""},o=[],n=[],s=!1,i=!1,a=Bb;for(let c=0;c<e.length;c++){let u=e[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(n,o,r))break;if(++t>7){r.error=!0;break}c>0&&e[c-1]===":"&&(s=!0),o.push(":");continue}else if(u==="%"){if(!a(n,o,r))break;a=Lm}else{n.push(u);continue}}return n.length&&(a===Lm?r.zone=n.join(""):i?o.push(n.join("")):o.push(Za(n))),r.address=o.join(""),r}function Hm(e){if(Gb(e,":")<2)return{host:e,isIPV6:!1};let t=Wb(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,o=t.address;return t.zone&&(r+="%"+t.zone,o+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:o}}}function Gb(e,t){let r=0;for(let o=0;o<e.length;o++)e[o]===t&&r++;return r}function Yb(e){let t=e,r=[],o=-1,n=0;for(;n=t.length;){if(n===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(n===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(n===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((o=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,o)),t=t.slice(o)}return r.join("")}var Qb={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Xb=/[@/?#:]/g,e0=/[@/?#]/g;function Km(e,t){let r=t?e0:Xb;return r.lastIndex=0,e.replace(r,o=>Qb[o])}function t0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let o=0;o<e.length;o++){if(e[o]==="%"&&o+2<e.length){let n=e.slice(o+1,o+3);if(ja(n)){let s=n.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Vm(i)?r+=i:r+="%"+s,o+=2;continue}}r+=e[o]}return r}function r0(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(ja(o)){let n=o.toUpperCase(),s=String.fromCharCode(parseInt(n,16));s!=="."&&Vm(s)?t+=s:t+="%"+n,r+=2;continue}}Kb(e[r])?t+=e[r]:t+=escape(e[r])}return t}function o0(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(ja(o)){t+="%"+o.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function n0(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Fm(r)){let o=Hm(r);o.isIPV6===!0?r=`[${o.escapedHost}]`:r=Km(r,!1)}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Jm.exports={nonSimpleDomain:Jb,recomposeAuthority:n0,reescapeHostDelimiters:Km,normalizePercentEncoding:t0,normalizePathEncoding:r0,escapePreservingEscapes:o0,removeDotSegments:Yb,isIPv4:Fm,isUUID:Hb,normalizeIPv6:Hm,stringArrayToHexStripped:Za}});var Qm=S((r1,Ym)=>{"use strict";var{isUUID:s0}=qa(),i0=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,a0=["http","https","ws","wss","urn","urn:uuid"];function c0(e){return a0.indexOf(e)!==-1}function Ma(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Bm(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Wm(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function u0(e){return e.secure=Ma(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function l0(e){if((e.port===(Ma(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function d0(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(i0);if(r){let o=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let n=`${o}:${t.nid||e.nid}`,s=Da(n);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function p0(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",o=e.nid.toLowerCase(),n=`${r}:${t.nid||o}`,s=Da(n);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${o||t.nid}:${a}`,t.skipEscape=!0,i}function f0(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!s0(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function m0(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Gm={scheme:"http",domainHost:!0,parse:Bm,serialize:Wm},h0={scheme:"https",domainHost:Gm.domainHost,parse:Bm,serialize:Wm},Hn={scheme:"ws",domainHost:!0,parse:u0,serialize:l0},g0={scheme:"wss",domainHost:Hn.domainHost,parse:Hn.parse,serialize:Hn.serialize},_0={scheme:"urn",parse:d0,serialize:p0,skipNormalize:!0},y0={scheme:"urn:uuid",parse:f0,serialize:m0,skipNormalize:!0},Kn={http:Gm,https:h0,ws:Hn,wss:g0,urn:_0,"urn:uuid":y0};Object.setPrototypeOf(Kn,null);function Da(e){return e&&(Kn[e]||Kn[e.toLowerCase()])||void 0}Ym.exports={wsIsSecure:Ma,SCHEMES:Kn,isValidSchemeName:c0,getSchemeHandler:Da}});var nh=S((o1,Jn)=>{"use strict";var{normalizeIPv6:v0,removeDotSegments:$o,recomposeAuthority:$0,normalizePercentEncoding:w0,normalizePathEncoding:b0,escapePreservingEscapes:z0,reescapeHostDelimiters:x0,isIPv4:S0,nonSimpleDomain:k0}=qa(),{SCHEMES:P0,getSchemeHandler:eh}=Qm();function E0(e,t){return typeof e=="string"?e=C0(e,t):typeof e=="object"&&(e=zr(Kt(e,t),t)),e}function T0(e,t,r){let o=r?Object.assign({scheme:"null"},r):{scheme:"null"},n=th(zr(e,o),zr(t,o),o,!0);return o.skipEscape=!0,Kt(n,o)}function th(e,t,r,o){let n={};return o||(e=zr(Kt(e,r),r),t=zr(Kt(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(n.scheme=t.scheme,n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=$o(t.path||""),n.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=$o(t.path||""),n.query=t.query):(t.path?(t.path[0]==="/"?n.path=$o(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?n.path="/"+t.path:e.path?n.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:n.path=t.path,n.path=$o(n.path)),n.query=t.query):(n.path=e.path,t.query!==void 0?n.query=t.query:n.query=e.query),n.userinfo=e.userinfo,n.host=e.host,n.port=e.port),n.scheme=e.scheme),n.fragment=t.fragment,n}function R0(e,t,r){let o=Xm(e,r),n=Xm(t,r);return o!==void 0&&n!==void 0&&o.toLowerCase()===n.toLowerCase()}function Kt(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},o=Object.assign({},t),n=[],s=eh(o.scheme||r.scheme);s&&s.serialize&&s.serialize(r,o),r.path!==void 0&&(o.skipEscape?r.path=w0(r.path):(r.path=z0(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),o.reference!=="suffix"&&r.scheme&&n.push(r.scheme,":");let i=$0(r);if(i!==void 0&&(o.reference!=="suffix"&&n.push("//"),n.push(i),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let a=r.path;!o.absolutePath&&(!s||!s.absolutePath)&&(a=$o(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),n.push(a)}return r.query!==void 0&&n.push("?",r.query),r.fragment!==void 0&&n.push("#",r.fragment),n.join("")}var O0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,I0=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function A0(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function rh(e,t){let r=Object.assign({},t),o={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=!1,s=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let i=e.match(I0);i!==null&&i[1].indexOf("\\")!==-1&&(o.error="URI authority must not contain a literal backslash.",n=!0);let a=e.match(O0);if(a){o.scheme=a[1],o.userinfo=a[3],o.host=a[4],o.port=parseInt(a[5],10),o.path=a[6]||"",o.query=a[7],o.fragment=a[8],isNaN(o.port)&&(o.port=a[5]);let c=A0(o,a);if(c!==void 0&&(o.error=o.error||c,n=!0),o.host)if(S0(o.host)===!1){let d=v0(o.host);o.host=d.host.toLowerCase(),s=d.isIPV6}else s=!0;o.scheme===void 0&&o.userinfo===void 0&&o.host===void 0&&o.port===void 0&&o.query===void 0&&!o.path?o.reference="same-document":o.scheme===void 0?o.reference="relative":o.fragment===void 0?o.reference="absolute":o.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==o.reference&&(o.error=o.error||"URI is not a "+r.reference+" reference.");let u=eh(r.scheme||o.scheme);if(!r.unicodeSupport&&(!u||!u.unicodeSupport)&&o.host&&(r.domainHost||u&&u.domainHost)&&s===!1&&k0(o.host))try{o.host=new URL("http://"+o.host).hostname}catch(l){o.error=o.error||"Host's domain name can not be converted to ASCII: "+l}if((!u||u&&!u.skipNormalize)&&(e.indexOf("%")!==-1&&(o.scheme!==void 0&&(o.scheme=unescape(o.scheme)),o.host!==void 0&&(o.host=x0(unescape(o.host),s))),o.path&&(o.path=b0(o.path)),o.fragment))try{o.fragment=encodeURI(decodeURIComponent(o.fragment))}catch{o.error=o.error||"URI malformed"}u&&u.parse&&u.parse(o,r)}else o.error=o.error||"URI can not be parsed.";return{parsed:o,malformedAuthorityOrPort:n}}function zr(e,t){return rh(e,t).parsed}function C0(e,t){return oh(e,t).normalized}function oh(e,t){let{parsed:r,malformedAuthorityOrPort:o}=rh(e,t);return{normalized:o?e:Kt(r,t),malformedAuthorityOrPort:o}}function Xm(e,t){if(typeof e=="string"){let{normalized:r,malformedAuthorityOrPort:o}=oh(e,t);return o?void 0:r}if(typeof e=="object")return Kt(e,t)}var Ua={SCHEMES:P0,normalize:E0,resolve:T0,resolveComponent:th,equal:R0,serialize:Kt,parse:zr};Jn.exports=Ua;Jn.exports.default=Ua;Jn.exports.fastUri=Ua});var ih=S(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var sh=nh();sh.code='require("ajv/dist/runtime/uri").default';La.default=sh});var mh=S(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=void 0;var N0=yo();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return N0.KeywordCxt}});var xr=j();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return xr._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return xr.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return xr.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return xr.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return xr.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return xr.CodeGen}});var j0=Ln(),dh=vo(),Z0=ga(),wo=Vn(),q0=j(),bo=ho(),Bn=mo(),Va=U(),ah=Um(),M0=ih(),ph=(e,t)=>new RegExp(e,t);ph.code="new RegExp";var D0=["removeAdditional","useDefaults","coerceTypes"],U0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),L0={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},F0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},ch=200;function V0(e){var t,r,o,n,s,i,a,c,u,l,d,f,m,h,_,v,$,k,z,P,y,w,A,se,ie;let Ee=e.strict,Cr=(t=e.code)===null||t===void 0?void 0:t.optimize,Bo=Cr===!0||Cr===void 0?1:Cr||0,Wo=(o=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&o!==void 0?o:ph,_t=(n=e.uriResolver)!==null&&n!==void 0?n:M0.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:Ee)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:Ee)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:Ee)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:Ee)!==null&&f!==void 0?f:"log",strictRequired:(h=(m=e.strictRequired)!==null&&m!==void 0?m:Ee)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:Bo,regExp:Wo}:{optimize:Bo,regExp:Wo},loopRequired:(_=e.loopRequired)!==null&&_!==void 0?_:ch,loopEnum:(v=e.loopEnum)!==null&&v!==void 0?v:ch,meta:($=e.meta)!==null&&$!==void 0?$:!0,messages:(k=e.messages)!==null&&k!==void 0?k:!0,inlineRefs:(z=e.inlineRefs)!==null&&z!==void 0?z:!0,schemaId:(P=e.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(y=e.addUsedSchema)!==null&&y!==void 0?y:!0,validateSchema:(w=e.validateSchema)!==null&&w!==void 0?w:!0,validateFormats:(A=e.validateFormats)!==null&&A!==void 0?A:!0,unicodeRegExp:(se=e.unicodeRegExp)!==null&&se!==void 0?se:!0,int32range:(ie=e.int32range)!==null&&ie!==void 0?ie:!0,uriResolver:_t}}var zo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...V0(t)};let{es5:r,lines:o}=this.opts.code;this.scope=new q0.ValueScope({scope:{},prefixes:U0,es5:r,lines:o}),this.logger=G0(t.logger);let n=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Z0.getRules)(),uh.call(this,L0,t,"NOT SUPPORTED"),uh.call(this,F0,t,"DEPRECATED","warn"),this._metaOpts=B0.call(this),t.formats&&K0.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&J0.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),H0.call(this),t.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:o}=this.opts,n=ah;o==="id"&&(n={...ah},n.id=n.$id,delete n.$id),r&&t&&this.addMetaSchema(n,n[o],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let o;if(typeof t=="string"){if(o=this.getSchema(t),!o)throw new Error(`no schema with key or ref "${t}"`)}else o=this.compile(t);let n=o(r);return"$async"in o||(this.errors=o.errors),n}compile(t,r){let o=this._addSchema(t,r);return o.validate||this._compileSchemaEnv(o)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:o}=this.opts;return n.call(this,t,r);async function n(l,d){await s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await n.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof dh.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=o(l))}finally{delete this._loading[l]}}}addSchema(t,r,o,n=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,o,n);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,bo.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,o,r,n,!0),this}addMetaSchema(t,r,o=this.opts.validateSchema){return this.addSchema(t,r,!0,o),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let o;if(o=t.$schema,o!==void 0&&typeof o!="string")throw new Error("$schema must be a string");if(o=o||this.opts.defaultMeta||this.defaultMeta(),!o)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let n=this.validate(o,t);if(!n&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return n}getSchema(t){let r;for(;typeof(r=lh.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:o}=this.opts,n=new wo.SchemaEnv({schema:{},schemaId:o});if(r=wo.resolveSchema.call(this,n,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=lh.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let o=t[this.opts.schemaId];return o&&(o=(0,bo.normalizeId)(o),delete this.schemas[o],delete this.refs[o]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let o;if(typeof t=="string")o=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=o);else if(typeof t=="object"&&r===void 0){if(r=t,o=r.keyword,Array.isArray(o)&&!o.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Q0.call(this,o,r),!r)return(0,Va.eachItem)(o,s=>Fa.call(this,s)),this;ez.call(this,r);let n={...r,type:(0,Bn.getJSONTypes)(r.type),schemaType:(0,Bn.getJSONTypes)(r.schemaType)};return(0,Va.eachItem)(o,n.type.length===0?s=>Fa.call(this,s,n):s=>n.type.forEach(i=>Fa.call(this,s,n,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let o of r.rules){let n=o.rules.findIndex(s=>s.keyword===t);n>=0&&o.rules.splice(n,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:o="data"}={}){return!t||t.length===0?"No errors":t.map(n=>`${o}${n.instancePath} ${n.message}`).reduce((n,s)=>n+r+s)}$dataMetaSchema(t,r){let o=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let n of r){let s=n.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in o){let c=o[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=fh(l))}}return t}_removeAllSchemas(t,r){for(let o in t){let n=t[o];(!r||r.test(o))&&(typeof n=="string"?delete t[o]:n&&!n.meta&&(this._cache.delete(n.schema),delete t[o]))}}_addSchema(t,r,o,n=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;o=(0,bo.normalizeId)(i||o);let u=bo.getSchemaRefs.call(this,t,o);return c=new wo.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:o,localRefs:u}),this._cache.set(c.schema,c),s&&!o.startsWith("#")&&(o&&this._checkUnique(o),this.refs[o]=c),n&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):wo.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{wo.compileSchema.call(this,t)}finally{this.opts=r}}};zo.ValidationError=j0.default;zo.MissingRefError=dh.default;ge.default=zo;function uh(e,t,r,o="error"){for(let n in e){let s=n;s in t&&this.logger[o](`${r}: option ${n}. ${e[s]}`)}}function lh(e){return e=(0,bo.normalizeId)(e),this.schemas[e]||this.refs[e]}function H0(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function K0(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function J0(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function B0(){let e={...this.opts};for(let t of D0)delete e[t];return e}var W0={log(){},warn(){},error(){}};function G0(e){if(e===!1)return W0;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var Y0=/^[a-z_$][a-z0-9_$:-]*$/i;function Q0(e,t){let{RULES:r}=this;if((0,Va.eachItem)(e,o=>{if(r.keywords[o])throw new Error(`Keyword ${o} is already defined`);if(!Y0.test(o))throw new Error(`Keyword ${o} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Fa(e,t,r){var o;let n=t?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=n?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Bn.getJSONTypes)(t.type),schemaType:(0,Bn.getJSONTypes)(t.schemaType)}};t.before?X0.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(o=t.implements)===null||o===void 0||o.forEach(c=>this.addKeyword(c))}function X0(e,t,r){let o=e.rules.findIndex(n=>n.keyword===r);o>=0?e.rules.splice(o,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function ez(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=fh(t)),e.validateSchema=this.compile(t,!0))}var tz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function fh(e){return{anyOf:[e,tz]}}});var hh=S(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});var rz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ha.default=rz});var vh=S(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.callRef=Jt.getValidate=void 0;var oz=vo(),gh=Le(),Ce=j(),Sr=dt(),_h=Vn(),Wn=U(),nz={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:o}=e,{baseId:n,schemaEnv:s,validateName:i,opts:a,self:c}=o,{root:u}=s;if((r==="#"||r==="#/")&&n===u.baseId)return d();let l=_h.resolveRef.call(c,u,n,r);if(l===void 0)throw new oz.default(o.opts.uriResolver,n,r);if(l instanceof _h.SchemaEnv)return f(l);return m(l);function d(){if(s===u)return Gn(e,i,s,s.$async);let h=t.scopeValue("root",{ref:u});return Gn(e,(0,Ce._)`${h}.validate`,u,u.$async)}function f(h){let _=yh(e,h);Gn(e,_,h,h.$async)}function m(h){let _=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Ce.stringify)(h)}:{ref:h}),v=t.name("valid"),$=e.subschema({schema:h,dataTypes:[],schemaPath:Ce.nil,topSchemaRef:_,errSchemaPath:r},v);e.mergeEvaluated($),e.ok(v)}}};function yh(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Ce._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Jt.getValidate=yh;function Gn(e,t,r,o){let{gen:n,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Sr.default.this:Ce.nil;o?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=n.let("valid");n.try(()=>{n.code((0,Ce._)`await ${(0,gh.callValidateCode)(e,t,u)}`),m(t),i||n.assign(h,!0)},_=>{n.if((0,Ce._)`!(${_} instanceof ${s.ValidationError})`,()=>n.throw(_)),f(_),i||n.assign(h,!1)}),e.ok(h)}function d(){e.result((0,gh.callValidateCode)(e,t,u),()=>m(t),()=>f(t))}function f(h){let _=(0,Ce._)`${h}.errors`;n.assign(Sr.default.vErrors,(0,Ce._)`${Sr.default.vErrors} === null ? ${_} : ${Sr.default.vErrors}.concat(${_})`),n.assign(Sr.default.errors,(0,Ce._)`${Sr.default.vErrors}.length`)}function m(h){var _;if(!s.opts.unevaluated)return;let v=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(s.props=Wn.mergeEvaluated.props(n,v.props,s.props));else{let $=n.var("props",(0,Ce._)`${h}.evaluated.props`);s.props=Wn.mergeEvaluated.props(n,$,s.props,Ce.Name)}if(s.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(s.items=Wn.mergeEvaluated.items(n,v.items,s.items));else{let $=n.var("items",(0,Ce._)`${h}.evaluated.items`);s.items=Wn.mergeEvaluated.items(n,$,s.items,Ce.Name)}}}Jt.callRef=Gn;Jt.default=nz});var $h=S(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var sz=hh(),iz=vh(),az=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",sz.default,iz.default];Ka.default=az});var wh=S(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});var Yn=j(),Ot=Yn.operators,Qn={maximum:{okStr:"<=",ok:Ot.LTE,fail:Ot.GT},minimum:{okStr:">=",ok:Ot.GTE,fail:Ot.LT},exclusiveMaximum:{okStr:"<",ok:Ot.LT,fail:Ot.GTE},exclusiveMinimum:{okStr:">",ok:Ot.GT,fail:Ot.LTE}},cz={message:({keyword:e,schemaCode:t})=>(0,Yn.str)`must be ${Qn[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Yn._)`{comparison: ${Qn[e].okStr}, limit: ${t}}`},uz={keyword:Object.keys(Qn),type:"number",schemaType:"number",$data:!0,error:cz,code(e){let{keyword:t,data:r,schemaCode:o}=e;e.fail$data((0,Yn._)`${r} ${Qn[t].fail} ${o} || isNaN(${r})`)}};Ja.default=uz});var bh=S(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});var xo=j(),lz={message:({schemaCode:e})=>(0,xo.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,xo._)`{multipleOf: ${e}}`},dz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:lz,code(e){let{gen:t,data:r,schemaCode:o,it:n}=e,s=n.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,xo._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,xo._)`${i} !== parseInt(${i})`;e.fail$data((0,xo._)`(${o} === 0 || (${i} = ${r}/${o}, ${a}))`)}};Ba.default=dz});var xh=S(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});function zh(e){let t=e.length,r=0,o=0,n;for(;o<t;)r++,n=e.charCodeAt(o++),n>=55296&&n<=56319&&o<t&&(n=e.charCodeAt(o),(n&64512)===56320&&o++);return r}Wa.default=zh;zh.code='require("ajv/dist/runtime/ucs2length").default'});var Sh=S(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var Bt=j(),pz=U(),fz=xh(),mz={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Bt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Bt._)`{limit: ${e}}`},hz={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:mz,code(e){let{keyword:t,data:r,schemaCode:o,it:n}=e,s=t==="maxLength"?Bt.operators.GT:Bt.operators.LT,i=n.opts.unicode===!1?(0,Bt._)`${r}.length`:(0,Bt._)`${(0,pz.useFunc)(e.gen,fz.default)}(${r})`;e.fail$data((0,Bt._)`${i} ${s} ${o}`)}};Ga.default=hz});var kh=S(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});var gz=Le(),_z=U(),kr=j(),yz={message:({schemaCode:e})=>(0,kr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,kr._)`{pattern: ${e}}`},vz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:yz,code(e){let{gen:t,data:r,$data:o,schema:n,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(o){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,kr._)`new RegExp`:(0,_z.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,kr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,kr._)`!${l}`)}else{let c=(0,gz.usePattern)(e,n);e.fail$data((0,kr._)`!${c}.test(${r})`)}}};Ya.default=vz});var Ph=S(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});var So=j(),$z={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,So.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,So._)`{limit: ${e}}`},wz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:$z,code(e){let{keyword:t,data:r,schemaCode:o}=e,n=t==="maxProperties"?So.operators.GT:So.operators.LT;e.fail$data((0,So._)`Object.keys(${r}).length ${n} ${o}`)}};Qa.default=wz});var Eh=S(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var ko=Le(),Po=j(),bz=U(),zz={message:({params:{missingProperty:e}})=>(0,Po.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Po._)`{missingProperty: ${e}}`},xz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:zz,code(e){let{gen:t,schema:r,schemaCode:o,data:n,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=e.parentSchema.properties,{definedProperties:h}=e.it;for(let _ of r)if(m?.[_]===void 0&&!h.has(_)){let v=i.schemaEnv.baseId+i.errSchemaPath,$=`required property "${_}" is not defined at "${v}" (strictRequired)`;(0,bz.checkStrictMode)(i,$,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(Po.nil,d);else for(let m of r)(0,ko.checkReportMissingProp)(e,m)}function l(){let m=t.let("missing");if(c||s){let h=t.let("valid",!0);e.block$data(h,()=>f(m,h)),e.ok(h)}else t.if((0,ko.checkMissingProp)(e,r,m)),(0,ko.reportMissingProp)(e,m),t.else()}function d(){t.forOf("prop",o,m=>{e.setParams({missingProperty:m}),t.if((0,ko.noPropertyInData)(t,n,m,a.ownProperties),()=>e.error())})}function f(m,h){e.setParams({missingProperty:m}),t.forOf(m,o,()=>{t.assign(h,(0,ko.propertyInData)(t,n,m,a.ownProperties)),t.if((0,Po.not)(h),()=>{e.error(),t.break()})},Po.nil)}}};Xa.default=xz});var Th=S(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});var Eo=j(),Sz={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Eo.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Eo._)`{limit: ${e}}`},kz={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Sz,code(e){let{keyword:t,data:r,schemaCode:o}=e,n=t==="maxItems"?Eo.operators.GT:Eo.operators.LT;e.fail$data((0,Eo._)`${r}.length ${n} ${o}`)}};ec.default=kz});var Xn=S(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var Rh=xa();Rh.code='require("ajv/dist/runtime/equal").default';tc.default=Rh});var Oh=S(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var rc=mo(),_e=j(),Pz=U(),Ez=Xn(),Tz={message:({params:{i:e,j:t}})=>(0,_e.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,_e._)`{i: ${e}, j: ${t}}`},Rz={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Tz,code(e){let{gen:t,data:r,$data:o,schema:n,parentSchema:s,schemaCode:i,it:a}=e;if(!o&&!n)return;let c=t.let("valid"),u=s.items?(0,rc.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,_e._)`${i} === false`),e.ok(c);function l(){let h=t.let("i",(0,_e._)`${r}.length`),_=t.let("j");e.setParams({i:h,j:_}),t.assign(c,!0),t.if((0,_e._)`${h} > 1`,()=>(d()?f:m)(h,_))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function f(h,_){let v=t.name("item"),$=(0,rc.checkDataTypes)(u,v,a.opts.strictNumbers,rc.DataType.Wrong),k=t.const("indices",(0,_e._)`{}`);t.for((0,_e._)`;${h}--;`,()=>{t.let(v,(0,_e._)`${r}[${h}]`),t.if($,(0,_e._)`continue`),u.length>1&&t.if((0,_e._)`typeof ${v} == "string"`,(0,_e._)`${v} += "_"`),t.if((0,_e._)`typeof ${k}[${v}] == "number"`,()=>{t.assign(_,(0,_e._)`${k}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,_e._)`${k}[${v}] = ${h}`)})}function m(h,_){let v=(0,Pz.useFunc)(t,Ez.default),$=t.name("outer");t.label($).for((0,_e._)`;${h}--;`,()=>t.for((0,_e._)`${_} = ${h}; ${_}--;`,()=>t.if((0,_e._)`${v}(${r}[${h}], ${r}[${_}])`,()=>{e.error(),t.assign(c,!1).break($)})))}}};oc.default=Rz});var Ih=S(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});var nc=j(),Oz=U(),Iz=Xn(),Az={message:"must be equal to constant",params:({schemaCode:e})=>(0,nc._)`{allowedValue: ${e}}`},Cz={keyword:"const",$data:!0,error:Az,code(e){let{gen:t,data:r,$data:o,schemaCode:n,schema:s}=e;o||s&&typeof s=="object"?e.fail$data((0,nc._)`!${(0,Oz.useFunc)(t,Iz.default)}(${r}, ${n})`):e.fail((0,nc._)`${s} !== ${r}`)}};sc.default=Cz});var Ah=S(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var To=j(),Nz=U(),jz=Xn(),Zz={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,To._)`{allowedValues: ${e}}`},qz={keyword:"enum",schemaType:"array",$data:!0,error:Zz,code(e){let{gen:t,data:r,$data:o,schema:n,schemaCode:s,it:i}=e;if(!o&&n.length===0)throw new Error("enum must have non-empty array");let a=n.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,Nz.useFunc)(t,jz.default)),l;if(a||o)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(n))throw new Error("ajv implementation error");let m=t.const("vSchema",s);l=(0,To.or)(...n.map((h,_)=>f(m,_)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,m=>t.if((0,To._)`${u()}(${r}, ${m})`,()=>t.assign(l,!0).break()))}function f(m,h){let _=n[h];return typeof _=="object"&&_!==null?(0,To._)`${u()}(${r}, ${m}[${h}])`:(0,To._)`${r} === ${_}`}}};ic.default=qz});var Ch=S(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var Mz=wh(),Dz=bh(),Uz=Sh(),Lz=kh(),Fz=Ph(),Vz=Eh(),Hz=Th(),Kz=Oh(),Jz=Ih(),Bz=Ah(),Wz=[Mz.default,Dz.default,Uz.default,Lz.default,Fz.default,Vz.default,Hz.default,Kz.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Jz.default,Bz.default];ac.default=Wz});var uc=S(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.validateAdditionalItems=void 0;var Wt=j(),cc=U(),Gz={message:({params:{len:e}})=>(0,Wt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Wt._)`{limit: ${e}}`},Yz={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Gz,code(e){let{parentSchema:t,it:r}=e,{items:o}=t;if(!Array.isArray(o)){(0,cc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Nh(e,o)}};function Nh(e,t){let{gen:r,schema:o,data:n,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,Wt._)`${n}.length`);if(o===!1)e.setParams({len:t.length}),e.pass((0,Wt._)`${a} <= ${t.length}`);else if(typeof o=="object"&&!(0,cc.alwaysValidSchema)(i,o)){let u=r.var("valid",(0,Wt._)`${a} <= ${t.length}`);r.if((0,Wt.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:cc.Type.Num},u),i.allErrors||r.if((0,Wt.not)(u),()=>r.break())})}}Ro.validateAdditionalItems=Nh;Ro.default=Yz});var lc=S(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.validateTuple=void 0;var jh=j(),es=U(),Qz=Le(),Xz={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Zh(e,"additionalItems",t);r.items=!0,!(0,es.alwaysValidSchema)(r,t)&&e.ok((0,Qz.validateArray)(e))}};function Zh(e,t,r=e.schema){let{gen:o,parentSchema:n,data:s,keyword:i,it:a}=e;l(n),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=es.mergeEvaluated.items(o,r.length,a.items));let c=o.name("valid"),u=o.const("len",(0,jh._)`${s}.length`);r.forEach((d,f)=>{(0,es.alwaysValidSchema)(a,d)||(o.if((0,jh._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:m}=a,h=r.length,_=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(f.strictTuples&&!_){let v=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,es.checkStrictMode)(a,v,f.strictTuples)}}}Oo.validateTuple=Zh;Oo.default=Xz});var qh=S(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var ex=lc(),tx={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,ex.validateTuple)(e,"items")};dc.default=tx});var Dh=S(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Mh=j(),rx=U(),ox=Le(),nx=uc(),sx={message:({params:{len:e}})=>(0,Mh.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Mh._)`{limit: ${e}}`},ix={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:sx,code(e){let{schema:t,parentSchema:r,it:o}=e,{prefixItems:n}=r;o.items=!0,!(0,rx.alwaysValidSchema)(o,t)&&(n?(0,nx.validateAdditionalItems)(e,n):e.ok((0,ox.validateArray)(e)))}};pc.default=ix});var Uh=S(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var Ve=j(),ts=U(),ax={message:({params:{min:e,max:t}})=>t===void 0?(0,Ve.str)`must contain at least ${e} valid item(s)`:(0,Ve.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Ve._)`{minContains: ${e}}`:(0,Ve._)`{minContains: ${e}, maxContains: ${t}}`},cx={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:ax,code(e){let{gen:t,schema:r,parentSchema:o,data:n,it:s}=e,i,a,{minContains:c,maxContains:u}=o;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,Ve._)`${n}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,ts.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ts.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,ts.alwaysValidSchema)(s,r)){let _=(0,Ve._)`${l} >= ${i}`;a!==void 0&&(_=(0,Ve._)`${_} && ${l} <= ${a}`),e.pass(_);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?m(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,Ve._)`${n}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let _=t.name("_valid"),v=t.let("count",0);m(_,()=>t.if(_,()=>h(v)))}function m(_,v){t.forRange("i",0,l,$=>{e.subschema({keyword:"contains",dataProp:$,dataPropType:ts.Type.Num,compositeRule:!0},_),v()})}function h(_){t.code((0,Ve._)`${_}++`),a===void 0?t.if((0,Ve._)`${_} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,Ve._)`${_} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,Ve._)`${_} >= ${i}`,()=>t.assign(d,!0)))}}};fc.default=cx});var Vh=S(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.validateSchemaDeps=tt.validatePropertyDeps=tt.error=void 0;var mc=j(),ux=U(),Io=Le();tt.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let o=t===1?"property":"properties";return(0,mc.str)`must have ${o} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:o}})=>(0,mc._)`{property: ${e},
13
+ missingProperty: ${o},
14
+ depsCount: ${t},
15
+ deps: ${r}}`};var lx={keyword:"dependencies",type:"object",schemaType:"object",error:tt.error,code(e){let[t,r]=dx(e);Lh(e,t),Fh(e,r)}};function dx({schema:e}){let t={},r={};for(let o in e){if(o==="__proto__")continue;let n=Array.isArray(e[o])?t:r;n[o]=e[o]}return[t,r]}function Lh(e,t=e.schema){let{gen:r,data:o,it:n}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,Io.propertyInData)(r,o,i,n.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),n.allErrors?r.if(c,()=>{for(let u of a)(0,Io.checkReportMissingProp)(e,u)}):(r.if((0,mc._)`${c} && (${(0,Io.checkMissingProp)(e,a,s)})`),(0,Io.reportMissingProp)(e,s),r.else())}}tt.validatePropertyDeps=Lh;function Fh(e,t=e.schema){let{gen:r,data:o,keyword:n,it:s}=e,i=r.name("valid");for(let a in t)(0,ux.alwaysValidSchema)(s,t[a])||(r.if((0,Io.propertyInData)(r,o,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:n,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}tt.validateSchemaDeps=Fh;tt.default=lx});var Kh=S(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var Hh=j(),px=U(),fx={message:"property name must be valid",params:({params:e})=>(0,Hh._)`{propertyName: ${e.propertyName}}`},mx={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:fx,code(e){let{gen:t,schema:r,data:o,it:n}=e;if((0,px.alwaysValidSchema)(n,r))return;let s=t.name("valid");t.forIn("key",o,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,Hh.not)(s),()=>{e.error(!0),n.allErrors||t.break()})}),e.ok(s)}};hc.default=mx});var _c=S(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var rs=Le(),Ge=j(),hx=dt(),os=U(),gx={message:"must NOT have additional properties",params:({params:e})=>(0,Ge._)`{additionalProperty: ${e.additionalProperty}}`},_x={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:gx,code(e){let{gen:t,schema:r,parentSchema:o,data:n,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,os.alwaysValidSchema)(i,r))return;let u=(0,rs.allSchemaProperties)(o.properties),l=(0,rs.allSchemaProperties)(o.patternProperties);d(),e.ok((0,Ge._)`${s} === ${hx.default.errors}`);function d(){t.forIn("key",n,v=>{!u.length&&!l.length?h(v):t.if(f(v),()=>h(v))})}function f(v){let $;if(u.length>8){let k=(0,os.schemaRefOrVal)(i,o.properties,"properties");$=(0,rs.isOwnProperty)(t,k,v)}else u.length?$=(0,Ge.or)(...u.map(k=>(0,Ge._)`${v} === ${k}`)):$=Ge.nil;return l.length&&($=(0,Ge.or)($,...l.map(k=>(0,Ge._)`${(0,rs.usePattern)(e,k)}.test(${v})`))),(0,Ge.not)($)}function m(v){t.code((0,Ge._)`delete ${n}[${v}]`)}function h(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(v);return}if(r===!1){e.setParams({additionalProperty:v}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,os.alwaysValidSchema)(i,r)){let $=t.name("valid");c.removeAdditional==="failing"?(_(v,$,!1),t.if((0,Ge.not)($),()=>{e.reset(),m(v)})):(_(v,$),a||t.if((0,Ge.not)($),()=>t.break()))}}function _(v,$,k){let z={keyword:"additionalProperties",dataProp:v,dataPropType:os.Type.Str};k===!1&&Object.assign(z,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(z,$)}}};gc.default=_x});var Wh=S(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var yx=yo(),Jh=Le(),yc=U(),Bh=_c(),vx={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:o,data:n,it:s}=e;s.opts.removeAdditional==="all"&&o.additionalProperties===void 0&&Bh.default.code(new yx.KeywordCxt(s,Bh.default,"additionalProperties"));let i=(0,Jh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=yc.mergeEvaluated.props(t,(0,yc.toHash)(i),s.props));let a=i.filter(d=>!(0,yc.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,Jh.propertyInData)(t,n,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};vc.default=vx});var Xh=S($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});var Gh=Le(),ns=j(),Yh=U(),Qh=U(),$x={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:o,parentSchema:n,it:s}=e,{opts:i}=s,a=(0,Gh.allSchemaProperties)(r),c=a.filter(_=>(0,Yh.alwaysValidSchema)(s,r[_]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&n.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof ns.Name)&&(s.props=(0,Qh.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let _ of a)u&&m(_),s.allErrors?h(_):(t.var(l,!0),h(_),t.if(l))}function m(_){for(let v in u)new RegExp(_).test(v)&&(0,Yh.checkStrictMode)(s,`property ${v} matches pattern ${_} (use allowMatchingProperties)`)}function h(_){t.forIn("key",o,v=>{t.if((0,ns._)`${(0,Gh.usePattern)(e,_)}.test(${v})`,()=>{let $=c.includes(_);$||e.subschema({keyword:"patternProperties",schemaProp:_,dataProp:v,dataPropType:Qh.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,ns._)`${d}[${v}]`,!0):!$&&!s.allErrors&&t.if((0,ns.not)(l),()=>t.break())})})}}};$c.default=$x});var eg=S(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var wx=U(),bx={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:o}=e;if((0,wx.alwaysValidSchema)(o,r)){e.fail();return}let n=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),e.failResult(n,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};wc.default=bx});var tg=S(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var zx=Le(),xx={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:zx.validateUnion,error:{message:"must match a schema in anyOf"}};bc.default=xx});var rg=S(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var ss=j(),Sx=U(),kx={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ss._)`{passingSchemas: ${e.passing}}`},Px={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:kx,code(e){let{gen:t,schema:r,parentSchema:o,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&o.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,Sx.alwaysValidSchema)(n,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,ss._)`${c} && ${i}`).assign(i,!1).assign(a,(0,ss._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,ss.Name)})})}}};zc.default=Px});var og=S(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var Ex=U(),Tx={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let n=t.name("valid");r.forEach((s,i)=>{if((0,Ex.alwaysValidSchema)(o,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},n);e.ok(n),e.mergeEvaluated(a)})}};xc.default=Tx});var ig=S(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var is=j(),sg=U(),Rx={message:({params:e})=>(0,is.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,is._)`{failingKeyword: ${e.ifClause}}`},Ox={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Rx,code(e){let{gen:t,parentSchema:r,it:o}=e;r.then===void 0&&r.else===void 0&&(0,sg.checkStrictMode)(o,'"if" without "then" and "else" is ignored');let n=ng(o,"then"),s=ng(o,"else");if(!n&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),n&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else n?t.if(a,u("then")):t.if((0,is.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,is._)`${l}`):e.setParams({ifClause:l})}}}};function ng(e,t){let r=e.schema[t];return r!==void 0&&!(0,sg.alwaysValidSchema)(e,r)}Sc.default=Ox});var ag=S(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});var Ix=U(),Ax={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Ix.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};kc.default=Ax});var cg=S(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var Cx=uc(),Nx=qh(),jx=lc(),Zx=Dh(),qx=Uh(),Mx=Vh(),Dx=Kh(),Ux=_c(),Lx=Wh(),Fx=Xh(),Vx=eg(),Hx=tg(),Kx=rg(),Jx=og(),Bx=ig(),Wx=ag();function Gx(e=!1){let t=[Vx.default,Hx.default,Kx.default,Jx.default,Bx.default,Wx.default,Dx.default,Ux.default,Mx.default,Lx.default,Fx.default];return e?t.push(Nx.default,Zx.default):t.push(Cx.default,jx.default),t.push(qx.default),t}Pc.default=Gx});var ug=S(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var ce=j(),Yx={message:({schemaCode:e})=>(0,ce.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ce._)`{format: ${e}}`},Qx={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Yx,code(e,t){let{gen:r,data:o,$data:n,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;n?f():m();function f(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),_=r.const("fDef",(0,ce._)`${h}[${i}]`),v=r.let("fType"),$=r.let("format");r.if((0,ce._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(v,(0,ce._)`${_}.type || "string"`).assign($,(0,ce._)`${_}.validate`),()=>r.assign(v,(0,ce._)`"string"`).assign($,_)),e.fail$data((0,ce.or)(k(),z()));function k(){return c.strictSchema===!1?ce.nil:(0,ce._)`${i} && !${$}`}function z(){let P=l.$async?(0,ce._)`(${_}.async ? await ${$}(${o}) : ${$}(${o}))`:(0,ce._)`${$}(${o})`,y=(0,ce._)`(typeof ${$} == "function" ? ${P} : ${$}.test(${o}))`;return(0,ce._)`${$} && ${$} !== true && ${v} === ${t} && !${y}`}}function m(){let h=d.formats[s];if(!h){k();return}if(h===!0)return;let[_,v,$]=z(h);_===t&&e.pass(P());function k(){if(c.strictSchema===!1){d.logger.warn(y());return}throw new Error(y());function y(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function z(y){let w=y instanceof RegExp?(0,ce.regexpCode)(y):c.code.formats?(0,ce._)`${c.code.formats}${(0,ce.getProperty)(s)}`:void 0,A=r.scopeValue("formats",{key:s,ref:y,code:w});return typeof y=="object"&&!(y instanceof RegExp)?[y.type||"string",y.validate,(0,ce._)`${A}.validate`]:["string",y,A]}function P(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ce._)`await ${$}(${o})`}return typeof v=="function"?(0,ce._)`${$}(${o})`:(0,ce._)`${$}.test(${o})`}}}};Ec.default=Qx});var lg=S(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var Xx=ug(),eS=[Xx.default];Tc.default=eS});var dg=S(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.contentVocabulary=Pr.metadataVocabulary=void 0;Pr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Pr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var fg=S(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});var tS=$h(),rS=Ch(),oS=cg(),nS=lg(),pg=dg(),sS=[tS.default,rS.default,(0,oS.default)(),nS.default,pg.metadataVocabulary,pg.contentVocabulary];Rc.default=sS});var hg=S(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.DiscrError=void 0;var mg;(function(e){e.Tag="tag",e.Mapping="mapping"})(mg||(as.DiscrError=mg={}))});var _g=S(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var Er=j(),Oc=hg(),gg=Vn(),iS=vo(),aS=U(),cS={message:({params:{discrError:e,tagName:t}})=>e===Oc.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Er._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},uS={keyword:"discriminator",type:"object",schemaType:"object",error:cS,code(e){let{gen:t,data:r,schema:o,parentSchema:n,it:s}=e,{oneOf:i}=n;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=o.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(o.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Er._)`${r}${(0,Er.getProperty)(a)}`);t.if((0,Er._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Oc.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let m=f();t.if(!1);for(let h in m)t.elseIf((0,Er._)`${u} === ${h}`),t.assign(c,d(m[h]));t.else(),e.error(!1,{discrError:Oc.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(m){let h=t.name("valid"),_=e.subschema({keyword:"oneOf",schemaProp:m},h);return e.mergeEvaluated(_,Er.Name),h}function f(){var m;let h={},_=$(n),v=!0;for(let P=0;P<i.length;P++){let y=i[P];if(y?.$ref&&!(0,aS.schemaHasRulesButRef)(y,s.self.RULES)){let A=y.$ref;if(y=gg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,A),y instanceof gg.SchemaEnv&&(y=y.schema),y===void 0)throw new iS.default(s.opts.uriResolver,s.baseId,A)}let w=(m=y?.properties)===null||m===void 0?void 0:m[a];if(typeof w!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);v=v&&(_||$(y)),k(w,P)}if(!v)throw new Error(`discriminator: "${a}" must be required`);return h;function $({required:P}){return Array.isArray(P)&&P.includes(a)}function k(P,y){if(P.const)z(P.const,y);else if(P.enum)for(let w of P.enum)z(w,y);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function z(P,y){if(typeof P!="string"||P in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[P]=y}}}};Ic.default=uS});var yg=S((H1,lS)=>{lS.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var Cc=S((te,Ac)=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MissingRefError=te.ValidationError=te.CodeGen=te.Name=te.nil=te.stringify=te.str=te._=te.KeywordCxt=te.Ajv=void 0;var dS=mh(),pS=fg(),fS=_g(),vg=yg(),mS=["/properties"],cs="http://json-schema.org/draft-07/schema",Tr=class extends dS.default{_addVocabularies(){super._addVocabularies(),pS.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(fS.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(vg,mS):vg;this.addMetaSchema(t,cs,!1),this.refs["http://json-schema.org/schema"]=cs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(cs)?cs:void 0)}};te.Ajv=Tr;Ac.exports=te=Tr;Ac.exports.Ajv=Tr;Object.defineProperty(te,"__esModule",{value:!0});te.default=Tr;var hS=yo();Object.defineProperty(te,"KeywordCxt",{enumerable:!0,get:function(){return hS.KeywordCxt}});var Rr=j();Object.defineProperty(te,"_",{enumerable:!0,get:function(){return Rr._}});Object.defineProperty(te,"str",{enumerable:!0,get:function(){return Rr.str}});Object.defineProperty(te,"stringify",{enumerable:!0,get:function(){return Rr.stringify}});Object.defineProperty(te,"nil",{enumerable:!0,get:function(){return Rr.nil}});Object.defineProperty(te,"Name",{enumerable:!0,get:function(){return Rr.Name}});Object.defineProperty(te,"CodeGen",{enumerable:!0,get:function(){return Rr.CodeGen}});var gS=Ln();Object.defineProperty(te,"ValidationError",{enumerable:!0,get:function(){return gS.default}});var _S=vo();Object.defineProperty(te,"MissingRefError",{enumerable:!0,get:function(){return _S.default}})});var Pg=S(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.formatNames=ot.fastFormats=ot.fullFormats=void 0;function rt(e,t){return{validate:e,compare:t}}ot.fullFormats={date:rt(zg,qc),time:rt(jc(!0),Mc),"date-time":rt($g(!0),Sg),"iso-time":rt(jc(),xg),"iso-date-time":rt($g(),kg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:zS,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:RS,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:xS,int32:{type:"number",validate:PS},int64:{type:"number",validate:ES},float:{type:"number",validate:bg},double:{type:"number",validate:bg},password:!0,binary:!0};ot.fastFormats={...ot.fullFormats,date:rt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,qc),time:rt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Mc),"date-time":rt(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Sg),"iso-time":rt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,xg),"iso-date-time":rt(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,kg),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};ot.formatNames=Object.keys(ot.fullFormats);function yS(e){return e%4===0&&(e%100!==0||e%400===0)}var vS=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,$S=[0,31,28,31,30,31,30,31,31,30,31,30,31];function zg(e){let t=vS.exec(e);if(!t)return!1;let r=+t[1],o=+t[2],n=+t[3];return o>=1&&o<=12&&n>=1&&n<=(o===2&&yS(r)?29:$S[o])}function qc(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Nc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function jc(e){return function(r){let o=Nc.exec(r);if(!o)return!1;let n=+o[1],s=+o[2],i=+o[3],a=o[4],c=o[5]==="-"?-1:1,u=+(o[6]||0),l=+(o[7]||0);if(u>23||l>59||e&&!a)return!1;if(n<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=n-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function Mc(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),o=new Date("2020-01-01T"+t).valueOf();if(r&&o)return r-o}function xg(e,t){if(!(e&&t))return;let r=Nc.exec(e),o=Nc.exec(t);if(r&&o)return e=r[1]+r[2]+r[3],t=o[1]+o[2]+o[3],e>t?1:e<t?-1:0}var Zc=/t|\s/i;function $g(e){let t=jc(e);return function(o){let n=o.split(Zc);return n.length===2&&zg(n[0])&&t(n[1])}}function Sg(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),o=new Date(t).valueOf();if(r&&o)return r-o}function kg(e,t){if(!(e&&t))return;let[r,o]=e.split(Zc),[n,s]=t.split(Zc),i=qc(r,n);if(i!==void 0)return i||Mc(o,s)}var wS=/\/|:/,bS=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function zS(e){return wS.test(e)&&bS.test(e)}var wg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function xS(e){return wg.lastIndex=0,wg.test(e)}var SS=-(2**31),kS=2**31-1;function PS(e){return Number.isInteger(e)&&e<=kS&&e>=SS}function ES(e){return Number.isInteger(e)}function bg(){return!0}var TS=/[^\\]\\Z/;function RS(e){if(TS.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var Eg=S(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.formatLimitDefinition=void 0;var OS=Cc(),Ye=j(),It=Ye.operators,us={formatMaximum:{okStr:"<=",ok:It.LTE,fail:It.GT},formatMinimum:{okStr:">=",ok:It.GTE,fail:It.LT},formatExclusiveMaximum:{okStr:"<",ok:It.LT,fail:It.GTE},formatExclusiveMinimum:{okStr:">",ok:It.GT,fail:It.LTE}},IS={message:({keyword:e,schemaCode:t})=>(0,Ye.str)`should be ${us[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ye._)`{comparison: ${us[e].okStr}, limit: ${t}}`};Or.formatLimitDefinition={keyword:Object.keys(us),type:"string",schemaType:"string",$data:!0,error:IS,code(e){let{gen:t,data:r,schemaCode:o,keyword:n,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new OS.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=t.const("fmt",(0,Ye._)`${f}[${c.schemaCode}]`);e.fail$data((0,Ye.or)((0,Ye._)`typeof ${m} != "object"`,(0,Ye._)`${m} instanceof RegExp`,(0,Ye._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let f=c.schema,m=a.formats[f];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${n}": format "${f}" does not define "compare" function`);let h=t.scopeValue("formats",{key:f,ref:m,code:i.code.formats?(0,Ye._)`${i.code.formats}${(0,Ye.getProperty)(f)}`:void 0});e.fail$data(d(h))}function d(f){return(0,Ye._)`${f}.compare(${r}, ${o}) ${us[n].fail} 0`}},dependencies:["format"]};var AS=e=>(e.addKeyword(Or.formatLimitDefinition),e);Or.default=AS});var Ig=S((Ao,Og)=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});var Ir=Pg(),CS=Eg(),Dc=j(),Tg=new Dc.Name("fullFormats"),NS=new Dc.Name("fastFormats"),Uc=(e,t={keywords:!0})=>{if(Array.isArray(t))return Rg(e,t,Ir.fullFormats,Tg),e;let[r,o]=t.mode==="fast"?[Ir.fastFormats,NS]:[Ir.fullFormats,Tg],n=t.formats||Ir.formatNames;return Rg(e,n,r,o),t.keywords&&(0,CS.default)(e),e};Uc.get=(e,t="full")=>{let o=(t==="fast"?Ir.fastFormats:Ir.fullFormats)[e];if(!o)throw new Error(`Unknown format "${e}"`);return o};function Rg(e,t,r,o){var n,s;(n=(s=e.opts.code).formats)!==null&&n!==void 0||(s.formats=(0,Dc._)`require("ajv-formats/dist/formats").${o}`);for(let i of t)e.addFormat(i,r[i])}Og.exports=Ao=Uc;Object.defineProperty(Ao,"__esModule",{value:!0});Ao.default=Uc});import{existsSync as Xc,mkdirSync as dk,readFileSync as pk,rmSync as fk,writeFileSync as mk}from"node:fs";import{homedir as hk}from"node:os";import{join as r_}from"node:path";var iu,xs=Object.freeze({status:"aborted"});function g(e,t,r){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let f=l[d];f in a||(a[f]=u[f].bind(a))}}let n=r?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function i(a){var c;let u=r?.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var h_=Symbol("zod_brand"),Qe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},tr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(iu=globalThis).__zod_globalConfig??(iu.__zod_globalConfig={});var rr=globalThis.__zod_globalConfig;function Te(e){return e&&Object.assign(rr,e),rr}var M={};zs(M,{BIGINT_FORMAT_RANGES:()=>lu,Class:()=>ks,NUMBER_FORMAT_RANGES:()=>Is,aborted:()=>$t,allowsEval:()=>Ts,assert:()=>$_,assertEqual:()=>g_,assertIs:()=>y_,assertNever:()=>v_,assertNotEqual:()=>__,assignProp:()=>yt,base64ToUint8Array:()=>pu,base64urlToUint8Array:()=>Z_,cached:()=>nr,captureStackTrace:()=>Qo,cleanEnum:()=>j_,cleanRegex:()=>qr,clone:()=>Ze,cloneDef:()=>b_,createTransparentProxy:()=>E_,defineLazy:()=>H,esc:()=>Yo,escapeRegex:()=>st,explicitlyAborted:()=>As,extend:()=>O_,finalizeIssue:()=>qe,floatSafeRemainder:()=>Ps,getElementAtPath:()=>z_,getEnumValues:()=>jr,getLengthableOrigin:()=>Mr,getParsedType:()=>P_,getSizableOrigin:()=>du,hexToUint8Array:()=>M_,isObject:()=>Nt,isPlainObject:()=>vt,issue:()=>sr,joinValues:()=>Go,jsonStringifyReplacer:()=>or,merge:()=>A_,mergeDefs:()=>nt,normalizeParams:()=>R,nullish:()=>Zr,numKeys:()=>k_,objectClone:()=>w_,omit:()=>R_,optionalKeys:()=>Os,parsedType:()=>Cs,partial:()=>C_,pick:()=>T_,prefixIssues:()=>it,primitiveTypes:()=>uu,promiseAllObject:()=>x_,propertyKeyTypes:()=>Rs,randomString:()=>S_,required:()=>N_,safeExtend:()=>I_,shallowClone:()=>cu,slugify:()=>Es,stringifyPrimitive:()=>Xo,uint8ArrayToBase64:()=>fu,uint8ArrayToBase64url:()=>q_,uint8ArrayToHex:()=>D_,unwrapMessage:()=>Nr});function g_(e){return e}function __(e){return e}function y_(e){}function v_(e){throw new Error("Unexpected value in exhaustive check")}function $_(e){}function jr(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Go(e,t="|"){return e.map(r=>Xo(r)).join(t)}function or(e,t){return typeof t=="bigint"?t.toString():t}function nr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Zr(e){return e==null}function qr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ps(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var au=Symbol("evaluating");function H(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==au)return o===void 0&&(o=au,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function w_(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function yt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function nt(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function b_(e){return nt(e._zod.def)}function z_(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function x_(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=o[s];return n})}function S_(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function Yo(e){return JSON.stringify(e)}function Es(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Qo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ts=nr(()=>{if(rr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function vt(e){if(Nt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Nt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function cu(e){return vt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function k_(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var P_=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Rs=new Set(["string","number","symbol"]),uu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function st(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ze(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function R(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 new 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 E_(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,s){return t??(t=e()),Reflect.set(t,o,n,s)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function Xo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Os(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Is={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},lu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function T_(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=nt(e._zod.def,{get shape(){let i={};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=r.shape[a])}return yt(this,"shape",i),i},checks:[]});return Ze(e,s)}function R_(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=nt(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return yt(this,"shape",i),i},checks:[]});return Ze(e,s)}function O_(e,t){if(!vt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=nt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return yt(this,"shape",s),s}});return Ze(e,n)}function I_(e,t){if(!vt(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=nt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return yt(this,"shape",o),o}});return Ze(e,r)}function A_(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=nt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return yt(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ze(e,r)}function C_(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=nt(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return yt(this,"shape",c),c},checks:[]});return Ze(t,i)}function N_(e,t,r){let o=nt(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new e({type:"nonoptional",innerType:n[i]}))}else for(let i in n)s[i]=new e({type:"nonoptional",innerType:n[i]});return yt(this,"shape",s),s}});return Ze(t,o)}function $t(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function As(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function it(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Nr(e){return typeof e=="string"?e:e?.message}function qe(e,t,r){let o=e.message?e.message:Nr(e.inst?._zod.def?.error?.(e))??Nr(t?.error?.(e))??Nr(r.customError?.(e))??Nr(r.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:i,...a}=e;return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=i),a}function du(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Mr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Cs(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function sr(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function j_(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function pu(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function fu(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Z_(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return pu(t+r)}function q_(e){return fu(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function M_(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function D_(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ks=class{constructor(...t){}};var mu=(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,or,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},en=g("$ZodError",mu),Ns=g("$ZodError",mu,{Parent:Error});function js(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Zs(e,t=r=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")o({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")o({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return o(e),r}var tn=e=>(t,r,o,n)=>{let s=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Qe;if(i.issues.length){let a=new(n?.Err??e)(i.issues.map(c=>qe(c,s,Te())));throw Qo(a,n?.callee),a}return i.value};var rn=e=>async(t,r,o,n)=>{let s=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(n?.Err??e)(i.issues.map(c=>qe(c,s,Te())));throw Qo(a,n?.callee),a}return i.value};var Dr=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new Qe;return s.issues.length?{success:!1,error:new(e??en)(s.issues.map(i=>qe(i,n,Te())))}:{success:!0,data:s.value}},Ur=Dr(Ns),Lr=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>qe(i,n,Te())))}:{success:!0,data:s.value}},on=Lr(Ns),hu=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return tn(e)(t,r,n)};var gu=e=>(t,r,o)=>tn(e)(t,r,o);var _u=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return rn(e)(t,r,n)};var yu=e=>async(t,r,o)=>rn(e)(t,r,o);var vu=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Dr(e)(t,r,n)};var $u=e=>(t,r,o)=>Dr(e)(t,r,o);var wu=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Lr(e)(t,r,n)};var bu=e=>async(t,r,o)=>Lr(e)(t,r,o);var zu=/^[cC][0-9a-z]{6,}$/,xu=/^[0-9a-z]+$/,Su=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ku=/^[0-9a-vA-V]{20}$/,Pu=/^[A-Za-z0-9]{27}$/,Eu=/^[a-zA-Z0-9_-]{21}$/,Tu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ru=/^([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})$/,qs=e=>e?new 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)$/;var Ou=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var L_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Iu(){return new RegExp(L_,"u")}var Au=/^(?:(?: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])$/,Cu=/^(([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}|:))$/;var Nu=/^((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])$/,ju=/^(([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])$/,Zu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ms=/^[A-Za-z0-9_-]*$/;var qu=/^https?$/,Mu=/^\+[1-9]\d{6,14}$/,Du="(?:(?:\\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])))",Uu=new RegExp(`^${Du}$`);function Lu(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 Fu(e){return new RegExp(`^${Lu(e)}$`)}function Vu(e){let t=Lu({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${Du}T(?:${o})$`)}var Hu=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ku=/^-?\d+n?$/,Ju=/^-?\d+$/,Ds=/^-?\d+(?:\.\d+)?$/,Bu=/^(?:true|false)$/i,Wu=/^null$/i;var Gu=/^[^A-Z]*$/,Yu=/^[^a-z]*$/;var pe=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Qu={number:"number",bigint:"bigint",object:"date"},Us=g("$ZodCheckLessThan",(e,t)=>{pe.init(e,t);let r=Qu[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ls=g("$ZodCheckGreaterThan",(e,t)=>{pe.init(e,t);let r=Qu[typeof t.value];e._zod.onattach.push(o=>{let n=o._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xu=g("$ZodCheckMultipleOf",(e,t)=>{pe.init(e,t),e._zod.onattach.push(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Ps(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),el=g("$ZodCheckNumberFormat",(e,t)=>{pe.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=Is[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=n,a.maximum=s,r&&(a.pattern=Ju)}),e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<n&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var tl=g("$ZodCheckMaxLength",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!Zr(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let n=o.value;if(n.length<=t.maximum)return;let i=Mr(n);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),rl=g("$ZodCheckMinLength",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!Zr(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let n=o.value;if(n.length>=t.minimum)return;let i=Mr(n);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ol=g("$ZodCheckLengthEquals",(e,t)=>{var r;pe.init(e,t),(r=e._zod.def).when??(r.when=o=>{let n=o.value;return!Zr(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{let n=o.value,s=n.length;if(s===t.length)return;let i=Mr(n),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Vr=g("$ZodCheckStringFormat",(e,t)=>{var r,o;pe.init(e,t),e._zod.onattach.push(n=>{let s=n._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.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})}):(o=e._zod).check??(o.check=()=>{})}),nl=g("$ZodCheckRegex",(e,t)=>{Vr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),sl=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Gu),Vr.init(e,t)}),il=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Yu),Vr.init(e,t)}),al=g("$ZodCheckIncludes",(e,t)=>{pe.init(e,t);let r=st(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),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})}}),cl=g("$ZodCheckStartsWith",(e,t)=>{pe.init(e,t);let r=new RegExp(`^${st(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),ul=g("$ZodCheckEndsWith",(e,t)=>{pe.init(e,t);let r=new RegExp(`.*${st(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var ll=g("$ZodCheckOverwrite",(e,t)=>{pe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var nn=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
16
+ `).filter(i=>i),n=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(n)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,n.join(`
17
+ `))}};var pl={major:4,minor:4,patch:3};var K=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pl;let o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(let n of o)for(let s of n._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(i,a,c)=>{let u=$t(i),l;for(let d of a){if(d._zod.def.when){if(As(i)||!d._zod.def.when(i))continue}else if(u)continue;let f=i.issues.length,m=d._zod.check(i);if(m instanceof Promise&&c?.async===!1)throw new Qe;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await m,i.issues.length!==f&&(u||(u=$t(i,f)))});else{if(i.issues.length===f)continue;u||(u=$t(i,f))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if($t(i))return i.aborted=!0,i;let u=n(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Qe;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){let u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}let c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Qe;return c.then(u=>n(u,o,a))}return n(c,o,a)}}H(e,"~standard",()=>({validate:n=>{try{let s=Ur(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return on(e,n).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),cn=g("$ZodString",(e,t)=>{K.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Hu(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Q=g("$ZodStringFormat",(e,t)=>{Vr.init(e,t),cn.init(e,t)}),wl=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ru),Q.init(e,t)}),bl=g("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=qs(o))}else t.pattern??(t.pattern=qs());Q.init(e,t)}),zl=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ou),Q.init(e,t)}),xl=g("$ZodURL",(e,t)=>{Q.init(e,t),e._zod.check=r=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===qu.source&&!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let n=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Sl=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Iu()),Q.init(e,t)}),kl=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Eu),Q.init(e,t)}),Pl=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=zu),Q.init(e,t)}),El=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=xu),Q.init(e,t)}),Tl=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Su),Q.init(e,t)}),Rl=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ku),Q.init(e,t)}),Ol=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Pu),Q.init(e,t)}),Il=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Vu(t)),Q.init(e,t)}),Al=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Uu),Q.init(e,t)}),Cl=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fu(t)),Q.init(e,t)}),Nl=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Tu),Q.init(e,t)}),jl=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Au),Q.init(e,t),e._zod.bag.format="ipv4"}),Zl=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Cu),Q.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var ql=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Nu),Q.init(e,t)}),Ml=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ju),Q.init(e,t),e._zod.check=r=>{let o=r.value.split("/");try{if(o.length!==2)throw new Error;let[n,s]=o;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Dl(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ul=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Zu),Q.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Dl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function H_(e){if(!Ms.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Dl(r)}var Ll=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ms),Q.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{H_(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Fl=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Mu),Q.init(e,t)});function K_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Vl=g("$ZodJWT",(e,t)=>{Q.init(e,t),e._zod.check=r=>{K_(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Vs=g("$ZodNumber",(e,t)=>{K.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ds,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),Hl=g("$ZodNumberFormat",(e,t)=>{el.init(e,t),Vs.init(e,t)}),Kl=g("$ZodBoolean",(e,t)=>{K.init(e,t),e._zod.pattern=Bu,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),Jl=g("$ZodBigInt",(e,t)=>{K.init(e,t),e._zod.pattern=Ku,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var Bl=g("$ZodNull",(e,t)=>{K.init(e,t),e._zod.pattern=Wu,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Wl=g("$ZodAny",(e,t)=>{K.init(e,t),e._zod.parse=r=>r}),Gl=g("$ZodUnknown",(e,t)=>{K.init(e,t),e._zod.parse=r=>r}),Yl=g("$ZodNever",(e,t)=>{K.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var Ql=g("$ZodDate",(e,t)=>{K.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,s=n instanceof Date;return s&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function fl(e,t,r){e.issues.length&&t.issues.push(...it(r,e.issues)),t.value[r]=e.value}var Xl=g("$ZodArray",(e,t)=>{K.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let s=[];for(let i=0;i<n.length;i++){let a=n[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>fl(u,r,i))):fl(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function an(e,t,r,o,n,s){let i=r in o;if(e.issues.length){if(n&&s&&!i)return;t.issues.push(...it(r,e.issues))}if(!i&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function ed(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let r=Os(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function td(e,t,r,o,n,s){let i=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(u==="never"){i.push(f);continue}let m=c.run({value:t[f],issues:[]},o);m instanceof Promise?e.push(m.then(h=>an(h,r,f,t,l,d))):an(m,r,f,t,l,d)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var J_=g("$ZodObject",(e,t)=>{if(K.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=nr(()=>ed(t));H(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let n=Nt,s=t.catchall,i;e._zod.parse=(a,c)=>{i??(i=o.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],d=i.shape;for(let f of i.keys){let m=d[f],h=m._zod.optin==="optional",_=m._zod.optout==="optional",v=m._zod.run({value:u[f],issues:[]},c);v instanceof Promise?l.push(v.then($=>an($,a,f,u,h,_))):an(v,a,f,u,h,_)}return s?td(l,u,a,c,o.value,e):l.length?Promise.all(l).then(()=>a):a}}),rd=g("$ZodObjectJIT",(e,t)=>{J_.init(e,t);let r=e._zod.parse,o=nr(()=>ed(t)),n=f=>{let m=new nn(["shape","payload","ctx"]),h=o.value,_=z=>{let P=Yo(z);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};m.write("const input = payload.value;");let v=Object.create(null),$=0;for(let z of h.keys)v[z]=`key_${$++}`;m.write("const newResult = {};");for(let z of h.keys){let P=v[z],y=Yo(z),w=f[z],A=w?._zod?.optin==="optional",se=w?._zod?.optout==="optional";m.write(`const ${P} = ${_(z)};`),A&&se?m.write(`
18
+ if (${P}.issues.length) {
19
+ if (${y} in input) {
20
+ payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
21
+ ...iss,
22
+ path: iss.path ? [${y}, ...iss.path] : [${y}]
23
+ })));
24
+ }
25
+ }
26
+
27
+ if (${P}.value === undefined) {
28
+ if (${y} in input) {
29
+ newResult[${y}] = undefined;
30
+ }
31
+ } else {
32
+ newResult[${y}] = ${P}.value;
33
+ }
34
+
35
+ `):A?m.write(`
36
+ if (${P}.issues.length) {
37
+ payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
38
+ ...iss,
39
+ path: iss.path ? [${y}, ...iss.path] : [${y}]
40
+ })));
41
+ }
42
+
43
+ if (${P}.value === undefined) {
44
+ if (${y} in input) {
45
+ newResult[${y}] = undefined;
46
+ }
47
+ } else {
48
+ newResult[${y}] = ${P}.value;
49
+ }
50
+
51
+ `):m.write(`
52
+ const ${P}_present = ${y} in input;
53
+ if (${P}.issues.length) {
54
+ payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
55
+ ...iss,
56
+ path: iss.path ? [${y}, ...iss.path] : [${y}]
57
+ })));
58
+ }
59
+ if (!${P}_present && !${P}.issues.length) {
60
+ payload.issues.push({
61
+ code: "invalid_type",
62
+ expected: "nonoptional",
63
+ input: undefined,
64
+ path: [${y}]
65
+ });
66
+ }
67
+
68
+ if (${P}_present) {
69
+ if (${P}.value === undefined) {
70
+ newResult[${y}] = undefined;
71
+ } else {
72
+ newResult[${y}] = ${P}.value;
73
+ }
74
+ }
75
+
76
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");let k=m.compile();return(z,P)=>k(f,z,P)},s,i=Nt,a=!rr.jitless,u=a&&Ts.value,l=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=o.value);let h=f.value;return i(h)?a&&u&&m?.async===!1&&m.jitless!==!0?(s||(s=n(t.shape)),f=s(f,m),l?td([],h,f,m,d,e):f):r(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f)}});function ml(e,t,r,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter(s=>!$t(s));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>qe(i,o,Te())))}),t)}var Hs=g("$ZodUnion",(e,t)=>{K.init(e,t),H(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),H(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),H(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),H(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){let o=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${o.map(n=>qr(n.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>ml(a,o,e,n)):ml(i,o,e,n)}});var od=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Hs.init(e,t);let r=e._zod.parse;H(e._zod,"propValues",()=>{let n={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){n[a]||(n[a]=new Set);for(let u of c)n[a].add(u)}}return n});let o=nr(()=>{let n=t.options,s=new Map;for(let i of n){let a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(n,s)=>{let i=n.value;if(!Nt(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let a=o.value.get(i?.[t.discriminator]);return a?a._zod.run(n,s):t.unionFallback||s.direction==="backward"?r(n,s):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:i,path:[t.discriminator],inst:e}),n)}}),nd=g("$ZodIntersection",(e,t)=>{K.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,s=t.left._zod.run({value:n,issues:[]},o),i=t.right._zod.run({value:n,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>hl(r,c,u)):hl(r,s,i)}});function Fs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(vt(e)&&vt(t)){let r=Object.keys(t),o=Object.keys(e).filter(s=>r.indexOf(s)!==-1),n={...e,...t};for(let s of o){let i=Fs(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],s=t[o],i=Fs(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function hl(e,t,r){let o=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);let s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&n&&e.issues.push({...n,keys:s}),$t(e))return e;let i=Fs(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var sd=g("$ZodRecord",(e,t)=>{K.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!vt(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let s=[],i=t.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>qe(m,o,Te())),input:u,path:[u],inst:e});continue}let d=l.value,f=t.valueType._zod.run({value:n[u],issues:[]},o);f instanceof Promise?s.push(f.then(m=>{m.issues.length&&r.issues.push(...it(u,m.issues)),r.value[d]=m.value})):(f.issues.length&&r.issues.push(...it(u,f.issues)),r.value[d]=f.value)}let c;for(let u in n)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Ds.test(a)&&c.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[a]=n[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>qe(d,o,Te())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:n[a],issues:[]},o);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...it(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...it(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var id=g("$ZodEnum",(e,t)=>{K.init(e,t);let r=jr(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter(n=>Rs.has(typeof n)).map(n=>typeof n=="string"?st(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let i=n.value;return o.has(i)||n.issues.push({code:"invalid_value",values:r,input:i,inst:e}),n}}),ad=g("$ZodLiteral",(e,t)=>{if(K.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?st(o):o?st(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var cd=g("$ZodTransform",(e,t)=>{K.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new tr(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(i=>(r.value=i,r.fallback=!0,r));if(n instanceof Promise)throw new Qe;return r.value=n,r.fallback=!0,r}});function gl(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ks=g("$ZodOptional",(e,t)=>{K.init(e,t),e._zod.optin="optional",e._zod.optout="optional",H(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),H(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${qr(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,s=t.innerType._zod.run(r,o);return s instanceof Promise?s.then(i=>gl(i,n)):gl(s,n)}return r.value===void 0?r:t.innerType._zod.run(r,o)}}),ud=g("$ZodExactOptional",(e,t)=>{Ks.init(e,t),H(e._zod,"values",()=>t.innerType._zod.values),H(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),ld=g("$ZodNullable",(e,t)=>{K.init(e,t),H(e._zod,"optin",()=>t.innerType._zod.optin),H(e._zod,"optout",()=>t.innerType._zod.optout),H(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${qr(r.source)}|null)$`):void 0}),H(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,o)}),dd=g("$ZodDefault",(e,t)=>{K.init(e,t),e._zod.optin="optional",H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(s=>_l(s,t)):_l(n,t)}});function _l(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var pd=g("$ZodPrefault",(e,t)=>{K.init(e,t),e._zod.optin="optional",H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>(o.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,o))}),fd=g("$ZodNonOptional",(e,t)=>{K.init(e,t),H(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(s=>yl(s,e)):yl(n,e)}});function yl(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 md=g("$ZodCatch",(e,t)=>{K.init(e,t),e._zod.optin="optional",H(e._zod,"optout",()=>t.innerType._zod.optout),H(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>qe(i,o,Te()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(s=>qe(s,o,Te()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var Js=g("$ZodPipe",(e,t)=>{K.init(e,t),H(e._zod,"values",()=>t.in._zod.values),H(e._zod,"optin",()=>t.in._zod.optin),H(e._zod,"optout",()=>t.out._zod.optout),H(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(r,o);return s instanceof Promise?s.then(i=>sn(i,t.in,o)):sn(s,t.in,o)}let n=t.in._zod.run(r,o);return n instanceof Promise?n.then(s=>sn(s,t.out,o)):sn(n,t.out,o)}});function sn(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var hd=g("$ZodPreprocess",(e,t)=>{Js.init(e,t)}),gd=g("$ZodReadonly",(e,t)=>{K.init(e,t),H(e._zod,"propValues",()=>t.innerType._zod.propValues),H(e._zod,"values",()=>t.innerType._zod.values),H(e._zod,"optin",()=>t.innerType?._zod?.optin),H(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(vl):vl(n)}});function vl(e){return e.value=Object.freeze(e.value),e}var _d=g("$ZodCustom",(e,t)=>{pe.init(e,t),K.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=r=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then(s=>$l(s,r,o,e));$l(n,r,o,e)}});function $l(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),t.issues.push(sr(n))}}var B_=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let s=o[n.expected]??n.expected,i=Cs(n.input),a=o[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${Xo(n.values[0])}`:`Invalid option: expected one of ${Go(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=t(n.origin);return i?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=t(n.origin);return i?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Go(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function yd(){return{localeError:B_()}}var vd,W_=Symbol("ZodOutput"),G_=Symbol("ZodInput"),Bs=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let o=r[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let o={...this.get(r)??{}};delete o.id;let n={...o,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function $d(){return new Bs}(vd=globalThis).__zod_globalRegistry??(vd.__zod_globalRegistry=$d());var wt=globalThis.__zod_globalRegistry;function wd(e,t){return new e({type:"string",...R(t)})}function bd(e,t){return new e({type:"string",coerce:!0,...R(t)})}function zd(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...R(t)})}function Ws(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...R(t)})}function xd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...R(t)})}function Sd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(t)})}function kd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(t)})}function Pd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(t)})}function Gs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...R(t)})}function Ed(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...R(t)})}function Td(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(t)})}function Rd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...R(t)})}function Od(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(t)})}function Id(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...R(t)})}function Ad(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...R(t)})}function Cd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(t)})}function Nd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(t)})}function jd(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(t)})}function Zd(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(t)})}function qd(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(t)})}function Md(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...R(t)})}function Dd(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...R(t)})}function Ud(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...R(t)})}function Ld(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...R(t)})}function Fd(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(t)})}function Vd(e,t){return new e({type:"string",format:"date",check:"string_format",...R(t)})}function Hd(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...R(t)})}function Kd(e,t){return new e({type:"string",format:"duration",check:"string_format",...R(t)})}function Jd(e,t){return new e({type:"number",checks:[],...R(t)})}function Bd(e,t){return new e({type:"number",coerce:!0,checks:[],...R(t)})}function Wd(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...R(t)})}function Gd(e,t){return new e({type:"boolean",...R(t)})}function Yd(e,t){return new e({type:"boolean",coerce:!0,...R(t)})}function Qd(e,t){return new e({type:"bigint",coerce:!0,...R(t)})}function Xd(e,t){return new e({type:"null",...R(t)})}function ep(e){return new e({type:"any"})}function tp(e){return new e({type:"unknown"})}function rp(e,t){return new e({type:"never",...R(t)})}function op(e,t){return new e({type:"date",coerce:!0,...R(t)})}function ir(e,t){return new Us({check:"less_than",...R(t),value:e,inclusive:!1})}function at(e,t){return new Us({check:"less_than",...R(t),value:e,inclusive:!0})}function ar(e,t){return new Ls({check:"greater_than",...R(t),value:e,inclusive:!1})}function He(e,t){return new Ls({check:"greater_than",...R(t),value:e,inclusive:!0})}function Hr(e,t){return new Xu({check:"multiple_of",...R(t),value:e})}function un(e,t){return new tl({check:"max_length",...R(t),maximum:e})}function cr(e,t){return new rl({check:"min_length",...R(t),minimum:e})}function ln(e,t){return new ol({check:"length_equals",...R(t),length:e})}function Ys(e,t){return new nl({check:"string_format",format:"regex",...R(t),pattern:e})}function Qs(e){return new sl({check:"string_format",format:"lowercase",...R(e)})}function Xs(e){return new il({check:"string_format",format:"uppercase",...R(e)})}function ei(e,t){return new al({check:"string_format",format:"includes",...R(t),includes:e})}function ti(e,t){return new cl({check:"string_format",format:"starts_with",...R(t),prefix:e})}function ri(e,t){return new ul({check:"string_format",format:"ends_with",...R(t),suffix:e})}function bt(e){return new ll({check:"overwrite",tx:e})}function oi(e){return bt(t=>t.normalize(e))}function ni(){return bt(e=>e.trim())}function si(){return bt(e=>e.toLowerCase())}function ii(){return bt(e=>e.toUpperCase())}function ai(){return bt(e=>Es(e))}function np(e,t,r){return new e({type:"array",element:t,...R(r)})}function sp(e,t,r){let o=R(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function ip(e,t,r){return new e({type:"custom",check:"custom",fn:t,...R(r)})}function ap(e,t){let r=Y_(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(sr(n,o.value,r._zod.def));else{let s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=o.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),o.issues.push(sr(s))}},e(o.value,o)),t);return r}function Y_(e,t){let r=new pe({check:"custom",...R(t)});return r._zod.check=e,r}function ci(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??wt,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 ae(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,m=t.processors[n.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);m(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ae(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&xe(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ui(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=o.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,i[0])}}let n=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(h=>h);if(d)return{ref:f(d)};let m=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=m,{defId:m,ref:`${f("__shared")}#/${a}/${m}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=n(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
77
+
78
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function li(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){o(d);let m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,l),a._zod.parent===d)for(let v in u)v==="$ref"||v==="allOf"||v in l||delete u[v];if(h.$ref&&m.def)for(let v in u)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(u[v])===JSON.stringify(m.def[v])&&delete u[v]}let f=a._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let h in u)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&n.id===s&&delete n.id;let i=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Kr(t,"input",e.processors),output:Kr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function xe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return xe(o.element,r);if(o.type==="set")return xe(o.valueType,r);if(o.type==="lazy")return xe(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return xe(o.innerType,r);if(o.type==="intersection")return xe(o.left,r)||xe(o.right,r);if(o.type==="record"||o.type==="map")return xe(o.keyType,r)||xe(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:xe(o.in,r)||xe(o.out,r);if(o.type==="object"){for(let n in o.shape)if(xe(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(xe(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(xe(n,r))return!0;return!!(o.rest&&xe(o.rest,r))}return!1}var cp=(e,t={})=>r=>{let o=ci({...r,processors:t});return ae(e,o),ui(o,e),li(o,e)},Kr=(e,t,r={})=>o=>{let{libraryOptions:n,target:s}=o??{},i=ci({...n??{},target:s,io:t,processors:r});return ae(e,i),ui(i,e),li(i,e)};var Q_={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},up=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(n.minLength=s),typeof i=="number"&&(n.maxLength=i),a&&(n.format=Q_[a]??a,n.format===""&&delete n.format,a==="time"&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?n.pattern=l[0].source:l.length>1&&(n.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},lp=(e,t,r,o)=>{let n=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof a=="string"&&a.includes("int")?n.type="integer":n.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";d?m?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof s=="number"&&(n.minimum=s),f?m?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof i=="number"&&(n.maximum=i),typeof c=="number"&&(n.multipleOf=c)},dp=(e,t,r,o)=>{r.type="boolean"},pp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")};var fp=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var mp=(e,t,r,o)=>{r.not={}},hp=(e,t,r,o)=>{},gp=(e,t,r,o)=>{},_p=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},yp=(e,t,r,o)=>{let n=e._zod.def,s=jr(n.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},vp=(e,t,r,o)=>{let n=e._zod.def,s=[];for(let i of n.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var $p=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var wp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var bp=(e,t,r,o)=>{let n=r,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(n.minItems=i),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=ae(s.element,t,{...o,path:[...o.path,"items"]})},zp=(e,t,r,o)=>{let n=r,s=e._zod.def;n.type="object",n.properties={};let i=s.shape;for(let u in i)n.properties[u]=ae(i[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(n.required=Array.from(c)),s.catchall?._zod.def.type==="never"?n.additionalProperties=!1:s.catchall?s.catchall&&(n.additionalProperties=ae(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},xp=(e,t,r,o)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((a,c)=>ae(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Sp=(e,t,r,o)=>{let n=e._zod.def,s=ae(n.left,t,{...o,path:[...o.path,"allOf",0]}),i=ae(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c};var kp=(e,t,r,o)=>{let n=r,s=e._zod.def;n.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=ae(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=ae(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),n.additionalProperties=ae(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l)}},Pp=(e,t,r,o)=>{let n=e._zod.def,s=ae(n.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=n.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Ep=(e,t,r,o)=>{let n=e._zod.def;ae(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},Tp=(e,t,r,o)=>{let n=e._zod.def;ae(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Rp=(e,t,r,o)=>{let n=e._zod.def;ae(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Op=(e,t,r,o)=>{let n=e._zod.def;ae(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Ip=(e,t,r,o)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;ae(i,t,o);let a=t.seen.get(e);a.ref=i},Ap=(e,t,r,o)=>{let n=e._zod.def;ae(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.readOnly=!0};var di=(e,t,r,o)=>{let n=e._zod.def;ae(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType};function lr(e){return!!e._zod}function Ke(e,t){return lr(e)?Ur(e,t):e.safeParse(t)}function dn(e){if(!e)return;let t;if(lr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Cp(e){if(lr(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let o=e.value;if(o!==void 0)return o}var Jr={};zs(Jr,{ZodISODate:()=>jp,ZodISODateTime:()=>Np,ZodISODuration:()=>qp,ZodISOTime:()=>Zp,date:()=>fi,datetime:()=>pi,duration:()=>hi,time:()=>mi});var Np=g("ZodISODateTime",(e,t)=>{Il.init(e,t),re.init(e,t)});function pi(e){return Fd(Np,e)}var jp=g("ZodISODate",(e,t)=>{Al.init(e,t),re.init(e,t)});function fi(e){return Vd(jp,e)}var Zp=g("ZodISOTime",(e,t)=>{Cl.init(e,t),re.init(e,t)});function mi(e){return Hd(Zp,e)}var qp=g("ZodISODuration",(e,t)=>{Nl.init(e,t),re.init(e,t)});function hi(e){return Kd(qp,e)}var iy=(e,t)=>{en.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Zs(e,r)},flatten:{value:r=>js(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,or,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,or,2)}},isEmpty:{get(){return e.issues.length===0}}})};var Ne=g("ZodError",iy,{Parent:Error});var Dp=tn(Ne),Up=rn(Ne),Lp=Dr(Ne),Fp=Lr(Ne),Vp=hu(Ne),Hp=gu(Ne),Kp=_u(Ne),Jp=yu(Ne),Bp=vu(Ne),Wp=$u(Ne),Gp=wu(Ne),Yp=bu(Ne);var Qp=new WeakMap;function Br(e,t,r){let o=Object.getPrototypeOf(e),n=Qp.get(o);if(n||(n=new Set,Qp.set(o,n)),!n.has(t)){n.add(t);for(let s in r){let i=r[s];Object.defineProperty(o,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var B=g("ZodType",(e,t)=>(K.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Kr(e,"input"),output:Kr(e,"output")}}),e.toJSONSchema=cp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>Dp(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>Lp(e,r,o),e.parseAsync=async(r,o)=>Up(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>Fp(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>Vp(e,r,o),e.decode=(r,o)=>Hp(e,r,o),e.encodeAsync=async(r,o)=>Kp(e,r,o),e.decodeAsync=async(r,o)=>Jp(e,r,o),e.safeEncode=(r,o)=>Bp(e,r,o),e.safeDecode=(r,o)=>Wp(e,r,o),e.safeEncodeAsync=async(r,o)=>Gp(e,r,o),e.safeDecodeAsync=async(r,o)=>Yp(e,r,o),Br(e,"ZodType",{check(...r){let o=this.def;return this.clone(M.mergeDefs(o,{checks:[...o.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return Ze(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(By(r,o))},superRefine(r,o){return this.check(Wy(r,o))},overwrite(r){return this.check(bt(r))},optional(){return ne(this)},exactOptional(){return jy(this)},nullable(){return rf(this)},nullish(){return ne(rf(this))},nonoptional(r){return Ly(this,r)},array(){return b(this)},or(r){return X([this,r])},and(r){return mn(this,r)},transform(r){return of(this,mf(r))},default(r){return My(this,r)},prefault(r){return Uy(this,r)},catch(r){return Vy(this,r)},pipe(r){return of(this,r)},readonly(){return Jy(this)},describe(r){let o=this.clone();return wt.add(o,{description:r}),o},meta(...r){if(r.length===0)return wt.get(this);let o=this.clone();return wt.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return wt.get(e)?.description},configurable:!0}),e)),nf=g("_ZodString",(e,t)=>{cn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(o,n,s)=>up(e,o,n,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Br(e,"_ZodString",{regex(...o){return this.check(Ys(...o))},includes(...o){return this.check(ei(...o))},startsWith(...o){return this.check(ti(...o))},endsWith(...o){return this.check(ri(...o))},min(...o){return this.check(cr(...o))},max(...o){return this.check(un(...o))},length(...o){return this.check(ln(...o))},nonempty(...o){return this.check(cr(1,...o))},lowercase(o){return this.check(Qs(o))},uppercase(o){return this.check(Xs(o))},trim(){return this.check(ni())},normalize(...o){return this.check(oi(...o))},toLowerCase(){return this.check(si())},toUpperCase(){return this.check(ii())},slugify(){return this.check(ai())}})}),_i=g("ZodString",(e,t)=>{cn.init(e,t),nf.init(e,t),e.email=r=>e.check(zd(cy,r)),e.url=r=>e.check(Gs(sf,r)),e.jwt=r=>e.check(Ld(zy,r)),e.emoji=r=>e.check(Ed(uy,r)),e.guid=r=>e.check(Ws(Xp,r)),e.uuid=r=>e.check(xd(pn,r)),e.uuidv4=r=>e.check(Sd(pn,r)),e.uuidv6=r=>e.check(kd(pn,r)),e.uuidv7=r=>e.check(Pd(pn,r)),e.nanoid=r=>e.check(Td(ly,r)),e.guid=r=>e.check(Ws(Xp,r)),e.cuid=r=>e.check(Rd(dy,r)),e.cuid2=r=>e.check(Od(py,r)),e.ulid=r=>e.check(Id(fy,r)),e.base64=r=>e.check(Md($y,r)),e.base64url=r=>e.check(Dd(wy,r)),e.xid=r=>e.check(Ad(my,r)),e.ksuid=r=>e.check(Cd(hy,r)),e.ipv4=r=>e.check(Nd(gy,r)),e.ipv6=r=>e.check(jd(_y,r)),e.cidrv4=r=>e.check(Zd(yy,r)),e.cidrv6=r=>e.check(qd(vy,r)),e.e164=r=>e.check(Ud(by,r)),e.datetime=r=>e.check(pi(r)),e.date=r=>e.check(fi(r)),e.time=r=>e.check(mi(r)),e.duration=r=>e.check(hi(r))});function p(e){return wd(_i,e)}var re=g("ZodStringFormat",(e,t)=>{Q.init(e,t),nf.init(e,t)}),cy=g("ZodEmail",(e,t)=>{zl.init(e,t),re.init(e,t)});var Xp=g("ZodGUID",(e,t)=>{wl.init(e,t),re.init(e,t)});var pn=g("ZodUUID",(e,t)=>{bl.init(e,t),re.init(e,t)});var sf=g("ZodURL",(e,t)=>{xl.init(e,t),re.init(e,t)});function af(e){return Gs(sf,e)}var uy=g("ZodEmoji",(e,t)=>{Sl.init(e,t),re.init(e,t)});var ly=g("ZodNanoID",(e,t)=>{kl.init(e,t),re.init(e,t)});var dy=g("ZodCUID",(e,t)=>{Pl.init(e,t),re.init(e,t)});var py=g("ZodCUID2",(e,t)=>{El.init(e,t),re.init(e,t)});var fy=g("ZodULID",(e,t)=>{Tl.init(e,t),re.init(e,t)});var my=g("ZodXID",(e,t)=>{Rl.init(e,t),re.init(e,t)});var hy=g("ZodKSUID",(e,t)=>{Ol.init(e,t),re.init(e,t)});var gy=g("ZodIPv4",(e,t)=>{jl.init(e,t),re.init(e,t)});var _y=g("ZodIPv6",(e,t)=>{Zl.init(e,t),re.init(e,t)});var yy=g("ZodCIDRv4",(e,t)=>{ql.init(e,t),re.init(e,t)});var vy=g("ZodCIDRv6",(e,t)=>{Ml.init(e,t),re.init(e,t)});var $y=g("ZodBase64",(e,t)=>{Ul.init(e,t),re.init(e,t)});var wy=g("ZodBase64URL",(e,t)=>{Ll.init(e,t),re.init(e,t)});var by=g("ZodE164",(e,t)=>{Fl.init(e,t),re.init(e,t)});var zy=g("ZodJWT",(e,t)=>{Vl.init(e,t),re.init(e,t)});var fn=g("ZodNumber",(e,t)=>{Vs.init(e,t),B.init(e,t),e._zod.processJSONSchema=(o,n,s)=>lp(e,o,n,s),Br(e,"ZodNumber",{gt(o,n){return this.check(ar(o,n))},gte(o,n){return this.check(He(o,n))},min(o,n){return this.check(He(o,n))},lt(o,n){return this.check(ir(o,n))},lte(o,n){return this.check(at(o,n))},max(o,n){return this.check(at(o,n))},int(o){return this.check(ef(o))},safe(o){return this.check(ef(o))},positive(o){return this.check(ar(0,o))},nonnegative(o){return this.check(He(0,o))},negative(o){return this.check(ir(0,o))},nonpositive(o){return this.check(at(0,o))},multipleOf(o,n){return this.check(Hr(o,n))},step(o,n){return this.check(Hr(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function F(e){return Jd(fn,e)}var xy=g("ZodNumberFormat",(e,t)=>{Hl.init(e,t),fn.init(e,t)});function ef(e){return Wd(xy,e)}var yi=g("ZodBoolean",(e,t)=>{Kl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dp(e,r,o,n)});function W(e){return Gd(yi,e)}var cf=g("ZodBigInt",(e,t)=>{Jl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(o,n,s)=>pp(e,o,n,s),e.gte=(o,n)=>e.check(He(o,n)),e.min=(o,n)=>e.check(He(o,n)),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(He(o,n)),e.min=(o,n)=>e.check(He(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(at(o,n)),e.max=(o,n)=>e.check(at(o,n)),e.positive=o=>e.check(ar(BigInt(0),o)),e.negative=o=>e.check(ir(BigInt(0),o)),e.nonpositive=o=>e.check(at(BigInt(0),o)),e.nonnegative=o=>e.check(He(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(Hr(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var Sy=g("ZodNull",(e,t)=>{Bl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fp(e,r,o,n)});function uf(e){return Xd(Sy,e)}var ky=g("ZodAny",(e,t)=>{Wl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hp(e,r,o,n)});function lf(){return ep(ky)}var Py=g("ZodUnknown",(e,t)=>{Gl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gp(e,r,o,n)});function oe(){return tp(Py)}var Ey=g("ZodNever",(e,t)=>{Yl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>mp(e,r,o,n)});function Ty(e){return rp(Ey,e)}var df=g("ZodDate",(e,t)=>{Ql.init(e,t),B.init(e,t),e._zod.processJSONSchema=(o,n,s)=>_p(e,o,n,s),e.min=(o,n)=>e.check(He(o,n)),e.max=(o,n)=>e.check(at(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});var Ry=g("ZodArray",(e,t)=>{Xl.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bp(e,r,o,n),e.element=t.element,Br(e,"ZodArray",{min(r,o){return this.check(cr(r,o))},nonempty(r){return this.check(cr(1,r))},max(r,o){return this.check(un(r,o))},length(r,o){return this.check(ln(r,o))},unwrap(){return this.element}})});function b(e,t){return np(Ry,e,t)}var pf=g("ZodObject",(e,t)=>{rd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>zp(e,r,o,n),M.defineLazy(e,"shape",()=>t.shape),Br(e,"ZodObject",{keyof(){return Re(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:oe()})},loose(){return this.clone({...this._zod.def,catchall:oe()})},strict(){return this.clone({...this._zod.def,catchall:Ty()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return M.extend(this,r)},safeExtend(r){return M.safeExtend(this,r)},merge(r){return M.merge(this,r)},pick(r){return M.pick(this,r)},omit(r){return M.omit(this,r)},partial(...r){return M.partial(hf,this,r[0])},required(...r){return M.required(gf,this,r[0])}})});function x(e,t){let r={type:"object",shape:e??{},...M.normalizeParams(t)};return new pf(r)}function le(e,t){return new pf({type:"object",shape:e,catchall:oe(),...M.normalizeParams(t)})}var ff=g("ZodUnion",(e,t)=>{Hs.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xp(e,r,o,n),e.options=t.options});function X(e,t){return new ff({type:"union",options:e,...M.normalizeParams(t)})}var Oy=g("ZodDiscriminatedUnion",(e,t)=>{ff.init(e,t),od.init(e,t)});function vi(e,t,r){return new Oy({type:"union",options:t,discriminator:e,...M.normalizeParams(r)})}var Iy=g("ZodIntersection",(e,t)=>{nd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Sp(e,r,o,n)});function mn(e,t){return new Iy({type:"intersection",left:e,right:t})}var tf=g("ZodRecord",(e,t)=>{sd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>kp(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function Y(e,t,r){return!t||!t._zod?new tf({type:"record",keyType:p(),valueType:e,...M.normalizeParams(t)}):new tf({type:"record",keyType:e,valueType:t,...M.normalizeParams(r)})}var gi=g("ZodEnum",(e,t)=>{id.init(e,t),B.init(e,t),e._zod.processJSONSchema=(o,n,s)=>yp(e,o,n,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let s={};for(let i of o)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new gi({...t,checks:[],...M.normalizeParams(n),entries:s})},e.exclude=(o,n)=>{let s={...t.entries};for(let i of o)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new gi({...t,checks:[],...M.normalizeParams(n),entries:s})}});function Re(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new gi({type:"enum",entries:r,...M.normalizeParams(t)})}var Ay=g("ZodLiteral",(e,t)=>{ad.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>vp(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new Ay({type:"literal",values:Array.isArray(e)?e:[e],...M.normalizeParams(t)})}var Cy=g("ZodTransform",(e,t)=>{cd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wp(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new tr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(M.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(M.issue(i))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function mf(e){return new Cy({type:"transform",transform:e})}var hf=g("ZodOptional",(e,t)=>{Ks.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>di(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ne(e){return new hf({type:"optional",innerType:e})}var Ny=g("ZodExactOptional",(e,t)=>{ud.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>di(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function jy(e){return new Ny({type:"optional",innerType:e})}var Zy=g("ZodNullable",(e,t)=>{ld.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Pp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function rf(e){return new Zy({type:"nullable",innerType:e})}var qy=g("ZodDefault",(e,t)=>{dd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Tp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function My(e,t){return new qy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():M.shallowClone(t)}})}var Dy=g("ZodPrefault",(e,t)=>{pd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Rp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Uy(e,t){return new Dy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():M.shallowClone(t)}})}var gf=g("ZodNonOptional",(e,t)=>{fd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ep(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ly(e,t){return new gf({type:"nonoptional",innerType:e,...M.normalizeParams(t)})}var Fy=g("ZodCatch",(e,t)=>{md.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Op(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vy(e,t){return new Fy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var _f=g("ZodPipe",(e,t)=>{Js.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ip(e,r,o,n),e.in=t.in,e.out=t.out});function of(e,t){return new _f({type:"pipe",in:e,out:t})}var Hy=g("ZodPreprocess",(e,t)=>{_f.init(e,t),hd.init(e,t)}),Ky=g("ZodReadonly",(e,t)=>{gd.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ap(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Jy(e){return new Ky({type:"readonly",innerType:e})}var yf=g("ZodCustom",(e,t)=>{_d.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$p(e,r,o,n)});function vf(e,t){return sp(yf,e??(()=>!0),t)}function By(e,t={}){return ip(yf,e,t)}function Wy(e,t){return ap(e,t)}function $i(e,t){return new Hy({type:"pipe",in:mf(e),out:t})}var wf={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var $f;$f||($f={});var hn={};zs(hn,{bigint:()=>Xy,boolean:()=>Qy,date:()=>ev,number:()=>Yy,string:()=>Gy});function Gy(e){return bd(_i,e)}function Yy(e){return Bd(fn,e)}function Qy(e){return Yd(yi,e)}function Xy(e){return Qd(cf,e)}function ev(e){return op(df,e)}Te(yd());var pr="2025-11-25";var bf=[pr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],zt="io.modelcontextprotocol/related-task",_n="2.0",de=vf(e=>e!==null&&(typeof e=="object"||typeof e=="function")),zf=X([p(),F().int()]),xf=p(),JE=le({ttl:F().optional(),pollInterval:F().optional()}),rv=x({ttl:F().optional()}),ov=x({taskId:p()}),bi=le({progressToken:zf.optional(),[zt]:ov.optional()}),je=x({_meta:bi.optional()}),Wr=je.extend({task:rv.optional()}),Sf=e=>Wr.safeParse(e).success,fe=x({method:p(),params:je.loose().optional()}),Me=x({_meta:bi.optional()}),De=x({method:p(),params:Me.loose().optional()}),me=le({_meta:bi.optional()}),yn=X([p(),F().int()]),kf=x({jsonrpc:E(_n),id:yn,...fe.shape}).strict(),Gr=e=>kf.safeParse(e).success,Pf=x({jsonrpc:E(_n),...De.shape}).strict(),Ef=e=>Pf.safeParse(e).success,zi=x({jsonrpc:E(_n),id:yn,result:me}).strict(),jt=e=>zi.safeParse(e).success;var I;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(I||(I={}));var xi=x({jsonrpc:E(_n),id:yn.optional(),error:x({code:F().int(),message:p(),data:oe().optional()})}).strict();var Tf=e=>xi.safeParse(e).success;var vn=X([kf,Pf,zi,xi]),BE=X([zi,xi]),Zt=me.strict(),nv=Me.extend({requestId:yn.optional(),reason:p().optional()}),$n=De.extend({method:E("notifications/cancelled"),params:nv}),sv=x({src:p(),mimeType:p().optional(),sizes:b(p()).optional(),theme:Re(["light","dark"]).optional()}),Yr=x({icons:b(sv).optional()}),dr=x({name:p(),title:p().optional()}),Rf=dr.extend({...dr.shape,...Yr.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),iv=mn(x({applyDefaults:W().optional()}),Y(p(),oe())),av=$i(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,mn(x({form:iv.optional(),url:de.optional()}),Y(p(),oe()).optional())),cv=le({list:de.optional(),cancel:de.optional(),requests:le({sampling:le({createMessage:de.optional()}).optional(),elicitation:le({create:de.optional()}).optional()}).optional()}),uv=le({list:de.optional(),cancel:de.optional(),requests:le({tools:le({call:de.optional()}).optional()}).optional()}),lv=x({experimental:Y(p(),de).optional(),sampling:x({context:de.optional(),tools:de.optional()}).optional(),elicitation:av.optional(),roots:x({listChanged:W().optional()}).optional(),tasks:cv.optional(),extensions:Y(p(),de).optional()}),dv=je.extend({protocolVersion:p(),capabilities:lv,clientInfo:Rf}),pv=fe.extend({method:E("initialize"),params:dv});var fv=x({experimental:Y(p(),de).optional(),logging:de.optional(),completions:de.optional(),prompts:x({listChanged:W().optional()}).optional(),resources:x({subscribe:W().optional(),listChanged:W().optional()}).optional(),tools:x({listChanged:W().optional()}).optional(),tasks:uv.optional(),extensions:Y(p(),de).optional()}),Si=me.extend({protocolVersion:p(),capabilities:fv,serverInfo:Rf,instructions:p().optional()}),Of=De.extend({method:E("notifications/initialized"),params:Me.optional()}),If=e=>Of.safeParse(e).success,wn=fe.extend({method:E("ping"),params:je.optional()}),mv=x({progress:F(),total:ne(F()),message:ne(p())}),hv=x({...Me.shape,...mv.shape,progressToken:zf}),bn=De.extend({method:E("notifications/progress"),params:hv}),gv=je.extend({cursor:xf.optional()}),Qr=fe.extend({params:gv.optional()}),Xr=me.extend({nextCursor:xf.optional()}),_v=Re(["working","input_required","completed","failed","cancelled"]),eo=x({taskId:p(),status:_v,ttl:X([F(),uf()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:ne(F()),statusMessage:ne(p())}),qt=me.extend({task:eo}),yv=Me.merge(eo),to=De.extend({method:E("notifications/tasks/status"),params:yv}),zn=fe.extend({method:E("tasks/get"),params:je.extend({taskId:p()})}),xn=me.merge(eo),Sn=fe.extend({method:E("tasks/result"),params:je.extend({taskId:p()})}),WE=me.loose(),kn=Qr.extend({method:E("tasks/list")}),Pn=Xr.extend({tasks:b(eo)}),En=fe.extend({method:E("tasks/cancel"),params:je.extend({taskId:p()})}),Af=me.merge(eo),Cf=x({uri:p(),mimeType:ne(p()),_meta:Y(p(),oe()).optional()}),Nf=Cf.extend({text:p()}),ki=p().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),jf=Cf.extend({blob:ki}),ro=Re(["user","assistant"]),fr=x({audience:b(ro).optional(),priority:F().min(0).max(1).optional(),lastModified:Jr.datetime({offset:!0}).optional()}),Zf=x({...dr.shape,...Yr.shape,uri:p(),description:ne(p()),mimeType:ne(p()),size:ne(F()),annotations:fr.optional(),_meta:ne(le({}))}),vv=x({...dr.shape,...Yr.shape,uriTemplate:p(),description:ne(p()),mimeType:ne(p()),annotations:fr.optional(),_meta:ne(le({}))}),$v=Qr.extend({method:E("resources/list")}),Pi=Xr.extend({resources:b(Zf)}),wv=Qr.extend({method:E("resources/templates/list")}),Ei=Xr.extend({resourceTemplates:b(vv)}),Ti=je.extend({uri:p()}),bv=Ti,zv=fe.extend({method:E("resources/read"),params:bv}),Ri=me.extend({contents:b(X([Nf,jf]))}),Oi=De.extend({method:E("notifications/resources/list_changed"),params:Me.optional()}),xv=Ti,Sv=fe.extend({method:E("resources/subscribe"),params:xv}),kv=Ti,Pv=fe.extend({method:E("resources/unsubscribe"),params:kv}),Ev=Me.extend({uri:p()}),Tv=De.extend({method:E("notifications/resources/updated"),params:Ev}),Rv=x({name:p(),description:ne(p()),required:ne(W())}),Ov=x({...dr.shape,...Yr.shape,description:ne(p()),arguments:ne(b(Rv)),_meta:ne(le({}))}),Iv=Qr.extend({method:E("prompts/list")}),Ii=Xr.extend({prompts:b(Ov)}),Av=je.extend({name:p(),arguments:Y(p(),p()).optional()}),Cv=fe.extend({method:E("prompts/get"),params:Av}),Ai=x({type:E("text"),text:p(),annotations:fr.optional(),_meta:Y(p(),oe()).optional()}),Ci=x({type:E("image"),data:ki,mimeType:p(),annotations:fr.optional(),_meta:Y(p(),oe()).optional()}),Ni=x({type:E("audio"),data:ki,mimeType:p(),annotations:fr.optional(),_meta:Y(p(),oe()).optional()}),Nv=x({type:E("tool_use"),name:p(),id:p(),input:Y(p(),oe()),_meta:Y(p(),oe()).optional()}),jv=x({type:E("resource"),resource:X([Nf,jf]),annotations:fr.optional(),_meta:Y(p(),oe()).optional()}),Zv=Zf.extend({type:E("resource_link")}),ji=X([Ai,Ci,Ni,Zv,jv]),qv=x({role:ro,content:ji}),Zi=me.extend({description:p().optional(),messages:b(qv)}),qi=De.extend({method:E("notifications/prompts/list_changed"),params:Me.optional()}),Mv=x({title:p().optional(),readOnlyHint:W().optional(),destructiveHint:W().optional(),idempotentHint:W().optional(),openWorldHint:W().optional()}),Dv=x({taskSupport:Re(["required","optional","forbidden"]).optional()}),qf=x({...dr.shape,...Yr.shape,description:p().optional(),inputSchema:x({type:E("object"),properties:Y(p(),de).optional(),required:b(p()).optional()}).catchall(oe()),outputSchema:x({type:E("object"),properties:Y(p(),de).optional(),required:b(p()).optional()}).catchall(oe()).optional(),annotations:Mv.optional(),execution:Dv.optional(),_meta:Y(p(),oe()).optional()}),Uv=Qr.extend({method:E("tools/list")}),Mi=Xr.extend({tools:b(qf)}),mr=me.extend({content:b(ji).default([]),structuredContent:Y(p(),oe()).optional(),isError:W().optional()}),GE=mr.or(me.extend({toolResult:oe()})),Lv=Wr.extend({name:p(),arguments:Y(p(),oe()).optional()}),Fv=fe.extend({method:E("tools/call"),params:Lv}),Di=De.extend({method:E("notifications/tools/list_changed"),params:Me.optional()}),Mf=x({autoRefresh:W().default(!0),debounceMs:F().int().nonnegative().default(300)}),Df=Re(["debug","info","notice","warning","error","critical","alert","emergency"]),Vv=je.extend({level:Df}),Hv=fe.extend({method:E("logging/setLevel"),params:Vv}),Kv=Me.extend({level:Df,logger:p().optional(),data:oe()}),Jv=De.extend({method:E("notifications/message"),params:Kv}),Bv=x({name:p().optional()}),Wv=x({hints:b(Bv).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),Gv=x({mode:Re(["auto","required","none"]).optional()}),Yv=x({type:E("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:b(ji).default([]),structuredContent:x({}).loose().optional(),isError:W().optional(),_meta:Y(p(),oe()).optional()}),Qv=vi("type",[Ai,Ci,Ni]),gn=vi("type",[Ai,Ci,Ni,Nv,Yv]),Xv=x({role:ro,content:X([gn,b(gn)]),_meta:Y(p(),oe()).optional()}),e$=Wr.extend({messages:b(Xv),modelPreferences:Wv.optional(),systemPrompt:p().optional(),includeContext:Re(["none","thisServer","allServers"]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:b(p()).optional(),metadata:de.optional(),tools:b(qf).optional(),toolChoice:Gv.optional()}),Ui=fe.extend({method:E("sampling/createMessage"),params:e$}),Li=me.extend({model:p(),stopReason:ne(Re(["endTurn","stopSequence","maxTokens"]).or(p())),role:ro,content:Qv}),Fi=me.extend({model:p(),stopReason:ne(Re(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:ro,content:X([gn,b(gn)])}),t$=x({type:E("boolean"),title:p().optional(),description:p().optional(),default:W().optional()}),r$=x({type:E("string"),title:p().optional(),description:p().optional(),minLength:F().optional(),maxLength:F().optional(),format:Re(["email","uri","date","date-time"]).optional(),default:p().optional()}),o$=x({type:Re(["number","integer"]),title:p().optional(),description:p().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),n$=x({type:E("string"),title:p().optional(),description:p().optional(),enum:b(p()),default:p().optional()}),s$=x({type:E("string"),title:p().optional(),description:p().optional(),oneOf:b(x({const:p(),title:p()})),default:p().optional()}),i$=x({type:E("string"),title:p().optional(),description:p().optional(),enum:b(p()),enumNames:b(p()).optional(),default:p().optional()}),a$=X([n$,s$]),c$=x({type:E("array"),title:p().optional(),description:p().optional(),minItems:F().optional(),maxItems:F().optional(),items:x({type:E("string"),enum:b(p())}),default:b(p()).optional()}),u$=x({type:E("array"),title:p().optional(),description:p().optional(),minItems:F().optional(),maxItems:F().optional(),items:x({anyOf:b(x({const:p(),title:p()}))}),default:b(p()).optional()}),l$=X([c$,u$]),d$=X([i$,a$,l$]),p$=X([d$,t$,r$,o$]),f$=Wr.extend({mode:E("form").optional(),message:p(),requestedSchema:x({type:E("object"),properties:Y(p(),p$),required:b(p()).optional()})}),m$=Wr.extend({mode:E("url"),message:p(),elicitationId:p(),url:p().url()}),h$=X([f$,m$]),Vi=fe.extend({method:E("elicitation/create"),params:h$}),g$=Me.extend({elicitationId:p()}),_$=De.extend({method:E("notifications/elicitation/complete"),params:g$}),Hi=me.extend({action:Re(["accept","decline","cancel"]),content:$i(e=>e===null?void 0:e,Y(p(),X([p(),F(),W(),b(p())])).optional())}),y$=x({type:E("ref/resource"),uri:p()});var v$=x({type:E("ref/prompt"),name:p()}),$$=je.extend({ref:X([v$,y$]),argument:x({name:p(),value:p()}),context:x({arguments:Y(p(),p()).optional()}).optional()}),w$=fe.extend({method:E("completion/complete"),params:$$});var Ki=me.extend({completion:le({values:b(p()).max(100),total:ne(F().int()),hasMore:ne(W())})}),b$=x({uri:p().startsWith("file://"),name:p().optional(),_meta:Y(p(),oe()).optional()}),z$=fe.extend({method:E("roots/list"),params:je.optional()}),x$=me.extend({roots:b(b$)}),S$=De.extend({method:E("notifications/roots/list_changed"),params:Me.optional()}),YE=X([wn,pv,w$,Hv,Cv,Iv,$v,wv,zv,Sv,Pv,Fv,Uv,zn,Sn,kn,En]),QE=X([$n,bn,Of,S$,to]),XE=X([Zt,Li,Fi,Hi,x$,xn,Pn,qt]),eT=X([wn,Ui,Vi,z$,zn,Sn,kn,En]),tT=X([$n,bn,Jv,Tv,Oi,Di,qi,to,_$]),rT=X([Zt,Si,Ki,Zi,Ii,Pi,Ei,Ri,mr,Mi,xn,Pn,qt]),O=class e extends Error{constructor(t,r,o){super(`MCP error ${t}: ${r}`),this.code=t,this.data=o,this.name="McpError"}static fromError(t,r,o){if(t===I.UrlElicitationRequired&&o){let n=o;if(n.elicitations)return new wi(n.elicitations,r)}return new e(t,r,o)}},wi=class extends O{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(I.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function xt(e){return e==="completed"||e==="failed"||e==="cancelled"}var k$=Symbol("Let zodToJsonSchema decide on which parser to use");var NT=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ji(e){let r=dn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=Cp(r);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function Bi(e,t){let r=Ke(e,t);if(!r.success)throw r.error;return r.data}var I$=6e4,Tn=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler($n,r=>{this._oncancel(r)}),this.setNotificationHandler(bn,r=>{this._onprogress(r)}),this.setRequestHandler(wn,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(zn,async(r,o)=>{let n=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!n)throw new O(I.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(Sn,async(r,o)=>{let n=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,o.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new O(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:o.requestId})}}let i=await this._taskStore.getTask(s,o.sessionId);if(!i)throw new O(I.InvalidParams,`Task not found: ${s}`);if(!xt(i.status))return await this._waitForTaskUpdate(s,o.signal),await n();if(xt(i.status)){let a=await this._taskStore.getTaskResult(s,o.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[zt]:{taskId:s}}}}return await n()};return await n()}),this.setRequestHandler(kn,async(r,o)=>{try{let{tasks:n,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,o.sessionId);return{tasks:n,nextCursor:s,_meta:{}}}catch(n){throw new O(I.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(En,async(r,o)=>{try{let n=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!n)throw new O(I.InvalidParams,`Task not found: ${r.params.taskId}`);if(xt(n.status))throw new O(I.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!s)throw new O(I.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(n){throw n instanceof O?n:new O(I.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,o,n,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:o,resetTimeoutOnProgress:s,onTimeout:n})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let o=Date.now()-r.startTime;if(r.maxTotalTimeout&&o>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),O.fromError(I.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:o});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let o=this.transport?.onerror;this._transport.onerror=s=>{o?.(s),this._onerror(s)};let n=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{n?.(s,i),jt(s)||Tf(s)?this._onresponse(s):Gr(s)?this._onrequest(s,i):Ef(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();for(let o of this._requestHandlerAbortControllers.values())o.abort();this._requestHandlerAbortControllers.clear();let r=O.fromError(I.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let o of t.values())o(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(t,r){let o=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,n=this._transport,s=t.params?._meta?.[zt]?.taskId;if(o===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:I.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},n?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):n?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);let a=Sf(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,n?.sessionId):void 0,u={signal:i.signal,sessionId:n?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(i.signal.aborted)throw new O(I.ConnectionClosed,"Request was cancelled");let m={...f,relatedRequestId:t.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let h=m.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>o(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},n?.sessionId):await n?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:I.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},n?.sessionId):await n?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...o}=t.params,n=Number(r),s=this._progressHandlers.get(n);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),i(c);return}s(o)}_onresponse(t){let r=Number(t.id),o=this._requestResolvers.get(r);if(o){if(this._requestResolvers.delete(r),jt(t))o(t);else{let i=new O(t.error.code,t.error.message,t.error.data);o(i)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(jt(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),jt(t))n(t);else{let i=O.fromError(t.error.code,t.error.message,t.error.data);n(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,o){let{task:n}=o??{};if(!n){try{yield{type:"result",result:await this.request(t,r,o)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(I.InternalError,String(i))}}return}let s;try{let i=await this.request(t,qt,o);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(I.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},o);if(yield{type:"taskStatus",task:a},xt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,o)}:a.status==="failed"?yield{type:"error",error:new O(I.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(I.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,o)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),o?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof O?i:new O(I.InternalError,String(i))}}}request(t,r,o){let{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=o??{};return new Promise((u,l)=>{let d=k=>{l(k)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(k){d(k);return}o?.signal?.throwIfAborted();let f=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:f};o?.onprogress&&(this._progressHandlers.set(f,o.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[zt]:c}});let h=k=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(k)}},{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch(P=>this._onerror(new Error(`Failed to send cancellation: ${P}`)));let z=k instanceof O?k:new O(I.RequestTimeout,String(k));l(z)};this._responseHandlers.set(f,k=>{if(!o?.signal?.aborted){if(k instanceof Error)return l(k);try{let z=Ke(r,k.result);z.success?u(z.data):l(z.error)}catch(z){l(z)}}}),o?.signal?.addEventListener("abort",()=>{h(o?.signal?.reason)});let _=o?.timeout??I$,v=()=>h(O.fromError(I.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(f,_,o?.maxTotalTimeout,v,o?.resetTimeoutOnProgress??!1);let $=c?.taskId;if($){let k=z=>{let P=this._responseHandlers.get(f);P?P(z):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,k),this._enqueueTaskMessage($,{type:"request",message:m,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(f),l(z)})}else this._transport.send(m,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch(k=>{this._cleanupTimeout(f),l(k)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},xn,r)}async getTaskResult(t,r,o){return this.request({method:"tasks/result",params:t},r,o)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Pn,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Af,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let o=r?.relatedTask?.taskId;if(o){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[zt]:r.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[zt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[zt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let o=Ji(t);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(n,s)=>{let i=Bi(t,n);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let o=Ji(t);this._notificationHandlers.set(o,n=>{let s=Bi(t,n);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,o){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,o,n)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let o=await this._taskMessageQueue.dequeueAll(t,r);for(let n of o)if(n.type==="request"&&Gr(n.message)){let s=n.message.id,i=this._requestResolvers.get(s);i?(i(new O(I.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let o=this._options?.defaultTaskPollInterval??1e3;try{let n=await this._taskStore?.getTask(t);n?.pollInterval&&(o=n.pollInterval)}catch{}return new Promise((n,s)=>{if(r.aborted){s(new O(I.InvalidRequest,"Request cancelled"));return}let i=setTimeout(n,o);r.addEventListener("abort",()=>{clearTimeout(i),s(new O(I.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let o=this._taskStore;if(!o)throw new Error("No task store configured");return{createTask:async n=>{if(!t)throw new Error("No request provided");return await o.createTask(n,t.id,{method:t.method,params:t.params},r)},getTask:async n=>{let s=await o.getTask(n,r);if(!s)throw new O(I.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(n,s,i)=>{await o.storeTaskResult(n,s,i,r);let a=await o.getTask(n,r);if(a){let c=to.parse({method:"notifications/tasks/status",params:a});await this.notification(c),xt(a.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>o.getTaskResult(n,r),updateTaskStatus:async(n,s,i)=>{let a=await o.getTask(n,r);if(!a)throw new O(I.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(xt(a.status))throw new O(I.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(n,s,i,r);let c=await o.getTask(n,r);if(c){let u=to.parse({method:"notifications/tasks/status",params:c});await this.notification(u),xt(c.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>o.listTasks(n,r)}}};function Uf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Lf(e,t){let r={...e};for(let o in t){let n=o,s=t[n];if(s===void 0)continue;let i=r[n];Uf(i)&&Uf(s)?r[n]={...i,...s}:r[n]=s}return r}var Ag=su(Cc(),1),Cg=su(Ig(),1);function jS(){let e=new Ag.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Cg.default)(e),e}var ls=class{constructor(t){this._ajv=t??jS()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return o=>r(o)?{valid:!0,data:o,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var ds=class{constructor(t){this._client=t}async*callToolStream(t,r=mr,o){let n=this._client,s={...o,task:o?.task??(n.isToolTask(t.name)?{}:void 0)},i=n.requestStream({method:"tools/call",params:t},r,s),a=n.getToolOutputValidator(t.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new O(I.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new O(I.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof O){yield{type:"error",error:l};return}yield{type:"error",error:new O(I.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,o){return this._client.getTaskResult({taskId:t},r,o)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,o){return this._client.requestStream(t,r,o)}};function Ng(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function jg(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function ps(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,o=e.properties;for(let n of Object.keys(o)){let s=o[n];r[n]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[n]=s.default),r[n]!==void 0&&ps(s,r[n])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&ps(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&ps(r,t)}}function ZS(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var fs=class extends Tn{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new ls,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Di,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",qi,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Oi,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new ds(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Lf(this._capabilities,t)}setRequestHandler(t,r){let n=dn(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let s;if(lr(n)){let a=n;s=a._zod?.def?.value??a.value}else{let a=n;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ke(Vi,c);if(!l.success){let k=l.error instanceof Error?l.error.message:String(l.error);throw new O(I.InvalidParams,`Invalid elicitation request: ${k}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:f,supportsUrlMode:m}=ZS(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new O(I.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new O(I.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let k=Ke(qt,h);if(!k.success){let z=k.error instanceof Error?k.error.message:String(k.error);throw new O(I.InvalidParams,`Invalid task creation result: ${z}`)}return k.data}let _=Ke(Hi,h);if(!_.success){let k=_.error instanceof Error?_.error.message:String(_.error);throw new O(I.InvalidParams,`Invalid elicitation result: ${k}`)}let v=_.data,$=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&$&&this._capabilities.elicitation?.form?.applyDefaults)try{ps($,v.content)}catch{}return v};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ke(Ui,c);if(!l.success){let v=l.error instanceof Error?l.error.message:String(l.error);throw new O(I.InvalidParams,`Invalid sampling request: ${v}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let v=Ke(qt,f);if(!v.success){let $=v.error instanceof Error?v.error.message:String(v.error);throw new O(I.InvalidParams,`Invalid task creation result: ${$}`)}return v.data}let h=d.tools||d.toolChoice?Fi:Li,_=Ke(h,f);if(!_.success){let v=_.error instanceof Error?_.error.message:String(_.error);throw new O(I.InvalidParams,`Invalid sampling result: ${v}`)}return _.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let o=await this.request({method:"initialize",params:{protocolVersion:pr,capabilities:this._capabilities,clientInfo:this._clientInfo}},Si,r);if(o===void 0)throw new Error(`Server sent invalid initialize result: ${o}`);if(!bf.includes(o.protocolVersion))throw new Error(`Server's protocol version is not supported: ${o.protocolVersion}`);this._serverCapabilities=o.capabilities,this._serverVersion=o.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(o.protocolVersion),this._instructions=o.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(o){throw this.close(),o}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break;case"ping":break}}assertTaskCapability(t){Ng(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&jg(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Zt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},Ki,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Zt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Zi,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Ii,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Pi,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Ei,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Ri,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Zt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Zt,r)}async callTool(t,r=mr,o){if(this.isToolTaskRequired(t.name))throw new O(I.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let n=await this.request({method:"tools/call",params:t},r,o),s=this.getToolOutputValidator(t.name);if(s){if(!n.structuredContent&&!n.isError)throw new O(I.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(n.structuredContent)try{let i=s(n.structuredContent);if(!i.valid)throw new O(I.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof O?i:new O(I.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return n}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let n=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}let o=r.execution?.taskSupport;(o==="required"||o==="optional")&&this._cachedKnownTaskTools.add(r.name),o==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let o=await this.request({method:"tools/list",params:t},Mi,r);return this.cacheToolMetadata(o.tools),o}_setupListChangedHandler(t,r,o,n){let s=Mf.safeParse(o);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof o.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=o,u=async()=>{if(!i){c(null,null);return}try{let d=await n();c(null,d)}catch(d){let f=d instanceof Error?d:new Error(String(d));c(f,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let f=setTimeout(u,a);this._listChangedDebounceTimers.set(t,f)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};function ms(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Zg(e=fetch,t){return t?async(r,o)=>{let n={...t,...o,headers:o?.headers?{...ms(t.headers),...ms(o.headers)}:t.headers};return e(r,n)}:e}var Lc;Lc=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function qS(e){return(await Lc).getRandomValues(new Uint8Array(e))}async function MS(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,o="";for(;o.length<e;){let n=await qS(e-o.length);for(let s of n)s<r&&(o+=t[s%t.length])}return o}async function DS(e){return await MS(e)}async function US(e){let t=await(await Lc).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Fc(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await DS(e),r=await US(t);return{code_verifier:t,code_challenge:r}}var ye=af().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:wf.custom,message:"URL must be parseable",fatal:!0}),xs}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Mg=le({resource:p().url(),authorization_servers:b(ye).optional(),jwks_uri:p().url().optional(),scopes_supported:b(p()).optional(),bearer_methods_supported:b(p()).optional(),resource_signing_alg_values_supported:b(p()).optional(),resource_name:p().optional(),resource_documentation:p().optional(),resource_policy_uri:p().url().optional(),resource_tos_uri:p().url().optional(),tls_client_certificate_bound_access_tokens:W().optional(),authorization_details_types_supported:b(p()).optional(),dpop_signing_alg_values_supported:b(p()).optional(),dpop_bound_access_tokens_required:W().optional()}),Vc=le({issuer:p(),authorization_endpoint:ye,token_endpoint:ye,registration_endpoint:ye.optional(),scopes_supported:b(p()).optional(),response_types_supported:b(p()),response_modes_supported:b(p()).optional(),grant_types_supported:b(p()).optional(),token_endpoint_auth_methods_supported:b(p()).optional(),token_endpoint_auth_signing_alg_values_supported:b(p()).optional(),service_documentation:ye.optional(),revocation_endpoint:ye.optional(),revocation_endpoint_auth_methods_supported:b(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:b(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:b(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:b(p()).optional(),code_challenge_methods_supported:b(p()).optional(),client_id_metadata_document_supported:W().optional()}),LS=le({issuer:p(),authorization_endpoint:ye,token_endpoint:ye,userinfo_endpoint:ye.optional(),jwks_uri:ye,registration_endpoint:ye.optional(),scopes_supported:b(p()).optional(),response_types_supported:b(p()),response_modes_supported:b(p()).optional(),grant_types_supported:b(p()).optional(),acr_values_supported:b(p()).optional(),subject_types_supported:b(p()),id_token_signing_alg_values_supported:b(p()),id_token_encryption_alg_values_supported:b(p()).optional(),id_token_encryption_enc_values_supported:b(p()).optional(),userinfo_signing_alg_values_supported:b(p()).optional(),userinfo_encryption_alg_values_supported:b(p()).optional(),userinfo_encryption_enc_values_supported:b(p()).optional(),request_object_signing_alg_values_supported:b(p()).optional(),request_object_encryption_alg_values_supported:b(p()).optional(),request_object_encryption_enc_values_supported:b(p()).optional(),token_endpoint_auth_methods_supported:b(p()).optional(),token_endpoint_auth_signing_alg_values_supported:b(p()).optional(),display_values_supported:b(p()).optional(),claim_types_supported:b(p()).optional(),claims_supported:b(p()).optional(),service_documentation:p().optional(),claims_locales_supported:b(p()).optional(),ui_locales_supported:b(p()).optional(),claims_parameter_supported:W().optional(),request_parameter_supported:W().optional(),request_uri_parameter_supported:W().optional(),require_request_uri_registration:W().optional(),op_policy_uri:ye.optional(),op_tos_uri:ye.optional(),client_id_metadata_document_supported:W().optional()}),Dg=x({...LS.shape,...Vc.pick({code_challenge_methods_supported:!0}).shape}),Ug=x({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:hn.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),Lg=x({error:p(),error_description:p().optional(),error_uri:p().optional()}),qg=ye.optional().or(E("").transform(()=>{})),FS=x({redirect_uris:b(ye),token_endpoint_auth_method:p().optional(),grant_types:b(p()).optional(),response_types:b(p()).optional(),client_name:p().optional(),client_uri:ye.optional(),logo_uri:qg,scope:p().optional(),contacts:b(p()).optional(),tos_uri:qg,policy_uri:p().optional(),jwks_uri:ye.optional(),jwks:lf().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),VS=x({client_id:p(),client_secret:p().optional(),client_id_issued_at:F().optional(),client_secret_expires_at:F().optional()}).strip(),Fg=FS.merge(VS),aA=x({error:p(),error_description:p().optional()}).strip(),cA=x({token:p(),token_type_hint:p().optional()}).strip();function Vg(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Hg({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;let n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(s)}var ue=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},Co=class extends ue{};Co.errorCode="invalid_request";var Gt=class extends ue{};Gt.errorCode="invalid_client";var Yt=class extends ue{};Yt.errorCode="invalid_grant";var Qt=class extends ue{};Qt.errorCode="unauthorized_client";var No=class extends ue{};No.errorCode="unsupported_grant_type";var jo=class extends ue{};jo.errorCode="invalid_scope";var Zo=class extends ue{};Zo.errorCode="access_denied";var ft=class extends ue{};ft.errorCode="server_error";var qo=class extends ue{};qo.errorCode="temporarily_unavailable";var Mo=class extends ue{};Mo.errorCode="unsupported_response_type";var Do=class extends ue{};Do.errorCode="unsupported_token_type";var Uo=class extends ue{};Uo.errorCode="invalid_token";var Lo=class extends ue{};Lo.errorCode="method_not_allowed";var Fo=class extends ue{};Fo.errorCode="too_many_requests";var Xt=class extends ue{};Xt.errorCode="invalid_client_metadata";var Vo=class extends ue{};Vo.errorCode="insufficient_scope";var Ho=class extends ue{};Ho.errorCode="invalid_target";var Kg={[Co.errorCode]:Co,[Gt.errorCode]:Gt,[Yt.errorCode]:Yt,[Qt.errorCode]:Qt,[No.errorCode]:No,[jo.errorCode]:jo,[Zo.errorCode]:Zo,[ft.errorCode]:ft,[qo.errorCode]:qo,[Mo.errorCode]:Mo,[Do.errorCode]:Do,[Uo.errorCode]:Uo,[Lo.errorCode]:Lo,[Fo.errorCode]:Fo,[Xt.errorCode]:Xt,[Vo.errorCode]:Vo,[Ho.errorCode]:Ho};var mt=class extends Error{constructor(t){super(t??"Unauthorized")}};function HS(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var Hc="code",Kc="S256";function KS(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&HS(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function JS(e,t,r,o){let{client_id:n,client_secret:s}=t;switch(e){case"client_secret_basic":BS(n,s,r);return;case"client_secret_post":WS(n,s,o);return;case"none":GS(n,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function BS(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}function WS(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function GS(e,t){t.set("client_id",e)}async function Bg(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let o=Lg.parse(JSON.parse(r)),{error:n,error_description:s,error_uri:i}=o,a=Kg[n]||ft;return new a(s||"",i)}catch(o){let n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new ft(n)}}async function Ko(e,t){try{return await Jc(e,t)}catch(r){if(r instanceof Gt||r instanceof Qt)return await e.invalidateCredentials?.("all"),await Jc(e,t);if(r instanceof Yt)return await e.invalidateCredentials?.("tokens"),await Jc(e,t);throw r}}async function Jc(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,l=n;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await Gg(c,{fetchFn:s}),!a)try{a=await Wg(t,{resourceMetadataUrl:l},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let z=await ok(t,{resourceMetadataUrl:l,fetchFn:s});c=z.authorizationServerUrl,u=z.authorizationServerMetadata,a=z.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=await QS(t,e,a),f=o||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,m=await Promise.resolve(e.clientInformation());if(!m){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let z=u?.client_id_metadata_document_supported===!0,P=e.clientMetadataUrl;if(P&&!YS(P))throw new Xt(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${P}`);if(z&&P)m={client_id:P},await e.saveClientInformation?.(m);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let w=await ck(c,{metadata:u,clientMetadata:e.clientMetadata,scope:f,fetchFn:s});await e.saveClientInformation(w),m=w}}let h=!e.redirectUrl;if(r!==void 0||h){let z=await ak(e,c,{metadata:u,resource:d,authorizationCode:r,fetchFn:s});return await e.saveTokens(z),"AUTHORIZED"}let _=await e.tokens();if(_?.refresh_token)try{let z=await ik(c,{metadata:u,clientInformation:m,refreshToken:_.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(z),"AUTHORIZED"}catch(z){if(!(!(z instanceof ue)||z instanceof ft))throw z}let v=e.state?await e.state():void 0,{authorizationUrl:$,codeVerifier:k}=await nk(c,{metadata:u,clientInformation:m,state:v,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier(k),await e.redirectToAuthorization($),"REDIRECT"}function YS(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function QS(e,t,r){let o=Vg(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!Hg({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}function Wc(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,o]=t.split(" ");if(r.toLowerCase()!=="bearer"||!o)return{};let n=Bc(e,"resource_metadata")||void 0,s;if(n)try{s=new URL(n)}catch{}let i=Bc(e,"scope")||void 0,a=Bc(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function Bc(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let o=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),n=r.match(o);return n?n[1]||n[2]:null}async function Wg(e,t,r=fetch){let o=await tk(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw await o?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw await o.body?.cancel(),new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return Mg.parse(await o.json())}async function Gc(e,t,r=fetch){try{return await r(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?Gc(e,void 0,r):void 0;throw o}}function XS(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Jg(e,t,r=fetch){return await Gc(e,{"MCP-Protocol-Version":t},r)}function ek(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function tk(e,t,r,o){let n=new URL(e),s=o?.protocolVersion??pr,i;if(o?.metadataUrl)i=new URL(o.metadataUrl);else{let c=XS(t,n.pathname);i=new URL(c,o?.metadataServerUrl??n),i.search=n.search}let a=await Jg(i,s,r);if(!o?.metadataUrl&&ek(a,n.pathname)){let c=new URL(`/.well-known/${t}`,n);a=await Jg(c,s,r)}return a}function rk(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function Gg(e,{fetchFn:t=fetch,protocolVersion:r=pr}={}){let o={"MCP-Protocol-Version":r,Accept:"application/json"},n=rk(e);for(let{url:s,type:i}of n){let a=await Gc(s,o,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?Vc.parse(await a.json()):Dg.parse(await a.json())}}}async function ok(e,t){let r,o;try{r=await Wg(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(o=r.authorization_servers[0])}catch{}o||(o=String(new URL("/",e)));let n=await Gg(o,{fetchFn:t?.fetchFn});return{authorizationServerUrl:o,authorizationServerMetadata:n,resourceMetadata:r}}async function nk(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Hc))throw new Error(`Incompatible auth server: does not support response type ${Hc}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Kc))throw new Error(`Incompatible auth server: does not support code challenge method ${Kc}`)}else a=new URL("/authorize",e);let c=await Fc(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Hc),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",Kc),a.searchParams.set("redirect_uri",String(o)),s&&a.searchParams.set("state",s),n&&a.searchParams.set("scope",n),n?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function sk(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Yg(e,{metadata:t,tokenRequestParams:r,clientInformation:o,addClientAuthentication:n,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",s.href),n)await n(c,r,a,t);else if(o){let l=t?.token_endpoint_auth_methods_supported??[],d=KS(o,l);JS(d,o,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await Bg(u);return Ug.parse(await u.json())}async function ik(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),c=await Yg(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:n,fetchFn:i});return{refresh_token:o,...c}}async function ak(e,t,{metadata:r,resource:o,authorizationCode:n,fetchFn:s}={}){let i=e.clientMetadata.scope,a;if(e.prepareTokenRequest&&(a=await e.prepareTokenRequest(i)),!a){if(!n)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let u=await e.codeVerifier();a=sk(n,u,e.redirectUrl)}let c=await e.clientInformation();return Yg(t,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:o,fetchFn:s})}async function ck(e,{metadata:t,clientMetadata:r,scope:o,fetchFn:n}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...o!==void 0?{scope:o}:{}})});if(!i.ok)throw await Bg(i);return Fg.parse(await i.json())}var Jo=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},Qg=10,uk=13,er=32;function Yc(e){}function t_(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Yc,onError:r=Yc,onRetry:o=Yc,onComment:n,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,f,m=!1;function h(y){if(m)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,y.charCodeAt(0)===239&&y.charCodeAt(1)===187&&y.charCodeAt(2)===191&&(y=y.slice(3))),i.length===0){let se=v(y);se!==""&&(i.push(se),a=se.length),_();return}if(y.indexOf(`
79
+ `)===-1&&y.indexOf("\r")===-1){i.push(y),a+=y.length,_();return}i.push(y);let w=i.join("");i.length=0,a=0;let A=v(w);A!==""&&(i.push(A),a=A.length),_()}function _(){s!==void 0&&(a+l.length<=s||(m=!0,i.length=0,a=0,u=void 0,l="",d=0,f=void 0,r(new Jo(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function v(y){let w=0;if(y.indexOf("\r")===-1){let A=y.indexOf(`
80
+ `,w);for(;A!==-1;){if(w===A){d>0&&t({id:u,event:f,data:l}),u=void 0,l="",d=0,f=void 0,w=A+1,A=y.indexOf(`
81
+ `,w);continue}let se=y.charCodeAt(w);if(Xg(y,w,se)){let ie=y.charCodeAt(w+5)===er?w+6:w+5,Ee=y.slice(ie,A);if(d===0&&y.charCodeAt(A+1)===Qg){t({id:u,event:f,data:Ee}),u=void 0,l="",f=void 0,w=A+2,A=y.indexOf(`
82
+ `,w);continue}l=d===0?Ee:`${l}
83
+ ${Ee}`,d++}else e_(y,w,se)?f=y.slice(y.charCodeAt(w+6)===er?w+7:w+6,A)||void 0:$(y,w,A);w=A+1,A=y.indexOf(`
84
+ `,w)}return y.slice(w)}for(;w<y.length;){let A=y.indexOf("\r",w),se=y.indexOf(`
85
+ `,w),ie=-1;if(A!==-1&&se!==-1?ie=A<se?A:se:A!==-1?A===y.length-1?ie=-1:ie=A:se!==-1&&(ie=se),ie===-1)break;$(y,w,ie),w=ie+1,y.charCodeAt(w-1)===uk&&y.charCodeAt(w)===Qg&&w++}return y.slice(w)}function $(y,w,A){if(w===A){z();return}let se=y.charCodeAt(w);if(Xg(y,w,se)){let _t=y.charCodeAt(w+5)===er?w+6:w+5,nu=y.slice(_t,A);l=d===0?nu:`${l}
86
+ ${nu}`,d++;return}if(e_(y,w,se)){f=y.slice(y.charCodeAt(w+6)===er?w+7:w+6,A)||void 0;return}if(se===105&&y.charCodeAt(w+1)===100&&y.charCodeAt(w+2)===58){let _t=y.slice(y.charCodeAt(w+3)===er?w+4:w+3,A);u=_t.includes("\0")?void 0:_t;return}if(se===58){if(n){let _t=y.slice(w,A);n(_t.slice(y.charCodeAt(w+1)===er?2:1))}return}let ie=y.slice(w,A),Ee=ie.indexOf(":");if(Ee===-1){k(ie,"",ie);return}let Cr=ie.slice(0,Ee),Bo=ie.charCodeAt(Ee+1)===er?2:1,Wo=ie.slice(Ee+Bo);k(Cr,Wo,ie)}function k(y,w,A){switch(y){case"event":f=w||void 0;break;case"data":l=d===0?w:`${l}
87
+ ${w}`,d++;break;case"id":u=w.includes("\0")?void 0:w;break;case"retry":/^\d+$/.test(w)?o(parseInt(w,10)):r(new Jo(`Invalid \`retry\` value: "${w}"`,{type:"invalid-retry",value:w,line:A}));break;default:r(new Jo(`Unknown field "${y.length>20?`${y.slice(0,20)}\u2026`:y}"`,{type:"unknown-field",field:y,value:w,line:A}));break}}function z(){d>0&&t({id:u,event:f,data:l}),u=void 0,l="",d=0,f=void 0}function P(y={}){if(y.consume&&i.length>0){let w=i.join("");$(w,0,w.length)}c=!0,u=void 0,l="",d=0,f=void 0,i.length=0,a=0,m=!1}return{feed:h,reset:P}}function Xg(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function e_(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var hs=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:o,maxBufferSize:n}={}){let s;super({start(i){s=t_({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:o,maxBufferSize:n})},transform(i){s.feed(i)}})}};var lk={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},At=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},gs=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Zg(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??lk}async _authThenStart(){if(!this._authProvider)throw new mt("No auth provider");let t;try{t=await Ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new mt;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(t.Authorization=`Bearer ${o.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=ms(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let o=await this._commonHeaders();o.set("Accept","text/event-stream"),r&&o.set("last-event-id",r);let n=await(this._fetch??fetch)(this._url,{method:"GET",headers:o,signal:this._abortController?.signal});if(!n.ok){if(await n.body?.cancel(),n.status===401&&this._authProvider)return await this._authThenStart();if(n.status===405)return;throw new At(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,t,!0)}catch(o){throw this.onerror?.(o),o}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,n=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(o,t),n)}_scheduleReconnection(t,r=0){let o=this._reconnectionOptions.maxRetries;if(r>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`));return}let n=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},n)}_handleSseStream(t,r,o){if(!t)return;let{onresumptiontoken:n,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new hs({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:h}=await l.read();if(h)break;if(m.id&&(i=m.id,a=!0,n?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let _=vn.parse(JSON.parse(m.data));jt(_)&&(c=!0,s!==void 0&&(_.id=s)),this.onmessage?.(_)}catch(_){this.onerror?.(_)}}(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:n,replayMessageId:s},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:n,replayMessageId:s},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new mt("No auth provider");if(await Ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mt("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:o,onresumptiontoken:n}=r||{};if(o){this._startOrAuthSse({resumptionToken:o,replayMessageId:Gr(t)?t.id:void 0}).catch(f=>this.onerror?.(f));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let f=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new At(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:m,scope:h}=Wc(a);if(this._resourceMetadataUrl=m,this._scope=h,await Ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mt;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:m,scope:h,error:_}=Wc(a);if(_==="insufficient_scope"){let v=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===v)throw new At(403,"Server returned 403 after trying upscoping");if(h&&(this._scope=h),m&&(this._resourceMetadataUrl=m),this._lastUpscopingHeader=v??void 0,await Ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new mt;return this.send(t)}}throw new At(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),If(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}let l=(Array.isArray(t)?t:[t]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=a.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(a.body,{onresumptiontoken:n},!1);else if(d?.includes("application/json")){let f=await a.json(),m=Array.isArray(f)?f.map(h=>vn.parse(h)):[vn.parse(f)];for(let h of m)this.onmessage?.(h)}else throw await a.body?.cancel(),new At(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(o){throw this.onerror?.(o),o}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,r);if(await o.body?.cancel(),!o.ok&&o.status!==405)throw new At(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};var Qc=r_(hk(),".kleo"),Ar=r_(Qc,"config.json"),gk="https://app.kleo.so";function eu(){if(!Xc(Ar))return{};try{return JSON.parse(pk(Ar,"utf8"))}catch{return{}}}function o_(e){Xc(Qc)||dk(Qc,{recursive:!0,mode:448}),mk(Ar,`${JSON.stringify(e,null,2)}
88
+ `,{mode:384})}function n_(){Xc(Ar)&&fk(Ar)}function ys(){return Ar}function vs(e){let t=eu(),r=e.apiUrl??process.env.KLEO_API_URL??t.apiUrl??gk,o=e.apiKey??process.env.KLEO_API_KEY??t.apiKey;return{apiUrl:r.replace(/\/+$/,""),apiKey:o}}function _s(e){return`${e.replace(/\/+$/,"")}/api/mcp/mcp`}async function s_(e){let{apiUrl:t,apiKey:r}=vs(e);if(!r)throw new Error("No API key. Run `kleo login --key kleo_sk_\u2026` (or set KLEO_API_KEY). Mint one in Kleo \u2192 Settings \u2192 MCP, or POST /api/mcp/keys.");let o=new gs(new URL(_s(t)),{requestInit:{headers:{Authorization:`Bearer ${r}`}}}),n=new fs({name:"kleo-cli",version:"1.0.0"},{capabilities:{}});try{await n.connect(o)}catch(s){let i=s instanceof Error?s.message:String(s);throw/401|unauthor/i.test(i)?new Error(`Auth rejected by ${_s(t)} \u2014 the API key is invalid or revoked.`):/404|not found/i.test(i)?new Error(`${_s(t)} returned 404 \u2014 the MCP surface is off (NEXT_PUBLIC_ENABLE_MCP must be 'true') or the URL is wrong.`):new Error(`Could not connect to ${_s(t)}: ${i}`)}return{client:n,close:async()=>{await n.close().catch(()=>{})}}}function _k(e){return(e.content??[]).filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
89
+ `).trim()}async function tu(e,t,r={}){let o=await e.client.callTool({name:t,arguments:r}),n=_k(o);if(o.isError)throw new Error(n||`Tool ${t} returned an error.`);return{text:n,raw:o}}async function i_(e){let{tools:t}=await e.client.listTools();return t}var yk=new Set(["json","help","h","version"]);function vk(e){let t=[],r={};for(let o=0;o<e.length;o++){let n=e[o];if(n.startsWith("--")||n.startsWith("-")&&n.length===2&&Number.isNaN(Number(n))){let s=n.replace(/^-+/,""),[i,a]=s.split("=");if(a!==void 0)r[i]=a;else if(yk.has(i))r[i]=!0;else{let c=e[o+1];c!==void 0&&!c.startsWith("-")?(r[i]=c,o++):r[i]=!0}}else t.push(n)}return{positionals:t,flags:r}}function Ct(e,t){let r=e[t];return typeof r=="string"?r:void 0}function a_(e,t){let r=Ct(e,t);if(r===void 0)return;let o=Number(r);return Number.isFinite(o)?o:void 0}var ws=process.stdout.isTTY,ht=e=>ws?`\x1B[2m${e}\x1B[0m`:e,Pe=e=>ws?`\x1B[1m${e}\x1B[0m`:e,$k=e=>ws?`\x1B[31m${e}\x1B[0m`:e,ru=e=>ws?`\x1B[36m${e}\x1B[0m`:e;function ze(e){process.stdout.write(`${e}
90
+ `)}function ve(e){process.stderr.write(`${$k("error")} ${e}
91
+ `),process.exit(1)}function wk(e){return{apiUrl:Ct(e,"url"),apiKey:Ct(e,"key")}}async function ou(e,t){let r=await s_(wk(e)).catch(o=>ve(o.message));try{return await t(r)}finally{await r.close()}}async function gt(e,t,r){await ou(e,async o=>{let{text:n,raw:s}=await tu(o,t,r).catch(i=>ve(i.message));ze(e.json?JSON.stringify(s,null,2):n||ht("(empty)"))})}function bk(e){let t=Ct(e.flags,"key")??process.env.KLEO_API_KEY,r=Ct(e.flags,"url");!t&&!r&&ve("Nothing to save. Pass --key kleo_sk_\u2026 and/or --url https://your-host"),t&&!t.startsWith("kleo_sk_")&&ve("That doesn't look like a Kleo key (expected it to start with 'kleo_sk_').");let o=eu();t&&(o.apiKey=t),r&&(o.apiUrl=r.replace(/\/+$/,"")),o_(o);let{apiUrl:n}=vs({});ze(`${ru("\u2713")} Saved to ${ht(ys())}`),ze(` server: ${n}`),t&&ze(` key: ${c_(t)}`)}function zk(){n_(),ze(`${ru("\u2713")} Cleared ${ht(ys())}`)}function xk(){let{apiUrl:e,apiKey:t}=vs({});ze(`${Pe("server")} ${e}`),ze(`${Pe("key")} ${t?c_(t):ht("(none \u2014 run `kleo login`)")}`),ze(ht(`config file: ${ys()}`)),ze(ht("precedence: --flag > env (KLEO_API_KEY/KLEO_API_URL) > config file > default"))}function c_(e){return e.length<=12?e:`${e.slice(0,12)}\u2026${e.slice(-4)}`}async function Sk(e){await ou(e.flags,async t=>{let r=await i_(t);if(e.flags.json)return ze(JSON.stringify(r,null,2));ze(Pe(`${r.length} tools available`));for(let o of r){let n=o.title??"";ze(` ${ru(o.name.padEnd(22))} ${ht(n)}`)}})}async function kk(e){await ou(e.flags,async t=>{let r=[["Offers & audiences","getOffersAndAudiences"],["Content strategy","getContentStrategy"],["Content plan","getContentPlan"]],o={};for(let[n,s]of r){let{text:i,raw:a}=await tu(t,s,{}).catch(c=>({text:`(failed: ${c.message})`,raw:{error:c.message}}));e.flags.json?o[s]=a:(ze(Pe(`
92
+ \u2500\u2500 ${n} \u2500\u2500`)),ze(i||ht("(none)")))}e.flags.json&&ze(JSON.stringify(o,null,2))})}async function Pk(e){let t=e.positionals.slice(1).join(" ").trim();t||ve('Give the agent a task, e.g. `kleo agent "draft a post about our launch"`');let r=Ct(e.flags,"chat");await gt(e.flags,"kleoAgent",{message:t,...r?{chatId:r}:{}})}async function Ek(e){let[,t,...r]=e.positionals;t||ve("Usage: kleo call <toolName> [--json '{...}'] [key=value \u2026]");let o={},n=Ct(e.flags,"input")??Ct(e.flags,"args");if(n)try{o=JSON.parse(n)}catch(s){ve(`--input is not valid JSON: ${s.message}`)}for(let s of r){let i=s.indexOf("=");i!==-1&&(o[s.slice(0,i)]=s.slice(i+1))}await gt(e.flags,t,o)}async function $s(e,t){let r=e.positionals[1],o=a_(e.flags,"limit");if(!r||r==="list")return t.list||ve("This store has no `list`; use `search` or `read`."),gt(e.flags,t.list.tool,o&&t.list.withLimit?{limit:o}:{});if(r==="search"){t.search||ve("This store has no `search`.");let n=e.positionals.slice(2).join(" ").trim();return n||ve("Usage: search <query>"),gt(e.flags,t.search.tool,{query:n,...o?{limit:o}:{}})}if(r==="read"){let n=e.positionals[2];return n||ve(`Usage: read <${t.read.label}>`),gt(e.flags,t.read.tool,{[t.read.argName]:n})}ve(`Unknown subcommand '${r}'. Expected: list | search | read`)}async function Tk(e){let t=e.positionals[1],r=a_(e.flags,"limit");if(!t||t==="view"||t==="list")return gt(e.flags,"viewMemory",{});if(t==="search"){let o=e.positionals.slice(2).join(" ").trim();return o||ve("Usage: kleo memory search <query>"),gt(e.flags,"searchMemory",{query:o,...r?{limit:r}:{}})}if(t==="read"){let o=e.positionals[2];return o||ve("Usage: kleo memory read <path> e.g. voice/style.md"),gt(e.flags,"readMemory",{path:o})}ve(`Unknown subcommand '${t}'. Expected: view | search | read`)}var Rk=`${Pe("kleo")} \u2014 your Kleo workspace from the terminal
93
+
94
+ ${Pe("USAGE")}
95
+ kleo <command> [subcommand] [args] [flags]
96
+
97
+ ${Pe("AUTH")}
98
+ kleo login --key kleo_sk_\u2026 [--url https://app.kleo.so] Save credentials (~/.kleo/config.json)
99
+ kleo logout Forget credentials
100
+ kleo config Show current server + key
101
+ kleo whoami Which user/profile this key acts as
102
+
103
+ ${Pe("KNOWLEDGE BASE")}
104
+ kleo kb list Catalog of every KB item (id \xB7 title \xB7 type \xB7 preview)
105
+ kleo kb search <query> Keyword search across KB content
106
+ kleo kb read <id> Full text of one item
107
+
108
+ ${Pe("SWIPE FILE")}
109
+ kleo swipe list Catalog of saved inspiration posts
110
+ kleo swipe search <query> Keyword search across swipes
111
+ kleo swipe read <id> Full text of one swipe
112
+
113
+ ${Pe("TEMPLATES")}
114
+ kleo template list Your templates + the Kleo library
115
+ kleo template search <query> Keyword search across templates
116
+ kleo template read <id> Full text of one template
117
+
118
+ ${Pe("POSTS")}
119
+ kleo post list Scheduled + published posts
120
+ kleo post read <id> Full content of one post
121
+
122
+ ${Pe("MEMORY (what Kleo has learned about you)")}
123
+ kleo memory view The memory index
124
+ kleo memory search <query> Search memory
125
+ kleo memory read <path> Read a memory file (e.g. voice/style.md)
126
+
127
+ ${Pe("STRATEGY")}
128
+ kleo strategy Offers & audiences, content strategy, content plan
129
+
130
+ ${Pe("AGENT & ESCAPE HATCH")}
131
+ kleo agent "<task>" [--chat <id>] Delegate a whole task to the Kleo agent
132
+ kleo tools List every tool the server exposes
133
+ kleo call <tool> [--input '{\u2026}'] [k=v \u2026] Call any tool by name
134
+
135
+ ${Pe("GLOBAL FLAGS")}
136
+ --url <u> Override server base URL --key <k> Override API key
137
+ --limit <n> Cap list/search results --json Raw JSON output
138
+ -h, --help Show this help
139
+
140
+ ${ht("Precedence for url/key: --flag > KLEO_API_URL / KLEO_API_KEY > ~/.kleo/config.json > default")}`;async function Ok(){let e=vk(process.argv.slice(2)),t=e.positionals[0];if(!t||e.flags.help||e.flags.h){ze(Rk);return}switch(t){case"login":return bk(e);case"logout":return zk();case"config":return xk();case"whoami":return gt(e.flags,"whoami",{});case"tools":return Sk(e);case"kb":return $s(e,{list:{tool:"listKB"},search:{tool:"searchKB"},read:{tool:"readKB",argName:"id",label:"id"}});case"swipe":case"swipes":return $s(e,{list:{tool:"listSwipes"},search:{tool:"searchSwipes"},read:{tool:"readSwipe",argName:"id",label:"id"}});case"template":case"templates":return $s(e,{list:{tool:"listTemplates",withLimit:!0},search:{tool:"searchTemplates"},read:{tool:"readTemplate",argName:"id",label:"id"}});case"post":case"posts":return $s(e,{list:{tool:"listPosts",withLimit:!0},read:{tool:"readPost",argName:"id",label:"id"}});case"memory":return Tk(e);case"strategy":return kk(e);case"agent":return Pk(e);case"call":return Ek(e);default:ve(`Unknown command '${t}'. Run \`kleo --help\`.`)}}Ok().catch(e=>ve(e instanceof Error?e.message:String(e)));
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@kleo.so/cli",
3
+ "version": "1.0.0",
4
+ "description": "Kleo from your terminal — read your knowledge base, swipe file, templates, posts and agent memory, and delegate tasks to the Kleo agent. A thin MCP client over the Kleo MCP server.",
5
+ "type": "module",
6
+ "bin": {
7
+ "kleo": "dist/kleo.js"
8
+ },
9
+ "files": ["dist", "README.md", "LICENSE"],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "scripts": {
17
+ "dev": "tsx kleo.ts",
18
+ "build": "node build.mjs",
19
+ "typecheck": "tsc --noEmit",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": ["kleo", "linkedin", "mcp", "model-context-protocol", "cli", "content"],
23
+ "license": "MIT",
24
+ "devDependencies": {
25
+ "@modelcontextprotocol/sdk": "^1.29.0",
26
+ "esbuild": "^0.24.0",
27
+ "tsx": "^4.19.1",
28
+ "typescript": "^5.6.0"
29
+ }
30
+ }