@magmacomputing/tempo-plugin-geo 1.2.0 → 1.4.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 CHANGED
@@ -5,6 +5,44 @@ 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.4.0] - 2026-09-27
9
+
10
+ ### Added
11
+ - **Reverse Geocoding & Spatial Deduplication (`Tempo.geo.reverse`)**:
12
+ - Reverse geocodes coordinates to address/locality metadata with source-partitioned 2-decimal spatial `BoundedCache` (~1.1 km resolution, 24h TTL) and `{ refresh: true }` cache bypass.
13
+ - Opt-in reverse geocoding during `.geoLocate()` via `t.geoLocate({ reverse: true })` when coordinates exist without locality metadata.
14
+ - **Dependency on `@magmacomputing/tempo-fns`**:
15
+ - Imported pure `resolveCulturalLocale` and `type LocaleSyncMode` from `@magmacomputing/tempo-fns`.
16
+
17
+ ### Changed (Clean Break)
18
+ - **Extracted GIS Math & Navigation to `@magmacomputing/tempo-plugin-spatial`**:
19
+ - Removed GIS calculations (`haversineDistance`, `calculateBearing`, `calculateMidpoint`, `calculateVelocity`, `isImpossibleTravel`, `isWithin`, `inBoundingBox`, `solarOffset`) and instance methods (`geoDistance`, `geoSolarOffset`) from `tempo-plugin-geo` to keep the core lean and focused solely on coordinate resolution, hardware/IP detection, and geocoding.
20
+ - GIS navigation and spatial geometry are now available via the dedicated `@magmacomputing/tempo-plugin-spatial` plugin under the immutable `Tempo.spatial` namespace.
21
+
22
+ ## [1.3.0] - 2026-09-25
23
+
24
+ ### Added
25
+ - **Pluggable Geocoding Provider Gateway (`GeoProvider`)**:
26
+ - `GeoProvider` interface: Standardized adapter interface for custom geocoding and geolocation providers (`lookup`, `reverseGeocode`, `forwardGeocode`).
27
+ - `Tempo.geo.setProvider(provider)` & `Tempo.geo.getProvider()`: Global registration of custom geolocation providers on the static namespace.
28
+ - `Tempo.geo.reverse(coords, options?)`: Reverse geocodes coordinates to address/locality metadata.
29
+ - `Tempo.geo.forward(query, options?)`: Forward geocodes place query strings to resolved coordinates.
30
+ - Call-site provider override: `t.geoLocate({ provider })` to dynamically override provider per operation.
31
+ - Automatic 24-hour BoundedCache integration and graceful failover to default environment lookup.
32
+ - **Navigation & Transit Analytics (`Tempo.geo` Static Namespace)**:
33
+ - `Tempo.geo.velocity(from, to, options?)`: Calculates travel speed between two timestamped geographic instances or coordinate objects in `km/h`, `mph`, or `m/s`.
34
+ - `Tempo.geo.isImpossibleTravel(from, to, options?)`: Evaluates physical travel feasibility against commercial aviation thresholds (default: 900 km/h) for cybersecurity anomaly detection and impossible travel prevention.
35
+ - `Tempo.geo.bearing(from, to, options?)`: Computes Great-Circle forward azimuth compass bearing in degrees (0° to 360°).
36
+ - `Tempo.geo.midpoint(from, to)`: Computes Great-Circle geographic midpoint with automatic hemisphere inference (`{ latitude, longitude, sphere }`).
37
+ - **Spatial Boundaries & Geofencing (`Tempo.geo` Static Namespace)**:
38
+ - `Tempo.geo.isWithin(from, to, maxDistance, unit?)`: Radial proximity query evaluating whether coordinates are within a specified distance (`'km'`, `'miles'`, `'m'`).
39
+ - `Tempo.geo.inBoundingBox(coords, bbox)`: Spatial containment test evaluating if coordinates fall within rectangular bounding box, including antimeridian crossing (180° longitude wrap).
40
+ - **Automated Cultural Sync (`t.geoLocate({ setLocale })`)**:
41
+ - `LocaleSyncMode`: Synchronizes BCP 47 locale during `.geoLocate()` with default regional adaptation (`true` / `'regional'`), preserving source language while adapting the cultural calendar (e.g. `en-US` ➜ `en-SA` for Saturday-start weeks and Friday/Saturday weekends).
42
+ - Supports `'native'` (e.g. `ar-SA`), custom BCP 47 tags (`'es-SA'`, `'fr-CH'`), and opt-out (`false` / `'none'`).
43
+ - **Exported Standalone Functional Utilities**:
44
+ - Direct named exports: `calculateBearing`, `calculateMidpoint`, `calculateVelocity`, `isImpossibleTravel`, `isWithin`, `inBoundingBox`, `resolveCulturalLocale`, and types `BearingOptions`, `VelocityOptions`, `ImpossibleTravelOptions`, `BoundingBox`, `LocaleSyncMode`, `TimeUnit`.
45
+
8
46
  ## [1.2.0] - 2026-09-18
9
47
 
10
48
  ### Added
