@local-logic/maps 0.0.4 → 0.0.6

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.
Files changed (153) hide show
  1. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  2. package/dist/index-B43MtiHH.js +30 -0
  3. package/dist/index-BAAE2pMq.js +64 -0
  4. package/dist/index-BHjgd5HB.js +29 -0
  5. package/dist/index-BZ2605rA.js +39 -0
  6. package/dist/index-B_LO5X9C.js +46 -0
  7. package/dist/index-BbrOUWDy.js +29 -0
  8. package/dist/index-Bd-X-1Gd.js +42 -0
  9. package/dist/index-CPq7k7F4.js +63 -0
  10. package/dist/index-CTk5bvm9.js +155 -0
  11. package/dist/index-CXLLvdx4.js +670 -0
  12. package/dist/index-CXjxZmYt.js +144 -0
  13. package/dist/index-DHw9gU4K.js +29 -0
  14. package/dist/index-DVitM43i.js +137 -0
  15. package/dist/index-J1MKzGEM.js +31 -0
  16. package/dist/index-qqbvBkdn.js +7 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.es.js +4 -0
  19. package/dist/index.modern-EsUgbhzI.js +908 -0
  20. package/dist/index.umd.js +3181 -0
  21. package/dist/logo-control-NE-LlsRy.js +607 -0
  22. package/dist/mapbox-gl-D58OubwB.js +32266 -0
  23. package/dist/maplibre-gl-CfOZKUDd.js +20722 -0
  24. package/dist/scale-control-CyJd4u6j.js +716 -0
  25. package/dist/src/components/Map/Root/BaseMap/Empty/index.d.ts +3 -0
  26. package/dist/src/components/Map/Root/BaseMap/Empty/index.d.ts.map +1 -0
  27. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts +11 -0
  28. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts.map +1 -0
  29. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts +4 -0
  30. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts.map +1 -0
  31. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts +4 -0
  32. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts.map +1 -0
  33. package/dist/src/components/Map/Root/BaseMap/index.d.ts +4 -0
  34. package/dist/src/components/Map/Root/BaseMap/index.d.ts.map +1 -0
  35. package/dist/src/components/Map/Root/BaseMap/styles.d.ts +2 -0
  36. package/dist/src/components/Map/Root/BaseMap/styles.d.ts.map +1 -0
  37. package/dist/src/components/Map/Root/BaseMap/types.d.ts +3 -0
  38. package/dist/src/components/Map/Root/BaseMap/types.d.ts.map +1 -0
  39. package/dist/src/components/Map/Root/Layers/Google/index.d.ts +4 -0
  40. package/dist/src/components/Map/Root/Layers/Google/index.d.ts.map +1 -0
  41. package/dist/src/components/Map/Root/Layers/Mapbox/index.d.ts +4 -0
  42. package/dist/src/components/Map/Root/Layers/Mapbox/index.d.ts.map +1 -0
  43. package/dist/src/components/Map/Root/Layers/Maptiler/index.d.ts +4 -0
  44. package/dist/src/components/Map/Root/Layers/Maptiler/index.d.ts.map +1 -0
  45. package/dist/src/components/Map/Root/Layers/index.d.ts +4 -0
  46. package/dist/src/components/Map/Root/Layers/index.d.ts.map +1 -0
  47. package/dist/src/components/Map/Root/Layers/types.d.ts +13 -0
  48. package/dist/src/components/Map/Root/Layers/types.d.ts.map +1 -0
  49. package/dist/src/components/Map/Root/Layers/utils.d.ts +6 -0
  50. package/dist/src/components/Map/Root/Layers/utils.d.ts.map +1 -0
  51. package/dist/src/components/Map/Root/Markers/Cluster/index.d.ts +6 -0
  52. package/dist/src/components/Map/Root/Markers/Cluster/index.d.ts.map +1 -0
  53. package/dist/src/components/Map/Root/Markers/Cluster/styles.d.ts +2 -0
  54. package/dist/src/components/Map/Root/Markers/Cluster/styles.d.ts.map +1 -0
  55. package/dist/src/components/Map/Root/Markers/Google/index.d.ts +4 -0
  56. package/dist/src/components/Map/Root/Markers/Google/index.d.ts.map +1 -0
  57. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts +4 -0
  58. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts.map +1 -0
  59. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts +4 -0
  60. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts.map +1 -0
  61. package/dist/src/components/Map/Root/Markers/index.d.ts +4 -0
  62. package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -0
  63. package/dist/src/components/Map/Root/Markers/styles.d.ts +5 -0
  64. package/dist/src/components/Map/Root/Markers/styles.d.ts.map +1 -0
  65. package/dist/src/components/Map/Root/Markers/types.d.ts +28 -0
  66. package/dist/src/components/Map/Root/Markers/types.d.ts.map +1 -0
  67. package/dist/src/components/Map/Root/Popup/Google/index.d.ts +4 -0
  68. package/dist/src/components/Map/Root/Popup/Google/index.d.ts.map +1 -0
  69. package/dist/src/components/Map/Root/Popup/Mapbox/index.d.ts +4 -0
  70. package/dist/src/components/Map/Root/Popup/Mapbox/index.d.ts.map +1 -0
  71. package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts +4 -0
  72. package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts.map +1 -0
  73. package/dist/src/components/Map/Root/Popup/index.d.ts +4 -0
  74. package/dist/src/components/Map/Root/Popup/index.d.ts.map +1 -0
  75. package/dist/src/components/Map/Root/Popup/styles.d.ts +2 -0
  76. package/dist/src/components/Map/Root/Popup/styles.d.ts.map +1 -0
  77. package/dist/src/components/Map/Root/Popup/types.d.ts +10 -0
  78. package/dist/src/components/Map/Root/Popup/types.d.ts.map +1 -0
  79. package/dist/src/components/Map/Root/constants.d.ts +7 -0
  80. package/dist/src/components/Map/Root/constants.d.ts.map +1 -0
  81. package/dist/src/components/Map/Root/context.d.ts +11 -0
  82. package/dist/src/components/Map/Root/context.d.ts.map +1 -0
  83. package/dist/src/components/Map/Root/index.d.ts +11 -0
  84. package/dist/src/components/Map/Root/index.d.ts.map +1 -0
  85. package/dist/src/components/Map/Root/types.d.ts +26 -0
  86. package/dist/src/components/Map/Root/types.d.ts.map +1 -0
  87. package/dist/src/components/Map/index.d.ts +2 -0
  88. package/dist/src/components/Map/index.d.ts.map +1 -0
  89. package/dist/src/components/Map/index.stories.d.ts +8 -0
  90. package/dist/src/components/Map/index.stories.d.ts.map +1 -0
  91. package/dist/src/components/Map/index.test.d.ts +2 -0
  92. package/dist/src/components/Map/index.test.d.ts.map +1 -0
  93. package/dist/src/components/Map/storybook-data.d.ts +18 -0
  94. package/dist/src/components/Map/storybook-data.d.ts.map +1 -0
  95. package/dist/src/index.d.ts +2 -0
  96. package/dist/src/index.d.ts.map +1 -0
  97. package/dist/style.css +1 -0
  98. package/{src/components/Map/Root/Popup/styles.ts → dist/styles-uPzJnzVS.js} +4 -1
  99. package/dist/utils-YqJg0vBb.js +25 -0
  100. package/package.json +14 -3
  101. package/.env.example +0 -3
  102. package/.storybook/defaults.ts +0 -40
  103. package/.storybook/globals.css +0 -32
  104. package/.storybook/main.ts +0 -19
  105. package/.storybook/preview.tsx +0 -28
  106. package/CHANGELOG.md +0 -27
  107. package/eslint.config.mjs +0 -46
  108. package/lint-staged.config.cjs +0 -4
  109. package/postcss.config.cjs +0 -6
  110. package/prettier.config.cjs +0 -1
  111. package/src/components/Map/Root/BaseMap/Empty/index.tsx +0 -7
  112. package/src/components/Map/Root/BaseMap/Google/index.tsx +0 -96
  113. package/src/components/Map/Root/BaseMap/Mapbox/index.tsx +0 -66
  114. package/src/components/Map/Root/BaseMap/Maptiler/index.tsx +0 -59
  115. package/src/components/Map/Root/BaseMap/index.tsx +0 -34
  116. package/src/components/Map/Root/BaseMap/styles.ts +0 -1
  117. package/src/components/Map/Root/BaseMap/types.ts +0 -3
  118. package/src/components/Map/Root/Layers/Google/index.tsx +0 -97
  119. package/src/components/Map/Root/Layers/Mapbox/index.tsx +0 -74
  120. package/src/components/Map/Root/Layers/Maptiler/index.tsx +0 -74
  121. package/src/components/Map/Root/Layers/index.tsx +0 -32
  122. package/src/components/Map/Root/Layers/types.ts +0 -15
  123. package/src/components/Map/Root/Layers/utils.ts +0 -64
  124. package/src/components/Map/Root/Markers/Cluster/index.tsx +0 -27
  125. package/src/components/Map/Root/Markers/Cluster/styles.ts +0 -11
  126. package/src/components/Map/Root/Markers/Google/index.tsx +0 -49
  127. package/src/components/Map/Root/Markers/Mapbox/index.tsx +0 -52
  128. package/src/components/Map/Root/Markers/Maptiler/index.tsx +0 -52
  129. package/src/components/Map/Root/Markers/index.tsx +0 -81
  130. package/src/components/Map/Root/Markers/styles.ts +0 -37
  131. package/src/components/Map/Root/Markers/types.ts +0 -32
  132. package/src/components/Map/Root/Popup/Google/index.tsx +0 -57
  133. package/src/components/Map/Root/Popup/Google/popup.css +0 -15
  134. package/src/components/Map/Root/Popup/Mapbox/index.tsx +0 -36
  135. package/src/components/Map/Root/Popup/Mapbox/popup.css +0 -15
  136. package/src/components/Map/Root/Popup/Maptiler/index.tsx +0 -37
  137. package/src/components/Map/Root/Popup/Maptiler/popup.css +0 -15
  138. package/src/components/Map/Root/Popup/index.tsx +0 -32
  139. package/src/components/Map/Root/Popup/types.ts +0 -20
  140. package/src/components/Map/Root/constants.ts +0 -6
  141. package/src/components/Map/Root/context.tsx +0 -15
  142. package/src/components/Map/Root/index.tsx +0 -30
  143. package/src/components/Map/Root/types.ts +0 -30
  144. package/src/components/Map/index.stories.tsx +0 -133
  145. package/src/components/Map/index.test.tsx +0 -16
  146. package/src/components/Map/index.tsx +0 -1
  147. package/src/components/Map/storybook-data.ts +0 -255
  148. package/src/index.ts +0 -1
  149. package/tailwind.config.cjs +0 -1
  150. package/tsconfig.json +0 -14
  151. package/tsconfig.node.json +0 -8
  152. package/vite-env.d.ts +0 -13
  153. package/vite.config.ts +0 -46
