@apollo/mcp-impostor-host 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/bin/serve-impostor-host.js +2 -0
- package/dist/core/Host.d.ts +16 -0
- package/dist/core/Host.d.ts.map +1 -0
- package/dist/core/Host.js +56 -0
- package/dist/core/Host.js.map +1 -0
- package/dist/core/HostConnection.d.ts +71 -0
- package/dist/core/HostConnection.d.ts.map +1 -0
- package/dist/core/HostConnection.js +57 -0
- package/dist/core/HostConnection.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/playwright/fixture.d.ts +24 -0
- package/dist/playwright/fixture.d.ts.map +1 -0
- package/dist/playwright/fixture.js +27 -0
- package/dist/playwright/fixture.js.map +1 -0
- package/dist/playwright/harness/harness.html +213 -0
- package/dist/playwright/index.d.ts +3 -0
- package/dist/playwright/index.d.ts.map +1 -0
- package/dist/playwright/index.js +2 -0
- package/dist/playwright/index.js.map +1 -0
- package/dist/playwright/types.d.ts +11 -0
- package/dist/playwright/types.d.ts.map +1 -0
- package/dist/playwright/types.js +2 -0
- package/dist/playwright/types.js.map +1 -0
- package/dist/react/Sandbox.d.ts +10 -0
- package/dist/react/Sandbox.d.ts.map +1 -0
- package/dist/react/Sandbox.js +109 -0
- package/dist/react/Sandbox.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -0
- package/dist/sandbox/sandbox.html +119 -0
- package/dist/sandbox/server.js +77 -0
- package/dist/utilities/TypedEventTarget.d.ts +19 -0
- package/dist/utilities/TypedEventTarget.d.ts.map +1 -0
- package/dist/utilities/TypedEventTarget.js +5 -0
- package/dist/utilities/TypedEventTarget.js.map +1 -0
- package/dist/utilities/constants.d.ts +2 -0
- package/dist/utilities/constants.d.ts.map +1 -0
- package/dist/utilities/constants.js +8 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/index.d.ts +6 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/index.js +5 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/invariant.d.ts +2 -0
- package/dist/utilities/invariant.d.ts.map +1 -0
- package/dist/utilities/invariant.js +5 -0
- package/dist/utilities/invariant.js.map +1 -0
- package/dist/utilities/logger.d.ts +24 -0
- package/dist/utilities/logger.d.ts.map +1 -0
- package/dist/utilities/logger.js +33 -0
- package/dist/utilities/logger.js.map +1 -0
- package/dist/utilities/promiseWithResolvers.d.ts +7 -0
- package/dist/utilities/promiseWithResolvers.d.ts.map +1 -0
- package/dist/utilities/promiseWithResolvers.js +15 -0
- package/dist/utilities/promiseWithResolvers.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playwright/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/playwright/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types";
|
|
2
|
+
export interface CallToolResponse {
|
|
3
|
+
result: CallToolResult;
|
|
4
|
+
input: Record<string, unknown> | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface McpHost {
|
|
7
|
+
connect(url: string): Promise<void>;
|
|
8
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<CallToolResponse>;
|
|
9
|
+
teardown(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/playwright/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/playwright/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HostConnection } from "../core/index.js";
|
|
2
|
+
export declare namespace Sandbox {
|
|
3
|
+
interface Props {
|
|
4
|
+
connection: HostConnection | null;
|
|
5
|
+
execution: HostConnection.ToolExecution | null;
|
|
6
|
+
url: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare function Sandbox({ url, connection, execution }: Sandbox.Props): import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
//# sourceMappingURL=Sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sandbox.d.ts","sourceRoot":"","sources":["../../src/react/Sandbox.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,UAAiB,KAAK;QACpB,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;QAClC,SAAS,EAAE,cAAc,CAAC,aAAa,GAAG,IAAI,CAAC;QAC/C,GAAG,EAAE,MAAM,CAAC;KACb;CACF;AAED,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,KAAK,kDA2GpE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AppBridge, buildAllowAttribute, getToolUiResourceUri, PostMessageTransport, SANDBOX_PROXY_READY_METHOD, } from "@modelcontextprotocol/ext-apps/app-bridge";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import pkg from "#package.json";
|
|
5
|
+
import { invariant } from "../utilities/invariant.js";
|
|
6
|
+
import { promiseWithResolvers } from "../utilities/promiseWithResolvers.js";
|
|
7
|
+
export function Sandbox({ url, connection, execution }) {
|
|
8
|
+
const resourceUri = execution ? getToolUiResourceUri(execution.tool) : null;
|
|
9
|
+
const hasUiResource = !!(connection && execution && resourceUri);
|
|
10
|
+
const refCallback = useCallback((iframe) => {
|
|
11
|
+
if (!connection || !execution || !resourceUri)
|
|
12
|
+
return;
|
|
13
|
+
invariant(!connection.closed, "The connection is already closed.");
|
|
14
|
+
let initialized = false;
|
|
15
|
+
let mounted = true;
|
|
16
|
+
let bridge;
|
|
17
|
+
function close() {
|
|
18
|
+
mounted = false;
|
|
19
|
+
if (initialized) {
|
|
20
|
+
bridge?.teardownResource({}).catch(() => { });
|
|
21
|
+
}
|
|
22
|
+
bridge?.close();
|
|
23
|
+
}
|
|
24
|
+
connection.addEventListener("close", close);
|
|
25
|
+
connection
|
|
26
|
+
.getUiResource(resourceUri)
|
|
27
|
+
.then(async (uiResource) => {
|
|
28
|
+
if (!mounted) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const allowAttribute = buildAllowAttribute(uiResource.permissions);
|
|
32
|
+
if (allowAttribute) {
|
|
33
|
+
iframe.setAttribute("allow", allowAttribute);
|
|
34
|
+
}
|
|
35
|
+
iframe.src = getSandboxSrc(url, uiResource);
|
|
36
|
+
await waitForSandboxReady(iframe);
|
|
37
|
+
const capabilities = connection.client.getServerCapabilities();
|
|
38
|
+
bridge = new AppBridge(connection.client, { name: "@apollo/mcp-impostor-host", version: pkg.version }, {
|
|
39
|
+
serverTools: capabilities?.tools,
|
|
40
|
+
serverResources: capabilities?.resources,
|
|
41
|
+
}, {
|
|
42
|
+
hostContext: {
|
|
43
|
+
platform: "web",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const init = promiseWithResolvers();
|
|
47
|
+
bridge.oninitialized = () => {
|
|
48
|
+
initialized = true;
|
|
49
|
+
init.resolve();
|
|
50
|
+
};
|
|
51
|
+
await bridge.connect(new PostMessageTransport(iframe.contentWindow, iframe.contentWindow));
|
|
52
|
+
bridge.sendSandboxResourceReady(uiResource);
|
|
53
|
+
await init.promise;
|
|
54
|
+
bridge.sendToolInput({ arguments: execution.input });
|
|
55
|
+
const result = await execution.resultPromise;
|
|
56
|
+
bridge.sendToolResult(result);
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
if (error instanceof Error) {
|
|
60
|
+
connection.logger.error(error.message, error.cause);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return () => {
|
|
64
|
+
mounted = false;
|
|
65
|
+
close();
|
|
66
|
+
connection.removeEventListener("close", close);
|
|
67
|
+
};
|
|
68
|
+
}, [connection, execution, resourceUri, url]);
|
|
69
|
+
return hasUiResource ?
|
|
70
|
+
_jsx("iframe", { ref: refCallback, sandbox: "allow-scripts allow-same-origin allow-forms", style: {
|
|
71
|
+
border: "none",
|
|
72
|
+
width: "100dvw",
|
|
73
|
+
height: "100dvh",
|
|
74
|
+
backgroundColor: "transparent",
|
|
75
|
+
} })
|
|
76
|
+
: null;
|
|
77
|
+
}
|
|
78
|
+
function getSandboxSrc(baseUrl, uiResource) {
|
|
79
|
+
const src = new URL(baseUrl);
|
|
80
|
+
if (uiResource.csp && Object.keys(uiResource.csp).length > 0) {
|
|
81
|
+
src.searchParams.set("csp", JSON.stringify(uiResource.csp));
|
|
82
|
+
}
|
|
83
|
+
return src.href;
|
|
84
|
+
}
|
|
85
|
+
function waitForSandboxReady(iframe) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
function cleanup() {
|
|
88
|
+
window.removeEventListener("message", handleMessage);
|
|
89
|
+
iframe.removeEventListener("error", handleError);
|
|
90
|
+
}
|
|
91
|
+
function handleError(event) {
|
|
92
|
+
reject(new Error("Could not load iframe", { cause: event.error }));
|
|
93
|
+
cleanup();
|
|
94
|
+
}
|
|
95
|
+
function handleMessage(event) {
|
|
96
|
+
if (event.source === iframe.contentWindow &&
|
|
97
|
+
event.data &&
|
|
98
|
+
typeof event.data === "object" &&
|
|
99
|
+
"method" in event.data &&
|
|
100
|
+
event.data?.method === SANDBOX_PROXY_READY_METHOD) {
|
|
101
|
+
resolve();
|
|
102
|
+
cleanup();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
window.addEventListener("message", handleMessage);
|
|
106
|
+
iframe.addEventListener("error", handleError);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=Sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sandbox.js","sourceRoot":"","sources":["../../src/react/Sandbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,GAAG,MAAM,eAAe,CAAC;AAGhC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAU5E,MAAM,UAAU,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAiB;IACnE,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,MAAM,aAAa,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,SAAS,IAAI,WAAW,CAAC,CAAC;IAEjE,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,MAAyB,EAAE,EAAE;QAC5B,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,IAAI,CAAC,WAAW;YAAE,OAAO;QAEtD,SAAS,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;QAEnE,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,MAA6B,CAAC;QAElC,SAAS,KAAK;YACZ,OAAO,GAAG,KAAK,CAAC;YAChB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC/C,CAAC;YAED,MAAM,EAAE,KAAK,EAAE,CAAC;QAClB,CAAC;QAED,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAE5C,UAAU;aACP,aAAa,CAAC,WAAW,CAAC;aAC1B,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;YACzB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAEnE,IAAI,cAAc,EAAE,CAAC;gBACnB,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAC/C,CAAC;YAED,MAAM,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YAE5C,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;YAElC,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;YAE/D,MAAM,GAAG,IAAI,SAAS,CACpB,UAAU,CAAC,MAAM,EACjB,EAAE,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAC3D;gBACE,WAAW,EAAE,YAAY,EAAE,KAAK;gBAChC,eAAe,EAAE,YAAY,EAAE,SAAS;aACzC,EACD;gBACE,WAAW,EAAE;oBACX,QAAQ,EAAE,KAAK;iBAChB;aACF,CACF,CAAC;YAEF,MAAM,IAAI,GAAG,oBAAoB,EAAQ,CAAC;YAE1C,MAAM,CAAC,aAAa,GAAG,GAAG,EAAE;gBAC1B,WAAW,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,CAAC,CAAC;YAEF,MAAM,MAAM,CAAC,OAAO,CAClB,IAAI,oBAAoB,CACtB,MAAM,CAAC,aAAc,EACrB,MAAM,CAAC,aAAc,CACtB,CACF,CAAC;YAEF,MAAM,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC;YAE5C,MAAM,IAAI,CAAC,OAAO,CAAC;YACnB,MAAM,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;YAErD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC;YAC7C,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,KAAK,CAAC;YAChB,KAAK,EAAE,CAAC;YACR,UAAU,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,CAAC,CAC1C,CAAC;IAEF,OAAO,aAAa,CAAC,CAAC;QAClB,iBACE,GAAG,EAAE,WAAW,EAChB,OAAO,EAAC,6CAA6C,EACrD,KAAK,EAAE;gBACL,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,QAAQ;gBAChB,eAAe,EAAE,aAAa;aAC/B,GACD;QACJ,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,SAAS,aAAa,CAAC,OAAe,EAAE,UAAqC;IAC3E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAE7B,IAAI,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAyB;IACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,SAAS,OAAO;YACd,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YACrD,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;QAED,SAAS,WAAW,CAAC,KAAiB;YACpC,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACnE,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,SAAS,aAAa,CAAC,KAA4B;YACjD,IACE,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,aAAa;gBACrC,KAAK,CAAC,IAAI;gBACV,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAC9B,QAAQ,IAAI,KAAK,CAAC,IAAI;gBACtB,KAAK,CAAC,IAAI,EAAE,MAAM,KAAK,0BAA0B,EACjD,CAAC;gBACD,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAED,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="color-scheme" content="light dark" />
|
|
6
|
+
<title>MCP Impostor Host - Sandbox</title>
|
|
7
|
+
<style>
|
|
8
|
+
html,
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
height: 100vh;
|
|
12
|
+
width: 100vw;
|
|
13
|
+
/* Transparent background allows parent page to show through */
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
* {
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
iframe {
|
|
22
|
+
background-color: transparent;
|
|
23
|
+
border: 0px none transparent;
|
|
24
|
+
padding: 0px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
color-scheme: inherit;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
30
|
+
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),Object.freeze({status:`aborted`});function e(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var t=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},n=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},r={};function i(e){return e&&Object.assign(r,e),r}function a(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function o(e,t){return typeof t==`bigint`?t.toString():t}function s(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function c(e){return e==null}function l(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function u(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var ee=Symbol(`evaluating`);function d(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ee)return r===void 0&&(r=ee,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function f(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function p(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function te(e){return JSON.stringify(e)}function ne(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var re=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ie=s(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function h(e){if(m(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(m(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ae(e){return h(e)?{...e}:Array.isArray(e)?[...e]:e}var oe=new Set([`string`,`number`,`symbol`]);function g(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function v(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function se(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var ce={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function le(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return _(e,p(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return f(this,`shape`,e),e},checks:[]}))}function ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return _(e,p(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return f(this,`shape`,r),r},checks:[]}))}function de(e,t){if(!h(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _(e,p(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return f(this,`shape`,n),n}}))}function fe(e,t){if(!h(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _(e,p(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return f(this,`shape`,n),n}}))}function pe(e,t){return _(e,p(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return f(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function me(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return _(t,p(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return f(this,`shape`,i),i},checks:[]}))}function he(e,t,n){return _(t,p(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return f(this,`shape`,i),i}}))}function y(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function b(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ge(e){return typeof e==`string`?e:e?.message}function x(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=ge(e.inst?._zod.def?.error?.(e))??ge(t?.error?.(e))??ge(n.customError?.(e))??ge(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function _e(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function S(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var ve=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,o,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},ye=e(`$ZodError`,ve),be=e(`$ZodError`,ve,{Parent:Error});function xe(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Se(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var Ce=e=>(n,r,a,o)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new t;if(c.issues.length){let t=new(o?.Err??e)(c.issues.map(e=>x(e,s,i())));throw re(t,o?.callee),t}return c.value},we=e=>async(t,n,r,a)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let t=new(a?.Err??e)(s.issues.map(e=>x(e,o,i())));throw re(t,a?.callee),t}return s.value},Te=e=>(n,r,a)=>{let o=a?{...a,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new t;return s.issues.length?{success:!1,error:new(e??ye)(s.issues.map(e=>x(e,o,i())))}:{success:!0,data:s.value}},Ee=Te(be),De=e=>async(t,n,r)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>x(e,a,i())))}:{success:!0,data:o.value}},Oe=De(be),ke=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ce(e)(t,n,i)},Ae=e=>(t,n,r)=>Ce(e)(t,n,r),je=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return we(e)(t,n,i)},Me=e=>async(t,n,r)=>we(e)(t,n,r),Ne=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Te(e)(t,n,i)},Pe=e=>(t,n,r)=>Te(e)(t,n,r),Fe=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return De(e)(t,n,i)},Ie=e=>async(t,n,r)=>De(e)(t,n,r),Le=/^[cC][^\s-]{8,}$/,Re=/^[0-9a-z]+$/,ze=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Be=/^[0-9a-vA-V]{20}$/,Ve=/^[A-Za-z0-9]{27}$/,He=/^[a-zA-Z0-9_-]{21}$/,Ue=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,We=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ge=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ke=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Je(){return new RegExp(qe,`u`)}var Ye=/^(?:(?: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])$/,Xe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ze=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,et=/^[A-Za-z0-9_-]*$/,tt=/^\+[1-9]\d{6,14}$/,nt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,rt=RegExp(`^${nt}$`);function it(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function at(e){return RegExp(`^${it(e)}$`)}function ot(e){let t=it({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${nt}T(?:${r})$`)}var st=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ct=/^-?\d+$/,lt=/^-?\d+(?:\.\d+)?$/,ut=/^(?:true|false)$/i,dt=/^null$/i,ft=/^undefined$/i,pt=/^[^A-Z]*$/,mt=/^[^a-z]*$/,C=e(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ht={number:`number`,bigint:`bigint`,object:`date`},gt=e(`$ZodCheckLessThan`,(e,t)=>{C.init(e,t);let n=ht[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_t=e(`$ZodCheckGreaterThan`,(e,t)=>{C.init(e,t);let n=ht[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vt=e(`$ZodCheckMultipleOf`,(e,t)=>{C.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):u(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yt=e(`$ZodCheckNumberFormat`,(e,t)=>{C.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ce[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ct)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),bt=e(`$ZodCheckMaxLength`,(e,t)=>{var n;C.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=_e(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xt=e(`$ZodCheckMinLength`,(e,t)=>{var n;C.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=_e(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),St=e(`$ZodCheckLengthEquals`,(e,t)=>{var n;C.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=_e(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ct=e(`$ZodCheckStringFormat`,(e,t)=>{var n,r;C.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),wt=e(`$ZodCheckRegex`,(e,t)=>{Ct.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Tt=e(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=pt,Ct.init(e,t)}),Et=e(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=mt,Ct.init(e,t)}),Dt=e(`$ZodCheckIncludes`,(e,t)=>{C.init(e,t);let n=g(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ot=e(`$ZodCheckStartsWith`,(e,t)=>{C.init(e,t);let n=RegExp(`^${g(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),kt=e(`$ZodCheckEndsWith`,(e,t)=>{C.init(e,t);let n=RegExp(`.*${g(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),At=e(`$ZodCheckOverwrite`,(e,t)=>{C.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),jt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
31
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
32
|
+
`))}},Mt={major:4,minor:3,patch:6},w=e(`$ZodType`,(e,n)=>{var r;e??={},e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Mt;let i=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(e,n,r)=>{let i=y(e),a;for(let o of n){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;let n=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&r?.async===!1)throw new t;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==n&&(i||=y(e,n))});else{if(e.issues.length===n)continue;i||=y(e,n)}}return a?a.then(()=>e):e},r=(r,a,o)=>{if(y(r))return r.aborted=!0,r;let s=n(a,i,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,a,o)):r(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(e=>n(e,i,o))}return n(s,i,o)}}d(e,`~standard`,()=>({validate:t=>{try{let n=Ee(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Oe(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Nt=e(`$ZodString`,(e,t)=>{w.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??st(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),T=e(`$ZodStringFormat`,(e,t)=>{Ct.init(e,t),Nt.init(e,t)}),Pt=e(`$ZodGUID`,(e,t)=>{t.pattern??=We,T.init(e,t)}),Ft=e(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ge(e)}else t.pattern??=Ge();T.init(e,t)}),It=e(`$ZodEmail`,(e,t)=>{t.pattern??=Ke,T.init(e,t)}),Lt=e(`$ZodURL`,(e,t)=>{T.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Rt=e(`$ZodEmoji`,(e,t)=>{t.pattern??=Je(),T.init(e,t)}),zt=e(`$ZodNanoID`,(e,t)=>{t.pattern??=He,T.init(e,t)}),Bt=e(`$ZodCUID`,(e,t)=>{t.pattern??=Le,T.init(e,t)}),Vt=e(`$ZodCUID2`,(e,t)=>{t.pattern??=Re,T.init(e,t)}),Ht=e(`$ZodULID`,(e,t)=>{t.pattern??=ze,T.init(e,t)}),Ut=e(`$ZodXID`,(e,t)=>{t.pattern??=Be,T.init(e,t)}),Wt=e(`$ZodKSUID`,(e,t)=>{t.pattern??=Ve,T.init(e,t)}),Gt=e(`$ZodISODateTime`,(e,t)=>{t.pattern??=ot(t),T.init(e,t)}),Kt=e(`$ZodISODate`,(e,t)=>{t.pattern??=rt,T.init(e,t)}),qt=e(`$ZodISOTime`,(e,t)=>{t.pattern??=at(t),T.init(e,t)}),Jt=e(`$ZodISODuration`,(e,t)=>{t.pattern??=Ue,T.init(e,t)}),Yt=e(`$ZodIPv4`,(e,t)=>{t.pattern??=Ye,T.init(e,t),e._zod.bag.format=`ipv4`}),Xt=e(`$ZodIPv6`,(e,t)=>{t.pattern??=Xe,T.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Zt=e(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ze,T.init(e,t)}),Qt=e(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Qe,T.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function $t(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var en=e(`$ZodBase64`,(e,t)=>{t.pattern??=$e,T.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{$t(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function tn(e){if(!et.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return $t(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var nn=e(`$ZodBase64URL`,(e,t)=>{t.pattern??=et,T.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{tn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),rn=e(`$ZodE164`,(e,t)=>{t.pattern??=tt,T.init(e,t)});function an(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var on=e(`$ZodJWT`,(e,t)=>{T.init(e,t),e._zod.check=n=>{an(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),sn=e(`$ZodNumber`,(e,t)=>{w.init(e,t),e._zod.pattern=e._zod.bag.pattern??lt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),cn=e(`$ZodNumberFormat`,(e,t)=>{yt.init(e,t),sn.init(e,t)}),ln=e(`$ZodBoolean`,(e,t)=>{w.init(e,t),e._zod.pattern=ut,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),un=e(`$ZodUndefined`,(e,t)=>{w.init(e,t),e._zod.pattern=ft,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),dn=e(`$ZodNull`,(e,t)=>{w.init(e,t),e._zod.pattern=dt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),fn=e(`$ZodUnknown`,(e,t)=>{w.init(e,t),e._zod.parse=e=>e}),pn=e(`$ZodNever`,(e,t)=>{w.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function mn(e,t,n){e.issues.length&&t.issues.push(...b(n,e.issues)),t.value[n]=e.value}var hn=e(`$ZodArray`,(e,t)=>{w.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>mn(t,n,e))):mn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function gn(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...b(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function _n(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=se(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function vn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>gn(e,n,i,t,u))):gn(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var yn=e(`$ZodObject`,(e,t)=>{if(w.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=s(()=>_n(t));d(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=m,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>gn(n,t,e,s,r))):gn(i,t,e,s,r)}return i?vn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),bn=e(`$ZodObjectJIT`,(e,t)=>{yn.init(e,t);let n=e._zod.parse,i=s(()=>_n(t)),a=e=>{let t=new jt([`shape`,`payload`,`ctx`]),n=i.value,r=e=>{let t=te(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let i of n.keys){let n=a[i],o=te(i),s=e[i]?._zod?.optout===`optional`;t.write(`const ${n} = ${r(i)};`),s?t.write(`
|
|
33
|
+
if (${n}.issues.length) {
|
|
34
|
+
if (${o} in input) {
|
|
35
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
36
|
+
...iss,
|
|
37
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
38
|
+
})));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (${n}.value === undefined) {
|
|
43
|
+
if (${o} in input) {
|
|
44
|
+
newResult[${o}] = undefined;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
newResult[${o}] = ${n}.value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
`):t.write(`
|
|
51
|
+
if (${n}.issues.length) {
|
|
52
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
53
|
+
...iss,
|
|
54
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
55
|
+
})));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (${n}.value === undefined) {
|
|
59
|
+
if (${o} in input) {
|
|
60
|
+
newResult[${o}] = undefined;
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
newResult[${o}] = ${n}.value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,c=m,l=!r.jitless,u=l&&ie.value,ee=t.catchall,d;e._zod.parse=(r,s)=>{d??=i.value;let f=r.value;return c(f)?l&&u&&s?.async===!1&&s.jitless!==!0?(o||=a(t.shape),r=o(r,s),ee?vn([],f,r,s,d,e):r):n(r,s):(r.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),r)}});function xn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let a=e.filter(e=>!y(e));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>x(e,r,i())))}),t)}var Sn=e(`$ZodUnion`,(e,t)=>{w.init(e,t),d(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),d(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),d(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),d(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>l(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>xn(t,i,e,a)):xn(s,i,e,a)}}),Cn=e(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Sn.init(e,t);let n=e._zod.parse;d(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=s(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!m(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),wn=e(`$ZodIntersection`,(e,t)=>{w.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>En(e,t,n)):En(e,i,a)}});function Tn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(h(e)&&h(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Tn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Tn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function En(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),y(e))return e;let o=Tn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Dn=e(`$ZodRecord`,(e,t)=>{w.init(e,t),e._zod.parse=(n,r)=>{let a=n.value;if(!h(a))return n.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let i=new Set;for(let e of s)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){i.add(typeof e==`number`?e.toString():e);let s=t.valueType._zod.run({value:a[e],issues:[]},r);s instanceof Promise?o.push(s.then(t=>{t.issues.length&&n.issues.push(...b(e,t.issues)),n.value[e]=t.value})):(s.issues.length&&n.issues.push(...b(e,s.issues)),n.value[e]=s.value)}let c;for(let e in a)i.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c})}else{n.value={};for(let s of Reflect.ownKeys(a)){if(s===`__proto__`)continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&<.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=a[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>x(e,r,i())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:a[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...b(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...b(s,l.issues)),n.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),On=e(`$ZodEnum`,(e,t)=>{w.init(e,t);let n=a(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>oe.has(typeof e)).map(e=>typeof e==`string`?g(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),kn=e(`$ZodLiteral`,(e,t)=>{if(w.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?g(e):e?g(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),An=e(`$ZodTransform`,(e,r)=>{w.init(e,r),e._zod.parse=(i,a)=>{if(a.direction===`backward`)throw new n(e.constructor.name);let o=r.transform(i.value,i);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i));if(o instanceof Promise)throw new t;return i.value=o,i}});function jn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Mn=e(`$ZodOptional`,(e,t)=>{w.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),d(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>jn(t,e.value)):jn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Nn=e(`$ZodExactOptional`,(e,t)=>{Mn.init(e,t),d(e._zod,`values`,()=>t.innerType._zod.values),d(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Pn=e(`$ZodNullable`,(e,t)=>{w.init(e,t),d(e._zod,`optin`,()=>t.innerType._zod.optin),d(e._zod,`optout`,()=>t.innerType._zod.optout),d(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)}|null)$`):void 0}),d(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Fn=e(`$ZodDefault`,(e,t)=>{w.init(e,t),e._zod.optin=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>In(e,t)):In(r,t)}});function In(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ln=e(`$ZodPrefault`,(e,t)=>{w.init(e,t),e._zod.optin=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Rn=e(`$ZodNonOptional`,(e,t)=>{w.init(e,t),d(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>zn(t,e)):zn(i,e)}});function zn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Bn=e(`$ZodCatch`,(e,t)=>{w.init(e,t),d(e._zod,`optin`,()=>t.innerType._zod.optin),d(e._zod,`optout`,()=>t.innerType._zod.optout),d(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>x(e,n,i()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>x(e,n,i()))},input:e.value}),e.issues=[]),e)}}),Vn=e(`$ZodPipe`,(e,t)=>{w.init(e,t),d(e._zod,`values`,()=>t.in._zod.values),d(e._zod,`optin`,()=>t.in._zod.optin),d(e._zod,`optout`,()=>t.out._zod.optout),d(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Hn(e,t.in,n)):Hn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Hn(e,t.out,n)):Hn(r,t.out,n)}});function Hn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Un=e(`$ZodReadonly`,(e,t)=>{w.init(e,t),d(e._zod,`propValues`,()=>t.innerType._zod.propValues),d(e._zod,`values`,()=>t.innerType._zod.values),d(e._zod,`optin`,()=>t.innerType?._zod?.optin),d(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Wn):Wn(r)}});function Wn(e){return e.value=Object.freeze(e.value),e}var Gn=e(`$ZodCustom`,(e,t)=>{C.init(e,t),w.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Kn(t,n,r,e));Kn(i,n,r,e)}});function Kn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(S(e))}}var qn,Jn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Yn(){return new Jn}(qn=globalThis).__zod_globalRegistry??(qn.__zod_globalRegistry=Yn());var E=globalThis.__zod_globalRegistry;function Xn(e,t){return new e({type:`string`,...v(t)})}function Zn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...v(t)})}function Qn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...v(t)})}function $n(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...v(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...v(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...v(t)})}function nr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...v(t)})}function rr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...v(t)})}function ir(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...v(t)})}function ar(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...v(t)})}function or(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...v(t)})}function sr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...v(t)})}function cr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...v(t)})}function lr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...v(t)})}function ur(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...v(t)})}function dr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...v(t)})}function fr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...v(t)})}function pr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...v(t)})}function mr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...v(t)})}function hr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...v(t)})}function gr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...v(t)})}function _r(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...v(t)})}function vr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...v(t)})}function yr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...v(t)})}function br(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...v(t)})}function xr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...v(t)})}function Sr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...v(t)})}function Cr(e,t){return new e({type:`number`,checks:[],...v(t)})}function wr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...v(t)})}function Tr(e,t){return new e({type:`boolean`,...v(t)})}function Er(e,t){return new e({type:`undefined`,...v(t)})}function Dr(e,t){return new e({type:`null`,...v(t)})}function Or(e){return new e({type:`unknown`})}function kr(e,t){return new e({type:`never`,...v(t)})}function Ar(e,t){return new gt({check:`less_than`,...v(t),value:e,inclusive:!1})}function jr(e,t){return new gt({check:`less_than`,...v(t),value:e,inclusive:!0})}function Mr(e,t){return new _t({check:`greater_than`,...v(t),value:e,inclusive:!1})}function Nr(e,t){return new _t({check:`greater_than`,...v(t),value:e,inclusive:!0})}function Pr(e,t){return new vt({check:`multiple_of`,...v(t),value:e})}function Fr(e,t){return new bt({check:`max_length`,...v(t),maximum:e})}function Ir(e,t){return new xt({check:`min_length`,...v(t),minimum:e})}function Lr(e,t){return new St({check:`length_equals`,...v(t),length:e})}function Rr(e,t){return new wt({check:`string_format`,format:`regex`,...v(t),pattern:e})}function zr(e){return new Tt({check:`string_format`,format:`lowercase`,...v(e)})}function Br(e){return new Et({check:`string_format`,format:`uppercase`,...v(e)})}function Vr(e,t){return new Dt({check:`string_format`,format:`includes`,...v(t),includes:e})}function Hr(e,t){return new Ot({check:`string_format`,format:`starts_with`,...v(t),prefix:e})}function Ur(e,t){return new kt({check:`string_format`,format:`ends_with`,...v(t),suffix:e})}function D(e){return new At({check:`overwrite`,tx:e})}function Wr(e){return D(t=>t.normalize(e))}function Gr(){return D(e=>e.trim())}function Kr(){return D(e=>e.toLowerCase())}function qr(){return D(e=>e.toUpperCase())}function Jr(){return D(e=>ne(e))}function Yr(e,t,n){return new e({type:`array`,element:t,...v(n)})}function Xr(e,t,n){let r=v(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Zr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...v(n)})}function Qr(e){let t=$r(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(S(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(S(r))}},e(n.value,n)));return t}function $r(e,t){let n=new C({check:`custom`,...v(t)});return n._zod.check=e,n}function ei(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??E,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function O(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,O(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&k(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ti(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
67
|
+
|
|
68
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ni(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ii(t,`input`,e.processors),output:ii(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function k(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return k(r.element,n);if(r.type===`set`)return k(r.valueType,n);if(r.type===`lazy`)return k(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return k(r.innerType,n);if(r.type===`intersection`)return k(r.left,n)||k(r.right,n);if(r.type===`record`||r.type===`map`)return k(r.keyType,n)||k(r.valueType,n);if(r.type===`pipe`)return k(r.in,n)||k(r.out,n);if(r.type===`object`){for(let e in r.shape)if(k(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(k(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(k(e,n))return!0;return!!(r.rest&&k(r.rest,n))}return!1}var ri=(e,t={})=>n=>{let r=ei({...n,processors:t});return O(e,r),ti(r,e),ni(r,e)},ii=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ei({...i??{},target:a,io:t,processors:n});return O(e,o),ti(o,e),ni(o,e)},ai={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ai[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},si=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},ci=(e,t,n,r)=>{n.type=`boolean`},li=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ui=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},di=(e,t,n,r)=>{n.not={}},fi=(e,t,n,r)=>{let i=e._zod.def,o=a(i.entries);o.every(e=>typeof e==`number`)&&(n.type=`number`),o.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=o},pi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},mi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},hi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},gi=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=O(a.element,t,{...r,path:[...r.path,`items`]})},_i=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=O(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=O(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},vi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>O(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},yi=(e,t,n,r)=>{let i=e._zod.def,a=O(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=O(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},bi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=O(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=O(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=O(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},xi=(e,t,n,r)=>{let i=e._zod.def,a=O(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Si=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ci=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},wi=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ti=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Ei=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;O(a,t,r);let o=t.seen.get(e);o.ref=a},Di=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Oi=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ki=e(`ZodISODateTime`,(e,t)=>{Gt.init(e,t),N.init(e,t)});function Ai(e){return yr(ki,e)}var ji=e(`ZodISODate`,(e,t)=>{Kt.init(e,t),N.init(e,t)});function Mi(e){return br(ji,e)}var Ni=e(`ZodISOTime`,(e,t)=>{qt.init(e,t),N.init(e,t)});function Pi(e){return xr(Ni,e)}var Fi=e(`ZodISODuration`,(e,t)=>{Jt.init(e,t),N.init(e,t)});function Ii(e){return Sr(Fi,e)}var Li=(e,t)=>{ye.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Se(e,t)},flatten:{value:t=>xe(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,o,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,o,2)}},isEmpty:{get(){return e.issues.length===0}}})};e(`ZodError`,Li);var A=e(`ZodError`,Li,{Parent:Error}),Ri=Ce(A),zi=we(A),Bi=Te(A),Vi=De(A),Hi=ke(A),Ui=Ae(A),Wi=je(A),Gi=Me(A),Ki=Ne(A),qi=Pe(A),Ji=Fe(A),Yi=Ie(A),j=e(`ZodType`,(e,t)=>(w.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ii(e,`input`),output:ii(e,`output`)}}),e.toJSONSchema=ri(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(p(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>_(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Ri(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Bi(e,t,n),e.parseAsync=async(t,n)=>zi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Vi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Hi(e,t,n),e.decode=(t,n)=>Ui(e,t,n),e.encodeAsync=async(t,n)=>Wi(e,t,n),e.decodeAsync=async(t,n)=>Gi(e,t,n),e.safeEncode=(t,n)=>Ki(e,t,n),e.safeDecode=(t,n)=>qi(e,t,n),e.safeEncodeAsync=async(t,n)=>Ji(e,t,n),e.safeDecodeAsync=async(t,n)=>Yi(e,t,n),e.refine=(t,n)=>e.check(ao(t,n)),e.superRefine=t=>e.check(oo(t)),e.overwrite=t=>e.check(D(t)),e.optional=()=>W(e),e.exactOptional=()=>Ha(e),e.nullable=()=>Wa(e),e.nullish=()=>W(Wa(e)),e.nonoptional=t=>Xa(e,t),e.array=()=>L(e),e.or=t=>B([e,t]),e.and=t=>Pa(e,t),e.transform=t=>eo(e,za(t)),e.default=t=>Ka(e,t),e.prefault=t=>Ja(e,t),e.catch=t=>Qa(e,t),e.pipe=t=>eo(e,t),e.readonly=()=>no(e),e.describe=t=>{let n=e.clone();return E.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return E.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return E.get(e);let n=e.clone();return E.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Xi=e(`_ZodString`,(e,t)=>{Nt.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Rr(...t)),e.includes=(...t)=>e.check(Vr(...t)),e.startsWith=(...t)=>e.check(Hr(...t)),e.endsWith=(...t)=>e.check(Ur(...t)),e.min=(...t)=>e.check(Ir(...t)),e.max=(...t)=>e.check(Fr(...t)),e.length=(...t)=>e.check(Lr(...t)),e.nonempty=(...t)=>e.check(Ir(1,...t)),e.lowercase=t=>e.check(zr(t)),e.uppercase=t=>e.check(Br(t)),e.trim=()=>e.check(Gr()),e.normalize=(...t)=>e.check(Wr(...t)),e.toLowerCase=()=>e.check(Kr()),e.toUpperCase=()=>e.check(qr()),e.slugify=()=>e.check(Jr())}),Zi=e(`ZodString`,(e,t)=>{Nt.init(e,t),Xi.init(e,t),e.email=t=>e.check(Zn(Qi,t)),e.url=t=>e.check(rr(ta,t)),e.jwt=t=>e.check(vr(ga,t)),e.emoji=t=>e.check(ir(na,t)),e.guid=t=>e.check(Qn($i,t)),e.uuid=t=>e.check($n(ea,t)),e.uuidv4=t=>e.check(er(ea,t)),e.uuidv6=t=>e.check(tr(ea,t)),e.uuidv7=t=>e.check(nr(ea,t)),e.nanoid=t=>e.check(ar(ra,t)),e.guid=t=>e.check(Qn($i,t)),e.cuid=t=>e.check(or(ia,t)),e.cuid2=t=>e.check(sr(aa,t)),e.ulid=t=>e.check(cr(oa,t)),e.base64=t=>e.check(hr(pa,t)),e.base64url=t=>e.check(gr(ma,t)),e.xid=t=>e.check(lr(sa,t)),e.ksuid=t=>e.check(ur(ca,t)),e.ipv4=t=>e.check(dr(la,t)),e.ipv6=t=>e.check(fr(ua,t)),e.cidrv4=t=>e.check(pr(da,t)),e.cidrv6=t=>e.check(mr(fa,t)),e.e164=t=>e.check(_r(ha,t)),e.datetime=t=>e.check(Ai(t)),e.date=t=>e.check(Mi(t)),e.time=t=>e.check(Pi(t)),e.duration=t=>e.check(Ii(t))});function M(e){return Xn(Zi,e)}var N=e(`ZodStringFormat`,(e,t)=>{T.init(e,t),Xi.init(e,t)}),Qi=e(`ZodEmail`,(e,t)=>{It.init(e,t),N.init(e,t)}),$i=e(`ZodGUID`,(e,t)=>{Pt.init(e,t),N.init(e,t)}),ea=e(`ZodUUID`,(e,t)=>{Ft.init(e,t),N.init(e,t)}),ta=e(`ZodURL`,(e,t)=>{Lt.init(e,t),N.init(e,t)}),na=e(`ZodEmoji`,(e,t)=>{Rt.init(e,t),N.init(e,t)}),ra=e(`ZodNanoID`,(e,t)=>{zt.init(e,t),N.init(e,t)}),ia=e(`ZodCUID`,(e,t)=>{Bt.init(e,t),N.init(e,t)}),aa=e(`ZodCUID2`,(e,t)=>{Vt.init(e,t),N.init(e,t)}),oa=e(`ZodULID`,(e,t)=>{Ht.init(e,t),N.init(e,t)}),sa=e(`ZodXID`,(e,t)=>{Ut.init(e,t),N.init(e,t)}),ca=e(`ZodKSUID`,(e,t)=>{Wt.init(e,t),N.init(e,t)}),la=e(`ZodIPv4`,(e,t)=>{Yt.init(e,t),N.init(e,t)}),ua=e(`ZodIPv6`,(e,t)=>{Xt.init(e,t),N.init(e,t)}),da=e(`ZodCIDRv4`,(e,t)=>{Zt.init(e,t),N.init(e,t)}),fa=e(`ZodCIDRv6`,(e,t)=>{Qt.init(e,t),N.init(e,t)}),pa=e(`ZodBase64`,(e,t)=>{en.init(e,t),N.init(e,t)}),ma=e(`ZodBase64URL`,(e,t)=>{nn.init(e,t),N.init(e,t)}),ha=e(`ZodE164`,(e,t)=>{rn.init(e,t),N.init(e,t)}),ga=e(`ZodJWT`,(e,t)=>{on.init(e,t),N.init(e,t)}),_a=e(`ZodNumber`,(e,t)=>{sn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>si(e,t,n,r),e.gt=(t,n)=>e.check(Mr(t,n)),e.gte=(t,n)=>e.check(Nr(t,n)),e.min=(t,n)=>e.check(Nr(t,n)),e.lt=(t,n)=>e.check(Ar(t,n)),e.lte=(t,n)=>e.check(jr(t,n)),e.max=(t,n)=>e.check(jr(t,n)),e.int=t=>e.check(ya(t)),e.safe=t=>e.check(ya(t)),e.positive=t=>e.check(Mr(0,t)),e.nonnegative=t=>e.check(Nr(0,t)),e.negative=t=>e.check(Ar(0,t)),e.nonpositive=t=>e.check(jr(0,t)),e.multipleOf=(t,n)=>e.check(Pr(t,n)),e.step=(t,n)=>e.check(Pr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function P(e){return Cr(_a,e)}var va=e(`ZodNumberFormat`,(e,t)=>{cn.init(e,t),_a.init(e,t)});function ya(e){return wr(va,e)}var ba=e(`ZodBoolean`,(e,t)=>{ln.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ci(e,t,n,r)});function F(e){return Tr(ba,e)}var xa=e(`ZodUndefined`,(e,t)=>{un.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r)});function Sa(e){return Er(xa,e)}var Ca=e(`ZodNull`,(e,t)=>{dn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r)});function wa(e){return Dr(Ca,e)}var Ta=e(`ZodUnknown`,(e,t)=>{fn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I(){return Or(Ta)}var Ea=e(`ZodNever`,(e,t)=>{pn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r)});function Da(e){return kr(Ea,e)}var Oa=e(`ZodArray`,(e,t)=>{hn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Ir(t,n)),e.nonempty=t=>e.check(Ir(1,t)),e.max=(t,n)=>e.check(Fr(t,n)),e.length=(t,n)=>e.check(Lr(t,n)),e.unwrap=()=>e.element});function L(e,t){return Yr(Oa,e,t)}var ka=e(`ZodObject`,(e,t)=>{bn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r),d(e,`shape`,()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I()}),e.loose=()=>e.clone({...e._zod.def,catchall:I()}),e.strict=()=>e.clone({...e._zod.def,catchall:Da()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>de(e,t),e.safeExtend=t=>fe(e,t),e.merge=t=>pe(e,t),e.pick=t=>le(e,t),e.omit=t=>ue(e,t),e.partial=(...t)=>me(Ba,e,t[0]),e.required=(...t)=>he(Ya,e,t[0])});function R(e,t){return new ka({type:`object`,shape:e??{},...v(t)})}function z(e,t){return new ka({type:`object`,shape:e,catchall:I(),...v(t)})}var Aa=e(`ZodUnion`,(e,t)=>{Sn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),e.options=t.options});function B(e,t){return new Aa({type:`union`,options:e,...v(t)})}var ja=e(`ZodDiscriminatedUnion`,(e,t)=>{Aa.init(e,t),Cn.init(e,t)});function Ma(e,t,n){return new ja({type:`union`,options:t,discriminator:e,...v(n)})}var Na=e(`ZodIntersection`,(e,t)=>{wn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r)});function Pa(e,t){return new Na({type:`intersection`,left:e,right:t})}var Fa=e(`ZodRecord`,(e,t)=>{Dn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function V(e,t,n){return new Fa({type:`record`,keyType:e,valueType:t,...v(n)})}var Ia=e(`ZodEnum`,(e,t)=>{On.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ia({...t,checks:[],...v(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ia({...t,checks:[],...v(r),entries:i})}});function H(e,t){return new Ia({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...v(t)})}var La=e(`ZodLiteral`,(e,t)=>{kn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function U(e,t){return new La({type:`literal`,values:Array.isArray(e)?e:[e],...v(t)})}var Ra=e(`ZodTransform`,(e,t)=>{An.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r),e._zod.parse=(r,i)=>{if(i.direction===`backward`)throw new n(e.constructor.name);r.addIssue=n=>{if(typeof n==`string`)r.issues.push(S(n,r.value,t));else{let t=n;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=r.value,t.inst??=e,r.issues.push(S(t))}};let a=t.transform(r.value,r);return a instanceof Promise?a.then(e=>(r.value=e,r)):(r.value=a,r)}});function za(e){return new Ra({type:`transform`,transform:e})}var Ba=e(`ZodOptional`,(e,t)=>{Mn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function W(e){return new Ba({type:`optional`,innerType:e})}var Va=e(`ZodExactOptional`,(e,t)=>{Nn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ha(e){return new Va({type:`optional`,innerType:e})}var Ua=e(`ZodNullable`,(e,t)=>{Pn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wa(e){return new Ua({type:`nullable`,innerType:e})}var Ga=e(`ZodDefault`,(e,t)=>{Fn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ka(e,t){return new Ga({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ae(t)}})}var qa=e(`ZodPrefault`,(e,t)=>{Ln.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ja(e,t){return new qa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ae(t)}})}var Ya=e(`ZodNonOptional`,(e,t)=>{Rn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xa(e,t){return new Ya({type:`nonoptional`,innerType:e,...v(t)})}var Za=e(`ZodCatch`,(e,t)=>{Bn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qa(e,t){return new Za({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var $a=e(`ZodPipe`,(e,t)=>{Vn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.in=t.in,e.out=t.out});function eo(e,t){return new $a({type:`pipe`,in:e,out:t})}var to=e(`ZodReadonly`,(e,t)=>{Un.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function no(e){return new to({type:`readonly`,innerType:e})}var ro=e(`ZodCustom`,(e,t)=>{Gn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r)});function io(e,t){return Xr(ro,e??(()=>!0),t)}function ao(e,t={}){return Zr(ro,e,t)}function oo(e){return Qr(e)}function so(e,t){return eo(za(e),t)}var co=`io.modelcontextprotocol/related-task`,G=io(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),lo=B([M(),P().int()]),uo=M();z({ttl:P().optional(),pollInterval:P().optional()});var fo=R({ttl:P().optional()}),po=R({taskId:M()}),mo=z({progressToken:lo.optional(),[co]:po.optional()}),K=R({_meta:mo.optional()}),ho=K.extend({task:fo.optional()}),q=R({method:M(),params:K.loose().optional()}),J=R({_meta:mo.optional()}),Y=R({method:M(),params:J.loose().optional()}),X=z({_meta:mo.optional()}),go=B([M(),P().int()]),_o=R({jsonrpc:U(`2.0`),id:go,...q.shape}).strict(),vo=R({jsonrpc:U(`2.0`),...Y.shape}).strict(),yo=R({jsonrpc:U(`2.0`),id:go,result:X}).strict(),bo;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(bo||={});var xo=R({jsonrpc:U(`2.0`),id:go.optional(),error:R({code:P().int(),message:M(),data:I().optional()})}).strict();B([_o,vo,yo,xo]),B([yo,xo]);var So=X.strict(),Co=J.extend({requestId:go.optional(),reason:M().optional()}),wo=Y.extend({method:U(`notifications/cancelled`),params:Co}),To=R({icons:L(R({src:M(),mimeType:M().optional(),sizes:L(M()).optional(),theme:H([`light`,`dark`]).optional()})).optional()}),Z=R({name:M(),title:M().optional()}),Eo=Z.extend({...Z.shape,...To.shape,version:M(),websiteUrl:M().optional(),description:M().optional()}),Do=so(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Pa(R({form:Pa(R({applyDefaults:F().optional()}),V(M(),I())).optional(),url:G.optional()}),V(M(),I()).optional())),Oo=z({list:G.optional(),cancel:G.optional(),requests:z({sampling:z({createMessage:G.optional()}).optional(),elicitation:z({create:G.optional()}).optional()}).optional()}),ko=z({list:G.optional(),cancel:G.optional(),requests:z({tools:z({call:G.optional()}).optional()}).optional()}),Ao=R({experimental:V(M(),G).optional(),sampling:R({context:G.optional(),tools:G.optional()}).optional(),elicitation:Do.optional(),roots:R({listChanged:F().optional()}).optional(),tasks:Oo.optional(),extensions:V(M(),G).optional()}),jo=K.extend({protocolVersion:M(),capabilities:Ao,clientInfo:Eo}),Mo=q.extend({method:U(`initialize`),params:jo}),No=R({experimental:V(M(),G).optional(),logging:G.optional(),completions:G.optional(),prompts:R({listChanged:F().optional()}).optional(),resources:R({subscribe:F().optional(),listChanged:F().optional()}).optional(),tools:R({listChanged:F().optional()}).optional(),tasks:ko.optional(),extensions:V(M(),G).optional()}),Po=X.extend({protocolVersion:M(),capabilities:No,serverInfo:Eo,instructions:M().optional()}),Fo=Y.extend({method:U(`notifications/initialized`),params:J.optional()}),Io=q.extend({method:U(`ping`),params:K.optional()}),Lo=R({progress:P(),total:W(P()),message:W(M())}),Ro=R({...J.shape,...Lo.shape,progressToken:lo}),zo=Y.extend({method:U(`notifications/progress`),params:Ro}),Bo=K.extend({cursor:uo.optional()}),Vo=q.extend({params:Bo.optional()}),Ho=X.extend({nextCursor:uo.optional()}),Uo=H([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Wo=R({taskId:M(),status:Uo,ttl:B([P(),wa()]),createdAt:M(),lastUpdatedAt:M(),pollInterval:W(P()),statusMessage:W(M())}),Go=X.extend({task:Wo}),Ko=J.merge(Wo),qo=Y.extend({method:U(`notifications/tasks/status`),params:Ko}),Jo=q.extend({method:U(`tasks/get`),params:K.extend({taskId:M()})}),Yo=X.merge(Wo),Xo=q.extend({method:U(`tasks/result`),params:K.extend({taskId:M()})});X.loose();var Zo=Vo.extend({method:U(`tasks/list`)}),Qo=Ho.extend({tasks:L(Wo)}),$o=q.extend({method:U(`tasks/cancel`),params:K.extend({taskId:M()})});X.merge(Wo);var es=R({uri:M(),mimeType:W(M()),_meta:V(M(),I()).optional()}),ts=es.extend({text:M()}),ns=M().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),rs=es.extend({blob:ns}),is=H([`user`,`assistant`]),Q=R({audience:L(is).optional(),priority:P().min(0).max(1).optional(),lastModified:Ai({offset:!0}).optional()}),as=R({...Z.shape,...To.shape,uri:M(),description:W(M()),mimeType:W(M()),size:W(P()),annotations:Q.optional(),_meta:W(z({}))}),os=R({...Z.shape,...To.shape,uriTemplate:M(),description:W(M()),mimeType:W(M()),annotations:Q.optional(),_meta:W(z({}))}),ss=Vo.extend({method:U(`resources/list`)}),cs=Ho.extend({resources:L(as)}),ls=Vo.extend({method:U(`resources/templates/list`)}),us=Ho.extend({resourceTemplates:L(os)}),ds=K.extend({uri:M()}),fs=ds,ps=q.extend({method:U(`resources/read`),params:fs}),ms=X.extend({contents:L(B([ts,rs]))}),hs=Y.extend({method:U(`notifications/resources/list_changed`),params:J.optional()}),gs=ds,_s=q.extend({method:U(`resources/subscribe`),params:gs}),vs=ds,ys=q.extend({method:U(`resources/unsubscribe`),params:vs}),bs=J.extend({uri:M()}),xs=Y.extend({method:U(`notifications/resources/updated`),params:bs}),Ss=R({name:M(),description:W(M()),required:W(F())}),Cs=R({...Z.shape,...To.shape,description:W(M()),arguments:W(L(Ss)),_meta:W(z({}))}),ws=Vo.extend({method:U(`prompts/list`)}),Ts=Ho.extend({prompts:L(Cs)}),Es=K.extend({name:M(),arguments:V(M(),M()).optional()}),Ds=q.extend({method:U(`prompts/get`),params:Es}),Os=R({type:U(`text`),text:M(),annotations:Q.optional(),_meta:V(M(),I()).optional()}),ks=R({type:U(`image`),data:ns,mimeType:M(),annotations:Q.optional(),_meta:V(M(),I()).optional()}),As=R({type:U(`audio`),data:ns,mimeType:M(),annotations:Q.optional(),_meta:V(M(),I()).optional()}),js=R({type:U(`tool_use`),name:M(),id:M(),input:V(M(),I()),_meta:V(M(),I()).optional()}),Ms=R({type:U(`resource`),resource:B([ts,rs]),annotations:Q.optional(),_meta:V(M(),I()).optional()}),Ns=as.extend({type:U(`resource_link`)}),Ps=B([Os,ks,As,Ns,Ms]),Fs=R({role:is,content:Ps}),Is=X.extend({description:M().optional(),messages:L(Fs)}),Ls=Y.extend({method:U(`notifications/prompts/list_changed`),params:J.optional()}),Rs=R({title:M().optional(),readOnlyHint:F().optional(),destructiveHint:F().optional(),idempotentHint:F().optional(),openWorldHint:F().optional()}),zs=R({taskSupport:H([`required`,`optional`,`forbidden`]).optional()}),Bs=R({...Z.shape,...To.shape,description:M().optional(),inputSchema:R({type:U(`object`),properties:V(M(),G).optional(),required:L(M()).optional()}).catchall(I()),outputSchema:R({type:U(`object`),properties:V(M(),G).optional(),required:L(M()).optional()}).catchall(I()).optional(),annotations:Rs.optional(),execution:zs.optional(),_meta:V(M(),I()).optional()}),Vs=Vo.extend({method:U(`tools/list`)}),Hs=Ho.extend({tools:L(Bs)}),Us=X.extend({content:L(Ps).default([]),structuredContent:V(M(),I()).optional(),isError:F().optional()});Us.or(X.extend({toolResult:I()}));var Ws=ho.extend({name:M(),arguments:V(M(),I()).optional()}),Gs=q.extend({method:U(`tools/call`),params:Ws}),Ks=Y.extend({method:U(`notifications/tools/list_changed`),params:J.optional()});R({autoRefresh:F().default(!0),debounceMs:P().int().nonnegative().default(300)});var qs=H([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Js=K.extend({level:qs}),Ys=q.extend({method:U(`logging/setLevel`),params:Js}),Xs=J.extend({level:qs,logger:M().optional(),data:I()}),Zs=Y.extend({method:U(`notifications/message`),params:Xs}),Qs=R({hints:L(R({name:M().optional()})).optional(),costPriority:P().min(0).max(1).optional(),speedPriority:P().min(0).max(1).optional(),intelligencePriority:P().min(0).max(1).optional()}),$s=R({mode:H([`auto`,`required`,`none`]).optional()}),ec=R({type:U(`tool_result`),toolUseId:M().describe(`The unique identifier for the corresponding tool call.`),content:L(Ps).default([]),structuredContent:R({}).loose().optional(),isError:F().optional(),_meta:V(M(),I()).optional()}),tc=Ma(`type`,[Os,ks,As]),nc=Ma(`type`,[Os,ks,As,js,ec]),rc=R({role:is,content:B([nc,L(nc)]),_meta:V(M(),I()).optional()}),ic=ho.extend({messages:L(rc),modelPreferences:Qs.optional(),systemPrompt:M().optional(),includeContext:H([`none`,`thisServer`,`allServers`]).optional(),temperature:P().optional(),maxTokens:P().int(),stopSequences:L(M()).optional(),metadata:G.optional(),tools:L(Bs).optional(),toolChoice:$s.optional()}),ac=q.extend({method:U(`sampling/createMessage`),params:ic}),oc=X.extend({model:M(),stopReason:W(H([`endTurn`,`stopSequence`,`maxTokens`]).or(M())),role:is,content:tc}),sc=X.extend({model:M(),stopReason:W(H([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(M())),role:is,content:B([nc,L(nc)])}),cc=R({type:U(`boolean`),title:M().optional(),description:M().optional(),default:F().optional()}),lc=R({type:U(`string`),title:M().optional(),description:M().optional(),minLength:P().optional(),maxLength:P().optional(),format:H([`email`,`uri`,`date`,`date-time`]).optional(),default:M().optional()}),uc=R({type:H([`number`,`integer`]),title:M().optional(),description:M().optional(),minimum:P().optional(),maximum:P().optional(),default:P().optional()}),dc=R({type:U(`string`),title:M().optional(),description:M().optional(),enum:L(M()),default:M().optional()}),fc=R({type:U(`string`),title:M().optional(),description:M().optional(),oneOf:L(R({const:M(),title:M()})),default:M().optional()}),pc=B([B([R({type:U(`string`),title:M().optional(),description:M().optional(),enum:L(M()),enumNames:L(M()).optional(),default:M().optional()}),B([dc,fc]),B([R({type:U(`array`),title:M().optional(),description:M().optional(),minItems:P().optional(),maxItems:P().optional(),items:R({type:U(`string`),enum:L(M())}),default:L(M()).optional()}),R({type:U(`array`),title:M().optional(),description:M().optional(),minItems:P().optional(),maxItems:P().optional(),items:R({anyOf:L(R({const:M(),title:M()}))}),default:L(M()).optional()})])]),cc,lc,uc]),mc=B([ho.extend({mode:U(`form`).optional(),message:M(),requestedSchema:R({type:U(`object`),properties:V(M(),pc),required:L(M()).optional()})}),ho.extend({mode:U(`url`),message:M(),elicitationId:M(),url:M().url()})]),hc=q.extend({method:U(`elicitation/create`),params:mc}),gc=J.extend({elicitationId:M()}),_c=Y.extend({method:U(`notifications/elicitation/complete`),params:gc}),vc=X.extend({action:H([`accept`,`decline`,`cancel`]),content:so(e=>e===null?void 0:e,V(M(),B([M(),P(),F(),L(M())])).optional())}),yc=R({type:U(`ref/resource`),uri:M()}),bc=R({type:U(`ref/prompt`),name:M()}),xc=K.extend({ref:B([bc,yc]),argument:R({name:M(),value:M()}),context:R({arguments:V(M(),M()).optional()}).optional()}),Sc=q.extend({method:U(`completion/complete`),params:xc}),Cc=X.extend({completion:z({values:L(M()).max(100),total:W(P().int()),hasMore:W(F())})}),wc=R({uri:M().startsWith(`file://`),name:M().optional(),_meta:V(M(),I()).optional()}),Tc=q.extend({method:U(`roots/list`),params:K.optional()}),Ec=X.extend({roots:L(wc)}),Dc=Y.extend({method:U(`notifications/roots/list_changed`),params:J.optional()});B([Io,Mo,Sc,Ys,Ds,ws,ss,ls,ps,_s,ys,Gs,Vs,Jo,Xo,Zo,$o]),B([wo,zo,Fo,Dc,qo]),B([So,oc,sc,vc,Ec,Yo,Qo,Go]),B([Io,ac,hc,Tc,Jo,Xo,Zo,$o]),B([wo,zo,Zs,xs,hs,Ks,Ls,qo,_c]),B([So,Po,Cc,Is,Ts,cs,us,ms,Us,Hs,Yo,Qo,Go]);var Oc=`ui/notifications/sandbox-proxy-ready`,kc=`ui/notifications/sandbox-resource-ready`,Ac=B([U(`light`),U(`dark`)]).describe(`Color theme preference for the host environment.`),jc=B([U(`inline`),U(`fullscreen`),U(`pip`)]).describe(`Display mode for UI presentation.`),Mc=V(B([U(`--color-background-primary`),U(`--color-background-secondary`),U(`--color-background-tertiary`),U(`--color-background-inverse`),U(`--color-background-ghost`),U(`--color-background-info`),U(`--color-background-danger`),U(`--color-background-success`),U(`--color-background-warning`),U(`--color-background-disabled`),U(`--color-text-primary`),U(`--color-text-secondary`),U(`--color-text-tertiary`),U(`--color-text-inverse`),U(`--color-text-ghost`),U(`--color-text-info`),U(`--color-text-danger`),U(`--color-text-success`),U(`--color-text-warning`),U(`--color-text-disabled`),U(`--color-border-primary`),U(`--color-border-secondary`),U(`--color-border-tertiary`),U(`--color-border-inverse`),U(`--color-border-ghost`),U(`--color-border-info`),U(`--color-border-danger`),U(`--color-border-success`),U(`--color-border-warning`),U(`--color-border-disabled`),U(`--color-ring-primary`),U(`--color-ring-secondary`),U(`--color-ring-inverse`),U(`--color-ring-info`),U(`--color-ring-danger`),U(`--color-ring-success`),U(`--color-ring-warning`),U(`--font-sans`),U(`--font-mono`),U(`--font-weight-normal`),U(`--font-weight-medium`),U(`--font-weight-semibold`),U(`--font-weight-bold`),U(`--font-text-xs-size`),U(`--font-text-sm-size`),U(`--font-text-md-size`),U(`--font-text-lg-size`),U(`--font-heading-xs-size`),U(`--font-heading-sm-size`),U(`--font-heading-md-size`),U(`--font-heading-lg-size`),U(`--font-heading-xl-size`),U(`--font-heading-2xl-size`),U(`--font-heading-3xl-size`),U(`--font-text-xs-line-height`),U(`--font-text-sm-line-height`),U(`--font-text-md-line-height`),U(`--font-text-lg-line-height`),U(`--font-heading-xs-line-height`),U(`--font-heading-sm-line-height`),U(`--font-heading-md-line-height`),U(`--font-heading-lg-line-height`),U(`--font-heading-xl-line-height`),U(`--font-heading-2xl-line-height`),U(`--font-heading-3xl-line-height`),U(`--border-radius-xs`),U(`--border-radius-sm`),U(`--border-radius-md`),U(`--border-radius-lg`),U(`--border-radius-xl`),U(`--border-radius-full`),U(`--border-width-regular`),U(`--shadow-hairline`),U(`--shadow-sm`),U(`--shadow-md`),U(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
|
|
69
|
+
|
|
70
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
71
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
72
|
+
|
|
73
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
74
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),B([M(),Sa()]).describe(`Style variables for theming MCP apps.
|
|
75
|
+
|
|
76
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
77
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
78
|
+
|
|
79
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
80
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
|
|
81
|
+
|
|
82
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
83
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
84
|
+
|
|
85
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
86
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);R({method:U(`ui/open-link`),params:R({url:M().describe(`URL to open in the host's browser`)})}),R({isError:F().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),R({isError:F().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),R({isError:F().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),R({method:U(`ui/notifications/sandbox-proxy-ready`),params:R({})});var Nc=R({connectDomains:L(M()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
87
|
+
|
|
88
|
+
- Maps to CSP \`connect-src\` directive
|
|
89
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:L(M()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:L(M()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:L(M()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Pc=R({camera:R({}).optional().describe(`Request camera access.
|
|
90
|
+
|
|
91
|
+
Maps to Permission Policy \`camera\` feature.`),microphone:R({}).optional().describe(`Request microphone access.
|
|
92
|
+
|
|
93
|
+
Maps to Permission Policy \`microphone\` feature.`),geolocation:R({}).optional().describe(`Request geolocation access.
|
|
94
|
+
|
|
95
|
+
Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:R({}).optional().describe(`Request clipboard write access.
|
|
96
|
+
|
|
97
|
+
Maps to Permission Policy \`clipboard-write\` feature.`)});R({method:U(`ui/notifications/size-changed`),params:R({width:P().optional().describe(`New width in pixels.`),height:P().optional().describe(`New height in pixels.`)})}),R({method:U(`ui/notifications/tool-input`),params:R({arguments:V(M(),I().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),R({method:U(`ui/notifications/tool-input-partial`),params:R({arguments:V(M(),I().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),R({method:U(`ui/notifications/tool-cancelled`),params:R({reason:M().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var Fc=R({fonts:M().optional()}),Ic=R({variables:Mc.optional().describe(`CSS variables for theming the app.`),css:Fc.optional().describe(`CSS blocks that apps can inject.`)});R({method:U(`ui/resource-teardown`),params:R({})}),V(M(),I());var Lc=R({text:R({}).optional().describe(`Host supports text content blocks.`),image:R({}).optional().describe(`Host supports image content blocks.`),audio:R({}).optional().describe(`Host supports audio content blocks.`),resource:R({}).optional().describe(`Host supports resource content blocks.`),resourceLink:R({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:R({}).optional().describe(`Host supports structured content.`)});R({method:U(`ui/notifications/request-teardown`),params:R({}).optional()});var Rc=R({experimental:R({}).optional().describe(`Experimental features (structure TBD).`),openLinks:R({}).optional().describe(`Host supports opening external URLs.`),downloadFile:R({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:R({listChanged:F().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:R({listChanged:F().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:R({}).optional().describe(`Host accepts log messages.`),sandbox:R({permissions:Pc.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:Nc.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:Lc.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:Lc.optional().describe(`Host supports receiving content messages (ui/message) from the view.`)}),zc=R({experimental:R({}).optional().describe(`Experimental features (structure TBD).`),tools:R({listChanged:F().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:L(jc).optional().describe(`Display modes the app supports.`)});R({method:U(`ui/notifications/initialized`),params:R({}).optional()}),R({csp:Nc.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:Pc.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:M().optional().describe(`Dedicated origin for view sandbox.
|
|
98
|
+
|
|
99
|
+
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
100
|
+
|
|
101
|
+
**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
|
|
102
|
+
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
103
|
+
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
104
|
+
|
|
105
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:F().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
106
|
+
|
|
107
|
+
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
108
|
+
|
|
109
|
+
- \`true\`: request visible border + background
|
|
110
|
+
- \`false\`: request no visible border + background
|
|
111
|
+
- omitted: host decides border`)}),R({method:U(`ui/request-display-mode`),params:R({mode:jc.describe(`The display mode being requested.`)})}),R({mode:jc.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var Bc=B([U(`model`),U(`app`)]).describe(`Tool visibility scope - who can access the tool.`);R({resourceUri:M().optional(),visibility:L(Bc).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
112
|
+
- "model": Tool visible to and callable by the agent
|
|
113
|
+
- "app": Tool callable by the app from this server only`)}),R({mimeTypes:L(M()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),R({method:U(`ui/download-file`),params:R({contents:L(B([Ms,Ns])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),R({method:U(`ui/message`),params:R({role:U(`user`).describe(`Message role, currently only "user" is supported.`),content:L(Ps).describe(`Message content blocks (text, image, etc.).`)})});var Vc=R({method:U(`ui/notifications/sandbox-resource-ready`),params:R({html:M().describe(`HTML content to load into the inner iframe.`),sandbox:M().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:Nc.optional().describe(`CSP configuration from resource metadata.`),permissions:Pc.optional().describe(`Sandbox permissions from resource metadata.`)})});R({method:U(`ui/notifications/tool-result`),params:Us.describe(`Standard MCP tool execution result.`)});var Hc=R({toolInfo:R({id:go.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Bs.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Ac.optional().describe(`Current color theme preference.`),styles:Ic.optional().describe(`Style configuration for theming the app.`),displayMode:jc.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:L(jc).optional().describe(`Display modes the host supports.`),containerDimensions:B([R({height:P().describe(`Fixed container height in pixels.`)}),R({maxHeight:B([P(),Sa()]).optional().describe(`Maximum container height in pixels.`)})]).and(B([R({width:P().describe(`Fixed container width in pixels.`)}),R({maxWidth:B([P(),Sa()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
114
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:M().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:M().optional().describe(`User's timezone in IANA format.`),userAgent:M().optional().describe(`Host application identifier.`),platform:B([U(`web`),U(`desktop`),U(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:R({touch:F().optional().describe(`Whether the device supports touch input.`),hover:F().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:R({top:P().describe(`Top safe area inset in pixels.`),right:P().describe(`Right safe area inset in pixels.`),bottom:P().describe(`Bottom safe area inset in pixels.`),left:P().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();R({method:U(`ui/notifications/host-context-changed`),params:Hc.describe(`Partial context update containing only changed fields.`)}),R({method:U(`ui/update-model-context`),params:R({content:L(Ps).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:V(M(),I().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),R({method:U(`ui/initialize`),params:R({appInfo:Eo.describe(`App identification (name and version).`),appCapabilities:zc.describe(`Features and capabilities this app provides.`),protocolVersion:M().describe(`Protocol version this app supports.`)})}),R({protocolVersion:M().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Eo.describe(`Host application identification and version.`),hostCapabilities:Rc.describe(`Features and capabilities provided by the host.`),hostContext:Hc.describe(`Rich context about the host environment.`)}).passthrough();function Uc(e){if(!e)return``;let t=[];return e.camera&&t.push(`camera`),e.microphone&&t.push(`microphone`),e.geolocation&&t.push(`geolocation`),e.clipboardWrite&&t.push(`clipboard-write`),t.join(`; `)}var Wc=[`default-src 'none'`,`script-src 'self' 'unsafe-inline'`,`style-src 'self' 'unsafe-inline'`,`img-src 'self' data:`,`media-src 'self' data:`,`connect-src 'none'`].join(`; `);if(window.self===window.top)throw Error(`Sandbox must not be used outside the sandbox context.`);if(!document.referrer)throw Error(`Sandbox does not have a referrer. Referer must be set.`);var Gc=new URL(document.referrer).origin,Kc=new URL(window.location.href).origin;try{throw window.top.alert(`If you see this, the sandbox is not setup securely.`),`FAIL`}catch(e){if(e===`FAIL`)throw Error(`The sandbox is not setup securely.`)}var $=document.createElement(`iframe`);$.style=`width:100%; height:100%; border:none;`,$.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-forms`),document.body.appendChild($),window.addEventListener(`message`,async e=>{if(e.source===window.parent){if(e.origin!==Gc){console.error(`[@apollo/mcp-impostor-host - Sandbox]: Message rejected from unknown origin:`,e.origin);return}if(e.data?.method===`ui/notifications/sandbox-resource-ready`){let t=Vc.safeParse(e.data);if(!t.success){console.error(`[@apollo/mcp-impostor-host - Sandbox]: ${kc} notification is malformed. Received:`,e.data);return}let{html:n,csp:r,sandbox:i,permissions:a}=t.data.params;typeof i==`string`&&$.setAttribute(`sandbox`,i);let o=Uc(a);o&&$.setAttribute(`allow`,o),typeof n==`string`&&($.srcdoc=Yc(n,r))}else $?.contentWindow&&$.contentWindow.postMessage(e.data,`*`)}else if(e.source===$.contentWindow){if(e.origin!==Kc){console.error(`[@apollo/mcp-impostor-host - Sandbox] Message rejected from unknown origin:`,e.origin);return}e.data&&typeof e.data==`object`&&e.data.jsonrpc===`2.0`&&window.parent.postMessage(e.data,Gc)}}),window.parent.postMessage({jsonrpc:`2.0`,method:Oc,params:{}},Gc);function qc(e){if(!(!e||e.length===0))return e.map(e=>{if(typeof e==`string`)return e.replace(/['"<>;]/g,``).trim()}).filter(Boolean).join(` `)}function Jc(e){if(!e)return Wc;let t=qc(e?.resourceDomains),n=qc(e?.resourceDomains),r=qc(e?.frameDomains),i=qc(e?.baseUriDomains);return[`default-src 'none'`,`script-src 'self' 'unsafe-inline' ${t||``}`,`style-src 'self' 'unsafe-inline' ${t||``}`,`connect-src 'self' ${n||``}`,`img-src 'self' data: ${t||``}`,`font-src 'self' ${t||``}`,`media-src 'self' data: ${t||``}`,`frame-src ${r||`'none'`}`,`object-src 'none'`,`base-uri ${i||`'self'`}`].join(`; `)}function Yc(e,t){let n=`<meta http-equiv="Content-Security-Policy" content="${Jc(t)}">`;return e.includes(`<head>`)||e.includes(`<HEAD>`)?e.replace(/(<head>)/i,`$1`+n):e.includes(`<html>`)||e.includes(`<HTML>`)?e.replace(/(<html>)/i,`$1<head>`+n+`</head>`):e.includes(`<!DOCTYPE`)||e.includes(`<!doctype`)?e.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i,`$1<head>`+n+`</head>`):n+e}</script>
|
|
115
|
+
</head>
|
|
116
|
+
|
|
117
|
+
<body>
|
|
118
|
+
</body>
|
|
119
|
+
</html>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { serve } from "@hono/node-server";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
|
+
import { DEFAULT_CSP } from "../utilities/index.js";
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
function normalizeDomains(domains) {
|
|
9
|
+
if (!domains || domains.length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return domains.filter(Boolean).join(" ");
|
|
13
|
+
}
|
|
14
|
+
function buildCspHeader(csp) {
|
|
15
|
+
const resourceDomains = normalizeDomains(csp.resourceDomains);
|
|
16
|
+
const connectDomains = normalizeDomains(csp.connectDomains);
|
|
17
|
+
const frameDomains = normalizeDomains(csp.frameDomains);
|
|
18
|
+
const baseUriDomains = normalizeDomains(csp.baseUriDomains);
|
|
19
|
+
return [
|
|
20
|
+
"default-src 'none'",
|
|
21
|
+
`script-src 'self' 'unsafe-inline' ${resourceDomains || ""}`,
|
|
22
|
+
`style-src 'self' 'unsafe-inline' ${resourceDomains || ""}`,
|
|
23
|
+
`img-src 'self' data: ${resourceDomains || ""}`,
|
|
24
|
+
`font-src 'self' ${resourceDomains || ""}`,
|
|
25
|
+
`media-src 'self' data: ${resourceDomains || ""}`,
|
|
26
|
+
connectDomains ?
|
|
27
|
+
`connect-src 'self' ${connectDomains}`
|
|
28
|
+
: "connect-src 'none'",
|
|
29
|
+
`frame-src ${frameDomains || "'none'"}`,
|
|
30
|
+
"object-src 'none'",
|
|
31
|
+
`base-uri ${baseUriDomains || "'self'"}`,
|
|
32
|
+
]
|
|
33
|
+
.map((str) => str.trim())
|
|
34
|
+
.join("; ");
|
|
35
|
+
}
|
|
36
|
+
const args = process.argv.slice(2);
|
|
37
|
+
const enablePlaywright = args.includes("--playwright");
|
|
38
|
+
const port = parseInt(process.env["SANDBOX_PORT"] ?? "8080", 10);
|
|
39
|
+
const sandboxHtml = readFileSync(join(__dirname, "sandbox.html"), "utf-8");
|
|
40
|
+
// This server serves two roles on the same port, using different
|
|
41
|
+
// hostnames for cross-origin isolation (required by MCP Apps spec):
|
|
42
|
+
//
|
|
43
|
+
// 1. Sandbox proxy at http://127.0.0.1:{port}/sandbox.html
|
|
44
|
+
// Serves the sandbox iframe with CSP headers.
|
|
45
|
+
//
|
|
46
|
+
// 2. (opt-in via --playwright) Harness page at http://localhost:{port}/
|
|
47
|
+
// Loads the test harness React app with window.__mcpHost for
|
|
48
|
+
// Playwright automation.
|
|
49
|
+
const app = new Hono();
|
|
50
|
+
app.get("/sandbox.html", (c) => {
|
|
51
|
+
const cspParam = c.req.query("csp");
|
|
52
|
+
let cspHeader = DEFAULT_CSP;
|
|
53
|
+
if (cspParam) {
|
|
54
|
+
try {
|
|
55
|
+
const csp = JSON.parse(cspParam);
|
|
56
|
+
cspHeader = buildCspHeader(csp);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// ignore malformed CSP param
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
c.header("Content-Security-Policy", cspHeader);
|
|
63
|
+
return c.html(sandboxHtml);
|
|
64
|
+
});
|
|
65
|
+
if (enablePlaywright) {
|
|
66
|
+
const harnessHtml = readFileSync(join(__dirname, "..", "playwright", "harness", "harness.html"), "utf-8");
|
|
67
|
+
app.get("/", (c) => c.html(harnessHtml));
|
|
68
|
+
}
|
|
69
|
+
serve({ fetch: app.fetch, port }, () => {
|
|
70
|
+
const lines = [
|
|
71
|
+
`[@apollo/mcp-impostor-host] Sandbox server running on http://127.0.0.1:${port}`,
|
|
72
|
+
];
|
|
73
|
+
if (enablePlaywright) {
|
|
74
|
+
lines.push(`[@apollo/mcp-impostor-host] Playwright harness running on http://localhost:${port}`);
|
|
75
|
+
}
|
|
76
|
+
console.log(lines.join("\n"));
|
|
77
|
+
});
|