package/README.md CHANGED
@@ -6,9 +6,9 @@
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) ecosystem that provides IP geolocation lookup, browser hardware location services, coordinate normalization, and 24-hour cached coordinate stashing.
9
+ A Community plugin for the [Tempo](https://github.com/magmacomputing/magma) ecosystem that provides IP geolocation lookup, browser hardware location services, forward & reverse geocoding gateway with pluggable providers, cultural locale synchronization, and 24-hour multi-tenant coordinate caching.
10
10
 
11
- By keeping geolocation logic in this plugin, core `@magmacomputing/tempo` remains zero-network and purely deterministic.
11
+ For geometric GIS math, Great-Circle navigation, and impossible travel anomaly detection, see [`@magmacomputing/tempo-plugin-spatial`](https://www.npmjs.com/package/@magmacomputing/tempo-plugin-spatial).
12
12
 
13
13
  👉 **[View the full documentation on our GitHub Pages](https://magmacomputing.github.io/magma/doc/9-plugins/geo.index.html)**
14
14
 
@@ -30,7 +30,7 @@ Installing `GeoPlugin` mounts an immutable, locked-down **`Tempo.geo`** namespac
30
30
 
31
31
  ```typescript
32
32
  import { Tempo } from '@magmacomputing/tempo';
33
- import { GeoPlugin } from '@magmacomputing/tempo-plugin-geo';
33
+ import { GeoPlugin, OpenStreetMapProvider } from '@magmacomputing/tempo-plugin-geo';
34
34
 
35
35
  Tempo.use(GeoPlugin);
36
36
 
@@ -38,18 +38,27 @@ Tempo.use(GeoPlugin);
38
38
  const lookupResult = await Tempo.geo.lookup();
39
39
  console.log(lookupResult.lat, lookupResult.lng, lookupResult.city);
40
40
 
41
- // 2. Inspect Current Ambient / Global Coordinates
41
+ // 2. Reverse Geocoding with Provider Gateway
42
+ Tempo.geo.setProvider(new OpenStreetMapProvider());
43
+ const address = await Tempo.geo.reverse({ lat: -33.8688, lng: 151.2093 });
44
+ console.log(address.city, address.country);
45
+
46
+ // 3. Inspect Current Ambient / Global Coordinates
42
47
  console.log(Tempo.geo.current); // { latitude: ..., longitude: ..., city: ... }
43
48
 
44
- // 3. Force Fresh Network Lookup (bypassing 24h cache)
49
+ // 4. Force Fresh Network Lookup (bypassing 24h cache)
45
50
  const fresh = await Tempo.geo.lookup({ refresh: true });
46
51
 
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);
52
+ // 5. Enrich a Tempo Instance Asynchronously with Cultural Sync
53
+ const t = new Tempo('2026-06-21T12:00:00Z', {
54
+ geo: { lat: 30.0444, lng: 31.2357, country: 'EG' } // Cairo
55
+ });
56
+ const localTime = await t.geoLocate({ setLocale: 'native' });
57
+ console.log(localTime.locale); // 'ar-EG'
51
58
  ```
52
59
 
60
+ > ⚡ **[Try this live in the interactive Tempo Sandbox ↗](https://magmacomputing.github.io/magma/repl/index.html?plugin=geo)**
61
+
53
62
  ### 2. Functional Tree-Shakeable APIs
54
63
 
55
64
  All underlying utilities can be imported as standalone tree-shakeable functions without augmenting `Tempo`:
@@ -58,6 +67,9 @@ All underlying utilities can be imported as standalone tree-shakeable functions
58
67
  import { Tempo } from '@magmacomputing/tempo';
59
68
  import {
60
69
  geoLookup,
70
+ reverseGeocode,
71
+ forwardGeocode,
72
+ resolveCulturalLocale,
61
73
  resolveGeoCoordinates,
62
74
  stashGeo,
63
75
  clearStashedGeo,
@@ -76,6 +88,10 @@ const t = new Tempo('2026-06-21', { geo: coords });
76
88
  | Method / Property | Description |
77
89
  | :--- | :--- |
78
90
  | `Tempo.geo.lookup(opts?)` | Universal geolocation lookup (browser hardware GPS or server IP lookup) cached for 24h. Supports `{ refresh: true }`. |
91
+ | `Tempo.geo.reverse(coords, opts?)` | Reverse geocodes coordinates to place/locality metadata using the active provider. |
92
+ | `Tempo.geo.forward(query, opts?)` | Forward geocodes query string to coordinates using the active provider. |
93
+ | `Tempo.geo.setProvider(provider)` | Sets the active custom geocoding provider (e.g. OpenStreetMap, Mapbox, internal IP proxy). |
94
+ | `Tempo.geo.getProvider()` | Retrieves the active custom geocoding provider. |
79
95
  | `Tempo.geo.resolve(input, opts?)` | Asynchronously resolves coordinates from an instance, configuration, or ambient storage cache. |
80
96
  | `Tempo.geo.coerce(input)` | Pure function normalizing various coordinate formats (`lat/lng`, `latitude/longitude`, etc.) into a canonical `GeoConfig`. |
81
97
  | `Tempo.geo.stash(coords, ttl?, keyOrOpts?)` | Stashes coordinates in storage with an optional custom TTL (default: 24h) and multi-tenant partitioning. |
@@ -89,62 +105,12 @@ const t = new Tempo('2026-06-21', { geo: coords });
89
105
 
90
106
  ## ⚠️ Critical Operational Warnings
91
107
 
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
110
-
111
108
  > [!CAUTION]
112
- > **Unpartitioned ambient storage is shared. In multi-tenant environments, always use unique keys or instance-level options.**
113
-
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.
109
+ > **Server Environments (Node.js, Deno, Bun, Workers)**:
110
+ > In server environments without hardware GPS, calling `Tempo.geo.lookup()` falls back to server outbound public IP geolocation. When executing in multi-user request pipelines, do **not** use the default singleton ambient cache if requests come from multiple distinct users. Instead, pass explicit coordinate payloads (`new Tempo({ geo: userGeo })`) or use tenant keys with `stashGeo(coords, ttl, tenantKey)`.
134
111
 
135
112
  ---
136
113
 
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
- ---
146
-
147
- ## Licensing
114
+ ## License
148
115
 
149
116
  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,29 +1,38 @@
1
1
  import { type TempoPlugin } from '@magmacomputing/tempo/plugin/sdk';
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';
2
+ import { geoLookup, resolveGeoCoordinates, coerceGeo, getStashedGeo, stashGeo, clearStashedGeo, setGeoProvider, getGeoProvider, reverseGeocode, forwardGeocode, GEO_PROPERTIES, type GeoLookupResult, type ResolvedCoordinates, type GeoConfig, type CoordinateInput, type GeoProvider } from '@magmacomputing/library/runtime/mapper.library.js';
3
+ import { resolveCulturalLocale, type LocaleSyncMode } from '@magmacomputing/tempo-fns';
3
4
  import { serverGeoLocation, serverGeoCoords, serverMapHemisphere, type ServerMapOpts, type ServerGeolocationResult } from '@magmacomputing/library/server/mapper.library.js';
4
5
  import { geoLocation } from '@magmacomputing/library/browser/mapper.library.js';
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, };
6
+ /**
7
+ * Control and execution options filtered out when preserving caller-defined custom metadata.
8
+ */
9
+ export declare const NON_GEO_CONTROL_KEYS: readonly ["setTimezone", "setLocale", "refresh", "ttl", "endpoint", "timeout", "maxBytes", "highAccuracy", "catch", "debug", "geo", "provider", "fallback", "reverse", "autoReverse"];
10
+ export { geoLookup, resolveGeoCoordinates, coerceGeo, getStashedGeo, stashGeo, clearStashedGeo, setGeoProvider, getGeoProvider, reverseGeocode, forwardGeocode, GEO_PROPERTIES, resolveCulturalLocale, serverGeoLocation, serverGeoCoords, serverMapHemisphere, geoLocation, };
11
+ export type { GeoLookupResult, ResolvedCoordinates, GeoConfig, CoordinateInput, GeoProvider, LocaleSyncMode, ServerMapOpts, ServerGeolocationResult, };
7
12
  /**
8
13
  * Cohesive static namespace for geolocation operations on Tempo.
9
14
  */
10
15
  export interface TempoGeoNamespace {
11
- /** Asynchronous universal geolocation lookup (browser hardware or server IP) with 24h caching */
16
+ /** Asynchronous universal geolocation lookup (browser hardware, server IP, or custom provider) with 24h caching */
12
17
  readonly lookup: typeof geoLookup;
13
18
  /** Asynchronously resolves coordinates from an instance, config, or ambient storage */
14
19
  readonly resolve: typeof resolveGeoCoordinates;
15
20
  /** Coerces coordinates and configurations into a canonical GeoConfig object */
16
21
  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
22
  /** Explicitly stashes coordinates into storage with optional TTL (default 24h) and multi-tenant partitioning */
22
23
  readonly stash: typeof stashGeo;
23
24
  /** Clears stashed coordinates from storage */
24
25
  readonly clear: typeof clearStashedGeo;
25
26
  /** Retrieves stashed coordinates from storage */
26
27
  readonly get: typeof getStashedGeo;
28
+ /** Sets the active custom geolocation provider gateway */
29
+ readonly setProvider: typeof setGeoProvider;
30
+ /** Gets the currently registered custom geolocation provider */
31
+ readonly getProvider: typeof getGeoProvider;
32
+ /** Reverse geocodes coordinates to address or location metadata using the active provider */
33
+ readonly reverse: typeof reverseGeocode;
34
+ /** Forward geocodes an address or place query string into coordinates using the active provider */
35
+ readonly forward: typeof forwardGeocode;
27
36
  /** Low-level server-side IP geolocation handler */
28
37
  readonly server: typeof serverGeoLocation;
29
38
  /** Low-level browser geolocation API handler */
@@ -37,6 +46,7 @@ export interface TempoGeoNamespace {
37
46
  export type GeoPluginOptions = Partial<GeoConfig> & {
38
47
  timeout?: number;
39
48
  highAccuracy?: boolean;
49
+ provider?: GeoProvider;
40
50
  [key: string]: any;
41
51
  };
42
52
  /**
@@ -55,14 +65,6 @@ declare module '@magmacomputing/tempo' {
55
65
  * Resolves coordinates for this instance via explicit coordinates or automatic IP/hardware lookup.
56
66
  */
57
67
  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;
66
68
  }
67
69
  namespace Tempo {
68
70
  let geo: TempoGeoNamespace;
@@ -1 +1 @@
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.2.0"}),rn=e=>(0,Ze.defineTerm)({...e,version:"1.2.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);})();
1
+ "use strict";var Magma;((Magma||={}).plugins||={}).geo=(()=>{var dn=Object.create;var He=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames;var yn=Object.getPrototypeOf,hn=Object.prototype.hasOwnProperty;var v=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var cr=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},he=(e,t)=>{for(var r in t)He(e,r,{get:t[r],enumerable:!0})},je=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gn(t))!hn.call(e,o)&&o!==r&&He(e,o,{get:()=>t[o],enumerable:!(n=mn(t,o))||n.enumerable});return e},ve=(e,t,r)=>(je(e,t,"default"),r&&je(r,t,"default")),yt=(e,t,r)=>(r=e!=null?dn(yn(e)):{},je(t||!e||!e.__esModule?He(r,"default",{value:e,enumerable:!0}):r,e)),wn=e=>je(He({},"__esModule",{value:!0}),e);var ht=cr((Io,lr)=>{"use strict";lr.exports=window.Magma.pluginSdk});var Sn,xn,Tn,En,On,_n,vn,Pn,ur,Nn,fr,b,H=v(()=>{"use strict";Sn=Symbol.for("$LibraryTarget"),xn=Symbol.for("$LibraryDiscover"),Tn=Symbol.for("$LibraryExtensible"),En=Symbol.for("nodejs.util.inspect.custom"),On=Symbol.for("$LibraryLogConfig"),_n=Symbol.for("$LibraryRegistry"),vn=Symbol.for("$LibraryRegister"),Pn=Symbol.for("$LibrarySerializerRegistry"),ur=Symbol.for("$LibraryMutable"),Nn=Symbol.for("$LibraryIdentity"),fr=Symbol.for("$LibraryUnwrapped"),b={$Target:Sn,$Discover:xn,$Extensible:Tn,$Inspect:En,$LogConfig:On,$Registry:_n,$Register:vn,$SerializerRegistry:Pn,$Identity:Nn,$Mutable:ur,$Unwrapped:fr}});function we(e){let t=e,r=0,n=50;for(;t;){let o=t[b.$Target];if(!o||r>=n)break;t=o,r++}return t}function C(e,t=!1){if(!e||typeof e!="object")return[];let r=we(e);if(!t){let l=Reflect.ownKeys(r),m=[];for(let f of l){let h=Object.getOwnPropertyDescriptor(r,f);h&&h.enumerable&&m.push([f,r[f]])}return m}let n=[],o=50,s=0,i=r;for(;i&&i!==Object.prototype&&s++<o;)n.push(we(i)),i=Object.getPrototypeOf(i);let a=[],c=new Set;for(let l of n.reverse()){let m=Reflect.ownKeys(l);for(let f of m){if(c.has(f))continue;let h=Object.getOwnPropertyDescriptor(l,f);!h||!h.enumerable||(c.add(f),a.push([f,r[f]]))}}return a}function qe(e,t=!1){return C(e,t).map(([r])=>r)}function pr(e,t=!1){return C(e,t).map(([r,n])=>n)}function Ve(e,t,r){return t?Ve(e.map(t,r)):Array.from(new Set(e))}var Y=v(()=>{"use strict";H()});var bt,St,Xe,pe,ee,In,Rn,Qe,K=v(()=>{"use strict";H();Y();bt=[],St=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"?we(e):e;return Object.prototype.toString.call(r).slice(8,-1)}catch{return t==="function"?"Function":"Object"}},Xe=e=>{try{let t=e?.[Symbol.toStringTag]??e?.prototype?.[Symbol.toStringTag];if(typeof t=="string")return t}catch{}},pe=(e,...t)=>{let r=e;try{r=e?.[b.$Target]??e}catch{r=e}let n=St(r);switch(n){case"Function":try{return Rn(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?.[b.$Target]??s.class;if(r===i||i&&r instanceof i)return s.type}let o=globalThis[b.$Registry]??[];for(let s of[...bt,...o]){let i=s.class?.[b.$Target]??s.class;if(r===i||i&&r instanceof i)return s.type}}catch{return"Object"}return"Object"}default:return n}},ee=(e,...t)=>({type:pe(e,...t),value:e}),In=/^\s*(class\s|\[native code\])/,Rn=e=>{if(typeof e!="function")return!1;let t=e?.[b.$Target]??e;if(!("prototype"in t))return!1;let r=t?.name,n=Xe(t);if(t?.[b.$Identity]||t?.prototype?.[b.$Identity]||typeof n=="string"&&n.startsWith("Temporal."))return!0;if(typeof n=="string"&&n.endsWith("Function"))return!1;if((globalThis[b.$Registry]??[]).some(s=>(s.class?.[b.$Target]??s.class)===t||r&&s.type===r||n&&s.type===n))return!0;try{let s=Function.prototype.toString.call(t);if(In.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=Xe(e),n=t??r??e.name;n&&!["Object","Function",""].includes(n)&&(bt.some(o=>o.class===e)||bt.push({class:e,type:n}))}});function et(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:Dn.test(r)||y(Number(r))}default:return!1}}var U,te,z,dr,d,F,y,Dn,xt,mr,de,gr,S,Tt,yr,re,Et,B,P,q,x,w,$,Pe,Ne,tt,Ie,O,N=v(()=>{"use strict";H();K();U=(e,...t)=>t.includes(pe(e)),te=e=>e===null||typeof e!="object"&&typeof e!="function",z=e=>!te(e),dr=e=>Symbol.iterator in Object(e)&&!d(e),d=e=>typeof e=="string",F=e=>typeof e=="string"&&e.trim().length>0,y=e=>Number.isFinite(e),Dn=/^[+-]?[0-9]+n$/;xt=e=>typeof e=="bigint",mr=e=>typeof e=="boolean",de=e=>Array.isArray(e),gr=e=>St(e)==="Object"&&"length"in e&&Object.keys(e).every(t=>t==="length"||y(Number(t))),S=e=>U(e,"Object"),Tt=e=>U(e,"Date"),yr=e=>U(e,"RegExp"),re=e=>typeof e=="symbol",Et=e=>typeof e=="symbol"&&Symbol.keyFor(e)!==void 0,B=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype",P=e=>e==null||U(e,"Void","Empty"),q=e=>e===void 0||U(e,"Void","Empty"),x=e=>e!=null&&!P(e),w=e=>U(e,"Function","AsyncFunction","GeneratorFunction","AsyncGeneratorFunction"),$=e=>typeof e=="function",Pe=e=>U(e,"Map"),Ne=e=>U(e,"Set"),tt=(e,t)=>U(e,"Error")&&(t?e instanceof t:!0),Ie=e=>typeof Intl<"u"&&typeof Intl.Locale=="function"&&e instanceof Intl.Locale,O=e=>P(e)||S(e)&&Reflect.ownKeys(e).length===0||d(e)&&e.trim().length===0||typeof e=="number"&&Number.isNaN(e)||de(e)&&e.length===0||Ne(e)&&e.size===0||Pe(e)&&e.size===0||ArrayBuffer.isView(e)&&e.byteLength===0||Tt(e)&&Number.isNaN(e.getTime())});function Ot(e,t,r=new WeakSet){let n=t instanceof WeakSet?t:t?.skip??$n;return te(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[b.$Extensible]?e:(r.add(e),C(e).forEach(([o,s])=>{B(o)&&Ot(s,{skip:n},r)}),Object.freeze(e))}var E,be,$n,Re=v(()=>{"use strict";Y();N();H();E={Unknown:"unknown",Browser:"browser",WebWorker:"web-worker",NodeJS:"nodejs",Deno:"deno",GoogleAppsScript:"google-apps-script"},be=()=>{let e=globalThis;try{if(x(e.SpreadsheetApp))return{global:e,type:E.GoogleAppsScript};if(x(e.window?.document))return{global:e,type:E.Browser};if(w(e.importScripts)||x(e.WorkerGlobalScope)&&e instanceof e.WorkerGlobalScope)return{global:e,type:E.WebWorker};if(x(e.Deno))return{global:e,type:E.Deno};if(x(e.process?.versions?.node)&&e.process?.release?.name==="node")return{global:e,type:E.NodeJS}}catch{}return{global:e,type:E.Unknown}},$n=new WeakSet});function hr(e){return Object.fromEntries(C(e,!0))}var wr=v(()=>{"use strict";Y();K();N()});function Sr(e,t={},r=!1){let{frozen:n,lock:o,appendOnly:s,onGet:i,keys:a,bind:c,skip:l}=t,m=new Set,f,h,p=we(e);o&&Ot(p,l?{skip:l}:void 0),Qe(p);let R={isExtensible:g=>Reflect.isExtensible(g),getPrototypeOf:g=>Reflect.getPrototypeOf(g),setPrototypeOf:(g,u)=>{if(n)throw new TypeError("Security: Prototype mutation attempt on protected object");return Reflect.setPrototypeOf(g,u)},getOwnPropertyDescriptor:(g,u)=>{if(!(a&&!a.includes(u))){if(a){if(i&&!re(u)&&!m.has(u)){m.add(u);try{let T=i(u,g);if(x(T))return{enumerable:!0,configurable:!0,value:T}}finally{m.delete(u)}}return{enumerable:!0,configurable:!0}}return Reflect.getOwnPropertyDescriptor(g,u)}},ownKeys:g=>{if(a)return a;if(i&&!m.has(b.$Discover)){m.add(b.$Discover);try{i(b.$Discover,g)}finally{m.delete(b.$Discover)}}return Reflect.ownKeys(g)},has:(g,u)=>a?a.includes(u):Reflect.has(g,u),deleteProperty:(g,u)=>{if(n)throw new TypeError(`Cannot delete property '${String(u)}' from a protected object.`);if(s&&Reflect.has(g,u))throw new Error(`Security: Deletion attempt on protected key '${String(u)}'`);return Reflect.deleteProperty(g,u)},defineProperty:(g,u,T)=>{if(n&&!Object.isFrozen(g))throw new TypeError(`Cannot define property '${String(u)}' on a frozen object.`);if(s&&Reflect.has(g,u))throw new Error(`Security: Mutation attempt on protected key '${String(u)}'`);return Reflect.defineProperty(g,u,T)},set:(g,u,T,D)=>{if(n&&D===h)throw new TypeError(`Cannot set property '${String(u)}' on a frozen object.`);if(s){if(Array.isArray(g)&&u==="length"&&T<g.length)throw new Error("Security: Truncation attempt on protected array.");if(!(Array.isArray(g)&&u==="length")&&Reflect.has(g,u))throw new Error(`Security: Mutation attempt on protected key '${String(u)}'`)}return Reflect.set(g,u,T,D)},get:(g,u,T)=>{if(u===b.$Target)return T===h?g:void 0;if(n&&(u===b.$Inspect||u==="toJSON")){let _=Object.getOwnPropertyDescriptor(g,u);return _&&w(_.value)?_.value:(f||(f=()=>hr(g)),f)}if(a&&!a.includes(u))return;if(i&&!re(u)&&!Reflect.has(g,u)&&!m.has(u)){m.add(u);try{let _=i(u,g);if(x(_))return _}finally{m.delete(u)}}let D=Reflect.get(g,u,T);if(c&&u!=="constructor"&&w(D)){let _=Object.getOwnPropertyDescriptor(g,u);if(_&&!_.configurable&&!_.writable)return D;let j=br.get(D);j||(j=new WeakMap,br.set(D,j));let fe=j.get(g);if(fe)return fe;let ar=D.bind(g);return j.set(g,ar),ar}return D}};if(r){let g=Proxy.revocable(p,R);return h=g.proxy,{proxy:g.proxy,revoke:g.revoke}}return h=new Proxy(p,R),h}function xr(e,t=!0,r=t,n=new WeakSet){return Sr(e,{frozen:t,lock:r,skip:n,bind:t})}function De(e,t=new WeakSet){return Sr(e,{frozen:!0,lock:!0,skip:t,bind:!0})}var br,rt=v(()=>{"use strict";H();wr();Re();Y();N();K();br=new WeakMap});function $e(e,t=new WeakSet){return JSON.stringify(e,function(r,n){if(n===void 0)return"\0__undefined__\0";if(xt(n))return`\0__bigint:${n}__\0`;if(w(n))return`function:${n.name||"anonymous"}`;if(z(n)){if(t.has(n))return"<Circular>";if(t.add(n),Ie(n))return n.toString();if(Pe(n))return`map:[${Array.from(n.entries()).map(o=>$e(o,t)).sort().join(",")}]`;if(Ne(n))return`set:[${Array.from(n).map(o=>$e(o,t)).sort().join(",")}]`}return n})}function Er(e){return function t(...r){return r.length>=e.length?e(...r):(...n)=>t(...r,...n)}}function A(e){let t=new Map;return function(...r){let n=$e(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 Ce(e,t){return{enumerable:!1,configurable:!1,writable:!1,value:function(...r){let n=`${String(e)},${$e(r)}`,o=Tr.get(this);if(o||(o=new Map,Tr.set(this,o)),!o.has(n)){let s=t.apply(this,r);De(s),o.set(n,s)}return o.get(n)}}}var Tr,nt=v(()=>{"use strict";rt();N();Tr=new WeakMap});function Or(e){try{return JSON.parse(JSON.stringify(e))}catch(t){throw console.warn("Could not clean object:",t?.message??t),t}}var _r=v(()=>{"use strict";N()});function oe(e){return x(e)?w(e)?e():e:t=>w(t)?t():t}var An,ne,_t=v(()=>{"use strict";Y();N();K();An=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))B(s)&&(i.enumerable||w(i.get))&&t.add(s);r=Object.getPrototypeOf(r)}return Array.from(t)},ne=e=>{if(te(e)||w(e))return e;if(de(e))return e.map(r=>ne(r));if(Tt(e)||yr(e)||Pe(e)||Ne(e))return e;try{if(w(e.toJSON))return ne(e.toJSON())}catch{}let t={};for(let r of An(e))try{t[r]=ne(e[r])}catch{}return t};oe.stringSymbol=oe();oe.symbolRegExp=oe();oe.symbolString=oe();oe.stringString=oe()});function Ir(e,t){try{return globalThis.structuredClone(e,t)}catch{return Or(e)}}function Ln(e,t){return zn(t)}function Pr(e){let t=encodeURI(e);return t.includes("%")&&(t=t.replace(Mn,r=>Rr[r.toUpperCase()]??decodeURI(r))),t}function zn(e){if(d(e))try{return decodeURI(e)}catch{}return e}function Ae(e){return!U(e,"Function","AsyncFunction","WeakMap","WeakSet","WeakRef")}function Fn(e,t){return`{"$${e}":${t}}`}function Gn(e){return G(re(e)?`${Et(e)?"@":""}@(${e.description??""})`:e)}function vt(e){let[t,r,n]=e.toString().match(kn)||[null,void 0,void 0];switch(!0){case re(e):case P(t):case(x(r)&&q(n)):return e;case x(r):return Symbol.for(n);case q(r):default:return Symbol(n)}}function Z(e,t){let r=me;me=t?.compact!==!1;try{let n=G(e,!1);if(t?.signed){if(!d(t.secret)||!t.secret)throw new TypeError("stringify: signed serialization requires an explicit secret string");return`$sig:${Dr(n,t.secret)}:${n}`}return n}finally{me=r}}function G(e,t=!0){let r=ee(e),n=Er(Fn)(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 me?JSON.stringify("~u"):n(JSON.stringify("void"));case"BigInt":return me?JSON.stringify(`~n${r.value.toString()}`):n(r.value.toString());case"Date":return me?JSON.stringify(`~t${r.value.getTime()}`):n(G(r.value.toJSON()));case"Object":return`{${C(r.value).filter(([,s])=>Ae(s)).map(([s,i])=>`${Gn(s)}: ${G(i)}`).join(",")}}`;case"Array":return`[${r.value.filter(s=>Ae(s)).map(s=>G(s)).join(",")}]`;case"Map":{let o=Array.from(r.value.entries()).filter(([,s])=>Ae(s)).map(([s,i])=>`[${G(s)}, ${G(i)}]`).join(",");return n(`[${o}]`)}case"Set":{let o=Array.from(r.value.values()).filter(s=>Ae(s)).map(s=>G(s)).join(",");return n(`[${o}]`)}case"Symbol":{let o=`${Et(r.value)?"@":""}@(${r.value.description??""})`;return me?JSON.stringify(`~y${o}`):n(JSON.stringify(o))}case"RegExp":return n(G({source:r.value.source,flags:r.value.flags}));default:{let o=r.value;switch(!0){case!Ae(o):return;case w(o.toJSON):return n(G(o.toJSON()));case(w(o.toString)&&o.toString!==Object.prototype.toString):{let s=o.toString();return n(s.includes('"')?s:JSON.stringify(s))}case(w(o.valueOf)&&o.valueOf!==Object.prototype.valueOf):return n(JSON.stringify(o.valueOf()));default:{let s=ne(o);return z(s)&&Object.keys(s).length>0?G(s):n(JSON.stringify(o,(i,a)=>O(i)?a:G(a)))}}}}}function ge(e,t){if(!d(e))return e;let r=w(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(!d(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=Dr(i,r.secret);if(!Un(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,Ln)}catch(o){return e.startsWith('"')&&e.endsWith('"')?(console.warn(`objectify.parse: -> ${e}, ${o.message}`),e):ge(`"${e}"`,r.requireSigned?{...r,requireSigned:!1}:r)}switch(!0){case(e.startsWith("{")&&e.endsWith("}")):case(e.startsWith("[")&&e.endsWith("]")):return Pt(n,r,0);default:return Le(n,r)}}function Pt(e,t,r=0){let n=t.maxDepth??Bn;return r>=n?e:S(e)?Le(C(e).filter(([o])=>B(o)).reduce((o,[s,i])=>Object.assign(o,{[vt(s)]:Le(Pt(i,t,r+1),t)}),{}),t):de(e)?pr(e).map(o=>Le(Pt(o,t,r+1),t)):Le(e,t)}function Le(e,t){if(d(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(et(s)?Number(s):s);return isNaN(i.getTime())?e:i}if(e==="~u")return t.sentinel?.();if(e.startsWith("~y"))return vt(e.substring(2))}catch{return e}if(!S(e)||qe(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||!S(n)||!d(n.source)||n.source.length>Jn?e:new RegExp(n.source,n.flags);case"Symbol":return vt(n);case"Map":return de(n)?new Map(n):e;case"Set":return de(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=ot.get(r);return s?Reflect.construct(s,[n]):(console.warn(`objectify: dont know how to deserialize '${o}'`),e)}}}catch{return e}}var ot,vr,Nr,Rr,Mn,kn,Wn,Dr,Un,me,Bn,Jn,Se=v(()=>{"use strict";nt();Y();_r();_t();K();N();H();ot=globalThis[b.$SerializerRegistry]??=new Map,vr=e=>{try{let t=e?.prototype?.[Symbol.toStringTag]??e?.[Symbol.toStringTag];return d(t)?t:void 0}catch{return}},Nr=(e,t)=>{let r=e.startsWith("$")?e:`$${e}`;if(ot.has(r)){let n=ot.get(r),o=vr(n),s=vr(t),i=n.name||o,a=t.name||s||(e.startsWith("$")?e.slice(1):e);if(n===t||n.toString()===t.toString()||!!t[b.$Identity]&&n[b.$Identity]===t[b.$Identity]||!!t[b.$Target]&&n[b.$Target]===t[b.$Target]||!!i&&!!a&&i===a)return;throw new Error(`[registerSerializable] Collision: '${r}' is already registered with ${n.name||"anonymous constructor"}`)}ot.set(r,t)};Rr={"%20":" ","%22":'"',"%3B":";","%3C":"<","%3E":">","%5B":"[","%5D":"]","%5E":"^","%7B":"{","%7C":"|","%7D":"}"},Mn=new RegExp(Object.keys(Rr).join("|"),"gi");kn=/^@(@)?\(([^\)]*)\)$/;Wn=globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID().split("-")[0]:Math.random().toString(36).slice(2,10),Dr=(e,t=Wn)=>{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")},Un=(e,t)=>{if(!d(e)||!d(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},me=!0;Bn=64,Jn=512});function ie(e,t,r,n,o,s){function i(T){if(T!==void 0&&typeof T!="function")throw new TypeError("Function expected");return T}for(var a=n.kind,c=a==="getter"?"get":a==="setter"?"set":"value",l=!t&&e?n.static?e:e.prototype:null,m=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),f,h=!1,p=r.length-1;p>=0;p--){var R={};for(var g in n)R[g]=g==="access"?{}:n[g];for(var g in n.access)R.access[g]=n.access[g];R.addInitializer=function(T){if(h)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(T||null))};var u=(0,r[p])(a==="accessor"?{get:m.get,set:m.set}:m[c],R);if(a==="accessor"){if(u===void 0)continue;if(u===null||typeof u!="object")throw new TypeError("Object expected");(f=i(u.get))&&(m.get=f),(f=i(u.set))&&(m.set=f),(f=i(u.init))&&o.unshift(f)}else(f=i(u))&&(a==="field"?o.unshift(f):m[c]=f)}l&&Object.defineProperty(l,n.name,m),h=!0}function se(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 Me=v(()=>{"use strict"});function $r(e,t){return Xe(e)??(q(t)?e.name||void 0:String(t))}function Cr(e,{kind:t,name:r,addInitializer:n}){let o=$r(e,r);if(o&&Qe(e,o),t==="class")return o&&n(()=>Nr(o,e)),e;throw new Error(`@Serializable decorating unknown 'kind': ${t} (${r})`)}function ae(e,t){let r=(n,o,s)=>{let i=n.prototype,a=o??$r(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 $(e)&&t?.kind==="class"?r(e,void 0,t.name):(n,o)=>r(n,d(e)?e:void 0,o?.name)}var ze=v(()=>{"use strict";H();rt();N();Se();K()});var Fe,Nt=v(()=>{"use strict";Me();N();ze();Fe=(()=>{let e=[ae("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;ie(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}),se(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 l=this.#t.get(i);for(super.has(i)&&super.delete(i),super.set(i,a),this.#e.delete(i),x(c)?c!==1/0?(this.#t.set(i,Date.now()+c),this.#r.set(i,c)):(this.#t.delete(i),this.#r.delete(i)):l!==void 0?this.#t.set(i,l):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 m=!1,f=super.keys(),h=f.next();for(;!h.done;){let p=h.value;if(!this.#e.has(p)){this.delete(p),m=!0;break}h=f.next()}if(!m)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(O(a))return 0;let c=[];for(let l of super.keys())d(l)&&l.toLowerCase().startsWith(a)&&c.push(l);for(let l of c)this.delete(l);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())d(a)&&i.push([a,c]);return Object.fromEntries(i)}static fromEntries(i,a=1e3,c=1440*60*1e3){let l=new s(a,c);for(let[m,f]of i)l.set(m,f);return l}};return s=n})()});function Mr(e,t){let r;if(q(e))return t??{};switch(k.type){case E.Browser:r=It.getItem(e);break;case E.NodeJS:r=Ge.has(e)?Ge.get(e):Kn(e);break;case E.Deno:r=k.global.Deno.env.get(e);break;case E.GoogleAppsScript:r=k.global.PropertiesService?.getUserProperties().getProperty(e);break;case E.WebWorker:case E.Unknown:r=void 0;break;default:throw new Error(`Cannot determine Javascript context: ${k.type}`)}return d(r)?ge(r):t}function $t(e,t,r){let n=x(t)?Z(t):void 0,o=x(n);switch(k.type){case E.Browser:try{o?It.setItem(e,n):It.removeItem(e)}catch(s){console.warn(`[Storage] Failed to ${o?"setItem":"removeItem"} for key '${e}':`,s)}break;case E.NodeJS:o?r?.static?Ge.setStatic(e,n):Ge.set(e,n,r?.ttl):Ge.set(e,void 0,r?.ttl);break;case E.Deno:o?k.global.Deno.env.set(e,n):k.global.Deno.env.delete(e);break;case E.GoogleAppsScript:o?k.global.PropertiesService?.getUserProperties().setProperty(e,n):k.global.PropertiesService?.getUserProperties().deleteProperty(e);break;case E.WebWorker:case E.Unknown:break;default:throw new Error(`Cannot determine Javascript context: ${k.type}`)}}var k,Lr,Ar,Rt,Dt,It,Ge,Kn,Ct=v(()=>{"use strict";Se();Re();N();Nt();k=be(),Lr=(e=1e3,t=1/0)=>{let r=new Fe(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))}}},Ar=new Map,Rt=e=>{let t=Ar.get(e);return t||(t=Lr(),Ar.set(e,t)),t},Dt=(e="localStorage")=>{try{let t=globalThis?.[e];if(t&&$(t.getItem)&&$(t.setItem)&&$(t.removeItem)&&$(t.clear)&&$(t.key)&&y(t.length))return t}catch{}return Rt(e)},It=k.type===E.Browser?Dt():Lr(),Ge=new Fe(1e3,1/0),Kn=e=>{try{let t=Reflect.get(k.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 zr=v(()=>{"use strict";Se();N()});function Fr(e=[],t){let r=n=>q(t)||x(n)?n:Ir(t);return gr(e)||dr(e)&&!d(e)?Array.from(e,r):[e]}function Gr(e){if(tt(e))return e;let t=new Error(S(e)&&d(e.message)?e.message:String(e));return S(e)&&(t.name=d(e.name)?e.name:"Error","code"in e&&(d(e.code)||y(e.code))&&(t.code=e.code),"stack"in e&&d(e.stack)&&(t.stack=e.stack)),t}var Hi,Yi,At=v(()=>{"use strict";Se();K();N();zr();Hi=BigInt(Number.MAX_SAFE_INTEGER),Yi=BigInt(Number.MIN_SAFE_INTEGER)});var kr=v(()=>{"use strict";At();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=Gr(e);if(console.warn("Tempo: Native Temporal implementation appears incomplete. Consider loading a polyfill.",t),t.message!=="Incomplete Temporal implementation")throw t}});function Wr(){return Temporal.Now.instant()}function Ur(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 Lt=v(()=>{"use strict";kr();N()});function ke(e,t,r){if(e){if($(e[t]))return e[t]();if(r&&r in e)return e[r]}}function oo(e){return e?Vn.has(e)?5:qn.has(e)?6:Yn.has(e)?7:1:1}function io(e){return e?e==="IR"?ro:e==="AF"?no:Xn.has(e)?to:Br:Br}function so(e,t){let r=e?.script??($(e?.maximize)?e.maximize().script:void 0);return r&&eo.has(r)||t&&Qn.has(t)?"rtl":"ltr"}var Zn,jn,xe,le,ss,as,zt,cs,Hn,ls,Yn,qn,Vn,Xn,Qn,eo,Br,to,ro,no,Mt,us,fs,ao,co,Jr,ps,it,ds,Ft=v(()=>{"use strict";Lt();nt();N();At();Zn=/_/g,jn=/[.@]/,xe=e=>typeof Intl<"u"&&(!e||Object.hasOwn(Intl,e)&&$(Intl[e])),le=e=>{if(Ie(e)&&(e=e.toString()),!d(e))return;let t=e.trim();if(O(t))return;let r=t.split(jn)[0];if(!O(r))return r.replace(Zn,"-")},ss=A((e,t)=>new Intl.RelativeTimeFormat(le(e),t)),as=A((e,t)=>new Intl.ListFormat(le(e),t)),zt=A((e,t)=>new Intl.DateTimeFormat(le(e),t)),cs=A((e,t)=>{try{return new Intl.PluralRules(le(e),t)}catch{return{select:()=>"other"}}}),Hn=A((e,t)=>new Intl.NumberFormat(le(e),t)),ls=A((e,t)=>{try{let r=new Intl.DurationFormat(le(e),t);if(w(r.format))return r;throw new Error("No format method")}catch{return{format:n=>String(n)}}});Yn=new Set(["US","CA","MX","BR","IL","JP","TW","HK","MO","PH","SG","TH","IN","KR","CO","PE","VE","ZA"]),qn=new Set(["SA","AF","BH","DJ","DZ","EG","IQ","IR","JO","KW","LY","OM","QA","SD","SY","YE"]),Vn=new Set(["MV"]),Xn=new Set(["SA","BH","DJ","DZ","EG","IQ","JO","KW","LY","OM","QA","SD","SY","YE"]),Qn=new Set(["ar","he","fa","ur","yi","ps","sd","ug","ckb"]),eo=new Set(["Arab","Hebr","Thaa","Syrc","Mand","Samr","Nkoo"]),Br=Object.freeze([6,7]),to=Object.freeze([5,6]),ro=Object.freeze([5]),no=Object.freeze([4,5]);Mt=A(e=>{if(Ie(e))return e;if(xe("Locale"))try{let t=le(e);return new Intl.Locale(t||"en-US")}catch{return}}),us=A(e=>{let t=Mt(e)??Mt("en-US"),r=t?.baseName??Jr(e)??"en-US",n=t?.language??r.split("-")[0]?.toLowerCase(),o=[];for(let fe of r.split("-").slice(1)){if(fe.length===1)break;o.push(fe)}let s=t?.region??($(t?.maximize)?t.maximize().region:void 0)??o.find(fe=>/^[a-zA-Z]{2}$|^\d{3}$/.test(fe))?.toUpperCase(),i=t?.script??($(t?.maximize)?t.maximize().script:void 0),a=ke(t,"getWeekInfo","weekInfo"),c=a?.firstDay??oo(s),l=Array.isArray(a?.weekend)?Object.freeze([...a.weekend]):io(s),f=ke(t,"getHourCycles","hourCycles")??t?.hourCycle??(xe("DateTimeFormat")?zt(r,{hour:"numeric"}).resolvedOptions().hourCycle:void 0),h=Array.isArray(f)&&f.length>0?Object.freeze([...f]):d(f)?Object.freeze([f]):Object.freeze(["h23"]),p=ke(t,"getTextInfo","textInfo"),R=p?.direction==="rtl"||p?.direction==="ltr"?p.direction:so(t,n),u=ke(t,"getNumberingSystems","numberingSystems")??t?.numberingSystem??(xe("NumberFormat")?Hn(r).resolvedOptions().numberingSystem:void 0),T=Array.isArray(u)&&u.length>0?Object.freeze([...u]):d(u)?Object.freeze([u]):Object.freeze(["latn"]),D=ke(t,"getTimeZones","timeZones"),_=Array.isArray(D)&&D.length>0?Object.freeze([...D]):Object.freeze([]),j=Object.freeze({firstDay:c,weekend:l});return Object.freeze({locale:t,baseName:r,language:n,region:s,script:i,weekInfo:j,firstDay:c,weekend:l,hourCycle:h[0],hourCycles:h,direction:R,numberingSystem:T[0],numberingSystems:T,timeZones:_})}),fs=A((e="latn")=>{if(!(!e||e==="latn"||!xe("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}}),ao=Object.freeze({locale:"en-US",calendar:"iso8601",numberingSystem:"latn",timeZone:"UTC"}),co=A(()=>xe("DateTimeFormat")?Object.freeze(zt().resolvedOptions()):ao),Jr=A(e=>{let t=le(e);if(t){if(xe("getCanonicalLocales"))try{return Intl.getCanonicalLocales(t)[0]}catch{return}return Mt(t)?.baseName??t}}),ps=A(e=>Object.freeze(Fr(e).map(t=>Jr(t)).filter(Boolean))),it=A((e=co().timeZone)=>{try{let{jan:t,jul:r}=Ur(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}}),ds=A(e=>{try{let t=new Date(2024,11,24),r=zt(e).formatToParts(t);return r[0].type==="month"&&r[0].value==="12"}catch{return!1}})});function V(e){return{enumerable:!1,configurable:!1,writable:!1,value:e}}function Te(e,t=!0){let n=pe(this)!=="Module"&&w(this?.has)?this:uo,o=ee(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(y(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 xr(s,!0,t)}var lo,uo,Ts,Kr=v(()=>{"use strict";Me();K();N();Y();rt();ze();nt();lo="Enumify",uo=De(Object.create(null,{keys:Ce("keys",function(){return C(this,!0).map(([e])=>e)}),values:Ce("values",function(){return C(this,!0).map(([e,t])=>t)}),entries:Ce("entries",function(){return C(this,!0).map(([e,t])=>Object.freeze([e,t]))}),invert:Ce("invert",function(){return Object.fromEntries(this.entries().map(([e,t])=>[t,e]))}),has:V(function(e){return this.keys().includes(e)}),count:V(function(){return this.keys().length}),includes:V(function(e){return this.values().includes(e)}),keyOf:V(function(e){return this.invert()[e]}),extend:V(function(e,t){return Te.call(this,e,t)}),forEach:V(function(e,t){this.entries().forEach((r,n)=>e.call(t,r,n,this))}),filter:V(function(e,t){return Te(this.entries().reduce((r,n,o)=>e.call(t,n,o,this)?Object.assign(r,{[n[0]]:n[1]}):r,{}))}),map:V(function(e,t){return Te(this.entries().reduce((r,n,o)=>Object.assign(r,{[n[0]]:e.call(t,n,o,this)}),{}))}),[Symbol.iterator]:V(function*(){for(let e of this.entries())yield e}),[Symbol.toStringTag]:{enumerable:!1,configurable:!1,writable:!1,value:lo}}));Ts=(()=>{let e=[Cr,ae("Enumify")],t,r=[],n;var o=class{static{n=this}static{let s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ie(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}),se(n,r)}constructor(s){return Te(s)}};return o=n})()});function fo(e,t=W.Info){return y(e)?e>=W.Off&&e<=W.Trace?e:t:d(e)?Zr[e.toLowerCase()]??t:t}var W,M,Zr,st,Gt=v(()=>{"use strict";Me();N();Kr();H();ze();W=Te(["Off","Error","Warn","Info","Debug","Trace"]),M={Off:"off",Log:"log",Info:"info",Warn:"warn",Debug:"debug",Trace:"trace",Error:"error"},Zr={[M.Off]:W.Off,[M.Error]:W.Error,[M.Warn]:W.Warn,[M.Info]:W.Info,[M.Log]:W.Info,[M.Debug]:W.Debug,[M.Trace]:W.Trace};st=(()=>{let e=[ae("Logger")],t,r=[],n;var o=class{static{n=this}static{let s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ie(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}),se(n,r)}#t;level;constructor(s,i=W.Info){this.#t=s.startsWith("[")?s:`[${s}]`,this.level=i}#e(s,...i){let a;if(i.length>0&&S(i[0]))try{i[0][b.$LogConfig]&&(a=i.shift())}catch{}let c=this.level;if(a){if(a.silent===!0)return;a.debug!==void 0&&(c=fo(a.debug,c))}if(c===W.Off||(Zr[s]??0)>c)return;let m=i.map(f=>{if(tt(f))return f.message;if(S(f))try{let h=f.constructor?.name??"Object";if(h==="Object"){let p=Object.keys(f);return`{ ${p.slice(0,3).join(", ")}${p.length>3?`, ... (+${p.length-3} more)`:""} }`}return`[${h}]`}catch{return"[Object]"}return String(f)}).filter(f=>!O(f)).join(" ");O(m)||console[s](`${this.#t} ${m}`)}log=(...s)=>this.#e(M.Log,...s);info=(...s)=>this.#e(M.Info,...s);warn=(...s)=>this.#e(M.Warn,...s);debug=(...s)=>this.#e(M.Debug,...s);trace=(...s)=>this.#e(M.Trace,...s);error=(...s)=>this.#e(M.Error,...s)};return o=n})()});var jr={};he(jr,{WebStore:()=>po});var We,po,Hr=v(()=>{"use strict";Me();Y();Se();K();N();Ct();ze();We={Local:"local",Session:"session"},po=(()=>{let e=[ae("WebStore")],t,r=[],n;var o=class{static{n=this}static{let s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;ie(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}),se(n,r)}static _localInstance;static _sessionInstance;static get local(){return o._localInstance??=new o(We.Local)}static get session(){return o._sessionInstance??=new o(We.Session)}#t;#e;get#r(){if(this.#e)return this.#e;let s=this.#t===We.Local?"localStorage":"sessionStorage";return this.#e=Dt(s)}#n(s){try{return s(this.#r)}catch{let a=this.#t===We.Local?"localStorage":"sessionStorage",c=Rt(a);return this.#e=c,s(c)}}constructor(s=We.Local){this.#t=s}get(s,i){let a=this.#n(c=>c.getItem(Z(s)));return d(a)?ge(a):i??null}set(s,i,a={merge:!0}){if(P(s))return this.clear();let c=this.get(s),l=ee(i);switch(l.type){case"Undefined":return this.del(s);case"Object":return c??={},this.#o(s,a.merge?Object.assign(c,l.value):l.value);case"Array":return c??=[],this.#o(s,a.merge?Ve(c.concat(l.value)):i);case"Map":return c??=new Map,a.merge?(l.value.forEach((m,f)=>c.set(f,m)),this.#o(s,c)):this.#o(s,l.value);case"Set":return c??=new Set,a.merge?(l.value.forEach(m=>c.add(m)),this.#o(s,c)):this.#o(s,l.value);default:return this.#o(s,l.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(Z(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=>Z(c))),a=[];return this.#n(c=>{for(let l=0;l<c.length;l++){let m=c.key(l);if(m!==null&&(O(s)||i.has(m))){let f=c.getItem(m);a.push([ge(m),ge(f)])}}}),a}from(s){return C(s).forEach(([i,a])=>this.set(i,a)),this}#o(s,i){try{this.#n(a=>a.setItem(Z(s),Z(i)))}catch(a){console.warn(`[WebStore] Failed to setItem for key '${String(s)}':`,a)}return this}};return o=n})()});var Vr={};he(Vr,{geoCoords:()=>qr,geoLocation:()=>Ue,mapAddress:()=>go,mapHemisphere:()=>mo,mapQuery:()=>Ut});var ct,Yr,I,Wt,X,kt,at,Ue,qr,Ut,mo,go,Bt=v(()=>{"use strict";_t();Re();N();Lt();Ft();Gt();ct={catch:!0,debug:0},Yr=be(),I={},Wt="_magma_browser_map_",X=new st("[Mapper]"),kt=null,at=()=>(kt||(kt=new Promise((e,t)=>{Yr.type===E.Browser?Promise.resolve().then(()=>(Hr(),jr)).then(({WebStore:r})=>{let n=new r("local"),o=n.get(Wt,{});z(o)&&(o.geolocation&&(!o.geolocation.coords||o.geolocation.$GeolocationPosition)&&delete o.geolocation,Object.assign(I,o)),e(n)}).catch(t):e(void 0)})),kt),Ue=(e={})=>at().then(()=>new Promise((t,r)=>{e=Object.assign({},ct,e);let n=e.catch?t:r;typeof navigator<"u"&&"geolocation"in navigator?navigator.geolocation.getCurrentPosition(o=>{let s=I.geolocation?.coords,i=s?.latitude?.toFixed(3),a=s?.longitude?.toFixed(3),c=I.geolocation?.timestamp??0,l=o.coords.latitude.toFixed(3)!==i,m=o.coords.longitude.toFixed(3)!==a,f=c<Wr().epochMilliseconds-36e5;(l||m||f)&&(Object.assign(I,{georesponse:null}),X.info(e,"GeoLocation: device update")),Object.assign(I,{geolocation:ne(o)}),t(I.geolocation)},o=>{Object.assign(I,{geolocation:{error:o.message},georesponse:null}),n(I.geolocation)}):(Object.assign(I,{geolocation:{error:"Not Supported"},georesponse:null}),n(I.geolocation))})).finally(()=>{(I.geolocation?.error?X.error:X.info)(e,"geoLocation: ",I.geolocation),at().then(r=>r?.set(Wt,I))}),qr=e=>new Promise((t,r)=>{if(!P(e))return t(e);Ue().then(n=>P(n.error)?{location:{lat:n.coords.latitude,lng:n.coords.longitude}}:null).then(n=>t(n)).catch(n=>r(n))}),Ut=(e,t={})=>at().then(()=>new Promise((r,n)=>{t=Object.assign({},ct,t);let o=t.catch?r:n;qr(e).then(s=>{switch(!0){case(Yr.type!==E.Browser||!window.google?.maps):throw new Error("Google Maps API not configured");case P(s):throw new Error("Cannot determine Coordinates");case P(e):{let i=I.geolocation&&I.georesponse,a=P(I.geolocation?.error)&&P(I.georesponse?.error);if(i&&a)return t.debug&&X.debug(t,"mapQuery: cache"),r(I.georesponse)}default:new window.google.maps.Geocoder().geocode(s).then(i=>r(I.georesponse=ne(i)))}}).catch(s=>{Object.assign(I,{georesponse:{error:s.message}}),o(I.georesponse)})})).finally(()=>{t.debug&&(I.georesponse?.error?X.error:X.debug)(t,"mapQuery: ",I.georesponse),at().then(r=>r?.set(Wt,I))}),mo=(e,t={})=>Ut(e,t).then(r=>{if(t=Object.assign({},ct,t),P(r.error))return t.debug&&X.debug(t,"sphere: ",r),r.results[0].geometry.location.lat()>=0?"north":"south";let n=it();if(P(n)&&t.catch===!1)throw new Error("Cannot determine Hemisphere");return n}).catch(r=>{if(t.debug&&X.warn(t,"mapHemisphere: ",r.message),t.catch===!1)throw r;return null}),go=(e,t={})=>Ut(e,t).then(r=>{if(!P(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({},ct,t),t.debug&&X.warn(t,"mapAddress: ",r.message),t.catch===!1)throw r;return null})});var Kt={};he(Kt,{HTTP:()=>en,HttpError:()=>Q,METHOD:()=>tn,fetchHead:()=>ho,fetchRequest:()=>yo});var Jt,Xr,en,tn,Q,Qr,yo,ho,Zt=v(()=>{"use strict";N();Jt=2e3,Xr=/\);?$/,en={Ok:200,PermRedirect:301,TempRedirect:302,BadRequest:400,Unauthorised:401,Forbidden:403},tn={Head:"HEAD",Get:"GET",Put:"PUT",Delete:"DELETE",Post:"POST"},Q=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"}},Qr=async(e,t)=>{let r=e.headers?.get?.("Content-Length")||e.headers?.get?.("content-length");if(r){let a=parseInt(r,10);if(y(a)&&a>t){try{await e.body?.cancel()}catch{}throw new Q(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 Q(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 Q(413,`Streamed payload exceeded limit (${t} bytes)`,null)}i+=o.decode(c,{stream:!0})}}return i+=o.decode(),i}finally{try{n.releaseLock()}catch{}}},yo=(e,t={},r={})=>{let n={...t,signal:t.signal?AbortSignal.any([t.signal,AbortSignal.timeout(r.timeout??Jt)]):AbortSignal.timeout(r.timeout??Jt)};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(x(r.maxBytes)){let c=await Qr(o,r.maxBytes);if(r.rawText)return c;if(r.prefix){let l=c.startsWith(r.prefix)?c.substring(r.prefix.length).replace(Xr,""):c;return JSON.parse(l)}if(a)return JSON.parse(c);try{return JSON.parse(c)}catch{return c}}if(r.rawText)return w(o.text)?await o.text():"";if(r.prefix){let c=await o.text(),l=c.startsWith(r.prefix)?c.substring(r.prefix.length).replace(Xr,""):c;return JSON.parse(l)}if(w(o.text)){let c=await o.text();try{return JSON.parse(c)}catch{return c}}return w(o.json)?await o.json():""}let s=null;try{let i=x(r.maxBytes)?await Qr(o,r.maxBytes):w(o.text)?await o.text():"";try{s=JSON.parse(i)}catch{s=i}}catch(i){if(i instanceof Q&&i.status===413)throw i}throw new Q(o.status,o.statusText,s)})},ho=e=>{let t=AbortSignal.timeout(Jt),r={method:tn.Head,signal:t};return fetch(e,r).then(({ok:n,status:o,statusText:s,headers:i})=>{if(n||o===en.Forbidden)return{status:o,headers:i};throw new Q(o,s,null)})}});var nn={};he(nn,{serverGeoCoords:()=>lt,serverGeoLocation:()=>Be,serverMapHemisphere:()=>qt});var rn,Yt,jt,Ht,wo,Be,lt,qt,Vt=v(()=>{"use strict";N();Ft();Gt();rn=new st("[ServerMapper]"),Yt="https://ipwho.is",jt={endpoint:`${Yt}/`,timeout:3e3,catch:!0,debug:0},Ht=null,wo=()=>(Ht||(Ht=Promise.resolve().then(()=>(Zt(),Kt))),Ht),Be=async(e={})=>{let t={...jt,...e},r=t.catch!==!1;try{let n=t.endpoint||jt.endpoint;if(d(t.ip)){let f=encodeURIComponent(t.ip.trim());if((n.endsWith("/")?n.slice(0,-1):n)===Yt)n=`${Yt}/${f}`;else if(n.includes("{ip}"))n=n.replace("{ip}",f);else if(f!=="")throw new Error(`Custom endpoint must include an '{ip}' placeholder to resolve a specific IP: ${n}`)}let o=t.timeout??jt.timeout,{fetchRequest:s}=await wo(),i=await s(n,{},{...y(o)?{timeout:o}:{},maxBytes:64*1024});if(typeof i!="object"||P(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=y(i.lat)?i.lat:i.latitude,c=y(i.lon)?i.lon:i.lng??i.longitude;if(!y(a)||!y(c))throw new Error("Geolocation lookup failed");let l=d(i.timezone)?i.timezone:i.timezone?.id??i.timeZone,m={lat:a,lng:c,latitude:a,longitude:c,...d(i.country||i.countryName||i.country_name)?{country:i.country||i.countryName||i.country_name}:{},...d(i.city||i.cityName||i.city_name)?{city:i.city||i.cityName||i.city_name}:{},...d(l)?{timezone:l}:{},...d(i.query||i.ip||i.ip_address)?{query:i.query||i.ip||i.ip_address}:{},status:"success"};return t.debug&&rn.info(t,"serverGeoLocation success: ",m),m}catch(n){let o=n?.message||"Server geolocation error";if(t.debug&&rn.error(t,"serverGeoLocation error: ",o),!r)throw n;return{error:o,status:"fail"}}},lt=async(e,t)=>{if(!P(e)){let n=e.latitude??e.lat,o=e.longitude??e.lng??e.lon??e.long;if(y(n)&&y(o))return{lat:n,lng:o}}let r=await Be(t);return P(r.error)&&y(r.lat)&&y(r.lng)?{lat:r.lat,lng:r.lng}:null},qt=async(e,t)=>{let r=await lt(e,t);return r?r.lat>=0?"north":"south":it()??null}});var fn=cr((ra,un)=>{"use strict";un.exports=window.undefined});var Po={};he(Po,{GEO_PROPERTIES:()=>Ke,GeoPlugin:()=>sr,NON_GEO_CONTROL_KEYS:()=>pn,clearStashedGeo:()=>pt,coerceGeo:()=>Oe,default:()=>vo,forwardGeocode:()=>or,geoLocation:()=>Ue,geoLookup:()=>mt,geoPlugin:()=>_o,getGeoProvider:()=>nr,getStashedGeo:()=>_e,resolveCulturalLocale:()=>ir.resolveCulturalLocale,resolveGeoCoordinates:()=>Ze,reverseGeocode:()=>gt,serverGeoCoords:()=>lt,serverGeoLocation:()=>Be,serverMapHemisphere:()=>qt,setGeoProvider:()=>dt,stashGeo:()=>ft});var J={};he(J,{definePlugin:()=>wt,defineTerm:()=>bn});ve(J,yt(ht()));var Ye=yt(ht()),wt=e=>(0,Ye.definePlugin)({...e,version:"1.4.0"}),bn=e=>(0,Ye.defineTerm)({...e,version:"1.4.0"});Re();N();Ct();N();function ce(...e){for(let t of e){let r=w(t)?t():t;if(r!==void 0)return r}}Nt();var ye="_magma_geo_",Qt=1440*60*1e3,bo="https://api.bigdatacloud.net/data/reverse-geocode-client",So=3e3,xo=64*1024,To=1e3,Ke=["latitude","lat","longitude","lng","lon","long","elevation","sphere","country","city","timezone","tz"],sn=e=>{if(!x(e)||mr(e))return NaN;if(d(e)){let t=e.trim();return t.length>0?Number(t):NaN}return y(e)?e:NaN},er=(e,t=!0)=>{let r=sn(e);if(!(!y(r)||r<-90||r>90))return t?Math.round(r*1e3)/1e3:r},tr=(e,t=!0)=>{let r=sn(e);if(!(!y(r)||r<-180||r>180))return t?Math.round(r*1e3)/1e3:r},Je=(e,t,r=!0)=>{let n=er(e,r),o=tr(t,r);return x(n)&&x(o)?{lat:n,lng:o}:void 0},an=e=>y(e)?Math.round(e*1e3)/1e3:void 0,Ee=(e,t)=>{if(e==="north"||e==="south"||e==="equator")return e;if(y(t))return t>.001?"north":t<-.001?"south":"equator"},cn=(e,t=!0)=>{if(d(e)&&e.includes(",")){let r=e.split(",").map(n=>n.trim());return r.length>=2?Je(r[0],r[1],t):void 0}return Array.isArray(e)&&e.length>=2?Je(e[0],e[1],t):void 0},ue=(e,t)=>{let r="lat"in e?e.lat:e.latitude,n="lng"in e?e.lng:e.longitude,o=er(r),s=tr(n),i=Ee(t?.sphere,o??r),a=an(t?.elevation);return{latitude:o??r,longitude:s??n,...i?{sphere:i}:{},...d(t?.city)&&!O(t.city)?{city:t.city.trim()}:{},...d(t?.country)&&!O(t.country)?{country:t.country.trim()}:{},...a!==void 0?{elevation:a}:{},...d(t?.timezone)&&!O(t.timezone)?{timezone:t.timezone.trim()}:{}}},Eo=(e,t=Ke)=>{let r={};if(z(e))for(let n of Object.keys(e))B(n)&&!t.includes(n)&&(r[n]=e[n]);return r},Oe=e=>{let t=cn(e);if(t)return ue(t);if(te(e))return;let r=e.geo??e,n=e.config?.geo??e.config,o=ce(r?.latitude,r?.lat,e.latitude,e.lat,n?.latitude,n?.lat),s=ce(r?.longitude,r?.lng,r?.lon,r?.long,e.longitude,e.lng,e.lon,e.long,n?.longitude,n?.lng,n?.lon,n?.long),i=ce(r?.elevation,e.elevation,n?.elevation),a=ce(r?.sphere,e.sphere,n?.sphere),c=ce(r?.country,e.country,n?.country),l=ce(r?.city,e.city,n?.city),m=ce(r?.timezone,r?.tz,e.timezone,e.tz,n?.timezone,n?.tz),f={},h=er(o),p=tr(s);h!==void 0&&(f.latitude=h),p!==void 0&&(f.longitude=p);let R=an(i);R!==void 0&&(f.elevation=R);let g=Ee(a,f.latitude);g&&(f.sphere=g),d(c)&&(f.country=c),d(l)&&(f.city=l),d(m)&&(f.timezone=m);let u=z(e.geo)?e.geo:z(e.config?.geo)?e.config.geo:void 0,T=Eo(u);return Object.assign(f,T),Object.keys(f).length>0?f:void 0},rr=e=>{if(d(e)&&!O(e)){let t=e.trim();return t.startsWith(ye)?t:`${ye}:${t}`}if(e&&S(e)){let t=e.provider??L,r=t&&d(t.name)&&!O(t.name)?`provider:${t.name}`:void 0,n=e.key??e.ip??e.query;if(d(n)&&!O(n)){let o=n.trim();return r?`${ye}:${r}:${o}`:`${ye}:${o}`}if(r)return`${ye}:${r}`}else if(L&&d(L.name)&&!O(L.name))return`${ye}:provider:${L.name}`;return ye},_e=e=>{let t=rr(e);try{let r=Mr(t)??($(globalThis.localStorage?.getItem)?globalThis.localStorage.getItem(t):void 0);if(!r)return;let n=d(r)&&(r.startsWith("{")||r.startsWith("["))?JSON.parse(r):r;if(S(n)&&y(n._expires)&&Date.now()>n._expires){pt(e);return}let o=cn(n);if(o)return ue(o);if(S(n)){let s=n.geolocation?.coords??n.coords??n,i=s?.latitude??s?.lat,a=s?.longitude??s?.lng??s?.lon??s?.long,c=Je(i,a);if(c){let l=n.elevation??s.elevation;return ue(c,{elevation:l,sphere:n.sphere,country:n.country,city:n.city,timezone:n.timezone})}}}catch{}},ft=(e,t=Qt,r)=>{let n=rr(r),o=y(t)&&t>0?{...e,_expires:Date.now()+t}:e;$t(n,o,{ttl:t})},pt=e=>{let t=rr(e);$t(t,void 0)},L;function dt(e){L=e}function nr(){return L}var mt=async(e={})=>{let t=e.provider??L;if(e.refresh!==!0){let a=_e(e);if(a&&y(a.latitude)&&y(a.longitude)){let{latitude:c,longitude:l,...m}=a;return{...m,status:"cached",lat:c,lng:l,latitude:c,longitude:l}}}let n;if(t&&w(t.lookup))try{let a=await t.lookup(e);if(a){if(n=a,a.error&&e.fallback===!1)return a}else if(e.fallback===!1)return{error:"Provider returned null and fallback is disabled"}}catch(a){if(e.fallback===!1)return{error:a?.message??"Provider lookup failed"}}if(!n||n.error){if(e.fallback===!1&&(t||n?.error))return n&&n.error?n:{error:"Geolocation resolution failed and fallback is disabled"};let{type:a}=be();switch(a){case E.Browser:{let{geoLocation:c}=await Promise.resolve().then(()=>(Bt(),Vr)),l=await c(e);if(l.error)return{error:l.error};let m=l.coords?.latitude,f=l.coords?.longitude;n={...l,lat:m,lng:f,latitude:m,longitude:f};break}case E.WebWorker:case E.NodeJS:case E.Deno:default:{let{serverGeoLocation:c}=await Promise.resolve().then(()=>(Vt(),nn));n=await c(e);break}}}let o=n.latitude??n.lat,s=n.longitude??n.lng,i=Je(o,s);if(P(n.error)&&i){let a=Ee(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=ue(i,n);try{let l=y(e.ttl)?e.ttl:Qt;ft(c,l,e)}catch{}}return n},Xt=null,Oo=()=>(Xt||(Xt=Promise.resolve().then(()=>(Zt(),Kt))),Xt),ut=new Fe(To,Qt),ln=e=>{try{let t=new URL(e);return t.protocol==="https:"||t.hostname==="localhost"||t.hostname==="127.0.0.1"}catch{return!1}};var on=(e,t,r)=>{let n=`${e.toFixed(2)},${t.toFixed(2)}`;if(d(r)&&!O(r))return`${n}:${r.trim()}`;if(S(r)){let s=Object.hasOwn(r,"provider")?r.provider:L,i=s&&d(s.name)&&!O(s.name)?s.name.trim():void 0,a=d(r.reverseEndpoint??r.reverseGeoEndpoint)&&!O(r.reverseEndpoint??r.reverseGeoEndpoint)?(r.reverseEndpoint??r.reverseGeoEndpoint).trim():void 0,c=a&&ln(a)?a:void 0;if(i&&c)return`${n}:${i}:${c}`;if(i)return`${n}:${i}`;if(c)return`${n}:${c}`}else if(L&&d(L.name)&&!O(L.name))return`${n}:${L.name.trim()}`;return n};async function gt(e,t){let r=Oe(e);if(!r||!y(r.latitude)||!y(r.longitude))return null;let n=r.latitude,o=r.longitude,s=on(n,o,t),i=t?.refresh!==!0;if(i){let p=ut.get(s);if(p)return{...p,latitude:n,longitude:o,sphere:Ee(p.sphere,n),elevation:y(p.elevation)?p.elevation:r.elevation,timezone:d(p.timezone)?p.timezone:r.timezone}}let a=S(t)&&Object.hasOwn(t,"provider"),c=a?t.provider:L;if(c&&w(c.reverseGeocode))try{let p=await c.reverseGeocode(r,t);if(p&&S(p)){let R=ue({lat:n,lng:o},{sphere:p.sphere,city:p.city,country:p.country,elevation:y(p.elevation)?p.elevation:r.elevation,timezone:d(p.timezone)?p.timezone:r.timezone}),g=ue({lat:n,lng:o},{sphere:p.sphere,city:p.city,country:p.country,timezone:p.timezone});return ut.set(s,g),R}if(t?.fallback===!1)return null}catch(p){if(t?.fallback===!1)throw p}else if(t?.fallback===!1&&(c||a))return null;let l=t?.reverseEndpoint??t?.reverseGeoEndpoint;if(F(l)){let p=l.trim();if(!ln(p))return t?.fallback===!1?null:r}let m=F(l)?l.trim():void 0,f=on(n,o,m??"default");if(i){let p=ut.get(f);if(p)return{...p,latitude:n,longitude:o,sphere:Ee(p.sphere,n),elevation:y(p.elevation)?p.elevation:r.elevation,timezone:d(p.timezone)?p.timezone:r.timezone}}let h;if(m)if(/\{(?:latitude|lat|longitude|lng|lon)\}/i.test(m))h=m.replace(/\{latitude\}/gi,encodeURIComponent(n)).replace(/\{lat\}/gi,encodeURIComponent(n)).replace(/\{longitude\}/gi,encodeURIComponent(o)).replace(/\{lng\}/gi,encodeURIComponent(o)).replace(/\{lon\}/gi,encodeURIComponent(o));else{let p=m.includes("?")?"&":"?";h=`${m}${p}latitude=${encodeURIComponent(n)}&longitude=${encodeURIComponent(o)}`}else h=`${bo}?latitude=${n}&longitude=${o}&localityLanguage=en`;try{let p=y(t?.timeout)&&t.timeout>0?t.timeout:So,R=y(t?.maxBytes)&&t.maxBytes>0?t.maxBytes:xo,{fetchRequest:g}=await Oo(),u=await g(h,{},{timeout:p,maxBytes:R});if(S(u)){let T=F(u.city)?u.city.trim():F(u.locality)?u.locality.trim():F(u.principalSubdivision)?u.principalSubdivision.trim():void 0,D=F(u.countryCode)?u.countryCode.trim():F(u.countryName)?u.countryName.trim():void 0,_=ue({lat:n,lng:o},{city:T,country:D,elevation:r.elevation,timezone:r.timezone});if(F(T)||F(D)){let j=ue({lat:n,lng:o},{city:T,country:D});ut.set(f,j)}return _}}catch{}return r}async function or(e,t){let r=t?.provider??L;return r&&w(r.forwardGeocode)?r.forwardGeocode(e,t):null}var Ze=async(e,t={})=>{let r=Oe(e);if(r&&y(r.latitude)&&y(r.longitude)){if((t.reverse===!0||t.autoReverse===!0)&&(!r.city||!r.country)){let a=await gt(r,t);if(a)return{...a,...r,city:F(r.city)?r.city:a.city,country:F(r.country)?r.country:a.country,lat:r.latitude,lng:r.longitude,latitude:r.latitude,longitude:r.longitude}}return{...r,lat:r.latitude,lng:r.longitude}}let n=t.refresh===!0?void 0:_e(t);if(n&&y(n.latitude)&&y(n.longitude))return{...n,lat:n.latitude,lng:n.longitude};let o=await mt(t),s=Je(o.lat,o.lng);if(P(o.error)&&s){let i=Ee(o.sphere,s.lat);return{...o,lat:s.lat,lng:s.lng,latitude:s.lat,longitude:s.lng,sphere:i}}return null};var ir=yt(fn(),1);Vt();Bt();N();var pn=["setTimezone","setLocale","refresh","ttl","endpoint","timeout","maxBytes","highAccuracy","catch","debug","geo","provider","fallback","reverse","autoReverse"];var sr=wt({name:"geo",install(e,t){let r=e||this;t?.provider&&dt(t.provider);let n=(o,s)=>{let i=r.config?.pluginOptions?.geo,a=s?.config?.pluginOptions?.geo;return{...S(t)?t:{},...S(i)?i:{},...S(a)?a:{},...S(o)?o:{}}};Object.hasOwn(r,"geo")||Object.defineProperty(r,"geo",{value:(0,J.deepFreeze)({lookup:s=>mt(n(s)),resolve:(s,i)=>Ze(s,n(i,s)),coerce:Oe,stash:ft,clear:pt,get:_e,setProvider:dt,getProvider:nr,reverse:(s,i)=>gt(s,n(i)),forward:(s,i)=>or(s,n(i)),server:Be,browser:Ue,get current(){return _e()??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=s?.setLocale??!0,c=await Ze(this,s);if(c){let l=S(this.config.geo)?this.config.geo:{},m={};for(let _ of Object.keys(l))B(_)&&!Ke.includes(_)&&(m[_]=l[_]);let f=Oe(o)??{};if(S(o))for(let _ of Object.keys(o))B(_)&&!pn.includes(_)&&(Ke.includes(_)||(m[_]=o[_]));let h=y(c?.elevation)?c.elevation:y(l.elevation)?l.elevation:void 0,p={...m,...c,...y(h)?{elevation:h}:{},...f},R=p.latitude,g=p.longitude;y(R)&&(p.latitude=Math.round(R*1e3)/1e3),y(g)&&(p.longitude=Math.round(g*1e3)/1e3),!p.sphere&&y(R)&&(p.sphere=R>.001?"north":R<-.001?"south":"equator");let u=this,T=p.timezone;i&&d(T)&&!O(T)&&(u=this.set({timeZone:T}));let D=p.country||d(a)?(0,ir.resolveCulturalLocale)(this.locale??this.config.locale,p.country,a):void 0;return new e(u,{...u.config,...D?{locale:D}:{},geo:(0,J.deepFreeze)(p),...p.sphere?{sphere:p.sphere}:{}})}return this},e.prototype.geoLookup=async function(o){return Ze(this,n(o,this))}}}),_o=sr,vo=sr;return wn(Po);})();