@telemetryos/root-sdk 1.15.0 → 1.16.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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- const Me = "1.15.0", qe = {
2
- version: Me
1
+ const He = "1.16.1", Le = {
2
+ version: He
3
3
  };
4
- class Le {
4
+ class De {
5
5
  constructor(e) {
6
6
  this._client = e;
7
7
  }
@@ -20,10 +20,32 @@ class Le {
20
20
  return e.account;
21
21
  }
22
22
  }
23
- class He {
23
+ class Ve {
24
24
  constructor(e) {
25
25
  this._client = e;
26
26
  }
27
+ /**
28
+ * Retrieve a single application by its id.
29
+ *
30
+ * @param applicationId The unique identifier of the application to retrieve
31
+ * @returns A promise that resolves to the application data
32
+ */
33
+ async getById(e) {
34
+ return (await this._client.request("applications.getById", {
35
+ applicationId: e
36
+ })).application;
37
+ }
38
+ /**
39
+ * Retrieves a single application by specifier
40
+ *
41
+ * @param applicationSpecifier The unique specifier of the application to retrieve
42
+ * @returns A promise that resolves to the application data
43
+ */
44
+ async getBySpecifier(e) {
45
+ return (await this._client.request("applications.getBySpecifier", {
46
+ applicationSpecifier: e
47
+ })).application;
48
+ }
27
49
  /**
28
50
  * Retrieves all applications with a specific mount point within the current account.
29
51
  *
@@ -42,21 +64,6 @@ class He {
42
64
  mountPoint: e
43
65
  })).applications;
44
66
  }
45
- /**
46
- * Retrieves an application by its name.
47
- *
48
- * This method allows finding a specific application when you know its name. It's useful
49
- * when you need to check if a particular application is available or get its details
50
- * before attempting to embed it.
51
- *
52
- * @param name The name of the application to query for
53
- * @returns A promise that resolves to the application object if found, or null if not found
54
- */
55
- async getByName(e) {
56
- return (await this._client.request("applications.getByName", {
57
- name: e
58
- })).application;
59
- }
60
67
  /**
61
68
  * Sets the dependencies for the current application.
62
69
  *
@@ -64,20 +71,24 @@ class He {
64
71
  * The player will download and prepare these dependencies before they can be loaded.
65
72
  *
66
73
  * IMPORTANT: This method must be called and awaited before loading any sub-applications
67
- * in iframes. Only applications that return as 'ready' should be loaded.
74
+ * in iframes.
68
75
  *
69
- * @param applicationSpecifiers An array of application specifiers that this application depends on
70
- * @returns A promise that resolves with arrays of ready and unavailable application specifiers
76
+ * @param applicationSpecifiers A map of application specifier to an array of instance IDs
77
+ * @returns A function that returns a {@link DependencyHandle} for a given specifier and instance ID
71
78
  *
72
79
  * @example
73
80
  * ```typescript
74
- * const result = await client.applications.setDependencies(['app1-hash', 'app2-hash'])
75
- * // result.ready: ['app1-hash'] - these can be loaded in iframes
76
- * // result.unavailable: ['app2-hash'] - these failed to load
81
+ * const getHandle = await applications().setDependencies({
82
+ * 'app1-specifier-hash': ['instance-1', 'instance-2'],
83
+ * 'app2-specifier-hash': ['instance-1'],
84
+ * })
85
+ * const handle = getHandle('app1-specifier-hash', 'instance-1')
86
+ * handle.onStatus((status) => console.log(status))
87
+ * const iframe = await handle.frame()
77
88
  * ```
78
89
  */
79
90
  async setDependencies(e) {
80
- return await this._client.request("applications.setDependencies", { applicationSpecifiers: e }, { timeout: 0 });
91
+ return await this._client._dependencyStore.setDependencies(e), (t, s) => this._client._dependencyStore.handleFor(t, s);
81
92
  }
82
93
  /**
83
94
  * Registers a message interceptor for client messages from sub-applications.
@@ -115,65 +126,7 @@ class He {
115
126
  this._client._messageInterceptors.set(e, t);
116
127
  }
117
128
  }
118
- class Ve {
119
- constructor(e) {
120
- this._client = e;
121
- }
122
- /**
123
- * Retrieves hardware information about the current physical device.
124
- *
125
- * This method returns details about the device running the application, such as
126
- * serial number, model, manufacturer, and platform. This information is only
127
- * available when running on a physical device (player), not in the admin UI.
128
- *
129
- * @returns A promise that resolves to the device hardware information
130
- * @example
131
- * // Get hardware info of the current device
132
- * const info = await devices.getInformation();
133
- * console.log(`Device: ${info.deviceManufacturer} ${info.deviceModel}`);
134
- */
135
- async getInformation() {
136
- const e = await this._client.request("devices.getInformation", {});
137
- if (!e.success)
138
- throw new Error("Failed to get device information");
139
- return e.deviceInformation;
140
- }
141
- /**
142
- * Retrieves the capabilities of the current device.
143
- *
144
- * Capabilities indicate what hardware and software features are available on
145
- * the device running the application. This can be used to conditionally enable
146
- * features based on what the device supports (e.g., MQTT, Bluetooth, WiFi).
147
- *
148
- * @returns A promise that resolves to an array of device capability strings
149
- * @example
150
- * const capabilities = await devices.getCapabilities();
151
- * if (capabilities.includes('mqtt')) {
152
- * // Enable MQTT features
153
- * }
154
- */
155
- async getCapabilities() {
156
- const e = await this._client.request("devices.getCapabilities", {});
157
- if (!e.success)
158
- throw new Error("Failed to get device capabilities");
159
- return e.capabilities;
160
- }
161
- }
162
129
  class ze {
163
- constructor(e) {
164
- this._client = e;
165
- }
166
- async getColorScheme() {
167
- return (await this._client.request("environment.getColorScheme", {})).colorScheme;
168
- }
169
- async subscribeColorScheme(e) {
170
- return (await this._client.subscribe("environment.subscribeColorScheme", {}, e)).success;
171
- }
172
- async unsubscribeColorScheme(e) {
173
- return (await this._client.unsubscribe("environment.unsubscribeColorScheme", {}, e)).success;
174
- }
175
- }
176
- class De {
177
130
  constructor(e) {
178
131
  this._client = e;
179
132
  }
@@ -222,705 +175,215 @@ class De {
222
175
  * Opens a full-screen media picker dialog in the host window.
223
176
  * This allows users to browse folders, view media, and select an item.
224
177
  *
178
+ * Uses a subscription pattern internally so the picker can remain open
179
+ * indefinitely without hitting the 30-second request timeout.
180
+ *
225
181
  * @param options Optional picker options including content type filter and current value
226
182
  * @returns A promise that resolves to the selected media, or null if cancelled
227
183
  */
228
184
  async openPicker(e) {
229
- return (await this._client.request("media.openPicker", {
230
- accept: e == null ? void 0 : e.accept,
231
- currentValue: e == null ? void 0 : e.currentValue
232
- })).selection;
185
+ return new Promise((t, s) => {
186
+ const n = (a) => {
187
+ this._client.unsubscribe("media.openPicker", n), t(a.selection);
188
+ };
189
+ this._client.subscribe("media.openPicker", {
190
+ accept: e == null ? void 0 : e.accept,
191
+ currentValue: e == null ? void 0 : e.currentValue
192
+ }, n).then((a) => {
193
+ a.success || s(new Error("Failed to open media picker"));
194
+ }).catch(s);
195
+ });
233
196
  }
234
197
  }
235
- class Be {
198
+ var b;
199
+ (function(i) {
200
+ i.assertEqual = (n) => {
201
+ };
202
+ function e(n) {
203
+ }
204
+ i.assertIs = e;
205
+ function t(n) {
206
+ throw new Error();
207
+ }
208
+ i.assertNever = t, i.arrayToEnum = (n) => {
209
+ const a = {};
210
+ for (const r of n)
211
+ a[r] = r;
212
+ return a;
213
+ }, i.getValidEnumValues = (n) => {
214
+ const a = i.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), r = {};
215
+ for (const o of a)
216
+ r[o] = n[o];
217
+ return i.objectValues(r);
218
+ }, i.objectValues = (n) => i.objectKeys(n).map(function(a) {
219
+ return n[a];
220
+ }), i.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
221
+ const a = [];
222
+ for (const r in n)
223
+ Object.prototype.hasOwnProperty.call(n, r) && a.push(r);
224
+ return a;
225
+ }, i.find = (n, a) => {
226
+ for (const r of n)
227
+ if (a(r))
228
+ return r;
229
+ }, i.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
230
+ function s(n, a = " | ") {
231
+ return n.map((r) => typeof r == "string" ? `'${r}'` : r).join(a);
232
+ }
233
+ i.joinValues = s, i.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
234
+ })(b || (b = {}));
235
+ var ye;
236
+ (function(i) {
237
+ i.mergeShapes = (e, t) => ({
238
+ ...e,
239
+ ...t
240
+ // second overwrites first
241
+ });
242
+ })(ye || (ye = {}));
243
+ const h = b.arrayToEnum([
244
+ "string",
245
+ "nan",
246
+ "number",
247
+ "integer",
248
+ "float",
249
+ "boolean",
250
+ "date",
251
+ "bigint",
252
+ "symbol",
253
+ "function",
254
+ "undefined",
255
+ "null",
256
+ "array",
257
+ "object",
258
+ "unknown",
259
+ "promise",
260
+ "void",
261
+ "never",
262
+ "map",
263
+ "set"
264
+ ]), A = (i) => {
265
+ switch (typeof i) {
266
+ case "undefined":
267
+ return h.undefined;
268
+ case "string":
269
+ return h.string;
270
+ case "number":
271
+ return Number.isNaN(i) ? h.nan : h.number;
272
+ case "boolean":
273
+ return h.boolean;
274
+ case "function":
275
+ return h.function;
276
+ case "bigint":
277
+ return h.bigint;
278
+ case "symbol":
279
+ return h.symbol;
280
+ case "object":
281
+ return Array.isArray(i) ? h.array : i === null ? h.null : i.then && typeof i.then == "function" && i.catch && typeof i.catch == "function" ? h.promise : typeof Map < "u" && i instanceof Map ? h.map : typeof Set < "u" && i instanceof Set ? h.set : typeof Date < "u" && i instanceof Date ? h.date : h.object;
282
+ default:
283
+ return h.unknown;
284
+ }
285
+ }, d = b.arrayToEnum([
286
+ "invalid_type",
287
+ "invalid_literal",
288
+ "custom",
289
+ "invalid_union",
290
+ "invalid_union_discriminator",
291
+ "invalid_enum_value",
292
+ "unrecognized_keys",
293
+ "invalid_arguments",
294
+ "invalid_return_type",
295
+ "invalid_date",
296
+ "invalid_string",
297
+ "too_small",
298
+ "too_big",
299
+ "invalid_intersection_types",
300
+ "not_multiple_of",
301
+ "not_finite"
302
+ ]);
303
+ class N extends Error {
304
+ get errors() {
305
+ return this.issues;
306
+ }
236
307
  constructor(e) {
237
- this._client = e;
308
+ super(), this.issues = [], this.addIssue = (s) => {
309
+ this.issues = [...this.issues, s];
310
+ }, this.addIssues = (s = []) => {
311
+ this.issues = [...this.issues, ...s];
312
+ };
313
+ const t = new.target.prototype;
314
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
238
315
  }
239
- async fetch(e, t) {
240
- var s;
241
- let n;
242
- typeof e == "string" ? n = e : e instanceof URL ? n = e.toString() : (n = e.url, t || (t = {
243
- method: e.method,
244
- headers: e.headers,
245
- body: e.body,
246
- credentials: e.credentials,
247
- cache: e.cache,
248
- redirect: e.redirect,
249
- referrer: e.referrer,
250
- integrity: e.integrity
251
- }));
252
- let r = {};
253
- t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((g, w) => {
254
- r[w] = g;
255
- }) : Array.isArray(t.headers) ? t.headers.forEach(([g, w]) => {
256
- r[g] = w;
257
- }) : r = t.headers);
258
- const i = await this._client.request("proxy.fetch", {
259
- url: n,
260
- method: (t == null ? void 0 : t.method) || "GET",
261
- headers: r,
262
- body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
263
- });
264
- if (!i.success)
265
- throw new TypeError(i.errorMessage, {
266
- cause: i.errorCause ? Error(i.errorCause) : void 0
267
- });
268
- const o = new Headers(i.headers), c = {
269
- status: i.status,
270
- statusText: i.statusText,
271
- headers: o
316
+ format(e) {
317
+ const t = e || function(a) {
318
+ return a.message;
319
+ }, s = { _errors: [] }, n = (a) => {
320
+ for (const r of a.issues)
321
+ if (r.code === "invalid_union")
322
+ r.unionErrors.map(n);
323
+ else if (r.code === "invalid_return_type")
324
+ n(r.returnTypeError);
325
+ else if (r.code === "invalid_arguments")
326
+ n(r.argumentsError);
327
+ else if (r.path.length === 0)
328
+ s._errors.push(t(r));
329
+ else {
330
+ let o = s, c = 0;
331
+ for (; c < r.path.length; ) {
332
+ const l = r.path[c];
333
+ c === r.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(r))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
334
+ }
335
+ }
272
336
  };
273
- let l = null;
274
- if (i.body !== null && i.body !== void 0)
275
- if (i.bodyType === "binary") {
276
- const g = atob(i.body), w = new Uint8Array(g.length);
277
- for (let T = 0; T < g.length; T++)
278
- w[T] = g.charCodeAt(T);
279
- l = w;
280
- } else i.bodyType === "text" ? l = i.body : i.bodyType === "json" && (l = JSON.stringify(i.body));
281
- return new Response(l, c);
337
+ return n(this), s;
282
338
  }
283
- }
284
- class Ue {
285
- constructor(e) {
286
- this._client = e;
339
+ static assert(e) {
340
+ if (!(e instanceof N))
341
+ throw new Error(`Not a ZodError: ${e}`);
287
342
  }
288
- /**
289
- * Provides access to the application store scope.
290
- *
291
- * Data stored in the application scope is shared across all instances of your application
292
- * within the current account. Use this scope for application-wide settings, shared resources,
293
- * or any data that should be consistent across all instances.
294
- *
295
- * @returns A StoreSlice instance for the application scope
296
- */
297
- get application() {
298
- return new G("application", void 0, this._client);
343
+ toString() {
344
+ return this.message;
299
345
  }
300
- /**
301
- * Provides access to the instance store scope.
302
- *
303
- * Data stored in the instance scope is only available to the current instance of your
304
- * application. This is ideal for instance-specific settings, UI state, temporary data,
305
- * or any information that shouldn't be shared with other instances.
306
- *
307
- * @returns A StoreSlice instance for the instance scope
308
- */
309
- get instance() {
310
- return new G("instance", this._client.applicationInstance, this._client);
346
+ get message() {
347
+ return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
311
348
  }
312
- /**
313
- * Provides access to the device store scope.
314
- *
315
- * Data stored in the device scope is only available to the application on the
316
- * current physical device. This is useful for device-specific settings, caching, or
317
- * any data that should persist across application instances but only on a single device.
318
- *
319
- * Note: This scope cannot be used for Settings-related mount points as the User
320
- * Administration UI does not run on a device.
321
- *
322
- * @returns A StoreSlice instance for the device scope
323
- */
324
- get device() {
325
- return new G("device", this._client.deviceId, this._client);
349
+ get isEmpty() {
350
+ return this.issues.length === 0;
326
351
  }
327
- /**
328
- * Provides access to the shared store scope with a specified namespace.
329
- *
330
- * The shared scope enables data sharing between different applications within the
331
- * same account. By specifying a common namespace, any two applications can exchange
332
- * data and communicate with each other.
333
- *
334
- * This is particularly useful for application ecosystems where multiple applications
335
- * need to coordinate or share configuration.
336
- *
337
- * @param namespace A string identifier for the shared data space
338
- * @returns A StoreSlice instance for the specified shared namespace
339
- */
340
- shared(e) {
341
- return new G("shared", e, this._client);
352
+ flatten(e = (t) => t.message) {
353
+ const t = {}, s = [];
354
+ for (const n of this.issues)
355
+ if (n.path.length > 0) {
356
+ const a = n.path[0];
357
+ t[a] = t[a] || [], t[a].push(e(n));
358
+ } else
359
+ s.push(e(n));
360
+ return { formErrors: s, fieldErrors: t };
361
+ }
362
+ get formErrors() {
363
+ return this.flatten();
342
364
  }
343
365
  }
344
- class G {
345
- constructor(e, t, s) {
346
- this._kind = e, this._namespace = t, this._client = s;
347
- }
348
- /**
349
- * Saves a value in the store.
350
- *
351
- * This method stores data under the specified key within the current store scope and namespace.
352
- * The value must be serializable (can be converted to JSON). Complex objects like Date instances
353
- * will be serialized and deserialize as regular objects, losing their prototype methods.
354
- *
355
- * @param key The key to save the value under
356
- * @param value The value to store - must be JSON serializable
357
- * @returns A promise that resolves to true if the value was saved successfully
358
- */
359
- async set(e, t) {
360
- return (await this._client.request("store.set", {
361
- kind: this._kind,
362
- namespace: this._namespace,
363
- key: e,
364
- value: t
365
- })).success;
366
- }
367
- /**
368
- * Retrieves a value from the store.
369
- *
370
- * This method fetches data stored under the specified key within the current store scope
371
- * and namespace. For real-time applications that need to respond to changes, consider
372
- * using subscribe() instead.
373
- *
374
- * @template T The expected type of the stored value
375
- * @param key The key to retrieve the value for
376
- * @returns A promise that resolves to the stored value, or undefined if the key does not exist
377
- */
378
- async get(e) {
379
- return (await this._client.request("store.get", {
380
- kind: this._kind,
381
- namespace: this._namespace,
382
- key: e
383
- })).value;
384
- }
385
- /**
386
- * Subscribes to changes in the store for a specific key.
387
- *
388
- * This method sets up a subscription that will call the provided handler whenever
389
- * the value associated with the specified key changes. This is the recommended way
390
- * to access store data in long-running applications that need to stay responsive
391
- * to data changes.
392
- *
393
- * @param key The key to subscribe to
394
- * @param handler The callback function to call when the value changes
395
- * @returns A promise that resolves to true if the subscription was successful
396
- */
397
- async subscribe(e, t) {
398
- return (await this._client.subscribe("store.subscribe", {
399
- kind: this._kind,
400
- namespace: this._namespace,
401
- key: e
402
- }, t)).success;
403
- }
404
- /**
405
- * Unsubscribes from changes in the store for a specific key.
406
- *
407
- * This method removes a subscription previously created with subscribe(). It can
408
- * either remove a specific handler or all handlers for the given key.
409
- *
410
- * @param key The key to unsubscribe from
411
- * @param handler Optional. The specific handler to remove. If not provided, all handlers for this key will be removed.
412
- * @returns A promise that resolves to true if the unsubscribe was successful
413
- */
414
- async unsubscribe(e, t) {
415
- return (await this._client.unsubscribe("store.unsubscribe", {
416
- kind: this._kind,
417
- namespace: this._namespace,
418
- key: e
419
- }, t)).success;
420
- }
421
- /**
422
- * Deletes a value from the store.
423
- *
424
- * This method removes the data stored under the specified key within the
425
- * current store scope and namespace.
426
- *
427
- * @param key The key to delete
428
- * @returns A promise that resolves to true if the value was deleted successfully
429
- */
430
- async delete(e) {
431
- return (await this._client.request("store.delete", {
432
- kind: this._kind,
433
- namespace: this._namespace,
434
- key: e
435
- })).success;
436
- }
437
- }
438
- class Ke {
439
- constructor(e) {
440
- this._client = e;
441
- }
442
- /**
443
- * Retrieves information about the user associated with the current session.
444
- *
445
- * This method allows an application to get details about the TelemetryOS user
446
- * who is currently using the application.
447
- *
448
- * @returns A promise that resolves to the current user result object
449
- * @example
450
- * // Get the current user information
451
- * const userResult = await users.getCurrent();
452
- * console.log(`Current user ID: ${userResult.user.id}`);
453
- */
454
- async getCurrent() {
455
- const e = await this._client.request("users.getCurrent", {});
456
- if (!e.success)
457
- throw new Error(e.error || "Failed to fetch current user");
458
- return e.user;
459
- }
460
- }
461
- class We {
462
- constructor(e) {
463
- this._client = e;
464
- }
465
- /**
466
- * Searches for cities by name or country
467
- *
468
- * @param params - Search parameters including optional country code and search query
469
- * @returns A promise that resolves to an array of matching cities
470
- * @throws {Error} If the request fails
471
- *
472
- * @example
473
- * ```typescript
474
- * // Search for cities named "New York"
475
- * const cities = await weather.getCities({ search: 'New York' })
476
- *
477
- * // Search for cities in the United States
478
- * const cities = await weather.getCities({ countryCode: 'US' })
479
- *
480
- * // Get a cityId for use in other methods
481
- * const cities = await weather.getCities({ search: 'London' })
482
- * const cityId = cities[0].cityId
483
- * ```
484
- */
485
- async getCities(e) {
486
- const t = await this._client.request("weather.getCities", e);
487
- if (!t.success)
488
- throw new Error(t.error || "Failed to fetch cities");
489
- return t.data || [];
490
- }
491
- /**
492
- * Retrieves current weather conditions for a specified city
493
- *
494
- * @param params - Weather request parameters including cityId and optional language
495
- * @returns A promise that resolves to the current weather conditions with dual units (C/F, kph/mph, etc.)
496
- * @throws {Error} If the request fails or cityId is invalid
497
- *
498
- * @example
499
- * ```typescript
500
- * // Get current conditions for a city
501
- * const conditions = await weather.getConditions({ cityId: 12345 })
502
- *
503
- * // With localized language
504
- * const conditions = await weather.getConditions({
505
- * cityId: 12345,
506
- * language: 'es'
507
- * })
508
- *
509
- * // Access both units
510
- * console.log(`${conditions.temperatureC}°C / ${conditions.temperatureF}°F`)
511
- * console.log(`${conditions.windSpeedKph} kph / ${conditions.windSpeedMph} mph`)
512
- * ```
513
- */
514
- async getConditions(e) {
515
- const t = await this._client.request("weather.getConditions", e);
516
- if (!t.success)
517
- throw new Error(t.error || "Failed to fetch weather conditions");
518
- return t;
519
- }
520
- /**
521
- * Retrieves daily weather forecast for a specified city
522
- *
523
- * @param params - Forecast request parameters including cityId, optional language and days
524
- * @returns A promise that resolves to daily forecast data with location information
525
- * @throws {Error} If the request fails or cityId is invalid
526
- *
527
- * @example
528
- * ```typescript
529
- * // Get 5-day forecast
530
- * const forecast = await weather.getDailyForecast({ cityId: 12345 })
531
- *
532
- * // Get 10-day forecast
533
- * const forecast = await weather.getDailyForecast({ cityId: 12345, days: 10 })
534
- *
535
- * // Access forecast data
536
- * forecast.data.forEach(day => {
537
- * console.log(`${day.forecastDate}: ${day.weatherDescription}`)
538
- * console.log(`High: ${day.maxTemperatureC}°C, Low: ${day.minTemperatureC}°C`)
539
- * })
540
- * ```
541
- */
542
- async getDailyForecast(e) {
543
- const t = await this._client.request("weather.getDailyForecast", e);
544
- if (!t.success)
545
- throw new Error(t.error || "Failed to fetch daily forecast");
546
- return t;
547
- }
548
- /**
549
- * Retrieves hourly weather forecast for a specified city
550
- *
551
- * @param params - Forecast request parameters including cityId, optional language and hours
552
- * @returns A promise that resolves to hourly forecast data with location information
553
- * @throws {Error} If the request fails or cityId is invalid
554
- *
555
- * @example
556
- * ```typescript
557
- * // Get 24-hour forecast
558
- * const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 24 })
559
- *
560
- * // Get 48-hour forecast
561
- * const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 48 })
562
- *
563
- * // Access forecast data
564
- * forecast.data.forEach(hour => {
565
- * console.log(`${hour.forecastTimeLocal}: ${hour.weatherDescription}`)
566
- * console.log(`Temp: ${hour.temperatureC}°C`)
567
- * })
568
- * ```
569
- */
570
- async getHourlyForecast(e) {
571
- const t = await this._client.request("weather.getHourlyForecast", e);
572
- if (!t.success)
573
- throw new Error(t.error || "Failed to fetch hourly forecast");
574
- return t;
575
- }
576
- /**
577
- * Retrieves weather alerts and warnings for a specified city
578
- *
579
- * @param params - Alert request parameters including cityId and optional language
580
- * @returns A promise that resolves to weather alerts with location information
581
- * @throws {Error} If the request fails or cityId is invalid
582
- *
583
- * @example
584
- * ```typescript
585
- * // Get weather alerts for a city
586
- * const alerts = await weather.getAlerts({ cityId: 12345 })
587
- *
588
- * // Check if there are any active alerts
589
- * if (alerts.alerts.length > 0) {
590
- * alerts.alerts.forEach(alert => {
591
- * console.log(`${alert.severity}: ${alert.title}`)
592
- * console.log(alert.description)
593
- * })
594
- * }
595
- * ```
596
- */
597
- async getAlerts(e) {
598
- const t = await this._client.request("weather.getAlerts", e);
599
- if (!t.success)
600
- throw new Error(t.error || "Failed to fetch weather alerts");
601
- return t;
602
- }
603
- }
604
- class Je {
605
- constructor(e) {
606
- this._client = e;
607
- }
608
- /**
609
- * Retrieves all available currency symbols and their full names.
610
- *
611
- * @returns A promise that resolves to a mapping of currency codes to their full names
612
- * @throws {Error} If the request fails
613
- *
614
- * @example
615
- * ```typescript
616
- * const symbols = await currency().getSymbols()
617
- * // { "USD": "United States Dollar", "EUR": "Euro", ... }
618
- * ```
619
- */
620
- async getSymbols() {
621
- const e = await this._client.request("currency.getSymbols", {});
622
- if (!e.success || !e.symbols)
623
- throw new Error("Failed to fetch currency symbols");
624
- return e.symbols;
625
- }
626
- /**
627
- * Retrieves current exchange rates for a base currency against target currencies.
628
- *
629
- * @param params - Currency rate request parameters including base currency and target symbols
630
- * @returns A promise that resolves to a mapping of currency codes to their exchange rates
631
- * @throws {Error} If the request fails or currencies are invalid
632
- *
633
- * @example
634
- * ```typescript
635
- * // Get exchange rates for USD against EUR, GBP, and JPY
636
- * const rates = await currency().getRates({
637
- * base: 'USD',
638
- * symbols: 'EUR,GBP,JPY'
639
- * })
640
- * // { "EUR": 0.92, "GBP": 0.79, "JPY": 149.50 }
641
- * ```
642
- */
643
- async getRates(e) {
644
- var t, s, n;
645
- const r = await this._client.request("currency.getRates", e);
646
- if (!r.success || !r.rates)
647
- throw ((t = r.error) === null || t === void 0 ? void 0 : t.code) === 201 ? new Error(`Invalid base currency '${e.base}'`) : ((s = r.error) === null || s === void 0 ? void 0 : s.code) === 202 ? new Error(`Invalid target currency symbol '${e.symbols}'`) : new Error(((n = r.error) === null || n === void 0 ? void 0 : n.message) || "Failed to fetch currency rates");
648
- return r.rates;
649
- }
650
- }
651
- class Qe {
652
- constructor(e) {
653
- this._client = e;
654
- }
655
- async discover() {
656
- const e = await this._client.request("mqtt.discover", {});
657
- if (!e.success)
658
- throw new Error("Failed to discover MQTT brokers");
659
- return e.brokers;
660
- }
661
- async connect(e, t) {
662
- const s = await this._client.request("mqtt.connect", {
663
- brokerUrl: e,
664
- ...t
665
- });
666
- if (!s.success)
667
- throw new Error("Failed to connect to MQTT broker");
668
- return s.clientId;
669
- }
670
- async disconnect(e) {
671
- if (!(await this._client.request("mqtt.disconnect", { clientId: e })).success)
672
- throw new Error("Failed to disconnect from MQTT broker");
673
- }
674
- async publish(e, t, s, n) {
675
- if (!(await this._client.request("mqtt.publish", {
676
- clientId: e,
677
- topic: t,
678
- payload: s,
679
- ...n
680
- })).success)
681
- throw new Error("Failed to publish MQTT message");
682
- }
683
- async subscribe(e, t, s, n) {
684
- return (await this._client.subscribe("mqtt.subscribe", {
685
- clientId: e,
686
- topic: t,
687
- ...n
688
- }, s)).success;
689
- }
690
- async unsubscribe(e, t, s) {
691
- return (await this._client.unsubscribe("mqtt.unsubscribe", {
692
- clientId: e,
693
- topic: t
694
- }, s)).success;
695
- }
696
- async getConnectionStatus(e) {
697
- const t = await this._client.request("mqtt.getConnectionStatus", {
698
- clientId: e
699
- });
700
- if (!t.success)
701
- throw new Error("Failed to get MQTT connection status");
702
- return t.status;
703
- }
704
- async subscribeConnectionStatus(e, t) {
705
- return (await this._client.subscribe("mqtt.subscribeConnectionStatus", {
706
- clientId: e
707
- }, t)).success;
708
- }
709
- async unsubscribeConnectionStatus(e, t) {
710
- return (await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus", {
711
- clientId: e
712
- }, t)).success;
713
- }
714
- }
715
- class Ge {
716
- constructor(e) {
717
- this._originalPushState = null, this._originalReplaceState = null, this._popstateHandler = null, this._backHandler = null, this._forwardHandler = null, this._client = e;
718
- }
719
- bind() {
720
- typeof window > "u" || this._originalPushState || (this._originalPushState = history.pushState.bind(history), history.pushState = (...e) => {
721
- this._originalPushState(...e), this._sendLocationChanged();
722
- }, this._originalReplaceState = history.replaceState.bind(history), history.replaceState = (...e) => {
723
- this._originalReplaceState(...e), this._sendLocationChanged();
724
- }, this._popstateHandler = () => this._sendLocationChanged(), window.addEventListener("popstate", this._popstateHandler), this._backHandler = () => history.back(), this._forwardHandler = () => history.forward(), this._client.on("navigation.back", this._backHandler), this._client.on("navigation.forward", this._forwardHandler), this._sendLocationChanged());
725
- }
726
- unbind() {
727
- typeof window > "u" || (this._originalPushState && (history.pushState = this._originalPushState, this._originalPushState = null), this._originalReplaceState && (history.replaceState = this._originalReplaceState, this._originalReplaceState = null), this._popstateHandler && (window.removeEventListener("popstate", this._popstateHandler), this._popstateHandler = null), this._backHandler && (this._client.off("navigation.back", this._backHandler), this._backHandler = null), this._forwardHandler && (this._client.off("navigation.forward", this._forwardHandler), this._forwardHandler = null));
728
- }
729
- _sendLocationChanged() {
730
- this._client.send("navigation.locationChanged", {
731
- pathname: window.location.pathname
732
- });
733
- }
734
- }
735
- var b;
736
- (function(a) {
737
- a.assertEqual = (n) => {
738
- };
739
- function e(n) {
740
- }
741
- a.assertIs = e;
742
- function t(n) {
743
- throw new Error();
744
- }
745
- a.assertNever = t, a.arrayToEnum = (n) => {
746
- const r = {};
747
- for (const i of n)
748
- r[i] = i;
749
- return r;
750
- }, a.getValidEnumValues = (n) => {
751
- const r = a.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
752
- for (const o of r)
753
- i[o] = n[o];
754
- return a.objectValues(i);
755
- }, a.objectValues = (n) => a.objectKeys(n).map(function(r) {
756
- return n[r];
757
- }), a.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
758
- const r = [];
759
- for (const i in n)
760
- Object.prototype.hasOwnProperty.call(n, i) && r.push(i);
761
- return r;
762
- }, a.find = (n, r) => {
763
- for (const i of n)
764
- if (r(i))
765
- return i;
766
- }, a.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
767
- function s(n, r = " | ") {
768
- return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(r);
769
- }
770
- a.joinValues = s, a.jsonStringifyReplacer = (n, r) => typeof r == "bigint" ? r.toString() : r;
771
- })(b || (b = {}));
772
- var ge;
773
- (function(a) {
774
- a.mergeShapes = (e, t) => ({
775
- ...e,
776
- ...t
777
- // second overwrites first
778
- });
779
- })(ge || (ge = {}));
780
- const h = b.arrayToEnum([
781
- "string",
782
- "nan",
783
- "number",
784
- "integer",
785
- "float",
786
- "boolean",
787
- "date",
788
- "bigint",
789
- "symbol",
790
- "function",
791
- "undefined",
792
- "null",
793
- "array",
794
- "object",
795
- "unknown",
796
- "promise",
797
- "void",
798
- "never",
799
- "map",
800
- "set"
801
- ]), O = (a) => {
802
- switch (typeof a) {
803
- case "undefined":
804
- return h.undefined;
805
- case "string":
806
- return h.string;
807
- case "number":
808
- return Number.isNaN(a) ? h.nan : h.number;
809
- case "boolean":
810
- return h.boolean;
811
- case "function":
812
- return h.function;
813
- case "bigint":
814
- return h.bigint;
815
- case "symbol":
816
- return h.symbol;
817
- case "object":
818
- return Array.isArray(a) ? h.array : a === null ? h.null : a.then && typeof a.then == "function" && a.catch && typeof a.catch == "function" ? h.promise : typeof Map < "u" && a instanceof Map ? h.map : typeof Set < "u" && a instanceof Set ? h.set : typeof Date < "u" && a instanceof Date ? h.date : h.object;
819
- default:
820
- return h.unknown;
821
- }
822
- }, d = b.arrayToEnum([
823
- "invalid_type",
824
- "invalid_literal",
825
- "custom",
826
- "invalid_union",
827
- "invalid_union_discriminator",
828
- "invalid_enum_value",
829
- "unrecognized_keys",
830
- "invalid_arguments",
831
- "invalid_return_type",
832
- "invalid_date",
833
- "invalid_string",
834
- "too_small",
835
- "too_big",
836
- "invalid_intersection_types",
837
- "not_multiple_of",
838
- "not_finite"
839
- ]);
840
- class Z extends Error {
841
- get errors() {
842
- return this.issues;
843
- }
844
- constructor(e) {
845
- super(), this.issues = [], this.addIssue = (s) => {
846
- this.issues = [...this.issues, s];
847
- }, this.addIssues = (s = []) => {
848
- this.issues = [...this.issues, ...s];
849
- };
850
- const t = new.target.prototype;
851
- Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
852
- }
853
- format(e) {
854
- const t = e || function(r) {
855
- return r.message;
856
- }, s = { _errors: [] }, n = (r) => {
857
- for (const i of r.issues)
858
- if (i.code === "invalid_union")
859
- i.unionErrors.map(n);
860
- else if (i.code === "invalid_return_type")
861
- n(i.returnTypeError);
862
- else if (i.code === "invalid_arguments")
863
- n(i.argumentsError);
864
- else if (i.path.length === 0)
865
- s._errors.push(t(i));
866
- else {
867
- let o = s, c = 0;
868
- for (; c < i.path.length; ) {
869
- const l = i.path[c];
870
- c === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
871
- }
872
- }
873
- };
874
- return n(this), s;
875
- }
876
- static assert(e) {
877
- if (!(e instanceof Z))
878
- throw new Error(`Not a ZodError: ${e}`);
879
- }
880
- toString() {
881
- return this.message;
882
- }
883
- get message() {
884
- return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
885
- }
886
- get isEmpty() {
887
- return this.issues.length === 0;
888
- }
889
- flatten(e = (t) => t.message) {
890
- const t = {}, s = [];
891
- for (const n of this.issues)
892
- if (n.path.length > 0) {
893
- const r = n.path[0];
894
- t[r] = t[r] || [], t[r].push(e(n));
895
- } else
896
- s.push(e(n));
897
- return { formErrors: s, fieldErrors: t };
898
- }
899
- get formErrors() {
900
- return this.flatten();
901
- }
902
- }
903
- Z.create = (a) => new Z(a);
904
- const oe = (a, e) => {
366
+ N.create = (i) => new N(i);
367
+ const de = (i, e) => {
905
368
  let t;
906
- switch (a.code) {
369
+ switch (i.code) {
907
370
  case d.invalid_type:
908
- a.received === h.undefined ? t = "Required" : t = `Expected ${a.expected}, received ${a.received}`;
371
+ i.received === h.undefined ? t = "Required" : t = `Expected ${i.expected}, received ${i.received}`;
909
372
  break;
910
373
  case d.invalid_literal:
911
- t = `Invalid literal value, expected ${JSON.stringify(a.expected, b.jsonStringifyReplacer)}`;
374
+ t = `Invalid literal value, expected ${JSON.stringify(i.expected, b.jsonStringifyReplacer)}`;
912
375
  break;
913
376
  case d.unrecognized_keys:
914
- t = `Unrecognized key(s) in object: ${b.joinValues(a.keys, ", ")}`;
377
+ t = `Unrecognized key(s) in object: ${b.joinValues(i.keys, ", ")}`;
915
378
  break;
916
379
  case d.invalid_union:
917
380
  t = "Invalid input";
918
381
  break;
919
382
  case d.invalid_union_discriminator:
920
- t = `Invalid discriminator value. Expected ${b.joinValues(a.options)}`;
383
+ t = `Invalid discriminator value. Expected ${b.joinValues(i.options)}`;
921
384
  break;
922
385
  case d.invalid_enum_value:
923
- t = `Invalid enum value. Expected ${b.joinValues(a.options)}, received '${a.received}'`;
386
+ t = `Invalid enum value. Expected ${b.joinValues(i.options)}, received '${i.received}'`;
924
387
  break;
925
388
  case d.invalid_arguments:
926
389
  t = "Invalid function arguments";
@@ -932,13 +395,13 @@ const oe = (a, e) => {
932
395
  t = "Invalid date";
933
396
  break;
934
397
  case d.invalid_string:
935
- typeof a.validation == "object" ? "includes" in a.validation ? (t = `Invalid input: must include "${a.validation.includes}"`, typeof a.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${a.validation.position}`)) : "startsWith" in a.validation ? t = `Invalid input: must start with "${a.validation.startsWith}"` : "endsWith" in a.validation ? t = `Invalid input: must end with "${a.validation.endsWith}"` : b.assertNever(a.validation) : a.validation !== "regex" ? t = `Invalid ${a.validation}` : t = "Invalid";
398
+ typeof i.validation == "object" ? "includes" in i.validation ? (t = `Invalid input: must include "${i.validation.includes}"`, typeof i.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${i.validation.position}`)) : "startsWith" in i.validation ? t = `Invalid input: must start with "${i.validation.startsWith}"` : "endsWith" in i.validation ? t = `Invalid input: must end with "${i.validation.endsWith}"` : b.assertNever(i.validation) : i.validation !== "regex" ? t = `Invalid ${i.validation}` : t = "Invalid";
936
399
  break;
937
400
  case d.too_small:
938
- a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "more than"} ${a.minimum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "over"} ${a.minimum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "bigint" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(a.minimum))}` : t = "Invalid input";
401
+ i.type === "array" ? t = `Array must contain ${i.exact ? "exactly" : i.inclusive ? "at least" : "more than"} ${i.minimum} element(s)` : i.type === "string" ? t = `String must contain ${i.exact ? "exactly" : i.inclusive ? "at least" : "over"} ${i.minimum} character(s)` : i.type === "number" ? t = `Number must be ${i.exact ? "exactly equal to " : i.inclusive ? "greater than or equal to " : "greater than "}${i.minimum}` : i.type === "bigint" ? t = `Number must be ${i.exact ? "exactly equal to " : i.inclusive ? "greater than or equal to " : "greater than "}${i.minimum}` : i.type === "date" ? t = `Date must be ${i.exact ? "exactly equal to " : i.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(i.minimum))}` : t = "Invalid input";
939
402
  break;
940
403
  case d.too_big:
941
- a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "less than"} ${a.maximum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "under"} ${a.maximum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "bigint" ? t = `BigInt must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly" : a.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(a.maximum))}` : t = "Invalid input";
404
+ i.type === "array" ? t = `Array must contain ${i.exact ? "exactly" : i.inclusive ? "at most" : "less than"} ${i.maximum} element(s)` : i.type === "string" ? t = `String must contain ${i.exact ? "exactly" : i.inclusive ? "at most" : "under"} ${i.maximum} character(s)` : i.type === "number" ? t = `Number must be ${i.exact ? "exactly" : i.inclusive ? "less than or equal to" : "less than"} ${i.maximum}` : i.type === "bigint" ? t = `BigInt must be ${i.exact ? "exactly" : i.inclusive ? "less than or equal to" : "less than"} ${i.maximum}` : i.type === "date" ? t = `Date must be ${i.exact ? "exactly" : i.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(i.maximum))}` : t = "Invalid input";
942
405
  break;
943
406
  case d.custom:
944
407
  t = "Invalid input";
@@ -947,60 +410,60 @@ const oe = (a, e) => {
947
410
  t = "Intersection results could not be merged";
948
411
  break;
949
412
  case d.not_multiple_of:
950
- t = `Number must be a multiple of ${a.multipleOf}`;
413
+ t = `Number must be a multiple of ${i.multipleOf}`;
951
414
  break;
952
415
  case d.not_finite:
953
416
  t = "Number must be finite";
954
417
  break;
955
418
  default:
956
- t = e.defaultError, b.assertNever(a);
419
+ t = e.defaultError, b.assertNever(i);
957
420
  }
958
421
  return { message: t };
959
422
  };
960
- let Ye = oe;
961
- function Xe() {
962
- return Ye;
423
+ let Be = de;
424
+ function Ue() {
425
+ return Be;
963
426
  }
964
- const et = (a) => {
965
- const { data: e, path: t, errorMaps: s, issueData: n } = a, r = [...t, ...n.path || []], i = {
427
+ const Ke = (i) => {
428
+ const { data: e, path: t, errorMaps: s, issueData: n } = i, a = [...t, ...n.path || []], r = {
966
429
  ...n,
967
- path: r
430
+ path: a
968
431
  };
969
432
  if (n.message !== void 0)
970
433
  return {
971
434
  ...n,
972
- path: r,
435
+ path: a,
973
436
  message: n.message
974
437
  };
975
438
  let o = "";
976
439
  const c = s.filter((l) => !!l).slice().reverse();
977
440
  for (const l of c)
978
- o = l(i, { data: e, defaultError: o }).message;
441
+ o = l(r, { data: e, defaultError: o }).message;
979
442
  return {
980
443
  ...n,
981
- path: r,
444
+ path: a,
982
445
  message: o
983
446
  };
984
447
  };
985
- function u(a, e) {
986
- const t = Xe(), s = et({
448
+ function u(i, e) {
449
+ const t = Ue(), s = Ke({
987
450
  issueData: e,
988
- data: a.data,
989
- path: a.path,
451
+ data: i.data,
452
+ path: i.path,
990
453
  errorMaps: [
991
- a.common.contextualErrorMap,
454
+ i.common.contextualErrorMap,
992
455
  // contextual error map is first priority
993
- a.schemaErrorMap,
456
+ i.schemaErrorMap,
994
457
  // then schema-bound map if available
995
458
  t,
996
459
  // then global override map
997
- t === oe ? void 0 : oe
460
+ t === de ? void 0 : de
998
461
  // then global default map
999
462
  ].filter((n) => !!n)
1000
463
  });
1001
- a.common.issues.push(s);
464
+ i.common.issues.push(s);
1002
465
  }
1003
- class S {
466
+ class T {
1004
467
  constructor() {
1005
468
  this.value = "valid";
1006
469
  }
@@ -1014,7 +477,7 @@ class S {
1014
477
  const s = [];
1015
478
  for (const n of t) {
1016
479
  if (n.status === "aborted")
1017
- return _;
480
+ return g;
1018
481
  n.status === "dirty" && e.dirty(), s.push(n.value);
1019
482
  }
1020
483
  return { status: e.value, value: s };
@@ -1022,33 +485,33 @@ class S {
1022
485
  static async mergeObjectAsync(e, t) {
1023
486
  const s = [];
1024
487
  for (const n of t) {
1025
- const r = await n.key, i = await n.value;
488
+ const a = await n.key, r = await n.value;
1026
489
  s.push({
1027
- key: r,
1028
- value: i
490
+ key: a,
491
+ value: r
1029
492
  });
1030
493
  }
1031
- return S.mergeObjectSync(e, s);
494
+ return T.mergeObjectSync(e, s);
1032
495
  }
1033
496
  static mergeObjectSync(e, t) {
1034
497
  const s = {};
1035
498
  for (const n of t) {
1036
- const { key: r, value: i } = n;
1037
- if (r.status === "aborted" || i.status === "aborted")
1038
- return _;
1039
- r.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), r.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[r.value] = i.value);
499
+ const { key: a, value: r } = n;
500
+ if (a.status === "aborted" || r.status === "aborted")
501
+ return g;
502
+ a.status === "dirty" && e.dirty(), r.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof r.value < "u" || n.alwaysSet) && (s[a.value] = r.value);
1040
503
  }
1041
504
  return { status: e.value, value: s };
1042
505
  }
1043
506
  }
1044
- const _ = Object.freeze({
507
+ const g = Object.freeze({
1045
508
  status: "aborted"
1046
- }), ce = (a) => ({ status: "dirty", value: a }), C = (a) => ({ status: "valid", value: a }), ye = (a) => a.status === "aborted", ve = (a) => a.status === "dirty", q = (a) => a.status === "valid", te = (a) => typeof Promise < "u" && a instanceof Promise;
509
+ }), ue = (i) => ({ status: "dirty", value: i }), C = (i) => ({ status: "valid", value: i }), ve = (i) => i.status === "aborted", be = (i) => i.status === "dirty", q = (i) => i.status === "valid", se = (i) => typeof Promise < "u" && i instanceof Promise;
1047
510
  var p;
1048
- (function(a) {
1049
- a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
511
+ (function(i) {
512
+ i.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, i.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
1050
513
  })(p || (p = {}));
1051
- class j {
514
+ class $ {
1052
515
  constructor(e, t, s, n) {
1053
516
  this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
1054
517
  }
@@ -1056,30 +519,30 @@ class j {
1056
519
  return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
1057
520
  }
1058
521
  }
1059
- const be = (a, e) => {
522
+ const we = (i, e) => {
1060
523
  if (q(e))
1061
524
  return { success: !0, data: e.value };
1062
- if (!a.common.issues.length)
525
+ if (!i.common.issues.length)
1063
526
  throw new Error("Validation failed but no issues detected.");
1064
527
  return {
1065
528
  success: !1,
1066
529
  get error() {
1067
530
  if (this._error)
1068
531
  return this._error;
1069
- const t = new Z(a.common.issues);
532
+ const t = new N(i.common.issues);
1070
533
  return this._error = t, this._error;
1071
534
  }
1072
535
  };
1073
536
  };
1074
- function y(a) {
1075
- if (!a)
537
+ function y(i) {
538
+ if (!i)
1076
539
  return {};
1077
- const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = a;
540
+ const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = i;
1078
541
  if (e && (t || s))
1079
542
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1080
- return e ? { errorMap: e, description: n } : { errorMap: (r, i) => {
1081
- const { message: o } = a;
1082
- return r.code === "invalid_enum_value" ? { message: o ?? i.defaultError } : typeof i.data > "u" ? { message: o ?? s ?? i.defaultError } : r.code !== "invalid_type" ? { message: i.defaultError } : { message: o ?? t ?? i.defaultError };
543
+ return e ? { errorMap: e, description: n } : { errorMap: (a, r) => {
544
+ const { message: o } = i;
545
+ return a.code === "invalid_enum_value" ? { message: o ?? r.defaultError } : typeof r.data > "u" ? { message: o ?? s ?? r.defaultError } : a.code !== "invalid_type" ? { message: r.defaultError } : { message: o ?? t ?? r.defaultError };
1083
546
  }, description: n };
1084
547
  }
1085
548
  class v {
@@ -1087,13 +550,13 @@ class v {
1087
550
  return this._def.description;
1088
551
  }
1089
552
  _getType(e) {
1090
- return O(e.data);
553
+ return A(e.data);
1091
554
  }
1092
555
  _getOrReturnCtx(e, t) {
1093
556
  return t || {
1094
557
  common: e.parent.common,
1095
558
  data: e.data,
1096
- parsedType: O(e.data),
559
+ parsedType: A(e.data),
1097
560
  schemaErrorMap: this._def.errorMap,
1098
561
  path: e.path,
1099
562
  parent: e.parent
@@ -1101,11 +564,11 @@ class v {
1101
564
  }
1102
565
  _processInputParams(e) {
1103
566
  return {
1104
- status: new S(),
567
+ status: new T(),
1105
568
  ctx: {
1106
569
  common: e.parent.common,
1107
570
  data: e.data,
1108
- parsedType: O(e.data),
571
+ parsedType: A(e.data),
1109
572
  schemaErrorMap: this._def.errorMap,
1110
573
  path: e.path,
1111
574
  parent: e.parent
@@ -1114,7 +577,7 @@ class v {
1114
577
  }
1115
578
  _parseSync(e) {
1116
579
  const t = this._parse(e);
1117
- if (te(t))
580
+ if (se(t))
1118
581
  throw new Error("Synchronous parse encountered promise.");
1119
582
  return t;
1120
583
  }
@@ -1139,9 +602,9 @@ class v {
1139
602
  schemaErrorMap: this._def.errorMap,
1140
603
  parent: null,
1141
604
  data: e,
1142
- parsedType: O(e)
605
+ parsedType: A(e)
1143
606
  }, n = this._parseSync({ data: e, path: s.path, parent: s });
1144
- return be(s, n);
607
+ return we(s, n);
1145
608
  }
1146
609
  "~validate"(e) {
1147
610
  var t, s;
@@ -1154,24 +617,24 @@ class v {
1154
617
  schemaErrorMap: this._def.errorMap,
1155
618
  parent: null,
1156
619
  data: e,
1157
- parsedType: O(e)
620
+ parsedType: A(e)
1158
621
  };
1159
622
  if (!this["~standard"].async)
1160
623
  try {
1161
- const r = this._parseSync({ data: e, path: [], parent: n });
1162
- return q(r) ? {
1163
- value: r.value
624
+ const a = this._parseSync({ data: e, path: [], parent: n });
625
+ return q(a) ? {
626
+ value: a.value
1164
627
  } : {
1165
628
  issues: n.common.issues
1166
629
  };
1167
- } catch (r) {
1168
- (s = (t = r == null ? void 0 : r.message) == null ? void 0 : t.toLowerCase()) != null && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
630
+ } catch (a) {
631
+ (s = (t = a == null ? void 0 : a.message) == null ? void 0 : t.toLowerCase()) != null && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
1169
632
  issues: [],
1170
633
  async: !0
1171
634
  };
1172
635
  }
1173
- return this._parseAsync({ data: e, path: [], parent: n }).then((r) => q(r) ? {
1174
- value: r.value
636
+ return this._parseAsync({ data: e, path: [], parent: n }).then((a) => q(a) ? {
637
+ value: a.value
1175
638
  } : {
1176
639
  issues: n.common.issues
1177
640
  });
@@ -1193,27 +656,27 @@ class v {
1193
656
  schemaErrorMap: this._def.errorMap,
1194
657
  parent: null,
1195
658
  data: e,
1196
- parsedType: O(e)
1197
- }, n = this._parse({ data: e, path: s.path, parent: s }), r = await (te(n) ? n : Promise.resolve(n));
1198
- return be(s, r);
659
+ parsedType: A(e)
660
+ }, n = this._parse({ data: e, path: s.path, parent: s }), a = await (se(n) ? n : Promise.resolve(n));
661
+ return we(s, a);
1199
662
  }
1200
663
  refine(e, t) {
1201
664
  const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
1202
- return this._refinement((n, r) => {
1203
- const i = e(n), o = () => r.addIssue({
665
+ return this._refinement((n, a) => {
666
+ const r = e(n), o = () => a.addIssue({
1204
667
  code: d.custom,
1205
668
  ...s(n)
1206
669
  });
1207
- return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
670
+ return typeof Promise < "u" && r instanceof Promise ? r.then((c) => c ? !0 : (o(), !1)) : r ? !0 : (o(), !1);
1208
671
  });
1209
672
  }
1210
673
  refinement(e, t) {
1211
674
  return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
1212
675
  }
1213
676
  _refinement(e) {
1214
- return new H({
677
+ return new L({
1215
678
  schema: this,
1216
- typeName: m.ZodEffects,
679
+ typeName: _.ZodEffects,
1217
680
  effect: { type: "refinement", refinement: e }
1218
681
  });
1219
682
  }
@@ -1231,54 +694,54 @@ class v {
1231
694
  return E.create(this, this._def);
1232
695
  }
1233
696
  nullable() {
1234
- return V.create(this, this._def);
697
+ return D.create(this, this._def);
1235
698
  }
1236
699
  nullish() {
1237
700
  return this.nullable().optional();
1238
701
  }
1239
702
  array() {
1240
- return N.create(this);
703
+ return I.create(this);
1241
704
  }
1242
705
  promise() {
1243
706
  return re.create(this, this._def);
1244
707
  }
1245
708
  or(e) {
1246
- return ne.create([this, e], this._def);
709
+ return ie.create([this, e], this._def);
1247
710
  }
1248
711
  and(e) {
1249
712
  return ae.create(this, e, this._def);
1250
713
  }
1251
714
  transform(e) {
1252
- return new H({
715
+ return new L({
1253
716
  ...y(this._def),
1254
717
  schema: this,
1255
- typeName: m.ZodEffects,
718
+ typeName: _.ZodEffects,
1256
719
  effect: { type: "transform", transform: e }
1257
720
  });
1258
721
  }
1259
722
  default(e) {
1260
723
  const t = typeof e == "function" ? e : () => e;
1261
- return new he({
724
+ return new fe({
1262
725
  ...y(this._def),
1263
726
  innerType: this,
1264
727
  defaultValue: t,
1265
- typeName: m.ZodDefault
728
+ typeName: _.ZodDefault
1266
729
  });
1267
730
  }
1268
731
  brand() {
1269
- return new xt({
1270
- typeName: m.ZodBranded,
732
+ return new _t({
733
+ typeName: _.ZodBranded,
1271
734
  type: this,
1272
735
  ...y(this._def)
1273
736
  });
1274
737
  }
1275
738
  catch(e) {
1276
739
  const t = typeof e == "function" ? e : () => e;
1277
- return new pe({
740
+ return new me({
1278
741
  ...y(this._def),
1279
742
  innerType: this,
1280
743
  catchValue: t,
1281
- typeName: m.ZodCatch
744
+ typeName: _.ZodCatch
1282
745
  });
1283
746
  }
1284
747
  describe(e) {
@@ -1289,10 +752,10 @@ class v {
1289
752
  });
1290
753
  }
1291
754
  pipe(e) {
1292
- return me.create(this, e);
755
+ return ge.create(this, e);
1293
756
  }
1294
757
  readonly() {
1295
- return fe.create(this);
758
+ return _e.create(this);
1296
759
  }
1297
760
  isOptional() {
1298
761
  return this.safeParse(void 0).success;
@@ -1301,31 +764,31 @@ class v {
1301
764
  return this.safeParse(null).success;
1302
765
  }
1303
766
  }
1304
- const tt = /^c[^\s-]{8,}$/i, st = /^[0-9a-z]+$/, nt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, at = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, rt = /^[a-z0-9_-]{21}$/i, it = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ot = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, ct = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, dt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1305
- let ie;
1306
- const ut = /^(?:(?: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])$/, lt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, ht = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, pt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, ft = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, mt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ie = "((\\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])))", _t = new RegExp(`^${Ie}$`);
1307
- function Ee(a) {
767
+ const We = /^c[^\s-]{8,}$/i, Je = /^[0-9a-z]+$/, Qe = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Ge = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Ye = /^[a-z0-9_-]{21}$/i, Xe = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, et = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, tt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, st = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
768
+ let ce;
769
+ const nt = /^(?:(?: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])$/, it = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, at = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, rt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, ot = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, ct = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ee = "((\\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])))", dt = new RegExp(`^${Ee}$`);
770
+ function $e(i) {
1308
771
  let e = "[0-5]\\d";
1309
- a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`);
1310
- const t = a.precision ? "+" : "?";
772
+ i.precision ? e = `${e}\\.\\d{${i.precision}}` : i.precision == null && (e = `${e}(\\.\\d+)?`);
773
+ const t = i.precision ? "+" : "?";
1311
774
  return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
1312
775
  }
1313
- function gt(a) {
1314
- return new RegExp(`^${Ee(a)}$`);
776
+ function ut(i) {
777
+ return new RegExp(`^${$e(i)}$`);
1315
778
  }
1316
- function yt(a) {
1317
- let e = `${Ie}T${Ee(a)}`;
779
+ function lt(i) {
780
+ let e = `${Ee}T${$e(i)}`;
1318
781
  const t = [];
1319
- return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
782
+ return t.push(i.local ? "Z?" : "Z"), i.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
1320
783
  }
1321
- function vt(a, e) {
1322
- return !!((e === "v4" || !e) && ut.test(a) || (e === "v6" || !e) && ht.test(a));
784
+ function ht(i, e) {
785
+ return !!((e === "v4" || !e) && nt.test(i) || (e === "v6" || !e) && at.test(i));
1323
786
  }
1324
- function bt(a, e) {
1325
- if (!it.test(a))
787
+ function pt(i, e) {
788
+ if (!Xe.test(i))
1326
789
  return !1;
1327
790
  try {
1328
- const [t] = a.split(".");
791
+ const [t] = i.split(".");
1329
792
  if (!t)
1330
793
  return !1;
1331
794
  const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
@@ -1334,10 +797,10 @@ function bt(a, e) {
1334
797
  return !1;
1335
798
  }
1336
799
  }
1337
- function wt(a, e) {
1338
- return !!((e === "v4" || !e) && lt.test(a) || (e === "v6" || !e) && pt.test(a));
800
+ function ft(i, e) {
801
+ return !!((e === "v4" || !e) && it.test(i) || (e === "v6" || !e) && rt.test(i));
1339
802
  }
1340
- class I extends v {
803
+ class O extends v {
1341
804
  _parse(e) {
1342
805
  if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
1343
806
  const n = this._getOrReturnCtx(e);
@@ -1345,9 +808,9 @@ class I extends v {
1345
808
  code: d.invalid_type,
1346
809
  expected: h.string,
1347
810
  received: n.parsedType
1348
- }), _;
811
+ }), g;
1349
812
  }
1350
- const t = new S();
813
+ const t = new T();
1351
814
  let s;
1352
815
  for (const n of this._def.checks)
1353
816
  if (n.kind === "min")
@@ -1369,15 +832,15 @@ class I extends v {
1369
832
  message: n.message
1370
833
  }), t.dirty());
1371
834
  else if (n.kind === "length") {
1372
- const r = e.data.length > n.value, i = e.data.length < n.value;
1373
- (r || i) && (s = this._getOrReturnCtx(e, s), r ? u(s, {
835
+ const a = e.data.length > n.value, r = e.data.length < n.value;
836
+ (a || r) && (s = this._getOrReturnCtx(e, s), a ? u(s, {
1374
837
  code: d.too_big,
1375
838
  maximum: n.value,
1376
839
  type: "string",
1377
840
  inclusive: !0,
1378
841
  exact: !0,
1379
842
  message: n.message
1380
- }) : i && u(s, {
843
+ }) : r && u(s, {
1381
844
  code: d.too_small,
1382
845
  minimum: n.value,
1383
846
  type: "string",
@@ -1386,43 +849,43 @@ class I extends v {
1386
849
  message: n.message
1387
850
  }), t.dirty());
1388
851
  } else if (n.kind === "email")
1389
- ct.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
852
+ tt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1390
853
  validation: "email",
1391
854
  code: d.invalid_string,
1392
855
  message: n.message
1393
856
  }), t.dirty());
1394
857
  else if (n.kind === "emoji")
1395
- ie || (ie = new RegExp(dt, "u")), ie.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
858
+ ce || (ce = new RegExp(st, "u")), ce.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1396
859
  validation: "emoji",
1397
860
  code: d.invalid_string,
1398
861
  message: n.message
1399
862
  }), t.dirty());
1400
863
  else if (n.kind === "uuid")
1401
- at.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
864
+ Ge.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1402
865
  validation: "uuid",
1403
866
  code: d.invalid_string,
1404
867
  message: n.message
1405
868
  }), t.dirty());
1406
869
  else if (n.kind === "nanoid")
1407
- rt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
870
+ Ye.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1408
871
  validation: "nanoid",
1409
872
  code: d.invalid_string,
1410
873
  message: n.message
1411
874
  }), t.dirty());
1412
875
  else if (n.kind === "cuid")
1413
- tt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
876
+ We.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1414
877
  validation: "cuid",
1415
878
  code: d.invalid_string,
1416
879
  message: n.message
1417
880
  }), t.dirty());
1418
881
  else if (n.kind === "cuid2")
1419
- st.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
882
+ Je.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1420
883
  validation: "cuid2",
1421
884
  code: d.invalid_string,
1422
885
  message: n.message
1423
886
  }), t.dirty());
1424
887
  else if (n.kind === "ulid")
1425
- nt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
888
+ Qe.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1426
889
  validation: "ulid",
1427
890
  code: d.invalid_string,
1428
891
  message: n.message
@@ -1453,39 +916,39 @@ class I extends v {
1453
916
  code: d.invalid_string,
1454
917
  validation: { endsWith: n.value },
1455
918
  message: n.message
1456
- }), t.dirty()) : n.kind === "datetime" ? yt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
919
+ }), t.dirty()) : n.kind === "datetime" ? lt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1457
920
  code: d.invalid_string,
1458
921
  validation: "datetime",
1459
922
  message: n.message
1460
- }), t.dirty()) : n.kind === "date" ? _t.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
923
+ }), t.dirty()) : n.kind === "date" ? dt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1461
924
  code: d.invalid_string,
1462
925
  validation: "date",
1463
926
  message: n.message
1464
- }), t.dirty()) : n.kind === "time" ? gt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
927
+ }), t.dirty()) : n.kind === "time" ? ut(n).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1465
928
  code: d.invalid_string,
1466
929
  validation: "time",
1467
930
  message: n.message
1468
- }), t.dirty()) : n.kind === "duration" ? ot.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
931
+ }), t.dirty()) : n.kind === "duration" ? et.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1469
932
  validation: "duration",
1470
933
  code: d.invalid_string,
1471
934
  message: n.message
1472
- }), t.dirty()) : n.kind === "ip" ? vt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), u(s, {
935
+ }), t.dirty()) : n.kind === "ip" ? ht(e.data, n.version) || (s = this._getOrReturnCtx(e, s), u(s, {
1473
936
  validation: "ip",
1474
937
  code: d.invalid_string,
1475
938
  message: n.message
1476
- }), t.dirty()) : n.kind === "jwt" ? bt(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), u(s, {
939
+ }), t.dirty()) : n.kind === "jwt" ? pt(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), u(s, {
1477
940
  validation: "jwt",
1478
941
  code: d.invalid_string,
1479
942
  message: n.message
1480
- }), t.dirty()) : n.kind === "cidr" ? wt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), u(s, {
943
+ }), t.dirty()) : n.kind === "cidr" ? ft(e.data, n.version) || (s = this._getOrReturnCtx(e, s), u(s, {
1481
944
  validation: "cidr",
1482
945
  code: d.invalid_string,
1483
946
  message: n.message
1484
- }), t.dirty()) : n.kind === "base64" ? ft.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
947
+ }), t.dirty()) : n.kind === "base64" ? ot.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1485
948
  validation: "base64",
1486
949
  code: d.invalid_string,
1487
950
  message: n.message
1488
- }), t.dirty()) : n.kind === "base64url" ? mt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
951
+ }), t.dirty()) : n.kind === "base64url" ? ct.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1489
952
  validation: "base64url",
1490
953
  code: d.invalid_string,
1491
954
  message: n.message
@@ -1500,7 +963,7 @@ class I extends v {
1500
963
  });
1501
964
  }
1502
965
  _addCheck(e) {
1503
- return new I({
966
+ return new O({
1504
967
  ...this._def,
1505
968
  checks: [...this._def.checks, e]
1506
969
  });
@@ -1636,19 +1099,19 @@ class I extends v {
1636
1099
  return this.min(1, p.errToObj(e));
1637
1100
  }
1638
1101
  trim() {
1639
- return new I({
1102
+ return new O({
1640
1103
  ...this._def,
1641
1104
  checks: [...this._def.checks, { kind: "trim" }]
1642
1105
  });
1643
1106
  }
1644
1107
  toLowerCase() {
1645
- return new I({
1108
+ return new O({
1646
1109
  ...this._def,
1647
1110
  checks: [...this._def.checks, { kind: "toLowerCase" }]
1648
1111
  });
1649
1112
  }
1650
1113
  toUpperCase() {
1651
- return new I({
1114
+ return new O({
1652
1115
  ...this._def,
1653
1116
  checks: [...this._def.checks, { kind: "toUpperCase" }]
1654
1117
  });
@@ -1714,17 +1177,17 @@ class I extends v {
1714
1177
  return e;
1715
1178
  }
1716
1179
  }
1717
- I.create = (a) => new I({
1180
+ O.create = (i) => new O({
1718
1181
  checks: [],
1719
- typeName: m.ZodString,
1720
- coerce: (a == null ? void 0 : a.coerce) ?? !1,
1721
- ...y(a)
1182
+ typeName: _.ZodString,
1183
+ coerce: (i == null ? void 0 : i.coerce) ?? !1,
1184
+ ...y(i)
1722
1185
  });
1723
- function kt(a, e) {
1724
- const t = (a.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, r = Number.parseInt(a.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
1725
- return r % i / 10 ** n;
1186
+ function mt(i, e) {
1187
+ const t = (i.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, a = Number.parseInt(i.toFixed(n).replace(".", "")), r = Number.parseInt(e.toFixed(n).replace(".", ""));
1188
+ return a % r / 10 ** n;
1726
1189
  }
1727
- class W extends v {
1190
+ class J extends v {
1728
1191
  constructor() {
1729
1192
  super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1730
1193
  }
@@ -1735,10 +1198,10 @@ class W extends v {
1735
1198
  code: d.invalid_type,
1736
1199
  expected: h.number,
1737
1200
  received: n.parsedType
1738
- }), _;
1201
+ }), g;
1739
1202
  }
1740
1203
  let t;
1741
- const s = new S();
1204
+ const s = new T();
1742
1205
  for (const n of this._def.checks)
1743
1206
  n.kind === "int" ? b.isInteger(e.data) || (t = this._getOrReturnCtx(e, t), u(t, {
1744
1207
  code: d.invalid_type,
@@ -1759,7 +1222,7 @@ class W extends v {
1759
1222
  inclusive: n.inclusive,
1760
1223
  exact: !1,
1761
1224
  message: n.message
1762
- }), s.dirty()) : n.kind === "multipleOf" ? kt(e.data, n.value) !== 0 && (t = this._getOrReturnCtx(e, t), u(t, {
1225
+ }), s.dirty()) : n.kind === "multipleOf" ? mt(e.data, n.value) !== 0 && (t = this._getOrReturnCtx(e, t), u(t, {
1763
1226
  code: d.not_multiple_of,
1764
1227
  multipleOf: n.value,
1765
1228
  message: n.message
@@ -1782,7 +1245,7 @@ class W extends v {
1782
1245
  return this.setLimit("max", e, !1, p.toString(t));
1783
1246
  }
1784
1247
  setLimit(e, t, s, n) {
1785
- return new W({
1248
+ return new J({
1786
1249
  ...this._def,
1787
1250
  checks: [
1788
1251
  ...this._def.checks,
@@ -1796,7 +1259,7 @@ class W extends v {
1796
1259
  });
1797
1260
  }
1798
1261
  _addCheck(e) {
1799
- return new W({
1262
+ return new J({
1800
1263
  ...this._def,
1801
1264
  checks: [...this._def.checks, e]
1802
1265
  });
@@ -1890,13 +1353,13 @@ class W extends v {
1890
1353
  return Number.isFinite(t) && Number.isFinite(e);
1891
1354
  }
1892
1355
  }
1893
- W.create = (a) => new W({
1356
+ J.create = (i) => new J({
1894
1357
  checks: [],
1895
- typeName: m.ZodNumber,
1896
- coerce: (a == null ? void 0 : a.coerce) || !1,
1897
- ...y(a)
1358
+ typeName: _.ZodNumber,
1359
+ coerce: (i == null ? void 0 : i.coerce) || !1,
1360
+ ...y(i)
1898
1361
  });
1899
- class J extends v {
1362
+ class Q extends v {
1900
1363
  constructor() {
1901
1364
  super(...arguments), this.min = this.gte, this.max = this.lte;
1902
1365
  }
@@ -1910,7 +1373,7 @@ class J extends v {
1910
1373
  if (this._getType(e) !== h.bigint)
1911
1374
  return this._getInvalidInput(e);
1912
1375
  let t;
1913
- const s = new S();
1376
+ const s = new T();
1914
1377
  for (const n of this._def.checks)
1915
1378
  n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), u(t, {
1916
1379
  code: d.too_small,
@@ -1937,7 +1400,7 @@ class J extends v {
1937
1400
  code: d.invalid_type,
1938
1401
  expected: h.bigint,
1939
1402
  received: t.parsedType
1940
- }), _;
1403
+ }), g;
1941
1404
  }
1942
1405
  gte(e, t) {
1943
1406
  return this.setLimit("min", e, !0, p.toString(t));
@@ -1952,7 +1415,7 @@ class J extends v {
1952
1415
  return this.setLimit("max", e, !1, p.toString(t));
1953
1416
  }
1954
1417
  setLimit(e, t, s, n) {
1955
- return new J({
1418
+ return new Q({
1956
1419
  ...this._def,
1957
1420
  checks: [
1958
1421
  ...this._def.checks,
@@ -1966,7 +1429,7 @@ class J extends v {
1966
1429
  });
1967
1430
  }
1968
1431
  _addCheck(e) {
1969
- return new J({
1432
+ return new Q({
1970
1433
  ...this._def,
1971
1434
  checks: [...this._def.checks, e]
1972
1435
  });
@@ -2023,13 +1486,13 @@ class J extends v {
2023
1486
  return e;
2024
1487
  }
2025
1488
  }
2026
- J.create = (a) => new J({
1489
+ Q.create = (i) => new Q({
2027
1490
  checks: [],
2028
- typeName: m.ZodBigInt,
2029
- coerce: (a == null ? void 0 : a.coerce) ?? !1,
2030
- ...y(a)
1491
+ typeName: _.ZodBigInt,
1492
+ coerce: (i == null ? void 0 : i.coerce) ?? !1,
1493
+ ...y(i)
2031
1494
  });
2032
- class we extends v {
1495
+ class ke extends v {
2033
1496
  _parse(e) {
2034
1497
  if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
2035
1498
  const t = this._getOrReturnCtx(e);
@@ -2037,17 +1500,17 @@ class we extends v {
2037
1500
  code: d.invalid_type,
2038
1501
  expected: h.boolean,
2039
1502
  received: t.parsedType
2040
- }), _;
1503
+ }), g;
2041
1504
  }
2042
1505
  return C(e.data);
2043
1506
  }
2044
1507
  }
2045
- we.create = (a) => new we({
2046
- typeName: m.ZodBoolean,
2047
- coerce: (a == null ? void 0 : a.coerce) || !1,
2048
- ...y(a)
1508
+ ke.create = (i) => new ke({
1509
+ typeName: _.ZodBoolean,
1510
+ coerce: (i == null ? void 0 : i.coerce) || !1,
1511
+ ...y(i)
2049
1512
  });
2050
- class se extends v {
1513
+ class ne extends v {
2051
1514
  _parse(e) {
2052
1515
  if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
2053
1516
  const n = this._getOrReturnCtx(e);
@@ -2055,15 +1518,15 @@ class se extends v {
2055
1518
  code: d.invalid_type,
2056
1519
  expected: h.date,
2057
1520
  received: n.parsedType
2058
- }), _;
1521
+ }), g;
2059
1522
  }
2060
1523
  if (Number.isNaN(e.data.getTime())) {
2061
1524
  const n = this._getOrReturnCtx(e);
2062
1525
  return u(n, {
2063
1526
  code: d.invalid_date
2064
- }), _;
1527
+ }), g;
2065
1528
  }
2066
- const t = new S();
1529
+ const t = new T();
2067
1530
  let s;
2068
1531
  for (const n of this._def.checks)
2069
1532
  n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), u(s, {
@@ -2087,7 +1550,7 @@ class se extends v {
2087
1550
  };
2088
1551
  }
2089
1552
  _addCheck(e) {
2090
- return new se({
1553
+ return new ne({
2091
1554
  ...this._def,
2092
1555
  checks: [...this._def.checks, e]
2093
1556
  });
@@ -2119,13 +1582,13 @@ class se extends v {
2119
1582
  return e != null ? new Date(e) : null;
2120
1583
  }
2121
1584
  }
2122
- se.create = (a) => new se({
1585
+ ne.create = (i) => new ne({
2123
1586
  checks: [],
2124
- coerce: (a == null ? void 0 : a.coerce) || !1,
2125
- typeName: m.ZodDate,
2126
- ...y(a)
1587
+ coerce: (i == null ? void 0 : i.coerce) || !1,
1588
+ typeName: _.ZodDate,
1589
+ ...y(i)
2127
1590
  });
2128
- class ke extends v {
1591
+ class xe extends v {
2129
1592
  _parse(e) {
2130
1593
  if (this._getType(e) !== h.symbol) {
2131
1594
  const t = this._getOrReturnCtx(e);
@@ -2133,16 +1596,16 @@ class ke extends v {
2133
1596
  code: d.invalid_type,
2134
1597
  expected: h.symbol,
2135
1598
  received: t.parsedType
2136
- }), _;
1599
+ }), g;
2137
1600
  }
2138
1601
  return C(e.data);
2139
1602
  }
2140
1603
  }
2141
- ke.create = (a) => new ke({
2142
- typeName: m.ZodSymbol,
2143
- ...y(a)
1604
+ xe.create = (i) => new xe({
1605
+ typeName: _.ZodSymbol,
1606
+ ...y(i)
2144
1607
  });
2145
- class xe extends v {
1608
+ class Se extends v {
2146
1609
  _parse(e) {
2147
1610
  if (this._getType(e) !== h.undefined) {
2148
1611
  const t = this._getOrReturnCtx(e);
@@ -2150,16 +1613,16 @@ class xe extends v {
2150
1613
  code: d.invalid_type,
2151
1614
  expected: h.undefined,
2152
1615
  received: t.parsedType
2153
- }), _;
1616
+ }), g;
2154
1617
  }
2155
1618
  return C(e.data);
2156
1619
  }
2157
1620
  }
2158
- xe.create = (a) => new xe({
2159
- typeName: m.ZodUndefined,
2160
- ...y(a)
1621
+ Se.create = (i) => new Se({
1622
+ typeName: _.ZodUndefined,
1623
+ ...y(i)
2161
1624
  });
2162
- class Se extends v {
1625
+ class Te extends v {
2163
1626
  _parse(e) {
2164
1627
  if (this._getType(e) !== h.null) {
2165
1628
  const t = this._getOrReturnCtx(e);
@@ -2167,16 +1630,16 @@ class Se extends v {
2167
1630
  code: d.invalid_type,
2168
1631
  expected: h.null,
2169
1632
  received: t.parsedType
2170
- }), _;
1633
+ }), g;
2171
1634
  }
2172
1635
  return C(e.data);
2173
1636
  }
2174
1637
  }
2175
- Se.create = (a) => new Se({
2176
- typeName: m.ZodNull,
2177
- ...y(a)
1638
+ Te.create = (i) => new Te({
1639
+ typeName: _.ZodNull,
1640
+ ...y(i)
2178
1641
  });
2179
- class de extends v {
1642
+ class le extends v {
2180
1643
  constructor() {
2181
1644
  super(...arguments), this._any = !0;
2182
1645
  }
@@ -2184,9 +1647,9 @@ class de extends v {
2184
1647
  return C(e.data);
2185
1648
  }
2186
1649
  }
2187
- de.create = (a) => new de({
2188
- typeName: m.ZodAny,
2189
- ...y(a)
1650
+ le.create = (i) => new le({
1651
+ typeName: _.ZodAny,
1652
+ ...y(i)
2190
1653
  });
2191
1654
  class Ce extends v {
2192
1655
  constructor() {
@@ -2196,9 +1659,9 @@ class Ce extends v {
2196
1659
  return C(e.data);
2197
1660
  }
2198
1661
  }
2199
- Ce.create = (a) => new Ce({
2200
- typeName: m.ZodUnknown,
2201
- ...y(a)
1662
+ Ce.create = (i) => new Ce({
1663
+ typeName: _.ZodUnknown,
1664
+ ...y(i)
2202
1665
  });
2203
1666
  class P extends v {
2204
1667
  _parse(e) {
@@ -2207,14 +1670,14 @@ class P extends v {
2207
1670
  code: d.invalid_type,
2208
1671
  expected: h.never,
2209
1672
  received: t.parsedType
2210
- }), _;
1673
+ }), g;
2211
1674
  }
2212
1675
  }
2213
- P.create = (a) => new P({
2214
- typeName: m.ZodNever,
2215
- ...y(a)
1676
+ P.create = (i) => new P({
1677
+ typeName: _.ZodNever,
1678
+ ...y(i)
2216
1679
  });
2217
- class Te extends v {
1680
+ class Ie extends v {
2218
1681
  _parse(e) {
2219
1682
  if (this._getType(e) !== h.undefined) {
2220
1683
  const t = this._getOrReturnCtx(e);
@@ -2222,16 +1685,16 @@ class Te extends v {
2222
1685
  code: d.invalid_type,
2223
1686
  expected: h.void,
2224
1687
  received: t.parsedType
2225
- }), _;
1688
+ }), g;
2226
1689
  }
2227
1690
  return C(e.data);
2228
1691
  }
2229
1692
  }
2230
- Te.create = (a) => new Te({
2231
- typeName: m.ZodVoid,
2232
- ...y(a)
1693
+ Ie.create = (i) => new Ie({
1694
+ typeName: _.ZodVoid,
1695
+ ...y(i)
2233
1696
  });
2234
- class N extends v {
1697
+ class I extends v {
2235
1698
  _parse(e) {
2236
1699
  const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
2237
1700
  if (t.parsedType !== h.array)
@@ -2239,13 +1702,13 @@ class N extends v {
2239
1702
  code: d.invalid_type,
2240
1703
  expected: h.array,
2241
1704
  received: t.parsedType
2242
- }), _;
1705
+ }), g;
2243
1706
  if (n.exactLength !== null) {
2244
- const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
2245
- (i || o) && (u(t, {
2246
- code: i ? d.too_big : d.too_small,
1707
+ const r = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
1708
+ (r || o) && (u(t, {
1709
+ code: r ? d.too_big : d.too_small,
2247
1710
  minimum: o ? n.exactLength.value : void 0,
2248
- maximum: i ? n.exactLength.value : void 0,
1711
+ maximum: r ? n.exactLength.value : void 0,
2249
1712
  type: "array",
2250
1713
  inclusive: !0,
2251
1714
  exact: !0,
@@ -2267,27 +1730,27 @@ class N extends v {
2267
1730
  exact: !1,
2268
1731
  message: n.maxLength.message
2269
1732
  }), s.dirty()), t.common.async)
2270
- return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new j(t, i, t.path, o)))).then((i) => S.mergeArray(s, i));
2271
- const r = [...t.data].map((i, o) => n.type._parseSync(new j(t, i, t.path, o)));
2272
- return S.mergeArray(s, r);
1733
+ return Promise.all([...t.data].map((r, o) => n.type._parseAsync(new $(t, r, t.path, o)))).then((r) => T.mergeArray(s, r));
1734
+ const a = [...t.data].map((r, o) => n.type._parseSync(new $(t, r, t.path, o)));
1735
+ return T.mergeArray(s, a);
2273
1736
  }
2274
1737
  get element() {
2275
1738
  return this._def.type;
2276
1739
  }
2277
1740
  min(e, t) {
2278
- return new N({
1741
+ return new I({
2279
1742
  ...this._def,
2280
1743
  minLength: { value: e, message: p.toString(t) }
2281
1744
  });
2282
1745
  }
2283
1746
  max(e, t) {
2284
- return new N({
1747
+ return new I({
2285
1748
  ...this._def,
2286
1749
  maxLength: { value: e, message: p.toString(t) }
2287
1750
  });
2288
1751
  }
2289
1752
  length(e, t) {
2290
- return new N({
1753
+ return new I({
2291
1754
  ...this._def,
2292
1755
  exactLength: { value: e, message: p.toString(t) }
2293
1756
  });
@@ -2296,29 +1759,29 @@ class N extends v {
2296
1759
  return this.min(1, e);
2297
1760
  }
2298
1761
  }
2299
- N.create = (a, e) => new N({
2300
- type: a,
1762
+ I.create = (i, e) => new I({
1763
+ type: i,
2301
1764
  minLength: null,
2302
1765
  maxLength: null,
2303
1766
  exactLength: null,
2304
- typeName: m.ZodArray,
1767
+ typeName: _.ZodArray,
2305
1768
  ...y(e)
2306
1769
  });
2307
- function M(a) {
2308
- if (a instanceof k) {
1770
+ function M(i) {
1771
+ if (i instanceof k) {
2309
1772
  const e = {};
2310
- for (const t in a.shape) {
2311
- const s = a.shape[t];
1773
+ for (const t in i.shape) {
1774
+ const s = i.shape[t];
2312
1775
  e[t] = E.create(M(s));
2313
1776
  }
2314
1777
  return new k({
2315
- ...a._def,
1778
+ ...i._def,
2316
1779
  shape: () => e
2317
1780
  });
2318
- } else return a instanceof N ? new N({
2319
- ...a._def,
2320
- type: M(a.element)
2321
- }) : a instanceof E ? E.create(M(a.unwrap())) : a instanceof V ? V.create(M(a.unwrap())) : a instanceof $ ? $.create(a.items.map((e) => M(e))) : a;
1781
+ } else return i instanceof I ? new I({
1782
+ ...i._def,
1783
+ type: M(i.element)
1784
+ }) : i instanceof E ? E.create(M(i.unwrap())) : i instanceof D ? D.create(M(i.unwrap())) : i instanceof R ? R.create(i.items.map((e) => M(e))) : i;
2322
1785
  }
2323
1786
  class k extends v {
2324
1787
  constructor() {
@@ -2337,43 +1800,43 @@ class k extends v {
2337
1800
  code: d.invalid_type,
2338
1801
  expected: h.object,
2339
1802
  received: c.parsedType
2340
- }), _;
1803
+ }), g;
2341
1804
  }
2342
- const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: r } = this._getCached(), i = [];
1805
+ const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: a } = this._getCached(), r = [];
2343
1806
  if (!(this._def.catchall instanceof P && this._def.unknownKeys === "strip"))
2344
1807
  for (const c in s.data)
2345
- r.includes(c) || i.push(c);
1808
+ a.includes(c) || r.push(c);
2346
1809
  const o = [];
2347
- for (const c of r) {
2348
- const l = n[c], g = s.data[c];
1810
+ for (const c of a) {
1811
+ const l = n[c], f = s.data[c];
2349
1812
  o.push({
2350
1813
  key: { status: "valid", value: c },
2351
- value: l._parse(new j(s, g, s.path, c)),
1814
+ value: l._parse(new $(s, f, s.path, c)),
2352
1815
  alwaysSet: c in s.data
2353
1816
  });
2354
1817
  }
2355
1818
  if (this._def.catchall instanceof P) {
2356
1819
  const c = this._def.unknownKeys;
2357
1820
  if (c === "passthrough")
2358
- for (const l of i)
1821
+ for (const l of r)
2359
1822
  o.push({
2360
1823
  key: { status: "valid", value: l },
2361
1824
  value: { status: "valid", value: s.data[l] }
2362
1825
  });
2363
1826
  else if (c === "strict")
2364
- i.length > 0 && (u(s, {
1827
+ r.length > 0 && (u(s, {
2365
1828
  code: d.unrecognized_keys,
2366
- keys: i
1829
+ keys: r
2367
1830
  }), t.dirty());
2368
1831
  else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
2369
1832
  } else {
2370
1833
  const c = this._def.catchall;
2371
- for (const l of i) {
2372
- const g = s.data[l];
1834
+ for (const l of r) {
1835
+ const f = s.data[l];
2373
1836
  o.push({
2374
1837
  key: { status: "valid", value: l },
2375
1838
  value: c._parse(
2376
- new j(s, g, s.path, l)
1839
+ new $(s, f, s.path, l)
2377
1840
  //, ctx.child(key), value, getParsedType(value)
2378
1841
  ),
2379
1842
  alwaysSet: l in s.data
@@ -2383,15 +1846,15 @@ class k extends v {
2383
1846
  return s.common.async ? Promise.resolve().then(async () => {
2384
1847
  const c = [];
2385
1848
  for (const l of o) {
2386
- const g = await l.key, w = await l.value;
1849
+ const f = await l.key, w = await l.value;
2387
1850
  c.push({
2388
- key: g,
1851
+ key: f,
2389
1852
  value: w,
2390
1853
  alwaysSet: l.alwaysSet
2391
1854
  });
2392
1855
  }
2393
1856
  return c;
2394
- }).then((c) => S.mergeObjectSync(t, c)) : S.mergeObjectSync(t, o);
1857
+ }).then((c) => T.mergeObjectSync(t, c)) : T.mergeObjectSync(t, o);
2395
1858
  }
2396
1859
  get shape() {
2397
1860
  return this._def.shape();
@@ -2402,12 +1865,12 @@ class k extends v {
2402
1865
  unknownKeys: "strict",
2403
1866
  ...e !== void 0 ? {
2404
1867
  errorMap: (t, s) => {
2405
- var n, r;
2406
- const i = ((r = (n = this._def).errorMap) == null ? void 0 : r.call(n, t, s).message) ?? s.defaultError;
1868
+ var n, a;
1869
+ const r = ((a = (n = this._def).errorMap) == null ? void 0 : a.call(n, t, s).message) ?? s.defaultError;
2407
1870
  return t.code === "unrecognized_keys" ? {
2408
- message: p.errToObj(e).message ?? i
1871
+ message: p.errToObj(e).message ?? r
2409
1872
  } : {
2410
- message: i
1873
+ message: r
2411
1874
  };
2412
1875
  }
2413
1876
  } : {}
@@ -2464,7 +1927,7 @@ class k extends v {
2464
1927
  ...this._def.shape(),
2465
1928
  ...e._def.shape()
2466
1929
  }),
2467
- typeName: m.ZodObject
1930
+ typeName: _.ZodObject
2468
1931
  });
2469
1932
  }
2470
1933
  // merge<
@@ -2584,49 +2047,49 @@ class k extends v {
2584
2047
  });
2585
2048
  }
2586
2049
  keyof() {
2587
- return je(b.objectKeys(this.shape));
2050
+ return Pe(b.objectKeys(this.shape));
2588
2051
  }
2589
2052
  }
2590
- k.create = (a, e) => new k({
2591
- shape: () => a,
2053
+ k.create = (i, e) => new k({
2054
+ shape: () => i,
2592
2055
  unknownKeys: "strip",
2593
2056
  catchall: P.create(),
2594
- typeName: m.ZodObject,
2057
+ typeName: _.ZodObject,
2595
2058
  ...y(e)
2596
2059
  });
2597
- k.strictCreate = (a, e) => new k({
2598
- shape: () => a,
2060
+ k.strictCreate = (i, e) => new k({
2061
+ shape: () => i,
2599
2062
  unknownKeys: "strict",
2600
2063
  catchall: P.create(),
2601
- typeName: m.ZodObject,
2064
+ typeName: _.ZodObject,
2602
2065
  ...y(e)
2603
2066
  });
2604
- k.lazycreate = (a, e) => new k({
2605
- shape: a,
2067
+ k.lazycreate = (i, e) => new k({
2068
+ shape: i,
2606
2069
  unknownKeys: "strip",
2607
2070
  catchall: P.create(),
2608
- typeName: m.ZodObject,
2071
+ typeName: _.ZodObject,
2609
2072
  ...y(e)
2610
2073
  });
2611
- class ne extends v {
2074
+ class ie extends v {
2612
2075
  _parse(e) {
2613
2076
  const { ctx: t } = this._processInputParams(e), s = this._def.options;
2614
- function n(r) {
2615
- for (const o of r)
2077
+ function n(a) {
2078
+ for (const o of a)
2616
2079
  if (o.result.status === "valid")
2617
2080
  return o.result;
2618
- for (const o of r)
2081
+ for (const o of a)
2619
2082
  if (o.result.status === "dirty")
2620
2083
  return t.common.issues.push(...o.ctx.common.issues), o.result;
2621
- const i = r.map((o) => new Z(o.ctx.common.issues));
2084
+ const r = a.map((o) => new N(o.ctx.common.issues));
2622
2085
  return u(t, {
2623
2086
  code: d.invalid_union,
2624
- unionErrors: i
2625
- }), _;
2087
+ unionErrors: r
2088
+ }), g;
2626
2089
  }
2627
2090
  if (t.common.async)
2628
- return Promise.all(s.map(async (r) => {
2629
- const i = {
2091
+ return Promise.all(s.map(async (a) => {
2092
+ const r = {
2630
2093
  ...t,
2631
2094
  common: {
2632
2095
  ...t.common,
@@ -2635,17 +2098,17 @@ class ne extends v {
2635
2098
  parent: null
2636
2099
  };
2637
2100
  return {
2638
- result: await r._parseAsync({
2101
+ result: await a._parseAsync({
2639
2102
  data: t.data,
2640
2103
  path: t.path,
2641
- parent: i
2104
+ parent: r
2642
2105
  }),
2643
- ctx: i
2106
+ ctx: r
2644
2107
  };
2645
2108
  })).then(n);
2646
2109
  {
2647
- let r;
2648
- const i = [];
2110
+ let a;
2111
+ const r = [];
2649
2112
  for (const c of s) {
2650
2113
  const l = {
2651
2114
  ...t,
@@ -2654,68 +2117,68 @@ class ne extends v {
2654
2117
  issues: []
2655
2118
  },
2656
2119
  parent: null
2657
- }, g = c._parseSync({
2120
+ }, f = c._parseSync({
2658
2121
  data: t.data,
2659
2122
  path: t.path,
2660
2123
  parent: l
2661
2124
  });
2662
- if (g.status === "valid")
2663
- return g;
2664
- g.status === "dirty" && !r && (r = { result: g, ctx: l }), l.common.issues.length && i.push(l.common.issues);
2125
+ if (f.status === "valid")
2126
+ return f;
2127
+ f.status === "dirty" && !a && (a = { result: f, ctx: l }), l.common.issues.length && r.push(l.common.issues);
2665
2128
  }
2666
- if (r)
2667
- return t.common.issues.push(...r.ctx.common.issues), r.result;
2668
- const o = i.map((c) => new Z(c));
2129
+ if (a)
2130
+ return t.common.issues.push(...a.ctx.common.issues), a.result;
2131
+ const o = r.map((c) => new N(c));
2669
2132
  return u(t, {
2670
2133
  code: d.invalid_union,
2671
2134
  unionErrors: o
2672
- }), _;
2135
+ }), g;
2673
2136
  }
2674
2137
  }
2675
2138
  get options() {
2676
2139
  return this._def.options;
2677
2140
  }
2678
2141
  }
2679
- ne.create = (a, e) => new ne({
2680
- options: a,
2681
- typeName: m.ZodUnion,
2142
+ ie.create = (i, e) => new ie({
2143
+ options: i,
2144
+ typeName: _.ZodUnion,
2682
2145
  ...y(e)
2683
2146
  });
2684
- function ue(a, e) {
2685
- const t = O(a), s = O(e);
2686
- if (a === e)
2687
- return { valid: !0, data: a };
2147
+ function he(i, e) {
2148
+ const t = A(i), s = A(e);
2149
+ if (i === e)
2150
+ return { valid: !0, data: i };
2688
2151
  if (t === h.object && s === h.object) {
2689
- const n = b.objectKeys(e), r = b.objectKeys(a).filter((o) => n.indexOf(o) !== -1), i = { ...a, ...e };
2690
- for (const o of r) {
2691
- const c = ue(a[o], e[o]);
2152
+ const n = b.objectKeys(e), a = b.objectKeys(i).filter((o) => n.indexOf(o) !== -1), r = { ...i, ...e };
2153
+ for (const o of a) {
2154
+ const c = he(i[o], e[o]);
2692
2155
  if (!c.valid)
2693
2156
  return { valid: !1 };
2694
- i[o] = c.data;
2157
+ r[o] = c.data;
2695
2158
  }
2696
- return { valid: !0, data: i };
2159
+ return { valid: !0, data: r };
2697
2160
  } else if (t === h.array && s === h.array) {
2698
- if (a.length !== e.length)
2161
+ if (i.length !== e.length)
2699
2162
  return { valid: !1 };
2700
2163
  const n = [];
2701
- for (let r = 0; r < a.length; r++) {
2702
- const i = a[r], o = e[r], c = ue(i, o);
2164
+ for (let a = 0; a < i.length; a++) {
2165
+ const r = i[a], o = e[a], c = he(r, o);
2703
2166
  if (!c.valid)
2704
2167
  return { valid: !1 };
2705
2168
  n.push(c.data);
2706
2169
  }
2707
2170
  return { valid: !0, data: n };
2708
- } else return t === h.date && s === h.date && +a == +e ? { valid: !0, data: a } : { valid: !1 };
2171
+ } else return t === h.date && s === h.date && +i == +e ? { valid: !0, data: i } : { valid: !1 };
2709
2172
  }
2710
2173
  class ae extends v {
2711
2174
  _parse(e) {
2712
- const { status: t, ctx: s } = this._processInputParams(e), n = (r, i) => {
2713
- if (ye(r) || ye(i))
2714
- return _;
2715
- const o = ue(r.value, i.value);
2716
- return o.valid ? ((ve(r) || ve(i)) && t.dirty(), { status: t.value, value: o.data }) : (u(s, {
2175
+ const { status: t, ctx: s } = this._processInputParams(e), n = (a, r) => {
2176
+ if (ve(a) || ve(r))
2177
+ return g;
2178
+ const o = he(a.value, r.value);
2179
+ return o.valid ? ((be(a) || be(r)) && t.dirty(), { status: t.value, value: o.data }) : (u(s, {
2717
2180
  code: d.invalid_intersection_types
2718
- }), _);
2181
+ }), g);
2719
2182
  };
2720
2183
  return s.common.async ? Promise.all([
2721
2184
  this._def.left._parseAsync({
@@ -2728,7 +2191,7 @@ class ae extends v {
2728
2191
  path: s.path,
2729
2192
  parent: s
2730
2193
  })
2731
- ]).then(([r, i]) => n(r, i)) : n(this._def.left._parseSync({
2194
+ ]).then(([a, r]) => n(a, r)) : n(this._def.left._parseSync({
2732
2195
  data: s.data,
2733
2196
  path: s.path,
2734
2197
  parent: s
@@ -2739,13 +2202,13 @@ class ae extends v {
2739
2202
  }));
2740
2203
  }
2741
2204
  }
2742
- ae.create = (a, e, t) => new ae({
2743
- left: a,
2205
+ ae.create = (i, e, t) => new ae({
2206
+ left: i,
2744
2207
  right: e,
2745
- typeName: m.ZodIntersection,
2208
+ typeName: _.ZodIntersection,
2746
2209
  ...y(t)
2747
2210
  });
2748
- class $ extends v {
2211
+ class R extends v {
2749
2212
  _parse(e) {
2750
2213
  const { status: t, ctx: s } = this._processInputParams(e);
2751
2214
  if (s.parsedType !== h.array)
@@ -2753,7 +2216,7 @@ class $ extends v {
2753
2216
  code: d.invalid_type,
2754
2217
  expected: h.array,
2755
2218
  received: s.parsedType
2756
- }), _;
2219
+ }), g;
2757
2220
  if (s.data.length < this._def.items.length)
2758
2221
  return u(s, {
2759
2222
  code: d.too_small,
@@ -2761,7 +2224,7 @@ class $ extends v {
2761
2224
  inclusive: !0,
2762
2225
  exact: !1,
2763
2226
  type: "array"
2764
- }), _;
2227
+ }), g;
2765
2228
  !this._def.rest && s.data.length > this._def.items.length && (u(s, {
2766
2229
  code: d.too_big,
2767
2230
  maximum: this._def.items.length,
@@ -2769,28 +2232,28 @@ class $ extends v {
2769
2232
  exact: !1,
2770
2233
  type: "array"
2771
2234
  }), t.dirty());
2772
- const n = [...s.data].map((r, i) => {
2773
- const o = this._def.items[i] || this._def.rest;
2774
- return o ? o._parse(new j(s, r, s.path, i)) : null;
2775
- }).filter((r) => !!r);
2776
- return s.common.async ? Promise.all(n).then((r) => S.mergeArray(t, r)) : S.mergeArray(t, n);
2235
+ const n = [...s.data].map((a, r) => {
2236
+ const o = this._def.items[r] || this._def.rest;
2237
+ return o ? o._parse(new $(s, a, s.path, r)) : null;
2238
+ }).filter((a) => !!a);
2239
+ return s.common.async ? Promise.all(n).then((a) => T.mergeArray(t, a)) : T.mergeArray(t, n);
2777
2240
  }
2778
2241
  get items() {
2779
2242
  return this._def.items;
2780
2243
  }
2781
2244
  rest(e) {
2782
- return new $({
2245
+ return new R({
2783
2246
  ...this._def,
2784
2247
  rest: e
2785
2248
  });
2786
2249
  }
2787
2250
  }
2788
- $.create = (a, e) => {
2789
- if (!Array.isArray(a))
2251
+ R.create = (i, e) => {
2252
+ if (!Array.isArray(i))
2790
2253
  throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2791
- return new $({
2792
- items: a,
2793
- typeName: m.ZodTuple,
2254
+ return new R({
2255
+ items: i,
2256
+ typeName: _.ZodTuple,
2794
2257
  rest: null,
2795
2258
  ...y(e)
2796
2259
  });
@@ -2809,41 +2272,41 @@ class Ne extends v {
2809
2272
  code: d.invalid_type,
2810
2273
  expected: h.map,
2811
2274
  received: s.parsedType
2812
- }), _;
2813
- const n = this._def.keyType, r = this._def.valueType, i = [...s.data.entries()].map(([o, c], l) => ({
2814
- key: n._parse(new j(s, o, s.path, [l, "key"])),
2815
- value: r._parse(new j(s, c, s.path, [l, "value"]))
2275
+ }), g;
2276
+ const n = this._def.keyType, a = this._def.valueType, r = [...s.data.entries()].map(([o, c], l) => ({
2277
+ key: n._parse(new $(s, o, s.path, [l, "key"])),
2278
+ value: a._parse(new $(s, c, s.path, [l, "value"]))
2816
2279
  }));
2817
2280
  if (s.common.async) {
2818
2281
  const o = /* @__PURE__ */ new Map();
2819
2282
  return Promise.resolve().then(async () => {
2820
- for (const c of i) {
2821
- const l = await c.key, g = await c.value;
2822
- if (l.status === "aborted" || g.status === "aborted")
2823
- return _;
2824
- (l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
2283
+ for (const c of r) {
2284
+ const l = await c.key, f = await c.value;
2285
+ if (l.status === "aborted" || f.status === "aborted")
2286
+ return g;
2287
+ (l.status === "dirty" || f.status === "dirty") && t.dirty(), o.set(l.value, f.value);
2825
2288
  }
2826
2289
  return { status: t.value, value: o };
2827
2290
  });
2828
2291
  } else {
2829
2292
  const o = /* @__PURE__ */ new Map();
2830
- for (const c of i) {
2831
- const l = c.key, g = c.value;
2832
- if (l.status === "aborted" || g.status === "aborted")
2833
- return _;
2834
- (l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
2293
+ for (const c of r) {
2294
+ const l = c.key, f = c.value;
2295
+ if (l.status === "aborted" || f.status === "aborted")
2296
+ return g;
2297
+ (l.status === "dirty" || f.status === "dirty") && t.dirty(), o.set(l.value, f.value);
2835
2298
  }
2836
2299
  return { status: t.value, value: o };
2837
2300
  }
2838
2301
  }
2839
2302
  }
2840
- Ne.create = (a, e, t) => new Ne({
2303
+ Ne.create = (i, e, t) => new Ne({
2841
2304
  valueType: e,
2842
- keyType: a,
2843
- typeName: m.ZodMap,
2305
+ keyType: i,
2306
+ typeName: _.ZodMap,
2844
2307
  ...y(t)
2845
2308
  });
2846
- class Q extends v {
2309
+ class G extends v {
2847
2310
  _parse(e) {
2848
2311
  const { status: t, ctx: s } = this._processInputParams(e);
2849
2312
  if (s.parsedType !== h.set)
@@ -2851,7 +2314,7 @@ class Q extends v {
2851
2314
  code: d.invalid_type,
2852
2315
  expected: h.set,
2853
2316
  received: s.parsedType
2854
- }), _;
2317
+ }), g;
2855
2318
  const n = this._def;
2856
2319
  n.minSize !== null && s.data.size < n.minSize.value && (u(s, {
2857
2320
  code: d.too_small,
@@ -2868,27 +2331,27 @@ class Q extends v {
2868
2331
  exact: !1,
2869
2332
  message: n.maxSize.message
2870
2333
  }), t.dirty());
2871
- const r = this._def.valueType;
2872
- function i(c) {
2334
+ const a = this._def.valueType;
2335
+ function r(c) {
2873
2336
  const l = /* @__PURE__ */ new Set();
2874
- for (const g of c) {
2875
- if (g.status === "aborted")
2876
- return _;
2877
- g.status === "dirty" && t.dirty(), l.add(g.value);
2337
+ for (const f of c) {
2338
+ if (f.status === "aborted")
2339
+ return g;
2340
+ f.status === "dirty" && t.dirty(), l.add(f.value);
2878
2341
  }
2879
2342
  return { status: t.value, value: l };
2880
2343
  }
2881
- const o = [...s.data.values()].map((c, l) => r._parse(new j(s, c, s.path, l)));
2882
- return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
2344
+ const o = [...s.data.values()].map((c, l) => a._parse(new $(s, c, s.path, l)));
2345
+ return s.common.async ? Promise.all(o).then((c) => r(c)) : r(o);
2883
2346
  }
2884
2347
  min(e, t) {
2885
- return new Q({
2348
+ return new G({
2886
2349
  ...this._def,
2887
2350
  minSize: { value: e, message: p.toString(t) }
2888
2351
  });
2889
2352
  }
2890
2353
  max(e, t) {
2891
- return new Q({
2354
+ return new G({
2892
2355
  ...this._def,
2893
2356
  maxSize: { value: e, message: p.toString(t) }
2894
2357
  });
@@ -2900,11 +2363,11 @@ class Q extends v {
2900
2363
  return this.min(1, e);
2901
2364
  }
2902
2365
  }
2903
- Q.create = (a, e) => new Q({
2904
- valueType: a,
2366
+ G.create = (i, e) => new G({
2367
+ valueType: i,
2905
2368
  minSize: null,
2906
2369
  maxSize: null,
2907
- typeName: m.ZodSet,
2370
+ typeName: _.ZodSet,
2908
2371
  ...y(e)
2909
2372
  });
2910
2373
  class Ze extends v {
@@ -2916,12 +2379,12 @@ class Ze extends v {
2916
2379
  return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2917
2380
  }
2918
2381
  }
2919
- Ze.create = (a, e) => new Ze({
2920
- getter: a,
2921
- typeName: m.ZodLazy,
2382
+ Ze.create = (i, e) => new Ze({
2383
+ getter: i,
2384
+ typeName: _.ZodLazy,
2922
2385
  ...y(e)
2923
2386
  });
2924
- class le extends v {
2387
+ class pe extends v {
2925
2388
  _parse(e) {
2926
2389
  if (e.data !== this._def.value) {
2927
2390
  const t = this._getOrReturnCtx(e);
@@ -2929,7 +2392,7 @@ class le extends v {
2929
2392
  received: t.data,
2930
2393
  code: d.invalid_literal,
2931
2394
  expected: this._def.value
2932
- }), _;
2395
+ }), g;
2933
2396
  }
2934
2397
  return { status: "valid", value: e.data };
2935
2398
  }
@@ -2937,19 +2400,19 @@ class le extends v {
2937
2400
  return this._def.value;
2938
2401
  }
2939
2402
  }
2940
- le.create = (a, e) => new le({
2941
- value: a,
2942
- typeName: m.ZodLiteral,
2403
+ pe.create = (i, e) => new pe({
2404
+ value: i,
2405
+ typeName: _.ZodLiteral,
2943
2406
  ...y(e)
2944
2407
  });
2945
- function je(a, e) {
2946
- return new L({
2947
- values: a,
2948
- typeName: m.ZodEnum,
2408
+ function Pe(i, e) {
2409
+ return new H({
2410
+ values: i,
2411
+ typeName: _.ZodEnum,
2949
2412
  ...y(e)
2950
2413
  });
2951
2414
  }
2952
- class L extends v {
2415
+ class H extends v {
2953
2416
  _parse(e) {
2954
2417
  if (typeof e.data != "string") {
2955
2418
  const t = this._getOrReturnCtx(e), s = this._def.values;
@@ -2957,7 +2420,7 @@ class L extends v {
2957
2420
  expected: b.joinValues(s),
2958
2421
  received: t.parsedType,
2959
2422
  code: d.invalid_type
2960
- }), _;
2423
+ }), g;
2961
2424
  }
2962
2425
  if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2963
2426
  const t = this._getOrReturnCtx(e), s = this._def.values;
@@ -2965,7 +2428,7 @@ class L extends v {
2965
2428
  received: t.data,
2966
2429
  code: d.invalid_enum_value,
2967
2430
  options: s
2968
- }), _;
2431
+ }), g;
2969
2432
  }
2970
2433
  return C(e.data);
2971
2434
  }
@@ -2991,19 +2454,19 @@ class L extends v {
2991
2454
  return e;
2992
2455
  }
2993
2456
  extract(e, t = this._def) {
2994
- return L.create(e, {
2457
+ return H.create(e, {
2995
2458
  ...this._def,
2996
2459
  ...t
2997
2460
  });
2998
2461
  }
2999
2462
  exclude(e, t = this._def) {
3000
- return L.create(this.options.filter((s) => !e.includes(s)), {
2463
+ return H.create(this.options.filter((s) => !e.includes(s)), {
3001
2464
  ...this._def,
3002
2465
  ...t
3003
2466
  });
3004
2467
  }
3005
2468
  }
3006
- L.create = je;
2469
+ H.create = Pe;
3007
2470
  class Ae extends v {
3008
2471
  _parse(e) {
3009
2472
  const t = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
@@ -3013,7 +2476,7 @@ class Ae extends v {
3013
2476
  expected: b.joinValues(n),
3014
2477
  received: s.parsedType,
3015
2478
  code: d.invalid_type
3016
- }), _;
2479
+ }), g;
3017
2480
  }
3018
2481
  if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
3019
2482
  const n = b.objectValues(t);
@@ -3021,7 +2484,7 @@ class Ae extends v {
3021
2484
  received: s.data,
3022
2485
  code: d.invalid_enum_value,
3023
2486
  options: n
3024
- }), _;
2487
+ }), g;
3025
2488
  }
3026
2489
  return C(e.data);
3027
2490
  }
@@ -3029,9 +2492,9 @@ class Ae extends v {
3029
2492
  return this._def.values;
3030
2493
  }
3031
2494
  }
3032
- Ae.create = (a, e) => new Ae({
3033
- values: a,
3034
- typeName: m.ZodNativeEnum,
2495
+ Ae.create = (i, e) => new Ae({
2496
+ values: i,
2497
+ typeName: _.ZodNativeEnum,
3035
2498
  ...y(e)
3036
2499
  });
3037
2500
  class re extends v {
@@ -3045,7 +2508,7 @@ class re extends v {
3045
2508
  code: d.invalid_type,
3046
2509
  expected: h.promise,
3047
2510
  received: t.parsedType
3048
- }), _;
2511
+ }), g;
3049
2512
  const s = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
3050
2513
  return C(s.then((n) => this._def.type.parseAsync(n, {
3051
2514
  path: t.path,
@@ -3053,54 +2516,54 @@ class re extends v {
3053
2516
  })));
3054
2517
  }
3055
2518
  }
3056
- re.create = (a, e) => new re({
3057
- type: a,
3058
- typeName: m.ZodPromise,
2519
+ re.create = (i, e) => new re({
2520
+ type: i,
2521
+ typeName: _.ZodPromise,
3059
2522
  ...y(e)
3060
2523
  });
3061
- class H extends v {
2524
+ class L extends v {
3062
2525
  innerType() {
3063
2526
  return this._def.schema;
3064
2527
  }
3065
2528
  sourceType() {
3066
- return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2529
+ return this._def.schema._def.typeName === _.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3067
2530
  }
3068
2531
  _parse(e) {
3069
- const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, r = {
3070
- addIssue: (i) => {
3071
- u(s, i), i.fatal ? t.abort() : t.dirty();
2532
+ const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, a = {
2533
+ addIssue: (r) => {
2534
+ u(s, r), r.fatal ? t.abort() : t.dirty();
3072
2535
  },
3073
2536
  get path() {
3074
2537
  return s.path;
3075
2538
  }
3076
2539
  };
3077
- if (r.addIssue = r.addIssue.bind(r), n.type === "preprocess") {
3078
- const i = n.transform(s.data, r);
2540
+ if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
2541
+ const r = n.transform(s.data, a);
3079
2542
  if (s.common.async)
3080
- return Promise.resolve(i).then(async (o) => {
2543
+ return Promise.resolve(r).then(async (o) => {
3081
2544
  if (t.value === "aborted")
3082
- return _;
2545
+ return g;
3083
2546
  const c = await this._def.schema._parseAsync({
3084
2547
  data: o,
3085
2548
  path: s.path,
3086
2549
  parent: s
3087
2550
  });
3088
- return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ? ce(c.value) : c;
2551
+ return c.status === "aborted" ? g : c.status === "dirty" || t.value === "dirty" ? ue(c.value) : c;
3089
2552
  });
3090
2553
  {
3091
2554
  if (t.value === "aborted")
3092
- return _;
2555
+ return g;
3093
2556
  const o = this._def.schema._parseSync({
3094
- data: i,
2557
+ data: r,
3095
2558
  path: s.path,
3096
2559
  parent: s
3097
2560
  });
3098
- return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ? ce(o.value) : o;
2561
+ return o.status === "aborted" ? g : o.status === "dirty" || t.value === "dirty" ? ue(o.value) : o;
3099
2562
  }
3100
2563
  }
3101
2564
  if (n.type === "refinement") {
3102
- const i = (o) => {
3103
- const c = n.refinement(o, r);
2565
+ const r = (o) => {
2566
+ const c = n.refinement(o, a);
3104
2567
  if (s.common.async)
3105
2568
  return Promise.resolve(c);
3106
2569
  if (c instanceof Promise)
@@ -3113,41 +2576,41 @@ class H extends v {
3113
2576
  path: s.path,
3114
2577
  parent: s
3115
2578
  });
3116
- return o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2579
+ return o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), r(o.value), { status: t.value, value: o.value });
3117
2580
  } else
3118
- return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2581
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), r(o.value).then(() => ({ status: t.value, value: o.value }))));
3119
2582
  }
3120
2583
  if (n.type === "transform")
3121
2584
  if (s.common.async === !1) {
3122
- const i = this._def.schema._parseSync({
2585
+ const r = this._def.schema._parseSync({
3123
2586
  data: s.data,
3124
2587
  path: s.path,
3125
2588
  parent: s
3126
2589
  });
3127
- if (!q(i))
3128
- return _;
3129
- const o = n.transform(i.value, r);
2590
+ if (!q(r))
2591
+ return g;
2592
+ const o = n.transform(r.value, a);
3130
2593
  if (o instanceof Promise)
3131
2594
  throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
3132
2595
  return { status: t.value, value: o };
3133
2596
  } else
3134
- return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => q(i) ? Promise.resolve(n.transform(i.value, r)).then((o) => ({
2597
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((r) => q(r) ? Promise.resolve(n.transform(r.value, a)).then((o) => ({
3135
2598
  status: t.value,
3136
2599
  value: o
3137
- })) : _);
2600
+ })) : g);
3138
2601
  b.assertNever(n);
3139
2602
  }
3140
2603
  }
3141
- H.create = (a, e, t) => new H({
3142
- schema: a,
3143
- typeName: m.ZodEffects,
2604
+ L.create = (i, e, t) => new L({
2605
+ schema: i,
2606
+ typeName: _.ZodEffects,
3144
2607
  effect: e,
3145
2608
  ...y(t)
3146
2609
  });
3147
- H.createWithPreprocess = (a, e, t) => new H({
2610
+ L.createWithPreprocess = (i, e, t) => new L({
3148
2611
  schema: e,
3149
- effect: { type: "preprocess", transform: a },
3150
- typeName: m.ZodEffects,
2612
+ effect: { type: "preprocess", transform: i },
2613
+ typeName: _.ZodEffects,
3151
2614
  ...y(t)
3152
2615
  });
3153
2616
  class E extends v {
@@ -3158,271 +2621,829 @@ class E extends v {
3158
2621
  return this._def.innerType;
3159
2622
  }
3160
2623
  }
3161
- E.create = (a, e) => new E({
3162
- innerType: a,
3163
- typeName: m.ZodOptional,
3164
- ...y(e)
3165
- });
3166
- class V extends v {
2624
+ E.create = (i, e) => new E({
2625
+ innerType: i,
2626
+ typeName: _.ZodOptional,
2627
+ ...y(e)
2628
+ });
2629
+ class D extends v {
2630
+ _parse(e) {
2631
+ return this._getType(e) === h.null ? C(null) : this._def.innerType._parse(e);
2632
+ }
2633
+ unwrap() {
2634
+ return this._def.innerType;
2635
+ }
2636
+ }
2637
+ D.create = (i, e) => new D({
2638
+ innerType: i,
2639
+ typeName: _.ZodNullable,
2640
+ ...y(e)
2641
+ });
2642
+ class fe extends v {
2643
+ _parse(e) {
2644
+ const { ctx: t } = this._processInputParams(e);
2645
+ let s = t.data;
2646
+ return t.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
2647
+ data: s,
2648
+ path: t.path,
2649
+ parent: t
2650
+ });
2651
+ }
2652
+ removeDefault() {
2653
+ return this._def.innerType;
2654
+ }
2655
+ }
2656
+ fe.create = (i, e) => new fe({
2657
+ innerType: i,
2658
+ typeName: _.ZodDefault,
2659
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2660
+ ...y(e)
2661
+ });
2662
+ class me extends v {
2663
+ _parse(e) {
2664
+ const { ctx: t } = this._processInputParams(e), s = {
2665
+ ...t,
2666
+ common: {
2667
+ ...t.common,
2668
+ issues: []
2669
+ }
2670
+ }, n = this._def.innerType._parse({
2671
+ data: s.data,
2672
+ path: s.path,
2673
+ parent: {
2674
+ ...s
2675
+ }
2676
+ });
2677
+ return se(n) ? n.then((a) => ({
2678
+ status: "valid",
2679
+ value: a.status === "valid" ? a.value : this._def.catchValue({
2680
+ get error() {
2681
+ return new N(s.common.issues);
2682
+ },
2683
+ input: s.data
2684
+ })
2685
+ })) : {
2686
+ status: "valid",
2687
+ value: n.status === "valid" ? n.value : this._def.catchValue({
2688
+ get error() {
2689
+ return new N(s.common.issues);
2690
+ },
2691
+ input: s.data
2692
+ })
2693
+ };
2694
+ }
2695
+ removeCatch() {
2696
+ return this._def.innerType;
2697
+ }
2698
+ }
2699
+ me.create = (i, e) => new me({
2700
+ innerType: i,
2701
+ typeName: _.ZodCatch,
2702
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2703
+ ...y(e)
2704
+ });
2705
+ class Oe extends v {
2706
+ _parse(e) {
2707
+ if (this._getType(e) !== h.nan) {
2708
+ const t = this._getOrReturnCtx(e);
2709
+ return u(t, {
2710
+ code: d.invalid_type,
2711
+ expected: h.nan,
2712
+ received: t.parsedType
2713
+ }), g;
2714
+ }
2715
+ return { status: "valid", value: e.data };
2716
+ }
2717
+ }
2718
+ Oe.create = (i) => new Oe({
2719
+ typeName: _.ZodNaN,
2720
+ ...y(i)
2721
+ });
2722
+ class _t extends v {
2723
+ _parse(e) {
2724
+ const { ctx: t } = this._processInputParams(e), s = t.data;
2725
+ return this._def.type._parse({
2726
+ data: s,
2727
+ path: t.path,
2728
+ parent: t
2729
+ });
2730
+ }
2731
+ unwrap() {
2732
+ return this._def.type;
2733
+ }
2734
+ }
2735
+ class ge extends v {
2736
+ _parse(e) {
2737
+ const { status: t, ctx: s } = this._processInputParams(e);
2738
+ if (s.common.async)
2739
+ return (async () => {
2740
+ const n = await this._def.in._parseAsync({
2741
+ data: s.data,
2742
+ path: s.path,
2743
+ parent: s
2744
+ });
2745
+ return n.status === "aborted" ? g : n.status === "dirty" ? (t.dirty(), ue(n.value)) : this._def.out._parseAsync({
2746
+ data: n.value,
2747
+ path: s.path,
2748
+ parent: s
2749
+ });
2750
+ })();
2751
+ {
2752
+ const n = this._def.in._parseSync({
2753
+ data: s.data,
2754
+ path: s.path,
2755
+ parent: s
2756
+ });
2757
+ return n.status === "aborted" ? g : n.status === "dirty" ? (t.dirty(), {
2758
+ status: "dirty",
2759
+ value: n.value
2760
+ }) : this._def.out._parseSync({
2761
+ data: n.value,
2762
+ path: s.path,
2763
+ parent: s
2764
+ });
2765
+ }
2766
+ }
2767
+ static create(e, t) {
2768
+ return new ge({
2769
+ in: e,
2770
+ out: t,
2771
+ typeName: _.ZodPipeline
2772
+ });
2773
+ }
2774
+ }
2775
+ class _e extends v {
3167
2776
  _parse(e) {
3168
- return this._getType(e) === h.null ? C(null) : this._def.innerType._parse(e);
2777
+ const t = this._def.innerType._parse(e), s = (n) => (q(n) && (n.value = Object.freeze(n.value)), n);
2778
+ return se(t) ? t.then((n) => s(n)) : s(t);
3169
2779
  }
3170
2780
  unwrap() {
3171
2781
  return this._def.innerType;
3172
2782
  }
3173
2783
  }
3174
- V.create = (a, e) => new V({
3175
- innerType: a,
3176
- typeName: m.ZodNullable,
2784
+ _e.create = (i, e) => new _e({
2785
+ innerType: i,
2786
+ typeName: _.ZodReadonly,
3177
2787
  ...y(e)
3178
2788
  });
3179
- class he extends v {
3180
- _parse(e) {
3181
- const { ctx: t } = this._processInputParams(e);
3182
- let s = t.data;
3183
- return t.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
3184
- data: s,
3185
- path: t.path,
3186
- parent: t
3187
- });
2789
+ var _;
2790
+ (function(i) {
2791
+ i.ZodString = "ZodString", i.ZodNumber = "ZodNumber", i.ZodNaN = "ZodNaN", i.ZodBigInt = "ZodBigInt", i.ZodBoolean = "ZodBoolean", i.ZodDate = "ZodDate", i.ZodSymbol = "ZodSymbol", i.ZodUndefined = "ZodUndefined", i.ZodNull = "ZodNull", i.ZodAny = "ZodAny", i.ZodUnknown = "ZodUnknown", i.ZodNever = "ZodNever", i.ZodVoid = "ZodVoid", i.ZodArray = "ZodArray", i.ZodObject = "ZodObject", i.ZodUnion = "ZodUnion", i.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", i.ZodIntersection = "ZodIntersection", i.ZodTuple = "ZodTuple", i.ZodRecord = "ZodRecord", i.ZodMap = "ZodMap", i.ZodSet = "ZodSet", i.ZodFunction = "ZodFunction", i.ZodLazy = "ZodLazy", i.ZodLiteral = "ZodLiteral", i.ZodEnum = "ZodEnum", i.ZodEffects = "ZodEffects", i.ZodNativeEnum = "ZodNativeEnum", i.ZodOptional = "ZodOptional", i.ZodNullable = "ZodNullable", i.ZodDefault = "ZodDefault", i.ZodCatch = "ZodCatch", i.ZodPromise = "ZodPromise", i.ZodBranded = "ZodBranded", i.ZodPipeline = "ZodPipeline", i.ZodReadonly = "ZodReadonly";
2792
+ })(_ || (_ = {}));
2793
+ const Z = O.create, je = le.create;
2794
+ P.create;
2795
+ I.create;
2796
+ const Re = k.create;
2797
+ ie.create;
2798
+ ae.create;
2799
+ R.create;
2800
+ const Fe = pe.create, gt = H.create;
2801
+ re.create;
2802
+ E.create;
2803
+ D.create;
2804
+ const yt = Re({
2805
+ type: Fe("bridge"),
2806
+ name: Z(),
2807
+ data: je()
2808
+ });
2809
+ function jt(i) {
2810
+ return { ...i, type: "bridge" };
2811
+ }
2812
+ const vt = Re({
2813
+ type: Fe("client"),
2814
+ telemetrySdkVersion: Z(),
2815
+ applicationSpecifier: Z(),
2816
+ applicationInstance: Z(),
2817
+ runtime: gt(["window", "worker"]),
2818
+ name: Z(),
2819
+ data: je(),
2820
+ responseName: Z().optional(),
2821
+ subscriptionName: Z().optional(),
2822
+ unsubscribeName: Z().optional()
2823
+ });
2824
+ function Y(i) {
2825
+ return { ...i, type: "client" };
2826
+ }
2827
+ class bt {
2828
+ constructor(e) {
2829
+ this._client = e;
3188
2830
  }
3189
- removeDefault() {
3190
- return this._def.innerType;
2831
+ /**
2832
+ * Provides access to the application store scope.
2833
+ *
2834
+ * Data stored in the application scope is shared across all instances of your application
2835
+ * within the current account. Use this scope for application-wide settings, shared resources,
2836
+ * or any data that should be consistent across all instances.
2837
+ *
2838
+ * @returns A StoreSlice instance for the application scope
2839
+ */
2840
+ get application() {
2841
+ return new X("application", "application", this._client);
2842
+ }
2843
+ /**
2844
+ * Provides access to the instance store scope.
2845
+ *
2846
+ * Data stored in the instance scope is only available to the current instance of your
2847
+ * application. This is ideal for instance-specific settings, UI state, temporary data,
2848
+ * or any information that shouldn't be shared with other instances.
2849
+ *
2850
+ * @returns A StoreSlice instance for the instance scope
2851
+ */
2852
+ get instance() {
2853
+ return new X("instance", this._client.applicationInstance, this._client);
2854
+ }
2855
+ /**
2856
+ * Provides access to the device store scope.
2857
+ *
2858
+ * Data stored in the device scope is only available to the application on the
2859
+ * current physical device. This is useful for device-specific settings, caching, or
2860
+ * any data that should persist across application instances but only on a single device.
2861
+ *
2862
+ * Note: This scope cannot be used for Settings-related mount points as the User
2863
+ * Administration UI does not run on a device.
2864
+ *
2865
+ * @returns A StoreSlice instance for the device scope
2866
+ */
2867
+ get device() {
2868
+ return new X("device", this._client.deviceId, this._client);
2869
+ }
2870
+ /**
2871
+ * Provides access to the shared store scope with a specified namespace.
2872
+ *
2873
+ * The shared scope enables data sharing between different applications within the
2874
+ * same account. By specifying a common namespace, any two applications can exchange
2875
+ * data and communicate with each other.
2876
+ *
2877
+ * This is particularly useful for application ecosystems where multiple applications
2878
+ * need to coordinate or share configuration.
2879
+ *
2880
+ * @param namespace A string identifier for the shared data space
2881
+ * @returns A StoreSlice instance for the specified shared namespace
2882
+ */
2883
+ shared(e) {
2884
+ return new X("shared", e, this._client);
3191
2885
  }
3192
2886
  }
3193
- he.create = (a, e) => new he({
3194
- innerType: a,
3195
- typeName: m.ZodDefault,
3196
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
3197
- ...y(e)
3198
- });
3199
- class pe extends v {
3200
- _parse(e) {
3201
- const { ctx: t } = this._processInputParams(e), s = {
3202
- ...t,
3203
- common: {
3204
- ...t.common,
3205
- issues: []
3206
- }
3207
- }, n = this._def.innerType._parse({
3208
- data: s.data,
3209
- path: s.path,
3210
- parent: {
3211
- ...s
3212
- }
3213
- });
3214
- return te(n) ? n.then((r) => ({
3215
- status: "valid",
3216
- value: r.status === "valid" ? r.value : this._def.catchValue({
3217
- get error() {
3218
- return new Z(s.common.issues);
3219
- },
3220
- input: s.data
3221
- })
3222
- })) : {
3223
- status: "valid",
3224
- value: n.status === "valid" ? n.value : this._def.catchValue({
3225
- get error() {
3226
- return new Z(s.common.issues);
3227
- },
3228
- input: s.data
3229
- })
3230
- };
2887
+ class X {
2888
+ constructor(e, t, s) {
2889
+ this._kind = e, this._namespace = t, this._client = s;
3231
2890
  }
3232
- removeCatch() {
3233
- return this._def.innerType;
2891
+ /**
2892
+ * Saves a value in the store.
2893
+ *
2894
+ * This method stores data under the specified key within the current store scope and namespace.
2895
+ * The value must be serializable (can be converted to JSON). Complex objects like Date instances
2896
+ * will be serialized and deserialize as regular objects, losing their prototype methods.
2897
+ *
2898
+ * @param key The key to save the value under
2899
+ * @param value The value to store - must be JSON serializable
2900
+ * @returns A promise that resolves to true if the value was saved successfully
2901
+ */
2902
+ async set(e, t) {
2903
+ return (await this._client.request("store.set", {
2904
+ kind: this._kind,
2905
+ namespace: this._namespace,
2906
+ key: e,
2907
+ value: t
2908
+ })).success;
2909
+ }
2910
+ /**
2911
+ * Retrieves a value from the store.
2912
+ *
2913
+ * This method fetches data stored under the specified key within the current store scope
2914
+ * and namespace. For real-time applications that need to respond to changes, consider
2915
+ * using subscribe() instead.
2916
+ *
2917
+ * @template T The expected type of the stored value
2918
+ * @param key The key to retrieve the value for
2919
+ * @returns A promise that resolves to the stored value, or undefined if the key does not exist
2920
+ */
2921
+ async get(e) {
2922
+ return (await this._client.request("store.get", {
2923
+ kind: this._kind,
2924
+ namespace: this._namespace,
2925
+ key: e
2926
+ })).value;
2927
+ }
2928
+ /**
2929
+ * Subscribes to changes in the store for a specific key.
2930
+ *
2931
+ * This method sets up a subscription that will call the provided handler whenever
2932
+ * the value associated with the specified key changes. This is the recommended way
2933
+ * to access store data in long-running applications that need to stay responsive
2934
+ * to data changes.
2935
+ *
2936
+ * @param key The key to subscribe to
2937
+ * @param handler The callback function to call when the value changes
2938
+ * @returns A promise that resolves to true if the subscription was successful
2939
+ */
2940
+ async subscribe(e, t) {
2941
+ return (await this._client.subscribe("store.subscribe", {
2942
+ kind: this._kind,
2943
+ namespace: this._namespace,
2944
+ key: e
2945
+ }, t)).success;
2946
+ }
2947
+ /**
2948
+ * Unsubscribes from changes in the store for a specific key.
2949
+ *
2950
+ * This method removes a subscription previously created with subscribe(). It can
2951
+ * either remove a specific handler or all handlers for the given key.
2952
+ *
2953
+ * @param key The key to unsubscribe from
2954
+ * @param handler Optional. The specific handler to remove. If not provided, all handlers for this key will be removed.
2955
+ * @returns A promise that resolves to true if the unsubscribe was successful
2956
+ */
2957
+ async unsubscribe(e, t) {
2958
+ return (await this._client.unsubscribe("store.unsubscribe", {
2959
+ kind: this._kind,
2960
+ namespace: this._namespace,
2961
+ key: e
2962
+ }, t)).success;
2963
+ }
2964
+ /**
2965
+ * Deletes a value from the store.
2966
+ *
2967
+ * This method removes the data stored under the specified key within the
2968
+ * current store scope and namespace.
2969
+ *
2970
+ * @param key The key to delete
2971
+ * @returns A promise that resolves to true if the value was deleted successfully
2972
+ */
2973
+ async delete(e) {
2974
+ return (await this._client.request("store.delete", {
2975
+ kind: this._kind,
2976
+ namespace: this._namespace,
2977
+ key: e
2978
+ })).success;
3234
2979
  }
3235
2980
  }
3236
- pe.create = (a, e) => new pe({
3237
- innerType: a,
3238
- typeName: m.ZodCatch,
3239
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
3240
- ...y(e)
3241
- });
3242
- class Oe extends v {
3243
- _parse(e) {
3244
- if (this._getType(e) !== h.nan) {
3245
- const t = this._getOrReturnCtx(e);
3246
- return u(t, {
3247
- code: d.invalid_type,
3248
- expected: h.nan,
3249
- received: t.parsedType
3250
- }), _;
3251
- }
3252
- return { status: "valid", value: e.data };
2981
+ class wt {
2982
+ /**
2983
+ * Creates a new RootSettingsNavigation API instance.
2984
+ *
2985
+ * @param store The Store instance to use for persistence
2986
+ * @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
2987
+ */
2988
+ constructor(e) {
2989
+ if (e._client._applicationSpecifier !== "rootSettingsNavigation")
2990
+ throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");
2991
+ this._store = e;
2992
+ }
2993
+ /**
2994
+ * Registers navigation entries for the root application in the TelemetryOS admin UI.
2995
+ *
2996
+ * This method allows a root application to define its sidebar navigation structure
2997
+ * within the TelemetryOS administration UI. The navigation entries will appear in the
2998
+ * sidebar menu, allowing users to navigate to different sections of the application.
2999
+ *
3000
+ * @param navigation An object containing the navigation entries to register
3001
+ * @returns A promise that resolves when the navigation has been registered
3002
+ */
3003
+ async setRootSettingsNavigation(e) {
3004
+ var t;
3005
+ const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, a = this._store._client._applicationSpecifier;
3006
+ n[a] = {
3007
+ applicationSpecifier: a,
3008
+ entries: e.entries
3009
+ }, s.set("navigation", n);
3010
+ }
3011
+ /**
3012
+ * Retrieves the current navigation entries for this root application.
3013
+ *
3014
+ * This method returns the navigation structure that was previously registered
3015
+ * for this application using setRootSettingsNavigation().
3016
+ *
3017
+ * @returns A promise that resolves to the navigation state for this application
3018
+ */
3019
+ async getRootSettingsNavigation() {
3020
+ var e;
3021
+ const s = (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {}, n = this._store._client._applicationSpecifier;
3022
+ return s[n];
3023
+ }
3024
+ /**
3025
+ * Retrieves the navigation entries for all root applications.
3026
+ *
3027
+ * This method returns the navigation structures for all root applications registered
3028
+ * in the TelemetryOS administration UI. This can be useful for coordination between
3029
+ * different root applications.
3030
+ *
3031
+ * @returns A promise that resolves to the navigation state for all applications
3032
+ */
3033
+ async getAllRootSettingsNavigation() {
3034
+ var e;
3035
+ return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
3253
3036
  }
3254
3037
  }
3255
- Oe.create = (a) => new Oe({
3256
- typeName: m.ZodNaN,
3257
- ...y(a)
3258
- });
3259
- class xt extends v {
3260
- _parse(e) {
3261
- const { ctx: t } = this._processInputParams(e), s = t.data;
3262
- return this._def.type._parse({
3263
- data: s,
3264
- path: t.path,
3265
- parent: t
3266
- });
3038
+ class kt {
3039
+ constructor(e) {
3040
+ this._client = e;
3267
3041
  }
3268
- unwrap() {
3269
- return this._def.type;
3042
+ /**
3043
+ * Retrieves information about the user associated with the current session.
3044
+ *
3045
+ * This method allows an application to get details about the TelemetryOS user
3046
+ * who is currently using the application.
3047
+ *
3048
+ * @returns A promise that resolves to the current user result object
3049
+ * @example
3050
+ * // Get the current user information
3051
+ * const userResult = await users.getCurrent();
3052
+ * console.log(`Current user ID: ${userResult.user.id}`);
3053
+ */
3054
+ async getCurrent() {
3055
+ const e = await this._client.request("users.getCurrent", {});
3056
+ if (!e.success)
3057
+ throw new Error(e.error || "Failed to fetch current user");
3058
+ return e.user;
3270
3059
  }
3271
3060
  }
3272
- class me extends v {
3273
- _parse(e) {
3274
- const { status: t, ctx: s } = this._processInputParams(e);
3275
- if (s.common.async)
3276
- return (async () => {
3277
- const n = await this._def.in._parseAsync({
3278
- data: s.data,
3279
- path: s.path,
3280
- parent: s
3281
- });
3282
- return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), ce(n.value)) : this._def.out._parseAsync({
3283
- data: n.value,
3284
- path: s.path,
3285
- parent: s
3286
- });
3287
- })();
3288
- {
3289
- const n = this._def.in._parseSync({
3290
- data: s.data,
3291
- path: s.path,
3292
- parent: s
3293
- });
3294
- return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), {
3295
- status: "dirty",
3296
- value: n.value
3297
- }) : this._def.out._parseSync({
3298
- data: n.value,
3299
- path: s.path,
3300
- parent: s
3301
- });
3302
- }
3061
+ class xt {
3062
+ constructor(e) {
3063
+ this._client = e;
3303
3064
  }
3304
- static create(e, t) {
3305
- return new me({
3306
- in: e,
3307
- out: t,
3308
- typeName: m.ZodPipeline
3065
+ async fetch(e, t) {
3066
+ var s;
3067
+ let n;
3068
+ typeof e == "string" ? n = e : e instanceof URL ? n = e.toString() : (n = e.url, t || (t = {
3069
+ method: e.method,
3070
+ headers: e.headers,
3071
+ body: e.body,
3072
+ credentials: e.credentials,
3073
+ cache: e.cache,
3074
+ redirect: e.redirect,
3075
+ referrer: e.referrer,
3076
+ integrity: e.integrity
3077
+ }));
3078
+ let a = {};
3079
+ t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((f, w) => {
3080
+ a[w] = f;
3081
+ }) : Array.isArray(t.headers) ? t.headers.forEach(([f, w]) => {
3082
+ a[f] = w;
3083
+ }) : a = t.headers);
3084
+ const r = await this._client.request("proxy.fetch", {
3085
+ url: n,
3086
+ method: (t == null ? void 0 : t.method) || "GET",
3087
+ headers: a,
3088
+ body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
3309
3089
  });
3090
+ if (!r.success)
3091
+ throw new TypeError(r.errorMessage, {
3092
+ cause: r.errorCause ? Error(r.errorCause) : void 0
3093
+ });
3094
+ const o = new Headers(r.headers), c = {
3095
+ status: r.status,
3096
+ statusText: r.statusText,
3097
+ headers: o
3098
+ };
3099
+ let l = null;
3100
+ if (r.body !== null && r.body !== void 0)
3101
+ if (r.bodyType === "binary") {
3102
+ const f = atob(r.body), w = new Uint8Array(f.length);
3103
+ for (let S = 0; S < f.length; S++)
3104
+ w[S] = f.charCodeAt(S);
3105
+ l = w;
3106
+ } else r.bodyType === "text" ? l = r.body : r.bodyType === "json" && (l = JSON.stringify(r.body));
3107
+ return new Response(l, c);
3310
3108
  }
3311
3109
  }
3312
- class fe extends v {
3313
- _parse(e) {
3314
- const t = this._def.innerType._parse(e), s = (n) => (q(n) && (n.value = Object.freeze(n.value)), n);
3315
- return te(t) ? t.then((n) => s(n)) : s(t);
3110
+ class St {
3111
+ constructor(e) {
3112
+ this._client = e;
3316
3113
  }
3317
- unwrap() {
3318
- return this._def.innerType;
3114
+ /**
3115
+ * Retrieves hardware information about the current physical device.
3116
+ *
3117
+ * This method returns details about the device running the application, such as
3118
+ * serial number, model, manufacturer, and platform. This information is only
3119
+ * available when running on a physical device (player), not in the admin UI.
3120
+ *
3121
+ * @returns A promise that resolves to the device hardware information
3122
+ * @example
3123
+ * // Get hardware info of the current device
3124
+ * const info = await devices.getInformation();
3125
+ * console.log(`Device: ${info.deviceManufacturer} ${info.deviceModel}`);
3126
+ */
3127
+ async getInformation() {
3128
+ const e = await this._client.request("devices.getInformation", {});
3129
+ if (!e.success)
3130
+ throw new Error("Failed to get device information");
3131
+ return e.deviceInformation;
3132
+ }
3133
+ /**
3134
+ * Retrieves the capabilities of the current device.
3135
+ *
3136
+ * Capabilities indicate what hardware and software features are available on
3137
+ * the device running the application. This can be used to conditionally enable
3138
+ * features based on what the device supports (e.g., MQTT, Bluetooth, WiFi).
3139
+ *
3140
+ * @returns A promise that resolves to an array of device capability strings
3141
+ * @example
3142
+ * const capabilities = await devices.getCapabilities();
3143
+ * if (capabilities.includes('mqtt')) {
3144
+ * // Enable MQTT features
3145
+ * }
3146
+ */
3147
+ async getCapabilities() {
3148
+ const e = await this._client.request("devices.getCapabilities", {});
3149
+ if (!e.success)
3150
+ throw new Error("Failed to get device capabilities");
3151
+ return e.capabilities;
3319
3152
  }
3320
3153
  }
3321
- fe.create = (a, e) => new fe({
3322
- innerType: a,
3323
- typeName: m.ZodReadonly,
3324
- ...y(e)
3325
- });
3326
- var m;
3327
- (function(a) {
3328
- a.ZodString = "ZodString", a.ZodNumber = "ZodNumber", a.ZodNaN = "ZodNaN", a.ZodBigInt = "ZodBigInt", a.ZodBoolean = "ZodBoolean", a.ZodDate = "ZodDate", a.ZodSymbol = "ZodSymbol", a.ZodUndefined = "ZodUndefined", a.ZodNull = "ZodNull", a.ZodAny = "ZodAny", a.ZodUnknown = "ZodUnknown", a.ZodNever = "ZodNever", a.ZodVoid = "ZodVoid", a.ZodArray = "ZodArray", a.ZodObject = "ZodObject", a.ZodUnion = "ZodUnion", a.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", a.ZodIntersection = "ZodIntersection", a.ZodTuple = "ZodTuple", a.ZodRecord = "ZodRecord", a.ZodMap = "ZodMap", a.ZodSet = "ZodSet", a.ZodFunction = "ZodFunction", a.ZodLazy = "ZodLazy", a.ZodLiteral = "ZodLiteral", a.ZodEnum = "ZodEnum", a.ZodEffects = "ZodEffects", a.ZodNativeEnum = "ZodNativeEnum", a.ZodOptional = "ZodOptional", a.ZodNullable = "ZodNullable", a.ZodDefault = "ZodDefault", a.ZodCatch = "ZodCatch", a.ZodPromise = "ZodPromise", a.ZodBranded = "ZodBranded", a.ZodPipeline = "ZodPipeline", a.ZodReadonly = "ZodReadonly";
3329
- })(m || (m = {}));
3330
- const A = I.create, Pe = de.create;
3331
- P.create;
3332
- N.create;
3333
- const Re = k.create;
3334
- ne.create;
3335
- ae.create;
3336
- $.create;
3337
- const $e = le.create;
3338
- L.create;
3339
- re.create;
3340
- E.create;
3341
- V.create;
3342
- const St = Re({
3343
- type: $e("bridge"),
3344
- name: A(),
3345
- data: Pe()
3346
- });
3347
- function Zt(a) {
3348
- return { ...a, type: "bridge" };
3349
- }
3350
- const At = Re({
3351
- type: $e("client"),
3352
- telemetrySdkVersion: A(),
3353
- applicationSpecifier: A(),
3354
- applicationInstance: A(),
3355
- name: A(),
3356
- data: Pe(),
3357
- responseName: A().optional(),
3358
- subscriptionName: A().optional(),
3359
- unsubscribeName: A().optional()
3360
- });
3361
- function Y(a) {
3362
- return { ...a, type: "client" };
3363
- }
3364
- class Ct {
3154
+ class Tt {
3155
+ constructor(e) {
3156
+ this._client = e;
3157
+ }
3365
3158
  /**
3366
- * Creates a new RootSettingsNavigation API instance.
3159
+ * Searches for cities by name or country
3367
3160
  *
3368
- * @param store The Store instance to use for persistence
3369
- * @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
3161
+ * @param params - Search parameters including optional country code and search query
3162
+ * @returns A promise that resolves to an array of matching cities
3163
+ * @throws {Error} If the request fails
3164
+ *
3165
+ * @example
3166
+ * ```typescript
3167
+ * // Search for cities named "New York"
3168
+ * const cities = await weather.getCities({ search: 'New York' })
3169
+ *
3170
+ * // Search for cities in the United States
3171
+ * const cities = await weather.getCities({ countryCode: 'US' })
3172
+ *
3173
+ * // Get a cityId for use in other methods
3174
+ * const cities = await weather.getCities({ search: 'London' })
3175
+ * const cityId = cities[0].cityId
3176
+ * ```
3177
+ */
3178
+ async getCities(e) {
3179
+ const t = await this._client.request("weather.getCities", e);
3180
+ if (!t.success)
3181
+ throw new Error(t.error || "Failed to fetch cities");
3182
+ return t.data || [];
3183
+ }
3184
+ /**
3185
+ * Retrieves current weather conditions for a specified city
3186
+ *
3187
+ * @param params - Weather request parameters including cityId and optional language
3188
+ * @returns A promise that resolves to the current weather conditions with dual units (C/F, kph/mph, etc.)
3189
+ * @throws {Error} If the request fails or cityId is invalid
3190
+ *
3191
+ * @example
3192
+ * ```typescript
3193
+ * // Get current conditions for a city
3194
+ * const conditions = await weather.getConditions({ cityId: 12345 })
3195
+ *
3196
+ * // With localized language
3197
+ * const conditions = await weather.getConditions({
3198
+ * cityId: 12345,
3199
+ * language: 'es'
3200
+ * })
3201
+ *
3202
+ * // Access both units
3203
+ * console.log(`${conditions.temperatureC}°C / ${conditions.temperatureF}°F`)
3204
+ * console.log(`${conditions.windSpeedKph} kph / ${conditions.windSpeedMph} mph`)
3205
+ * ```
3206
+ */
3207
+ async getConditions(e) {
3208
+ const t = await this._client.request("weather.getConditions", e);
3209
+ if (!t.success)
3210
+ throw new Error(t.error || "Failed to fetch weather conditions");
3211
+ return t;
3212
+ }
3213
+ /**
3214
+ * Retrieves daily weather forecast for a specified city
3215
+ *
3216
+ * @param params - Forecast request parameters including cityId, optional language and days
3217
+ * @returns A promise that resolves to daily forecast data with location information
3218
+ * @throws {Error} If the request fails or cityId is invalid
3219
+ *
3220
+ * @example
3221
+ * ```typescript
3222
+ * // Get 5-day forecast
3223
+ * const forecast = await weather.getDailyForecast({ cityId: 12345 })
3224
+ *
3225
+ * // Get 10-day forecast
3226
+ * const forecast = await weather.getDailyForecast({ cityId: 12345, days: 10 })
3227
+ *
3228
+ * // Access forecast data
3229
+ * forecast.data.forEach(day => {
3230
+ * console.log(`${day.forecastDate}: ${day.weatherDescription}`)
3231
+ * console.log(`High: ${day.maxTemperatureC}°C, Low: ${day.minTemperatureC}°C`)
3232
+ * })
3233
+ * ```
3234
+ */
3235
+ async getDailyForecast(e) {
3236
+ const t = await this._client.request("weather.getDailyForecast", e);
3237
+ if (!t.success)
3238
+ throw new Error(t.error || "Failed to fetch daily forecast");
3239
+ return t;
3240
+ }
3241
+ /**
3242
+ * Retrieves hourly weather forecast for a specified city
3243
+ *
3244
+ * @param params - Forecast request parameters including cityId, optional language and hours
3245
+ * @returns A promise that resolves to hourly forecast data with location information
3246
+ * @throws {Error} If the request fails or cityId is invalid
3247
+ *
3248
+ * @example
3249
+ * ```typescript
3250
+ * // Get 24-hour forecast
3251
+ * const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 24 })
3252
+ *
3253
+ * // Get 48-hour forecast
3254
+ * const forecast = await weather.getHourlyForecast({ cityId: 12345, hours: 48 })
3255
+ *
3256
+ * // Access forecast data
3257
+ * forecast.data.forEach(hour => {
3258
+ * console.log(`${hour.forecastTimeLocal}: ${hour.weatherDescription}`)
3259
+ * console.log(`Temp: ${hour.temperatureC}°C`)
3260
+ * })
3261
+ * ```
3370
3262
  */
3371
- constructor(e) {
3372
- if (e._client._applicationSpecifier !== "rootSettingsNavigation")
3373
- throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");
3374
- this._store = e;
3263
+ async getHourlyForecast(e) {
3264
+ const t = await this._client.request("weather.getHourlyForecast", e);
3265
+ if (!t.success)
3266
+ throw new Error(t.error || "Failed to fetch hourly forecast");
3267
+ return t;
3375
3268
  }
3376
3269
  /**
3377
- * Registers navigation entries for the root application in the TelemetryOS admin UI.
3270
+ * Retrieves weather alerts and warnings for a specified city
3378
3271
  *
3379
- * This method allows a root application to define its sidebar navigation structure
3380
- * within the TelemetryOS administration UI. The navigation entries will appear in the
3381
- * sidebar menu, allowing users to navigate to different sections of the application.
3272
+ * @param params - Alert request parameters including cityId and optional language
3273
+ * @returns A promise that resolves to weather alerts with location information
3274
+ * @throws {Error} If the request fails or cityId is invalid
3382
3275
  *
3383
- * @param navigation An object containing the navigation entries to register
3384
- * @returns A promise that resolves when the navigation has been registered
3276
+ * @example
3277
+ * ```typescript
3278
+ * // Get weather alerts for a city
3279
+ * const alerts = await weather.getAlerts({ cityId: 12345 })
3280
+ *
3281
+ * // Check if there are any active alerts
3282
+ * if (alerts.alerts.length > 0) {
3283
+ * alerts.alerts.forEach(alert => {
3284
+ * console.log(`${alert.severity}: ${alert.title}`)
3285
+ * console.log(alert.description)
3286
+ * })
3287
+ * }
3288
+ * ```
3385
3289
  */
3386
- async setRootSettingsNavigation(e) {
3387
- var t;
3388
- const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, r = this._store._client._applicationSpecifier;
3389
- n[r] = {
3390
- applicationSpecifier: r,
3391
- entries: e.entries
3392
- }, s.set("navigation", n);
3290
+ async getAlerts(e) {
3291
+ const t = await this._client.request("weather.getAlerts", e);
3292
+ if (!t.success)
3293
+ throw new Error(t.error || "Failed to fetch weather alerts");
3294
+ return t;
3295
+ }
3296
+ }
3297
+ class Ct {
3298
+ constructor(e) {
3299
+ this._client = e;
3393
3300
  }
3394
3301
  /**
3395
- * Retrieves the current navigation entries for this root application.
3302
+ * Retrieves all available currency symbols and their full names.
3396
3303
  *
3397
- * This method returns the navigation structure that was previously registered
3398
- * for this application using setRootSettingsNavigation().
3304
+ * @returns A promise that resolves to a mapping of currency codes to their full names
3305
+ * @throws {Error} If the request fails
3399
3306
  *
3400
- * @returns A promise that resolves to the navigation state for this application
3307
+ * @example
3308
+ * ```typescript
3309
+ * const symbols = await currency().getSymbols()
3310
+ * // { "USD": "United States Dollar", "EUR": "Euro", ... }
3311
+ * ```
3401
3312
  */
3402
- async getRootSettingsNavigation() {
3403
- var e;
3404
- const s = (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {}, n = this._store._client._applicationSpecifier;
3405
- return s[n];
3313
+ async getSymbols() {
3314
+ const e = await this._client.request("currency.getSymbols", {});
3315
+ if (!e.success || !e.symbols)
3316
+ throw new Error("Failed to fetch currency symbols");
3317
+ return e.symbols;
3406
3318
  }
3407
3319
  /**
3408
- * Retrieves the navigation entries for all root applications.
3320
+ * Retrieves current exchange rates for a base currency against target currencies.
3409
3321
  *
3410
- * This method returns the navigation structures for all root applications registered
3411
- * in the TelemetryOS administration UI. This can be useful for coordination between
3412
- * different root applications.
3322
+ * @param params - Currency rate request parameters including base currency and target symbols
3323
+ * @returns A promise that resolves to a mapping of currency codes to their exchange rates
3324
+ * @throws {Error} If the request fails or currencies are invalid
3413
3325
  *
3414
- * @returns A promise that resolves to the navigation state for all applications
3326
+ * @example
3327
+ * ```typescript
3328
+ * // Get exchange rates for USD against EUR, GBP, and JPY
3329
+ * const rates = await currency().getRates({
3330
+ * base: 'USD',
3331
+ * symbols: 'EUR,GBP,JPY'
3332
+ * })
3333
+ * // { "EUR": 0.92, "GBP": 0.79, "JPY": 149.50 }
3334
+ * ```
3415
3335
  */
3416
- async getAllRootSettingsNavigation() {
3417
- var e;
3418
- return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
3336
+ async getRates(e) {
3337
+ var t, s, n;
3338
+ const a = await this._client.request("currency.getRates", e);
3339
+ if (!a.success || !a.rates)
3340
+ throw ((t = a.error) === null || t === void 0 ? void 0 : t.code) === 201 ? new Error(`Invalid base currency '${e.base}'`) : ((s = a.error) === null || s === void 0 ? void 0 : s.code) === 202 ? new Error(`Invalid target currency symbol '${e.symbols}'`) : new Error(((n = a.error) === null || n === void 0 ? void 0 : n.message) || "Failed to fetch currency rates");
3341
+ return a.rates;
3419
3342
  }
3420
3343
  }
3421
- const B = 1e3 * 30, _e = typeof window > "u" && typeof self < "u", K = _e ? self : window;
3422
- function U(a) {
3423
- _e ? self.postMessage(a) : K.parent.postMessage(a, "*");
3344
+ class It {
3345
+ constructor(e) {
3346
+ this._client = e;
3347
+ }
3348
+ async getColorScheme() {
3349
+ return (await this._client.request("environment.getColorScheme", {})).colorScheme;
3350
+ }
3351
+ async subscribeColorScheme(e) {
3352
+ return (await this._client.subscribe("environment.subscribeColorScheme", {}, e)).success;
3353
+ }
3354
+ async unsubscribeColorScheme(e) {
3355
+ return (await this._client.unsubscribe("environment.unsubscribeColorScheme", {}, e)).success;
3356
+ }
3424
3357
  }
3425
- class Tt {
3358
+ class Nt {
3359
+ constructor(e) {
3360
+ this._client = e;
3361
+ }
3362
+ async discover() {
3363
+ const e = await this._client.request("mqtt.discover", {});
3364
+ if (!e.success)
3365
+ throw new Error("Failed to discover MQTT brokers");
3366
+ return e.brokers;
3367
+ }
3368
+ async connect(e, t) {
3369
+ const s = await this._client.request("mqtt.connect", {
3370
+ brokerUrl: e,
3371
+ ...t
3372
+ });
3373
+ if (!s.success)
3374
+ throw new Error("Failed to connect to MQTT broker");
3375
+ return s.clientId;
3376
+ }
3377
+ async disconnect(e) {
3378
+ if (!(await this._client.request("mqtt.disconnect", { clientId: e })).success)
3379
+ throw new Error("Failed to disconnect from MQTT broker");
3380
+ }
3381
+ async publish(e, t, s, n) {
3382
+ if (!(await this._client.request("mqtt.publish", {
3383
+ clientId: e,
3384
+ topic: t,
3385
+ payload: s,
3386
+ ...n
3387
+ })).success)
3388
+ throw new Error("Failed to publish MQTT message");
3389
+ }
3390
+ async subscribe(e, t, s, n) {
3391
+ return (await this._client.subscribe("mqtt.subscribe", {
3392
+ clientId: e,
3393
+ topic: t,
3394
+ ...n
3395
+ }, s)).success;
3396
+ }
3397
+ async unsubscribe(e, t, s) {
3398
+ return (await this._client.unsubscribe("mqtt.unsubscribe", {
3399
+ clientId: e,
3400
+ topic: t
3401
+ }, s)).success;
3402
+ }
3403
+ async getConnectionStatus(e) {
3404
+ const t = await this._client.request("mqtt.getConnectionStatus", {
3405
+ clientId: e
3406
+ });
3407
+ if (!t.success)
3408
+ throw new Error("Failed to get MQTT connection status");
3409
+ return t.status;
3410
+ }
3411
+ async subscribeConnectionStatus(e, t) {
3412
+ return (await this._client.subscribe("mqtt.subscribeConnectionStatus", {
3413
+ clientId: e
3414
+ }, t)).success;
3415
+ }
3416
+ async unsubscribeConnectionStatus(e, t) {
3417
+ return (await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus", {
3418
+ clientId: e
3419
+ }, t)).success;
3420
+ }
3421
+ }
3422
+ class Zt {
3423
+ constructor(e) {
3424
+ this._originalPushState = null, this._originalReplaceState = null, this._popstateHandler = null, this._backHandler = null, this._forwardHandler = null, this._client = e;
3425
+ }
3426
+ bind() {
3427
+ typeof window > "u" || this._originalPushState || (this._originalPushState = history.pushState.bind(history), history.pushState = (...e) => {
3428
+ this._originalPushState(...e), this._sendLocationChanged();
3429
+ }, this._originalReplaceState = history.replaceState.bind(history), history.replaceState = (...e) => {
3430
+ this._originalReplaceState(...e), this._sendLocationChanged();
3431
+ }, this._popstateHandler = () => this._sendLocationChanged(), window.addEventListener("popstate", this._popstateHandler), this._backHandler = () => history.back(), this._forwardHandler = () => history.forward(), this._client.on("navigation.back", this._backHandler), this._client.on("navigation.forward", this._forwardHandler), this._sendLocationChanged());
3432
+ }
3433
+ unbind() {
3434
+ typeof window > "u" || (this._originalPushState && (history.pushState = this._originalPushState, this._originalPushState = null), this._originalReplaceState && (history.replaceState = this._originalReplaceState, this._originalReplaceState = null), this._popstateHandler && (window.removeEventListener("popstate", this._popstateHandler), this._popstateHandler = null), this._backHandler && (this._client.off("navigation.back", this._backHandler), this._backHandler = null), this._forwardHandler && (this._client.off("navigation.forward", this._forwardHandler), this._forwardHandler = null));
3435
+ }
3436
+ _sendLocationChanged() {
3437
+ this._client.send("navigation.locationChanged", {
3438
+ pathname: window.location.pathname
3439
+ });
3440
+ }
3441
+ }
3442
+ const B = 1e3 * 30, Me = 1e3 * 5, oe = typeof window > "u" && typeof self < "u", ee = oe ? "worker" : "window", W = oe ? self : window;
3443
+ function U(i) {
3444
+ oe ? self.postMessage(i) : W.parent.postMessage(i, "*");
3445
+ }
3446
+ class At {
3426
3447
  /**
3427
3448
  * Creates a new Client instance for communicating with the TelemetryOS platform.
3428
3449
  *
@@ -3431,7 +3452,7 @@ class Tt {
3431
3452
  * the application ID from the URL.
3432
3453
  */
3433
3454
  constructor() {
3434
- this._applicationInstance = "", this._applicationSpecifier = "", this._deviceId = "", this._navigation = new Ge(this), this._messageInterceptors = /* @__PURE__ */ new Map(), this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map();
3455
+ this._applicationInstance = "", this._applicationSpecifier = "", this._deviceId = "", this._heartbeatInterval = null, this._heartbeatSignature = K(), this._messageInterceptors = /* @__PURE__ */ new Map(), this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map(), this._dependencyStore = new Et(this), this._navigation = new Zt(this);
3435
3456
  }
3436
3457
  /**
3437
3458
  * Provides access to the accounts API for retrieving TelemetryOS account information.
@@ -3445,7 +3466,7 @@ class Tt {
3445
3466
  * @returns An Accounts instance bound to this client
3446
3467
  */
3447
3468
  get accounts() {
3448
- return new Le(this);
3469
+ return new De(this);
3449
3470
  }
3450
3471
  /**
3451
3472
  * Provides access to the users API for retrieving TelemetryOS user information.
@@ -3459,7 +3480,7 @@ class Tt {
3459
3480
  * @returns A Users instance bound to this client
3460
3481
  */
3461
3482
  get users() {
3462
- return new Ke(this);
3483
+ return new kt(this);
3463
3484
  }
3464
3485
  /**
3465
3486
  * Provides access to the store API for data persistence with multiple storage scopes.
@@ -3473,7 +3494,7 @@ class Tt {
3473
3494
  * @returns A Store instance bound to this client
3474
3495
  */
3475
3496
  get store() {
3476
- return new Ue(this);
3497
+ return new bt(this);
3477
3498
  }
3478
3499
  /**
3479
3500
  * Provides access to the applications API for discovering other TelemetryOS applications.
@@ -3487,7 +3508,7 @@ class Tt {
3487
3508
  * @returns An Applications instance bound to this client
3488
3509
  */
3489
3510
  get applications() {
3490
- return new He(this);
3511
+ return new Ve(this);
3491
3512
  }
3492
3513
  /**
3493
3514
  * Provides access to the media API for working with content hosted on the TelemetryOS platform.
@@ -3502,7 +3523,7 @@ class Tt {
3502
3523
  * @returns A Media instance bound to this client
3503
3524
  */
3504
3525
  get media() {
3505
- return new De(this);
3526
+ return new ze(this);
3506
3527
  }
3507
3528
  /**
3508
3529
  * Provides access to the proxy API for fetching third-party content through the TelemetryOS API.
@@ -3516,7 +3537,7 @@ class Tt {
3516
3537
  * @returns A Proxy instance bound to this client
3517
3538
  */
3518
3539
  get proxy() {
3519
- return new Be(this);
3540
+ return new xt(this);
3520
3541
  }
3521
3542
  /**
3522
3543
  * Provides access to the devices API for interacting with the current device.
@@ -3531,7 +3552,7 @@ class Tt {
3531
3552
  * @returns A Devices instance bound to this client
3532
3553
  */
3533
3554
  get devices() {
3534
- return new Ve(this);
3555
+ return new St(this);
3535
3556
  }
3536
3557
  /**
3537
3558
  * Provides access to the root settings navigation API for TelemetryOS administration UI integration.
@@ -3549,7 +3570,7 @@ class Tt {
3549
3570
  * @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
3550
3571
  */
3551
3572
  get rootSettingsNavigation() {
3552
- return new Ct(this.store);
3573
+ return new wt(this.store);
3553
3574
  }
3554
3575
  /**
3555
3576
  * Provides access to the weather API for retrieving weather data.
@@ -3563,7 +3584,7 @@ class Tt {
3563
3584
  * @returns A Weather instance bound to this client
3564
3585
  */
3565
3586
  get weather() {
3566
- return new We(this);
3587
+ return new Tt(this);
3567
3588
  }
3568
3589
  /**
3569
3590
  * Provides access to the currency API for retrieving currency exchange rates.
@@ -3577,7 +3598,7 @@ class Tt {
3577
3598
  * @returns A Currency instance bound to this client
3578
3599
  */
3579
3600
  get currency() {
3580
- return new Je(this);
3601
+ return new Ct(this);
3581
3602
  }
3582
3603
  /**
3583
3604
  * Provides access to the environment API for accessing environment settings.
@@ -3591,10 +3612,10 @@ class Tt {
3591
3612
  * @returns An Environment instance bound to this client
3592
3613
  */
3593
3614
  get environment() {
3594
- return new ze(this);
3615
+ return new It(this);
3595
3616
  }
3596
3617
  get mqtt() {
3597
- return new Qe(this);
3618
+ return new Nt(this);
3598
3619
  }
3599
3620
  get applicationSpecifier() {
3600
3621
  return this._applicationSpecifier;
@@ -3622,53 +3643,67 @@ class Tt {
3622
3643
  */
3623
3644
  bind() {
3624
3645
  var e, t;
3625
- const s = new URL(K.location.href), n = s.searchParams;
3646
+ const s = new URL(W.location.href), n = s.searchParams;
3626
3647
  this._applicationInstance = n.get("applicationInstance") || "single", this._deviceId = n.get("deviceId") || this._applicationInstance;
3627
- const r = /^[a-z0-9-]{40}$/i;
3628
- if (this._applicationSpecifier = (e = n.get("applicationSpecifier")) !== null && e !== void 0 ? e : "", !this._applicationSpecifier || !r.test(this._applicationSpecifier)) {
3629
- const i = s.hostname.split(".");
3630
- this._applicationSpecifier = (t = i[0]) !== null && t !== void 0 ? t : "";
3648
+ const a = /^[a-z0-9-]{40}$/i;
3649
+ if (this._applicationSpecifier = (e = n.get("applicationSpecifier")) !== null && e !== void 0 ? e : "", !this._applicationSpecifier || !a.test(this._applicationSpecifier)) {
3650
+ const r = s.hostname.split(".");
3651
+ this._applicationSpecifier = (t = r[0]) !== null && t !== void 0 ? t : "";
3631
3652
  }
3632
- if (!this._applicationSpecifier || !r.test(this._applicationSpecifier))
3653
+ if (!this._applicationSpecifier || !a.test(this._applicationSpecifier))
3633
3654
  throw console.error("TelemetryOS apps require an applicationSpecifier in the URL query parameters or subdomain. Make sure your app is being served correctly through the TelemetryOS platform or development environment."), new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
3634
- this._windowMessageHandler = (i) => {
3635
- if (i.source === K || !i.data || typeof i.data != "object" || !("type" in i.data) || i.data.type !== "client" && i.data.type !== "bridge")
3655
+ this._windowMessageHandler = (r) => {
3656
+ if (r.source === W || !r.data || typeof r.data != "object" || !("type" in r.data) || r.data.type !== "client" && r.data.type !== "bridge")
3636
3657
  return;
3637
3658
  let o;
3638
- if (i.data.type === "client") {
3639
- const c = this._messageInterceptors.get(i.data.name);
3640
- if (!c) {
3641
- U(i.data);
3659
+ if (r.data.type === "client") {
3660
+ const c = vt.safeParse(r.data);
3661
+ if (!c.success) {
3662
+ const S = r.data;
3663
+ S && typeof S == "object" && S.type === "client" && console.warn("[sdk-client] Received a message that looks like a client message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.", c.error.issues);
3642
3664
  return;
3643
3665
  }
3666
+ const l = c.data, f = this._messageInterceptors.get(l.name);
3667
+ if (!f)
3668
+ return U(l);
3669
+ let w;
3670
+ try {
3671
+ w = f(l);
3672
+ } catch (S) {
3673
+ console.error(`Error in interceptor for message ${l.name}:`, S);
3674
+ }
3675
+ if (!w)
3676
+ return;
3644
3677
  o = {
3645
- ...c(i.data.data),
3678
+ ...w,
3646
3679
  type: "bridge",
3647
- ...i.data.responseName ? { name: i.data.responseName } : {}
3680
+ ...r.data.responseName ? { name: r.data.responseName } : {}
3648
3681
  };
3649
3682
  }
3650
3683
  if (!o) {
3651
- const c = St.safeParse(i.data);
3684
+ const c = yt.safeParse(r.data);
3652
3685
  if (!c.success) {
3653
- const w = i.data;
3686
+ const w = r.data;
3654
3687
  w && typeof w == "object" && w.type === "bridge" && console.warn("[sdk-client] Received a message that looks like a bridge message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.", c.error.issues);
3655
3688
  return;
3656
3689
  }
3657
3690
  o = c.data;
3658
- const l = this._onHandlers.get(o.name), g = this._onceHandlers.get(o.name);
3691
+ const l = this._onHandlers.get(o.name), f = this._onceHandlers.get(o.name);
3659
3692
  if (l)
3660
3693
  for (const w of l)
3661
3694
  w(o.data);
3662
- if (g) {
3663
- for (const w of g)
3695
+ if (f) {
3696
+ for (const w of f)
3664
3697
  w(o.data);
3665
3698
  this._onceHandlers.delete(o.name);
3666
3699
  }
3667
3700
  }
3668
- if (!_e)
3701
+ if (!oe)
3669
3702
  for (let c = 0; c < window.frames.length; c += 1)
3670
3703
  window.frames[c].postMessage(o, "*");
3671
- }, K.addEventListener("message", this._windowMessageHandler), this._navigation.bind();
3704
+ }, W.addEventListener("message", this._windowMessageHandler), this._navigation.bind(), this._heartbeatInterval = setInterval(() => {
3705
+ this.send("heartbeat", { signature: this._heartbeatSignature });
3706
+ }, Me);
3672
3707
  }
3673
3708
  /**
3674
3709
  * Removes the message event listener and cleans up resources.
@@ -3684,7 +3719,7 @@ class Tt {
3684
3719
  * of managing their own Client instances.
3685
3720
  */
3686
3721
  unbind() {
3687
- this._windowMessageHandler && (this._navigation.unbind(), K.removeEventListener("message", this._windowMessageHandler));
3722
+ this._windowMessageHandler && (this._navigation.unbind(), W.removeEventListener("message", this._windowMessageHandler), this._heartbeatInterval && clearInterval(this._heartbeatInterval));
3688
3723
  }
3689
3724
  /**
3690
3725
  * Sends a one-way message to the TelemetryOS platform.
@@ -3701,9 +3736,10 @@ class Tt {
3701
3736
  */
3702
3737
  send(e, t) {
3703
3738
  const s = Y({
3704
- telemetrySdkVersion: ee,
3739
+ telemetrySdkVersion: te,
3705
3740
  applicationSpecifier: this._applicationSpecifier,
3706
3741
  applicationInstance: this._applicationInstance,
3742
+ runtime: ee,
3707
3743
  name: e,
3708
3744
  data: t
3709
3745
  });
@@ -3730,97 +3766,100 @@ class Tt {
3730
3766
  */
3731
3767
  request(e, t, s) {
3732
3768
  var n;
3733
- const r = X(), i = Y({
3734
- telemetrySdkVersion: ee,
3769
+ const a = K(), r = Y({
3770
+ telemetrySdkVersion: te,
3735
3771
  applicationSpecifier: this._applicationSpecifier,
3736
3772
  applicationInstance: this._applicationInstance,
3773
+ runtime: ee,
3737
3774
  name: e,
3738
3775
  data: t,
3739
- responseName: r
3776
+ responseName: a
3740
3777
  });
3741
- U(i);
3778
+ U(r);
3742
3779
  const o = (n = s == null ? void 0 : s.timeout) !== null && n !== void 0 ? n : B;
3743
3780
  let c = !1, l;
3744
- const g = new Promise((T) => {
3745
- l = (R) => {
3746
- c || T(R);
3747
- }, this.once(r, l);
3781
+ const f = new Promise((S) => {
3782
+ l = (j) => {
3783
+ c || S(j);
3784
+ }, this.once(a, l);
3748
3785
  });
3749
3786
  if (o === 0)
3750
- return g;
3751
- const w = new Promise((T, R) => {
3752
- const z = new Error(`${e} message request with response name of ${r} timed out after ${o}`);
3787
+ return f;
3788
+ const w = new Promise((S, j) => {
3789
+ const V = new Error(`${e} message request with response name of ${a} timed out after ${o}`);
3753
3790
  setTimeout(() => {
3754
- c = !0, this.off(r, l), R(z);
3791
+ c = !0, this.off(a, l), j(V);
3755
3792
  }, o);
3756
3793
  });
3757
- return Promise.race([w, g]);
3794
+ return Promise.race([w, f]);
3758
3795
  }
3759
3796
  async subscribe(e, t, s) {
3760
- let n, r;
3761
- typeof t == "function" ? r = t : (n = t, r = s);
3762
- const i = X(), o = X();
3797
+ let n, a;
3798
+ typeof t == "function" ? a = t : (n = t, a = s);
3799
+ const r = K(), o = K();
3763
3800
  let c = this._subscriptionNamesBySubjectName.get(e);
3764
- c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(i), this._subscriptionNamesByHandler.set(r, i), this.on(i, r);
3801
+ c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(r), this._subscriptionNamesByHandler.set(a, r), this.on(r, a);
3765
3802
  const l = Y({
3766
- telemetrySdkVersion: ee,
3803
+ telemetrySdkVersion: te,
3767
3804
  applicationSpecifier: this._applicationSpecifier,
3768
3805
  applicationInstance: this._applicationInstance,
3806
+ runtime: ee,
3769
3807
  name: e,
3770
3808
  data: n,
3771
3809
  responseName: o,
3772
- subscriptionName: i
3810
+ subscriptionName: r
3773
3811
  });
3774
3812
  U(l);
3775
- let g = !1, w;
3776
- const T = new Promise((z, F) => {
3777
- const D = new Error(`${e} subscribe request with subscription name of ${i} and response name of ${o} timed out after ${B}`);
3813
+ let f = !1, w;
3814
+ const S = new Promise((V, F) => {
3815
+ const z = new Error(`${e} subscribe request with subscription name of ${r} and response name of ${o} timed out after ${B}`);
3778
3816
  setTimeout(() => {
3779
- g = !0, this.off(o, w), F(D);
3817
+ f = !0, this.off(o, w), F(z);
3780
3818
  }, B);
3781
- }), R = new Promise((z) => {
3819
+ }), j = new Promise((V) => {
3782
3820
  w = (F) => {
3783
- g || z(F);
3821
+ f || V(F);
3784
3822
  }, this.once(o, w);
3785
3823
  });
3786
- return Promise.race([T, R]);
3824
+ return Promise.race([S, j]);
3787
3825
  }
3788
3826
  async unsubscribe(e, t, s) {
3789
- let n, r;
3790
- typeof t == "function" ? r = t : (n = t, r = s);
3791
- const i = X();
3827
+ let n, a;
3828
+ typeof t == "function" ? a = t : (n = t, a = s);
3829
+ const r = K();
3792
3830
  let o = [];
3793
- if (r) {
3794
- const c = this._subscriptionNamesByHandler.get(r);
3831
+ if (a) {
3832
+ const c = this._subscriptionNamesByHandler.get(a);
3795
3833
  if (!c)
3796
3834
  return { success: !1 };
3797
- o = [c], this._subscriptionNamesByHandler.delete(r);
3835
+ o = [c], this._subscriptionNamesByHandler.delete(a);
3798
3836
  } else if (!this._subscriptionNamesBySubjectName.get(e))
3799
3837
  return { success: !1 };
3800
3838
  for await (const c of o) {
3801
- this.off(c, r);
3839
+ this.off(c, a);
3802
3840
  const l = Y({
3803
- telemetrySdkVersion: ee,
3841
+ telemetrySdkVersion: te,
3804
3842
  applicationInstance: this._applicationInstance,
3805
3843
  applicationSpecifier: this._applicationSpecifier,
3844
+ runtime: ee,
3806
3845
  name: e,
3807
3846
  data: n,
3808
- responseName: i,
3847
+ responseName: r,
3809
3848
  unsubscribeName: c
3810
3849
  });
3811
3850
  U(l);
3812
- let g = !1, w;
3813
- const T = new Promise((F, D) => {
3814
- const Fe = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${i} timed out after ${B}`);
3851
+ let f = !1, w;
3852
+ const S = new Promise((F, z) => {
3853
+ const qe = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${r} timed out after ${B}`);
3815
3854
  setTimeout(() => {
3816
- g = !0, this.off(i, w), D(Fe);
3855
+ f = !0, this.off(r, w), z(qe);
3817
3856
  }, B);
3818
- }), R = new Promise((F) => {
3819
- w = (D) => {
3820
- g || F(D);
3821
- }, this.once(i, w);
3857
+ }), j = new Promise((F) => {
3858
+ w = (z) => {
3859
+ f || F(z);
3860
+ }, this.once(r, w);
3822
3861
  });
3823
- if (!(await Promise.race([T, R])).success)
3862
+ if (!(await Promise.race([S, j])).success)
3824
3863
  return { success: !1 };
3825
3864
  }
3826
3865
  return { success: !0 };
@@ -3885,133 +3924,301 @@ class Tt {
3885
3924
  const s = this._onHandlers.get(e), n = this._onceHandlers.get(e);
3886
3925
  if (!(!s && !n)) {
3887
3926
  if (s) {
3888
- for (let r = 0; r < s.length; r += 1)
3889
- t && s[r] !== t || (s.splice(r, 1), r -= 1);
3927
+ for (let a = 0; a < s.length; a += 1)
3928
+ t && s[a] !== t || (s.splice(a, 1), a -= 1);
3890
3929
  s.length === 0 && this._onHandlers.delete(e);
3891
3930
  }
3892
3931
  if (n) {
3893
- for (let r = 0; r < n.length; r += 1)
3894
- t && n[r] !== t || (n.splice(r, 1), r -= 1);
3932
+ for (let a = 0; a < n.length; a += 1)
3933
+ t && n[a] !== t || (n.splice(a, 1), a -= 1);
3895
3934
  n.length === 0 && this._onceHandlers.delete(e);
3896
3935
  }
3897
3936
  }
3898
3937
  }
3899
3938
  }
3900
- function X() {
3939
+ function K() {
3901
3940
  return Math.random().toString(36).slice(2, 9);
3902
3941
  }
3903
- const ee = qe.version;
3904
- let f = null;
3905
- function Ot() {
3906
- return f;
3907
- }
3908
- function It(a) {
3909
- Nt(), f = new Tt(), f.bind();
3910
- }
3911
- function Nt() {
3912
- f == null || f.unbind(), f = null;
3913
- }
3914
- function Et(...a) {
3915
- return x(f), f.on(...a);
3916
- }
3917
- function jt(...a) {
3918
- return x(f), f.once(...a);
3942
+ const Ot = 3;
3943
+ class Et {
3944
+ constructor(e) {
3945
+ this._client = e, this._dependencies = /* @__PURE__ */ new Map(), this._heartbeatTimeouts = /* @__PURE__ */ new Map(), this._client._messageInterceptors.set("heartbeat", (t) => {
3946
+ this._handleHeartbeat(t.applicationSpecifier, t.applicationInstance);
3947
+ });
3948
+ }
3949
+ /**
3950
+ * Sends the full set of dependency specifiers to the platform and reconciles
3951
+ * local handles. Any previously tracked dependency that is no longer present
3952
+ * in the new specifiers map is destroyed.
3953
+ *
3954
+ * @param applicationSpecifiers A map of application specifier to an array of instance IDs
3955
+ */
3956
+ async setDependencies(e) {
3957
+ this._client.send("applications.setDependencies", {
3958
+ applicationSpecifiers: e
3959
+ });
3960
+ const t = [];
3961
+ for (const [s, n] of this._dependencies.entries()) {
3962
+ const [a, r] = s.split(":");
3963
+ (!e[a] || !e[a].includes(r)) && (t.push(n._destroy()), this._dependencies.delete(s));
3964
+ }
3965
+ await Promise.all(t);
3966
+ }
3967
+ /**
3968
+ * Returns the {@link DependencyHandle} for a given specifier and instance ID,
3969
+ * creating one if it does not already exist.
3970
+ *
3971
+ * @param specifier The application specifier (40-char hex)
3972
+ * @param instanceId The unique instance identifier
3973
+ * @returns The existing or newly created DependencyHandle
3974
+ */
3975
+ handleFor(e, t) {
3976
+ let s = this._dependencies.get(`${e}:${t}`);
3977
+ return s || (s = new $t(this, e, t), this._dependencies.set(`${e}:${t}`, s), s);
3978
+ }
3979
+ /**
3980
+ * Resets the heartbeat timeout for the given dependency. If no heartbeat
3981
+ * arrives within {@link missedHeartbeatsThreshold} intervals the
3982
+ * dependency's iframe is reloaded.
3983
+ */
3984
+ _handleHeartbeat(e, t) {
3985
+ const s = `${e}:${t}`, n = this._dependencies.get(s);
3986
+ if (!n)
3987
+ return;
3988
+ const a = this._heartbeatTimeouts.get(s);
3989
+ a && clearTimeout(a), this._heartbeatTimeouts.set(s, setTimeout(() => {
3990
+ this._heartbeatTimeouts.delete(s), n._resetIframe();
3991
+ }, Me * Ot));
3992
+ }
3919
3993
  }
3920
- function Pt(...a) {
3921
- return x(f), f.off(...a);
3994
+ class $t {
3995
+ /** The current download/readiness status of the dependency. */
3996
+ get status() {
3997
+ return this._status;
3998
+ }
3999
+ /** A deep clone of the application record, or null if not yet available. */
4000
+ get application() {
4001
+ return structuredClone(this._application);
4002
+ }
4003
+ constructor(e, t, s) {
4004
+ this._store = e, this._specifier = t, this._instanceId = s, this._status = "unloaded", this._application = null, this._iframe = null, this._onStatusHandlers = /* @__PURE__ */ new Set(), this._subscriptionHandler = (n) => {
4005
+ this._status = n.status, this._application = n.application;
4006
+ for (const a of this._onStatusHandlers)
4007
+ a(n.status);
4008
+ }, this._store._client.subscribe("applications.dependency", {
4009
+ applicationSpecifier: this._specifier,
4010
+ applicationInstance: this._instanceId
4011
+ }, this._subscriptionHandler).catch((n) => {
4012
+ console.error(`Dependency subscription failed for ${this._specifier}:${this._instanceId}:`, n);
4013
+ });
4014
+ }
4015
+ /**
4016
+ * Returns a promise that resolves with an iframe element once the dependency
4017
+ * is ready, or null if the dependency becomes unloaded before it is ready.
4018
+ *
4019
+ * If the dependency is already ready, the promise resolves immediately with
4020
+ * the cached iframe. The iframe's `src` is pre-configured for the dependency.
4021
+ *
4022
+ * @returns A promise resolving to the iframe element or null
4023
+ */
4024
+ async frame() {
4025
+ return new Promise((e) => {
4026
+ if (this._iframe)
4027
+ return e(this._iframe);
4028
+ if (this._status === "ready")
4029
+ return this._iframe = this._buildIframe(), e(this._iframe);
4030
+ let t;
4031
+ const s = (n) => {
4032
+ if (n === "ready")
4033
+ return t(), this._iframe = this._buildIframe(), e(this._iframe);
4034
+ if (n === "unloaded")
4035
+ return t(), e(null);
4036
+ };
4037
+ t = this.onStatus(s);
4038
+ });
4039
+ }
4040
+ /**
4041
+ * Registers a callback that fires whenever the dependency status changes.
4042
+ *
4043
+ * @param handler Callback receiving the new {@link ApplicationStatus}
4044
+ * @returns An unsubscribe function that removes the handler
4045
+ */
4046
+ onStatus(e) {
4047
+ return this._onStatusHandlers.add(e), () => {
4048
+ this._onStatusHandlers.delete(e);
4049
+ };
4050
+ }
4051
+ _buildIframe() {
4052
+ var e, t;
4053
+ const s = (t = (e = this._application) === null || e === void 0 ? void 0 : e.versions) === null || t === void 0 ? void 0 : t[0], n = s == null ? void 0 : s.baseUrl;
4054
+ if (!n)
4055
+ return console.error(`No baseUrl for dependency ${this._specifier}:${this._instanceId}`), null;
4056
+ const a = new URL(n);
4057
+ a.searchParams.set("applicationSpecifier", this._specifier), a.searchParams.set("applicationInstance", this._instanceId), a.searchParams.set("deviceId", this._store._client.deviceId);
4058
+ const r = document.createElement("iframe");
4059
+ return r.src = a.toString(), r;
4060
+ }
4061
+ /**
4062
+ * Resets the iframe by clearing it, requesting the host to clean up
4063
+ * subscriptions and state for this instance, then reloading it if the
4064
+ * iframe is still in the DOM.
4065
+ */
4066
+ async _resetIframe() {
4067
+ if (!this._iframe)
4068
+ return;
4069
+ const e = this._iframe, t = e.src;
4070
+ e.src = "about:blank";
4071
+ try {
4072
+ await this._store._client.request("applications.reset", {
4073
+ applicationSpecifier: this._specifier,
4074
+ applicationInstance: this._instanceId,
4075
+ cause: "heartbeat-timeout"
4076
+ });
4077
+ } catch (s) {
4078
+ console.error(`Failed to reset application ${this._specifier}:${this._instanceId}:`, s);
4079
+ }
4080
+ this._iframe === e && e.isConnected && (e.src = t);
4081
+ }
4082
+ /**
4083
+ * Tears down this handle: resets status to 'unloaded', blanks the iframe,
4084
+ * requests the host to clean up all subscriptions (window + worker),
4085
+ * notifies status handlers, and unsubscribes from platform updates.
4086
+ */
4087
+ async _destroy() {
4088
+ this._status = "unloaded", this._iframe && (this._iframe.src = "about:blank"), this._iframe = null;
4089
+ for (const s of this._onStatusHandlers)
4090
+ s("unloaded");
4091
+ const e = `${this._specifier}:${this._instanceId}`, t = this._store._heartbeatTimeouts.get(e);
4092
+ t && (clearTimeout(t), this._store._heartbeatTimeouts.delete(e));
4093
+ try {
4094
+ await this._store._client.request("applications.destroy", {
4095
+ applicationSpecifier: this._specifier,
4096
+ applicationInstance: this._instanceId
4097
+ });
4098
+ } catch (s) {
4099
+ console.error(`Failed to destroy ${this._specifier}:${this._instanceId}:`, s);
4100
+ }
4101
+ await this._store._client.unsubscribe("applications.dependency", {
4102
+ applicationSpecifier: this._specifier,
4103
+ applicationInstance: this._instanceId
4104
+ }, this._subscriptionHandler).catch((s) => {
4105
+ console.error(`Dependency unsubscription failed for ${this._specifier}:${this._instanceId}:`, s);
4106
+ });
4107
+ }
3922
4108
  }
3923
- function Rt(...a) {
3924
- return x(f), f.send(...a);
4109
+ const te = Le.version;
4110
+ let m = null;
4111
+ function Rt() {
4112
+ return m;
3925
4113
  }
3926
- function $t(...a) {
3927
- return x(f), f.request(...a);
4114
+ function Ft(i) {
4115
+ Pt(), m = new At(), m.bind();
3928
4116
  }
3929
- function Ft(...a) {
3930
- return x(f), f.subscribe(...a);
4117
+ function Pt() {
4118
+ m == null || m.unbind(), m = null;
3931
4119
  }
3932
- function Mt(...a) {
3933
- return x(f), f.unsubscribe(...a);
4120
+ function Mt(...i) {
4121
+ return x(m), m.on(...i);
3934
4122
  }
3935
- function qt() {
3936
- return x(f), f.store;
4123
+ function qt(...i) {
4124
+ return x(m), m.once(...i);
3937
4125
  }
3938
- function Lt() {
3939
- return x(f), f.applications;
4126
+ function Ht(...i) {
4127
+ return x(m), m.off(...i);
3940
4128
  }
3941
- function Ht() {
3942
- return x(f), f.media;
4129
+ function Lt(...i) {
4130
+ return x(m), m.send(...i);
3943
4131
  }
3944
- function Vt() {
3945
- return x(f), f.accounts;
4132
+ function Dt(...i) {
4133
+ return x(m), m.request(...i);
3946
4134
  }
3947
- function zt() {
3948
- return x(f), f.users;
4135
+ function Vt(...i) {
4136
+ return x(m), m.subscribe(...i);
3949
4137
  }
3950
- function Dt() {
3951
- return x(f), f.devices;
4138
+ function zt(...i) {
4139
+ return x(m), m.unsubscribe(...i);
3952
4140
  }
3953
4141
  function Bt() {
3954
- return x(f), f.proxy;
4142
+ return x(m), m.store;
3955
4143
  }
3956
4144
  function Ut() {
3957
- return x(f), f.rootSettingsNavigation;
4145
+ return x(m), m.applications;
3958
4146
  }
3959
4147
  function Kt() {
3960
- return x(f), f.weather;
4148
+ return x(m), m.media;
3961
4149
  }
3962
4150
  function Wt() {
3963
- return x(f), f.currency;
4151
+ return x(m), m.accounts;
3964
4152
  }
3965
4153
  function Jt() {
3966
- return x(f), f.environment;
4154
+ return x(m), m.users;
3967
4155
  }
3968
4156
  function Qt() {
3969
- return x(f), f.mqtt;
4157
+ return x(m), m.devices;
4158
+ }
4159
+ function Gt() {
4160
+ return x(m), m.proxy;
4161
+ }
4162
+ function Yt() {
4163
+ return x(m), m.rootSettingsNavigation;
4164
+ }
4165
+ function Xt() {
4166
+ return x(m), m.weather;
4167
+ }
4168
+ function es() {
4169
+ return x(m), m.currency;
4170
+ }
4171
+ function ts() {
4172
+ return x(m), m.environment;
4173
+ }
4174
+ function ss() {
4175
+ return x(m), m.mqtt;
3970
4176
  }
3971
- function x(a) {
3972
- if (!a)
4177
+ function x(i) {
4178
+ if (!i)
3973
4179
  throw new Error("SDK is not configured");
3974
4180
  }
3975
4181
  export {
3976
- Le as Accounts,
3977
- He as Applications,
3978
- Tt as Client,
3979
- Je as Currency,
3980
- Ve as Devices,
3981
- ze as Environment,
3982
- De as Media,
3983
- Qe as Mqtt,
3984
- Ge as Navigation,
3985
- Be as Proxy,
3986
- Ue as Store,
3987
- G as StoreSlice,
3988
- Ke as Users,
3989
- We as Weather,
3990
- Vt as accounts,
3991
- Lt as applications,
3992
- St as bridgeMessageValidator,
3993
- At as clientMessageValidator,
3994
- It as configure,
3995
- Wt as currency,
3996
- Nt as destroy,
3997
- Dt as devices,
3998
- Jt as environment,
3999
- Zt as formatBridgeMessage,
4182
+ De as Accounts,
4183
+ Ve as Applications,
4184
+ At as Client,
4185
+ Ct as Currency,
4186
+ $t as DependencyHandle,
4187
+ St as Devices,
4188
+ It as Environment,
4189
+ ze as Media,
4190
+ Nt as Mqtt,
4191
+ Zt as Navigation,
4192
+ xt as Proxy,
4193
+ bt as Store,
4194
+ X as StoreSlice,
4195
+ kt as Users,
4196
+ Tt as Weather,
4197
+ Wt as accounts,
4198
+ Ut as applications,
4199
+ yt as bridgeMessageValidator,
4200
+ vt as clientMessageValidator,
4201
+ Ft as configure,
4202
+ es as currency,
4203
+ Pt as destroy,
4204
+ Qt as devices,
4205
+ ts as environment,
4206
+ jt as formatBridgeMessage,
4000
4207
  Y as formatClientMessage,
4001
- Ot as globalClient,
4002
- Ht as media,
4003
- Qt as mqtt,
4004
- Pt as off,
4005
- Et as on,
4006
- jt as once,
4007
- Bt as proxy,
4008
- $t as request,
4009
- Ut as rootSettingsNavigation,
4010
- Rt as send,
4011
- qt as store,
4012
- Ft as subscribe,
4013
- ee as telemetrySdkVersion,
4014
- Mt as unsubscribe,
4015
- zt as users,
4016
- Kt as weather
4208
+ Rt as globalClient,
4209
+ Kt as media,
4210
+ ss as mqtt,
4211
+ Ht as off,
4212
+ Mt as on,
4213
+ qt as once,
4214
+ Gt as proxy,
4215
+ Dt as request,
4216
+ Yt as rootSettingsNavigation,
4217
+ Lt as send,
4218
+ Bt as store,
4219
+ Vt as subscribe,
4220
+ te as telemetrySdkVersion,
4221
+ zt as unsubscribe,
4222
+ Jt as users,
4223
+ Xt as weather
4017
4224
  };