@linkurious/ogma-annotations 2.1.1 → 2.1.3

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