@leafer-ui/draw 1.0.0 → 1.0.1

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
@@ -985,7 +985,7 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
985
985
  this.__controllers.push(this.renderer = core.Creator.renderer(this, canvas, config), this.watcher = core.Creator.watcher(this, config), this.layouter = core.Creator.layouter(this, config));
986
986
  if (this.isApp)
987
987
  this.__setApp();
988
- this.__checkAutoLayout(config);
988
+ this.__checkAutoLayout(config, parentApp);
989
989
  this.view = canvas.view;
990
990
  if (parentApp) {
991
991
  this.__bindApp(parentApp);
@@ -1086,9 +1086,10 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
1086
1086
  this.leafer = leafer;
1087
1087
  this.__level = 1;
1088
1088
  }
1089
- __checkAutoLayout(config) {
1090
- if (!config.width || !config.height) {
1091
- this.autoLayout = new core.AutoBounds(config);
1089
+ __checkAutoLayout(config, parentApp) {
1090
+ if (!parentApp) {
1091
+ if (!config.width || !config.height)
1092
+ this.autoLayout = new core.AutoBounds(config);
1092
1093
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
1093
1094
  }
1094
1095
  }
@@ -1223,7 +1224,9 @@ exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
1223
1224
  list.push(item);
1224
1225
  }
1225
1226
  }
1226
- zoom(_zoomType, _padding, _fixedScale) { return undefined; }
1227
+ zoom(_zoomType, _padding, _fixedScale) {
1228
+ return debug.error('need @leafer-in/view');
1229
+ }
1227
1230
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
1228
1231
  getValidScale(changeScale) { return changeScale; }
