@leafer-ui/core 1.0.0-rc.8 → 1.0.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.cjs CHANGED
@@ -206,6 +206,9 @@ class FrameData extends BoxData {
206
206
  class LineData extends UIData {
207
207
  }
208
208
 
209
+ class ArrowData extends LineData {
210
+ }
211
+
209
212
  class RectData extends UIData {
210
213
  get __boxStroke() { return true; }
211
214
  }
@@ -264,6 +267,25 @@ class TextData extends UIData {
264
267
  }
265
268
 
266
269
  class ImageData extends RectData {
270
+ setUrl(value) {
271
+ this.__setImageFill(value);
272
+ this._url = value;
273
+ }
274
+ __setImageFill(value) {
275
+ if (this.__leaf.image)
276
+ this.__leaf.image = null;
277
+ this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
278
+ }
279
+ __getData() {
280
+ const data = super.__getData();
281
+ delete data.fill;
282
+ return data;
283
+ }
284
+ __getInputData() {
285
+ const data = super.__getInputData();
286
+ delete data.fill;
287
+ return data;
288
+ }
267
289
  }
268
290
 
269
291
  class CanvasData extends RectData {
@@ -510,14 +532,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
510
532
  findOne(condition, options) {
511
533
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
512
534
  }
513
- getPath(curve) {
514
- const { path } = this.__;
535
+ getPath(curve, pathForRender) {
536
+ this.__layout.update();
537
+ let path = pathForRender ? this.__.__pathForRender : this.__.path;
515
538
  if (!path)
516
- return [];
539
+ this.__drawPathByBox(new core.PathCreator(path = []));
517
540
  return curve ? core.PathConvert.toCanvasData(path, true) : path;
518
541
  }
519
- getPathString(curve) {
520
- return core.PathConvert.stringify(this.getPath(curve));
542
+ getPathString(curve, pathForRender) {
543
+ return core.PathConvert.stringify(this.getPath(curve, pathForRender));
521
544
  }
522
545
  __onUpdateSize() {
523
546
  if (this.__.__input) {
@@ -689,6 +712,12 @@ __decorate([
689
712
  __decorate([
690
713
  core.strokeType(10)
691
714
  ], exports.UI.prototype, "miterLimit", void 0);
715
+ __decorate([
716
+ core.strokeType('none')
717
+ ], exports.UI.prototype, "startArrow", void 0);
718
+ __decorate([
719
+ core.strokeType('none')
720
+ ], exports.UI.prototype, "endArrow", void 0);
692
721
  __decorate([
693
722
  core.pathType(0)
694
723
  ], exports.UI.prototype, "cornerRadius", void 0);
@@ -1185,26 +1214,10 @@ exports.Image = class Image extends exports.Rect {
1185
1214
  get ready() { return this.image ? this.image.ready : false; }
1186
1215
  constructor(data) {
1187
1216
  super(data);
1188
- }
1189
- __updateBoxBounds() {
1190
- let update;
1191
- const { url } = this;
1192
- const fill = this.fill;
1193
- if (fill) {
1194
- if (fill.url !== url)
1195
- update = true;
1196
- }
1197
- else {
1198
- if (url)
1199
- update = true;
1200
- }
1201
- if (update) {
1202
- if (this.image)
1203
- this.image = null;
1204
- this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
1205
- this.once(core.ImageEvent.LOADED, (e) => this.image = e.image);
1206
- }
1207
- super.__updateBoxBounds();
1217
+ this.on(core.ImageEvent.LOADED, (e) => {
1218
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
1219
+ this.image = e.image;
1220
+ });
1208
1221
  }
1209
1222
  destroy() {
1210
1223
  this.image = null;
@@ -1965,6 +1978,7 @@ exports.App = __decorate([
1965
1978
  ], exports.App);
1966
1979
 
1967
1980
  exports.Animate = Animate;
1981
+ exports.ArrowData = ArrowData;
1968
1982
  exports.BoxData = BoxData;
1969
1983
  exports.CanvasData = CanvasData;
1970
1984
  exports.ColorConvert = ColorConvert;
package/dist/core.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MoveEvent, LeafHelper, ZoomEvent, Debug, LeafData, PathConvert, defineLeafAttr, OneRadian, Platform, dataProcessor, dataType, surfaceType, opacityType, maskType, eraserType, sortType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, pathType, rewrite, Leaf, PathDrawer, useModule, rewriteAble, PathCorner, UICreator, MatrixHelper, Branch, registerUI, affectRenderBoundsType, BoundsHelper, PathCommandDataHelper, affectStrokeBoundsType, PathScaler, PointHelper, PathBounds, ImageEvent, Creator, Matrix, MathHelper, PathCreator, ImageManager, DataHelper, CanvasManager, HitCanvasManager, PluginManager, LeaferEvent, canvasSizeAttrs, ResizeEvent, AutoBounds, WaitHelper, Run, LayoutEvent, RenderEvent, WatchEvent, AnimateEvent, PropertyEvent } from '@leafer/core';
1
+ import { MoveEvent, LeafHelper, ZoomEvent, Debug, LeafData, PathConvert, defineLeafAttr, OneRadian, Platform, dataProcessor, dataType, surfaceType, opacityType, maskType, eraserType, sortType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, pathType, rewrite, Leaf, PathDrawer, useModule, rewriteAble, PathCreator, PathCorner, UICreator, MatrixHelper, Branch, registerUI, affectRenderBoundsType, BoundsHelper, PathCommandDataHelper, affectStrokeBoundsType, PathScaler, PointHelper, PathBounds, ImageEvent, Creator, Matrix, MathHelper, ImageManager, DataHelper, CanvasManager, HitCanvasManager, PluginManager, LeaferEvent, canvasSizeAttrs, ResizeEvent, AutoBounds, WaitHelper, Run, LayoutEvent, RenderEvent, WatchEvent, AnimateEvent, PropertyEvent } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -205,6 +205,9 @@ class FrameData extends BoxData {
205
205
  class LineData extends UIData {
206
206
  }
207
207
 
208
+ class ArrowData extends LineData {
209
+ }
210
+
208
211
  class RectData extends UIData {
209
212
  get __boxStroke() { return true; }
210
213
  }
@@ -263,6 +266,25 @@ class TextData extends UIData {
263
266
  }
264
267
 
265
268
  class ImageData extends RectData {
269
+ setUrl(value) {
270
+ this.__setImageFill(value);
271
+ this._url = value;
272
+ }
273
+ __setImageFill(value) {
274
+ if (this.__leaf.image)
275
+ this.__leaf.image = null;
276
+ this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
277
+ }
278
+ __getData() {
279
+ const data = super.__getData();
280
+ delete data.fill;
281
+ return data;
282
+ }
283
+ __getInputData() {
284
+ const data = super.__getInputData();
285
+ delete data.fill;
286
+ return data;
287
+ }
266
288
  }
267
289
 
268
290
  class CanvasData extends RectData {
@@ -509,14 +531,15 @@ let UI = UI_1 = class UI extends Leaf {
509
531
  findOne(condition, options) {
510
532
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
511
533
  }
512
- getPath(curve) {
513
- const { path } = this.__;
534
+ getPath(curve, pathForRender) {
535
+ this.__layout.update();
536
+ let path = pathForRender ? this.__.__pathForRender : this.__.path;
514
537
  if (!path)
515
- return [];
538
+ this.__drawPathByBox(new PathCreator(path = []));
516
539
  return curve ? PathConvert.toCanvasData(path, true) : path;
517
540
  }
518
- getPathString(curve) {
519
- return PathConvert.stringify(this.getPath(curve));
541
+ getPathString(curve, pathForRender) {
542
+ return PathConvert.stringify(this.getPath(curve, pathForRender));
520
543
  }
521
544
  __onUpdateSize() {
522
545
  if (this.__.__input) {
@@ -688,6 +711,12 @@ __decorate([
688
711
  __decorate([
689
712
  strokeType(10)
690
713
  ], UI.prototype, "miterLimit", void 0);
714
+ __decorate([
715
+ strokeType('none')
716
+ ], UI.prototype, "startArrow", void 0);
717
+ __decorate([
718
+ strokeType('none')
719
+ ], UI.prototype, "endArrow", void 0);
691
720
  __decorate([
692
721
  pathType(0)
693
722
  ], UI.prototype, "cornerRadius", void 0);
@@ -1184,26 +1213,10 @@ let Image = class Image extends Rect {
1184
1213
  get ready() { return this.image ? this.image.ready : false; }
1185
1214
  constructor(data) {
1186
1215
  super(data);
1187
- }
1188
- __updateBoxBounds() {
1189
- let update;
1190
- const { url } = this;
1191
- const fill = this.fill;
1192
- if (fill) {
1193
- if (fill.url !== url)
1194
- update = true;
1195
- }
1196
- else {
1197
- if (url)
1198
- update = true;
1199
- }
1200
- if (update) {
1201
- if (this.image)
1202
- this.image = null;
1203
- this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
1204
- this.once(ImageEvent.LOADED, (e) => this.image = e.image);
1205
- }
1206
- super.__updateBoxBounds();
1216
+ this.on(ImageEvent.LOADED, (e) => {
1217
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
1218
+ this.image = e.image;
1219
+ });
1207
1220
  }
1208
1221
  destroy() {
1209
1222
  this.image = null;
@@ -1963,4 +1976,4 @@ App = __decorate([
1963
1976
  registerUI()
1964
1977
  ], App);
1965
1978
 
1966
- export { Animate, App, Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, LeaferTypeCreator, Line, LineData, Paint, Path, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, Text, TextConvert, TextData, UI, UIBounds, UIData, UIHit, UIRender, UnitConvert, effectType, resizeType };
1979
+ export { Animate, App, ArrowData, Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, LeaferTypeCreator, Line, LineData, Paint, Path, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, Text, TextConvert, TextData, UI, UIBounds, UIData, UIHit, UIRender, UnitConvert, effectType, resizeType };
@@ -1 +1 @@
1
- import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as o,PathConvert as r,defineLeafAttr as a,OneRadian as h,Platform as _,dataProcessor as n,dataType as d,surfaceType as l,opacityType as p,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,autoLayoutType as m,hitType as x,strokeType as R,cursorType as k,pathType as B,rewrite as S,Leaf as b,PathDrawer as C,useModule as A,rewriteAble as P,PathCorner as E,UICreator as L,MatrixHelper as F,Branch as D,registerUI as T,affectRenderBoundsType as z,BoundsHelper as M,PathCommandDataHelper as W,affectStrokeBoundsType as I,PathScaler as O,PointHelper as H,PathBounds as V,ImageEvent as N,Creator as Y,Matrix as X,MathHelper as j,PathCreator as U,ImageManager as G,DataHelper as J,CanvasManager as $,HitCanvasManager as q,PluginManager as K,LeaferEvent as Z,canvasSizeAttrs as Q,ResizeEvent as tt,AutoBounds as et,WaitHelper as st,Run as it,LayoutEvent as ot,RenderEvent as rt,WatchEvent as at,AnimateEvent as ht,PropertyEvent as _t}from"@leafer/core";export*from"@leafer/core";function nt(t,e,s,i){var o,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(a=(r<3?o(a):r>3?o(e,s,a):o(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}function dt(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const lt=i.get("LeaferTypeCreator"),pt={list:{},register(t,e){ct[t]?lt.repeat(t):ct[t]=e},run(t,e){const s=pt.list[t];s?s(e):lt.error("no",t)}},{list:ct}=pt;pt.register("draw",dt),pt.register("user",dt),pt.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.zoomLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:o,max:r}=i.app.config.zoom;let{scale:a}=t;a*Math.abs(s)<o?a=o/s:a*Math.abs(s)>r&&(a=r/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const ut={},yt={},vt={},gt={},ft={},wt={},mt={},xt=i.get("UIData");class Rt extends o{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){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,xt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,xt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=mt)):(this.__isFills&&(this.__removeInput("fill"),yt.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=mt)):(this.__isStrokes&&(this.__removeInput("stroke"),yt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const kt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class Bt extends Rt{}class St extends Bt{get __boxStroke(){return!0}}class bt extends Bt{}class Ct extends St{}class At extends Rt{}class Pt extends Rt{get __boxStroke(){return!0}}class Et extends Rt{get __boxStroke(){return!0}}class Lt extends Rt{}class Ft extends Rt{}const{parse:Dt}=r;class Tt extends Rt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Dt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class zt extends Bt{}const Mt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Wt extends Rt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Mt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class It extends Pt{}class Ot extends Pt{}function Ht(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function Vt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const Nt={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:o,strokeWidth:r}=this.__;if((s||"all"===i)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(r)-t:0,o="none"===s?0:r;t+=Math.max(i,o)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,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)})),i&&(t=Math.max(t,i));let r=t=Math.ceil(t);return s&&s.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}},Yt={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this;"miniapp"===_.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:o}=this.__,r=s&&"path"===i||"all"===i,a=e.hitFill(t,o);if(r&&a)return!0;const{stroke:h,hitStroke:n,strokeWidth:d,strokeAlign:l}=this.__,p=h&&"path"===n||"all"===n,c=2*t.radiusX;let u=c;if(p)switch(l){case"inside":if(u+=2*d,!r&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!r){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||i||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&yt.fill(s,this,t),o&&this.__drawAfterFill(t,e),i&&yt.stroke(i,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const r=yt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&ut.shadow(this,t,r,e),s&&(this.__.__isFills?yt.fills(s,this,t):yt.fill(s,this,t)),o&&this.__drawAfterFill(t,e),h&&ut.innerShadow(this,t,r,e),i&&(this.__.__isStrokes?yt.strokes(i,this,t,e):yt.stroke(i,this,t,e)),r.worldCanvas&&r.worldCanvas.recycle(),r.canvas.recycle()}else s&&(this.__.__isFills?yt.fills(s,this,t):yt.fill(s,this,t)),o&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?yt.strokes(i,this,t,e):yt.stroke(i,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?yt.fills(s,this,t):yt.fill("#000000",this,t)),i&&(this.__.__pixelStroke?yt.strokes(i,this,t,e):yt.stroke("#000000",this,t,e))}},jt={__drawFast(t,e){const{width:s,height:i,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-o,i-o);break;case"outside":t.strokeRect(-a,-a,s+o,i+o)}}}};var Ut;let Gt=Ut=class extends b{get app(){return this.leafer&&this.leafer.app}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}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(t){const{path:e}=this.__;return e?t?r.toCanvasData(e,!0):e:[]}getPathString(t){return r.stringify(this.getPath(t))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&yt.compute("fill",this),e&&yt.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:i,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,i,o,this.__.cornerRadius):t.rect(e,s,i,o)}export(t,e){return wt.export(this,t,e)}clone(){return Ut.one(this.toJSON())}static one(t,e,s,i,o){return L.get(t.tag||this.prototype.__tag,t,e,s,i,o)}destroy(){this.fill=this.stroke=null,super.destroy()}};nt([n(Rt)],Gt.prototype,"__",void 0),nt([d("")],Gt.prototype,"id",void 0),nt([d("")],Gt.prototype,"name",void 0),nt([d("")],Gt.prototype,"className",void 0),nt([l("pass-through")],Gt.prototype,"blendMode",void 0),nt([p(1)],Gt.prototype,"opacity",void 0),nt([p(!0)],Gt.prototype,"visible",void 0),nt([c(!1)],Gt.prototype,"isMask",void 0),nt([u(!1)],Gt.prototype,"isEraser",void 0),nt([d(!1)],Gt.prototype,"locked",void 0),nt([y(0)],Gt.prototype,"zIndex",void 0),nt([v(0)],Gt.prototype,"x",void 0),nt([v(0)],Gt.prototype,"y",void 0),nt([g(100)],Gt.prototype,"width",void 0),nt([g(100)],Gt.prototype,"height",void 0),nt([f(1)],Gt.prototype,"scaleX",void 0),nt([f(1)],Gt.prototype,"scaleY",void 0),nt([w(0)],Gt.prototype,"rotation",void 0),nt([w(0)],Gt.prototype,"skewX",void 0),nt([w(0)],Gt.prototype,"skewY",void 0),nt([m()],Gt.prototype,"around",void 0),nt([d(!1)],Gt.prototype,"draggable",void 0),nt([d(!1)],Gt.prototype,"editable",void 0),nt([d("size")],Gt.prototype,"editSize",void 0),nt([x(!0)],Gt.prototype,"hittable",void 0),nt([x("path")],Gt.prototype,"hitFill",void 0),nt([R("path")],Gt.prototype,"hitStroke",void 0),nt([x(!1)],Gt.prototype,"hitBox",void 0),nt([x(!0)],Gt.prototype,"hitChildren",void 0),nt([x(!0)],Gt.prototype,"hitSelf",void 0),nt([x()],Gt.prototype,"hitRadius",void 0),nt([k("")],Gt.prototype,"cursor",void 0),nt([l()],Gt.prototype,"fill",void 0),nt([R()],Gt.prototype,"stroke",void 0),nt([R("inside")],Gt.prototype,"strokeAlign",void 0),nt([R(1)],Gt.prototype,"strokeWidth",void 0),nt([R("none")],Gt.prototype,"strokeCap",void 0),nt([R("miter")],Gt.prototype,"strokeJoin",void 0),nt([R()],Gt.prototype,"dashPattern",void 0),nt([R()],Gt.prototype,"dashOffset",void 0),nt([R(10)],Gt.prototype,"miterLimit",void 0),nt([B(0)],Gt.prototype,"cornerRadius",void 0),nt([B()],Gt.prototype,"cornerSmoothing",void 0),nt([Ht()],Gt.prototype,"shadow",void 0),nt([Ht()],Gt.prototype,"innerShadow",void 0),nt([Ht()],Gt.prototype,"blur",void 0),nt([Ht()],Gt.prototype,"backgroundBlur",void 0),nt([Ht()],Gt.prototype,"grayscale",void 0),nt([S(b.prototype.reset)],Gt.prototype,"reset",null),nt([S(C.drawPathByData)],Gt.prototype,"__drawPathByData",null),Gt=Ut=nt([A(Nt),A(Yt),A(Xt),P()],Gt);const Jt=F.get();let $t=class extends Gt{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let s;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{s=L.get(t.tag,t),this.add(s)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let i=0;i<s.length;i++)Jt.a=t,Jt.d=e,s[i].transform(Jt,!0)}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){}};nt([n(Bt)],$t.prototype,"__",void 0),$t=nt([A(D),T()],$t);let qt=class extends Gt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}};nt([n(Pt)],qt.prototype,"__",void 0),nt([S(Gt.prototype.__drawPathByBox)],qt.prototype,"__drawPathByData",null),qt=nt([A(jt),P(),T()],qt);const Kt=qt.prototype,Zt=$t.prototype,Qt={},{copy:te,add:ee}=M;let se=class extends $t{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;te(Qt,t),super.__updateRenderBounds(),ee(t,Qt)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};nt([n(St)],se.prototype,"__",void 0),nt([z("show")],se.prototype,"overflow",void 0),nt([S(Kt.__updateStrokeSpread)],se.prototype,"__updateStrokeSpread",null),nt([S(Kt.__updateRenderSpread)],se.prototype,"__updateRectRenderSpread",null),nt([S(Kt.__updateBoxBounds)],se.prototype,"__updateRectBoxBounds",null),nt([S(Kt.__updateStrokeBounds)],se.prototype,"__updateStrokeBounds",null),nt([S(Kt.__updateRenderBounds)],se.prototype,"__updateRectRenderBounds",null),nt([S(Kt.__updateChange)],se.prototype,"__updateRectChange",null),nt([S(Kt.__drawPathByData)],se.prototype,"__drawPathByData",null),nt([S(Kt.__render)],se.prototype,"__renderRect",null),nt([S(Zt.__render)],se.prototype,"__renderGroup",null),se=nt([P(),T()],se);let ie=class extends se{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}};nt([n(Ct)],ie.prototype,"__",void 0),nt([z("hide")],ie.prototype,"overflow",void 0),ie=nt([T()],ie);const{moveTo:oe,closePath:re,ellipse:ae}=W;let he=class extends Gt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:o}=this.__,r=t/2,a=e/2,h=this.__.path=[];s?(i||o?(s<1&&ae(h,r,a,r*s,a*s,0,i,o,!1),ae(h,r,a,r,a,0,o,i,!0),s<1&&re(h)):(s<1&&(ae(h,r,a,r*s,a*s),oe(h,t,a)),ae(h,r,a,r,a,0,360,0,!0)),_.ellipseToCurve&&(this.__.path=this.getPath(!0))):i||o?(oe(h,r,a),ae(h,r,a,r,a,0,i,o,!1),re(h)):ae(h,r,a,r,a)}};nt([n(Et)],he.prototype,"__",void 0),nt([B(0)],he.prototype,"innerRadius",void 0),nt([B(0)],he.prototype,"startAngle",void 0),nt([B(0)],he.prototype,"endAngle",void 0),he=nt([T()],he);const{moveTo:_e,lineTo:ne,drawPoints:de}=W,{rotate:le,getAngle:pe,getDistance:ce,defaultPoint:ue}=H,{toBounds:ye}=V;let ve=class extends Gt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&le(s,e),s}set toPoint(t){this.width=ce(ue,t),this.rotation=pe(ue,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?de(t,this.__.points,!1):(_e(t,0,0),ne(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?de(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?ye(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(t,e){if(this.points)O.scalePoints(this.__.points,t,e),this.points=this.__.points;else if("Line"===this.__tag){const s=this.toPoint;s.x*=t,s.y*=e,this.toPoint=s}else super.__scaleResize(t,e)}};nt([n(At)],ve.prototype,"__",void 0),nt([I("center")],ve.prototype,"strokeAlign",void 0),nt([g(0)],ve.prototype,"height",void 0),nt([B()],ve.prototype,"points",void 0),nt([B(0)],ve.prototype,"curve",void 0),ve=nt([T()],ve);const{sin:ge,cos:fe,PI:we}=Math,{moveTo:me,lineTo:xe,closePath:Re,drawPoints:ke}=W,Be=ve.prototype;let Se=class extends Gt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)ke(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,o=e/2,r=s/2;me(t,o,0);for(let e=1;e<i;e++)xe(t,o+o*ge(2*e*we/i),r-r*fe(2*e*we/i))}Re(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}};nt([n(Lt)],Se.prototype,"__",void 0),nt([B(3)],Se.prototype,"sides",void 0),nt([B()],Se.prototype,"points",void 0),nt([B(0)],Se.prototype,"curve",void 0),nt([S(Be.__updateRenderPath)],Se.prototype,"__updateRenderPath",null),nt([S(Be.__updateBoxBounds)],Se.prototype,"__updateBoxBounds",null),nt([S(Be.__scaleResize)],Se.prototype,"__scaleResize",null),Se=nt([P(),T()],Se);const{sin:be,cos:Ce,PI:Ae}=Math,{moveTo:Pe,lineTo:Ee,closePath:Le}=W;let Fe=class extends Gt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,o=t/2,r=e/2,a=this.__.path=[];Pe(a,o,0);for(let t=1;t<2*s;t++)Ee(a,o+(t%2==0?o:o*i)*be(t*Ae/s),r-(t%2==0?r:r*i)*Ce(t*Ae/s));Le(a)}};nt([n(Ft)],Fe.prototype,"__",void 0),nt([B(5)],Fe.prototype,"corners",void 0),nt([B(.382)],Fe.prototype,"innerRadius",void 0),Fe=nt([T()],Fe);let De=class extends qt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let t;const{url:e}=this,s=this.fill;s?s.url!==e&&(t=!0):e&&(t=!0),t&&(this.image&&(this.image=null),this.fill=e?{type:"image",mode:"strench",url:e}:void 0,this.once(N.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}};nt([n(It)],De.prototype,"__",void 0),nt([g("")],De.prototype,"url",void 0),De=nt([T()],De);let Te=class extends qt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=Y.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.update();const o=new X(t.__world);o.invert();const r=new X;e&&r.translate(e.x,e.y),s&&("number"==typeof s?r.scale(s):r.scale(s.x,s.y)),i&&r.rotate(i),o.multiplyParent(r),t.__render(this.canvas,{matrix:o}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,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()}};nt([n(It)],Te.prototype,"__",void 0),nt([Vt(100)],Te.prototype,"width",void 0),nt([Vt(100)],Te.prototype,"height",void 0),nt([Vt(_.devicePixelRatio)],Te.prototype,"pixelRatio",void 0),nt([Vt(!0)],Te.prototype,"smooth",void 0),nt([x("all")],Te.prototype,"hitFill",void 0),Te=nt([T()],Te);const{copyAndSpread:ze,includes:Me,spread:We,setList:Ie}=M;let Oe=class extends Gt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:o,height:r}=this.__layout.boxBounds;t.rect(s,i,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=gt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:o,fontSize:r,fontWeight:a,italic:h,textCase:_,textOverflow:n,padding:d}=t,l=t.__autoWidth,p=t.__autoHeight;t.__lineHeight=kt.number(s,r),t.__letterSpacing=kt.number(i,r),t.__padding=d?j.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==n&&!t.__autoBounds,this.__updateTextDrawData();const{bounds:c}=t.__textDrawData,u=e.boxBounds;if(t.__lineHeight<r&&We(c,r/2),l||p){if(u.x=l?c.x:0,u.y=p?c.y:0,u.width=l?c.width:t.width,u.height=p?c.height:t.height,d){const[e,s,i,o]=t.__padding;l&&(u.x-=o,u.width+=s+o),p&&(u.y-=e,u.height+=i+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const y=Me(u,c)?u:c;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Ie(t.__textBoxBounds={},[u,c])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ze(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};nt([n(Wt)],Oe.prototype,"__",void 0),nt([g(0)],Oe.prototype,"width",void 0),nt([g(0)],Oe.prototype,"height",void 0),nt([g(0)],Oe.prototype,"padding",void 0),nt([l("#000000")],Oe.prototype,"fill",void 0),nt([I("outside")],Oe.prototype,"strokeAlign",void 0),nt([x("all")],Oe.prototype,"hitFill",void 0),nt([g("")],Oe.prototype,"text",void 0),nt([g("L")],Oe.prototype,"fontFamily",void 0),nt([g(12)],Oe.prototype,"fontSize",void 0),nt([g("normal")],Oe.prototype,"fontWeight",void 0),nt([g(!1)],Oe.prototype,"italic",void 0),nt([g("none")],Oe.prototype,"textCase",void 0),nt([g("none")],Oe.prototype,"textDecoration",void 0),nt([g(0)],Oe.prototype,"letterSpacing",void 0),nt([g({type:"percent",value:150})],Oe.prototype,"lineHeight",void 0),nt([g(0)],Oe.prototype,"paraIndent",void 0),nt([g(0)],Oe.prototype,"paraSpacing",void 0),nt([g("left")],Oe.prototype,"textAlign",void 0),nt([g("top")],Oe.prototype,"verticalAlign",void 0),nt([g("normal")],Oe.prototype,"textWrap",void 0),nt([g("show")],Oe.prototype,"textOverflow",void 0),Oe=nt([T()],Oe);const{toBounds:He}=V;let Ve=class extends Gt{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(t,e){O.scale(this.__.path,t,e),this.path=this.__.path}__updateBoxBounds(){He(this.__.path,this.__layout.boxBounds)}};nt([n(Tt)],Ve.prototype,"__",void 0),nt([B()],Ve.prototype,"path",void 0),nt([B()],Ve.prototype,"windingRule",void 0),nt([I("center")],Ve.prototype,"strokeAlign",void 0),Ve=nt([T()],Ve);let Ne=class extends $t{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ve(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,s,i,o,r){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,o){return this}ellipse(t,e,s,i,o,r,a,h){return this}arc(t,e,s,i,o,r){return this}arcTo(t,e,s,i,o){return this}drawEllipse(t,e,s,i,o,r,a,h){return this}drawArc(t,e,s,i,o,r){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};nt([n(zt)],Ne.prototype,"__",void 0),Ne=nt([A(U,["beginPath"]),T()],Ne);const Ye=i.get("Leafer");let Xe=class extends $t{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&G.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&J.assign(this.config,t);const{config:i}=this;pt.run(i.type,this),this.canvas=Y.canvas(i),this.__controllers.push(this.renderer=Y.renderer(this,this.canvas,i),this.watcher=Y.watcher(this,i),this.layouter=Y.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=Y.selector(this),this.__controllers.unshift(this.interaction=Y.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new $,this.hitCanvasManager=new q,s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),K.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Z.RESTART):this.emitLeafer(Z.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(Z.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=J.copyAttrs({},t,Q);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=J.copyAttrs({},this.canvas,Q);this.canvas.resize(t),this.__onResize(new tt(t,e))}__onResize(t){this.emitEvent(t),J.copyAttrs(this.__,t,Q),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.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new et(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(Q.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Q.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=J.copyAttrs({},this.canvas,Q);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Z.BEFORE_READY),this.emitLeafer(Z.READY),this.emitLeafer(Z.AFTER_READY),st.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Z.VIEW_READY),st.run(this.__viewReadyWait))}__onAnimateFrame(){if(this.viewReady){this.__nextRenderWait.length&&st.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(Z.VIEW_COMPLETED),st.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t){this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Z(t,this))}__listenEvents(){const t=it.start("FirstCreate "+this.innerName);this.once(Z.START,(()=>it.end(t))),this.once(ot.END,(()=>this.__onReady())),this.once(rt.START,(()=>this.__onCreated())),this.once(rt.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(at.DATA,this.__onWatchData,this),this.on_(ht.FRAME,this.__onAnimateFrame,this),this.on_(ot.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new Z(Z.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{G.clearRecycled()}),100)}catch(t){Ye.error(t)}}))}};nt([n(bt)],Xe.prototype,"__",void 0),nt([g()],Xe.prototype,"pixelRatio",void 0),Xe=nt([T()],Xe);let je=class extends Xe{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){if(super(t,e),t){const{ground:e,tree:s,sky:i,editor:o}=t;e&&(this.ground=this.addLeafer(e)),(s||o)&&(this.tree=this.addLeafer(s)),(i||o)&&(this.sky=this.addLeafer(i||{type:"draw",usePartRender:!1})),o&&(this.editor=Y.editor(o),this.sky.add(this.editor))}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:s}=this.config;e||s===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(_t.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new Xe(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){i.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&J.assign(e,t),this.autoLayout&&J.copyAttrs(e,this,Q),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(ot.END,(()=>this.__onReady())),t.once(rt.START,(()=>this.__onCreated())),t.once(rt.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(rt.END,this.__onChildRenderEnd,this))}};je=nt([T()],je);export{vt as Animate,je as App,se as Box,St as BoxData,Te as Canvas,Ot as CanvasData,ft as ColorConvert,ut as Effect,he as Ellipse,Et as EllipseData,wt as Export,ie as Frame,Ct as FrameData,$t as Group,Bt as GroupData,De as Image,It as ImageData,Xe as Leafer,bt as LeaferData,pt as LeaferTypeCreator,ve as Line,At as LineData,yt as Paint,Ve as Path,Tt as PathData,Ne as Pen,zt as PenData,Se as Polygon,Lt as PolygonData,qt as Rect,Pt as RectData,jt as RectRender,Fe as Star,Ft as StarData,Oe as Text,gt as TextConvert,Wt as TextData,Gt as UI,Nt as UIBounds,Rt as UIData,Yt as UIHit,Xt as UIRender,kt as UnitConvert,Ht as effectType,Vt as resizeType};
1
+ import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as o,PathConvert as r,defineLeafAttr as a,OneRadian as h,Platform as _,dataProcessor as n,dataType as d,surfaceType as l,opacityType as p,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,autoLayoutType as m,hitType as x,strokeType as R,cursorType as k,pathType as B,rewrite as S,Leaf as b,PathDrawer as C,useModule as A,rewriteAble as P,PathCreator as E,PathCorner as F,UICreator as L,MatrixHelper as D,Branch as T,registerUI as z,affectRenderBoundsType as M,BoundsHelper as W,PathCommandDataHelper as I,affectStrokeBoundsType as O,PathScaler as H,PointHelper as V,PathBounds as N,ImageEvent as Y,Creator as U,Matrix as X,MathHelper as j,ImageManager as G,DataHelper as J,CanvasManager as $,HitCanvasManager as q,PluginManager as K,LeaferEvent as Z,canvasSizeAttrs as Q,ResizeEvent as tt,AutoBounds as et,WaitHelper as st,Run as it,LayoutEvent as ot,RenderEvent as rt,WatchEvent as at,AnimateEvent as ht,PropertyEvent as _t}from"@leafer/core";export*from"@leafer/core";function nt(t,e,s,i){var o,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(a=(r<3?o(a):r>3?o(e,s,a):o(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}function dt(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const lt=i.get("LeaferTypeCreator"),pt={list:{},register(t,e){ct[t]?lt.repeat(t):ct[t]=e},run(t,e){const s=pt.list[t];s?s(e):lt.error("no",t)}},{list:ct}=pt;pt.register("draw",dt),pt.register("user",dt),pt.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.zoomLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:o,max:r}=i.app.config.zoom;let{scale:a}=t;a*Math.abs(s)<o?a=o/s:a*Math.abs(s)>r&&(a=r/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const ut={},yt={},vt={},gt={},ft={},wt={},mt={},xt=i.get("UIData");class Rt extends o{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){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,xt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,xt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=mt)):(this.__isFills&&(this.__removeInput("fill"),yt.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=mt)):(this.__isStrokes&&(this.__removeInput("stroke"),yt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const kt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class Bt extends Rt{}class St extends Bt{get __boxStroke(){return!0}}class bt extends Bt{}class Ct extends St{}class At extends Rt{}class Pt extends At{}class Et extends Rt{get __boxStroke(){return!0}}class Ft extends Rt{get __boxStroke(){return!0}}class Lt extends Rt{}class Dt extends Rt{}const{parse:Tt}=r;class zt extends Rt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Tt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class Mt extends Bt{}const Wt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class It extends Rt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Wt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ot extends Et{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 Ht extends Et{}function Vt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function Nt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const Yt={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:o,strokeWidth:r}=this.__;if((s||"all"===i)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(r)-t:0,o="none"===s?0:r;t+=Math.max(i,o)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,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)})),i&&(t=Math.max(t,i));let r=t=Math.ceil(t);return s&&s.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}},Ut={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this;"miniapp"===_.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:o}=this.__,r=s&&"path"===i||"all"===i,a=e.hitFill(t,o);if(r&&a)return!0;const{stroke:h,hitStroke:n,strokeWidth:d,strokeAlign:l}=this.__,p=h&&"path"===n||"all"===n,c=2*t.radiusX;let u=c;if(p)switch(l){case"inside":if(u+=2*d,!r&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!r){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||i||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&yt.fill(s,this,t),o&&this.__drawAfterFill(t,e),i&&yt.stroke(i,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const r=yt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&ut.shadow(this,t,r,e),s&&(this.__.__isFills?yt.fills(s,this,t):yt.fill(s,this,t)),o&&this.__drawAfterFill(t,e),h&&ut.innerShadow(this,t,r,e),i&&(this.__.__isStrokes?yt.strokes(i,this,t,e):yt.stroke(i,this,t,e)),r.worldCanvas&&r.worldCanvas.recycle(),r.canvas.recycle()}else s&&(this.__.__isFills?yt.fills(s,this,t):yt.fill(s,this,t)),o&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?yt.strokes(i,this,t,e):yt.stroke(i,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?yt.fills(s,this,t):yt.fill("#000000",this,t)),i&&(this.__.__pixelStroke?yt.strokes(i,this,t,e):yt.stroke("#000000",this,t,e))}},jt={__drawFast(t,e){const{width:s,height:i,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-o,i-o);break;case"outside":t.strokeRect(-a,-a,s+o,i+o)}}}};var Gt;let Jt=Gt=class extends b{get app(){return this.leafer&&this.leafer.app}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}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(t,e){this.__layout.update();let s=e?this.__.__pathForRender:this.__.path;return s||this.__drawPathByBox(new E(s=[])),t?r.toCanvasData(s,!0):s}getPathString(t,e){return r.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&yt.compute("fill",this),e&&yt.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:i,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,i,o,this.__.cornerRadius):t.rect(e,s,i,o)}export(t,e){return wt.export(this,t,e)}clone(){return Gt.one(this.toJSON())}static one(t,e,s,i,o){return L.get(t.tag||this.prototype.__tag,t,e,s,i,o)}destroy(){this.fill=this.stroke=null,super.destroy()}};nt([n(Rt)],Jt.prototype,"__",void 0),nt([d("")],Jt.prototype,"id",void 0),nt([d("")],Jt.prototype,"name",void 0),nt([d("")],Jt.prototype,"className",void 0),nt([l("pass-through")],Jt.prototype,"blendMode",void 0),nt([p(1)],Jt.prototype,"opacity",void 0),nt([p(!0)],Jt.prototype,"visible",void 0),nt([c(!1)],Jt.prototype,"isMask",void 0),nt([u(!1)],Jt.prototype,"isEraser",void 0),nt([d(!1)],Jt.prototype,"locked",void 0),nt([y(0)],Jt.prototype,"zIndex",void 0),nt([v(0)],Jt.prototype,"x",void 0),nt([v(0)],Jt.prototype,"y",void 0),nt([g(100)],Jt.prototype,"width",void 0),nt([g(100)],Jt.prototype,"height",void 0),nt([f(1)],Jt.prototype,"scaleX",void 0),nt([f(1)],Jt.prototype,"scaleY",void 0),nt([w(0)],Jt.prototype,"rotation",void 0),nt([w(0)],Jt.prototype,"skewX",void 0),nt([w(0)],Jt.prototype,"skewY",void 0),nt([m()],Jt.prototype,"around",void 0),nt([d(!1)],Jt.prototype,"draggable",void 0),nt([d(!1)],Jt.prototype,"editable",void 0),nt([d("size")],Jt.prototype,"editSize",void 0),nt([x(!0)],Jt.prototype,"hittable",void 0),nt([x("path")],Jt.prototype,"hitFill",void 0),nt([R("path")],Jt.prototype,"hitStroke",void 0),nt([x(!1)],Jt.prototype,"hitBox",void 0),nt([x(!0)],Jt.prototype,"hitChildren",void 0),nt([x(!0)],Jt.prototype,"hitSelf",void 0),nt([x()],Jt.prototype,"hitRadius",void 0),nt([k("")],Jt.prototype,"cursor",void 0),nt([l()],Jt.prototype,"fill",void 0),nt([R()],Jt.prototype,"stroke",void 0),nt([R("inside")],Jt.prototype,"strokeAlign",void 0),nt([R(1)],Jt.prototype,"strokeWidth",void 0),nt([R("none")],Jt.prototype,"strokeCap",void 0),nt([R("miter")],Jt.prototype,"strokeJoin",void 0),nt([R()],Jt.prototype,"dashPattern",void 0),nt([R()],Jt.prototype,"dashOffset",void 0),nt([R(10)],Jt.prototype,"miterLimit",void 0),nt([R("none")],Jt.prototype,"startArrow",void 0),nt([R("none")],Jt.prototype,"endArrow",void 0),nt([B(0)],Jt.prototype,"cornerRadius",void 0),nt([B()],Jt.prototype,"cornerSmoothing",void 0),nt([Vt()],Jt.prototype,"shadow",void 0),nt([Vt()],Jt.prototype,"innerShadow",void 0),nt([Vt()],Jt.prototype,"blur",void 0),nt([Vt()],Jt.prototype,"backgroundBlur",void 0),nt([Vt()],Jt.prototype,"grayscale",void 0),nt([S(b.prototype.reset)],Jt.prototype,"reset",null),nt([S(C.drawPathByData)],Jt.prototype,"__drawPathByData",null),Jt=Gt=nt([A(Yt),A(Ut),A(Xt),P()],Jt);const $t=D.get();let qt=class extends Jt{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let s;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{s=L.get(t.tag,t),this.add(s)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let i=0;i<s.length;i++)$t.a=t,$t.d=e,s[i].transform($t,!0)}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){}};nt([n(Bt)],qt.prototype,"__",void 0),qt=nt([A(T),z()],qt);let Kt=class extends Jt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}};nt([n(Et)],Kt.prototype,"__",void 0),nt([S(Jt.prototype.__drawPathByBox)],Kt.prototype,"__drawPathByData",null),Kt=nt([A(jt),P(),z()],Kt);const Zt=Kt.prototype,Qt=qt.prototype,te={},{copy:ee,add:se}=W;let ie=class extends qt{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;ee(te,t),super.__updateRenderBounds(),se(t,te)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};nt([n(St)],ie.prototype,"__",void 0),nt([M("show")],ie.prototype,"overflow",void 0),nt([S(Zt.__updateStrokeSpread)],ie.prototype,"__updateStrokeSpread",null),nt([S(Zt.__updateRenderSpread)],ie.prototype,"__updateRectRenderSpread",null),nt([S(Zt.__updateBoxBounds)],ie.prototype,"__updateRectBoxBounds",null),nt([S(Zt.__updateStrokeBounds)],ie.prototype,"__updateStrokeBounds",null),nt([S(Zt.__updateRenderBounds)],ie.prototype,"__updateRectRenderBounds",null),nt([S(Zt.__updateChange)],ie.prototype,"__updateRectChange",null),nt([S(Zt.__drawPathByData)],ie.prototype,"__drawPathByData",null),nt([S(Zt.__render)],ie.prototype,"__renderRect",null),nt([S(Qt.__render)],ie.prototype,"__renderGroup",null),ie=nt([P(),z()],ie);let oe=class extends ie{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}};nt([n(Ct)],oe.prototype,"__",void 0),nt([M("hide")],oe.prototype,"overflow",void 0),oe=nt([z()],oe);const{moveTo:re,closePath:ae,ellipse:he}=I;let _e=class extends Jt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:o}=this.__,r=t/2,a=e/2,h=this.__.path=[];s?(i||o?(s<1&&he(h,r,a,r*s,a*s,0,i,o,!1),he(h,r,a,r,a,0,o,i,!0),s<1&&ae(h)):(s<1&&(he(h,r,a,r*s,a*s),re(h,t,a)),he(h,r,a,r,a,0,360,0,!0)),_.ellipseToCurve&&(this.__.path=this.getPath(!0))):i||o?(re(h,r,a),he(h,r,a,r,a,0,i,o,!1),ae(h)):he(h,r,a,r,a)}};nt([n(Ft)],_e.prototype,"__",void 0),nt([B(0)],_e.prototype,"innerRadius",void 0),nt([B(0)],_e.prototype,"startAngle",void 0),nt([B(0)],_e.prototype,"endAngle",void 0),_e=nt([z()],_e);const{moveTo:ne,lineTo:de,drawPoints:le}=I,{rotate:pe,getAngle:ce,getDistance:ue,defaultPoint:ye}=V,{toBounds:ve}=N;let ge=class extends Jt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&pe(s,e),s}set toPoint(t){this.width=ue(ye,t),this.rotation=ce(ye,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?le(t,this.__.points,!1):(ne(t,0,0),de(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?le(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?ve(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(t,e){if(this.points)H.scalePoints(this.__.points,t,e),this.points=this.__.points;else if("Line"===this.__tag){const s=this.toPoint;s.x*=t,s.y*=e,this.toPoint=s}else super.__scaleResize(t,e)}};nt([n(At)],ge.prototype,"__",void 0),nt([O("center")],ge.prototype,"strokeAlign",void 0),nt([g(0)],ge.prototype,"height",void 0),nt([B()],ge.prototype,"points",void 0),nt([B(0)],ge.prototype,"curve",void 0),ge=nt([z()],ge);const{sin:fe,cos:we,PI:me}=Math,{moveTo:xe,lineTo:Re,closePath:ke,drawPoints:Be}=I,Se=ge.prototype;let be=class extends Jt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Be(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,o=e/2,r=s/2;xe(t,o,0);for(let e=1;e<i;e++)Re(t,o+o*fe(2*e*me/i),r-r*we(2*e*me/i))}ke(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}};nt([n(Lt)],be.prototype,"__",void 0),nt([B(3)],be.prototype,"sides",void 0),nt([B()],be.prototype,"points",void 0),nt([B(0)],be.prototype,"curve",void 0),nt([S(Se.__updateRenderPath)],be.prototype,"__updateRenderPath",null),nt([S(Se.__updateBoxBounds)],be.prototype,"__updateBoxBounds",null),nt([S(Se.__scaleResize)],be.prototype,"__scaleResize",null),be=nt([P(),z()],be);const{sin:Ce,cos:Ae,PI:Pe}=Math,{moveTo:Ee,lineTo:Fe,closePath:Le}=I;let De=class extends Jt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,o=t/2,r=e/2,a=this.__.path=[];Ee(a,o,0);for(let t=1;t<2*s;t++)Fe(a,o+(t%2==0?o:o*i)*Ce(t*Pe/s),r-(t%2==0?r:r*i)*Ae(t*Pe/s));Le(a)}};nt([n(Dt)],De.prototype,"__",void 0),nt([B(5)],De.prototype,"corners",void 0),nt([B(.382)],De.prototype,"innerRadius",void 0),De=nt([z()],De);let Te=class extends Kt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(Y.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};nt([n(Ot)],Te.prototype,"__",void 0),nt([g("")],Te.prototype,"url",void 0),Te=nt([z()],Te);let ze=class extends Kt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=U.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.update();const o=new X(t.__world);o.invert();const r=new X;e&&r.translate(e.x,e.y),s&&("number"==typeof s?r.scale(s):r.scale(s.x,s.y)),i&&r.rotate(i),o.multiplyParent(r),t.__render(this.canvas,{matrix:o}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,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()}};nt([n(Ot)],ze.prototype,"__",void 0),nt([Nt(100)],ze.prototype,"width",void 0),nt([Nt(100)],ze.prototype,"height",void 0),nt([Nt(_.devicePixelRatio)],ze.prototype,"pixelRatio",void 0),nt([Nt(!0)],ze.prototype,"smooth",void 0),nt([x("all")],ze.prototype,"hitFill",void 0),ze=nt([z()],ze);const{copyAndSpread:Me,includes:We,spread:Ie,setList:Oe}=W;let He=class extends Jt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:o,height:r}=this.__layout.boxBounds;t.rect(s,i,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=gt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:o,fontSize:r,fontWeight:a,italic:h,textCase:_,textOverflow:n,padding:d}=t,l=t.__autoWidth,p=t.__autoHeight;t.__lineHeight=kt.number(s,r),t.__letterSpacing=kt.number(i,r),t.__padding=d?j.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==n&&!t.__autoBounds,this.__updateTextDrawData();const{bounds:c}=t.__textDrawData,u=e.boxBounds;if(t.__lineHeight<r&&Ie(c,r/2),l||p){if(u.x=l?c.x:0,u.y=p?c.y:0,u.width=l?c.width:t.width,u.height=p?c.height:t.height,d){const[e,s,i,o]=t.__padding;l&&(u.x-=o,u.width+=s+o),p&&(u.y-=e,u.height+=i+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const y=We(u,c)?u:c;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Oe(t.__textBoxBounds={},[u,c])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Me(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};nt([n(It)],He.prototype,"__",void 0),nt([g(0)],He.prototype,"width",void 0),nt([g(0)],He.prototype,"height",void 0),nt([g(0)],He.prototype,"padding",void 0),nt([l("#000000")],He.prototype,"fill",void 0),nt([O("outside")],He.prototype,"strokeAlign",void 0),nt([x("all")],He.prototype,"hitFill",void 0),nt([g("")],He.prototype,"text",void 0),nt([g("L")],He.prototype,"fontFamily",void 0),nt([g(12)],He.prototype,"fontSize",void 0),nt([g("normal")],He.prototype,"fontWeight",void 0),nt([g(!1)],He.prototype,"italic",void 0),nt([g("none")],He.prototype,"textCase",void 0),nt([g("none")],He.prototype,"textDecoration",void 0),nt([g(0)],He.prototype,"letterSpacing",void 0),nt([g({type:"percent",value:150})],He.prototype,"lineHeight",void 0),nt([g(0)],He.prototype,"paraIndent",void 0),nt([g(0)],He.prototype,"paraSpacing",void 0),nt([g("left")],He.prototype,"textAlign",void 0),nt([g("top")],He.prototype,"verticalAlign",void 0),nt([g("normal")],He.prototype,"textWrap",void 0),nt([g("show")],He.prototype,"textOverflow",void 0),He=nt([z()],He);const{toBounds:Ve}=N;let Ne=class extends Jt{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(t,e){H.scale(this.__.path,t,e),this.path=this.__.path}__updateBoxBounds(){Ve(this.__.path,this.__layout.boxBounds)}};nt([n(zt)],Ne.prototype,"__",void 0),nt([B()],Ne.prototype,"path",void 0),nt([B()],Ne.prototype,"windingRule",void 0),nt([O("center")],Ne.prototype,"strokeAlign",void 0),Ne=nt([z()],Ne);let Ye=class extends qt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ne(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,s,i,o,r){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,o){return this}ellipse(t,e,s,i,o,r,a,h){return this}arc(t,e,s,i,o,r){return this}arcTo(t,e,s,i,o){return this}drawEllipse(t,e,s,i,o,r,a,h){return this}drawArc(t,e,s,i,o,r){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};nt([n(Mt)],Ye.prototype,"__",void 0),Ye=nt([A(E,["beginPath"]),z()],Ye);const Ue=i.get("Leafer");let Xe=class extends qt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&G.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&J.assign(this.config,t);const{config:i}=this;pt.run(i.type,this),this.canvas=U.canvas(i),this.__controllers.push(this.renderer=U.renderer(this,this.canvas,i),this.watcher=U.watcher(this,i),this.layouter=U.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=U.selector(this),this.__controllers.unshift(this.interaction=U.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new $,this.hitCanvasManager=new q,s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),K.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Z.RESTART):this.emitLeafer(Z.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(Z.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=J.copyAttrs({},t,Q);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=J.copyAttrs({},this.canvas,Q);this.canvas.resize(t),this.__onResize(new tt(t,e))}__onResize(t){this.emitEvent(t),J.copyAttrs(this.__,t,Q),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.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new et(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(Q.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Q.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=J.copyAttrs({},this.canvas,Q);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Z.BEFORE_READY),this.emitLeafer(Z.READY),this.emitLeafer(Z.AFTER_READY),st.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Z.VIEW_READY),st.run(this.__viewReadyWait))}__onAnimateFrame(){if(this.viewReady){this.__nextRenderWait.length&&st.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(Z.VIEW_COMPLETED),st.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t){this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Z(t,this))}__listenEvents(){const t=it.start("FirstCreate "+this.innerName);this.once(Z.START,(()=>it.end(t))),this.once(ot.END,(()=>this.__onReady())),this.once(rt.START,(()=>this.__onCreated())),this.once(rt.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(at.DATA,this.__onWatchData,this),this.on_(ht.FRAME,this.__onAnimateFrame,this),this.on_(ot.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new Z(Z.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{G.clearRecycled()}),100)}catch(t){Ue.error(t)}}))}};nt([n(bt)],Xe.prototype,"__",void 0),nt([g()],Xe.prototype,"pixelRatio",void 0),Xe=nt([z()],Xe);let je=class extends Xe{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){if(super(t,e),t){const{ground:e,tree:s,sky:i,editor:o}=t;e&&(this.ground=this.addLeafer(e)),(s||o)&&(this.tree=this.addLeafer(s)),(i||o)&&(this.sky=this.addLeafer(i||{type:"draw",usePartRender:!1})),o&&(this.editor=U.editor(o),this.sky.add(this.editor))}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:s}=this.config;e||s===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(_t.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new Xe(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){i.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&J.assign(e,t),this.autoLayout&&J.copyAttrs(e,this,Q),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(ot.END,(()=>this.__onReady())),t.once(rt.START,(()=>this.__onCreated())),t.once(rt.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(rt.END,this.__onChildRenderEnd,this))}};je=nt([z()],je);export{vt as Animate,je as App,Pt as ArrowData,ie as Box,St as BoxData,ze as Canvas,Ht as CanvasData,ft as ColorConvert,ut as Effect,_e as Ellipse,Ft as EllipseData,wt as Export,oe as Frame,Ct as FrameData,qt as Group,Bt as GroupData,Te as Image,Ot as ImageData,Xe as Leafer,bt as LeaferData,pt as LeaferTypeCreator,ge as Line,At as LineData,yt as Paint,Ne as Path,zt as PathData,Ye as Pen,Mt as PenData,be as Polygon,Lt as PolygonData,Kt as Rect,Et as RectData,jt as RectRender,De as Star,Dt as StarData,He as Text,gt as TextConvert,It as TextData,Jt as UI,Yt as UIBounds,Rt as UIData,Ut as UIHit,Xt as UIRender,kt as UnitConvert,Vt as effectType,Nt as resizeType};
package/dist/core.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const r=t.Debug.get("LeaferTypeCreator"),o={list:{},register(t,e){i[t]?r.repeat(t):i[t]=e},run(t,e){const s=o.list[t];s?s(e):r.error("no",t)}},{list:i}=o;o.register("draw",s),o.register("user",s),o.register("design",(function(e){e.isApp||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(s=>{t.LeafHelper.moveWorld(e.zoomLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.app.config.zoom;let{scale:a}=s;a*Math.abs(r)<o?a=o/r:a*Math.abs(r)>i&&(a=i/r),1!==a&&t.LeafHelper.zoomOfWorld(e.zoomLayer,s,a)})))}));const a={},n={},h={},p={},_={},d=t.Debug.get("UIData");class l extends t.LeafData{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){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,d.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,d.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=_)):(this.__isFills&&(this.__removeInput("fill"),n.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=_)):(this.__isStrokes&&(this.__removeInput("stroke"),n.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const u={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class c extends l{}class y extends c{get __boxStroke(){return!0}}class x extends c{}class v extends y{}class g extends l{}class f extends l{get __boxStroke(){return!0}}class w extends l{get __boxStroke(){return!0}}class m extends l{}class R extends l{}const{parse:T}=t.PathConvert;class P extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=T(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class B extends c{}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 l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=k[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class b extends f{}function I(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function S(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const E={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},L={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(e){const{__hitCanvas:s}=this;"miniapp"===t.Platform.name&&this.__drawHitPath(s);const{fill:r,hitFill:o,windingRule:i}=this.__,a=r&&"path"===o||"all"===o,n=s.hitFill(e,i);if(a&&n)return!0;const{stroke:h,hitStroke:p,strokeWidth:_,strokeAlign:d}=this.__,l=h&&"path"===p||"all"===p,u=2*e.radiusX;let c=u;if(l)switch(d){case"inside":if(c+=2*_,!a&&n&&s.hitStroke(e,c))return!0;c=u;break;case"center":c+=_;break;case"outside":if(c+=2*_,!a){if(!n&&s.hitStroke(e,c))return!0;c=u}}return!!c&&s.hitStroke(e,c)}},A={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const i=n.shape(this,t,e),{shadow:h,innerShadow:p}=this.__;h&&a.shadow(this,t,i,e),s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t,e):n.stroke("#000000",this,t,e))}},U={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var D;exports.UI=D=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}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}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(e){const{path:s}=this.__;return s?e?t.PathConvert.toCanvasData(s,!0):s:[]}getPathString(e){return t.PathConvert.stringify(this.getPath(e))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&n.compute("fill",this),e&&n.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:e}=this;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return p.export(this,t,e)}clone(){return D.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(l)],exports.UI.prototype,"__",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.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.maskType(!1)],exports.UI.prototype,"isMask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"isEraser",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",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("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([I()],exports.UI.prototype,"shadow",void 0),e([I()],exports.UI.prototype,"innerShadow",void 0),e([I()],exports.UI.prototype,"blur",void 0),e([I()],exports.UI.prototype,"backgroundBlur",void 0),e([I()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=D=e([t.useModule(E),t.useModule(L),t.useModule(A),t.rewriteAble()],exports.UI);const F=t.MatrixHelper.get();exports.Group=class extends exports.UI{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let r=0;r<s.length;r++)F.a=t,F.d=e,s[r].transform(F,!0)}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){}},e([t.dataProcessor(c)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}},e([t.dataProcessor(f)],exports.Rect.prototype,"__",void 0),e([t.rewrite(exports.UI.prototype.__drawPathByBox)],exports.Rect.prototype,"__drawPathByData",null),exports.Rect=e([t.useModule(U),t.rewriteAble(),t.registerUI()],exports.Rect);const M=exports.Rect.prototype,z=exports.Group.prototype,W={},{copy:H,add:O}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;H(W,t),super.__updateRenderBounds(),O(t,W)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(y)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(M.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(M.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(M.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(M.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(M.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(M.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(M.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(M.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(z.__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"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(v)],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:V,closePath:G,ellipse:N}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,h=this.__.path=[];r?(o||i?(r<1&&N(h,a,n,a*r,n*r,0,o,i,!1),N(h,a,n,a,n,0,i,o,!0),r<1&&G(h)):(r<1&&(N(h,a,n,a*r,n*r),V(h,e,n)),N(h,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(V(h,a,n),N(h,a,n,a,n,0,o,i,!1),G(h)):N(h,a,n,a,n)}},e([t.dataProcessor(w)],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:j,lineTo:Y,drawPoints:X}=t.PathCommandDataHelper,{rotate:J,getAngle:$,getDistance:q,defaultPoint:Z}=t.PointHelper,{toBounds:K}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&J(s,e),s}set toPoint(t){this.width=q(Z,t),this.rotation=$(Z,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?X(t,this.__.points,!1):(j(t,0,0),Y(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?X(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?K(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(e,s){if(this.points)t.PathScaler.scalePoints(this.__.points,e,s),this.points=this.__.points;else if("Line"===this.__tag){const t=this.toPoint;t.x*=e,t.y*=s,this.toPoint=t}else super.__scaleResize(e,s)}},e([t.dataProcessor(g)],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),exports.Line=e([t.registerUI()],exports.Line);const{sin:Q,cos:tt,PI:et}=Math,{moveTo:st,lineTo:rt,closePath:ot,drawPoints:it}=t.PathCommandDataHelper,at=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)it(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;st(t,o,0);for(let e=1;e<r;e++)rt(t,o+o*Q(2*e*et/r),i-i*tt(2*e*et/r))}ot(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}},e([t.dataProcessor(m)],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(at.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(at.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),e([t.rewrite(at.__scaleResize)],exports.Polygon.prototype,"__scaleResize",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:nt,cos:ht,PI:pt}=Math,{moveTo:_t,lineTo:dt,closePath:lt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];_t(a,o,0);for(let t=1;t<2*s;t++)dt(a,o+(t%2==0?o:o*r)*nt(t*pt/s),i-(t%2==0?i:i*r)*ht(t*pt/s));lt(a)}},e([t.dataProcessor(R)],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(t){super(t)}__updateBoxBounds(){let e;const{url:s}=this,r=this.fill;r?r.url!==s&&(e=!0):s&&(e=!0),e&&(this.image&&(this.image=null),this.fill=s?{type:"image",mode:"strench",url:s}:void 0,this.once(t.ImageEvent.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(b)],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.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world);i.invert();const a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,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()}},e([t.dataProcessor(b)],exports.Canvas.prototype,"__",void 0),e([S(100)],exports.Canvas.prototype,"width",void 0),e([S(100)],exports.Canvas.prototype,"height",void 0),e([S(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([S(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ut,includes:ct,spread:yt,setList:xt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=h.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:h,textCase:p,textOverflow:_,padding:d}=e,l=e.__autoWidth,c=e.__autoHeight;e.__lineHeight=u.number(r,a),e.__letterSpacing=u.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${h?"italic ":""}${"small-caps"===p?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoBounds,this.__updateTextDrawData();const{bounds:y}=e.__textDrawData,x=s.boxBounds;if(e.__lineHeight<a&&yt(y,a/2),l||c){if(x.x=l?y.x:0,x.y=c?y.y:0,x.width=l?y.width:e.width,x.height=c?y.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(x.x-=o,x.width+=s+o),c&&(x.y-=t,x.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const v=ct(x,y)?x:y;v!==s.contentBounds?(s.contentBounds=v,s.renderChanged=!0,xt(e.__textBoxBounds={},[x,y])):e.__textBoxBounds=v}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ut(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.boundsType(0)],exports.Text.prototype,"padding",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:150})],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);const{toBounds:vt}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(e,s){t.PathScaler.scale(this.__.path,e,s),this.path=this.__.path}__updateBoxBounds(){vt(this.__.path,this.__layout.boxBounds)}},e([t.dataProcessor(P)],exports.Path.prototype,"__",void 0),e([t.pathType()],exports.Path.prototype,"path",void 0),e([t.pathType()],exports.Path.prototype,"windingRule",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,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}},e([t.dataProcessor(B)],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const gt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:i}=this;o.run(i.type,this),this.canvas=t.Creator.canvas(i),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,i),this.watcher=t.Creator.watcher(this,i),this.layouter=t.Creator.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.__controllers.unshift(this.interaction=t.Creator.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new t.CanvasManager,this.hitCanvasManager=new t.HitCanvasManager,r=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.PluginManager.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{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 s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__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))}__onAnimateFrame(){if(this.viewReady){this.__nextRenderWait.length&&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()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t){this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.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.AnimateEvent.FRAME,this.__onAnimateFrame,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)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.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.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){gt.error(t)}}))}},e([t.dataProcessor(x)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.App=class extends exports.Leafer{get __tag(){return"App"}get isApp(){return!0}constructor(e,s){if(super(e,s),e){const{ground:s,tree:r,sky:o,editor:i}=e;s&&(this.ground=this.addLeafer(s)),(r||i)&&(this.tree=this.addLeafer(r)),(o||i)&&(this.sky=this.addLeafer(o||{type:"draw",usePartRender:!1})),i&&(this.editor=t.Creator.editor(i),this.sky.add(this.editor))}}__setApp(){const{canvas:e}=this,{realCanvas:s,view:r}=this.config;s||r===this.canvas.view||!e.parentView?this.realCanvas=!0:e.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(t.PropertyEvent.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new exports.Leafer(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){t.Debug.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(e){let s=Object.assign({},this.config);return s.hittable=s.realCanvas=void 0,e&&t.DataHelper.assign(s,e),this.autoLayout&&t.DataHelper.copyAttrs(s,this,t.canvasSizeAttrs),s.view=this.realCanvas?void 0:this.view,s.fill=void 0,s}__listenChildEvents(e){e.once(t.LayoutEvent.END,(()=>this.__onReady())),e.once(t.RenderEvent.START,(()=>this.__onCreated())),e.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(e.on_(t.RenderEvent.END,this.__onChildRenderEnd,this))}},exports.App=e([t.registerUI()],exports.App),exports.Animate={},exports.BoxData=y,exports.CanvasData=class extends f{},exports.ColorConvert={},exports.Effect=a,exports.EllipseData=w,exports.Export=p,exports.FrameData=v,exports.GroupData=c,exports.ImageData=b,exports.LeaferData=x,exports.LeaferTypeCreator=o,exports.LineData=g,exports.Paint=n,exports.PathData=P,exports.PenData=B,exports.PolygonData=m,exports.RectData=f,exports.RectRender=U,exports.StarData=R,exports.TextConvert=h,exports.TextData=C,exports.UIBounds=E,exports.UIData=l,exports.UIHit=L,exports.UIRender=A,exports.UnitConvert=u,exports.effectType=I,exports.resizeType=S,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const r=t.Debug.get("LeaferTypeCreator"),o={list:{},register(t,e){i[t]?r.repeat(t):i[t]=e},run(t,e){const s=o.list[t];s?s(e):r.error("no",t)}},{list:i}=o;o.register("draw",s),o.register("user",s),o.register("design",(function(e){e.isApp||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(s=>{t.LeafHelper.moveWorld(e.zoomLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.app.config.zoom;let{scale:a}=s;a*Math.abs(r)<o?a=o/r:a*Math.abs(r)>i&&(a=i/r),1!==a&&t.LeafHelper.zoomOfWorld(e.zoomLayer,s,a)})))}));const a={},n={},h={},p={},_={},d=t.Debug.get("UIData");class l extends t.LeafData{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){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,d.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,d.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=_)):(this.__isFills&&(this.__removeInput("fill"),n.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=_)):(this.__isStrokes&&(this.__removeInput("stroke"),n.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const u={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class c extends l{}class y extends c{get __boxStroke(){return!0}}class x extends c{}class v extends y{}class g extends l{}class f extends l{get __boxStroke(){return!0}}class w extends l{get __boxStroke(){return!0}}class m extends l{}class R extends l{}const{parse:T}=t.PathConvert;class P extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=T(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class k extends c{}const I={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class B extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=I[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class C extends f{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}}function b(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function S(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const E={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},A={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(e){const{__hitCanvas:s}=this;"miniapp"===t.Platform.name&&this.__drawHitPath(s);const{fill:r,hitFill:o,windingRule:i}=this.__,a=r&&"path"===o||"all"===o,n=s.hitFill(e,i);if(a&&n)return!0;const{stroke:h,hitStroke:p,strokeWidth:_,strokeAlign:d}=this.__,l=h&&"path"===p||"all"===p,u=2*e.radiusX;let c=u;if(l)switch(d){case"inside":if(c+=2*_,!a&&n&&s.hitStroke(e,c))return!0;c=u;break;case"center":c+=_;break;case"outside":if(c+=2*_,!a){if(!n&&s.hitStroke(e,c))return!0;c=u}}return!!c&&s.hitStroke(e,c)}},L={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const i=n.shape(this,t,e),{shadow:h,innerShadow:p}=this.__;h&&a.shadow(this,t,i,e),s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t,e):n.stroke("#000000",this,t,e))}},U={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var D;exports.UI=D=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}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}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;return r||this.__drawPathByBox(new t.PathCreator(r=[])),e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&n.compute("fill",this),e&&n.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:e}=this;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return p.export(this,t,e)}clone(){return D.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(l)],exports.UI.prototype,"__",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.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.maskType(!1)],exports.UI.prototype,"isMask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"isEraser",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",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("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.strokeType("none")],exports.UI.prototype,"startArrow",void 0),e([t.strokeType("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([b()],exports.UI.prototype,"shadow",void 0),e([b()],exports.UI.prototype,"innerShadow",void 0),e([b()],exports.UI.prototype,"blur",void 0),e([b()],exports.UI.prototype,"backgroundBlur",void 0),e([b()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=D=e([t.useModule(E),t.useModule(A),t.useModule(L),t.rewriteAble()],exports.UI);const F=t.MatrixHelper.get();exports.Group=class extends exports.UI{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let r=0;r<s.length;r++)F.a=t,F.d=e,s[r].transform(F,!0)}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){}},e([t.dataProcessor(c)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}},e([t.dataProcessor(f)],exports.Rect.prototype,"__",void 0),e([t.rewrite(exports.UI.prototype.__drawPathByBox)],exports.Rect.prototype,"__drawPathByData",null),exports.Rect=e([t.useModule(U),t.rewriteAble(),t.registerUI()],exports.Rect);const M=exports.Rect.prototype,z=exports.Group.prototype,W={},{copy:H,add:O}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;H(W,t),super.__updateRenderBounds(),O(t,W)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(y)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(M.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(M.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(M.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(M.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(M.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(M.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(M.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(M.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(z.__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"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(v)],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:V,closePath:N,ellipse:G}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,h=this.__.path=[];r?(o||i?(r<1&&G(h,a,n,a*r,n*r,0,o,i,!1),G(h,a,n,a,n,0,i,o,!0),r<1&&N(h)):(r<1&&(G(h,a,n,a*r,n*r),V(h,e,n)),G(h,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(V(h,a,n),G(h,a,n,a,n,0,o,i,!1),N(h)):G(h,a,n,a,n)}},e([t.dataProcessor(w)],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:j,lineTo:Y,drawPoints:X}=t.PathCommandDataHelper,{rotate:J,getAngle:$,getDistance:q,defaultPoint:Z}=t.PointHelper,{toBounds:K}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&J(s,e),s}set toPoint(t){this.width=q(Z,t),this.rotation=$(Z,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?X(t,this.__.points,!1):(j(t,0,0),Y(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?X(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?K(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(e,s){if(this.points)t.PathScaler.scalePoints(this.__.points,e,s),this.points=this.__.points;else if("Line"===this.__tag){const t=this.toPoint;t.x*=e,t.y*=s,this.toPoint=t}else super.__scaleResize(e,s)}},e([t.dataProcessor(g)],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),exports.Line=e([t.registerUI()],exports.Line);const{sin:Q,cos:tt,PI:et}=Math,{moveTo:st,lineTo:rt,closePath:ot,drawPoints:it}=t.PathCommandDataHelper,at=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)it(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;st(t,o,0);for(let e=1;e<r;e++)rt(t,o+o*Q(2*e*et/r),i-i*tt(2*e*et/r))}ot(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}},e([t.dataProcessor(m)],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(at.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(at.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),e([t.rewrite(at.__scaleResize)],exports.Polygon.prototype,"__scaleResize",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:nt,cos:ht,PI:pt}=Math,{moveTo:_t,lineTo:dt,closePath:lt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];_t(a,o,0);for(let t=1;t<2*s;t++)dt(a,o+(t%2==0?o:o*r)*nt(t*pt/s),i-(t%2==0?i:i*r)*ht(t*pt/s));lt(a)}},e([t.dataProcessor(R)],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(C)],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.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world);i.invert();const a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,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()}},e([t.dataProcessor(C)],exports.Canvas.prototype,"__",void 0),e([S(100)],exports.Canvas.prototype,"width",void 0),e([S(100)],exports.Canvas.prototype,"height",void 0),e([S(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([S(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ut,includes:ct,spread:yt,setList:xt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=h.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:h,textCase:p,textOverflow:_,padding:d}=e,l=e.__autoWidth,c=e.__autoHeight;e.__lineHeight=u.number(r,a),e.__letterSpacing=u.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${h?"italic ":""}${"small-caps"===p?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoBounds,this.__updateTextDrawData();const{bounds:y}=e.__textDrawData,x=s.boxBounds;if(e.__lineHeight<a&&yt(y,a/2),l||c){if(x.x=l?y.x:0,x.y=c?y.y:0,x.width=l?y.width:e.width,x.height=c?y.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(x.x-=o,x.width+=s+o),c&&(x.y-=t,x.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const v=ct(x,y)?x:y;v!==s.contentBounds?(s.contentBounds=v,s.renderChanged=!0,xt(e.__textBoxBounds={},[x,y])):e.__textBoxBounds=v}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ut(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(B)],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.boundsType(0)],exports.Text.prototype,"padding",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:150})],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);const{toBounds:vt}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(e,s){t.PathScaler.scale(this.__.path,e,s),this.path=this.__.path}__updateBoxBounds(){vt(this.__.path,this.__layout.boxBounds)}},e([t.dataProcessor(P)],exports.Path.prototype,"__",void 0),e([t.pathType()],exports.Path.prototype,"path",void 0),e([t.pathType()],exports.Path.prototype,"windingRule",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,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}},e([t.dataProcessor(k)],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const gt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:i}=this;o.run(i.type,this),this.canvas=t.Creator.canvas(i),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,i),this.watcher=t.Creator.watcher(this,i),this.layouter=t.Creator.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.__controllers.unshift(this.interaction=t.Creator.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new t.CanvasManager,this.hitCanvasManager=new t.HitCanvasManager,r=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.PluginManager.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{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 s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__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))}__onAnimateFrame(){if(this.viewReady){this.__nextRenderWait.length&&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()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t){this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.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.AnimateEvent.FRAME,this.__onAnimateFrame,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)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.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.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){gt.error(t)}}))}},e([t.dataProcessor(x)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.App=class extends exports.Leafer{get __tag(){return"App"}get isApp(){return!0}constructor(e,s){if(super(e,s),e){const{ground:s,tree:r,sky:o,editor:i}=e;s&&(this.ground=this.addLeafer(s)),(r||i)&&(this.tree=this.addLeafer(r)),(o||i)&&(this.sky=this.addLeafer(o||{type:"draw",usePartRender:!1})),i&&(this.editor=t.Creator.editor(i),this.sky.add(this.editor))}}__setApp(){const{canvas:e}=this,{realCanvas:s,view:r}=this.config;s||r===this.canvas.view||!e.parentView?this.realCanvas=!0:e.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(t.PropertyEvent.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new exports.Leafer(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){t.Debug.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(e){let s=Object.assign({},this.config);return s.hittable=s.realCanvas=void 0,e&&t.DataHelper.assign(s,e),this.autoLayout&&t.DataHelper.copyAttrs(s,this,t.canvasSizeAttrs),s.view=this.realCanvas?void 0:this.view,s.fill=void 0,s}__listenChildEvents(e){e.once(t.LayoutEvent.END,(()=>this.__onReady())),e.once(t.RenderEvent.START,(()=>this.__onCreated())),e.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(e.on_(t.RenderEvent.END,this.__onChildRenderEnd,this))}},exports.App=e([t.registerUI()],exports.App),exports.Animate={},exports.ArrowData=class extends g{},exports.BoxData=y,exports.CanvasData=class extends f{},exports.ColorConvert={},exports.Effect=a,exports.EllipseData=w,exports.Export=p,exports.FrameData=v,exports.GroupData=c,exports.ImageData=C,exports.LeaferData=x,exports.LeaferTypeCreator=o,exports.LineData=g,exports.Paint=n,exports.PathData=P,exports.PenData=k,exports.PolygonData=m,exports.RectData=f,exports.RectRender=U,exports.StarData=R,exports.TextConvert=h,exports.TextData=B,exports.UIBounds=E,exports.UIData=l,exports.UIHit=A,exports.UIRender=L,exports.UnitConvert=u,exports.effectType=b,exports.resizeType=S,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/core",
3
- "version": "1.0.0-rc.8",
3
+ "version": "1.0.0-rc.9",
4
4
  "description": "@leafer-ui/core",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -29,12 +29,12 @@
29
29
  "leaferjs"
30
30
  ],
31
31
  "dependencies": {
32
- "@leafer/core": "1.0.0-rc.8",
33
- "@leafer-ui/app": "1.0.0-rc.8",
34
- "@leafer-ui/display": "1.0.0-rc.8",
35
- "@leafer-ui/decorator": "1.0.0-rc.8",
36
- "@leafer-ui/display-module": "1.0.0-rc.8",
37
- "@leafer-ui/external": "1.0.0-rc.8",
38
- "@leafer-ui/type": "1.0.0-rc.8"
32
+ "@leafer/core": "1.0.0-rc.9",
33
+ "@leafer-ui/app": "1.0.0-rc.9",
34
+ "@leafer-ui/display": "1.0.0-rc.9",
35
+ "@leafer-ui/decorator": "1.0.0-rc.9",
36
+ "@leafer-ui/display-module": "1.0.0-rc.9",
37
+ "@leafer-ui/external": "1.0.0-rc.9",
38
+ "@leafer-ui/type": "1.0.0-rc.9"
39
39
  }
40
40
  }