@leafer-ui/worker 1.6.1 → 1.6.2

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.cjs CHANGED
@@ -187,7 +187,7 @@ class Watcher {
187
187
  }
188
188
  }
189
189
 
190
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = core.LeafHelper;
190
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
191
191
  const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
192
192
  function updateMatrix(updateList, levelList) {
193
193
  let layout;
@@ -230,15 +230,7 @@ function updateBounds(boundsList) {
230
230
  });
231
231
  }
232
232
  function updateChange(updateList) {
233
- let layout;
234
- updateList.list.forEach(leaf => {
235
- layout = leaf.__layout;
236
- if (layout.opacityChanged)
237
- updateAllWorldOpacity(leaf);
238
- if (layout.stateStyleChanged)
239
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
240
- leaf.__updateChange();
241
- });
233
+ updateList.list.forEach(updateOneChange);
242
234
  }
243
235
 
244
236
  const { worldBounds } = core.LeafBoundsHelper;
@@ -829,8 +821,10 @@ Object.assign(core.Creator, {
829
821
  core.Platform.layout = Layouter.fullLayout;
830
822
 
831
823
  function fillText(ui, canvas) {
832
- let row, data = ui.__.__textDrawData;
833
- const { rows, decorationY } = data;
824
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
825
+ if (data.__isPlacehold && data.placeholderColor)
826
+ canvas.fillStyle = data.placeholderColor;
827
+ let row;
834
828
  for (let i = 0, len = rows.length; i < len; i++) {
835
829
  row = rows[i];
836
830
  if (row.text)
@@ -839,7 +833,7 @@ function fillText(ui, canvas) {
839
833
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
840
834
  }
841
835
  if (decorationY) {
842
- const { decorationColor, decorationHeight } = data;
836
+ const { decorationColor, decorationHeight } = data.__textDrawData;
843
837
  if (decorationColor)
844
838
  canvas.fillStyle = decorationColor;
845
839
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -848,38 +842,44 @@ function fillText(ui, canvas) {
848
842
 
849
843
  function fill(fill, ui, canvas) {
850
844
  canvas.fillStyle = fill;
851
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
845
+ fillPathOrText(ui, canvas);
852
846
  }
853
847
  function fills(fills, ui, canvas) {
854
848
  let item;
855
- const { windingRule, __font } = ui.__;
856
849
  for (let i = 0, len = fills.length; i < len; i++) {
857
850
  item = fills[i];
858
- if (item.image && draw.PaintImage.checkImage(ui, canvas, item, !__font))
859
- continue;
860
- if (item.style) {
861
- canvas.fillStyle = item.style;
862
- if (item.transform) {
863
- canvas.save();
864
- canvas.transform(item.transform);
865
- if (item.blendMode)
866
- canvas.blendMode = item.blendMode;
867
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
868
- canvas.restore();
851
+ if (item.image) {
852
+ if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
853
+ continue;
854
+ if (!item.style) {
855
+ if (!i && item.image.isPlacehold)
856
+ ui.drawImagePlaceholder(canvas, item.image);
857
+ continue;
869
858
  }
870
- else {
871
- if (item.blendMode) {
872
- canvas.saveBlendMode(item.blendMode);
873
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
874
- canvas.restoreBlendMode();
875
- }
876
- else {
877
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
878
- }
859
+ }
860
+ canvas.fillStyle = item.style;
861
+ if (item.transform) {
862
+ canvas.save();
863
+ canvas.transform(item.transform);
864
+ if (item.blendMode)
865
+ canvas.blendMode = item.blendMode;
866
+ fillPathOrText(ui, canvas);
867
+ canvas.restore();
868
+ }
869
+ else {
870
+ if (item.blendMode) {
871
+ canvas.saveBlendMode(item.blendMode);
872
+ fillPathOrText(ui, canvas);
873
+ canvas.restoreBlendMode();
879
874
  }
875
+ else
876
+ fillPathOrText(ui, canvas);
880
877
  }
881
878
  }
882
879
  }
880
+ function fillPathOrText(ui, canvas) {
881
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
882
+ }
883
883
 
884
884
  function strokeText(stroke, ui, canvas) {
885
885
  const { strokeAlign } = ui.__;
@@ -1119,6 +1119,7 @@ const PaintModule = {
1119
1119
  compute,
1120
1120
  fill,
1121
1121
  fills,
1122
+ fillPathOrText,
1122
1123
  fillText,
1123
1124
  stroke,
1124
1125
  strokes,
@@ -1311,6 +1312,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1311
1312
  onLoadError(ui, event, error);
1312
1313
  leafPaint.loadId = null;
1313
1314
  });
1315
+ if (ui.placeholderColor)
1316
+ setTimeout(() => {
1317
+ if (!(image.ready || image.isPlacehold)) {
1318
+ image.isPlacehold = true;
1319
+ ui.forceUpdate('surface');
1320
+ }
1321
+ }, 100);
1314
1322
  }
1315
1323
  return leafPaint;
1316
1324
  }
@@ -2403,4 +2411,3 @@ Object.keys(core$1).forEach(function (k) {
2403
2411
  get: function () { return core$1[k]; }
2404
2412
  });
2405
2413
  });
2406
- //# sourceMappingURL=worker.cjs.map
@@ -188,7 +188,7 @@ class Watcher {
188
188
  }
189
189
  }
190
190
 
191
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
191
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
192
192
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
193
193
  function updateMatrix(updateList, levelList) {
194
194
  let layout;
@@ -231,15 +231,7 @@ function updateBounds(boundsList) {
231
231
  });
232
232
  }
233
233
  function updateChange(updateList) {
234
- let layout;
235
- updateList.list.forEach(leaf => {
236
- layout = leaf.__layout;
237
- if (layout.opacityChanged)
238
- updateAllWorldOpacity(leaf);
239
- if (layout.stateStyleChanged)
240
- setTimeout(() => layout.stateStyleChanged && leaf.updateState());
241
- leaf.__updateChange();
242
- });
234
+ updateList.list.forEach(updateOneChange);
243
235
  }
244
236
 
245
237
  const { worldBounds } = LeafBoundsHelper;
@@ -830,8 +822,10 @@ Object.assign(Creator, {
830
822
  Platform.layout = Layouter.fullLayout;
831
823
 
832
824
  function fillText(ui, canvas) {
833
- let row, data = ui.__.__textDrawData;
834
- const { rows, decorationY } = data;
825
+ const data = ui.__, { rows, decorationY } = data.__textDrawData;
826
+ if (data.__isPlacehold && data.placeholderColor)
827
+ canvas.fillStyle = data.placeholderColor;
828
+ let row;
835
829
  for (let i = 0, len = rows.length; i < len; i++) {
836
830
  row = rows[i];
837
831
  if (row.text)
@@ -840,7 +834,7 @@ function fillText(ui, canvas) {
840
834
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
841
835
  }
842
836
  if (decorationY) {
843
- const { decorationColor, decorationHeight } = data;
837
+ const { decorationColor, decorationHeight } = data.__textDrawData;
844
838
  if (decorationColor)
845
839
  canvas.fillStyle = decorationColor;
846
840
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
@@ -849,38 +843,44 @@ function fillText(ui, canvas) {
849
843
 
850
844
  function fill(fill, ui, canvas) {
851
845
  canvas.fillStyle = fill;
852
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
846
+ fillPathOrText(ui, canvas);
853
847
  }
854
848
  function fills(fills, ui, canvas) {
855
849
  let item;
856
- const { windingRule, __font } = ui.__;
857
850
  for (let i = 0, len = fills.length; i < len; i++) {
858
851
  item = fills[i];
859
- if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
860
- continue;
861
- if (item.style) {
862
- canvas.fillStyle = item.style;
863
- if (item.transform) {
864
- canvas.save();
865
- canvas.transform(item.transform);
866
- if (item.blendMode)
867
- canvas.blendMode = item.blendMode;
868
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
869
- canvas.restore();
852
+ if (item.image) {
853
+ if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
854
+ continue;
855
+ if (!item.style) {
856
+ if (!i && item.image.isPlacehold)
857
+ ui.drawImagePlaceholder(canvas, item.image);
858
+ continue;
870
859
  }
871
- else {
872
- if (item.blendMode) {
873
- canvas.saveBlendMode(item.blendMode);
874
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
875
- canvas.restoreBlendMode();
876
- }
877
- else {
878
- __font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
879
- }
860
+ }
861
+ canvas.fillStyle = item.style;
862
+ if (item.transform) {
863
+ canvas.save();
864
+ canvas.transform(item.transform);
865
+ if (item.blendMode)
866
+ canvas.blendMode = item.blendMode;
867
+ fillPathOrText(ui, canvas);
868
+ canvas.restore();
869
+ }
870
+ else {
871
+ if (item.blendMode) {
872
+ canvas.saveBlendMode(item.blendMode);
873
+ fillPathOrText(ui, canvas);
874
+ canvas.restoreBlendMode();
880
875
  }
876
+ else
877
+ fillPathOrText(ui, canvas);
881
878
  }
882
879
  }
883
880
  }
881
+ function fillPathOrText(ui, canvas) {
882
+ ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
883
+ }
884
884
 
885
885
  function strokeText(stroke, ui, canvas) {
886
886
  const { strokeAlign } = ui.__;
@@ -1120,6 +1120,7 @@ const PaintModule = {
1120
1120
  compute,
1121
1121
  fill,
1122
1122
  fills,
1123
+ fillPathOrText,
1123
1124
  fillText,
1124
1125
  stroke,
1125
1126
  strokes,
@@ -1312,6 +1313,13 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1312
1313
  onLoadError(ui, event, error);
1313
1314
  leafPaint.loadId = null;
1314
1315
  });
1316
+ if (ui.placeholderColor)
1317
+ setTimeout(() => {
1318
+ if (!(image.ready || image.isPlacehold)) {
1319
+ image.isPlacehold = true;
1320
+ ui.forceUpdate('surface');
1321
+ }
1322
+ }, 100);
1315
1323
  }
1316
1324
  return leafPaint;
1317
1325
  }
@@ -2382,4 +2390,3 @@ Object.assign(Creator, {
2382
2390
  useCanvas();
2383
2391
 
2384
2392
  export { Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
2385
- //# sourceMappingURL=worker.esm.js.map
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as _,LeafBoundsHelper as g,Bounds as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as E,AlignHelper as S,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as C,InteractionBase as T}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,ColorConvert as P,PaintGradient as D,Export as I,Group as F,TextConvert as Y,Paint as G,Effect as z}from"@leafer-ui/draw";class N extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:U}=n;function X(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:U(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:U(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new N(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):j.indexOf("Safari")>-1&&-1===j.indexOf("Chrome")&&(e.fullImageShadow=!0),j.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):j.indexOf("Mac")>-1?e.os="Mac":j.indexOf("Linux")>-1&&(e.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=d.default(e,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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:V,updateAllWorldOpacity:Q}=f,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:J}=g;class K{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,J),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:tt,updateAllChange:et}=f,it=w.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,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.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:r}=m,o=this.getBlocks(n);o.forEach((t=>t.setBefore())),i.emitEvent(new m(s,o,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(H(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||V(n[t])}V(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&Q(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new m(a,o,this.times)),i.emitEvent(new m(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new o(e));e.emitEvent(new m(i,a,this.times)),nt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new K([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new K(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(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=w.get("Renderer");class at{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,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(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,st.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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(t){const e=x.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new p(n);i.save(),n.spread(at.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new p(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(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||st.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}at.clipSpread=10;const{hitRadiusPoint:rt}=B;class ot{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,r=i.length;t<r;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||rt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new ot(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function lt(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(a){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>a.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function ht(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ft(t,!0,e,i):ut(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:a,__font:r}=n.__,o=s.getSameCanvas(!0,!0);o.setStroke(i?void 0:e,2*a,n.__),o.font=r,i?ft(e,!0,n,o):ut(n,o),o.blendMode="outside"===t?"destination-out":"destination-in",lt(n,o),o.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(o,n.__nowWorld):s.copyWorldToInner(o,n.__nowWorld,n.__layout.renderBounds),o.recycle(n.__nowWorld)}function ut(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=n;s.forEach((i=>a.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function ft(t,e,i,n){let s;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ut(i,n):n.stroke(),n.restoreBlendMode()):e?ut(i,n):n.stroke())}function _t(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new at(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=nt.fullLayout;const{getSpread:gt,getOuterOf:pt,getByMove:wt,getIntersectData:yt}=B;let mt;function xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:r,opacity:o}=e;return{type:s,blendMode:a,style:P.string(r,o)};case"image":return M.image(i,t,e,n,!mt||!mt[e.url]);case"linear":return D.linearGradient(e,n);case"radial":return D.radialGradient(e,n);case"angular":return D.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:P.string(e)}:void 0}}const vt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),mt=M.recycleImage(t,i);for(let i,s=0,r=a.length;s<r;s++)i=xt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?lt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let r=0,o=t.length;r<o;r++)n=t[r],n.image&&M.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?lt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?lt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?lt(e,i):s?i.fill(s):i.fill())},fillText:lt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=n;if(s)if(r)ht(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&_t(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=n;if(s)if(r)ht(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i),n.__useArrow&&_t(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,n),ft(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:ht,drawTextStroke:ut,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=o=s;else{const{renderShapeSpread:n}=t.__layout,c=yt(n?gt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),o=pt(s,r),a=wt(o,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let bt={};const{get:Bt,rotateOfOuter:kt,translate:Rt,scaleOfOuter:Et,scale:St,rotate:Lt}=R;function At(t,e,i,n,s,a,r){const o=Bt();Rt(o,e.x+i,e.y+n),St(o,s,a),r&&kt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Wt(t,e,i,n,s,a,r){const o=Bt();Rt(o,e.x+i,e.y+n),s&&St(o,s,a),r&&Lt(o,r),t.transform=o}function Ot(t,e,i,n,s,a,r,o,d,l){const h=Bt();if(d)if("center"===l)kt(h,{x:i/2,y:n/2},d);else switch(Lt(h,d),d){case 90:Rt(h,n,0);break;case 180:Rt(h,i,n);break;case 270:Rt(h,0,i)}bt.x=e.x+s,bt.y=e.y+a,Rt(h,bt.x,bt.y),r&&Et(h,bt,r,o),t.transform=h}const{get:Ct,translate:Tt}=R,Mt=new p,Pt={},Dt={};function It(t,e,i,n){const{blendMode:s,changeful:a,sync:r}=i;s&&(t.blendMode=s),a&&(t.changeful=a),r&&(t.sync=r),t.data=Ft(i,n,e)}function Ft(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Mt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:r,align:o,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:f}=t,_=e.width===n&&e.height===s,g={mode:r},p="center"!==o&&(c||0)%180==90,w=p?s:n,y=p?n:s;let m,x,v=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||h)&&(E.getScaleData(l,h,i,Dt),m=Dt.scaleX,x=Dt.scaleY);else if(!_||c){const t=e.width/w,i=e.height/y;m=x="fit"===r?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,b+=(e.height-s*x)/2}if(o){const t={x:v,y:b,width:w,height:y};m&&(t.width*=m,t.height*=x),S.toPoint(o,t,e,Pt,!0),v+=Pt.x,b+=Pt.y}switch(d&&(v+=d.x,b+=d.y),r){case"stretch":_||(n=e.width,s=e.height);break;case"normal":case"clip":(v||b||m||c)&&Wt(g,e,v,b,m,x,c);break;case"repeat":(!_||m||c)&&Ot(g,e,n,s,v,b,m,x,c,o),u||(g.repeat="repeat");break;default:m&&At(g,e,v,b,m,x,c)}return g.transform||(e.x||e.y)&&(g.transform=Ct(),Tt(g.transform,e.x,e.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=x),g.width=n,g.height=s,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Yt,Gt=new p;const{isSame:zt}=B;function Nt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||It(s,n,i,a),!0}function Ut(t,e){qt(t,L.LOAD,e)}function Xt(t,e){qt(t,L.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,L.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Ht(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Vt,scale:Qt,copy:Zt}=R,{ceil:$t,abs:Jt}=Math;function Kt(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const r=s+"-"+a+"-"+n;if(i.patternId===r||t.destroyed)return!1;{s=Jt(s),a=Jt(a);const{image:t,data:o}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:_,repeat:g}=o;u&&(l=Vt(),Zt(l,_),Qt(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const p=h*c;if(!g&&p>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}p>w&&(d=Math.sqrt(p/w)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=Vt(),_&&Zt(l,_)),Qt(l,1/s,1/a));const y=t.getCanvas($t(h)||1,$t(c)||1,o.opacity,o.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=r,!0}}function te(t,e,i,n){return new(i||(i=Promise))((function(s,a){function r(t){try{d(n.next(t))}catch(t){a(t)}}function o(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ee}=Math;const ie={image:function(t,e,i,n,s){let a,r;const o=v.get(i);return Yt&&i===Yt.paint&&zt(n,Yt.boxBounds)?a=Yt.leafPaint:(a={type:i.type,image:o},Yt=o.use>1?{leafPaint:a,paint:i,boxBounds:Gt.set(n)}:null),(s||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Nt(t,e,i,o,a,n),s&&(Ut(t,r),Xt(t,r))):o.error?s&&jt(t,r,o.error):(s&&(Ht(t,!0),Ut(t,r)),a.loadId=o.load((()=>{Ht(t,!1),t.destroyed||(Nt(t,e,i,o,a,n)&&(o.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Xt(t,r)),a.loadId=null}),(e=>{Ht(t,!1),jt(t,r,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:r}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:o}=i,{data:d}=n;if(!d||n.patternId===a+"-"+r+"-"+o&&!I.running)return!1;if(s)if(d.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||I.running)){let{width:t,height:i}=d;t*=ee(a)*o,i*=ee(r)*o,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,d),!0):(!n.style||n.sync||I.running?Kt(t,n,o):n.patternTask||(n.patternTask=v.patternTasker.add((()=>te(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Kt(t,n,o),t.forceUpdate("surface")}))),300)),!1)},createPattern:Kt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,r,o;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,v.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:It,getPatternData:Ft,fillOrFitMode:At,clipMode:Wt,repeatMode:Ot},{toPoint:ne}=A,se={},ae={};function re(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}}const{getAngle:oe,getDistance:de}=W,{get:le,rotateOfOuter:he,scaleOfOuter:ce}=R,{toPoint:ue}=A,fe={},_e={};function ge(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=oe(e,i);a=le(),s?(ce(a,e,r/o*(n||1),1),he(a,e,t+90)):(ce(a,e,1,r/o*(n||1)),he(a,e,t))}return a}const{getDistance:pe}=W,{toPoint:we}=A,ye={},me={};const xe={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:r,opacity:o}=t;ne(n||"top",i,se),ne(s||"bottom",i,ae);const d=e.canvas.createLinearGradient(se.x,se.y,ae.x,ae.y);re(d,t.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,blendMode:o,stretch:d}=t;ue(n||"center",i,fe),ue(s||"bottom",i,_e);const l=e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,de(fe,_e));re(l,t.stops,r);const h={type:a,style:l},c=ge(i,fe,_e,d,!0);return c&&(h.transform=c),o&&(h.blendMode=o),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:r,blendMode:o,stretch:d}=t;we(n||"center",i,ye),we(s||"bottom",i,me);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,ye.x,ye.y):e.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,pe(ye,me));re(l,t.stops,r);const h={type:a,style:l},c=ge(i,ye,me,d||1,e.conicGradientRotate90);return c&&(h.transform=c),o&&(h.blendMode=o),h},getTransform:ge},{copy:ve,toOffsetOutBounds:be}=B,Be={},ke={};function Re(t,i,n,s){const{bounds:a,shapeBounds:r}=s;if(e.fullImageShadow){if(ve(Be,t.bounds),Be.x+=i.x-r.x,Be.y+=i.y-r.y,n){const{matrix:t}=s;Be.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Be.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Be.width*=n,Be.height*=n}t.copyWorld(s.canvas,t.bounds,Be)}else n&&(ve(Be,i),Be.x-=i.width/2*(n-1),Be.y-=i.height/2*(n-1),Be.width*=n,Be.height*=n),t.copyWorld(s.canvas,r,n?Be:i)}const{toOffsetOutBounds:Ee}=B,Se={};const Le={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=o.length-1;be(l,ke),o.forEach(((o,g)=>{f.setWorldShadow(ke.offsetX+o.x*c,ke.offsetY+o.y*u,o.blur*c,P.string(o.color)),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Re(f,ke,s,i),n=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,o.blendMode):e.copyWorldToInner(f,n,r.renderBounds,o.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=o.length-1;Ee(l,Se),o.forEach(((o,g)=>{f.save(),f.setWorldShadow(Se.offsetX+o.x*c,Se.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Re(f,Se,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,P.string(o.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,o.blendMode):e.copyWorldToInner(f,n,r.renderBounds,o.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ae}=g;function We(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ce(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ce(t,i,n,a);break;case"path":i.restore()}}function Oe(t){return t.getSameCanvas(!1,!0)}function Ce(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,a,r,o;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],o=i.__.mask,o&&(r&&(We(this,r,t,s,n,a),n=s=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",a=i.opacity,s||(s=Oe(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=Oe(t)),s||(s=Oe(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o)||Ae(i,e)||i.__render(s||t,e);We(this,r,t,s,n,a)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Me=Te+"_#~&*+\\=|≮≯≈≠=…",Pe=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 De(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ie=De("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Fe=De("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ye=De(Te),Ge=De(Me),ze=De("- —/~|┆·");var Ne;!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"}(Ne||(Ne={}));const{Letter:Ue,Single:Xe,Before:je,After:qe,Symbol:He,Break:Ve}=Ne;function Qe(t){return Ie[t]?Ue:ze[t]?Ve:Fe[t]?je:Ye[t]?qe:Ge[t]?He:Pe.test(t)?Xe:Ue}const Ze={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function $e(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Je}=Ze,{Letter:Ke,Single:ti,Before:ei,After:ii,Symbol:ni,Break:si}=Ne;let ai,ri,oi,di,li,hi,ci,ui,fi,_i,gi,pi,wi,yi,mi,xi,vi,bi=[];function Bi(t,e){fi&&!ui&&(ui=fi),ai.data.push({char:t,width:e}),oi+=e}function ki(){di+=oi,ai.width=oi,ri.words.push(ai),ai={data:[]},oi=0}function Ri(){yi&&(mi.paraNumber++,ri.paraStart=!0,yi=!1),fi&&(ri.startCharSize=ui,ri.endCharSize=fi,ui=0),ri.width=di,xi.width?Je(ri):vi&&Ei(),bi.push(ri),ri={words:[]},di=0}function Ei(){di>(mi.maxWidth||0)&&(mi.maxWidth=di)}const{top:Si,right:Li,bottom:Ai,left:Wi}=O;function Oi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ci={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=i;l&&(a?(n=l[Wi],a-=l[Li]+l[Wi]):i.autoSizeAlign||(n=l[Wi]),r?(s=l[Si],r-=l[Si]+l[Ai]):i.autoSizeAlign||(s=l[Si]));const h={bounds:{x:n,y:s,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){mi=t,bi=t.rows,xi=t.bounds,vi=!xi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=e,{width:d,height:l}=xi;if(d||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;yi=!0,gi=null,ui=ci=fi=oi=di=0,ai={data:[]},ri={words:[]};for(let n=0,l=i.length;n<l;n++)hi=i[n],"\n"===hi?(oi&&ki(),ri.paraEnd=!0,Ri(),yi=!0):(_i=Qe(hi),_i===Ke&&"none"!==r&&(hi=$e(hi,r,!oi)),ci=o.measureText(hi).width,s&&(s<0&&(fi=ci),ci+=s),pi=_i===ti&&(gi===ti||gi===Ke)||gi===ti&&_i!==ii,wi=!(_i!==ei&&_i!==ti||gi!==ni&&gi!==ii),li=yi&&a?d-a:d,t&&d&&di+oi+ci>li&&(e?(oi&&ki(),di&&Ri()):(wi||(wi=_i===Ke&&gi==ii),pi||wi||_i===si||_i===ei||_i===ti||oi+ci>li?(oi&&ki(),di&&Ri()):di&&Ri()))," "===hi&&!0!==yi&&di+oi===0||(_i===si?(" "===hi&&oi&&ki(),Bi(hi,ci),ki()):pi||wi?(oi&&ki(),Bi(hi,ci)):Bi(hi,ci)),gi=_i);oi&&ki(),di&&Ri(),bi.length>0&&(bi[bi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{mi.paraNumber++,di=o.measureText(t).width,bi.push({x:a||0,text:t,width:di,paraStart:!0}),vi&&Ei()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Oi(e,"x",t[Wi]);break;case"right":Oi(e,"x",-t[Li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Oi(e,"y",t[Si]);break;case"bottom":Oi(e,"y",-t[Ai])}}(l,h,i,a,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:_,width:g,height:p}=n,w=a*s+(c?c*(t.paraNumber-1):0),y=r;if(d&&w>p)w=Math.max(p,a),s>1&&(t.overflow=s);else if(p||u)switch(h){case"middle":_+=(p-w)/2;break;case"bottom":_+=p-w}y+=_;let m,x,v,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<n.x&&(n.x=x),v>n.width&&(n.width=v),d&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,d,l,h,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,h=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,o=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(o+=d,t.width+=d)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,d;"hide"===o?o="":"ellipsis"===o&&(o="...");const l=o?e.canvas.measureText(o).width:0,h=n+s-l;("none"===i.textWrap?a:[a[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:o,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,a),"none"!==o&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=P.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,i),h}};const Ti={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(Y,Ci),Object.assign(P,Ti),Object.assign(G,vt),Object.assign(M,ie),Object.assign(D,xe),Object.assign(z,Le),Object.assign(s,{interaction:(t,e,i,n)=>new T(t,e,i,n),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new C}),X();export{nt as Layouter,N as LeaferCanvas,ot as Picker,at as Renderer,dt as Selector,q as Watcher,X as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as o,defineKey as r,LeafList as a,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as _,LeafBoundsHelper as g,Bounds as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as x,ImageManager as v,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as E,AlignHelper as S,ImageEvent as L,AroundHelper as A,PointHelper as W,Direction4 as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as C,InteractionBase as T}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,ColorConvert as P,PaintGradient as D,Export as I,Group as F,TextConvert as Y,Paint as G,Effect as z}from"@leafer-ui/draw";class U extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:N}=n;function X(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:N(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:N(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(s,{canvas:(t,e)=>new U(t,e),image:t=>new o(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:j}=navigator;j.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):j.indexOf("Safari")>-1&&-1===j.indexOf("Chrome")&&(e.fullImageShadow=!0),j.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):j.indexOf("Mac")>-1?e.os="Mac":j.indexOf("Linux")>-1&&(e.os="Linux");class q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new a;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new a,this.target=t,e&&(this.config=d.default(e,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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:H,updateBounds:V,updateChange:Q}=f,{pushAllChildBranch:Z,pushAllParent:$}=_;const{worldBounds:J}=g;class K{constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,J)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,J),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:tt,updateAllChange:et}=f,it=w.get("Layouter");class nt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,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.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=m,a=this.getBlocks(n);a.forEach((t=>t.setBefore())),i.emitEvent(new m(s,a,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(H(t,!0),e.add(t),t.isBranch&&Z(t,e),$(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),$(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||V(n[t])}V(i)}}))}(this.__levelList),function(t){t.list.forEach(Q)}(n),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new m(o,a,this.times)),i.emitEvent(new m(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,o=this.getBlocks(new a(e));e.emitEvent(new m(i,o,this.times)),nt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new K([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new K(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(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=w.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,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(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(l.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(l.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,st.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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(t){const e=x.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new p(n);i.save(),n.spread(ot.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new p(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(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||st.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}ot.clipSpread=10;const{hitRadiusPoint:rt}=B;class at{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new a(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new a;const{x:n,y:s}=this.point,o={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new a;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new a;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new a,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,o;for(let t=0,r=i.length;t<r;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(o=n.list[t],!s||!s.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||rt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class dt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new at(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:o}=this;return e.backgrounder&&s&&s.updateLayout(),o.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function lt(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function ht(t,e){t.__.__font?lt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ct(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?_t(t,!0,e,i):ft(e,i);break;case"inside":ut("inside",t,s,e,i);break;case"outside":ut("outside",t,s,e,i)}}function ut(t,e,i,n,s){const{__strokeWidth:o,__font:r}=n.__,a=s.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,n.__),a.font=r,i?_t(e,!0,n,a):ft(n,a),a.blendMode="outside"===t?"destination-out":"destination-in",lt(n,a),a.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(a,n.__nowWorld):s.copyWorldToInner(a,n.__nowWorld,n.__layout.renderBounds),a.recycle(n.__nowWorld)}function ft(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function _t(t,e,i,n){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ft(i,n):n.stroke(),n.restoreBlendMode()):e?ft(i,n):n.stroke())}function gt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new q(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>new dt(t,e)}),e.layout=nt.fullLayout;const{getSpread:pt,getOuterOf:wt,getByMove:yt,getIntersectData:mt}=B;let xt;function vt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:a}=e;return{type:s,blendMode:o,style:P.string(r,a)};case"image":return M.image(i,t,e,n,!xt||!xt[e.url]);case"linear":return D.linearGradient(e,n);case"radial":return D.radialGradient(e,n);case"angular":return D.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:P.string(e)}:void 0}}const bt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),xt=M.recycleImage(t,i);for(let i,s=0,r=o.length;s<r;s++)i=vt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,ht(e,i)},fills:function(t,e,i){let n;for(let s=0,o=t.length;s<o;s++){if(n=t[s],n.image){if(M.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),ht(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),ht(e,i),i.restoreBlendMode()):ht(e,i)}},fillPathOrText:ht,fillText:lt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)ct(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&gt(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)ct(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),_t(t,!1,e,i),n.__useArrow&&gt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),_t(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,n),_t(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:ct,drawTextStroke:ft,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,c=mt(n?pt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),a=wt(s,r),o=yt(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:d,shapeBounds:a,scaleX:l,scaleY:h}}};let Bt={};const{get:kt,rotateOfOuter:Rt,translate:Et,scaleOfOuter:St,scale:Lt,rotate:At}=R;function Wt(t,e,i,n,s,o,r){const a=kt();Et(a,e.x+i,e.y+n),Lt(a,s,o),r&&Rt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Ot(t,e,i,n,s,o,r){const a=kt();Et(a,e.x+i,e.y+n),s&&Lt(a,s,o),r&&At(a,r),t.transform=a}function Ct(t,e,i,n,s,o,r,a,d,l){const h=kt();if(d)if("center"===l)Rt(h,{x:i/2,y:n/2},d);else switch(At(h,d),d){case 90:Et(h,n,0);break;case 180:Et(h,i,n);break;case 270:Et(h,0,i)}Bt.x=e.x+s,Bt.y=e.y+o,Et(h,Bt.x,Bt.y),r&&St(h,Bt,r,a),t.transform=h}const{get:Tt,translate:Mt}=R,Pt=new p,Dt={},It={};function Ft(t,e,i,n){const{blendMode:s,changeful:o,sync:r}=i;s&&(t.blendMode=s),o&&(t.changeful=o),r&&(t.sync=r),t.data=Yt(i,n,e)}function Yt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Pt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:d,scale:l,size:h,rotation:c,repeat:u,filters:f}=t,_=e.width===n&&e.height===s,g={mode:r},p="center"!==a&&(c||0)%180==90,w=p?s:n,y=p?n:s;let m,x,v=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||h)&&(E.getScaleData(l,h,i,It),m=It.scaleX,x=It.scaleY);else if(!_||c){const t=e.width/w,i=e.height/y;m=x="fit"===r?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,b+=(e.height-s*x)/2}if(a){const t={x:v,y:b,width:w,height:y};m&&(t.width*=m,t.height*=x),S.toPoint(a,t,e,Dt,!0),v+=Dt.x,b+=Dt.y}switch(d&&(v+=d.x,b+=d.y),r){case"stretch":_||(n=e.width,s=e.height);break;case"normal":case"clip":(v||b||m||c)&&Ot(g,e,v,b,m,x,c);break;case"repeat":(!_||m||c)&&Ct(g,e,n,s,v,b,m,x,c,a),u||(g.repeat="repeat");break;default:m&&Wt(g,e,v,b,m,x,c)}return g.transform||(e.x||e.y)&&(g.transform=Tt(),Mt(g.transform,e.x,e.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=x),g.width=n,g.height=s,o&&(g.opacity=o),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Gt,zt=new p;const{isSame:Ut}=B;function Nt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Ft(s,n,i,o),!0}function Xt(t,e){Ht(t,L.LOAD,e)}function jt(t,e){Ht(t,L.LOADED,e)}function qt(t,e,i){e.error=i,t.forceUpdate("surface"),Ht(t,L.ERROR,e)}function Ht(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Qt,scale:Zt,copy:$t}=R,{ceil:Jt,abs:Kt}=Math;function te(t,i,n){let{scaleX:s,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;const r=s+"-"+o+"-"+n;if(i.patternId===r||t.destroyed)return!1;{s=Kt(s),o=Kt(o);const{image:t,data:a}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,transform:_,repeat:g}=a;u&&(l=Qt(),$t(l,_),Zt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,h*=s,c*=o;const p=h*c;if(!g&&p>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}p>w&&(d=Math.sqrt(p/w)),d&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=f),(_||1!==s||1!==o)&&(l||(l=Qt(),_&&$t(l,_)),Zt(l,1/s,1/o));const y=t.getCanvas(Jt(h)||1,Jt(c)||1,a.opacity,a.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=m,i.patternId=r,!0}}function ee(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{d(n.next(t))}catch(t){o(t)}}function a(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ie}=Math;const ne={image:function(t,e,i,n,s){let o,r;const a=v.get(i);return Gt&&i===Gt.paint&&Ut(n,Gt.boxBounds)?o=Gt.leafPaint:(o={type:i.type,image:a},Gt=a.use>1?{leafPaint:o,paint:i,boxBounds:zt.set(n)}:null),(s||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Nt(t,e,i,a,o,n),s&&(Xt(t,r),jt(t,r))):a.error?s&&qt(t,r,a.error):(s&&(Vt(t,!0),Xt(t,r)),o.loadId=a.load((()=>{Vt(t,!1),t.destroyed||(Nt(t,e,i,a,o,n)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),jt(t,r)),o.loadId=null}),(e=>{Vt(t,!1),qt(t,r,e),o.loadId=null})),t.placeholderColor&&setTimeout((()=>{a.ready||a.isPlacehold||(a.isPlacehold=!0,t.forceUpdate("surface"))}),100)),o},checkImage:function(t,i,n,s){const{scaleX:o,scaleY:r}=v.patternLocked?t.__world:t.__nowWorld,{pixelRatio:a}=i,{data:d}=n;if(!d||n.patternId===o+"-"+r+"-"+a&&!I.running)return!1;if(s)if(d.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||I.running)){let{width:t,height:i}=d;t*=ie(o)*a,i*=ie(r)*a,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,d),!0):(!n.style||n.sync||I.running?te(t,n,a):n.patternTask||(n.patternTask=v.patternTasker.add((()=>ee(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&te(t,n,a),t.forceUpdate("surface")}))),300)),!1)},createPattern:te,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,r,a;for(let d=0,l=i.length;d<l;d++)n=i[d],s=n.image,a=s&&s.url,a&&(o||(o={}),o[a]=!0,v.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===a)))));return o}return null},createData:Ft,getPatternData:Yt,fillOrFitMode:Wt,clipMode:Ot,repeatMode:Ct},{toPoint:se}=A,oe={},re={};function ae(t,e,i){if(e){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}}const{getAngle:de,getDistance:le}=W,{get:he,rotateOfOuter:ce,scaleOfOuter:ue}=R,{toPoint:fe}=A,_e={},ge={};function pe(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=de(e,i);o=he(),s?(ue(o,e,r/a*(n||1),1),ce(o,e,t+90)):(ue(o,e,1,r/a*(n||1)),ce(o,e,t))}return o}const{getDistance:we}=W,{toPoint:ye}=A,me={},xe={};const ve={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:r,opacity:a}=t;se(n||"top",i,oe),se(s||"bottom",i,re);const d=e.canvas.createLinearGradient(oe.x,oe.y,re.x,re.y);ae(d,t.stops,a);const l={type:o,style:d};return r&&(l.blendMode=r),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:d}=t;fe(n||"center",i,_e),fe(s||"bottom",i,ge);const l=e.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,le(_e,ge));ae(l,t.stops,r);const h={type:o,style:l},c=pe(i,_e,ge,d,!0);return c&&(h.transform=c),a&&(h.blendMode=a),h},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:d}=t;ye(n||"center",i,me),ye(s||"bottom",i,xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,me.x,me.y):e.canvas.createRadialGradient(me.x,me.y,0,me.x,me.y,we(me,xe));ae(l,t.stops,r);const h={type:o,style:l},c=pe(i,me,xe,d||1,e.conicGradientRotate90);return c&&(h.transform=c),a&&(h.blendMode=a),h},getTransform:pe},{copy:be,toOffsetOutBounds:Be}=B,ke={},Re={};function Ee(t,i,n,s){const{bounds:o,shapeBounds:r}=s;if(e.fullImageShadow){if(be(ke,t.bounds),ke.x+=i.x-r.x,ke.y+=i.y-r.y,n){const{matrix:t}=s;ke.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),ke.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),ke.width*=n,ke.height*=n}t.copyWorld(s.canvas,t.bounds,ke)}else n&&(be(ke,i),ke.x-=i.width/2*(n-1),ke.y-=i.height/2*(n-1),ke.width*=n,ke.height*=n),t.copyWorld(s.canvas,r,n?ke:i)}const{toOffsetOutBounds:Se}=B,Le={};const Ae={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=a.length-1;Be(l,Re),a.forEach(((a,g)=>{f.setWorldShadow(Re.offsetX+a.x*c,Re.offsetY+a.y*u,a.blur*c,P.string(a.color)),s=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ee(f,Re,s,i),n=l,a.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,a.blendMode):e.copyWorldToInner(f,n,r.renderBounds,a.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=a.length-1;Se(l,Le),a.forEach(((a,g)=>{f.save(),f.setWorldShadow(Le.offsetX+a.x*c,Le.offsetY+a.y*u,a.blur*c),s=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ee(f,Le,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,P.string(a.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,a.blendMode):e.copyWorldToInner(f,n,r.renderBounds,a.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:We}=g;function Oe(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Te(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Te(t,i,n,o);break;case"path":i.restore()}}function Ce(t){return t.getSameCanvas(!1,!0)}function Te(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],a=i.__.mask,a&&(r&&(Oe(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=Ce(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=Ce(t)),s||(s=Ce(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||We(i,e)||i.__render(s||t,e);Oe(this,r,t,s,n,o)};const Me=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Pe=Me+"_#~&*+\\=|≮≯≈≠=…",De=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 Ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Fe=Ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ye=Ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=Ie(Me),ze=Ie(Pe),Ue=Ie("- —/~|┆·");var Ne;!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"}(Ne||(Ne={}));const{Letter:Xe,Single:je,Before:qe,After:He,Symbol:Ve,Break:Qe}=Ne;function Ze(t){return Fe[t]?Xe:Ue[t]?Qe:Ye[t]?qe:Ge[t]?He:ze[t]?Ve:De.test(t)?je:Xe}const $e={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Je(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ke}=$e,{Letter:ti,Single:ei,Before:ii,After:ni,Symbol:si,Break:oi}=Ne;let ri,ai,di,li,hi,ci,ui,fi,_i,gi,pi,wi,yi,mi,xi,vi,bi,Bi=[];function ki(t,e){_i&&!fi&&(fi=_i),ri.data.push({char:t,width:e}),di+=e}function Ri(){li+=di,ri.width=di,ai.words.push(ri),ri={data:[]},di=0}function Ei(){mi&&(xi.paraNumber++,ai.paraStart=!0,mi=!1),_i&&(ai.startCharSize=fi,ai.endCharSize=_i,fi=0),ai.width=li,vi.width?Ke(ai):bi&&Si(),Bi.push(ai),ai={words:[]},li=0}function Si(){li>(xi.maxWidth||0)&&(xi.maxWidth=li)}const{top:Li,right:Ai,bottom:Wi,left:Oi}=O;function Ci(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Ti={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:a,__font:d,__padding:l}=i;l&&(o?(n=l[Oi],o-=l[Ai]+l[Oi]):i.autoSizeAlign||(n=l[Oi]),r?(s=l[Li],r-=l[Li]+l[Wi]):i.autoSizeAlign||(s=l[Li]));const h={bounds:{x:n,y:s,width:o,height:r},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){xi=t,Bi=t.rows,vi=t.bounds,bi=!vi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=e,{width:d,height:l}=vi;if(d||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;mi=!0,pi=null,fi=ui=_i=di=li=0,ri={data:[]},ai={words:[]};for(let n=0,l=i.length;n<l;n++)ci=i[n],"\n"===ci?(di&&Ri(),ai.paraEnd=!0,Ei(),mi=!0):(gi=Ze(ci),gi===ti&&"none"!==r&&(ci=Je(ci,r,!di)),ui=a.measureText(ci).width,s&&(s<0&&(_i=ui),ui+=s),wi=gi===ei&&(pi===ei||pi===ti)||pi===ei&&gi!==ni,yi=!(gi!==ii&&gi!==ei||pi!==si&&pi!==ni),hi=mi&&o?d-o:d,t&&d&&li+di+ui>hi&&(e?(di&&Ri(),li&&Ei()):(yi||(yi=gi===ti&&pi==ni),wi||yi||gi===oi||gi===ii||gi===ei||di+ui>hi?(di&&Ri(),li&&Ei()):li&&Ei()))," "===ci&&!0!==mi&&li+di===0||(gi===oi?(" "===ci&&di&&Ri(),ki(ci,ui),Ri()):wi||yi?(di&&Ri(),ki(ci,ui)):ki(ci,ui)),pi=gi);di&&Ri(),li&&Ei(),Bi.length>0&&(Bi[Bi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{xi.paraNumber++,li=a.measureText(t).width,Bi.push({x:o||0,text:t,width:li,paraStart:!0}),bi&&Si()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ci(e,"x",t[Oi]);break;case"right":Ci(e,"x",-t[Ai])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ci(e,"y",t[Li]);break;case"bottom":Ci(e,"y",-t[Wi])}}(l,h,i,o,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:d,textAlign:l,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:_,width:g,height:p}=n,w=o*s+(c?c*(t.paraNumber-1):0),y=r;if(d&&w>p)w=Math.max(p,o),s>1&&(t.overflow=s);else if(p||u)switch(h){case"middle":_+=(p-w)/2;break;case"bottom":_+=p-w}y+=_;let m,x,v,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!d)switch(l){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=o,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,x-=v,v+=e.fontSize):v-=a),x<n.x&&(n.x=x),v>n.width&&(n.width=v),d&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=w}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let a,d,l,h,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,d=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,h=r||t.isOverflow?0:d>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||i===u-1||(a+=d,t.width+=d)}))),t.words=null)}))}(h,i,o),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let t,d;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?e.canvas.measureText(a).width:0,h=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,o),"none"!==a&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=P.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(h,i),h}};const Mi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!P.object)return t;t=P.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(Y,Ti),Object.assign(P,Mi),Object.assign(G,bt),Object.assign(M,ne),Object.assign(D,ve),Object.assign(z,Ae),Object.assign(s,{interaction:(t,e,i,n)=>new T(t,e,i,n),hitCanvas:(t,e)=>new U(t,e),hitCanvasManager:()=>new C}),X();export{nt as Layouter,U as LeaferCanvas,at as Picker,ot as Renderer,dt as Selector,q as Watcher,X as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map