@linkurious/ogma-annotations 2.1.1 → 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.
@@ -1,8 +1,8 @@
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 = {
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
2
  SHAPES: 1,
3
3
  EDITOR: 2,
4
4
  HANDLES: 3
5
- }, w = "start", Nt = "end", Ct = {
5
+ }, T = "start", Ct = "end", Mt = {
6
6
  default: "default",
7
7
  move: "move",
8
8
  pointer: "pointer",
@@ -21,7 +21,7 @@ const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click",
21
21
  eResize: "e-resize",
22
22
  sResize: "s-resize",
23
23
  wResize: "w-resize"
24
- }, T = "collapsed", B = "expanded", Mt = 1.2, z = 0.2, At = {
24
+ }, w = "collapsed", B = "expanded", Nt = 1.2, z = 0.2, At = {
25
25
  TEXT: "text",
26
26
  NODE: "node",
27
27
  BOX: "box",
@@ -35,11 +35,14 @@ const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click",
35
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
36
  </svg>
37
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), "");
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
39
  const G = "http://www.w3.org/2000/svg";
40
40
  function Rt(t) {
41
41
  return document.createElementNS(G, t);
42
42
  }
43
+ function zt(t, e) {
44
+ t.appendChild(e);
45
+ }
43
46
  function S(t) {
44
47
  return t.geometry.bbox || H(t), t.geometry.bbox;
45
48
  }
@@ -55,19 +58,19 @@ function D(t) {
55
58
  height: e[3] - e[1]
56
59
  };
57
60
  }
58
- function Y(t, e = !1, r = 1) {
61
+ function Y(t, e = !1, n = 1) {
59
62
  if (t.geometry.type === "Point" && "width" in t.properties && "height" in t.properties) {
60
63
  const [s, o] = t.geometry.coordinates;
61
64
  let i = t.properties.width, a = t.properties.height;
62
- return e && (i /= r, a /= r), {
65
+ return e && (i /= n, a /= n), {
63
66
  x: s - i / 2,
64
67
  y: o - a / 2
65
68
  };
66
69
  }
67
- const n = S(t);
68
- return { x: n[0], y: n[1] };
70
+ const r = S(t);
71
+ return { x: r[0], y: r[1] };
69
72
  }
70
- function zt(t) {
73
+ function Dt(t) {
71
74
  if (t.geometry.type === "Point")
72
75
  return { x: t.geometry.coordinates[0], y: t.geometry.coordinates[1] };
73
76
  const e = S(t);
@@ -75,57 +78,57 @@ function zt(t) {
75
78
  }
76
79
  function H(t) {
77
80
  if (j(t)) {
78
- const [e, r] = t.geometry.coordinates[0], [n, s] = t.geometry.coordinates[1];
81
+ const [e, n] = t.geometry.coordinates[0], [r, s] = t.geometry.coordinates[1];
79
82
  t.geometry.bbox = [
80
- Math.min(e, n),
81
- Math.min(r, s),
82
- Math.max(e, n),
83
- Math.max(r, s)
83
+ Math.min(e, r),
84
+ Math.min(n, s),
85
+ Math.max(e, r),
86
+ Math.max(n, s)
84
87
  ];
85
88
  } 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];
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];
88
91
  } else if (t.geometry.type === "Polygon") {
89
92
  const e = t.geometry.coordinates[0];
90
- let r = Number.POSITIVE_INFINITY, n = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
93
+ let n = Number.POSITIVE_INFINITY, r = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
91
94
  for (const i of e) {
92
95
  const a = i[0], c = i[1];
93
- a < r && (r = a), c < n && (n = c), a > s && (s = a), c > o && (o = c);
96
+ a < n && (n = a), c < r && (r = c), a > s && (s = a), c > o && (o = c);
94
97
  }
95
- t.geometry.bbox = [r, n, s, o];
98
+ t.geometry.bbox = [n, r, s, o];
96
99
  }
97
100
  }
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;
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;
100
103
  }
