@leafer-draw/worker 1.9.6 → 1.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -392,6 +392,15 @@ var LeaferUI = function(exports) {
392
392
  t.c *= scaleY;
393
393
  t.d *= scaleY;
394
394
  },
395
+ pixelScale(t, pixelRatio, to) {
396
+ to || (to = t);
397
+ to.a = t.a * pixelRatio;
398
+ to.b = t.b * pixelRatio;
399
+ to.c = t.c * pixelRatio;
400
+ to.d = t.d * pixelRatio;
401
+ to.e = t.e * pixelRatio;
402
+ to.f = t.f * pixelRatio;
403
+ },
395
404
  scaleOfOuter(t, origin, scaleX, scaleY) {
396
405
  M$6.toInnerPoint(t, origin, tempPoint$3);
397
406
  M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
@@ -882,6 +891,10 @@ var LeaferUI = function(exports) {
882
891
  this.scaleY *= y || x;
883
892
  return this;
884
893
  }
894
+ pixelScale(pixelRatio) {
895
+ MatrixHelper.pixelScale(this, pixelRatio);
896
+ return this;
897
+ }
885
898
  scaleOfOuter(origin, x, y) {
886
899
  MatrixHelper.scaleOfOuter(this, origin, x, y);
887
900
  return this;
@@ -1991,7 +2004,7 @@ var LeaferUI = function(exports) {
1991
2004
  __decorate([ contextMethod() ], Canvas.prototype, "fillText", null);
1992
2005
  __decorate([ contextMethod() ], Canvas.prototype, "measureText", null);
1993
2006
  __decorate([ contextMethod() ], Canvas.prototype, "strokeText", null);
1994
- const {copy: copy$7, multiplyParent: multiplyParent$4} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
2007
+ const {copy: copy$7, multiplyParent: multiplyParent$4, pixelScale: pixelScale} = MatrixHelper, {round: round$1} = Math, tempPixelBounds = new Bounds, tempPixelBounds2 = new Bounds;
1995
2008
  const minSize = {
1996
2009
  width: 1,
1997
2010
  height: 1,
@@ -2089,12 +2102,7 @@ var LeaferUI = function(exports) {
2089
2102
  setWorld(matrix, parentMatrix) {
2090
2103
  const {pixelRatio: pixelRatio, pixelSnap: pixelSnap} = this, w = this.worldTransform;
2091
2104
  if (parentMatrix) multiplyParent$4(matrix, parentMatrix, w);
2092
- w.a = matrix.a * pixelRatio;
2093
- w.b = matrix.b * pixelRatio;
2094
- w.c = matrix.c * pixelRatio;
2095
- w.d = matrix.d * pixelRatio;
2096
- w.e = matrix.e * pixelRatio;
2097
- w.f = matrix.f * pixelRatio;
2105
+ pixelScale(matrix, pixelRatio, w);
2098
2106
  if (pixelSnap) {
2099
2107
  if (matrix.half && matrix.half * pixelRatio % 2) w.e = round$1(w.e - .5) + .5, w.f = round$1(w.f - .5) + .5; else w.e = round$1(w.e),
2100
2108
  w.f = round$1(w.f);
@@ -4008,6 +4016,17 @@ var LeaferUI = function(exports) {
4008
4016
  }
4009
4017
  }));
4010
4018
  }
4019
+ function dimType(defaultValue) {
4020
+ return decorateLeafAttr(defaultValue, key => attr({
4021
+ set(value) {
4022
+ if (this.__setAttr(key, value)) {
4023
+ const data = this.__;
4024
+ DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4025
+ this.__layout.surfaceChange();
4026
+ }
4027
+ }
4028
+ }));
4029
+ }
4011
4030
  function opacityType(defaultValue) {
4012
4031
  return decorateLeafAttr(defaultValue, key => attr({
4013
4032
  set(value) {
@@ -4048,7 +4067,7 @@ var LeaferUI = function(exports) {
4048
4067
  return decorateLeafAttr(defaultValue, key => attr({
4049
4068
  set(value) {
4050
4069
  if (this.__setAttr(key, value)) {
4051
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
4070
+ this.__layout.surfaceChange();
4052
4071
  this.waitParent(() => {
4053
4072
  this.parent.__layout.childrenSortChange();
4054
4073
  });
@@ -4082,7 +4101,7 @@ var LeaferUI = function(exports) {
4082
4101
  set(value) {
4083
4102
  if (this.__setAttr(key, value)) {
4084
4103
  this.__layout.hitCanvasChanged = true;
4085
- if (Debug.showBounds === "hit") this.__layout.surfaceChanged || this.__layout.surfaceChange();
4104
+ if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4086
4105
  if (this.leafer) this.leafer.updateCursor();
4087
4106
  }
4088
4107
  }
@@ -5480,6 +5499,7 @@ var LeaferUI = function(exports) {
5480
5499
  if (options.shape) return this.__renderShape(canvas, options);
5481
5500
  if (this.__worldOpacity) {
5482
5501
  const data = this.__;
5502
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5483
5503
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5484
5504
  canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5485
5505
  if (this.__.__single) {
@@ -5526,7 +5546,9 @@ var LeaferUI = function(exports) {
5526
5546
  this.__nowWorld = this.__getNowWorld(options);
5527
5547
  if (this.__worldOpacity) {
5528
5548
  const data = this.__;
5529
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5549
+ if (data.__useDim) {
5550
+ if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5551
+ }
5530
5552
  if (data.__single && !this.isBranchLeaf) {
5531
5553
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5532
5554
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -6351,7 +6373,7 @@ var LeaferUI = function(exports) {
6351
6373
  this.levelMap = null;
6352
6374
  }
6353
6375
  }
6354
- const version = "1.9.6";
6376
+ const version = "1.9.7";
6355
6377
  class LeaferCanvas extends LeaferCanvasBase {
6356
6378
  get allowBackgroundColor() {
6357
6379
  return true;
@@ -6878,7 +6900,7 @@ var LeaferUI = function(exports) {
6878
6900
  };
6879
6901
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
6880
6902
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
6881
- this.target.__render(canvas, options);
6903
+ Platform.render(this.target, canvas, options);
6882
6904
  this.renderBounds = realBounds = realBounds || bounds;
6883
6905
  this.renderOptions = options;
6884
6906
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
@@ -6967,6 +6989,14 @@ var LeaferUI = function(exports) {
6967
6989
  interaction: (_target, _canvas, _selector, _options) => undefined
6968
6990
  });
6969
6991
  Platform.layout = Layouter.fullLayout;
6992
+ Platform.render = function(target, canvas, options) {
6993
+ const topOptions = Object.assign(Object.assign({}, options), {
6994
+ topRendering: true
6995
+ });
6996
+ options.topList = new LeafList;
6997
+ target.__render(canvas, options);
6998
+ if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
6999
+ };
6970
7000
  function effectType(defaultValue) {
6971
7001
  return decorateLeafAttr(defaultValue, key => attr({
6972
7002
  set(value) {
@@ -7684,8 +7714,8 @@ var LeaferUI = function(exports) {
7684
7714
  __decorate([ opacityType(1) ], exports.UI.prototype, "opacity", void 0);
7685
7715
  __decorate([ visibleType(true) ], exports.UI.prototype, "visible", void 0);
7686
7716
  __decorate([ surfaceType(false) ], exports.UI.prototype, "locked", void 0);
7687
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dim", void 0);
7688
- __decorate([ surfaceType(false) ], exports.UI.prototype, "dimskip", void 0);
7717
+ __decorate([ dimType(false) ], exports.UI.prototype, "dim", void 0);
7718
+ __decorate([ dimType(false) ], exports.UI.prototype, "dimskip", void 0);
7689
7719
  __decorate([ sortType(0) ], exports.UI.prototype, "zIndex", void 0);
7690
7720
  __decorate([ maskType(false) ], exports.UI.prototype, "mask", void 0);
7691
7721
  __decorate([ eraserType(false) ], exports.UI.prototype, "eraser", void 0);
@@ -10305,6 +10335,7 @@ var LeaferUI = function(exports) {
10305
10335
  exports.defineDataProcessor = defineDataProcessor;
10306
10336
  exports.defineKey = defineKey;
10307
10337
  exports.defineLeafAttr = defineLeafAttr;
10338
+ exports.dimType = dimType;
10308
10339
  exports.doBoundsType = doBoundsType;
10309
10340
  exports.doStrokeType = doStrokeType;
10310
10341
  exports.effectType = effectType;
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a}=t.FileHelper;function i(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise((i,s)=>{t.convertToBlob({type:a(e),quality:n}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise(t=>t()),download(t,e){},loadImage:e=>new Promise((n,a)=>{let i=new XMLHttpRequest;i.open("GET",t.Platform.image.getRealURL(e),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then(t=>{n(t)}).catch(t=>{a(t)})},i.onerror=t=>a(t),i.send()})},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?t.Platform.os="Mac":s.indexOf("Linux")>-1&&(t.Platform.os="Linux");class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:o,updateBounds:l,updateChange:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper;class f{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:p,updateAllChange:g}=t.LeafHelper,_=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){_.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?_.warn("layouting"):this.times>3?_.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:s,LAYOUT:r,AFTER:u}=t.LayoutEvent,f=this.getBlocks(i);f.forEach(t=>t.setBefore()),a.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach(t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(o(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))})}(i,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){a=n.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||l(a[t])}l(n)}})}(this.__levelList),function(t){t.list.forEach(d)}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),a.emitEvent(new t.LayoutEvent(r,f,this.times)),a.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:a,LAYOUT:i,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,r,this.times)),m.fullLayout(n),r.forEach(t=>{t.setAfter()}),n.emitEvent(new t.LayoutEvent(i,r,this.times)),n.emitEvent(new t.LayoutEvent(s,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){p(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),g(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new f([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new f(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class w{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=e,this.canvas=n,a&&(this.config=t.DataHelper.default(a,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:a}=this,i=e.getIntersect(a.bounds),s=new t.Bounds(i);a.save(),i.spread(w.clipSpread).ceil(),a.clearWorld(i),a.clipWorld(i),this.__render(i,s),a.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:a}=this,i=e.includes(this.target.__world),s=i?{includes:i}:{bounds:e,includes:i};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.target.__render(a,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),a.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now(),a=()=>{const e=1e3/(Date.now()-n),{maxFPS:i}=this.config;if(i&&e>i-.5)return t.Platform.requestRender(a);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(a)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:a}=e.old;if(!new t.Bounds(0,0,n,a).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,n,a){this.target.emitEvent(new t.RenderEvent(e,this.times,n,a))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function v(t,e){const n=t.__,{rows:a,decorationY:i}=n.__textDrawData;let s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=a.length;t<n;t++)s=a[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(i){const{decorationColor:t,decorationHeight:s}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>i.forEach(n=>e.fillRect(t.x,t.y+n,t.width,s)))}}function x(t,e){t.__.__font?v(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function b(t,e,n){switch(e.__.strokeAlign){case"center":E(t,1,e,n);break;case"inside":B(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?E(t,2,e,n):B(t,"outside",e,n)}}function E(e,n,a,i){const s=a.__;t.isObject(e)?R(e,n,!0,a,i):(i.setStroke(e,s.__strokeWidth*n,s),S(a,i))}function B(e,n,a,i){const s=i.getSameCanvas(!0,!0);s.font=a.__.__font,E(e,2,a,s),s.blendMode="outside"===n?"destination-out":"destination-in",v(a,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(a,i,s),s.recycle(a.__nowWorld)}function S(t,e){let n,a=t.__.__textDrawData;const{rows:i,decorationY:s}=a;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.strokeText(t.char,t.x,n.y)});if(s){const{decorationHeight:t}=a;i.forEach(n=>s.forEach(a=>e.strokeRect(n.x,n.y+a,n.width,t)))}}function R(t,n,a,i,s){let r;const o=i.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*n,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(i,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*n,o,t):s.setStroke(r.style,o.__strokeWidth*n,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),a?S(i,s):s.stroke(),s.restoreBlendMode()):a?S(i,s):s.stroke()}}function k(e,n,a){const i=n.__;if(i.__strokeWidth)if(i.__font)b(e,n,a);else switch(i.strokeAlign){case"center":L(e,1,n,a);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),L(t,2,e,n),n.restore()}(e,n,a);break;case"outside":!function(e,n,a){const i=n.__;if(i.__fillAfterStroke)L(e,2,n,a);else{const{renderBounds:s}=n.__layout,r=a.getSameCanvas(!0,!0);n.__drawRenderPath(r),L(e,2,n,r),r.clipUI(i),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(n,a,r),r.recycle(n.__nowWorld)}}(e,n,a)}}function L(n,a,i,s){const r=i.__;t.isObject(n)?R(n,a,!1,i,s):(s.setStroke(n,r.__strokeWidth*a,r),s.stroke()),r.__useArrow&&e.Paint.strokeArrow(n,i,s)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new w(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,a)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:P,getOuterOf:C,getByMove:A,getIntersectData:O}=t.BoundsHelper;let T;const{stintSet:M}=t.DataHelper,{hasTransparent:W}=e.ColorConvert;function D(n,a,i){if(!t.isObject(a)||!1===a.visible||0===a.opacity)return;let s;const{boxBounds:r}=i.__layout;switch(a.type){case"image":s=e.PaintImage.image(i,n,a,r,!T||!T[a.url]);break;case"linear":s=e.PaintGradient.linearGradient(a,r);break;case"radial":s=e.PaintGradient.radialGradient(a,r);break;case"angular":s=e.PaintGradient.conicGradient(a,r);break;case"solid":const{type:o,color:l,opacity:d}=a;s={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(a.r)||(s={type:"solid",style:e.ColorConvert.string(a)})}if(s){if(t.isString(s.style)&&W(s.style)&&(s.isTransparent=!0),a.style){if(0===a.style.strokeWidth)return;s.strokeStyle=a.style}a.editing&&(s.editing=a.editing),a.blendMode&&(s.blendMode=a.blendMode)}return s}const I={compute:function(n,a){const i=a.__,s=[];let r,o,l,d=i.__input[n];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(n,i);for(let t,e=0,i=d.length;e<i;e++)(t=D(n,d[e],a))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));i["_"+n]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===n?(M(i,"__isAlphaPixelFill",r),M(i,"__isTransparentFill",o)):(M(i,"__isAlphaPixelStroke",r),M(i,"__isTransparentStroke",o),M(i,"__hasMultiStrokeStyle",l))},fill:function(t,e,n){n.fillStyle=t,x(e,n)},fills:function(t,n,a){let i;for(let s=0,r=t.length;s<r;s++){if(i=t[s],i.image){if(e.PaintImage.checkImage(n,a,i,!n.__.__font))continue;if(!i.style){!s&&i.image.isPlacehold&&n.drawImagePlaceholder(a,i.image);continue}}if(a.fillStyle=i.style,i.transform||i.scaleFixed){if(a.save(),i.transform&&a.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:e}=n.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&e>1)&&a.scale(1/t,1/e)}i.blendMode&&(a.blendMode=i.blendMode),x(n,a),a.restore()}else i.blendMode?(a.saveBlendMode(i.blendMode),x(n,a),a.restoreBlendMode()):x(n,a)}},fillPathOrText:x,fillText:v,stroke:k,strokes:function(t,e,n){k(t,e,n)},strokeText:b,drawTextStroke:S,shape:function(e,n,a){const i=n.getSameCanvas(),s=e.__nowWorld,r=n.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(s))h=i,o=c=s;else{const{renderShapeSpread:i}=e.__layout;let p;if(t.Platform.fullImageShadow)p=s;else{const t=i?P(r,u===f?i*u:[i*f,i*u]):r;p=O(t,s)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=n.getSameCanvas(),e.__renderShape(h,a),u*=g,f*=_),c=C(s,d),o=A(c,-d.e,-d.f);const m=a.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),a=Object.assign(Object.assign({},a),{matrix:l})}return e.__renderShape(i,a),{canvas:i,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let H={},F=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:z,scaleOfOuter:U,multiplyParent:Y,scale:q,rotate:N,skew:X}=t.MatrixHelper;function V(t,e,n,a,i,s,r){const o=j();z(o,e.x+n,e.y+a),q(o,i,s),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Q(t,e,n,a,i,s,r,o,l){const d=j();K(d,e,n,a,i,s,r,o),l&&(F.a=e.width/l.width,F.d=e.height/l.height,Y(d,F)),t.transform=d}function Z(t,e,n,a,i,s,r,o,l,d,c,h){const u=j();if(h)K(u,e,i,s,r,o,l,d);else{if(l)if("center"===c)G(u,{x:n/2,y:a/2},l);else switch(N(u,l),l){case 90:z(u,a,0);break;case 180:z(u,n,a);break;case 270:z(u,0,n)}H.x=e.x+i,H.y=e.y+s,z(u,H.x,H.y),r&&U(u,H,r,o)}t.transform=u}function K(t,e,n,a,i,s,r,o){r&&N(t,r),o&&X(t,o.x,o.y),i&&q(t,i,s),z(t,e.x+n,e.y+a)}const{get:$,translate:J}=t.MatrixHelper,tt=new t.Bounds,et={},nt={};function at(t,e,n,a){const{changeful:i,sync:s,scaleFixed:r}=n;i&&(t.changeful=i),s&&(t.sync=s),r&&(t.scaleFixed=r),t.data=it(n,a,e)}function it(e,n,a){e.padding&&(n=tt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:i,height:s}=a;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,y=n.width===i&&n.height===s,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(nt,0,0,v?s:i,v?i:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,a,et),x=et.scaleX,b=et.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(nt,x,b,!0),l&&t.AlignHelper.toPoint(l,nt,n,nt,!0,!0))):y&&!u||(x=b=t.BoundsHelper.getFitScale(n,nt,"fit"!==o),t.BoundsHelper.put(n,a,l,x,!1,nt),t.BoundsHelper.scale(nt,x,b,!0)),d&&t.PointHelper.move(nt,d),o){case"stretch":y||(i=n.width,s=n.height);break;case"normal":case"clip":(nt.x||nt.y||x||p||u||f)&&Q(w,n,nt.x,nt.y,x,b,u,f,e.clipSize);break;case"repeat":(!y||x||u||f)&&Z(w,n,i,s,nt.x,nt.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const a=t.isObject(g);(_||a)&&(w.gap=function(e,n,a,i,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:st(r,a,s.width,n&&n.x),y:st(o,i,s.height,n&&n.y)}}(_,a&&g,nt.width,nt.height,n));break;default:x&&V(w,n,nt.x,nt.y,x,b,u)}return w.transform||(n.x||n.y)&&(w.transform=$(),J(w.transform,n.x,n.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=b),w.width=i,w.height=s,r&&(w.opacity=r),m&&(w.filters=m),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function st(e,n,a,i){const s=t.isString(e)||i?(i?a-i*n:a%n)/((i||Math.floor(a/n))-1):e;return"auto"===e&&s<0?0:s}let rt,ot=new t.Bounds;const{isSame:lt}=t.BoundsHelper;function dt(t,e,n,a,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||at(i,a,n,s),!0}function ct(e,n){ft(e,t.ImageEvent.LOAD,n)}function ht(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,a){n.error=a,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function pt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:gt,scale:_t,copy:mt}=t.MatrixHelper,{floor:yt,ceil:wt,max:vt,abs:xt}=Math;function bt(e,n,a){let{scaleX:i,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed);const r=i+"-"+s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=n;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;i*=a,s*=a,f&&(f=xt(f),p=xt(p),c=gt(),mt(c,g),_t(c,1/f,1/p),i*=f,s*=p),h*=i,u*=s;const y=h*u;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/wt(t))}else{const t=o.width*o.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(i/=d,s/=d,h/=d,u/=d),f&&(i/=f,s/=p);const v=m&&m.x*i,x=m&&m.y*s;if(g||1!==i||1!==s){const t=h+(v||0),e=u+(x||0);i/=t/vt(yt(t),1),s/=e/vt(yt(e),1),c||(c=gt(),g&&mt(c,g)),_t(c,1/i,1/s)}const b=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,n);return n.style=E,n.patternId=r,!0}}function Et(t,e,n,a){return new(n||(n=Promise))(function(i,s){function r(t){try{l(a.next(t))}catch(t){s(t)}}function o(t){try{l(a.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Bt={image:function(e,n,a,i,s){let r,o;const l=t.ImageManager.get(a);return rt&&a===rt.paint&&lt(i,rt.boxBounds)?r=rt.leafPaint:(r={type:a.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),rt=l.use>1?{leafPaint:r,paint:a,boxBounds:ot.set(i)}:null),(s||l.loading)&&(o={image:l,attrName:n,attrValue:a}),l.ready?(dt(e,n,a,l,r,i),s&&(ct(e,o),ht(e,o))):l.error?s&&ut(e,o,l.error):(s&&(pt(e,!0),ct(e,o)),r.loadId=l.load(()=>{pt(e,!1),e.destroyed||(dt(e,n,a,l,r,i)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,o)),r.loadId=void 0},t=>{pt(e,!1),ut(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(n,a,i,s){const{scaleX:r,scaleY:o}=n.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:l}=a,{data:d}=i;if(!d||i.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=r*l,n*=o*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(n.__.__isFastShadow&&(a.fillStyle=i.style||"#000",a.fill()),function(t,e,n,a){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);a.opacity&&(e.opacity*=a.opacity);a.transform&&e.transform(a.transform);e.drawImage(n.image.getFull(a.filters),0,0,a.width,a.height),e.restore()}(n,a,i,d),!0):(!i.style||i.sync||e.Export.running?bt(n,i,l):i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>Et(this,void 0,void 0,function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&bt(n,i,l),n.forceUpdate("surface")}),300)),!1)},createPattern:bt,recycleImage:function(e,n){const a=n["_"+e];if(t.isArray(a)){let i,s,r,o,l;for(let d=0,c=a.length;d<c;d++)i=a[d],s=i.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(a[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:it,fillOrFitMode:V,clipMode:Q,repeatMode:Z},{toPoint:St}=t.AroundHelper,{hasTransparent:Rt}=e.ColorConvert,kt={},Lt={};function Pt(n,a,i,s){if(i){let r,o,l,d;for(let n=0,c=i.length;n<c;n++)r=i[n],t.isString(r)?(l=n/(c-1),o=e.ColorConvert.string(r,s)):(l=r.offset,o=e.ColorConvert.string(r.color,s)),a.addColorStop(l,o),!d&&Rt(o)&&(d=!0);d&&(n.isTransparent=!0)}}const{getAngle:Ct,getDistance:At}=t.PointHelper,{get:Ot,rotateOfOuter:Tt,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:Wt}=t.AroundHelper,Dt={},It={};function Ht(t,e,n,a,i){let s;const{width:r,height:o}=t;if(r!==o||a){const t=Ct(e,n);s=Ot(),i?(Mt(s,e,r/o*(a||1),1),Tt(s,e,t+90)):(Mt(s,e,1,r/o*(a||1)),Tt(s,e,t))}return s}const{getDistance:Ft}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},zt={};const Ut={linearGradient:function(e,n){let{from:a,to:i,type:s,opacity:r}=e;St(a||"top",n,kt),St(i||"bottom",n,Lt);const o=t.Platform.canvas.createLinearGradient(kt.x,kt.y,Lt.x,Lt.y),l={type:s,style:o};return Pt(l,o,e.stops,r),l},radialGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;Wt(a||"center",n,Dt),Wt(i||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,At(Dt,It)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Dt,It,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;jt(a||"center",n,Gt),jt(i||"bottom",n,zt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Gt.x,Gt.y):t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Ft(Gt,zt)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Gt,zt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ht},{copy:Yt,toOffsetOutBounds:qt}=t.BoundsHelper,Nt={},Xt={};function Vt(e,n,a,i){const{bounds:s,shapeBounds:r}=i;if(t.Platform.fullImageShadow){if(Yt(Nt,e.bounds),Nt.x+=n.x-r.x,Nt.y+=n.y-r.y,a){const{fitMatrix:t}=i;Nt.x-=(s.x+(t?t.e:0)+s.width/2)*(a-1),Nt.y-=(s.y+(t?t.f:0)+s.height/2)*(a-1),Nt.width*=a,Nt.height*=a}e.copyWorld(i.canvas,e.bounds,Nt)}else a&&(Yt(Nt,n),Nt.x-=n.width/2*(a-1),Nt.y-=n.height/2*(a-1),Nt.width*=a,Nt.height*=a),e.copyWorld(i.canvas,r,a?Nt:n)}const{toOffsetOutBounds:Qt}=t.BoundsHelper,Zt={};const Kt={shadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{shadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;qt(h,Xt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Xt.offsetX+d.x*f*y,Xt.offsetY+d.y*p*y,d.blur*f*y,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Xt,r,i),s=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),s=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(i.canvas,u,h,"destination-out")),e.Effect.isTransformShadow(d)?e.Effect.renderTransformShadow(n,a,g,s,d):t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{innerShadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;Qt(h,Zt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(Zt.offsetX+d.x*f*y,Zt.offsetY+d.y*p*y,d.blur*f*y),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Zt,r,i),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,u,h,"source-out"),s=h),g.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,n){const{blur:a}=t.__;n.setWorldBlur(a*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){},getShadowSpread:function(t,e){let n=0;return e.forEach(t=>n=Math.max(n,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),n},isTransformShadow(t){}},{excludeRenderBounds:$t}=t.LeafBoundsHelper;let Jt;function te(t,e,n,a,i,s,r,o){switch(e){case"grayscale":Jt||(Jt=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,n,a,i,s){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,r),s&&a.recycle(r);ne(t,e,n,1,i,s)}(t,n,a,i,r,o);break;case"opacity-path":ne(t,n,a,s,r,o);break;case"path":o&&n.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ne(t,e,n,a,i,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,r,void 0,i),s?n.recycle(r):n.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let n,a,i,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(n=l[d],o=n.__.mask,o){r&&(te(this,r,t,i,a,s,void 0,!0),a=i=null),s=n.__.opacity,Jt=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",i||(i=ee(t))):(r="path",t.save()),n.__clip(i||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ee(t)),i||(i=ee(t)),n.__render(a,e)),"clipping"!==o&&"clipping-path"!==o||$t(n,e)||n.__render(t,e);continue}const c=1===s&&n.__.__blendMode;c&&te(this,r,t,i,a,s,void 0,!1),$t(n,e)||n.__render(i||t,e),c&&te(this,r,t,i,a,s,c,!1)}te(this,r,t,i,a,s,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ie=ae+"_#~&*+\\=|≮≯≈≠=…",se=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const oe=re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),de=re(ae),ce=re(ie),he=re("- —/~|┆·");var ue;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:me,Break:ye}=ue;function we(t){return oe[t]?fe:he[t]?ye:le[t]?ge:de[t]?_e:ce[t]?me:se.test(t)?pe:fe}const ve={trimRight(t){const{words:e}=t;let n,a=0,i=e.length;for(let s=i-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)a++,t.width-=n.width;a&&e.splice(i-a,a)}};function xe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:be}=ve,{Letter:Ee,Single:Be,Before:Se,After:Re,Symbol:ke,Break:Le}=ue;let Pe,Ce,Ae,Oe,Te,Me,We,De,Ie,He,Fe,je,Ge,ze,Ue,Ye,qe,Ne=[];function Xe(t,e){Ie&&!De&&(De=Ie),Pe.data.push({char:t,width:e}),Ae+=e}function Ve(){Oe+=Ae,Pe.width=Ae,Ce.words.push(Pe),Pe={data:[]},Ae=0}function Qe(){ze&&(Ue.paraNumber++,Ce.paraStart=!0,ze=!1),Ie&&(Ce.startCharSize=De,Ce.endCharSize=Ie,De=0),Ce.width=Oe,Ye.width?be(Ce):qe&&Ze(),Ne.push(Ce),Ce={words:[]},Oe=0}function Ze(){Oe>(Ue.maxWidth||0)&&(Ue.maxWidth=Oe)}const{top:Ke,right:$e,bottom:Je,left:tn}=t.Direction4;function en(t,e,n){const{bounds:a,rows:i}=t;a[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const nn={getDrawData:function(n,a){t.isString(n)||(n=String(n));let i=0,s=0,r=a.__getInput("width")||0,o=a.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=a;c&&(r?(i=c[tn],r-=c[$e]+c[tn]):a.autoSizeAlign||(i=c[tn]),o?(s=c[Ke],o-=c[Ke]+c[Je]):a.autoSizeAlign||(s=c[Ke]));const h={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){Ue=e,Ne=e.rows,Ye=e.bounds,qe=!Ye.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:s,textCase:r}=a,{canvas:o}=t.Platform,{width:l,height:d}=Ye;if(l||d||i||"none"!==r){const t="none"!==a.textWrap,e="break"===a.textWrap;ze=!0,Fe=null,De=We=Ie=Ae=Oe=0,Pe={data:[]},Ce={words:[]},i&&(n=[...n]);for(let a=0,d=n.length;a<d;a++)Me=n[a],"\n"===Me?(Ae&&Ve(),Ce.paraEnd=!0,Qe(),ze=!0):(He=we(Me),He===Ee&&"none"!==r&&(Me=xe(Me,r,!Ae)),We=o.measureText(Me).width,i&&(i<0&&(Ie=We),We+=i),je=He===Be&&(Fe===Be||Fe===Ee)||Fe===Be&&He!==Re,Ge=!(He!==Se&&He!==Be||Fe!==ke&&Fe!==Re),Te=ze&&s?l-s:l,t&&l&&Oe+Ae+We>Te&&(e?(Ae&&Ve(),Oe&&Qe()):(Ge||(Ge=He===Ee&&Fe==Re),je||Ge||He===Le||He===Se||He===Be||Ae+We>Te?(Ae&&Ve(),Oe&&Qe()):Oe&&Qe()))," "===Me&&!0!==ze&&Oe+Ae===0||(He===Le?(" "===Me&&Ae&&Ve(),Xe(Me,We),Ve()):je||Ge?(Ae&&Ve(),Xe(Me,We)):Xe(Me,We)),Fe=He);Ae&&Ve(),Oe&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else n.split("\n").forEach(t=>{Ue.paraNumber++,Oe=o.measureText(t).width,Ne.push({x:s||0,text:t,width:Oe,paraStart:!0}),qe&&Ze()})}(h,n,a),c&&function(t,e,n,a,i){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[$e])}if(!i&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[Je])}}(c,h,a,r,o),function(t,e){const{rows:n,bounds:a}=t,i=n.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=s*i+(h?h*(t.paraNumber-1):0),y=r;if(l&&m>_)m=Math.max(_,s),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=i;r<c;r++){if(w=n[r],w.x=f,w.width<g||w.width>g&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&r>0&&(y+=h),w.y=y,y+=s,t.overflow>r&&y>m&&(w.isOverflow=!0,t.overflow=r+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<a.x&&(a.x=v),x>a.width&&(a.width=x),l&&g&&g<x&&(w.isOverflow=!0,t.overflow||(t.overflow=n.length))}a.y=p,a.height=m}(h,a),function(t,e,n){const{rows:a}=t,{textAlign:i,paraIndent:s,letterSpacing:r}=e;let o,l,d,c,h,u;a.forEach(t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===i||"both"===i)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,n)=>{1===c?(h={char:"",x:o},o=function(t,e,n){return t.forEach(t=>{n.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,n,a){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==i||n===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,a,r),h.overflow&&function(e,n,a,i){if(!i)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=n;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+i-d;("none"===n.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let a=n;a>-1&&(e=t.data[a],l=e.x+e.width,!(a===n&&l<c));a--){if(l<c&&" "!==e.char||!a){t.data.splice(a+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(h,a,i,r),"none"!==l&&function(n,a){let i,s=0;const{fontSize:r,textDecoration:o}=a;switch(n.decorationHeight=r/11,t.isObject(o)?(i=o.type,o.color&&(n.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):i=o,i){case"under":n.decorationY=[.15*r+s];break;case"delete":n.decorationY=[.35*-r];break;case"under-delete":n.decorationY=[.15*r+s,.35*-r]}}(h,a),h}};const an={string:function(n,a){const i=t.isNumber(a)&&a<1;if(t.isString(n)){if(!i||!e.ColorConvert.object)return n;n=e.ColorConvert.object(n)}let s=t.isUndefined(n.a)?1:n.a;i&&(s*=a);const r=n.r+","+n.g+","+n.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(e.TextConvert,nn),Object.assign(e.ColorConvert,an),Object.assign(e.Paint,I),Object.assign(e.PaintImage,Bt),Object.assign(e.PaintGradient,Ut),Object.assign(e.Effect,Kt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=w,exports.Watcher=r,exports.useCanvas=i,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]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a}=t.FileHelper;function i(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise((i,s)=>{t.convertToBlob({type:a(e),quality:n}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise(t=>t()),download(t,e){},loadImage:e=>new Promise((n,a)=>{let i=new XMLHttpRequest;i.open("GET",t.Platform.image.getRealURL(e),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then(t=>{n(t)}).catch(t=>{a(t)})},i.onerror=t=>a(t),i.send()})},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?t.Platform.os="Mac":s.indexOf("Linux")>-1&&(t.Platform.os="Linux");class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:o,updateBounds:l,updateChange:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper;class f{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:p,updateAllChange:g}=t.LeafHelper,_=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){_.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?_.warn("layouting"):this.times>3?_.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:s,LAYOUT:r,AFTER:u}=t.LayoutEvent,f=this.getBlocks(i);f.forEach(t=>t.setBefore()),a.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach(t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(o(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))})}(i,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){a=n.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||l(a[t])}l(n)}})}(this.__levelList),function(t){t.list.forEach(d)}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),a.emitEvent(new t.LayoutEvent(r,f,this.times)),a.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:a,LAYOUT:i,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,r,this.times)),m.fullLayout(n),r.forEach(t=>{t.setAfter()}),n.emitEvent(new t.LayoutEvent(i,r,this.times)),n.emitEvent(new t.LayoutEvent(s,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){p(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),g(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new f([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new f(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class w{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=e,this.canvas=n,a&&(this.config=t.DataHelper.default(a,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:a}=this,i=e.getIntersect(a.bounds),s=new t.Bounds(i);a.save(),i.spread(w.clipSpread).ceil(),a.clearWorld(i),a.clipWorld(i),this.__render(i,s),a.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:a}=this,i=e.includes(this.target.__world),s=i?{includes:i}:{bounds:e,includes:i};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),t.Platform.render(this.target,a,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),a.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now(),a=()=>{const e=1e3/(Date.now()-n),{maxFPS:i}=this.config;if(i&&e>i-.5)return t.Platform.requestRender(a);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(a)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:a}=e.old;if(!new t.Bounds(0,0,n,a).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,n,a){this.target.emitEvent(new t.RenderEvent(e,this.times,n,a))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function v(t,e){const n=t.__,{rows:a,decorationY:i}=n.__textDrawData;let s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=a.length;t<n;t++)s=a[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(i){const{decorationColor:t,decorationHeight:s}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>i.forEach(n=>e.fillRect(t.x,t.y+n,t.width,s)))}}function x(t,e){t.__.__font?v(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function b(t,e,n){switch(e.__.strokeAlign){case"center":E(t,1,e,n);break;case"inside":B(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?E(t,2,e,n):B(t,"outside",e,n)}}function E(e,n,a,i){const s=a.__;t.isObject(e)?L(e,n,!0,a,i):(i.setStroke(e,s.__strokeWidth*n,s),S(a,i))}function B(e,n,a,i){const s=i.getSameCanvas(!0,!0);s.font=a.__.__font,E(e,2,a,s),s.blendMode="outside"===n?"destination-out":"destination-in",v(a,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(a,i,s),s.recycle(a.__nowWorld)}function S(t,e){let n,a=t.__.__textDrawData;const{rows:i,decorationY:s}=a;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.strokeText(t.char,t.x,n.y)});if(s){const{decorationHeight:t}=a;i.forEach(n=>s.forEach(a=>e.strokeRect(n.x,n.y+a,n.width,t)))}}function L(t,n,a,i,s){let r;const o=i.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*n,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(i,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*n,o,t):s.setStroke(r.style,o.__strokeWidth*n,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),a?S(i,s):s.stroke(),s.restoreBlendMode()):a?S(i,s):s.stroke()}}function R(e,n,a){const i=n.__;if(i.__strokeWidth)if(i.__font)b(e,n,a);else switch(i.strokeAlign){case"center":k(e,1,n,a);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),k(t,2,e,n),n.restore()}(e,n,a);break;case"outside":!function(e,n,a){const i=n.__;if(i.__fillAfterStroke)k(e,2,n,a);else{const{renderBounds:s}=n.__layout,r=a.getSameCanvas(!0,!0);n.__drawRenderPath(r),k(e,2,n,r),r.clipUI(i),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(n,a,r),r.recycle(n.__nowWorld)}}(e,n,a)}}function k(n,a,i,s){const r=i.__;t.isObject(n)?L(n,a,!1,i,s):(s.setStroke(n,r.__strokeWidth*a,r),s.stroke()),r.__useArrow&&e.Paint.strokeArrow(n,i,s)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new w(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,a)=>{}}),t.Platform.layout=m.fullLayout,t.Platform.render=function(e,n,a){const i=Object.assign(Object.assign({},a),{topRendering:!0});a.topList=new t.LeafList,e.__render(n,a),a.topList.length&&a.topList.forEach(t=>t.__render(n,i))};const{getSpread:P,getOuterOf:C,getByMove:A,getIntersectData:O}=t.BoundsHelper;let T;const{stintSet:M}=t.DataHelper,{hasTransparent:W}=e.ColorConvert;function D(n,a,i){if(!t.isObject(a)||!1===a.visible||0===a.opacity)return;let s;const{boxBounds:r}=i.__layout;switch(a.type){case"image":s=e.PaintImage.image(i,n,a,r,!T||!T[a.url]);break;case"linear":s=e.PaintGradient.linearGradient(a,r);break;case"radial":s=e.PaintGradient.radialGradient(a,r);break;case"angular":s=e.PaintGradient.conicGradient(a,r);break;case"solid":const{type:o,color:l,opacity:d}=a;s={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(a.r)||(s={type:"solid",style:e.ColorConvert.string(a)})}if(s){if(t.isString(s.style)&&W(s.style)&&(s.isTransparent=!0),a.style){if(0===a.style.strokeWidth)return;s.strokeStyle=a.style}a.editing&&(s.editing=a.editing),a.blendMode&&(s.blendMode=a.blendMode)}return s}const I={compute:function(n,a){const i=a.__,s=[];let r,o,l,d=i.__input[n];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(n,i);for(let t,e=0,i=d.length;e<i;e++)(t=D(n,d[e],a))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));i["_"+n]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===n?(M(i,"__isAlphaPixelFill",r),M(i,"__isTransparentFill",o)):(M(i,"__isAlphaPixelStroke",r),M(i,"__isTransparentStroke",o),M(i,"__hasMultiStrokeStyle",l))},fill:function(t,e,n){n.fillStyle=t,x(e,n)},fills:function(t,n,a){let i;for(let s=0,r=t.length;s<r;s++){if(i=t[s],i.image){if(e.PaintImage.checkImage(n,a,i,!n.__.__font))continue;if(!i.style){!s&&i.image.isPlacehold&&n.drawImagePlaceholder(a,i.image);continue}}if(a.fillStyle=i.style,i.transform||i.scaleFixed){if(a.save(),i.transform&&a.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:e}=n.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&e>1)&&a.scale(1/t,1/e)}i.blendMode&&(a.blendMode=i.blendMode),x(n,a),a.restore()}else i.blendMode?(a.saveBlendMode(i.blendMode),x(n,a),a.restoreBlendMode()):x(n,a)}},fillPathOrText:x,fillText:v,stroke:R,strokes:function(t,e,n){R(t,e,n)},strokeText:b,drawTextStroke:S,shape:function(e,n,a){const i=n.getSameCanvas(),s=e.__nowWorld,r=n.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(s))h=i,o=c=s;else{const{renderShapeSpread:i}=e.__layout;let p;if(t.Platform.fullImageShadow)p=s;else{const t=i?P(r,u===f?i*u:[i*f,i*u]):r;p=O(t,s)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=n.getSameCanvas(),e.__renderShape(h,a),u*=g,f*=_),c=C(s,d),o=A(c,-d.e,-d.f);const m=a.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),a=Object.assign(Object.assign({},a),{matrix:l})}return e.__renderShape(i,a),{canvas:i,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let H={},F=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:z,scaleOfOuter:U,multiplyParent:Y,scale:q,rotate:N,skew:X}=t.MatrixHelper;function V(t,e,n,a,i,s,r){const o=j();z(o,e.x+n,e.y+a),q(o,i,s),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Q(t,e,n,a,i,s,r,o,l){const d=j();K(d,e,n,a,i,s,r,o),l&&(F.a=e.width/l.width,F.d=e.height/l.height,Y(d,F)),t.transform=d}function Z(t,e,n,a,i,s,r,o,l,d,c,h){const u=j();if(h)K(u,e,i,s,r,o,l,d);else{if(l)if("center"===c)G(u,{x:n/2,y:a/2},l);else switch(N(u,l),l){case 90:z(u,a,0);break;case 180:z(u,n,a);break;case 270:z(u,0,n)}H.x=e.x+i,H.y=e.y+s,z(u,H.x,H.y),r&&U(u,H,r,o)}t.transform=u}function K(t,e,n,a,i,s,r,o){r&&N(t,r),o&&X(t,o.x,o.y),i&&q(t,i,s),z(t,e.x+n,e.y+a)}const{get:$,translate:J}=t.MatrixHelper,tt=new t.Bounds,et={},nt={};function at(t,e,n,a){const{changeful:i,sync:s,scaleFixed:r}=n;i&&(t.changeful=i),s&&(t.sync=s),r&&(t.scaleFixed=r),t.data=it(n,a,e)}function it(e,n,a){e.padding&&(n=tt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:i,height:s}=a;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,y=n.width===i&&n.height===s,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(nt,0,0,v?s:i,v?i:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,a,et),x=et.scaleX,b=et.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(nt,x,b,!0),l&&t.AlignHelper.toPoint(l,nt,n,nt,!0,!0))):y&&!u||(x=b=t.BoundsHelper.getFitScale(n,nt,"fit"!==o),t.BoundsHelper.put(n,a,l,x,!1,nt),t.BoundsHelper.scale(nt,x,b,!0)),d&&t.PointHelper.move(nt,d),o){case"stretch":y||(i=n.width,s=n.height);break;case"normal":case"clip":(nt.x||nt.y||x||p||u||f)&&Q(w,n,nt.x,nt.y,x,b,u,f,e.clipSize);break;case"repeat":(!y||x||u||f)&&Z(w,n,i,s,nt.x,nt.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const a=t.isObject(g);(_||a)&&(w.gap=function(e,n,a,i,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:st(r,a,s.width,n&&n.x),y:st(o,i,s.height,n&&n.y)}}(_,a&&g,nt.width,nt.height,n));break;default:x&&V(w,n,nt.x,nt.y,x,b,u)}return w.transform||(n.x||n.y)&&(w.transform=$(),J(w.transform,n.x,n.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=b),w.width=i,w.height=s,r&&(w.opacity=r),m&&(w.filters=m),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function st(e,n,a,i){const s=t.isString(e)||i?(i?a-i*n:a%n)/((i||Math.floor(a/n))-1):e;return"auto"===e&&s<0?0:s}let rt,ot=new t.Bounds;const{isSame:lt}=t.BoundsHelper;function dt(t,e,n,a,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||at(i,a,n,s),!0}function ct(e,n){ft(e,t.ImageEvent.LOAD,n)}function ht(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,a){n.error=a,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function pt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:gt,scale:_t,copy:mt}=t.MatrixHelper,{floor:yt,ceil:wt,max:vt,abs:xt}=Math;function bt(e,n,a){let{scaleX:i,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed);const r=i+"-"+s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=n;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;i*=a,s*=a,f&&(f=xt(f),p=xt(p),c=gt(),mt(c,g),_t(c,1/f,1/p),i*=f,s*=p),h*=i,u*=s;const y=h*u;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/wt(t))}else{const t=o.width*o.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(i/=d,s/=d,h/=d,u/=d),f&&(i/=f,s/=p);const v=m&&m.x*i,x=m&&m.y*s;if(g||1!==i||1!==s){const t=h+(v||0),e=u+(x||0);i/=t/vt(yt(t),1),s/=e/vt(yt(e),1),c||(c=gt(),g&&mt(c,g)),_t(c,1/i,1/s)}const b=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,n);return n.style=E,n.patternId=r,!0}}function Et(t,e,n,a){return new(n||(n=Promise))(function(i,s){function r(t){try{l(a.next(t))}catch(t){s(t)}}function o(t){try{l(a.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Bt={image:function(e,n,a,i,s){let r,o;const l=t.ImageManager.get(a);return rt&&a===rt.paint&&lt(i,rt.boxBounds)?r=rt.leafPaint:(r={type:a.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),rt=l.use>1?{leafPaint:r,paint:a,boxBounds:ot.set(i)}:null),(s||l.loading)&&(o={image:l,attrName:n,attrValue:a}),l.ready?(dt(e,n,a,l,r,i),s&&(ct(e,o),ht(e,o))):l.error?s&&ut(e,o,l.error):(s&&(pt(e,!0),ct(e,o)),r.loadId=l.load(()=>{pt(e,!1),e.destroyed||(dt(e,n,a,l,r,i)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,o)),r.loadId=void 0},t=>{pt(e,!1),ut(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(n,a,i,s){const{scaleX:r,scaleY:o}=n.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:l}=a,{data:d}=i;if(!d||i.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=r*l,n*=o*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(n.__.__isFastShadow&&(a.fillStyle=i.style||"#000",a.fill()),function(t,e,n,a){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);a.opacity&&(e.opacity*=a.opacity);a.transform&&e.transform(a.transform);e.drawImage(n.image.getFull(a.filters),0,0,a.width,a.height),e.restore()}(n,a,i,d),!0):(!i.style||i.sync||e.Export.running?bt(n,i,l):i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>Et(this,void 0,void 0,function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&bt(n,i,l),n.forceUpdate("surface")}),300)),!1)},createPattern:bt,recycleImage:function(e,n){const a=n["_"+e];if(t.isArray(a)){let i,s,r,o,l;for(let d=0,c=a.length;d<c;d++)i=a[d],s=i.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(a[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:it,fillOrFitMode:V,clipMode:Q,repeatMode:Z},{toPoint:St}=t.AroundHelper,{hasTransparent:Lt}=e.ColorConvert,Rt={},kt={};function Pt(n,a,i,s){if(i){let r,o,l,d;for(let n=0,c=i.length;n<c;n++)r=i[n],t.isString(r)?(l=n/(c-1),o=e.ColorConvert.string(r,s)):(l=r.offset,o=e.ColorConvert.string(r.color,s)),a.addColorStop(l,o),!d&&Lt(o)&&(d=!0);d&&(n.isTransparent=!0)}}const{getAngle:Ct,getDistance:At}=t.PointHelper,{get:Ot,rotateOfOuter:Tt,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:Wt}=t.AroundHelper,Dt={},It={};function Ht(t,e,n,a,i){let s;const{width:r,height:o}=t;if(r!==o||a){const t=Ct(e,n);s=Ot(),i?(Mt(s,e,r/o*(a||1),1),Tt(s,e,t+90)):(Mt(s,e,1,r/o*(a||1)),Tt(s,e,t))}return s}const{getDistance:Ft}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},zt={};const Ut={linearGradient:function(e,n){let{from:a,to:i,type:s,opacity:r}=e;St(a||"top",n,Rt),St(i||"bottom",n,kt);const o=t.Platform.canvas.createLinearGradient(Rt.x,Rt.y,kt.x,kt.y),l={type:s,style:o};return Pt(l,o,e.stops,r),l},radialGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;Wt(a||"center",n,Dt),Wt(i||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,At(Dt,It)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Dt,It,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;jt(a||"center",n,Gt),jt(i||"bottom",n,zt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Gt.x,Gt.y):t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Ft(Gt,zt)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Gt,zt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ht},{copy:Yt,toOffsetOutBounds:qt}=t.BoundsHelper,Nt={},Xt={};function Vt(e,n,a,i){const{bounds:s,shapeBounds:r}=i;if(t.Platform.fullImageShadow){if(Yt(Nt,e.bounds),Nt.x+=n.x-r.x,Nt.y+=n.y-r.y,a){const{fitMatrix:t}=i;Nt.x-=(s.x+(t?t.e:0)+s.width/2)*(a-1),Nt.y-=(s.y+(t?t.f:0)+s.height/2)*(a-1),Nt.width*=a,Nt.height*=a}e.copyWorld(i.canvas,e.bounds,Nt)}else a&&(Yt(Nt,n),Nt.x-=n.width/2*(a-1),Nt.y-=n.height/2*(a-1),Nt.width*=a,Nt.height*=a),e.copyWorld(i.canvas,r,a?Nt:n)}const{toOffsetOutBounds:Qt}=t.BoundsHelper,Zt={};const Kt={shadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{shadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;qt(h,Xt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Xt.offsetX+d.x*f*y,Xt.offsetY+d.y*p*y,d.blur*f*y,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Xt,r,i),s=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),s=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(i.canvas,u,h,"destination-out")),e.Effect.isTransformShadow(d)?e.Effect.renderTransformShadow(n,a,g,s,d):t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{innerShadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;Qt(h,Zt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(Zt.offsetX+d.x*f*y,Zt.offsetY+d.y*p*y,d.blur*f*y),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Zt,r,i),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,u,h,"source-out"),s=h),g.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,n){const{blur:a}=t.__;n.setWorldBlur(a*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){},getShadowSpread:function(t,e){let n=0;return e.forEach(t=>n=Math.max(n,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),n},isTransformShadow(t){}},{excludeRenderBounds:$t}=t.LeafBoundsHelper;let Jt;function te(t,e,n,a,i,s,r,o){switch(e){case"grayscale":Jt||(Jt=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,n,a,i,s){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,r),s&&a.recycle(r);ne(t,e,n,1,i,s)}(t,n,a,i,r,o);break;case"opacity-path":ne(t,n,a,s,r,o);break;case"path":o&&n.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ne(t,e,n,a,i,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,r,void 0,i),s?n.recycle(r):n.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let n,a,i,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(n=l[d],o=n.__.mask,o){r&&(te(this,r,t,i,a,s,void 0,!0),a=i=null),s=n.__.opacity,Jt=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",i||(i=ee(t))):(r="path",t.save()),n.__clip(i||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ee(t)),i||(i=ee(t)),n.__render(a,e)),"clipping"!==o&&"clipping-path"!==o||$t(n,e)||n.__render(t,e);continue}const c=1===s&&n.__.__blendMode;c&&te(this,r,t,i,a,s,void 0,!1),$t(n,e)||n.__render(i||t,e),c&&te(this,r,t,i,a,s,c,!1)}te(this,r,t,i,a,s,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ie=ae+"_#~&*+\\=|≮≯≈≠=…",se=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const oe=re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),de=re(ae),ce=re(ie),he=re("- —/~|┆·");var ue;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:me,Break:ye}=ue;function we(t){return oe[t]?fe:he[t]?ye:le[t]?ge:de[t]?_e:ce[t]?me:se.test(t)?pe:fe}const ve={trimRight(t){const{words:e}=t;let n,a=0,i=e.length;for(let s=i-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)a++,t.width-=n.width;a&&e.splice(i-a,a)}};function xe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:be}=ve,{Letter:Ee,Single:Be,Before:Se,After:Le,Symbol:Re,Break:ke}=ue;let Pe,Ce,Ae,Oe,Te,Me,We,De,Ie,He,Fe,je,Ge,ze,Ue,Ye,qe,Ne=[];function Xe(t,e){Ie&&!De&&(De=Ie),Pe.data.push({char:t,width:e}),Ae+=e}function Ve(){Oe+=Ae,Pe.width=Ae,Ce.words.push(Pe),Pe={data:[]},Ae=0}function Qe(){ze&&(Ue.paraNumber++,Ce.paraStart=!0,ze=!1),Ie&&(Ce.startCharSize=De,Ce.endCharSize=Ie,De=0),Ce.width=Oe,Ye.width?be(Ce):qe&&Ze(),Ne.push(Ce),Ce={words:[]},Oe=0}function Ze(){Oe>(Ue.maxWidth||0)&&(Ue.maxWidth=Oe)}const{top:Ke,right:$e,bottom:Je,left:tn}=t.Direction4;function en(t,e,n){const{bounds:a,rows:i}=t;a[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const nn={getDrawData:function(n,a){t.isString(n)||(n=String(n));let i=0,s=0,r=a.__getInput("width")||0,o=a.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=a;c&&(r?(i=c[tn],r-=c[$e]+c[tn]):a.autoSizeAlign||(i=c[tn]),o?(s=c[Ke],o-=c[Ke]+c[Je]):a.autoSizeAlign||(s=c[Ke]));const h={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){Ue=e,Ne=e.rows,Ye=e.bounds,qe=!Ye.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:s,textCase:r}=a,{canvas:o}=t.Platform,{width:l,height:d}=Ye;if(l||d||i||"none"!==r){const t="none"!==a.textWrap,e="break"===a.textWrap;ze=!0,Fe=null,De=We=Ie=Ae=Oe=0,Pe={data:[]},Ce={words:[]},i&&(n=[...n]);for(let a=0,d=n.length;a<d;a++)Me=n[a],"\n"===Me?(Ae&&Ve(),Ce.paraEnd=!0,Qe(),ze=!0):(He=we(Me),He===Ee&&"none"!==r&&(Me=xe(Me,r,!Ae)),We=o.measureText(Me).width,i&&(i<0&&(Ie=We),We+=i),je=He===Be&&(Fe===Be||Fe===Ee)||Fe===Be&&He!==Le,Ge=!(He!==Se&&He!==Be||Fe!==Re&&Fe!==Le),Te=ze&&s?l-s:l,t&&l&&Oe+Ae+We>Te&&(e?(Ae&&Ve(),Oe&&Qe()):(Ge||(Ge=He===Ee&&Fe==Le),je||Ge||He===ke||He===Se||He===Be||Ae+We>Te?(Ae&&Ve(),Oe&&Qe()):Oe&&Qe()))," "===Me&&!0!==ze&&Oe+Ae===0||(He===ke?(" "===Me&&Ae&&Ve(),Xe(Me,We),Ve()):je||Ge?(Ae&&Ve(),Xe(Me,We)):Xe(Me,We)),Fe=He);Ae&&Ve(),Oe&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else n.split("\n").forEach(t=>{Ue.paraNumber++,Oe=o.measureText(t).width,Ne.push({x:s||0,text:t,width:Oe,paraStart:!0}),qe&&Ze()})}(h,n,a),c&&function(t,e,n,a,i){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[$e])}if(!i&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[Je])}}(c,h,a,r,o),function(t,e){const{rows:n,bounds:a}=t,i=n.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=s*i+(h?h*(t.paraNumber-1):0),y=r;if(l&&m>_)m=Math.max(_,s),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=i;r<c;r++){if(w=n[r],w.x=f,w.width<g||w.width>g&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&r>0&&(y+=h),w.y=y,y+=s,t.overflow>r&&y>m&&(w.isOverflow=!0,t.overflow=r+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<a.x&&(a.x=v),x>a.width&&(a.width=x),l&&g&&g<x&&(w.isOverflow=!0,t.overflow||(t.overflow=n.length))}a.y=p,a.height=m}(h,a),function(t,e,n){const{rows:a}=t,{textAlign:i,paraIndent:s,letterSpacing:r}=e;let o,l,d,c,h,u;a.forEach(t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===i||"both"===i)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,n)=>{1===c?(h={char:"",x:o},o=function(t,e,n){return t.forEach(t=>{n.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,n,a){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==i||n===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,a,r),h.overflow&&function(e,n,a,i){if(!i)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=n;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+i-d;("none"===n.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let a=n;a>-1&&(e=t.data[a],l=e.x+e.width,!(a===n&&l<c));a--){if(l<c&&" "!==e.char||!a){t.data.splice(a+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(h,a,i,r),"none"!==l&&function(n,a){let i,s=0;const{fontSize:r,textDecoration:o}=a;switch(n.decorationHeight=r/11,t.isObject(o)?(i=o.type,o.color&&(n.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):i=o,i){case"under":n.decorationY=[.15*r+s];break;case"delete":n.decorationY=[.35*-r];break;case"under-delete":n.decorationY=[.15*r+s,.35*-r]}}(h,a),h}};const an={string:function(n,a){const i=t.isNumber(a)&&a<1;if(t.isString(n)){if(!i||!e.ColorConvert.object)return n;n=e.ColorConvert.object(n)}let s=t.isUndefined(n.a)?1:n.a;i&&(s*=a);const r=n.r+","+n.g+","+n.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(e.TextConvert,nn),Object.assign(e.ColorConvert,an),Object.assign(e.Paint,I),Object.assign(e.PaintImage,Bt),Object.assign(e.PaintGradient,Ut),Object.assign(e.Effect,Kt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=w,exports.Watcher=r,exports.useCanvas=i,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]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
2
2
  //# sourceMappingURL=worker.min.cjs.map