@leafer-ui/miniapp 1.0.2 → 1.0.3

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/miniapp.cjs CHANGED
@@ -366,9 +366,13 @@ function updateBounds(boundsList) {
366
366
  });
367
367
  }
368
368
  function updateChange(updateList) {
369
+ let layout;
369
370
  updateList.list.forEach(leaf => {
370
- if (leaf.__layout.opacityChanged)
371
+ layout = leaf.__layout;
372
+ if (layout.opacityChanged)
371
373
  updateAllWorldOpacity(leaf);
374
+ if (layout.stateStyleChanged)
375
+ setTimeout(() => layout.stateStyleChanged && leaf.updateState());
372
376
  leaf.__updateChange();
373
377
  });
374
378
  }
@@ -734,7 +738,6 @@ class Renderer {
734
738
  core.Platform.requestRender(() => {
735
739
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
736
740
  if (this.running) {
737
- this.target.emit(core.AnimateEvent.FRAME);
738
741
  if (this.changed && this.canvas.view)
739
742
  this.render();
740
743
  this.target.emit(core.RenderEvent.NEXT);
@@ -1548,6 +1551,8 @@ function getPatternData(paint, box, image) {
1548
1551
  let { width, height } = image;
1549
1552
  if (paint.padding)
1550
1553
  box = tempBox.set(box).shrink(paint.padding);
1554
+ if (paint.mode === 'strench')
1555
+ paint.mode = 'stretch';
1551
1556
  const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
1552
1557
  const sameBox = box.width === width && box.height === height;
1553
1558
  const data = { mode };
@@ -1576,7 +1581,7 @@ function getPatternData(paint, box, image) {
1576
1581
  if (offset)
1577
1582
  x += offset.x, y += offset.y;
1578
1583
  switch (mode) {
1579
- case 'strench':
1584
+ case 'stretch':
1580
1585
  if (!sameBox)
1581
1586
  width = box.width, height = box.height;
1582
1587
  break;
@@ -1603,7 +1608,7 @@ function getPatternData(paint, box, image) {
1603
1608
  translate(data.transform, box.x, box.y);
1604
1609
  }
1605
1610
  }
1606
- if (scaleX && mode !== 'strench') {
1611
+ if (scaleX && mode !== 'stretch') {
1607
1612
  data.scaleX = scaleX;
1608
1613
  data.scaleY = scaleY;
1609
1614
  }
@@ -1707,7 +1712,7 @@ const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
1707
1712
  const { ceil, abs: abs$1 } = Math;
1708
1713
  function createPattern(ui, paint, pixelRatio) {
1709
1714
  let { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1710
- const id = scaleX + '-' + scaleY;
1715
+ const id = scaleX + '-' + scaleY + '-' + pixelRatio;
1711
1716
  if (paint.patternId !== id && !ui.destroyed) {
1712
1717
  scaleX = abs$1(scaleX);
1713
1718
  scaleY = abs$1(scaleY);
@@ -1801,7 +1806,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1801
1806
  const { abs } = Math;
1802
1807
  function checkImage(ui, canvas, paint, allowPaint) {
1803
1808
  const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1804
- if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !draw.Export.running)) {
1809
+ const { pixelRatio } = canvas;
1810
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
1805
1811
  return false;
1806
1812
  }
1807
1813
  else {
@@ -1809,8 +1815,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
1809
1815
  if (allowPaint) {
1810
1816
  if (!data.repeat) {
1811
1817
  let { width, height } = data;
1812
- width *= abs(scaleX) * canvas.pixelRatio;
1813
- height *= abs(scaleY) * canvas.pixelRatio;
1818
+ width *= abs(scaleX) * pixelRatio;
1819
+ height *= abs(scaleY) * pixelRatio;
1814
1820
  if (data.scaleX) {
1815
1821
  width *= data.scaleX;
1816
1822
  height *= data.scaleY;
@@ -1836,14 +1842,14 @@ function checkImage(ui, canvas, paint, allowPaint) {
1836
1842
  }
1837
1843
  else {
1838
1844
  if (!paint.style || paint.sync || draw.Export.running) {
1839
- createPattern(ui, paint, canvas.pixelRatio);
1845
+ createPattern(ui, paint, pixelRatio);
1840
1846
  }
1841
1847
  else {
1842
1848
  if (!paint.patternTask) {
1843
1849
  paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1844
1850
  paint.patternTask = null;
1845
1851
  if (canvas.bounds.hit(ui.__nowWorld))
1846
- createPattern(ui, paint, canvas.pixelRatio);
1852
+ createPattern(ui, paint, pixelRatio);
1847
1853
  ui.forceUpdate('surface');
1848
1854
  }), 300);
1849
1855
  }
@@ -1907,14 +1913,16 @@ function linearGradient(paint, box) {
1907
1913
  return data;
1908
1914
  }
1909
1915
  function applyStops(gradient, stops, opacity) {
1910
- let stop;
1911
- for (let i = 0, len = stops.length; i < len; i++) {
1912
- stop = stops[i];
1913
- if (typeof stop === 'string') {
1914
- gradient.addColorStop(i / (len - 1), draw.ColorConvert.string(stop, opacity));
1915
- }
1916
- else {
1917
- gradient.addColorStop(stop.offset, draw.ColorConvert.string(stop.color, opacity));
1916
+ if (stops) {
1917
+ let stop;
1918
+ for (let i = 0, len = stops.length; i < len; i++) {
1919
+ stop = stops[i];
1920
+ if (typeof stop === 'string') {
1921
+ gradient.addColorStop(i / (len - 1), draw.ColorConvert.string(stop, opacity));
1922
+ }
1923
+ else {
1924
+ gradient.addColorStop(stop.offset, draw.ColorConvert.string(stop.color, opacity));
1925
+ }
1918
1926
  }
1919
1927
  }
1920
1928
  }
@@ -2670,10 +2678,15 @@ const TextConvertModule = {
2670
2678
  };
2671
2679
 
2672
2680
  function string(color, opacity) {
2673
- if (typeof color === 'string')
2674
- return color;
2681
+ const doOpacity = typeof opacity === 'number' && opacity !== 1;
2682
+ if (typeof color === 'string') {
2683
+ if (doOpacity && draw.ColorConvert.object)
2684
+ color = draw.ColorConvert.object(color);
2685
+ else
2686
+ return color;
2687
+ }
2675
2688
  let a = color.a === undefined ? 1 : color.a;
2676
- if (opacity)
2689
+ if (doOpacity)
2677
2690
  a *= opacity;
2678
2691
  const rgb = color.r + ',' + color.g + ',' + color.b;
2679
2692
  return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, BoundsHelper, Answer, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Answer, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { InteractionHelper, InteractionBase, HitCanvasManager } from '@leafer-ui/core';
@@ -367,9 +367,13 @@ function updateBounds(boundsList) {
367
367
  });
368
368
  }
369
369
  function updateChange(updateList) {
370
+ let layout;
370
371
  updateList.list.forEach(leaf => {
371
- if (leaf.__layout.opacityChanged)
372
+ layout = leaf.__layout;
373
+ if (layout.opacityChanged)
372
374
  updateAllWorldOpacity(leaf);
375
+ if (layout.stateStyleChanged)
376
+ setTimeout(() => layout.stateStyleChanged && leaf.updateState());
373
377
  leaf.__updateChange();
374
378
  });
375
379
  }
@@ -735,7 +739,6 @@ class Renderer {
735
739
  Platform.requestRender(() => {
736
740
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)));
737
741
  if (this.running) {
738
- this.target.emit(AnimateEvent.FRAME);
739
742
  if (this.changed && this.canvas.view)
740
743
  this.render();
741
744
  this.target.emit(RenderEvent.NEXT);
@@ -1549,6 +1552,8 @@ function getPatternData(paint, box, image) {
1549
1552
  let { width, height } = image;
1550
1553
  if (paint.padding)
1551
1554
  box = tempBox.set(box).shrink(paint.padding);
1555
+ if (paint.mode === 'strench')
1556
+ paint.mode = 'stretch';
1552
1557
  const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
1553
1558
  const sameBox = box.width === width && box.height === height;
1554
1559
  const data = { mode };
@@ -1577,7 +1582,7 @@ function getPatternData(paint, box, image) {
1577
1582
  if (offset)
1578
1583
  x += offset.x, y += offset.y;
1579
1584
  switch (mode) {
1580
- case 'strench':
1585
+ case 'stretch':
1581
1586
  if (!sameBox)
1582
1587
  width = box.width, height = box.height;
1583
1588
  break;
@@ -1604,7 +1609,7 @@ function getPatternData(paint, box, image) {
1604
1609
  translate(data.transform, box.x, box.y);
1605
1610
  }
1606
1611
  }
1607
- if (scaleX && mode !== 'strench') {
1612
+ if (scaleX && mode !== 'stretch') {
1608
1613
  data.scaleX = scaleX;
1609
1614
  data.scaleY = scaleY;
1610
1615
  }
@@ -1708,7 +1713,7 @@ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
1708
1713
  const { ceil, abs: abs$1 } = Math;
1709
1714
  function createPattern(ui, paint, pixelRatio) {
1710
1715
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1711
- const id = scaleX + '-' + scaleY;
1716
+ const id = scaleX + '-' + scaleY + '-' + pixelRatio;
1712
1717
  if (paint.patternId !== id && !ui.destroyed) {
1713
1718
  scaleX = abs$1(scaleX);
1714
1719
  scaleY = abs$1(scaleY);
@@ -1802,7 +1807,8 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1802
1807
  const { abs } = Math;
1803
1808
  function checkImage(ui, canvas, paint, allowPaint) {
1804
1809
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1805
- if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
1810
+ const { pixelRatio } = canvas;
1811
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
1806
1812
  return false;
1807
1813
  }
1808
1814
  else {
@@ -1810,8 +1816,8 @@ function checkImage(ui, canvas, paint, allowPaint) {
1810
1816
  if (allowPaint) {
1811
1817
  if (!data.repeat) {
1812
1818
  let { width, height } = data;
1813
- width *= abs(scaleX) * canvas.pixelRatio;
1814
- height *= abs(scaleY) * canvas.pixelRatio;
1819
+ width *= abs(scaleX) * pixelRatio;
1820
+ height *= abs(scaleY) * pixelRatio;
1815
1821
  if (data.scaleX) {
1816
1822
  width *= data.scaleX;
1817
1823
  height *= data.scaleY;
@@ -1837,14 +1843,14 @@ function checkImage(ui, canvas, paint, allowPaint) {
1837
1843
  }
1838
1844
  else {
1839
1845
  if (!paint.style || paint.sync || Export.running) {
1840
- createPattern(ui, paint, canvas.pixelRatio);
1846
+ createPattern(ui, paint, pixelRatio);
1841
1847
  }
1842
1848
  else {
1843
1849
  if (!paint.patternTask) {
1844
1850
  paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1845
1851
  paint.patternTask = null;
1846
1852
  if (canvas.bounds.hit(ui.__nowWorld))
1847
- createPattern(ui, paint, canvas.pixelRatio);
1853
+ createPattern(ui, paint, pixelRatio);
1848
1854
  ui.forceUpdate('surface');
1849
1855
  }), 300);
1850
1856
  }
@@ -1908,14 +1914,16 @@ function linearGradient(paint, box) {
1908
1914
  return data;
1909
1915
  }
1910
1916
  function applyStops(gradient, stops, opacity) {
1911
- let stop;
1912
- for (let i = 0, len = stops.length; i < len; i++) {
1913
- stop = stops[i];
1914
- if (typeof stop === 'string') {
1915
- gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
1916
- }
1917
- else {
1918
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
1917
+ if (stops) {
1918
+ let stop;
1919
+ for (let i = 0, len = stops.length; i < len; i++) {
1920
+ stop = stops[i];
1921
+ if (typeof stop === 'string') {
1922
+ gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
1923
+ }
1924
+ else {
1925
+ gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
1926
+ }
1919
1927
  }
1920
1928
  }
1921
1929
  }
@@ -2671,10 +2679,15 @@ const TextConvertModule = {
2671
2679
  };
2672
2680
 
2673
2681
  function string(color, opacity) {
2674
- if (typeof color === 'string')
2675
- return color;
2682
+ const doOpacity = typeof opacity === 'number' && opacity !== 1;
2683
+ if (typeof color === 'string') {
2684
+ if (doOpacity && ColorConvert.object)
2685
+ color = ColorConvert.object(color);
2686
+ else
2687
+ return color;
2688
+ }
2676
2689
  let a = color.a === undefined ? 1 : color.a;
2677
- if (opacity)
2690
+ if (doOpacity)
2678
2691
  a *= opacity;
2679
2692
  const rgb = color.r + ',' + color.g + ',' + color.b;
2680
2693
  return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as h,FileHelper as d,LeafList as l,RenderEvent as c,ChildEvent as u,WatchEvent as f,PropertyEvent as g,LeafHelper as p,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,AnimateEvent as R,BoundsHelper as k,Answer as S,MatrixHelper as L,MathHelper as E,AlignHelper as T,ImageEvent as M,AroundHelper as A,PointHelper as C,Direction4 as W,TwoPointBoundsHelper as O,TaskProcessor as P,Matrix as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as D,InteractionBase as F,HitCanvasManager as z}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as N,ColorConvert as Y,PaintGradient as U,Export as V,Group as X,TextConvert as j,Paint as G,Effect as H,Leafer as q}from"@leafer-ui/draw";class Q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__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)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:J,fileType:K}=d;function Z(t,i){e.origin={createCanvas:(t,e,s)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(J(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(J(K(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new Q(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},h(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;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 l,this.target=t,e&&(this.config=s.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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:tt,updateBounds:et,updateAllWorldOpacity:it}=p,{pushAllChildBranch:st,pushAllParent:nt}=_;const{worldBounds:ot}=m,at={x:0,y:0,width:1e5,height:1e5};class rt{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ot)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(at):this.afterBounds.setListWithFn(t,ot),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:ht,updateAllChange:dt}=p,lt=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?lt.warn("layouting"):this.times>3?lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||et(s[t])}et(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&it(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new l(e));e.emitEvent(new x(i,o,this.times)),ct.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){ht(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new rt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new rt(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_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=y.get("Renderer");class ft{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=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,ut.log(e.innerName,"---\x3e");try{this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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;if(!e)return ut.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new w(s);i.save(),n&&!y.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(s),y.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(R.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__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||ut.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 c(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(c.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:gt}=k;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=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 l(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new l;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.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 l;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new l;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new l,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.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()}}const{Yes:_t,NoAndSkip:wt,YesAndSkip:mt}=S,yt={},vt={},xt={};class bt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new pt(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":yt.id=t.substring(1),t=yt;break;case".":vt.className=t.substring(1),t=vt;break;default:xt.tag=t,t=xt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(x.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&p.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===_t||o===mt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<wt&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(u.REMOVE,this.__onRemoveChild,this),this.target.on_(g.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new bt(t,e)}),e.layout=ct.fullLayout;const Bt={convertTouch(t,e){const i=Bt.getTouch(t),s=D.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class Rt extends F{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=Bt.getTouch(t);this.pointerDown(Bt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=Bt.getTouch(t);this.pointerMove(Bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=Bt.getTouch(t);this.pointerUp(Bt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(D.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function kt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function St(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Tt(t,!0,e,i):Et(e,i);break;case"inside":Lt("inside",t,n,e,i);break;case"outside":Lt("outside",t,n,e,i)}}function Lt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Tt(e,!0,s,r):Et(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",kt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function Et(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Tt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&N.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Et(i,s):s.stroke(),s.restoreBlendMode()):e?Et(i,s):s.stroke())}const{getSpread:Mt,getOuterOf:At,getByMove:Ct,getIntersectData:Wt}=k;let Ot;function Pt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:Y.string(a,r)};case"image":return N.image(i,t,e,s,!Ot||!Ot[e.url]);case"linear":return U.linearGradient(e,s);case"radial":return U.radialGradient(e,s);case"angular":return U.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:Y.string(e)}:void 0}}const It={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Ot=N.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Pt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?kt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&N.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?kt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?kt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?kt(e,i):n?i.fill(n):i.fill())},fillText:kt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Tt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Tt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),Tt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:St,drawTextStroke:Et,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Wt(s?Mt(e.bounds,d===l?s*d:[s*l,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=f),r=At(n,a),o=Ct(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let Dt={};const{get:Ft,rotateOfOuter:zt,translate:Nt,scaleOfOuter:Yt,scale:Ut,rotate:Vt}=L;function Xt(t,e,i,s,n,o,a){const r=Ft();Nt(r,e.x+i,e.y+s),Ut(r,n,o),a&&zt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function jt(t,e,i,s,n,o,a){const r=Ft();Nt(r,e.x+i,e.y+s),n&&Ut(r,n,o),a&&Vt(r,a),t.transform=r}function Gt(t,e,i,s,n,o,a,r,h,d){const l=Ft();if(h)if("center"===d)zt(l,{x:i/2,y:s/2},h);else switch(Vt(l,h),h){case 90:Nt(l,s,0);break;case 180:Nt(l,i,s);break;case 270:Nt(l,0,i)}Dt.x=e.x+n,Dt.y=e.y+o,Nt(l,Dt.x,Dt.y),a&&Yt(l,Dt,a,r),t.transform=l}const{get:Ht,translate:qt}=L,Qt=new w,Jt={},Kt={};function Zt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=$t(i,s,e)}function $t(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Qt.set(e).shrink(t.padding));const{opacity:o,mode:a,align:r,offset:h,scale:d,size:l,rotation:c,repeat:u}=t,f=e.width===s&&e.height===n,g={mode:a},p="center"!==r&&(c||0)%180==90,_=p?n:s,w=p?s:n;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(d||l)&&(E.getScaleData(d,l,i,Kt),m=Kt.scaleX,y=Kt.scaleY);else if(!f||c){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*m)/2,x+=(e.height-n*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),T.toPoint(r,t,e,Jt,!0),v+=Jt.x,x+=Jt.y}switch(h&&(v+=h.x,x+=h.y),a){case"strench":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||m||c)&&jt(g,e,v,x,m,y,c);break;case"repeat":(!f||m||c)&&Gt(g,e,s,n,v,x,m,y,c,r),u||(g.repeat="repeat");break;default:m&&Xt(g,e,v,x,m,y,c)}return g.transform||(e.x||e.y)&&(g.transform=Ht(),qt(g.transform,e.x,e.y)),m&&"strench"!==a&&(g.scaleX=m,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let te,ee=new w;const{isSame:ie}=k;function se(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Zt(n,s,i,o),!0}function ne(t,e){re(t,M.LOAD,e)}function oe(t,e){re(t,M.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,M.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new M(e,i))}function he(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:de,scale:le,copy:ce}=L,{ceil:ue,abs:fe}=Math;function ge(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o;if(i.patternId===a||t.destroyed)return!1;{n=fe(n),o=fe(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=de(),ce(d,p),le(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(h=Math.sqrt(w/m)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=de(),p&&ce(d,p)),le(d,1/n,1/o));const y=t.getCanvas(ue(l)||1,ue(c)||1,g),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function pe(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:_e}=Math;const we={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return te&&i===te.paint&&ie(s,te.boxBounds)?o=te.leafPaint:(o={type:i.type,image:r},te=r.use>1?{leafPaint:o,paint:i,boxBounds:ee.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(se(t,e,i,r,o,s),n&&(ne(t,a),oe(t,a))):r.error?n&&ae(t,a,r.error):(he(t,!0),n&&ne(t,a),o.loadId=r.load((()=>{he(t,!1),t.destroyed||(se(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,a)),o.loadId=null}),(e=>{he(t,!1),ae(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld;if(!s.data||s.patternId===o+"-"+a&&!V.running)return!1;{const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=_e(o)*i.pixelRatio,s*=_e(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize||V.running}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||s.sync||V.running?ge(t,s,i.pixelRatio):s.patternTask||(s.patternTask=B.patternTasker.add((()=>pe(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Zt,getPatternData:$t,fillOrFitMode:Xt,clipMode:jt,repeatMode:Gt},{toPoint:me}=A,ye={},ve={};function xe(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),Y.string(s,i)):t.addColorStop(s.offset,Y.string(s.color,i))}const{getAngle:be,getDistance:Be}=C,{get:Re,rotateOfOuter:ke,scaleOfOuter:Se}=L,{toPoint:Le}=A,Ee={},Te={};function Me(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=be(e,i);o=Re(),n?(Se(o,e,a/r*(s||1),1),ke(o,e,t+90)):(Se(o,e,1,a/r*(s||1)),ke(o,e,t))}return o}const{getDistance:Ae}=C,{toPoint:Ce}=A,We={},Oe={};const Pe={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;me(s||"top",i,ye),me(n||"bottom",i,ve);const h=e.canvas.createLinearGradient(ye.x,ye.y,ve.x,ve.y);xe(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Le(s||"center",i,Ee),Le(n||"bottom",i,Te);const d=e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Be(Ee,Te));xe(d,t.stops,a);const l={type:o,style:d},c=Me(i,Ee,Te,h,!0);return c&&(l.transform=c),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Ce(s||"center",i,We),Ce(n||"bottom",i,Oe);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,We.x,We.y):e.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Ae(We,Oe));xe(d,t.stops,a);const l={type:o,style:d},c=Me(i,We,Oe,h||1,e.conicGradientRotate90);return c&&(l.transform=c),r&&(l.blendMode=r),l},getTransform:Me},{copy:Ie,toOffsetOutBounds:De}=k,Fe={},ze={};function Ne(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Ie(Fe,t.bounds),Fe.x+=i.x-a.x,Fe.y+=i.y-a.y,s){const{matrix:t}=n;Fe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Fe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Fe.width*=s,Fe.height*=s}t.copyWorld(n.canvas,t.bounds,Fe)}else s&&(Ie(Fe,i),Fe.x-=i.width/2*(s-1),Fe.y-=i.height/2*(s-1),Fe.width*=s,Fe.height*=s),t.copyWorld(n.canvas,a,s?Fe:i)}const{toOffsetOutBounds:Ye}=k,Ue={};const Ve={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;De(d,ze),r.forEach(((r,p)=>{f.setWorldShadow(ze.offsetX+r.x*c,ze.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ne(f,ze,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ye(d,Ue),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ue.offsetX+r.x*c,Ue.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ne(f,Ue,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,l,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Xe}=m;function je(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),He(t,e,i,1)}(t,i,s,n);break;case"opacity-path":He(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}X.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let h=0,d=r.length;h<d;h++)i=r[h],i.__.mask&&(a&&(je(this,a,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ge(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Xe(i,e)||i.__render(n||t,e);je(this,a,t,n,s,o)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=qe+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ke(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Ke("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Ke("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=Ke(qe),ei=Ke(Qe),ii=Ke("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:hi,Break:di}=si;function li(t){return Ze[t]?ni:ii[t]?di:$e[t]?ai:ti[t]?ri:ei[t]?hi:Je.test(t)?oi:ni}const ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ui(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:fi}=ci,{Letter:gi,Single:pi,Before:_i,After:wi,Symbol:mi,Break:yi}=si;let vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ti,Mi,Ai,Ci,Wi,Oi,Pi,Ii=[];function Di(t,e){Ei&&!Li&&(Li=Ei),vi.data.push({char:t,width:e}),bi+=e}function Fi(){Bi+=bi,vi.width=bi,xi.words.push(vi),vi={data:[]},bi=0}function zi(){Wi&&(Oi.paraNumber++,xi.paraStart=!0,Wi=!1),Ei&&(xi.startCharSize=Li,xi.endCharSize=Ei,Li=0),xi.width=Bi,Pi.width&&fi(xi),Ii.push(xi),xi={words:[]},Bi=0}const Ni=0,Yi=1,Ui=2;const{top:Vi,right:Xi,bottom:ji,left:Gi}=W;function Hi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const qi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o&&(s=d[Gi],o-=d[Xi]+d[Gi]),a&&(n=d[Vi],a-=d[Vi]+d[ji]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Oi=t,Ii=t.rows,Pi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Pi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Wi=!0,Mi=null,Li=Si=Ei=bi=Bi=0,vi={data:[]},xi={words:[]};for(let s=0,d=i.length;s<d;s++)ki=i[s],"\n"===ki?(bi&&Fi(),xi.paraEnd=!0,zi(),Wi=!0):(Ti=li(ki),Ti===gi&&"none"!==a&&(ki=ui(ki,a,!bi)),Si=r.measureText(ki).width,n&&(n<0&&(Ei=Si),Si+=n),Ai=Ti===pi&&(Mi===pi||Mi===gi)||Mi===pi&&Ti!==wi,Ci=!(Ti!==_i&&Ti!==pi||Mi!==mi&&Mi!==wi),Ri=Wi&&o?h-o:h,t&&h&&Bi+bi+Si>Ri&&(e?(bi&&Fi(),Bi&&zi()):(Ci||(Ci=Ti===gi&&Mi==wi),Ai||Ci||Ti===yi||Ti===_i||Ti===pi||bi+Si>Ri?(bi&&Fi(),Bi&&zi()):Bi&&zi()))," "===ki&&!0!==Wi&&Bi+bi===0||(Ti===yi?(" "===ki&&bi&&Fi(),Di(ki,Si),Fi()):Ai||Ci?(bi&&Fi(),Di(ki,Si)):Di(ki,Si)),Mi=Ti);bi&&Fi(),Bi&&zi(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Oi.paraNumber++,Ii.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Hi(e,"x",t[Gi]);break;case"right":Hi(e,"x",-t[Xi])}if(!n)switch(i.verticalAlign){case"top":Hi(e,"y",t[Vi]);break;case"bottom":Hi(e,"y",-t[ji])}}(d,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:l}=e;let c,u,f,{x:g,y:p,width:_,height:w}=s,m=n*i.length+(l?l*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":p+=(w-m)/2;break;case"bottom":p+=w-m}y+=p;for(let o=0,d=i.length;o<d;o++){if(c=i[o],c.x=g,c.width<_||c.width>_&&!r)switch(h){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&l&&o>0&&(y+=l),c.y=y,y+=n,t.overflow>o&&y>m&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=m}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ni:d>.01?Yi:Ui,t.isOverflow&&!r&&(t.textMode=!0),c===Ui?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{c===Yi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,l=s+n-d;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<l));s--){if(h<l&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i,s,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const Qi={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Ji,addPoint:Ki,toBounds:Zi}=O;const $i={export(t,i,s){this.running=!0;const n=d.fileType(i),o=i.includes(".");return s=d.getExportOptions(s),function(t){ts||(ts=new P);return new Promise((e=>{ts.add((()=>pe(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((h=>{const l=t=>{r(t),h(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===n)return o&&u(c(JSON.stringify(t.toJSON(s.json)),"text"),i),l({data:!!o||t.toJSON(s.json)});if("svg"===n)return o&&u(c(t.toSVG(),"svg"),i),l({data:!!o||t.toSVG()});const{leafer:f}=t;f?(es(t),f.waitViewCompleted((()=>pe(this,void 0,void 0,(function*(){let e,n,o=1,r=1;const{worldTransform:h,isLeafer:c,isFrame:u}=t,{slice:g,trim:p,onCanvas:_}=s,m=void 0===s.smooth?f.config.smooth:s.smooth,y=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=c&&v&&void 0===s.fill?t.fill:s.fill,b=d.isOpaqueImage(i)||x,B=new I;if(v)e=!0===v?c?f.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"inner":"local");switch(o=h.scaleX,r=h.scaleY,i){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(h).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};E.getScaleData(s.scale,s.size,e,R);let k=s.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:S,y:L,width:T,height:M}=new w(e).scale(R.scaleX,R.scaleY),A={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-S,-L).withScale(1/o*R.scaleX,1/r*R.scaleY)};let C,W=a.canvas({width:Math.round(T),height:Math.round(M),pixelRatio:k,smooth:m,contextSettings:y});if(g&&(C=t,C.__worldOpacity=0,t=f,A.bounds=W.bounds),W.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(W,A),t.fill=e}else t.__render(W,A);if(W.restore(),C&&C.__updateWorldOpacity(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?Ki(a,n,o):Ji(a={},n,o)),r++;const h=new w;return Zi(a,h),h.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:k};W=a.canvas(s),W.copyWorld(t,n,s)}b&&W.fillWorld(W.bounds,x||"#FFFFFF","destination-over"),_&&_(W);const O="canvas"===i?W:yield W.export(i,s);l({data:O,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:n})}))))):l({data:!1})}))))}};let ts;function es(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>es(t)))}const is=t.prototype,ss=y.get("@leafer-ui/export");is.export=function(t,e){const{quality:i,blob:s}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},is.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{ss.error(t),s(null)}))}))},is.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},is.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{ss.error(t),s(!1)}))}))},Object.assign(j,qi),Object.assign(Y,Qi),Object.assign(G,It),Object.assign(N,we),Object.assign(U,Pe),Object.assign(H,Ve),Object.assign(V,$i),Object.assign(a,{interaction:(t,e,i,s)=>new Rt(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new z}),q.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&Z(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(r.prototype.getPattern=function(t,i,s,n){const o=e.canvas.createPattern(this.view,i),{width:a,height:r}=t;this.width===a&&this.height===r||(s||(s=L.get()),L.scale(s,a/this.width,r/this.height));try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o});export{Rt as Interaction,ct as Layouter,Q as LeaferCanvas,ft as Renderer,bt as Selector,$ as Watcher,Z as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as h,FileHelper as d,LeafList as c,RenderEvent as l,ChildEvent as u,WatchEvent as f,PropertyEvent as g,LeafHelper as p,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,Answer as k,MatrixHelper as S,MathHelper as L,AlignHelper as E,ImageEvent as T,AroundHelper as M,PointHelper as A,Direction4 as C,TwoPointBoundsHelper as W,TaskProcessor as O,Matrix as P}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as I,InteractionBase as D,HitCanvasManager as F}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as z,ColorConvert as N,PaintGradient as Y,Export as U,Group as V,TextConvert as X,Paint as j,Effect as G,Leafer as H}from"@leafer-ui/draw";class q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__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)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:Q,fileType:J}=d;function K(t,i){e.origin={createCanvas:(t,e,s)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(Q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(Q(J(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new q(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},h(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new c;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 c,this.target=t,e&&(this.config=s.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===u.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new c,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:$,updateBounds:tt,updateAllWorldOpacity:et}=p,{pushAllChildBranch:it,pushAllParent:st}=_;const{worldBounds:nt}=m,ot={x:0,y:0,width:1e5,height:1e5};class at{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new c(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,nt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ot):this.afterBounds.setListWithFn(t,nt),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:rt,updateAllChange:ht}=p,dt=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.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(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?($(t,!0),e.add(t),t.isBranch&&it(t,e),st(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||tt(s[t])}tt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&et(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new c(e));e.emitEvent(new x(i,o,this.times)),ct.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),ht(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(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_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const lt=y.get("Renderer");class ut{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=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,lt.log(e.innerName,"---\x3e");try{this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,lt.error(t)}lt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return lt.warn("rendering");if(this.times>3)return lt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,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;if(!e)return lt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new w(s);i.save(),n&&!y.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(s),y.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(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 w(0,0,1,1)),this.changed=!0}}__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||lt.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_(x.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ft}=R;class gt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=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 c(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new c;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.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 c;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new c;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new c,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ft(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.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()}}const{Yes:pt,NoAndSkip:_t,YesAndSkip:wt}=k,mt={},yt={},vt={};class xt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new gt(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":mt.id=t.substring(1),t=mt;break;case".":yt.className=t.substring(1),t=yt;break;default:vt.tag=t,t=vt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(x.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&p.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===pt||o===wt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<_t&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(u.REMOVE,this.__onRemoveChild,this),this.target.on_(g.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new xt(t,e)}),e.layout=ct.fullLayout;const bt={convertTouch(t,e){const i=bt.getTouch(t),s=I.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class Bt extends D{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=bt.getTouch(t);this.pointerDown(bt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=bt.getTouch(t);this.pointerUp(bt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(I.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function Rt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function kt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Et(t,!0,e,i):Lt(e,i);break;case"inside":St("inside",t,n,e,i);break;case"outside":St("outside",t,n,e,i)}}function St(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Et(e,!0,s,r):Lt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",Rt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function Lt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Et(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&z.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Lt(i,s):s.stroke(),s.restoreBlendMode()):e?Lt(i,s):s.stroke())}const{getSpread:Tt,getOuterOf:Mt,getByMove:At,getIntersectData:Ct}=R;let Wt;function Ot(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:N.string(a,r)};case"image":return z.image(i,t,e,s,!Wt||!Wt[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:N.string(e)}:void 0}}const Pt={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Wt=z.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Ot(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?Rt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&z.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?Rt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Rt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Rt(e,i):n?i.fill(n):i.fill())},fillText:Rt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)kt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)kt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Et(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Et(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*n,s),Et(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:kt,drawTextStroke:Lt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:c}=n;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,l=Ct(s?Tt(e.bounds,d===c?s*d:[s*c,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(l);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,c*=f),r=Mt(n,a),o=At(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:c}}};let It={};const{get:Dt,rotateOfOuter:Ft,translate:zt,scaleOfOuter:Nt,scale:Yt,rotate:Ut}=S;function Vt(t,e,i,s,n,o,a){const r=Dt();zt(r,e.x+i,e.y+s),Yt(r,n,o),a&&Ft(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Xt(t,e,i,s,n,o,a){const r=Dt();zt(r,e.x+i,e.y+s),n&&Yt(r,n,o),a&&Ut(r,a),t.transform=r}function jt(t,e,i,s,n,o,a,r,h,d){const c=Dt();if(h)if("center"===d)Ft(c,{x:i/2,y:s/2},h);else switch(Ut(c,h),h){case 90:zt(c,s,0);break;case 180:zt(c,i,s);break;case 270:zt(c,0,i)}It.x=e.x+n,It.y=e.y+o,zt(c,It.x,It.y),a&&Nt(c,It,a,r),t.transform=c}const{get:Gt,translate:Ht}=S,qt=new w,Qt={},Jt={};function Kt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=Zt(i,s,e)}function Zt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:d,size:c,rotation:l,repeat:u}=t,f=e.width===s&&e.height===n,g={mode:a},p="center"!==r&&(l||0)%180==90,_=p?n:s,w=p?s:n;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(d||c)&&(L.getScaleData(d,c,i,Jt),m=Jt.scaleX,y=Jt.scaleY);else if(!f||l){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*m)/2,x+=(e.height-n*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Qt,!0),v+=Qt.x,x+=Qt.y}switch(h&&(v+=h.x,x+=h.y),a){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||m||l)&&Xt(g,e,v,x,m,y,l);break;case"repeat":(!f||m||l)&&jt(g,e,s,n,v,x,m,y,l,r),u||(g.repeat="repeat");break;default:m&&Vt(g,e,v,x,m,y,l)}return g.transform||(e.x||e.y)&&(g.transform=Gt(),Ht(g.transform,e.x,e.y)),m&&"stretch"!==a&&(g.scaleX=m,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let $t,te=new w;const{isSame:ee}=R;function ie(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Kt(n,s,i,o),!0}function se(t,e){ae(t,T.LOAD,e)}function ne(t,e){ae(t,T.LOADED,e)}function oe(t,e,i){e.error=i,t.forceUpdate("surface"),ae(t,T.ERROR,e)}function ae(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:he,scale:de,copy:ce}=S,{ceil:le,abs:ue}=Math;function fe(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=ue(n),o=ue(o);const{image:t,data:r}=i;let h,d,{width:c,height:l,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=he(),ce(d,p),de(d,1/u,1/f),n*=u,o*=f),n*=s,o*=s,c*=n,l*=o;const w=c*l;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(h=Math.sqrt(w/m)),h&&(n/=h,o/=h,c/=h,l/=h),u&&(n/=u,o/=f),(p||1!==n||1!==o)&&(d||(d=he(),p&&ce(d,p)),de(d,1/n,1/o));const y=t.getCanvas(le(c)||1,le(l)||1,g),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function ge(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:pe}=Math;const _e={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return $t&&i===$t.paint&&ee(s,$t.boxBounds)?o=$t.leafPaint:(o={type:i.type,image:r},$t=r.use>1?{leafPaint:o,paint:i,boxBounds:te.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(ie(t,e,i,r,o,s),n&&(se(t,a),ne(t,a))):r.error?n&&oe(t,a,r.error):(re(t,!0),n&&se(t,a),o.loadId=r.load((()=>{re(t,!1),t.destroyed||(ie(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ne(t,a)),o.loadId=null}),(e=>{re(t,!1),oe(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!U.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:i}=h;t*=pe(o)*r,i*=pe(a)*r,h.scaleX&&(t*=h.scaleX,i*=h.scaleY),n=t*i>e.image.maxCacheSize||U.running}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.view,0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||U.running?fe(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ge(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&fe(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:fe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Kt,getPatternData:Zt,fillOrFitMode:Vt,clipMode:Xt,repeatMode:jt},{toPoint:we}=M,me={},ye={};function ve(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),N.string(s,i)):t.addColorStop(s.offset,N.string(s.color,i))}}const{getAngle:xe,getDistance:be}=A,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=S,{toPoint:Se}=M,Le={},Ee={};function Te(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=xe(e,i);o=Be(),n?(ke(o,e,a/r*(s||1),1),Re(o,e,t+90)):(ke(o,e,1,a/r*(s||1)),Re(o,e,t))}return o}const{getDistance:Me}=A,{toPoint:Ae}=M,Ce={},We={};const Oe={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;we(s||"top",i,me),we(n||"bottom",i,ye);const h=e.canvas.createLinearGradient(me.x,me.y,ye.x,ye.y);ve(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Se(s||"center",i,Le),Se(n||"bottom",i,Ee);const d=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,be(Le,Ee));ve(d,t.stops,a);const c={type:o,style:d},l=Te(i,Le,Ee,h,!0);return l&&(c.transform=l),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Ae(s||"center",i,Ce),Ae(n||"bottom",i,We);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,Ce.x,Ce.y):e.canvas.createRadialGradient(Ce.x,Ce.y,0,Ce.x,Ce.y,Me(Ce,We));ve(d,t.stops,a);const c={type:o,style:d},l=Te(i,Ce,We,h||1,e.conicGradientRotate90);return l&&(c.transform=l),r&&(c.blendMode=r),c},getTransform:Te},{copy:Pe,toOffsetOutBounds:Ie}=R,De={},Fe={};function ze(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Pe(De,t.bounds),De.x+=i.x-a.x,De.y+=i.y-a.y,s){const{matrix:t}=n;De.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),De.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),De.width*=s,De.height*=s}t.copyWorld(n.canvas,t.bounds,De)}else s&&(Pe(De,i),De.x-=i.width/2*(s-1),De.y-=i.height/2*(s-1),De.width*=s,De.height*=s),t.copyWorld(n.canvas,a,s?De:i)}const{toOffsetOutBounds:Ne}=R,Ye={};const Ue={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:l,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(d,Fe),r.forEach(((r,p)=>{f.setWorldShadow(Fe.offsetX+r.x*l,Fe.offsetY+r.y*u,r.blur*l,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ze(f,Fe,n,i),s=d,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,d,o,"copy"),s=o),h?f.copyWorld(h,o,o,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:l,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ne(d,Ye),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Ye.offsetX+r.x*l,Ye.offsetY+r.y*u,r.blur*l),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ze(f,Ye,n,i),f.restore(),h?(f.copyWorld(f,d,o,"copy"),f.copyWorld(h,o,o,"source-out"),s=o):(f.copyWorld(i.canvas,c,d,"source-out"),s=d),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,o,r.blendMode):e.copyWorldToInner(f,s,a.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ve}=m;function Xe(t,e,i,s,n,o){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ge(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ge(t,i,s,o);break;case"path":i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function Ge(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}V.prototype.__renderMask=function(t,e){let i,s,n,o,a;const{children:r}=this;for(let h=0,d=r.length;h<d;h++)i=r[h],i.__.mask&&(a&&(Xe(this,a,t,n,s,o),s=n=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=je(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="alpha",s||(s=je(t)),n||(n=je(t)),i.__render(s,e)),"clipping"!==i.__.mask)||Ve(i,e)||i.__render(n||t,e);Xe(this,a,t,n,s,o)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qe=He+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ke=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ze=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$e=Je(He),ti=Je(qe),ei=Je("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:si,Single:ni,Before:oi,After:ai,Symbol:ri,Break:hi}=ii;function di(t){return Ke[t]?si:ei[t]?hi:Ze[t]?oi:$e[t]?ai:ti[t]?ri:Qe.test(t)?ni:si}const ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function li(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:ui}=ci,{Letter:fi,Single:gi,Before:pi,After:_i,Symbol:wi,Break:mi}=ii;let yi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ti,Mi,Ai,Ci,Wi,Oi,Pi=[];function Ii(t,e){Li&&!Si&&(Si=Li),yi.data.push({char:t,width:e}),xi+=e}function Di(){bi+=xi,yi.width=xi,vi.words.push(yi),yi={data:[]},xi=0}function Fi(){Ci&&(Wi.paraNumber++,vi.paraStart=!0,Ci=!1),Li&&(vi.startCharSize=Si,vi.endCharSize=Li,Si=0),vi.width=bi,Oi.width&&ui(vi),Pi.push(vi),vi={words:[]},bi=0}const zi=0,Ni=1,Yi=2;const{top:Ui,right:Vi,bottom:Xi,left:ji}=C;function Gi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Hi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o&&(s=d[ji],o-=d[Vi]+d[ji]),a&&(n=d[Ui],a-=d[Ui]+d[Xi]));const c={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Wi=t,Pi=t.rows,Oi=t.bounds;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Oi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Ci=!0,Ti=null,Si=ki=Li=xi=bi=0,yi={data:[]},vi={words:[]};for(let s=0,d=i.length;s<d;s++)Ri=i[s],"\n"===Ri?(xi&&Di(),vi.paraEnd=!0,Fi(),Ci=!0):(Ei=di(Ri),Ei===fi&&"none"!==a&&(Ri=li(Ri,a,!xi)),ki=r.measureText(Ri).width,n&&(n<0&&(Li=ki),ki+=n),Mi=Ei===gi&&(Ti===gi||Ti===fi)||Ti===gi&&Ei!==_i,Ai=!(Ei!==pi&&Ei!==gi||Ti!==wi&&Ti!==_i),Bi=Ci&&o?h-o:h,t&&h&&bi+xi+ki>Bi&&(e?(xi&&Di(),bi&&Fi()):(Ai||(Ai=Ei===fi&&Ti==_i),Mi||Ai||Ei===mi||Ei===pi||Ei===gi||xi+ki>Bi?(xi&&Di(),bi&&Fi()):bi&&Fi()))," "===Ri&&!0!==Ci&&bi+xi===0||(Ei===mi?(" "===Ri&&xi&&Di(),Ii(Ri,ki),Di()):Mi||Ai?(xi&&Di(),Ii(Ri,ki)):Ii(Ri,ki)),Ti=Ei);xi&&Di(),bi&&Fi(),Pi.length>0&&(Pi[Pi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Wi.paraNumber++,Pi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Gi(e,"x",t[ji]);break;case"right":Gi(e,"x",-t[Vi])}if(!n)switch(i.verticalAlign){case"top":Gi(e,"y",t[Ui]);break;case"bottom":Gi(e,"y",-t[Xi])}}(d,c,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:c}=e;let l,u,f,{x:g,y:p,width:_,height:w}=s,m=n*i.length+(c?c*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,n),t.overflow=i.length;else switch(d){case"middle":p+=(w-m)/2;break;case"bottom":p+=w-m}y+=p;for(let o=0,d=i.length;o<d;o++){if(l=i[o],l.x=g,l.width<_||l.width>_&&!r)switch(h){case"center":l.x+=(_-l.width)/2;break;case"right":l.x+=_-l.width}l.paraStart&&c&&o>0&&(y+=c),l.y=y,y+=n,t.overflow>o&&y>m&&(l.isOverflow=!0,t.overflow=o+1),u=l.x,f=l.width,a<0&&(l.width<0?(f=-l.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&_&&_<f&&(l.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=m}(c,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,c,l,u;n.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,l=r||t.isOverflow?zi:d>.01?Ni:Yi,t.isOverflow&&!r&&(t.textMode=!0),l===Yi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,h=t.x,t.data=[],t.words.forEach((e=>{l===Ni?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+n-d;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,s,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,i),c}};const qi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!N.object)return t;t=N.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:Qi,addPoint:Ji,toBounds:Ki}=W;const Zi={export(t,i,s){this.running=!0;const n=d.fileType(i),o=i.includes(".");return s=d.getExportOptions(s),function(t){$i||($i=new O);return new Promise((e=>{$i.add((()=>ge(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((h=>{const c=t=>{r(t),h(),this.running=!1},{toURL:l}=e,{download:u}=e.origin;if("json"===n)return o&&u(l(JSON.stringify(t.toJSON(s.json)),"text"),i),c({data:!!o||t.toJSON(s.json)});if("svg"===n)return o&&u(l(t.toSVG(),"svg"),i),c({data:!!o||t.toSVG()});const{leafer:f}=t;f?(ts(t),f.waitViewCompleted((()=>ge(this,void 0,void 0,(function*(){let e,n,o=1,r=1;const{worldTransform:h,isLeafer:l,isFrame:u}=t,{slice:g,trim:p,onCanvas:_}=s,m=void 0===s.smooth?f.config.smooth:s.smooth,y=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=l&&v&&void 0===s.fill?t.fill:s.fill,b=d.isOpaqueImage(i)||x,B=new P;if(v)e=!0===v?l?f.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(l?"inner":"local");switch(o=h.scaleX,r=h.scaleY,i){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(h).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};L.getScaleData(s.scale,s.size,e,R);let k=s.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:S,y:E,width:T,height:M}=new w(e).scale(R.scaleX,R.scaleY),A={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-S,-E).withScale(1/o*R.scaleX,1/r*R.scaleY)};let C,W=a.canvas({width:Math.round(T),height:Math.round(M),pixelRatio:k,smooth:m,contextSettings:y});if(g&&(C=t,C.__worldOpacity=0,t=f,A.bounds=W.bounds),W.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(W,A),t.fill=e}else t.__render(W,A);if(W.restore(),C&&C.__updateWorldOpacity(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?Ji(a,n,o):Qi(a={},n,o)),r++;const h=new w;return Ki(a,h),h.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:k};W=a.canvas(s),W.copyWorld(t,n,s)}b&&W.fillWorld(W.bounds,x||"#FFFFFF","destination-over"),_&&_(W);const O="canvas"===i?W:yield W.export(i,s);c({data:O,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:n})}))))):c({data:!1})}))))}};let $i;function ts(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ts(t)))}const es=t.prototype,is=y.get("@leafer-ui/export");es.export=function(t,e){const{quality:i,blob:s}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},es.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{is.error(t),s(null)}))}))},es.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},es.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{is.error(t),s(!1)}))}))},Object.assign(X,Hi),Object.assign(N,qi),Object.assign(j,Pt),Object.assign(z,_e),Object.assign(Y,Oe),Object.assign(G,Ue),Object.assign(U,Zi),Object.assign(a,{interaction:(t,e,i,s)=>new Bt(t,e,i,s),hitCanvas:(t,e)=>new q(t,e),hitCanvasManager:()=>new F}),H.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&K(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(r.prototype.getPattern=function(t,i,s,n){const o=e.canvas.createPattern(this.view,i),{width:a,height:r}=t;this.width===a&&this.height===r||(s||(s=S.get()),S.scale(s,a/this.width,r/this.height));try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o});export{Bt as Interaction,ct as Layouter,q as LeaferCanvas,ut as Renderer,xt as Selector,Z as Watcher,K as useCanvas};