@@ -0,0 +1,670 @@
1
+ import { jsx as x, Fragment as nt } from "react/jsx-runtime";
2
+ import * as F from "react";
3
+ import st, { useContext as it, lazy as w, useMemo as L, useRef as G, useState as Q } from "react";
4
+ const q = st.createContext(
5
+ {}
6
+ ), R = () => it(q), S = {
7
+ zoom: 16,
8
+ pitch: 0,
9
+ bearing: 0,
10
+ cooperativeGestures: !1
11
+ }, ot = "w-full h-full relative overflow-hidden", at = w(() => import("./index-Bd-X-1Gd.js")), ct = w(() => import("./index-BAAE2pMq.js")), ut = w(() => import("./index-B_LO5X9C.js")), ht = w(() => import("./index-qqbvBkdn.js")), pt = ({ children: n }) => {
12
+ const {
13
+ mapProvider: t,
14
+ center: e,
15
+ zoom: r = S.zoom,
16
+ pitch: i = S.pitch,
17
+ bearing: o = S.bearing,
18
+ cooperativeGestures: a = S.cooperativeGestures,
19
+ zoomPosition: u
20
+ } = R(), s = L(() => {
21
+ switch (t == null ? void 0 : t.name) {
22
+ case "maptiler":
23
+ return at;
24
+ case "google":
25
+ return ct;
26
+ case "mapbox":
27
+ return ut;
28
+ default:
29
+ return ht;
30
+ }
31
+ }, [t]);
32
+ return /* @__PURE__ */ x(
33
+ "div",
34
+ {
35
+ className: ot,
36
+ "data-testid": "base-map",
37
+ "data-map-provider": t == null ? void 0 : t.name,
38
+ "data-zoom": r,
39
+ "data-pitch": i,
40
+ "data-bearing": o,
41
+ "data-cooperative-gestures": a,
42
+ "data-zoom-position": u,
43
+ "data-center-latitude": e.latitude,
44
+ "data-center-longitude": e.longitude,
45
+ children: /* @__PURE__ */ x(s, { children: n })
46
+ }
47
+ );
48
+ };
49
+ function lt(n, t, e = {}) {
50
+ const r = { type: "Feature" };
51
+ return (e.id === 0 || e.id) && (r.id = e.id), e.bbox && (r.bbox = e.bbox), r.properties = t || {}, r.geometry = n, r;
52
+ }
53
+ function ft(n, t, e = {}) {
54
+ if (!n)
55
+ throw new Error("coordinates is required");
56
+ if (!Array.isArray(n))
57
+ throw new Error("coordinates must be an Array");
58
+ if (n.length < 2)
59
+ throw new Error("coordinates must be at least 2 numbers long");
60
+ if (!V(n[0]) || !V(n[1]))
61
+ throw new Error("coordinates must contain numbers");
62
+ return lt({
63
+ type: "Point",
64
+ coordinates: n
65
+ }, t, e);
66
+ }
67
+ function V(n) {
68
+ return !isNaN(n) && n !== null && !Array.isArray(n);
69
+ }
70
+ const H = [
71
+ Int8Array,
72
+ Uint8Array,
73
+ Uint8ClampedArray,
74
+ Int16Array,
75
+ Uint16Array,
76
+ Int32Array,
77
+ Uint32Array,
78
+ Float32Array,
79
+ Float64Array
80
+ ], C = 1, P = 8;
81
+ class D {
82
+ /**
83
+ * Creates an index from raw `ArrayBuffer` data.
84
+ * @param {ArrayBuffer} data
85
+ */
86
+ static from(t) {
87
+ if (!(t instanceof ArrayBuffer))
88
+ throw new Error("Data must be an instance of ArrayBuffer.");
89
+ const [e, r] = new Uint8Array(t, 0, 2);
90
+ if (e !== 219)
91
+ throw new Error("Data does not appear to be in a KDBush format.");
92
+ const i = r >> 4;
93
+ if (i !== C)
94
+ throw new Error(`Got v${i} data when expected v${C}.`);
95
+ const o = H[r & 15];
96
+ if (!o)
97
+ throw new Error("Unrecognized array type.");
98
+ const [a] = new Uint16Array(t, 2, 1), [u] = new Uint32Array(t, 4, 1);
99
+ return new D(u, a, o, t);
100
+ }
101
+ /**
102
+ * Creates an index that will hold a given number of items.
103
+ * @param {number} numItems
104
+ * @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
105
+ * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
106
+ * @param {ArrayBuffer} [data] (For internal use only)
107
+ */
108
+ constructor(t, e = 64, r = Float64Array, i) {
109
+ if (isNaN(t) || t < 0) throw new Error(`Unpexpected numItems value: ${t}.`);
110
+ this.numItems = +t, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.ArrayType = r, this.IndexArrayType = t < 65536 ? Uint16Array : Uint32Array;
111
+ const o = H.indexOf(this.ArrayType), a = t * 2 * this.ArrayType.BYTES_PER_ELEMENT, u = t * this.IndexArrayType.BYTES_PER_ELEMENT, s = (8 - u % 8) % 8;
112
+ if (o < 0)
113
+ throw new Error(`Unexpected typed array class: ${r}.`);
114
+ i && i instanceof ArrayBuffer ? (this.data = i, this.ids = new this.IndexArrayType(this.data, P, t), this.coords = new this.ArrayType(this.data, P + u + s, t * 2), this._pos = t * 2, this._finished = !0) : (this.data = new ArrayBuffer(P + a + u + s), this.ids = new this.IndexArrayType(this.data, P, t), this.coords = new this.ArrayType(this.data, P + u + s, t * 2), this._pos = 0, this._finished = !1, new Uint8Array(this.data, 0, 2).set([219, (C << 4) + o]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = t);
115
+ }
116
+ /**
117
+ * Add a point to the index.
118
+ * @param {number} x
119
+ * @param {number} y
120
+ * @returns {number} An incremental index associated with the added item (starting from `0`).
121
+ */
122
+ add(t, e) {
123
+ const r = this._pos >> 1;
124
+ return this.ids[r] = r, this.coords[this._pos++] = t, this.coords[this._pos++] = e, r;
125
+ }
126
+ /**
127
+ * Perform indexing of the added points.
128
+ */
129
+ finish() {
130
+ const t = this._pos >> 1;
131
+ if (t !== this.numItems)
132
+ throw new Error(`Added ${t} items when expected ${this.numItems}.`);
133
+ return j(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0), this._finished = !0, this;
134
+ }
135
+ /**
136
+ * Search the index for items within a given bounding box.
137
+ * @param {number} minX
138
+ * @param {number} minY
139
+ * @param {number} maxX
140
+ * @param {number} maxY
141
+ * @returns {number[]} An array of indices correponding to the found items.
142
+ */
143
+ range(t, e, r, i) {
144
+ if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
145
+ const { ids: o, coords: a, nodeSize: u } = this, s = [0, o.length - 1, 0], c = [];
146
+ for (; s.length; ) {
147
+ const p = s.pop() || 0, h = s.pop() || 0, l = s.pop() || 0;
148
+ if (h - l <= u) {
149
+ for (let d = l; d <= h; d++) {
150
+ const y = a[2 * d], M = a[2 * d + 1];
151
+ y >= t && y <= r && M >= e && M <= i && c.push(o[d]);
152
+ }
153
+ continue;
154
+ }
155
+ const f = l + h >> 1, g = a[2 * f], m = a[2 * f + 1];
156
+ g >= t && g <= r && m >= e && m <= i && c.push(o[f]), (p === 0 ? t <= g : e <= m) && (s.push(l), s.push(f - 1), s.push(1 - p)), (p === 0 ? r >= g : i >= m) && (s.push(f + 1), s.push(h), s.push(1 - p));
157
+ }
158
+ return c;
159
+ }
160
+ /**
161
+ * Search the index for items within a given radius.
162
+ * @param {number} qx
163
+ * @param {number} qy
164
+ * @param {number} r Query radius.
165
+ * @returns {number[]} An array of indices correponding to the found items.
166
+ */
167
+ within(t, e, r) {
168
+ if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
169
+ const { ids: i, coords: o, nodeSize: a } = this, u = [0, i.length - 1, 0], s = [], c = r * r;
170
+ for (; u.length; ) {
171
+ const p = u.pop() || 0, h = u.pop() || 0, l = u.pop() || 0;
172
+ if (h - l <= a) {
173
+ for (let d = l; d <= h; d++)
174
+ k(o[2 * d], o[2 * d + 1], t, e) <= c && s.push(i[d]);
175
+ continue;
176
+ }
177
+ const f = l + h >> 1, g = o[2 * f], m = o[2 * f + 1];
178
+ k(g, m, t, e) <= c && s.push(i[f]), (p === 0 ? t - r <= g : e - r <= m) && (u.push(l), u.push(f - 1), u.push(1 - p)), (p === 0 ? t + r >= g : e + r >= m) && (u.push(f + 1), u.push(h), u.push(1 - p));
179
+ }
180
+ return s;
181
+ }
182
+ }
183
+ function j(n, t, e, r, i, o) {
184
+ if (i - r <= e) return;
185
+ const a = r + i >> 1;
186
+ X(n, t, a, r, i, o), j(n, t, e, r, a - 1, 1 - o), j(n, t, e, a + 1, i, 1 - o);
187
+ }
188
+ function X(n, t, e, r, i, o) {
189
+ for (; i > r; ) {
190
+ if (i - r > 600) {
191
+ const c = i - r + 1, p = e - r + 1, h = Math.log(c), l = 0.5 * Math.exp(2 * h / 3), f = 0.5 * Math.sqrt(h * l * (c - l) / c) * (p - c / 2 < 0 ? -1 : 1), g = Math.max(r, Math.floor(e - p * l / c + f)), m = Math.min(i, Math.floor(e + (c - p) * l / c + f));
192
+ X(n, t, e, g, m, o);
193
+ }
194
+ const a = t[2 * e + o];
195
+ let u = r, s = i;
196
+ for (O(n, t, r, e), t[2 * i + o] > a && O(n, t, r, i); u < s; ) {
197
+ for (O(n, t, u, s), u++, s--; t[2 * u + o] < a; ) u++;
198
+ for (; t[2 * s + o] > a; ) s--;
199
+ }
200
+ t[2 * r + o] === a ? O(n, t, r, s) : (s++, O(n, t, s, i)), s <= e && (r = s + 1), e <= s && (i = s - 1);
201
+ }
202
+ }
203
+ function O(n, t, e, r) {
204
+ U(n, e, r), U(t, 2 * e, 2 * r), U(t, 2 * e + 1, 2 * r + 1);
205
+ }
206
+ function U(n, t, e) {
207
+ const r = n[t];
208
+ n[t] = n[e], n[e] = r;
209
+ }
210
+ function k(n, t, e, r) {
211
+ const i = n - e, o = t - r;
212
+ return i * i + o * o;
213
+ }
214
+ const dt = {
215
+ minZoom: 0,
216
+ // min zoom to generate clusters on
217
+ maxZoom: 16,
218
+ // max zoom level to cluster the points on
219
+ minPoints: 2,
220
+ // minimum points to form a cluster
221
+ radius: 40,
222
+ // cluster radius in pixels
223
+ extent: 512,
224
+ // tile extent (radius is calculated relative to it)
225
+ nodeSize: 64,
226
+ // size of the KD-tree leaf node, affects performance
227
+ log: !1,
228
+ // whether to log timing info
229
+ // whether to generate numeric ids for input features (in vector tiles)
230
+ generateId: !1,
231
+ // a reduce function for calculating custom cluster properties
232
+ reduce: null,
233
+ // (accumulated, props) => { accumulated.sum += props.sum; }
234
+ // properties to use for individual points when running the reducer
235
+ map: (n) => n
236
+ // props => ({sum: props.my_value})
237
+ }, J = Math.fround || /* @__PURE__ */ ((n) => (t) => (n[0] = +t, n[0]))(new Float32Array(1)), v = 2, E = 3, z = 4, A = 5, tt = 6;
238
+ class gt {
239
+ constructor(t) {
240
+ this.options = Object.assign(Object.create(dt), t), this.trees = new Array(this.options.maxZoom + 1), this.stride = this.options.reduce ? 7 : 6, this.clusterProps = [];
241
+ }
242
+ load(t) {
243
+ const { log: e, minZoom: r, maxZoom: i } = this.options;
244
+ e && console.time("total time");
245
+ const o = `prepare ${t.length} points`;
246
+ e && console.time(o), this.points = t;
247
+ const a = [];
248
+ for (let s = 0; s < t.length; s++) {
249
+ const c = t[s];
250
+ if (!c.geometry) continue;
251
+ const [p, h] = c.geometry.coordinates, l = J(I(p)), f = J(B(h));
252
+ a.push(
253
+ l,
254
+ f,
255
+ // projected point coordinates
256
+ 1 / 0,
257
+ // the last zoom the point was processed at
258
+ s,
259
+ // index of the source feature in the original input array
260
+ -1,
261
+ // parent cluster id
262
+ 1
263
+ // number of points in a cluster
264
+ ), this.options.reduce && a.push(0);
265
+ }
266
+ let u = this.trees[i + 1] = this._createTree(a);
267
+ e && console.timeEnd(o);
268
+ for (let s = i; s >= r; s--) {
269
+ const c = +Date.now();
270
+ u = this.trees[s] = this._createTree(this._cluster(u, s)), e && console.log("z%d: %d clusters in %dms", s, u.numItems, +Date.now() - c);
271
+ }
272
+ return e && console.timeEnd("total time"), this;
273
+ }
274
+ getClusters(t, e) {
275
+ let r = ((t[0] + 180) % 360 + 360) % 360 - 180;
276
+ const i = Math.max(-90, Math.min(90, t[1]));
277
+ let o = t[2] === 180 ? 180 : ((t[2] + 180) % 360 + 360) % 360 - 180;
278
+ const a = Math.max(-90, Math.min(90, t[3]));
279
+ if (t[2] - t[0] >= 360)
280
+ r = -180, o = 180;
281
+ else if (r > o) {
282
+ const h = this.getClusters([r, i, 180, a], e), l = this.getClusters([-180, i, o, a], e);
283
+ return h.concat(l);
284
+ }
285
+ const u = this.trees[this._limitZoom(e)], s = u.range(I(r), B(a), I(o), B(i)), c = u.data, p = [];
286
+ for (const h of s) {
287
+ const l = this.stride * h;
288
+ p.push(c[l + A] > 1 ? K(c, l, this.clusterProps) : this.points[c[l + E]]);
289
+ }
290
+ return p;
291
+ }
292
+ getChildren(t) {
293
+ const e = this._getOriginId(t), r = this._getOriginZoom(t), i = "No cluster with the specified id.", o = this.trees[r];
294
+ if (!o) throw new Error(i);
295
+ const a = o.data;
296
+ if (e * this.stride >= a.length) throw new Error(i);
297
+ const u = this.options.radius / (this.options.extent * Math.pow(2, r - 1)), s = a[e * this.stride], c = a[e * this.stride + 1], p = o.within(s, c, u), h = [];
298
+ for (const l of p) {
299
+ const f = l * this.stride;
300
+ a[f + z] === t && h.push(a[f + A] > 1 ? K(a, f, this.clusterProps) : this.points[a[f + E]]);
301
+ }
302
+ if (h.length === 0) throw new Error(i);
303
+ return h;
304
+ }
305
+ getLeaves(t, e, r) {
306
+ e = e || 10, r = r || 0;
307
+ const i = [];
308
+ return this._appendLeaves(i, t, e, r, 0), i;
309
+ }
310
+ getTile(t, e, r) {
311
+ const i = this.trees[this._limitZoom(t)], o = Math.pow(2, t), { extent: a, radius: u } = this.options, s = u / a, c = (r - s) / o, p = (r + 1 + s) / o, h = {
312
+ features: []
313
+ };
314
+ return this._addTileFeatures(
315
+ i.range((e - s) / o, c, (e + 1 + s) / o, p),
316
+ i.data,
317
+ e,
318
+ r,
319
+ o,
320
+ h
321
+ ), e === 0 && this._addTileFeatures(
322
+ i.range(1 - s / o, c, 1, p),
323
+ i.data,
324
+ o,
325
+ r,
326
+ o,
327
+ h
328
+ ), e === o - 1 && this._addTileFeatures(
329
+ i.range(0, c, s / o, p),
330
+ i.data,
331
+ -1,
332
+ r,
333
+ o,
334
+ h
335
+ ), h.features.length ? h : null;
336
+ }
337
+ getClusterExpansionZoom(t) {
338
+ let e = this._getOriginZoom(t) - 1;
339
+ for (; e <= this.options.maxZoom; ) {
340
+ const r = this.getChildren(t);
341
+ if (e++, r.length !== 1) break;
342
+ t = r[0].properties.cluster_id;
343
+ }
344
+ return e;
345
+ }
346
+ _appendLeaves(t, e, r, i, o) {
347
+ const a = this.getChildren(e);
348
+ for (const u of a) {
349
+ const s = u.properties;
350
+ if (s && s.cluster ? o + s.point_count <= i ? o += s.point_count : o = this._appendLeaves(t, s.cluster_id, r, i, o) : o < i ? o++ : t.push(u), t.length === r) break;
351
+ }
352
+ return o;
353
+ }
354
+ _createTree(t) {
355
+ const e = new D(t.length / this.stride | 0, this.options.nodeSize, Float32Array);
356
+ for (let r = 0; r < t.length; r += this.stride) e.add(t[r], t[r + 1]);
357
+ return e.finish(), e.data = t, e;
358
+ }
359
+ _addTileFeatures(t, e, r, i, o, a) {
360
+ for (const u of t) {
361
+ const s = u * this.stride, c = e[s + A] > 1;
362
+ let p, h, l;
363
+ if (c)
364
+ p = et(e, s, this.clusterProps), h = e[s], l = e[s + 1];
365
+ else {
366
+ const m = this.points[e[s + E]];
367
+ p = m.properties;
368
+ const [d, y] = m.geometry.coordinates;
369
+ h = I(d), l = B(y);
370
+ }
371
+ const f = {
372
+ type: 1,
373
+ geometry: [[
374
+ Math.round(this.options.extent * (h * o - r)),
375
+ Math.round(this.options.extent * (l * o - i))
376
+ ]],
377
+ tags: p
378
+ };
379
+ let g;
380
+ c || this.options.generateId ? g = e[s + E] : g = this.points[e[s + E]].id, g !== void 0 && (f.id = g), a.features.push(f);
381
+ }
382
+ }
383
+ _limitZoom(t) {
384
+ return Math.max(this.options.minZoom, Math.min(Math.floor(+t), this.options.maxZoom + 1));
385
+ }
386
+ _cluster(t, e) {
387
+ const { radius: r, extent: i, reduce: o, minPoints: a } = this.options, u = r / (i * Math.pow(2, e)), s = t.data, c = [], p = this.stride;
388
+ for (let h = 0; h < s.length; h += p) {
389
+ if (s[h + v] <= e) continue;
390
+ s[h + v] = e;
391
+ const l = s[h], f = s[h + 1], g = t.within(s[h], s[h + 1], u), m = s[h + A];
392
+ let d = m;
393
+ for (const y of g) {
394
+ const M = y * p;
395
+ s[M + v] > e && (d += s[M + A]);
396
+ }
397
+ if (d > m && d >= a) {
398
+ let y = l * m, M = f * m, _, N = -1;
399
+ const Z = ((h / p | 0) << 5) + (e + 1) + this.points.length;
400
+ for (const rt of g) {
401
+ const b = rt * p;
402
+ if (s[b + v] <= e) continue;
403
+ s[b + v] = e;
404
+ const $ = s[b + A];
405
+ y += s[b] * $, M += s[b + 1] * $, s[b + z] = Z, o && (_ || (_ = this._map(s, h, !0), N = this.clusterProps.length, this.clusterProps.push(_)), o(_, this._map(s, b)));
406
+ }
407
+ s[h + z] = Z, c.push(y / d, M / d, 1 / 0, Z, -1, d), o && c.push(N);
408
+ } else {
409
+ for (let y = 0; y < p; y++) c.push(s[h + y]);
410
+ if (d > 1)
411
+ for (const y of g) {
412
+ const M = y * p;
413
+ if (!(s[M + v] <= e)) {
414
+ s[M + v] = e;
415
+ for (let _ = 0; _ < p; _++) c.push(s[M + _]);
416
+ }
417
+ }
418
+ }
419
+ }
420
+ return c;
421
+ }
422
+ // get index of the point from which the cluster originated
423
+ _getOriginId(t) {
424
+ return t - this.points.length >> 5;
425
+ }
426
+ // get zoom of the point from which the cluster originated
427
+ _getOriginZoom(t) {
428
+ return (t - this.points.length) % 32;
429
+ }
430
+ _map(t, e, r) {
431
+ if (t[e + A] > 1) {
432
+ const a = this.clusterProps[t[e + tt]];
433
+ return r ? Object.assign({}, a) : a;
434
+ }
435
+ const i = this.points[t[e + E]].properties, o = this.options.map(i);
436
+ return r && o === i ? Object.assign({}, o) : o;
437
+ }
438
+ }
439
+ function K(n, t, e) {
440
+ return {
441
+ type: "Feature",
442
+ id: n[t + E],
443
+ properties: et(n, t, e),
444
+ geometry: {
445
+ type: "Point",
446
+ coordinates: [mt(n[t]), yt(n[t + 1])]
447
+ }
448
+ };
449
+ }
450
+ function et(n, t, e) {
451
+ const r = n[t + A], i = r >= 1e4 ? `${Math.round(r / 1e3)}k` : r >= 1e3 ? `${Math.round(r / 100) / 10}k` : r, o = n[t + tt], a = o === -1 ? {} : Object.assign({}, e[o]);
452
+ return Object.assign(a, {
453
+ cluster: !0,
454
+ cluster_id: n[t + E],
455
+ point_count: r,
456
+ point_count_abbreviated: i
457
+ });
458
+ }
459
+ function I(n) {
460
+ return n / 360 + 0.5;
461
+ }
462
+ function B(n) {
463
+ const t = Math.sin(n * Math.PI / 180), e = 0.5 - 0.25 * Math.log((1 + t) / (1 - t)) / Math.PI;
464
+ return e < 0 ? 0 : e > 1 ? 1 : e;
465
+ }
466
+ function mt(n) {
467
+ return (n - 0.5) * 360;
468
+ }
469
+ function yt(n) {
470
+ const t = (180 - n * 360) * Math.PI / 180;
471
+ return 360 * Math.atan(Math.exp(t)) / Math.PI - 90;
472
+ }
473
+ var W = Object.prototype.hasOwnProperty;
474
+ function Y(n, t, e) {
475
+ for (e of n.keys())
476
+ if (T(e, t)) return e;
477
+ }
478
+ function T(n, t) {
479
+ var e, r, i;
480
+ if (n === t) return !0;
481
+ if (n && t && (e = n.constructor) === t.constructor) {
482
+ if (e === Date) return n.getTime() === t.getTime();
483
+ if (e === RegExp) return n.toString() === t.toString();
484
+ if (e === Array) {
485
+ if ((r = n.length) === t.length)
486
+ for (; r-- && T(n[r], t[r]); ) ;
487
+ return r === -1;
488
+ }
489
+ if (e === Set) {
490
+ if (n.size !== t.size)
491
+ return !1;
492
+ for (r of n)
493
+ if (i = r, i && typeof i == "object" && (i = Y(t, i), !i) || !t.has(i)) return !1;
494
+ return !0;
495
+ }
496
+ if (e === Map) {
497
+ if (n.size !== t.size)
498
+ return !1;
499
+ for (r of n)
500
+ if (i = r[0], i && typeof i == "object" && (i = Y(t, i), !i) || !T(r[1], t.get(i)))
501
+ return !1;
502
+ return !0;
503
+ }
504
+ if (e === ArrayBuffer)
505
+ n = new Uint8Array(n), t = new Uint8Array(t);
506
+ else if (e === DataView) {
507
+ if ((r = n.byteLength) === t.byteLength)
508
+ for (; r-- && n.getInt8(r) === t.getInt8(r); ) ;
509
+ return r === -1;
510
+ }
511
+ if (ArrayBuffer.isView(n)) {
512
+ if ((r = n.byteLength) === t.byteLength)
513
+ for (; r-- && n[r] === t[r]; ) ;
514
+ return r === -1;
515
+ }
516
+ if (!e || typeof n == "object") {
517
+ r = 0;
518
+ for (e in n)
519
+ if (W.call(n, e) && ++r && !W.call(t, e) || !(e in t) || !T(n[e], t[e])) return !1;
520
+ return Object.keys(t).length === r;
521
+ }
522
+ }
523
+ return n !== n && t !== t;
524
+ }
525
+ function wt(n) {
526
+ var t = F.useRef(n), e = F.useRef(0);
527
+ return T(n, t.current) || (t.current = n, e.current += 1), F.useMemo(function() {
528
+ return t.current;
529
+ }, [e.current]);
530
+ }
531
+ function Mt(n, t) {
532
+ return F.useEffect(n, wt(t));
533
+ }
534
+ var xt = function(t) {
535
+ var e = t.points, r = t.bounds, i = t.zoom, o = t.options, a = t.disableRefresh, u = G(), s = G(), c = Q([]), p = c[0], h = c[1], l = Math.round(i);
536
+ return Mt(function() {
537
+ a !== !0 && ((!u.current || !T(s.current, e) || !T(u.current.options, o)) && (u.current = new gt(o), u.current.load(e)), r && h(u.current.getClusters(r, l)), s.current = e);
538
+ }, [e, r, l, o, a]), {
539
+ clusters: p,
540
+ supercluster: u.current
541
+ };
542
+ };
543
+ const Ut = `
544
+ cursor-pointer
545
+ relative
546
+ h-7
547
+ w-5
548
+ text-base-white
549
+ group
550
+ transition-transform
551
+
552
+ data-[is-cluster=true]:w-auto
553
+ `, _t = `
554
+ cursor-pointer
555
+ fill-primary-100
556
+ stroke-1
557
+ box-border
558
+ transition-colors
559
+ transition-transform
560
+ group-hover:stroke-base-white
561
+ group-focus:stroke-base-white
562
+ `, zt = `
563
+ absolute top-1 left-1/2 transform -translate-x-1/2
564
+ flex justify-center items-center rounded-full overflow-hidden
565
+ transition-all w-3.5 h-3.5
566
+
567
+ group-hover:bg-base-white
568
+ `, jt = `
569
+ m-auto transition-all w-full h-full
570
+ max-w-3.5 max-h-3.5
571
+
572
+ group-hover:text-primary-100
573
+ group-hover:max-w-2.5
574
+ group-hover:max-h-2.5
575
+ `, At = w(() => import("./index-DHw9gU4K.js")), Et = w(() => import("./index-BHjgd5HB.js")), bt = w(() => import("./index-BbrOUWDy.js")), vt = ({ markers: n, onClick: t, ...e }) => {
576
+ const { mapProvider: r, bounds: i } = R(), { clusters: o, supercluster: a } = xt({
577
+ points: n.map((c) => ft([c.longitude, c.latitude], c)),
578
+ bounds: i,
579
+ zoom: 16,
580
+ options: { radius: 50, maxZoom: 30 }
581
+ }), u = (c) => {
582
+ var p, h, l;
583
+ if (!("properties" in c))
584
+ throw new Error("Cluster does not have properties");
585
+ if ((p = c.properties) != null && p.cluster && typeof ((h = c.properties) == null ? void 0 : h.cluster_id) == "number") {
586
+ t == null || t({
587
+ id: `${c.properties.cluster_id}`,
588
+ latitude: c.geometry.coordinates[1],
589
+ longitude: c.geometry.coordinates[0],
590
+ markers: ((l = a == null ? void 0 : a.getChildren(c.properties.cluster_id)) == null ? void 0 : l.map((f) => f.properties)) ?? []
591
+ });
592
+ return;
593
+ }
594
+ t == null || t({
595
+ id: c.properties.id,
596
+ latitude: c.properties.latitude,
597
+ longitude: c.properties.longitude,
598
+ markers: [c.properties]
599
+ });
600
+ }, s = L(() => {
601
+ switch (r == null ? void 0 : r.name) {
602
+ case "maptiler":
603
+ return At;
604
+ case "google":
605
+ return Et;
606
+ case "mapbox":
607
+ return bt;
608
+ default:
609
+ return null;
610
+ }
611
+ }, [r]);
612
+ return s ? /* @__PURE__ */ x(nt, { children: /* @__PURE__ */ x(s, { clusters: o, onClick: u, ...e, children: /* @__PURE__ */ x("svg", { viewBox: "0 0 20 28", fill: "none", className: _t, children: /* @__PURE__ */ x(
613
+ "path",
614
+ {
615
+ d: "M20 10C20 15.5228 12 27.5 10 27.5C8 27.5 0 15.5228 0 10C0 4.47715 4.47715 0 10 0C15.5228 0 20 4.47715 20 10Z",
616
+ fill: "inherit"
617
+ }
618
+ ) }) }) }) : null;
619
+ }, Tt = w(() => import("./index-J1MKzGEM.js")), Pt = w(() => import("./index-BZ2605rA.js")), Ot = w(() => import("./index-B43MtiHH.js"));
620
+ function St({ children: n, ...t }) {
621
+ const { mapProvider: e } = R(), r = L(() => {
622
+ switch (e == null ? void 0 : e.name) {
623
+ case "maptiler":
624
+ return Tt;
625
+ case "google":
626
+ return Pt;
627
+ case "mapbox":
628
+ return Ot;
629
+ default:
630
+ return null;
631
+ }
632
+ }, [e]);
633
+ return r ? /* @__PURE__ */ x(r, { ...t, children: n }) : null;
634
+ }
635
+ const It = w(() => import("./index-CTk5bvm9.js")), Bt = w(() => import("./index-CPq7k7F4.js")), Ft = w(() => import("./index-DVitM43i.js"));
636
+ function Lt(n) {
637
+ const { mapProvider: t } = R(), e = L(() => {
638
+ switch (t == null ? void 0 : t.name) {
639
+ case "maptiler":
640
+ return It;
641
+ case "google":
642
+ return Bt;
643
+ case "mapbox":
644
+ return Ft;
645
+ default:
646
+ return null;
647
+ }
648
+ }, [t]);
649
+ return e ? /* @__PURE__ */ x(e, { ...n }) : null;
650
+ }
651
+ function Rt(n) {
652
+ const [t, e] = Q();
653
+ return /* @__PURE__ */ x(q.Provider, { value: { ...n, bounds: t, setBounds: e }, children: n.children });
654
+ }
655
+ const Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
656
+ __proto__: null,
657
+ BaseMap: pt,
658
+ Layers: Lt,
659
+ Markers: vt,
660
+ Popup: St,
661
+ Root: Rt
662
+ }, Symbol.toStringTag, { value: "Module" }));
663
+ export {
664
+ jt as a,
665
+ Dt as b,
666
+ Ut as c,
667
+ S as d,
668
+ zt as i,
669
+ R as u
670
+ };