@leafer-ui/draw 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/draw.cjs CHANGED
@@ -108,6 +108,12 @@ class UIData extends core.LeafData {
108
108
  return strokeWidth;
109
109
  }
110
110
  get __hasStroke() { return this.stroke && this.strokeWidth; }
111
+ get __hasMultiPaint() {
112
+ const t = this;
113
+ if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
114
+ return true;
115
+ return t.fill && this.__hasStroke;
116
+ }
111
117
  get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
112
118
  get __autoWidth() { return !this._width; }
113
119
  get __autoHeight() { return !this._height; }
@@ -477,9 +483,8 @@ const RectRender = {
477
483
  canvas.strokeRect(half, half, width, height);
478
484
  canvas.restore();
479
485
  }
480
- else {
486
+ else
481
487
  canvas.strokeRect(half, half, width, height);
482
- }
483
488
  break;
484
489
  case 'outside':
485
490
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -509,11 +514,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
509
514
  super(data);
510
515
  }
511
516
  reset(_data) { }
512
- set(data, isTemp) {
513
- if (isTemp) {
514
- this.lockNormalStyle = true;
515
- Object.assign(this, data);
516
- this.lockNormalStyle = false;
517
+ set(data, transition) {
518
+ if (transition) {
519
+ if (transition === 'temp') {
520
+ this.lockNormalStyle = true;
521
+ Object.assign(this, data);
522
+ this.lockNormalStyle = false;
523
+ }
524
+ else
525
+ this.animate(data, transition);
517
526
  }
518
527
  else
519
528
  Object.assign(this, data);
@@ -704,6 +713,15 @@ __decorate([
704
713
  __decorate([
705
714
  core.boundsType(0)
706
715
  ], exports.UI.prototype, "padding", void 0);
716
+ __decorate([
717
+ core.boundsType(false)
718
+ ], exports.UI.prototype, "lockRatio", void 0);
719
+ __decorate([
720
+ core.boundsType()
721
+ ], exports.UI.prototype, "widthRange", void 0);
722
+ __decorate([
723
+ core.boundsType()
724
+ ], exports.UI.prototype, "heightRange", void 0);
707
725
  __decorate([
708
726
  core.dataType(false)
709
727
  ], exports.UI.prototype, "draggable", void 0);
@@ -814,17 +832,17 @@ exports.Group = class Group extends exports.UI {
814
832
  if (!this.children)
815
833
  this.children = [];
816
834
  }
817
- set(data, isTemp) {
835
+ set(data, transition) {
818
836
  if (data.children) {
819
837
  const { children } = data;
820
838
  delete data.children;
821
839
  this.children ? this.clear() : this.__setBranch();
822
- super.set(data, isTemp);
840
+ super.set(data, transition);
823
841
  children.forEach(child => this.add(child));
824
842
  data.children = children;
825
843
  }
826
844
  else
827
- super.set(data, isTemp);
845
+ super.set(data, transition);
828
846
  }
829
847
  toJSON(options) {
830
848
  const data = super.toJSON(options);
@@ -937,8 +955,8 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
937
955
  }
938
956
  onInit() { }
939
957
  initType(_type) { }
940
- set(data) {
941
- this.waitInit(() => { super.set(data); });
958
+ set(data, transition) {
959
+ this.waitInit(() => { super.set(data, transition); });
942
960
  }
943
961
  start() {
944
962
  clearTimeout(this.__startTimer);
@@ -995,8 +1013,6 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
995
1013
  __onResize(event) {
996
1014
  this.emitEvent(event);
997
1015
  core.DataHelper.copyAttrs(this.__, event, core.canvasSizeAttrs);
998
- if (!event.width || !event.height)
999
- debug.warn('w = 0 or h = 0');
1000
1016
  setTimeout(() => { if (this.canvasManager)
1001
1017
  this.canvasManager.clearRecycled(); }, 0);
1002
1018
  }
@@ -1321,9 +1337,6 @@ __decorate([
1321
1337
  __decorate([
1322
1338
  core.dataType(false)
1323
1339
  ], exports.Box.prototype, "resizeChildren", void 0);
1324
- __decorate([
1325
- core.dataType(false)
1326
- ], exports.Box.prototype, "textBox", void 0);
1327
1340
  __decorate([
1328
1341
  core.affectRenderBoundsType('show')
1329
1342
  ], exports.Box.prototype, "overflow", void 0);
package/lib/draw.esm.js CHANGED
@@ -107,6 +107,12 @@ class UIData extends LeafData {
107
107
  return strokeWidth;
108
108
  }
109
109
  get __hasStroke() { return this.stroke && this.strokeWidth; }
110
+ get __hasMultiPaint() {
111
+ const t = this;
112
+ if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
113
+ return true;
114
+ return t.fill && this.__hasStroke;
115
+ }
110
116
  get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
111
117
  get __autoWidth() { return !this._width; }
112
118
  get __autoHeight() { return !this._height; }
@@ -476,9 +482,8 @@ const RectRender = {
476
482
  canvas.strokeRect(half, half, width, height);
477
483
  canvas.restore();
478
484
  }
479
- else {
485
+ else
480
486
  canvas.strokeRect(half, half, width, height);
481
- }
482
487
  break;
483
488
  case 'outside':
484
489
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -508,11 +513,15 @@ let UI = UI_1 = class UI extends Leaf {
508
513
  super(data);
509
514
  }
510
515
  reset(_data) { }
511
- set(data, isTemp) {
512
- if (isTemp) {
513
- this.lockNormalStyle = true;
514
- Object.assign(this, data);
515
- this.lockNormalStyle = false;
516
+ set(data, transition) {
517
+ if (transition) {
518
+ if (transition === 'temp') {
519
+ this.lockNormalStyle = true;
520
+ Object.assign(this, data);
521
+ this.lockNormalStyle = false;
522
+ }
523
+ else
524
+ this.animate(data, transition);
516
525
  }
517
526
  else
518
527
  Object.assign(this, data);
@@ -703,6 +712,15 @@ __decorate([
703
712
  __decorate([
704
713
  boundsType(0)
705
714
  ], UI.prototype, "padding", void 0);
715
+ __decorate([
716
+ boundsType(false)
717
+ ], UI.prototype, "lockRatio", void 0);
718
+ __decorate([
719
+ boundsType()
720
+ ], UI.prototype, "widthRange", void 0);
721
+ __decorate([
722
+ boundsType()
723
+ ], UI.prototype, "heightRange", void 0);
706
724
  __decorate([
707
725
  dataType(false)
708
726
  ], UI.prototype, "draggable", void 0);
@@ -813,17 +831,17 @@ let Group = class Group extends UI {
813
831
  if (!this.children)
814
832
  this.children = [];
815
833
  }
816
- set(data, isTemp) {
834
+ set(data, transition) {
817
835
  if (data.children) {
818
836
  const { children } = data;
819
837
  delete data.children;
820
838
  this.children ? this.clear() : this.__setBranch();
821
- super.set(data, isTemp);
839
+ super.set(data, transition);
822
840
  children.forEach(child => this.add(child));
823
841
  data.children = children;
824
842
  }
825
843
  else
826
- super.set(data, isTemp);
844
+ super.set(data, transition);
827
845
  }
828
846
  toJSON(options) {
829
847
  const data = super.toJSON(options);
@@ -936,8 +954,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
936
954
  }
937
955
  onInit() { }
938
956
  initType(_type) { }
939
- set(data) {
940
- this.waitInit(() => { super.set(data); });
957
+ set(data, transition) {
958
+ this.waitInit(() => { super.set(data, transition); });
941
959
  }
942
960
  start() {
943
961
  clearTimeout(this.__startTimer);
@@ -994,8 +1012,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
994
1012
  __onResize(event) {
995
1013
  this.emitEvent(event);
996
1014
  DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
997
- if (!event.width || !event.height)
998
- debug.warn('w = 0 or h = 0');
999
1015
  setTimeout(() => { if (this.canvasManager)
1000
1016
  this.canvasManager.clearRecycled(); }, 0);
1001
1017
  }
@@ -1320,9 +1336,6 @@ __decorate([
1320
1336
  __decorate([
1321
1337
  dataType(false)
1322
1338
  ], Box.prototype, "resizeChildren", void 0);
1323
- __decorate([
1324
- dataType(false)
1325
- ], Box.prototype, "textBox", void 0);
1326
1339
  __decorate([
1327
1340
  affectRenderBoundsType('show')
1328
1341
  ], Box.prototype, "overflow", void 0);
@@ -1 +1 @@
1
- import{decorateLeafAttr as t,attr as e,defineKey as i,needPlugin as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as A,useModule as P,rewriteAble as F,MathHelper as D,pen as I,PathCorner as E,PathDrawer as L,UICreator as W,registerUI as T,Branch as z,LeafList as M,ImageManager as O,DataHelper as N,Creator as V,CanvasManager as j,WaitHelper as H,LeaferEvent as Y,Bounds as U,ResizeEvent as X,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as q,affectRenderBoundsType as Q,BoundsHelper as Z,Platform as tt,PathCommandDataHelper as et,affectStrokeBoundsType as it,getPointData as st,PointHelper as ot,PathBounds as rt,ImageEvent as at,LeaferImage as nt,Matrix as _t,PathCreator as ht}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function pt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function lt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ut(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const ct={},yt={},gt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},vt={},ft={},wt={},xt={},mt={},Rt={},St={setStyleName:(t,e,i)=>s("state"),set:(t,e)=>s("state")},kt={list:{},register(t,e){kt.list[t]=e},get:t=>kt.list[t]},{parse:Bt,objectToCanvasData:bt}=a,Ct={},At=o.get("UIData");class Pt extends r{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __clipAfterFill(){return this.cornerRadius||this.__pathInputed}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,At.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,At.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ct)):(this.__isFills&&(this.__removeInput("fill"),wt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ct)):(this.__isStrokes&&(this.__removeInput("stroke"),wt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Bt(t):bt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t&&!1!==t.visible?[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t&&!1!==t.visible?[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ft.compute("fill",this.__leaf),e&&ft.compute("stroke",this.__leaf),this.__needComputePaint=!1}}class Ft extends Pt{}class Dt extends Ft{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return"hide"===this.overflow&&this.__clipAfterFill&&this.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class It extends Ft{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Et extends Dt{}class Lt extends Pt{}class Wt extends Pt{get __boxStroke(){return!this.__pathInputed}}class Tt extends Pt{get __boxStroke(){return!this.__pathInputed}}class zt extends Pt{}class Mt extends Pt{}class Ot extends Pt{get __pathInputed(){return 2}}class Nt extends Ft{}const Vt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class jt extends Pt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Vt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Yt extends Wt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Ut={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Gt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ft.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&mt.shadow(this,t,a),s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&mt.innerShadow(this,t,a),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t))}else i.__pathInputed?Gt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ft.fills(o,this,t):ft.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ft.strokes(r,this,t):ft.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Gt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ft.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ft.stroke(o,t,e)}const Jt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var $t;let Kt=$t=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?a.toCanvasData(i,!0):i}getPathString(t,e,i){return a.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Rt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&vt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?L.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s("animate")}killAnimate(t){}export(t,e){return Rt.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),$t.one(e)}static one(t,e,i,s,o){return W.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};dt([_(Pt)],Kt.prototype,"__",void 0),dt([ut()],Kt.prototype,"zoomLayer",void 0),dt([h("")],Kt.prototype,"id",void 0),dt([h("")],Kt.prototype,"name",void 0),dt([h("")],Kt.prototype,"className",void 0),dt([d("pass-through")],Kt.prototype,"blendMode",void 0),dt([p(1)],Kt.prototype,"opacity",void 0),dt([l(!0)],Kt.prototype,"visible",void 0),dt([d(!1)],Kt.prototype,"locked",void 0),dt([u(0)],Kt.prototype,"zIndex",void 0),dt([c(!1)],Kt.prototype,"mask",void 0),dt([y(!1)],Kt.prototype,"eraser",void 0),dt([g(0,!0)],Kt.prototype,"x",void 0),dt([g(0,!0)],Kt.prototype,"y",void 0),dt([v(100,!0)],Kt.prototype,"width",void 0),dt([v(100,!0)],Kt.prototype,"height",void 0),dt([f(1,!0)],Kt.prototype,"scaleX",void 0),dt([f(1,!0)],Kt.prototype,"scaleY",void 0),dt([w(0,!0)],Kt.prototype,"rotation",void 0),dt([w(0,!0)],Kt.prototype,"skewX",void 0),dt([w(0,!0)],Kt.prototype,"skewY",void 0),dt([g(0,!0)],Kt.prototype,"offsetX",void 0),dt([g(0,!0)],Kt.prototype,"offsetY",void 0),dt([g(0,!0)],Kt.prototype,"scrollX",void 0),dt([g(0,!0)],Kt.prototype,"scrollY",void 0),dt([x()],Kt.prototype,"origin",void 0),dt([x()],Kt.prototype,"around",void 0),dt([h(!1)],Kt.prototype,"lazy",void 0),dt([m(1)],Kt.prototype,"pixelRatio",void 0),dt([R()],Kt.prototype,"path",void 0),dt([S()],Kt.prototype,"windingRule",void 0),dt([S(!0)],Kt.prototype,"closed",void 0),dt([v(0)],Kt.prototype,"padding",void 0),dt([h(!1)],Kt.prototype,"draggable",void 0),dt([h()],Kt.prototype,"dragBounds",void 0),dt([h(!1)],Kt.prototype,"editable",void 0),dt([k(!0)],Kt.prototype,"hittable",void 0),dt([k("path")],Kt.prototype,"hitFill",void 0),dt([B("path")],Kt.prototype,"hitStroke",void 0),dt([k(!1)],Kt.prototype,"hitBox",void 0),dt([k(!0)],Kt.prototype,"hitChildren",void 0),dt([k(!0)],Kt.prototype,"hitSelf",void 0),dt([k()],Kt.prototype,"hitRadius",void 0),dt([b("")],Kt.prototype,"cursor",void 0),dt([d()],Kt.prototype,"fill",void 0),dt([B()],Kt.prototype,"stroke",void 0),dt([B("inside")],Kt.prototype,"strokeAlign",void 0),dt([B(1)],Kt.prototype,"strokeWidth",void 0),dt([B(!1)],Kt.prototype,"strokeWidthFixed",void 0),dt([B("none")],Kt.prototype,"strokeCap",void 0),dt([B("miter")],Kt.prototype,"strokeJoin",void 0),dt([B()],Kt.prototype,"dashPattern",void 0),dt([B()],Kt.prototype,"dashOffset",void 0),dt([B(10)],Kt.prototype,"miterLimit",void 0),dt([S(0)],Kt.prototype,"cornerRadius",void 0),dt([S()],Kt.prototype,"cornerSmoothing",void 0),dt([pt()],Kt.prototype,"shadow",void 0),dt([pt()],Kt.prototype,"innerShadow",void 0),dt([pt()],Kt.prototype,"blur",void 0),dt([pt()],Kt.prototype,"backgroundBlur",void 0),dt([pt()],Kt.prototype,"grayscale",void 0),dt([h({})],Kt.prototype,"data",void 0),dt([C(A.prototype.reset)],Kt.prototype,"reset",null),Kt=$t=dt([P(Ut),P(Xt),F()],Kt);let qt=class extends Kt{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Qt;dt([_(Ft)],qt.prototype,"__",void 0),qt=dt([P(z),T()],qt);const Zt=o.get("Leafer");let te=Qt=class extends qt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&N.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new j,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(Y.RESTART):this.emitLeafer(Y.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Y.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new X(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),t.width&&t.height||Zt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?(e||Zt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Y.BEFORE_READY),this.emitLeafer(Y.READY),this.emitLeafer(Y.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Y.VIEW_READY),H.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Y.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){return s("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Y(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(Y.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once($.END,(()=>this.__onReady())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(q.DATA,this.__onWatchData,this),this.on_(K.NEXT,this.__onNextRender,this),this.on_($.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Qt.list.remove(this);try{this.stop(),this.emitEvent(new Y(Y.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{O.clearRecycled()}),100)}catch(t){Zt.error(t)}}};t?e():setTimeout(e)}};te.list=new M,dt([_(It)],te.prototype,"__",void 0),dt([v()],te.prototype,"pixelRatio",void 0),te=Qt=dt([T()],te);let ee=class extends Kt{get __tag(){return"Rect"}constructor(t){super(t)}};dt([_(Wt)],ee.prototype,"__",void 0),ee=dt([P(Jt),F(),T()],ee);const{copy:ie,add:se,includes:oe}=Z,re=ee.prototype,ae=qt.prototype,ne={};let _e=class extends qt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ie(ne,e),this.__updateRectRenderBounds(),t=!oe(e,ne),t&&"hide"!==this.__.overflow&&se(e,ne)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([_(Dt)],_e.prototype,"__",void 0),dt([h(!1)],_e.prototype,"resizeChildren",void 0),dt([h(!1)],_e.prototype,"textBox",void 0),dt([Q("show")],_e.prototype,"overflow",void 0),dt([C(re.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([C(re.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([C(re.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([C(re.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([C(re.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([C(re.__updateChange)],_e.prototype,"__updateRectChange",null),dt([C(re.__render)],_e.prototype,"__renderRect",null),dt([C(ae.__render)],_e.prototype,"__renderGroup",null),_e=dt([F(),T()],_e);let he=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([_(Et)],he.prototype,"__",void 0),dt([d("#FFFFFF")],he.prototype,"fill",void 0),dt([Q("hide")],he.prototype,"overflow",void 0),he=dt([T()],he);const{moveTo:de,closePath:pe,ellipse:le}=et;let ue=class extends Kt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&le(n,r,a,r*i,a*i,0,s,o,!1),le(n,r,a,r,a,0,o,s,!0),i<1&&pe(n)):(i<1&&(le(n,r,a,r*i,a*i),de(n,t,a)),le(n,r,a,r,a,0,360,0,!0)),tt.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(de(n,r,a),le(n,r,a,r,a,0,s,o,!1),pe(n)):le(n,r,a,r,a)}};dt([_(Tt)],ue.prototype,"__",void 0),dt([S(0)],ue.prototype,"innerRadius",void 0),dt([S(0)],ue.prototype,"startAngle",void 0),dt([S(0)],ue.prototype,"endAngle",void 0),ue=dt([T()],ue);const{moveTo:ce,lineTo:ye,drawPoints:ge}=et,{rotate:ve,getAngle:fe,getDistance:we,defaultPoint:xe}=ot,{toBounds:me}=rt;let Re=class extends Kt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=st();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=we(xe,t),this.rotation=fe(xe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ge(e,t.points,!1,t.closed):(ce(e,0,0),ye(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ge(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&vt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?me(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([_(Lt)],Re.prototype,"__",void 0),dt([it("center")],Re.prototype,"strokeAlign",void 0),dt([v(0)],Re.prototype,"height",void 0),dt([S()],Re.prototype,"points",void 0),dt([S(0)],Re.prototype,"curve",void 0),dt([S(!1)],Re.prototype,"closed",void 0),Re=dt([T()],Re);const{sin:Se,cos:ke,PI:Be}=Math,{moveTo:be,lineTo:Ce,closePath:Ae,drawPoints:Pe}=et,Fe=Re.prototype;let De=class extends Kt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Pe(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;be(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Se(2*e*Be/s),r-r*ke(2*e*Be/s))}Ae(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([_(zt)],De.prototype,"__",void 0),dt([S(3)],De.prototype,"sides",void 0),dt([S()],De.prototype,"points",void 0),dt([S(0)],De.prototype,"curve",void 0),dt([C(Fe.__updateRenderPath)],De.prototype,"__updateRenderPath",null),dt([C(Fe.__updateBoxBounds)],De.prototype,"__updateBoxBounds",null),De=dt([F(),T()],De);const{sin:Ie,cos:Ee,PI:Le}=Math,{moveTo:We,lineTo:Te,closePath:ze}=et;let Me=class extends Kt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)Te(a,o+(t%2==0?o:o*s)*Ie(t*Le/i),r-(t%2==0?r:r*s)*Ee(t*Le/i));ze(a)}};dt([_(Mt)],Me.prototype,"__",void 0),dt([S(5)],Me.prototype,"corners",void 0),dt([S(.382)],Me.prototype,"innerRadius",void 0),Me=dt([T()],Me);let Oe=class extends ee{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(at.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([_(Ht)],Oe.prototype,"__",void 0),dt([v("")],Oe.prototype,"url",void 0),Oe=dt([T()],Oe);const Ne=Oe;let Ve=class extends ee{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new nt({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new at(at.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new _t(t.worldTransform).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([_(Yt)],Ve.prototype,"__",void 0),dt([lt(100)],Ve.prototype,"width",void 0),dt([lt(100)],Ve.prototype,"height",void 0),dt([lt(1)],Ve.prototype,"pixelRatio",void 0),dt([lt(!0)],Ve.prototype,"smooth",void 0),dt([lt()],Ve.prototype,"contextSettings",void 0),Ve=dt([T()],Ve);const{copyAndSpread:je,includes:He,isSame:Ye,spread:Ue,setList:Xe}=Z;let Ge=class extends Kt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=gt.number(e,o),t.__letterSpacing=gt.number(i,o),t.__padding=h?D.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=ct.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(t.__lineHeight<i&&Ue(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=He(_,n)?_:n;Ye(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,Xe(t.__textBoxBounds={},[_,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){je(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([_(jt)],Ge.prototype,"__",void 0),dt([v(0)],Ge.prototype,"width",void 0),dt([v(0)],Ge.prototype,"height",void 0),dt([h(!1)],Ge.prototype,"resizeFontSize",void 0),dt([d("#000000")],Ge.prototype,"fill",void 0),dt([it("outside")],Ge.prototype,"strokeAlign",void 0),dt([k("all")],Ge.prototype,"hitFill",void 0),dt([v("")],Ge.prototype,"text",void 0),dt([v("L")],Ge.prototype,"fontFamily",void 0),dt([v(12)],Ge.prototype,"fontSize",void 0),dt([v("normal")],Ge.prototype,"fontWeight",void 0),dt([v(!1)],Ge.prototype,"italic",void 0),dt([v("none")],Ge.prototype,"textCase",void 0),dt([v("none")],Ge.prototype,"textDecoration",void 0),dt([v(0)],Ge.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],Ge.prototype,"lineHeight",void 0),dt([v(0)],Ge.prototype,"paraIndent",void 0),dt([v(0)],Ge.prototype,"paraSpacing",void 0),dt([v("left")],Ge.prototype,"textAlign",void 0),dt([v("top")],Ge.prototype,"verticalAlign",void 0),dt([v(!0)],Ge.prototype,"autoSizeAlign",void 0),dt([v("normal")],Ge.prototype,"textWrap",void 0),dt([v("show")],Ge.prototype,"textOverflow",void 0),Ge=dt([T()],Ge);let Je=class extends Kt{get __tag(){return"Path"}constructor(t){super(t)}};dt([_(Ot)],Je.prototype,"__",void 0),dt([it("center")],Je.prototype,"strokeAlign",void 0),Je=dt([T()],Je);let $e=class extends qt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([_(Nt)],$e.prototype,"__",void 0),dt([(t,e)=>{i(t,e,{get(){return this.__path}})}],$e.prototype,"path",void 0),$e=dt([P(ht,["set","path","paint"]),T()],$e);export{_e as Box,Dt as BoxData,Ve as Canvas,Yt as CanvasData,yt as ColorConvert,mt as Effect,ue as Ellipse,Tt as EllipseData,Rt as Export,he as Frame,Et as FrameData,qt as Group,Ft as GroupData,Oe as Image,Ht as ImageData,te as Leafer,It as LeaferData,Re as Line,Lt as LineData,Ne as MyImage,ft as Paint,xt as PaintGradient,wt as PaintImage,Je as Path,vt as PathArrow,Ot as PathData,$e as Pen,Nt as PenData,De as Polygon,zt as PolygonData,ee as Rect,Wt as RectData,Jt as RectRender,Me as Star,Mt as StarData,St as State,Ge as Text,ct as TextConvert,jt as TextData,kt as Transition,Kt as UI,Ut as UIBounds,Pt as UIData,Xt as UIRender,gt as UnitConvert,pt as effectType,lt as resizeType,ut as zoomLayerType};
1
+ import{decorateLeafAttr as t,attr as e,defineKey as i,needPlugin as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as m,naturalBoundsType as x,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as A,useModule as P,rewriteAble as F,MathHelper as D,pen as I,PathCorner as E,PathDrawer as L,UICreator as W,registerUI as T,Branch as z,LeafList as M,ImageManager as O,DataHelper as N,Creator as V,CanvasManager as j,WaitHelper as H,LeaferEvent as Y,Bounds as U,ResizeEvent as X,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as q,affectRenderBoundsType as Q,BoundsHelper as Z,Platform as tt,PathCommandDataHelper as et,affectStrokeBoundsType as it,getPointData as st,PointHelper as ot,PathBounds as rt,ImageEvent as at,LeaferImage as nt,Matrix as _t,PathCreator as ht}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function pt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function lt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ut(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const ct={},yt={},gt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},vt={},ft={},wt={},mt={},xt={},Rt={},St={setStyleName:(t,e,i)=>s("state"),set:(t,e)=>s("state")},kt={list:{},register(t,e){kt.list[t]=e},get:t=>kt.list[t]},{parse:Bt,objectToCanvasData:bt}=a,Ct={},At=o.get("UIData");class Pt extends r{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){return this.cornerRadius||this.__pathInputed}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,At.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,At.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ct)):(this.__isFills&&(this.__removeInput("fill"),wt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ct)):(this.__isStrokes&&(this.__removeInput("stroke"),wt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Bt(t):bt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t&&!1!==t.visible?[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t&&!1!==t.visible?[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ft.compute("fill",this.__leaf),e&&ft.compute("stroke",this.__leaf),this.__needComputePaint=!1}}class Ft extends Pt{}class Dt extends Ft{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return"hide"===this.overflow&&this.__clipAfterFill&&this.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class It extends Ft{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Et extends Dt{}class Lt extends Pt{}class Wt extends Pt{get __boxStroke(){return!this.__pathInputed}}class Tt extends Pt{get __boxStroke(){return!this.__pathInputed}}class zt extends Pt{}class Mt extends Pt{}class Ot extends Pt{get __pathInputed(){return 2}}class Nt extends Ft{}const Vt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class jt extends Pt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Vt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Yt extends Wt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Ut={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Gt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ft.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&xt.shadow(this,t,a),s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&xt.innerShadow(this,t,a),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t))}else i.__pathInputed?Gt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ft.fills(o,this,t):ft.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ft.strokes(r,this,t):ft.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Gt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ft.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ft.stroke(o,t,e)}const Jt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var $t;let Kt=$t=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?a.toCanvasData(i,!0):i}getPathString(t,e,i){return a.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Rt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&vt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?L.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s("animate")}killAnimate(t){}export(t,e){return Rt.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),$t.one(e)}static one(t,e,i,s,o){return W.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};dt([_(Pt)],Kt.prototype,"__",void 0),dt([ut()],Kt.prototype,"zoomLayer",void 0),dt([h("")],Kt.prototype,"id",void 0),dt([h("")],Kt.prototype,"name",void 0),dt([h("")],Kt.prototype,"className",void 0),dt([d("pass-through")],Kt.prototype,"blendMode",void 0),dt([p(1)],Kt.prototype,"opacity",void 0),dt([l(!0)],Kt.prototype,"visible",void 0),dt([d(!1)],Kt.prototype,"locked",void 0),dt([u(0)],Kt.prototype,"zIndex",void 0),dt([c(!1)],Kt.prototype,"mask",void 0),dt([y(!1)],Kt.prototype,"eraser",void 0),dt([g(0,!0)],Kt.prototype,"x",void 0),dt([g(0,!0)],Kt.prototype,"y",void 0),dt([v(100,!0)],Kt.prototype,"width",void 0),dt([v(100,!0)],Kt.prototype,"height",void 0),dt([f(1,!0)],Kt.prototype,"scaleX",void 0),dt([f(1,!0)],Kt.prototype,"scaleY",void 0),dt([w(0,!0)],Kt.prototype,"rotation",void 0),dt([w(0,!0)],Kt.prototype,"skewX",void 0),dt([w(0,!0)],Kt.prototype,"skewY",void 0),dt([g(0,!0)],Kt.prototype,"offsetX",void 0),dt([g(0,!0)],Kt.prototype,"offsetY",void 0),dt([g(0,!0)],Kt.prototype,"scrollX",void 0),dt([g(0,!0)],Kt.prototype,"scrollY",void 0),dt([m()],Kt.prototype,"origin",void 0),dt([m()],Kt.prototype,"around",void 0),dt([h(!1)],Kt.prototype,"lazy",void 0),dt([x(1)],Kt.prototype,"pixelRatio",void 0),dt([R()],Kt.prototype,"path",void 0),dt([S()],Kt.prototype,"windingRule",void 0),dt([S(!0)],Kt.prototype,"closed",void 0),dt([v(0)],Kt.prototype,"padding",void 0),dt([v(!1)],Kt.prototype,"lockRatio",void 0),dt([v()],Kt.prototype,"widthRange",void 0),dt([v()],Kt.prototype,"heightRange",void 0),dt([h(!1)],Kt.prototype,"draggable",void 0),dt([h()],Kt.prototype,"dragBounds",void 0),dt([h(!1)],Kt.prototype,"editable",void 0),dt([k(!0)],Kt.prototype,"hittable",void 0),dt([k("path")],Kt.prototype,"hitFill",void 0),dt([B("path")],Kt.prototype,"hitStroke",void 0),dt([k(!1)],Kt.prototype,"hitBox",void 0),dt([k(!0)],Kt.prototype,"hitChildren",void 0),dt([k(!0)],Kt.prototype,"hitSelf",void 0),dt([k()],Kt.prototype,"hitRadius",void 0),dt([b("")],Kt.prototype,"cursor",void 0),dt([d()],Kt.prototype,"fill",void 0),dt([B()],Kt.prototype,"stroke",void 0),dt([B("inside")],Kt.prototype,"strokeAlign",void 0),dt([B(1)],Kt.prototype,"strokeWidth",void 0),dt([B(!1)],Kt.prototype,"strokeWidthFixed",void 0),dt([B("none")],Kt.prototype,"strokeCap",void 0),dt([B("miter")],Kt.prototype,"strokeJoin",void 0),dt([B()],Kt.prototype,"dashPattern",void 0),dt([B()],Kt.prototype,"dashOffset",void 0),dt([B(10)],Kt.prototype,"miterLimit",void 0),dt([S(0)],Kt.prototype,"cornerRadius",void 0),dt([S()],Kt.prototype,"cornerSmoothing",void 0),dt([pt()],Kt.prototype,"shadow",void 0),dt([pt()],Kt.prototype,"innerShadow",void 0),dt([pt()],Kt.prototype,"blur",void 0),dt([pt()],Kt.prototype,"backgroundBlur",void 0),dt([pt()],Kt.prototype,"grayscale",void 0),dt([h({})],Kt.prototype,"data",void 0),dt([C(A.prototype.reset)],Kt.prototype,"reset",null),Kt=$t=dt([P(Ut),P(Xt),F()],Kt);let qt=class extends Kt{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Qt;dt([_(Ft)],qt.prototype,"__",void 0),qt=dt([P(z),T()],qt);const Zt=o.get("Leafer");let te=Qt=class extends qt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&N.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new j,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(Y.RESTART):this.emitLeafer(Y.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Y.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new X(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?(e||Zt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Y.BEFORE_READY),this.emitLeafer(Y.READY),this.emitLeafer(Y.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Y.VIEW_READY),H.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Y.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){return s("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Y(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(Y.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once($.END,(()=>this.__onReady())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(q.DATA,this.__onWatchData,this),this.on_(K.NEXT,this.__onNextRender,this),this.on_($.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Qt.list.remove(this);try{this.stop(),this.emitEvent(new Y(Y.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{O.clearRecycled()}),100)}catch(t){Zt.error(t)}}};t?e():setTimeout(e)}};te.list=new M,dt([_(It)],te.prototype,"__",void 0),dt([v()],te.prototype,"pixelRatio",void 0),te=Qt=dt([T()],te);let ee=class extends Kt{get __tag(){return"Rect"}constructor(t){super(t)}};dt([_(Wt)],ee.prototype,"__",void 0),ee=dt([P(Jt),F(),T()],ee);const{copy:ie,add:se,includes:oe}=Z,re=ee.prototype,ae=qt.prototype,ne={};let _e=class extends qt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ie(ne,e),this.__updateRectRenderBounds(),t=!oe(e,ne),t&&"hide"!==this.__.overflow&&se(e,ne)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([_(Dt)],_e.prototype,"__",void 0),dt([h(!1)],_e.prototype,"resizeChildren",void 0),dt([Q("show")],_e.prototype,"overflow",void 0),dt([C(re.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([C(re.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([C(re.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([C(re.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([C(re.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([C(re.__updateChange)],_e.prototype,"__updateRectChange",null),dt([C(re.__render)],_e.prototype,"__renderRect",null),dt([C(ae.__render)],_e.prototype,"__renderGroup",null),_e=dt([F(),T()],_e);let he=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([_(Et)],he.prototype,"__",void 0),dt([d("#FFFFFF")],he.prototype,"fill",void 0),dt([Q("hide")],he.prototype,"overflow",void 0),he=dt([T()],he);const{moveTo:de,closePath:pe,ellipse:le}=et;let ue=class extends Kt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&le(n,r,a,r*i,a*i,0,s,o,!1),le(n,r,a,r,a,0,o,s,!0),i<1&&pe(n)):(i<1&&(le(n,r,a,r*i,a*i),de(n,t,a)),le(n,r,a,r,a,0,360,0,!0)),tt.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(de(n,r,a),le(n,r,a,r,a,0,s,o,!1),pe(n)):le(n,r,a,r,a)}};dt([_(Tt)],ue.prototype,"__",void 0),dt([S(0)],ue.prototype,"innerRadius",void 0),dt([S(0)],ue.prototype,"startAngle",void 0),dt([S(0)],ue.prototype,"endAngle",void 0),ue=dt([T()],ue);const{moveTo:ce,lineTo:ye,drawPoints:ge}=et,{rotate:ve,getAngle:fe,getDistance:we,defaultPoint:me}=ot,{toBounds:xe}=rt;let Re=class extends Kt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=st();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=we(me,t),this.rotation=fe(me,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ge(e,t.points,!1,t.closed):(ce(e,0,0),ye(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ge(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&vt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?xe(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([_(Lt)],Re.prototype,"__",void 0),dt([it("center")],Re.prototype,"strokeAlign",void 0),dt([v(0)],Re.prototype,"height",void 0),dt([S()],Re.prototype,"points",void 0),dt([S(0)],Re.prototype,"curve",void 0),dt([S(!1)],Re.prototype,"closed",void 0),Re=dt([T()],Re);const{sin:Se,cos:ke,PI:Be}=Math,{moveTo:be,lineTo:Ce,closePath:Ae,drawPoints:Pe}=et,Fe=Re.prototype;let De=class extends Kt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Pe(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;be(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Se(2*e*Be/s),r-r*ke(2*e*Be/s))}Ae(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([_(zt)],De.prototype,"__",void 0),dt([S(3)],De.prototype,"sides",void 0),dt([S()],De.prototype,"points",void 0),dt([S(0)],De.prototype,"curve",void 0),dt([C(Fe.__updateRenderPath)],De.prototype,"__updateRenderPath",null),dt([C(Fe.__updateBoxBounds)],De.prototype,"__updateBoxBounds",null),De=dt([F(),T()],De);const{sin:Ie,cos:Ee,PI:Le}=Math,{moveTo:We,lineTo:Te,closePath:ze}=et;let Me=class extends Kt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)Te(a,o+(t%2==0?o:o*s)*Ie(t*Le/i),r-(t%2==0?r:r*s)*Ee(t*Le/i));ze(a)}};dt([_(Mt)],Me.prototype,"__",void 0),dt([S(5)],Me.prototype,"corners",void 0),dt([S(.382)],Me.prototype,"innerRadius",void 0),Me=dt([T()],Me);let Oe=class extends ee{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(at.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([_(Ht)],Oe.prototype,"__",void 0),dt([v("")],Oe.prototype,"url",void 0),Oe=dt([T()],Oe);const Ne=Oe;let Ve=class extends ee{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new nt({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new at(at.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new _t(t.worldTransform).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([_(Yt)],Ve.prototype,"__",void 0),dt([lt(100)],Ve.prototype,"width",void 0),dt([lt(100)],Ve.prototype,"height",void 0),dt([lt(1)],Ve.prototype,"pixelRatio",void 0),dt([lt(!0)],Ve.prototype,"smooth",void 0),dt([lt()],Ve.prototype,"contextSettings",void 0),Ve=dt([T()],Ve);const{copyAndSpread:je,includes:He,isSame:Ye,spread:Ue,setList:Xe}=Z;let Ge=class extends Kt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=gt.number(e,o),t.__letterSpacing=gt.number(i,o),t.__padding=h?D.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=ct.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(t.__lineHeight<i&&Ue(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=He(_,n)?_:n;Ye(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,Xe(t.__textBoxBounds={},[_,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){je(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([_(jt)],Ge.prototype,"__",void 0),dt([v(0)],Ge.prototype,"width",void 0),dt([v(0)],Ge.prototype,"height",void 0),dt([h(!1)],Ge.prototype,"resizeFontSize",void 0),dt([d("#000000")],Ge.prototype,"fill",void 0),dt([it("outside")],Ge.prototype,"strokeAlign",void 0),dt([k("all")],Ge.prototype,"hitFill",void 0),dt([v("")],Ge.prototype,"text",void 0),dt([v("L")],Ge.prototype,"fontFamily",void 0),dt([v(12)],Ge.prototype,"fontSize",void 0),dt([v("normal")],Ge.prototype,"fontWeight",void 0),dt([v(!1)],Ge.prototype,"italic",void 0),dt([v("none")],Ge.prototype,"textCase",void 0),dt([v("none")],Ge.prototype,"textDecoration",void 0),dt([v(0)],Ge.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],Ge.prototype,"lineHeight",void 0),dt([v(0)],Ge.prototype,"paraIndent",void 0),dt([v(0)],Ge.prototype,"paraSpacing",void 0),dt([v("left")],Ge.prototype,"textAlign",void 0),dt([v("top")],Ge.prototype,"verticalAlign",void 0),dt([v(!0)],Ge.prototype,"autoSizeAlign",void 0),dt([v("normal")],Ge.prototype,"textWrap",void 0),dt([v("show")],Ge.prototype,"textOverflow",void 0),Ge=dt([T()],Ge);let Je=class extends Kt{get __tag(){return"Path"}constructor(t){super(t)}};dt([_(Ot)],Je.prototype,"__",void 0),dt([it("center")],Je.prototype,"strokeAlign",void 0),Je=dt([T()],Je);let $e=class extends qt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([_(Nt)],$e.prototype,"__",void 0),dt([(t,e)=>{i(t,e,{get(){return this.__path}})}],$e.prototype,"path",void 0),$e=dt([P(ht,["set","path","paint"]),T()],$e);export{_e as Box,Dt as BoxData,Ve as Canvas,Yt as CanvasData,yt as ColorConvert,xt as Effect,ue as Ellipse,Tt as EllipseData,Rt as Export,he as Frame,Et as FrameData,qt as Group,Ft as GroupData,Oe as Image,Ht as ImageData,te as Leafer,It as LeaferData,Re as Line,Lt as LineData,Ne as MyImage,ft as Paint,mt as PaintGradient,wt as PaintImage,Je as Path,vt as PathArrow,Ot as PathData,$e as Pen,Nt as PenData,De as Polygon,zt as PolygonData,ee as Rect,Wt as RectData,Jt as RectRender,Me as Star,Mt as StarData,St as State,Ge as Text,ct as TextConvert,jt as TextData,kt as Transition,Kt as UI,Ut as UIBounds,Pt as UIData,Xt as UIRender,gt as UnitConvert,pt as effectType,lt as resizeType,ut as zoomLayerType};
package/lib/draw.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function r(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function o(){return(e,s)=>{const r="_"+s;t.defineKey(e,s,{set(t){this.isLeafer&&(this[r]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[r]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const i={},a={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},n={},p={},h={},_={},d={},l={setStyleName:(e,s,r)=>t.needPlugin("state"),set:(e,s)=>t.needPlugin("state")},u={list:{},register(t,e){u.list[t]=e},get:t=>u.list[t]},{parse:c,objectToCanvasData:y}=t.PathConvert,x={},g=t.Debug.get("UIData");class v extends t.LeafData{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:s}=e.__nowWorld||e.__world;return s<0&&(s=-s),s>1?t/s:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __clipAfterFill(){return this.cornerRadius||this.__pathInputed}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,g.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,g.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=x)):(this.__isFills&&(this.__removeInput("fill"),h.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=x)):(this.__isStrokes&&(this.__removeInput("stroke"),h.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?c(t):y(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t&&!1!==t.visible?[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t&&!1!==t.visible?[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&p.compute("fill",this.__leaf),e&&p.compute("stroke",this.__leaf),this.__needComputePaint=!1}}class f extends v{}class w extends f{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return"hide"===this.overflow&&this.__clipAfterFill&&this.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class m extends f{__getInputData(e,s){const r=super.__getInputData(e,s);return t.canvasSizeAttrs.forEach((t=>delete r[t])),r}}class T extends w{}class I extends v{}class R extends v{get __boxStroke(){return!this.__pathInputed}}class P extends v{get __boxStroke(){return!this.__pathInputed}}class S extends v{}class B extends v{}class b extends v{get __pathInputed(){return 2}}class C extends f{}const k={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class U extends v{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=k[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class A extends R{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const s=super.__getInputData(t,e);return delete s.fill,s}}class L extends R{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const s=super.__getInputData(t,e);return s.url=this.__leaf.canvas.toDataURL("image/png"),s}}const D={__updateStrokeSpread(){let t=0,e=0;const s=this.__,{strokeAlign:r,strokeWidth:o}=s;if((s.stroke||"all"===s.hitStroke)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!s.__boxStroke)){const e=s.__isLinePath?0:10*t,r="none"===s.strokeCap?0:o;t+=Math.max(e,r)}return s.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t+(this.__layout.strokeSpread||0)}},E={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:i}=s;if(this.__drawRenderPath(t),s.__useEffect){const a=p.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:h}=s;n&&_.shadow(this,t,a),r&&(s.__isFills?p.fills(r,this,t):p.fill(r,this,t)),i&&this.__drawAfterFill(t,e),h&&_.innerShadow(this,t,a),o&&(s.__isStrokes?p.strokes(o,this,t):p.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else r&&(s.__isFills?p.fills(r,this,t):p.fill(r,this,t)),i&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?p.strokes(o,this,t):p.stroke(o,this,t))}else s.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,s,r){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:i}=this.__;this.__drawRenderPath(t),o&&!s&&(this.__.__pixelFill?p.fills(o,this,t):p.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),i&&!r&&(this.__.__pixelStroke?p.strokes(i,this,t):p.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function F(t,e,s){const{fill:r,stroke:o,__drawAfterFill:i}=t.__;t.__drawRenderPath(e),r&&p.fill(r,t,e),i&&t.__drawAfterFill(e,s),o&&p.stroke(o,t,e)}const W={__drawFast(t,e){let{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(i,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,s,r);break;case"inside":s-=a,r-=a,s<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,s,r),t.restore()):t.strokeRect(n,n,s,r);break;case"outside":t.strokeRect(-n,-n,s+a,r+a)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(e){t.MathHelper.assignScale(this,e)}get scale(){return this.__.scale}get pen(){const{path:e}=this.__;return t.pen.set(this.path=e||[]),e||this.__drawPathByBox(t.pen),t.pen}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;return r||(t.pen.set(r=[]),this.__drawPathByBox(t.pen)),e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s,r){return t.PathConvert.stringify(this.getPath(e,s),r)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||d.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&n.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,s,r,o,"number"==typeof i?[i]:i)}else t.rect(e,s,r,o)}animate(e,s,r,o){return t.needPlugin("animate")}killAnimate(t){}export(t,e){return d.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),z.one(e)}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([o()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.visibleType(!0)],exports.UI.prototype,"visible",void 0),e([t.surfaceType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([s()],exports.UI.prototype,"shadow",void 0),e([s()],exports.UI.prototype,"innerShadow",void 0),e([s()],exports.UI.prototype,"blur",void 0),e([s()],exports.UI.prototype,"backgroundBlur",void 0),e([s()],exports.UI.prototype,"grayscale",void 0),e([t.dataType({})],exports.UI.prototype,"data",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(D),t.useModule(E),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:s}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),s.forEach((t=>this.add(t))),t.children=s}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const O=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type);const i=this.canvas=t.Creator.canvas(o);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o,s),this.view=i.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(i),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(e){const{canvas:s}=this;if(!s||s.isSameSize(e))return;const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,r))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),e.width&&e.height||O.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e,s){s||(e.width&&e.height||(this.autoLayout=new t.AutoBounds(e)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){return this.canvas&&(t.canvasSizeAttrs.includes(e)?(s||O.warn(e+" is 0"),this.__changeCanvasSize(e,s)):"fill"===e?this.__changeFill(s):"hittable"===e?this.parent||(this.canvas.hittable=s):"zIndex"===e&&(this.canvas.zIndex=s,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,s){e&&(t=t.bind(e));const r=this.__nextRenderWait;if(s){for(let e=0;e<r.length;e++)if(r[e]===t){r.splice(e,1);break}}else r.push(t)}zoom(e,s,r){return t.needPlugin("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.START,(()=>this.updateLazyBounds())),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(e){const s=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){O.error(t)}}};e?s():setTimeout(s)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(m)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const{copy:H,add:N,includes:j}=t.BoundsHelper,G=exports.Rect.prototype,V=exports.Group.prototype,Y={};exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),H(Y,e),this.__updateRectRenderBounds(),t=!j(e,Y),t&&"hide"!==this.__.overflow&&N(e,Y)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.dataType(!1)],exports.Box.prototype,"resizeChildren",void 0),e([t.dataType(!1)],exports.Box.prototype,"textBox",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(G.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(G.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(G.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(G.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(G.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(G.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(G.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(V.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(T)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:X,closePath:J,ellipse:K}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&K(p,a,n,a*r,n*r,0,o,i,!1),K(p,a,n,a,n,0,i,o,!0),r<1&&J(p)):(r<1&&(K(p,a,n,a*r,n*r),X(p,e,n)),K(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(X(p,a,n),K(p,a,n,a,n,0,o,i,!1),J(p)):K(p,a,n,a,n)}},e([t.dataProcessor(P)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:$,lineTo:q,drawPoints:Q}=t.PathCommandDataHelper,{rotate:Z,getAngle:tt,getDistance:et,defaultPoint:st}=t.PointHelper,{toBounds:rt}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&Z(r,s),r}set toPoint(t){this.width=et(st,t),this.rotation=tt(st,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Q(e,t.points,!1,t.closed):($(e,0,0),q(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Q(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&n.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?rt(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(I)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:ot,cos:it,PI:at}=Math,{moveTo:nt,lineTo:pt,closePath:ht,drawPoints:_t}=t.PathCommandDataHelper,dt=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)_t(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;nt(t,o,0);for(let e=1;e<r;e++)pt(t,o+o*ot(2*e*at/r),i-i*it(2*e*at/r))}ht(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(S)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(dt.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(dt.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:lt,cos:ut,PI:ct}=Math,{moveTo:yt,lineTo:xt,closePath:gt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];yt(a,o,0);for(let t=1;t<2*s;t++)xt(a,o+(t%2==0?o:o*r)*lt(t*ct/s),i-(t%2==0?i:i*r)*ut(t*ct/s));gt(a)}},e([t.dataProcessor(B)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image);const vt=exports.Image;exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,e&&e.url&&this.drawImage(e.url)}drawImage(e){new t.LeaferImage({url:e}).load((e=>{this.context.drawImage(e.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:e}))}))}draw(e,s,r,o){const i=new t.Matrix(e.worldTransform).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:s,height:r}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,s,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([r(100)],exports.Canvas.prototype,"width",void 0),e([r(100)],exports.Canvas.prototype,"height",void 0),e([r(1)],exports.Canvas.prototype,"pixelRatio",void 0),e([r(!0)],exports.Canvas.prototype,"smooth",void 0),e([r()],exports.Canvas.prototype,"contextSettings",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ft,includes:wt,isSame:mt,spread:Tt,setList:It}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:s,__baseLine:r,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-r,o.width,e<s?s:e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const e=this.__,{lineHeight:s,letterSpacing:r,fontFamily:o,fontSize:n,fontWeight:p,italic:h,textCase:_,textOverflow:d,padding:l}=e;e.__lineHeight=a.number(s,n),e.__letterSpacing=a.number(r,n),e.__padding=l?t.MathHelper.fourNumber(l):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*n)/2,e.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==p?p+" ":""}${n}px ${o}`,e.__clipText="show"!==d&&!e.__autoSize,e.__textDrawData=i.getDrawData(e.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:s,italic:r,padding:o,__autoWidth:i,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,p=e.boxBounds;if(t.__lineHeight<s&&Tt(n,s/2),i||a){if(p.x=i?n.x:0,p.y=a?n.y:0,p.width=i?n.width:t.width,p.height=a?n.height:t.height,o){const[e,s,r,o]=t.__padding;i&&(p.x-=o,p.width+=s+o),a&&(p.y-=e,p.height+=r+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();r&&(p.width+=.16*s);const h=wt(p,n)?p:n;mt(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,It(t.__textBoxBounds={},[p,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ft(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(U)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.dataType(!1)],exports.Text.prototype,"resizeFontSize",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:1.5})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType(!0)],exports.Text.prototype,"autoSizeAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}},e([t.dataProcessor(b)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},e([t.dataProcessor(C)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","path","paint"]),t.registerUI()],exports.Pen),exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=_,exports.EllipseData=P,exports.Export=d,exports.FrameData=T,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=m,exports.LineData=I,exports.MyImage=vt,exports.Paint=p,exports.PaintGradient={},exports.PaintImage=h,exports.PathArrow=n,exports.PathData=b,exports.PenData=C,exports.PolygonData=S,exports.RectData=R,exports.RectRender=W,exports.StarData=B,exports.State=l,exports.TextConvert=i,exports.TextData=U,exports.Transition=u,exports.UIBounds=D,exports.UIData=v,exports.UIRender=E,exports.UnitConvert=a,exports.effectType=s,exports.resizeType=r,exports.zoomLayerType=o,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function r(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function o(){return(e,s)=>{const r="_"+s;t.defineKey(e,s,{set(t){this.isLeafer&&(this[r]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[r]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const i={},a={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},n={},p={},h={},_={},d={},l={setStyleName:(e,s,r)=>t.needPlugin("state"),set:(e,s)=>t.needPlugin("state")},u={list:{},register(t,e){u.list[t]=e},get:t=>u.list[t]},{parse:c,objectToCanvasData:y}=t.PathConvert,x={},g=t.Debug.get("UIData");class v extends t.LeafData{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:s}=e.__nowWorld||e.__world;return s<0&&(s=-s),s>1?t/s:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){return this.cornerRadius||this.__pathInputed}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,g.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,g.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=x)):(this.__isFills&&(this.__removeInput("fill"),h.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=x)):(this.__isStrokes&&(this.__removeInput("stroke"),h.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?c(t):y(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t&&!1!==t.visible?[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t&&!1!==t.visible?[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&p.compute("fill",this.__leaf),e&&p.compute("stroke",this.__leaf),this.__needComputePaint=!1}}class f extends v{}class w extends f{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return"hide"===this.overflow&&this.__clipAfterFill&&this.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class m extends f{__getInputData(e,s){const r=super.__getInputData(e,s);return t.canvasSizeAttrs.forEach((t=>delete r[t])),r}}class T extends w{}class I extends v{}class R extends v{get __boxStroke(){return!this.__pathInputed}}class P extends v{get __boxStroke(){return!this.__pathInputed}}class S extends v{}class b extends v{}class B extends v{get __pathInputed(){return 2}}class k extends f{}const C={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class U extends v{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=C[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class A extends R{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const s=super.__getInputData(t,e);return delete s.fill,s}}class L extends R{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const s=super.__getInputData(t,e);return s.url=this.__leaf.canvas.toDataURL("image/png"),s}}const E={__updateStrokeSpread(){let t=0,e=0;const s=this.__,{strokeAlign:r,strokeWidth:o}=s;if((s.stroke||"all"===s.hitStroke)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!s.__boxStroke)){const e=s.__isLinePath?0:10*t,r="none"===s.strokeCap?0:o;t+=Math.max(e,r)}return s.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t+(this.__layout.strokeSpread||0)}},D={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:i}=s;if(this.__drawRenderPath(t),s.__useEffect){const a=p.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:h}=s;n&&_.shadow(this,t,a),r&&(s.__isFills?p.fills(r,this,t):p.fill(r,this,t)),i&&this.__drawAfterFill(t,e),h&&_.innerShadow(this,t,a),o&&(s.__isStrokes?p.strokes(o,this,t):p.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else r&&(s.__isFills?p.fills(r,this,t):p.fill(r,this,t)),i&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?p.strokes(o,this,t):p.stroke(o,this,t))}else s.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,s,r){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:i}=this.__;this.__drawRenderPath(t),o&&!s&&(this.__.__pixelFill?p.fills(o,this,t):p.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),i&&!r&&(this.__.__pixelStroke?p.strokes(i,this,t):p.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function F(t,e,s){const{fill:r,stroke:o,__drawAfterFill:i}=t.__;t.__drawRenderPath(e),r&&p.fill(r,t,e),i&&t.__drawAfterFill(e,s),o&&p.stroke(o,t,e)}const W={__drawFast(t,e){let{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(i,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,s,r);break;case"inside":s-=a,r-=a,s<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,s,r),t.restore()):t.strokeRect(n,n,s,r);break;case"outside":t.strokeRect(-n,-n,s+a,r+a)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(e){t.MathHelper.assignScale(this,e)}get scale(){return this.__.scale}get pen(){const{path:e}=this.__;return t.pen.set(this.path=e||[]),e||this.__drawPathByBox(t.pen),t.pen}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;return r||(t.pen.set(r=[]),this.__drawPathByBox(t.pen)),e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s,r){return t.PathConvert.stringify(this.getPath(e,s),r)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||d.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&n.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,s,r,o,"number"==typeof i?[i]:i)}else t.rect(e,s,r,o)}animate(e,s,r,o){return t.needPlugin("animate")}killAnimate(t){}export(t,e){return d.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),z.one(e)}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([o()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.visibleType(!0)],exports.UI.prototype,"visible",void 0),e([t.surfaceType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.boundsType(!1)],exports.UI.prototype,"lockRatio",void 0),e([t.boundsType()],exports.UI.prototype,"widthRange",void 0),e([t.boundsType()],exports.UI.prototype,"heightRange",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([s()],exports.UI.prototype,"shadow",void 0),e([s()],exports.UI.prototype,"innerShadow",void 0),e([s()],exports.UI.prototype,"blur",void 0),e([s()],exports.UI.prototype,"backgroundBlur",void 0),e([s()],exports.UI.prototype,"grayscale",void 0),e([t.dataType({})],exports.UI.prototype,"data",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(E),t.useModule(D),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:s}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),s.forEach((t=>this.add(t))),t.children=s}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const O=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type);const i=this.canvas=t.Creator.canvas(o);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o,s),this.view=i.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(i),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(e){const{canvas:s}=this;if(!s||s.isSameSize(e))return;const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,r))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e,s){s||(e.width&&e.height||(this.autoLayout=new t.AutoBounds(e)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){return this.canvas&&(t.canvasSizeAttrs.includes(e)?(s||O.warn(e+" is 0"),this.__changeCanvasSize(e,s)):"fill"===e?this.__changeFill(s):"hittable"===e?this.parent||(this.canvas.hittable=s):"zIndex"===e&&(this.canvas.zIndex=s,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,s){e&&(t=t.bind(e));const r=this.__nextRenderWait;if(s){for(let e=0;e<r.length;e++)if(r[e]===t){r.splice(e,1);break}}else r.push(t)}zoom(e,s,r){return t.needPlugin("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.START,(()=>this.updateLazyBounds())),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(e){const s=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){O.error(t)}}};e?s():setTimeout(s)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(m)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const{copy:H,add:N,includes:j}=t.BoundsHelper,G=exports.Rect.prototype,V=exports.Group.prototype,Y={};exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),H(Y,e),this.__updateRectRenderBounds(),t=!j(e,Y),t&&"hide"!==this.__.overflow&&N(e,Y)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.dataType(!1)],exports.Box.prototype,"resizeChildren",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(G.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(G.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(G.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(G.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(G.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(G.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(G.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(V.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(T)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:X,closePath:J,ellipse:K}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&K(p,a,n,a*r,n*r,0,o,i,!1),K(p,a,n,a,n,0,i,o,!0),r<1&&J(p)):(r<1&&(K(p,a,n,a*r,n*r),X(p,e,n)),K(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(X(p,a,n),K(p,a,n,a,n,0,o,i,!1),J(p)):K(p,a,n,a,n)}},e([t.dataProcessor(P)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:$,lineTo:q,drawPoints:Q}=t.PathCommandDataHelper,{rotate:Z,getAngle:tt,getDistance:et,defaultPoint:st}=t.PointHelper,{toBounds:rt}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&Z(r,s),r}set toPoint(t){this.width=et(st,t),this.rotation=tt(st,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Q(e,t.points,!1,t.closed):($(e,0,0),q(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Q(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&n.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?rt(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(I)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:ot,cos:it,PI:at}=Math,{moveTo:nt,lineTo:pt,closePath:ht,drawPoints:_t}=t.PathCommandDataHelper,dt=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)_t(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;nt(t,o,0);for(let e=1;e<r;e++)pt(t,o+o*ot(2*e*at/r),i-i*it(2*e*at/r))}ht(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(S)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(dt.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(dt.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:lt,cos:ut,PI:ct}=Math,{moveTo:yt,lineTo:xt,closePath:gt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];yt(a,o,0);for(let t=1;t<2*s;t++)xt(a,o+(t%2==0?o:o*r)*lt(t*ct/s),i-(t%2==0?i:i*r)*ut(t*ct/s));gt(a)}},e([t.dataProcessor(b)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image);const vt=exports.Image;exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,e&&e.url&&this.drawImage(e.url)}drawImage(e){new t.LeaferImage({url:e}).load((e=>{this.context.drawImage(e.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:e}))}))}draw(e,s,r,o){const i=new t.Matrix(e.worldTransform).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:s,height:r}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,s,r)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([r(100)],exports.Canvas.prototype,"width",void 0),e([r(100)],exports.Canvas.prototype,"height",void 0),e([r(1)],exports.Canvas.prototype,"pixelRatio",void 0),e([r(!0)],exports.Canvas.prototype,"smooth",void 0),e([r()],exports.Canvas.prototype,"contextSettings",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ft,includes:wt,isSame:mt,spread:Tt,setList:It}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:s,__baseLine:r,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-r,o.width,e<s?s:e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const e=this.__,{lineHeight:s,letterSpacing:r,fontFamily:o,fontSize:n,fontWeight:p,italic:h,textCase:_,textOverflow:d,padding:l}=e;e.__lineHeight=a.number(s,n),e.__letterSpacing=a.number(r,n),e.__padding=l?t.MathHelper.fourNumber(l):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*n)/2,e.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==p?p+" ":""}${n}px ${o}`,e.__clipText="show"!==d&&!e.__autoSize,e.__textDrawData=i.getDrawData(e.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:s,italic:r,padding:o,__autoWidth:i,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,p=e.boxBounds;if(t.__lineHeight<s&&Tt(n,s/2),i||a){if(p.x=i?n.x:0,p.y=a?n.y:0,p.width=i?n.width:t.width,p.height=a?n.height:t.height,o){const[e,s,r,o]=t.__padding;i&&(p.x-=o,p.width+=s+o),a&&(p.y-=e,p.height+=r+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();r&&(p.width+=.16*s);const h=wt(p,n)?p:n;mt(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,It(t.__textBoxBounds={},[p,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ft(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(U)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.dataType(!1)],exports.Text.prototype,"resizeFontSize",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:1.5})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType(!0)],exports.Text.prototype,"autoSizeAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}},e([t.dataProcessor(B)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},e([t.dataProcessor(k)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","path","paint"]),t.registerUI()],exports.Pen),exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=_,exports.EllipseData=P,exports.Export=d,exports.FrameData=T,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=m,exports.LineData=I,exports.MyImage=vt,exports.Paint=p,exports.PaintGradient={},exports.PaintImage=h,exports.PathArrow=n,exports.PathData=B,exports.PenData=k,exports.PolygonData=S,exports.RectData=R,exports.RectRender=W,exports.StarData=b,exports.State=l,exports.TextConvert=i,exports.TextData=U,exports.Transition=u,exports.UIBounds=E,exports.UIData=v,exports.UIRender=D,exports.UnitConvert=a,exports.effectType=s,exports.resizeType=r,exports.zoomLayerType=o,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/draw",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "@leafer-ui/draw",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -29,10 +29,10 @@
29
29
  "leaferjs"
30
30
  ],
31
31
  "dependencies": {
32
- "@leafer/core": "1.0.9",
33
- "@leafer-ui/display": "1.0.9",
34
- "@leafer-ui/display-module": "1.0.9",
35
- "@leafer-ui/decorator": "1.0.9",
36
- "@leafer-ui/external": "1.0.9"
32
+ "@leafer/core": "1.1.0",
33
+ "@leafer-ui/display": "1.1.0",
34
+ "@leafer-ui/display-module": "1.1.0",
35
+ "@leafer-ui/decorator": "1.1.0",
36
+ "@leafer-ui/external": "1.1.0"
37
37
  }
38
38
  }