101
104
  function W(t) {
102
- const [e, r] = t.geometry.coordinates[0];
103
- return { x: e, y: r };
105
+ const [e, n] = t.geometry.coordinates[0];
106
+ return { x: e, y: n };
104
107
  }
105
108
  function Ft(t, e) {
106
- const [r, n] = t.geometry.coordinates[e === w ? 0 : 1];
107
- return { x: r, y: n };
109
+ const [n, r] = t.geometry.coordinates[e === T ? 0 : 1];
110
+ return { x: n, y: r };
108
111
  }
109
112
  function X(t) {
110
- const [e, r] = t.geometry.coordinates[1];
111
- return { x: e, y: r };
113
+ const [e, n] = t.geometry.coordinates[1];
114
+ return { x: e, y: n };
112
115
  }
113
- function $(t, e, r) {
114
- t.geometry.coordinates[0] = [e, r];
116
+ function $(t, e, n) {
117
+ t.geometry.coordinates[0] = [e, n];
115
118
  }
116
- function v(t, e, r) {
117
- t.geometry.coordinates[1] = [e, r];
119
+ function v(t, e, n) {
120
+ t.geometry.coordinates[1] = [e, n];
118
121
  }
119
122
  function U(t) {
120
123
  return { start: W(t), end: X(t) };
121
124
  }
122
- function Lt(t, e, r, n) {
123
- e === w ? $(t, r, n) : v(t, r, n);
125
+ function Lt(t, e, n, r) {
126
+ e === T ? $(t, n, r) : v(t, n, r);
124
127
  }
125
- const Ot = (t) => parseInt(t.getAttribute("data-handle-id") || "-1");
126
- function Vt(t) {
128
+ const Vt = (t) => parseInt(t.getAttribute("data-handle-id") || "-1");
129
+ function kt(t) {
127
130
  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),
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),
129
132
  [
130
133
  Number.POSITIVE_INFINITY,
131
134
  Number.POSITIVE_INFINITY,
@@ -137,15 +140,15 @@ function Vt(t) {
137
140
  function q(t) {
138
141
  return Array.isArray(t) && t.length === 2 && t.every(isFinite);
139
142
  }
140
- function kt(t, e, r, n) {
143
+ function Bt(t, e, n, r) {
141
144
  for (let s = 0; s < t.coordinates.length; s++) {
142
145
  const o = t.coordinates[s];
143
146
  if (q(o))
144
- o[0] = r + (o[0] - r) * e, o[1] = n + (o[1] - n) * e;
147
+ o[0] = n + (o[0] - n) * e, o[1] = r + (o[1] - r) * e;
145
148
  else
146
149
  for (let i = 0; i < o.length; i++) {
147
150
  const a = o[i];
148
- a[0] = r + (a[0] - r) * e, a[1] = n + (a[1] - n) * e;
151
+ a[0] = n + (a[0] - n) * e, a[1] = r + (a[1] - r) * e;
149
152
  }
150
153
  }
151
154
  return t;
@@ -160,53 +163,53 @@ function b(t) {
160
163
  else if (t.type == "LineString" || t.type == "MultiPoint")
161
164
  e = t.coordinates;
162
165
  else if (t.type == "Polygon" || t.type == "MultiLineString")
163
- e = t.coordinates.reduce(function(r, n) {
164
- return r.concat(n);
166
+ e = t.coordinates.reduce(function(n, r) {
167
+ return n.concat(r);
165
168
  }, []);
166
169
  else if (t.type == "MultiPolygon")
167
170
  e = t.coordinates.reduce(
168
- (r, n) => r.concat(n.reduce((s, o) => s.concat(o), [])),
171
+ (n, r) => n.concat(r.reduce((s, o) => s.concat(o), [])),
169
172
  []
170
173
  );
171
174
  else if (t.type == "Feature")
172
- if (V(t) || O(t)) {
173
- const r = S(t);
175
+ if (V(t) || L(t)) {
176
+ const n = S(t);
174
177
  e = [
175
- [r[0], r[1]],
176
- [r[2], r[3]]
178
+ [n[0], n[1]],
179
+ [n[2], n[3]]
177
180
  ];
178
181
  } else e = b(t.geometry);
179
182
  else t.type == "GeometryCollection" ? e = t.geometries.reduce(
180
- (r, n) => r.concat(b(n)),
183
+ (n, r) => n.concat(b(r)),
181
184
  []
182
185
  ) : t.type == "FeatureCollection" && (e = t.features.reduce(
183
- (r, n) => r.concat(b(n)),
186
+ (n, r) => n.concat(b(r)),
184
187
  []
185
188
  ));
186
189
  return e;
187
190
  }
188
- function Bt(t, e, r) {
189
- const n = Math.atan2(t.y - e.y, t.x - e.x);
191
+ function Gt(t, e, n) {
192
+ const r = Math.atan2(t.y - e.y, t.x - e.x);
190
193
  return {
191
- x: e.x + r * Math.cos(n),
192
- y: e.y + r * Math.sin(n)
194
+ x: e.x + n * Math.cos(r),
195
+ y: e.y + n * Math.sin(r)
193
196
  };
194
197
  }
195
- function Gt(t, e) {
198
+ function Yt(t, e) {
196
199
  if (!e) return { x: t.clientX, y: t.clientY };
197
- const r = e.getBoundingClientRect();
200
+ const n = e.getBoundingClientRect();
198
201
  return {
199
- x: t.clientX - r.left - e.clientLeft,
200
- y: t.clientY - r.top - e.clientTop
202
+ x: t.clientX - n.left - e.clientLeft,
203
+ y: t.clientY - n.top - e.clientTop
201
204
  };
202
205
  }
203
- function Yt(t, e) {
206
+ function Ht(t, e) {
204
207
  return t.startsWith("#") ? Z(t, e) : t.startsWith("rgb") ? K(t, e) : t;
205
208
  }
206
- function Ht(t) {
209
+ function Wt(t) {
207
210
  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 };
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 };
210
213
  } else {
211
214
  const e = t.match(
212
215
  /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/
@@ -220,62 +223,62 @@ function Ht(t) {
220
223
  };
221
224
  }
222
225
  }
223
- function M(t) {
226
+ function N(t) {
224
227
  return t.length === 4 ? t.split("").map((e) => e + e).join("") : t;
225
228
  }
226
229
  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})`;
230
+ const [n, r, s] = N(t).match(/\w\w/g).map((o) => parseInt(o, 16));
231
+ return `rgba(${n}, ${r}, ${s}, ${e})`;
229
232
  }
230
233
  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})`;
234
+ const [n, r, s] = t.match(/\d+/g).map((o) => parseInt(o, 10));
235
+ return `rgba(${n}, ${r}, ${s}, ${e})`;
233
236
  }
234
- function Wt() {
237
+ function Xt() {
235
238
  return typeof window < "u" ? window : void 0;
236
239
  }
237
- const Xt = (t, e = 16, r = !1) => {
238
- let n = !1, s = null;
240
+ const $t = (t, e = 16, n = !1) => {
241
+ let r = !1, s = null;
239
242
  const o = Math.max(1, Math.round(e * 60 / 1e3)), i = (a) => {
240
243
  requestAnimationFrame(() => {
241
244
  if (a > 1)
242
245
  i(a - 1);
243
- else if (n = !1, r && s !== null) {
246
+ else if (r = !1, n && s !== null) {
244
247
  const c = s;
245
- s = null, t(...c), n = !0, i(o);
248
+ s = null, t(...c), r = !0, i(o);
246
249
  }
247
250
  });
248
251
  };
249
252
  return (...a) => {
250
- if (n) {
251
- r && (s = a);
253
+ if (r) {
254
+ n && (s = a);
252
255
  return;
253
256
  }
254
- t(...a), n = !0, i(o);
257
+ t(...a), r = !0, i(o);
255
258
  };
256
- }, $t = (t, e) => {
257
- let r;
259
+ }, vt = (t, e) => {
260
+ let n;
258
261
  return (...s) => {
259
- clearTimeout(r), r = setTimeout(() => t(...s), e);
262
+ clearTimeout(n), n = setTimeout(() => t(...s), e);
260
263
  };
261
264
  };
262
- function vt(t, e) {
263
- let r;
264
- return function(...n) {
265
- clearTimeout(r), r = setTimeout(() => {
266
- t.apply(this, n);
265
+ function Ut(t, e) {
266
+ let n;
267
+ return function(...r) {
268
+ clearTimeout(n), n = setTimeout(() => {
269
+ t.apply(this, r);
267
270
  }, e);
268
271
  };
269
272
  }
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
+ 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;
273
276
  return {
274
277
  ...t,
275
278
  geometry: {
276
279
  type: "Point",
277
280
  coordinates: [c, d],
278
- bbox: [r, n, s, o]
281
+ bbox: [n, r, s, o]
279
282
  },
280
283
  properties: {
281
284
  ...t.properties,
@@ -286,51 +289,51 @@ function Ut(t) {
286
289
  }
287
290
  return t;
288
291
  }
289
- function F(t, e) {
290
- let r, n, s, o = 1;
292
+ function O(t, e) {
293
+ let n, r, s, o = 1;
291
294
  const i = t.trim();
292
295
  if (i.startsWith("#")) {
293
- const y = (i.length === 4 ? M(i) : i).match(/#?(\w{2})(\w{2})(\w{2})/);
296
+ const y = (i.length === 4 ? N(i) : i).match(/#?(\w{2})(\w{2})(\w{2})/);
294
297
  if (!y) return t;
295
- r = parseInt(y[1], 16), n = parseInt(y[2], 16), s = parseInt(y[3], 16);
298
+ n = parseInt(y[1], 16), r = parseInt(y[2], 16), s = parseInt(y[3], 16);
296
299
  } else {
297
300
  const u = i.match(
298
301
  /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/
299
302
  );
300
303
  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;
304
+ n = parseInt(u[1]), r = parseInt(u[2]), s = parseInt(u[3]), o = u[4] !== void 0 ? parseFloat(u[4]) : 1;
302
305
  }
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})`;
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})`;
305
308
  }
306
- const qt = (t) => F(t, z), Zt = (t) => F(t, -z), P = (t, e) => ({
309
+ const Zt = (t) => O(t, z), Kt = (t) => O(t, -z), P = (t, e) => ({
307
310
  x: t.x - e.x,
308
311
  y: t.y - e.y
309
- }), L = (t) => Math.sqrt(t.x * t.x + t.y * t.y), Kt = (t) => ({
312
+ }), F = (t) => Math.sqrt(t.x * t.x + t.y * t.y), Jt = (t) => ({
310
313
  x: -t.x,
311
314
  y: -t.y
312
315
  }), R = (t) => {
313
- const e = L(t);
316
+ const e = F(t);
314
317
  return e === 0 ? { x: 0, y: 0 } : {
315
318
  x: t.x / e,
316
319
  y: t.y / e
317
320
  };
318
- }, Jt = (t, e) => ({
321
+ }, Qt = (t, e) => ({
319
322
  x: t.x + e.x,
320
323
  y: t.y + e.y
321
- }), Qt = (t, e) => ({
324
+ }), jt = (t, e) => ({
322
325
  x: t.x * e,
323
326
  y: t.y * e
324
- }), jt = (t, e) => {
325
- const r = Math.sin(e), n = Math.cos(e);
327
+ }), te = (t, e) => {
328
+ const n = Math.sin(e), r = Math.cos(e);
326
329
  return {
327
- x: t.x * n - t.y * r,
328
- y: t.x * r + t.y * n
330
+ x: t.x * r - t.y * n,
331
+ y: t.x * n + t.y * r
329
332
  };
330
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";
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
+ 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;
334
337
  }
335
338
  const E = {
336
339
  strokeType: "plain",
@@ -338,7 +341,7 @@ const E = {
338
341
  strokeWidth: 1,
339
342
  head: "none",
340
343
  tail: "none"
341
- }, ee = {
344
+ }, ne = {
342
345
  id: void 0,
343
346
  // will be set by the editor
344
347
  type: "Feature",
@@ -365,7 +368,7 @@ const E = {
365
368
  // tail: 'arrow-plain',
366
369
  // start: { x: 0, y: 0 },
367
370
  // end: { x: 100, y: 100 }
368
- }, tt = (t = 0, e = 0, r = 0, n = 0, s = { ...E }) => ({
371
+ }, tt = (t = 0, e = 0, n = 0, r = 0, s = { ...E }) => ({
369
372
  id: g(),
370
373
  type: "Feature",
371
374
  properties: {
@@ -379,12 +382,12 @@ const E = {
379
382
  type: "LineString",
380
383
  coordinates: [
381
384
  [t, e],
382
- [r, n]
385
+ [n, r]
383
386
  ]
384
387
  }
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
+ }), 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;
388
391
  return u > -s && u < i + s && y > -s && y < a + s;
389
392
  }
390
393
  const I = {
@@ -394,7 +397,7 @@ const I = {
394
397
  boxShadow: "",
395
398
  padding: 16,
396
399
  strokeType: "plain"
397
- }, ne = {
400
+ }, se = {
398
401
  id: void 0,
399
402
  // will be set by the editor
400
403
  type: "Feature",
@@ -410,21 +413,21 @@ const I = {
410
413
  // center of 100x50 box
411
414
  bbox: [0, 0, 100, 50]
412
415
  }
413
- }, se = (t = 0, e = 0, r = 100, n = 50, s = { ...I }) => ({
416
+ }, oe = (t = 0, e = 0, n = 100, r = 50, s = { ...I }) => ({
414
417
  id: g(),
415
418
  type: "Feature",
416
419
  properties: {
417
420
  type: "box",
418
- width: r,
419
- height: n,
421
+ width: n,
422
+ height: r,
420
423
  style: { ...I, ...s }
421
424
  },
422
425
  geometry: {
423
426
  type: "Point",
424
- coordinates: [t + r / 2, e + n / 2]
427
+ coordinates: [t + n / 2, e + r / 2]
425
428
  // center
426
429
  }
427
- }), V = (t) => t.properties.type === "text", C = {
430
+ }), V = (t) => t.properties.type === "text", M = {
428
431
  font: "sans-serif",
429
432
  fontSize: 18,
430
433
  color: "#505050",
@@ -434,7 +437,7 @@ const I = {
434
437
  padding: 16,
435
438
  strokeType: "plain",
436
439
  fixedSize: !1
437
- }, oe = {
440
+ }, ie = {
438
441
  id: g(),
439
442
  type: "Feature",
440
443
  properties: {
@@ -442,7 +445,7 @@ const I = {
442
445
  content: "",
443
446
  width: 100,
444
447
  height: 50,
445
- style: { ...C }
448
+ style: { ...M }
446
449
  },
447
450
  geometry: {
448
451
  type: "Point",
@@ -450,32 +453,32 @@ const I = {
450
453
  // center of 100x50 box
451
454
  bbox: [0, 0, 100, 50]
452
455
  }
453
- }, ie = (t = 0, e = 0, r = 100, n = 50, s = "", o = { ...C }) => ({
456
+ }, ae = (t = 0, e = 0, n = 100, r = 50, s = "", o = { ...M }) => ({
454
457
  id: g(),
455
458
  type: "Feature",
456
459
  properties: {
457
460
  type: "text",
458
461
  content: s,
459
- width: r,
460
- height: n,
461
- style: { ...C, ...o }
462
+ width: n,
463
+ height: r,
464
+ style: { ...M, ...o }
462
465
  },
463
466
  geometry: {
464
467
  type: "Point",
465
- coordinates: [t + r / 2, e + n / 2],
468
+ coordinates: [t + n / 2, e + r / 2],
466
469
  // center
467
- bbox: [t, e, t + r, e + n]
470
+ bbox: [t, e, t + n, e + r]
468
471
  }
469
472
  });
470
- function et(t, e, r = 0, n = 0, s = 1, o = 1) {
471
- var x;
473
+ function et(t, e, n = 0, r = 0, s = 1, o = 1) {
474
+ var m;
472
475
  const [i, a] = t.geometry.coordinates;
473
476
  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
+ (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;
477
480
  }
478
- const ae = (t) => t.properties.type === "comment", m = {
481
+ const ce = (t) => t.properties.type === "comment", p = {
479
482
  // Box styling
480
483
  background: "#FFFACD",
481
484
  // Light yellow (sticky note color)
@@ -506,26 +509,28 @@ const ae = (t) => t.properties.type === "comment", m = {
506
509
  shadow: !0,
507
510
  expandOnSelect: !1,
508
511
  // Fixed size (always screen-aligned)
509
- fixedSize: !0
510
- }, N = {
512
+ fixedSize: !0,
513
+ // Connector line behavior
514
+ connectorMode: "rigid"
515
+ }, C = {
511
516
  mode: "expanded",
512
517
  width: 200,
513
518
  height: 60,
514
519
  // Initial height, will auto-grow
515
- style: m
520
+ style: p
516
521
  };
517
- function rt(t, e, r, n) {
522
+ function nt(t, e, n, r) {
518
523
  const s = {
519
524
  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,
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,
526
531
  style: {
527
- ...m,
528
- ...n == null ? void 0 : n.style
532
+ ...p,
533
+ ...r == null ? void 0 : r.style
529
534
  }
530
535
  };
531
536
  return {
@@ -538,51 +543,54 @@ function rt(t, e, r, n) {
538
543
  }
539
544
  };
540
545
  }
541
- function ce(t) {
546
+ function de(t) {
542
547
  return {
543
548
  ...t,
544
549
  properties: {
545
550
  ...t.properties,
546
- mode: t.properties.mode === T ? B : T
551
+ mode: t.properties.mode === w ? B : w
547
552
  }
548
553
  };
549
554
  }
550
- function de(t, e, r = 0, n, s, o = 1) {
551
- if (t.properties.mode !== T)
555
+ function ue(t, e, n = 0, r, s, o = 1) {
556
+ if (t.properties.mode !== w)
552
557
  return et(
553
558
  t,
554
559
  e,
555
- r,
556
560
  n,
561
+ r,
557
562
  s,
558
563
  o
559
564
  );
560
- const i = t.properties, a = { ...m, ...i.style };
565
+ const i = t.properties, a = { ...p, ...i.style };
561
566
  let c = a.iconSize, d = a.iconSize;
562
567
  a.fixedSize && (c /= o, d /= o);
563
568
  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
+ return l >= -u - n && l <= u + n && f >= -y - n && f <= y + n;
569
570
  }
570
571
  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));
572
+ const [e, n] = t.geometry.coordinates;
573
+ return { x: e, y: n };
577
574
  }
578
575
  function le(t) {
579
- const e = { ...m, ...t.properties.style };
580
- return e.collapseZoomThreshold !== void 0 ? e.collapseZoomThreshold : nt(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 };
581
578
  }
582
- function fe(t, e, r, n, s = "", o) {
583
- const i = rt(
584
- r,
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(
585
592
  n,
593
+ r,
586
594
  s,
587
595
  o == null ? void 0 : o.commentStyle
588
596
  ), a = {
@@ -590,59 +598,59 @@ function fe(t, e, r, n, s = "", o) {
590
598
  head: "arrow",
591
599
  // Default to arrow head
592
600
  ...o == null ? void 0 : o.arrowStyle
593
- }, c = tt(r, n, t, e, a);
601
+ }, c = tt(n, r, t, e, a);
594
602
  return c.properties.link = {
595
- [w]: {
603
+ [T]: {
596
604
  id: i.id,
597
- side: w,
605
+ side: T,
598
606
  type: "comment",
599
607
  magnet: { x: 0, y: 0 }
600
608
  }
601
609
  }, { comment: i, arrow: c };
602
610
  }
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;
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;
606
614
  }
607
- function st(t, e, r) {
608
- const n = r.x - e.x, s = r.y - e.y, o = n * n + s * s;
615
+ function st(t, e, n) {
616
+ const r = n.x - e.x, s = n.y - e.y, o = r * r + s * s;
609
617
  if (o === 0) {
610
618
  const y = t.x - e.x, l = t.y - e.y;
611
619
  return Math.sqrt(y * y + l * l);
612
620
  }
613
- let i = ((t.x - e.x) * n + (t.y - e.y) * s) / o;
621
+ let i = ((t.x - e.x) * r + (t.y - e.y) * s) / o;
614
622
  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;
623
+ const a = e.x + i * r, c = e.y + i * s, d = t.x - a, u = t.y - c;
616
624
  return Math.sqrt(d * d + u * u);
617
625
  }
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;
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;
621
629
  if (s) {
622
630
  const [i, a, c, d] = s;
623
- if (e.x < i - r || e.x > c + r || e.y < a - r || e.y > d + r)
631
+ if (e.x < i - n || e.x > c + n || e.y < a - n || e.y > d + n)
624
632
  return !1;
625
633
  }
626
634
  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];
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];
629
637
  d > e.y != y > e.y && e.x < (u - c) * (e.y - d) / (y - d) + c && (o = !o);
630
638
  }
631
639
  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;
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;
636
644
  }
637
645
  return !1;
638
646
  }
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 || {};
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 || {};
646
654
  return {
647
655
  type: "Feature",
648
656
  id: c || g(),
@@ -666,114 +674,116 @@ const k = {
666
674
  strokeColor: "#000000",
667
675
  strokeWidth: 2,
668
676
  background: "transparent"
669
- }, me = {
677
+ }, Te = {
670
678
  type: "polygon",
671
679
  style: {
672
680
  ...k
673
681
  }
674
682
  };
675
683
  export {
676
- X as $,
677
- pe as A,
684
+ Y as $,
685
+ me as A,
678
686
  H as B,
679
- T as C,
687
+ w as C,
680
688
  xt as D,
681
689
  at as E,
682
- m as F,
683
- C as G,
690
+ p as F,
691
+ M as G,
684
692
  D as H,
685
- Mt as I,
693
+ Nt as I,
686
694
  J,
687
695
  It as K,
688
696
  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,
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,
696
704
  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 _,
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 _,
704
712
  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,
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,
755
765
  ct as b,
756
- Ct as c,
766
+ Mt as c,
757
767
  it as d,
758
- Gt as e,
768
+ Yt as e,
759
769
  tt as f,
760
- Wt as g,
770
+ Xt as g,
761
771
  E as h,
762
- ae as i,
772
+ ce as i,
763
773
  j,
764
- Nt as k,
774
+ Ct as k,
765
775
  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,
776
+ ae as m,
777
+ oe as n,
778
+ be as o,
779
+ nt as p,
780
+ pt as q,
781
+ qt as r,
772
782
  V as s,
773
- O as t,
774
- zt as u,
775
- he as v,
776
- te as w,
783
+ L as t,
784
+ Dt as u,
785
+ xe as v,
786
+ ee as w,
777
787
  Ft as x,
778
788
  Lt as y,
779
789
  Et as z