@elementor/angie-sdk 1.0.1 → 1.0.3
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/README.md +92 -14
- package/dist/angie-iframe-utils.d.ts +5 -0
- package/dist/angie-mcp-sdk.d.ts +22 -1
- package/dist/client-manager.d.ts +3 -1
- package/dist/config.d.ts +6 -0
- package/dist/iframe.d.ts +27 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/localStorage.d.ts +1 -0
- package/dist/navigation-utils.d.ts +6 -0
- package/dist/oauth.d.ts +15 -0
- package/dist/openSaaSPage.d.ts +18 -0
- package/dist/registration-queue.d.ts +1 -0
- package/dist/sdk.d.ts +14 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/sidebar.d.ts +27 -0
- package/dist/types.d.ts +61 -7
- package/dist/utils.d.ts +6 -0
- package/dist/version.d.ts +1 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @elementor/angie-sdk
|
|
2
2
|
|
|
3
|
-
Based on [MCP](https://github.com/modelcontextprotocol/typescript-sdk) version: 1.
|
|
3
|
+
Based on [MCP](https://github.com/modelcontextprotocol/typescript-sdk) version: 1.17.4
|
|
4
4
|
|
|
5
5
|
**An SDK for extending Angie AI Assistant capabilities.**
|
|
6
6
|
|
|
@@ -15,6 +15,7 @@ This SDK enables you to create custom MCP servers that Angie can discover and us
|
|
|
15
15
|
- [Supported MCP Features](#supported-mcp-features)
|
|
16
16
|
- [Installation](#installation)
|
|
17
17
|
- [Quick Start](#quick-start)
|
|
18
|
+
- [Triggering Angie with Prompts](#triggering-angie-with-prompts)
|
|
18
19
|
- [MCP Server Example](#mcp-server-example)
|
|
19
20
|
- [Registering Tools](#registering-tools)
|
|
20
21
|
- [Handling Tool Calls](#handling-tool-calls)
|
|
@@ -66,17 +67,27 @@ The SDK covers three main abilities:
|
|
|
66
67
|
* Run your MCP server in the browser
|
|
67
68
|
|
|
68
69
|
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
```
|
|
71
|
+
┌──────────────────────────────┐
|
|
72
|
+
│ Angie SDK Flow │
|
|
73
|
+
├──────────────────────────────┤
|
|
74
|
+
│ │
|
|
75
|
+
│ Your WordPress Plugin │
|
|
76
|
+
│ │ │
|
|
77
|
+
│ │ enqueue script │
|
|
78
|
+
│ ▼ │
|
|
79
|
+
│ Your MCP Server (JS) │
|
|
80
|
+
│ │ │
|
|
81
|
+
│ │ register server │
|
|
82
|
+
│ ▼ │
|
|
83
|
+
│ Angie SDK │
|
|
84
|
+
│ │ │
|
|
85
|
+
│ ◄─► Browser │
|
|
86
|
+
│ │ Transport │
|
|
87
|
+
│ ▼ │
|
|
88
|
+
│ Angie (iframe) │
|
|
89
|
+
│ │
|
|
90
|
+
└──────────────────────────────┘
|
|
80
91
|
```
|
|
81
92
|
|
|
82
93
|
## Supported MCP Features
|
|
@@ -136,6 +147,57 @@ await sdk.registerServer({
|
|
|
136
147
|
|
|
137
148
|
---
|
|
138
149
|
|
|
150
|
+
## Triggering Angie with Prompts
|
|
151
|
+
|
|
152
|
+
The SDK can also trigger Angie with custom prompts - useful for help buttons or deep linking.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { AngieMcpSdk } from '@elementor/angie-sdk';
|
|
156
|
+
|
|
157
|
+
// Register your MCP server and trigger Angie
|
|
158
|
+
const server = createSeoMcpServer();
|
|
159
|
+
const sdk = new AngieMcpSdk();
|
|
160
|
+
await sdk.registerServer({
|
|
161
|
+
name: 'my-seo-server',
|
|
162
|
+
version: '1.0.0',
|
|
163
|
+
description: 'SEO tools for Angie',
|
|
164
|
+
server,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Trigger Angie with a prompt
|
|
168
|
+
await sdk.triggerAngie({
|
|
169
|
+
prompt: 'Help me optimize this page for SEO',
|
|
170
|
+
context: { pageType: 'product', source: 'my-plugin' },
|
|
171
|
+
options: {
|
|
172
|
+
timeout: 30000, // Optional: 30 seconds timeout (default: 30000)
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Or simplified version
|
|
178
|
+
await sdk.triggerAngie({
|
|
179
|
+
prompt: 'Help me create a contact page'
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Options:**
|
|
184
|
+
- `timeout`: How long to wait for Angie response (milliseconds)
|
|
185
|
+
- `priority`: Request priority level
|
|
186
|
+
- `context`: Additional data to help Angie understand the request
|
|
187
|
+
|
|
188
|
+
### Hash Parameter Method
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
// Trigger via URL hash - perfect for deep linking
|
|
192
|
+
window.location.hash = 'angie-prompt=' + encodeURIComponent('Help me create a contact page');
|
|
193
|
+
|
|
194
|
+
// Or visit URLs like: https://yoursite.com/wp-admin/edit.php#angie-prompt=Help%20me%20optimize%20SEO
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Note:** Always call `await sdk.waitForReady()` before triggering Angie.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
139
201
|
## MCP Server Example
|
|
140
202
|
|
|
141
203
|
A typical project structure:
|
|
@@ -261,7 +323,7 @@ add_action('rest_api_init', function () {
|
|
|
261
323
|
),
|
|
262
324
|
]);
|
|
263
325
|
});
|
|
264
|
-
|
|
326
|
+
```
|
|
265
327
|
## Remote SSE and HTTP Streamable MCP servers
|
|
266
328
|
|
|
267
329
|
For remote servers, let your Angie users add them via Angie MCP Gateway settings.
|
|
@@ -322,8 +384,24 @@ If you have questions or need help, open an issue or contact the Elementor team!
|
|
|
322
384
|
3. Test REST API endpoints independently
|
|
323
385
|
4. Ensure proper nonce and permission setup
|
|
324
386
|
|
|
387
|
+
### Dev Mode for Enhanced Debugging
|
|
388
|
+
|
|
389
|
+
Angie includes a Dev Mode feature that displays tool execution progress and details directly in the chat interface, making it easier to debug your MCP server integrations and understand how Angie interacts with your tools.
|
|
390
|
+
|
|
391
|
+
**To enable Dev Mode:**
|
|
392
|
+
1. Open Angie in WordPress
|
|
393
|
+
2. Click on the User Profile icon
|
|
394
|
+
3. Navigate to Tools
|
|
395
|
+
4. Toggle "Dev Mode" on
|
|
396
|
+
|
|
397
|
+
**What Dev Mode shows:**
|
|
398
|
+
When enabled, Angie will display in the chat:
|
|
399
|
+
- Tool execution history for each user request
|
|
400
|
+
- Tool call status (pending, in progress, completed, failed)
|
|
401
|
+
- Tool input and output
|
|
402
|
+
|
|
325
403
|
---
|
|
326
404
|
|
|
327
405
|
## License
|
|
328
406
|
|
|
329
|
-
MIT
|
|
407
|
+
MIT
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const setAngieIframeRef: (iframe: HTMLIFrameElement | null) => void;
|
|
2
|
+
export declare const getAngieIframe: () => HTMLIFrameElement | null;
|
|
3
|
+
export declare const angieIframeExists: () => boolean;
|
|
4
|
+
export declare const getAngieIframeOrigin: () => string | null;
|
|
5
|
+
export declare const postMessageToAngieIframe: (message: Record<string, unknown>, targetOrigin?: string) => boolean;
|
package/dist/angie-mcp-sdk.d.ts
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import { AngieServerConfig, ServerRegistration } from './types';
|
|
1
|
+
import { AngieLocalServerConfig, AngieRemoteServerConfig, AngieServerConfig, ServerRegistration, AngieTriggerRequest, AngieTriggerResponse } from './types';
|
|
2
|
+
export type AngieMcpSdkOptions = {
|
|
3
|
+
origin?: string;
|
|
4
|
+
uiTheme?: string;
|
|
5
|
+
isRTL?: boolean;
|
|
6
|
+
};
|
|
2
7
|
export declare class AngieMcpSdk {
|
|
3
8
|
private angieDetector;
|
|
4
9
|
private registrationQueue;
|
|
5
10
|
private clientManager;
|
|
6
11
|
private isInitialized;
|
|
12
|
+
private instanceId;
|
|
7
13
|
constructor();
|
|
14
|
+
loadSidebar(options?: AngieMcpSdkOptions): Promise<void>;
|
|
15
|
+
private setupReRegistrationHandler;
|
|
8
16
|
private setupAngieReadyHandler;
|
|
9
17
|
private handleAngieReady;
|
|
10
18
|
private processRegistration;
|
|
19
|
+
registerLocalServer(config: AngieLocalServerConfig): Promise<void>;
|
|
20
|
+
registerRemoteServer(config: AngieRemoteServerConfig): Promise<void>;
|
|
21
|
+
private isLocalServerConfig;
|
|
22
|
+
private isRemoteServerConfig;
|
|
11
23
|
registerServer(config: AngieServerConfig): Promise<void>;
|
|
12
24
|
getRegistrations(): ServerRegistration[];
|
|
13
25
|
getPendingRegistrations(): ServerRegistration[];
|
|
14
26
|
isAngieReady(): boolean;
|
|
15
27
|
isReady(): boolean;
|
|
16
28
|
waitForReady(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Triggers Angie with a specified prompt and optional context
|
|
31
|
+
* @param request - The trigger request containing prompt and optional context
|
|
32
|
+
* @returns Promise resolving to Angie's response
|
|
33
|
+
*/
|
|
34
|
+
triggerAngie(request: AngieTriggerRequest): Promise<AngieTriggerResponse>;
|
|
17
35
|
destroy(): void;
|
|
18
36
|
private setupServerInitHandler;
|
|
19
37
|
private handleServerInitRequest;
|
|
38
|
+
private generateRequestId;
|
|
39
|
+
private handlePromptHash;
|
|
40
|
+
private setupPromptHashDetection;
|
|
20
41
|
}
|
package/dist/client-manager.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ServerRegistration, ClientCreationResponse } from './types';
|
|
2
2
|
export declare class ClientManager {
|
|
3
|
-
requestClientCreation(registration: ServerRegistration
|
|
3
|
+
requestClientCreation(registration: ServerRegistration & {
|
|
4
|
+
instanceId?: string;
|
|
5
|
+
}): Promise<ClientCreationResponse>;
|
|
4
6
|
}
|
package/dist/config.d.ts
ADDED
package/dist/iframe.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
angieConfig?: {
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare enum MessageEventType {
|
|
9
|
+
SDK_ANGIE_ALL_SERVERS_REGISTERED = "sdk-angie-all-servers-registered",
|
|
10
|
+
SDK_ANGIE_READY_PING = "sdk-angie-ready-ping",
|
|
11
|
+
SDK_REQUEST_CLIENT_CREATION = "sdk-request-client-creation",
|
|
12
|
+
SDK_TRIGGER_ANGIE = "sdk-trigger-angie",
|
|
13
|
+
SDK_TRIGGER_ANGIE_RESPONSE = "sdk-trigger-angie-response",
|
|
14
|
+
ANGIE_SIDEBAR_RESIZED = "angie-sidebar-resized",
|
|
15
|
+
ANGIE_SIDEBAR_TOGGLED = "angie-sidebar-toggled",
|
|
16
|
+
ANGIE_CHAT_TOGGLE = "angie-chat-toggle",
|
|
17
|
+
ANGIE_STUDIO_TOGGLE = "angie-studio-toggle",
|
|
18
|
+
ANGIE_NAVIGATE_TO_URL = "angie/navigate-to-url",
|
|
19
|
+
ANGIE_PAGE_RELOAD = "angie/page-reload"
|
|
20
|
+
}
|
|
21
|
+
type OpenIframeProps = {
|
|
22
|
+
origin?: string;
|
|
23
|
+
uiTheme: string;
|
|
24
|
+
isRTL: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const openIframe: (props: OpenIframeProps) => Promise<void>;
|
|
27
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ export { AngieMcpSdk } from './angie-mcp-sdk';
|
|
|
2
2
|
export { AngieDetector } from './angie-detector';
|
|
3
3
|
export { RegistrationQueue } from './registration-queue';
|
|
4
4
|
export { ClientManager } from './client-manager';
|
|
5
|
-
export type
|
|
5
|
+
export { ANGIE_SIDEBAR_STATE_OPEN, applyWidth, getAngieSidebarSavedState, initAngieSidebar, initializeResize, loadState, loadWidth, saveWidth, type AngieSidebarState, } from './sidebar';
|
|
6
|
+
export { waitForDocumentReady, toggleAngieSidebar } from './utils';
|
|
7
|
+
export { navigateAngieIframe } from './navigation-utils';
|
|
8
|
+
export { getAngieIframe } from './angie-iframe-utils';
|
|
9
|
+
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t,s,a;!function(e){e.POST_MESSAGE="postMessage"}(e||(e={})),function(e){e.SDK_ANGIE_READY_PING="sdk-angie-ready-ping",e.SDK_REQUEST_CLIENT_CREATION="sdk-request-client-creation",e.SDK_REQUEST_INIT_SERVER="sdk-request-init-server"}(t||(t={}));class r{isAngieReady=!1;readyPromise;readyResolve;constructor(){if(this.readyPromise=new Promise((e=>{this.readyResolve=e})),"undefined"==typeof window)return;let e=0;const s=()=>{if(this.isAngieReady||e>=500)return void(!this.isAngieReady&&e>=500&&this.handleDetectionTimeout());const a=new MessageChannel;a.port1.onmessage=e=>{this.handleAngieReady(e.data),a.port1.close(),a.port2.close()};const r={type:t.SDK_ANGIE_READY_PING,timestamp:Date.now()};window.postMessage(r,window.location.origin,[a.port2]),e++,setTimeout(s,500)};s()}handleAngieReady(e){this.isAngieReady=!0;const t={isReady:!0,version:e.version,capabilities:e.capabilities};this.readyResolve&&this.readyResolve(t)}handleDetectionTimeout(){this.readyResolve&&this.readyResolve({isReady:!1}),console.warn("AngieMcpSdk: AngieDetector: Detection timeout - Angie may not be available")}isReady(){return this.isAngieReady}async waitForReady(){return this.readyPromise}}class n{queue=[];isProcessing=!1;add(e){const t={id:this.generateId(e),config:e,timestamp:Date.now(),status:"pending"};return this.queue.push(t),console.log(`RegistrationQueue: Added server "${e.name}" to queue`),t}getAll(){return[...this.queue]}getPending(){return this.queue.filter((e=>"pending"===e.status))}updateStatus(e,t,s){const a=this.queue.find((t=>t.id===e));a&&(a.status=t,s&&(a.error=s),console.log(`RegistrationQueue: Updated server ${e} status to ${t}`))}async processQueue(e){if(this.isProcessing)return void console.log("RegistrationQueue: Already processing queue");this.isProcessing=!0;const t=this.getPending();console.log(`RegistrationQueue: Processing ${t.length} pending registrations`);try{for(const s of t)try{await e(s),this.updateStatus(s.id,"registered")}catch(e){const t=e instanceof Error?e.message:String(e);this.updateStatus(s.id,"failed",t),console.error(`RegistrationQueue: Failed to process registration ${s.id}:`,t)}}finally{this.isProcessing=!1}}clear(){this.queue=[],console.log("RegistrationQueue: Cleared all registrations")}remove(e){const t=this.queue.findIndex((t=>t.id===e));return-1!==t&&(this.queue.splice(t,1),console.log(`RegistrationQueue: Removed registration ${e}`),!0)}generateId(e){return`reg_${e.name}_${e.version}_${Date.now()}`}}class i{async requestClientCreation(s){const{config:a}=s,r={serverId:s.id,serverName:a.name,serverVersion:a.version,description:a.description,transport:e.POST_MESSAGE,capabilities:a.capabilities};return new Promise(((e,s)=>{const a=new MessageChannel,n=setTimeout((()=>{s(new Error("Client creation request timed out after 10000ms"))}),1e4);a.port1.onmessage=t=>{clearTimeout(n),e(t.data)};const i={type:t.SDK_REQUEST_CLIENT_CREATION,payload:r,timestamp:Date.now()};window.postMessage(i,window.location.origin,[a.port2])}))}}!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(s||(s={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(a||(a={}));const o=s.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),d=e=>{switch(typeof e){case"undefined":return o.undefined;case"string":return o.string;case"number":return Number.isNaN(e)?o.nan:o.number;case"boolean":return o.boolean;case"function":return o.function;case"bigint":return o.bigint;case"symbol":return o.symbol;case"object":return Array.isArray(e)?o.array:null===e?o.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?o.promise:"undefined"!=typeof Map&&e instanceof Map?o.map:"undefined"!=typeof Set&&e instanceof Set?o.set:"undefined"!=typeof Date&&e instanceof Date?o.date:o.object;default:return o.unknown}},c=s.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class u extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(a);else if("invalid_return_type"===r.code)a(r.returnTypeError);else if("invalid_arguments"===r.code)a(r.argumentsError);else if(0===r.path.length)s._errors.push(t(r));else{let e=s,a=0;for(;a<r.path.length;){const s=r.path[a];a===r.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(r))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof u))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,s.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}u.create=e=>new u(e);const l=(e,t)=>{let a;switch(e.code){case c.invalid_type:a=e.received===o.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case c.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,s.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:a=`Unrecognized key(s) in object: ${s.joinValues(e.keys,", ")}`;break;case c.invalid_union:a="Invalid input";break;case c.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${s.joinValues(e.options)}`;break;case c.invalid_enum_value:a=`Invalid enum value. Expected ${s.joinValues(e.options)}, received '${e.received}'`;break;case c.invalid_arguments:a="Invalid function arguments";break;case c.invalid_return_type:a="Invalid function return type";break;case c.invalid_date:a="Invalid date";break;case c.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:s.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case c.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case c.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case c.custom:a="Invalid input";break;case c.invalid_intersection_types:a="Intersection results could not be merged";break;case c.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case c.not_finite:a="Number must be finite";break;default:a=t.defaultError,s.assertNever(e)}return{message:a}};let h=l;function p(e,t){const s=h,a=(e=>{const{data:t,path:s,errorMaps:a,issueData:r}=e,n=[...s,...r.path||[]],i={...r,path:n};if(void 0!==r.message)return{...r,path:n,message:r.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...r,path:n,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===l?void 0:l].filter((e=>!!e))});e.common.issues.push(a)}class m{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return g;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return m.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:r}=a;if("aborted"===t.status)return g;if("aborted"===r.status)return g;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"===t.value||void 0===r.value&&!a.alwaysSet||(s[t.value]=r.value)}return{status:e.value,value:s}}}const g=Object.freeze({status:"aborted"}),f=e=>({status:"dirty",value:e}),y=e=>({status:"valid",value:e}),_=e=>"aborted"===e.status,v=e=>"dirty"===e.status,x=e=>"valid"===e.status,k=e=>"undefined"!=typeof Promise&&e instanceof Promise;var b;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(b||(b={}));class w{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const S=(e,t)=>{if(x(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new u(e.common.issues);return this._error=t,this._error}}};function T(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:r}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:r}:{errorMap:(t,r)=>{const{message:n}=e;return"invalid_enum_value"===t.code?{message:n??r.defaultError}:void 0===r.data?{message:n??a??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:n??s??r.defaultError}},description:r}}class A{get description(){return this._def.description}_getType(e){return d(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:d(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new m,ctx:{common:e.parent.common,data:e.data,parsedType:d(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(k(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:d(e)},a=this._parseSync({data:e,path:s.path,parent:s});return S(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:d(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return x(s)?{value:s.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((e=>x(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:d(e)},a=this._parse({data:e,path:s.path,parent:s}),r=await(k(a)?a:Promise.resolve(a));return S(s,r)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const r=e(t),n=()=>a.addIssue({code:c.custom,...s(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then((e=>!!e||(n(),!1))):!!r||(n(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new Te({schema:this,typeName:je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Ae.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return oe.create(this)}promise(){return Se.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return me.create(this,e,this._def)}transform(e){return new Te({...T(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Re({...T(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new Ie({typeName:je.ZodBranded,type:this,...T(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ze({...T(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ee.create(this,e)}readonly(){return Ne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C=/^c[^\s-]{8,}$/i,R=/^[0-9a-z]+$/,Z=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,I=/^[a-z0-9_-]{21}$/i,E=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,N=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let P;const $=/^(?:(?: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])$/,M=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,D=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,F=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,q=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,z=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,L="((\\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])))",V=new RegExp(`^${L}$`);function U(e){let t="[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function K(e){let t=`${L}T${U(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function Q(e,t){if(!E.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),r=JSON.parse(atob(a));return!("object"!=typeof r||null===r||"typ"in r&&"JWT"!==r?.typ||!r.alg||t&&r.alg!==t)}catch{return!1}}function B(e,t){return!("v4"!==t&&t||!M.test(e))||!("v6"!==t&&t||!F.test(e))}class W extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==o.string){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.string,received:t.parsedType}),g}const t=new m;let a;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:c.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:c.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const s=e.data.length>i.value,r=e.data.length<i.value;(s||r)&&(a=this._getOrReturnCtx(e,a),s?p(a,{code:c.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):r&&p(a,{code:c.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)j.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"email",code:c.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)P||(P=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),P.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"emoji",code:c.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)O.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"uuid",code:c.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)I.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"nanoid",code:c.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)C.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"cuid",code:c.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)R.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"cuid2",code:c.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)Z.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"ulid",code:c.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),p(a,{validation:"url",code:c.invalid_string,message:i.message}),t.dirty()}else"regex"===i.kind?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"regex",code:c.invalid_string,message:i.message}),t.dirty())):"trim"===i.kind?e.data=e.data.trim():"includes"===i.kind?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),p(a,{code:c.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):"toLowerCase"===i.kind?e.data=e.data.toLowerCase():"toUpperCase"===i.kind?e.data=e.data.toUpperCase():"startsWith"===i.kind?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),p(a,{code:c.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):"endsWith"===i.kind?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),p(a,{code:c.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):"datetime"===i.kind?K(i).test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{code:c.invalid_string,validation:"datetime",message:i.message}),t.dirty()):"date"===i.kind?V.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{code:c.invalid_string,validation:"date",message:i.message}),t.dirty()):"time"===i.kind?new RegExp(`^${U(i)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{code:c.invalid_string,validation:"time",message:i.message}),t.dirty()):"duration"===i.kind?N.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"duration",code:c.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?(r=e.data,("v4"!==(n=i.version)&&n||!$.test(r))&&("v6"!==n&&n||!D.test(r))&&(a=this._getOrReturnCtx(e,a),p(a,{validation:"ip",code:c.invalid_string,message:i.message}),t.dirty())):"jwt"===i.kind?Q(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"jwt",code:c.invalid_string,message:i.message}),t.dirty()):"cidr"===i.kind?B(e.data,i.version)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"cidr",code:c.invalid_string,message:i.message}),t.dirty()):"base64"===i.kind?q.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"base64",code:c.invalid_string,message:i.message}),t.dirty()):"base64url"===i.kind?z.test(e.data)||(a=this._getOrReturnCtx(e,a),p(a,{validation:"base64url",code:c.invalid_string,message:i.message}),t.dirty()):s.assertNever(i);var r,n;return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:c.invalid_string,...b.errToObj(s)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function H(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,r=s>a?s:a;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}W.create=e=>new W({checks:[],typeName:je.ZodString,coerce:e?.coerce??!1,...T(e)});class G extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==o.number){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.number,received:t.parsedType}),g}let t;const a=new m;for(const r of this._def.checks)"int"===r.kind?s.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:c.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:c.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:c.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"multipleOf"===r.kind?0!==H(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:c.not_finite,message:r.message}),a.dirty()):s.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,a){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(a)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&s.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}G.create=e=>new G({checks:[],typeName:je.ZodNumber,coerce:e?.coerce||!1,...T(e)});class J extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==o.bigint)return this._getInvalidInput(e);let t;const a=new m;for(const r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:c.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:c.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),p(t,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):s.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,s,a){return new J({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:b.toString(a)}]})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}J.create=e=>new J({checks:[],typeName:je.ZodBigInt,coerce:e?.coerce??!1,...T(e)});class Y extends A{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==o.boolean){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.boolean,received:t.parsedType}),g}return y(e.data)}}Y.create=e=>new Y({typeName:je.ZodBoolean,coerce:e?.coerce||!1,...T(e)});class X extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==o.date){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.date,received:t.parsedType}),g}if(Number.isNaN(e.data.getTime()))return p(this._getOrReturnCtx(e),{code:c.invalid_date}),g;const t=new m;let a;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:c.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),p(a,{code:c.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):s.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}X.create=e=>new X({checks:[],coerce:e?.coerce||!1,typeName:je.ZodDate,...T(e)});class ee extends A{_parse(e){if(this._getType(e)!==o.symbol){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.symbol,received:t.parsedType}),g}return y(e.data)}}ee.create=e=>new ee({typeName:je.ZodSymbol,...T(e)});class te extends A{_parse(e){if(this._getType(e)!==o.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.undefined,received:t.parsedType}),g}return y(e.data)}}te.create=e=>new te({typeName:je.ZodUndefined,...T(e)});class se extends A{_parse(e){if(this._getType(e)!==o.null){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.null,received:t.parsedType}),g}return y(e.data)}}se.create=e=>new se({typeName:je.ZodNull,...T(e)});class ae extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return y(e.data)}}ae.create=e=>new ae({typeName:je.ZodAny,...T(e)});class re extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return y(e.data)}}re.create=e=>new re({typeName:je.ZodUnknown,...T(e)});class ne extends A{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.never,received:t.parsedType}),g}}ne.create=e=>new ne({typeName:je.ZodNever,...T(e)});class ie extends A{_parse(e){if(this._getType(e)!==o.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.void,received:t.parsedType}),g}return y(e.data)}}ie.create=e=>new ie({typeName:je.ZodVoid,...T(e)});class oe extends A{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==o.array)return p(t,{code:c.invalid_type,expected:o.array,received:t.parsedType}),g;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,r=t.data.length<a.exactLength.value;(e||r)&&(p(t,{code:e?c.too_big:c.too_small,minimum:r?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(p(t,{code:c.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(p(t,{code:c.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new w(t,e,t.path,s))))).then((e=>m.mergeArray(s,e)));const r=[...t.data].map(((e,s)=>a.type._parseSync(new w(t,e,t.path,s))));return m.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new oe({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new oe({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new oe({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}function de(e){if(e instanceof ce){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Ae.create(de(a))}return new ce({...e._def,shape:()=>t})}return e instanceof oe?new oe({...e._def,type:de(e.element)}):e instanceof Ae?Ae.create(de(e.unwrap())):e instanceof Ce?Ce.create(de(e.unwrap())):e instanceof ge?ge.create(e.items.map((e=>de(e)))):e}oe.create=(e,t)=>new oe({type:e,minLength:null,maxLength:null,exactLength:null,typeName:je.ZodArray,...T(t)});class ce extends A{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=s.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==o.object){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.object,received:t.parsedType}),g}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:r}=this._getCached(),n=[];if(!(this._def.catchall instanceof ne&&"strip"===this._def.unknownKeys))for(const e in s.data)r.includes(e)||n.push(e);const i=[];for(const e of r){const t=a[e],r=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new w(s,r,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof ne){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of n)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)n.length>0&&(p(s,{code:c.unrecognized_keys,keys:n}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of n){const a=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new w(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of i){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>m.mergeObjectSync(t,e))):m.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new ce({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:b.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ce({...this._def,unknownKeys:"strip"})}passthrough(){return new ce({...this._def,unknownKeys:"passthrough"})}extend(e){return new ce({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ce({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ce({...this._def,catchall:e})}pick(e){const t={};for(const a of s.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new ce({...this._def,shape:()=>t})}omit(e){const t={};for(const a of s.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new ce({...this._def,shape:()=>t})}deepPartial(){return de(this)}partial(e){const t={};for(const a of s.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new ce({...this._def,shape:()=>t})}required(e){const t={};for(const a of s.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof Ae;)e=e._def.innerType;t[a]=e}return new ce({...this._def,shape:()=>t})}keyof(){return ke(s.objectKeys(this.shape))}}ce.create=(e,t)=>new ce({shape:()=>e,unknownKeys:"strip",catchall:ne.create(),typeName:je.ZodObject,...T(t)}),ce.strictCreate=(e,t)=>new ce({shape:()=>e,unknownKeys:"strict",catchall:ne.create(),typeName:je.ZodObject,...T(t)}),ce.lazycreate=(e,t)=>new ce({shape:e,unknownKeys:"strip",catchall:ne.create(),typeName:je.ZodObject,...T(t)});class ue extends A{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new u(e.ctx.common.issues)));return p(t,{code:c.invalid_union,unionErrors:s}),g}));{let e;const a=[];for(const r of s){const s={...t,common:{...t.common,issues:[]},parent:null},n=r._parseSync({data:t.data,path:t.path,parent:s});if("valid"===n.status)return n;"dirty"!==n.status||e||(e={result:n,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const r=a.map((e=>new u(e)));return p(t,{code:c.invalid_union,unionErrors:r}),g}}get options(){return this._def.options}}ue.create=(e,t)=>new ue({options:e,typeName:je.ZodUnion,...T(t)});const le=e=>e instanceof ve?le(e.schema):e instanceof Te?le(e.innerType()):e instanceof xe?[e.value]:e instanceof be?e.options:e instanceof we?s.objectValues(e.enum):e instanceof Re?le(e._def.innerType):e instanceof te?[void 0]:e instanceof se?[null]:e instanceof Ae?[void 0,...le(e.unwrap())]:e instanceof Ce?[null,...le(e.unwrap())]:e instanceof Ie||e instanceof Ne?le(e.unwrap()):e instanceof Ze?le(e._def.innerType):[];class he extends A{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.object)return p(t,{code:c.invalid_type,expected:o.object,received:t.parsedType}),g;const s=this.discriminator,a=t.data[s],r=this.optionsMap.get(a);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=le(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const r of t){if(a.has(r))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);a.set(r,s)}}return new he({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...T(s)})}}function pe(e,t){const a=d(e),r=d(t);if(e===t)return{valid:!0,data:e};if(a===o.object&&r===o.object){const a=s.objectKeys(t),r=s.objectKeys(e).filter((e=>-1!==a.indexOf(e))),n={...e,...t};for(const s of r){const a=pe(e[s],t[s]);if(!a.valid)return{valid:!1};n[s]=a.data}return{valid:!0,data:n}}if(a===o.array&&r===o.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const r=pe(e[a],t[a]);if(!r.valid)return{valid:!1};s.push(r.data)}return{valid:!0,data:s}}return a===o.date&&r===o.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class me extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(_(e)||_(a))return g;const r=pe(e.value,a.value);return r.valid?((v(e)||v(a))&&t.dirty(),{status:t.value,value:r.data}):(p(s,{code:c.invalid_intersection_types}),g)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}me.create=(e,t,s)=>new me({left:e,right:t,typeName:je.ZodIntersection,...T(s)});class ge extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.array)return p(s,{code:c.invalid_type,expected:o.array,received:s.parsedType}),g;if(s.data.length<this._def.items.length)return p(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&s.data.length>this._def.items.length&&(p(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new w(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>m.mergeArray(t,e))):m.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ge({...this._def,rest:e})}}ge.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ge({items:e,typeName:je.ZodTuple,rest:null,...T(t)})};class fe extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.object)return p(s,{code:c.invalid_type,expected:o.object,received:s.parsedType}),g;const a=[],r=this._def.keyType,n=this._def.valueType;for(const e in s.data)a.push({key:r._parse(new w(s,e,s.path,e)),value:n._parse(new w(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?m.mergeObjectAsync(t,a):m.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new fe(t instanceof A?{keyType:e,valueType:t,typeName:je.ZodRecord,...T(s)}:{keyType:W.create(),valueType:e,typeName:je.ZodRecord,...T(t)})}}class ye extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.map)return p(s,{code:c.invalid_type,expected:o.map,received:s.parsedType}),g;const a=this._def.keyType,r=this._def.valueType,n=[...s.data.entries()].map((([e,t],n)=>({key:a._parse(new w(s,e,s.path,[n,"key"])),value:r._parse(new w(s,t,s.path,[n,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of n){const a=await s.key,r=await s.value;if("aborted"===a.status||"aborted"===r.status)return g;"dirty"!==a.status&&"dirty"!==r.status||t.dirty(),e.set(a.value,r.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of n){const a=s.key,r=s.value;if("aborted"===a.status||"aborted"===r.status)return g;"dirty"!==a.status&&"dirty"!==r.status||t.dirty(),e.set(a.value,r.value)}return{status:t.value,value:e}}}}ye.create=(e,t,s)=>new ye({valueType:t,keyType:e,typeName:je.ZodMap,...T(s)});class _e extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.set)return p(s,{code:c.invalid_type,expected:o.set,received:s.parsedType}),g;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(p(s,{code:c.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(p(s,{code:c.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const r=this._def.valueType;function n(e){const s=new Set;for(const a of e){if("aborted"===a.status)return g;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const i=[...s.data.values()].map(((e,t)=>r._parse(new w(s,e,s.path,t))));return s.common.async?Promise.all(i).then((e=>n(e))):n(i)}min(e,t){return new _e({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new _e({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(e,t)=>new _e({valueType:e,minSize:null,maxSize:null,typeName:je.ZodSet,...T(t)});class ve extends A{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ve.create=(e,t)=>new ve({getter:e,typeName:je.ZodLazy,...T(t)});class xe extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ke(e,t){return new be({values:e,typeName:je.ZodEnum,...T(t)})}xe.create=(e,t)=>new xe({value:e,typeName:je.ZodLiteral,...T(t)});class be extends A{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return p(t,{expected:s.joinValues(a),received:t.parsedType,code:c.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return p(t,{received:t.data,code:c.invalid_enum_value,options:s}),g}return y(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return be.create(e,{...this._def,...t})}exclude(e,t=this._def){return be.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}be.create=ke;class we extends A{_parse(e){const t=s.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==o.string&&a.parsedType!==o.number){const e=s.objectValues(t);return p(a,{expected:s.joinValues(e),received:a.parsedType,code:c.invalid_type}),g}if(this._cache||(this._cache=new Set(s.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=s.objectValues(t);return p(a,{received:a.data,code:c.invalid_enum_value,options:e}),g}return y(e.data)}get enum(){return this._def.values}}we.create=(e,t)=>new we({values:e,typeName:je.ZodNativeEnum,...T(t)});class Se extends A{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.promise&&!1===t.common.async)return p(t,{code:c.invalid_type,expected:o.promise,received:t.parsedType}),g;const s=t.parsedType===o.promise?t.data:Promise.resolve(t.data);return y(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}Se.create=(e,t)=>new Se({type:e,typeName:je.ZodPromise,...T(t)});class Te extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:e=>{p(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===r.type){const e=r.transform(a.data,n);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return g;const s=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===s.status?g:"dirty"===s.status||"dirty"===t.value?f(s.value):s}));{if("aborted"===t.value)return g;const s=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===s.status?g:"dirty"===s.status||"dirty"===t.value?f(s.value):s}}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,n);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const s=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===s.status?g:("dirty"===s.status&&t.dirty(),e(s.value),{status:t.value,value:s.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((s=>"aborted"===s.status?g:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===r.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!x(e))return g;const s=r.transform(e.value,n);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>x(e)?Promise.resolve(r.transform(e.value,n)).then((e=>({status:t.value,value:e}))):g))}s.assertNever(r)}}Te.create=(e,t,s)=>new Te({schema:e,typeName:je.ZodEffects,effect:t,...T(s)}),Te.createWithPreprocess=(e,t,s)=>new Te({schema:t,effect:{type:"preprocess",transform:e},typeName:je.ZodEffects,...T(s)});class Ae extends A{_parse(e){return this._getType(e)===o.undefined?y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ae.create=(e,t)=>new Ae({innerType:e,typeName:je.ZodOptional,...T(t)});class Ce extends A{_parse(e){return this._getType(e)===o.null?y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:je.ZodNullable,...T(t)});class Re extends A{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===o.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Re.create=(e,t)=>new Re({innerType:e,typeName:je.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...T(t)});class Ze extends A{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return k(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new u(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new u(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ze.create=(e,t)=>new Ze({innerType:e,typeName:je.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...T(t)});class Oe extends A{_parse(e){if(this._getType(e)!==o.nan){const t=this._getOrReturnCtx(e);return p(t,{code:c.invalid_type,expected:o.nan,received:t.parsedType}),g}return{status:"valid",value:e.data}}}Oe.create=e=>new Oe({typeName:je.ZodNaN,...T(e)}),Symbol("zod_brand");class Ie extends A{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ee extends A{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?g:"dirty"===e.status?(t.dirty(),f(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})();{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?g:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Ee({in:e,out:t,typeName:je.ZodPipeline})}}class Ne extends A{_parse(e){const t=this._def.innerType._parse(e),s=e=>(x(e)&&(e.value=Object.freeze(e.value)),e);return k(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}var je;Ne.create=(e,t)=>new Ne({innerType:e,typeName:je.ZodReadonly,...T(t)}),ce.lazycreate,function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(je||(je={}));const Pe=W.create,$e=G.create,Me=(Oe.create,J.create,Y.create),De=(X.create,ee.create,te.create,se.create,ae.create,re.create),Fe=(ne.create,ie.create,oe.create),qe=ce.create,ze=(ce.strictCreate,ue.create),Le=he.create,Ve=(me.create,ge.create,fe.create),Ue=(ye.create,_e.create,ve.create,xe.create),Ke=be.create,Qe=(we.create,Se.create,Te.create,Ae.create),Be=(Ce.create,Te.createWithPreprocess,Ee.create,"2.0"),We=ze([Pe(),$e().int()]),He=Pe(),Ge=qe({progressToken:Qe(We)}).passthrough(),Je=qe({_meta:Qe(Ge)}).passthrough(),Ye=qe({method:Pe(),params:Qe(Je)}),Xe=qe({_meta:Qe(qe({}).passthrough())}).passthrough(),et=qe({method:Pe(),params:Qe(Xe)}),tt=qe({_meta:Qe(qe({}).passthrough())}).passthrough(),st=ze([Pe(),$e().int()]),at=qe({jsonrpc:Ue(Be),id:st}).merge(Ye).strict(),rt=qe({jsonrpc:Ue(Be)}).merge(et).strict(),nt=qe({jsonrpc:Ue(Be),id:st,result:tt}).strict();var it;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError"}(it||(it={}));const ot=ze([at,rt,nt,qe({jsonrpc:Ue(Be),id:st,error:qe({code:$e().int(),message:Pe(),data:Qe(De())})}).strict()]),dt=tt.strict(),ct=et.extend({method:Ue("notifications/cancelled"),params:Xe.extend({requestId:st,reason:Pe().optional()})}),ut=qe({name:Pe(),title:Qe(Pe())}).passthrough(),lt=ut.extend({version:Pe()}),ht=qe({experimental:Qe(qe({}).passthrough()),sampling:Qe(qe({}).passthrough()),elicitation:Qe(qe({}).passthrough()),roots:Qe(qe({listChanged:Qe(Me())}).passthrough())}).passthrough(),pt=Ye.extend({method:Ue("initialize"),params:Je.extend({protocolVersion:Pe(),capabilities:ht,clientInfo:lt})}),mt=qe({experimental:Qe(qe({}).passthrough()),logging:Qe(qe({}).passthrough()),completions:Qe(qe({}).passthrough()),prompts:Qe(qe({listChanged:Qe(Me())}).passthrough()),resources:Qe(qe({subscribe:Qe(Me()),listChanged:Qe(Me())}).passthrough()),tools:Qe(qe({listChanged:Qe(Me())}).passthrough())}).passthrough(),gt=tt.extend({protocolVersion:Pe(),capabilities:mt,serverInfo:lt,instructions:Qe(Pe())}),ft=et.extend({method:Ue("notifications/initialized")}),yt=Ye.extend({method:Ue("ping")}),_t=qe({progress:$e(),total:Qe($e()),message:Qe(Pe())}).passthrough(),vt=et.extend({method:Ue("notifications/progress"),params:Xe.merge(_t).extend({progressToken:We})}),xt=Ye.extend({params:Je.extend({cursor:Qe(He)}).optional()}),kt=tt.extend({nextCursor:Qe(He)}),bt=qe({uri:Pe(),mimeType:Qe(Pe()),_meta:Qe(qe({}).passthrough())}).passthrough(),wt=bt.extend({text:Pe()}),St=bt.extend({blob:Pe().base64()}),Tt=ut.extend({uri:Pe(),description:Qe(Pe()),mimeType:Qe(Pe()),_meta:Qe(qe({}).passthrough())}),At=ut.extend({uriTemplate:Pe(),description:Qe(Pe()),mimeType:Qe(Pe()),_meta:Qe(qe({}).passthrough())}),Ct=xt.extend({method:Ue("resources/list")}),Rt=kt.extend({resources:Fe(Tt)}),Zt=xt.extend({method:Ue("resources/templates/list")}),Ot=kt.extend({resourceTemplates:Fe(At)}),It=Ye.extend({method:Ue("resources/read"),params:Je.extend({uri:Pe()})}),Et=tt.extend({contents:Fe(ze([wt,St]))}),Nt=et.extend({method:Ue("notifications/resources/list_changed")}),jt=Ye.extend({method:Ue("resources/subscribe"),params:Je.extend({uri:Pe()})}),Pt=Ye.extend({method:Ue("resources/unsubscribe"),params:Je.extend({uri:Pe()})}),$t=et.extend({method:Ue("notifications/resources/updated"),params:Xe.extend({uri:Pe()})}),Mt=qe({name:Pe(),description:Qe(Pe()),required:Qe(Me())}).passthrough(),Dt=ut.extend({description:Qe(Pe()),arguments:Qe(Fe(Mt)),_meta:Qe(qe({}).passthrough())}),Ft=xt.extend({method:Ue("prompts/list")}),qt=kt.extend({prompts:Fe(Dt)}),zt=Ye.extend({method:Ue("prompts/get"),params:Je.extend({name:Pe(),arguments:Qe(Ve(Pe()))})}),Lt=qe({type:Ue("text"),text:Pe(),_meta:Qe(qe({}).passthrough())}).passthrough(),Vt=qe({type:Ue("image"),data:Pe().base64(),mimeType:Pe(),_meta:Qe(qe({}).passthrough())}).passthrough(),Ut=qe({type:Ue("audio"),data:Pe().base64(),mimeType:Pe(),_meta:Qe(qe({}).passthrough())}).passthrough(),Kt=qe({type:Ue("resource"),resource:ze([wt,St]),_meta:Qe(qe({}).passthrough())}).passthrough(),Qt=ze([Lt,Vt,Ut,Tt.extend({type:Ue("resource_link")}),Kt]),Bt=qe({role:Ke(["user","assistant"]),content:Qt}).passthrough(),Wt=tt.extend({description:Qe(Pe()),messages:Fe(Bt)}),Ht=et.extend({method:Ue("notifications/prompts/list_changed")}),Gt=qe({title:Qe(Pe()),readOnlyHint:Qe(Me()),destructiveHint:Qe(Me()),idempotentHint:Qe(Me()),openWorldHint:Qe(Me())}).passthrough(),Jt=ut.extend({description:Qe(Pe()),inputSchema:qe({type:Ue("object"),properties:Qe(qe({}).passthrough()),required:Qe(Fe(Pe()))}).passthrough(),outputSchema:Qe(qe({type:Ue("object"),properties:Qe(qe({}).passthrough()),required:Qe(Fe(Pe()))}).passthrough()),annotations:Qe(Gt),_meta:Qe(qe({}).passthrough())}),Yt=xt.extend({method:Ue("tools/list")}),Xt=kt.extend({tools:Fe(Jt)}),es=tt.extend({content:Fe(Qt).default([]),structuredContent:qe({}).passthrough().optional(),isError:Qe(Me())}),ts=(es.or(tt.extend({toolResult:De()})),Ye.extend({method:Ue("tools/call"),params:Je.extend({name:Pe(),arguments:Qe(Ve(De()))})})),ss=et.extend({method:Ue("notifications/tools/list_changed")}),as=Ke(["debug","info","notice","warning","error","critical","alert","emergency"]),rs=Ye.extend({method:Ue("logging/setLevel"),params:Je.extend({level:as})}),ns=et.extend({method:Ue("notifications/message"),params:Xe.extend({level:as,logger:Qe(Pe()),data:De()})}),is=qe({name:Pe().optional()}).passthrough(),os=qe({hints:Qe(Fe(is)),costPriority:Qe($e().min(0).max(1)),speedPriority:Qe($e().min(0).max(1)),intelligencePriority:Qe($e().min(0).max(1))}).passthrough(),ds=qe({role:Ke(["user","assistant"]),content:ze([Lt,Vt,Ut])}).passthrough(),cs=Ye.extend({method:Ue("sampling/createMessage"),params:Je.extend({messages:Fe(ds),systemPrompt:Qe(Pe()),includeContext:Qe(Ke(["none","thisServer","allServers"])),temperature:Qe($e()),maxTokens:$e().int(),stopSequences:Qe(Fe(Pe())),metadata:Qe(qe({}).passthrough()),modelPreferences:Qe(os)})}),us=tt.extend({model:Pe(),stopReason:Qe(Ke(["endTurn","stopSequence","maxTokens"]).or(Pe())),role:Ke(["user","assistant"]),content:Le("type",[Lt,Vt,Ut])}),ls=ze([qe({type:Ue("boolean"),title:Qe(Pe()),description:Qe(Pe()),default:Qe(Me())}).passthrough(),qe({type:Ue("string"),title:Qe(Pe()),description:Qe(Pe()),minLength:Qe($e()),maxLength:Qe($e()),format:Qe(Ke(["email","uri","date","date-time"]))}).passthrough(),qe({type:Ke(["number","integer"]),title:Qe(Pe()),description:Qe(Pe()),minimum:Qe($e()),maximum:Qe($e())}).passthrough(),qe({type:Ue("string"),title:Qe(Pe()),description:Qe(Pe()),enum:Fe(Pe()),enumNames:Qe(Fe(Pe()))}).passthrough()]),hs=Ye.extend({method:Ue("elicitation/create"),params:Je.extend({message:Pe(),requestedSchema:qe({type:Ue("object"),properties:Ve(Pe(),ls),required:Qe(Fe(Pe()))}).passthrough()})}),ps=tt.extend({action:Ke(["accept","reject","cancel"]),content:Qe(Ve(Pe(),De()))}),ms=qe({type:Ue("ref/resource"),uri:Pe()}).passthrough(),gs=qe({type:Ue("ref/prompt"),name:Pe()}).passthrough(),fs=Ye.extend({method:Ue("completion/complete"),params:Je.extend({ref:ze([gs,ms]),argument:qe({name:Pe(),value:Pe()}).passthrough(),context:Qe(qe({arguments:Qe(Ve(Pe(),Pe()))}))})}),ys=tt.extend({completion:qe({values:Fe(Pe()).max(100),total:Qe($e().int()),hasMore:Qe(Me())}).passthrough()}),_s=qe({uri:Pe().startsWith("file://"),name:Qe(Pe()),_meta:Qe(qe({}).passthrough())}).passthrough(),vs=Ye.extend({method:Ue("roots/list")}),xs=tt.extend({roots:Fe(_s)}),ks=et.extend({method:Ue("notifications/roots/list_changed")});ze([yt,pt,fs,rs,zt,Ft,Ct,Zt,It,jt,Pt,ts,Yt]),ze([ct,vt,ft,ks]),ze([dt,us,ps,xs]),ze([yt,cs,hs,vs]),ze([ct,vt,ns,$t,Nt,ss,Ht]),ze([dt,gt,ys,Wt,qt,Rt,Ot,Et,es,Xt]),Error;class bs{sessionId;onmessage;onerror;onclose;_port;_started=!1;_closed=!1;constructor(e,t){if(!e)throw new Error("MessagePort is required");this._port=e,this.sessionId=t||this.generateId(),this._port.onmessage=e=>{try{const t=ot.parse(e.data);this.onmessage?.(t)}catch(e){const t=new Error(`Failed to parse message: ${e}`);this.onerror?.(t)}},this._port.onmessageerror=e=>{const t=new Error(`MessagePort error: ${JSON.stringify(e)}`);this.onerror?.(t)}}static generateSessionId(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,10)}`}async start(){if(this._started)throw new Error("BrowserContextTransport already started! If using Client or Server class, note that connect() calls start() automatically.");if(this._closed)throw new Error("Cannot start a closed BrowserContextTransport");this._started=!0,this._port.start()}async send(e){if(this._closed)throw new Error("Cannot send on a closed BrowserContextTransport");return new Promise(((t,s)=>{try{this._port.postMessage(e),t()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.onerror?.(t),s(t)}}))}async close(){this._closed||(this._closed=!0,this._port.close(),this.onclose?.())}generateId(){return bs.generateSessionId()}}class ws{angieDetector;registrationQueue;clientManager;isInitialized=!1;constructor(){this.angieDetector=new r,this.registrationQueue=new n,this.clientManager=new i,this.setupAngieReadyHandler(),this.setupServerInitHandler()}setupAngieReadyHandler(){this.angieDetector.waitForReady().then((e=>{e.isReady?this.handleAngieReady():console.warn("AngieMcpSdk: Angie not detected - servers will remain queued")})).catch((e=>{console.error("AngieMcpSdk: Error waiting for Angie:",e)}))}async handleAngieReady(){console.log("AngieMcpSdk: Angie is ready, processing queued registrations");try{await this.registrationQueue.processQueue((async e=>{await this.processRegistration(e)})),this.isInitialized=!0,console.log("AngieMcpSdk: Initialization complete")}catch(e){console.error("AngieMcpSdk: Error processing registration queue:",e)}}async processRegistration(e){console.log(`AngieMcpSdk: Processing registration for server "${e.config.name}"`);try{await this.clientManager.requestClientCreation(e),console.log(`AngieMcpSdk: Successfully registered server "${e.config.name}"`)}catch(t){throw console.error(`AngieMcpSdk: Failed to register server "${e.config.name}":`,t),t}}async registerServer(e){if(!e.server)throw new Error("Server instance is required");if(!e.name)throw new Error("Server name is required");if(!e.description)throw new Error("Server description is required");console.log(`AngieMcpSdk: Registering server "${e.name}"`);const t=this.registrationQueue.add(e);if(this.angieDetector.isReady())try{await this.processRegistration(t),this.registrationQueue.updateStatus(t.id,"registered"),console.log(`AngieMcpSdk: Server "${e.name}" registered successfully`)}catch(e){const s=e instanceof Error?e.message:String(e);throw this.registrationQueue.updateStatus(t.id,"failed",s),e}else console.log(`AngieMcpSdk: Server "${e.name}" queued until Angie is ready`)}getRegistrations(){return this.registrationQueue.getAll()}getPendingRegistrations(){return this.registrationQueue.getPending()}isAngieReady(){return this.angieDetector.isReady()}isReady(){return this.isInitialized}async waitForReady(){if(!(await this.angieDetector.waitForReady()).isReady)throw new Error("Angie is not available");for(;!this.isInitialized;)await new Promise((e=>setTimeout(e,100)))}destroy(){this.registrationQueue.clear(),console.log("AngieMcpSdk: SDK destroyed")}setupServerInitHandler(){window.addEventListener("message",(e=>{e.data?.type===t.SDK_REQUEST_INIT_SERVER&&this.handleServerInitRequest(e)}))}handleServerInitRequest(e){const{clientId:t,serverId:s}=e.data.payload||{};if(t&&s){console.log(`AngieMcpSdk: Handling server init request for clientId: ${t}, serverId: ${s}`);try{const t=this.registrationQueue.getAll().find((e=>e.id===s));if(!t)return void console.error(`AngieMcpSdk: No registration found for serverId: ${s}`);const a=e.ports[0];if(!a)return void console.error("AngieMcpSdk: No port provided in server init request");const r=t.config.server,n=new bs(a);r.connect(n),console.log(`AngieMcpSdk: Server "${t.config.name}" initialized successfully`)}catch(e){console.error(`AngieMcpSdk: Error initializing server for clientId ${t}:`,e)}}else console.error("AngieMcpSdk: Invalid server init request - missing clientId or serverId")}}export{r as AngieDetector,ws as AngieMcpSdk,i as ClientManager,n as RegistrationQueue};
|
|
1
|
+
var e,t,n,s,a,i,r,o,d;(function(e){e.POST_MESSAGE="postMessage"})(e||(e={})),function(e){e.POST_MESSAGE="postMessage"}(t||(t={})),function(e){e.STREAMABLE_HTTP="streamableHttp",e.SSE="sse"}(n||(n={})),function(e){e.LOCAL="local",e.REMOTE="remote"}(s||(s={})),function(e){e.SDK_ANGIE_READY_PING="sdk-angie-ready-ping",e.SDK_ANGIE_REFRESH_PING="sdk-angie-refresh-ping",e.SDK_REQUEST_CLIENT_CREATION="sdk-request-client-creation",e.SDK_REQUEST_INIT_SERVER="sdk-request-init-server",e.SDK_TRIGGER_ANGIE="sdk-trigger-angie",e.SDK_TRIGGER_ANGIE_RESPONSE="sdk-trigger-angie-response"}(a||(a={})),function(e){e.SET="ANGIE_SET_LOCALSTORAGE",e.GET="ANGIE_GET_LOCALSTORAGE"}(i||(i={})),function(e){e.RESET_HASH="reset-hash",e.HOST_READY="host/ready",e.ANGIE_LOADED="angie/loaded",e.ANGIE_READY="angie/ready"}(r||(r={}));class c{isAngieReady=!1;readyPromise;readyResolve;constructor(){if(this.readyPromise=new Promise(e=>{this.readyResolve=e}),"undefined"==typeof window)return;let e=0;const t=()=>{if(this.isAngieReady||e>=500)return void(!this.isAngieReady&&e>=500&&this.handleDetectionTimeout());const n=new MessageChannel;n.port1.onmessage=e=>{this.handleAngieReady(e.data),n.port1.close(),n.port2.close()};const s={type:a.SDK_ANGIE_READY_PING,timestamp:Date.now()};window.postMessage(s,window.location.origin,[n.port2]),e++,setTimeout(t,500)};t()}handleAngieReady(e){this.isAngieReady=!0;const t={isReady:!0,version:e.version,capabilities:e.capabilities};this.readyResolve&&this.readyResolve(t)}handleDetectionTimeout(){this.readyResolve&&this.readyResolve({isReady:!1}),console.warn("AngieMcpSdk: AngieDetector: Detection timeout - Angie may not be available")}isReady(){return this.isAngieReady}async waitForReady(){return this.readyPromise}}class u{queue=[];isProcessing=!1;add(e){const t={id:this.generateId(e),config:e,timestamp:Date.now(),status:"pending"};return this.queue.push(t),console.log(`RegistrationQueue: Added server "${e.name}" to queue`),t}getAll(){return[...this.queue]}getPending(){return this.queue.filter(e=>"pending"===e.status)}updateStatus(e,t,n){const s=this.queue.find(t=>t.id===e);s&&(s.status=t,n?s.error=n:"pending"!==t&&"registered"!==t||delete s.error,console.log(`RegistrationQueue: Updated server ${e} status to ${t}`))}async processQueue(e){if(this.isProcessing)return void console.log("RegistrationQueue: Already processing queue");this.isProcessing=!0;const t=this.getPending();console.log(`RegistrationQueue: Processing ${t.length} pending registrations`);try{for(const n of t)try{await e(n),this.updateStatus(n.id,"registered")}catch(e){const t=e instanceof Error?e.message:String(e);this.updateStatus(n.id,"failed",t),console.error(`RegistrationQueue: Failed to process registration ${n.id}:`,t)}}finally{this.isProcessing=!1}}clear(){this.queue=[],console.log("RegistrationQueue: Cleared all registrations")}resetAllToPending(){if(this.isProcessing)return console.log("RegistrationQueue: Cannot reset to pending - processing in progress"),!1;const e=this.queue.filter(e=>"registered"===e.status).length,t=this.queue.filter(e=>"failed"===e.status).length;return this.queue.forEach(e=>{"pending"!==e.status&&(e.status="pending",delete e.error)}),console.log(`RegistrationQueue: Reset ${e+t} registrations to pending`),!0}remove(e){const t=this.queue.findIndex(t=>t.id===e);return-1!==t&&(this.queue.splice(t,1),console.log(`RegistrationQueue: Removed registration ${e}`),!0)}generateId(e){return`reg_${e.name}_${e.version}_${Date.now()}`}}class l{async requestClientCreation(e){const{config:n}=e,s={serverId:e.id,serverName:n.name,serverVersion:n.version,description:n.description,transport:n.transport||t.POST_MESSAGE,capabilities:n.capabilities,instanceId:e.instanceId};return"type"in n&&"remote"===n.type&&(s.remote={url:n.url}),new Promise((e,t)=>{const n=new MessageChannel,i=setTimeout(()=>{t(new Error("Client creation request timed out after 15000ms"))},15e3);n.port1.onmessage=t=>{clearTimeout(i),e(t.data)};const r={type:a.SDK_REQUEST_CLIENT_CREATION,payload:s,timestamp:Date.now()};window.postMessage(r,window.location.origin,[n.port2])})}}!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),s={};for(const e of n)s[e]=t[e];return e.objectValues(s)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(o||(o={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(d||(d={}));const h=o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),p=e=>{switch(typeof e){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(e)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(e)?h.array:null===e?h.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?h.promise:"undefined"!=typeof Map&&e instanceof Map?h.map:"undefined"!=typeof Set&&e instanceof Set?h.set:"undefined"!=typeof Date&&e instanceof Date?h.date:h.object;default:return h.unknown}},g=o.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class m extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},s=e=>{for(const a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(s);else if("invalid_return_type"===a.code)s(a.returnTypeError);else if("invalid_arguments"===a.code)s(a.argumentsError);else if(0===a.path.length)n._errors.push(t(a));else{let e=n,s=0;for(;s<a.path.length;){const n=a.path[s];s===a.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(a))):e[n]=e[n]||{_errors:[]},e=e[n],s++}}};return s(this),n}static assert(e){if(!(e instanceof m))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const s of this.issues)if(s.path.length>0){const n=s.path[0];t[n]=t[n]||[],t[n].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}m.create=e=>new m(e);const f=(e,t)=>{let n;switch(e.code){case g.invalid_type:n=e.received===h.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case g.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,o.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:n=`Unrecognized key(s) in object: ${o.joinValues(e.keys,", ")}`;break;case g.invalid_union:n="Invalid input";break;case g.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${o.joinValues(e.options)}`;break;case g.invalid_enum_value:n=`Invalid enum value. Expected ${o.joinValues(e.options)}, received '${e.received}'`;break;case g.invalid_arguments:n="Invalid function arguments";break;case g.invalid_return_type:n="Invalid function return type";break;case g.invalid_date:n="Invalid date";break;case g.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:o.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case g.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case g.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case g.custom:n="Invalid input";break;case g.invalid_intersection_types:n="Intersection results could not be merged";break;case g.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case g.not_finite:n="Number must be finite";break;default:n=t.defaultError,o.assertNever(e)}return{message:n}};let y=f;var _;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(_||(_={}));function v(e,t){const n=y,s=(e=>{const{data:t,path:n,errorMaps:s,issueData:a}=e,i=[...n,...a.path||[]],r={...a,path:i};if(void 0!==a.message)return{...a,path:i,message:a.message};let o="";const d=s.filter(e=>!!e).slice().reverse();for(const e of d)o=e(r,{data:t,defaultError:o}).message;return{...a,path:i,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===f?void 0:f].filter(e=>!!e)});e.common.issues.push(s)}class w{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if("aborted"===s.status)return b;"dirty"===s.status&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,s=await e.value;n.push({key:t,value:s})}return w.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:t,value:a}=s;if("aborted"===t.status)return b;if("aborted"===a.status)return b;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"===t.value||void 0===a.value&&!s.alwaysSet||(n[t.value]=a.value)}return{status:e.value,value:n}}}const b=Object.freeze({status:"aborted"}),x=e=>({status:"dirty",value:e}),k=e=>({status:"valid",value:e}),S=e=>"aborted"===e.status,I=e=>"dirty"===e.status,A=e=>"valid"===e.status,E=e=>"undefined"!=typeof Promise&&e instanceof Promise;class T{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const R=(e,t)=>{if(A(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new m(e.common.issues);return this._error=t,this._error}}};function O(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:s,description:a}=e;if(t&&(n||s))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:a}:{errorMap:(t,a)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??a.defaultError}:void 0===a.data?{message:i??s??a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:i??n??a.defaultError}},description:a}}class C{get description(){return this._def.description}_getType(e){return p(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:p(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new w,ctx:{common:e.parent.common,data:e.data,parsedType:p(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(E(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)},s=this._parseSync({data:e,path:n.path,parent:n});return R(n,s)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return A(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>A(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(E(s)?s:Promise.resolve(s));return R(n,a)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,s)=>{const a=e(t),i=()=>s.addIssue({code:g.custom,...n(t)});return"undefined"!=typeof Promise&&a instanceof Promise?a.then(e=>!!e||(i(),!1)):!!a||(i(),!1)})}refinement(e,t){return this._refinement((n,s)=>!!e(n)||(s.addIssue("function"==typeof t?t(n,s):t),!1))}_refinement(e){return new Ne({schema:this,typeName:Ue.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Pe.create(this,this._def)}nullable(){return $e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ge.create(this)}promise(){return Ce.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return be.create(this,e,this._def)}transform(e){return new Ne({...O(this._def),schema:this,typeName:Ue.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Le({...O(this._def),innerType:this,defaultValue:t,typeName:Ue.ZodDefault})}brand(){return new De({typeName:Ue.ZodBranded,type:this,...O(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ze({...O(this._def),innerType:this,catchValue:t,typeName:Ue.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return Ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const N=/^c[^\s-]{8,}$/i,P=/^[0-9a-z]+$/,$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,L=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z=/^[a-z0-9_-]{21}$/i,M=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,D=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let G;const U=/^(?:(?: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])$/,q=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,F=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,z=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,K=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,B="((\\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])))",H=new RegExp(`^${B}$`);function W(e){let t="[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Q(e){return new RegExp(`^${W(e)}$`)}function Y(e){let t=`${B}T${W(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function X(e,t){return!("v4"!==t&&t||!U.test(e))||!("v6"!==t&&t||!F.test(e))}function J(e,t){if(!M.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(s));return!("object"!=typeof a||null===a||"typ"in a&&"JWT"!==a?.typ||!a.alg||t&&a.alg!==t)}catch{return!1}}function ee(e,t){return!("v4"!==t&&t||!q.test(e))||!("v6"!==t&&t||!z.test(e))}class te extends C{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.string,received:t.parsedType}),b}const t=new w;let n;for(const s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if("max"===s.kind)e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if("length"===s.kind){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?v(n,{code:g.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&v(n,{code:g.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if("email"===s.kind)j.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"email",code:g.invalid_string,message:s.message}),t.dirty());else if("emoji"===s.kind)G||(G=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),G.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"emoji",code:g.invalid_string,message:s.message}),t.dirty());else if("uuid"===s.kind)L.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"uuid",code:g.invalid_string,message:s.message}),t.dirty());else if("nanoid"===s.kind)Z.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"nanoid",code:g.invalid_string,message:s.message}),t.dirty());else if("cuid"===s.kind)N.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"cuid",code:g.invalid_string,message:s.message}),t.dirty());else if("cuid2"===s.kind)P.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"cuid2",code:g.invalid_string,message:s.message}),t.dirty());else if("ulid"===s.kind)$.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"ulid",code:g.invalid_string,message:s.message}),t.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),v(n,{validation:"url",code:g.invalid_string,message:s.message}),t.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"regex",code:g.invalid_string,message:s.message}),t.dirty())):"trim"===s.kind?e.data=e.data.trim():"includes"===s.kind?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):"toLowerCase"===s.kind?e.data=e.data.toLowerCase():"toUpperCase"===s.kind?e.data=e.data.toUpperCase():"startsWith"===s.kind?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):"endsWith"===s.kind?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):"datetime"===s.kind?Y(s).test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:"datetime",message:s.message}),t.dirty()):"date"===s.kind?H.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:"date",message:s.message}),t.dirty()):"time"===s.kind?Q(s).test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:g.invalid_string,validation:"time",message:s.message}),t.dirty()):"duration"===s.kind?D.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"duration",code:g.invalid_string,message:s.message}),t.dirty()):"ip"===s.kind?X(e.data,s.version)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"ip",code:g.invalid_string,message:s.message}),t.dirty()):"jwt"===s.kind?J(e.data,s.alg)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"jwt",code:g.invalid_string,message:s.message}),t.dirty()):"cidr"===s.kind?ee(e.data,s.version)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"cidr",code:g.invalid_string,message:s.message}),t.dirty()):"base64"===s.kind?K.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"base64",code:g.invalid_string,message:s.message}),t.dirty()):"base64url"===s.kind?V.test(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{validation:"base64url",code:g.invalid_string,message:s.message}),t.dirty()):o.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:g.invalid_string,..._.errToObj(n)})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,..._.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,..._.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new te({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new te({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new te({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function ne(e,t){const n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,a=n>s?n:s;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}te.create=e=>new te({checks:[],typeName:Ue.ZodString,coerce:e?.coerce??!1,...O(e)});class se extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.number,received:t.parsedType}),b}let t;const n=new w;for(const s of this._def.checks)"int"===s.kind?o.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),v(t,{code:g.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):"multipleOf"===s.kind?0!==ne(e.data,s.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):"finite"===s.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),v(t,{code:g.not_finite,message:s.message}),n.dirty()):o.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,n,s){return new se({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:_.toString(s)}]})}_addCheck(e){return new se({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&o.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}se.create=e=>new se({checks:[],typeName:Ue.ZodNumber,coerce:e?.coerce||!1,...O(e)});class ae extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let t;const n=new w;for(const s of this._def.checks)"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),v(t,{code:g.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):o.assertNever(s);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.bigint,received:t.parsedType}),b}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,n,s){return new ae({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:_.toString(s)}]})}_addCheck(e){return new ae({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ae.create=e=>new ae({checks:[],typeName:Ue.ZodBigInt,coerce:e?.coerce??!1,...O(e)});class ie extends C{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==h.boolean){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.boolean,received:t.parsedType}),b}return k(e.data)}}ie.create=e=>new ie({typeName:Ue.ZodBoolean,coerce:e?.coerce||!1,...O(e)});class re extends C{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.date,received:t.parsedType}),b}if(Number.isNaN(e.data.getTime()))return v(this._getOrReturnCtx(e),{code:g.invalid_date}),b;const t=new w;let n;for(const s of this._def.checks)"min"===s.kind?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):"max"===s.kind?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),v(n,{code:g.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):o.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new re({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}re.create=e=>new re({checks:[],coerce:e?.coerce||!1,typeName:Ue.ZodDate,...O(e)});class oe extends C{_parse(e){if(this._getType(e)!==h.symbol){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.symbol,received:t.parsedType}),b}return k(e.data)}}oe.create=e=>new oe({typeName:Ue.ZodSymbol,...O(e)});class de extends C{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.undefined,received:t.parsedType}),b}return k(e.data)}}de.create=e=>new de({typeName:Ue.ZodUndefined,...O(e)});class ce extends C{_parse(e){if(this._getType(e)!==h.null){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.null,received:t.parsedType}),b}return k(e.data)}}ce.create=e=>new ce({typeName:Ue.ZodNull,...O(e)});class ue extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return k(e.data)}}ue.create=e=>new ue({typeName:Ue.ZodAny,...O(e)});class le extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return k(e.data)}}le.create=e=>new le({typeName:Ue.ZodUnknown,...O(e)});class he extends C{_parse(e){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.never,received:t.parsedType}),b}}he.create=e=>new he({typeName:Ue.ZodNever,...O(e)});class pe extends C{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.void,received:t.parsedType}),b}return k(e.data)}}pe.create=e=>new pe({typeName:Ue.ZodVoid,...O(e)});class ge extends C{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return v(t,{code:g.invalid_type,expected:h.array,received:t.parsedType}),b;if(null!==s.exactLength){const e=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(e||a)&&(v(t,{code:e?g.too_big:g.too_small,minimum:a?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(v(t,{code:g.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(v(t,{code:g.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>s.type._parseAsync(new T(t,e,t.path,n)))).then(e=>w.mergeArray(n,e));const a=[...t.data].map((e,n)=>s.type._parseSync(new T(t,e,t.path,n)));return w.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ge({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new ge({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new ge({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}function me(e){if(e instanceof fe){const t={};for(const n in e.shape){const s=e.shape[n];t[n]=Pe.create(me(s))}return new fe({...e._def,shape:()=>t})}return e instanceof ge?new ge({...e._def,type:me(e.element)}):e instanceof Pe?Pe.create(me(e.unwrap())):e instanceof $e?$e.create(me(e.unwrap())):e instanceof xe?xe.create(e.items.map(e=>me(e))):e}ge.create=(e,t)=>new ge({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ue.ZodArray,...O(t)});class fe extends C{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=o.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.object,received:t.parsedType}),b}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof he&&"strip"===this._def.unknownKeys))for(const e in n.data)a.includes(e)||i.push(e);const r=[];for(const e of a){const t=s[e],a=n.data[e];r.push({key:{status:"valid",value:e},value:t._parse(new T(n,a,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof he){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)r.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)i.length>0&&(v(n,{code:g.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const s=n.data[t];r.push({key:{status:"valid",value:t},value:e._parse(new T(n,s,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of r){const n=await t.key,s=await t.value;e.push({key:n,value:s,alwaysSet:t.alwaysSet})}return e}).then(e=>w.mergeObjectSync(t,e)):w.mergeObjectSync(t,r)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new fe({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const s=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:_.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new fe({...this._def,unknownKeys:"strip"})}passthrough(){return new fe({...this._def,unknownKeys:"passthrough"})}extend(e){return new fe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new fe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ue.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new fe({...this._def,catchall:e})}pick(e){const t={};for(const n of o.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new fe({...this._def,shape:()=>t})}omit(e){const t={};for(const n of o.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new fe({...this._def,shape:()=>t})}deepPartial(){return me(this)}partial(e){const t={};for(const n of o.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new fe({...this._def,shape:()=>t})}required(e){const t={};for(const n of o.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof Pe;)e=e._def.innerType;t[n]=e}return new fe({...this._def,shape:()=>t})}keyof(){return Te(o.objectKeys(this.shape))}}fe.create=(e,t)=>new fe({shape:()=>e,unknownKeys:"strip",catchall:he.create(),typeName:Ue.ZodObject,...O(t)}),fe.strictCreate=(e,t)=>new fe({shape:()=>e,unknownKeys:"strict",catchall:he.create(),typeName:Ue.ZodObject,...O(t)}),fe.lazycreate=(e,t)=>new fe({shape:e,unknownKeys:"strip",catchall:he.create(),typeName:Ue.ZodObject,...O(t)});class ye extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new m(e.ctx.common.issues));return v(t,{code:g.invalid_union,unionErrors:n}),b});{let e;const s=[];for(const a of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=a._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&s.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const a=s.map(e=>new m(e));return v(t,{code:g.invalid_union,unionErrors:a}),b}}get options(){return this._def.options}}ye.create=(e,t)=>new ye({options:e,typeName:Ue.ZodUnion,...O(t)});const _e=e=>e instanceof Ae?_e(e.schema):e instanceof Ne?_e(e.innerType()):e instanceof Ee?[e.value]:e instanceof Re?e.options:e instanceof Oe?o.objectValues(e.enum):e instanceof Le?_e(e._def.innerType):e instanceof de?[void 0]:e instanceof ce?[null]:e instanceof Pe?[void 0,..._e(e.unwrap())]:e instanceof $e?[null,..._e(e.unwrap())]:e instanceof De||e instanceof Ge?_e(e.unwrap()):e instanceof Ze?_e(e._def.innerType):[];class ve extends C{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return v(t,{code:g.invalid_type,expected:h.object,received:t.parsedType}),b;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(v(t,{code:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const n of t){const t=_e(n.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of t){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,n)}}return new ve({typeName:Ue.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...O(n)})}}function we(e,t){const n=p(e),s=p(t);if(e===t)return{valid:!0,data:e};if(n===h.object&&s===h.object){const n=o.objectKeys(t),s=o.objectKeys(e).filter(e=>-1!==n.indexOf(e)),a={...e,...t};for(const n of s){const s=we(e[n],t[n]);if(!s.valid)return{valid:!1};a[n]=s.data}return{valid:!0,data:a}}if(n===h.array&&s===h.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let s=0;s<e.length;s++){const a=we(e[s],t[s]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}return n===h.date&&s===h.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class be extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(e,s)=>{if(S(e)||S(s))return b;const a=we(e.value,s.value);return a.valid?((I(e)||I(s))&&t.dirty(),{status:t.value,value:a.data}):(v(n,{code:g.invalid_intersection_types}),b)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>s(e,t)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}be.create=(e,t,n)=>new be({left:e,right:t,typeName:Ue.ZodIntersection,...O(n)});class xe extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return v(n,{code:g.invalid_type,expected:h.array,received:n.parsedType}),b;if(n.data.length<this._def.items.length)return v(n,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((e,t)=>{const s=this._def.items[t]||this._def.rest;return s?s._parse(new T(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(s).then(e=>w.mergeArray(t,e)):w.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new xe({...this._def,rest:e})}}xe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xe({items:e,typeName:Ue.ZodTuple,rest:null,...O(t)})};class ke extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return v(n,{code:g.invalid_type,expected:h.object,received:n.parsedType}),b;const s=[],a=this._def.keyType,i=this._def.valueType;for(const e in n.data)s.push({key:a._parse(new T(n,e,n.path,e)),value:i._parse(new T(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?w.mergeObjectAsync(t,s):w.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return new ke(t instanceof C?{keyType:e,valueType:t,typeName:Ue.ZodRecord,...O(n)}:{keyType:te.create(),valueType:e,typeName:Ue.ZodRecord,...O(t)})}}class Se extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return v(n,{code:g.invalid_type,expected:h.map,received:n.parsedType}),b;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([e,t],i)=>({key:s._parse(new T(n,e,n.path,[i,"key"])),value:a._parse(new T(n,t,n.path,[i,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of i){const s=await n.key,a=await n.value;if("aborted"===s.status||"aborted"===a.status)return b;"dirty"!==s.status&&"dirty"!==a.status||t.dirty(),e.set(s.value,a.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of i){const s=n.key,a=n.value;if("aborted"===s.status||"aborted"===a.status)return b;"dirty"!==s.status&&"dirty"!==a.status||t.dirty(),e.set(s.value,a.value)}return{status:t.value,value:e}}}}Se.create=(e,t,n)=>new Se({valueType:t,keyType:e,typeName:Ue.ZodMap,...O(n)});class Ie extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return v(n,{code:g.invalid_type,expected:h.set,received:n.parsedType}),b;const s=this._def;null!==s.minSize&&n.data.size<s.minSize.value&&(v(n,{code:g.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&n.data.size>s.maxSize.value&&(v(n,{code:g.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(e){const n=new Set;for(const s of e){if("aborted"===s.status)return b;"dirty"===s.status&&t.dirty(),n.add(s.value)}return{status:t.value,value:n}}const r=[...n.data.values()].map((e,t)=>a._parse(new T(n,e,n.path,t)));return n.common.async?Promise.all(r).then(e=>i(e)):i(r)}min(e,t){return new Ie({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new Ie({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ie.create=(e,t)=>new Ie({valueType:e,minSize:null,maxSize:null,typeName:Ue.ZodSet,...O(t)});class Ae extends C{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ae.create=(e,t)=>new Ae({getter:e,typeName:Ue.ZodLazy,...O(t)});class Ee extends C{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return v(t,{received:t.data,code:g.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Te(e,t){return new Re({values:e,typeName:Ue.ZodEnum,...O(t)})}Ee.create=(e,t)=>new Ee({value:e,typeName:Ue.ZodLiteral,...O(t)});class Re extends C{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return v(t,{expected:o.joinValues(n),received:t.parsedType,code:g.invalid_type}),b}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return v(t,{received:t.data,code:g.invalid_enum_value,options:n}),b}return k(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Re.create(e,{...this._def,...t})}exclude(e,t=this._def){return Re.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}Re.create=Te;class Oe extends C{_parse(e){const t=o.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const e=o.objectValues(t);return v(n,{expected:o.joinValues(e),received:n.parsedType,code:g.invalid_type}),b}if(this._cache||(this._cache=new Set(o.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=o.objectValues(t);return v(n,{received:n.data,code:g.invalid_enum_value,options:e}),b}return k(e.data)}get enum(){return this._def.values}}Oe.create=(e,t)=>new Oe({values:e,typeName:Ue.ZodNativeEnum,...O(t)});class Ce extends C{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&!1===t.common.async)return v(t,{code:g.invalid_type,expected:h.promise,received:t.parsedType}),b;const n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return k(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(e,t)=>new Ce({type:e,typeName:Ue.ZodPromise,...O(t)});class Ne extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ue.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:e=>{v(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===s.type){const e=s.transform(n.data,a);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return b;const s=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===s.status?b:"dirty"===s.status||"dirty"===t.value?x(s.value):s});{if("aborted"===t.value)return b;const s=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===s.status?b:"dirty"===s.status||"dirty"===t.value?x(s.value):s}}if("refinement"===s.type){const e=e=>{const t=s.refinement(e,a);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===s.status?b:("dirty"===s.status&&t.dirty(),e(s.value),{status:t.value,value:s.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?b:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if("transform"===s.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!A(e))return b;const i=s.transform(e.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>A(e)?Promise.resolve(s.transform(e.value,a)).then(e=>({status:t.value,value:e})):b)}o.assertNever(s)}}Ne.create=(e,t,n)=>new Ne({schema:e,typeName:Ue.ZodEffects,effect:t,...O(n)}),Ne.createWithPreprocess=(e,t,n)=>new Ne({schema:t,effect:{type:"preprocess",transform:e},typeName:Ue.ZodEffects,...O(n)});class Pe extends C{_parse(e){return this._getType(e)===h.undefined?k(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pe.create=(e,t)=>new Pe({innerType:e,typeName:Ue.ZodOptional,...O(t)});class $e extends C{_parse(e){return this._getType(e)===h.null?k(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$e.create=(e,t)=>new $e({innerType:e,typeName:Ue.ZodNullable,...O(t)});class Le extends C{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Le.create=(e,t)=>new Le({innerType:e,typeName:Ue.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...O(t)});class Ze extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return E(s)?s.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new m(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===s.status?s.value:this._def.catchValue({get error(){return new m(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ze.create=(e,t)=>new Ze({innerType:e,typeName:Ue.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...O(t)});class Me extends C{_parse(e){if(this._getType(e)!==h.nan){const t=this._getOrReturnCtx(e);return v(t,{code:g.invalid_type,expected:h.nan,received:t.parsedType}),b}return{status:"valid",value:e.data}}}Me.create=e=>new Me({typeName:Ue.ZodNaN,...O(e)}),Symbol("zod_brand");class De extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class je extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?b:"dirty"===e.status?(t.dirty(),x(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?b:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new je({in:e,out:t,typeName:Ue.ZodPipeline})}}class Ge extends C{_parse(e){const t=this._def.innerType._parse(e),n=e=>(A(e)&&(e.value=Object.freeze(e.value)),e);return E(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}var Ue;Ge.create=(e,t)=>new Ge({innerType:e,typeName:Ue.ZodReadonly,...O(t)}),fe.lazycreate,function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Ue||(Ue={}));const qe=te.create,Fe=se.create,ze=(Me.create,ae.create,ie.create),Ke=(re.create,oe.create,de.create,ce.create,ue.create,le.create),Ve=(he.create,pe.create,ge.create),Be=fe.create,He=(fe.strictCreate,ye.create),We=ve.create,Qe=(be.create,xe.create,ke.create),Ye=(Se.create,Ie.create,Ae.create,Ee.create),Xe=Re.create,Je=(Oe.create,Ce.create,Ne.create,Pe.create),et=($e.create,Ne.createWithPreprocess,je.create,"2.0"),tt=He([qe(),Fe().int()]),nt=qe(),st=Be({progressToken:Je(tt)}).passthrough(),at=Be({_meta:Je(st)}).passthrough(),it=Be({method:qe(),params:Je(at)}),rt=Be({_meta:Je(Be({}).passthrough())}).passthrough(),ot=Be({method:qe(),params:Je(rt)}),dt=Be({_meta:Je(Be({}).passthrough())}).passthrough(),ct=He([qe(),Fe().int()]),ut=Be({jsonrpc:Ye(et),id:ct}).merge(it).strict(),lt=Be({jsonrpc:Ye(et)}).merge(ot).strict(),ht=Be({jsonrpc:Ye(et),id:ct,result:dt}).strict();var pt;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError"}(pt||(pt={}));const gt=He([ut,lt,ht,Be({jsonrpc:Ye(et),id:ct,error:Be({code:Fe().int(),message:qe(),data:Je(Ke())})}).strict()]),mt=dt.strict(),ft=ot.extend({method:Ye("notifications/cancelled"),params:rt.extend({requestId:ct,reason:qe().optional()})}),yt=Be({name:qe(),title:Je(qe())}).passthrough(),_t=yt.extend({version:qe()}),vt=Be({experimental:Je(Be({}).passthrough()),sampling:Je(Be({}).passthrough()),elicitation:Je(Be({}).passthrough()),roots:Je(Be({listChanged:Je(ze())}).passthrough())}).passthrough(),wt=it.extend({method:Ye("initialize"),params:at.extend({protocolVersion:qe(),capabilities:vt,clientInfo:_t})}),bt=Be({experimental:Je(Be({}).passthrough()),logging:Je(Be({}).passthrough()),completions:Je(Be({}).passthrough()),prompts:Je(Be({listChanged:Je(ze())}).passthrough()),resources:Je(Be({subscribe:Je(ze()),listChanged:Je(ze())}).passthrough()),tools:Je(Be({listChanged:Je(ze())}).passthrough())}).passthrough(),xt=dt.extend({protocolVersion:qe(),capabilities:bt,serverInfo:_t,instructions:Je(qe())}),kt=ot.extend({method:Ye("notifications/initialized")}),St=it.extend({method:Ye("ping")}),It=Be({progress:Fe(),total:Je(Fe()),message:Je(qe())}).passthrough(),At=ot.extend({method:Ye("notifications/progress"),params:rt.merge(It).extend({progressToken:tt})}),Et=it.extend({params:at.extend({cursor:Je(nt)}).optional()}),Tt=dt.extend({nextCursor:Je(nt)}),Rt=Be({uri:qe(),mimeType:Je(qe()),_meta:Je(Be({}).passthrough())}).passthrough(),Ot=Rt.extend({text:qe()}),Ct=qe().refine(e=>{try{return atob(e),!0}catch(e){return!1}},{message:"Invalid Base64 string"}),Nt=Rt.extend({blob:Ct}),Pt=yt.extend({uri:qe(),description:Je(qe()),mimeType:Je(qe()),_meta:Je(Be({}).passthrough())}),$t=yt.extend({uriTemplate:qe(),description:Je(qe()),mimeType:Je(qe()),_meta:Je(Be({}).passthrough())}),Lt=Et.extend({method:Ye("resources/list")}),Zt=Tt.extend({resources:Ve(Pt)}),Mt=Et.extend({method:Ye("resources/templates/list")}),Dt=Tt.extend({resourceTemplates:Ve($t)}),jt=it.extend({method:Ye("resources/read"),params:at.extend({uri:qe()})}),Gt=dt.extend({contents:Ve(He([Ot,Nt]))}),Ut=ot.extend({method:Ye("notifications/resources/list_changed")}),qt=it.extend({method:Ye("resources/subscribe"),params:at.extend({uri:qe()})}),Ft=it.extend({method:Ye("resources/unsubscribe"),params:at.extend({uri:qe()})}),zt=ot.extend({method:Ye("notifications/resources/updated"),params:rt.extend({uri:qe()})}),Kt=Be({name:qe(),description:Je(qe()),required:Je(ze())}).passthrough(),Vt=yt.extend({description:Je(qe()),arguments:Je(Ve(Kt)),_meta:Je(Be({}).passthrough())}),Bt=Et.extend({method:Ye("prompts/list")}),Ht=Tt.extend({prompts:Ve(Vt)}),Wt=it.extend({method:Ye("prompts/get"),params:at.extend({name:qe(),arguments:Je(Qe(qe()))})}),Qt=Be({type:Ye("text"),text:qe(),_meta:Je(Be({}).passthrough())}).passthrough(),Yt=Be({type:Ye("image"),data:Ct,mimeType:qe(),_meta:Je(Be({}).passthrough())}).passthrough(),Xt=Be({type:Ye("audio"),data:Ct,mimeType:qe(),_meta:Je(Be({}).passthrough())}).passthrough(),Jt=Be({type:Ye("resource"),resource:He([Ot,Nt]),_meta:Je(Be({}).passthrough())}).passthrough(),en=He([Qt,Yt,Xt,Pt.extend({type:Ye("resource_link")}),Jt]),tn=Be({role:Xe(["user","assistant"]),content:en}).passthrough(),nn=dt.extend({description:Je(qe()),messages:Ve(tn)}),sn=ot.extend({method:Ye("notifications/prompts/list_changed")}),an=Be({title:Je(qe()),readOnlyHint:Je(ze()),destructiveHint:Je(ze()),idempotentHint:Je(ze()),openWorldHint:Je(ze())}).passthrough(),rn=yt.extend({description:Je(qe()),inputSchema:Be({type:Ye("object"),properties:Je(Be({}).passthrough()),required:Je(Ve(qe()))}).passthrough(),outputSchema:Je(Be({type:Ye("object"),properties:Je(Be({}).passthrough()),required:Je(Ve(qe()))}).passthrough()),annotations:Je(an),_meta:Je(Be({}).passthrough())}),on=Et.extend({method:Ye("tools/list")}),dn=Tt.extend({tools:Ve(rn)}),cn=dt.extend({content:Ve(en).default([]),structuredContent:Be({}).passthrough().optional(),isError:Je(ze())}),un=(cn.or(dt.extend({toolResult:Ke()})),it.extend({method:Ye("tools/call"),params:at.extend({name:qe(),arguments:Je(Qe(Ke()))})})),ln=ot.extend({method:Ye("notifications/tools/list_changed")}),hn=Xe(["debug","info","notice","warning","error","critical","alert","emergency"]),pn=it.extend({method:Ye("logging/setLevel"),params:at.extend({level:hn})}),gn=ot.extend({method:Ye("notifications/message"),params:rt.extend({level:hn,logger:Je(qe()),data:Ke()})}),mn=Be({name:qe().optional()}).passthrough(),fn=Be({hints:Je(Ve(mn)),costPriority:Je(Fe().min(0).max(1)),speedPriority:Je(Fe().min(0).max(1)),intelligencePriority:Je(Fe().min(0).max(1))}).passthrough(),yn=Be({role:Xe(["user","assistant"]),content:He([Qt,Yt,Xt])}).passthrough(),_n=it.extend({method:Ye("sampling/createMessage"),params:at.extend({messages:Ve(yn),systemPrompt:Je(qe()),includeContext:Je(Xe(["none","thisServer","allServers"])),temperature:Je(Fe()),maxTokens:Fe().int(),stopSequences:Je(Ve(qe())),metadata:Je(Be({}).passthrough()),modelPreferences:Je(fn)})}),vn=dt.extend({model:qe(),stopReason:Je(Xe(["endTurn","stopSequence","maxTokens"]).or(qe())),role:Xe(["user","assistant"]),content:We("type",[Qt,Yt,Xt])}),wn=He([Be({type:Ye("boolean"),title:Je(qe()),description:Je(qe()),default:Je(ze())}).passthrough(),Be({type:Ye("string"),title:Je(qe()),description:Je(qe()),minLength:Je(Fe()),maxLength:Je(Fe()),format:Je(Xe(["email","uri","date","date-time"]))}).passthrough(),Be({type:Xe(["number","integer"]),title:Je(qe()),description:Je(qe()),minimum:Je(Fe()),maximum:Je(Fe())}).passthrough(),Be({type:Ye("string"),title:Je(qe()),description:Je(qe()),enum:Ve(qe()),enumNames:Je(Ve(qe()))}).passthrough()]),bn=it.extend({method:Ye("elicitation/create"),params:at.extend({message:qe(),requestedSchema:Be({type:Ye("object"),properties:Qe(qe(),wn),required:Je(Ve(qe()))}).passthrough()})}),xn=dt.extend({action:Xe(["accept","decline","cancel"]),content:Je(Qe(qe(),Ke()))}),kn=Be({type:Ye("ref/resource"),uri:qe()}).passthrough(),Sn=Be({type:Ye("ref/prompt"),name:qe()}).passthrough(),In=it.extend({method:Ye("completion/complete"),params:at.extend({ref:He([Sn,kn]),argument:Be({name:qe(),value:qe()}).passthrough(),context:Je(Be({arguments:Je(Qe(qe(),qe()))}))})}),An=dt.extend({completion:Be({values:Ve(qe()).max(100),total:Je(Fe().int()),hasMore:Je(ze())}).passthrough()}),En=Be({uri:qe().startsWith("file://"),name:Je(qe()),_meta:Je(Be({}).passthrough())}).passthrough(),Tn=it.extend({method:Ye("roots/list")}),Rn=dt.extend({roots:Ve(En)}),On=ot.extend({method:Ye("notifications/roots/list_changed")});He([St,wt,In,pn,Wt,Bt,Lt,Mt,jt,qt,Ft,un,on]),He([ft,At,kt,On]),He([mt,vn,xn,Rn]),He([St,_n,bn,Tn]),He([ft,At,gn,zt,Ut,ln,sn]),He([mt,xt,An,nn,Ht,Zt,Dt,Gt,cn,dn]),Error;class Cn{sessionId;onmessage;onerror;onclose;_port;_started=!1;_closed=!1;constructor(e,t){if(!e)throw new Error("MessagePort is required");this._port=e,this.sessionId=t||this.generateId(),this._port.onmessage=e=>{try{const t=gt.parse(e.data);this.onmessage?.(t)}catch(e){const t=new Error(`Failed to parse message: ${e}`);this.onerror?.(t)}},this._port.onmessageerror=e=>{const t=new Error(`MessagePort error: ${JSON.stringify(e)}`);this.onerror?.(t)}}static generateSessionId(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,10)}`}async start(){if(this._started)throw new Error("BrowserContextTransport already started! If using Client or Server class, note that connect() calls start() automatically.");if(this._closed)throw new Error("Cannot start a closed BrowserContextTransport");this._started=!0,this._port.start()}async send(e){if(this._closed)throw new Error("Cannot send on a closed BrowserContextTransport");return new Promise((t,n)=>{try{this._port.postMessage(e),t()}catch(e){const t=e instanceof Error?e:new Error(String(e));this.onerror?.(t),n(t)}})}async close(){this._closed||(this._closed=!0,this._port.close(),this.onclose?.())}generateId(){return Cn.generateSessionId()}}let Nn=null;const Pn=()=>(Nn&&document.contains(Nn)||(Nn=document.querySelector('iframe[src*="angie/"]')),Nn),$n=(e,t)=>{console.log("postMessageToAngieIframe",e,t);const n=Pn();if(!n?.contentWindow)return!1;const s=t||(()=>{const e=Pn();if(!e)return null;try{return new URL(e.src).origin}catch(e){return console.error("Error parsing iframe URL:",e),null}})();return s?(n.contentWindow.postMessage(e,s),!0):(console.error("Could not determine target origin for Angie iframe"),!1)};let Ln=!1;const Zn="open",Mn="closed";function Dn(){if("undefined"==typeof window)return 370;try{const e=window.localStorage.getItem("angie_sidebar_width");if(e){const t=parseInt(e,10);if(t>=350&&t<=590)return t}}catch(e){console.warn("localStorage not available")}return 370}function jn(){return"undefined"==typeof window?null:localStorage.getItem("angie_sidebar_state")}function Gn(e){try{localStorage.setItem("angie_sidebar_width",e.toString())}catch(e){console.warn("localStorage not available")}}function Un(e){document.documentElement.style.setProperty("--angie-sidebar-width",`${e}px`)}function qn(){!function(){const e=new URLSearchParams(window.location.search);return e.has("start-oauth")||e.has("oauth_code")||e.has("oauth_state")||e.has("oauth_error")}()?Fn(jn()||Zn):function(){Fn(Mn);try{localStorage.setItem("angie_sidebar_state",Mn)}catch(e){console.warn("localStorage not available")}}()}function Fn(e){"undefined"!=typeof window&&window.toggleAngieSidebar&&window.toggleAngieSidebar(e===Zn,!0)}function zn(){const e=document.getElementById("angie-sidebar-container");if(!e)return;let t=!1,n=0,s=0;e.addEventListener("mousedown",a=>{const i=e.getBoundingClientRect();("rtl"===document.documentElement.dir?a.clientX<=i.left+4:a.clientX>=i.right-4)&&(t=!0,n=a.clientX,s=i.width,e.classList.add("angie-resizing"),document.body.style.cursor="ew-resize",document.body.style.userSelect="none",a.preventDefault(),a.stopPropagation())}),document.addEventListener("mousemove",e=>{if(!t)return;let a;a="rtl"===document.documentElement.dir?n-e.clientX:e.clientX-n,Un(Math.max(350,Math.min(590,s+a))),e.preventDefault(),e.stopPropagation()}),document.addEventListener("mouseup",n=>{if(t){t=!1,e.classList.remove("angie-resizing"),document.body.style.cursor="",document.body.style.userSelect="";const a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--angie-sidebar-width"),10);Gn(a),$n({type:es.ANGIE_SIDEBAR_RESIZED,payload:{initialWidth:s,width:a}}),n.preventDefault(),n.stopPropagation()}}),Un(Dn())}function Kn(e){!function(){if("undefined"==typeof document||Ln)return;const e="angie-sidebar-styles";if(document.getElementById(e))return void(Ln=!0);const t=document.createElement("style");t.id=e,t.textContent="/* Angie Sidebar - CSS Variables */\n:root {\n --angie-sidebar-z-index: 1200; /* below MUI popups, elementor popups and media library modal */\n --angie-sidebar-width: 330px;\n --angie-sidebar-transition: margin 0.3s ease-in-out, transform 0.3s ease-in-out;\n /* Direction-aware transform values for sidebar positioning */\n --angie-sidebar-hide-transform: translateX(-100%); /* LTR: hide to the left */\n --angie-sidebar-show-transform: translateX(0);\n}\n\n/* RTL-specific transform values */\n[dir=\"rtl\"] {\n --angie-sidebar-hide-transform: translateX(100%); /* RTL: hide to the right */\n}\n\n/* Respect user's motion preferences */\n@media (prefers-reduced-motion: reduce) {\n :root {\n --angie-sidebar-transition: none;\n }\n}\n\n/* Apply transitions only when user is actively toggling */\nbody.angie-sidebar-transitioning {\n transition: var(--angie-sidebar-transition) !important;\n}\n\nbody.angie-sidebar-transitioning #angie-sidebar-container {\n transition: var(--angie-sidebar-transition) !important;\n}\n\n/* LTR Layout (default) - Push content to the right */\n@media (min-width: 768px) {\n body.angie-sidebar-active {\n padding-inline-start: var(--angie-sidebar-width) !important;\n }\n\n body.angie-sidebar-active #angie-body-top-padding {\n width: 100%;\n height: 8px;\n }\n\n /* Push WordPress Admin Bar - LTR */\n body.angie-sidebar-active #wpadminbar {\n inset-inline-start: var(--angie-sidebar-width) !important;\n inset-inline-end: 8px !important;\n width: calc(100% - 8px - var(--angie-sidebar-width)) !important;\n margin-top: 8px;\n }\n\n /* Sidebar container - LTR */\n #angie-sidebar-container {\n position: fixed;\n top: 0;\n inset-inline-start: 0;\n width: var(--angie-sidebar-width);\n height: 100vh;\n z-index: var(--angie-sidebar-z-index) !important; /* below elementor popups and media library modal */\n background: #FCFCFC;\n transform: var(--angie-sidebar-hide-transform);\n outline: none;\n overflow: hidden;\n /* No default transition - only when transitioning */\n }\n\n /* Resize handle */\n #angie-sidebar-container::after {\n content: '';\n position: absolute;\n top: 0;\n inset-inline-end: 0;\n width: 4px;\n height: 100%;\n cursor: ew-resize;\n background: transparent;\n z-index: 1000001;\n }\n\n /* Pink border during resize */\n #angie-sidebar-container.angie-resizing {\n border-inline-end-color: #ff69b4 !important;\n border-inline-end-width: 2px !important;\n }\n\n /* Disable iframe pointer events during resize */\n #angie-sidebar-container.angie-resizing iframe#angie-iframe {\n pointer-events: none !important;\n }\n}\n\n/* Active states */\nbody.angie-sidebar-active #angie-sidebar-container {\n transform: var(--angie-sidebar-show-transform);\n}\n\n/* Studio mode - sidebar takes full width */\n@media (min-width: 768px) {\n html.angie-studio-active body.angie-sidebar-active #angie-sidebar-container {\n width: 100%;\n }\n}\n\n/* High contrast mode support */\n@media (prefers-contrast: high) {\n #angie-sidebar-container {\n border-color: #000;\n box-shadow: none;\n }\n}\n\n/* Screen reader only class */\n.angie-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n/* Plugin conflict resolution */\nbody.angie-sidebar-active {\n /* Reset common conflicting styles */\n box-sizing: border-box !important;\n position: relative !important;\n}\n\n#angie-sidebar-toggle {\n z-index: 99999 !important;\n}\n";const n=document.head||document.getElementsByTagName("head")[0];n.insertBefore(t,n.firstChild),Ln=!0}(),"undefined"!=typeof window&&(window.toggleAngieSidebar=function(e){return function(t,n){const s=document.body,a=document.getElementById("angie-sidebar-container");if(!a)return void console.warn("Angie Sidebar: Required elements not found!");const i=s.classList.contains("angie-sidebar-active"),r=void 0!==t?t:!i;n||(s.classList.add("angie-sidebar-transitioning"),setTimeout(function(){s.classList.remove("angie-sidebar-transitioning")},300)),r?s.classList.add("angie-sidebar-active"):s.classList.remove("angie-sidebar-active"),r&&setTimeout(function(){$n({type:"focusInput"})},n?0:300),e&&e(r,a,n),function(e){try{localStorage.setItem("angie_sidebar_state",e)}catch(e){console.warn("localStorage not available")}}(r?Zn:Mn);const o=new CustomEvent("angieSidebarToggle",{detail:{isOpen:r,sidebar:a,skipTransition:n}});document.dispatchEvent(o),$n({type:es.ANGIE_SIDEBAR_TOGGLED,payload:{state:r?"opened":"closed"}})}}(e),window.addEventListener("message",function(e){if(e.data&&"toggleAngieSidebar"===e.data.type){const{force:t,skipTransition:n}=e.data.payload||{};window.toggleAngieSidebar&&window.toggleAngieSidebar(t,n)}}))}const Vn=(e,t)=>{const n=document.getElementById("angie-sidebar-container");n&&n.setAttribute("aria-hidden",t?"false":"true"),t?e.removeAttribute("tabindex"):e.setAttribute("tabindex","-1")},Bn=(e,t)=>{e.postMessage({status:"success",payload:t})},Hn=(e,t)=>{e.postMessage({status:"error",payload:t})},Wn=()=>new Promise(e=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e(null)});var Qn;(Qn||(Qn={})).POST_MESSAGE="postMessage";const Yn={open:!1,iframe:null,iframeUrlObject:null};function Xn(){const e=new URL(window.location.href);e.searchParams.set("start-oauth","1"),console.log("OAuth: Redirecting to wp-admin with OAuth:",e.toString()),window.location.href=e.toString()}const Jn=()=>{window.addEventListener("message",e=>{if(e.origin===Yn.iframeUrlObject?.origin)switch(e.data.type){case"OAUTH_GET_CODE_AND_STATE":(e=>{const t=new URLSearchParams(window.location.search),n=t.get("oauth_code"),s=t.get("oauth_state");if(n&&s)Bn(e,{code:n,state:s});else{const a=t.get("oauth_error");if(a){Hn(e,{message:a,code:n||null,state:s||null});const t=new URL(window.location.href);t.searchParams.delete("oauth_error"),history.replaceState({},"",t.toString())}else Bn(e,{message:"No OAuth error found"})}})(e.ports[0]);break;case"OAUTH_GET_TOP_URL":console.log("OAuth: Iframe requested top window URL via MessageChannel"),Bn(e.ports[0],{topUrl:window.location.href});break;case"OAUTH_REDIRECT_TOP_WINDOW":console.log("OAuth: Iframe requested top window redirect to:",e.data.payload.url),window.location.href=e.data.payload.url;break;case"OAUTH_UPDATE_URL":console.log("OAuth: Iframe requested URL update to:",e.data.payload.url),function(e,t){if(!history?.replaceState)return console.warn("history.replaceState not supported in this browser"),void Hn(t,{message:"URL update not supported in this browser"});try{const n=window.location.href;history.replaceState({},"",e),function(e,t){const n=new URL(t),s=new URL(e),a=n.searchParams,i=s.searchParams,r=["oauth_code","oauth_state","start-oauth"];return r.some(e=>i?.has(e))&&!r.some(e=>a?.has(e))}(n,e)&&function(){console.log("OAuth parameters cleaned, opening sidebar");try{localStorage.setItem("angie_sidebar_state","open")}catch(e){console.warn("localStorage not available")}setTimeout(()=>{window.toggleAngieSidebar(!0)},500)}(),Bn(t,{message:"URL updated successfully"})}catch(e){console.warn("Failed to update URL via history.replaceState:",e),Hn(t,{message:"URL update failed: "+(e instanceof Error?e.message:"Unknown error")})}}(e.data.payload.url,e.ports[0]);break;case"ANGIE_REDIRECT_TO_WP_ADMIN_WITH_OAUTH":Xn();break;case"ANGIE_REDIRECT_TO_AUTH_ORIGIN_LOGOUT":try{Xn()}catch(e){console.error("OAuth: Auth origin logout fallback failed:",e),window.location.reload()}}})};var es;!function(e){e.SDK_ANGIE_ALL_SERVERS_REGISTERED="sdk-angie-all-servers-registered",e.SDK_ANGIE_READY_PING="sdk-angie-ready-ping",e.SDK_REQUEST_CLIENT_CREATION="sdk-request-client-creation",e.SDK_TRIGGER_ANGIE="sdk-trigger-angie",e.SDK_TRIGGER_ANGIE_RESPONSE="sdk-trigger-angie-response",e.ANGIE_SIDEBAR_RESIZED="angie-sidebar-resized",e.ANGIE_SIDEBAR_TOGGLED="angie-sidebar-toggled",e.ANGIE_CHAT_TOGGLE="angie-chat-toggle",e.ANGIE_STUDIO_TOGGLE="angie-studio-toggle",e.ANGIE_NAVIGATE_TO_URL="angie/navigate-to-url",e.ANGIE_PAGE_RELOAD="angie/page-reload"}(es||(es={}));class ts{angieDetector;registrationQueue;clientManager;isInitialized=!1;instanceId;constructor(){this.instanceId=Math.random().toString(36).substring(2,8),console.log(`AngieMcpSdk: Constructor called - initializing SDK (Instance: ${this.instanceId})`),this.angieDetector=new c,this.registrationQueue=new u,this.clientManager=new l,console.log(`AngieMcpSdk: Setting up event handlers (Instance: ${this.instanceId})`),this.setupAngieReadyHandler(),this.setupServerInitHandler(),this.setupReRegistrationHandler(),console.log(`AngieMcpSdk: SDK initialization complete (Instance: ${this.instanceId})`)}async loadSidebar(e){Kn(),await(async e=>{if(window.screen.availWidth<=768)return void console.log("Angie: Mobile detected, skipping iframe injection");let t=document.getElementById("angie-sidebar-container");if(!t){const e=performance.now();if(console.log("⏱️ Waiting for sidebar container..."),await new Promise(e=>{let n=0;const s=setInterval(()=>{t=document.getElementById("angie-sidebar-container"),n++,(t||n>20)&&(clearInterval(s),t&&e())},100);setTimeout(()=>{if(clearInterval(s),t)return void e();const n=new MutationObserver(()=>{t=document.getElementById("angie-sidebar-container"),t&&(n.disconnect(),e())});n.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{n.disconnect(),e()},8e3)},2e3)}),console.log(`⏱️ Sidebar container detection took: ${(performance.now()-e).toFixed(2)}ms`),!t)return void console.error("Angie: Sidebar container not found")}const{iframe:n,iframeUrlObject:s}=await(async e=>{const t=e.origin,n=new URL(e.path,t),s=n.pathname.slice(1).replace(/\//,"--")+"-"+Math.random().toString(36).substring(7);return new Promise(a=>{const i=new URL(t);i.pathname=n.pathname;const o=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(i.searchParams.append("colorScheme",e.uiTheme||o||"light"),i.searchParams.append("sdkVersion",e.sdkVersion),i.searchParams.append("instanceId",s),i.searchParams.append("origin",window.location.origin),e.isRTL&&i.searchParams.append("isRTL",e.isRTL?"true":"false"),"localhost"===window.location.hostname&&window.location.search.includes("debug_error")){const e=new URLSearchParams(window.location.search).get("debug_error");e&&i.searchParams.append("debug_error",e)}n.searchParams.forEach((e,t)=>{i.searchParams.set(t,e)}),i.searchParams.set("ver",(new Date).getTime().toString());const d=e.parent||document,c=d.createElement("iframe"),u={"background-color":"transparent","color-scheme":"normal",...e.css};window.addEventListener("message",async e=>{if(e.origin===i.origin)switch(e.data.type){case r.ANGIE_READY:a({iframe:c,iframeUrlObject:i});break;case r.ANGIE_LOADED:c.contentWindow?.postMessage({type:r.HOST_READY,instanceId:s},i.origin)}}),c.setAttribute("src",i.href),c.id="angie-iframe",c.setAttribute("frameborder","0"),c.setAttribute("scrolling","no"),c.setAttribute("style",Object.entries(u).map(([e,t])=>`${e}: ${t}`).join("; ")),c.setAttribute("allow","clipboard-write; clipboard-read"),e.insertCallback?e.insertCallback(c):d.body.appendChild(c)})})({origin:e.origin||"https://angie.elementor.com",path:"angie/wp-admin",insertCallback:e=>{console.log("Injecting Angie iframe into sidebar container"),e.setAttribute("title","Angie AI Assistant"),e.setAttribute("role","application"),e.setAttribute("aria-label","Angie AI Assistant Interface");const n=document.getElementById("angie-sidebar-loading");n&&(n.textContent=""),t?.appendChild(e),Vn(e,!0),e.addEventListener("load",()=>{e.focus()})},css:{width:"100%",height:"100%",border:"none",outline:"none"},uiTheme:e.uiTheme,isRTL:e.isRTL,sdkVersion:"1.0.3"});Yn.iframe=n,Yn.iframeUrlObject=s,window.addEventListener("message",e=>{if(e.origin===Yn.iframeUrlObject?.origin)switch(e.data.type){case i.SET:window.localStorage.setItem(e.data.key,e.data.value);break;case i.GET:const t=e.ports[0],n=window.localStorage.getItem(e.data.key);t.postMessage({value:n})}}),(e=>{window.addEventListener("message",async t=>{const n=t.origin===window.location.origin,s=t.origin===e.iframeUrlObject?.origin;if(n||s)switch(t?.data?.type){case es.SDK_ANGIE_ALL_SERVERS_REGISTERED:break;case es.SDK_ANGIE_READY_PING:const n=t.ports[0];console.log("Angie is ready",t),Bn(n,{message:"Angie is ready"});break;case es.SDK_REQUEST_CLIENT_CREATION:const s=t.data.payload;try{const n=t.ports[0],a=new MessageChannel;a.port1.onmessage=e=>{n.postMessage({success:!0,data:e.data})};const i={type:es.SDK_REQUEST_CLIENT_CREATION,payload:{success:!0,...s,clientId:`dynamic-client-${s.serverName}-${s.serverVersion}-${Date.now()}`,requestId:t.data.payload.requestId},timestamp:Date.now()};if(!e.iframe)throw new Error("Iframe not found");e.iframe.contentWindow?.postMessage(i,e.iframeUrlObject?.origin||"",[a.port2])}catch(e){console.error(`AngieMcpSdk:Failed to create client for SDK server "${s.serverName}":`,e)}break;case es.SDK_TRIGGER_ANGIE:console.log("SDK Trigger Angie received",t.data);try{const{requestId:n,prompt:s,context:a}=t.data.payload;if(!e.iframe)throw new Error("Iframe not found");e.iframe.contentWindow?.postMessage({type:es.SDK_TRIGGER_ANGIE,payload:{requestId:n,prompt:s,context:a}},e.iframeUrlObject?.origin||""),window.postMessage({type:es.SDK_TRIGGER_ANGIE_RESPONSE,payload:{success:!0,requestId:n,response:"Angie triggered successfully"}},window.location.origin)}catch(e){console.error("Failed to trigger Angie:",e),window.postMessage({type:es.SDK_TRIGGER_ANGIE_RESPONSE,payload:{success:!1,requestId:t.data.payload?.requestId,error:e instanceof Error?e.message:"Unknown error"}},window.location.origin)}}})})(Yn),Jn(),window.addEventListener("message",async t=>{if([window.location.origin,e.origin||"https://angie.elementor.com"].includes(t.origin))if(t?.data?.type===es.ANGIE_CHAT_TOGGLE)Yn.open=t.data.open,Yn.iframe&&Vn(Yn.iframe,Yn.open);else if(t?.data?.type===es.ANGIE_STUDIO_TOGGLE){const e=t.data.isStudioOpen;if(!Yn.iframe)return;if(e)document.documentElement.classList.add("angie-studio-active");else{const e=Dn();document.documentElement.style.setProperty("--angie-sidebar-width",`${e}px`),document.documentElement.classList.remove("angie-studio-active")}}else if(t?.data?.type===es.ANGIE_NAVIGATE_TO_URL){const{url:e=""}=t.data;if(!((e,t=[])=>{const n=0===t.length&&"undefined"!=typeof window?[window.location.origin]:t;if(!e.startsWith("http"))return!1;try{const t=new URL(e);return n.includes(t.origin)}catch{return!1}})(e))throw new Error("Angie: Invalid URL - navigation blocked for security reasons");window.location.assign(e)}else t?.data?.type===es.ANGIE_PAGE_RELOAD?(console.log("Angie requested page reload - database operations completed"),window.location.reload()):t?.data?.type===r.RESET_HASH&&(window.location.hash="",Bn(t.ports[0],{message:"Hash reset successfully"}))})})({origin:e?.origin||"https://angie.elementor.com",uiTheme:e?.uiTheme||"light",isRTL:e?.isRTL||!1,...e}),this.setupPromptHashDetection()}setupReRegistrationHandler(){window.addEventListener("message",e=>{if(e.data?.type===a.SDK_ANGIE_REFRESH_PING)if(console.log(`AngieMcpSdk: Angie refresh ping received (Instance: ${this.instanceId})`),this.registrationQueue.resetAllToPending()){const e=this.registrationQueue.getPending().length;console.log(`AngieMcpSdk: Successfully reset ${e} registrations, processing queue (Instance: ${this.instanceId})`),this.handleAngieReady()}else console.log(`AngieMcpSdk: Skipping queue reset - processing already in progress (Instance: ${this.instanceId})`)})}setupAngieReadyHandler(){this.angieDetector.waitForReady().then(e=>{e.isReady?this.handleAngieReady():console.warn("AngieMcpSdk: Angie not detected - servers will remain queued")}).catch(e=>{console.error("AngieMcpSdk: Error waiting for Angie:",e)})}async handleAngieReady(){console.log(`AngieMcpSdk: Angie is ready, processing queued registrations (Instance: ${this.instanceId})`);try{await this.registrationQueue.processQueue(async e=>{console.log(`AngieMcpSdk: processQueue callback called for "${e.config.name}" (Instance: ${this.instanceId})`),await this.processRegistration(e)}),this.isInitialized=!0,console.log(`AngieMcpSdk: Initialization complete (Instance: ${this.instanceId})`)}catch(e){console.error(`AngieMcpSdk: Error processing registration queue (Instance: ${this.instanceId}):`,e)}}async processRegistration(e){console.log(`AngieMcpSdk: Processing registration for server "${e.config.name}" (ID: ${e.id}) (Instance: ${this.instanceId})`);try{console.log(`AngieMcpSdk: Calling clientManager.requestClientCreation for "${e.config.name}" (Instance: ${this.instanceId})`);const t={...e,instanceId:this.instanceId};await this.clientManager.requestClientCreation(t),console.log(`AngieMcpSdk: Successfully registered server "${e.config.name}" (Instance: ${this.instanceId})`)}catch(t){throw console.error(`AngieMcpSdk: Failed to register server "${e.config.name}" (Instance: ${this.instanceId}):`,t),t}}registerLocalServer(e){return e.type=s.LOCAL,e.transport=t.POST_MESSAGE,this.registerServer(e)}registerRemoteServer(e){return e.type=s.REMOTE,this.registerServer(e)}isLocalServerConfig(e){return e.type===s.LOCAL||!e.type&&"server"in e}isRemoteServerConfig(e){return e.type===s.REMOTE&&"url"in e}async registerServer(e){if(!e.type)return console.warn("AngieMcpSdk: for a local server, please use registerLocalServer instead of registerServer"),void this.registerLocalServer(e);if(console.log(`AngieMcpSdk: registerServer called for "${e.name}" (Instance: ${this.instanceId})`),!e.name)throw new Error("Server name is required");if(!e.description)throw new Error("Server description is required");if(this.isLocalServerConfig(e)&&!e.server)throw new Error("Server instance is required for local servers");console.log(`AngieMcpSdk: Registering server "${e.name}" (Instance: ${this.instanceId})`);const t=this.registrationQueue.add(e);if(console.log(`AngieMcpSdk: Added registration to queue: ${t.id} (Instance: ${this.instanceId})`),this.angieDetector.isReady())try{await this.processRegistration(t),this.registrationQueue.updateStatus(t.id,"registered"),console.log(`AngieMcpSdk: Server "${e.name}" registered successfully (Instance: ${this.instanceId})`)}catch(e){const n=e instanceof Error?e.message:String(e);throw this.registrationQueue.updateStatus(t.id,"failed",n),e}else console.log(`AngieMcpSdk: Server "${e.name}" queued until Angie is ready (Instance: ${this.instanceId})`)}getRegistrations(){return this.registrationQueue.getAll()}getPendingRegistrations(){return this.registrationQueue.getPending()}isAngieReady(){return this.angieDetector.isReady()}isReady(){return this.isInitialized}async waitForReady(){if(!(await this.angieDetector.waitForReady()).isReady)throw new Error("Angie is not available");for(;!this.isInitialized;)await new Promise(e=>setTimeout(e,100))}async triggerAngie(e){if(!this.isAngieReady())throw new Error("Angie is not ready. Please wait for Angie to be available before triggering.");const t=this.generateRequestId(),n=e.options?.timeout||3e4;return new Promise((s,i)=>{const r=setTimeout(()=>{i(new Error("Angie trigger request timed out"))},n),o=e=>{e.data?.type===a.SDK_TRIGGER_ANGIE_RESPONSE&&e.data?.payload?.requestId===t&&(clearTimeout(r),window.removeEventListener("message",o),s(e.data.payload))};window.addEventListener("message",o);const d={type:a.SDK_TRIGGER_ANGIE,payload:{requestId:t,prompt:e.prompt,options:e.options,context:{pageUrl:window.location.href,pageTitle:document.title,...e.context}},timestamp:Date.now()};console.log(`AngieMcpSdk: Triggering Angie with prompt (Request ID: ${t}, Instance: ${this.instanceId})`),window.postMessage(d,window.location.origin)})}destroy(){this.registrationQueue.clear(),console.log(`AngieMcpSdk: SDK destroyed (Instance: ${this.instanceId})`)}setupServerInitHandler(){window.addEventListener("message",e=>{e.data?.type===a.SDK_REQUEST_INIT_SERVER&&(console.log(`AngieMcpSdk: Server init request received (Instance: ${this.instanceId})`),this.handleServerInitRequest(e))})}handleServerInitRequest(e){const{clientId:t,serverId:n,instanceId:s}=e.data.payload||{};if(t&&n)if(console.log(`AngieMcpSdk: Server init request received - Request instanceId: ${s}, This instanceId: ${this.instanceId} (Instance: ${this.instanceId})`),s&&s!==this.instanceId)console.log(`AngieMcpSdk: Ignoring server init request for different instance. Request instanceId: ${s}, this instanceId: ${this.instanceId}`);else{console.log(`AngieMcpSdk: Handling server init request for clientId: ${t}, serverId: ${n} (Instance: ${this.instanceId})`);try{const t=this.registrationQueue.getAll().find(e=>e.id===n);if(!t)return void console.error(`AngieMcpSdk: No registration found for serverId: ${n} (Instance: ${this.instanceId})`);if("type"in t.config&&"remote"===t.config.type)return void console.log(`AngieMcpSdk: Remote server registration detected; skipping local connect (Instance: ${this.instanceId})`);const s=e.ports[0];if(!s)return void console.error(`AngieMcpSdk: No port provided in server init request (Instance: ${this.instanceId})`);const a=t.config.server,i=new Cn(s);a.connect(i),console.log(`AngieMcpSdk: Server "${t.config.name}" initialized successfully (Instance: ${this.instanceId})`)}catch(e){console.error(`AngieMcpSdk: Error initializing server for clientId ${t} (Instance: ${this.instanceId}):`,e)}}else console.error(`AngieMcpSdk: Invalid server init request - missing clientId or serverId (Instance: ${this.instanceId})`)}generateRequestId(){return`${this.instanceId}-${Date.now()}-${Math.random().toString(36).substring(2,8)}`}async handlePromptHash(){const e=window.location.hash;if(e.startsWith("#angie-prompt="))try{const t=e.replace("#angie-prompt=",""),n=decodeURIComponent(t);if(!n)return void console.warn("AngieMcpSdk: Empty prompt detected in hash");console.log("AngieMcpSdk: Detected prompt in hash:",n),await this.waitForReady();const s=await this.triggerAngie({prompt:n,context:{source:"hash-parameter",pageUrl:window.location.href,timestamp:(new Date).toISOString()}});console.log("AngieMcpSdk: Triggered successfully from hash:",s),window.location.hash=""}catch(e){console.error("AngieMcpSdk: Failed to trigger from hash:",e)}}setupPromptHashDetection(){this.handlePromptHash(),window.addEventListener("hashchange",()=>this.handlePromptHash())}}const ns=(e,t)=>{if(Pn()){t.isOpen&&window.toggleAngieSidebar&&window.toggleAngieSidebar(!0);const n=$n({type:"angie-route-navigation",path:e,payload:t});return n||console.error("Failed to post navigation message to Angie iframe"),n}return console.error("Angie iframe not found"),!1};export{Zn as ANGIE_SIDEBAR_STATE_OPEN,c as AngieDetector,t as AngieLocalServerTransport,e as AngieMCPTransport,ts as AngieMcpSdk,n as AngieRemoteServerTransport,s as AngieServerType,l as ClientManager,r as HostEventType,i as HostLocalStorageEventType,a as MessageEventType,u as RegistrationQueue,Un as applyWidth,Pn as getAngieIframe,jn as getAngieSidebarSavedState,Kn as initAngieSidebar,zn as initializeResize,qn as loadState,Dn as loadWidth,ns as navigateAngieIframe,Gn as saveWidth,Vn as toggleAngieSidebar,Wn as waitForDocumentReady};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const addLocalStorageListener: () => void;
|
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
toggleAngieSidebar: (force?: boolean, skipTransition?: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export declare const OAUTH_MESSAGE_TYPES: {
|
|
7
|
+
readonly OAUTH_GET_CODE_AND_STATE: "OAUTH_GET_CODE_AND_STATE";
|
|
8
|
+
readonly OAUTH_GET_TOP_URL: "OAUTH_GET_TOP_URL";
|
|
9
|
+
readonly OAUTH_REDIRECT_TOP_WINDOW: "OAUTH_REDIRECT_TOP_WINDOW";
|
|
10
|
+
readonly OAUTH_UPDATE_URL: "OAUTH_UPDATE_URL";
|
|
11
|
+
readonly ANGIE_REDIRECT_TO_WP_ADMIN_WITH_OAUTH: "ANGIE_REDIRECT_TO_WP_ADMIN_WITH_OAUTH";
|
|
12
|
+
readonly ANGIE_REDIRECT_TO_AUTH_ORIGIN_LOGOUT: "ANGIE_REDIRECT_TO_AUTH_ORIGIN_LOGOUT";
|
|
13
|
+
};
|
|
14
|
+
export declare const getOAuthCodeAndState: (port: MessagePort) => void;
|
|
15
|
+
export declare const listenToOAuthFromIframe: () => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type OpenSaaSPageInput = {
|
|
2
|
+
origin: string;
|
|
3
|
+
path: string;
|
|
4
|
+
parent?: Document;
|
|
5
|
+
insertCallback?: (iframe: HTMLIFrameElement) => void;
|
|
6
|
+
css: {
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
};
|
|
9
|
+
uiTheme?: string;
|
|
10
|
+
isRTL?: boolean;
|
|
11
|
+
sdkVersion: string;
|
|
12
|
+
};
|
|
13
|
+
type OpenSaaSPageOutput = {
|
|
14
|
+
iframe: HTMLIFrameElement;
|
|
15
|
+
iframeUrlObject: URL;
|
|
16
|
+
};
|
|
17
|
+
export declare const openSaaSPage: (props: OpenSaaSPageInput) => Promise<OpenSaaSPageOutput>;
|
|
18
|
+
export {};
|
|
@@ -8,6 +8,7 @@ export declare class RegistrationQueue {
|
|
|
8
8
|
updateStatus(id: string, status: ServerRegistration['status'], error?: string): void;
|
|
9
9
|
processQueue(processor: (registration: ServerRegistration) => Promise<void>): Promise<void>;
|
|
10
10
|
clear(): void;
|
|
11
|
+
resetAllToPending(): boolean;
|
|
11
12
|
remove(id: string): boolean;
|
|
12
13
|
private generateId;
|
|
13
14
|
}
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ServerCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { AppState } from './config';
|
|
3
|
+
export declare enum AngieMCPTransport {
|
|
4
|
+
POST_MESSAGE = "postMessage"
|
|
5
|
+
}
|
|
6
|
+
export interface ClientCreationRequest {
|
|
7
|
+
serverId: string;
|
|
8
|
+
serverName: string;
|
|
9
|
+
description: string;
|
|
10
|
+
serverVersion: string;
|
|
11
|
+
transport: AngieMCPTransport;
|
|
12
|
+
capabilities?: ServerCapabilities;
|
|
13
|
+
}
|
|
14
|
+
export declare const listenToSDK: (appState: AppState) => void;
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const ANGIE_SIDEBAR_STATE_OPEN = "open";
|
|
2
|
+
export declare const ANGIE_SIDEBAR_STATE_CLOSED = "closed";
|
|
3
|
+
export type AngieSidebarState = typeof ANGIE_SIDEBAR_STATE_OPEN | typeof ANGIE_SIDEBAR_STATE_CLOSED;
|
|
4
|
+
export type AngieSidebarToggleEventData = {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
sidebar: HTMLElement;
|
|
7
|
+
skipTransition?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function loadWidth(): number;
|
|
10
|
+
export declare function getAngieSidebarSavedState(): AngieSidebarState | null;
|
|
11
|
+
export declare function handleFocus(isOpen: boolean, delay: number): void;
|
|
12
|
+
export declare function saveState(state: string): void;
|
|
13
|
+
export declare function saveWidth(width: number): void;
|
|
14
|
+
export declare function applyWidth(width: number): void;
|
|
15
|
+
export declare function isInOAuthFlow(): boolean;
|
|
16
|
+
export declare function forceSidebarClosedDuringOAuth(): void;
|
|
17
|
+
export declare function loadState(): void;
|
|
18
|
+
export declare function applyState(state: AngieSidebarState): void;
|
|
19
|
+
export declare function initializeResize(): void;
|
|
20
|
+
export declare function createToggleSidebarFunction(onToggle?: (isOpen: boolean, sidebar: HTMLElement, skipTransition?: boolean) => void): (force?: boolean, skipTransition?: boolean) => void;
|
|
21
|
+
export declare function setupMessageListener(): void;
|
|
22
|
+
export declare function initAngieSidebar(onToggle?: (isOpen: boolean, sidebar: HTMLElement, skipTransition?: boolean) => void): void;
|
|
23
|
+
declare global {
|
|
24
|
+
interface Window {
|
|
25
|
+
toggleAngieSidebar: (force?: boolean, skipTransition?: boolean) => void;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,13 +4,35 @@ import { ServerCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
|
4
4
|
export declare enum AngieMCPTransport {
|
|
5
5
|
POST_MESSAGE = "postMessage"
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export declare enum AngieLocalServerTransport {
|
|
8
|
+
POST_MESSAGE = "postMessage"
|
|
9
|
+
}
|
|
10
|
+
export declare enum AngieRemoteServerTransport {
|
|
11
|
+
STREAMABLE_HTTP = "streamableHttp",
|
|
12
|
+
SSE = "sse"
|
|
13
|
+
}
|
|
14
|
+
export declare enum AngieServerType {
|
|
15
|
+
LOCAL = "local",
|
|
16
|
+
REMOTE = "remote"
|
|
17
|
+
}
|
|
18
|
+
export type AngieBaseServerConfig = {
|
|
8
19
|
name: string;
|
|
9
20
|
version: string;
|
|
10
21
|
description: string;
|
|
11
|
-
server: Server | McpServer;
|
|
12
22
|
capabilities?: ServerCapabilities;
|
|
13
|
-
|
|
23
|
+
type?: AngieServerType;
|
|
24
|
+
};
|
|
25
|
+
export type AngieLocalServerConfig = AngieBaseServerConfig & {
|
|
26
|
+
server: Server | McpServer;
|
|
27
|
+
transport?: AngieLocalServerTransport;
|
|
28
|
+
type?: AngieServerType.LOCAL;
|
|
29
|
+
};
|
|
30
|
+
export type AngieRemoteServerConfig = AngieBaseServerConfig & {
|
|
31
|
+
url: string;
|
|
32
|
+
transport?: AngieRemoteServerTransport;
|
|
33
|
+
type?: AngieServerType.REMOTE;
|
|
34
|
+
};
|
|
35
|
+
export type AngieServerConfig = AngieLocalServerConfig | AngieRemoteServerConfig;
|
|
14
36
|
export interface ServerRegistration {
|
|
15
37
|
id: string;
|
|
16
38
|
config: AngieServerConfig;
|
|
@@ -23,9 +45,9 @@ export interface AngieDetectionResult {
|
|
|
23
45
|
version?: string;
|
|
24
46
|
capabilities?: string[];
|
|
25
47
|
}
|
|
26
|
-
export interface AngieMessage {
|
|
48
|
+
export interface AngieMessage<T = unknown> {
|
|
27
49
|
type: string;
|
|
28
|
-
payload:
|
|
50
|
+
payload: T;
|
|
29
51
|
origin?: string;
|
|
30
52
|
timestamp: number;
|
|
31
53
|
}
|
|
@@ -34,16 +56,48 @@ export interface ClientCreationRequest {
|
|
|
34
56
|
serverName: string;
|
|
35
57
|
description: string;
|
|
36
58
|
serverVersion: string;
|
|
37
|
-
transport
|
|
59
|
+
transport?: AngieLocalServerTransport | AngieRemoteServerTransport;
|
|
38
60
|
capabilities?: ServerCapabilities;
|
|
61
|
+
instanceId?: string;
|
|
62
|
+
remote?: {
|
|
63
|
+
url: string;
|
|
64
|
+
};
|
|
39
65
|
}
|
|
40
66
|
export interface ClientCreationResponse {
|
|
41
67
|
success: boolean;
|
|
42
68
|
clientId?: string;
|
|
43
69
|
error?: string;
|
|
44
70
|
}
|
|
71
|
+
export interface AngieTriggerRequest {
|
|
72
|
+
prompt?: string;
|
|
73
|
+
context: {
|
|
74
|
+
source?: string;
|
|
75
|
+
} & Record<string, any>;
|
|
76
|
+
options?: {
|
|
77
|
+
timeout?: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export interface AngieTriggerResponse {
|
|
81
|
+
success: boolean;
|
|
82
|
+
response?: string;
|
|
83
|
+
error?: string;
|
|
84
|
+
requestId: string;
|
|
85
|
+
}
|
|
45
86
|
export declare enum MessageEventType {
|
|
46
87
|
SDK_ANGIE_READY_PING = "sdk-angie-ready-ping",
|
|
88
|
+
SDK_ANGIE_REFRESH_PING = "sdk-angie-refresh-ping",
|
|
47
89
|
SDK_REQUEST_CLIENT_CREATION = "sdk-request-client-creation",
|
|
48
|
-
SDK_REQUEST_INIT_SERVER = "sdk-request-init-server"
|
|
90
|
+
SDK_REQUEST_INIT_SERVER = "sdk-request-init-server",
|
|
91
|
+
SDK_TRIGGER_ANGIE = "sdk-trigger-angie",
|
|
92
|
+
SDK_TRIGGER_ANGIE_RESPONSE = "sdk-trigger-angie-response"
|
|
93
|
+
}
|
|
94
|
+
export declare enum HostLocalStorageEventType {
|
|
95
|
+
SET = "ANGIE_SET_LOCALSTORAGE",
|
|
96
|
+
GET = "ANGIE_GET_LOCALSTORAGE"
|
|
97
|
+
}
|
|
98
|
+
export declare enum HostEventType {
|
|
99
|
+
RESET_HASH = "reset-hash",
|
|
100
|
+
HOST_READY = "host/ready",
|
|
101
|
+
ANGIE_LOADED = "angie/loaded",
|
|
102
|
+
ANGIE_READY = "angie/ready"
|
|
49
103
|
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const toggleAngieSidebar: (iframe: HTMLIFrameElement, isOpen: boolean) => void;
|
|
2
|
+
export declare const isMobile: () => boolean;
|
|
3
|
+
export declare const sendSuccessMessage: (port: MessagePort, payload?: unknown) => void;
|
|
4
|
+
export declare const sendErrorMessage: (port: MessagePort, error: unknown) => void;
|
|
5
|
+
export declare const waitForDocumentReady: () => Promise<unknown>;
|
|
6
|
+
export declare const isSafeUrl: (url: string, trustedOrigins?: string[]) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ANGIE_SDK_VERSION: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/angie-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "TypeScript SDK for Angie AI assistant",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"build": "npm run build:types && npm run build:bundle",
|
|
10
10
|
"build:types": "tsc",
|
|
11
11
|
"build:bundle": "webpack --mode=production",
|
|
12
|
+
"build:watch": "npm run build:types && webpack --mode=production --watch",
|
|
12
13
|
"dev": "tsc --watch",
|
|
13
14
|
"test": "jest",
|
|
14
15
|
"lint": "eslint src/**/*.ts",
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
"author": "Elementor",
|
|
26
27
|
"license": "MIT",
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@modelcontextprotocol/sdk": "
|
|
29
|
-
"zod": "
|
|
29
|
+
"@modelcontextprotocol/sdk": "1.17.4",
|
|
30
|
+
"zod": "4.1.3"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/jest": "^29.5.12",
|
|
@@ -35,8 +36,11 @@
|
|
|
35
36
|
"@typescript-eslint/parser": "^6.19.1",
|
|
36
37
|
"eslint": "^8.56.0",
|
|
37
38
|
"jest": "^29.7.0",
|
|
39
|
+
"jest-environment-jsdom": "^30.0.0",
|
|
40
|
+
"raw-loader": "^4.0.2",
|
|
38
41
|
"ts-jest": "^29.3.2",
|
|
39
42
|
"ts-loader": "^9.5.1",
|
|
43
|
+
"ts-node": "^10.9.2",
|
|
40
44
|
"typescript": "^5.3.3",
|
|
41
45
|
"webpack": "^5.89.0",
|
|
42
46
|
"webpack-cli": "^5.1.4"
|