@u-devtools/core 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Universal DevTools Kit Contributors
3
+ Copyright (c) 2024 Universal DevTools Kit
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @u-devtools/core
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@u-devtools/core/latest?style=for-the-badge)](https://www.npmjs.com/package/@u-devtools/core)
4
+ [![npm downloads](https://img.shields.io/npm/dw/@u-devtools/core?style=for-the-badge)](https://www.npmjs.com/package/@u-devtools/core)
5
+ [![License](https://img.shields.io/npm/l/@u-devtools/core?style=for-the-badge)](https://www.npmjs.com/package/@u-devtools/core)
6
+ [![Donate](https://img.shields.io/badge/Donate-Donationalerts-ff4081?style=for-the-badge)](https://www.donationalerts.com/r/s00d88)
7
+
8
+ Core types and interfaces for Universal DevTools Kit. This package provides the foundational TypeScript types, interfaces, and utilities used throughout the DevTools ecosystem.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @u-devtools/core
14
+ # or
15
+ pnpm add @u-devtools/core
16
+ # or
17
+ yarn add @u-devtools/core
18
+ ```
19
+
20
+ ## What's Included
21
+
22
+ ### Type Definitions
23
+
24
+ - **RPC Interfaces** - Types for client-server communication
25
+ - **Plugin Interfaces** - Types for creating DevTools plugins
26
+ - **API Interfaces** - Types for ClientApi, StorageApi, SettingsApi, etc.
27
+ - **Utility Types** - Common types used across the ecosystem
28
+
29
+ ### Core Classes
30
+
31
+ - **AppBridge** - Typed communication bridge between App context and Client context
32
+ - **SyncedState** - Universal state synchronization class with React `useSyncExternalStore` support
33
+ - **Control** - DevTools control utilities
34
+
35
+ ### Vite Configuration
36
+
37
+ - **vite.config.base** - Base Vite configuration for building DevTools packages
38
+
39
+ ## Usage
40
+
41
+ ### Importing Types
42
+
43
+ ```ts
44
+ import type {
45
+ DevToolsPlugin,
46
+ PluginClientInstance,
47
+ ClientApi,
48
+ RpcServerInterface,
49
+ ServerContext,
50
+ } from '@u-devtools/core';
51
+ ```
52
+
53
+ ### Using AppBridge with Typed Protocol
54
+
55
+ ```ts
56
+ import { AppBridge } from '@u-devtools/core';
57
+
58
+ // Define your protocol
59
+ interface MyPluginProtocol {
60
+ 'element-selected': (data: { id: string }) => void;
61
+ 'toggle-inspector': (data: { state: boolean }) => void;
62
+ }
63
+
64
+ // Create typed bridge
65
+ const bridge = new AppBridge<MyPluginProtocol>('my-plugin');
66
+
67
+ // ✅ Full type safety
68
+ bridge.send('element-selected', { id: 'el-1' });
69
+ bridge.on('toggle-inspector', ({ state }) => {
70
+ // state is automatically typed as { state: boolean }
71
+ });
72
+ ```
73
+
74
+ ### Using SyncedState
75
+
76
+ ```ts
77
+ import { AppBridge, SyncedState } from '@u-devtools/core';
78
+
79
+ const bridge = new AppBridge('my-plugin');
80
+
81
+ // Create synced state
82
+ const isOpen = bridge.state('isOpen', false);
83
+
84
+ // Read value
85
+ console.log(isOpen.value);
86
+
87
+ // Update value (automatically syncs)
88
+ isOpen.value = true;
89
+
90
+ // Subscribe to changes
91
+ const unsub = isOpen.subscribe((val) => {
92
+ console.log('Changed:', val);
93
+ });
94
+
95
+ // Use with React useSyncExternalStore
96
+ import { useSyncExternalStore } from 'react';
97
+ const enabled = useSyncExternalStore(
98
+ isOpen.subscribe,
99
+ isOpen.getSnapshot
100
+ );
101
+ ```
102
+
103
+ ### Using Vite Config Base
104
+
105
+ ```ts
106
+ import { createViteConfig } from '@u-devtools/core/vite.config.base';
107
+
108
+ export default createViteConfig({
109
+ name: 'MyPackage',
110
+ entry: 'src/index.ts',
111
+ dir: __dirname,
112
+ // ... other options
113
+ });
114
+ ```
115
+
116
+ ## License
117
+
118
+ MIT
119
+
package/dist/index.cjs.js CHANGED
@@ -1 +1,46 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r{constructor(e){this.namespace=e,this.listeners=new Map,this.channel=new BroadcastChannel(`u-devtools:${e}`),this.channel.onmessage=t=>{const{event:s,data:i}=t.data,o=this.listeners.get(s);o&&o.forEach(l=>{l(i)})}}send(e,t){try{this.channel.postMessage({event:e,data:t})}catch(s){if(s instanceof DOMException&&(s.name==="InvalidStateError"||s.message?.includes("closed"))){console.warn(`[AppBridge] Cannot send event "${e}": channel is closed`);return}throw s}}on(e,t){const s=String(e);this.listeners.has(s)||this.listeners.set(s,new Set);const i=this.listeners.get(s),o=t;return i&&i.add(o),()=>{this.listeners.get(s)?.delete(o)}}close(){this.channel.close(),this.listeners.clear()}}const a="u-devtools:register-menu-item";function h(n){if(typeof window>"u")return;window.__UDEVTOOLS_MENU_ITEMS__||(window.__UDEVTOOLS_MENU_ITEMS__=[]);const e=window.__UDEVTOOLS_MENU_ITEMS__.findIndex(t=>t.id===n.id);e!==-1?window.__UDEVTOOLS_MENU_ITEMS__[e]=n:window.__UDEVTOOLS_MENU_ITEMS__.push(n),window.dispatchEvent(new CustomEvent(a,{detail:n}))}class c{constructor(){this.channel=new BroadcastChannel("u-devtools:control")}open(){this.channel.postMessage({action:"open"})}close(){this.channel.postMessage({action:"close"})}toggle(){this.channel.postMessage({action:"toggle"})}isOpen(){return new Promise(e=>{const t=s=>{s.data?.type==="u-devtools:state-response"&&(this.channel.removeEventListener("message",t),e(s.data.isOpen))};this.channel.addEventListener("message",t),this.channel.postMessage({action:"get-state"}),setTimeout(()=>{this.channel.removeEventListener("message",t),e(!1)},200)})}onStateChange(e){const t=s=>{s.data?.type==="u-devtools:state-changed"&&e(s.data.isOpen)};return this.channel.addEventListener("message",t),()=>this.channel.removeEventListener("message",t)}switchPlugin(e){this.channel.postMessage({action:"switch-plugin",pluginName:e})}switchTab(e,t){this.channel.postMessage({action:"switch-tab",pluginName:e,tabName:t})}destroy(){this.channel.close()}}const d=new c;exports.AppBridge=r;exports.DevToolsControl=c;exports.OVERLAY_EVENT=a;exports.devtools=d;exports.registerMenuItem=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _t=require("@u-devtools/utils");function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=s.prototype,d=Object.keys(l);for(let f=0;f<d.length;f++){const h=d[f];h in c||(c[h]=l[h].bind(c))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(c){var a;const l=n?.Parent?new i:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class U extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ae extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Re={};function E(e){return Re}function Ce(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 se(e,t){return typeof t=="bigint"?t.toString():t}function ae(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ue(e){return e==null}function le(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const ge=Symbol("evaluating");function g(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ge)return r===void 0&&(r=ge,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 I(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function _e(e){return JSON.stringify(e)}function yt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const De="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vt=ae(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function L(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 Ne(e){return L(e)?{...e}:Array.isArray(e)?[...e]:e}const wt=new Set(["string","number","symbol"]);function X(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function A(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function p(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 zt(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function bt(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 i=I(e._zod.def,{get shape(){const s={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(s[c]=n.shape[c])}return C(this,"shape",s),s},checks:[]});return A(e,i)}function kt(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 i=I(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete s[c]}return C(this,"shape",s),s},checks:[]});return A(e,i)}function $t(e,t){if(!L(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=I(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return C(this,"shape",i),i}});return A(e,o)}function St(e,t){if(!L(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=I(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return C(this,"shape",r),r}});return A(e,n)}function Zt(e,t){const n=I(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:[]});return A(e,n)}function Ot(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 s=I(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 A(t,s)}function Tt(e,t,n){const r=I(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return C(this,"shape",i),i}});return A(t,r)}function D(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 N(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function x(e){return typeof e=="string"?e:e?.message}function j(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=x(e.inst?._zod.def?.error?.(e))??x(t?.error?.(e))??x(n.customError?.(e))??x(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function de(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function W(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Ue=(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,se,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Le=u("$ZodError",Ue),Je=u("$ZodError",Ue,{Parent:Error});function Pt(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 Et(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const a=i.path[c];c===i.path.length-1?(s[a]=s[a]||{_errors:[]},s[a]._errors.push(t(i))):s[a]=s[a]||{_errors:[]},s=s[a],c++}}};return r(e),n}const fe=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new U;if(s.issues.length){const c=new(o?.Err??e)(s.issues.map(a=>j(a,i,E())));throw De(c,o?.callee),c}return s.value},pe=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(o?.Err??e)(s.issues.map(a=>j(a,i,E())));throw De(c,o?.callee),c}return s.value},Y=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new U;return i.issues.length?{success:!1,error:new(e??Le)(i.issues.map(s=>j(s,o,E())))}:{success:!0,data:i.value}},jt=Y(Je),ee=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>j(s,o,E())))}:{success:!0,data:i.value}},It=ee(Je),At=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return fe(e)(t,n,o)},Rt=e=>(t,n,r)=>fe(e)(t,n,r),Ct=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return pe(e)(t,n,o)},Dt=e=>async(t,n,r)=>pe(e)(t,n,r),Nt=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Y(e)(t,n,o)},Ut=e=>(t,n,r)=>Y(e)(t,n,r),Lt=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ee(e)(t,n,o)},Jt=e=>async(t,n,r)=>ee(e)(t,n,r),Mt=/^[cC][^\s-]{8,}$/,Ft=/^[0-9a-z]+$/,Wt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vt=/^[0-9a-vA-V]{20}$/,xt=/^[A-Za-z0-9]{27}$/,Bt=/^[a-zA-Z0-9_-]{21}$/,Kt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qt=/^([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})$/,ye=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)$/,Ht=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Qt(){return new RegExp(Gt,"u")}const Xt=/^(?:(?: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])$/,Yt=/^(([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}|:))$/,en=/^((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])$/,tn=/^(([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])$/,nn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Me=/^[A-Za-z0-9_-]*$/,rn=/^\+[1-9]\d{6,14}$/,Fe="(?:(?:\\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])))",on=new RegExp(`^${Fe}$`);function We(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 sn(e){return new RegExp(`^${We(e)}$`)}function cn(e){const t=We({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(`^${Fe}T(?:${r})$`)}const an=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},un=/^-?\d+(?:\.\d+)?$/,ln=/^[^A-Z]*$/,dn=/^[^a-z]*$/,P=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fn=u("$ZodCheckMaxLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ue(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 s=de(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),pn=u("$ZodCheckMinLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ue(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 s=de(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hn=u("$ZodCheckLengthEquals",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ue(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,i=o.length;if(i===t.length)return;const s=de(o),c=i>t.length;r.issues.push({origin:s,...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})}}),te=u("$ZodCheckStringFormat",(e,t)=>{var n,r;P.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.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=()=>{})}),mn=u("$ZodCheckRegex",(e,t)=>{te.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})}}),gn=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ln),te.init(e,t)}),_n=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=dn),te.init(e,t)}),yn=u("$ZodCheckIncludes",(e,t)=>{P.init(e,t);const n=X(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.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})}}),vn=u("$ZodCheckStartsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`^${X(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})}}),wn=u("$ZodCheckEndsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`.*${X(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})}}),zn=u("$ZodCheckOverwrite",(e,t)=>{P.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class bn{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(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
3
+ `))}}const kn={major:4,minor:3,patch:5},w=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=kn;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,c,a)=>{let l=D(s),d;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(s))continue}else if(l)continue;const h=s.issues.length,m=f._zod.check(s);if(m instanceof Promise&&a?.async===!1)throw new U;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,s.issues.length!==h&&(l||(l=D(s,h)))});else{if(s.issues.length===h)continue;l||(l=D(s,h))}}return d?d.then(()=>s):s},i=(s,c,a)=>{if(D(s))return s.aborted=!0,s;const l=o(c,r,a);if(l instanceof Promise){if(a.async===!1)throw new U;return l.then(d=>e._zod.parse(d,a))}return e._zod.parse(l,a)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const l=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,s,c)):i(l,s,c)}const a=e._zod.parse(s,c);if(a instanceof Promise){if(c.async===!1)throw new U;return a.then(l=>o(l,r,c))}return o(a,r,c)}}g(e,"~standard",()=>({validate:o=>{try{const i=jt(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return It(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),he=u("$ZodString",(e,t)=>{w.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??an(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}}),_=u("$ZodStringFormat",(e,t)=>{te.init(e,t),he.init(e,t)}),$n=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qt),_.init(e,t)}),Sn=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=ye(r))}else t.pattern??(t.pattern=ye());_.init(e,t)}),Zn=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ht),_.init(e,t)}),On=u("$ZodURL",(e,t)=>{_.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),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})}}}),Tn=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Qt()),_.init(e,t)}),Pn=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Bt),_.init(e,t)}),En=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Mt),_.init(e,t)}),jn=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ft),_.init(e,t)}),In=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wt),_.init(e,t)}),An=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Vt),_.init(e,t)}),Rn=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xt),_.init(e,t)}),Cn=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cn(t)),_.init(e,t)}),Dn=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=on),_.init(e,t)}),Nn=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=sn(t)),_.init(e,t)}),Un=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Kt),_.init(e,t)}),Ln=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xt),_.init(e,t),e._zod.bag.format="ipv4"}),Jn=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Yt),_.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})}}}),Mn=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=en),_.init(e,t)}),Fn=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tn),_.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>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 Ve(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Wn=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nn),_.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ve(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Vn(e){if(!Me.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ve(n)}const xn=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Me),_.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Vn(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Bn=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rn),_.init(e,t)});function Kn(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 qn=u("$ZodJWT",(e,t)=>{_.init(e,t),e._zod.check=n=>{Kn(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Hn=u("$ZodUnknown",(e,t)=>{w.init(e,t),e._zod.parse=n=>n}),Gn=u("$ZodNever",(e,t)=>{w.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ve(e,t,n){e.issues.length&&t.issues.push(...N(n,e.issues)),t.value[n]=e.value}const Qn=u("$ZodArray",(e,t)=>{w.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 i=[];for(let s=0;s<o.length;s++){const c=o[s],a=t.element._zod.run({value:c,issues:[]},r);a instanceof Promise?i.push(a.then(l=>ve(l,n,s))):ve(a,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function H(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...N(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function xe(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=zt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Be(e,t,n,r,o,i){const s=[],c=o.keySet,a=o.catchall._zod,l=a.def.type,d=a.optout==="optional";for(const f in t){if(c.has(f))continue;if(l==="never"){s.push(f);continue}const h=a.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(m=>H(m,n,f,t,d))):H(h,n,f,t,d)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Xn=u("$ZodObject",(e,t)=>{if(w.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=ae(()=>xe(t));g(e._zod,"propValues",()=>{const c=t.shape,a={};for(const l in c){const d=c[l]._zod;if(d.values){a[l]??(a[l]=new Set);for(const f of d.values)a[l].add(f)}}return a});const o=q,i=t.catchall;let s;e._zod.parse=(c,a)=>{s??(s=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 d=[],f=s.shape;for(const h of s.keys){const m=f[h],k=m._zod.optout==="optional",b=m._zod.run({value:l[h],issues:[]},a);b instanceof Promise?d.push(b.then(V=>H(V,c,h,l,k))):H(b,c,h,l,k)}return i?Be(d,l,c,a,r.value,e):d.length?Promise.all(d).then(()=>c):c}}),Yn=u("$ZodObjectJIT",(e,t)=>{Xn.init(e,t);const n=e._zod.parse,r=ae(()=>xe(t)),o=h=>{const m=new bn(["shape","payload","ctx"]),k=r.value,b=T=>{const S=_e(T);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};m.write("const input = payload.value;");const V=Object.create(null);let ht=0;for(const T of k.keys)V[T]=`key_${ht++}`;m.write("const newResult = {};");for(const T of k.keys){const S=V[T],O=_e(T),gt=h[T]?._zod?.optout==="optional";m.write(`const ${S} = ${b(T)};`),gt?m.write(`
4
+ if (${S}.issues.length) {
5
+ if (${O} in input) {
6
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${S}.value === undefined) {
14
+ if (${O} in input) {
15
+ newResult[${O}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${O}] = ${S}.value;
19
+ }
20
+
21
+ `):m.write(`
22
+ if (${S}.issues.length) {
23
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
26
+ })));
27
+ }
28
+
29
+ if (${S}.value === undefined) {
30
+ if (${O} in input) {
31
+ newResult[${O}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${O}] = ${S}.value;
35
+ }
36
+
37
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");const mt=m.compile();return(T,S)=>mt(h,T,S)};let i;const s=q,c=!Re.jitless,l=c&&vt.value,d=t.catchall;let f;e._zod.parse=(h,m)=>{f??(f=r.value);const k=h.value;return s(k)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),h=i(h,m),d?Be([],k,h,m,f,e):h):n(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:k,inst:e}),h)}});function we(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!D(i));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(i=>i.issues.map(s=>j(s,r,E())))}),t)}const er=u("$ZodUnion",(e,t)=>{w.init(e,t),g(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),g(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),g(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),g(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>le(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const c=[];for(const a of t.options){const l=a._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)c.push(l),s=!0;else{if(l.issues.length===0)return l;c.push(l)}}return s?Promise.all(c).then(a=>we(a,o,e,i)):we(c,o,e,i)}}),tr=u("$ZodIntersection",(e,t)=>{w.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,l])=>ze(n,a,l)):ze(n,i,s)}});function ie(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(L(e)&&L(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=ie(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.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],i=t[r],s=ie(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ze(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 i=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&o&&e.issues.push({...o,keys:i}),D(e))return e;const s=ie(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const nr=u("$ZodRecord",(e,t)=>{w.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!L(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const c=new Set;for(const l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){c.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...N(l,f.issues)),n.value[l]=f.value})):(d.issues.length&&n.issues.push(...N(l,d.issues)),n.value[l]=d.value)}let a;for(const l in o)c.has(l)||(a=a??[],a.push(l));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;let a=t.keyType._zod.run({value:c,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&un.test(c)&&a.issues.length&&a.issues.some(f=>f.code==="invalid_type"&&f.expected==="number")){const f=t.keyType._zod.run({value:Number(c),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(a=f)}if(a.issues.length){t.mode==="loose"?n.value[c]=o[c]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(f=>j(f,r,E())),input:c,path:[c],inst:e});continue}const d=t.valueType._zod.run({value:o[c],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...N(c,f.issues)),n.value[a.value]=f.value})):(d.issues.length&&n.issues.push(...N(c,d.issues)),n.value[a.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),rr=u("$ZodEnum",(e,t)=>{w.init(e,t);const n=Ce(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>wt.has(typeof o)).map(o=>typeof o=="string"?X(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),or=u("$ZodTransform",(e,t)=>{w.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ae(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new U;return n.value=o,n}});function be(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Ke=u("$ZodOptional",(e,t)=>{w.init(e,t),e._zod.optin="optional",e._zod.optout="optional",g(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),g(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${le(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(i=>be(i,n.value)):be(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),sr=u("$ZodExactOptional",(e,t)=>{Ke.init(e,t),g(e._zod,"values",()=>t.innerType._zod.values),g(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ir=u("$ZodNullable",(e,t)=>{w.init(e,t),g(e._zod,"optin",()=>t.innerType._zod.optin),g(e._zod,"optout",()=>t.innerType._zod.optout),g(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${le(n.source)}|null)$`):void 0}),g(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)}),cr=u("$ZodDefault",(e,t)=>{w.init(e,t),e._zod.optin="optional",g(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(i=>ke(i,t)):ke(o,t)}});function ke(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ar=u("$ZodPrefault",(e,t)=>{w.init(e,t),e._zod.optin="optional",g(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))}),ur=u("$ZodNonOptional",(e,t)=>{w.init(e,t),g(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(i=>$e(i,e)):$e(o,e)}});function $e(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 lr=u("$ZodCatch",(e,t)=>{w.init(e,t),g(e._zod,"optin",()=>t.innerType._zod.optin),g(e._zod,"optout",()=>t.innerType._zod.optout),g(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(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>j(s,r,E()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>j(i,r,E()))},input:n.value}),n.issues=[]),n)}}),dr=u("$ZodPipe",(e,t)=>{w.init(e,t),g(e._zod,"values",()=>t.in._zod.values),g(e._zod,"optin",()=>t.in._zod.optin),g(e._zod,"optout",()=>t.out._zod.optout),g(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>B(s,t.in,r)):B(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>B(i,t.out,r)):B(o,t.out,r)}});function B(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const fr=u("$ZodReadonly",(e,t)=>{w.init(e,t),g(e._zod,"propValues",()=>t.innerType._zod.propValues),g(e._zod,"values",()=>t.innerType._zod.values),g(e._zod,"optin",()=>t.innerType?._zod?.optin),g(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(Se):Se(o)}});function Se(e){return e.value=Object.freeze(e.value),e}const pr=u("$ZodLazy",(e,t)=>{w.init(e,t),g(e._zod,"innerType",()=>t.getter()),g(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),g(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),g(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),g(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),hr=u("$ZodCustom",(e,t)=>{P.init(e,t),w.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(i=>Ze(i,n,r,e));Ze(o,n,r,e)}});function Ze(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(W(o))}}var Oe;class mr{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 gr(){return new mr}(Oe=globalThis).__zod_globalRegistry??(Oe.__zod_globalRegistry=gr());const F=globalThis.__zod_globalRegistry;function _r(e,t){return new e({type:"string",...p(t)})}function yr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...p(t)})}function Te(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...p(t)})}function vr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...p(t)})}function wr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...p(t)})}function zr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...p(t)})}function br(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...p(t)})}function kr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...p(t)})}function $r(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...p(t)})}function Sr(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...p(t)})}function Zr(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...p(t)})}function Or(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...p(t)})}function Tr(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...p(t)})}function Pr(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...p(t)})}function Er(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...p(t)})}function jr(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...p(t)})}function Ir(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...p(t)})}function Ar(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...p(t)})}function Rr(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...p(t)})}function Cr(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...p(t)})}function Dr(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...p(t)})}function Nr(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...p(t)})}function Ur(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...p(t)})}function Lr(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...p(t)})}function Jr(e,t){return new e({type:"string",format:"date",check:"string_format",...p(t)})}function Mr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...p(t)})}function Fr(e,t){return new e({type:"string",format:"duration",check:"string_format",...p(t)})}function Wr(e){return new e({type:"unknown"})}function Vr(e,t){return new e({type:"never",...p(t)})}function qe(e,t){return new fn({check:"max_length",...p(t),maximum:e})}function G(e,t){return new pn({check:"min_length",...p(t),minimum:e})}function He(e,t){return new hn({check:"length_equals",...p(t),length:e})}function xr(e,t){return new mn({check:"string_format",format:"regex",...p(t),pattern:e})}function Br(e){return new gn({check:"string_format",format:"lowercase",...p(e)})}function Kr(e){return new _n({check:"string_format",format:"uppercase",...p(e)})}function qr(e,t){return new yn({check:"string_format",format:"includes",...p(t),includes:e})}function Hr(e,t){return new vn({check:"string_format",format:"starts_with",...p(t),prefix:e})}function Gr(e,t){return new wn({check:"string_format",format:"ends_with",...p(t),suffix:e})}function M(e){return new zn({check:"overwrite",tx:e})}function Qr(e){return M(t=>t.normalize(e))}function Xr(){return M(e=>e.trim())}function Yr(){return M(e=>e.toLowerCase())}function eo(){return M(e=>e.toUpperCase())}function to(){return M(e=>yt(e))}function no(e,t,n){return new e({type:"array",element:t,...p(n)})}function ro(e,t,n){return new e({type:"custom",check:"custom",fn:t,...p(n)})}function oo(e){const t=so(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(W(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(W(o))}},e(n.value,n)));return t}function so(e,t){const n=new P({check:"custom",...p(t)});return n._zod.check=e,n}function Ge(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 v(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{const h=s.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,h,d)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),v(f,t,d),t.seen.get(f).isParent=!0)}const a=t.metadataRegistry.get(e);return a&&Object.assign(s.schema,a),t.io==="input"&&$(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Qe(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 s of e.seen.entries()){const c=e.metadataRegistry.get(s[0])?.id;if(c){const a=r.get(c);if(a&&a!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,s[0])}}const o=s=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(s[0])?.id,h=e.external.uri??(k=>k);if(f)return{ref:h(f)};const m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${h("__shared")}#/${c}/${m}`}}if(s[1]===n)return{ref:"#"};const l=`#/${c}/`,d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},i=s=>{if(s[1].schema.$ref)return;const c=s[1],{ref:a,defId:l}=o(s);c.def={...c.schema},l&&(c.defId=l);const d=c.schema;for(const f in d)delete d[f];d.$ref=a};if(e.cycles==="throw")for(const s of e.seen.entries()){const c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
38
+
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const c=s[1];if(t===s[0]){i(s);continue}if(e.external){const l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1&&e.reused==="ref"){i(s);continue}}}function Xe(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const c=e.seen.get(s);if(c.ref===null)return;const a=c.def??c.schema,l={...a},d=c.ref;if(c.ref=null,d){r(d);const h=e.seen.get(d),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(a.allOf=a.allOf??[],a.allOf.push(m)):Object.assign(a,m),Object.assign(a,l),s._zod.parent===d)for(const b in a)b==="$ref"||b==="allOf"||b in l||delete a[b];if(m.$ref)for(const b in a)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(a[b])===JSON.stringify(h.def[b])&&delete a[b]}const f=s._zod.parent;if(f&&f!==d){r(f);const h=e.seen.get(f);if(h?.schema.$ref&&(a.$ref=h.schema.$ref,h.def))for(const m in a)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(a[m])===JSON.stringify(h.def[m])&&delete a[m]}e.override({zodSchema:s,jsonSchema:a,path:c.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[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 s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const c=s[1];c.def&&c.defId&&(i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Q(t,"input",e.processors),output:Q(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function $(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 $(r.element,n);if(r.type==="set")return $(r.valueType,n);if(r.type==="lazy")return $(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 $(r.innerType,n);if(r.type==="intersection")return $(r.left,n)||$(r.right,n);if(r.type==="record"||r.type==="map")return $(r.keyType,n)||$(r.valueType,n);if(r.type==="pipe")return $(r.in,n)||$(r.out,n);if(r.type==="object"){for(const o in r.shape)if($(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if($(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if($(o,n))return!0;return!!(r.rest&&$(r.rest,n))}return!1}const io=(e,t={})=>n=>{const r=Ge({...n,processors:t});return v(e,r),Qe(r,e),Xe(r,e)},Q=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Ge({...o??{},target:i,io:t,processors:n});return v(e,s),Qe(s,e),Xe(s,e)},co={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ao=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:c,patterns:a,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),c&&(o.format=co[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),l&&(o.contentEncoding=l),a&&a.size>0){const d=[...a];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},uo=(e,t,n,r)=>{n.not={}},lo=(e,t,n,r)=>{},fo=(e,t,n,r)=>{const o=e._zod.def,i=Ce(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},po=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ho=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},mo=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:c}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=v(i.element,t,{...r,path:[...r.path,"items"]})},go=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const l in s)o.properties[l]=v(s[l],t,{...r,path:[...r.path,"properties",l]});const c=new Set(Object.keys(s)),a=new Set([...c].filter(l=>{const d=i.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));a.size>0&&(o.required=Array.from(a)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=v(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},_o=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((c,a)=>v(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",a]}));i?n.oneOf=s:n.anyOf=s},yo=(e,t,n,r)=>{const o=e._zod.def,i=v(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=v(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=l=>"allOf"in l&&Object.keys(l).length===1,a=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];n.allOf=a},vo=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=s._zod.bag?.patterns;if(i.mode==="loose"&&a&&a.size>0){const d=v(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const f of a)o.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=v(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=v(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const l=s._zod.values;if(l){const d=[...l].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(o.required=d)}},wo=(e,t,n,r)=>{const o=e._zod.def,i=v(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},zo=(e,t,n,r)=>{const o=e._zod.def;v(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},bo=(e,t,n,r)=>{const o=e._zod.def;v(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ko=(e,t,n,r)=>{const o=e._zod.def;v(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},$o=(e,t,n,r)=>{const o=e._zod.def;v(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},So=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;v(i,t,r);const s=t.seen.get(e);s.ref=i},Zo=(e,t,n,r)=>{const o=e._zod.def;v(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Ye=(e,t,n,r)=>{const o=e._zod.def;v(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Oo=(e,t,n,r)=>{const o=e._zod.innerType;v(o,t,r);const i=t.seen.get(e);i.ref=o},To=u("ZodISODateTime",(e,t)=>{Cn.init(e,t),y.init(e,t)});function Po(e){return Lr(To,e)}const Eo=u("ZodISODate",(e,t)=>{Dn.init(e,t),y.init(e,t)});function jo(e){return Jr(Eo,e)}const Io=u("ZodISOTime",(e,t)=>{Nn.init(e,t),y.init(e,t)});function Ao(e){return Mr(Io,e)}const Ro=u("ZodISODuration",(e,t)=>{Un.init(e,t),y.init(e,t)});function Co(e){return Fr(Ro,e)}const Do=(e,t)=>{Le.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Et(e,n)},flatten:{value:n=>Pt(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,se,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,se,2)}},isEmpty:{get(){return e.issues.length===0}}})},Z=u("ZodError",Do,{Parent:Error}),No=fe(Z),Uo=pe(Z),Lo=Y(Z),Jo=ee(Z),Mo=At(Z),Fo=Rt(Z),Wo=Ct(Z),Vo=Dt(Z),xo=Nt(Z),Bo=Ut(Z),Ko=Lt(Z),qo=Jt(Z),z=u("ZodType",(e,t)=>(w.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Q(e,"input"),output:Q(e,"output")}}),e.toJSONSchema=io(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(I(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>A(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>No(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Lo(e,n,r),e.parseAsync=async(n,r)=>Uo(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Jo(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Mo(e,n,r),e.decode=(n,r)=>Fo(e,n,r),e.encodeAsync=async(n,r)=>Wo(e,n,r),e.decodeAsync=async(n,r)=>Vo(e,n,r),e.safeEncode=(n,r)=>xo(e,n,r),e.safeDecode=(n,r)=>Bo(e,n,r),e.safeEncodeAsync=async(n,r)=>Ko(e,n,r),e.safeDecodeAsync=async(n,r)=>qo(e,n,r),e.refine=(n,r)=>e.check(Ms(n,r)),e.superRefine=n=>e.check(Fs(n)),e.overwrite=n=>e.check(M(n)),e.optional=()=>Ee(e),e.exactOptional=()=>Zs(e),e.nullable=()=>je(e),e.nullish=()=>Ee(je(e)),e.nonoptional=n=>Is(e,n),e.array=()=>tt(e),e.or=n=>vs([e,n]),e.and=n=>zs(e,n),e.transform=n=>Ie(e,$s(n)),e.default=n=>Ps(e,n),e.prefault=n=>js(e,n),e.catch=n=>Rs(e,n),e.pipe=n=>Ie(e,n),e.readonly=()=>Ns(e),e.describe=n=>{const r=e.clone();return F.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return F.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return F.get(e);const r=e.clone();return F.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),et=u("_ZodString",(e,t)=>{he.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ao(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(xr(...r)),e.includes=(...r)=>e.check(qr(...r)),e.startsWith=(...r)=>e.check(Hr(...r)),e.endsWith=(...r)=>e.check(Gr(...r)),e.min=(...r)=>e.check(G(...r)),e.max=(...r)=>e.check(qe(...r)),e.length=(...r)=>e.check(He(...r)),e.nonempty=(...r)=>e.check(G(1,...r)),e.lowercase=r=>e.check(Br(r)),e.uppercase=r=>e.check(Kr(r)),e.trim=()=>e.check(Xr()),e.normalize=(...r)=>e.check(Qr(...r)),e.toLowerCase=()=>e.check(Yr()),e.toUpperCase=()=>e.check(eo()),e.slugify=()=>e.check(to())}),Ho=u("ZodString",(e,t)=>{he.init(e,t),et.init(e,t),e.email=n=>e.check(yr(Go,n)),e.url=n=>e.check(kr(Qo,n)),e.jwt=n=>e.check(Ur(fs,n)),e.emoji=n=>e.check($r(Xo,n)),e.guid=n=>e.check(Te(Pe,n)),e.uuid=n=>e.check(vr(K,n)),e.uuidv4=n=>e.check(wr(K,n)),e.uuidv6=n=>e.check(zr(K,n)),e.uuidv7=n=>e.check(br(K,n)),e.nanoid=n=>e.check(Sr(Yo,n)),e.guid=n=>e.check(Te(Pe,n)),e.cuid=n=>e.check(Zr(es,n)),e.cuid2=n=>e.check(Or(ts,n)),e.ulid=n=>e.check(Tr(ns,n)),e.base64=n=>e.check(Cr(us,n)),e.base64url=n=>e.check(Dr(ls,n)),e.xid=n=>e.check(Pr(rs,n)),e.ksuid=n=>e.check(Er(os,n)),e.ipv4=n=>e.check(jr(ss,n)),e.ipv6=n=>e.check(Ir(is,n)),e.cidrv4=n=>e.check(Ar(cs,n)),e.cidrv6=n=>e.check(Rr(as,n)),e.e164=n=>e.check(Nr(ds,n)),e.datetime=n=>e.check(Po(n)),e.date=n=>e.check(jo(n)),e.time=n=>e.check(Ao(n)),e.duration=n=>e.check(Co(n))});function R(e){return _r(Ho,e)}const y=u("ZodStringFormat",(e,t)=>{_.init(e,t),et.init(e,t)}),Go=u("ZodEmail",(e,t)=>{Zn.init(e,t),y.init(e,t)}),Pe=u("ZodGUID",(e,t)=>{$n.init(e,t),y.init(e,t)}),K=u("ZodUUID",(e,t)=>{Sn.init(e,t),y.init(e,t)}),Qo=u("ZodURL",(e,t)=>{On.init(e,t),y.init(e,t)}),Xo=u("ZodEmoji",(e,t)=>{Tn.init(e,t),y.init(e,t)}),Yo=u("ZodNanoID",(e,t)=>{Pn.init(e,t),y.init(e,t)}),es=u("ZodCUID",(e,t)=>{En.init(e,t),y.init(e,t)}),ts=u("ZodCUID2",(e,t)=>{jn.init(e,t),y.init(e,t)}),ns=u("ZodULID",(e,t)=>{In.init(e,t),y.init(e,t)}),rs=u("ZodXID",(e,t)=>{An.init(e,t),y.init(e,t)}),os=u("ZodKSUID",(e,t)=>{Rn.init(e,t),y.init(e,t)}),ss=u("ZodIPv4",(e,t)=>{Ln.init(e,t),y.init(e,t)}),is=u("ZodIPv6",(e,t)=>{Jn.init(e,t),y.init(e,t)}),cs=u("ZodCIDRv4",(e,t)=>{Mn.init(e,t),y.init(e,t)}),as=u("ZodCIDRv6",(e,t)=>{Fn.init(e,t),y.init(e,t)}),us=u("ZodBase64",(e,t)=>{Wn.init(e,t),y.init(e,t)}),ls=u("ZodBase64URL",(e,t)=>{xn.init(e,t),y.init(e,t)}),ds=u("ZodE164",(e,t)=>{Bn.init(e,t),y.init(e,t)}),fs=u("ZodJWT",(e,t)=>{qn.init(e,t),y.init(e,t)}),ps=u("ZodUnknown",(e,t)=>{Hn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lo()});function J(){return Wr(ps)}const hs=u("ZodNever",(e,t)=>{Gn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uo(e,n,r)});function ms(e){return Vr(hs,e)}const gs=u("ZodArray",(e,t)=>{Qn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mo(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(G(n,r)),e.nonempty=n=>e.check(G(1,n)),e.max=(n,r)=>e.check(qe(n,r)),e.length=(n,r)=>e.check(He(n,r)),e.unwrap=()=>e.element});function tt(e,t){return no(gs,e,t)}const _s=u("ZodObject",(e,t)=>{Yn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>go(e,n,r,o),g(e,"shape",()=>t.shape),e.keyof=()=>ne(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:J()}),e.loose=()=>e.clone({...e._zod.def,catchall:J()}),e.strict=()=>e.clone({...e._zod.def,catchall:ms()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>$t(e,n),e.safeExtend=n=>St(e,n),e.merge=n=>Zt(e,n),e.pick=n=>bt(e,n),e.omit=n=>kt(e,n),e.partial=(...n)=>Ot(rt,e,n[0]),e.required=(...n)=>Tt(ot,e,n[0])});function me(e,t){const n={type:"object",shape:e??{},...p(t)};return new _s(n)}const ys=u("ZodUnion",(e,t)=>{er.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_o(e,n,r,o),e.options=t.options});function vs(e,t){return new ys({type:"union",options:e,...p(t)})}const ws=u("ZodIntersection",(e,t)=>{tr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yo(e,n,r,o)});function zs(e,t){return new ws({type:"intersection",left:e,right:t})}const bs=u("ZodRecord",(e,t)=>{nr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vo(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function nt(e,t,n){return new bs({type:"record",keyType:e,valueType:t,...p(n)})}const ce=u("ZodEnum",(e,t)=>{rr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,i)=>fo(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 i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new ce({...t,checks:[],...p(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new ce({...t,checks:[],...p(o),entries:i})}});function ne(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ce({type:"enum",entries:n,...p(t)})}const ks=u("ZodTransform",(e,t)=>{or.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ho(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ae(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(W(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(W(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function $s(e){return new ks({type:"transform",transform:e})}const rt=u("ZodOptional",(e,t)=>{Ke.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ye(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ee(e){return new rt({type:"optional",innerType:e})}const Ss=u("ZodExactOptional",(e,t)=>{sr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ye(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Zs(e){return new Ss({type:"optional",innerType:e})}const Os=u("ZodNullable",(e,t)=>{ir.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function je(e){return new Os({type:"nullable",innerType:e})}const Ts=u("ZodDefault",(e,t)=>{cr.init(e,t),z.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 Ps(e,t){return new Ts({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ne(t)}})}const Es=u("ZodPrefault",(e,t)=>{ar.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ko(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function js(e,t){return new Es({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ne(t)}})}const ot=u("ZodNonOptional",(e,t)=>{ur.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Is(e,t){return new ot({type:"nonoptional",innerType:e,...p(t)})}const As=u("ZodCatch",(e,t)=>{lr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$o(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Rs(e,t){return new As({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Cs=u("ZodPipe",(e,t)=>{dr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>So(e,n,r,o),e.in=t.in,e.out=t.out});function Ie(e,t){return new Cs({type:"pipe",in:e,out:t})}const Ds=u("ZodReadonly",(e,t)=>{fr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ns(e){return new Ds({type:"readonly",innerType:e})}const Us=u("ZodLazy",(e,t)=>{pr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Oo(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Ls(e){return new Us({type:"lazy",getter:e})}const Js=u("ZodCustom",(e,t)=>{hr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>po(e,n)});function Ms(e,t={}){return ro(Js,e,t)}function Fs(e){return oo(e)}const st=me({id:R().min(1),type:ne(["request","response","event"]),method:R().optional(),payload:J().optional(),error:J().optional()});function it(e){const t=st.safeParse(e);return t.success?t.data:null}const Ws=()=>Math.random().toString(36).substring(2,15);class re{constructor(){this.handlers=new Map,this.eventListeners=new Map,this.disposed=!1,this.timeout=5e3}call(t,n){if(this.disposed)return Promise.reject(new Error("Transport has been disposed"));const r=Ws();return new Promise((o,i)=>{this.handlers.set(r,{resolve:o,reject:i}),this.sendMessage("request",{id:r,type:"request",method:t,payload:n}),setTimeout(()=>{const s=this.handlers.get(r);if(s){this.handlers.delete(r);const c=new Error(`RPC Timeout: ${t}`);console.error("[RPC Timeout]",{method:t,payload:n,stack:c.stack,timestamp:new Date().toISOString()}),s.reject(c)}},this.timeout)})}on(t,n){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t)?.add(n);const r=this.subscribe("event",o=>{const i=o;i.method===t&&n(i.payload)});return()=>{const o=this.eventListeners.get(t);o&&o.delete(n),r()}}off(t,n){const r=this.eventListeners.get(t);r&&r.delete(n)}handleMessage(t){if(this.disposed)return;const n=it(t);if(!n){console.warn("[Transport] Invalid RPC message structure:",t);return}if(n.type==="response"){const r=this.handlers.get(n.id);if(r){if(n.error){const o=_t.extractErrorMessage(n.error);r.reject(new Error(o))}else r.resolve(n.payload);this.handlers.delete(n.id)}return}if(n.type==="event"){const r=n.method||"",o=this.eventListeners.get(r);if(o&&o.size>0)for(const i of o)try{i(n.payload)}catch(s){console.error("[Transport] Error in listener:",s)}}}dispose(){this.disposed=!0;for(const[t,n]of this.handlers.entries())n.reject(new Error(`Transport disposed: request ${t} was cancelled`));this.handlers.clear(),this.eventListeners.clear()}}class ct extends re{constructor(t){super(),this.namespace=t,this.channel=new BroadcastChannel(`u-devtools:${t}`),this.messageHandler=n=>{const{event:r,data:o}=n.data,i=this.eventListeners.get(r);i&&i.forEach(s=>{s(o)})},this.channel.onmessage=this.messageHandler}unwrapVueReactive(t){if(t&&typeof t=="object"){if("__v_isRef"in t||"_value"in t){const o=t._value??t.value;return this.unwrapVueReactive(o)}if(Array.isArray(t))return t.map(o=>this.unwrapVueReactive(o));const n={},r=new WeakSet;for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const i=t[o];if(o.startsWith("__")||o.startsWith("_")&&o!=="_value")continue;if(i&&typeof i=="object"){if(r.has(i)){n[o]="[Circular]";continue}r.add(i)}n[o]=this.unwrapVueReactive(i)}return n}return t}send(t,n){try{const r=n!==void 0?this.unwrapVueReactive(n):void 0;this.channel.postMessage({event:t,data:r})}catch(r){if(r instanceof DOMException&&(r.name==="InvalidStateError"||r.message?.includes("closed"))){console.warn(`[BroadcastTransport:${this.namespace}] Cannot send event "${t}": channel is closed`);return}if(r instanceof Error&&(r.name==="DataCloneError"||r.message?.includes("circular"))){const o=new Error().stack,i=n===null?"null":n===void 0?"undefined":typeof n;let s="";try{s=typeof n=="object"&&n!==null?JSON.stringify(n,(c,a)=>{if(typeof a=="function")return"[Function]";if(a instanceof Node)return`[${a.nodeName}]`;if(a instanceof Error)return`[Error: ${a.message}]`;if(!(c.startsWith("__")||c.startsWith("_")&&c!=="_value"))return a},2).slice(0,200):String(n).slice(0,100)}catch{s="[Unable to serialize]"}console.error(`[BroadcastTransport:${this.namespace}] DataCloneError: Failed to send event "${t}".
40
+ Data type: ${i}
41
+ Data preview: ${s}
42
+ This usually means the data contains non-serializable objects (functions, DOM nodes, Vue refs, etc.).
43
+ Stack trace:
44
+ ${o?.split(`
45
+ `).slice(0,5).join(`
46
+ `)||"N/A"}`);return}throw r}}call(t,n){return Promise.reject(new Error("RPC calls are not supported in BroadcastTransport. Use send() for events."))}sendMessage(t,n){throw new Error("sendMessage is not supported in BroadcastTransport. Use send() instead.")}subscribe(t,n){this.eventListeners.has(t)||this.eventListeners.set(t,new Set);const r=this.eventListeners.get(t);return r&&r.add(n),()=>{const o=this.eventListeners.get(t);o&&o.delete(n)}}unsubscribe(t,n){const r=this.eventListeners.get(t);r&&r.delete(n)}dispose(){super.dispose(),this.channel.close()}close(){this.dispose()}}class at{constructor(t,n,r){this.bridge=t,this.key=n,this.listeners=new Set,this.isUpdating=!1,this.subscribe=s=>(this.listeners.add(s),s(this._value),()=>{this.listeners.delete(s)}),this.getSnapshot=()=>this._value,this._value=r;const o=`sync:${n}`,i=`request:${n}`;this.bridge.on(o,(s=>{if(this.isUpdating)return;const c=s;this._value!==c&&(this._value=c,this.isUpdating=!0,this.notify(),this.isUpdating=!1)})),this.bridge.on(i,()=>{this.bridge.send(o,this._value)}),this.bridge.send(i,{})}get value(){return this._value}set value(t){this._value!==t&&(this._value=t,this.notify(),this.isUpdating||this.bridge.send(`sync:${this.key}`,t))}notify(){this.listeners.forEach(t=>{t(this._value)})}}class Vs{constructor(t){this.namespace=t.toLowerCase().replace(/\s+/g,"-"),this.displayName=t,this.transport=new ct(this.namespace)}send(t,...n){const r=n.length===1?n[0]:n.length>1?n:void 0;this.transport.send(t,r)}on(t,n){return this.transport.on(t,n)}request(t,n,r,o=5e3,i){return new Promise((s,c)=>{const a=setTimeout(()=>{l(),c(new Error(`Request timeout: ${t} -> ${r}`))},o),l=this.transport.on(r,d=>{const f=d;i&&!i(n,f)||(clearTimeout(a),l(),s(f))});this.transport.send(t,n)})}close(){this.transport.close()}state(t,n){return new at(this,t,n)}}class ut{constructor(){this.channel=new BroadcastChannel("u-devtools:control")}open(){this.channel.postMessage({action:"open"})}close(){this.channel.postMessage({action:"close"})}toggle(){this.channel.postMessage({action:"toggle"})}isOpen(){return new Promise(t=>{const n=r=>{r.data?.type==="u-devtools:state-response"&&(this.channel.removeEventListener("message",n),t(r.data.isOpen))};this.channel.addEventListener("message",n),this.channel.postMessage({action:"get-state"}),setTimeout(()=>{this.channel.removeEventListener("message",n),t(!1)},200)})}onStateChange(t){const n=r=>{r.data?.type==="u-devtools:state-changed"&&t(r.data.isOpen)};return this.channel.addEventListener("message",n),()=>this.channel.removeEventListener("message",n)}switchPlugin(t){this.channel.postMessage({action:"switch-plugin",pluginName:t})}switchTab(t,n){this.channel.postMessage({action:"switch-tab",pluginName:t,tabName:n})}destroy(){this.channel.close()}}const xs=new ut;class Bs extends re{constructor(t){if(super(),this.hot=t,!t)throw new Error("Hot Module Replacement is required for HmrTransport");this.responseHandler=n=>{this.handleMessage(n)},t.on("u-devtools:response",this.responseHandler),this.eventHandler=n=>{this.handleMessage(n)},t.on("u-devtools:event",this.eventHandler)}on(t,n){return this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t)?.add(n),()=>{const r=this.eventListeners.get(t);r&&r.delete(n)}}sendMessage(t,n){t==="request"&&this.hot.send("u-devtools:request",n)}subscribe(t,n){return()=>{}}unsubscribe(t,n){}dispose(){super.dispose(),this.hot.off&&this.responseHandler&&this.hot.off("u-devtools:response",this.responseHandler),this.hot.off&&this.eventHandler&&this.hot.off("u-devtools:event",this.eventHandler)}}const lt=ne(["string","number","boolean","select","array"]),dt=me({label:R(),value:J()}),oe=Ls(()=>me({label:R().min(1),description:R().optional(),type:lt,default:J().optional(),options:tt(dt).optional(),items:nt(R(),oe).optional(),itemType:ne(["string","number"]).optional()})),ft=nt(R(),oe);function Ks(e){const t=oe.safeParse(e);return t.success?t.data:null}function qs(e){const t=ft.safeParse(e);return t.success?t.data:null}function pt(e,t){switch(t.type){case"string":return typeof e=="string";case"number":return typeof e=="number"&&!Number.isNaN(e);case"boolean":return typeof e=="boolean";case"select":return t.options?t.options.some(n=>n.value===e):!1;case"array":if(!Array.isArray(e))return!1;if(t.itemType)return e.every(n=>t.itemType==="string"?typeof n=="string":t.itemType==="number"?typeof n=="number":!1);if(t.items){const n=t.items;return e.every(r=>{if(typeof r!="object"||r===null)return!1;for(const[o,i]of Object.entries(n)){const s=r[o];if(!pt(s,i))return!1}return!0})}return!0;default:return!1}}class Hs extends re{constructor(t){super(),this.url=t,this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.reconnectTimer=null,this.isManualClose=!1,this.messageQueue=[],this.connect()}connect(){this.ws&&(this.ws.close(),this.ws=null);try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,console.log("[WebSocketTransport] Connected"),this.flushQueue()},this.ws.onmessage=t=>{try{const n=JSON.parse(t.data);this.handleMessage(n)}catch(n){console.error("[WebSocketTransport] Failed to parse message:",n)}},this.ws.onerror=t=>{console.error("[WebSocketTransport] Socket error:",t)},this.ws.onclose=t=>{this.isManualClose||(console.warn(`[WebSocketTransport] Closed (code: ${t.code}). Attempting reconnect...`),this.scheduleReconnect())}}catch(t){console.error("[WebSocketTransport] Failed to create socket:",t),this.scheduleReconnect()}}scheduleReconnect(){if(this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const t=this.reconnectDelay*this.reconnectAttempts;console.log(`[WebSocketTransport] Reconnecting in ${t}ms...`),this.reconnectTimer=setTimeout(()=>{this.connect()},t)}else console.error("[WebSocketTransport] Max reconnect attempts reached")}sendMessage(t,n){const r=n,o={id:r.id||"",type:t,method:r.method,payload:t==="request"?r.payload:r,error:r.error},i=JSON.stringify(o);this.isConnected()?this.ws.send(i):this.messageQueue.push(i)}flushQueue(){if(this.isConnected())for(;this.messageQueue.length>0;){const t=this.messageQueue.shift();t&&this.ws.send(t)}}subscribe(t,n){return()=>{}}unsubscribe(t,n){}dispose(){this.isManualClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null),this.messageQueue=[],super.dispose()}isConnected(){return this.ws!==null&&this.ws.readyState===WebSocket.OPEN}}class Gs{constructor(){this.listeners=new Map}emit(t,n){const r=this.listeners.get(t);r&&r.forEach(o=>{o(n)})}on(t,n){this.listeners.has(t)||this.listeners.set(t,new Set);const r=this.listeners.get(t);return r&&r.add(n),()=>{this.off(t,n)}}off(t,n){const r=this.listeners.get(t);r&&(r.delete(n),r.size===0&&this.listeners.delete(t))}clear(){this.listeners.clear()}listenerCount(t){return this.listeners.get(t)?.size||0}}exports.AppBridge=Vs;exports.BroadcastTransport=ct;exports.DevToolsControl=ut;exports.HmrTransport=Bs;exports.PluginSettingsSchemaSchema=ft;exports.RpcMessageSchema=st;exports.SettingOptionSchema=dt;exports.SettingSchemaDefSchema=oe;exports.SettingTypeSchema=lt;exports.SyncedState=at;exports.Transport=re;exports.TypedEventBus=Gs;exports.WebSocketTransport=Hs;exports.devtools=xs;exports.validatePluginSettingsSchema=qs;exports.validateRpcMessage=it;exports.validateSettingSchemaDef=Ks;exports.validateSettingValue=pt;