@russss/maplibregl-layer-switcher 2.2.3 → 3.0.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
@@ -21,7 +21,7 @@ import { LayerSwitcher } from '@russss/maplibregl-layer-switcher'
21
21
  You can also import some basic styles:
22
22
 
23
23
  ```css
24
- @import '@russss/maplibregl-layer-switcher/layerswitcher.css';
24
+ @import '@russss/maplibregl-layer-switcher/maplibregl-layer-switcher.css';
25
25
  ```
26
26
 
27
27
  Now define your layers. Each layer has a short identifier which will be used in the URL hash,
@@ -110,5 +110,4 @@ The URLHash object doesn't currently support tilt and rotation parameters.
110
110
 
111
111
  ## Development
112
112
 
113
- Vite can be used to test the library (using index.html and index.ts in the root directory) but isn't
114
- used to build the published version.
113
+ Vite is used to build and test the library - to test, run `npm start` (which uses index.html and index.ts in the root directory).
package/dist/data.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A layer in the layer switcher.
3
+ */
4
+ export declare class Layer {
5
+ id: string;
6
+ prefix: string;
7
+ title: string;
8
+ groupId?: string;
9
+ enabled: boolean;
10
+ /**
11
+ * An item in the layer switcher.
12
+ *
13
+ * @param id alphanumeric identifier for the layer. This is included in the URL hash so should be as short
14
+ * as possible. Must be unique among all layers, or an error will be thrown.
15
+ * @param title name of the layer as shown in the layer switcher.
16
+ * @param prefix prefix of the layer in the map style to match.
17
+ * @param groupId when group id is set the layer will be part of a radio button group.
18
+ * @param enabled whether the layer is enabled by default.
19
+ */
20
+ constructor(id: string, title: string, prefix: string, enabled?: boolean);
21
+ constructor(id: string, title: string, prefix: string, groupId: string, enabled?: boolean);
22
+ }
23
+ /**
24
+ * A group of layers shown in the layer switcher.
25
+ */
26
+ export declare class LayerGroup {
27
+ layers: Layer[];
28
+ title: string;
29
+ /**
30
+ * A group of layers shown in the layer switcher.
31
+ *
32
+ * @param title name of the group to be shown.
33
+ * @param layers list of layers in the group.
34
+ */
35
+ constructor(title: string, layers: Layer[]);
36
+ }
37
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,KAAK;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAQ;IAExB;;;;;;;;;OASG;gBACS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;gBAC5D,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAa1F;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IAEb;;;;;OAKG;gBACS,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;CAI3C"}
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./layerswitcher-CezhM7p2.cjs");function t(e){let t=e.replace(`#`,``).split(`/`),n={additional:{}};if(t.length<3)return n;n.layers=``,n.zoom=+t[0],n.center=[+t[2],+t[1]];for(let e=3;e<t.length;e++){let r=t[e],i=r.match(/^(\w+)=(.*)$/);i?(n.additional=n.additional||{},n.additional[i[1]]=i[2]):n.layers=r}return n}function n(e){if(!e.zoom||!e.center)return``;let t=Math.round(e.zoom*100)/100,n=10**Math.ceil((t*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.round(e.center[0]*n)/n,i=`#${t}/${Math.round(e.center[1]*n)/n}/${r}`;if(e.layers&&(i+=`/`+e.layers),e.additional)for(let t in e.additional)i+=`/`+t+`=`+e.additional[t];return i}var r=class{constructor(e){this.layerSwitcher=e,this.additional={},this.handlers={}}enable(e){this._map=e,this.layerSwitcher.urlhash=this,this._onHashChange(window.location.hash),e.on(`moveend`,()=>{this._updateHash()}),window.addEventListener(`hashchange`,()=>{this._onHashChange(window.location.hash)},!1)}registerHandler(e,t){this.handlers[e]=t}setParameter(e,t){this.additional[e]!==t&&(t===null?delete this.additional[e]:this.additional[e]=t,this._updateHash())}_fireParameterChange(e,t){this.handlers[e]&&this.handlers[e](t)}_onHashChange(e){let n=t(e),r=[...Object.keys(n.additional),...Object.keys(this.additional)];for(let e of r)this.additional[e]&&!n.additional[e]?(delete this.additional[e],this._fireParameterChange(e,null)):n.additional[e]&&this.additional[e]!==n.additional[e]&&(this.additional[e]=n.additional[e],this._fireParameterChange(e,n.additional[e]));this._map?.isStyleLoaded()&&n.center&&n.zoom&&this._map.jumpTo({center:n.center,zoom:n.zoom}),this.layerSwitcher&&n.layers!==void 0&&this.layerSwitcher.setURLString(n.layers)}_updateHash(){let e=this.getHashString();try{window.history.replaceState(window.history.state,``,e)}catch(e){console.log(e)}}getHashString(){if(!this._map)throw Error(`getHashString called before map initialised`);let{lng:e,lat:t}=this._map.getCenter(),r={center:[e,t],zoom:this._map.getZoom(),additional:this.additional};return this.layerSwitcher&&(r.layers=this.layerSwitcher.getURLString()),n(r)}init(e){e.hash=!1;let t=window.location.hash.replace(`#`,``).split(`/`);return t.length>=3&&(e.center=[+t[2],+t[1]],e.zoom=+t[0]),e}};exports.Layer=e.n,exports.LayerGroup=e.r,exports.LayerSwitcher=e.t,exports.URLHash=r;
@@ -0,0 +1,5 @@
1
+ import { default as LayerSwitcher } from './layerswitcher';
2
+ import { default as URLHash } from './urlhash';
3
+ import { Layer, LayerGroup } from './data';
4
+ export { LayerSwitcher, URLHash, Layer, LayerGroup };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,71 @@
1
+ import { n as e, r as t, t as n } from "./layerswitcher-B7ForKVG.js";
2
+ //#region src/urlhash.ts
3
+ function r(e) {
4
+ let t = e.replace("#", "").split("/"), n = { additional: {} };
5
+ if (t.length < 3) return n;
6
+ n.layers = "", n.zoom = +t[0], n.center = [+t[2], +t[1]];
7
+ for (let e = 3; e < t.length; e++) {
8
+ let r = t[e], i = r.match(/^(\w+)=(.*)$/);
9
+ i ? (n.additional = n.additional || {}, n.additional[i[1]] = i[2]) : n.layers = r;
10
+ }
11
+ return n;
12
+ }
13
+ function i(e) {
14
+ if (!e.zoom || !e.center) return "";
15
+ let t = Math.round(e.zoom * 100) / 100, n = 10 ** Math.ceil((t * Math.LN2 + Math.log(512 / 360 / .5)) / Math.LN10), r = Math.round(e.center[0] * n) / n, i = `#${t}/${Math.round(e.center[1] * n) / n}/${r}`;
16
+ if (e.layers && (i += "/" + e.layers), e.additional) for (let t in e.additional) i += "/" + t + "=" + e.additional[t];
17
+ return i;
18
+ }
19
+ var a = class {
20
+ constructor(e) {
21
+ this.layerSwitcher = e, this.additional = {}, this.handlers = {};
22
+ }
23
+ enable(e) {
24
+ this._map = e, this.layerSwitcher.urlhash = this, this._onHashChange(window.location.hash), e.on("moveend", () => {
25
+ this._updateHash();
26
+ }), window.addEventListener("hashchange", () => {
27
+ this._onHashChange(window.location.hash);
28
+ }, !1);
29
+ }
30
+ registerHandler(e, t) {
31
+ this.handlers[e] = t;
32
+ }
33
+ setParameter(e, t) {
34
+ this.additional[e] !== t && (t === null ? delete this.additional[e] : this.additional[e] = t, this._updateHash());
35
+ }
36
+ _fireParameterChange(e, t) {
37
+ this.handlers[e] && this.handlers[e](t);
38
+ }
39
+ _onHashChange(e) {
40
+ let t = r(e), n = [...Object.keys(t.additional), ...Object.keys(this.additional)];
41
+ for (let e of n) this.additional[e] && !t.additional[e] ? (delete this.additional[e], this._fireParameterChange(e, null)) : t.additional[e] && this.additional[e] !== t.additional[e] && (this.additional[e] = t.additional[e], this._fireParameterChange(e, t.additional[e]));
42
+ this._map?.isStyleLoaded() && t.center && t.zoom && this._map.jumpTo({
43
+ center: t.center,
44
+ zoom: t.zoom
45
+ }), this.layerSwitcher && t.layers !== void 0 && this.layerSwitcher.setURLString(t.layers);
46
+ }
47
+ _updateHash() {
48
+ let e = this.getHashString();
49
+ try {
50
+ window.history.replaceState(window.history.state, "", e);
51
+ } catch (e) {
52
+ console.log(e);
53
+ }
54
+ }
55
+ getHashString() {
56
+ if (!this._map) throw Error("getHashString called before map initialised");
57
+ let { lng: e, lat: t } = this._map.getCenter(), n = {
58
+ center: [e, t],
59
+ zoom: this._map.getZoom(),
60
+ additional: this.additional
61
+ };
62
+ return this.layerSwitcher && (n.layers = this.layerSwitcher.getURLString()), i(n);
63
+ }
64
+ init(e) {
65
+ e.hash = !1;
66
+ let t = window.location.hash.replace("#", "").split("/");
67
+ return t.length >= 3 && (e.center = [+t[2], +t[1]], e.zoom = +t[0]), e;
68
+ }
69
+ };
70
+ //#endregion
71
+ export { e as Layer, t as LayerGroup, n as LayerSwitcher, a as URLHash };
@@ -0,0 +1,813 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : o, n));
12
+ //#endregion
13
+ //#region node_modules/redom/dist/redom.es.js
14
+ function l(e, t) {
15
+ var n = u(e), r = n.tag, i = n.id, a = n.className, o = t ? document.createElementNS(t, r) : document.createElement(r);
16
+ return i && (o.id = i), a && (t ? o.setAttribute("class", a) : o.className = a), o;
17
+ }
18
+ function u(e) {
19
+ for (var t = e.split(/([.#])/), n = "", r = "", i = 1; i < t.length; i += 2) switch (t[i]) {
20
+ case ".":
21
+ n += " " + t[i + 1];
22
+ break;
23
+ case "#": r = t[i + 1];
24
+ }
25
+ return {
26
+ className: n.trim(),
27
+ tag: t[0] || "div",
28
+ id: r
29
+ };
30
+ }
31
+ function d(e, t) {
32
+ var n = w(e), r = w(t);
33
+ return t === r && r.__redom_view && (t = r.__redom_view), r.parentNode && (f(t, r, n), n.removeChild(r)), t;
34
+ }
35
+ function f(e, t, n) {
36
+ var r = t.__redom_lifecycle;
37
+ if (p(r)) {
38
+ t.__redom_lifecycle = {};
39
+ return;
40
+ }
41
+ var i = n;
42
+ for (t.__redom_mounted && _(t, "onunmount"); i;) {
43
+ var a = i.__redom_lifecycle || {};
44
+ for (var o in r) a[o] && (a[o] -= r[o]);
45
+ p(a) && (i.__redom_lifecycle = null), i = i.parentNode;
46
+ }
47
+ }
48
+ function p(e) {
49
+ if (e == null) return !0;
50
+ for (var t in e) if (e[t]) return !1;
51
+ return !0;
52
+ }
53
+ var m = [
54
+ "onmount",
55
+ "onremount",
56
+ "onunmount"
57
+ ], h = typeof window < "u" && "ShadowRoot" in window;
58
+ function g(e, t, n, r) {
59
+ var i = w(e), a = w(t);
60
+ t === a && a.__redom_view && (t = a.__redom_view), t !== a && (a.__redom_view = t);
61
+ var o = a.__redom_mounted, s = a.parentNode;
62
+ if (o && s !== i && f(t, a, s), n != null) {
63
+ if (r) {
64
+ var c = w(n);
65
+ c.__redom_mounted && _(c, "onunmount"), i.replaceChild(a, c);
66
+ } else i.insertBefore(a, w(n));
67
+ } else i.appendChild(a);
68
+ return v(t, a, i, s), t;
69
+ }
70
+ function _(e, t) {
71
+ t === "onmount" || t === "onremount" ? e.__redom_mounted = !0 : t === "onunmount" && (e.__redom_mounted = !1);
72
+ var n = e.__redom_lifecycle;
73
+ if (n) {
74
+ var r = e.__redom_view, i = 0;
75
+ for (var a in r && r[t] && r[t](), n) a && i++;
76
+ if (i) for (var o = e.firstChild; o;) {
77
+ var s = o.nextSibling;
78
+ _(o, t), o = s;
79
+ }
80
+ }
81
+ }
82
+ function v(e, t, n, r) {
83
+ for (var i = t.__redom_lifecycle ||= {}, a = n === r, o = !1, s = 0, c = m; s < c.length; s += 1) {
84
+ var l = c[s];
85
+ a || e !== t && l in e && (i[l] = (i[l] || 0) + 1), i[l] && (o = !0);
86
+ }
87
+ if (!o) {
88
+ t.__redom_lifecycle = {};
89
+ return;
90
+ }
91
+ var u = n, d = !1;
92
+ for ((a || u && u.__redom_mounted) && (_(t, a ? "onremount" : "onmount"), d = !0); u;) {
93
+ var f = u.parentNode, p = u.__redom_lifecycle || (u.__redom_lifecycle = {});
94
+ for (var g in i) p[g] = (p[g] || 0) + i[g];
95
+ if (d) break;
96
+ (u.nodeType === Node.DOCUMENT_NODE || h && u instanceof ShadowRoot || f && f.__redom_mounted) && (_(u, a ? "onremount" : "onmount"), d = !0), u = f;
97
+ }
98
+ }
99
+ function y(e, t, n) {
100
+ var r = w(e);
101
+ if (typeof t == "object") for (var i in t) b(r, i, t[i]);
102
+ else b(r, t, n);
103
+ }
104
+ function b(e, t, n) {
105
+ e.style[t] = n ?? "";
106
+ }
107
+ var x = "http://www.w3.org/1999/xlink";
108
+ function ee(e, t, n, r) {
109
+ var i = w(e);
110
+ if (typeof t == "object") for (var a in t) ee(i, a, t[a], r);
111
+ else {
112
+ var o = i instanceof SVGElement, s = typeof n == "function";
113
+ if (t === "style" && typeof n == "object") y(i, n);
114
+ else if (o && s) i[t] = n;
115
+ else if (t === "dataset") ne(i, n);
116
+ else if (!o && (t in i || s) && t !== "list") i[t] = n;
117
+ else {
118
+ if (o && t === "xlink") {
119
+ te(i, n);
120
+ return;
121
+ }
122
+ r && t === "class" && (n = i.className + " " + n), n == null ? i.removeAttribute(t) : i.setAttribute(t, n);
123
+ }
124
+ }
125
+ }
126
+ function te(e, t, n) {
127
+ if (typeof t == "object") for (var r in t) te(e, r, t[r]);
128
+ else n == null ? e.removeAttributeNS(x, t, n) : e.setAttributeNS(x, t, n);
129
+ }
130
+ function ne(e, t, n) {
131
+ if (typeof t == "object") for (var r in t) ne(e, r, t[r]);
132
+ else n == null ? delete e.dataset[t] : e.dataset[t] = n;
133
+ }
134
+ function S(e) {
135
+ return document.createTextNode(e ?? "");
136
+ }
137
+ function C(e, t, n) {
138
+ for (var r = 0, i = t; r < i.length; r += 1) {
139
+ var a = i[r];
140
+ if (a === 0 || a) {
141
+ var o = typeof a;
142
+ o === "function" ? a(e) : o === "string" || o === "number" ? e.appendChild(S(a)) : ie(w(a)) ? g(e, a) : a.length ? C(e, a, n) : o === "object" && ee(e, a, null, n);
143
+ }
144
+ }
145
+ }
146
+ function re(e) {
147
+ return typeof e == "string" ? T(e) : w(e);
148
+ }
149
+ function w(e) {
150
+ return e.nodeType && e || !e.el && e || w(e.el);
151
+ }
152
+ function ie(e) {
153
+ return e && e.nodeType;
154
+ }
155
+ function T(e) {
156
+ for (var t = [], n = arguments.length - 1; n-- > 0;) t[n] = arguments[n + 1];
157
+ var r, i = typeof e;
158
+ if (i === "string") r = l(e);
159
+ else if (i === "function") {
160
+ var a = e;
161
+ r = new (Function.prototype.bind.apply(a, [null].concat(t)))();
162
+ } else throw Error("At least one argument required");
163
+ return C(w(r), t, !0), r;
164
+ }
165
+ var E = T;
166
+ T.extend = function() {
167
+ for (var e = [], t = arguments.length; t--;) e[t] = arguments[t];
168
+ return T.bind.apply(T, [this].concat(e));
169
+ };
170
+ function D(e) {
171
+ for (var t = [], n = arguments.length - 1; n-- > 0;) t[n] = arguments[n + 1];
172
+ for (var r = O(e, t, w(e).firstChild); r;) {
173
+ var i = r.nextSibling;
174
+ d(e, r), r = i;
175
+ }
176
+ }
177
+ function O(e, t, n) {
178
+ for (var r = n, i = Array(t.length), a = 0; a < t.length; a++) i[a] = t[a] && w(t[a]);
179
+ for (var o = 0; o < t.length; o++) {
180
+ var s = t[o];
181
+ if (s) {
182
+ var c = i[o];
183
+ if (c === r) {
184
+ r = r.nextSibling;
185
+ continue;
186
+ }
187
+ if (ie(c)) {
188
+ var l = r && r.nextSibling, u = s.__redom_index != null && l === i[o + 1];
189
+ g(e, s, r, u), u && (r = l);
190
+ continue;
191
+ }
192
+ s.length != null && (r = O(e, s, r));
193
+ }
194
+ }
195
+ return r;
196
+ }
197
+ var ae = function(e, t, n) {
198
+ this.View = e, this.initData = n, this.oldLookup = {}, this.lookup = {}, this.oldViews = [], this.views = [], t != null && (this.key = typeof t == "function" ? t : k(t));
199
+ };
200
+ ae.prototype.update = function(e, t) {
201
+ for (var n = this, r = n.View, i = n.key, a = n.initData, o = i != null, s = this.lookup, c = {}, l = Array(e.length), u = this.views, d = 0; d < e.length; d++) {
202
+ var f = e[d], p = void 0;
203
+ if (o) {
204
+ var m = i(f);
205
+ p = s[m] || new r(a, f, d, e), c[m] = p, p.__redom_id = m;
206
+ } else p = u[d] || new r(a, f, d, e);
207
+ p.update && p.update(f, d, e, t);
208
+ var h = w(p.el);
209
+ h.__redom_view = p, l[d] = p;
210
+ }
211
+ this.oldViews = u, this.views = l, this.oldLookup = s, this.lookup = c;
212
+ };
213
+ function k(e) {
214
+ return function(t) {
215
+ return t[e];
216
+ };
217
+ }
218
+ var A = function(e, t, n, r) {
219
+ this.View = t, this.initData = r, this.views = [], this.pool = new ae(t, n, r), this.el = re(e), this.keySet = n != null;
220
+ };
221
+ A.prototype.update = function(e, t) {
222
+ e === void 0 && (e = []);
223
+ var n = this.keySet, r = this.views;
224
+ this.pool.update(e, t);
225
+ var i = this.pool, a = i.views, o = i.lookup;
226
+ if (n) for (var s = 0; s < r.length; s++) {
227
+ var c = r[s];
228
+ o[c.__redom_id] ?? (c.__redom_index = null, d(this, c));
229
+ }
230
+ for (var l = 0; l < a.length; l++) {
231
+ var u = a[l];
232
+ u.__redom_index = l;
233
+ }
234
+ D(this, a), n && (this.lookup = o), this.views = a;
235
+ }, A.extend = function(e, t, n, r) {
236
+ return A.bind(A, e, t, n, r);
237
+ }, A.extend;
238
+ var oe = function(e, t) {
239
+ this.el = S(""), this.visible = !1, this.view = null, this._placeholder = this.el, e instanceof Node ? this._el = e : e.el instanceof Node ? (this._el = e, this.view = e) : this._View = e, this._initData = t;
240
+ };
241
+ oe.prototype.update = function(e, t) {
242
+ var n = this._placeholder, r = this.el.parentNode;
243
+ if (e) {
244
+ if (!this.visible) {
245
+ if (this._el) g(r, this._el, n), d(r, n), this.el = w(this._el), this.visible = e;
246
+ else {
247
+ var i = this._View, a = new i(this._initData);
248
+ this.el = w(a), this.view = a, g(r, a, n), d(r, n);
249
+ }
250
+ }
251
+ this.view && this.view.update && this.view.update(t);
252
+ } else if (this.visible) {
253
+ if (this._el) {
254
+ g(r, n, this._el), d(r, this._el), this.el = n, this.visible = e;
255
+ return;
256
+ }
257
+ g(r, n, this.view), d(r, this.view), this.el = n, this.view = null;
258
+ }
259
+ this.visible = e;
260
+ };
261
+ var se = function(e, t, n) {
262
+ this.el = re(e), this.Views = t, this.initData = n;
263
+ };
264
+ se.prototype.update = function(e, t) {
265
+ if (e !== this.route) {
266
+ var n = this.Views[e];
267
+ this.route = e, this.view = n && (n instanceof Node || n.el instanceof Node) ? n : n && new n(this.initData, t), D(this.el, [this.view]);
268
+ }
269
+ this.view && this.view.update && this.view.update(t, e);
270
+ };
271
+ var j = "http://www.w3.org/2000/svg";
272
+ function M(e) {
273
+ for (var t = [], n = arguments.length - 1; n-- > 0;) t[n] = arguments[n + 1];
274
+ var r, i = typeof e;
275
+ if (i === "string") r = l(e, j);
276
+ else if (i === "function") {
277
+ var a = e;
278
+ r = new (Function.prototype.bind.apply(a, [null].concat(t)))();
279
+ } else throw Error("At least one argument required");
280
+ return C(w(r), t, !0), r;
281
+ }
282
+ M.extend = function() {
283
+ for (var e = [], t = arguments.length; t--;) e[t] = arguments[t];
284
+ return M.bind.apply(M, [this].concat(e));
285
+ }, M.ns = j;
286
+ //#endregion
287
+ //#region src/data.ts
288
+ var ce = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
289
+ var n = "__lodash_hash_undefined__", r = 9007199254740991, i = "[object Arguments]", a = "[object Array]", o = "[object Boolean]", s = "[object Date]", c = "[object Error]", l = "[object Function]", u = "[object Map]", d = "[object Number]", f = "[object Object]", p = "[object Promise]", m = "[object RegExp]", h = "[object Set]", g = "[object String]", _ = "[object WeakMap]", v = "[object ArrayBuffer]", y = "[object DataView]", b = "[object Float32Array]", x = "[object Float64Array]", ee = "[object Int8Array]", te = "[object Int16Array]", ne = "[object Int32Array]", S = "[object Uint8Array]", C = "[object Uint8ClampedArray]", re = "[object Uint16Array]", w = "[object Uint32Array]", ie = /[\\^$.*+?()[\]{}|]/g, T = /^\[object .+?Constructor\]$/, E = /^(?:0|[1-9]\d*)$/, D = {};
290
+ D[b] = D[x] = D[ee] = D[te] = D[ne] = D[S] = D[C] = D[re] = D[w] = !0, D[i] = D[a] = D[v] = D[o] = D[y] = D[s] = D[c] = D[l] = D[u] = D[d] = D[f] = D[m] = D[h] = D[g] = D[_] = !1;
291
+ var O = typeof global == "object" && global && global.Object === Object && global, ae = typeof self == "object" && self && self.Object === Object && self, k = O || ae || Function("return this")(), A = typeof e == "object" && e && !e.nodeType && e, oe = A && typeof t == "object" && t && !t.nodeType && t, se = oe && oe.exports === A, j = se && O.process, M = function() {
292
+ try {
293
+ return j && j.binding && j.binding("util");
294
+ } catch {}
295
+ }(), ce = M && M.isTypedArray;
296
+ function N(e, t) {
297
+ for (var n = -1, r = e == null ? 0 : e.length, i = 0, a = []; ++n < r;) {
298
+ var o = e[n];
299
+ t(o, n, e) && (a[i++] = o);
300
+ }
301
+ return a;
302
+ }
303
+ function P(e, t) {
304
+ for (var n = -1, r = t.length, i = e.length; ++n < r;) e[i + n] = t[n];
305
+ return e;
306
+ }
307
+ function le(e, t) {
308
+ for (var n = -1, r = e == null ? 0 : e.length; ++n < r;) if (t(e[n], n, e)) return !0;
309
+ return !1;
310
+ }
311
+ function ue(e, t) {
312
+ for (var n = -1, r = Array(e); ++n < e;) r[n] = t(n);
313
+ return r;
314
+ }
315
+ function de(e) {
316
+ return function(t) {
317
+ return e(t);
318
+ };
319
+ }
320
+ function fe(e, t) {
321
+ return e.has(t);
322
+ }
323
+ function pe(e, t) {
324
+ return e?.[t];
325
+ }
326
+ function me(e) {
327
+ var t = -1, n = Array(e.size);
328
+ return e.forEach(function(e, r) {
329
+ n[++t] = [r, e];
330
+ }), n;
331
+ }
332
+ function he(e, t) {
333
+ return function(n) {
334
+ return e(t(n));
335
+ };
336
+ }
337
+ function ge(e) {
338
+ var t = -1, n = Array(e.size);
339
+ return e.forEach(function(e) {
340
+ n[++t] = e;
341
+ }), n;
342
+ }
343
+ var _e = Array.prototype, ve = Function.prototype, F = Object.prototype, ye = k["__core-js_shared__"], be = ve.toString, I = F.hasOwnProperty, xe = function() {
344
+ var e = /[^.]+$/.exec(ye && ye.keys && ye.keys.IE_PROTO || "");
345
+ return e ? "Symbol(src)_1." + e : "";
346
+ }(), Se = F.toString, Ce = RegExp("^" + be.call(I).replace(ie, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), we = se ? k.Buffer : void 0, L = k.Symbol, Te = k.Uint8Array, Ee = F.propertyIsEnumerable, De = _e.splice, R = L ? L.toStringTag : void 0, Oe = Object.getOwnPropertySymbols, ke = we ? we.isBuffer : void 0, Ae = he(Object.keys, Object), je = Y(k, "DataView"), z = Y(k, "Map"), Me = Y(k, "Promise"), Ne = Y(k, "Set"), Pe = Y(k, "WeakMap"), B = Y(Object, "create"), Fe = Z(je), Ie = Z(z), Le = Z(Me), Re = Z(Ne), ze = Z(Pe), Be = L ? L.prototype : void 0, Ve = Be ? Be.valueOf : void 0;
347
+ function V(e) {
348
+ var t = -1, n = e == null ? 0 : e.length;
349
+ for (this.clear(); ++t < n;) {
350
+ var r = e[t];
351
+ this.set(r[0], r[1]);
352
+ }
353
+ }
354
+ function He() {
355
+ this.__data__ = B ? B(null) : {}, this.size = 0;
356
+ }
357
+ function Ue(e) {
358
+ var t = this.has(e) && delete this.__data__[e];
359
+ return this.size -= +!!t, t;
360
+ }
361
+ function We(e) {
362
+ var t = this.__data__;
363
+ if (B) {
364
+ var r = t[e];
365
+ return r === n ? void 0 : r;
366
+ }
367
+ return I.call(t, e) ? t[e] : void 0;
368
+ }
369
+ function Ge(e) {
370
+ var t = this.__data__;
371
+ return B ? t[e] !== void 0 : I.call(t, e);
372
+ }
373
+ function Ke(e, t) {
374
+ var r = this.__data__;
375
+ return this.size += +!this.has(e), r[e] = B && t === void 0 ? n : t, this;
376
+ }
377
+ V.prototype.clear = He, V.prototype.delete = Ue, V.prototype.get = We, V.prototype.has = Ge, V.prototype.set = Ke;
378
+ function H(e) {
379
+ var t = -1, n = e == null ? 0 : e.length;
380
+ for (this.clear(); ++t < n;) {
381
+ var r = e[t];
382
+ this.set(r[0], r[1]);
383
+ }
384
+ }
385
+ function qe() {
386
+ this.__data__ = [], this.size = 0;
387
+ }
388
+ function Je(e) {
389
+ var t = this.__data__, n = K(t, e);
390
+ return n < 0 ? !1 : (n == t.length - 1 ? t.pop() : De.call(t, n, 1), --this.size, !0);
391
+ }
392
+ function Ye(e) {
393
+ var t = this.__data__, n = K(t, e);
394
+ return n < 0 ? void 0 : t[n][1];
395
+ }
396
+ function Xe(e) {
397
+ return K(this.__data__, e) > -1;
398
+ }
399
+ function Ze(e, t) {
400
+ var n = this.__data__, r = K(n, e);
401
+ return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
402
+ }
403
+ H.prototype.clear = qe, H.prototype.delete = Je, H.prototype.get = Ye, H.prototype.has = Xe, H.prototype.set = Ze;
404
+ function U(e) {
405
+ var t = -1, n = e == null ? 0 : e.length;
406
+ for (this.clear(); ++t < n;) {
407
+ var r = e[t];
408
+ this.set(r[0], r[1]);
409
+ }
410
+ }
411
+ function Qe() {
412
+ this.size = 0, this.__data__ = {
413
+ hash: new V(),
414
+ map: new (z || H)(),
415
+ string: new V()
416
+ };
417
+ }
418
+ function $e(e) {
419
+ var t = J(this, e).delete(e);
420
+ return this.size -= +!!t, t;
421
+ }
422
+ function et(e) {
423
+ return J(this, e).get(e);
424
+ }
425
+ function tt(e) {
426
+ return J(this, e).has(e);
427
+ }
428
+ function nt(e, t) {
429
+ var n = J(this, e), r = n.size;
430
+ return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
431
+ }
432
+ U.prototype.clear = Qe, U.prototype.delete = $e, U.prototype.get = et, U.prototype.has = tt, U.prototype.set = nt;
433
+ function W(e) {
434
+ var t = -1, n = e == null ? 0 : e.length;
435
+ for (this.__data__ = new U(); ++t < n;) this.add(e[t]);
436
+ }
437
+ function rt(e) {
438
+ return this.__data__.set(e, n), this;
439
+ }
440
+ function it(e) {
441
+ return this.__data__.has(e);
442
+ }
443
+ W.prototype.add = W.prototype.push = rt, W.prototype.has = it;
444
+ function G(e) {
445
+ var t = this.__data__ = new H(e);
446
+ this.size = t.size;
447
+ }
448
+ function at() {
449
+ this.__data__ = new H(), this.size = 0;
450
+ }
451
+ function ot(e) {
452
+ var t = this.__data__, n = t.delete(e);
453
+ return this.size = t.size, n;
454
+ }
455
+ function st(e) {
456
+ return this.__data__.get(e);
457
+ }
458
+ function ct(e) {
459
+ return this.__data__.has(e);
460
+ }
461
+ function lt(e, t) {
462
+ var n = this.__data__;
463
+ if (n instanceof H) {
464
+ var r = n.__data__;
465
+ if (!z || r.length < 199) return r.push([e, t]), this.size = ++n.size, this;
466
+ n = this.__data__ = new U(r);
467
+ }
468
+ return n.set(e, t), this.size = n.size, this;
469
+ }
470
+ G.prototype.clear = at, G.prototype.delete = ot, G.prototype.get = st, G.prototype.has = ct, G.prototype.set = lt;
471
+ function ut(e, t) {
472
+ var n = Q(e), r = !n && At(e), i = !n && !r && Mt(e), a = !n && !r && !i && Lt(e), o = n || r || i || a, s = o ? ue(e.length, String) : [], c = s.length;
473
+ for (var l in e) (t || I.call(e, l)) && !(o && (l == "length" || i && (l == "offset" || l == "parent") || a && (l == "buffer" || l == "byteLength" || l == "byteOffset") || wt(l, c))) && s.push(l);
474
+ return s;
475
+ }
476
+ function K(e, t) {
477
+ for (var n = e.length; n--;) if (kt(e[n][0], t)) return n;
478
+ return -1;
479
+ }
480
+ function dt(e, t, n) {
481
+ var r = t(e);
482
+ return Q(e) ? r : P(r, n(e));
483
+ }
484
+ function q(e) {
485
+ return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : R && R in Object(e) ? St(e) : Ot(e);
486
+ }
487
+ function ft(e) {
488
+ return $(e) && q(e) == i;
489
+ }
490
+ function pt(e, t, n, r, i) {
491
+ return e === t ? !0 : e == null || t == null || !$(e) && !$(t) ? e !== e && t !== t : mt(e, t, n, r, pt, i);
492
+ }
493
+ function mt(e, t, n, r, o, s) {
494
+ var c = Q(e), l = Q(t), u = c ? a : X(e), d = l ? a : X(t);
495
+ u = u == i ? f : u, d = d == i ? f : d;
496
+ var p = u == f, m = d == f, h = u == d;
497
+ if (h && Mt(e)) {
498
+ if (!Mt(t)) return !1;
499
+ c = !0, p = !1;
500
+ }
501
+ if (h && !p) return s ||= new G(), c || Lt(e) ? vt(e, t, n, r, o, s) : yt(e, t, u, n, r, o, s);
502
+ if (!(n & 1)) {
503
+ var g = p && I.call(e, "__wrapped__"), _ = m && I.call(t, "__wrapped__");
504
+ if (g || _) {
505
+ var v = g ? e.value() : e, y = _ ? t.value() : t;
506
+ return s ||= new G(), o(v, y, n, r, s);
507
+ }
508
+ }
509
+ return h ? (s ||= new G(), bt(e, t, n, r, o, s)) : !1;
510
+ }
511
+ function ht(e) {
512
+ return !It(e) || Et(e) ? !1 : (Pt(e) ? Ce : T).test(Z(e));
513
+ }
514
+ function gt(e) {
515
+ return $(e) && Ft(e.length) && !!D[q(e)];
516
+ }
517
+ function _t(e) {
518
+ if (!Dt(e)) return Ae(e);
519
+ var t = [];
520
+ for (var n in Object(e)) I.call(e, n) && n != "constructor" && t.push(n);
521
+ return t;
522
+ }
523
+ function vt(e, t, n, r, i, a) {
524
+ var o = n & 1, s = e.length, c = t.length;
525
+ if (s != c && !(o && c > s)) return !1;
526
+ var l = a.get(e);
527
+ if (l && a.get(t)) return l == t;
528
+ var u = -1, d = !0, f = n & 2 ? new W() : void 0;
529
+ for (a.set(e, t), a.set(t, e); ++u < s;) {
530
+ var p = e[u], m = t[u];
531
+ if (r) var h = o ? r(m, p, u, t, e, a) : r(p, m, u, e, t, a);
532
+ if (h !== void 0) {
533
+ if (h) continue;
534
+ d = !1;
535
+ break;
536
+ }
537
+ if (f) {
538
+ if (!le(t, function(e, t) {
539
+ if (!fe(f, t) && (p === e || i(p, e, n, r, a))) return f.push(t);
540
+ })) {
541
+ d = !1;
542
+ break;
543
+ }
544
+ } else if (!(p === m || i(p, m, n, r, a))) {
545
+ d = !1;
546
+ break;
547
+ }
548
+ }
549
+ return a.delete(e), a.delete(t), d;
550
+ }
551
+ function yt(e, t, n, r, i, a, l) {
552
+ switch (n) {
553
+ case y:
554
+ if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset) return !1;
555
+ e = e.buffer, t = t.buffer;
556
+ case v: return !(e.byteLength != t.byteLength || !a(new Te(e), new Te(t)));
557
+ case o:
558
+ case s:
559
+ case d: return kt(+e, +t);
560
+ case c: return e.name == t.name && e.message == t.message;
561
+ case m:
562
+ case g: return e == t + "";
563
+ case u: var f = me;
564
+ case h:
565
+ var p = r & 1;
566
+ if (f ||= ge, e.size != t.size && !p) return !1;
567
+ var _ = l.get(e);
568
+ if (_) return _ == t;
569
+ r |= 2, l.set(e, t);
570
+ var b = vt(f(e), f(t), r, i, a, l);
571
+ return l.delete(e), b;
572
+ case "[object Symbol]": if (Ve) return Ve.call(e) == Ve.call(t);
573
+ }
574
+ return !1;
575
+ }
576
+ function bt(e, t, n, r, i, a) {
577
+ var o = n & 1, s = xt(e), c = s.length;
578
+ if (c != xt(t).length && !o) return !1;
579
+ for (var l = c; l--;) {
580
+ var u = s[l];
581
+ if (!(o ? u in t : I.call(t, u))) return !1;
582
+ }
583
+ var d = a.get(e);
584
+ if (d && a.get(t)) return d == t;
585
+ var f = !0;
586
+ a.set(e, t), a.set(t, e);
587
+ for (var p = o; ++l < c;) {
588
+ u = s[l];
589
+ var m = e[u], h = t[u];
590
+ if (r) var g = o ? r(h, m, u, t, e, a) : r(m, h, u, e, t, a);
591
+ if (!(g === void 0 ? m === h || i(m, h, n, r, a) : g)) {
592
+ f = !1;
593
+ break;
594
+ }
595
+ p ||= u == "constructor";
596
+ }
597
+ if (f && !p) {
598
+ var _ = e.constructor, v = t.constructor;
599
+ _ != v && "constructor" in e && "constructor" in t && !(typeof _ == "function" && _ instanceof _ && typeof v == "function" && v instanceof v) && (f = !1);
600
+ }
601
+ return a.delete(e), a.delete(t), f;
602
+ }
603
+ function xt(e) {
604
+ return dt(e, Rt, Ct);
605
+ }
606
+ function J(e, t) {
607
+ var n = e.__data__;
608
+ return Tt(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
609
+ }
610
+ function Y(e, t) {
611
+ var n = pe(e, t);
612
+ return ht(n) ? n : void 0;
613
+ }
614
+ function St(e) {
615
+ var t = I.call(e, R), n = e[R];
616
+ try {
617
+ e[R] = void 0;
618
+ var r = !0;
619
+ } catch {}
620
+ var i = Se.call(e);
621
+ return r && (t ? e[R] = n : delete e[R]), i;
622
+ }
623
+ var Ct = Oe ? function(e) {
624
+ return e == null ? [] : (e = Object(e), N(Oe(e), function(t) {
625
+ return Ee.call(e, t);
626
+ }));
627
+ } : zt, X = q;
628
+ (je && X(new je(/* @__PURE__ */ new ArrayBuffer(1))) != y || z && X(new z()) != u || Me && X(Me.resolve()) != p || Ne && X(new Ne()) != h || Pe && X(new Pe()) != _) && (X = function(e) {
629
+ var t = q(e), n = t == f ? e.constructor : void 0, r = n ? Z(n) : "";
630
+ if (r) switch (r) {
631
+ case Fe: return y;
632
+ case Ie: return u;
633
+ case Le: return p;
634
+ case Re: return h;
635
+ case ze: return _;
636
+ }
637
+ return t;
638
+ });
639
+ function wt(e, t) {
640
+ return t ??= r, !!t && (typeof e == "number" || E.test(e)) && e > -1 && e % 1 == 0 && e < t;
641
+ }
642
+ function Tt(e) {
643
+ var t = typeof e;
644
+ return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
645
+ }
646
+ function Et(e) {
647
+ return !!xe && xe in e;
648
+ }
649
+ function Dt(e) {
650
+ var t = e && e.constructor;
651
+ return e === (typeof t == "function" && t.prototype || F);
652
+ }
653
+ function Ot(e) {
654
+ return Se.call(e);
655
+ }
656
+ function Z(e) {
657
+ if (e != null) {
658
+ try {
659
+ return be.call(e);
660
+ } catch {}
661
+ try {
662
+ return e + "";
663
+ } catch {}
664
+ }
665
+ return "";
666
+ }
667
+ function kt(e, t) {
668
+ return e === t || e !== e && t !== t;
669
+ }
670
+ var At = ft(function() {
671
+ return arguments;
672
+ }()) ? ft : function(e) {
673
+ return $(e) && I.call(e, "callee") && !Ee.call(e, "callee");
674
+ }, Q = Array.isArray;
675
+ function jt(e) {
676
+ return e != null && Ft(e.length) && !Pt(e);
677
+ }
678
+ var Mt = ke || Bt;
679
+ function Nt(e, t) {
680
+ return pt(e, t);
681
+ }
682
+ function Pt(e) {
683
+ if (!It(e)) return !1;
684
+ var t = q(e);
685
+ return t == l || t == "[object GeneratorFunction]" || t == "[object AsyncFunction]" || t == "[object Proxy]";
686
+ }
687
+ function Ft(e) {
688
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= r;
689
+ }
690
+ function It(e) {
691
+ var t = typeof e;
692
+ return e != null && (t == "object" || t == "function");
693
+ }
694
+ function $(e) {
695
+ return typeof e == "object" && !!e;
696
+ }
697
+ var Lt = ce ? de(ce) : gt;
698
+ function Rt(e) {
699
+ return jt(e) ? ut(e) : _t(e);
700
+ }
701
+ function zt() {
702
+ return [];
703
+ }
704
+ function Bt() {
705
+ return !1;
706
+ }
707
+ t.exports = Nt;
708
+ })))(), 1), N = class {
709
+ constructor(e, t, n, r = !1, i = !1) {
710
+ this.enabled = !1, this.id = e, this.title = t, this.prefix = n, typeof r == "string" ? (this.groupId = r, this.enabled = i) : this.enabled = r;
711
+ }
712
+ }, P = class {
713
+ constructor(e, t) {
714
+ this.title = e, this.layers = t;
715
+ }
716
+ }, le = class {
717
+ constructor(e, t = "Layers") {
718
+ this.getDefaultPosition = () => "top-right", this._layers = e, this._layerIndex = {};
719
+ for (let e of this.getLayers()) {
720
+ if (this._layerIndex[e.id]) throw Error(`Duplicate layer ID "${e.id}". Layer IDs must be unique.`);
721
+ this._layerIndex[e.id] = e;
722
+ }
723
+ this._visible = this._default_visible = Object.values(this._layerIndex).filter((e) => e.enabled).map((e) => e.id), this._layerList = E("ul"), this._container = E("div", [E("h3", t), this._layerList], { class: "layer-switcher-list" });
724
+ }
725
+ getLayers() {
726
+ let e = [];
727
+ for (let t of this._layers) t instanceof P ? e.push(...t.layers) : t instanceof N && e.push(t);
728
+ return e;
729
+ }
730
+ setVisibility(e, t) {
731
+ t ? this._visible.includes(e) || this._visible.push(e) : this._visible = this._visible.filter((t) => t !== e), this._updateVisibility();
732
+ }
733
+ _updateVisibility() {
734
+ if (this._map) {
735
+ var e = this._map.getStyle().layers;
736
+ for (let t of e) {
737
+ let e = t.id;
738
+ for (let t in this._layerIndex) {
739
+ let n = this._layerIndex[t].prefix;
740
+ e.startsWith(n) && (this._visible.includes(t) ? this._map.setLayoutProperty(e, "visibility", "visible") : this._map.setLayoutProperty(e, "visibility", "none"));
741
+ }
742
+ }
743
+ this.urlhash && this.urlhash._updateHash();
744
+ }
745
+ }
746
+ setInitialVisibility(e) {
747
+ for (let t of e.layers) for (let e in this._layerIndex) {
748
+ let n = this._layerIndex[e].prefix;
749
+ t.id.startsWith(n) && !this._visible.includes(t.id) && (t.layout ||= {}, t.layout.visibility = "none");
750
+ }
751
+ this._updateList();
752
+ }
753
+ getURLString() {
754
+ return (0, ce.default)(this._visible.sort(), this._default_visible.sort()) ? "" : this._visible.sort().join(",");
755
+ }
756
+ setURLString(e) {
757
+ if (e) {
758
+ let t = e.split(",");
759
+ this._visible = t.length == 0 ? [...this._default_visible] : t.filter((e) => this._layerIndex[e]).map((e) => e);
760
+ } else this._visible = [...this._default_visible];
761
+ this._map?.isStyleLoaded() && this._updateVisibility(), this._updateList();
762
+ }
763
+ onAdd(e) {
764
+ this._map = e, e.isStyleLoaded() ? this._updateVisibility() : e.on("load", () => {
765
+ this._updateVisibility();
766
+ });
767
+ let t = E("button", {
768
+ class: "layer-switcher-button",
769
+ "aria-label": "Layer Switcher"
770
+ });
771
+ return t.onmouseover = () => {
772
+ let n = e.getContainer();
773
+ g(n, this._container);
774
+ var r = n.getBoundingClientRect(), i = t.getBoundingClientRect(), a = this._container.getBoundingClientRect();
775
+ this._container.style.top = i.top - r.top + "px", this._container.style.left = i.right - r.left - a.width + "px";
776
+ }, this._container.onmouseleave = () => {
777
+ d(e.getContainer(), this._container);
778
+ }, E("div", t, { class: "maplibregl-ctrl maplibregl-ctrl-group layer-switcher" });
779
+ }
780
+ onRemove() {
781
+ this._map = void 0;
782
+ }
783
+ _getLayerElement(e) {
784
+ if (e instanceof N) {
785
+ let t;
786
+ return t = e.groupId ? E("input", {
787
+ type: "radio",
788
+ name: e.groupId,
789
+ value: e.id,
790
+ checked: this._visible.includes(e.id) ? "checked" : void 0,
791
+ onchange: (t) => {
792
+ let n = this._container.querySelectorAll(`input[name=${e.groupId}]`);
793
+ for (let e of Array.from(n)) this.setVisibility(e.value, !1);
794
+ let r = this._container.querySelector(`input[name=${e.groupId}]:checked`);
795
+ r && this.setVisibility(r.value, !0);
796
+ }
797
+ }) : E("input", {
798
+ type: "checkbox",
799
+ checked: this._visible.includes(e.id),
800
+ onchange: (t) => {
801
+ this.setVisibility(e.id, t.target.checked);
802
+ }
803
+ }), E("li", E("label", e.title, t));
804
+ }
805
+ if (e instanceof P) return E("li.layer-switcher-group", [E("h4", e.title), E("ul", e.layers.map((e) => this._getLayerElement(e)))]);
806
+ throw Error("Unknown item type: " + e);
807
+ }
808
+ _updateList() {
809
+ this._layerList.replaceChildren(...this._layers.map((e) => this._getLayerElement(e)));
810
+ }
811
+ };
812
+ //#endregion
813
+ export { N as n, P as r, le as t };
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));function l(e,t){var n=u(e),r=n.tag,i=n.id,a=n.className,o=t?document.createElementNS(t,r):document.createElement(r);return i&&(o.id=i),a&&(t?o.setAttribute(`class`,a):o.className=a),o}function u(e){for(var t=e.split(/([.#])/),n=``,r=``,i=1;i<t.length;i+=2)switch(t[i]){case`.`:n+=` `+t[i+1];break;case`#`:r=t[i+1]}return{className:n.trim(),tag:t[0]||`div`,id:r}}function d(e,t){var n=w(e),r=w(t);return t===r&&r.__redom_view&&(t=r.__redom_view),r.parentNode&&(f(t,r,n),n.removeChild(r)),t}function f(e,t,n){var r=t.__redom_lifecycle;if(p(r)){t.__redom_lifecycle={};return}var i=n;for(t.__redom_mounted&&_(t,`onunmount`);i;){var a=i.__redom_lifecycle||{};for(var o in r)a[o]&&(a[o]-=r[o]);p(a)&&(i.__redom_lifecycle=null),i=i.parentNode}}function p(e){if(e==null)return!0;for(var t in e)if(e[t])return!1;return!0}var m=[`onmount`,`onremount`,`onunmount`],h=typeof window<`u`&&`ShadowRoot`in window;function g(e,t,n,r){var i=w(e),a=w(t);t===a&&a.__redom_view&&(t=a.__redom_view),t!==a&&(a.__redom_view=t);var o=a.__redom_mounted,s=a.parentNode;if(o&&s!==i&&f(t,a,s),n!=null){if(r){var c=w(n);c.__redom_mounted&&_(c,`onunmount`),i.replaceChild(a,c)}else i.insertBefore(a,w(n))}else i.appendChild(a);return v(t,a,i,s),t}function _(e,t){t===`onmount`||t===`onremount`?e.__redom_mounted=!0:t===`onunmount`&&(e.__redom_mounted=!1);var n=e.__redom_lifecycle;if(n){var r=e.__redom_view,i=0;for(var a in r&&r[t]&&r[t](),n)a&&i++;if(i)for(var o=e.firstChild;o;){var s=o.nextSibling;_(o,t),o=s}}}function v(e,t,n,r){for(var i=t.__redom_lifecycle||={},a=n===r,o=!1,s=0,c=m;s<c.length;s+=1){var l=c[s];a||e!==t&&l in e&&(i[l]=(i[l]||0)+1),i[l]&&(o=!0)}if(!o){t.__redom_lifecycle={};return}var u=n,d=!1;for((a||u&&u.__redom_mounted)&&(_(t,a?`onremount`:`onmount`),d=!0);u;){var f=u.parentNode,p=u.__redom_lifecycle||(u.__redom_lifecycle={});for(var g in i)p[g]=(p[g]||0)+i[g];if(d)break;(u.nodeType===Node.DOCUMENT_NODE||h&&u instanceof ShadowRoot||f&&f.__redom_mounted)&&(_(u,a?`onremount`:`onmount`),d=!0),u=f}}function y(e,t,n){var r=w(e);if(typeof t==`object`)for(var i in t)b(r,i,t[i]);else b(r,t,n)}function b(e,t,n){e.style[t]=n??``}var x=`http://www.w3.org/1999/xlink`;function ee(e,t,n,r){var i=w(e);if(typeof t==`object`)for(var a in t)ee(i,a,t[a],r);else{var o=i instanceof SVGElement,s=typeof n==`function`;if(t===`style`&&typeof n==`object`)y(i,n);else if(o&&s)i[t]=n;else if(t===`dataset`)ne(i,n);else if(!o&&(t in i||s)&&t!==`list`)i[t]=n;else{if(o&&t===`xlink`){te(i,n);return}r&&t===`class`&&(n=i.className+` `+n),n==null?i.removeAttribute(t):i.setAttribute(t,n)}}}function te(e,t,n){if(typeof t==`object`)for(var r in t)te(e,r,t[r]);else n==null?e.removeAttributeNS(x,t,n):e.setAttributeNS(x,t,n)}function ne(e,t,n){if(typeof t==`object`)for(var r in t)ne(e,r,t[r]);else n==null?delete e.dataset[t]:e.dataset[t]=n}function S(e){return document.createTextNode(e??``)}function C(e,t,n){for(var r=0,i=t;r<i.length;r+=1){var a=i[r];if(a===0||a){var o=typeof a;o===`function`?a(e):o===`string`||o===`number`?e.appendChild(S(a)):ie(w(a))?g(e,a):a.length?C(e,a,n):o===`object`&&ee(e,a,null,n)}}}function re(e){return typeof e==`string`?T(e):w(e)}function w(e){return e.nodeType&&e||!e.el&&e||w(e.el)}function ie(e){return e&&e.nodeType}function T(e){for(var t=[],n=arguments.length-1;n-->0;)t[n]=arguments[n+1];var r,i=typeof e;if(i===`string`)r=l(e);else if(i===`function`){var a=e;r=new(Function.prototype.bind.apply(a,[null].concat(t)))}else throw Error(`At least one argument required`);return C(w(r),t,!0),r}var E=T;T.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return T.bind.apply(T,[this].concat(e))};function D(e){for(var t=[],n=arguments.length-1;n-->0;)t[n]=arguments[n+1];for(var r=O(e,t,w(e).firstChild);r;){var i=r.nextSibling;d(e,r),r=i}}function O(e,t,n){for(var r=n,i=Array(t.length),a=0;a<t.length;a++)i[a]=t[a]&&w(t[a]);for(var o=0;o<t.length;o++){var s=t[o];if(s){var c=i[o];if(c===r){r=r.nextSibling;continue}if(ie(c)){var l=r&&r.nextSibling,u=s.__redom_index!=null&&l===i[o+1];g(e,s,r,u),u&&(r=l);continue}s.length!=null&&(r=O(e,s,r))}}return r}var ae=function(e,t,n){this.View=e,this.initData=n,this.oldLookup={},this.lookup={},this.oldViews=[],this.views=[],t!=null&&(this.key=typeof t==`function`?t:k(t))};ae.prototype.update=function(e,t){for(var n=this,r=n.View,i=n.key,a=n.initData,o=i!=null,s=this.lookup,c={},l=Array(e.length),u=this.views,d=0;d<e.length;d++){var f=e[d],p=void 0;if(o){var m=i(f);p=s[m]||new r(a,f,d,e),c[m]=p,p.__redom_id=m}else p=u[d]||new r(a,f,d,e);p.update&&p.update(f,d,e,t);var h=w(p.el);h.__redom_view=p,l[d]=p}this.oldViews=u,this.views=l,this.oldLookup=s,this.lookup=c};function k(e){return function(t){return t[e]}}var A=function(e,t,n,r){this.View=t,this.initData=r,this.views=[],this.pool=new ae(t,n,r),this.el=re(e),this.keySet=n!=null};A.prototype.update=function(e,t){e===void 0&&(e=[]);var n=this.keySet,r=this.views;this.pool.update(e,t);var i=this.pool,a=i.views,o=i.lookup;if(n)for(var s=0;s<r.length;s++){var c=r[s];o[c.__redom_id]??(c.__redom_index=null,d(this,c))}for(var l=0;l<a.length;l++){var u=a[l];u.__redom_index=l}D(this,a),n&&(this.lookup=o),this.views=a},A.extend=function(e,t,n,r){return A.bind(A,e,t,n,r)},A.extend;var oe=function(e,t){this.el=S(``),this.visible=!1,this.view=null,this._placeholder=this.el,e instanceof Node?this._el=e:e.el instanceof Node?(this._el=e,this.view=e):this._View=e,this._initData=t};oe.prototype.update=function(e,t){var n=this._placeholder,r=this.el.parentNode;if(e){if(!this.visible){if(this._el)g(r,this._el,n),d(r,n),this.el=w(this._el),this.visible=e;else{var i=this._View,a=new i(this._initData);this.el=w(a),this.view=a,g(r,a,n),d(r,n)}}this.view&&this.view.update&&this.view.update(t)}else if(this.visible){if(this._el){g(r,n,this._el),d(r,this._el),this.el=n,this.visible=e;return}g(r,n,this.view),d(r,this.view),this.el=n,this.view=null}this.visible=e};var se=function(e,t,n){this.el=re(e),this.Views=t,this.initData=n};se.prototype.update=function(e,t){if(e!==this.route){var n=this.Views[e];this.route=e,this.view=n&&(n instanceof Node||n.el instanceof Node)?n:n&&new n(this.initData,t),D(this.el,[this.view])}this.view&&this.view.update&&this.view.update(t,e)};var j=`http://www.w3.org/2000/svg`;function M(e){for(var t=[],n=arguments.length-1;n-->0;)t[n]=arguments[n+1];var r,i=typeof e;if(i===`string`)r=l(e,j);else if(i===`function`){var a=e;r=new(Function.prototype.bind.apply(a,[null].concat(t)))}else throw Error(`At least one argument required`);return C(w(r),t,!0),r}M.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return M.bind.apply(M,[this].concat(e))},M.ns=j;var ce=c(o(((e,t)=>{var n=`__lodash_hash_undefined__`,r=9007199254740991,i=`[object Arguments]`,a=`[object Array]`,o=`[object Boolean]`,s=`[object Date]`,c=`[object Error]`,l=`[object Function]`,u=`[object Map]`,d=`[object Number]`,f=`[object Object]`,p=`[object Promise]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object WeakMap]`,v=`[object ArrayBuffer]`,y=`[object DataView]`,b=`[object Float32Array]`,x=`[object Float64Array]`,ee=`[object Int8Array]`,te=`[object Int16Array]`,ne=`[object Int32Array]`,S=`[object Uint8Array]`,C=`[object Uint8ClampedArray]`,re=`[object Uint16Array]`,w=`[object Uint32Array]`,ie=/[\\^$.*+?()[\]{}|]/g,T=/^\[object .+?Constructor\]$/,E=/^(?:0|[1-9]\d*)$/,D={};D[b]=D[x]=D[ee]=D[te]=D[ne]=D[S]=D[C]=D[re]=D[w]=!0,D[i]=D[a]=D[v]=D[o]=D[y]=D[s]=D[c]=D[l]=D[u]=D[d]=D[f]=D[m]=D[h]=D[g]=D[_]=!1;var O=typeof global==`object`&&global&&global.Object===Object&&global,ae=typeof self==`object`&&self&&self.Object===Object&&self,k=O||ae||Function(`return this`)(),A=typeof e==`object`&&e&&!e.nodeType&&e,oe=A&&typeof t==`object`&&t&&!t.nodeType&&t,se=oe&&oe.exports===A,j=se&&O.process,M=function(){try{return j&&j.binding&&j.binding(`util`)}catch{}}(),ce=M&&M.isTypedArray;function N(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function P(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function le(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function ue(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function de(e){return function(t){return e(t)}}function fe(e,t){return e.has(t)}function pe(e,t){return e?.[t]}function me(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function he(e,t){return function(n){return e(t(n))}}function ge(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var _e=Array.prototype,ve=Function.prototype,F=Object.prototype,ye=k[`__core-js_shared__`],be=ve.toString,I=F.hasOwnProperty,xe=function(){var e=/[^.]+$/.exec(ye&&ye.keys&&ye.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),Se=F.toString,Ce=RegExp(`^`+be.call(I).replace(ie,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),we=se?k.Buffer:void 0,L=k.Symbol,Te=k.Uint8Array,Ee=F.propertyIsEnumerable,De=_e.splice,R=L?L.toStringTag:void 0,Oe=Object.getOwnPropertySymbols,ke=we?we.isBuffer:void 0,Ae=he(Object.keys,Object),je=Y(k,`DataView`),z=Y(k,`Map`),Me=Y(k,`Promise`),Ne=Y(k,`Set`),Pe=Y(k,`WeakMap`),B=Y(Object,`create`),Fe=Z(je),Ie=Z(z),Le=Z(Me),Re=Z(Ne),ze=Z(Pe),Be=L?L.prototype:void 0,Ve=Be?Be.valueOf:void 0;function V(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function He(){this.__data__=B?B(null):{},this.size=0}function Ue(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function We(e){var t=this.__data__;if(B){var r=t[e];return r===n?void 0:r}return I.call(t,e)?t[e]:void 0}function Ge(e){var t=this.__data__;return B?t[e]!==void 0:I.call(t,e)}function Ke(e,t){var r=this.__data__;return this.size+=+!this.has(e),r[e]=B&&t===void 0?n:t,this}V.prototype.clear=He,V.prototype.delete=Ue,V.prototype.get=We,V.prototype.has=Ge,V.prototype.set=Ke;function H(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function qe(){this.__data__=[],this.size=0}function Je(e){var t=this.__data__,n=K(t,e);return n<0?!1:(n==t.length-1?t.pop():De.call(t,n,1),--this.size,!0)}function Ye(e){var t=this.__data__,n=K(t,e);return n<0?void 0:t[n][1]}function Xe(e){return K(this.__data__,e)>-1}function Ze(e,t){var n=this.__data__,r=K(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}H.prototype.clear=qe,H.prototype.delete=Je,H.prototype.get=Ye,H.prototype.has=Xe,H.prototype.set=Ze;function U(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Qe(){this.size=0,this.__data__={hash:new V,map:new(z||H),string:new V}}function $e(e){var t=J(this,e).delete(e);return this.size-=+!!t,t}function et(e){return J(this,e).get(e)}function tt(e){return J(this,e).has(e)}function nt(e,t){var n=J(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}U.prototype.clear=Qe,U.prototype.delete=$e,U.prototype.get=et,U.prototype.has=tt,U.prototype.set=nt;function W(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new U;++t<n;)this.add(e[t])}function rt(e){return this.__data__.set(e,n),this}function it(e){return this.__data__.has(e)}W.prototype.add=W.prototype.push=rt,W.prototype.has=it;function G(e){var t=this.__data__=new H(e);this.size=t.size}function at(){this.__data__=new H,this.size=0}function ot(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function st(e){return this.__data__.get(e)}function ct(e){return this.__data__.has(e)}function lt(e,t){var n=this.__data__;if(n instanceof H){var r=n.__data__;if(!z||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new U(r)}return n.set(e,t),this.size=n.size,this}G.prototype.clear=at,G.prototype.delete=ot,G.prototype.get=st,G.prototype.has=ct,G.prototype.set=lt;function ut(e,t){var n=Q(e),r=!n&&At(e),i=!n&&!r&&Mt(e),a=!n&&!r&&!i&&Lt(e),o=n||r||i||a,s=o?ue(e.length,String):[],c=s.length;for(var l in e)(t||I.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||wt(l,c)))&&s.push(l);return s}function K(e,t){for(var n=e.length;n--;)if(kt(e[n][0],t))return n;return-1}function dt(e,t,n){var r=t(e);return Q(e)?r:P(r,n(e))}function q(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:R&&R in Object(e)?St(e):Ot(e)}function ft(e){return $(e)&&q(e)==i}function pt(e,t,n,r,i){return e===t?!0:e==null||t==null||!$(e)&&!$(t)?e!==e&&t!==t:mt(e,t,n,r,pt,i)}function mt(e,t,n,r,o,s){var c=Q(e),l=Q(t),u=c?a:X(e),d=l?a:X(t);u=u==i?f:u,d=d==i?f:d;var p=u==f,m=d==f,h=u==d;if(h&&Mt(e)){if(!Mt(t))return!1;c=!0,p=!1}if(h&&!p)return s||=new G,c||Lt(e)?vt(e,t,n,r,o,s):yt(e,t,u,n,r,o,s);if(!(n&1)){var g=p&&I.call(e,`__wrapped__`),_=m&&I.call(t,`__wrapped__`);if(g||_){var v=g?e.value():e,y=_?t.value():t;return s||=new G,o(v,y,n,r,s)}}return h?(s||=new G,bt(e,t,n,r,o,s)):!1}function ht(e){return!It(e)||Et(e)?!1:(Pt(e)?Ce:T).test(Z(e))}function gt(e){return $(e)&&Ft(e.length)&&!!D[q(e)]}function _t(e){if(!Dt(e))return Ae(e);var t=[];for(var n in Object(e))I.call(e,n)&&n!=`constructor`&&t.push(n);return t}function vt(e,t,n,r,i,a){var o=n&1,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var u=-1,d=!0,f=n&2?new W:void 0;for(a.set(e,t),a.set(t,e);++u<s;){var p=e[u],m=t[u];if(r)var h=o?r(m,p,u,t,e,a):r(p,m,u,e,t,a);if(h!==void 0){if(h)continue;d=!1;break}if(f){if(!le(t,function(e,t){if(!fe(f,t)&&(p===e||i(p,e,n,r,a)))return f.push(t)})){d=!1;break}}else if(!(p===m||i(p,m,n,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}function yt(e,t,n,r,i,a,l){switch(n){case y:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case v:return!(e.byteLength!=t.byteLength||!a(new Te(e),new Te(t)));case o:case s:case d:return kt(+e,+t);case c:return e.name==t.name&&e.message==t.message;case m:case g:return e==t+``;case u:var f=me;case h:var p=r&1;if(f||=ge,e.size!=t.size&&!p)return!1;var _=l.get(e);if(_)return _==t;r|=2,l.set(e,t);var b=vt(f(e),f(t),r,i,a,l);return l.delete(e),b;case`[object Symbol]`:if(Ve)return Ve.call(e)==Ve.call(t)}return!1}function bt(e,t,n,r,i,a){var o=n&1,s=xt(e),c=s.length;if(c!=xt(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:I.call(t,u)))return!1}var d=a.get(e);if(d&&a.get(t))return d==t;var f=!0;a.set(e,t),a.set(t,e);for(var p=o;++l<c;){u=s[l];var m=e[u],h=t[u];if(r)var g=o?r(h,m,u,t,e,a):r(m,h,u,e,t,a);if(!(g===void 0?m===h||i(m,h,n,r,a):g)){f=!1;break}p||=u==`constructor`}if(f&&!p){var _=e.constructor,v=t.constructor;_!=v&&`constructor`in e&&`constructor`in t&&!(typeof _==`function`&&_ instanceof _&&typeof v==`function`&&v instanceof v)&&(f=!1)}return a.delete(e),a.delete(t),f}function xt(e){return dt(e,Rt,Ct)}function J(e,t){var n=e.__data__;return Tt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Y(e,t){var n=pe(e,t);return ht(n)?n:void 0}function St(e){var t=I.call(e,R),n=e[R];try{e[R]=void 0;var r=!0}catch{}var i=Se.call(e);return r&&(t?e[R]=n:delete e[R]),i}var Ct=Oe?function(e){return e==null?[]:(e=Object(e),N(Oe(e),function(t){return Ee.call(e,t)}))}:zt,X=q;(je&&X(new je(new ArrayBuffer(1)))!=y||z&&X(new z)!=u||Me&&X(Me.resolve())!=p||Ne&&X(new Ne)!=h||Pe&&X(new Pe)!=_)&&(X=function(e){var t=q(e),n=t==f?e.constructor:void 0,r=n?Z(n):``;if(r)switch(r){case Fe:return y;case Ie:return u;case Le:return p;case Re:return h;case ze:return _}return t});function wt(e,t){return t??=r,!!t&&(typeof e==`number`||E.test(e))&&e>-1&&e%1==0&&e<t}function Tt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Et(e){return!!xe&&xe in e}function Dt(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||F)}function Ot(e){return Se.call(e)}function Z(e){if(e!=null){try{return be.call(e)}catch{}try{return e+``}catch{}}return``}function kt(e,t){return e===t||e!==e&&t!==t}var At=ft(function(){return arguments}())?ft:function(e){return $(e)&&I.call(e,`callee`)&&!Ee.call(e,`callee`)},Q=Array.isArray;function jt(e){return e!=null&&Ft(e.length)&&!Pt(e)}var Mt=ke||Bt;function Nt(e,t){return pt(e,t)}function Pt(e){if(!It(e))return!1;var t=q(e);return t==l||t==`[object GeneratorFunction]`||t==`[object AsyncFunction]`||t==`[object Proxy]`}function Ft(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=r}function It(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function $(e){return typeof e==`object`&&!!e}var Lt=ce?de(ce):gt;function Rt(e){return jt(e)?ut(e):_t(e)}function zt(){return[]}function Bt(){return!1}t.exports=Nt}))(),1),N=class{constructor(e,t,n,r=!1,i=!1){this.enabled=!1,this.id=e,this.title=t,this.prefix=n,typeof r==`string`?(this.groupId=r,this.enabled=i):this.enabled=r}},P=class{constructor(e,t){this.title=e,this.layers=t}},le=class{constructor(e,t=`Layers`){this.getDefaultPosition=()=>`top-right`,this._layers=e,this._layerIndex={};for(let e of this.getLayers()){if(this._layerIndex[e.id])throw Error(`Duplicate layer ID "${e.id}". Layer IDs must be unique.`);this._layerIndex[e.id]=e}this._visible=this._default_visible=Object.values(this._layerIndex).filter(e=>e.enabled).map(e=>e.id),this._layerList=E(`ul`),this._container=E(`div`,[E(`h3`,t),this._layerList],{class:`layer-switcher-list`})}getLayers(){let e=[];for(let t of this._layers)t instanceof P?e.push(...t.layers):t instanceof N&&e.push(t);return e}setVisibility(e,t){t?this._visible.includes(e)||this._visible.push(e):this._visible=this._visible.filter(t=>t!==e),this._updateVisibility()}_updateVisibility(){if(this._map){var e=this._map.getStyle().layers;for(let t of e){let e=t.id;for(let t in this._layerIndex){let n=this._layerIndex[t].prefix;e.startsWith(n)&&(this._visible.includes(t)?this._map.setLayoutProperty(e,`visibility`,`visible`):this._map.setLayoutProperty(e,`visibility`,`none`))}}this.urlhash&&this.urlhash._updateHash()}}setInitialVisibility(e){for(let t of e.layers)for(let e in this._layerIndex){let n=this._layerIndex[e].prefix;t.id.startsWith(n)&&!this._visible.includes(t.id)&&(t.layout||={},t.layout.visibility=`none`)}this._updateList()}getURLString(){return(0,ce.default)(this._visible.sort(),this._default_visible.sort())?``:this._visible.sort().join(`,`)}setURLString(e){if(e){let t=e.split(`,`);this._visible=t.length==0?[...this._default_visible]:t.filter(e=>this._layerIndex[e]).map(e=>e)}else this._visible=[...this._default_visible];this._map?.isStyleLoaded()&&this._updateVisibility(),this._updateList()}onAdd(e){this._map=e,e.isStyleLoaded()?this._updateVisibility():e.on(`load`,()=>{this._updateVisibility()});let t=E(`button`,{class:`layer-switcher-button`,"aria-label":`Layer Switcher`});return t.onmouseover=()=>{let n=e.getContainer();g(n,this._container);var r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this._container.getBoundingClientRect();this._container.style.top=i.top-r.top+`px`,this._container.style.left=i.right-r.left-a.width+`px`},this._container.onmouseleave=()=>{d(e.getContainer(),this._container)},E(`div`,t,{class:`maplibregl-ctrl maplibregl-ctrl-group layer-switcher`})}onRemove(){this._map=void 0}_getLayerElement(e){if(e instanceof N){let t;return t=e.groupId?E(`input`,{type:`radio`,name:e.groupId,value:e.id,checked:this._visible.includes(e.id)?`checked`:void 0,onchange:t=>{let n=this._container.querySelectorAll(`input[name=${e.groupId}]`);for(let e of Array.from(n))this.setVisibility(e.value,!1);let r=this._container.querySelector(`input[name=${e.groupId}]:checked`);r&&this.setVisibility(r.value,!0)}}):E(`input`,{type:`checkbox`,checked:this._visible.includes(e.id),onchange:t=>{this.setVisibility(e.id,t.target.checked)}}),E(`li`,E(`label`,e.title,t))}if(e instanceof P)return E(`li.layer-switcher-group`,[E(`h4`,e.title),E(`ul`,e.layers.map(e=>this._getLayerElement(e)))]);throw Error(`Unknown item type: `+e)}_updateList(){this._layerList.replaceChildren(...this._layers.map(e=>this._getLayerElement(e)))}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return le}});
@@ -0,0 +1 @@
1
+ const e=require("./layerswitcher-CezhM7p2.cjs");module.exports=e.t;
@@ -0,0 +1,42 @@
1
+ import { default as URLHash } from './urlhash';
2
+ import { Layer, LayerGroup } from './data';
3
+ import { Map, IControl, ControlPosition, StyleSpecification } from 'maplibre-gl';
4
+ /**
5
+ * A layer switcher control for MapLibre GL JS.
6
+ */
7
+ declare class LayerSwitcher implements IControl {
8
+ _layers: (Layer | LayerGroup)[];
9
+ _layerIndex: Record<string, Layer>;
10
+ _container: HTMLElement;
11
+ _visible: string[];
12
+ _default_visible: string[];
13
+ _layerList: HTMLElement;
14
+ _map: Map | undefined;
15
+ urlhash: URLHash | undefined;
16
+ /**
17
+ * A layer switcher control for MapLibre GL JS.
18
+ *
19
+ * @param layers a list of `Layer` or `LayerGroup` objects.
20
+ * @param title the title of the layer switcher (default "Layers").
21
+ */
22
+ constructor(layers: (Layer | LayerGroup)[], title?: string);
23
+ getLayers(): Layer[];
24
+ setVisibility(layerId: string, visible: boolean): void;
25
+ _updateVisibility(): void;
26
+ /**
27
+ * Modify a MapLibre GL style object before creating the map to set initial visibility states.
28
+ * This prevents flash-of-invisible-layers.
29
+ *
30
+ * @param style the MapLibre GL style object to modify
31
+ */
32
+ setInitialVisibility(style: StyleSpecification): void;
33
+ getURLString(): string;
34
+ setURLString(string: string): void;
35
+ onAdd(map: Map): HTMLDivElement;
36
+ onRemove(): void;
37
+ getDefaultPosition: () => ControlPosition;
38
+ _getLayerElement(item: Layer | LayerGroup): Node;
39
+ _updateList(): void;
40
+ }
41
+ export default LayerSwitcher;
42
+ //# sourceMappingURL=layerswitcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layerswitcher.d.ts","sourceRoot":"","sources":["../src/layerswitcher.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,qBAAqB,CAAA;AAE5B;;GAEG;AACH,cAAM,aAAc,YAAW,QAAQ;IACrC,OAAO,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAClC,UAAU,EAAE,WAAW,CAAA;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,UAAU,EAAE,WAAW,CAAA;IACvB,IAAI,EAAE,GAAG,GAAG,SAAS,CAAA;IACrB,OAAO,EAAE,OAAO,GAAG,SAAS,CAAA;IAE5B;;;;;OAKG;gBACS,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,EAAE,KAAK,GAAE,MAAiB;IAkBpE,SAAS,IAAI,KAAK,EAAE;IAYpB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAY/C,iBAAiB;IAwBjB;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,kBAAkB;IAe9C,YAAY;IAOZ,YAAY,CAAC,MAAM,EAAE,MAAM;IAqB3B,KAAK,CAAC,GAAG,EAAE,GAAG;IAkCd,QAAQ;IAIR,kBAAkB,QAAO,eAAe,CAAe;IAEvD,gBAAgB,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,IAAI;IA8ChD,WAAW;CAGZ;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as e } from "./layerswitcher-B7ForKVG.js";
2
+ export { e as default };
@@ -0,0 +1,2 @@
1
+ .layer-switcher{background:#fff url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%228%22%20height%3D%228%22%20viewBox%3D%220%200%208%208%22%3E%0A%20%20%3Cpath%20d%3D%22M0%200v4h4v-4h-4zm5%202v3h-3v1h4v-4h-1zm2%202v3h-3v1h4v-4h-1z%22%20/%3E%0A%3C/svg%3E) 50%/15px 15px no-repeat;min-width:30px;min-height:30px;font-size:22px}.layer-switcher-list{-webkit-user-select:none;user-select:none;z-index:1000;box-sizing:content-box;background:#fff;border-radius:4px;min-width:100px;padding-left:8px;padding-right:8px;font-size:15px;position:absolute;box-shadow:1px 1px 5px #0003;margin:0!important}@media screen and (width<=900px){.layer-switcher-list{font-size:1.2em;position:fixed;top:50px;left:10px;right:10px}}.layer-switcher-list h3{margin:6px 0 0}.layer-switcher-list h4{border-bottom:1px solid #ccc;width:100%;margin:0 0 .5rem;padding:0;display:inline-block}.layer-switcher-list ul{flex-direction:column;margin-bottom:4px;padding:0;list-style-type:none;display:flex}.layer-switcher-list li{width:100%}.layer-switcher-group+li{padding-top:10px}.layer-switcher-list li.layer-switcher-group{flex-direction:column;display:flex}.layer-switcher-list input{float:right;width:1em;height:1em;font-size:1em}.layer-switcher-list label{cursor:pointer;justify-content:space-between;align-items:center;width:100%;display:flex}
2
+ /*$vite$:1*/
@@ -0,0 +1,53 @@
1
+ import { default as LayerSwitcher } from './layerswitcher';
2
+ import { Map, MapOptions } from 'maplibre-gl';
3
+ export interface HashComponents {
4
+ zoom?: number;
5
+ center?: [number, number];
6
+ layers?: string;
7
+ additional: Record<string, string>;
8
+ }
9
+ export declare function decodeHash(hash: string): HashComponents;
10
+ export declare function encodeHash(components: HashComponents): string;
11
+ type ParameterCallbackFunction = (value: string | null) => void;
12
+ /**
13
+ * Object to manage the URL hash for a Maplibre GL JS map.
14
+ */
15
+ declare class URLHash {
16
+ layerSwitcher: LayerSwitcher;
17
+ _map: Map | undefined;
18
+ additional: Record<string, string>;
19
+ handlers: Record<string, ParameterCallbackFunction>;
20
+ constructor(layerSwitcher: LayerSwitcher);
21
+ enable(map: Map): void;
22
+ /**
23
+ * Register a handler for a URL hash parameter. The key will be included in
24
+ * the URL hash, so keep it as short as possible.
25
+ *
26
+ * @param key short key used to identify the parameter in the URL hash
27
+ * @param handler handler function that will be called when the parameter changes
28
+ */
29
+ registerHandler(key: string, handler: ParameterCallbackFunction): void;
30
+ /**
31
+ * Set a custom URL hash parameter. Use `registerHandler` to receive a notification
32
+ * when the parameter changes.
33
+ *
34
+ * @param key short key used to identify the parameter in the URL hash
35
+ * @param value the value of the parameter, or null to remove it.
36
+ */
37
+ setParameter(key: string, value: string | null): void;
38
+ _fireParameterChange(key: string, value: string | null): void;
39
+ _onHashChange(new_hash: string): void;
40
+ _updateHash(): void;
41
+ getHashString(): string;
42
+ /**
43
+ * Modify MapLibre GL map constructor options to include values from the URL hash.
44
+ *
45
+ * @param options the original options passed to the MapLibre GL `Map` constructor.
46
+ * You can include defaults for the `center` and `zoom` parameters.
47
+ * @returns an options object to be passed to the `Map` constructor, with the
48
+ * `center` and `zoom` parameters updated if necessary. Other options are untouched.
49
+ */
50
+ init(options: MapOptions): MapOptions;
51
+ }
52
+ export default URLHash;
53
+ //# sourceMappingURL=urlhash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlhash.d.ts","sourceRoot":"","sources":["../src/urlhash.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAsBvD;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CA2B7D;AAED,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;AAE/D;;GAEG;AACH,cAAM,OAAO;IACX,aAAa,EAAE,aAAa,CAAA;IAC5B,IAAI,EAAE,GAAG,GAAG,SAAS,CAAA;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;gBAEvC,aAAa,EAAE,aAAa;IAMxC,MAAM,CAAC,GAAG,EAAE,GAAG;IAmBf;;;;;;OAMG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB;IAI/D;;;;;;OAMG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW9C,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAMtD,aAAa,CAAC,QAAQ,EAAE,MAAM;IA6B9B,WAAW;IASX,aAAa;IAkBb;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;CAStC;AAED,eAAe,OAAO,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=urlhash.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlhash.test.d.ts","sourceRoot":"","sources":["../src/urlhash.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "@russss/maplibregl-layer-switcher",
3
- "version": "2.2.3",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "description": "Layer switcher for Maplibre GL JS based on layer prefixes",
6
6
  "exports": {
7
- ".": "./lib/index.js",
8
- "./*.css": "./lib/*.css"
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs"
10
+ },
11
+ "./layerswitcher": {
12
+ "import": "./dist/layerswitcher.js",
13
+ "require": "./dist/layerswitcher.cjs"
14
+ },
15
+ "./maplibregl-layer-switcher.css": "./dist/maplibregl-layer-switcher.css"
9
16
  },
10
- "types": "./lib/index.d.ts",
17
+ "types": "./dist/index.d.ts",
11
18
  "scripts": {
12
19
  "start": "vite",
13
- "build": "tsc && cp src/layerswitcher.css lib/",
20
+ "build": "vite build",
14
21
  "test": "jest"
15
22
  },
16
23
  "author": "Russ Garrett",
@@ -27,16 +34,17 @@
27
34
  "redom": "^3.24.2"
28
35
  },
29
36
  "devDependencies": {
30
- "@types/node": "^22.13.4",
31
37
  "@types/jest": "^29.5.3",
32
38
  "@types/lodash.isequal": "^4.5.6",
39
+ "@types/node": "^22.13.4",
33
40
  "jest": "^29.6.1",
34
41
  "jest-environment-jsdom": "^29.6.1",
35
- "maplibre-gl": "^5.3.0",
42
+ "maplibre-gl": "^6.7.0",
36
43
  "prettier": "^3.3.3",
37
44
  "ts-jest": "^29.1.1",
38
45
  "ts-node": "^10.9.2",
39
46
  "typescript": "^5.8.3",
40
- "vite": "^6.2.5"
47
+ "unplugin-dts": "^1.1.0",
48
+ "vite": "^8.2.2"
41
49
  }
42
50
  }