@linkurious/ogma-annotations 1.0.5
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.mjs +2445 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +23 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/types/Control.d.ts +104 -0
- package/dist/types/Editor/Arrows/defaults.d.ts +10 -0
- package/dist/types/Editor/Arrows/index.d.ts +38 -0
- package/dist/types/Editor/Arrows/render.d.ts +13 -0
- package/dist/types/Editor/Texts/defaults.d.ts +5 -0
- package/dist/types/Editor/Texts/index.d.ts +40 -0
- package/dist/types/Editor/Texts/render.d.ts +7 -0
- package/dist/types/Editor/base.d.ts +81 -0
- package/dist/types/constants.d.ts +13 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/links.d.ts +20 -0
- package/dist/types/types.d.ts +172 -0
- package/dist/types/utils.d.ts +48 -0
- package/package.json +78 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2445 @@
|
|
|
1
|
+
var En = Object.defineProperty;
|
|
2
|
+
var kn = (u, l, t) => l in u ? En(u, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[l] = t;
|
|
3
|
+
var m = (u, l, t) => (kn(u, typeof l != "symbol" ? l + "" : l, t), t);
|
|
4
|
+
var Tn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
5
|
+
function oe(u) {
|
|
6
|
+
return u && u.__esModule && Object.prototype.hasOwnProperty.call(u, "default") ? u.default : u;
|
|
7
|
+
}
|
|
8
|
+
var Pe = { exports: {} };
|
|
9
|
+
(function(u) {
|
|
10
|
+
(function(l, t) {
|
|
11
|
+
u.exports = t();
|
|
12
|
+
})("Vector", function() {
|
|
13
|
+
var l = function() {
|
|
14
|
+
var t = Math.PI * 2, s = 180 / Math.PI, a = Math.PI / 180;
|
|
15
|
+
function c(r) {
|
|
16
|
+
return Math.round(r * 1e8) / 1e8;
|
|
17
|
+
}
|
|
18
|
+
function g(r, d) {
|
|
19
|
+
var v = d.x - r.x, T = d.y - r.y;
|
|
20
|
+
return Math.sqrt(v * v + T * T);
|
|
21
|
+
}
|
|
22
|
+
function y(r, d, v) {
|
|
23
|
+
var T = d.y - r.y, _ = d.x - r.x, E = Math.atan2(T, _);
|
|
24
|
+
if (v)
|
|
25
|
+
for (; E < 0; )
|
|
26
|
+
E += t;
|
|
27
|
+
return E;
|
|
28
|
+
}
|
|
29
|
+
function f(r, d) {
|
|
30
|
+
this.x = r !== void 0 ? r : 0, this.y = d !== void 0 ? d : 0;
|
|
31
|
+
}
|
|
32
|
+
return f.fromRadians = function(r) {
|
|
33
|
+
var d = Math.cos(r), v = Math.sin(r);
|
|
34
|
+
return new f(d, v);
|
|
35
|
+
}, f.fromDegrees = function(r) {
|
|
36
|
+
var d = r * (Math.PI / 180);
|
|
37
|
+
return f.fromRadians(d);
|
|
38
|
+
}, f.fromString = function(r) {
|
|
39
|
+
var d = r.split(",");
|
|
40
|
+
return new f(parseFloat(d[0]), parseFloat(d[1]));
|
|
41
|
+
}, f.fromArray = function(r) {
|
|
42
|
+
return new f(r[0], r[1]);
|
|
43
|
+
}, f.prototype = {
|
|
44
|
+
// version
|
|
45
|
+
version: "2.0.1",
|
|
46
|
+
// [API]
|
|
47
|
+
// [chainable, clone]
|
|
48
|
+
// clone the vector and return the cloned instance.
|
|
49
|
+
// @return cloned vector.
|
|
50
|
+
clone: function() {
|
|
51
|
+
return new f(this.x, this.y);
|
|
52
|
+
},
|
|
53
|
+
// [API]
|
|
54
|
+
// []
|
|
55
|
+
// Get if equal to another vector
|
|
56
|
+
// @param vector - other vector to compare with.
|
|
57
|
+
// @return if vectors are equal.
|
|
58
|
+
equals: function(r) {
|
|
59
|
+
return this.prototype === r.prototype && this.x === r.x && this.y === r.y;
|
|
60
|
+
},
|
|
61
|
+
// [API]
|
|
62
|
+
// [chainable, changeSelf]
|
|
63
|
+
// set values from another vector. this changes value of self.
|
|
64
|
+
// @param vector - other vector to get values from.
|
|
65
|
+
// @return self.
|
|
66
|
+
copy: function(r) {
|
|
67
|
+
return this.x = r.x, this.y = r.y, this;
|
|
68
|
+
},
|
|
69
|
+
// [API]
|
|
70
|
+
// [chainable, changeSelf]
|
|
71
|
+
// set only the x component from another vector.
|
|
72
|
+
// @return self.
|
|
73
|
+
copyX: function(r) {
|
|
74
|
+
return this.x = r.x, this;
|
|
75
|
+
},
|
|
76
|
+
// [API]
|
|
77
|
+
// [chainable, changeSelf]
|
|
78
|
+
// set only the y component from another vector.
|
|
79
|
+
// @return self.
|
|
80
|
+
copyY: function(r) {
|
|
81
|
+
return this.y = r.y, this;
|
|
82
|
+
},
|
|
83
|
+
// [API]
|
|
84
|
+
// []
|
|
85
|
+
// convert to a dictionary with {x, y}.
|
|
86
|
+
// @return a dictionary representation of the vector.
|
|
87
|
+
toDict: function() {
|
|
88
|
+
return { x: this.x, y: this.y };
|
|
89
|
+
},
|
|
90
|
+
// [API]
|
|
91
|
+
// []
|
|
92
|
+
// convert to array with [x, y].
|
|
93
|
+
// @return an array representation of the vector.
|
|
94
|
+
toArray: function() {
|
|
95
|
+
return [this.x, this.y];
|
|
96
|
+
},
|
|
97
|
+
// [API]
|
|
98
|
+
// [chainable, changeSelf]
|
|
99
|
+
// set values from x, y.
|
|
100
|
+
// @param x - optional x component to set.
|
|
101
|
+
// @param y - optional y component to set.
|
|
102
|
+
// @return self.
|
|
103
|
+
set: function(r, d) {
|
|
104
|
+
return r !== void 0 && (this.x = r), d !== void 0 && (this.y = d), this;
|
|
105
|
+
},
|
|
106
|
+
// [API]
|
|
107
|
+
// [chainable, clone]
|
|
108
|
+
// clone and flip between x and y values.
|
|
109
|
+
// @return cloned vector with flipped x and y components.
|
|
110
|
+
flipXY: function() {
|
|
111
|
+
return new f(this.y, this.x);
|
|
112
|
+
},
|
|
113
|
+
// [API]
|
|
114
|
+
// [chainable, changeSelf]
|
|
115
|
+
// flip between x and y values.
|
|
116
|
+
// @return self.
|
|
117
|
+
flipXYSelf: function() {
|
|
118
|
+
return this.y = [this.x, this.x = this.y][0], this;
|
|
119
|
+
},
|
|
120
|
+
// [API]
|
|
121
|
+
// [chainable, clone]
|
|
122
|
+
// clone and invert x and y values (like multiply with -1, eg x, y => -x, -y)
|
|
123
|
+
// @return cloned vector with inverted values.
|
|
124
|
+
invert: function() {
|
|
125
|
+
return this.mulScalar(-1);
|
|
126
|
+
},
|
|
127
|
+
// [API]
|
|
128
|
+
// [chainable, changeSelf]
|
|
129
|
+
// invert x and y values (like multiply with -1, eg x, y => -x, -y)
|
|
130
|
+
// @return self.
|
|
131
|
+
invertSelf: function() {
|
|
132
|
+
return this.mulScalarSelf(-1), this;
|
|
133
|
+
},
|
|
134
|
+
// [API]
|
|
135
|
+
// []
|
|
136
|
+
// get the distance from another vector.
|
|
137
|
+
// @param other - vector to get distance from.
|
|
138
|
+
// @return distance between vectors.
|
|
139
|
+
distanceFrom: function(r) {
|
|
140
|
+
return g(this, r);
|
|
141
|
+
},
|
|
142
|
+
// [API]
|
|
143
|
+
// []
|
|
144
|
+
// get angle from another vector in radians.
|
|
145
|
+
// @return angle in radians from this to other.
|
|
146
|
+
radiansTo: function(r) {
|
|
147
|
+
return y(this, r, !0);
|
|
148
|
+
},
|
|
149
|
+
// [API]
|
|
150
|
+
// []
|
|
151
|
+
// get degrees from another vector in degrees.
|
|
152
|
+
// @return angle in degrees from this to other.
|
|
153
|
+
degreesTo: function(r) {
|
|
154
|
+
return y(this, r, !0) * s;
|
|
155
|
+
},
|
|
156
|
+
// [API]
|
|
157
|
+
// []
|
|
158
|
+
// convert this vector to a radian angle.
|
|
159
|
+
// this is equivalent to doing Vector.zero.radiansTo(this).
|
|
160
|
+
// @return angle in radians.
|
|
161
|
+
toRadians: function(r) {
|
|
162
|
+
return y(f.zero, this, !0);
|
|
163
|
+
},
|
|
164
|
+
// [API]
|
|
165
|
+
// []
|
|
166
|
+
// convert this vector to degree.
|
|
167
|
+
// this is equivalent to doing Vector.zero.degreeTo(this).
|
|
168
|
+
// @return angle in degrees (0-360).
|
|
169
|
+
toDegrees: function(r) {
|
|
170
|
+
return this.toRadians() * s;
|
|
171
|
+
},
|
|
172
|
+
// [API]
|
|
173
|
+
// [chainable, changeSelf]
|
|
174
|
+
// rotate this vector by a given degree.
|
|
175
|
+
// @param degrees - degrees to rotate this vector by (can be positive or negative).
|
|
176
|
+
// @return self.
|
|
177
|
+
rotateDegreesSelf: function(r) {
|
|
178
|
+
return this.rotateRadiansSelf(r * a);
|
|
179
|
+
},
|
|
180
|
+
// [API]
|
|
181
|
+
// [chainable]
|
|
182
|
+
// clone and rotate the vector by a given degree.
|
|
183
|
+
// @param degrees - degree to rotate this vector by (can be positive or negative).
|
|
184
|
+
// @return cloned rotated vector.
|
|
185
|
+
rotateDegrees: function(r) {
|
|
186
|
+
return this.clone().rotateDegreesSelf(r);
|
|
187
|
+
},
|
|
188
|
+
// [API]
|
|
189
|
+
// [chainable, changeSelf]
|
|
190
|
+
// rotate this vector by a given radian.
|
|
191
|
+
// @param radians - radians to rotate this vector by (can be positive or negative).
|
|
192
|
+
// @return self.
|
|
193
|
+
rotateRadiansSelf: function(r) {
|
|
194
|
+
var d = Math.cos(r), v = Math.sin(r), T = this.x * d - this.y * v, _ = this.x * v + this.y * d;
|
|
195
|
+
return this.x = c(T), this.y = c(_), this;
|
|
196
|
+
},
|
|
197
|
+
// [API]
|
|
198
|
+
// [chainable]
|
|
199
|
+
// clone and rotate the vector by a given degree.
|
|
200
|
+
// @param radians - radians to rotate this vector by (can be positive or negative).
|
|
201
|
+
// @return cloned rotated vector.
|
|
202
|
+
rotateRadians: function(r) {
|
|
203
|
+
return this.clone().rotateRadiansSelf(r);
|
|
204
|
+
},
|
|
205
|
+
// [API]
|
|
206
|
+
// []
|
|
207
|
+
// calculate the length of this vector (aka magnitude).
|
|
208
|
+
// @return vector length.
|
|
209
|
+
length: function() {
|
|
210
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
211
|
+
},
|
|
212
|
+
// [API]
|
|
213
|
+
// [chainable, changeSelf]
|
|
214
|
+
// normalize this vector, eg make length equal 1.
|
|
215
|
+
// @return self.
|
|
216
|
+
normalizeSelf: function() {
|
|
217
|
+
var r = Math.sqrt(this.x * this.x + this.y * this.y);
|
|
218
|
+
return r === 0 ? this : (this.x /= r, this.y /= r, this);
|
|
219
|
+
},
|
|
220
|
+
// [API]
|
|
221
|
+
// [chainable, clone]
|
|
222
|
+
// clone and normalize the vector.
|
|
223
|
+
// @return normalized vector.
|
|
224
|
+
normalize: function() {
|
|
225
|
+
return this.clone().normalizeSelf();
|
|
226
|
+
},
|
|
227
|
+
// [API]
|
|
228
|
+
// [chainable, changeSelf]
|
|
229
|
+
// add other vector to self.
|
|
230
|
+
// for example, v(10, 11) + v(5, 6) = v(15, 17).
|
|
231
|
+
// @param other - vector to add components to self.
|
|
232
|
+
// @return self.
|
|
233
|
+
addSelf: function(r) {
|
|
234
|
+
return typeof r == "number" ? this.addScalarSelf(r) : (this.x += r.x, this.y += r.y, this);
|
|
235
|
+
},
|
|
236
|
+
// [API]
|
|
237
|
+
// [chainable, changeSelf]
|
|
238
|
+
// subtract other vector from self.
|
|
239
|
+
// for example, v(10, 10) - v(2, 3) = v(8, 7).
|
|
240
|
+
// @param other - vector to subtract components from self.
|
|
241
|
+
// @return self.
|
|
242
|
+
subSelf: function(r) {
|
|
243
|
+
return typeof r == "number" ? this.subScalarSelf(r) : (this.x -= r.x, this.y -= r.y, this);
|
|
244
|
+
},
|
|
245
|
+
// [API]
|
|
246
|
+
// [chainable, changeSelf]
|
|
247
|
+
// divide self by other vector.
|
|
248
|
+
// for example, v(10, 20) / v(2, 5) = v(5, 4).
|
|
249
|
+
// @param other - vector to divide components from self.
|
|
250
|
+
// @return self.
|
|
251
|
+
divSelf: function(r) {
|
|
252
|
+
return typeof r == "number" ? this.divScalarSelf(r) : (this.x /= r.x, this.y /= r.y, this);
|
|
253
|
+
},
|
|
254
|
+
// [API]
|
|
255
|
+
// [chainable, changeSelf]
|
|
256
|
+
// multiply self vector by other vector.
|
|
257
|
+
// for example, v(2, 3) * v(3, 4) = v(6, 12).
|
|
258
|
+
// @param other - vector to multiply components with self.
|
|
259
|
+
// @return self.
|
|
260
|
+
mulSelf: function(r) {
|
|
261
|
+
return typeof r == "number" ? this.mulScalarSelf(r) : (this.x *= r.x, this.y *= r.y, this);
|
|
262
|
+
},
|
|
263
|
+
// [API]
|
|
264
|
+
// [chainable, changeSelf]
|
|
265
|
+
// add scalar value to self.
|
|
266
|
+
// for example, v(2, 3) + 5 = v(7, 8).
|
|
267
|
+
// @param val - value to add to components.
|
|
268
|
+
// @return self.
|
|
269
|
+
addScalarSelf: function(r) {
|
|
270
|
+
return this.x += r, this.y += r, this;
|
|
271
|
+
},
|
|
272
|
+
// [API]
|
|
273
|
+
// [chainable, changeSelf]
|
|
274
|
+
// subtract scalar from self.
|
|
275
|
+
// for example, v(7, 9) - 5 = v(3, 4).
|
|
276
|
+
// @param val - value to subtract from components.
|
|
277
|
+
// @return self.
|
|
278
|
+
subScalarSelf: function(r) {
|
|
279
|
+
return this.x -= r, this.y -= r, this;
|
|
280
|
+
},
|
|
281
|
+
// [API]
|
|
282
|
+
// [chainable, changeSelf]
|
|
283
|
+
// divide self by scalar.
|
|
284
|
+
// for example, v(6, 8) / 5 = v(3, 4).
|
|
285
|
+
// @param val - value to divide components by.
|
|
286
|
+
// @return self.
|
|
287
|
+
divScalarSelf: function(r) {
|
|
288
|
+
return this.x /= r, this.y /= r, this;
|
|
289
|
+
},
|
|
290
|
+
// [API]
|
|
291
|
+
// [chainable, changeSelf]
|
|
292
|
+
// multiply self by scalar.
|
|
293
|
+
// for example, v(2, 3) * 2 = v(4, 6).
|
|
294
|
+
// @param val - value to multiply components with.
|
|
295
|
+
// @return self.
|
|
296
|
+
mulScalarSelf: function(r) {
|
|
297
|
+
return this.x *= r, this.y *= r, this;
|
|
298
|
+
},
|
|
299
|
+
// [API]
|
|
300
|
+
// [chainable, clone]
|
|
301
|
+
// clone self and add other vector to it.
|
|
302
|
+
// @param other - vector to add with.
|
|
303
|
+
// @return cloned vector.
|
|
304
|
+
add: function(r) {
|
|
305
|
+
return this.clone().addSelf(r);
|
|
306
|
+
},
|
|
307
|
+
// [API]
|
|
308
|
+
// [chainable, clone]
|
|
309
|
+
// clone self and subtract other vector from it.
|
|
310
|
+
// @param other - vector to subtract with.
|
|
311
|
+
// @return cloned vector.
|
|
312
|
+
sub: function(r) {
|
|
313
|
+
return this.clone().subSelf(r);
|
|
314
|
+
},
|
|
315
|
+
// [API]
|
|
316
|
+
// [chainable, clone]
|
|
317
|
+
// clone self and multiply by other vector.
|
|
318
|
+
// @param other - vector to multiply with.
|
|
319
|
+
// @return cloned vector.
|
|
320
|
+
mul: function(r) {
|
|
321
|
+
return this.clone().mulSelf(r);
|
|
322
|
+
},
|
|
323
|
+
// [API]
|
|
324
|
+
// [chainable, clone]
|
|
325
|
+
// clone self and divide by other vector.
|
|
326
|
+
// @param other - vector to divide with.
|
|
327
|
+
// @param scalar - value to divide by.
|
|
328
|
+
// @return cloned vector.
|
|
329
|
+
div: function(r) {
|
|
330
|
+
return this.clone().divSelf(r);
|
|
331
|
+
},
|
|
332
|
+
// [API]
|
|
333
|
+
// [chainable, clone]
|
|
334
|
+
// clone self and add scalar to it.
|
|
335
|
+
// @param scalar - value to add.
|
|
336
|
+
// @return cloned vector.
|
|
337
|
+
addScalar: function(r) {
|
|
338
|
+
return this.clone().addScalarSelf(r);
|
|
339
|
+
},
|
|
340
|
+
// [API]
|
|
341
|
+
// [chainable, clone]
|
|
342
|
+
// clone self and substract scalar from it.
|
|
343
|
+
// @param scalar - value to subtract.
|
|
344
|
+
// @return cloned vector.
|
|
345
|
+
subScalar: function(r) {
|
|
346
|
+
return this.clone().subScalarSelf(r);
|
|
347
|
+
},
|
|
348
|
+
// [API]
|
|
349
|
+
// [chainable, clone]
|
|
350
|
+
// clone self and multiply by scalar.
|
|
351
|
+
// @param scalar - value to multiply with.
|
|
352
|
+
// @return cloned vector.
|
|
353
|
+
mulScalar: function(r) {
|
|
354
|
+
return this.clone().mulScalarSelf(r);
|
|
355
|
+
},
|
|
356
|
+
// [API]
|
|
357
|
+
// [chainable, clone]
|
|
358
|
+
// clone self and divide by scalar.
|
|
359
|
+
// @param scalar - value to divide by.
|
|
360
|
+
// @return cloned vector.
|
|
361
|
+
divScalar: function(r) {
|
|
362
|
+
return this.clone().divScalarSelf(r);
|
|
363
|
+
},
|
|
364
|
+
// [API]
|
|
365
|
+
// [chainable, changeSelf]
|
|
366
|
+
// clamp vector values into range.
|
|
367
|
+
// note: this function does not validate that min < max.
|
|
368
|
+
// @param min - min value for x, y components.
|
|
369
|
+
// @param max - max value for x, y components.
|
|
370
|
+
// @return self.
|
|
371
|
+
clampSelf: function(r, d) {
|
|
372
|
+
return this.x < r.x && (this.x = r.x), this.y < r.y && (this.y = r.y), this.x > d.x && (this.x = d.x), this.y > d.y && (this.y = d.y), this;
|
|
373
|
+
},
|
|
374
|
+
// [API]
|
|
375
|
+
// [chainable, clone]
|
|
376
|
+
// clone vector and clamp its values.
|
|
377
|
+
// note: this function does not validate that min < max.
|
|
378
|
+
// @param min - min value for x, y components.
|
|
379
|
+
// @param max - max value for x, y components.
|
|
380
|
+
// @return cloned vector in range.
|
|
381
|
+
clamp: function(r, d) {
|
|
382
|
+
return this.clone().clampSelf(r, d);
|
|
383
|
+
},
|
|
384
|
+
// [API]
|
|
385
|
+
// [chainable, changeSelf]
|
|
386
|
+
// apply a function on x and y components of the vector.
|
|
387
|
+
// for example, you can use Math.round to round the vector x, y values.
|
|
388
|
+
// @param func - function to apply on components.
|
|
389
|
+
// @return self.
|
|
390
|
+
applySelf: function(r) {
|
|
391
|
+
return this.x = r(this.x), this.y = r(this.y), this;
|
|
392
|
+
},
|
|
393
|
+
// [API]
|
|
394
|
+
// [chainable, clone]
|
|
395
|
+
// clone self and apply a function on x and y components of the clone vector.
|
|
396
|
+
// for example, you can use Math.round to round the vector x, y values.
|
|
397
|
+
// @param func - function to apply on components.
|
|
398
|
+
// @return cloned vector.
|
|
399
|
+
apply: function(r) {
|
|
400
|
+
return this.clone().applySelf(r);
|
|
401
|
+
},
|
|
402
|
+
// [API]
|
|
403
|
+
// [chainable, changeSelf]
|
|
404
|
+
// turn self to absolute values (eg turn x, y positive).
|
|
405
|
+
// @return self.
|
|
406
|
+
absSelf: function() {
|
|
407
|
+
return this.applySelf(Math.abs);
|
|
408
|
+
},
|
|
409
|
+
// [API]
|
|
410
|
+
// [chainable, clone]
|
|
411
|
+
// clone and turn to absolute values (eg turn x, y positive).
|
|
412
|
+
// @return cloned vector.
|
|
413
|
+
abs: function() {
|
|
414
|
+
return this.clone().absSelf();
|
|
415
|
+
},
|
|
416
|
+
// [API]
|
|
417
|
+
// [chainable, changeSelf]
|
|
418
|
+
// turn self to round values (eg turn x, y positive).
|
|
419
|
+
// @return self.
|
|
420
|
+
roundSelf: function() {
|
|
421
|
+
return this.applySelf(Math.round);
|
|
422
|
+
},
|
|
423
|
+
// [API]
|
|
424
|
+
// [chainable, clone]
|
|
425
|
+
// clone and turn to round values (eg turn x, y positive).
|
|
426
|
+
// @return cloned vector.
|
|
427
|
+
round: function() {
|
|
428
|
+
return this.clone().roundSelf();
|
|
429
|
+
},
|
|
430
|
+
// [API]
|
|
431
|
+
// []
|
|
432
|
+
// calculate dot-product of this vector with another vector.
|
|
433
|
+
// @param other - other vector to calculate dot-product with.
|
|
434
|
+
// @return dot product.
|
|
435
|
+
dot: function(r) {
|
|
436
|
+
return this.x * r.x + this.y * r.y;
|
|
437
|
+
},
|
|
438
|
+
// [API]
|
|
439
|
+
// []
|
|
440
|
+
// calculate cross-product of this vector with another vector.
|
|
441
|
+
// @param other - other vector to calculate cross-product with.
|
|
442
|
+
// @return dot product.
|
|
443
|
+
cross: function(r) {
|
|
444
|
+
return this.x * r.y - this.y * r.x;
|
|
445
|
+
},
|
|
446
|
+
// [API]
|
|
447
|
+
// [chainable, changeSelf]
|
|
448
|
+
// if any of the components of this vector are NaN, null, undefined, etc. set them to defaults.
|
|
449
|
+
// note: 0's are considered to be a valid number and will not be replaced with a default value.
|
|
450
|
+
// @param x - default value for x if undefined (0 if not defined).
|
|
451
|
+
// @param y - default value for y if undefined (0 if not defined).
|
|
452
|
+
// @return self.
|
|
453
|
+
repairSelf: function(r, d) {
|
|
454
|
+
return (typeof this.x != "number" || isNaN(this.x + 1)) && (this.x = r || 0), (typeof this.y != "number" || isNaN(this.y + 1)) && (this.y = d || 0), this;
|
|
455
|
+
},
|
|
456
|
+
// [API]
|
|
457
|
+
// [chainable, clone]
|
|
458
|
+
// create a clone and if any of the components of the vector are NaN, null, undefined, etc. set them to default.
|
|
459
|
+
// note: 0's are considered to be a valid number and will not be replaced with a default value.
|
|
460
|
+
// @param x - default value for x if undefined (0 if not defined).
|
|
461
|
+
// @param y - default value for y if undefined (0 if not defined).
|
|
462
|
+
// @return repaired clone.
|
|
463
|
+
repair: function(r, d) {
|
|
464
|
+
return this.clone().repairSelf(r, d);
|
|
465
|
+
},
|
|
466
|
+
// [API]
|
|
467
|
+
// []
|
|
468
|
+
// convert to string in the form of "x,y".
|
|
469
|
+
// @return string representation of the vector.
|
|
470
|
+
toString: function() {
|
|
471
|
+
return this.x + "," + this.y;
|
|
472
|
+
},
|
|
473
|
+
// [API]
|
|
474
|
+
// []
|
|
475
|
+
// convert to a string with a given format.
|
|
476
|
+
// @param format - a string in which %x and %y will be replaced with the vector values.
|
|
477
|
+
// @return formatted string representing the vector.
|
|
478
|
+
format: function(r) {
|
|
479
|
+
return r = r || "%x,%y", r = r.replace(new RegExp("%x", "g"), this.x), r = r.replace(new RegExp("%y", "g"), this.y), r;
|
|
480
|
+
}
|
|
481
|
+
}, f;
|
|
482
|
+
}();
|
|
483
|
+
return l.zero = new l(0, 0), l.one = new l(1, 1), l.up = new l(0, -1), l.down = new l(0, 1), l.left = new l(-1, 0), l.right = new l(1, 0), l.upLeft = new l(-1, -1), l.downLeft = new l(-1, 1), l.upRight = new l(1, -1), l.downRight = new l(1, 1), l.prototype.magnitude = l.prototype.length, Object.freeze && (Object.freeze(l.zero), Object.freeze(l.one), Object.freeze(l.up), Object.freeze(l.down), Object.freeze(l.left), Object.freeze(l.right), Object.freeze(l.upLeft), Object.freeze(l.downLeft), Object.freeze(l.upRight), Object.freeze(l.downRight)), l;
|
|
484
|
+
});
|
|
485
|
+
})(Pe);
|
|
486
|
+
var In = Pe.exports;
|
|
487
|
+
const rt = /* @__PURE__ */ oe(In);
|
|
488
|
+
let jt = (u = 21) => crypto.getRandomValues(new Uint8Array(u)).reduce((l, t) => (t &= 63, t < 36 ? l += t.toString(36) : t < 62 ? l += (t - 26).toString(36).toUpperCase() : t > 62 ? l += "-" : l += "_", l), "");
|
|
489
|
+
const Dt = {
|
|
490
|
+
strokeType: "plain",
|
|
491
|
+
strokeColor: "black",
|
|
492
|
+
strokeWidth: 1,
|
|
493
|
+
head: "none",
|
|
494
|
+
tail: "none"
|
|
495
|
+
}, Se = {
|
|
496
|
+
id: 0,
|
|
497
|
+
type: "Feature",
|
|
498
|
+
properties: {
|
|
499
|
+
type: "arrow",
|
|
500
|
+
style: {
|
|
501
|
+
...Dt
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
geometry: {
|
|
505
|
+
type: "LineString",
|
|
506
|
+
coordinates: [
|
|
507
|
+
[0, 0],
|
|
508
|
+
[100, 100]
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
// type: 'arrow',
|
|
512
|
+
// stroke: {
|
|
513
|
+
// type: 'plain',
|
|
514
|
+
// color: 'black',
|
|
515
|
+
// width: 1
|
|
516
|
+
// },
|
|
517
|
+
// head: 'none',
|
|
518
|
+
// tail: 'arrow-plain',
|
|
519
|
+
// start: { x: 0, y: 0 },
|
|
520
|
+
// end: { x: 100, y: 100 }
|
|
521
|
+
}, _n = (u = 0, l = 0, t = 0, s = 0, a = { ...Dt }) => ({
|
|
522
|
+
id: jt(),
|
|
523
|
+
type: "Feature",
|
|
524
|
+
properties: {
|
|
525
|
+
type: "arrow",
|
|
526
|
+
style: {
|
|
527
|
+
...Dt,
|
|
528
|
+
...a
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
geometry: {
|
|
532
|
+
type: "LineString",
|
|
533
|
+
coordinates: [
|
|
534
|
+
[u, l],
|
|
535
|
+
[t, s]
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
}), Dn = "http://www.w3.org/2000/svg";
|
|
539
|
+
function It(u) {
|
|
540
|
+
return document.createElementNS(Dn, u);
|
|
541
|
+
}
|
|
542
|
+
function Ce(u) {
|
|
543
|
+
return u.geometry.bbox || On(u), u.geometry.bbox;
|
|
544
|
+
}
|
|
545
|
+
function dt(u) {
|
|
546
|
+
const l = Ce(u);
|
|
547
|
+
return {
|
|
548
|
+
width: l[2] - l[0],
|
|
549
|
+
height: l[3] - l[1]
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
function yt(u) {
|
|
553
|
+
const l = Ce(u);
|
|
554
|
+
return { x: l[0], y: l[1] };
|
|
555
|
+
}
|
|
556
|
+
function On(u) {
|
|
557
|
+
const [l, t] = u.geometry.coordinates[0][0], [s, a] = u.geometry.coordinates[0][2];
|
|
558
|
+
u.geometry.bbox = [l, t, s, a];
|
|
559
|
+
}
|
|
560
|
+
function Mn(u, l, t, s, a) {
|
|
561
|
+
u.geometry.bbox = [l, t, l + s, t + a], u.geometry.coordinates = [
|
|
562
|
+
[
|
|
563
|
+
[l, t],
|
|
564
|
+
[l + s, t],
|
|
565
|
+
[l + s, t + a],
|
|
566
|
+
[l, t + a],
|
|
567
|
+
[l, t]
|
|
568
|
+
]
|
|
569
|
+
];
|
|
570
|
+
}
|
|
571
|
+
function _t(u) {
|
|
572
|
+
const [l, t] = u.geometry.coordinates[0];
|
|
573
|
+
return { x: l, y: t };
|
|
574
|
+
}
|
|
575
|
+
function Ae(u, l) {
|
|
576
|
+
const [t, s] = u.geometry.coordinates[l === "start" ? 0 : 1];
|
|
577
|
+
return { x: t, y: s };
|
|
578
|
+
}
|
|
579
|
+
function Ht(u) {
|
|
580
|
+
const [l, t] = u.geometry.coordinates[1];
|
|
581
|
+
return { x: l, y: t };
|
|
582
|
+
}
|
|
583
|
+
function Ne(u, l, t) {
|
|
584
|
+
u.geometry.coordinates[0] = [l, t];
|
|
585
|
+
}
|
|
586
|
+
function $e(u, l, t) {
|
|
587
|
+
u.geometry.coordinates[1] = [l, t];
|
|
588
|
+
}
|
|
589
|
+
function Rt(u) {
|
|
590
|
+
return { start: _t(u), end: Ht(u) };
|
|
591
|
+
}
|
|
592
|
+
function Qt(u, l, t, s) {
|
|
593
|
+
l === "start" ? Ne(u, t, s) : $e(u, t, s);
|
|
594
|
+
}
|
|
595
|
+
const He = (u) => parseInt(u.getAttribute("data-handle-id") || "-1");
|
|
596
|
+
function Xn(u) {
|
|
597
|
+
return $t(u).reduce(
|
|
598
|
+
(l, t) => (l[0] = Math.min(t[0], l[0]), l[1] = Math.min(t[1], l[1]), l[2] = Math.max(t[0], l[2]), l[3] = Math.max(t[1], l[3]), l),
|
|
599
|
+
[
|
|
600
|
+
Number.POSITIVE_INFINITY,
|
|
601
|
+
Number.POSITIVE_INFINITY,
|
|
602
|
+
Number.NEGATIVE_INFINITY,
|
|
603
|
+
Number.NEGATIVE_INFINITY
|
|
604
|
+
]
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
function $t(u) {
|
|
608
|
+
let l = [];
|
|
609
|
+
return u.type == "Point" ? l = [u.coordinates] : u.type == "LineString" || u.type == "MultiPoint" ? l = u.coordinates : u.type == "Polygon" || u.type == "MultiLineString" ? l = u.coordinates.reduce(function(t, s) {
|
|
610
|
+
return t.concat(s);
|
|
611
|
+
}, []) : u.type == "MultiPolygon" ? l = u.coordinates.reduce(
|
|
612
|
+
(t, s) => t.concat(s.reduce((a, c) => a.concat(c), [])),
|
|
613
|
+
[]
|
|
614
|
+
) : u.type == "Feature" ? l = $t(u.geometry) : u.type == "GeometryCollection" ? l = u.geometries.reduce(
|
|
615
|
+
(t, s) => t.concat($t(s)),
|
|
616
|
+
[]
|
|
617
|
+
) : u.type == "FeatureCollection" && (l = u.features.reduce(
|
|
618
|
+
(t, s) => t.concat($t(s)),
|
|
619
|
+
[]
|
|
620
|
+
)), l;
|
|
621
|
+
}
|
|
622
|
+
function Ee(u, l, t) {
|
|
623
|
+
const s = Math.atan2(u.y - l.y, u.x - l.x);
|
|
624
|
+
return {
|
|
625
|
+
x: l.x + t * Math.cos(s),
|
|
626
|
+
y: l.y + t * Math.sin(s)
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function Re(u, l = 5, t = 30) {
|
|
630
|
+
var r;
|
|
631
|
+
const { start: s, end: a } = Rt(u), c = new rt(s.x, s.y), y = new rt(a.x, a.y).sub(c), f = u.properties.style && u.properties.style.strokeWidth ? (r = u.properties.style) == null ? void 0 : r.strokeWidth : 0;
|
|
632
|
+
return Math.min(t, Math.max(3 * f, y.length() * 0.1, l));
|
|
633
|
+
}
|
|
634
|
+
function ke(u, l, t, s) {
|
|
635
|
+
const a = l.clone().normalize().invert().mul(s);
|
|
636
|
+
if (!t || t === "none")
|
|
637
|
+
return "";
|
|
638
|
+
const c = u.clone().add(a.rotateRadians(Math.PI / 8)), g = u.clone().add(a.rotateRadians(-Math.PI / 8)), y = `${u.x} ${u.y}`;
|
|
639
|
+
return `M ${c.x} ${c.y} L ${y} ${g.x} ${g.y} ${t === "arrow" ? "" : `${c.x} ${c.y}`}`;
|
|
640
|
+
}
|
|
641
|
+
function zn(u, l, t, s, a) {
|
|
642
|
+
const { start: c, end: g } = Rt(u), { tail: y, head: f, strokeColor: r, strokeWidth: d } = u.properties.style || t, v = new rt(c.x, c.y), T = new rt(g.x, g.y), _ = T.clone().sub(v), E = Re(u, s, a), P = It("path");
|
|
643
|
+
P.setAttribute("data-annotation", `${u.id}`), P.setAttribute("data-annotation-type", "arrow");
|
|
644
|
+
const A = f === "arrow-plain" || y === "arrow";
|
|
645
|
+
P.setAttribute("stroke", r || "none"), P.setAttribute("stroke-width", `${d}`), P.setAttribute("fill", A ? r || "" : "none"), P.setAttribute("stroke-linecap", "round"), P.setAttribute("stroke-linejoin", "round");
|
|
646
|
+
const U = ke(v, _.clone().invert(), y, E), N = ke(T, _, f, E), z = U + `M ${v.x} ${v.y} ${T.x} ${T.y}` + N;
|
|
647
|
+
P.setAttribute("d", z), l.appendChild(P);
|
|
648
|
+
}
|
|
649
|
+
const B = -1, ae = "dragging", le = "dragstart", Ot = "dragend", ee = "select", ne = "unselect", Ln = "hover", Pn = "unhover", ie = "remove", re = "add", Cn = "cancelDrawing", se = "update", Nn = "link";
|
|
650
|
+
var je = { exports: {} };
|
|
651
|
+
(function(u) {
|
|
652
|
+
var l = Object.prototype.hasOwnProperty, t = "~";
|
|
653
|
+
function s() {
|
|
654
|
+
}
|
|
655
|
+
Object.create && (s.prototype = /* @__PURE__ */ Object.create(null), new s().__proto__ || (t = !1));
|
|
656
|
+
function a(f, r, d) {
|
|
657
|
+
this.fn = f, this.context = r, this.once = d || !1;
|
|
658
|
+
}
|
|
659
|
+
function c(f, r, d, v, T) {
|
|
660
|
+
if (typeof d != "function")
|
|
661
|
+
throw new TypeError("The listener must be a function");
|
|
662
|
+
var _ = new a(d, v || f, T), E = t ? t + r : r;
|
|
663
|
+
return f._events[E] ? f._events[E].fn ? f._events[E] = [f._events[E], _] : f._events[E].push(_) : (f._events[E] = _, f._eventsCount++), f;
|
|
664
|
+
}
|
|
665
|
+
function g(f, r) {
|
|
666
|
+
--f._eventsCount === 0 ? f._events = new s() : delete f._events[r];
|
|
667
|
+
}
|
|
668
|
+
function y() {
|
|
669
|
+
this._events = new s(), this._eventsCount = 0;
|
|
670
|
+
}
|
|
671
|
+
y.prototype.eventNames = function() {
|
|
672
|
+
var r = [], d, v;
|
|
673
|
+
if (this._eventsCount === 0)
|
|
674
|
+
return r;
|
|
675
|
+
for (v in d = this._events)
|
|
676
|
+
l.call(d, v) && r.push(t ? v.slice(1) : v);
|
|
677
|
+
return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(d)) : r;
|
|
678
|
+
}, y.prototype.listeners = function(r) {
|
|
679
|
+
var d = t ? t + r : r, v = this._events[d];
|
|
680
|
+
if (!v)
|
|
681
|
+
return [];
|
|
682
|
+
if (v.fn)
|
|
683
|
+
return [v.fn];
|
|
684
|
+
for (var T = 0, _ = v.length, E = new Array(_); T < _; T++)
|
|
685
|
+
E[T] = v[T].fn;
|
|
686
|
+
return E;
|
|
687
|
+
}, y.prototype.listenerCount = function(r) {
|
|
688
|
+
var d = t ? t + r : r, v = this._events[d];
|
|
689
|
+
return v ? v.fn ? 1 : v.length : 0;
|
|
690
|
+
}, y.prototype.emit = function(r, d, v, T, _, E) {
|
|
691
|
+
var P = t ? t + r : r;
|
|
692
|
+
if (!this._events[P])
|
|
693
|
+
return !1;
|
|
694
|
+
var A = this._events[P], U = arguments.length, N, z;
|
|
695
|
+
if (A.fn) {
|
|
696
|
+
switch (A.once && this.removeListener(r, A.fn, void 0, !0), U) {
|
|
697
|
+
case 1:
|
|
698
|
+
return A.fn.call(A.context), !0;
|
|
699
|
+
case 2:
|
|
700
|
+
return A.fn.call(A.context, d), !0;
|
|
701
|
+
case 3:
|
|
702
|
+
return A.fn.call(A.context, d, v), !0;
|
|
703
|
+
case 4:
|
|
704
|
+
return A.fn.call(A.context, d, v, T), !0;
|
|
705
|
+
case 5:
|
|
706
|
+
return A.fn.call(A.context, d, v, T, _), !0;
|
|
707
|
+
case 6:
|
|
708
|
+
return A.fn.call(A.context, d, v, T, _, E), !0;
|
|
709
|
+
}
|
|
710
|
+
for (z = 1, N = new Array(U - 1); z < U; z++)
|
|
711
|
+
N[z - 1] = arguments[z];
|
|
712
|
+
A.fn.apply(A.context, N);
|
|
713
|
+
} else {
|
|
714
|
+
var W = A.length, nt;
|
|
715
|
+
for (z = 0; z < W; z++)
|
|
716
|
+
switch (A[z].once && this.removeListener(r, A[z].fn, void 0, !0), U) {
|
|
717
|
+
case 1:
|
|
718
|
+
A[z].fn.call(A[z].context);
|
|
719
|
+
break;
|
|
720
|
+
case 2:
|
|
721
|
+
A[z].fn.call(A[z].context, d);
|
|
722
|
+
break;
|
|
723
|
+
case 3:
|
|
724
|
+
A[z].fn.call(A[z].context, d, v);
|
|
725
|
+
break;
|
|
726
|
+
case 4:
|
|
727
|
+
A[z].fn.call(A[z].context, d, v, T);
|
|
728
|
+
break;
|
|
729
|
+
default:
|
|
730
|
+
if (!N)
|
|
731
|
+
for (nt = 1, N = new Array(U - 1); nt < U; nt++)
|
|
732
|
+
N[nt - 1] = arguments[nt];
|
|
733
|
+
A[z].fn.apply(A[z].context, N);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return !0;
|
|
737
|
+
}, y.prototype.on = function(r, d, v) {
|
|
738
|
+
return c(this, r, d, v, !1);
|
|
739
|
+
}, y.prototype.once = function(r, d, v) {
|
|
740
|
+
return c(this, r, d, v, !0);
|
|
741
|
+
}, y.prototype.removeListener = function(r, d, v, T) {
|
|
742
|
+
var _ = t ? t + r : r;
|
|
743
|
+
if (!this._events[_])
|
|
744
|
+
return this;
|
|
745
|
+
if (!d)
|
|
746
|
+
return g(this, _), this;
|
|
747
|
+
var E = this._events[_];
|
|
748
|
+
if (E.fn)
|
|
749
|
+
E.fn === d && (!T || E.once) && (!v || E.context === v) && g(this, _);
|
|
750
|
+
else {
|
|
751
|
+
for (var P = 0, A = [], U = E.length; P < U; P++)
|
|
752
|
+
(E[P].fn !== d || T && !E[P].once || v && E[P].context !== v) && A.push(E[P]);
|
|
753
|
+
A.length ? this._events[_] = A.length === 1 ? A[0] : A : g(this, _);
|
|
754
|
+
}
|
|
755
|
+
return this;
|
|
756
|
+
}, y.prototype.removeAllListeners = function(r) {
|
|
757
|
+
var d;
|
|
758
|
+
return r ? (d = t ? t + r : r, this._events[d] && g(this, d)) : (this._events = new s(), this._eventsCount = 0), this;
|
|
759
|
+
}, y.prototype.off = y.prototype.removeListener, y.prototype.addListener = y.prototype.on, y.prefixed = t, y.EventEmitter = y, u.exports = y;
|
|
760
|
+
})(je);
|
|
761
|
+
var $n = je.exports;
|
|
762
|
+
const Fe = /* @__PURE__ */ oe($n);
|
|
763
|
+
class qe extends Fe {
|
|
764
|
+
constructor(t, s) {
|
|
765
|
+
super();
|
|
766
|
+
m(this, "ogma");
|
|
767
|
+
m(this, "elements");
|
|
768
|
+
// layer to draw elements
|
|
769
|
+
m(this, "layer");
|
|
770
|
+
m(this, "editor");
|
|
771
|
+
m(this, "selectedId", B);
|
|
772
|
+
m(this, "hoveredId", B);
|
|
773
|
+
// used to remember ogma options before we change them
|
|
774
|
+
m(this, "ogmaOptions");
|
|
775
|
+
m(this, "shouldDetect");
|
|
776
|
+
m(this, "isDragging");
|
|
777
|
+
m(this, "_onKeyUp", (t) => {
|
|
778
|
+
t.code === 27 && this.selectedId !== B ? this.unselect() : (t.code === 46 || t.code === 8) && this.selectedId !== B && this._canRemove() && this.remove(this.selectedId);
|
|
779
|
+
});
|
|
780
|
+
m(this, "_onClickMouseMove", (t) => {
|
|
781
|
+
if (!t.domEvent || this.isDragging || !this.shouldDetect)
|
|
782
|
+
return;
|
|
783
|
+
const s = this.ogma.view.screenToGraphCoordinates(t), a = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(s, 0) : void 0;
|
|
784
|
+
t.domEvent.type === "mousemove" ? a ? this.hover(a.id) : this.hoveredId !== B && this.unhover() : a ? this.select(a.id) : this.selectedId !== B && this.unselect();
|
|
785
|
+
});
|
|
786
|
+
this.ogma = t, this.elements = [], this.shouldDetect = !0, this.isDragging = !1, this.ogmaOptions = t.getOptions(), t.events.on(["click", "mousemove"], this._onClickMouseMove).on("keyup", this._onKeyUp), this.layer = t.layers.addSVGLayer({
|
|
787
|
+
draw: (a) => this.draw(a)
|
|
788
|
+
}), this.layer.moveToTop(), this.editor = t.layers.addOverlay({
|
|
789
|
+
element: s,
|
|
790
|
+
position: { x: 0, y: 0 },
|
|
791
|
+
size: { width: 0, height: 0 }
|
|
792
|
+
}), this.editor.hide();
|
|
793
|
+
}
|
|
794
|
+
_canRemove() {
|
|
795
|
+
return !0;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* @method add
|
|
799
|
+
* @param options Params for the annotation (merged with default)
|
|
800
|
+
* @returns the added annotation
|
|
801
|
+
*/
|
|
802
|
+
add(t) {
|
|
803
|
+
const s = this.getDefaultOptions(), a = Object.assign(t, {
|
|
804
|
+
id: t.id === void 0 ? jt() : t.id,
|
|
805
|
+
type: t.type,
|
|
806
|
+
properties: {
|
|
807
|
+
...s.properties,
|
|
808
|
+
...t.properties || {},
|
|
809
|
+
// styles need to be merged
|
|
810
|
+
style: { ...s.properties.style, ...t.properties.style || {} }
|
|
811
|
+
},
|
|
812
|
+
geometry: {
|
|
813
|
+
...s.geometry,
|
|
814
|
+
...t.geometry
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
return this.elements.push(a), this.layer.refresh(), this.emit(re, a), a;
|
|
818
|
+
}
|
|
819
|
+
updateStyle(t, s) {
|
|
820
|
+
this.updateAnnotation(t, {
|
|
821
|
+
properties: {
|
|
822
|
+
style: s
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
updateGeometry(t, s) {
|
|
827
|
+
this.updateAnnotation(t, {
|
|
828
|
+
geometry: s
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* @method update
|
|
833
|
+
* Updates an annotation (position, color etc)
|
|
834
|
+
* @param id Id of the annotation to update
|
|
835
|
+
* @param new params of the annotation
|
|
836
|
+
*/
|
|
837
|
+
update(t, s) {
|
|
838
|
+
const a = this.getById(t);
|
|
839
|
+
this.updateAnnotation(a, s);
|
|
840
|
+
}
|
|
841
|
+
updateAnnotation(t, s) {
|
|
842
|
+
if (!t)
|
|
843
|
+
return;
|
|
844
|
+
const a = t.id;
|
|
845
|
+
Object.keys(s).forEach((c) => {
|
|
846
|
+
if (c !== "id")
|
|
847
|
+
if (c === "properties") {
|
|
848
|
+
const g = s.properties || { style: {} };
|
|
849
|
+
t.properties = {
|
|
850
|
+
...t.properties || {},
|
|
851
|
+
...g || {},
|
|
852
|
+
style: {
|
|
853
|
+
...t.properties.style || {},
|
|
854
|
+
...g.style || {}
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
} else
|
|
858
|
+
c === "geometry" ? t.geometry = {
|
|
859
|
+
...t.geometry,
|
|
860
|
+
...s.geometry
|
|
861
|
+
} : t[c] = s[c];
|
|
862
|
+
}), a === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
863
|
+
}
|
|
864
|
+
getById(t) {
|
|
865
|
+
for (let s = 0; s < this.elements.length; s++) {
|
|
866
|
+
const a = this.elements[s];
|
|
867
|
+
if (a.id === t)
|
|
868
|
+
return a;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* @method select
|
|
873
|
+
* @param id id of the element to select
|
|
874
|
+
* Select element, show editor, disable Ogma dragging and fire event
|
|
875
|
+
*/
|
|
876
|
+
select(t) {
|
|
877
|
+
const s = this.getById(t);
|
|
878
|
+
s && (this.editor.show(), this.selectedId = t, this.refreshEditor(), this.layer.refresh(), this.emit(ee, s));
|
|
879
|
+
}
|
|
880
|
+
hover(t) {
|
|
881
|
+
const s = this.getById(t);
|
|
882
|
+
s && (this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(Ln, s));
|
|
883
|
+
}
|
|
884
|
+
getSelectedFeature() {
|
|
885
|
+
return this.selectedId === B ? null : this.getById(this.selectedId);
|
|
886
|
+
}
|
|
887
|
+
unselect() {
|
|
888
|
+
const t = this.getById(this.selectedId);
|
|
889
|
+
return t && this.emit(ne, t), this.selectedId = B, this.hoveredId === B && this.editor.hide(), this.layer.refresh(), this;
|
|
890
|
+
}
|
|
891
|
+
unhover() {
|
|
892
|
+
const t = this.getById(this.hoveredId);
|
|
893
|
+
return this.emit(Pn, t), this.hoveredId = B, this.selectedId === B && this.editor.hide(), this.layer.refresh(), this;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* @method remove
|
|
897
|
+
* @param id Id of the annotation to remove
|
|
898
|
+
* Removes annotation with the given id
|
|
899
|
+
*/
|
|
900
|
+
remove(t) {
|
|
901
|
+
const s = this.getById(t);
|
|
902
|
+
t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((a) => a.id !== t), s && this.emit(ie, s), this.layer.refresh();
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* @method disableDragging
|
|
906
|
+
* Prevents Ogma from dragging elements or moving the view while dragging an annotation
|
|
907
|
+
*/
|
|
908
|
+
disableDragging() {
|
|
909
|
+
this.ogma.setOptions({
|
|
910
|
+
interactions: {
|
|
911
|
+
drag: { enabled: !1 },
|
|
912
|
+
pan: { enabled: !1 }
|
|
913
|
+
},
|
|
914
|
+
detect: {
|
|
915
|
+
nodes: !1,
|
|
916
|
+
edges: !1,
|
|
917
|
+
nodeTexts: !1,
|
|
918
|
+
edgeTexts: !1
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* @method restoreDragging
|
|
924
|
+
* restore ogma options as they were before we start dragging an annotation
|
|
925
|
+
*/
|
|
926
|
+
restoreDragging() {
|
|
927
|
+
this.ogma.setOptions(this.ogmaOptions);
|
|
928
|
+
}
|
|
929
|
+
enableDetection() {
|
|
930
|
+
this.shouldDetect = !0;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* @method disableDetection
|
|
934
|
+
* Disables the hover behaviour, used by controller to avoid hovering
|
|
935
|
+
* arrows while dragging texts and vice versa
|
|
936
|
+
*/
|
|
937
|
+
disableDetection() {
|
|
938
|
+
this.shouldDetect = !1;
|
|
939
|
+
}
|
|
940
|
+
refreshLayer() {
|
|
941
|
+
this.layer.refresh();
|
|
942
|
+
}
|
|
943
|
+
getElements() {
|
|
944
|
+
return [...this.elements];
|
|
945
|
+
}
|
|
946
|
+
destroy() {
|
|
947
|
+
this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp), this.layer.destroy();
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
const Te = "handle-line", Ie = "handle-start", _e = "handle-end";
|
|
951
|
+
class Hn extends qe {
|
|
952
|
+
constructor(t, s = {}) {
|
|
953
|
+
super(
|
|
954
|
+
t,
|
|
955
|
+
`
|
|
956
|
+
<div class="arrow-handle">
|
|
957
|
+
<div id="${Te}" data-handle-id="0" class="handle line"></div>
|
|
958
|
+
<div id="${Ie}" data-handle-id="1" class="handle"></div>
|
|
959
|
+
<div id="${_e}" data-handle-id="2" class="handle"></div>
|
|
960
|
+
</div>
|
|
961
|
+
`
|
|
962
|
+
);
|
|
963
|
+
// active handle id
|
|
964
|
+
m(this, "draggedHandle", B);
|
|
965
|
+
m(this, "start", { x: 0, y: 0 });
|
|
966
|
+
m(this, "end", { x: 0, y: 0 });
|
|
967
|
+
m(this, "arrow", { ...Se });
|
|
968
|
+
m(this, "startX", 0);
|
|
969
|
+
m(this, "startY", 0);
|
|
970
|
+
m(this, "minArrowHeight", 0);
|
|
971
|
+
m(this, "maxArrowHeight", 0);
|
|
972
|
+
m(this, "handles", []);
|
|
973
|
+
m(this, "onHandleMouseDown", (t) => {
|
|
974
|
+
const s = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
975
|
+
s && (this.startDragging(s, t.clientX, t.clientY), this.draggedHandle = He(t.target));
|
|
976
|
+
});
|
|
977
|
+
m(this, "onMouseUp", () => {
|
|
978
|
+
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = B, this.emit(Ot, this.arrow));
|
|
979
|
+
});
|
|
980
|
+
m(this, "onMouseMove", (t) => {
|
|
981
|
+
if (!this.isDragging || this.draggedHandle === B)
|
|
982
|
+
return;
|
|
983
|
+
const s = this.handles[this.draggedHandle], a = this.ogma.view.getZoom(), c = (t.clientX - this.startX) / a, g = (t.clientY - this.startY) / a, y = s.id === Te, f = s.id === Ie, r = s.id === _e;
|
|
984
|
+
(y || f) && Ne(this.arrow, this.start.x + c, this.start.y + g), (y || r) && $e(this.arrow, this.end.x + c, this.end.y + g), this.emit(
|
|
985
|
+
ae,
|
|
986
|
+
this.arrow,
|
|
987
|
+
y ? "line" : f ? "start" : "end"
|
|
988
|
+
), this.refreshEditor(), this.layer.refresh();
|
|
989
|
+
});
|
|
990
|
+
this.minArrowHeight = s.minArrowHeight || 0, this.maxArrowHeight = s.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call(
|
|
991
|
+
this.editor.element.querySelectorAll(".arrow-handle>.handle")
|
|
992
|
+
), this.handles.forEach(
|
|
993
|
+
(a) => a.addEventListener("mousedown", this.onHandleMouseDown)
|
|
994
|
+
), document.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("mouseup", this.onMouseUp);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Start drawing a new arrow, it will also be added as a new annotation
|
|
998
|
+
* @param x
|
|
999
|
+
* @param y
|
|
1000
|
+
* @param arrow
|
|
1001
|
+
*/
|
|
1002
|
+
startDrawing(t, s, a = _n(t, s, t, s, Dt)) {
|
|
1003
|
+
this.add(a), this.hoveredId = a.id;
|
|
1004
|
+
const c = this.ogma.view.graphToScreenCoordinates({ x: t, y: s });
|
|
1005
|
+
this.startDragging(this.getById(a.id), c.x, c.y), this.draggedHandle = 2;
|
|
1006
|
+
}
|
|
1007
|
+
cancelDrawing() {
|
|
1008
|
+
this.isDragging && (this.remove(this.arrow.id), this.emit(Ot, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = B);
|
|
1009
|
+
}
|
|
1010
|
+
startDragging(t, s, a) {
|
|
1011
|
+
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = s, this.startY = a, this.start = _t(this.arrow), this.end = Ht(this.arrow), this.disableDragging(), this.emit(le, this.arrow), this.isDragging = !0;
|
|
1012
|
+
}
|
|
1013
|
+
detect(t, s = 0) {
|
|
1014
|
+
return this.elements.find((a) => {
|
|
1015
|
+
const { start: c, end: g } = Rt(a), y = new rt(t.x, t.y).sub(
|
|
1016
|
+
new rt((c.x + g.x) / 2, (c.y + g.y) / 2)
|
|
1017
|
+
), f = new rt(g.x, g.y).sub(new rt(c.x, c.y)), r = f.length(), d = f.normalize(), v = Re(a);
|
|
1018
|
+
return Math.abs(d.dot(y)) < r / 2 + s && Math.abs(d.rotateRadians(Math.PI / 2).dot(y)) < v / 2 + s;
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
refreshEditor() {
|
|
1022
|
+
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
1023
|
+
return;
|
|
1024
|
+
const t = this.selectedId !== B ? this.getById(this.selectedId) : this.getById(this.hoveredId), { start: s, end: a } = Rt(t);
|
|
1025
|
+
this.editor.setPosition({ x: 0, y: 0 }).setSize({ width: "100%", height: "100%" });
|
|
1026
|
+
const [c, g, y] = Array.prototype.slice.call(
|
|
1027
|
+
this.editor.element.querySelectorAll(".handle")
|
|
1028
|
+
);
|
|
1029
|
+
g.style.left = `${s.x}px`, g.style.top = `${s.y}px`, y.style.left = `${a.x}px`, y.style.top = `${a.y}px`;
|
|
1030
|
+
const f = {
|
|
1031
|
+
x: (a.x + s.x) / 2,
|
|
1032
|
+
y: (a.y + s.y) / 2
|
|
1033
|
+
}, r = new rt(a.x - s.x, a.y - s.y), d = r.mul(1 / r.length()), v = Math.atan2(d.y, d.x);
|
|
1034
|
+
c.style.width = `${r.length()}px`, c.style.left = `${f.x}px`, c.style.top = `${f.y}px`, c.style.transform = `translate(-50%, -50%) rotate(${v}rad)`;
|
|
1035
|
+
}
|
|
1036
|
+
getDefaultOptions() {
|
|
1037
|
+
return Se;
|
|
1038
|
+
}
|
|
1039
|
+
draw(t) {
|
|
1040
|
+
t.innerHTML = "";
|
|
1041
|
+
const s = It("g");
|
|
1042
|
+
this.elements.forEach(
|
|
1043
|
+
(a) => zn(a, s, Dt, this.minArrowHeight, this.maxArrowHeight)
|
|
1044
|
+
), t.appendChild(s);
|
|
1045
|
+
}
|
|
1046
|
+
destroy() {
|
|
1047
|
+
super.destroy(), document.removeEventListener("mousemove", this.onMouseMove, !0), document.removeEventListener("mouseup", this.onMouseUp);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
const bt = {
|
|
1051
|
+
font: "sans-serif",
|
|
1052
|
+
fontSize: "12",
|
|
1053
|
+
color: "black",
|
|
1054
|
+
background: "",
|
|
1055
|
+
strokeWidth: 1,
|
|
1056
|
+
strokeColor: "#000",
|
|
1057
|
+
strokeType: "plain"
|
|
1058
|
+
}, te = {
|
|
1059
|
+
id: 0,
|
|
1060
|
+
type: "Feature",
|
|
1061
|
+
properties: {
|
|
1062
|
+
type: "text",
|
|
1063
|
+
content: "",
|
|
1064
|
+
style: { ...bt }
|
|
1065
|
+
},
|
|
1066
|
+
geometry: {
|
|
1067
|
+
type: "Polygon",
|
|
1068
|
+
coordinates: [
|
|
1069
|
+
[
|
|
1070
|
+
[0, 0],
|
|
1071
|
+
[100, 0],
|
|
1072
|
+
[100, 50],
|
|
1073
|
+
[0, 50],
|
|
1074
|
+
[0, 0]
|
|
1075
|
+
]
|
|
1076
|
+
]
|
|
1077
|
+
}
|
|
1078
|
+
// position: { x: 0, y: 0 },
|
|
1079
|
+
// size: { width: 100, height: 50 }
|
|
1080
|
+
}, De = {
|
|
1081
|
+
handleSize: 3.5,
|
|
1082
|
+
placeholder: "Your text..."
|
|
1083
|
+
}, Rn = (u = 0, l = 0, t = 100, s = 50, a = "", c = { ...bt }) => ({
|
|
1084
|
+
id: jt(),
|
|
1085
|
+
type: "Feature",
|
|
1086
|
+
properties: {
|
|
1087
|
+
type: "text",
|
|
1088
|
+
content: a,
|
|
1089
|
+
style: { ...bt, ...c }
|
|
1090
|
+
},
|
|
1091
|
+
geometry: {
|
|
1092
|
+
type: "Polygon",
|
|
1093
|
+
coordinates: [
|
|
1094
|
+
[
|
|
1095
|
+
[u, l],
|
|
1096
|
+
[u + t, l],
|
|
1097
|
+
[u + t, l + s],
|
|
1098
|
+
[u, l + s],
|
|
1099
|
+
[u, l]
|
|
1100
|
+
]
|
|
1101
|
+
]
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
var Be = { exports: {} };
|
|
1105
|
+
(function(u, l) {
|
|
1106
|
+
(function(t, s) {
|
|
1107
|
+
u.exports = s();
|
|
1108
|
+
})(Tn, () => (() => {
|
|
1109
|
+
var t = { d: (e, n) => {
|
|
1110
|
+
for (var o in n)
|
|
1111
|
+
t.o(n, o) && !t.o(e, o) && Object.defineProperty(e, o, { enumerable: !0, get: n[o] });
|
|
1112
|
+
}, o: (e, n) => Object.prototype.hasOwnProperty.call(e, n) }, s = {};
|
|
1113
|
+
function a(e) {
|
|
1114
|
+
return a = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1115
|
+
return typeof n;
|
|
1116
|
+
} : function(n) {
|
|
1117
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1118
|
+
}, a(e);
|
|
1119
|
+
}
|
|
1120
|
+
t.d(s, { default: () => Sn });
|
|
1121
|
+
var c = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, g = /\bsmall-caps\b/, y = /\b(?:italic|oblique)\b/, f = /\bbold(?:er)?\b/, r = 13.3333333, d = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
1122
|
+
function v(e) {
|
|
1123
|
+
var n = "", o = this;
|
|
1124
|
+
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;
|
|
1125
|
+
}
|
|
1126
|
+
var T = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: v, valueOf: v };
|
|
1127
|
+
function _(e) {
|
|
1128
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = c.exec(e);
|
|
1129
|
+
n.family = (o[6] || "").trim();
|
|
1130
|
+
var i = d[o[2]] || parseFloat(o[2]);
|
|
1131
|
+
o[3] === "%" ? i *= 0.16 : o[3] === "em" ? i *= 16 : o[3] === "pt" && (i *= r), n.size = i;
|
|
1132
|
+
var h = parseFloat(o[4]);
|
|
1133
|
+
if (h !== "normal" && h !== "inherit" && h ? o[5] && o[5] !== "em" ? o[5] === "pt" ? n.height = h * r : o[5] === "%" ? n.height = 0.01 * i : n.height = h : n.height = h * i : n.height = Math.round(i * (7 / 6)), g.test(o[1]) && (n.variant = "small-caps"), y.test(o[1]) && (n.style = "italic"), f.test(o[1]))
|
|
1134
|
+
n.weight = "bold";
|
|
1135
|
+
else {
|
|
1136
|
+
var p = parseInt(/\b(\d+)\b/.exec(o[1]), 10);
|
|
1137
|
+
p >= 100 && p !== 400 && (n.weight = p);
|
|
1138
|
+
}
|
|
1139
|
+
return n;
|
|
1140
|
+
}
|
|
1141
|
+
function E() {
|
|
1142
|
+
var e, n, o, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", h = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, p = 14, w = 12, x = null, b = null, S = "";
|
|
1143
|
+
if (i && i.nodeType) {
|
|
1144
|
+
var D = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView), O = D.getComputedStyle(i, null);
|
|
1145
|
+
e = O.getPropertyValue("font-family") || "", w = parseFloat(O.getPropertyValue("font-size")), p = O.getPropertyValue("line-height"), x = O.getPropertyValue("font-weight"), b = O.getPropertyValue("font-style"), S = O.getPropertyValue("font-variant") || "";
|
|
1146
|
+
} else if (typeof i == "string") {
|
|
1147
|
+
var k = _(i);
|
|
1148
|
+
e = k.family, w = k.size, p = k.height, S = k.variant, b = k.style, x = k.weight;
|
|
1149
|
+
} else
|
|
1150
|
+
a(i) === "object" && (e = i.family, w = i.size, p = i.height, S = i.variant, x = i.weight, b = i.style, n = i.baseline, o = i.color);
|
|
1151
|
+
h.size && h.size < 3 && (w *= h.size), p = p !== "normal" && p ? parseFloat(p) : w * (7 / 6), h.height && h.height < 3 && (p *= h.height);
|
|
1152
|
+
var M = Object.create(T);
|
|
1153
|
+
return M.family = h.family || e || "sans-serif", M.height = p ?? 14, M.size = w ?? 12, M.variant = h.variant || S || "", M.style = h.style || b || "", M.weight = h.weight || x || "", M.baseline = n || 0, h.baseline != null && (M.baseline = h.baseline), M.color = h.color || o || "", M.id = v.call(M, !0), M;
|
|
1154
|
+
}
|
|
1155
|
+
const P = { "\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 };
|
|
1156
|
+
var A, U = function(e) {
|
|
1157
|
+
var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas");
|
|
1158
|
+
if (n && n.getContext) {
|
|
1159
|
+
var o = n.getContext("2d");
|
|
1160
|
+
if (o && typeof o.measureText == "function")
|
|
1161
|
+
return function(i, h) {
|
|
1162
|
+
return o.font = String(h), o.measureText(i).width;
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
}(typeof document < "u" ? document : null) || (A = {}, function(e, n) {
|
|
1166
|
+
if (!A[n]) {
|
|
1167
|
+
var o = E(n);
|
|
1168
|
+
A[n] = o, /\bmonospace\b/.test(o.family) ? o.size *= 0.6 : (o.size *= 0.45, o.weight && (o.size *= 1.18));
|
|
1169
|
+
}
|
|
1170
|
+
return e.length * A[n].size;
|
|
1171
|
+
}), N = {}, z = { trim: !0, collapse: !0 };
|
|
1172
|
+
function W(e, n, o) {
|
|
1173
|
+
var i = Object.assign({}, z, o), h = String(e);
|
|
1174
|
+
if (!h)
|
|
1175
|
+
return 0;
|
|
1176
|
+
if (h in P) {
|
|
1177
|
+
var p = n.id + "/" + h;
|
|
1178
|
+
return p in N || (N[p] = U("_".concat(h, "_"), n) - U("__", n)), N[p];
|
|
1179
|
+
}
|
|
1180
|
+
return i.trim && i.collapse ? i.trim ? h = h.trim() : i.collapse && (h = h.replace(/\s+/g, " ")) : h = h.replace(/\n/g, " "), U(h, n) + n.size * (e.tracking || 0);
|
|
1181
|
+
}
|
|
1182
|
+
function nt(e) {
|
|
1183
|
+
return nt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1184
|
+
return typeof n;
|
|
1185
|
+
} : function(n) {
|
|
1186
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1187
|
+
}, nt(e);
|
|
1188
|
+
}
|
|
1189
|
+
function Ft(e, n) {
|
|
1190
|
+
if (typeof n != "function" && n !== null)
|
|
1191
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
1192
|
+
e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n && qt(e, n);
|
|
1193
|
+
}
|
|
1194
|
+
function qt(e, n) {
|
|
1195
|
+
return qt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, i) {
|
|
1196
|
+
return o.__proto__ = i, o;
|
|
1197
|
+
}, qt(e, n);
|
|
1198
|
+
}
|
|
1199
|
+
function Bt(e) {
|
|
1200
|
+
var n = function() {
|
|
1201
|
+
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
|
|
1202
|
+
return !1;
|
|
1203
|
+
if (typeof Proxy == "function")
|
|
1204
|
+
return !0;
|
|
1205
|
+
try {
|
|
1206
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
1207
|
+
})), !0;
|
|
1208
|
+
} catch {
|
|
1209
|
+
return !1;
|
|
1210
|
+
}
|
|
1211
|
+
}();
|
|
1212
|
+
return function() {
|
|
1213
|
+
var o, i = Mt(e);
|
|
1214
|
+
if (n) {
|
|
1215
|
+
var h = Mt(this).constructor;
|
|
1216
|
+
o = Reflect.construct(i, arguments, h);
|
|
1217
|
+
} else
|
|
1218
|
+
o = i.apply(this, arguments);
|
|
1219
|
+
return Ve(this, o);
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
function Ve(e, n) {
|
|
1223
|
+
if (n && (nt(n) === "object" || typeof n == "function"))
|
|
1224
|
+
return n;
|
|
1225
|
+
if (n !== void 0)
|
|
1226
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1227
|
+
return function(o) {
|
|
1228
|
+
if (o === void 0)
|
|
1229
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1230
|
+
return o;
|
|
1231
|
+
}(e);
|
|
1232
|
+
}
|
|
1233
|
+
function Mt(e) {
|
|
1234
|
+
return Mt = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
|
|
1235
|
+
return n.__proto__ || Object.getPrototypeOf(n);
|
|
1236
|
+
}, Mt(e);
|
|
1237
|
+
}
|
|
1238
|
+
function zt(e, n) {
|
|
1239
|
+
if (!(e instanceof n))
|
|
1240
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1241
|
+
}
|
|
1242
|
+
function he(e, n) {
|
|
1243
|
+
for (var o = 0; o < n.length; o++) {
|
|
1244
|
+
var i = n[o];
|
|
1245
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (h = function(p, w) {
|
|
1246
|
+
if (nt(p) !== "object" || p === null)
|
|
1247
|
+
return p;
|
|
1248
|
+
var x = p[Symbol.toPrimitive];
|
|
1249
|
+
if (x !== void 0) {
|
|
1250
|
+
var b = x.call(p, w);
|
|
1251
|
+
if (nt(b) !== "object")
|
|
1252
|
+
return b;
|
|
1253
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1254
|
+
}
|
|
1255
|
+
return String(p);
|
|
1256
|
+
}(i.key, "string"), nt(h) === "symbol" ? h : String(h)), i);
|
|
1257
|
+
}
|
|
1258
|
+
var h;
|
|
1259
|
+
}
|
|
1260
|
+
function Lt(e, n, o) {
|
|
1261
|
+
return n && he(e.prototype, n), o && he(e, o), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
1262
|
+
}
|
|
1263
|
+
var H = function() {
|
|
1264
|
+
function e() {
|
|
1265
|
+
var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
1266
|
+
zt(this, e), this.value = n, this.weight = null, this.style = null, this.font = null, this.href = null, this.sub = !1, this.sup = !1;
|
|
1267
|
+
}
|
|
1268
|
+
return Lt(e, [{ key: "clone", value: function() {
|
|
1269
|
+
var n = new e(this.value);
|
|
1270
|
+
return n.value = this.value, n.weight = this.weight, n.style = this.style, n.font = this.font, n.href = this.href, n.sub = this.sub, n.sup = this.sup, n;
|
|
1271
|
+
} }, { key: "valueOf", value: function() {
|
|
1272
|
+
return this.value;
|
|
1273
|
+
} }, { key: "toString", value: function() {
|
|
1274
|
+
return this.value;
|
|
1275
|
+
} }]), e;
|
|
1276
|
+
}(), St = function(e) {
|
|
1277
|
+
Ft(o, e);
|
|
1278
|
+
var n = Bt(o);
|
|
1279
|
+
function o() {
|
|
1280
|
+
return zt(this, o), n.apply(this, arguments);
|
|
1281
|
+
}
|
|
1282
|
+
return Lt(o);
|
|
1283
|
+
}(H), tt = function(e) {
|
|
1284
|
+
Ft(o, e);
|
|
1285
|
+
var n = Bt(o);
|
|
1286
|
+
function o() {
|
|
1287
|
+
return zt(this, o), n.apply(this, arguments);
|
|
1288
|
+
}
|
|
1289
|
+
return Lt(o);
|
|
1290
|
+
}(H), ft = function(e) {
|
|
1291
|
+
Ft(o, e);
|
|
1292
|
+
var n = Bt(o);
|
|
1293
|
+
function o() {
|
|
1294
|
+
return zt(this, o), n.apply(this, arguments);
|
|
1295
|
+
}
|
|
1296
|
+
return Lt(o);
|
|
1297
|
+
}(H), Vt = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, Ue = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, ue = /^[\xA0\u2011\u202F\u2060\uFEFF]/, Ye = /^(?:[;\xAD%?…]|,(?!\d))/, Xe = /^[´±°¢£¤$¥\u2212]/;
|
|
1298
|
+
function Pt(e, n) {
|
|
1299
|
+
n !== !1 && (e = e.trim());
|
|
1300
|
+
for (var o, i, h = [], p = e.charAt(0), w = 0, x = 1, b = e.length; x < b; x++) {
|
|
1301
|
+
o = e.charAt(x), i = e.charAt(x + 1);
|
|
1302
|
+
var S = Vt.test(p), D = Vt.test(o), O = D || S, k = void 0;
|
|
1303
|
+
if ((Xe.test(o) && !ue.test(p) || Ye.test(p + i) && !ue.test(o)) && (O = !0), p !== "-" && p !== "‐" && p !== "–" && p !== "—" || ((k = Vt.test(e.charAt(x - 2))) && !D && (O = !1), !k && Ue.test(o + i) && (O = !0)), O) {
|
|
1304
|
+
var M = e.slice(w, x);
|
|
1305
|
+
/\u00AD$/.test(M) ? (h.push(new H(M.slice(0, -1))), h.push(new ft())) : (h.push(new H(M)), h.push(new St())), w = x;
|
|
1306
|
+
}
|
|
1307
|
+
p = o;
|
|
1308
|
+
}
|
|
1309
|
+
return h.push(new H(e.slice(w))), h;
|
|
1310
|
+
}
|
|
1311
|
+
const ce = { 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: "›" };
|
|
1312
|
+
var Ge = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, We = /^<\/([a-zA-Z0-9]+)([^>]*)>/, Ze = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, Ke = /^<!--(.+?)-->/, Je = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, de = { b: function(e) {
|
|
1313
|
+
e.weight = "bold";
|
|
1314
|
+
}, strong: function(e) {
|
|
1315
|
+
e.weight = "bold";
|
|
1316
|
+
}, i: function(e) {
|
|
1317
|
+
e.style = "italic";
|
|
1318
|
+
}, em: function(e) {
|
|
1319
|
+
e.style = "italic";
|
|
1320
|
+
}, dfn: function(e) {
|
|
1321
|
+
e.style = "italic";
|
|
1322
|
+
}, cite: function(e) {
|
|
1323
|
+
e.style = "italic";
|
|
1324
|
+
}, code: function(e) {
|
|
1325
|
+
e.family = "monospace";
|
|
1326
|
+
}, kbd: function(e) {
|
|
1327
|
+
e.family = "monospace";
|
|
1328
|
+
}, samp: function(e) {
|
|
1329
|
+
e.family = "monospace";
|
|
1330
|
+
}, var: function(e) {
|
|
1331
|
+
e.family = "monospace";
|
|
1332
|
+
}, tt: function(e) {
|
|
1333
|
+
e.family = "monospace";
|
|
1334
|
+
}, sub: function(e) {
|
|
1335
|
+
e.sub = !0;
|
|
1336
|
+
}, sup: function(e) {
|
|
1337
|
+
e.sup = !0;
|
|
1338
|
+
} }, Qe = { 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 };
|
|
1339
|
+
function fe(e) {
|
|
1340
|
+
return e.replace(Je, function(n, o, i, h) {
|
|
1341
|
+
if (o || i) {
|
|
1342
|
+
var p = o ? 10 : 16;
|
|
1343
|
+
return String.fromCharCode(parseInt(o || i, p));
|
|
1344
|
+
}
|
|
1345
|
+
return h in ce ? ce[h] : n;
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
function tn(e) {
|
|
1349
|
+
return e && e.length > 1 && (e[0] === '"' && e[e.length - 1] === '"' || e[0] === "'" && e[e.length - 1] === "'") ? e.slice(1, -1) : e;
|
|
1350
|
+
}
|
|
1351
|
+
var en = /^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;
|
|
1352
|
+
function nn(e) {
|
|
1353
|
+
var n, o = {};
|
|
1354
|
+
if (e) {
|
|
1355
|
+
do
|
|
1356
|
+
if (n = en.exec(e)) {
|
|
1357
|
+
var i = fe(tn(n[2] || "")).replace(/[ \r\n\t]+/g, " ").trim();
|
|
1358
|
+
if (o[n[1]] = i, (e = e.slice(n[0].length)).length && /^\S/.test(e[0]))
|
|
1359
|
+
throw new Error("Attribute error");
|
|
1360
|
+
}
|
|
1361
|
+
while (n && e.length);
|
|
1362
|
+
if (/\S/.test(e))
|
|
1363
|
+
throw new Error("Attribute error");
|
|
1364
|
+
}
|
|
1365
|
+
return o;
|
|
1366
|
+
}
|
|
1367
|
+
const pe = { copyright: "©", textcopyright: "©", dag: "†", textdagger: "†", ddag: "‡", textdaggerdbl: "‡", guillemotleft: "«", guillemotright: "»", guilsinglleft: "‹", guilsinglright: "›", ldots: "…", dots: "…", textellipsis: "…", lq: "‘", P: "¶", textparagraph: "¶", pounds: "£", textsterling: "£", quotedblbase: "„", quotesinglbase: "‚", rq: "’", S: "§", sim: "~", textasciicircum: "^", textasciitilde: "˜", texttildelow: "~", textasteriskcentered: "*", textbackslash: "'", textbar: "|", textbardbl: "╎", textbigcircle: "◯", textbraceleft: "{", textbraceright: "}", textbullet: "•", textdollar: "$", textemdash: "—", textendash: "—", texteuro: "€", eurosym: "€", euro: "€", textexclamdown: "¡", textgreater: ">", textless: "<", textordfeminine: "ª", textordmasculine: "º", textperiodcentered: "·", cdot: "·", textquestiondown: "¿", textquotedblleft: "“", textquotedblright: "”", textquoteleft: "‘", textquoteright: "’", textquotestraightbase: "‚", textquotestraightdblbase: "„", textregistered: "®", textthreequartersemdash: "-", texttrademark: "™", texttwelveudash: "-", textunderscore: "_", textvisiblespace: "␣", gets: "←", textleftarrow: "←", to: "→", textrightarrow: "→", textdegree: "°", infty: "∞", triangle: "△", triangledown: "▽", blacktriangle: "▲", blacktriangledown: "▼", angle: "∠", sphericalangle: "∢", aleph: "ℵ", hbar: "ħ", imath: "𝚤", jmath: "𝚥", ell: "ℓ", wp: "℘", Re: "ℜ", Im: "ℑ", mho: "℧", prime: "′", emptyset: "∅", nabla: "∇", surd: "√", partial: "∂", top: "⟙", bot: "⟂", vdash: "⟝", dashv: "⟞", forall: "∀", exists: "∃", nexists: "∄", neg: "¬", lnot: "¬", flat: "♭", natural: "♮", sharp: "♯", backslash: "\\", Box: "□", Diamond: "♢", clubsuit: "♣", diamondsuit: "♦", heartsuit: "♥", spadesuit: "♠", Join: "⨝", blacksquare: "■", bigstar: "★", diagdown: "╲", diagup: "╱", blacklozenge: "⧫", rfloor: "⌋", lfloor: "⌊", rceil: "⌉", lceil: "⌈", rangle: "⟩", langle: "⟨", sum: "∑", int: "∫", oint: "∮", prod: "∏", coprod: "∏", bigcap: "∩", bigcup: "∪", bigsqcup: "⊔", bigvee: "∨", bigwedge: "∧", bigodot: "⊙", bigotimes: "⊗", bigoplus: "⊕", biguplus: "⊎", alpha: "α", beta: "β", chi: "χ", delta: "δ", epsilon: "ε", eta: "η", gamma: "γ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", omega: "ω", phi: "φ", pi: "π", psi: "ψ", rho: "ρ", sigma: "σ", tau: "τ", theta: "θ", upsilon: "υ", xi: "ξ", zeta: "ζ", Alpha: "Α", Beta: "Β", Chi: "Χ", Delta: "Δ", Epsilon: "Ε", Eta: "Η", Gamma: "Γ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Omega: "Ω", Phi: "Φ", Pi: "Π", Psi: "Ψ", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Theta: "Θ", Upsilon: "Υ", Xi: "Ξ", Zeta: "Ζ", aa: "å", AA: "Å", ae: "æ", AE: "Æ", dh: "ð", DH: "Ð", dj: "đ", DJ: "Đ", ij: "ij", IJ: "IJ", l: "ł", L: "Ł", ng: "ŋ", NG: "Ŋ", o: "ø", O: "Ø", oe: "œ", OE: "Œ", ss: "ß", SS: "SS", th: "þ", TH: "Þ" };
|
|
1368
|
+
var rn = /^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/, sn = /^%[^\n]+(?:\n|$)/, on = /^[^#$%&~_^\\{}]+/, an = /^\\([&{}$%#_])/, ln = /(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g, hn = { "---": "—", "--": "–", "!`": "¡", "?`": "¿", "``": "“", ",,": "„", "''": "”", "`": "‘", "'": "’", "<<": "«", ">>": "»", "~": " ", "\\-": "", "\\,": " ", "\\;": " ", "\\:": " ", "\\!": " ", "\\@": "\uFEFF", "\\\\": "\\newline{}" }, V = { bf: function(e) {
|
|
1369
|
+
e.weight = "bold";
|
|
1370
|
+
}, it: function(e) {
|
|
1371
|
+
e.style = "italic";
|
|
1372
|
+
}, sl: function(e) {
|
|
1373
|
+
e.style = "italic";
|
|
1374
|
+
}, color: function(e, n) {
|
|
1375
|
+
e.color = n;
|
|
1376
|
+
}, href: function(e, n) {
|
|
1377
|
+
e.href = n;
|
|
1378
|
+
}, "^": function(e) {
|
|
1379
|
+
e.sup = !0;
|
|
1380
|
+
}, _: function(e) {
|
|
1381
|
+
e.sub = !0;
|
|
1382
|
+
}, par: function(e) {
|
|
1383
|
+
this.tokens.push(new tt(), new tt());
|
|
1384
|
+
}, newline: function(e) {
|
|
1385
|
+
this.tokens.push(new tt());
|
|
1386
|
+
}, url: function(e, n) {
|
|
1387
|
+
this.open_context().href = n, this.add_token(new H(n)), this.close_context();
|
|
1388
|
+
} };
|
|
1389
|
+
V.textsuperscript = V["^"], V.textsubscript = V._, V.textsl = V.sl, V.mathbf = V.bf, V.mathit = V.it, V.textbf = V.bf, V.textit = V.it, V.textcolor = V.color;
|
|
1390
|
+
var un = /[\r\n\xA0]+/g;
|
|
1391
|
+
function cn(e, n) {
|
|
1392
|
+
e.sup && (e.baseline = 0.45, e.size = 0.7), e.sub && (e.baseline = -0.3, e.size = 0.7);
|
|
1393
|
+
var o = n;
|
|
1394
|
+
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o = E(n, e)), o;
|
|
1395
|
+
}
|
|
1396
|
+
function ge(e, n, o) {
|
|
1397
|
+
for (var i, h, p = e.width; p + o.width > n && e.length; )
|
|
1398
|
+
h = (i = e[e.length - 1]).width, i.width > o.width ? (i.value = i.value.slice(0, -1), i.width = W(i, i.font), p += i.width) : e.pop(), p -= h;
|
|
1399
|
+
e[e.length - 1] instanceof ft && e.pop(), i = e[e.length - 1] || i || {}, o.font = E(o.font, i.bold, i.italic, ""), o.href = e.length ? i.href : null, o.rel = e.length ? i.rel : null, o.target = e.length ? i.target : null, e.push(o);
|
|
1400
|
+
}
|
|
1401
|
+
function mt(e) {
|
|
1402
|
+
return Math.round(1e6 * e) / 1e6;
|
|
1403
|
+
}
|
|
1404
|
+
function ye(e) {
|
|
1405
|
+
return function(n) {
|
|
1406
|
+
if (Array.isArray(n))
|
|
1407
|
+
return Ut(n);
|
|
1408
|
+
}(e) || function(n) {
|
|
1409
|
+
if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
|
|
1410
|
+
return Array.from(n);
|
|
1411
|
+
}(e) || function(n, o) {
|
|
1412
|
+
if (n) {
|
|
1413
|
+
if (typeof n == "string")
|
|
1414
|
+
return Ut(n, o);
|
|
1415
|
+
var i = Object.prototype.toString.call(n).slice(8, -1);
|
|
1416
|
+
return i === "Object" && n.constructor && (i = n.constructor.name), i === "Map" || i === "Set" ? Array.from(n) : i === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i) ? Ut(n, o) : void 0;
|
|
1417
|
+
}
|
|
1418
|
+
}(e) || function() {
|
|
1419
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1420
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
1421
|
+
}();
|
|
1422
|
+
}
|
|
1423
|
+
function Ut(e, n) {
|
|
1424
|
+
(n == null || n > e.length) && (n = e.length);
|
|
1425
|
+
for (var o = 0, i = new Array(n); o < n; o++)
|
|
1426
|
+
i[o] = e[o];
|
|
1427
|
+
return i;
|
|
1428
|
+
}
|
|
1429
|
+
var dn = { center: "middle", right: "end" }, fn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, Yt = function(e, n) {
|
|
1430
|
+
return !e && !n || e === n;
|
|
1431
|
+
};
|
|
1432
|
+
function pn(e, n) {
|
|
1433
|
+
var o = [], i = n.font(), h = i.size, p = i.family, w = n.align(), x = n.createElement();
|
|
1434
|
+
if (e.length) {
|
|
1435
|
+
var b = i.height, S = n.valign(), D = n.height()(), O = n.width()(0), k = !isFinite(O) && e.length === 1, M = k ? null : n.x(), R = mt(b / h), K = k ? null : mt(b / (1.15 * h + (b - h) / 2));
|
|
1436
|
+
if (fn[S] && isFinite(D)) {
|
|
1437
|
+
var C = S === "bottom" ? 1 : 0.5;
|
|
1438
|
+
K += (D * C - b * e.length * C) / h;
|
|
1439
|
+
}
|
|
1440
|
+
var L = w === "justify", j = 0;
|
|
1441
|
+
w === "right" ? j = O : w === "center" && (j = O / 2);
|
|
1442
|
+
for (var $ = [], J = "tspan", Y = null, F = "", I = function() {
|
|
1443
|
+
if (F) {
|
|
1444
|
+
var pt = x(J, Y, F);
|
|
1445
|
+
$.push(pt);
|
|
1446
|
+
}
|
|
1447
|
+
J = "tspan", Y = null, F = "";
|
|
1448
|
+
}, et = 0, Q = e.length; et < Q; et++) {
|
|
1449
|
+
var ot = "", ht = "", st = 0, at = e[et];
|
|
1450
|
+
if (at.length) {
|
|
1451
|
+
$ = [];
|
|
1452
|
+
for (var vt = 0, kt = 0, lt = void 0, X = 0, Ct = at.length; X < Ct; X++) {
|
|
1453
|
+
var q = at[X], G = q.font;
|
|
1454
|
+
q.whitespace && vt++, kt += q.width, X && !q.tracking && !st && Yt(G.id, ot) && Yt(q.class, ht) && Yt(lt, q.href) ? F += q.value : (I(), F = q.value, Y = { fontFamily: G.family !== p ? G.family : null, fontSize: G.size !== h ? G.size : null, fontWeight: G.weight || null, fontStyle: G.style || null, fontVariant: G.variant !== "normal" && G.variant || null, fill: G.color || null, baselineShift: G.baseline ? 100 * G.baseline + "%" : null, className: q.class || null }, st && (Y.dx = mt(st), st = 0), q.tracking && (st = G.size * q.tracking), q.href && !lt ? (lt = q.href, J = "a", Y.href = lt, Y.rel = q.rel, Y.target = q.target) : lt = null, ot = G.id, ht = q.class);
|
|
1455
|
+
}
|
|
1456
|
+
if (I(), k)
|
|
1457
|
+
o.push.apply(o, ye($));
|
|
1458
|
+
else {
|
|
1459
|
+
var Nt = null, Tt = et === Q - 1 || at[at.length - 1] instanceof tt;
|
|
1460
|
+
L && at.length > 1 && !Tt && (Nt = mt((O - kt) / vt)), o.push(x.apply(void 0, ["tspan", { wordSpacing: Nt, x: M(et) + j, dy: mt(et ? R : K) + "em" }].concat(ye($))));
|
|
1461
|
+
}
|
|
1462
|
+
} else
|
|
1463
|
+
o.push(x("tspan", { x: M(et), dy: mt(et ? R : K) + "em" }, " "));
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
return x.apply(void 0, ["text", { fontFamily: p, fontSize: h, textAnchor: dn[w] || "start" }].concat(o));
|
|
1467
|
+
}
|
|
1468
|
+
var gn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 };
|
|
1469
|
+
function yn(e, n, o) {
|
|
1470
|
+
if (e.length) {
|
|
1471
|
+
o.textBaseline = "middle";
|
|
1472
|
+
var i = n.font(), h = i.height, p = i.size, w = n.valign(), x = n.height()(), b = n.width()(0), S = n.align(), D = S === "justify", O = 0.5 * h, k = gn[w];
|
|
1473
|
+
if (k && isFinite(x)) {
|
|
1474
|
+
var M = e.length * h;
|
|
1475
|
+
O += x * k - M * k;
|
|
1476
|
+
}
|
|
1477
|
+
e.forEach(function(R, K) {
|
|
1478
|
+
var C = n.x()(K), L = K * h + O, j = 0, $ = 0;
|
|
1479
|
+
R.forEach(function(F) {
|
|
1480
|
+
F.whitespace && j++, $ += F.width;
|
|
1481
|
+
});
|
|
1482
|
+
var J = 0, Y = K === e.length - 1 || R[R.length - 1] instanceof tt;
|
|
1483
|
+
D && R.length > 1 && !Y && (J = (b - $) / j), R.forEach(function(F) {
|
|
1484
|
+
o.font = F.font;
|
|
1485
|
+
var I = F.font, et = I.baseline ? p * -I.baseline + 0.15 * p : 0;
|
|
1486
|
+
o.fillStyle = function(ht, st) {
|
|
1487
|
+
return ht.color ? ht.color : st.href ? "#00C" : "#000";
|
|
1488
|
+
}(I, F);
|
|
1489
|
+
var Q = 0;
|
|
1490
|
+
if (S === "right" ? Q += b - $ : S === "center" ? Q += b / 2 - $ / 2 : S === "justify" && (F.whitespace || F instanceof tt) && (C += J), o.fillText(F.value, C + Q, L + et), F.href) {
|
|
1491
|
+
o.beginPath(), o.strokeStyle = o.fillStyle;
|
|
1492
|
+
var ot = Math.floor(L + 0.45 * p) + 0.5;
|
|
1493
|
+
o.moveTo(C + Q, ot), o.lineTo(C + Q + F.width, ot), o.stroke();
|
|
1494
|
+
}
|
|
1495
|
+
C += F.width;
|
|
1496
|
+
});
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
function Xt(e) {
|
|
1501
|
+
return Xt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1502
|
+
return typeof n;
|
|
1503
|
+
} : function(n) {
|
|
1504
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1505
|
+
}, Xt(e);
|
|
1506
|
+
}
|
|
1507
|
+
function me(e) {
|
|
1508
|
+
for (var n = {}, o = 0; o < e.length; o++) {
|
|
1509
|
+
var i = e[o];
|
|
1510
|
+
typeof i != "number" && i != null && (typeof i == "string" ? n.text = i : typeof i == "function" ? n.fn = i : Xt(i) === "object" && i._groups ? n.d3 = i : i && i.nodeType && i.getContext ? n.ctx = i.getContext("2d") : i && i.fillText && i.beginPath ? n.ctx = i : i && (n.text = i));
|
|
1511
|
+
}
|
|
1512
|
+
return n;
|
|
1513
|
+
}
|
|
1514
|
+
function At(e) {
|
|
1515
|
+
return At = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1516
|
+
return typeof n;
|
|
1517
|
+
} : function(n) {
|
|
1518
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1519
|
+
}, At(e);
|
|
1520
|
+
}
|
|
1521
|
+
function mn(e, n) {
|
|
1522
|
+
for (var o = 0; o < n.length; o++) {
|
|
1523
|
+
var i = n[o];
|
|
1524
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (h = function(p, w) {
|
|
1525
|
+
if (At(p) !== "object" || p === null)
|
|
1526
|
+
return p;
|
|
1527
|
+
var x = p[Symbol.toPrimitive];
|
|
1528
|
+
if (x !== void 0) {
|
|
1529
|
+
var b = x.call(p, w);
|
|
1530
|
+
if (At(b) !== "object")
|
|
1531
|
+
return b;
|
|
1532
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1533
|
+
}
|
|
1534
|
+
return String(p);
|
|
1535
|
+
}(i.key, "string"), At(h) === "symbol" ? h : String(h)), i);
|
|
1536
|
+
}
|
|
1537
|
+
var h;
|
|
1538
|
+
}
|
|
1539
|
+
var vn = E(), Gt = function(e) {
|
|
1540
|
+
return typeof e == "function" ? e : function() {
|
|
1541
|
+
return e;
|
|
1542
|
+
};
|
|
1543
|
+
}, it = function() {
|
|
1544
|
+
function e(i) {
|
|
1545
|
+
if (function(p, w) {
|
|
1546
|
+
if (!(p instanceof w))
|
|
1547
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1548
|
+
}(this, e), this.props = { overflow: "ellipsis", lineclamp: null, align: "left", wordBreak: null, valign: "top", width: function() {
|
|
1549
|
+
return 1 / 0;
|
|
1550
|
+
}, height: function() {
|
|
1551
|
+
return 1 / 0;
|
|
1552
|
+
}, x: function() {
|
|
1553
|
+
return 0;
|
|
1554
|
+
}, font: null, tAnchor: 0, parser: e.defaultparser }, i)
|
|
1555
|
+
for (var h in i)
|
|
1556
|
+
typeof this[h] == "function" && this[h](i[h]);
|
|
1557
|
+
}
|
|
1558
|
+
var n, o;
|
|
1559
|
+
return n = e, o = [{ key: "linebreak", value: function(i) {
|
|
1560
|
+
var h = this, p = this.props.parser(String(i)), w = this.font(), x = function(b, S, D) {
|
|
1561
|
+
if (!b.length)
|
|
1562
|
+
return [];
|
|
1563
|
+
var O = S.height(), k = S.width(), M = S.overflowLine(), R = S.overflowWrap(), K = E(D, !0, !1), C = isFinite(O()) ? Math.floor(O() / D.height) : 1 / 0;
|
|
1564
|
+
if (!O() && !k(0) || !C)
|
|
1565
|
+
return [];
|
|
1566
|
+
for (var L = 0, j = 0, $ = 0, J = [], Y = [], F = !1; L < b.length && j < C; ) {
|
|
1567
|
+
var I = b[L], et = cn(I, D);
|
|
1568
|
+
if (I.width = W(I, et), I.font = et, I.line = j, I.whitespace = I.value in P, I.value && (I.value = I.value.replace(un, " ")), !(!$ && I.whitespace || F && I.whitespace))
|
|
1569
|
+
if (I instanceof tt)
|
|
1570
|
+
$ = 0, Y = [], J.push(L + 1), j++;
|
|
1571
|
+
else if (I instanceof St || I instanceof ft)
|
|
1572
|
+
Y.push({ index: L, width: $ });
|
|
1573
|
+
else if (I.whitespace || $ + I.width < k(j))
|
|
1574
|
+
$ += I.width;
|
|
1575
|
+
else if (Y.length) {
|
|
1576
|
+
var Q = void 0, ot = void 0;
|
|
1577
|
+
do {
|
|
1578
|
+
ot = !0, Q = Y.pop();
|
|
1579
|
+
var ht = b[Q.index], st = void 0;
|
|
1580
|
+
ht instanceof ft && (st = W("-", ht.font), Q.width + st > k(j) && (ot = !Y.length));
|
|
1581
|
+
} while (!ot);
|
|
1582
|
+
J.push(Q.index + 1), $ = 0, j++, L = Q.index, Y = [];
|
|
1583
|
+
} else if (R === "break-word") {
|
|
1584
|
+
var at = k(j);
|
|
1585
|
+
if ($ + I.width > at) {
|
|
1586
|
+
var vt = I.clone();
|
|
1587
|
+
do
|
|
1588
|
+
I.value = I.value.slice(0, -1), I.width = W(I, I.font), $ += I.width;
|
|
1589
|
+
while (I.value && I.width > at);
|
|
1590
|
+
vt.value = vt.value.slice(I.value.length), b.splice(L + 1, 0, new St(), vt);
|
|
1591
|
+
}
|
|
1592
|
+
J.push(L + 1), $ = 0, j++;
|
|
1593
|
+
} else
|
|
1594
|
+
$ += I.width;
|
|
1595
|
+
L++, F = I.whitespace;
|
|
1596
|
+
}
|
|
1597
|
+
L !== J[J.length - 1] && J.push(L);
|
|
1598
|
+
var kt = 0, lt = 0, X = J.map(function(pt) {
|
|
1599
|
+
for (var Z, gt = kt; (Z = b[gt]) && (Z.whitespace || !Z.value); )
|
|
1600
|
+
gt++;
|
|
1601
|
+
for (var ut = pt, Kt = null; ut > gt && (Z = b[ut - 1]) && (Z.whitespace || !(Z.value || Z instanceof ft)); )
|
|
1602
|
+
Z instanceof tt && (Kt = Z), ut--;
|
|
1603
|
+
Z instanceof ft && (Z.value = "-", Z.width = W("-", Z.font)), kt = pt;
|
|
1604
|
+
var xt = b.slice(gt, ut).filter(function(Jt) {
|
|
1605
|
+
return Jt.value;
|
|
1606
|
+
});
|
|
1607
|
+
return Kt && xt.push(Kt), xt.width = xt.reduce(function(Jt, An) {
|
|
1608
|
+
return Jt + An.width;
|
|
1609
|
+
}, 0), xt.width > lt && (lt = xt.width), xt;
|
|
1610
|
+
});
|
|
1611
|
+
if (X.hasLineOverflow = !1, M) {
|
|
1612
|
+
var Ct = M === "ellipsis" ? "…" : M;
|
|
1613
|
+
X.forEach(function(pt, Z) {
|
|
1614
|
+
var gt = k(Z);
|
|
1615
|
+
if (pt.width > gt) {
|
|
1616
|
+
var ut = new H(Ct);
|
|
1617
|
+
ut.font = D, ut.width = W(Ct, K), ge(pt, gt, ut), X.hasLineOverflow = !0;
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
var q = S.overflow() === "ellipsis" ? "…" : S.overflow();
|
|
1622
|
+
if (q && L !== b.length) {
|
|
1623
|
+
var G = k(X.length - 1), Nt = X[X.length - 1], Tt = new H(q);
|
|
1624
|
+
Tt.font = D, Tt.width = W(q, K), ge(Nt, G, Tt), X.hasOverflow = !0;
|
|
1625
|
+
} else
|
|
1626
|
+
X.hasOverflow = !1;
|
|
1627
|
+
return X.font = D, X.width = lt, X;
|
|
1628
|
+
}(p, this, w);
|
|
1629
|
+
return x.height = x.length * w.height, x.render = function(b) {
|
|
1630
|
+
return h.render(x, b);
|
|
1631
|
+
}, x.svg = x.render, x.draw = x.render, x;
|
|
1632
|
+
} }, { key: "font", value: function(i) {
|
|
1633
|
+
return arguments.length ? (this.props.font = E(i), this) : this.props.font || E(vn);
|
|
1634
|
+
} }, { key: "overflow", value: function(i) {
|
|
1635
|
+
return arguments.length ? (this.props.overflow = String(i), this) : this.props.overflow;
|
|
1636
|
+
} }, { key: "overflowLine", value: function(i) {
|
|
1637
|
+
return arguments.length ? (this.props.lineclamp = String(i), this) : this.props.lineclamp;
|
|
1638
|
+
} }, { key: "valign", value: function(i) {
|
|
1639
|
+
return arguments.length ? (this.props.valign = i, this) : this.props.valign;
|
|
1640
|
+
} }, { key: "align", value: function(i) {
|
|
1641
|
+
if (!arguments.length)
|
|
1642
|
+
return this.props.align;
|
|
1643
|
+
var h = String(i).toLowerCase();
|
|
1644
|
+
return h === "left" || h === "start" ? (this.props.align = "left", this.props.tAnchor = 0) : h === "center" || h === "middle" ? (this.props.align = "center", this.props.tAnchor = -0.5) : h === "end" || h === "right" ? (this.props.align = "right", this.props.tAnchor = -1) : h === "justify" && (this.props.align = i, this.props.tAnchor = 0), this;
|
|
1645
|
+
} }, { key: "overflowWrap", value: function(i) {
|
|
1646
|
+
if (!arguments.length)
|
|
1647
|
+
return this.props.overflowWrap || "normal";
|
|
1648
|
+
var h = String(i).toLowerCase();
|
|
1649
|
+
return h === "break-word" ? this.props.overflowWrap = "break-word" : h !== "normal" && i != null || (this.props.overflowWrap = null), this;
|
|
1650
|
+
} }, { key: "width", value: function(i) {
|
|
1651
|
+
return arguments.length ? (this.props.width = Gt(i), this) : this.props.width;
|
|
1652
|
+
} }, { key: "height", value: function(i) {
|
|
1653
|
+
return arguments.length ? (this.props.height = Gt(i), this) : this.props.height;
|
|
1654
|
+
} }, { key: "x", value: function(i) {
|
|
1655
|
+
return arguments.length ? (this.props.x = Gt(i), this) : this.props.x;
|
|
1656
|
+
} }, { key: "parser", value: function(i) {
|
|
1657
|
+
if (!arguments.length)
|
|
1658
|
+
return this.props.parser;
|
|
1659
|
+
if (typeof i == "string") {
|
|
1660
|
+
var h = e[i] || e[i + "parser"];
|
|
1661
|
+
typeof h == "function" && (i = h);
|
|
1662
|
+
}
|
|
1663
|
+
if (typeof i != "function")
|
|
1664
|
+
throw new Error("Unknown parser: " + i);
|
|
1665
|
+
return this.props.parser = i, this;
|
|
1666
|
+
} }, { key: "createElement", value: function(i) {
|
|
1667
|
+
return arguments.length ? (this.props.createElement = i, this) : this.props.createElement || e.createElement;
|
|
1668
|
+
} }, { key: "render", value: function() {
|
|
1669
|
+
var i = me(arguments);
|
|
1670
|
+
return typeof i.text == "string" && (i.text = this.linebreak(i.text)), i.ctx ? yn(i.text, this, i.ctx) : pn(i.text, this);
|
|
1671
|
+
} }], o && mn(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1672
|
+
}();
|
|
1673
|
+
function Et(e) {
|
|
1674
|
+
return Et = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1675
|
+
return typeof n;
|
|
1676
|
+
} : function(n) {
|
|
1677
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1678
|
+
}, Et(e);
|
|
1679
|
+
}
|
|
1680
|
+
function Wt(e, n) {
|
|
1681
|
+
(n == null || n > e.length) && (n = e.length);
|
|
1682
|
+
for (var o = 0, i = new Array(n); o < n; o++)
|
|
1683
|
+
i[o] = e[o];
|
|
1684
|
+
return i;
|
|
1685
|
+
}
|
|
1686
|
+
function xn(e, n) {
|
|
1687
|
+
for (var o = 0; o < n.length; o++) {
|
|
1688
|
+
var i = n[o];
|
|
1689
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (h = function(p, w) {
|
|
1690
|
+
if (Et(p) !== "object" || p === null)
|
|
1691
|
+
return p;
|
|
1692
|
+
var x = p[Symbol.toPrimitive];
|
|
1693
|
+
if (x !== void 0) {
|
|
1694
|
+
var b = x.call(p, w);
|
|
1695
|
+
if (Et(b) !== "object")
|
|
1696
|
+
return b;
|
|
1697
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1698
|
+
}
|
|
1699
|
+
return String(p);
|
|
1700
|
+
}(i.key, "string"), Et(h) === "symbol" ? h : String(h)), i);
|
|
1701
|
+
}
|
|
1702
|
+
var h;
|
|
1703
|
+
}
|
|
1704
|
+
var ve = function(e) {
|
|
1705
|
+
return typeof e == "function" ? e : function() {
|
|
1706
|
+
return e;
|
|
1707
|
+
};
|
|
1708
|
+
}, xe = function() {
|
|
1709
|
+
function e(i) {
|
|
1710
|
+
if (function(p, w) {
|
|
1711
|
+
if (!(p instanceof w))
|
|
1712
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1713
|
+
}(this, e), this.props = { width: function() {
|
|
1714
|
+
return 1 / 0;
|
|
1715
|
+
}, height: function() {
|
|
1716
|
+
return 1 / 0;
|
|
1717
|
+
}, rotation: 0, vAnchor: 0, hAnchor: 0 }, i)
|
|
1718
|
+
for (var h in i)
|
|
1719
|
+
typeof this[h] == "function" && this[h](i[h]);
|
|
1720
|
+
this.render = this.render.bind(this);
|
|
1721
|
+
}
|
|
1722
|
+
var n, o;
|
|
1723
|
+
return n = e, o = [{ key: "anchor", value: function(i) {
|
|
1724
|
+
var h = this.props, p = h.hAnchor, w = h.vAnchor, x = h.width, b = h.height;
|
|
1725
|
+
if (!arguments.length)
|
|
1726
|
+
return [p * x(0), w * b(0)];
|
|
1727
|
+
if (typeof i == "string") {
|
|
1728
|
+
var S = this.props;
|
|
1729
|
+
i.toLowerCase().trim().split(/\s+/).forEach(function(D) {
|
|
1730
|
+
D === "top" && (S.vAnchor = -0), D === "middle" && (S.vAnchor = -0.5), D === "bottom" && (S.vAnchor = -1), D === "left" && (S.hAnchor = -0), D === "center" && (S.hAnchor = -0.5), D === "right" && (S.hAnchor = -1);
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
return this;
|
|
1734
|
+
} }, { key: "width", value: function(i) {
|
|
1735
|
+
return arguments.length ? (this.props.width = ve(i), this) : this.props.width;
|
|
1736
|
+
} }, { key: "height", value: function(i) {
|
|
1737
|
+
return arguments.length ? (this.props.height = ve(i), this) : this.props.height;
|
|
1738
|
+
} }, { key: "rotate", value: function(i) {
|
|
1739
|
+
return arguments.length ? (this.props.rotation = i, this) : this.props.rotation;
|
|
1740
|
+
} }, { key: "createElement", value: function(i) {
|
|
1741
|
+
return arguments.length ? (this.props.createElement = i, this) : this.props.createElement || e.createElement;
|
|
1742
|
+
} }, { key: "canvas", value: function(i, h) {
|
|
1743
|
+
var p, w = i.getContext ? i.getContext("2d") : i;
|
|
1744
|
+
return w.save(), w.rotate(this.rotate() * Math.PI / 180), w.translate.apply(w, function(x) {
|
|
1745
|
+
if (Array.isArray(x))
|
|
1746
|
+
return Wt(x);
|
|
1747
|
+
}(p = this.anchor()) || function(x) {
|
|
1748
|
+
if (typeof Symbol < "u" && x[Symbol.iterator] != null || x["@@iterator"] != null)
|
|
1749
|
+
return Array.from(x);
|
|
1750
|
+
}(p) || function(x, b) {
|
|
1751
|
+
if (x) {
|
|
1752
|
+
if (typeof x == "string")
|
|
1753
|
+
return Wt(x, b);
|
|
1754
|
+
var S = Object.prototype.toString.call(x).slice(8, -1);
|
|
1755
|
+
return S === "Object" && x.constructor && (S = x.constructor.name), S === "Map" || S === "Set" ? Array.from(x) : S === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S) ? Wt(x, b) : void 0;
|
|
1756
|
+
}
|
|
1757
|
+
}(p) || function() {
|
|
1758
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1759
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
1760
|
+
}()), h(w), w.restore(), w;
|
|
1761
|
+
} }, { key: "render", value: function() {
|
|
1762
|
+
var i = me(arguments);
|
|
1763
|
+
if (i.d3)
|
|
1764
|
+
return i.d3.attr("transform", "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")"));
|
|
1765
|
+
if (i.ctx)
|
|
1766
|
+
return this.canvas(i.ctx, i.fn);
|
|
1767
|
+
if (i.text) {
|
|
1768
|
+
var h = typeof i.text.render == "function" ? i.text.render() : i.text;
|
|
1769
|
+
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, h);
|
|
1770
|
+
}
|
|
1771
|
+
} }], o && xn(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1772
|
+
}(), wn = Object.prototype.hasOwnProperty, Zt = {};
|
|
1773
|
+
function bn(e) {
|
|
1774
|
+
return Zt[e] || (Zt[e] = e.replace(/([a-z])([A-Z])/g, function(n, o, i) {
|
|
1775
|
+
return o + "-" + i.toLowerCase();
|
|
1776
|
+
})), Zt[e];
|
|
1777
|
+
}
|
|
1778
|
+
function we(e, n) {
|
|
1779
|
+
if (Array.isArray(n))
|
|
1780
|
+
return n.forEach(function(o) {
|
|
1781
|
+
return we(e, o);
|
|
1782
|
+
});
|
|
1783
|
+
typeof n == "string" && (n = document.createTextNode(n)), e.appendChild(n);
|
|
1784
|
+
}
|
|
1785
|
+
function be(e, n) {
|
|
1786
|
+
if (typeof document < "u") {
|
|
1787
|
+
var o = typeof e == "string" ? document.createElementNS("http://www.w3.org/2000/svg", e) : e;
|
|
1788
|
+
if (n && o.setAttribute)
|
|
1789
|
+
for (var i in n)
|
|
1790
|
+
wn.call(n, i) && n[i] != null && o.setAttribute(i === "className" ? "class" : bn(i), n[i]);
|
|
1791
|
+
for (var h = arguments.length, p = new Array(h > 2 ? h - 2 : 0), w = 2; w < h; w++)
|
|
1792
|
+
p[w - 2] = arguments[w];
|
|
1793
|
+
return p != null && p.length && p.forEach(function(x) {
|
|
1794
|
+
we(o, x);
|
|
1795
|
+
}), o;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
it.createElement = be, it.textparser = Pt, it.defaultparser = Pt, it.htmlparser = function(e) {
|
|
1799
|
+
e = String(e || "").trim();
|
|
1800
|
+
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, h = [], p = [], w = function(O) {
|
|
1801
|
+
for (var k in i)
|
|
1802
|
+
i[k] && (O[k] = i[k]);
|
|
1803
|
+
h.push(O);
|
|
1804
|
+
}, x = function(O) {
|
|
1805
|
+
var k = h.length, M = Qe[O];
|
|
1806
|
+
if (k && M) {
|
|
1807
|
+
for (var R = k - 1; h[R] && (h[R] instanceof St || Ge.test(h[R].value)); )
|
|
1808
|
+
R--;
|
|
1809
|
+
for (; M && h[R] && h[R] instanceof tt; )
|
|
1810
|
+
R--, M--;
|
|
1811
|
+
for (; M-- > 0; )
|
|
1812
|
+
h.push(new tt());
|
|
1813
|
+
}
|
|
1814
|
+
}; e.length; ) {
|
|
1815
|
+
if (n = /^[^<]+/.exec(e))
|
|
1816
|
+
Pt(fe(n[0]), !1).forEach(w);
|
|
1817
|
+
else if (!(n = Ke.exec(e)))
|
|
1818
|
+
if (n = We.exec(e))
|
|
1819
|
+
p.length && (i = p.pop()), x(n[1]);
|
|
1820
|
+
else if (n = Ze.exec(e)) {
|
|
1821
|
+
var b = n[1];
|
|
1822
|
+
x(b), p.push(i), i = Object.create(i), de[b] && de[b](i, "");
|
|
1823
|
+
var S = nn(n[2]);
|
|
1824
|
+
b === "a" && (S.href && (i.href = S.href), S.rel && (i.rel = S.rel), S.target && (i.target = S.target)), S.class && (i.class = i.class ? i.class + " " + S.class : S.class), S.style && (o = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(S.style)) && o[1] && (i.color = o[1]), b === "br" && h.push(new tt());
|
|
1825
|
+
} else
|
|
1826
|
+
n = [e.slice(0, 1)], w(new H(n[0]));
|
|
1827
|
+
e = e.slice(n[0].length);
|
|
1828
|
+
}
|
|
1829
|
+
for (var D = h[h.length - 1]; D instanceof tt; )
|
|
1830
|
+
h.pop(), D = h[h.length - 1];
|
|
1831
|
+
return h;
|
|
1832
|
+
}, it.latexparser = function(e) {
|
|
1833
|
+
e = String(e || "").trim();
|
|
1834
|
+
var n = [0];
|
|
1835
|
+
e = e.replace(/\\verb,(.*?),/, function(C, L) {
|
|
1836
|
+
return n.push(L), "\\verb," + (n.length - 1) + ",";
|
|
1837
|
+
}).replace(/\\\\\n/g, function() {
|
|
1838
|
+
return "\\\\";
|
|
1839
|
+
}).replace(ln, function(C, L, j) {
|
|
1840
|
+
return j.charAt(L - 1) === "\\" ? C : hn[C];
|
|
1841
|
+
}).replace(/\n\s+/g, function(C) {
|
|
1842
|
+
return /\n/.test(C.slice(1)) ? "\\par " : C;
|
|
1843
|
+
}).replace(/\\symbol\{(\d+)\}/, function(C, L, j, $) {
|
|
1844
|
+
return $.charAt(j - 1) === "\\" ? C : String.fromCharCode(1 * L);
|
|
1845
|
+
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(C, L, j, $) {
|
|
1846
|
+
return L + j + "{" + $ + "}";
|
|
1847
|
+
}).replace(/\\verb,(.*?),/, function(C, L) {
|
|
1848
|
+
return "\\verb,".concat(n[+L], ",");
|
|
1849
|
+
});
|
|
1850
|
+
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, h = [], p = [], w = function(C) {
|
|
1851
|
+
for (var L in i)
|
|
1852
|
+
i[L] && (C[L] = i[L]);
|
|
1853
|
+
return h.push(C), C;
|
|
1854
|
+
}, x = function() {
|
|
1855
|
+
p.push(i), i = Object.create(i);
|
|
1856
|
+
}, b = function() {
|
|
1857
|
+
if (!p.length)
|
|
1858
|
+
throw new Error("Unexpected }");
|
|
1859
|
+
i = p.pop();
|
|
1860
|
+
}, S = { tokens: h, open_context: x, close_context: b, add_token: w }; e.length; ) {
|
|
1861
|
+
if (o = on.exec(e))
|
|
1862
|
+
Pt(o[0], !1).forEach(w);
|
|
1863
|
+
else if (o = an.exec(e))
|
|
1864
|
+
w(new H(o[1]));
|
|
1865
|
+
else if (!(o = sn.exec(e))) {
|
|
1866
|
+
if (o = /^\{/.exec(e))
|
|
1867
|
+
x();
|
|
1868
|
+
else if (o = /^\}/.exec(e))
|
|
1869
|
+
b();
|
|
1870
|
+
else if (!(o = /^\$/.exec(e)))
|
|
1871
|
+
if (o = /^\\verb,([^,]+),/.exec(e))
|
|
1872
|
+
w(new H(o[1]));
|
|
1873
|
+
else if (o = rn.exec(e)) {
|
|
1874
|
+
var D = o[1].slice(1) || o[1], O = !!o[2];
|
|
1875
|
+
if (/^(La)?TeX$/i.test(D)) {
|
|
1876
|
+
x(), i.family = "serif";
|
|
1877
|
+
var k = void 0;
|
|
1878
|
+
D === "LaTeX" && ((k = w(new H("L"))).tracking = -0.25, (k = w(new H("A"))).size = 0.7, k.baseline = 0.3, k.tracking = -0.1), (k = w(new H("T"))).tracking = -0.17, (k = w(new H("E"))).baseline = -0.22, k.tracking = -0.13, k = w(new H("X")), b();
|
|
1879
|
+
} else if (D in pe)
|
|
1880
|
+
w(new H(pe[D])), O && x();
|
|
1881
|
+
else if (D in V) {
|
|
1882
|
+
var M = [], R = V[D].length - 1, K = void 0;
|
|
1883
|
+
if (R) {
|
|
1884
|
+
for (O = !1, e = e.slice(o[0].length - 1); R--; ) {
|
|
1885
|
+
if (!(K = /^\{([^}]+)\}/.exec(e)))
|
|
1886
|
+
throw new Error(D + " is missing an argument");
|
|
1887
|
+
M.push(K[1]), e = e.slice(K[0].length);
|
|
1888
|
+
}
|
|
1889
|
+
o[0] = /^\{/.exec(e) ? "{" : "", O = !!o[0];
|
|
1890
|
+
}
|
|
1891
|
+
O && x(), V[D].apply(S, [i].concat(M));
|
|
1892
|
+
} else
|
|
1893
|
+
console.warn("unknown latex command", D), w(new H(o[1])), O && x();
|
|
1894
|
+
} else
|
|
1895
|
+
o = [e.slice(0, 1)], w(new H(o[0]));
|
|
1896
|
+
}
|
|
1897
|
+
e = e.slice(o[0].length);
|
|
1898
|
+
}
|
|
1899
|
+
return h;
|
|
1900
|
+
}, it.measureText = function(e, n, o) {
|
|
1901
|
+
return W(e, E(n), o);
|
|
1902
|
+
}, it.Token = H, it.Break = St, it.LineBreak = tt, it.SoftHyphen = ft, it.Rotator = xe, xe.createElement = be;
|
|
1903
|
+
const Sn = it;
|
|
1904
|
+
return s.default;
|
|
1905
|
+
})());
|
|
1906
|
+
})(Be);
|
|
1907
|
+
var jn = Be.exports;
|
|
1908
|
+
const Oe = /* @__PURE__ */ oe(jn);
|
|
1909
|
+
function Fn(u, l) {
|
|
1910
|
+
const t = dt(u), { fontSize: s, font: a, padding: c = 0 } = u.properties.style || {};
|
|
1911
|
+
if (t.width === t.height && t.width === 0)
|
|
1912
|
+
return;
|
|
1913
|
+
const f = new Oe({
|
|
1914
|
+
font: `${s}px/${s}px ${a}`.replace(/(px)+/g, "px"),
|
|
1915
|
+
width: t.width - c * 2,
|
|
1916
|
+
height: t.height - c * 2,
|
|
1917
|
+
align: "left",
|
|
1918
|
+
valign: "top",
|
|
1919
|
+
x: 0,
|
|
1920
|
+
overflow: "ellipsis",
|
|
1921
|
+
parser: "html",
|
|
1922
|
+
createElement: Oe.createElement
|
|
1923
|
+
}).linebreak(
|
|
1924
|
+
u.properties.content.replaceAll(`
|
|
1925
|
+
`, "<br>")
|
|
1926
|
+
).render();
|
|
1927
|
+
f.setAttribute("transform", `translate(${c}, ${c})`), l.appendChild(f);
|
|
1928
|
+
}
|
|
1929
|
+
const Me = 20;
|
|
1930
|
+
class qn extends qe {
|
|
1931
|
+
constructor(t, s = {}) {
|
|
1932
|
+
super(
|
|
1933
|
+
t,
|
|
1934
|
+
`
|
|
1935
|
+
<div class="annotation-text-handle">
|
|
1936
|
+
<span class="handle line-handle top" data-handle-id="0"></span>
|
|
1937
|
+
<span class="handle line-handle bottom" data-handle-id="1"></span>
|
|
1938
|
+
<span class="handle line-handle left" data-handle-id="2"></span>
|
|
1939
|
+
<span class="handle line-handle right" data-handle-id="3"></span>
|
|
1940
|
+
<span class="handle top right point-handle top-right" data-handle-id="4"></span>
|
|
1941
|
+
<span class="handle left top point-handle top-left" data-handle-id="5"></span>
|
|
1942
|
+
<span class="handle bottom right point-handle bottom-right" data-handle-id="6"></span>
|
|
1943
|
+
<span class="handle left bottom left-handle point-handle bottom-left" data-handle-id="7"></span>
|
|
1944
|
+
<textarea wrap="off"></textarea>
|
|
1945
|
+
</div>
|
|
1946
|
+
`
|
|
1947
|
+
);
|
|
1948
|
+
m(this, "textArea");
|
|
1949
|
+
m(this, "handleSize");
|
|
1950
|
+
m(this, "rect", { x: 0, y: 0, width: 0, height: 0 });
|
|
1951
|
+
m(this, "annotation", { ...te });
|
|
1952
|
+
m(this, "startX", 0);
|
|
1953
|
+
m(this, "startY", 0);
|
|
1954
|
+
m(this, "handles", []);
|
|
1955
|
+
m(this, "draggedHandle", B);
|
|
1956
|
+
m(this, "isFocused", !1);
|
|
1957
|
+
m(this, "placeholder", "Type your text here...");
|
|
1958
|
+
m(this, "_onFocus", () => {
|
|
1959
|
+
this.textArea.value === this.placeholder && (this.textArea.value = ""), this.isFocused = !0;
|
|
1960
|
+
});
|
|
1961
|
+
m(this, "_onBlur", () => {
|
|
1962
|
+
this.isFocused = !1;
|
|
1963
|
+
});
|
|
1964
|
+
m(this, "startDrawing", (t, s, a = Rn(t, s, 0, 0, "", bt)) => {
|
|
1965
|
+
this.add(a);
|
|
1966
|
+
const c = this.ogma.view.graphToScreenCoordinates({ x: t, y: s });
|
|
1967
|
+
this.select(a.id), this.startDragging(this.getById(a.id), c.x, c.y), this.draggedHandle = 6;
|
|
1968
|
+
});
|
|
1969
|
+
m(this, "cancelDrawing", () => {
|
|
1970
|
+
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...te }, this.draggedHandle = B, this.isDragging = !1, this.emit(Ot, this.annotation));
|
|
1971
|
+
});
|
|
1972
|
+
m(this, "startDragging", (t, s, a) => {
|
|
1973
|
+
this.annotation = t;
|
|
1974
|
+
const c = yt(this.annotation), g = dt(this.annotation);
|
|
1975
|
+
this.rect.x = c.x, this.rect.y = c.y, this.rect.width = g.width, this.rect.height = g.height, this.startX = s, this.startY = a, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(le, this.annotation), this.isDragging = !0;
|
|
1976
|
+
});
|
|
1977
|
+
m(this, "onHandleMouseDown", (t) => {
|
|
1978
|
+
const s = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
1979
|
+
s && (this.selectedId !== s.id && this.select(this.hoveredId), this.startDragging(s, t.clientX, t.clientY), this.draggedHandle = He(t.target));
|
|
1980
|
+
});
|
|
1981
|
+
m(this, "onMouseMove", (t) => {
|
|
1982
|
+
requestAnimationFrame(() => this._onMouseMove(t));
|
|
1983
|
+
});
|
|
1984
|
+
m(this, "_onMouseMove", (t) => {
|
|
1985
|
+
if (!this.isDragging)
|
|
1986
|
+
return;
|
|
1987
|
+
t.stopPropagation(), t.preventDefault();
|
|
1988
|
+
const s = this.handles[this.draggedHandle], a = s.classList.contains("top"), c = s.classList.contains("left"), g = s.classList.contains("right"), y = s.classList.contains("bottom"), f = s.classList.contains("line-handle"), r = this.ogma.view.getZoom(), d = (t.clientX - this.startX) / r, v = (t.clientY - this.startY) / r, T = c || f ? this.rect.x + d : this.rect.x, _ = a || f ? this.rect.y + v : this.rect.y, E = Math.max(
|
|
1989
|
+
this.rect.width + d * (f ? 0 : c ? -1 : g ? 1 : 0),
|
|
1990
|
+
Me
|
|
1991
|
+
), P = Math.max(
|
|
1992
|
+
this.rect.height + v * (f ? 0 : a ? -1 : y ? 1 : 0),
|
|
1993
|
+
Me
|
|
1994
|
+
);
|
|
1995
|
+
Mn(this.annotation, T, _, E, P), this.emit(ae, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
|
|
1996
|
+
});
|
|
1997
|
+
m(this, "onMouseUp", () => {
|
|
1998
|
+
!this.isDragging || this.draggedHandle === B || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(Ot, this.annotation), this.isDragging = !1, this.draggedHandle = B);
|
|
1999
|
+
});
|
|
2000
|
+
m(this, "onViewChanged", () => {
|
|
2001
|
+
const t = Math.max(2, this.handleSize / this.ogma.view.getZoom());
|
|
2002
|
+
document.documentElement.style.setProperty("--handle-width", `${t}px`);
|
|
2003
|
+
});
|
|
2004
|
+
m(this, "_onInput", () => {
|
|
2005
|
+
const t = this.getById(this.selectedId);
|
|
2006
|
+
t && (this.textArea.value = this.textArea.value.replace(/ +(?= )/g, ""), this.textArea.focus(), t.properties.content = this.textArea.value, this.emit(se, t), this.layer.refresh());
|
|
2007
|
+
});
|
|
2008
|
+
this.handleSize = De.handleSize || s.textHandleSize, this.placeholder = De.placeholder || s.textPlaceholder || "";
|
|
2009
|
+
const a = this.textArea = this.editor.element.querySelector("textarea");
|
|
2010
|
+
a.addEventListener("input", this._onInput), a.addEventListener("focus", this._onFocus), a.addEventListener("blur", this._onBlur), a.spellcheck = !1, this.handles = Array.prototype.slice.call(
|
|
2011
|
+
this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
|
|
2012
|
+
), this.handles.forEach(
|
|
2013
|
+
(c) => c.addEventListener("mousedown", this.onHandleMouseDown)
|
|
2014
|
+
), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), t.events.on(["viewChanged", "zoom"], this.onViewChanged);
|
|
2015
|
+
}
|
|
2016
|
+
_canRemove() {
|
|
2017
|
+
return !this.isFocused;
|
|
2018
|
+
}
|
|
2019
|
+
detect({ x: t, y: s }, a = 0) {
|
|
2020
|
+
return this.elements.find((c) => {
|
|
2021
|
+
const { x: g, y } = yt(c), { width: f, height: r } = dt(c);
|
|
2022
|
+
return g - a < t && y - a < s && g + f + a > t && y + r + a > s;
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
draw(t) {
|
|
2026
|
+
t.innerHTML = "";
|
|
2027
|
+
const s = "";
|
|
2028
|
+
this.elements.forEach((c, g) => {
|
|
2029
|
+
const y = `class${g}`, f = dt(c), r = yt(c), d = c.id, {
|
|
2030
|
+
color: v,
|
|
2031
|
+
fontSize: T,
|
|
2032
|
+
font: _,
|
|
2033
|
+
strokeColor: E,
|
|
2034
|
+
strokeWidth: P,
|
|
2035
|
+
strokeType: A,
|
|
2036
|
+
background: U
|
|
2037
|
+
} = c.properties.style || bt;
|
|
2038
|
+
if (d === this.selectedId || this.selectedId === -1 && d === this.hoveredId)
|
|
2039
|
+
return;
|
|
2040
|
+
const N = It("g");
|
|
2041
|
+
N.setAttribute("fill", `${v}`), N.setAttribute("font-size", `${T}`), N.setAttribute("font-family", `${_}`);
|
|
2042
|
+
const z = It("rect");
|
|
2043
|
+
let W = !1;
|
|
2044
|
+
A && A !== "none" && (W = !0, z.setAttribute("stroke", E || "black"), z.setAttribute("stroke-width", `${P}`), A === "dashed" && z.setAttribute("stroke-dasharray", "5,5")), (U && U.length || W) && (W = !0, z.setAttribute("fill", U || "transparent")), W && (z.setAttribute("width", `${f.width}`), z.setAttribute("height", `${f.height}`)), N.appendChild(z), Fn(c, N), N.setAttribute("transform", `translate(${r.x},${r.y})`), N.classList.add(y), N.setAttribute("data-annotation", `${c.id}`), N.setAttribute("data-annotation-type", "text"), t.appendChild(N);
|
|
2045
|
+
});
|
|
2046
|
+
const a = It("style");
|
|
2047
|
+
a.innerHTML = s, t.firstChild && t.insertBefore(a, t.firstChild);
|
|
2048
|
+
}
|
|
2049
|
+
getDefaultOptions() {
|
|
2050
|
+
return te;
|
|
2051
|
+
}
|
|
2052
|
+
refreshEditor() {
|
|
2053
|
+
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
2054
|
+
return;
|
|
2055
|
+
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), s = dt(t), a = yt(t), {
|
|
2056
|
+
font: c,
|
|
2057
|
+
fontSize: g,
|
|
2058
|
+
color: y,
|
|
2059
|
+
background: f,
|
|
2060
|
+
padding: r = 0
|
|
2061
|
+
} = t.properties.style || bt;
|
|
2062
|
+
this.textArea.value = t.properties.content, this.editor.setPosition({ x: a.x, y: a.y }), this.editor.setSize(s), this.textArea.style.fontFamily = c || "sans-serif", this.textArea.style.fontSize = `${g}px`, this.textArea.style.padding = `${r}px`, this.textArea.style.lineHeight = `${g}px`, this.textArea.style.boxSizing = "border-box", this.textArea.style.color = y || "black", this.textArea.style.background = f || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
2063
|
+
}
|
|
2064
|
+
select(t) {
|
|
2065
|
+
super.select(t), this.textArea.focus();
|
|
2066
|
+
}
|
|
2067
|
+
destroy() {
|
|
2068
|
+
super.destroy(), document.removeEventListener("mouseup", this.onMouseUp), document.removeEventListener("mousemove", this.onMouseMove, !0), this.ogma.events.off(this.onViewChanged);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
class Bn {
|
|
2072
|
+
constructor() {
|
|
2073
|
+
m(this, "links", {});
|
|
2074
|
+
m(this, "linksByTargetId", {});
|
|
2075
|
+
m(this, "linksByArrowId", {});
|
|
2076
|
+
}
|
|
2077
|
+
add(l, t, s, a, c) {
|
|
2078
|
+
const g = jt(), y = l.id, f = {
|
|
2079
|
+
id: g,
|
|
2080
|
+
arrow: y,
|
|
2081
|
+
target: s,
|
|
2082
|
+
targetType: a,
|
|
2083
|
+
connectionPoint: c,
|
|
2084
|
+
side: t
|
|
2085
|
+
};
|
|
2086
|
+
return this.links[g] = f, this.linksByTargetId[s] || (this.linksByTargetId[s] = []), this.linksByTargetId[s].push(g), this.linksByArrowId[y] || (this.linksByArrowId[y] = {}), this.linksByArrowId[y][t] = g, l.properties.link = l.properties.link || {}, l.properties.link[t] = {
|
|
2087
|
+
id: s,
|
|
2088
|
+
side: t,
|
|
2089
|
+
type: a,
|
|
2090
|
+
magnet: c
|
|
2091
|
+
}, this;
|
|
2092
|
+
}
|
|
2093
|
+
arrowIsLinked(l, t) {
|
|
2094
|
+
var s;
|
|
2095
|
+
return !!((s = this.linksByArrowId[l]) != null && s[t]);
|
|
2096
|
+
}
|
|
2097
|
+
// remove the link between the arrow and the target by arrow id and side
|
|
2098
|
+
remove(l, t) {
|
|
2099
|
+
var y, f;
|
|
2100
|
+
const s = l.id, a = (y = this.linksByArrowId[s]) == null ? void 0 : y[t];
|
|
2101
|
+
if ((f = l.properties.link) == null || delete f[t], !a)
|
|
2102
|
+
return this;
|
|
2103
|
+
const c = this.links[a];
|
|
2104
|
+
delete this.links[a];
|
|
2105
|
+
const g = this.linksByTargetId[c.target];
|
|
2106
|
+
for (let r = 0; r < g.length; r++)
|
|
2107
|
+
if (g[r] === a) {
|
|
2108
|
+
g.splice(r, 1);
|
|
2109
|
+
break;
|
|
2110
|
+
}
|
|
2111
|
+
return delete this.linksByArrowId[s][t], this;
|
|
2112
|
+
}
|
|
2113
|
+
getArrowLink(l, t) {
|
|
2114
|
+
var a;
|
|
2115
|
+
const s = (a = this.linksByArrowId[l]) == null ? void 0 : a[t];
|
|
2116
|
+
return s ? this.links[s] : null;
|
|
2117
|
+
}
|
|
2118
|
+
getTargetLinks(l) {
|
|
2119
|
+
var t;
|
|
2120
|
+
return ((t = this.linksByTargetId[l]) == null ? void 0 : t.map((s) => this.links[s])) ?? [];
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
const ct = (u) => u.properties.type === "arrow", wt = (u) => u.properties.type === "text", Vn = (u) => u.type === "FeatureCollection", Un = {
|
|
2124
|
+
magnetColor: "#3e8",
|
|
2125
|
+
detectMargin: 20,
|
|
2126
|
+
magnetHandleRadius: 5,
|
|
2127
|
+
magnetRadius: 10,
|
|
2128
|
+
textPlaceholder: "Type here",
|
|
2129
|
+
arrowHandleSize: 3.5,
|
|
2130
|
+
textHandleSize: 3.5,
|
|
2131
|
+
minArrowHeight: 20,
|
|
2132
|
+
maxArrowHeight: 30
|
|
2133
|
+
}, ze = ["start", "end"], Le = [
|
|
2134
|
+
{ x: 0, y: 0 },
|
|
2135
|
+
{ x: 0.5, y: 0 },
|
|
2136
|
+
{ x: 1, y: 0 },
|
|
2137
|
+
{ x: 0, y: 0.5 },
|
|
2138
|
+
{ x: 1, y: 0.5 },
|
|
2139
|
+
{ x: 0, y: 1 },
|
|
2140
|
+
{ x: 0.5, y: 1 },
|
|
2141
|
+
{ x: 1, y: 1 }
|
|
2142
|
+
];
|
|
2143
|
+
class Gn extends Fe {
|
|
2144
|
+
constructor(t, s = {}) {
|
|
2145
|
+
super();
|
|
2146
|
+
m(this, "arrows");
|
|
2147
|
+
m(this, "texts");
|
|
2148
|
+
m(this, "links", new Bn());
|
|
2149
|
+
m(this, "layer");
|
|
2150
|
+
m(this, "annotations");
|
|
2151
|
+
m(this, "ogma");
|
|
2152
|
+
m(this, "options");
|
|
2153
|
+
m(this, "selected", null);
|
|
2154
|
+
m(this, "updateTimeout", 0);
|
|
2155
|
+
m(this, "hoveredNode", null);
|
|
2156
|
+
m(this, "dragged", null);
|
|
2157
|
+
m(this, "textToMagnet");
|
|
2158
|
+
m(this, "activeLinks", []);
|
|
2159
|
+
m(this, "_render", (t) => {
|
|
2160
|
+
if (!this.dragged || this.textToMagnet === void 0)
|
|
2161
|
+
return;
|
|
2162
|
+
t.beginPath(), t.fillStyle = "green";
|
|
2163
|
+
const s = this.ogma.view.getZoom();
|
|
2164
|
+
Le.forEach((a) => {
|
|
2165
|
+
if (!this.textToMagnet)
|
|
2166
|
+
return;
|
|
2167
|
+
const c = dt(this.textToMagnet), g = yt(this.textToMagnet), { x: y, y: f } = new rt(a.x, a.y).mul({ x: c.width, y: c.height }).add(g);
|
|
2168
|
+
t.moveTo(y, f), t.arc(y, f, this.options.magnetHandleRadius / s, 0, Math.PI * 2);
|
|
2169
|
+
}), t.fill(), t.closePath();
|
|
2170
|
+
});
|
|
2171
|
+
m(this, "_onFeatureDrag", (t, s) => {
|
|
2172
|
+
const a = s;
|
|
2173
|
+
if (ct(t) && a === "line")
|
|
2174
|
+
["start", "end"].find((c) => {
|
|
2175
|
+
const g = c === "start" ? _t(t) : Ht(t);
|
|
2176
|
+
return this._snapToText(t, a, g) || this._findAndSnapToNode(t, c, g);
|
|
2177
|
+
});
|
|
2178
|
+
else if (ct(t) && a !== "line") {
|
|
2179
|
+
const c = a === "start" ? _t(t) : Ht(t);
|
|
2180
|
+
this._snapToText(t, a, c) || this._findAndSnapToNode(t, a, c);
|
|
2181
|
+
} else
|
|
2182
|
+
wt(t) && (this.activeLinks.forEach(({ arrow: c, side: g, connectionPoint: y }) => {
|
|
2183
|
+
const f = this.getAnnotation(c), r = dt(t), d = yt(t), v = new rt(y.x, y.y).mul({ x: r.width, y: r.height }).add(d);
|
|
2184
|
+
f.geometry.coordinates[g === "start" ? 0 : 1] = [v.x, v.y];
|
|
2185
|
+
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
2186
|
+
this.layer.refresh();
|
|
2187
|
+
});
|
|
2188
|
+
m(this, "_onFeatureDragEnd", (t) => {
|
|
2189
|
+
this.dragged !== null && ct(t) && _t(this.dragged) && ze.forEach((s) => {
|
|
2190
|
+
this.links.getArrowLink(t.id, s) && this.emit(Nn, {
|
|
2191
|
+
arrow: t,
|
|
2192
|
+
link: this.links.getArrowLink(t.id, s)
|
|
2193
|
+
});
|
|
2194
|
+
}), (wt(t) || ct(t)) && this.onUpdate(t), this.dragged = null, this.activeLinks = [], this.textToMagnet = void 0, this.annotations.forEach((s) => s.enableDetection()), this.layer.refresh();
|
|
2195
|
+
});
|
|
2196
|
+
m(this, "_onFeatureDragStart", (t) => {
|
|
2197
|
+
this.textToMagnet = void 0, ct(t) ? this.dragged = t : wt(t) && this.activeLinks.push(...this.links.getTargetLinks(t.id)), this.annotations.forEach((s) => {
|
|
2198
|
+
const a = s.getSelectedFeature();
|
|
2199
|
+
a && a !== t && s.unhover().unselect(), s.disableDetection();
|
|
2200
|
+
});
|
|
2201
|
+
});
|
|
2202
|
+
m(this, "_onNodesDragStart", () => {
|
|
2203
|
+
this.arrows.unhover().unselect(), this.texts.unhover().unselect();
|
|
2204
|
+
});
|
|
2205
|
+
m(this, "_onNodesDrag", (t) => {
|
|
2206
|
+
const { dx: s, dy: a } = t;
|
|
2207
|
+
this._moveNodes(t.nodes, s, a);
|
|
2208
|
+
});
|
|
2209
|
+
m(this, "_onAdded", (t) => {
|
|
2210
|
+
this.emit(re, t);
|
|
2211
|
+
});
|
|
2212
|
+
m(this, "_onRemoved", (t) => {
|
|
2213
|
+
this.emit(ie, t);
|
|
2214
|
+
});
|
|
2215
|
+
m(this, "_onUnselect", (t) => {
|
|
2216
|
+
this.selected = null, this.emit(ne, t);
|
|
2217
|
+
});
|
|
2218
|
+
m(this, "_onSelect", (t) => {
|
|
2219
|
+
this.selected !== t && (this.selected = t, this.emit(ee, this.selected));
|
|
2220
|
+
});
|
|
2221
|
+
/**
|
|
2222
|
+
* Triggers the update event on the annotation
|
|
2223
|
+
* @param annotation The annotation updated
|
|
2224
|
+
*/
|
|
2225
|
+
m(this, "onUpdate", (t) => {
|
|
2226
|
+
cancelAnimationFrame(this.updateTimeout), this.updateTimeout = requestAnimationFrame(
|
|
2227
|
+
() => this._onUpdate(t)
|
|
2228
|
+
);
|
|
2229
|
+
});
|
|
2230
|
+
m(this, "_onUpdate", (t) => {
|
|
2231
|
+
this.emit(se, t);
|
|
2232
|
+
});
|
|
2233
|
+
this.options = this.setOptions({ ...Un, ...s }), this.ogma = t, this.arrows = new Hn(t, this.options), this.texts = new qn(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((a) => {
|
|
2234
|
+
a.on(le, this._onFeatureDragStart).on(ae, this._onFeatureDrag).on(Ot, this._onFeatureDragEnd).on(se, this.onUpdate).on(ne, this._onUnselect).on(ee, this._onSelect).on(re, this._onAdded).on(ie, this._onRemoved);
|
|
2235
|
+
}), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
2236
|
+
}
|
|
2237
|
+
_moveNodes(t, s, a) {
|
|
2238
|
+
t.forEach((c) => {
|
|
2239
|
+
const g = this.links.getTargetLinks(c.getId()), y = c.getPosition();
|
|
2240
|
+
g.forEach((f) => {
|
|
2241
|
+
const r = this.getAnnotation(f.arrow), d = f.side, v = Ae(
|
|
2242
|
+
r,
|
|
2243
|
+
d === "start" ? "end" : "start"
|
|
2244
|
+
);
|
|
2245
|
+
let T = y;
|
|
2246
|
+
const _ = +c.getAttribute("radius"), E = 1e-6;
|
|
2247
|
+
(f.connectionPoint.x - (y.x - s) > E || f.connectionPoint.y - (y.y - a) > E) && (T = Ee(v, y, _)), Qt(r, d, T.x, T.y);
|
|
2248
|
+
});
|
|
2249
|
+
}), this.arrows.refreshLayer();
|
|
2250
|
+
}
|
|
2251
|
+
_snapToText(t, s, a) {
|
|
2252
|
+
const c = this.texts.detect(a, this.options.detectMargin);
|
|
2253
|
+
if (this.links.remove(t, s), !c)
|
|
2254
|
+
return !1;
|
|
2255
|
+
this.textToMagnet = c;
|
|
2256
|
+
const g = this.findMagnetPoint(Le, c, a);
|
|
2257
|
+
return g ? (Qt(t, s, g.point.x, g.point.y), this.links.add(t, s, c.id, "text", g.magnet), !0) : !1;
|
|
2258
|
+
}
|
|
2259
|
+
_findAndSnapToNode(t, s, a) {
|
|
2260
|
+
const c = this.ogma.view.graphToScreenCoordinates(a), g = this.ogma.view.getElementAt(c);
|
|
2261
|
+
this.links.remove(t, s), g && g.isNode ? (this.hoveredNode = g, this.hoveredNode.setSelected(!0), this._snapToNode(t, s, g, c)) : (this.hoveredNode && this.hoveredNode.setSelected(!1), this.hoveredNode = null);
|
|
2262
|
+
}
|
|
2263
|
+
_snapToNode(t, s, a, c) {
|
|
2264
|
+
const g = a.getPositionOnScreen(), y = +a.getAttribute("radius"), f = y * this.ogma.view.getZoom(), r = c.x - g.x, d = c.y - g.y, v = Math.sqrt(r * r + d * d), T = a.getPosition();
|
|
2265
|
+
if (v < f + this.options.detectMargin) {
|
|
2266
|
+
let _ = T;
|
|
2267
|
+
if (v > f / 2) {
|
|
2268
|
+
const E = Ae(t, s === "end" ? "start" : "end");
|
|
2269
|
+
_ = Ee(E, _, y);
|
|
2270
|
+
}
|
|
2271
|
+
Qt(t, s, _.x, _.y), this.links.add(t, s, a.getId(), "node", _);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
/**
|
|
2275
|
+
* @returns the currently selected annotation
|
|
2276
|
+
*/
|
|
2277
|
+
getSelected() {
|
|
2278
|
+
return this.selected;
|
|
2279
|
+
}
|
|
2280
|
+
findMagnetPoint(t, s, a) {
|
|
2281
|
+
let c;
|
|
2282
|
+
for (const g of t) {
|
|
2283
|
+
const y = dt(s), f = yt(s), r = new rt(g.x, g.y).mul({ x: y.width, y: y.height }).add(f), d = r.sub(a).length(), v = this.options.magnetRadius * this.ogma.view.getZoom();
|
|
2284
|
+
if (d < Math.max(v, this.options.magnetHandleRadius)) {
|
|
2285
|
+
c = {
|
|
2286
|
+
point: r,
|
|
2287
|
+
magnet: g
|
|
2288
|
+
};
|
|
2289
|
+
break;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
return c;
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Set the options for the controller
|
|
2296
|
+
* @param options new Options
|
|
2297
|
+
* @returns the updated options
|
|
2298
|
+
*/
|
|
2299
|
+
setOptions(t = {}) {
|
|
2300
|
+
return this.options = {
|
|
2301
|
+
...this.options || {},
|
|
2302
|
+
...t
|
|
2303
|
+
}, this.options;
|
|
2304
|
+
}
|
|
2305
|
+
/**
|
|
2306
|
+
* Selects the annotation with the given id
|
|
2307
|
+
* @param id the id of the annotation to select
|
|
2308
|
+
*/
|
|
2309
|
+
select(t) {
|
|
2310
|
+
const s = this.getAnnotations().features.find((a) => a.id === t);
|
|
2311
|
+
return s ? (ct(s) ? this.arrows.select(s.id) : wt(s) && this.texts.select(s.id), this) : this;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Unselects the currently selected annotation
|
|
2315
|
+
*/
|
|
2316
|
+
unselect() {
|
|
2317
|
+
return this.selected ? (ct(this.selected) ? this.arrows.unselect() : wt(this.selected) && this.texts.unselect(), this) : this;
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Add an annotation to the controller
|
|
2321
|
+
* @param annotation The annotation to add
|
|
2322
|
+
*/
|
|
2323
|
+
add(t) {
|
|
2324
|
+
if (Vn(t))
|
|
2325
|
+
return t.features.forEach(
|
|
2326
|
+
(s) => this.add(s)
|
|
2327
|
+
), this;
|
|
2328
|
+
switch (t.properties.type) {
|
|
2329
|
+
case "text":
|
|
2330
|
+
this.texts.add(t);
|
|
2331
|
+
break;
|
|
2332
|
+
default:
|
|
2333
|
+
this.arrows.add(t), this.loadLink(t);
|
|
2334
|
+
break;
|
|
2335
|
+
}
|
|
2336
|
+
return this;
|
|
2337
|
+
}
|
|
2338
|
+
loadLink(t) {
|
|
2339
|
+
if (t.properties.link)
|
|
2340
|
+
for (const s of ze) {
|
|
2341
|
+
const a = t.properties.link[s];
|
|
2342
|
+
if (!a)
|
|
2343
|
+
continue;
|
|
2344
|
+
if (this.getAnnotation(a.id))
|
|
2345
|
+
this.links.add(t, s, a.id, a.type, a.magnet);
|
|
2346
|
+
else {
|
|
2347
|
+
if (!this.ogma.getNode(a.id))
|
|
2348
|
+
continue;
|
|
2349
|
+
this.links.add(t, s, a.id, a.type, a.magnet);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Start adding an arrow (add it, and give control to the user)
|
|
2355
|
+
* @param x coord of the first point
|
|
2356
|
+
* @param y coord of the first point
|
|
2357
|
+
* @param arrow The arrow to add
|
|
2358
|
+
*/
|
|
2359
|
+
startArrow(t, s, a) {
|
|
2360
|
+
this.cancelDrawing(), this.arrows.startDrawing(t, s, a);
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Start adding a text (add it, and give control to the user)
|
|
2364
|
+
* @param x coord of the top left point
|
|
2365
|
+
* @param y coord of the top left point
|
|
2366
|
+
* @param text The text to add
|
|
2367
|
+
*/
|
|
2368
|
+
startText(t, s, a) {
|
|
2369
|
+
this.cancelDrawing(), this.texts.startDrawing(t, s, a);
|
|
2370
|
+
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Cancel drawing on the current frame
|
|
2373
|
+
*/
|
|
2374
|
+
cancelDrawing() {
|
|
2375
|
+
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(Cn);
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Update the style of the annotation with the given id
|
|
2379
|
+
* @param id The id of the annotation to update
|
|
2380
|
+
* @param style The new style
|
|
2381
|
+
*/
|
|
2382
|
+
updateStyle(t, s) {
|
|
2383
|
+
const a = this.getAnnotations().features.find((c) => c.id === t);
|
|
2384
|
+
return a ? (ct(a) ? this.arrows.updateStyle(a, s) : wt(a) && this.texts.updateStyle(a, s), this.onUpdate(a), this) : this;
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
*
|
|
2388
|
+
* @returns the annotations in the controller
|
|
2389
|
+
*/
|
|
2390
|
+
getAnnotations() {
|
|
2391
|
+
const t = {
|
|
2392
|
+
type: "FeatureCollection",
|
|
2393
|
+
features: []
|
|
2394
|
+
};
|
|
2395
|
+
return this.annotations.forEach((s) => {
|
|
2396
|
+
t.features = [...t.features, ...s.getElements()];
|
|
2397
|
+
}), t;
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Retrieve the annotation with the given id
|
|
2401
|
+
* @param id the id of the annotation to get
|
|
2402
|
+
* @returns The annotation with the given id
|
|
2403
|
+
*/
|
|
2404
|
+
getAnnotation(t) {
|
|
2405
|
+
return this.getAnnotations().features.find((s) => s.id === t);
|
|
2406
|
+
}
|
|
2407
|
+
/**
|
|
2408
|
+
* Destroy the controller and its elements
|
|
2409
|
+
*/
|
|
2410
|
+
destroy() {
|
|
2411
|
+
this.annotations.forEach((t) => t.destroy()), this.layer.destroy();
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
export {
|
|
2415
|
+
Hn as Arrows,
|
|
2416
|
+
Gn as Control,
|
|
2417
|
+
qn as Texts,
|
|
2418
|
+
_n as createArrow,
|
|
2419
|
+
It as createSVGElement,
|
|
2420
|
+
Rn as createText,
|
|
2421
|
+
Se as defaultArrowOptions,
|
|
2422
|
+
Dt as defaultArrowStyle,
|
|
2423
|
+
De as defaultControllerOptions,
|
|
2424
|
+
te as defaultTextOptions,
|
|
2425
|
+
bt as defaultTextStyle,
|
|
2426
|
+
Xn as getAnnotationsBounds,
|
|
2427
|
+
Ht as getArrowEnd,
|
|
2428
|
+
Rt as getArrowEndPoints,
|
|
2429
|
+
Ae as getArrowSide,
|
|
2430
|
+
_t as getArrowStart,
|
|
2431
|
+
Ee as getAttachmentPointOnNode,
|
|
2432
|
+
He as getHandleId,
|
|
2433
|
+
Ce as getTextBbox,
|
|
2434
|
+
yt as getTextPosition,
|
|
2435
|
+
dt as getTextSize,
|
|
2436
|
+
Vn as isAnnotationCollection,
|
|
2437
|
+
ct as isArrow,
|
|
2438
|
+
wt as isText,
|
|
2439
|
+
$e as setArrowEnd,
|
|
2440
|
+
Qt as setArrowEndPoint,
|
|
2441
|
+
Ne as setArrowStart,
|
|
2442
|
+
Mn as setTextBbox,
|
|
2443
|
+
On as updateTextBbox
|
|
2444
|
+
};
|
|
2445
|
+
//# sourceMappingURL=index.mjs.map
|