@formulaxjs/tiptap 0.3.0 → 0.4.0

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.
Files changed (46) hide show
  1. package/README.md +212 -207
  2. package/README.zh-CN.md +71 -66
  3. package/dist/base.css +47 -0
  4. package/dist/canvg-runtime-UR3JNX5Q.js +2759 -0
  5. package/dist/canvg-runtime-UR3JNX5Q.js.map +1 -0
  6. package/dist/chunk-OCSSWPUX.js +3407 -0
  7. package/dist/chunk-OCSSWPUX.js.map +1 -0
  8. package/dist/images/scrollbar/custom/bar-bg.png +0 -0
  9. package/dist/images/scrollbar/custom/bar.png +0 -0
  10. package/dist/images/scrollbar/custom/bg.png +0 -0
  11. package/dist/images/scrollbar/custom/bottom.png +0 -0
  12. package/dist/images/scrollbar/custom/btn.png +0 -0
  13. package/dist/images/scrollbar/custom/down.png +0 -0
  14. package/dist/images/scrollbar/custom/top.png +0 -0
  15. package/dist/images/scrollbar/custom/up.png +0 -0
  16. package/dist/images/scrollbar/edit/bar-bg.png +0 -0
  17. package/dist/images/scrollbar/edit/bar-left.png +0 -0
  18. package/dist/images/scrollbar/edit/bar-right.png +0 -0
  19. package/dist/images/scrollbar/edit/thumb-bg.png +0 -0
  20. package/dist/images/scrollbar/edit/thumb-left.png +0 -0
  21. package/dist/images/scrollbar/edit/thumb-right.png +0 -0
  22. package/dist/images/toolbar/btn.png +0 -0
  23. package/dist/index.cjs +24075 -65
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.global.js +2385 -2241
  26. package/dist/index.global.js.map +1 -1
  27. package/dist/index.js +3768 -21
  28. package/dist/index.js.map +1 -1
  29. package/dist/install-XGCSWTLU.js +5464 -0
  30. package/dist/install-XGCSWTLU.js.map +1 -0
  31. package/dist/install-XVTKACEN.js +1349 -0
  32. package/dist/install-XVTKACEN.js.map +1 -0
  33. package/dist/other.png +0 -0
  34. package/dist/scrollbar.css +78 -0
  35. package/dist/start-MBLTNR2Q.js +4926 -0
  36. package/dist/start-MBLTNR2Q.js.map +1 -0
  37. package/dist/ui.css +625 -0
  38. package/package.json +9 -4
  39. /package/dist/{KF_AMS_BB-5QF7FUSO.woff → KF_AMS_BB.woff} +0 -0
  40. /package/dist/{KF_AMS_CAL-NXRNLAZN.woff → KF_AMS_CAL.woff} +0 -0
  41. /package/dist/{KF_AMS_FRAK-CO33WWN4.woff → KF_AMS_FRAK.woff} +0 -0
  42. /package/dist/{KF_AMS_MAIN-25QJVAWY.woff → KF_AMS_MAIN.woff} +0 -0
  43. /package/dist/{KF_AMS_ROMAN-243BR7HH.woff → KF_AMS_ROMAN.woff} +0 -0
  44. /package/dist/{btn-5DANP6JY.png → btn.png} +0 -0
  45. /package/dist/{editor-JT5KLVXX.css → editor.css} +0 -0
  46. /package/dist/{other-OMWJFGL5.png → images/toolbar/other.png} +0 -0
package/dist/index.js CHANGED
@@ -1,5 +1,3745 @@
1
+ import {
2
+ DEFAULT_FORMULAX_LOCALE,
3
+ createLegacyBaseComponent,
4
+ getFormulaXRuntimeMessage,
5
+ kityAssetManifest,
6
+ legacyBaseUtils,
7
+ legacyBoxType,
8
+ legacyEleType,
9
+ legacyEventListener,
10
+ legacyGroupType,
11
+ legacyInputFilter,
12
+ legacyItemType,
13
+ legacyKfEvent,
14
+ legacyKfExtDef,
15
+ legacyOtherPosition,
16
+ legacySysconf,
17
+ legacyUiDef,
18
+ legacyUiUtils,
19
+ normalizeFormulaXLocale,
20
+ setToolbarAssetUrls,
21
+ utils_default
22
+ } from "./chunk-OCSSWPUX.js";
23
+
1
24
  // src/index.ts
2
25
  import { Node } from "@tiptap/core";
