@linkurious/ogma-annotations-react 1.1.25 → 1.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -8
- package/dist/index.mjs +561 -555
- package/dist/types/index.d.ts +2 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Wr, { createContext as Ye, useContext as Ur, useReducer as Xr, useState as Et, useEffect as he } from "react";
|
|
2
2
|
import { useOgma as Gr } from "@linkurious/ogma-react";
|
|
3
|
-
var Vr = Object.defineProperty, Zr = (l, t,
|
|
4
|
-
let Jt = (l = 21) => crypto.getRandomValues(new Uint8Array(l)).reduce((t,
|
|
3
|
+
var Vr = Object.defineProperty, Zr = (l, t, i) => t in l ? Vr(l, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : l[t] = i, m = (l, t, i) => Zr(l, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
let Jt = (l = 21) => crypto.getRandomValues(new Uint8Array(l)).reduce((t, i) => (i &= 63, i < 36 ? t += i.toString(36) : i < 62 ? t += (i - 26).toString(36).toUpperCase() : i > 62 ? t += "-" : t += "_", t), "");
|
|
5
5
|
const Pt = {
|
|
6
6
|
strokeType: "plain",
|
|
7
7
|
strokeColor: "#202020",
|
|
@@ -34,7 +34,7 @@ const Pt = {
|
|
|
34
34
|
// tail: 'arrow-plain',
|
|
35
35
|
// start: { x: 0, y: 0 },
|
|
36
36
|
// end: { x: 100, y: 100 }
|
|
37
|
-
}, Yr = (l = 0, t = 0,
|
|
37
|
+
}, Yr = (l = 0, t = 0, i = 0, r = 0, a = { ...Pt }) => ({
|
|
38
38
|
id: Jt(),
|
|
39
39
|
type: "Feature",
|
|
40
40
|
properties: {
|
|
@@ -48,7 +48,7 @@ const Pt = {
|
|
|
48
48
|
type: "LineString",
|
|
49
49
|
coordinates: [
|
|
50
50
|
[l, t],
|
|
51
|
-
[
|
|
51
|
+
[i, r]
|
|
52
52
|
]
|
|
53
53
|
}
|
|
54
54
|
}), Jr = "http://www.w3.org/2000/svg";
|
|
@@ -70,74 +70,74 @@ function dt(l) {
|
|
|
70
70
|
return { x: t[0], y: t[1] };
|
|
71
71
|
}
|
|
72
72
|
function Kr(l) {
|
|
73
|
-
const [t,
|
|
74
|
-
l.geometry.bbox = [t,
|
|
73
|
+
const [t, i] = l.geometry.coordinates[0][0], [r, a] = l.geometry.coordinates[0][2];
|
|
74
|
+
l.geometry.bbox = [t, i, r, a];
|
|
75
75
|
}
|
|
76
|
-
function Qr(l, t,
|
|
77
|
-
l.geometry.bbox = [t,
|
|
76
|
+
function Qr(l, t, i, r, a) {
|
|
77
|
+
l.geometry.bbox = [t, i, t + r, i + a], l.geometry.coordinates = [
|
|
78
78
|
[
|
|
79
|
-
[t,
|
|
80
|
-
[t + r,
|
|
81
|
-
[t + r,
|
|
82
|
-
[t,
|
|
83
|
-
[t,
|
|
79
|
+
[t, i],
|
|
80
|
+
[t + r, i],
|
|
81
|
+
[t + r, i + a],
|
|
82
|
+
[t, i + a],
|
|
83
|
+
[t, i]
|
|
84
84
|
]
|
|
85
85
|
];
|
|
86
86
|
}
|
|
87
87
|
function zt(l) {
|
|
88
|
-
const [t,
|
|
89
|
-
return { x: t, y:
|
|
88
|
+
const [t, i] = l.geometry.coordinates[0];
|
|
89
|
+
return { x: t, y: i };
|
|
90
90
|
}
|
|
91
91
|
function Rt(l, t) {
|
|
92
|
-
const [
|
|
93
|
-
return { x:
|
|
92
|
+
const [i, r] = l.geometry.coordinates[t === "start" ? 0 : 1];
|
|
93
|
+
return { x: i, y: r };
|
|
94
94
|
}
|
|
95
95
|
function Xt(l) {
|
|
96
|
-
const [t,
|
|
97
|
-
return { x: t, y:
|
|
96
|
+
const [t, i] = l.geometry.coordinates[1];
|
|
97
|
+
return { x: t, y: i };
|
|
98
98
|
}
|
|
99
|
-
function Ke(l, t,
|
|
100
|
-
l.geometry.coordinates[0] = [t,
|
|
99
|
+
function Ke(l, t, i) {
|
|
100
|
+
l.geometry.coordinates[0] = [t, i];
|
|
101
101
|
}
|
|
102
|
-
function Qe(l, t,
|
|
103
|
-
l.geometry.coordinates[1] = [t,
|
|
102
|
+
function Qe(l, t, i) {
|
|
103
|
+
l.geometry.coordinates[1] = [t, i];
|
|
104
104
|
}
|
|
105
105
|
function Gt(l) {
|
|
106
106
|
return { start: zt(l), end: Xt(l) };
|
|
107
107
|
}
|
|
108
|
-
function St(l, t,
|
|
109
|
-
t === "start" ? Ke(l,
|
|
108
|
+
function St(l, t, i, r) {
|
|
109
|
+
t === "start" ? Ke(l, i, r) : Qe(l, i, r);
|
|
110
110
|
}
|
|
111
111
|
const tr = (l) => parseInt(l.getAttribute("data-handle-id") || "-1");
|
|
112
112
|
function tn(l) {
|
|
113
113
|
return Array.isArray(l) && l.length === 2 && l.every(isFinite);
|
|
114
114
|
}
|
|
115
|
-
function en(l, t,
|
|
115
|
+
function en(l, t, i, r) {
|
|
116
116
|
for (let a = 0; a < l.coordinates.length; a++) {
|
|
117
117
|
const h = l.coordinates[a];
|
|
118
118
|
if (tn(h))
|
|
119
|
-
h[0] =
|
|
119
|
+
h[0] = i + (h[0] - i) * t, h[1] = r + (h[1] - r) * t;
|
|
120
120
|
else
|
|
121
121
|
for (let c = 0; c < h.length; c++) {
|
|
122
|
-
const
|
|
123
|
-
|
|
122
|
+
const d = h[c];
|
|
123
|
+
d[0] = i + (d[0] - i) * t, d[1] = r + (d[1] - r) * t;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
return l;
|
|
127
127
|
}
|
|
128
|
-
function Wt(l, t,
|
|
128
|
+
function Wt(l, t, i) {
|
|
129
129
|
const r = Math.atan2(l.y - t.y, l.x - t.x);
|
|
130
130
|
return {
|
|
131
|
-
x: t.x +
|
|
132
|
-
y: t.y +
|
|
131
|
+
x: t.x + i * Math.cos(r),
|
|
132
|
+
y: t.y + i * Math.sin(r)
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
function Vt(l, t) {
|
|
136
136
|
if (!t) return { x: l.clientX, y: l.clientY };
|
|
137
|
-
const
|
|
137
|
+
const i = t.getBoundingClientRect();
|
|
138
138
|
return {
|
|
139
|
-
x: l.clientX -
|
|
140
|
-
y: l.clientY -
|
|
139
|
+
x: l.clientX - i.left - t.clientLeft,
|
|
140
|
+
y: l.clientY - i.top - t.clientTop
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
const xt = (l, t) => ({
|
|
@@ -162,54 +162,54 @@ const xt = (l, t) => ({
|
|
|
162
162
|
x: l.x * t.x,
|
|
163
163
|
y: l.y * t.y
|
|
164
164
|
}), nt = (l, t) => {
|
|
165
|
-
const
|
|
165
|
+
const i = Math.sin(t), r = Math.cos(t);
|
|
166
166
|
return {
|
|
167
|
-
x: l.x * r - l.y *
|
|
168
|
-
y: l.x *
|
|
167
|
+
x: l.x * r - l.y * i,
|
|
168
|
+
y: l.x * i + l.y * r
|
|
169
169
|
};
|
|
170
170
|
}, rn = (l, t) => ({
|
|
171
171
|
x: l.x / t,
|
|
172
172
|
y: l.y / t
|
|
173
173
|
}), Ie = (l, t) => l.x * t.x + l.y * t.y, nn = 0.5;
|
|
174
|
-
function ir(l, t = 5,
|
|
174
|
+
function ir(l, t = 5, i = 30) {
|
|
175
175
|
var r;
|
|
176
|
-
const { start: a, end: h } = Gt(l), c = xt(h, a),
|
|
177
|
-
return Math.min(
|
|
176
|
+
const { start: a, end: h } = Gt(l), c = xt(h, a), d = l.properties.style && l.properties.style.strokeWidth ? (r = l.properties.style) == null ? void 0 : r.strokeWidth : 0;
|
|
177
|
+
return Math.min(i, Math.max(3 * d, _t(c) * 0.01, t));
|
|
178
178
|
}
|
|
179
|
-
function Me(l, t,
|
|
179
|
+
function Me(l, t, i, r) {
|
|
180
180
|
const a = nr(er(rr(t)), r);
|
|
181
|
-
if (!
|
|
182
|
-
const h = Ct(l, nt(a, Math.PI / 10)), c = Ct(l, nt(a, -Math.PI / 10)),
|
|
183
|
-
return `M ${h.x} ${h.y} L ${
|
|
181
|
+
if (!i || i !== "arrow" && i !== "arrow-plain") return "";
|
|
182
|
+
const h = Ct(l, nt(a, Math.PI / 10)), c = Ct(l, nt(a, -Math.PI / 10)), d = `${l.x} ${l.y}`;
|
|
183
|
+
return `M ${h.x} ${h.y} L ${d} ${c.x} ${c.y} ${i === "arrow" ? "" : `${h.x} ${h.y}`}`;
|
|
184
184
|
}
|
|
185
|
-
function sn(l, t,
|
|
185
|
+
function sn(l, t, i, r, a) {
|
|
186
186
|
const { start: h, end: c } = Gt(l), {
|
|
187
|
-
tail:
|
|
188
|
-
head:
|
|
187
|
+
tail: d,
|
|
188
|
+
head: f,
|
|
189
189
|
strokeColor: g,
|
|
190
190
|
strokeWidth: p = 0
|
|
191
|
-
} = l.properties.style ||
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
E.setAttribute("stroke", L), E.setAttribute("stroke-width", `${p}`), E.setAttribute("fill",
|
|
195
|
-
const
|
|
196
|
-
E.setAttribute("d",
|
|
191
|
+
} = l.properties.style || i, w = xt(c, h), b = ir(l, r, a), A = wt("g"), E = wt("path");
|
|
192
|
+
A.setAttribute("data-annotation", `${l.id}`), A.setAttribute("data-annotation-type", "arrow");
|
|
193
|
+
const k = f === "arrow-plain" || d === "arrow", L = g || "none";
|
|
194
|
+
E.setAttribute("stroke", L), E.setAttribute("stroke-width", `${p}`), E.setAttribute("fill", k ? g || "" : "none"), E.setAttribute("stroke-linecap", "round"), E.setAttribute("stroke-linejoin", "round");
|
|
195
|
+
const M = Me(h, er(w), d, b), C = Me(c, w, f, b), N = M + `M ${h.x} ${h.y} ${c.x} ${c.y}` + C;
|
|
196
|
+
E.setAttribute("d", N), A.appendChild(E), Oe(A, h, L, d, p), Oe(A, c, L, f, p), t.appendChild(A);
|
|
197
197
|
}
|
|
198
|
-
function Oe(l, t,
|
|
198
|
+
function Oe(l, t, i, r, a) {
|
|
199
199
|
r === "halo-dot" && ze(
|
|
200
200
|
l,
|
|
201
201
|
t,
|
|
202
|
-
on(
|
|
202
|
+
on(i),
|
|
203
203
|
nn,
|
|
204
204
|
a * 4
|
|
205
|
-
), (r === "dot" || r === "halo-dot") && ze(l, t,
|
|
205
|
+
), (r === "dot" || r === "halo-dot") && ze(l, t, i, 1, a * 2);
|
|
206
206
|
}
|
|
207
207
|
function on(l) {
|
|
208
208
|
return l === "none" ? "none" : l;
|
|
209
209
|
}
|
|
210
|
-
function ze(l, t,
|
|
210
|
+
function ze(l, t, i, r, a) {
|
|
211
211
|
const h = wt("circle");
|
|
212
|
-
h.setAttribute("cx", `${t.x}`), h.setAttribute("cy", `${t.y}`), h.setAttribute("r", `${a}`), h.setAttribute("fill-opacity", `${r}`), h.setAttribute("fill",
|
|
212
|
+
h.setAttribute("cx", `${t.x}`), h.setAttribute("cy", `${t.y}`), h.setAttribute("r", `${a}`), h.setAttribute("fill-opacity", `${r}`), h.setAttribute("fill", i), l.appendChild(h);
|
|
213
213
|
}
|
|
214
214
|
const U = -1, Zt = "dragging", Yt = "dragstart", Lt = "dragend", fe = "select", ge = "unselect", an = "hover", ln = "unhover", pe = "remove", ye = "add", hn = "cancelDrawing", me = "update", un = "link";
|
|
215
215
|
function sr(l) {
|
|
@@ -218,114 +218,114 @@ function sr(l) {
|
|
|
218
218
|
var Pe = { exports: {} }, Fe;
|
|
219
219
|
function cn() {
|
|
220
220
|
return Fe || (Fe = 1, function(l) {
|
|
221
|
-
var t = Object.prototype.hasOwnProperty,
|
|
221
|
+
var t = Object.prototype.hasOwnProperty, i = "~";
|
|
222
222
|
function r() {
|
|
223
223
|
}
|
|
224
|
-
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (
|
|
225
|
-
function a(
|
|
226
|
-
this.fn =
|
|
224
|
+
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (i = !1));
|
|
225
|
+
function a(f, g, p) {
|
|
226
|
+
this.fn = f, this.context = g, this.once = p || !1;
|
|
227
227
|
}
|
|
228
|
-
function h(
|
|
228
|
+
function h(f, g, p, w, b) {
|
|
229
229
|
if (typeof p != "function")
|
|
230
230
|
throw new TypeError("The listener must be a function");
|
|
231
|
-
var
|
|
232
|
-
return
|
|
231
|
+
var A = new a(p, w || f, b), E = i ? i + g : g;
|
|
232
|
+
return f._events[E] ? f._events[E].fn ? f._events[E] = [f._events[E], A] : f._events[E].push(A) : (f._events[E] = A, f._eventsCount++), f;
|
|
233
233
|
}
|
|
234
|
-
function c(
|
|
235
|
-
--
|
|
234
|
+
function c(f, g) {
|
|
235
|
+
--f._eventsCount === 0 ? f._events = new r() : delete f._events[g];
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function d() {
|
|
238
238
|
this._events = new r(), this._eventsCount = 0;
|
|
239
239
|
}
|
|
240
|
-
|
|
241
|
-
var
|
|
242
|
-
if (this._eventsCount === 0) return
|
|
240
|
+
d.prototype.eventNames = function() {
|
|
241
|
+
var f = [], g, p;
|
|
242
|
+
if (this._eventsCount === 0) return f;
|
|
243
243
|
for (p in g = this._events)
|
|
244
|
-
t.call(g, p) &&
|
|
245
|
-
return Object.getOwnPropertySymbols ?
|
|
246
|
-
},
|
|
247
|
-
var g =
|
|
244
|
+
t.call(g, p) && f.push(i ? p.slice(1) : p);
|
|
245
|
+
return Object.getOwnPropertySymbols ? f.concat(Object.getOwnPropertySymbols(g)) : f;
|
|
246
|
+
}, d.prototype.listeners = function(f) {
|
|
247
|
+
var g = i ? i + f : f, p = this._events[g];
|
|
248
248
|
if (!p) return [];
|
|
249
249
|
if (p.fn) return [p.fn];
|
|
250
|
-
for (var
|
|
251
|
-
|
|
252
|
-
return
|
|
253
|
-
},
|
|
254
|
-
var g =
|
|
250
|
+
for (var w = 0, b = p.length, A = new Array(b); w < b; w++)
|
|
251
|
+
A[w] = p[w].fn;
|
|
252
|
+
return A;
|
|
253
|
+
}, d.prototype.listenerCount = function(f) {
|
|
254
|
+
var g = i ? i + f : f, p = this._events[g];
|
|
255
255
|
return p ? p.fn ? 1 : p.length : 0;
|
|
256
|
-
},
|
|
257
|
-
var E =
|
|
256
|
+
}, d.prototype.emit = function(f, g, p, w, b, A) {
|
|
257
|
+
var E = i ? i + f : f;
|
|
258
258
|
if (!this._events[E]) return !1;
|
|
259
|
-
var
|
|
260
|
-
if (
|
|
261
|
-
switch (
|
|
259
|
+
var k = this._events[E], L = arguments.length, M, C;
|
|
260
|
+
if (k.fn) {
|
|
261
|
+
switch (k.once && this.removeListener(f, k.fn, void 0, !0), L) {
|
|
262
262
|
case 1:
|
|
263
|
-
return
|
|
263
|
+
return k.fn.call(k.context), !0;
|
|
264
264
|
case 2:
|
|
265
|
-
return
|
|
265
|
+
return k.fn.call(k.context, g), !0;
|
|
266
266
|
case 3:
|
|
267
|
-
return
|
|
267
|
+
return k.fn.call(k.context, g, p), !0;
|
|
268
268
|
case 4:
|
|
269
|
-
return
|
|
269
|
+
return k.fn.call(k.context, g, p, w), !0;
|
|
270
270
|
case 5:
|
|
271
|
-
return
|
|
271
|
+
return k.fn.call(k.context, g, p, w, b), !0;
|
|
272
272
|
case 6:
|
|
273
|
-
return
|
|
273
|
+
return k.fn.call(k.context, g, p, w, b, A), !0;
|
|
274
274
|
}
|
|
275
|
-
for (C = 1,
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
for (C = 1, M = new Array(L - 1); C < L; C++)
|
|
276
|
+
M[C - 1] = arguments[C];
|
|
277
|
+
k.fn.apply(k.context, M);
|
|
278
278
|
} else {
|
|
279
|
-
var
|
|
280
|
-
for (C = 0; C <
|
|
281
|
-
switch (
|
|
279
|
+
var N = k.length, P;
|
|
280
|
+
for (C = 0; C < N; C++)
|
|
281
|
+
switch (k[C].once && this.removeListener(f, k[C].fn, void 0, !0), L) {
|
|
282
282
|
case 1:
|
|
283
|
-
|
|
283
|
+
k[C].fn.call(k[C].context);
|
|
284
284
|
break;
|
|
285
285
|
case 2:
|
|
286
|
-
|
|
286
|
+
k[C].fn.call(k[C].context, g);
|
|
287
287
|
break;
|
|
288
288
|
case 3:
|
|
289
|
-
|
|
289
|
+
k[C].fn.call(k[C].context, g, p);
|
|
290
290
|
break;
|
|
291
291
|
case 4:
|
|
292
|
-
|
|
292
|
+
k[C].fn.call(k[C].context, g, p, w);
|
|
293
293
|
break;
|
|
294
294
|
default:
|
|
295
|
-
if (!
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
if (!M) for (P = 1, M = new Array(L - 1); P < L; P++)
|
|
296
|
+
M[P - 1] = arguments[P];
|
|
297
|
+
k[C].fn.apply(k[C].context, M);
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
return !0;
|
|
301
|
-
},
|
|
302
|
-
return h(this,
|
|
303
|
-
},
|
|
304
|
-
return h(this,
|
|
305
|
-
},
|
|
306
|
-
var
|
|
307
|
-
if (!this._events[
|
|
301
|
+
}, d.prototype.on = function(f, g, p) {
|
|
302
|
+
return h(this, f, g, p, !1);
|
|
303
|
+
}, d.prototype.once = function(f, g, p) {
|
|
304
|
+
return h(this, f, g, p, !0);
|
|
305
|
+
}, d.prototype.removeListener = function(f, g, p, w) {
|
|
306
|
+
var b = i ? i + f : f;
|
|
307
|
+
if (!this._events[b]) return this;
|
|
308
308
|
if (!g)
|
|
309
|
-
return c(this,
|
|
310
|
-
var
|
|
311
|
-
if (
|
|
312
|
-
|
|
309
|
+
return c(this, b), this;
|
|
310
|
+
var A = this._events[b];
|
|
311
|
+
if (A.fn)
|
|
312
|
+
A.fn === g && (!w || A.once) && (!p || A.context === p) && c(this, b);
|
|
313
313
|
else {
|
|
314
|
-
for (var E = 0,
|
|
315
|
-
(
|
|
316
|
-
|
|
314
|
+
for (var E = 0, k = [], L = A.length; E < L; E++)
|
|
315
|
+
(A[E].fn !== g || w && !A[E].once || p && A[E].context !== p) && k.push(A[E]);
|
|
316
|
+
k.length ? this._events[b] = k.length === 1 ? k[0] : k : c(this, b);
|
|
317
317
|
}
|
|
318
318
|
return this;
|
|
319
|
-
},
|
|
319
|
+
}, d.prototype.removeAllListeners = function(f) {
|
|
320
320
|
var g;
|
|
321
|
-
return
|
|
322
|
-
},
|
|
321
|
+
return f ? (g = i ? i + f : f, this._events[g] && c(this, g)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
322
|
+
}, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = i, d.EventEmitter = d, l.exports = d;
|
|
323
323
|
}(Pe)), Pe.exports;
|
|
324
324
|
}
|
|
325
325
|
var dn = cn();
|
|
326
326
|
const or = /* @__PURE__ */ sr(dn);
|
|
327
327
|
class ar extends or {
|
|
328
|
-
constructor(t,
|
|
328
|
+
constructor(t, i) {
|
|
329
329
|
super(), m(this, "ogma"), m(this, "elements"), m(this, "layer"), m(this, "editor"), m(this, "selectedId", U), m(this, "hoveredId", U), m(this, "ogmaOptions"), m(this, "shouldDetect"), m(this, "isDragging"), m(this, "showeditorOnHover"), m(this, "_onKeyUp", (r) => {
|
|
330
330
|
r.code === 27 && this.selectedId !== U ? this.unselect() : (r.code === 46 || r.code === 8) && this.selectedId !== U && this._canRemove() && this.remove(this.selectedId);
|
|
331
331
|
}), m(this, "_onClickMouseMove", (r) => {
|
|
@@ -337,7 +337,7 @@ class ar extends or {
|
|
|
337
337
|
this.refreshEditor(), this.refreshDrawing();
|
|
338
338
|
}), this.layer = t.layers.addSVGLayer({
|
|
339
339
|
draw: (r) => this.draw(r)
|
|
340
|
-
}), this.layer.moveToTop(), this.editor = t.layers.addLayer(
|
|
340
|
+
}), this.layer.moveToTop(), this.editor = t.layers.addLayer(i), this.editor.hide();
|
|
341
341
|
}
|
|
342
342
|
_canRemove() {
|
|
343
343
|
return !0;
|
|
@@ -348,38 +348,38 @@ class ar extends or {
|
|
|
348
348
|
* @returns the added annotation
|
|
349
349
|
*/
|
|
350
350
|
add(t) {
|
|
351
|
-
const
|
|
351
|
+
const i = this.getDefaultOptions(), r = Object.assign(t, {
|
|
352
352
|
id: t.id === void 0 ? Jt() : t.id,
|
|
353
353
|
type: t.type,
|
|
354
354
|
properties: {
|
|
355
|
-
...
|
|
355
|
+
...i.properties,
|
|
356
356
|
...t.properties || {},
|
|
357
357
|
// styles need to be merged
|
|
358
|
-
style: { ...
|
|
358
|
+
style: { ...i.properties.style, ...t.properties.style || {} }
|
|
359
359
|
},
|
|
360
360
|
geometry: {
|
|
361
|
-
...
|
|
361
|
+
...i.geometry,
|
|
362
362
|
...t.geometry
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
365
|
return this.elements.push(r), this.layer.refresh(), this.emit(ye, r), r;
|
|
366
366
|
}
|
|
367
|
-
updateStyle(t,
|
|
367
|
+
updateStyle(t, i) {
|
|
368
368
|
this.updateAnnotation(t, {
|
|
369
369
|
properties: {
|
|
370
|
-
style:
|
|
370
|
+
style: i
|
|
371
371
|
}
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
|
-
updateGeometry(t,
|
|
374
|
+
updateGeometry(t, i) {
|
|
375
375
|
this.updateAnnotation(t, {
|
|
376
|
-
geometry:
|
|
376
|
+
geometry: i
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
scale(t,
|
|
379
|
+
scale(t, i, r, a) {
|
|
380
380
|
this.updateGeometry(
|
|
381
381
|
t,
|
|
382
|
-
en(t.geometry,
|
|
382
|
+
en(t.geometry, i, r, a)
|
|
383
383
|
);
|
|
384
384
|
}
|
|
385
385
|
/**
|
|
@@ -388,17 +388,17 @@ class ar extends or {
|
|
|
388
388
|
* @param id Id of the annotation to update
|
|
389
389
|
* @param element params of the annotation
|
|
390
390
|
*/
|
|
391
|
-
update(t,
|
|
391
|
+
update(t, i) {
|
|
392
392
|
const r = this.getById(t);
|
|
393
|
-
this.updateAnnotation(r,
|
|
393
|
+
this.updateAnnotation(r, i);
|
|
394
394
|
}
|
|
395
|
-
updateAnnotation(t,
|
|
395
|
+
updateAnnotation(t, i) {
|
|
396
396
|
if (!t) return;
|
|
397
397
|
const r = t.id;
|
|
398
|
-
Object.keys(
|
|
398
|
+
Object.keys(i).forEach((a) => {
|
|
399
399
|
if (a !== "id")
|
|
400
400
|
if (a === "properties") {
|
|
401
|
-
const h =
|
|
401
|
+
const h = i.properties || { style: {} };
|
|
402
402
|
t.properties = {
|
|
403
403
|
...t.properties || {},
|
|
404
404
|
...h || {},
|
|
@@ -409,15 +409,15 @@ class ar extends or {
|
|
|
409
409
|
};
|
|
410
410
|
} else a === "geometry" ? t.geometry = {
|
|
411
411
|
...t.geometry,
|
|
412
|
-
...
|
|
413
|
-
} : t[a] =
|
|
412
|
+
...i.geometry
|
|
413
|
+
} : t[a] = i[a];
|
|
414
414
|
}), r === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
415
415
|
}
|
|
416
416
|
getById(t) {
|
|
417
|
-
const
|
|
417
|
+
const i = Number(t);
|
|
418
418
|
for (let r = 0; r < this.elements.length; r++) {
|
|
419
419
|
const a = this.elements[r];
|
|
420
|
-
if (!(a.id !== t && a.id !==
|
|
420
|
+
if (!(a.id !== t && a.id !== i))
|
|
421
421
|
return a;
|
|
422
422
|
}
|
|
423
423
|
}
|
|
@@ -427,12 +427,12 @@ class ar extends or {
|
|
|
427
427
|
* Select element, show editor, disable Ogma dragging and fire event
|
|
428
428
|
*/
|
|
429
429
|
select(t) {
|
|
430
|
-
const
|
|
431
|
-
|
|
430
|
+
const i = this.getById(t);
|
|
431
|
+
i && (this.editor.show(), this.selectedId = t, this.refreshEditor(), this.layer.refresh(), this.emit(fe, i));
|
|
432
432
|
}
|
|
433
433
|
hover(t) {
|
|
434
|
-
const
|
|
435
|
-
|
|
434
|
+
const i = this.getById(t);
|
|
435
|
+
i && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(an, i));
|
|
436
436
|
}
|
|
437
437
|
getSelectedFeature() {
|
|
438
438
|
return this.selectedId === U ? null : this.getById(this.selectedId);
|
|
@@ -451,8 +451,8 @@ class ar extends or {
|
|
|
451
451
|
* Removes annotation with the given id
|
|
452
452
|
*/
|
|
453
453
|
remove(t) {
|
|
454
|
-
const
|
|
455
|
-
t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((r) => r.id !== t),
|
|
454
|
+
const i = this.getById(t);
|
|
455
|
+
t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((r) => r.id !== t), i && this.emit(pe, i), this.layer.refresh();
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
458
|
* @method disableDragging
|
|
@@ -504,7 +504,7 @@ class ar extends or {
|
|
|
504
504
|
}
|
|
505
505
|
const He = "handle-line", Ne = "handle-start", je = "handle-end";
|
|
506
506
|
class fn extends ar {
|
|
507
|
-
constructor(t,
|
|
507
|
+
constructor(t, i = {}) {
|
|
508
508
|
super(
|
|
509
509
|
t,
|
|
510
510
|
`
|
|
@@ -523,19 +523,19 @@ class fn extends ar {
|
|
|
523
523
|
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = U, this.emit(Lt, this.arrow));
|
|
524
524
|
}), m(this, "onMouseMove", (r) => {
|
|
525
525
|
if (!this.isDragging || this.draggedHandle === U) return;
|
|
526
|
-
const { x: a, y: h } = Vt(r, this.ogma.getContainer()), c = this.handles[this.draggedHandle],
|
|
526
|
+
const { x: a, y: h } = Vt(r, this.ogma.getContainer()), c = this.handles[this.draggedHandle], d = this.ogma.view.getAngle(), { x: f, y: g } = nt(
|
|
527
527
|
rn(
|
|
528
528
|
{ x: a - this.startX, y: h - this.startY },
|
|
529
529
|
this.ogma.view.getZoom()
|
|
530
530
|
),
|
|
531
|
-
|
|
532
|
-
), p = c.id === He,
|
|
533
|
-
(p ||
|
|
531
|
+
d
|
|
532
|
+
), p = c.id === He, w = c.id === Ne, b = c.id === je;
|
|
533
|
+
(p || w) && Ke(this.arrow, this.start.x + f, this.start.y + g), (p || b) && Qe(this.arrow, this.end.x + f, this.end.y + g), this.emit(
|
|
534
534
|
Zt,
|
|
535
535
|
this.arrow,
|
|
536
|
-
p ? "line" :
|
|
536
|
+
p ? "line" : w ? "start" : "end"
|
|
537
537
|
), this.refreshEditor(), this.layer.refresh();
|
|
538
|
-
}), this.minArrowHeight =
|
|
538
|
+
}), this.minArrowHeight = i.minArrowHeight || 0, this.maxArrowHeight = i.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call(
|
|
539
539
|
this.editor.element.querySelectorAll(".arrow-handle>.handle")
|
|
540
540
|
), this.handles.forEach(
|
|
541
541
|
(r) => r.addEventListener("mousedown", this.onHandleMouseDown)
|
|
@@ -547,10 +547,10 @@ class fn extends ar {
|
|
|
547
547
|
* @param y
|
|
548
548
|
* @param arrow
|
|
549
549
|
*/
|
|
550
|
-
startDrawing(t,
|
|
550
|
+
startDrawing(t, i, r = Yr(t, i, t, i, Pt)) {
|
|
551
551
|
var a;
|
|
552
552
|
this.disableDragging(), this.add(r), this.hoveredId = r.id;
|
|
553
|
-
const h = this.ogma.view.graphToScreenCoordinates({ x: t, y:
|
|
553
|
+
const h = this.ogma.view.graphToScreenCoordinates({ x: t, y: i }), c = ((a = this.ogma.getContainer()) == null ? void 0 : a.getBoundingClientRect()) || {
|
|
554
554
|
left: 0,
|
|
555
555
|
top: 0
|
|
556
556
|
};
|
|
@@ -563,39 +563,39 @@ class fn extends ar {
|
|
|
563
563
|
cancelDrawing() {
|
|
564
564
|
this.isDragging && (this.remove(this.arrow.id), this.emit(Lt, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = U);
|
|
565
565
|
}
|
|
566
|
-
startDragging(t,
|
|
567
|
-
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX =
|
|
566
|
+
startDragging(t, i, r) {
|
|
567
|
+
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = i, this.startY = r, this.start = zt(this.arrow), this.end = Xt(this.arrow), this.disableDragging(), this.emit(Yt, this.arrow), this.isDragging = !0;
|
|
568
568
|
}
|
|
569
|
-
detect(t,
|
|
569
|
+
detect(t, i = 0) {
|
|
570
570
|
return this.elements.find((r) => {
|
|
571
571
|
const { start: a, end: h } = Gt(r), c = xt(t, {
|
|
572
572
|
x: (a.x + h.x) / 2,
|
|
573
573
|
y: (a.y + h.y) / 2
|
|
574
|
-
}),
|
|
575
|
-
return Math.abs(Ie(g, c)) <
|
|
574
|
+
}), d = xt(h, a), f = _t(d), g = rr(d), p = ir(r);
|
|
575
|
+
return Math.abs(Ie(g, c)) < f / 2 + i && Math.abs(Ie(nt(g, Math.PI / 2), c)) < p / 2 + i;
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
578
|
refreshEditor() {
|
|
579
579
|
if (+this.selectedId < 0 && +this.hoveredId < 0) return;
|
|
580
|
-
const t = this.selectedId !== U ? this.getById(this.selectedId) : this.getById(this.hoveredId),
|
|
580
|
+
const t = this.selectedId !== U ? this.getById(this.selectedId) : this.getById(this.hoveredId), i = Gt(t), r = this.ogma.view.graphToScreenCoordinates(i.start), a = this.ogma.view.graphToScreenCoordinates(i.end), [h, c, d] = Array.prototype.slice.call(
|
|
581
581
|
this.editor.element.querySelectorAll(".handle")
|
|
582
582
|
);
|
|
583
|
-
c.style.transform = `translate(${r.x}px, ${r.y}px) translate(-50%, -50%)`,
|
|
584
|
-
const
|
|
583
|
+
c.style.transform = `translate(${r.x}px, ${r.y}px) translate(-50%, -50%)`, d.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%)`;
|
|
584
|
+
const f = {
|
|
585
585
|
x: (a.x + r.x) / 2,
|
|
586
586
|
y: (a.y + r.y) / 2
|
|
587
|
-
}, g = xt(a, r), p = nr(g, 1 / _t(g)),
|
|
588
|
-
h.style.width = `${_t(g)}px`, h.style.left = `${
|
|
587
|
+
}, g = xt(a, r), p = nr(g, 1 / _t(g)), w = Math.atan2(p.y, p.x);
|
|
588
|
+
h.style.width = `${_t(g)}px`, h.style.left = `${f.x}px`, h.style.top = `${f.y}px`, h.style.transform = `translate(-50%, -50%) rotate(${w}rad)`;
|
|
589
589
|
}
|
|
590
590
|
getDefaultOptions() {
|
|
591
591
|
return $e;
|
|
592
592
|
}
|
|
593
593
|
draw(t) {
|
|
594
594
|
t.innerHTML = "";
|
|
595
|
-
const
|
|
596
|
-
r !== 0 &&
|
|
597
|
-
(a) => sn(a,
|
|
598
|
-
), t.appendChild(
|
|
595
|
+
const i = wt("g"), r = this.ogma.view.getAngle();
|
|
596
|
+
r !== 0 && i.setAttribute("transform", `rotate(${-r * (180 / Math.PI)})`), this.elements.forEach(
|
|
597
|
+
(a) => sn(a, i, Pt, this.minArrowHeight, this.maxArrowHeight)
|
|
598
|
+
), t.appendChild(i);
|
|
599
599
|
}
|
|
600
600
|
refreshDrawing() {
|
|
601
601
|
const t = this.ogma.view.getAngle();
|
|
@@ -642,7 +642,7 @@ const Dt = {
|
|
|
642
642
|
}, Be = {
|
|
643
643
|
handleSize: 3.5,
|
|
644
644
|
placeholder: "Your text..."
|
|
645
|
-
}, gn = (l = 0, t = 0,
|
|
645
|
+
}, gn = (l = 0, t = 0, i = 100, r = 50, a = "", h = { ...Dt }) => ({
|
|
646
646
|
id: Jt(),
|
|
647
647
|
type: "Feature",
|
|
648
648
|
properties: {
|
|
@@ -655,8 +655,8 @@ const Dt = {
|
|
|
655
655
|
coordinates: [
|
|
656
656
|
[
|
|
657
657
|
[l, t],
|
|
658
|
-
[l +
|
|
659
|
-
[l +
|
|
658
|
+
[l + i, t],
|
|
659
|
+
[l + i, t + r],
|
|
660
660
|
[l, t + r],
|
|
661
661
|
[l, t]
|
|
662
662
|
]
|
|
@@ -666,11 +666,11 @@ const Dt = {
|
|
|
666
666
|
var ve = { exports: {} }, pn = ve.exports, qe;
|
|
667
667
|
function yn() {
|
|
668
668
|
return qe || (qe = 1, function(l, t) {
|
|
669
|
-
(function(
|
|
669
|
+
(function(i, r) {
|
|
670
670
|
l.exports = r();
|
|
671
671
|
})(pn, () => (() => {
|
|
672
|
-
var
|
|
673
|
-
for (var o in n)
|
|
672
|
+
var i = { d: (e, n) => {
|
|
673
|
+
for (var o in n) i.o(n, o) && !i.o(e, o) && Object.defineProperty(e, o, { enumerable: !0, get: n[o] });
|
|
674
674
|
}, o: (e, n) => Object.prototype.hasOwnProperty.call(e, n) }, r = {};
|
|
675
675
|
function a(e) {
|
|
676
676
|
return a = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
@@ -679,20 +679,20 @@ function yn() {
|
|
|
679
679
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
680
680
|
}, a(e);
|
|
681
681
|
}
|
|
682
|
-
|
|
683
|
-
var h = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, c = /\bsmall-caps\b/,
|
|
684
|
-
function
|
|
682
|
+
i.d(r, { default: () => qr });
|
|
683
|
+
var h = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, c = /\bsmall-caps\b/, d = /\b(?:italic|oblique)\b/, f = /\bbold(?:er)?\b/, g = 13.3333333, p = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
684
|
+
function w(e) {
|
|
685
685
|
var n = "", o = this;
|
|
686
686
|
return o.style && o.style !== "normal" && (n += o.style), o.variant && o.variant !== "normal" && (n += (n ? " " : "") + o.variant), o.weight && o.weight !== "normal" && (n += (n ? " " : "") + o.weight), o.size && (n += (n ? " " : "") + o.size + "px", o.height !== o.size && (n += "/" + o.height + "px")), o.family && (n += (n ? " " : "") + o.family), e && (n += "::" + o.baseline), e && (n += "::" + o.color), n;
|
|
687
687
|
}
|
|
688
|
-
var
|
|
689
|
-
function
|
|
688
|
+
var b = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: w, valueOf: w };
|
|
689
|
+
function A(e) {
|
|
690
690
|
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = h.exec(e);
|
|
691
691
|
n.family = (o[6] || "").trim();
|
|
692
|
-
var
|
|
693
|
-
o[3] === "%" ?
|
|
692
|
+
var s = p[o[2]] || parseFloat(o[2]);
|
|
693
|
+
o[3] === "%" ? s *= 0.16 : o[3] === "em" ? s *= 16 : o[3] === "pt" && (s *= g), n.size = s;
|
|
694
694
|
var u = parseFloat(o[4]);
|
|
695
|
-
if (u !== "normal" && u !== "inherit" && u ? o[5] && o[5] !== "em" ? o[5] === "pt" ? n.height = u * g : o[5] === "%" ? n.height = 0.01 *
|
|
695
|
+
if (u !== "normal" && u !== "inherit" && u ? o[5] && o[5] !== "em" ? o[5] === "pt" ? n.height = u * g : o[5] === "%" ? n.height = 0.01 * s : n.height = u : n.height = u * s : n.height = Math.round(s * (7 / 6)), c.test(o[1]) && (n.variant = "small-caps"), d.test(o[1]) && (n.style = "italic"), f.test(o[1])) n.weight = "bold";
|
|
696
696
|
else {
|
|
697
697
|
var y = parseInt(/\b(\d+)\b/.exec(o[1]), 10);
|
|
698
698
|
y >= 100 && y !== 400 && (n.weight = y);
|
|
@@ -700,25 +700,25 @@ function yn() {
|
|
|
700
700
|
return n;
|
|
701
701
|
}
|
|
702
702
|
function E() {
|
|
703
|
-
var e, n, o,
|
|
704
|
-
if (
|
|
705
|
-
var $ =
|
|
706
|
-
e = I.getPropertyValue("font-family") || "",
|
|
707
|
-
} else if (typeof
|
|
708
|
-
var D =
|
|
709
|
-
e = D.family,
|
|
710
|
-
} else a(
|
|
711
|
-
u.size && u.size < 3 && (
|
|
712
|
-
var
|
|
713
|
-
return
|
|
703
|
+
var e, n, o, s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, y = 14, x = 12, v = null, S = null, _ = "";
|
|
704
|
+
if (s && s.nodeType) {
|
|
705
|
+
var $ = s && (s.ownerDocument && s.ownerDocument.defaultView || s.document && s || s.defaultView), I = $.getComputedStyle(s, null);
|
|
706
|
+
e = I.getPropertyValue("font-family") || "", x = parseFloat(I.getPropertyValue("font-size")), y = I.getPropertyValue("line-height"), v = I.getPropertyValue("font-weight"), S = I.getPropertyValue("font-style"), _ = I.getPropertyValue("font-variant") || "";
|
|
707
|
+
} else if (typeof s == "string") {
|
|
708
|
+
var D = A(s);
|
|
709
|
+
e = D.family, x = D.size, y = D.height, _ = D.variant, S = D.style, v = D.weight;
|
|
710
|
+
} else a(s) === "object" && (e = s.family, x = s.size, y = s.height, _ = s.variant, v = s.weight, S = s.style, n = s.baseline, o = s.color);
|
|
711
|
+
u.size && u.size < 3 && (x *= u.size), y = y !== "normal" && y ? parseFloat(y) : x * (7 / 6), u.height && u.height < 3 && (y *= u.height);
|
|
712
|
+
var O = Object.create(b);
|
|
713
|
+
return O.family = u.family || e || "sans-serif", O.height = y ?? 14, O.size = x ?? 12, O.variant = u.variant || _ || "", O.style = u.style || S || "", O.weight = u.weight || v || "", O.baseline = n || 0, u.baseline != null && (O.baseline = u.baseline), O.color = u.color || o || "", O.id = w.call(O, !0), O;
|
|
714
714
|
}
|
|
715
|
-
const
|
|
716
|
-
var L,
|
|
715
|
+
const k = { "\n": 0.28, "\r": 0.28, " ": 0.28, " ": 0.28, " ": 0.28, "": 0, " ": 0.5, " ": 1, " ": 0.5, " ": 1, " ": 0.33, " ": 0.25, " ": 0.16, " ": 0.56, " ": 0.28, " ": 0.2, " ": 0.15, "": 0, " ": 0.16, " ": 0.22, " ": 1, "\uFEFF": 0 };
|
|
716
|
+
var L, M = function(e) {
|
|
717
717
|
var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas");
|
|
718
718
|
if (n && n.getContext) {
|
|
719
719
|
var o = n.getContext("2d");
|
|
720
|
-
if (o && typeof o.measureText == "function") return function(
|
|
721
|
-
return o.font = String(u), o.measureText(
|
|
720
|
+
if (o && typeof o.measureText == "function") return function(s, u) {
|
|
721
|
+
return o.font = String(u), o.measureText(s).width;
|
|
722
722
|
};
|
|
723
723
|
}
|
|
724
724
|
}(typeof document < "u" ? document : null) || (L = {}, function(e, n) {
|
|
@@ -727,15 +727,15 @@ function yn() {
|
|
|
727
727
|
L[n] = o, /\bmonospace\b/.test(o.family) ? o.size *= 0.6 : (o.size *= 0.45, o.weight && (o.size *= 1.18));
|
|
728
728
|
}
|
|
729
729
|
return e.length * L[n].size;
|
|
730
|
-
}), C = {},
|
|
731
|
-
function
|
|
732
|
-
var
|
|
730
|
+
}), C = {}, N = { trim: !0, collapse: !0 };
|
|
731
|
+
function P(e, n, o) {
|
|
732
|
+
var s = Object.assign({}, N, o), u = String(e);
|
|
733
733
|
if (!u) return 0;
|
|
734
|
-
if (u in
|
|
734
|
+
if (u in k) {
|
|
735
735
|
var y = n.id + "/" + u;
|
|
736
|
-
return y in C || (C[y] =
|
|
736
|
+
return y in C || (C[y] = M("_".concat(u, "_"), n) - M("__", n)), C[y];
|
|
737
737
|
}
|
|
738
|
-
return
|
|
738
|
+
return s.trim && s.collapse ? s.trim ? u = u.trim() : s.collapse && (u = u.replace(/\s+/g, " ")) : u = u.replace(/\n/g, " "), M(u, n) + n.size * (e.tracking || 0);
|
|
739
739
|
}
|
|
740
740
|
function tt(e) {
|
|
741
741
|
return tt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
@@ -749,8 +749,8 @@ function yn() {
|
|
|
749
749
|
e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n && Kt(e, n);
|
|
750
750
|
}
|
|
751
751
|
function Kt(e, n) {
|
|
752
|
-
return Kt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o,
|
|
753
|
-
return o.__proto__ =
|
|
752
|
+
return Kt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, s) {
|
|
753
|
+
return o.__proto__ = s, o;
|
|
754
754
|
}, Kt(e, n);
|
|
755
755
|
}
|
|
756
756
|
function Qt(e) {
|
|
@@ -765,11 +765,11 @@ function yn() {
|
|
|
765
765
|
}
|
|
766
766
|
}();
|
|
767
767
|
return function() {
|
|
768
|
-
var o,
|
|
768
|
+
var o, s = Ft(e);
|
|
769
769
|
if (n) {
|
|
770
770
|
var u = Ft(this).constructor;
|
|
771
|
-
o = Reflect.construct(
|
|
772
|
-
} else o =
|
|
771
|
+
o = Reflect.construct(s, arguments, u);
|
|
772
|
+
} else o = s.apply(this, arguments);
|
|
773
773
|
return ur(this, o);
|
|
774
774
|
};
|
|
775
775
|
}
|
|
@@ -791,17 +791,17 @@ function yn() {
|
|
|
791
791
|
}
|
|
792
792
|
function cr(e, n) {
|
|
793
793
|
for (var o = 0; o < n.length; o++) {
|
|
794
|
-
var
|
|
795
|
-
|
|
794
|
+
var s = n[o];
|
|
795
|
+
s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, (u = function(y, x) {
|
|
796
796
|
if (tt(y) !== "object" || y === null) return y;
|
|
797
797
|
var v = y[Symbol.toPrimitive];
|
|
798
798
|
if (v !== void 0) {
|
|
799
|
-
var S = v.call(y,
|
|
799
|
+
var S = v.call(y, x);
|
|
800
800
|
if (tt(S) !== "object") return S;
|
|
801
801
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
802
802
|
}
|
|
803
803
|
return String(y);
|
|
804
|
-
}(
|
|
804
|
+
}(s.key, "string"), tt(u) === "symbol" ? u : String(u)), s);
|
|
805
805
|
}
|
|
806
806
|
var u;
|
|
807
807
|
}
|
|
@@ -845,16 +845,16 @@ function yn() {
|
|
|
845
845
|
}(j), te = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, dr = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, we = /^[\xA0\u2011\u202F\u2060\uFEFF]/, fr = /^(?:[;\xAD%?…]|,(?!\d))/, gr = /^[´±°¢£¤$¥\u2212]/;
|
|
846
846
|
function jt(e, n) {
|
|
847
847
|
n !== !1 && (e = e.trim());
|
|
848
|
-
for (var o,
|
|
849
|
-
o = e.charAt(v),
|
|
848
|
+
for (var o, s, u = [], y = e.charAt(0), x = 0, v = 1, S = e.length; v < S; v++) {
|
|
849
|
+
o = e.charAt(v), s = e.charAt(v + 1);
|
|
850
850
|
var _ = te.test(y), $ = te.test(o), I = $ || _, D = void 0;
|
|
851
|
-
if ((gr.test(o) && !we.test(y) || fr.test(y +
|
|
852
|
-
var
|
|
853
|
-
/\u00AD$/.test(
|
|
851
|
+
if ((gr.test(o) && !we.test(y) || fr.test(y + s) && !we.test(o)) && (I = !0), y !== "-" && y !== "‐" && y !== "–" && y !== "—" || ((D = te.test(e.charAt(v - 2))) && !$ && (I = !1), !D && dr.test(o + s) && (I = !0)), I) {
|
|
852
|
+
var O = e.slice(x, v);
|
|
853
|
+
/\u00AD$/.test(O) ? (u.push(new j(O.slice(0, -1))), u.push(new yt())) : (u.push(new j(O)), u.push(new Tt())), x = v;
|
|
854
854
|
}
|
|
855
855
|
y = o;
|
|
856
856
|
}
|
|
857
|
-
return u.push(new j(e.slice(
|
|
857
|
+
return u.push(new j(e.slice(x))), u;
|
|
858
858
|
}
|
|
859
859
|
const xe = { nbsp: " ", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", times: "×", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", divide: "÷", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", fnof: "ƒ", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", bull: "•", hellip: "…", prime: "′", Prime: "″", oline: "‾", frasl: "⁄", weierp: "℘", image: "ℑ", real: "ℜ", trade: "™", alefsym: "ℵ", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lArr: "⇐", uArr: "⇑", rArr: "⇒", dArr: "⇓", hArr: "⇔", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "⊥", or: "⊦", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", lang: "〈", rang: "〉", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦", quot: '"', amp: "&", lt: "<", gt: ">", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "", zwj: "", lrm: "", rlm: "", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", permil: "‰", lsaquo: "‹", rsaquo: "›" };
|
|
860
860
|
var pr = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, yr = /^<\/([a-zA-Z0-9]+)([^>]*)>/, mr = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, vr = /^<!--(.+?)-->/, wr = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, be = { b: function(e) {
|
|
@@ -885,10 +885,10 @@ function yn() {
|
|
|
885
885
|
e.sup = !0;
|
|
886
886
|
} }, xr = { div: 1, li: 1, blockquote: 2, h1: 2, h2: 2, h3: 2, h4: 2, h5: 2, h6: 2, ul: 2, ol: 2, hr: 2, p: 2 };
|
|
887
887
|
function Ae(e) {
|
|
888
|
-
return e.replace(wr, function(n, o,
|
|
889
|
-
if (o ||
|
|
888
|
+
return e.replace(wr, function(n, o, s, u) {
|
|
889
|
+
if (o || s) {
|
|
890
890
|
var y = o ? 10 : 16;
|
|
891
|
-
return String.fromCharCode(parseInt(o ||
|
|
891
|
+
return String.fromCharCode(parseInt(o || s, y));
|
|
892
892
|
}
|
|
893
893
|
return u in xe ? xe[u] : n;
|
|
894
894
|
});
|
|
@@ -902,8 +902,8 @@ function yn() {
|
|
|
902
902
|
if (e) {
|
|
903
903
|
do
|
|
904
904
|
if (n = Ar.exec(e)) {
|
|
905
|
-
var
|
|
906
|
-
if (o[n[1]] =
|
|
905
|
+
var s = Ae(br(n[2] || "")).replace(/[ \r\n\t]+/g, " ").trim();
|
|
906
|
+
if (o[n[1]] = s, (e = e.slice(n[0].length)).length && /^\S/.test(e[0])) throw new Error("Attribute error");
|
|
907
907
|
}
|
|
908
908
|
while (n && e.length);
|
|
909
909
|
if (/\S/.test(e)) throw new Error("Attribute error");
|
|
@@ -940,8 +940,8 @@ function yn() {
|
|
|
940
940
|
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o = E(n, e)), o;
|
|
941
941
|
}
|
|
942
942
|
function Ee(e, n, o) {
|
|
943
|
-
for (var
|
|
944
|
-
e[e.length - 1] instanceof yt && e.pop(),
|
|
943
|
+
for (var s, u, y = e.width; y + o.width > n && e.length; ) u = (s = e[e.length - 1]).width, s.width > o.width ? (s.value = s.value.slice(0, -1), s.width = P(s, s.font), y += s.width) : e.pop(), y -= u;
|
|
944
|
+
e[e.length - 1] instanceof yt && e.pop(), s = e[e.length - 1] || s || {}, o.font = E(o.font, s.bold, s.italic, ""), o.href = e.length ? s.href : null, o.rel = e.length ? s.rel : null, o.target = e.length ? s.target : null, e.push(o);
|
|
945
945
|
}
|
|
946
946
|
function bt(e) {
|
|
947
947
|
return Math.round(1e6 * e) / 1e6;
|
|
@@ -954,8 +954,8 @@ function yn() {
|
|
|
954
954
|
}(e) || function(n, o) {
|
|
955
955
|
if (n) {
|
|
956
956
|
if (typeof n == "string") return ee(n, o);
|
|
957
|
-
var
|
|
958
|
-
return
|
|
957
|
+
var s = Object.prototype.toString.call(n).slice(8, -1);
|
|
958
|
+
return s === "Object" && n.constructor && (s = n.constructor.name), s === "Map" || s === "Set" ? Array.from(n) : s === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s) ? ee(n, o) : void 0;
|
|
959
959
|
}
|
|
960
960
|
}(e) || function() {
|
|
961
961
|
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
@@ -964,22 +964,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
964
964
|
}
|
|
965
965
|
function ee(e, n) {
|
|
966
966
|
(n == null || n > e.length) && (n = e.length);
|
|
967
|
-
for (var o = 0,
|
|
968
|
-
return
|
|
967
|
+
for (var o = 0, s = new Array(n); o < n; o++) s[o] = e[o];
|
|
968
|
+
return s;
|
|
969
969
|
}
|
|
970
970
|
var Ir = { center: "middle", right: "end" }, Mr = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, re = function(e, n) {
|
|
971
971
|
return !e && !n || e === n;
|
|
972
972
|
};
|
|
973
973
|
function Or(e, n) {
|
|
974
|
-
var o = [],
|
|
974
|
+
var o = [], s = n.font(), u = s.size, y = s.family, x = n.align(), v = n.createElement();
|
|
975
975
|
if (e.length) {
|
|
976
|
-
var S =
|
|
976
|
+
var S = s.height, _ = n.valign(), $ = n.height()(), I = n.width()(0), D = !isFinite(I) && e.length === 1, O = D ? null : n.x(), B = bt(S / u), J = D ? null : bt(S / (1.15 * u + (S - u) / 2));
|
|
977
977
|
if (Mr[_] && isFinite($)) {
|
|
978
978
|
var F = _ === "bottom" ? 1 : 0.5;
|
|
979
979
|
J += ($ * F - S * e.length * F) / u;
|
|
980
980
|
}
|
|
981
|
-
var z =
|
|
982
|
-
|
|
981
|
+
var z = x === "justify", q = 0;
|
|
982
|
+
x === "right" ? q = I : x === "center" && (q = I / 2);
|
|
983
983
|
for (var H = [], K = "tspan", G = null, R = "", T = function() {
|
|
984
984
|
if (R) {
|
|
985
985
|
var mt = v(K, G, R);
|
|
@@ -997,21 +997,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
997
997
|
if (T(), D) o.push.apply(o, Se(H));
|
|
998
998
|
else {
|
|
999
999
|
var qt = null, Ot = rt === Q - 1 || ht[ht.length - 1] instanceof et;
|
|
1000
|
-
z && ht.length > 1 && !Ot && (qt = bt((I - Mt) / At)), o.push(v.apply(void 0, ["tspan", { wordSpacing: qt, x:
|
|
1000
|
+
z && ht.length > 1 && !Ot && (qt = bt((I - Mt) / At)), o.push(v.apply(void 0, ["tspan", { wordSpacing: qt, x: O(rt) + q, dy: bt(rt ? B : J) + "em" }].concat(Se(H))));
|
|
1001
1001
|
}
|
|
1002
|
-
} else o.push(v("tspan", { x:
|
|
1002
|
+
} else o.push(v("tspan", { x: O(rt), dy: bt(rt ? B : J) + "em" }, " "));
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
|
-
return v.apply(void 0, ["text", { fontFamily: y, fontSize: u, textAnchor: Ir[
|
|
1005
|
+
return v.apply(void 0, ["text", { fontFamily: y, fontSize: u, textAnchor: Ir[x] || "start" }].concat(o));
|
|
1006
1006
|
}
|
|
1007
1007
|
var zr = { middle: 0.5, center: 0.5, bottom: 1, end: 1 };
|
|
1008
1008
|
function Pr(e, n, o) {
|
|
1009
1009
|
if (e.length) {
|
|
1010
1010
|
o.textBaseline = "middle";
|
|
1011
|
-
var
|
|
1011
|
+
var s = n.font(), u = s.height, y = s.size, x = n.valign(), v = n.height()(), S = n.width()(0), _ = n.align(), $ = _ === "justify", I = 0.5 * u, D = zr[x];
|
|
1012
1012
|
if (D && isFinite(v)) {
|
|
1013
|
-
var
|
|
1014
|
-
I += v * D -
|
|
1013
|
+
var O = e.length * u;
|
|
1014
|
+
I += v * D - O * D;
|
|
1015
1015
|
}
|
|
1016
1016
|
e.forEach(function(B, J) {
|
|
1017
1017
|
var F = n.x()(J), z = J * u + I, q = 0, H = 0;
|
|
@@ -1045,8 +1045,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1045
1045
|
}
|
|
1046
1046
|
function Ce(e) {
|
|
1047
1047
|
for (var n = {}, o = 0; o < e.length; o++) {
|
|
1048
|
-
var
|
|
1049
|
-
typeof
|
|
1048
|
+
var s = e[o];
|
|
1049
|
+
typeof s != "number" && s != null && (typeof s == "string" ? n.text = s : typeof s == "function" ? n.fn = s : ne(s) === "object" && s._groups ? n.d3 = s : s && s.nodeType && s.getContext ? n.ctx = s.getContext("2d") : s && s.fillText && s.beginPath ? n.ctx = s : s && (n.text = s));
|
|
1050
1050
|
}
|
|
1051
1051
|
return n;
|
|
1052
1052
|
}
|
|
@@ -1059,17 +1059,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1059
1059
|
}
|
|
1060
1060
|
function Fr(e, n) {
|
|
1061
1061
|
for (var o = 0; o < n.length; o++) {
|
|
1062
|
-
var
|
|
1063
|
-
|
|
1062
|
+
var s = n[o];
|
|
1063
|
+
s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, (u = function(y, x) {
|
|
1064
1064
|
if ($t(y) !== "object" || y === null) return y;
|
|
1065
1065
|
var v = y[Symbol.toPrimitive];
|
|
1066
1066
|
if (v !== void 0) {
|
|
1067
|
-
var S = v.call(y,
|
|
1067
|
+
var S = v.call(y, x);
|
|
1068
1068
|
if ($t(S) !== "object") return S;
|
|
1069
1069
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1070
1070
|
}
|
|
1071
1071
|
return String(y);
|
|
1072
|
-
}(
|
|
1072
|
+
}(s.key, "string"), $t(u) === "symbol" ? u : String(u)), s);
|
|
1073
1073
|
}
|
|
1074
1074
|
var u;
|
|
1075
1075
|
}
|
|
@@ -1078,26 +1078,26 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1078
1078
|
return e;
|
|
1079
1079
|
};
|
|
1080
1080
|
}, st = function() {
|
|
1081
|
-
function e(
|
|
1082
|
-
if (function(y,
|
|
1083
|
-
if (!(y instanceof
|
|
1081
|
+
function e(s) {
|
|
1082
|
+
if (function(y, x) {
|
|
1083
|
+
if (!(y instanceof x)) throw new TypeError("Cannot call a class as a function");
|
|
1084
1084
|
}(this, e), this.props = { overflow: "ellipsis", lineclamp: null, align: "left", wordBreak: null, valign: "top", width: function() {
|
|
1085
1085
|
return 1 / 0;
|
|
1086
1086
|
}, height: function() {
|
|
1087
1087
|
return 1 / 0;
|
|
1088
1088
|
}, x: function() {
|
|
1089
1089
|
return 0;
|
|
1090
|
-
}, font: null, tAnchor: 0, parser: e.defaultparser },
|
|
1090
|
+
}, font: null, tAnchor: 0, parser: e.defaultparser }, s) for (var u in s) typeof this[u] == "function" && this[u](s[u]);
|
|
1091
1091
|
}
|
|
1092
1092
|
var n, o;
|
|
1093
|
-
return n = e, o = [{ key: "linebreak", value: function(
|
|
1094
|
-
var u = this, y = this.props.parser(String(
|
|
1093
|
+
return n = e, o = [{ key: "linebreak", value: function(s) {
|
|
1094
|
+
var u = this, y = this.props.parser(String(s)), x = this.font(), v = function(S, _, $) {
|
|
1095
1095
|
if (!S.length) return [];
|
|
1096
|
-
var I = _.height(), D = _.width(),
|
|
1096
|
+
var I = _.height(), D = _.width(), O = _.overflowLine(), B = _.overflowWrap(), J = E($, !0, !1), F = isFinite(I()) ? Math.floor(I() / $.height) : 1 / 0;
|
|
1097
1097
|
if (!I() && !D(0) || !F) return [];
|
|
1098
1098
|
for (var z = 0, q = 0, H = 0, K = [], G = [], R = !1; z < S.length && q < F; ) {
|
|
1099
1099
|
var T = S[z], rt = $r(T, $);
|
|
1100
|
-
if (T.width =
|
|
1100
|
+
if (T.width = P(T, rt), T.font = rt, T.line = q, T.whitespace = T.value in k, T.value && (T.value = T.value.replace(Tr, " ")), !(!H && T.whitespace || R && T.whitespace)) if (T instanceof et) H = 0, G = [], K.push(z + 1), q++;
|
|
1101
1101
|
else if (T instanceof Tt || T instanceof yt) G.push({ index: z, width: H });
|
|
1102
1102
|
else if (T.whitespace || H + T.width < D(q)) H += T.width;
|
|
1103
1103
|
else if (G.length) {
|
|
@@ -1105,7 +1105,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1105
1105
|
do {
|
|
1106
1106
|
lt = !0, Q = G.pop();
|
|
1107
1107
|
var gt = S[Q.index], at = void 0;
|
|
1108
|
-
gt instanceof yt && (at =
|
|
1108
|
+
gt instanceof yt && (at = P("-", gt.font), Q.width + at > D(q) && (lt = !G.length));
|
|
1109
1109
|
} while (!lt);
|
|
1110
1110
|
K.push(Q.index + 1), H = 0, q++, z = Q.index, G = [];
|
|
1111
1111
|
} else if (B === "break-word") {
|
|
@@ -1113,7 +1113,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1113
1113
|
if (H + T.width > ht) {
|
|
1114
1114
|
var At = T.clone();
|
|
1115
1115
|
do
|
|
1116
|
-
T.value = T.value.slice(0, -1), T.width =
|
|
1116
|
+
T.value = T.value.slice(0, -1), T.width = P(T, T.font), H += T.width;
|
|
1117
1117
|
while (T.value && T.width > ht);
|
|
1118
1118
|
At.value = At.value.slice(T.value.length), S.splice(z + 1, 0, new Tt(), At);
|
|
1119
1119
|
}
|
|
@@ -1125,7 +1125,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1125
1125
|
var Mt = 0, ut = 0, V = K.map(function(mt) {
|
|
1126
1126
|
for (var Y, vt = Mt; (Y = S[vt]) && (Y.whitespace || !Y.value); ) vt++;
|
|
1127
1127
|
for (var pt = mt, ae = null; pt > vt && (Y = S[pt - 1]) && (Y.whitespace || !(Y.value || Y instanceof yt)); ) Y instanceof et && (ae = Y), pt--;
|
|
1128
|
-
Y instanceof yt && (Y.value = "-", Y.width =
|
|
1128
|
+
Y instanceof yt && (Y.value = "-", Y.width = P("-", Y.font)), Mt = mt;
|
|
1129
1129
|
var kt = S.slice(vt, pt).filter(function(le) {
|
|
1130
1130
|
return le.value;
|
|
1131
1131
|
});
|
|
@@ -1133,61 +1133,61 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1133
1133
|
return le + Rr.width;
|
|
1134
1134
|
}, 0), kt.width > ut && (ut = kt.width), kt;
|
|
1135
1135
|
});
|
|
1136
|
-
if (V.hasLineOverflow = !1,
|
|
1137
|
-
var Bt =
|
|
1136
|
+
if (V.hasLineOverflow = !1, O) {
|
|
1137
|
+
var Bt = O === "ellipsis" ? "…" : O;
|
|
1138
1138
|
V.forEach(function(mt, Y) {
|
|
1139
1139
|
var vt = D(Y);
|
|
1140
1140
|
if (mt.width > vt) {
|
|
1141
1141
|
var pt = new j(Bt);
|
|
1142
|
-
pt.font = $, pt.width =
|
|
1142
|
+
pt.font = $, pt.width = P(Bt, J), Ee(mt, vt, pt), V.hasLineOverflow = !0;
|
|
1143
1143
|
}
|
|
1144
1144
|
});
|
|
1145
1145
|
}
|
|
1146
1146
|
var W = _.overflow() === "ellipsis" ? "…" : _.overflow();
|
|
1147
1147
|
if (W && z !== S.length) {
|
|
1148
1148
|
var Z = D(V.length - 1), qt = V[V.length - 1], Ot = new j(W);
|
|
1149
|
-
Ot.font = $, Ot.width =
|
|
1149
|
+
Ot.font = $, Ot.width = P(W, J), Ee(qt, Z, Ot), V.hasOverflow = !0;
|
|
1150
1150
|
} else V.hasOverflow = !1;
|
|
1151
1151
|
return V.font = $, V.width = ut, V;
|
|
1152
|
-
}(y, this,
|
|
1153
|
-
return v.height = v.length *
|
|
1152
|
+
}(y, this, x);
|
|
1153
|
+
return v.height = v.length * x.height, v.render = function(S) {
|
|
1154
1154
|
return u.render(v, S);
|
|
1155
1155
|
}, v.svg = v.render, v.draw = v.render, v;
|
|
1156
|
-
} }, { key: "font", value: function(
|
|
1157
|
-
return arguments.length ? (this.props.font = E(
|
|
1158
|
-
} }, { key: "overflow", value: function(
|
|
1159
|
-
return arguments.length ? (this.props.overflow = String(
|
|
1160
|
-
} }, { key: "overflowLine", value: function(
|
|
1161
|
-
return arguments.length ? (this.props.lineclamp = String(
|
|
1162
|
-
} }, { key: "valign", value: function(
|
|
1163
|
-
return arguments.length ? (this.props.valign =
|
|
1164
|
-
} }, { key: "align", value: function(
|
|
1156
|
+
} }, { key: "font", value: function(s) {
|
|
1157
|
+
return arguments.length ? (this.props.font = E(s), this) : this.props.font || E(Hr);
|
|
1158
|
+
} }, { key: "overflow", value: function(s) {
|
|
1159
|
+
return arguments.length ? (this.props.overflow = String(s), this) : this.props.overflow;
|
|
1160
|
+
} }, { key: "overflowLine", value: function(s) {
|
|
1161
|
+
return arguments.length ? (this.props.lineclamp = String(s), this) : this.props.lineclamp;
|
|
1162
|
+
} }, { key: "valign", value: function(s) {
|
|
1163
|
+
return arguments.length ? (this.props.valign = s, this) : this.props.valign;
|
|
1164
|
+
} }, { key: "align", value: function(s) {
|
|
1165
1165
|
if (!arguments.length) return this.props.align;
|
|
1166
|
-
var u = String(
|
|
1167
|
-
return u === "left" || u === "start" ? (this.props.align = "left", this.props.tAnchor = 0) : u === "center" || u === "middle" ? (this.props.align = "center", this.props.tAnchor = -0.5) : u === "end" || u === "right" ? (this.props.align = "right", this.props.tAnchor = -1) : u === "justify" && (this.props.align =
|
|
1168
|
-
} }, { key: "overflowWrap", value: function(
|
|
1166
|
+
var u = String(s).toLowerCase();
|
|
1167
|
+
return u === "left" || u === "start" ? (this.props.align = "left", this.props.tAnchor = 0) : u === "center" || u === "middle" ? (this.props.align = "center", this.props.tAnchor = -0.5) : u === "end" || u === "right" ? (this.props.align = "right", this.props.tAnchor = -1) : u === "justify" && (this.props.align = s, this.props.tAnchor = 0), this;
|
|
1168
|
+
} }, { key: "overflowWrap", value: function(s) {
|
|
1169
1169
|
if (!arguments.length) return this.props.overflowWrap || "normal";
|
|
1170
|
-
var u = String(
|
|
1171
|
-
return u === "break-word" ? this.props.overflowWrap = "break-word" : u !== "normal" &&
|
|
1172
|
-
} }, { key: "width", value: function(
|
|
1173
|
-
return arguments.length ? (this.props.width = ie(
|
|
1174
|
-
} }, { key: "height", value: function(
|
|
1175
|
-
return arguments.length ? (this.props.height = ie(
|
|
1176
|
-
} }, { key: "x", value: function(
|
|
1177
|
-
return arguments.length ? (this.props.x = ie(
|
|
1178
|
-
} }, { key: "parser", value: function(
|
|
1170
|
+
var u = String(s).toLowerCase();
|
|
1171
|
+
return u === "break-word" ? this.props.overflowWrap = "break-word" : u !== "normal" && s != null || (this.props.overflowWrap = null), this;
|
|
1172
|
+
} }, { key: "width", value: function(s) {
|
|
1173
|
+
return arguments.length ? (this.props.width = ie(s), this) : this.props.width;
|
|
1174
|
+
} }, { key: "height", value: function(s) {
|
|
1175
|
+
return arguments.length ? (this.props.height = ie(s), this) : this.props.height;
|
|
1176
|
+
} }, { key: "x", value: function(s) {
|
|
1177
|
+
return arguments.length ? (this.props.x = ie(s), this) : this.props.x;
|
|
1178
|
+
} }, { key: "parser", value: function(s) {
|
|
1179
1179
|
if (!arguments.length) return this.props.parser;
|
|
1180
|
-
if (typeof
|
|
1181
|
-
var u = e[
|
|
1182
|
-
typeof u == "function" && (
|
|
1180
|
+
if (typeof s == "string") {
|
|
1181
|
+
var u = e[s] || e[s + "parser"];
|
|
1182
|
+
typeof u == "function" && (s = u);
|
|
1183
1183
|
}
|
|
1184
|
-
if (typeof
|
|
1185
|
-
return this.props.parser =
|
|
1186
|
-
} }, { key: "createElement", value: function(
|
|
1187
|
-
return arguments.length ? (this.props.createElement =
|
|
1184
|
+
if (typeof s != "function") throw new Error("Unknown parser: " + s);
|
|
1185
|
+
return this.props.parser = s, this;
|
|
1186
|
+
} }, { key: "createElement", value: function(s) {
|
|
1187
|
+
return arguments.length ? (this.props.createElement = s, this) : this.props.createElement || e.createElement;
|
|
1188
1188
|
} }, { key: "render", value: function() {
|
|
1189
|
-
var
|
|
1190
|
-
return typeof
|
|
1189
|
+
var s = Ce(arguments);
|
|
1190
|
+
return typeof s.text == "string" && (s.text = this.linebreak(s.text)), s.ctx ? Pr(s.text, this, s.ctx) : Or(s.text, this);
|
|
1191
1191
|
} }], o && Fr(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1192
1192
|
}();
|
|
1193
1193
|
function It(e) {
|
|
@@ -1199,22 +1199,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1199
1199
|
}
|
|
1200
1200
|
function se(e, n) {
|
|
1201
1201
|
(n == null || n > e.length) && (n = e.length);
|
|
1202
|
-
for (var o = 0,
|
|
1203
|
-
return
|
|
1202
|
+
for (var o = 0, s = new Array(n); o < n; o++) s[o] = e[o];
|
|
1203
|
+
return s;
|
|
1204
1204
|
}
|
|
1205
1205
|
function Nr(e, n) {
|
|
1206
1206
|
for (var o = 0; o < n.length; o++) {
|
|
1207
|
-
var
|
|
1208
|
-
|
|
1207
|
+
var s = n[o];
|
|
1208
|
+
s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, (u = function(y, x) {
|
|
1209
1209
|
if (It(y) !== "object" || y === null) return y;
|
|
1210
1210
|
var v = y[Symbol.toPrimitive];
|
|
1211
1211
|
if (v !== void 0) {
|
|
1212
|
-
var S = v.call(y,
|
|
1212
|
+
var S = v.call(y, x);
|
|
1213
1213
|
if (It(S) !== "object") return S;
|
|
1214
1214
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1215
1215
|
}
|
|
1216
1216
|
return String(y);
|
|
1217
|
-
}(
|
|
1217
|
+
}(s.key, "string"), It(u) === "symbol" ? u : String(u)), s);
|
|
1218
1218
|
}
|
|
1219
1219
|
var u;
|
|
1220
1220
|
}
|
|
@@ -1223,38 +1223,38 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1223
1223
|
return e;
|
|
1224
1224
|
};
|
|
1225
1225
|
}, De = function() {
|
|
1226
|
-
function e(
|
|
1227
|
-
if (function(y,
|
|
1228
|
-
if (!(y instanceof
|
|
1226
|
+
function e(s) {
|
|
1227
|
+
if (function(y, x) {
|
|
1228
|
+
if (!(y instanceof x)) throw new TypeError("Cannot call a class as a function");
|
|
1229
1229
|
}(this, e), this.props = { width: function() {
|
|
1230
1230
|
return 1 / 0;
|
|
1231
1231
|
}, height: function() {
|
|
1232
1232
|
return 1 / 0;
|
|
1233
|
-
}, rotation: 0, vAnchor: 0, hAnchor: 0 },
|
|
1233
|
+
}, rotation: 0, vAnchor: 0, hAnchor: 0 }, s) for (var u in s) typeof this[u] == "function" && this[u](s[u]);
|
|
1234
1234
|
this.render = this.render.bind(this);
|
|
1235
1235
|
}
|
|
1236
1236
|
var n, o;
|
|
1237
|
-
return n = e, o = [{ key: "anchor", value: function(
|
|
1238
|
-
var u = this.props, y = u.hAnchor,
|
|
1239
|
-
if (!arguments.length) return [y * v(0),
|
|
1240
|
-
if (typeof
|
|
1237
|
+
return n = e, o = [{ key: "anchor", value: function(s) {
|
|
1238
|
+
var u = this.props, y = u.hAnchor, x = u.vAnchor, v = u.width, S = u.height;
|
|
1239
|
+
if (!arguments.length) return [y * v(0), x * S(0)];
|
|
1240
|
+
if (typeof s == "string") {
|
|
1241
1241
|
var _ = this.props;
|
|
1242
|
-
|
|
1242
|
+
s.toLowerCase().trim().split(/\s+/).forEach(function($) {
|
|
1243
1243
|
$ === "top" && (_.vAnchor = -0), $ === "middle" && (_.vAnchor = -0.5), $ === "bottom" && (_.vAnchor = -1), $ === "left" && (_.hAnchor = -0), $ === "center" && (_.hAnchor = -0.5), $ === "right" && (_.hAnchor = -1);
|
|
1244
1244
|
});
|
|
1245
1245
|
}
|
|
1246
1246
|
return this;
|
|
1247
|
-
} }, { key: "width", value: function(
|
|
1248
|
-
return arguments.length ? (this.props.width = _e(
|
|
1249
|
-
} }, { key: "height", value: function(
|
|
1250
|
-
return arguments.length ? (this.props.height = _e(
|
|
1251
|
-
} }, { key: "rotate", value: function(
|
|
1252
|
-
return arguments.length ? (this.props.rotation =
|
|
1253
|
-
} }, { key: "createElement", value: function(
|
|
1254
|
-
return arguments.length ? (this.props.createElement =
|
|
1255
|
-
} }, { key: "canvas", value: function(
|
|
1256
|
-
var y,
|
|
1257
|
-
return
|
|
1247
|
+
} }, { key: "width", value: function(s) {
|
|
1248
|
+
return arguments.length ? (this.props.width = _e(s), this) : this.props.width;
|
|
1249
|
+
} }, { key: "height", value: function(s) {
|
|
1250
|
+
return arguments.length ? (this.props.height = _e(s), this) : this.props.height;
|
|
1251
|
+
} }, { key: "rotate", value: function(s) {
|
|
1252
|
+
return arguments.length ? (this.props.rotation = s, this) : this.props.rotation;
|
|
1253
|
+
} }, { key: "createElement", value: function(s) {
|
|
1254
|
+
return arguments.length ? (this.props.createElement = s, this) : this.props.createElement || e.createElement;
|
|
1255
|
+
} }, { key: "canvas", value: function(s, u) {
|
|
1256
|
+
var y, x = s.getContext ? s.getContext("2d") : s;
|
|
1257
|
+
return x.save(), x.rotate(this.rotate() * Math.PI / 180), x.translate.apply(x, function(v) {
|
|
1258
1258
|
if (Array.isArray(v)) return se(v);
|
|
1259
1259
|
}(y = this.anchor()) || function(v) {
|
|
1260
1260
|
if (typeof Symbol < "u" && v[Symbol.iterator] != null || v["@@iterator"] != null) return Array.from(v);
|
|
@@ -1267,20 +1267,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1267
1267
|
}(y) || function() {
|
|
1268
1268
|
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1269
1269
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
1270
|
-
}()), u(
|
|
1270
|
+
}()), u(x), x.restore(), x;
|
|
1271
1271
|
} }, { key: "render", value: function() {
|
|
1272
|
-
var
|
|
1273
|
-
if (
|
|
1274
|
-
if (
|
|
1275
|
-
if (
|
|
1276
|
-
var u = typeof
|
|
1272
|
+
var s = Ce(arguments);
|
|
1273
|
+
if (s.d3) return s.d3.attr("transform", "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")"));
|
|
1274
|
+
if (s.ctx) return this.canvas(s.ctx, s.fn);
|
|
1275
|
+
if (s.text) {
|
|
1276
|
+
var u = typeof s.text.render == "function" ? s.text.render() : s.text;
|
|
1277
1277
|
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, u);
|
|
1278
1278
|
}
|
|
1279
1279
|
} }], o && Nr(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1280
1280
|
}(), jr = Object.prototype.hasOwnProperty, oe = {};
|
|
1281
1281
|
function Br(e) {
|
|
1282
|
-
return oe[e] || (oe[e] = e.replace(/([a-z])([A-Z])/g, function(n, o,
|
|
1283
|
-
return o + "-" +
|
|
1282
|
+
return oe[e] || (oe[e] = e.replace(/([a-z])([A-Z])/g, function(n, o, s) {
|
|
1283
|
+
return o + "-" + s.toLowerCase();
|
|
1284
1284
|
})), oe[e];
|
|
1285
1285
|
}
|
|
1286
1286
|
function Le(e, n) {
|
|
@@ -1292,8 +1292,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1292
1292
|
function Te(e, n) {
|
|
1293
1293
|
if (typeof document < "u") {
|
|
1294
1294
|
var o = typeof e == "string" ? document.createElementNS("http://www.w3.org/2000/svg", e) : e;
|
|
1295
|
-
if (n && o.setAttribute) for (var
|
|
1296
|
-
for (var u = arguments.length, y = new Array(u > 2 ? u - 2 : 0),
|
|
1295
|
+
if (n && o.setAttribute) for (var s in n) jr.call(n, s) && n[s] != null && o.setAttribute(s === "className" ? "class" : Br(s), n[s]);
|
|
1296
|
+
for (var u = arguments.length, y = new Array(u > 2 ? u - 2 : 0), x = 2; x < u; x++) y[x - 2] = arguments[x];
|
|
1297
1297
|
return y != null && y.length && y.forEach(function(v) {
|
|
1298
1298
|
Le(o, v);
|
|
1299
1299
|
}), o;
|
|
@@ -1301,25 +1301,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1301
1301
|
}
|
|
1302
1302
|
st.createElement = Te, st.textparser = jt, st.defaultparser = jt, st.htmlparser = function(e) {
|
|
1303
1303
|
e = String(e || "").trim();
|
|
1304
|
-
for (var n, o,
|
|
1305
|
-
for (var D in
|
|
1304
|
+
for (var n, o, s = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, u = [], y = [], x = function(I) {
|
|
1305
|
+
for (var D in s) s[D] && (I[D] = s[D]);
|
|
1306
1306
|
u.push(I);
|
|
1307
1307
|
}, v = function(I) {
|
|
1308
|
-
var D = u.length,
|
|
1309
|
-
if (D &&
|
|
1308
|
+
var D = u.length, O = xr[I];
|
|
1309
|
+
if (D && O) {
|
|
1310
1310
|
for (var B = D - 1; u[B] && (u[B] instanceof Tt || pr.test(u[B].value)); ) B--;
|
|
1311
|
-
for (;
|
|
1312
|
-
for (;
|
|
1311
|
+
for (; O && u[B] && u[B] instanceof et; ) B--, O--;
|
|
1312
|
+
for (; O-- > 0; ) u.push(new et());
|
|
1313
1313
|
}
|
|
1314
1314
|
}; e.length; ) {
|
|
1315
|
-
if (n = /^[^<]+/.exec(e)) jt(Ae(n[0]), !1).forEach(
|
|
1316
|
-
else if (!(n = vr.exec(e))) if (n = yr.exec(e)) y.length && (
|
|
1315
|
+
if (n = /^[^<]+/.exec(e)) jt(Ae(n[0]), !1).forEach(x);
|
|
1316
|
+
else if (!(n = vr.exec(e))) if (n = yr.exec(e)) y.length && (s = y.pop()), v(n[1]);
|
|
1317
1317
|
else if (n = mr.exec(e)) {
|
|
1318
1318
|
var S = n[1];
|
|
1319
|
-
v(S), y.push(
|
|
1319
|
+
v(S), y.push(s), s = Object.create(s), be[S] && be[S](s, "");
|
|
1320
1320
|
var _ = kr(n[2]);
|
|
1321
|
-
S === "a" && (_.href && (
|
|
1322
|
-
} else n = [e.slice(0, 1)],
|
|
1321
|
+
S === "a" && (_.href && (s.href = _.href), _.rel && (s.rel = _.rel), _.target && (s.target = _.target)), _.class && (s.class = s.class ? s.class + " " + _.class : _.class), _.style && (o = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(_.style)) && o[1] && (s.color = o[1]), S === "br" && u.push(new et());
|
|
1322
|
+
} else n = [e.slice(0, 1)], x(new j(n[0]));
|
|
1323
1323
|
e = e.slice(n[0].length);
|
|
1324
1324
|
}
|
|
1325
1325
|
for (var $ = u[u.length - 1]; $ instanceof et; ) u.pop(), $ = u[u.length - 1];
|
|
@@ -1342,46 +1342,46 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1342
1342
|
}).replace(/\\verb,(.*?),/, function(F, z) {
|
|
1343
1343
|
return "\\verb,".concat(n[+z], ",");
|
|
1344
1344
|
});
|
|
1345
|
-
for (var o,
|
|
1346
|
-
for (var z in
|
|
1345
|
+
for (var o, s = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, u = [], y = [], x = function(F) {
|
|
1346
|
+
for (var z in s) s[z] && (F[z] = s[z]);
|
|
1347
1347
|
return u.push(F), F;
|
|
1348
1348
|
}, v = function() {
|
|
1349
|
-
y.push(
|
|
1349
|
+
y.push(s), s = Object.create(s);
|
|
1350
1350
|
}, S = function() {
|
|
1351
1351
|
if (!y.length) throw new Error("Unexpected }");
|
|
1352
|
-
|
|
1353
|
-
}, _ = { tokens: u, open_context: v, close_context: S, add_token:
|
|
1354
|
-
if (o = Cr.exec(e)) jt(o[0], !1).forEach(
|
|
1355
|
-
else if (o = _r.exec(e))
|
|
1352
|
+
s = y.pop();
|
|
1353
|
+
}, _ = { tokens: u, open_context: v, close_context: S, add_token: x }; e.length; ) {
|
|
1354
|
+
if (o = Cr.exec(e)) jt(o[0], !1).forEach(x);
|
|
1355
|
+
else if (o = _r.exec(e)) x(new j(o[1]));
|
|
1356
1356
|
else if (!(o = Sr.exec(e))) {
|
|
1357
1357
|
if (o = /^\{/.exec(e)) v();
|
|
1358
1358
|
else if (o = /^\}/.exec(e)) S();
|
|
1359
|
-
else if (!(o = /^\$/.exec(e))) if (o = /^\\verb,([^,]+),/.exec(e))
|
|
1359
|
+
else if (!(o = /^\$/.exec(e))) if (o = /^\\verb,([^,]+),/.exec(e)) x(new j(o[1]));
|
|
1360
1360
|
else if (o = Er.exec(e)) {
|
|
1361
1361
|
var $ = o[1].slice(1) || o[1], I = !!o[2];
|
|
1362
1362
|
if (/^(La)?TeX$/i.test($)) {
|
|
1363
|
-
v(),
|
|
1363
|
+
v(), s.family = "serif";
|
|
1364
1364
|
var D = void 0;
|
|
1365
|
-
$ === "LaTeX" && ((D =
|
|
1366
|
-
} else if ($ in ke)
|
|
1365
|
+
$ === "LaTeX" && ((D = x(new j("L"))).tracking = -0.25, (D = x(new j("A"))).size = 0.7, D.baseline = 0.3, D.tracking = -0.1), (D = x(new j("T"))).tracking = -0.17, (D = x(new j("E"))).baseline = -0.22, D.tracking = -0.13, D = x(new j("X")), S();
|
|
1366
|
+
} else if ($ in ke) x(new j(ke[$])), I && v();
|
|
1367
1367
|
else if ($ in X) {
|
|
1368
|
-
var
|
|
1368
|
+
var O = [], B = X[$].length - 1, J = void 0;
|
|
1369
1369
|
if (B) {
|
|
1370
1370
|
for (I = !1, e = e.slice(o[0].length - 1); B--; ) {
|
|
1371
1371
|
if (!(J = /^\{([^}]+)\}/.exec(e))) throw new Error($ + " is missing an argument");
|
|
1372
|
-
|
|
1372
|
+
O.push(J[1]), e = e.slice(J[0].length);
|
|
1373
1373
|
}
|
|
1374
1374
|
o[0] = /^\{/.exec(e) ? "{" : "", I = !!o[0];
|
|
1375
1375
|
}
|
|
1376
|
-
I && v(), X[$].apply(_, [
|
|
1377
|
-
} else console.warn("unknown latex command", $),
|
|
1378
|
-
} else o = [e.slice(0, 1)],
|
|
1376
|
+
I && v(), X[$].apply(_, [s].concat(O));
|
|
1377
|
+
} else console.warn("unknown latex command", $), x(new j(o[1])), I && v();
|
|
1378
|
+
} else o = [e.slice(0, 1)], x(new j(o[0]));
|
|
1379
1379
|
}
|
|
1380
1380
|
e = e.slice(o[0].length);
|
|
1381
1381
|
}
|
|
1382
1382
|
return u;
|
|
1383
1383
|
}, st.measureText = function(e, n, o) {
|
|
1384
|
-
return
|
|
1384
|
+
return P(e, E(n), o);
|
|
1385
1385
|
}, st.Token = j, st.Break = Tt, st.LineBreak = et, st.SoftHyphen = yt, st.Rotator = De, De.createElement = Te;
|
|
1386
1386
|
const qr = st;
|
|
1387
1387
|
return r.default;
|
|
@@ -1397,12 +1397,12 @@ function de(l) {
|
|
|
1397
1397
|
return l.children[0].innerHTML;
|
|
1398
1398
|
}
|
|
1399
1399
|
function vn(l, t) {
|
|
1400
|
-
const
|
|
1401
|
-
if (
|
|
1400
|
+
const i = ft(l), { fontSize: r, font: a, padding: h = 0 } = l.properties.style || {};
|
|
1401
|
+
if (i.width === i.height && i.width === 0) return;
|
|
1402
1402
|
const c = new Re({
|
|
1403
1403
|
font: `${r}px/${r}px ${a}`.replace(/(px)+/g, "px"),
|
|
1404
|
-
width:
|
|
1405
|
-
height:
|
|
1404
|
+
width: i.width - h * 2,
|
|
1405
|
+
height: i.height - h * 2,
|
|
1406
1406
|
align: "left",
|
|
1407
1407
|
valign: "top",
|
|
1408
1408
|
x: 0,
|
|
@@ -1411,48 +1411,48 @@ function vn(l, t) {
|
|
|
1411
1411
|
createElement: Re.createElement
|
|
1412
1412
|
});
|
|
1413
1413
|
c.overflowWrap("break-word");
|
|
1414
|
-
const
|
|
1414
|
+
const d = c.linebreak(
|
|
1415
1415
|
l.properties.content.replaceAll(`
|
|
1416
1416
|
`, "<br>")
|
|
1417
|
-
).render(),
|
|
1417
|
+
).render(), f = [...d.children];
|
|
1418
1418
|
let g = 0;
|
|
1419
1419
|
const p = [];
|
|
1420
1420
|
l.properties.content.split(`
|
|
1421
|
-
`).forEach((
|
|
1422
|
-
let E =
|
|
1423
|
-
for (; E.length && g <
|
|
1424
|
-
if (
|
|
1421
|
+
`).forEach((A) => {
|
|
1422
|
+
let E = A;
|
|
1423
|
+
for (; E.length && g < f.length; ) {
|
|
1424
|
+
if (f[g].innerHTML === " ") {
|
|
1425
1425
|
E.startsWith(`
|
|
1426
1426
|
`) || p.push(g), g++;
|
|
1427
1427
|
break;
|
|
1428
1428
|
}
|
|
1429
|
-
const
|
|
1430
|
-
E.startsWith(
|
|
1429
|
+
const k = ce(de(f[g]));
|
|
1430
|
+
E.startsWith(k) && (E = E.slice(k.length).trim()), g++;
|
|
1431
1431
|
}
|
|
1432
|
-
}), p.forEach((
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1435
|
-
let E =
|
|
1436
|
-
const
|
|
1432
|
+
}), p.forEach((A) => d.removeChild(f[A]));
|
|
1433
|
+
const w = l.properties.content.match(/(https?:\/\/.*)/gm), b = w ? w.map((A) => A.split(" ")[0]) : [];
|
|
1434
|
+
d.setAttribute("transform", `translate(${h}, ${h})`), b.forEach((A) => {
|
|
1435
|
+
let E = A;
|
|
1436
|
+
const k = [];
|
|
1437
1437
|
for (; E.length > 0; ) {
|
|
1438
|
-
const L =
|
|
1438
|
+
const L = f.find(
|
|
1439
1439
|
(C) => !!C.children[0] && C.children[0].tagName === "tspan" && E.startsWith(ce(de(C)))
|
|
1440
1440
|
);
|
|
1441
1441
|
if (!L) break;
|
|
1442
|
-
|
|
1443
|
-
const
|
|
1444
|
-
if (!
|
|
1445
|
-
E = E.slice(
|
|
1442
|
+
k.push(L);
|
|
1443
|
+
const M = ce(L.children[0].innerHTML).length;
|
|
1444
|
+
if (!M) break;
|
|
1445
|
+
E = E.slice(M);
|
|
1446
1446
|
}
|
|
1447
|
-
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1447
|
+
k.forEach((L) => {
|
|
1448
|
+
const M = document.createElementNS("http://www.w3.org/2000/svg", "a");
|
|
1449
|
+
M.setAttribute("href", A), M.setAttribute("target", "_blank"), M.innerHTML = de(L), L.children[0].innerHTML = "", L.children[0].appendChild(M);
|
|
1450
1450
|
});
|
|
1451
|
-
}), t.appendChild(
|
|
1451
|
+
}), t.appendChild(d);
|
|
1452
1452
|
}
|
|
1453
1453
|
const We = 20;
|
|
1454
1454
|
class wn extends ar {
|
|
1455
|
-
constructor(t,
|
|
1455
|
+
constructor(t, i = {}) {
|
|
1456
1456
|
super(
|
|
1457
1457
|
t,
|
|
1458
1458
|
`
|
|
@@ -1474,20 +1474,20 @@ class wn extends ar {
|
|
|
1474
1474
|
this.isFocused = !1;
|
|
1475
1475
|
}), m(this, "startDrawing", (a, h, c = gn(a, h, 0, 0, "", Dt)) => {
|
|
1476
1476
|
this.add(c);
|
|
1477
|
-
const
|
|
1478
|
-
this.select(c.id), this.startDragging(this.getById(c.id),
|
|
1477
|
+
const d = this.ogma.view.graphToScreenCoordinates({ x: a, y: h });
|
|
1478
|
+
this.select(c.id), this.startDragging(this.getById(c.id), d.x, d.y), this.draggedHandle = 6;
|
|
1479
1479
|
}), m(this, "cancelDrawing", () => {
|
|
1480
1480
|
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...ue }, this.draggedHandle = U, this.isDragging = !1, this.emit(Lt, this.annotation));
|
|
1481
1481
|
}), m(this, "startDragging", (a, h, c) => {
|
|
1482
1482
|
this.annotation = a;
|
|
1483
|
-
const
|
|
1484
|
-
this.rect.x =
|
|
1483
|
+
const d = dt(this.annotation), f = ft(this.annotation);
|
|
1484
|
+
this.rect.x = d.x, this.rect.y = d.y, this.rect.width = f.width, this.rect.height = f.height, this.startX = h, this.startY = c, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Yt, this.annotation), this.isDragging = !0;
|
|
1485
1485
|
}), m(this, "onHandleMouseDown", (a) => {
|
|
1486
1486
|
const h = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
1487
1487
|
if (!h) return;
|
|
1488
1488
|
this.selectedId !== h.id && this.select(this.hoveredId);
|
|
1489
|
-
const { x: c, y:
|
|
1490
|
-
this.startDragging(h, c,
|
|
1489
|
+
const { x: c, y: d } = Vt(a, this.ogma.getContainer());
|
|
1490
|
+
this.startDragging(h, c, d), this.draggedHandle = tr(a.target);
|
|
1491
1491
|
}), m(this, "onMouseMove", (a) => {
|
|
1492
1492
|
requestAnimationFrame(() => this._onMouseMove(a));
|
|
1493
1493
|
}), m(this, "_onMouseMove", (a) => {
|
|
@@ -1495,16 +1495,16 @@ class wn extends ar {
|
|
|
1495
1495
|
a.stopPropagation(), a.preventDefault();
|
|
1496
1496
|
const h = this.handles[this.draggedHandle];
|
|
1497
1497
|
let c = h.classList.contains("top");
|
|
1498
|
-
const
|
|
1498
|
+
const d = h.classList.contains("left"), f = h.classList.contains("right"), g = h.classList.contains("bottom");
|
|
1499
1499
|
let p = h.classList.contains("line-handle");
|
|
1500
|
-
!p && !c && !g && !
|
|
1501
|
-
const { x:
|
|
1500
|
+
!p && !c && !g && !d && !f && (c = !0, p = !0);
|
|
1501
|
+
const { x: w, y: b } = Vt(
|
|
1502
1502
|
a,
|
|
1503
1503
|
this.ogma.getContainer()
|
|
1504
1504
|
);
|
|
1505
|
-
let
|
|
1506
|
-
const
|
|
1507
|
-
p ? (
|
|
1505
|
+
let A = this.rect.x, E = this.rect.y, k = Math.max(this.rect.width, We), L = Math.max(this.rect.height, We);
|
|
1506
|
+
const M = this.ogma.view.getZoom(), C = (w - this.startX) / M, N = (b - this.startY) / M, P = this.ogma.view.getAngle(), tt = nt({ x: C, y: N }, P), it = nt({ x: C, y: N }, -P);
|
|
1507
|
+
p ? (A = this.rect.x + tt.x, E = this.rect.y + tt.y) : d && c ? (A += tt.x, E += tt.y, k -= C, L -= N) : f && g ? (k += C, L += N) : d && g ? (A += it.x, k -= it.x, L += it.y) : f && c && (E += it.y, k += it.x, L -= it.y), Qr(this.annotation, A, E, k, L), this.emit(Zt, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
|
|
1508
1508
|
}), m(this, "onMouseUp", () => {
|
|
1509
1509
|
!this.isDragging || this.draggedHandle === U || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(Lt, this.annotation), this.isDragging = !1, this.draggedHandle = U);
|
|
1510
1510
|
}), m(this, "_onMousedown", (a) => {
|
|
@@ -1526,47 +1526,47 @@ class wn extends ar {
|
|
|
1526
1526
|
_canRemove() {
|
|
1527
1527
|
return !this.isFocused;
|
|
1528
1528
|
}
|
|
1529
|
-
detect({ x: t, y:
|
|
1530
|
-
const a = { x: t, y:
|
|
1529
|
+
detect({ x: t, y: i }, r = 0) {
|
|
1530
|
+
const a = { x: t, y: i }, h = this.ogma.view.getAngle();
|
|
1531
1531
|
return this.elements.find((c) => {
|
|
1532
|
-
const { x:
|
|
1533
|
-
return
|
|
1532
|
+
const { x: d, y: f } = dt(c), { width: g, height: p } = ft(c), w = { x: d, y: f }, { x: b, y: A } = nt(xt(a, w), -h);
|
|
1533
|
+
return b > -r && b < g + r && A > -r && A < p + r;
|
|
1534
1534
|
});
|
|
1535
1535
|
}
|
|
1536
1536
|
draw(t) {
|
|
1537
1537
|
t.innerHTML = "";
|
|
1538
|
-
const
|
|
1538
|
+
const i = "", r = this.ogma.view.getAngle();
|
|
1539
1539
|
for (let h = 0; h < this.elements.length; h++) {
|
|
1540
|
-
const c = this.elements[h],
|
|
1540
|
+
const c = this.elements[h], d = `class${h}`, f = ft(c), g = dt(c);
|
|
1541
1541
|
if (c.id === this.selectedId) continue;
|
|
1542
1542
|
const {
|
|
1543
1543
|
color: p,
|
|
1544
|
-
fontSize:
|
|
1545
|
-
font:
|
|
1546
|
-
strokeColor:
|
|
1544
|
+
fontSize: w,
|
|
1545
|
+
font: b,
|
|
1546
|
+
strokeColor: A,
|
|
1547
1547
|
strokeWidth: E,
|
|
1548
|
-
strokeType:
|
|
1548
|
+
strokeType: k,
|
|
1549
1549
|
background: L,
|
|
1550
|
-
borderRadius:
|
|
1550
|
+
borderRadius: M
|
|
1551
1551
|
} = c.properties.style || Dt, C = wt("g");
|
|
1552
|
-
C.classList.add("annotation-text"), C.setAttribute("fill", `${p}`), C.setAttribute("font-size", `${
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
-
let
|
|
1556
|
-
|
|
1552
|
+
C.classList.add("annotation-text"), C.setAttribute("fill", `${p}`), C.setAttribute("font-size", `${w}px`), C.setAttribute("font-family", `${b}`);
|
|
1553
|
+
const N = wt("rect");
|
|
1554
|
+
M && (N.setAttribute("rx", `${M}`), N.setAttribute("ry", `${M}`));
|
|
1555
|
+
let P = !1;
|
|
1556
|
+
k && k !== "none" && (P = !0, N.setAttribute("stroke", A || "black"), N.setAttribute("stroke-width", `${E}`), k === "dashed" && N.setAttribute("stroke-dasharray", "5,5")), (L && L.length || P) && (P = !0, N.setAttribute("fill", L || "transparent")), P && (N.setAttribute("width", `${f.width}`), N.setAttribute("height", `${f.height}`)), C.appendChild(N), vn(c, C);
|
|
1557
1557
|
const { x: tt, y: it } = nt(g, -r);
|
|
1558
|
-
C.setAttribute("transform", `translate(${tt},${it})`), C.classList.add(
|
|
1558
|
+
C.setAttribute("transform", `translate(${tt},${it})`), C.classList.add(d), C.setAttribute("data-annotation", `${c.id}`), C.setAttribute("data-annotation-type", "text"), t.appendChild(C);
|
|
1559
1559
|
}
|
|
1560
1560
|
const a = wt("style");
|
|
1561
|
-
a.innerHTML =
|
|
1561
|
+
a.innerHTML = i, t.firstChild && t.insertBefore(a, t.firstChild);
|
|
1562
1562
|
}
|
|
1563
1563
|
refreshDrawing() {
|
|
1564
|
-
const t = this.ogma.view.getAngle(),
|
|
1565
|
-
for (let r = 0; r <
|
|
1566
|
-
const a =
|
|
1564
|
+
const t = this.ogma.view.getAngle(), i = this.layer.element.children;
|
|
1565
|
+
for (let r = 0; r < i.length; r++) {
|
|
1566
|
+
const a = i[r];
|
|
1567
1567
|
if (!a.hasAttribute("data-annotation")) continue;
|
|
1568
|
-
const h = a.getAttribute("data-annotation"), c = dt(this.getById(h)), { x:
|
|
1569
|
-
a.setAttribute("transform", `translate(${
|
|
1568
|
+
const h = a.getAttribute("data-annotation"), c = dt(this.getById(h)), { x: d, y: f } = nt(c, -t);
|
|
1569
|
+
a.setAttribute("transform", `translate(${d},${f})`);
|
|
1570
1570
|
}
|
|
1571
1571
|
}
|
|
1572
1572
|
getDefaultOptions() {
|
|
@@ -1574,20 +1574,20 @@ class wn extends ar {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
refreshEditor() {
|
|
1576
1576
|
if (+this.selectedId < 0 && +this.hoveredId < 0) return;
|
|
1577
|
-
const t = this.getById(this.selectedId) || this.getById(this.hoveredId),
|
|
1577
|
+
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), i = ft(t), r = this.ogma.view.graphToScreenCoordinates(
|
|
1578
1578
|
dt(t)
|
|
1579
1579
|
), a = this.ogma.view.getZoom(), {
|
|
1580
1580
|
font: h,
|
|
1581
1581
|
fontSize: c,
|
|
1582
|
-
color:
|
|
1583
|
-
background:
|
|
1582
|
+
color: d,
|
|
1583
|
+
background: f,
|
|
1584
1584
|
padding: g = 0
|
|
1585
1585
|
} = t.properties.style || Dt, p = (c || 1) * a;
|
|
1586
1586
|
this.textArea.value = t.properties.content;
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1587
|
+
const w = this.editor.element.style;
|
|
1588
|
+
w.transform = `translate(${r.x}px, ${r.y}px)translate(-50%, -50%)translate(${i.width / 2 * a}px, ${i.height / 2 * a}px)`, w.width = `${i.width * a}px`, w.height = `${i.height * a}px`;
|
|
1589
|
+
const b = this.textArea.style;
|
|
1590
|
+
b.font = `${p} ${h}`, b.fontFamily = h || "sans-serif", b.fontSize = `${p}px`, b.padding = `${a * g}px`, b.lineHeight = `${p}px`, b.boxSizing = "border-box", b.color = d || "black", b.background = f || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
1591
1591
|
}
|
|
1592
1592
|
select(t) {
|
|
1593
1593
|
super.select(t), this.textArea.classList.add("noevents");
|
|
@@ -1600,49 +1600,49 @@ class xn {
|
|
|
1600
1600
|
constructor() {
|
|
1601
1601
|
m(this, "links", {}), m(this, "linksByTargetId", {}), m(this, "linksByArrowId", {});
|
|
1602
1602
|
}
|
|
1603
|
-
add(t,
|
|
1604
|
-
const c = Jt(),
|
|
1603
|
+
add(t, i, r, a, h) {
|
|
1604
|
+
const c = Jt(), d = t.id, f = {
|
|
1605
1605
|
id: c,
|
|
1606
|
-
arrow:
|
|
1606
|
+
arrow: d,
|
|
1607
1607
|
target: r,
|
|
1608
1608
|
targetType: a,
|
|
1609
1609
|
connectionPoint: h,
|
|
1610
|
-
side:
|
|
1610
|
+
side: i
|
|
1611
1611
|
};
|
|
1612
|
-
return this.links[c] =
|
|
1612
|
+
return this.links[c] = f, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(c), this.linksByArrowId[d] || (this.linksByArrowId[d] = {}), this.linksByArrowId[d][i] = c, t.properties.link = t.properties.link || {}, t.properties.link[i] = {
|
|
1613
1613
|
id: r,
|
|
1614
|
-
side:
|
|
1614
|
+
side: i,
|
|
1615
1615
|
type: a,
|
|
1616
1616
|
magnet: h
|
|
1617
1617
|
}, this;
|
|
1618
1618
|
}
|
|
1619
|
-
arrowIsLinked(t,
|
|
1619
|
+
arrowIsLinked(t, i) {
|
|
1620
1620
|
var r;
|
|
1621
|
-
return !!((r = this.linksByArrowId[t]) != null && r[
|
|
1621
|
+
return !!((r = this.linksByArrowId[t]) != null && r[i]);
|
|
1622
1622
|
}
|
|
1623
1623
|
// remove the link between the arrow and the target by arrow id and side
|
|
1624
|
-
remove(t,
|
|
1624
|
+
remove(t, i) {
|
|
1625
1625
|
var r, a;
|
|
1626
|
-
const h = t.id, c = (r = this.linksByArrowId[h]) == null ? void 0 : r[
|
|
1627
|
-
if ((a = t.properties.link) == null || delete a[
|
|
1628
|
-
const
|
|
1626
|
+
const h = t.id, c = (r = this.linksByArrowId[h]) == null ? void 0 : r[i];
|
|
1627
|
+
if ((a = t.properties.link) == null || delete a[i], !c) return this;
|
|
1628
|
+
const d = this.links[c];
|
|
1629
1629
|
delete this.links[c];
|
|
1630
|
-
const
|
|
1631
|
-
for (let g = 0; g <
|
|
1632
|
-
if (
|
|
1633
|
-
|
|
1630
|
+
const f = this.linksByTargetId[d.target];
|
|
1631
|
+
for (let g = 0; g < f.length; g++)
|
|
1632
|
+
if (f[g] === c) {
|
|
1633
|
+
f.splice(g, 1);
|
|
1634
1634
|
break;
|
|
1635
1635
|
}
|
|
1636
|
-
return delete this.linksByArrowId[h][
|
|
1636
|
+
return delete this.linksByArrowId[h][i], this;
|
|
1637
1637
|
}
|
|
1638
|
-
getArrowLink(t,
|
|
1638
|
+
getArrowLink(t, i) {
|
|
1639
1639
|
var r;
|
|
1640
|
-
const a = (r = this.linksByArrowId[t]) == null ? void 0 : r[
|
|
1640
|
+
const a = (r = this.linksByArrowId[t]) == null ? void 0 : r[i];
|
|
1641
1641
|
return a ? this.links[a] : null;
|
|
1642
1642
|
}
|
|
1643
|
-
getTargetLinks(t,
|
|
1643
|
+
getTargetLinks(t, i) {
|
|
1644
1644
|
var r;
|
|
1645
|
-
return ((r = this.linksByTargetId[t]) == null ? void 0 : r.map((a) => this.links[a]).filter((a) => a.targetType ===
|
|
1645
|
+
return ((r = this.linksByTargetId[t]) == null ? void 0 : r.map((a) => this.links[a]).filter((a) => a.targetType === i)) ?? [];
|
|
1646
1646
|
}
|
|
1647
1647
|
forEach(t) {
|
|
1648
1648
|
Object.values(this.links).forEach(t);
|
|
@@ -1669,29 +1669,29 @@ const ot = (l) => l.properties.type === "arrow", ct = (l) => l.properties.type =
|
|
|
1669
1669
|
{ x: 1, y: 1 }
|
|
1670
1670
|
];
|
|
1671
1671
|
class An extends or {
|
|
1672
|
-
constructor(t,
|
|
1672
|
+
constructor(t, i = {}) {
|
|
1673
1673
|
super(), m(this, "arrows"), m(this, "texts"), m(this, "links", new xn()), m(this, "layer"), m(this, "annotations"), m(this, "ogma"), m(this, "options"), m(this, "selected", null), m(this, "updateTimeout", 0), m(this, "hoveredNode", null), m(this, "dragged", null), m(this, "textToMagnet"), m(this, "activeLinks", []), m(this, "_render", (r) => {
|
|
1674
1674
|
if (!this.dragged || this.textToMagnet === void 0) return;
|
|
1675
1675
|
r.beginPath(), r.fillStyle = "green";
|
|
1676
1676
|
const a = this.ogma.view.getZoom();
|
|
1677
1677
|
Ge.forEach((h) => {
|
|
1678
1678
|
if (!this.textToMagnet) return;
|
|
1679
|
-
const c = ft(this.textToMagnet),
|
|
1680
|
-
r.moveTo(p,
|
|
1679
|
+
const c = ft(this.textToMagnet), d = dt(this.textToMagnet), f = Ut(h, { x: c.width, y: c.height }), g = nt(f, this.ogma.view.getAngle()), { x: p, y: w } = Ct(g, d);
|
|
1680
|
+
r.moveTo(p, w), r.arc(p, w, this.options.magnetHandleRadius / a, 0, Math.PI * 2);
|
|
1681
1681
|
}), r.fill(), r.closePath();
|
|
1682
1682
|
}), m(this, "_onFeatureDrag", (r, a) => {
|
|
1683
1683
|
const h = a;
|
|
1684
1684
|
if (ot(r) && h === "line")
|
|
1685
1685
|
["start", "end"].find((c) => {
|
|
1686
|
-
const
|
|
1687
|
-
return this._snapToText(r, h,
|
|
1686
|
+
const d = c === "start" ? zt(r) : Xt(r);
|
|
1687
|
+
return this._snapToText(r, h, d) || this._findAndSnapToNode(r, c, d);
|
|
1688
1688
|
});
|
|
1689
1689
|
else if (ot(r) && h !== "line") {
|
|
1690
1690
|
const c = h === "start" ? zt(r) : Xt(r);
|
|
1691
1691
|
this._snapToText(r, h, c) || this._findAndSnapToNode(r, h, c);
|
|
1692
|
-
} else ct(r) && (this.activeLinks.forEach(({ arrow: c, side:
|
|
1693
|
-
const g = this.getAnnotation(c), p = ft(r),
|
|
1694
|
-
g.geometry.coordinates[
|
|
1692
|
+
} else ct(r) && (this.activeLinks.forEach(({ arrow: c, side: d, connectionPoint: f }) => {
|
|
1693
|
+
const g = this.getAnnotation(c), p = ft(r), w = dt(r), b = Ut(f, { x: p.width, y: p.height }), A = nt(b, this.ogma.view.getAngle()), E = Ct(A, w);
|
|
1694
|
+
g.geometry.coordinates[d === "start" ? 0 : 1] = [E.x, E.y];
|
|
1695
1695
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
1696
1696
|
this.layer.refresh(), this.emit(Zt, r, a);
|
|
1697
1697
|
}), m(this, "_onFeatureDragEnd", (r) => {
|
|
@@ -1714,11 +1714,11 @@ class An extends or {
|
|
|
1714
1714
|
}), m(this, "_onLayoutEnd", (r) => {
|
|
1715
1715
|
r.ids.forEach((a, h) => {
|
|
1716
1716
|
this.links.getTargetLinks(a, "node").forEach((c) => {
|
|
1717
|
-
const
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
), p = r.positions.current[h],
|
|
1721
|
-
St(
|
|
1717
|
+
const d = this.getAnnotation(c.arrow), f = c.side, g = Rt(
|
|
1718
|
+
d,
|
|
1719
|
+
f === "start" ? "end" : "start"
|
|
1720
|
+
), p = r.positions.current[h], w = this.ogma.getNode(a).getAttribute("radius"), b = Wt(g, p, +w);
|
|
1721
|
+
St(d, f, b.x, b.y);
|
|
1722
1722
|
});
|
|
1723
1723
|
}), this.arrows.refreshLayer(), this.texts.refreshLayer();
|
|
1724
1724
|
}), m(this, "_onAdded", (r) => {
|
|
@@ -1735,57 +1735,57 @@ class An extends or {
|
|
|
1735
1735
|
);
|
|
1736
1736
|
}), m(this, "_onUpdate", (r) => {
|
|
1737
1737
|
this.emit(me, r);
|
|
1738
|
-
}), this.options = this.setOptions({ ...bn, ...
|
|
1738
|
+
}), this.options = this.setOptions({ ...bn, ...i }), this.ogma = t, this.arrows = new fn(t, this.options), this.texts = new wn(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((r) => {
|
|
1739
1739
|
r.on(Yt, this._onFeatureDragStart).on(Zt, this._onFeatureDrag).on(Lt, this._onFeatureDragEnd).on(me, this.onUpdate).on(ge, this._onUnselect).on(fe, this._onSelect).on(ye, this._onAdded).on(pe, this._onRemoved);
|
|
1740
1740
|
}), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd).on(["viewChanged", "rotate"], () => {
|
|
1741
1741
|
this.refreshTextLinks();
|
|
1742
1742
|
}), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
1743
1743
|
}
|
|
1744
|
-
_moveNodes(t,
|
|
1744
|
+
_moveNodes(t, i, r) {
|
|
1745
1745
|
t.forEach((a) => {
|
|
1746
1746
|
const h = this.links.getTargetLinks(a.getId(), "node"), c = a.getPosition();
|
|
1747
|
-
h.forEach((
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1747
|
+
h.forEach((d) => {
|
|
1748
|
+
const f = this.getAnnotation(d.arrow), g = d.side, p = Rt(
|
|
1749
|
+
f,
|
|
1750
1750
|
g === "start" ? "end" : "start"
|
|
1751
1751
|
);
|
|
1752
|
-
let
|
|
1753
|
-
const
|
|
1754
|
-
(
|
|
1752
|
+
let w = c;
|
|
1753
|
+
const b = +a.getAttribute("radius"), A = 1e-6;
|
|
1754
|
+
(d.connectionPoint.x - (c.x - i) > A || d.connectionPoint.y - (c.y - r) > A) && (w = Wt(p, c, b)), St(f, g, w.x, w.y);
|
|
1755
1755
|
});
|
|
1756
1756
|
}), this.arrows.refreshLayer();
|
|
1757
1757
|
}
|
|
1758
|
-
_snapToText(t,
|
|
1758
|
+
_snapToText(t, i, r) {
|
|
1759
1759
|
const a = this.texts.detect(r, this.options.detectMargin);
|
|
1760
|
-
if (this.links.remove(t,
|
|
1760
|
+
if (this.links.remove(t, i), !a) return !1;
|
|
1761
1761
|
this.textToMagnet = a;
|
|
1762
1762
|
const h = this.findMagnetPoint(Ge, a, r);
|
|
1763
|
-
return h ? (St(t,
|
|
1763
|
+
return h ? (St(t, i, h.point.x, h.point.y), this.links.add(t, i, a.id, "text", h.magnet), !0) : !1;
|
|
1764
1764
|
}
|
|
1765
|
-
_findAndSnapToNode(t,
|
|
1765
|
+
_findAndSnapToNode(t, i, r) {
|
|
1766
1766
|
var a, h;
|
|
1767
|
-
const c = this.ogma.view.graphToScreenCoordinates(r),
|
|
1768
|
-
this.links.remove(t,
|
|
1769
|
-
}
|
|
1770
|
-
_snapToNode(t,
|
|
1771
|
-
const h = r.getPositionOnScreen(), c = +r.getAttribute("radius"),
|
|
1772
|
-
if (p <
|
|
1773
|
-
let
|
|
1774
|
-
if (p >
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1767
|
+
const c = this.ogma.view.graphToScreenCoordinates(r), d = this.ogma.view.getElementAt(c);
|
|
1768
|
+
this.links.remove(t, i), d && d.isNode ? ((a = this.hoveredNode) == null || a.setSelected(!1), this.hoveredNode = d, d.setSelected(!0), this._snapToNode(t, i, d, c)) : ((h = this.hoveredNode) == null || h.setSelected(!1), this.hoveredNode = null);
|
|
1769
|
+
}
|
|
1770
|
+
_snapToNode(t, i, r, a) {
|
|
1771
|
+
const h = r.getPositionOnScreen(), c = +r.getAttribute("radius"), d = c * this.ogma.view.getZoom(), f = a.x - h.x, g = a.y - h.y, p = Math.sqrt(f * f + g * g), w = r.getPosition();
|
|
1772
|
+
if (p < d + this.options.detectMargin) {
|
|
1773
|
+
let b = w;
|
|
1774
|
+
if (p > d / 2) {
|
|
1775
|
+
const A = Rt(t, i === "end" ? "start" : "end");
|
|
1776
|
+
b = Wt(A, b, c);
|
|
1777
1777
|
}
|
|
1778
|
-
St(t,
|
|
1778
|
+
St(t, i, b.x, b.y), this.links.add(t, i, r.getId(), "node", b);
|
|
1779
1779
|
}
|
|
1780
1780
|
}
|
|
1781
1781
|
refreshTextLinks() {
|
|
1782
1782
|
let t = !1;
|
|
1783
1783
|
this.links.forEach(
|
|
1784
|
-
({ connectionPoint:
|
|
1784
|
+
({ connectionPoint: i, targetType: r, target: a, arrow: h, side: c }) => {
|
|
1785
1785
|
if (r !== "text") return;
|
|
1786
1786
|
t = !0;
|
|
1787
|
-
const
|
|
1788
|
-
St(
|
|
1787
|
+
const d = this.getAnnotation(a), f = this.getAnnotation(h), g = ft(d), p = dt(d), w = Ut(i, { x: g.width, y: g.height }), b = nt(w, this.ogma.view.getAngle()), A = Ct(b, p);
|
|
1788
|
+
St(f, c, A.x, A.y);
|
|
1789
1789
|
}
|
|
1790
1790
|
), t && this.arrows.refreshLayer();
|
|
1791
1791
|
}
|
|
@@ -1795,16 +1795,16 @@ class An extends or {
|
|
|
1795
1795
|
getSelected() {
|
|
1796
1796
|
return this.selected;
|
|
1797
1797
|
}
|
|
1798
|
-
findMagnetPoint(t,
|
|
1798
|
+
findMagnetPoint(t, i, r) {
|
|
1799
1799
|
let a;
|
|
1800
1800
|
for (const h of t) {
|
|
1801
|
-
const c = ft(
|
|
1801
|
+
const c = ft(i), d = dt(i), f = Ut(h, { x: c.width, y: c.height }), g = nt(f, this.ogma.view.getAngle()), p = Ct(g, d), w = _t(xt(p, r)), b = Math.min(
|
|
1802
1802
|
this.options.magnetRadius * this.ogma.view.getZoom(),
|
|
1803
1803
|
// when really zoomed in: avoid to snap on too far away magnets
|
|
1804
1804
|
c.width / 2,
|
|
1805
1805
|
c.height / 2
|
|
1806
1806
|
);
|
|
1807
|
-
if (
|
|
1807
|
+
if (w < Math.max(b, this.options.magnetHandleRadius)) {
|
|
1808
1808
|
a = {
|
|
1809
1809
|
point: p,
|
|
1810
1810
|
magnet: h
|
|
@@ -1830,8 +1830,8 @@ class An extends or {
|
|
|
1830
1830
|
* @param id the id of the annotation to select
|
|
1831
1831
|
*/
|
|
1832
1832
|
select(t) {
|
|
1833
|
-
const
|
|
1834
|
-
return
|
|
1833
|
+
const i = this.getAnnotations().features.find((r) => r.id === t);
|
|
1834
|
+
return i ? (ot(i) ? this.arrows.select(i.id) : ct(i) && this.texts.select(i.id), this) : this;
|
|
1835
1835
|
}
|
|
1836
1836
|
/**
|
|
1837
1837
|
* Unselects the currently selected annotation
|
|
@@ -1845,11 +1845,11 @@ class An extends or {
|
|
|
1845
1845
|
*/
|
|
1846
1846
|
add(t) {
|
|
1847
1847
|
if (Ue(t)) {
|
|
1848
|
-
const [
|
|
1848
|
+
const [i, r] = t.features.reduce(
|
|
1849
1849
|
(a, h) => (ot(h) ? a[1].push(h) : ct(h) && a[0].push(h), a),
|
|
1850
1850
|
[[], []]
|
|
1851
1851
|
);
|
|
1852
|
-
return
|
|
1852
|
+
return i.forEach((a) => this.add(a)), r.forEach((a) => this.add(a)), this.arrows.refreshLayer(), this;
|
|
1853
1853
|
}
|
|
1854
1854
|
switch (t.properties.type) {
|
|
1855
1855
|
case "text":
|
|
@@ -1868,26 +1868,26 @@ class An extends or {
|
|
|
1868
1868
|
*/
|
|
1869
1869
|
remove(t) {
|
|
1870
1870
|
return Ue(t) ? (t.features.forEach(
|
|
1871
|
-
(
|
|
1871
|
+
(i) => this.remove(i)
|
|
1872
1872
|
), this) : (ot(t) ? (this.links.remove(t, "start"), this.links.remove(t, "end"), this.arrows.remove(t.id)) : this.texts.remove(t.id), this);
|
|
1873
1873
|
}
|
|
1874
1874
|
loadLink(t) {
|
|
1875
1875
|
if (t.properties.link)
|
|
1876
|
-
for (const
|
|
1877
|
-
const r = t.properties.link[
|
|
1876
|
+
for (const i of Xe) {
|
|
1877
|
+
const r = t.properties.link[i];
|
|
1878
1878
|
if (!r) continue;
|
|
1879
1879
|
const a = this.getAnnotation(r.id);
|
|
1880
1880
|
if (r.type === "text" && a)
|
|
1881
|
-
this.links.add(t,
|
|
1881
|
+
this.links.add(t, i, r.id, r.type, r.magnet);
|
|
1882
1882
|
else if (r.type === "node") {
|
|
1883
1883
|
const h = this.ogma.getNode(r.id);
|
|
1884
1884
|
if (!h) continue;
|
|
1885
|
-
this.links.add(t,
|
|
1886
|
-
const c = h.getPosition(),
|
|
1885
|
+
this.links.add(t, i, r.id, r.type, r.magnet);
|
|
1886
|
+
const c = h.getPosition(), d = h.getAttribute("radius") || 0, f = Rt(
|
|
1887
1887
|
t,
|
|
1888
|
-
|
|
1889
|
-
), g = Wt(
|
|
1890
|
-
St(t,
|
|
1888
|
+
i === "start" ? "end" : "start"
|
|
1889
|
+
), g = Wt(f, c, +d);
|
|
1890
|
+
St(t, i, g.x, g.y);
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
1893
|
}
|
|
@@ -1897,8 +1897,8 @@ class An extends or {
|
|
|
1897
1897
|
* @param y coord of the first point
|
|
1898
1898
|
* @param arrow The arrow to add
|
|
1899
1899
|
*/
|
|
1900
|
-
startArrow(t,
|
|
1901
|
-
this.cancelDrawing(), this.arrows.startDrawing(t,
|
|
1900
|
+
startArrow(t, i, r) {
|
|
1901
|
+
this.cancelDrawing(), this.arrows.startDrawing(t, i, r);
|
|
1902
1902
|
}
|
|
1903
1903
|
/**
|
|
1904
1904
|
* Start adding a text (add it, and give control to the user)
|
|
@@ -1906,8 +1906,8 @@ class An extends or {
|
|
|
1906
1906
|
* @param y coord of the top left point
|
|
1907
1907
|
* @param text The text to add
|
|
1908
1908
|
*/
|
|
1909
|
-
startText(t,
|
|
1910
|
-
this.cancelDrawing(), this.texts.startDrawing(t,
|
|
1909
|
+
startText(t, i, r) {
|
|
1910
|
+
this.cancelDrawing(), this.texts.startDrawing(t, i, r);
|
|
1911
1911
|
}
|
|
1912
1912
|
/**
|
|
1913
1913
|
* Cancel drawing on the current frame
|
|
@@ -1920,13 +1920,13 @@ class An extends or {
|
|
|
1920
1920
|
* @param id The id of the annotation to update
|
|
1921
1921
|
* @param style The new style
|
|
1922
1922
|
*/
|
|
1923
|
-
updateStyle(t,
|
|
1923
|
+
updateStyle(t, i) {
|
|
1924
1924
|
const r = this.getAnnotations().features.find((a) => a.id === t);
|
|
1925
|
-
return r ? (ot(r) ? this.arrows.updateStyle(r,
|
|
1925
|
+
return r ? (ot(r) ? this.arrows.updateStyle(r, i) : ct(r) && this.texts.updateStyle(r, i), this.onUpdate(r), this) : this;
|
|
1926
1926
|
}
|
|
1927
|
-
setScale(t,
|
|
1927
|
+
setScale(t, i, r, a) {
|
|
1928
1928
|
const h = this.getAnnotations().features.find((c) => c.id === t);
|
|
1929
|
-
return h ? (ot(h) ? this.arrows.scale(h,
|
|
1929
|
+
return h ? (ot(h) ? this.arrows.scale(h, i, r, a) : ct(h) && this.texts.scale(h, i, r, a), this.onUpdate(h), this) : this;
|
|
1930
1930
|
}
|
|
1931
1931
|
/**
|
|
1932
1932
|
* @returns the annotations in the controller
|
|
@@ -1936,8 +1936,8 @@ class An extends or {
|
|
|
1936
1936
|
type: "FeatureCollection",
|
|
1937
1937
|
features: []
|
|
1938
1938
|
};
|
|
1939
|
-
return this.annotations.forEach((
|
|
1940
|
-
t.features = [...t.features, ...
|
|
1939
|
+
return this.annotations.forEach((i) => {
|
|
1940
|
+
t.features = [...t.features, ...i.getElements()];
|
|
1941
1941
|
}), t;
|
|
1942
1942
|
}
|
|
1943
1943
|
/**
|
|
@@ -1946,7 +1946,7 @@ class An extends or {
|
|
|
1946
1946
|
* @returns The annotation with the given id
|
|
1947
1947
|
*/
|
|
1948
1948
|
getAnnotation(t) {
|
|
1949
|
-
return this.getAnnotations().features.find((
|
|
1949
|
+
return this.getAnnotations().features.find((i) => i.id === t);
|
|
1950
1950
|
}
|
|
1951
1951
|
/**
|
|
1952
1952
|
* Destroy the controller and its elements
|
|
@@ -1993,13 +1993,13 @@ const Ve = [8, 10, 12, 14, 16, 24, 32, 48, 64, 72], Ze = "none", lr = "#333333",
|
|
|
1993
1993
|
background: Ze
|
|
1994
1994
|
};
|
|
1995
1995
|
function Cn(l) {
|
|
1996
|
-
return l.reduce((t,
|
|
1996
|
+
return l.reduce((t, i) => t + i, 0) / l.length;
|
|
1997
1997
|
}
|
|
1998
|
-
function In(l, t = 0,
|
|
1999
|
-
return t + (
|
|
1998
|
+
function In(l, t = 0, i = 1) {
|
|
1999
|
+
return t + (i - t) * l;
|
|
2000
2000
|
}
|
|
2001
|
-
function Mn(l, t = 0,
|
|
2002
|
-
return (l - t) / (
|
|
2001
|
+
function Mn(l, t = 0, i = 1) {
|
|
2002
|
+
return (l - t) / (i - t);
|
|
2003
2003
|
}
|
|
2004
2004
|
function On() {
|
|
2005
2005
|
return Ye(null);
|
|
@@ -2016,63 +2016,69 @@ const hr = Ye(
|
|
|
2016
2016
|
case "remove":
|
|
2017
2017
|
return {
|
|
2018
2018
|
...l,
|
|
2019
|
-
features: l.features.filter((
|
|
2019
|
+
features: l.features.filter((i) => i.id !== t.payload.id)
|
|
2020
2020
|
};
|
|
2021
2021
|
case "update":
|
|
2022
2022
|
return {
|
|
2023
2023
|
...l,
|
|
2024
2024
|
features: l.features.map(
|
|
2025
|
-
(
|
|
2025
|
+
(i) => i.id === t.payload.id ? t.payload : i
|
|
2026
2026
|
)
|
|
2027
2027
|
};
|
|
2028
2028
|
default:
|
|
2029
2029
|
return l;
|
|
2030
2030
|
}
|
|
2031
|
-
}, Pn = ({
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2031
|
+
}, Pn = ({
|
|
2032
|
+
children: l,
|
|
2033
|
+
annotations: t
|
|
2034
|
+
}) => {
|
|
2035
|
+
const i = Gr(), [r, a] = Xr(
|
|
2036
|
+
_n,
|
|
2037
|
+
t || {
|
|
2038
|
+
type: "FeatureCollection",
|
|
2039
|
+
features: []
|
|
2040
|
+
}
|
|
2041
|
+
), [h, c] = Et(null), [d, f] = Et(kn), [g, p] = Et(Sn), [w, b] = Et(), [A, E] = Et(1), [k, L] = Et(1);
|
|
2036
2042
|
return he(() => {
|
|
2037
|
-
if (!
|
|
2038
|
-
const
|
|
2043
|
+
if (!i) return;
|
|
2044
|
+
const M = new An(i, {
|
|
2039
2045
|
minArrowHeight: 1
|
|
2040
|
-
}),
|
|
2046
|
+
}), C = Cn(i.getNodes().getAttribute("radius")) / 5, N = A;
|
|
2041
2047
|
return f({
|
|
2042
|
-
...
|
|
2043
|
-
strokeWidth: (
|
|
2044
|
-
}),
|
|
2048
|
+
...d,
|
|
2049
|
+
strokeWidth: (d.strokeWidth || 1) * N
|
|
2050
|
+
}), E(N), L(C), M.on("select", (P) => {
|
|
2045
2051
|
ot(P) ? f({
|
|
2046
2052
|
...P.properties.style || {}
|
|
2047
|
-
}) : ct(P) &&
|
|
2053
|
+
}) : ct(P) && p({
|
|
2048
2054
|
...P.properties.style || {}
|
|
2049
|
-
}),
|
|
2055
|
+
}), c(P);
|
|
2050
2056
|
}).on("unselect", () => {
|
|
2051
|
-
|
|
2052
|
-
}), b(
|
|
2053
|
-
|
|
2057
|
+
c(null);
|
|
2058
|
+
}), b(M), t && M.add(t), () => {
|
|
2059
|
+
M.destroy();
|
|
2054
2060
|
};
|
|
2055
|
-
}, [
|
|
2056
|
-
|
|
2057
|
-
}, [
|
|
2058
|
-
|
|
2059
|
-
}, [
|
|
2061
|
+
}, [i]), he(() => {
|
|
2062
|
+
w && h && (h == null ? void 0 : h.properties.type) === "arrow" && w.updateStyle(h.id, d);
|
|
2063
|
+
}, [w, d, h]), he(() => {
|
|
2064
|
+
w && h && (h == null ? void 0 : h.properties.type) === "text" && w.updateStyle(h.id, g);
|
|
2065
|
+
}, [w, g, h]), /* @__PURE__ */ Wr.createElement(
|
|
2060
2066
|
hr.Provider,
|
|
2061
2067
|
{
|
|
2062
2068
|
value: {
|
|
2063
|
-
annotations:
|
|
2064
|
-
updateAnnotations:
|
|
2065
|
-
currentAnnotation:
|
|
2066
|
-
setCurrentAnnotation:
|
|
2067
|
-
textStyle:
|
|
2068
|
-
setTextStyle:
|
|
2069
|
-
arrowStyle:
|
|
2069
|
+
annotations: r,
|
|
2070
|
+
updateAnnotations: a,
|
|
2071
|
+
currentAnnotation: h,
|
|
2072
|
+
setCurrentAnnotation: c,
|
|
2073
|
+
textStyle: g,
|
|
2074
|
+
setTextStyle: p,
|
|
2075
|
+
arrowStyle: d,
|
|
2070
2076
|
setArrowStyle: f,
|
|
2071
2077
|
arrowWidthFactor: A,
|
|
2072
|
-
setArrowWidthFactor:
|
|
2073
|
-
textSizeFactor:
|
|
2074
|
-
setTextSizeFactor:
|
|
2075
|
-
editor:
|
|
2078
|
+
setArrowWidthFactor: E,
|
|
2079
|
+
textSizeFactor: k,
|
|
2080
|
+
setTextSizeFactor: L,
|
|
2081
|
+
editor: w,
|
|
2076
2082
|
setEditor: b
|
|
2077
2083
|
}
|
|
2078
2084
|
},
|