@halliday-sdk/payments 0.1.0-beta-1

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.
@@ -0,0 +1,313 @@
1
+ import { z } from 'zod/v4';
2
+ import { JsonRpcSigner } from 'ethers';
3
+ import { WalletClient } from 'viem';
4
+
5
+ declare const Address: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
6
+ type Address = z.infer<typeof Address>;
7
+ declare const TransactionRequest: z.ZodObject<{
8
+ to: z.ZodString;
9
+ from: z.ZodOptional<z.ZodString>;
10
+ nonce: z.ZodOptional<z.ZodNumber>;
11
+ gasLimit: z.ZodOptional<z.ZodBigInt>;
12
+ gasPrice: z.ZodOptional<z.ZodBigInt>;
13
+ maxPriorityFeePerGas: z.ZodOptional<z.ZodBigInt>;
14
+ maxFeePerGas: z.ZodOptional<z.ZodBigInt>;
15
+ data: z.ZodOptional<z.ZodString>;
16
+ value: z.ZodOptional<z.ZodBigInt>;
17
+ chainId: z.ZodNumber;
18
+ }, z.core.$strip>;
19
+ type TransactionRequest = z.infer<typeof TransactionRequest>;
20
+ declare const TransactionReceipt: z.ZodObject<{
21
+ transactionHash: z.ZodOptional<z.ZodString>;
22
+ blockHash: z.ZodOptional<z.ZodString>;
23
+ blockNumber: z.ZodOptional<z.ZodNumber>;
24
+ from: z.ZodOptional<z.ZodString>;
25
+ to: z.ZodOptional<z.ZodString>;
26
+ rawReceipt: z.ZodAny;
27
+ }, z.core.$strip>;
28
+ type TransactionReceipt = z.infer<typeof TransactionReceipt>;
29
+ declare const EVMChainConfig: z.ZodObject<{
30
+ chain_id: z.ZodNumber;
31
+ network: z.ZodString;
32
+ native_currency: z.ZodObject<{
33
+ name: z.ZodString;
34
+ symbol: z.ZodString;
35
+ decimals: z.ZodNumber;
36
+ }, z.core.$strip>;
37
+ rpc: z.ZodString;
38
+ image: z.ZodString;
39
+ is_testnet: z.ZodBoolean;
40
+ explorer: z.ZodString;
41
+ }, z.core.$strip>;
42
+ type EVMChainConfig = z.infer<typeof EVMChainConfig>;
43
+
44
+ declare const TypedData: z.ZodString;
45
+ type TypedData = z.infer<typeof TypedData>;
46
+
47
+ declare const WindowType: z.ZodEnum<{
48
+ EMBED: "EMBED";
49
+ POPUP: "POPUP";
50
+ }>;
51
+ type WindowType = z.infer<typeof WindowType>;
52
+ declare const CustomStyles: z.ZodObject<{
53
+ primaryColor: z.ZodOptional<z.ZodString>;
54
+ backgroundColor: z.ZodOptional<z.ZodString>;
55
+ borderColor: z.ZodOptional<z.ZodString>;
56
+ textColor: z.ZodOptional<z.ZodString>;
57
+ textSecondaryColor: z.ZodOptional<z.ZodString>;
58
+ logo: z.ZodOptional<z.ZodObject<{
59
+ src: z.ZodURL;
60
+ alt: z.ZodString;
61
+ width: z.ZodNumber;
62
+ height: z.ZodNumber;
63
+ }, z.core.$strip>>;
64
+ }, z.core.$strip>;
65
+ type CustomStyles = z.infer<typeof CustomStyles>;
66
+ declare const OrderStatus: z.ZodAny;
67
+ type OrderStatus = z.infer<typeof OrderStatus>;
68
+ type SignMessage = (input: {
69
+ message: string;
70
+ ownerAddress?: Address;
71
+ }) => Promise<string>;
72
+ type SignTypedData = (input: {
73
+ typedData: TypedData;
74
+ ownerAddress?: Address;
75
+ }) => Promise<string>;
76
+ type SendTransaction = (transaction: TransactionRequest, chainConfig: EVMChainConfig) => Promise<TransactionReceipt>;
77
+ type StatusCallback = (input: {
78
+ type: string;
79
+ payload: OrderStatus;
80
+ }) => void;
81
+ declare const PaymentsWidgetSDKParams: z.ZodObject<{
82
+ customStyles: z.ZodOptional<z.ZodObject<{
83
+ primaryColor: z.ZodOptional<z.ZodString>;
84
+ backgroundColor: z.ZodOptional<z.ZodString>;
85
+ borderColor: z.ZodOptional<z.ZodString>;
86
+ textColor: z.ZodOptional<z.ZodString>;
87
+ textSecondaryColor: z.ZodOptional<z.ZodString>;
88
+ logo: z.ZodOptional<z.ZodObject<{
89
+ src: z.ZodURL;
90
+ alt: z.ZodString;
91
+ width: z.ZodNumber;
92
+ height: z.ZodNumber;
93
+ }, z.core.$strip>>;
94
+ }, z.core.$strip>>;
95
+ targetElementId: z.ZodOptional<z.ZodString>;
96
+ windowType: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
97
+ EMBED: "EMBED";
98
+ POPUP: "POPUP";
99
+ }>>>;
100
+ signMessage: z.ZodOptional<z.ZodAny>;
101
+ sendTransaction: z.ZodOptional<z.ZodAny>;
102
+ statusCallback: z.ZodOptional<z.ZodAny>;
103
+ signTypedData: z.ZodOptional<z.ZodAny>;
104
+ onramps: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
105
+ offramps: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
106
+ sandbox: z.ZodDefault<z.ZodBoolean>;
107
+ inputs: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
108
+ outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
109
+ apiKey: z.ZodString;
110
+ destinationAddress: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
111
+ ownerAddress: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
112
+ }, z.core.$strip>;
113
+ type PaymentsWidgetSDKParams = z.infer<typeof PaymentsWidgetSDKParams> & {
114
+ signMessage?: SignMessage;
115
+ sendTransaction?: SendTransaction;
116
+ statusCallback?: StatusCallback;
117
+ };
118
+ declare const PaymentsWidgetQueryParams: z.ZodObject<{
119
+ apiBaseUrl: z.ZodOptional<z.ZodString>;
120
+ hasOwner: z.ZodBoolean;
121
+ hasTxHandler: z.ZodBoolean;
122
+ onramps: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
123
+ offramps: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
124
+ sandbox: z.ZodDefault<z.ZodBoolean>;
125
+ inputs: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>>;
126
+ outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
127
+ ownerAddress: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
128
+ apiKey: z.ZodString;
129
+ destinationAddress: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
130
+ customStyles: z.ZodOptional<z.ZodObject<{
131
+ primaryColor: z.ZodOptional<z.ZodString>;
132
+ backgroundColor: z.ZodOptional<z.ZodString>;
133
+ borderColor: z.ZodOptional<z.ZodString>;
134
+ textColor: z.ZodOptional<z.ZodString>;
135
+ textSecondaryColor: z.ZodOptional<z.ZodString>;
136
+ logo: z.ZodOptional<z.ZodObject<{
137
+ src: z.ZodURL;
138
+ alt: z.ZodString;
139
+ width: z.ZodNumber;
140
+ height: z.ZodNumber;
141
+ }, z.core.$strip>>;
142
+ }, z.core.$strip>>;
143
+ targetElementId: z.ZodOptional<z.ZodString>;
144
+ windowType: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
145
+ EMBED: "EMBED";
146
+ POPUP: "POPUP";
147
+ }>>>;
148
+ signTypedData: z.ZodOptional<z.ZodAny>;
149
+ }, z.core.$strip>;
150
+ type PaymentsWidgetQueryParams = z.infer<typeof PaymentsWidgetQueryParams>;
151
+ declare enum MessageType {
152
+ ACTION_TRANSACTION = "ACTION_TRANSACTION",
153
+ EVENT_ORDER_STATUS = "EVENT_ORDER_STATUS",
154
+ EVENT_WINDOW_CLOSE = "EVENT_WINDOW_CLOSE",
155
+ ACTION_SIGN_MESSAGE = "ACTION_SIGN_MESSAGE",
156
+ ACTION_PROVIDER_WIDGET = "ACTION_PROVIDER_WIDGET",
157
+ ACTION_SIGN_TYPED_DATA = "ACTION_SIGN_TYPED_DATA"
158
+ }
159
+ type Message = {
160
+ type: MessageType.ACTION_TRANSACTION;
161
+ payload: {
162
+ transaction: TransactionRequest;
163
+ messageId: string;
164
+ chainConfig: EVMChainConfig;
165
+ };
166
+ } | {
167
+ type: MessageType.EVENT_ORDER_STATUS;
168
+ payload: OrderStatus;
169
+ } | {
170
+ type: MessageType.EVENT_WINDOW_CLOSE;
171
+ payload: undefined;
172
+ } | {
173
+ type: MessageType.ACTION_SIGN_MESSAGE;
174
+ payload: {
175
+ message: string;
176
+ messageId: string;
177
+ ownerAddress?: Address;
178
+ };
179
+ } | {
180
+ type: MessageType.ACTION_PROVIDER_WIDGET;
181
+ payload: {
182
+ providerWidgetMode: "REDIRECT" | "POPUP";
183
+ redirectUrl: string;
184
+ url: string;
185
+ workflowId: string;
186
+ };
187
+ } | {
188
+ type: MessageType.ACTION_SIGN_TYPED_DATA;
189
+ payload: {
190
+ typedData: TypedData;
191
+ messageId: string;
192
+ ownerAddress?: Address;
193
+ };
194
+ };
195
+ type MessageResponse = {
196
+ type: MessageType.ACTION_TRANSACTION;
197
+ payload: {
198
+ messageId: string;
199
+ txReceipt: TransactionReceipt;
200
+ error: null;
201
+ } | {
202
+ messageId: string;
203
+ txReceipt: null;
204
+ error: string;
205
+ };
206
+ } | {
207
+ type: MessageType.ACTION_SIGN_MESSAGE;
208
+ payload: {
209
+ messageId: string;
210
+ signature: string;
211
+ error: null;
212
+ } | {
213
+ messageId: string;
214
+ signature: null;
215
+ error: string;
216
+ };
217
+ } | {
218
+ type: MessageType.ACTION_SIGN_TYPED_DATA;
219
+ payload: {
220
+ messageId: string;
221
+ signature: string;
222
+ error: null;
223
+ } | {
224
+ messageId: string;
225
+ signature: null;
226
+ error: string;
227
+ };
228
+ };
229
+
230
+ /**
231
+ * Opens the Halliday Payments widget.
232
+ *
233
+ * This function initializes and opens the payment widget window in a popup or embedded mode.
234
+ *
235
+ * @param {PaymentsWidgetSDKParams} params The configurations for the payments widget, which includes:
236
+ *
237
+ * @param {!string} params.apiKey {string} Your API key for authorization.
238
+ * @param {boolean=} params.sandbox {boolean} (optional) Whether the widget is in sandbox mode.
239
+ * @param {string=} params.ownerAddress {string} (optional) The address of the owner of the widget.
240
+ * @param {string=} params.destinationAddress {string} (optional) The address of the destination of the widget.
241
+ *
242
+ * @param {Asset[]=} params.inputs {{@link Asset}[]} (optional) The input assets for the widget.
243
+ * @param {Asset[]=} params.outputs {{@link Asset}[]} (optional) The output assets for the widget.
244
+ * @param {RampName[]=} params.onramps {{@link RampName}[]} (optional) The onramps for the widget.
245
+ * @param {RampName[]=} params.offramps {{@link RampName}[]} (optional) The offramps for the widget.
246
+ *
247
+ * @param {CustomStyles=} params.customStyles {{@link CustomStyles}} (optional) A list of custom styles to show in the widget.
248
+ * @param {string=} params.targetElementId {string} (required if windowType is "EMBED") The ID of the DOM element where the widget should be embedded.
249
+ * @param {("POPUP" | "EMBED")=} params.windowType {"POPUP" | "EMBED"} The desired display mode of the widget.
250
+ *
251
+ * @param {SendTransaction=} params.sendTransaction {{@link SendTransaction}} (optional) Function for sending transactions.
252
+ * @param {SignMessage=} params.signMessage {{@link SignMessage}} (optional) Function for signing messages.
253
+ * @param {SignTypedData=} params.signTypedData {{@link SignTypedData}} (optional) Function for signing typed data.
254
+ * @param {StatusCallback=} params.statusCallback {{@link StatusCallback}} (optional) Callback to receive status events.
255
+ */
256
+ declare function openHallidayPayments(params: PaymentsWidgetSDKParams, ...args: any[]): Promise<void>;
257
+
258
+ /**
259
+ * Serialize the query params to a base64 string.
260
+ *
261
+ * @param {PaymentsWidgetQueryParams} data {{@link PaymentsWidgetQueryParams}} The query params to serialize.
262
+ * @returns The serialized (base64) query params
263
+ */
264
+ declare const serializeQueryParams: (data: PaymentsWidgetQueryParams) => string;
265
+ /**
266
+ * Deserialize the query params from a base64 string.
267
+ *
268
+ * @param {string} serialized The base64 string to deserialize.
269
+ * @returns {{@link PaymentsWidgetQueryParams}} The deserialized query params.
270
+ */
271
+ declare const deserializeQueryParams: (serialized: string) => PaymentsWidgetQueryParams;
272
+ /**
273
+ * Get the URL for the payments widget.
274
+ *
275
+ * @param {PaymentsWidgetQueryParams & { windowOrigin?: string }} params {{@link PaymentsWidgetQueryParams}} The query params to serialize.
276
+ * @returns The URL for the payments widget.
277
+ */
278
+ declare const getPaymentsWidgetUrl: (params: PaymentsWidgetQueryParams & {
279
+ windowOrigin?: string;
280
+ }) => string;
281
+
282
+ /**
283
+ * Connect to a signer.
284
+ *
285
+ * @param {function} getSigner {function} The function to get the signer.
286
+ * @returns {function} ``getAddress`` {function} Function that returns the address of the signer.
287
+ * @returns {function} ``signMessage`` {{@link SignMessage}} Function that signs a message.
288
+ * @returns {function} ``sendTransaction`` {{@link SendTransaction}} Function that sends an EVM transaction.
289
+ */
290
+ declare const connectSigner: (getSigner: (address?: Address) => Promise<JsonRpcSigner>) => {
291
+ getAddress: () => Promise<Address>;
292
+ signMessage: SignMessage;
293
+ sendTransaction: SendTransaction;
294
+ signTypedData: SignTypedData;
295
+ };
296
+
297
+ /**
298
+ * Connect to a wallet.
299
+ *
300
+ * @param {WalletClient} wallet {{@link WalletClient}} The viem wallet client.
301
+ * @returns {function} ``getAddress`` {function} Function that returns the address of the wallet.
302
+ * @returns {function} ``signMessage`` {{@link SignMessage}} Function that signs a message.
303
+ * @returns {function} ``sendTransaction`` {{@link SendTransaction}} Function that sends an EVM transaction.
304
+ */
305
+ declare const connectWallet: (wallet: WalletClient) => {
306
+ getAddress: () => Promise<Address[]>;
307
+ signMessage: SignMessage;
308
+ sendTransaction: SendTransaction;
309
+ signTypedData: SignTypedData;
310
+ };
311
+
312
+ export { CustomStyles, MessageType, OrderStatus, PaymentsWidgetQueryParams, PaymentsWidgetSDKParams, WindowType, connectSigner, connectWallet, deserializeQueryParams, getPaymentsWidgetUrl, openHallidayPayments, serializeQueryParams };
313
+ export type { Message, MessageResponse };
@@ -0,0 +1,2 @@
1
+ import{verifyMessage as e,toBeArray as t}from"ethers";import{createPublicClient as n,http as i}from"viem";const o="https://app.halliday.xyz",r=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;function s(e,t,n){function i(n,i){var o;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(o=n._zod).traits??(o.traits=new Set),n._zod.traits.add(e),t(n,i);for(const e in s.prototype)Object.defineProperty(n,e,{value:s.prototype[e].bind(n)});n._zod.constr=s,n._zod.def=i}const o=n?.Parent??Object;class r extends o{}function s(e){var t;const o=n?.Parent?new r:this;i(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const u={};function c(e){return u}function d(e,t){return"bigint"==typeof t?t.toString():t}function l(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function p(e){return null==e}function f(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function h(e,t,n){Object.defineProperty(e,t,{get(){{const i=n();return e[t]=i,i}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function m(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let i=0;i<e;i++)n+=t[Math.floor(26*Math.random())];return n}function g(e){return JSON.stringify(e)}function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const y=l((()=>{try{return new Function(""),!0}catch(e){return!1}}));function w(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}const z=new Set(["string","number","symbol"]);function k(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}function E(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const I={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function $(e,t=0){for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n].continue)return!0;return!1}function T(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function x(e){return"string"==typeof e?e:e?.message}function A(e,t,n){const i={...e,path:e.path??[]};if(!e.message){const o=x(e.inst?._zod.def?.error?.(e))??x(t?.error?.(e))??x(n.customError?.(e))??x(n.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Z(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function N(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}const O=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,d,2),enumerable:!0})},P=s("$ZodError",O),S=s("$ZodError",O,{Parent:Error});const D=e=>(t,n,i,o)=>{const r=i?Object.assign(i,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new a;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>A(e,r,c()))));throw Error.captureStackTrace(t,o?.callee),t}return s.value},C=e=>async(t,n,i,o)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>A(e,r,c()))));throw Error.captureStackTrace(t,o?.callee),t}return s.value},R=e=>(t,n,i)=>{const o=i?{...i,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new a;return r.issues.length?{success:!1,error:new(e??P)(r.issues.map((e=>A(e,o,c()))))}:{success:!0,data:r.value}},M=R(S),F=e=>async(t,n,i)=>{const o=i?Object.assign(i,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map((e=>A(e,o,c()))))}:{success:!0,data:r.value}},j=F(S),U=/^[cC][^\s-]{8,}$/,L=/^[0-9a-z]+$/,V=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,W=/^[0-9a-vA-V]{20}$/,B=/^[A-Za-z0-9]{27}$/,G=/^[a-zA-Z0-9_-]{21}$/,H=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,q=/^([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})$/,K=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Y=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const J=/^(?:(?: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])$/,X=/^(([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})$/,Q=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ee=/^(([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])$/,te=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ne=/^[A-Za-z0-9_-]*$/,ie=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,oe=/^\+(?:[0-9]){6,14}[0-9]$/,re="((\\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])))",se=new RegExp(`^${re}$`);function ae(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}const ue=/^\d+n?$/,ce=/^\d+$/,de=/^-?\d+(?:\.\d+)?/i,le=/true|false/i,pe=/null/i,fe=/^[^A-Z]*$/,he=/^[^a-z]*$/,me=s("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),_e={number:"number",bigint:"bigint",object:"date"},ge=s("$ZodCheckLessThan",((e,t)=>{me.init(e,t);const n=_e[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)})),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),ve=s("$ZodCheckGreaterThan",((e,t)=>{me.init(e,t);const n=_e[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),ye=s("$ZodCheckMultipleOf",((e,t)=>{me.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 new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,o=n>i?n:i;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),we=s("$ZodCheckNumberFormat",((e,t)=>{me.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),i=n?"int":"number",[o,r]=I[t.format];e._zod.onattach.push((e=>{const i=e._zod.bag;i.format=t.format,i.minimum=o,i.maximum=r,n&&(i.pattern=ce)})),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:i,format:t.format,code:"invalid_type",input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,continue:!t.abort}))}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>r&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:r,inst:e})}})),ze=s("$ZodCheckMaxLength",((e,t)=>{me.init(e,t),e._zod.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const o=Z(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,input:i,inst:e,continue:!t.abort})}})),ke=s("$ZodCheckMinLength",((e,t)=>{me.init(e,t),e._zod.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const o=Z(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,input:i,inst:e,continue:!t.abort})}})),be=s("$ZodCheckLengthEquals",((e,t)=>{me.init(e,t),e._zod.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length})),e._zod.check=n=>{const i=n.value,o=i.length;if(o===t.length)return;const r=Z(i),s=o>t.length;n.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},input:n.value,inst:e,continue:!t.abort})}})),Ee=s("$ZodCheckStringFormat",((e,t)=>{var n;me.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),(n=e._zod).check??(n.check=n=>{if(!t.pattern)throw new Error("Not implemented.");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})})})),Ie=s("$ZodCheckRegex",((e,t)=>{Ee.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})}})),$e=s("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=fe),Ee.init(e,t)})),Te=s("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=he),Ee.init(e,t)})),xe=s("$ZodCheckIncludes",((e,t)=>{me.init(e,t);const n=k(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)})),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})}})),Ae=s("$ZodCheckStartsWith",((e,t)=>{me.init(e,t);const n=new RegExp(`^${k(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(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})}})),Ze=s("$ZodCheckEndsWith",((e,t)=>{me.init(e,t);const n=new RegExp(`.*${k(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(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})}})),Ne=s("$ZodCheckOverwrite",((e,t)=>{me.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class Oe{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),i=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const e of i)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>` ${e}`))].join("\n"))}}const Pe={major:4,minor:0,patch:0},Se=s("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.id=t.type+"_"+_(10),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pe;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const t of i)for(const n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let i,o=$(e);for(const r of t){if(r._zod.when){if(!r._zod.when(e))continue}else if(o)continue;const t=e.issues.length,s=r._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new a;if(i||s instanceof Promise)i=(i??Promise.resolve()).then((async()=>{await s;e.issues.length!==t&&(o||(o=$(e,t)))}));else{if(e.issues.length===t)continue;o||(o=$(e,t))}}return i?i.then((()=>e)):e};e._zod.run=(n,o)=>{const r=e._zod.parse(n,o);if(r instanceof Promise){if(!1===o.async)throw new a;return r.then((e=>t(e,i,o)))}return t(r,i,o)}}e["~standard"]={validate:t=>{try{const n=M(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return j(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),De=s("$ZodString",((e,t)=>{var n;Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),Ce=s("$ZodStringFormat",((e,t)=>{Ee.init(e,t),De.init(e,t)})),Re=s("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=q),Ce.init(e,t)})),Me=s("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=K(e))}else t.pattern??(t.pattern=K());Ce.init(e,t)})),Fe=s("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=Y),Ce.init(e,t)})),je=s("$ZodURL",((e,t)=>{Ce.init(e,t),e._zod.check=n=>{try{const i=new URL(n.value);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:ie.source,input:n.value,inst:e})),void(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})))}catch(t){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e})}}})),Ue=s("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ce.init(e,t)})),Le=s("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=G),Ce.init(e,t)})),Ve=s("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=U),Ce.init(e,t)})),We=s("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=L),Ce.init(e,t)})),Be=s("$ZodULID",((e,t)=>{t.pattern??(t.pattern=V),Ce.init(e,t)})),Ge=s("$ZodXID",((e,t)=>{t.pattern??(t.pattern=W),Ce.init(e,t)})),He=s("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=B),Ce.init(e,t)})),qe=s("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){let t=`${re}T${ae(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}(t)),Ce.init(e,t)})),Ke=s("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=se),Ce.init(e,t)})),Ye=s("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${ae(t)}$`)),Ce.init(e,t)})),Je=s("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=H),Ce.init(e,t)})),Xe=s("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=J),Ce.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.format="ipv4"}))})),Qe=s("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=X),Ce.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.format="ipv6"})),e._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e})}}})),et=s("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=Q),Ce.init(e,t)})),tt=s("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=ee),Ce.init(e,t),e._zod.check=t=>{const[n,i]=t.value.split("/");try{if(!i)throw new Error;const e=Number(i);if(`${e}`!==i)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e})}}}));function nt(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const it=s("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=te),Ce.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.contentEncoding="base64"})),e._zod.check=t=>{nt(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e})}}));const ot=s("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=ne),Ce.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.contentEncoding="base64url"})),e._zod.check=t=>{(function(e){if(!ne.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return nt(t.padEnd(4*Math.ceil(t.length/4),"="))})(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e})}})),rt=s("$ZodE164",((e,t)=>{t.pattern??(t.pattern=oe),Ce.init(e,t)}));const st=s("$ZodJWT",((e,t)=>{Ce.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n,o=JSON.parse(atob(i));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e})}})),at=s("$ZodNumber",((e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??de,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const r="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...r?{received:r}:{}}),n}})),ut=s("$ZodNumber",((e,t)=>{we.init(e,t),at.init(e,t)})),ct=s("$ZodBoolean",((e,t)=>{Se.init(e,t),e._zod.pattern=le,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}})),dt=s("$ZodBigInt",((e,t)=>{Se.init(e,t),e._zod.pattern=ue,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}const{value:o}=n;return"bigint"==typeof o||n.issues.push({expected:"bigint",code:"invalid_type",input:o,inst:e}),n}})),lt=s("$ZodNull",((e,t)=>{Se.init(e,t),e._zod.pattern=pe,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const{value:i}=t;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}})),pt=s("$ZodAny",((e,t)=>{Se.init(e,t),e._zod.parse=e=>e})),ft=s("$ZodUnknown",((e,t)=>{Se.init(e,t),e._zod.parse=e=>e})),ht=s("$ZodNever",((e,t)=>{Se.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function mt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}const _t=s("$ZodArray",((e,t)=>{Se.init(e,t),e._zod.parse=(n,i)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const r=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},i);a instanceof Promise?r.push(a.then((t=>mt(t,n,e)))):mt(a,n,e)}return r.length?Promise.all(r).then((()=>n)):n}}));function gt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}function vt(e,t,n,i){e.issues.length?void 0===i[n]?t.value[n]=n in i?void 0:e.value:t.issues.push(...T(n,e.issues)):void 0===e.value?n in i&&(t.value[n]=void 0):t.value[n]=e.value}const yt=s("$ZodObject",((e,t)=>{Se.init(e,t);const n=l((()=>{const e=Object.keys(t.shape);for(const n of e)if(!(t.shape[n]instanceof Se))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(i=t.shape,Object.keys(i).filter((e=>"optional"===i[e]._zod.optin&&"optional"===i[e]._zod.optout)));var i;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}));h(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const i=e[t]._zod;if(i.values){n[t]??(n[t]=new Set);for(const e of i.values)n[t].add(e)}}return n}));let i;const o=v,r=!u.jitless,s=r&&y.value,{catchall:a}=t;let c;e._zod.parse=(u,d)=>{c??(c=n.value);const l=u.value;if(!o(l))return u.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),u;const p=[];if(r&&s&&!1===d?.async&&!0!==d.jitless)i||(i=(e=>{const t=new Oe(["shape","payload","ctx"]),{keys:i,optionalKeys:o}=n.value,r=e=>{const t=g(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);for(const e of i)s[e]=_(15);t.write("const newResult = {}");for(const e of i)if(o.has(e)){const n=s[e];t.write(`const ${n} = ${r(e)};`);const i=g(e);t.write(`\n if (${n}.issues.length) {\n if (input[${i}] === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${n}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}],\n }))\n );\n }\n } else if (${n}.value === undefined) {\n if (${i} in input) newResult[${i}] = undefined;\n } else {\n newResult[${i}] = ${n}.value;\n }\n `)}else{const n=s[e];t.write(`const ${n} = ${r(e)};`),t.write(`\n if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${g(e)}, ...iss.path] : [${g(e)}]\n })));`),t.write(`newResult[${g(e)}] = ${n}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),u=i(u,d);else{u.value={};const e=c.shape;for(const t of c.keys){const n=e[t],i=n._zod.run({value:l[t],issues:[]},d),o="optional"===n._zod.optin&&"optional"===n._zod.optout;i instanceof Promise?p.push(i.then((e=>o?vt(e,u,t,l):gt(e,u,t)))):o?vt(i,u,t,l):gt(i,u,t)}}if(!a)return p.length?Promise.all(p).then((()=>u)):u;const f=[],h=c.keySet,m=a._zod,v=m.def.type;for(const e of Object.keys(l)){if(h.has(e))continue;if("never"===v){f.push(e);continue}const t=m.run({value:l[e],issues:[]},d);t instanceof Promise?p.push(t.then((t=>gt(t,u,e)))):gt(t,u,e)}return f.length&&u.issues.push({code:"unrecognized_keys",keys:f,input:l,inst:e}),p.length?Promise.all(p).then((()=>u)):u}}));function wt(e,t,n,i){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>A(e,i,c())))))}),t}const zt=s("$ZodUnion",((e,t)=>{Se.init(e,t),h(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),h(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>f(e.source))).join("|")})$`)}})),e._zod.parse=(n,i)=>{let o=!1;const r=[];for(const e of t.options){const t=e._zod.run({value:n.value,issues:[]},i);if(t instanceof Promise)r.push(t),o=!0;else{if(0===t.issues.length)return t;r.push(t)}}return o?Promise.all(r).then((t=>wt(t,n,e,i))):wt(r,n,e,i)}})),kt=s("$ZodDiscriminatedUnion",((e,t)=>{zt.init(e,t);const n=e._zod.parse;h(e._zod,"propValues",(()=>{const e={};for(const n of t.options){const i=n._zod.propValues;if(!i||0===Object.keys(i).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(i)){e[t]||(e[t]=new Set);for(const i of n)e[t].add(i)}}return e}));const i=l((()=>{const e=t.options,n=new Map;for(const i of e){const e=i._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,i)}}return n}));e._zod.parse=(o,r)=>{const s=o.value;if(!v(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=i.value.get(s?.[t.discriminator]);return a?a._zod.run(o,r):t.unionFallback?n(o,r):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),o)}})),bt=s("$ZodIntersection",((e,t)=>{Se.init(e,t),e._zod.parse=(e,n)=>{const{value:i}=e,o=t.left._zod.run({value:i,issues:[]},n),r=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then((([t,n])=>It(e,t,n))):It(e,o,r)}}));function Et(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(w(e)&&w(t)){const n=Object.keys(t),i=Object.keys(e).filter((e=>-1!==n.indexOf(e))),o={...e,...t};for(const n of i){const i=Et(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};o[n]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const o=Et(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function It(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),$(e))return e;const i=Et(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const $t=s("$ZodTuple",((e,t)=>{Se.init(e,t);const n=t.items,i=n.length-[...n].reverse().findIndex((e=>"optional"!==e._zod.optin));e._zod.parse=(o,r)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const a=[];if(!t.rest){const t=s.length>n.length,r=s.length<i-1;if(t||r)return o.issues.push({input:s,inst:e,origin:"array",...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length}}),o}let u=-1;for(const e of n){if(u++,u>=s.length&&u>=i)continue;const t=e._zod.run({value:s[u],issues:[]},r);t instanceof Promise?a.push(t.then((e=>Tt(e,o,u)))):Tt(t,o,u)}if(t.rest){const e=s.slice(n.length);for(const n of e){u++;const e=t.rest._zod.run({value:n,issues:[]},r);e instanceof Promise?a.push(e.then((e=>Tt(e,o,u)))):Tt(e,o,u)}}return a.length?Promise.all(a).then((()=>o)):o}}));function Tt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}const xt=s("$ZodRecord",((e,t)=>{Se.init(e,t),e._zod.parse=(n,i)=>{const o=n.value;if(!w(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const r=[];if(t.keyType._zod.values){const s=t.keyType._zod.values;n.value={};for(const e of s)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const s=t.valueType._zod.run({value:o[e],issues:[]},i);s instanceof Promise?r.push(s.then((t=>{t.issues.length&&n.issues.push(...T(e,t.issues)),n.value[e]=t.value}))):(s.issues.length&&n.issues.push(...T(e,s.issues)),n.value[e]=s.value)}let a;for(const e in o)s.has(e)||(a=a??[],a.push(e));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;const a=t.keyType._zod.run({value:s,issues:[]},i);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map((e=>A(e,i,c()))),input:s,path:[s],inst:e}),n.value[a.value]=a.value;continue}const u=t.valueType._zod.run({value:o[s],issues:[]},i);u instanceof Promise?r.push(u.then((e=>{e.issues.length&&n.issues.push(...T(s,e.issues)),n.value[a.value]=e.value}))):(u.issues.length&&n.issues.push(...T(s,u.issues)),n.value[a.value]=u.value)}}return r.length?Promise.all(r).then((()=>n)):n}})),At=s("$ZodEnum",((e,t)=>{Se.init(e,t);const n=function(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter((e=>z.has(typeof e))).map((e=>"string"==typeof e?k(e):e.toString())).join("|")})$`),e._zod.parse=(t,i)=>{const o=t.value;return e._zod.values.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}})),Zt=s("$ZodLiteral",((e,t)=>{Se.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?k(e):e?e.toString():String(e))).join("|")})$`),e._zod.parse=(n,i)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}})),Nt=s("$ZodTransform",((e,t)=>{Se.init(e,t),e._zod.parse=(e,n)=>{const i=t.transform(e.value,e);if(n.async){return(i instanceof Promise?i:Promise.resolve(i)).then((t=>(e.value=t,e)))}if(i instanceof Promise)throw new a;return e.value=i,e}})),Ot=s("$ZodOptional",((e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",h(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),h(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${f(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>void 0===e.value?e:t.innerType._zod.run(e,n)})),Pt=s("$ZodNullable",((e,t)=>{Se.init(e,t),h(e._zod,"optin",(()=>t.innerType._zod.optin)),h(e._zod,"optout",(()=>t.innerType._zod.optout)),h(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${f(e.source)}|null)$`):void 0})),h(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),St=s("$ZodDefault",((e,t)=>{Se.init(e,t),e._zod.optin="optional",h(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then((e=>Dt(e,t))):Dt(i,t)}}));function Dt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Ct=s("$ZodPrefault",((e,t)=>{Se.init(e,t),e._zod.optin="optional",h(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),Rt=s("$ZodNonOptional",((e,t)=>{Se.init(e,t),h(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,i)=>{const o=t.innerType._zod.run(n,i);return o instanceof Promise?o.then((t=>Mt(t,e))):Mt(o,e)}}));function Mt(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ft=s("$ZodCatch",((e,t)=>{Se.init(e,t),h(e._zod,"optin",(()=>t.innerType._zod.optin)),h(e._zod,"optout",(()=>t.innerType._zod.optout)),h(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then((i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map((e=>A(e,n,c())))},input:e.value}),e.issues=[]),e))):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map((e=>A(e,n,c())))},input:e.value}),e.issues=[]),e)}})),jt=s("$ZodPipe",((e,t)=>{Se.init(e,t),h(e._zod,"values",(()=>t.in._zod.values)),h(e._zod,"optin",(()=>t.in._zod.optin)),h(e._zod,"optout",(()=>t.out._zod.optout)),e._zod.parse=(e,n)=>{const i=t.in._zod.run(e,n);return i instanceof Promise?i.then((e=>Ut(e,t,n))):Ut(i,t,n)}}));function Ut(e,t,n){return $(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Lt=s("$ZodReadonly",((e,t)=>{Se.init(e,t),h(e._zod,"propValues",(()=>t.innerType._zod.propValues)),h(e._zod,"optin",(()=>t.innerType._zod.optin)),h(e._zod,"optout",(()=>t.innerType._zod.optout)),e._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(Vt):Vt(i)}}));function Vt(e){return e.value=Object.freeze(e.value),e}const Wt=s("$ZodLazy",((e,t)=>{Se.init(e,t),h(e._zod,"innerType",(()=>t.getter())),h(e._zod,"pattern",(()=>e._zod.innerType._zod.pattern)),h(e._zod,"propValues",(()=>e._zod.innerType._zod.propValues)),h(e._zod,"optin",(()=>e._zod.innerType._zod.optin)),h(e._zod,"optout",(()=>e._zod.innerType._zod.optout)),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)})),Bt=s("$ZodCustom",((e,t)=>{me.init(e,t),Se.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,o=t.fn(i);if(o instanceof Promise)return o.then((t=>Gt(t,n,i,e)));Gt(o,n,i,e)}}));function Gt(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(N(e))}}class Ht{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function qt(){return new Ht}const Kt=qt();function Yt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function Jt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function Xt(e,t){return new ge({check:"less_than",...E(t),value:e,inclusive:!1})}function Qt(e,t){return new ge({check:"less_than",...E(t),value:e,inclusive:!0})}function en(e,t){return new ve({check:"greater_than",...E(t),value:e,inclusive:!1})}function tn(e,t){return new ve({check:"greater_than",...E(t),value:e,inclusive:!0})}function nn(e,t){return new ye({check:"multiple_of",...E(t),value:e})}function on(e,t){return new ze({check:"max_length",...E(t),maximum:e})}function rn(e,t){return new ke({check:"min_length",...E(t),minimum:e})}function sn(e,t){return new be({check:"length_equals",...E(t),length:e})}function an(e){return new Ne({check:"overwrite",tx:e})}const un=s("ZodISODateTime",((e,t)=>{qe.init(e,t),In.init(e,t)}));function cn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}(un,e)}const dn=s("ZodISODate",((e,t)=>{Ke.init(e,t),In.init(e,t)}));function ln(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}(dn,e)}const pn=s("ZodISOTime",((e,t)=>{Ye.init(e,t),In.init(e,t)}));function fn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}(pn,e)}const hn=s("ZodISODuration",((e,t)=>{Je.init(e,t),In.init(e,t)}));function mn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}(hn,e)}const _n=s("ZodError",((e,t)=>{P.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const n=t||function(e){return e.message},i={_errors:[]},o=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map((e=>o({issues:e})));else if("invalid_key"===t.code)o({issues:t.issues});else if("invalid_element"===t.code)o({issues:t.issues});else if(0===t.path.length)i._errors.push(n(t));else{let e=i,o=0;for(;o<t.path.length;){const i=t.path[o];o===t.path.length-1?(e[i]=e[i]||{_errors:[]},e[i]._errors.push(n(t))):e[i]=e[i]||{_errors:[]},e=e[i],o++}}};return o(e),i}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},i=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):i.push(t(o));return{formErrors:i,fieldErrors:n}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})}),{Parent:Error}),gn=D(_n),vn=C(_n),yn=R(_n),wn=F(_n),zn=s("ZodType",((e,t)=>(Se.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),e.clone=(t,n)=>b(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>gn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>yn(e,t,n),e.parseAsync=async(t,n)=>vn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>wn(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...E(n)})}(Mi,e,t)}(t,n)),e.superRefine=t=>e.check(function(e,t){const n=function(e,t){const n=new me({check:"custom",...E(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(N(e,t.value,n._zod.def));else{const i=e;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),t.issues.push(N(i))}},e(t.value,t))),t);return n}(t)),e.overwrite=t=>e.check(an(t)),e.optional=()=>Ti(e),e.nullable=()=>Ai(e),e.nullish=()=>Ti(Ai(e)),e.nonoptional=t=>function(e,t){return new Oi({type:"nonoptional",innerType:e,...E(t)})}(e,t),e.array=()=>ui(e),e.or=t=>pi([e,t]),e.and=t=>new mi({type:"intersection",left:e,right:t}),e.transform=t=>Di(e,Ii(t)),e.default=t=>{return n=t,new Zi({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():n}});var n},e.prefault=t=>{return n=t,new Ni({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():n}});var n},e.catch=t=>{return new Pi({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>Di(e,t),e.readonly=()=>new Ci({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Kt.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Kt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Kt.get(e);const n=e.clone();return Kt.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e))),kn=s("_ZodString",((e,t)=>{De.init(e,t),zn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Ie({check:"string_format",format:"regex",...E(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new xe({check:"string_format",format:"includes",...E(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Ae({check:"string_format",format:"starts_with",...E(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Ze({check:"string_format",format:"ends_with",...E(t),suffix:e})}(...t)),e.min=(...t)=>e.check(rn(...t)),e.max=(...t)=>e.check(on(...t)),e.length=(...t)=>e.check(sn(...t)),e.nonempty=(...t)=>e.check(rn(1,...t)),e.lowercase=t=>e.check(function(e){return new $e({check:"string_format",format:"lowercase",...E(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Te({check:"string_format",format:"uppercase",...E(e)})}(t)),e.trim=()=>e.check(an((e=>e.trim()))),e.normalize=(...t)=>e.check(function(e){return an((t=>t.normalize(e)))}(...t)),e.toLowerCase=()=>e.check(an((e=>e.toLowerCase()))),e.toUpperCase=()=>e.check(an((e=>e.toUpperCase())))})),bn=s("ZodString",((e,t)=>{De.init(e,t),kn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}($n,t)),e.url=t=>e.check(Jt(An,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}(Bn,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}(Nn,t)),e.guid=t=>e.check(Yt(Tn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}(xn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}(xn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}(xn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}(xn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}(On,t)),e.guid=t=>e.check(Yt(Tn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}(Pn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}(Sn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}(Dn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}(Ln,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}(Vn,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}(Cn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}(Rn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}(Mn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}(Fn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}(jn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}(Un,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}(Wn,t)),e.datetime=t=>e.check(cn(t)),e.date=t=>e.check(ln(t)),e.time=t=>e.check(fn(t)),e.duration=t=>e.check(mn(t))}));function En(e){return function(e,t){return new e({type:"string",...E(t)})}(bn,e)}const In=s("ZodStringFormat",((e,t)=>{Ce.init(e,t),kn.init(e,t)})),$n=s("ZodEmail",((e,t)=>{Fe.init(e,t),In.init(e,t)})),Tn=s("ZodGUID",((e,t)=>{Re.init(e,t),In.init(e,t)})),xn=s("ZodUUID",((e,t)=>{Me.init(e,t),In.init(e,t)})),An=s("ZodURL",((e,t)=>{je.init(e,t),In.init(e,t)}));function Zn(e){return Jt(An,e)}const Nn=s("ZodEmoji",((e,t)=>{Ue.init(e,t),In.init(e,t)})),On=s("ZodNanoID",((e,t)=>{Le.init(e,t),In.init(e,t)})),Pn=s("ZodCUID",((e,t)=>{Ve.init(e,t),In.init(e,t)})),Sn=s("ZodCUID2",((e,t)=>{We.init(e,t),In.init(e,t)})),Dn=s("ZodULID",((e,t)=>{Be.init(e,t),In.init(e,t)})),Cn=s("ZodXID",((e,t)=>{Ge.init(e,t),In.init(e,t)})),Rn=s("ZodKSUID",((e,t)=>{He.init(e,t),In.init(e,t)})),Mn=s("ZodIPv4",((e,t)=>{Xe.init(e,t),In.init(e,t)})),Fn=s("ZodIPv6",((e,t)=>{Qe.init(e,t),In.init(e,t)})),jn=s("ZodCIDRv4",((e,t)=>{et.init(e,t),In.init(e,t)})),Un=s("ZodCIDRv6",((e,t)=>{tt.init(e,t),In.init(e,t)})),Ln=s("ZodBase64",((e,t)=>{it.init(e,t),In.init(e,t)})),Vn=s("ZodBase64URL",((e,t)=>{ot.init(e,t),In.init(e,t)})),Wn=s("ZodE164",((e,t)=>{rt.init(e,t),In.init(e,t)})),Bn=s("ZodJWT",((e,t)=>{st.init(e,t),In.init(e,t)})),Gn=s("ZodNumber",((e,t)=>{at.init(e,t),zn.init(e,t),e.gt=(t,n)=>e.check(en(t,n)),e.gte=(t,n)=>e.check(tn(t,n)),e.min=(t,n)=>e.check(tn(t,n)),e.lt=(t,n)=>e.check(Xt(t,n)),e.lte=(t,n)=>e.check(Qt(t,n)),e.max=(t,n)=>e.check(Qt(t,n)),e.int=t=>e.check(Kn(t)),e.safe=t=>e.check(Kn(t)),e.positive=t=>e.check(en(0,t)),e.nonnegative=t=>e.check(tn(0,t)),e.negative=t=>e.check(Xt(0,t)),e.nonpositive=t=>e.check(Qt(0,t)),e.multipleOf=(t,n)=>e.check(nn(t,n)),e.step=(t,n)=>e.check(nn(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}));function Hn(e){return function(e,t){return new e({type:"number",checks:[],...E(t)})}(Gn,e)}const qn=s("ZodNumberFormat",((e,t)=>{ut.init(e,t),Gn.init(e,t)}));function Kn(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}(qn,e)}const Yn=s("ZodBoolean",((e,t)=>{ct.init(e,t),zn.init(e,t)}));function Jn(e){return function(e,t){return new e({type:"boolean",...E(t)})}(Yn,e)}const Xn=s("ZodBigInt",((e,t)=>{dt.init(e,t),zn.init(e,t),e.gte=(t,n)=>e.check(tn(t,n)),e.min=(t,n)=>e.check(tn(t,n)),e.gt=(t,n)=>e.check(en(t,n)),e.gte=(t,n)=>e.check(tn(t,n)),e.min=(t,n)=>e.check(tn(t,n)),e.lt=(t,n)=>e.check(Xt(t,n)),e.lte=(t,n)=>e.check(Qt(t,n)),e.max=(t,n)=>e.check(Qt(t,n)),e.positive=t=>e.check(en(BigInt(0),t)),e.negative=t=>e.check(Xt(BigInt(0),t)),e.nonpositive=t=>e.check(Qt(BigInt(0),t)),e.nonnegative=t=>e.check(tn(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(nn(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function Qn(e){return function(e,t){return new e({type:"bigint",...E(t)})}(Xn,e)}const ei=s("ZodNull",((e,t)=>{lt.init(e,t),zn.init(e,t)}));const ti=s("ZodAny",((e,t)=>{pt.init(e,t),zn.init(e,t)}));function ni(){return new ti({type:"any"})}const ii=s("ZodUnknown",((e,t)=>{ft.init(e,t),zn.init(e,t)}));function oi(){return new ii({type:"unknown"})}const ri=s("ZodNever",((e,t)=>{ht.init(e,t),zn.init(e,t)}));function si(e){return function(e,t){return new e({type:"never",...E(t)})}(ri,e)}const ai=s("ZodArray",((e,t)=>{_t.init(e,t),zn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(rn(t,n)),e.nonempty=t=>e.check(rn(1,t)),e.max=(t,n)=>e.check(on(t,n)),e.length=(t,n)=>e.check(sn(t,n)),e.unwrap=()=>e.element}));function ui(e,t){return function(e,t,n){return new e({type:"array",element:t,...E(n)})}(ai,e,t)}const ci=s("ZodObject",((e,t)=>{yt.init(e,t),zn.init(e,t),h(e,"shape",(()=>Object.fromEntries(Object.entries(e._zod.def.shape)))),e.keyof=()=>zi(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:oi()}),e.loose=()=>e.clone({...e._zod.def,catchall:oi()}),e.strict=()=>e.clone({...e._zod.def,catchall:si()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return m(this,"shape",n),n},checks:[]};return b(e,n)}(e,t),e.merge=t=>{return i=t,b(n=e,{...n._zod.def,get shape(){const e={...n._zod.def.shape,...i._zod.def.shape};return m(this,"shape",e),e},catchall:i._zod.def.catchall,checks:[]});var n,i},e.pick=t=>function(e,t){const n={},i=e._zod.def;for(const e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=i.shape[e])}return b(e,{...e._zod.def,shape:n,checks:[]})}(e,t),e.omit=t=>function(e,t){const n={...e._zod.def.shape},i=e._zod.def;for(const e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return b(e,{...e._zod.def,shape:n,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,n){const i=t._zod.def.shape,o={...i};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:i[t]}):i[t])}else for(const t in i)o[t]=e?new e({type:"optional",innerType:i[t]}):i[t];return b(t,{...t._zod.def,shape:o,checks:[]})}($i,e,t[0]),e.required=(...t)=>function(e,t,n){const i=t._zod.def.shape,o={...i};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:i[t]}))}else for(const t in i)o[t]=new e({type:"nonoptional",innerType:i[t]});return b(t,{...t._zod.def,shape:o,checks:[]})}(Oi,e,t[0])}));function di(e,t){const n={type:"object",get shape(){return m(this,"shape",{...e}),this.shape},...E(t)};return new ci(n)}const li=s("ZodUnion",((e,t)=>{zt.init(e,t),zn.init(e,t),e.options=t.options}));function pi(e,t){return new li({type:"union",options:e,...E(t)})}const fi=s("ZodDiscriminatedUnion",((e,t)=>{li.init(e,t),kt.init(e,t)}));function hi(e,t,n){return new fi({type:"union",options:t,discriminator:e,...E(n)})}const mi=s("ZodIntersection",((e,t)=>{bt.init(e,t),zn.init(e,t)}));const _i=s("ZodTuple",((e,t)=>{$t.init(e,t),zn.init(e,t),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function gi(e,t,n){const i=t instanceof Se;return new _i({type:"tuple",items:e,rest:i?t:null,...E(i?n:t)})}const vi=s("ZodRecord",((e,t)=>{xt.init(e,t),zn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType}));function yi(e,t,n){return new vi({type:"record",keyType:e,valueType:t,...E(n)})}const wi=s("ZodEnum",((e,t)=>{At.init(e,t),zn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,i)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new wi({...t,checks:[],...E(i),entries:o})},e.exclude=(e,i)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new wi({...t,checks:[],...E(i),entries:o})}}));function zi(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new wi({type:"enum",entries:n,...E(t)})}const ki=s("ZodLiteral",((e,t)=>{Zt.init(e,t),zn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));function bi(e,t){return new ki({type:"literal",values:Array.isArray(e)?e:[e],...E(t)})}const Ei=s("ZodTransform",((e,t)=>{Nt.init(e,t),zn.init(e,t),e._zod.parse=(n,i)=>{n.addIssue=i=>{if("string"==typeof i)n.issues.push(N(i,n.value,t));else{const t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),n.issues.push(N(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then((e=>(n.value=e,n))):(n.value=o,n)}}));function Ii(e){return new Ei({type:"transform",transform:e})}const $i=s("ZodOptional",((e,t)=>{Ot.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));function Ti(e){return new $i({type:"optional",innerType:e})}const xi=s("ZodNullable",((e,t)=>{Pt.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));function Ai(e){return new xi({type:"nullable",innerType:e})}const Zi=s("ZodDefault",((e,t)=>{St.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Ni=s("ZodPrefault",((e,t)=>{Ct.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));const Oi=s("ZodNonOptional",((e,t)=>{Rt.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));const Pi=s("ZodCatch",((e,t)=>{Ft.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Si=s("ZodPipe",((e,t)=>{jt.init(e,t),zn.init(e,t),e.in=t.in,e.out=t.out}));function Di(e,t){return new Si({type:"pipe",in:e,out:t})}const Ci=s("ZodReadonly",((e,t)=>{Lt.init(e,t),zn.init(e,t)}));const Ri=s("ZodLazy",((e,t)=>{Wt.init(e,t),zn.init(e,t),e.unwrap=()=>e._zod.def.getter()}));const Mi=s("ZodCustom",((e,t)=>{Bt.init(e,t),zn.init(e,t)}));const Fi=En().refine((e=>/^(0|[1-9]\d*)(\.\d+)?$/.test(e)),{message:"Invalid amount"}),ji=/^(0x|0x[a-fA-F0-9]{40})$/,Ui=En().refine((e=>ji.test(e)),{message:"Invalid EVM token address"}),Li=Ui.refine((e=>"0x"!==e),{message:"Invalid EVM address"}),Vi=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/,Wi=/^So[1-2]{41}$/,Bi=En().refine((e=>Vi.test(e)||Wi.test(e)),{message:"Invalid Solana token address"}),Gi=pi([Li,En().refine((e=>Vi.test(e)),{message:"Invalid Solana address"})]),Hi=En().refine((e=>/^[a-zA-Z_]{3,}$/.test(e)),{message:"Invalid fiat"}),qi=di({issuer:En(),name:En(),alias:En().optional(),symbol:En(),decimals:Hn()}),Ki=En(),Yi=En().regex(/^[a-zA-Z]\w{1,7}$/,{message:"Must be a short alpha-numeric symbol"}),Ji=Hn().min(0).max(18),Xi=En().url(),Qi=En(),eo=di({chain:En(),address:Ui}),to=di({chain:bi("solana"),address:Bi}),no=pi([eo,to]),io=En().refine((e=>{const[t,n]=e.split(":");return no.safeParse({chain:t,address:n}).success}),{message:"Invalid token"}),oo=di({name:Ki,symbol:Yi,decimals:Ji,alias:Yi.optional(),image_url:Xi.optional(),coingecko_id:Qi.optional(),wrapper:Yi.optional()}),ro=pi([eo.extend(oo.shape),to.extend(oo.shape)]),so=pi([io,Hi]),ao=pi([ro,qi]),uo=hi("type",[di({type:bi("chain"),chain:En()}),di({type:bi("issuer"),issuer:En()})]),co=En().transform((e=>e.toLowerCase()));var lo,po;lo=e=>"string"==typeof e?e.toUpperCase():e,po=zi(["ONRAMP","OFFRAMP"]),Di(Ii(lo),po),di({to:Li,from:Li.optional(),nonce:Hn().optional(),gasLimit:Qn().optional(),gasPrice:Qn().optional(),maxPriorityFeePerGas:Qn().optional(),maxFeePerGas:Qn().optional(),data:En().optional(),value:Qn().optional(),chainId:Hn()}),di({transactionHash:En().optional(),blockHash:En().optional(),blockNumber:Hn().optional(),from:Li.optional(),to:Li.optional(),rawReceipt:ni()});pi([di({chain_id:Hn(),network:En(),native_currency:di({name:En(),symbol:En(),decimals:Hn()}),rpc:En(),image:En(),is_testnet:Jn(),explorer:En()}),di({chain_id:Hn(),network:En()})]);const fo=di({"#":En()});di({name:En(),alpha2:En().length(2),alpha3:En().length(3)});const ho=En().refine((e=>r.test(e)),{message:"Invalid workflow ID"}),mo=di({onramps:ui(co).optional(),offramps:ui(co).optional(),sandbox:Jn().default(!1)}),_o=mo.extend({inputs:ui(so).optional(),outputs:ui(so)});pi([_o,mo.extend({inputs:ui(so),outputs:ui(so).optional()})]);const go=new Ri({type:"lazy",getter:()=>pi([wo,zo,ko])});const vo=di({asset:so,amount:Fi}),yo=di({token:io,amount:Fi}),wo=vo,zo=vo,ko=ui(go),bo=En(),Eo=hi("kind",[di({kind:bi("FixedInputSwap"),input:vo,output:so,quote_fiat:Hi}),di({kind:bi("FixedOutputSwap"),input:so,output:vo,quote_fiat:Hi})]),Io=zi(["USER","DEST","HALLIDAY","SPW","REV_SHARE","BRIDGE"]),$o=di({asset:so,property:zi(["APPROVAL","BALANCE"])}),To=di({account:Io,resource:$o}),xo=To.extend({sau:fo});En();const Ao=di({consume:ui(xo),produce:ui(xo)}),Zo=zi(["user_fund","onramp","poll","bridge","rev_share","transfer_out","convert"]),No=di({type:pi([bi("ONRAMP"),bi("STEP")]),net_effect:Ao,pieces_info:ui(di({piece_type:Zo,hop_data:di({hop_identifier:En(),input:so,output:so}).optional(),ramp_data:di({ramp_identifier:En()}).optional()})),expected_metadata:di({step_index:Hn().optional()})}),Oo=pi([bi("COMPLETE"),bi("UNREACHABLE"),bi("FAILED")]),Po=pi([Oo,bi("PENDING")]),So=zi(["INITIALIZED","PAYMENT_SUBMITTED","COMPLETED","FAILED","NOT_FOUND"]),Do=zi(["PENDING","COMPLETED","FAILED","NOT_FOUND"]),Co=zi(["PENDING","COMPLETE","FAILED"]),Ro=di({observed_status:Po,details:No.extend({observed_metadata:di({tx_hash:En().optional(),purchase_status:So.optional(),step_status:Do.optional()})}).nullable()}),Mo=di({expected_details_list:ui(No),preconditions:ui(xo)});di({tx_hash:En(),step_status:Do,block_timestamp:Hn(),net_effect:Ao});const Fo=function(e,t){return new e({type:"null",...E(t)})}(ei,jo);var jo;const Uo=pi([bi("FIXED"),bi("SOLVE"),bi("SOLVE_TEMPLATED")]),Lo=pi([di({in_decl:bi(!0),instr_type:Uo}),di({in_decl:bi(!1)})]),Vo=di({type:Zo,effect:Ao,attributes:Lo}),Wo=Vo.extend({type:bi("user_fund"),attributes:di({in_decl:bi(!1)})}),Bo=Vo.extend({type:bi("onramp"),attributes:di({in_decl:bi(!1)}),ramp_data:di({ramp_identifier:En()})}),Go=Vo.extend({type:bi("poll"),attributes:di({in_decl:bi(!1)}),hop_data:di({hop_identifier:En(),input:so,output:so})}),Ho=Vo.extend({type:bi("bridge"),attributes:di({in_decl:bi(!0),instr_type:bi("SOLVE_TEMPLATED")}),hop_data:di({hop_identifier:En(),input:so,output:so}),template_metadata:Fo,constraint_values:gi([fo])}),qo=Vo.extend({type:bi("transfer_out"),attributes:di({in_decl:bi(!0),instr_type:bi("FIXED")}),hop_data:di({hop_identifier:En(),input:so,output:so}),constraint_values:gi([fo])}),Ko=hi("type",[Wo,Bo,Go,Ho,Vo.extend({type:bi("rev_share"),attributes:di({in_decl:bi(!0),instr_type:bi("FIXED")}),hop_data:di({hop_identifier:En(),input:so,output:so}),rev_share_config:di({numerator:Qn(),denominator:Qn()}),constraint_values:gi([fo])}),qo,Vo.extend({type:bi("convert"),attributes:di({in_decl:bi(!0),instr_type:bi("SOLVE")})})]),Yo=di({consume:ui(To),produce:ui(To)}),Jo=To.extend({amount:Fi}),Xo=Yo.extend({consume:ui(Jo),produce:ui(Jo)}),Qo=No.extend({net_effect:Xo}),er=Ro.extend({details:Qo.extend({observed_metadata:di({tx_hash:En().optional(),purchase_status:So.optional(),step_status:Do.optional()})}).nullable()}),tr=Mo.extend({expected_details_list:ui(Qo),preconditions:ui(Jo)}),nr=di({observed_details_list:ui(er),preconditions_remaining:di({preconditions:ui(Jo),current_fulfillment:ui(Jo),met:ui(Jn()),all_met_timestamp:En().nullable()}).optional()}),ir=di({realm:uo,indices:ui(Hn())}),or=di({chain:En(),indices:ui(Hn())}),rr=di({pieces:ui(Ko),workflow_id:ho,all_groups:ui(ir),step_groups:ui(or),workflow_expected_details_amount:tr}),sr=yi(so,En()),ar=di({request:Eo,prices:sr,quotes:ui(rr),quote_fiat:Hi,combined_asset_details_list:ui(ao),quoted_at:En(),accept_by:En()}),ur=hi("kind",[di({kind:pi([bi("amount"),bi("amount-downstream")]),given:En(),limits:di({min:En().optional(),max:En().optional()}),source:En(),message:En()}),di({kind:bi("geolocation"),message:En()}),di({kind:bi("provider"),message:En()}),di({kind:bi("other"),message:En()}),di({kind:bi("unknown"),message:En()})]),cr=di({service_ids:ui(En()),latency_seconds:Hn(),issues:ui(ur).optional()});di({content:ar,state_token:En(),failures:ui(cr)}),di({workflowId:ho,stateToken:En(),addresses:di({owner_address:Gi.optional(),dest_address:Gi})});const dr=yi(En(),En());di({workflow_id:ho,workflow_expected_details_amount:tr,post_creation_account_store:dr,prices:sr,asset_details_list:ui(ao),initiate_fund_by:En()});const lr=di({workflow_id:ho,workflow_expected_details_amount:tr,workflow_observed_details_amount:nr,owner_address:Gi,post_creation_account_store:dr,prices:sr,asset_details_list:ui(ao),initiate_fund_by:En(),initiate_fund_by_passed:Jn(),observe_by_passed:Jn(),created_at:En(),status:Co});di({ramp_type:zi(["ONRAMP","OFFRAMP"]),workflow_id:ho,group_index:Hn().int().nonnegative(),redirect_url:En().optional()}),di({ramp_url:En(),is_externally_initialized:Jn(),client_secret:En().optional()}),di({idQuery:En().optional(),paginationKey:En().optional(),destAddress:Gi.optional(),ownerAddress:Gi.optional(),limit:Hn().int().positive().optional()}),di({orders:ui(lr),next_pagination_key:En().nullable()}),di({workflowId:ho.optional(),customQueries:ui(di({spw_address:Gi,token:pi([io,no])})).optional()}).refine((e=>!(!e.workflowId&&!e.customQueries?.length)),{message:"workflow_id or custom_queries is required"}),di({balance_results:ui(di({spw_address:Gi,token:io,value:hi("kind",[di({kind:bi("amount"),amount:Fi}),di({kind:bi("error")})])}))});const pr=En(),fr=di({workflowId:En(),tokenAmounts:ui(yo),recipientAddress:Gi,acceptBlame:Jn().optional()});di({workflow_id:En(),payload:pr}),fr.extend({signature:bo}),di({workflow_id:En(),tx_id:En()});const hr=zi(["EMBED","POPUP"]),mr=En().refine((e=>/^(#[0-9A-Fa-f]{3,8}|rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\)|rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3}(\s*,\s*(0(\.\d+)?|1(\.0+)?))\))$/.test(e)),{message:"Invalid CSS color value"}),_r=di({src:Zn(),alt:En(),width:Hn().positive(),height:Hn().positive()}),gr=di({primaryColor:mr.optional(),backgroundColor:mr.optional(),borderColor:mr.optional(),textColor:mr.optional(),textSecondaryColor:mr.optional(),logo:_r.optional()}),vr=ni(),yr=di({apiKey:En().nonempty(),destinationAddress:Gi.optional(),ownerAddress:Gi.optional(),..._o.shape,customStyles:gr.optional(),targetElementId:En().optional(),windowType:hr.default(hr.enum.POPUP).optional(),signMessage:ni().refine((e=>"function"==typeof e)).optional(),sendTransaction:ni().refine((e=>"function"==typeof e)).optional(),statusCallback:ni().refine((e=>"function"==typeof e)).optional(),signTypedData:ni().refine((e=>"function"==typeof e)).optional()}).refine((e=>!("EMBED"===e.windowType&&!e.targetElementId)),{message:"targetElementId is required when windowType is EMBED"}).refine((e=>!(!e.ownerAddress&&"function"==typeof e.signMessage)),{message:"ownerAddress is required to use signMessage"}).refine((e=>!(!e.ownerAddress&&"function"==typeof e.signTypedData)),{message:"ownerAddress is required to use signTypedData"}),wr=En().regex(/^(https:\/\/(?:[\w-]+\.)*halliday\.xyz(?:\/.*)?|http:\/\/localhost(?::\d+)?(?:\/.*)?|https:\/\/localhost(?::\d+)?(?:\/.*)?)$/,"Invalid API baseUrl"),zr=di({dangerouslyOverrideHallidayDomainName:Zn().optional(),dangerouslyOverrideApiBaseUrl:wr.optional()}),kr=di({apiBaseUrl:wr.optional(),hasOwner:Jn(),hasTxHandler:Jn()}),br=di({...yr.omit({signMessage:!0,sendTransaction:!0,statusCallback:!0}).shape,...kr.shape});var Er;!function(e){e.ACTION_TRANSACTION="ACTION_TRANSACTION",e.EVENT_ORDER_STATUS="EVENT_ORDER_STATUS",e.EVENT_WINDOW_CLOSE="EVENT_WINDOW_CLOSE",e.ACTION_SIGN_MESSAGE="ACTION_SIGN_MESSAGE",e.ACTION_PROVIDER_WIDGET="ACTION_PROVIDER_WIDGET",e.ACTION_SIGN_TYPED_DATA="ACTION_SIGN_TYPED_DATA"}(Er||(Er={}));const Ir=async(e,t,n)=>{if(!t.provider)throw new Error("Signer does not have a provider");try{await t.provider.send("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}])}catch(i){if(console.error("Error switching chain",i),!n)throw i;try{await(async(e,t)=>{if(!e.provider)throw new Error("Signer does not have a provider");await e.provider.send("wallet_addEthereumChain",[t])})(t,(e=>({chainId:String(e.chain_id),blockExplorerUrls:[e.explorer],chainName:e.network,iconUrls:[e.image],nativeCurrency:e.native_currency,rpcUrls:[e.rpc]}))(n)),await t.provider.send("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}])}catch(e){throw console.error("Error adding chain",e),e}}},$r=e=>{const t=br.parse(e);return btoa(JSON.stringify(t))},Tr=e=>br.parse(JSON.parse(atob(e))),xr=e=>{const{windowOrigin:t=o,...n}=e;return`${t}/payments/quote?data=${$r(n)}`},Ar=async({apiKey:e,baseURL:t,workflowId:n})=>{let i;for(let o=1;o<=3;o++)try{const i=await fetch(`${t}/quotes/status?workflow_id=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return await i.json()}catch(e){if(i=e instanceof Error?e:new Error(String(e)),3===o)throw i;const t=1e3*Math.pow(2,o);await new Promise((e=>setTimeout(e,t)))}throw i},Zr=({address:n,message:i,signedMessage:o})=>{const r=((n,i)=>e(t(n),i))(i,o);if(r!==n)throw new Error("Signer address does not match owner address")},Nr=(()=>{let e=null,t=null,n=[];const i=()=>{n.forEach((e=>{window.removeEventListener("message",e)})),n=[]};return{openWidget:async(r,...s)=>{const a=s[999]||{},u=yr.parse(r),{dangerouslyOverrideHallidayDomainName:c,dangerouslyOverrideApiBaseUrl:d}=zr.parse(a),{sendTransaction:l,signMessage:p,statusCallback:f,signTypedData:h}=u,m=c||o,_="function"==typeof p,g="function"==typeof l;i();const v=[t=>{if(t.origin!==m||t.source!==e)return;const{type:n}=t.data||{};n===Er.EVENT_WINDOW_CLOSE&&i()}];if(_){const t=async t=>{if(t.origin!==m||t.source!==e)return;const{type:n,payload:i}=t.data||{};if(n===Er.ACTION_SIGN_MESSAGE){const{messageId:t,message:o,ownerAddress:r}=i;try{let i;if("function"!=typeof p)throw new Error("No signMessage function provided");i=await p({message:o,ownerAddress:r}),r&&Zr({address:r,message:o,signedMessage:i}),e?.postMessage({type:n,payload:{messageId:t,signature:i}},m)}catch(i){console.error("Error signing message",i),e?.postMessage({type:n,payload:{messageId:t,error:i instanceof Error?i.message:i}},m)}}else if(n===Er.ACTION_SIGN_TYPED_DATA){const{messageId:t,typedData:o,ownerAddress:r}=i;try{let i;if("function"!=typeof h)throw new Error("No signTypedData function provided");i=await h({typedData:o,ownerAddress:r}),e?.postMessage({type:n,payload:{messageId:t,signature:i}},m)}catch(i){console.error("Error signing typed data",i),e?.postMessage({type:n,payload:{messageId:t,error:i instanceof Error?i.message:i}},m)}}};v.push(t)}if(g){const t=async t=>{if(t.origin!==m||t.source!==e)return;const{type:n,payload:i}=t.data||{};if(n===Er.ACTION_TRANSACTION){const{messageId:t,chainConfig:o,transaction:r}=i;try{let i;if("function"!=typeof l)throw new Error("No sendTransaction function provided");i=await l(r,o),e?.postMessage({type:n,payload:{messageId:t,txReceipt:i}},m)}catch(i){console.error("Error handling transaction",i),e?.postMessage({type:n,payload:{messageId:t,error:i instanceof Error?i.message:i}},m)}}};v.push(t)}if(f){const t=t=>{if(t.origin!==m||t.source!==e)return;const{type:n,payload:i}=t.data||{};n===Er.EVENT_ORDER_STATUS&&f({type:n,payload:i})};v.push(t)}var y;v.push((async n=>{if(n.origin!==m||n.source!==e)return;const{type:i,payload:o}=n.data||{};if(i===Er.ACTION_PROVIDER_WIDGET&&e){const{url:n,redirectUrl:i,providerWidgetMode:r,workflowId:s}=o||{};if(!(n&&i&&r&&s))throw new Error("Invalid provider widget payload");let a=null;if("REDIRECT"===r)e.location=n,a=e;else{if("POPUP"!==r)throw new Error("Invalid provider widget mode");t=(e=>{const t=window.innerWidth/2-240;return window.open(e,"Provider Widget",`popup left=${t} top=70 width=480 height=638`)})(n),a=t}if(await(async({apiKey:e,baseURL:t,window:n,workflowId:i})=>{for(;!n.closed;){let n;try{n=await Ar({apiKey:e,baseURL:t,workflowId:i})}catch(e){console.error("Error fetching payment status",e);break}const o=n.workflow_observed_details_amount.observed_details_list.find((e=>"ONRAMP"===e.details?.type)),r=o?.details?.observed_metadata?.purchase_status;if("COMPLETED"===r)break;await new Promise((e=>setTimeout(e,5e3)))}})({apiKey:u.apiKey,baseURL:d||"https://v2.prod.halliday.xyz",workflowId:s,window:a}),a?.closed)return;"REDIRECT"===r?e.location=i:"POPUP"===r&&(t?.close(),t=null)}})),e=(e=>{const t=window.innerWidth/2-240,{windowType:n="POPUP",targetElementId:i,windowOrigin:o}=e,r=xr(e);let s;if("EMBED"===n){const e=document.getElementById(i);if(!e)throw new Error(`Element with id ${i} not found`);const t=document.createElement("iframe");t.src=r,t.style.width="480px",t.style.height="638px",e.innerHTML="",e.appendChild(t);const n=t=>{if(t.origin!==o||t.source!==s)return;const{type:i}=t.data||{};i===Er.EVENT_WINDOW_CLOSE&&(window.removeEventListener("message",n),e.innerHTML="")};window.addEventListener("message",n),s=t.contentWindow}else s=window.open(r,"Halliday Payments",`popup left=${t} top=70 width=480 height=638`);return s})({...r,hasOwner:_,hasTxHandler:g,windowOrigin:m,apiBaseUrl:d}),(y=v).forEach((e=>{window.addEventListener("message",e)})),n=y}}})();async function Or(e,...t){return Nr.openWidget(e,...t)}const Pr=e=>({getAddress:async()=>(await e()).getAddress(),signMessage:async({message:t,ownerAddress:n})=>{const i=await e(n);if(n){if(n!==await i.getAddress())throw new Error("Owner address does not match")}return await i.signMessage(t)},sendTransaction:async(t,n)=>{let i=await e();const o=await(i.provider?.getNetwork());o?.chainId?.toString()!==t.chainId.toString()&&(await Ir(t.chainId,i,n),i=await e());const r=await(async({signer:e,transaction:t,confirmations:n,timeout:i})=>{const o=await e.sendTransaction(t);return await o.wait(n,i)})({signer:i,transaction:t});return{transactionHash:(s=r).hash,blockHash:s.blockHash,blockNumber:s.blockNumber,from:s.from,to:s.to||void 0,rawReceipt:s};var s},signTypedData:async({typedData:t,ownerAddress:n})=>{const i=await e(n);if(n){if(n!==await i.getAddress())throw new Error("Owner address does not match")}return await(i.provider?.send("eth_signTypedData_v4",[n,t]))}}),Sr=e=>({blockExplorers:{default:{name:e.network,url:e.explorer??""}},id:e.chain_id,name:e.network,nativeCurrency:e.native_currency,rpcUrls:{default:{http:[e.rpc]}}}),Dr=async({wallet:e,transaction:t,chainConfig:o})=>{const r=n({chain:Sr(o),transport:i(o.rpc)}),s=await e.sendTransaction(((e,t)=>({account:e.from,to:e.to,value:e.value,data:e.data,gas:e.gasLimit,nonce:e.nonce,chain:Sr(t)}))(t,o));return await r.waitForTransactionReceipt({hash:s})},Cr=e=>({getAddress:async()=>await e.getAddresses(),signMessage:async({message:t,ownerAddress:n})=>await e.signMessage({account:n,message:t}),sendTransaction:async(t,n)=>{const i=await Dr({wallet:e,transaction:t,chainConfig:n});return{transactionHash:(o=i).transactionHash,blockHash:o.blockHash,blockNumber:Number(o.blockNumber),from:o.from,to:o.to||void 0,rawReceipt:o};var o},signTypedData:async({typedData:t,ownerAddress:n})=>{const i=JSON.parse(t);return await e.signTypedData({account:n,...i})}});export{gr as CustomStyles,Er as MessageType,vr as OrderStatus,br as PaymentsWidgetQueryParams,yr as PaymentsWidgetSDKParams,Pr as connectSigner,Cr as connectWallet,Tr as deserializeQueryParams,xr as getPaymentsWidgetUrl,Or as openHallidayPayments,$r as serializeQueryParams};
2
+ //# sourceMappingURL=index.esm.min.js.map