@aigora/mcp 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,124 @@
1
- # Temporary Holding Version
1
+ # @aigora/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Aigora MCP client bridge. Connects any stdio MCP client (Claude Code, Cursor, Claude Desktop, Codex, OpenCode, Hermes, OpenClaw, custom) to the public **Aigora MCP server** — the Celo agent registry + bounty toolset (`find_agent`, `get_agent_profile`, `create_bounty_intent`, …) over streamable-http.
4
+
5
+ ## Quickstart
6
+
7
+ ```bash
8
+ # Safely merge the Aigora server into each supported client config:
9
+ npx @aigora/mcp@latest init --client=claude-code
10
+ npx @aigora/mcp@latest init --client=cursor
11
+ npx @aigora/mcp@latest init --client=claude-desktop
12
+
13
+ # Custom client / debugging — run the bridge directly:
14
+ npx @aigora/mcp@latest run [--url https://…/mcp]
15
+ ```
16
+
17
+ Environment:
18
+
19
+ | Variable | Meaning |
20
+ |---|---|
21
+ | `AIGORA_MCP_URL` | Server URL override (defaults to the qualified isolated production endpoint; `--url` wins over both) |
22
+ | `AIGORA_API_KEY` | Optional Tier-1 key — raises the read rate ceiling. Tx-intent tools need only a connected wallet, never a key. |
23
+
24
+ `init` preserves existing servers and atomically adds or updates only the `aigora` entry, keeping any `env` you added to it. Invalid JSON is
25
+ never overwritten. Tier 0 needs no key; add `env.AIGORA_API_KEY` to the entry only when using a real Tier-1 key.
26
+
27
+ For Claude Code, `init` uses top-level `mcpServers` in `~/.claude.json`, the default
28
+ [user configuration](https://code.claude.com/docs/en/mcp#mcp-installation-scopes). It retains unrelated
29
+ settings, servers and any existing `aigora.env` entries, including an optional key you configured.
30
+ Malformed server or environment maps are refused. The obsolete `~/.claude/mcp.json` is left untouched.
31
+ Quit Claude Code before running `init`: a running Claude Code can rewrite `~/.claude.json` and drop the new entry.
32
+ `claude mcp add` (below) avoids that.
33
+
34
+ For a project-specific Claude Code entry, use the manual command:
35
+
36
+ ```bash
37
+ claude mcp add aigora -- npx @aigora/mcp@latest run
38
+ ```
39
+
40
+ ## Other clients
41
+
42
+ `init` does not write these configs. Add the entry yourself, then reload MCP or restart the client.
43
+
44
+ **Codex** (`~/.codex/config.toml`):
45
+
46
+ ```toml
47
+ [mcp_servers.aigora]
48
+ command = "npx"
49
+ args = ["@aigora/mcp@latest", "run"]
50
+
51
+ # Headless `codex exec`, or approval_policy = "never", refuses unapproved MCP calls. Pre-approve the read tools only:
52
+ [mcp_servers.aigora.tools.find_agent]
53
+ approval_mode = "approve"
54
+ [mcp_servers.aigora.tools.list_services]
55
+ approval_mode = "approve"
56
+ [mcp_servers.aigora.tools.get_agent_profile]
57
+ approval_mode = "approve"
58
+ [mcp_servers.aigora.tools.rank_agent]
59
+ approval_mode = "approve"
60
+ [mcp_servers.aigora.tools.list_tasks]
61
+ approval_mode = "approve"
62
+ ```
63
+
64
+ **OpenCode** (`opencode.json`):
65
+
66
+ ```json
67
+ { "mcp": { "aigora": { "type": "local", "command": ["npx", "@aigora/mcp@latest", "run"], "enabled": true } } }
68
+ ```
69
+
70
+ **Hermes Agent** (`~/.hermes/config.yaml`):
71
+
72
+ ```yaml
73
+ mcp_servers:
74
+ aigora:
75
+ command: "npx"
76
+ args: ["@aigora/mcp@latest", "run"]
77
+ ```
78
+
79
+ **OpenClaw**:
80
+
81
+ ```bash
82
+ openclaw mcp add aigora --command npx --arg @aigora/mcp@latest --arg run
83
+ ```
84
+
85
+ Codex 0.164.0 and OpenCode 1.19.3 were tested against the live server on 2026-10-26. The Hermes and OpenClaw entries
86
+ follow those clients' MCP documentation and have not been tested yet. Keep the intent tools (`*_intent`,
87
+ `refine_bounty_spec`) behind your client's approval prompt.
88
+
89
+ ## How it works
90
+
91
+ `run` opens a raw bidirectional pipe between a stdio server transport (your client's side) and a
92
+ streamable-http client transport (Aigora's side). The bridge interprets nothing: every JSON-RPC message —
93
+ current and future tools alike — passes through unchanged. The npm artifact is a Node 24 single-file
94
+ bundle with zero runtime npm dependencies; bundled third-party license texts ship beside it.
95
+
96
+ The deploy-ready documentation source is [`docs/index.md`](docs/index.md). Release verification refuses
97
+ README/docs/client-snippet drift, unexpected tarball files, likely secrets, oversized artifacts, unsafe
98
+ config writes or a broken installed-binary roundtrip.
99
+
100
+ ## Versioning & deprecation policy
101
+
102
+ - **Semver**: a **major** bump = a breaking tool-schema change; **minor** = additive tools/fields only
103
+ (additive-only); **patch** = fixes. The default server URL baked into the bridge only
104
+ changes in a minor+.
105
+ - **Deprecation**: a tool slated for removal first serves `Deprecation: true` + `Sunset: <date>` response
106
+ headers and keeps working until the sunset date; the migration note lives in this README's changelog
107
+ section when it happens.
108
+ - **Old clients**: the server answers schema-version mismatches with its current schema and the hint to
109
+ upgrade via `npx @aigora/mcp@latest`.
110
+
111
+ ## Release verification
112
+
113
+ ```bash
114
+ npm run verify:release
115
+ ```
116
+
117
+ This creates the actual tarball in an isolated temporary directory, enforces the package allowlist and
118
+ 3 MB target, installs it into a clean project, runs `npx aigora-mcp help`, installs all three client
119
+ configs, proves invalid JSON is untouched, and drives `initialize` + `tools/list` through the installed
120
+ bridge against a local fixture MCP server (`test/fixtures/mcpServer.mjs`). The final JSON contains the publish
121
+ candidate’s SHA-256 and npm integrity values and checks that `release/<version>.json` records them and the bundled
122
+ default MCP URL. This repository (`github.com/trionlabs/agent-search-mcp-aigora`) is the package's only source; the
123
+ live Aigora service's tool contract and the aigora.org web snippets are checked against each published version
124
+ separately. Releases are owner steps; see [`RELEASE_NOTES.md`](RELEASE_NOTES.md).
@@ -0,0 +1,80 @@
1
+ # @aigora/mcp 0.1.2 — release candidate notes
2
+
3
+ Documentation release on top of 0.1.1 (it includes everything in 0.1.1, which is not published to npm):
4
+
5
+ - the README and `docs/index.md` give the client lines for Codex, OpenCode, Hermes and OpenClaw, beside Claude Code,
6
+ Cursor and Claude Desktop;
7
+ - the packaged skill (`skills/aigora-mcp.md`, exported as `./skill`) now points to the maintained Aigora MCP skill in
8
+ `github.com/trionlabs/aigora-skills`, so there is one source.
9
+
10
+ The bridge, default MCP URL, tools and configuration are unchanged from 0.1.1. `release/0.1.2.json` qualifies this
11
+ Node 24 tarball.
12
+
13
+ 0.1.2 is published from the owner's machine with npm 2FA and without npm provenance, as 0.1.0 was. The release
14
+ workflow's publish job needs a GitHub-hosted runner (npm trusted publishing supports no other), and that runner is not
15
+ available to this repository yet. Later versions publish only through `.github/workflows/release.yml` with npm trusted
16
+ publishing and provenance. Owner steps for 0.1.2:
17
+
18
+ 1. Under **Node 24.21.0** (other Node versions gzip differently), from the release commit on `main`: `npm ci`,
19
+ `npm test`, `npm run typecheck` and `npm run verify:release`.
20
+ 2. `npm pack`, then check that the tarball's SHA-256 and npm integrity equal `release/0.1.2.json`.
21
+ 3. `npm publish ./aigora-mcp-0.1.2.tgz --access public` with npm 2FA.
22
+ 4. Confirm that `npm view @aigora/mcp@0.1.2 dist.integrity` equals `release/0.1.2.json`, then push the tag `v0.1.2`
23
+ on the release commit. For an already published version, `release.yml` only reads the registry back.
24
+
25
+ # @aigora/mcp 0.1.1 — release candidate notes
26
+
27
+ Not published to npm: 0.1.2 includes these changes and is published instead.
28
+
29
+ Patch release:
30
+
31
+ - a clean shutdown (the editor closes stdin) no longer prints `[aigora-mcp] http: request failed`. Closing aborts
32
+ the bridge's own server-event stream, and that abort is no longer reported as a failure. Errors while the session
33
+ is open are still reported, with the same fixed messages.
34
+
35
+ The default MCP URL, tools and configuration are unchanged from 0.1.0. `release/0.1.1.json` qualifies this Node 24
36
+ tarball as `release/0.1.0.json` did for 0.1.0.
37
+
38
+ 0.1.1 was to be the first version published only through `.github/workflows/release.yml`, with npm trusted
39
+ publishing and provenance. CI and the release checks run on Blacksmith runners; the publish job alone runs on a GitHub-hosted
40
+ runner, because npm trusted publishing does not support self-hosted runners. Owner steps:
41
+
42
+ 1. On the release commit, `ci` must pass, including `npm run verify:release`; that proves the Linux tarball equals
43
+ `release/0.1.1.json`. The organization's billing must also allow GitHub-hosted jobs, which the publish job needs.
44
+ Do not configure trust before both hold.
45
+ 2. Configure the `npm-publish` environment (the owner as required reviewer, `v*` tags only) and the npm trusted
46
+ publisher for `release.yml` with that environment. npm expects a new trusted-publisher configuration to publish
47
+ within two days.
48
+ 3. Merge the release commit to `main`, then push the tag `v0.1.1` on it.
49
+ 4. Approve the `npm-publish` deployment. The workflow checks that the packed tarball equals `release/0.1.1.json`
50
+ before it publishes, then reads the registry back against it.
51
+
52
+ # @aigora/mcp 0.1.0 — release notes
53
+
54
+ Initial public bridge release:
55
+
56
+ - stdio ↔ streamable-http transport;
57
+ - safe config merge for Claude Code, Cursor and Claude Desktop;
58
+ - public Tier‑0 operation plus optional `AIGORA_API_KEY`;
59
+ - packaged Aigora skill file;
60
+ - zero runtime npm dependencies through a Node 24 single-file bundle;
61
+ - deterministic tarball allowlist, secret scan, clean install and installed-binary roundtrip gate;
62
+ - default connection to Aigora's production MCP service.
63
+
64
+ `release/0.1.0.json` qualifies this Node 24 tarball: its SHA-256, npm integrity, file allowlist and the
65
+ default MCP URL the bundle connects to. `npm run verify:release` fails if any of them changes.
66
+
67
+ Owner release steps for 0.1.0:
68
+
69
+ 1. Confirm npm `@aigora` organization ownership and `0.1.0` availability.
70
+ 2. Run `npm run verify:release` from the exact release commit; its SHA-256/integrity must equal `release/0.1.0.json`.
71
+ 3. Keep `github.com/trionlabs/agent-search-mcp-aigora` private until its security review passes, then make it public.
72
+ 4. Publish 0.1.0 from the owner's machine with npm 2FA, from the verified tarball: under **Node 24.21.0** (other Node
73
+ versions gzip differently), `npm pack`, check that the tarball's SHA-256 and npm integrity equal
74
+ `release/0.1.0.json`, then `npm publish ./aigora-mcp-0.1.0.tgz --access public`. 0.1.0 is published without npm
75
+ provenance, and so is 0.1.2 (see its notes); other later versions publish only through
76
+ `.github/workflows/release.yml` with npm trusted publishing and provenance from this public repository.
77
+ 5. Confirm that `npm view @aigora/mcp@0.1.0 dist.integrity` equals `release/0.1.0.json`, then tag `v0.1.0`.
78
+
79
+ The bundle connects only to the exact production MCP URL recorded in `release/0.1.0.json`; a later default-URL change
80
+ needs a minor+ release.
package/bin/mcp.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ // `npx @aigora/mcp …` entry — thin shell over the generated single-file release bundle.
3
+ const bundleUrl = new URL('../dist/cli.js', import.meta.url);
4
+ const { execute, parseArgs } = await import(bundleUrl.href);
5
+
6
+ const code = await execute(parseArgs(process.argv.slice(2)));
7
+ // `run` resolves when the bridge closes (client hung up) — exiting then is correct for npx lifetimes.
8
+ process.exit(code);
@@ -0,0 +1,127 @@
1
+ Aigora MCP — bundled third-party license notices
2
+
3
+ ================================================================================
4
+ @modelcontextprotocol/sdk@1.32.2
5
+ ================================================================================
6
+ MIT License
7
+
8
+ Copyright (c) 2024 Anthropic, PBC
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ ================================================================================
29
+ content-type@1.0.5
30
+ ================================================================================
31
+ (The MIT License)
32
+
33
+ Copyright (c) 2015 Douglas Christopher Wilson
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining
36
+ a copy of this software and associated documentation files (the
37
+ 'Software'), to deal in the Software without restriction, including
38
+ without limitation the rights to use, copy, modify, merge, publish,
39
+ distribute, sublicense, and/or sell copies of the Software, and to
40
+ permit persons to whom the Software is furnished to do so, subject to
41
+ the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
49
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
50
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
52
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53
+
54
+ ================================================================================
55
+ eventsource-parser@3.1.0
56
+ ================================================================================
57
+ MIT License
58
+
59
+ Copyright (c) 2026 Espen Hovlandsdal <espen@hovlandsdal.com>
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining a copy
62
+ of this software and associated documentation files (the "Software"), to deal
63
+ in the Software without restriction, including without limitation the rights
64
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65
+ copies of the Software, and to permit persons to whom the Software is
66
+ furnished to do so, subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in all
69
+ copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
77
+ SOFTWARE.
78
+
79
+ ================================================================================
80
+ pkce-challenge@5.0.1
81
+ ================================================================================
82
+ MIT License
83
+
84
+ Copyright (c) 2019
85
+
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to deal
88
+ in the Software without restriction, including without limitation the rights
89
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
90
+ copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in all
94
+ copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
101
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
102
+ SOFTWARE.
103
+
104
+ ================================================================================
105
+ zod@4.6.7
106
+ ================================================================================
107
+ MIT License
108
+
109
+ Copyright (c) 2025 Colin McDonnell
110
+
111
+ Permission is hereby granted, free of charge, to any person obtaining a copy
112
+ of this software and associated documentation files (the "Software"), to deal
113
+ in the Software without restriction, including without limitation the rights
114
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
115
+ copies of the Software, and to permit persons to whom the Software is
116
+ furnished to do so, subject to the following conditions:
117
+
118
+ The above copyright notice and this permission notice shall be included in all
119
+ copies or substantial portions of the Software.
120
+
121
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
122
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
123
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
124
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
125
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
126
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
127
+ SOFTWARE.
package/dist/cli.js ADDED
@@ -0,0 +1,86 @@
1
+ var _l=Object.create;var Nr=Object.defineProperty;var zl=Object.getOwnPropertyDescriptor;var xl=Object.getOwnPropertyNames;var yl=Object.getPrototypeOf,bl=Object.prototype.hasOwnProperty;var wl=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},jr=(e,t)=>{for(var r in t)Nr(e,r,{get:t[r],enumerable:!0})},vl=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xl(t))!bl.call(e,n)&&n!==r&&Nr(e,n,{get:()=>t[n],enumerable:!(o=zl(t,n))||o.enumerable});return e};var Sl=(e,t,r)=>(r=e!=null?_l(yl(e)):{},vl(t||!e||!e.__esModule?Nr(r,"default",{value:e,enumerable:!0}):r,e));var Fu=wl(nn=>{"use strict";var Lu=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,eh=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Du=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,th=/\\([\u000b\u0020-\u00ff])/g,rh=/([\\"])/g,Mu=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;nn.format=oh;nn.parse=nh;function oh(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!Mu.test(r))throw new TypeError("invalid type");var o=r;if(t&&typeof t=="object")for(var n,i=Object.keys(t).sort(),s=0;s<i.length;s++){if(n=i[s],!Du.test(n))throw new TypeError("invalid parameter name");o+="; "+n+"="+sh(t[n])}return o}function nh(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?ih(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),o=r!==-1?t.slice(0,r).trim():t.trim();if(!Mu.test(o))throw new TypeError("invalid media type");var n=new ch(o.toLowerCase());if(r!==-1){var i,s,c;for(Lu.lastIndex=r;s=Lu.exec(t);){if(s.index!==r)throw new TypeError("invalid parameter format");r+=s[0].length,i=s[1].toLowerCase(),c=s[2],c.charCodeAt(0)===34&&(c=c.slice(1,-1),c.indexOf("\\")!==-1&&(c=c.replace(th,"$1"))),n.parameters[i]=c}if(r!==t.length)throw new TypeError("invalid parameter format")}return n}function ih(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function sh(e){var t=String(e);if(Du.test(t))return t;if(t.length>0&&!eh.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(rh,"\\$1")+'"'}function ch(e){this.parameters=Object.create(null),this.type=e}});var $l=["@aigora/mcp@latest","run"],rt=Object.freeze({command:"npx",args:$l}),ot=Object.freeze(["claude-code","cursor","claude-desktop"]),Jh=Object.freeze(Object.fromEntries(ot.map(e=>[e,`npx @aigora/mcp@latest init --client=${e}`])));function yn(e){switch((e??"").trim()){case"claude-code":return{ok:!0,client:"claude-code",target:"run this in your project (writes .mcp.json / user scope per the flag you choose)",snippet:"claude mcp add aigora -- npx @aigora/mcp@latest run"};case"cursor":return{ok:!0,client:"cursor",target:"~/.cursor/mcp.json (or .cursor/mcp.json in your project)",snippet:JSON.stringify({mcpServers:{aigora:rt}},null,2)};case"claude-desktop":return{ok:!0,client:"claude-desktop",target:"claude_desktop_config.json (Claude Desktop \u2192 Settings \u2192 Developer \u2192 Edit Config)",snippet:JSON.stringify({mcpServers:{aigora:rt}},null,2)};default:return{ok:!1,error:"unknown_client",clients:ot}}}import{execFile as kl}from"node:child_process";import{randomBytes as Pl}from"node:crypto";import{promisify as Ol}from"node:util";import{mkdir as Rl,open as Zl,readFile as Cl,rename as El,rm as Al}from"node:fs/promises";import{dirname as Tl,join as je,win32 as Il}from"node:path";import{platform as bn}from"node:os";function Nl(e,t=process.env,r=bn()){let o=t.HOME||t.USERPROFILE;return o?e==="claude-code"?{ok:!0,path:je(o,".claude.json"),rootKey:"mcpServers"}:e==="cursor"?{ok:!0,path:je(o,".cursor","mcp.json"),rootKey:"mcpServers"}:e==="claude-desktop"?{ok:!0,path:r==="darwin"?je(o,"Library","Application Support","Claude","claude_desktop_config.json"):r==="win32"?je(t.APPDATA||je(o,"AppData","Roaming"),"Claude","claude_desktop_config.json"):je(o,".config","Claude","claude_desktop_config.json"),rootKey:"mcpServers"}:{ok:!1,error:"unknown_client"}:{ok:!1,error:"home_not_found"}}async function jl(e,t,r=Ol(kl)){if(!t.USERNAME)throw new Error("Cannot restrict the config file to the current Windows user: USERNAME is unset");let o=t.USERDOMAIN?`${t.USERDOMAIN}\\${t.USERNAME}`:t.USERNAME,n=t.SystemRoot||process.env.SystemRoot;if(!n)throw new Error("Cannot restrict the config file to the current Windows user: SystemRoot is unset");await r(Il.join(n,"System32","icacls.exe"),[e,"/inheritance:r","/grant:r",`${o}:F`])}async function Ul(e){try{let t=await Cl(e,"utf8"),r=JSON.parse(t);if(!r||Array.isArray(r)||typeof r!="object")throw new Error("config root must be an object");return r}catch(t){if(t.code==="ENOENT")return{};throw t instanceof SyntaxError?new Error(`Refusing to overwrite invalid JSON at ${e}`):t}}async function wn(e,t={}){let r=Nl(e,t.env,t.platform);if(!r.ok)return r;let o=await Ul(r.path),n=o[r.rootKey];if(n!=null&&(Array.isArray(n)||typeof n!="object"))throw new Error(`Refusing to replace non-object ${r.rootKey} in ${r.path}`);if(n===null)throw new Error(`Refusing to replace non-object ${r.rootKey} in ${r.path}`);let i=n?.aigora;if(i!==void 0&&(!i||Array.isArray(i)||typeof i!="object"))throw new Error(`Refusing to replace non-object aigora in ${r.path}`);let s=i?.env;if(s!==void 0&&(!s||Array.isArray(s)||typeof s!="object"))throw new Error(`Refusing to replace non-object aigora.env in ${r.path}`);let c={...rt,...s===void 0?{}:{env:s}},a={...o,[r.rootKey]:{...n||{},aigora:c}};await Rl(Tl(r.path),{recursive:!0});let u=`${r.path}.aigora-tmp-${Pl(8).toString("hex")}`,p=t.platform??bn(),f=t.restrictToOwner??(p==="win32"?d=>jl(d,t.env??process.env):null),h=await Zl(u,"wx",384);try{f&&await f(u),await h.writeFile(`${JSON.stringify(a,null,2)}
2
+ `,"utf8"),await h.close(),await El(u,r.path)}catch(d){throw await h.close().catch(()=>{}),await Al(u,{force:!0}),d}return{ok:!0,path:r.path}}import Uu from"node:process";var $={};jr($,{BIGINT_FORMAT_RANGES:()=>Bt,CONSTANT_CATCH:()=>Tn,Class:()=>Dr,NUMBER_FORMAT_RANGES:()=>it,aborted:()=>ae,allowsEval:()=>qr,assert:()=>Bl,assertEqual:()=>Ll,assertIs:()=>Ml,assertNever:()=>Fl,assertNotEqual:()=>Dl,assignProp:()=>re,attachSchema:()=>st,base64ToUint8Array:()=>En,base64urlToUint8Array:()=>ap,cached:()=>Me,captureStackTrace:()=>Mt,cleanEnum:()=>cp,cleanRegex:()=>nt,clone:()=>ie,cloneDef:()=>Wl,codePointLength:()=>ct,constantCatch:()=>In,createTransparentProxy:()=>Yl,defineLazy:()=>$n,defineLazyInternal:()=>R,derived:()=>dp,esc:()=>Br,escapeRegex:()=>ge,explicitlyAborted:()=>Kr,extend:()=>tp,finalizeIssue:()=>ue,floatSafeRemainder:()=>Fr,getElementAtPath:()=>Vl,getEnumValues:()=>Le,getLengthableOrigin:()=>at,getParsedType:()=>Xl,getSizableOrigin:()=>Cn,hexToUint8Array:()=>lp,hide:()=>Wt,installLazyProp:()=>gp,isObject:()=>Re,isPlainObject:()=>Se,issue:()=>Be,joinValues:()=>Dt,jsonStringifyReplacer:()=>De,members:()=>Hr,merge:()=>op,mergeDefs:()=>he,normalizeParams:()=>S,nullish:()=>Mr,numKeys:()=>Hl,objectClone:()=>Jl,omit:()=>ep,optionalKeys:()=>Vr,own:()=>ve,parsedType:()=>Gr,partial:()=>np,pick:()=>Ql,prefixIssues:()=>_e,primitiveTypes:()=>Rn,promiseAllObject:()=>Kl,propertyKeyTypes:()=>Wr,randomString:()=>Gl,rawShape:()=>Fe,required:()=>ip,safeExtend:()=>rp,shallowClone:()=>On,sizeCaps:()=>qt,slugify:()=>Jr,stringifyPrimitive:()=>Ft,toZod:()=>Sn,uint8ArrayToBase64:()=>An,uint8ArrayToBase64url:()=>up,uint8ArrayToHex:()=>pp,unwrapMessage:()=>Ue});function Ll(e){return e}function Dl(e){return e}function Sn(){return e=>e}function Ml(e){}function Fl(e){throw new Error("Unexpected value in exhaustive check")}function Bl(e){}function Le(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 Dt(e,t="|"){return e.map(r=>Ft(r)).join(t)}function De(e,t){return typeof t=="bigint"?t.toString():t}var Lr=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Me(e){return new Lr(e)}function Mr(e){return e==null}function nt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Fr(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var vn=Symbol("evaluating");function $n(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==vn)return o===void 0&&(o=vn,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Jl(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function re(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Fe(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function me(e){return Fe(e._zod.def)??e._zod.def.shape}function kn(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return re(this,t,o),o},enumerable:!0,configurable:!0})}function Pn(e,t,r){t in e?re(e,t,r):e[t]=r}function Oe(e,t,r,o){let n=me(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(n,i);s.enumerable&&(s.get?kn(e,i,()=>{let c=t._zod.def.shape[i];return o?o(c,i):c}):Pn(e,i,o?o(s.value,i):s.value))}}function ql(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);o.enumerable&&(o.get?kn(e,r,()=>t[r]):Pn(e,r,o.value))}}function he(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function Wl(e){return he(e._zod.def)}function Vl(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function Kl(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function Gl(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function Br(e){return JSON.stringify(e)}function Jr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Mt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var qr=Me(()=>{if(Q.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Se(e){if(Re(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Re(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function On(e){return Se(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Hl(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Xl=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}`)}},Wr=new Set(["string","number","symbol"]),Rn=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function S(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 Yl(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},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 Ft(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Vr(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var it={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]},Bt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ql(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 i={};return Oe(i,e,Jt(e,t)),ie(e,he(r,{shape:i,checks:[]}))}function Jt(e,t){let r=me(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&o.push(n)}return o}function ep(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 i=new Set(Jt(e,t)),s={};return Oe(s,e,Reflect.ownKeys(me(e)).filter(c=>!i.has(c))),ie(e,he(r,{shape:s,checks:[]}))}function tp(e,t){if(!Se(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=me(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ie(e,he(e._zod.def,{shape:Zn(e,t)}))}function Zn(e,t){let r={};return Oe(r,e,Reflect.ownKeys(me(e))),ql(r,t),r}function rp(e,t){if(!Se(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ie(e,he(e._zod.def,{shape:Zn(e,t)}))}function op(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Oe(r,e,Reflect.ownKeys(me(e))),Oe(r,t,Reflect.ownKeys(me(t)));let o=he(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ie(e,o)}function np(e,t,r,o="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${o}() cannot be used on object schemas containing refinements`);let c=r?new Set(Jt(t,r)):void 0,a={};return Oe(a,t,Reflect.ownKeys(me(t)),e&&((u,p)=>c&&!c.has(p)?u:new e({type:"optional",innerType:u}))),ie(t,he(t._zod.def,{shape:a,checks:[]}))}function ip(e,t,r){let o=r?new Set(Jt(t,r)):void 0,n={};return Oe(n,t,Reflect.ownKeys(me(t)),(i,s)=>o&&!o.has(s)?i:new e({type:"nonoptional",innerType:i})),ie(t,he(t._zod.def,{shape:n}))}function ae(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 Kr(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 _e(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Ue(e){return typeof e=="string"?e:e?.message}function qt(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;n>=0&&t.push([n,r])}return t}function st(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function ue(e,t,r){var o;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(o=e).schema??(o.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Ue(e.inst?._zod.def?.error?.(e))??Ue(i?.(e))??Ue(t?.error?.(e))??Ue(r.customError?.(e))??Ue(r.localeError?.(e))??"Invalid input",c={};for(let a of Object.keys(e))a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__"||(c[a]=e[a]);return c.path??(c.path=[]),c.message=s,t?.reportInput&&(c.input=e.input),c}function Cn(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var sp=/[\uD800-\uDBFF]/;function ct(e){let t=e.length;if(!sp.test(e))return t;let r=t;for(let o=0;o<t-1;o++)(e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320&&(r--,o++);return r}function at(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gr(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 Be(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function cp(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function En(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 An(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function ap(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return En(t+r)}function up(e){return An(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function lp(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 pp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Dr=class{constructor(...t){}};function Hr(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);o.get?Object.defineProperty(e,r,{...o,enumerable:!1}):fp(e,r,o.value)}}function ve(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function Wt(e,t,r){return ve(e,t,r,!1)}function dp(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return ve(this,r,o(this))},set(n){ve(this,r,n)}})}return t}function fp(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:ve(this,t,r.bind(this))},set(o){ve(this,t,o)}})}function mp(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Ur,we=!1,hp={configurable:!0,get(){we=!0}};function R(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&Ur!==e._zod){Ur=void 0;return}Ur=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,hp);let n=we;we=!1;try{let i=r(this);return we?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),we=we||n,i}catch(i){throw delete this[t],we=we||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function gp(e,t,r,o){let n=mp(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:i})}})}var Tn="~constantCatch";function In(e){let t=()=>e;return t[Tn]=!0,t}var Nn,Yr=Object.freeze({status:"aborted"}),Xr={value:void 0,enumerable:!1},jn="captureStackTrace"in Error?Error:null;function _p(e){let t=jn;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return jn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function m(e,t,r,o){let n={};function i(h){this.def=h,this.constr=f,this.traits=new Set}i.prototype=n;let s=r,c=s&&new WeakSet;function a(h,d){if(h._zod){if(h._zod.traits.has(e))return}else{Xr.value=new i(d);try{Object.defineProperty(h,"_zod",Xr)}finally{Xr.value=void 0}}if(h._zod.traits.add(e),t(h,d),c){let b=Object.getPrototypeOf(h),w=h._zod.constr.prototype,P=b;for(;P&&P!==w;)P=Object.getPrototypeOf(P);let B=P??b;c.has(B)||(c.add(B),Hr(B,s))}let g=f.prototype;for(let b in g)Object.prototype.hasOwnProperty.call(g,b)&&(b in h||(h[b]=g[b].bind(h)))}let u=o?.Parent??Object;class p extends u{}Object.defineProperty(p,"name",{value:e});function f(h){let d=o?.Parent?_p(p):this;a(d,h);let g=d._zod.deferred;if(g){for(let w of g)w();d._zod.deferred=void 0}let b=globalThis.__zod_globalConfig?.postProcessor;return b&&b(d),d}return Object.defineProperty(f,"init",{value:a}),Object.defineProperty(f,Symbol.hasInstance,{value:h=>o?.Parent&&h instanceof o.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var le=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Je=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Nn=globalThis).__zod_globalConfig??(Nn.__zod_globalConfig={});var Q=globalThis.__zod_globalConfig;function ee(e){return e&&Object.assign(Q,e),Q}function zp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,De,2)),e.message}function xp(e){this._zod.message=e}var yp={get:zp,set:xp,enumerable:!0,configurable:!0},eo={value:void 0,enumerable:!1},Un=new WeakSet([Object.prototype,Error.prototype]),Ln=(e,t)=>{e.name="$ZodError",eo.value=t,Object.defineProperty(e,"issues",eo),eo.value=void 0,Object.defineProperty(e,"message",yp);let r=Object.getPrototypeOf(e);Un.has(r)||(Un.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}}))},Dn=m("$ZodError",Ln),ig=m("$ZodError",Ln,void 0,{Parent:Error});function bp(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function to(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?bp(r,n.path[0],()=>[]).push(t(n)):o.push(t(n));return{formErrors:o,fieldErrors:r}}function ro(e,t=r=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>o({issues:c},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let c=[...i,...s.path];if(c.length===0)r._errors.push(t(s));else{let a=r,u=0;for(;u<c.length;){let p=c[u],f=u===c.length-1;if(p==="_errors"){f&&a._errors.push(t(s)),u++;continue}Object.prototype.hasOwnProperty.call(a,p)||Object.defineProperty(a,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=a[p];f&&h._errors.push(t(s)),a=h,u++}}}};return o(e),r}function Vt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Kt=e=>{let t=(r,o,n,i)=>{let s=n?{...n,async:!1}:{async:!1},c=r._zod.run({value:o,issues:[]},s);if(c instanceof Promise)throw new le;if(c.issues.length){let a=new(i?.Err??e)(c.issues.map(u=>ue(u,s,ee())));throw Mt(a,i?.callee??t),a}return c.value};return t};var Gt=e=>{let t=async(r,o,n,i)=>{let s=n?{...n,async:!0}:{async:!0},c=r._zod.run({value:o,issues:[]},s);if(c instanceof Promise&&(c=await c),c.issues.length){let a=new(i?.Err??e)(c.issues.map(u=>ue(u,s,ee())));throw Mt(a,i?.callee??t),a}return c.value};return t};var Ht=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new le;return i.issues.length?Mn(e,i.issues,n):{success:!0,data:i.value}};function Mn(e,t,r){let o;return{success:!1,get error(){return o||(o=new e(t.map(n=>ue(n,r,ee()))),t=void 0,r=void 0),o},set error(n){o=n,t=void 0,r=void 0}}}var Xt=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?Mn(e,i.issues,n):{success:!0,data:i.value}};var wp=Symbol.for("zod.compile.invalid"),vp=Symbol.for("zod.compile.fallback"),oo=((e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==wp)return!0;if(o.definite===!0&&r===void 0)return!1}return Sp(e,t,r)});function Sp(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,i;if(n?(o[vp]=!0,i=n({value:t,issues:[]},o)):i=e._zod.run({value:t,issues:[]},o),i instanceof Promise)throw new le;return i.issues.length===0}var no=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);return n instanceof Promise&&(n=await n),n.issues.length===0},Fn=e=>{let t=Kt(e),r=(o,n,i,s)=>{let c=i?{...i,direction:"backward"}:{direction:"backward"};return t(o,n,c,Vt(r,s))};return r};var Bn=e=>{let t=Kt(e),r=(o,n,i,s)=>t(o,n,i,Vt(r,s));return r};var Jn=e=>{let t=Gt(e),r=async(o,n,i,s)=>{let c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(o,n,c,Vt(r,s))};return r};var qn=e=>{let t=Gt(e),r=async(o,n,i,s)=>await t(o,n,i,Vt(r,s));return r};var Wn=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ht(e)(t,r,n)};var Vn=e=>(t,r,o)=>Ht(e)(t,r,o);var Kn=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Xt(e)(t,r,n)};var Gn=e=>async(t,r,o)=>Xt(e)(t,r,o);var Hn=/^[cC][0-9a-z]{6,}$/,Xn=/^[0-9a-z]+$/,Yn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Qn=/^[0-9a-vA-V]{20}$/,ei=/^[A-Za-z0-9]{27}$/,ti=/^[a-zA-Z0-9_-]{21}$/;function ri(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var oi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ni=/^([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})$/,so=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 ii=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var $p="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function si(){return new RegExp($p,"u")}var ci=/^(?:(?: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])$/,ai=/^(([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 ui=/^((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])$/,li=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,di=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var fi=/^https?$/,mi=/^\+[1-9]\d{6,14}$/;var hi="(?:(?:\\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])))";function kp(e){return new RegExp(`^${e}$`)}var gi=kp(hi);function io(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function _i(e){return new RegExp(`^${io(e)}$`)}function zi(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${io({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${io({precision:e.precision})}`:r;return new RegExp(`^${hi}T(?:${o})$`)}var xi=/^[\s\S]{0,}$/;var yi=/^-?\d+n?$/,co=/^-?\d+$/,ut=/^-?\d+(?:\.\d+)?$/,bi=/^(?:true|false)$/i,wi=/^null$/i;var vi=/^[^A-Z]*$/,Si=/^[^a-z]*$/;var V=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var ao=e=>{let t=e.value;return!Mr(t)&&t.length!==void 0},Yt={number:"number",bigint:"bigint",object:"date"},uo=m("$ZodCheckLessThan",(e,t)=>{V.init(e,t);let r=Yt[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:Yt[typeof o.value]??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})}}),lo=m("$ZodCheckGreaterThan",(e,t)=>{V.init(e,t);let r=Yt[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:Yt[typeof o.value]??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})}}),$i=m("$ZodCheckMultipleOf",(e,t)=>{V.init(e,t),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"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Fr(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})}}),ki=m("$ZodCheckNumberFormat",(e,t)=>{V.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=it[t.format];e._zod.check=s=>{let c=s.value;if(r){if(!Number.isInteger(c)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,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}):s.issues.push({input:c,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}}c<n&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Pi=m("$ZodCheckMaxLength",(e,t)=>{var r;V.init(e,t),(r=e._zod.def).when??(r.when=ao),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>t.maximum?ct(n):i)<=t.maximum)return;let c=at(n);o.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Oi=m("$ZodCheckMinLength",(e,t)=>{var r;V.init(e,t),(r=e._zod.def).when??(r.when=ao),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>=t.minimum&&i<t.minimum*2?ct(n):i)>=t.minimum)return;let c=at(n);o.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ri=m("$ZodCheckLengthEquals",(e,t)=>{var r;V.init(e,t),(r=e._zod.def).when??(r.when=ao),e._zod.check=o=>{let n=o.value,i=n.length,s=typeof n=="string"&&i>=t.length&&i<=t.length*2?ct(n):i;if(s===t.length)return;let c=at(n),a=s>t.length;o.issues.push({origin:c,...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})}}),lt=m("$ZodCheckStringFormat",(e,t)=>{var r,o;V.init(e,t),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=()=>{})}),Zi=m("$ZodCheckRegex",(e,t)=>{lt.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})}}),Ci=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vi),lt.init(e,t)}),Ei=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Si),lt.init(e,t)}),Ai=m("$ZodCheckIncludes",(e,t)=>{V.init(e,t);let r=ge(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=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})}}),Ti=m("$ZodCheckStartsWith",(e,t)=>{V.init(e,t);let r=new RegExp(`^${ge(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),Ii=m("$ZodCheckEndsWith",(e,t)=>{V.init(e,t);let r=new RegExp(`.*${ge(t.suffix)}$`);t.pattern??(t.pattern=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 Ni=m("$ZodCheckOverwrite",(e,t)=>{V.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Qt=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
3
+ `).filter(s=>s),n=Math.min(...o.map(s=>s.length-s.trimStart().length)),i=o.map(s=>s.slice(n)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4
+ ${r.join(`
5
+ `)}
6
+ };`)(...Object.values(this.closed))}};var Ui={major:4,minor:6,patch:7};var C=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ui;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let i of n)for(let s of i._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(c,a,u)=>{if(c.memo)return c;let p=ae(c),f;for(let h of a){if(h._zod.def.when){if(Kr(c)||!h._zod.def.when(c))continue}else if(p)continue;let d=c.issues.length,g=h._zod.check(c);if(g instanceof Promise&&u?.async===!1)throw new le;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,c.issues.length!==d&&(st(c.issues,d,e),p||(p=ae(c,d)))});else{if(c.issues.length===d)continue;st(c.issues,d,e),p||(p=ae(c,d))}}return f?f.then(()=>c):c},s=(c,a,u)=>{if(ae(c))return c.aborted=!0,c;let p=i(a,n,u);if(p instanceof Promise){if(u.async===!1)throw new le;return p.then(f=>e._zod.parse(f,u))}return e._zod.parse(p,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let p=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});return p instanceof Promise?p.then(f=>s(f,c,a)):s(p,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new le;return u.then(p=>i(p,n,a))}return i(u,n,a)}}},{get"~standard"(){return Wt(this,"~standard",fo(this))},set"~standard"(e){ve(this,"~standard",e)}}),Gi=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ue(r,t,ee()))}:{value:e.value};async function Pp(e,t){let r={async:!0};return Gi(await e._zod.run({value:t,issues:[]},r),r)}function fo(e){return{validate:t=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Gi(o,r)}catch{}return Pp(e,t)},vendor:"zod",version:1}}var or=m("$ZodString",(e,t)=>{C.init(e,t),e._zod.pattern=t.pattern??xi,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}}),I=m("$ZodStringFormat",(e,t)=>{lt.init(e,t),or.init(e,t)}),Hi=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ni),I.init(e,t)}),Xi=m("$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=so(o))}else t.pattern??(t.pattern=so());I.init(e,t)}),Yi=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ii),I.init(e,t)}),Qi=1,tr=2;function es(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Op(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?es(e)||tr:Rp(e,t)}function Rp(e,t){if(!t.normalize&&t.protocol?.source===fi.source&&!/^https?:\/\//i.test(e))return Qi;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??tr}return new URL(e)}catch{return tr}}var Zp=/[\t\n\r]/g;function Li(e){return e.replace(Zp,"")}function Cp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ep(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ts=m("$ZodURL",(e,t)=>{I.init(e,t),e._zod.check=r=>{try{let o=r.value.trim(),n=Op(o,t);if(n===Qi){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===tr){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=Li(o);return}t.hostname&&!Cp(n,t.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&&!Ep(n,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?n.href:Li(o);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),rs=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=si()),I.init(e,t)}),os=m("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?ti:ri(t.length)),I.init(e,t)}),ns=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Hn),I.init(e,t)}),is=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Xn),I.init(e,t)}),ss=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Yn),I.init(e,t)}),cs=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qn),I.init(e,t)}),as=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ei),I.init(e,t)}),us=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zi(t)),I.init(e,t)}),ls=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=gi),I.init(e,t)}),ps=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=_i(t)),I.init(e,t)}),ds=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=oi),I.init(e,t)}),fs=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ci),I.init(e,t)}),Ap=/^[0-9a-fA-F:.]+$/;function ms(e){return Ap.test(e)?es(`http://[${e}]`):!1}var hs=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ai),I.init(e,t),e._zod.check=r=>{ms(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var gs=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ui),I.init(e,t)});function Tp(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);return`${n}`!==o||n<0||n>128?!1:ms(r)}var _s=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=li),I.init(e,t),e._zod.check=r=>{Tp(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function zs(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var mo=/^[0-9a-zA-Z+/]*={0,2}$/,xs=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=mo),I.init(e,t),e._zod.check=r=>{zs(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),nr=/^[A-Za-z0-9_-]*$/;function Ip(e){if(!nr.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return zs(r)}var ys=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nr),I.init(e,t),e._zod.check=r=>{Ip(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),bs=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=mi),I.init(e,t)});function Np(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 ws=m("$ZodJWT",(e,t)=>{I.init(e,t),e._zod.check=r=>{Np(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ho=m("$ZodNumber",(e,t)=>{C.init(e,t),e._zod.pattern=ut,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 i=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),vs=m("$ZodNumberFormat",(e,t)=>{ki.init(e,t),ho.init(e,t)}),Ss=m("$ZodBoolean",(e,t)=>{C.init(e,t),e._zod.pattern=bi,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}}),$s=m("$ZodBigInt",(e,t)=>{C.init(e,t),e._zod.pattern=yi,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 ks=m("$ZodNull",(e,t)=>{C.init(e,t),e._zod.pattern=wi,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}}),Ps=m("$ZodAny",(e,t)=>{C.init(e,t),e._zod.parse=r=>r}),Os=m("$ZodUnknown",(e,t)=>{C.init(e,t),e._zod.parse=r=>r}),Rs=m("$ZodNever",(e,t)=>{C.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var Zs=m("$ZodDate",(e,t)=>{C.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,i=n instanceof Date;return i&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});function jp(e,t){let r=qt(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map(i=>i[0])),n=e._zod.parse;e._zod.parse=(i,s)=>{let c=t(i.value);if(c>o&&!s?.skipChecks&&s?.direction!=="backward"){for(let[a,u]of qt(e._zod.def.checks))if(c>a&&u._zod.def.when(i)){let p=i.issues.length;return u._zod.check(i),i.issues[p].continue=!1,st(i.issues,p,e),i}}return n(i,s)}}var Up=e=>Array.isArray(e)?e.length:-1;function Di(e,t,r){e.issues.length&&t.issues.push(..._e(r,e.issues)),t.value[r]=e.value}var Cs=m("$ZodArray",(e,t)=>{C.init(e,t);let r=Q.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),o;o.value=r?r.alloc(e,o,Array(i.length),n):Array(i.length);let s=[],c=n?.abortEarly;for(let a=0;a<i.length;a++){let u=i[a],p=t.element._zod.run({value:u,issues:[]},n);if(p instanceof Promise)s.push(p.then(f=>Di(f,o,a)));else if(Di(p,o,a),c&&p.issues.length!==0&&ae(p))break}return s.length?Promise.all(s).then(()=>o):o},jp(e,Up)});function rr(e,t,r,o,n,i){let s=r in o,c=i==="optional";if(!(!s&&c&&n==="optional")){if(e.issues.length){if(n!==void 0&&c&&!s)return;t.issues.push(..._e(r,e.issues))}if(!s&&n===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(s||n==="defaulted"&&!c)&&(t.value[r]=void 0):t.value[r]=e.value}}var Lp=[];function Es(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:Lp,n=o.length?[...t,...o]:t;for(let s of n)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Vr(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function As(e,t,r,o,n,i,s){let c=[],a=n.keySet,u=n.catchall._zod,p=u.def.type,f=u.optin,h=u.optout,d=0;for(let g in t){if(s&&r.issues.length!==d){if(ae(r,d))break;d=r.issues.length}if(a.has(g))continue;if(g==="__proto__"){p==="never"&&c.push(g);continue}if(p==="never"){c.push(g);continue}let b=u.run({value:t[g],issues:[]},o);b instanceof Promise?e.push(b.then(w=>rr(w,r,g,t,f,h))):rr(b,r,g,t,f,h)}return c.length&&r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Dp=m("$ZodObject",(e,t)=>{C.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let u=()=>{let p={...o};return Object.defineProperty(t,"shape",{value:p}),u.raw=p,p};u.raw=o,Object.defineProperty(t,"shape",{get:u})}let n=Me(()=>Es(t));R(e,"propValues",u=>{let p=u.def.shape,f={};for(let h in p){let d=p[h]._zod;if(d.values){Object.prototype.hasOwnProperty.call(f,h)||re(f,h,new Set);for(let g of d.values)f[h].add(g);d.optin!==void 0&&f[h].add(void 0)}}return f});let i=Re,s=t.catchall,c,a=Q.memoizer;a?.attach(e),e._zod.parse=(u,p)=>{c??(c=n.value);let f=u.value;if(!i(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=a?a.alloc(e,u,{},p):{};let h=[],d=c.shape,g=p?.abortEarly,b=u.issues.length;for(let w of c.allKeys){if(g&&u.issues.length!==b){if(ae(u,b))break;b=u.issues.length}if(w==="__proto__")continue;let P=d[w],B=P._zod.optin,de=P._zod.optout,fe=P._zod.run({value:f[w],issues:[]},p);fe instanceof Promise?h.push(fe.then(z=>rr(z,u,w,f,B,de))):rr(fe,u,w,f,B,de)}return s?As(h,f,u,p,n.value,e,g===!0):h.length?Promise.all(h).then(()=>u):u}}),Ts=m("$ZodObjectJIT",(e,t)=>{Dp.init(e,t);let r=e._zod.parse,o=Me(()=>Es(t)),n=Q.memoizer,i=d=>{let g=o.value,b=g.symbolKeys,w=new Qt(["payload","ctx"],{shape:d,inst:e,memo:n,syms:b}),P=z=>`shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`,B=(z,_)=>`
7
+ let ${z}_ab = false;
8
+ for (let i = 0; i < ${z}.issues.length; i++) {
9
+ const iss = ${z}.issues[i];
10
+ iss.path = iss.path ? [${_}, ...iss.path] : [${_}];
11
+ payload.issues.push(iss);
12
+ if (iss.continue !== true) ${z}_ab = true;
13
+ }
14
+ if (${z}_ab && ctx && ctx.abortEarly) {
15
+ payload.value = newResult;
16
+ return payload;
17
+ }`;w.write("const input = payload.value;");let de=Object.create(null),fe=0;for(let z of g.allKeys)de[z]=`key_${fe++}`;w.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let z of g.allKeys){if(z==="__proto__")continue;let _=de[z],k=typeof z=="symbol"?`syms[${b.indexOf(z)}]`:Br(z),L=`${k} in input`,O=d[z],W=O?._zod?.optin,tt=W!==void 0,Lt=O?._zod?.optout==="optional";if(w.write(`const ${_} = ${P(k)};`),tt&&Lt){let Ir=W==="optional"?`${_}_present`:`${_}.value !== undefined || ${_}_present`;w.write(`
18
+ const ${_}_present = ${L};
19
+ if (!${_}.issues.length || ${_}_present) {
20
+ if (${_}.issues.length) {${B(_,k)}
21
+ }
22
+
23
+ if (${Ir}) {
24
+ newResult[${k}] = ${_}.value;
25
+ }
26
+ }
27
+
28
+ `)}else tt?(w.write(`
29
+ if (${_}.issues.length) {${B(_,k)}
30
+ }
31
+ `),W==="defaulted"?w.write(`newResult[${k}] = ${_}.value;`):w.write(`
32
+ if (${_}.value !== undefined || ${L}) {
33
+ newResult[${k}] = ${_}.value;
34
+ }
35
+ `)):w.write(`
36
+ const ${_}_present = ${L};
37
+ if (${_}.issues.length) {${B(_,k)}
38
+ }
39
+ if (!${_}_present && !${_}.issues.length) {
40
+ payload.issues.push({
41
+ code: "invalid_type",
42
+ expected: "nonoptional",
43
+ input: undefined,
44
+ path: [${k}]
45
+ });
46
+ if (ctx && ctx.abortEarly) {
47
+ payload.value = newResult;
48
+ return payload;
49
+ }
50
+ }
51
+
52
+ if (${_}_present) {
53
+ newResult[${k}] = ${_}.value;
54
+ }
55
+
56
+ `)}return w.write("payload.value = newResult;"),w.write("return payload;"),w.compile()},s,c=Re,a=!Q.jitless,p=a&&qr.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=o.value);let b=d.value;return c(b)?a&&p&&g?.async===!1&&g.jitless!==!0?(s||(s=i(t.shape)),d=s(d,g),f?As([],b,d,g,h,e,g?.abortEarly===!0):d):r(d,g):(d.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),d)}});function Mi(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter(i=>!ae(i));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(i=>i.issues.map(s=>ue(s,o,ee())))}),t)}var go=m("$ZodUnion",(e,t)=>{C.init(e,t),R(e,"optin",o=>o.def.options.some(n=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some(n=>n._zod.optin!==void 0)?"optional":void 0),R(e,"optout",o=>o.def.options.some(n=>n._zod.optout==="optional")?"optional":void 0),R(e,"values",o=>{if(o.def.options.every(n=>n._zod.values))return new Set(o.def.options.flatMap(n=>Array.from(n._zod.values)))}),R(e,"pattern",o=>{if(o.def.options.every(n=>n._zod.pattern)){let n=o.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>nt(i.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 i=!1,s=[];for(let c of t.options){let a=c._zod.run({value:o.value,issues:[]},n);if(a instanceof Promise)s.push(a),i=!0;else{if(a.issues.length===0)return a;s.push(a)}}return i?Promise.all(s).then(c=>Mi(c,o,e,n)):Mi(s,o,e,n)}});function Mp(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw new Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var Is=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,go.init(e,t);let r=e._zod.parse;R(e,"propValues",n=>{let i={},s=0;for(let c of n.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${n.def.options.indexOf(c)}"`);a[n.def.discriminator]?.has(void 0)&&s++;for(let[u,p]of Object.entries(a)){Object.prototype.hasOwnProperty.call(i,u)||re(i,u,new Set);for(let f of p)i[u].add(f)}}return!n.def.unionFallback&&s>1&&i[n.def.discriminator]?.delete(void 0),i}),t.options.forEach((n,i)=>{let s=Fe(n._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});let o=Me(()=>Mp(t));e._zod.parse=(n,i)=>{let s=n.value;if(!Re(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let c=s?.[t.discriminator],a=o.value.get(c);return a&&(c!==void 0||i.direction!=="backward")?a._zod.run(n,i):t.unionFallback||i.direction==="backward"?r(n,i):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter(u=>o.value.get(u)!==null),input:s,path:[t.discriminator],inst:e}),n)}}),Ns=m("$ZodIntersection",(e,t)=>{C.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,u])=>Fi(r,a,u)):Fi(r,i,s)}});function po(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(Se(e)&&Se(t)){let r=Object.keys(t),o=Object.keys(e).filter(i=>r.indexOf(i)!==-1),n={...e,...t};Object.prototype.hasOwnProperty.call(n,"__proto__")&&delete n.__proto__;for(let i of o){if(i==="__proto__")continue;let s=po(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.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],i=t[o],s=po(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Fi(e,t,r){let o=new Map,n,i=new Map,s=(u,p)=>{let f;if(u.code==="unrecognized_keys"&&!u.path?.length)n??(n=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let h=String(u.path[0]);i.has(h)||i.set(h,u),f=[h]}else return!1;for(let h of f)o.has(h)||o.set(h,{}),o.get(h)[p]=!0;return!0};for(let u of t.issues)s(u,"l")||e.issues.push(u);for(let u of r.issues)s(u,"r")||e.issues.push(u);let c=[...o].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){let u=n?c.filter(p=>n.keys.includes(p)):[];u.length&&e.issues.push({...n,keys:u});for(let p of c)!u.includes(p)&&i.has(p)&&e.issues.push(i.get(p))}let a=po(t.value,r.value);if(!a.valid){if(ae(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var js=m("$ZodRecord",(e,t)=>{C.init(e,t);let r=Q.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Se(i))return o.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),o;let s=[],c=t.keyType._zod.values;if(c&&!t.partial){o.value=r?r.alloc(e,o,{},n):{};let a=new Set;for(let p of c)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){if(a.add(typeof p=="number"?p.toString():p),p==="__proto__")continue;let f=t.keyType._zod.run({value:p,issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(g=>ue(g,n,ee())),input:p,path:[p],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:i[p],issues:[]},n);d instanceof Promise?s.push(d.then(g=>{g.issues.length&&o.issues.push(..._e(p,g.issues)),o.value[h]=g.value})):(d.issues.length&&o.issues.push(..._e(p,d.issues)),o.value[h]=d.value)}let u;for(let p in i)if(!a.has(p))if(t.mode==="loose"){if(p==="__proto__")continue;o.value[p]=i[p]}else u=u??[],u.push(p);u&&u.length>0&&o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{o.value=r?r.alloc(e,o,{},n):{};let a;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let p=t.keyType._zod.run({value:u,issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&ut.test(u)&&p.issues.length){let g=t.keyType._zod.run({value:Number(u),issues:[]},n);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(p=g)}if(p.issues.length){t.mode==="loose"?o.value[u]=i[u]:c?(a=a??[],a.push(u)):o.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(g=>ue(g,n,ee())),input:u,path:[u],inst:e});continue}let h=p.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:i[u],issues:[]},n);d instanceof Promise?s.push(d.then(g=>{g.issues.length&&o.issues.push(..._e(u,g.issues)),o.value[h]=g.value})):(d.issues.length&&o.issues.push(..._e(u,d.issues)),o.value[h]=d.value)}a&&a.length>0&&o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a,continue:!0})}return s.length?Promise.all(s).then(()=>o):o}});var Us=m("$ZodEnum",(e,t)=>{C.init(e,t);let r=Le(t.entries),o=new Set(r);e._zod.values=o,R(e,"pattern",n=>{let i=Le(n.def.entries).filter(s=>Wr.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>ge(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,i)=>{let s=n.value;return o.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),Ls=m("$ZodLiteral",(e,t)=>{C.init(e,t);let r=new Set(t.values);e._zod.values=r,R(e,"pattern",o=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map(i=>typeof i=="string"?ge(i):i?ge(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}});var Ds=m("$ZodTransform",(e,t)=>{C.init(e,t),e._zod.optin="optional",Q.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Je(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(s=>(r.value=s,r));if(n instanceof Promise)throw new le;return r.value=n,r}});function Bi(e,t){return e.value=t.issues.length?void 0:t.value,e}var _o=m("$ZodOptional",(e,t)=>{C.init(e,t),R(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",R(e,"values",r=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),R(e,"pattern",r=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${nt(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);return n instanceof Promise?n.then(i=>Bi(r,i)):Bi(r,n)}return t.innerType._zod.run(r,o)}}),Ms=m("$ZodExactOptional",(e,t)=>{_o.init(e,t),R(e,"values",r=>r.def.innerType._zod.values),R(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Fs=m("$ZodNullable",(e,t)=>{C.init(e,t),R(e,"optin",r=>r.def.innerType._zod.optin),R(e,"optout",r=>r.def.innerType._zod.optout),R(e,"pattern",r=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${nt(o.source)}|null)$`):void 0}),R(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,o)}),Bs=m("$ZodDefault",(e,t)=>{C.init(e,t),e._zod.optin="defaulted",R(e,"values",r=>r.def.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(i=>Ji(i,t)):Ji(n,t)}});function Ji(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Js=m("$ZodPrefault",(e,t)=>{C.init(e,t),e._zod.optin="defaulted",R(e,"values",r=>r.def.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))}),qs=m("$ZodNonOptional",(e,t)=>{C.init(e,t),R(e,"values",r=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>qi(i,e)):qi(n,e)}});function qi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Wi(e,t,r,o){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(n=>ue(n,o,ee()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ws=m("$ZodCatch",(e,t)=>{C.init(e,t),R(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),R(e,"optout",r=>r.def.innerType._zod.optout),R(e,"values",r=>r.def.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({value:r.value,issues:[]},o);return n instanceof Promise?n.then(i=>Wi(r,i,t,o)):Wi(r,n,t,o)}});var zo=m("$ZodPipe",(e,t)=>{C.init(e,t),R(e,"values",r=>r.def.in._zod.values),R(e,"optin",r=>r.def.in._zod.optin),R(e,"optout",r=>r.def.out._zod.optout),R(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);return i instanceof Promise?i.then(s=>er(s,t.in,o)):er(i,t.in,o)}let n=t.in._zod.run(r,o);return n instanceof Promise?n.then(i=>er(i,t.out,o)):er(n,t.out,o)}});function er(e,t,r){return e.issues.some(o=>o.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Vs=m("$ZodPreprocess",(e,t)=>{zo.init(e,t)}),Ks=m("$ZodReadonly",(e,t)=>{C.init(e,t),R(e,"propValues",r=>r.def.innerType._zod.propValues),R(e,"values",r=>r.def.innerType._zod.values),R(e,"optin",r=>r.def.innerType?._zod?.optin),R(e,"optout",r=>r.def.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(Vi):Vi(n)}});function Vi(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Gs=m("$ZodCustom",(e,t)=>{V.init(e,t),C.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(i=>Ki(i,r,o,e));Ki(n,r,o,e)}});function Ki(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(Be(n))}}var yo=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},bo="~memo",Hs=[];function Xs(e){return e!==null&&typeof e=="object"}function xo(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Ys=new WeakMap,pt=0,cr=1,dt=2;function ar(e,t,r){let o=Ys.get(e);if(o!==void 0)return o?dt:pt;if(t.has(e))return dt;t.add(e);let n=pt,i=p=>{if(n!==dt&&p?._zod){let f=ar(p,t,r);f>n&&(n=f)}},s=(p,f)=>{let h=pt;for(let d of Reflect.ownKeys(p)){let g=Object.getOwnPropertyDescriptor(p,d);if(f&&!g.enumerable)continue;let b=g.get?cr:g.value?._zod?ar(g.value,t,r):pt;b>h&&(h=b)}return h},c=p=>{p>n&&(n=p)},a=e._zod.def,u=a.type;switch(u){case"object":{let p=Fe(a);c(p?s(p,!0):cr),i(a.catchall);break}case"array":i(a.element);break;case"tuple":for(let p of a.items)i(p);i(a.rest);break;case"record":case"map":i(a.keyType),i(a.valueType);break;case"set":i(a.valueType);break;case"union":for(let p of a.options)i(p);break;case"intersection":i(a.left),i(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(a.innerType);break;case"pipe":i(a.in),i(a.out);break;case"function":i(a.input),i(a.output);break;case"lazy":{let p=a._cachedInner??(r?e._zod.innerType:void 0);c(p?ar(p,t,!1):cr);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let p in a){let f=Object.getOwnPropertyDescriptor(a,p);if(!f||f.get)continue;let h=f.value;if(!(!h||typeof h!="object")){if(h._zod)i(h);else if(Array.isArray(h))for(let d of h)i(d)}}}return t.delete(e),Fp(e,n)}function Fp(e,t){return t!==cr&&Ys.set(e,t===dt),t}function Bp(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var ir,sr=[],Jp={alloc(e,t,r){let o=ir;if(!o)return r;ir=void 0;let n={value:r,issues:null};return o.set(t.value,n),sr.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,i)=>{if(i.direction!=="backward"&&qp(i,n.value))throw new yo;return r(n,i)};e._zod.parse=o,e._zod.run===r&&(e._zod.run=o)})},attach(e){var t;let r,o=!1,n,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,c=(a,u)=>{if(r===void 0){let P=ar(e,new Set,!1);if(P===pt)return e._zod.parse=s,e._zod.run===c&&(e._zod.run=s),s(a,u);P===dt||o?r=!0:o=!0}let p=a.value;if(!Xs(p))return s(a,u);let f=u[bo];f||(f={buckets:new WeakMap,backEdges:void 0},u[bo]=f);let h;n===u?h=i:(h=Bp(f,e),n=u,i=h);let d=h.get(p);if(d)return a.value=d.value,d.issues?d.issues.length&&a.issues.push(...xo(d.issues)):(a.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value)),a;ir=h;let g=sr.length,b=s(a,u);ir=void 0;let w=sr.length>g?sr.pop():void 0;return b instanceof Promise?b.then(P=>(w&&(w.issues=P.issues.length?xo(P.issues):Hs),P)):(w&&(w.issues=b.issues.length?xo(b.issues):Hs),b)};e._zod.parse=c,e._zod.run===s&&(e._zod.run=c)})}};function wo(){return Jp}function qp(e,t){let r=e[bo]?.backEdges;return r!==void 0&&Xs(t)&&r.has(t)}var Wp=()=>{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(i){return e[i]??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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):o[i]??i}return i=>{switch(i.code){case"invalid_type":{let s=n(i.expected),c=Gr(i.input),a=n(c,i.input);return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Ft(i.values[0])}`:`Invalid option: expected one of ${Dt(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${c.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;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]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Dt(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(c=>`'${c}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Qs(){return{localeError:Wp()}}var ec;var vo=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 tc(){return new vo}(ec=globalThis).__zod_globalRegistry??(ec.__zod_globalRegistry=tc());var $e=globalThis.__zod_globalRegistry;function ur(e){return e.checks&&(e.checks=[...e.checks]),e}function rc(e,t){return new e(ur({type:"string",...S(t)}))}function oc(e,t){return new e(ur({type:"string",coerce:!0,...S(t)}))}function nc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function ic(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function sc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function cc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function ac(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function uc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function So(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function lc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function pc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function dc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function fc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function mc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function hc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function gc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function _c(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function zc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function xc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function yc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function bc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function wc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function vc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function Sc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function lr(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function pr(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function dr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function fr(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function $c(e,t){return new e(ur({type:"number",checks:[],...S(t)}))}function kc(e,t){return new e(ur({type:"number",coerce:!0,checks:[],...S(t)}))}function Pc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function Oc(e,t){return new e({type:"boolean",...S(t)})}function Rc(e,t){return new e({type:"boolean",coerce:!0,...S(t)})}function Zc(e,t){return new e({type:"bigint",coerce:!0,...S(t)})}function Cc(e,t){return new e({type:"null",...S(t)})}function Ec(e){return new e({type:"any"})}function Ac(e){return new e({type:"unknown"})}function Tc(e,t){return new e({type:"never",...S(t)})}function Ic(e,t){return new e({type:"date",coerce:!0,...S(t)})}function We(e,t){return new uo({check:"less_than",...S(t),value:e,inclusive:!1})}function ze(e,t){return new uo({check:"less_than",...S(t),value:e,inclusive:!0})}function Ve(e,t){return new lo({check:"greater_than",...S(t),value:e,inclusive:!1})}function xe(e,t){return new lo({check:"greater_than",...S(t),value:e,inclusive:!0})}function ft(e,t){return new $i({check:"multiple_of",...S(t),value:e})}function mr(e,t){return new Pi({check:"max_length",...S(t),maximum:e})}function Ke(e,t){return new Oi({check:"min_length",...S(t),minimum:e})}function hr(e,t){return new Ri({check:"length_equals",...S(t),length:e})}function $o(e,t){return new Zi({check:"string_format",format:"regex",...S(t),pattern:e})}function ko(e){return new Ci({check:"string_format",format:"lowercase",...S(e)})}function Po(e){return new Ei({check:"string_format",format:"uppercase",...S(e)})}function Oo(e,t){return new Ai({check:"string_format",format:"includes",...S(t),includes:e})}function Ro(e,t){return new Ti({check:"string_format",format:"starts_with",...S(t),prefix:e})}function Zo(e,t){return new Ii({check:"string_format",format:"ends_with",...S(t),suffix:e})}function ke(e){return new Ni({check:"overwrite",tx:e})}function Co(e){return ke(t=>t.normalize(e))}function Eo(){return ke(e=>e.trim())}function Ao(){return ke(e=>e.toLowerCase())}function To(){return ke(e=>e.toUpperCase())}function Io(){return ke(e=>Jr(e))}function Nc(e,t,r){return new e({type:"array",element:t,...S(r)})}function jc(e,t,r){let o=S(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Uc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...S(r)})}function Lc(e,t){let r=Vp(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(Be(n,o.value,r._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Be(i))}},e(o.value,o)),t);return r}function Vp(e,t){let r=new V({check:"custom",...S(t)});return r._zod.check=e,r}function mt(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,o)&&re(e,o,r[o]);return e}function jo(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??$e,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function pe(e,t,r,o,n){let i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(n);return Object.assign(r,i),!0}function M(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,p);else{let h=s.schema,d=t.processors[n.type];if(!d)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);d(e,t,h,p)}let f=e._zod.parent;f&&(s.ref||(s.ref=f),M(f,t,p),t.seen.get(f).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&mt(s.schema,a),t.io==="input"&&Y(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((o=s.schema).default??(o.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Dc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Uo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let s of e.seen.entries()){let c=e.metadataRegistry.get(s[0])?.id;if(c){let a=o.get(c);if(a&&a!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,s[0])}}let n=s=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,h=e.external.uri??(g=>g);if(f)return{ref:h(f)};let d=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=d,{defId:d,ref:`${h("__shared")}#/${c}/${Dc(d)}`}}let a="#",u=`${a}/${c}/`;if(s[1]===r&&!s[1].schema.id)return{ref:a};let p=s[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+Dc(p)}},i=s=>{if(s[1].schema.$ref)return;let c=s[1],{ref:a,defId:u}=n(s);c.def={...c.schema},u&&(c.defId=u);let p=c.schema;for(let f in p)delete p[f];p.$ref=a};if(e.cycles==="throw")for(let s of e.seen.entries()){let c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
57
+
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}c.count>1&&e.reused==="ref"&&i(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Bc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!="object")return;Bc(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;r.includes(s)||r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Jc=new Set(["type","properties","required","additionalProperties"]),Mc=["oneOf","anyOf"];function Fc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function No(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let s in i)if(!Jc.has(s))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let c=[];for(let u of t){let p=u.properties?.[s]??Fc(u);p!=null&&(c.some(f=>JSON.stringify(f)===JSON.stringify(p))||c.push(p))}let a=c.length===1?c[0]:No(c)??{allOf:c};re(r,s,a)}for(let s of i.required??[])o.add(s)}let n={type:"object",properties:r};if(o.size&&(n.required=[...o]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let s of t){let c=Fc(s);c&&!i.some(a=>JSON.stringify(a)===JSON.stringify(c))&&i.push(c)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function Kp(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of Jc)if(n in e)return;let r=t.filter(n=>Mc.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=No(t);else{let n=r[0],i=Mc.find(a=>Array.isArray(n[a]));if(Object.keys(n).length!==1)return;let s=t.filter(a=>a!==n),c=n[i].map(a=>No([...s,a]));if(c.some(a=>!a))return;o={[i]:c}}o&&(delete e.allOf,mt(e,o))}function Lo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=c=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,p={...u},f=a.ref;if(a.ref=null,f){o(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(g)):mt(u,g),mt(u,p),c._zod.parent===f)for(let w in u)w==="$ref"||w==="allOf"||w in p||delete u[w];if(g.$ref&&d.def)for(let w in u)w==="$ref"||w==="allOf"||w in d.def&&JSON.stringify(u[w])===JSON.stringify(d.def[w])&&delete u[w]}let h=c._zod.parent;if(h&&h!==f){o(h);let d=e.seen.get(h);if(d?.schema.$ref&&(u.$ref=d.schema.$ref,d.def))for(let g in u)g==="$ref"||g==="allOf"||g in d.def&&JSON.stringify(u[g])===JSON.stringify(d.def[g])&&delete u[g]}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())Bc(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let u of[a.schema,a.def]){let p=u?.allOf;if(!Array.isArray(p))continue;let f=c.get(p);f?f.push(u):c.set(p,[u])}for(let a of e.intersections)for(let u of c.get(a)??[])Kp(u)}}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 c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}mt(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];a.def&&a.defId&&(a.def.id===a.defId&&delete a.def.id,re(s,a.defId,a.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?n.$defs=s:n.definitions=s);try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:ht(t,"input",e.processors),output:ht(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Y(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 Y(o.element,r);if(o.type==="set")return Y(o.valueType,r);if(o.type==="lazy")return Y(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"||o.type==="catch")return Y(o.innerType,r);if(o.type==="intersection")return Y(o.left,r)||Y(o.right,r);if(o.type==="record"||o.type==="map")return Y(o.keyType,r)||Y(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Y(o.in,r)||Y(o.out,r);if(o.type==="object"){for(let n in o.shape)if(Y(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(Y(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(Y(n,r))return!0;return!!(o.rest&&Y(o.rest,r))}return!1}var qc=(e,t={})=>r=>{let o=jo({...r,processors:t});return M(e,o),Uo(o,e),Lo(o,e)},ht=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},s=jo({...n??{},target:i,io:t,processors:r});return M(e,s),Uo(s,e),Lo(s,e)};var Ge=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},He=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Wc=(e,t)=>{Ge(e,"minimum",t),He(e,"maximum",t)},Hc=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Xc=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Yc=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Qc=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Vc=(e,t)=>Ge(e,"minimum",t.minimum),Kc=(e,t)=>He(e,"maximum",t.maximum),Gc=e=>(t,r)=>{Qc(t,r.format);let[o,n]=e[r.format];Ge(t,"minimum",o),He(t,"maximum",n)},Gp={greater_than:(e,t)=>Ge(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>He(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Hc(e,t.value),number_format:Gc(it),bigint_format:Gc(Bt),min_length:Vc,max_length:Kc,length_equals:(e,t)=>Wc(e,t.length),min_size:Vc,max_size:Kc,size_equals:(e,t)=>Wc(e,t.size),string_format:(e,t)=>{Qc(e,t.format),t.pattern&&Xc(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Yc(e,t.mime)};function K(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)Gp[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&Ge(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&Ge(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&He(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&He(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&Hc(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&Yc(t,n.mime);for(let i of n.patterns??[])Xc(t,i);return t}var Hp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xp=new Map([[mo,pi],[nr,di]]),ea=e=>Xp.get(e)??e,ta=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:c,patterns:a,contentEncoding:u,laxFormat:p}=K(e);if(typeof i=="number"&&(n.minLength=i),typeof s=="number"&&(n.maxLength=s),c&&(n.format=Hp[c]??c,n.format===""&&delete n.format,(c==="time"||p)&&delete n.format),u&&(n.contentEncoding=u),a&&a.size>0){let f=[...a].map(ea);f.length===1?n.pattern=f[0].source:f.length>1&&(n.allOf=[...f.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},ra=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:u,isInt:p}=K(e);n.type=p?"integer":"number";let f=typeof u=="number"&&u>=(i??Number.NEGATIVE_INFINITY),h=typeof a=="number"&&a<=(s??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f?d?(n.minimum=u,n.exclusiveMinimum=!0):n.exclusiveMinimum=u:typeof i=="number"&&(n.minimum=i),h?d?(n.maximum=a,n.exclusiveMaximum=!0):n.exclusiveMaximum=a:typeof s=="number"&&(n.maximum=s),c){let g=new Set;for(let P of c)Number.isFinite(P)&&P!==0?g.add(Math.abs(P)):pe(e,t,n,o,`A multipleOf divisor of ${P} cannot be represented in JSON Schema`);let[b,...w]=g;b!==void 0&&(n.multipleOf=b),w.length&&(n.allOf=[...n.allOf??[],...w.map(P=>({multipleOf:P}))])}},oa=(e,t,r,o)=>{r.type="boolean"},na=(e,t,r,o)=>{pe(e,t,r,o,"BigInt cannot be represented in JSON Schema")};var ia=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var sa=(e,t,r,o)=>{r.not={}},ca=(e,t,r,o)=>{},aa=(e,t,r,o)=>{},ua=(e,t,r,o)=>{pe(e,t,r,o,"Date cannot be represented in JSON Schema")},la=(e,t,r,o)=>{let n=e._zod.def,i=Le(n.entries);if(i.length===0){r.not={};return}i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},pa=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let s of n.values)if(s===void 0){if(pe(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(pe(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){let s=i[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),i.every(s=>typeof s=="boolean")&&(r.type="boolean"),i.every(s=>s===null)&&(r.type="null"),r.enum=i};var da=(e,t,r,o)=>{pe(e,t,r,o,"Custom types cannot be represented in JSON Schema")};var fa=(e,t,r,o)=>{pe(e,t,r,o,"Transforms cannot be represented in JSON Schema")};var ma=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:c}=K(e);typeof s=="number"&&(n.minItems=s),typeof c=="number"&&(n.maxItems=c),n.type="array",n.items=M(i.element,t,{...o,path:[...o.path,"items"]})};function gr(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?gr(t.out):t.type==="catch"?gr(t.innerType):e._zod.optin}var ha=(e,t,r,o)=>{let n=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&pe(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let u in s)re(n.properties,u,M(s[u],t,{...o,path:[...o.path,"properties",u]}));let a=[];for(let u of Object.keys(s)){let p=i.shape[u];(t.io==="input"?gr(p)===void 0:p._zod.optout===void 0)&&a.push(u)}a.length>0&&(n.required=a),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=M(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},ga=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((c,a)=>M(c,t,{...o,path:[...o.path,i?"oneOf":"anyOf",a]}));i?r.oneOf=s:r.anyOf=s},_a=(e,t,r,o)=>{let n=e._zod.def,i=M(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=M(n.right,t,{...o,path:[...o.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];r.allOf=a,t.intersections.push(a)};function Do(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let b=Do(e,g,r);return b===g?t:b}for(let g of["anyOf","oneOf"]){let b=t[g];if(!Array.isArray(b))continue;let w=b.map(P=>Do(e,P,r));w.some((P,B)=>P!==b[B])&&(t={...t,[g]:w})}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:s,maximum:c,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:p,format:f,id:h,...d}=t;return d.enum?d.enum=d.enum.map(g=>typeof g=="number"?String(g):g):typeof d.const=="number"&&(d.const=String(d.const)),n&&(d.type="string",i||(d.pattern=(o.includes("number")?ut:co).source)),d}var Mo=new WeakMap;function Yp(e){let t=new Map;for(let o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);let r=new Map;for(let o of Mo.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Do(t,i,new Set);s!==i&&r.set(i,s)}if(r.size)for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var za=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=K(s).patterns;if(i.mode==="loose"&&c&&c.size>0){let p=M(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)re(n.patternProperties,ea(f).source,p)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=M(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let p=Mo.get(t);p||(p=[],Mo.set(t,p),t.deferred.push(()=>Yp(t))),p.push(e)}n.additionalProperties=M(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let a=s._zod.values,u=t.io==="input"&&gr(i.valueType)!==void 0;if(a&&!i.partial&&!u){let p=[...a].filter(f=>typeof f=="string"||typeof f=="number");p.length>0&&(n.required=p.map(String))}},xa=(e,t,r,o)=>{let n=e._zod.def,i=M(n.innerType,t,o),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},ya=(e,t,r,o)=>{let n=e._zod.def;M(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Fo=Symbol();function ba(e,t,r,o,n){let i=!1,s=JSON.stringify(e,(c,a)=>typeof a!="bigint"?a:(i=!0,null));return i?(pe(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),Fo):JSON.parse(s)}var wa=(e,t,r,o)=>{let n=e._zod.def;M(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s=ba(n.defaultValue,e,t,r,o);s!==Fo&&(r.default=s)},va=(e,t,r,o)=>{let n=e._zod.def;M(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let s=ba(n.defaultValue,e,t,r,o);s!==Fo&&(r._prefault=s)},Sa=(e,t,r,o)=>{let n=e._zod.def;M(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{pe(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},$a=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;M(s,t,o);let c=t.seen.get(e);c.ref=s},ka=(e,t,r,o)=>{let n=e._zod.def;M(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0};var Bo=(e,t,r,o)=>{let n=e._zod.def;M(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType};var Pa=new WeakSet([Object.prototype,Error.prototype]);function _r(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var cd=(e,t)=>{Dn.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Pa.has(r)||(Pa.add(r),_r(r,"format",o=>n=>ro(o,n)),_r(r,"flatten",o=>n=>to(o,n)),_r(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,De,2)}),_r(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,De,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var oe=m("ZodError",cd,void 0,{Parent:Error});var Oa=Kt(oe),Ra=Gt(oe),Za=Ht(oe),Ca=Xt(oe),Ea=Fn(oe),Aa=Bn(oe),Ta=Jn(oe),Ia=qn(oe),Na=Wn(oe),ja=Vn(oe),Ua=Kn(oe),La=Gn(oe);function ud(){Q.localeError||ee(Qs())}function xr(){Q.memoizer||ee({memoizer:wo()})}var E=m("ZodType",(e,t)=>(ud(),C.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone($.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ie(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Hd(e,t))},superRefine(e,t){return this.check(Xd(e,t))},overwrite(e){return this.check(ke(e))},optional(){return U(this)},exactOptional(){return Ud(this)},nullable(){return Fa(this)},nullish(){return U(Fa(this))},nonoptional(e){return Jd(this,e)},array(){return x(this)},or(e){return N([this,e])},and(e){return br(this,e)},transform(e){return Ba(this,Qa(e))},default(e){return Md(this,e)},prefault(e){return Bd(this,e)},catch(e){return Wd(this,e)},pipe(e){return Ba(this,e)},readonly(){return Gd(this)},describe(e){let t=this.clone();return $e.add(t,{description:e}),t},meta(...e){if(e.length===0)return $e.get(this);let t=this.clone();return $e.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return $.hide(this,"~standard",{...fo(this),jsonSchema:{input:ht(this,"input"),output:ht(this,"output")}})},set"~standard"(e){$.own(this,"~standard",e)},parse:function e(t,r){return Oa(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Ra(this,t,r,{callee:e})},safeParse(e,t){return Za(this,e,t)},async safeParseAsync(e,t){return Ca(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){$.own(this,"spa",e)},validate(e,t){return oo(this,e,t)},validateAsync(e,t){return no(this,e,t)},encode:function e(t,r){return Ea(this,t,r,{callee:e})},decode:function e(t,r){return Aa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Ta(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ia(this,t,r,{callee:e})},safeEncode(e,t){return Na(this,e,t)},safeDecode(e,t){return ja(this,e,t)},async safeEncodeAsync(e,t){return Ua(this,e,t)},async safeDecodeAsync(e,t){return La(this,e,t)},toJSONSchema(e){return qc(this,{})(e)},get description(){return $e.get(this)?.description},get _def(){return this._zod.def}}),Ja=m("_ZodString",(e,t)=>{or.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ta(e,r,o,n)},$.derived({format:e=>K(e).format??null,minLength:e=>K(e).minimum??null,maxLength:e=>K(e).maximum??null},{regex(...e){return this.check($o(...e))},includes(...e){return this.check(Oo(...e))},startsWith(...e){return this.check(Ro(...e))},endsWith(...e){return this.check(Zo(...e))},min(...e){return this.check(Ke(...e))},max(...e){return this.check(mr(...e))},length(...e){return this.check(hr(...e))},nonempty(...e){return this.check(Ke(1,...e))},lowercase(e){return this.check(ko(e))},uppercase(e){return this.check(Po(e))},trim(){return this.check(Eo())},normalize(...e){return this.check(Co(...e))},toLowerCase(){return this.check(Ao())},toUpperCase(){return this.check(To())},slugify(){return this.check(Io())}})),qo=m("ZodString",(e,t)=>{or.init(e,t),Ja.init(e,t)},{email(e){return this.check(nc(ld,e))},url(e){return this.check(So(qa,e))},jwt(e){return this.check(Sc(kd,e))},emoji(e){return this.check(lc(dd,e))},guid(e){return this.check(ic(pd,e))},uuid(e){return this.check(sc(zr,e))},uuidv4(e){return this.check(cc(zr,e))},uuidv6(e){return this.check(ac(zr,e))},uuidv7(e){return this.check(uc(zr,e))},nanoid(e){return this.check(pc(fd,e))},cuid(e){return this.check(dc(md,e))},cuid2(e){return this.check(fc(hd,e))},ulid(e){return this.check(mc(gd,e))},base64(e){return this.check(bc(vd,e))},base64url(e){return this.check(wc(Sd,e))},xid(e){return this.check(hc(_d,e))},ksuid(e){return this.check(gc(zd,e))},ipv4(e){return this.check(_c(xd,e))},ipv6(e){return this.check(zc(yd,e))},cidrv4(e){return this.check(xc(bd,e))},cidrv6(e){return this.check(yc(wd,e))},e164(e){return this.check(vc($d,e))},datetime(e){return this.check(lr(gt,e))},date(e){return this.check(pr(_t,e))},time(e){return this.check(dr(zt,e))},duration(e){return this.check(fr(xt,e))}});function l(e){return rc(qo,e)}var D=m("ZodStringFormat",(e,t)=>{I.init(e,t),Ja.init(e,t)}),gt=m("ZodISODateTime",(e,t)=>{us.init(e,t),D.init(e,t)}),_t=m("ZodISODate",(e,t)=>{ls.init(e,t),D.init(e,t)}),zt=m("ZodISOTime",(e,t)=>{ps.init(e,t),D.init(e,t)}),xt=m("ZodISODuration",(e,t)=>{ds.init(e,t),D.init(e,t)}),ld=m("ZodEmail",(e,t)=>{Yi.init(e,t),D.init(e,t)});var pd=m("ZodGUID",(e,t)=>{Hi.init(e,t),D.init(e,t)});var zr=m("ZodUUID",(e,t)=>{Xi.init(e,t),D.init(e,t)});var qa=m("ZodURL",(e,t)=>{ts.init(e,t),D.init(e,t)});function Wa(e){return So(qa,e)}var dd=m("ZodEmoji",(e,t)=>{rs.init(e,t),D.init(e,t)});var fd=m("ZodNanoID",(e,t)=>{os.init(e,t),D.init(e,t)});var md=m("ZodCUID",(e,t)=>{ns.init(e,t),D.init(e,t)});var hd=m("ZodCUID2",(e,t)=>{is.init(e,t),D.init(e,t)});var gd=m("ZodULID",(e,t)=>{ss.init(e,t),D.init(e,t)});var _d=m("ZodXID",(e,t)=>{cs.init(e,t),D.init(e,t)});var zd=m("ZodKSUID",(e,t)=>{as.init(e,t),D.init(e,t)});var xd=m("ZodIPv4",(e,t)=>{fs.init(e,t),D.init(e,t)});var yd=m("ZodIPv6",(e,t)=>{hs.init(e,t),D.init(e,t)});var bd=m("ZodCIDRv4",(e,t)=>{gs.init(e,t),D.init(e,t)});var wd=m("ZodCIDRv6",(e,t)=>{_s.init(e,t),D.init(e,t)});var vd=m("ZodBase64",(e,t)=>{xs.init(e,t),D.init(e,t)});var Sd=m("ZodBase64URL",(e,t)=>{ys.init(e,t),D.init(e,t)});var $d=m("ZodE164",(e,t)=>{bs.init(e,t),D.init(e,t)});var kd=m("ZodJWT",(e,t)=>{ws.init(e,t),D.init(e,t)});var yr=m("ZodNumber",(e,t)=>{ho.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ra(e,r,o,n),e.isFinite=!0},$.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=K(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=K(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=K(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>K(e).format??null},{gt(e,t){return this.check(Ve(e,t))},gte(e,t){return this.check(xe(e,t))},min(e,t){return this.check(xe(e,t))},lt(e,t){return this.check(We(e,t))},lte(e,t){return this.check(ze(e,t))},max(e,t){return this.check(ze(e,t))},int(e){return this.check(Da(e))},safe(e){return this.check(Da(e))},positive(e){return this.check(Ve(0,e))},nonnegative(e){return this.check(xe(0,e))},negative(e){return this.check(We(0,e))},nonpositive(e){return this.check(ze(0,e))},multipleOf(e,t){return this.check(ft(e,t))},step(e,t){return this.check(ft(e,t))},finite(){return this}}));function Z(e){return $c(yr,e)}var Pd=m("ZodNumberFormat",(e,t)=>{vs.init(e,t),yr.init(e,t)});function Da(e){return Pc(Pd,e)}var Wo=m("ZodBoolean",(e,t)=>{Ss.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oa(e,r,o,n)});function A(e){return Oc(Wo,e)}var Va=m("ZodBigInt",(e,t)=>{$s.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>na(e,r,o,n)},$.derived({minValue:e=>K(e).minimum??null,maxValue:e=>K(e).maximum??null,format:e=>K(e).format??null},{gte(e,t){return this.check(xe(e,t))},min(e,t){return this.check(xe(e,t))},gt(e,t){return this.check(Ve(e,t))},lt(e,t){return this.check(We(e,t))},lte(e,t){return this.check(ze(e,t))},max(e,t){return this.check(ze(e,t))},positive(e){return this.check(Ve(BigInt(0),e))},negative(e){return this.check(We(BigInt(0),e))},nonpositive(e){return this.check(ze(BigInt(0),e))},nonnegative(e){return this.check(xe(BigInt(0),e))},multipleOf(e,t){return this.check(ft(e,t))}}));var Od=m("ZodNull",(e,t)=>{ks.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ia(e,r,o,n)});function Ka(e){return Cc(Od,e)}var Rd=m("ZodAny",(e,t)=>{Ps.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ca(e,r,o,n)});function Ga(){return Ec(Rd)}var Zd=m("ZodUnknown",(e,t)=>{Os.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>aa(e,r,o,n)});function j(){return Ac(Zd)}var Cd=m("ZodNever",(e,t)=>{Rs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sa(e,r,o,n)});function Ed(e){return Tc(Cd,e)}var Ha=m("ZodDate",(e,t)=>{Zs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ua(e,r,o,n),e.min=(r,o)=>e.check(xe(r,o)),e.max=(r,o)=>e.check(ze(r,o))},$.derived({minDate:e=>{let{minimum:t}=K(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=K(e);return t?new Date(t):null}},{}));var Ad=m("ZodArray",(e,t)=>{xr(),Cs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ma(e,r,o,n),e.element=t.element},{min(e,t){return this.check(Ke(e,t))},nonempty(e){return this.check(Ke(1,e))},max(e,t){return this.check(mr(e,t))},length(e,t){return this.check(hr(e,t))},unwrap(){return this.element}});function x(e,t){return Nc(Ad,e,t)}var Xa=m("ZodObject",(e,t)=>{xr(),Ts.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ha(e,r,o,n),$.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return te(Object.keys(this._zod.def.shape))},catchall(e){return this.clone($.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone($.mergeDefs(this._zod.def,{catchall:j()}))},loose(){return this.clone($.mergeDefs(this._zod.def,{catchall:j()}))},strict(){return this.clone($.mergeDefs(this._zod.def,{catchall:Ed()}))},strip(){return this.clone($.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return $.extend(this,e)},safeExtend(e){return $.safeExtend(this,e)},merge(e){return $.merge(this,e)},pick(e){return $.pick(this,e)},omit(e){return $.omit(this,e)},partial(...e){return $.partial(eu,this,e[0])},exactPartial(...e){return $.partial(tu,this,e[0],"exactPartial")},required(...e){return $.required(ru,this,e[0])}});function y(e,t){let r={type:"object",shape:e??{},...$.normalizeParams(t)};return new Xa(r)}function J(e,t){return new Xa({type:"object",shape:e,catchall:j(),...$.normalizeParams(t)})}var Ya=m("ZodUnion",(e,t)=>{go.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ga(e,r,o,n),e.options=t.options});function N(e,t){return new Ya({type:"union",options:e,...$.normalizeParams(t)})}var Td=m("ZodDiscriminatedUnion",(e,t)=>{Ya.init(e,t),Is.init(e,t)});function Vo(e,t,r){return new Td({type:"union",options:t,discriminator:e,...$.normalizeParams(r)})}var Id=m("ZodIntersection",(e,t)=>{Ns.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_a(e,r,o,n)});function br(e,t){return new Id({type:"intersection",left:e,right:t})}var Ma=m("ZodRecord",(e,t)=>{xr(),js.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>za(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function T(e,t,r){return!t||!t._zod?new Ma({type:"record",keyType:l(),valueType:e,...$.normalizeParams(t)}):new Ma({type:"record",keyType:e,valueType:t,...$.normalizeParams(r)})}var Jo=m("ZodEnum",(e,t)=>{Us.init(e,t),E.init(e,t),e._zod.processJSONSchema=(o,n,i)=>la(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Jo({...t,checks:[],...$.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Jo({...t,checks:[],...$.normalizeParams(n),entries:i})}});function te(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Jo({type:"enum",entries:r,...$.normalizeParams(t)})}var Nd=m("ZodLiteral",(e,t)=>{Ls.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pa(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 v(e,t){return new Nd({type:"literal",values:Array.isArray(e)?e:[e],...$.normalizeParams(t)})}var jd=m("ZodTransform",(e,t)=>{xr(),Ds.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fa(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Je(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push($.issue(i,r.value,t));else{let s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=e),r.issues.push($.issue(s))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function Qa(e){return new jd({type:"transform",transform:e})}var eu=m("ZodOptional",(e,t)=>{_o.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function U(e){return new eu({type:"optional",innerType:e})}var tu=m("ZodExactOptional",(e,t)=>{Ms.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ud(e){return new tu({type:"optional",innerType:e})}var Ld=m("ZodNullable",(e,t)=>{Fs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xa(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Fa(e){return new Ld({type:"nullable",innerType:e})}var Dd=m("ZodDefault",(e,t)=>{Bs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wa(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Md(e,t){return new Dd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var Fd=m("ZodPrefault",(e,t)=>{Js.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>va(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Bd(e,t){return new Fd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var ru=m("ZodNonOptional",(e,t)=>{qs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ya(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Jd(e,t){return new ru({type:"nonoptional",innerType:e,...$.normalizeParams(t)})}var qd=m("ZodCatch",(e,t)=>{Ws.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Sa(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wd(e,t){return new qd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:$.constantCatch(t)})}var ou=m("ZodPipe",(e,t)=>{zo.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$a(e,r,o,n),e.in=t.in,e.out=t.out});function Ba(e,t){return new ou({type:"pipe",in:e,out:t})}var Vd=m("ZodPreprocess",(e,t)=>{ou.init(e,t),Vs.init(e,t)}),Kd=m("ZodReadonly",(e,t)=>{Ks.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ka(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Gd(e){return new Kd({type:"readonly",innerType:e})}var nu=m("ZodCustom",(e,t)=>{Gs.init(e,t),E.init(e,t),e._zod.processJSONSchema=(r,o,n)=>da(e,r,o,n)});function iu(e,t){return jc(nu,e??(()=>!0),t)}function Hd(e,t={}){return Uc(nu,e,t)}function Xd(e,t){return Lc(e,t)}function Ko(e,t){return new Vd({type:"pipe",in:Qa(e),out:t})}var cu={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 su;su||(su={});var wr={};jr(wr,{ZodISODate:()=>_t,ZodISODateTime:()=>gt,ZodISODuration:()=>xt,ZodISOTime:()=>zt,date:()=>ef,datetime:()=>Qd,duration:()=>rf,time:()=>tf});function Qd(e){return lr(gt,e)}function ef(e){return pr(_t,e)}function tf(e){return dr(zt,e)}function rf(e){return fr(xt,e)}var vr={};jr(vr,{bigint:()=>cf,boolean:()=>sf,date:()=>af,number:()=>nf,string:()=>of});function of(e){return oc(qo,e)}function nf(e){return kc(yr,e)}function sf(e){return Rc(Wo,e)}function cf(e){return Zc(Va,e)}function af(e){return Ic(Ha,e)}var Go="2025-11-25";var lf="io.modelcontextprotocol/related-task",$r="2.0",q=iu(e=>e!==null&&(typeof e=="object"||typeof e=="function")),uu=N([l(),Z().int()]),lu=l(),Rz=J({ttl:Z().optional(),pollInterval:Z().optional()}),pf=y({ttl:Z().optional()}),df=y({taskId:l()}),Ho=J({progressToken:uu.optional(),[lf]:df.optional()}),ne=y({_meta:Ho.optional()}),kr=ne.extend({task:pf.optional()});var G=y({method:l(),params:ne.loose().optional()}),se=y({_meta:Ho.optional()}),ce=y({method:l(),params:se.loose().optional()}),H=J({_meta:Ho.optional()}),Pr=N([l(),Z().int()]),pu=y({jsonrpc:v($r),id:Pr,...G.shape}).strict(),du=e=>pu.safeParse(e).success,ff=y({jsonrpc:v($r),...ce.shape}).strict();var Xo=y({jsonrpc:v($r),id:Pr,result:H}).strict(),fu=e=>Xo.safeParse(e).success;var au;(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"})(au||(au={}));var mu=y({jsonrpc:v($r),id:Pr.optional(),error:y({code:Z().int(),message:l(),data:j().optional()})}).strict();var Qe=N([pu,ff,Xo,mu]),Zz=N([Xo,mu]),hu=H.strict(),mf=se.extend({requestId:Pr.optional(),reason:l().optional()}),gu=ce.extend({method:v("notifications/cancelled"),params:mf}),hf=y({src:l(),mimeType:l().optional(),sizes:x(l()).optional(),theme:te(["light","dark"]).optional()}),yt=y({icons:x(hf).optional()}),Ye=y({name:l(),title:l().optional()}),_u=Ye.extend({...Ye.shape,...yt.shape,version:l(),websiteUrl:l().optional(),description:l().optional()}),gf=br(y({applyDefaults:A().optional()}),T(l(),j())),_f=Ko(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,br(y({form:gf.optional(),url:q.optional()}),T(l(),j()).optional())),zf=J({list:q.optional(),cancel:q.optional(),requests:J({sampling:J({createMessage:q.optional()}).optional(),elicitation:J({create:q.optional()}).optional()}).optional()}),xf=J({list:q.optional(),cancel:q.optional(),requests:J({tools:J({call:q.optional()}).optional()}).optional()}),yf=y({experimental:T(l(),q).optional(),sampling:y({context:q.optional(),tools:q.optional()}).optional(),elicitation:_f.optional(),roots:y({listChanged:A().optional()}).optional(),tasks:zf.optional(),extensions:T(l(),q).optional()}),bf=ne.extend({protocolVersion:l(),capabilities:yf,clientInfo:_u}),wf=G.extend({method:v("initialize"),params:bf});var vf=y({experimental:T(l(),q).optional(),logging:q.optional(),completions:q.optional(),prompts:y({listChanged:A().optional()}).optional(),resources:y({subscribe:A().optional(),listChanged:A().optional()}).optional(),tools:y({listChanged:A().optional()}).optional(),tasks:xf.optional(),extensions:T(l(),q).optional()}),Sf=H.extend({protocolVersion:l(),capabilities:vf,serverInfo:_u,instructions:l().optional()}),zu=ce.extend({method:v("notifications/initialized"),params:se.optional()}),xu=e=>zu.safeParse(e).success,yu=G.extend({method:v("ping"),params:ne.optional()}),$f=y({progress:Z(),total:U(Z()),message:U(l())}),kf=y({...se.shape,...$f.shape,progressToken:uu}),bu=ce.extend({method:v("notifications/progress"),params:kf}),Pf=ne.extend({cursor:lu.optional()}),bt=G.extend({params:Pf.optional()}),wt=H.extend({nextCursor:lu.optional()}),Of=te(["working","input_required","completed","failed","cancelled"]),vt=y({taskId:l(),status:Of,ttl:N([Z(),Ka()]),createdAt:l(),lastUpdatedAt:l(),pollInterval:U(Z()),statusMessage:U(l())}),wu=H.extend({task:vt}),Rf=se.merge(vt),vu=ce.extend({method:v("notifications/tasks/status"),params:Rf}),Su=G.extend({method:v("tasks/get"),params:ne.extend({taskId:l()})}),$u=H.merge(vt),ku=G.extend({method:v("tasks/result"),params:ne.extend({taskId:l()})}),Cz=H.loose(),Pu=bt.extend({method:v("tasks/list")}),Ou=wt.extend({tasks:x(vt)}),Ru=G.extend({method:v("tasks/cancel"),params:ne.extend({taskId:l()})}),Ez=H.merge(vt),Zu=y({uri:l(),mimeType:U(l()),_meta:T(l(),j()).optional()}),Cu=Zu.extend({text:l()}),Yo=l().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Eu=Zu.extend({blob:Yo}),St=te(["user","assistant"]),et=y({audience:x(St).optional(),priority:Z().min(0).max(1).optional(),lastModified:wr.datetime({offset:!0}).optional()}),Au=y({...Ye.shape,...yt.shape,uri:l(),description:U(l()),mimeType:U(l()),size:U(Z()),annotations:et.optional(),_meta:U(J({}))}),Zf=y({...Ye.shape,...yt.shape,uriTemplate:l(),description:U(l()),mimeType:U(l()),annotations:et.optional(),_meta:U(J({}))}),Cf=bt.extend({method:v("resources/list")}),Ef=wt.extend({resources:x(Au)}),Af=bt.extend({method:v("resources/templates/list")}),Tf=wt.extend({resourceTemplates:x(Zf)}),Qo=ne.extend({uri:l()}),If=Qo,Nf=G.extend({method:v("resources/read"),params:If}),jf=H.extend({contents:x(N([Cu,Eu]))}),Uf=ce.extend({method:v("notifications/resources/list_changed"),params:se.optional()}),Lf=Qo,Df=G.extend({method:v("resources/subscribe"),params:Lf}),Mf=Qo,Ff=G.extend({method:v("resources/unsubscribe"),params:Mf}),Bf=se.extend({uri:l()}),Jf=ce.extend({method:v("notifications/resources/updated"),params:Bf}),qf=y({name:l(),description:U(l()),required:U(A())}),Wf=y({...Ye.shape,...yt.shape,description:U(l()),arguments:U(x(qf)),_meta:U(J({}))}),Vf=bt.extend({method:v("prompts/list")}),Kf=wt.extend({prompts:x(Wf)}),Gf=ne.extend({name:l(),arguments:T(l(),l()).optional()}),Hf=G.extend({method:v("prompts/get"),params:Gf}),en=y({type:v("text"),text:l(),annotations:et.optional(),_meta:T(l(),j()).optional()}),tn=y({type:v("image"),data:Yo,mimeType:l(),annotations:et.optional(),_meta:T(l(),j()).optional()}),rn=y({type:v("audio"),data:Yo,mimeType:l(),annotations:et.optional(),_meta:T(l(),j()).optional()}),Xf=y({type:v("tool_use"),name:l(),id:l(),input:T(l(),j()),_meta:T(l(),j()).optional()}),Yf=y({type:v("resource"),resource:N([Cu,Eu]),annotations:et.optional(),_meta:T(l(),j()).optional()}),Qf=Au.extend({type:v("resource_link")}),on=N([en,tn,rn,Qf,Yf]),em=y({role:St,content:on}),tm=H.extend({description:l().optional(),messages:x(em)}),rm=ce.extend({method:v("notifications/prompts/list_changed"),params:se.optional()}),om=y({title:l().optional(),readOnlyHint:A().optional(),destructiveHint:A().optional(),idempotentHint:A().optional(),openWorldHint:A().optional()}),nm=y({taskSupport:te(["required","optional","forbidden"]).optional()}),Tu=y({...Ye.shape,...yt.shape,description:l().optional(),inputSchema:y({type:v("object"),properties:T(l(),q).optional(),required:x(l()).optional()}).catchall(j()),outputSchema:y({type:v("object"),properties:T(l(),q).optional(),required:x(l()).optional()}).catchall(j()).optional(),annotations:om.optional(),execution:nm.optional(),_meta:T(l(),j()).optional()}),im=bt.extend({method:v("tools/list")}),sm=wt.extend({tools:x(Tu)}),Iu=H.extend({content:x(on).default([]),structuredContent:T(l(),j()).optional(),isError:A().optional()}),Az=Iu.or(H.extend({toolResult:j()})),cm=kr.extend({name:l(),arguments:T(l(),j()).optional()}),am=G.extend({method:v("tools/call"),params:cm}),um=ce.extend({method:v("notifications/tools/list_changed"),params:se.optional()}),Tz=y({autoRefresh:A().default(!0),debounceMs:Z().int().nonnegative().default(300)}),Nu=te(["debug","info","notice","warning","error","critical","alert","emergency"]),lm=ne.extend({level:Nu}),pm=G.extend({method:v("logging/setLevel"),params:lm}),dm=se.extend({level:Nu,logger:l().optional(),data:j()}),fm=ce.extend({method:v("notifications/message"),params:dm}),mm=y({name:l().optional()}),hm=y({hints:x(mm).optional(),costPriority:Z().min(0).max(1).optional(),speedPriority:Z().min(0).max(1).optional(),intelligencePriority:Z().min(0).max(1).optional()}),gm=y({mode:te(["auto","required","none"]).optional()}),_m=y({type:v("tool_result"),toolUseId:l().describe("The unique identifier for the corresponding tool call."),content:x(on).default([]),structuredContent:y({}).loose().optional(),isError:A().optional(),_meta:T(l(),j()).optional()}),zm=Vo("type",[en,tn,rn]),Sr=Vo("type",[en,tn,rn,Xf,_m]),xm=y({role:St,content:N([Sr,x(Sr)]),_meta:T(l(),j()).optional()}),ym=kr.extend({messages:x(xm),modelPreferences:hm.optional(),systemPrompt:l().optional(),includeContext:te(["none","thisServer","allServers"]).optional(),temperature:Z().optional(),maxTokens:Z().int(),stopSequences:x(l()).optional(),metadata:q.optional(),tools:x(Tu).optional(),toolChoice:gm.optional()}),bm=G.extend({method:v("sampling/createMessage"),params:ym}),wm=H.extend({model:l(),stopReason:U(te(["endTurn","stopSequence","maxTokens"]).or(l())),role:St,content:zm}),vm=H.extend({model:l(),stopReason:U(te(["endTurn","stopSequence","maxTokens","toolUse"]).or(l())),role:St,content:N([Sr,x(Sr)])}),Sm=y({type:v("boolean"),title:l().optional(),description:l().optional(),default:A().optional()}),$m=y({type:v("string"),title:l().optional(),description:l().optional(),minLength:Z().optional(),maxLength:Z().optional(),format:te(["email","uri","date","date-time"]).optional(),default:l().optional()}),km=y({type:te(["number","integer"]),title:l().optional(),description:l().optional(),minimum:Z().optional(),maximum:Z().optional(),default:Z().optional()}),Pm=y({type:v("string"),title:l().optional(),description:l().optional(),enum:x(l()),default:l().optional()}),Om=y({type:v("string"),title:l().optional(),description:l().optional(),oneOf:x(y({const:l(),title:l()})),default:l().optional()}),Rm=y({type:v("string"),title:l().optional(),description:l().optional(),enum:x(l()),enumNames:x(l()).optional(),default:l().optional()}),Zm=N([Pm,Om]),Cm=y({type:v("array"),title:l().optional(),description:l().optional(),minItems:Z().optional(),maxItems:Z().optional(),items:y({type:v("string"),enum:x(l())}),default:x(l()).optional()}),Em=y({type:v("array"),title:l().optional(),description:l().optional(),minItems:Z().optional(),maxItems:Z().optional(),items:y({anyOf:x(y({const:l(),title:l()}))}),default:x(l()).optional()}),Am=N([Cm,Em]),Tm=N([Rm,Zm,Am]),Im=N([Tm,Sm,$m,km]),Nm=kr.extend({mode:v("form").optional(),message:l(),requestedSchema:y({type:v("object"),properties:T(l(),Im),required:x(l()).optional()})}),jm=kr.extend({mode:v("url"),message:l(),elicitationId:l(),url:l().url()}),Um=N([Nm,jm]),Lm=G.extend({method:v("elicitation/create"),params:Um}),Dm=se.extend({elicitationId:l()}),Mm=ce.extend({method:v("notifications/elicitation/complete"),params:Dm}),Fm=H.extend({action:te(["accept","decline","cancel"]),content:Ko(e=>e===null?void 0:e,T(l(),N([l(),Z(),A(),x(l())])).optional())}),Bm=y({type:v("ref/resource"),uri:l()});var Jm=y({type:v("ref/prompt"),name:l()}),qm=ne.extend({ref:N([Jm,Bm]),argument:y({name:l(),value:l()}),context:y({arguments:T(l(),l()).optional()}).optional()}),Wm=G.extend({method:v("completion/complete"),params:qm});var Vm=H.extend({completion:J({values:x(l()).max(100),total:U(Z().int()),hasMore:U(A())})}),Km=y({uri:l().startsWith("file://"),name:l().optional(),_meta:T(l(),j()).optional()}),Gm=G.extend({method:v("roots/list"),params:ne.optional()}),Hm=H.extend({roots:x(Km)}),Xm=ce.extend({method:v("notifications/roots/list_changed"),params:se.optional()}),Iz=N([yu,wf,Wm,pm,Hf,Vf,Cf,Af,Nf,Df,Ff,am,im,Su,ku,Pu,Ru]),Nz=N([gu,bu,zu,Xm,vu]),jz=N([hu,wm,vm,Fm,Hm,$u,Ou,wu]),Uz=N([yu,bm,Lm,Gm,Su,ku,Pu,Ru]),Lz=N([gu,bu,fm,Jf,Uf,um,rm,vu,Mm]),Dz=N([hu,Sf,Vm,tm,Kf,Ef,Tf,jf,Iu,sm,$u,Ou,wu]);var Ym=10*1024*1024,Or=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??Ym}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
59
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),Qm(r)}clear(){this._buffer=void 0}};function Qm(e){return Qe.parse(JSON.parse(e))}function ju(e){return JSON.stringify(e)+`
60
+ `}var Rr=class{constructor(t=Uu.stdin,r=Uu.stdout,o){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(i){this.onerror?.(i),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new Or({maxBufferSize:o?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let o=ju(t);this._stdout.write(o)?r():this._stdout.once("drain",r)})}};var Bu=Sl(Fu(),1);function Ju(e){if(e)try{return Bu.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Zr(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function qu(e=fetch,t){return t?async(r,o)=>{let n={...t,...o,headers:o?.headers?{...Zr(t.headers),...Zr(o.headers)}:t.headers};return e(r,n)}:e}var ah=5,uh=[301,302,303,307,308];function lh(e,t){return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port?!0:e.hostname===t.hostname&&e.protocol==="http:"&&e.port===""&&t.protocol==="https:"&&t.port===""}function Wu(e,t){let r=uh.includes(e.status)?e.headers.get("location"):null;try{return r?new URL(r,t):void 0}catch{return}}function Cr(e,t,r,o,n=0){let i=Wu(o,t),s=o.status===307||o.status===308||(r?.method??"GET").toUpperCase()==="GET";if(!i||n===ah||!s)return;let c=new URL(t);if(!((i.username||i.password)&&(i.username!==c.username||i.password!==c.password)||!lh(c,i)))return Promise.resolve(o.body?.cancel()).then(()=>e(i,{...r,redirect:"manual"})).then(u=>Cr(e,i,r,u,n+1)??u)}var Vu=new WeakSet;function sn(e){let t=(r,o)=>(e??fetch)(r,o);return Vu.add(t),t}function Ze(e=fetch){return Vu.has(e)?e:(t,r)=>r?.redirect==="error"||r?.redirect==="manual"?e(t,r):Promise.resolve(e(t,{...r,redirect:"manual"})).then(o=>Cr(e,t,r,o)??o)}function Er(e,t){if(e.type==="opaqueredirect")return"Redirect not followed: this runtime does not expose the redirect target";let r=e.url||t,o=Wu(e,r);if(o)return o.username=o.password=o.search=o.hash="",o.protocol==="http:"&&new URL(r).protocol==="https:"?(o.protocol="https:",`Redirect to plain http not followed; try ${o.href} instead`):`Redirect to ${o.href} not followed`}var cn;cn=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function ph(e){return(await cn).getRandomValues(new Uint8Array(e))}async function dh(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,o="";for(;o.length<e;){let n=await ph(e-o.length);for(let i of n)i<r&&(o+=t[i%t.length])}return o}async function fh(e){return await dh(e)}async function mh(e){let t=await(await cn).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function an(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await fh(e),r=await mh(t);return{code_verifier:t,code_challenge:r}}var X=Wa().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:cu.custom,message:"URL must be parseable",fatal:!0}),Yr}).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"}),Gu=J({resource:l().url(),authorization_servers:x(X).optional(),jwks_uri:l().url().optional(),scopes_supported:x(l()).optional(),bearer_methods_supported:x(l()).optional(),resource_signing_alg_values_supported:x(l()).optional(),resource_name:l().optional(),resource_documentation:l().optional(),resource_policy_uri:l().url().optional(),resource_tos_uri:l().url().optional(),tls_client_certificate_bound_access_tokens:A().optional(),authorization_details_types_supported:x(l()).optional(),dpop_signing_alg_values_supported:x(l()).optional(),dpop_bound_access_tokens_required:A().optional()}),un=J({issuer:l(),authorization_endpoint:X,token_endpoint:X,registration_endpoint:X.optional(),scopes_supported:x(l()).optional(),response_types_supported:x(l()),response_modes_supported:x(l()).optional(),grant_types_supported:x(l()).optional(),token_endpoint_auth_methods_supported:x(l()).optional(),token_endpoint_auth_signing_alg_values_supported:x(l()).optional(),service_documentation:X.optional(),revocation_endpoint:X.optional(),revocation_endpoint_auth_methods_supported:x(l()).optional(),revocation_endpoint_auth_signing_alg_values_supported:x(l()).optional(),introspection_endpoint:l().optional(),introspection_endpoint_auth_methods_supported:x(l()).optional(),introspection_endpoint_auth_signing_alg_values_supported:x(l()).optional(),code_challenge_methods_supported:x(l()).optional(),client_id_metadata_document_supported:A().optional()}),hh=J({issuer:l(),authorization_endpoint:X,token_endpoint:X,userinfo_endpoint:X.optional(),jwks_uri:X,registration_endpoint:X.optional(),scopes_supported:x(l()).optional(),response_types_supported:x(l()),response_modes_supported:x(l()).optional(),grant_types_supported:x(l()).optional(),acr_values_supported:x(l()).optional(),subject_types_supported:x(l()),id_token_signing_alg_values_supported:x(l()),id_token_encryption_alg_values_supported:x(l()).optional(),id_token_encryption_enc_values_supported:x(l()).optional(),userinfo_signing_alg_values_supported:x(l()).optional(),userinfo_encryption_alg_values_supported:x(l()).optional(),userinfo_encryption_enc_values_supported:x(l()).optional(),request_object_signing_alg_values_supported:x(l()).optional(),request_object_encryption_alg_values_supported:x(l()).optional(),request_object_encryption_enc_values_supported:x(l()).optional(),token_endpoint_auth_methods_supported:x(l()).optional(),token_endpoint_auth_signing_alg_values_supported:x(l()).optional(),display_values_supported:x(l()).optional(),claim_types_supported:x(l()).optional(),claims_supported:x(l()).optional(),service_documentation:l().optional(),claims_locales_supported:x(l()).optional(),ui_locales_supported:x(l()).optional(),claims_parameter_supported:A().optional(),request_parameter_supported:A().optional(),request_uri_parameter_supported:A().optional(),require_request_uri_registration:A().optional(),op_policy_uri:X.optional(),op_tos_uri:X.optional(),client_id_metadata_document_supported:A().optional()}),Hu=y({...hh.shape,...un.pick({code_challenge_methods_supported:!0}).shape}),Xu=y({access_token:l(),id_token:l().optional(),token_type:l(),expires_in:vr.number().optional(),scope:l().optional(),refresh_token:l().optional(),issuer:l().optional().catch(void 0)}).strip(),Yu=y({error:l(),error_description:l().optional(),error_uri:l().optional()}),Ku=X.optional().or(v("").transform(()=>{})),gh=y({redirect_uris:x(X),token_endpoint_auth_method:l().optional(),grant_types:x(l()).optional(),response_types:x(l()).optional(),client_name:l().optional(),client_uri:X.optional(),logo_uri:Ku,scope:l().optional(),contacts:x(l()).optional(),tos_uri:Ku,policy_uri:l().optional(),jwks_uri:X.optional(),jwks:Ga().optional(),software_id:l().optional(),software_version:l().optional(),software_statement:l().optional()}).strip(),_h=y({client_id:l(),client_secret:l().optional(),client_id_issued_at:Z().optional(),client_secret_expires_at:Z().optional(),issuer:l().optional().catch(void 0)}).strip(),Qu=gh.merge(_h),Xz=y({error:l(),error_description:l().optional()}).strip(),Yz=y({token:l(),token_type_hint:l().optional()}).strip();function el(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function tl({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+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(i)}var F=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}},$t=class extends F{};$t.errorCode="invalid_request";var Ce=class extends F{};Ce.errorCode="invalid_client";var Ee=class extends F{};Ee.errorCode="invalid_grant";var Ae=class extends F{};Ae.errorCode="unauthorized_client";var kt=class extends F{};kt.errorCode="unsupported_grant_type";var Pt=class extends F{};Pt.errorCode="invalid_scope";var Ot=class extends F{};Ot.errorCode="access_denied";var ye=class extends F{};ye.errorCode="server_error";var Rt=class extends F{};Rt.errorCode="temporarily_unavailable";var Zt=class extends F{};Zt.errorCode="unsupported_response_type";var Ct=class extends F{};Ct.errorCode="unsupported_token_type";var Et=class extends F{};Et.errorCode="invalid_token";var At=class extends F{};At.errorCode="method_not_allowed";var Tt=class extends F{};Tt.errorCode="too_many_requests";var Te=class extends F{};Te.errorCode="invalid_client_metadata";var It=class extends F{};It.errorCode="insufficient_scope";var Nt=class extends F{};Nt.errorCode="invalid_target";var rl={[$t.errorCode]:$t,[Ce.errorCode]:Ce,[Ee.errorCode]:Ee,[Ae.errorCode]:Ae,[kt.errorCode]:kt,[Pt.errorCode]:Pt,[Ot.errorCode]:Ot,[ye.errorCode]:ye,[Rt.errorCode]:Rt,[Zt.errorCode]:Zt,[Ct.errorCode]:Ct,[Et.errorCode]:Et,[At.errorCode]:At,[Tt.errorCode]:Tt,[Te.errorCode]:Te,[It.errorCode]:It,[Nt.errorCode]:Nt};var be=class extends Error{constructor(t){super(t??"Unauthorized")}};function zh(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var ln="code",pn="S256";function xh(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&zh(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 yh(e,t,r,o){let{client_id:n,client_secret:i}=t;switch(e){case"client_secret_basic":bh(n,i,r);return;case"client_secret_post":wh(n,i,o);return;case"none":vh(n,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function bh(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 wh(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function vh(e,t){t.set("client_id",e)}async function nl(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let o=Yu.parse(JSON.parse(r)),{error:n,error_description:i,error_uri:s}=o,c=rl[n]||ye;return new c(i||"",s)}catch(o){let n=e instanceof Response?Er(e,e.url):void 0,i=`${t?`HTTP ${t}: `:""}${n??`Invalid OAuth error response: ${o}. Raw body: ${r}`}`;return new ye(i)}}function Sh(e,t){let[r,o]=[e,t];try{[r,o]=[new URL(e).href,new URL(t).href]}catch{}return r===o||r.endsWith("/")&&r.slice(0,-1)===o||o.endsWith("/")&&o.slice(0,-1)===r}function mn(e,t){if(e)return typeof e.issuer!="string"?e.issuer==null?e:{...e,issuer:void 0}:Sh(e.issuer,t)?e:void 0}var $h=Xu.omit({issuer:!0}),kh=Qu.omit({issuer:!0});function il(e,t){return new Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function jt(e,t){try{return await dn(e,t)}catch(r){if(r instanceof Ce||r instanceof Ae)return await e.invalidateCredentials?.("all"),await dn(e,t);if(r instanceof Ee)return await e.invalidateCredentials?.("tokens"),await dn(e,t);throw r}}async function dn(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:i}){let s=await e.discoveryState?.(),c,a,u,p=n;if(!p&&s?.resourceMetadataUrl&&(p=new URL(s.resourceMetadataUrl)),s?.authorizationServerUrl){if(a=s.authorizationServerUrl,c=s.resourceMetadata,u=s.authorizationServerMetadata??await cl(a,{fetchFn:i}),!c)try{c=await sl(t,{resourceMetadataUrl:p},i)}catch{}(u!==s.authorizationServerMetadata||c!==s.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(a),resourceMetadataUrl:p?.toString(),resourceMetadata:c,authorizationServerMetadata:u})}else{let O=await Ah(t,{resourceMetadataUrl:p,fetchFn:i});a=O.authorizationServerUrl,u=O.authorizationServerMetadata,c=O.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(a),resourceMetadataUrl:p?.toString(),resourceMetadata:c,authorizationServerMetadata:u})}let f=String(a),h=await Oh(t,e,c),d=h&&c&&!e.validateResourceURL?c.resource:h,g=o||c?.scopes_supported?.join(" ")||e.clientMetadata.scope,b=await Promise.resolve(e.clientInformation()),w=mn(b,f),P=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(b&&!w&&!P)throw il(b,f);let B=w?.issuer==null?w:void 0,de=async()=>{try{B&&await e.saveClientInformation?.({...B,issuer:f})}catch{}};if(!w){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let O=u?.client_id_metadata_document_supported===!0,W=e.clientMetadataUrl;if(W&&!Ph(W))throw new Te(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${W}`);if(O&&W)w={client_id:W,issuer:f},await e.saveClientInformation?.(w);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");w={...await Uh(a,{metadata:u,clientMetadata:e.clientMetadata,scope:g,fetchFn:i}),issuer:f},await e.saveClientInformation(w)}}let fe=!e.redirectUrl;if(r!==void 0||fe){let O=await jh(e,a,{metadata:u,resource:d,authorizationCode:r,fetchFn:i});return await de(),await e.saveTokens({...O,issuer:f}),"AUTHORIZED"}let z=mn(await e.tokens(),f);if(z?.refresh_token&&z.issuer==null&&console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged."),z?.refresh_token)try{let O=await Nh(a,{metadata:u,clientInformation:w,refreshToken:z.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await de(),await e.saveTokens({...O,issuer:f}),"AUTHORIZED"}catch(O){if(!(!(O instanceof F)||O instanceof ye))throw O}let _=e.state?await e.state():void 0,{authorizationUrl:k,codeVerifier:L}=await Th(a,{metadata:u,clientInformation:w,state:_,redirectUrl:e.redirectUrl,scope:g,resource:d});return await e.saveCodeVerifier(L),await e.redirectToAuthorization(k),"REDIRECT"}function Ph(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function Oh(e,t,r){let o=el(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!tl({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 hn(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,o]=t.split(" ");if(r.toLowerCase()!=="bearer"||!o)return{};let n=fn(e,"resource_metadata")||void 0,i;if(n)try{i=new URL(n)}catch{}let s=fn(e,"scope")||void 0,c=fn(e,"error")||void 0;return{resourceMetadataUrl:i,scope:s,error:c}}function fn(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 sl(e,t,r=fetch){let o=await Ch(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 Gu.parse(await o.json())}async function gn(e,t,r=fetch){try{return await Ze(r)(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?gn(e,void 0,r):void 0;throw o}}function Rh(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function ol(e,t,r=fetch){return await gn(e,{"MCP-Protocol-Version":t},r)}function Zh(e,t){return!e||!e.ok&&e.status<500&&t!=="/"}async function Ch(e,t,r,o){let n=new URL(e),i=o?.protocolVersion??Go,s;if(o?.metadataUrl)s=new URL(o.metadataUrl);else{let a=Rh(t,n.pathname);s=new URL(a,o?.metadataServerUrl??n),s.search=n.search}let c=await ol(s,i,r);if(!o?.metadataUrl&&Zh(c,n.pathname)){let a=new URL(`/.well-known/${t}`,n);c=await ol(a,i,r)}return c}function Eh(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 cl(e,{fetchFn:t=fetch,protocolVersion:r=Go}={}){let o={"MCP-Protocol-Version":r,Accept:"application/json"},n=Eh(e);for(let{url:i,type:s}of n){let c=await gn(i,o,t);if(c){if(!c.ok){if(await c.body?.cancel(),c.status<500)continue;throw new Error(`HTTP ${c.status} trying to load ${s==="oauth"?"OAuth":"OpenID provider"} metadata from ${i}`)}return s==="oauth"?un.parse(await c.json()):Hu.parse(await c.json())}}}async function Ah(e,t){let r,o;try{r=await sl(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 cl(o,{fetchFn:t?.fetchFn});return{authorizationServerUrl:o,authorizationServerMetadata:n,resourceMetadata:r}}function al(e){return typeof e=="string"?e:e.href}async function Th(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,state:i,resource:s}){let c;if(t){if(c=new URL(t.authorization_endpoint),!t.response_types_supported.includes(ln))throw new Error(`Incompatible auth server: does not support response type ${ln}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(pn))throw new Error(`Incompatible auth server: does not support code challenge method ${pn}`)}else c=new URL("/authorize",e);let a=await an(),u=a.code_verifier,p=a.code_challenge;return c.searchParams.set("response_type",ln),c.searchParams.set("client_id",r.client_id),c.searchParams.set("code_challenge",p),c.searchParams.set("code_challenge_method",pn),c.searchParams.set("redirect_uri",String(o)),i&&c.searchParams.set("state",i),n&&c.searchParams.set("scope",n),n?.includes("offline_access")&&c.searchParams.append("prompt","consent"),s&&c.searchParams.set("resource",al(s)),{authorizationUrl:c,codeVerifier:u}}function Ih(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function ul(e,{metadata:t,tokenRequestParams:r,clientInformation:o,addClientAuthentication:n,resource:i,fetchFn:s}){let c=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),a=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(i&&r.set("resource",al(i)),n)await n(a,r,c,t);else if(o){let p=t?.token_endpoint_auth_methods_supported??[],f=xh(o,p);yh(f,o,a,r)}let u=await Ze(s??fetch)(c,{method:"POST",headers:a,body:r});if(!u.ok)throw await nl(u);return $h.parse(await u.json())}async function Nh(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,addClientAuthentication:i,fetchFn:s}){let c=new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),a=await ul(e,{metadata:t,tokenRequestParams:c,clientInformation:r,addClientAuthentication:i,resource:n,fetchFn:s});return{refresh_token:o,...a}}async function jh(e,t,{metadata:r,resource:o,authorizationCode:n,fetchFn:i}={}){let s=async()=>{let p=await e.clientInformation(),f=mn(p,String(t));if(p&&!f)throw il(p,String(t));return f},c=await s(),a=e.clientMetadata.scope,u;if(e.prepareTokenRequest&&(u=await e.prepareTokenRequest(a)),!u){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 p=await e.codeVerifier();u=Ih(n,p,e.redirectUrl)}return c??(c=await s()),ul(t,{metadata:r,tokenRequestParams:u,clientInformation:c,addClientAuthentication:e.addClientAuthentication,resource:o,fetchFn:i})}async function Uh(e,{metadata:t,clientMetadata:r,scope:o,fetchFn:n}){let i;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");i=new URL(t.registration_endpoint)}else i=new URL("/register",e);let s=await Ze(n??fetch)(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...o!==void 0?{scope:o}:{}})});if(!s.ok)throw await nl(s);return kh.parse(await s.json())}var Ut=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}},ll=10,Lh=13,Ie=32;function _n(e){}function fl(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=_n,onError:r=_n,onRetry:o=_n,onComment:n,maxBufferSize:i}=e,s=[],c=0,a=!0,u,p="",f=0,h,d=!1;function g(z){if(d)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(a&&(a=!1,z.charCodeAt(0)===239&&z.charCodeAt(1)===187&&z.charCodeAt(2)===191&&(z=z.slice(3))),s.length===0){let L=w(z);L!==""&&(s.push(L),c=L.length),b();return}if(z.indexOf(`
61
+ `)===-1&&z.indexOf("\r")===-1){s.push(z),c+=z.length,b();return}s.push(z);let _=s.join("");s.length=0,c=0;let k=w(_);k!==""&&(s.push(k),c=k.length),b()}function b(){i!==void 0&&(c+p.length<=i||(d=!0,s.length=0,c=0,u=void 0,p="",f=0,h=void 0,r(new Ut(`Buffered data exceeded max buffer size of ${i} characters`,{type:"max-buffer-size-exceeded"}))))}function w(z){let _=0;if(z.indexOf("\r")===-1){let k=z.indexOf(`
62
+ `,_);for(;k!==-1;){if(_===k){f>0&&t({id:u,event:h,data:p}),u=void 0,p="",f=0,h=void 0,_=k+1,k=z.indexOf(`
63
+ `,_);continue}let L=z.charCodeAt(_);if(pl(z,_,L)){let O=z.charCodeAt(_+5)===Ie?_+6:_+5,W=z.slice(O,k);if(f===0&&z.charCodeAt(k+1)===ll){t({id:u,event:h,data:W}),u=void 0,p="",h=void 0,_=k+2,k=z.indexOf(`
64
+ `,_);continue}p=f===0?W:`${p}
65
+ ${W}`,f++}else dl(z,_,L)?h=z.slice(z.charCodeAt(_+6)===Ie?_+7:_+6,k)||void 0:P(z,_,k);_=k+1,k=z.indexOf(`
66
+ `,_)}return z.slice(_)}for(;_<z.length;){let k=z.indexOf("\r",_),L=z.indexOf(`
67
+ `,_),O=-1;if(k!==-1&&L!==-1?O=k<L?k:L:k!==-1?k===z.length-1?O=-1:O=k:L!==-1&&(O=L),O===-1)break;P(z,_,O),_=O+1,z.charCodeAt(_-1)===Lh&&z.charCodeAt(_)===ll&&_++}return z.slice(_)}function P(z,_,k){if(_===k){de();return}let L=z.charCodeAt(_);if(pl(z,_,L)){let Ne=z.charCodeAt(_+5)===Ie?_+6:_+5,xn=z.slice(Ne,k);p=f===0?xn:`${p}
68
+ ${xn}`,f++;return}if(dl(z,_,L)){h=z.slice(z.charCodeAt(_+6)===Ie?_+7:_+6,k)||void 0;return}if(L===105&&z.charCodeAt(_+1)===100&&z.charCodeAt(_+2)===58){let Ne=z.slice(z.charCodeAt(_+3)===Ie?_+4:_+3,k);u=Ne.includes("\0")?void 0:Ne;return}if(L===58){if(n){let Ne=z.slice(_,k);n(Ne.slice(z.charCodeAt(_+1)===Ie?2:1))}return}let O=z.slice(_,k),W=O.indexOf(":");if(W===-1){B(O,"",O);return}let tt=O.slice(0,W),Lt=O.charCodeAt(W+1)===Ie?2:1,Ir=O.slice(W+Lt);B(tt,Ir,O)}function B(z,_,k){switch(z){case"event":h=_||void 0;break;case"data":p=f===0?_:`${p}
69
+ ${_}`,f++;break;case"id":u=_.includes("\0")?void 0:_;break;case"retry":/^\d+$/.test(_)?o(parseInt(_,10)):r(new Ut(`Invalid \`retry\` value: "${_}"`,{type:"invalid-retry",value:_,line:k}));break;default:r(new Ut(`Unknown field "${z.length>20?`${z.slice(0,20)}\u2026`:z}"`,{type:"unknown-field",field:z,value:_,line:k}));break}}function de(){f>0&&t({id:u,event:h,data:p}),u=void 0,p="",f=0,h=void 0}function fe(z={}){if(z.consume&&s.length>0){let _=s.join("");P(_,0,_.length)}a=!0,u=void 0,p="",f=0,h=void 0,s.length=0,c=0,d=!1}return{feed:g,reset:fe}}function pl(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 dl(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 Ar=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:o,maxBufferSize:n}={}){let i;super({start(s){i=fl({onEvent:c=>{s.enqueue(c)},onError(c){typeof t=="function"&&t(c),(t==="terminate"||c.type==="max-buffer-size-exceeded")&&s.error(c)},onRetry:r,onComment:o,maxBufferSize:n})},transform(s){i.feed(s)}})}};var Dh={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Pe=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Tr=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=qu(r?.fetch,r?.requestInit),this._followRedirects=r?.redirectPolicy==="follow",this._followRedirects&&(this._fetch=sn(this._fetch),this._fetchWithInit=sn(this._fetchWithInit)),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??Dh}_unfollowedRedirect(t,r){let o=Er(t,r);return o&&!this._followRedirects?`${o} (redirectPolicy: 'same-origin')`:o}async _authThenStart(){if(!this._authProvider)throw new be("No auth provider");let t;try{t=await jt(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 be;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=Zr(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=this._fetch??fetch,i={method:"GET",headers:o,signal:this._abortController?.signal},s=await n(this._url,this._followRedirects?i:{...i,redirect:"manual"}),c=this._followRedirects?void 0:Cr(n,this._url,i,s);if(c&&(s=await c),!s.ok){if(await s.body?.cancel(),s.status===401&&this._authProvider)return await this._authThenStart();if(s.status===405)return;throw new Pe(s.status,`Failed to open SSE stream: ${this._unfollowedRedirect(s,this._url)??s.statusText}`)}this._handleSseStream(s.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(i=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${i instanceof Error?i.message:String(i)}`)),this._scheduleReconnection(t,r+1)})},n)}_handleSseStream(t,r,o){if(!t)return;let{onresumptiontoken:n,replayMessageId:i}=r,s,c=!1,a=!1;(async()=>{try{let p=t.pipeThrough(new TextDecoderStream).pipeThrough(new Ar({onRetry:d=>{this._serverRetryMs=d}})).getReader();for(;;){let{value:d,done:g}=await p.read();if(g)break;if(d.id&&(s=d.id,c=!0,n?.(d.id)),!!d.data&&(!d.event||d.event==="message"))try{let b=Qe.parse(JSON.parse(d.data));fu(b)&&(a=!0,i!==void 0&&(b.id=i)),this.onmessage?.(b)}catch(b){this.onerror?.(b)}}(o||c)&&!a&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:i},0)}catch(p){if(this.onerror?.(new Error(`SSE stream disconnected: ${p}`)),(o||c)&&!a&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:i},0)}catch(d){this.onerror?.(new Error(`Failed to reconnect: ${d instanceof Error?d.message:String(d)}`))}}})()}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 be("No auth provider");if(await jt(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new be("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:du(t)?t.id:void 0}).catch(d=>this.onerror?.(d));return}let i=await this._commonHeaders();i.set("content-type","application/json"),i.set("accept","application/json, text/event-stream");let s={...this._requestInit,method:"POST",headers:i,body:JSON.stringify(t),signal:this._abortController?.signal},c=await Ze(this._fetch??fetch)(this._url,s),a=c.headers.get("mcp-session-id");if(a&&(this._sessionId=a),!c.ok){let d=await c.text().catch(()=>null);if(c.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Pe(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:b}=hn(c);if(this._resourceMetadataUrl=g,this._scope=b,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new be;return this._hasCompletedAuthFlow=!0,this.send(t)}if(c.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:b,error:w}=hn(c);if(w==="insufficient_scope"){let P=c.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===P)throw new Pe(403,"Server returned 403 after trying upscoping");if(b&&(this._scope=b),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=P??void 0,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new be;return this.send(t)}}throw new Pe(c.status,`Error POSTing to endpoint: ${this._unfollowedRedirect(c,this._url)??d}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,c.status===202){await c.body?.cancel(),xu(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(d=>this.onerror?.(d));return}let p=(Array.isArray(t)?t:[t]).filter(d=>"method"in d&&"id"in d&&d.id!==void 0).length>0,f=c.headers.get("content-type"),h=Ju(f);if(p)if(h==="text/event-stream")this._handleSseStream(c.body,{onresumptiontoken:n},!1);else if(h==="application/json"){let d=await c.json(),g=Array.isArray(d)?d.map(b=>Qe.parse(b)):[Qe.parse(d)];for(let b of g)this.onmessage?.(b)}else throw await c.body?.cancel(),new Pe(-1,`Unexpected content type: ${f}`);else await c.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 Ze(this._fetch??fetch)(this._url,r);if(await o.body?.cancel(),!o.ok&&o.status!==405)throw new Pe(o.status,`Failed to terminate session: ${this._unfollowedRedirect(o,this._url)??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 Mh="https://aigora-prd-mcp-vfl5n4ujkq-ey.a.run.app/mcp";function zn(e,t=process.env){return(e||t.AIGORA_MCP_URL||Mh).trim()}function ml(e){try{let t=new URL(e);return t.username="",t.password="",t.search="",t.hash="",t.href}catch{return"(invalid URL)"}}var Fh=new Set(["localhost","127.0.0.1","[::1]"]);async function hl(e={}){let t=e.env??process.env,r;try{r=new URL(zn(e.url,t))}catch{throw new Error("The MCP URL is not a valid URL")}if(r.protocol!=="https:"&&r.protocol!=="http:")throw new Error("The MCP URL must be https:// (or http:// to localhost)");if(r.username||r.password)throw new Error("The MCP URL must not contain a username or password");let o=e.apiKey??t.AIGORA_API_KEY??null;if(o&&!/^[A-Za-z0-9_-]+$/.test(o))throw new Error('AIGORA_API_KEY may contain only letters, digits, "_" and "-"');if(o&&r.protocol!=="https:"&&!Fh.has(r.hostname))throw new Error("AIGORA_API_KEY needs an https:// MCP URL (plain http only to localhost)");let n=h=>{let d=h?.code;return`request failed${Number.isInteger(d)&&d>=100&&d<=599?` (HTTP ${d})`:""}`},i=e.onError??((h,d)=>console.error(`[aigora-mcp] ${h}: ${n(d)}`)),s=o?{headers:{authorization:`Bearer ${o}`}}:void 0,c=e.makeLocal?e.makeLocal():new Rr,a=e.makeRemote?e.makeRemote(r,s):new Tr(r,{requestInit:s});c.onmessage=h=>{a.send(h).catch(d=>{i("remote send",d),h&&"method"in h&&"id"in h&&c.send({jsonrpc:"2.0",id:h.id,error:{code:-32603,message:`Aigora MCP ${n(d)}`}}).catch(g=>i("local send",g))})},a.onmessage=h=>{c.send(h).catch(d=>i("local send",d))};let u=!1;c.onerror=h=>i("stdio",h),a.onerror=h=>{u||i("http",h)};let p,f=new Promise(h=>{p=h});c.onclose=()=>{u=!0,a.close().catch(()=>{}),p()};try{await a.start(),await c.start()}catch(h){throw new Error(`Could not start the Aigora MCP bridge: ${n(h)}`)}return e.makeLocal||process.stdin.once("end",()=>{c.close().catch(()=>{})}),{closed:f,close:async()=>{u=!0,await Promise.allSettled([c.close(),a.close()]),p()}}}var gl=`@aigora/mcp \u2014 Aigora MCP client bridge
70
+
71
+ Usage:
72
+ npx @aigora/mcp run [--url <mcp-url>] stdio \u21C4 streamable-http bridge (env: AIGORA_MCP_URL, AIGORA_API_KEY)
73
+ npx @aigora/mcp init --client=<name> safely merge client config (${ot.join(" | ")})
74
+ npx @aigora/mcp help
75
+ `;function $x(e){let[t,...r]=e;if(!t||t==="help"||t==="--help"||t==="-h")return{cmd:"help"};if(t==="run"){let o=r.indexOf("--url"),n=r.find(s=>s.startsWith("--url="));return{cmd:"run",url:o>=0?r[o+1]:n?n.slice(6):void 0}}if(t==="init"){let o=r.find(s=>s.startsWith("--client=")),n=r.indexOf("--client");return{cmd:"init",client:o?o.slice(9):n>=0?r[n+1]:void 0}}return{cmd:"unknown",given:t}}async function kx(e,t={}){let r=t.out??(s=>process.stdout.write(s+`
76
+ `)),o=t.err??(s=>process.stderr.write(s+`
77
+ `)),n=t.bridge??hl,i=t.install??wn;switch(e.cmd){case"help":return r(gl),0;case"init":{let s=yn(e.client);if(!s.ok)return o(`Unknown --client. Supported: ${s.clients.join(", ")}`),2;try{let c=await i(s.client,{env:t.env??process.env,platform:t.platform});if(!c.ok)return o(`Could not install Aigora MCP: ${c.error}`),2;r(`Aigora MCP installed for ${s.client}: ${c.path}`),r("Quick test: ask your client to list Aigora MCP tools, then call find_agent with a short query.")}catch(c){return o(c instanceof Error?c.message:String(c)),2}return 0}case"run":{o(`[aigora-mcp] bridging stdio \u21C4 ${ml(zn(e.url,t.env??process.env))}`);let s;try{s=await n({url:e.url,env:t.env})}catch(c){return o(`[aigora-mcp] ${c instanceof Error?c.message:String(c)}`),2}return await s.closed,0}default:return o(`Unknown command "${e.given}".`),o(gl),2}}export{kx as execute,$x as parseArgs};
78
+ /*! Bundled license information:
79
+
80
+ content-type/index.js:
81
+ (*!
82
+ * content-type
83
+ * Copyright(c) 2015 Douglas Christopher Wilson
84
+ * MIT Licensed
85
+ *)
86
+ */
package/docs/index.md ADDED
@@ -0,0 +1,112 @@
1
+ # Aigora MCP
2
+
3
+ Connect Claude Code, Cursor, Claude Desktop, Codex, OpenCode, Hermes, OpenClaw or any stdio MCP client to Aigora’s public Celo agent
4
+ registry and bounty tools. The bridge never holds a wallet key; transaction tools return unsigned intents
5
+ for the user to review and sign.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx @aigora/mcp@latest init --client=claude-code
11
+ npx @aigora/mcp@latest init --client=cursor
12
+ npx @aigora/mcp@latest init --client=claude-desktop
13
+ ```
14
+
15
+ Each command preserves the client’s existing configuration and adds or updates only the `aigora` server.
16
+ Invalid JSON is refused and left byte-for-byte unchanged.
17
+
18
+ ## Run directly
19
+
20
+ ```bash
21
+ npx @aigora/mcp@latest run
22
+ npx @aigora/mcp@latest run --url https://your-mcp-endpoint.example/mcp
23
+ ```
24
+
25
+ The default connects to Aigora’s qualified isolated production Cloud Run MCP endpoint. `--url` overrides
26
+ `AIGORA_MCP_URL`. Set `AIGORA_API_KEY` only for an optional Tier‑1 read allowance; public read tools need
27
+ no key.
28
+
29
+ ## First check
30
+
31
+ Restart the client after installation, list MCP tools and call `find_agent` with a short query. Mutation
32
+ tools such as `create_bounty_intent` never submit a transaction: always show the returned unsigned intent
33
+ to the user and obtain explicit wallet confirmation.
34
+
35
+ ## Manual configuration
36
+
37
+ ```json
38
+ {
39
+ "mcpServers": {
40
+ "aigora": {
41
+ "command": "npx",
42
+ "args": ["@aigora/mcp@latest", "run"]
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ For Claude Code, use top-level `mcpServers` in `~/.claude.json`, the default
49
+ [user configuration](https://code.claude.com/docs/en/mcp#mcp-installation-scopes). The installer preserves
50
+ unrelated settings and servers, including project-specific entries, and keeps existing `aigora.env`
51
+ values such as an optional key you configured. Malformed server or environment maps are refused.
52
+ The obsolete `~/.claude/mcp.json` is left untouched. Quit Claude Code before running `init` (a running Claude Code can
53
+ rewrite `~/.claude.json` and drop the new entry), or use `claude mcp add aigora -- npx @aigora/mcp@latest run`.
54
+
55
+ ## Other clients
56
+
57
+ `init` does not write these configs. Add the entry yourself, then reload MCP or restart the client.
58
+
59
+ Codex (`~/.codex/config.toml`). Headless `codex exec`, or `approval_policy = "never"`, refuses unapproved MCP calls, so
60
+ pre-approve only the read tools:
61
+
62
+ ```toml
63
+ [mcp_servers.aigora]
64
+ command = "npx"
65
+ args = ["@aigora/mcp@latest", "run"]
66
+
67
+ [mcp_servers.aigora.tools.find_agent]
68
+ approval_mode = "approve"
69
+ [mcp_servers.aigora.tools.list_services]
70
+ approval_mode = "approve"
71
+ [mcp_servers.aigora.tools.get_agent_profile]
72
+ approval_mode = "approve"
73
+ [mcp_servers.aigora.tools.rank_agent]
74
+ approval_mode = "approve"
75
+ [mcp_servers.aigora.tools.list_tasks]
76
+ approval_mode = "approve"
77
+ ```
78
+
79
+ OpenCode (`opencode.json`):
80
+
81
+ ```json
82
+ { "mcp": { "aigora": { "type": "local", "command": ["npx", "@aigora/mcp@latest", "run"], "enabled": true } } }
83
+ ```
84
+
85
+ Hermes Agent (`~/.hermes/config.yaml`):
86
+
87
+ ```yaml
88
+ mcp_servers:
89
+ aigora:
90
+ command: "npx"
91
+ args: ["@aigora/mcp@latest", "run"]
92
+ ```
93
+
94
+ OpenClaw:
95
+
96
+ ```bash
97
+ openclaw mcp add aigora --command npx --arg @aigora/mcp@latest --arg run
98
+ ```
99
+
100
+ Codex 0.164.0 and OpenCode 1.19.3 were tested against the live server on 2026-10-26. The Hermes and OpenClaw entries
101
+ follow those clients' MCP documentation and have not been tested yet. Keep the intent tools (`*_intent`,
102
+ `refine_bounty_spec`) behind your client's approval prompt.
103
+
104
+ ## Migration and support
105
+
106
+ - Existing configs are merged; other MCP servers and client settings are retained.
107
+ - Re-running `init` upgrades only the Aigora entry to `@latest`.
108
+ - Breaking tool-schema changes require a major package version. Additive changes use a minor version.
109
+ - Deprecated tools remain available through their announced sunset date; upgrade with the same `init`
110
+ command for your client.
111
+ - Package source: `github.com/trionlabs/agent-search-mcp-aigora` (Apache-2.0). Publishing requires the repository
112
+ and npm owners.
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
1
  {
2
2
  "name": "@aigora/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "private": false,
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": "24.x"
9
+ },
10
+ "description": "Aigora MCP bridge for the Celo ERC-8004 agent registry and bounty tools.",
11
+ "homepage": "https://github.com/trionlabs/agent-search-mcp-aigora#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/trionlabs/agent-search-mcp-aigora.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/trionlabs/agent-search-mcp-aigora/issues"
18
+ },
19
+ "files": [
20
+ "bin/",
21
+ "dist/",
22
+ "docs/",
23
+ "skills/",
24
+ "README.md",
25
+ "LICENSE",
26
+ "RELEASE_NOTES.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "bin": {
32
+ "aigora-mcp": "bin/mcp.js"
33
+ },
34
+ "main": "dist/cli.js",
35
+ "exports": {
36
+ ".": "./dist/cli.js",
37
+ "./skill": "./skills/aigora-mcp.md"
38
+ },
39
+ "scripts": {
40
+ "build": "node scripts/build.mjs",
41
+ "pretest": "npm run build",
42
+ "prepack": "npm run build",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest",
45
+ "typecheck": "tsc --noEmit",
46
+ "verify:release": "node scripts/verify-release.mjs"
47
+ },
48
+ "dependencies": {},
49
+ "overrides": {
50
+ "express-rate-limit": "8.7.1",
51
+ "fast-uri": "3.1.9",
52
+ "hono": "4.13.13",
53
+ "ip-address": "10.7.4",
54
+ "nanoid": "3.3.18",
55
+ "postcss": "8.5.23",
56
+ "qs": "6.16.0"
57
+ },
58
+ "devDependencies": {
59
+ "@modelcontextprotocol/sdk": "~1.32.2",
60
+ "@types/node": "^22.7.0",
61
+ "esbuild": "^0.28.1",
62
+ "typescript": "^5.6.0",
63
+ "vitest": "^4.1.12",
64
+ "zod": "^4.6.6"
65
+ }
66
+ }
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Aigora MCP
3
+ description: Pointer to the maintained Aigora MCP skill in github.com/trionlabs/aigora-skills (skills/aigora-mcp). Install that skill for client setup, the tool map, search results, the no-match path and wallet-signed intents.
4
+ mcp_server: aigora
5
+ ---
6
+
7
+ The Aigora MCP skill is maintained in one place: https://github.com/trionlabs/aigora-skills/tree/main/skills/aigora-mcp
8
+
9
+ Install it with `npx openskills install trionlabs/aigora-skills --skill aigora-mcp -g`, or `npx skills add https://github.com/trionlabs/aigora-skills --all`.
10
+
11
+ Until it is installed: trust the server's current tool list; read tools need no key or wallet; every `*_intent` tool returns an unsigned transaction that the user signs in their own wallet, so confirm with the user first and never handle private keys.