@leafer-in/editor 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/dist/editor.cjs CHANGED
@@ -14,9 +14,6 @@ const PathScaler = {
14
14
  command = data[i];
15
15
  switch (command) {
16
16
  case M:
17
- scalePoints(data, scaleX, scaleY, i, 1);
18
- i += 3;
19
- break;
20
17
  case L:
21
18
  scalePoints(data, scaleX, scaleY, i, 1);
22
19
  i += 3;
@@ -98,34 +95,34 @@ function scaleResize(leaf, scaleX, scaleY) {
98
95
  function scaleResizeFontSize(leaf, scaleX, scaleY) {
99
96
  const { app } = leaf;
100
97
  const editor = app && app.editor;
98
+ let fontScale = scaleX;
101
99
  if (editor.editing) {
102
100
  const layout = leaf.__layout;
103
101
  let { width, height } = layout.boxBounds;
104
- width *= (scaleY - scaleX) * (leaf.scaleX < 0 ? -1 : 1);
105
- height *= (scaleX - scaleY) * (leaf.scaleY < 0 ? -1 : 1);
102
+ width *= scaleY - scaleX;
103
+ height *= scaleX - scaleY;
106
104
  switch (editor.resizeDirection) {
107
105
  case top$1:
108
106
  case bottom$1:
109
- leaf.fontSize *= scaleY;
107
+ fontScale = scaleY;
110
108
  layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
111
109
  break;
112
110
  case left$2:
113
111
  case right$2:
114
- leaf.fontSize *= scaleX;
115
112
  layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
116
113
  break;
117
114
  case topLeft$1:
118
115
  case topRight$1:
119
- leaf.fontSize *= scaleX;
120
116
  layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
121
117
  break;
122
- default:
123
- leaf.fontSize *= scaleX;
124
118
  }
125
119
  }
126
- else {
127
- leaf.fontSize *= scaleX;
128
- }
120
+ leaf.fontSize *= fontScale;
121
+ const data = leaf.__;
122
+ if (!data.__autoWidth)
123
+ leaf.width *= fontScale;
124
+ if (!data.__autoHeight)
125
+ leaf.height *= fontScale;
129
126
  }
130
127
  function scaleResizePath(leaf, scaleX, scaleY) {
131
128
  PathScaler.scale(leaf.__.path, scaleX, scaleY);
@@ -171,7 +168,7 @@ leaf.resizeHeight = function (height) {
171
168
  this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
172
169
  };
173
170
  draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
174
- if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
171
+ if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
175
172
  scaleResizeFontSize(this, scaleX, scaleY);
176
173
  }
177
174
  else {
@@ -524,7 +521,7 @@ class EditSelect extends draw.Group {
524
521
  if (this.allowDrag(e)) {
525
522
  const { editor } = this;
526
523
  const { stroke, area } = editor.mergeConfig;
527
- const { x, y } = e.getInner(this);
524
+ const { x, y } = e.getInnerPoint(this);
528
525
  this.bounds.set(x, y);
529
526
  this.selectArea.setStyle({ visible: true, stroke, x, y }, area);
530
527
  this.selectArea.setBounds(this.bounds.get());
@@ -730,7 +727,7 @@ const EditDataHelper = {
730
727
  const nowHeight = boxBounds.height * element.scaleY;
731
728
  scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
732
729
  }
733
- toPoint(around || align, boxBounds, origin);
730
+ toPoint(around || align, boxBounds, origin, true);
734
731
  return { origin, scaleX, scaleY, direction, lockRatio, around };
735
732
  },
736
733
  getRotateData(bounds, direction, current, last, around) {
@@ -751,7 +748,7 @@ const EditDataHelper = {
751
748
  default:
752
749
  align = 'center';
753
750
  }
754
- toPoint(around || align, bounds, origin);
751
+ toPoint(around || align, bounds, origin, true);
755
752
  return { origin, rotation: draw.PointHelper.getRotation(last, origin, current) };
756
753
  },
757
754
  getSkewData(bounds, direction, move, around) {
@@ -778,10 +775,10 @@ const EditDataHelper = {
778
775
  align = 'left';
779
776
  skewY = 1;
780
777
  }
781
- const { x, y, width, height } = bounds;
782
- last.x = x + last.x * width;
783
- last.y = y + last.y * height;
784
- toPoint(around || align, bounds, origin);
778
+ const { width, height } = bounds;
779
+ last.x = last.x * width;
780
+ last.y = last.y * height;
781
+ toPoint(around || align, bounds, origin, true);
785
782
  const rotation = draw.PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
786
783
  skewX ? skewX = -rotation : skewY = rotation;
787
784
  return { origin, skewX, skewY };
@@ -1277,6 +1274,7 @@ function onTarget(editor, oldValue) {
1277
1274
  }
1278
1275
  else {
1279
1276
  editor.leafList.reset();
1277
+ editor.closeInnerEditor();
1280
1278
  }
1281
1279
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, { editor, value: target, oldValue }));
1282
1280
  editor.checkOpenedGroups();
@@ -1505,7 +1503,7 @@ class Editor extends draw.Group {
1505
1503
  let { around, lockRatio, resizeable, flipable, editSize } = this.mergeConfig;
1506
1504
  if (e instanceof core.ZoomEvent) {
1507
1505
  if (resizeable === 'zoom')
1508
- e.stop(), this.scaleOf(element.getInnerPoint(e), e.scale, e.scale);
1506
+ e.stop(), this.scaleOf(element.getBoxPoint(e), e.scale, e.scale);
1509
1507
  }
1510
1508
  else {
1511
1509
  const { direction } = e.current;
@@ -1530,13 +1528,13 @@ class Editor extends draw.Group {
1530
1528
  let origin, rotation;
1531
1529
  if (e instanceof core.RotateEvent) {
1532
1530
  if (rotateable === 'rotate')
1533
- e.stop(), rotation = e.rotation, origin = element.getInnerPoint(e);
1531
+ e.stop(), rotation = e.rotation, origin = element.getBoxPoint(e);
1534
1532
  else
1535
1533
  return;
1536
1534
  }
1537
1535
  else {
1538
1536
  const last = { x: e.x - e.moveX, y: e.y - e.moveY };
1539
- const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getInner(element), element.getInnerPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'));
1537
+ const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getBoxPoint(element), element.getBoxPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'));
1540
1538
  rotation = data.rotation;
1541
1539
  origin = data.origin;
1542
1540
  }
@@ -12,9 +12,6 @@ const PathScaler = {
12
12
  command = data[i];
13
13
  switch (command) {
14
14
  case M:
15
- scalePoints(data, scaleX, scaleY, i, 1);
16
- i += 3;
17
- break;
18
15
  case L:
19
16
  scalePoints(data, scaleX, scaleY, i, 1);
20
17
  i += 3;
@@ -96,34 +93,34 @@ function scaleResize(leaf, scaleX, scaleY) {
96
93
  function scaleResizeFontSize(leaf, scaleX, scaleY) {
97
94
  const { app } = leaf;
98
95
  const editor = app && app.editor;
96
+ let fontScale = scaleX;
99
97
  if (editor.editing) {
100
98
  const layout = leaf.__layout;
101
99
  let { width, height } = layout.boxBounds;
102
- width *= (scaleY - scaleX) * (leaf.scaleX < 0 ? -1 : 1);
103
- height *= (scaleX - scaleY) * (leaf.scaleY < 0 ? -1 : 1);
100
+ width *= scaleY - scaleX;
101
+ height *= scaleX - scaleY;
104
102
  switch (editor.resizeDirection) {
105
103
  case top$1:
106
104
  case bottom$1:
107
- leaf.fontSize *= scaleY;
105
+ fontScale = scaleY;
108
106
  layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
109
107
  break;
110
108
  case left$2:
111
109
  case right$2:
112
- leaf.fontSize *= scaleX;
113
110
  layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
114
111
  break;
115
112
  case topLeft$1:
116
113
  case topRight$1:
117
- leaf.fontSize *= scaleX;
118
114
  layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
119
115
  break;
120
- default:
121
- leaf.fontSize *= scaleX;
122
116
  }
123
117
  }
124
- else {
125
- leaf.fontSize *= scaleX;
126
- }
118
+ leaf.fontSize *= fontScale;
119
+ const data = leaf.__;
120
+ if (!data.__autoWidth)
121
+ leaf.width *= fontScale;
122
+ if (!data.__autoHeight)
123
+ leaf.height *= fontScale;
127
124
  }
128
125
  function scaleResizePath(leaf, scaleX, scaleY) {
129
126
  PathScaler.scale(leaf.__.path, scaleX, scaleY);
@@ -169,7 +166,7 @@ leaf.resizeHeight = function (height) {
169
166
  this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
170
167
  };
171
168
  Text.prototype.__scaleResize = function (scaleX, scaleY) {
172
- if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
169
+ if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
173
170
  scaleResizeFontSize(this, scaleX, scaleY);
174
171
  }
175
172
  else {
@@ -522,7 +519,7 @@ class EditSelect extends Group {
522
519
  if (this.allowDrag(e)) {
523
520
  const { editor } = this;
524
521
  const { stroke, area } = editor.mergeConfig;
525
- const { x, y } = e.getInner(this);
522
+ const { x, y } = e.getInnerPoint(this);
526
523
  this.bounds.set(x, y);
527
524
  this.selectArea.setStyle({ visible: true, stroke, x, y }, area);
528
525
  this.selectArea.setBounds(this.bounds.get());
@@ -728,7 +725,7 @@ const EditDataHelper = {
728
725
  const nowHeight = boxBounds.height * element.scaleY;
729
726
  scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
730
727
  }
731
- toPoint(around || align, boxBounds, origin);
728
+ toPoint(around || align, boxBounds, origin, true);
732
729
  return { origin, scaleX, scaleY, direction, lockRatio, around };
733
730
  },
734
731
  getRotateData(bounds, direction, current, last, around) {
@@ -749,7 +746,7 @@ const EditDataHelper = {
749
746
  default:
750
747
  align = 'center';
751
748
  }
752
- toPoint(around || align, bounds, origin);
749
+ toPoint(around || align, bounds, origin, true);
753
750
  return { origin, rotation: PointHelper.getRotation(last, origin, current) };
754
751
  },
755
752
  getSkewData(bounds, direction, move, around) {
@@ -776,10 +773,10 @@ const EditDataHelper = {
776
773
  align = 'left';
777
774
  skewY = 1;
778
775
  }
779
- const { x, y, width, height } = bounds;
780
- last.x = x + last.x * width;
781
- last.y = y + last.y * height;
782
- toPoint(around || align, bounds, origin);
776
+ const { width, height } = bounds;
777
+ last.x = last.x * width;
778
+ last.y = last.y * height;
779
+ toPoint(around || align, bounds, origin, true);
783
780
  const rotation = PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
784
781
  skewX ? skewX = -rotation : skewY = rotation;
785
782
  return { origin, skewX, skewY };
@@ -1275,6 +1272,7 @@ function onTarget(editor, oldValue) {
1275
1272
  }
1276
1273
  else {
1277
1274
  editor.leafList.reset();
1275
+ editor.closeInnerEditor();
1278
1276
  }
1279
1277
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, { editor, value: target, oldValue }));
1280
1278
  editor.checkOpenedGroups();
@@ -1503,7 +1501,7 @@ class Editor extends Group {
1503
1501
  let { around, lockRatio, resizeable, flipable, editSize } = this.mergeConfig;
1504
1502
  if (e instanceof ZoomEvent) {
1505
1503
  if (resizeable === 'zoom')
1506
- e.stop(), this.scaleOf(element.getInnerPoint(e), e.scale, e.scale);
1504
+ e.stop(), this.scaleOf(element.getBoxPoint(e), e.scale, e.scale);
1507
1505
  }
1508
1506
  else {
1509
1507
  const { direction } = e.current;
@@ -1528,13 +1526,13 @@ class Editor extends Group {
1528
1526
  let origin, rotation;
1529
1527
  if (e instanceof RotateEvent) {
1530
1528
  if (rotateable === 'rotate')
1531
- e.stop(), rotation = e.rotation, origin = element.getInnerPoint(e);
1529
+ e.stop(), rotation = e.rotation, origin = element.getBoxPoint(e);
1532
1530
  else
1533
1531
  return;
1534
1532
  }
1535
1533
  else {
1536
1534
  const last = { x: e.x - e.moveX, y: e.y - e.moveY };
1537
- const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getInner(element), element.getInnerPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'));
1535
+ const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getBoxPoint(element), element.getBoxPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'));
1538
1536
  rotation = data.rotation;
1539
1537
  origin = data.origin;
1540
1538
  }
@@ -1 +1 @@
1
- import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as n,Line as r,Polygon as a,Group as h,Box as l,Event as d,defineKey as c,UI as g,Paint as u,Rect as f,Answer as p,Bounds as m,LeafList as v,PointHelper as b,AroundHelper as _,MathHelper as y,Matrix as w,Debug as L,DataHelper as E,LeafHelper as k,RenderEvent as x,getPointData as S,Creator as O}from"@leafer-ui/draw";import{PointerEvent as T,DragEvent as M,MoveEvent as P,ZoomEvent as C,RotateEvent as V,KeyEvent as R}from"@leafer-ui/core";const{M:B,L:I,C:H,Q:z,Z:D,N:A,D:Z,X:W,G:F,F:X,O:Y,P:G,U:U}=t,N={scale(t,e,i){if(!t)return;let s,o=0,n=t.length;for(;o<n;)switch(s=t[o],s){case B:case I:j(t,e,i,o,1),o+=3;break;case H:j(t,e,i,o,3),o+=7;break;case z:j(t,e,i,o,2),o+=5;break;case D:o+=1;break;case A:j(t,e,i,o,2),o+=5;break;case Z:j(t,e,i,o,2),o+=9;break;case W:j(t,e,i,o,2),o+=6;break;case F:j(t,e,i,o,2),o+=9;break;case X:j(t,e,i,o,2),o+=5;break;case Y:t[o]=F,t.splice(o+4,0,t[o+3],0),j(t,e,i,o,2),o+=9,n+=2;break;case G:t[o]=X,t.splice(o+4,0,t[o+3]),j(t,e,i,o,2),o+=5,n+=1;break;case U:j(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let n=o?s+1:0,r=o?n+2*o:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:j}=N,K=e.get(),{topLeft:$,top:q,topRight:Q,right:J,bottom:tt,left:et}=i;function it(t,e,i){t.pathInputed?ot(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function st(t,e,i){const{app:s}=t,o=s&&s.editor;if(o.editing){const s=t.__layout;let{width:n,height:r}=s.boxBounds;switch(n*=(i-e)*(t.scaleX<0?-1:1),r*=(e-i)*(t.scaleY<0?-1:1),o.resizeDirection){case q:case tt:t.fontSize*=i,s.affectScaleOrRotation?t.moveInner(-n/2,0):t.x-=n/2;break;case et:case J:t.fontSize*=e,s.affectScaleOrRotation?t.moveInner(0,-r/2):t.y-=r/2;break;case $:case Q:t.fontSize*=e,s.affectScaleOrRotation?t.moveInner(0,-r):t.y-=r;break;default:t.fontSize*=e}}else t.fontSize*=e}function ot(t,e,i){N.scale(t.__.path,e,i),t.path=t.__.path}function nt(t,e,i){N.scalePoints(t.__.points,e,i),t.points=t.__.points}function rt(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)K.a=e,K.d=i,s[t].transform(K,!0)}const at=s.prototype;function ht(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function lt(t){return t?t instanceof Array?t:[t]:[]}at.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},at.__scaleResize=function(t,e){it(this,t,e)},at.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},at.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},o.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?st(this,t,e):it(this,t,e)},n.prototype.__scaleResize=function(t,e){ot(this,t,e)},r.prototype.__scaleResize=function(t,e){this.pathInputed?ot(this,t,e):this.points?nt(this,t,e):this.width*=t},a.prototype.__scaleResize=function(t,e){this.pathInputed?ot(this,t,e):this.points?nt(this,t,e):it(this,t,e)},h.prototype.__scaleResize=function(t,e){rt(this,t,e)},l.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?rt(this,t,e):(it(this,t,e),this.__.resizeChildren&&rt(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class dt extends d{get list(){return lt(this.value)}get oldList(){return lt(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}dt.SELECT="editor.select",dt.HOVER="editor.hover";class ct extends dt{constructor(t,e){super(t,e)}}ct.MOVE="editor.move";class gt extends dt{constructor(t,e){super(t,e)}}gt.SCALE="editor.scale";class ut extends dt{constructor(t,e){super(t,e)}}ut.ROTATE="editor.rotate";class ft extends dt{constructor(t,e){super(t,e)}}function pt(t){return(e,i)=>{const s="_"+i;c(e,i,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}ft.SKEW="editor.skew";const mt=e.get(),{abs:vt}=Math,{copy:bt,scale:_t}=e;class yt extends g{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,e){const{list:i}=this;if(i.length){let s;const{stroke:o,strokeWidth:n,fill:r}=this.__,{bounds:a}=e;for(let h=0;h<i.length;h++)if(s=i[h],a&&a.hit(s.__world,e.matrix)){const i=vt(s.__world.scaleX),a=vt(s.__world.scaleY);if(i!==a){bt(mt,s.__world),_t(mt,1/i,1/a),t.setWorld(mt,e.matrix),t.beginPath(),this.__.strokeWidth=n;const{x:o,y:r,width:h,height:l}=s.__layout.boxBounds;t.rect(o*i,r*a,h*i,l*a)}else t.setWorld(s.__world,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=n/vt(s.__world.scaleX);o&&("string"==typeof o?u.stroke(o,this,t):u.strokes(o,this,t)),r&&("string"==typeof r?u.fill(r,this,t):u.fills(r,this,t))}this.__.strokeWidth=n}}destroy(){this.target=null,super.destroy()}}ht([pt((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],yt.prototype,"target",void 0);class wt extends h{constructor(t){super(t),this.strokeArea=new f({strokeAlign:"center"}),this.fillArea=new f,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:o}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:o},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:Lt,Yes:Et,NoAndSkip:kt,YesAndSkip:xt}=p,St={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?xt:kt;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?xt:Lt;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return Et}return Lt}return t.isBranch?kt:Lt}},{findOne:Ot}=St;class Tt extends h{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new yt,this.targetStroker=new yt,this.bounds=new m,this.selectArea=new wt,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,s/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInner(this);this.bounds.set(o,n),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:n},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new v(e.app.find(St.findBounds,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),o.length){const t=[];this.originList.forEach((e=>{o.has(e)||t.push(e)})),o.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!Ot(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new v(this.editor.editBox.rect)};return Ot(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Ot(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(dt.HOVER,this.onHover,this),t.on_(dt.SELECT,this.onSelect,this),e.on_(T.MOVE,this.onPointerMove,this),e.on_(T.BEFORE_DOWN,this.onBeforeDown,this),e.on_(T.TAP,this.onTap,this),e.on_(M.START,this.onDragStart,this,!0),e.on_(M.DRAG,this.onDrag,this),e.on_(M.END,this.onDragEnd,this),e.on_(P.MOVE,this.onAutoMove,this),e.on_([C.ZOOM,P.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Mt,top:Pt,topRight:Ct,right:Vt,bottomRight:Rt,bottom:Bt,bottomLeft:It,left:Ht}=i,{toPoint:zt}=_,{within:Dt}=y,At={getScaleData(t,e,i,s,o,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,_=v<0?-1:1,y=b<0?-1:1,w=a?v:_*g.width/p,L=a?b:y*g.height/m;s.x*=a?v:_,s.y*=a?b:y,Math.abs(s.x)===p&&(s.x+=.1),Math.abs(s.y)===m&&(s.y+=.1);const E=(-s.y+m)/m,k=(s.x+p)/p,x=(s.y+m)/m,S=(-s.x+p)/p;switch(i){case Pt:c=E,h="bottom";break;case Vt:d=k,h="left";break;case Bt:c=x,h="top";break;case Ht:d=S,h="right";break;case Mt:c=E,d=S,h="bottom-right";break;case Ct:c=E,d=k,h="bottom-left";break;case Rt:c=x,d=k,h="top-left";break;case It:c=x,d=S,h="top-right"}if(o){if(!("corner"===o&&i%2)){let t;switch(i){case Pt:case Bt:t=c;break;case Ht:case Vt:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=w,c/=L,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=Dt(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=Dt(e*c,f)/e}return zt(n||h,g,l),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:o,around:n}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case Mt:n="bottom-right";break;case Ct:n="bottom-left";break;case Rt:n="top-left";break;case It:n="top-right";break;default:n="center"}return zt(o||n,t,r),{origin:r,rotation:b.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case Pt:n={x:.5,y:0},o="bottom",a=1;break;case Bt:n={x:.5,y:1},o="top",a=1;break;case Ht:n={x:0,y:.5},o="right",h=1;break;case Vt:n={x:1,y:.5},o="left",h=1}const{x:l,y:d,width:c,height:g}=t;n.x=l+n.x*c,n.y=d+n.y*g,zt(s||o,t,r);const u=b.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-u:h=u,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Ht:t=Vt;break;case Mt:t=Ct;break;case It:t=Rt;break;case Vt:t=Ht;break;case Ct:t=Mt;break;case Rt:t=It}if(i)switch(t){case Pt:t=Bt;break;case Mt:t=It;break;case Ct:t=Rt;break;case Bt:t=Pt;break;case It:t=Mt;break;case Rt:t=Ct}return t}},Zt={};function Wt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:o}=i;const{resizeCursor:n,rotateCursor:r,skewCursor:a,resizeable:h,rotateable:l,skewable:d}=t.mergeConfig,{pointType:c}=s,{flippedX:g,flippedY:u}=i;let f="resize"===c;f&&l&&(e.metaKey||e.ctrlKey||!h)&&(f=!1);const p=d&&!f&&"resize-line"===s.name?a:f?n:r;o+=45*(At.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(y.formatRotation(o,!0)/2);const{url:m,x:v,y:b}=p,_=m+o;Zt[_]?s.cursor=Zt[_]:Zt[_]=s.cursor={url:Xt(m,o),x:v,y:b}}function Ft(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function Xt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Yt extends l{}const Gt=["top","right","bottom","left"];class Ut extends h{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new h,this.rect=new l({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Yt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new h({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:n,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Yt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Yt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Yt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,h,l,...r,...o),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:o,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:h}=t,l=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:l[t/2%l.length])),t%2||(c.rotation=t/2*90);o.set(this.getPointStyle(t.circle||t.rotatePoint||l[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i&&!!h,e.syncEventer=i&&h?s:null,this.app.interaction.bottomList=i&&h?[{target:s,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:e}=this.editor,{width:i,height:s}=t,{rect:o,circle:n,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=e,f="number"==typeof u?u:10,p=!(u&&i<f&&s<f);let m,v,b,y={};for(let o=0;o<8;o++)_.toPoint(_.directionData[o],t,y),v=a[o],m=h[o],b=l[Math.floor(o/2)],v.set(y),m.set(y),b.set(y),v.visible=b.visible=p&&!(!c&&!g),m.visible=p&&g&&c&&!e.rotatePoint,o%2&&(v.visible=m.visible=p&&!!d,(o+1)/2%2?(b.width=i,v.width>i-30&&(v.visible=!1)):(b.height=s,v.rotation=90,v.width>s-30&&(v.visible=!1)));n.visible=p&&g&&!(!e.circle&&!e.rotatePoint),n.visible&&this.layoutCircle(e),o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0})),r.visible=p&&r.children.length>0,r.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:o,middlePoint:n}=t,r=Gt.indexOf(e||(this.buttons.children.length&&"bottom"===o?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=Gt.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?At.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,o,!!n),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*r;n?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:n}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:o,height:o,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),Wt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(M.START,this.onDragStart,this),t.on_(M.DRAG,this.onDrag,this),t.on_(M.END,this.onDragEnd,this),t.on_(T.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(T.ENTER,(e=>{this.enterPoint=t,Wt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(dt.SELECT,this.onSelect,this),t.on_(M.START,this.onDragStart,this),t.on_(M.DRAG,e.onMove,e),t.on_(M.END,this.onDragEnd,this),t.on_(T.ENTER,(()=>Ft(e))),t.on_(T.DOUBLE_TAP,this.onDoubleTap,this),t.on_(T.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class Nt extends g{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:o}=i.editBox,{width:n,height:r}=o.__;t.resetTransform(),t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const jt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Kt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${jt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${jt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${jt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0};function $t(t){const{simulateTarget:e,leafList:i}=t,{x:s,y:o,width:n,height:r}=(new m).setListWithFn(i.list,(t=>t.worldBoxBounds)),a=e.parent=i.list[0].leafer.zoomLayer,{scaleX:h,scaleY:l,e:d,f:c}=a.__world;e.reset({x:(s-d)/h,y:(o-c)/l,width:n/h,height:r/l})}const qt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Qt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Jt={group(t,e,i){t.sort(Qt);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new h(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(qt);const r=new w(e.worldTransform);return r.divideParent(o.worldTransform),n.setTransform(r),n.editable=!0,n.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(n))),s.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(qt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Qt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},te=L.get("EditToolCreator");function ee(){return t=>{se.register(t)}}const ie=ee,se={list:{},register(t){const{tag:e}=t.prototype;oe[e]?te.repeat(e):oe[e]=t},get:(t,e)=>new oe[t](e)},{list:oe}=se;class ne extends dt{constructor(t,e){super(t,e)}}ne.BEFORE_OPEN="innerEditor.before_open",ne.OPEN="innerEditor.open",ne.BEFORE_CLOSE="innerEditor.before_close",ne.CLOSE="innerEditor.close";class re extends dt{constructor(t,e){super(t,e)}}re.GROUP="editor.group",re.BEFORE_UNGROUP="editor.before_ungroup",re.UNGROUP="editor.ungroup",re.OPEN="editor.open_group",re.CLOSE="editor.close_group";class ae extends h{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=E.clone(Kt),this.leafList=new v,this.openedGroupList=new v,this.simulateTarget=new f({visible:!1}),this.editBox=new Ut(this),this.editToolList={},this.selector=new Tt(this),this.editMask=new Nt(this),this.targetEventIds=[],t&&(this.config=E.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&$t(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||se.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof P){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(M.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:o,flipable:n,editSize:r}=this.mergeConfig;if(t instanceof C)"zoom"===o&&(t.stop(),this.scaleOf(e.getInnerPoint(t),t.scale,t.scale));else{const{direction:o}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=At.getScaleData(e,this.dragStartBounds,o,t.getInnerTotal(e),s,At.getAround(i,t.altKey),n,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:o}=this.mergeConfig,{direction:n,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:a}=this;let h,l;if(t instanceof V){if("rotate"!==i)return;t.stop(),l=t.rotation,h=a.getInnerPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=At.getRotateData(a.boxBounds,n,t.getInner(a),a.getInnerPoint(e),t.shiftKey?null:a.around||a.origin||s||"center");l=i.rotation,h=i.origin}l=y.getGapRotation(l,o,a.rotation),l&&(a.scaleX*a.scaleY<0&&(l=-l),this.rotateOf(h,y.float(l,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=At.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),At.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),o=new ct(ct.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=new gt(gt.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.scaleOf(t,e,i))),a=new gt(gt.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(this.element.locked)return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.flip(t))):new w(k.getFlipTransform(e,t)),o=new gt(gt.SCALE,{target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,s=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.rotateOf(t,e))),n=new ut(ut.ROTATE,{target:i,editor:this,worldOrigin:s,rotation:e,transform:o});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.skewOf(t,e,i))),a=new ft(ft.SKEW,{target:o,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}getWorldOrigin(t){return this.element.getWorldPoint(k.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this,i=new w(e.worldTransform);return t(),new w(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.target=Jt.group(this.list,this.element,t),this.emitGroupEvent(re.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(re.BEFORE_UNGROUP,t))),this.target=Jt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(re.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(re.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(re.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!k.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new re(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&se.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||se.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(ne.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(ne.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(ne.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(ne.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new ne(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(Jt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Jt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[this.app.on_(P.BEFORE_MOVE,this.onMove,this,!0),this.app.on_(C.BEFORE_ZOOM,this.onScale,this,!0),this.app.on_(V.BEFORE_ROTATE,this.onRotate,this,!0),t.on_(x.START,this.update,this),t.on_([R.HOLD,R.UP],(t=>{Wt(this,t)})),t.on_(R.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}ht([pt((function(t,e){t.emitEvent(new dt(dt.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],ae.prototype,"hoverTarget",void 0),ht([pt((function(t,e){const{target:i}=t;i?t.leafList=i instanceof v?i:new v(i):t.leafList.reset(),t.emitEvent(new dt(dt.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&$t(t),Ft(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],ae.prototype,"target",void 0);class he{static registerInnerEditor(){se.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new h,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let le=class extends he{static registerEditTool(){se.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:n}=s;o.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(o,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:n,list:r}=o;n.lockLayout(),r.forEach((t=>{const n="scale"!==o.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(s,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(o,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:s}=t;t.multiple&&i.parent.updateLayout();const{x:o,y:n,scaleX:r,scaleY:a,rotation:h,skewX:l,skewY:d,width:c,height:g}=s.getLayoutBounds("box",t,!0);e.set({x:o,y:n,scaleX:r,scaleY:a,rotation:h,skewX:l,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};le=ht([ee()],le);const{left:de,right:ce}=i,{move:ge,copy:ue}=b;let fe=class extends le{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,n=t.target,r=i===de;if(n.pathInputed){const{path:t}=n.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,n.path=t}else if(n.points){const{points:t}=n,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,n.points=t}else{const t=S(),{toPoint:i}=n;n.rotation=0,this.dragPoint(t,i,r,o,this.getInnerMove(n,e,s)),n.getLocalPointByInner(t,null,null,!0),n.getLocalPointByInner(i,null,null,!0),n.x=t.x,n.y=t.y,n.getInnerPointByLocal(i,null,null,!0),n.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(ge(t,n,r),s&&ge(e,-n,-r)):(s&&ge(t,-n,-r),ge(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),ue(s[7],i),ue(e[7],i),ue(s[3],a),ue(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===de||t===ce,s[t].visible=a,e[t].visible=!r&&a}};fe=ht([ee()],fe),O.editor=function(t){return new ae(t)},g.setEditConfig=function(t){c(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},g.setEditOuter=function(t){c(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},g.setEditInner=function(t){c(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{Ut as EditBox,At as EditDataHelper,Yt as EditPoint,Tt as EditSelect,St as EditSelectHelper,le as EditTool,se as EditToolCreator,ae as Editor,dt as EditorEvent,re as EditorGroupEvent,Jt as EditorHelper,ct as EditorMoveEvent,ut as EditorRotateEvent,gt as EditorScaleEvent,ft as EditorSkewEvent,he as InnerEditor,ne as InnerEditorEvent,fe as LineEditTool,N as PathScaler,wt as SelectArea,yt as Stroker,ee as registerEditTool,ie as registerInnerEditor,it as scaleResize,st as scaleResizeFontSize,rt as scaleResizeGroup,ot as scaleResizePath,nt as scaleResizePoints};
1
+ import{PathCommandMap as t,MatrixHelper as e,Direction9 as i,Leaf as s,Text as o,Path as n,Line as r,Polygon as a,Group as h,Box as l,Event as d,defineKey as c,UI as g,Paint as u,Rect as f,Answer as p,Bounds as m,LeafList as v,PointHelper as b,AroundHelper as _,MathHelper as y,Matrix as w,Debug as L,DataHelper as E,LeafHelper as k,RenderEvent as x,getPointData as O,Creator as S}from"@leafer-ui/draw";import{PointerEvent as T,DragEvent as M,MoveEvent as P,ZoomEvent as B,RotateEvent as C,KeyEvent as V}from"@leafer-ui/core";const{M:R,L:H,C:I,Q:D,Z:z,N:A,D:Z,X:W,G:F,F:X,O:Y,P:G,U:U}=t,N={scale(t,e,i){if(!t)return;let s,o=0,n=t.length;for(;o<n;)switch(s=t[o],s){case R:case H:j(t,e,i,o,1),o+=3;break;case I:j(t,e,i,o,3),o+=7;break;case D:j(t,e,i,o,2),o+=5;break;case z:o+=1;break;case A:j(t,e,i,o,2),o+=5;break;case Z:j(t,e,i,o,2),o+=9;break;case W:j(t,e,i,o,2),o+=6;break;case F:j(t,e,i,o,2),o+=9;break;case X:j(t,e,i,o,2),o+=5;break;case Y:t[o]=F,t.splice(o+4,0,t[o+3],0),j(t,e,i,o,2),o+=9,n+=2;break;case G:t[o]=X,t.splice(o+4,0,t[o+3]),j(t,e,i,o,2),o+=5,n+=1;break;case U:j(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let n=o?s+1:0,r=o?n+2*o:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:j}=N,K=e.get(),{topLeft:$,top:q,topRight:Q,right:J,bottom:tt,left:et}=i;function it(t,e,i){t.pathInputed?ot(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function st(t,e,i){const{app:s}=t,o=s&&s.editor;let n=e;if(o.editing){const s=t.__layout;let{width:r,height:a}=s.boxBounds;switch(r*=i-e,a*=e-i,o.resizeDirection){case q:case tt:n=i,s.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case et:case J:s.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case $:case Q:s.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__;r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}function ot(t,e,i){N.scale(t.__.path,e,i),t.path=t.__.path}function nt(t,e,i){N.scalePoints(t.__.points,e,i),t.points=t.__.points}function rt(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)K.a=e,K.d=i,s[t].transform(K,!0)}const at=s.prototype;function ht(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function lt(t){return t?t instanceof Array?t:[t]:[]}at.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},at.__scaleResize=function(t,e){it(this,t,e)},at.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},at.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},o.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?st(this,t,e):it(this,t,e)},n.prototype.__scaleResize=function(t,e){ot(this,t,e)},r.prototype.__scaleResize=function(t,e){this.pathInputed?ot(this,t,e):this.points?nt(this,t,e):this.width*=t},a.prototype.__scaleResize=function(t,e){this.pathInputed?ot(this,t,e):this.points?nt(this,t,e):it(this,t,e)},h.prototype.__scaleResize=function(t,e){rt(this,t,e)},l.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?rt(this,t,e):(it(this,t,e),this.__.resizeChildren&&rt(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class dt extends d{get list(){return lt(this.value)}get oldList(){return lt(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}dt.SELECT="editor.select",dt.HOVER="editor.hover";class ct extends dt{constructor(t,e){super(t,e)}}ct.MOVE="editor.move";class gt extends dt{constructor(t,e){super(t,e)}}gt.SCALE="editor.scale";class ut extends dt{constructor(t,e){super(t,e)}}ut.ROTATE="editor.rotate";class ft extends dt{constructor(t,e){super(t,e)}}function pt(t){return(e,i)=>{const s="_"+i;c(e,i,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}ft.SKEW="editor.skew";const mt=e.get(),{abs:vt}=Math,{copy:bt,scale:_t}=e;class yt extends g{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,e){const{list:i}=this;if(i.length){let s;const{stroke:o,strokeWidth:n,fill:r}=this.__,{bounds:a}=e;for(let h=0;h<i.length;h++)if(s=i[h],a&&a.hit(s.__world,e.matrix)){const i=vt(s.__world.scaleX),a=vt(s.__world.scaleY);if(i!==a){bt(mt,s.__world),_t(mt,1/i,1/a),t.setWorld(mt,e.matrix),t.beginPath(),this.__.strokeWidth=n;const{x:o,y:r,width:h,height:l}=s.__layout.boxBounds;t.rect(o*i,r*a,h*i,l*a)}else t.setWorld(s.__world,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=n/vt(s.__world.scaleX);o&&("string"==typeof o?u.stroke(o,this,t):u.strokes(o,this,t)),r&&("string"==typeof r?u.fill(r,this,t):u.fills(r,this,t))}this.__.strokeWidth=n}}destroy(){this.target=null,super.destroy()}}ht([pt((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],yt.prototype,"target",void 0);class wt extends h{constructor(t){super(t),this.strokeArea=new f({strokeAlign:"center"}),this.fillArea=new f,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:o}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:o},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:Lt,Yes:Et,NoAndSkip:kt,YesAndSkip:xt}=p,Ot={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?xt:kt;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?xt:Lt;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return Et}return Lt}return t.isBranch?kt:Lt}},{findOne:St}=Ot;class Tt extends h{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new yt,this.targetStroker=new yt,this.bounds=new m,this.selectArea=new wt,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,s/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInnerPoint(this);this.bounds.set(o,n),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:n},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new v(e.app.find(Ot.findBounds,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),o.length){const t=[];this.originList.forEach((e=>{o.has(e)||t.push(e)})),o.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!St(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new v(this.editor.editBox.rect)};return St(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):St(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(dt.HOVER,this.onHover,this),t.on_(dt.SELECT,this.onSelect,this),e.on_(T.MOVE,this.onPointerMove,this),e.on_(T.BEFORE_DOWN,this.onBeforeDown,this),e.on_(T.TAP,this.onTap,this),e.on_(M.START,this.onDragStart,this,!0),e.on_(M.DRAG,this.onDrag,this),e.on_(M.END,this.onDragEnd,this),e.on_(P.MOVE,this.onAutoMove,this),e.on_([B.ZOOM,P.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Mt,top:Pt,topRight:Bt,right:Ct,bottomRight:Vt,bottom:Rt,bottomLeft:Ht,left:It}=i,{toPoint:Dt}=_,{within:zt}=y,At={getScaleData(t,e,i,s,o,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,_=v<0?-1:1,y=b<0?-1:1,w=a?v:_*g.width/p,L=a?b:y*g.height/m;s.x*=a?v:_,s.y*=a?b:y,Math.abs(s.x)===p&&(s.x+=.1),Math.abs(s.y)===m&&(s.y+=.1);const E=(-s.y+m)/m,k=(s.x+p)/p,x=(s.y+m)/m,O=(-s.x+p)/p;switch(i){case Pt:c=E,h="bottom";break;case Ct:d=k,h="left";break;case Rt:c=x,h="top";break;case It:d=O,h="right";break;case Mt:c=E,d=O,h="bottom-right";break;case Bt:c=E,d=k,h="bottom-left";break;case Vt:c=x,d=k,h="top-left";break;case Ht:c=x,d=O,h="top-right"}if(o){if(!("corner"===o&&i%2)){let t;switch(i){case Pt:case Rt:t=c;break;case It:case Ct:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=w,c/=L,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=zt(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=zt(e*c,f)/e}return Dt(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:o,around:n}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case Mt:n="bottom-right";break;case Bt:n="bottom-left";break;case Vt:n="top-left";break;case Ht:n="top-right";break;default:n="center"}return Dt(o||n,t,r,!0),{origin:r,rotation:b.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case Pt:n={x:.5,y:0},o="bottom",a=1;break;case Rt:n={x:.5,y:1},o="top",a=1;break;case It:n={x:0,y:.5},o="right",h=1;break;case Ct:n={x:1,y:.5},o="left",h=1}const{width:l,height:d}=t;n.x=n.x*l,n.y=n.y*d,Dt(s||o,t,r,!0);const c=b.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case It:t=Ct;break;case Mt:t=Bt;break;case Ht:t=Vt;break;case Ct:t=It;break;case Bt:t=Mt;break;case Vt:t=Ht}if(i)switch(t){case Pt:t=Rt;break;case Mt:t=Ht;break;case Bt:t=Vt;break;case Rt:t=Pt;break;case Ht:t=Mt;break;case Vt:t=Bt}return t}},Zt={};function Wt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:o}=i;const{resizeCursor:n,rotateCursor:r,skewCursor:a,resizeable:h,rotateable:l,skewable:d}=t.mergeConfig,{pointType:c}=s,{flippedX:g,flippedY:u}=i;let f="resize"===c;f&&l&&(e.metaKey||e.ctrlKey||!h)&&(f=!1);const p=d&&!f&&"resize-line"===s.name?a:f?n:r;o+=45*(At.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(y.formatRotation(o,!0)/2);const{url:m,x:v,y:b}=p,_=m+o;Zt[_]?s.cursor=Zt[_]:Zt[_]=s.cursor={url:Xt(m,o),x:v,y:b}}function Ft(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function Xt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Yt extends l{}const Gt=["top","right","bottom","left"];class Ut extends h{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new h,this.rect=new l({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Yt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new h({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:n,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Yt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Yt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Yt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,h,l,...r,...o),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:o,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:h}=t,l=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:l[t/2%l.length])),t%2||(c.rotation=t/2*90);o.set(this.getPointStyle(t.circle||t.rotatePoint||l[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i&&!!h,e.syncEventer=i&&h?s:null,this.app.interaction.bottomList=i&&h?[{target:s,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:e}=this.editor,{width:i,height:s}=t,{rect:o,circle:n,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=e,f="number"==typeof u?u:10,p=!(u&&i<f&&s<f);let m,v,b,y={};for(let o=0;o<8;o++)_.toPoint(_.directionData[o],t,y),v=a[o],m=h[o],b=l[Math.floor(o/2)],v.set(y),m.set(y),b.set(y),v.visible=b.visible=p&&!(!c&&!g),m.visible=p&&g&&c&&!e.rotatePoint,o%2&&(v.visible=m.visible=p&&!!d,(o+1)/2%2?(b.width=i,v.width>i-30&&(v.visible=!1)):(b.height=s,v.rotation=90,v.width>s-30&&(v.visible=!1)));n.visible=p&&g&&!(!e.circle&&!e.rotatePoint),n.visible&&this.layoutCircle(e),o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0})),r.visible=p&&r.children.length>0,r.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:o,middlePoint:n}=t,r=Gt.indexOf(e||(this.buttons.children.length&&"bottom"===o?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=Gt.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?At.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,o,!!n),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*r;n?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:n}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:o,height:o,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),Wt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(M.START,this.onDragStart,this),t.on_(M.DRAG,this.onDrag,this),t.on_(M.END,this.onDragEnd,this),t.on_(T.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(T.ENTER,(e=>{this.enterPoint=t,Wt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(dt.SELECT,this.onSelect,this),t.on_(M.START,this.onDragStart,this),t.on_(M.DRAG,e.onMove,e),t.on_(M.END,this.onDragEnd,this),t.on_(T.ENTER,(()=>Ft(e))),t.on_(T.DOUBLE_TAP,this.onDoubleTap,this),t.on_(T.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class Nt extends g{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:o}=i.editBox,{width:n,height:r}=o.__;t.resetTransform(),t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const jt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Kt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${jt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${jt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${jt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0};function $t(t){const{simulateTarget:e,leafList:i}=t,{x:s,y:o,width:n,height:r}=(new m).setListWithFn(i.list,(t=>t.worldBoxBounds)),a=e.parent=i.list[0].leafer.zoomLayer,{scaleX:h,scaleY:l,e:d,f:c}=a.__world;e.reset({x:(s-d)/h,y:(o-c)/l,width:n/h,height:r/l})}const qt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Qt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Jt={group(t,e,i){t.sort(Qt);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new h(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(qt);const r=new w(e.worldTransform);return r.divideParent(o.worldTransform),n.setTransform(r),n.editable=!0,n.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(n))),s.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(qt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Qt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},te=L.get("EditToolCreator");function ee(){return t=>{se.register(t)}}const ie=ee,se={list:{},register(t){const{tag:e}=t.prototype;oe[e]?te.repeat(e):oe[e]=t},get:(t,e)=>new oe[t](e)},{list:oe}=se;class ne extends dt{constructor(t,e){super(t,e)}}ne.BEFORE_OPEN="innerEditor.before_open",ne.OPEN="innerEditor.open",ne.BEFORE_CLOSE="innerEditor.before_close",ne.CLOSE="innerEditor.close";class re extends dt{constructor(t,e){super(t,e)}}re.GROUP="editor.group",re.BEFORE_UNGROUP="editor.before_ungroup",re.UNGROUP="editor.ungroup",re.OPEN="editor.open_group",re.CLOSE="editor.close_group";class ae extends h{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=E.clone(Kt),this.leafList=new v,this.openedGroupList=new v,this.simulateTarget=new f({visible:!1}),this.editBox=new Ut(this),this.editToolList={},this.selector=new Tt(this),this.editMask=new Nt(this),this.targetEventIds=[],t&&(this.config=E.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&$t(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||se.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof P){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(M.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:o,flipable:n,editSize:r}=this.mergeConfig;if(t instanceof B)"zoom"===o&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:o}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=At.getScaleData(e,this.dragStartBounds,o,t.getInnerTotal(e),s,At.getAround(i,t.altKey),n,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:o}=this.mergeConfig,{direction:n,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:a}=this;let h,l;if(t instanceof C){if("rotate"!==i)return;t.stop(),l=t.rotation,h=a.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=At.getRotateData(a.boxBounds,n,t.getBoxPoint(a),a.getBoxPoint(e),t.shiftKey?null:a.around||a.origin||s||"center");l=i.rotation,h=i.origin}l=y.getGapRotation(l,o,a.rotation),l&&(a.scaleX*a.scaleY<0&&(l=-l),this.rotateOf(h,y.float(l,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=At.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),At.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),o=new ct(ct.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=new gt(gt.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.scaleOf(t,e,i))),a=new gt(gt.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(this.element.locked)return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.flip(t))):new w(k.getFlipTransform(e,t)),o=new gt(gt.SCALE,{target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,s=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.rotateOf(t,e))),n=new ut(ut.ROTATE,{target:i,editor:this,worldOrigin:s,rotation:e,transform:o});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.skewOf(t,e,i))),a=new ft(ft.SKEW,{target:o,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}getWorldOrigin(t){return this.element.getWorldPoint(k.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this,i=new w(e.worldTransform);return t(),new w(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.target=Jt.group(this.list,this.element,t),this.emitGroupEvent(re.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(re.BEFORE_UNGROUP,t))),this.target=Jt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(re.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(re.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(re.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!k.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new re(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&se.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||se.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(ne.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(ne.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(ne.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(ne.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new ne(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(Jt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Jt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[this.app.on_(P.BEFORE_MOVE,this.onMove,this,!0),this.app.on_(B.BEFORE_ZOOM,this.onScale,this,!0),this.app.on_(C.BEFORE_ROTATE,this.onRotate,this,!0),t.on_(x.START,this.update,this),t.on_([V.HOLD,V.UP],(t=>{Wt(this,t)})),t.on_(V.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}ht([pt((function(t,e){t.emitEvent(new dt(dt.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],ae.prototype,"hoverTarget",void 0),ht([pt((function(t,e){const{target:i}=t;i?t.leafList=i instanceof v?i:new v(i):(t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new dt(dt.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&$t(t),Ft(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],ae.prototype,"target",void 0);class he{static registerInnerEditor(){se.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new h,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let le=class extends he{static registerEditTool(){se.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:n}=s;o.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(o,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:n,list:r}=o;n.lockLayout(),r.forEach((t=>{const n="scale"!==o.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(s,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(o,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:s}=t;t.multiple&&i.parent.updateLayout();const{x:o,y:n,scaleX:r,scaleY:a,rotation:h,skewX:l,skewY:d,width:c,height:g}=s.getLayoutBounds("box",t,!0);e.set({x:o,y:n,scaleX:r,scaleY:a,rotation:h,skewX:l,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};le=ht([ee()],le);const{left:de,right:ce}=i,{move:ge,copy:ue}=b;let fe=class extends le{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,n=t.target,r=i===de;if(n.pathInputed){const{path:t}=n.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,n.path=t}else if(n.points){const{points:t}=n,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,n.points=t}else{const t=O(),{toPoint:i}=n;n.rotation=0,this.dragPoint(t,i,r,o,this.getInnerMove(n,e,s)),n.getLocalPointByInner(t,null,null,!0),n.getLocalPointByInner(i,null,null,!0),n.x=t.x,n.y=t.y,n.getInnerPointByLocal(i,null,null,!0),n.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(ge(t,n,r),s&&ge(e,-n,-r)):(s&&ge(t,-n,-r),ge(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),ue(s[7],i),ue(e[7],i),ue(s[3],a),ue(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===de||t===ce,s[t].visible=a,e[t].visible=!r&&a}};fe=ht([ee()],fe),S.editor=function(t){return new ae(t)},g.setEditConfig=function(t){c(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},g.setEditOuter=function(t){c(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},g.setEditInner=function(t){c(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{Ut as EditBox,At as EditDataHelper,Yt as EditPoint,Tt as EditSelect,Ot as EditSelectHelper,le as EditTool,se as EditToolCreator,ae as Editor,dt as EditorEvent,re as EditorGroupEvent,Jt as EditorHelper,ct as EditorMoveEvent,ut as EditorRotateEvent,gt as EditorScaleEvent,ft as EditorSkewEvent,he as InnerEditor,ne as InnerEditorEvent,fe as LineEditTool,N as PathScaler,wt as SelectArea,yt as Stroker,ee as registerEditTool,ie as registerInnerEditor,it as scaleResize,st as scaleResizeFontSize,rt as scaleResizeGroup,ot as scaleResizePath,nt as scaleResizePoints};
package/dist/editor.js CHANGED
@@ -13,9 +13,6 @@ this.LeaferIN.editor = (function (exports, draw, core) {
13
13
  command = data[i];
14
14
  switch (command) {
15
15
  case M:
16
- scalePoints(data, scaleX, scaleY, i, 1);
17
- i += 3;
18
- break;
19
16
  case L:
20
17
  scalePoints(data, scaleX, scaleY, i, 1);
21
18
  i += 3;
@@ -97,34 +94,34 @@ this.LeaferIN.editor = (function (exports, draw, core) {
97
94
  function scaleResizeFontSize(leaf, scaleX, scaleY) {
98
95
  const { app } = leaf;
99
96
  const editor = app && app.editor;
97
+ let fontScale = scaleX;
100
98
  if (editor.editing) {
101
99
  const layout = leaf.__layout;
102
100
  let { width, height } = layout.boxBounds;
103
- width *= (scaleY - scaleX) * (leaf.scaleX < 0 ? -1 : 1);
104
- height *= (scaleX - scaleY) * (leaf.scaleY < 0 ? -1 : 1);
101
+ width *= scaleY - scaleX;
102
+ height *= scaleX - scaleY;
105
103
  switch (editor.resizeDirection) {
106
104
  case top$1:
107
105
  case bottom$1:
108
- leaf.fontSize *= scaleY;
106
+ fontScale = scaleY;
109
107
  layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
110
108
  break;
111
109
  case left$2:
112
110
  case right$2:
113
- leaf.fontSize *= scaleX;
114
111
  layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
115
112
  break;
116
113
  case topLeft$1:
117
114
  case topRight$1:
118
- leaf.fontSize *= scaleX;
119
115
  layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
120
116
  break;
121
- default:
122
- leaf.fontSize *= scaleX;
123
117
  }
124
118
  }
125
- else {
126
- leaf.fontSize *= scaleX;
127
- }
119
+ leaf.fontSize *= fontScale;
120
+ const data = leaf.__;
121
+ if (!data.__autoWidth)
122
+ leaf.width *= fontScale;
123
+ if (!data.__autoHeight)
124
+ leaf.height *= fontScale;
128
125
  }
129
126
  function scaleResizePath(leaf, scaleX, scaleY) {
130
127
  PathScaler.scale(leaf.__.path, scaleX, scaleY);
@@ -170,7 +167,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
170
167
  this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
171
168
  };
172
169
  draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
173
- if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
170
+ if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
174
171
  scaleResizeFontSize(this, scaleX, scaleY);
175
172
  }
176
173
  else {
@@ -523,7 +520,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
523
520
  if (this.allowDrag(e)) {
524
521
  const { editor } = this;
525
522
  const { stroke, area } = editor.mergeConfig;
526
- const { x, y } = e.getInner(this);
523
+ const { x, y } = e.getInnerPoint(this);
527
524
  this.bounds.set(x, y);
528
525
  this.selectArea.setStyle({ visible: true, stroke, x, y }, area);
529
526
  this.selectArea.setBounds(this.bounds.get());
@@ -729,7 +726,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
729
726
  const nowHeight = boxBounds.height * element.scaleY;
730
727
  scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
731
728
  }
732
- toPoint(around || align, boxBounds, origin);
729
+ toPoint(around || align, boxBounds, origin, true);
733
730
  return { origin, scaleX, scaleY, direction, lockRatio, around };
734
731
  },
735
732
  getRotateData(bounds, direction, current, last, around) {
@@ -750,7 +747,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
750
747
  default:
751
748
  align = 'center';
752
749
  }
753
- toPoint(around || align, bounds, origin);
750
+ toPoint(around || align, bounds, origin, true);
754
751
  return { origin, rotation: draw.PointHelper.getRotation(last, origin, current) };
755
752
  },
756
753
  getSkewData(bounds, direction, move, around) {
@@ -777,10 +774,10 @@ this.LeaferIN.editor = (function (exports, draw, core) {
777
774
  align = 'left';
778
775
  skewY = 1;
779
776
  }
780
- const { x, y, width, height } = bounds;
781
- last.x = x + last.x * width;
782
- last.y = y + last.y * height;
783
- toPoint(around || align, bounds, origin);
777
+ const { width, height } = bounds;
778
+ last.x = last.x * width;
779
+ last.y = last.y * height;
780
+ toPoint(around || align, bounds, origin, true);
784
781
  const rotation = draw.PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
785
782
  skewX ? skewX = -rotation : skewY = rotation;
786
783
  return { origin, skewX, skewY };
@@ -1276,6 +1273,7 @@ ${filterStyle}
1276
1273
  }
1277
1274
  else {
1278
1275
  editor.leafList.reset();
1276
+ editor.closeInnerEditor();
1279
1277
  }
1280
1278
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, { editor, value: target, oldValue }));
1281
1279
  editor.checkOpenedGroups();
@@ -1504,7 +1502,7 @@ ${filterStyle}
1504
1502
  let { around, lockRatio, resizeable, flipable, editSize } = this.mergeConfig;
1505
1503
  if (e instanceof core.ZoomEvent) {
1506
1504
  if (resizeable === 'zoom')
1507
- e.stop(), this.scaleOf(element.getInnerPoint(e), e.scale, e.scale);
1505
+ e.stop(), this.scaleOf(element.getBoxPoint(e), e.scale, e.scale);
1508
1506
  }
1509
1507
  else {
1510
1508
  const { direction } = e.current;
@@ -1529,13 +1527,13 @@ ${filterStyle}
1529
1527
  let origin, rotation;
1530
1528
  if (e instanceof core.RotateEvent) {
1531
1529
  if (rotateable === 'rotate')
1532
- e.stop(), rotation = e.rotation, origin = element.getInnerPoint(e);
1530
+ e.stop(), rotation = e.rotation, origin = element.getBoxPoint(e);
1533
1531
  else
1534
1532
  return;
1535
1533
  }
1536
1534
  else {
1537
1535
  const last = { x: e.x - e.moveX, y: e.y - e.moveY };
1538
- const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getInner(element), element.getInnerPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'));
1536
+ const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getBoxPoint(element), element.getBoxPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'));
1539
1537
  rotation = data.rotation;
1540
1538
  origin = data.origin;
1541
1539
  }
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");const{M:i,L:o,C:s,Q:n,Z:r,N:a,D:l,X:h,G:d,F:c,O:g,P:u,U:p}=t.PathCommandMap,f={scale(t,e,f){if(!t)return;let v,E=0,b=t.length;for(;E<b;)switch(v=t[E],v){case i:case o:m(t,e,f,E,1),E+=3;break;case s:m(t,e,f,E,3),E+=7;break;case n:m(t,e,f,E,2),E+=5;break;case r:E+=1;break;case a:m(t,e,f,E,2),E+=5;break;case l:m(t,e,f,E,2),E+=9;break;case h:m(t,e,f,E,2),E+=6;break;case d:m(t,e,f,E,2),E+=9;break;case c:m(t,e,f,E,2),E+=5;break;case g:t[E]=d,t.splice(E+4,0,t[E+3],0),m(t,e,f,E,2),E+=9,b+=2;break;case u:t[E]=c,t.splice(E+4,0,t[E+3]),m(t,e,f,E,2),E+=5,b+=1;break;case p:m(t,e,f,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:m}=f,v=t.MatrixHelper.get(),{topLeft:E,top:b,topRight:y,right:L,bottom:_,left:w}=t.Direction9;function x(t,e,i){t.pathInputed?S(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function k(t,e,i){const{app:o}=t,s=o&&o.editor;if(s.editing){const o=t.__layout;let{width:n,height:r}=o.boxBounds;switch(n*=(i-e)*(t.scaleX<0?-1:1),r*=(e-i)*(t.scaleY<0?-1:1),s.resizeDirection){case b:case _:t.fontSize*=i,o.affectScaleOrRotation?t.moveInner(-n/2,0):t.x-=n/2;break;case w:case L:t.fontSize*=e,o.affectScaleOrRotation?t.moveInner(0,-r/2):t.y-=r/2;break;case E:case y:t.fontSize*=e,o.affectScaleOrRotation?t.moveInner(0,-r):t.y-=r;break;default:t.fontSize*=e}}else t.fontSize*=e}function S(t,e,i){f.scale(t.__.path,e,i),t.path=t.__.path}function M(t,e,i){f.scalePoints(t.__.points,e,i),t.points=t.__.points}function T(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)v.a=e,v.d=i,o[t].transform(v,!0)}const O=t.Leaf.prototype;function P(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function H(t){return t?t instanceof Array?t:[t]:[]}O.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},O.__scaleResize=function(t,e){x(this,t,e)},O.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},O.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?k(this,t,e):x(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){S(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?S(this,t,e):this.points?M(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?S(this,t,e):this.points?M(this,t,e):x(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){T(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?T(this,t,e):(x(this,t,e),this.__.resizeChildren&&T(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class R extends t.Event{get list(){return H(this.value)}get oldList(){return H(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}R.SELECT="editor.select",R.HOVER="editor.hover";class C extends R{constructor(t,e){super(t,e)}}C.MOVE="editor.move";class B extends R{constructor(t,e){super(t,e)}}B.SCALE="editor.scale";class I extends R{constructor(t,e){super(t,e)}}I.ROTATE="editor.rotate";class V extends R{constructor(t,e){super(t,e)}}function D(e){return(i,o)=>{const s="_"+o;t.defineKey(i,o,{get(){return this[s]},set(t){const i=this[s];i!==t&&(this[s]=t,e(this,i))}})}}V.SKEW="editor.skew";const z=t.MatrixHelper.get(),{abs:A}=Math,{copy:Z,scale:W}=t.MatrixHelper;class G extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(e,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=A(s.__world.scaleX),l=A(s.__world.scaleY);if(o!==l){Z(z,s.__world),W(z,1/o,1/l),e.setWorld(z,i.matrix),e.beginPath(),this.__.strokeWidth=r;const{x:t,y:n,width:a,height:h}=s.__layout.boxBounds;e.rect(t*o,n*l,a*o,h*l)}else e.setWorld(s.__world,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),this.__.strokeWidth=r/A(s.__world.scaleX);n&&("string"==typeof n?t.Paint.stroke(n,this,e):t.Paint.strokes(n,this,e)),a&&("string"==typeof a?t.Paint.fill(a,this,e):t.Paint.fills(a,this,e))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}P([D((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],G.prototype,"target",void 0);class F extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:U,Yes:X,NoAndSkip:Y,YesAndSkip:K}=t.Answer,N={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?K:Y;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?K:U;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return X}return U}return t.isBranch?Y:U}},{findOne:j}=N;class q extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new G,this.targetStroker=new G,this.bounds=new t.Bounds,this.selectArea=new F,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(e){if(!e.multiTouch){if(this.editor.dragging)return this.onDragEnd(e);if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(i.app.find(N.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!j(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return j(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):j(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_(R.HOVER,this.onHover,this),t.on_(R.SELECT,this.onSelect,this),i.on_(e.PointerEvent.MOVE,this.onPointerMove,this),i.on_(e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),i.on_(e.PointerEvent.TAP,this.onTap,this),i.on_(e.DragEvent.START,this.onDragStart,this,!0),i.on_(e.DragEvent.DRAG,this.onDrag,this),i.on_(e.DragEvent.END,this.onDragEnd,this),i.on_(e.MoveEvent.MOVE,this.onAutoMove,this),i.on_([e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:$,top:Q,topRight:J,right:tt,bottomRight:et,bottom:it,bottomLeft:ot,left:st}=t.Direction9,{toPoint:nt}=t.AroundHelper,{within:rt}=t.MathHelper,at={getScaleData(t,e,i,o,s,n,r,a){let l,h={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:p}=t,{width:f,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=v<0?-1:1,y=E<0?-1:1,L=a?v:b*g.width/f,_=a?E:y*g.height/m;o.x*=a?v:b,o.y*=a?E:y,Math.abs(o.x)===f&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const w=(-o.y+m)/m,x=(o.x+f)/f,k=(o.y+m)/m,S=(-o.x+f)/f;switch(i){case Q:c=w,l="bottom";break;case tt:d=x,l="left";break;case it:c=k,l="top";break;case st:d=S,l="right";break;case $:c=w,d=S,l="bottom-right";break;case J:c=w,d=x,l="bottom-left";break;case et:c=k,d=x,l="top-left";break;case ot:c=k,d=S,l="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case Q:case it:t=c;break;case st:case tt:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=L,c/=_,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=rt(e*d,u)/e}if(p){const e=g.height*t.scaleY;c=rt(e*c,p)/e}return nt(n||l,g,h),{origin:h,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case $:r="bottom-right";break;case J:r="bottom-left";break;case et:r="top-left";break;case ot:r="top-right";break;default:r="center"}return nt(n||r,e,a),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},l=0,h=0;switch(i){case Q:r={x:.5,y:0},n="bottom",l=1;break;case it:r={x:.5,y:1},n="top",l=1;break;case st:r={x:0,y:.5},n="right",h=1;break;case tt:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=e;r.x=d+r.x*g,r.y=c+r.y*u,nt(s||n,e,a);const p=t.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-p:h=p,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case st:t=tt;break;case $:t=J;break;case ot:t=et;break;case tt:t=st;break;case J:t=$;break;case et:t=ot}if(i)switch(t){case Q:t=it;break;case $:t=ot;break;case J:t=et;break;case it:t=Q;break;case ot:t=$;break;case et:t=J}return t}},lt={};function ht(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!h)&&(f=!1);const m=c&&!f&&"resize-line"===s.name?l:f?r:a;n+=45*(at.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:b}=m,y=v+n;lt[y]?s.cursor=lt[y]:lt[y]=s.cursor={url:ct(v,n),x:E,y:b}}function dt(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function ct(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class gt extends t.Box{}const ut=["top","right","bottom","left"];class pt extends t.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new gt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.rect.syncEventer=e,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new gt({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new gt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new gt({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,l,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&!!l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(e){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=e,{rect:n,circle:r,buttons:a,resizePoints:l,rotatePoints:h,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:p}=i,f="number"==typeof p?p:10,m=!(p&&o<f&&s<f);let v,E,b,y={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,y),E=l[n],v=h[n],b=d[Math.floor(n/2)],E.set(y),v.set(y),b.set(y),E.visible=b.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(b.width=o,E.width>o-30&&(E.visible=!1)):(b.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=ut.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let l=ut.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?at.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l;this.setButtonPosition(e,h,s,!!n),o&&(e.rotation=90*(h-l)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),ht(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,i,o){const{editor:s}=this;t.direction=o,t.pointType=i,t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,this.onDrag,this),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(e.PointerEvent.ENTER,(e=>{this.enterPoint=t,ht(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(R.SELECT,this.onSelect,this),t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,i.onMove,i),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.ENTER,(()=>dt(i))),t.on_(e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(e.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class ft extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:o}=i.mergeConfig;if(o&&i.list.length){const{rect:s}=i.editBox,{width:n,height:r}=s.__;t.resetTransform(),t.fillWorld(t.bounds,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const mt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',vt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${mt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${mt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${mt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0};function Et(e){const{simulateTarget:i,leafList:o}=e,{x:s,y:n,width:r,height:a}=(new t.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const bt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),yt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Lt={group(e,i,o){e.sort(yt);const{app:s,parent:n}=e[0];let r;r=o&&o.add?o:new t.Group(o),n.addAt(r,n.children.indexOf(e[0])),e.sort(bt);const a=new t.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),e.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(bt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(yt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},_t=t.Debug.get("EditToolCreator");function wt(){return t=>{kt.register(t)}}const xt=wt,kt={list:{},register(t){const{tag:e}=t.prototype;St[e]?_t.repeat(e):St[e]=t},get:(t,e)=>new St[t](e)},{list:St}=kt;class Mt extends R{constructor(t,e){super(t,e)}}Mt.BEFORE_OPEN="innerEditor.before_open",Mt.OPEN="innerEditor.open",Mt.BEFORE_CLOSE="innerEditor.before_close",Mt.CLOSE="innerEditor.close";class Tt extends R{constructor(t,e){super(t,e)}}Tt.GROUP="editor.group",Tt.BEFORE_UNGROUP="editor.before_ungroup",Tt.UNGROUP="editor.ungroup",Tt.OPEN="editor.open_group",Tt.CLOSE="editor.close_group";class Ot extends t.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(e,i){super(i),this.config=t.DataHelper.clone(vt),this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new t.Rect({visible:!1}),this.editBox=new pt(this),this.editToolList={},this.selector=new q(this),this.editMask=new ft(this),this.targetEventIds=[],e&&(this.config=t.DataHelper.default(e,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&Et(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||kt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof e.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{const i={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(i.x)>Math.abs(i.y)?i.y=0:i.x=0),this.move(e.DragEvent.getValidMove(this.element,this.dragStartPoint,i))}}onScale(t){const{element:i}=this;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof e.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(i.getInnerPoint(t),t.scale,t.scale));else{const{direction:e}=t.current;(t.shiftKey||i.lockRatio)&&(s=!0);const n=at.getScaleData(i,this.dragStartBounds,e,t.getInnerTotal(i),s,at.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(i){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:l}=i.current;if(o&&"resize-line"===l)return this.onSkew(i);const{element:h}=this;let d,c;if(i instanceof e.RotateEvent){if("rotate"!==s)return;i.stop(),c=i.rotation,d=h.getInnerPoint(i)}else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=at.getRotateData(h.boxBounds,a,i.getInner(h),h.getInnerPoint(t),i.shiftKey?null:h.around||h.origin||n||"center");c=e.rotation,d=e.origin}c=t.MathHelper.getGapRotation(c,r,h.rotation),c&&(h.scaleX*h.scaleY<0&&(c=-c),this.rotateOf(d,t.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=at.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),at.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new C(C.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=new B(B.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.scaleOf(t,e,i))),a=new B(B.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(e){if(this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.flip(e))):new t.Matrix(t.LeafHelper.getFlipTransform(i,e)),n=new B(B.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===e?-1:1,scaleY:"y"===e?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.rotateOf(t,e))),n=new I(I.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.skewOf(t,e,i))),a=new V(V.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}getWorldOrigin(e){return this.element.getWorldPoint(t.LeafHelper.getInnerOrigin(this.element,e))}getChangedTransform(e){const{element:i}=this,o=new t.Matrix(i.worldTransform);return e(),new t.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=Lt.group(this.list,this.element,t),this.emitGroupEvent(Tt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Tt.BEFORE_UNGROUP,t))),this.target=Lt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Tt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Tt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Tt.CLOSE,t)}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach((e=>this.list.every((i=>!t.LeafHelper.hasParent(i,e)))&&i.push(e)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Tt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&kt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||kt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Mt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Mt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Mt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Mt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new Mt(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(Lt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Lt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:i}=this.list[0];this.targetEventIds=[this.app.on_(e.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),this.app.on_(e.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),this.app.on_(e.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),i.on_(t.RenderEvent.START,this.update,this),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{ht(this,t)})),i.on_(e.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}P([D((function(t,e){t.emitEvent(new R(R.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Ot.prototype,"hoverTarget",void 0),P([D((function(e,i){const{target:o}=e;o?e.leafList=o instanceof t.LeafList?o:new t.LeafList(o):e.leafList.reset(),e.emitEvent(new R(R.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{e.multiple&&Et(e),dt(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],Ot.prototype,"target",void 0);class Pt{static registerInnerEditor(){kt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}exports.EditTool=class extends Pt{static registerEditTool(){kt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=P([wt()],exports.EditTool);const{left:Ht,right:Rt}=t.Direction9,{move:Ct,copy:Bt}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:o,lockRatio:s,around:n}=e,r=e.target,a=o===Ht;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const e=t.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(e,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=e.x,r.y=e.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(Ct(t,n,r),o&&Ct(e,-n,-r)):(o&&Ct(t,-n,-r),Ct(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Bt(o[7],i),Bt(e[7],i),Bt(o[3],a),Bt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Ht||t===Rt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=P([wt()],exports.LineEditTool),t.Creator.editor=function(t){return new Ot(t)},t.UI.setEditConfig=function(e){t.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof e?e(this):e}})},t.UI.setEditOuter=function(e){t.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof e?e:e(this)}})},t.UI.setEditInner=function(e){t.defineKey(this.prototype,"editInner",{get(){return"string"==typeof e?e:e(this)}})},exports.EditBox=pt,exports.EditDataHelper=at,exports.EditPoint=gt,exports.EditSelect=q,exports.EditSelectHelper=N,exports.EditToolCreator=kt,exports.Editor=Ot,exports.EditorEvent=R,exports.EditorGroupEvent=Tt,exports.EditorHelper=Lt,exports.EditorMoveEvent=C,exports.EditorRotateEvent=I,exports.EditorScaleEvent=B,exports.EditorSkewEvent=V,exports.InnerEditor=Pt,exports.InnerEditorEvent=Mt,exports.PathScaler=f,exports.SelectArea=F,exports.Stroker=G,exports.registerEditTool=wt,exports.registerInnerEditor=xt,exports.scaleResize=x,exports.scaleResizeFontSize=k,exports.scaleResizeGroup=T,exports.scaleResizePath=S,exports.scaleResizePoints=M;
1
+ "use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");const{M:i,L:o,C:s,Q:n,Z:r,N:a,D:l,X:h,G:d,F:c,O:g,P:u,U:p}=t.PathCommandMap,f={scale(t,e,f){if(!t)return;let v,E=0,b=t.length;for(;E<b;)switch(v=t[E],v){case i:case o:m(t,e,f,E,1),E+=3;break;case s:m(t,e,f,E,3),E+=7;break;case n:m(t,e,f,E,2),E+=5;break;case r:E+=1;break;case a:m(t,e,f,E,2),E+=5;break;case l:m(t,e,f,E,2),E+=9;break;case h:m(t,e,f,E,2),E+=6;break;case d:m(t,e,f,E,2),E+=9;break;case c:m(t,e,f,E,2),E+=5;break;case g:t[E]=d,t.splice(E+4,0,t[E+3],0),m(t,e,f,E,2),E+=9,b+=2;break;case u:t[E]=c,t.splice(E+4,0,t[E+3]),m(t,e,f,E,2),E+=5,b+=1;break;case p:m(t,e,f,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:m}=f,v=t.MatrixHelper.get(),{topLeft:E,top:b,topRight:y,right:_,bottom:L,left:w}=t.Direction9;function x(t,e,i){t.pathInputed?M(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function k(t,e,i){const{app:o}=t,s=o&&o.editor;let n=e;if(s.editing){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s.resizeDirection){case b:case L:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case w:case _:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case E:case y:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__;r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}function M(t,e,i){f.scale(t.__.path,e,i),t.path=t.__.path}function S(t,e,i){f.scalePoints(t.__.points,e,i),t.points=t.__.points}function T(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)v.a=e,v.d=i,o[t].transform(v,!0)}const O=t.Leaf.prototype;function P(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function H(t){return t?t instanceof Array?t:[t]:[]}O.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},O.__scaleResize=function(t,e){x(this,t,e)},O.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},O.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?k(this,t,e):x(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){M(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?M(this,t,e):this.points?S(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?M(this,t,e):this.points?S(this,t,e):x(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){T(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?T(this,t,e):(x(this,t,e),this.__.resizeChildren&&T(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class R extends t.Event{get list(){return H(this.value)}get oldList(){return H(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}R.SELECT="editor.select",R.HOVER="editor.hover";class B extends R{constructor(t,e){super(t,e)}}B.MOVE="editor.move";class C extends R{constructor(t,e){super(t,e)}}C.SCALE="editor.scale";class V extends R{constructor(t,e){super(t,e)}}V.ROTATE="editor.rotate";class I extends R{constructor(t,e){super(t,e)}}function D(e){return(i,o)=>{const s="_"+o;t.defineKey(i,o,{get(){return this[s]},set(t){const i=this[s];i!==t&&(this[s]=t,e(this,i))}})}}I.SKEW="editor.skew";const z=t.MatrixHelper.get(),{abs:A}=Math,{copy:Z,scale:W}=t.MatrixHelper;class G extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(e,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=A(s.__world.scaleX),l=A(s.__world.scaleY);if(o!==l){Z(z,s.__world),W(z,1/o,1/l),e.setWorld(z,i.matrix),e.beginPath(),this.__.strokeWidth=r;const{x:t,y:n,width:a,height:h}=s.__layout.boxBounds;e.rect(t*o,n*l,a*o,h*l)}else e.setWorld(s.__world,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),this.__.strokeWidth=r/A(s.__world.scaleX);n&&("string"==typeof n?t.Paint.stroke(n,this,e):t.Paint.strokes(n,this,e)),a&&("string"==typeof a?t.Paint.fill(a,this,e):t.Paint.fills(a,this,e))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}P([D((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],G.prototype,"target",void 0);class F extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:U,Yes:X,NoAndSkip:Y,YesAndSkip:K}=t.Answer,N={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?K:Y;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?K:U;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return X}return U}return t.isBranch?Y:U}},{findOne:j}=N;class q extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new G,this.targetStroker=new G,this.bounds=new t.Bounds,this.selectArea=new F,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInnerPoint(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(e){if(!e.multiTouch){if(this.editor.dragging)return this.onDragEnd(e);if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(i.app.find(N.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!j(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return j(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):j(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_(R.HOVER,this.onHover,this),t.on_(R.SELECT,this.onSelect,this),i.on_(e.PointerEvent.MOVE,this.onPointerMove,this),i.on_(e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),i.on_(e.PointerEvent.TAP,this.onTap,this),i.on_(e.DragEvent.START,this.onDragStart,this,!0),i.on_(e.DragEvent.DRAG,this.onDrag,this),i.on_(e.DragEvent.END,this.onDragEnd,this),i.on_(e.MoveEvent.MOVE,this.onAutoMove,this),i.on_([e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:$,top:Q,topRight:J,right:tt,bottomRight:et,bottom:it,bottomLeft:ot,left:st}=t.Direction9,{toPoint:nt}=t.AroundHelper,{within:rt}=t.MathHelper,at={getScaleData(t,e,i,o,s,n,r,a){let l,h={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:p}=t,{width:f,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=v<0?-1:1,y=E<0?-1:1,_=a?v:b*g.width/f,L=a?E:y*g.height/m;o.x*=a?v:b,o.y*=a?E:y,Math.abs(o.x)===f&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const w=(-o.y+m)/m,x=(o.x+f)/f,k=(o.y+m)/m,M=(-o.x+f)/f;switch(i){case Q:c=w,l="bottom";break;case tt:d=x,l="left";break;case it:c=k,l="top";break;case st:d=M,l="right";break;case $:c=w,d=M,l="bottom-right";break;case J:c=w,d=x,l="bottom-left";break;case et:c=k,d=x,l="top-left";break;case ot:c=k,d=M,l="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case Q:case it:t=c;break;case st:case tt:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=_,c/=L,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=rt(e*d,u)/e}if(p){const e=g.height*t.scaleY;c=rt(e*c,p)/e}return nt(n||l,g,h,!0),{origin:h,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case $:r="bottom-right";break;case J:r="bottom-left";break;case et:r="top-left";break;case ot:r="top-right";break;default:r="center"}return nt(n||r,e,a,!0),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},l=0,h=0;switch(i){case Q:r={x:.5,y:0},n="bottom",l=1;break;case it:r={x:.5,y:1},n="top",l=1;break;case st:r={x:0,y:.5},n="right",h=1;break;case tt:r={x:1,y:.5},n="left",h=1}const{width:d,height:c}=e;r.x=r.x*d,r.y=r.y*c,nt(s||n,e,a,!0);const g=t.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-g:h=g,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case st:t=tt;break;case $:t=J;break;case ot:t=et;break;case tt:t=st;break;case J:t=$;break;case et:t=ot}if(i)switch(t){case Q:t=it;break;case $:t=ot;break;case J:t=et;break;case it:t=Q;break;case ot:t=$;break;case et:t=J}return t}},lt={};function ht(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!h)&&(f=!1);const m=c&&!f&&"resize-line"===s.name?l:f?r:a;n+=45*(at.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:b}=m,y=v+n;lt[y]?s.cursor=lt[y]:lt[y]=s.cursor={url:ct(v,n),x:E,y:b}}function dt(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function ct(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class gt extends t.Box{}const ut=["top","right","bottom","left"];class pt extends t.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new gt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.rect.syncEventer=e,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new gt({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new gt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new gt({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,l,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&!!l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(e){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=e,{rect:n,circle:r,buttons:a,resizePoints:l,rotatePoints:h,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:p}=i,f="number"==typeof p?p:10,m=!(p&&o<f&&s<f);let v,E,b,y={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,y),E=l[n],v=h[n],b=d[Math.floor(n/2)],E.set(y),v.set(y),b.set(y),E.visible=b.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(b.width=o,E.width>o-30&&(E.visible=!1)):(b.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=ut.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let l=ut.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?at.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l;this.setButtonPosition(e,h,s,!!n),o&&(e.rotation=90*(h-l)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),ht(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,i,o){const{editor:s}=this;t.direction=o,t.pointType=i,t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,this.onDrag,this),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(e.PointerEvent.ENTER,(e=>{this.enterPoint=t,ht(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(R.SELECT,this.onSelect,this),t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,i.onMove,i),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.ENTER,(()=>dt(i))),t.on_(e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(e.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class ft extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:o}=i.mergeConfig;if(o&&i.list.length){const{rect:s}=i.editBox,{width:n,height:r}=s.__;t.resetTransform(),t.fillWorld(t.bounds,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const mt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',vt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${mt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${mt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${mt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0};function Et(e){const{simulateTarget:i,leafList:o}=e,{x:s,y:n,width:r,height:a}=(new t.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const bt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),yt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),_t={group(e,i,o){e.sort(yt);const{app:s,parent:n}=e[0];let r;r=o&&o.add?o:new t.Group(o),n.addAt(r,n.children.indexOf(e[0])),e.sort(bt);const a=new t.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),e.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(bt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(yt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Lt=t.Debug.get("EditToolCreator");function wt(){return t=>{kt.register(t)}}const xt=wt,kt={list:{},register(t){const{tag:e}=t.prototype;Mt[e]?Lt.repeat(e):Mt[e]=t},get:(t,e)=>new Mt[t](e)},{list:Mt}=kt;class St extends R{constructor(t,e){super(t,e)}}St.BEFORE_OPEN="innerEditor.before_open",St.OPEN="innerEditor.open",St.BEFORE_CLOSE="innerEditor.before_close",St.CLOSE="innerEditor.close";class Tt extends R{constructor(t,e){super(t,e)}}Tt.GROUP="editor.group",Tt.BEFORE_UNGROUP="editor.before_ungroup",Tt.UNGROUP="editor.ungroup",Tt.OPEN="editor.open_group",Tt.CLOSE="editor.close_group";class Ot extends t.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(e,i){super(i),this.config=t.DataHelper.clone(vt),this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new t.Rect({visible:!1}),this.editBox=new pt(this),this.editToolList={},this.selector=new q(this),this.editMask=new ft(this),this.targetEventIds=[],e&&(this.config=t.DataHelper.default(e,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&Et(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||kt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof e.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{const i={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(i.x)>Math.abs(i.y)?i.y=0:i.x=0),this.move(e.DragEvent.getValidMove(this.element,this.dragStartPoint,i))}}onScale(t){const{element:i}=this;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof e.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(i.getBoxPoint(t),t.scale,t.scale));else{const{direction:e}=t.current;(t.shiftKey||i.lockRatio)&&(s=!0);const n=at.getScaleData(i,this.dragStartBounds,e,t.getInnerTotal(i),s,at.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(i){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:l}=i.current;if(o&&"resize-line"===l)return this.onSkew(i);const{element:h}=this;let d,c;if(i instanceof e.RotateEvent){if("rotate"!==s)return;i.stop(),c=i.rotation,d=h.getBoxPoint(i)}else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=at.getRotateData(h.boxBounds,a,i.getBoxPoint(h),h.getBoxPoint(t),i.shiftKey?null:h.around||h.origin||n||"center");c=e.rotation,d=e.origin}c=t.MathHelper.getGapRotation(c,r,h.rotation),c&&(h.scaleX*h.scaleY<0&&(c=-c),this.rotateOf(d,t.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=at.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),at.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new B(B.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=new C(C.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.scaleOf(t,e,i))),a=new C(C.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(e){if(this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.flip(e))):new t.Matrix(t.LeafHelper.getFlipTransform(i,e)),n=new C(C.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===e?-1:1,scaleY:"y"===e?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.rotateOf(t,e))),n=new V(V.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.skewOf(t,e,i))),a=new I(I.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}getWorldOrigin(e){return this.element.getWorldPoint(t.LeafHelper.getInnerOrigin(this.element,e))}getChangedTransform(e){const{element:i}=this,o=new t.Matrix(i.worldTransform);return e(),new t.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=_t.group(this.list,this.element,t),this.emitGroupEvent(Tt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Tt.BEFORE_UNGROUP,t))),this.target=_t.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Tt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Tt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Tt.CLOSE,t)}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach((e=>this.list.every((i=>!t.LeafHelper.hasParent(i,e)))&&i.push(e)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Tt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&kt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||kt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(St.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(St.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(St.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(St.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new St(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(_t.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(_t.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:i}=this.list[0];this.targetEventIds=[this.app.on_(e.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),this.app.on_(e.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),this.app.on_(e.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),i.on_(t.RenderEvent.START,this.update,this),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{ht(this,t)})),i.on_(e.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}P([D((function(t,e){t.emitEvent(new R(R.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Ot.prototype,"hoverTarget",void 0),P([D((function(e,i){const{target:o}=e;o?e.leafList=o instanceof t.LeafList?o:new t.LeafList(o):(e.leafList.reset(),e.closeInnerEditor()),e.emitEvent(new R(R.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{e.multiple&&Et(e),dt(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],Ot.prototype,"target",void 0);class Pt{static registerInnerEditor(){kt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}exports.EditTool=class extends Pt{static registerEditTool(){kt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=P([wt()],exports.EditTool);const{left:Ht,right:Rt}=t.Direction9,{move:Bt,copy:Ct}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:o,lockRatio:s,around:n}=e,r=e.target,a=o===Ht;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const e=t.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(e,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=e.x,r.y=e.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(Bt(t,n,r),o&&Bt(e,-n,-r)):(o&&Bt(t,-n,-r),Bt(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Ct(o[7],i),Ct(e[7],i),Ct(o[3],a),Ct(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Ht||t===Rt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=P([wt()],exports.LineEditTool),t.Creator.editor=function(t){return new Ot(t)},t.UI.setEditConfig=function(e){t.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof e?e(this):e}})},t.UI.setEditOuter=function(e){t.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof e?e:e(this)}})},t.UI.setEditInner=function(e){t.defineKey(this.prototype,"editInner",{get(){return"string"==typeof e?e:e(this)}})},exports.EditBox=pt,exports.EditDataHelper=at,exports.EditPoint=gt,exports.EditSelect=q,exports.EditSelectHelper=N,exports.EditToolCreator=kt,exports.Editor=Ot,exports.EditorEvent=R,exports.EditorGroupEvent=Tt,exports.EditorHelper=_t,exports.EditorMoveEvent=B,exports.EditorRotateEvent=V,exports.EditorScaleEvent=C,exports.EditorSkewEvent=I,exports.InnerEditor=Pt,exports.InnerEditorEvent=St,exports.PathScaler=f,exports.SelectArea=F,exports.Stroker=G,exports.registerEditTool=wt,exports.registerInnerEditor=xt,exports.scaleResize=x,exports.scaleResizeFontSize=k,exports.scaleResizeGroup=T,exports.scaleResizePath=M,exports.scaleResizePoints=S;
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.editor=function(t,e,i){"use strict";const{M:o,L:s,C:n,Q:r,Z:a,N:l,D:h,X:d,G:c,F:g,O:u,P:f,U:p}=e.PathCommandMap,m={scale(t,e,i){if(!t)return;let m,E=0,b=t.length;for(;E<b;)switch(m=t[E],m){case o:case s:v(t,e,i,E,1),E+=3;break;case n:v(t,e,i,E,3),E+=7;break;case r:v(t,e,i,E,2),E+=5;break;case a:E+=1;break;case l:v(t,e,i,E,2),E+=5;break;case h:v(t,e,i,E,2),E+=9;break;case d:v(t,e,i,E,2),E+=6;break;case c:v(t,e,i,E,2),E+=9;break;case g:v(t,e,i,E,2),E+=5;break;case u:t[E]=c,t.splice(E+4,0,t[E+3],0),v(t,e,i,E,2),E+=9,b+=2;break;case f:t[E]=g,t.splice(E+4,0,t[E+3]),v(t,e,i,E,2),E+=5,b+=1;break;case p:v(t,e,i,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:v}=m,E=e.MatrixHelper.get(),{topLeft:b,top:y,topRight:L,right:_,bottom:w,left:k}=e.Direction9;function x(t,e,i){t.pathInputed?M(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function S(t,e,i){const{app:o}=t,s=o&&o.editor;if(s.editing){const o=t.__layout;let{width:n,height:r}=o.boxBounds;switch(n*=(i-e)*(t.scaleX<0?-1:1),r*=(e-i)*(t.scaleY<0?-1:1),s.resizeDirection){case y:case w:t.fontSize*=i,o.affectScaleOrRotation?t.moveInner(-n/2,0):t.x-=n/2;break;case k:case _:t.fontSize*=e,o.affectScaleOrRotation?t.moveInner(0,-r/2):t.y-=r/2;break;case b:case L:t.fontSize*=e,o.affectScaleOrRotation?t.moveInner(0,-r):t.y-=r;break;default:t.fontSize*=e}}else t.fontSize*=e}function M(t,e,i){m.scale(t.__.path,e,i),t.path=t.__.path}function T(t,e,i){m.scalePoints(t.__.points,e,i),t.points=t.__.points}function O(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)E.a=e,E.d=i,o[t].transform(E,!0)}const P=e.Leaf.prototype;function H(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function R(t){return t?t instanceof Array?t:[t]:[]}P.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},P.__scaleResize=function(t,e){x(this,t,e)},P.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},P.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},e.Text.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?S(this,t,e):x(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){M(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?M(this,t,e):this.points?T(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?M(this,t,e):this.points?T(this,t,e):x(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){O(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?O(this,t,e):(x(this,t,e),this.__.resizeChildren&&O(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class I extends e.Event{get list(){return R(this.value)}get oldList(){return R(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}I.SELECT="editor.select",I.HOVER="editor.hover";class C extends I{constructor(t,e){super(t,e)}}C.MOVE="editor.move";class B extends I{constructor(t,e){super(t,e)}}B.SCALE="editor.scale";class V extends I{constructor(t,e){super(t,e)}}V.ROTATE="editor.rotate";class D extends I{constructor(t,e){super(t,e)}}function z(t){return(i,o)=>{const s="_"+o;e.defineKey(i,o,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}D.SKEW="editor.skew";const A=e.MatrixHelper.get(),{abs:Z}=Math,{copy:W,scale:G}=e.MatrixHelper;class U extends e.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=Z(s.__world.scaleX),l=Z(s.__world.scaleY);if(o!==l){W(A,s.__world),G(A,1/o,1/l),t.setWorld(A,i.matrix),t.beginPath(),this.__.strokeWidth=r;const{x:e,y:n,width:a,height:h}=s.__layout.boxBounds;t.rect(e*o,n*l,a*o,h*l)}else t.setWorld(s.__world,i.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=r/Z(s.__world.scaleX);n&&("string"==typeof n?e.Paint.stroke(n,this,t):e.Paint.strokes(n,this,t)),a&&("string"==typeof a?e.Paint.fill(a,this,t):e.Paint.fills(a,this,t))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}H([z((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],U.prototype,"target",void 0);class F extends e.Group{constructor(t){super(t),this.strokeArea=new e.Rect({strokeAlign:"center"}),this.fillArea=new e.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:X,Yes:Y,NoAndSkip:N,YesAndSkip:K}=e.Answer,j={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?K:N;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?K:X;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return Y}return X}return t.isBranch?N:X}},{findOne:$}=j;class q extends e.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new U,this.targetStroker=new U,this.bounds=new e.Bounds,this.selectArea=new F,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:i}=this,o=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new e.LeafList(i.app.find(j.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!$(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const i={exclude:new e.LeafList(this.editor.editBox.rect)};return $(t.target.leafer.interaction.findPath(t,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):$(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(I.HOVER,this.onHover,this),t.on_(I.SELECT,this.onSelect,this),e.on_(i.PointerEvent.MOVE,this.onPointerMove,this),e.on_(i.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),e.on_(i.PointerEvent.TAP,this.onTap,this),e.on_(i.DragEvent.START,this.onDragStart,this,!0),e.on_(i.DragEvent.DRAG,this.onDrag,this),e.on_(i.DragEvent.END,this.onDragEnd,this),e.on_(i.MoveEvent.MOVE,this.onAutoMove,this),e.on_([i.ZoomEvent.ZOOM,i.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Q,top:J,topRight:tt,right:et,bottomRight:it,bottom:ot,bottomLeft:st,left:nt}=e.Direction9,{toPoint:rt}=e.AroundHelper,{within:at}=e.MathHelper,lt={getScaleData(t,e,i,o,s,n,r,a){let l,h={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=v<0?-1:1,y=E<0?-1:1,L=a?v:b*g.width/p,_=a?E:y*g.height/m;o.x*=a?v:b,o.y*=a?E:y,Math.abs(o.x)===p&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const w=(-o.y+m)/m,k=(o.x+p)/p,x=(o.y+m)/m,S=(-o.x+p)/p;switch(i){case J:c=w,l="bottom";break;case et:d=k,l="left";break;case ot:c=x,l="top";break;case nt:d=S,l="right";break;case Q:c=w,d=S,l="bottom-right";break;case tt:c=w,d=k,l="bottom-left";break;case it:c=x,d=k,l="top-left";break;case st:c=x,d=S,l="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case J:case ot:t=c;break;case nt:case et:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=L,c/=_,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=at(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=at(e*c,f)/e}return rt(n||l,g,h),{origin:h,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(t,i,o,s,n){let r,a={};switch(i){case Q:r="bottom-right";break;case tt:r="bottom-left";break;case it:r="top-left";break;case st:r="top-right";break;default:r="center"}return rt(n||r,t,a),{origin:a,rotation:e.PointHelper.getRotation(s,a,o)}},getSkewData(t,i,o,s){let n,r,a={},l=0,h=0;switch(i){case J:r={x:.5,y:0},n="bottom",l=1;break;case ot:r={x:.5,y:1},n="top",l=1;break;case nt:r={x:0,y:.5},n="right",h=1;break;case et:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=t;r.x=d+r.x*g,r.y=c+r.y*u,rt(s||n,t,a);const f=e.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-f:h=f,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case nt:t=et;break;case Q:t=tt;break;case st:t=it;break;case et:t=nt;break;case tt:t=Q;break;case it:t=st}if(i)switch(t){case J:t=ot;break;case Q:t=st;break;case tt:t=it;break;case ot:t=J;break;case st:t=Q;break;case it:t=tt}return t}},ht={};function dt(t,i){const{editBox:o}=t,s=o.enterPoint;if(!s||!t.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=t.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:f}=o;let p="resize"===g;p&&d&&(i.metaKey||i.ctrlKey||!h)&&(p=!1);const m=c&&!p&&"resize-line"===s.name?l:p?r:a;n+=45*(lt.getFlipDirection(s.direction,u,f)+1),n=2*Math.round(e.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:b}=m,y=v+n;ht[y]?s.cursor=ht[y]:ht[y]=s.cursor={url:gt(v,n),x:E,y:b}}function ct(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function gt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class ut extends e.Box{}const ft=["top","right","bottom","left"];class pt extends e.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new e.Group,this.rect=new e.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new ut({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new e.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new ut({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new ut({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new ut({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,l,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&!!l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=t,{rect:n,circle:r,buttons:a,resizePoints:l,rotatePoints:h,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:f}=i,p="number"==typeof f?f:10,m=!(f&&o<p&&s<p);let v,E,b,y={};for(let n=0;n<8;n++)e.AroundHelper.toPoint(e.AroundHelper.directionData[n],t,y),E=l[n],v=h[n],b=d[Math.floor(n/2)],E.set(y),v.set(y),b.set(y),E.visible=b.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(b.width=o,E.width>o-30&&(E.visible=!1)):(b.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=ft.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let l=ft.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?lt.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l;this.setButtonPosition(e,h,s,!!n),o&&(e.rotation=90*(h-l)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),dt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,o){const{editor:s}=this;t.direction=o,t.pointType=e,t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,this.onDrag,this),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(i.PointerEvent.ENTER,(e=>{this.enterPoint=t,dt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(I.SELECT,this.onSelect,this),t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,e.onMove,e),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.PointerEvent.ENTER,(()=>ct(e))),t.on_(i.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(i.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class mt extends e.UI{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:o}=i.mergeConfig;if(o&&i.list.length){const{rect:s}=i.editBox,{width:n,height:r}=s.__;t.resetTransform(),t.fillWorld(t.bounds,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const vt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Et={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${vt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${vt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${vt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0};function bt(t){const{simulateTarget:i,leafList:o}=t,{x:s,y:n,width:r,height:a}=(new e.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const yt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Lt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),_t={group(t,i,o){t.sort(Lt);const{app:s,parent:n}=t[0];let r;r=o&&o.add?o:new e.Group(o),n.addAt(r,n.children.indexOf(t[0])),t.sort(yt);const a=new e.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(yt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Lt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},wt=e.Debug.get("EditToolCreator");function kt(){return t=>{St.register(t)}}const xt=kt,St={list:{},register(t){const{tag:e}=t.prototype;Mt[e]?wt.repeat(e):Mt[e]=t},get:(t,e)=>new Mt[t](e)},{list:Mt}=St;class Tt extends I{constructor(t,e){super(t,e)}}Tt.BEFORE_OPEN="innerEditor.before_open",Tt.OPEN="innerEditor.open",Tt.BEFORE_CLOSE="innerEditor.before_close",Tt.CLOSE="innerEditor.close";class Ot extends I{constructor(t,e){super(t,e)}}Ot.GROUP="editor.group",Ot.BEFORE_UNGROUP="editor.before_ungroup",Ot.UNGROUP="editor.ungroup",Ot.OPEN="editor.open_group",Ot.CLOSE="editor.close_group";class Pt extends e.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,i){super(i),this.config=e.DataHelper.clone(Et),this.leafList=new e.LeafList,this.openedGroupList=new e.LeafList,this.simulateTarget=new e.Rect({visible:!1}),this.editBox=new pt(this),this.editToolList={},this.selector=new q(this),this.editMask=new mt(this),this.targetEventIds=[],t&&(this.config=e.DataHelper.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&bt(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||St.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof i.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(i.DragEvent.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof i.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(e.getInnerPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const n=lt.getScaleData(e,this.dragStartBounds,i,t.getInnerTotal(e),s,lt.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:l}=t.current;if(o&&"resize-line"===l)return this.onSkew(t);const{element:h}=this;let d,c;if(t instanceof i.RotateEvent){if("rotate"!==s)return;t.stop(),c=t.rotation,d=h.getInnerPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=lt.getRotateData(h.boxBounds,a,t.getInner(h),h.getInnerPoint(e),t.shiftKey?null:h.around||h.origin||n||"center");c=i.rotation,d=i.origin}c=e.MathHelper.getGapRotation(c,r,h.rotation),c&&(h.scaleX*h.scaleY<0&&(c=-c),this.rotateOf(d,e.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=lt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),lt.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new C(C.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=new B(B.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.scaleOf(t,e,i))),a=new B(B.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.flip(t))):new e.Matrix(e.LeafHelper.getFlipTransform(i,t)),n=new B(B.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.rotateOf(t,e))),n=new V(V.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.skewOf(t,e,i))),a=new D(D.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}getWorldOrigin(t){return this.element.getWorldPoint(e.LeafHelper.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:i}=this,o=new e.Matrix(i.worldTransform);return t(),new e.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=_t.group(this.list,this.element,t),this.emitGroupEvent(Ot.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Ot.BEFORE_UNGROUP,t))),this.target=_t.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Ot.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Ot.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Ot.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:i}=t;this.editing&&(i=[],t.forEach((t=>this.list.every((i=>!e.LeafHelper.hasParent(i,t)))&&i.push(t)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Ot(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&St.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||St.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Tt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Tt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Tt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Tt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new Tt(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(_t.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(_t.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[this.app.on_(i.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),this.app.on_(i.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),this.app.on_(i.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),t.on_(e.RenderEvent.START,this.update,this),t.on_([i.KeyEvent.HOLD,i.KeyEvent.UP],(t=>{dt(this,t)})),t.on_(i.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}H([z((function(t,e){t.emitEvent(new I(I.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Pt.prototype,"hoverTarget",void 0),H([z((function(t,i){const{target:o}=t;o?t.leafList=o instanceof e.LeafList?o:new e.LeafList(o):t.leafList.reset(),t.emitEvent(new I(I.SELECT,{editor:t,value:o,oldValue:i})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&bt(t),ct(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],Pt.prototype,"target",void 0);class Ht{static registerInnerEditor(){St.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new e.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}t.EditTool=class extends Ht{static registerEditTool(){St.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=H([kt()],t.EditTool);const{left:Rt,right:It}=e.Direction9,{move:Ct,copy:Bt}=e.PointHelper;return t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:i,direction:o,lockRatio:s,around:n}=t,r=t.target,a=o===Rt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const t=e.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(t,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(Ct(t,n,r),o&&Ct(e,-n,-r)):(o&&Ct(t,-n,-r),Ct(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Bt(o[7],i),Bt(e[7],i),Bt(o[3],a),Bt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Rt||t===It,o[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=H([kt()],t.LineEditTool),e.Creator.editor=function(t){return new Pt(t)},e.UI.setEditConfig=function(t){e.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},e.UI.setEditOuter=function(t){e.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},e.UI.setEditInner=function(t){e.defineKey(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})},t.EditBox=pt,t.EditDataHelper=lt,t.EditPoint=ut,t.EditSelect=q,t.EditSelectHelper=j,t.EditToolCreator=St,t.Editor=Pt,t.EditorEvent=I,t.EditorGroupEvent=Ot,t.EditorHelper=_t,t.EditorMoveEvent=C,t.EditorRotateEvent=V,t.EditorScaleEvent=B,t.EditorSkewEvent=D,t.InnerEditor=Ht,t.InnerEditorEvent=Tt,t.PathScaler=m,t.SelectArea=F,t.Stroker=U,t.registerEditTool=kt,t.registerInnerEditor=xt,t.scaleResize=x,t.scaleResizeFontSize=S,t.scaleResizeGroup=O,t.scaleResizePath=M,t.scaleResizePoints=T,t}({},LeaferUI,LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.editor=function(t,e,i){"use strict";const{M:o,L:s,C:n,Q:r,Z:a,N:l,D:h,X:d,G:c,F:g,O:u,P:f,U:p}=e.PathCommandMap,m={scale(t,e,i){if(!t)return;let m,E=0,b=t.length;for(;E<b;)switch(m=t[E],m){case o:case s:v(t,e,i,E,1),E+=3;break;case n:v(t,e,i,E,3),E+=7;break;case r:v(t,e,i,E,2),E+=5;break;case a:E+=1;break;case l:v(t,e,i,E,2),E+=5;break;case h:v(t,e,i,E,2),E+=9;break;case d:v(t,e,i,E,2),E+=6;break;case c:v(t,e,i,E,2),E+=9;break;case g:v(t,e,i,E,2),E+=5;break;case u:t[E]=c,t.splice(E+4,0,t[E+3],0),v(t,e,i,E,2),E+=9,b+=2;break;case f:t[E]=g,t.splice(E+4,0,t[E+3]),v(t,e,i,E,2),E+=5,b+=1;break;case p:v(t,e,i,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:v}=m,E=e.MatrixHelper.get(),{topLeft:b,top:y,topRight:L,right:_,bottom:w,left:k}=e.Direction9;function x(t,e,i){t.pathInputed?S(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function M(t,e,i){const{app:o}=t,s=o&&o.editor;let n=e;if(s.editing){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s.resizeDirection){case y:case w:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case k:case _:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case b:case L:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__;r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}function S(t,e,i){m.scale(t.__.path,e,i),t.path=t.__.path}function T(t,e,i){m.scalePoints(t.__.points,e,i),t.points=t.__.points}function O(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)E.a=e,E.d=i,o[t].transform(E,!0)}const P=e.Leaf.prototype;function H(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function R(t){return t?t instanceof Array?t:[t]:[]}P.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},P.__scaleResize=function(t,e){x(this,t,e)},P.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},P.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},e.Text.prototype.__scaleResize=function(t,e){this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize?M(this,t,e):x(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){S(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?S(this,t,e):this.points?T(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?S(this,t,e):this.points?T(this,t,e):x(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){O(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?O(this,t,e):(x(this,t,e),this.__.resizeChildren&&O(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class B extends e.Event{get list(){return R(this.value)}get oldList(){return R(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}B.SELECT="editor.select",B.HOVER="editor.hover";class I extends B{constructor(t,e){super(t,e)}}I.MOVE="editor.move";class C extends B{constructor(t,e){super(t,e)}}C.SCALE="editor.scale";class V extends B{constructor(t,e){super(t,e)}}V.ROTATE="editor.rotate";class D extends B{constructor(t,e){super(t,e)}}function z(t){return(i,o)=>{const s="_"+o;e.defineKey(i,o,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}D.SKEW="editor.skew";const A=e.MatrixHelper.get(),{abs:Z}=Math,{copy:W,scale:G}=e.MatrixHelper;class U extends e.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=Z(s.__world.scaleX),l=Z(s.__world.scaleY);if(o!==l){W(A,s.__world),G(A,1/o,1/l),t.setWorld(A,i.matrix),t.beginPath(),this.__.strokeWidth=r;const{x:e,y:n,width:a,height:h}=s.__layout.boxBounds;t.rect(e*o,n*l,a*o,h*l)}else t.setWorld(s.__world,i.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=r/Z(s.__world.scaleX);n&&("string"==typeof n?e.Paint.stroke(n,this,t):e.Paint.strokes(n,this,t)),a&&("string"==typeof a?e.Paint.fill(a,this,t):e.Paint.fills(a,this,t))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}H([z((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],U.prototype,"target",void 0);class F extends e.Group{constructor(t){super(t),this.strokeArea=new e.Rect({strokeAlign:"center"}),this.fillArea=new e.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:X,Yes:Y,NoAndSkip:N,YesAndSkip:K}=e.Answer,j={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?K:N;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?K:X;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return Y}return X}return t.isBranch?N:X}},{findOne:$}=j;class q extends e.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new U,this.targetStroker=new U,this.bounds=new e.Bounds,this.selectArea=new F,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInnerPoint(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:i}=this,o=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new e.LeafList(i.app.find(j.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!$(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const i={exclude:new e.LeafList(this.editor.editBox.rect)};return $(t.target.leafer.interaction.findPath(t,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):$(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(B.HOVER,this.onHover,this),t.on_(B.SELECT,this.onSelect,this),e.on_(i.PointerEvent.MOVE,this.onPointerMove,this),e.on_(i.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),e.on_(i.PointerEvent.TAP,this.onTap,this),e.on_(i.DragEvent.START,this.onDragStart,this,!0),e.on_(i.DragEvent.DRAG,this.onDrag,this),e.on_(i.DragEvent.END,this.onDragEnd,this),e.on_(i.MoveEvent.MOVE,this.onAutoMove,this),e.on_([i.ZoomEvent.ZOOM,i.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Q,top:J,topRight:tt,right:et,bottomRight:it,bottom:ot,bottomLeft:st,left:nt}=e.Direction9,{toPoint:rt}=e.AroundHelper,{within:at}=e.MathHelper,lt={getScaleData(t,e,i,o,s,n,r,a){let l,h={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=v<0?-1:1,y=E<0?-1:1,L=a?v:b*g.width/p,_=a?E:y*g.height/m;o.x*=a?v:b,o.y*=a?E:y,Math.abs(o.x)===p&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const w=(-o.y+m)/m,k=(o.x+p)/p,x=(o.y+m)/m,M=(-o.x+p)/p;switch(i){case J:c=w,l="bottom";break;case et:d=k,l="left";break;case ot:c=x,l="top";break;case nt:d=M,l="right";break;case Q:c=w,d=M,l="bottom-right";break;case tt:c=w,d=k,l="bottom-left";break;case it:c=x,d=k,l="top-left";break;case st:c=x,d=M,l="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case J:case ot:t=c;break;case nt:case et:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=L,c/=_,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=at(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=at(e*c,f)/e}return rt(n||l,g,h,!0),{origin:h,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(t,i,o,s,n){let r,a={};switch(i){case Q:r="bottom-right";break;case tt:r="bottom-left";break;case it:r="top-left";break;case st:r="top-right";break;default:r="center"}return rt(n||r,t,a,!0),{origin:a,rotation:e.PointHelper.getRotation(s,a,o)}},getSkewData(t,i,o,s){let n,r,a={},l=0,h=0;switch(i){case J:r={x:.5,y:0},n="bottom",l=1;break;case ot:r={x:.5,y:1},n="top",l=1;break;case nt:r={x:0,y:.5},n="right",h=1;break;case et:r={x:1,y:.5},n="left",h=1}const{width:d,height:c}=t;r.x=r.x*d,r.y=r.y*c,rt(s||n,t,a,!0);const g=e.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-g:h=g,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case nt:t=et;break;case Q:t=tt;break;case st:t=it;break;case et:t=nt;break;case tt:t=Q;break;case it:t=st}if(i)switch(t){case J:t=ot;break;case Q:t=st;break;case tt:t=it;break;case ot:t=J;break;case st:t=Q;break;case it:t=tt}return t}},ht={};function dt(t,i){const{editBox:o}=t,s=o.enterPoint;if(!s||!t.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=t.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:f}=o;let p="resize"===g;p&&d&&(i.metaKey||i.ctrlKey||!h)&&(p=!1);const m=c&&!p&&"resize-line"===s.name?l:p?r:a;n+=45*(lt.getFlipDirection(s.direction,u,f)+1),n=2*Math.round(e.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:b}=m,y=v+n;ht[y]?s.cursor=ht[y]:ht[y]=s.cursor={url:gt(v,n),x:E,y:b}}function ct(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function gt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class ut extends e.Box{}const ft=["top","right","bottom","left"];class pt extends e.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new e.Group,this.rect=new e.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new ut({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new e.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new ut({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new ut({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new ut({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,l,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&!!l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=t,{rect:n,circle:r,buttons:a,resizePoints:l,rotatePoints:h,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:f}=i,p="number"==typeof f?f:10,m=!(f&&o<p&&s<p);let v,E,b,y={};for(let n=0;n<8;n++)e.AroundHelper.toPoint(e.AroundHelper.directionData[n],t,y),E=l[n],v=h[n],b=d[Math.floor(n/2)],E.set(y),v.set(y),b.set(y),E.visible=b.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(b.width=o,E.width>o-30&&(E.visible=!1)):(b.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=ft.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let l=ft.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?lt.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l;this.setButtonPosition(e,h,s,!!n),o&&(e.rotation=90*(h-l)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),dt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,o){const{editor:s}=this;t.direction=o,t.pointType=e,t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,this.onDrag,this),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(i.PointerEvent.ENTER,(e=>{this.enterPoint=t,dt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(B.SELECT,this.onSelect,this),t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,e.onMove,e),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.PointerEvent.ENTER,(()=>ct(e))),t.on_(i.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(i.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class mt extends e.UI{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:o}=i.mergeConfig;if(o&&i.list.length){const{rect:s}=i.editBox,{width:n,height:r}=s.__;t.resetTransform(),t.fillWorld(t.bounds,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const vt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Et={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${vt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${vt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${vt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0};function bt(t){const{simulateTarget:i,leafList:o}=t,{x:s,y:n,width:r,height:a}=(new e.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const yt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Lt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),_t={group(t,i,o){t.sort(Lt);const{app:s,parent:n}=t[0];let r;r=o&&o.add?o:new e.Group(o),n.addAt(r,n.children.indexOf(t[0])),t.sort(yt);const a=new e.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(yt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Lt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},wt=e.Debug.get("EditToolCreator");function kt(){return t=>{Mt.register(t)}}const xt=kt,Mt={list:{},register(t){const{tag:e}=t.prototype;St[e]?wt.repeat(e):St[e]=t},get:(t,e)=>new St[t](e)},{list:St}=Mt;class Tt extends B{constructor(t,e){super(t,e)}}Tt.BEFORE_OPEN="innerEditor.before_open",Tt.OPEN="innerEditor.open",Tt.BEFORE_CLOSE="innerEditor.before_close",Tt.CLOSE="innerEditor.close";class Ot extends B{constructor(t,e){super(t,e)}}Ot.GROUP="editor.group",Ot.BEFORE_UNGROUP="editor.before_ungroup",Ot.UNGROUP="editor.ungroup",Ot.OPEN="editor.open_group",Ot.CLOSE="editor.close_group";class Pt extends e.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,i){super(i),this.config=e.DataHelper.clone(Et),this.leafList=new e.LeafList,this.openedGroupList=new e.LeafList,this.simulateTarget=new e.Rect({visible:!1}),this.editBox=new pt(this),this.editToolList={},this.selector=new q(this),this.editMask=new mt(this),this.targetEventIds=[],t&&(this.config=e.DataHelper.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&bt(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||Mt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof i.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(i.DragEvent.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof i.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const n=lt.getScaleData(e,this.dragStartBounds,i,t.getInnerTotal(e),s,lt.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:l}=t.current;if(o&&"resize-line"===l)return this.onSkew(t);const{element:h}=this;let d,c;if(t instanceof i.RotateEvent){if("rotate"!==s)return;t.stop(),c=t.rotation,d=h.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=lt.getRotateData(h.boxBounds,a,t.getBoxPoint(h),h.getBoxPoint(e),t.shiftKey?null:h.around||h.origin||n||"center");c=i.rotation,d=i.origin}c=e.MathHelper.getGapRotation(c,r,h.rotation),c&&(h.scaleX*h.scaleY<0&&(c=-c),this.rotateOf(d,e.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=lt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),lt.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new I(I.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=new C(C.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.scaleOf(t,e,i))),a=new C(C.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.flip(t))):new e.Matrix(e.LeafHelper.getFlipTransform(i,t)),n=new C(C.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.rotateOf(t,e))),n=new V(V.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.skewOf(t,e,i))),a=new D(D.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}getWorldOrigin(t){return this.element.getWorldPoint(e.LeafHelper.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:i}=this,o=new e.Matrix(i.worldTransform);return t(),new e.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=_t.group(this.list,this.element,t),this.emitGroupEvent(Ot.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Ot.BEFORE_UNGROUP,t))),this.target=_t.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Ot.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Ot.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Ot.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:i}=t;this.editing&&(i=[],t.forEach((t=>this.list.every((i=>!e.LeafHelper.hasParent(i,t)))&&i.push(t)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Ot(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&Mt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||Mt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Tt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Tt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Tt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Tt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new Tt(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(_t.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(_t.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[this.app.on_(i.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),this.app.on_(i.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),this.app.on_(i.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),t.on_(e.RenderEvent.START,this.update,this),t.on_([i.KeyEvent.HOLD,i.KeyEvent.UP],(t=>{dt(this,t)})),t.on_(i.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}H([z((function(t,e){t.emitEvent(new B(B.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Pt.prototype,"hoverTarget",void 0),H([z((function(t,i){const{target:o}=t;o?t.leafList=o instanceof e.LeafList?o:new e.LeafList(o):(t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new B(B.SELECT,{editor:t,value:o,oldValue:i})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&bt(t),ct(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],Pt.prototype,"target",void 0);class Ht{static registerInnerEditor(){Mt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new e.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}t.EditTool=class extends Ht{static registerEditTool(){Mt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=H([kt()],t.EditTool);const{left:Rt,right:Bt}=e.Direction9,{move:It,copy:Ct}=e.PointHelper;return t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:i,direction:o,lockRatio:s,around:n}=t,r=t.target,a=o===Rt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const t=e.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(t,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(It(t,n,r),o&&It(e,-n,-r)):(o&&It(t,-n,-r),It(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Ct(o[7],i),Ct(e[7],i),Ct(o[3],a),Ct(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Rt||t===Bt,o[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=H([kt()],t.LineEditTool),e.Creator.editor=function(t){return new Pt(t)},e.UI.setEditConfig=function(t){e.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},e.UI.setEditOuter=function(t){e.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},e.UI.setEditInner=function(t){e.defineKey(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})},t.EditBox=pt,t.EditDataHelper=lt,t.EditPoint=ut,t.EditSelect=q,t.EditSelectHelper=j,t.EditToolCreator=Mt,t.Editor=Pt,t.EditorEvent=B,t.EditorGroupEvent=Ot,t.EditorHelper=_t,t.EditorMoveEvent=I,t.EditorRotateEvent=V,t.EditorScaleEvent=C,t.EditorSkewEvent=D,t.InnerEditor=Ht,t.InnerEditorEvent=Tt,t.PathScaler=m,t.SelectArea=F,t.Stroker=U,t.registerEditTool=kt,t.registerInnerEditor=xt,t.scaleResize=x,t.scaleResizeFontSize=M,t.scaleResizeGroup=O,t.scaleResizePath=S,t.scaleResizePoints=T,t}({},LeaferUI,LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/editor",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "@leafer-in/editor",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,9 +34,9 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@leafer-ui/core": "^1.0.2",
38
- "@leafer-ui/interface": "^1.0.2",
39
- "@leafer-in/resize": "^1.0.2",
40
- "@leafer-in/interface": "^1.0.2"
37
+ "@leafer-ui/core": "^1.0.4",
38
+ "@leafer-ui/interface": "^1.0.4",
39
+ "@leafer-in/resize": "^1.0.4",
40
+ "@leafer-in/interface": "^1.0.4"
41
41
  }
42
42
  }
package/src/Editor.ts CHANGED
@@ -187,7 +187,7 @@ export class Editor extends Group implements IEditor {
187
187
 
188
188
  if (e instanceof ZoomEvent) {
189
189
 
190
- if (resizeable === 'zoom') e.stop(), this.scaleOf(element.getInnerPoint(e), e.scale, e.scale)
190
+ if (resizeable === 'zoom') e.stop(), this.scaleOf(element.getBoxPoint(e), e.scale, e.scale)
191
191
 
192
192
  } else {
193
193
 
@@ -218,13 +218,13 @@ export class Editor extends Group implements IEditor {
218
218
 
219
219
  if (e instanceof RotateEvent) {
220
220
 
221
- if (rotateable === 'rotate') e.stop(), rotation = e.rotation, origin = element.getInnerPoint(e)
221
+ if (rotateable === 'rotate') e.stop(), rotation = e.rotation, origin = element.getBoxPoint(e)
222
222
  else return
223
223
 
224
224
  } else {
225
225
 
226
226
  const last = { x: e.x - e.moveX, y: e.y - e.moveY }
227
- const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getInner(element), element.getInnerPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'))
227
+ const data = EditDataHelper.getRotateData(element.boxBounds, direction, e.getBoxPoint(element), element.getBoxPoint(last), e.shiftKey ? null : (element.around || element.origin || around || 'center'))
228
228
  rotation = data.rotation
229
229
  origin = data.origin
230
230
 
@@ -139,7 +139,7 @@ export class EditSelect extends Group implements IEditSelect {
139
139
  if (this.allowDrag(e)) {
140
140
  const { editor } = this
141
141
  const { stroke, area } = editor.mergeConfig
142
- const { x, y } = e.getInner(this)
142
+ const { x, y } = e.getInnerPoint(this)
143
143
 
144
144
  this.bounds.set(x, y)
145
145
 
@@ -13,6 +13,7 @@ export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
13
13
  editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target as IUI)
14
14
  } else {
15
15
  editor.leafList.reset()
16
+ editor.closeInnerEditor()
16
17
  }
17
18
 
18
19
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, { editor, value: target, oldValue }))
@@ -128,7 +128,7 @@ export const EditDataHelper = {
128
128
  }
129
129
 
130
130
 
131
- toPoint(around || align, boxBounds, origin)
131
+ toPoint(around || align, boxBounds, origin, true)
132
132
 
133
133
  return { origin, scaleX, scaleY, direction, lockRatio, around }
134
134
  },
@@ -153,7 +153,7 @@ export const EditDataHelper = {
153
153
  align = 'center'
154
154
  }
155
155
 
156
- toPoint(around || align, bounds, origin)
156
+ toPoint(around || align, bounds, origin, true)
157
157
 
158
158
  return { origin, rotation: PointHelper.getRotation(last, origin, current) }
159
159
  },
@@ -184,12 +184,12 @@ export const EditDataHelper = {
184
184
  skewY = 1
185
185
  }
186
186
 
187
- const { x, y, width, height } = bounds
187
+ const { width, height } = bounds
188
188
 
189
- last.x = x + last.x * width
190
- last.y = y + last.y * height
189
+ last.x = last.x * width
190
+ last.y = last.y * height
191
191
 
192
- toPoint(around || align, bounds, origin)
192
+ toPoint(around || align, bounds, origin, true)
193
193
 
194
194
  const rotation = PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) })
195
195
  skewX ? skewX = -rotation : skewY = rotation