@magmacomputing/tempo-plugin-geo 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -2
- package/README.md +112 -17
- package/dist/index.d.ts +51 -18
- package/dist/index.global.min.js +1 -1
- package/dist/index.js +1429 -333
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,34 @@ All notable changes to the `@magmacomputing/tempo-plugin-geo` project will be do
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [1.
|
|
8
|
+
## [1.1.0] - 2026-09-16
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
|
+
- **Plugin Options Merging & Callable Plugin Support**:
|
|
12
|
+
- `GeoPlugin.install` now accepts resolved options passed by `Tempo.use(GeoPlugin, options)` or `Tempo.use(GeoPlugin(options))` or tuple syntax `[GeoPlugin, options]`.
|
|
13
|
+
- Merges class defaults (`installedClass.config?.pluginOptions?.geo`), plugin registration options, instance options, and call-site options prior to coordinate resolution and lookup.
|
|
14
|
+
- Ensures call-site options override configured defaults (such as `timeout` and `highAccuracy`) while preserving existing coordinate resolution behavior.
|
|
15
|
+
|
|
16
|
+
## [1.0.0] - 2026-09-08
|
|
17
|
+
|
|
18
|
+
### Changed (Breaking Changes)
|
|
19
|
+
- **Consolidated `Tempo.geo` Namespace**:
|
|
20
|
+
- Removed loose static methods mounted directly on the `Tempo` root class (`Tempo.geoLookup`, `Tempo.resolveGeoCoordinates`, `Tempo.serverGeoLocation`, `Tempo.geoLocation`) to prevent flat base class pollution.
|
|
21
|
+
- All static geolocation utilities are now organized under the dedicated, immutable **`Tempo.geo`** namespace (`Tempo.geo.lookup`, `Tempo.geo.resolve`, `Tempo.geo.server`, `Tempo.geo.browser`, `Tempo.geo.stash`, `Tempo.geo.clear`, `Tempo.geo.get`, and `Tempo.geo.current`).
|
|
22
|
+
- Standalone tree-shakeable functions (`geoLookup`, `resolveGeoCoordinates`, `serverGeoLocation`, etc.) remain available as direct named exports from the package for tree-shaking.
|
|
23
|
+
- **Storage Key Scoping**:
|
|
24
|
+
- Standardized ambient coordinate storage on `_magma_geo_`.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **24-Hour TTL Caching & Multi-Tenant Partitioning**:
|
|
28
|
+
- Added automatic 24-hour TTL caching for `Tempo.geo.lookup()` with `{ refresh: true }` cache bypass support.
|
|
29
|
+
- Added multi-tenant partitioning in `Tempo.geo.stash()`, `Tempo.geo.get()`, and `Tempo.geo.clear()`, scoping storage under `_magma_geo_:<tenant-id>`.
|
|
30
|
+
- Added `Tempo.geo.current` read-only getter to inspect active ambient coordinates snapshot.
|
|
31
|
+
- **Immutability Hardening**:
|
|
32
|
+
- The `Tempo.geo` namespace and attached utilities are recursively frozen via `deepFreeze()`.
|
|
11
33
|
- **Stable Community Release**:
|
|
12
34
|
- Official 1.0.0 release of `@magmacomputing/tempo-plugin-geo`.
|
|
13
|
-
- Configured npm Trusted Publisher automation for CI/CD publishing.
|
|
35
|
+
- Configured npm Trusted Publisher automation for CI/CD publishing with Sigstore provenance.
|
|
14
36
|
|
|
15
37
|
## [0.1.0] - 2026-09-07
|
|
16
38
|
|
package/README.md
CHANGED
|
@@ -6,50 +6,145 @@
|
|
|
6
6
|
<a href="https://www.npmjs.com/package/@magmacomputing/tempo-plugin-geo"><img src="https://img.shields.io/npm/v/@magmacomputing/tempo-plugin-geo?style=flat-square" alt="npm version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/@magmacomputing/tempo"><img src="https://img.shields.io/npm/dependency-version/@magmacomputing/tempo-plugin-geo/peer/@magmacomputing/tempo?style=flat-square" alt="npm peer dependency version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/@magmacomputing/tempo-plugin-geo"><img src="https://img.shields.io/npm/l/@magmacomputing/tempo-plugin-geo?style=flat-square" alt="License" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript&style=flat-square" alt="TypeScript Ready" style="display: inline-block; margin: 0 4px;"></a> <a href="https://magmacomputing.github.io/magma/doc/9-plugins/geo.index.html"><img src="https://img.shields.io/badge/Docs-VitePress-brightgreen?logo=vitepress&style=flat-square" alt="Documentation" style="display: inline-block; margin: 0 4px;"></a>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
A Community plugin for the [Tempo](https://github.com/magmacomputing/magma)
|
|
9
|
+
A Community plugin for the [Tempo](https://github.com/magmacomputing/magma) ecosystem that provides IP geolocation lookup, browser hardware location services, coordinate normalization, and 24-hour cached coordinate stashing.
|
|
10
|
+
|
|
11
|
+
By keeping geolocation logic in this plugin, core `@magmacomputing/tempo` remains zero-network and purely deterministic.
|
|
10
12
|
|
|
11
13
|
👉 **[View the full documentation on our GitHub Pages](https://magmacomputing.github.io/magma/doc/9-plugins/geo.index.html)**
|
|
12
14
|
|
|
15
|
+
---
|
|
16
|
+
|
|
13
17
|
## Installation
|
|
14
18
|
|
|
15
19
|
```bash
|
|
16
20
|
npm install @magmacomputing/tempo-plugin-geo
|
|
17
21
|
```
|
|
18
22
|
|
|
23
|
+
---
|
|
24
|
+
|
|
19
25
|
## Usage
|
|
20
26
|
|
|
21
|
-
###
|
|
27
|
+
### 1. Fluent OOP with Namespaced `Tempo.geo`
|
|
28
|
+
|
|
29
|
+
Installing `GeoPlugin` mounts an immutable, locked-down **`Tempo.geo`** namespace onto the `Tempo` class:
|
|
22
30
|
|
|
23
31
|
```typescript
|
|
24
32
|
import { Tempo } from '@magmacomputing/tempo';
|
|
25
|
-
import {
|
|
33
|
+
import { GeoPlugin } from '@magmacomputing/tempo-plugin-geo';
|
|
34
|
+
|
|
35
|
+
Tempo.use(GeoPlugin);
|
|
36
|
+
|
|
37
|
+
// 1. Universal Geolocation Lookup (cached for 24h)
|
|
38
|
+
const lookupResult = await Tempo.geo.lookup();
|
|
39
|
+
console.log(lookupResult.lat, lookupResult.lng, lookupResult.city);
|
|
40
|
+
|
|
41
|
+
// 2. Inspect Current Ambient / Global Coordinates
|
|
42
|
+
console.log(Tempo.geo.current); // { latitude: ..., longitude: ..., city: ... }
|
|
26
43
|
|
|
27
|
-
//
|
|
28
|
-
const
|
|
29
|
-
const t = new Tempo({ geo });
|
|
44
|
+
// 3. Force Fresh Network Lookup (bypassing 24h cache)
|
|
45
|
+
const fresh = await Tempo.geo.lookup({ refresh: true });
|
|
30
46
|
|
|
31
|
-
|
|
47
|
+
// 4. Enrich a Tempo Instance Asynchronously
|
|
48
|
+
const t = new Tempo();
|
|
49
|
+
const localTime = await t.geoLocate();
|
|
50
|
+
console.log(localTime.geo?.latitude, localTime.geo?.longitude);
|
|
32
51
|
```
|
|
33
52
|
|
|
34
|
-
###
|
|
53
|
+
### 2. Functional Tree-Shakeable APIs
|
|
54
|
+
|
|
55
|
+
All underlying utilities can be imported as standalone tree-shakeable functions without augmenting `Tempo`:
|
|
35
56
|
|
|
36
57
|
```typescript
|
|
37
58
|
import { Tempo } from '@magmacomputing/tempo';
|
|
38
|
-
import {
|
|
59
|
+
import {
|
|
60
|
+
geoLookup,
|
|
61
|
+
resolveGeoCoordinates,
|
|
62
|
+
stashGeo,
|
|
63
|
+
clearStashedGeo,
|
|
64
|
+
getStashedGeo,
|
|
65
|
+
} from '@magmacomputing/tempo-plugin-geo';
|
|
66
|
+
|
|
67
|
+
// Standalone lookup & instance creation
|
|
68
|
+
const coords = await geoLookup();
|
|
69
|
+
const t = new Tempo('2026-06-21', { geo: coords });
|
|
70
|
+
```
|
|
39
71
|
|
|
40
|
-
|
|
72
|
+
---
|
|
41
73
|
|
|
42
|
-
|
|
74
|
+
## The `Tempo.geo` API Surface
|
|
43
75
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
76
|
+
| Method / Property | Description |
|
|
77
|
+
| :--- | :--- |
|
|
78
|
+
| `Tempo.geo.lookup(opts?)` | Universal geolocation lookup (browser hardware GPS or server IP lookup) cached for 24h. Supports `{ refresh: true }`. |
|
|
79
|
+
| `Tempo.geo.resolve(input, opts?)` | Asynchronously resolves coordinates from an instance, configuration, or ambient storage cache. |
|
|
80
|
+
| `Tempo.geo.coerce(input)` | Pure function normalizing various coordinate formats (`lat/lng`, `latitude/longitude`, etc.) into a canonical `GeoConfig`. |
|
|
81
|
+
| `Tempo.geo.stash(coords, ttl?, keyOrOpts?)` | Stashes coordinates in storage with an optional custom TTL (default: 24h) and multi-tenant partitioning. |
|
|
82
|
+
| `Tempo.geo.clear(keyOrOpts?)` | Purges stashed coordinates from storage. |
|
|
83
|
+
| `Tempo.geo.get(keyOrOpts?)` | Reads stashed coordinates for the specified tenant/IP or ambient default. |
|
|
84
|
+
| `Tempo.geo.current` | **Read-only getter** returning the active global/ambient coordinates snapshot (`getStashedGeo() ?? Tempo.config.geo`). |
|
|
85
|
+
| `Tempo.geo.server(opts?)` | Low-level server-side IP geolocation handler. |
|
|
86
|
+
| `Tempo.geo.browser(opts?)` | Low-level browser Geolocation API handler. |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## ⚠️ Critical Operational Warnings
|
|
91
|
+
|
|
92
|
+
### 1. Server Context vs. Client Context
|
|
93
|
+
|
|
94
|
+
> [!WARNING]
|
|
95
|
+
> **Ambient IP lookup on a server resolves the SERVER's location, NOT the user's location.**
|
|
96
|
+
|
|
97
|
+
- In a server environment (Node.js, Deno, Bun, Edge runtimes), calling `Tempo.geo.lookup()` without options will query the **datacenter's public outbound IP address**.
|
|
98
|
+
- If your server runs in AWS `us-east-1` (Virginia) and an Australian user hits your API, calling ambient `Tempo.geo.lookup()` will resolve to Virginia!
|
|
99
|
+
- **Best Practice for Backends**:
|
|
100
|
+
- Always extract the client IP from trusted reverse proxy headers (e.g., `X-Forwarded-For`, `CF-Connecting-IP`) and pass it explicitly:
|
|
101
|
+
```typescript
|
|
102
|
+
const userCoords = await Tempo.geo.lookup({ ip: clientIp });
|
|
103
|
+
const userTime = new Tempo(date, { geo: userCoords });
|
|
104
|
+
```
|
|
105
|
+
- Or receive explicit GPS/browser coordinates from the frontend client request payload.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### 2. Multi-Tenant Key Isolation
|
|
48
110
|
|
|
49
|
-
|
|
111
|
+
> [!CAUTION]
|
|
112
|
+
> **Unpartitioned ambient storage is shared. In multi-tenant environments, always use unique keys or instance-level options.**
|
|
50
113
|
|
|
51
|
-
|
|
114
|
+
- Ambient storage stores coordinates under `_magma_geo_` by default.
|
|
115
|
+
- In a shared process or server handling requests for multiple tenants or distinct users, calling `stash()` or ambient `lookup()` without a key will cause tenants to **overwrite each other's cached coordinates**!
|
|
116
|
+
- **Solution A: Multi-Tenant Key Scoping**:
|
|
117
|
+
Pass a tenant identifier or user ID as the key:
|
|
118
|
+
```typescript
|
|
119
|
+
// Stash coordinates partitioned for tenant A:
|
|
120
|
+
Tempo.geo.stash(tenantACoords, undefined, 'tenant-alpha');
|
|
121
|
+
|
|
122
|
+
// Lookup / retrieve for a specific tenant:
|
|
123
|
+
const coords = Tempo.geo.get('tenant-alpha');
|
|
124
|
+
Tempo.geo.clear('tenant-alpha');
|
|
125
|
+
```
|
|
126
|
+
The cache automatically partitions keys under `_magma_geo_:<tenant-id>`, guaranteeing strict isolation.
|
|
127
|
+
|
|
128
|
+
- **Solution B: Instance-Level Configuration (Recommended)**:
|
|
129
|
+
Avoid ambient storage altogether by binding coordinates directly to `Tempo` instances:
|
|
130
|
+
```typescript
|
|
131
|
+
const tenantTime = new Tempo(date, { geo: tenantCoords });
|
|
132
|
+
```
|
|
133
|
+
Instance-level coordinates are completely local, immutable, and never touch shared memory or ambient caches.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Security & Immutability
|
|
138
|
+
|
|
139
|
+
In keeping with Tempo's strict immutability principles, the `Tempo.geo` namespace is fully locked down:
|
|
140
|
+
|
|
141
|
+
- **Deeply Frozen**: The entire `Tempo.geo` namespace and its attached utilities are recursively frozen.
|
|
142
|
+
- **Tamper-Proof**: Protected against modification, deletion, or monkey-patching. Any attempt to reassign `Tempo.geo` or mutate its methods (e.g. `Tempo.geo.lookup = ...`) will throw a `TypeError` in strict mode.
|
|
143
|
+
- **Pure Instance Operations**: Instance methods like `t.geoLocate()` always return a new, enriched `Tempo` instance, preserving the immutability of the original instance.
|
|
144
|
+
|
|
145
|
+
---
|
|
52
146
|
|
|
53
147
|
## Licensing
|
|
54
148
|
|
|
55
149
|
This is a **Community** plugin. It is completely free and open-source for personal and commercial use under the MIT license.
|
|
150
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import { type TempoPlugin } from '@magmacomputing/tempo/plugin/sdk';
|
|
2
|
-
import { geoLookup, resolveGeoCoordinates, coerceGeo, getStashedGeo, type GeoLookupResult, type GeoConfig, type CoordinateInput } from '@magmacomputing/library/runtime/mapper.library.js';
|
|
2
|
+
import { geoLookup, resolveGeoCoordinates, coerceGeo, getStashedGeo, stashGeo, clearStashedGeo, GEO_PROPERTIES, haversineDistance, solarOffset, type GeoLookupResult, type ResolvedCoordinates, type GeoConfig, type CoordinateInput, type DistanceUnit, type SolarOffsetOptions, type SolarOffsetUnit } from '@magmacomputing/library/runtime/mapper.library.js';
|
|
3
3
|
import { serverGeoLocation, serverGeoCoords, serverMapHemisphere, type ServerMapOpts, type ServerGeolocationResult } from '@magmacomputing/library/server/mapper.library.js';
|
|
4
4
|
import { geoLocation } from '@magmacomputing/library/browser/mapper.library.js';
|
|
5
|
-
export { geoLookup, resolveGeoCoordinates, coerceGeo, getStashedGeo, serverGeoLocation, serverGeoCoords, serverMapHemisphere, geoLocation, };
|
|
6
|
-
export type { GeoLookupResult, GeoConfig, CoordinateInput, ServerMapOpts, ServerGeolocationResult, };
|
|
7
|
-
type GeoLookupFn = typeof geoLookup;
|
|
8
|
-
type ResolveGeoCoordinatesFn = typeof resolveGeoCoordinates;
|
|
9
|
-
type ServerGeoLocationFn = typeof serverGeoLocation;
|
|
10
|
-
type GeoLocationFn = typeof geoLocation;
|
|
5
|
+
export { geoLookup, resolveGeoCoordinates, coerceGeo, getStashedGeo, stashGeo, clearStashedGeo, GEO_PROPERTIES, haversineDistance, solarOffset, serverGeoLocation, serverGeoCoords, serverMapHemisphere, geoLocation, };
|
|
6
|
+
export type { GeoLookupResult, ResolvedCoordinates, GeoConfig, CoordinateInput, DistanceUnit, SolarOffsetOptions, SolarOffsetUnit, ServerMapOpts, ServerGeolocationResult, };
|
|
11
7
|
/**
|
|
12
|
-
*
|
|
8
|
+
* Cohesive static namespace for geolocation operations on Tempo.
|
|
13
9
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
10
|
+
export interface TempoGeoNamespace {
|
|
11
|
+
/** Asynchronous universal geolocation lookup (browser hardware or server IP) with 24h caching */
|
|
12
|
+
readonly lookup: typeof geoLookup;
|
|
13
|
+
/** Asynchronously resolves coordinates from an instance, config, or ambient storage */
|
|
14
|
+
readonly resolve: typeof resolveGeoCoordinates;
|
|
15
|
+
/** Coerces coordinates and configurations into a canonical GeoConfig object */
|
|
16
|
+
readonly coerce: typeof coerceGeo;
|
|
17
|
+
/** Calculates Great-Circle distance between two coordinates using Haversine formula */
|
|
18
|
+
readonly distance: typeof haversineDistance;
|
|
19
|
+
/** Calculates Natural Solar Time Offset between civil clock time and actual solar noon */
|
|
20
|
+
readonly solarOffset: typeof solarOffset;
|
|
21
|
+
/** Explicitly stashes coordinates into storage with optional TTL (default 24h) and multi-tenant partitioning */
|
|
22
|
+
readonly stash: typeof stashGeo;
|
|
23
|
+
/** Clears stashed coordinates from storage */
|
|
24
|
+
readonly clear: typeof clearStashedGeo;
|
|
25
|
+
/** Retrieves stashed coordinates from storage */
|
|
26
|
+
readonly get: typeof getStashedGeo;
|
|
27
|
+
/** Low-level server-side IP geolocation handler */
|
|
28
|
+
readonly server: typeof serverGeoLocation;
|
|
29
|
+
/** Low-level browser geolocation API handler */
|
|
30
|
+
readonly browser: typeof geoLocation;
|
|
31
|
+
/** Current ambient or global coordinates snapshot (reads getStashedGeo() ?? Tempo.config.geo) */
|
|
32
|
+
readonly current: GeoConfig | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options for configuring the Geo plugin.
|
|
36
|
+
*/
|
|
37
|
+
export type GeoPluginOptions = Partial<GeoConfig> & {
|
|
38
|
+
timeout?: number;
|
|
39
|
+
highAccuracy?: boolean;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* GeoPlugin installs geolocation lookup and coordinate resolution helpers onto Tempo under the `Tempo.geo` namespace.
|
|
44
|
+
*/
|
|
45
|
+
export declare const GeoPlugin: TempoPlugin<GeoPluginOptions>;
|
|
46
|
+
export declare const geoPlugin: TempoPlugin<GeoPluginOptions>;
|
|
16
47
|
export default GeoPlugin;
|
|
17
48
|
declare module '@magmacomputing/tempo' {
|
|
18
49
|
interface Tempo {
|
|
@@ -23,15 +54,17 @@ declare module '@magmacomputing/tempo' {
|
|
|
23
54
|
/**
|
|
24
55
|
* Resolves coordinates for this instance via explicit coordinates or automatic IP/hardware lookup.
|
|
25
56
|
*/
|
|
26
|
-
geoLookup(opts?: Record<string, any>): Promise<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
geoLookup(opts?: Record<string, any>): Promise<ResolvedCoordinates | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Calculates Great-Circle distance from this instance's coordinates to target coordinates using Haversine formula.
|
|
60
|
+
*/
|
|
61
|
+
geoDistance(other: any, unit?: DistanceUnit): number;
|
|
62
|
+
/**
|
|
63
|
+
* Calculates Natural Solar Time Offset between civil clock time and actual solar noon for this instance.
|
|
64
|
+
*/
|
|
65
|
+
geoSolarOffset(options?: SolarOffsetOptions): number;
|
|
30
66
|
}
|
|
31
67
|
namespace Tempo {
|
|
32
|
-
let
|
|
33
|
-
let resolveGeoCoordinates: ResolveGeoCoordinatesFn;
|
|
34
|
-
let serverGeoLocation: ServerGeoLocationFn;
|
|
35
|
-
let geoLocation: GeoLocationFn;
|
|
68
|
+
let geo: TempoGeoNamespace;
|
|
36
69
|
}
|
|
37
70
|
}
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Magma;((Magma||={}).plugins||={}).geo=(()=>{var cr=Object.create;var xe=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var fr=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty;var b=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var mr=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Q=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},Se=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lr(t))!pr.call(e,i)&&i!==r&&xe(e,i,{get:()=>t[i],enumerable:!(n=ur(t,i))||n.enumerable});return e},ue=(e,t,r)=>(Se(e,t,"default"),r&&Se(r,t,"default")),yt=(e,t,r)=>(r=e!=null?cr(fr(e)):{},Se(t||!e||!e.__esModule?xe(r,"default",{value:e,enumerable:!0}):r,e)),gr=e=>Se(xe({},"__esModule",{value:!0}),e);var Ze=mr((Qr,ht)=>{"use strict";ht.exports=window.Magma.pluginSdk});var yr,hr,wr,br,Sr,xr,Tr,Or,wt,Er,bt,d,M=b(()=>{"use strict";yr=Symbol.for("$LibraryTarget"),hr=Symbol.for("$LibraryDiscover"),wr=Symbol.for("$LibraryExtensible"),br=Symbol.for("nodejs.util.inspect.custom"),Sr=Symbol.for("$LibraryLogConfig"),xr=Symbol.for("$LibraryRegistry"),Tr=Symbol.for("$LibraryRegister"),Or=Symbol.for("$LibrarySerializerRegistry"),wt=Symbol.for("$LibraryMutable"),Er=Symbol.for("$LibraryIdentity"),bt=Symbol.for("$LibraryUnwrapped"),d={$Target:yr,$Discover:hr,$Extensible:wr,$Inspect:br,$LogConfig:Sr,$Registry:xr,$Register:Tr,$SerializerRegistry:Or,$Identity:Er,$Mutable:wt,$Unwrapped:bt}});function ee(e){let t=e,r=0,n=50;for(;t;){let i=t[d.$Target];if(!i||r>=n)break;t=i,r++}return t}function E(e,t=!1){if(!e||typeof e!="object")return[];let r=ee(e);if(!t){let l=Reflect.ownKeys(r),p=[];for(let m of l){let O=Object.getOwnPropertyDescriptor(r,m);O&&O.enumerable&&p.push([m,r[m]])}return p}let n=[],i=50,o=0,s=r;for(;s&&s!==Object.prototype&&o++<i;)n.push(ee(s)),s=Object.getPrototypeOf(s);let a=[],c=new Set;for(let l of n.reverse()){let p=Reflect.ownKeys(l);for(let m of p){if(c.has(m))continue;let O=Object.getOwnPropertyDescriptor(l,m);!O||!O.enumerable||(c.add(m),a.push([m,r[m]]))}}return a}function le(e,t=!1){return E(e,t).map(([r])=>r)}function St(e,t=!1){return E(e,t).map(([r,n])=>n)}function Oe(e,t,r){return t?Oe(e.map(t,r)):Array.from(new Set(e))}var F=b(()=>{"use strict";M()});var je,xt,Ee,H,z,_r,Pr,_e,A=b(()=>{"use strict";M();F();je=[],xt=e=>{if(e===null)return"Null";if(e===void 0)return"Undefined";let t=typeof e;if(t==="string")return"String";if(t==="number")return"Number";if(t==="boolean")return"Boolean";if(t==="bigint")return"BigInt";if(t==="symbol")return"Symbol";try{let r=t==="object"?ee(e):e;return Object.prototype.toString.call(r).slice(8,-1)}catch{return t==="function"?"Function":"Object"}},Ee=e=>{try{let t=e?.[Symbol.toStringTag]??e?.prototype?.[Symbol.toStringTag];if(typeof t=="string")return t}catch{}},H=(e,...t)=>{let r=e;try{r=e?.[d.$Target]??e}catch{r=e}let n=xt(r);switch(n){case"Function":try{return Pr(r)?"Class":"Function"}catch{return"Function"}case"Object":{try{if("length"in r&&Object.keys(r).every(o=>o==="length"||Number.isFinite(Number(o))))return"ArrayLike";for(let o of t){let s=o.class?.[d.$Target]??o.class;if(r===s||s&&r instanceof s)return o.type}let i=globalThis[d.$Registry]??[];for(let o of[...je,...i]){let s=o.class?.[d.$Target]??o.class;if(r===s||s&&r instanceof s)return o.type}}catch{return"Object"}return"Object"}default:return n}},z=(e,...t)=>({type:H(e,...t),value:e}),_r=/^\s*(class\s|\[native code\])/,Pr=e=>{if(typeof e!="function")return!1;let t=e?.[d.$Target]??e;if(!("prototype"in t))return!1;let r=t?.name,n=Ee(t);if(t?.[d.$Identity]||t?.prototype?.[d.$Identity]||typeof n=="string"&&n.startsWith("Temporal."))return!0;if(typeof n=="string"&&n.endsWith("Function"))return!1;if((globalThis[d.$Registry]??[]).some(o=>(o.class?.[d.$Target]??o.class)===t||r&&o.type===r||n&&o.type===n))return!0;try{let o=Function.prototype.toString.call(t);if(_r.test(o))return!0;let s=Object.getOwnPropertyDescriptor(t,"prototype");if(s&&s.writable===!1&&!Object.isFrozen(t))return!0;let a=t.prototype;if(a&&Object.getOwnPropertyNames(a).length>2)return!0}catch{return!1}return!1},_e=(e,t)=>{if(typeof e!="function")return;let r=Ee(e),n=t??r??e.name;n&&!["Object","Function",""].includes(n)&&(je.some(i=>i.class===e)||je.push({class:e,type:n}))}});var N,Pe,Ne,y,g,He,V,I,Nr,U,Tt,te,h,Y,x,w,Ie,De,$e,Z,T=b(()=>{"use strict";M();A();N=(e,...t)=>t.includes(H(e)),Pe=e=>N(e,"String","Number","BigInt","Boolean","Symbol","Undefined","Void","Null","Empty"),Ne=e=>!Pe(e),y=e=>N(e,"String"),g=e=>Number.isFinite(e),He=e=>N(e,"BigInt"),V=e=>N(e,"Array"),I=e=>N(e,"Object"),Nr=e=>N(e,"Date"),U=e=>N(e,"Symbol"),Tt=e=>N(e,"Symbol")&&Symbol.keyFor(e)!==void 0,te=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",h=e=>N(e,"Null","Undefined","Void","Empty"),Y=e=>N(e,"Undefined","Void","Empty"),x=e=>!h(e),w=e=>N(e,"Function","AsyncFunction","GeneratorFunction","AsyncGeneratorFunction"),Ie=e=>N(e,"Map"),De=e=>N(e,"Set"),$e=(e,t)=>N(e,"Error")&&(t?e instanceof t:!0),Z=e=>h(e)||I(e)&&Reflect.ownKeys(e).length===0||y(e)&&e.trim().length===0||typeof e=="number"&&Number.isNaN(e)||V(e)&&e.length===0||De(e)&&e.size===0||Ie(e)&&e.size===0||ArrayBuffer.isView(e)&&e.byteLength===0||Nr(e)&&Number.isNaN(e.getTime())});function Ve(e,t,r=new WeakSet){let n=t instanceof WeakSet?t:t?.skip??Ir;return Pe(e)||r.has(e)||n.has(e)||e instanceof Date||e instanceof RegExp||e instanceof Error||e instanceof Map||e instanceof Set||e instanceof Promise||e?.[Symbol.toStringTag]==="Enumify"||e[d.$Extensible]?e:(r.add(e),E(e).forEach(([i,o])=>{te(i)&&Ve(o,{skip:n},r)}),Object.freeze(e))}var _,q,Ir,fe=b(()=>{"use strict";F();T();M();_={Unknown:"unknown",Browser:"browser",WebWorker:"web-worker",NodeJS:"nodejs",Deno:"deno",GoogleAppsScript:"google-apps-script"},q=()=>{let e=globalThis;try{if(x(e.SpreadsheetApp))return{global:e,type:_.GoogleAppsScript};if(x(e.window?.document))return{global:e,type:_.Browser};if(w(e.importScripts)||x(e.WorkerGlobalScope)&&e instanceof e.WorkerGlobalScope)return{global:e,type:_.WebWorker};if(x(e.Deno))return{global:e,type:_.Deno};if(x(e.process?.versions?.node)&&e.process?.release?.name==="node")return{global:e,type:_.NodeJS}}catch{}return{global:e,type:_.Unknown}},Ir=new WeakSet});function K(e){return x(e)?w(e)?e():e:t=>w(t)?t():t}var Re,Ot=b(()=>{"use strict";F();T();A();Re=e=>{if(h(e)||!I(e))return e;let t=V(e)?[]:{};return le(e).forEach(r=>{te(r)&&(t[r]=Re(e[r]))}),t};K.stringSymbol=K();K.symbolRegExp=K();K.symbolString=K();K.stringString=K()});function Et(e){return Object.fromEntries(E(e,!0))}var _t=b(()=>{"use strict";F();A();T()});function Nt(e,t={},r=!1){let{frozen:n,lock:i,appendOnly:o,onGet:s,keys:a,bind:c,skip:l}=t,p=new Set,m,O,$=ee(e);i&&Ve($,l?{skip:l}:void 0),_e($);let J={isExtensible:f=>Reflect.isExtensible(f),getPrototypeOf:f=>Reflect.getPrototypeOf(f),setPrototypeOf:(f,u)=>{if(n)throw new TypeError("Security: Prototype mutation attempt on protected object");return Reflect.setPrototypeOf(f,u)},getOwnPropertyDescriptor:(f,u)=>{if(!(a&&!a.includes(u))){if(a){if(s&&!U(u)&&!p.has(u)){p.add(u);try{let P=s(u,f);if(x(P))return{enumerable:!0,configurable:!0,value:P}}finally{p.delete(u)}}return{enumerable:!0,configurable:!0}}return Reflect.getOwnPropertyDescriptor(f,u)}},ownKeys:f=>{if(a)return a;if(s&&!p.has(d.$Discover)){p.add(d.$Discover);try{s(d.$Discover,f)}finally{p.delete(d.$Discover)}}return Reflect.ownKeys(f)},has:(f,u)=>a?a.includes(u):Reflect.has(f,u),deleteProperty:(f,u)=>{if(n)throw new TypeError(`Cannot delete property '${String(u)}' from a protected object.`);if(o&&Reflect.has(f,u))throw new Error(`Security: Deletion attempt on protected key '${String(u)}'`);return Reflect.deleteProperty(f,u)},defineProperty:(f,u,P)=>{if(n&&!Object.isFrozen(f))throw new TypeError(`Cannot define property '${String(u)}' on a frozen object.`);if(o&&Reflect.has(f,u))throw new Error(`Security: Mutation attempt on protected key '${String(u)}'`);return Reflect.defineProperty(f,u,P)},set:(f,u,P,L)=>{if(n&&L===O)throw new TypeError(`Cannot set property '${String(u)}' on a frozen object.`);if(o){if(Array.isArray(f)&&u==="length"&&P<f.length)throw new Error("Security: Truncation attempt on protected array.");if(!(Array.isArray(f)&&u==="length")&&Reflect.has(f,u))throw new Error(`Security: Mutation attempt on protected key '${String(u)}'`)}return Reflect.set(f,u,P,L)},get:(f,u,P)=>{if(u===d.$Target)return P===O?f:void 0;if(n&&(u===d.$Inspect||u==="toJSON")){let v=Object.getOwnPropertyDescriptor(f,u);return v&&w(v.value)?v.value:(m||(m=()=>Et(f)),m)}if(a&&!a.includes(u))return;if(s&&!U(u)&&!Reflect.has(f,u)&&!p.has(u)){p.add(u);try{let v=s(u,f);if(x(v))return v}finally{p.delete(u)}}let L=Reflect.get(f,u,P);if(c&&u!=="constructor"&&w(L)){let v=Object.getOwnPropertyDescriptor(f,u);if(v&&!v.configurable&&!v.writable)return L;let ce=Pt.get(L);ce||(ce=new WeakMap,Pt.set(L,ce));let gt=ce.get(f);if(gt)return gt;let dt=L.bind(f);return ce.set(f,dt),dt}return L}};if(r){let f=Proxy.revocable($,J);return O=f.proxy,{proxy:f.proxy,revoke:f.revoke}}return O=new Proxy($,J),O}function It(e,t=!0,r=t,n=new WeakSet){return Nt(e,{frozen:t,lock:r,skip:n,bind:t})}function pe(e,t=new WeakSet){return Nt(e,{frozen:!0,lock:!0,skip:t,bind:!0})}var Pt,ve=b(()=>{"use strict";M();_t();fe();F();T();A();Pt=new WeakMap});function me(e,t=new WeakSet){return JSON.stringify(e,function(r,n){if(n===void 0)return"\0__undefined__\0";if(He(n))return`\0__bigint:${n}__\0`;if(w(n))return`function:${n.name||"anonymous"}`;if(Ne(n)){if(t.has(n))return"<Circular>";if(t.add(n),Ie(n))return`map:[${Array.from(n.entries()).map(i=>me(i,t)).sort().join(",")}]`;if(De(n))return`set:[${Array.from(n).map(i=>me(i,t)).sort().join(",")}]`}return n})}function $t(e){return function t(...r){return r.length>=e.length?e(...r):(...n)=>t(...r,...n)}}function X(e){let t=new Map;return function(...r){let n=me(this!==void 0&&this!==globalThis?[this,...r]:r);if(!t.has(n)){let i=e.apply(this,r);t.set(n,i)}return t.get(n)}}function ge(e,t){return{enumerable:!1,configurable:!1,writable:!1,value:function(...r){let n=`${String(e)},${me(r)}`,i=Dt.get(this);if(i||(i=new Map,Dt.set(this,i)),!i.has(n)){let o=t.apply(this,r);pe(o),i.set(n,o)}return i.get(n)}}}var Dt,Ae=b(()=>{"use strict";ve();T();Dt=new WeakMap});var Rt=b(()=>{"use strict"});function Dr(e,t){return Z(e)?t:C(t)}function $r(e,t){return vr(t)}function At(e){let t=encodeURI(e);return t.includes("%")&&(t=t.replace(Rr,r=>Mt[r.toUpperCase()]??decodeURI(r))),t}function vr(e){if(y(e))try{return decodeURI(e)}catch{}return e}function de(e){return!N(e,"Function","AsyncFunction","WeakMap","WeakSet","WeakRef")}function Ar(e,t){return`{"$${e}":${t}}`}function Ct(e){return C(U(e)?`${Tt(e)?"@":""}@(${e.description??""})`:e)}function Ft(e){let[t,r,n]=e.toString().match(Cr)||[null,void 0,void 0];switch(!0){case U(e):case h(t):case(x(r)&&Y(n)):return e;case x(r):return Symbol.for(n);case Y(r):default:return Symbol(n)}}function k(e){return C(e,!1)}function C(e,t=!0){let r=z(e),n=$t(Ar)(r.type);switch(r.type){case"String":return t||(t=r.value==="true"||r.value==="false"||r.value==="null"||parseFloat(r.value).toString()===r.value),t?JSON.stringify(At(r.value)):At(r.value);case"Boolean":case"Null":case"Number":return JSON.stringify(r.value);case"Void":case"Undefined":return n(JSON.stringify("void"));case"BigInt":return n(r.value.toString());case"Object":return`{${E(r.value).filter(([,o])=>de(o)).map(([o,s])=>`${Ct(o)}: ${C(s)}`).join(",")}}`;case"Array":return`[${r.value.filter(o=>de(o)).map(o=>C(o)).join(",")}]`;case"Map":{let i=Array.from(r.value.entries()).filter(([,o])=>de(o)).map(([o,s])=>`[${C(o)}, ${C(s)}]`).join(",");return n(`[${i}]`)}case"Set":{let i=Array.from(r.value.values()).filter(o=>de(o)).map(o=>C(o)).join(",");return n(`[${i}]`)}case"Symbol":return n(Ct(r.value));case"RegExp":return n(C({source:r.value.source,flags:r.value.flags}));default:{let i=r.value;switch(!0){case!de(i):return;case w(i.toJSON):return n(C(i.toJSON()));case w(i.toString):{let o=i.toString();return n(o.includes('"')?o:JSON.stringify(o))}case w(i.valueOf):return n(JSON.stringify(i.valueOf()));default:return n(JSON.stringify(i,Dr))}}}}function re(e,t){if(!y(e))return e;let r;try{r=JSON.parse(e,$r)}catch(n){return e.startsWith('"')&&e.endsWith('"')?(console.warn(`objectify.parse: -> ${e}, ${n.message}`),e):re(`"${e}"`,t)}switch(!0){case(e.startsWith("{")&&e.endsWith("}")):case(e.startsWith("[")&&e.endsWith("]")):return qe(r,t);default:return r}}function qe(e,t){return I(e)?Ye(E(e).reduce((r,[n,i])=>Object.assign(r,{[Ft(n)]:Ye(qe(i,t))}),{}),t):V(e)?St(e).map(r=>Ye(qe(r,t))):e}function Ye(e,t){if(!I(e)||le(e).length!==1)return e;let[r,n]=E(e)[0];if(!String(r).startsWith("$"))return e;let i=r.substring(1);try{switch(i){case"String":case"Boolean":case"Object":case"Array":return n;case"Number":return Number(n);case"BigInt":return BigInt(n);case"Null":return null;case"Undefined":case"Empty":case"Void":return t?.();case"Date":return new Date(n);case"RegExp":return!I(n)||!y(n.source)?e:new RegExp(n.source,n.flags);case"Symbol":return Ft(n);case"Map":return V(n)?new Map(n):e;case"Set":return V(n)?new Set(n):e;default:let o=Ce.get(r);return o?Reflect.construct(o,[n]):(console.warn(`objectify: dont know how to deserialize '${i}'`),e)}}catch{return e}}var Ce,vt,Lt,Mt,Rr,Cr,ne=b(()=>{"use strict";Ae();F();Rt();A();T();M();Ce=globalThis[d.$SerializerRegistry]??=new Map,vt=e=>{try{let t=e?.prototype?.[Symbol.toStringTag]??e?.[Symbol.toStringTag];return y(t)?t:void 0}catch{return}},Lt=(e,t)=>{let r=e.startsWith("$")?e:`$${e}`;if(Ce.has(r)){let n=Ce.get(r),i=vt(n),o=vt(t),s=n.name||i,a=t.name||o||(e.startsWith("$")?e.slice(1):e);if(n===t||n.toString()===t.toString()||!!t[d.$Identity]&&n[d.$Identity]===t[d.$Identity]||!!t[d.$Target]&&n[d.$Target]===t[d.$Target]||!!s&&!!a&&s===a)return;throw new Error(`[registerSerializable] Collision: '${r}' is already registered with ${n.name||"anonymous constructor"}`)}Ce.set(r,t)};Mt={"%20":" ","%22":'"',"%3B":";","%3C":"<","%3E":">","%5B":"[","%5D":"]","%5E":"^","%7B":"{","%7C":"|","%7D":"}"},Rr=new RegExp(Object.keys(Mt).join("|"),"gi");Cr=/^@(@)?\(([^\)]*)\)$/});var kt=b(()=>{"use strict";ne();T()});function Gt(e){if($e(e))return e;let t=new Error(I(e)&&y(e.message)?e.message:String(e));return I(e)&&(t.name=y(e.name)?e.name:"Error","code"in e&&(y(e.code)||g(e.code))&&(t.code=e.code),"stack"in e&&y(e.stack)&&(t.stack=e.stack)),t}var ro,no,Wt=b(()=>{"use strict";ne();A();T();kt();ro=BigInt(Number.MAX_SAFE_INTEGER),no=BigInt(Number.MIN_SAFE_INTEGER)});var Bt=b(()=>{"use strict";Wt();if(typeof globalThis.Temporal>"u")throw new Error("Temporal API is not available. Node 20+ with a polyfill (e.g. @js-temporal/polyfill) is highly recommended. Native Temporal is fully reliable only on Node 26+ (while Node 22 may have instabilities).");try{if(typeof Temporal.Now.zonedDateTimeISO=="function"&&typeof Temporal.Now.zonedDateTimeISO().add!="function")throw new Error("Incomplete Temporal implementation")}catch(e){let t=Gt(e);if(console.warn("Tempo: Native Temporal implementation appears incomplete. Consider loading a polyfill.",t),t.message!=="Incomplete Temporal implementation")throw t}});function Jt(){return Temporal.Now.instant()}function zt(e,t=2024){let r=Temporal.ZonedDateTime.from({year:t,month:1,day:1,hour:0,minute:0,second:0,timeZone:e}).offsetNanoseconds,n=Temporal.ZonedDateTime.from({year:t,month:7,day:1,hour:0,minute:0,second:0,timeZone:e}).offsetNanoseconds;return{jan:r,jul:n}}var Xe=b(()=>{"use strict";Bt();T()});function Fr(){return Mr().resolvedOptions()}function Le(e=Fr().timeZone){try{let{jan:t,jul:r}=zt(e),i=["Australia","Antarctica","Africa/Johannesburg","America/Argentina/Buenos_Aires","America/Sao_Paulo"].some(o=>e.startsWith(o));switch(!0){case r>t:return"north";case r<t:return"south";default:return i?"south":void 0}}catch{return}}var mo,go,Mr,yo,ho,wo,Qe=b(()=>{"use strict";Xe();Ae();T();mo=X((e,t="narrow",r="always")=>new Intl.RelativeTimeFormat(e,{style:t,numeric:r})),go=X((e,t="conjunction",r="long")=>new Intl.ListFormat(e,{type:t,style:r})),Mr=X((e,t)=>new Intl.DateTimeFormat(e,t)),yo=X((e,t)=>{try{return new Intl.PluralRules(e,t)}catch{return{select:()=>"other"}}}),ho=X((e,t)=>new Intl.NumberFormat(e,t)),wo=X((e,t)=>{try{let r=new Intl.DurationFormat(e,t);if(w(r.format))return r;throw new Error("No format method")}catch{return{format:n=>String(n)}}})});function oe(e,t,r,n,i,o){function s(P){if(P!==void 0&&typeof P!="function")throw new TypeError("Function expected");return P}for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!t&&e?n.static?e:e.prototype:null,p=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),m,O=!1,$=r.length-1;$>=0;$--){var J={};for(var f in n)J[f]=f==="access"?{}:n[f];for(var f in n.access)J.access[f]=n.access[f];J.addInitializer=function(P){if(O)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(P||null))};var u=(0,r[$])(a==="accessor"?{get:p.get,set:p.set}:p[c],J);if(a==="accessor"){if(u===void 0)continue;if(u===null||typeof u!="object")throw new TypeError("Object expected");(m=s(u.get))&&(p.get=m),(m=s(u.set))&&(p.set=m),(m=s(u.init))&&i.unshift(m)}else(m=s(u))&&(a==="field"?i.unshift(m):p[c]=m)}l&&Object.defineProperty(l,n.name,p),O=!0}function ie(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0}var Me=b(()=>{"use strict"});function Ut(e,t){return Ee(e)??(Y(t)?e.name||void 0:String(t))}function Zt(e,{kind:t,name:r,addInitializer:n}){let i=Ut(e,r);if(i&&_e(e,i),t==="class")return i&&n(()=>Lt(i,e)),e;throw new Error(`@Serializable decorating unknown 'kind': ${t} (${r})`)}function se(e,t){let r=(n,i,o)=>{let s=n.prototype,a=i??Ut(n,o);if(a&&(s&&!Object.hasOwn(s,Symbol.toStringTag)&&Object.defineProperty(s,Symbol.toStringTag,{value:a,configurable:!0,writable:!1,enumerable:!1}),!n.name||n.name!==a))try{Object.defineProperty(n,"name",{value:a,configurable:!0,writable:!1,enumerable:!1})}catch{}return n};return typeof e=="function"&&t?.kind==="class"?r(e,void 0,t.name):(n,i)=>r(n,y(e)?e:void 0,i?.name)}var Fe=b(()=>{"use strict";M();ve();T();ne();A()});function G(e){return{enumerable:!1,configurable:!1,writable:!1,value:e}}function ae(e,t=!0){let n=H(this)!=="Module"&&w(this?.has)?this:Gr,i=z(e),o=Object.create(n);switch(i.type){case"Enumify":case"Object":Object.defineProperties(o,Object.getOwnPropertyDescriptors(i.value));break;case"Array":i.value.forEach((s,a)=>{if(g(s))throw new Error("Enumify: numeric keys are not supported");o[s]=a});break;default:throw new Error(`Enumify: invalid argument type: ${i.type}`)}return It(o,!0,t)}var kr,Gr,Co,Kt=b(()=>{"use strict";Me();A();T();F();ve();Fe();Ae();kr="Enumify",Gr=pe(Object.create(null,{keys:ge("keys",function(){return E(this,!0).map(([e])=>e)}),values:ge("values",function(){return E(this,!0).map(([e,t])=>t)}),entries:ge("entries",function(){return E(this,!0).map(([e,t])=>Object.freeze([e,t]))}),invert:ge("invert",function(){return Object.fromEntries(this.entries().map(([e,t])=>[t,e]))}),has:G(function(e){return this.keys().includes(e)}),count:G(function(){return this.keys().length}),includes:G(function(e){return this.values().includes(e)}),keyOf:G(function(e){return this.invert()[e]}),extend:G(function(e,t){return ae.call(this,e,t)}),forEach:G(function(e,t){this.entries().forEach((r,n)=>e.call(t,r,n,this))}),filter:G(function(e,t){return ae(this.entries().reduce((r,n,i)=>e.call(t,n,i,this)?Object.assign(r,{[n[0]]:n[1]}):r,{}))}),map:G(function(e,t){return ae(this.entries().reduce((r,n,i)=>Object.assign(r,{[n[0]]:e.call(t,n,i,this)}),{}))}),[Symbol.iterator]:G(function*(){for(let e of this.entries())yield e}),[Symbol.toStringTag]:{enumerable:!1,configurable:!1,writable:!1,value:kr}}));Co=(()=>{let e=[Zt,se("Enumify")],t,r=[],n;var i=class{static{n=this}static{let o=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;oe(null,t={value:n},e,{kind:"class",name:n.name,metadata:o},null,r),i=n=t.value,o&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o}),ie(n,r)}constructor(o){return ae(o)}};return i=n})()});function Wr(e,t=R.Info){return g(e)?e>=R.Off&&e<=R.Trace?e:t:y(e)?jt[e.toLowerCase()]??t:t}var R,D,jt,ke,et=b(()=>{"use strict";Me();T();Kt();M();Fe();R=ae(["Off","Error","Warn","Info","Debug","Trace"]),D={Off:"off",Log:"log",Info:"info",Warn:"warn",Debug:"debug",Trace:"trace",Error:"error"},jt={[D.Off]:R.Off,[D.Error]:R.Error,[D.Warn]:R.Warn,[D.Info]:R.Info,[D.Log]:R.Info,[D.Debug]:R.Debug,[D.Trace]:R.Trace};ke=(()=>{let e=[se("Logger")],t,r=[],n;var i=class{static{n=this}static{let o=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;oe(null,t={value:n},e,{kind:"class",name:n.name,metadata:o},null,r),i=n=t.value,o&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o}),ie(n,r)}#r;level;constructor(o,s=R.Info){this.#r=o.startsWith("[")?o:`[${o}]`,this.level=s}#e(o,...s){let a;if(s.length>0&&I(s[0]))try{s[0][d.$LogConfig]&&(a=s.shift())}catch{}let c=this.level;if(a){if(a.silent===!0)return;a.debug!==void 0&&(c=Wr(a.debug,c))}if(c===R.Off||(jt[o]??0)>c)return;let p=s.map(m=>{if($e(m))return m.message;if(I(m))try{let O=m.constructor?.name??"Object";if(O==="Object"){let $=Object.keys(m);return`{ ${$.slice(0,3).join(", ")}${$.length>3?`, ... (+${$.length-3} more)`:""} }`}return`[${O}]`}catch{return"[Object]"}return String(m)}).filter(m=>!Z(m)).join(" ");Z(p)||console[o](`${this.#r} ${p}`)}log=(...o)=>this.#e(D.Log,...o);info=(...o)=>this.#e(D.Info,...o);warn=(...o)=>this.#e(D.Warn,...o);debug=(...o)=>this.#e(D.Debug,...o);trace=(...o)=>this.#e(D.Trace,...o);error=(...o)=>this.#e(D.Error,...o)};return i=n})()});var Br,Vt,Ht,tt,rt,jo,Yt=b(()=>{"use strict";ne();fe();T();Br=q(),Vt=()=>{let e=new Map;return{get length(){return e.size},clear:()=>e.clear(),getItem:t=>e.get(t)??null,key:t=>Array.from(e.keys())[t]??null,removeItem:t=>{e.delete(t)},setItem:(t,r)=>{e.set(t,String(r))}}},Ht=new Map,tt=e=>{let t=Ht.get(e);return t||(t=Vt(),Ht.set(e,t)),t},rt=(e="localStorage")=>{try{let t=globalThis?.[e];if(t&&typeof t.getItem=="function"&&typeof t.setItem=="function"&&typeof t.removeItem=="function"&&typeof t.clear=="function"&&typeof t.key=="function"&&typeof t.length=="number")return t}catch{}return tt(e)},jo=Br.type===_.Browser?rt():Vt()});var qt={};Q(qt,{WebStore:()=>Jr});var ye,Jr,Xt=b(()=>{"use strict";Me();F();ne();A();T();Yt();Fe();ye={Local:"local",Session:"session"},Jr=(()=>{let e=[se("WebStore")],t,r=[],n;var i=class{static{n=this}static{let o=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;oe(null,t={value:n},e,{kind:"class",name:n.name,metadata:o},null,r),i=n=t.value,o&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o}),ie(n,r)}static _localInstance;static _sessionInstance;static get local(){return i._localInstance??=new i(ye.Local)}static get session(){return i._sessionInstance??=new i(ye.Session)}#r;#e;get#o(){if(this.#e)return this.#e;let o=this.#r===ye.Local?"localStorage":"sessionStorage";return this.#e=rt(o)}#n(o){try{return o(this.#o)}catch{let a=this.#r===ye.Local?"localStorage":"sessionStorage",c=tt(a);return this.#e=c,o(c)}}constructor(o=ye.Local){this.#r=o}get(o,s){let a=this.#n(c=>c.getItem(k(o)));return y(a)?re(a):s??null}set(o,s,a={merge:!0}){if(h(o))return this.clear();let c=this.get(o),l=z(s);switch(l.type){case"Undefined":return this.del(o);case"Object":return c??={},this.#t(o,a.merge?Object.assign(c,l.value):l.value);case"Array":return c??=[],this.#t(o,a.merge?Oe(c.concat(l.value)):s);case"Map":return c??=new Map,a.merge?(l.value.forEach((p,m)=>c.set(m,p)),this.#t(o,c)):this.#t(o,l.value);case"Set":return c??=new Set,a.merge?(l.value.forEach(p=>c.add(p)),this.#t(o,c)):this.#t(o,l.value);default:return this.#t(o,l.value)}}clear(){try{this.#n(o=>o.clear())}catch(o){console.warn("[WebStore] Failed to clear storage:",o)}return this}del(...o){return o.forEach(s=>{try{this.#n(a=>a.removeItem(k(s)))}catch(a){console.warn(`[WebStore] Failed to removeItem for key '${String(s)}':`,a)}}),this}keys(...o){return this.entries(...o).map(([s])=>s)}values(...o){return this.entries(...o).map(([,s])=>s)}entries(...o){let s=new Set(o.map(c=>k(c))),a=[];return this.#n(c=>{for(let l=0;l<c.length;l++){let p=c.key(l);if(p!==null&&(Z(o)||s.has(p))){let m=c.getItem(p);a.push([re(p),re(m)])}}}),a}from(o){return E(o).forEach(([s,a])=>this.set(s,a)),this}#t(o,s){try{this.#n(a=>a.setItem(k(o),k(s)))}catch(a){console.warn(`[WebStore] Failed to setItem for key '${String(o)}':`,a)}return this}};return i=n})()});var er={};Q(er,{geoCoords:()=>Qt,geoLocation:()=>he,mapAddress:()=>Zr,mapHemisphere:()=>Ur,mapQuery:()=>it});var We,zr,S,ot,W,nt,Ge,he,Qt,it,Ur,Zr,st=b(()=>{"use strict";Ot();fe();T();Xe();Qe();et();We={catch:!0,debug:0},zr=q(),S={},ot="_map_",W=new ke("[Mapper]"),nt=null,Ge=()=>(nt||(nt=new Promise((e,t)=>{zr.type===_.Browser?Promise.resolve().then(()=>(Xt(),qt)).then(({WebStore:r})=>{let n=new r("local");Object.assign(S,n.get(ot,{})),e(n)}).catch(t):e(void 0)})),nt),he=(e={})=>Ge().then(()=>new Promise((t,r)=>{e=Object.assign({},We,e);let n=e.catch?t:r;typeof navigator<"u"&&"geolocation"in navigator?navigator.geolocation.getCurrentPosition(i=>{let o=S.geolocation?.coords,s=o?.latitude?.toFixed(3),a=o?.longitude?.toFixed(3),c=S.geolocation?.timestamp??0,l=i.coords.latitude.toFixed(3)!==s,p=i.coords.longitude.toFixed(3)!==a,m=c<Jt().epochMilliseconds-36e5;(l||p||m)&&(Object.assign(S,{georesponse:null}),W.info(e,"GeoLocation: device update")),Object.assign(S,{geolocation:Re(i)}),t(S.geolocation)},i=>{Object.assign(S,{geolocation:{error:i.message},georesponse:null}),n(S.geolocation)}):(Object.assign(S,{geolocation:{error:"Not Supported"},georesponse:null}),n(S.geolocation))})).finally(()=>{(S.geolocation?.error?W.error:W.info)(e,"geoLocation: ",S.geolocation),Ge().then(r=>r?.set(ot,S))}),Qt=e=>new Promise((t,r)=>{if(!h(e))return t(e);he().then(n=>h(n.error)?{location:{lat:n.coords.latitude,lng:n.coords.longitude}}:null).then(n=>t(n)).catch(n=>r(n))}),it=(e,t={})=>Ge().then(()=>new Promise((r,n)=>{t=Object.assign({},We,t);let i=t.catch?r:n;Qt(e).then(o=>{switch(!0){case!(typeof window<"u"&&"google"in window&&"maps"in window.google):throw new Error("Google Maps API not configured");case h(o):throw new Error("Cannot determine Coordinates");case h(e):{let s=S.geolocation&&S.georesponse,a=h(S.geolocation?.error)&&h(S.georesponse?.error);if(s&&a)return t.debug&&W.debug(t,"mapQuery: cache"),r(S.georesponse)}default:new window.google.maps.Geocoder().geocode(o).then(s=>r(S.georesponse=Re(s)))}}).catch(o=>{Object.assign(S,{georesponse:{error:o.message}}),i(S.georesponse)})})).finally(()=>{t.debug&&(S.georesponse?.error?W.error:W.debug)(t,"mapQuery: ",S.georesponse),Ge().then(r=>r?.set(ot,S))}),Ur=(e,t={})=>it(e,t).then(r=>{if(t=Object.assign({},We,t),h(r.error))return t.debug&&W.debug(t,"sphere: ",r),r.results[0].geometry.location.lat()>=0?"north":"south";let n=Le();if(h(n)&&t.catch===!1)throw new Error("Cannot determine Hemisphere");return n}).catch(r=>{if(t.debug&&W.warn(t,"mapHemisphere: ",r.message),t.catch===!1)throw r;return null}),Zr=(e,t={})=>it(e,t).then(r=>{if(!h(r.error))throw new Error(r.error);return r.results[0]}).then(({formatted_address:r,address_components:n})=>n.reduce((i,o)=>(o.types.filter(s=>s!=="political").forEach(s=>i[s]=(i[s]?i[s]+",":"").concat(o.short_name)),i),{formatted_address:r})).catch(r=>{if(t=Object.assign({},We,t),t.debug&&W.warn(t,"mapAddress: ",r.message),t.catch===!1)throw r;return null})});var ir={};Q(ir,{HTTP:()=>nr,HttpError:()=>B,METHOD:()=>or,fetchHead:()=>jr,fetchRequest:()=>Kr});var at,tr,nr,or,B,rr,Kr,jr,sr=b(()=>{"use strict";T();at=2e3,tr=/\);?$/,nr={Ok:200,PermRedirect:301,TempRedirect:302,BadRequest:400,Unauthorised:401,Forbidden:403},or={Head:"HEAD",Get:"GET",Put:"PUT",Delete:"DELETE",Post:"POST"},B=class extends Error{status;statusText;body;constructor(t,r,n){super(`${t}: ${r}`),this.status=t,this.statusText=r,this.body=n,this.name="HttpError"}},rr=async(e,t)=>{let r=e.headers?.get?.("Content-Length")||e.headers?.get?.("content-length");if(r){let a=parseInt(r,10);if(g(a)&&a>t){try{await e.body?.cancel()}catch{}throw new B(413,`Content-Length (${a}) exceeds limit (${t} bytes)`,null)}}if(!e.body){let a;if(w(e.text))a=await e.text();else if(w(e.json)){let l=await e.json();a=JSON.stringify(l)??""}else a="";let c=new TextEncoder().encode(a).byteLength;if(c>t)throw new B(413,`Payload length (${c}) exceeds limit (${t} bytes)`,null);return a}let n=e.body.getReader(),i=new TextDecoder,o=0,s="";try{for(;;){let{done:a,value:c}=await n.read();if(a)break;if(c){if(o+=c.byteLength,o>t){try{await n.cancel()}catch{}throw new B(413,`Streamed payload exceeded limit (${t} bytes)`,null)}s+=i.decode(c,{stream:!0})}}return s+=i.decode(),s}finally{try{n.releaseLock()}catch{}}},Kr=(e,t={},r={})=>{let n={...t,signal:t.signal?AbortSignal.any([t.signal,AbortSignal.timeout(r.timeout??at)]):AbortSignal.timeout(r.timeout??at)};return fetch(e,n).then(async i=>{if(i.ok){let a=(i.headers?.get?.("Content-Type")||i.headers?.get?.("content-type")||"").includes("application/json");if(x(r.maxBytes)){let c=await rr(i,r.maxBytes);if(r.rawText)return c;if(r.prefix){let l=c.startsWith(r.prefix)?c.substring(r.prefix.length).replace(tr,""):c;return JSON.parse(l)}if(a)return JSON.parse(c);try{return JSON.parse(c)}catch{return c}}if(r.rawText)return w(i.text)?await i.text():"";if(r.prefix){let c=await i.text(),l=c.startsWith(r.prefix)?c.substring(r.prefix.length).replace(tr,""):c;return JSON.parse(l)}if(w(i.text)){let c=await i.text();try{return JSON.parse(c)}catch{return c}}return w(i.json)?await i.json():""}let o=null;try{let s=x(r.maxBytes)?await rr(i,r.maxBytes):w(i.text)?await i.text():"";try{o=JSON.parse(s)}catch{o=s}}catch(s){if(s instanceof B&&s.status===413)throw s}throw new B(i.status,i.statusText,o)})},jr=e=>{let t=AbortSignal.timeout(at),r={method:or.Head,signal:t};return fetch(e,r).then(({ok:n,status:i,statusText:o,headers:s})=>{if(n||i===nr.Forbidden)return{status:i,headers:s};throw new B(i,o,null)})}});var ft={};Q(ft,{serverGeoCoords:()=>Be,serverGeoLocation:()=>we,serverMapHemisphere:()=>lt});var ar,ct,ut,Hr,we,Be,lt,Je=b(()=>{"use strict";T();Qe();et();ar=new ke("[ServerMapper]"),ct={endpoint:"https://ipwho.is/",timeout:3e3,catch:!0,debug:0},ut=null,Hr=()=>(ut||(ut=Promise.resolve().then(()=>(sr(),ir))),ut),we=async(e={})=>{let t={...ct,...e},r=t.catch!==!1;try{let n=t.endpoint||ct.endpoint,i=t.timeout??ct.timeout,{fetchRequest:o}=await Hr(),s=await o(n,{},{...g(i)?{timeout:i}:{},maxBytes:64*1024});if(typeof s!="object"||h(s))throw new Error("Geolocation lookup failed");if(s.status==="fail"||s.success===!1)throw new Error(s.message||s.reason||"Geolocation lookup failed");let a=g(s.lat)?s.lat:s.latitude,c=g(s.lon)?s.lon:s.lng??s.longitude;if(!g(a)||!g(c))throw new Error("Geolocation lookup failed");let l=y(s.timezone)?s.timezone:s.timezone?.id??s.timeZone,p={lat:a,lng:c,latitude:a,longitude:c,...y(s.country||s.countryName||s.country_name)?{country:s.country||s.countryName||s.country_name}:{},...y(s.city||s.cityName||s.city_name)?{city:s.city||s.cityName||s.city_name}:{},...y(l)?{timezone:l}:{},...y(s.query||s.ip||s.ip_address)?{query:s.query||s.ip||s.ip_address}:{},status:"success"};return t.debug&&ar.info(t,"serverGeoLocation success: ",p),p}catch(n){let i=n?.message||"Server geolocation error";if(t.debug&&ar.error(t,"serverGeoLocation error: ",i),!r)throw n;return{error:i,status:"fail"}}},Be=async(e,t)=>{if(!h(e)){let n=e.latitude??e.lat,i=e.longitude??e.lng??e.lon??e.long;if(g(n)&&g(i))return{lat:n,lng:i}}let r=await we(t);return h(r.error)&&g(r.lat)&&g(r.lng)?{lat:r.lat,lng:r.lng}:null},lt=async(e,t)=>{let r=await Be(e,t);return r?r.lat>=0?"north":"south":Le()??null}});var qr={};Q(qr,{GeoPlugin:()=>mt,coerceGeo:()=>pt,default:()=>Yr,geoLocation:()=>he,geoLookup:()=>Ue,geoPlugin:()=>Vr,getStashedGeo:()=>ze,resolveGeoCoordinates:()=>be,serverGeoCoords:()=>Be,serverGeoLocation:()=>we,serverMapHemisphere:()=>lt});var j={};Q(j,{definePlugin:()=>Ke,defineTerm:()=>dr});ue(j,yt(Ze()));var Te=yt(Ze()),Ke=e=>(0,Te.definePlugin)({...e,version:"0.1.0"}),dr=e=>(0,Te.defineTerm)({...e,version:"0.1.0"});fe();T();var pt=e=>{if(h(e)||typeof e!="object")return;let t=e.geo??e,r=e.config?.geo??e.config,n=t?.latitude??t?.lat??e.latitude??e.lat??r?.latitude??r?.lat,i=t?.longitude??t?.lng??t?.lon??t?.long??e.longitude??e.lng??e.lon??e.long??r?.longitude??r?.lng??r?.lon??r?.long,o=t?.elevation??e.elevation??r?.elevation,s=t?.sphere??e.sphere??r?.sphere,a=t?.country??e.country??r?.country,c=t?.city??e.city??r?.city,l={};if(g(n)&&(l.latitude=n),g(i)&&(l.longitude=i),g(o)&&(l.elevation=o),(s==="north"||s==="south")&&(l.sphere=s),y(a)&&(l.country=a),y(c)&&(l.city=c),t&&typeof t=="object")for(let p of Object.keys(t))te(p)&&!["latitude","lat","longitude","lng","lon","long","elevation","sphere","country","city"].includes(p)&&(l[p]=t[p]);return Object.keys(l).length>0?l:void 0},ze=()=>{let{type:e}=q();if(e===_.Browser||e===_.WebWorker)try{if(typeof localStorage<"u"){let t=localStorage.getItem("_map_");if(t){let n=JSON.parse(t)?.geolocation?.coords;if(g(n?.latitude)&&g(n?.longitude))return{latitude:n.latitude,longitude:n.longitude}}}}catch{}},Ue=async(e={})=>{let{type:t}=q();switch(t){case _.Browser:{let{geoLocation:r}=await Promise.resolve().then(()=>(st(),er)),n=await r(e);if(n.error)return{error:n.error};let i=n.coords?.latitude,o=n.coords?.longitude;return{lat:i,lng:o,latitude:i,longitude:o,...n}}case _.WebWorker:{let r=ze();if(r&&g(r.latitude)&&g(r.longitude))return{lat:r.latitude,lng:r.longitude,latitude:r.latitude,longitude:r.longitude};let{serverGeoLocation:n}=await Promise.resolve().then(()=>(Je(),ft));return n(e)}case _.NodeJS:case _.Deno:default:{let{serverGeoLocation:r}=await Promise.resolve().then(()=>(Je(),ft));return r(e)}}},be=async(e,t={})=>{let r=pt(e);if(r&&g(r.latitude)&&g(r.longitude))return{lat:r.latitude,lng:r.longitude};let n=ze();if(n&&g(n.latitude)&&g(n.longitude))return{lat:n.latitude,lng:n.longitude};let i=await Ue(t);return h(i.error)&&g(i.lat)&&g(i.lng)?{lat:i.lat,lng:i.lng}:null};Je();st();var mt=Ke({name:"geo",install(e){e.geoLookup=Ue,e.resolveGeoCoordinates=be,e.serverGeoLocation=we,e.geoLocation=he,e.prototype.geoLocate=async function(t){let r=await be(this,t);if(r){let n=typeof this.config.geo=="object"&&this.config.geo!==null?this.config.geo:{};return new e(this,{...this.config,geo:{...n,latitude:r.lat,longitude:r.lng}})}return this},e.prototype.geoLookup=async function(t){return be(this,t)}}}),Vr=mt,Yr=mt;return gr(qr);})();
|
|
1
|
+
"use strict";var Magma;((Magma||={}).plugins||={}).geo=(()=>{var qr=Object.create;var Be=Object.defineProperty;var Hr=Object.getOwnPropertyDescriptor;var Vr=Object.getOwnPropertyNames;var Xr=Object.getPrototypeOf,Qr=Object.prototype.hasOwnProperty;var E=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var en=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ge=(e,t)=>{for(var r in t)Be(e,r,{get:t[r],enumerable:!0})},Je=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Vr(t))!Qr.call(e,o)&&o!==r&&Be(e,o,{get:()=>t[o],enumerable:!(n=Hr(t,o))||n.enumerable});return e},Oe=(e,t,r)=>(Je(e,t,"default"),r&&Je(r,t,"default")),jt=(e,t,r)=>(r=e!=null?qr(Xr(e)):{},Je(t||!e||!e.__esModule?Be(r,"default",{value:e,enumerable:!0}):r,e)),tn=e=>Je(Be({},"__esModule",{value:!0}),e);var pt=en((ao,Yt)=>{"use strict";Yt.exports=window.Magma.pluginSdk});var nn,on,sn,an,cn,ln,un,fn,qt,pn,Ht,w,Z=E(()=>{"use strict";nn=Symbol.for("$LibraryTarget"),on=Symbol.for("$LibraryDiscover"),sn=Symbol.for("$LibraryExtensible"),an=Symbol.for("nodejs.util.inspect.custom"),cn=Symbol.for("$LibraryLogConfig"),ln=Symbol.for("$LibraryRegistry"),un=Symbol.for("$LibraryRegister"),fn=Symbol.for("$LibrarySerializerRegistry"),qt=Symbol.for("$LibraryMutable"),pn=Symbol.for("$LibraryIdentity"),Ht=Symbol.for("$LibraryUnwrapped"),w={$Target:nn,$Discover:on,$Extensible:sn,$Inspect:an,$LogConfig:cn,$Registry:ln,$Register:un,$SerializerRegistry:fn,$Identity:pn,$Mutable:qt,$Unwrapped:Ht}});function he(e){let t=e,r=0,n=50;for(;t;){let o=t[w.$Target];if(!o||r>=n)break;t=o,r++}return t}function C(e,t=!1){if(!e||typeof e!="object")return[];let r=he(e);if(!t){let u=Reflect.ownKeys(r),f=[];for(let d of u){let h=Object.getOwnPropertyDescriptor(r,d);h&&h.enumerable&&f.push([d,r[d]])}return f}let n=[],o=50,s=0,i=r;for(;i&&i!==Object.prototype&&s++<o;)n.push(he(i)),i=Object.getPrototypeOf(i);let a=[],c=new Set;for(let u of n.reverse()){let f=Reflect.ownKeys(u);for(let d of f){if(c.has(d))continue;let h=Object.getOwnPropertyDescriptor(u,d);!h||!h.enumerable||(c.add(d),a.push([d,r[d]]))}}return a}function Ke(e,t=!1){return C(e,t).map(([r])=>r)}function Vt(e,t=!1){return C(e,t).map(([r,n])=>n)}function je(e,t,r){return t?je(e.map(t,r)):Array.from(new Set(e))}var K=E(()=>{"use strict";Z()});var mt,gt,Ye,ue,V,dn,mn,qe,J=E(()=>{"use strict";Z();K();mt=[],gt=e=>{if(e===null)return"Null";if(e===void 0)return"Undefined";let t=typeof e;if(t==="string")return"String";if(t==="number")return"Number";if(t==="boolean")return"Boolean";if(t==="bigint")return"BigInt";if(t==="symbol")return"Symbol";try{let r=t==="object"?he(e):e;return Object.prototype.toString.call(r).slice(8,-1)}catch{return t==="function"?"Function":"Object"}},Ye=e=>{try{let t=e?.[Symbol.toStringTag]??e?.prototype?.[Symbol.toStringTag];if(typeof t=="string")return t}catch{}},ue=(e,...t)=>{let r=e;try{r=e?.[w.$Target]??e}catch{r=e}let n=gt(r);switch(n){case"Function":try{return mn(r)?"Class":"Function"}catch{return"Function"}case"Object":{try{if("length"in r&&Object.keys(r).every(s=>s==="length"||Number.isFinite(Number(s))))return"ArrayLike";for(let s of t){let i=s.class?.[w.$Target]??s.class;if(r===i||i&&r instanceof i)return s.type}let o=globalThis[w.$Registry]??[];for(let s of[...mt,...o]){let i=s.class?.[w.$Target]??s.class;if(r===i||i&&r instanceof i)return s.type}}catch{return"Object"}return"Object"}default:return n}},V=(e,...t)=>({type:ue(e,...t),value:e}),dn=/^\s*(class\s|\[native code\])/,mn=e=>{if(typeof e!="function")return!1;let t=e?.[w.$Target]??e;if(!("prototype"in t))return!1;let r=t?.name,n=Ye(t);if(t?.[w.$Identity]||t?.prototype?.[w.$Identity]||typeof n=="string"&&n.startsWith("Temporal."))return!0;if(typeof n=="string"&&n.endsWith("Function"))return!1;if((globalThis[w.$Registry]??[]).some(s=>(s.class?.[w.$Target]??s.class)===t||r&&s.type===r||n&&s.type===n))return!0;try{let s=Function.prototype.toString.call(t);if(dn.test(s))return!0;let i=Object.getOwnPropertyDescriptor(t,"prototype");if(i&&i.writable===!1&&!Object.isFrozen(t))return!0;let a=t.prototype;if(a&&Object.getOwnPropertyNames(a).length>2)return!0}catch{return!1}return!1},qe=(e,t)=>{if(typeof e!="function")return;let r=Ye(e),n=t??r??e.name;n&&!["Object","Function",""].includes(n)&&(mt.some(o=>o.class===e)||mt.push({class:e,type:n}))}});function He(e){switch(typeof e){case"number":return Number.isFinite(e);case"bigint":return!0;case"string":{let r=e.trim();return r.length===0?!1:gn.test(r)||g(Number(r))}default:return!1}}var W,X,$,Xt,m,Qt,g,gn,ht,fe,er,T,Ee,tr,Q,yt,k,_,j,N,S,A,_e,Ne,Ve,Pe,R,P=E(()=>{"use strict";Z();J();W=(e,...t)=>t.includes(ue(e)),X=e=>e===null||typeof e!="object"&&typeof e!="function",$=e=>!X(e),Xt=e=>Symbol.iterator in Object(e)&&!m(e),m=e=>typeof e=="string",Qt=e=>typeof e=="string"&&e.trim().length>0,g=e=>Number.isFinite(e),gn=/^[+-]?[0-9]+n$/;ht=e=>typeof e=="bigint",fe=e=>Array.isArray(e),er=e=>gt(e)==="Object"&&"length"in e&&Object.keys(e).every(t=>t==="length"||g(Number(t))),T=e=>W(e,"Object"),Ee=e=>W(e,"Date"),tr=e=>W(e,"RegExp"),Q=e=>typeof e=="symbol",yt=e=>typeof e=="symbol"&&Symbol.keyFor(e)!==void 0,k=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",_=e=>e==null||W(e,"Void","Empty"),j=e=>e===void 0||W(e,"Void","Empty"),N=e=>e!=null&&!_(e),S=e=>W(e,"Function","AsyncFunction","GeneratorFunction","AsyncGeneratorFunction"),A=e=>typeof e=="function",_e=e=>W(e,"Map"),Ne=e=>W(e,"Set"),Ve=(e,t)=>W(e,"Error")&&(t?e instanceof t:!0),Pe=e=>typeof Intl<"u"&&typeof Intl.Locale=="function"&&e instanceof Intl.Locale,R=e=>_(e)||T(e)&&Reflect.ownKeys(e).length===0||m(e)&&e.trim().length===0||typeof e=="number"&&Number.isNaN(e)||fe(e)&&e.length===0||Ne(e)&&e.size===0||_e(e)&&e.size===0||ArrayBuffer.isView(e)&&e.byteLength===0||Ee(e)&&Number.isNaN(e.getTime())});function wt(e,t,r=new WeakSet){let n=t instanceof WeakSet?t:t?.skip??hn;return X(e)||r.has(e)||n.has(e)||e instanceof Date||e instanceof RegExp||e instanceof Error||e instanceof Map||e instanceof Set||e instanceof Promise||e?.[Symbol.toStringTag]==="Enumify"||e[w.$Extensible]?e:(r.add(e),C(e).forEach(([o,s])=>{k(o)&&wt(s,{skip:n},r)}),Object.freeze(e))}var x,ye,hn,De=E(()=>{"use strict";K();P();Z();x={Unknown:"unknown",Browser:"browser",WebWorker:"web-worker",NodeJS:"nodejs",Deno:"deno",GoogleAppsScript:"google-apps-script"},ye=()=>{let e=globalThis;try{if(N(e.SpreadsheetApp))return{global:e,type:x.GoogleAppsScript};if(N(e.window?.document))return{global:e,type:x.Browser};if(S(e.importScripts)||N(e.WorkerGlobalScope)&&e instanceof e.WorkerGlobalScope)return{global:e,type:x.WebWorker};if(N(e.Deno))return{global:e,type:x.Deno};if(N(e.process?.versions?.node)&&e.process?.release?.name==="node")return{global:e,type:x.NodeJS}}catch{}return{global:e,type:x.Unknown}},hn=new WeakSet});function rr(e){return Object.fromEntries(C(e,!0))}var nr=E(()=>{"use strict";K();J();P()});function ir(e,t={},r=!1){let{frozen:n,lock:o,appendOnly:s,onGet:i,keys:a,bind:c,skip:u}=t,f=new Set,d,h,b=he(e);o&&wt(b,u?{skip:u}:void 0),qe(b);let O={isExtensible:l=>Reflect.isExtensible(l),getPrototypeOf:l=>Reflect.getPrototypeOf(l),setPrototypeOf:(l,p)=>{if(n)throw new TypeError("Security: Prototype mutation attempt on protected object");return Reflect.setPrototypeOf(l,p)},getOwnPropertyDescriptor:(l,p)=>{if(!(a&&!a.includes(p))){if(a){if(i&&!Q(p)&&!f.has(p)){f.add(p);try{let y=i(p,l);if(N(y))return{enumerable:!0,configurable:!0,value:y}}finally{f.delete(p)}}return{enumerable:!0,configurable:!0}}return Reflect.getOwnPropertyDescriptor(l,p)}},ownKeys:l=>{if(a)return a;if(i&&!f.has(w.$Discover)){f.add(w.$Discover);try{i(w.$Discover,l)}finally{f.delete(w.$Discover)}}return Reflect.ownKeys(l)},has:(l,p)=>a?a.includes(p):Reflect.has(l,p),deleteProperty:(l,p)=>{if(n)throw new TypeError(`Cannot delete property '${String(p)}' from a protected object.`);if(s&&Reflect.has(l,p))throw new Error(`Security: Deletion attempt on protected key '${String(p)}'`);return Reflect.deleteProperty(l,p)},defineProperty:(l,p,y)=>{if(n&&!Object.isFrozen(l))throw new TypeError(`Cannot define property '${String(p)}' on a frozen object.`);if(s&&Reflect.has(l,p))throw new Error(`Security: Mutation attempt on protected key '${String(p)}'`);return Reflect.defineProperty(l,p,y)},set:(l,p,y,I)=>{if(n&&I===h)throw new TypeError(`Cannot set property '${String(p)}' on a frozen object.`);if(s){if(Array.isArray(l)&&p==="length"&&y<l.length)throw new Error("Security: Truncation attempt on protected array.");if(!(Array.isArray(l)&&p==="length")&&Reflect.has(l,p))throw new Error(`Security: Mutation attempt on protected key '${String(p)}'`)}return Reflect.set(l,p,y,I)},get:(l,p,y)=>{if(p===w.$Target)return y===h?l:void 0;if(n&&(p===w.$Inspect||p==="toJSON")){let v=Object.getOwnPropertyDescriptor(l,p);return v&&S(v.value)?v.value:(d||(d=()=>rr(l)),d)}if(a&&!a.includes(p))return;if(i&&!Q(p)&&!Reflect.has(l,p)&&!f.has(p)){f.add(p);try{let v=i(p,l);if(N(v))return v}finally{f.delete(p)}}let I=Reflect.get(l,p,y);if(c&&p!=="constructor"&&S(I)){let v=Object.getOwnPropertyDescriptor(l,p);if(v&&!v.configurable&&!v.writable)return I;let ce=or.get(I);ce||(ce=new WeakMap,or.set(I,ce));let le=ce.get(l);if(le)return le;let Kt=I.bind(l);return ce.set(l,Kt),Kt}return I}};if(r){let l=Proxy.revocable(b,O);return h=l.proxy,{proxy:l.proxy,revoke:l.revoke}}return h=new Proxy(b,O),h}function sr(e,t=!0,r=t,n=new WeakSet){return ir(e,{frozen:t,lock:r,skip:n,bind:t})}function Ie(e,t=new WeakSet){return ir(e,{frozen:!0,lock:!0,skip:t,bind:!0})}var or,Xe=E(()=>{"use strict";Z();nr();De();K();P();J();or=new WeakMap});function ve(e,t=new WeakSet){return JSON.stringify(e,function(r,n){if(n===void 0)return"\0__undefined__\0";if(ht(n))return`\0__bigint:${n}__\0`;if(S(n))return`function:${n.name||"anonymous"}`;if($(n)){if(t.has(n))return"<Circular>";if(t.add(n),Pe(n))return n.toString();if(_e(n))return`map:[${Array.from(n.entries()).map(o=>ve(o,t)).sort().join(",")}]`;if(Ne(n))return`set:[${Array.from(n).map(o=>ve(o,t)).sort().join(",")}]`}return n})}function cr(e){return function t(...r){return r.length>=e.length?e(...r):(...n)=>t(...r,...n)}}function M(e){let t=new Map;return function(...r){let n=ve(this!==void 0&&this!==globalThis?[this,...r]:r);if(!t.has(n)){let o=e.apply(this,r);t.set(n,o)}return t.get(n)}}function Re(e,t){return{enumerable:!1,configurable:!1,writable:!1,value:function(...r){let n=`${String(e)},${ve(r)}`,o=ar.get(this);if(o||(o=new Map,ar.set(this,o)),!o.has(n)){let s=t.apply(this,r);Ie(s),o.set(n,s)}return o.get(n)}}}var ar,Qe=E(()=>{"use strict";Xe();P();ar=new WeakMap});function lr(e){try{return JSON.parse(JSON.stringify(e))}catch(t){throw console.warn("Could not clean object:",t?.message??t),t}}var ur=E(()=>{"use strict";P()});function te(e){return N(e)?S(e)?e():e:t=>S(t)?t():t}var wn,ee,St=E(()=>{"use strict";K();P();J();wn=e=>{let t=new Set,r=e,n=0;for(;r&&r!==Object.prototype&&n++<10;){let o=Object.getOwnPropertyDescriptors(r);for(let[s,i]of Object.entries(o))k(s)&&(i.enumerable||S(i.get))&&t.add(s);r=Object.getPrototypeOf(r)}return Array.from(t)},ee=e=>{if(X(e)||S(e))return e;if(fe(e))return e.map(r=>ee(r));if(Ee(e)||tr(e)||_e(e)||Ne(e))return e;try{if(S(e.toJSON))return ee(e.toJSON())}catch{}let t={};for(let r of wn(e))try{t[r]=ee(e[r])}catch{}return t};te.stringSymbol=te();te.symbolRegExp=te();te.symbolString=te();te.stringString=te()});function mr(e,t){try{return globalThis.structuredClone(e,t)}catch{return lr(e)}}function Sn(e,t){return xn(t)}function pr(e){let t=encodeURI(e);return t.includes("%")&&(t=t.replace(bn,r=>gr[r.toUpperCase()]??decodeURI(r))),t}function xn(e){if(m(e))try{return decodeURI(e)}catch{}return e}function Ce(e){return!W(e,"Function","AsyncFunction","WeakMap","WeakSet","WeakRef")}function Tn(e,t){return`{"$${e}":${t}}`}function On(e){return F(Q(e)?`${yt(e)?"@":""}@(${e.description??""})`:e)}function bt(e){let[t,r,n]=e.toString().match(En)||[null,void 0,void 0];switch(!0){case Q(e):case _(t):case(N(r)&&j(n)):return e;case N(r):return Symbol.for(n);case j(r):default:return Symbol(n)}}function B(e,t){let r=pe;pe=t?.compact!==!1;try{let n=F(e,!1);if(t?.signed){if(!m(t.secret)||!t.secret)throw new TypeError("stringify: signed serialization requires an explicit secret string");return`$sig:${hr(n,t.secret)}:${n}`}return n}finally{pe=r}}function F(e,t=!0){let r=V(e),n=cr(Tn)(r.type);switch(r.type){case"String":{let o=r.value;return o.startsWith("~")&&(o=`~${o}`),t||(t=o==="true"||o==="false"||o==="null"||parseFloat(o).toString()===o||o.startsWith("~")),t?JSON.stringify(pr(o)):pr(o)}case"Boolean":case"Null":case"Number":return JSON.stringify(r.value);case"Void":case"Undefined":return pe?JSON.stringify("~u"):n(JSON.stringify("void"));case"BigInt":return pe?JSON.stringify(`~n${r.value.toString()}`):n(r.value.toString());case"Date":return pe?JSON.stringify(`~t${r.value.getTime()}`):n(F(r.value.toJSON()));case"Object":return`{${C(r.value).filter(([,s])=>Ce(s)).map(([s,i])=>`${On(s)}: ${F(i)}`).join(",")}}`;case"Array":return`[${r.value.filter(s=>Ce(s)).map(s=>F(s)).join(",")}]`;case"Map":{let o=Array.from(r.value.entries()).filter(([,s])=>Ce(s)).map(([s,i])=>`[${F(s)}, ${F(i)}]`).join(",");return n(`[${o}]`)}case"Set":{let o=Array.from(r.value.values()).filter(s=>Ce(s)).map(s=>F(s)).join(",");return n(`[${o}]`)}case"Symbol":{let o=`${yt(r.value)?"@":""}@(${r.value.description??""})`;return pe?JSON.stringify(`~y${o}`):n(JSON.stringify(o))}case"RegExp":return n(F({source:r.value.source,flags:r.value.flags}));default:{let o=r.value;switch(!0){case!Ce(o):return;case S(o.toJSON):return n(F(o.toJSON()));case(S(o.toString)&&o.toString!==Object.prototype.toString):{let s=o.toString();return n(s.includes('"')?s:JSON.stringify(s))}case(S(o.valueOf)&&o.valueOf!==Object.prototype.valueOf):return n(JSON.stringify(o.valueOf()));default:{let s=ee(o);return $(s)&&Object.keys(s).length>0?F(s):n(JSON.stringify(o,(i,a)=>R(i)?a:F(a)))}}}}}function de(e,t){if(!m(e))return e;let r=S(t)?{sentinel:t}:t??{};if(e.startsWith("$sig:")){let o=e.indexOf(":",5);if(o!==-1){let s=e.substring(5,o),i=e.substring(o+1);if(!m(r.secret)||!r.secret){if(console.warn("objectify: signature verification requires an explicit secret string"),r.throwOnError)throw new TypeError("objectify: signature verification requires an explicit secret string");return e}let a=hr(i,r.secret);if(!Nn(s,a)){if(console.warn("objectify: signature verification failed"),r.throwOnError)throw new Error("objectify: signature verification failed");return e}e=i}else if(r.requireSigned){if(console.warn("objectify: malformed signed payload"),r.throwOnError)throw new Error("objectify: malformed signed payload");return e}}else if(r.requireSigned){if(console.warn("objectify: unsigned string rejected by requireSigned policy"),r.throwOnError)throw new Error("objectify: unsigned string rejected by requireSigned policy");return e}let n;try{n=JSON.parse(e,Sn)}catch(o){return e.startsWith('"')&&e.endsWith('"')?(console.warn(`objectify.parse: -> ${e}, ${o.message}`),e):de(`"${e}"`,r.requireSigned?{...r,requireSigned:!1}:r)}switch(!0){case(e.startsWith("{")&&e.endsWith("}")):case(e.startsWith("[")&&e.endsWith("]")):return xt(n,r,0);default:return Ae(n,r)}}function xt(e,t,r=0){let n=t.maxDepth??Pn;return r>=n?e:T(e)?Ae(C(e).filter(([o])=>k(o)).reduce((o,[s,i])=>Object.assign(o,{[bt(s)]:Ae(xt(i,t,r+1),t)}),{}),t):fe(e)?Vt(e).map(o=>Ae(xt(o,t,r+1),t)):Ae(e,t)}function Ae(e,t){if(m(e)&&e.startsWith("~"))try{if(e.startsWith("~~"))return e.substring(1);if(e.startsWith("~n"))return BigInt(e.substring(2));if(e.startsWith("~t")){let s=e.substring(2),i=new Date(He(s)?Number(s):s);return isNaN(i.getTime())?e:i}if(e==="~u")return t.sentinel?.();if(e.startsWith("~y"))return bt(e.substring(2))}catch{return e}if(!T(e)||Ke(e).length!==1)return e;let[r,n]=C(e)[0];if(!String(r).startsWith("$"))return e;let o=r.substring(1);try{switch(o){case"String":case"Boolean":case"Object":case"Array":return n;case"Number":return Number(n);case"BigInt":return BigInt(n);case"Null":return null;case"Undefined":case"Empty":case"Void":return t.sentinel?.();case"Date":return new Date(n);case"RegExp":return t.allowRegExp===!1||!T(n)||!m(n.source)||n.source.length>Dn?e:new RegExp(n.source,n.flags);case"Symbol":return bt(n);case"Map":return fe(n)?new Map(n):e;case"Set":return fe(n)?new Set(n):e;default:{if(t.allowClasses===!1||t.allowedClasses&&!(t.allowedClasses instanceof Set?t.allowedClasses.has(r)||t.allowedClasses.has(o):t.allowedClasses.includes(r)||t.allowedClasses.includes(o)))return e;let s=et.get(r);return s?Reflect.construct(s,[n]):(console.warn(`objectify: dont know how to deserialize '${o}'`),e)}}}catch{return e}}var et,fr,dr,gr,bn,En,_n,hr,Nn,pe,Pn,Dn,we=E(()=>{"use strict";Qe();K();ur();St();J();P();Z();et=globalThis[w.$SerializerRegistry]??=new Map,fr=e=>{try{let t=e?.prototype?.[Symbol.toStringTag]??e?.[Symbol.toStringTag];return m(t)?t:void 0}catch{return}},dr=(e,t)=>{let r=e.startsWith("$")?e:`$${e}`;if(et.has(r)){let n=et.get(r),o=fr(n),s=fr(t),i=n.name||o,a=t.name||s||(e.startsWith("$")?e.slice(1):e);if(n===t||n.toString()===t.toString()||!!t[w.$Identity]&&n[w.$Identity]===t[w.$Identity]||!!t[w.$Target]&&n[w.$Target]===t[w.$Target]||!!i&&!!a&&i===a)return;throw new Error(`[registerSerializable] Collision: '${r}' is already registered with ${n.name||"anonymous constructor"}`)}et.set(r,t)};gr={"%20":" ","%22":'"',"%3B":";","%3C":"<","%3E":">","%5B":"[","%5D":"]","%5E":"^","%7B":"{","%7C":"|","%7D":"}"},bn=new RegExp(Object.keys(gr).join("|"),"gi");En=/^@(@)?\(([^\)]*)\)$/;_n=globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID().split("-")[0]:Math.random().toString(36).slice(2,10),hr=(e,t=_n)=>{let r=2166136261,n=2654435769,o=`${t}:${e}`;for(let s=0;s<o.length;s++){let i=o.charCodeAt(s);r=Math.imul(r^i,16777619),n=Math.imul(n^i,2246822507)}return(r>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},Nn=(e,t)=>{if(!m(e)||!m(t)||e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e.charCodeAt(n)^t.charCodeAt(n);return r===0},pe=!0;Pn=64,Dn=512});function re(e,t,r,n,o,s){function i(y){if(y!==void 0&&typeof y!="function")throw new TypeError("Function expected");return y}for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",u=!t&&e?n.static?e:e.prototype:null,f=t||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),d,h=!1,b=r.length-1;b>=0;b--){var O={};for(var l in n)O[l]=l==="access"?{}:n[l];for(var l in n.access)O.access[l]=n.access[l];O.addInitializer=function(y){if(h)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(y||null))};var p=(0,r[b])(a==="accessor"?{get:f.get,set:f.set}:f[c],O);if(a==="accessor"){if(p===void 0)continue;if(p===null||typeof p!="object")throw new TypeError("Object expected");(d=i(p.get))&&(f.get=d),(d=i(p.set))&&(f.set=d),(d=i(p.init))&&o.unshift(d)}else(d=i(p))&&(a==="field"?o.unshift(d):f[c]=d)}u&&Object.defineProperty(u,n.name,f),h=!0}function ne(e,t,r){for(var n=arguments.length>2,o=0;o<t.length;o++)r=n?t[o].call(e,r):t[o].call(e);return n?r:void 0}var $e=E(()=>{"use strict"});function yr(e,t){return Ye(e)??(j(t)?e.name||void 0:String(t))}function wr(e,{kind:t,name:r,addInitializer:n}){let o=yr(e,r);if(o&&qe(e,o),t==="class")return o&&n(()=>dr(o,e)),e;throw new Error(`@Serializable decorating unknown 'kind': ${t} (${r})`)}function oe(e,t){let r=(n,o,s)=>{let i=n.prototype,a=o??yr(n,s);if(a&&(i&&!Object.hasOwn(i,Symbol.toStringTag)&&Object.defineProperty(i,Symbol.toStringTag,{value:a,configurable:!0,writable:!1,enumerable:!1}),!n.name||n.name!==a))try{Object.defineProperty(n,"name",{value:a,configurable:!0,writable:!1,enumerable:!1})}catch{}return n};return A(e)&&t?.kind==="class"?r(e,void 0,t.name):(n,o)=>r(n,m(e)?e:void 0,o?.name)}var Me=E(()=>{"use strict";Z();Xe();P();we();J()});var Tt,Sr=E(()=>{"use strict";$e();P();Me();Tt=(()=>{let e=[oe("BoundedCache")],t,r=[],n,o=Map;var s=class extends o{static{n=this}static{let i=typeof Symbol=="function"&&Symbol.metadata?Object.create(o[Symbol.metadata]??null):void 0;re(null,t={value:n},e,{kind:"class",name:n.name,metadata:i},null,r),s=n=t.value,i&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:i}),ne(n,r)}#t=new Map;#e=new Set;#r=new Map;maxSize;ttl;constructor(i=1e3,a=1440*60*1e3){super(),this.maxSize=i,this.ttl=a}get isBoundedCache(){return!0}#n(i){let a=this.#t.get(i);return a===void 0?!1:Date.now()>a}evictExpired(){if(this.#t.size===0)return;let i=Date.now();for(let[a,c]of this.#t.entries())i>c&&this.delete(a)}setStatic(i,a){return super.has(i)&&super.delete(i),super.set(i,a),this.#e.add(i),this.#t.delete(i),this.#r.delete(i),this}isStatic(i){return this.#e.has(i)}get(i){if(this.#n(i)){this.delete(i);return}if(!super.has(i))return;let a=super.get(i);return super.delete(i),super.set(i,a),a}has(i){return this.#n(i)?(this.delete(i),!1):super.has(i)}get size(){return this.evictExpired(),super.size}forEach(i,a){this.evictExpired(),super.forEach(i,a)}set(i,a,c){this.evictExpired();let u=this.#t.get(i);for(super.has(i)&&super.delete(i),super.set(i,a),this.#e.delete(i),N(c)?c!==1/0?(this.#t.set(i,Date.now()+c),this.#r.set(i,c)):(this.#t.delete(i),this.#r.delete(i)):u!==void 0?this.#t.set(i,u):this.ttl!==1/0?(this.#t.set(i,Date.now()+this.ttl),this.#r.delete(i)):(this.#t.delete(i),this.#r.delete(i));this.size-this.#e.size>this.maxSize;){let f=!1,d=super.keys(),h=d.next();for(;!h.done;){let b=h.value;if(!this.#e.has(b)){this.delete(b),f=!0;break}h=d.next()}if(!f)break}return this}delete(i){return this.#e.delete(i),this.#t.delete(i),this.#r.delete(i),super.delete(i)}deletePrefix(i){let a=String(i).trim().toLowerCase();if(R(a))return 0;let c=[];for(let u of super.keys())m(u)&&u.toLowerCase().startsWith(a)&&c.push(u);for(let u of c)this.delete(u);return c.length}clear(i){if(i===void 0){this.#e.clear(),this.#t.clear(),this.#r.clear(),super.clear();return}let a=0;for(let c of super.keys()){if(a>=i)break;this.#e.has(c)||(this.delete(c),a++)}}keys(){return this.evictExpired(),super.keys()}values(){return this.evictExpired(),super.values()}entries(){return this.evictExpired(),super.entries()}[Symbol.iterator](){return this.evictExpired(),super[Symbol.iterator]()}toJSON(){this.evictExpired();let i=[];for(let[a,c]of super.entries())m(a)&&i.push([a,c]);return Object.fromEntries(i)}static fromEntries(i,a=1e3,c=1440*60*1e3){let u=new s(a,c);for(let[f,d]of i)u.set(f,d);return u}};return s=n})()});function Tr(e,t){let r;if(j(e))return t??{};switch(z.type){case x.Browser:r=Ot.getItem(e);break;case x.NodeJS:r=Le.has(e)?Le.get(e):In(e);break;case x.Deno:r=z.global.Deno.env.get(e);break;case x.GoogleAppsScript:r=z.global.PropertiesService?.getUserProperties().getProperty(e);break;case x.WebWorker:case x.Unknown:r=void 0;break;default:throw new Error(`Cannot determine Javascript context: ${z.type}`)}return m(r)?de(r):t}function Nt(e,t,r){let n=N(t)?B(t):void 0,o=N(n);switch(z.type){case x.Browser:try{o?Ot.setItem(e,n):Ot.removeItem(e)}catch(s){console.warn(`[Storage] Failed to ${o?"setItem":"removeItem"} for key '${e}':`,s)}break;case x.NodeJS:o?r?.static?Le.setStatic(e,n):Le.set(e,n,r?.ttl):Le.set(e,void 0,r?.ttl);break;case x.Deno:o?z.global.Deno.env.set(e,n):z.global.Deno.env.delete(e);break;case x.GoogleAppsScript:o?z.global.PropertiesService?.getUserProperties().setProperty(e,n):z.global.PropertiesService?.getUserProperties().deleteProperty(e);break;case x.WebWorker:case x.Unknown:break;default:throw new Error(`Cannot determine Javascript context: ${z.type}`)}}var z,xr,br,Et,_t,Ot,Le,In,Pt=E(()=>{"use strict";we();De();P();Sr();z=ye(),xr=(e=1e3,t=1/0)=>{let r=new Tt(e,t);return{get length(){return r.size},clear:()=>r.clear(),getItem:n=>r.get(n)??null,key:n=>Array.from(r.keys())[n]??null,removeItem:n=>{r.delete(n)},setItem:(n,o)=>{r.set(n,String(o))}}},br=new Map,Et=e=>{let t=br.get(e);return t||(t=xr(),br.set(e,t)),t},_t=(e="localStorage")=>{try{let t=globalThis?.[e];if(t&&A(t.getItem)&&A(t.setItem)&&A(t.removeItem)&&A(t.clear)&&A(t.key)&&g(t.length))return t}catch{}return Et(e)},Ot=z.type===x.Browser?_t():xr(),Le=new Tt(1e3,1/0),In=e=>{try{let t=Reflect.get(z.global,"process");if(!t||typeof t!="object")return;let r=Reflect.get(t,"env");return!r||typeof r!="object"?void 0:Reflect.get(r,e)}catch{return}}});var Or=E(()=>{"use strict";we();P()});function Er(e=[],t){let r=n=>j(t)||N(n)?n:mr(t);return er(e)||Xt(e)&&!m(e)?Array.from(e,r):[e]}function _r(e){if(Ve(e))return e;let t=new Error(T(e)&&m(e.message)?e.message:String(e));return T(e)&&(t.name=m(e.name)?e.name:"Error","code"in e&&(m(e.code)||g(e.code))&&(t.code=e.code),"stack"in e&&m(e.stack)&&(t.stack=e.stack)),t}var Pi,Di,Dt=E(()=>{"use strict";we();J();P();Or();Pi=BigInt(Number.MAX_SAFE_INTEGER),Di=BigInt(Number.MIN_SAFE_INTEGER)});var Nr=E(()=>{"use strict";Dt();if(typeof globalThis.Temporal>"u")throw new Error("Temporal API is not available. Node 20+ with a polyfill (e.g. @js-temporal/polyfill) is highly recommended. Native Temporal is fully reliable only on Node 26+ (while Node 22 may have instabilities).");try{if(typeof Temporal.Now.zonedDateTimeISO=="function"&&typeof Temporal.Now.zonedDateTimeISO().add!="function")throw new Error("Incomplete Temporal implementation")}catch(e){let t=_r(e);if(console.warn("Tempo: Native Temporal implementation appears incomplete. Consider loading a polyfill.",t),t.message!=="Incomplete Temporal implementation")throw t}});function Pr(){return Temporal.Now.instant()}function Dr(e,t=2024){let r=Temporal.ZonedDateTime.from({year:t,month:1,day:1,hour:0,minute:0,second:0,timeZone:e}).offsetNanoseconds,n=Temporal.ZonedDateTime.from({year:t,month:7,day:1,hour:0,minute:0,second:0,timeZone:e}).offsetNanoseconds;return{jan:r,jul:n}}var It=E(()=>{"use strict";Nr();P()});function Fe(e,t,r){if(e){if(A(e[t]))return e[t]();if(r&&r in e)return e[r]}}function Un(e){return e?Mn.has(e)?5:$n.has(e)?6:An.has(e)?7:1:1}function Jn(e){return e?e==="IR"?Wn:e==="AF"?kn:Ln.has(e)?Gn:Ir:Ir}function Bn(e,t){let r=e?.script??(A(e?.maximize)?e.maximize().script:void 0);return r&&zn.has(r)||t&&Fn.has(t)?"rtl":"ltr"}var vn,Rn,Se,se,Gi,Wi,Rt,ki,Cn,Ui,An,$n,Mn,Ln,Fn,zn,Ir,Gn,Wn,kn,vt,Ji,Bi,Zn,Kn,vr,Zi,tt,Ki,Ct=E(()=>{"use strict";It();Qe();P();Dt();vn=/_/g,Rn=/[.@]/,Se=e=>typeof Intl<"u"&&(!e||Object.hasOwn(Intl,e)&&A(Intl[e])),se=e=>{if(Pe(e)&&(e=e.toString()),!m(e))return;let t=e.trim();if(R(t))return;let r=t.split(Rn)[0];if(!R(r))return r.replace(vn,"-")},Gi=M((e,t)=>new Intl.RelativeTimeFormat(se(e),t)),Wi=M((e,t)=>new Intl.ListFormat(se(e),t)),Rt=M((e,t)=>new Intl.DateTimeFormat(se(e),t)),ki=M((e,t)=>{try{return new Intl.PluralRules(se(e),t)}catch{return{select:()=>"other"}}}),Cn=M((e,t)=>new Intl.NumberFormat(se(e),t)),Ui=M((e,t)=>{try{let r=new Intl.DurationFormat(se(e),t);if(S(r.format))return r;throw new Error("No format method")}catch{return{format:n=>String(n)}}});An=new Set(["US","CA","MX","BR","IL","JP","TW","HK","MO","PH","SG","TH","IN","KR","CO","PE","VE","ZA"]),$n=new Set(["SA","AF","BH","DJ","DZ","EG","IQ","IR","JO","KW","LY","OM","QA","SD","SY","YE"]),Mn=new Set(["MV"]),Ln=new Set(["SA","BH","DJ","DZ","EG","IQ","JO","KW","LY","OM","QA","SD","SY","YE"]),Fn=new Set(["ar","he","fa","ur","yi","ps","sd","ug","ckb"]),zn=new Set(["Arab","Hebr","Thaa","Syrc","Mand","Samr","Nkoo"]),Ir=Object.freeze([6,7]),Gn=Object.freeze([5,6]),Wn=Object.freeze([5]),kn=Object.freeze([4,5]);vt=M(e=>{if(Pe(e))return e;if(Se("Locale"))try{let t=se(e);return new Intl.Locale(t||"en-US")}catch{return}}),Ji=M(e=>{let t=vt(e)??vt("en-US"),r=t?.baseName??vr(e)??"en-US",n=t?.language??r.split("-")[0]?.toLowerCase(),o=[];for(let le of r.split("-").slice(1)){if(le.length===1)break;o.push(le)}let s=t?.region??(A(t?.maximize)?t.maximize().region:void 0)??o.find(le=>/^[a-zA-Z]{2}$|^\d{3}$/.test(le))?.toUpperCase(),i=t?.script??(A(t?.maximize)?t.maximize().script:void 0),a=Fe(t,"getWeekInfo","weekInfo"),c=a?.firstDay??Un(s),u=Array.isArray(a?.weekend)?Object.freeze([...a.weekend]):Jn(s),d=Fe(t,"getHourCycles","hourCycles")??t?.hourCycle??(Se("DateTimeFormat")?Rt(r,{hour:"numeric"}).resolvedOptions().hourCycle:void 0),h=Array.isArray(d)&&d.length>0?Object.freeze([...d]):m(d)?Object.freeze([d]):Object.freeze(["h23"]),b=Fe(t,"getTextInfo","textInfo"),O=b?.direction==="rtl"||b?.direction==="ltr"?b.direction:Bn(t,n),p=Fe(t,"getNumberingSystems","numberingSystems")??t?.numberingSystem??(Se("NumberFormat")?Cn(r).resolvedOptions().numberingSystem:void 0),y=Array.isArray(p)&&p.length>0?Object.freeze([...p]):m(p)?Object.freeze([p]):Object.freeze(["latn"]),I=Fe(t,"getTimeZones","timeZones"),v=Array.isArray(I)&&I.length>0?Object.freeze([...I]):Object.freeze([]),ce=Object.freeze({firstDay:c,weekend:u});return Object.freeze({locale:t,baseName:r,language:n,region:s,script:i,weekInfo:ce,firstDay:c,weekend:u,hourCycle:h[0],hourCycles:h,direction:O,numberingSystem:y[0],numberingSystems:y,timeZones:v})}),Bi=M((e="latn")=>{if(!(!e||e==="latn"||!Se("NumberFormat")))try{let t=new Intl.NumberFormat(`en-u-nu-${e}`,{useGrouping:!1}),r=Array.from({length:10},(n,o)=>t.format(o));return r[0]==="0"&&r[9]==="9"?void 0:Object.freeze(r)}catch{return}}),Zn=Object.freeze({locale:"en-US",calendar:"iso8601",numberingSystem:"latn",timeZone:"UTC"}),Kn=M(()=>Se("DateTimeFormat")?Object.freeze(Rt().resolvedOptions()):Zn),vr=M(e=>{let t=se(e);if(t){if(Se("getCanonicalLocales"))try{return Intl.getCanonicalLocales(t)[0]}catch{return}return vt(t)?.baseName??t}}),Zi=M(e=>Object.freeze(Er(e).map(t=>vr(t)).filter(Boolean))),tt=M((e=Kn().timeZone)=>{try{let{jan:t,jul:r}=Dr(e),o=["Australia","Antarctica","Africa/Johannesburg","America/Argentina/Buenos_Aires","America/Sao_Paulo"].some(s=>e.startsWith(s));switch(!0){case r>t:return"north";case r<t:return"south";default:return o?"south":void 0}}catch{return}}),Ki=M(e=>{try{let t=new Date(2024,11,24),r=Rt(e).formatToParts(t);return r[0].type==="month"&&r[0].value==="12"}catch{return!1}})});function Y(e){return{enumerable:!1,configurable:!1,writable:!1,value:e}}function be(e,t=!0){let n=ue(this)!=="Module"&&S(this?.has)?this:Yn,o=V(e),s=Object.create(n);switch(o.type){case"Enumify":case"Object":Object.defineProperties(s,Object.getOwnPropertyDescriptors(o.value));break;case"Array":o.value.forEach((i,a)=>{if(g(i))throw new Error("Enumify: numeric keys are not supported");s[i]=a});break;default:throw new Error(`Enumify: invalid argument type: ${o.type}`)}return sr(s,!0,t)}var jn,Yn,ts,Rr=E(()=>{"use strict";$e();J();P();K();Xe();Me();Qe();jn="Enumify",Yn=Ie(Object.create(null,{keys:Re("keys",function(){return C(this,!0).map(([e])=>e)}),values:Re("values",function(){return C(this,!0).map(([e,t])=>t)}),entries:Re("entries",function(){return C(this,!0).map(([e,t])=>Object.freeze([e,t]))}),invert:Re("invert",function(){return Object.fromEntries(this.entries().map(([e,t])=>[t,e]))}),has:Y(function(e){return this.keys().includes(e)}),count:Y(function(){return this.keys().length}),includes:Y(function(e){return this.values().includes(e)}),keyOf:Y(function(e){return this.invert()[e]}),extend:Y(function(e,t){return be.call(this,e,t)}),forEach:Y(function(e,t){this.entries().forEach((r,n)=>e.call(t,r,n,this))}),filter:Y(function(e,t){return be(this.entries().reduce((r,n,o)=>e.call(t,n,o,this)?Object.assign(r,{[n[0]]:n[1]}):r,{}))}),map:Y(function(e,t){return be(this.entries().reduce((r,n,o)=>Object.assign(r,{[n[0]]:e.call(t,n,o,this)}),{}))}),[Symbol.iterator]:Y(function*(){for(let e of this.entries())yield e}),[Symbol.toStringTag]:{enumerable:!1,configurable:!1,writable:!1,value:jn}}));ts=(()=>{let e=[wr,oe("Enumify")],t,r=[],n;var o=class{static{n=this}static{let s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;re(null,t={value:n},e,{kind:"class",name:n.name,metadata:s},null,r),o=n=t.value,s&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),ne(n,r)}constructor(s){return be(s)}};return o=n})()});function qn(e,t=G.Info){return g(e)?e>=G.Off&&e<=G.Trace?e:t:m(e)?Cr[e.toLowerCase()]??t:t}var G,L,Cr,rt,At=E(()=>{"use strict";$e();P();Rr();Z();Me();G=be(["Off","Error","Warn","Info","Debug","Trace"]),L={Off:"off",Log:"log",Info:"info",Warn:"warn",Debug:"debug",Trace:"trace",Error:"error"},Cr={[L.Off]:G.Off,[L.Error]:G.Error,[L.Warn]:G.Warn,[L.Info]:G.Info,[L.Log]:G.Info,[L.Debug]:G.Debug,[L.Trace]:G.Trace};rt=(()=>{let e=[oe("Logger")],t,r=[],n;var o=class{static{n=this}static{let s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;re(null,t={value:n},e,{kind:"class",name:n.name,metadata:s},null,r),o=n=t.value,s&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),ne(n,r)}#t;level;constructor(s,i=G.Info){this.#t=s.startsWith("[")?s:`[${s}]`,this.level=i}#e(s,...i){let a;if(i.length>0&&T(i[0]))try{i[0][w.$LogConfig]&&(a=i.shift())}catch{}let c=this.level;if(a){if(a.silent===!0)return;a.debug!==void 0&&(c=qn(a.debug,c))}if(c===G.Off||(Cr[s]??0)>c)return;let f=i.map(d=>{if(Ve(d))return d.message;if(T(d))try{let h=d.constructor?.name??"Object";if(h==="Object"){let b=Object.keys(d);return`{ ${b.slice(0,3).join(", ")}${b.length>3?`, ... (+${b.length-3} more)`:""} }`}return`[${h}]`}catch{return"[Object]"}return String(d)}).filter(d=>!R(d)).join(" ");R(f)||console[s](`${this.#t} ${f}`)}log=(...s)=>this.#e(L.Log,...s);info=(...s)=>this.#e(L.Info,...s);warn=(...s)=>this.#e(L.Warn,...s);debug=(...s)=>this.#e(L.Debug,...s);trace=(...s)=>this.#e(L.Trace,...s);error=(...s)=>this.#e(L.Error,...s)};return o=n})()});var Ar={};ge(Ar,{WebStore:()=>Hn});var ze,Hn,$r=E(()=>{"use strict";$e();K();we();J();P();Pt();Me();ze={Local:"local",Session:"session"},Hn=(()=>{let e=[oe("WebStore")],t,r=[],n;var o=class{static{n=this}static{let s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;re(null,t={value:n},e,{kind:"class",name:n.name,metadata:s},null,r),o=n=t.value,s&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),ne(n,r)}static _localInstance;static _sessionInstance;static get local(){return o._localInstance??=new o(ze.Local)}static get session(){return o._sessionInstance??=new o(ze.Session)}#t;#e;get#r(){if(this.#e)return this.#e;let s=this.#t===ze.Local?"localStorage":"sessionStorage";return this.#e=_t(s)}#n(s){try{return s(this.#r)}catch{let a=this.#t===ze.Local?"localStorage":"sessionStorage",c=Et(a);return this.#e=c,s(c)}}constructor(s=ze.Local){this.#t=s}get(s,i){let a=this.#n(c=>c.getItem(B(s)));return m(a)?de(a):i??null}set(s,i,a={merge:!0}){if(_(s))return this.clear();let c=this.get(s),u=V(i);switch(u.type){case"Undefined":return this.del(s);case"Object":return c??={},this.#o(s,a.merge?Object.assign(c,u.value):u.value);case"Array":return c??=[],this.#o(s,a.merge?je(c.concat(u.value)):i);case"Map":return c??=new Map,a.merge?(u.value.forEach((f,d)=>c.set(d,f)),this.#o(s,c)):this.#o(s,u.value);case"Set":return c??=new Set,a.merge?(u.value.forEach(f=>c.add(f)),this.#o(s,c)):this.#o(s,u.value);default:return this.#o(s,u.value)}}clear(){try{this.#n(s=>s.clear())}catch(s){console.warn("[WebStore] Failed to clear storage:",s)}return this}del(...s){return s.forEach(i=>{try{this.#n(a=>a.removeItem(B(i)))}catch(a){console.warn(`[WebStore] Failed to removeItem for key '${String(i)}':`,a)}}),this}keys(...s){return this.entries(...s).map(([i])=>i)}values(...s){return this.entries(...s).map(([,i])=>i)}entries(...s){let i=new Set(s.map(c=>B(c))),a=[];return this.#n(c=>{for(let u=0;u<c.length;u++){let f=c.key(u);if(f!==null&&(R(s)||i.has(f))){let d=c.getItem(f);a.push([de(f),de(d)])}}}),a}from(s){return C(s).forEach(([i,a])=>this.set(i,a)),this}#o(s,i){try{this.#n(a=>a.setItem(B(s),B(i)))}catch(a){console.warn(`[WebStore] Failed to setItem for key '${String(s)}':`,a)}return this}};return o=n})()});var Fr={};ge(Fr,{geoCoords:()=>Lr,geoLocation:()=>Ge,mapAddress:()=>Xn,mapHemisphere:()=>Vn,mapQuery:()=>Lt});var ot,Mr,D,Mt,q,$t,nt,Ge,Lr,Lt,Vn,Xn,Ft=E(()=>{"use strict";St();De();P();It();Ct();At();ot={catch:!0,debug:0},Mr=ye(),D={},Mt="_magma_browser_map_",q=new rt("[Mapper]"),$t=null,nt=()=>($t||($t=new Promise((e,t)=>{Mr.type===x.Browser?Promise.resolve().then(()=>($r(),Ar)).then(({WebStore:r})=>{let n=new r("local"),o=n.get(Mt,{});$(o)&&(o.geolocation&&(!o.geolocation.coords||o.geolocation.$GeolocationPosition)&&delete o.geolocation,Object.assign(D,o)),e(n)}).catch(t):e(void 0)})),$t),Ge=(e={})=>nt().then(()=>new Promise((t,r)=>{e=Object.assign({},ot,e);let n=e.catch?t:r;typeof navigator<"u"&&"geolocation"in navigator?navigator.geolocation.getCurrentPosition(o=>{let s=D.geolocation?.coords,i=s?.latitude?.toFixed(3),a=s?.longitude?.toFixed(3),c=D.geolocation?.timestamp??0,u=o.coords.latitude.toFixed(3)!==i,f=o.coords.longitude.toFixed(3)!==a,d=c<Pr().epochMilliseconds-36e5;(u||f||d)&&(Object.assign(D,{georesponse:null}),q.info(e,"GeoLocation: device update")),Object.assign(D,{geolocation:ee(o)}),t(D.geolocation)},o=>{Object.assign(D,{geolocation:{error:o.message},georesponse:null}),n(D.geolocation)}):(Object.assign(D,{geolocation:{error:"Not Supported"},georesponse:null}),n(D.geolocation))})).finally(()=>{(D.geolocation?.error?q.error:q.info)(e,"geoLocation: ",D.geolocation),nt().then(r=>r?.set(Mt,D))}),Lr=e=>new Promise((t,r)=>{if(!_(e))return t(e);Ge().then(n=>_(n.error)?{location:{lat:n.coords.latitude,lng:n.coords.longitude}}:null).then(n=>t(n)).catch(n=>r(n))}),Lt=(e,t={})=>nt().then(()=>new Promise((r,n)=>{t=Object.assign({},ot,t);let o=t.catch?r:n;Lr(e).then(s=>{switch(!0){case(Mr.type!==x.Browser||!window.google?.maps):throw new Error("Google Maps API not configured");case _(s):throw new Error("Cannot determine Coordinates");case _(e):{let i=D.geolocation&&D.georesponse,a=_(D.geolocation?.error)&&_(D.georesponse?.error);if(i&&a)return t.debug&&q.debug(t,"mapQuery: cache"),r(D.georesponse)}default:new window.google.maps.Geocoder().geocode(s).then(i=>r(D.georesponse=ee(i)))}}).catch(s=>{Object.assign(D,{georesponse:{error:s.message}}),o(D.georesponse)})})).finally(()=>{t.debug&&(D.georesponse?.error?q.error:q.debug)(t,"mapQuery: ",D.georesponse),nt().then(r=>r?.set(Mt,D))}),Vn=(e,t={})=>Lt(e,t).then(r=>{if(t=Object.assign({},ot,t),_(r.error))return t.debug&&q.debug(t,"sphere: ",r),r.results[0].geometry.location.lat()>=0?"north":"south";let n=tt();if(_(n)&&t.catch===!1)throw new Error("Cannot determine Hemisphere");return n}).catch(r=>{if(t.debug&&q.warn(t,"mapHemisphere: ",r.message),t.catch===!1)throw r;return null}),Xn=(e,t={})=>Lt(e,t).then(r=>{if(!_(r.error))throw new Error(r.error);return r.results[0]}).then(({formatted_address:r,address_components:n})=>n.reduce((o,s)=>(s.types.filter(i=>i!=="political").forEach(i=>o[i]=(o[i]?o[i]+",":"").concat(s.short_name)),o),{formatted_address:r})).catch(r=>{if(t=Object.assign({},ot,t),t.debug&&q.warn(t,"mapAddress: ",r.message),t.catch===!1)throw r;return null})});var Ur={};ge(Ur,{HTTP:()=>Wr,HttpError:()=>H,METHOD:()=>kr,fetchHead:()=>eo,fetchRequest:()=>Qn});var zt,zr,Wr,kr,H,Gr,Qn,eo,Jr=E(()=>{"use strict";P();zt=2e3,zr=/\);?$/,Wr={Ok:200,PermRedirect:301,TempRedirect:302,BadRequest:400,Unauthorised:401,Forbidden:403},kr={Head:"HEAD",Get:"GET",Put:"PUT",Delete:"DELETE",Post:"POST"},H=class extends Error{status;statusText;body;constructor(t,r,n){super(`${t}: ${r}`),this.status=t,this.statusText=r,this.body=n,this.name="HttpError"}},Gr=async(e,t)=>{let r=e.headers?.get?.("Content-Length")||e.headers?.get?.("content-length");if(r){let a=parseInt(r,10);if(g(a)&&a>t){try{await e.body?.cancel()}catch{}throw new H(413,`Content-Length (${a}) exceeds limit (${t} bytes)`,null)}}if(!e.body){let a;if(S(e.text))a=await e.text();else if(S(e.json)){let u=await e.json();a=JSON.stringify(u)??""}else a="";let c=new TextEncoder().encode(a).byteLength;if(c>t)throw new H(413,`Payload length (${c}) exceeds limit (${t} bytes)`,null);return a}let n=e.body.getReader(),o=new TextDecoder,s=0,i="";try{for(;;){let{done:a,value:c}=await n.read();if(a)break;if(c){if(s+=c.byteLength,s>t){try{await n.cancel()}catch{}throw new H(413,`Streamed payload exceeded limit (${t} bytes)`,null)}i+=o.decode(c,{stream:!0})}}return i+=o.decode(),i}finally{try{n.releaseLock()}catch{}}},Qn=(e,t={},r={})=>{let n={...t,signal:t.signal?AbortSignal.any([t.signal,AbortSignal.timeout(r.timeout??zt)]):AbortSignal.timeout(r.timeout??zt)};return fetch(e,n).then(async o=>{if(o.ok){let a=(o.headers?.get?.("Content-Type")||o.headers?.get?.("content-type")||"").includes("application/json");if(N(r.maxBytes)){let c=await Gr(o,r.maxBytes);if(r.rawText)return c;if(r.prefix){let u=c.startsWith(r.prefix)?c.substring(r.prefix.length).replace(zr,""):c;return JSON.parse(u)}if(a)return JSON.parse(c);try{return JSON.parse(c)}catch{return c}}if(r.rawText)return S(o.text)?await o.text():"";if(r.prefix){let c=await o.text(),u=c.startsWith(r.prefix)?c.substring(r.prefix.length).replace(zr,""):c;return JSON.parse(u)}if(S(o.text)){let c=await o.text();try{return JSON.parse(c)}catch{return c}}return S(o.json)?await o.json():""}let s=null;try{let i=N(r.maxBytes)?await Gr(o,r.maxBytes):S(o.text)?await o.text():"";try{s=JSON.parse(i)}catch{s=i}}catch(i){if(i instanceof H&&i.status===413)throw i}throw new H(o.status,o.statusText,s)})},eo=e=>{let t=AbortSignal.timeout(zt),r={method:kr.Head,signal:t};return fetch(e,r).then(({ok:n,status:o,statusText:s,headers:i})=>{if(n||o===Wr.Forbidden)return{status:o,headers:i};throw new H(o,s,null)})}});var Zr={};ge(Zr,{serverGeoCoords:()=>it,serverGeoLocation:()=>We,serverMapHemisphere:()=>Ut});var Br,kt,Gt,Wt,to,We,it,Ut,Jt=E(()=>{"use strict";P();Ct();At();Br=new rt("[ServerMapper]"),kt="https://ipwho.is",Gt={endpoint:`${kt}/`,timeout:3e3,catch:!0,debug:0},Wt=null,to=()=>(Wt||(Wt=Promise.resolve().then(()=>(Jr(),Ur))),Wt),We=async(e={})=>{let t={...Gt,...e},r=t.catch!==!1;try{let n=t.endpoint||Gt.endpoint;if(m(t.ip)){let d=encodeURIComponent(t.ip.trim());if((n.endsWith("/")?n.slice(0,-1):n)===kt)n=`${kt}/${d}`;else if(n.includes("{ip}"))n=n.replace("{ip}",d);else if(d!=="")throw new Error(`Custom endpoint must include an '{ip}' placeholder to resolve a specific IP: ${n}`)}let o=t.timeout??Gt.timeout,{fetchRequest:s}=await to(),i=await s(n,{},{...g(o)?{timeout:o}:{},maxBytes:64*1024});if(typeof i!="object"||_(i))throw new Error("Geolocation lookup failed");if(i.status==="fail"||i.success===!1)throw new Error(i.message||i.reason||"Geolocation lookup failed");let a=g(i.lat)?i.lat:i.latitude,c=g(i.lon)?i.lon:i.lng??i.longitude;if(!g(a)||!g(c))throw new Error("Geolocation lookup failed");let u=m(i.timezone)?i.timezone:i.timezone?.id??i.timeZone,f={lat:a,lng:c,latitude:a,longitude:c,...m(i.country||i.countryName||i.country_name)?{country:i.country||i.countryName||i.country_name}:{},...m(i.city||i.cityName||i.city_name)?{city:i.city||i.cityName||i.city_name}:{},...m(u)?{timezone:u}:{},...m(i.query||i.ip||i.ip_address)?{query:i.query||i.ip||i.ip_address}:{},status:"success"};return t.debug&&Br.info(t,"serverGeoLocation success: ",f),f}catch(n){let o=n?.message||"Server geolocation error";if(t.debug&&Br.error(t,"serverGeoLocation error: ",o),!r)throw n;return{error:o,status:"fail"}}},it=async(e,t)=>{if(!_(e)){let n=e.latitude??e.lat,o=e.longitude??e.lng??e.lon??e.long;if(g(n)&&g(o))return{lat:n,lng:o}}let r=await We(t);return _(r.error)&&g(r.lat)&&g(r.lng)?{lat:r.lat,lng:r.lng}:null},Ut=async(e,t)=>{let r=await it(e,t);return r?r.lat>=0?"north":"south":tt()??null}});var io={};ge(io,{GEO_PROPERTIES:()=>ke,GeoPlugin:()=>Zt,clearStashedGeo:()=>ct,coerceGeo:()=>ae,default:()=>oo,geoLocation:()=>Ge,geoLookup:()=>lt,geoPlugin:()=>no,getStashedGeo:()=>Te,haversineDistance:()=>ut,resolveGeoCoordinates:()=>Ue,serverGeoCoords:()=>it,serverGeoLocation:()=>We,serverMapHemisphere:()=>Ut,solarOffset:()=>ft,stashGeo:()=>at});var U={};ge(U,{definePlugin:()=>dt,defineTerm:()=>rn});Oe(U,jt(pt()));var Ze=jt(pt()),dt=e=>(0,Ze.definePlugin)({...e,version:"1.1.0"}),rn=e=>(0,Ze.defineTerm)({...e,version:"1.1.0"});De();P();Pt();P();function ie(...e){for(let t of e){let r=S(t)?t():t;if(r!==void 0)return r}}var st="_magma_geo_",Kr=1440*60*1e3,ke=["latitude","lat","longitude","lng","lon","long","elevation","sphere","country","city","timezone","tz"],jr=e=>g(e)&&e>=-90&&e<=90?Math.round(e*1e3)/1e3:void 0,Yr=e=>g(e)&&e>=-180&&e<=180?Math.round(e*1e3)/1e3:void 0,xe=(e,t)=>{let r=jr(e),n=Yr(t);return r!==void 0&&n!==void 0?{lat:r,lng:n}:void 0},me=(e,t)=>{if(e==="north"||e==="south"||e==="equator")return e;if(g(t))return t>.001?"north":t<-.001?"south":"equator"},ae=e=>{if(m(e)&&e.includes(",")){let p=e.split(",").map(y=>y.trim()).map(y=>y===""?NaN:Number(y));if(p.length>=2&&!isNaN(p[0])&&!isNaN(p[1])){let y=xe(p[0],p[1]);if(y){let I={latitude:y.lat,longitude:y.lng},v=me(void 0,y.lat);return v&&(I.sphere=v),I}}return}if(X(e))return;if(Array.isArray(e)&&e.length>=2){let l=xe(e[0],e[1]);if(l){let p={latitude:l.lat,longitude:l.lng},y=me(void 0,l.lat);return y&&(p.sphere=y),p}return}let t=e.geo??e,r=e.config?.geo??e.config,n=ie(t?.latitude,t?.lat,e.latitude,e.lat,r?.latitude,r?.lat),o=ie(t?.longitude,t?.lng,t?.lon,t?.long,e.longitude,e.lng,e.lon,e.long,r?.longitude,r?.lng,r?.lon,r?.long),s=ie(t?.elevation,e.elevation,r?.elevation),i=ie(t?.sphere,e.sphere,r?.sphere),a=ie(t?.country,e.country,r?.country),c=ie(t?.city,e.city,r?.city),u=ie(t?.timezone,t?.tz,e.timezone,e.tz,r?.timezone,r?.tz),f={},d=jr(n),h=Yr(o);d!==void 0&&(f.latitude=d),h!==void 0&&(f.longitude=h),g(s)&&(f.elevation=Math.round(s*1e3)/1e3);let b=me(i,f.latitude);b&&(f.sphere=b),m(a)&&(f.country=a),m(c)&&(f.city=c),m(u)&&(f.timezone=u);let O=$(e.geo)?e.geo:$(e.config?.geo)?e.config.geo:void 0;if($(O))for(let l of Object.keys(O))k(l)&&!ke.includes(l)&&(f[l]=O[l]);return Object.keys(f).length>0?f:void 0},Bt=e=>{if(m(e)&&!R(e)){let t=e.trim();return t.startsWith(st)?t:`${st}:${t}`}if(e&&T(e)){let t=e.key??e.ip??e.query;if(m(t)&&!R(t))return`${st}:${t.trim()}`}return st},Te=e=>{let t=Bt(e);try{let r=Tr(t)??(typeof localStorage<"u"?localStorage.getItem(t):void 0);if(!r)return;let n=m(r)&&(r.startsWith("{")||r.startsWith("["))?JSON.parse(r):r;if(T(n)&&g(n._expires)&&Date.now()>n._expires){ct(e);return}if(m(n)&&n.includes(",")){let o=n.split(",").map(i=>parseFloat(i.trim())),s=xe(o[0],o[1]);if(s)return{latitude:s.lat,longitude:s.lng,sphere:me(void 0,s.lat)}}if(T(n)){let o=n.geolocation?.coords??n.coords??n,s=o?.latitude??o?.lat,i=o?.longitude??o?.lng??o?.lon??o?.long,a=xe(s,i);if(a){let c={latitude:a.lat,longitude:a.lng},u=n.elevation??o.elevation;return g(u)&&(c.elevation=Math.round(u*1e3)/1e3),c.sphere=me(n.sphere,a.lat),m(n.country)&&(c.country=n.country),m(n.city)&&(c.city=n.city),m(n.timezone)&&(c.timezone=n.timezone),c}}}catch{}},at=(e,t=Kr,r)=>{let n=Bt(r),o=g(t)&&t>0?{...e,_expires:Date.now()+t}:e;Nt(n,o,{ttl:t})},ct=e=>{let t=Bt(e);Nt(t,void 0)},lt=async(e={})=>{if(e.refresh!==!0){let a=Te(e);if(a&&g(a.latitude)&&g(a.longitude)){let{latitude:c,longitude:u,...f}=a;return{...f,status:"cached",lat:c,lng:u,latitude:c,longitude:u}}}let{type:r}=ye(),n;switch(r){case x.Browser:{let{geoLocation:a}=await Promise.resolve().then(()=>(Ft(),Fr)),c=await a(e);if(c.error)return{error:c.error};let u=c.coords?.latitude,f=c.coords?.longitude;n={...c,lat:u,lng:f,latitude:u,longitude:f};break}case x.WebWorker:case x.NodeJS:case x.Deno:default:{let{serverGeoLocation:a}=await Promise.resolve().then(()=>(Jt(),Zr));n=await a(e);break}}let o=n.latitude??n.lat,s=n.longitude??n.lng,i=xe(o,s);if(_(n.error)&&i){let a=me(n.sphere,i.lat);n.lat=i.lat,n.lng=i.lng,n.latitude=i.lat,n.longitude=i.lng,n.sphere=a;let c={latitude:i.lat,longitude:i.lng,sphere:a,...m(n.city)?{city:n.city}:{},...m(n.country)?{country:n.country}:{},...g(n.elevation)?{elevation:Math.round(n.elevation*1e3)/1e3}:{},...m(n.timezone)?{timezone:n.timezone}:{}};try{let u=g(e.ttl)?e.ttl:Kr;at(c,u,e)}catch{}}return n},Ue=async(e,t={})=>{let r=ae(e);if(r&&g(r.latitude)&&g(r.longitude))return{...r,lat:r.latitude,lng:r.longitude};let n=t.refresh===!0?void 0:Te(t);if(n&&g(n.latitude)&&g(n.longitude))return{...n,lat:n.latitude,lng:n.longitude};let o=await lt(t),s=xe(o.lat,o.lng);if(_(o.error)&&s){let i=me(o.sphere,s.lat);return{...o,lat:s.lat,lng:s.lng,latitude:s.lat,longitude:s.lng,sphere:i}}return null};function ut(e,t,r="km"){let n=ae(e),o=ae(t);if(!n||!o||!g(n.latitude)||!g(n.longitude)||!g(o.latitude)||!g(o.longitude))return NaN;let s=Math.PI/180,i=n.latitude*s,a=n.longitude*s,c=o.latitude*s,u=o.longitude*s,f=c-i,d=u-a,h=Math.sin(f/2)**2+Math.cos(i)*Math.cos(c)*Math.sin(d/2)**2,b=2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),O;r==="miles"?O=3958.7613:r==="m"?O=63710088e-1:O=6371.0088;let l=O*b;return r==="m"?Math.round(l):Math.round(l*1e3)/1e3}var ro=(e,t)=>{try{if(typeof Temporal<"u"&&typeof Temporal.Instant?.fromEpochMilliseconds=="function")return Temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(e).offsetNanoseconds/6e10;let n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset",year:"numeric"}).formatToParts(new Date(t)).find(o=>o.type==="timeZoneName")?.value;if(n){if(n==="GMT"||n==="UTC")return 0;let o=n.match(/GMT([+-])(\d{2}):(\d{2})/);if(o)return(o[1]==="-"?-1:1)*(parseInt(o[2],10)*60+parseInt(o[3],10))}}catch{}};function ft(e,t){let r=ae(e);if(!r||!g(r.latitude)||!g(r.longitude)||isNaN(r.latitude)||isNaN(r.longitude))return NaN;let n=r.longitude,o=t?.timeZone??($(e)?e.timezone??e.tz:void 0)??r.timezone,s=t?.date??($(e)&&g(e.epoch?.ms)?e.epoch.ms:Date.now()),i=typeof s=="number"?s:m(s)?Date.parse(s):Ee(s)?s.getTime():$(s)&&g(s?.epoch?.ms)?s.epoch.ms:Date.now();if(!Number.isFinite(i))return NaN;let a=Qt(o)?ro(o,i):void 0,c=a!==void 0?a/60*15:Math.round(n/15)*15,f=(n-c)*4;if(t?.apparent){let l=new Date(i),p=Date.UTC(l.getUTCFullYear(),0,1),y=Math.floor((i-p)/864e5)+1,I=2*Math.PI/365*(y-1),v=229.18*(75e-6+.001868*Math.cos(I)-.032077*Math.sin(I)-.014615*Math.cos(2*I)-.040849*Math.sin(2*I));f+=v}let d=t?.unit??"minutes",h;d==="seconds"?h=f*60:d==="hours"?h=f/60:h=f;let b=t?.precision??2,O=Math.pow(10,b);return Math.round(h*O)/O}Jt();Ft();P();var Zt=dt({name:"geo",install(e,t){let r=e||this,n=(o,s)=>{let i=r.config?.pluginOptions?.geo,a=s?.config?.pluginOptions?.geo;return{...T(t)?t:{},...T(i)?i:{},...T(a)?a:{},...T(o)?o:{}}};Object.hasOwn(r,"geo")||Object.defineProperty(r,"geo",{value:(0,U.deepFreeze)({lookup:s=>lt(n(s)),resolve:(s,i)=>Ue(s,n(i,s)),coerce:ae,distance:ut,solarOffset:ft,stash:at,clear:ct,get:Te,server:We,browser:Ge,get current(){return Te()??r.config?.geo}}),writable:!1,configurable:!1,enumerable:!1}),e.prototype.geoLocate=async function(o){let s=n(o,this),i=s?.setTimezone!==!1,a=await Ue(this,s);if(a){let c=T(this.config.geo)?this.config.geo:{},u={};for(let l of Object.keys(c))k(l)&&!ke.includes(l)&&(u[l]=c[l]);let f=ae(o)??{};if(T(o))for(let l of Object.keys(o))k(l)&&!["setTimezone","refresh","ttl","endpoint","timeout","catch","debug","geo"].includes(l)&&(ke.includes(l)||(u[l]=o[l]));let d=g(a?.elevation)?a.elevation:g(c.elevation)?c.elevation:void 0,h={...u,...a,...g(d)?{elevation:d}:{},...f};g(h.latitude)&&(h.latitude=Math.round(h.latitude*1e3)/1e3),g(h.longitude)&&(h.longitude=Math.round(h.longitude*1e3)/1e3),!h.sphere&&g(h.latitude)&&(h.sphere=h.latitude>.001?"north":h.latitude<-.001?"south":"equator");let b=this,O=h.timezone;return i&&m(O)&&!R(O)&&(b=this.set({timeZone:O})),new e(b,{...b.config,geo:(0,U.deepFreeze)(h),...h.sphere?{sphere:h.sphere}:{}})}return this},e.prototype.geoLookup=async function(o){return Ue(this,n(o,this))},e.prototype.geoDistance=function(o,s){return ut(this,o,s)},e.prototype.geoSolarOffset=function(o){return ft(this,o)}}}),no=Zt,oo=Zt;return tn(io);})();
|