1229
1232
  getWorldPointByClient(clientPoint, updateClient) {
@@ -1750,8 +1753,7 @@ exports.Canvas = class Canvas extends exports.Rect {
1750
1753
  destroy() {
1751
1754
  if (this.canvas) {
1752
1755
  this.canvas.destroy();
1753
- this.canvas = null;
1754
- this.context = null;
1756
+ this.canvas = this.context = null;
1755
1757
  }
1756
1758
  super.destroy();
1757
1759
  }
package/lib/draw.esm.js CHANGED
@@ -984,7 +984,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
984
984
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
985
985
  if (this.isApp)
986
986
  this.__setApp();
987
- this.__checkAutoLayout(config);
987
+ this.__checkAutoLayout(config, parentApp);
988
988
  this.view = canvas.view;
989
989
  if (parentApp) {
990
990
  this.__bindApp(parentApp);
@@ -1085,9 +1085,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1085
1085
  this.leafer = leafer;
1086
1086
  this.__level = 1;
1087
1087
  }
1088
- __checkAutoLayout(config) {
1089
- if (!config.width || !config.height) {
1090
- this.autoLayout = new AutoBounds(config);
1088
+ __checkAutoLayout(config, parentApp) {
1089
+ if (!parentApp) {
1090
+ if (!config.width || !config.height)
1091
+ this.autoLayout = new AutoBounds(config);
1091
1092
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
1092
1093
  }
1093
1094
  }
@@ -1222,7 +1223,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1222
1223
  list.push(item);
1223
1224
  }
1224
1225
  }
1225
- zoom(_zoomType, _padding, _fixedScale) { return undefined; }
1226
+ zoom(_zoomType, _padding, _fixedScale) {
1227
+ return debug.error('need @leafer-in/view');
1228
+ }
1226
1229
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
1227
1230
  getValidScale(changeScale) { return changeScale; }
1228
1231
  getWorldPointByClient(clientPoint, updateClient) {
@@ -1749,8 +1752,7 @@ let Canvas = class Canvas extends Rect {
1749
1752
  destroy() {
1750
1753
  if (this.canvas) {
1751
1754
  this.canvas.destroy();
1752
- this.canvas = null;
1753
- this.context = null;
1755
+ this.canvas = this.context = null;
1754
1756
  }
1755
1757
  super.destroy();
1756
1758
  }
@@ -1 +1 @@
1
- import{decorateLeafAttr as t,attr as e,doStrokeType as i,defineKey as s,Debug as o,LeafData as r,PathConvert as a,dataProcessor as n,dataType as _,surfaceType as h,opacityType as d,visibleType as p,sortType as l,maskType as u,eraserType as c,positionType as y,boundsType as v,scaleType as g,rotationType as f,autoLayoutType as w,naturalBoundsType as x,pathInputType as m,pathType as R,hitType as S,strokeType as B,cursorType as k,rewrite as b,Leaf as A,useModule as C,rewriteAble as P,pen as F,PathCorner as E,PathDrawer as L,UICreator as I,registerUI as W,Branch as D,LeafList as T,ImageManager as z,DataHelper as M,Creator as O,CanvasManager as N,WaitHelper as H,LeaferEvent as V,canvasSizeAttrs as Y,Bounds as X,ResizeEvent as U,AutoBounds as j,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,affectRenderBoundsType as q,BoundsHelper as Q,Platform as Z,PathCommandDataHelper as tt,affectStrokeBoundsType as et,getPointData as it,PointHelper as st,PathBounds as ot,ImageEvent as rt,Matrix as at,MathHelper as nt,PathCreator as _t}from"@leafer/core";export*from"@leafer/core";function ht(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const dt={},pt={},lt={},ut={},ct={},yt={},vt={},gt={},ft={};function wt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>{ft.setStyle&&ft.setStyle(this,t+"Style",e)}))}})))}function xt(s){return t(s,(t=>e({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,i(this)}}})))}function mt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Rt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function St(){return(t,e)=>{const i="_"+e;s(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:Bt}=a,kt={},bt=o.get("UIData");class At extends r{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,bt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,bt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=kt)):(this.__isFills&&(this.__removeInput("fill"),ct.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=kt)):(this.__isStrokes&&(this.__removeInput("stroke"),ct.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=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?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ut.compute("fill",this.__leaf),e&&ut.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Ct={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class Pt extends At{}class Ft extends Pt{get __boxStroke(){return!this.__pathInputed}}class Et extends Pt{}class Lt extends Ft{}class It extends At{}class Wt extends At{get __boxStroke(){return!this.__pathInputed}}class Dt extends At{get __boxStroke(){return!this.__pathInputed}}class Tt extends At{}class zt extends At{}class Mt extends At{}class Ot extends Pt{}const Nt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ht extends At{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Nt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Vt extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Yt extends Wt{}const Xt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Ut={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){jt(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=ut.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&vt.shadow(this,t,a),s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&vt.innerShadow(this,t,a),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t))}else i.__pathInputed?jt(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?ut.fills(o,this,t):ut.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ut.strokes(r,this,t):ut.stroke("#000000",this,t))}}};function jt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ut.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ut.stroke(o,t,e)}const Gt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Jt;let $t=Jt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:t}=this.__;return F.set(this.path=t||[]),t||this.__drawPathByBox(F),F}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(F.set(i=[]),this.__drawPathByBox(F)),t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||gt.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&&lt.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)}export(t,e){return gt.export(this,t,e)}clone(){return Jt.one(this.toJSON())}static one(t,e,i,s,o){return I.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){W()(this)}static registerData(t){n(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}};ht([n(At)],$t.prototype,"__",void 0),ht([St()],$t.prototype,"zoomLayer",void 0),ht([_("")],$t.prototype,"id",void 0),ht([_("")],$t.prototype,"name",void 0),ht([_("")],$t.prototype,"className",void 0),ht([h("pass-through")],$t.prototype,"blendMode",void 0),ht([d(1)],$t.prototype,"opacity",void 0),ht([p(!0)],$t.prototype,"visible",void 0),ht([wt(!1)],$t.prototype,"selected",void 0),ht([wt(!1)],$t.prototype,"disabled",void 0),ht([h(!1)],$t.prototype,"locked",void 0),ht([l(0)],$t.prototype,"zIndex",void 0),ht([u(!1)],$t.prototype,"mask",void 0),ht([c(!1)],$t.prototype,"eraser",void 0),ht([y(0,!0)],$t.prototype,"x",void 0),ht([y(0,!0)],$t.prototype,"y",void 0),ht([v(100,!0)],$t.prototype,"width",void 0),ht([v(100,!0)],$t.prototype,"height",void 0),ht([g(1,!0)],$t.prototype,"scaleX",void 0),ht([g(1,!0)],$t.prototype,"scaleY",void 0),ht([f(0,!0)],$t.prototype,"rotation",void 0),ht([f(0,!0)],$t.prototype,"skewX",void 0),ht([f(0,!0)],$t.prototype,"skewY",void 0),ht([y(0,!0)],$t.prototype,"offsetX",void 0),ht([y(0,!0)],$t.prototype,"offsetY",void 0),ht([y(0,!0)],$t.prototype,"scrollX",void 0),ht([y(0,!0)],$t.prototype,"scrollY",void 0),ht([w()],$t.prototype,"origin",void 0),ht([w()],$t.prototype,"around",void 0),ht([_(!1)],$t.prototype,"lazy",void 0),ht([x(1)],$t.prototype,"pixelRatio",void 0),ht([m()],$t.prototype,"path",void 0),ht([R()],$t.prototype,"windingRule",void 0),ht([R(!0)],$t.prototype,"closed",void 0),ht([w(!1)],$t.prototype,"flow",void 0),ht([v(0)],$t.prototype,"padding",void 0),ht([v(0)],$t.prototype,"gap",void 0),ht([v("top-left")],$t.prototype,"flowAlign",void 0),ht([v(!1)],$t.prototype,"flowWrap",void 0),ht([v("box")],$t.prototype,"itemBox",void 0),ht([v(!0)],$t.prototype,"inFlow",void 0),ht([v()],$t.prototype,"autoWidth",void 0),ht([v()],$t.prototype,"autoHeight",void 0),ht([v()],$t.prototype,"lockRatio",void 0),ht([v()],$t.prototype,"autoBox",void 0),ht([v()],$t.prototype,"widthRange",void 0),ht([v()],$t.prototype,"heightRange",void 0),ht([_(!1)],$t.prototype,"draggable",void 0),ht([_()],$t.prototype,"dragBounds",void 0),ht([_(!1)],$t.prototype,"editable",void 0),ht([S(!0)],$t.prototype,"hittable",void 0),ht([S("path")],$t.prototype,"hitFill",void 0),ht([B("path")],$t.prototype,"hitStroke",void 0),ht([S(!1)],$t.prototype,"hitBox",void 0),ht([S(!0)],$t.prototype,"hitChildren",void 0),ht([S(!0)],$t.prototype,"hitSelf",void 0),ht([S()],$t.prototype,"hitRadius",void 0),ht([k("")],$t.prototype,"cursor",void 0),ht([h()],$t.prototype,"fill",void 0),ht([B()],$t.prototype,"stroke",void 0),ht([B("inside")],$t.prototype,"strokeAlign",void 0),ht([B(1)],$t.prototype,"strokeWidth",void 0),ht([B(!1)],$t.prototype,"strokeWidthFixed",void 0),ht([B("none")],$t.prototype,"strokeCap",void 0),ht([B("miter")],$t.prototype,"strokeJoin",void 0),ht([B()],$t.prototype,"dashPattern",void 0),ht([B()],$t.prototype,"dashOffset",void 0),ht([B(10)],$t.prototype,"miterLimit",void 0),ht([xt("none")],$t.prototype,"startArrow",void 0),ht([xt("none")],$t.prototype,"endArrow",void 0),ht([R(0)],$t.prototype,"cornerRadius",void 0),ht([R()],$t.prototype,"cornerSmoothing",void 0),ht([mt()],$t.prototype,"shadow",void 0),ht([mt()],$t.prototype,"innerShadow",void 0),ht([mt()],$t.prototype,"blur",void 0),ht([mt()],$t.prototype,"backgroundBlur",void 0),ht([mt()],$t.prototype,"grayscale",void 0),ht([_()],$t.prototype,"normalStyle",void 0),ht([_()],$t.prototype,"hoverStyle",void 0),ht([_()],$t.prototype,"pressStyle",void 0),ht([_()],$t.prototype,"focusStyle",void 0),ht([_()],$t.prototype,"selectedStyle",void 0),ht([_()],$t.prototype,"disabledStyle",void 0),ht([_({})],$t.prototype,"data",void 0),ht([b(A.prototype.reset)],$t.prototype,"reset",null),$t=Jt=ht([C(Xt),C(Ut),P()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:I.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var qt;ht([n(Pt)],Kt.prototype,"__",void 0),Kt=ht([C(D),W()],Kt);const Qt=o.get("Leafer");let Zt=qt=class extends Kt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&z.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&&M.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=O.canvas(s);this.__controllers.push(this.renderer=O.renderer(this,o,s),this.watcher=O.watcher(this,s),this.layouter=O.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=O.selector(this),this.interaction=O.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=O.hitCanvasManager()),this.canvasManager=new N,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(V.RESTART):this.emitLeafer(V.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(V.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=M.copyAttrs({},t,Y);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=M.copyAttrs({},this.canvas,Y);e.resize(t),this.updateLazyBounds(),this.__onResize(new U(t,i))}__onResize(t){this.emitEvent(t),M.copyAttrs(this.__,t,Y),t.width&&t.height||Qt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new j(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Y.includes(t)?(e||Qt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Y.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=M.copyAttrs({},this.canvas,Y);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(V.BEFORE_READY),this.emitLeafer(V.READY),this.emitLeafer(V.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(V.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(V.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){}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new V(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(V.START,(()=>G.end(t))),this.once(J.START,(()=>this.updateLazyBounds())),this.once(J.END,(()=>this.__onReady())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_($.NEXT,this.__onNextRender,this),this.on_(J.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){qt.list.remove(this);try{this.stop(),this.emitEvent(new V(V.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((()=>{z.clearRecycled()}),100)}catch(t){Qt.error(t)}}};t?e():setTimeout(e)}};Zt.list=new T,ht([n(Et)],Zt.prototype,"__",void 0),ht([v()],Zt.prototype,"pixelRatio",void 0),Zt=qt=ht([W()],Zt);let te=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};ht([n(Wt)],te.prototype,"__",void 0),te=ht([C(Gt),P(),W()],te);const ee=te.prototype,ie=Kt.prototype,se={},{copy:oe,add:re,includes:ae}=Q;let ne=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(this.children.length){if(t.__autoSide){if(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.height+=e.y,e.width=t.width,e.x=e.y=0),t.__autoHeight||(e.width+=e.x,e.height=t.height,e.y=e.x=0)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),oe(se,e),this.__updateRectRenderBounds(),t=!ae(e,se)||void 0):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),t&&!(this.__.__drawAfterFill="hide"===this.__.overflow)&&re(e,se)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};ht([n(Ft)],ne.prototype,"__",void 0),ht([_(!1)],ne.prototype,"resizeChildren",void 0),ht([q("show")],ne.prototype,"overflow",void 0),ht([b(ee.__updateStrokeSpread)],ne.prototype,"__updateStrokeSpread",null),ht([b(ee.__updateRenderSpread)],ne.prototype,"__updateRectRenderSpread",null),ht([b(ee.__updateBoxBounds)],ne.prototype,"__updateRectBoxBounds",null),ht([b(ee.__updateStrokeBounds)],ne.prototype,"__updateStrokeBounds",null),ht([b(ee.__updateRenderBounds)],ne.prototype,"__updateRectRenderBounds",null),ht([b(ee.__updateChange)],ne.prototype,"__updateRectChange",null),ht([b(ee.__render)],ne.prototype,"__renderRect",null),ht([b(ie.__render)],ne.prototype,"__renderGroup",null),ne=ht([P(),W()],ne);let _e=class extends ne{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};ht([n(Lt)],_e.prototype,"__",void 0),ht([h("#FFFFFF")],_e.prototype,"fill",void 0),ht([q("hide")],_e.prototype,"overflow",void 0),_e=ht([W()],_e);const{moveTo:he,closePath:de,ellipse:pe}=tt;let le=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&pe(n,r,a,r*i,a*i,0,s,o,!1),pe(n,r,a,r,a,0,o,s,!0),i<1&&de(n)):(i<1&&(pe(n,r,a,r*i,a*i),he(n,t,a)),pe(n,r,a,r,a,0,360,0,!0)),Z.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(he(n,r,a),pe(n,r,a,r,a,0,s,o,!1),de(n)):pe(n,r,a,r,a)}};ht([n(Dt)],le.prototype,"__",void 0),ht([R(0)],le.prototype,"innerRadius",void 0),ht([R(0)],le.prototype,"startAngle",void 0),ht([R(0)],le.prototype,"endAngle",void 0),le=ht([W()],le);const{moveTo:ue,lineTo:ce,drawPoints:ye}=tt,{rotate:ve,getAngle:ge,getDistance:fe,defaultPoint:we}=st,{toBounds:xe}=ot;let me=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=it();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=fe(we,t),this.rotation=ge(we,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ye(e,t.points,!1,t.closed):(ue(e,0,0),ce(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ye(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&lt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?xe(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};ht([n(It)],me.prototype,"__",void 0),ht([et("center")],me.prototype,"strokeAlign",void 0),ht([v(0)],me.prototype,"height",void 0),ht([R()],me.prototype,"points",void 0),ht([R(0)],me.prototype,"curve",void 0),ht([R(!1)],me.prototype,"closed",void 0),me=ht([W()],me);const{sin:Re,cos:Se,PI:Be}=Math,{moveTo:ke,lineTo:be,closePath:Ae,drawPoints:Ce}=tt,Pe=me.prototype;let Fe=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ce(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;ke(t,o,0);for(let e=1;e<s;e++)be(t,o+o*Re(2*e*Be/s),r-r*Se(2*e*Be/s))}Ae(t)}__updateRenderPath(){}__updateBoxBounds(){}};ht([n(Tt)],Fe.prototype,"__",void 0),ht([R(3)],Fe.prototype,"sides",void 0),ht([R()],Fe.prototype,"points",void 0),ht([R(0)],Fe.prototype,"curve",void 0),ht([b(Pe.__updateRenderPath)],Fe.prototype,"__updateRenderPath",null),ht([b(Pe.__updateBoxBounds)],Fe.prototype,"__updateBoxBounds",null),Fe=ht([P(),W()],Fe);const{sin:Ee,cos:Le,PI:Ie}=Math,{moveTo:We,lineTo:De,closePath:Te}=tt;let ze=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)De(a,o+(t%2==0?o:o*s)*Ee(t*Ie/i),r-(t%2==0?r:r*s)*Le(t*Ie/i));Te(a)}};ht([n(zt)],ze.prototype,"__",void 0),ht([R(5)],ze.prototype,"corners",void 0),ht([R(.382)],ze.prototype,"innerRadius",void 0),ze=ht([W()],ze);let Me=class extends te{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(rt.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};ht([n(Vt)],Me.prototype,"__",void 0),ht([v("")],Me.prototype,"url",void 0),Me=ht([W()],Me);let Oe=class extends te{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=O.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new at(t.__world).invert(),r=new at;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};ht([n(Yt)],Oe.prototype,"__",void 0),ht([Rt(100)],Oe.prototype,"width",void 0),ht([Rt(100)],Oe.prototype,"height",void 0),ht([Rt(Z.devicePixelRatio)],Oe.prototype,"pixelRatio",void 0),ht([Rt(!0)],Oe.prototype,"smooth",void 0),ht([Rt()],Oe.prototype,"contextSettings",void 0),Oe=ht([W()],Oe);const{copyAndSpread:Ne,includes:He,isSame:Ve,spread:Ye,setList:Xe}=Q;let Ue=class extends $t{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=dt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:_,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Ct.number(i,r),t.__letterSpacing=Ct.number(s,r),t.__padding=d?nt.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ye(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=He(c,u)?c:u;Ve(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Xe(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Ne(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};ht([n(Ht)],Ue.prototype,"__",void 0),ht([v(0)],Ue.prototype,"width",void 0),ht([v(0)],Ue.prototype,"height",void 0),ht([_(!1)],Ue.prototype,"resizeFontSize",void 0),ht([h("#000000")],Ue.prototype,"fill",void 0),ht([et("outside")],Ue.prototype,"strokeAlign",void 0),ht([S("all")],Ue.prototype,"hitFill",void 0),ht([v("")],Ue.prototype,"text",void 0),ht([v("L")],Ue.prototype,"fontFamily",void 0),ht([v(12)],Ue.prototype,"fontSize",void 0),ht([v("normal")],Ue.prototype,"fontWeight",void 0),ht([v(!1)],Ue.prototype,"italic",void 0),ht([v("none")],Ue.prototype,"textCase",void 0),ht([v("none")],Ue.prototype,"textDecoration",void 0),ht([v(0)],Ue.prototype,"letterSpacing",void 0),ht([v({type:"percent",value:1.5})],Ue.prototype,"lineHeight",void 0),ht([v(0)],Ue.prototype,"paraIndent",void 0),ht([v(0)],Ue.prototype,"paraSpacing",void 0),ht([v("left")],Ue.prototype,"textAlign",void 0),ht([v("top")],Ue.prototype,"verticalAlign",void 0),ht([v("normal")],Ue.prototype,"textWrap",void 0),ht([v("show")],Ue.prototype,"textOverflow",void 0),Ue=ht([W()],Ue);let je=class extends $t{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};ht([n(Mt)],je.prototype,"__",void 0),ht([et("center")],je.prototype,"strokeAlign",void 0),je=ht([W()],je);let Ge=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}};ht([n(Ot)],Ge.prototype,"__",void 0),ht([(t,e)=>{s(t,e,{get(){return this.__path}})}],Ge.prototype,"path",void 0),Ge=ht([C(_t,["set","beginPath","path"]),W()],Ge);export{ne as Box,Ft as BoxData,Oe as Canvas,Yt as CanvasData,pt as ColorConvert,vt as Effect,le as Ellipse,Dt as EllipseData,gt as Export,_e as Frame,Lt as FrameData,Kt as Group,Pt as GroupData,Me as Image,Vt as ImageData,Zt as Leafer,Et as LeaferData,me as Line,It as LineData,ut as Paint,yt as PaintGradient,ct as PaintImage,je as Path,lt as PathArrow,Mt as PathData,Ge as Pen,Ot as PenData,Fe as Polygon,Tt as PolygonData,te as Rect,Wt as RectData,Gt as RectRender,ze as Star,zt as StarData,ft as State,Ue as Text,dt as TextConvert,Ht as TextData,$t as UI,Xt as UIBounds,At as UIData,Ut as UIRender,Ct as UnitConvert,xt as arrowType,mt as effectType,Rt as resizeType,wt as stateType,St as zoomLayerType};
1
+ import{decorateLeafAttr as t,attr as e,doStrokeType as i,defineKey as s,Debug as o,LeafData as r,PathConvert as a,dataProcessor as n,dataType as _,surfaceType as h,opacityType as d,visibleType as p,sortType as l,maskType as u,eraserType as c,positionType as y,boundsType as v,scaleType as g,rotationType as f,autoLayoutType as w,naturalBoundsType as x,pathInputType as m,pathType as R,hitType as S,strokeType as B,cursorType as k,rewrite as b,Leaf as A,useModule as C,rewriteAble as P,pen as F,PathCorner as E,PathDrawer as L,UICreator as I,registerUI as W,Branch as D,LeafList as T,ImageManager as z,DataHelper as M,Creator as O,CanvasManager as N,WaitHelper as H,LeaferEvent as V,canvasSizeAttrs as Y,Bounds as X,ResizeEvent as U,AutoBounds as j,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,affectRenderBoundsType as q,BoundsHelper as Q,Platform as Z,PathCommandDataHelper as tt,affectStrokeBoundsType as et,getPointData as it,PointHelper as st,PathBounds as ot,ImageEvent as rt,Matrix as at,MathHelper as nt,PathCreator as _t}from"@leafer/core";export*from"@leafer/core";function ht(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const dt={},pt={},lt={},ut={},ct={},yt={},vt={},gt={},ft={};function wt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>{ft.setStyle&&ft.setStyle(this,t+"Style",e)}))}})))}function xt(s){return t(s,(t=>e({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,i(this)}}})))}function mt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Rt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function St(){return(t,e)=>{const i="_"+e;s(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:Bt}=a,kt={},bt=o.get("UIData");class At extends r{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,bt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,bt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=kt)):(this.__isFills&&(this.__removeInput("fill"),ct.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=kt)):(this.__isStrokes&&(this.__removeInput("stroke"),ct.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=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?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ut.compute("fill",this.__leaf),e&&ut.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Ct={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class Pt extends At{}class Ft extends Pt{get __boxStroke(){return!this.__pathInputed}}class Et extends Pt{}class Lt extends Ft{}class It extends At{}class Wt extends At{get __boxStroke(){return!this.__pathInputed}}class Dt extends At{get __boxStroke(){return!this.__pathInputed}}class Tt extends At{}class zt extends At{}class Mt extends At{}class Ot extends Pt{}const Nt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ht extends At{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Nt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Vt extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Yt extends Wt{}const Xt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Ut={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){jt(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=ut.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&vt.shadow(this,t,a),s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&vt.innerShadow(this,t,a),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t))}else i.__pathInputed?jt(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?ut.fills(o,this,t):ut.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ut.strokes(r,this,t):ut.stroke("#000000",this,t))}}};function jt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ut.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ut.stroke(o,t,e)}const Gt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Jt;let $t=Jt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:t}=this.__;return F.set(this.path=t||[]),t||this.__drawPathByBox(F),F}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(F.set(i=[]),this.__drawPathByBox(F)),t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||gt.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&&lt.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)}export(t,e){return gt.export(this,t,e)}clone(){return Jt.one(this.toJSON())}static one(t,e,i,s,o){return I.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){W()(this)}static registerData(t){n(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}};ht([n(At)],$t.prototype,"__",void 0),ht([St()],$t.prototype,"zoomLayer",void 0),ht([_("")],$t.prototype,"id",void 0),ht([_("")],$t.prototype,"name",void 0),ht([_("")],$t.prototype,"className",void 0),ht([h("pass-through")],$t.prototype,"blendMode",void 0),ht([d(1)],$t.prototype,"opacity",void 0),ht([p(!0)],$t.prototype,"visible",void 0),ht([wt(!1)],$t.prototype,"selected",void 0),ht([wt(!1)],$t.prototype,"disabled",void 0),ht([h(!1)],$t.prototype,"locked",void 0),ht([l(0)],$t.prototype,"zIndex",void 0),ht([u(!1)],$t.prototype,"mask",void 0),ht([c(!1)],$t.prototype,"eraser",void 0),ht([y(0,!0)],$t.prototype,"x",void 0),ht([y(0,!0)],$t.prototype,"y",void 0),ht([v(100,!0)],$t.prototype,"width",void 0),ht([v(100,!0)],$t.prototype,"height",void 0),ht([g(1,!0)],$t.prototype,"scaleX",void 0),ht([g(1,!0)],$t.prototype,"scaleY",void 0),ht([f(0,!0)],$t.prototype,"rotation",void 0),ht([f(0,!0)],$t.prototype,"skewX",void 0),ht([f(0,!0)],$t.prototype,"skewY",void 0),ht([y(0,!0)],$t.prototype,"offsetX",void 0),ht([y(0,!0)],$t.prototype,"offsetY",void 0),ht([y(0,!0)],$t.prototype,"scrollX",void 0),ht([y(0,!0)],$t.prototype,"scrollY",void 0),ht([w()],$t.prototype,"origin",void 0),ht([w()],$t.prototype,"around",void 0),ht([_(!1)],$t.prototype,"lazy",void 0),ht([x(1)],$t.prototype,"pixelRatio",void 0),ht([m()],$t.prototype,"path",void 0),ht([R()],$t.prototype,"windingRule",void 0),ht([R(!0)],$t.prototype,"closed",void 0),ht([w(!1)],$t.prototype,"flow",void 0),ht([v(0)],$t.prototype,"padding",void 0),ht([v(0)],$t.prototype,"gap",void 0),ht([v("top-left")],$t.prototype,"flowAlign",void 0),ht([v(!1)],$t.prototype,"flowWrap",void 0),ht([v("box")],$t.prototype,"itemBox",void 0),ht([v(!0)],$t.prototype,"inFlow",void 0),ht([v()],$t.prototype,"autoWidth",void 0),ht([v()],$t.prototype,"autoHeight",void 0),ht([v()],$t.prototype,"lockRatio",void 0),ht([v()],$t.prototype,"autoBox",void 0),ht([v()],$t.prototype,"widthRange",void 0),ht([v()],$t.prototype,"heightRange",void 0),ht([_(!1)],$t.prototype,"draggable",void 0),ht([_()],$t.prototype,"dragBounds",void 0),ht([_(!1)],$t.prototype,"editable",void 0),ht([S(!0)],$t.prototype,"hittable",void 0),ht([S("path")],$t.prototype,"hitFill",void 0),ht([B("path")],$t.prototype,"hitStroke",void 0),ht([S(!1)],$t.prototype,"hitBox",void 0),ht([S(!0)],$t.prototype,"hitChildren",void 0),ht([S(!0)],$t.prototype,"hitSelf",void 0),ht([S()],$t.prototype,"hitRadius",void 0),ht([k("")],$t.prototype,"cursor",void 0),ht([h()],$t.prototype,"fill",void 0),ht([B()],$t.prototype,"stroke",void 0),ht([B("inside")],$t.prototype,"strokeAlign",void 0),ht([B(1)],$t.prototype,"strokeWidth",void 0),ht([B(!1)],$t.prototype,"strokeWidthFixed",void 0),ht([B("none")],$t.prototype,"strokeCap",void 0),ht([B("miter")],$t.prototype,"strokeJoin",void 0),ht([B()],$t.prototype,"dashPattern",void 0),ht([B()],$t.prototype,"dashOffset",void 0),ht([B(10)],$t.prototype,"miterLimit",void 0),ht([xt("none")],$t.prototype,"startArrow",void 0),ht([xt("none")],$t.prototype,"endArrow",void 0),ht([R(0)],$t.prototype,"cornerRadius",void 0),ht([R()],$t.prototype,"cornerSmoothing",void 0),ht([mt()],$t.prototype,"shadow",void 0),ht([mt()],$t.prototype,"innerShadow",void 0),ht([mt()],$t.prototype,"blur",void 0),ht([mt()],$t.prototype,"backgroundBlur",void 0),ht([mt()],$t.prototype,"grayscale",void 0),ht([_()],$t.prototype,"normalStyle",void 0),ht([_()],$t.prototype,"hoverStyle",void 0),ht([_()],$t.prototype,"pressStyle",void 0),ht([_()],$t.prototype,"focusStyle",void 0),ht([_()],$t.prototype,"selectedStyle",void 0),ht([_()],$t.prototype,"disabledStyle",void 0),ht([_({})],$t.prototype,"data",void 0),ht([b(A.prototype.reset)],$t.prototype,"reset",null),$t=Jt=ht([C(Xt),C(Ut),P()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:I.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var qt;ht([n(Pt)],Kt.prototype,"__",void 0),Kt=ht([C(D),W()],Kt);const Qt=o.get("Leafer");let Zt=qt=class extends Kt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&z.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&&M.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=O.canvas(s);this.__controllers.push(this.renderer=O.renderer(this,o,s),this.watcher=O.watcher(this,s),this.layouter=O.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=O.selector(this),this.interaction=O.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=O.hitCanvasManager()),this.canvasManager=new N,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(V.RESTART):this.emitLeafer(V.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(V.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=M.copyAttrs({},t,Y);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=M.copyAttrs({},this.canvas,Y);e.resize(t),this.updateLazyBounds(),this.__onResize(new U(t,i))}__onResize(t){this.emitEvent(t),M.copyAttrs(this.__,t,Y),t.width&&t.height||Qt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new j(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Y.includes(t)?(e||Qt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Y.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=M.copyAttrs({},this.canvas,Y);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(V.BEFORE_READY),this.emitLeafer(V.READY),this.emitLeafer(V.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(V.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(V.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 Qt.error("need @leafer-in/view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new V(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(V.START,(()=>G.end(t))),this.once(J.START,(()=>this.updateLazyBounds())),this.once(J.END,(()=>this.__onReady())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_($.NEXT,this.__onNextRender,this),this.on_(J.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){qt.list.remove(this);try{this.stop(),this.emitEvent(new V(V.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((()=>{z.clearRecycled()}),100)}catch(t){Qt.error(t)}}};t?e():setTimeout(e)}};Zt.list=new T,ht([n(Et)],Zt.prototype,"__",void 0),ht([v()],Zt.prototype,"pixelRatio",void 0),Zt=qt=ht([W()],Zt);let te=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};ht([n(Wt)],te.prototype,"__",void 0),te=ht([C(Gt),P(),W()],te);const ee=te.prototype,ie=Kt.prototype,se={},{copy:oe,add:re,includes:ae}=Q;let ne=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(this.children.length){if(t.__autoSide){if(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.height+=e.y,e.width=t.width,e.x=e.y=0),t.__autoHeight||(e.width+=e.x,e.height=t.height,e.y=e.x=0)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),oe(se,e),this.__updateRectRenderBounds(),t=!ae(e,se)||void 0):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),t&&!(this.__.__drawAfterFill="hide"===this.__.overflow)&&re(e,se)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};ht([n(Ft)],ne.prototype,"__",void 0),ht([_(!1)],ne.prototype,"resizeChildren",void 0),ht([q("show")],ne.prototype,"overflow",void 0),ht([b(ee.__updateStrokeSpread)],ne.prototype,"__updateStrokeSpread",null),ht([b(ee.__updateRenderSpread)],ne.prototype,"__updateRectRenderSpread",null),ht([b(ee.__updateBoxBounds)],ne.prototype,"__updateRectBoxBounds",null),ht([b(ee.__updateStrokeBounds)],ne.prototype,"__updateStrokeBounds",null),ht([b(ee.__updateRenderBounds)],ne.prototype,"__updateRectRenderBounds",null),ht([b(ee.__updateChange)],ne.prototype,"__updateRectChange",null),ht([b(ee.__render)],ne.prototype,"__renderRect",null),ht([b(ie.__render)],ne.prototype,"__renderGroup",null),ne=ht([P(),W()],ne);let _e=class extends ne{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};ht([n(Lt)],_e.prototype,"__",void 0),ht([h("#FFFFFF")],_e.prototype,"fill",void 0),ht([q("hide")],_e.prototype,"overflow",void 0),_e=ht([W()],_e);const{moveTo:he,closePath:de,ellipse:pe}=tt;let le=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&pe(n,r,a,r*i,a*i,0,s,o,!1),pe(n,r,a,r,a,0,o,s,!0),i<1&&de(n)):(i<1&&(pe(n,r,a,r*i,a*i),he(n,t,a)),pe(n,r,a,r,a,0,360,0,!0)),Z.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(he(n,r,a),pe(n,r,a,r,a,0,s,o,!1),de(n)):pe(n,r,a,r,a)}};ht([n(Dt)],le.prototype,"__",void 0),ht([R(0)],le.prototype,"innerRadius",void 0),ht([R(0)],le.prototype,"startAngle",void 0),ht([R(0)],le.prototype,"endAngle",void 0),le=ht([W()],le);const{moveTo:ue,lineTo:ce,drawPoints:ye}=tt,{rotate:ve,getAngle:ge,getDistance:fe,defaultPoint:we}=st,{toBounds:xe}=ot;let me=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=it();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=fe(we,t),this.rotation=ge(we,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ye(e,t.points,!1,t.closed):(ue(e,0,0),ce(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ye(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&lt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?xe(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};ht([n(It)],me.prototype,"__",void 0),ht([et("center")],me.prototype,"strokeAlign",void 0),ht([v(0)],me.prototype,"height",void 0),ht([R()],me.prototype,"points",void 0),ht([R(0)],me.prototype,"curve",void 0),ht([R(!1)],me.prototype,"closed",void 0),me=ht([W()],me);const{sin:Re,cos:Se,PI:Be}=Math,{moveTo:ke,lineTo:be,closePath:Ae,drawPoints:Ce}=tt,Pe=me.prototype;let Fe=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ce(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;ke(t,o,0);for(let e=1;e<s;e++)be(t,o+o*Re(2*e*Be/s),r-r*Se(2*e*Be/s))}Ae(t)}__updateRenderPath(){}__updateBoxBounds(){}};ht([n(Tt)],Fe.prototype,"__",void 0),ht([R(3)],Fe.prototype,"sides",void 0),ht([R()],Fe.prototype,"points",void 0),ht([R(0)],Fe.prototype,"curve",void 0),ht([b(Pe.__updateRenderPath)],Fe.prototype,"__updateRenderPath",null),ht([b(Pe.__updateBoxBounds)],Fe.prototype,"__updateBoxBounds",null),Fe=ht([P(),W()],Fe);const{sin:Ee,cos:Le,PI:Ie}=Math,{moveTo:We,lineTo:De,closePath:Te}=tt;let ze=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)De(a,o+(t%2==0?o:o*s)*Ee(t*Ie/i),r-(t%2==0?r:r*s)*Le(t*Ie/i));Te(a)}};ht([n(zt)],ze.prototype,"__",void 0),ht([R(5)],ze.prototype,"corners",void 0),ht([R(.382)],ze.prototype,"innerRadius",void 0),ze=ht([W()],ze);let Me=class extends te{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(rt.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};ht([n(Vt)],Me.prototype,"__",void 0),ht([v("")],Me.prototype,"url",void 0),Me=ht([W()],Me);let Oe=class extends te{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=O.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new at(t.__world).invert(),r=new at;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};ht([n(Yt)],Oe.prototype,"__",void 0),ht([Rt(100)],Oe.prototype,"width",void 0),ht([Rt(100)],Oe.prototype,"height",void 0),ht([Rt(Z.devicePixelRatio)],Oe.prototype,"pixelRatio",void 0),ht([Rt(!0)],Oe.prototype,"smooth",void 0),ht([Rt()],Oe.prototype,"contextSettings",void 0),Oe=ht([W()],Oe);const{copyAndSpread:Ne,includes:He,isSame:Ve,spread:Ye,setList:Xe}=Q;let Ue=class extends $t{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=dt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:_,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Ct.number(i,r),t.__letterSpacing=Ct.number(s,r),t.__padding=d?nt.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ye(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=He(c,u)?c:u;Ve(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Xe(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Ne(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};ht([n(Ht)],Ue.prototype,"__",void 0),ht([v(0)],Ue.prototype,"width",void 0),ht([v(0)],Ue.prototype,"height",void 0),ht([_(!1)],Ue.prototype,"resizeFontSize",void 0),ht([h("#000000")],Ue.prototype,"fill",void 0),ht([et("outside")],Ue.prototype,"strokeAlign",void 0),ht([S("all")],Ue.prototype,"hitFill",void 0),ht([v("")],Ue.prototype,"text",void 0),ht([v("L")],Ue.prototype,"fontFamily",void 0),ht([v(12)],Ue.prototype,"fontSize",void 0),ht([v("normal")],Ue.prototype,"fontWeight",void 0),ht([v(!1)],Ue.prototype,"italic",void 0),ht([v("none")],Ue.prototype,"textCase",void 0),ht([v("none")],Ue.prototype,"textDecoration",void 0),ht([v(0)],Ue.prototype,"letterSpacing",void 0),ht([v({type:"percent",value:1.5})],Ue.prototype,"lineHeight",void 0),ht([v(0)],Ue.prototype,"paraIndent",void 0),ht([v(0)],Ue.prototype,"paraSpacing",void 0),ht([v("left")],Ue.prototype,"textAlign",void 0),ht([v("top")],Ue.prototype,"verticalAlign",void 0),ht([v("normal")],Ue.prototype,"textWrap",void 0),ht([v("show")],Ue.prototype,"textOverflow",void 0),Ue=ht([W()],Ue);let je=class extends $t{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};ht([n(Mt)],je.prototype,"__",void 0),ht([et("center")],je.prototype,"strokeAlign",void 0),je=ht([W()],je);let Ge=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}};ht([n(Ot)],Ge.prototype,"__",void 0),ht([(t,e)=>{s(t,e,{get(){return this.__path}})}],Ge.prototype,"path",void 0),Ge=ht([C(_t,["set","beginPath","path"]),W()],Ge);export{ne as Box,Ft as BoxData,Oe as Canvas,Yt as CanvasData,pt as ColorConvert,vt as Effect,le as Ellipse,Dt as EllipseData,gt as Export,_e as Frame,Lt as FrameData,Kt as Group,Pt as GroupData,Me as Image,Vt as ImageData,Zt as Leafer,Et as LeaferData,me as Line,It as LineData,ut as Paint,yt as PaintGradient,ct as PaintImage,je as Path,lt as PathArrow,Mt as PathData,Ge as Pen,Ot as PenData,Fe as Polygon,Tt as PolygonData,te as Rect,Wt as RectData,Gt as RectRender,ze as Star,zt as StarData,ft as State,Ue as Text,dt as TextConvert,Ht as TextData,$t as UI,Xt as UIBounds,At as UIData,Ut as UIRender,Ct as UnitConvert,xt as arrowType,mt as effectType,Rt as resizeType,wt as stateType,St as zoomLayerType};
package/lib/draw.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core");function e(t,e,o,s){var r,i=arguments.length,a=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,s);else for(var n=t.length-1;n>=0;n--)(r=t[n])&&(a=(i<3?r(a):i>3?r(e,o,a):r(e,o))||a);return i>3&&a&&Object.defineProperty(e,o,a),a}"function"==typeof SuppressedError&&SuppressedError;const o={},s={},r={},i={},a={},n={},p={};function h(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.waitLeafer((()=>{p.setStyle&&p.setStyle(this,e+"Style",t)}))}})))}function _(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){if(this.__setAttr(e,o)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,t.doStrokeType(this)}}})))}function d(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function l(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function u(){return(e,o)=>{const s="_"+o;t.defineKey(e,o,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:c}=t.PathConvert,y={},x=t.Debug.get("UIData");class v extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:o}=e.__nowWorld||e.__world;return o<0&&(o=-o),o>1?t/o:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,x.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,x.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=y)):(this.__isFills&&(this.__removeInput("fill"),i.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=y)):(this.__isStrokes&&(this.__removeInput("stroke"),i.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=c(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&r.compute("fill",this.__leaf),e&&r.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const g={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class f extends v{}class w extends f{get __boxStroke(){return!this.__pathInputed}}class T extends f{}class I extends w{}class m extends v{}class R extends v{get __boxStroke(){return!this.__pathInputed}}class b extends v{get __boxStroke(){return!this.__pathInputed}}class P extends v{}class S extends v{}class B extends v{}class U 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 C 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:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends R{}const E={__updateStrokeSpread(){let t=0,e=0;const o=this.__,{strokeAlign:s,strokeWidth:r}=o;if((o.stroke||"all"===o.hitStroke)&&r&&"inside"!==s&&(e=t="center"===s?r/2:r,!o.__boxStroke)){const e=o.__isLinePath?0:10*t,s="none"===o.strokeCap?0:r;t+=Math.max(e,s)}return o.__useArrow&&(t+=5*r),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:o,blur:s,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let i=t=Math.ceil(t);return o&&o.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(i=Math.max(i,r)),this.__layout.renderShapeSpread=i,t+(this.__layout.strokeSpread||0)}},D={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:o,blur:s,backgroundBlur:r}=this.__;t.__useEffect=!!(e||o||s||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const o=this.__;if(o.__complex){o.__needComputePaint&&o.__computePaint();const{fill:s,stroke:i,__drawAfterFill:n}=o;if(this.__drawRenderPath(t),o.__useEffect){const p=r.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=o;h&&a.shadow(this,t,p),s&&(o.__isFills?r.fills(s,this,t):r.fill(s,this,t)),n&&this.__drawAfterFill(t,e),_&&a.innerShadow(this,t,p),i&&(o.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t)),p.worldCanvas&&p.worldCanvas.recycle(),p.canvas.recycle()}else s&&(o.__isFills?r.fills(s,this,t):r.fill(s,this,t)),n&&this.__drawAfterFill(t,e),i&&(o.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t))}else o.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,o,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:a}=this.__;this.__drawRenderPath(t),i&&!o&&(this.__.__pixelFill?r.fills(i,this,t):r.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),a&&!s&&(this.__.__pixelStroke?r.strokes(a,this,t):r.stroke("#000000",this,t))}}};function F(t,e,o){const{fill:s,stroke:i,__drawAfterFill:a}=t.__;t.__drawRenderPath(e),s&&r.fill(s,t,e),a&&t.__drawAfterFill(e,o),i&&r.stroke(i,t,e)}const W={__drawFast(t,e){let{width:o,height:s,fill:r,stroke:i,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,o,s)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:r,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(i,a,this.__);const n=a/2;switch(r){case"center":t.strokeRect(0,0,o,s);break;case"inside":o-=a,s-=a,o<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,o,s),t.restore()):t.strokeRect(n,n,o,s);break;case"outside":t.strokeRect(-n,-n,o+a,s+a)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:e}=this.__;return t.pen.set(this.path=e||[]),e||this.__drawPathByBox(t.pen),t.pen}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,o){this.__layout.update();let s=o?this.__.__pathForRender:this.__.path;return s||(t.pen.set(s=[]),this.__drawPathByBox(t.pen)),e?t.PathConvert.toCanvasData(s,!0):s}getPathString(e,o){return t.PathConvert.stringify(this.getPath(e,o))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||n.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&s.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,o){o?t.PathDrawer.drawPathByData(e,o):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:o,width:s,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,o,s,r,"number"==typeof i?[i]:i)}else t.rect(e,o,s,r)}export(t,e){return n.export(this,t,e)}clone(){return z.one(this.toJSON())}static one(e,o,s,r,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,o,s,r,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([u()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.visibleType(!0)],exports.UI.prototype,"visible",void 0),e([h(!1)],exports.UI.prototype,"selected",void 0),e([h(!1)],exports.UI.prototype,"disabled",void 0),e([t.surfaceType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.autoLayoutType(!1)],exports.UI.prototype,"flow",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.boundsType(0)],exports.UI.prototype,"gap",void 0),e([t.boundsType("top-left")],exports.UI.prototype,"flowAlign",void 0),e([t.boundsType(!1)],exports.UI.prototype,"flowWrap",void 0),e([t.boundsType("box")],exports.UI.prototype,"itemBox",void 0),e([t.boundsType(!0)],exports.UI.prototype,"inFlow",void 0),e([t.boundsType()],exports.UI.prototype,"autoWidth",void 0),e([t.boundsType()],exports.UI.prototype,"autoHeight",void 0),e([t.boundsType()],exports.UI.prototype,"lockRatio",void 0),e([t.boundsType()],exports.UI.prototype,"autoBox",void 0),e([t.boundsType()],exports.UI.prototype,"widthRange",void 0),e([t.boundsType()],exports.UI.prototype,"heightRange",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([_("none")],exports.UI.prototype,"startArrow",void 0),e([_("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([d()],exports.UI.prototype,"shadow",void 0),e([d()],exports.UI.prototype,"innerShadow",void 0),e([d()],exports.UI.prototype,"blur",void 0),e([d()],exports.UI.prototype,"backgroundBlur",void 0),e([d()],exports.UI.prototype,"grayscale",void 0),e([t.dataType()],exports.UI.prototype,"normalStyle",void 0),e([t.dataType()],exports.UI.prototype,"hoverStyle",void 0),e([t.dataType()],exports.UI.prototype,"pressStyle",void 0),e([t.dataType()],exports.UI.prototype,"focusStyle",void 0),e([t.dataType()],exports.UI.prototype,"selectedStyle",void 0),e([t.dataType()],exports.UI.prototype,"disabledStyle",void 0),e([t.dataType({})],exports.UI.prototype,"data",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(E),t.useModule(D),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(e){if(e.children){const{children:o}=e;let s;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),o.forEach((e=>{s=e.__?e:t.UICreator.get(e.tag,e),this.add(s)})),e.children=o}else super.set(e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const H=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,o){if(this.canvas)return;let s;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:r}=this;this.initType(r.type);const i=this.canvas=t.Creator.canvas(r);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,r),this.watcher=t.Creator.watcher(this,r),this.layouter=t.Creator.layouter(this,r)),this.isApp&&this.__setApp(),this.__checkAutoLayout(r),this.view=i.view,o?(this.__bindApp(o),s=o.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,r),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,s=r.start),this.hittable=r.hittable,this.fill=r.fill,this.canvasManager.add(i),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const o=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(o).forEach((t=>this[t]=o[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:o}=this;if(!o||o.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);o.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),e.width&&e.height||H.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,o){return this.canvas&&(t.canvasSizeAttrs.includes(e)?(o||H.warn(e+" is 0"),this.__changeCanvasSize(e,o)):"fill"===e?this.__changeFill(o):"hittable"===e?this.parent||(this.canvas.hittable=o):"zIndex"===e&&(this.canvas.zIndex=o,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(e,o)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,o){const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s[e]=this.config[e]=o,o&&this.canvas.stopAutoLayout(),this.__doResize(s)}__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,o){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(o){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,o){}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}__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 o=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){H.error(t)}}};e?o():setTimeout(o)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(T)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const O=exports.Rect.prototype,N=exports.Group.prototype,G={},{copy:V,add:Y,includes:j}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(this.children.length){if(t.__autoSide){if(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.height+=e.y,e.width=t.width,e.x=e.y=0),t.__autoHeight||(e.width+=e.x,e.height=t.height,e.y=e.x=0)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),V(G,e),this.__updateRectRenderBounds(),t=!j(e,G)||void 0):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),t&&!(this.__.__drawAfterFill="hide"===this.__.overflow)&&Y(e,G)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:o}=this.children;this.isOverflow?(t.save(),t.clip(),o&&this.__renderGroup(t,e),t.restore()):o&&this.__renderGroup(t,e),this.__.stroke&&o&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.dataType(!1)],exports.Box.prototype,"resizeChildren",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(O.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(O.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(O.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(O.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(O.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(O.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(N.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(I)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo: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:o,innerRadius:s,startAngle:r,endAngle:i}=this.__,a=e/2,n=o/2,p=this.__.path=[];s?(r||i?(s<1&&K(p,a,n,a*s,n*s,0,r,i,!1),K(p,a,n,a,n,0,i,r,!0),s<1&&J(p)):(s<1&&(K(p,a,n,a*s,n*s),X(p,e,n)),K(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):r||i?(X(p,a,n),K(p,a,n,a,n,0,r,i,!1),J(p)):K(p,a,n,a,n)}},e([t.dataProcessor(b)],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:ot}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:o}=this.__,s=t.getPointData();return e&&(s.x=e),o&&Z(s,o),s}set toPoint(t){this.width=et(ot,t),this.rotation=tt(ot,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&&s.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?st(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(m)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:rt,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:o,sides:s}=this.__,r=e/2,i=o/2;nt(t,r,0);for(let e=1;e<s;e++)pt(t,r+r*rt(2*e*at/s),i-i*it(2*e*at/s))}ht(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(P)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(dt.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(dt.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:lt,cos:ut,PI:ct}=Math,{moveTo:yt,lineTo:xt,closePath:vt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:o,innerRadius:s}=this.__,r=t/2,i=e/2,a=this.__.path=[];yt(a,r,0);for(let t=1;t<2*o;t++)xt(a,r+(t%2==0?r:r*s)*lt(t*ct/o),i-(t%2==0?i:i*s)*ut(t*ct/o));vt(a)}},e([t.dataProcessor(S)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0}draw(e,o,s,r){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;o&&a.translate(o.x,o.y),s&&("number"==typeof s?a.scale(s):a.scale(s.x,s.y)),r&&a.rotate(r),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const o=this.canvas.view,{width:s,height:r}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,o.width,o.height,0,0,s,r),t.restore()):t.drawImage(this.canvas.view,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=null,this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([l(100)],exports.Canvas.prototype,"width",void 0),e([l(100)],exports.Canvas.prototype,"height",void 0),e([l(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([l(!0)],exports.Canvas.prototype,"smooth",void 0),e([l()],exports.Canvas.prototype,"contextSettings",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:gt,includes:ft,isSame:wt,spread:Tt,setList:It}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:o,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-o,s.width,e)))}__drawPathByData(t,e){const{x:o,y:s,width:r,height:i}=this.__layout.boxBounds;t.rect(o,s,r,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=o.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,o=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=g.number(s,a),e.__letterSpacing=g.number(r,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=o.boxBounds;if(e.__lineHeight<a&&Tt(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,o,s,r]=e.__padding;l&&(y.x-=r,y.width+=o+r),u&&(y.y-=t,y.height+=s+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();p&&(y.width+=.16*a);const x=ft(y,c)?y:c;wt(x,o.contentBounds)?e.__textBoxBounds=x:(o.contentBounds=x,o.renderChanged=!0,It(e.__textBoxBounds={},[y,c]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){gt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(C)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.dataType(!1)],exports.Text.prototype,"resizeFontSize",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:1.5})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(B)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,o,s,r,i){return this}quadraticCurveTo(t,e,o,s){return this}closePath(){return this}rect(t,e,o,s){return this}roundRect(t,e,o,s,r){return this}ellipse(t,e,o,s,r,i,a,n){return this}arc(t,e,o,s,r,i){return this}arcTo(t,e,o,s,r){return this}drawEllipse(t,e,o,s,r,i,a,n){return this}drawArc(t,e,o,s,r,i){return this}drawPoints(t,e,o){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(U)],exports.Pen.prototype,"__",void 0),e([(e,o)=>{t.defineKey(e,o,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","beginPath","path"]),t.registerUI()],exports.Pen),exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=a,exports.EllipseData=b,exports.Export=n,exports.FrameData=I,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=T,exports.LineData=m,exports.Paint=r,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=s,exports.PathData=B,exports.PenData=U,exports.PolygonData=P,exports.RectData=R,exports.RectRender=W,exports.StarData=S,exports.State=p,exports.TextConvert=o,exports.TextData=C,exports.UIBounds=E,exports.UIData=v,exports.UIRender=D,exports.UnitConvert=g,exports.arrowType=_,exports.effectType=d,exports.resizeType=l,exports.stateType=h,exports.zoomLayerType=u,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";var t=require("@leafer/core");function e(t,e,o,s){var r,i=arguments.length,a=i<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,s);else for(var n=t.length-1;n>=0;n--)(r=t[n])&&(a=(i<3?r(a):i>3?r(e,o,a):r(e,o))||a);return i>3&&a&&Object.defineProperty(e,o,a),a}"function"==typeof SuppressedError&&SuppressedError;const o={},s={},r={},i={},a={},n={},p={};function h(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.waitLeafer((()=>{p.setStyle&&p.setStyle(this,e+"Style",t)}))}})))}function _(e){return t.decorateLeafAttr(e,(e=>t.attr({set(o){if(this.__setAttr(e,o)){const e=this.__;e.__useArrow="none"!==e.startArrow||"none"!==e.endArrow,t.doStrokeType(this)}}})))}function d(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function l(e){return t.decorateLeafAttr(e,(e=>t.attr({set(t){this.__setAttr(e,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function u(){return(e,o)=>{const s="_"+o;t.defineKey(e,o,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:c}=t.PathConvert,y={},x=t.Debug.get("UIData");class v extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:o}=e.__nowWorld||e.__world;return o<0&&(o=-o),o>1?t/o:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,x.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,x.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=y)):(this.__isFills&&(this.__removeInput("fill"),i.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=y)):(this.__isStrokes&&(this.__removeInput("stroke"),i.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=c(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&r.compute("fill",this.__leaf),e&&r.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const g={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class f extends v{}class w extends f{get __boxStroke(){return!this.__pathInputed}}class T extends f{}class I extends w{}class m extends v{}class R extends v{get __boxStroke(){return!this.__pathInputed}}class b extends v{get __boxStroke(){return!this.__pathInputed}}class P extends v{}class S extends v{}class B extends v{}class U 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 C 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:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends R{}const E={__updateStrokeSpread(){let t=0,e=0;const o=this.__,{strokeAlign:s,strokeWidth:r}=o;if((o.stroke||"all"===o.hitStroke)&&r&&"inside"!==s&&(e=t="center"===s?r/2:r,!o.__boxStroke)){const e=o.__isLinePath?0:10*t,s="none"===o.strokeCap?0:r;t+=Math.max(e,s)}return o.__useArrow&&(t+=5*r),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:o,blur:s,backgroundBlur:r}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let i=t=Math.ceil(t);return o&&o.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(i=Math.max(i,r)),this.__layout.renderShapeSpread=i,t+(this.__layout.strokeSpread||0)}},D={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:o,blur:s,backgroundBlur:r}=this.__;t.__useEffect=!!(e||o||s||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const o=this.__;if(o.__complex){o.__needComputePaint&&o.__computePaint();const{fill:s,stroke:i,__drawAfterFill:n}=o;if(this.__drawRenderPath(t),o.__useEffect){const p=r.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=o;h&&a.shadow(this,t,p),s&&(o.__isFills?r.fills(s,this,t):r.fill(s,this,t)),n&&this.__drawAfterFill(t,e),_&&a.innerShadow(this,t,p),i&&(o.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t)),p.worldCanvas&&p.worldCanvas.recycle(),p.canvas.recycle()}else s&&(o.__isFills?r.fills(s,this,t):r.fill(s,this,t)),n&&this.__drawAfterFill(t,e),i&&(o.__isStrokes?r.strokes(i,this,t):r.stroke(i,this,t))}else o.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,o,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:a}=this.__;this.__drawRenderPath(t),i&&!o&&(this.__.__pixelFill?r.fills(i,this,t):r.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),a&&!s&&(this.__.__pixelStroke?r.strokes(a,this,t):r.stroke("#000000",this,t))}}};function F(t,e,o){const{fill:s,stroke:i,__drawAfterFill:a}=t.__;t.__drawRenderPath(e),s&&r.fill(s,t,e),a&&t.__drawAfterFill(e,o),i&&r.stroke(i,t,e)}const W={__drawFast(t,e){let{width:o,height:s,fill:r,stroke:i,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,o,s)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:r,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(i,a,this.__);const n=a/2;switch(r){case"center":t.strokeRect(0,0,o,s);break;case"inside":o-=a,s-=a,o<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,o,s),t.restore()):t.strokeRect(n,n,o,s);break;case"outside":t.strokeRect(-n,-n,o+a,s+a)}}}};var z,M;exports.UI=z=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){const{path:e}=this.__;return t.pen.set(this.path=e||[]),e||this.__drawPathByBox(t.pen),t.pen}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(e,o){this.__layout.update();let s=o?this.__.__pathForRender:this.__.path;return s||(t.pen.set(s=[]),this.__drawPathByBox(t.pen)),e?t.PathConvert.toCanvasData(s,!0):s}getPathString(e,o){return t.PathConvert.stringify(this.getPath(e,o))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||n.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&s.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,o){o?t.PathDrawer.drawPathByData(e,o):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:o,width:s,height:r}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:i}=this.__;t.roundRect(e,o,s,r,"number"==typeof i?[i]:i)}else t.rect(e,o,s,r)}export(t,e){return n.export(this,t,e)}clone(){return z.one(this.toJSON())}static one(e,o,s,r,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,o,s,r,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([u()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.visibleType(!0)],exports.UI.prototype,"visible",void 0),e([h(!1)],exports.UI.prototype,"selected",void 0),e([h(!1)],exports.UI.prototype,"disabled",void 0),e([t.surfaceType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"x",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"width",void 0),e([t.boundsType(100,!0)],exports.UI.prototype,"height",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1,!0)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0,!0)],exports.UI.prototype,"skewY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"offsetY",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollX",void 0),e([t.positionType(0,!0)],exports.UI.prototype,"scrollY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"origin",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([t.pathType(!0)],exports.UI.prototype,"closed",void 0),e([t.autoLayoutType(!1)],exports.UI.prototype,"flow",void 0),e([t.boundsType(0)],exports.UI.prototype,"padding",void 0),e([t.boundsType(0)],exports.UI.prototype,"gap",void 0),e([t.boundsType("top-left")],exports.UI.prototype,"flowAlign",void 0),e([t.boundsType(!1)],exports.UI.prototype,"flowWrap",void 0),e([t.boundsType("box")],exports.UI.prototype,"itemBox",void 0),e([t.boundsType(!0)],exports.UI.prototype,"inFlow",void 0),e([t.boundsType()],exports.UI.prototype,"autoWidth",void 0),e([t.boundsType()],exports.UI.prototype,"autoHeight",void 0),e([t.boundsType()],exports.UI.prototype,"lockRatio",void 0),e([t.boundsType()],exports.UI.prototype,"autoBox",void 0),e([t.boundsType()],exports.UI.prototype,"widthRange",void 0),e([t.boundsType()],exports.UI.prototype,"heightRange",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType()],exports.UI.prototype,"dragBounds",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([_("none")],exports.UI.prototype,"startArrow",void 0),e([_("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([d()],exports.UI.prototype,"shadow",void 0),e([d()],exports.UI.prototype,"innerShadow",void 0),e([d()],exports.UI.prototype,"blur",void 0),e([d()],exports.UI.prototype,"backgroundBlur",void 0),e([d()],exports.UI.prototype,"grayscale",void 0),e([t.dataType()],exports.UI.prototype,"normalStyle",void 0),e([t.dataType()],exports.UI.prototype,"hoverStyle",void 0),e([t.dataType()],exports.UI.prototype,"pressStyle",void 0),e([t.dataType()],exports.UI.prototype,"focusStyle",void 0),e([t.dataType()],exports.UI.prototype,"selectedStyle",void 0),e([t.dataType()],exports.UI.prototype,"disabledStyle",void 0),e([t.dataType({})],exports.UI.prototype,"data",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=z=e([t.useModule(E),t.useModule(D),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(e){if(e.children){const{children:o}=e;let s;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),o.forEach((e=>{s=e.__?e:t.UICreator.get(e.tag,e),this.add(s)})),e.children=o}else super.set(e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const H=t.Debug.get("Leafer");exports.Leafer=M=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),M.list.add(this)}init(e,o){if(this.canvas)return;let s;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:r}=this;this.initType(r.type);const i=this.canvas=t.Creator.canvas(r);this.__controllers.push(this.renderer=t.Creator.renderer(this,i,r),this.watcher=t.Creator.watcher(this,r),this.layouter=t.Creator.layouter(this,r)),this.isApp&&this.__setApp(),this.__checkAutoLayout(r,o),this.view=i.view,o?(this.__bindApp(o),s=o.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,i,this.selector,r),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,s=r.start),this.hittable=r.hittable,this.fill=r.fill,this.canvasManager.add(i),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),t.WaitHelper.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const o=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(o).forEach((t=>this[t]=o[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:o}=this;if(!o||o.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);o.resize(e),this.updateLazyBounds(),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),e.width&&e.height||H.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(e,o){o||(e.width&&e.height||(this.autoLayout=new t.AutoBounds(e)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,o){return this.canvas&&(t.canvasSizeAttrs.includes(e)?(o||H.warn(e+" is 0"),this.__changeCanvasSize(e,o)):"fill"===e?this.__changeFill(o):"hittable"===e?this.parent||(this.canvas.hittable=o):"zIndex"===e&&(this.canvas.zIndex=o,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(e,o)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,o){const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);s[e]=this.config[e]=o,o&&this.canvas.stopAutoLayout(),this.__doResize(s)}__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,o){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(o){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,o){return H.error("need @leafer-in/view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}__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 o=()=>{if(!this.destroyed){M.list.remove(this);try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){H.error(t)}}};e?o():setTimeout(o)}},exports.Leafer.list=new t.LeafList,e([t.dataProcessor(T)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=M=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const O=exports.Rect.prototype,N=exports.Group.prototype,G={},{copy:V,add:Y,includes:j}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(this.children.length){if(t.__autoSide){if(this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.height+=e.y,e.width=t.width,e.x=e.y=0),t.__autoHeight||(e.width+=e.x,e.height=t.height,e.y=e.x=0)}}else this.__updateRectBoxBounds();t.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),V(G,e),this.__updateRectRenderBounds(),t=!j(e,G)||void 0):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),t&&!(this.__.__drawAfterFill="hide"===this.__.overflow)&&Y(e,G)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:o}=this.children;this.isOverflow?(t.save(),t.clip(),o&&this.__renderGroup(t,e),t.restore()):o&&this.__renderGroup(t,e),this.__.stroke&&o&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.dataType(!1)],exports.Box.prototype,"resizeChildren",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(O.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(O.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(O.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(O.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(O.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(O.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(N.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(I)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo: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:o,innerRadius:s,startAngle:r,endAngle:i}=this.__,a=e/2,n=o/2,p=this.__.path=[];s?(r||i?(s<1&&K(p,a,n,a*s,n*s,0,r,i,!1),K(p,a,n,a,n,0,i,r,!0),s<1&&J(p)):(s<1&&(K(p,a,n,a*s,n*s),X(p,e,n)),K(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):r||i?(X(p,a,n),K(p,a,n,a,n,0,r,i,!1),J(p)):K(p,a,n,a,n)}},e([t.dataProcessor(b)],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:ot}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:o}=this.__,s=t.getPointData();return e&&(s.x=e),o&&Z(s,o),s}set toPoint(t){this.width=et(ot,t),this.rotation=tt(ot,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&&s.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?st(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(m)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),e([t.pathType(!1)],exports.Line.prototype,"closed",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:rt,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:o,sides:s}=this.__,r=e/2,i=o/2;nt(t,r,0);for(let e=1;e<s;e++)pt(t,r+r*rt(2*e*at/s),i-i*it(2*e*at/s))}ht(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(P)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(dt.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(dt.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:lt,cos:ut,PI:ct}=Math,{moveTo:yt,lineTo:xt,closePath:vt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:o,innerRadius:s}=this.__,r=t/2,i=e/2,a=this.__.path=[];yt(a,r,0);for(let t=1;t<2*o;t++)xt(a,r+(t%2==0?r:r*s)*lt(t*ct/o),i-(t%2==0?i:i*s)*ut(t*ct/o));vt(a)}},e([t.dataProcessor(S)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0}draw(e,o,s,r){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;o&&a.translate(o.x,o.y),s&&("number"==typeof s?a.scale(s):a.scale(s.x,s.y)),r&&a.rotate(r),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const o=this.canvas.view,{width:s,height:r}=this;this.__.cornerRadius||this.pathInputed?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,o.width,o.height,0,0,s,r),t.restore()):t.drawImage(this.canvas.view,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([l(100)],exports.Canvas.prototype,"width",void 0),e([l(100)],exports.Canvas.prototype,"height",void 0),e([l(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([l(!0)],exports.Canvas.prototype,"smooth",void 0),e([l()],exports.Canvas.prototype,"contextSettings",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:gt,includes:ft,isSame:wt,spread:Tt,setList:It}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:o,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-o,s.width,e)))}__drawPathByData(t,e){const{x:o,y:s,width:r,height:i}=this.__layout.boxBounds;t.rect(o,s,r,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=o.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,o=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=g.number(s,a),e.__letterSpacing=g.number(r,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=o.boxBounds;if(e.__lineHeight<a&&Tt(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,o,s,r]=e.__padding;l&&(y.x-=r,y.width+=o+r),u&&(y.y-=t,y.height+=s+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();p&&(y.width+=.16*a);const x=ft(y,c)?y:c;wt(x,o.contentBounds)?e.__textBoxBounds=x:(o.contentBounds=x,o.renderChanged=!0,It(e.__textBoxBounds={},[y,c]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){gt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(C)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.dataType(!1)],exports.Text.prototype,"resizeFontSize",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:1.5})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(B)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,o,s,r,i){return this}quadraticCurveTo(t,e,o,s){return this}closePath(){return this}rect(t,e,o,s){return this}roundRect(t,e,o,s,r){return this}ellipse(t,e,o,s,r,i,a,n){return this}arc(t,e,o,s,r,i){return this}arcTo(t,e,o,s,r){return this}drawEllipse(t,e,o,s,r,i,a,n){return this}drawArc(t,e,o,s,r,i){return this}drawPoints(t,e,o){return this}clearPath(){return this}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(U)],exports.Pen.prototype,"__",void 0),e([(e,o)=>{t.defineKey(e,o,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["set","beginPath","path"]),t.registerUI()],exports.Pen),exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=a,exports.EllipseData=b,exports.Export=n,exports.FrameData=I,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=T,exports.LineData=m,exports.Paint=r,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=s,exports.PathData=B,exports.PenData=U,exports.PolygonData=P,exports.RectData=R,exports.RectRender=W,exports.StarData=S,exports.State=p,exports.TextConvert=o,exports.TextData=C,exports.UIBounds=E,exports.UIData=v,exports.UIRender=D,exports.UnitConvert=g,exports.arrowType=_,exports.effectType=d,exports.resizeType=l,exports.stateType=h,exports.zoomLayerType=u,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/draw",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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.0",
33
- "@leafer-ui/display": "1.0.0",
34
- "@leafer-ui/display-module": "1.0.0",
35
- "@leafer-ui/decorator": "1.0.0",
36
- "@leafer-ui/external": "1.0.0"
32
+ "@leafer/core": "1.0.1",
33
+ "@leafer-ui/display": "1.0.1",
34
+ "@leafer-ui/display-module": "1.0.1",
35
+ "@leafer-ui/decorator": "1.0.1",
36
+ "@leafer-ui/external": "1.0.1"
37
37
  }
38
38
  }