@linkurious/ogma-annotations 2.1.0 → 2.1.2

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