@leafer-in/editor 2.2.5 → 2.2.7

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
@@ -354,7 +354,7 @@ function eachFind(children, list, bounds, mode) {
354
354
  } else {
355
355
  isFind = bounds[mode](child.__layout.boxBounds, child.__world) && data.hitSelf;
356
356
  if (child.isBranch) {
357
- if (!data.hitChildren) {
357
+ if (!data.hitChildren || isFind && child.children.every(item => !item.editable)) {
358
358
  if (isFind) list.push(child);
359
359
  continue;
360
360
  }
@@ -1045,6 +1045,13 @@ class EditBox extends draw.Group {
1045
1045
  view.add([ ...rotatePoints, rect, circle, buttons, ...resizeLines, ...resizePoints ]);
1046
1046
  this.add(view);
1047
1047
  }
1048
+ showView() {
1049
+ this.view.opacity = 1;
1050
+ this.update();
1051
+ }
1052
+ hideView() {
1053
+ this.view.opacity = 0;
1054
+ }
1048
1055
  load() {
1049
1056
  const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
1050
1057
  const {stroke: stroke, strokeWidth: strokeWidth, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
@@ -1080,12 +1087,13 @@ class EditBox extends draw.Group {
1080
1087
  } ];
1081
1088
  }
1082
1089
  if (single) draw.DataHelper.stintSet(target.__world, "ignorePixelSnap", ignorePixelSnap);
1083
- updateMoveCursor(this);
1090
+ this.updateMoveCursor();
1084
1091
  this.loadWidgets();
1085
1092
  }
1086
1093
  update() {
1087
- const {editor: editor} = this;
1088
- const {x: x, y: y, scaleX: scaleX, scaleY: scaleY, rotation: rotation, skewX: skewX, skewY: skewY, width: width, height: height} = this.target.getLayoutBounds("box", editor, true);
1094
+ const {editor: editor, target: target} = this;
1095
+ if (!target) return;
1096
+ const {x: x, y: y, scaleX: scaleX, scaleY: scaleY, rotation: rotation, skewX: skewX, skewY: skewY, width: width, height: height} = target.getLayoutBounds("box", editor, true);
1089
1097
  this.visible = !this.target.locked;
1090
1098
  this.set({
1091
1099
  x: x,
@@ -1228,6 +1236,12 @@ class EditBox extends draw.Group {
1228
1236
  const {resizeLine: resizeLine} = this.mergedConfig;
1229
1237
  return draw.isArray(resizeLine) ? resizeLine : [ resizeLine ];
1230
1238
  }
1239
+ updateMoveCursor() {
1240
+ updateMoveCursor(this);
1241
+ }
1242
+ updatePointCursor(e) {
1243
+ updatePointCursor(this, e);
1244
+ }
1231
1245
  onDragStart(e) {
1232
1246
  this.dragging = true;
1233
1247
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
@@ -1256,7 +1270,7 @@ class EditBox extends draw.Group {
1256
1270
  if (resizing) transformTool.onScale(e);
1257
1271
  if (skewing) transformTool.onSkew(e);
1258
1272
  }
1259
- updatePointCursor(this, e);
1273
+ this.updatePointCursor(e);
1260
1274
  }
1261
1275
  onDragEnd(e) {
1262
1276
  this.onTransformEnd(e);
@@ -1350,7 +1364,7 @@ class EditBox extends draw.Group {
1350
1364
  return e.metaKey || e.ctrlKey;
1351
1365
  }
1352
1366
  onKey(e) {
1353
- updatePointCursor(this, e);
1367
+ this.updatePointCursor(e);
1354
1368
  }
1355
1369
  onArrow(e) {
1356
1370
  if (this.canUse) {
@@ -1409,7 +1423,7 @@ class EditBox extends draw.Group {
1409
1423
  point.direction = direction;
1410
1424
  point.pointType = type;
1411
1425
  this.__eventIds.push(point.on_([ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.ENTER, e => {
1412
- this.enterPoint = point, updatePointCursor(this, e);
1426
+ this.enterPoint = point, this.updatePointCursor(e);
1413
1427
  } ], [ core.PointerEvent.LEAVE, () => {
1414
1428
  this.enterPoint = null;
1415
1429
  } ] ]));
@@ -2399,6 +2413,7 @@ class InnerEditor {
2399
2413
  this._editBox = value;
2400
2414
  }
2401
2415
  constructor(editor) {
2416
+ this.configKeepKeys = [ "editBox" ];
2402
2417
  this.eventIds = [];
2403
2418
  this.editor = editor;
2404
2419
  this.create();
@@ -2424,6 +2439,12 @@ class InnerEditor {
2424
2439
  this.view = new draw.Group;
2425
2440
  this.onCreate();
2426
2441
  }
2442
+ showView() {
2443
+ this.view.opacity = 1;
2444
+ }
2445
+ hideView() {
2446
+ this.view.opacity = 0;
2447
+ }
2427
2448
  onLoad() {}
2428
2449
  load() {
2429
2450
  const {editor: editor} = this;
@@ -2434,16 +2455,27 @@ class InnerEditor {
2434
2455
  }
2435
2456
  onUpdate() {}
2436
2457
  update() {
2437
- this.onUpdate();
2458
+ if (this.editor) {
2459
+ this.updateEditBoxConfig();
2460
+ this.onUpdate();
2461
+ }
2438
2462
  }
2439
2463
  onUnload() {}
2440
2464
  unload() {
2441
2465
  const {editor: editor} = this;
2442
2466
  if (editor) {
2467
+ this.unloadEditBoxConfig();
2443
2468
  if (editor.app && this.mode === "focus") editor.selector.hittable = editor.app.tree.hitChildren = true;
2444
2469
  this.onUnload();
2445
2470
  }
2446
2471
  }
2472
+ updateEditBoxConfig() {
2473
+ const {mergeConfig: mergeConfig} = this;
2474
+ if (mergeConfig) this.editBox.config = mergeConfig.editBox;
2475
+ }
2476
+ unloadEditBoxConfig() {
2477
+ this.editBox.config = undefined;
2478
+ }
2447
2479
  onDestroy() {}
2448
2480
  destroy() {
2449
2481
  this.onDestroy();
@@ -2455,6 +2487,8 @@ class InnerEditor {
2455
2487
  }
2456
2488
  }
2457
2489
 
2490
+ __decorate([ editToolMergeConfigAttr() ], InnerEditor.prototype, "mergeConfig", void 0);
2491
+
2458
2492
  exports.EditTool = class EditTool extends InnerEditor {
2459
2493
  static registerEditTool(name, changeTag) {
2460
2494
  EditToolCreator.register(this, name);
@@ -2468,6 +2502,7 @@ exports.EditTool = class EditTool extends InnerEditor {
2468
2502
  return "EditTool";
2469
2503
  }
2470
2504
  onMove(e) {
2505
+ if (this.isMotionElement) return this.onMoveMotion(e); else if (this.isFlowElement) return this.onMoveFlow(e);
2471
2506
  const {moveX: moveX, moveY: moveY, editor: editor} = e;
2472
2507
  const {app: app, list: list} = editor;
2473
2508
  app.lockLayout();
@@ -2511,11 +2546,13 @@ exports.EditTool = class EditTool extends InnerEditor {
2511
2546
  this.onLoad();
2512
2547
  }
2513
2548
  update() {
2549
+ this.updateEditBoxConfig();
2514
2550
  this.editBox.update();
2515
2551
  this.onUpdate();
2516
2552
  }
2517
2553
  unload() {
2518
2554
  this.editBox.view.visible = false;
2555
+ this.unloadEditBoxConfig();
2519
2556
  this.onUnload();
2520
2557
  }
2521
2558
  };
@@ -352,7 +352,7 @@ function eachFind(children, list, bounds, mode) {
352
352
  } else {
353
353
  isFind = bounds[mode](child.__layout.boxBounds, child.__world) && data.hitSelf;
354
354
  if (child.isBranch) {
355
- if (!data.hitChildren) {
355
+ if (!data.hitChildren || isFind && child.children.every(item => !item.editable)) {
356
356
  if (isFind) list.push(child);
357
357
  continue;
358
358
  }
@@ -1043,6 +1043,13 @@ class EditBox extends Group {
1043
1043
  view.add([ ...rotatePoints, rect, circle, buttons, ...resizeLines, ...resizePoints ]);
1044
1044
  this.add(view);
1045
1045
  }
1046
+ showView() {
1047
+ this.view.opacity = 1;
1048
+ this.update();
1049
+ }
1050
+ hideView() {
1051
+ this.view.opacity = 0;
1052
+ }
1046
1053
  load() {
1047
1054
  const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
1048
1055
  const {stroke: stroke, strokeWidth: strokeWidth, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
@@ -1078,12 +1085,13 @@ class EditBox extends Group {
1078
1085
  } ];
1079
1086
  }
1080
1087
  if (single) DataHelper.stintSet(target.__world, "ignorePixelSnap", ignorePixelSnap);
1081
- updateMoveCursor(this);
1088
+ this.updateMoveCursor();
1082
1089
  this.loadWidgets();
1083
1090
  }
1084
1091
  update() {
1085
- const {editor: editor} = this;
1086
- const {x: x, y: y, scaleX: scaleX, scaleY: scaleY, rotation: rotation, skewX: skewX, skewY: skewY, width: width, height: height} = this.target.getLayoutBounds("box", editor, true);
1092
+ const {editor: editor, target: target} = this;
1093
+ if (!target) return;
1094
+ const {x: x, y: y, scaleX: scaleX, scaleY: scaleY, rotation: rotation, skewX: skewX, skewY: skewY, width: width, height: height} = target.getLayoutBounds("box", editor, true);
1087
1095
  this.visible = !this.target.locked;
1088
1096
  this.set({
1089
1097
  x: x,
@@ -1226,6 +1234,12 @@ class EditBox extends Group {
1226
1234
  const {resizeLine: resizeLine} = this.mergedConfig;
1227
1235
  return isArray(resizeLine) ? resizeLine : [ resizeLine ];
1228
1236
  }
1237
+ updateMoveCursor() {
1238
+ updateMoveCursor(this);
1239
+ }
1240
+ updatePointCursor(e) {
1241
+ updatePointCursor(this, e);
1242
+ }
1229
1243
  onDragStart(e) {
1230
1244
  this.dragging = true;
1231
1245
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
@@ -1254,7 +1268,7 @@ class EditBox extends Group {
1254
1268
  if (resizing) transformTool.onScale(e);
1255
1269
  if (skewing) transformTool.onSkew(e);
1256
1270
  }
1257
- updatePointCursor(this, e);
1271
+ this.updatePointCursor(e);
1258
1272
  }
1259
1273
  onDragEnd(e) {
1260
1274
  this.onTransformEnd(e);
@@ -1348,7 +1362,7 @@ class EditBox extends Group {
1348
1362
  return e.metaKey || e.ctrlKey;
1349
1363
  }
1350
1364
  onKey(e) {
1351
- updatePointCursor(this, e);
1365
+ this.updatePointCursor(e);
1352
1366
  }
1353
1367
  onArrow(e) {
1354
1368
  if (this.canUse) {
@@ -1407,7 +1421,7 @@ class EditBox extends Group {
1407
1421
  point.direction = direction;
1408
1422
  point.pointType = type;
1409
1423
  this.__eventIds.push(point.on_([ [ DragEvent.START, this.onDragStart, this ], [ DragEvent.DRAG, this.onDrag, this ], [ DragEvent.END, this.onDragEnd, this ], [ PointerEvent.ENTER, e => {
1410
- this.enterPoint = point, updatePointCursor(this, e);
1424
+ this.enterPoint = point, this.updatePointCursor(e);
1411
1425
  } ], [ PointerEvent.LEAVE, () => {
1412
1426
  this.enterPoint = null;
1413
1427
  } ] ]));
@@ -2397,6 +2411,7 @@ class InnerEditor {
2397
2411
  this._editBox = value;
2398
2412
  }
2399
2413
  constructor(editor) {
2414
+ this.configKeepKeys = [ "editBox" ];
2400
2415
  this.eventIds = [];
2401
2416
  this.editor = editor;
2402
2417
  this.create();
@@ -2422,6 +2437,12 @@ class InnerEditor {
2422
2437
  this.view = new Group;
2423
2438
  this.onCreate();
2424
2439
  }
2440
+ showView() {
2441
+ this.view.opacity = 1;
2442
+ }
2443
+ hideView() {
2444
+ this.view.opacity = 0;
2445
+ }
2425
2446
  onLoad() {}
2426
2447
  load() {
2427
2448
  const {editor: editor} = this;
@@ -2432,16 +2453,27 @@ class InnerEditor {
2432
2453
  }
2433
2454
  onUpdate() {}
2434
2455
  update() {
2435
- this.onUpdate();
2456
+ if (this.editor) {
2457
+ this.updateEditBoxConfig();
2458
+ this.onUpdate();
2459
+ }
2436
2460
  }
2437
2461
  onUnload() {}
2438
2462
  unload() {
2439
2463
  const {editor: editor} = this;
2440
2464
  if (editor) {
2465
+ this.unloadEditBoxConfig();
2441
2466
  if (editor.app && this.mode === "focus") editor.selector.hittable = editor.app.tree.hitChildren = true;
2442
2467
  this.onUnload();
2443
2468
  }
2444
2469
  }
2470
+ updateEditBoxConfig() {
2471
+ const {mergeConfig: mergeConfig} = this;
2472
+ if (mergeConfig) this.editBox.config = mergeConfig.editBox;
2473
+ }
2474
+ unloadEditBoxConfig() {
2475
+ this.editBox.config = undefined;
2476
+ }
2445
2477
  onDestroy() {}
2446
2478
  destroy() {
2447
2479
  this.onDestroy();
@@ -2453,6 +2485,8 @@ class InnerEditor {
2453
2485
  }
2454
2486
  }
2455
2487
 
2488
+ __decorate([ editToolMergeConfigAttr() ], InnerEditor.prototype, "mergeConfig", void 0);
2489
+
2456
2490
  let EditTool = class EditTool extends InnerEditor {
2457
2491
  static registerEditTool(name, changeTag) {
2458
2492
  EditToolCreator.register(this, name);
@@ -2466,6 +2500,7 @@ let EditTool = class EditTool extends InnerEditor {
2466
2500
  return "EditTool";
2467
2501
  }
2468
2502
  onMove(e) {
2503
+ if (this.isMotionElement) return this.onMoveMotion(e); else if (this.isFlowElement) return this.onMoveFlow(e);
2469
2504
  const {moveX: moveX, moveY: moveY, editor: editor} = e;
2470
2505
  const {app: app, list: list} = editor;
2471
2506
  app.lockLayout();
@@ -2509,11 +2544,13 @@ let EditTool = class EditTool extends InnerEditor {
2509
2544
  this.onLoad();
2510
2545
  }
2511
2546
  update() {
2547
+ this.updateEditBoxConfig();
2512
2548
  this.editBox.update();
2513
2549
  this.onUpdate();
2514
2550
  }
2515
2551
  unload() {
2516
2552
  this.editBox.view.visible = false;
2553
+ this.unloadEditBoxConfig();
2517
2554
  this.onUnload();
2518
2555
  }
2519
2556
  };
@@ -1,2 +1,2 @@
1
- import{Event as t,isArray as e,Group as i,Matrix as s,defineKey as o,isNull as r,isUndefined as n,isObject as a,DataHelper as h,MatrixHelper as l,BoundsHelper as d,LeafBoundsHelper as c,getMatrixData as g,getBoundsData as u,surfaceType as f,UI as p,ColorConvert as m,isString as E,Paint as v,Rect as b,Bounds as w,LeafList as y,Direction9 as k,AroundHelper as L,MathHelper as T,PointHelper as x,isNumber as O,Box as S,Debug as _,ResizeEvent as B,getPointData as C,Text as M,LeafHelper as R,PropertyEvent as P,Plugin as V,RenderEvent as H,LeaferEvent as D,Creator as A,dataType as I}from"@leafer-ui/draw";import{PointerEvent as W,DragEvent as z,MoveEvent as F,ZoomEvent as Z,DragBoundsHelper as X,KeyEvent as Y,RotateEvent as G,useModule as U}from"@leafer-ui/core";import"@leafer-in/resize";function K(t,e,i,s){var o,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(r<3?o(n):r>3?o(e,i,n):o(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}function j(t){return t?e(t)?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class N extends t{get list(){return j(this.value)}get oldList(){return j(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}N.BEFORE_SELECT="editor.before_select",N.SELECT="editor.select",N.AFTER_SELECT="editor.after_select",N.BEFORE_HOVER="editor.before_hover",N.HOVER="editor.hover";const $=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),q=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),J={group(t,e,o){t.sort(q);const{app:r,parent:n}=t[0];let a;a=o&&o.add?o:new i(o),n.addAt(a,n.children.indexOf(t[0])),t.sort($);const h=new s(e.worldTransform);return h.divideParent(n.scrollWorldTransform),a.setTransform(h),a.editable=!0,a.hitChildren=!1,r.lockLayout(),t.forEach(t=>t.dropTo(a)),r.unlockLayout(),a},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.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort($),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(q),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})},mergeMaskConfig(t,e){},getSiblingMaskElements(t){}};function Q(t){return(i,s)=>{const r="_"+s;o(i,s,{get(){return this[r]},set(i){const o=this[r];if(o!==i){const n=this;if(n.config){const t="target"===s;if(t){const{beforeSelect:t}=n.config;if(t){const e=t({target:i});if(a(e))i=e;else if(!1===e)return}n.hasDimOthers&&n.cancelDimOthers(),e(i)&&i.length>1&&i.some(t=>t.locked||"single"===t.editable)&&(i=i.filter(t=>!(t.locked||"single"===t.editable))),n.single&&(delete n.element.syncEventer,delete n.element.__world.ignorePixelSnap)}const r=t?N.BEFORE_SELECT:N.BEFORE_HOVER;this.hasEvent(r)&&this.emitEvent(new N(r,{editor:n,value:i,oldValue:o}))}this[r]=i,t(this,o)}}})}}function tt(){return(t,e)=>{o(t,e,{get(){const t=this,{config:e,userConfig:i,configKeepKeys:s}=t,o=e?h.clone(e):{};if(s)for(let t in i)s.includes(t)||(o[t]=i[t]);return t.preMergedConfig&&t.preMergedConfig(o),s&&s.forEach(t=>{i[t]&&Object.assign(o[t],i[t])}),t.mergedConfig=o}})}}const{abs:et}=Math,{copy:it}=l,{setListWithFn:st}=d,{worldBounds:ot}=c,rt=g(),nt=u();class at extends p{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(st(nt,e,ot),t&&this.set(t),this.set(nt),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const o=this.__,{stroke:r,strokeWidth:n,fill:a}=o,{bounds:h}=e;for(let l=0;l<i.length;l++){s=i[l];const{worldTransform:d,worldRenderBounds:c}=s;if(c.width&&c.height&&(!h||h.hit(c,e.matrix))){const i=et(d.scaleX),h=et(d.scaleY);switch(it(rt,d),rt.half=n%2,t.setWorld(rt,e.matrix),t.beginPath(),this.strokePathType){case"box":const{boxBounds:e}=s.__layout;t.rect(e.x,e.y,e.width,e.height);break;case"stroke":const{strokeBounds:i}=s.__layout;t.rect(i.x,i.y,i.width,i.height);break;case"path":s.__drawPath(t);break;default:s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t)}if(o.strokeWidth=n/Math.max(i,h),o.shadow){const e=o.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,m.string(e.color))}r&&(E(r)?v.stroke(r,this,t,e):v.strokes(r,this,t,e)),a&&(E(a)?v.fill(a,this,t,e):v.fills(a,this,t,e)),o.shadow&&t.restore()}}o.strokeWidth=n}}destroy(){this.target=null,super.destroy()}}K([Q(function(t){const i=t.target;t.list=i?e(i)?i:[i]:[]})],at.prototype,"target",void 0),K([f("render-path")],at.prototype,"strokePathType",void 0);class ht extends i{constructor(t){super(t),this.strokeArea=new b({strokeAlign:"center"}),this.fillArea=new b,this.visible=0,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 lt={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e,i="hit"){const s=[];return dt([t],s,e,i),s}};function dt(t,e,i,s){let o,r,n;for(let a=0,h=t.length;a<h;a++)if(o=t[a],r=o.__,r.hittable&&r.visible&&!r.locked&&i.hit(o.__world)){if(r.editable&&"single"!==r.editable)if(o.isFrame){if(i.includes(o.__layout.boxBounds,o.__world)){e.push(o);continue}}else if(n=i[s](o.__layout.boxBounds,o.__world)&&r.hitSelf,o.isBranch){if(!r.hitChildren){n&&e.push(o);continue}}else n&&e.push(o);o.isBranch&&dt(o.children,e,i,s)}}const{findOne:ct,findByBounds:gt}=lt;class ut extends i{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new at,this.targetStroker=new at,this.bounds=new w,this.selectArea=new ht,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{hoverTarget:e,mergeConfig:i}=t,s=Object.assign({},i);e&&e.editConfig&&Object.assign(s,e.editConfig);const{stroke:o,strokeWidth:r,hover:n,hoverStyle:a,hoverPathType:h}=s;this.hoverStroker.setTarget(n?e:null,Object.assign({stroke:o,strokeWidth:r,strokePathType:h},a||{}))}}onSelect(){if(this.running){const{editor:t}=this;let{list:e}=t;const i=J.getSiblingMaskElements(t);i&&(e=i.concat(e)),this.targetStroker.setTarget(e),this.hoverStroker.target=null}}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedPathType:i,selectedStyle:s}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2),strokePathType:i},s||{}))}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,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(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,t.path.needUpdate=!0):this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(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:r}=t.getInnerPoint(this);this.bounds.set(o,r),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:r},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 y(gt(e.app,s,"includes"===e.mergedConfig.boxSelect?"includes":"hit"));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=0)}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){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||this.isHoldMultipleSelectKey(t)&&!ct(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new y(this.editor.editBox.rect)};return ct(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):ct(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[N.HOVER,this.onHover,this],[N.SELECT,this.onSelect,this]]),e.on_([[W.MOVE,this.onPointerMove,this],[W.BEFORE_DOWN,this.onBeforeDown,this],[W.TAP,this.onTap,this],[z.START,this.onDragStart,this,!0],[z.DRAG,this.onDrag,this],[z.END,this.onDragEnd,this],[F.MOVE,this.onAutoMove,this],[[Z.ZOOM,F.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:ft,top:pt,topRight:mt,right:Et,bottomRight:vt,bottom:bt,bottomLeft:wt,left:yt}=k,{toPoint:kt}=L,{within:Lt,sign:Tt}=T,{abs:xt}=Math,Ot={getScaleData(t,e,i,s,o,r,n,a){let h,l,d={},c=1,g=1;const{widthRange:u,heightRange:f,dragBounds:p,worldTransform:m,boxBounds:E}=t,{width:v,height:b}=e,w=xt(m.scaleX),y=xt(m.scaleY),k=t.scaleX/e.scaleX,L=t.scaleY/e.scaleY,T=Tt(k),x=Tt(L),S=a?k:T*E.width/v,_=a?L:x*E.height/b;if(O(s))c=g=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=a?k:T,s.y*=a?L:x;const t=(-s.y+b)/b,e=(s.x+v)/v,n=(s.y+b)/b,d=(-s.x+v)/v;switch(i){case pt:g=t,h="bottom";break;case Et:c=e,h="left";break;case bt:g=n,h="top";break;case yt:c=d,h="right";break;case ft:g=t,c=d,h="bottom-right";break;case mt:g=t,c=e,h="bottom-left";break;case vt:g=n,c=e,h="top-left";break;case wt:g=n,c=d,h="top-right"}if(o)if("corner"===o&&i%2)o=!1;else switch(i){case pt:case bt:c=g;break;case yt:case Et:g=c;break;default:l=Math.sqrt(xt(c*g)),c=Tt(c)*l,g=Tt(g)*l}}const B=1!==c,C=1!==g;if(B&&(c/=S),C&&(g/=_),n||(c<0&&(c=1/E.width/w),g<0&&(g=1/E.height/y)),kt(r||h,E,d,!0),p){const e={x:c,y:g};X.limitScaleOf(t,d,e,o),c=e.x,g=e.y}if(B&&u){const e=E.width*t.scaleX;c=Lt(e*c,u)/e}if(C&&f){const e=E.height*t.scaleY;g=Lt(e*g,f)/e}const M=w*E.width,R=y*E.height;return B&&xt(c*M)<1&&(c=1*Tt(c)/M),C&&xt(g*R)<1&&(g=1*Tt(g)/R),o&&c!==g&&(l=Math.min(xt(c),xt(g)),c=Tt(c)*l,g=Tt(g)*l),isFinite(c)||(c=1),isFinite(g)||(g=1),{origin:d,scaleX:c,scaleY:g,direction:i,lockRatio:o,around:r}},getRotateData(t,e,i,s,o){let r,n={};switch(e){case ft:r="bottom-right";break;case mt:r="bottom-left";break;case vt:r="top-left";break;case wt:r="top-right";break;default:r="center"}return kt(o||r,t.boxBounds,n,!0),{origin:n,rotation:x.getRotation(s,t.getWorldPointByBox(n),i)}},getSkewData(t,e,i,s){let o,r,n={},a=0,h=0;switch(e){case pt:case ft:r={x:.5,y:0},o="bottom",a=1;break;case bt:case vt:r={x:.5,y:1},o="top",a=1;break;case yt:case wt:r={x:0,y:.5},o="right",h=1;break;case Et:case mt:r={x:1,y:.5},o="left",h=1}const{boxBounds:l}=t,{width:d,height:c}=l;r.x=r.x*d,r.y=r.y*c,kt(s||o,l,n,!0);const g=x.getRotation(r,n,{x:r.x+(a?i.x:0),y:r.y+(h?i.y:0)});return a?a=-g:h=g,{origin:n,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 yt:t=Et;break;case ft:t=mt;break;case wt:t=vt;break;case Et:t=yt;break;case mt:t=ft;break;case vt:t=wt}if(i)switch(t){case pt:t=bt;break;case ft:t=wt;break;case mt:t=vt;break;case bt:t=pt;break;case wt:t=ft;break;case vt:t=mt}return t}},St={};function _t(t,e){const{enterPoint:i,dragging:s,skewing:o,resizing:r,flippedX:n,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Bt(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:g,skewCursor:u,moveable:f,resizeable:p,rotateable:m,skewable:E}=t.mergeConfig;if("move"===l)return i.cursor=d,void(f||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let v=l.includes("resize");v&&m&&(t.isHoldRotateKey(e)||!p)&&(v=!1);const b=E&&!v&&("resize-line"===i.name||"skew"===l),w=s?o?u:r?c:g:b?u:v?c:g;h+=45*(Ot.getFlipDirection(i.direction,n,a)+1),h=2*Math.round(T.formatRotation(h,!0)/2);const{url:y,x:k,y:L}=w,x=y+h;St[x]?i.cursor=St[x]:St[x]=i.cursor={url:Ct(y,h),x:k,y:L}}function Bt(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Ct(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Mt extends S{constructor(t){super(t),this.useFastShadow=!0}}const Rt=["top","right","bottom","left"],Pt=void 0,Vt=_.get("EditBox");class Ht extends i{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}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}get canUse(){return this.app&&this.editor.editing}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return E(t)||E(e)||E(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(t){super(),this.view=new i,this.rect=new Mt({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Mt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new i({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.widgets=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents(),this.createWidgets()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:r,resizeLines:n,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 Mt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Mt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),n.push(e),this.listenPointEvents(e,"resize",s)),i=new Mt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.add([...r,a,h,l,...n,...o]),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:o,resizePoints:n,resizeLines:a}=this,{stroke:l,strokeWidth:d,ignorePixelSnap:c}=e,g=this.getPointsStyle(),u=this.getMiddlePointsStyle(),f=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let t=0;t<8;t++)p=n[t],p.children.length&&p.clear(),p.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:g[t/2%g.length])),p.rotation=(t-(t%2?1:0))/2*90,t%2&&a[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},f[(t-1)/2%f.length]||{}));o.set(this.getPointStyle(e.circle||e.rotatePoint||g[0])),s.set(Object.assign({stroke:l,strokeWidth:d,opacity:1,editConfig:Pt},e.rect||{}));const m=r(e.rectThrough)?i:e.rectThrough;s.hittable=!m,m&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&h.stintSet(t.__world,"ignorePixelSnap",c),Bt(this),this.loadWidgets()}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:o,rotation:r,skewX:n,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:o,rotation:r,skewX:n,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l}),this.updateWidgets()}unload(){this.unloadWidgets(),this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,target:i,mergeConfig:s,single:o,rect:r,circle:a,buttons:h,resizePoints:l,rotatePoints:c,resizeLines:g}=this,{editMask:u}=e,{middlePoint:f,resizeable:p,rotateable:m,hideOnSmall:E,editBox:v,editBoxType:b,mask:w,dimOthers:y,bright:k,spread:T,hideRotatePoints:x,hideResizeLines:S}=s;if("stroke"===b){const{scaleX:e,scaleY:s}=i.worldTransform,{strokeBoxSpread:o}=i.__layout;o&&d.spread(t,[o*Math.abs(s),o*Math.abs(e)])}if(T&&d.spread(t,T),this.rectBounds=t,u.visible=!!w||0,n(y)&&n(k)?e.hasDimOthers&&e.cancelDimOthers():(e.setDimOthers(y),e.setBright(!!y||k),e.hasDimOthers=!0),this.view.worldOpacity){const{width:e,height:i}=t,n=O(E)?E:10,d=this.showPoints=v&&!(E&&e<n&&i<n);let u,b,w,y={};for(let s=0;s<8;s++)L.toPoint(L.directionData[s],t,y),b=l[s],u=c[s],b.set(y),u.set(y),b.visible=d&&!(!p&&!m),u.visible=d&&m&&p&&!x,s%2&&(w=g[(s-1)/2],w.set(y),w.visible=b.visible&&!S,b.visible&&(b.visible=!!f),u.visible&&(u.visible=!!f),(s+1)/2%2?(w.width=e+w.height,E&&2*b.width>e&&(b.visible=!1)):(w.width=i+w.height,E&&2*b.width>i&&(b.visible=!1)));a.visible=d&&m&&!(!s.circle&&!s.rotatePoint),a.visible&&this.layoutCircle(),r.path&&(r.path=null),r.set(Object.assign(Object.assign({},t),{visible:!o||v})),h.visible=d&&h.children.length>0||0,h.visible&&this.layoutButtons()}else r.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:o}=this.mergedConfig,r=Rt.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,e||i,!!o)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:o}=this.mergedConfig,{flippedX:r,flippedY:n}=this;let a=Rt.indexOf(e);(a%2&&r||(a+1)%2&&n)&&i&&(a=(a+2)%4);const h=i?Ot.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!o),i&&(t.rotation=90*(h-a)),t.scaleX=r?-1:1,t.scaleY=n?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],r=e%2,n=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*n;r?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:r}=this.mergedConfig,n={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:o,height:o,cornerRadius:r,offsetX:0,offsetY:0,editConfig:Pt};return t?Object.assign(n,t):n}getPointsStyle(){const{point:t}=this.mergedConfig;return e(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return e(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return e(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:o,rotateable:r,skewable:n,onCopy:a}=this.mergeConfig;"move"===i?(t.altKey&&a&&a()&&this.editor.single&&this.app.interaction.replaceDownTarget(this.target),s&&(this.moving=!0)):(i.includes("rotate")||this.isHoldRotateKey(t)||!o?(r&&(this.rotating=!0),"resize-rotate"===i?o&&(this.resizing=!0):"resize-line"===e.name&&(n&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&o&&(this.resizing=!0),"skew"===i&&n&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:o,skewing:r}=this;if(i)e.onMove(t);else if(s||o||r){const i=t.current;i.pointType&&(this.enterPoint=i),o&&e.onRotate(t),s&&e.onScale(t),r&&e.onSkew(t)}_t(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){const{hideOnMove:e}=this.mergedConfig;(this.moving||this.gesturing)&&(this.editor.opacity=e?0:1),this.resizing&&(B.resizingKeys=this.editor.leafList.keys);const{dragStartData:i,target:s}=this;i.x=t.x,i.y=t.y,i.totalOffset=C(),i.point={x:s.x,y:s.y},i.bounds=Object.assign({},s.getLayoutBounds("box","local")),i.rotation=s.rotation}onTransformEnd(t){this.canDragLimitAnimate&&(t instanceof z||t instanceof F)&&this.transformTool.onMove(t),this.resizing&&(B.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(t){if(this.canGesture&&"drag"!==t.moveType&&(t.stop(),E(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,t.type){case F.START:this.onTransformStart(t);break;case F.END:this.onTransformEnd(t);break;default:this.transformTool.onMove(t)}}onScale(t){if(this.canGesture&&(t.stop(),E(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,t.type){case Z.START:this.onTransformStart(t);break;case Z.END:this.onTransformEnd(t);break;default:this.transformTool.onScale(t)}}onRotate(t){if(this.canGesture&&(t.stop(),E(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,t.type){case Z.START:this.onTransformStart(t);break;case Z.END:this.onTransformEnd(t);break;default:this.transformTool.onRotate(t)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){_t(this,t)}onArrow(t){if(this.canUse){let e=0,i=0;switch(t.code){case"ArrowDown":i=1;break;case"ArrowUp":i=-1;break;case"ArrowLeft":e=-1;break;case"ArrowRight":e=1}if(e||i){const{keyEvent:s,arrowStep:o,arrowFastStep:r}=this.mergeConfig;if(s){const s=t.shiftKey?r:o;this.transformTool.move(e*s,i*s)}}}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof M)||t.find(t=>t instanceof M);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[z.START,this.onDragStart,this],[z.DRAG,this.onDrag,this],[z.END,this.onDragEnd,this],[W.ENTER,e=>{this.enterPoint=t,_t(this,e)}],[W.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[W.DOUBLE_TAP,this.onDoubleTap,this],[W.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[Y.HOLD,Y.UP],this.onKey,this],[Y.DOWN,this.onArrow,this],[[F.START,F.BEFORE_MOVE,F.END],this.onMove,this,!0],[[Z.START,Z.BEFORE_ZOOM,Z.END],this.onScale,this,!0],[[G.START,G.BEFORE_ROTATE,G.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}static registerWidget(t){const{tag:e}=t.prototype;Ht.WidgetList[e]&&Vt.repeat(e),Ht.WidgetList[e]=t}createWidgets(){Object.values(Ht.WidgetList).forEach(t=>{this.widgets.push(new t(this))})}loadWidgets(){this.widgets.forEach(t=>t.onLoad())}updateWidgets(){this.widgets.forEach(t=>t.onUpdate())}unloadWidgets(){this.widgets.forEach(t=>t.onUnload())}destroyWidgets(){this.widgets.forEach(t=>t.onDestroy())}destroy(){this.editor=null,this.__removeListenEvents(),this.destroyWidgets(),super.destroy()}}Ht.WidgetList={};const Dt={x:0,y:0,width:1e5,height:1e5};class At extends p{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Dt),Object.assign(this.__world,Dt)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}}const It='\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"/>',Wt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,arrowStep:1,arrowFastStep:10,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${It}\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${It}\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${It}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,editBoxType:"box",hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},zt=new w;function Ft(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{zt.setListWithFn(i,t=>t.getBounds("box","page")),0===zt.width&&(zt.width=.1),0===zt.height&&(zt.height=.1),e.reset(zt.get())}),s.add(e)}const Zt=_.get("EditToolCreator");function Xt(){return t=>{Gt.register(t)}}const Yt=Xt,Gt={EditTool:"EditTool",LineEditTool:"LineEditTool",PointsEditTool:"PointsEditTool",list:{},register(t,e){const{tag:i}=t.prototype;e||(e=i),Ut[e]&&Zt.repeat(e),Ut[e]=t},get:(t,e)=>new Ut[t](e)},{list:Ut}=Gt;class Kt extends N{constructor(t,e){super(t,e)}}Kt.BEFORE_OPEN="innerEditor.before_open",Kt.OPEN="innerEditor.open",Kt.BEFORE_CLOSE="innerEditor.before_close",Kt.CLOSE="innerEditor.close";class jt extends N{constructor(t,e){super(t,e)}}jt.BEFORE_GROUP="editor.before_group",jt.GROUP="editor.group",jt.BEFORE_UNGROUP="editor.before_ungroup",jt.UNGROUP="editor.ungroup",jt.BEFORE_OPEN="editor.before_open_group",jt.OPEN="editor.open_group",jt.BEFORE_CLOSE="editor.before_close_group",jt.CLOSE="editor.close_group";const{updateMatrix:Nt}=R,$t={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},qt="top-left";class Jt extends b{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.skipJSON=!0,this.on(P.CHANGE,e=>{if(this.checkChange&&$t[e.attrName]){const{attrName:i,newValue:o,oldValue:r}=e,n="s"===i[0]?(o||1)/(r||1):(o||0)-(r||0);this.canChange=!1;const a=this.__;a[i]=r,Nt(this.parent),Nt(this);const h=new s(this.__world);switch(a[i]=o,this.__layout.rotationChange(),Nt(this),this.changedTransform=new s(this.__world).divide(h),i){case"x":t.move(n,0);break;case"y":t.move(0,n);break;case"rotation":t.rotateOf(qt,n);break;case"scaleX":t.scaleOf(qt,n,1);break;case"scaleY":t.scaleOf(qt,1,n);break;case"skewX":t.skewOf(qt,n,0);break;case"skewY":t.skewOf(qt,0,n)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Qt extends N{constructor(t,e){super(t,e)}}Qt.BEFORE_MOVE="editor.before_move",Qt.MOVE="editor.move";class te extends N{constructor(t,e){super(t,e)}}te.BEFORE_SCALE="editor.before_scale",te.SCALE="editor.scale";class ee extends N{constructor(t,e){super(t,e)}}ee.BEFORE_ROTATE="editor.before_rotate",ee.ROTATE="editor.rotate";class ie extends N{constructor(t,e){super(t,e)}}ie.BEFORE_SKEW="editor.before_skew",ie.SKEW="editor.skew";class se{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let o,{dragLimitAnimate:r}=i;const n=t.type===F.END||t.type===z.END,a=E(e.draggable),h=!r||n||a,l={x:t.totalX,y:t.totalY};t instanceof F&&x.move(l,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(l.x)>Math.abs(l.y)?l.y=0:l.x=0),o=z.getValidMove(e,s.point,l,h),(o.x||o.y)&&(r&&!a&&n?R.animateMove(this,o,O(r)?r:.3):this.move(o))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:o}=this.editBox;let r,{around:n,lockRatio:a,flipable:h,editSize:l}=i;t instanceof Z?(n||(n=e.getBoxPoint(t)),r=t.totalScale):r=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=Ot.getScaleData(e,o.bounds,d,r,a,Ot.getAround(n,t.altKey),h,!s||"scale"===l),g=e.x,u=e.y;t instanceof z&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),x.move(o.totalOffset,e.x-g,e.y-u)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:o,rotateAround:r,rotateGap:n,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof G)d=t.rotation,l=r?L.getPoint(r,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,n=Ot.getRotateData(e,h,t,s,i?null:r||e.around||e.origin||o||"center");d=s.rotation+n.rotation-e.rotation,l=n.origin}if(d=T.float(T.getGapRotation(d,n,e.rotation),2),!d)return;const c=e.x,g=e.y;this.rotateOf(l,d),x.move(s.totalOffset,e.x-c,e.y-g)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:o,skewX:r,skewY:n}=Ot.getSkewData(e,t.current.direction,t.getInnerMove(e),Ot.getAround(s,t.altKey));(r||n)&&this.skewOf(o,r,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;a(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:o,editor:r}=this.editBox,{beforeMove:n}=s;if(n){const s=n({target:i,x:t,y:e});if(a(s))t=s.x,e=s.y;else if(!1===s)return}const h=i.getWorldPointByLocal({x:t,y:e},null,!0);o||i.safeChange(()=>i.move(t,e));const l={target:i,editor:r,moveX:h.x,moveY:h.y};this.emitEvent(new Qt(Qt.BEFORE_MOVE,l));const d=new Qt(Qt.MOVE,l);this.doMove(d),this.emitEvent(d)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:o}=i;if(o){const{origin:i,scaleX:s,scaleY:r,drag:n}=t;if(!1===o({target:e,drag:n,origin:i,scaleX:s,scaleY:r}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new te(te.BEFORE_SCALE,t));const r=new te(te.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:o,mergeConfig:r,single:n,editor:h}=this.editBox,{beforeScale:l}=r;if(l){const s=l({target:o,origin:t,scaleX:e,scaleY:i});if(a(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const d=this.getWorldOrigin(t),c=!n&&this.getChangedTransform(()=>o.safeChange(()=>o.scaleOf(t,e,i))),g={target:o,editor:h,worldOrigin:d,scaleX:e,scaleY:i,transform:c};this.emitEvent(new te(te.BEFORE_SCALE,g));const u=new te(te.SCALE,g);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:o}=this.editBox,r=this.getWorldOrigin("center"),n=i?new s(R.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),a={target:e,editor:o,worldOrigin:r,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:n};this.emitEvent(new te(te.BEFORE_SCALE,a));const h=new te(te.SCALE,a);this.doScale(h),this.emitEvent(h)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:o,editor:r}=this.editBox,{beforeRotate:n}=s;if(n){const s=n({target:i,origin:t,rotation:e});if(O(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!o&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),l={target:i,editor:r,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new ee(ee.BEFORE_ROTATE,l));const d=new ee(ee.ROTATE,l);this.doRotate(d),this.emitEvent(d)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:o,mergeConfig:r,single:n,editor:h}=this.editBox,{beforeSkew:l}=r;if(l){const s=l({target:o,origin:t,skewX:e,skewY:i});if(a(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const d=this.getWorldOrigin(t),c=!n&&this.getChangedTransform(()=>o.safeChange(()=>o.skewOf(t,e,i))),g={target:o,editor:h,worldOrigin:d,skewX:e,skewY:i,transform:c};this.emitEvent(new ie(ie.BEFORE_SKEW,g));const u=new ie(ie.SKEW,g);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(R.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const o=new s(e.worldTransform);return t(),new s(e.worldTransform).divide(o)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}let oe=class extends i{get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}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 dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new y,this.openedGroupList=new y,this.simulateTarget=new Jt(this),this.editBox=new Ht(this),this.editToolList={},this.selector=new ut(this),this.editMask=new At(this),this.targetEventIds=[];let i=h.clone(Wt);t&&(i=h.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),V.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}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)}setDimOthers(t,i="dim",s){if(!s){const{dimTarget:t,targetLeafer:i}=this;s=t?e(t)?t:[t]:[i]}s[0]&&s[0][i]!==(t||!1)&&s.forEach(e=>h.stintSet(e,i,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}cancelDimOthers(){this.setDimOthers(!1),this.setBright(!1),this.hasDimOthers=void 0}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Ft(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||Gt.get(t,this)}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(E(s))e=s;else if(!1===s)return}if(Gt.list[e]){const i=this.editTool=this.getEditTool(e);this.editBox.load(),i.editTarget=t,i.load(),this.update()}}}unloadEditTool(t){let e=this.editTool;e&&(t||this.editBox.unload(),e.unload(),t||(this.editTool=null),e.editTarget=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(jt.BEFORE_GROUP),this.target=J.group(this.list,this.element,t),this.emitGroupEvent(jt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(jt.BEFORE_UNGROUP,t)),this.target=J.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(jt.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(jt.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(jt.OPEN,t)}closeGroup(t){this.emitGroupEvent(jt.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(jt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!R.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 jt(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||Gt.get(t,this)}openInnerEditor(t,e,i){let s;if(E(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(E(i))s=i;else if(!1===i)return}Gt.list[s]&&(this.unloadEditTool(!0),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(Kt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Kt.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Kt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Kt.CLOSE),t||this.updateEditTool(),this.innerEditor=this.innerEditor.editTarget=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Kt(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&&(J.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(J.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(H.START,this.onRenderStart,this),i&&i.on_(P.SCROLL,this.onChildScroll,this),t.on_(H.CHILD_START,this.onAppRenderStart,this),t.on_(D.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach(t=>t.destroy()),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}};K([(t,e)=>{o(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,editTool:o,innerEditor:a,app:h}=this,l=Object.assign({},t);if(a?a.editConfig&&Object.assign(l,a.editConfig):o&&o.editConfig&&Object.assign(l,o.editConfig),e&&e.mask&&J.mergeMaskConfig(l,this),e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle||t.hoverPathType)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle,delete t.hoverPathType),Object.assign(l,t)}return s.config&&Object.assign(l,s.config),i&&(i.editConfig&&Object.assign(l,i.editConfig),"font-size"===l.editSize&&(l.lockRatio=!0),"resize-rotate"===i.pointType&&(l.around||(l.around="center"),r(l.lockRatio)&&(l.lockRatio=!0))),n(l.dragLimitAnimate)&&(l.dragLimitAnimate=h&&h.config.pointer.dragLimitAnimate),this.mergedConfig=l}})}],oe.prototype,"mergeConfig",void 0),K([Q(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof y?i:new y(i),t.multiple&&Ft(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new N(N.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new N(N.AFTER_SELECT,s))})],oe.prototype,"target",void 0),K([Q(function(t,e){t.emitEvent(new N(N.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],oe.prototype,"hoverTarget",void 0),oe=K([U(se,["editBox","editTool","emitEvent"])],oe);const{abs:re}=Math,{scale:ne}=x;class ae{static registerInnerEditor(){Gt.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get userConfig(){return this.editBox.mergeConfig[this.tag]||{}}get editBox(){return this._editBox||this.editor.editBox}set editBox(t){this._editBox=t}constructor(t){this.eventIds=[],this.editor=t,this.create()}getEditBoxPoint(t,e){const i=e?t:{x:t.x,y:t.y},{scaleX:s,scaleY:o}=this.editTarget.worldTransform;return ne(i,re(s),re(o)),i}getEditTargetPoint(t,e){const i=e?t:{x:t.x,y:t.y},{scaleX:s,scaleY:o}=this.editTarget.worldTransform;return ne(i,Math.abs(1/s),re(1/o)),i}onCreate(){}create(){this.view=new i,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.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 he=class extends ae{static registerEditTool(t,e){Gt.register(this,t),e&&o(this.prototype,"tag",{get:()=>t})}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:r}=s;o.lockLayout(),r.forEach(t=>{t.moveWorld(e,i)}),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:r}=t,{app:n,list:a}=r;n.lockLayout(),a.forEach(t=>{const n="scale"!==r.getEditSize(t);s?t.transformWorld(s,n,!1):t.scaleOfWorld(o,e,i,n,!1)}),n.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:r,list:n}=o;r.lockLayout(),n.forEach(t=>{const r="scale"!==o.getEditSize(t);i?t.transformWorld(i,r,!1):t.rotateOfWorld(s,e)}),r.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:r}=t,{app:n,list:a}=r;n.lockLayout(),a.forEach(t=>{const n="scale"!==r.getEditSize(t);s?t.transformWorld(s,n,!1):t.skewOfWorld(o,e,i,n)}),n.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};he=K([Xt()],he);const{left:le,right:de}=k,{move:ce,copy:ge,toNumberPoints:ue}=x;let fe=class extends he{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,r=t.target,n=i===le;if(r.pathInputed){const{path:t}=r.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,n,o,this.getInnerMove(r,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,r.path=t}else if(r.points){const{points:t}=r,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,n,o,this.getInnerMove(r,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,r.points=t}else{const t=C(),{toPoint:i}=r;r.rotation=0,this.dragPoint(t,i,n,o,this.getInnerMove(r,e,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(i,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(i,null,null,!0),r.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){const e=ue(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,o){const{x:r,y:n}=o;i?(ce(t,r,n),s&&ce(e,-r,-n)):(s&&ce(t,-r,-n),ce(e,r,n))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,r=t.target;let n,a;if(r.pathInputed?n=this.getFromToByPath(r.__.path):r.points&&(n=this.getFromToByPoints(r.__.points)),n){const{from:i,to:a}=n;r.innerToWorld(i,i,!1,t),r.innerToWorld(a,a,!1,t);const{x:h,y:l}=t.rectBounds;o.pen.clearPath().moveTo(i.x-h,i.y-l).lineTo(a.x-h,a.y-l),ge(s[7],i),ge(e[7],i),ge(s[3],a),ge(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===le||t===de,s[t].visible=a,e[t].visible=!n&&a}};fe=K([Xt()],fe),V.add("editor","resize"),A.editor=function(t,e){const i=new oe(t);return e&&e.sky.add(e.editor=i),i},S.addAttr("textBox",!1,I),p.addAttr("editConfig",void 0,I),p.addAttr("editOuter",t=>{t.updateLayout();const{EditTool:e,LineEditTool:i,PointsEditTool:s}=Gt,o=t.pathInputed||t.isPointsMode?s:t.tag+"EditTool",r=Gt.list[o];return!t.__.__isLinePath||o==s&&r?r?o:e:i},I),p.addAttr("editInner","PathEditor",I),i.addAttr("editInner","",I),M.addAttr("editInner","TextEditor",I),p.setEditConfig=function(t){this.changeAttr("editConfig",t)},p.setEditOuter=function(t){this.changeAttr("editOuter",t)},p.setEditInner=function(t){this.changeAttr("editInner",t)};export{Ht as EditBox,Ot as EditDataHelper,Mt as EditPoint,ut as EditSelect,lt as EditSelectHelper,he as EditTool,Gt as EditToolCreator,oe as Editor,N as EditorEvent,jt as EditorGroupEvent,J as EditorHelper,Qt as EditorMoveEvent,ee as EditorRotateEvent,te as EditorScaleEvent,ie as EditorSkewEvent,ae as InnerEditor,Kt as InnerEditorEvent,fe as LineEditTool,ht as SelectArea,at as Stroker,se as TransformTool,tt as editToolMergeConfigAttr,Xt as registerEditTool,Yt as registerInnerEditor};
1
+ import{Event as t,isArray as e,Group as i,Matrix as s,defineKey as o,isNull as r,isUndefined as n,isObject as a,DataHelper as h,MatrixHelper as l,BoundsHelper as d,LeafBoundsHelper as c,getMatrixData as g,getBoundsData as u,surfaceType as f,UI as p,ColorConvert as m,isString as E,Paint as v,Rect as b,Bounds as w,LeafList as y,Direction9 as k,AroundHelper as L,MathHelper as x,PointHelper as T,isNumber as O,Box as S,Debug as _,ResizeEvent as C,getPointData as B,Text as M,LeafHelper as P,PropertyEvent as R,Plugin as V,RenderEvent as H,LeaferEvent as D,Creator as A,dataType as I}from"@leafer-ui/draw";import{PointerEvent as W,DragEvent as F,MoveEvent as z,ZoomEvent as Z,DragBoundsHelper as X,KeyEvent as Y,RotateEvent as G,useModule as U}from"@leafer-ui/core";import"@leafer-in/resize";function K(t,e,i,s){var o,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(r<3?o(n):r>3?o(e,i,n):o(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}function j(t){return t?e(t)?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class N extends t{get list(){return j(this.value)}get oldList(){return j(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}N.BEFORE_SELECT="editor.before_select",N.SELECT="editor.select",N.AFTER_SELECT="editor.after_select",N.BEFORE_HOVER="editor.before_hover",N.HOVER="editor.hover";const $=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),q=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),J={group(t,e,o){t.sort(q);const{app:r,parent:n}=t[0];let a;a=o&&o.add?o:new i(o),n.addAt(a,n.children.indexOf(t[0])),t.sort($);const h=new s(e.worldTransform);return h.divideParent(n.scrollWorldTransform),a.setTransform(h),a.editable=!0,a.hitChildren=!1,r.lockLayout(),t.forEach(t=>t.dropTo(a)),r.unlockLayout(),a},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.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort($),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(q),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})},mergeMaskConfig(t,e){},getSiblingMaskElements(t){}};function Q(t){return(i,s)=>{const r="_"+s;o(i,s,{get(){return this[r]},set(i){const o=this[r];if(o!==i){const n=this;if(n.config){const t="target"===s;if(t){const{beforeSelect:t}=n.config;if(t){const e=t({target:i});if(a(e))i=e;else if(!1===e)return}n.hasDimOthers&&n.cancelDimOthers(),e(i)&&i.length>1&&i.some(t=>t.locked||"single"===t.editable)&&(i=i.filter(t=>!(t.locked||"single"===t.editable))),n.single&&(delete n.element.syncEventer,delete n.element.__world.ignorePixelSnap)}const r=t?N.BEFORE_SELECT:N.BEFORE_HOVER;this.hasEvent(r)&&this.emitEvent(new N(r,{editor:n,value:i,oldValue:o}))}this[r]=i,t(this,o)}}})}}function tt(){return(t,e)=>{o(t,e,{get(){const t=this,{config:e,userConfig:i,configKeepKeys:s}=t,o=e?h.clone(e):{};if(s)for(let t in i)s.includes(t)||(o[t]=i[t]);return t.preMergedConfig&&t.preMergedConfig(o),s&&s.forEach(t=>{i[t]&&Object.assign(o[t],i[t])}),t.mergedConfig=o}})}}const{abs:et}=Math,{copy:it}=l,{setListWithFn:st}=d,{worldBounds:ot}=c,rt=g(),nt=u();class at extends p{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(st(nt,e,ot),t&&this.set(t),this.set(nt),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const o=this.__,{stroke:r,strokeWidth:n,fill:a}=o,{bounds:h}=e;for(let l=0;l<i.length;l++){s=i[l];const{worldTransform:d,worldRenderBounds:c}=s;if(c.width&&c.height&&(!h||h.hit(c,e.matrix))){const i=et(d.scaleX),h=et(d.scaleY);switch(it(rt,d),rt.half=n%2,t.setWorld(rt,e.matrix),t.beginPath(),this.strokePathType){case"box":const{boxBounds:e}=s.__layout;t.rect(e.x,e.y,e.width,e.height);break;case"stroke":const{strokeBounds:i}=s.__layout;t.rect(i.x,i.y,i.width,i.height);break;case"path":s.__drawPath(t);break;default:s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t)}if(o.strokeWidth=n/Math.max(i,h),o.shadow){const e=o.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,m.string(e.color))}r&&(E(r)?v.stroke(r,this,t,e):v.strokes(r,this,t,e)),a&&(E(a)?v.fill(a,this,t,e):v.fills(a,this,t,e)),o.shadow&&t.restore()}}o.strokeWidth=n}}destroy(){this.target=null,super.destroy()}}K([Q(function(t){const i=t.target;t.list=i?e(i)?i:[i]:[]})],at.prototype,"target",void 0),K([f("render-path")],at.prototype,"strokePathType",void 0);class ht extends i{constructor(t){super(t),this.strokeArea=new b({strokeAlign:"center"}),this.fillArea=new b,this.visible=0,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 lt={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e,i="hit"){const s=[];return dt([t],s,e,i),s}};function dt(t,e,i,s){let o,r,n;for(let a=0,h=t.length;a<h;a++)if(o=t[a],r=o.__,r.hittable&&r.visible&&!r.locked&&i.hit(o.__world)){if(r.editable&&"single"!==r.editable)if(o.isFrame){if(i.includes(o.__layout.boxBounds,o.__world)){e.push(o);continue}}else if(n=i[s](o.__layout.boxBounds,o.__world)&&r.hitSelf,o.isBranch){if(!r.hitChildren||n&&o.children.every(t=>!t.editable)){n&&e.push(o);continue}}else n&&e.push(o);o.isBranch&&dt(o.children,e,i,s)}}const{findOne:ct,findByBounds:gt}=lt;class ut extends i{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new at,this.targetStroker=new at,this.bounds=new w,this.selectArea=new ht,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{hoverTarget:e,mergeConfig:i}=t,s=Object.assign({},i);e&&e.editConfig&&Object.assign(s,e.editConfig);const{stroke:o,strokeWidth:r,hover:n,hoverStyle:a,hoverPathType:h}=s;this.hoverStroker.setTarget(n?e:null,Object.assign({stroke:o,strokeWidth:r,strokePathType:h},a||{}))}}onSelect(){if(this.running){const{editor:t}=this;let{list:e}=t;const i=J.getSiblingMaskElements(t);i&&(e=i.concat(e)),this.targetStroker.setTarget(e),this.hoverStroker.target=null}}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedPathType:i,selectedStyle:s}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2),strokePathType:i},s||{}))}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,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(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,t.path.needUpdate=!0):this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(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:r}=t.getInnerPoint(this);this.bounds.set(o,r),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:r},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 y(gt(e.app,s,"includes"===e.mergedConfig.boxSelect?"includes":"hit"));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=0)}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){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||this.isHoldMultipleSelectKey(t)&&!ct(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new y(this.editor.editBox.rect)};return ct(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):ct(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[N.HOVER,this.onHover,this],[N.SELECT,this.onSelect,this]]),e.on_([[W.MOVE,this.onPointerMove,this],[W.BEFORE_DOWN,this.onBeforeDown,this],[W.TAP,this.onTap,this],[F.START,this.onDragStart,this,!0],[F.DRAG,this.onDrag,this],[F.END,this.onDragEnd,this],[z.MOVE,this.onAutoMove,this],[[Z.ZOOM,z.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:ft,top:pt,topRight:mt,right:Et,bottomRight:vt,bottom:bt,bottomLeft:wt,left:yt}=k,{toPoint:kt}=L,{within:Lt,sign:xt}=x,{abs:Tt}=Math,Ot={getScaleData(t,e,i,s,o,r,n,a){let h,l,d={},c=1,g=1;const{widthRange:u,heightRange:f,dragBounds:p,worldTransform:m,boxBounds:E}=t,{width:v,height:b}=e,w=Tt(m.scaleX),y=Tt(m.scaleY),k=t.scaleX/e.scaleX,L=t.scaleY/e.scaleY,x=xt(k),T=xt(L),S=a?k:x*E.width/v,_=a?L:T*E.height/b;if(O(s))c=g=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=a?k:x,s.y*=a?L:T;const t=(-s.y+b)/b,e=(s.x+v)/v,n=(s.y+b)/b,d=(-s.x+v)/v;switch(i){case pt:g=t,h="bottom";break;case Et:c=e,h="left";break;case bt:g=n,h="top";break;case yt:c=d,h="right";break;case ft:g=t,c=d,h="bottom-right";break;case mt:g=t,c=e,h="bottom-left";break;case vt:g=n,c=e,h="top-left";break;case wt:g=n,c=d,h="top-right"}if(o)if("corner"===o&&i%2)o=!1;else switch(i){case pt:case bt:c=g;break;case yt:case Et:g=c;break;default:l=Math.sqrt(Tt(c*g)),c=xt(c)*l,g=xt(g)*l}}const C=1!==c,B=1!==g;if(C&&(c/=S),B&&(g/=_),n||(c<0&&(c=1/E.width/w),g<0&&(g=1/E.height/y)),kt(r||h,E,d,!0),p){const e={x:c,y:g};X.limitScaleOf(t,d,e,o),c=e.x,g=e.y}if(C&&u){const e=E.width*t.scaleX;c=Lt(e*c,u)/e}if(B&&f){const e=E.height*t.scaleY;g=Lt(e*g,f)/e}const M=w*E.width,P=y*E.height;return C&&Tt(c*M)<1&&(c=1*xt(c)/M),B&&Tt(g*P)<1&&(g=1*xt(g)/P),o&&c!==g&&(l=Math.min(Tt(c),Tt(g)),c=xt(c)*l,g=xt(g)*l),isFinite(c)||(c=1),isFinite(g)||(g=1),{origin:d,scaleX:c,scaleY:g,direction:i,lockRatio:o,around:r}},getRotateData(t,e,i,s,o){let r,n={};switch(e){case ft:r="bottom-right";break;case mt:r="bottom-left";break;case vt:r="top-left";break;case wt:r="top-right";break;default:r="center"}return kt(o||r,t.boxBounds,n,!0),{origin:n,rotation:T.getRotation(s,t.getWorldPointByBox(n),i)}},getSkewData(t,e,i,s){let o,r,n={},a=0,h=0;switch(e){case pt:case ft:r={x:.5,y:0},o="bottom",a=1;break;case bt:case vt:r={x:.5,y:1},o="top",a=1;break;case yt:case wt:r={x:0,y:.5},o="right",h=1;break;case Et:case mt:r={x:1,y:.5},o="left",h=1}const{boxBounds:l}=t,{width:d,height:c}=l;r.x=r.x*d,r.y=r.y*c,kt(s||o,l,n,!0);const g=T.getRotation(r,n,{x:r.x+(a?i.x:0),y:r.y+(h?i.y:0)});return a?a=-g:h=g,{origin:n,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 yt:t=Et;break;case ft:t=mt;break;case wt:t=vt;break;case Et:t=yt;break;case mt:t=ft;break;case vt:t=wt}if(i)switch(t){case pt:t=bt;break;case ft:t=wt;break;case mt:t=vt;break;case bt:t=pt;break;case wt:t=ft;break;case vt:t=mt}return t}},St={};function _t(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Ct(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Bt extends S{constructor(t){super(t),this.useFastShadow=!0}}const Mt=["top","right","bottom","left"],Pt=void 0,Rt=_.get("EditBox");class Vt extends i{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}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}get canUse(){return this.app&&this.editor.editing}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return E(t)||E(e)||E(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(t){super(),this.view=new i,this.rect=new Bt({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Bt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new i({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.widgets=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents(),this.createWidgets()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:r,resizeLines:n,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 Bt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Bt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),n.push(e),this.listenPointEvents(e,"resize",s)),i=new Bt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.add([...r,a,h,l,...n,...o]),this.add(s)}showView(){this.view.opacity=1,this.update()}hideView(){this.view.opacity=0}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:o,resizePoints:n,resizeLines:a}=this,{stroke:l,strokeWidth:d,ignorePixelSnap:c}=e,g=this.getPointsStyle(),u=this.getMiddlePointsStyle(),f=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let t=0;t<8;t++)p=n[t],p.children.length&&p.clear(),p.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:g[t/2%g.length])),p.rotation=(t-(t%2?1:0))/2*90,t%2&&a[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},f[(t-1)/2%f.length]||{}));o.set(this.getPointStyle(e.circle||e.rotatePoint||g[0])),s.set(Object.assign({stroke:l,strokeWidth:d,opacity:1,editConfig:Pt},e.rect||{}));const m=r(e.rectThrough)?i:e.rectThrough;s.hittable=!m,m&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&h.stintSet(t.__world,"ignorePixelSnap",c),this.updateMoveCursor(),this.loadWidgets()}update(){const{editor:t,target:e}=this;if(!e)return;const{x:i,y:s,scaleX:o,scaleY:r,rotation:n,skewX:a,skewY:h,width:l,height:d}=e.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:i,y:s,scaleX:o,scaleY:r,rotation:n,skewX:a,skewY:h}),this.updateBounds({x:0,y:0,width:l,height:d}),this.updateWidgets()}unload(){this.unloadWidgets(),this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,target:i,mergeConfig:s,single:o,rect:r,circle:a,buttons:h,resizePoints:l,rotatePoints:c,resizeLines:g}=this,{editMask:u}=e,{middlePoint:f,resizeable:p,rotateable:m,hideOnSmall:E,editBox:v,editBoxType:b,mask:w,dimOthers:y,bright:k,spread:x,hideRotatePoints:T,hideResizeLines:S}=s;if("stroke"===b){const{scaleX:e,scaleY:s}=i.worldTransform,{strokeBoxSpread:o}=i.__layout;o&&d.spread(t,[o*Math.abs(s),o*Math.abs(e)])}if(x&&d.spread(t,x),this.rectBounds=t,u.visible=!!w||0,n(y)&&n(k)?e.hasDimOthers&&e.cancelDimOthers():(e.setDimOthers(y),e.setBright(!!y||k),e.hasDimOthers=!0),this.view.worldOpacity){const{width:e,height:i}=t,n=O(E)?E:10,d=this.showPoints=v&&!(E&&e<n&&i<n);let u,b,w,y={};for(let s=0;s<8;s++)L.toPoint(L.directionData[s],t,y),b=l[s],u=c[s],b.set(y),u.set(y),b.visible=d&&!(!p&&!m),u.visible=d&&m&&p&&!T,s%2&&(w=g[(s-1)/2],w.set(y),w.visible=b.visible&&!S,b.visible&&(b.visible=!!f),u.visible&&(u.visible=!!f),(s+1)/2%2?(w.width=e+w.height,E&&2*b.width>e&&(b.visible=!1)):(w.width=i+w.height,E&&2*b.width>i&&(b.visible=!1)));a.visible=d&&m&&!(!s.circle&&!s.rotatePoint),a.visible&&this.layoutCircle(),r.path&&(r.path=null),r.set(Object.assign(Object.assign({},t),{visible:!o||v})),h.visible=d&&h.children.length>0||0,h.visible&&this.layoutButtons()}else r.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:o}=this.mergedConfig,r=Mt.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,e||i,!!o)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:o}=this.mergedConfig,{flippedX:r,flippedY:n}=this;let a=Mt.indexOf(e);(a%2&&r||(a+1)%2&&n)&&i&&(a=(a+2)%4);const h=i?Ot.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!o),i&&(t.rotation=90*(h-a)),t.scaleX=r?-1:1,t.scaleY=n?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],r=e%2,n=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*n;r?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:r}=this.mergedConfig,n={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:o,height:o,cornerRadius:r,offsetX:0,offsetY:0,editConfig:Pt};return t?Object.assign(n,t):n}getPointsStyle(){const{point:t}=this.mergedConfig;return e(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return e(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return e(t)?t:[t]}updateMoveCursor(){_t(this)}updatePointCursor(t){!function(t,e){const{enterPoint:i,dragging:s,skewing:o,resizing:r,flippedX:n,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return _t(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:g,skewCursor:u,moveable:f,resizeable:p,rotateable:m,skewable:E}=t.mergeConfig;if("move"===l)return i.cursor=d,void(f||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let v=l.includes("resize");v&&m&&(t.isHoldRotateKey(e)||!p)&&(v=!1);const b=E&&!v&&("resize-line"===i.name||"skew"===l),w=s?o?u:r?c:g:b?u:v?c:g;h+=45*(Ot.getFlipDirection(i.direction,n,a)+1),h=2*Math.round(x.formatRotation(h,!0)/2);const{url:y,x:k,y:L}=w,T=y+h;St[T]?i.cursor=St[T]:St[T]=i.cursor={url:Ct(y,h),x:k,y:L}}(this,t)}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:o,rotateable:r,skewable:n,onCopy:a}=this.mergeConfig;"move"===i?(t.altKey&&a&&a()&&this.editor.single&&this.app.interaction.replaceDownTarget(this.target),s&&(this.moving=!0)):(i.includes("rotate")||this.isHoldRotateKey(t)||!o?(r&&(this.rotating=!0),"resize-rotate"===i?o&&(this.resizing=!0):"resize-line"===e.name&&(n&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&o&&(this.resizing=!0),"skew"===i&&n&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:o,skewing:r}=this;if(i)e.onMove(t);else if(s||o||r){const i=t.current;i.pointType&&(this.enterPoint=i),o&&e.onRotate(t),s&&e.onScale(t),r&&e.onSkew(t)}this.updatePointCursor(t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){const{hideOnMove:e}=this.mergedConfig;(this.moving||this.gesturing)&&(this.editor.opacity=e?0:1),this.resizing&&(C.resizingKeys=this.editor.leafList.keys);const{dragStartData:i,target:s}=this;i.x=t.x,i.y=t.y,i.totalOffset=B(),i.point={x:s.x,y:s.y},i.bounds=Object.assign({},s.getLayoutBounds("box","local")),i.rotation=s.rotation}onTransformEnd(t){this.canDragLimitAnimate&&(t instanceof F||t instanceof z)&&this.transformTool.onMove(t),this.resizing&&(C.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(t){if(this.canGesture&&"drag"!==t.moveType&&(t.stop(),E(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,t.type){case z.START:this.onTransformStart(t);break;case z.END:this.onTransformEnd(t);break;default:this.transformTool.onMove(t)}}onScale(t){if(this.canGesture&&(t.stop(),E(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,t.type){case Z.START:this.onTransformStart(t);break;case Z.END:this.onTransformEnd(t);break;default:this.transformTool.onScale(t)}}onRotate(t){if(this.canGesture&&(t.stop(),E(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,t.type){case Z.START:this.onTransformStart(t);break;case Z.END:this.onTransformEnd(t);break;default:this.transformTool.onRotate(t)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){this.updatePointCursor(t)}onArrow(t){if(this.canUse){let e=0,i=0;switch(t.code){case"ArrowDown":i=1;break;case"ArrowUp":i=-1;break;case"ArrowLeft":e=-1;break;case"ArrowRight":e=1}if(e||i){const{keyEvent:s,arrowStep:o,arrowFastStep:r}=this.mergeConfig;if(s){const s=t.shiftKey?r:o;this.transformTool.move(e*s,i*s)}}}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof M)||t.find(t=>t instanceof M);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[F.START,this.onDragStart,this],[F.DRAG,this.onDrag,this],[F.END,this.onDragEnd,this],[W.ENTER,e=>{this.enterPoint=t,this.updatePointCursor(e)}],[W.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[W.DOUBLE_TAP,this.onDoubleTap,this],[W.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[Y.HOLD,Y.UP],this.onKey,this],[Y.DOWN,this.onArrow,this],[[z.START,z.BEFORE_MOVE,z.END],this.onMove,this,!0],[[Z.START,Z.BEFORE_ZOOM,Z.END],this.onScale,this,!0],[[G.START,G.BEFORE_ROTATE,G.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}static registerWidget(t){const{tag:e}=t.prototype;Vt.WidgetList[e]&&Rt.repeat(e),Vt.WidgetList[e]=t}createWidgets(){Object.values(Vt.WidgetList).forEach(t=>{this.widgets.push(new t(this))})}loadWidgets(){this.widgets.forEach(t=>t.onLoad())}updateWidgets(){this.widgets.forEach(t=>t.onUpdate())}unloadWidgets(){this.widgets.forEach(t=>t.onUnload())}destroyWidgets(){this.widgets.forEach(t=>t.onDestroy())}destroy(){this.editor=null,this.__removeListenEvents(),this.destroyWidgets(),super.destroy()}}Vt.WidgetList={};const Ht={x:0,y:0,width:1e5,height:1e5};class Dt extends p{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Ht),Object.assign(this.__world,Ht)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}}const At='\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"/>',It={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,arrowStep:1,arrowFastStep:10,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${At}\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${At}\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${At}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,editBoxType:"box",hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},Wt=new w;function Ft(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Wt.setListWithFn(i,t=>t.getBounds("box","page")),0===Wt.width&&(Wt.width=.1),0===Wt.height&&(Wt.height=.1),e.reset(Wt.get())}),s.add(e)}const zt=_.get("EditToolCreator");function Zt(){return t=>{Yt.register(t)}}const Xt=Zt,Yt={EditTool:"EditTool",LineEditTool:"LineEditTool",PointsEditTool:"PointsEditTool",list:{},register(t,e){const{tag:i}=t.prototype;e||(e=i),Gt[e]&&zt.repeat(e),Gt[e]=t},get:(t,e)=>new Gt[t](e)},{list:Gt}=Yt;class Ut extends N{constructor(t,e){super(t,e)}}Ut.BEFORE_OPEN="innerEditor.before_open",Ut.OPEN="innerEditor.open",Ut.BEFORE_CLOSE="innerEditor.before_close",Ut.CLOSE="innerEditor.close";class Kt extends N{constructor(t,e){super(t,e)}}Kt.BEFORE_GROUP="editor.before_group",Kt.GROUP="editor.group",Kt.BEFORE_UNGROUP="editor.before_ungroup",Kt.UNGROUP="editor.ungroup",Kt.BEFORE_OPEN="editor.before_open_group",Kt.OPEN="editor.open_group",Kt.BEFORE_CLOSE="editor.before_close_group",Kt.CLOSE="editor.close_group";const{updateMatrix:jt}=P,Nt={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},$t="top-left";class qt extends b{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.skipJSON=!0,this.on(R.CHANGE,e=>{if(this.checkChange&&Nt[e.attrName]){const{attrName:i,newValue:o,oldValue:r}=e,n="s"===i[0]?(o||1)/(r||1):(o||0)-(r||0);this.canChange=!1;const a=this.__;a[i]=r,jt(this.parent),jt(this);const h=new s(this.__world);switch(a[i]=o,this.__layout.rotationChange(),jt(this),this.changedTransform=new s(this.__world).divide(h),i){case"x":t.move(n,0);break;case"y":t.move(0,n);break;case"rotation":t.rotateOf($t,n);break;case"scaleX":t.scaleOf($t,n,1);break;case"scaleY":t.scaleOf($t,1,n);break;case"skewX":t.skewOf($t,n,0);break;case"skewY":t.skewOf($t,0,n)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Jt extends N{constructor(t,e){super(t,e)}}Jt.BEFORE_MOVE="editor.before_move",Jt.MOVE="editor.move";class Qt extends N{constructor(t,e){super(t,e)}}Qt.BEFORE_SCALE="editor.before_scale",Qt.SCALE="editor.scale";class te extends N{constructor(t,e){super(t,e)}}te.BEFORE_ROTATE="editor.before_rotate",te.ROTATE="editor.rotate";class ee extends N{constructor(t,e){super(t,e)}}ee.BEFORE_SKEW="editor.before_skew",ee.SKEW="editor.skew";class ie{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let o,{dragLimitAnimate:r}=i;const n=t.type===z.END||t.type===F.END,a=E(e.draggable),h=!r||n||a,l={x:t.totalX,y:t.totalY};t instanceof z&&T.move(l,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(l.x)>Math.abs(l.y)?l.y=0:l.x=0),o=F.getValidMove(e,s.point,l,h),(o.x||o.y)&&(r&&!a&&n?P.animateMove(this,o,O(r)?r:.3):this.move(o))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:o}=this.editBox;let r,{around:n,lockRatio:a,flipable:h,editSize:l}=i;t instanceof Z?(n||(n=e.getBoxPoint(t)),r=t.totalScale):r=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=Ot.getScaleData(e,o.bounds,d,r,a,Ot.getAround(n,t.altKey),h,!s||"scale"===l),g=e.x,u=e.y;t instanceof F&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),T.move(o.totalOffset,e.x-g,e.y-u)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:o,rotateAround:r,rotateGap:n,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof G)d=t.rotation,l=r?L.getPoint(r,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,n=Ot.getRotateData(e,h,t,s,i?null:r||e.around||e.origin||o||"center");d=s.rotation+n.rotation-e.rotation,l=n.origin}if(d=x.float(x.getGapRotation(d,n,e.rotation),2),!d)return;const c=e.x,g=e.y;this.rotateOf(l,d),T.move(s.totalOffset,e.x-c,e.y-g)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:o,skewX:r,skewY:n}=Ot.getSkewData(e,t.current.direction,t.getInnerMove(e),Ot.getAround(s,t.altKey));(r||n)&&this.skewOf(o,r,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;a(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:o,editor:r}=this.editBox,{beforeMove:n}=s;if(n){const s=n({target:i,x:t,y:e});if(a(s))t=s.x,e=s.y;else if(!1===s)return}const h=i.getWorldPointByLocal({x:t,y:e},null,!0);o||i.safeChange(()=>i.move(t,e));const l={target:i,editor:r,moveX:h.x,moveY:h.y};this.emitEvent(new Jt(Jt.BEFORE_MOVE,l));const d=new Jt(Jt.MOVE,l);this.doMove(d),this.emitEvent(d)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:o}=i;if(o){const{origin:i,scaleX:s,scaleY:r,drag:n}=t;if(!1===o({target:e,drag:n,origin:i,scaleX:s,scaleY:r}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new Qt(Qt.BEFORE_SCALE,t));const r=new Qt(Qt.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:o,mergeConfig:r,single:n,editor:h}=this.editBox,{beforeScale:l}=r;if(l){const s=l({target:o,origin:t,scaleX:e,scaleY:i});if(a(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const d=this.getWorldOrigin(t),c=!n&&this.getChangedTransform(()=>o.safeChange(()=>o.scaleOf(t,e,i))),g={target:o,editor:h,worldOrigin:d,scaleX:e,scaleY:i,transform:c};this.emitEvent(new Qt(Qt.BEFORE_SCALE,g));const u=new Qt(Qt.SCALE,g);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:o}=this.editBox,r=this.getWorldOrigin("center"),n=i?new s(P.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),a={target:e,editor:o,worldOrigin:r,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:n};this.emitEvent(new Qt(Qt.BEFORE_SCALE,a));const h=new Qt(Qt.SCALE,a);this.doScale(h),this.emitEvent(h)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:o,editor:r}=this.editBox,{beforeRotate:n}=s;if(n){const s=n({target:i,origin:t,rotation:e});if(O(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!o&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),l={target:i,editor:r,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new te(te.BEFORE_ROTATE,l));const d=new te(te.ROTATE,l);this.doRotate(d),this.emitEvent(d)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:o,mergeConfig:r,single:n,editor:h}=this.editBox,{beforeSkew:l}=r;if(l){const s=l({target:o,origin:t,skewX:e,skewY:i});if(a(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const d=this.getWorldOrigin(t),c=!n&&this.getChangedTransform(()=>o.safeChange(()=>o.skewOf(t,e,i))),g={target:o,editor:h,worldOrigin:d,skewX:e,skewY:i,transform:c};this.emitEvent(new ee(ee.BEFORE_SKEW,g));const u=new ee(ee.SKEW,g);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(P.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const o=new s(e.worldTransform);return t(),new s(e.worldTransform).divide(o)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}let se=class extends i{get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}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 dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new y,this.openedGroupList=new y,this.simulateTarget=new qt(this),this.editBox=new Vt(this),this.editToolList={},this.selector=new ut(this),this.editMask=new Dt(this),this.targetEventIds=[];let i=h.clone(It);t&&(i=h.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),V.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}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)}setDimOthers(t,i="dim",s){if(!s){const{dimTarget:t,targetLeafer:i}=this;s=t?e(t)?t:[t]:[i]}s[0]&&s[0][i]!==(t||!1)&&s.forEach(e=>h.stintSet(e,i,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}cancelDimOthers(){this.setDimOthers(!1),this.setBright(!1),this.hasDimOthers=void 0}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Ft(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||Yt.get(t,this)}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(E(s))e=s;else if(!1===s)return}if(Yt.list[e]){const i=this.editTool=this.getEditTool(e);this.editBox.load(),i.editTarget=t,i.load(),this.update()}}}unloadEditTool(t){let e=this.editTool;e&&(t||this.editBox.unload(),e.unload(),t||(this.editTool=null),e.editTarget=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(Kt.BEFORE_GROUP),this.target=J.group(this.list,this.element,t),this.emitGroupEvent(Kt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(Kt.BEFORE_UNGROUP,t)),this.target=J.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(Kt.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(Kt.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Kt.OPEN,t)}closeGroup(t){this.emitGroupEvent(Kt.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Kt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!P.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 Kt(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||Yt.get(t,this)}openInnerEditor(t,e,i){let s;if(E(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(E(i))s=i;else if(!1===i)return}Yt.list[s]&&(this.unloadEditTool(!0),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(Ut.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Ut.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Ut.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Ut.CLOSE),t||this.updateEditTool(),this.innerEditor=this.innerEditor.editTarget=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Ut(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&&(J.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(J.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(H.START,this.onRenderStart,this),i&&i.on_(R.SCROLL,this.onChildScroll,this),t.on_(H.CHILD_START,this.onAppRenderStart,this),t.on_(D.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach(t=>t.destroy()),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}};K([(t,e)=>{o(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,editTool:o,innerEditor:a,app:h}=this,l=Object.assign({},t);if(a?a.editConfig&&Object.assign(l,a.editConfig):o&&o.editConfig&&Object.assign(l,o.editConfig),e&&e.mask&&J.mergeMaskConfig(l,this),e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle||t.hoverPathType)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle,delete t.hoverPathType),Object.assign(l,t)}return s.config&&Object.assign(l,s.config),i&&(i.editConfig&&Object.assign(l,i.editConfig),"font-size"===l.editSize&&(l.lockRatio=!0),"resize-rotate"===i.pointType&&(l.around||(l.around="center"),r(l.lockRatio)&&(l.lockRatio=!0))),n(l.dragLimitAnimate)&&(l.dragLimitAnimate=h&&h.config.pointer.dragLimitAnimate),this.mergedConfig=l}})}],se.prototype,"mergeConfig",void 0),K([Q(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof y?i:new y(i),t.multiple&&Ft(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new N(N.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new N(N.AFTER_SELECT,s))})],se.prototype,"target",void 0),K([Q(function(t,e){t.emitEvent(new N(N.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],se.prototype,"hoverTarget",void 0),se=K([U(ie,["editBox","editTool","emitEvent"])],se);const{abs:oe}=Math,{scale:re}=T;class ne{static registerInnerEditor(){Yt.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get userConfig(){return this.editBox.mergeConfig[this.tag]||{}}get editBox(){return this._editBox||this.editor.editBox}set editBox(t){this._editBox=t}constructor(t){this.configKeepKeys=["editBox"],this.eventIds=[],this.editor=t,this.create()}getEditBoxPoint(t,e){const i=e?t:{x:t.x,y:t.y},{scaleX:s,scaleY:o}=this.editTarget.worldTransform;return re(i,oe(s),oe(o)),i}getEditTargetPoint(t,e){const i=e?t:{x:t.x,y:t.y},{scaleX:s,scaleY:o}=this.editTarget.worldTransform;return re(i,Math.abs(1/s),oe(1/o)),i}onCreate(){}create(){this.view=new i,this.onCreate()}showView(){this.view.opacity=1}hideView(){this.view.opacity=0}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.editor&&(this.updateEditBoxConfig(),this.onUpdate())}onUnload(){}unload(){const{editor:t}=this;t&&(this.unloadEditBoxConfig(),t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}updateEditBoxConfig(){const{mergeConfig:t}=this;t&&(this.editBox.config=t.editBox)}unloadEditBoxConfig(){this.editBox.config=void 0}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)}}K([tt()],ne.prototype,"mergeConfig",void 0);let ae=class extends ne{static registerEditTool(t,e){Yt.register(this,t),e&&o(this.prototype,"tag",{get:()=>t})}get tag(){return"EditTool"}onMove(t){if(this.isMotionElement)return this.onMoveMotion(t);if(this.isFlowElement)return this.onMoveFlow(t);const{moveX:e,moveY:i,editor:s}=t,{app:o,list:r}=s;o.lockLayout(),r.forEach(t=>{t.moveWorld(e,i)}),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:r}=t,{app:n,list:a}=r;n.lockLayout(),a.forEach(t=>{const n="scale"!==r.getEditSize(t);s?t.transformWorld(s,n,!1):t.scaleOfWorld(o,e,i,n,!1)}),n.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:r,list:n}=o;r.lockLayout(),n.forEach(t=>{const r="scale"!==o.getEditSize(t);i?t.transformWorld(i,r,!1):t.rotateOfWorld(s,e)}),r.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:r}=t,{app:n,list:a}=r;n.lockLayout(),a.forEach(t=>{const n="scale"!==r.getEditSize(t);s?t.transformWorld(s,n,!1):t.skewOfWorld(o,e,i,n)}),n.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.updateEditBoxConfig(),this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.unloadEditBoxConfig(),this.onUnload()}};ae=K([Zt()],ae);const{left:he,right:le}=k,{move:de,copy:ce,toNumberPoints:ge}=T;let ue=class extends ae{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,r=t.target,n=i===he;if(r.pathInputed){const{path:t}=r.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,n,o,this.getInnerMove(r,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,r.path=t}else if(r.points){const{points:t}=r,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,n,o,this.getInnerMove(r,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,r.points=t}else{const t=B(),{toPoint:i}=r;r.rotation=0,this.dragPoint(t,i,n,o,this.getInnerMove(r,e,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(i,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(i,null,null,!0),r.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){const e=ge(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,o){const{x:r,y:n}=o;i?(de(t,r,n),s&&de(e,-r,-n)):(s&&de(t,-r,-n),de(e,r,n))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,r=t.target;let n,a;if(r.pathInputed?n=this.getFromToByPath(r.__.path):r.points&&(n=this.getFromToByPoints(r.__.points)),n){const{from:i,to:a}=n;r.innerToWorld(i,i,!1,t),r.innerToWorld(a,a,!1,t);const{x:h,y:l}=t.rectBounds;o.pen.clearPath().moveTo(i.x-h,i.y-l).lineTo(a.x-h,a.y-l),ce(s[7],i),ce(e[7],i),ce(s[3],a),ce(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===he||t===le,s[t].visible=a,e[t].visible=!n&&a}};ue=K([Zt()],ue),V.add("editor","resize"),A.editor=function(t,e){const i=new se(t);return e&&e.sky.add(e.editor=i),i},S.addAttr("textBox",!1,I),p.addAttr("editConfig",void 0,I),p.addAttr("editOuter",t=>{t.updateLayout();const{EditTool:e,LineEditTool:i,PointsEditTool:s}=Yt,o=t.pathInputed||t.isPointsMode?s:t.tag+"EditTool",r=Yt.list[o];return!t.__.__isLinePath||o==s&&r?r?o:e:i},I),p.addAttr("editInner","PathEditor",I),i.addAttr("editInner","",I),M.addAttr("editInner","TextEditor",I),p.setEditConfig=function(t){this.changeAttr("editConfig",t)},p.setEditOuter=function(t){this.changeAttr("editOuter",t)},p.setEditInner=function(t){this.changeAttr("editInner",t)};export{Vt as EditBox,Ot as EditDataHelper,Bt as EditPoint,ut as EditSelect,lt as EditSelectHelper,ae as EditTool,Yt as EditToolCreator,se as Editor,N as EditorEvent,Kt as EditorGroupEvent,J as EditorHelper,Jt as EditorMoveEvent,te as EditorRotateEvent,Qt as EditorScaleEvent,ee as EditorSkewEvent,ne as InnerEditor,Ut as InnerEditorEvent,ue as LineEditTool,ht as SelectArea,at as Stroker,ie as TransformTool,tt as editToolMergeConfigAttr,Zt as registerEditTool,Xt as registerInnerEditor};
2
2
  //# sourceMappingURL=editor.esm.min.js.map