26
+
27
+ // ../kity-runtime/src/vendor/char-position.ts
28
+ var legacyCharPosition = {
29
+ "\\pm": {
30
+ "x": 5,
31
+ "y": 0
32
+ },
33
+ "\\infty": {
34
+ "x": 42,
35
+ "y": 0
36
+ },
37
+ "=": {
38
+ "x": 79,
39
+ "y": 0
40
+ },
41
+ "\\sim": {
42
+ "x": 116,
43
+ "y": 0
44
+ },
45
+ "\\times": {
46
+ "x": 153,
47
+ "y": 0
48
+ },
49
+ "\\div": {
50
+ "x": 190,
51
+ "y": 0
52
+ },
53
+ "!": {
54
+ "x": 227,
55
+ "y": 0
56
+ },
57
+ "<": {
58
+ "x": 264,
59
+ "y": 0
60
+ },
61
+ "\\ll": {
62
+ "x": 301,
63
+ "y": 0
64
+ },
65
+ ">": {
66
+ "x": 338,
67
+ "y": 0
68
+ },
69
+ "\\gg": {
70
+ "x": 375,
71
+ "y": 0
72
+ },
73
+ "\\leq": {
74
+ "x": 412,
75
+ "y": 0
76
+ },
77
+ "\\geq": {
78
+ "x": 449,
79
+ "y": 0
80
+ },
81
+ "\\mp": {
82
+ "x": 486,
83
+ "y": 0
84
+ },
85
+ "\\cong": {
86
+ "x": 523,
87
+ "y": 0
88
+ },
89
+ "\\equiv": {
90
+ "x": 560,
91
+ "y": 0
92
+ },
93
+ "\\propto": {
94
+ "x": 597,
95
+ "y": 0
96
+ },
97
+ "\\approx": {
98
+ "x": 634,
99
+ "y": 0
100
+ },
101
+ "\\forall": {
102
+ "x": 671,
103
+ "y": 0
104
+ },
105
+ "\\partial": {
106
+ "x": 708,
107
+ "y": 0
108
+ },
109
+ "\\surd": {
110
+ "x": 745,
111
+ "y": 0
112
+ },
113
+ "\\cup": {
114
+ "x": 782,
115
+ "y": 0
116
+ },
117
+ "\\cap": {
118
+ "x": 819,
119
+ "y": 0
120
+ },
121
+ "\\varnothing": {
122
+ "x": 856,
123
+ "y": 0
124
+ },
125
+ "%": {
126
+ "x": 893,
127
+ "y": 0
128
+ },
129
+ "\\circ": {
130
+ "x": 930,
131
+ "y": 0
132
+ },
133
+ "\\exists": {
134
+ "x": 967,
135
+ "y": 0
136
+ },
137
+ "\\nexists": {
138
+ "x": 1004,
139
+ "y": 0
140
+ },
141
+ "\\in": {
142
+ "x": 1041,
143
+ "y": 0
144
+ },
145
+ "\\ni": {
146
+ "x": 1078,
147
+ "y": 0
148
+ },
149
+ "\\gets": {
150
+ "x": 5,
151
+ "y": 37
152
+ },
153
+ "\\uparrow": {
154
+ "x": 42,
155
+ "y": 37
156
+ },
157
+ "\\to": {
158
+ "x": 79,
159
+ "y": 37
160
+ },
161
+ "\\downarrow": {
162
+ "x": 116,
163
+ "y": 37
164
+ },
165
+ "\\leftrightarrow": {
166
+ "x": 153,
167
+ "y": 37
168
+ },
169
+ "\\therefore": {
170
+ "x": 190,
171
+ "y": 37
172
+ },
173
+ "\\because": {
174
+ "x": 227,
175
+ "y": 37
176
+ },
177
+ "+": {
178
+ "x": 264,
179
+ "y": 37
180
+ },
181
+ "-": {
182
+ "x": 301,
183
+ "y": 37
184
+ },
185
+ "\\neg": {
186
+ "x": 338,
187
+ "y": 37
188
+ },
189
+ "\\ast": {
190
+ "x": 375,
191
+ "y": 37
192
+ },
193
+ "\\cdot": {
194
+ "x": 412,
195
+ "y": 37
196
+ },
197
+ "\\vdots": {
198
+ "x": 449,
199
+ "y": 37
200
+ },
201
+ "\\ddots": {
202
+ "x": 486,
203
+ "y": 37
204
+ },
205
+ "\\aleph": {
206
+ "x": 523,
207
+ "y": 37
208
+ },
209
+ "\\beth": {
210
+ "x": 560,
211
+ "y": 37
212
+ },
213
+ "\\blacksquare": {
214
+ "x": 597,
215
+ "y": 37
216
+ },
217
+ "\\alpha": {
218
+ "x": 634,
219
+ "y": 37
220
+ },
221
+ "\\beta": {
222
+ "x": 671,
223
+ "y": 37
224
+ },
225
+ "\\gamma": {
226
+ "x": 708,
227
+ "y": 37
228
+ },
229
+ "\\delta": {
230
+ "x": 745,
231
+ "y": 37
232
+ },
233
+ "\\epsilon": {
234
+ "x": 782,
235
+ "y": 37
236
+ },
237
+ "\\zeta": {
238
+ "x": 819,
239
+ "y": 37
240
+ },
241
+ "\\eta": {
242
+ "x": 856,
243
+ "y": 37
244
+ },
245
+ "\\theta": {
246
+ "x": 893,
247
+ "y": 37
248
+ },
249
+ "\\iota": {
250
+ "x": 930,
251
+ "y": 37
252
+ },
253
+ "\\kappa": {
254
+ "x": 967,
255
+ "y": 37
256
+ },
257
+ "\\lambda": {
258
+ "x": 1004,
259
+ "y": 37
260
+ },
261
+ "\\mu": {
262
+ "x": 1041,
263
+ "y": 37
264
+ },
265
+ "\\nu": {
266
+ "x": 1078,
267
+ "y": 37
268
+ },
269
+ "\\xi": {
270
+ "x": 5,
271
+ "y": 74
272
+ },
273
+ "\\omicron": {
274
+ "x": 42,
275
+ "y": 74
276
+ },
277
+ "\\pi": {
278
+ "x": 79,
279
+ "y": 74
280
+ },
281
+ "\\rho": {
282
+ "x": 116,
283
+ "y": 74
284
+ },
285
+ "\\sigma": {
286
+ "x": 153,
287
+ "y": 74
288
+ },
289
+ "\\tau": {
290
+ "x": 190,
291
+ "y": 74
292
+ },
293
+ "\\upsilon": {
294
+ "x": 227,
295
+ "y": 74
296
+ },
297
+ "\\phi": {
298
+ "x": 264,
299
+ "y": 74
300
+ },
301
+ "\\chi": {
302
+ "x": 301,
303
+ "y": 74
304
+ },
305
+ "\\psi": {
306
+ "x": 338,
307
+ "y": 74
308
+ },
309
+ "\\omega": {
310
+ "x": 375,
311
+ "y": 74
312
+ },
313
+ "\\Alpha": {
314
+ "x": 412,
315
+ "y": 74
316
+ },
317
+ "\\Beta": {
318
+ "x": 449,
319
+ "y": 74
320
+ },
321
+ "\\Gamma": {
322
+ "x": 486,
323
+ "y": 74
324
+ },
325
+ "\\Delta": {
326
+ "x": 523,
327
+ "y": 74
328
+ },
329
+ "\\Epsilon": {
330
+ "x": 560,
331
+ "y": 74
332
+ },
333
+ "\\Zeta": {
334
+ "x": 597,
335
+ "y": 74
336
+ },
337
+ "\\Eta": {
338
+ "x": 634,
339
+ "y": 74
340
+ },
341
+ "\\Theta": {
342
+ "x": 671,
343
+ "y": 74
344
+ },
345
+ "\\Iota": {
346
+ "x": 708,
347
+ "y": 74
348
+ },
349
+ "\\Kappa": {
350
+ "x": 745,
351
+ "y": 74
352
+ },
353
+ "\\Lambda": {
354
+ "x": 782,
355
+ "y": 74
356
+ },
357
+ "\\Mu": {
358
+ "x": 819,
359
+ "y": 74
360
+ },
361
+ "\\Nu": {
362
+ "x": 856,
363
+ "y": 74
364
+ },
365
+ "\\Xi": {
366
+ "x": 893,
367
+ "y": 74
368
+ },
369
+ "\\Omicron": {
370
+ "x": 930,
371
+ "y": 74
372
+ },
373
+ "\\Pi": {
374
+ "x": 967,
375
+ "y": 74
376
+ },
377
+ "\\Rho": {
378
+ "x": 1004,
379
+ "y": 74
380
+ },
381
+ "\\Sigma": {
382
+ "x": 1041,
383
+ "y": 74
384
+ },
385
+ "\\Tau": {
386
+ "x": 1078,
387
+ "y": 74
388
+ },
389
+ "\\Upsilon": {
390
+ "x": 5,
391
+ "y": 111
392
+ },
393
+ "\\Phi": {
394
+ "x": 42,
395
+ "y": 111
396
+ },
397
+ "\\Chi": {
398
+ "x": 79,
399
+ "y": 111
400
+ },
401
+ "\\Psi": {
402
+ "x": 116,
403
+ "y": 111
404
+ },
405
+ "\\Omega": {
406
+ "x": 153,
407
+ "y": 111
408
+ },
409
+ "\\digamma": {
410
+ "x": 190,
411
+ "y": 111
412
+ },
413
+ "\\varepsilon": {
414
+ "x": 227,
415
+ "y": 111
416
+ },
417
+ "\\varkappa": {
418
+ "x": 264,
419
+ "y": 111
420
+ },
421
+ "\\varphi": {
422
+ "x": 301,
423
+ "y": 111
424
+ },
425
+ "\\varpi": {
426
+ "x": 338,
427
+ "y": 111
428
+ },
429
+ "\\varrho": {
430
+ "x": 375,
431
+ "y": 111
432
+ },
433
+ "\\varsigma": {
434
+ "x": 412,
435
+ "y": 111
436
+ },
437
+ "\\vartheta": {
438
+ "x": 449,
439
+ "y": 111
440
+ },
441
+ "\\neq": {
442
+ "x": 486,
443
+ "y": 111
444
+ },
445
+ "\\nless": {
446
+ "x": 523,
447
+ "y": 111
448
+ },
449
+ "\\ngtr": {
450
+ "x": 560,
451
+ "y": 111
452
+ },
453
+ "\\nleq": {
454
+ "x": 597,
455
+ "y": 111
456
+ },
457
+ "\\ngeq": {
458
+ "x": 634,
459
+ "y": 111
460
+ },
461
+ "\\nsim": {
462
+ "x": 671,
463
+ "y": 111
464
+ },
465
+ "\\lneqq": {
466
+ "x": 708,
467
+ "y": 111
468
+ },
469
+ "\\gneqq": {
470
+ "x": 745,
471
+ "y": 111
472
+ },
473
+ "\\nprec": {
474
+ "x": 782,
475
+ "y": 111
476
+ },
477
+ "\\nsucc": {
478
+ "x": 819,
479
+ "y": 111
480
+ },
481
+ "\\notin": {
482
+ "x": 856,
483
+ "y": 111
484
+ },
485
+ "\\nsubseteq": {
486
+ "x": 893,
487
+ "y": 111
488
+ },
489
+ "\\nsupseteq": {
490
+ "x": 930,
491
+ "y": 111
492
+ },
493
+ "\\subsetneq": {
494
+ "x": 967,
495
+ "y": 111
496
+ },
497
+ "\\supsetneq": {
498
+ "x": 1004,
499
+ "y": 111
500
+ },
501
+ "\\lnsim": {
502
+ "x": 1041,
503
+ "y": 111
504
+ },
505
+ "\\gnsim": {
506
+ "x": 1078,
507
+ "y": 111
508
+ },
509
+ "\\precnsim": {
510
+ "x": 5,
511
+ "y": 148
512
+ },
513
+ "\\succnsim": {
514
+ "x": 42,
515
+ "y": 148
516
+ },
517
+ "\\ntriangleleft": {
518
+ "x": 79,
519
+ "y": 148
520
+ },
521
+ "\\ntriangleright": {
522
+ "x": 116,
523
+ "y": 148
524
+ },
525
+ "\\ntrianglelefteq": {
526
+ "x": 153,
527
+ "y": 148
528
+ },
529
+ "\\ntrianglerighteq": {
530
+ "x": 190,
531
+ "y": 148
532
+ },
533
+ "\\nmid": {
534
+ "x": 227,
535
+ "y": 148
536
+ },
537
+ "\\nparallel": {
538
+ "x": 264,
539
+ "y": 148
540
+ },
541
+ "\\nvdash": {
542
+ "x": 301,
543
+ "y": 148
544
+ },
545
+ "\\nVdash": {
546
+ "x": 338,
547
+ "y": 148
548
+ },
549
+ "\\nvDash": {
550
+ "x": 375,
551
+ "y": 148
552
+ },
553
+ "\\nVDash": {
554
+ "x": 412,
555
+ "y": 148
556
+ },
557
+ "\\daleth": {
558
+ "x": 449,
559
+ "y": 148
560
+ },
561
+ "\\gimel": {
562
+ "x": 486,
563
+ "y": 148
564
+ },
565
+ "\\complement": {
566
+ "x": 523,
567
+ "y": 148
568
+ },
569
+ "\\ell": {
570
+ "x": 560,
571
+ "y": 148
572
+ },
573
+ "\\eth": {
574
+ "x": 597,
575
+ "y": 148
576
+ },
577
+ "\\hbar": {
578
+ "x": 634,
579
+ "y": 148
580
+ },
581
+ "\\hslash": {
582
+ "x": 671,
583
+ "y": 148
584
+ },
585
+ "\\mho": {
586
+ "x": 708,
587
+ "y": 148
588
+ },
589
+ "\\wp": {
590
+ "x": 745,
591
+ "y": 148
592
+ },
593
+ "\\circledS": {
594
+ "x": 782,
595
+ "y": 148
596
+ },
597
+ "\\Bbbk": {
598
+ "x": 819,
599
+ "y": 148
600
+ },
601
+ "\\Finv": {
602
+ "x": 856,
603
+ "y": 148
604
+ },
605
+ "\\Game": {
606
+ "x": 893,
607
+ "y": 148
608
+ },
609
+ "\\Im": {
610
+ "x": 930,
611
+ "y": 148
612
+ },
613
+ "\\Re": {
614
+ "x": 967,
615
+ "y": 148
616
+ },
617
+ "\\updownarrow": {
618
+ "x": 1004,
619
+ "y": 148
620
+ },
621
+ "\\Leftarrow": {
622
+ "x": 1041,
623
+ "y": 148
624
+ },
625
+ "\\Rightarrow": {
626
+ "x": 1078,
627
+ "y": 148
628
+ },
629
+ "\\Uparrow": {
630
+ "x": 5,
631
+ "y": 185
632
+ },
633
+ "\\Downarrow": {
634
+ "x": 42,
635
+ "y": 185
636
+ },
637
+ "\\Leftrightarrow": {
638
+ "x": 79,
639
+ "y": 185
640
+ },
641
+ "\\Updownarrow": {
642
+ "x": 116,
643
+ "y": 185
644
+ },
645
+ "\\longleftarrow": {
646
+ "x": 153,
647
+ "y": 185
648
+ },
649
+ "\\longrightarrow": {
650
+ "x": 190,
651
+ "y": 185
652
+ },
653
+ "\\longleftrightarrow": {
654
+ "x": 227,
655
+ "y": 185
656
+ },
657
+ "\\Longleftarrow": {
658
+ "x": 264,
659
+ "y": 185
660
+ },
661
+ "\\Longrightarrow": {
662
+ "x": 301,
663
+ "y": 185
664
+ },
665
+ "\\Longleftrightarrow": {
666
+ "x": 338,
667
+ "y": 185
668
+ },
669
+ "\\nearrow": {
670
+ "x": 375,
671
+ "y": 185
672
+ },
673
+ "\\nwarrow": {
674
+ "x": 412,
675
+ "y": 185
676
+ },
677
+ "\\searrow": {
678
+ "x": 449,
679
+ "y": 185
680
+ },
681
+ "\\swarrow": {
682
+ "x": 486,
683
+ "y": 185
684
+ },
685
+ "\\nleftarrow": {
686
+ "x": 523,
687
+ "y": 185
688
+ },
689
+ "\\nrightarrow": {
690
+ "x": 560,
691
+ "y": 185
692
+ },
693
+ "\\nLeftarrow": {
694
+ "x": 597,
695
+ "y": 185
696
+ },
697
+ "\\nRightarrow": {
698
+ "x": 634,
699
+ "y": 185
700
+ },
701
+ "\\nLeftrightarrow": {
702
+ "x": 671,
703
+ "y": 185
704
+ },
705
+ "\\leftharpoonup": {
706
+ "x": 708,
707
+ "y": 185
708
+ },
709
+ "\\leftharpoondown": {
710
+ "x": 745,
711
+ "y": 185
712
+ },
713
+ "\\rightharpoonup": {
714
+ "x": 782,
715
+ "y": 185
716
+ },
717
+ "\\rightharpoondown": {
718
+ "x": 819,
719
+ "y": 185
720
+ },
721
+ "\\upharpoonleft": {
722
+ "x": 856,
723
+ "y": 185
724
+ },
725
+ "\\upharpoonright": {
726
+ "x": 893,
727
+ "y": 185
728
+ },
729
+ "\\downharpoonleft": {
730
+ "x": 930,
731
+ "y": 185
732
+ },
733
+ "\\downharpoonright": {
734
+ "x": 967,
735
+ "y": 185
736
+ },
737
+ "\\leftrightharpoons": {
738
+ "x": 1004,
739
+ "y": 185
740
+ },
741
+ "\\rightleftharpoons": {
742
+ "x": 1041,
743
+ "y": 185
744
+ },
745
+ "\\leftleftarrows": {
746
+ "x": 1078,
747
+ "y": 185
748
+ },
749
+ "\\rightrightarrows": {
750
+ "x": 5,
751
+ "y": 222
752
+ },
753
+ "\\upuparrows": {
754
+ "x": 42,
755
+ "y": 222
756
+ },
757
+ "\\downdownarrows": {
758
+ "x": 79,
759
+ "y": 222
760
+ },
761
+ "\\leftrightarrows": {
762
+ "x": 116,
763
+ "y": 222
764
+ },
765
+ "\\rightleftarrows": {
766
+ "x": 153,
767
+ "y": 222
768
+ },
769
+ "\\looparrowleft": {
770
+ "x": 190,
771
+ "y": 222
772
+ },
773
+ "\\looparrowright": {
774
+ "x": 227,
775
+ "y": 222
776
+ },
777
+ "\\leftarrowtail": {
778
+ "x": 264,
779
+ "y": 222
780
+ },
781
+ "\\rightarrowtail": {
782
+ "x": 301,
783
+ "y": 222
784
+ },
785
+ "\\Lsh": {
786
+ "x": 338,
787
+ "y": 222
788
+ },
789
+ "\\Rsh": {
790
+ "x": 375,
791
+ "y": 222
792
+ },
793
+ "\\Lleftarrow": {
794
+ "x": 412,
795
+ "y": 222
796
+ },
797
+ "\\Rrightarrow": {
798
+ "x": 449,
799
+ "y": 222
800
+ },
801
+ "\\curvearrowleft": {
802
+ "x": 486,
803
+ "y": 222
804
+ },
805
+ "\\curvearrowright": {
806
+ "x": 523,
807
+ "y": 222
808
+ },
809
+ "\\circlearrowleft": {
810
+ "x": 560,
811
+ "y": 222
812
+ },
813
+ "\\circlearrowright": {
814
+ "x": 597,
815
+ "y": 222
816
+ },
817
+ "\\multimap": {
818
+ "x": 634,
819
+ "y": 222
820
+ },
821
+ "\\leftrightsquigarrow": {
822
+ "x": 671,
823
+ "y": 222
824
+ },
825
+ "\\twoheadleftarrow": {
826
+ "x": 708,
827
+ "y": 222
828
+ },
829
+ "\\twoheadrightarrow": {
830
+ "x": 745,
831
+ "y": 222
832
+ },
833
+ "\\rightsquigarrow": {
834
+ "x": 782,
835
+ "y": 222
836
+ },
837
+ "\\mathcal{A}": {
838
+ "x": 819,
839
+ "y": 222
840
+ },
841
+ "\\mathcal{B}": {
842
+ "x": 856,
843
+ "y": 222
844
+ },
845
+ "\\mathcal{C}": {
846
+ "x": 893,
847
+ "y": 222
848
+ },
849
+ "\\mathcal{D}": {
850
+ "x": 930,
851
+ "y": 222
852
+ },
853
+ "\\mathcal{E}": {
854
+ "x": 967,
855
+ "y": 222
856
+ },
857
+ "\\mathcal{F}": {
858
+ "x": 1004,
859
+ "y": 222
860
+ },
861
+ "\\mathcal{G}": {
862
+ "x": 1041,
863
+ "y": 222
864
+ },
865
+ "\\mathcal{H}": {
866
+ "x": 1078,
867
+ "y": 222
868
+ },
869
+ "\\mathcal{I}": {
870
+ "x": 5,
871
+ "y": 259
872
+ },
873
+ "\\mathcal{J}": {
874
+ "x": 42,
875
+ "y": 259
876
+ },
877
+ "\\mathcal{K}": {
878
+ "x": 79,
879
+ "y": 259
880
+ },
881
+ "\\mathcal{L}": {
882
+ "x": 116,
883
+ "y": 259
884
+ },
885
+ "\\mathcal{M}": {
886
+ "x": 153,
887
+ "y": 259
888
+ },
889
+ "\\mathcal{N}": {
890
+ "x": 190,
891
+ "y": 259
892
+ },
893
+ "\\mathcal{O}": {
894
+ "x": 227,
895
+ "y": 259
896
+ },
897
+ "\\mathcal{P}": {
898
+ "x": 264,
899
+ "y": 259
900
+ },
901
+ "\\mathcal{Q}": {
902
+ "x": 301,
903
+ "y": 259
904
+ },
905
+ "\\mathcal{R}": {
906
+ "x": 338,
907
+ "y": 259
908
+ },
909
+ "\\mathcal{S}": {
910
+ "x": 375,
911
+ "y": 259
912
+ },
913
+ "\\mathcal{T}": {
914
+ "x": 412,
915
+ "y": 259
916
+ },
917
+ "\\mathcal{U}": {
918
+ "x": 449,
919
+ "y": 259
920
+ },
921
+ "\\mathcal{V}": {
922
+ "x": 486,
923
+ "y": 259
924
+ },
925
+ "\\mathcal{W}": {
926
+ "x": 523,
927
+ "y": 259
928
+ },
929
+ "\\mathcal{X}": {
930
+ "x": 560,
931
+ "y": 259
932
+ },
933
+ "\\mathcal{Y}": {
934
+ "x": 597,
935
+ "y": 259
936
+ },
937
+ "\\mathcal{Z}": {
938
+ "x": 634,
939
+ "y": 259
940
+ },
941
+ "\\mathfrak{A}": {
942
+ "x": 671,
943
+ "y": 259
944
+ },
945
+ "\\mathfrak{B}": {
946
+ "x": 708,
947
+ "y": 259
948
+ },
949
+ "\\mathfrak{C}": {
950
+ "x": 745,
951
+ "y": 259
952
+ },
953
+ "\\mathfrak{D}": {
954
+ "x": 782,
955
+ "y": 259
956
+ },
957
+ "\\mathfrak{E}": {
958
+ "x": 819,
959
+ "y": 259
960
+ },
961
+ "\\mathfrak{F}": {
962
+ "x": 856,
963
+ "y": 259
964
+ },
965
+ "\\mathfrak{G}": {
966
+ "x": 893,
967
+ "y": 259
968
+ },
969
+ "\\mathfrak{H}": {
970
+ "x": 930,
971
+ "y": 259
972
+ },
973
+ "\\mathfrak{I}": {
974
+ "x": 967,
975
+ "y": 259
976
+ },
977
+ "\\mathfrak{J}": {
978
+ "x": 1004,
979
+ "y": 259
980
+ },
981
+ "\\mathfrak{K}": {
982
+ "x": 1041,
983
+ "y": 259
984
+ },
985
+ "\\mathfrak{L}": {
986
+ "x": 1078,
987
+ "y": 259
988
+ },
989
+ "\\mathfrak{M}": {
990
+ "x": 5,
991
+ "y": 296
992
+ },
993
+ "\\mathfrak{N}": {
994
+ "x": 42,
995
+ "y": 296
996
+ },
997
+ "\\mathfrak{O}": {
998
+ "x": 79,
999
+ "y": 296
1000
+ },
1001
+ "\\mathfrak{P}": {
1002
+ "x": 116,
1003
+ "y": 296
1004
+ },
1005
+ "\\mathfrak{Q}": {
1006
+ "x": 153,
1007
+ "y": 296
1008
+ },
1009
+ "\\mathfrak{R}": {
1010
+ "x": 190,
1011
+ "y": 296
1012
+ },
1013
+ "\\mathfrak{S}": {
1014
+ "x": 227,
1015
+ "y": 296
1016
+ },
1017
+ "\\mathfrak{T}": {
1018
+ "x": 264,
1019
+ "y": 296
1020
+ },
1021
+ "\\mathfrak{U}": {
1022
+ "x": 301,
1023
+ "y": 296
1024
+ },
1025
+ "\\mathfrak{V}": {
1026
+ "x": 338,
1027
+ "y": 296
1028
+ },
1029
+ "\\mathfrak{W}": {
1030
+ "x": 375,
1031
+ "y": 296
1032
+ },
1033
+ "\\mathfrak{X}": {
1034
+ "x": 412,
1035
+ "y": 296
1036
+ },
1037
+ "\\mathfrak{Y}": {
1038
+ "x": 449,
1039
+ "y": 296
1040
+ },
1041
+ "\\mathfrak{Z}": {
1042
+ "x": 486,
1043
+ "y": 296
1044
+ },
1045
+ "\\mathfrak{a}": {
1046
+ "x": 523,
1047
+ "y": 296
1048
+ },
1049
+ "\\mathfrak{b}": {
1050
+ "x": 560,
1051
+ "y": 296
1052
+ },
1053
+ "\\mathfrak{c}": {
1054
+ "x": 597,
1055
+ "y": 296
1056
+ },
1057
+ "\\mathfrak{d}": {
1058
+ "x": 634,
1059
+ "y": 296
1060
+ },
1061
+ "\\mathfrak{e}": {
1062
+ "x": 671,
1063
+ "y": 296
1064
+ },
1065
+ "\\mathfrak{f}": {
1066
+ "x": 708,
1067
+ "y": 296
1068
+ },
1069
+ "\\mathfrak{g}": {
1070
+ "x": 745,
1071
+ "y": 296
1072
+ },
1073
+ "\\mathfrak{h}": {
1074
+ "x": 782,
1075
+ "y": 296
1076
+ },
1077
+ "\\mathfrak{i}": {
1078
+ "x": 819,
1079
+ "y": 296
1080
+ },
1081
+ "\\mathfrak{j}": {
1082
+ "x": 856,
1083
+ "y": 296
1084
+ },
1085
+ "\\mathfrak{k}": {
1086
+ "x": 893,
1087
+ "y": 296
1088
+ },
1089
+ "\\mathfrak{l}": {
1090
+ "x": 930,
1091
+ "y": 296
1092
+ },
1093
+ "\\mathfrak{m}": {
1094
+ "x": 967,
1095
+ "y": 296
1096
+ },
1097
+ "\\mathfrak{n}": {
1098
+ "x": 1004,
1099
+ "y": 296
1100
+ },
1101
+ "\\mathfrak{o}": {
1102
+ "x": 1041,
1103
+ "y": 296
1104
+ },
1105
+ "\\mathfrak{p}": {
1106
+ "x": 1078,
1107
+ "y": 296
1108
+ },
1109
+ "\\mathfrak{q}": {
1110
+ "x": 5,
1111
+ "y": 333
1112
+ },
1113
+ "\\mathfrak{r}": {
1114
+ "x": 42,
1115
+ "y": 333
1116
+ },
1117
+ "\\mathfrak{s}": {
1118
+ "x": 79,
1119
+ "y": 333
1120
+ },
1121
+ "\\mathfrak{t}": {
1122
+ "x": 116,
1123
+ "y": 333
1124
+ },
1125
+ "\\mathfrak{u}": {
1126
+ "x": 153,
1127
+ "y": 333
1128
+ },
1129
+ "\\mathfrak{v}": {
1130
+ "x": 190,
1131
+ "y": 333
1132
+ },
1133
+ "\\mathfrak{w}": {
1134
+ "x": 227,
1135
+ "y": 333
1136
+ },
1137
+ "\\mathfrak{x}": {
1138
+ "x": 264,
1139
+ "y": 333
1140
+ },
1141
+ "\\mathfrak{y}": {
1142
+ "x": 301,
1143
+ "y": 333
1144
+ },
1145
+ "\\mathfrak{z}": {
1146
+ "x": 338,
1147
+ "y": 333
1148
+ },
1149
+ "\\mathbb{A}": {
1150
+ "x": 375,
1151
+ "y": 333
1152
+ },
1153
+ "\\mathbb{B}": {
1154
+ "x": 412,
1155
+ "y": 333
1156
+ },
1157
+ "\\mathbb{C}": {
1158
+ "x": 449,
1159
+ "y": 333
1160
+ },
1161
+ "\\mathbb{D}": {
1162
+ "x": 486,
1163
+ "y": 333
1164
+ },
1165
+ "\\mathbb{E}": {
1166
+ "x": 523,
1167
+ "y": 333
1168
+ },
1169
+ "\\mathbb{F}": {
1170
+ "x": 560,
1171
+ "y": 333
1172
+ },
1173
+ "\\mathbb{G}": {
1174
+ "x": 597,
1175
+ "y": 333
1176
+ },
1177
+ "\\mathbb{H}": {
1178
+ "x": 634,
1179
+ "y": 333
1180
+ },
1181
+ "\\mathbb{I}": {
1182
+ "x": 671,
1183
+ "y": 333
1184
+ },
1185
+ "\\mathbb{J}": {
1186
+ "x": 708,
1187
+ "y": 333
1188
+ },
1189
+ "\\mathbb{K}": {
1190
+ "x": 745,
1191
+ "y": 333
1192
+ },
1193
+ "\\mathbb{L}": {
1194
+ "x": 782,
1195
+ "y": 333
1196
+ },
1197
+ "\\mathbb{M}": {
1198
+ "x": 819,
1199
+ "y": 333
1200
+ },
1201
+ "\\mathbb{N}": {
1202
+ "x": 856,
1203
+ "y": 333
1204
+ },
1205
+ "\\mathbb{O}": {
1206
+ "x": 893,
1207
+ "y": 333
1208
+ },
1209
+ "\\mathbb{P}": {
1210
+ "x": 930,
1211
+ "y": 333
1212
+ },
1213
+ "\\mathbb{Q}": {
1214
+ "x": 967,
1215
+ "y": 333
1216
+ },
1217
+ "\\mathbb{R}": {
1218
+ "x": 1004,
1219
+ "y": 333
1220
+ },
1221
+ "\\mathbb{S}": {
1222
+ "x": 1041,
1223
+ "y": 333
1224
+ },
1225
+ "\\mathbb{T}": {
1226
+ "x": 1078,
1227
+ "y": 333
1228
+ },
1229
+ "\\mathbb{U}": {
1230
+ "x": 5,
1231
+ "y": 370
1232
+ },
1233
+ "\\mathbb{V}": {
1234
+ "x": 42,
1235
+ "y": 370
1236
+ },
1237
+ "\\mathbb{W}": {
1238
+ "x": 79,
1239
+ "y": 370
1240
+ },
1241
+ "\\mathbb{X}": {
1242
+ "x": 116,
1243
+ "y": 370
1244
+ },
1245
+ "\\mathbb{Y}": {
1246
+ "x": 153,
1247
+ "y": 370
1248
+ },
1249
+ "\\mathbb{Z}": {
1250
+ "x": 190,
1251
+ "y": 370
1252
+ },
1253
+ "\\mathrm{A}": {
1254
+ "x": 227,
1255
+ "y": 370
1256
+ },
1257
+ "\\mathrm{B}": {
1258
+ "x": 264,
1259
+ "y": 370
1260
+ },
1261
+ "\\mathrm{C}": {
1262
+ "x": 301,
1263
+ "y": 370
1264
+ },
1265
+ "\\mathrm{D}": {
1266
+ "x": 338,
1267
+ "y": 370
1268
+ },
1269
+ "\\mathrm{E}": {
1270
+ "x": 375,
1271
+ "y": 370
1272
+ },
1273
+ "\\mathrm{F}": {
1274
+ "x": 412,
1275
+ "y": 370
1276
+ },
1277
+ "\\mathrm{G}": {
1278
+ "x": 449,
1279
+ "y": 370
1280
+ },
1281
+ "\\mathrm{H}": {
1282
+ "x": 486,
1283
+ "y": 370
1284
+ },
1285
+ "\\mathrm{I}": {
1286
+ "x": 523,
1287
+ "y": 370
1288
+ },
1289
+ "\\mathrm{J}": {
1290
+ "x": 560,
1291
+ "y": 370
1292
+ },
1293
+ "\\mathrm{K}": {
1294
+ "x": 597,
1295
+ "y": 370
1296
+ },
1297
+ "\\mathrm{L}": {
1298
+ "x": 634,
1299
+ "y": 370
1300
+ },
1301
+ "\\mathrm{M}": {
1302
+ "x": 671,
1303
+ "y": 370
1304
+ },
1305
+ "\\mathrm{N}": {
1306
+ "x": 708,
1307
+ "y": 370
1308
+ },
1309
+ "\\mathrm{O}": {
1310
+ "x": 745,
1311
+ "y": 370
1312
+ },
1313
+ "\\mathrm{P}": {
1314
+ "x": 782,
1315
+ "y": 370
1316
+ },
1317
+ "\\mathrm{Q}": {
1318
+ "x": 819,
1319
+ "y": 370
1320
+ },
1321
+ "\\mathrm{R}": {
1322
+ "x": 856,
1323
+ "y": 370
1324
+ },
1325
+ "\\mathrm{S}": {
1326
+ "x": 893,
1327
+ "y": 370
1328
+ },
1329
+ "\\mathrm{T}": {
1330
+ "x": 930,
1331
+ "y": 370
1332
+ },
1333
+ "\\mathrm{U}": {
1334
+ "x": 967,
1335
+ "y": 370
1336
+ },
1337
+ "\\mathrm{V}": {
1338
+ "x": 1004,
1339
+ "y": 370
1340
+ },
1341
+ "\\mathrm{W}": {
1342
+ "x": 1041,
1343
+ "y": 370
1344
+ },
1345
+ "\\mathrm{X}": {
1346
+ "x": 1078,
1347
+ "y": 370
1348
+ },
1349
+ "\\mathrm{Y}": {
1350
+ "x": 5,
1351
+ "y": 407
1352
+ },
1353
+ "\\mathrm{Z}": {
1354
+ "x": 42,
1355
+ "y": 407
1356
+ },
1357
+ "\\mathrm{a}": {
1358
+ "x": 79,
1359
+ "y": 407
1360
+ },
1361
+ "\\mathrm{b}": {
1362
+ "x": 116,
1363
+ "y": 407
1364
+ },
1365
+ "\\mathrm{c}": {
1366
+ "x": 153,
1367
+ "y": 407
1368
+ },
1369
+ "\\mathrm{d}": {
1370
+ "x": 190,
1371
+ "y": 407
1372
+ },
1373
+ "\\mathrm{e}": {
1374
+ "x": 227,
1375
+ "y": 407
1376
+ },
1377
+ "\\mathrm{f}": {
1378
+ "x": 264,
1379
+ "y": 407
1380
+ },
1381
+ "\\mathrm{g}": {
1382
+ "x": 301,
1383
+ "y": 407
1384
+ },
1385
+ "\\mathrm{h}": {
1386
+ "x": 338,
1387
+ "y": 407
1388
+ },
1389
+ "\\mathrm{i}": {
1390
+ "x": 375,
1391
+ "y": 407
1392
+ },
1393
+ "\\mathrm{j}": {
1394
+ "x": 412,
1395
+ "y": 407
1396
+ },
1397
+ "\\mathrm{k}": {
1398
+ "x": 449,
1399
+ "y": 407
1400
+ },
1401
+ "\\mathrm{l}": {
1402
+ "x": 486,
1403
+ "y": 407
1404
+ },
1405
+ "\\mathrm{m}": {
1406
+ "x": 523,
1407
+ "y": 407
1408
+ },
1409
+ "\\mathrm{n}": {
1410
+ "x": 560,
1411
+ "y": 407
1412
+ },
1413
+ "\\mathrm{o}": {
1414
+ "x": 597,
1415
+ "y": 407
1416
+ },
1417
+ "\\mathrm{p}": {
1418
+ "x": 634,
1419
+ "y": 407
1420
+ },
1421
+ "\\mathrm{q}": {
1422
+ "x": 671,
1423
+ "y": 407
1424
+ },
1425
+ "\\mathrm{r}": {
1426
+ "x": 708,
1427
+ "y": 407
1428
+ },
1429
+ "\\mathrm{s}": {
1430
+ "x": 745,
1431
+ "y": 407
1432
+ },
1433
+ "\\mathrm{t}": {
1434
+ "x": 782,
1435
+ "y": 407
1436
+ },
1437
+ "\\mathrm{u}": {
1438
+ "x": 819,
1439
+ "y": 407
1440
+ },
1441
+ "\\mathrm{v}": {
1442
+ "x": 856,
1443
+ "y": 407
1444
+ },
1445
+ "\\mathrm{w}": {
1446
+ "x": 893,
1447
+ "y": 407
1448
+ },
1449
+ "\\mathrm{x}": {
1450
+ "x": 930,
1451
+ "y": 407
1452
+ },
1453
+ "\\mathrm{y}": {
1454
+ "x": 967,
1455
+ "y": 407
1456
+ },
1457
+ "\\mathrm{z}": {
1458
+ "x": 1004,
1459
+ "y": 407
1460
+ }
1461
+ };
1462
+
1463
+ // ../kity-runtime/src/vendor/legacy-common.ts
1464
+ var legacyCommonUtils = {
1465
+ contains: legacyBaseUtils.contains,
1466
+ getRect: legacyBaseUtils.getRect
1467
+ };
1468
+
1469
+ // ../kity-runtime/src/kity/class-system.ts
1470
+ function Class() {
1471
+ }
1472
+ var ClassProto = Class.prototype;
1473
+ ClassProto.base = function(name) {
1474
+ const stack = this.__kityCallStack__;
1475
+ const info = stack[stack.length - 1];
1476
+ const method = info.cls.__KityBaseClass.prototype[name];
1477
+ return method.apply(this, Array.prototype.slice.call(arguments, 1));
1478
+ };
1479
+ ClassProto.callBase = function() {
1480
+ const stack = this.__kityCallStack__;
1481
+ const info = stack[stack.length - 1];
1482
+ const method = info.cls.__KityBaseClass.prototype[info.methodName];
1483
+ return method.apply(this, arguments);
1484
+ };
1485
+ ClassProto.mixin = function(name) {
1486
+ const stack = this.__kityCallStack__;
1487
+ const info = stack[stack.length - 1];
1488
+ const mixins = info.cls.__KityMixins;
1489
+ if (!mixins) return this;
1490
+ return mixins[name].apply(this, Array.prototype.slice.call(arguments, 1));
1491
+ };
1492
+ ClassProto.callMixin = function() {
1493
+ const stack = this.__kityCallStack__;
1494
+ const info = stack[stack.length - 1];
1495
+ const methodName = info.methodName;
1496
+ const mixins = info.cls.__KityMixins;
1497
+ if (!mixins) return this;
1498
+ const method = mixins[methodName];
1499
+ if (methodName === "constructor") {
1500
+ for (let i = 0; i < method.length; i++) method[i].call(this);
1501
+ return this;
1502
+ }
1503
+ return method.apply(this, arguments);
1504
+ };
1505
+ ClassProto.pipe = function(fn) {
1506
+ if (typeof fn === "function") fn.call(this, this);
1507
+ return this;
1508
+ };
1509
+ ClassProto.getType = function() {
1510
+ return this.__KityClassName;
1511
+ };
1512
+ ClassProto.getClass = function() {
1513
+ return this.constructor;
1514
+ };
1515
+ function wrapMethod(cls, methodName, originalMethod) {
1516
+ const wrapped = function() {
1517
+ this.__kityCallStack__ = this.__kityCallStack__ || [];
1518
+ this.__kityCallStack__.push({ cls, methodName });
1519
+ try {
1520
+ return originalMethod.apply(this, arguments);
1521
+ } finally {
1522
+ this.__kityCallStack__.pop();
1523
+ }
1524
+ };
1525
+ wrapped.__KityMethodClass = cls;
1526
+ wrapped.__KityMethodName = methodName;
1527
+ return wrapped;
1528
+ }
1529
+ function inherit(constructor, BaseClass) {
1530
+ const KityClass = function() {
1531
+ const meta2 = KityClass;
1532
+ meta2.__KityConstructor.apply(this, arguments);
1533
+ };
1534
+ const meta = KityClass;
1535
+ meta.__KityConstructor = constructor;
1536
+ KityClass.prototype = Object.create(BaseClass.prototype);
1537
+ for (const methodName in BaseClass.prototype) {
1538
+ if (Object.prototype.hasOwnProperty.call(BaseClass.prototype, methodName) && methodName.indexOf("__Kity") !== 0) {
1539
+ KityClass.prototype[methodName] = BaseClass.prototype[methodName];
1540
+ }
1541
+ }
1542
+ KityClass.prototype.constructor = KityClass;
1543
+ return KityClass;
1544
+ }
1545
+ function legacyMixin(NewClass, mixins) {
1546
+ if (!(mixins instanceof Array)) return NewClass;
1547
+ const meta = NewClass;
1548
+ meta.__KityMixins = { constructor: [] };
1549
+ for (let i = 0; i < mixins.length; i++) {
1550
+ const proto = mixins[i].prototype;
1551
+ for (const method in proto) {
1552
+ if (!Object.prototype.hasOwnProperty.call(proto, method)) continue;
1553
+ if (method === "constructor") {
1554
+ meta.__KityMixins["constructor"].push(proto[method]);
1555
+ } else {
1556
+ NewClass.prototype[method] = meta.__KityMixins[method] = proto[method];
1557
+ }
1558
+ }
1559
+ }
1560
+ return NewClass;
1561
+ }
1562
+ function extend(BaseClass, extension) {
1563
+ for (const methodName in extension) {
1564
+ if (Object.prototype.hasOwnProperty.call(extension, methodName) && methodName !== "constructor" && methodName.indexOf("__Kity") !== 0) {
1565
+ BaseClass.prototype[methodName] = wrapMethod(
1566
+ BaseClass,
1567
+ methodName,
1568
+ extension[methodName]
1569
+ );
1570
+ }
1571
+ }
1572
+ return BaseClass;
1573
+ }
1574
+ function checkBaseConstructorCall(targetClass, classname) {
1575
+ if (!/this\.callBase/.test(targetClass.toString())) {
1576
+ throw new Error(
1577
+ `${classname}: the constructor must call the base constructor for compatibility with the legacy kity class system.`
1578
+ );
1579
+ }
1580
+ }
1581
+ function createClass(classname, defines) {
1582
+ let constructor;
1583
+ let NewClass;
1584
+ let BaseClass;
1585
+ if (arguments.length === 1) {
1586
+ defines = arguments[0];
1587
+ classname = "AnonymousClass";
1588
+ }
1589
+ defines = defines || {};
1590
+ BaseClass = defines.base || Class;
1591
+ if (Object.prototype.hasOwnProperty.call(defines, "constructor")) {
1592
+ constructor = defines.constructor;
1593
+ if (BaseClass !== Class) {
1594
+ checkBaseConstructorCall(constructor, classname);
1595
+ }
1596
+ } else {
1597
+ constructor = function() {
1598
+ this.callBase.apply(this, arguments);
1599
+ this.callMixin.apply(this, arguments);
1600
+ };
1601
+ }
1602
+ const originalConstructor = constructor;
1603
+ constructor = function() {
1604
+ this.__kityCallStack__ = this.__kityCallStack__ || [];
1605
+ this.__kityCallStack__.push({
1606
+ cls: NewClass,
1607
+ methodName: "constructor"
1608
+ });
1609
+ try {
1610
+ return originalConstructor.apply(this, arguments);
1611
+ } finally {
1612
+ this.__kityCallStack__.pop();
1613
+ }
1614
+ };
1615
+ NewClass = inherit(constructor, BaseClass);
1616
+ NewClass = legacyMixin(NewClass, defines.mixins || []);
1617
+ const meta = NewClass;
1618
+ meta.__KityClassName = constructor.__KityClassName = classname;
1619
+ meta.__KityBaseClass = constructor.__KityBaseClass = BaseClass;
1620
+ constructor.__KityMethodName = "constructor";
1621
+ constructor.__KityMethodClass = NewClass;
1622
+ delete defines.mixins;
1623
+ delete defines.constructor;
1624
+ delete defines.base;
1625
+ NewClass = extend(NewClass, defines);
1626
+ return NewClass;
1627
+ }
1628
+ function extendClass(clazz, extension) {
1629
+ return extend(clazz, extension);
1630
+ }
1631
+
1632
+ // ../kity-runtime/src/kity/geometry.ts
1633
+ var Box = createClass("Box", {
1634
+ constructor(x, y, width, height) {
1635
+ const box = arguments[0];
1636
+ if (box && typeof box === "object" && ("x" in box || "left" in box)) {
1637
+ x = box.x ?? box.left;
1638
+ y = box.y ?? box.top;
1639
+ width = box.width;
1640
+ height = box.height;
1641
+ }
1642
+ const w = width ?? 0;
1643
+ const h = height ?? 0;
1644
+ if (w < 0) {
1645
+ x = x - (width = -w);
1646
+ }
1647
+ if (h < 0) {
1648
+ y = y - (height = -h);
1649
+ }
1650
+ this.x = x || 0;
1651
+ this.y = y || 0;
1652
+ this.width = width || 0;
1653
+ this.height = height || 0;
1654
+ this.left = this.x;
1655
+ this.right = this.x + this.width;
1656
+ this.top = this.y;
1657
+ this.bottom = this.y + this.height;
1658
+ this.cx = this.x + this.width / 2;
1659
+ this.cy = this.y + this.height / 2;
1660
+ },
1661
+ getRangeX() {
1662
+ return [this.left, this.right];
1663
+ },
1664
+ getRangeY() {
1665
+ return [this.top, this.bottom];
1666
+ },
1667
+ merge(another) {
1668
+ if (this.isEmpty()) return new Box(another.x, another.y, another.width, another.height);
1669
+ const left = Math.min(this.left, another.left);
1670
+ const right = Math.max(this.right, another.right);
1671
+ const top = Math.min(this.top, another.top);
1672
+ const bottom = Math.max(this.bottom, another.bottom);
1673
+ return new Box(left, top, right - left, bottom - top);
1674
+ },
1675
+ intersect(another) {
1676
+ if (!(another instanceof Box) || this.isEmpty() || another.isEmpty()) return new Box();
1677
+ if (this.right <= another.left || another.right <= this.left || this.bottom <= another.top || another.bottom <= this.top)
1678
+ return new Box();
1679
+ const x = Math.max(this.left, another.left), y = Math.max(this.top, another.top);
1680
+ return new Box(
1681
+ x,
1682
+ y,
1683
+ Math.min(this.right, another.right) - x,
1684
+ Math.min(this.bottom, another.bottom) - y
1685
+ );
1686
+ },
1687
+ expand(top, right, bottom, left) {
1688
+ if (arguments.length < 4) {
1689
+ right = top;
1690
+ bottom = top;
1691
+ left = top;
1692
+ }
1693
+ return new Box(
1694
+ this.x - left,
1695
+ this.y - top,
1696
+ this.width + right + left,
1697
+ this.height + top + bottom
1698
+ );
1699
+ },
1700
+ valueOf() {
1701
+ return [this.x, this.y, this.width, this.height];
1702
+ },
1703
+ toString() {
1704
+ return this.valueOf().join(" ");
1705
+ },
1706
+ isEmpty() {
1707
+ return !this.width || !this.height;
1708
+ }
1709
+ });
1710
+ Box.parse = function(unknown) {
1711
+ if (!unknown) return new Box();
1712
+ if (unknown instanceof Box) return unknown;
1713
+ if (typeof unknown === "string") return Box.parse(unknown.split(/\s*[\s,]\s*/));
1714
+ if ("0" in unknown && "1" in unknown && "2" in unknown && "3" in unknown)
1715
+ return new Box(unknown[0], unknown[1], unknown[2], unknown[3]);
1716
+ return new Box();
1717
+ };
1718
+ var Point = createClass("Point", {
1719
+ constructor(x, y) {
1720
+ this.x = x || 0;
1721
+ this.y = y || 0;
1722
+ },
1723
+ offset(dx, dy) {
1724
+ if (arguments.length === 1) {
1725
+ dy = dx.y;
1726
+ dx = dx.x;
1727
+ }
1728
+ return new Point(this.x + dx, this.y + dy);
1729
+ },
1730
+ valueOf() {
1731
+ return [this.x, this.y];
1732
+ },
1733
+ toString() {
1734
+ return this.valueOf().join(" ");
1735
+ },
1736
+ spof() {
1737
+ return new Point((this.x | 0) + 0.5, (this.y | 0) + 0.5);
1738
+ },
1739
+ round() {
1740
+ return new Point(this.x | 0, this.y | 0);
1741
+ },
1742
+ isOrigin() {
1743
+ return this.x === 0 && this.y === 0;
1744
+ }
1745
+ });
1746
+ Point.fromPolar = function(radius, angle, unit) {
1747
+ if (unit !== "rad") angle = angle / 180 * Math.PI;
1748
+ return new Point(radius * Math.cos(angle), radius * Math.sin(angle));
1749
+ };
1750
+ Point.parse = function(unknown) {
1751
+ if (!unknown) return new Point();
1752
+ if (unknown instanceof Point) return unknown;
1753
+ if (typeof unknown === "string") return Point.parse(unknown.split(/\s*[\s,]\s*/));
1754
+ if ("0" in unknown && "1" in unknown) return new Point(unknown[0], unknown[1]);
1755
+ return new Point();
1756
+ };
1757
+ var g = {};
1758
+ g.pathToString = function(pathSegment) {
1759
+ pathSegment = pathSegment || this;
1760
+ if (typeof pathSegment === "string") return pathSegment;
1761
+ if (pathSegment instanceof Array)
1762
+ return utils_default.flatten(pathSegment).join(",").replace(/,?([achlmqrstvxz]),?/gi, "$1");
1763
+ return "";
1764
+ };
1765
+ function d2r(deg) {
1766
+ return deg * Math.PI / 180;
1767
+ }
1768
+ function mergeMatrixData(m2, m1) {
1769
+ return {
1770
+ a: m1.a * m2.a + m1.c * m2.b,
1771
+ b: m1.b * m2.a + m1.d * m2.b,
1772
+ c: m1.a * m2.c + m1.c * m2.d,
1773
+ d: m1.b * m2.c + m1.d * m2.d,
1774
+ e: m1.a * m2.e + m1.c * m2.f + m1.e,
1775
+ f: m1.b * m2.e + m1.d * m2.f + m1.f
1776
+ };
1777
+ }
1778
+ var mPattern = /matrix\s*\((.+)\)/i;
1779
+ var Matrix = createClass("Matrix", {
1780
+ constructor(..._args) {
1781
+ if (arguments.length) {
1782
+ this.setMatrix.apply(this, arguments);
1783
+ } else {
1784
+ this.setMatrix(1, 0, 0, 1, 0, 0);
1785
+ }
1786
+ },
1787
+ translate(x, y) {
1788
+ this.m = mergeMatrixData(this.m, {
1789
+ a: 1,
1790
+ c: 0,
1791
+ e: x,
1792
+ b: 0,
1793
+ d: 1,
1794
+ f: y
1795
+ });
1796
+ return this;
1797
+ },
1798
+ rotate(deg) {
1799
+ const r = d2r(deg), s = Math.sin(r), c = Math.cos(r);
1800
+ this.m = mergeMatrixData(this.m, {
1801
+ a: c,
1802
+ c: -s,
1803
+ e: 0,
1804
+ b: s,
1805
+ d: c,
1806
+ f: 0
1807
+ });
1808
+ return this;
1809
+ },
1810
+ scale(sx, sy) {
1811
+ if (sy === void 0) sy = sx;
1812
+ this.m = mergeMatrixData(this.m, {
1813
+ a: sx,
1814
+ c: 0,
1815
+ e: 0,
1816
+ b: 0,
1817
+ d: sy,
1818
+ f: 0
1819
+ });
1820
+ return this;
1821
+ },
1822
+ skew(degX, degY) {
1823
+ if (degY === void 0) degY = degX;
1824
+ this.m = mergeMatrixData(this.m, {
1825
+ a: 1,
1826
+ c: Math.tan(d2r(degX)),
1827
+ e: 0,
1828
+ b: Math.tan(d2r(degY)),
1829
+ d: 1,
1830
+ f: 0
1831
+ });
1832
+ return this;
1833
+ },
1834
+ inverse() {
1835
+ const m = this.m, k = m.a * m.d - m.b * m.c;
1836
+ return new Matrix(
1837
+ m.d / k,
1838
+ -m.b / k,
1839
+ -m.c / k,
1840
+ m.a / k,
1841
+ (m.c * m.f - m.e * m.d) / k,
1842
+ (m.b * m.e - m.a * m.f) / k
1843
+ );
1844
+ },
1845
+ setMatrix(a, b, c, d, e, f) {
1846
+ if (arguments.length === 1) {
1847
+ this.m = utils_default.clone(arguments[0]);
1848
+ } else {
1849
+ this.m = {
1850
+ a,
1851
+ b,
1852
+ c,
1853
+ d,
1854
+ e,
1855
+ f
1856
+ };
1857
+ }
1858
+ return this;
1859
+ },
1860
+ getMatrix() {
1861
+ return utils_default.clone(this.m);
1862
+ },
1863
+ getTranslate() {
1864
+ const m = this.m;
1865
+ return { x: m.e / m.a, y: m.f / m.d };
1866
+ },
1867
+ mergeMatrix(matrix) {
1868
+ return new Matrix(mergeMatrixData(this.m, matrix.m));
1869
+ },
1870
+ merge(matrix) {
1871
+ return this.mergeMatrix(matrix);
1872
+ },
1873
+ toString() {
1874
+ return this.valueOf().join(" ");
1875
+ },
1876
+ valueOf() {
1877
+ const m = this.m;
1878
+ return [m.a, m.b, m.c, m.d, m.e, m.f];
1879
+ },
1880
+ equals(matrix) {
1881
+ const m1 = this.m, m2 = matrix.m;
1882
+ return m1.a === m2.a && m1.b === m2.b && m1.c === m2.c && m1.d === m2.d && m1.e === m2.e && m1.f === m2.f;
1883
+ },
1884
+ transformPoint() {
1885
+ return Matrix.transformPoint.apply(
1886
+ null,
1887
+ [].slice.call(arguments).concat([this.m])
1888
+ );
1889
+ },
1890
+ transformBox(box) {
1891
+ return Matrix.transformBox(box, this.m);
1892
+ },
1893
+ clone() {
1894
+ return new Matrix(this.m);
1895
+ },
1896
+ reverse() {
1897
+ return this.inverse();
1898
+ }
1899
+ });
1900
+ Matrix.parse = function(str) {
1901
+ const f = parseFloat;
1902
+ if (str instanceof Array)
1903
+ return new Matrix({
1904
+ a: f(str[0]),
1905
+ b: f(str[1]),
1906
+ c: f(str[2]),
1907
+ d: f(str[3]),
1908
+ e: f(str[4]),
1909
+ f: f(str[5])
1910
+ });
1911
+ const match = mPattern.exec(str);
1912
+ if (match) {
1913
+ let values = match[1].split(",");
1914
+ if (values.length !== 6) values = match[1].split(" ");
1915
+ return new Matrix({
1916
+ a: f(values[0]),
1917
+ b: f(values[1]),
1918
+ c: f(values[2]),
1919
+ d: f(values[3]),
1920
+ e: f(values[4]),
1921
+ f: f(values[5])
1922
+ });
1923
+ }
1924
+ return new Matrix();
1925
+ };
1926
+ Matrix.transformPoint = function(x, y, m) {
1927
+ if (arguments.length === 2) {
1928
+ m = y;
1929
+ y = x.y;
1930
+ x = x.x;
1931
+ }
1932
+ return new Point(
1933
+ m.a * x + m.c * y + m.e,
1934
+ m.b * x + m.d * y + m.f
1935
+ );
1936
+ };
1937
+ Matrix.transformBox = function(box, matrix) {
1938
+ let xMin = Number.MAX_VALUE, xMax = -Number.MAX_VALUE, yMin = Number.MAX_VALUE, yMax = -Number.MAX_VALUE;
1939
+ const bps = [
1940
+ [box.x, box.y],
1941
+ [box.x + box.width, box.y],
1942
+ [box.x, box.y + box.height],
1943
+ [box.x + box.width, box.y + box.height]
1944
+ ];
1945
+ const rps = [];
1946
+ let bp;
1947
+ while (bp = bps.pop()) {
1948
+ const rp = Matrix.transformPoint(bp[0], bp[1], matrix);
1949
+ rps.push(rp);
1950
+ xMin = Math.min(xMin, rp.x);
1951
+ xMax = Math.max(xMax, rp.x);
1952
+ yMin = Math.min(yMin, rp.y);
1953
+ yMax = Math.max(yMax, rp.y);
1954
+ }
1955
+ const result = new Box({
1956
+ x: xMin,
1957
+ y: yMin,
1958
+ width: xMax - xMin,
1959
+ height: yMax - yMin
1960
+ });
1961
+ utils_default.extend(result, { closurePoints: rps });
1962
+ return result;
1963
+ };
1964
+ function getTransformToElement(target, source) {
1965
+ try {
1966
+ return source.getScreenCTM().inverse().multiply(target.getScreenCTM());
1967
+ } catch {
1968
+ throw new Error("Unable to invert the source element's transformation matrix.");
1969
+ }
1970
+ }
1971
+ Matrix.getCTM = function(target, refer) {
1972
+ let ctm = {
1973
+ a: 1,
1974
+ b: 0,
1975
+ c: 0,
1976
+ d: 1,
1977
+ e: 0,
1978
+ f: 0
1979
+ };
1980
+ const node = target.shapeNode || target.node;
1981
+ refer = refer || "parent";
1982
+ switch (refer) {
1983
+ case "screen":
1984
+ ctm = node.getScreenCTM();
1985
+ break;
1986
+ case "doc":
1987
+ case "paper":
1988
+ ctm = node.getCTM();
1989
+ break;
1990
+ case "view":
1991
+ case "top":
1992
+ if (target.getPaper()) {
1993
+ ctm = getTransformToElement(node, target.getPaper().shapeNode);
1994
+ }
1995
+ break;
1996
+ case "parent":
1997
+ if (target.node.parentNode) {
1998
+ ctm = getTransformToElement(node, target.node.parentNode);
1999
+ }
2000
+ break;
2001
+ default:
2002
+ if (refer && refer.node) {
2003
+ ctm = getTransformToElement(node, refer.shapeNode || refer.node);
2004
+ }
2005
+ }
2006
+ return new Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f);
2007
+ };
2008
+
2009
+ // ../kity-runtime/src/kity/graphics.ts
2010
+ var pc = Point;
2011
+ var mc = Matrix;
2012
+ var _svgId = { id: 0 };
2013
+ var svg = {
2014
+ ns: "http://www.w3.org/2000/svg",
2015
+ xlink: "http://www.w3.org/1999/xlink",
2016
+ defaults: {
2017
+ stroke: "none",
2018
+ fill: "none"
2019
+ },
2020
+ createNode(name) {
2021
+ const node = document.createElementNS(svg.ns, name);
2022
+ node.id = "kity_" + name + "_" + _svgId.id++;
2023
+ return node;
2024
+ }
2025
+ };
2026
+ var INNER_HANDLER_CACHE = {};
2027
+ var USER_HANDLER_CACHE = {};
2028
+ var _guid = 0;
2029
+ function getEventUid(target) {
2030
+ const eventUid = target._EVENT_UID ?? target._EVNET_UID;
2031
+ if (eventUid === void 0) {
2032
+ throw new Error("Event handler instance is missing an event uid.");
2033
+ }
2034
+ return eventUid;
2035
+ }
2036
+ function setLegacyEventUid(target, eventUid) {
2037
+ target._EVENT_UID = eventUid;
2038
+ if (Object.prototype.hasOwnProperty.call(target, "_EVNET_UID")) {
2039
+ target._EVNET_UID = eventUid;
2040
+ return;
2041
+ }
2042
+ Object.defineProperty(target, "_EVNET_UID", {
2043
+ configurable: true,
2044
+ enumerable: true,
2045
+ get() {
2046
+ return target._EVENT_UID;
2047
+ },
2048
+ set(value) {
2049
+ target._EVENT_UID = value;
2050
+ }
2051
+ });
2052
+ }
2053
+ function bindDomEvent(node, type, handler) {
2054
+ node.addEventListener(type, handler, false);
2055
+ }
2056
+ function deleteDomEvent(node, type, handler) {
2057
+ node.removeEventListener(type, handler, false);
2058
+ }
2059
+ function sendMessage(messageObj, type, msg) {
2060
+ const handlers = INNER_HANDLER_CACHE[getEventUid(messageObj)];
2061
+ if (!handlers) {
2062
+ return;
2063
+ }
2064
+ const handler = handlers[type];
2065
+ if (!handler) {
2066
+ return;
2067
+ }
2068
+ const event = utils_default.extend({ type, target: messageObj }, msg || {});
2069
+ handler.call(messageObj, event);
2070
+ }
2071
+ function listen(node, type, handler, isOnce, targetObject) {
2072
+ const eid = getEventUid(targetObject);
2073
+ if (!INNER_HANDLER_CACHE[eid]) {
2074
+ INNER_HANDLER_CACHE[eid] = {};
2075
+ }
2076
+ if (!INNER_HANDLER_CACHE[eid][type]) {
2077
+ INNER_HANDLER_CACHE[eid][type] = function kityEventHandler(e) {
2078
+ e = new ShapeEvent(e || window.event);
2079
+ const list = USER_HANDLER_CACHE[eid][type];
2080
+ if (!list) {
2081
+ return;
2082
+ }
2083
+ for (let i = 0; i < list.length; i++) {
2084
+ const fn = list[i];
2085
+ if (fn) {
2086
+ const result = fn.call(targetObject, e);
2087
+ if (isOnce) {
2088
+ targetObject.off(type, fn);
2089
+ }
2090
+ if (result === false) {
2091
+ return false;
2092
+ }
2093
+ }
2094
+ }
2095
+ return;
2096
+ };
2097
+ }
2098
+ if (!USER_HANDLER_CACHE[eid]) {
2099
+ USER_HANDLER_CACHE[eid] = {};
2100
+ }
2101
+ if (!USER_HANDLER_CACHE[eid][type]) {
2102
+ USER_HANDLER_CACHE[eid][type] = [handler];
2103
+ if (!!node && "on" + type in node) {
2104
+ bindDomEvent(node, type, INNER_HANDLER_CACHE[eid][type]);
2105
+ }
2106
+ } else {
2107
+ USER_HANDLER_CACHE[eid][type].push(handler);
2108
+ }
2109
+ }
2110
+ function _addEvent(type, handler, isOnce) {
2111
+ isOnce = !!isOnce;
2112
+ if (utils_default.isString(type)) {
2113
+ type = type.match(/\S+/g) || [];
2114
+ }
2115
+ utils_default.each(type, (currentType) => {
2116
+ listen(this.node, currentType, handler, isOnce, this);
2117
+ });
2118
+ return this;
2119
+ }
2120
+ function _removeEvent(type, handler) {
2121
+ const eventId = String(getEventUid(this));
2122
+ const userHandlerList = USER_HANDLER_CACHE[eventId][type];
2123
+ let isRemoveAll = handler === void 0;
2124
+ if (!isRemoveAll && userHandlerList) {
2125
+ isRemoveAll = true;
2126
+ utils_default.each(userHandlerList, (fn, index) => {
2127
+ if (fn === handler) {
2128
+ delete userHandlerList[index];
2129
+ } else {
2130
+ isRemoveAll = false;
2131
+ }
2132
+ });
2133
+ }
2134
+ if (isRemoveAll) {
2135
+ deleteDomEvent(this.node, type, INNER_HANDLER_CACHE[eventId][type]);
2136
+ delete USER_HANDLER_CACHE[eventId][type];
2137
+ delete INNER_HANDLER_CACHE[eventId][type];
2138
+ }
2139
+ return this;
2140
+ }
2141
+ var EventHandler = createClass("EventHandler", {
2142
+ constructor() {
2143
+ setLegacyEventUid(this, ++_guid);
2144
+ },
2145
+ addEventListener(type, handler) {
2146
+ return _addEvent.call(this, type, handler, false);
2147
+ },
2148
+ addOnceEventListener(type, handler) {
2149
+ return _addEvent.call(this, type, handler, true);
2150
+ },
2151
+ removeEventListener(type, handler) {
2152
+ return _removeEvent.call(this, type, handler);
2153
+ },
2154
+ on(type, handler) {
2155
+ return this.addEventListener(type, handler);
2156
+ },
2157
+ once(type, handler) {
2158
+ return this.addOnceEventListener(type, handler);
2159
+ },
2160
+ off(type, handler) {
2161
+ return this.removeEventListener(type, handler);
2162
+ },
2163
+ fire(type, params) {
2164
+ return this.trigger(type, params);
2165
+ },
2166
+ trigger(type, params) {
2167
+ sendMessage(this, type, params);
2168
+ return this;
2169
+ }
2170
+ });
2171
+ var ShapeEvent = createClass("ShapeEvent", {
2172
+ constructor(event) {
2173
+ let target = null;
2174
+ if (!utils_default.isObject(event.target)) {
2175
+ this.type = event.type;
2176
+ target = event.target;
2177
+ if (target.correspondingUseElement) {
2178
+ target = target.correspondingUseElement;
2179
+ }
2180
+ this.originEvent = event;
2181
+ this.targetShape = target.shape || target.paper || event.currentTarget && (event.currentTarget.shape || event.currentTarget.paper);
2182
+ if (event._kityParam) {
2183
+ utils_default.extend(this, event._kityParam);
2184
+ }
2185
+ } else {
2186
+ utils_default.extend(this, event);
2187
+ }
2188
+ },
2189
+ preventDefault() {
2190
+ const evt = this.originEvent;
2191
+ if (!evt) {
2192
+ return true;
2193
+ }
2194
+ evt.preventDefault();
2195
+ return evt.cancelable;
2196
+ },
2197
+ getPosition(refer, touchIndex) {
2198
+ if (!this.originEvent) {
2199
+ return null;
2200
+ }
2201
+ const eventClient = this.originEvent.touches ? this.originEvent.touches[touchIndex || 0] : this.originEvent;
2202
+ const target = this.targetShape;
2203
+ const targetNode = target.shapeNode || target.node;
2204
+ const pScreen = new pc(
2205
+ eventClient && eventClient.clientX || 0,
2206
+ eventClient && eventClient.clientY || 0
2207
+ );
2208
+ const pTarget = mc.transformPoint(pScreen, targetNode.getScreenCTM().inverse());
2209
+ const pRefer = mc.getCTM(target, refer || "view").transformPoint(pTarget);
2210
+ return pRefer;
2211
+ },
2212
+ stopPropagation() {
2213
+ const evt = this.originEvent;
2214
+ if (!evt) {
2215
+ return true;
2216
+ }
2217
+ evt.stopPropagation();
2218
+ }
2219
+ });
2220
+ var _ClassListProto = {
2221
+ constructor(node) {
2222
+ this._node = node;
2223
+ this._list = node.className.toString().split(" ");
2224
+ },
2225
+ _update() {
2226
+ this._node.className = this._list.join(" ");
2227
+ },
2228
+ add(name) {
2229
+ this._list.push(name);
2230
+ this._update();
2231
+ },
2232
+ remove(name) {
2233
+ const index = this._list.indexOf(name);
2234
+ if (~index) {
2235
+ this._list.splice(index, 1);
2236
+ }
2237
+ this._update();
2238
+ },
2239
+ contains(name) {
2240
+ return !!~this._list.indexOf(name);
2241
+ }
2242
+ };
2243
+ function _getClassList(node) {
2244
+ if (!node.classList) {
2245
+ node.classList = new (createClass("ClassList", _ClassListProto))(node);
2246
+ }
2247
+ return node.classList;
2248
+ }
2249
+ var Styled = createClass("Styled", {
2250
+ addClass(name) {
2251
+ _getClassList(this.node).add(name);
2252
+ return this;
2253
+ },
2254
+ removeClass(name) {
2255
+ _getClassList(this.node).remove(name);
2256
+ return this;
2257
+ },
2258
+ hasClass(name) {
2259
+ return _getClassList(this.node).contains(name);
2260
+ },
2261
+ setStyle(styleOrName, value) {
2262
+ if (arguments.length === 2 && typeof styleOrName === "string") {
2263
+ this.node.style[styleOrName] = value;
2264
+ return this;
2265
+ }
2266
+ if (typeof styleOrName === "object") {
2267
+ for (const name in styleOrName) {
2268
+ if (Object.prototype.hasOwnProperty.call(styleOrName, name)) {
2269
+ this.node.style[name] = styleOrName[name];
2270
+ }
2271
+ }
2272
+ }
2273
+ return this;
2274
+ }
2275
+ });
2276
+ var Data = createClass("Data", {
2277
+ constructor() {
2278
+ this._data = {};
2279
+ },
2280
+ setData(name, value) {
2281
+ this._data[name] = value;
2282
+ return this;
2283
+ },
2284
+ getData(name) {
2285
+ return this._data[name];
2286
+ },
2287
+ removeData(name) {
2288
+ delete this._data[name];
2289
+ return this;
2290
+ }
2291
+ });
2292
+ function itemRemove() {
2293
+ this.container.removeItem(this);
2294
+ return this;
2295
+ }
2296
+ var Container = createClass("Container", {
2297
+ getItems() {
2298
+ return this.items || (this.items = []);
2299
+ },
2300
+ getItem(index) {
2301
+ return this.getItems()[index];
2302
+ },
2303
+ getFirstItem() {
2304
+ return this.getItem(0);
2305
+ },
2306
+ getLastItem() {
2307
+ return this.getItem(this.getItems().length - 1);
2308
+ },
2309
+ indexOf(item) {
2310
+ return this.getItems().indexOf(item);
2311
+ },
2312
+ eachItem(fn) {
2313
+ const items = this.getItems();
2314
+ for (let i = 0; i < items.length; i++) {
2315
+ fn.call(this, i, items[i]);
2316
+ }
2317
+ return this;
2318
+ },
2319
+ addItem(item, pos, noEvent) {
2320
+ const items = this.getItems();
2321
+ const length = items.length;
2322
+ if (~items.indexOf(item)) {
2323
+ return this;
2324
+ }
2325
+ if (!(pos >= 0 && pos < length)) {
2326
+ pos = length;
2327
+ }
2328
+ items.splice(pos, 0, item);
2329
+ if (typeof item === "object") {
2330
+ item.container = this;
2331
+ item.remove = itemRemove;
2332
+ }
2333
+ this.handleAdd(item, pos);
2334
+ if (!noEvent) {
2335
+ this.onContainerChanged("add", [item]);
2336
+ }
2337
+ return this;
2338
+ },
2339
+ addItems(items) {
2340
+ for (let i = 0, l = items.length; i < l; i++) {
2341
+ this.addItem(items[i], -1, true);
2342
+ }
2343
+ this.onContainerChanged("add", items);
2344
+ return this;
2345
+ },
2346
+ setItems(items) {
2347
+ return this.clear().addItems(items);
2348
+ },
2349
+ appendItem(item) {
2350
+ return this.addItem(item);
2351
+ },
2352
+ prependItem(item) {
2353
+ return this.addItem(item, 0);
2354
+ },
2355
+ removeItem(pos, noEvent) {
2356
+ if (typeof pos !== "number") {
2357
+ return this.removeItem(this.indexOf(pos));
2358
+ }
2359
+ const items = this.getItems();
2360
+ const item = items[pos];
2361
+ if (item === void 0) {
2362
+ return this;
2363
+ }
2364
+ items.splice(pos, 1);
2365
+ if (item.container) {
2366
+ delete item.container;
2367
+ }
2368
+ if (item.remove) {
2369
+ delete item.remove;
2370
+ }
2371
+ this.handleRemove(item, pos);
2372
+ if (!noEvent) {
2373
+ this.onContainerChanged("remove", [item]);
2374
+ }
2375
+ return this;
2376
+ },
2377
+ clear() {
2378
+ const removed = [];
2379
+ let item;
2380
+ while ((item = this.getFirstItem()) !== void 0) {
2381
+ removed.push(item);
2382
+ this.removeItem(0, true);
2383
+ }
2384
+ this.onContainerChanged("remove", removed);
2385
+ return this;
2386
+ },
2387
+ onContainerChanged(_type, _items) {
2388
+ },
2389
+ handleAdd(_item, _index) {
2390
+ },
2391
+ handleRemove(_item, _index) {
2392
+ }
2393
+ });
2394
+ var Shape = createClass("Shape", {
2395
+ mixins: [EventHandler, Styled, Data],
2396
+ constructor(tagName) {
2397
+ this.node = svg.createNode(tagName);
2398
+ this.node.shape = this;
2399
+ this.transform = {
2400
+ translate: null,
2401
+ rotate: null,
2402
+ scale: null,
2403
+ matrix: null
2404
+ };
2405
+ this.callMixin();
2406
+ },
2407
+ getId() {
2408
+ return this.node.id;
2409
+ },
2410
+ setId(id) {
2411
+ this.node.id = id;
2412
+ return this;
2413
+ },
2414
+ getNode() {
2415
+ return this.node;
2416
+ },
2417
+ getBoundaryBox() {
2418
+ let box;
2419
+ try {
2420
+ box = this.node.getBBox();
2421
+ } catch {
2422
+ box = {
2423
+ x: this.node.clientLeft,
2424
+ y: this.node.clientTop,
2425
+ width: this.node.clientWidth,
2426
+ height: this.node.clientHeight
2427
+ };
2428
+ }
2429
+ return new Box(box);
2430
+ },
2431
+ getRenderBox(refer) {
2432
+ const box = this.getBoundaryBox();
2433
+ const matrix = this.getTransform(refer);
2434
+ return matrix.transformBox(box);
2435
+ },
2436
+ getWidth() {
2437
+ return this.getRenderBox().width;
2438
+ },
2439
+ getHeight() {
2440
+ return this.getRenderBox().height;
2441
+ },
2442
+ getSize() {
2443
+ const box = this.getRenderBox();
2444
+ delete box.x;
2445
+ delete box.y;
2446
+ return box;
2447
+ },
2448
+ setOpacity(value) {
2449
+ this.node.setAttribute("opacity", String(value));
2450
+ return this;
2451
+ },
2452
+ getOpacity() {
2453
+ const opacity = this.node.getAttribute("opacity");
2454
+ return opacity ? +opacity : 1;
2455
+ },
2456
+ setVisible(value) {
2457
+ if (value) {
2458
+ this.node.removeAttribute("display");
2459
+ } else {
2460
+ this.node.setAttribute("display", "none");
2461
+ }
2462
+ return this;
2463
+ },
2464
+ getVisible() {
2465
+ this.node.getAttribute("display");
2466
+ },
2467
+ hasAncestor(node) {
2468
+ let parent = this.container;
2469
+ while (parent) {
2470
+ if (parent === node) {
2471
+ return true;
2472
+ }
2473
+ parent = parent.container;
2474
+ }
2475
+ return false;
2476
+ },
2477
+ getTransform(refer) {
2478
+ return mc.getCTM(this, refer);
2479
+ },
2480
+ clearTransform() {
2481
+ this.node.removeAttribute("transform");
2482
+ this.transform = {
2483
+ translate: null,
2484
+ rotate: null,
2485
+ scale: null,
2486
+ matrix: null
2487
+ };
2488
+ this.trigger("shapeupdate", {
2489
+ type: "transform"
2490
+ });
2491
+ return this;
2492
+ },
2493
+ _applyTransform() {
2494
+ const t = this.transform;
2495
+ const result = [];
2496
+ if (t.translate) {
2497
+ result.push(["translate(", t.translate, ")"]);
2498
+ }
2499
+ if (t.rotate) {
2500
+ result.push(["rotate(", t.rotate, ")"]);
2501
+ }
2502
+ if (t.scale) {
2503
+ result.push(["scale(", t.scale, ")"]);
2504
+ }
2505
+ if (t.matrix) {
2506
+ result.push(["matrix(", t.matrix, ")"]);
2507
+ }
2508
+ this.node.setAttribute("transform", utils_default.flatten(result).join(" "));
2509
+ return this;
2510
+ },
2511
+ setMatrix(m) {
2512
+ this.transform.matrix = m;
2513
+ return this._applyTransform();
2514
+ },
2515
+ setTranslate(t) {
2516
+ this.transform.translate = t !== null && [].slice.call(arguments) || null;
2517
+ return this._applyTransform();
2518
+ },
2519
+ setRotate(r) {
2520
+ this.transform.rotate = r !== null && [].slice.call(arguments) || null;
2521
+ return this._applyTransform();
2522
+ },
2523
+ setScale(s) {
2524
+ this.transform.scale = s !== null && [].slice.call(arguments) || null;
2525
+ return this._applyTransform();
2526
+ },
2527
+ translate(dx, dy) {
2528
+ let m = this.transform.matrix || new mc();
2529
+ if (dy === void 0) {
2530
+ dy = 0;
2531
+ }
2532
+ this.transform.matrix = m.translate(dx, dy);
2533
+ return this._applyTransform();
2534
+ },
2535
+ rotate(deg) {
2536
+ let m = this.transform.matrix || new mc();
2537
+ this.transform.matrix = m.rotate(deg);
2538
+ return this._applyTransform();
2539
+ },
2540
+ scale(sx, sy) {
2541
+ let m = this.transform.matrix || new mc();
2542
+ if (sy === void 0) {
2543
+ sy = sx;
2544
+ }
2545
+ this.transform.matrix = m.scale(sx, sy);
2546
+ return this._applyTransform();
2547
+ },
2548
+ skew(sx, sy) {
2549
+ let m = this.transform.matrix || new mc();
2550
+ if (sy === void 0) {
2551
+ sy = sx;
2552
+ }
2553
+ this.transform.matrix = m.skew(sx, sy);
2554
+ return this._applyTransform();
2555
+ },
2556
+ stroke(pen, width) {
2557
+ if (pen && pen.stroke) {
2558
+ pen.stroke(this);
2559
+ } else if (pen) {
2560
+ this.node.setAttribute("stroke", pen.toString());
2561
+ if (width) {
2562
+ this.node.setAttribute("stroke-width", String(width));
2563
+ }
2564
+ } else if (pen === null) {
2565
+ this.node.removeAttribute("stroke");
2566
+ }
2567
+ return this;
2568
+ },
2569
+ fill(brush) {
2570
+ if (brush) {
2571
+ this.node.setAttribute("fill", brush.toString());
2572
+ }
2573
+ if (brush === null) {
2574
+ this.node.removeAttribute("fill");
2575
+ }
2576
+ return this;
2577
+ },
2578
+ setAttr(a, v) {
2579
+ if (utils_default.isObject(a)) {
2580
+ utils_default.each(a, (val, key) => {
2581
+ this.setAttr(key, val);
2582
+ });
2583
+ return this;
2584
+ }
2585
+ if (v === void 0 || v === null || v === "") {
2586
+ this.node.removeAttribute(a);
2587
+ } else {
2588
+ this.node.setAttribute(a, v);
2589
+ }
2590
+ return this;
2591
+ },
2592
+ getAttr(a) {
2593
+ return this.node.getAttribute(a);
2594
+ }
2595
+ });
2596
+ var ShapeContainer = createClass("ShapeContainer", {
2597
+ base: Container,
2598
+ isShapeContainer: true,
2599
+ handleAdd(shape, index) {
2600
+ const parent = this.getShapeNode();
2601
+ parent.insertBefore(shape.node, parent.childNodes[index] || null);
2602
+ shape.trigger("add", { container: this });
2603
+ if (shape.notifyTreeModification) {
2604
+ shape.notifyTreeModification("treeadd", this);
2605
+ }
2606
+ },
2607
+ handleRemove(shape, _index) {
2608
+ const parent = this.getShapeNode();
2609
+ parent.removeChild(shape.node);
2610
+ shape.trigger("remove", {
2611
+ container: this
2612
+ });
2613
+ if (shape.notifyTreeModification) {
2614
+ shape.notifyTreeModification("treeremove", this);
2615
+ }
2616
+ },
2617
+ notifyTreeModification(type, container) {
2618
+ this.eachItem((_index, shape) => {
2619
+ if (shape.notifyTreeModification) {
2620
+ shape.notifyTreeModification(type, container);
2621
+ }
2622
+ shape.trigger(type, { container });
2623
+ });
2624
+ },
2625
+ getShape(index) {
2626
+ return this.getItem(index);
2627
+ },
2628
+ addShape(shape, index) {
2629
+ return this.addItem(shape, index);
2630
+ },
2631
+ put(shape) {
2632
+ this.addShape(shape);
2633
+ return shape;
2634
+ },
2635
+ appendShape(shape) {
2636
+ return this.addShape(shape);
2637
+ },
2638
+ prependShape(shape) {
2639
+ return this.addShape(shape, 0);
2640
+ },
2641
+ replaceShape(replacer, origin) {
2642
+ const index = this.indexOf(origin);
2643
+ if (index === -1) {
2644
+ return;
2645
+ }
2646
+ this.removeShape(index);
2647
+ this.addShape(replacer, index);
2648
+ return this;
2649
+ },
2650
+ addShapeBefore(shape, refer) {
2651
+ const index = this.indexOf(refer);
2652
+ return this.addShape(shape, index);
2653
+ },
2654
+ addShapeAfter(shape, refer) {
2655
+ const index = this.indexOf(refer);
2656
+ return this.addShape(shape, index === -1 ? void 0 : index + 1);
2657
+ },
2658
+ addShapes(shapes) {
2659
+ return this.addItems(shapes);
2660
+ },
2661
+ removeShape(index) {
2662
+ return this.removeItem(index);
2663
+ },
2664
+ getShapes() {
2665
+ return this.getItems();
2666
+ },
2667
+ getShapesByType(name) {
2668
+ const shapes = [];
2669
+ const getShapes = (shape) => {
2670
+ if (name.toLowerCase() === shape.getType().toLowerCase()) {
2671
+ shapes.push(shape);
2672
+ }
2673
+ if (shape.isShapeContainer) {
2674
+ utils_default.each(shape.getShapes(), (n) => {
2675
+ getShapes(n);
2676
+ });
2677
+ }
2678
+ };
2679
+ getShapes(this);
2680
+ return shapes;
2681
+ },
2682
+ getShapeById(id) {
2683
+ return this.getShapeNode().getElementById(id).shape;
2684
+ },
2685
+ arrangeShape(shape, index) {
2686
+ return this.removeShape(shape).addShape(shape, index);
2687
+ },
2688
+ getShapeNode() {
2689
+ return this.shapeNode || this.node;
2690
+ }
2691
+ });
2692
+ extendClass(Shape, {
2693
+ bringTo(index) {
2694
+ this.container.arrangeShape(this, index);
2695
+ return this;
2696
+ },
2697
+ bringFront() {
2698
+ return this.bringTo(this.container.indexOf(this) + 1);
2699
+ },
2700
+ bringBack() {
2701
+ return this.bringTo(this.container.indexOf(this) - 1);
2702
+ },
2703
+ bringTop() {
2704
+ this.container.removeShape(this).addShape(this);
2705
+ return this;
2706
+ },
2707
+ bringRear() {
2708
+ return this.bringTo(0);
2709
+ },
2710
+ bringRefer(referShape, offset) {
2711
+ if (referShape.container) {
2712
+ if (this.remove) {
2713
+ this.remove();
2714
+ }
2715
+ referShape.container.addShape(this, referShape.container.indexOf(referShape) + (offset || 0));
2716
+ }
2717
+ return this;
2718
+ },
2719
+ bringAbove(referShape) {
2720
+ return this.bringRefer(referShape);
2721
+ },
2722
+ bringBelow(referShape) {
2723
+ return this.bringRefer(referShape, 1);
2724
+ },
2725
+ replaceBy(newShape) {
2726
+ if (this.container) {
2727
+ newShape.bringAbove(this);
2728
+ this.remove();
2729
+ }
2730
+ return this;
2731
+ }
2732
+ });
2733
+ var ViewBox = createClass("ViewBox", {
2734
+ getViewBox() {
2735
+ const attr = this.node.getAttribute("viewBox");
2736
+ if (attr === null) {
2737
+ return {
2738
+ x: 0,
2739
+ y: 0,
2740
+ width: this.node.clientWidth || this.node.parentNode?.clientWidth || 0,
2741
+ height: this.node.clientHeight || this.node.parentNode?.clientHeight || 0
2742
+ };
2743
+ } else {
2744
+ const parts = attr.split(" ");
2745
+ return {
2746
+ x: +parts[0],
2747
+ y: +parts[1],
2748
+ width: +parts[2],
2749
+ height: +parts[3]
2750
+ };
2751
+ }
2752
+ },
2753
+ setViewBox(x, y, width, height) {
2754
+ this.node.setAttribute("viewBox", [x, y, width, height].join(" "));
2755
+ return this;
2756
+ }
2757
+ });
2758
+ var TextContent = createClass("TextContent", {
2759
+ base: Shape,
2760
+ constructor(nodeType) {
2761
+ this.callBase(nodeType);
2762
+ this.shapeNode = this.shapeNode || this.node;
2763
+ this.shapeNode.setAttribute("text-rendering", "geometricPrecision");
2764
+ },
2765
+ clearContent() {
2766
+ while (this.shapeNode.firstChild) {
2767
+ this.shapeNode.removeChild(this.shapeNode.firstChild);
2768
+ }
2769
+ return this;
2770
+ },
2771
+ setContent(content) {
2772
+ this.shapeNode.textContent = content;
2773
+ return this;
2774
+ },
2775
+ getContent() {
2776
+ return this.shapeNode.textContent;
2777
+ },
2778
+ appendContent(content) {
2779
+ this.shapeNode.textContent += content;
2780
+ return this;
2781
+ },
2782
+ setSize(value) {
2783
+ return this.setFontSize(value);
2784
+ },
2785
+ setFontSize(value) {
2786
+ return this.setFont({
2787
+ size: value
2788
+ });
2789
+ },
2790
+ setFontFamily(value) {
2791
+ return this.setFont({
2792
+ family: value
2793
+ });
2794
+ },
2795
+ setFontBold(bold) {
2796
+ return this.setFont({
2797
+ weight: bold ? "bold" : "normal"
2798
+ });
2799
+ },
2800
+ setFontItalic(italic) {
2801
+ return this.setFont({
2802
+ style: italic ? "italic" : "normal"
2803
+ });
2804
+ },
2805
+ setFont(font) {
2806
+ const node = this.node;
2807
+ ["family", "size", "weight", "style"].forEach((section) => {
2808
+ if (font[section] === null) {
2809
+ node.removeAttribute("font-" + section);
2810
+ } else if (font[section]) {
2811
+ node.setAttribute("font-" + section, font[section]);
2812
+ }
2813
+ });
2814
+ return this;
2815
+ },
2816
+ getExtentOfChar(index) {
2817
+ return this.node.getExtentOfChar(index);
2818
+ },
2819
+ getRotationOfChar(index) {
2820
+ return this.node.getRotationOfChar(index);
2821
+ },
2822
+ getCharNumAtPosition(x, y) {
2823
+ return this.node.getCharNumAtPosition({ x, y });
2824
+ }
2825
+ });
2826
+ var _offsetHash = {};
2827
+ function _getTextBoundOffset(text) {
2828
+ const font = text._cachedFontHash;
2829
+ if (_offsetHash[font]) {
2830
+ return _offsetHash[font];
2831
+ }
2832
+ const textContent = text.getContent();
2833
+ text.setContent("\u767E\u5EA6Fex");
2834
+ const bbox = text.getBoundaryBox();
2835
+ const y = text.getY();
2836
+ if (!bbox.height) {
2837
+ return { top: 0, bottom: 0, middle: 0 };
2838
+ }
2839
+ const topOffset = y - bbox.y + +text.node.getAttribute("dy");
2840
+ const bottomOffset = topOffset - bbox.height;
2841
+ text.setContent(textContent);
2842
+ _offsetHash[font] = {
2843
+ top: topOffset,
2844
+ bottom: bottomOffset,
2845
+ middle: (topOffset + bottomOffset) / 2
2846
+ };
2847
+ return _offsetHash[font];
2848
+ }
2849
+ var Text = createClass("Text", {
2850
+ base: TextContent,
2851
+ mixins: [ShapeContainer],
2852
+ constructor(content) {
2853
+ this.callBase("text");
2854
+ if (content !== void 0) {
2855
+ this.setContent(content);
2856
+ }
2857
+ this._buildFontHash();
2858
+ },
2859
+ fixPosition() {
2860
+ if (!this.__fixedPosition) {
2861
+ this.setVerticalAlign(this.getVerticalAlign());
2862
+ }
2863
+ },
2864
+ _buildFontHash() {
2865
+ const style = window.getComputedStyle(this.node);
2866
+ this._cachedFontHash = [
2867
+ style.fontFamily,
2868
+ style.fontSize,
2869
+ style.fontStretch,
2870
+ style.fontStyle,
2871
+ style.fontVariant,
2872
+ style.fontWeight
2873
+ ].join("-");
2874
+ },
2875
+ _fontChanged(font) {
2876
+ const last = this._lastFont;
2877
+ const current = utils_default.extend({}, last, font);
2878
+ if (!last) {
2879
+ this._lastFont = font;
2880
+ return true;
2881
+ }
2882
+ const changed = last.family !== current.family || last.size !== current.size || last.style !== current.style || last.weight !== current.weight;
2883
+ this._lastFont = current;
2884
+ return changed;
2885
+ },
2886
+ setX(x) {
2887
+ this.node.setAttribute("x", String(x));
2888
+ return this;
2889
+ },
2890
+ setPosition(x, y) {
2891
+ return this.setX(x).setY(y);
2892
+ },
2893
+ setY(y) {
2894
+ this.node.setAttribute("y", String(y));
2895
+ return this;
2896
+ },
2897
+ getX() {
2898
+ return +(this.node.getAttribute("x") || "0");
2899
+ },
2900
+ getY() {
2901
+ return +(this.node.getAttribute("y") || "0");
2902
+ },
2903
+ setFont(font) {
2904
+ this.callBase(font);
2905
+ if (this._fontChanged(font)) {
2906
+ this._buildFontHash();
2907
+ this.setVerticalAlign(this.getVerticalAlign());
2908
+ }
2909
+ return this;
2910
+ },
2911
+ setTextAnchor(anchor) {
2912
+ this.node.setAttribute("text-anchor", anchor);
2913
+ return this;
2914
+ },
2915
+ getTextAnchor() {
2916
+ return this.node.getAttribute("text-anchor") || "start";
2917
+ },
2918
+ setVerticalAlign(align) {
2919
+ this.whenPaperReady(() => {
2920
+ let dy;
2921
+ switch (align) {
2922
+ case "top":
2923
+ dy = _getTextBoundOffset(this).top;
2924
+ break;
2925
+ case "bottom":
2926
+ dy = _getTextBoundOffset(this).bottom;
2927
+ break;
2928
+ case "middle":
2929
+ dy = _getTextBoundOffset(this).middle;
2930
+ break;
2931
+ default:
2932
+ dy = 0;
2933
+ }
2934
+ if (dy) {
2935
+ this.__fixedPosition = true;
2936
+ }
2937
+ this.node.setAttribute("dy", dy);
2938
+ });
2939
+ this.verticalAlign = align;
2940
+ return this;
2941
+ },
2942
+ getVerticalAlign() {
2943
+ return this.verticalAlign || "baseline";
2944
+ },
2945
+ setStartOffset(offset) {
2946
+ if (this.shapeNode !== this.node) {
2947
+ this.shapeNode.setAttribute("startOffset", offset * 100 + "%");
2948
+ }
2949
+ },
2950
+ addSpan(span) {
2951
+ this.addShape(span);
2952
+ return this;
2953
+ },
2954
+ setPath(path) {
2955
+ let textpath = this.shapeNode;
2956
+ if (this.shapeNode === this.node) {
2957
+ textpath = this.shapeNode = svg.createNode("textPath");
2958
+ while (this.node.firstChild) {
2959
+ this.shapeNode.appendChild(this.node.firstChild);
2960
+ }
2961
+ this.node.appendChild(textpath);
2962
+ }
2963
+ textpath.setAttributeNS(svg.xlink, "xlink:href", "#" + path.node.id);
2964
+ this.setTextAnchor(this.getTextAnchor());
2965
+ return this;
2966
+ }
2967
+ });
2968
+ var PathDrawer = createClass("PathDrawer", {
2969
+ constructor(path) {
2970
+ this.segment = [];
2971
+ this.path = path;
2972
+ this.__clear = false;
2973
+ },
2974
+ getPath() {
2975
+ return this.path;
2976
+ },
2977
+ redraw() {
2978
+ this._transation = this._transation || [];
2979
+ return this.clear();
2980
+ },
2981
+ done() {
2982
+ const transation = this._transation;
2983
+ this._transation = null;
2984
+ this.push(transation);
2985
+ return this;
2986
+ },
2987
+ clear() {
2988
+ if (this._transation) {
2989
+ this._transation = [];
2990
+ } else {
2991
+ this.path.setPathData("M 0 0");
2992
+ }
2993
+ this._clear = true;
2994
+ return this;
2995
+ },
2996
+ push() {
2997
+ const segment = [].slice.call(arguments);
2998
+ let originData;
2999
+ if (this._transation) {
3000
+ this._transation.push(segment);
3001
+ return this;
3002
+ }
3003
+ if (this._clear) {
3004
+ originData = "";
3005
+ this._clear = false;
3006
+ } else {
3007
+ originData = this.path.getPathData();
3008
+ }
3009
+ originData = originData || "";
3010
+ this.path.setPathData(originData + g.pathToString(segment));
3011
+ return this;
3012
+ },
3013
+ moveTo(_x, _y) {
3014
+ return this.push("M", [].slice.call(arguments));
3015
+ },
3016
+ moveBy(_dx, _dy) {
3017
+ return this.push("m", [].slice.call(arguments));
3018
+ },
3019
+ lineTo(_x, _y) {
3020
+ return this.push("L", [].slice.call(arguments));
3021
+ },
3022
+ lineBy(_dx, _dy) {
3023
+ return this.push("l", [].slice.call(arguments));
3024
+ },
3025
+ arcTo(_rx, _ry, _xr, _laf, _sf, _x, _y) {
3026
+ return this.push("A", [].slice.call(arguments));
3027
+ },
3028
+ arcBy(_rx, _ry, _xr, _laf, _sf, _dx, _dy) {
3029
+ return this.push("a", arguments);
3030
+ },
3031
+ carcTo(r, _laf, _sf, _x, _y) {
3032
+ return this.push("A", [r, r, 0].concat([].slice.call(arguments, 1)));
3033
+ },
3034
+ carcBy(r, _laf, _sf, _dx, _dy) {
3035
+ return this.push("a", [r, r, 0].concat([].slice.call(arguments, 1)));
3036
+ },
3037
+ bezierTo(_x1, _y1, _x2, _y2, _x, _y) {
3038
+ return this.push("C", [].slice.call(arguments));
3039
+ },
3040
+ bezierBy(_dx1, _dy1, _dx2, _dy2, _dx, _dy) {
3041
+ return this.push("c", [].slice.call(arguments));
3042
+ },
3043
+ close() {
3044
+ return this.push("z");
3045
+ }
3046
+ });
3047
+ var Path = createClass("Path", {
3048
+ base: Shape,
3049
+ constructor(data) {
3050
+ this.callBase("path");
3051
+ if (data) {
3052
+ this.setPathData(data);
3053
+ }
3054
+ this.node.setAttribute("fill", svg.defaults.fill);
3055
+ this.node.setAttribute("stroke", svg.defaults.stroke);
3056
+ },
3057
+ setPathData(data) {
3058
+ data = data || "M0,0";
3059
+ this.pathdata = g.pathToString(data);
3060
+ this.node.setAttribute("d", this.pathdata);
3061
+ this.trigger("shapeupdate", {
3062
+ type: "pathdata"
3063
+ });
3064
+ return this;
3065
+ },
3066
+ getPathData() {
3067
+ return this.pathdata || "";
3068
+ },
3069
+ getDrawer() {
3070
+ return new PathDrawer(this);
3071
+ },
3072
+ isClosed() {
3073
+ const data = this.getPathData();
3074
+ return !!~data.indexOf("z") || !!~data.indexOf("Z");
3075
+ }
3076
+ });
3077
+ var RectUtils = {
3078
+ formatRadius(width, height, radius) {
3079
+ const minValue = Math.floor(Math.min(width / 2, height / 2));
3080
+ return Math.min(minValue, radius);
3081
+ }
3082
+ };
3083
+ var Rect = createClass("Rect", {
3084
+ base: Path,
3085
+ constructor(width, height, x, y, radius) {
3086
+ this.callBase();
3087
+ this.x = x || 0;
3088
+ this.y = y || 0;
3089
+ this.width = width || 0;
3090
+ this.height = height || 0;
3091
+ this.radius = RectUtils.formatRadius(this.width, this.height, radius || 0);
3092
+ this.update();
3093
+ },
3094
+ update() {
3095
+ const x = this.x, y = this.y, w = this.width, h = this.height, r = this.radius;
3096
+ const drawer = this.getDrawer().redraw();
3097
+ if (!r) {
3098
+ drawer.push("M", x, y);
3099
+ drawer.push("h", w);
3100
+ drawer.push("v", h);
3101
+ drawer.push("h", -w);
3102
+ drawer.push("z");
3103
+ } else {
3104
+ const w2 = w - 2 * r;
3105
+ const h2 = h - 2 * r;
3106
+ drawer.push("M", x + r, y);
3107
+ drawer.push("h", w2);
3108
+ drawer.push("a", r, r, 0, 0, 1, r, r);
3109
+ drawer.push("v", h2);
3110
+ drawer.push("a", r, r, 0, 0, 1, -r, r);
3111
+ drawer.push("h", -w2);
3112
+ drawer.push("a", r, r, 0, 0, 1, -r, -r);
3113
+ drawer.push("v", -h2);
3114
+ drawer.push("a", r, r, 0, 0, 1, r, -r);
3115
+ drawer.push("z");
3116
+ }
3117
+ drawer.done();
3118
+ return this;
3119
+ },
3120
+ setWidth(width) {
3121
+ this.width = width;
3122
+ return this.update();
3123
+ },
3124
+ setHeight(height) {
3125
+ this.height = height;
3126
+ return this.update();
3127
+ },
3128
+ setSize(width, height) {
3129
+ this.width = width;
3130
+ this.height = height;
3131
+ return this.update();
3132
+ },
3133
+ setBox(box) {
3134
+ this.x = box.x;
3135
+ this.y = box.y;
3136
+ this.width = box.width;
3137
+ this.height = box.height;
3138
+ return this.update();
3139
+ },
3140
+ getBox() {
3141
+ return new Box(this.x, this.y, this.width, this.height);
3142
+ },
3143
+ getRadius() {
3144
+ return this.radius;
3145
+ },
3146
+ setRadius(radius) {
3147
+ this.radius = RectUtils.formatRadius(this.width, this.height, radius || 0);
3148
+ return this.update();
3149
+ },
3150
+ getPosition() {
3151
+ return new pc(this.x, this.y);
3152
+ },
3153
+ setPosition(xOrP, y) {
3154
+ if (arguments.length === 1) {
3155
+ const p = pc.parse(arguments[0]);
3156
+ y = p.y;
3157
+ xOrP = p.x;
3158
+ }
3159
+ this.x = xOrP;
3160
+ this.y = y;
3161
+ return this.update();
3162
+ },
3163
+ getWidth() {
3164
+ return this.width;
3165
+ },
3166
+ getHeight() {
3167
+ return this.height;
3168
+ },
3169
+ getPositionX() {
3170
+ return this.x;
3171
+ },
3172
+ getPositionY() {
3173
+ return this.y;
3174
+ },
3175
+ setPositionX(x) {
3176
+ this.x = x;
3177
+ return this.update();
3178
+ },
3179
+ setPositionY(y) {
3180
+ this.y = y;
3181
+ return this.update();
3182
+ }
3183
+ });
3184
+ var Group = createClass("Group", {
3185
+ mixins: [ShapeContainer],
3186
+ base: Shape,
3187
+ constructor() {
3188
+ this.callBase("g");
3189
+ }
3190
+ });
3191
+ var Use = createClass("Use", {
3192
+ base: Shape,
3193
+ constructor(shape) {
3194
+ this.callBase("use");
3195
+ this.ref(shape);
3196
+ },
3197
+ ref(shape) {
3198
+ if (!shape) {
3199
+ this.node.removeAttributeNS(svg.xlink, "xlink:href");
3200
+ return this;
3201
+ }
3202
+ const shapeId = shape.getId();
3203
+ if (shapeId) {
3204
+ this.node.setAttributeNS(svg.xlink, "xlink:href", "#" + shapeId);
3205
+ }
3206
+ if (shape.node.getAttribute("fill") === "none") {
3207
+ shape.node.removeAttribute("fill");
3208
+ }
3209
+ if (shape.node.getAttribute("stroke") === "none") {
3210
+ shape.node.removeAttribute("stroke");
3211
+ }
3212
+ return this;
3213
+ }
3214
+ });
3215
+ extendClass(Shape, {
3216
+ use() {
3217
+ return new Use(this);
3218
+ }
3219
+ });
3220
+ var Paper = createClass("Paper", {
3221
+ mixins: [ShapeContainer, EventHandler, Styled, ViewBox],
3222
+ constructor(container) {
3223
+ this.callBase();
3224
+ this.node = this.createSVGNode();
3225
+ this.node.paper = this;
3226
+ this.node.appendChild(this.resourceNode = svg.createNode("defs"));
3227
+ this.node.appendChild(this.shapeNode = svg.createNode("g"));
3228
+ this.resources = new Container();
3229
+ this.setWidth("100%").setHeight("100%");
3230
+ if (container) {
3231
+ this.renderTo(container);
3232
+ }
3233
+ this.callMixin();
3234
+ },
3235
+ renderTo(container) {
3236
+ if (utils_default.isString(container)) {
3237
+ container = document.getElementById(container);
3238
+ }
3239
+ this.container = container;
3240
+ container.appendChild(this.node);
3241
+ },
3242
+ createSVGNode() {
3243
+ const node = svg.createNode("svg");
3244
+ node.setAttribute("xmlns", "http://www.w3.org/2000/svg");
3245
+ node.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
3246
+ node.setAttribute("version", "1.1");
3247
+ return node;
3248
+ },
3249
+ getNode() {
3250
+ return this.node;
3251
+ },
3252
+ getContainer() {
3253
+ return this.container;
3254
+ },
3255
+ getWidth() {
3256
+ return this.node.clientWidth;
3257
+ },
3258
+ setWidth(width) {
3259
+ this.node.setAttribute("width", String(width));
3260
+ return this;
3261
+ },
3262
+ getHeight() {
3263
+ return this.node.clientHeight;
3264
+ },
3265
+ setHeight(height) {
3266
+ this.node.setAttribute("height", String(height));
3267
+ return this;
3268
+ },
3269
+ setViewPort(cx, cy, zoom) {
3270
+ let viewport, box;
3271
+ if (arguments.length === 1) {
3272
+ viewport = arguments[0];
3273
+ cx = viewport.center.x;
3274
+ cy = viewport.center.y;
3275
+ zoom = viewport.zoom;
3276
+ }
3277
+ zoom = zoom || 1;
3278
+ box = this.getViewBox();
3279
+ const matrix = new mc();
3280
+ const dx = box.x + box.width / 2 - cx;
3281
+ const dy = box.y + box.height / 2 - cy;
3282
+ matrix.translate(-cx, -cy);
3283
+ matrix.scale(zoom);
3284
+ matrix.translate(cx, cy);
3285
+ matrix.translate(dx, dy);
3286
+ this.shapeNode.setAttribute("transform", "matrix(" + matrix + ")");
3287
+ this.viewport = {
3288
+ center: { x: cx, y: cy },
3289
+ offset: { x: dx, y: dy },
3290
+ zoom
3291
+ };
3292
+ return this;
3293
+ },
3294
+ getViewPort() {
3295
+ if (!this.viewport) {
3296
+ const box = this.getViewBox();
3297
+ return {
3298
+ zoom: 1,
3299
+ center: {
3300
+ x: box.x + box.width / 2,
3301
+ y: box.y + box.height / 2
3302
+ },
3303
+ offset: { x: 0, y: 0 }
3304
+ };
3305
+ }
3306
+ return this.viewport;
3307
+ },
3308
+ getViewPortMatrix() {
3309
+ return mc.parse(this.shapeNode.getAttribute("transform"));
3310
+ },
3311
+ getViewPortTransform() {
3312
+ const m = this.shapeNode.getCTM();
3313
+ return new mc(m.a, m.b, m.c, m.d, m.e, m.f);
3314
+ },
3315
+ getTransform() {
3316
+ return this.getViewPortTransform().reverse();
3317
+ },
3318
+ addResource(resource) {
3319
+ this.resources.appendItem(resource);
3320
+ if (resource.node) {
3321
+ this.resourceNode.appendChild(resource.node);
3322
+ }
3323
+ return this;
3324
+ },
3325
+ removeResource(resource) {
3326
+ if (resource.remove) {
3327
+ resource.remove();
3328
+ }
3329
+ if (resource.node) {
3330
+ this.resourceNode.removeChild(resource.node);
3331
+ }
3332
+ return this;
3333
+ },
3334
+ getPaper() {
3335
+ return this;
3336
+ }
3337
+ });
3338
+ extendClass(Shape, {
3339
+ getPaper() {
3340
+ let parent = this.container;
3341
+ while (parent && parent instanceof Paper === false) {
3342
+ parent = parent.container;
3343
+ }
3344
+ return parent;
3345
+ },
3346
+ isAttached() {
3347
+ return !!this.getPaper();
3348
+ },
3349
+ whenPaperReady(fn) {
3350
+ const me = this;
3351
+ function check() {
3352
+ const paper = me.getPaper();
3353
+ if (paper && fn) {
3354
+ fn.call(me, paper);
3355
+ }
3356
+ return paper;
3357
+ }
3358
+ if (!check()) {
3359
+ this.on("add treeadd", function listen2() {
3360
+ if (check()) {
3361
+ me.off("add", listen2);
3362
+ me.off("treeadd", listen2);
3363
+ }
3364
+ });
3365
+ }
3366
+ return this;
3367
+ }
3368
+ });
3369
+
3370
+ // ../kity-runtime/src/kity/index.ts
3371
+ var kity = {
3372
+ version: "2.0.5",
3373
+ createClass,
3374
+ extendClass,
3375
+ Utils: utils_default,
3376
+ Class,
3377
+ Box,
3378
+ Point,
3379
+ Matrix,
3380
+ g,
3381
+ Container,
3382
+ Shape,
3383
+ ShapeContainer,
3384
+ Group,
3385
+ Rect,
3386
+ Path,
3387
+ Text,
3388
+ Paper,
3389
+ Use,
3390
+ ViewBox,
3391
+ EventHandler,
3392
+ Styled,
3393
+ Data,
3394
+ PathDrawer,
3395
+ svg
3396
+ };
3397
+ function installKityRuntime(targetWindow = window) {
3398
+ if (targetWindow.kity) {
3399
+ return;
3400
+ }
3401
+ targetWindow.kity = kity;
3402
+ }
3403
+
3404
+ // ../kity-runtime/src/perf.ts
3405
+ function getPerfHost() {
3406
+ return globalThis;
3407
+ }
3408
+ function getPerfState() {
3409
+ const host = getPerfHost();
3410
+ host.__FORMULAX_PERF_STATE__ ??= {
3411
+ reportedMeasureCount: 0,
3412
+ reportScheduled: false
3413
+ };
3414
+ return host.__FORMULAX_PERF_STATE__;
3415
+ }
3416
+ function hasPerfSupport() {
3417
+ return typeof performance !== "undefined" && typeof performance.mark === "function" && typeof performance.measure === "function" && typeof performance.getEntriesByType === "function";
3418
+ }
3419
+ function isPerfDebugEnabled() {
3420
+ return getPerfHost().__FORMULAX_PERF__ === true;
3421
+ }
3422
+ function schedulePerfReport() {
3423
+ if (!hasPerfSupport() || !isPerfDebugEnabled()) {
3424
+ return;
3425
+ }
3426
+ const state = getPerfState();
3427
+ if (state.reportScheduled) {
3428
+ return;
3429
+ }
3430
+ state.reportScheduled = true;
3431
+ queueMicrotask(() => {
3432
+ state.reportScheduled = false;
3433
+ const entries = performance.getEntriesByType("measure").filter((entry) => entry.name.startsWith("fx:")).sort((left, right) => left.startTime - right.startTime);
3434
+ const nextEntries = entries.slice(state.reportedMeasureCount);
3435
+ state.reportedMeasureCount = entries.length;
3436
+ if (!nextEntries.length) {
3437
+ return;
3438
+ }
3439
+ console.table(nextEntries.map((entry) => ({
3440
+ name: entry.name,
3441
+ duration: Number(entry.duration.toFixed(2)),
3442
+ startTime: Number(entry.startTime.toFixed(2))
3443
+ })));
3444
+ });
3445
+ }
3446
+ function markFormulaXPerf(name) {
3447
+ if (!hasPerfSupport()) {
3448
+ return null;
3449
+ }
3450
+ const markName = `${name}::${Date.now()}::${Math.random().toString(36).slice(2, 8)}`;
3451
+ performance.mark(markName);
3452
+ return markName;
3453
+ }
3454
+ function measureFormulaXPerf(name, startMark, endMark) {
3455
+ if (!hasPerfSupport() || !startMark) {
3456
+ return null;
3457
+ }
3458
+ const resolvedEndMark = endMark ?? markFormulaXPerf(`${name}:end`);
3459
+ if (!resolvedEndMark) {
3460
+ return null;
3461
+ }
3462
+ performance.measure(name, startMark, resolvedEndMark);
3463
+ schedulePerfReport();
3464
+ return resolvedEndMark;
3465
+ }
3466
+ function clearFormulaXPerfMarks(...marks) {
3467
+ if (!hasPerfSupport()) {
3468
+ return;
3469
+ }
3470
+ for (const mark of marks) {
3471
+ if (!mark) {
3472
+ continue;
3473
+ }
3474
+ performance.clearMarks(mark);
3475
+ }
3476
+ }
3477
+
3478
+ // ../kity-runtime/src/create-editor.ts
3479
+ var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
3480
+ var DEFAULT_EDITOR_HEIGHT = "auto";
3481
+ var KITY_STYLE_ID = "formulax-kity-editor-styles";
3482
+ var runtimePromise = null;
3483
+ function resolveContainer(el) {
3484
+ if (typeof el === "string") {
3485
+ const element = document.querySelector(el);
3486
+ if (!(element instanceof HTMLElement)) {
3487
+ throw new Error(`Kity editor mount target not found: ${el}`);
3488
+ }
3489
+ return element;
3490
+ }
3491
+ return el;
3492
+ }
3493
+ function normalizeCssSize(value, fallback) {
3494
+ if (typeof value === "number") {
3495
+ return `${value}px`;
3496
+ }
3497
+ return value ?? fallback;
3498
+ }
3499
+ function resolveEditorAssets(assets) {
3500
+ return {
3501
+ fonts: {
3502
+ ...kityAssetManifest.fonts,
3503
+ ...assets?.fonts
3504
+ },
3505
+ toolbar: {
3506
+ ...kityAssetManifest.toolbar,
3507
+ ...assets?.toolbar
3508
+ },
3509
+ styles: {
3510
+ ...kityAssetManifest.styles,
3511
+ ...assets?.styles
3512
+ }
3513
+ };
3514
+ }
3515
+ function ensureKityStylesheet(doc, href) {
3516
+ if (doc.getElementById(KITY_STYLE_ID)) {
3517
+ return false;
3518
+ }
3519
+ const link = doc.createElement("link");
3520
+ link.id = KITY_STYLE_ID;
3521
+ link.rel = "stylesheet";
3522
+ link.href = href;
3523
+ doc.head.appendChild(link);
3524
+ return true;
3525
+ }
3526
+ function hydrateLegacyKf(runtimeWindow) {
3527
+ const requireFormula = runtimeWindow.__kityFormulaRequire__;
3528
+ if (!requireFormula) {
3529
+ return;
3530
+ }
3531
+ runtimeWindow.kf = {
3532
+ ...runtimeWindow.kf ?? {},
3533
+ ResourceManager: requireFormula("resource-manager"),
3534
+ Operator: requireFormula("operator/operator"),
3535
+ Expression: requireFormula("expression/expression"),
3536
+ CompoundExpression: requireFormula("expression/compound"),
3537
+ TextExpression: requireFormula("expression/text"),
3538
+ EmptyExpression: requireFormula("expression/empty"),
3539
+ CombinationExpression: requireFormula("expression/compound-exp/combination"),
3540
+ FunctionExpression: requireFormula("expression/compound-exp/func"),
3541
+ FractionExpression: requireFormula("expression/compound-exp/fraction"),
3542
+ IntegrationExpression: requireFormula("expression/compound-exp/integration"),
3543
+ RadicalExpression: requireFormula("expression/compound-exp/radical"),
3544
+ ScriptExpression: requireFormula("expression/compound-exp/script"),
3545
+ SuperscriptExpression: requireFormula("expression/compound-exp/binary-exp/superscript"),
3546
+ SubscriptExpression: requireFormula("expression/compound-exp/binary-exp/subscript"),
3547
+ SummationExpression: requireFormula("expression/compound-exp/summation"),
3548
+ BracketsExpression: requireFormula("expression/compound-exp/brackets")
3549
+ };
3550
+ }
3551
+ function installLegacyRuntime(runtimeWindow) {
3552
+ runtimeWindow.__FORMULAX_KITY_RUNTIME__ = {
3553
+ baseComponent: runtimeWindow.kity ? createLegacyBaseComponent(
3554
+ runtimeWindow.kity
3555
+ ) : void 0,
3556
+ baseUtils: legacyBaseUtils,
3557
+ boxType: legacyBoxType,
3558
+ sysconf: legacySysconf,
3559
+ charPosition: legacyCharPosition,
3560
+ commonUtils: legacyCommonUtils,
3561
+ eleType: legacyEleType,
3562
+ eventListener: legacyEventListener,
3563
+ groupType: legacyGroupType,
3564
+ inputFilter: legacyInputFilter,
3565
+ itemType: legacyItemType,
3566
+ kf: runtimeWindow.kf,
3567
+ kfExtDef: legacyKfExtDef,
3568
+ kfEvent: legacyKfEvent,
3569
+ kity: runtimeWindow.kity,
3570
+ otherPosition: legacyOtherPosition,
3571
+ uiDef: legacyUiDef,
3572
+ uiUtils: legacyUiUtils
3573
+ };
3574
+ }
3575
+ async function ensureKityRuntime() {
3576
+ if (runtimePromise) {
3577
+ return runtimePromise;
3578
+ }
3579
+ runtimePromise = (async () => {
3580
+ const runtimeTotalStart = markFormulaXPerf("fx:kity-runtime:total");
3581
+ const runtimeWindow = window;
3582
+ runtimeWindow.kf = runtimeWindow.kf ?? {};
3583
+ installKityRuntime(runtimeWindow);
3584
+ try {
3585
+ const formulaImportStart = markFormulaXPerf("fx:kity-runtime:formula-import");
3586
+ const { installLegacyKityFormulaRuntime } = await import("./install-XGCSWTLU.js");
3587
+ const formulaImportEnd = markFormulaXPerf("fx:kity-runtime:formula-import:end");
3588
+ measureFormulaXPerf("fx:kity-runtime:formula-import", formulaImportStart, formulaImportEnd);
3589
+ clearFormulaXPerfMarks(formulaImportStart, formulaImportEnd);
3590
+ const formulaInstallStart = markFormulaXPerf("fx:kity-runtime:formula-install");
3591
+ installLegacyKityFormulaRuntime(runtimeWindow);
3592
+ hydrateLegacyKf(runtimeWindow);
3593
+ const formulaInstallEnd = markFormulaXPerf("fx:kity-runtime:formula-install:end");
3594
+ measureFormulaXPerf("fx:kity-runtime:formula-install", formulaInstallStart, formulaInstallEnd);
3595
+ clearFormulaXPerfMarks(formulaInstallStart, formulaInstallEnd);
3596
+ const parserImportStart = markFormulaXPerf("fx:kity-runtime:parser-import");
3597
+ const { installLegacyParserRuntime } = await import("./install-XVTKACEN.js");
3598
+ const parserImportEnd = markFormulaXPerf("fx:kity-runtime:parser-import:end");
3599
+ measureFormulaXPerf("fx:kity-runtime:parser-import", parserImportStart, parserImportEnd);
3600
+ clearFormulaXPerfMarks(parserImportStart, parserImportEnd);
3601
+ const parserInstallStart = markFormulaXPerf("fx:kity-runtime:parser-install");
3602
+ installLegacyParserRuntime(runtimeWindow);
3603
+ const parserInstallEnd = markFormulaXPerf("fx:kity-runtime:parser-install:end");
3604
+ measureFormulaXPerf("fx:kity-runtime:parser-install", parserInstallStart, parserInstallEnd);
3605
+ clearFormulaXPerfMarks(parserInstallStart, parserInstallEnd);
3606
+ installLegacyRuntime(runtimeWindow);
3607
+ const bootImportStart = markFormulaXPerf("fx:kity-runtime:boot-import");
3608
+ const { installKityEditorStart } = await import("./start-MBLTNR2Q.js");
3609
+ const bootImportEnd = markFormulaXPerf("fx:kity-runtime:boot-import:end");
3610
+ measureFormulaXPerf("fx:kity-runtime:boot-import", bootImportStart, bootImportEnd);
3611
+ clearFormulaXPerfMarks(bootImportStart, bootImportEnd);
3612
+ const bootInstallStart = markFormulaXPerf("fx:kity-runtime:boot-install");
3613
+ installKityEditorStart(runtimeWindow);
3614
+ const bootInstallEnd = markFormulaXPerf("fx:kity-runtime:boot-install:end");
3615
+ measureFormulaXPerf("fx:kity-runtime:boot-install", bootInstallStart, bootInstallEnd);
3616
+ clearFormulaXPerfMarks(bootInstallStart, bootInstallEnd);
3617
+ } finally {
3618
+ const runtimeTotalEnd = markFormulaXPerf("fx:kity-runtime:total:end");
3619
+ measureFormulaXPerf("fx:kity-runtime:total", runtimeTotalStart, runtimeTotalEnd);
3620
+ clearFormulaXPerfMarks(runtimeTotalStart, runtimeTotalEnd);
3621
+ }
3622
+ })();
3623
+ return runtimePromise;
3624
+ }
3625
+ async function createKityEditor(container, options = {}) {
3626
+ const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
3627
+ const fontsize = options.render?.fontsize ?? 40;
3628
+ const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
3629
+ const locale = normalizeFormulaXLocale(options.locale ?? DEFAULT_FORMULAX_LOCALE);
3630
+ const assets = resolveEditorAssets(options.assets);
3631
+ try {
3632
+ legacySysconf.rootPlaceholder.content = getFormulaXRuntimeMessage("editor.placeholder.root", locale);
3633
+ const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
3634
+ if (stylesheetInserted) {
3635
+ const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
3636
+ measureFormulaXPerf("fx:kity-css:link-inserted", createEditorStart, stylesheetInsertedMark);
3637
+ clearFormulaXPerfMarks(stylesheetInsertedMark);
3638
+ }
3639
+ setToolbarAssetUrls(assets.toolbar);
3640
+ await ensureKityRuntime();
3641
+ const runtimeReadyMark = markFormulaXPerf("fx:kity-runtime:ready-for-editor");
3642
+ measureFormulaXPerf("fx:kity-runtime:ready-for-editor", createEditorStart, runtimeReadyMark);
3643
+ clearFormulaXPerfMarks(runtimeReadyMark);
3644
+ const runtimeWindow = window;
3645
+ if (!runtimeWindow.kf?.EditorFactory) {
3646
+ throw new Error("Kity editor runtime did not initialize");
3647
+ }
3648
+ container.innerHTML = "";
3649
+ const host = document.createElement("div");
3650
+ host.className = "kf-editor";
3651
+ host.style.width = "100%";
3652
+ host.style.height = editorHeight;
3653
+ container.appendChild(host);
3654
+ const factoryCreateStart = markFormulaXPerf("fx:kity-editor-factory:create");
3655
+ const factory = runtimeWindow.kf.EditorFactory.create(host, {
3656
+ render: {
3657
+ fontsize
3658
+ },
3659
+ ui: {
3660
+ locale
3661
+ },
3662
+ resource: {
3663
+ path: "",
3664
+ fonts: assets.fonts
3665
+ }
3666
+ });
3667
+ const factoryCreateEnd = markFormulaXPerf("fx:kity-editor-factory:create:end");
3668
+ measureFormulaXPerf("fx:kity-editor-factory:create", factoryCreateStart, factoryCreateEnd);
3669
+ clearFormulaXPerfMarks(factoryCreateStart, factoryCreateEnd);
3670
+ return {
3671
+ ready: factory.ready.bind(factory),
3672
+ execCommand(name, value) {
3673
+ factory.ready(function execWhenReady() {
3674
+ this.execCommand(name, value);
3675
+ });
3676
+ },
3677
+ focus() {
3678
+ factory.ready(function focusWhenReady() {
3679
+ this.execCommand("focus");
3680
+ });
3681
+ },
3682
+ destroy() {
3683
+ container.innerHTML = "";
3684
+ },
3685
+ host,
3686
+ raw: factory
3687
+ };
3688
+ } finally {
3689
+ const createEditorEnd = markFormulaXPerf("fx:create-kity-editor:total:end");
3690
+ measureFormulaXPerf("fx:create-kity-editor:total", createEditorStart, createEditorEnd);
3691
+ clearFormulaXPerfMarks(createEditorStart, createEditorEnd);
3692
+ }
3693
+ }
3694
+ async function mountKityEditor(container, options = {}) {
3695
+ const editor = await createKityEditor(container, options);
3696
+ const initialLatex = options.initialLatex ?? DEFAULT_LATEX;
3697
+ const shouldFocus = options.autofocus ?? true;
3698
+ editor.ready(function ready() {
3699
+ this.execCommand("render", initialLatex);
3700
+ if (shouldFocus) {
3701
+ this.execCommand("focus");
3702
+ }
3703
+ });
3704
+ return editor;
3705
+ }
3706
+ var FormulaXEditor = class {
3707
+ container;
3708
+ options;
3709
+ handlePromise;
3710
+ constructor(options) {
3711
+ const { el, ...editorOptions } = options;
3712
+ this.container = resolveContainer(el);
3713
+ this.options = editorOptions;
3714
+ this.handlePromise = mountKityEditor(this.container, this.options);
3715
+ }
3716
+ ready(callback) {
3717
+ void this.handlePromise.then((handle) => handle.ready(callback));
3718
+ return this;
3719
+ }
3720
+ async execCommand(name, value) {
3721
+ const handle = await this.handlePromise;
3722
+ handle.execCommand(name, value);
3723
+ return this;
3724
+ }
3725
+ async focus() {
3726
+ const handle = await this.handlePromise;
3727
+ handle.focus();
3728
+ return this;
3729
+ }
3730
+ async destroy() {
3731
+ const handle = await this.handlePromise;
3732
+ handle.destroy();
3733
+ }
3734
+ async getHandle() {
3735
+ return this.handlePromise;
3736
+ }
3737
+ };
3738
+ if (typeof window !== "undefined") {
3739
+ window.FormulaXEditor = FormulaXEditor;
3740
+ }
3741
+
3742
+ // src/index.ts
3
3743
  import { parseLatex, serializeLatex } from "@formulaxjs/core";
