vue3-google-map 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,9 +1,9 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var d=document.createElement("style");d.appendChild(document.createTextNode(".mapdiv[data-v-7d660dd5]{width:100%;height:100%}.info-window-wrapper[data-v-45a4606d]{display:none}.mapdiv .info-window-wrapper[data-v-45a4606d]{display:inline-block}.custom-marker-wrapper[data-v-c7599d50]{display:none}.mapdiv .custom-marker-wrapper[data-v-c7599d50]{display:inline-block}")),document.head.appendChild(d)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- var Oe = Object.defineProperty;
3
- var xe = (o, e, t) => e in o ? Oe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
4
- var V = (o, e, t) => (xe(o, typeof e != "symbol" ? e + "" : e, t), t);
5
- import { defineComponent as k, ref as v, provide as q, watch as b, onMounted as ge, onBeforeUnmount as S, markRaw as M, toRef as L, openBlock as F, createElementBlock as G, createElementVNode as Y, renderSlot as U, normalizeProps as Pe, guardReactiveProps as Se, inject as y, computed as z, withDirectives as Le, vShow as Ie, Comment as ve, mergeProps as ye, createCommentVNode as Ce } from "vue";
6
- const I = Symbol("map"), E = Symbol("api"), _e = Symbol("marker"), ke = Symbol("markerCluster"), H = Symbol("CustomMarker"), we = Symbol("mapTilesLoaded"), P = [
1
+ (function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".mapdiv[data-v-174b771e]{width:100%;height:100%}.info-window-wrapper[data-v-45a4606d]{display:none}.mapdiv .info-window-wrapper[data-v-45a4606d]{display:inline-block}.custom-marker-wrapper[data-v-2d2d343a]{display:none}.mapdiv .custom-marker-wrapper[data-v-2d2d343a]{display:inline-block}")),document.head.appendChild(a)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
+ var qe = Object.defineProperty;
3
+ var Be = (n, e, t) => e in n ? qe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
4
+ var se = (n, e, t) => (Be(n, typeof e != "symbol" ? e + "" : e, t), t);
5
+ import { defineComponent as b, ref as y, provide as G, watch as O, onMounted as Me, onBeforeUnmount as B, markRaw as S, toRef as N, openBlock as Y, createElementBlock as X, createElementVNode as ae, renderSlot as Q, normalizeProps as Ne, guardReactiveProps as Ze, inject as C, computed as J, withDirectives as De, vShow as Ue, Comment as Ee, mergeProps as Pe, createCommentVNode as Oe } from "vue";
6
+ const Z = Symbol("map"), D = Symbol("api"), xe = Symbol("marker"), Le = Symbol("markerCluster"), ee = Symbol("CustomMarker"), Se = Symbol("mapTilesLoaded"), q = [
7
7
  "click",
8
8
  "dblclick",
9
9
  "drag",
@@ -16,18 +16,59 @@ const I = Symbol("map"), E = Symbol("api"), _e = Symbol("marker"), ke = Symbol("
16
16
  "mouseup",
17
17
  "rightclick"
18
18
  ];
19
- var Ee = function o(e, t) {
19
+ /*! *****************************************************************************
20
+ Copyright (c) Microsoft Corporation.
21
+
22
+ Permission to use, copy, modify, and/or distribute this software for any
23
+ purpose with or without fee is hereby granted.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
26
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
27
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
28
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
29
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
+ PERFORMANCE OF THIS SOFTWARE.
32
+ ***************************************************************************** */
33
+ function Fe(n, e, t, s) {
34
+ function r(o) {
35
+ return o instanceof t ? o : new t(function(a) {
36
+ a(o);
37
+ });
38
+ }
39
+ return new (t || (t = Promise))(function(o, a) {
40
+ function l(u) {
41
+ try {
42
+ h(s.next(u));
43
+ } catch (c) {
44
+ a(c);
45
+ }
46
+ }
47
+ function i(u) {
48
+ try {
49
+ h(s.throw(u));
50
+ } catch (c) {
51
+ a(c);
52
+ }
53
+ }
54
+ function h(u) {
55
+ u.done ? o(u.value) : r(u.value).then(l, i);
56
+ }
57
+ h((s = s.apply(n, e || [])).next());
58
+ });
59
+ }
60
+ var ze = function n(e, t) {
20
61
  if (e === t)
21
62
  return !0;
22
63
  if (e && t && typeof e == "object" && typeof t == "object") {
23
64
  if (e.constructor !== t.constructor)
24
65
  return !1;
25
- var n, s, r;
66
+ var s, r, o;
26
67
  if (Array.isArray(e)) {
27
- if (n = e.length, n != t.length)
68
+ if (s = e.length, s != t.length)
28
69
  return !1;
29
- for (s = n; s-- !== 0; )
30
- if (!o(e[s], t[s]))
70
+ for (r = s; r-- !== 0; )
71
+ if (!n(e[r], t[r]))
31
72
  return !1;
32
73
  return !0;
33
74
  }
@@ -37,22 +78,26 @@ var Ee = function o(e, t) {
37
78
  return e.valueOf() === t.valueOf();
38
79
  if (e.toString !== Object.prototype.toString)
39
80
  return e.toString() === t.toString();
40
- if (r = Object.keys(e), n = r.length, n !== Object.keys(t).length)
81
+ if (o = Object.keys(e), s = o.length, s !== Object.keys(t).length)
41
82
  return !1;
42
- for (s = n; s-- !== 0; )
43
- if (!Object.prototype.hasOwnProperty.call(t, r[s]))
83
+ for (r = s; r-- !== 0; )
84
+ if (!Object.prototype.hasOwnProperty.call(t, o[r]))
44
85
  return !1;
45
- for (s = n; s-- !== 0; ) {
46
- var a = r[s];
47
- if (!o(e[a], t[a]))
86
+ for (r = s; r-- !== 0; ) {
87
+ var a = o[r];
88
+ if (!n(e[a], t[a]))
48
89
  return !1;
49
90
  }
50
91
  return !0;
51
92
  }
52
93
  return e !== e && t !== t;
53
94
  };
54
- const ne = "__googleMapsScriptId";
55
- class O {
95
+ const he = "__googleMapsScriptId";
96
+ var R;
97
+ (function(n) {
98
+ n[n.INITIALIZED = 0] = "INITIALIZED", n[n.LOADING = 1] = "LOADING", n[n.SUCCESS = 2] = "SUCCESS", n[n.FAILURE = 3] = "FAILURE";
99
+ })(R || (R = {}));
100
+ class A {
56
101
  /**
57
102
  * Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
58
103
  * using this library, instead the defaults are set by the Google Maps
@@ -62,13 +107,13 @@ class O {
62
107
  * const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
63
108
  * ```
64
109
  */
65
- constructor({ apiKey: e, channel: t, client: n, id: s = ne, libraries: r = [], language: a, region: l, version: i, mapIds: p, nonce: u, retries: c = 3, url: h = "https://maps.googleapis.com/maps/api/js" }) {
66
- if (this.CALLBACK = "__googleMapsCallback", this.callbacks = [], this.done = !1, this.loading = !1, this.errors = [], this.version = i, this.apiKey = e, this.channel = t, this.client = n, this.id = s || ne, this.libraries = r, this.language = a, this.region = l, this.mapIds = p, this.nonce = u, this.retries = c, this.url = h, O.instance) {
67
- if (!Ee(this.options, O.instance.options))
68
- throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(O.instance.options)}`);
69
- return O.instance;
110
+ constructor({ apiKey: e, authReferrerPolicy: t, channel: s, client: r, id: o = he, language: a, libraries: l = [], mapIds: i, nonce: h, region: u, retries: c = 3, url: d = "https://maps.googleapis.com/maps/api/js", version: p }) {
111
+ if (this.callbacks = [], this.done = !1, this.loading = !1, this.errors = [], this.apiKey = e, this.authReferrerPolicy = t, this.channel = s, this.client = r, this.id = o || he, this.language = a, this.libraries = l, this.mapIds = i, this.nonce = h, this.region = u, this.retries = c, this.url = d, this.version = p, A.instance) {
112
+ if (!ze(this.options, A.instance.options))
113
+ throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(A.instance.options)}`);
114
+ return A.instance;
70
115
  }
71
- O.instance = this;
116
+ A.instance = this;
72
117
  }
73
118
  get options() {
74
119
  return {
@@ -82,9 +127,13 @@ class O {
82
127
  region: this.region,
83
128
  mapIds: this.mapIds,
84
129
  nonce: this.nonce,
85
- url: this.url
130
+ url: this.url,
131
+ authReferrerPolicy: this.authReferrerPolicy
86
132
  };
87
133
  }
134
+ get status() {
135
+ return this.errors.length ? R.FAILURE : this.done ? R.SUCCESS : this.loading ? R.LOADING : R.INITIALIZED;
136
+ }
88
137
  get failed() {
89
138
  return this.done && !this.loading && this.errors.length >= this.retries + 1;
90
139
  }
@@ -92,10 +141,11 @@ class O {
92
141
  * CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
93
142
  *
94
143
  * @ignore
144
+ * @deprecated
95
145
  */
96
146
  createUrl() {
97
147
  let e = this.url;
98
- return e += `?callback=${this.CALLBACK}`, this.apiKey && (e += `&key=${this.apiKey}`), this.channel && (e += `&channel=${this.channel}`), this.client && (e += `&client=${this.client}`), this.libraries.length > 0 && (e += `&libraries=${this.libraries.join(",")}`), this.language && (e += `&language=${this.language}`), this.region && (e += `&region=${this.region}`), this.version && (e += `&v=${this.version}`), this.mapIds && (e += `&map_ids=${this.mapIds.join(",")}`), e;
148
+ return e += "?callback=__googleMapsCallback", this.apiKey && (e += `&key=${this.apiKey}`), this.channel && (e += `&channel=${this.channel}`), this.client && (e += `&client=${this.client}`), this.libraries.length > 0 && (e += `&libraries=${this.libraries.join(",")}`), this.language && (e += `&language=${this.language}`), this.region && (e += `&region=${this.region}`), this.version && (e += `&v=${this.version}`), this.mapIds && (e += `&map_ids=${this.mapIds.join(",")}`), this.authReferrerPolicy && (e += `&auth_referrer_policy=${this.authReferrerPolicy}`), e;
99
149
  }
100
150
  deleteScript() {
101
151
  const e = document.getElementById(this.id);
@@ -103,6 +153,7 @@ class O {
103
153
  }
104
154
  /**
105
155
  * Load the Google Maps JavaScript API script and return a Promise.
156
+ * @deprecated, use importLibrary() instead.
106
157
  */
107
158
  load() {
108
159
  return this.loadPromise();
@@ -111,16 +162,21 @@ class O {
111
162
  * Load the Google Maps JavaScript API script and return a Promise.
112
163
  *
113
164
  * @ignore
165
+ * @deprecated, use importLibrary() instead.
114
166
  */
115
167
  loadPromise() {
116
168
  return new Promise((e, t) => {
117
- this.loadCallback((n) => {
118
- n ? t(n.error) : e(window.google);
169
+ this.loadCallback((s) => {
170
+ s ? t(s.error) : e(window.google);
119
171
  });
120
172
  });
121
173
  }
174
+ importLibrary(e) {
175
+ return this.execute(), google.maps.importLibrary(e);
176
+ }
122
177
  /**
123
178
  * Load the Google Maps JavaScript API script with a callback.
179
+ * @deprecated, use importLibrary() instead.
124
180
  */
125
181
  loadCallback(e) {
126
182
  this.callbacks.push(e), this.execute();
@@ -129,12 +185,45 @@ class O {
129
185
  * Set the script on document.
130
186
  */
131
187
  setScript() {
188
+ var e, t;
132
189
  if (document.getElementById(this.id)) {
133
190
  this.callback();
134
191
  return;
135
192
  }
136
- const e = this.createUrl(), t = document.createElement("script");
137
- t.id = this.id, t.type = "text/javascript", t.src = e, t.onerror = this.loadErrorCallback.bind(this), t.defer = !0, t.async = !0, this.nonce && (t.nonce = this.nonce), document.head.appendChild(t);
193
+ const s = {
194
+ key: this.apiKey,
195
+ channel: this.channel,
196
+ client: this.client,
197
+ libraries: this.libraries.length && this.libraries,
198
+ v: this.version,
199
+ mapIds: this.mapIds,
200
+ language: this.language,
201
+ region: this.region,
202
+ authReferrerPolicy: this.authReferrerPolicy
203
+ };
204
+ Object.keys(s).forEach(
205
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
+ (o) => !s[o] && delete s[o]
207
+ ), !((t = (e = window == null ? void 0 : window.google) === null || e === void 0 ? void 0 : e.maps) === null || t === void 0) && t.importLibrary || ((o) => {
208
+ let a, l, i, h = "The Google Maps JavaScript API", u = "google", c = "importLibrary", d = "__ib__", p = document, f = window;
209
+ f = f[u] || (f[u] = {});
210
+ const m = f.maps || (f.maps = {}), g = /* @__PURE__ */ new Set(), v = new URLSearchParams(), w = () => (
211
+ // @ts-ignore
212
+ a || (a = new Promise((_, M) => Fe(this, void 0, void 0, function* () {
213
+ var P;
214
+ yield l = p.createElement("script"), l.id = this.id, v.set("libraries", [...g] + "");
215
+ for (i in o)
216
+ v.set(i.replace(/[A-Z]/g, ($) => "_" + $[0].toLowerCase()), o[i]);
217
+ v.set("callback", u + ".maps." + d), l.src = this.url + "?" + v, m[d] = _, l.onerror = () => a = M(Error(h + " could not load.")), l.nonce = this.nonce || ((P = p.querySelector("script[nonce]")) === null || P === void 0 ? void 0 : P.nonce) || "", p.head.append(l);
218
+ })))
219
+ );
220
+ m[c] ? console.warn(h + " only loads once. Ignoring:", o) : m[c] = (_, ...M) => g.add(_) && w().then(() => m[c](_, ...M));
221
+ })(s);
222
+ const r = this.libraries.map((o) => this.importLibrary(o));
223
+ r.length || r.push(this.importLibrary("core")), Promise.all(r).then(() => this.callback(), (o) => {
224
+ const a = new ErrorEvent("error", { error: o });
225
+ this.loadErrorCallback(a);
226
+ });
138
227
  }
139
228
  /**
140
229
  * Reset the loader state.
@@ -148,15 +237,12 @@ class O {
148
237
  loadErrorCallback(e) {
149
238
  if (this.errors.push(e), this.errors.length <= this.retries) {
150
239
  const t = this.errors.length * Math.pow(2, this.errors.length);
151
- console.log(`Failed to load Google Maps script, retrying in ${t} ms.`), setTimeout(() => {
240
+ console.error(`Failed to load Google Maps script, retrying in ${t} ms.`), setTimeout(() => {
152
241
  this.deleteScript(), this.setScript();
153
242
  }, t);
154
243
  } else
155
244
  this.onerrorEvent = e, this.callback();
156
245
  }
157
- setCallback() {
158
- window.__googleMapsCallback = this.callback.bind(this);
159
- }
160
246
  callback() {
161
247
  this.done = !0, this.loading = !1, this.callbacks.forEach((e) => {
162
248
  e(this.onerrorEvent);
@@ -170,69 +256,69 @@ class O {
170
256
  console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."), this.callback();
171
257
  return;
172
258
  }
173
- this.loading || (this.loading = !0, this.setCallback(), this.setScript());
259
+ this.loading || (this.loading = !0, this.setScript());
174
260
  }
175
261
  }
176
262
  }
177
- function $e(o) {
178
- return class extends o.OverlayView {
179
- constructor(n) {
263
+ function Ve(n) {
264
+ return class extends n.OverlayView {
265
+ constructor(s) {
180
266
  super();
181
- V(this, "element");
182
- V(this, "opts");
183
- const { element: s, ...r } = n;
184
- this.element = s, this.opts = r, this.opts.map && this.setMap(this.opts.map);
267
+ se(this, "element");
268
+ se(this, "opts");
269
+ const { element: r, ...o } = s;
270
+ this.element = r, this.opts = o, this.opts.map && this.setMap(this.opts.map);
185
271
  }
186
272
  getPosition() {
187
- return this.opts.position ? this.opts.position instanceof o.LatLng ? this.opts.position : new o.LatLng(this.opts.position) : null;
273
+ return this.opts.position ? this.opts.position instanceof n.LatLng ? this.opts.position : new n.LatLng(this.opts.position) : null;
188
274
  }
189
275
  getVisible() {
190
276
  if (!this.element)
191
277
  return !1;
192
- const n = this.element;
193
- return n.style.display !== "none" && n.style.visibility !== "hidden" && (n.style.opacity === "" || Number(n.style.opacity) > 0.01);
278
+ const s = this.element;
279
+ return s.style.display !== "none" && s.style.visibility !== "hidden" && (s.style.opacity === "" || Number(s.style.opacity) > 0.01);
194
280
  }
195
281
  onAdd() {
196
282
  if (!this.element)
197
283
  return;
198
- const n = this.getPanes();
199
- n && n.overlayMouseTarget.appendChild(this.element);
284
+ const s = this.getPanes();
285
+ s && s.overlayMouseTarget.appendChild(this.element);
200
286
  }
201
287
  draw() {
202
288
  if (!this.element)
203
289
  return;
204
- const s = this.getProjection().fromLatLngToDivPixel(this.getPosition());
205
- if (s) {
290
+ const s = this.getProjection(), r = s == null ? void 0 : s.fromLatLngToDivPixel(this.getPosition());
291
+ if (r) {
206
292
  this.element.style.position = "absolute";
207
- const r = this.element.offsetHeight, a = this.element.offsetWidth;
293
+ const o = this.element.offsetHeight, a = this.element.offsetWidth;
208
294
  let l, i;
209
295
  switch (this.opts.anchorPoint) {
210
296
  case "TOP_CENTER":
211
- l = s.x - a / 2, i = s.y;
297
+ l = r.x - a / 2, i = r.y;
212
298
  break;
213
299
  case "BOTTOM_CENTER":
214
- l = s.x - a / 2, i = s.y - r;
300
+ l = r.x - a / 2, i = r.y - o;
215
301
  break;
216
302
  case "LEFT_CENTER":
217
- l = s.x, i = s.y - r / 2;
303
+ l = r.x, i = r.y - o / 2;
218
304
  break;
219
305
  case "RIGHT_CENTER":
220
- l = s.x - a, i = s.y - r / 2;
306
+ l = r.x - a, i = r.y - o / 2;
221
307
  break;
222
308
  case "TOP_LEFT":
223
- l = s.x, i = s.y;
309
+ l = r.x, i = r.y;
224
310
  break;
225
311
  case "TOP_RIGHT":
226
- l = s.x - a, i = s.y;
312
+ l = r.x - a, i = r.y;
227
313
  break;
228
314
  case "BOTTOM_LEFT":
229
- l = s.x, i = s.y - r;
315
+ l = r.x, i = r.y - o;
230
316
  break;
231
317
  case "BOTTOM_RIGHT":
232
- l = s.x - a, i = s.y - r;
318
+ l = r.x - a, i = r.y - o;
233
319
  break;
234
320
  default:
235
- l = s.x - a / 2, i = s.y - r / 2;
321
+ l = r.x - a / 2, i = r.y - o / 2;
236
322
  }
237
323
  this.element.style.left = l + "px", this.element.style.top = i + "px", this.element.style.transform = `translateX(${this.opts.offsetX || 0}px) translateY(${this.opts.offsetY || 0}px)`, this.opts.zIndex && (this.element.style.zIndex = this.opts.zIndex.toString());
238
324
  }
@@ -240,13 +326,14 @@ function $e(o) {
240
326
  onRemove() {
241
327
  this.element && this.element.remove();
242
328
  }
243
- setOptions(n) {
244
- this.opts = n, this.draw();
329
+ setOptions(s) {
330
+ const { element: r, ...o } = s;
331
+ this.element = r, this.opts = o, this.draw();
245
332
  }
246
333
  };
247
334
  }
248
- let oe;
249
- const re = [
335
+ let de;
336
+ const pe = [
250
337
  "bounds_changed",
251
338
  "center_changed",
252
339
  "click",
@@ -266,7 +353,7 @@ const re = [
266
353
  "tilesloaded",
267
354
  "tilt_changed",
268
355
  "zoom_changed"
269
- ], je = k({
356
+ ], Ge = b({
270
357
  props: {
271
358
  apiPromise: {
272
359
  type: Promise
@@ -454,104 +541,104 @@ const re = [
454
541
  required: !1
455
542
  }
456
543
  },
457
- emits: re,
458
- setup(o, { emit: e }) {
459
- const t = v(), n = v(!1), s = v(), r = v(), a = v(!1);
460
- q(I, s), q(E, r), q(we, a);
544
+ emits: pe,
545
+ setup(n, { emit: e }) {
546
+ const t = y(), s = y(!1), r = y(), o = y(), a = y(!1);
547
+ G(Z, r), G(D, o), G(Se, a);
461
548
  const l = () => {
462
- const c = { ...o };
549
+ const c = { ...n };
463
550
  Object.keys(c).forEach((m) => {
464
551
  c[m] === void 0 && delete c[m];
465
552
  });
466
- const f = (m) => {
553
+ const p = (m) => {
467
554
  var g;
468
- return m ? { position: (g = r.value) == null ? void 0 : g.ControlPosition[m] } : {};
469
- }, d = {
470
- scaleControlOptions: o.scaleControlStyle ? { style: o.scaleControlStyle } : {},
471
- panControlOptions: f(o.panControlPosition),
472
- zoomControlOptions: f(o.zoomControlPosition),
473
- rotateControlOptions: f(o.rotateControlPosition),
474
- streetViewControlOptions: f(o.streetViewControlPosition),
475
- fullscreenControlOptions: f(o.fullscreenControlPosition),
476
- disableDefaultUI: o.disableDefaultUi
555
+ return m ? { position: (g = o.value) == null ? void 0 : g.ControlPosition[m] } : {};
556
+ }, f = {
557
+ scaleControlOptions: n.scaleControlStyle ? { style: n.scaleControlStyle } : {},
558
+ panControlOptions: p(n.panControlPosition),
559
+ zoomControlOptions: p(n.zoomControlPosition),
560
+ rotateControlOptions: p(n.rotateControlPosition),
561
+ streetViewControlOptions: p(n.streetViewControlPosition),
562
+ fullscreenControlOptions: p(n.fullscreenControlPosition),
563
+ disableDefaultUI: n.disableDefaultUi
477
564
  };
478
- return { ...c, ...d };
479
- }, i = b(
480
- [r, s],
481
- ([c, h]) => {
482
- const f = c, d = h;
483
- f && d && (f.event.addListenerOnce(d, "tilesloaded", () => {
565
+ return { ...c, ...f };
566
+ }, i = O(
567
+ [o, r],
568
+ ([c, d]) => {
569
+ const p = c, f = d;
570
+ p && f && (p.event.addListenerOnce(f, "tilesloaded", () => {
484
571
  a.value = !0;
485
572
  }), setTimeout(i, 0));
486
573
  },
487
574
  { immediate: !0 }
488
- ), p = () => {
575
+ ), h = () => {
489
576
  try {
490
- const { apiKey: c, region: h, version: f, language: d, libraries: m } = o;
491
- oe = new O({ apiKey: c, region: h, version: f, language: d, libraries: m });
577
+ const { apiKey: c, region: d, version: p, language: f, libraries: m } = n;
578
+ de = new A({ apiKey: c, region: d, version: p, language: f, libraries: m });
492
579
  } catch (c) {
493
580
  console.error(c);
494
581
  }
495
582
  }, u = (c) => {
496
- r.value = M(c.maps), s.value = M(new c.maps.Map(t.value, l()));
497
- const h = $e(r.value);
498
- r.value[H] = h, re.forEach((d) => {
583
+ o.value = S(c.maps), r.value = S(new c.maps.Map(t.value, l()));
584
+ const d = Ve(o.value);
585
+ o.value[ee] = d, pe.forEach((f) => {
499
586
  var m;
500
- (m = s.value) == null || m.addListener(d, (g) => e(d, g));
501
- }), n.value = !0;
502
- const f = Object.keys(o).filter(
503
- (d) => !["apiPromise", "apiKey", "version", "libraries", "region", "language", "center", "zoom"].includes(d)
504
- ).map((d) => L(o, d));
505
- b(
506
- [() => o.center, () => o.zoom, ...f],
507
- ([d, m], [g, C]) => {
508
- var ee, te, se;
509
- const { center: w, zoom: j, ..._ } = l();
510
- (ee = s.value) == null || ee.setOptions(_), m !== void 0 && m !== C && ((te = s.value) == null || te.setZoom(m));
511
- const Z = !g || d.lng !== g.lng || d.lat !== g.lat;
512
- d && Z && ((se = s.value) == null || se.panTo(d));
587
+ (m = r.value) == null || m.addListener(f, (g) => e(f, g));
588
+ }), s.value = !0;
589
+ const p = Object.keys(n).filter(
590
+ (f) => !["apiPromise", "apiKey", "version", "libraries", "region", "language", "center", "zoom"].includes(f)
591
+ ).map((f) => N(n, f));
592
+ O(
593
+ [() => n.center, () => n.zoom, ...p],
594
+ ([f, m], [g, v]) => {
595
+ var $, E, F;
596
+ const { center: w, zoom: _, ...M } = l();
597
+ ($ = r.value) == null || $.setOptions(M), m !== void 0 && m !== v && ((E = r.value) == null || E.setZoom(m));
598
+ const P = !g || f.lng !== g.lng || f.lat !== g.lat;
599
+ f && P && ((F = r.value) == null || F.panTo(f));
513
600
  }
514
601
  );
515
602
  };
516
- return ge(() => {
517
- o.apiPromise && o.apiPromise instanceof Promise ? o.apiPromise.then(u) : (p(), oe.load().then(u));
518
- }), S(() => {
603
+ return Me(() => {
604
+ n.apiPromise && n.apiPromise instanceof Promise ? n.apiPromise.then(u) : (h(), de.load().then(u));
605
+ }), B(() => {
519
606
  var c;
520
- a.value = !1, s.value && ((c = r.value) == null || c.event.clearInstanceListeners(s.value));
521
- }), { mapRef: t, ready: n, map: s, api: r, mapTilesLoaded: a };
607
+ a.value = !1, r.value && ((c = o.value) == null || c.event.clearInstanceListeners(r.value));
608
+ }), { mapRef: t, ready: s, map: r, api: o, mapTilesLoaded: a };
522
609
  }
523
610
  });
524
- const K = (o, e) => {
525
- const t = o.__vccOpts || o;
526
- for (const [n, s] of e)
527
- t[n] = s;
611
+ const te = (n, e) => {
612
+ const t = n.__vccOpts || n;
613
+ for (const [s, r] of e)
614
+ t[s] = r;
528
615
  return t;
529
- }, Te = {
616
+ }, He = {
530
617
  ref: "mapRef",
531
618
  class: "mapdiv"
532
619
  };
533
- function qe(o, e, t, n, s, r) {
534
- return F(), G("div", null, [
535
- Y("div", Te, null, 512),
536
- U(o.$slots, "default", Pe(Se({ ready: o.ready, map: o.map, api: o.api, mapTilesLoaded: o.mapTilesLoaded })), void 0, !0)
620
+ function We(n, e, t, s, r, o) {
621
+ return Y(), X("div", null, [
622
+ ae("div", He, null, 512),
623
+ Q(n.$slots, "default", Ne(Ze({ ready: n.ready, map: n.map, api: n.api, mapTilesLoaded: n.mapTilesLoaded })), void 0, !0)
537
624
  ]);
538
625
  }
539
- const vt = /* @__PURE__ */ K(je, [["render", qe], ["__scopeId", "data-v-7d660dd5"]]);
540
- function Re(o) {
541
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
626
+ const Ot = /* @__PURE__ */ te(Ge, [["render", We], ["__scopeId", "data-v-174b771e"]]);
627
+ function Ke(n) {
628
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
542
629
  }
543
- var Ae = function o(e, t) {
630
+ var Je = function n(e, t) {
544
631
  if (e === t)
545
632
  return !0;
546
633
  if (e && t && typeof e == "object" && typeof t == "object") {
547
634
  if (e.constructor !== t.constructor)
548
635
  return !1;
549
- var n, s, r;
636
+ var s, r, o;
550
637
  if (Array.isArray(e)) {
551
- if (n = e.length, n != t.length)
638
+ if (s = e.length, s != t.length)
552
639
  return !1;
553
- for (s = n; s-- !== 0; )
554
- if (!o(e[s], t[s]))
640
+ for (r = s; r-- !== 0; )
641
+ if (!n(e[r], t[r]))
555
642
  return !1;
556
643
  return !0;
557
644
  }
@@ -561,51 +648,51 @@ var Ae = function o(e, t) {
561
648
  return e.valueOf() === t.valueOf();
562
649
  if (e.toString !== Object.prototype.toString)
563
650
  return e.toString() === t.toString();
564
- if (r = Object.keys(e), n = r.length, n !== Object.keys(t).length)
651
+ if (o = Object.keys(e), s = o.length, s !== Object.keys(t).length)
565
652
  return !1;
566
- for (s = n; s-- !== 0; )
567
- if (!Object.prototype.hasOwnProperty.call(t, r[s]))
653
+ for (r = s; r-- !== 0; )
654
+ if (!Object.prototype.hasOwnProperty.call(t, o[r]))
568
655
  return !1;
569
- for (s = n; s-- !== 0; ) {
570
- var a = r[s];
571
- if (!o(e[a], t[a]))
656
+ for (r = s; r-- !== 0; ) {
657
+ var a = o[r];
658
+ if (!n(e[a], t[a]))
572
659
  return !1;
573
660
  }
574
661
  return !0;
575
662
  }
576
663
  return e !== e && t !== t;
577
664
  };
578
- const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o === H, $ = (o, e, t, n) => {
579
- const s = v(), r = y(I, v()), a = y(E, v()), l = y(ke, v()), i = z(
580
- () => !!(l.value && a.value && (s.value instanceof a.value.Marker || s.value instanceof a.value[H]))
665
+ const T = /* @__PURE__ */ Ke(Je), Ye = (n) => n === "Marker", Xe = (n) => n === ee, U = (n, e, t, s) => {
666
+ const r = y(), o = C(Z, y()), a = C(D, y()), l = C(Le, y()), i = J(
667
+ () => !!(l.value && a.value && (r.value instanceof a.value.Marker || r.value instanceof a.value[ee]))
581
668
  );
582
- return b(
583
- [r, t],
584
- (p, [u, c]) => {
585
- var f, d, m;
586
- const h = !A(t.value, c) || r.value !== u;
587
- !r.value || !a.value || !h || (s.value ? (s.value.setOptions(t.value), i.value && ((f = l.value) == null || f.removeMarker(s.value), (d = l.value) == null || d.addMarker(s.value))) : (Ze(o) ? s.value = M(
588
- new a.value[o](t.value)
589
- ) : Be(o) ? s.value = M(
590
- new a.value[o](t.value)
591
- ) : s.value = M(
592
- new a.value[o]({
669
+ return O(
670
+ [o, t],
671
+ (h, [u, c]) => {
672
+ var p, f, m;
673
+ const d = !T(t.value, c) || o.value !== u;
674
+ !o.value || !a.value || !d || (r.value ? (r.value.setOptions(t.value), i.value && ((p = l.value) == null || p.removeMarker(r.value), (f = l.value) == null || f.addMarker(r.value))) : (Ye(n) ? r.value = S(
675
+ new a.value[n](t.value)
676
+ ) : Xe(n) ? r.value = S(
677
+ new a.value[n](t.value)
678
+ ) : r.value = S(
679
+ new a.value[n]({
593
680
  ...t.value,
594
- map: r.value
681
+ map: o.value
595
682
  })
596
- ), i.value ? (m = l.value) == null || m.addMarker(s.value) : s.value.setMap(r.value), e.forEach((g) => {
597
- var C;
598
- (C = s.value) == null || C.addListener(g, (w) => n(g, w));
683
+ ), i.value ? (m = l.value) == null || m.addMarker(r.value) : r.value.setMap(o.value), e.forEach((g) => {
684
+ var v;
685
+ (v = r.value) == null || v.addListener(g, (w) => s(g, w));
599
686
  })));
600
687
  },
601
688
  {
602
689
  immediate: !0
603
690
  }
604
- ), S(() => {
605
- var p, u;
606
- s.value && ((p = a.value) == null || p.event.clearInstanceListeners(s.value), i.value ? (u = l.value) == null || u.removeMarker(s.value) : s.value.setMap(null));
607
- }), s;
608
- }, ie = [
691
+ ), B(() => {
692
+ var h, u;
693
+ r.value && ((h = a.value) == null || h.event.clearInstanceListeners(r.value), i.value ? (u = l.value) == null || u.removeMarker(r.value) : r.value.setMap(null));
694
+ }), r;
695
+ }, fe = [
609
696
  "animation_changed",
610
697
  "click",
611
698
  "dblclick",
@@ -629,7 +716,7 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
629
716
  "shape_changed",
630
717
  "title_changed",
631
718
  "visible_changed"
632
- ], yt = k({
719
+ ], xt = b({
633
720
  name: "Marker",
634
721
  props: {
635
722
  options: {
@@ -637,15 +724,15 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
637
724
  required: !0
638
725
  }
639
726
  },
640
- emits: ie,
641
- setup(o, { emit: e, expose: t, slots: n }) {
642
- const s = L(o, "options"), r = $("Marker", ie, s, e);
643
- return q(_e, r), t({ marker: r }), () => {
727
+ emits: fe,
728
+ setup(n, { emit: e, expose: t, slots: s }) {
729
+ const r = N(n, "options"), o = U("Marker", fe, r, e);
730
+ return G(xe, o), t({ marker: o }), () => {
644
731
  var a;
645
- return (a = n.default) == null ? void 0 : a.call(n);
732
+ return (a = s.default) == null ? void 0 : a.call(s);
646
733
  };
647
734
  }
648
- }), Ct = k({
735
+ }), Lt = b({
649
736
  name: "Polyline",
650
737
  props: {
651
738
  options: {
@@ -653,13 +740,13 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
653
740
  required: !0
654
741
  }
655
742
  },
656
- emits: P,
657
- setup(o, { emit: e }) {
658
- const t = L(o, "options");
659
- return { polyline: $("Polyline", P, t, e) };
743
+ emits: q,
744
+ setup(n, { emit: e }) {
745
+ const t = N(n, "options");
746
+ return { polyline: U("Polyline", q, t, e) };
660
747
  },
661
748
  render: () => null
662
- }), _t = k({
749
+ }), St = b({
663
750
  name: "Polygon",
664
751
  props: {
665
752
  options: {
@@ -667,13 +754,13 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
667
754
  required: !0
668
755
  }
669
756
  },
670
- emits: P,
671
- setup(o, { emit: e }) {
672
- const t = L(o, "options");
673
- return { polygon: $("Polygon", P, t, e) };
757
+ emits: q,
758
+ setup(n, { emit: e }) {
759
+ const t = N(n, "options");
760
+ return { polygon: U("Polygon", q, t, e) };
674
761
  },
675
762
  render: () => null
676
- }), ae = P.concat(["bounds_changed"]), kt = k({
763
+ }), me = q.concat(["bounds_changed"]), It = b({
677
764
  name: "Rectangle",
678
765
  props: {
679
766
  options: {
@@ -681,13 +768,13 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
681
768
  required: !0
682
769
  }
683
770
  },
684
- emits: ae,
685
- setup(o, { emit: e }) {
686
- const t = L(o, "options");
687
- return { rectangle: $("Rectangle", ae, t, e) };
771
+ emits: me,
772
+ setup(n, { emit: e }) {
773
+ const t = N(n, "options");
774
+ return { rectangle: U("Rectangle", me, t, e) };
688
775
  },
689
776
  render: () => null
690
- }), le = P.concat(["center_changed", "radius_changed"]), wt = k({
777
+ }), ge = q.concat(["center_changed", "radius_changed"]), At = b({
691
778
  name: "Circle",
692
779
  props: {
693
780
  options: {
@@ -695,13 +782,13 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
695
782
  required: !0
696
783
  }
697
784
  },
698
- emits: le,
699
- setup(o, { emit: e }) {
700
- const t = L(o, "options");
701
- return { circle: $("Circle", le, t, e) };
785
+ emits: ge,
786
+ setup(n, { emit: e }) {
787
+ const t = N(n, "options");
788
+ return { circle: U("Circle", ge, t, e) };
702
789
  },
703
790
  render: () => null
704
- }), Ne = k({
791
+ }), Qe = b({
705
792
  props: {
706
793
  position: {
707
794
  type: String,
@@ -713,48 +800,48 @@ const A = /* @__PURE__ */ Re(Ae), Ze = (o) => o === "Marker", Be = (o) => o ===
713
800
  }
714
801
  },
715
802
  emits: ["content:loaded"],
716
- setup(o, { emit: e }) {
717
- const t = v(null), n = y(I, v()), s = y(E, v()), r = y(we, v(!1)), a = v(!1), l = b(
718
- [r, s, t],
719
- ([u, c, h]) => {
720
- c && u && h && (i(o.position), a.value = !0, e("content:loaded"), setTimeout(l, 0));
803
+ setup(n, { emit: e }) {
804
+ const t = y(null), s = C(Z, y()), r = C(D, y()), o = C(Se, y(!1)), a = y(!1), l = O(
805
+ [o, r, t],
806
+ ([u, c, d]) => {
807
+ c && u && d && (i(n.position), a.value = !0, e("content:loaded"), setTimeout(l, 0));
721
808
  },
722
809
  { immediate: !0 }
723
810
  ), i = (u) => {
724
- if (n.value && s.value && t.value) {
725
- const c = s.value.ControlPosition[u];
726
- n.value.controls[c].push(t.value);
811
+ if (s.value && r.value && t.value) {
812
+ const c = r.value.ControlPosition[u];
813
+ s.value.controls[c].push(t.value);
727
814
  }
728
- }, p = (u) => {
729
- if (n.value && s.value) {
815
+ }, h = (u) => {
816
+ if (s.value && r.value) {
730
817
  let c = null;
731
- const h = s.value.ControlPosition[u];
732
- n.value.controls[h].forEach((f, d) => {
733
- f === t.value && (c = d);
734
- }), c !== null && n.value.controls[h].removeAt(c);
818
+ const d = r.value.ControlPosition[u];
819
+ s.value.controls[d].forEach((p, f) => {
820
+ p === t.value && (c = f);
821
+ }), c !== null && s.value.controls[d].removeAt(c);
735
822
  }
736
823
  };
737
- return S(() => p(o.position)), b(
738
- () => o.position,
824
+ return B(() => h(n.position)), O(
825
+ () => n.position,
739
826
  (u, c) => {
740
- p(c), i(u);
827
+ h(c), i(u);
741
828
  }
742
- ), b(
743
- () => o.index,
829
+ ), O(
830
+ () => n.index,
744
831
  (u) => {
745
- u && t.value && (t.value.index = o.index);
832
+ u && t.value && (t.value.index = n.index);
746
833
  }
747
834
  ), { controlRef: t, showContent: a };
748
835
  }
749
- }), ze = { ref: "controlRef" };
750
- function De(o, e, t, n, s, r) {
751
- return Le((F(), G("div", ze, [
752
- U(o.$slots, "default")
836
+ }), et = { ref: "controlRef" };
837
+ function tt(n, e, t, s, r, o) {
838
+ return De((Y(), X("div", et, [
839
+ Q(n.$slots, "default")
753
840
  ], 512)), [
754
- [Ie, o.showContent]
841
+ [Ue, n.showContent]
755
842
  ]);
756
843
  }
757
- const bt = /* @__PURE__ */ K(Ne, [["render", De]]), ce = ["closeclick", "content_changed", "domready", "position_changed", "visible", "zindex_changed"], Fe = k({
844
+ const Tt = /* @__PURE__ */ te(Qe, [["render", tt]]), ve = ["closeclick", "content_changed", "domready", "position_changed", "visible", "zindex_changed"], st = b({
758
845
  inheritAttrs: !1,
759
846
  props: {
760
847
  options: {
@@ -762,146 +849,212 @@ const bt = /* @__PURE__ */ K(Ne, [["render", De]]), ce = ["closeclick", "content
762
849
  default: () => ({})
763
850
  }
764
851
  },
765
- emits: ce,
766
- setup(o, { slots: e, emit: t, expose: n }) {
767
- const s = v(), r = v(), a = y(I, v()), l = y(E, v()), i = y(_e, v());
768
- let p;
769
- const u = z(() => {
770
- var f;
771
- return (f = e.default) == null ? void 0 : f.call(e).some((d) => d.type !== ve);
772
- }), c = (f) => {
773
- var d;
774
- return (d = s.value) == null ? void 0 : d.open({ map: a.value, anchor: i.value, ...f });
775
- }, h = () => {
852
+ emits: ve,
853
+ setup(n, { slots: e, emit: t, expose: s }) {
854
+ const r = y(), o = y(), a = C(Z, y()), l = C(D, y()), i = C(xe, y());
855
+ let h;
856
+ const u = J(() => {
857
+ var p;
858
+ return (p = e.default) == null ? void 0 : p.call(e).some((f) => f.type !== Ee);
859
+ }), c = (p) => {
776
860
  var f;
777
- return (f = s.value) == null ? void 0 : f.close();
861
+ return (f = r.value) == null ? void 0 : f.open({ map: a.value, anchor: i.value, ...p });
862
+ }, d = () => {
863
+ var p;
864
+ return (p = r.value) == null ? void 0 : p.close();
778
865
  };
779
- return ge(() => {
780
- b(
781
- [a, () => o.options],
782
- ([f, d], [m, g]) => {
783
- const C = !A(d, g) || a.value !== m;
784
- a.value && l.value && C && (s.value ? (s.value.setOptions({
785
- ...d,
786
- content: u.value ? r.value : d.content
787
- }), i.value || c()) : (s.value = M(
866
+ return Me(() => {
867
+ O(
868
+ [a, () => n.options],
869
+ ([p, f], [m, g]) => {
870
+ const v = !T(f, g) || a.value !== m;
871
+ a.value && l.value && v && (r.value ? (r.value.setOptions({
872
+ ...f,
873
+ content: u.value ? o.value : f.content
874
+ }), i.value || c()) : (r.value = S(
788
875
  new l.value.InfoWindow({
789
- ...d,
790
- content: u.value ? r.value : d.content
876
+ ...f,
877
+ content: u.value ? o.value : f.content
791
878
  })
792
- ), i.value ? p = i.value.addListener("click", () => {
879
+ ), i.value ? h = i.value.addListener("click", () => {
793
880
  c();
794
- }) : c(), ce.forEach((w) => {
795
- var j;
796
- (j = s.value) == null || j.addListener(w, (_) => t(w, _));
881
+ }) : c(), ve.forEach((w) => {
882
+ var _;
883
+ (_ = r.value) == null || _.addListener(w, (M) => t(w, M));
797
884
  })));
798
885
  },
799
886
  {
800
887
  immediate: !0
801
888
  }
802
889
  );
803
- }), S(() => {
804
- var f;
805
- p && p.remove(), s.value && ((f = l.value) == null || f.event.clearInstanceListeners(s.value), h());
806
- }), n({ infoWindow: s, open: c, close: h }), { infoWindow: s, infoWindowRef: r, hasSlotContent: u, open: c, close: h };
890
+ }), B(() => {
891
+ var p;
892
+ h && h.remove(), r.value && ((p = l.value) == null || p.event.clearInstanceListeners(r.value), d());
893
+ }), s({ infoWindow: r, open: c, close: d }), { infoWindow: r, infoWindowRef: o, hasSlotContent: u, open: c, close: d };
807
894
  }
808
895
  });
809
- const Ge = {
896
+ const rt = {
810
897
  key: 0,
811
898
  class: "info-window-wrapper"
812
899
  };
813
- function Ue(o, e, t, n, s, r) {
814
- return o.hasSlotContent ? (F(), G("div", Ge, [
815
- Y("div", ye({ ref: "infoWindowRef" }, o.$attrs), [
816
- U(o.$slots, "default", {}, void 0, !0)
900
+ function nt(n, e, t, s, r, o) {
901
+ return n.hasSlotContent ? (Y(), X("div", rt, [
902
+ ae("div", Pe({ ref: "infoWindowRef" }, n.$attrs), [
903
+ Q(n.$slots, "default", {}, void 0, !0)
817
904
  ], 16)
818
- ])) : Ce("", !0);
819
- }
820
- const Mt = /* @__PURE__ */ K(Fe, [["render", Ue], ["__scopeId", "data-v-45a4606d"]]);
821
- function J(o, e, t, n, s, r) {
822
- if (s - n <= t)
823
- return;
824
- const a = n + s >> 1;
825
- be(o, e, a, n, s, r % 2), J(o, e, t, n, a - 1, r + 1), J(o, e, t, a + 1, s, r + 1);
905
+ ])) : Oe("", !0);
826
906
  }
827
- function be(o, e, t, n, s, r) {
828
- for (; s > n; ) {
829
- if (s - n > 600) {
830
- const p = s - n + 1, u = t - n + 1, c = Math.log(p), h = 0.5 * Math.exp(2 * c / 3), f = 0.5 * Math.sqrt(c * h * (p - h) / p) * (u - p / 2 < 0 ? -1 : 1), d = Math.max(n, Math.floor(t - u * h / p + f)), m = Math.min(s, Math.floor(t + (p - u) * h / p + f));
831
- be(o, e, t, d, m, r);
907
+ const $t = /* @__PURE__ */ te(st, [["render", nt], ["__scopeId", "data-v-45a4606d"]]), ye = [
908
+ Int8Array,
909
+ Uint8Array,
910
+ Uint8ClampedArray,
911
+ Int16Array,
912
+ Uint16Array,
913
+ Int32Array,
914
+ Uint32Array,
915
+ Float32Array,
916
+ Float64Array
917
+ ], re = 1, z = 8;
918
+ class le {
919
+ /**
920
+ * Creates an index from raw `ArrayBuffer` data.
921
+ * @param {ArrayBuffer} data
922
+ */
923
+ static from(e) {
924
+ if (!(e instanceof ArrayBuffer))
925
+ throw new Error("Data must be an instance of ArrayBuffer.");
926
+ const [t, s] = new Uint8Array(e, 0, 2);
927
+ if (t !== 219)
928
+ throw new Error("Data does not appear to be in a KDBush format.");
929
+ const r = s >> 4;
930
+ if (r !== re)
931
+ throw new Error(`Got v${r} data when expected v${re}.`);
932
+ const o = ye[s & 15];
933
+ if (!o)
934
+ throw new Error("Unrecognized array type.");
935
+ const [a] = new Uint16Array(e, 2, 1), [l] = new Uint32Array(e, 4, 1);
936
+ return new le(l, a, o, e);
937
+ }
938
+ /**
939
+ * Creates an index that will hold a given number of items.
940
+ * @param {number} numItems
941
+ * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
942
+ * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
943
+ * @param {ArrayBuffer} [data] (For internal use only)
944
+ */
945
+ constructor(e, t = 64, s = Float64Array, r) {
946
+ if (isNaN(e) || e < 0)
947
+ throw new Error(`Unpexpected numItems value: ${e}.`);
948
+ this.numItems = +e, this.nodeSize = Math.min(Math.max(+t, 2), 65535), this.ArrayType = s, this.IndexArrayType = e < 65536 ? Uint16Array : Uint32Array;
949
+ const o = ye.indexOf(this.ArrayType), a = e * 2 * this.ArrayType.BYTES_PER_ELEMENT, l = e * this.IndexArrayType.BYTES_PER_ELEMENT, i = (8 - l % 8) % 8;
950
+ if (o < 0)
951
+ throw new Error(`Unexpected typed array class: ${s}.`);
952
+ r && r instanceof ArrayBuffer ? (this.data = r, this.ids = new this.IndexArrayType(this.data, z, e), this.coords = new this.ArrayType(this.data, z + l + i, e * 2), this._pos = e * 2, this._finished = !0) : (this.data = new ArrayBuffer(z + a + l + i), this.ids = new this.IndexArrayType(this.data, z, e), this.coords = new this.ArrayType(this.data, z + l + i, e * 2), this._pos = 0, this._finished = !1, new Uint8Array(this.data, 0, 2).set([219, (re << 4) + o]), new Uint16Array(this.data, 2, 1)[0] = t, new Uint32Array(this.data, 4, 1)[0] = e);
953
+ }
954
+ /**
955
+ * Add a point to the index.
956
+ * @param {number} x
957
+ * @param {number} y
958
+ * @returns {number} An incremental index associated with the added item (starting from `0`).
959
+ */
960
+ add(e, t) {
961
+ const s = this._pos >> 1;
962
+ return this.ids[s] = s, this.coords[this._pos++] = e, this.coords[this._pos++] = t, s;
963
+ }
964
+ /**
965
+ * Perform indexing of the added points.
966
+ */
967
+ finish() {
968
+ const e = this._pos >> 1;
969
+ if (e !== this.numItems)
970
+ throw new Error(`Added ${e} items when expected ${this.numItems}.`);
971
+ return ie(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
972
+ }
973
+ /**
974
+ * Search the index for items within a given bounding box.
975
+ * @param {number} minX
976
+ * @param {number} minY
977
+ * @param {number} maxX
978
+ * @param {number} maxY
979
+ * @returns {number[]} An array of indices correponding to the found items.
980
+ */
981
+ range(e, t, s, r) {
982
+ if (!this._finished)
983
+ throw new Error("Data not yet indexed - call index.finish().");
984
+ const { ids: o, coords: a, nodeSize: l } = this, i = [0, o.length - 1, 0], h = [];
985
+ for (; i.length; ) {
986
+ const u = i.pop() || 0, c = i.pop() || 0, d = i.pop() || 0;
987
+ if (c - d <= l) {
988
+ for (let g = d; g <= c; g++) {
989
+ const v = a[2 * g], w = a[2 * g + 1];
990
+ v >= e && v <= s && w >= t && w <= r && h.push(o[g]);
991
+ }
992
+ continue;
993
+ }
994
+ const p = d + c >> 1, f = a[2 * p], m = a[2 * p + 1];
995
+ f >= e && f <= s && m >= t && m <= r && h.push(o[p]), (u === 0 ? e <= f : t <= m) && (i.push(d), i.push(p - 1), i.push(1 - u)), (u === 0 ? s >= f : r >= m) && (i.push(p + 1), i.push(c), i.push(1 - u));
832
996
  }
833
- const a = e[2 * t + r];
834
- let l = n, i = s;
835
- for (T(o, e, n, t), e[2 * s + r] > a && T(o, e, n, s); l < i; ) {
836
- for (T(o, e, l, i), l++, i--; e[2 * l + r] < a; )
837
- l++;
838
- for (; e[2 * i + r] > a; )
839
- i--;
997
+ return h;
998
+ }
999
+ /**
1000
+ * Search the index for items within a given radius.
1001
+ * @param {number} qx
1002
+ * @param {number} qy
1003
+ * @param {number} r Query radius.
1004
+ * @returns {number[]} An array of indices correponding to the found items.
1005
+ */
1006
+ within(e, t, s) {
1007
+ if (!this._finished)
1008
+ throw new Error("Data not yet indexed - call index.finish().");
1009
+ const { ids: r, coords: o, nodeSize: a } = this, l = [0, r.length - 1, 0], i = [], h = s * s;
1010
+ for (; l.length; ) {
1011
+ const u = l.pop() || 0, c = l.pop() || 0, d = l.pop() || 0;
1012
+ if (c - d <= a) {
1013
+ for (let g = d; g <= c; g++)
1014
+ we(o[2 * g], o[2 * g + 1], e, t) <= h && i.push(r[g]);
1015
+ continue;
1016
+ }
1017
+ const p = d + c >> 1, f = o[2 * p], m = o[2 * p + 1];
1018
+ we(f, m, e, t) <= h && i.push(r[p]), (u === 0 ? e - s <= f : t - s <= m) && (l.push(d), l.push(p - 1), l.push(1 - u)), (u === 0 ? e + s >= f : t + s >= m) && (l.push(p + 1), l.push(c), l.push(1 - u));
840
1019
  }
841
- e[2 * n + r] === a ? T(o, e, n, i) : (i++, T(o, e, i, s)), i <= t && (n = i + 1), t <= i && (s = i - 1);
1020
+ return i;
842
1021
  }
843
1022
  }
844
- function T(o, e, t, n) {
845
- W(o, t, n), W(e, 2 * t, 2 * n), W(e, 2 * t + 1, 2 * n + 1);
846
- }
847
- function W(o, e, t) {
848
- const n = o[e];
849
- o[e] = o[t], o[t] = n;
1023
+ function ie(n, e, t, s, r, o) {
1024
+ if (r - s <= t)
1025
+ return;
1026
+ const a = s + r >> 1;
1027
+ Ie(n, e, a, s, r, o), ie(n, e, t, s, a - 1, 1 - o), ie(n, e, t, a + 1, r, 1 - o);
850
1028
  }
851
- function He(o, e, t, n, s, r, a) {
852
- const l = [0, o.length - 1, 0], i = [];
853
- let p, u;
854
- for (; l.length; ) {
855
- const c = l.pop(), h = l.pop(), f = l.pop();
856
- if (h - f <= a) {
857
- for (let g = f; g <= h; g++)
858
- p = e[2 * g], u = e[2 * g + 1], p >= t && p <= s && u >= n && u <= r && i.push(o[g]);
859
- continue;
1029
+ function Ie(n, e, t, s, r, o) {
1030
+ for (; r > s; ) {
1031
+ if (r - s > 600) {
1032
+ const h = r - s + 1, u = t - s + 1, c = Math.log(h), d = 0.5 * Math.exp(2 * c / 3), p = 0.5 * Math.sqrt(c * d * (h - d) / h) * (u - h / 2 < 0 ? -1 : 1), f = Math.max(s, Math.floor(t - u * d / h + p)), m = Math.min(r, Math.floor(t + (h - u) * d / h + p));
1033
+ Ie(n, e, t, f, m, o);
860
1034
  }
861
- const d = Math.floor((f + h) / 2);
862
- p = e[2 * d], u = e[2 * d + 1], p >= t && p <= s && u >= n && u <= r && i.push(o[d]);
863
- const m = (c + 1) % 2;
864
- (c === 0 ? t <= p : n <= u) && (l.push(f), l.push(d - 1), l.push(m)), (c === 0 ? s >= p : r >= u) && (l.push(d + 1), l.push(h), l.push(m));
865
- }
866
- return i;
867
- }
868
- function Ke(o, e, t, n, s, r) {
869
- const a = [0, o.length - 1, 0], l = [], i = s * s;
870
- for (; a.length; ) {
871
- const p = a.pop(), u = a.pop(), c = a.pop();
872
- if (u - c <= r) {
873
- for (let g = c; g <= u; g++)
874
- ue(e[2 * g], e[2 * g + 1], t, n) <= i && l.push(o[g]);
875
- continue;
1035
+ const a = e[2 * t + o];
1036
+ let l = s, i = r;
1037
+ for (V(n, e, s, t), e[2 * r + o] > a && V(n, e, s, r); l < i; ) {
1038
+ for (V(n, e, l, i), l++, i--; e[2 * l + o] < a; )
1039
+ l++;
1040
+ for (; e[2 * i + o] > a; )
1041
+ i--;
876
1042
  }
877
- const h = Math.floor((c + u) / 2), f = e[2 * h], d = e[2 * h + 1];
878
- ue(f, d, t, n) <= i && l.push(o[h]);
879
- const m = (p + 1) % 2;
880
- (p === 0 ? t - s <= f : n - s <= d) && (a.push(c), a.push(h - 1), a.push(m)), (p === 0 ? t + s >= f : n + s >= d) && (a.push(h + 1), a.push(u), a.push(m));
1043
+ e[2 * s + o] === a ? V(n, e, s, i) : (i++, V(n, e, i, r)), i <= t && (s = i + 1), t <= i && (r = i - 1);
881
1044
  }
882
- return l;
883
1045
  }
884
- function ue(o, e, t, n) {
885
- const s = o - t, r = e - n;
886
- return s * s + r * r;
1046
+ function V(n, e, t, s) {
1047
+ ne(n, t, s), ne(e, 2 * t, 2 * s), ne(e, 2 * t + 1, 2 * s + 1);
887
1048
  }
888
- const Ve = (o) => o[0], We = (o) => o[1];
889
- class pe {
890
- constructor(e, t = Ve, n = We, s = 64, r = Float64Array) {
891
- this.nodeSize = s, this.points = e;
892
- const a = e.length < 65536 ? Uint16Array : Uint32Array, l = this.ids = new a(e.length), i = this.coords = new r(e.length * 2);
893
- for (let p = 0; p < e.length; p++)
894
- l[p] = p, i[2 * p] = t(e[p]), i[2 * p + 1] = n(e[p]);
895
- J(l, i, s, 0, l.length - 1, 0);
896
- }
897
- range(e, t, n, s) {
898
- return He(this.ids, this.coords, e, t, n, s, this.nodeSize);
899
- }
900
- within(e, t, n) {
901
- return Ke(this.ids, this.coords, e, t, n, this.nodeSize);
902
- }
1049
+ function ne(n, e, t) {
1050
+ const s = n[e];
1051
+ n[e] = n[t], n[t] = s;
903
1052
  }
904
- const Je = {
1053
+ function we(n, e, t, s) {
1054
+ const r = n - t, o = e - s;
1055
+ return r * r + o * o;
1056
+ }
1057
+ const ot = {
905
1058
  minZoom: 0,
906
1059
  // min zoom to generate clusters on
907
1060
  maxZoom: 16,
@@ -922,170 +1075,203 @@ const Je = {
922
1075
  reduce: null,
923
1076
  // (accumulated, props) => { accumulated.sum += props.sum; }
924
1077
  // properties to use for individual points when running the reducer
925
- map: (o) => o
1078
+ map: (n) => n
926
1079
  // props => ({sum: props.my_value})
927
- }, D = Math.fround || ((o) => (e) => (o[0] = +e, o[0]))(new Float32Array(1));
928
- class Xe {
1080
+ }, _e = Math.fround || ((n) => (e) => (n[0] = +e, n[0]))(new Float32Array(1)), I = 2, L = 3, oe = 4, x = 5, Ae = 6;
1081
+ class Te {
929
1082
  constructor(e) {
930
- this.options = R(Object.create(Je), e), this.trees = new Array(this.options.maxZoom + 1);
1083
+ this.options = Object.assign(Object.create(ot), e), this.trees = new Array(this.options.maxZoom + 1), this.stride = this.options.reduce ? 7 : 6, this.clusterProps = [];
931
1084
  }
932
1085
  load(e) {
933
- const { log: t, minZoom: n, maxZoom: s, nodeSize: r } = this.options;
1086
+ const { log: t, minZoom: s, maxZoom: r } = this.options;
934
1087
  t && console.time("total time");
935
- const a = `prepare ${e.length} points`;
936
- t && console.time(a), this.points = e;
937
- let l = [];
938
- for (let i = 0; i < e.length; i++)
939
- e[i].geometry && l.push(Qe(e[i], i));
940
- this.trees[s + 1] = new pe(l, he, fe, r, Float32Array), t && console.timeEnd(a);
941
- for (let i = s; i >= n; i--) {
942
- const p = +Date.now();
943
- l = this._cluster(l, i), this.trees[i] = new pe(l, he, fe, r, Float32Array), t && console.log("z%d: %d clusters in %dms", i, l.length, +Date.now() - p);
1088
+ const o = `prepare ${e.length} points`;
1089
+ t && console.time(o), this.points = e;
1090
+ const a = [];
1091
+ for (let i = 0; i < e.length; i++) {
1092
+ const h = e[i];
1093
+ if (!h.geometry)
1094
+ continue;
1095
+ const [u, c] = h.geometry.coordinates, d = _e(W(u)), p = _e(K(c));
1096
+ a.push(
1097
+ d,
1098
+ p,
1099
+ // projected point coordinates
1100
+ 1 / 0,
1101
+ // the last zoom the point was processed at
1102
+ i,
1103
+ // index of the source feature in the original input array
1104
+ -1,
1105
+ // parent cluster id
1106
+ 1
1107
+ // number of points in a cluster
1108
+ ), this.options.reduce && a.push(0);
1109
+ }
1110
+ let l = this.trees[r + 1] = this._createTree(a);
1111
+ t && console.timeEnd(o);
1112
+ for (let i = r; i >= s; i--) {
1113
+ const h = +Date.now();
1114
+ l = this.trees[i] = this._createTree(this._cluster(l, i)), t && console.log("z%d: %d clusters in %dms", i, l.numItems, +Date.now() - h);
944
1115
  }
945
1116
  return t && console.timeEnd("total time"), this;
946
1117
  }
947
1118
  getClusters(e, t) {
948
- let n = ((e[0] + 180) % 360 + 360) % 360 - 180;
949
- const s = Math.max(-90, Math.min(90, e[1]));
950
- let r = e[2] === 180 ? 180 : ((e[2] + 180) % 360 + 360) % 360 - 180;
1119
+ let s = ((e[0] + 180) % 360 + 360) % 360 - 180;
1120
+ const r = Math.max(-90, Math.min(90, e[1]));
1121
+ let o = e[2] === 180 ? 180 : ((e[2] + 180) % 360 + 360) % 360 - 180;
951
1122
  const a = Math.max(-90, Math.min(90, e[3]));
952
1123
  if (e[2] - e[0] >= 360)
953
- n = -180, r = 180;
954
- else if (n > r) {
955
- const u = this.getClusters([n, s, 180, a], t), c = this.getClusters([-180, s, r, a], t);
956
- return u.concat(c);
1124
+ s = -180, o = 180;
1125
+ else if (s > o) {
1126
+ const c = this.getClusters([s, r, 180, a], t), d = this.getClusters([-180, r, o, a], t);
1127
+ return c.concat(d);
957
1128
  }
958
- const l = this.trees[this._limitZoom(t)], i = l.range(B(n), N(a), B(r), N(s)), p = [];
959
- for (const u of i) {
960
- const c = l.points[u];
961
- p.push(c.numPoints ? de(c) : this.points[c.index]);
1129
+ const l = this.trees[this._limitZoom(t)], i = l.range(W(s), K(a), W(o), K(r)), h = l.data, u = [];
1130
+ for (const c of i) {
1131
+ const d = this.stride * c;
1132
+ u.push(h[d + x] > 1 ? ke(h, d, this.clusterProps) : this.points[h[d + L]]);
962
1133
  }
963
- return p;
1134
+ return u;
964
1135
  }
965
1136
  getChildren(e) {
966
- const t = this._getOriginId(e), n = this._getOriginZoom(e), s = "No cluster with the specified id.", r = this.trees[n];
967
- if (!r)
968
- throw new Error(s);
969
- const a = r.points[t];
970
- if (!a)
971
- throw new Error(s);
972
- const l = this.options.radius / (this.options.extent * Math.pow(2, n - 1)), i = r.within(a.x, a.y, l), p = [];
973
- for (const u of i) {
974
- const c = r.points[u];
975
- c.parentId === e && p.push(c.numPoints ? de(c) : this.points[c.index]);
1137
+ const t = this._getOriginId(e), s = this._getOriginZoom(e), r = "No cluster with the specified id.", o = this.trees[s];
1138
+ if (!o)
1139
+ throw new Error(r);
1140
+ const a = o.data;
1141
+ if (t * this.stride >= a.length)
1142
+ throw new Error(r);
1143
+ const l = this.options.radius / (this.options.extent * Math.pow(2, s - 1)), i = a[t * this.stride], h = a[t * this.stride + 1], u = o.within(i, h, l), c = [];
1144
+ for (const d of u) {
1145
+ const p = d * this.stride;
1146
+ a[p + oe] === e && c.push(a[p + x] > 1 ? ke(a, p, this.clusterProps) : this.points[a[p + L]]);
976
1147
  }
977
- if (p.length === 0)
978
- throw new Error(s);
979
- return p;
1148
+ if (c.length === 0)
1149
+ throw new Error(r);
1150
+ return c;
980
1151
  }
981
- getLeaves(e, t, n) {
982
- t = t || 10, n = n || 0;
983
- const s = [];
984
- return this._appendLeaves(s, e, t, n, 0), s;
1152
+ getLeaves(e, t, s) {
1153
+ t = t || 10, s = s || 0;
1154
+ const r = [];
1155
+ return this._appendLeaves(r, e, t, s, 0), r;
985
1156
  }
986
- getTile(e, t, n) {
987
- const s = this.trees[this._limitZoom(e)], r = Math.pow(2, e), { extent: a, radius: l } = this.options, i = l / a, p = (n - i) / r, u = (n + 1 + i) / r, c = {
1157
+ getTile(e, t, s) {
1158
+ const r = this.trees[this._limitZoom(e)], o = Math.pow(2, e), { extent: a, radius: l } = this.options, i = l / a, h = (s - i) / o, u = (s + 1 + i) / o, c = {
988
1159
  features: []
989
1160
  };
990
1161
  return this._addTileFeatures(
991
- s.range((t - i) / r, p, (t + 1 + i) / r, u),
992
- s.points,
1162
+ r.range((t - i) / o, h, (t + 1 + i) / o, u),
1163
+ r.data,
993
1164
  t,
994
- n,
995
- r,
1165
+ s,
1166
+ o,
996
1167
  c
997
1168
  ), t === 0 && this._addTileFeatures(
998
- s.range(1 - i / r, p, 1, u),
999
- s.points,
1000
- r,
1001
- n,
1002
- r,
1169
+ r.range(1 - i / o, h, 1, u),
1170
+ r.data,
1171
+ o,
1172
+ s,
1173
+ o,
1003
1174
  c
1004
- ), t === r - 1 && this._addTileFeatures(
1005
- s.range(0, p, i / r, u),
1006
- s.points,
1175
+ ), t === o - 1 && this._addTileFeatures(
1176
+ r.range(0, h, i / o, u),
1177
+ r.data,
1007
1178
  -1,
1008
- n,
1009
- r,
1179
+ s,
1180
+ o,
1010
1181
  c
1011
1182
  ), c.features.length ? c : null;
1012
1183
  }
1013
1184
  getClusterExpansionZoom(e) {
1014
1185
  let t = this._getOriginZoom(e) - 1;
1015
1186
  for (; t <= this.options.maxZoom; ) {
1016
- const n = this.getChildren(e);
1017
- if (t++, n.length !== 1)
1187
+ const s = this.getChildren(e);
1188
+ if (t++, s.length !== 1)
1018
1189
  break;
1019
- e = n[0].properties.cluster_id;
1190
+ e = s[0].properties.cluster_id;
1020
1191
  }
1021
1192
  return t;
1022
1193
  }
1023
- _appendLeaves(e, t, n, s, r) {
1194
+ _appendLeaves(e, t, s, r, o) {
1024
1195
  const a = this.getChildren(t);
1025
1196
  for (const l of a) {
1026
1197
  const i = l.properties;
1027
- if (i && i.cluster ? r + i.point_count <= s ? r += i.point_count : r = this._appendLeaves(e, i.cluster_id, n, s, r) : r < s ? r++ : e.push(l), e.length === n)
1198
+ if (i && i.cluster ? o + i.point_count <= r ? o += i.point_count : o = this._appendLeaves(e, i.cluster_id, s, r, o) : o < r ? o++ : e.push(l), e.length === s)
1028
1199
  break;
1029
1200
  }
1030
- return r;
1201
+ return o;
1202
+ }
1203
+ _createTree(e) {
1204
+ const t = new le(e.length / this.stride | 0, this.options.nodeSize, Float32Array);
1205
+ for (let s = 0; s < e.length; s += this.stride)
1206
+ t.add(e[s], e[s + 1]);
1207
+ return t.finish(), t.data = e, t;
1031
1208
  }
1032
- _addTileFeatures(e, t, n, s, r, a) {
1209
+ _addTileFeatures(e, t, s, r, o, a) {
1033
1210
  for (const l of e) {
1034
- const i = t[l], p = i.numPoints;
1035
- let u, c, h;
1036
- if (p)
1037
- u = Me(i), c = i.x, h = i.y;
1211
+ const i = l * this.stride, h = t[i + x] > 1;
1212
+ let u, c, d;
1213
+ if (h)
1214
+ u = $e(t, i, this.clusterProps), c = t[i], d = t[i + 1];
1038
1215
  else {
1039
- const m = this.points[i.index];
1040
- u = m.properties, c = B(m.geometry.coordinates[0]), h = N(m.geometry.coordinates[1]);
1216
+ const m = this.points[t[i + L]];
1217
+ u = m.properties;
1218
+ const [g, v] = m.geometry.coordinates;
1219
+ c = W(g), d = K(v);
1041
1220
  }
1042
- const f = {
1221
+ const p = {
1043
1222
  type: 1,
1044
1223
  geometry: [[
1045
- Math.round(this.options.extent * (c * r - n)),
1046
- Math.round(this.options.extent * (h * r - s))
1224
+ Math.round(this.options.extent * (c * o - s)),
1225
+ Math.round(this.options.extent * (d * o - r))
1047
1226
  ]],
1048
1227
  tags: u
1049
1228
  };
1050
- let d;
1051
- p ? d = i.id : this.options.generateId ? d = i.index : this.points[i.index].id && (d = this.points[i.index].id), d !== void 0 && (f.id = d), a.features.push(f);
1229
+ let f;
1230
+ h || this.options.generateId ? f = t[i + L] : f = this.points[t[i + L]].id, f !== void 0 && (p.id = f), a.features.push(p);
1052
1231
  }
1053
1232
  }
1054
1233
  _limitZoom(e) {
1055
1234
  return Math.max(this.options.minZoom, Math.min(Math.floor(+e), this.options.maxZoom + 1));
1056
1235
  }
1057
1236
  _cluster(e, t) {
1058
- const n = [], { radius: s, extent: r, reduce: a, minPoints: l } = this.options, i = s / (r * Math.pow(2, t));
1059
- for (let p = 0; p < e.length; p++) {
1060
- const u = e[p];
1061
- if (u.zoom <= t)
1237
+ const { radius: s, extent: r, reduce: o, minPoints: a } = this.options, l = s / (r * Math.pow(2, t)), i = e.data, h = [], u = this.stride;
1238
+ for (let c = 0; c < i.length; c += u) {
1239
+ if (i[c + I] <= t)
1062
1240
  continue;
1063
- u.zoom = t;
1064
- const c = this.trees[t + 1], h = c.within(u.x, u.y, i), f = u.numPoints || 1;
1065
- let d = f;
1066
- for (const m of h) {
1067
- const g = c.points[m];
1068
- g.zoom > t && (d += g.numPoints || 1);
1241
+ i[c + I] = t;
1242
+ const d = i[c], p = i[c + 1], f = e.within(i[c], i[c + 1], l), m = i[c + x];
1243
+ let g = m;
1244
+ for (const v of f) {
1245
+ const w = v * u;
1246
+ i[w + I] > t && (g += i[w + x]);
1069
1247
  }
1070
- if (d > f && d >= l) {
1071
- let m = u.x * f, g = u.y * f, C = a && f > 1 ? this._map(u, !0) : null;
1072
- const w = (p << 5) + (t + 1) + this.points.length;
1073
- for (const j of h) {
1074
- const _ = c.points[j];
1075
- if (_.zoom <= t)
1248
+ if (g > m && g >= a) {
1249
+ let v = d * m, w = p * m, _, M = -1;
1250
+ const P = ((c / u | 0) << 5) + (t + 1) + this.points.length;
1251
+ for (const $ of f) {
1252
+ const E = $ * u;
1253
+ if (i[E + I] <= t)
1076
1254
  continue;
1077
- _.zoom = t;
1078
- const Z = _.numPoints || 1;
1079
- m += _.x * Z, g += _.y * Z, _.parentId = w, a && (C || (C = this._map(u, !0)), a(C, this._map(_)));
1080
- }
1081
- u.parentId = w, n.push(Ye(m / d, g / d, w, d, C));
1082
- } else if (n.push(u), d > 1)
1083
- for (const m of h) {
1084
- const g = c.points[m];
1085
- g.zoom <= t || (g.zoom = t, n.push(g));
1255
+ i[E + I] = t;
1256
+ const F = i[E + x];
1257
+ v += i[E] * F, w += i[E + 1] * F, i[E + oe] = P, o && (_ || (_ = this._map(i, c, !0), M = this.clusterProps.length, this.clusterProps.push(_)), o(_, this._map(i, E)));
1086
1258
  }
1259
+ i[c + oe] = P, h.push(v / g, w / g, 1 / 0, P, -1, g), o && h.push(M);
1260
+ } else {
1261
+ for (let v = 0; v < u; v++)
1262
+ h.push(i[c + v]);
1263
+ if (g > 1)
1264
+ for (const v of f) {
1265
+ const w = v * u;
1266
+ if (!(i[w + I] <= t)) {
1267
+ i[w + I] = t;
1268
+ for (let _ = 0; _ < u; _++)
1269
+ h.push(i[w + _]);
1270
+ }
1271
+ }
1272
+ }
1087
1273
  }
1088
- return n;
1274
+ return h;
1089
1275
  }
1090
1276
  // get index of the point from which the cluster originated
1091
1277
  _getOriginId(e) {
@@ -1095,87 +1281,49 @@ class Xe {
1095
1281
  _getOriginZoom(e) {
1096
1282
  return (e - this.points.length) % 32;
1097
1283
  }
1098
- _map(e, t) {
1099
- if (e.numPoints)
1100
- return t ? R({}, e.properties) : e.properties;
1101
- const n = this.points[e.index].properties, s = this.options.map(n);
1102
- return t && s === n ? R({}, s) : s;
1284
+ _map(e, t, s) {
1285
+ if (e[t + x] > 1) {
1286
+ const a = this.clusterProps[e[t + Ae]];
1287
+ return s ? Object.assign({}, a) : a;
1288
+ }
1289
+ const r = this.points[e[t + L]].properties, o = this.options.map(r);
1290
+ return s && o === r ? Object.assign({}, o) : o;
1103
1291
  }
1104
1292
  }
1105
- function Ye(o, e, t, n, s) {
1106
- return {
1107
- x: D(o),
1108
- // weighted cluster center; round for consistency with Float32Array index
1109
- y: D(e),
1110
- zoom: 1 / 0,
1111
- // the last zoom the cluster was processed at
1112
- id: t,
1113
- // encodes index of the first child of the cluster and its zoom level
1114
- parentId: -1,
1115
- // parent cluster id
1116
- numPoints: n,
1117
- properties: s
1118
- };
1119
- }
1120
- function Qe(o, e) {
1121
- const [t, n] = o.geometry.coordinates;
1122
- return {
1123
- x: D(B(t)),
1124
- // projected point coordinates
1125
- y: D(N(n)),
1126
- zoom: 1 / 0,
1127
- // the last zoom the point was processed at
1128
- index: e,
1129
- // index of the source feature in the original input array,
1130
- parentId: -1
1131
- // parent cluster id
1132
- };
1133
- }
1134
- function de(o) {
1293
+ function ke(n, e, t) {
1135
1294
  return {
1136
1295
  type: "Feature",
1137
- id: o.id,
1138
- properties: Me(o),
1296
+ id: n[e + L],
1297
+ properties: $e(n, e, t),
1139
1298
  geometry: {
1140
1299
  type: "Point",
1141
- coordinates: [et(o.x), tt(o.y)]
1300
+ coordinates: [it(n[e]), at(n[e + 1])]
1142
1301
  }
1143
1302
  };
1144
1303
  }
1145
- function Me(o) {
1146
- const e = o.numPoints, t = e >= 1e4 ? `${Math.round(e / 1e3)}k` : e >= 1e3 ? `${Math.round(e / 100) / 10}k` : e;
1147
- return R(R({}, o.properties), {
1304
+ function $e(n, e, t) {
1305
+ const s = n[e + x], r = s >= 1e4 ? `${Math.round(s / 1e3)}k` : s >= 1e3 ? `${Math.round(s / 100) / 10}k` : s, o = n[e + Ae], a = o === -1 ? {} : Object.assign({}, t[o]);
1306
+ return Object.assign(a, {
1148
1307
  cluster: !0,
1149
- cluster_id: o.id,
1150
- point_count: e,
1151
- point_count_abbreviated: t
1308
+ cluster_id: n[e + L],
1309
+ point_count: s,
1310
+ point_count_abbreviated: r
1152
1311
  });
1153
1312
  }
1154
- function B(o) {
1155
- return o / 360 + 0.5;
1313
+ function W(n) {
1314
+ return n / 360 + 0.5;
1156
1315
  }
1157
- function N(o) {
1158
- const e = Math.sin(o * Math.PI / 180), t = 0.5 - 0.25 * Math.log((1 + e) / (1 - e)) / Math.PI;
1316
+ function K(n) {
1317
+ const e = Math.sin(n * Math.PI / 180), t = 0.5 - 0.25 * Math.log((1 + e) / (1 - e)) / Math.PI;
1159
1318
  return t < 0 ? 0 : t > 1 ? 1 : t;
1160
1319
  }
1161
- function et(o) {
1162
- return (o - 0.5) * 360;
1320
+ function it(n) {
1321
+ return (n - 0.5) * 360;
1163
1322
  }
1164
- function tt(o) {
1165
- const e = (180 - o * 360) * Math.PI / 180;
1323
+ function at(n) {
1324
+ const e = (180 - n * 360) * Math.PI / 180;
1166
1325
  return 360 * Math.atan(Math.exp(e)) / Math.PI - 90;
1167
1326
  }
1168
- function R(o, e) {
1169
- for (const t in e)
1170
- o[t] = e[t];
1171
- return o;
1172
- }
1173
- function he(o) {
1174
- return o.x;
1175
- }
1176
- function fe(o) {
1177
- return o.y;
1178
- }
1179
1327
  /*! *****************************************************************************
1180
1328
  Copyright (c) Microsoft Corporation.
1181
1329
 
@@ -1190,22 +1338,52 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1190
1338
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1191
1339
  PERFORMANCE OF THIS SOFTWARE.
1192
1340
  ***************************************************************************** */
1193
- function st(o, e) {
1341
+ function ce(n, e) {
1194
1342
  var t = {};
1195
- for (var n in o)
1196
- Object.prototype.hasOwnProperty.call(o, n) && e.indexOf(n) < 0 && (t[n] = o[n]);
1197
- if (o != null && typeof Object.getOwnPropertySymbols == "function")
1198
- for (var s = 0, n = Object.getOwnPropertySymbols(o); s < n.length; s++)
1199
- e.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(o, n[s]) && (t[n[s]] = o[n[s]]);
1343
+ for (var s in n)
1344
+ Object.prototype.hasOwnProperty.call(n, s) && e.indexOf(s) < 0 && (t[s] = n[s]);
1345
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
1346
+ for (var r = 0, s = Object.getOwnPropertySymbols(n); r < s.length; r++)
1347
+ e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, s[r]) && (t[s[r]] = n[s[r]]);
1200
1348
  return t;
1201
1349
  }
1202
- class X {
1350
+ class k {
1351
+ static isAdvancedMarkerAvailable(e) {
1352
+ return google.maps.marker && e.getMapCapabilities().isAdvancedMarkersAvailable === !0;
1353
+ }
1354
+ static isAdvancedMarker(e) {
1355
+ return google.maps.marker && e instanceof google.maps.marker.AdvancedMarkerElement;
1356
+ }
1357
+ static setMap(e, t) {
1358
+ this.isAdvancedMarker(e) ? e.map = t : e.setMap(t);
1359
+ }
1360
+ static getPosition(e) {
1361
+ if (this.isAdvancedMarker(e)) {
1362
+ if (e.position) {
1363
+ if (e.position instanceof google.maps.LatLng)
1364
+ return e.position;
1365
+ if (e.position.lat && e.position.lng)
1366
+ return new google.maps.LatLng(e.position.lat, e.position.lng);
1367
+ }
1368
+ return new google.maps.LatLng(null);
1369
+ }
1370
+ return e.getPosition();
1371
+ }
1372
+ static getVisible(e) {
1373
+ return this.isAdvancedMarker(e) ? !0 : e.getVisible();
1374
+ }
1375
+ }
1376
+ class H {
1203
1377
  constructor({ markers: e, position: t }) {
1204
1378
  this.markers = e, t && (t instanceof google.maps.LatLng ? this._position = t : this._position = new google.maps.LatLng(t));
1205
1379
  }
1206
1380
  get bounds() {
1207
- if (!(this.markers.length === 0 && !this._position))
1208
- return this.markers.reduce((e, t) => e.extend(t.getPosition()), new google.maps.LatLngBounds(this._position, this._position));
1381
+ if (this.markers.length === 0 && !this._position)
1382
+ return;
1383
+ const e = new google.maps.LatLngBounds(this._position, this._position);
1384
+ for (const t of this.markers)
1385
+ e.extend(k.getPosition(t));
1386
+ return e;
1209
1387
  }
1210
1388
  get position() {
1211
1389
  return this._position || this.bounds.getCenter();
@@ -1214,7 +1392,7 @@ class X {
1214
1392
  * Get the count of **visible** markers.
1215
1393
  */
1216
1394
  get count() {
1217
- return this.markers.filter((e) => e.getVisible()).length;
1395
+ return this.markers.filter((e) => k.getVisible(e)).length;
1218
1396
  }
1219
1397
  /**
1220
1398
  * Add a marker to the cluster.
@@ -1226,10 +1404,26 @@ class X {
1226
1404
  * Cleanup references and remove marker from map.
1227
1405
  */
1228
1406
  delete() {
1229
- this.marker && (this.marker.setMap(null), delete this.marker), this.markers.length = 0;
1407
+ this.marker && (k.setMap(this.marker, null), this.marker = void 0), this.markers.length = 0;
1230
1408
  }
1231
1409
  }
1232
- class nt {
1410
+ const lt = (n, e, t, s) => {
1411
+ const r = Re(n.getBounds(), e, s);
1412
+ return t.filter((o) => r.contains(k.getPosition(o)));
1413
+ }, Re = (n, e, t) => {
1414
+ const { northEast: s, southWest: r } = ct(n, e), o = ut({ northEast: s, southWest: r }, t);
1415
+ return ht(o, e);
1416
+ }, Ce = (n, e, t) => {
1417
+ const s = Re(n, e, t), r = s.getNorthEast(), o = s.getSouthWest();
1418
+ return [o.lng(), o.lat(), r.lng(), r.lat()];
1419
+ }, ct = (n, e) => ({
1420
+ northEast: e.fromLatLngToDivPixel(n.getNorthEast()),
1421
+ southWest: e.fromLatLngToDivPixel(n.getSouthWest())
1422
+ }), ut = ({ northEast: n, southWest: e }, t) => (n.x += t, n.y -= t, e.x -= t, e.y += t, { northEast: n, southWest: e }), ht = ({ northEast: n, southWest: e }, t) => {
1423
+ const s = t.fromDivPixelToLatLng(e), r = t.fromDivPixelToLatLng(n);
1424
+ return new google.maps.LatLngBounds(s, r);
1425
+ };
1426
+ class je {
1233
1427
  constructor({ maxZoom: e = 16 }) {
1234
1428
  this.maxZoom = e;
1235
1429
  }
@@ -1240,78 +1434,144 @@ class nt {
1240
1434
  * ```typescript
1241
1435
  * cluster({markers, map}: AlgorithmInput): Cluster[] {
1242
1436
  * if (shouldBypassClustering(map)) {
1243
- * return this.noop({markers, map})
1437
+ * return this.noop({markers})
1244
1438
  * }
1245
1439
  * }
1246
1440
  * ```
1247
1441
  */
1248
1442
  noop({ markers: e }) {
1249
- return ot(e);
1443
+ return pt(e);
1444
+ }
1445
+ }
1446
+ class dt extends je {
1447
+ constructor(e) {
1448
+ var { viewportPadding: t = 60 } = e, s = ce(e, ["viewportPadding"]);
1449
+ super(s), this.viewportPadding = 60, this.viewportPadding = t;
1450
+ }
1451
+ calculate({ markers: e, map: t, mapCanvasProjection: s }) {
1452
+ return t.getZoom() >= this.maxZoom ? {
1453
+ clusters: this.noop({
1454
+ markers: e
1455
+ }),
1456
+ changed: !1
1457
+ } : {
1458
+ clusters: this.cluster({
1459
+ markers: lt(t, s, e, this.viewportPadding),
1460
+ map: t,
1461
+ mapCanvasProjection: s
1462
+ })
1463
+ };
1250
1464
  }
1251
1465
  }
1252
- const ot = (o) => o.map((t) => new X({
1253
- position: t.getPosition(),
1466
+ const pt = (n) => n.map((t) => new H({
1467
+ position: k.getPosition(t),
1254
1468
  markers: [t]
1255
1469
  }));
1256
- class rt extends nt {
1470
+ class ft extends je {
1257
1471
  constructor(e) {
1258
- var { maxZoom: t, radius: n = 60 } = e, s = st(e, ["maxZoom", "radius"]);
1259
- super({ maxZoom: t }), this.superCluster = new Xe(Object.assign({ maxZoom: this.maxZoom, radius: n }, s)), this.state = { zoom: null };
1472
+ var { maxZoom: t, radius: s = 60 } = e, r = ce(e, ["maxZoom", "radius"]);
1473
+ super({ maxZoom: t }), this.state = { zoom: -1 }, this.superCluster = new Te(Object.assign({ maxZoom: this.maxZoom, radius: s }, r));
1260
1474
  }
1261
1475
  calculate(e) {
1262
1476
  let t = !1;
1263
- if (!A(e.markers, this.markers)) {
1477
+ const s = { zoom: e.map.getZoom() };
1478
+ if (!T(e.markers, this.markers)) {
1264
1479
  t = !0, this.markers = [...e.markers];
1265
- const s = this.markers.map((r) => ({
1266
- type: "Feature",
1267
- geometry: {
1268
- type: "Point",
1269
- coordinates: [
1270
- r.getPosition().lng(),
1271
- r.getPosition().lat()
1272
- ]
1273
- },
1274
- properties: { marker: r }
1275
- }));
1276
- this.superCluster.load(s);
1480
+ const r = this.markers.map((o) => {
1481
+ const a = k.getPosition(o);
1482
+ return {
1483
+ type: "Feature",
1484
+ geometry: {
1485
+ type: "Point",
1486
+ coordinates: [a.lng(), a.lat()]
1487
+ },
1488
+ properties: { marker: o }
1489
+ };
1490
+ });
1491
+ this.superCluster.load(r);
1277
1492
  }
1278
- const n = { zoom: e.map.getZoom() };
1279
- return t || this.state.zoom > this.maxZoom && n.zoom > this.maxZoom || (t = t || !A(this.state, n)), this.state = n, t && (this.clusters = this.cluster(e)), { clusters: this.clusters, changed: t };
1493
+ return t || (this.state.zoom <= this.maxZoom || s.zoom <= this.maxZoom) && (t = !T(this.state, s)), this.state = s, t && (this.clusters = this.cluster(e)), { clusters: this.clusters, changed: t };
1280
1494
  }
1281
1495
  cluster({ map: e }) {
1282
- return this.superCluster.getClusters([-180, -90, 180, 90], Math.round(e.getZoom())).map(this.transformCluster.bind(this));
1496
+ return this.superCluster.getClusters([-180, -90, 180, 90], Math.round(e.getZoom())).map((t) => this.transformCluster(t));
1283
1497
  }
1284
- transformCluster({ geometry: { coordinates: [e, t] }, properties: n }) {
1285
- if (n.cluster)
1286
- return new X({
1287
- markers: this.superCluster.getLeaves(n.cluster_id, 1 / 0).map((s) => s.properties.marker),
1288
- position: new google.maps.LatLng({ lat: t, lng: e })
1498
+ transformCluster({ geometry: { coordinates: [e, t] }, properties: s }) {
1499
+ if (s.cluster)
1500
+ return new H({
1501
+ markers: this.superCluster.getLeaves(s.cluster_id, 1 / 0).map((o) => o.properties.marker),
1502
+ position: { lat: t, lng: e }
1289
1503
  });
1290
- {
1291
- const s = n.marker;
1292
- return new X({
1293
- markers: [s],
1294
- position: s.getPosition()
1504
+ const r = s.marker;
1505
+ return new H({
1506
+ markers: [r],
1507
+ position: k.getPosition(r)
1508
+ });
1509
+ }
1510
+ }
1511
+ class mt extends dt {
1512
+ constructor(e) {
1513
+ var { maxZoom: t, radius: s = 60, viewportPadding: r = 60 } = e, o = ce(e, ["maxZoom", "radius", "viewportPadding"]);
1514
+ super({ maxZoom: t, viewportPadding: r }), this.superCluster = new Te(Object.assign({ maxZoom: this.maxZoom, radius: s }, o)), this.state = { zoom: -1, view: [0, 0, 0, 0] };
1515
+ }
1516
+ calculate(e) {
1517
+ const t = {
1518
+ zoom: Math.round(e.map.getZoom()),
1519
+ view: Ce(e.map.getBounds(), e.mapCanvasProjection, this.viewportPadding)
1520
+ };
1521
+ let s = !T(this.state, t);
1522
+ if (!T(e.markers, this.markers)) {
1523
+ s = !0, this.markers = [...e.markers];
1524
+ const r = this.markers.map((o) => {
1525
+ const a = k.getPosition(o);
1526
+ return {
1527
+ type: "Feature",
1528
+ geometry: {
1529
+ type: "Point",
1530
+ coordinates: [a.lng(), a.lat()]
1531
+ },
1532
+ properties: { marker: o }
1533
+ };
1295
1534
  });
1535
+ this.superCluster.load(r);
1296
1536
  }
1537
+ return s && (this.clusters = this.cluster(e), this.state = t), { clusters: this.clusters, changed: s };
1538
+ }
1539
+ cluster({ map: e, mapCanvasProjection: t }) {
1540
+ const s = {
1541
+ zoom: Math.round(e.getZoom()),
1542
+ view: Ce(e.getBounds(), t, this.viewportPadding)
1543
+ };
1544
+ return this.superCluster.getClusters(s.view, s.zoom).map((r) => this.transformCluster(r));
1545
+ }
1546
+ transformCluster({ geometry: { coordinates: [e, t] }, properties: s }) {
1547
+ if (s.cluster)
1548
+ return new H({
1549
+ markers: this.superCluster.getLeaves(s.cluster_id, 1 / 0).map((o) => o.properties.marker),
1550
+ position: { lat: t, lng: e }
1551
+ });
1552
+ const r = s.marker;
1553
+ return new H({
1554
+ markers: [r],
1555
+ position: k.getPosition(r)
1556
+ });
1297
1557
  }
1298
1558
  }
1299
- class it {
1559
+ class gt {
1300
1560
  constructor(e, t) {
1301
1561
  this.markers = { sum: e.length };
1302
- const n = t.map((r) => r.count), s = n.reduce((r, a) => r + a, 0);
1562
+ const s = t.map((o) => o.count), r = s.reduce((o, a) => o + a, 0);
1303
1563
  this.clusters = {
1304
1564
  count: t.length,
1305
1565
  markers: {
1306
- mean: s / t.length,
1307
- sum: s,
1308
- min: Math.min(...n),
1309
- max: Math.max(...n)
1566
+ mean: r / t.length,
1567
+ sum: r,
1568
+ min: Math.min(...s),
1569
+ max: Math.max(...s)
1310
1570
  }
1311
1571
  };
1312
1572
  }
1313
1573
  }
1314
- class at {
1574
+ class vt {
1315
1575
  /**
1316
1576
  * The default render function for the library used by {@link MarkerClusterer}.
1317
1577
  *
@@ -1350,67 +1610,76 @@ class at {
1350
1610
  * });
1351
1611
  * ```
1352
1612
  */
1353
- render({ count: e, position: t }, n) {
1354
- const s = e > Math.max(10, n.clusters.markers.mean) ? "#ff0000" : "#0000ff", r = window.btoa(`
1355
- <svg fill="${s}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240">
1356
- <circle cx="120" cy="120" opacity=".6" r="70" />
1357
- <circle cx="120" cy="120" opacity=".3" r="90" />
1358
- <circle cx="120" cy="120" opacity=".2" r="110" />
1359
- </svg>`);
1360
- return new google.maps.Marker({
1613
+ render({ count: e, position: t }, s, r) {
1614
+ const a = `<svg fill="${e > Math.max(10, s.clusters.markers.mean) ? "#ff0000" : "#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">
1615
+ <circle cx="120" cy="120" opacity=".6" r="70" />
1616
+ <circle cx="120" cy="120" opacity=".3" r="90" />
1617
+ <circle cx="120" cy="120" opacity=".2" r="110" />
1618
+ <text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${e}</text>
1619
+ </svg>`, l = `Cluster of ${e} markers`, i = Number(google.maps.Marker.MAX_ZINDEX) + e;
1620
+ if (k.isAdvancedMarkerAvailable(r)) {
1621
+ const u = document.createElement("div");
1622
+ u.innerHTML = a;
1623
+ const c = u.firstElementChild;
1624
+ c.setAttribute("transform", "translate(0 25)");
1625
+ const d = {
1626
+ map: r,
1627
+ position: t,
1628
+ zIndex: i,
1629
+ title: l,
1630
+ content: c
1631
+ };
1632
+ return new google.maps.marker.AdvancedMarkerElement(d);
1633
+ }
1634
+ const h = {
1361
1635
  position: t,
1636
+ zIndex: i,
1637
+ title: l,
1362
1638
  icon: {
1363
- url: `data:image/svg+xml;base64,${r}`,
1364
- scaledSize: new google.maps.Size(45, 45)
1365
- },
1366
- label: {
1367
- text: String(e),
1368
- color: "rgba(255,255,255,0.9)",
1369
- fontSize: "12px"
1370
- },
1371
- title: `Cluster of ${e} markers`,
1372
- // adjust zIndex to be above other markers
1373
- zIndex: Number(google.maps.Marker.MAX_ZINDEX) + e
1374
- });
1639
+ url: `data:image/svg+xml;base64,${btoa(a)}`,
1640
+ anchor: new google.maps.Point(25, 25)
1641
+ }
1642
+ };
1643
+ return new google.maps.Marker(h);
1375
1644
  }
1376
1645
  }
1377
- function lt(o, e) {
1646
+ function yt(n, e) {
1378
1647
  for (let t in e.prototype)
1379
- o.prototype[t] = e.prototype[t];
1648
+ n.prototype[t] = e.prototype[t];
1380
1649
  }
1381
- class Q {
1650
+ class ue {
1382
1651
  constructor() {
1383
- lt(Q, google.maps.OverlayView);
1652
+ yt(ue, google.maps.OverlayView);
1384
1653
  }
1385
1654
  }
1386
- var x;
1387
- (function(o) {
1388
- o.CLUSTERING_BEGIN = "clusteringbegin", o.CLUSTERING_END = "clusteringend", o.CLUSTER_CLICK = "click";
1389
- })(x || (x = {}));
1390
- const ct = (o, e, t) => {
1655
+ var j;
1656
+ (function(n) {
1657
+ n.CLUSTERING_BEGIN = "clusteringbegin", n.CLUSTERING_END = "clusteringend", n.CLUSTER_CLICK = "click";
1658
+ })(j || (j = {}));
1659
+ const wt = (n, e, t) => {
1391
1660
  t.fitBounds(e.bounds);
1392
1661
  };
1393
- class ut extends Q {
1394
- constructor({ map: e, markers: t = [], algorithm: n = new rt({}), renderer: s = new at(), onClusterClick: r = ct }) {
1395
- super(), this.markers = [...t], this.clusters = [], this.algorithm = n, this.renderer = s, this.onClusterClick = r, e && this.setMap(e);
1662
+ class _t extends ue {
1663
+ constructor({ map: e, markers: t = [], algorithmOptions: s = {}, algorithm: r = new ft(s), renderer: o = new vt(), onClusterClick: a = wt }) {
1664
+ super(), this.markers = [...t], this.clusters = [], this.algorithm = r, this.renderer = o, this.onClusterClick = a, e && this.setMap(e);
1396
1665
  }
1397
1666
  addMarker(e, t) {
1398
1667
  this.markers.includes(e) || (this.markers.push(e), t || this.render());
1399
1668
  }
1400
1669
  addMarkers(e, t) {
1401
- e.forEach((n) => {
1402
- this.addMarker(n, !0);
1670
+ e.forEach((s) => {
1671
+ this.addMarker(s, !0);
1403
1672
  }), t || this.render();
1404
1673
  }
1405
1674
  removeMarker(e, t) {
1406
- const n = this.markers.indexOf(e);
1407
- return n === -1 ? !1 : (e.setMap(null), this.markers.splice(n, 1), t || this.render(), !0);
1675
+ const s = this.markers.indexOf(e);
1676
+ return s === -1 ? !1 : (k.setMap(e, null), this.markers.splice(s, 1), t || this.render(), !0);
1408
1677
  }
1409
1678
  removeMarkers(e, t) {
1410
- let n = !1;
1411
- return e.forEach((s) => {
1412
- n = this.removeMarker(s, !0) || n;
1413
- }), n && !t && this.render(), n;
1679
+ let s = !1;
1680
+ return e.forEach((r) => {
1681
+ s = this.removeMarker(r, !0) || s;
1682
+ }), s && !t && this.render(), s;
1414
1683
  }
1415
1684
  clearMarkers(e) {
1416
1685
  this.markers.length = 0, e || this.render();
@@ -1420,14 +1689,23 @@ class ut extends Q {
1420
1689
  */
1421
1690
  render() {
1422
1691
  const e = this.getMap();
1423
- if (e instanceof google.maps.Map && this.getProjection()) {
1424
- google.maps.event.trigger(this, x.CLUSTERING_BEGIN, this);
1425
- const { clusters: t, changed: n } = this.algorithm.calculate({
1692
+ if (e instanceof google.maps.Map && e.getProjection()) {
1693
+ google.maps.event.trigger(this, j.CLUSTERING_BEGIN, this);
1694
+ const { clusters: t, changed: s } = this.algorithm.calculate({
1426
1695
  markers: this.markers,
1427
1696
  map: e,
1428
1697
  mapCanvasProjection: this.getProjection()
1429
1698
  });
1430
- (n || n == null) && (this.reset(), this.clusters = t, this.renderClusters()), google.maps.event.trigger(this, x.CLUSTERING_END, this);
1699
+ if (s || s == null) {
1700
+ const r = /* @__PURE__ */ new Set();
1701
+ for (const a of t)
1702
+ a.markers.length == 1 && r.add(a.markers[0]);
1703
+ const o = [];
1704
+ for (const a of this.clusters)
1705
+ a.marker != null && (a.markers.length == 1 ? r.has(a.marker) || k.setMap(a.marker, null) : o.push(a.marker));
1706
+ this.clusters = t, this.renderClusters(), requestAnimationFrame(() => o.forEach((a) => k.setMap(a, null)));
1707
+ }
1708
+ google.maps.event.trigger(this, j.CLUSTERING_END, this);
1431
1709
  }
1432
1710
  }
1433
1711
  onAdd() {
@@ -1437,22 +1715,22 @@ class ut extends Q {
1437
1715
  google.maps.event.removeListener(this.idleListener), this.reset();
1438
1716
  }
1439
1717
  reset() {
1440
- this.markers.forEach((e) => e.setMap(null)), this.clusters.forEach((e) => e.delete()), this.clusters = [];
1718
+ this.markers.forEach((e) => k.setMap(e, null)), this.clusters.forEach((e) => e.delete()), this.clusters = [];
1441
1719
  }
1442
1720
  renderClusters() {
1443
- const e = new it(this.markers, this.clusters), t = this.getMap();
1444
- this.clusters.forEach((n) => {
1445
- n.markers.length === 1 ? n.marker = n.markers[0] : (n.marker = this.renderer.render(n, e), this.onClusterClick && n.marker.addListener(
1721
+ const e = new gt(this.markers, this.clusters), t = this.getMap();
1722
+ this.clusters.forEach((s) => {
1723
+ s.markers.length === 1 ? s.marker = s.markers[0] : (s.marker = this.renderer.render(s, e, t), s.markers.forEach((r) => k.setMap(r, null)), this.onClusterClick && s.marker.addListener(
1446
1724
  "click",
1447
1725
  /* istanbul ignore next */
1448
- (s) => {
1449
- google.maps.event.trigger(this, x.CLUSTER_CLICK, n), this.onClusterClick(s, n, t);
1726
+ (r) => {
1727
+ google.maps.event.trigger(this, j.CLUSTER_CLICK, s), this.onClusterClick(r, s, t);
1450
1728
  }
1451
- )), n.marker.setMap(t);
1729
+ )), k.setMap(s.marker, t);
1452
1730
  });
1453
1731
  }
1454
1732
  }
1455
- const me = Object.values(x), Ot = k({
1733
+ const be = Object.values(j), Rt = b({
1456
1734
  name: "MarkerCluster",
1457
1735
  props: {
1458
1736
  options: {
@@ -1460,29 +1738,37 @@ const me = Object.values(x), Ot = k({
1460
1738
  default: () => ({})
1461
1739
  }
1462
1740
  },
1463
- emits: me,
1464
- setup(o, { emit: e, expose: t, slots: n }) {
1465
- const s = v(), r = y(I, v()), a = y(E, v());
1466
- return q(ke, s), b(
1467
- r,
1741
+ emits: be,
1742
+ setup(n, { emit: e, expose: t, slots: s }) {
1743
+ const r = y(), o = C(Z, y()), a = C(D, y());
1744
+ return G(Le, r), O(
1745
+ o,
1468
1746
  () => {
1469
- r.value && (s.value = M(new ut({ map: r.value, ...o.options })), me.forEach((l) => {
1747
+ o.value && (r.value = S(
1748
+ new _t({
1749
+ map: o.value,
1750
+ // Better perf than the default `SuperClusterAlgorithm`. See:
1751
+ // https://github.com/googlemaps/js-markerclusterer/pull/640
1752
+ algorithm: new mt(n.options.algorithmOptions ?? {}),
1753
+ ...n.options
1754
+ })
1755
+ ), be.forEach((l) => {
1470
1756
  var i;
1471
- (i = s.value) == null || i.addListener(l, (p) => e(l, p));
1757
+ (i = r.value) == null || i.addListener(l, (h) => e(l, h));
1472
1758
  }));
1473
1759
  },
1474
1760
  {
1475
1761
  immediate: !0
1476
1762
  }
1477
- ), S(() => {
1763
+ ), B(() => {
1478
1764
  var l;
1479
- s.value && ((l = a.value) == null || l.event.clearInstanceListeners(s.value), s.value.clearMarkers(), s.value.setMap(null));
1480
- }), t({ markerCluster: s }), () => {
1765
+ r.value && ((l = a.value) == null || l.event.clearInstanceListeners(r.value), r.value.clearMarkers(), r.value.setMap(null));
1766
+ }), t({ markerCluster: r }), () => {
1481
1767
  var l;
1482
- return (l = n.default) == null ? void 0 : l.call(n);
1768
+ return (l = s.default) == null ? void 0 : l.call(s);
1483
1769
  };
1484
1770
  }
1485
- }), pt = k({
1771
+ }), kt = b({
1486
1772
  inheritAttrs: !1,
1487
1773
  props: {
1488
1774
  options: {
@@ -1490,34 +1776,34 @@ const me = Object.values(x), Ot = k({
1490
1776
  required: !0
1491
1777
  }
1492
1778
  },
1493
- setup(o, { slots: e, emit: t, expose: n }) {
1494
- const s = v(), r = z(() => {
1779
+ setup(n, { slots: e, emit: t, expose: s }) {
1780
+ const r = y(), o = J(() => {
1495
1781
  var i;
1496
- return (i = e.default) == null ? void 0 : i.call(e).some((p) => p.type !== ve);
1497
- }), a = z(() => ({
1498
- ...o.options,
1499
- element: s.value
1500
- })), l = $(H, [], a, t);
1501
- return n({
1782
+ return (i = e.default) == null ? void 0 : i.call(e).some((h) => h.type !== Ee);
1783
+ }), a = J(() => ({
1784
+ ...n.options,
1785
+ element: r.value
1786
+ })), l = U(ee, [], a, t);
1787
+ return s({
1502
1788
  customMarker: l
1503
- }), { customMarkerRef: s, customMarker: l, hasSlotContent: r };
1789
+ }), { customMarkerRef: r, customMarker: l, hasSlotContent: o };
1504
1790
  }
1505
1791
  });
1506
- const dt = {
1792
+ const Ct = {
1507
1793
  key: 0,
1508
1794
  class: "custom-marker-wrapper"
1509
1795
  };
1510
- function ht(o, e, t, n, s, r) {
1511
- return o.hasSlotContent ? (F(), G("div", dt, [
1512
- Y("div", ye({
1796
+ function bt(n, e, t, s, r, o) {
1797
+ return n.hasSlotContent ? (Y(), X("div", Ct, [
1798
+ ae("div", Pe({
1513
1799
  ref: "customMarkerRef",
1514
- style: { cursor: o.$attrs.onClick ? "pointer" : void 0 }
1515
- }, o.$attrs), [
1516
- U(o.$slots, "default", {}, void 0, !0)
1800
+ style: { cursor: n.$attrs.onClick ? "pointer" : void 0 }
1801
+ }, n.$attrs), [
1802
+ Q(n.$slots, "default", {}, void 0, !0)
1517
1803
  ], 16)
1518
- ])) : Ce("", !0);
1804
+ ])) : Oe("", !0);
1519
1805
  }
1520
- const xt = /* @__PURE__ */ K(pt, [["render", ht], ["__scopeId", "data-v-c7599d50"]]), Pt = k({
1806
+ const jt = /* @__PURE__ */ te(kt, [["render", bt], ["__scopeId", "data-v-2d2d343a"]]), qt = b({
1521
1807
  name: "HeatmapLayer",
1522
1808
  props: {
1523
1809
  options: {
@@ -1525,21 +1811,21 @@ const xt = /* @__PURE__ */ K(pt, [["render", ht], ["__scopeId", "data-v-c7599d50
1525
1811
  default: () => ({})
1526
1812
  }
1527
1813
  },
1528
- setup(o) {
1529
- const e = v(), t = y(I, v()), n = y(E, v());
1530
- return b(
1531
- [t, () => o.options],
1532
- ([s, r], [a, l]) => {
1533
- var p;
1534
- const i = !A(r, l) || t.value !== a;
1535
- if (t.value && n.value && i) {
1536
- const u = structuredClone(r);
1537
- if (u.data && !(u.data instanceof n.value.MVCArray)) {
1538
- const c = n.value.LatLng;
1539
- u.data = (p = u.data) == null ? void 0 : p.map((h) => h instanceof c || "location" in h && (h.location instanceof c || h.location === null) ? h : "location" in h ? { ...h, location: new c(h.location) } : new c(h));
1814
+ setup(n) {
1815
+ const e = y(), t = C(Z, y()), s = C(D, y());
1816
+ return O(
1817
+ [t, () => n.options],
1818
+ ([r, o], [a, l]) => {
1819
+ var h;
1820
+ const i = !T(o, l) || t.value !== a;
1821
+ if (t.value && s.value && i) {
1822
+ const u = structuredClone(o);
1823
+ if (u.data && !(u.data instanceof s.value.MVCArray)) {
1824
+ const c = s.value.LatLng;
1825
+ u.data = (h = u.data) == null ? void 0 : h.map((d) => d instanceof c || "location" in d && (d.location instanceof c || d.location === null) ? d : "location" in d ? { ...d, location: new c(d.location) } : new c(d));
1540
1826
  }
1541
- e.value ? e.value.setOptions(u) : e.value = M(
1542
- new n.value.visualization.HeatmapLayer({
1827
+ e.value ? e.value.setOptions(u) : e.value = S(
1828
+ new s.value.visualization.HeatmapLayer({
1543
1829
  ...u,
1544
1830
  map: t.value
1545
1831
  })
@@ -1547,22 +1833,22 @@ const xt = /* @__PURE__ */ K(pt, [["render", ht], ["__scopeId", "data-v-c7599d50
1547
1833
  }
1548
1834
  },
1549
1835
  { immediate: !0 }
1550
- ), S(() => {
1836
+ ), B(() => {
1551
1837
  e.value && e.value.setMap(null);
1552
1838
  }), { heatmapLayer: e };
1553
1839
  },
1554
1840
  render: () => null
1555
1841
  });
1556
1842
  export {
1557
- wt as Circle,
1558
- bt as CustomControl,
1559
- xt as CustomMarker,
1560
- vt as GoogleMap,
1561
- Pt as HeatmapLayer,
1562
- Mt as InfoWindow,
1563
- yt as Marker,
1564
- Ot as MarkerCluster,
1565
- _t as Polygon,
1566
- Ct as Polyline,
1567
- kt as Rectangle
1843
+ At as Circle,
1844
+ Tt as CustomControl,
1845
+ jt as CustomMarker,
1846
+ Ot as GoogleMap,
1847
+ qt as HeatmapLayer,
1848
+ $t as InfoWindow,
1849
+ xt as Marker,
1850
+ Rt as MarkerCluster,
1851
+ St as Polygon,
1852
+ Lt as Polyline,
1853
+ It as Rectangle
1568
1854
  };