@morozinc/opencode-bmad-plugin 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +31 -0
- package/NOTICE.md +6 -0
- package/README.md +64 -2
- package/dist/gui-experimental.cjs +64 -0
- package/docs/screenshots/artifact-storage.png +0 -0
- package/package.json +53 -4
- package/skills/bmad-code-review/SKILL.md +23 -0
- package/skills/bmad-code-review/reference/SKILL.md +90 -0
- package/skills/bmad-code-review/reference/customize.toml +41 -0
- package/skills/bmad-code-review/reference/steps/step-01-gather-context.md +85 -0
- package/skills/bmad-code-review/reference/steps/step-02-review.md +35 -0
- package/skills/bmad-code-review/reference/steps/step-03-triage.md +49 -0
- package/skills/bmad-code-review/reference/steps/step-04-present.md +132 -0
- package/skills/bmad-create-architecture/SKILL.md +23 -0
- package/skills/bmad-create-architecture/reference/SKILL.md +74 -0
- package/skills/bmad-create-architecture/reference/architecture-decision-template.md +12 -0
- package/skills/bmad-create-architecture/reference/customize.toml +41 -0
- package/skills/bmad-create-architecture/reference/data/domain-complexity.csv +13 -0
- package/skills/bmad-create-architecture/reference/data/project-types.csv +7 -0
- package/skills/bmad-create-architecture/reference/steps/step-01-init.md +153 -0
- package/skills/bmad-create-architecture/reference/steps/step-01b-continue.md +173 -0
- package/skills/bmad-create-architecture/reference/steps/step-02-context.md +224 -0
- package/skills/bmad-create-architecture/reference/steps/step-03-starter.md +329 -0
- package/skills/bmad-create-architecture/reference/steps/step-04-decisions.md +318 -0
- package/skills/bmad-create-architecture/reference/steps/step-05-patterns.md +359 -0
- package/skills/bmad-create-architecture/reference/steps/step-06-structure.md +379 -0
- package/skills/bmad-create-architecture/reference/steps/step-07-validation.md +361 -0
- package/skills/bmad-create-architecture/reference/steps/step-08-complete.md +82 -0
- package/skills/bmad-create-epics-and-stories/SKILL.md +23 -0
- package/skills/bmad-create-epics-and-stories/reference/SKILL.md +93 -0
- package/skills/bmad-create-epics-and-stories/reference/customize.toml +41 -0
- package/skills/bmad-create-epics-and-stories/reference/steps/step-01-validate-prerequisites.md +255 -0
- package/skills/bmad-create-epics-and-stories/reference/steps/step-02-design-epics.md +242 -0
- package/skills/bmad-create-epics-and-stories/reference/steps/step-03-create-stories.md +255 -0
- package/skills/bmad-create-epics-and-stories/reference/steps/step-04-final-validation.md +143 -0
- package/skills/bmad-create-epics-and-stories/reference/templates/epics-template.md +61 -0
- package/skills/bmad-create-story/SKILL.md +23 -0
- package/skills/bmad-create-story/reference/SKILL.md +429 -0
- package/skills/bmad-create-story/reference/checklist.md +357 -0
- package/skills/bmad-create-story/reference/customize.toml +41 -0
- package/skills/bmad-create-story/reference/discover-inputs.md +88 -0
- package/skills/bmad-create-story/reference/template.md +49 -0
- package/skills/bmad-dev-story/SKILL.md +23 -0
- package/skills/bmad-dev-story/reference/SKILL.md +500 -0
- package/skills/bmad-dev-story/reference/checklist.md +80 -0
- package/skills/bmad-dev-story/reference/customize.toml +41 -0
- package/skills/bmad-document-project/SKILL.md +23 -0
- package/skills/bmad-document-project/reference/SKILL.md +62 -0
- package/skills/bmad-document-project/reference/checklist.md +245 -0
- package/skills/bmad-document-project/reference/customize.toml +41 -0
- package/skills/bmad-document-project/reference/documentation-requirements.csv +12 -0
- package/skills/bmad-document-project/reference/instructions.md +128 -0
- package/skills/bmad-document-project/reference/templates/deep-dive-template.md +345 -0
- package/skills/bmad-document-project/reference/templates/index-template.md +169 -0
- package/skills/bmad-document-project/reference/templates/project-overview-template.md +103 -0
- package/skills/bmad-document-project/reference/templates/project-scan-report-schema.json +160 -0
- package/skills/bmad-document-project/reference/templates/source-tree-template.md +135 -0
- package/skills/bmad-document-project/reference/workflows/deep-dive-instructions.md +300 -0
- package/skills/bmad-document-project/reference/workflows/deep-dive-workflow.md +34 -0
- package/skills/bmad-document-project/reference/workflows/full-scan-instructions.md +1108 -0
- package/skills/bmad-document-project/reference/workflows/full-scan-workflow.md +34 -0
- package/skills/bmad-generate-project-context/SKILL.md +23 -0
- package/skills/bmad-generate-project-context/reference/SKILL.md +81 -0
- package/skills/bmad-generate-project-context/reference/customize.toml +41 -0
- package/skills/bmad-generate-project-context/reference/project-context-template.md +21 -0
- package/skills/bmad-generate-project-context/reference/steps/step-01-discover.md +186 -0
- package/skills/bmad-generate-project-context/reference/steps/step-02-generate.md +321 -0
- package/skills/bmad-generate-project-context/reference/steps/step-03-complete.md +284 -0
- package/skills/bmad-help/SKILL.md +19 -0
- package/skills/bmad-help/reference/SKILL.md +75 -0
- package/skills/bmad-prd/SKILL.md +23 -0
- package/skills/bmad-prd/reference/SKILL.md +92 -0
- package/skills/bmad-prd/reference/assets/headless-schemas.md +76 -0
- package/skills/bmad-prd/reference/assets/prd-template.md +165 -0
- package/skills/bmad-prd/reference/assets/prd-validation-checklist.md +135 -0
- package/skills/bmad-prd/reference/assets/validation-report-template.html +325 -0
- package/skills/bmad-prd/reference/customize.toml +147 -0
- package/skills/bmad-prd/reference/references/headless.md +39 -0
- package/skills/bmad-prd/reference/references/validate.md +97 -0
- package/skills/bmad-product-brief/SKILL.md +22 -0
- package/skills/bmad-product-brief/reference/SKILL.md +91 -0
- package/skills/bmad-product-brief/reference/assets/brief-template.md +41 -0
- package/skills/bmad-product-brief/reference/customize.toml +99 -0
- package/skills/bmad-quick-dev/SKILL.md +26 -0
- package/skills/bmad-quick-dev/reference/SKILL.md +111 -0
- package/skills/bmad-quick-dev/reference/compile-epic-context.md +62 -0
- package/skills/bmad-quick-dev/reference/customize.toml +41 -0
- package/skills/bmad-quick-dev/reference/spec-template.md +88 -0
- package/skills/bmad-quick-dev/reference/step-01-clarify-and-route.md +100 -0
- package/skills/bmad-quick-dev/reference/step-02-plan.md +47 -0
- package/skills/bmad-quick-dev/reference/step-03-implement.md +41 -0
- package/skills/bmad-quick-dev/reference/step-04-review.md +50 -0
- package/skills/bmad-quick-dev/reference/step-05-present.md +78 -0
- package/skills/bmad-quick-dev/reference/step-oneshot.md +71 -0
- package/skills/bmad-quick-dev/reference/sync-sprint-status.md +19 -0
- package/skills/bmad-sprint-planning/SKILL.md +23 -0
- package/skills/bmad-sprint-planning/reference/SKILL.md +300 -0
- package/skills/bmad-sprint-planning/reference/checklist.md +33 -0
- package/skills/bmad-sprint-planning/reference/customize.toml +41 -0
- package/skills/bmad-sprint-planning/reference/sprint-status-template.yaml +56 -0
- package/src/gui.tsx +127 -0
- package/src/index.ts +114 -0
- package/src/rpc.ts +27 -0
- package/src/storage.ts +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Moroz Inc. (OpenCode plugin code)
|
|
4
|
+
Copyright (c) 2025 BMad Code, LLC
|
|
5
|
+
|
|
6
|
+
This project incorporates contributions from the open source community.
|
|
7
|
+
See [CONTRIBUTORS.md](CONTRIBUTORS.md) for contributor attribution.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
TRADEMARK NOTICE:
|
|
28
|
+
BMad™, BMad Method™, and BMad Core™ are trademarks of BMad Code, LLC, covering all
|
|
29
|
+
casings and variations (including BMAD, bmad, BMadMethod, BMAD-METHOD, etc.). The use of
|
|
30
|
+
these trademarks in this software does not grant any rights to use the trademarks
|
|
31
|
+
for any other purpose. See [TRADEMARK.md](TRADEMARK.md) for detailed guidelines.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
The skills and reference materials in `skills/` are adapted from BMAD Method,
|
|
2
|
+
copyright (c) 2025 BMad Code, LLC and contributors, under the MIT License.
|
|
3
|
+
|
|
4
|
+
Source: eLLMsha v3 `bmad-method/ellmsha-skills`, itself based on BMAD Method.
|
|
5
|
+
This plugin changes global registration and artifact storage instructions.
|
|
6
|
+
BMAD, BMad Method and BMad Core are trademarks of BMad Code, LLC.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BMAD Method for OpenCode
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use BMAD Method in any OpenCode project without installing `_bmad` in each
|
|
4
|
+
repository. The plugin ships twelve skills with their reference files. Code
|
|
5
|
+
changes go in the repository you have open.
|
|
6
|
+
|
|
7
|
+
## Install from npm
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
opencode plugin add @morozinc/opencode-bmad-plugin@0.1.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Build from source
|
|
14
|
+
|
|
15
|
+
Requires OpenCode 2.4.3 and Node 22.20+.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm ci
|
|
19
|
+
npm run check
|
|
20
|
+
npm run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Add the plugin directory to `plugins` in your **global** `~/.config/opencode/opencode.jsonc`, preserving other entries:
|
|
24
|
+
|
|
25
|
+
```jsonc
|
|
26
|
+
{
|
|
27
|
+
"plugins": ["/absolute/path/to/opencode-bmad-plugin"],
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Ask OpenCode to use a BMAD workflow or call a skill by name. Start with
|
|
34
|
+
`bmad-help` if you’re unsure which skill fits. The workflows run on request.
|
|
35
|
+
|
|
36
|
+
- Planning: `bmad-product-brief`, `bmad-prd`, `bmad-create-architecture`,
|
|
37
|
+
`bmad-create-epics-and-stories`, `bmad-sprint-planning`.
|
|
38
|
+
- Development: `bmad-create-story`, `bmad-dev-story`, `bmad-quick-dev`,
|
|
39
|
+
`bmad-code-review`.
|
|
40
|
+
- Documentation: `bmad-document-project`, `bmad-generate-project-context`.
|
|
41
|
+
|
|
42
|
+
### Artifact storage
|
|
43
|
+
|
|
44
|
+
Open **Settings > BMAD Method** or run **Open BMAD Settings** from the command
|
|
45
|
+
palette. By default, BMAD saves Markdown to `_bmad-output/` in the active
|
|
46
|
+
repository.
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
If [TencentDB Memory](https://github.com/ShiftHackZ/opencode-tencentdb-plugin) is active, you can
|
|
51
|
+
save artifacts in its project scope instead. BMAD uses the `tdai_scenario_*`
|
|
52
|
+
document tools and the `bmad_prefix` returned by `tdai_context`. Switching
|
|
53
|
+
storage leaves existing artifacts where they are. If TencentDB is selected and
|
|
54
|
+
goes offline, writes stop until it comes back or you switch storage.
|
|
55
|
+
|
|
56
|
+
## Source and license
|
|
57
|
+
|
|
58
|
+
The skills are adapted from BMAD Method by BMad Code, LLC. The original
|
|
59
|
+
methodology is in the reference files. This plugin adapts the artifact storage
|
|
60
|
+
instructions for OpenCode. See [NOTICE.md](NOTICE.md) and [LICENSE](LICENSE).
|
|
61
|
+
BMad trademarks remain with BMad Code, LLC.
|
|
62
|
+
|
|
63
|
+
Developed by [Moroz Inc.](https://moroz.cc).
|
|
64
|
+
|
|
65
|
+
This project is not affiliated with OpenCode or Anomaly.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("solid-js/web"),K=require("@opencode/plugin/gui"),M=require("solid-js"),It=require("@opencode/plugin/rpc");var ye;function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,f=Object.keys(l);for(let h=0;h<f.length;h++){const m=f[h];m in c||(c[m]=l[m].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const f of l._zod.deferred)f();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class D extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ge extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ye=globalThis).__zod_globalConfig??(ye.__zod_globalConfig={});const le=globalThis.__zod_globalConfig;function j(e){return le}function Ke(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ce(e,t){return typeof t=="bigint"?t.toString():t}function fe(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function de(e){return e==null}function pe(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Et(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}const we=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==we)return r===void 0&&(r=we,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function C(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function T(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ke(e){return JSON.stringify(e)}function Pt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const qe="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Tt=fe(()=>{if(le.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function J(e){if(q(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(q(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ye(e){return J(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Nt=new Set(["string","number","symbol"]);function Q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function d(e){const 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 jt(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const At={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]};function Ct(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=T(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return C(this,"shape",i),i},checks:[]});return N(e,s)}function Rt(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=T(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return C(this,"shape",i),i},checks:[]});return N(e,s)}function Dt(e,t){if(!J(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=T(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return C(this,"shape",s),s}});return N(e,o)}function xt(e,t){if(!J(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=T(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return C(this,"shape",r),r}});return N(e,n)}function Ut(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=T(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return C(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return N(e,n)}function Mt(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=T(t._zod.def,{get shape(){const c=t._zod.def.shape,a={...c};if(n)for(const l in n){if(!(l in c))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(a[l]=e?new e({type:"optional",innerType:c[l]}):c[l])}else for(const l in c)a[l]=e?new e({type:"optional",innerType:c[l]}):c[l];return C(this,"shape",a),a},checks:[]});return N(t,i)}function Ft(e,t,n){const r=T(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return C(this,"shape",s),s}});return N(t,r)}function R(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Jt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Xe(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function B(e){return typeof e=="string"?e:e?.message}function A(e,t,n){const r=e.message?e.message:B(e.inst?._zod.def?.error?.(e))??B(t?.error?.(e))??B(n.customError?.(e))??B(n.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=r,t?.reportInput&&(c.input=i),c}function he(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function L(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const He=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ce,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Qe=u("$ZodError",He),et=u("$ZodError",He,{Parent:Error});function Lt(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Vt(e,t=n=>n.message){const n={_errors:[]},r=(o,s=[])=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(c=>r({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{const c=[...s,...i.path];if(c.length===0)n._errors.push(t(i));else{let a=n,l=0;for(;l<c.length;){const f=c[l];l===c.length-1?(a[f]=a[f]||{_errors:[]},a[f]._errors.push(t(i))):a[f]=a[f]||{_errors:[]},a=a[f],l++}}}};return r(e),n}const me=e=>(t,n,r,o)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new D;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>A(a,s,j())));throw qe(c,o?.callee),c}return i.value},_e=e=>async(t,n,r,o)=>{const s=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>A(a,s,j())));throw qe(c,o?.callee),c}return i.value},ee=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new D;return s.issues.length?{success:!1,error:new(e??Qe)(s.issues.map(i=>A(i,o,j())))}:{success:!0,data:s.value}},Bt=ee(et),te=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>A(i,o,j())))}:{success:!0,data:s.value}},Wt=te(et),Gt=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return me(e)(t,n,o)},Kt=e=>(t,n,r)=>me(e)(t,n,r),qt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return _e(e)(t,n,o)},Yt=e=>async(t,n,r)=>_e(e)(t,n,r),Xt=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ee(e)(t,n,o)},Ht=e=>(t,n,r)=>ee(e)(t,n,r),Qt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return te(e)(t,n,o)},en=e=>async(t,n,r)=>te(e)(t,n,r),tn=/^[cC][0-9a-z]{6,}$/,nn=/^[0-9a-z]+$/,rn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,on=/^[0-9a-vA-V]{20}$/,sn=/^[A-Za-z0-9]{27}$/,cn=/^[a-zA-Z0-9_-]{21}$/,un=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,an=/^([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})$/,$e=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)$/,ln=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function dn(){return new RegExp(fn,"u")}const pn=/^(?:(?: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])$/,hn=/^(([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}|:))$/,mn=/^((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])$/,_n=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tt=/^[A-Za-z0-9_-]*$/,vn=/^https?$/,bn=/^\+[1-9]\d{6,14}$/,nt="(?:(?:\\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])))",zn=new RegExp(`^${nt}$`);function rt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function yn(e){return new RegExp(`^${rt(e)}$`)}function wn(e){const t=rt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${nt}T(?:${r})$`)}const kn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$n=/^-?\d+$/,Zn=/^-?\d+(?:\.\d+)?$/,Sn=/^(?:true|false)$/i,On=/^[^A-Z]*$/,In=/^[^a-z]*$/,O=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ot={number:"number",bigint:"bigint",object:"date"},it=u("$ZodCheckLessThan",(e,t)=>{O.init(e,t);const n=ot[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),st=u("$ZodCheckGreaterThan",(e,t)=>{O.init(e,t);const n=ot[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),En=u("$ZodCheckMultipleOf",(e,t)=>{O.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Et(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Pn=u("$ZodCheckNumberFormat",(e,t)=>{O.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=At[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=$n)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Tn=u("$ZodCheckMaxLength",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!de(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=he(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Nn=u("$ZodCheckMinLength",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!de(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=he(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),jn=u("$ZodCheckLengthEquals",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!de(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=he(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ne=u("$ZodCheckStringFormat",(e,t)=>{var n,r;O.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),An=u("$ZodCheckRegex",(e,t)=>{ne.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Cn=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=On),ne.init(e,t)}),Rn=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=In),ne.init(e,t)}),Dn=u("$ZodCheckIncludes",(e,t)=>{O.init(e,t);const n=Q(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),xn=u("$ZodCheckStartsWith",(e,t)=>{O.init(e,t);const n=new RegExp(`^${Q(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Un=u("$ZodCheckEndsWith",(e,t)=>{O.init(e,t);const n=new RegExp(`.*${Q(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Mn=u("$ZodCheckOverwrite",(e,t)=>{O.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Fn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
|
+
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
3
|
+
`))}}const Jn={major:4,minor:4,patch:0},y=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jn;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,a)=>{let l=R(i),f;for(const h of c){if(h._zod.def.when){if(Jt(i)||!h._zod.def.when(i))continue}else if(l)continue;const m=i.issues.length,p=h._zod.check(i);if(p instanceof Promise&&a?.async===!1)throw new D;if(f||p instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await p,i.issues.length!==m&&(l||(l=R(i,m)))});else{if(i.issues.length===m)continue;l||(l=R(i,m))}}return f?f.then(()=>i):i},s=(i,c,a)=>{if(R(i))return i.aborted=!0,i;const l=o(c,r,a);if(l instanceof Promise){if(a.async===!1)throw new D;return l.then(f=>e._zod.parse(f,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(f=>s(f,i,c)):s(l,i,c)}const a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new D;return a.then(l=>o(l,r,c))}return o(a,r,c)}}_(e,"~standard",()=>({validate:o=>{try{const s=Bt(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Wt(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),ge=u("$ZodString",(e,t)=>{y.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??kn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),v=u("$ZodStringFormat",(e,t)=>{ne.init(e,t),ge.init(e,t)}),Ln=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=an),v.init(e,t)}),Vn=u("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$e(r))}else t.pattern??(t.pattern=$e());v.init(e,t)}),Bn=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ln),v.init(e,t)}),Wn=u("$ZodURL",(e,t)=>{v.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===vn.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Gn=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=dn()),v.init(e,t)}),Kn=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=cn),v.init(e,t)}),qn=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=tn),v.init(e,t)}),Yn=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nn),v.init(e,t)}),Xn=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=rn),v.init(e,t)}),Hn=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=on),v.init(e,t)}),Qn=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sn),v.init(e,t)}),er=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=wn(t)),v.init(e,t)}),tr=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=zn),v.init(e,t)}),nr=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=yn(t)),v.init(e,t)}),rr=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=un),v.init(e,t)}),or=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=pn),v.init(e,t),e._zod.bag.format="ipv4"}),ir=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hn),v.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),sr=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=mn),v.init(e,t)}),cr=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=_n),v.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ct(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ur=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=gn),v.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ct(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ar(e){if(!tt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ct(n)}const lr=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tt),v.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ar(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),fr=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=bn),v.init(e,t)});function dr(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const pr=u("$ZodJWT",(e,t)=>{v.init(e,t),e._zod.check=n=>{dr(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ut=u("$ZodNumber",(e,t)=>{y.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),hr=u("$ZodNumberFormat",(e,t)=>{Pn.init(e,t),ut.init(e,t)}),mr=u("$ZodBoolean",(e,t)=>{y.init(e,t),e._zod.pattern=Sn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),_r=u("$ZodUnknown",(e,t)=>{y.init(e,t),e._zod.parse=n=>n}),gr=u("$ZodNever",(e,t)=>{y.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ze(e,t,n){e.issues.length&&t.issues.push(...Xe(n,e.issues)),t.value[n]=e.value}const vr=u("$ZodArray",(e,t)=>{y.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const c=o[i],a=t.element._zod.run({value:c,issues:[]},r);a instanceof Promise?s.push(a.then(l=>Ze(l,n,i))):Ze(a,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Y(e,t,n,r,o,s){const i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...Xe(n,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?i&&(t.value[n]=void 0):t.value[n]=e.value}function at(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=jt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function lt(e,t,n,r,o,s){const i=[],c=o.keySet,a=o.catchall._zod,l=a.def.type,f=a.optin==="optional",h=a.optout==="optional";for(const m in t){if(m==="__proto__"||c.has(m))continue;if(l==="never"){i.push(m);continue}const p=a.run({value:t[m],issues:[]},r);p instanceof Promise?e.push(p.then(g=>Y(g,n,m,t,f,h))):Y(p,n,m,t,f,h)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const br=u("$ZodObject",(e,t)=>{if(y.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}const r=fe(()=>at(t));_(e._zod,"propValues",()=>{const c=t.shape,a={};for(const l in c){const f=c[l]._zod;if(f.values){a[l]??(a[l]=new Set);for(const h of f.values)a[l].add(h)}}return a});const o=q,s=t.catchall;let i;e._zod.parse=(c,a)=>{i??(i=r.value);const l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};const f=[],h=i.shape;for(const m of i.keys){const p=h[m],g=p._zod.optin==="optional",U=p._zod.optout==="optional",k=p._zod.run({value:l[m],issues:[]},a);k instanceof Promise?f.push(k.then(re=>Y(re,c,m,l,g,U))):Y(k,c,m,l,g,U)}return s?lt(f,l,c,a,r.value,e):f.length?Promise.all(f).then(()=>c):c}}),zr=u("$ZodObjectJIT",(e,t)=>{br.init(e,t);const n=e._zod.parse,r=fe(()=>at(t)),o=m=>{const p=new Fn(["shape","payload","ctx"]),g=r.value,U=P=>{const z=ke(P);return`shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`};p.write("const input = payload.value;");const k=Object.create(null);let re=0;for(const P of g.keys)k[P]=`key_${re++}`;p.write("const newResult = {};");for(const P of g.keys){const z=k[P],$=ke(P),be=m[P],ze=be?._zod?.optin==="optional",Ot=be?._zod?.optout==="optional";p.write(`const ${z} = ${U(P)};`),ze&&Ot?p.write(`
|
|
4
|
+
if (${z}.issues.length) {
|
|
5
|
+
if (${$} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
|
|
7
|
+
...iss,
|
|
8
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (${z}.value === undefined) {
|
|
14
|
+
if (${$} in input) {
|
|
15
|
+
newResult[${$}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
newResult[${$}] = ${z}.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
`):ze?p.write(`
|
|
22
|
+
if (${z}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
|
|
24
|
+
...iss,
|
|
25
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${z}.value === undefined) {
|
|
30
|
+
if (${$} in input) {
|
|
31
|
+
newResult[${$}] = undefined;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
newResult[${$}] = ${z}.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`):p.write(`
|
|
38
|
+
const ${z}_present = ${$} in input;
|
|
39
|
+
if (${z}.issues.length) {
|
|
40
|
+
payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
|
|
41
|
+
...iss,
|
|
42
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
43
|
+
})));
|
|
44
|
+
}
|
|
45
|
+
if (!${z}_present && !${z}.issues.length) {
|
|
46
|
+
payload.issues.push({
|
|
47
|
+
code: "invalid_type",
|
|
48
|
+
expected: "nonoptional",
|
|
49
|
+
input: undefined,
|
|
50
|
+
path: [${$}]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (${z}_present) {
|
|
55
|
+
if (${z}.value === undefined) {
|
|
56
|
+
newResult[${$}] = undefined;
|
|
57
|
+
} else {
|
|
58
|
+
newResult[${$}] = ${z}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const St=p.compile();return(P,z)=>St(m,P,z)};let s;const i=q,c=!le.jitless,l=c&&Tt.value,f=t.catchall;let h;e._zod.parse=(m,p)=>{h??(h=r.value);const g=m.value;return i(g)?c&&l&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),m=s(m,p),f?lt([],g,m,p,h,e):m):n(m,p):(m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m)}});function Se(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!R(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>A(i,r,j())))}),t)}const yr=u("$ZodUnion",(e,t)=>{y.init(e,t),_(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>pe(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1;const i=[];for(const c of t.options){const a=c._zod.run({value:r.value,issues:[]},o);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}return s?Promise.all(i).then(c=>Se(c,r,e,o)):Se(i,r,e,o)}}),wr=u("$ZodIntersection",(e,t)=>{y.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,l])=>Oe(n,a,l)):Oe(n,s,i)}});function ue(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(J(e)&&J(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=ue(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=ue(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Oe(e,t,n){const r=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const a of c.keys)r.has(a)||r.set(a,{}),r.get(a).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const a of c.keys)r.has(a)||r.set(a,{}),r.get(a).r=!0;else e.issues.push(c);const s=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o&&e.issues.push({...o,keys:s}),R(e))return e;const i=ue(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const kr=u("$ZodEnum",(e,t)=>{y.init(e,t);const n=Ke(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Nt.has(typeof o)).map(o=>typeof o=="string"?Q(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),$r=u("$ZodTransform",(e,t)=>{y.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ge(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new D;return n.value=o,n}});function Ie(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const ft=u("$ZodOptional",(e,t)=>{y.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pe(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Ie(s,n.value)):Ie(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Zr=u("$ZodExactOptional",(e,t)=>{ft.init(e,t),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Sr=u("$ZodNullable",(e,t)=>{y.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pe(n.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Or=u("$ZodDefault",(e,t)=>{y.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Ee(s,t)):Ee(o,t)}});function Ee(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ir=u("$ZodPrefault",(e,t)=>{y.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Er=u("$ZodNonOptional",(e,t)=>{y.init(e,t),_(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Pe(s,e)):Pe(o,e)}});function Pe(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Pr=u("$ZodCatch",(e,t)=>{y.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>A(i,r,j()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>A(s,r,j()))},input:n.value}),n.issues=[]),n)}}),Tr=u("$ZodPipe",(e,t)=>{y.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>W(i,t.in,r)):W(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>W(s,t.out,r)):W(o,t.out,r)}});function W(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Nr=u("$ZodReadonly",(e,t)=>{y.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Te):Te(o)}});function Te(e){return e.value=Object.freeze(e.value),e}const jr=u("$ZodCustom",(e,t)=>{O.init(e,t),y.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Ne(s,n,r,e));Ne(o,n,r,e)}});function Ne(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(L(o))}}var je;class Ar{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Cr(){return new Ar}(je=globalThis).__zod_globalRegistry??(je.__zod_globalRegistry=Cr());const F=globalThis.__zod_globalRegistry;function Rr(e,t){return new e({type:"string",...d(t)})}function Dr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...d(t)})}function Ae(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...d(t)})}function xr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...d(t)})}function Ur(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...d(t)})}function Mr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...d(t)})}function Fr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...d(t)})}function Jr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...d(t)})}function Lr(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...d(t)})}function Vr(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...d(t)})}function Br(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...d(t)})}function Wr(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...d(t)})}function Gr(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...d(t)})}function Kr(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...d(t)})}function qr(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...d(t)})}function Yr(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...d(t)})}function Xr(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...d(t)})}function Hr(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...d(t)})}function Qr(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...d(t)})}function eo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...d(t)})}function to(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...d(t)})}function no(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...d(t)})}function ro(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...d(t)})}function oo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...d(t)})}function io(e,t){return new e({type:"string",format:"date",check:"string_format",...d(t)})}function so(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...d(t)})}function co(e,t){return new e({type:"string",format:"duration",check:"string_format",...d(t)})}function uo(e,t){return new e({type:"number",checks:[],...d(t)})}function ao(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...d(t)})}function lo(e,t){return new e({type:"boolean",...d(t)})}function fo(e){return new e({type:"unknown"})}function po(e,t){return new e({type:"never",...d(t)})}function Ce(e,t){return new it({check:"less_than",...d(t),value:e,inclusive:!1})}function oe(e,t){return new it({check:"less_than",...d(t),value:e,inclusive:!0})}function Re(e,t){return new st({check:"greater_than",...d(t),value:e,inclusive:!1})}function ie(e,t){return new st({check:"greater_than",...d(t),value:e,inclusive:!0})}function De(e,t){return new En({check:"multiple_of",...d(t),value:e})}function dt(e,t){return new Tn({check:"max_length",...d(t),maximum:e})}function X(e,t){return new Nn({check:"min_length",...d(t),minimum:e})}function pt(e,t){return new jn({check:"length_equals",...d(t),length:e})}function ho(e,t){return new An({check:"string_format",format:"regex",...d(t),pattern:e})}function mo(e){return new Cn({check:"string_format",format:"lowercase",...d(e)})}function _o(e){return new Rn({check:"string_format",format:"uppercase",...d(e)})}function go(e,t){return new Dn({check:"string_format",format:"includes",...d(t),includes:e})}function vo(e,t){return new xn({check:"string_format",format:"starts_with",...d(t),prefix:e})}function bo(e,t){return new Un({check:"string_format",format:"ends_with",...d(t),suffix:e})}function x(e){return new Mn({check:"overwrite",tx:e})}function zo(e){return x(t=>t.normalize(e))}function yo(){return x(e=>e.trim())}function wo(){return x(e=>e.toLowerCase())}function ko(){return x(e=>e.toUpperCase())}function $o(){return x(e=>Pt(e))}function Zo(e,t,n){return new e({type:"array",element:t,...d(n)})}function So(e,t,n){return new e({type:"custom",check:"custom",fn:t,...d(n)})}function Oo(e,t){const n=Io(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(L(o,r.value,n._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(L(s))}},e(r.value,r)),t);return n}function Io(e,t){const n=new O({check:"custom",...d(t)});return n._zod.check=e,n}function ht(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??F,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Z(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,f);else{const m=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,m,f)}const h=e._zod.parent;h&&(i.ref||(i.ref=h),Z(h,t,f),t.seen.get(h).isParent=!0)}const a=t.metadataRegistry.get(e);return a&&Object.assign(i.schema,a),t.io==="input"&&S(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function mt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const a=r.get(c);if(a&&a!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,i[0])}}const o=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(i[0])?.id,m=e.external.uri??(g=>g);if(h)return{ref:m(h)};const p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${m("__shared")}#/${c}/${p}`}}if(i[1]===n)return{ref:"#"};const l=`#/${c}/`,f=i[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:l+f}},s=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:a,defId:l}=o(i);c.def={...c.schema},l&&(c.defId=l);const f=c.schema;for(const h in f)delete f[h];f.$ref=a};if(e.cycles==="throw")for(const i of e.seen.entries()){const c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
63
|
+
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){s(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1&&e.reused==="ref"){s(i);continue}}}function _t(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const a=e.seen.get(c);if(a.ref===null)return;const l=a.def??a.schema,f={...l},h=a.ref;if(a.ref=null,h){r(h);const p=e.seen.get(h),g=p.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):Object.assign(l,g),Object.assign(l,f),c._zod.parent===h)for(const k in l)k==="$ref"||k==="allOf"||k in f||delete l[k];if(g.$ref&&p.def)for(const k in l)k==="$ref"||k==="allOf"||k in p.def&&JSON.stringify(l[k])===JSON.stringify(p.def[k])&&delete l[k]}const m=c._zod.parent;if(m&&m!==h){r(m);const p=e.seen.get(m);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(const g in l)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(l[g])===JSON.stringify(p.def[g])&&delete l[g]}e.override({zodSchema:c,jsonSchema:l,path:a.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}Object.assign(o,n.def??n.schema);const s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;const i=e.external?.defs??{};for(const c of e.seen.entries()){const a=c[1];a.def&&a.defId&&(a.def.id===a.defId&&delete a.def.id,i[a.defId]=a.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:H(t,"input",e.processors),output:H(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function S(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return S(r.element,n);if(r.type==="set")return S(r.valueType,n);if(r.type==="lazy")return S(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return S(r.innerType,n);if(r.type==="intersection")return S(r.left,n)||S(r.right,n);if(r.type==="record"||r.type==="map")return S(r.keyType,n)||S(r.valueType,n);if(r.type==="pipe")return S(r.in,n)||S(r.out,n);if(r.type==="object"){for(const o in r.shape)if(S(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(S(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(S(o,n))return!0;return!!(r.rest&&S(r.rest,n))}return!1}const Eo=(e,t={})=>n=>{const r=ht({...n,processors:t});return Z(e,r),mt(r,e),_t(r,e)},H=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=ht({...o??{},target:s,io:t,processors:n});return Z(e,i),mt(i,e),_t(i,e)},Po={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},To=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:l}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),c&&(o.format=Po[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),l&&(o.contentEncoding=l),a&&a.size>0){const f=[...a];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},No=(e,t,n,r)=>{const o=n,{minimum:s,maximum:i,format:c,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const h=typeof f=="number"&&f>=(s??Number.NEGATIVE_INFINITY),m=typeof l=="number"&&l<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";h?p?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof s=="number"&&(o.minimum=s),m?p?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l:typeof i=="number"&&(o.maximum=i),typeof a=="number"&&(o.multipleOf=a)},jo=(e,t,n,r)=>{n.type="boolean"},Ao=(e,t,n,r)=>{n.not={}},Co=(e,t,n,r)=>{},Ro=(e,t,n,r)=>{const o=e._zod.def,s=Ke(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Do=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},xo=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Uo=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=Z(s.element,t,{...r,path:[...r.path,"items"]})},Mo=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const l in i)o.properties[l]=Z(i[l],t,{...r,path:[...r.path,"properties",l]});const c=new Set(Object.keys(i)),a=new Set([...c].filter(l=>{const f=s.shape[l]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));a.size>0&&(o.required=Array.from(a)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Z(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Fo=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>Z(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",a]}));s?n.oneOf=i:n.anyOf=i},Jo=(e,t,n,r)=>{const o=e._zod.def,s=Z(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Z(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=l=>"allOf"in l&&Object.keys(l).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];n.allOf=a},Lo=(e,t,n,r)=>{const o=e._zod.def,s=Z(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Vo=(e,t,n,r)=>{const o=e._zod.def;Z(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Bo=(e,t,n,r)=>{const o=e._zod.def;Z(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Wo=(e,t,n,r)=>{const o=e._zod.def;Z(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Go=(e,t,n,r)=>{const o=e._zod.def;Z(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},Ko=(e,t,n,r)=>{const o=e._zod.def,s=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Z(s,t,r);const i=t.seen.get(e);i.ref=s},qo=(e,t,n,r)=>{const o=e._zod.def;Z(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},gt=(e,t,n,r)=>{const o=e._zod.def;Z(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Yo=u("ZodISODateTime",(e,t)=>{er.init(e,t),b.init(e,t)});function Xo(e){return oo(Yo,e)}const Ho=u("ZodISODate",(e,t)=>{tr.init(e,t),b.init(e,t)});function Qo(e){return io(Ho,e)}const ei=u("ZodISOTime",(e,t)=>{nr.init(e,t),b.init(e,t)});function ti(e){return so(ei,e)}const ni=u("ZodISODuration",(e,t)=>{rr.init(e,t),b.init(e,t)});function ri(e){return co(ni,e)}const oi=(e,t)=>{Qe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Vt(e,n)},flatten:{value:n=>Lt(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ce,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ce,2)}},isEmpty:{get(){return e.issues.length===0}}})},E=u("ZodError",oi,{Parent:Error}),ii=me(E),si=_e(E),ci=ee(E),ui=te(E),ai=Gt(E),li=Kt(E),fi=qt(E),di=Yt(E),pi=Xt(E),hi=Ht(E),mi=Qt(E),_i=en(E),xe=new WeakMap;function V(e,t,n){const r=Object.getPrototypeOf(e);let o=xe.get(r);if(o||(o=new Set,xe.set(r,o)),!o.has(t)){o.add(t);for(const s in n){const i=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){const c=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}}const w=u("ZodType",(e,t)=>(y.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:H(e,"input"),output:H(e,"output")}}),e.toJSONSchema=Eo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>ii(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>ci(e,n,r),e.parseAsync=async(n,r)=>si(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>ui(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>ai(e,n,r),e.decode=(n,r)=>li(e,n,r),e.encodeAsync=async(n,r)=>fi(e,n,r),e.decodeAsync=async(n,r)=>di(e,n,r),e.safeEncode=(n,r)=>pi(e,n,r),e.safeDecode=(n,r)=>hi(e,n,r),e.safeEncodeAsync=async(n,r)=>mi(e,n,r),e.safeDecodeAsync=async(n,r)=>_i(e,n,r),V(e,"ZodType",{check(...n){const r=this.def;return this.clone(T(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return N(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(fs(n,r))},superRefine(n,r){return this.check(ds(n,r))},overwrite(n){return this.check(x(n))},optional(){return Je(this)},exactOptional(){return Hi(this)},nullable(){return Le(this)},nullish(){return Je(Le(this))},nonoptional(n){return os(this,n)},array(){return Li(this)},or(n){return Wi([this,n])},and(n){return Ki(this,n)},transform(n){return Ve(this,Yi(n))},default(n){return ts(this,n)},prefault(n){return rs(this,n)},catch(n){return ss(this,n)},pipe(n){return Ve(this,n)},readonly(){return as(this)},describe(n){const r=this.clone();return F.add(r,{description:n}),r},meta(...n){if(n.length===0)return F.get(this);const r=this.clone();return F.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return F.get(e)?.description},configurable:!0}),e)),vt=u("_ZodString",(e,t)=>{ge.init(e,t),w.init(e,t),e._zod.processJSONSchema=(r,o,s)=>To(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,V(e,"_ZodString",{regex(...r){return this.check(ho(...r))},includes(...r){return this.check(go(...r))},startsWith(...r){return this.check(vo(...r))},endsWith(...r){return this.check(bo(...r))},min(...r){return this.check(X(...r))},max(...r){return this.check(dt(...r))},length(...r){return this.check(pt(...r))},nonempty(...r){return this.check(X(1,...r))},lowercase(r){return this.check(mo(r))},uppercase(r){return this.check(_o(r))},trim(){return this.check(yo())},normalize(...r){return this.check(zo(...r))},toLowerCase(){return this.check(wo())},toUpperCase(){return this.check(ko())},slugify(){return this.check($o())}})}),gi=u("ZodString",(e,t)=>{ge.init(e,t),vt.init(e,t),e.email=n=>e.check(Dr(bi,n)),e.url=n=>e.check(Jr(zi,n)),e.jwt=n=>e.check(ro(Ci,n)),e.emoji=n=>e.check(Lr(yi,n)),e.guid=n=>e.check(Ae(Ue,n)),e.uuid=n=>e.check(xr(G,n)),e.uuidv4=n=>e.check(Ur(G,n)),e.uuidv6=n=>e.check(Mr(G,n)),e.uuidv7=n=>e.check(Fr(G,n)),e.nanoid=n=>e.check(Vr(wi,n)),e.guid=n=>e.check(Ae(Ue,n)),e.cuid=n=>e.check(Br(ki,n)),e.cuid2=n=>e.check(Wr($i,n)),e.ulid=n=>e.check(Gr(Zi,n)),e.base64=n=>e.check(eo(Ni,n)),e.base64url=n=>e.check(to(ji,n)),e.xid=n=>e.check(Kr(Si,n)),e.ksuid=n=>e.check(qr(Oi,n)),e.ipv4=n=>e.check(Yr(Ii,n)),e.ipv6=n=>e.check(Xr(Ei,n)),e.cidrv4=n=>e.check(Hr(Pi,n)),e.cidrv6=n=>e.check(Qr(Ti,n)),e.e164=n=>e.check(no(Ai,n)),e.datetime=n=>e.check(Xo(n)),e.date=n=>e.check(Qo(n)),e.time=n=>e.check(ti(n)),e.duration=n=>e.check(ri(n))});function vi(e){return Rr(gi,e)}const b=u("ZodStringFormat",(e,t)=>{v.init(e,t),vt.init(e,t)}),bi=u("ZodEmail",(e,t)=>{Bn.init(e,t),b.init(e,t)}),Ue=u("ZodGUID",(e,t)=>{Ln.init(e,t),b.init(e,t)}),G=u("ZodUUID",(e,t)=>{Vn.init(e,t),b.init(e,t)}),zi=u("ZodURL",(e,t)=>{Wn.init(e,t),b.init(e,t)}),yi=u("ZodEmoji",(e,t)=>{Gn.init(e,t),b.init(e,t)}),wi=u("ZodNanoID",(e,t)=>{Kn.init(e,t),b.init(e,t)}),ki=u("ZodCUID",(e,t)=>{qn.init(e,t),b.init(e,t)}),$i=u("ZodCUID2",(e,t)=>{Yn.init(e,t),b.init(e,t)}),Zi=u("ZodULID",(e,t)=>{Xn.init(e,t),b.init(e,t)}),Si=u("ZodXID",(e,t)=>{Hn.init(e,t),b.init(e,t)}),Oi=u("ZodKSUID",(e,t)=>{Qn.init(e,t),b.init(e,t)}),Ii=u("ZodIPv4",(e,t)=>{or.init(e,t),b.init(e,t)}),Ei=u("ZodIPv6",(e,t)=>{ir.init(e,t),b.init(e,t)}),Pi=u("ZodCIDRv4",(e,t)=>{sr.init(e,t),b.init(e,t)}),Ti=u("ZodCIDRv6",(e,t)=>{cr.init(e,t),b.init(e,t)}),Ni=u("ZodBase64",(e,t)=>{ur.init(e,t),b.init(e,t)}),ji=u("ZodBase64URL",(e,t)=>{lr.init(e,t),b.init(e,t)}),Ai=u("ZodE164",(e,t)=>{fr.init(e,t),b.init(e,t)}),Ci=u("ZodJWT",(e,t)=>{pr.init(e,t),b.init(e,t)}),bt=u("ZodNumber",(e,t)=>{ut.init(e,t),w.init(e,t),e._zod.processJSONSchema=(r,o,s)=>No(e,r,o),V(e,"ZodNumber",{gt(r,o){return this.check(Re(r,o))},gte(r,o){return this.check(ie(r,o))},min(r,o){return this.check(ie(r,o))},lt(r,o){return this.check(Ce(r,o))},lte(r,o){return this.check(oe(r,o))},max(r,o){return this.check(oe(r,o))},int(r){return this.check(Me(r))},safe(r){return this.check(Me(r))},positive(r){return this.check(Re(0,r))},nonnegative(r){return this.check(ie(0,r))},negative(r){return this.check(Ce(0,r))},nonpositive(r){return this.check(oe(0,r))},multipleOf(r,o){return this.check(De(r,o))},step(r,o){return this.check(De(r,o))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ri(e){return uo(bt,e)}const Di=u("ZodNumberFormat",(e,t)=>{hr.init(e,t),bt.init(e,t)});function Me(e){return ao(Di,e)}const xi=u("ZodBoolean",(e,t)=>{mr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jo(e,n,r)});function Ui(e){return lo(xi,e)}const Mi=u("ZodUnknown",(e,t)=>{_r.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Co()});function Fe(){return fo(Mi)}const Fi=u("ZodNever",(e,t)=>{gr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ao(e,n,r)});function zt(e){return po(Fi,e)}const Ji=u("ZodArray",(e,t)=>{vr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Uo(e,n,r,o),e.element=t.element,V(e,"ZodArray",{min(n,r){return this.check(X(n,r))},nonempty(n){return this.check(X(1,n))},max(n,r){return this.check(dt(n,r))},length(n,r){return this.check(pt(n,r))},unwrap(){return this.element}})});function Li(e,t){return Zo(Ji,e,t)}const Vi=u("ZodObject",(e,t)=>{zr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mo(e,n,r,o),_(e,"shape",()=>t.shape),V(e,"ZodObject",{keyof(){return yt(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Fe()})},loose(){return this.clone({...this._zod.def,catchall:Fe()})},strict(){return this.clone({...this._zod.def,catchall:zt()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Dt(this,n)},safeExtend(n){return xt(this,n)},merge(n){return Ut(this,n)},pick(n){return Ct(this,n)},omit(n){return Rt(this,n)},partial(...n){return Mt(wt,this,n[0])},required(...n){return Ft(kt,this,n[0])}})});function ve(e,t){return new Vi({type:"object",shape:e,catchall:zt(),...d(t)})}const Bi=u("ZodUnion",(e,t)=>{yr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fo(e,n,r,o),e.options=t.options});function Wi(e,t){return new Bi({type:"union",options:e,...d(t)})}const Gi=u("ZodIntersection",(e,t)=>{wr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jo(e,n,r,o)});function Ki(e,t){return new Gi({type:"intersection",left:e,right:t})}const ae=u("ZodEnum",(e,t)=>{kr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Ro(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ae({...t,checks:[],...d(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ae({...t,checks:[],...d(o),entries:s})}});function yt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ae({type:"enum",entries:n,...d(t)})}const qi=u("ZodTransform",(e,t)=>{$r.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xo(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ge(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(L(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(L(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function Yi(e){return new qi({type:"transform",transform:e})}const wt=u("ZodOptional",(e,t)=>{ft.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gt(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Je(e){return new wt({type:"optional",innerType:e})}const Xi=u("ZodExactOptional",(e,t)=>{Zr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gt(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Hi(e){return new Xi({type:"optional",innerType:e})}const Qi=u("ZodNullable",(e,t)=>{Sr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Le(e){return new Qi({type:"nullable",innerType:e})}const es=u("ZodDefault",(e,t)=>{Or.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ts(e,t){return new es({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ye(t)}})}const ns=u("ZodPrefault",(e,t)=>{Ir.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function rs(e,t){return new ns({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ye(t)}})}const kt=u("ZodNonOptional",(e,t)=>{Er.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function os(e,t){return new kt({type:"nonoptional",innerType:e,...d(t)})}const is=u("ZodCatch",(e,t)=>{Pr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Go(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ss(e,t){return new is({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const cs=u("ZodPipe",(e,t)=>{Tr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ko(e,n,r,o),e.in=t.in,e.out=t.out});function Ve(e,t){return new cs({type:"pipe",in:e,out:t})}const us=u("ZodReadonly",(e,t)=>{Nr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function as(e){return new us({type:"readonly",innerType:e})}const ls=u("ZodCustom",(e,t)=>{jr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Do(e,n)});function fs(e,t={}){return So(ls,e,t)}function ds(e,t){return Oo(e,t)}const ps="opencode-bmad-plugin",$t=yt(["repository","tencentdb"]),Be=ve({}),We=ve({storage:$t,tencentdbAvailable:Ui(),project:vi(),skills:Ri().int()}),Zt=It.Rpc.define({id:ps,methods:{status:{input:Be,output:We},setStorage:{input:ve({storage:$t}),output:We,errors:{bmad_error:Be}}},events:{}});var hs=I.template("<p role=alert>");async function ms(e){return e.client.rpc(Zt).status({})}const se=new WeakMap;function _s(){const e=K.usePlugin(),t=e.ui,[n,{mutate:r,refetch:o}]=M.createResource(async()=>{const f=await ms(e);return se.set(e,f),f},{initialValue:se.get(e)}),[s,i]=M.createSignal(!1),[c,a]=M.createSignal("");async function l(f){i(!0),a("");try{const h=await e.client.rpc(Zt).setStorage({storage:f});se.set(e,h),r(h)}catch(h){a(h instanceof Error?h.message:String(h))}finally{i(!1)}}return I.createComponent(t.SettingsLayout,{title:"BMAD Method",description:"Global BMAD skills for every OpenCode project. Choose where project artifacts are stored.",get actions(){return I.createComponent(t.Button,{onClick:()=>{o()},children:"Refresh"})},get children(){return[I.createComponent(M.Show,{get when(){return n.error||c()},get children(){var f=hs();return I.insert(f,()=>c()||(n.error instanceof Error?n.error.message:"Could not load BMAD settings.")),f}}),I.createComponent(M.Show,{get when(){return n()},children:f=>I.createComponent(t.SettingsSection,{title:"Artifact storage",get footer(){return`${f().skills} global skills available`},get children(){return[I.createComponent(t.SettingsRow,{title:"Repository Markdown",description:"Default. Save BMAD artifacts in _bmad-output/ in each repository.",get children(){return I.createComponent(t.Button,{get variant(){return f().storage==="repository"?"contrast":void 0},get disabled(){return s()||f().storage==="repository"},onClick:()=>{l("repository")},get children(){return f().storage==="repository"?"Selected":"Use repository"}})}}),I.createComponent(t.SettingsRow,{title:"TencentDB",get description(){return f().tencentdbAvailable?"Save artifacts in this project's TencentDB document scope.":"Install and activate opencode-tencentdb-plugin to enable this option."},get children(){return I.createComponent(t.Button,{get variant(){return f().storage==="tencentdb"?"contrast":void 0},get disabled(){return s()||!f().tencentdbAvailable||f().storage==="tencentdb"},onClick:()=>{l("tencentdb")},get children(){return f().storage==="tencentdb"?"Selected":"Use TencentDB"}})}})]}})})]}})}const gs=K.Plugin.define({setup(e){e.add(K.SettingsPage,{id:"bmad",title:"BMAD Method",icon:"file-tree",render:()=>I.createComponent(_s,{})}),e.add(K.Command,{id:"settings",title:"Open BMAD Settings",run:()=>e.layout.settings("bmad")})}});exports.default=gs;
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morozinc/opencode-bmad-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Global BMAD Method skills and configurable artifact storage for OpenCode V2.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "git+https://github.com/ShiftHackZ/opencode-bmad-plugin.git",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"opencode",
|
|
9
|
+
"opencode-plugin",
|
|
10
|
+
"bmad"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org/"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./src/index.ts",
|
|
19
|
+
"./gui-experimental": "./dist/gui-experimental.cjs",
|
|
20
|
+
"./rpc": "./src/rpc.ts"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"docs/screenshots",
|
|
24
|
+
"src",
|
|
25
|
+
"dist",
|
|
26
|
+
"skills",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"NOTICE.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "vite build",
|
|
33
|
+
"check": "tsc --noEmit",
|
|
34
|
+
"test": "node --import tsx tests/opencode-smoke.mjs",
|
|
35
|
+
"prepack": "npm run check && npm run build"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@opencode/plugin": "2.4.3",
|
|
39
|
+
"effect": "4.1.0",
|
|
40
|
+
"zod": "4.4.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@opencode/client": "2.4.3",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"solid-js": "^1.9.0",
|
|
46
|
+
"tsx": "^4.21.0",
|
|
47
|
+
"typescript": "^5.9.0",
|
|
48
|
+
"vite": "^7.0.0",
|
|
49
|
+
"vite-plugin-solid": "^2.11.0",
|
|
50
|
+
"prettier": "^3.7.0"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=22.20.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bmad-code-review
|
|
3
|
+
description: 'Review code changes adversarially using parallel review layers (Blind Hunter, Edge Case Hunter, Acceptance Auditor) with structured triage into actionable categories. Use when the user says "run code review" or "review this code"'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bmad-code-review · OpenCode edition
|
|
7
|
+
|
|
8
|
+
## Artifact storage
|
|
9
|
+
|
|
10
|
+
Use the **BMAD artifact storage** contract injected by the OpenCode BMAD plugin for this project. It names the selected backend, project root and exact artifact prefix. Call `bmad_storage` if the contract is missing or you need to refresh it. Read existing artifacts before editing, write complete Markdown, then read back and verify. Keep each artifact's logical name stable. Do not switch storage backends silently. The plugin is installed globally; project artifacts are scoped to the current repository. Source code changes remain in the repository. Bundled references may mention upstream project-local `_bmad` setup, config or scripts; use their methodology without requiring those files in the project. The selected storage contract overrides artifact paths in references.
|
|
11
|
+
|
|
12
|
+
## Workflow
|
|
13
|
+
|
|
14
|
+
1. Establish the diff or files under review and retrieve their requirements, architecture and relevant prior decisions. Reuse the requested review/change ID.
|
|
15
|
+
2. Inspect correctness, edge cases and acceptance coverage. Use independent blind, edge-case and acceptance reviewers when useful; give each the scoped artifact paths and storage protocol.
|
|
16
|
+
3. Triage findings against actual code evidence: include file/line, failure scenario, impact and a concrete remedy. Separate verified bugs, uncertainty and deferred risks; omit speculative noise.
|
|
17
|
+
4. Save the full review and report the actionable findings. Do not mark a requirement verified without evidence; apply fixes only when requested or already authorized.
|
|
18
|
+
|
|
19
|
+
**Primary artifact:** `reviews/<review-id>.md`. Use a stable descriptive `<story-id>`, `<review-id>` or `<change-id>` where shown, and return its full verified artifact path.
|
|
20
|
+
|
|
21
|
+
## Optional method references
|
|
22
|
+
|
|
23
|
+
Read only the template or checklist needed for the current step, relative to this skill directory: `reference/steps/step-02-review.md`; `reference/steps/step-03-triage.md`. The references preserve upstream methodology; their filesystem writes, activation scripts and local artifact discovery are replaced by the BMAD artifact storage contract above. Do not load the entire upstream workflow or unrelated artifacts.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bmad-code-review
|
|
3
|
+
description: 'Review code changes adversarially using parallel review layers (Blind Hunter, Edge Case Hunter, Acceptance Auditor) with structured triage into actionable categories. Use when the user says "run code review" or "review this code"'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Review Workflow
|
|
7
|
+
|
|
8
|
+
**Goal:** Review code changes adversarially using parallel review layers and structured triage.
|
|
9
|
+
|
|
10
|
+
**Your Role:** You are an elite code reviewer. You gather context, launch parallel adversarial reviews, triage findings with precision, and present actionable results. No noise, no filler.
|
|
11
|
+
|
|
12
|
+
## Conventions
|
|
13
|
+
|
|
14
|
+
- Bare paths (e.g. `checklist.md`) resolve from the skill root.
|
|
15
|
+
- `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives).
|
|
16
|
+
- `{project-root}`-prefixed paths resolve from the project working directory.
|
|
17
|
+
- `{skill-name}` resolves to the skill directory's basename.
|
|
18
|
+
|
|
19
|
+
## On Activation
|
|
20
|
+
|
|
21
|
+
### Step 1: Resolve the Workflow Block
|
|
22
|
+
|
|
23
|
+
Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow`
|
|
24
|
+
|
|
25
|
+
**If the script fails**, resolve the `workflow` block yourself by reading these three files in base → team → user order and applying the same structural merge rules as the resolver:
|
|
26
|
+
|
|
27
|
+
1. `{skill-root}/customize.toml` — defaults
|
|
28
|
+
2. `{project-root}/_bmad/custom/{skill-name}.toml` — team overrides
|
|
29
|
+
3. `{project-root}/_bmad/custom/{skill-name}.user.toml` — personal overrides
|
|
30
|
+
|
|
31
|
+
Any missing file is skipped. Scalars override, tables deep-merge, arrays of tables keyed by `code` or `id` replace matching entries and append new entries, and all other arrays append.
|
|
32
|
+
|
|
33
|
+
### Step 2: Execute Prepend Steps
|
|
34
|
+
|
|
35
|
+
Execute each entry in `{workflow.activation_steps_prepend}` in order before proceeding.
|
|
36
|
+
|
|
37
|
+
### Step 3: Load Persistent Facts
|
|
38
|
+
|
|
39
|
+
Treat every entry in `{workflow.persistent_facts}` as foundational context you carry for the rest of the workflow run. Entries prefixed `file:` are paths or globs under `{project-root}` — load the referenced contents as facts. All other entries are facts verbatim.
|
|
40
|
+
|
|
41
|
+
### Step 4: Load Config
|
|
42
|
+
|
|
43
|
+
Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve:
|
|
44
|
+
|
|
45
|
+
- `project_name`, `planning_artifacts`, `implementation_artifacts`, `user_name`
|
|
46
|
+
- `communication_language`, `document_output_language`, `user_skill_level`
|
|
47
|
+
- `date` as system-generated current datetime
|
|
48
|
+
- `sprint_status` = `{implementation_artifacts}/sprint-status.yaml`
|
|
49
|
+
- `project_context` = `**/project-context.md` (load if exists)
|
|
50
|
+
- CLAUDE.md / memory files (load if exist)
|
|
51
|
+
- YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
|
|
52
|
+
|
|
53
|
+
### Step 5: Greet the User
|
|
54
|
+
|
|
55
|
+
Greet `{user_name}`, speaking in `{communication_language}`.
|
|
56
|
+
|
|
57
|
+
### Step 6: Execute Append Steps
|
|
58
|
+
|
|
59
|
+
Execute each entry in `{workflow.activation_steps_append}` in order.
|
|
60
|
+
|
|
61
|
+
Activation is complete. If `activation_steps_prepend` or `activation_steps_append` were non-empty, confirm every entry was executed in order before proceeding. Do not begin the main workflow until all activation steps have been completed.
|
|
62
|
+
|
|
63
|
+
## WORKFLOW ARCHITECTURE
|
|
64
|
+
|
|
65
|
+
This uses **step-file architecture** for disciplined execution:
|
|
66
|
+
|
|
67
|
+
- **Micro-file Design**: Each step is self-contained and followed exactly
|
|
68
|
+
- **Just-In-Time Loading**: Only load the current step file
|
|
69
|
+
- **Sequential Enforcement**: Complete steps in order, no skipping
|
|
70
|
+
- **State Tracking**: Persist progress via in-memory variables
|
|
71
|
+
- **Append-Only Building**: Build artifacts incrementally
|
|
72
|
+
|
|
73
|
+
### Step Processing Rules
|
|
74
|
+
|
|
75
|
+
1. **READ COMPLETELY**: Read the entire step file before acting
|
|
76
|
+
2. **FOLLOW SEQUENCE**: Execute sections in order
|
|
77
|
+
3. **WAIT FOR INPUT**: Halt at checkpoints and wait for human
|
|
78
|
+
4. **LOAD NEXT**: When directed, read fully and follow the next step file
|
|
79
|
+
|
|
80
|
+
### Critical Rules (NO EXCEPTIONS)
|
|
81
|
+
|
|
82
|
+
- **NEVER** load multiple step files simultaneously
|
|
83
|
+
- **ALWAYS** read entire step file before execution
|
|
84
|
+
- **NEVER** skip steps or optimize the sequence
|
|
85
|
+
- **ALWAYS** follow the exact instructions in the step file
|
|
86
|
+
- **ALWAYS** halt at checkpoints and wait for human input
|
|
87
|
+
|
|
88
|
+
## FIRST STEP
|
|
89
|
+
|
|
90
|
+
Read fully and follow: `./steps/step-01-gather-context.md`
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# DO NOT EDIT -- overwritten on every update.
|
|
2
|
+
#
|
|
3
|
+
# Workflow customization surface for bmad-code-review. Mirrors the
|
|
4
|
+
# agent customization shape under the [workflow] namespace.
|
|
5
|
+
|
|
6
|
+
[workflow]
|
|
7
|
+
|
|
8
|
+
# --- Configurable below. Overrides merge per BMad structural rules: ---
|
|
9
|
+
# scalars: override wins • arrays (persistent_facts, activation_steps_*): append
|
|
10
|
+
# arrays-of-tables with `code`/`id`: replace matching items, append new ones.
|
|
11
|
+
|
|
12
|
+
# Steps to run before the standard activation (config load, greet).
|
|
13
|
+
# Overrides append. Use for pre-flight loads, compliance checks, etc.
|
|
14
|
+
|
|
15
|
+
activation_steps_prepend = []
|
|
16
|
+
|
|
17
|
+
# Steps to run after greet but before the workflow begins.
|
|
18
|
+
# Overrides append. Use for context-heavy setup that should happen
|
|
19
|
+
# once the user has been acknowledged.
|
|
20
|
+
|
|
21
|
+
activation_steps_append = []
|
|
22
|
+
|
|
23
|
+
# Persistent facts the workflow keeps in mind for the whole run
|
|
24
|
+
# (standards, compliance constraints, stylistic guardrails).
|
|
25
|
+
# Distinct from the runtime memory sidecar — these are static context
|
|
26
|
+
# loaded on activation. Overrides append.
|
|
27
|
+
#
|
|
28
|
+
# Each entry is either:
|
|
29
|
+
# - a literal sentence, e.g. "All stories must include testable acceptance criteria."
|
|
30
|
+
# - a file reference prefixed with `file:`, e.g. "file:{project-root}/docs/standards.md"
|
|
31
|
+
# (glob patterns are supported; the file's contents are loaded and treated as facts).
|
|
32
|
+
|
|
33
|
+
persistent_facts = [
|
|
34
|
+
"file:{project-root}/**/project-context.md",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
# Scalar: executed when the workflow reaches its final step,
|
|
38
|
+
# after review findings are presented and sprint status is synced. Override wins.
|
|
39
|
+
# Leave empty for no custom post-completion behavior.
|
|
40
|
+
|
|
41
|
+
on_complete = ""
|