@leafer-ui/draw 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/draw.cjs CHANGED
@@ -31,36 +31,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
31
31
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
32
  };
33
33
 
34
- const TextConvert = {};
35
- const ColorConvert = {};
36
- const PathArrow = {};
37
- const Paint = {};
38
- const PaintImage = {};
39
- const PaintGradient = {};
40
- const Effect = {};
41
- const Export = {};
42
- const State = {};
43
-
44
- function stateType(defaultValue) {
45
- return core.decorateLeafAttr(defaultValue, (key) => core.attr({
46
- set(value) {
47
- this.__setAttr(key, value);
48
- this.waitLeafer(() => { if (State.setStyle)
49
- State.setStyle(this, key + 'Style', value); });
50
- }
51
- }));
52
- }
53
- function arrowType(defaultValue) {
54
- return core.decorateLeafAttr(defaultValue, (key) => core.attr({
55
- set(value) {
56
- if (this.__setAttr(key, value)) {
57
- const data = this.__;
58
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
59
- core.doStrokeType(this);
60
- }
61
- }
62
- }));
63
- }
64
34
  function effectType(defaultValue) {
65
35
  return core.decorateLeafAttr(defaultValue, (key) => core.attr({
66
36
  set(value) {
@@ -95,10 +65,33 @@ function zoomLayerType() {
95
65
  };
96
66
  }
97
67
 
68
+ const TextConvert = {};
69
+ const ColorConvert = {};
70
+ const PathArrow = {};
71
+ const Paint = {};
72
+ const PaintImage = {};
73
+ const PaintGradient = {};
74
+ const Effect = {};
75
+ const Export = {};
76
+ const State = {
77
+ setStyleName(_leaf, _styleName, _value) { return core.needPlugin('state'); },
78
+ set(_leaf, _stateName) { return core.needPlugin('state'); }
79
+ };
80
+ const Transition = {
81
+ list: {},
82
+ register(attrName, fn) {
83
+ Transition.list[attrName] = fn;
84
+ },
85
+ get(attrName) {
86
+ return Transition.list[attrName];
87
+ }
88
+ };
89
+
98
90
  const { parse } = core.PathConvert;
99
91
  const emptyPaint = {};
100
92
  const debug$1 = core.Debug.get('UIData');
101
93
  class UIData extends core.LeafData {
94
+ get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
102
95
  get __strokeWidth() {
103
96
  const { strokeWidth, strokeWidthFixed } = this;
104
97
  if (strokeWidthFixed) {
@@ -117,9 +110,10 @@ class UIData extends core.LeafData {
117
110
  get __autoSide() { return !this._width || !this._height; }
118
111
  get __autoSize() { return !this._width && !this._height; }
119
112
  setVisible(value) {
120
- if (this.__leaf.leafer)
121
- this.__leaf.leafer.watcher.hasVisible = true;
122
113
  this._visible = value;
114
+ const { leafer } = this.__leaf;
115
+ if (leafer)
116
+ leafer.watcher.hasVisible = true;
123
117
  }
124
118
  setWidth(value) {
125
119
  if (value < 0) {
@@ -310,7 +304,7 @@ class ImageData extends RectData {
310
304
  __setImageFill(value) {
311
305
  if (this.__leaf.image)
312
306
  this.__leaf.image = null;
313
- this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
307
+ this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
314
308
  }
315
309
  __getData() {
316
310
  const data = super.__getData();
@@ -500,19 +494,8 @@ var UI_1;
500
494
  exports.UI = UI_1 = class UI extends core.Leaf {
501
495
  get app() { return this.leafer && this.leafer.app; }
502
496
  get isFrame() { return false; }
503
- set scale(value) {
504
- if (typeof value === 'number') {
505
- this.scaleX = this.scaleY = value;
506
- }
507
- else {
508
- this.scaleX = value.x;
509
- this.scaleY = value.y;
510
- }
511
- }
512
- get scale() {
513
- const { scaleX, scaleY } = this;
514
- return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
515
- }
497
+ set scale(value) { core.MathHelper.assignScale(this, value); }
498
+ get scale() { return this.__.scale; }
516
499
  get pen() {
517
500
  const { path } = this.__;
518
501
  core.pen.set(this.path = path || []);
@@ -527,8 +510,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
527
510
  super(data);
528
511
  }
529
512
  reset(_data) { }
530
- set(data) {
531
- Object.assign(this, data);
513
+ set(data, isTemp) {
514
+ if (isTemp) {
515
+ this.lockNormalStyle = true;
516
+ Object.assign(this, data);
517
+ this.lockNormalStyle = false;
518
+ }
519
+ else {
520
+ Object.assign(this, data);
521
+ }
532
522
  }
533
523
  get(name) {
534
524
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -591,11 +581,18 @@ exports.UI = UI_1 = class UI extends core.Leaf {
591
581
  drawer.rect(x, y, width, height);
592
582
  }
593
583
  }
584
+ animate(_keyframe, _options, _type, _isTemp) {
585
+ return core.needPlugin('animate');
586
+ }
587
+ killAnimate(_type) { }
594
588
  export(filename, options) {
595
589
  return Export.export(this, filename, options);
596
590
  }
597
- clone() {
598
- return UI_1.one(this.toJSON());
591
+ clone(data) {
592
+ const json = this.toJSON();
593
+ if (data)
594
+ Object.assign(json, data);
595
+ return UI_1.one(json);
599
596
  }
600
597
  static one(data, x, y, width, height) {
601
598
  return core.UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
@@ -611,6 +608,8 @@ exports.UI = UI_1 = class UI extends core.Leaf {
611
608
  static setEditInner(_editorName) { }
612
609
  destroy() {
613
610
  this.fill = this.stroke = null;
611
+ if (this.__animate)
612
+ this.killAnimate();
614
613
  super.destroy();
615
614
  }
616
615
  };
@@ -638,12 +637,6 @@ __decorate([
638
637
  __decorate([
639
638
  core.visibleType(true)
640
639
  ], exports.UI.prototype, "visible", void 0);
641
- __decorate([
642
- stateType(false)
643
- ], exports.UI.prototype, "selected", void 0);
644
- __decorate([
645
- stateType(false)
646
- ], exports.UI.prototype, "disabled", void 0);
647
640
  __decorate([
648
641
  core.surfaceType(false)
649
642
  ], exports.UI.prototype, "locked", void 0);
@@ -716,45 +709,9 @@ __decorate([
716
709
  __decorate([
717
710
  core.pathType(true)
718
711
  ], exports.UI.prototype, "closed", void 0);
719
- __decorate([
720
- core.autoLayoutType(false)
721
- ], exports.UI.prototype, "flow", void 0);
722
712
  __decorate([
723
713
  core.boundsType(0)
724
714
  ], exports.UI.prototype, "padding", void 0);
725
- __decorate([
726
- core.boundsType(0)
727
- ], exports.UI.prototype, "gap", void 0);
728
- __decorate([
729
- core.boundsType('top-left')
730
- ], exports.UI.prototype, "flowAlign", void 0);
731
- __decorate([
732
- core.boundsType(false)
733
- ], exports.UI.prototype, "flowWrap", void 0);
734
- __decorate([
735
- core.boundsType('box')
736
- ], exports.UI.prototype, "itemBox", void 0);
737
- __decorate([
738
- core.boundsType(true)
739
- ], exports.UI.prototype, "inFlow", void 0);
740
- __decorate([
741
- core.boundsType()
742
- ], exports.UI.prototype, "autoWidth", void 0);
743
- __decorate([
744
- core.boundsType()
745
- ], exports.UI.prototype, "autoHeight", void 0);
746
- __decorate([
747
- core.boundsType()
748
- ], exports.UI.prototype, "lockRatio", void 0);
749
- __decorate([
750
- core.boundsType()
751
- ], exports.UI.prototype, "autoBox", void 0);
752
- __decorate([
753
- core.boundsType()
754
- ], exports.UI.prototype, "widthRange", void 0);
755
- __decorate([
756
- core.boundsType()
757
- ], exports.UI.prototype, "heightRange", void 0);
758
715
  __decorate([
759
716
  core.dataType(false)
760
717
  ], exports.UI.prototype, "draggable", void 0);
@@ -818,12 +775,6 @@ __decorate([
818
775
  __decorate([
819
776
  core.strokeType(10)
820
777
  ], exports.UI.prototype, "miterLimit", void 0);
821
- __decorate([
822
- arrowType('none')
823
- ], exports.UI.prototype, "startArrow", void 0);
824
- __decorate([
825
- arrowType('none')
826
- ], exports.UI.prototype, "endArrow", void 0);
827
778
  __decorate([
828
779
  core.pathType(0)
829
780
  ], exports.UI.prototype, "cornerRadius", void 0);
@@ -845,24 +796,6 @@ __decorate([
845
796
  __decorate([
846
797
  effectType()
847
798
  ], exports.UI.prototype, "grayscale", void 0);
848
- __decorate([
849
- core.dataType()
850
- ], exports.UI.prototype, "normalStyle", void 0);
851
- __decorate([
852
- core.dataType()
853
- ], exports.UI.prototype, "hoverStyle", void 0);
854
- __decorate([
855
- core.dataType()
856
- ], exports.UI.prototype, "pressStyle", void 0);
857
- __decorate([
858
- core.dataType()
859
- ], exports.UI.prototype, "focusStyle", void 0);
860
- __decorate([
861
- core.dataType()
862
- ], exports.UI.prototype, "selectedStyle", void 0);
863
- __decorate([
864
- core.dataType()
865
- ], exports.UI.prototype, "disabledStyle", void 0);
866
799
  __decorate([
867
800
  core.dataType({})
868
801
  ], exports.UI.prototype, "data", void 0);
@@ -889,7 +822,7 @@ exports.Group = class Group extends exports.UI {
889
822
  if (!this.children)
890
823
  this.children = [];
891
824
  }
892
- set(data) {
825
+ set(data, isTemp) {
893
826
  if (data.children) {
894
827
  const { children } = data;
895
828
  delete data.children;
@@ -899,7 +832,7 @@ exports.Group = class Group extends exports.UI {
899
832
  else {
900
833
  this.clear();
901
834
  }
902
- super.set(data);
835
+ super.set(data, isTemp);
903
836
  let child;
904
837
  children.forEach(childData => {
905
838
  child = childData.__ ? childData : core.UICreator.get(childData.tag, childData);
@@ -908,7 +841,7 @@ exports.Group = class Group extends exports.UI {
908
841
  data.children = children;
909
842
  }
910
843
  else {
911
- super.set(data);
844
+ super.set(data, isTemp);
912
845
  }
913
846
  }
914
847
  toJSON(options) {
@@ -1235,7 +1168,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
1235
1168
  }
1236
1169
  }
1237
1170
  zoom(_zoomType, _padding, _fixedScale) {
1238
- return debug.error('need @leafer-in/view');
1171
+ return core.needPlugin('view');
1239
1172
  }
1240
1173
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
1241
1174
  getValidScale(changeScale) { return changeScale; }
@@ -1758,19 +1691,18 @@ exports.Canvas = class Canvas extends exports.Rect {
1758
1691
  this.paint();
1759
1692
  }
1760
1693
  paint() {
1761
- this.forceUpdate('fill');
1694
+ this.forceRender();
1762
1695
  }
1763
1696
  __drawAfterFill(canvas, _options) {
1764
- const origin = this.canvas.view;
1765
- const { width, height } = this;
1766
- if (this.__.cornerRadius || this.pathInputed) {
1697
+ const { width, height, cornerRadius } = this.__, { view } = this.canvas;
1698
+ if (cornerRadius || this.pathInputed) {
1767
1699
  canvas.save();
1768
1700
  canvas.clip();
1769
- canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
1701
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
1770
1702
  canvas.restore();
1771
1703
  }
1772
1704
  else {
1773
- canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
1705
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
1774
1706
  }
1775
1707
  }
1776
1708
  __updateSize() {
@@ -2070,14 +2002,13 @@ exports.StarData = StarData;
2070
2002
  exports.State = State;
2071
2003
  exports.TextConvert = TextConvert;
2072
2004
  exports.TextData = TextData;
2005
+ exports.Transition = Transition;
2073
2006
  exports.UIBounds = UIBounds;
2074
2007
  exports.UIData = UIData;
2075
2008
  exports.UIRender = UIRender;
2076
2009
  exports.UnitConvert = UnitConvert;
2077
- exports.arrowType = arrowType;
2078
2010
  exports.effectType = effectType;
2079
2011
  exports.resizeType = resizeType;
2080
- exports.stateType = stateType;
2081
2012
  exports.zoomLayerType = zoomLayerType;
2082
2013
  Object.keys(core).forEach(function (k) {
2083
2014
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
package/lib/draw.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { decorateLeafAttr, attr, doStrokeType, defineKey, Debug, LeafData, PathConvert, canvasSizeAttrs, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, pen, PathCorner, PathDrawer, UICreator, registerUI, Branch, LeafList, ImageManager, DataHelper, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, affectRenderBoundsType, BoundsHelper, Platform, PathCommandDataHelper, affectStrokeBoundsType, getPointData, PointHelper, PathBounds, ImageEvent, LeaferImage, Matrix, MathHelper, PathCreator } from '@leafer/core';
1
+ import { decorateLeafAttr, attr, defineKey, needPlugin, Debug, LeafData, PathConvert, canvasSizeAttrs, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, UICreator, registerUI, Branch, LeafList, ImageManager, DataHelper, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, affectRenderBoundsType, BoundsHelper, Platform, PathCommandDataHelper, affectStrokeBoundsType, getPointData, PointHelper, PathBounds, ImageEvent, LeaferImage, Matrix, PathCreator } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -30,36 +30,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
30
30
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
31
  };
32
32
 
33
- const TextConvert = {};
34
- const ColorConvert = {};
35
- const PathArrow = {};
36
- const Paint = {};
37
- const PaintImage = {};
38
- const PaintGradient = {};
39
- const Effect = {};
40
- const Export = {};
41
- const State = {};
42
-
43
- function stateType(defaultValue) {
44
- return decorateLeafAttr(defaultValue, (key) => attr({
45
- set(value) {
46
- this.__setAttr(key, value);
47
- this.waitLeafer(() => { if (State.setStyle)
48
- State.setStyle(this, key + 'Style', value); });
49
- }
50
- }));
51
- }
52
- function arrowType(defaultValue) {
53
- return decorateLeafAttr(defaultValue, (key) => attr({
54
- set(value) {
55
- if (this.__setAttr(key, value)) {
56
- const data = this.__;
57
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
58
- doStrokeType(this);
59
- }
60
- }
61
- }));
62
- }
63
33
  function effectType(defaultValue) {
64
34
  return decorateLeafAttr(defaultValue, (key) => attr({
65
35
  set(value) {
@@ -94,10 +64,33 @@ function zoomLayerType() {
94
64
  };
95
65
  }
96
66
 
67
+ const TextConvert = {};
68
+ const ColorConvert = {};
69
+ const PathArrow = {};
70
+ const Paint = {};
71
+ const PaintImage = {};
72
+ const PaintGradient = {};
73
+ const Effect = {};
74
+ const Export = {};
75
+ const State = {
76
+ setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
77
+ set(_leaf, _stateName) { return needPlugin('state'); }
78
+ };
79
+ const Transition = {
80
+ list: {},
81
+ register(attrName, fn) {
82
+ Transition.list[attrName] = fn;
83
+ },
84
+ get(attrName) {
85
+ return Transition.list[attrName];
86
+ }
87
+ };
88
+
97
89
  const { parse } = PathConvert;
98
90
  const emptyPaint = {};
99
91
  const debug$1 = Debug.get('UIData');
100
92
  class UIData extends LeafData {
93
+ get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
101
94
  get __strokeWidth() {
102
95
  const { strokeWidth, strokeWidthFixed } = this;
103
96
  if (strokeWidthFixed) {
@@ -116,9 +109,10 @@ class UIData extends LeafData {
116
109
  get __autoSide() { return !this._width || !this._height; }
117
110
  get __autoSize() { return !this._width && !this._height; }
118
111
  setVisible(value) {
119
- if (this.__leaf.leafer)
120
- this.__leaf.leafer.watcher.hasVisible = true;
121
112
  this._visible = value;
113
+ const { leafer } = this.__leaf;
114
+ if (leafer)
115
+ leafer.watcher.hasVisible = true;
122
116
  }
123
117
  setWidth(value) {
124
118
  if (value < 0) {
@@ -309,7 +303,7 @@ class ImageData extends RectData {
309
303
  __setImageFill(value) {
310
304
  if (this.__leaf.image)
311
305
  this.__leaf.image = null;
312
- this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
306
+ this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
313
307
  }
314
308
  __getData() {
315
309
  const data = super.__getData();
@@ -499,19 +493,8 @@ var UI_1;
499
493
  let UI = UI_1 = class UI extends Leaf {
500
494
  get app() { return this.leafer && this.leafer.app; }
501
495
  get isFrame() { return false; }
502
- set scale(value) {
503
- if (typeof value === 'number') {
504
- this.scaleX = this.scaleY = value;
505
- }
506
- else {
507
- this.scaleX = value.x;
508
- this.scaleY = value.y;
509
- }
510
- }
511
- get scale() {
512
- const { scaleX, scaleY } = this;
513
- return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
514
- }
496
+ set scale(value) { MathHelper.assignScale(this, value); }
497
+ get scale() { return this.__.scale; }
515
498
  get pen() {
516
499
  const { path } = this.__;
517
500
  pen.set(this.path = path || []);
@@ -526,8 +509,15 @@ let UI = UI_1 = class UI extends Leaf {
526
509
  super(data);
527
510
  }
528
511
  reset(_data) { }
529
- set(data) {
530
- Object.assign(this, data);
512
+ set(data, isTemp) {
513
+ if (isTemp) {
514
+ this.lockNormalStyle = true;
515
+ Object.assign(this, data);
516
+ this.lockNormalStyle = false;
517
+ }
518
+ else {
519
+ Object.assign(this, data);
520
+ }
531
521
  }
532
522
  get(name) {
533
523
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
@@ -590,11 +580,18 @@ let UI = UI_1 = class UI extends Leaf {
590
580
  drawer.rect(x, y, width, height);
591
581
  }
592
582
  }
583
+ animate(_keyframe, _options, _type, _isTemp) {
584
+ return needPlugin('animate');
585
+ }
586
+ killAnimate(_type) { }
593
587
  export(filename, options) {
594
588
  return Export.export(this, filename, options);
595
589
  }
596
- clone() {
597
- return UI_1.one(this.toJSON());
590
+ clone(data) {
591
+ const json = this.toJSON();
592
+ if (data)
593
+ Object.assign(json, data);
594
+ return UI_1.one(json);
598
595
  }
599
596
  static one(data, x, y, width, height) {
600
597
  return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height);
@@ -610,6 +607,8 @@ let UI = UI_1 = class UI extends Leaf {
610
607
  static setEditInner(_editorName) { }
611
608
  destroy() {
612
609
  this.fill = this.stroke = null;
610
+ if (this.__animate)
611
+ this.killAnimate();
613
612
  super.destroy();
614
613
  }
615
614
  };
@@ -637,12 +636,6 @@ __decorate([
637
636
  __decorate([
638
637
  visibleType(true)
639
638
  ], UI.prototype, "visible", void 0);
640
- __decorate([
641
- stateType(false)
642
- ], UI.prototype, "selected", void 0);
643
- __decorate([
644
- stateType(false)
645
- ], UI.prototype, "disabled", void 0);
646
639
  __decorate([
647
640
  surfaceType(false)
648
641
  ], UI.prototype, "locked", void 0);
@@ -715,45 +708,9 @@ __decorate([
715
708
  __decorate([
716
709
  pathType(true)
717
710
  ], UI.prototype, "closed", void 0);
718
- __decorate([
719
- autoLayoutType(false)
720
- ], UI.prototype, "flow", void 0);
721
711
  __decorate([
722
712
  boundsType(0)
723
713
  ], UI.prototype, "padding", void 0);
724
- __decorate([
725
- boundsType(0)
726
- ], UI.prototype, "gap", void 0);
727
- __decorate([
728
- boundsType('top-left')
729
- ], UI.prototype, "flowAlign", void 0);
730
- __decorate([
731
- boundsType(false)
732
- ], UI.prototype, "flowWrap", void 0);
733
- __decorate([
734
- boundsType('box')
735
- ], UI.prototype, "itemBox", void 0);
736
- __decorate([
737
- boundsType(true)
738
- ], UI.prototype, "inFlow", void 0);
739
- __decorate([
740
- boundsType()
741
- ], UI.prototype, "autoWidth", void 0);
742
- __decorate([
743
- boundsType()
744
- ], UI.prototype, "autoHeight", void 0);
745
- __decorate([
746
- boundsType()
747
- ], UI.prototype, "lockRatio", void 0);
748
- __decorate([
749
- boundsType()
750
- ], UI.prototype, "autoBox", void 0);
751
- __decorate([
752
- boundsType()
753
- ], UI.prototype, "widthRange", void 0);
754
- __decorate([
755
- boundsType()
756
- ], UI.prototype, "heightRange", void 0);
757
714
  __decorate([
758
715
  dataType(false)
759
716
  ], UI.prototype, "draggable", void 0);
@@ -817,12 +774,6 @@ __decorate([
817
774
  __decorate([
818
775
  strokeType(10)
819
776
  ], UI.prototype, "miterLimit", void 0);
820
- __decorate([
821
- arrowType('none')
822
- ], UI.prototype, "startArrow", void 0);
823
- __decorate([
824
- arrowType('none')
825
- ], UI.prototype, "endArrow", void 0);
826
777
  __decorate([
827
778
  pathType(0)
828
779
  ], UI.prototype, "cornerRadius", void 0);
@@ -844,24 +795,6 @@ __decorate([
844
795
  __decorate([
845
796
  effectType()
846
797
  ], UI.prototype, "grayscale", void 0);
847
- __decorate([
848
- dataType()
849
- ], UI.prototype, "normalStyle", void 0);
850
- __decorate([
851
- dataType()
852
- ], UI.prototype, "hoverStyle", void 0);
853
- __decorate([
854
- dataType()
855
- ], UI.prototype, "pressStyle", void 0);
856
- __decorate([
857
- dataType()
858
- ], UI.prototype, "focusStyle", void 0);
859
- __decorate([
860
- dataType()
861
- ], UI.prototype, "selectedStyle", void 0);
862
- __decorate([
863
- dataType()
864
- ], UI.prototype, "disabledStyle", void 0);
865
798
  __decorate([
866
799
  dataType({})
867
800
  ], UI.prototype, "data", void 0);
@@ -888,7 +821,7 @@ let Group = class Group extends UI {
888
821
  if (!this.children)
889
822
  this.children = [];
890
823
  }
891
- set(data) {
824
+ set(data, isTemp) {
892
825
  if (data.children) {
893
826
  const { children } = data;
894
827
  delete data.children;
@@ -898,7 +831,7 @@ let Group = class Group extends UI {
898
831
  else {
899
832
  this.clear();
900
833
  }
901
- super.set(data);
834
+ super.set(data, isTemp);
902
835
  let child;
903
836
  children.forEach(childData => {
904
837
  child = childData.__ ? childData : UICreator.get(childData.tag, childData);
@@ -907,7 +840,7 @@ let Group = class Group extends UI {
907
840
  data.children = children;
908
841
  }
909
842
  else {
910
- super.set(data);
843
+ super.set(data, isTemp);
911
844
  }
912
845
  }
913
846
  toJSON(options) {
@@ -1234,7 +1167,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1234
1167
  }
1235
1168
  }
1236
1169
  zoom(_zoomType, _padding, _fixedScale) {
1237
- return debug.error('need @leafer-in/view');
1170
+ return needPlugin('view');
1238
1171
  }
1239
1172
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
1240
1173
  getValidScale(changeScale) { return changeScale; }
@@ -1757,19 +1690,18 @@ let Canvas = class Canvas extends Rect {
1757
1690
  this.paint();
1758
1691
  }
1759
1692
  paint() {
1760
- this.forceUpdate('fill');
1693
+ this.forceRender();
1761
1694
  }
1762
1695
  __drawAfterFill(canvas, _options) {
1763
- const origin = this.canvas.view;
1764
- const { width, height } = this;
1765
- if (this.__.cornerRadius || this.pathInputed) {
1696
+ const { width, height, cornerRadius } = this.__, { view } = this.canvas;
1697
+ if (cornerRadius || this.pathInputed) {
1766
1698
  canvas.save();
1767
1699
  canvas.clip();
1768
- canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
1700
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
1769
1701
  canvas.restore();
1770
1702
  }
1771
1703
  else {
1772
- canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
1704
+ canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
1773
1705
  }
1774
1706
  }
1775
1707
  __updateSize() {
@@ -2044,4 +1976,4 @@ function penPathType() {
2044
1976
  };
2045
1977
  }
2046
1978
 
2047
- export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, UI, UIBounds, UIData, UIRender, UnitConvert, arrowType, effectType, resizeType, stateType, zoomLayerType };
1979
+ export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, effectType, resizeType, zoomLayerType };
@@ -1 +1 @@
1
- import{decorateLeafAttr as t,attr as e,doStrokeType as i,defineKey as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as h,dataType as _,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as B,strokeType as k,cursorType as b,rewrite as A,Leaf as C,useModule as P,rewriteAble as I,pen as E,PathCorner as F,PathDrawer as D,UICreator as L,registerUI as W,Branch as T,LeafList as z,ImageManager as M,DataHelper as O,Creator as N,CanvasManager as V,WaitHelper as H,LeaferEvent as Y,Bounds as X,ResizeEvent as U,AutoBounds as j,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,affectRenderBoundsType as q,BoundsHelper as Q,Platform as Z,PathCommandDataHelper as tt,affectStrokeBoundsType as et,getPointData as it,PointHelper as st,PathBounds as ot,ImageEvent as rt,LeaferImage as at,Matrix as nt,MathHelper as ht,PathCreator as _t}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const pt={},lt={},ut={},ct={},yt={},gt={},vt={},ft={},wt={};function xt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>{wt.setStyle&&wt.setStyle(this,t+"Style",e)}))}})))}function mt(s){return t(s,(t=>e({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,i(this)}}})))}function Rt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function St(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function Bt(){return(t,e)=>{const i="_"+e;s(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:kt}=a,bt={},At=o.get("UIData");class Ct extends r{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,At.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,At.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=bt)):(this.__isFills&&(this.__removeInput("fill"),yt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=bt)):(this.__isStrokes&&(this.__removeInput("stroke"),yt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=kt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ct.compute("fill",this.__leaf),e&&ct.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Pt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class It extends Ct{}class Et extends It{get __boxStroke(){return!this.__pathInputed}}class Ft extends It{__getInputData(){const t=super.__getInputData();return n.forEach((e=>delete t[e])),t}}class Dt extends Et{}class Lt extends Ct{}class Wt extends Ct{get __boxStroke(){return!this.__pathInputed}}class Tt extends Ct{get __boxStroke(){return!this.__pathInputed}}class zt extends Ct{}class Mt extends Ct{}class Ot extends Ct{}class Nt extends It{}const Vt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ht extends Ct{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Vt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Yt extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Xt extends Wt{__getInputData(){const t=super.__getInputData();return t.url=this.__leaf.canvas.toDataURL("image/png"),t}}const Ut={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},jt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Gt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ct.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:h}=i;n&&vt.shadow(this,t,a),s&&(i.__isFills?ct.fills(s,this,t):ct.fill(s,this,t)),r&&this.__drawAfterFill(t,e),h&&vt.innerShadow(this,t,a),o&&(i.__isStrokes?ct.strokes(o,this,t):ct.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ct.fills(s,this,t):ct.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ct.strokes(o,this,t):ct.stroke(o,this,t))}else i.__pathInputed?Gt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ct.fills(o,this,t):ct.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ct.strokes(r,this,t):ct.stroke("#000000",this,t))}}};function Gt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ct.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ct.stroke(o,t,e)}const Jt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var $t;let Kt=$t=class extends C{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:t}=this.__;return E.set(this.path=t||[]),t||this.__drawPathByBox(E),E}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(E.set(i=[]),this.__drawPathByBox(E)),t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||ft.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&ut.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?D.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}export(t,e){return ft.export(this,t,e)}clone(){return $t.one(this.toJSON())}static one(t,e,i,s,o){return L.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){W()(this)}static registerData(t){h(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}};dt([h(Ct)],Kt.prototype,"__",void 0),dt([Bt()],Kt.prototype,"zoomLayer",void 0),dt([_("")],Kt.prototype,"id",void 0),dt([_("")],Kt.prototype,"name",void 0),dt([_("")],Kt.prototype,"className",void 0),dt([d("pass-through")],Kt.prototype,"blendMode",void 0),dt([p(1)],Kt.prototype,"opacity",void 0),dt([l(!0)],Kt.prototype,"visible",void 0),dt([xt(!1)],Kt.prototype,"selected",void 0),dt([xt(!1)],Kt.prototype,"disabled",void 0),dt([d(!1)],Kt.prototype,"locked",void 0),dt([u(0)],Kt.prototype,"zIndex",void 0),dt([c(!1)],Kt.prototype,"mask",void 0),dt([y(!1)],Kt.prototype,"eraser",void 0),dt([g(0,!0)],Kt.prototype,"x",void 0),dt([g(0,!0)],Kt.prototype,"y",void 0),dt([v(100,!0)],Kt.prototype,"width",void 0),dt([v(100,!0)],Kt.prototype,"height",void 0),dt([f(1,!0)],Kt.prototype,"scaleX",void 0),dt([f(1,!0)],Kt.prototype,"scaleY",void 0),dt([w(0,!0)],Kt.prototype,"rotation",void 0),dt([w(0,!0)],Kt.prototype,"skewX",void 0),dt([w(0,!0)],Kt.prototype,"skewY",void 0),dt([g(0,!0)],Kt.prototype,"offsetX",void 0),dt([g(0,!0)],Kt.prototype,"offsetY",void 0),dt([g(0,!0)],Kt.prototype,"scrollX",void 0),dt([g(0,!0)],Kt.prototype,"scrollY",void 0),dt([x()],Kt.prototype,"origin",void 0),dt([x()],Kt.prototype,"around",void 0),dt([_(!1)],Kt.prototype,"lazy",void 0),dt([m(1)],Kt.prototype,"pixelRatio",void 0),dt([R()],Kt.prototype,"path",void 0),dt([S()],Kt.prototype,"windingRule",void 0),dt([S(!0)],Kt.prototype,"closed",void 0),dt([x(!1)],Kt.prototype,"flow",void 0),dt([v(0)],Kt.prototype,"padding",void 0),dt([v(0)],Kt.prototype,"gap",void 0),dt([v("top-left")],Kt.prototype,"flowAlign",void 0),dt([v(!1)],Kt.prototype,"flowWrap",void 0),dt([v("box")],Kt.prototype,"itemBox",void 0),dt([v(!0)],Kt.prototype,"inFlow",void 0),dt([v()],Kt.prototype,"autoWidth",void 0),dt([v()],Kt.prototype,"autoHeight",void 0),dt([v()],Kt.prototype,"lockRatio",void 0),dt([v()],Kt.prototype,"autoBox",void 0),dt([v()],Kt.prototype,"widthRange",void 0),dt([v()],Kt.prototype,"heightRange",void 0),dt([_(!1)],Kt.prototype,"draggable",void 0),dt([_()],Kt.prototype,"dragBounds",void 0),dt([_(!1)],Kt.prototype,"editable",void 0),dt([B(!0)],Kt.prototype,"hittable",void 0),dt([B("path")],Kt.prototype,"hitFill",void 0),dt([k("path")],Kt.prototype,"hitStroke",void 0),dt([B(!1)],Kt.prototype,"hitBox",void 0),dt([B(!0)],Kt.prototype,"hitChildren",void 0),dt([B(!0)],Kt.prototype,"hitSelf",void 0),dt([B()],Kt.prototype,"hitRadius",void 0),dt([b("")],Kt.prototype,"cursor",void 0),dt([d()],Kt.prototype,"fill",void 0),dt([k()],Kt.prototype,"stroke",void 0),dt([k("inside")],Kt.prototype,"strokeAlign",void 0),dt([k(1)],Kt.prototype,"strokeWidth",void 0),dt([k(!1)],Kt.prototype,"strokeWidthFixed",void 0),dt([k("none")],Kt.prototype,"strokeCap",void 0),dt([k("miter")],Kt.prototype,"strokeJoin",void 0),dt([k()],Kt.prototype,"dashPattern",void 0),dt([k()],Kt.prototype,"dashOffset",void 0),dt([k(10)],Kt.prototype,"miterLimit",void 0),dt([mt("none")],Kt.prototype,"startArrow",void 0),dt([mt("none")],Kt.prototype,"endArrow",void 0),dt([S(0)],Kt.prototype,"cornerRadius",void 0),dt([S()],Kt.prototype,"cornerSmoothing",void 0),dt([Rt()],Kt.prototype,"shadow",void 0),dt([Rt()],Kt.prototype,"innerShadow",void 0),dt([Rt()],Kt.prototype,"blur",void 0),dt([Rt()],Kt.prototype,"backgroundBlur",void 0),dt([Rt()],Kt.prototype,"grayscale",void 0),dt([_()],Kt.prototype,"normalStyle",void 0),dt([_()],Kt.prototype,"hoverStyle",void 0),dt([_()],Kt.prototype,"pressStyle",void 0),dt([_()],Kt.prototype,"focusStyle",void 0),dt([_()],Kt.prototype,"selectedStyle",void 0),dt([_()],Kt.prototype,"disabledStyle",void 0),dt([_({})],Kt.prototype,"data",void 0),dt([A(C.prototype.reset)],Kt.prototype,"reset",null),Kt=$t=dt([P(Ut),P(jt),I()],Kt);let qt=class extends Kt{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:L.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Qt;dt([h(It)],qt.prototype,"__",void 0),qt=dt([P(T),W()],qt);const Zt=o.get("Leafer");let te=Qt=class extends qt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&M.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&O.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=N.canvas(s);this.__controllers.push(this.renderer=N.renderer(this,o,s),this.watcher=N.watcher(this,s),this.layouter=N.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=N.selector(this),this.interaction=N.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=N.hitCanvasManager()),this.canvasManager=new V,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Y.RESTART):this.emitLeafer(Y.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Y.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=O.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=O.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new U(t,i))}__onResize(t){this.emitEvent(t),O.copyAttrs(this.__,t,n),t.width&&t.height||Zt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new j(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?(e||Zt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=O.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Y.BEFORE_READY),this.emitLeafer(Y.READY),this.emitLeafer(Y.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Y.VIEW_READY),H.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Y.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){return Zt.error("need @leafer-in/view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Y(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(Y.START,(()=>G.end(t))),this.once(J.START,(()=>this.updateLazyBounds())),this.once(J.END,(()=>this.__onReady())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_($.NEXT,this.__onNextRender,this),this.on_(J.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Qt.list.remove(this);try{this.stop(),this.emitEvent(new Y(Y.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{M.clearRecycled()}),100)}catch(t){Zt.error(t)}}};t?e():setTimeout(e)}};te.list=new z,dt([h(Ft)],te.prototype,"__",void 0),dt([v()],te.prototype,"pixelRatio",void 0),te=Qt=dt([W()],te);let ee=class extends Kt{get __tag(){return"Rect"}constructor(t){super(t)}};dt([h(Wt)],ee.prototype,"__",void 0),ee=dt([P(Jt),I(),W()],ee);const ie=ee.prototype,se=qt.prototype,oe={},{copy:re,add:ae,includes:ne,copyAndSpread:he}=Q;let _e=class extends qt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length){if(e.__autoSide){this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds();const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(i.width+=i.x,i.height=e.height,i.y=i.x=0):(i.height+=i.y,i.width=e.width,i.x=i.y=0)),t&&e.flow&&e.padding&&he(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),re(oe,e),this.__updateRectRenderBounds(),t=!ne(e,oe)||!this.pathInputed||!this.__.cornerRadius):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),!(this.__.__drawAfterFill="hide"===this.__.overflow)&&t&&ae(e,oe)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([h(Et)],_e.prototype,"__",void 0),dt([_(!1)],_e.prototype,"resizeChildren",void 0),dt([q("show")],_e.prototype,"overflow",void 0),dt([A(ie.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([A(ie.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([A(ie.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([A(ie.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([A(ie.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([A(ie.__updateChange)],_e.prototype,"__updateRectChange",null),dt([A(ie.__render)],_e.prototype,"__renderRect",null),dt([A(se.__render)],_e.prototype,"__renderGroup",null),_e=dt([I(),W()],_e);let de=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([h(Dt)],de.prototype,"__",void 0),dt([d("#FFFFFF")],de.prototype,"fill",void 0),dt([q("hide")],de.prototype,"overflow",void 0),de=dt([W()],de);const{moveTo:pe,closePath:le,ellipse:ue}=tt;let ce=class extends Kt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&ue(n,r,a,r*i,a*i,0,s,o,!1),ue(n,r,a,r,a,0,o,s,!0),i<1&&le(n)):(i<1&&(ue(n,r,a,r*i,a*i),pe(n,t,a)),ue(n,r,a,r,a,0,360,0,!0)),Z.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(pe(n,r,a),ue(n,r,a,r,a,0,s,o,!1),le(n)):ue(n,r,a,r,a)}};dt([h(Tt)],ce.prototype,"__",void 0),dt([S(0)],ce.prototype,"innerRadius",void 0),dt([S(0)],ce.prototype,"startAngle",void 0),dt([S(0)],ce.prototype,"endAngle",void 0),ce=dt([W()],ce);const{moveTo:ye,lineTo:ge,drawPoints:ve}=tt,{rotate:fe,getAngle:we,getDistance:xe,defaultPoint:me}=st,{toBounds:Re}=ot;let Se=class extends Kt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=it();return t&&(i.x=t),e&&fe(i,e),i}set toPoint(t){this.width=xe(me,t),this.rotation=we(me,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ve(e,t.points,!1,t.closed):(ye(e,0,0),ge(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ve(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&ut.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Re(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([h(Lt)],Se.prototype,"__",void 0),dt([et("center")],Se.prototype,"strokeAlign",void 0),dt([v(0)],Se.prototype,"height",void 0),dt([S()],Se.prototype,"points",void 0),dt([S(0)],Se.prototype,"curve",void 0),dt([S(!1)],Se.prototype,"closed",void 0),Se=dt([W()],Se);const{sin:Be,cos:ke,PI:be}=Math,{moveTo:Ae,lineTo:Ce,closePath:Pe,drawPoints:Ie}=tt,Ee=Se.prototype;let Fe=class extends Kt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ie(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Ae(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Be(2*e*be/s),r-r*ke(2*e*be/s))}Pe(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([h(zt)],Fe.prototype,"__",void 0),dt([S(3)],Fe.prototype,"sides",void 0),dt([S()],Fe.prototype,"points",void 0),dt([S(0)],Fe.prototype,"curve",void 0),dt([A(Ee.__updateRenderPath)],Fe.prototype,"__updateRenderPath",null),dt([A(Ee.__updateBoxBounds)],Fe.prototype,"__updateBoxBounds",null),Fe=dt([I(),W()],Fe);const{sin:De,cos:Le,PI:We}=Math,{moveTo:Te,lineTo:ze,closePath:Me}=tt;let Oe=class extends Kt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Te(a,o,0);for(let t=1;t<2*i;t++)ze(a,o+(t%2==0?o:o*s)*De(t*We/i),r-(t%2==0?r:r*s)*Le(t*We/i));Me(a)}};dt([h(Mt)],Oe.prototype,"__",void 0),dt([S(5)],Oe.prototype,"corners",void 0),dt([S(.382)],Oe.prototype,"innerRadius",void 0),Oe=dt([W()],Oe);let Ne=class extends ee{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(rt.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([h(Yt)],Ne.prototype,"__",void 0),dt([v("")],Ne.prototype,"url",void 0),Ne=dt([W()],Ne);const Ve=Ne;let He=class extends ee{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=N.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0,t&&t.url&&this.drawImage(t.url)}drawImage(t){new at({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new rt(rt.LOADED,{image:t}))}))}draw(t,e,i,s){t.__layout.update();const o=new nt(t.__world).invert(),r=new nt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([h(Xt)],He.prototype,"__",void 0),dt([St(100)],He.prototype,"width",void 0),dt([St(100)],He.prototype,"height",void 0),dt([St(1)],He.prototype,"pixelRatio",void 0),dt([St(!0)],He.prototype,"smooth",void 0),dt([St()],He.prototype,"contextSettings",void 0),He=dt([W()],He);const{copyAndSpread:Ye,includes:Xe,isSame:Ue,spread:je,setList:Ge}=Q;let Je=class extends Kt{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=pt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:h,textOverflow:_,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Pt.number(i,r),t.__letterSpacing=Pt.number(s,r),t.__padding=d?ht.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==_&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&je(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=Xe(c,u)?c:u;Ue(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Ge(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Ye(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([h(Ht)],Je.prototype,"__",void 0),dt([v(0)],Je.prototype,"width",void 0),dt([v(0)],Je.prototype,"height",void 0),dt([_(!1)],Je.prototype,"resizeFontSize",void 0),dt([d("#000000")],Je.prototype,"fill",void 0),dt([et("outside")],Je.prototype,"strokeAlign",void 0),dt([B("all")],Je.prototype,"hitFill",void 0),dt([v("")],Je.prototype,"text",void 0),dt([v("L")],Je.prototype,"fontFamily",void 0),dt([v(12)],Je.prototype,"fontSize",void 0),dt([v("normal")],Je.prototype,"fontWeight",void 0),dt([v(!1)],Je.prototype,"italic",void 0),dt([v("none")],Je.prototype,"textCase",void 0),dt([v("none")],Je.prototype,"textDecoration",void 0),dt([v(0)],Je.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],Je.prototype,"lineHeight",void 0),dt([v(0)],Je.prototype,"paraIndent",void 0),dt([v(0)],Je.prototype,"paraSpacing",void 0),dt([v("left")],Je.prototype,"textAlign",void 0),dt([v("top")],Je.prototype,"verticalAlign",void 0),dt([v("normal")],Je.prototype,"textWrap",void 0),dt([v("show")],Je.prototype,"textOverflow",void 0),Je=dt([W()],Je);let $e=class extends Kt{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};dt([h(Ot)],$e.prototype,"__",void 0),dt([et("center")],$e.prototype,"strokeAlign",void 0),$e=dt([W()],$e);let Ke=class extends qt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new $e(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([h(Nt)],Ke.prototype,"__",void 0),dt([(t,e)=>{s(t,e,{get(){return this.__path}})}],Ke.prototype,"path",void 0),Ke=dt([P(_t,["set","beginPath","path","paint"]),W()],Ke);export{_e as Box,Et as BoxData,He as Canvas,Xt as CanvasData,lt as ColorConvert,vt as Effect,ce as Ellipse,Tt as EllipseData,ft as Export,de as Frame,Dt as FrameData,qt as Group,It as GroupData,Ne as Image,Yt as ImageData,te as Leafer,Ft as LeaferData,Se as Line,Lt as LineData,Ve as MyImage,ct as Paint,gt as PaintGradient,yt as PaintImage,$e as Path,ut as PathArrow,Ot as PathData,Ke as Pen,Nt as PenData,Fe as Polygon,zt as PolygonData,ee as Rect,Wt as RectData,Jt as RectRender,Oe as Star,Mt as StarData,wt as State,Je as Text,pt as TextConvert,Ht as TextData,Kt as UI,Ut as UIBounds,Ct as UIData,jt as UIRender,Pt as UnitConvert,mt as arrowType,Rt as effectType,St as resizeType,xt as stateType,Bt as zoomLayerType};
1
+ import{decorateLeafAttr as t,attr as e,defineKey as i,needPlugin as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as P,useModule as A,rewriteAble as I,MathHelper as E,pen as D,PathCorner as F,PathDrawer as L,UICreator as W,registerUI as T,Branch as z,LeafList as M,ImageManager as O,DataHelper as N,Creator as V,CanvasManager as H,WaitHelper as Y,LeaferEvent as j,Bounds as U,ResizeEvent as X,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as q,affectRenderBoundsType as Q,BoundsHelper as Z,Platform as tt,PathCommandDataHelper as et,affectStrokeBoundsType as it,getPointData as st,PointHelper as ot,PathBounds as rt,ImageEvent as at,LeaferImage as nt,Matrix as _t,PathCreator as ht}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function pt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function lt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ut(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const ct={},yt={},gt={},vt={},ft={},wt={},xt={},mt={},Rt={setStyleName:(t,e,i)=>s("state"),set:(t,e)=>s("state")},St={list:{},register(t,e){St.list[t]=e},get:t=>St.list[t]},{parse:kt}=a,Bt={},bt=o.get("UIData");class Ct extends r{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,bt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,bt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Bt)):(this.__isFills&&(this.__removeInput("fill"),ft.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Bt)):(this.__isStrokes&&(this.__removeInput("stroke"),ft.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=kt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&vt.compute("fill",this.__leaf),e&&vt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Pt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class At extends Ct{}class It extends At{get __boxStroke(){return!this.__pathInputed}}class Et extends At{__getInputData(){const t=super.__getInputData();return n.forEach((e=>delete t[e])),t}}class Dt extends It{}class Ft extends Ct{}class Lt extends Ct{get __boxStroke(){return!this.__pathInputed}}class Wt extends Ct{get __boxStroke(){return!this.__pathInputed}}class Tt extends Ct{}class zt extends Ct{}class Mt extends Ct{}class Ot extends At{}const Nt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Vt extends Ct{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Nt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Lt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Yt extends Lt{__getInputData(){const t=super.__getInputData();return t.url=this.__leaf.canvas.toDataURL("image/png"),t}}const jt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Ut={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Xt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=vt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&xt.shadow(this,t,a),s&&(i.__isFills?vt.fills(s,this,t):vt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&xt.innerShadow(this,t,a),o&&(i.__isStrokes?vt.strokes(o,this,t):vt.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?vt.fills(s,this,t):vt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?vt.strokes(o,this,t):vt.stroke(o,this,t))}else i.__pathInputed?Xt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?vt.fills(o,this,t):vt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?vt.strokes(r,this,t):vt.stroke("#000000",this,t))}}};function Xt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&vt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&vt.stroke(o,t,e)}const Gt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Jt;let $t=Jt=class extends P{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){E.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return D.set(this.path=t||[]),t||this.__drawPathByBox(D),D}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(D.set(i=[]),this.__drawPathByBox(D)),t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||mt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&gt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?L.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s("animate")}killAnimate(t){}export(t,e){return mt.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),Jt.one(e)}static one(t,e,i,s,o){return W.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};dt([_(Ct)],$t.prototype,"__",void 0),dt([ut()],$t.prototype,"zoomLayer",void 0),dt([h("")],$t.prototype,"id",void 0),dt([h("")],$t.prototype,"name",void 0),dt([h("")],$t.prototype,"className",void 0),dt([d("pass-through")],$t.prototype,"blendMode",void 0),dt([p(1)],$t.prototype,"opacity",void 0),dt([l(!0)],$t.prototype,"visible",void 0),dt([d(!1)],$t.prototype,"locked",void 0),dt([u(0)],$t.prototype,"zIndex",void 0),dt([c(!1)],$t.prototype,"mask",void 0),dt([y(!1)],$t.prototype,"eraser",void 0),dt([g(0,!0)],$t.prototype,"x",void 0),dt([g(0,!0)],$t.prototype,"y",void 0),dt([v(100,!0)],$t.prototype,"width",void 0),dt([v(100,!0)],$t.prototype,"height",void 0),dt([f(1,!0)],$t.prototype,"scaleX",void 0),dt([f(1,!0)],$t.prototype,"scaleY",void 0),dt([w(0,!0)],$t.prototype,"rotation",void 0),dt([w(0,!0)],$t.prototype,"skewX",void 0),dt([w(0,!0)],$t.prototype,"skewY",void 0),dt([g(0,!0)],$t.prototype,"offsetX",void 0),dt([g(0,!0)],$t.prototype,"offsetY",void 0),dt([g(0,!0)],$t.prototype,"scrollX",void 0),dt([g(0,!0)],$t.prototype,"scrollY",void 0),dt([x()],$t.prototype,"origin",void 0),dt([x()],$t.prototype,"around",void 0),dt([h(!1)],$t.prototype,"lazy",void 0),dt([m(1)],$t.prototype,"pixelRatio",void 0),dt([R()],$t.prototype,"path",void 0),dt([S()],$t.prototype,"windingRule",void 0),dt([S(!0)],$t.prototype,"closed",void 0),dt([v(0)],$t.prototype,"padding",void 0),dt([h(!1)],$t.prototype,"draggable",void 0),dt([h()],$t.prototype,"dragBounds",void 0),dt([h(!1)],$t.prototype,"editable",void 0),dt([k(!0)],$t.prototype,"hittable",void 0),dt([k("path")],$t.prototype,"hitFill",void 0),dt([B("path")],$t.prototype,"hitStroke",void 0),dt([k(!1)],$t.prototype,"hitBox",void 0),dt([k(!0)],$t.prototype,"hitChildren",void 0),dt([k(!0)],$t.prototype,"hitSelf",void 0),dt([k()],$t.prototype,"hitRadius",void 0),dt([b("")],$t.prototype,"cursor",void 0),dt([d()],$t.prototype,"fill",void 0),dt([B()],$t.prototype,"stroke",void 0),dt([B("inside")],$t.prototype,"strokeAlign",void 0),dt([B(1)],$t.prototype,"strokeWidth",void 0),dt([B(!1)],$t.prototype,"strokeWidthFixed",void 0),dt([B("none")],$t.prototype,"strokeCap",void 0),dt([B("miter")],$t.prototype,"strokeJoin",void 0),dt([B()],$t.prototype,"dashPattern",void 0),dt([B()],$t.prototype,"dashOffset",void 0),dt([B(10)],$t.prototype,"miterLimit",void 0),dt([S(0)],$t.prototype,"cornerRadius",void 0),dt([S()],$t.prototype,"cornerSmoothing",void 0),dt([pt()],$t.prototype,"shadow",void 0),dt([pt()],$t.prototype,"innerShadow",void 0),dt([pt()],$t.prototype,"blur",void 0),dt([pt()],$t.prototype,"backgroundBlur",void 0),dt([pt()],$t.prototype,"grayscale",void 0),dt([h({})],$t.prototype,"data",void 0),dt([C(P.prototype.reset)],$t.prototype,"reset",null),$t=Jt=dt([A(jt),A(Ut),I()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:i}=t;let s;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>{s=t.__?t:W.get(t.tag,t),this.add(s)})),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var qt;dt([_(At)],Kt.prototype,"__",void 0),Kt=dt([A(z),T()],Kt);const Qt=o.get("Leafer");let Zt=qt=class extends Kt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&N.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new H,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Y.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(j.RESTART):this.emitLeafer(j.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(j.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new X(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),t.width&&t.height||Qt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?(e||Qt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(j.BEFORE_READY),this.emitLeafer(j.READY),this.emitLeafer(j.AFTER_READY),Y.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(j.VIEW_READY),Y.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){Y.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(j.VIEW_COMPLETED),Y.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){return s("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new j(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(j.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once($.END,(()=>this.__onReady())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(q.DATA,this.__onWatchData,this),this.on_(K.NEXT,this.__onNextRender,this),this.on_($.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){qt.list.remove(this);try{this.stop(),this.emitEvent(new j(j.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{O.clearRecycled()}),100)}catch(t){Qt.error(t)}}};t?e():setTimeout(e)}};Zt.list=new M,dt([_(Et)],Zt.prototype,"__",void 0),dt([v()],Zt.prototype,"pixelRatio",void 0),Zt=qt=dt([T()],Zt);let te=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};dt([_(Lt)],te.prototype,"__",void 0),te=dt([A(Gt),I(),T()],te);const ee=te.prototype,ie=Kt.prototype,se={},{copy:oe,add:re,includes:ae,copyAndSpread:ne}=Z;let _e=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length){if(e.__autoSide){this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds();const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(i.width+=i.x,i.height=e.height,i.y=i.x=0):(i.height+=i.y,i.width=e.width,i.x=i.y=0)),t&&e.flow&&e.padding&&ne(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),oe(se,e),this.__updateRectRenderBounds(),t=!ae(e,se)||!this.pathInputed||!this.__.cornerRadius):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),!(this.__.__drawAfterFill="hide"===this.__.overflow)&&t&&re(e,se)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([_(It)],_e.prototype,"__",void 0),dt([h(!1)],_e.prototype,"resizeChildren",void 0),dt([Q("show")],_e.prototype,"overflow",void 0),dt([C(ee.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([C(ee.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([C(ee.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([C(ee.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([C(ee.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([C(ee.__updateChange)],_e.prototype,"__updateRectChange",null),dt([C(ee.__render)],_e.prototype,"__renderRect",null),dt([C(ie.__render)],_e.prototype,"__renderGroup",null),_e=dt([I(),T()],_e);let he=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([_(Dt)],he.prototype,"__",void 0),dt([d("#FFFFFF")],he.prototype,"fill",void 0),dt([Q("hide")],he.prototype,"overflow",void 0),he=dt([T()],he);const{moveTo:de,closePath:pe,ellipse:le}=et;let ue=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&le(n,r,a,r*i,a*i,0,s,o,!1),le(n,r,a,r,a,0,o,s,!0),i<1&&pe(n)):(i<1&&(le(n,r,a,r*i,a*i),de(n,t,a)),le(n,r,a,r,a,0,360,0,!0)),tt.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(de(n,r,a),le(n,r,a,r,a,0,s,o,!1),pe(n)):le(n,r,a,r,a)}};dt([_(Wt)],ue.prototype,"__",void 0),dt([S(0)],ue.prototype,"innerRadius",void 0),dt([S(0)],ue.prototype,"startAngle",void 0),dt([S(0)],ue.prototype,"endAngle",void 0),ue=dt([T()],ue);const{moveTo:ce,lineTo:ye,drawPoints:ge}=et,{rotate:ve,getAngle:fe,getDistance:we,defaultPoint:xe}=ot,{toBounds:me}=rt;let Re=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=st();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=we(xe,t),this.rotation=fe(xe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ge(e,t.points,!1,t.closed):(ce(e,0,0),ye(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ge(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&gt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?me(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([_(Ft)],Re.prototype,"__",void 0),dt([it("center")],Re.prototype,"strokeAlign",void 0),dt([v(0)],Re.prototype,"height",void 0),dt([S()],Re.prototype,"points",void 0),dt([S(0)],Re.prototype,"curve",void 0),dt([S(!1)],Re.prototype,"closed",void 0),Re=dt([T()],Re);const{sin:Se,cos:ke,PI:Be}=Math,{moveTo:be,lineTo:Ce,closePath:Pe,drawPoints:Ae}=et,Ie=Re.prototype;let Ee=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ae(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;be(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Se(2*e*Be/s),r-r*ke(2*e*Be/s))}Pe(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([_(Tt)],Ee.prototype,"__",void 0),dt([S(3)],Ee.prototype,"sides",void 0),dt([S()],Ee.prototype,"points",void 0),dt([S(0)],Ee.prototype,"curve",void 0),dt([C(Ie.__updateRenderPath)],Ee.prototype,"__updateRenderPath",null),dt([C(Ie.__updateBoxBounds)],Ee.prototype,"__updateBoxBounds",null),Ee=dt([I(),T()],Ee);const{sin:De,cos:Fe,PI:Le}=Math,{moveTo:We,lineTo:Te,closePath:ze}=et;let Me=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)Te(a,o+(t%2==0?o:o*s)*De(t*Le/i),r-(t%2==0?r:r*s)*Fe(t*Le/i));ze(a)}};dt([_(zt)],Me.prototype,"__",void 0),dt([S(5)],Me.prototype,"corners",void 0),dt([S(.382)],Me.prototype,"innerRadius",void 0),Me=dt([T()],Me);let Oe=class extends te{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(at.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([_(Ht)],Oe.prototype,"__",void 0),dt([v("")],Oe.prototype,"url",void 0),Oe=dt([T()],Oe);const Ne=Oe;let Ve=class extends te{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0,t&&t.url&&this.drawImage(t.url)}drawImage(t){new nt({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new at(at.LOADED,{image:t}))}))}draw(t,e,i,s){t.__layout.update();const o=new _t(t.__world).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawAfterFill(t,e){const{width:i,height:s,cornerRadius:o}=this.__,{view:r}=this.canvas;o||this.pathInputed?(t.save(),t.clip(),t.drawImage(r,0,0,r.width,r.height,0,0,i,s),t.restore()):t.drawImage(r,0,0,r.width,r.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([_(Yt)],Ve.prototype,"__",void 0),dt([lt(100)],Ve.prototype,"width",void 0),dt([lt(100)],Ve.prototype,"height",void 0),dt([lt(1)],Ve.prototype,"pixelRatio",void 0),dt([lt(!0)],Ve.prototype,"smooth",void 0),dt([lt()],Ve.prototype,"contextSettings",void 0),Ve=dt([T()],Ve);const{copyAndSpread:He,includes:Ye,isSame:je,spread:Ue,setList:Xe}=Z;let Ge=class extends $t{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=ct.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:_,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Pt.number(i,r),t.__letterSpacing=Pt.number(s,r),t.__padding=d?E.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ue(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=Ye(c,u)?c:u;je(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Xe(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){He(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([_(Vt)],Ge.prototype,"__",void 0),dt([v(0)],Ge.prototype,"width",void 0),dt([v(0)],Ge.prototype,"height",void 0),dt([h(!1)],Ge.prototype,"resizeFontSize",void 0),dt([d("#000000")],Ge.prototype,"fill",void 0),dt([it("outside")],Ge.prototype,"strokeAlign",void 0),dt([k("all")],Ge.prototype,"hitFill",void 0),dt([v("")],Ge.prototype,"text",void 0),dt([v("L")],Ge.prototype,"fontFamily",void 0),dt([v(12)],Ge.prototype,"fontSize",void 0),dt([v("normal")],Ge.prototype,"fontWeight",void 0),dt([v(!1)],Ge.prototype,"italic",void 0),dt([v("none")],Ge.prototype,"textCase",void 0),dt([v("none")],Ge.prototype,"textDecoration",void 0),dt([v(0)],Ge.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],Ge.prototype,"lineHeight",void 0),dt([v(0)],Ge.prototype,"paraIndent",void 0),dt([v(0)],Ge.prototype,"paraSpacing",void 0),dt([v("left")],Ge.prototype,"textAlign",void 0),dt([v("top")],Ge.prototype,"verticalAlign",void 0),dt([v("normal")],Ge.prototype,"textWrap",void 0),dt([v("show")],Ge.prototype,"textOverflow",void 0),Ge=dt([T()],Ge);let Je=class extends $t{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};dt([_(Mt)],Je.prototype,"__",void 0),dt([it("center")],Je.prototype,"strokeAlign",void 0),Je=dt([T()],Je);let $e=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([_(Ot)],$e.prototype,"__",void 0),dt([(t,e)=>{i(t,e,{get(){return this.__path}})}],$e.prototype,"path",void 0),$e=dt([A(ht,["set","beginPath","path","paint"]),T()],$e);export{_e as Box,It as BoxData,Ve as Canvas,Yt as CanvasData,yt as ColorConvert,xt as Effect,ue as Ellipse,Wt as EllipseData,mt as Export,he as Frame,Dt as FrameData,Kt as Group,At as GroupData,Oe as Image,Ht as ImageData,Zt as Leafer,Et as LeaferData,Re as Line,Ft as LineData,Ne as MyImage,vt as Paint,wt as PaintGradient,ft as PaintImage,Je as Path,gt as PathArrow,Mt as PathData,$e as Pen,Ot as PenData,Ee as Polygon,Tt as PolygonData,te as Rect,Lt as RectData,Gt as RectRender,Me as Star,zt as StarData,Rt as State,Ge as Text,ct as TextConvert,Vt as TextData,St as Transition,$t as UI,jt as UIBounds,Ct as UIData,Ut as UIRender,Pt as UnitConvert,pt as effectType,lt as resizeType,ut as zoomLayerType};
package/lib/draw.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core");function e(t,e,s,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,s):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,o);else for(var n=t.length-1;n>=0;n--)(r=t[n])&&(a=(i<3?r(a):i>3?r(e,s,a):r(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}"function"==typeof SuppressedError&&SuppressedError;const s={},o={},r={},i={},a={},n={},p={};function h(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.waitLeafer((()=>{p.setStyle&&p.setStyle(this,e+"Style",t)}))}})))}function _(e){return t.decorateLeafAttr(e,(e=>t.attr({set(s){if(this.__setAttr(e,s)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,t.doStrokeType(this)}}})))}function d(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function l(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function u(){return(e,s)=>{const o="_"+s;t.defineKey(e,s,{set(t){this.isLeafer&&(this[o]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[o]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:c}=t.PathConvert,y={},x=t.Debug.get("UIData");class g extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:s}=e.__nowWorld||e.__world;return s<0&&(s=-s),s>1?t/s:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,x.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,x.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=y)):(this.__isFills&&(this.__removeInput("fill"),i.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=y)):(this.__isStrokes&&(this.__removeInput("stroke"),i.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=c(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&r.compute("fill",this.__leaf),e&&r.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const v={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class f extends g{}class w extends f{get __boxStroke(){return!this.__pathInputed}}class T extends f{__getInputData(){const e=super.__getInputData();return t.canvasSizeAttrs.forEach((t=>delete e[t])),e}}class I extends w{}class m extends g{}class R extends g{get __boxStroke(){return!this.__pathInputed}}class P extends g{get __boxStroke(){return!this.__pathInputed}}class b extends g{}class S extends g{}class B extends g{}class U extends f{}const C={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class k extends g{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=C[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class A extends R{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends R{__getInputData(){const t=super.__getInputData();return t.url=this.__leaf.canvas.toDataURL("image/png"),t}}const E={__updateStrokeSpread(){let t=0,e=0;const s=this.__,{strokeAlign:o,strokeWidth:r}=s;if((s.stroke||"all"===s.hitStroke)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!s.__boxStroke)){const e=s.__isLinePath?0:10*t,o="none"===s.strokeCap?0:r;t+=Math.max(e,o)}return s.__useArrow&&(t+=5*r),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:o,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),o&&(t=Math.max(t,o));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(i=Math.max(i,r)),this.__layout.renderShapeSpread=i,t+(this.__layout.strokeSpread||0)}},D={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:o,backgroundBlur:r}=this.__;t.__useEffect=!!(e||s||o||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:i,__drawAfterFill:n}=s;if(this.__drawRenderPath(t),s.__useEffect){const p=r.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=s;h&&a.shadow(this,t,p),o&&(s.__isFills?r.fills(o,this,t):r.fill(o,this,t)),n&&this.__drawAfterFill(t,e),_&&a.innerShadow(this,t,p),i&&(s.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t)),p.worldCanvas&&p.worldCanvas.recycle(),p.canvas.recycle()}else o&&(s.__isFills?r.fills(o,this,t):r.fill(o,this,t)),n&&this.__drawAfterFill(t,e),i&&(s.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t))}else s.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,s,o){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:a}=this.__;this.__drawRenderPath(t),i&&!s&&(this.__.__pixelFill?r.fills(i,this,t):r.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),a&&!o&&(this.__.__pixelStroke?r.strokes(a,this,t):r.stroke("#000000",this,t))}}};function F(t,e,s){const{fill:o,stroke:i,__drawAfterFill:a}=t.__;t.__drawRenderPath(e),o&&r.fill(o,t,e),a&&t.__drawAfterFill(e,s),i&&r.stroke(i,t,e)}const W={__drawFast(t,e){let{width:s,height:o,fill:r,stroke:i,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,s,o)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:r,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(i,a,this.__);const n=a/2;switch(r){case"center":t.strokeRect(0,0,s,o);break;case"inside":s-=a,o-=a,s<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,s,o),t.restore()):t.strokeRect(n,n,s,o);break;case"outside":t.strokeRect(-n,-n,s+a,o+a)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:e}=this.__;return t.pen.set(this.path=e||[]),e||this.__drawPathByBox(t.pen),t.pen}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,s){this.__layout.update();let o=s?this.__.__pathForRender:this.__.path;return o||(t.pen.set(o=[]),this.__drawPathByBox(t.pen)),e?t.PathConvert.toCanvasData(o,!0):o}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||n.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&o.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:o,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,s,o,r,"number"==typeof i?[i]:i)}else t.rect(e,s,o,r)}export(t,e){return n.export(this,t,e)}clone(){return z.one(this.toJSON())}static one(e,s,o,r,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,o,r,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(g)],exports.UI.prototype,"__",void 0),e([u()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.visibleType(!0)],exports.UI.prototype,"visible",void 0),e([h(!1)],exports.UI.prototype,"selected",void 0),e([h(!1)],exports.UI.prototype,"disabled",void 0),e([t.surfaceType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.autoLayoutType(!1)],exports.UI.prototype,"flow",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.boundsType(0)],exports.UI.prototype,"gap",void 0),e([t.boundsType("top-left")],exports.UI.prototype,"flowAlign",void 0),e([t.boundsType(!1)],exports.UI.prototype,"flowWrap",void 0),e([t.boundsType("box")],exports.UI.prototype,"itemBox",void 0),e([t.boundsType(!0)],exports.UI.prototype,"inFlow",void 0),e([t.boundsType()],exports.UI.prototype,"autoWidth",void 0),e([t.boundsType()],exports.UI.prototype,"autoHeight",void 0),e([t.boundsType()],exports.UI.prototype,"lockRatio",void 0),e([t.boundsType()],exports.UI.prototype,"autoBox",void 0),e([t.boundsType()],exports.UI.prototype,"widthRange",void 0),e([t.boundsType()],exports.UI.prototype,"heightRange",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([_("none")],exports.UI.prototype,"startArrow",void 0),e([_("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([d()],exports.UI.prototype,"shadow",void 0),e([d()],exports.UI.prototype,"innerShadow",void 0),e([d()],exports.UI.prototype,"blur",void 0),e([d()],exports.UI.prototype,"backgroundBlur",void 0),e([d()],exports.UI.prototype,"grayscale",void 0),e([t.dataType()],exports.UI.prototype,"normalStyle",void 0),e([t.dataType()],exports.UI.prototype,"hoverStyle",void 0),e([t.dataType()],exports.UI.prototype,"pressStyle",void 0),e([t.dataType()],exports.UI.prototype,"focusStyle",void 0),e([t.dataType()],exports.UI.prototype,"selectedStyle",void 0),e([t.dataType()],exports.UI.prototype,"disabledStyle",void 0),e([t.dataType({})],exports.UI.prototype,"data",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(E),t.useModule(D),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let o;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),s.forEach((e=>{o=e.__?e:t.UICreator.get(e.tag,e),this.add(o)})),e.children=s}else super.set(e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const H=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,s){if(this.canvas)return;let o;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:r}=this;this.initType(r.type);const i=this.canvas=t.Creator.canvas(r);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,r),this.watcher=t.Creator.watcher(this,r),this.layouter=t.Creator.layouter(this,r)),this.isApp&&this.__setApp(),this.__checkAutoLayout(r,s),this.view=i.view,s?(this.__bindApp(s),o=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,r),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,o=r.start),this.hittable=r.hittable,this.fill=r.fill,this.canvasManager.add(i),this.__listenEvents(),o&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(e){const{canvas:s}=this;if(!s||s.isSameSize(e))return;const o=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,o))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),e.width&&e.height||H.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e,s){s||(e.width&&e.height||(this.autoLayout=new t.AutoBounds(e)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){return this.canvas&&(t.canvasSizeAttrs.includes(e)?(s||H.warn(e+" is 0"),this.__changeCanvasSize(e,s)):"fill"===e?this.__changeFill(s):"hittable"===e?this.parent||(this.canvas.hittable=s):"zIndex"===e&&(this.canvas.zIndex=s,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const o=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);o[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(o)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,s){e&&(t=t.bind(e));const o=this.__nextRenderWait;if(s){for(let e=0;e<o.length;e++)if(o[e]===t){o.splice(e,1);break}}else o.push(t)}zoom(t,e,s){return H.error("need @leafer-in/view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.START,(()=>this.updateLazyBounds())),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(e){const s=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){H.error(t)}}};e?s():setTimeout(s)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(T)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const O=exports.Rect.prototype,N=exports.Group.prototype,G={},{copy:V,add:Y,includes:j,copyAndSpread:X}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length){if(e.__autoSide){this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds();const{boxBounds:s}=this.__layout;e.__autoSize||(e.__autoWidth?(s.width+=s.x,s.height=e.height,s.y=s.x=0):(s.height+=s.y,s.width=e.width,s.x=s.y=0)),t&&e.flow&&e.padding&&X(s,s,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),V(G,e),this.__updateRectRenderBounds(),t=!j(e,G)||!this.pathInputed||!this.__.cornerRadius):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),!(this.__.__drawAfterFill="hide"===this.__.overflow)&&t&&Y(e,G)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:s}=this.children;this.isOverflow?(t.save(),t.clip(),s&&this.__renderGroup(t,e),t.restore()):s&&this.__renderGroup(t,e),this.__.stroke&&s&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.dataType(!1)],exports.Box.prototype,"resizeChildren",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(O.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(O.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(O.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(O.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(O.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(O.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(N.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(I)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:J,closePath:K,ellipse:$}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:o,startAngle:r,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];o?(r||i?(o<1&&$(p,a,n,a*o,n*o,0,r,i,!1),$(p,a,n,a,n,0,i,r,!0),o<1&&K(p)):(o<1&&($(p,a,n,a*o,n*o),J(p,e,n)),$(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):r||i?(J(p,a,n),$(p,a,n,a,n,0,r,i,!1),K(p)):$(p,a,n,a,n)}},e([t.dataProcessor(P)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:q,lineTo:Q,drawPoints:Z}=t.PathCommandDataHelper,{rotate:tt,getAngle:et,getDistance:st,defaultPoint:ot}=t.PointHelper,{toBounds:rt}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,o=t.getPointData();return e&&(o.x=e),s&&tt(o,s),o}set toPoint(t){this.width=st(ot,t),this.rotation=et(ot,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Z(e,t.points,!1,t.closed):(q(e,0,0),Q(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Z(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&o.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?rt(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(m)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:it,cos:at,PI:nt}=Math,{moveTo:pt,lineTo:ht,closePath:_t,drawPoints:dt}=t.PathCommandDataHelper,lt=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)dt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:o}=this.__,r=e/2,i=s/2;pt(t,r,0);for(let e=1;e<o;e++)ht(t,r+r*it(2*e*nt/o),i-i*at(2*e*nt/o))}_t(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(b)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(lt.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(lt.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:ut,cos:ct,PI:yt}=Math,{moveTo:xt,lineTo:gt,closePath:vt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:o}=this.__,r=t/2,i=e/2,a=this.__.path=[];xt(a,r,0);for(let t=1;t<2*s;t++)gt(a,r+(t%2==0?r:r*o)*ut(t*yt/s),i-(t%2==0?i:i*o)*ct(t*yt/s));vt(a)}},e([t.dataProcessor(S)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image);const ft=exports.Image;exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0,e&&e.url&&this.drawImage(e.url)}drawImage(e){new t.LeaferImage({url:e}).load((e=>{this.context.drawImage(e.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:e}))}))}draw(e,s,o,r){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),o&&("number"==typeof o?a.scale(o):a.scale(o.x,o.y)),r&&a.rotate(r),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:o,height:r}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,o,r),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,o,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([l(100)],exports.Canvas.prototype,"width",void 0),e([l(100)],exports.Canvas.prototype,"height",void 0),e([l(1)],exports.Canvas.prototype,"pixelRatio",void 0),e([l(!0)],exports.Canvas.prototype,"smooth",void 0),e([l()],exports.Canvas.prototype,"contextSettings",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:wt,includes:Tt,isSame:It,spread:mt,setList:Rt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:s,__baseLine:o,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-o,r.width,e<s?s:e)))}__drawPathByData(t,e){const{x:s,y:o,width:r,height:i}=this.__layout.boxBounds;t.rect(s,o,r,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=s.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:o,letterSpacing:r,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=v.number(o,a),e.__letterSpacing=v.number(r,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&mt(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,s,o,r]=e.__padding;l&&(y.x-=r,y.width+=s+r),u&&(y.y-=t,y.height+=o+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();p&&(y.width+=.16*a);const x=Tt(y,c)?y:c;It(x,s.contentBounds)?e.__textBoxBounds=x:(s.contentBounds=x,s.renderChanged=!0,Rt(e.__textBoxBounds={},[y,c]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){wt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(k)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.dataType(!1)],exports.Text.prototype,"resizeFontSize",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:1.5})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(B)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,o,r,i){return this}quadraticCurveTo(t,e,s,o){return this}closePath(){return this}rect(t,e,s,o){return this}roundRect(t,e,s,o,r){return this}ellipse(t,e,s,o,r,i,a,n){return this}arc(t,e,s,o,r,i){return this}arcTo(t,e,s,o,r){return this}drawEllipse(t,e,s,o,r,i,a,n){return this}drawArc(t,e,s,o,r,i){return this}drawPoints(t,e,s){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},e([t.dataProcessor(U)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","beginPath","path","paint"]),t.registerUI()],exports.Pen),exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=a,exports.EllipseData=P,exports.Export=n,exports.FrameData=I,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=T,exports.LineData=m,exports.MyImage=ft,exports.Paint=r,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=o,exports.PathData=B,exports.PenData=U,exports.PolygonData=b,exports.RectData=R,exports.RectRender=W,exports.StarData=S,exports.State=p,exports.TextConvert=s,exports.TextData=k,exports.UIBounds=E,exports.UIData=g,exports.UIRender=D,exports.UnitConvert=v,exports.arrowType=_,exports.effectType=d,exports.resizeType=l,exports.stateType=h,exports.zoomLayerType=u,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function r(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function o(){return(e,s)=>{const r="_"+s;t.defineKey(e,s,{set(t){this.isLeafer&&(this[r]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[r]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const i={},a={},n={},p={},h={},_={},d={setStyleName:(e,s,r)=>t.needPlugin("state"),set:(e,s)=>t.needPlugin("state")},l={list:{},register(t,e){l.list[t]=e},get:t=>l.list[t]},{parse:u}=t.PathConvert,c={},y=t.Debug.get("UIData");class x extends t.LeafData{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:s}=e.__nowWorld||e.__world;return s<0&&(s=-s),s>1?t/s:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,y.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,y.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=c)):(this.__isFills&&(this.__removeInput("fill"),p.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=c)):(this.__isStrokes&&(this.__removeInput("stroke"),p.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=u(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&n.compute("fill",this.__leaf),e&&n.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const g={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class v extends x{}class f extends v{get __boxStroke(){return!this.__pathInputed}}class w extends v{__getInputData(){const e=super.__getInputData();return t.canvasSizeAttrs.forEach((t=>delete e[t])),e}}class m extends f{}class T extends x{}class I extends x{get __boxStroke(){return!this.__pathInputed}}class R extends x{get __boxStroke(){return!this.__pathInputed}}class P extends x{}class S extends x{}class B extends x{}class b extends v{}const C={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class k extends x{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=C[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class U extends I{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends I{__getInputData(){const t=super.__getInputData();return t.url=this.__leaf.canvas.toDataURL("image/png"),t}}const A={__updateStrokeSpread(){let t=0,e=0;const s=this.__,{strokeAlign:r,strokeWidth:o}=s;if((s.stroke||"all"===s.hitStroke)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!s.__boxStroke)){const e=s.__isLinePath?0:10*t,r="none"===s.strokeCap?0:o;t+=Math.max(e,r)}return s.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t+(this.__layout.strokeSpread||0)}},E={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){D(this,t,e)},__draw(t,e){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:i}=s;if(this.__drawRenderPath(t),s.__useEffect){const a=n.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:p,innerShadow:_}=s;p&&h.shadow(this,t,a),r&&(s.__isFills?n.fills(r,this,t):n.fill(r,this,t)),i&&this.__drawAfterFill(t,e),_&&h.innerShadow(this,t,a),o&&(s.__isStrokes?n.strokes(o,this,t):n.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else r&&(s.__isFills?n.fills(r,this,t):n.fill(r,this,t)),i&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?n.strokes(o,this,t):n.stroke(o,this,t))}else s.__pathInputed?D(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,s,r){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:i}=this.__;this.__drawRenderPath(t),o&&!s&&(this.__.__pixelFill?n.fills(o,this,t):n.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),i&&!r&&(this.__.__pixelStroke?n.strokes(i,this,t):n.stroke("#000000",this,t))}}};function D(t,e,s){const{fill:r,stroke:o,__drawAfterFill:i}=t.__;t.__drawRenderPath(e),r&&n.fill(r,t,e),i&&t.__drawAfterFill(e,s),o&&n.stroke(o,t,e)}const F={__drawFast(t,e){let{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(i,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,s,r);break;case"inside":s-=a,r-=a,s<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,s,r),t.restore()):t.strokeRect(n,n,s,r);break;case"outside":t.strokeRect(-n,-n,s+a,r+a)}}}};var W,z;exports.UI=W=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(e){t.MathHelper.assignScale(this,e)}get scale(){return this.__.scale}get pen(){const{path:e}=this.__;return t.pen.set(this.path=e||[]),e||this.__drawPathByBox(t.pen),t.pen}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;return r||(t.pen.set(r=[]),this.__drawPathByBox(t.pen)),e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||_.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&a.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,s,r,o,"number"==typeof i?[i]:i)}else t.rect(e,s,r,o)}animate(e,s,r,o){return t.needPlugin("animate")}killAnimate(t){}export(t,e){return _.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),W.one(e)}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},e([t.dataProcessor(x)],exports.UI.prototype,"__",void 0),e([o()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.visibleType(!0)],exports.UI.prototype,"visible",void 0),e([t.surfaceType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([s()],exports.UI.prototype,"shadow",void 0),e([s()],exports.UI.prototype,"innerShadow",void 0),e([s()],exports.UI.prototype,"blur",void 0),e([s()],exports.UI.prototype,"backgroundBlur",void 0),e([s()],exports.UI.prototype,"grayscale",void 0),e([t.dataType({})],exports.UI.prototype,"data",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=W=e([t.useModule(A),t.useModule(E),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(e,s){if(e.children){const{children:r}=e;let o;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e,s),r.forEach((e=>{o=e.__?e:t.UICreator.get(e.tag,e),this.add(o)})),e.children=r}else super.set(e,s)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(v)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const M=t.Debug.get("Leafer");exports.Leafer=z=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),z.list.add(this)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type);const i=this.canvas=t.Creator.canvas(o);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o,s),this.view=i.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(i),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(e){const{canvas:s}=this;if(!s||s.isSameSize(e))return;const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,r))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),e.width&&e.height||M.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e,s){s||(e.width&&e.height||(this.autoLayout=new t.AutoBounds(e)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){return this.canvas&&(t.canvasSizeAttrs.includes(e)?(s||M.warn(e+" is 0"),this.__changeCanvasSize(e,s)):"fill"===e?this.__changeFill(s):"hittable"===e?this.parent||(this.canvas.hittable=s):"zIndex"===e&&(this.canvas.zIndex=s,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,s){e&&(t=t.bind(e));const r=this.__nextRenderWait;if(s){for(let e=0;e<r.length;e++)if(r[e]===t){r.splice(e,1);break}}else r.push(t)}zoom(e,s,r){return t.needPlugin("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.START,(()=>this.updateLazyBounds())),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(e){const s=()=>{if(!this.destroyed){z.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){M.error(t)}}};e?s():setTimeout(s)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(w)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=z=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(I)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(F),t.rewriteAble(),t.registerUI()],exports.Rect);const O=exports.Rect.prototype,H=exports.Group.prototype,N={},{copy:G,add:V,includes:j,copyAndSpread:Y}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length){if(e.__autoSide){this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds();const{boxBounds:s}=this.__layout;e.__autoSize||(e.__autoWidth?(s.width+=s.x,s.height=e.height,s.y=s.x=0):(s.height+=s.y,s.width=e.width,s.x=s.y=0)),t&&e.flow&&e.padding&&Y(s,s,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),G(N,e),this.__updateRectRenderBounds(),t=!j(e,N)||!this.pathInputed||!this.__.cornerRadius):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),!(this.__.__drawAfterFill="hide"===this.__.overflow)&&t&&V(e,N)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:s}=this.children;this.isOverflow?(t.save(),t.clip(),s&&this.__renderGroup(t,e),t.restore()):s&&this.__renderGroup(t,e),this.__.stroke&&s&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},e([t.dataProcessor(f)],exports.Box.prototype,"__",void 0),e([t.dataType(!1)],exports.Box.prototype,"resizeChildren",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(O.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(O.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(O.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(O.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(O.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(O.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(H.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(m)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:X,closePath:J,ellipse:K}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&K(p,a,n,a*r,n*r,0,o,i,!1),K(p,a,n,a,n,0,i,o,!0),r<1&&J(p)):(r<1&&(K(p,a,n,a*r,n*r),X(p,e,n)),K(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(X(p,a,n),K(p,a,n,a,n,0,o,i,!1),J(p)):K(p,a,n,a,n)}},e([t.dataProcessor(R)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:$,lineTo:q,drawPoints:Q}=t.PathCommandDataHelper,{rotate:Z,getAngle:tt,getDistance:et,defaultPoint:st}=t.PointHelper,{toBounds:rt}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&Z(r,s),r}set toPoint(t){this.width=et(st,t),this.rotation=tt(st,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Q(e,t.points,!1,t.closed):($(e,0,0),q(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Q(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&a.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?rt(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(T)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:ot,cos:it,PI:at}=Math,{moveTo:nt,lineTo:pt,closePath:ht,drawPoints:_t}=t.PathCommandDataHelper,dt=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)_t(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;nt(t,o,0);for(let e=1;e<r;e++)pt(t,o+o*ot(2*e*at/r),i-i*it(2*e*at/r))}ht(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(P)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(dt.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(dt.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:lt,cos:ut,PI:ct}=Math,{moveTo:yt,lineTo:xt,closePath:gt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];yt(a,o,0);for(let t=1;t<2*s;t++)xt(a,o+(t%2==0?o:o*r)*lt(t*ct/s),i-(t%2==0?i:i*r)*ut(t*ct/s));gt(a)}},e([t.dataProcessor(S)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(U)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image);const vt=exports.Image;exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0,e&&e.url&&this.drawImage(e.url)}drawImage(e){new t.LeaferImage({url:e}).load((e=>{this.context.drawImage(e.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:e}))}))}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceRender()}__drawAfterFill(t,e){const{width:s,height:r,cornerRadius:o}=this.__,{view:i}=this.canvas;o||this.pathInputed?(t.save(),t.clip(),t.drawImage(i,0,0,i.width,i.height,0,0,s,r),t.restore()):t.drawImage(i,0,0,i.width,i.height,0,0,s,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([r(100)],exports.Canvas.prototype,"width",void 0),e([r(100)],exports.Canvas.prototype,"height",void 0),e([r(1)],exports.Canvas.prototype,"pixelRatio",void 0),e([r(!0)],exports.Canvas.prototype,"smooth",void 0),e([r()],exports.Canvas.prototype,"contextSettings",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ft,includes:wt,isSame:mt,spread:Tt,setList:It}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:s,__baseLine:r,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-r,o.width,e<s?s:e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=i.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=g.number(r,a),e.__letterSpacing=g.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&Tt(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(y.x-=o,y.width+=s+o),u&&(y.y-=t,y.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();p&&(y.width+=.16*a);const x=wt(y,c)?y:c;mt(x,s.contentBounds)?e.__textBoxBounds=x:(s.contentBounds=x,s.renderChanged=!0,It(e.__textBoxBounds={},[y,c]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ft(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(k)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.dataType(!1)],exports.Text.prototype,"resizeFontSize",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:1.5})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(B)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},e([t.dataProcessor(b)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","beginPath","path","paint"]),t.registerUI()],exports.Pen),exports.BoxData=f,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=h,exports.EllipseData=R,exports.Export=_,exports.FrameData=m,exports.GroupData=v,exports.ImageData=U,exports.LeaferData=w,exports.LineData=T,exports.MyImage=vt,exports.Paint=n,exports.PaintGradient={},exports.PaintImage=p,exports.PathArrow=a,exports.PathData=B,exports.PenData=b,exports.PolygonData=P,exports.RectData=I,exports.RectRender=F,exports.StarData=S,exports.State=d,exports.TextConvert=i,exports.TextData=k,exports.Transition=l,exports.UIBounds=A,exports.UIData=x,exports.UIRender=E,exports.UnitConvert=g,exports.effectType=s,exports.resizeType=r,exports.zoomLayerType=o,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/draw",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "@leafer-ui/draw",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -29,10 +29,10 @@
29
29
  "leaferjs"
30
30
  ],
31
31
  "dependencies": {
32
- "@leafer/core": "1.0.2",
33
- "@leafer-ui/display": "1.0.2",
34
- "@leafer-ui/display-module": "1.0.2",
35
- "@leafer-ui/decorator": "1.0.2",
36
- "@leafer-ui/external": "1.0.2"
32
+ "@leafer/core": "1.0.4",
33
+ "@leafer-ui/display": "1.0.4",
34
+ "@leafer-ui/display-module": "1.0.4",
35
+ "@leafer-ui/decorator": "1.0.4",
36
+ "@leafer-ui/external": "1.0.4"
37
37
  }
38
38
  }