@arenarium/maps 1.0.188 → 1.0.189
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/api.cjs.js +1 -1
- package/dist/api.es.js +2 -2
- package/dist/index.js +2 -2
- package/dist/main.cjs.js +2 -2
- package/dist/main.es.js +2 -2
- package/dist/states-DJiLxlPa.js +412 -0
- package/dist/states-Dj48QyzN.cjs +1 -0
- package/package.json +1 -1
- package/dist/states-BVsyCOND.js +0 -413
- package/dist/states-Dr9TQeEe.cjs +0 -1
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
var et = Object.defineProperty;
|
|
2
|
+
var nt = (c, f, u) => f in c ? et(c, f, { enumerable: !0, configurable: !0, writable: !0, value: u }) : c[f] = u;
|
|
3
|
+
var A = (c, f, u) => nt(c, typeof f != "symbol" ? f + "" : f, u);
|
|
4
|
+
var Y;
|
|
5
|
+
((c) => {
|
|
6
|
+
function f(u, h, l) {
|
|
7
|
+
const y = u / 2, I = h / 2, d = Math.sqrt(y * y + I * I), b = Math.atan(I / y) * (180 / Math.PI), i = l * (Math.PI / 180);
|
|
8
|
+
return l < 180 ? l < 90 ? l < b ? {
|
|
9
|
+
x: 0,
|
|
10
|
+
y: d * Math.sin(i) - I
|
|
11
|
+
} : {
|
|
12
|
+
x: d * Math.cos(i) - y,
|
|
13
|
+
y: 0
|
|
14
|
+
} : l < 180 - b ? {
|
|
15
|
+
x: d * Math.cos(i) - y,
|
|
16
|
+
y: 0
|
|
17
|
+
} : {
|
|
18
|
+
x: -u,
|
|
19
|
+
y: d * Math.sin(i) - I
|
|
20
|
+
} : l < 270 ? l < 180 + b ? {
|
|
21
|
+
x: -u,
|
|
22
|
+
y: d * Math.sin(i) - I
|
|
23
|
+
} : {
|
|
24
|
+
x: d * Math.cos(i) - y,
|
|
25
|
+
y: -h
|
|
26
|
+
} : l < 360 - b ? {
|
|
27
|
+
x: d * Math.cos(i) - y,
|
|
28
|
+
y: -h
|
|
29
|
+
} : {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: d * Math.sin(i) - I
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
c.getOffsets = f;
|
|
35
|
+
})(Y || (Y = {}));
|
|
36
|
+
var L;
|
|
37
|
+
((c) => {
|
|
38
|
+
function f(d, b, i) {
|
|
39
|
+
return {
|
|
40
|
+
x: h(b) * i,
|
|
41
|
+
y: l(d) * i
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
c.project = f;
|
|
45
|
+
function u(d, b, i) {
|
|
46
|
+
return {
|
|
47
|
+
lat: I(b / i),
|
|
48
|
+
lng: y(d / i)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
c.unproject = u;
|
|
52
|
+
function h(d) {
|
|
53
|
+
return (180 + d) / 360;
|
|
54
|
+
}
|
|
55
|
+
function l(d) {
|
|
56
|
+
return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + d * Math.PI / 360))) / 360;
|
|
57
|
+
}
|
|
58
|
+
function y(d) {
|
|
59
|
+
return d * 360 - 180;
|
|
60
|
+
}
|
|
61
|
+
function I(d) {
|
|
62
|
+
return 360 / Math.PI * Math.atan(Math.exp((180 - d * 360) * Math.PI / 180)) - 90;
|
|
63
|
+
}
|
|
64
|
+
})(L || (L = {}));
|
|
65
|
+
var M;
|
|
66
|
+
((c) => {
|
|
67
|
+
c.COUNT = 12, c.DEGREES = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330], c.DEGREES_DEFAULT = 270;
|
|
68
|
+
})(M || (M = {}));
|
|
69
|
+
var j;
|
|
70
|
+
((c) => {
|
|
71
|
+
const f = M.DEGREES.map((i) => i * Math.PI / 180), u = f.map((i) => Math.cos(i)), h = f.map((i) => Math.sin(i));
|
|
72
|
+
function l(i, x) {
|
|
73
|
+
const p = Math.abs(x / i);
|
|
74
|
+
return p < 1 ? p < 0.26795 ? 0 : 1 : p < 3.73205 ? 2 : 3;
|
|
75
|
+
}
|
|
76
|
+
function y(i, x) {
|
|
77
|
+
const p = l(i, x);
|
|
78
|
+
return i > 0 ? x > 0 ? (12 - p) % 12 : 0 + p : x > 0 ? 6 + p : 6 - p;
|
|
79
|
+
}
|
|
80
|
+
function I(i, x) {
|
|
81
|
+
return x == 0 ? i : ((i + x) % M.COUNT + M.COUNT) % M.COUNT;
|
|
82
|
+
}
|
|
83
|
+
function d(i) {
|
|
84
|
+
let x = !0;
|
|
85
|
+
for (let p = 0; p < i.length; p++) {
|
|
86
|
+
const E = i[p], S = E.particle, v = E.x, n = E.y, t = S.distX, e = S.distY, o = S.index, r = I(o, -1), s = I(o, 1), a = v + t * u[r], m = n + e * h[r], g = v + t * u[o], F = n + e * h[o], G = v + t * u[s], R = n + e * h[s];
|
|
87
|
+
let O = 0, z = 0, D = 0;
|
|
88
|
+
const P = E.neighbours;
|
|
89
|
+
for (let C = 0; C < P.length; C++) {
|
|
90
|
+
const Z = P[C], k = Z.particle, K = Z.x, V = Z.y, $ = k.distX, tt = k.distY, W = k.index, X = K + $ * u[W], U = V + tt * h[W], _ = a - X, B = m - U;
|
|
91
|
+
O += 1 / (_ * _ + B * B);
|
|
92
|
+
const H = g - X, q = F - U;
|
|
93
|
+
z += 1 / (H * H + q * q);
|
|
94
|
+
const Q = G - X, J = R - U;
|
|
95
|
+
D += 1 / (Q * Q + J * J);
|
|
96
|
+
}
|
|
97
|
+
let T = 0;
|
|
98
|
+
O < z && O < D && (T = -1), D < z && D < O && (T = 1), T != 0 && (S.index = I(o, T), x = !1);
|
|
99
|
+
}
|
|
100
|
+
return x;
|
|
101
|
+
}
|
|
102
|
+
c.updateAngleIndexes = d;
|
|
103
|
+
function b(i) {
|
|
104
|
+
for (let x = 0; x < i.length; x++) {
|
|
105
|
+
const p = i[x], E = p.x, S = p.y;
|
|
106
|
+
let v = 0, n = 0;
|
|
107
|
+
for (let t = 0; t < i.length; t++) {
|
|
108
|
+
const e = i[t], o = e.x, r = e.y, s = E - o, a = S - r;
|
|
109
|
+
if (s == 0 && a == 0) continue;
|
|
110
|
+
const m = Math.sqrt(s * s + a * a), g = 1 / (m * m);
|
|
111
|
+
v += g * s / m, n += -(g * a) / m;
|
|
112
|
+
}
|
|
113
|
+
p.particle.index = y(v, n);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
c.initializeAngleIndexes = b;
|
|
117
|
+
})(j || (j = {}));
|
|
118
|
+
var w;
|
|
119
|
+
((c) => {
|
|
120
|
+
function f(h, l) {
|
|
121
|
+
return !(h.x - h.distances.left > l.x + l.distances.right || h.x + h.distances.right < l.x - l.distances.left || h.y - h.distances.top > l.y + l.distances.bottom || h.y + h.distances.bottom < l.y - l.distances.top);
|
|
122
|
+
}
|
|
123
|
+
c.areOverlaping = f;
|
|
124
|
+
function u(h, l) {
|
|
125
|
+
let y = Math.abs(h.x - l.x), d = (h.x < l.x ? h.distances.right + l.distances.left : h.distances.left + l.distances.right) / y, b = Math.abs(h.y - l.y), x = (h.y < l.y ? h.distances.bottom + l.distances.top : h.distances.top + l.distances.bottom) / b, p = Math.min(d, x);
|
|
126
|
+
return Math.log2(p);
|
|
127
|
+
}
|
|
128
|
+
c.getZoomWhenTouching = u;
|
|
129
|
+
})(w || (w = {}));
|
|
130
|
+
var N;
|
|
131
|
+
((c) => {
|
|
132
|
+
class f {
|
|
133
|
+
constructor() {
|
|
134
|
+
A(this, "zoomAfterExpanded");
|
|
135
|
+
A(this, "zoomAfterAngleIndexes");
|
|
136
|
+
this.zoomAfterExpanded = NaN, this.zoomAfterAngleIndexes = [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
c.State = f;
|
|
140
|
+
class u {
|
|
141
|
+
constructor(t) {
|
|
142
|
+
A(this, "min");
|
|
143
|
+
A(this, "max");
|
|
144
|
+
A(this, "scale");
|
|
145
|
+
A(this, "step");
|
|
146
|
+
this.min = t.zoomMin, this.max = t.zoomMax, this.scale = t.zoomScale, this.step = 1 / this.scale;
|
|
147
|
+
}
|
|
148
|
+
addSteps(t, e) {
|
|
149
|
+
return Math.round((t + e * this.step) * this.scale) / this.scale;
|
|
150
|
+
}
|
|
151
|
+
getIndex(t) {
|
|
152
|
+
if (!(t < this.min))
|
|
153
|
+
return Math.min(Math.ceil(t * this.scale), this.max * this.scale);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
c.Zoom = u;
|
|
157
|
+
class h {
|
|
158
|
+
constructor(t, e, o) {
|
|
159
|
+
// PROPERTIES
|
|
160
|
+
/** The id of the tooltip that this tooltip represents. */
|
|
161
|
+
A(this, "id", "");
|
|
162
|
+
/** The index of the tooltip in the tooltips array. */
|
|
163
|
+
A(this, "index", NaN);
|
|
164
|
+
/** The rank of the tooltip tooltip. */
|
|
165
|
+
A(this, "rank", NaN);
|
|
166
|
+
/** The x coordinate of the tooltip anchor. */
|
|
167
|
+
A(this, "x", NaN);
|
|
168
|
+
/** The y coordinate of the tooltip anchor. */
|
|
169
|
+
A(this, "y", NaN);
|
|
170
|
+
/** The base width of the tooltip tooltip. */
|
|
171
|
+
A(this, "width", NaN);
|
|
172
|
+
/** The base height of the tooltip tooltip. */
|
|
173
|
+
A(this, "height", NaN);
|
|
174
|
+
// STATE
|
|
175
|
+
/** State of the tooltip expanded or not. */
|
|
176
|
+
A(this, "expanded", !0);
|
|
177
|
+
/** The scale of the tooltip. */
|
|
178
|
+
A(this, "scale", 1);
|
|
179
|
+
/** The angle of the tooltip. */
|
|
180
|
+
A(this, "angle", M.DEGREES_DEFAULT);
|
|
181
|
+
/** The neighbours of the tooltip. */
|
|
182
|
+
A(this, "neighbours", new Array());
|
|
183
|
+
// BOUNDS
|
|
184
|
+
//* Scaled distances to edges of the tooltip bounds */
|
|
185
|
+
A(this, "distances", { left: NaN, right: NaN, top: NaN, bottom: NaN });
|
|
186
|
+
// SIMULATION
|
|
187
|
+
/** A tooltip has a particle whose position is used to calculate the angle */
|
|
188
|
+
A(this, "particle", { index: M.DEGREES.indexOf(M.DEGREES_DEFAULT), distX: NaN, distY: NaN });
|
|
189
|
+
const r = L.project(e.lat, e.lng, t.mapSize);
|
|
190
|
+
this.index = o, this.id = e.id, this.rank = e.rank, this.x = r.x, this.y = r.y, this.width = e.width + 2 * e.margin, this.height = e.height + 2 * e.margin;
|
|
191
|
+
}
|
|
192
|
+
updateScale(t) {
|
|
193
|
+
t != this.scale && (this.scale = t, this.updateBounds(t, this.angle), this.updateParticle(t));
|
|
194
|
+
}
|
|
195
|
+
updateAngle(t) {
|
|
196
|
+
t != this.angle && (this.angle = t, this.updateBounds(this.scale, t));
|
|
197
|
+
}
|
|
198
|
+
updateBounds(t, e) {
|
|
199
|
+
const o = Y.getOffsets(this.width, this.height, e), r = -o.x, s = this.width - r, a = -o.y, m = this.height - a, g = this.distances;
|
|
200
|
+
g.left = r / t, g.right = s / t, g.top = a / t, g.bottom = m / t;
|
|
201
|
+
}
|
|
202
|
+
updateParticle(t) {
|
|
203
|
+
this.particle.distX = this.width / 2 / t, this.particle.distY = this.height / 2 / t;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
c.Tooltip = h;
|
|
207
|
+
function l(n, t) {
|
|
208
|
+
let e = new Array(t.length);
|
|
209
|
+
for (let o = 0; o < t.length; o++)
|
|
210
|
+
e[o] = new h(n, t[o], o);
|
|
211
|
+
return e;
|
|
212
|
+
}
|
|
213
|
+
c.createTooltips = l;
|
|
214
|
+
function y(n, t) {
|
|
215
|
+
let e = new Array(), o = 0;
|
|
216
|
+
for (let s = t.min * t.scale; s < t.max * t.scale; s++)
|
|
217
|
+
e[s] = new Array(n.length);
|
|
218
|
+
const r = new Array(n.length);
|
|
219
|
+
for (let s = 0; s < n.length; s++) {
|
|
220
|
+
const a = n[s];
|
|
221
|
+
r[s] = {
|
|
222
|
+
x: a.x,
|
|
223
|
+
y: a.y,
|
|
224
|
+
distances: {
|
|
225
|
+
left: a.width,
|
|
226
|
+
right: a.width,
|
|
227
|
+
top: a.height,
|
|
228
|
+
bottom: a.height
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
for (let s = 0; s < n.length; s++) {
|
|
233
|
+
const a = n[s], m = r[s];
|
|
234
|
+
for (let g = s + 1; g < n.length; g++) {
|
|
235
|
+
const F = n[g], G = r[g], R = w.getZoomWhenTouching(m, G);
|
|
236
|
+
R > o && (o = R);
|
|
237
|
+
const O = t.getIndex(R);
|
|
238
|
+
if (O == null) continue;
|
|
239
|
+
const z = e[O], D = z[s];
|
|
240
|
+
D ? D.push(F) : z[s] = [F];
|
|
241
|
+
const P = z[g];
|
|
242
|
+
P ? P.push(a) : z[g] = [a];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return { zoomMax: o, zoomIndexDeltas: e };
|
|
246
|
+
}
|
|
247
|
+
c.createNeighbours = y;
|
|
248
|
+
function I(n, t) {
|
|
249
|
+
for (let e = 0; e < n.length; e++) {
|
|
250
|
+
let o = n[e];
|
|
251
|
+
if (o.expanded == !1) {
|
|
252
|
+
o.neighbours.length = 0;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const r = t[e];
|
|
256
|
+
if (r != null)
|
|
257
|
+
for (let s = 0; s < r.length; s++) {
|
|
258
|
+
const a = r[s];
|
|
259
|
+
a.expanded != !1 && o.neighbours.push(a);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
c.updateNeighbours = I;
|
|
264
|
+
function d(n) {
|
|
265
|
+
const t = /* @__PURE__ */ new Set(), e = [];
|
|
266
|
+
for (let o = 0; o < n.length; o++) {
|
|
267
|
+
let r = n[o];
|
|
268
|
+
if (r.expanded == !1 || r.neighbours.length == 0 || t.has(r)) continue;
|
|
269
|
+
t.add(r);
|
|
270
|
+
const s = [], a = [r];
|
|
271
|
+
for (; a.length > 0; ) {
|
|
272
|
+
const m = a.pop();
|
|
273
|
+
s.push(m);
|
|
274
|
+
for (const g of m.neighbours)
|
|
275
|
+
t.has(g) || (t.add(g), a.push(g));
|
|
276
|
+
}
|
|
277
|
+
e.push(s);
|
|
278
|
+
}
|
|
279
|
+
return e;
|
|
280
|
+
}
|
|
281
|
+
c.getNeighbourGraphs = d;
|
|
282
|
+
function b(n) {
|
|
283
|
+
n.expanded = !1;
|
|
284
|
+
const t = n.neighbours;
|
|
285
|
+
for (let e = 0; e < t.length; e++) {
|
|
286
|
+
const o = t[e], r = o.neighbours.indexOf(n);
|
|
287
|
+
o.neighbours.splice(r, 1);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
c.updateCollapsed = b;
|
|
291
|
+
function i(n, t, e) {
|
|
292
|
+
for (let o = 0; o < t.length; o++) {
|
|
293
|
+
const r = t[o];
|
|
294
|
+
if (r.expanded == !1) continue;
|
|
295
|
+
const s = n.get(r.id);
|
|
296
|
+
if (!s) throw new Error("Tooltip not found");
|
|
297
|
+
s.zoomAfterExpanded = e;
|
|
298
|
+
const a = M.DEGREES.indexOf(r.angle);
|
|
299
|
+
s.zoomAfterAngleIndexes.length == 0 ? s.zoomAfterAngleIndexes.push([e, a]) : s.zoomAfterAngleIndexes[0][1] != a ? s.zoomAfterAngleIndexes.unshift([e, a]) : s.zoomAfterAngleIndexes[0][0] = e;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
c.updateStates = i;
|
|
303
|
+
function x(n, t) {
|
|
304
|
+
for (let e = 0; e < n.length; e++)
|
|
305
|
+
n[e].updateScale(t);
|
|
306
|
+
}
|
|
307
|
+
c.updateScale = x;
|
|
308
|
+
function p(n) {
|
|
309
|
+
const t = /* @__PURE__ */ new Set();
|
|
310
|
+
for (let e = 0; e < n.length; e++) {
|
|
311
|
+
const o = n[e], r = n[e].neighbours;
|
|
312
|
+
for (let s = 0; s < r.length; s++) {
|
|
313
|
+
const a = r[s];
|
|
314
|
+
w.areOverlaping(o, a) && (t.add(o), t.add(a));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return t;
|
|
318
|
+
}
|
|
319
|
+
c.getOverlaps = p;
|
|
320
|
+
function E(n, t) {
|
|
321
|
+
let e = !1;
|
|
322
|
+
for (let o = 0; o < t.length; o++) {
|
|
323
|
+
const r = t[o], s = t[o].neighbours;
|
|
324
|
+
for (let a = 0; a < s.length; a++) {
|
|
325
|
+
const m = s[a];
|
|
326
|
+
w.areOverlaping(r, m) && (n.has(r) || (n.add(r), e = !0), n.has(m) || (n.add(m), e = !0));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return e;
|
|
330
|
+
}
|
|
331
|
+
c.updateOverlaps = E;
|
|
332
|
+
function S(n) {
|
|
333
|
+
let t, e = 0;
|
|
334
|
+
for (let o = 0; o < n.length; o++) {
|
|
335
|
+
const r = n[o], s = n[o].neighbours;
|
|
336
|
+
let a = 0;
|
|
337
|
+
for (let m = 0; m < s.length; m++) {
|
|
338
|
+
const g = s[m];
|
|
339
|
+
w.areOverlaping(r, g) && (a += 1 + (g.rank - r.rank));
|
|
340
|
+
}
|
|
341
|
+
a = a * s.length, a > e && (e = a, t = r);
|
|
342
|
+
}
|
|
343
|
+
return t;
|
|
344
|
+
}
|
|
345
|
+
c.getOverlapsWorstTooltip = S;
|
|
346
|
+
function v(n) {
|
|
347
|
+
for (let t = 0; t < n.length; t++) {
|
|
348
|
+
const e = n[t];
|
|
349
|
+
for (let o = t + 1; o < n.length; o++) {
|
|
350
|
+
const r = n[o];
|
|
351
|
+
if (w.areOverlaping(e, r))
|
|
352
|
+
return !0;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return !1;
|
|
356
|
+
}
|
|
357
|
+
c.areOverlaping = v, ((n) => {
|
|
358
|
+
function t(r) {
|
|
359
|
+
j.initializeAngleIndexes(r), o(r);
|
|
360
|
+
}
|
|
361
|
+
n.initializeAngles = t;
|
|
362
|
+
function e(r) {
|
|
363
|
+
const s = j.updateAngleIndexes(r);
|
|
364
|
+
return o(r), s;
|
|
365
|
+
}
|
|
366
|
+
n.updateAngles = e;
|
|
367
|
+
function o(r) {
|
|
368
|
+
for (let s = 0; s < r.length; s++) {
|
|
369
|
+
const a = r[s];
|
|
370
|
+
a.updateAngle(M.DEGREES[a.particle.index]);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
n.updateTooltips = o;
|
|
374
|
+
})(c.Particles || (c.Particles = {}));
|
|
375
|
+
})(N || (N = {}));
|
|
376
|
+
function st(c, f) {
|
|
377
|
+
const u = new N.Zoom(c);
|
|
378
|
+
if (f.length == 0) return [];
|
|
379
|
+
if (f.length == 1) return [[u.min, [[u.min, M.DEGREES.indexOf(M.DEGREES_DEFAULT)]]]];
|
|
380
|
+
const h = new Map(f.map((i) => [i.id, new N.State()])), l = N.createTooltips(c, f), y = N.createNeighbours(l, u);
|
|
381
|
+
N.Particles.initializeAngles(l), N.updateStates(h, l, u.addSteps(u.max, 1));
|
|
382
|
+
const I = u.getIndex(y.zoomMax);
|
|
383
|
+
if (I == null) return Array.from(h.values()).map((i) => [i.zoomAfterExpanded, i.zoomAfterAngleIndexes]);
|
|
384
|
+
const d = u.min, b = I / u.scale;
|
|
385
|
+
for (let i = b; i >= d; i = u.addSteps(i, -1)) {
|
|
386
|
+
const x = Math.pow(2, i), p = Math.round(i * u.scale);
|
|
387
|
+
N.updateNeighbours(l, y.zoomIndexDeltas[p]);
|
|
388
|
+
const E = N.getNeighbourGraphs(l);
|
|
389
|
+
for (const S of E) {
|
|
390
|
+
N.updateScale(S, x);
|
|
391
|
+
const v = N.getOverlaps(S);
|
|
392
|
+
for (; v.size > 1; ) {
|
|
393
|
+
const n = Array.from(v);
|
|
394
|
+
for (let o = 0; o < M.COUNT && !(N.Particles.updateAngles(n) == !0 || N.areOverlaping(n) == !1); o++)
|
|
395
|
+
;
|
|
396
|
+
if (N.updateOverlaps(v, n)) continue;
|
|
397
|
+
const e = N.getOverlapsWorstTooltip(n);
|
|
398
|
+
if (e == null) break;
|
|
399
|
+
N.updateCollapsed(e), v.delete(e);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
N.updateStates(h, l, Number(i.toFixed(1)));
|
|
403
|
+
}
|
|
404
|
+
return Array.from(h.values()).map((i) => [i.zoomAfterExpanded, i.zoomAfterAngleIndexes]);
|
|
405
|
+
}
|
|
406
|
+
export {
|
|
407
|
+
M as A,
|
|
408
|
+
w as B,
|
|
409
|
+
L as M,
|
|
410
|
+
Y as R,
|
|
411
|
+
st as g
|
|
412
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var K=Object.defineProperty;var V=(c,f,d)=>f in c?K(c,f,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[f]=d;var m=(c,f,d)=>V(c,typeof f!="symbol"?f+"":f,d);exports.Rectangle=void 0;(c=>{function f(d,h,l){const y=d/2,I=h/2,u=Math.sqrt(y*y+I*I),b=Math.atan(I/y)*(180/Math.PI),i=l*(Math.PI/180);return l<180?l<90?l<b?{x:0,y:u*Math.sin(i)-I}:{x:u*Math.cos(i)-y,y:0}:l<180-b?{x:u*Math.cos(i)-y,y:0}:{x:-d,y:u*Math.sin(i)-I}:l<270?l<180+b?{x:-d,y:u*Math.sin(i)-I}:{x:u*Math.cos(i)-y,y:-h}:l<360-b?{x:u*Math.cos(i)-y,y:-h}:{x:0,y:u*Math.sin(i)-I}}c.getOffsets=f})(exports.Rectangle||(exports.Rectangle={}));exports.Mercator=void 0;(c=>{function f(u,b,i){return{x:h(b)*i,y:l(u)*i}}c.project=f;function d(u,b,i){return{lat:I(b/i),lng:y(u/i)}}c.unproject=d;function h(u){return(180+u)/360}function l(u){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+u*Math.PI/360)))/360}function y(u){return u*360-180}function I(u){return 360/Math.PI*Math.atan(Math.exp((180-u*360)*Math.PI/180))-90}})(exports.Mercator||(exports.Mercator={}));exports.Angles=void 0;(c=>{c.COUNT=12,c.DEGREES=[0,30,60,90,120,150,180,210,240,270,300,330],c.DEGREES_DEFAULT=270})(exports.Angles||(exports.Angles={}));var F;(c=>{const f=exports.Angles.DEGREES.map(i=>i*Math.PI/180),d=f.map(i=>Math.cos(i)),h=f.map(i=>Math.sin(i));function l(i,x){const p=Math.abs(x/i);return p<1?p<.26795?0:1:p<3.73205?2:3}function y(i,x){const p=l(i,x);return i>0?x>0?(12-p)%12:0+p:x>0?6+p:6-p}function I(i,x){return x==0?i:((i+x)%exports.Angles.COUNT+exports.Angles.COUNT)%exports.Angles.COUNT}function u(i){let x=!0;for(let p=0;p<i.length;p++){const v=i[p],S=v.particle,M=v.x,n=v.y,t=S.distX,e=S.distY,o=S.index,r=I(o,-1),s=I(o,1),a=M+t*d[r],A=n+e*h[r],g=M+t*d[o],R=n+e*h[o],T=M+t*d[s],D=n+e*h[s];let z=0,E=0,O=0;const w=v.neighbours;for(let j=0;j<w.length;j++){const G=w[j],B=G.particle,H=G.x,q=G.y,Q=B.distX,J=B.distY,k=B.index,C=H+Q*d[k],Z=q+J*h[k],X=a-C,U=A-Z;z+=1/(X*X+U*U);const Y=g-C,L=R-Z;E+=1/(Y*Y+L*L);const W=T-C,_=D-Z;O+=1/(W*W+_*_)}let P=0;z<E&&z<O&&(P=-1),O<E&&O<z&&(P=1),P!=0&&(S.index=I(o,P),x=!1)}return x}c.updateAngleIndexes=u;function b(i){for(let x=0;x<i.length;x++){const p=i[x],v=p.x,S=p.y;let M=0,n=0;for(let t=0;t<i.length;t++){const e=i[t],o=e.x,r=e.y,s=v-o,a=S-r;if(s==0&&a==0)continue;const A=Math.sqrt(s*s+a*a),g=1/(A*A);M+=g*s/A,n+=-(g*a)/A}p.particle.index=y(M,n)}}c.initializeAngleIndexes=b})(F||(F={}));exports.Bounds=void 0;(c=>{function f(h,l){return!(h.x-h.distances.left>l.x+l.distances.right||h.x+h.distances.right<l.x-l.distances.left||h.y-h.distances.top>l.y+l.distances.bottom||h.y+h.distances.bottom<l.y-l.distances.top)}c.areOverlaping=f;function d(h,l){let y=Math.abs(h.x-l.x),u=(h.x<l.x?h.distances.right+l.distances.left:h.distances.left+l.distances.right)/y,b=Math.abs(h.y-l.y),x=(h.y<l.y?h.distances.bottom+l.distances.top:h.distances.top+l.distances.bottom)/b,p=Math.min(u,x);return Math.log2(p)}c.getZoomWhenTouching=d})(exports.Bounds||(exports.Bounds={}));var N;(c=>{class f{constructor(){m(this,"zoomAfterExpanded");m(this,"zoomAfterAngleIndexes");this.zoomAfterExpanded=NaN,this.zoomAfterAngleIndexes=[]}}c.State=f;class d{constructor(t){m(this,"min");m(this,"max");m(this,"scale");m(this,"step");this.min=t.zoomMin,this.max=t.zoomMax,this.scale=t.zoomScale,this.step=1/this.scale}addSteps(t,e){return Math.round((t+e*this.step)*this.scale)/this.scale}getIndex(t){if(!(t<this.min))return Math.min(Math.ceil(t*this.scale),this.max*this.scale)}}c.Zoom=d;class h{constructor(t,e,o){m(this,"id","");m(this,"index",NaN);m(this,"rank",NaN);m(this,"x",NaN);m(this,"y",NaN);m(this,"width",NaN);m(this,"height",NaN);m(this,"expanded",!0);m(this,"scale",1);m(this,"angle",exports.Angles.DEGREES_DEFAULT);m(this,"neighbours",new Array);m(this,"distances",{left:NaN,right:NaN,top:NaN,bottom:NaN});m(this,"particle",{index:exports.Angles.DEGREES.indexOf(exports.Angles.DEGREES_DEFAULT),distX:NaN,distY:NaN});const r=exports.Mercator.project(e.lat,e.lng,t.mapSize);this.index=o,this.id=e.id,this.rank=e.rank,this.x=r.x,this.y=r.y,this.width=e.width+2*e.margin,this.height=e.height+2*e.margin}updateScale(t){t!=this.scale&&(this.scale=t,this.updateBounds(t,this.angle),this.updateParticle(t))}updateAngle(t){t!=this.angle&&(this.angle=t,this.updateBounds(this.scale,t))}updateBounds(t,e){const o=exports.Rectangle.getOffsets(this.width,this.height,e),r=-o.x,s=this.width-r,a=-o.y,A=this.height-a,g=this.distances;g.left=r/t,g.right=s/t,g.top=a/t,g.bottom=A/t}updateParticle(t){this.particle.distX=this.width/2/t,this.particle.distY=this.height/2/t}}c.Tooltip=h;function l(n,t){let e=new Array(t.length);for(let o=0;o<t.length;o++)e[o]=new h(n,t[o],o);return e}c.createTooltips=l;function y(n,t){let e=new Array,o=0;for(let s=t.min*t.scale;s<t.max*t.scale;s++)e[s]=new Array(n.length);const r=new Array(n.length);for(let s=0;s<n.length;s++){const a=n[s];r[s]={x:a.x,y:a.y,distances:{left:a.width,right:a.width,top:a.height,bottom:a.height}}}for(let s=0;s<n.length;s++){const a=n[s],A=r[s];for(let g=s+1;g<n.length;g++){const R=n[g],T=r[g],D=exports.Bounds.getZoomWhenTouching(A,T);D>o&&(o=D);const z=t.getIndex(D);if(z==null)continue;const E=e[z],O=E[s];O?O.push(R):E[s]=[R];const w=E[g];w?w.push(a):E[g]=[a]}}return{zoomMax:o,zoomIndexDeltas:e}}c.createNeighbours=y;function I(n,t){for(let e=0;e<n.length;e++){let o=n[e];if(o.expanded==!1){o.neighbours.length=0;continue}const r=t[e];if(r!=null)for(let s=0;s<r.length;s++){const a=r[s];a.expanded!=!1&&o.neighbours.push(a)}}}c.updateNeighbours=I;function u(n){const t=new Set,e=[];for(let o=0;o<n.length;o++){let r=n[o];if(r.expanded==!1||r.neighbours.length==0||t.has(r))continue;t.add(r);const s=[],a=[r];for(;a.length>0;){const A=a.pop();s.push(A);for(const g of A.neighbours)t.has(g)||(t.add(g),a.push(g))}e.push(s)}return e}c.getNeighbourGraphs=u;function b(n){n.expanded=!1;const t=n.neighbours;for(let e=0;e<t.length;e++){const o=t[e],r=o.neighbours.indexOf(n);o.neighbours.splice(r,1)}}c.updateCollapsed=b;function i(n,t,e){for(let o=0;o<t.length;o++){const r=t[o];if(r.expanded==!1)continue;const s=n.get(r.id);if(!s)throw new Error("Tooltip not found");s.zoomAfterExpanded=e;const a=exports.Angles.DEGREES.indexOf(r.angle);s.zoomAfterAngleIndexes.length==0?s.zoomAfterAngleIndexes.push([e,a]):s.zoomAfterAngleIndexes[0][1]!=a?s.zoomAfterAngleIndexes.unshift([e,a]):s.zoomAfterAngleIndexes[0][0]=e}}c.updateStates=i;function x(n,t){for(let e=0;e<n.length;e++)n[e].updateScale(t)}c.updateScale=x;function p(n){const t=new Set;for(let e=0;e<n.length;e++){const o=n[e],r=n[e].neighbours;for(let s=0;s<r.length;s++){const a=r[s];exports.Bounds.areOverlaping(o,a)&&(t.add(o),t.add(a))}}return t}c.getOverlaps=p;function v(n,t){let e=!1;for(let o=0;o<t.length;o++){const r=t[o],s=t[o].neighbours;for(let a=0;a<s.length;a++){const A=s[a];exports.Bounds.areOverlaping(r,A)&&(n.has(r)||(n.add(r),e=!0),n.has(A)||(n.add(A),e=!0))}}return e}c.updateOverlaps=v;function S(n){let t,e=0;for(let o=0;o<n.length;o++){const r=n[o],s=n[o].neighbours;let a=0;for(let A=0;A<s.length;A++){const g=s[A];exports.Bounds.areOverlaping(r,g)&&(a+=1+(g.rank-r.rank))}a=a*s.length,a>e&&(e=a,t=r)}return t}c.getOverlapsWorstTooltip=S;function M(n){for(let t=0;t<n.length;t++){const e=n[t];for(let o=t+1;o<n.length;o++){const r=n[o];if(exports.Bounds.areOverlaping(e,r))return!0}}return!1}c.areOverlaping=M,(n=>{function t(r){F.initializeAngleIndexes(r),o(r)}n.initializeAngles=t;function e(r){const s=F.updateAngleIndexes(r);return o(r),s}n.updateAngles=e;function o(r){for(let s=0;s<r.length;s++){const a=r[s];a.updateAngle(exports.Angles.DEGREES[a.particle.index])}}n.updateTooltips=o})(c.Particles||(c.Particles={}))})(N||(N={}));function $(c,f){const d=new N.Zoom(c);if(f.length==0)return[];if(f.length==1)return[[d.min,[[d.min,exports.Angles.DEGREES.indexOf(exports.Angles.DEGREES_DEFAULT)]]]];const h=new Map(f.map(i=>[i.id,new N.State])),l=N.createTooltips(c,f),y=N.createNeighbours(l,d);N.Particles.initializeAngles(l),N.updateStates(h,l,d.addSteps(d.max,1));const I=d.getIndex(y.zoomMax);if(I==null)return Array.from(h.values()).map(i=>[i.zoomAfterExpanded,i.zoomAfterAngleIndexes]);const u=d.min,b=I/d.scale;for(let i=b;i>=u;i=d.addSteps(i,-1)){const x=Math.pow(2,i),p=Math.round(i*d.scale);N.updateNeighbours(l,y.zoomIndexDeltas[p]);const v=N.getNeighbourGraphs(l);for(const S of v){N.updateScale(S,x);const M=N.getOverlaps(S);for(;M.size>1;){const n=Array.from(M);for(let o=0;o<exports.Angles.COUNT&&!(N.Particles.updateAngles(n)==!0||N.areOverlaping(n)==!1);o++);if(N.updateOverlaps(M,n))continue;const e=N.getOverlapsWorstTooltip(n);if(e==null)break;N.updateCollapsed(e),M.delete(e)}}N.updateStates(h,l,Number(i.toFixed(1)))}return Array.from(h.values()).map(i=>[i.zoomAfterExpanded,i.zoomAfterAngleIndexes])}exports.getStates=$;
|