@leafer-in/editor 1.9.4 → 1.9.6
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 +11 -13
- package/dist/editor.esm.js +12 -14
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +11 -13
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.cjs.map +1 -1
- package/dist/editor.min.js +1 -1
- package/dist/editor.min.js.map +1 -1
- package/package.json +6 -6
- package/src/Editor.ts +4 -3
- package/src/display/EditSelect.ts +1 -1
- package/src/helper/EditDataHelper.ts +5 -15
package/dist/editor.js
CHANGED
|
@@ -224,7 +224,7 @@ this.LeaferIN.editor = function(exports, draw, core) {
|
|
|
224
224
|
}
|
|
225
225
|
get running() {
|
|
226
226
|
const {editor: editor} = this;
|
|
227
|
-
return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector;
|
|
227
|
+
return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
|
|
228
228
|
}
|
|
229
229
|
get isMoveMode() {
|
|
230
230
|
return this.app && this.app.interaction.moveMode;
|
|
@@ -522,17 +522,13 @@ this.LeaferIN.editor = function(exports, draw, core) {
|
|
|
522
522
|
}
|
|
523
523
|
toPoint(around || align, boxBounds, origin, true);
|
|
524
524
|
if (dragBounds) {
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
if (useScaleX) scaleX *= fitScaleX;
|
|
533
|
-
if (useScaleY) scaleY *= fitScaleY;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
525
|
+
const scaleData = {
|
|
526
|
+
x: scaleX,
|
|
527
|
+
y: scaleY
|
|
528
|
+
};
|
|
529
|
+
draw.DragBoundsHelper.limitScaleOf(target, origin, scaleData);
|
|
530
|
+
scaleX = scaleData.x;
|
|
531
|
+
scaleY = scaleData.y;
|
|
536
532
|
}
|
|
537
533
|
if (useScaleX && widthRange) {
|
|
538
534
|
const nowWidth = boxBounds.width * target.scaleX;
|
|
@@ -2036,7 +2032,9 @@ this.LeaferIN.editor = function(exports, draw, core) {
|
|
|
2036
2032
|
listenTargetEvents() {
|
|
2037
2033
|
if (!this.targetEventIds.length) {
|
|
2038
2034
|
const {app: app, leafer: leafer, targetLeafer: targetLeafer, editMask: editMask} = this;
|
|
2039
|
-
this.targetEventIds = [ leafer.on_(draw.RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(draw.PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(draw.RenderEvent.CHILD_START, this.onAppRenderStart, this)
|
|
2035
|
+
this.targetEventIds = [ leafer.on_(draw.RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(draw.PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(draw.RenderEvent.CHILD_START, this.onAppRenderStart, this), app.on_(draw.LeaferEvent.UPDATE_MODE, data => {
|
|
2036
|
+
if (data.mode && data.mode !== "normal") this.cancel();
|
|
2037
|
+
}) ];
|
|
2040
2038
|
if (editMask.visible) editMask.forceRender();
|
|
2041
2039
|
}
|
|
2042
2040
|
}
|
package/dist/editor.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");function i(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 s(e){return e?t.isArray(e)?e:[e]:[]}require("@leafer-in/resize"),"function"==typeof SuppressedError&&SuppressedError;class o extends t.Event{get list(){return s(this.value)}get oldList(){return s(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function r(e){return(i,s)=>{const r="_"+s;t.defineKey(i,s,{get(){return this[r]},set(i){const n=this[r];if(n!==i){if(this.config){const e="target"===s;if(e){t.isArray(i)&&i.length>1&&i[0].locked&&i.splice(0,1),this.single&&(this.element.syncEventer=null);const{beforeSelect:e}=this.config;if(e){const s=e({target:i});if(t.isObject(s))i=s;else if(!1===s)return}}const r=e?o.BEFORE_SELECT:o.BEFORE_HOVER;this.hasEvent(r)&&this.emitEvent(new o(r,{editor:this,value:i,oldValue:n}))}this[r]=i,e(this,n)}}})}}o.BEFORE_SELECT="editor.before_select",o.SELECT="editor.select",o.AFTER_SELECT="editor.after_select",o.BEFORE_HOVER="editor.before_hover",o.HOVER="editor.hover";const{abs:n}=Math,{copy:a,scale:h}=t.MatrixHelper,{setListWithFn:l}=t.BoundsHelper,{worldBounds:d}=t.LeafBoundsHelper,c=t.getMatrixData(),g=t.getBoundsData();class u extends t.UI{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?(l(g,e,d),t&&this.set(t),this.set(g),this.visible=!0):this.visible=0}__draw(e,i){const{list:s}=this;if(s.length){let o;const r=this.__,{stroke:l,strokeWidth:d,fill:g}=r,{bounds:u}=i;for(let f=0;f<s.length;f++){o=s[f];const{worldTransform:p,worldRenderBounds:E}=o;if(E.width&&E.height&&(!u||u.hit(E,i.matrix))){const s=n(p.scaleX),u=n(p.scaleY);if(a(c,p),c.half=d%2,s!==u){h(c,1/s,1/u),e.setWorld(c,i.matrix),e.beginPath(),r.strokeWidth=d;const{x:t,y:n,width:a,height:l}=o.__layout.boxBounds;e.rect(t*s,n*u,a*s,l*u)}else e.setWorld(c,i.matrix),e.beginPath(),o.__.__useArrow?o.__drawPath(e):o.__.__pathForRender?o.__drawRenderPath(e):o.__drawPathByBox(e),r.strokeWidth=d/n(p.scaleX);l&&(t.isString(l)?t.Paint.stroke(l,this,e):t.Paint.strokes(l,this,e)),g&&(t.isString(g)?t.Paint.fill(g,this,e):t.Paint.fills(g,this,e))}}r.strokeWidth=d}}destroy(){this.target=null,super.destroy()}}i([r(function(e){const i=e.target;e.list=i?t.isArray(i)?i:[i]:[]})],u.prototype,"target",void 0);class f extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=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 p={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return E([t],i,e),i}};function E(t,e,i){let s,o;for(let r=0,n=t.length;r<n;r++)if(s=t[r],o=s.__,o.hittable&&o.visible&&!o.locked&&i.hit(s.__world)){if(o.editable){if(s.isBranch&&!o.hitChildren){o.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&o.hitSelf&&e.push(s)}s.isBranch&&E(s.children,e,i)}}const{findOne:m,findByBounds:v}=p;class b extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new u,this.targetStroker=new u,this.bounds=new t.Bounds,this.selectArea=new f,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedStyle:i}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2)},i||{}))}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||(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(e){if(!e.multiTouch){if(this.editor.dragging)return this.onDragEnd(e);if(this.dragging){const{editor:i}=this,s=e.getInnerTotal(this),o=this.bounds.clone().unsign(),r=new t.LeafList(v(i.app,o));if(this.bounds.width=s.x,this.bounds.height=s.y,this.selectArea.setBounds(o.get()),r.length){const t=[];this.originList.forEach(e=>{r.has(e)||t.push(e)}),r.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==i.list.length||i.list.some((e,i)=>e!==t[i]))&&(i.target=t)}else i.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=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)&&!m(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return m(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):m(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:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_([[o.HOVER,this.onHover,this],[o.SELECT,this.onSelect,this]]),i.on_([[e.PointerEvent.MOVE,this.onPointerMove,this],[e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this],[e.PointerEvent.TAP,this.onTap,this],[e.DragEvent.START,this.onDragStart,this,!0],[e.DragEvent.DRAG,this.onDrag,this],[e.DragEvent.END,this.onDragEnd,this],[e.MoveEvent.MOVE,this.onAutoMove,this],[[e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:w,top:L,topRight:x,right:y,bottomRight:k,bottom:T,bottomLeft:O,left:S}=t.Direction9,{toPoint:_}=t.AroundHelper,{within:M,sign:B}=t.MathHelper,C={getScaleData(e,i,s,o,r,n,a,h){let l,d={},c=1,g=1;const{boxBounds:u,widthRange:f,heightRange:p,dragBounds:E,worldBoxBounds:m}=e,{width:v,height:b}=i;n&&(o.x*=2,o.y*=2);const C=e.scaleX/i.scaleX,R=e.scaleY/i.scaleY,P=B(C),H=B(R),D=h?C:P*u.width/v,V=h?R:H*u.height/b;o.x*=h?C:P,o.y*=h?R:H;const I=(-o.y+b)/b,A=(o.x+v)/v,z=(o.y+b)/b,F=(-o.x+v)/v;switch(s){case L:g=I,l="bottom";break;case y:c=A,l="left";break;case T:g=z,l="top";break;case S:c=F,l="right";break;case w:g=I,c=F,l="bottom-right";break;case x:g=I,c=A,l="bottom-left";break;case k:g=z,c=A,l="top-left";break;case O:g=z,c=F,l="top-right"}if(r)if("corner"===r&&s%2)r=!1;else{let t;switch(s){case L:case T:t=g;break;case S:case y:t=c;break;default:t=Math.sqrt(Math.abs(c*g))}c=c<0?-t:t,g=g<0?-t:t}const Z=1!==c,G=1!==g;if(Z&&(c/=D),G&&(g/=V),!a){const{worldTransform:t}=e;c<0&&(c=1/u.width/t.scaleX),g<0&&(g=1/u.height/t.scaleY)}if(_(n||l,u,d,!0),E){const i="parent"===E?e.parent.boxBounds:E,s=new t.Bounds(e.__localBoxBounds);if(t.BoundsHelper.includes(new t.Bounds(i).spread(.1),s)&&(s.scaleOf(e.getLocalPointByInner(d),c,g),!t.BoundsHelper.includes(i,s))){const t=s.getIntersect(i),e=t.width/s.width,o=t.height/s.height;Z&&(c*=e),G&&(g*=o)}}if(Z&&f){const t=u.width*e.scaleX;c=M(t*c,f)/t}if(G&&p){const t=u.height*e.scaleY;g=M(t*g,p)/t}return Z&&Math.abs(c*m.width)<1&&(c=B(c)/m.width),G&&Math.abs(g*m.height)<1&&(g=B(g)/m.height),r&&c!==g&&(g=c=Math.min(c,g)),{origin:d,scaleX:c,scaleY:g,direction:s,lockRatio:r,around:n}},getRotateData(e,i,s,o,r){let n,a={};switch(i){case w:n="bottom-right";break;case x:n="bottom-left";break;case k:n="top-left";break;case O:n="top-right";break;default:n="center"}return _(r||n,e.boxBounds,a,!0),{origin:a,rotation:t.PointHelper.getRotation(o,e.getWorldPointByBox(a),s)}},getSkewData(e,i,s,o){let r,n,a={},h=0,l=0;switch(i){case L:case w:n={x:.5,y:0},r="bottom",h=1;break;case T:case k:n={x:.5,y:1},r="top",h=1;break;case S:case O:n={x:0,y:.5},r="right",l=1;break;case y:case x:n={x:1,y:.5},r="left",l=1}const{width:d,height:c}=e;n.x=n.x*d,n.y=n.y*c,_(o||r,e,a,!0);const g=t.PointHelper.getRotation(n,a,{x:n.x+(h?s.x:0),y:n.y+(l?s.y:0)});return h?h=-g:l=g,{origin:a,skewX:h,skewY:l}},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 S:t=y;break;case w:t=x;break;case O:t=k;break;case y:t=S;break;case x:t=w;break;case k:t=O}if(i)switch(t){case L:t=T;break;case w:t=O;break;case x:t=k;break;case T:t=L;break;case O:t=w;break;case k:t=x}return t}},R={};function P(e,i){const{enterPoint:s,dragging:o,skewing:r,resizing:n,flippedX:a,flippedY:h}=e;if(!s||!e.editor.editing||!e.canUse)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:l}=e;const{pointType:d}=s,{resizeCursor:c,rotateCursor:g,skewCursor:u,resizeable:f,rotateable:p,skewable:E}=e.mergeConfig;let m=d.includes("resize");m&&p&&(e.isHoldRotateKey(i)||!f)&&(m=!1);const v=E&&!m&&("resize-line"===s.name||"skew"===d),b=o?r?u:n?c:g:v?u:m?c:g;l+=45*(C.getFlipDirection(s.direction,a,h)+1),l=2*Math.round(t.MathHelper.formatRotation(l,!0)/2);const{url:w,x:L,y:x}=b,y=w+l;R[y]?s.cursor=R[y]:R[y]=s.cursor={url:D(w,l),x:L,y:x}}function H(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function D(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class V extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const I=["top","right","bottom","left"],A=void 0;class z extends t.Group{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.visible&&this.view.visible}get canGesture(){if(!this.canUse)return!1;const{moveable:e,resizeable:i,rotateable:s}=this.mergeConfig;return t.isString(e)||t.isString(i)||t.isString(s)}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new V({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}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 V({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new V({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),n.push(e),this.listenPointEvents(e,"resize",s)),i=new V({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...r,a,h,l,...n,...o),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:o,resizePoints:r}=this,{stroke:n,strokeWidth:a}=e,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;this.visible=!t.locked;for(let t=0;t<8;t++)d=r[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),d.rotation=(t-(t%2?1:0))/2*90;o.set(this.getPointStyle(e.circle||e.rotatePoint||h[0])),s.set(Object.assign({stroke:n,strokeWidth:a,editConfig:A},e.rect||{}));const c=i&&this.transformTool.editTool;s.hittable=!c,s.syncEventer=c&&this.editor,c&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),H(this)}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})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(e){const{editMask:i}=this.editor,{mergeConfig:s,single:o,rect:r,circle:n,buttons:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:f,editBox:p,mask:E,spread:m,hideRotatePoints:v,hideResizeLines:b}=s;if(i.visible=!!E||0,m&&t.BoundsHelper.spread(e,m),this.view.worldOpacity){const{width:i,height:E}=e,m=t.isNumber(f)?f:10,w=p&&!(f&&i<m&&E<m);let L,x,y,k={};for(let s=0;s<8;s++)t.AroundHelper.toPoint(t.AroundHelper.directionData[s],e,k),x=h[s],L=l[s],x.set(k),L.set(k),x.visible=w&&!(!g&&!u),L.visible=w&&u&&g&&!v,s%2&&(y=d[(s-1)/2],y.set(k),y.visible=x.visible&&!b,x.visible=L.visible=w&&!!c,(s+1)/2%2?(y.width=i,f&&2*x.width>i&&(x.visible=!1)):(y.height=E,f&&2*x.width>E&&(x.visible=!1)));n.visible=w&&u&&!(!s.circle&&!s.rotatePoint),n.visible&&this.layoutCircle(),r.path&&(r.path=null),r.set(Object.assign(Object.assign({},e),{visible:!o||p})),a.visible=w&&a.children.length>0||0,a.visible&&this.layoutButtons()}else r.set(e)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:o}=this.mergedConfig,r=I.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=I.indexOf(e);(a%2&&r||(a+1)%2&&n)&&i&&(a=(a+2)%4);const h=i?C.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",width:o,height:o,cornerRadius:r,offsetX:0,offsetY:0,editConfig:A};return t?Object.assign(n,t):n}getPointsStyle(){const{point:e}=this.mergedConfig;return t.isArray(e)?e:[e]}getMiddlePointsStyle(){const{middlePoint:e}=this.mergedConfig;return t.isArray(e)?e:e?[e]:this.getPointsStyle()}onDragStart(e){this.dragging=!0;const i=this.dragPoint=e.current,{pointType:s}=i,{editor:o,dragStartData:r}=this,{target:n}=this,{moveable:a,resizeable:h,rotateable:l,skewable:d,hideOnMove:c}=this.mergeConfig;"rect"===i.name?(a&&(this.moving=!0),o.opacity=c?0:1):(s.includes("rotate")||this.isHoldRotateKey(e)||!h?(l&&(this.rotating=!0),"resize-rotate"===s?h&&(this.resizing=!0):"resize-line"===i.name&&(d&&(this.skewing=!0),this.rotating=!1)):"resize"===s&&h&&(this.resizing=!0),"skew"===s&&d&&(this.skewing=!0)),r.x=e.x,r.y=e.y,r.point={x:n.x,y:n.y},r.bounds=Object.assign({},n.getLayoutBounds("box","local")),r.rotation=n.rotation,s&&s.includes("resize")&&(t.ResizeEvent.resizingKeys=o.leafList.keys)}onDragEnd(e){this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds&&this.transformTool.onMove(e),this.dragPoint=null,this.resetDoing();const{name:i,pointType:s}=e.current;"rect"===i&&(this.editor.opacity=1),s&&s.includes("resize")&&(t.ResizeEvent.resizingKeys=null)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:o,skewing:r}=this;if(i)e.onMove(t),H(this);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),P(this,t)}}resetDoing(){this.canUse&&(this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1)}onMove(e){this.canGesture&&"drag"!==e.moveType&&(e.stop(),t.isString(this.mergeConfig.moveable)&&(this.gesturing=this.moving=!0,this.transformTool.onMove(e)))}onMoveEnd(t){this.moving&&this.transformTool.onMove(t),this.resetDoing()}onScale(e){this.canGesture&&(e.stop(),t.isString(this.mergeConfig.resizeable)&&(this.gesturing=this.resizing=!0,this.transformTool.onScale(e)))}onRotate(e){this.canGesture&&(e.stop(),t.isString(this.mergeConfig.rotateable)&&(this.gesturing=this.rotating=!0,this.transformTool.onRotate(e)))}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){P(this,t)}onArrow(t){const{editor:e,transformTool:i}=this;if(this.canUse&&e.editing&&this.mergeConfig.keyEvent){let e=0,s=0;const o=t.shiftKey?10:1;switch(t.code){case"ArrowDown":s=o;break;case"ArrowUp":s=-o;break;case"ArrowLeft":e=-o;break;case"ArrowRight":e=o}(e||s)&&i.move(e,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(e){const{editor:i,target:s}=this;if(this.single){if(s.locked)return;if(s.isBranch&&!s.editInner){if(s.textBox){const{children:e}=s,o=e.find(e=>e.editable&&e instanceof t.Text)||e.find(e=>e instanceof t.Text);if(o)return i.openInnerEditor(o)}i.openGroup(s),i.target=i.selector.findDeepOne(e)}else i.openInnerEditor()}}listenPointEvents(t,i,s){t.direction=s,t.pointType=i;const o=[[e.DragEvent.START,this.onDragStart,this],[e.DragEvent.DRAG,this.onDrag,this],[e.DragEvent.END,this.onDragEnd,this],[e.PointerEvent.LEAVE,()=>{this.enterPoint=null}]];"circle"!==t.name&&o.push([e.PointerEvent.ENTER,e=>{this.enterPoint=t,P(this,e)}]),this.__eventIds.push(t.on_(o))}__listenEvents(){const{rect:t,editor:i,__eventIds:s}=this;s.push(t.on_([[e.DragEvent.START,this.onDragStart,this],[e.DragEvent.DRAG,this.onDrag,this],[e.DragEvent.END,this.onDragEnd,this],[e.PointerEvent.ENTER,()=>H(this)],[e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this],[e.PointerEvent.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{s.push(i.app.on_([[[e.KeyEvent.HOLD,e.KeyEvent.UP],this.onKey,this],[e.KeyEvent.DOWN,this.onArrow,this],[e.MoveEvent.BEFORE_MOVE,this.onMove,this,!0],[e.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0],[e.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0],[e.MoveEvent.END,this.onMoveEnd,this],[e.ZoomEvent.END,this.resetDoing,this],[e.RotateEvent.END,this.resetDoing,this]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const F={x:0,y:0,width:1e5,height:1e5};class Z extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,F),Object.assign(this.__world,F)}__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 G='\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"/>',W={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${G}\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${G}\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${G}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},U=new t.Bounds;function X(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{U.setListWithFn(i,t=>t.getBounds("box","page")),0===U.width&&(U.width=.1),0===U.height&&(U.height=.1),e.reset(U.get())}),s.add(e)}const Y=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),K=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),N={group(e,i,s){e.sort(K);const{app:o,parent:r}=e[0];let n;n=s&&s.add?s:new t.Group(s),r.addAt(n,r.children.indexOf(e[0])),e.sort(Y);const a=new t.Matrix(i.worldTransform);return a.divideParent(r.scrollWorldTransform),n.setTransform(a),n.editable=!0,n.hitChildren=!1,o.lockLayout(),e.forEach(t=>t.dropTo(n)),o.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(Y),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(K),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},j=t.Debug.get("EditToolCreator");function q(){return t=>{J.register(t)}}const $=q,J={list:{},register(t){const{tag:e}=t.prototype;Q[e]&&j.repeat(e),Q[e]=t},get:(t,e)=>new Q[t](e)},{list:Q}=J;class tt extends o{constructor(t,e){super(t,e)}}tt.BEFORE_OPEN="innerEditor.before_open",tt.OPEN="innerEditor.open",tt.BEFORE_CLOSE="innerEditor.before_close",tt.CLOSE="innerEditor.close";class et extends o{constructor(t,e){super(t,e)}}et.BEFORE_GROUP="editor.before_group",et.GROUP="editor.group",et.BEFORE_UNGROUP="editor.before_ungroup",et.UNGROUP="editor.ungroup",et.BEFORE_OPEN="editor.before_open_group",et.OPEN="editor.open_group",et.BEFORE_CLOSE="editor.before_close_group",et.CLOSE="editor.close_group";const{updateMatrix:it}=t.LeafHelper,st={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},ot="top-left";class rt extends t.Rect{get __tag(){return"SimulateElement"}constructor(e){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(t.PropertyEvent.CHANGE,i=>{if(this.checkChange&&st[i.attrName]){const{attrName:s,newValue:o,oldValue:r}=i,n="s"===s[0]?(o||1)/(r||1):(o||0)-(r||0);this.canChange=!1;const a=this.__;a[s]=r,it(this.parent),it(this);const h=new t.Matrix(this.__world);switch(a[s]=o,this.__layout.rotationChange(),it(this),this.changedTransform=new t.Matrix(this.__world).divide(h),s){case"x":e.move(n,0);break;case"y":e.move(0,n);break;case"rotation":e.rotateOf(ot,n);break;case"scaleX":e.scaleOf(ot,n,1);break;case"scaleY":e.scaleOf(ot,1,n);break;case"skewX":e.skewOf(ot,n,0);break;case"skewY":e.skewOf(ot,0,n)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class nt extends o{constructor(t,e){super(t,e)}}nt.BEFORE_MOVE="editor.before_move",nt.MOVE="editor.move";class at extends o{constructor(t,e){super(t,e)}}at.BEFORE_SCALE="editor.before_scale",at.SCALE="editor.scale";class ht extends o{constructor(t,e){super(t,e)}}ht.BEFORE_ROTATE="editor.before_rotate",ht.ROTATE="editor.rotate";class lt extends o{constructor(t,e){super(t,e)}}lt.BEFORE_SKEW="editor.before_skew",lt.SKEW="editor.skew";class dt{onMove(i){const{target:s,mergeConfig:o,dragStartData:r}=this.editBox;let n,{dragLimitAnimate:a}=o;const h=i.type===e.MoveEvent.END||i.type===e.DragEvent.END,l=t.isString(s.draggable),d=!a||h||l;if(i instanceof e.MoveEvent)n=i.getLocalMove(s),d&&e.DragEvent.limitMove(s,n);else{const t={x:i.totalX,y:i.totalY};i.shiftKey&&(Math.abs(t.x)>Math.abs(t.y)?t.y=0:t.x=0),n=e.DragEvent.getValidMove(s,r.point,t,d)}(n.x||n.y)&&(a&&!l&&h?t.LeafHelper.animateMove(this,n,t.isNumber(a)?a:.3):this.move(n))}onScale(t){const{target:i,mergeConfig:s,single:o,dragStartData:r}=this.editBox;let{around:n,lockRatio:a,flipable:h,editSize:l}=s;if(t instanceof e.ZoomEvent)this.scaleOf(i.getBoxPoint(t),t.scale,t.scale);else{const{direction:e}=t.current;(t.shiftKey||i.lockRatio)&&(a=!0);const s=C.getScaleData(i,r.bounds,e,t.getInnerTotal(i),a,C.getAround(n,t.altKey),h,!o||"scale"===l);this.editTool&&this.editTool.onScaleWithDrag?(s.drag=t,this.scaleWithDrag(s)):this.scaleOf(s.origin,s.scaleX,s.scaleY)}}onRotate(i){const{target:s,mergeConfig:o,dragStartData:r}=this.editBox,{around:n,rotateAround:a,rotateGap:h}=o,{direction:l}=i.current;let d,c;if(i instanceof e.RotateEvent)c=i.rotation,d=a?t.AroundHelper.getPoint(a,s.boxBounds):s.getBoxPoint(i);else{const t=C.getRotateData(s,l,i,r,i.shiftKey?null:a||s.around||s.origin||n||"center");c=r.rotation+t.rotation-s.rotation,d=t.origin}c=t.MathHelper.float(t.MathHelper.getGapRotation(c,h,s.rotation),2),c&&this.rotateOf(d,c)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:o,skewX:r,skewY:n}=C.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),C.getAround(s,t.altKey));(r||n)&&this.skewOf(o,r,n)}move(e,i=0){if(!this.checkTransform("moveable"))return;t.isObject(e)&&(i=e.y,e=e.x);const{target:s,mergeConfig:o,single:r,editor:n}=this.editBox,{beforeMove:a}=o;if(a){const o=a({target:s,x:e,y:i});if(t.isObject(o))e=o.x,i=o.y;else if(!1===o)return}const h=s.getWorldPointByLocal({x:e,y:i},null,!0);r||s.safeChange(()=>s.move(e,i));const l={target:s,editor:n,moveX:h.x,moveY:h.y};this.emitEvent(new nt(nt.BEFORE_MOVE,l));const d=new nt(nt.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 at(at.BEFORE_SCALE,t));const r=new at(at.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(e,i,s=i,o){if(!this.checkTransform("resizeable"))return;const{target:r,mergeConfig:n,single:a,editor:h}=this.editBox,{beforeScale:l}=n;if(l){const o=l({target:r,origin:e,scaleX:i,scaleY:s});if(t.isObject(o))i=o.scaleX,s=o.scaleY;else if(!1===o)return}const d=this.getWorldOrigin(e),c=!a&&this.getChangedTransform(()=>r.safeChange(()=>r.scaleOf(e,i,s))),g={target:r,editor:h,worldOrigin:d,scaleX:i,scaleY:s,transform:c};this.emitEvent(new at(at.BEFORE_SCALE,g));const u=new at(at.SCALE,g);this.doScale(u),this.emitEvent(u)}flip(e){if(!this.checkTransform("resizeable"))return;const{target:i,single:s,editor:o}=this.editBox,r=this.getWorldOrigin("center"),n=s?new t.Matrix(t.LeafHelper.getFlipTransform(i,e)):this.getChangedTransform(()=>i.safeChange(()=>i.flip(e))),a={target:i,editor:o,worldOrigin:r,scaleX:"x"===e?-1:1,scaleY:"y"===e?-1:1,transform:n};this.emitEvent(new at(at.BEFORE_SCALE,a));const h=new at(at.SCALE,a);this.doScale(h),this.emitEvent(h)}rotateOf(e,i){if(!this.checkTransform("rotateable"))return;const{target:s,mergeConfig:o,single:r,editor:n}=this.editBox,{beforeRotate:a}=o;if(a){const o=a({target:s,origin:e,rotation:i});if(t.isNumber(o))i=o;else if(!1===o)return}const h=this.getWorldOrigin(e),l=!r&&this.getChangedTransform(()=>s.safeChange(()=>s.rotateOf(e,i))),d={target:s,editor:n,worldOrigin:h,rotation:i,transform:l};this.emitEvent(new ht(ht.BEFORE_ROTATE,d));const c=new ht(ht.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(e,i,s=0,o){if(!this.checkTransform("skewable"))return;const{target:r,mergeConfig:n,single:a,editor:h}=this.editBox,{beforeSkew:l}=n;if(l){const o=l({target:r,origin:e,skewX:i,skewY:s});if(t.isObject(o))i=o.skewX,s=o.skewY;else if(!1===o)return}const d=this.getWorldOrigin(e),c=!a&&this.getChangedTransform(()=>r.safeChange(()=>r.skewOf(e,i,s))),g={target:r,editor:h,worldOrigin:d,skewX:i,skewY:s,transform:c};this.emitEvent(new lt(lt.BEFORE_SKEW,g));const u=new lt(lt.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(e){const{target:i}=this.editBox;return i.getWorldPoint(t.LeafHelper.getInnerOrigin(i,e))}getChangedTransform(e){const{target:i,single:s}=this.editBox;if(!s&&!i.canChange)return i.changedTransform;const o=new t.Matrix(i.worldTransform);return e(),new t.Matrix(i.worldTransform).divide(o)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}exports.Editor=class extends t.Group{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(e,i){super(i),this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new rt(this),this.editBox=new z(this),this.editToolList={},this.selector=new b(this),this.editMask=new Z(this),this.targetEventIds=[];let s=t.DataHelper.clone(W);e&&(s=t.DataHelper.default(e,s)),this.mergedConfig=this.config=s,this.addMany(this.editMask,this.selector,this.editBox),t.Plugin.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&X(this),this.update()}updateEditTool(){if(this.unloadEditTool(),this.editing){const e=this.element;let i=e.editOuter||"EditTool";const{beforeEditOuter:s}=this.mergeConfig;if(s){const o=s({target:e,name:i});if(t.isString(o))i=o;else if(!1===o)return}if(J.list[i]){const t=this.editTool=this.editToolList[i]=this.editToolList[i]||J.get(i,this);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=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(et.BEFORE_GROUP),this.target=N.group(this.list,this.element,t),this.emitGroupEvent(et.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(et.BEFORE_UNGROUP,t)),this.target=N.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(et.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(et.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(et.OPEN,t)}closeGroup(t){this.emitGroupEvent(et.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(et.CLOSE,t)}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach(e=>this.list.every(i=>!t.LeafHelper.hasParent(i,e))&&i.push(e))),i.forEach(t=>this.closeGroup(t))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new et(t,{editTarget:e});e&&e.syncEventer||this.emitEvent(i),e&&e.emitEvent(i)}openInnerEditor(e,i,s){let o;if(t.isString(i)?o=i:s||(s=i),e&&s&&(this.target=e),this.single){e||(e=this.element),o||(o=e.editInner);const{beforeEditInner:i}=this.mergeConfig;if(i){const s=i({target:e,name:o});if(t.isString(s))o=s;else if(!1===s)return}J.list[o]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[o]=this.editToolList[o]||J.get(o,this),this.innerEditor.editTarget=e,this.emitInnerEvent(tt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(tt.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(tt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(tt.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new tt(t,{editTarget:i,innerEditor:e});i.syncEventer||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&&(N.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(N.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:e,leafer:i,targetLeafer:s,editMask:o}=this;this.targetEventIds=[i.on_(t.RenderEvent.START,this.onRenderStart,this),s&&s.on_(t.PropertyEvent.SCROLL,this.onChildScroll,this),e.on_(t.RenderEvent.CHILD_START,this.onAppRenderStart,this)],o.visible&&o.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())}},i([(e,i)=>{t.defineKey(e,i,{get(){const{config:e,element:i,dragPoint:s,editBox:o,app:r}=this,n=Object.assign({},e);return i&&i.editConfig&&Object.assign(n,i.editConfig),o.config&&Object.assign(n,o.config),s&&(s.editConfig&&Object.assign(n,s.editConfig),"font-size"===n.editSize&&(n.lockRatio=!0),"resize-rotate"===s.pointType&&(n.around||(n.around="center"),t.isNull(n.lockRatio)&&(n.lockRatio=!0))),t.isUndefined(n.dragLimitAnimate)&&(n.dragLimitAnimate=r&&r.config.pointer.dragLimitAnimate),this.mergedConfig=n}})}],exports.Editor.prototype,"mergeConfig",void 0),i([r(function(t,e){t.emitEvent(new o(o.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],exports.Editor.prototype,"hoverTarget",void 0),i([r(function(e,i){const{target:s}=e;s?(e.leafList=s instanceof t.LeafList?s:new t.LeafList(s),e.multiple&&X(e)):(e.simulateTarget.remove(),e.leafList.reset()),e.closeInnerEditor(!0),e.unloadEditTool();const r={editor:e,value:s,oldValue:i};e.emitEvent(new o(o.SELECT,r)),e.checkOpenedGroups(),e.editing?e.waitLeafer(()=>{e.updateEditTool(),e.listenTargetEvents()}):(e.updateEditTool(),e.removeTargetEvents()),e.emitEvent(new o(o.AFTER_SELECT,r))})],exports.Editor.prototype,"target",void 0),exports.Editor=i([e.useModule(dt,["editBox","editTool","emitEvent"])],exports.Editor);class ct{static registerInnerEditor(){J.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this.editor.editBox}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,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)}}exports.EditTool=class extends ct{static registerEditTool(){J.register(this)}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):t.scaleOfWorld(o,e,i,n)}),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):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):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()}},exports.EditTool=i([q()],exports.EditTool);const{left:gt,right:ut}=t.Direction9,{move:ft,copy:pt,toNumberPoints:Et}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:s,lockRatio:o,around:r}=e,n=e.target,a=s===gt;if(n.pathInputed){const{path:t}=n.__,{from:e,to:s}=this.getFromToByPath(t);this.dragPoint(e,s,a,r,this.getInnerMove(n,i,o)),t[1]=e.x,t[2]=e.y,t[4]=s.x,t[5]=s.y,n.path=t}else if(n.points){const{points:t}=n,{from:e,to:s}=this.getFromToByPoints(t);this.dragPoint(e,s,a,r,this.getInnerMove(n,i,o)),t[0]=e.x,t[1]=e.y,t[2]=s.x,t[3]=s.y,n.points=t}else{const e=t.getPointData(),{toPoint:s}=n;n.rotation=0,this.dragPoint(e,s,a,r,this.getInnerMove(n,i,o)),n.getLocalPointByInner(e,null,null,!0),n.getLocalPointByInner(s,null,null,!0),n.x=e.x,n.y=e.y,n.getInnerPointByLocal(s,null,null,!0),n.toPoint=s}}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=Et(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?(ft(t,r,n),s&&ft(e,-r,-n)):(s&&ft(t,-r,-n),ft(e,r,n))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,r=this.editor.element;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),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),pt(s[7],i),pt(e[7],i),pt(s[3],a),pt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===gt||t===ut,s[t].visible=a,e[t].visible=!n&&a}},exports.LineEditTool=i([q()],exports.LineEditTool),t.Plugin.add("editor","resize"),t.Creator.editor=function(t,e){const i=new exports.Editor(t);return e&&e.sky.add(e.editor=i),i},t.Box.addAttr("textBox",!1,t.dataType),t.UI.addAttr("editConfig",void 0,t.dataType),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),t.dataType),t.UI.addAttr("editInner","PathEditor",t.dataType),t.Group.addAttr("editInner","",t.dataType),t.Text.addAttr("editInner","TextEditor",t.dataType),t.UI.setEditConfig=function(t){this.changeAttr("editConfig",t)},t.UI.setEditOuter=function(t){this.changeAttr("editOuter",t)},t.UI.setEditInner=function(t){this.changeAttr("editInner",t)},exports.EditBox=z,exports.EditDataHelper=C,exports.EditPoint=V,exports.EditSelect=b,exports.EditSelectHelper=p,exports.EditToolCreator=J,exports.EditorEvent=o,exports.EditorGroupEvent=et,exports.EditorHelper=N,exports.EditorMoveEvent=nt,exports.EditorRotateEvent=ht,exports.EditorScaleEvent=at,exports.EditorSkewEvent=lt,exports.InnerEditor=ct,exports.InnerEditorEvent=tt,exports.SelectArea=f,exports.Stroker=u,exports.TransformTool=dt,exports.registerEditTool=q,exports.registerInnerEditor=$;
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");function i(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 s(e){return e?t.isArray(e)?e:[e]:[]}require("@leafer-in/resize"),"function"==typeof SuppressedError&&SuppressedError;class o extends t.Event{get list(){return s(this.value)}get oldList(){return s(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function r(e){return(i,s)=>{const r="_"+s;t.defineKey(i,s,{get(){return this[r]},set(i){const n=this[r];if(n!==i){if(this.config){const e="target"===s;if(e){t.isArray(i)&&i.length>1&&i[0].locked&&i.splice(0,1),this.single&&(this.element.syncEventer=null);const{beforeSelect:e}=this.config;if(e){const s=e({target:i});if(t.isObject(s))i=s;else if(!1===s)return}}const r=e?o.BEFORE_SELECT:o.BEFORE_HOVER;this.hasEvent(r)&&this.emitEvent(new o(r,{editor:this,value:i,oldValue:n}))}this[r]=i,e(this,n)}}})}}o.BEFORE_SELECT="editor.before_select",o.SELECT="editor.select",o.AFTER_SELECT="editor.after_select",o.BEFORE_HOVER="editor.before_hover",o.HOVER="editor.hover";const{abs:n}=Math,{copy:a,scale:h}=t.MatrixHelper,{setListWithFn:l}=t.BoundsHelper,{worldBounds:d}=t.LeafBoundsHelper,c=t.getMatrixData(),g=t.getBoundsData();class u extends t.UI{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?(l(g,e,d),t&&this.set(t),this.set(g),this.visible=!0):this.visible=0}__draw(e,i){const{list:s}=this;if(s.length){let o;const r=this.__,{stroke:l,strokeWidth:d,fill:g}=r,{bounds:u}=i;for(let f=0;f<s.length;f++){o=s[f];const{worldTransform:p,worldRenderBounds:E}=o;if(E.width&&E.height&&(!u||u.hit(E,i.matrix))){const s=n(p.scaleX),u=n(p.scaleY);if(a(c,p),c.half=d%2,s!==u){h(c,1/s,1/u),e.setWorld(c,i.matrix),e.beginPath(),r.strokeWidth=d;const{x:t,y:n,width:a,height:l}=o.__layout.boxBounds;e.rect(t*s,n*u,a*s,l*u)}else e.setWorld(c,i.matrix),e.beginPath(),o.__.__useArrow?o.__drawPath(e):o.__.__pathForRender?o.__drawRenderPath(e):o.__drawPathByBox(e),r.strokeWidth=d/n(p.scaleX);l&&(t.isString(l)?t.Paint.stroke(l,this,e):t.Paint.strokes(l,this,e)),g&&(t.isString(g)?t.Paint.fill(g,this,e):t.Paint.fills(g,this,e))}}r.strokeWidth=d}}destroy(){this.target=null,super.destroy()}}i([r(function(e){const i=e.target;e.list=i?t.isArray(i)?i:[i]:[]})],u.prototype,"target",void 0);class f extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=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 p={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return E([t],i,e),i}};function E(t,e,i){let s,o;for(let r=0,n=t.length;r<n;r++)if(s=t[r],o=s.__,o.hittable&&o.visible&&!o.locked&&i.hit(s.__world)){if(o.editable){if(s.isBranch&&!o.hitChildren){o.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&o.hitSelf&&e.push(s)}s.isBranch&&E(s.children,e,i)}}const{findOne:m,findByBounds:v}=p;class b extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&"normal"===this.app.mode}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new u,this.targetStroker=new u,this.bounds=new t.Bounds,this.selectArea=new f,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedStyle:i}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2)},i||{}))}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||(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(e){if(!e.multiTouch){if(this.editor.dragging)return this.onDragEnd(e);if(this.dragging){const{editor:i}=this,s=e.getInnerTotal(this),o=this.bounds.clone().unsign(),r=new t.LeafList(v(i.app,o));if(this.bounds.width=s.x,this.bounds.height=s.y,this.selectArea.setBounds(o.get()),r.length){const t=[];this.originList.forEach(e=>{r.has(e)||t.push(e)}),r.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==i.list.length||i.list.some((e,i)=>e!==t[i]))&&(i.target=t)}else i.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=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)&&!m(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return m(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):m(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:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_([[o.HOVER,this.onHover,this],[o.SELECT,this.onSelect,this]]),i.on_([[e.PointerEvent.MOVE,this.onPointerMove,this],[e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this],[e.PointerEvent.TAP,this.onTap,this],[e.DragEvent.START,this.onDragStart,this,!0],[e.DragEvent.DRAG,this.onDrag,this],[e.DragEvent.END,this.onDragEnd,this],[e.MoveEvent.MOVE,this.onAutoMove,this],[[e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:w,top:L,topRight:x,right:y,bottomRight:k,bottom:T,bottomLeft:O,left:S}=t.Direction9,{toPoint:_}=t.AroundHelper,{within:M,sign:B}=t.MathHelper,C={getScaleData(e,i,s,o,r,n,a,h){let l,d={},c=1,g=1;const{boxBounds:u,widthRange:f,heightRange:p,dragBounds:E,worldBoxBounds:m}=e,{width:v,height:b}=i;n&&(o.x*=2,o.y*=2);const C=e.scaleX/i.scaleX,R=e.scaleY/i.scaleY,P=B(C),H=B(R),D=h?C:P*u.width/v,V=h?R:H*u.height/b;o.x*=h?C:P,o.y*=h?R:H;const A=(-o.y+b)/b,I=(o.x+v)/v,z=(o.y+b)/b,F=(-o.x+v)/v;switch(s){case L:g=A,l="bottom";break;case y:c=I,l="left";break;case T:g=z,l="top";break;case S:c=F,l="right";break;case w:g=A,c=F,l="bottom-right";break;case x:g=A,c=I,l="bottom-left";break;case k:g=z,c=I,l="top-left";break;case O:g=z,c=F,l="top-right"}if(r)if("corner"===r&&s%2)r=!1;else{let t;switch(s){case L:case T:t=g;break;case S:case y:t=c;break;default:t=Math.sqrt(Math.abs(c*g))}c=c<0?-t:t,g=g<0?-t:t}const Z=1!==c,G=1!==g;if(Z&&(c/=D),G&&(g/=V),!a){const{worldTransform:t}=e;c<0&&(c=1/u.width/t.scaleX),g<0&&(g=1/u.height/t.scaleY)}if(_(n||l,u,d,!0),E){const i={x:c,y:g};t.DragBoundsHelper.limitScaleOf(e,d,i),c=i.x,g=i.y}if(Z&&f){const t=u.width*e.scaleX;c=M(t*c,f)/t}if(G&&p){const t=u.height*e.scaleY;g=M(t*g,p)/t}return Z&&Math.abs(c*m.width)<1&&(c=B(c)/m.width),G&&Math.abs(g*m.height)<1&&(g=B(g)/m.height),r&&c!==g&&(g=c=Math.min(c,g)),{origin:d,scaleX:c,scaleY:g,direction:s,lockRatio:r,around:n}},getRotateData(e,i,s,o,r){let n,a={};switch(i){case w:n="bottom-right";break;case x:n="bottom-left";break;case k:n="top-left";break;case O:n="top-right";break;default:n="center"}return _(r||n,e.boxBounds,a,!0),{origin:a,rotation:t.PointHelper.getRotation(o,e.getWorldPointByBox(a),s)}},getSkewData(e,i,s,o){let r,n,a={},h=0,l=0;switch(i){case L:case w:n={x:.5,y:0},r="bottom",h=1;break;case T:case k:n={x:.5,y:1},r="top",h=1;break;case S:case O:n={x:0,y:.5},r="right",l=1;break;case y:case x:n={x:1,y:.5},r="left",l=1}const{width:d,height:c}=e;n.x=n.x*d,n.y=n.y*c,_(o||r,e,a,!0);const g=t.PointHelper.getRotation(n,a,{x:n.x+(h?s.x:0),y:n.y+(l?s.y:0)});return h?h=-g:l=g,{origin:a,skewX:h,skewY:l}},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 S:t=y;break;case w:t=x;break;case O:t=k;break;case y:t=S;break;case x:t=w;break;case k:t=O}if(i)switch(t){case L:t=T;break;case w:t=O;break;case x:t=k;break;case T:t=L;break;case O:t=w;break;case k:t=x}return t}},R={};function P(e,i){const{enterPoint:s,dragging:o,skewing:r,resizing:n,flippedX:a,flippedY:h}=e;if(!s||!e.editor.editing||!e.canUse)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:l}=e;const{pointType:d}=s,{resizeCursor:c,rotateCursor:g,skewCursor:u,resizeable:f,rotateable:p,skewable:E}=e.mergeConfig;let m=d.includes("resize");m&&p&&(e.isHoldRotateKey(i)||!f)&&(m=!1);const v=E&&!m&&("resize-line"===s.name||"skew"===d),b=o?r?u:n?c:g:v?u:m?c:g;l+=45*(C.getFlipDirection(s.direction,a,h)+1),l=2*Math.round(t.MathHelper.formatRotation(l,!0)/2);const{url:w,x:L,y:x}=b,y=w+l;R[y]?s.cursor=R[y]:R[y]=s.cursor={url:D(w,l),x:L,y:x}}function H(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function D(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class V extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const A=["top","right","bottom","left"],I=void 0;class z extends t.Group{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.visible&&this.view.visible}get canGesture(){if(!this.canUse)return!1;const{moveable:e,resizeable:i,rotateable:s}=this.mergeConfig;return t.isString(e)||t.isString(i)||t.isString(s)}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new V({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}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 V({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new V({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),n.push(e),this.listenPointEvents(e,"resize",s)),i=new V({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...r,a,h,l,...n,...o),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:o,resizePoints:r}=this,{stroke:n,strokeWidth:a}=e,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;this.visible=!t.locked;for(let t=0;t<8;t++)d=r[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),d.rotation=(t-(t%2?1:0))/2*90;o.set(this.getPointStyle(e.circle||e.rotatePoint||h[0])),s.set(Object.assign({stroke:n,strokeWidth:a,editConfig:I},e.rect||{}));const c=i&&this.transformTool.editTool;s.hittable=!c,s.syncEventer=c&&this.editor,c&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),H(this)}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})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(e){const{editMask:i}=this.editor,{mergeConfig:s,single:o,rect:r,circle:n,buttons:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:f,editBox:p,mask:E,spread:m,hideRotatePoints:v,hideResizeLines:b}=s;if(i.visible=!!E||0,m&&t.BoundsHelper.spread(e,m),this.view.worldOpacity){const{width:i,height:E}=e,m=t.isNumber(f)?f:10,w=p&&!(f&&i<m&&E<m);let L,x,y,k={};for(let s=0;s<8;s++)t.AroundHelper.toPoint(t.AroundHelper.directionData[s],e,k),x=h[s],L=l[s],x.set(k),L.set(k),x.visible=w&&!(!g&&!u),L.visible=w&&u&&g&&!v,s%2&&(y=d[(s-1)/2],y.set(k),y.visible=x.visible&&!b,x.visible=L.visible=w&&!!c,(s+1)/2%2?(y.width=i,f&&2*x.width>i&&(x.visible=!1)):(y.height=E,f&&2*x.width>E&&(x.visible=!1)));n.visible=w&&u&&!(!s.circle&&!s.rotatePoint),n.visible&&this.layoutCircle(),r.path&&(r.path=null),r.set(Object.assign(Object.assign({},e),{visible:!o||p})),a.visible=w&&a.children.length>0||0,a.visible&&this.layoutButtons()}else r.set(e)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:o}=this.mergedConfig,r=A.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=A.indexOf(e);(a%2&&r||(a+1)%2&&n)&&i&&(a=(a+2)%4);const h=i?C.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",width:o,height:o,cornerRadius:r,offsetX:0,offsetY:0,editConfig:I};return t?Object.assign(n,t):n}getPointsStyle(){const{point:e}=this.mergedConfig;return t.isArray(e)?e:[e]}getMiddlePointsStyle(){const{middlePoint:e}=this.mergedConfig;return t.isArray(e)?e:e?[e]:this.getPointsStyle()}onDragStart(e){this.dragging=!0;const i=this.dragPoint=e.current,{pointType:s}=i,{editor:o,dragStartData:r}=this,{target:n}=this,{moveable:a,resizeable:h,rotateable:l,skewable:d,hideOnMove:c}=this.mergeConfig;"rect"===i.name?(a&&(this.moving=!0),o.opacity=c?0:1):(s.includes("rotate")||this.isHoldRotateKey(e)||!h?(l&&(this.rotating=!0),"resize-rotate"===s?h&&(this.resizing=!0):"resize-line"===i.name&&(d&&(this.skewing=!0),this.rotating=!1)):"resize"===s&&h&&(this.resizing=!0),"skew"===s&&d&&(this.skewing=!0)),r.x=e.x,r.y=e.y,r.point={x:n.x,y:n.y},r.bounds=Object.assign({},n.getLayoutBounds("box","local")),r.rotation=n.rotation,s&&s.includes("resize")&&(t.ResizeEvent.resizingKeys=o.leafList.keys)}onDragEnd(e){this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds&&this.transformTool.onMove(e),this.dragPoint=null,this.resetDoing();const{name:i,pointType:s}=e.current;"rect"===i&&(this.editor.opacity=1),s&&s.includes("resize")&&(t.ResizeEvent.resizingKeys=null)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:o,skewing:r}=this;if(i)e.onMove(t),H(this);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),P(this,t)}}resetDoing(){this.canUse&&(this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1)}onMove(e){this.canGesture&&"drag"!==e.moveType&&(e.stop(),t.isString(this.mergeConfig.moveable)&&(this.gesturing=this.moving=!0,this.transformTool.onMove(e)))}onMoveEnd(t){this.moving&&this.transformTool.onMove(t),this.resetDoing()}onScale(e){this.canGesture&&(e.stop(),t.isString(this.mergeConfig.resizeable)&&(this.gesturing=this.resizing=!0,this.transformTool.onScale(e)))}onRotate(e){this.canGesture&&(e.stop(),t.isString(this.mergeConfig.rotateable)&&(this.gesturing=this.rotating=!0,this.transformTool.onRotate(e)))}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){P(this,t)}onArrow(t){const{editor:e,transformTool:i}=this;if(this.canUse&&e.editing&&this.mergeConfig.keyEvent){let e=0,s=0;const o=t.shiftKey?10:1;switch(t.code){case"ArrowDown":s=o;break;case"ArrowUp":s=-o;break;case"ArrowLeft":e=-o;break;case"ArrowRight":e=o}(e||s)&&i.move(e,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(e){const{editor:i,target:s}=this;if(this.single){if(s.locked)return;if(s.isBranch&&!s.editInner){if(s.textBox){const{children:e}=s,o=e.find(e=>e.editable&&e instanceof t.Text)||e.find(e=>e instanceof t.Text);if(o)return i.openInnerEditor(o)}i.openGroup(s),i.target=i.selector.findDeepOne(e)}else i.openInnerEditor()}}listenPointEvents(t,i,s){t.direction=s,t.pointType=i;const o=[[e.DragEvent.START,this.onDragStart,this],[e.DragEvent.DRAG,this.onDrag,this],[e.DragEvent.END,this.onDragEnd,this],[e.PointerEvent.LEAVE,()=>{this.enterPoint=null}]];"circle"!==t.name&&o.push([e.PointerEvent.ENTER,e=>{this.enterPoint=t,P(this,e)}]),this.__eventIds.push(t.on_(o))}__listenEvents(){const{rect:t,editor:i,__eventIds:s}=this;s.push(t.on_([[e.DragEvent.START,this.onDragStart,this],[e.DragEvent.DRAG,this.onDrag,this],[e.DragEvent.END,this.onDragEnd,this],[e.PointerEvent.ENTER,()=>H(this)],[e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this],[e.PointerEvent.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{s.push(i.app.on_([[[e.KeyEvent.HOLD,e.KeyEvent.UP],this.onKey,this],[e.KeyEvent.DOWN,this.onArrow,this],[e.MoveEvent.BEFORE_MOVE,this.onMove,this,!0],[e.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0],[e.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0],[e.MoveEvent.END,this.onMoveEnd,this],[e.ZoomEvent.END,this.resetDoing,this],[e.RotateEvent.END,this.resetDoing,this]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const F={x:0,y:0,width:1e5,height:1e5};class Z extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,F),Object.assign(this.__world,F)}__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 G='\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"/>',W={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${G}\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${G}\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${G}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},U=new t.Bounds;function X(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{U.setListWithFn(i,t=>t.getBounds("box","page")),0===U.width&&(U.width=.1),0===U.height&&(U.height=.1),e.reset(U.get())}),s.add(e)}const Y=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),K=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),N={group(e,i,s){e.sort(K);const{app:o,parent:r}=e[0];let n;n=s&&s.add?s:new t.Group(s),r.addAt(n,r.children.indexOf(e[0])),e.sort(Y);const a=new t.Matrix(i.worldTransform);return a.divideParent(r.scrollWorldTransform),n.setTransform(a),n.editable=!0,n.hitChildren=!1,o.lockLayout(),e.forEach(t=>t.dropTo(n)),o.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(Y),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(K),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},j=t.Debug.get("EditToolCreator");function q(){return t=>{J.register(t)}}const $=q,J={list:{},register(t){const{tag:e}=t.prototype;Q[e]&&j.repeat(e),Q[e]=t},get:(t,e)=>new Q[t](e)},{list:Q}=J;class tt extends o{constructor(t,e){super(t,e)}}tt.BEFORE_OPEN="innerEditor.before_open",tt.OPEN="innerEditor.open",tt.BEFORE_CLOSE="innerEditor.before_close",tt.CLOSE="innerEditor.close";class et extends o{constructor(t,e){super(t,e)}}et.BEFORE_GROUP="editor.before_group",et.GROUP="editor.group",et.BEFORE_UNGROUP="editor.before_ungroup",et.UNGROUP="editor.ungroup",et.BEFORE_OPEN="editor.before_open_group",et.OPEN="editor.open_group",et.BEFORE_CLOSE="editor.before_close_group",et.CLOSE="editor.close_group";const{updateMatrix:it}=t.LeafHelper,st={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},ot="top-left";class rt extends t.Rect{get __tag(){return"SimulateElement"}constructor(e){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(t.PropertyEvent.CHANGE,i=>{if(this.checkChange&&st[i.attrName]){const{attrName:s,newValue:o,oldValue:r}=i,n="s"===s[0]?(o||1)/(r||1):(o||0)-(r||0);this.canChange=!1;const a=this.__;a[s]=r,it(this.parent),it(this);const h=new t.Matrix(this.__world);switch(a[s]=o,this.__layout.rotationChange(),it(this),this.changedTransform=new t.Matrix(this.__world).divide(h),s){case"x":e.move(n,0);break;case"y":e.move(0,n);break;case"rotation":e.rotateOf(ot,n);break;case"scaleX":e.scaleOf(ot,n,1);break;case"scaleY":e.scaleOf(ot,1,n);break;case"skewX":e.skewOf(ot,n,0);break;case"skewY":e.skewOf(ot,0,n)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class nt extends o{constructor(t,e){super(t,e)}}nt.BEFORE_MOVE="editor.before_move",nt.MOVE="editor.move";class at extends o{constructor(t,e){super(t,e)}}at.BEFORE_SCALE="editor.before_scale",at.SCALE="editor.scale";class ht extends o{constructor(t,e){super(t,e)}}ht.BEFORE_ROTATE="editor.before_rotate",ht.ROTATE="editor.rotate";class lt extends o{constructor(t,e){super(t,e)}}lt.BEFORE_SKEW="editor.before_skew",lt.SKEW="editor.skew";class dt{onMove(i){const{target:s,mergeConfig:o,dragStartData:r}=this.editBox;let n,{dragLimitAnimate:a}=o;const h=i.type===e.MoveEvent.END||i.type===e.DragEvent.END,l=t.isString(s.draggable),d=!a||h||l;if(i instanceof e.MoveEvent)n=i.getLocalMove(s),d&&e.DragEvent.limitMove(s,n);else{const t={x:i.totalX,y:i.totalY};i.shiftKey&&(Math.abs(t.x)>Math.abs(t.y)?t.y=0:t.x=0),n=e.DragEvent.getValidMove(s,r.point,t,d)}(n.x||n.y)&&(a&&!l&&h?t.LeafHelper.animateMove(this,n,t.isNumber(a)?a:.3):this.move(n))}onScale(t){const{target:i,mergeConfig:s,single:o,dragStartData:r}=this.editBox;let{around:n,lockRatio:a,flipable:h,editSize:l}=s;if(t instanceof e.ZoomEvent)this.scaleOf(i.getBoxPoint(t),t.scale,t.scale);else{const{direction:e}=t.current;(t.shiftKey||i.lockRatio)&&(a=!0);const s=C.getScaleData(i,r.bounds,e,t.getInnerTotal(i),a,C.getAround(n,t.altKey),h,!o||"scale"===l);this.editTool&&this.editTool.onScaleWithDrag?(s.drag=t,this.scaleWithDrag(s)):this.scaleOf(s.origin,s.scaleX,s.scaleY)}}onRotate(i){const{target:s,mergeConfig:o,dragStartData:r}=this.editBox,{around:n,rotateAround:a,rotateGap:h}=o,{direction:l}=i.current;let d,c;if(i instanceof e.RotateEvent)c=i.rotation,d=a?t.AroundHelper.getPoint(a,s.boxBounds):s.getBoxPoint(i);else{const t=C.getRotateData(s,l,i,r,i.shiftKey?null:a||s.around||s.origin||n||"center");c=r.rotation+t.rotation-s.rotation,d=t.origin}c=t.MathHelper.float(t.MathHelper.getGapRotation(c,h,s.rotation),2),c&&this.rotateOf(d,c)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:o,skewX:r,skewY:n}=C.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),C.getAround(s,t.altKey));(r||n)&&this.skewOf(o,r,n)}move(e,i=0){if(!this.checkTransform("moveable"))return;t.isObject(e)&&(i=e.y,e=e.x);const{target:s,mergeConfig:o,single:r,editor:n}=this.editBox,{beforeMove:a}=o;if(a){const o=a({target:s,x:e,y:i});if(t.isObject(o))e=o.x,i=o.y;else if(!1===o)return}const h=s.getWorldPointByLocal({x:e,y:i},null,!0);r||s.safeChange(()=>s.move(e,i));const l={target:s,editor:n,moveX:h.x,moveY:h.y};this.emitEvent(new nt(nt.BEFORE_MOVE,l));const d=new nt(nt.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 at(at.BEFORE_SCALE,t));const r=new at(at.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(e,i,s=i,o){if(!this.checkTransform("resizeable"))return;const{target:r,mergeConfig:n,single:a,editor:h}=this.editBox,{beforeScale:l}=n;if(l){const o=l({target:r,origin:e,scaleX:i,scaleY:s});if(t.isObject(o))i=o.scaleX,s=o.scaleY;else if(!1===o)return}const d=this.getWorldOrigin(e),c=!a&&this.getChangedTransform(()=>r.safeChange(()=>r.scaleOf(e,i,s))),g={target:r,editor:h,worldOrigin:d,scaleX:i,scaleY:s,transform:c};this.emitEvent(new at(at.BEFORE_SCALE,g));const u=new at(at.SCALE,g);this.doScale(u),this.emitEvent(u)}flip(e){if(!this.checkTransform("resizeable"))return;const{target:i,single:s,editor:o}=this.editBox,r=this.getWorldOrigin("center"),n=s?new t.Matrix(t.LeafHelper.getFlipTransform(i,e)):this.getChangedTransform(()=>i.safeChange(()=>i.flip(e))),a={target:i,editor:o,worldOrigin:r,scaleX:"x"===e?-1:1,scaleY:"y"===e?-1:1,transform:n};this.emitEvent(new at(at.BEFORE_SCALE,a));const h=new at(at.SCALE,a);this.doScale(h),this.emitEvent(h)}rotateOf(e,i){if(!this.checkTransform("rotateable"))return;const{target:s,mergeConfig:o,single:r,editor:n}=this.editBox,{beforeRotate:a}=o;if(a){const o=a({target:s,origin:e,rotation:i});if(t.isNumber(o))i=o;else if(!1===o)return}const h=this.getWorldOrigin(e),l=!r&&this.getChangedTransform(()=>s.safeChange(()=>s.rotateOf(e,i))),d={target:s,editor:n,worldOrigin:h,rotation:i,transform:l};this.emitEvent(new ht(ht.BEFORE_ROTATE,d));const c=new ht(ht.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(e,i,s=0,o){if(!this.checkTransform("skewable"))return;const{target:r,mergeConfig:n,single:a,editor:h}=this.editBox,{beforeSkew:l}=n;if(l){const o=l({target:r,origin:e,skewX:i,skewY:s});if(t.isObject(o))i=o.skewX,s=o.skewY;else if(!1===o)return}const d=this.getWorldOrigin(e),c=!a&&this.getChangedTransform(()=>r.safeChange(()=>r.skewOf(e,i,s))),g={target:r,editor:h,worldOrigin:d,skewX:i,skewY:s,transform:c};this.emitEvent(new lt(lt.BEFORE_SKEW,g));const u=new lt(lt.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(e){const{target:i}=this.editBox;return i.getWorldPoint(t.LeafHelper.getInnerOrigin(i,e))}getChangedTransform(e){const{target:i,single:s}=this.editBox;if(!s&&!i.canChange)return i.changedTransform;const o=new t.Matrix(i.worldTransform);return e(),new t.Matrix(i.worldTransform).divide(o)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}exports.Editor=class extends t.Group{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(e,i){super(i),this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new rt(this),this.editBox=new z(this),this.editToolList={},this.selector=new b(this),this.editMask=new Z(this),this.targetEventIds=[];let s=t.DataHelper.clone(W);e&&(s=t.DataHelper.default(e,s)),this.mergedConfig=this.config=s,this.addMany(this.editMask,this.selector,this.editBox),t.Plugin.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&X(this),this.update()}updateEditTool(){if(this.unloadEditTool(),this.editing){const e=this.element;let i=e.editOuter||"EditTool";const{beforeEditOuter:s}=this.mergeConfig;if(s){const o=s({target:e,name:i});if(t.isString(o))i=o;else if(!1===o)return}if(J.list[i]){const t=this.editTool=this.editToolList[i]=this.editToolList[i]||J.get(i,this);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=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(et.BEFORE_GROUP),this.target=N.group(this.list,this.element,t),this.emitGroupEvent(et.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(et.BEFORE_UNGROUP,t)),this.target=N.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(et.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(et.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(et.OPEN,t)}closeGroup(t){this.emitGroupEvent(et.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(et.CLOSE,t)}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach(e=>this.list.every(i=>!t.LeafHelper.hasParent(i,e))&&i.push(e))),i.forEach(t=>this.closeGroup(t))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new et(t,{editTarget:e});e&&e.syncEventer||this.emitEvent(i),e&&e.emitEvent(i)}openInnerEditor(e,i,s){let o;if(t.isString(i)?o=i:s||(s=i),e&&s&&(this.target=e),this.single){e||(e=this.element),o||(o=e.editInner);const{beforeEditInner:i}=this.mergeConfig;if(i){const s=i({target:e,name:o});if(t.isString(s))o=s;else if(!1===s)return}J.list[o]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[o]=this.editToolList[o]||J.get(o,this),this.innerEditor.editTarget=e,this.emitInnerEvent(tt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(tt.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(tt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(tt.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new tt(t,{editTarget:i,innerEditor:e});i.syncEventer||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&&(N.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(N.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:e,leafer:i,targetLeafer:s,editMask:o}=this;this.targetEventIds=[i.on_(t.RenderEvent.START,this.onRenderStart,this),s&&s.on_(t.PropertyEvent.SCROLL,this.onChildScroll,this),e.on_(t.RenderEvent.CHILD_START,this.onAppRenderStart,this),e.on_(t.LeaferEvent.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],o.visible&&o.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())}},i([(e,i)=>{t.defineKey(e,i,{get(){const{config:e,element:i,dragPoint:s,editBox:o,app:r}=this,n=Object.assign({},e);return i&&i.editConfig&&Object.assign(n,i.editConfig),o.config&&Object.assign(n,o.config),s&&(s.editConfig&&Object.assign(n,s.editConfig),"font-size"===n.editSize&&(n.lockRatio=!0),"resize-rotate"===s.pointType&&(n.around||(n.around="center"),t.isNull(n.lockRatio)&&(n.lockRatio=!0))),t.isUndefined(n.dragLimitAnimate)&&(n.dragLimitAnimate=r&&r.config.pointer.dragLimitAnimate),this.mergedConfig=n}})}],exports.Editor.prototype,"mergeConfig",void 0),i([r(function(t,e){t.emitEvent(new o(o.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],exports.Editor.prototype,"hoverTarget",void 0),i([r(function(e,i){const{target:s}=e;s?(e.leafList=s instanceof t.LeafList?s:new t.LeafList(s),e.multiple&&X(e)):(e.simulateTarget.remove(),e.leafList.reset()),e.closeInnerEditor(!0),e.unloadEditTool();const r={editor:e,value:s,oldValue:i};e.emitEvent(new o(o.SELECT,r)),e.checkOpenedGroups(),e.editing?e.waitLeafer(()=>{e.updateEditTool(),e.listenTargetEvents()}):(e.updateEditTool(),e.removeTargetEvents()),e.emitEvent(new o(o.AFTER_SELECT,r))})],exports.Editor.prototype,"target",void 0),exports.Editor=i([e.useModule(dt,["editBox","editTool","emitEvent"])],exports.Editor);class ct{static registerInnerEditor(){J.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this.editor.editBox}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,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)}}exports.EditTool=class extends ct{static registerEditTool(){J.register(this)}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):t.scaleOfWorld(o,e,i,n)}),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):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):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()}},exports.EditTool=i([q()],exports.EditTool);const{left:gt,right:ut}=t.Direction9,{move:ft,copy:pt,toNumberPoints:Et}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:s,lockRatio:o,around:r}=e,n=e.target,a=s===gt;if(n.pathInputed){const{path:t}=n.__,{from:e,to:s}=this.getFromToByPath(t);this.dragPoint(e,s,a,r,this.getInnerMove(n,i,o)),t[1]=e.x,t[2]=e.y,t[4]=s.x,t[5]=s.y,n.path=t}else if(n.points){const{points:t}=n,{from:e,to:s}=this.getFromToByPoints(t);this.dragPoint(e,s,a,r,this.getInnerMove(n,i,o)),t[0]=e.x,t[1]=e.y,t[2]=s.x,t[3]=s.y,n.points=t}else{const e=t.getPointData(),{toPoint:s}=n;n.rotation=0,this.dragPoint(e,s,a,r,this.getInnerMove(n,i,o)),n.getLocalPointByInner(e,null,null,!0),n.getLocalPointByInner(s,null,null,!0),n.x=e.x,n.y=e.y,n.getInnerPointByLocal(s,null,null,!0),n.toPoint=s}}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=Et(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?(ft(t,r,n),s&&ft(e,-r,-n)):(s&&ft(t,-r,-n),ft(e,r,n))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,r=this.editor.element;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),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),pt(s[7],i),pt(e[7],i),pt(s[3],a),pt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===gt||t===ut,s[t].visible=a,e[t].visible=!n&&a}},exports.LineEditTool=i([q()],exports.LineEditTool),t.Plugin.add("editor","resize"),t.Creator.editor=function(t,e){const i=new exports.Editor(t);return e&&e.sky.add(e.editor=i),i},t.Box.addAttr("textBox",!1,t.dataType),t.UI.addAttr("editConfig",void 0,t.dataType),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),t.dataType),t.UI.addAttr("editInner","PathEditor",t.dataType),t.Group.addAttr("editInner","",t.dataType),t.Text.addAttr("editInner","TextEditor",t.dataType),t.UI.setEditConfig=function(t){this.changeAttr("editConfig",t)},t.UI.setEditOuter=function(t){this.changeAttr("editOuter",t)},t.UI.setEditInner=function(t){this.changeAttr("editInner",t)},exports.EditBox=z,exports.EditDataHelper=C,exports.EditPoint=V,exports.EditSelect=b,exports.EditSelectHelper=p,exports.EditToolCreator=J,exports.EditorEvent=o,exports.EditorGroupEvent=et,exports.EditorHelper=N,exports.EditorMoveEvent=nt,exports.EditorRotateEvent=ht,exports.EditorScaleEvent=at,exports.EditorSkewEvent=lt,exports.InnerEditor=ct,exports.InnerEditorEvent=tt,exports.SelectArea=f,exports.Stroker=u,exports.TransformTool=dt,exports.registerEditTool=q,exports.registerInnerEditor=$;
|
|
2
2
|
//# sourceMappingURL=editor.min.cjs.map
|