4
3744
  import {
5
3745
  createFormulaElement,
@@ -9,14 +3749,18 @@ import {
9
3749
  getFormulaLatexFromElement
10
3750
  } from "@formulaxjs/renderer";
11
3751
  import { createKityFormulaRenderer } from "@formulaxjs/renderer-kity";
12
- import { ensureFormulaXModalStyles as ensureFormulaXModalStyles2, scheduleFormulaXEditorPreload } from "@formulaxjs/editor";
3752
+ import {
3753
+ ensureFormulaXModalStyles as ensureFormulaXModalStyles2,
3754
+ getFormulaXEditorMessage,
3755
+ scheduleFormulaXEditorPreload
3756
+ } from "@formulaxjs/editor";
13
3757
 
14
3758
  // src/modal.ts
15
3759
  import {
16
- clearFormulaXPerfMarks,
3760
+ clearFormulaXPerfMarks as clearFormulaXPerfMarks2,
17
3761
  ensureFormulaXModalStyles,
18
- markFormulaXPerf,
19
- measureFormulaXPerf,
3762
+ markFormulaXPerf as markFormulaXPerf2,
3763
+ measureFormulaXPerf as measureFormulaXPerf2,
20
3764
  mountFormulaXEditor,
21
3765
  recordFormulaXPerfPoint,
22
3766
  renderFormulaXEditorLoadingState,
@@ -28,7 +3772,7 @@ import {
28
3772
  } from "@formulaxjs/renderer";
29
3773
  function openFormulaXTiptapModal(input) {
30
3774
  recordFormulaXPerfPoint("fx:modal:open:start");
31
- const modalOpenStart = markFormulaXPerf("fx:modal:open:start:scope");
3775
+ const modalOpenStart = markFormulaXPerf2("fx:modal:open:start:scope");
32
3776
  ensureFormulaXModalStyles(document);
33
3777
  const root = document.createElement("div");
34
3778
  root.className = "fx-formula-modal-root";
@@ -52,13 +3796,13 @@ function openFormulaXTiptapModal(input) {
52
3796
  `;
53
3797
  document.body.appendChild(root);
54
3798
  document.body.classList.add("fx-formula-modal-open");
55
- const modalDomReadyMark = markFormulaXPerf("fx:modal:dom-ready");
56
- measureFormulaXPerf("fx:modal:dom-ready", modalOpenStart, modalDomReadyMark);
57
- clearFormulaXPerfMarks(modalDomReadyMark);
3799
+ const modalDomReadyMark = markFormulaXPerf2("fx:modal:dom-ready");
3800
+ measureFormulaXPerf2("fx:modal:dom-ready", modalOpenStart, modalDomReadyMark);
3801
+ clearFormulaXPerfMarks2(modalDomReadyMark);
58
3802
  const host = root.querySelector(".fx-formula-editor-host");
59
3803
  if (!host) {
60
3804
  root.remove();
61
- clearFormulaXPerfMarks(modalOpenStart);
3805
+ clearFormulaXPerfMarks2(modalOpenStart);
62
3806
  return Promise.reject(new Error("[FormulaX] Tiptap modal host not found."));
63
3807
  }
64
3808
  renderFormulaXEditorLoadingState(host);
@@ -66,25 +3810,26 @@ function openFormulaXTiptapModal(input) {
66
3810
  let mounted = null;
67
3811
  const mountedPromise = waitForFormulaXAnimationFrame().then(() => {
68
3812
  if (closed) {
69
- clearFormulaXPerfMarks(modalOpenStart);
3813
+ clearFormulaXPerfMarks2(modalOpenStart);
70
3814
  return null;
71
3815
  }
72
- const mountStartMark = markFormulaXPerf("fx:modal:editor-mount-start");
73
- measureFormulaXPerf("fx:modal:editor-mount-start", modalOpenStart, mountStartMark);
74
- clearFormulaXPerfMarks(mountStartMark);
3816
+ const mountStartMark = markFormulaXPerf2("fx:modal:editor-mount-start");
3817
+ measureFormulaXPerf2("fx:modal:editor-mount-start", modalOpenStart, mountStartMark);
3818
+ clearFormulaXPerfMarks2(mountStartMark);
75
3819
  const nextMounted = mountFormulaXEditor(host, {
76
3820
  initialLatex: input.initialLatex,
77
3821
  height: input.options.editor.height,
78
3822
  autofocus: input.options.editor.autofocus,
3823
+ locale: input.options.editor.locale,
79
3824
  assets: input.options.editor.assets,
80
3825
  render: {
81
3826
  fontsize: input.options.editor.render.fontsize
82
3827
  }
83
3828
  });
84
3829
  mounted = nextMounted;
85
- const mountedMark = markFormulaXPerf("fx:modal:editor-mounted");
86
- measureFormulaXPerf("fx:modal:editor-mounted", modalOpenStart, mountedMark);
87
- clearFormulaXPerfMarks(mountedMark, modalOpenStart);
3830
+ const mountedMark = markFormulaXPerf2("fx:modal:editor-mounted");
3831
+ measureFormulaXPerf2("fx:modal:editor-mounted", modalOpenStart, mountedMark);
3832
+ clearFormulaXPerfMarks2(mountedMark, modalOpenStart);
88
3833
  queueMicrotask(() => {
89
3834
  if (!closed) {
90
3835
  nextMounted.root.focus();
@@ -92,7 +3837,7 @@ function openFormulaXTiptapModal(input) {
92
3837
  });
93
3838
  return nextMounted;
94
3839
  }).catch((error) => {
95
- clearFormulaXPerfMarks(modalOpenStart);
3840
+ clearFormulaXPerfMarks2(modalOpenStart);
96
3841
  throw error;
97
3842
  });
98
3843
  return new Promise((resolve) => {
@@ -156,6 +3901,7 @@ function openFormulaXTiptapModal(input) {
156
3901
  // src/index.ts
157
3902
  var FORMULAX_NODE_NAME = "formulaX";
158
3903
  function resolveOptions(options = {}) {
3904
+ const locale = options.editor?.locale ?? DEFAULT_FORMULAX_LOCALE;
159
3905
  return {
160
3906
  name: options.name ?? FORMULAX_NODE_NAME,
161
3907
  formulaClassName: options.formulaClassName ?? DEFAULT_FORMULA_CLASS,
@@ -169,15 +3915,16 @@ function resolveOptions(options = {}) {
169
3915
  }),
170
3916
  preload: options.preload ?? "idle",
171
3917
  modal: {
172
- title: options.modal?.title ?? "FormulaX Editor",
173
- insertText: options.modal?.insertText ?? "Insert",
174
- updateText: options.modal?.updateText ?? "Update",
175
- cancelText: options.modal?.cancelText ?? "Cancel",
3918
+ title: options.modal?.title ?? getFormulaXEditorMessage("modal.title", locale),
3919
+ insertText: options.modal?.insertText ?? getFormulaXEditorMessage("modal.insert", locale),
3920
+ updateText: options.modal?.updateText ?? getFormulaXEditorMessage("modal.update", locale),
3921
+ cancelText: options.modal?.cancelText ?? getFormulaXEditorMessage("modal.cancel", locale),
176
3922
  closeOnBackdrop: options.modal?.closeOnBackdrop ?? true
177
3923
  },
178
3924
  editor: {
179
3925
  height: options.editor?.height ?? "100%",
180
3926
  autofocus: options.editor?.autofocus ?? true,
3927
+ locale,
181
3928
  assets: options.editor?.assets ?? {},
182
3929
  render: {
183
3930
  fontsize: options.editor?.render?.fontsize ?? 40