@linkurious/ogma-annotations 2.0.3 → 2.1.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.
@@ -0,0 +1,780 @@
1
+ const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click", ut = "select", yt = "unselect", lt = "hover", ft = "unhover", gt = "remove", ht = "add", pt = "cancelDrawing", xt = "completeDrawing", mt = "update", bt = "link", wt = "history", Tt = "data-annotation", Et = 5, It = 3, St = {
2
+ SHAPES: 1,
3
+ EDITOR: 2,
4
+ HANDLES: 3
5
+ }, w = "start", Nt = "end", Ct = {
6
+ default: "default",
7
+ move: "move",
8
+ pointer: "pointer",
9
+ crosshair: "crosshair",
10
+ grab: "grab",
11
+ grabbing: "grabbing",
12
+ ewResize: "ew-resize",
13
+ nsResize: "ns-resize",
14
+ neswResize: "nesw-resize",
15
+ nwseResize: "nwse-resize",
16
+ nwResize: "nw-resize",
17
+ neResize: "ne-resize",
18
+ swResize: "sw-resize",
19
+ seResize: "se-resize",
20
+ nResize: "n-resize",
21
+ eResize: "e-resize",
22
+ sResize: "s-resize",
23
+ wResize: "w-resize"
24
+ }, T = "collapsed", B = "expanded", Mt = 1.2, z = 0.2, At = {
25
+ TEXT: "text",
26
+ NODE: "node",
27
+ BOX: "box",
28
+ COMMENT: "comment",
29
+ POLYGON: "polygon",
30
+ ANNOTATION: "annotation",
31
+ EDGE: "edge"
32
+ }, _t = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
33
+ <path d="M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
34
+ </svg>`, Pt = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
35
+ <path d="M12 6.00015H7.33333C6.97971 6.00015 6.64057 6.14063 6.39052 6.39068C6.14048 6.64072 6 6.97986 6 7.33348V16.6668C6 17.0204 6.14048 17.3596 6.39052 17.6096C6.64057 17.8597 6.97971 18.0002 7.33333 18.0002H16.6667C17.0203 18.0002 17.3594 17.8597 17.6095 17.6096C17.8595 17.3596 18 17.0204 18 16.6668V12.0002M16.25 5.75015C16.5152 5.48493 16.8749 5.33594 17.25 5.33594C17.6251 5.33594 17.9848 5.48493 18.25 5.75015C18.5152 6.01537 18.6642 6.37508 18.6642 6.75015C18.6642 7.12522 18.5152 7.48493 18.25 7.75015L12.2413 13.7595C12.083 13.9176 11.8875 14.0334 11.6727 14.0962L9.75733 14.6562C9.69997 14.6729 9.63916 14.6739 9.58127 14.6591C9.52339 14.6442 9.47055 14.6141 9.4283 14.5719C9.38604 14.5296 9.35593 14.4768 9.3411 14.4189C9.32627 14.361 9.32727 14.3002 9.344 14.2428L9.904 12.3275C9.96702 12.1129 10.083 11.9175 10.2413 11.7595L16.25 5.75015Z" stroke="#1A70E5" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
36
+ </svg>
37
+ `;
38
+ let g = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, r) => (r &= 63, r < 36 ? e += r.toString(36) : r < 62 ? e += (r - 26).toString(36).toUpperCase() : r > 62 ? e += "-" : e += "_", e), "");
39
+ const G = "http://www.w3.org/2000/svg";
40
+ function Rt(t) {
41
+ return document.createElementNS(G, t);
42
+ }
43
+ function S(t) {
44
+ return t.geometry.bbox || H(t), t.geometry.bbox;
45
+ }
46
+ function D(t) {
47
+ if ("width" in t.properties && "height" in t.properties)
48
+ return {
49
+ width: t.properties.width,
50
+ height: t.properties.height
51
+ };
52
+ const e = S(t);
53
+ return {
54
+ width: e[2] - e[0],
55
+ height: e[3] - e[1]
56
+ };
57
+ }
58
+ function Y(t, e = !1, r = 1) {
59
+ if (t.geometry.type === "Point" && "width" in t.properties && "height" in t.properties) {
60
+ const [s, o] = t.geometry.coordinates;
61
+ let i = t.properties.width, a = t.properties.height;
62
+ return e && (i /= r, a /= r), {
63
+ x: s - i / 2,
64
+ y: o - a / 2
65
+ };
66
+ }
67
+ const n = S(t);
68
+ return { x: n[0], y: n[1] };
69
+ }
70
+ function zt(t) {
71
+ if (t.geometry.type === "Point")
72
+ return { x: t.geometry.coordinates[0], y: t.geometry.coordinates[1] };
73
+ const e = S(t);
74
+ return { x: (e[0] + e[2]) / 2, y: (e[1] + e[3]) / 2 };
75
+ }
76
+ function H(t) {
77
+ if (j(t)) {
78
+ const [e, r] = t.geometry.coordinates[0], [n, s] = t.geometry.coordinates[1];
79
+ t.geometry.bbox = [
80
+ Math.min(e, n),
81
+ Math.min(r, s),
82
+ Math.max(e, n),
83
+ Math.max(r, s)
84
+ ];
85
+ } else if (t.geometry.type === "Point" && "width" in t.properties && "height" in t.properties) {
86
+ const [e, r] = t.geometry.coordinates, n = t.properties.width / 2, s = t.properties.height / 2;
87
+ t.geometry.bbox = [e - n, r - s, e + n, r + s];
88
+ } else if (t.geometry.type === "Polygon") {
89
+ const e = t.geometry.coordinates[0];
90
+ let r = Number.POSITIVE_INFINITY, n = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
91
+ for (const i of e) {
92
+ const a = i[0], c = i[1];
93
+ a < r && (r = a), c < n && (n = c), a > s && (s = a), c > o && (o = c);
94
+ }
95
+ t.geometry.bbox = [r, n, s, o];
96
+ }
97
+ }
98
+ function Dt(t, e, r, n, s) {
99
+ t.geometry.coordinates = [e + n / 2, r + s / 2], t.geometry.bbox = [e, r, e + n, r + s], t.properties.width = n, t.properties.height = s;
100
+ }
101
+ function W(t) {
102
+ const [e, r] = t.geometry.coordinates[0];
103
+ return { x: e, y: r };
104
+ }
105
+ function Ft(t, e) {
106
+ const [r, n] = t.geometry.coordinates[e === w ? 0 : 1];
107
+ return { x: r, y: n };
108
+ }
109
+ function X(t) {
110
+ const [e, r] = t.geometry.coordinates[1];
111
+ return { x: e, y: r };
112
+ }
113
+ function $(t, e, r) {
114
+ t.geometry.coordinates[0] = [e, r];
115
+ }
116
+ function v(t, e, r) {
117
+ t.geometry.coordinates[1] = [e, r];
118
+ }
119
+ function U(t) {
120
+ return { start: W(t), end: X(t) };
121
+ }
122
+ function Lt(t, e, r, n) {
123
+ e === w ? $(t, r, n) : v(t, r, n);
124
+ }
125
+ const Ot = (t) => parseInt(t.getAttribute("data-handle-id") || "-1");
126
+ function Vt(t) {
127
+ return b(t).reduce(
128
+ (e, r) => (e[0] = Math.min(r[0], e[0]), e[1] = Math.min(r[1], e[1]), e[2] = Math.max(r[0], e[2]), e[3] = Math.max(r[1], e[3]), e),
129
+ [
130
+ Number.POSITIVE_INFINITY,
131
+ Number.POSITIVE_INFINITY,
132
+ Number.NEGATIVE_INFINITY,
133
+ Number.NEGATIVE_INFINITY
134
+ ]
135
+ );
136
+ }
137
+ function q(t) {
138
+ return Array.isArray(t) && t.length === 2 && t.every(isFinite);
139
+ }
140
+ function kt(t, e, r, n) {
141
+ for (let s = 0; s < t.coordinates.length; s++) {
142
+ const o = t.coordinates[s];
143
+ if (q(o))
144
+ o[0] = r + (o[0] - r) * e, o[1] = n + (o[1] - n) * e;
145
+ else
146
+ for (let i = 0; i < o.length; i++) {
147
+ const a = o[i];
148
+ a[0] = r + (a[0] - r) * e, a[1] = n + (a[1] - n) * e;
149
+ }
150
+ }
151
+ return t;
152
+ }
153
+ function b(t) {
154
+ let e = [];
155
+ if (t.type == "Point")
156
+ t.bbox ? e = [
157
+ [t.bbox[0], t.bbox[1]],
158
+ [t.bbox[2], t.bbox[3]]
159
+ ] : e = [t.coordinates];
160
+ else if (t.type == "LineString" || t.type == "MultiPoint")
161
+ e = t.coordinates;
162
+ else if (t.type == "Polygon" || t.type == "MultiLineString")
163
+ e = t.coordinates.reduce(function(r, n) {
164
+ return r.concat(n);
165
+ }, []);
166
+ else if (t.type == "MultiPolygon")
167
+ e = t.coordinates.reduce(
168
+ (r, n) => r.concat(n.reduce((s, o) => s.concat(o), [])),
169
+ []
170
+ );
171
+ else if (t.type == "Feature")
172
+ if (V(t) || O(t)) {
173
+ const r = S(t);
174
+ e = [
175
+ [r[0], r[1]],
176
+ [r[2], r[3]]
177
+ ];
178
+ } else e = b(t.geometry);
179
+ else t.type == "GeometryCollection" ? e = t.geometries.reduce(
180
+ (r, n) => r.concat(b(n)),
181
+ []
182
+ ) : t.type == "FeatureCollection" && (e = t.features.reduce(
183
+ (r, n) => r.concat(b(n)),
184
+ []
185
+ ));
186
+ return e;
187
+ }
188
+ function Bt(t, e, r) {
189
+ const n = Math.atan2(t.y - e.y, t.x - e.x);
190
+ return {
191
+ x: e.x + r * Math.cos(n),
192
+ y: e.y + r * Math.sin(n)
193
+ };
194
+ }
195
+ function Gt(t, e) {
196
+ if (!e) return { x: t.clientX, y: t.clientY };
197
+ const r = e.getBoundingClientRect();
198
+ return {
199
+ x: t.clientX - r.left - e.clientLeft,
200
+ y: t.clientY - r.top - e.clientTop
201
+ };
202
+ }
203
+ function Yt(t, e) {
204
+ return t.startsWith("#") ? Z(t, e) : t.startsWith("rgb") ? K(t, e) : t;
205
+ }
206
+ function Ht(t) {
207
+ if (t.startsWith("#")) {
208
+ const e = M(t), r = parseInt(e.slice(1, 3), 16), n = parseInt(e.slice(3, 5), 16), s = parseInt(e.slice(5, 7), 16);
209
+ return { r, g: n, b: s, a: 1 };
210
+ } else {
211
+ const e = t.match(
212
+ /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/
213
+ );
214
+ if (!e) throw new Error(`Invalid RGB color: ${t}`);
215
+ return {
216
+ r: parseInt(e[1]),
217
+ g: parseInt(e[2]),
218
+ b: parseInt(e[3]),
219
+ a: e[4] !== void 0 ? parseFloat(e[4]) : 1
220
+ };
221
+ }
222
+ }
223
+ function M(t) {
224
+ return t.length === 4 ? t.split("").map((e) => e + e).join("") : t;
225
+ }
226
+ function Z(t, e) {
227
+ const [r, n, s] = M(t).match(/\w\w/g).map((o) => parseInt(o, 16));
228
+ return `rgba(${r}, ${n}, ${s}, ${e})`;
229
+ }
230
+ function K(t, e) {
231
+ const [r, n, s] = t.match(/\d+/g).map((o) => parseInt(o, 10));
232
+ return `rgba(${r}, ${n}, ${s}, ${e})`;
233
+ }
234
+ function Wt() {
235
+ return typeof window < "u" ? window : void 0;
236
+ }
237
+ const Xt = (t, e = 16, r = !1) => {
238
+ let n = !1, s = null;
239
+ const o = Math.max(1, Math.round(e * 60 / 1e3)), i = (a) => {
240
+ requestAnimationFrame(() => {
241
+ if (a > 1)
242
+ i(a - 1);
243
+ else if (n = !1, r && s !== null) {
244
+ const c = s;
245
+ s = null, t(...c), n = !0, i(o);
246
+ }
247
+ });
248
+ };
249
+ return (...a) => {
250
+ if (n) {
251
+ r && (s = a);
252
+ return;
253
+ }
254
+ t(...a), n = !0, i(o);
255
+ };
256
+ }, $t = (t, e) => {
257
+ let r;
258
+ return (...s) => {
259
+ clearTimeout(r), r = setTimeout(() => t(...s), e);
260
+ };
261
+ };
262
+ function vt(t, e) {
263
+ let r;
264
+ return function(...n) {
265
+ clearTimeout(r), r = setTimeout(() => {
266
+ t.apply(this, n);
267
+ }, e);
268
+ };
269
+ }
270
+ function Ut(t) {
271
+ if ((O(t) || V(t)) && t.geometry.type === "Polygon") {
272
+ const e = t.geometry.coordinates[0], r = e[0][0], n = e[0][1], s = e[2][0], o = e[2][1], i = s - r, a = o - n, c = r + i / 2, d = n + a / 2;
273
+ return {
274
+ ...t,
275
+ geometry: {
276
+ type: "Point",
277
+ coordinates: [c, d],
278
+ bbox: [r, n, s, o]
279
+ },
280
+ properties: {
281
+ ...t.properties,
282
+ width: i,
283
+ height: a
284
+ }
285
+ };
286
+ }
287
+ return t;
288
+ }
289
+ function F(t, e) {
290
+ let r, n, s, o = 1;
291
+ const i = t.trim();
292
+ if (i.startsWith("#")) {
293
+ const y = (i.length === 4 ? M(i) : i).match(/#?(\w{2})(\w{2})(\w{2})/);
294
+ if (!y) return t;
295
+ r = parseInt(y[1], 16), n = parseInt(y[2], 16), s = parseInt(y[3], 16);
296
+ } else {
297
+ const u = i.match(
298
+ /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/
299
+ );
300
+ if (!u) return t;
301
+ r = parseInt(u[1]), n = parseInt(u[2]), s = parseInt(u[3]), o = u[4] !== void 0 ? parseFloat(u[4]) : 1;
302
+ }
303
+ const a = e * 100, d = 0.299 * r + 0.587 * n + 0.114 * s > 186 ? -a / 2 : a;
304
+ return r = Math.max(0, Math.min(255, r + Math.round(2.55 * d))), n = Math.max(0, Math.min(255, n + Math.round(2.55 * d))), s = Math.max(0, Math.min(255, s + Math.round(2.55 * d))), `rgba(${r},${n},${s},${o})`;
305
+ }
306
+ const qt = (t) => F(t, z), Zt = (t) => F(t, -z), P = (t, e) => ({
307
+ x: t.x - e.x,
308
+ y: t.y - e.y
309
+ }), L = (t) => Math.sqrt(t.x * t.x + t.y * t.y), Kt = (t) => ({
310
+ x: -t.x,
311
+ y: -t.y
312
+ }), R = (t) => {
313
+ const e = L(t);
314
+ return e === 0 ? { x: 0, y: 0 } : {
315
+ x: t.x / e,
316
+ y: t.y / e
317
+ };
318
+ }, Jt = (t, e) => ({
319
+ x: t.x + e.x,
320
+ y: t.y + e.y
321
+ }), Qt = (t, e) => ({
322
+ x: t.x * e,
323
+ y: t.y * e
324
+ }), jt = (t, e) => {
325
+ const r = Math.sin(e), n = Math.cos(e);
326
+ return {
327
+ x: t.x * n - t.y * r,
328
+ y: t.x * r + t.y * n
329
+ };
330
+ }, J = (t, e) => t.x * e.x + t.y * e.y, Q = (t, e) => t.x * e.y - t.y * e.x, j = (t) => t.properties.type === "arrow";
331
+ function te(t, e, r) {
332
+ const { start: n, end: s } = U(t), o = P(e, n), i = t.properties.style.strokeWidth, a = P(s, n), c = L(a), d = J(o, R(a));
333
+ return d > 0 && d < c && Math.abs(Q(o, R(a))) < i / 2 + r;
334
+ }
335
+ const E = {
336
+ strokeType: "plain",
337
+ strokeColor: "#202020",
338
+ strokeWidth: 1,
339
+ head: "none",
340
+ tail: "none"
341
+ }, ee = {
342
+ id: void 0,
343
+ // will be set by the editor
344
+ type: "Feature",
345
+ properties: {
346
+ type: "arrow",
347
+ style: {
348
+ ...E
349
+ }
350
+ },
351
+ geometry: {
352
+ type: "LineString",
353
+ coordinates: [
354
+ [0, 0],
355
+ [100, 100]
356
+ ]
357
+ }
358
+ // type: 'arrow',
359
+ // stroke: {
360
+ // type: 'plain',
361
+ // color: 'black',
362
+ // width: 1
363
+ // },
364
+ // head: 'none',
365
+ // tail: 'arrow-plain',
366
+ // start: { x: 0, y: 0 },
367
+ // end: { x: 100, y: 100 }
368
+ }, tt = (t = 0, e = 0, r = 0, n = 0, s = { ...E }) => ({
369
+ id: g(),
370
+ type: "Feature",
371
+ properties: {
372
+ type: "arrow",
373
+ style: {
374
+ ...E,
375
+ ...s
376
+ }
377
+ },
378
+ geometry: {
379
+ type: "LineString",
380
+ coordinates: [
381
+ [t, e],
382
+ [r, n]
383
+ ]
384
+ }
385
+ }), O = (t) => t.properties.type === "box";
386
+ function re(t, e, r = 0, n = 1, s = 0) {
387
+ const o = Y(t), { width: i, height: a } = D(t), c = e.x - o.x, d = e.y - o.y, u = c * n - d * r, y = c * r + d * n;
388
+ return u > -s && u < i + s && y > -s && y < a + s;
389
+ }
390
+ const I = {
391
+ background: "#f5f5f5",
392
+ strokeWidth: 0,
393
+ borderRadius: 8,
394
+ boxShadow: "",
395
+ padding: 16,
396
+ strokeType: "plain"
397
+ }, ne = {
398
+ id: void 0,
399
+ // will be set by the editor
400
+ type: "Feature",
401
+ properties: {
402
+ type: "box",
403
+ width: 100,
404
+ height: 50,
405
+ style: { ...I }
406
+ },
407
+ geometry: {
408
+ type: "Point",
409
+ coordinates: [50, 25],
410
+ // center of 100x50 box
411
+ bbox: [0, 0, 100, 50]
412
+ }
413
+ }, se = (t = 0, e = 0, r = 100, n = 50, s = { ...I }) => ({
414
+ id: g(),
415
+ type: "Feature",
416
+ properties: {
417
+ type: "box",
418
+ width: r,
419
+ height: n,
420
+ style: { ...I, ...s }
421
+ },
422
+ geometry: {
423
+ type: "Point",
424
+ coordinates: [t + r / 2, e + n / 2]
425
+ // center
426
+ }
427
+ }), V = (t) => t.properties.type === "text", C = {
428
+ font: "sans-serif",
429
+ fontSize: 18,
430
+ color: "#505050",
431
+ background: "#f5f5f5",
432
+ strokeWidth: 0,
433
+ borderRadius: 8,
434
+ padding: 16,
435
+ strokeType: "plain",
436
+ fixedSize: !1
437
+ }, oe = {
438
+ id: g(),
439
+ type: "Feature",
440
+ properties: {
441
+ type: "text",
442
+ content: "",
443
+ width: 100,
444
+ height: 50,
445
+ style: { ...C }
446
+ },
447
+ geometry: {
448
+ type: "Point",
449
+ coordinates: [50, 25],
450
+ // center of 100x50 box
451
+ bbox: [0, 0, 100, 50]
452
+ }
453
+ }, ie = (t = 0, e = 0, r = 100, n = 50, s = "", o = { ...C }) => ({
454
+ id: g(),
455
+ type: "Feature",
456
+ properties: {
457
+ type: "text",
458
+ content: s,
459
+ width: r,
460
+ height: n,
461
+ style: { ...C, ...o }
462
+ },
463
+ geometry: {
464
+ type: "Point",
465
+ coordinates: [t + r / 2, e + n / 2],
466
+ // center
467
+ bbox: [t, e, t + r, e + n]
468
+ }
469
+ });
470
+ function et(t, e, r = 0, n = 0, s = 1, o = 1) {
471
+ var x;
472
+ const [i, a] = t.geometry.coordinates;
473
+ let { width: c, height: d } = D(t);
474
+ (x = t.properties.style) != null && x.fixedSize && (c /= o, d /= o);
475
+ const u = c / 2, y = d / 2, l = e.x - i, f = e.y - a, h = l * s - f * n, p = l * n + f * s;
476
+ return h > -u - r && h < u + r && p > -y - r && p < y + r;
477
+ }
478
+ const ae = (t) => t.properties.type === "comment", m = {
479
+ // Box styling
480
+ background: "#FFFACD",
481
+ // Light yellow (sticky note color)
482
+ padding: 8,
483
+ borderRadius: 4,
484
+ strokeColor: "#DDD",
485
+ strokeWidth: 1,
486
+ strokeType: "plain",
487
+ // Icon styling (collapsed mode)
488
+ iconColor: "#FFFACD",
489
+ // Gold
490
+ iconSymbol: "💬",
491
+ iconBorderColor: "#aaa",
492
+ iconBorderWidth: 1,
493
+ // Size properties
494
+ minHeight: 60,
495
+ maxHeight: 480,
496
+ iconSize: 32,
497
+ // collapseZoomThreshold is undefined by default, so it auto-calculates from dimensions
498
+ // Text styling
499
+ color: "#333",
500
+ font: "Arial, sans-serif",
501
+ fontSize: 12,
502
+ // Editing UI
503
+ showSendButton: !0,
504
+ autoGrow: !0,
505
+ // Visual effects
506
+ shadow: !0,
507
+ expandOnSelect: !1,
508
+ // Fixed size (always screen-aligned)
509
+ fixedSize: !0
510
+ }, N = {
511
+ mode: "expanded",
512
+ width: 200,
513
+ height: 60,
514
+ // Initial height, will auto-grow
515
+ style: m
516
+ };
517
+ function rt(t, e, r, n) {
518
+ const s = {
519
+ type: "comment",
520
+ content: r,
521
+ mode: (n == null ? void 0 : n.mode) ?? N.mode,
522
+ width: (n == null ? void 0 : n.width) ?? N.width,
523
+ height: (n == null ? void 0 : n.height) ?? N.height,
524
+ author: n == null ? void 0 : n.author,
525
+ timestamp: n == null ? void 0 : n.timestamp,
526
+ style: {
527
+ ...m,
528
+ ...n == null ? void 0 : n.style
529
+ }
530
+ };
531
+ return {
532
+ id: g(),
533
+ type: "Feature",
534
+ properties: s,
535
+ geometry: {
536
+ type: "Point",
537
+ coordinates: [t, e]
538
+ }
539
+ };
540
+ }
541
+ function ce(t) {
542
+ return {
543
+ ...t,
544
+ properties: {
545
+ ...t.properties,
546
+ mode: t.properties.mode === T ? B : T
547
+ }
548
+ };
549
+ }
550
+ function de(t, e, r = 0, n, s, o = 1) {
551
+ if (t.properties.mode !== T)
552
+ return et(
553
+ t,
554
+ e,
555
+ r,
556
+ n,
557
+ s,
558
+ o
559
+ );
560
+ const i = t.properties, a = { ...m, ...i.style };
561
+ let c = a.iconSize, d = a.iconSize;
562
+ a.fixedSize && (c /= o, d /= o);
563
+ const u = c / 2, y = d / 2, l = e.x - t.geometry.coordinates[0], f = e.y - t.geometry.coordinates[1];
564
+ return l >= -u - r && l <= u + r && f >= -y - r && f <= y + r;
565
+ }
566
+ function ue(t) {
567
+ const [e, r] = t.geometry.coordinates;
568
+ return { x: e, y: r };
569
+ }
570
+ function ye(t) {
571
+ const e = t.properties, r = { ...m, ...e.style };
572
+ return e.mode === T ? { width: r.iconSize, height: r.iconSize } : { width: e.width, height: e.height };
573
+ }
574
+ function nt(t, e = 80) {
575
+ const r = e / t.properties.width;
576
+ return Math.max(0.1, Math.min(1, r));
577
+ }
578
+ function le(t) {
579
+ const e = { ...m, ...t.properties.style };
580
+ return e.collapseZoomThreshold !== void 0 ? e.collapseZoomThreshold : nt(t);
581
+ }
582
+ function fe(t, e, r, n, s = "", o) {
583
+ const i = rt(
584
+ r,
585
+ n,
586
+ s,
587
+ o == null ? void 0 : o.commentStyle
588
+ ), a = {
589
+ ...E,
590
+ head: "arrow",
591
+ // Default to arrow head
592
+ ...o == null ? void 0 : o.arrowStyle
593
+ }, c = tt(r, n, t, e, a);
594
+ return c.properties.link = {
595
+ [w]: {
596
+ id: i.id,
597
+ side: w,
598
+ type: "comment",
599
+ magnet: { x: 0, y: 0 }
600
+ }
601
+ }, { comment: i, arrow: c };
602
+ }
603
+ function ge(t, e, r, n, s, o, i, a, c) {
604
+ const d = t - i, u = e - a, y = i + d * o - u * s, l = a + d * s + u * o, f = i + (d + r) * o - u * s, h = a + (d + r) * s + u * o, p = i + (d + r) * o - (u + n) * s, x = a + (d + r) * s + (u + n) * o, A = i + d * o - (u + n) * s, _ = a + d * s + (u + n) * o;
605
+ return c[0] = Math.min(y, f, p, A), c[1] = Math.min(l, h, x, _), c[2] = Math.max(y, f, p, A), c[3] = Math.max(l, h, x, _), c;
606
+ }
607
+ function st(t, e, r) {
608
+ const n = r.x - e.x, s = r.y - e.y, o = n * n + s * s;
609
+ if (o === 0) {
610
+ const y = t.x - e.x, l = t.y - e.y;
611
+ return Math.sqrt(y * y + l * l);
612
+ }
613
+ let i = ((t.x - e.x) * n + (t.y - e.y) * s) / o;
614
+ i = Math.max(0, Math.min(1, i));
615
+ const a = e.x + i * n, c = e.y + i * s, d = t.x - a, u = t.y - c;
616
+ return Math.sqrt(d * d + u * u);
617
+ }
618
+ const he = (t) => t.properties.type === "polygon";
619
+ function pe(t, e, r = 0) {
620
+ const n = t.geometry.coordinates[0], s = t.geometry.bbox;
621
+ if (s) {
622
+ const [i, a, c, d] = s;
623
+ if (e.x < i - r || e.x > c + r || e.y < a - r || e.y > d + r)
624
+ return !1;
625
+ }
626
+ let o = !1;
627
+ for (let i = 0, a = n.length - 1; i < n.length; a = i++) {
628
+ const c = n[i][0], d = n[i][1], u = n[a][0], y = n[a][1];
629
+ d > e.y != y > e.y && e.x < (u - c) * (e.y - d) / (y - d) + c && (o = !o);
630
+ }
631
+ if (o) return !0;
632
+ if (r > 0)
633
+ for (let i = 0; i < n.length - 1; i++) {
634
+ const [a, c] = n[i], [d, u] = n[i + 1];
635
+ if (st(e, { x: a, y: c }, { x: d, y: u }) <= r) return !0;
636
+ }
637
+ return !1;
638
+ }
639
+ function xe(t, e) {
640
+ const r = t[0];
641
+ r.length > 0 && (r[0][0] !== r[r.length - 1][0] || r[0][1] !== r[r.length - 1][1]) && r.push([r[0][0], r[0][1]]);
642
+ let n = 1 / 0, s = 1 / 0, o = -1 / 0, i = -1 / 0;
643
+ for (const [y, l] of r)
644
+ y < n && (n = y), y > o && (o = y), l < s && (s = l), l > i && (i = l);
645
+ const a = [n, s, o, i], { id: c, style: d, ...u } = e || {};
646
+ return {
647
+ type: "Feature",
648
+ id: c || g(),
649
+ geometry: {
650
+ type: "Polygon",
651
+ coordinates: t,
652
+ bbox: a
653
+ },
654
+ properties: {
655
+ type: "polygon",
656
+ style: {
657
+ ...k,
658
+ ...d
659
+ },
660
+ ...u
661
+ }
662
+ };
663
+ }
664
+ const k = {
665
+ ...I,
666
+ strokeColor: "#000000",
667
+ strokeWidth: 2,
668
+ background: "transparent"
669
+ }, me = {
670
+ type: "polygon",
671
+ style: {
672
+ ...k
673
+ }
674
+ };
675
+ export {
676
+ X as $,
677
+ pe as A,
678
+ H as B,
679
+ T as C,
680
+ xt as D,
681
+ at as E,
682
+ m as F,
683
+ C as G,
684
+ D as H,
685
+ Mt as I,
686
+ J,
687
+ It as K,
688
+ St as L,
689
+ Jt as M,
690
+ g as N,
691
+ Xt as O,
692
+ Qt as P,
693
+ P as Q,
694
+ ye as R,
695
+ w as S,
696
+ At as T,
697
+ L as U,
698
+ re as V,
699
+ de as W,
700
+ et as X,
701
+ S as Y,
702
+ Y as Z,
703
+ W as _,
704
+ B as a,
705
+ U as a0,
706
+ R as a1,
707
+ Kt as a2,
708
+ Rt as a3,
709
+ jt as a4,
710
+ I as a5,
711
+ qt as a6,
712
+ k as a7,
713
+ Pt as a8,
714
+ _t as a9,
715
+ Bt as aA,
716
+ ue as aB,
717
+ le as aC,
718
+ b as aD,
719
+ Ot as aE,
720
+ M as aF,
721
+ Z as aG,
722
+ Ht as aH,
723
+ K as aI,
724
+ kt as aJ,
725
+ v as aK,
726
+ $ as aL,
727
+ Dt as aM,
728
+ ce as aN,
729
+ ge as aa,
730
+ bt as ab,
731
+ wt as ac,
732
+ ut as ad,
733
+ yt as ae,
734
+ mt as af,
735
+ gt as ag,
736
+ pt as ah,
737
+ Tt as ai,
738
+ lt as aj,
739
+ ft as ak,
740
+ z as al,
741
+ ot as am,
742
+ F as an,
743
+ nt as ao,
744
+ Yt as ap,
745
+ fe as aq,
746
+ Zt as ar,
747
+ $t as as,
748
+ vt as at,
749
+ ee as au,
750
+ ne as av,
751
+ N as aw,
752
+ me as ax,
753
+ oe as ay,
754
+ Vt as az,
755
+ ct as b,
756
+ Ct as c,
757
+ it as d,
758
+ Gt as e,
759
+ tt as f,
760
+ Wt as g,
761
+ E as h,
762
+ ae as i,
763
+ j,
764
+ Nt as k,
765
+ dt as l,
766
+ ie as m,
767
+ se as n,
768
+ xe as o,
769
+ rt as p,
770
+ ht as q,
771
+ Ut as r,
772
+ V as s,
773
+ O as t,
774
+ zt as u,
775
+ he as v,
776
+ te as w,
777
+ Ft as x,
778
+ Lt as y,
779
+ Et as z
780
+ };