solid-map-gl 2.0.1 → 2.2.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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![CI](https://img.shields.io/github/actions/workflow/status/GIShub4/solid-map-gl/ci.yml?branch=main&label=CI)](https://github.com/GIShub4/solid-map-gl/actions/workflows/ci.yml)
6
6
  [![codecov](https://img.shields.io/codecov/c/github/GIShub4/solid-map-gl)](https://codecov.io/gh/GIShub4/solid-map-gl)
7
7
  [![npm](https://img.shields.io/npm/v/solid-map-gl)](https://www.npmjs.com/package/solid-map-gl)
8
- [![downloads](https://img.shields.io/npm/dt/solid-map-gl)](https://www.npmjs.com/package/solid-map-gl)
8
+ [![downloads](https://img.shields.io/npm/d18m/solid-map-gl)](https://www.npmjs.com/package/solid-map-gl)
9
9
  [![licence](https://img.shields.io/npm/l/solid-map-gl?color=blue)](LICENSE/)
10
10
 
11
11
  [SolidJS](https://www.solidjs.com/) Component Library for [Mapbox GL JS](https://github.com/mapbox/mapbox-gl-js) and [MapLibre GL.](https://maplibre.org/projects/maplibre-gl-js/) Both libraries render interactive maps from vector tiles and Map styles using WebGL. This project is intended to be as close as possible to the [Mapbox GL JS API.](https://docs.mapbox.com/mapbox-gl-js/api/)
@@ -33,6 +33,12 @@ pnpm add solid-map-gl maplibre-gl mapbox-gl@npm:empty-npm-package@1.0.0
33
33
  pnpm dev
34
34
  ```
35
35
 
36
+ > [!NOTE]
37
+ > `npm` enforces peer-dependency version ranges more strictly than `pnpm`/`yarn` — the placeholder
38
+ > above satisfies them on `pnpm`/`yarn`, but `npm install` will fail with an `ERESOLVE` error since
39
+ > the placeholder's version doesn't match `solid-map-gl`'s declared `mapbox-gl` range. Use
40
+ > `pnpm`/`yarn` for this install, or run `npm install --legacy-peer-deps` if you must use `npm`.
41
+
36
42
  #### [Solid Start](https://gis-hub.gitbook.io/solid-map-gl/start#solid-start)
37
43
 
38
44
  ```shell
@@ -123,6 +129,12 @@ yarn add solid-map-gl maplibre-gl mapbox-gl@npm:empty-npm-package@1.0.0
123
129
  npm i solid-map-gl maplibre-gl mapbox-gl@npm:empty-npm-package@1.0.0
124
130
  ```
125
131
 
132
+ > [!NOTE]
133
+ > `npm` enforces peer-dependency version ranges more strictly than `pnpm`/`yarn` — the placeholder
134
+ > above satisfies them on `pnpm`/`yarn`, but `npm install` will fail with an `ERESOLVE` error since
135
+ > the placeholder's version doesn't match `solid-map-gl`'s declared `mapbox-gl` range. Use
136
+ > `pnpm`/`yarn` for this install, or run `npm install --legacy-peer-deps` if you must use `npm`.
137
+
126
138
  ```jsx
127
139
  import { render } from "solid-js/web";
128
140
  import { Component, createSignal } from "solid-js";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,76 @@
1
1
  import { Component, JSX, ParentComponent, VoidComponent } from 'solid-js';
2
2
  import { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent, LngLatLike, LngLatBounds, PaddingOptions, MapboxOptions, StyleSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, FogSpecification, NavigationControlOptions, ScaleControlOptions, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, MarkerOptions, PopupOptions, StyleImageInterface, Map as Map$1, LightSpecification } from 'mapbox-gl';
3
3
 
4
+ /** Any object shaped enough like `mapboxgl.Map`/`maplibregl.Map` for the functions in this module —
5
+ * kept loose (not the real `mapboxgl.Map` type) so this file has no hard dependency on either
6
+ * library's types. */
7
+ type SettleableMap = {
8
+ areTilesLoaded(): boolean;
9
+ triggerRepaint(): void;
10
+ once(event: "idle", cb: () => void): unknown;
11
+ style?: {
12
+ hasTransitions?: () => boolean;
13
+ };
14
+ };
15
+ type SettleOptions = {
16
+ /** Max time (ms) to keep polling `areTilesLoaded()` before giving up and moving on anyway.
17
+ * Default 10000. */
18
+ timeout?: number;
19
+ /** Extra flat delay (ms) to outlast a `raster-fade-duration` cross-fade still in flight after
20
+ * tiles report loaded — there's no public event for "the fade finished", and the internal
21
+ * tracking (`hasActiveFadeTransition`) doesn't reliably cover imported style fragments (e.g.
22
+ * Standard/Standard Satellite). Default 400 (mapbox-gl's own `raster-fade-duration` default is
23
+ * 300). Set to 0 to skip this step entirely. */
24
+ fadeMargin?: number;
25
+ };
26
+ /** The actual "is this map done, visually" check: polls `areTilesLoaded()`, confirms a real paint
27
+ * via two animation frames, then (unless `fadeMargin` is 0) waits out any raster-fade cross-fade
28
+ * still in flight. Call this from inside your own `map.once('idle', ...)` — it doesn't listen for
29
+ * 'idle' itself, since 'idle' can otherwise fire while raster tiles are still fetching, mid
30
+ * GPU-upload, or still cross-fading in, none of which 'idle' itself waits out. Use
31
+ * `waitForIdleAndSettle` for the common case of "wait for the next idle, then this". */
32
+ declare function settleAfterIdle(map: SettleableMap, options?: SettleOptions): Promise<void>;
33
+ /** Waits for the map's next 'idle' event, then `settleAfterIdle`. The convenience entry point for
34
+ * off-screen/headless capture: call your own `jumpTo`/`fitBounds`/`setData` first, then `await` this
35
+ * before reading the canvas. */
36
+ declare function waitForIdleAndSettle(map: SettleableMap, options?: SettleOptions): Promise<void>;
37
+ /** Zeros `raster-fade-duration` on every layer that supports it, so newly-loaded raster tiles
38
+ * appear at full opacity immediately instead of cross-fading in over mapbox-gl's default 300ms —
39
+ * that fade is a paint-time opacity animation, invisible to `areTilesLoaded()`/`isSourceLoaded()`,
40
+ * so a capture taken right on load/idle can otherwise catch tiles still visibly fading in. Tries
41
+ * every layer rather than filtering to `type === "raster"`: some styles (e.g. Mapbox's
42
+ * Standard/Standard Satellite family) compose their base imagery in ways that don't always surface
43
+ * as a plain `"raster"`-typed layer in `getStyle().layers`, so filtering by type risked silently
44
+ * missing the actual imagery layer — `setPaintProperty` throwing for a layer type that doesn't
45
+ * support this property is caught and ignored instead. */
46
+ declare function disableRasterFade(map: {
47
+ getStyle(): {
48
+ layers?: {
49
+ id: string;
50
+ }[];
51
+ } | undefined;
52
+ setPaintProperty(id: string, name: string, value: unknown): void;
53
+ }): void;
54
+
55
+ /** Handed to `<MapGL offscreen>`'s `onCapturerReady` callback. */
56
+ type MapCapturer = {
57
+ /** The raw mapboxgl.Map/maplibregl.Map instance — for anything not already covered by
58
+ * `<Source>`/`<Layer>` children, e.g. reading back computed values. Camera/data changes are
59
+ * still made the normal declarative way, via `<MapGL>`'s own `viewport` prop and `<Source>`'s
60
+ * `data` prop. */
61
+ map: any;
62
+ /** Waits for the map's next 'idle', then for every tile to be genuinely loaded, painted, and (if
63
+ * applicable) done cross-fading in — see `waitForIdleAndSettle`. Call this after changing
64
+ * `viewport`/`data` props. */
65
+ waitUntilSettled(): Promise<void>;
66
+ /** `map.getCanvas().toDataURL(type, quality)`. Call after `waitUntilSettled()`, or use
67
+ * `captureWhenSettled()` to do both in one call. The result can be handed to any PDF/document
68
+ * library — this doesn't depend on or assume one. */
69
+ capture(type?: string, quality?: number): string;
70
+ /** `await waitUntilSettled()` then `capture()`, in one call. */
71
+ captureWhenSettled(type?: string, quality?: number): Promise<string>;
72
+ };
73
+
4
74
  type mapEventTypes = {
5
75
  onMouseDown?: (event: MapMouseEvent) => void;
6
76
  onMouseUp?: (event: MapMouseEvent) => void;
@@ -196,6 +266,40 @@ type Props$b = {
196
266
  onViewportChange?: (viewport: Viewport) => void;
197
267
  /** Event listener for User Interaction */
198
268
  onUserInteraction?: (user: boolean) => void;
269
+ /** Called once every currently-required tile has actually finished loading *and* rendering after
270
+ * an 'idle' event — unlike 'onIdle' itself, which can fire while raster tiles are still
271
+ * fetching, mid GPU-upload, or still cross-fading in via `raster-fade-duration`. Re-fires after
272
+ * every idle, not just the initial load. */
273
+ onTilesLoaded?: () => void;
274
+ /** Max time (ms) to keep polling `areTilesLoaded()` after idle before giving up and moving on
275
+ * anyway, so a permanently-erroring tile can't block `onTilesLoaded` forever. Default 10000. */
276
+ tilesLoadedTimeout?: number;
277
+ /** Extra flat delay (ms) `onTilesLoaded` waits after tiles report loaded, to outlast any
278
+ * `raster-fade-duration` cross-fade still in flight — mapbox-gl-js exposes no public event for
279
+ * "the fade finished", and its own internal transition tracking doesn't reliably cover imported
280
+ * style fragments (e.g. Mapbox's Standard/Standard Satellite styles), so a flat margin is the
281
+ * only fully reliable option. Default 400 (mapbox-gl's own `raster-fade-duration` default is
282
+ * 300). Set to 0 to disable and get the old, faster-but-less-certain behavior. */
283
+ tilesLoadedFadeMargin?: number;
284
+ /** Renders the map off-screen (`position: fixed`, far outside the viewport) instead of filling
285
+ * its normal container, for capturing map images (e.g. PDF export) without showing the map to
286
+ * the user — an off-screen element has no layout to size itself against, so a width/height is
287
+ * required. `<Source>`/`<Layer>` children work exactly as they do on a normal `<MapGL>`, since
288
+ * they only ever read the map off context, never the DOM it's rendered into. */
289
+ offscreen?: {
290
+ width: number;
291
+ height: number;
292
+ /** Zero every layer's `raster-fade-duration` once the map loads — see `disableRasterFade`.
293
+ * Default `true`. */
294
+ disableRasterFade?: boolean;
295
+ };
296
+ /** Called once, after the map loads, with a capturer for grabbing the canvas as an image — only
297
+ * meaningful together with `offscreen`. Change `viewport`/`<Source>`'s `data` the normal
298
+ * declarative way, then call `capturer.captureWhenSettled()`, which waits for the map to fully
299
+ * settle (see `onTilesLoaded`, reusing this same `tilesLoadedTimeout`/`tilesLoadedFadeMargin`)
300
+ * before reading the canvas. The result (a data URL) can be handed to any PDF/document library —
301
+ * this doesn't depend on or assume one. */
302
+ onCapturerReady?: (capturer: MapCapturer) => void;
199
303
  /** Displays Map Tile Borders */
200
304
  showTileBoundaries?: boolean;
201
305
  /** Displays Wireframe if Terrain is visible */
@@ -219,6 +323,12 @@ type Props$b = {
219
323
  disableResize?: boolean;
220
324
  mapLib?: any;
221
325
  apikey?: string;
326
+ /** Named values (colors, widths, ...), reusable across every `<Layer>` in this map by writing
327
+ * `"@name"` in a paint/layout style property instead of repeating the literal value. Updating
328
+ * this prop updates every layer referencing a changed name. Mirrors the `constants`/`@name`
329
+ * feature the Mapbox GL style spec itself dropped after v7 — resolved here in JS instead, never
330
+ * touching the style JSON Mapbox itself sees. */
331
+ constants?: Record<string, string | number>;
222
332
  debug?: boolean;
223
333
  debugEvents?: boolean;
224
334
  ref?: HTMLDivElement;
@@ -233,12 +343,23 @@ type MapContextState = {
233
343
  /** The resolved Mapbox/MapLibre module in use — replaces the old `window.MapLib` global */
234
344
  mapLib: any;
235
345
  isMapLibre: boolean;
346
+ /** Named values (colors, widths, ...) that Layer style props can reference via `"@name"` */
347
+ constants: Record<string, any>;
348
+ /** Bumped by MapGL on every matchMedia/dark-class-mutation firing, unconditionally — not a
349
+ * light/dark judgment, just "something in the environment that could affect a resolved CSS
350
+ * value just changed." Layer reads this only to know *when* to re-probe a "bg-x dark:bg-y"
351
+ * color pair, never to decide which of the two applies (the browser's own cascade decides that,
352
+ * see resolveColor in src/colors.ts) — so it stays correct even for a dark-mode strategy (e.g. a
353
+ * `data-theme` attribute) MapGL's own class-based heuristic wouldn't recognize as "dark" */
354
+ themeVersion: number;
236
355
  };
237
356
  declare const useMapContext: () => [MapContextState];
238
357
  declare const MapProvider: ParentComponent<{
239
358
  map?: Map;
240
359
  mapLib?: any;
241
360
  isMapLibre?: boolean;
361
+ constants?: Record<string, any>;
362
+ themeVersion?: number;
242
363
  }>;
243
364
 
244
365
  declare const useSourceId: () => string;
@@ -253,6 +374,28 @@ type Props$a = {
253
374
  declare const Source: Component<Props$a>;
254
375
 
255
376
  type FlatLayerStyle = Record<string, any>;
377
+ type PulseConfig = {
378
+ /** The paint property to animate, e.g. `"icon-halo-width"`, `"icon-opacity"`, or a
379
+ * `*-color` property (e.g. `"icon-halo-color"`) to fade/shift a color instead of a number.
380
+ * Default `"icon-halo-width"` — override for anything other than a symbol layer's halo
381
+ * (e.g. `"circle-radius"`/`"circle-opacity"` on a circle layer). */
382
+ property?: string;
383
+ /** Start value — a number for a plain paint property, or any CSS color string (hex, named,
384
+ * rgb/rgba, a Tailwind name, ...) when animating a `*-color` property. Default `0`. */
385
+ from?: number | string;
386
+ /** Default `8`. */
387
+ to?: number | string;
388
+ /** Full cycle length, in ms. Default `1500`. */
389
+ duration?: number;
390
+ /** - `"out"` (default): a one-directional ease-out ramp from `from` to `to`, holding at `to`
391
+ * for the last quarter of the cycle before resetting — Tailwind's `animate-ping` shape
392
+ * (e.g. a ring that grows outward and fades, then disappears until the next cycle). The
393
+ * most common "pulsing dot" look.
394
+ * - `"in"`: the mirror of `"out"` — ramps from `to` down to `from`, holding at `from`.
395
+ * - `"in-out"`: smooth back-and-forth between `from` and `to`, forever (sine-eased) — e.g. a
396
+ * halo that grows and shrinks continuously, with no reset. */
397
+ waveform?: "in-out" | "out" | "in";
398
+ };
256
399
  type Props$9 = {
257
400
  id?: string;
258
401
  /** A string that uniquely identifies the layer. If not provided, a unique ID will be generated. */
@@ -277,6 +420,15 @@ type Props$9 = {
277
420
  state: Record<string, any>;
278
421
  };
279
422
  /** An object that specifies the state of a feature in the layer. The object consists of an ID (either a number or a string) and an object containing the state. */
423
+ /** Continuously animates one paint property via `setPaintProperty` every animation frame —
424
+ * e.g. a growing/fading `icon-halo-width`/`icon-halo-color` for a "pulsing dot" marker. Every
425
+ * field defaults (see `PulseConfig`), so `pulse` alone or `pulse={{}}` already pulses a
426
+ * symbol layer's halo — override only what you need to customize. Pass an array to drive
427
+ * several properties at once (one shared `requestAnimationFrame` loop), e.g. `icon-halo-width`
428
+ * and `icon-opacity` together for a combined ping. Driven by real paint properties (not a
429
+ * swapped-out image), so it composes with any other paint value, including data-driven
430
+ * expressions on other properties of the same layer. */
431
+ pulse?: boolean | PulseConfig | PulseConfig[];
280
432
  children?: any;
281
433
  } & layerEventTypes;
282
434
  declare const Layer: Component<Props$9>;
@@ -376,8 +528,35 @@ type Props$5 = {
376
528
  };
377
529
  declare const Popup: Component<Props$5>;
378
530
 
379
- type StyleImageMetadata = NonNullable<Parameters<Map$1['addImage']>[2]>;
531
+ type SDFOptions = {
532
+ /** Pixels of gradient falloff encoded around each edge. Needs matching empty margin
533
+ * around the source art (see `sdfPadding`) or the field clips at the bitmap border. */
534
+ radius?: number;
535
+ /** Where along the gradient (0-1) the shape's "true" edge sits; matches mapbox's own
536
+ * glyph default. */
537
+ cutoff?: number;
538
+ };
539
+ type PixelData = {
540
+ width: number;
541
+ height: number;
542
+ data: Uint8Array | Uint8ClampedArray;
543
+ };
544
+ declare function toSDF(imageData: PixelData, { radius, cutoff }?: SDFOptions): PixelData;
545
+
546
+ type Pattern = {
547
+ size: number;
548
+ path: string;
549
+ fill?: boolean;
550
+ };
551
+ declare const PATTERN: Record<string, Pattern>;
380
552
  declare const patternList: string[];
553
+ type PatternName = keyof typeof PATTERN;
554
+ declare const SYMBOL: Record<string, string>;
555
+ declare const symbolList: string[];
556
+ type SymbolName = keyof typeof SYMBOL;
557
+
558
+ type StyleImageMetadata = NonNullable<Parameters<Map$1['addImage']>[2]>;
559
+
381
560
  type Color = `#${string}` | `rgb(${number}, ${number}, ${number})` | `rgba(${number}, ${number}, ${number}, ${number})` | `hsl(${number}, ${number}%, ${number}%)` | `hsla(${number}, ${number}%, ${number}%, ${number})`;
382
561
  type Props$4 = {
383
562
  id: string;
@@ -395,11 +574,22 @@ type Props$4 = {
395
574
  };
396
575
  /** The options for the image */
397
576
  pattern?: {
398
- type: string;
577
+ type: PatternName | (string & {});
399
578
  color: Color;
400
579
  background: Color;
401
- lineWith: number;
580
+ lineWidth: number;
402
581
  };
582
+ /** The pattern to be used for the image component. */
583
+ /** A predefined icon shape (see `symbolList`, e.g. `"triangle"`, `"hexagon"`), full custom
584
+ * SVG markup, or a raw SVG path `d` string. Resolved the same way `source` is — including
585
+ * `sdf` and `options.fill`/`options.stroke` — so it's just a convenient way to pick a
586
+ * built-in shape instead of writing the markup yourself. Ignored if `source` is set. */
587
+ symbol?: SymbolName | (string & {});
588
+ /** Convert the rasterized source into a real signed-distance-field bitmap (not just
589
+ * tagged with `sdf: true`), so `icon-color`/`icon-halo-color`/`icon-halo-width`/
590
+ * `icon-halo-blur` can recolor and outline it crisply from layer paint properties.
591
+ * Only applies to `source`/`symbol`, not `pattern`. */
592
+ sdf?: boolean | SDFOptions;
403
593
  };
404
594
  declare const MGL_Image: VoidComponent<Props$4>;
405
595
 
@@ -486,4 +676,4 @@ type Props = {
486
676
  /** Adds a deck.gl overlay control to the map, forwarding `props` reactively via `setProps`. */
487
677
  declare const DeckOverlay: VoidComponent<Props>;
488
678
 
489
- export { Atmosphere, Camera, type Color, Control, DeckOverlay, Draw, MGL_Image as Image, Layer, Layer3D, Light, type MapLibreSky, MapProvider, Marker, Popup, Source, Terrain, type Viewport, MapGL as default, patternList, useMapContext, useScene, useSourceId };
679
+ export { Atmosphere, Camera, type Color, Control, DeckOverlay, Draw, MGL_Image as Image, Layer, Layer3D, Light, type MapCapturer, type MapLibreSky, MapProvider, Marker, type PatternName, type PixelData, Popup, type SDFOptions, type SettleOptions, type SettleableMap, Source, type SymbolName, Terrain, type Viewport, MapGL as default, disableRasterFade, patternList, settleAfterIdle, symbolList, toSDF, useMapContext, useScene, useSourceId, waitForIdleAndSettle };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { template, createComponent, use, insert, memo, effect, setAttribute, className, classList, style } from 'solid-js/web';
2
- import { createContext, useContext, createSignal, onMount, createEffect, on, onCleanup, createUniqueId, createMemo, splitProps, untrack } from 'solid-js';
1
+ import { template, createComponent, isServer, use, insert, memo, effect, setAttribute, className, classList, style } from 'solid-js/web';
2
+ import { createContext, useContext, createEffect, createSignal, onMount, on, onCleanup, createUniqueId, createMemo, splitProps, untrack } from 'solid-js';
3
3
  import { createStore } from 'solid-js/store';
4
- import pe from '@turf/length';
5
- import jt from '@turf/area';
6
- import Ut from '@turf/midpoint';
4
+ import Ue from '@turf/length';
5
+ import Eo from '@turf/area';
6
+ import Po from '@turf/midpoint';
7
7
  import { centerOfMass } from '@turf/center-of-mass';
8
8
 
9
- var q={map:null,mapLib:null,isMapLibre:false},W=createContext([q]),h=()=>useContext(W),R=e=>{let[t,o]=createStore({...q});return e.map&&o("map",e.map),e.mapLib&&o("mapLib",e.mapLib),o("isMapLibre",!!e.isMapLibre),createComponent(W.Provider,{value:[t],get children(){return e.children}})};var H=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],J=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],K=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"];var b="mapbox://styles/mapbox",k="https://raw.githubusercontent.com/",y="https://raw.githubusercontent.com/GIShub4/map-styles/main/",V="https://assets.vector.hereapi.com/styles/",Q={mb:{standard:`${b}/standard`,light:`${b}/light-v11`,dark:`${b}/dark-v11`,street:`${b}/streets-v12`,outdoor:`${b}/outdoors-v12`,sat:`${b}/satellite-v9`,sat_street:`${b}/satellite-streets-v12`,nav_base:`${b}/navigation-guidance-day-v4`,nav_base_night:`${b}/navigation-guidance-night-v4`,nav:`${b}/navigation-day-v1`,nav_night:`${b}/navigation-night-v1`,basic:`${b}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${b}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${b}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${b}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${b}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${b}/cj44mfrt20f082snokim4ungi`,mineral:`${b}/cjtep62gq54l21frr1whf27ak`,moonlight:`${b}/cj3kbeqzo00022smj7akz3o1e`,frank:`${b}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${b}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${b}-map-design/ck4014y110wt61ctt07egsel6`,stand:`${b}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${b}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${b}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${b}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${k}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${k}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${k}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${k}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${k}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${k}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${k}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${k}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${V}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${V}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${V}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${y}esri:blueprint.json`,charted_territory:`${y}esri:charted-territory.json`,colored_pencil:`${y}esri:colored-pencil.json`,community:`${y}esri:community.json`,mid_century:`${y}esri:mid-century.json`,modern_antique:`${y}esri:modern-antique.json`,nat_geo:`${y}esri:national-geographic.json`,newspaper:`${y}esri:newspaper.json`,open_street_map:`${y}esri:open-street-map.json`,light_gray_canvas:`${y}esri:light-gray-canvas.json`,dark_gray_canvas:`${y}esri:dark-gray-canvas.json`,human_geo_light:`${y}esri:human-geography-light.json`,human_geo_dark:`${y}esri:human-geography-dark.json`,world_navigation:`${y}esri:world-navigation.json`,world_street:`${y}esri:world-street.json`,world_street_night:`${y}esri:world-street-night.json`,world_terrain:`${y}esri:world-terrain.json`,world_terrain_hybrid:`${y}esri:world-terrain-hybrid.json`,world_topographic:`${y}esri:world-topographic.json`,chromium:`${y}esri:chromium.json`,dreamcatcher:`${y}esri:dreamcatcher.json`,seahaven:`${y}esri:seahaven.json`,sangria:`${y}esri:sangria.json`,mercurial:`${y}esri:mercurial.json`,imagery:`${y}esri:imagery.json`,imagery_hybrid:`${y}esri:imagery-hybrid.json`,firefly:`${y}esri:firefly.json`,firefly_hybrid:`${y}esri:firefly-hybrid.json`,oceans:`${y}esri:oceans.json`}},j="https://{s}.basemaps.cartocdn.com/rastertiles/",D="https://stamen-tiles-{s}.a.ssl.fastly.net/",E="https://{s}.tile.thunderforest.com/",U={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>'},carto:{voyager:`${j}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${j}light_all/{z}/{x}/{y}{r}.png`,dark:`${j}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">&copy; Carto</a>'},stamen:{toner:`${D}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${D}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${D}watercolor/{z}/{x}/{y}.png`,terrain:`${D}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">&copy; Stamen Design</a>'},tf:{cycle:`${E}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${E}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${E}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${E}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${E}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${E}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${E}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${E}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${E}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${E}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">&copy; Thunderforest</a>'}};var Ie=template("<div style=width:100%;height:100%>"),Te=template("<style>.overlay{position:relative;width:100%;height:100%;pointer-events:none}:where(.overlay>*){pointer-events:auto}"),De=template("<div class=overlay>"),Ae=e=>{let t,o,n,r,s,a=false,[i,d]=createSignal(null),[p,f]=createSignal(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches||typeof document<"u"&&document.body.classList.contains("dark")),g=false,x=false,m=(l,c)=>(e.debug||e.debugEvents)&&console.debug("%c[MapGL]","color: #0ea5e9",l,c||""),v=(l,c)=>{let u=p()&&c?c:l;return (typeof u=="string"||u instanceof String)&&u?.split(":").reduce((M,C)=>M&&M[C],Q)?.replace("{apikey}",e.apikey||import.meta.env?.VITE_VECTOR_API_KEY)||u};onMount(async()=>{if(s=e.mapLib||await import('mapbox-gl'),s.Map||(s=window.maplibregl||window.mapboxgl),typeof s.supported=="function"&&!s.supported())throw new Error("Mapbox GL not supported");a=typeof s.Map?.prototype?.setConfigProperty!="function",m(`Map (v${s.version}) loading...`),t=new s.Map({accessToken:e.options?.accessToken||import.meta.env?.VITE_MAPBOX_ACCESS_TOKEN,interactive:e.options?.interactive||!!e.onViewportChange,...e.options,...e.viewport,projection:e.options?.projection,container:o,style:v(e.options?.style,e.darkStyle),fitBoundsOptions:{padding:e.viewport?.padding}}),t.debug=e.debug,t.debugEvents=e.debugEvents,t.sourceIdList=[],t.layerIdList=[],t.isMapLibre=a,H.forEach(l=>{let c=e[l];if(c){let u=l.slice(2).toLowerCase();typeof c=="function"?t.on(u,M=>{setTimeout(()=>{M.clickOnLayer||(c(M),e.debugEvents&&m(`Map '${u}' event:`,M));},0);}):Object.keys(c).forEach(M=>{t.on(u,M,C=>{setTimeout(()=>{C.clickOnLayer||(c[M](C),e.debugEvents&&m(`Map '${u}' event on '${M}':`,C));},0);});});}}),t.once("load",()=>{d(t),m("Map loaded"),["mousedown","touchstart","wheel"].forEach(c=>t.on(c,u=>!u.rotate&&e.onUserInteraction?.(true))),["moveend","mouseup","touchend"].forEach(c=>t.on(c,u=>!u.rotate&&e.onUserInteraction?.(false)));let l=typeof window<"u"&&window?.matchMedia("(prefers-color-scheme: dark)");l?.addEventListener("change",()=>{f(l.matches),m("Set dark theme to:",l.matches?.toString());}),r=new MutationObserver(()=>{let c=document.body.classList.contains("dark");f(c),m("Set theme to:",c);}),r.observe(document.body,{attributes:true}),e.disableResize||(n=new ResizeObserver(()=>{setTimeout(()=>{t?.resize();},0),m("Map resized");}),n.observe(o)),t.on("move",c=>{let u={...e.viewport,id:e.id,point:{x:c.originalEvent?.x,y:c.originalEvent?.y},center:e.viewport?.center?.lat?t.getCenter():[t.getCenter().lng,t.getCenter().lat],zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),inTransit:true,bounds:null};!c.viewport&&e.onViewportChange&&(x=true,e.onViewportChange(u));}),t.on("moveend",c=>{if(g||c.rotate||!e.onViewportChange)return;let u={...e.viewport,inTransit:false};x=true,e.onViewportChange(u);});});}),createEffect(on(()=>e.viewport,l=>{if(e.id!==l?.id)return;if(x){x=false;return}let c={...l,...l.bounds?t.cameraForBounds(l.bounds,{bearing:l?.bearing,pitch:l?.pitch,padding:l?.padding}):null};g=true,t.stop(),g=false,t[e.transitionType||"flyTo"](c),m(`Update Viewport (${e.transitionType||"flyTo"}):`,c);},{defer:true})),createEffect(()=>{let l=i();if(typeof l?.setConfigProperty!="function"){l&&e.config&&Object.keys(e.config).length&&m("Config prop is set but this map library has no setConfigProperty (Mapbox Standard Style only) \u2014 skipping");return}for(let c in e.config){if(!c||c==="id")continue;let u=e.config?.id||"basemap",M=e.config[c];l.setConfigProperty(u,c,M),m(`Set Config (${u}:${c}) to:`,M);}}),createEffect(()=>{let l=e.options?.projection;!t||!l||(t.setProjection(l),m("Set Projection to:",l));}),createEffect(()=>{let l=e.cursorStyle;!t||!l||(t.getCanvas().style.cursor=l,m("Set Cursor to:",l));});let w=(l,c)=>(c.forEach(u=>{let M=l.findIndex(C=>u.metadata.smg.beforeType?C.type===u.metadata.smg.beforeType:C.id===u.metadata.smg.beforeId);l=M===-1?[...l,u]:[...l.slice(0,M),u,...l.slice(M)];}),l);return createEffect(l=>{let c=v(e.options?.style,e.darkStyle);if(t?.isStyleLoaded()&&l!==c){let u=t.getStyle(),M=u.layers.filter(L=>t.layerIdList.includes(L.id)),C=Object.keys(u.sources).filter(L=>t.sourceIdList.includes(L)).reduce((L,Y)=>({...L,[Y]:u.sources[Y]}),{}),A=e.shouldDiffStyle?e.shouldDiffStyle(l,c):true;t.setStyle(c,A?void 0:{diff:false}),t.once("styledata",()=>{if(!M)return;let L=t.getStyle();t.setStyle({...L,sources:{...L.sources,...C},layers:w(L.layers,M),fog:u.fog,terrain:u.terrain,light:u.light}),m("Set Mapstyle to:",c);});}return c},e.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach(l=>{createEffect(()=>{let c=e[l];!t||!c||(t[l]=c,m(`Set ${l} to:`,c));});}),onCleanup(()=>{n?.disconnect(),r?.disconnect(),t?.remove(),m("Map removed");}),(()=>{var l=Ie(),c=o;return typeof c=="function"?use(c,l):o=l,insert(l,(()=>{var u=memo(()=>!!i());return ()=>u()&&createComponent(R,{get map(){return i()},mapLib:s,isMapLibre:a,get children(){return [Te(),(()=>{var M=De();return insert(M,()=>e.children),M})()]}})})()),effect(u=>{var M=e.id,C=e?.class,A=e?.classList,L={...e.style};return M!==u.e&&setAttribute(l,"id",u.e=M),C!==u.t&&className(l,u.t=C),u.a=classList(l,A,u.a),u.o=style(l,L,u.o),u},{e:void 0,t:void 0,a:void 0,o:void 0}),l})()};var oe=createContext(),$=()=>useContext(oe),Ge=e=>{let[t]=h();e.id??=createUniqueId();let o=(s,a)=>{t.map.debug&&console.debug("%c[MapGL]","color: #ec4899",s,a||"");},n=()=>e.source,r=s=>{let a=s?.split(":").reduce((d,p)=>d&&d[p],U),i=a?{...n(),url:"",tiles:[a.replace("{apikey}",n().apikey||import.meta.env?.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:U[s.split(":")[0]]._copy}:n();return i.tiles&&(i.tiles=["a","b","c"].map(d=>i.tiles[0].replace("{s}",d))),i};switch(t.map.addSource(e.id,r(n().url)),t.map.sourceIdList.push(e.id),o("Add Source:",e.id),n().type){case "geojson":createEffect(()=>{let s=n().data;t.map.getSource(e.id).setData(s||{}),o("Update GeoJSON Data:",e.id);});break;case "image":createEffect(()=>{let s=n().url,a=n().coordinates;t.map.getSource(e.id).updateImage(s,a),o("Update Image Data:",e.id);});break;case "vector":createEffect(()=>{let s=n().url,a=n().tiles,i=t.map.getSource(e.id);s?i.setUrl(s):i.setTiles(a),o("Update Vector Data:",e.id);});break;case "raster":createEffect(()=>{let s=r(n().url),a=t.map.getSource(e.id);s.url?a.setUrl(s.url):a.setTiles(s.tiles),o("Update Raster Data:",e.id);});break}return onCleanup(()=>{t.map?.getStyle().layers.forEach(s=>s.source===e.id&&t.map.removeLayer(s.id)),t.map?.getSource(e.id)&&t.map?.removeSource(e.id),o("Remove Source:",e.id);}),createComponent(oe.Provider,{get value(){return e.id},get children(){return e.children}})};var ne=["id","type","filter","source","source-layer","minzoom","metadata","maxzoom","paint","layout"],re=["visibility","line-join","line-cap","line-miter-limit","line-round-limit","line-sort-key","circle-sort-key","symbol-avoid-edges","symbol-placement","symbol-sort-key","symbol-spacing","symbol-z-order","icon-allow-overlap","icon-anchor","icon-ignore-placement","icon-image","icon-keep-upright","icon-offset","icon-optional","icon-padding","icon-pitch-alignment","icon-rotate","icon-rotation-alignment","icon-size","icon-text-fit","icon-text-fit-padding","text-allow-overlap","text-anchor","text-field","text-font","text-ignore-placement","text-justify","text-keep-upright","text-letter-spacing","text-line-height","text-max-angle","text-max-width","text-offset","text-optional","text-padding","text-pitch-alignment","text-radial-offset","text-rotate","text-rotation-alignment","text-size","text-transform","text-variable-anchor","text-writing-mode"];var ae=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce((n,r)=>{let s=e[r];return s!==t[r]&&n.push([r,s]),n},[]),G=(e,t)=>(e.startsWith(t)||e.startsWith("icon")||e.startsWith("text")?"":t+"-")+e.replace(/[A-Z]/g,o=>"-"+o.toLowerCase()),N=e=>{if(!e)return;let t={},o={},n={};return Object.entries(e).forEach(([r,s])=>{if(ne.includes(r))n[r]=s;else {let a=G(r,e.type);re.includes(a)?t[a]=s:o[a]=s;}}),e.paint&&Object.entries(e.paint).forEach(([r,s])=>o[G(r,e.type)]=s),e.layout&&Object.entries(e.layout).forEach(([r,s])=>t[G(r,e.type)]=s),{...n,paint:o,layout:t}},Ye=e=>{let[t]=h(),o=e.sourceId||e.style?.source||$(),n=e.id||e.customLayer?.id||createUniqueId(),r=(a,i)=>{(t.map.debug||t.map.debugEvents)&&console.debug("%c[MapGL]","color: #10b981",a,i||"");},s=createMemo(()=>e.beforeType?t.map.getStyle().layers.find(a=>a.type===e.beforeType)?.id:e.beforeId);return t.map.addLayer(e.customLayer||{...N(e.style),id:n,source:o,...t.isMapLibre?{}:{slot:e.slot||""},metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},s()),t.map.layerIdList.push(n),e.customLayer&&t.map.fire("load"),r("Add Layer:",n),J.forEach(a=>{if(e[a]){let i=a.slice(2).toLowerCase();t.map.on(i,n,d=>{d.clickOnLayer=true,e[a](d),t.map.debugEvents&&r(`Layer '${i}' event on '${n}':`,d);});}}),createEffect(a=>{let i=N(e.style);if(i!==a)return i.layout!==a?.layout&&ae(i.layout,a?.layout).forEach(([d,p])=>t.map.setLayoutProperty(n,d,p,{validate:false})),i.paint!==a?.paint&&ae(i.paint,a?.paint).forEach(([d,p])=>t.map.setPaintProperty(n,d,p,{validate:false})),(i.minzoom!==a?.minzoom||i.maxzoom!==a?.maxzoom)&&t.map.setLayerZoomRange(n,i.minzoom,i.maxzoom),i.filter!==a?.filter&&t.map.setFilter(n,i.filter,{validate:false}),r("Update Layer Style:",n),i},N(e.style)),createEffect(a=>{if(e.visible!==a)return t.map.setLayoutProperty(n,"visibility",e.visible?"visible":"none",{validate:false}),r(`Update Visibility (${n}):`,e.visible.toString()),e.visible},e.visible),createEffect(a=>s()===a?a:(t.map.moveLayer(n,s()),r(`Update Layer Z-Index (${n}):`,s()),s()),s()),createEffect(async()=>{e.filter&&(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.setFilter(n,e.filter),r(`Update Filter (${n}):`,e.filter));}),createEffect(async()=>{!e.featureState||e.featureState.id===null||(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:o,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:o,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state));}),onCleanup(()=>t.map?.getLayer(n)&&t.map?.removeLayer(n)),e.children};var ie=createContext(),ot=()=>useContext(ie),nt=e=>{let[t]=h(),[o,n]=createSignal(null);return onMount(async()=>{e.id=e.id||createUniqueId();let r=t.mapLib.MercatorCoordinate.fromLngLat([e.origin[0]||0,e.origin[1]||0],e.origin[2]||0),s=r.meterInMercatorCoordinateUnits(),{x:a,y:i,z:d}=r,p=null,f=null,g=null;e.babylon?(f=await import('@babylonjs/core'),p=f.Matrix.Compose(new f.Vector3(s,s,s),f.Quaternion.FromEulerAngles(Math.PI/2,0,0),new f.Vector3(a,i,d))):(g=await import('three'),p={translateX:a,translateY:i,translateZ:d,rotateX:Math.PI/2,rotateY:0,rotateZ:0,scale:s}),t.map.addLayer({id:e.id,type:"custom",renderingMode:"3d",onAdd(x,m){if(e.babylon){let v=new f.Engine(m,true,{useHighPrecisionMatrix:true},true);this.scene=new f.Scene(v),this.scene.autoClear=false,this.scene.preventDefaultOnPointerDown=false,this.scene.preventDefaultOnPointerUp=false;let w=new f.UniversalCamera("Camera",f.Vector3.Zero());w.mode=f.Camera.ORTHOGRAPHIC_CAMERA,w.inertia=0,this.scene.ambientColor=new f.Color3(1,1,1),e.defaultLight&&new f.HemisphericLight("Light",new f.Vector3(100,10,0),this.scene);}else this.camera=new g.Camera,this.scene=new g.Scene,e.defaultLight&&(this.light=new g.DirectionalLight(16777215),this.light.position.set(100,0,0).normalize(),this.scene.add(this.light)),this.renderer=new g.WebGLRenderer({canvas:x.getCanvas(),context:m,antialias:true}),this.renderer.autoClear=false;this.map=x,e.onAdd&&e.onAdd(this.scene,this.map,m),n(this.scene);},render(x,m){if(e.babylon){this.scene.activeCamera.freezeProjectionMatrix(p.multiply(f.Matrix.FromArray(m)));this.map.getPitch()*(Math.PI/180);this.map.getBearing()*(Math.PI/180);this.scene.render(false);}else {let v=new g.Matrix4().makeRotationAxis(new g.Vector3(1,0,0),p.rotateX),w=new g.Matrix4().makeRotationAxis(new g.Vector3(0,1,0),p.rotateY),l=new g.Matrix4().makeRotationAxis(new g.Vector3(0,0,1),p.rotateZ),c=new g.Matrix4().fromArray(m),u=new g.Matrix4().makeTranslation(p.translateX,p.translateY,p.translateZ).scale(new g.Vector3(p.scale,-p.scale,p.scale)).multiply(v).multiply(w).multiply(l);this.camera.projectionMatrix=c.multiply(u),this.renderer.resetState(),this.renderer.render(this.scene,this.camera);}e.onRender&&e.onRender(x,m),t.map.triggerRepaint();}},e.beforeId);}),onCleanup(()=>{t.map.getLayer(e.id)&&t.map.removeLayer(e.id);}),createComponent(ie.Provider,{value:o,get children(){return memo(()=>!!o())()&&e.children}})};var it=e=>{let[t]=h();return createEffect(()=>{t.isMapLibre?t.map.setSky?.(e.style||{}):t.map.setFog(e.style||{});}),onCleanup(()=>{t.isMapLibre?t.map.getSky?.()&&t.map.setSky(null):t.map.getFog()&&t.map.setFog(null);}),null};var ut=e=>{let[t]=h(),o=$();return !o&&!e?.source&&(o=createUniqueId(),t.map.addSource(o,{type:"raster-dem",url:t.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.isMapLibre?256:512,maxzoom:t.isMapLibre?void 0:14}),t.map.sourceIdList.push(o)),createEffect(()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e?.source||o});}),onCleanup(()=>t.map?.setTerrain(null)),null};var z=(e,t)=>{let[o]=h();createEffect(()=>{let n=e(),r=t?.();n&&(o.map.hasControl(n)&&o.map.removeControl(n),o.map.addControl(n,r));}),onCleanup(()=>{let n=e();n&&o.map.hasControl(n)&&o.map.removeControl(n);});};var yt=e=>{let[t]=h(),[o,n]=splitProps(e,["position"]),[r,s]=createSignal(null),a=new Map([["navigation",t.mapLib.NavigationControl],["scale",t.mapLib.ScaleControl],["attribution",t.mapLib.AttributionControl],["geolocate",t.mapLib.GeolocateControl],["fullscreen",t.mapLib.FullscreenControl],["logo",t.mapLib.LogoControl],["terrain",t.mapLib.TerrainControl]]);return createEffect(()=>{untrack(()=>r()&&t.map.hasControl(r())&&t.map.removeControl(r())),s(n.custom||new(a.get(n.type||"navigation"))(n.options));}),z(r,()=>o.position),null};var bt=e=>{if(!e.lngLat)throw new Error("Marker - lngLat is required");let[t,o,n]=splitProps(e,["lngLat","children","showPopup","draggable"],["popup","onOpen","onClose"]),[r]=h(),s=null,a=null,i=t.lngLat;return createEffect(()=>{r.map&&(a?.remove(),a=new r.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...o.popup}).on("open",()=>o.onOpen?.()).on("close",()=>o.onClose?.()),createEffect(()=>{t.children!==void 0&&(typeof t.children=="string"?a?.setHTML(t.children):a?.setDOMContent(t.children),s?.setPopup(a));}),createEffect(()=>t.showPopup!==a?.isOpen()&&s?.togglePopup()));}),createEffect(()=>{r.map&&(s?.remove(),s=new r.mapLib.Marker(n.options).on("dragstart",()=>n.onDragStart?.()).on("dragend",()=>n.onDragEnd?.()).on("drag",()=>n.onDrag?.(s?.getLngLat().toArray())).setPopup(a).setLngLat(i).addTo(r.map),createEffect(()=>t.showPopup!==a?.isOpen()&&s?.togglePopup()));}),createEffect(()=>s?.setLngLat(t.lngLat)),createEffect(()=>s?.setDraggable(t.draggable)),onCleanup(()=>s?.remove()),null};var Ct=e=>{if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");let[t,o]=splitProps(e,["lngLat","children","trackPointer"]),[n]=h(),r;return createEffect(()=>{n.map&&(r?.remove(),r=new n.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...o.options}).on("open",()=>o.onOpen?.()).on("close",()=>o.onClose?.()).addTo(n.map),createEffect(()=>t.trackPointer?r.trackPointer():r.setLngLat(t.lngLat)),createEffect(()=>typeof t.children=="string"?r.setHTML(t.children):r.setDOMContent(t.children)));}),onCleanup(()=>r?.remove()),null};var se={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:true},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:true}},Pt=Object.keys(se),_t=e=>{let[t]=h(),[o,n]=createSignal({width:0,height:0}),r=(i,d)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",i,d||"");};onCleanup(()=>{t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),r("Remove Image:",e.id);}),createEffect(()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern)throw new Error("Image - Image or Pattern is required");let i=e.pattern?{pixelRatio:2,...e.options}:e.options;s(e.source||a(e.pattern),d=>{let{width:p,height:f}=d;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,d,i),!e.pattern&&untrack(()=>p===o().width&&f===o().height)?(t.map.updateImage(e.id,d),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,d,i)),n({width:p,height:f}),r("Add Image:",e.id),t.map.on("style.load",()=>{t.map.hasImage(e.id)||(t.map.addImage(e.id,d,i),r("Re-Add Image:",e.id));});});});let s=(i,d)=>{if(typeof i=="string"&&i?.trimStart().startsWith("<svg")&&(i=new DOMParser().parseFromString(i,"image/svg+xml").childNodes[0]),i instanceof SVGElement&&(e.options?.fill&&i.setAttribute("fill",e.options.fill),e.options?.stroke&&i.setAttribute("stroke",e.options.stroke),i=new XMLSerializer().serializeToString(i)),typeof i!="string")return d(i);t.map.loadImage(i,async(p,f)=>{if(p){typeof i=="string"&&i?.trimEnd().endsWith(".svg")&&(i=await(await fetch(i)).text(),i=new DOMParser().parseFromString(i,"image/svg+xml").childNodes[0],i.setAttribute("fill",e.options.fill),i.setAttribute("stroke",e.options.stroke),i.setAttribute("transform",e.options.transform),i=new XMLSerializer().serializeToString(i));let g=new Image;g.crossOrigin="Anonymous",g.onload=()=>{let x=document.createElement("canvas");x.width=Math.max(g.width,50),x.height=Math.max(g.height,50);let m=x.getContext("2d");return m.imageSmoothingEnabled=true,m.drawImage(g,0,0,x.width,x.height),d(m.getImageData(0,0,x.width,x.height))},g.src=i.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+i:i;}else return d(f)});},a=i=>{let d=se[i.type];return {width:d.size,height:d.size,data:new Uint8Array(d.size*d.size*4),onAdd:function(){let p=document.createElement("canvas");p.width=p.height=d.size,this.ctx=p.getContext("2d",{willReadFrequently:true});},render:function(){return this.ctx.fillStyle=i.background||"transparent",this.ctx.fillRect(0,0,this.width,this.height),this.ctx.strokeStyle=this.ctx.fillStyle=i.color||"black",this.ctx.lineWidth=i.lineWith||1,this.ctx.stroke(new Path2D(d.path)),d.fill&&this.ctx.fill(new Path2D(d.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,true}}};return null};var Tt=(e,t,o)=>e.map((n,r)=>(1-o)*e[r]+o*t[r]),Dt=(e,t,o)=>{let n=e.map((s,a)=>e[a]*t[a]).reduce((s,a)=>s+a),r=Math.acos(n);return e.map((s,a)=>Math.sin((1-o)*r)/Math.sin(r)*e[a]+Math.sin(o*r)/Math.sin(r)*t[a])},Ot={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},zt=e=>{let[t]=h(),o=.1,n=false,[r,s]=createSignal(false);["mousedown","touchstart","wheel"].forEach(m=>t.map.on(m,v=>!v.rotate&&s(true))),["moveend","mouseup","touchend"].forEach(m=>t.map.on(m,v=>!v.rotate&&s(false)));let a=async([m,v,w],l)=>{let c=t.map.getFreeCameraOptions();c.position=t.mapLib.MercatorCoordinate.fromLngLat([m,v],w),c.lookAtPoint(l),t.map.setFreeCameraOptions(c);},i=()=>{e.translate&&window.requestAnimationFrame(i);let m=[e.translate.start,e.translate.end,e.translate.easing?Ot[e.translate.easing](o):o],v=e.translate.type==="line"?Tt(...m):Dt(...m);a(v,e.translate.target),!e.translate.loop&&(o>1||o<0)&&(n=!n),o=n?o-.001:o+.001;};createEffect(()=>{e.translate&&window.requestAnimationFrame(i);});let d={duration:1e3,easing:m=>m},p=()=>{if(r())return;let{secPerRev:m=120,maxSpinZoom:v=5,slowSpinZoom:w=3}=e.rotateGlobe,l=t.map.getZoom();if(l>v)return;let c=360/m;l>w&&(c*=(v-l)/(v-w));let u=t.map.getCenter();u.lng=e.reverse?u.lng+c:u.lng-c,t.map.easeTo({center:u,...d},{rotate:true});},f=()=>{if(!e.rotateViewport||r()){t.map.stop();return}let m=e.rotateViewport,v=m?.secPerRev||60,w=e.reverse?t.map.getBearing()+360/v:t.map.getBearing()-360/v,l=m?.pitch||60,c=m?.around;t.map.easeTo({bearing:w,pitch:l,around:c,...d},{rotate:true});},g=()=>e.rotateGlobe?p():f();t.map.on("moveend",g).on("dragend",g);let x;return createEffect(()=>{e.rotateGlobe!=null&&(e.rotateGlobe?(x=t.map.getCenter(),p()):e.resetWhenStopped?t.map.stop().easeTo({center:x}):t.map.stop());}),createEffect(()=>{e.rotateViewport!=null&&(e.rotateViewport?f():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop());}),onCleanup(()=>t.map.off("moveend",g).off("dragend",g)),e.children};var Rt=e=>{let[t]=h();return createEffect(()=>t.map.setLight(e.style||{})),onCleanup(()=>t.map?.setLight(null)),null};var T={};T.onSetup=function(e){var t={};return t.count=e.count||0,t};T.onClick=function(e,t){var o=this.newFeature({type:"Feature",properties:{count:e.count},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}});this.addFeature(o);};T.onKeyUp=function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")};T.toDisplayFeatures=function(e,t,o){o(t);};var le=T;var ce=e=>new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[0])+"\xB0 "+new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[1])+"\xB0",S=(e,t)=>{let o=pe({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}},{units:window.navigator.language==="en-US"?"miles":"kilometers"});return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=1?"foot":"mile"}).format(o<=1?o*5280:o):new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=1?"meter":"kilometer"}).format(o<=1?o*1e3:o),...t},geometry:{type:"Point",coordinates:Ut(e[0],e[1]).geometry.coordinates}}},F=(e,t)=>{let o=jt({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:e}});return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=10.764?"foot":"mile"}).format(o<=10.764?o*10.764:o*1.0000003861)+"\xB2":new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=1e6?"meter":"kilometer"}).format(o<=1e6?o:o/1e6)+"\xB2",...t},geometry:centerOfMass({type:"Polygon",coordinates:e}).geometry}};var ue=e=>{let t=e.modes.draw_line_string;return {...t,onSetup:function(){let o=t.onSetup.call(this),n=this.newFeature({type:"Feature",properties:{type:"measure",value:"TTT"},geometry:{type:"Point",coordinates:[]}});return {...o,measure:n}},onMouseMove:function(o,n){if(t.onMouseMove.call(this,o,n),o.line.coordinates.length>=2){let r=S(o.line.coordinates);o.measure.properties.value=r.properties.value,o.measure.updateCoordinate("",r.geometry.coordinates[0],r.geometry.coordinates[1]);}},toDisplayFeatures:function(o,n,r){t.toDisplayFeatures.call(this,o,n,r),this.drawConfig.userProperties.showLength&&r(o.measure.toGeoJSON());}}};var de=e=>{let t=e.modes.draw_point;return {...t,onSetup:function(){let o=t.onSetup.call(this);return o.point.properties={...o.point.properties,type:"measure",anchor:"bottom"},o},onMouseMove:function(o,{lngLat:n}){o.point.properties.value=ce([n.lng,n.lat]),o.point.updateCoordinate("",n.lng,n.lat);},toDisplayFeatures:function(o,n,r){let s=n.properties.id===o.point.id;return n.properties.active=s?"":"false",r(n)}}};var me=e=>{let t=e.modes.draw_polygon;return {...t,toDisplayFeatures:function(o,n,r){let s=a=>{if(r(a),this.drawConfig.userProperties.showLength){let i=Array.isArray(a.geometry.coordinates[0][0])?a.geometry.coordinates[0]:a.geometry.coordinates;i.forEach((d,p)=>{!Array.isArray(d)||p==0||r(S([i[p-1],d]));});}this.drawConfig.userProperties.showArea&&a.geometry.coordinates[0].length>=3&&r(F([a.geometry.coordinates[0]]));};t.toDisplayFeatures.call(this,o,n,s);}}};function Gt(e,t,o,n){return {type:"Feature",properties:{meta:"vertex",parent:e,coord_path:o,active:n?"true":"false"},geometry:{type:"Point",coordinates:t}}}function Nt(e,t,o,n=64){let r=[],s=t/(111.32*Math.cos(e[1]*Math.PI/180)),a=t/110.574;for(let i=0;i<n;i+=1){let d=i/n*(2*Math.PI),p=s*Math.cos(d),f=a*Math.sin(d);r.push([e[0]+p,e[1]+f]);}return r.push(r[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[r]},properties:{parent:o,active:"true"}}}var Bt={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);}},Xt=e=>({...e.modes.draw_line_string,clickAnywhere:function(t,o){return t.currentVertexPosition===1?(t.line.addCoordinate(0,o.lngLat.lng,o.lngLat.lat),this.changeMode("simple_select",{featureIds:[t.line.id]})):(this.updateUIClasses({mouse:"add"}),t.line.updateCoordinate(t.currentVertexPosition,o.lngLat.lng,o.lngLat.lat),t.direction==="forward"?(t.currentVertexPosition+=1,t.line.updateCoordinate(t.currentVertexPosition,o.lngLat.lng,o.lngLat.lat)):t.line.addCoordinate(0,o.lngLat.lng,o.lngLat.lat),null)},onStop:function(t){if(Bt.enable(this),this.activateUIButton(),this.getFeature(t.line.id)!==void 0)if(t.line.removeCoordinate("0"),t.line.isValid()){let o=t.line.toGeoJSON(),n=(pe(o)*1e3).toFixed(1),r=o.geometry.coordinates[0];this.deleteFeature([t.line.id],{silent:true});let s=this.newFeature({type:"Feature",properties:{radius:n},geometry:{type:"Point",coordinates:r}});this.addFeature(s),this.map.fire("draw.create",{features:[s.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[s.id]});}else this.deleteFeature([t.line.id],{silent:true}),this.changeMode("simple_select",{},{silent:true});},toDisplayFeatures:function(t,o,n){let r=o.properties.id===t.line.id;return o.properties.active=r?"true":"false",r?(o.geometry.coordinates.length<2||(o.properties.meta="feature",n(Gt(t.line.id,o.geometry.coordinates[t.direction==="forward"?o.geometry.coordinates.length-2:1],`${t.direction==="forward"?o.geometry.coordinates.length-2:1}`,false)),n(o),n(S(o.geometry.coordinates,{parent:t.line.id})),n(Nt(o.geometry.coordinates[0],pe(o),t.line.id))),null):n(o)}}),ge=Xt;var Yt=e=>({...e.modes.draw_line_string,onSetup:function(t){let o=e.modes.draw_line_string.onSetup.call(this,t),n=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(n),{...o,...t,rectangle:n}},onTap:function(t,o){t.startPoint&&this.onMouseMove(t,o),this.onClick(t,o);},onClick:function(t,o){t.startPoint&&t.startPoint[0]!==o.lngLat.lng&&t.startPoint[1]!==o.lngLat.lat?(this.updateUIClasses({mouse:"pointer"}),t.endPoint=[o.lngLat.lng,o.lngLat.lat],this.changeMode("simple_select",{featuresId:t.rectangle.id})):t.startPoint=[o.lngLat.lng,o.lngLat.lat];},onMouseMove:function(t,o){t.startPoint&&(t.rectangle.updateCoordinate("0.0",t.startPoint[0],t.startPoint[1]),t.rectangle.updateCoordinate("0.1",o.lngLat.lng,t.startPoint[1]),t.rectangle.updateCoordinate("0.2",o.lngLat.lng,o.lngLat.lat),t.rectangle.updateCoordinate("0.3",t.startPoint[0],o.lngLat.lat),t.rectangle.updateCoordinate("0.4",t.startPoint[0],t.startPoint[1]));},onKeyUp:function(t,o){if(o.keyCode===27)return this.changeMode("simple_select")},onStop:function(t){e.modes.draw_line_string.onStop.call(this,t),this.getFeature(t.rectangle.id)!==void 0&&(t.rectangle.removeCoordinate("0.4"),t.rectangle.isValid()?this.map.fire("draw.create",{features:[t.rectangle.toGeoJSON()]}):(this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(t,o,n){let r=o.properties.id===t.rectangle.id;if(o.properties.active=r?"true":"false",!r)return n(o);if(t.startPoint)return n(o),this.drawConfig.userProperties.showLength&&(n(S([o.geometry.coordinates[0][0],o.geometry.coordinates[0][1]],{parent:t.rectangle.id,anchor:"bottom"})),n(S([o.geometry.coordinates[0][1],o.geometry.coordinates[0][2]],{parent:t.rectangle.id,anchor:"left"}))),this.drawConfig.userProperties.showArea&&n(F(o.geometry.coordinates,{parent:t.rectangle.id})),null},onTrash:function(t){this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select");}}),fe=Yt;var he={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable();},0);}},qt={onSetup:function(e){let t=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),he.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:true}),{rectangle:t,currentVertexPosition:0}},onTap:function(e,t){this.onClick(e,t);},onClick:function(e,t){if(e.currentVertexPosition===2){let o=this.calculatepXY3(e,t,false);return o&&e.rectangle.updateCoordinate(`0.${e.currentVertexPosition+1}`,o[0],o[1]),this.updateUIClasses({mouse:"pointer"}),this.changeMode("simple_select",{featuresId:e.rectangle.id})}else e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat);},onMouseMove:function(e,t){if(e.rectangle.updateCoordinate("0."+e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition&&e.currentVertexPosition>0&&this.calculateOrientedAnglePolygon(e),e.currentVertexPosition===2){let o=this.calculatepXY3(e,t,true);o&&e.rectangle.updateCoordinate("0."+(e.currentVertexPosition+1),o[0],o[1]);}},deegrees2meters(e){let t=e[0]*2003750834e-2/180,o=Math.log(Math.tan((90+e[1])*Math.PI/360))/(Math.PI/180);return o=o*2003750834e-2/180,[t,o]},meters2degress(e){let t=e[0]*180/2003750834e-2,o=Math.atan(Math.exp(e[1]*Math.PI/2003750834e-2))*360/Math.PI-90;return [t,o]},calculateOrientedAnglePolygon:function(e){let t=e.rectangle.getCoordinate("0.0"),o=this.deegrees2meters(t),n=e.rectangle.getCoordinate("0.1"),r=this.deegrees2meters(n),a=-1*(Math.atan2(r[1]-o[1],r[0]-o[0])*180/Math.PI+90),i=a<0?a+360:a;e.angle=parseFloat(i.toFixed(2));},calculatepXY3:function(e,t,o){let n=e.rectangle.getCoordinate("0.0"),r=this.deegrees2meters(n),s=e.rectangle.getCoordinate("0.1"),a=this.deegrees2meters(s),i=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]),d=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]);if(r[0]===a[0])i=[d[0],a[1]];else if(r[1]===a[1])i=[a[0],d[1]];else {let v=-1/((a[1]-r[1])/(a[0]-r[0]));Math.abs(v)<1?i[1]=v*(d[0]-a[0])+a[1]:i[0]=a[0]+(i[1]-a[1])/v;}let p=[a[0]-r[0],a[1]-r[1]],f=[i[0]-p[0],i[1]-p[1]],g=this.meters2degress(i),x=this.meters2degress(f);return e.rectangle.updateCoordinate("0.2",g[0],g[1]),e.rectangle.updateCoordinate("0.3",x[0],x[1]),x},onKeyUp:function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")},onStop:function(e){he.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(e.rectangle.id)!==void 0&&(e.rectangle.removeCoordinate("0.4"),e.rectangle.isValid()?this.map.fire("draw.create",{features:[e.rectangle.toGeoJSON()]}):(this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(e,t,o){let n=t.properties.id===e.rectangle.id;if(t.properties.active=n?"true":"false",t.properties.angle=e.angle,t.angle=e.angle,!n)return o(t);let r=t.geometry.coordinates[0].length;if(r<3){let s=t.geometry.coordinates[0][0],a={type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:t.geometry.coordinates[0][0],type:"Point"}};s&&o(a);return}if(r>=3&&r<=4){let s=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(o({type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:s,type:"LineString"}}),r===3)return}return o(t)},onTrash:function(e){this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select");}},ye=qt;var ve=[{id:"measure-label",type:"symbol",filter:["all",["==","$type","Point"],["==","user_type","measure"]],layout:{"text-field":["get","user_value"],"text-anchor":["get","user_anchor"],"text-offset":["match",["get","user_anchor"],"bottom",[0,-0.5],[0,0]],"text-size":12,"text-allow-overlap":true,"text-ignore-placement":true},paint:{"text-halo-color":"rgba(255,255,255,0.75)","text-halo-width":2,"text-halo-blur":1,"text-color":"#000"}}];var Ht=e=>{let[t]=h();t.isMapLibre&&e.lib.constants?.classes&&Object.assign(e.lib.constants.classes,{CANVAS:"maplibregl-canvas",CONTROL_BASE:"maplibregl-ctrl",CONTROL_PREFIX:"maplibregl-ctrl-",CONTROL_GROUP:"maplibregl-ctrl-group",ATTRIBUTION:"maplibregl-ctrl-attrib"});let o=new e.lib({styles:[...e.lib.lib.theme,...ve],modes:{...e.lib.modes,draw_point:de(e.lib),draw_line_string:ue(e.lib),draw_polygon:me(e.lib),multi_point:le,radius:ge(e.lib),rectangle:fe(e.lib),rectangle_assisted:ye},userProperties:{showLength:e.showLength||false,showArea:e.showArea||false},...e.options});t.map.addControl(o,e.position||"top-right"),e.getInstance&&e.getInstance(o);let n={};return K.forEach(r=>{if(e[r]){let s=`draw.${r.slice(2).toLowerCase()}`,a=i=>e[r](i);n[s]=a,t.map.on(s,a);}}),onCleanup(()=>{Object.keys(n).forEach(r=>t.map.off(r,n[r])),t.map?.removeControl(o);}),null};var Kt=e=>{let[t]=h(),o;return z(()=>(o||(o=new e.overlay(e.props||{})),o)),createEffect(()=>o?.setProps(e.props||{})),null};
9
+ var fe={map:null,mapLib:null,isMapLibre:false,constants:{},themeVersion:0},he=createContext([fe]),w=()=>useContext(he),X=e=>{let[t,o]=createStore({...fe});return e.map&&o("map",e.map),e.mapLib&&o("mapLib",e.mapLib),o("isMapLibre",!!e.isMapLibre),o("constants",e.constants||{}),o("themeVersion",e.themeVersion||0),createEffect(()=>o("constants",e.constants||{})),createEffect(()=>o("themeVersion",e.themeVersion||0)),createComponent(he.Provider,{value:[t],get children(){return e.children}})};var ye=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],ve=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],Me=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"];var S="mapbox://styles/mapbox",I="https://raw.githubusercontent.com/",C="https://raw.githubusercontent.com/GIShub4/map-styles/main/",W="https://assets.vector.hereapi.com/styles/",be={mb:{standard:`${S}/standard`,light:`${S}/light-v11`,dark:`${S}/dark-v11`,street:`${S}/streets-v12`,outdoor:`${S}/outdoors-v12`,sat:`${S}/satellite-v9`,sat_street:`${S}/satellite-streets-v12`,nav_base:`${S}/navigation-guidance-day-v4`,nav_base_night:`${S}/navigation-guidance-night-v4`,nav:`${S}/navigation-day-v1`,nav_night:`${S}/navigation-night-v1`,basic:`${S}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${S}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${S}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${S}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${S}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${S}/cj44mfrt20f082snokim4ungi`,mineral:`${S}/cjtep62gq54l21frr1whf27ak`,moonlight:`${S}/cj3kbeqzo00022smj7akz3o1e`,frank:`${S}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${S}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${S}-map-design/ck4014y110wt61ctt07egsel6`,stand:`${S}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${S}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${S}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${S}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${I}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${I}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${I}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${I}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${I}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${I}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${I}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${I}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${W}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${W}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${W}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${C}esri:blueprint.json`,charted_territory:`${C}esri:charted-territory.json`,colored_pencil:`${C}esri:colored-pencil.json`,community:`${C}esri:community.json`,mid_century:`${C}esri:mid-century.json`,modern_antique:`${C}esri:modern-antique.json`,nat_geo:`${C}esri:national-geographic.json`,newspaper:`${C}esri:newspaper.json`,open_street_map:`${C}esri:open-street-map.json`,light_gray_canvas:`${C}esri:light-gray-canvas.json`,dark_gray_canvas:`${C}esri:dark-gray-canvas.json`,human_geo_light:`${C}esri:human-geography-light.json`,human_geo_dark:`${C}esri:human-geography-dark.json`,world_navigation:`${C}esri:world-navigation.json`,world_street:`${C}esri:world-street.json`,world_street_night:`${C}esri:world-street-night.json`,world_terrain:`${C}esri:world-terrain.json`,world_terrain_hybrid:`${C}esri:world-terrain-hybrid.json`,world_topographic:`${C}esri:world-topographic.json`,chromium:`${C}esri:chromium.json`,dreamcatcher:`${C}esri:dreamcatcher.json`,seahaven:`${C}esri:seahaven.json`,sangria:`${C}esri:sangria.json`,mercurial:`${C}esri:mercurial.json`,imagery:`${C}esri:imagery.json`,imagery_hybrid:`${C}esri:imagery-hybrid.json`,firefly:`${C}esri:firefly.json`,firefly_hybrid:`${C}esri:firefly-hybrid.json`,oceans:`${C}esri:oceans.json`}},H="https://{s}.basemaps.cartocdn.com/rastertiles/",U="https://stamen-tiles-{s}.a.ssl.fastly.net/",_="https://{s}.tile.thunderforest.com/",J={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>'},carto:{voyager:`${H}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${H}light_all/{z}/{x}/{y}{r}.png`,dark:`${H}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">&copy; Carto</a>'},stamen:{toner:`${U}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${U}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${U}watercolor/{z}/{x}/{y}.png`,terrain:`${U}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">&copy; Stamen Design</a>'},tf:{cycle:`${_}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${_}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${_}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${_}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${_}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${_}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${_}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${_}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${_}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${_}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">&copy; Thunderforest</a>'}};var O=()=>new Promise(e=>requestAnimationFrame(()=>e())),He=e=>{try{return !!e.style?.hasTransitions?.()}catch{return false}};function Je(e,t){return new Promise(o=>{let n=Date.now()+t,r=()=>{if(e.areTilesLoaded()){o(true);return}if(Date.now()>=n){o(false);return}setTimeout(r,100);};r();})}async function j(e,t={}){let{timeout:o=1e4,fadeMargin:n=400}=t;if(await Je(e,o),e.triggerRepaint(),await O(),await O(),n>0){let r=Date.now()+Math.max(n,2e3);for(;He(e)&&Date.now()<r;)e.triggerRepaint(),await O();await new Promise(i=>setTimeout(i,n)),e.triggerRepaint(),await O(),await O();}}function N(e,t={}){return new Promise(o=>{e.once("idle",()=>{j(e,t).then(o);});})}function K(e){for(let t of e.getStyle()?.layers??[])try{e.setPaintProperty(t.id,"raster-fade-duration",0);}catch{}}function xe(e,t){return {map:e,waitUntilSettled:()=>N(e,t),capture:(o="image/jpeg",n=.92)=>e.getCanvas().toDataURL(o,n),captureWhenSettled:async(o="image/jpeg",n=.92)=>(await N(e,t),e.getCanvas().toDataURL(o,n))}}var it=template("<div>"),st=template("<style>.overlay{position:relative;width:100%;height:100%;pointer-events:none}:where(.overlay>*){pointer-events:auto}"),lt=template("<div class=overlay>"),mt=e=>{let t,o,n,r,i,a=false,l=0,[d,s]=createSignal(null),[y,p]=createSignal(0),[b,u]=createSignal(!isServer&&(window.matchMedia("(prefers-color-scheme: dark)").matches||document.body.classList.contains("dark"))),f=false,M=false,h=(c,g)=>(e.debug||e.debugEvents)&&console.debug("%c[MapGL]","color: #0ea5e9",c,g||""),v=(c,g)=>{let m=b()&&g?g:c;return (typeof m=="string"||m instanceof String)&&m?.split(":").reduce((x,E)=>x&&x[E],be)?.replace("{apikey}",e.apikey||import.meta.env?.VITE_VECTOR_API_KEY)||m};onMount(async()=>{if(i=e.mapLib||await import('mapbox-gl'),i.Map||(i=window.maplibregl||window.mapboxgl),typeof i.supported=="function"&&!i.supported())throw new Error("Mapbox GL not supported");if(a=typeof i.Map?.prototype?.setConfigProperty!="function",h(`Map (v${i.version}) loading...`),t=new i.Map({accessToken:e.options?.accessToken||import.meta.env?.VITE_MAPBOX_ACCESS_TOKEN,interactive:e.options?.interactive||!!e.onViewportChange,...e.options,...e.viewport,projection:e.options?.projection,container:o,style:v(e.options?.style,e.darkStyle),fitBoundsOptions:{padding:e.viewport?.padding},...e.offscreen?{preserveDrawingBuffer:true}:{}}),t.debug=e.debug,t.debugEvents=e.debugEvents,t.sourceIdList=[],t.layerIdList=[],t.isMapLibre=a,ye.forEach(c=>{let g=e[c];if(g){let m=c.slice(2).toLowerCase();typeof g=="function"?t.on(m,x=>{setTimeout(()=>{x.clickOnLayer||(g(x),e.debugEvents&&h(`Map '${m}' event:`,x));},0);}):Object.keys(g).forEach(x=>{t.on(m,x,E=>{setTimeout(()=>{E.clickOnLayer||(g[x](E),e.debugEvents&&h(`Map '${m}' event on '${x}':`,E));},0);});});}}),e.onTilesLoaded){let c=e.tilesLoadedTimeout??1e4,g=e.tilesLoadedFadeMargin??400;t.on("idle",()=>{let m=++l;j(t,{timeout:c,fadeMargin:g}).then(()=>{m===l&&(h("Tiles settled"),e.onTilesLoaded());});});}t.once("load",()=>{s(t),h("Map loaded"),e.offscreen&&(e.offscreen.disableRasterFade!==false&&K(t),e.onCapturerReady?.(xe(t,{timeout:e.tilesLoadedTimeout??1e4,fadeMargin:e.tilesLoadedFadeMargin??400}))),["mousedown","touchstart","wheel"].forEach(g=>t.on(g,m=>!m.rotate&&e.onUserInteraction?.(true))),["moveend","mouseup","touchend"].forEach(g=>t.on(g,m=>!m.rotate&&e.onUserInteraction?.(false)));let c=!isServer&&window.matchMedia("(prefers-color-scheme: dark)");c?.addEventListener("change",()=>{u(c.matches),p(g=>g+1),h("Set dark theme to:",c.matches?.toString());}),r=new MutationObserver(()=>{let g=document.documentElement.classList.contains("dark")||document.body.classList.contains("dark");u(g),p(m=>m+1),h("Set theme to:",g);}),r.observe(document.documentElement,{attributes:true}),r.observe(document.body,{attributes:true}),e.disableResize||(n=new ResizeObserver(()=>{setTimeout(()=>{t?.resize();},0),h("Map resized");}),n.observe(o)),t.on("move",g=>{let m={...e.viewport,id:e.id,point:{x:g.originalEvent?.x,y:g.originalEvent?.y},center:e.viewport?.center?.lat?t.getCenter():[t.getCenter().lng,t.getCenter().lat],zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),inTransit:true,bounds:null};!g.viewport&&e.onViewportChange&&(M=true,e.onViewportChange(m));}),t.on("moveend",g=>{if(f||g.rotate||!e.onViewportChange)return;let m={...e.viewport,inTransit:false};M=true,e.onViewportChange(m);});});}),createEffect(on(()=>e.viewport,c=>{if(e.id!==c?.id)return;if(M){M=false;return}let g={...c,...c.bounds?t.cameraForBounds(c.bounds,{bearing:c?.bearing,pitch:c?.pitch,padding:c?.padding}):null};f=true,t.stop(),f=false,t[e.transitionType||"flyTo"](g),h(`Update Viewport (${e.transitionType||"flyTo"}):`,g);},{defer:true})),createEffect(()=>{let c=d();if(typeof c?.setConfigProperty!="function"){c&&e.config&&Object.keys(e.config).length&&h("Config prop is set but this map library has no setConfigProperty (Mapbox Standard Style only) \u2014 skipping");return}for(let g in e.config){if(!g||g==="id")continue;let m=e.config?.id||"basemap",x=e.config[g];c.setConfigProperty(m,g,x),h(`Set Config (${m}:${g}) to:`,x);}}),createEffect(()=>{let c=e.options?.projection;!t||!c||(t.setProjection(c),h("Set Projection to:",c));}),createEffect(()=>{let c=e.cursorStyle;!t||!c||(t.getCanvas().style.cursor=c,h("Set Cursor to:",c));});let L=(c,g)=>(g.forEach(m=>{let x=c.findIndex(E=>m.metadata.smg.beforeType?E.type===m.metadata.smg.beforeType:E.id===m.metadata.smg.beforeId);c=x===-1?[...c,m]:[...c.slice(0,x),m,...c.slice(x)];}),c);return createEffect(c=>{let g=v(e.options?.style,e.darkStyle);if(t?.isStyleLoaded()&&c!==g){let m=t.getStyle(),x=m.layers.filter(P=>t.layerIdList.includes(P.id)),E=Object.keys(m.sources).filter(P=>t.sourceIdList.includes(P)).reduce((P,pe)=>({...P,[pe]:m.sources[pe]}),{}),Y=e.shouldDiffStyle?e.shouldDiffStyle(c,g):true;t.setStyle(g,Y?void 0:{diff:false}),t.once("styledata",()=>{if(!x)return;let P=t.getStyle();t.setStyle({...P,sources:{...P.sources,...E},layers:L(P.layers,x),fog:m.fog,terrain:m.terrain,light:m.light}),h("Set Mapstyle to:",g);});}return g},e.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach(c=>{createEffect(()=>{let g=e[c];!t||!g||(t[c]=g,h(`Set ${c} to:`,g));});}),onCleanup(()=>{n?.disconnect(),r?.disconnect(),l++,t?.remove(),h("Map removed");}),(()=>{var c=it(),g=o;return typeof g=="function"?use(g,c):o=c,insert(c,(()=>{var m=memo(()=>!!d());return ()=>m()&&createComponent(X,{get map(){return d()},mapLib:i,isMapLibre:a,get constants(){return e.constants},get themeVersion(){return y()},get children(){return [st(),(()=>{var x=lt();return insert(x,()=>e.children),x})()]}})})()),effect(m=>{var x=e.id,E=e?.class,Y=e?.classList,P=e.offscreen?{position:"fixed",left:"-99999px",top:"-99999px",width:`${e.offscreen.width}px`,height:`${e.offscreen.height}px`,...e.style}:{width:"100%",height:"100%",...e.style};return x!==m.e&&setAttribute(c,"id",m.e=x),E!==m.t&&className(c,m.t=E),m.a=classList(c,Y,m.a),m.o=style(c,P,m.o),m},{e:void 0,t:void 0,a:void 0,o:void 0}),c})()};var Le=createContext(),R=()=>useContext(Le),vt=e=>{let[t]=w();e.id??=createUniqueId();let o=(i,a)=>{t.map.debug&&console.debug("%c[MapGL]","color: #ec4899",i,a||"");},n=()=>e.source,r=i=>{let a=i?.split(":").reduce((d,s)=>d&&d[s],J),l=a?{...n(),url:"",tiles:[a.replace("{apikey}",n().apikey||import.meta.env?.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:J[i.split(":")[0]]._copy}:n();return l.tiles&&(l.tiles=["a","b","c"].map(d=>l.tiles[0].replace("{s}",d))),l};switch(t.map.addSource(e.id,r(n().url)),t.map.sourceIdList.push(e.id),o("Add Source:",e.id),n().type){case "geojson":createEffect(()=>{let i=n().data;t.map.getSource(e.id).setData(i||{}),o("Update GeoJSON Data:",e.id);});break;case "image":createEffect(()=>{let i=n().url,a=n().coordinates;t.map.getSource(e.id).updateImage(i,a),o("Update Image Data:",e.id);});break;case "vector":createEffect(()=>{let i=n().url,a=n().tiles,l=t.map.getSource(e.id);i?l.setUrl(i):l.setTiles(a),o("Update Vector Data:",e.id);});break;case "raster":createEffect(()=>{let i=r(n().url),a=t.map.getSource(e.id);i.url?a.setUrl(i.url):a.setTiles(i.tiles),o("Update Raster Data:",e.id);});break}return onCleanup(()=>{t.map?.getStyle().layers.forEach(i=>i.source===e.id&&t.map.removeLayer(i.id)),t.map?.getSource(e.id)&&t.map?.removeSource(e.id),o("Remove Source:",e.id);}),createComponent(Le.Provider,{get value(){return e.id},get children(){return e.children}})};var Se=["id","type","filter","source","source-layer","minzoom","metadata","maxzoom","paint","layout"],Ee=["visibility","line-join","line-cap","line-miter-limit","line-round-limit","line-sort-key","circle-sort-key","symbol-avoid-edges","symbol-placement","symbol-sort-key","symbol-spacing","symbol-z-order","icon-allow-overlap","icon-anchor","icon-ignore-placement","icon-image","icon-keep-upright","icon-offset","icon-optional","icon-padding","icon-pitch-alignment","icon-rotate","icon-rotation-alignment","icon-size","icon-text-fit","icon-text-fit-padding","text-allow-overlap","text-anchor","text-field","text-font","text-ignore-placement","text-justify","text-keep-upright","text-letter-spacing","text-line-height","text-max-angle","text-max-width","text-offset","text-optional","text-padding","text-pitch-alignment","text-radial-offset","text-rotate","text-rotation-alignment","text-size","text-transform","text-variable-anchor","text-writing-mode"];var A,te=e=>(A??=document.body.appendChild(document.createElement("div")),A.style.cssText="position:absolute;visibility:hidden;pointer-events:none",A.style.color="",A.style.color=e,A.style.color?getComputedStyle(A).color:void 0),Mt=/^[a-z]+-\d{2,3}$/,bt=/^(rgb|rgba|hsl|hsla)\(/i,xt=/^[a-z-]+\(/i,z,wt=/^bg-[a-z]+-\d{2,3}(?:\s+dark:bg-[a-z]+-\d{2,3})?$/,Ct=e=>{z??=document.body.appendChild(document.createElement("div")),z.style.cssText="position:absolute;visibility:hidden;pointer-events:none",z.className=e;let t=getComputedStyle(z).backgroundColor;return z.className="",t&&t!=="rgba(0, 0, 0, 0)"?t:e},oe=e=>{if(wt.test(e))return Ct(e);if(Mt.test(e)){let t=getComputedStyle(document.documentElement).getPropertyValue(`--color-${e}`).trim();return t&&te(t)||e}return xt.test(e)&&!bt.test(e)&&te(e)||e},ne=e=>{let o=(te(oe(e))??e).match(/rgba?\(([^)]+)\)/i);if(!o)return [0,0,0,1];let[n,r,i,a=1]=o[1].split(",").map(Number);return [n,r,i,a]};var Et={property:"icon-halo-width",from:0,to:8,duration:1500,waveform:"out"},Pt=.75,kt=e=>1-(1-e)*(1-e),_t=(e,t,o)=>{let n=e%t/t;if(o==="in-out")return (1-Math.cos(n*Math.PI*2))/2;let r=Math.min(n/Pt,1);return kt(r)},$t=(e,t,o)=>{let n=Math.round(e[0]+(t[0]-e[0])*o),r=Math.round(e[1]+(t[1]-e[1])*o),i=Math.round(e[2]+(t[2]-e[2])*o),a=e[3]+(t[3]-e[3])*o;return `rgba(${n}, ${r}, ${i}, ${a})`},ke=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce((n,r)=>{let i=e[r];return i!==t[r]&&n.push([r,i]),n},[]),re=(e,t)=>(e.startsWith(t)||e.startsWith("icon")||e.startsWith("text")?"":t+"-")+e.replace(/[A-Z]/g,o=>"-"+o.toLowerCase()),It=(e,t)=>e.endsWith("color")&&typeof t=="string"?oe(t):t,Tt=/^@(.+)$/,ae=(e,t,o,n)=>{if(typeof t!="string")return t;let r=t.match(Tt);if(!r)return t;let i=o[r[1]];return i===void 0?(n(`Unknown constant "@${r[1]}" referenced by "${e}" \u2014 leaving unresolved`),t):i},ie=(e,t={},o=()=>{})=>{if(!e)return;let n={},r={},i={},a=(l,d)=>It(l,ae(l,d,t,o));return Object.entries(e).forEach(([l,d])=>{if(Se.includes(l))i[l]=d;else {let s=re(l,e.type);Ee.includes(s)?n[s]=ae(s,d,t,o):r[s]=a(s,d);}}),e.paint&&Object.entries(e.paint).forEach(([l,d])=>{let s=re(l,e.type);r[s]=a(s,d);}),e.layout&&Object.entries(e.layout).forEach(([l,d])=>{let s=re(l,e.type);n[s]=ae(s,d,t,o);}),{...i,paint:r,layout:n}},Ft=e=>{let[t]=w(),o=e.sourceId||e.style?.source||R(),n=e.id||e.customLayer?.id||createUniqueId(),r=(a,l)=>{(t.map.debug||t.map.debugEvents)&&console.debug("%c[MapGL]","color: #10b981",a,l||"");},i=createMemo(()=>e.beforeType?t.map.getStyle().layers.find(a=>a.type===e.beforeType)?.id:e.beforeId);return t.map.addLayer(e.customLayer||{...ie(e.style,t.constants,r),id:n,source:o,...t.isMapLibre?{}:{slot:e.slot||""},metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},i()),t.map.layerIdList.push(n),e.customLayer&&t.map.fire("load"),r("Add Layer:",n),ve.forEach(a=>{if(e[a]){let l=a.slice(2).toLowerCase();t.map.on(l,n,d=>{d.clickOnLayer=true,e[a](d),t.map.debugEvents&&r(`Layer '${l}' event on '${n}':`,d);});}}),createEffect(a=>{t.themeVersion;let l=ie(e.style,t.constants,r);if(l!==a)return l.layout!==a?.layout&&ke(l.layout,a?.layout).forEach(([d,s])=>t.map.setLayoutProperty(n,d,s,{validate:false})),l.paint!==a?.paint&&ke(l.paint,a?.paint).forEach(([d,s])=>t.map.setPaintProperty(n,d,s,{validate:false})),(l.minzoom!==a?.minzoom||l.maxzoom!==a?.maxzoom)&&t.map.setLayerZoomRange(n,l.minzoom,l.maxzoom),l.filter!==a?.filter&&t.map.setFilter(n,l.filter,{validate:false}),r("Update Layer Style:",n),l},ie(e.style,t.constants,r)),createEffect(a=>{if(e.visible!==a)return t.map.setLayoutProperty(n,"visibility",e.visible?"visible":"none",{validate:false}),r(`Update Visibility (${n}):`,e.visible.toString()),e.visible},e.visible),createEffect(a=>i()===a?a:(t.map.moveLayer(n,i()),r(`Update Layer Z-Index (${n}):`,i()),i()),i()),createEffect(async()=>{e.filter&&(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.setFilter(n,e.filter),r(`Update Filter (${n}):`,e.filter));}),createEffect(async()=>{!e.featureState||e.featureState.id===null||(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:o,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:o,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state));}),createEffect(()=>{if(!e.pulse)return;let l=(e.pulse===true?[{}]:Array.isArray(e.pulse)?e.pulse:[e.pulse]).map(p=>{let{property:b,from:u,to:f,duration:M,waveform:h}={...Et,...p},v=typeof u=="string"||typeof f=="string",[L,c]=h==="in"?[f,u]:[u,f];return {property:b,duration:M,waveform:h,isColor:v,fromNum:v?0:L,toNum:v?0:c,fromRgba:v?ne(L):null,toRgba:v?ne(c):null}}),d=performance.now(),s,y=p=>{let b=p-d;l.forEach(u=>{let f=_t(b,u.duration,u.waveform),M=u.isColor?$t(u.fromRgba,u.toRgba,f):u.fromNum+(u.toNum-u.fromNum)*f;t.map.setPaintProperty(n,u.property,M,{validate:false});}),s=window.requestAnimationFrame(y);};s=window.requestAnimationFrame(y),r(`Start Pulse (${n}):`,e.pulse),onCleanup(()=>window.cancelAnimationFrame(s));}),onCleanup(()=>t.map?.getLayer(n)&&t.map?.removeLayer(n)),e.children};var _e=createContext(),Nt=()=>useContext(_e),Zt=e=>{let[t]=w(),[o,n]=createSignal(null);return onMount(async()=>{e.id=e.id||createUniqueId();let r=t.mapLib.MercatorCoordinate.fromLngLat([e.origin[0]||0,e.origin[1]||0],e.origin[2]||0),i=r.meterInMercatorCoordinateUnits(),{x:a,y:l,z:d}=r,s=null,y=null,p=null;e.babylon?(y=await import('@babylonjs/core'),s=y.Matrix.Compose(new y.Vector3(i,i,i),y.Quaternion.FromEulerAngles(Math.PI/2,0,0),new y.Vector3(a,l,d))):(p=await import('three'),s={translateX:a,translateY:l,translateZ:d,rotateX:Math.PI/2,rotateY:0,rotateZ:0,scale:i}),t.map.addLayer({id:e.id,type:"custom",renderingMode:"3d",onAdd(b,u){if(e.babylon){let f=new y.Engine(u,true,{useHighPrecisionMatrix:true},true);this.scene=new y.Scene(f),this.scene.autoClear=false,this.scene.preventDefaultOnPointerDown=false,this.scene.preventDefaultOnPointerUp=false;let M=new y.UniversalCamera("Camera",y.Vector3.Zero());M.mode=y.Camera.ORTHOGRAPHIC_CAMERA,M.inertia=0,this.scene.ambientColor=new y.Color3(1,1,1),e.defaultLight&&new y.HemisphericLight("Light",new y.Vector3(100,10,0),this.scene);}else this.camera=new p.Camera,this.scene=new p.Scene,e.defaultLight&&(this.light=new p.DirectionalLight(16777215),this.light.position.set(100,0,0).normalize(),this.scene.add(this.light)),this.renderer=new p.WebGLRenderer({canvas:b.getCanvas(),context:u,antialias:true}),this.renderer.autoClear=false;this.map=b,e.onAdd&&e.onAdd(this.scene,this.map,u),n(this.scene);},render(b,u){if(e.babylon){this.scene.activeCamera.freezeProjectionMatrix(s.multiply(y.Matrix.FromArray(u)));this.map.getPitch()*(Math.PI/180);this.map.getBearing()*(Math.PI/180);this.scene.render(false);}else {let f=new p.Matrix4().makeRotationAxis(new p.Vector3(1,0,0),s.rotateX),M=new p.Matrix4().makeRotationAxis(new p.Vector3(0,1,0),s.rotateY),h=new p.Matrix4().makeRotationAxis(new p.Vector3(0,0,1),s.rotateZ),v=new p.Matrix4().fromArray(u),L=new p.Matrix4().makeTranslation(s.translateX,s.translateY,s.translateZ).scale(new p.Vector3(s.scale,-s.scale,s.scale)).multiply(f).multiply(M).multiply(h);this.camera.projectionMatrix=v.multiply(L),this.renderer.resetState(),this.renderer.render(this.scene,this.camera);}e.onRender&&e.onRender(b,u),t.map.triggerRepaint();}},e.beforeId);}),onCleanup(()=>{t.map.getLayer(e.id)&&t.map.removeLayer(e.id);}),createComponent(_e.Provider,{value:o,get children(){return memo(()=>!!o())()&&e.children}})};var Bt=e=>{let[t]=w();return createEffect(()=>{t.isMapLibre?t.map.setSky?.(e.style||{}):t.map.setFog(e.style||{});}),onCleanup(()=>{t.isMapLibre?t.map.getSky?.()&&t.map.setSky(null):t.map.getFog()&&t.map.setFog(null);}),null};var Ht=e=>{let[t]=w(),o=R();return !o&&!e?.source&&(o=createUniqueId(),t.map.addSource(o,{type:"raster-dem",url:t.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.isMapLibre?256:512,maxzoom:t.isMapLibre?void 0:14}),t.map.sourceIdList.push(o)),createEffect(()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e?.source||o});}),onCleanup(()=>t.map?.setTerrain(null)),null};var q=(e,t)=>{let[o]=w();createEffect(()=>{let n=e(),r=t?.();n&&(o.map.hasControl(n)&&o.map.removeControl(n),o.map.addControl(n,r));}),onCleanup(()=>{let n=e();n&&o.map.hasControl(n)&&o.map.removeControl(n);});};var no=e=>{let[t]=w(),[o,n]=splitProps(e,["position"]),[r,i]=createSignal(null),a=new Map([["navigation",t.mapLib.NavigationControl],["scale",t.mapLib.ScaleControl],["attribution",t.mapLib.AttributionControl],["geolocate",t.mapLib.GeolocateControl],["fullscreen",t.mapLib.FullscreenControl],["logo",t.mapLib.LogoControl],["terrain",t.mapLib.TerrainControl]]);return createEffect(()=>{untrack(()=>r()&&t.map.hasControl(r())&&t.map.removeControl(r())),i(n.custom||new(a.get(n.type||"navigation"))(n.options));}),q(r,()=>o.position),null};var io=e=>{if(!e.lngLat)throw new Error("Marker - lngLat is required");let[t,o,n]=splitProps(e,["lngLat","children","showPopup","draggable"],["popup","onOpen","onClose"]),[r]=w(),i=null,a=null,l=t.lngLat;return createEffect(()=>{r.map&&(a?.remove(),a=new r.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...o.popup}).on("open",()=>o.onOpen?.()).on("close",()=>o.onClose?.()),createEffect(()=>{t.children!==void 0&&(typeof t.children=="string"?a?.setHTML(t.children):a?.setDOMContent(t.children),i?.setPopup(a));}),createEffect(()=>t.showPopup!==a?.isOpen()&&i?.togglePopup()));}),createEffect(()=>{r.map&&(i?.remove(),i=new r.mapLib.Marker(n.options).on("dragstart",()=>n.onDragStart?.()).on("dragend",()=>n.onDragEnd?.()).on("drag",()=>n.onDrag?.(i?.getLngLat().toArray())).setPopup(a).setLngLat(l).addTo(r.map),createEffect(()=>t.showPopup!==a?.isOpen()&&i?.togglePopup()));}),createEffect(()=>i?.setLngLat(t.lngLat)),createEffect(()=>i?.setDraggable(t.draggable)),onCleanup(()=>i?.remove()),null};var co=e=>{if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");let[t,o]=splitProps(e,["lngLat","children","trackPointer"]),[n]=w(),r;return createEffect(()=>{n.map&&(r?.remove(),r=new n.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...o.options}).on("open",()=>o.onOpen?.()).on("close",()=>o.onClose?.()).addTo(n.map),createEffect(()=>t.trackPointer?r.trackPointer():r.setLngLat(t.lngLat)),createEffect(()=>typeof t.children=="string"?r.setHTML(t.children):r.setDOMContent(t.children)));}),onCleanup(()=>r?.remove()),null};var le=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-Math.pow(e/255,.45454545454545453);le[e]=t*Math.abs(t);}le[255]=-1e20;function $e(e,t,o,n,r,i,a){i[0]=0,a[0]=-1e20,a[1]=1e20,r[0]=e[t];for(let l=1,d=0,s=0;l<n;l++){r[l]=e[t+l*o];let y=l*l;do{let p=i[d];s=(r[l]-r[p]+y-p*p)/(l-p)/2;}while(s<=a[d]&&--d>-1);d++,i[d]=l,a[d]=s,a[d+1]=1e20;}for(let l=0,d=0;l<n;l++){for(;a[d+1]<l;)d++;let s=i[d],y=l-s;e[t+l*o]=r[s]+y*y;}}function Ie(e,t,o,n,r,i){for(let a=0;a<t;a++)$e(e,a,t,o,n,r,i);for(let a=0;a<o;a++)$e(e,a*t,1,t,n,r,i);}var ce=({radius:e=8}={})=>Math.ceil(e);function G(e,{radius:t=8,cutoff:o=.25}={}){let{width:n,height:r}=e,i=n*r,a=new Float64Array(i).fill(1e20),l=new Float64Array(i),d=Math.max(n,r),s=new Float64Array(d),y=new Uint16Array(d),p=new Float64Array(d+1),b=e.data;for(let h=0,v=3;h<i;h++,v+=4){let L=b[v];if(L===0)continue;let c=le[L];a[h]=Math.max(0,c),l[h]=Math.max(0,-c);}Ie(a,n,r,s,y,p),Ie(l,n,r,s,y,p);let u=255/t,f=255*(1-o),M=new Uint8ClampedArray(i*4);for(let h=0,v=0;h<i;h++,v+=4){let L=Math.sqrt(a[h])-Math.sqrt(l[h]),c=Math.max(0,Math.min(255,Math.round(f-u*L)));M[v]=M[v+1]=M[v+2]=255,M[v+3]=c;}return {width:n,height:r,data:M}}var de={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:true},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:true},grid:{size:20,path:"M10 0V20M0 10H20"},brick:{size:40,path:"M0 0H40M0 20H40M0 40H40M0 0V20M20 0V20M40 0V20M10 20V40M30 20V40"},wave:{size:20,path:"M0 5Q5 0 10 5T20 5M0 15Q5 10 10 15T20 15"}},Te=Object.keys(de),k=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">${e}</svg>`,ue={square:k('<rect x="8" y="8" width="48" height="48" fill="#000"/>'),circle:k('<circle cx="32" cy="32" r="28" fill="#000"/>'),triangle:k('<polygon points="32,6 60,56 4,56" fill="#000"/>'),diamond:k('<polygon points="32,4 60,32 32,60 4,32" fill="#000"/>'),pentagon:k('<polygon points="32,4 59,23 48,55 16,55 5,23" fill="#000"/>'),hexagon:k('<polygon points="32,4 56,18 56,46 32,60 8,46 8,18" fill="#000"/>'),octagon:k('<polygon points="20,4 44,4 60,20 60,44 44,60 20,60 4,44 4,20" fill="#000"/>'),cross:k('<polygon points="20,4 44,4 44,20 60,20 60,44 44,44 44,60 20,60 20,44 4,44 4,20 20,20" fill="#000"/>'),x:k('<polygon points="43,4 60,21 49,32 60,43 43,60 32,49 21,60 4,43 15,32 4,21 21,4 32,15" fill="#000"/>'),star:k('<polygon points="32,2 39,23 61,23 43,36 50,56 32,44 14,56 21,36 4,23 25,23" fill="#000"/>')},Fe=Object.keys(ue),Ae=e=>k(`<path d="${e}" fill="#000"/>`);var fo=e=>{let[t]=w(),[o,n]=createSignal({width:0,height:0}),r=null,i=(s,y)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",s,y||"");},a=()=>{!r||!t.map||t.map.hasImage(e.id)||(t.map.addImage(e.id,r.data,r.ops),i("Re-Add Image:",e.id));};t.map.on("style.load",a),onCleanup(()=>{t.map?.off("style.load",a),t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),i("Remove Image:",e.id);}),createEffect(()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern&&!e.symbol)throw new Error("Image - Image, Pattern or Symbol is required");let s=Math.max(1,Math.round(window.devicePixelRatio||2)),y=e.pattern?{pixelRatio:s,...e.options}:e.sdf?{...e.options,sdf:true}:e.options,p=e.symbol&&(ue[e.symbol]||(e.symbol.trimStart().startsWith("<svg")?e.symbol:Ae(e.symbol)));l(e.source||p||d(e.pattern,s),(b,u)=>{let f=u?{...y,pixelRatio:u}:y,{width:M,height:h}=b;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,b,f),!e.pattern&&untrack(()=>M===o().width&&h===o().height)?(t.map.updateImage(e.id,b),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,b,f)),n({width:M,height:h}),r={data:b,ops:f},i("Add Image:",e.id);});});let l=(s,y)=>{let p=e.sdf?typeof e.sdf=="object"?e.sdf:{}:null;if(typeof s=="string"&&s?.trimStart().startsWith("<svg")&&(s=new DOMParser().parseFromString(s,"image/svg+xml").childNodes[0]),s instanceof SVGElement&&(e.options?.fill&&s.setAttribute("fill",e.options.fill),e.options?.stroke&&s.setAttribute("stroke",e.options.stroke),s=new XMLSerializer().serializeToString(s)),typeof s!="string")return y(s);t.map.loadImage(s,async(b,u)=>{if(b){typeof s=="string"&&s?.trimEnd().endsWith(".svg")&&(s=await(await fetch(s)).text(),s=new DOMParser().parseFromString(s,"image/svg+xml").childNodes[0],s.setAttribute("fill",e.options.fill),s.setAttribute("stroke",e.options.stroke),s.setAttribute("transform",e.options.transform),s=new XMLSerializer().serializeToString(s));let f=new Image;f.crossOrigin="Anonymous",f.onload=()=>{let M=Math.max(1,50/Math.min(f.width,f.height)),h=e.options?.pixelRatio??Math.max(1,Math.round(window.devicePixelRatio||1)),v=M*h,L=p?ce(p)*h:0,c=Math.round(f.width*v),g=Math.round(f.height*v),m=document.createElement("canvas");m.width=c+L*2,m.height=g+L*2;let x=m.getContext("2d");x.imageSmoothingEnabled=true,x.drawImage(f,L,L,c,g);let E=x.getImageData(0,0,m.width,m.height);return y(p?G(E,p):E,h)},f.onerror=M=>console.error(`[MapGL] Image "${e.id}" failed to load:`,M),f.src=s.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(s):s;}else {if(!p)return y(u);let{width:f,height:M}=u,h=ce(p),v=document.createElement("canvas");v.width=f+h*2,v.height=M+h*2;let L=v.getContext("2d");L.imageSmoothingEnabled=true,"data"in u?L.putImageData(u,h,h):L.drawImage(u,h,h,f,M);let c=L.getImageData(0,0,v.width,v.height);return y(G(c,p))}});},d=(s,y=2)=>{let p=de[s.type],b=p.size*y;return {width:b,height:b,data:new Uint8Array(b*b*4),onAdd:function(){let u=document.createElement("canvas");u.width=u.height=b,this.ctx=u.getContext("2d",{willReadFrequently:true}),this.ctx.scale(y,y);},render:function(){return this.ctx.fillStyle=s.background||"transparent",this.ctx.fillRect(0,0,p.size,p.size),this.ctx.strokeStyle=this.ctx.fillStyle=s.color||"black",this.ctx.lineWidth=s.lineWidth||1,this.ctx.stroke(new Path2D(p.path)),p.fill&&this.ctx.fill(new Path2D(p.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,true}}};return null};var vo=(e,t,o)=>e.map((n,r)=>(1-o)*e[r]+o*t[r]),Mo=(e,t,o)=>{let n=e.map((i,a)=>e[a]*t[a]).reduce((i,a)=>i+a),r=Math.acos(n);return e.map((i,a)=>Math.sin((1-o)*r)/Math.sin(r)*e[a]+Math.sin(o*r)/Math.sin(r)*t[a])},bo={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},xo=e=>{let[t]=w(),o=.1,n=false,[r,i]=createSignal(false);["mousedown","touchstart","wheel"].forEach(u=>t.map.on(u,f=>!f.rotate&&i(true))),["moveend","mouseup","touchend"].forEach(u=>t.map.on(u,f=>!f.rotate&&i(false)));let a=async([u,f,M],h)=>{let v=t.map.getFreeCameraOptions();v.position=t.mapLib.MercatorCoordinate.fromLngLat([u,f],M),v.lookAtPoint(h),t.map.setFreeCameraOptions(v);},l=()=>{e.translate&&window.requestAnimationFrame(l);let u=[e.translate.start,e.translate.end,e.translate.easing?bo[e.translate.easing](o):o],f=e.translate.type==="line"?vo(...u):Mo(...u);a(f,e.translate.target),!e.translate.loop&&(o>1||o<0)&&(n=!n),o=n?o-.001:o+.001;};createEffect(()=>{e.translate&&window.requestAnimationFrame(l);});let d={duration:1e3,easing:u=>u},s=()=>{if(r())return;let{secPerRev:u=120,maxSpinZoom:f=5,slowSpinZoom:M=3}=e.rotateGlobe,h=t.map.getZoom();if(h>f)return;let v=360/u;h>M&&(v*=(f-h)/(f-M));let L=t.map.getCenter();L.lng=e.reverse?L.lng+v:L.lng-v,t.map.easeTo({center:L,...d},{rotate:true});},y=()=>{if(!e.rotateViewport||r()){t.map.stop();return}let u=e.rotateViewport,f=u?.secPerRev||60,M=e.reverse?t.map.getBearing()+360/f:t.map.getBearing()-360/f,h=u?.pitch||60,v=u?.around;t.map.easeTo({bearing:M,pitch:h,around:v,...d},{rotate:true});},p=()=>e.rotateGlobe?s():y();t.map.on("moveend",p).on("dragend",p);let b;return createEffect(()=>{e.rotateGlobe!=null&&(e.rotateGlobe?(b=t.map.getCenter(),s()):e.resetWhenStopped?t.map.stop().easeTo({center:b}):t.map.stop());}),createEffect(()=>{e.rotateViewport!=null&&(e.rotateViewport?y():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop());}),onCleanup(()=>t.map.off("moveend",p).off("dragend",p)),e.children};var Lo=e=>{let[t]=w();return createEffect(()=>t.map.setLight(e.style||{})),onCleanup(()=>t.map?.setLight(null)),null};var V={};V.onSetup=function(e){var t={};return t.count=e.count||0,t};V.onClick=function(e,t){var o=this.newFeature({type:"Feature",properties:{count:e.count},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}});this.addFeature(o);};V.onKeyUp=function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")};V.toDisplayFeatures=function(e,t,o){o(t);};var De=V;var Oe=e=>new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[0])+"\xB0 "+new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[1])+"\xB0",$=(e,t)=>{let o=Ue({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}},{units:window.navigator.language==="en-US"?"miles":"kilometers"});return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=1?"foot":"mile"}).format(o<=1?o*5280:o):new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=1?"meter":"kilometer"}).format(o<=1?o*1e3:o),...t},geometry:{type:"Point",coordinates:Po(e[0],e[1]).geometry.coordinates}}},B=(e,t)=>{let o=Eo({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:e}});return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=10.764?"foot":"mile"}).format(o<=10.764?o*10.764:o*1.0000003861)+"\xB2":new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:o<=1e6?"meter":"kilometer"}).format(o<=1e6?o:o/1e6)+"\xB2",...t},geometry:centerOfMass({type:"Polygon",coordinates:e}).geometry}};var Re=e=>{let t=e.modes.draw_line_string;return {...t,onSetup:function(){let o=t.onSetup.call(this),n=this.newFeature({type:"Feature",properties:{type:"measure",value:"TTT"},geometry:{type:"Point",coordinates:[]}});return {...o,measure:n}},onMouseMove:function(o,n){if(t.onMouseMove.call(this,o,n),o.line.coordinates.length>=2){let r=$(o.line.coordinates);o.measure.properties.value=r.properties.value,o.measure.updateCoordinate("",r.geometry.coordinates[0],r.geometry.coordinates[1]);}},toDisplayFeatures:function(o,n,r){t.toDisplayFeatures.call(this,o,n,r),this.drawConfig.userProperties.showLength&&r(o.measure.toGeoJSON());}}};var ze=e=>{let t=e.modes.draw_point;return {...t,onSetup:function(){let o=t.onSetup.call(this);return o.point.properties={...o.point.properties,type:"measure",anchor:"bottom"},o},onMouseMove:function(o,{lngLat:n}){o.point.properties.value=Oe([n.lng,n.lat]),o.point.updateCoordinate("",n.lng,n.lat);},toDisplayFeatures:function(o,n,r){let i=n.properties.id===o.point.id;return n.properties.active=i?"":"false",r(n)}}};var Ve=e=>{let t=e.modes.draw_polygon;return {...t,toDisplayFeatures:function(o,n,r){let i=a=>{if(r(a),this.drawConfig.userProperties.showLength){let l=Array.isArray(a.geometry.coordinates[0][0])?a.geometry.coordinates[0]:a.geometry.coordinates;l.forEach((d,s)=>{!Array.isArray(d)||s==0||r($([l[s-1],d]));});}this.drawConfig.userProperties.showArea&&a.geometry.coordinates[0].length>=3&&r(B([a.geometry.coordinates[0]]));};t.toDisplayFeatures.call(this,o,n,i);}}};function _o(e,t,o,n){return {type:"Feature",properties:{meta:"vertex",parent:e,coord_path:o,active:n?"true":"false"},geometry:{type:"Point",coordinates:t}}}function $o(e,t,o,n=64){let r=[],i=t/(111.32*Math.cos(e[1]*Math.PI/180)),a=t/110.574;for(let l=0;l<n;l+=1){let d=l/n*(2*Math.PI),s=i*Math.cos(d),y=a*Math.sin(d);r.push([e[0]+s,e[1]+y]);}return r.push(r[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[r]},properties:{parent:o,active:"true"}}}var Io={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);}},To=e=>({...e.modes.draw_line_string,clickAnywhere:function(t,o){return t.currentVertexPosition===1?(t.line.addCoordinate(0,o.lngLat.lng,o.lngLat.lat),this.changeMode("simple_select",{featureIds:[t.line.id]})):(this.updateUIClasses({mouse:"add"}),t.line.updateCoordinate(t.currentVertexPosition,o.lngLat.lng,o.lngLat.lat),t.direction==="forward"?(t.currentVertexPosition+=1,t.line.updateCoordinate(t.currentVertexPosition,o.lngLat.lng,o.lngLat.lat)):t.line.addCoordinate(0,o.lngLat.lng,o.lngLat.lat),null)},onStop:function(t){if(Io.enable(this),this.activateUIButton(),this.getFeature(t.line.id)!==void 0)if(t.line.removeCoordinate("0"),t.line.isValid()){let o=t.line.toGeoJSON(),n=(Ue(o)*1e3).toFixed(1),r=o.geometry.coordinates[0];this.deleteFeature([t.line.id],{silent:true});let i=this.newFeature({type:"Feature",properties:{radius:n},geometry:{type:"Point",coordinates:r}});this.addFeature(i),this.map.fire("draw.create",{features:[i.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[i.id]});}else this.deleteFeature([t.line.id],{silent:true}),this.changeMode("simple_select",{},{silent:true});},toDisplayFeatures:function(t,o,n){let r=o.properties.id===t.line.id;return o.properties.active=r?"true":"false",r?(o.geometry.coordinates.length<2||(o.properties.meta="feature",n(_o(t.line.id,o.geometry.coordinates[t.direction==="forward"?o.geometry.coordinates.length-2:1],`${t.direction==="forward"?o.geometry.coordinates.length-2:1}`,false)),n(o),n($(o.geometry.coordinates,{parent:t.line.id})),n($o(o.geometry.coordinates[0],Ue(o),t.line.id))),null):n(o)}}),je=To;var Fo=e=>({...e.modes.draw_line_string,onSetup:function(t){let o=e.modes.draw_line_string.onSetup.call(this,t),n=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(n),{...o,...t,rectangle:n}},onTap:function(t,o){t.startPoint&&this.onMouseMove(t,o),this.onClick(t,o);},onClick:function(t,o){t.startPoint&&t.startPoint[0]!==o.lngLat.lng&&t.startPoint[1]!==o.lngLat.lat?(this.updateUIClasses({mouse:"pointer"}),t.endPoint=[o.lngLat.lng,o.lngLat.lat],this.changeMode("simple_select",{featuresId:t.rectangle.id})):t.startPoint=[o.lngLat.lng,o.lngLat.lat];},onMouseMove:function(t,o){t.startPoint&&(t.rectangle.updateCoordinate("0.0",t.startPoint[0],t.startPoint[1]),t.rectangle.updateCoordinate("0.1",o.lngLat.lng,t.startPoint[1]),t.rectangle.updateCoordinate("0.2",o.lngLat.lng,o.lngLat.lat),t.rectangle.updateCoordinate("0.3",t.startPoint[0],o.lngLat.lat),t.rectangle.updateCoordinate("0.4",t.startPoint[0],t.startPoint[1]));},onKeyUp:function(t,o){if(o.keyCode===27)return this.changeMode("simple_select")},onStop:function(t){e.modes.draw_line_string.onStop.call(this,t),this.getFeature(t.rectangle.id)!==void 0&&(t.rectangle.removeCoordinate("0.4"),t.rectangle.isValid()?this.map.fire("draw.create",{features:[t.rectangle.toGeoJSON()]}):(this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(t,o,n){let r=o.properties.id===t.rectangle.id;if(o.properties.active=r?"true":"false",!r)return n(o);if(t.startPoint)return n(o),this.drawConfig.userProperties.showLength&&(n($([o.geometry.coordinates[0][0],o.geometry.coordinates[0][1]],{parent:t.rectangle.id,anchor:"bottom"})),n($([o.geometry.coordinates[0][1],o.geometry.coordinates[0][2]],{parent:t.rectangle.id,anchor:"left"}))),this.drawConfig.userProperties.showArea&&n(B(o.geometry.coordinates,{parent:t.rectangle.id})),null},onTrash:function(t){this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select");}}),Ne=Fo;var Ze={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable();},0);}},Ao={onSetup:function(e){let t=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),Ze.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:true}),{rectangle:t,currentVertexPosition:0}},onTap:function(e,t){this.onClick(e,t);},onClick:function(e,t){if(e.currentVertexPosition===2){let o=this.calculatepXY3(e,t,false);return o&&e.rectangle.updateCoordinate(`0.${e.currentVertexPosition+1}`,o[0],o[1]),this.updateUIClasses({mouse:"pointer"}),this.changeMode("simple_select",{featuresId:e.rectangle.id})}else e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat);},onMouseMove:function(e,t){if(e.rectangle.updateCoordinate("0."+e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition&&e.currentVertexPosition>0&&this.calculateOrientedAnglePolygon(e),e.currentVertexPosition===2){let o=this.calculatepXY3(e,t,true);o&&e.rectangle.updateCoordinate("0."+(e.currentVertexPosition+1),o[0],o[1]);}},deegrees2meters(e){let t=e[0]*2003750834e-2/180,o=Math.log(Math.tan((90+e[1])*Math.PI/360))/(Math.PI/180);return o=o*2003750834e-2/180,[t,o]},meters2degress(e){let t=e[0]*180/2003750834e-2,o=Math.atan(Math.exp(e[1]*Math.PI/2003750834e-2))*360/Math.PI-90;return [t,o]},calculateOrientedAnglePolygon:function(e){let t=e.rectangle.getCoordinate("0.0"),o=this.deegrees2meters(t),n=e.rectangle.getCoordinate("0.1"),r=this.deegrees2meters(n),a=-1*(Math.atan2(r[1]-o[1],r[0]-o[0])*180/Math.PI+90),l=a<0?a+360:a;e.angle=parseFloat(l.toFixed(2));},calculatepXY3:function(e,t,o){let n=e.rectangle.getCoordinate("0.0"),r=this.deegrees2meters(n),i=e.rectangle.getCoordinate("0.1"),a=this.deegrees2meters(i),l=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]),d=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]);if(r[0]===a[0])l=[d[0],a[1]];else if(r[1]===a[1])l=[a[0],d[1]];else {let f=-1/((a[1]-r[1])/(a[0]-r[0]));Math.abs(f)<1?l[1]=f*(d[0]-a[0])+a[1]:l[0]=a[0]+(l[1]-a[1])/f;}let s=[a[0]-r[0],a[1]-r[1]],y=[l[0]-s[0],l[1]-s[1]],p=this.meters2degress(l),b=this.meters2degress(y);return e.rectangle.updateCoordinate("0.2",p[0],p[1]),e.rectangle.updateCoordinate("0.3",b[0],b[1]),b},onKeyUp:function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")},onStop:function(e){Ze.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(e.rectangle.id)!==void 0&&(e.rectangle.removeCoordinate("0.4"),e.rectangle.isValid()?this.map.fire("draw.create",{features:[e.rectangle.toGeoJSON()]}):(this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(e,t,o){let n=t.properties.id===e.rectangle.id;if(t.properties.active=n?"true":"false",t.properties.angle=e.angle,t.angle=e.angle,!n)return o(t);let r=t.geometry.coordinates[0].length;if(r<3){let i=t.geometry.coordinates[0][0],a={type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:t.geometry.coordinates[0][0],type:"Point"}};i&&o(a);return}if(r>=3&&r<=4){let i=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(o({type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:i,type:"LineString"}}),r===3)return}return o(t)},onTrash:function(e){this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select");}},qe=Ao;var Ge=[{id:"measure-label",type:"symbol",filter:["all",["==","$type","Point"],["==","user_type","measure"]],layout:{"text-field":["get","user_value"],"text-anchor":["get","user_anchor"],"text-offset":["match",["get","user_anchor"],"bottom",[0,-0.5],[0,0]],"text-size":12,"text-allow-overlap":true,"text-ignore-placement":true},paint:{"text-halo-color":"rgba(255,255,255,0.75)","text-halo-width":2,"text-halo-blur":1,"text-color":"#000"}}];var Oo=e=>{let[t]=w();t.isMapLibre&&e.lib.constants?.classes&&Object.assign(e.lib.constants.classes,{CANVAS:"maplibregl-canvas",CONTROL_BASE:"maplibregl-ctrl",CONTROL_PREFIX:"maplibregl-ctrl-",CONTROL_GROUP:"maplibregl-ctrl-group",ATTRIBUTION:"maplibregl-ctrl-attrib"});let o=new e.lib({styles:[...e.lib.lib.theme,...Ge],modes:{...e.lib.modes,draw_point:ze(e.lib),draw_line_string:Re(e.lib),draw_polygon:Ve(e.lib),multi_point:De,radius:je(e.lib),rectangle:Ne(e.lib),rectangle_assisted:qe},userProperties:{showLength:e.showLength||false,showArea:e.showArea||false},...e.options});t.map.addControl(o,e.position||"top-right"),e.getInstance&&e.getInstance(o);let n={};return Me.forEach(r=>{if(e[r]){let i=`draw.${r.slice(2).toLowerCase()}`,a=l=>e[r](l);n[i]=a,t.map.on(i,a);}}),onCleanup(()=>{Object.keys(n).forEach(r=>t.map.off(r,n[r])),t.map?.removeControl(o);}),null};var zo=e=>{let[t]=w(),o;return q(()=>(o||(o=new e.overlay(e.props||{})),o)),createEffect(()=>o?.setProps(e.props||{})),null};
10
10
 
11
- export { it as Atmosphere, zt as Camera, yt as Control, Kt as DeckOverlay, Ht as Draw, _t as Image, Ye as Layer, nt as Layer3D, Rt as Light, R as MapProvider, bt as Marker, Ct as Popup, Ge as Source, ut as Terrain, Ae as default, Pt as patternList, h as useMapContext, ot as useScene, $ as useSourceId };
11
+ export { Bt as Atmosphere, xo as Camera, no as Control, zo as DeckOverlay, Oo as Draw, fo as Image, Ft as Layer, Zt as Layer3D, Lo as Light, X as MapProvider, io as Marker, co as Popup, vt as Source, Ht as Terrain, mt as default, K as disableRasterFade, Te as patternList, j as settleAfterIdle, Fe as symbolList, G as toSDF, w as useMapContext, Nt as useScene, R as useSourceId, N as waitForIdleAndSettle };